@symbo.ls/brender 3.14.678 → 3.14.680

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,51 @@
1
1
  # @symbo.ls/brender
2
2
 
3
+ ## 3.14.680
4
+
5
+ ### Patch Changes
6
+
7
+ - 74ce537: A page's agent view is rendered ahead for AI crawlers (S1). AI crawlers read only the served HTML, and a page's agent view (the landing's `?view=agent`, which its app shows at init) existed in the browser only: every publish-time render was made at the route's address with no query, so `/pricing` and `/pricing?view=agent` served the same bytes.
8
+
9
+ - brender: `render()`, `renderRoute()` and `renderPage()` take `search`, the query of the address the page is rendered at. The render's `location.search` and `location.href` carry it, so a page that reads its query renders that view; the head stays the page's own. `''`, `'?'`, `null` or none render as before, byte for byte; each render owns its location, so the next render never inherits a query. A value that is not a string, or that holds a `#`, throws a TypeError that names the option.
10
+ - utils (`@symbo.ls/utils/server`): `agentViewOf(data)` reads config.js `agentView: { param: 'view', on: 'agent', off: 'human' }` (`true`, `{}` or a missing field take these defaults) under the platform render worker's rules (`param` a letter, then up to 31 letters, digits, `_` or `-`, not `__smbls…`; `on` / `off` 1–32 of those, and different), and throws a TypeError that names the shape for a declaration outside them; null without one. It reads a project payload where the renderer reads `polyglot`: under `data.config` (else `data.settings`) when the payload keeps config nested, else at its top level, where frank spreads config.js — a served `/get` payload has no `config`, and its `settings` is the platform's own. `renderVariantsOf(data)` gives the renders a publish makes beside each page: `[{ name: 'agent', search: '?view=agent' }]`, or `[]`. `AGENT_VIEW_DEFAULTS` is exported.
11
+ - mermaid: `renderProjectHtml` takes `search` (a live render at that query; never the visitor's own query). `@symbo.ls/mermaid/render` exports `renderVariants(data)` — the variant list, read with that lookup — which the platform's publish feature-checks: it then renders each page once more per variant and stores it under `<route><search>`.
12
+ - cli: `smbls publish --ssr` renders each stored route once more per variant, after every page (in page order, `/` first) and within the same time budget, and stores it in the same `PUT /core/projects/:projectId/prerender` under `<route>?<param>=<on>` (`/pricing?view=agent`, `/?view=agent`), the key the platform serves crawlers from. The variants have size budgets of their own, so a site whose pages fill the pages' 16 MB still gets its agent views and a page never loses its place to one: 8 MB for all of them (`--ssr-variant-budget <MB>`, or `symbols.json` `brender.variantBudgetMB`) and 1 MB for one (`--ssr-variant-route-cap <KB>`, or `brender.variantRouteKB`; 1024 is also the most, the platform's cap per stored row — a page keeps its own 512 KB). A flag wins over symbols.json; a value that is not a number above 0, or that passes the platform's cap, stops the publish with a message that names it. A publish keeps within the platform's caps per version, which refuse a larger write as a whole: at most 500 routes, variants included (`maxRoutes`), and 20 MB with the styles, which the variants stop short of. A variant never takes a page's place; a route whose own render was not stored gets none. The publish report lists them apart (`N of M static routes stored and K of L variant renders (?view=agent; X KB)`), and a variant render that was not stored gives one warning with the count, the first route it missed and the reasons (`⚠ 12 of 57 variant renders not stored, from /pricing?view=agent: 12 variant budget spent (8 MB)`). A declaration it cannot use is printed (`agent view not pre-rendered: …`) and the publish stores the pages alone. Without `agentView` a publish renders and stores what it did before.
13
+
14
+ - Updated dependencies [8eb4239]
15
+ - Updated dependencies [b6a3cd6]
16
+ - Updated dependencies [74ce537]
17
+ - Updated dependencies [a271b1b]
18
+ - Updated dependencies [4537877]
19
+ - Updated dependencies [6da9c79]
20
+ - @symbo.ls/default-config@3.14.794
21
+ - @symbo.ls/scratch@3.14.799
22
+ - @symbo.ls/element@3.14.823
23
+ - smbls@3.14.869
24
+ - @symbo.ls/utils@3.14.859
25
+ - @symbo.ls/fetch@3.14.678
26
+
27
+ ## 3.14.679
28
+
29
+ ### Patch Changes
30
+
31
+ - 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.
32
+
33
+ `@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.
34
+
35
+ `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`).
36
+
37
+ - Updated dependencies [bfef7bf]
38
+ - Updated dependencies [0e57128]
39
+ - Updated dependencies [9f253fc]
40
+ - Updated dependencies [9f253fc]
41
+ - Updated dependencies [de2f734]
42
+ - Updated dependencies [d9194ce]
43
+ - @symbo.ls/element@3.14.819
44
+ - @symbo.ls/utils@3.14.855
45
+ - smbls@3.14.862
46
+ - @symbo.ls/fetch@3.14.675
47
+ - @symbo.ls/helmet@3.14.674
48
+
3
49
  ## 3.14.678
4
50
 
5
51
  ### Patch Changes
package/README.md CHANGED
@@ -147,6 +147,7 @@ Options:
147
147
  | Option | Default | What it does |
148
148
  |--------|---------|--------------|
149
149
  | `pathname` | the route | The address the page is rendered at. The router matches it, and `location` (canonical, og:url) reads it. A route with parameters needs one (`renderPage(data, '/:lang/about', { pathname: '/en/about' })`); the not-found page `/*` is rendered at `/404` by `smbls build`. |
150
+ | `search` | — | The query of the address the page is rendered at (`'?view=agent'`; the `?` is added when missing). The render's `location.search` and `location.href` carry it, as a browser's do at that address, so a page that reads its query (an agent view its app shows at init) renders that view; the head is the page's own. `render()` and `renderRoute()` take it too. `''`, `'?'`, `null` or none: no query, and the render is the same as before, byte for byte. A value that is not a string, or that holds a `#`, throws a TypeError that names the option. |
150
151
  | `shell` | — | A built app document (e.g. `dist/index.html`) to render INTO. |
151
152
  | `preloadScripts` | `true` | With `shell`: a high-priority `modulepreload` (`preload as=script` for a classic script) in `<head>` for each script the shell boots from, so the pre-rendered images do not take its bandwidth. `async` and `nomodule` scripts are left alone. |
152
153
  | `eagerImages` | `2` | Images past the first `eagerImages` in the markup get `loading="lazy"`, unless they name their own `loading`. `false` turns it off. |
@@ -209,6 +210,8 @@ No inline script — a strict Content-Security-Policy (`script-src 'self'`, no `
209
210
 
210
211
  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
 
213
+ **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").
214
+
212
215
  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.
213
216
 
214
217
  **The data is the build's.** A pre-rendered page shows the answers its render got until it is rendered again — a `smbls build` page until the next build. A page flagged stale (`<html data-smbls-stale>` from the host, or the project's `fetch.seed.isStale(stamp)` / `fetch.seed.maxAge`) shows them at once and then, after the adoption, asks again and swaps in what changed; `fetch.seed: false` keeps the answers out of the page. See `@symbo.ls/fetch`, "A pre-built page shows the data of its build".
@@ -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/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 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 K,stylesheetRules as T}from"./pageWeight.js";import{markFacesSheet as j,facesSheetMarks as F}from"./faces.js";var z={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:K,stylesheetRules:T,markFacesSheet:j,facesSheetMarks:F};export{f as adoptionScripts,t as assignKeys,g as buildStamp,x as classRulesForPage,P as collectBrNodes,b as composeIntoShell,e as createEnv,z as default,h as extractMetadata,F 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,j 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,T as stylesheetRules,k as trimSpriteToPage,K 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,22 +1,22 @@
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(`
1
+ import{resolve as d,join as nt,dirname as j}from"path";import{existsSync as S,unlinkSync as st,readFileSync as Y,realpathSync as rt}from"fs";import{resolvePackageEntry as ct}from"./packageEntry.js";import{tmpdir as it}from"os";import{randomBytes as lt}from"crypto";import{createRequire as he}from"module";import{pathToFileURL as at}from"url";import{createEnv as Te}from"./env.js";import{resetKeys as ve,assignKeys as Le,mapKeysToElements as Ae}from"./keys.js";import{extractMetadata as ye,generateHeadHtml as ft}from"./metadata.js";import"./hydrate.js";import{composeIntoShell as pt}from"./shell.js";import{trimSpriteToPage as ut,classRulesForPage as mt,markupClasses as dt,trimVariablesToPage as gt}from"./pageWeight.js";import{facesSheetTag as ht}from"./faces.js";import{fetchSSRTranslations as yt}from"./prefetch.js";import{createEarlySeedScript as bt}from"@symbo.ls/fetch";import{headerEntries as St}from"@symbo.ls/fetch/rest";import{brenderStampMeta as Rt,brenderLazyMeta as $e,escapeRegExp as wt,jsonForScript as kt,libraryPackageSpecs as xt,polyglotFallbackLang as be,polyglotLangStorageKey as _t,polyglotAddressLang as Et,polyglotStartupScript as jt}from"@symbo.ls/utils";import{brenderRegistryBlock as Tt,brenderRegistryTreeBlock as vt}from"@symbo.ls/utils/server";import*as Lt from"@symbo.ls/utils/server";let ie=null;const At=async()=>{if(ie)return ie;try{return ie=(await import("@symbo.ls/funcql")).funcqlPlugin,ie}catch{return null}};import"linkedom";import{createEarlySeedBlock as $t,fetchRunsOf as Dt}from"@symbo.ls/fetch";import{reset as Ct}from"@symbo.ls/css";const le=(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},ae=(e,t)=>be(e?.lang,t),Ot=e=>{const t=Lt.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},De=(e,t,o,n)=>{if(o?.translations){const r=o.translations[t];if(r){const l=le(r,e);if(l!==void 0)return l}}if(n?.translations){const r=n.translations[t];if(r){const l=le(r,e);if(l!==void 0)return l}}const s=be(void 0,o);if(s!==t&&o?.translations){const r=o.translations[s];if(r){const l=le(r,e);if(l!==void 0)return l}}},Mt=function(e,t){if(!e)return"";const o=this?.context,n=o?.polyglot,s=this?.state?.root||o?.state?.root,r=De(e,t||ae(s,n),n,s);if(r!==void 0)return r;const l=ke(we);return n&&l&&l.labelKeys.add(e),e},Ce=function(){return ae(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=he(import.meta.url))}catch{}const qt=()=>{if(!import.meta.url||!q)return{isMonorepo:!1,monorepoRoot:null,resolvePackage:p=>p};const e=rt(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 p=q.resolve("smbls/package.json");n=j(p)}catch{let p=e;for(;p!==j(p);){const h=d(p,"node_modules","smbls");if(S(d(h,"package.json"))){n=h;break}p=j(p)}}let s=q;if(n)try{s=he(d(n,"package.json"))}catch{}let r,l=process.cwd();for(;l!==j(l);){if(S(d(l,"package.json"))){r=l;break}l=j(l)}let f=s;if(r)try{f=he(d(r,"package.json"))}catch{}return{isMonorepo:!1,smblsRoot:n,brenderDir:e,projectRoot:r,_smblsRequire:s,_projectRequire:f}},z=(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},sn=(e,t,...o)=>{if(e.isMonorepo)return d(e.monorepoRoot,"packages",t,...o);const n=z(e,`${t}/package.json`);return n?d(j(n),...o):null},rn=(e,t,...o)=>{if(e.isMonorepo)return d(e.monorepoRoot,"plugins",t,...o);const n=z(e,`@symbo.ls/${t}/package.json`);return n?d(j(n),...o):null},Se=(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=z(e,`@symbo.ls/${t}/package.json`);return n?d(j(n),...o):null},Oe=(e,t,...o)=>{if(e.isMonorepo)return d(e.monorepoRoot,"packages","domql","packages",t,...o);const n=z(e,`@symbo.ls/${t}/package.json`);return n?d(j(n),...o):null};let fe=null;const Me="smbls/ssr",Pt=async()=>{const e=await import("smbls/ssr");if(typeof e?.createDomqlElement!="function")throw new Error("smbls/ssr does not export createDomqlElement");return e},qe=()=>(fe||(fe=It().catch(e=>{throw fe=null,e})),fe),It=async()=>{const e=qt();let t;if(q&&e.isMonorepo)t=d(e.monorepoRoot,"packages","smbls","src","createDomql.js");else{let a;try{return await Pt()}catch(c){a=c}if(!q)throw new Error(`brender: ${Me} is not available in this bundled runtime (${a.message}). Bundle smbls \u2265 the release that adds the smbls/ssr export alongside @symbo.ls/brender.`);const i=e.smblsRoot&&d(e.smblsRoot,"src","createDomql.js");if(i&&S(i))t=i;else throw new Error(`brender: cannot load ${Me} (${a.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=nt(it(),`br_createDomql_${lt(6).toString("hex")}.mjs`),s=ct,r=e.isMonorepo?await import(at(d(e.monorepoRoot,"scripts","vite-workspace-source.mjs")).href):null,l=r?new Set(r.workspacePackageRoots().map(a=>r.workspacePackageAt(a).name)):null,f=/^(?:smbls(?:\/.*)?|domql|css-in-props(?:\/.*)?|@symbo\.ls\/[^/]+)$/,p={name:"workspace-resolve",setup(a){r&&(a.onResolve({filter:/^[^./]/},i=>{if(f.test(i.path))return;const c=i.path.split("/"),u=i.path.startsWith("@")?c.slice(0,2).join("/"):c[0];if(!l.has(u))return;const g=r.resolveWorkspaceSource(i.path,i.importer||t);return g?{path:g}:{errors:[{text:`"${i.path}" names no source file in the workspace`}]}}),a.onLoad({filter:/[\\/]dist[\\/]/},i=>r.isWorkspaceDist(i.path)?{errors:[{text:`${i.path} is a BUILD of a workspace package \u2014 the render bundles source`}]}:void 0)),a.onResolve({filter:/^smbls/},i=>{const c=i.path.replace(/^smbls\/?/,""),u=e.isMonorepo?d(e.monorepoRoot,"packages","smbls"):e.smblsRoot;if(!u)return;if(!c){const E=s(u);return E?{path:E}:void 0}const g=d(u,c);if(S(g))return{path:g};if(S(g+".js"))return{path:g+".js"};const R=d(g,"index.js");if(S(R))return{path:R}}),a.onResolve({filter:/^domql$/},i=>{if(e.isMonorepo){const c=d(e.monorepoRoot,"packages","domql","src","index.js");if(S(c))return{path:c};const u=d(e.monorepoRoot,"packages","domql","index.js");if(S(u))return{path:u}}else try{const c=_require.resolve("domql/package.json"),u=s(j(c));if(u)return{path:u}}catch{}}),a.onResolve({filter:/^@symbo\.ls\//},i=>{const c=i.path.replace("@symbo.ls/","");if(c==="sync")return{path:"sync-stub",namespace:"brender-stub"};if(e.isMonorepo){for(const g of["packages","plugins"]){const R=d(e.monorepoRoot,g,c,"src","index.js");if(S(R))return{path:R};const E=d(e.monorepoRoot,g,c,"index.js");if(S(E))return{path:E}}const u=d(e.monorepoRoot,"packages","default-config","blank","index.js");if(c==="default-config"&&S(u))return{path:u}}else{const u=Se(e,c,"src","index.js");if(u&&S(u))return{path:u};const g=Se(e,c,"index.js");if(g&&S(g))return{path:g};if(c==="default-config"){const R=Se(e,"default-config","blank","index.js");if(R&&S(R))return{path:R}}}}),a.onResolve({filter:/^@domql\//},i=>{const c=i.path.replace("@symbo.ls/","");if(e.isMonorepo){const u=d(e.monorepoRoot,"packages","domql","packages",c,"src","index.js");if(S(u))return{path:u};const g=d(e.monorepoRoot,"packages","domql","packages",c,"index.js");if(S(g))return{path:g}}else{const u=Oe(e,c,"src","index.js");if(u&&S(u))return{path:u};const g=Oe(e,c,"index.js");if(g&&S(g))return{path:g}}}),a.onResolve({filter:/^css-in-props/},i=>{let c;if(e.isMonorepo)c=d(e.monorepoRoot,"packages","css-in-props");else{const R=z(e,"css-in-props/package.json");R&&(c=j(R))}if(!c)return;const u=i.path.replace(/^css-in-props\/?/,"");if(u){const R=d(c,u),E=d(R,"index.js");if(S(E))return{path:E};if(S(R+".js"))return{path:R+".js"};if(S(R))return{path:R}}const g=s(c);if(g)return{path:g}}),a.onResolve({filter:/^@emotion\//},i=>{let c;if(e.isMonorepo)c=d(e.monorepoRoot,"node_modules",i.path);else{const u=z(e,`${i.path}/package.json`);if(!u)return;c=j(u)}if(S(c)){const u=d(c,"package.json");if(S(u))try{const g=JSON.parse(Y(u,"utf8")),R=g.module||g.main||"dist/emotion-css.esm.js";return{path:d(c,R)}}catch{}return{path:c}}}),a.onResolve({filter:/\.json$/},i=>{if(i.resolveDir){const c=d(i.resolveDir,i.path);if(S(c))return{path:c}}}),a.onLoad({filter:/smbls\/.*options\.js$/},async i=>{if(!i.path.includes("smbls/")||!i.path.endsWith("options.js"))return;let c=Y(i.path,"utf8");return c=c.replace(/import\s*\{[^}]*version[^}]*\}\s*from\s*['"][^'"]*package\.json['"][^;\n]*/,"const version = '0.0.0'"),c=c.replace(/import\s*\{[^}]*createRequire[^}]*\}\s*from\s*['"]module['"][^;\n]*/g,"// createRequire removed for brender build"),{contents:c,loader:"js"}}),a.onLoad({filter:/smbls\/.*init\.js$/},async i=>{if(!i.path.includes("smbls/")||!i.path.endsWith("init.js"))return;let c=Y(i.path,"utf8");return c=c.replace(/import\s*\{[^}]*createRequire[^}]*\}\s*from\s*['"]module['"][^;\n]*/g,"// createRequire removed for brender build"),{contents:c,loader:"js"}}),a.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"})),a.onLoad({filter:/smbls\/src\/router\.js$/},async i=>{let c=Y(i.path,"utf8");return c=c.replace(/import\s*\{\s*Link\s*\}\s*from\s*['"]smbls['"]/,"const Link = { tag: 'a', attr: { href: (el) => el.href } }"),{contents:c,loader:"js"}}),a.onLoad({filter:/fetchOnCreate\.js$/},async i=>{if(!i.path.includes("smbls/"))return;let c=Y(i.path,"utf8");return c=c.replace(/window\s*&&\s*window\.location\s*\?\s*window\.location\.host\.includes/g,"window && window.location && window.location.host ? window.location.host.includes"),{contents:c,loader:"js"}})}};await o.build({entryPoints:[t],bundle:!0,format:"esm",platform:"node",outfile:n,write:!0,logLevel:"warning",plugins:[p],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(a=>S(a)),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 h=await import(`file://${n}`);if(process.env.BRENDER_DEBUG)console.log("[brender] Bundle saved:",n);else try{st(n)}catch{}return h},Ft={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"}},Gt=(e,t)=>{const o={};return Pe(e,(n,s)=>{if(!s.__brKey)return;const r=t(n);o[r===""?"__root":r]=s.__brKey}),o},Pe=(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)},Bt=new Set(["app","config","pages","components","state","snippets","designSystem","dependencies","functions","methods","files","sharedLibraries"]);let W=0;const Ie=Symbol.for("brender.fetchTracked"),Re=()=>W,Kt=256*1024,Nt=1024*1024,Ht=new Set(["accept-language","accept"]),Fe={renders:0,record:null},zt=50,we={renders:0,record:null},Ge=(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)}}},ke=e=>e.record&&!e.record.tainted?e.record:null,Wt=e=>{try{const t=new URL(e);return t.origin+t.pathname}catch{return String(e).split("?")[0]}},xe=(e,t,o)=>{!e||e.tainted||e.failures.length>=zt||e.failures.push({url:Wt(t),reason:o})},Be=e=>e&&typeof e=="object"&&typeof e.url=="string"?e.url:String(e),Ut=e=>{const[t,o]=e,n=t&&typeof t=="object"&&typeof t.url=="string",s=Be(t),r=String(o&&o.method||n&&t.method||"GET").toUpperCase(),l={},f=p=>{if(!p)return;const h=!Array.isArray(p)&&typeof p.entries!="function";for(const[a,i]of St(p))h&&i==null||(l[String(a).toLowerCase()]=String(i))};return n&&f(t.headers),o&&f(o.headers),{url:s,method:r,headers:l}},Vt=(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(l=>{e.tainted||l.length>Kt||e.bytes+l.length>Nt||(e.bytes+=l.length,e.entries.push({url:t.url,lang:t.headers["accept-language"]||"",status:o.status,type:s,body:l}))},()=>{}))},Jt=()=>{const e=globalThis.fetch;if(typeof e!="function"||e[Ie])return;const t=function(...o){W++;let n=!1;const s=()=>{n||(n=!0,W--)},r=i=>{W++,i.then(()=>{W--},()=>{W--})},l=ke(Fe),f=ke(we);let p=null;if(l)try{p=Ut(o),(p.method!=="GET"||!/^https?:/i.test(p.url)||Object.keys(p.headers).some(i=>!Ht.has(i)))&&(p=null)}catch{p=null}const h=()=>Be(o[0]);let a;try{a=e.apply(this,o)}catch(i){throw xe(f,h(),i&&i.message||"failed"),s(),i}return a&&typeof a.then=="function"?a.then(i=>{p&&Vt(l,p,i,r),f&&i&&i.ok===!1&&xe(f,h(),"HTTP "+i.status),s()},i=>{xe(f,h(),i&&i.message||"network error"),s()}):s(),a};t[Ie]=!0,globalThis.fetch=t},cn=({brRegistry:e,fetchSeed:t,hydrateFlag:o=!0}={})=>{if(!e||!Object.keys(e).length)return"";const n=kt(e);return o?`<script>window.__BR_REGISTRY__=${n};window.__BRENDER_HYDRATE__=true<\/script>`+(t&&t.length?`
2
+ `+bt(t):""):`<script>window.__BR_REGISTRY__=${n}<\/script>`},Yt=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=xt(e())}catch{return}for(const[r]of s)!o.has(r)&&Object.prototype.hasOwnProperty.call(n,r)&&Reflect.deleteProperty(n,r)}},Xt=3e4,Qt=2147483647;let Ke=Promise.resolve();const Ne=()=>{},Zt=e=>{const t=Ke.then(e);return Ke=t.then(Ne,Ne),t},eo=e=>{if(e===void 0)return Xt;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,Qt)},He=e=>{if(e==null||e===""||e==="?")return"";if(typeof e!="string"||e.includes("#"))throw new TypeError(`brender: options.search is a query string ('?view=agent'), without a hash \u2014 not ${JSON.stringify(e)}`);return e.charAt(0)==="?"?e:"?"+e},to=(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},oo=e=>{e.closed=!0;for(const t of e.undo.splice(0))t()},no=e=>{let t=!1;return()=>{t||(t=!0,e())}},ze=(e,t={})=>{let o;try{o=eo(t.timeout),He(t.search)}catch(n){return Promise.reject(n)}return Zt(()=>so(e,t,o))},so=async(e,t,o)=>{await qe();const n={closed:!1,undo:[]},s=ro(e,t,n);if(!o)return s;let r;const l=new Promise((f,p)=>{r=setTimeout(()=>{oo(n),p(to(t,o))},o)});try{return await Promise.race([s,l])}finally{clearTimeout(r)}},ro=async(e,t,o)=>{const{route:n="/",pathname:s,state:r,context:l,prefetch:f=!1,lazyGroups:p}=t,h=s||n,a=He(t.search);Jt();const i=Ge(we,()=>({failures:[],labelKeys:new Set,tainted:!1}));try{return await co(Ot(e),{route:n,locationPath:h,locationSearch:a,stateOverrides:r,contextOverrides:l,prefetch:f,lazyGroups:p},i.record,o)}finally{i.close()}},co=async(e,{route:t,locationPath:o,locationSearch:n,stateOverrides:s,contextOverrides:r,prefetch:l,lazyGroups:f},p,h)=>{const a=()=>{if(h.closed)throw new Error("brender: this render was abandoned at its timeout")};let i;if(l){try{i=await yt(e)}catch(P){h.closed||console.warn("[brender] SSR translation fetch failed:",P.message)}a()}const{window:c,document:u}=Te(),g=u.body;c.location.pathname=o,n&&(c.location.search=n,c.location.href=c.location.origin+o+n);let R=null;const E=[pe("document",u),pe("location",c.location),pe("localStorage",c.localStorage),pe("sessionStorage",c.sessionStorage),Yt(()=>R&&R.sharedLibraries)].map(no);h.undo.push(...E);try{const{createDomqlElement:P,PRERENDER_REGISTRY_FORMATS:X}=await qe();a();const de=L(e.app||{}),x={...e.config||{}};e.polyglot&&!x.polyglot&&(x.polyglot=e.polyglot),e.fetch&&!x.fetch&&(x.fetch=e.fetch),e.router&&!x.router&&(x.router=e.router);for(const m of mo)e[m]!=null&&x[m]==null&&(x[m]=e[m]);const _=x.polyglot?{...x.polyglot,prefetch:!1}:void 0,Q=Et(o,_);Q&&c.localStorage.setItem(_t(_),Q),i&&_&&(_.translations={..._.translations||{},...i});const Z=L(e.state||{});Ct();const I={};for(const m in e){if(Bt.has(m))continue;const b=e[m];I[m]=b&&typeof b=="object"?L(b):b}const k={...I,state:Z,...s?{state:{...Z,...s}}:{},dependencies:L(e.dependencies||{}),components:L(e.components||{}),snippets:L(e.snippets||{}),pages:L(e.pages||{}),functions:{...e.functions||{},polyglot:Mt,getActiveLang:Ce,getLang:Ce},methods:e.methods||{},designSystem:L(e.designSystem||{}),files:e.files||{},sharedLibraries:e.sharedLibraries||[],...x,..._?{polyglot:_}:{},document:u,window:c,parent:{node:g},initOptions:{},domqlOptions:{sourcemap:!1},firstRender:!1,sync:!1,inspect:!1,notifications:!1,afterFirstView:null,isolateDesignSystem:!0,isolateFetchCache:!0,captureDesignSystem:!0,...io(f),...r||{},ssr:!0};R=k;const ee=await At();a(),ee&&(k.plugins=k.plugins||[],k.plugins.some(m=>m.name==="funcql")||k.plugins.push(ee)),ve();const K=Ge(Fe,()=>({entries:[],bytes:0,tainted:!1})),y=K.record;let w;try{if(w=await P(de,k),a(),k.lazyFirstView){const D=(w&&w.context||k).__firstNavigation;if(D&&typeof D.then=="function"){try{await D}catch{}a()}}const m=Date.now(),b=l?2e3:50,T=D=>new Promise(ce=>setTimeout(ce,D));for(await T(Math.min(50,b));l&&!h.closed&&Re()>0&&Date.now()-m<b;)await T(10),Re()===0&&await T(Math.max(0,Math.min(50,b-(Date.now()-m))));if(a(),l&&await lo(w,_)){a();const D=Date.now();for(await T(Math.min(50,b));!h.closed&&Re()>0&&Date.now()-D<b;)await T(10);a()}}finally{K.close()}const U=y&&!y.tainted&&!(x.fetch&&x.fetch.seed===!1)?y.entries.slice():[];Le(g);const A=Ae(w),{elementPath:N}=await import("@symbo.ls/element");a();const te=Gt(w,N),oe=U.length?Dt(w&&w.context||k,N):{},V=w?.context?.routerOptions?.contentElementKey||"content",F=w&&w[V],C=F&&typeof F=="object"&&F.__ref?F:void 0,je=ye(e,t,w,w?.state,C),O=[],J=u.head||u.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&&O.push(b);if(!O.length){const b=m.textContent||"";b&&O.push({cssText:b})}}const ne=O.map(m=>m.cssText),{globalCSS:se,classRules:ge}=Ro(O);let v=Ve(g.innerHTML);const G=w?.state?.root,B=ae(G,_),M=ao(i,G);M&&(v=Ue(v,We(M,B,_)));const H=p&&!p.tainted?{failedRequests:p.failures.slice(),rawLabelKeys:uo(p.labelKeys,v,B,_,G)}:null,$=(w&&w.context||k).__lazyFirstViews,re=$&&typeof $.forEach=="function"?[...$]:[];return{html:v,metadata:je,registry:A,brRegistry:te,element:w,emotionCSS:ne,lazyGroups:re,globalCSS:se,classRules:ge,fetchSeed:U,fetchRuns:oe,document:u,window:c,ssrTranslations:M||void 0,activeLang:B,diagnostics:H,preparedDesignSystem:k.preparedDesignSystem||null,registryFormats:Array.isArray(X)?X.slice():["paths"]}}finally{for(const P of E)P()}},io=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{}},pe=(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]})},lo=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=ae(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},_e=/\{\{\s*([^|{}]+?)\s*\|\s*polyglot\s*\}\}/g,Ee=e=>e&&typeof e.parse=="function"?e.parse():e,ao=(e,t)=>{const o=Ee(t?.translations),n={};for(const s of[e,o])if(!(!s||typeof s!="object"))for(const r in s){const l=Ee(s[r]);l&&typeof l=="object"&&(n[r]={...n[r]||{},...l})}return Object.keys(n).length?n:null},We=(e,t,o)=>e[t]||e[be(void 0,o)]||Object.values(e)[0]||{},Ue=(e,t)=>e.replace(_e,(o,n)=>le(t,n.trim())??o),fo=/<script\b[^>]*\btype\s*=\s*["']?application\/json["']?[^>]*>[\s\S]*?<\/script\s*>/gi,po=(e,t)=>new RegExp(`(?:^|[^\\w.-])${wt(t)}(?![\\w-]|\\.\\w)`).test(e),uo=(e,t,o,n,s)=>{const r=new Set,l=t.replace(fo,"");for(const f of e)/\s/.test(f)||De(f,o,n,s)===void 0&&po(l,f)&&r.add(f);for(const f of l.matchAll(_e))r.add(f[1].trim());return[...r]},ln=async(e,t={})=>{const{context:o={}}=t,{window:n,document:s}=Te(),r=s.body,{create:l}=await import("@symbo.ls/element"),f=await import("@symbo.ls/utils"),p={...Ft,...o.components||{}},h={...f,...o.utils||{},...o.functions||{}};ve();let a;try{a=l(e,{node:r},"root",{context:{document:s,window:n,...o,components:p,utils:h,ssr:!0}})}catch{}Le(r);const i=a?Ae(a):{};return{html:Ve(r.innerHTML),registry:i,element:a}},Ve=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}),mo=["globalTheme","themeStorageKey","themeRoot","useReset","useVariable","useFontImport","useIconSprite","useSvgSprite","useDocumentTheme","useDefaultConfig","useDefaultIcons","useThemeSuffixedVars","verbose","semanticIcons"],go=new Set(["auto","system"]),Je=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||go.has(s)?null:s},ho=e=>String(e).replace(/&/g,"&amp;").replace(/"/g,"&quot;").replace(/</g,"&lt;"),yo=/\.[A-Za-z_\\-]/,bo=e=>{if(typeof e!="string"||!e)return!1;const t=e.replace(/"(?:[^"\\]|\\.)*"|'(?:[^'\\]|\\.)*'/g,'""').replace(/\[[^\]]*\]/g,"[]");return!yo.test(t)},So=/^\s*(:root|\[data-theme|\[data-skin)/,Ye=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 bo(e.selectorText)?So.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(Ye));return n.has(null)||n.size!==1?n.has(null)?null:"reset":[...n][0]}return null},Xe=e=>typeof e=="string"&&/^\s*@font-face\b/i.test(e),Ro=e=>{const t={root:[],reset:[],keyframes:[]},o=[];for(const n of e||[]){const s=Ye(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 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">
5
+ `),fontFaceCSS:""},classRules:o}};let ue=new Set;const an=()=>{ue=new Set},fn=()=>Array.from(ue).join(`
6
+ `),pn=(e,t)=>e.replace(/<style data-emotion="smbls">[\s\S]*?<\/style>/,t?`<style data-emotion="smbls">
7
7
  ${t}
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
- `):te.join(`
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)||""}
8
+ </style>`:""),un=async(e,t={})=>{const{route:o="/",pathname:n,search:s,prefetch:r=!0,timeout:l}=t,f=await ze(e,{route:o,pathname:n,search:s,prefetch:r,timeout:l});if(!f)return null;const p=e.designSystem||{},h=f.globalCSS;let a=null;try{const c=wo(f.element);Object.keys(c).length&&(a=c)}catch{}const i=f.activeLang;return{html:f.html,css:f.classRules.join(`
9
+ `),classRules:f.classRules.slice(),globalCSS:h,resetCss:h.resetRules,fontLinks:ot(p),metadata:f.metadata||ye(e,o),brKeyCount:f.registry?Object.keys(f.registry).length:0,brRegistry:f.brRegistry||{},fetchSeed:f.fetchSeed||[],fetchRuns:f.fetchRuns||{},ssrTranslations:f.ssrTranslations,prefetchedState:a,activeLang:i,theme:Je(e),diagnostics:f.diagnostics,preparedDesignSystem:f.preparedDesignSystem||null}},wo=e=>{const t={};return Pe(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 l=r.startsWith("~/"),f=l?r.slice(2):r,p=l?o.state.root:o.state,h=Ee(p&&p[f]);f&&h!=null&&typeof h!="function"&&(t[f]=h)}}),t},mn=async(e,t="/",o={})=>{const{lang:n,themeColor:s,isr:r,hydrate:l=!0,prefetch:f=!0,shell:p,adoptDom:h=!1,pathname:a,search:i,eagerImages:c=tt,preloadScripts:u=!0,nonce:g,timeout:R,stamp:E,time:P,spriteIcons:X="all",cssClasses:de="all",cssVariables:x="all",registryFormat:_="paths",lazyGroups:Q,paint:Z}=o,I=ko(Z),k=Ao(g),ee=n||e.state?.lang||e.app?.metadata?.lang||"en",K=Je(e),y=await ze(e,{route:t,pathname:a,search:i,prefetch:f,timeout:R,lazyGroups:Q});if(!y)return null;const w={...y.metadata};if(s&&(w["theme-color"]=s),typeof p=="string"&&!e.name){const m="\0brender-undeclared-title\0";if(ye({...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 U=ft(w);for(const m of y.classRules)m&&ue.add(m);let A=To(y.html,c);X==="page"&&(A=ut(A,typeof p=="string"?p:"").html);const N=Array.from(ue),te=N.filter(Xe),oe=te.length?N.filter(m=>!Xe(m)):N,V=de==="page"?mt(oe,dt(A,typeof p=="string"?p:"")).join(`
10
+ `):oe.join(`
11
+ `),F=ht(te),C=y.globalCSS,O=`<style data-brender>
12
+ ${(x==="page"?gt(C.rootRule||"",C.resetRules,C.keyframeRules,V,A,typeof p=="string"?p:"").css:C.rootRule)||""}
13
13
  ${C.resetRules||""}
14
14
  ${C.keyframeRules||""}
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+`
18
- `:"",re=v.blocks?v.blocks+`
19
- `:"";F=`${D}${re}<script type="module" src="${b}${r.clientScript}"${x}><\/script>`}else F=`<script type="module"${x}>
15
+ </style>`,J=V?`<style data-emotion="smbls">
16
+ ${V}
17
+ </style>`:"",ne=ot(e.designSystem||{}),se=Object.keys(y.registry).length,ge=_==="tree"||_==="auto"&&(y.registryFormats||[]).includes("tree"),v=vo({brRegistry:y.brRegistry,fetchSeed:y.fetchSeed,fetchRuns:y.fetchRuns,adoptDom:h,stamp:E,time:P,registryFormat:ge?"tree":"paths",lazyGroups:y.lazyGroups});let G="";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(l){const T=jt({polyglot:e.polyglot||e.config?.polyglot,translations:y.ssrTranslations,lang:y.activeLang,pathname:a||t,attrs:k}),D=T?T+`
18
+ `:"",ce=v.blocks?v.blocks+`
19
+ `:"";G=`${D}${ce}<script type="module" src="${b}${r.clientScript}"${k}><\/script>`}else G=`<script type="module"${k}>
20
20
  {
21
21
  const brEls = document.querySelectorAll('body > :not(script):not(style)')
22
22
  const observer = new MutationObserver((mutations) => {
@@ -33,29 +33,29 @@ ${U}
33
33
  observer.observe(document.body, { childList: true })
34
34
  }
35
35
  <\/script>
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)}"`:""}>
36
+ <script type="module" src="${b}${r.clientScript}"${k}><\/script>`}const B={...e.config||{}};e.polyglot&&!B.polyglot&&(B.polyglot=e.polyglot);const M=B.polyglot;let H=U;if(M){const m={...M.translations||{}};for(const b in y.ssrTranslations||{})m[b]={...m[b]||{},...y.ssrTranslations[b]};H=Ue(U,We(m,y.activeLang,M))}const $=y.diagnostics;if($)for(const m of H.matchAll(_e)){const b=m[1].trim();$.rawLabelKeys.includes(b)||$.rawLabelKeys.push(b)}if(typeof p=="string"){const m=pt(p,{headTags:`${H}
37
+ ${v.meta}`,headEnd:[ne,F,O,J].filter(Boolean).join(`
38
+ `),body:I?A+`
39
+ `+Ze:A,depth:Number.isInteger(o.depth)?o.depth:0,bootScripts:v.blocks,lang:n||(M?y.activeLang:void 0),theme:K,preloadScripts:u});return{html:I?et(m):m,route:t,brKeyCount:se,shell:!0,diagnostics:$,preparedDesignSystem:y.preparedDesignSystem||null,lazyGroups:y.lazyGroups||[]}}const re=`<!DOCTYPE html>
40
+ <html lang="${ee}"${K?` data-theme="${ho(K)}"`:""}>
41
41
  <head>
42
- ${N}${r&&r.clientScript&&i?`
42
+ ${H}${r&&r.clientScript&&l?`
43
43
  ${v.meta}`:""}
44
- ${oe}
45
- ${I}
46
- ${M}
47
- ${V}
44
+ ${ne}
45
+ ${F}
46
+ ${O}
47
+ ${J}
48
48
  </head>
49
49
  <body>
50
- ${A}${P?`
51
- ${Xe}`:""}
52
- ${F}
50
+ ${A}${I?`
51
+ ${Ze}`:""}
52
+ ${G}
53
53
  </body>
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)+`
56
- `+ue+e.slice(n.index+n[0].length)}return ue+`
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};
54
+ </html>`;return{html:I?et(re):re,route:t,brKeyCount:se,diagnostics:$,preparedDesignSystem:y.preparedDesignSystem||null,lazyGroups:y.lazyGroups||[]}},Qe="smbls-whole",Ze=`<template id="${Qe}"></template>`,me=`<link rel="expect" href="#${Qe}" blocking="render">`,ko=e=>!!(e&&typeof e=="object"&&e.whole===!0),xo=/<meta\b[^>]*\bcharset\s*=[^>]*>/i,_o=[/<head\b[^>]*>/i,/<html\b[^>]*>/i,/^\s*<!doctype\b[^>]*>/i],et=e=>{if(typeof e!="string"||e.includes(me))return e;const t=xo.exec(e.slice(0,1024));if(t){const o=t.index+t[0].length;return e.slice(0,o)+`
55
+ `+me+e.slice(o)}for(const o of _o){const n=o.exec(e);if(n)return e.slice(0,n.index+n[0].length)+`
56
+ `+me+e.slice(n.index+n[0].length)}return me+`
57
+ `+e},tt=2,Eo=/<img\b(?:[^>"']|"[^"]*"|'[^']*')*>/gi,jo=/\sloading\s*=/i,To=(e,t=tt)=>{if(t===!1||t==null||typeof e!="string")return e;const o=Math.max(0,Number(t)||0);let n=0;return e.replace(Eo,s=>n++<o||jo.test(s)?s:s.replace(/^<img\b/i,'<img loading="lazy"'))},ot=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
+ `):""},vo=({brRegistry:e,fetchSeed:t,fetchRuns:o,adoptDom:n=!1,stamp:s,time:r,registryFormat:l="paths",lazyGroups:f}={})=>{const h=n&&e&&Object.keys(e).length?l==="tree"&&vt(e)||Tt(e):"",a=$t(t,o);return{meta:`<meta name="brender" content="${h?"hydrate":"replace"}">
59
+ `+Rt(Lo(s,r))+($e(f)?`
60
+ `+$e(f):""),blocks:[h,a].filter(Boolean).join(`
61
+ `)}},Lo=(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}},Ao=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{tt as EAGER_IMAGES_DEFAULT,Me as SMBLS_SSR_SPECIFIER,Qe as WHOLE_MARKER_ID,cn as adoptionScripts,Lo as buildStamp,Je as fixedThemeOf,fn as getAccumulatedEmotionCSS,To as markLazyImages,ko as paintsWhole,vo as prerenderParts,ze as render,ln as renderElement,mn as renderPage,un as renderRoute,pn as replaceEmotionCSS,an as resetGlobalCSSCache,Ro as splitCapturedCSS,et as withWholePaint};