@symbo.ls/brender 3.14.680 → 3.14.682

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,31 @@
1
1
  # @symbo.ls/brender
2
2
 
3
+ ## 3.14.682
4
+
5
+ ### Patch Changes
6
+
7
+ - 6b34e4a: A built page writes its atomic rules in the app's cascade-tier order (XMA #1283). In the app each rule sits in a tier sheet (`@symbo.ls/css` atomic.js "Cascade tiers": max-width rules narrowest last, min-width widest last, a longhand class after its shorthand). brender's `renderPage` kept the rules of every page of a build in one set and wrote them in that set's order, each where the FIRST page that used it put it: `/` minted `@media (max-width: 560px){…{grid-template-columns:1fr}}`, `/b` minted the 768 px rule after it, and the built `/b` wrote 560 before 768, so at 390 px it showed 2 columns where the app shows 1 (and a longhand class an earlier page minted lost to the shorthand a later page needs). `@symbo.ls/css` exports `tierOfStyle(style)` (the tier of a `<style>` the engine made, read off its `data-tier`; null for any other `<style>`) and `sortByTier(items, tierOf)` (a stable sort in cascade order, on the one tier comparison the sheets' own placement uses). brender's render names the tier of each captured class rule (`classRuleTiers`, also on `renderRoute`'s result: the tier of the engine sheet it was read from, never re-derived from the rule's text), and `renderPage` (both `cssClasses` modes) and `getAccumulatedEmotionCSS` write the rules by tier, in first-written order inside a tier; one page's own rules keep their order, and the `@font-face` rules keep theirs. brender also exports `sortByTier` for a caller that merges several renders: `smbls publish`'s pre-render (`buildSsrCache`) now stores the routes' shared rules (`__ssr.__styles.css`) in tier order, so the platform serves `/b` with 768 before 560 too; with an older brender it keeps the first-seen order. `smbls` re-exports the two helpers (`export *` of `@symbo.ls/css`) and inlines the engine in its bundles.
8
+ - Updated dependencies [6b34e4a]
9
+ - Updated dependencies [0db50ef]
10
+ - Updated dependencies [b4c02a8]
11
+ - Updated dependencies [a4fdcb8]
12
+ - @symbo.ls/css@3.14.783
13
+ - smbls@3.14.877
14
+ - @symbo.ls/element@3.14.829
15
+
16
+ ## 3.14.681
17
+
18
+ ### Patch Changes
19
+
20
+ - 849f8c1: frank writes an app's lang map once. An app whose polyglot reads its design system's lang map (`polyglot: { translations: lang }`, `lang` imported from `designSystem/lang.js` — the workspace apps' pattern) shipped the map twice: frank keeps the shared reference, and JSON writes a shared object at each place it occurs (a commerce app's payload: +102,603 bytes, +17.6 %). `frank.toJSON` now keeps the map in `designSystem.lang` (where the workspace shell reads a module's copy) and writes the polyglot config with `translationsFrom: 'designSystem.lang'` in the place of `translations` — only when the translations ARE that map (the same object, or a copy with the same content). Every reader puts the map back before it reads the config: `@symbo.ls/utils` adds `polyglotTranslations(project, polyglot)` (a read), `resolvePolyglotTranslations(project)` (in place — `smbls` `prepareContext` resolves the runtime's context before the shared libraries merge in) and `withPolyglotTranslations(project)` (a view — `@symbo.ls/brender` `render`/`renderPage`, `@symbo.ls/mermaid` `renderProjectHtml`'s start-up script and language, each shared library merge; the payload a server also serves is never written, so it keeps the map once); utils `getPageMetadata` resolves head labels from the pointer; `@symbo.ls/sync` resolves a livesync snapshot before it applies it (`resolveSnapshotTranslations`), so an edited copy reaches the page with the snapshot. A config with `translations` as well gets the named map with its own labels over it, per language. `@symbo.ls/polyglot`: the README documents `translationsFrom`. A runtime older than this release reads such a payload as a polyglot without static strings (the keys show): release the runtime packages and the mermaid-server pin before apps push with this frank.
21
+ - 71f56ce: `@symbo.ls/fetch` ships a built-in `symbols` adapter (`adapters/symbols.js`, also `@symbo.ls/fetch/symbols`): a published site reads and writes through the platform SDK, signed out, with `fetch: { adapter: 'symbols', load: () => import('@symbo.ls/sdk') }` in its config. The adapter loads the SDK on the first query only (frank publishes the literal import() as the lazy host-package marker, so the page declares the SDK file instead of inlining it), builds ONE SDK per page (memory tokens, the SDK's own telemetry off, the API base from `window.__SYMBOLS_ENV__`), and maps every op the way the hosts' 'sdk' adapter does (`select → list`, `insert → create`, …; every answer `{ data, error }`). It has no session surface. It is built in under its own name: a built-in 'sdk' would answer a host's first elements before the host's own late `registerAdapter('sdk')` (measured; `sdkAdapterShellRace.test.js`), so 'sdk' stays the hosts'. `resolveDb(config, env)` hands `env` (`{ serverRender }`, set from a context's `isolateFetchCache`) to `setup(options, env)`; the `symbols` adapter answers `null` in a server render, so the query is skipped there and the server never loads the SDK or calls the API. `@symbo.ls/brender` `createSSRAdapter` passes `{ serverRender: true }`. `smbls`: the full esm build keeps the new adapter import static (no `__esm` initializer), the core build gates it as kit `symbols` (`build.treeShakeFeatures`), and the bundles carry the new adapter.
22
+ - Updated dependencies [ed88d4e]
23
+ - Updated dependencies [849f8c1]
24
+ - Updated dependencies [71f56ce]
25
+ - @symbo.ls/fetch@3.14.679
26
+ - smbls@3.14.872
27
+ - @symbo.ls/utils@3.14.860
28
+
3
29
  ## 3.14.680
4
30
 
5
31
  ### Patch Changes
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 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
+ 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 i,renderRoute as p,renderPage as l,resetGlobalCSSCache as d,getAccumulatedEmotionCSS as n,replaceEmotionCSS as c,adoptionScripts as f,prerenderParts as S,buildStamp as g,sortByTier as h}from"./render.js";import{extractMetadata as u,generateHeadHtml as P}from"./metadata.js";import{collectBrNodes as y,hydrate as C}from"./hydrate.js";import{generateSitemap as E}from"./sitemap.js";import{prefetchPageData as R,injectPrefetchedState as T}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 j,facesSheetMarks as B}from"./faces.js";import{drawnFaces as H}from"./drawnFaces.js";var O={createEnv:e,resetKeys:r,assignKeys:t,mapKeysToElements:o,loadProject:a,loadAndRenderAll:m,render:s,renderElement:i,renderRoute:p,renderPage:l,resetGlobalCSSCache:d,getAccumulatedEmotionCSS:n,replaceEmotionCSS:c,extractMetadata:u,generateHeadHtml:P,collectBrNodes:y,hydrate:C,generateSitemap:E,prefetchPageData:R,injectPrefetchedState:T,composeIntoShell:b,adoptionScripts:f,prerenderParts:S,buildStamp:g,trimSpriteToPage:k,classRulesForPage:x,markupClasses:A,trimVariablesToPage:F,stylesheetRules:K,sortByTier:h,markFacesSheet:j,facesSheetMarks:B,drawnFaces:H};export{f as adoptionScripts,t as assignKeys,g as buildStamp,x as classRulesForPage,y as collectBrNodes,b as composeIntoShell,e as createEnv,O as default,H as drawnFaces,u as extractMetadata,B as facesSheetMarks,P as generateHeadHtml,E as generateSitemap,n as getAccumulatedEmotionCSS,C as hydrate,T as injectPrefetchedState,m as loadAndRenderAll,a as loadProject,o as mapKeysToElements,j as markFacesSheet,A as markupClasses,R as prefetchPageData,S as prerenderParts,s as render,i as renderElement,l as renderPage,p as renderRoute,c as replaceEmotionCSS,d as resetGlobalCSSCache,r as resetKeys,h as sortByTier,K as stylesheetRules,k as trimSpriteToPage,F as trimVariablesToPage};
@@ -1 +1 @@
1
- const l=t=>typeof t=="function",A=t=>Array.isArray(t),y=t=>t!==null&&typeof t=="object"&&!Array.isArray(t),_=(t,n)=>{if(t){if(l(t))try{return t({state:n||{},call:()=>{},__ref:{}},n||{})}catch{return}return t}},j=t=>A(t)?t.length===0||t.includes("create")||!t.some(n=>typeof n=="string"&&n):!t||t==="create",k=(t,n)=>{if(!t)return null;if(typeof t=="string")return{from:t,method:"select"};const r=l(t)?null:{...t};return!r||(r.method||(r.method="select"),l(r.params)&&(r.params=_(r.params,n)),r.method==="insert"||r.method==="update"||r.method==="upsert"||r.method==="delete")||!j(r.on)?null:r},S=(t,n="")=>{if(!t||typeof t!="object")return[];if(l(t))return[];const r=[],s=t.state||{};if(t.fetch){const e=A(t.fetch)?t.fetch:[t.fetch];for(const c of e){const o=k(c,s);o&&r.push({config:o,stateKey:o.as,path:n,elementState:s})}}for(const e in t)e==="fetch"||e==="state"||e==="props"||e==="attr"||e==="on"||e==="define"||e==="childExtends"||e==="childProps"||e==="childrenAs"||e.charAt(0)>="A"&&e.charAt(0)<="Z"&&y(t[e])&&r.push(...S(t[e],n?`${n}.${e}`:e));return r},M=["rest","local"],w=new WeakMap,b=async t=>{if(!t)return null;if(y(t)&&(l(t.select)||l(t.rpc)))return t;const n=typeof t=="string"?{adapter:t}:t;if(!y(n)||typeof n.adapter!="string")return null;if(w.has(n))return w.get(n);const r=(async()=>{let s;try{s=await import("@symbo.ls/fetch")}catch{return null}if(!(l(s.hasAdapter)?s.hasAdapter(n.adapter):M.includes(n.adapter)))return null;try{return await s.resolveDb(n)}catch(c){return console.warn(`[brender] SSR adapter "${n.adapter}" unavailable: ${c.message}`),null}})();return w.set(n,r),r},P=async(t,n)=>{try{const{method:r,from:s,params:e,transform:c,limit:o,offset:f,order:u,single:p,headers:h,baseUrl:g}=n;let i;if(r==="rpc"){if(!l(t.rpc))return null;i=await t.rpc({from:s,params:e,headers:h,baseUrl:g})}else{if(!l(t.select))return null;i=await t.select({from:s,select:n.select,params:e,limit:o,offset:f,order:u,single:p,headers:h,baseUrl:g})}let a=i?.data??null;if(i?.error)return null;if(a&&c&&l(c))try{a=c(a)}catch{}return a}catch{return null}},x=async(t,n="/",r={})=>{const e=(t.pages||{})[n];if(!e)return new Map;const c=t.config||t.settings||{},o=c.fetch||t.fetch||c.db||t.db;if(!o)return new Map;const f=await b(o);if(!f)return new Map;const u=S(e);if(!u.length)return new Map;const p=new Map,h=await Promise.allSettled(u.map(async({config:g,stateKey:i,path:a})=>{const d=await P(f,g);if(d!==null){const m=p.get(a)||{};i?m[i]=d:y(d)&&Object.assign(m,d),p.set(a,m)}}));return p},D=async t=>{const n=t.config||{},r=n.polyglot||t.polyglot;if(!r?.fetch||typeof r.fetch=="function")return null;const s=n.fetch||t.fetch||n.db||t.db;if(!s)return null;const e=await b(s);if(!e)return null;const c=r.fetch,o=c.rpc||c.from||"get_translations_if_changed",f=await import("@symbo.ls/utils"),u=f.polyglotLanguages(r,!1),p=u.length?u:[f.polyglotFallbackLang(void 0,r)],h={},g=await Promise.allSettled(p.map(async i=>{try{if(!l(e.rpc))return;const a=await e.rpc({from:o,params:{p_lang:i,p_cached_version:0}});if(a.error||!a.data)return;const d=a.data;d.translations&&(h[i]=d.translations)}catch(a){console.warn("[brender] SSR translation fetch failed:",a.message)}}));return Object.keys(h).length?h:null},E=(t,n)=>{if(!(!n||!n.size))for(const[r,s]of n){let e=t;if(r){const c=r.split(".");for(const o of c){if(!e||typeof e!="object")break;e=e[o]}}e&&typeof e=="object"&&((!e.state||typeof e.state!="object")&&(e.state={}),Object.assign(e.state,s))}};export{b as createSSRAdapter,D as fetchSSRTranslations,E as injectPrefetchedState,x as prefetchPageData};
1
+ const l=t=>typeof t=="function",A=t=>Array.isArray(t),y=t=>t!==null&&typeof t=="object"&&!Array.isArray(t),_=(t,n)=>{if(t){if(l(t))try{return t({state:n||{},call:()=>{},__ref:{}},n||{})}catch{return}return t}},j=t=>A(t)?t.length===0||t.includes("create")||!t.some(n=>typeof n=="string"&&n):!t||t==="create",k=(t,n)=>{if(!t)return null;if(typeof t=="string")return{from:t,method:"select"};const r=l(t)?null:{...t};return!r||(r.method||(r.method="select"),l(r.params)&&(r.params=_(r.params,n)),r.method==="insert"||r.method==="update"||r.method==="upsert"||r.method==="delete")||!j(r.on)?null:r},S=(t,n="")=>{if(!t||typeof t!="object")return[];if(l(t))return[];const r=[],s=t.state||{};if(t.fetch){const e=A(t.fetch)?t.fetch:[t.fetch];for(const c of e){const o=k(c,s);o&&r.push({config:o,stateKey:o.as,path:n,elementState:s})}}for(const e in t)e==="fetch"||e==="state"||e==="props"||e==="attr"||e==="on"||e==="define"||e==="childExtends"||e==="childProps"||e==="childrenAs"||e.charAt(0)>="A"&&e.charAt(0)<="Z"&&y(t[e])&&r.push(...S(t[e],n?`${n}.${e}`:e));return r},M=["rest","local"],w=new WeakMap,b=async t=>{if(!t)return null;if(y(t)&&(l(t.select)||l(t.rpc)))return t;const n=typeof t=="string"?{adapter:t}:t;if(!y(n)||typeof n.adapter!="string")return null;if(w.has(n))return w.get(n);const r=(async()=>{let s;try{s=await import("@symbo.ls/fetch")}catch{return null}if(!(l(s.hasAdapter)?s.hasAdapter(n.adapter):M.includes(n.adapter)))return null;try{return await s.resolveDb(n,{serverRender:!0})}catch(c){return console.warn(`[brender] SSR adapter "${n.adapter}" unavailable: ${c.message}`),null}})();return w.set(n,r),r},P=async(t,n)=>{try{const{method:r,from:s,params:e,transform:c,limit:o,offset:f,order:u,single:p,headers:h,baseUrl:g}=n;let i;if(r==="rpc"){if(!l(t.rpc))return null;i=await t.rpc({from:s,params:e,headers:h,baseUrl:g})}else{if(!l(t.select))return null;i=await t.select({from:s,select:n.select,params:e,limit:o,offset:f,order:u,single:p,headers:h,baseUrl:g})}let a=i?.data??null;if(i?.error)return null;if(a&&c&&l(c))try{a=c(a)}catch{}return a}catch{return null}},x=async(t,n="/",r={})=>{const e=(t.pages||{})[n];if(!e)return new Map;const c=t.config||t.settings||{},o=c.fetch||t.fetch||c.db||t.db;if(!o)return new Map;const f=await b(o);if(!f)return new Map;const u=S(e);if(!u.length)return new Map;const p=new Map,h=await Promise.allSettled(u.map(async({config:g,stateKey:i,path:a})=>{const d=await P(f,g);if(d!==null){const m=p.get(a)||{};i?m[i]=d:y(d)&&Object.assign(m,d),p.set(a,m)}}));return p},D=async t=>{const n=t.config||{},r=n.polyglot||t.polyglot;if(!r?.fetch||typeof r.fetch=="function")return null;const s=n.fetch||t.fetch||n.db||t.db;if(!s)return null;const e=await b(s);if(!e)return null;const c=r.fetch,o=c.rpc||c.from||"get_translations_if_changed",f=await import("@symbo.ls/utils"),u=f.polyglotLanguages(r,!1),p=u.length?u:[f.polyglotFallbackLang(void 0,r)],h={},g=await Promise.allSettled(p.map(async i=>{try{if(!l(e.rpc))return;const a=await e.rpc({from:o,params:{p_lang:i,p_cached_version:0}});if(a.error||!a.data)return;const d=a.data;d.translations&&(h[i]=d.translations)}catch(a){console.warn("[brender] SSR translation fetch failed:",a.message)}}));return Object.keys(h).length?h:null},R=(t,n)=>{if(!(!n||!n.size))for(const[r,s]of n){let e=t;if(r){const c=r.split(".");for(const o of c){if(!e||typeof e!="object")break;e=e[o]}}e&&typeof e=="object"&&((!e.state||typeof e.state!="object")&&(e.state={}),Object.assign(e.state,s))}};export{b as createSSRAdapter,D as fetchSSRTranslations,R as injectPrefetchedState,x as prefetchPageData};
@@ -1,22 +1,22 @@
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(`
1
+ import{resolve as h,join as at,dirname as j}from"path";import{existsSync as S,unlinkSync as lt,readFileSync as Q,realpathSync as ft}from"fs";import{resolvePackageEntry as pt}from"./packageEntry.js";import{tmpdir as ut}from"os";import{randomBytes as mt}from"crypto";import{createRequire as Re}from"module";import{pathToFileURL as dt}from"url";import{createEnv as Ae}from"./env.js";import{resetKeys as $e,assignKeys as De,mapKeysToElements as Oe}from"./keys.js";import{extractMetadata as we,generateHeadHtml as gt}from"./metadata.js";import"./hydrate.js";import{composeIntoShell as ht}from"./shell.js";import{trimSpriteToPage as yt,classRulesForPage as bt,markupClasses as St,trimVariablesToPage as Rt}from"./pageWeight.js";import{facesSheetTag as wt}from"./faces.js";import{fetchSSRTranslations as kt}from"./prefetch.js";import{createEarlySeedScript as xt}from"@symbo.ls/fetch";import{headerEntries as Tt}from"@symbo.ls/fetch/rest";import{brenderStampMeta as _t,brenderLazyMeta as Ce,escapeRegExp as Et,jsonForScript as jt,libraryPackageSpecs as vt,polyglotFallbackLang as ke,polyglotLangStorageKey as Lt,polyglotAddressLang as At,polyglotStartupScript as $t}from"@symbo.ls/utils";import{brenderRegistryBlock as Dt,brenderRegistryTreeBlock as Ot}from"@symbo.ls/utils/server";import*as Ct from"@symbo.ls/utils/server";import*as Mt from"@symbo.ls/utils";let pe=null;const qt=async()=>{if(pe)return pe;try{return pe=(await import("@symbo.ls/funcql")).funcqlPlugin,pe}catch{return null}};import"linkedom";import{createEarlySeedBlock as Pt,fetchRunsOf as It}from"@symbo.ls/fetch";import{reset as Ft}from"@symbo.ls/css";import*as ue from"@symbo.ls/css";const Bt=e=>typeof ue.tierOfStyle=="function"?ue.tierOfStyle(e):null,Gt=(e,t)=>typeof ue.sortByTier=="function"?ue.sortByTier(e,t):Array.from(e||[]),me=(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},de=(e,t)=>ke(e?.lang,t),Kt=e=>{const t=Ct.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},Me=e=>{const t=Mt.withPolyglotTranslations;return typeof t=="function"?t(e):e},qe=(e,t,o,n)=>{if(o?.translations){const r=o.translations[t];if(r){const a=me(r,e);if(a!==void 0)return a}}if(n?.translations){const r=n.translations[t];if(r){const a=me(r,e);if(a!==void 0)return a}}const s=ke(void 0,o);if(s!==t&&o?.translations){const r=o.translations[s];if(r){const a=me(r,e);if(a!==void 0)return a}}},Nt=function(e,t){if(!e)return"";const o=this?.context,n=o?.polyglot,s=this?.state?.root||o?.state?.root,r=qe(e,t||de(s,n),n,s);if(r!==void 0)return r;const a=Ee(_e);return n&&a&&a.labelKeys.add(e),e},Pe=function(){return de(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 C=null;try{import.meta.url&&(C=Re(import.meta.url))}catch{}const Ht=()=>{if(!import.meta.url||!C)return{isMonorepo:!1,monorepoRoot:null,resolvePackage:u=>u};const e=ft(new URL(".",import.meta.url).pathname),t=h(e,"../..");if(S(h(t,"packages","smbls","src","createDomql.js")))return{isMonorepo:!0,monorepoRoot:t};let n;try{const u=C.resolve("smbls/package.json");n=j(u)}catch{let u=e;for(;u!==j(u);){const g=h(u,"node_modules","smbls");if(S(h(g,"package.json"))){n=g;break}u=j(u)}}let s=C;if(n)try{s=Re(h(n,"package.json"))}catch{}let r,a=process.cwd();for(;a!==j(a);){if(S(h(a,"package.json"))){r=a;break}a=j(a)}let l=s;if(r)try{l=Re(h(r,"package.json"))}catch{}return{isMonorepo:!1,smblsRoot:n,brenderDir:e,projectRoot:r,_smblsRequire:s,_projectRequire:l}},H=(e,t)=>{const o=e.isMonorepo?[C]:[e._smblsRequire,e._projectRequire,C].filter(Boolean);for(const n of o)try{return n.resolve(t)}catch{}return null},mn=(e,t,...o)=>{if(e.isMonorepo)return h(e.monorepoRoot,"packages",t,...o);const n=H(e,`${t}/package.json`);return n?h(j(n),...o):null},dn=(e,t,...o)=>{if(e.isMonorepo)return h(e.monorepoRoot,"plugins",t,...o);const n=H(e,`@symbo.ls/${t}/package.json`);return n?h(j(n),...o):null},xe=(e,t,...o)=>{if(e.isMonorepo){for(const s of["packages","plugins"]){const r=h(e.monorepoRoot,s,t,...o);if(S(r))return r}return null}const n=H(e,`@symbo.ls/${t}/package.json`);return n?h(j(n),...o):null},Ie=(e,t,...o)=>{if(e.isMonorepo)return h(e.monorepoRoot,"packages","domql","packages",t,...o);const n=H(e,`@symbo.ls/${t}/package.json`);return n?h(j(n),...o):null};let ge=null;const Fe="smbls/ssr",zt=async()=>{const e=await import("smbls/ssr");if(typeof e?.createDomqlElement!="function")throw new Error("smbls/ssr does not export createDomqlElement");return e},Be=()=>(ge||(ge=Wt().catch(e=>{throw ge=null,e})),ge),Wt=async()=>{const e=Ht();let t;if(C&&e.isMonorepo)t=h(e.monorepoRoot,"packages","smbls","src","createDomql.js");else{let f;try{return await zt()}catch(c){f=c}if(!C)throw new Error(`brender: ${Fe} 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 i=e.smblsRoot&&h(e.smblsRoot,"src","createDomql.js");if(i&&S(i))t=i;else throw new Error(`brender: cannot load ${Fe} (${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=at(ut(),`br_createDomql_${mt(6).toString("hex")}.mjs`),s=pt,r=e.isMonorepo?await import(dt(h(e.monorepoRoot,"scripts","vite-workspace-source.mjs")).href):null,a=r?new Set(r.workspacePackageRoots().map(f=>r.workspacePackageAt(f).name)):null,l=/^(?:smbls(?:\/.*)?|domql|css-in-props(?:\/.*)?|@symbo\.ls\/[^/]+)$/,u={name:"workspace-resolve",setup(f){r&&(f.onResolve({filter:/^[^./]/},i=>{if(l.test(i.path))return;const c=i.path.split("/"),m=i.path.startsWith("@")?c.slice(0,2).join("/"):c[0];if(!a.has(m))return;const y=r.resolveWorkspaceSource(i.path,i.importer||t);return y?{path:y}:{errors:[{text:`"${i.path}" names no source file in the workspace`}]}}),f.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)),f.onResolve({filter:/^smbls/},i=>{const c=i.path.replace(/^smbls\/?/,""),m=e.isMonorepo?h(e.monorepoRoot,"packages","smbls"):e.smblsRoot;if(!m)return;if(!c){const T=s(m);return T?{path:T}:void 0}const y=h(m,c);if(S(y))return{path:y};if(S(y+".js"))return{path:y+".js"};const R=h(y,"index.js");if(S(R))return{path:R}}),f.onResolve({filter:/^domql$/},i=>{if(e.isMonorepo){const c=h(e.monorepoRoot,"packages","domql","src","index.js");if(S(c))return{path:c};const m=h(e.monorepoRoot,"packages","domql","index.js");if(S(m))return{path:m}}else try{const c=_require.resolve("domql/package.json"),m=s(j(c));if(m)return{path:m}}catch{}}),f.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 y of["packages","plugins"]){const R=h(e.monorepoRoot,y,c,"src","index.js");if(S(R))return{path:R};const T=h(e.monorepoRoot,y,c,"index.js");if(S(T))return{path:T}}const m=h(e.monorepoRoot,"packages","default-config","blank","index.js");if(c==="default-config"&&S(m))return{path:m}}else{const m=xe(e,c,"src","index.js");if(m&&S(m))return{path:m};const y=xe(e,c,"index.js");if(y&&S(y))return{path:y};if(c==="default-config"){const R=xe(e,"default-config","blank","index.js");if(R&&S(R))return{path:R}}}}),f.onResolve({filter:/^@domql\//},i=>{const c=i.path.replace("@symbo.ls/","");if(e.isMonorepo){const m=h(e.monorepoRoot,"packages","domql","packages",c,"src","index.js");if(S(m))return{path:m};const y=h(e.monorepoRoot,"packages","domql","packages",c,"index.js");if(S(y))return{path:y}}else{const m=Ie(e,c,"src","index.js");if(m&&S(m))return{path:m};const y=Ie(e,c,"index.js");if(y&&S(y))return{path:y}}}),f.onResolve({filter:/^css-in-props/},i=>{let c;if(e.isMonorepo)c=h(e.monorepoRoot,"packages","css-in-props");else{const R=H(e,"css-in-props/package.json");R&&(c=j(R))}if(!c)return;const m=i.path.replace(/^css-in-props\/?/,"");if(m){const R=h(c,m),T=h(R,"index.js");if(S(T))return{path:T};if(S(R+".js"))return{path:R+".js"};if(S(R))return{path:R}}const y=s(c);if(y)return{path:y}}),f.onResolve({filter:/^@emotion\//},i=>{let c;if(e.isMonorepo)c=h(e.monorepoRoot,"node_modules",i.path);else{const m=H(e,`${i.path}/package.json`);if(!m)return;c=j(m)}if(S(c)){const m=h(c,"package.json");if(S(m))try{const y=JSON.parse(Q(m,"utf8")),R=y.module||y.main||"dist/emotion-css.esm.js";return{path:h(c,R)}}catch{}return{path:c}}}),f.onResolve({filter:/\.json$/},i=>{if(i.resolveDir){const c=h(i.resolveDir,i.path);if(S(c))return{path:c}}}),f.onLoad({filter:/smbls\/.*options\.js$/},async i=>{if(!i.path.includes("smbls/")||!i.path.endsWith("options.js"))return;let c=Q(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"}}),f.onLoad({filter:/smbls\/.*init\.js$/},async i=>{if(!i.path.includes("smbls/")||!i.path.endsWith("init.js"))return;let c=Q(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"}}),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 i=>{let c=Q(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"}}),f.onLoad({filter:/fetchOnCreate\.js$/},async i=>{if(!i.path.includes("smbls/"))return;let c=Q(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:[u],nodePaths:e.isMonorepo?[h(e.monorepoRoot,"node_modules")]:[...e.smblsRoot?[h(e.smblsRoot,"node_modules")]:[],...e.projectRoot?[h(e.projectRoot,"node_modules")]:[],...e.smblsRoot?[h(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{lt(n)}catch{}return g},Ut={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"}},Vt=(e,t)=>{const o={};return Ge(e,(n,s)=>{if(!s.__brKey)return;const r=t(n);o[r===""?"__root":r]=s.__brKey}),o},Ge=(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)},Jt=new Set(["app","config","pages","components","state","snippets","designSystem","dependencies","functions","methods","files","sharedLibraries"]);let z=0;const Ke=Symbol.for("brender.fetchTracked"),Te=()=>z,Yt=256*1024,Xt=1024*1024,Qt=new Set(["accept-language","accept"]),Ne={renders:0,record:null},Zt=50,_e={renders:0,record:null},He=(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)}}},Ee=e=>e.record&&!e.record.tainted?e.record:null,eo=e=>{try{const t=new URL(e);return t.origin+t.pathname}catch{return String(e).split("?")[0]}},je=(e,t,o)=>{!e||e.tainted||e.failures.length>=Zt||e.failures.push({url:eo(t),reason:o})},ze=e=>e&&typeof e=="object"&&typeof e.url=="string"?e.url:String(e),to=e=>{const[t,o]=e,n=t&&typeof t=="object"&&typeof t.url=="string",s=ze(t),r=String(o&&o.method||n&&t.method||"GET").toUpperCase(),a={},l=u=>{if(!u)return;const g=!Array.isArray(u)&&typeof u.entries!="function";for(const[f,i]of Tt(u))g&&i==null||(a[String(f).toLowerCase()]=String(i))};return n&&l(t.headers),o&&l(o.headers),{url:s,method:r,headers:a}},oo=(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(a=>{e.tainted||a.length>Yt||e.bytes+a.length>Xt||(e.bytes+=a.length,e.entries.push({url:t.url,lang:t.headers["accept-language"]||"",status:o.status,type:s,body:a}))},()=>{}))},no=()=>{const e=globalThis.fetch;if(typeof e!="function"||e[Ke])return;const t=function(...o){z++;let n=!1;const s=()=>{n||(n=!0,z--)},r=i=>{z++,i.then(()=>{z--},()=>{z--})},a=Ee(Ne),l=Ee(_e);let u=null;if(a)try{u=to(o),(u.method!=="GET"||!/^https?:/i.test(u.url)||Object.keys(u.headers).some(i=>!Qt.has(i)))&&(u=null)}catch{u=null}const g=()=>ze(o[0]);let f;try{f=e.apply(this,o)}catch(i){throw je(l,g(),i&&i.message||"failed"),s(),i}return f&&typeof f.then=="function"?f.then(i=>{u&&oo(a,u,i,r),l&&i&&i.ok===!1&&je(l,g(),"HTTP "+i.status),s()},i=>{je(l,g(),i&&i.message||"network error"),s()}):s(),f};t[Ke]=!0,globalThis.fetch=t},gn=({brRegistry:e,fetchSeed:t,hydrateFlag:o=!0}={})=>{if(!e||!Object.keys(e).length)return"";const n=jt(e);return o?`<script>window.__BR_REGISTRY__=${n};window.__BRENDER_HYDRATE__=true<\/script>`+(t&&t.length?`
2
+ `+xt(t):""):`<script>window.__BR_REGISTRY__=${n}<\/script>`},so=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=vt(e())}catch{return}for(const[r]of s)!o.has(r)&&Object.prototype.hasOwnProperty.call(n,r)&&Reflect.deleteProperty(n,r)}},ro=3e4,co=2147483647;let We=Promise.resolve();const Ue=()=>{},io=e=>{const t=We.then(e);return We=t.then(Ue,Ue),t},ao=e=>{if(e===void 0)return ro;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,co)},Ve=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},lo=(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},fo=e=>{e.closed=!0;for(const t of e.undo.splice(0))t()},po=e=>{let t=!1;return()=>{t||(t=!0,e())}},Je=(e,t={})=>{let o;try{o=ao(t.timeout),Ve(t.search)}catch(n){return Promise.reject(n)}return io(()=>uo(Me(e),t,o))},uo=async(e,t,o)=>{await Be();const n={closed:!1,undo:[]},s=mo(e,t,n);if(!o)return s;let r;const a=new Promise((l,u)=>{r=setTimeout(()=>{fo(n),u(lo(t,o))},o)});try{return await Promise.race([s,a])}finally{clearTimeout(r)}},mo=async(e,t,o)=>{const{route:n="/",pathname:s,state:r,context:a,prefetch:l=!1,lazyGroups:u}=t,g=s||n,f=Ve(t.search);no();const i=He(_e,()=>({failures:[],labelKeys:new Set,tainted:!1}));try{return await go(Kt(e),{route:n,locationPath:g,locationSearch:f,stateOverrides:r,contextOverrides:a,prefetch:l,lazyGroups:u},i.record,o)}finally{i.close()}},go=async(e,{route:t,locationPath:o,locationSearch:n,stateOverrides:s,contextOverrides:r,prefetch:a,lazyGroups:l},u,g)=>{const f=()=>{if(g.closed)throw new Error("brender: this render was abandoned at its timeout")};let i;if(a){try{i=await kt(e)}catch(M){g.closed||console.warn("[brender] SSR translation fetch failed:",M.message)}f()}const{window:c,document:m}=Ae(),y=m.body;c.location.pathname=o,n&&(c.location.search=n,c.location.href=c.location.origin+o+n);let R=null;const T=[he("document",m),he("location",c.location),he("localStorage",c.localStorage),he("sessionStorage",c.sessionStorage),so(()=>R&&R.sharedLibraries)].map(po);g.undo.push(...T);try{const{createDomqlElement:M,PRERENDER_REGISTRY_FORMATS:Z}=await Be();f();const be=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 p of ko)e[p]!=null&&x[p]==null&&(x[p]=e[p]);const _=x.polyglot?{...x.polyglot,prefetch:!1}:void 0,U=At(o,_);U&&c.localStorage.setItem(Lt(_),U),i&&_&&(_.translations={..._.translations||{},...i});const ee=L(e.state||{});Ft();const te={};for(const p in e){if(Jt.has(p))continue;const b=e[p];te[p]=b&&typeof b=="object"?L(b):b}const k={...te,state:ee,...s?{state:{...ee,...s}}:{},dependencies:L(e.dependencies||{}),components:L(e.components||{}),snippets:L(e.snippets||{}),pages:L(e.pages||{}),functions:{...e.functions||{},polyglot:Nt,getActiveLang:Pe,getLang:Pe},methods:e.methods||{},designSystem:L(e.designSystem||{}),files:e.files||{},sharedLibraries:e.sharedLibraries||[],...x,..._?{polyglot:_}:{},document:m,window:c,parent:{node:y},initOptions:{},domqlOptions:{sourcemap:!1},firstRender:!1,sync:!1,inspect:!1,notifications:!1,afterFirstView:null,isolateDesignSystem:!0,isolateFetchCache:!0,captureDesignSystem:!0,...ho(l),...r||{},ssr:!0};R=k;const q=await qt();f(),q&&(k.plugins=k.plugins||[],k.plugins.some(p=>p.name==="funcql")||k.plugins.push(q)),$e();const oe=He(Ne,()=>({entries:[],bytes:0,tainted:!1})),P=oe.record;let d;try{if(d=await M(be,k),f(),k.lazyFirstView){const D=(d&&d.context||k).__firstNavigation;if(D&&typeof D.then=="function"){try{await D}catch{}f()}}const p=Date.now(),b=a?2e3:50,w=D=>new Promise(fe=>setTimeout(fe,D));for(await w(Math.min(50,b));a&&!g.closed&&Te()>0&&Date.now()-p<b;)await w(10),Te()===0&&await w(Math.max(0,Math.min(50,b-(Date.now()-p))));if(f(),a&&await yo(d,_)){f();const D=Date.now();for(await w(Math.min(50,b));!g.closed&&Te()>0&&Date.now()-D<b;)await w(10);f()}}finally{oe.close()}const I=P&&!P.tainted&&!(x.fetch&&x.fetch.seed===!1)?P.entries.slice():[];De(y);const ne=Oe(d),{elementPath:se}=await import("@symbo.ls/element");f();const A=Vt(d,se),V=I.length?It(d&&d.context||k,se):{},re=d?.context?.routerOptions?.contentElementKey||"content",F=d&&d[re],J=F&&typeof F=="object"&&F.__ref?F:void 0,ce=we(e,t,d,d?.state,J),E=[],K=new Map,Y=m.head||m.querySelector("head");if(Y){let p=null;for(const b of Y.querySelectorAll("style")){if(p=Bt(b)||p,b.sheet&&b.sheet.cssRules)for(const w of b.sheet.cssRules)w.cssText&&(E.push(w),p&&!K.has(w.cssText)&&K.set(w.cssText,p));if(!E.length){const w=b.textContent||"";w&&(E.push({cssText:w}),p&&!K.has(w)&&K.set(w,p))}}}const ie=E.map(p=>p.cssText),{globalCSS:ae,classRules:X}=vo(E),Se=X.map(p=>K.get(p)||null);let v=Qe(y.innerHTML);const B=d?.state?.root,G=de(B,_),O=bo(i,B);O&&(v=Xe(v,Ye(O,G,_)));const N=u&&!u.tainted?{failedRequests:u.failures.slice(),rawLabelKeys:wo(u.labelKeys,v,G,_,B)}:null,$=(d&&d.context||k).__lazyFirstViews,le=$&&typeof $.forEach=="function"?[...$]:[];return{html:v,metadata:ce,registry:ne,brRegistry:A,element:d,emotionCSS:ie,lazyGroups:le,globalCSS:ae,classRules:X,classRuleTiers:Se,fetchSeed:I,fetchRuns:V,document:m,window:c,ssrTranslations:O||void 0,activeLang:G,diagnostics:N,preparedDesignSystem:k.preparedDesignSystem||null,registryFormats:Array.isArray(Z)?Z.slice():["paths"]}}finally{for(const M of T)M()}},ho=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{}},he=(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]})},yo=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=de(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},ve=/\{\{\s*([^|{}]+?)\s*\|\s*polyglot\s*\}\}/g,Le=e=>e&&typeof e.parse=="function"?e.parse():e,bo=(e,t)=>{const o=Le(t?.translations),n={};for(const s of[e,o])if(!(!s||typeof s!="object"))for(const r in s){const a=Le(s[r]);a&&typeof a=="object"&&(n[r]={...n[r]||{},...a})}return Object.keys(n).length?n:null},Ye=(e,t,o)=>e[t]||e[ke(void 0,o)]||Object.values(e)[0]||{},Xe=(e,t)=>e.replace(ve,(o,n)=>me(t,n.trim())??o),So=/<script\b[^>]*\btype\s*=\s*["']?application\/json["']?[^>]*>[\s\S]*?<\/script\s*>/gi,Ro=(e,t)=>new RegExp(`(?:^|[^\\w.-])${Et(t)}(?![\\w-]|\\.\\w)`).test(e),wo=(e,t,o,n,s)=>{const r=new Set,a=t.replace(So,"");for(const l of e)/\s/.test(l)||qe(l,o,n,s)===void 0&&Ro(a,l)&&r.add(l);for(const l of a.matchAll(ve))r.add(l[1].trim());return[...r]},hn=async(e,t={})=>{const{context:o={}}=t,{window:n,document:s}=Ae(),r=s.body,{create:a}=await import("@symbo.ls/element"),l=await import("@symbo.ls/utils"),u={...Ut,...o.components||{}},g={...l,...o.utils||{},...o.functions||{}};$e();let f;try{f=a(e,{node:r},"root",{context:{document:s,window:n,...o,components:u,utils:g,ssr:!0}})}catch{}De(r);const i=f?Oe(f):{};return{html:Qe(r.innerHTML),registry:i,element:f}},Qe=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}),ko=["globalTheme","themeStorageKey","themeRoot","useReset","useVariable","useFontImport","useIconSprite","useSvgSprite","useDocumentTheme","useDefaultConfig","useDefaultIcons","useThemeSuffixedVars","verbose","semanticIcons"],xo=new Set(["auto","system"]),Ze=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||xo.has(s)?null:s},To=e=>String(e).replace(/&/g,"&amp;").replace(/"/g,"&quot;").replace(/</g,"&lt;"),_o=/\.[A-Za-z_\\-]/,Eo=e=>{if(typeof e!="string"||!e)return!1;const t=e.replace(/"(?:[^"\\]|\\.)*"|'(?:[^'\\]|\\.)*'/g,'""').replace(/\[[^\]]*\]/g,"[]");return!_o.test(t)},jo=/^\s*(:root|\[data-theme|\[data-skin)/,et=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 Eo(e.selectorText)?jo.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(et));return n.has(null)||n.size!==1?n.has(null)?null:"reset":[...n][0]}return null},tt=e=>typeof e=="string"&&/^\s*@font-face\b/i.test(e),vo=e=>{const t={root:[],reset:[],keyframes:[]},o=[];for(const n of e||[]){const s=et(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 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">
5
+ `),fontFaceCSS:""},classRules:o}};let W=new Map;const ot=e=>Gt(e,t=>W.get(t)),yn=()=>{W=new Map},bn=()=>ot(W.keys()).join(`
6
+ `),Sn=(e,t)=>e.replace(/<style data-emotion="smbls">[\s\S]*?<\/style>/,t?`<style data-emotion="smbls">
7
7
  ${t}
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
- ${C.resetRules||""}
14
- ${C.keyframeRules||""}
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}>
8
+ </style>`:""),Rn=async(e,t={})=>{const{route:o="/",pathname:n,search:s,prefetch:r=!0,timeout:a}=t,l=await Je(e,{route:o,pathname:n,search:s,prefetch:r,timeout:a});if(!l)return null;const u=e.designSystem||{},g=l.globalCSS;let f=null;try{const c=Lo(l.element);Object.keys(c).length&&(f=c)}catch{}const i=l.activeLang;return{html:l.html,css:l.classRules.join(`
9
+ `),classRules:l.classRules.slice(),classRuleTiers:l.classRuleTiers.slice(),globalCSS:g,resetCss:g.resetRules,fontLinks:it(u),metadata:l.metadata||we(e,o),brKeyCount:l.registry?Object.keys(l.registry).length:0,brRegistry:l.brRegistry||{},fetchSeed:l.fetchSeed||[],fetchRuns:l.fetchRuns||{},ssrTranslations:l.ssrTranslations,prefetchedState:f,activeLang:i,theme:Ze(e),diagnostics:l.diagnostics,preparedDesignSystem:l.preparedDesignSystem||null}},Lo=e=>{const t={};return Ge(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 a=r.startsWith("~/"),l=a?r.slice(2):r,u=a?o.state.root:o.state,g=Le(u&&u[l]);l&&g!=null&&typeof g!="function"&&(t[l]=g)}}),t},wn=async(e,t="/",o={})=>{const n=Me(e),{lang:s,themeColor:r,isr:a,hydrate:l=!0,prefetch:u=!0,shell:g,adoptDom:f=!1,pathname:i,search:c,eagerImages:m=ct,preloadScripts:y=!0,nonce:R,timeout:T,stamp:M,time:Z,spriteIcons:be="all",cssClasses:x="all",cssVariables:_="all",registryFormat:U="paths",lazyGroups:ee,paint:te}=o,k=Ao(te),q=Io(R),oe=s||n.state?.lang||n.app?.metadata?.lang||"en",P=Ze(n),d=await Je(n,{route:t,pathname:i,search:c,prefetch:u,timeout:T,lazyGroups:ee});if(!d)return null;const I={...d.metadata};if(r&&(I["theme-color"]=r),typeof g=="string"&&!n.name){const p="\0brender-undeclared-title\0";if(we({...n,name:p},t,d.element,d.element?.state).title===p)for(const w of["title","og:title","twitter:title"])I[w]===d.metadata.title&&delete I[w]}const ne=gt(I),se=d.classRuleTiers||[];d.classRules.forEach((p,b)=>{p&&!W.has(p)&&W.set(p,se[b]||null)});let A=Mo(d.html,m);be==="page"&&(A=yt(A,typeof g=="string"?g:"").html);const V=Array.from(W.keys()),re=V.filter(tt),F=ot(re.length?V.filter(p=>!tt(p)):V),J=x==="page"?bt(F,St(A,typeof g=="string"?g:"")).join(`
10
+ `):F.join(`
11
+ `),ce=wt(re),E=d.globalCSS,Y=`<style data-brender>
12
+ ${(_==="page"?Rt(E.rootRule||"",E.resetRules,E.keyframeRules,J,A,typeof g=="string"?g:"").css:E.rootRule)||""}
13
+ ${E.resetRules||""}
14
+ ${E.keyframeRules||""}
15
+ </style>`,ie=J?`<style data-emotion="smbls">
16
+ ${J}
17
+ </style>`:"",ae=it(n.designSystem||{}),X=Object.keys(d.registry).length,Se=U==="tree"||U==="auto"&&(d.registryFormats||[]).includes("tree"),v=qo({brRegistry:d.brRegistry,fetchSeed:d.fetchSeed,fetchRuns:d.fetchRuns,adoptDom:f,stamp:M,time:Z,registryFormat:Se?"tree":"paths",lazyGroups:d.lazyGroups});let B="";if(a&&a.clientScript){const p=Number.isInteger(o.depth)?o.depth:t==="/"?0:t.replace(/^\/|\/$/g,"").split("/").length,b=p>0?"../".repeat(p):"./";if(l){const w=$t({polyglot:n.polyglot||n.config?.polyglot,translations:d.ssrTranslations,lang:d.activeLang,pathname:i||t,attrs:q}),D=w?w+`
18
+ `:"",fe=v.blocks?v.blocks+`
19
+ `:"";B=`${D}${fe}<script type="module" src="${b}${a.clientScript}"${q}><\/script>`}else B=`<script type="module"${q}>
20
20
  {
21
21
  const brEls = document.querySelectorAll('body > :not(script):not(style)')
22
22
  const observer = new MutationObserver((mutations) => {
@@ -33,29 +33,29 @@ ${V}
33
33
  observer.observe(document.body, { childList: true })
34
34
  }
35
35
  <\/script>
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)}"`:""}>
36
+ <script type="module" src="${b}${a.clientScript}"${q}><\/script>`}const G={...n.config||{}};n.polyglot&&!G.polyglot&&(G.polyglot=n.polyglot);const O=G.polyglot;let N=ne;if(O){const p={...O.translations||{}};for(const b in d.ssrTranslations||{})p[b]={...p[b]||{},...d.ssrTranslations[b]};N=Xe(ne,Ye(p,d.activeLang,O))}const $=d.diagnostics;if($)for(const p of N.matchAll(ve)){const b=p[1].trim();$.rawLabelKeys.includes(b)||$.rawLabelKeys.push(b)}if(typeof g=="string"){const p=ht(g,{headTags:`${N}
37
+ ${v.meta}`,headEnd:[ae,ce,Y,ie].filter(Boolean).join(`
38
+ `),body:k?A+`
39
+ `+st:A,depth:Number.isInteger(o.depth)?o.depth:0,bootScripts:v.blocks,lang:s||(O?d.activeLang:void 0),theme:P,preloadScripts:y});return{html:k?rt(p):p,route:t,brKeyCount:X,shell:!0,diagnostics:$,preparedDesignSystem:d.preparedDesignSystem||null,lazyGroups:d.lazyGroups||[]}}const le=`<!DOCTYPE html>
40
+ <html lang="${oe}"${P?` data-theme="${To(P)}"`:""}>
41
41
  <head>
42
- ${H}${r&&r.clientScript&&l?`
42
+ ${N}${a&&a.clientScript&&l?`
43
43
  ${v.meta}`:""}
44
- ${ne}
45
- ${F}
46
- ${O}
47
- ${J}
44
+ ${ae}
45
+ ${ce}
46
+ ${Y}
47
+ ${ie}
48
48
  </head>
49
49
  <body>
50
- ${A}${I?`
51
- ${Ze}`:""}
52
- ${G}
50
+ ${A}${k?`
51
+ ${st}`:""}
52
+ ${B}
53
53
  </body>
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};
54
+ </html>`;return{html:k?rt(le):le,route:t,brKeyCount:X,diagnostics:$,preparedDesignSystem:d.preparedDesignSystem||null,lazyGroups:d.lazyGroups||[]}},nt="smbls-whole",st=`<template id="${nt}"></template>`,ye=`<link rel="expect" href="#${nt}" blocking="render">`,Ao=e=>!!(e&&typeof e=="object"&&e.whole===!0),$o=/<meta\b[^>]*\bcharset\s*=[^>]*>/i,Do=[/<head\b[^>]*>/i,/<html\b[^>]*>/i,/^\s*<!doctype\b[^>]*>/i],rt=e=>{if(typeof e!="string"||e.includes(ye))return e;const t=$o.exec(e.slice(0,1024));if(t){const o=t.index+t[0].length;return e.slice(0,o)+`
55
+ `+ye+e.slice(o)}for(const o of Do){const n=o.exec(e);if(n)return e.slice(0,n.index+n[0].length)+`
56
+ `+ye+e.slice(n.index+n[0].length)}return ye+`
57
+ `+e},ct=2,Oo=/<img\b(?:[^>"']|"[^"]*"|'[^']*')*>/gi,Co=/\sloading\s*=/i,Mo=(e,t=ct)=>{if(t===!1||t==null||typeof e!="string")return e;const o=Math.max(0,Number(t)||0);let n=0;return e.replace(Oo,s=>n++<o||Co.test(s)?s:s.replace(/^<img\b/i,'<img loading="lazy"'))},it=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
+ `):""},qo=({brRegistry:e,fetchSeed:t,fetchRuns:o,adoptDom:n=!1,stamp:s,time:r,registryFormat:a="paths",lazyGroups:l}={})=>{const g=n&&e&&Object.keys(e).length?a==="tree"&&Ot(e)||Dt(e):"",f=Pt(t,o);return{meta:`<meta name="brender" content="${g?"hydrate":"replace"}">
59
+ `+_t(Po(s,r))+(Ce(l)?`
60
+ `+Ce(l):""),blocks:[g,f].filter(Boolean).join(`
61
+ `)}},Po=(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}},Io=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{ct as EAGER_IMAGES_DEFAULT,Fe as SMBLS_SSR_SPECIFIER,nt as WHOLE_MARKER_ID,gn as adoptionScripts,Po as buildStamp,Ze as fixedThemeOf,bn as getAccumulatedEmotionCSS,Mo as markLazyImages,Ao as paintsWhole,qo as prerenderParts,Je as render,hn as renderElement,wn as renderPage,Rn as renderRoute,Sn as replaceEmotionCSS,yn as resetGlobalCSSCache,Gt as sortByTier,vo as splitCapturedCSS,rt as withWholePaint};
package/index.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import { createEnv } from './env.js'
2
2
  import { resetKeys, assignKeys, mapKeysToElements } from './keys.js'
3
3
  import { loadProject, loadAndRenderAll } from './load.js'
4
- import { render, renderElement, renderRoute, renderPage, resetGlobalCSSCache, getAccumulatedEmotionCSS, replaceEmotionCSS, adoptionScripts, prerenderParts, buildStamp } from './render.js'
4
+ import { render, renderElement, renderRoute, renderPage, resetGlobalCSSCache, getAccumulatedEmotionCSS, replaceEmotionCSS, adoptionScripts, prerenderParts, buildStamp, sortByTier } from './render.js'
5
5
  import { extractMetadata, generateHeadHtml } from './metadata.js'
6
6
  import { collectBrNodes, hydrate } from './hydrate.js'
7
7
  import { generateSitemap } from './sitemap.js'
@@ -50,6 +50,9 @@ export {
50
50
  markupClasses,
51
51
  trimVariablesToPage,
52
52
  stylesheetRules,
53
+ // The atomic engine's cascade-tier order (XMA #1283), for a caller that
54
+ // unions the class rules of several renders (renderRoute's classRuleTiers)
55
+ sortByTier,
53
56
  markFacesSheet,
54
57
  facesSheetMarks,
55
58
  drawnFaces
@@ -85,6 +88,9 @@ export default {
85
88
  markupClasses,
86
89
  trimVariablesToPage,
87
90
  stylesheetRules,
91
+ // The atomic engine's cascade-tier order (XMA #1283), for a caller that
92
+ // unions the class rules of several renders (renderRoute's classRuleTiers)
93
+ sortByTier,
88
94
  markFacesSheet,
89
95
  facesSheetMarks,
90
96
  drawnFaces
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@symbo.ls/brender",
3
- "version": "3.14.680",
3
+ "version": "3.14.682",
4
4
  "license": "CC-BY-NC-4.0",
5
5
  "type": "module",
6
6
  "module": "./dist/esm/index.js",
@@ -56,18 +56,18 @@
56
56
  "prepublishOnly": "npm run build"
57
57
  },
58
58
  "dependencies": {
59
- "@symbo.ls/css": "^3.14.782",
59
+ "@symbo.ls/css": "^3.14.783",
60
60
  "@symbo.ls/default-config": "^3.14.794",
61
- "@symbo.ls/element": "^3.14.823",
62
- "@symbo.ls/fetch": "^3.14.678",
61
+ "@symbo.ls/element": "^3.14.829",
62
+ "@symbo.ls/fetch": "^3.14.679",
63
63
  "@symbo.ls/helmet": "^3.14.674",
64
64
  "@symbo.ls/scratch": "^3.14.799",
65
- "@symbo.ls/utils": "^3.14.859",
65
+ "@symbo.ls/utils": "^3.14.860",
66
66
  "esbuild": "^0.28.1",
67
67
  "linkedom": "^0.16.8"
68
68
  },
69
69
  "peerDependencies": {
70
- "smbls": "^3.14.869"
70
+ "smbls": "^3.14.877"
71
71
  },
72
72
  "optionalDependencies": {
73
73
  "@symbo.ls/funcql": "^3.14.0"
package/prefetch.js CHANGED
@@ -124,12 +124,15 @@ const collectFetchDeclarations = (def, path = '') => {
124
124
  * sub-problem 2): the Supabase SSR path had been removed, nothing replaced it,
125
125
  * so server renders never had data or fetched translations.
126
126
  *
127
- * Not every adapter can run on the server: the platform's 'sdk' adapter is
128
- * registered by the page runtime, which a server render does not have. For a
127
+ * Not every adapter can run on the server: a host's 'sdk' adapter is
128
+ * registered by the host page, which a server render does not have. For a
129
129
  * name @symbo.ls/fetch cannot resolve right now (`hasAdapter`), this returns
130
130
  * null at once — the page renders without prefetched data and the client's
131
131
  * fetch loads it — instead of letting resolveDb wait for a registration that
132
- * never comes.
132
+ * never comes. A built-in that must not run here (`symbols`, the platform
133
+ * SDK of a published site) is told so — resolveDb's `{ serverRender: true }`
134
+ * — and answers null at once: the server never loads the SDK and never calls
135
+ * the API.
133
136
  */
134
137
  const BUILTIN_ADAPTER_NAMES = ['rest', 'local'] // @symbo.ls/fetch without hasAdapter()
135
138
  const _adapterCache = new WeakMap()
@@ -153,7 +156,7 @@ const createSSRAdapter = async (dbConfig) => {
153
156
  : BUILTIN_ADAPTER_NAMES.includes(config.adapter)
154
157
  if (!known) return null
155
158
  try {
156
- return await fetchPkg.resolveDb(config)
159
+ return await fetchPkg.resolveDb(config, { serverRender: true })
157
160
  } catch (e) {
158
161
  console.warn(`[brender] SSR adapter "${config.adapter}" unavailable: ${e.message}`)
159
162
  return null
package/render.js CHANGED
@@ -21,6 +21,8 @@ import { brenderRegistryBlock, brenderRegistryTreeBlock } from '@symbo.ls/utils/
21
21
  // than this package's utils floor (a named import of a missing export fails
22
22
  // the module at link time).
23
23
  import * as utilsServer from '@symbo.ls/utils/server'
24
+ // The same, for withPolyglotTranslations (withTranslations below).
25
+ import * as utilsIndex from '@symbo.ls/utils'
24
26
 
25
27
  // funcql plugin — enables evaluation of funcql schemas as property values
26
28
  // during SSR. Async-imported to avoid polluting non-funcql codepaths.
@@ -38,6 +40,25 @@ const getFuncqlPlugin = async () => {
38
40
  import { parseHTML } from 'linkedom'
39
41
  import { createEarlySeedBlock, fetchRunsOf } from '@symbo.ls/fetch'
40
42
  import { css, injectGlobal, reset as resetCss } from '@symbo.ls/css'
43
+ // The atomic engine's cascade tiers (@symbo.ls/css atomic.js "The tiers for a
44
+ // reader of the sheets", XMA #1283), through the namespace, read at call time:
45
+ // tierOfStyle / sortByTier are newer than this package's css floor (a named
46
+ // import of a missing export fails the module at link time). Without them the
47
+ // rules keep the order they were captured in, as before.
48
+ import * as atomicCss from '@symbo.ls/css'
49
+
50
+ const tierOfStyle = (style) => (typeof atomicCss.tierOfStyle === 'function' ? atomicCss.tierOfStyle(style) : null)
51
+
52
+ /**
53
+ * Items in the atomic engine's cascade-tier order (@symbo.ls/css sortByTier):
54
+ * by the tier `tierOf(item)` names, the order they came in inside a tier. For
55
+ * a caller that merges the class rules of several renders (renderPage below,
56
+ * @symbo.ls/cli's publish-time pre-render with renderRoute's `classRuleTiers`).
57
+ * @param {Iterable<*>} items
58
+ * @param {(item: *) => (string|null|undefined)} tierOf
59
+ * @returns {Array<*>}
60
+ */
61
+ export const sortByTier = (items, tierOf) => (typeof atomicCss.sortByTier === 'function' ? atomicCss.sortByTier(items, tierOf) : Array.from(items || []))
41
62
 
42
63
  // Lightweight SSR polyglot functions — resolve translations from context
43
64
  // without needing the full polyglot plugin runtime
@@ -82,6 +103,20 @@ const withRevivedDefaultLang = (data) => {
82
103
  return out
83
104
  }
84
105
 
106
+ // The payload as frank writes an app whose polyglot reads its design
107
+ // system's lang map: `polyglot.translationsFrom: 'designSystem.lang'` and no
108
+ // `translations` — the map once (FW-FRANK-LANG-MAP-ONCE, @symbo.ls/utils
109
+ // polyglotLang.js). A render reads a VIEW whose polyglot holds that map as
110
+ // its `translations` — for the languages (the address's language), the
111
+ // labels, the fetched labels merged over them, the head — and never writes
112
+ // the caller's payload: mermaid also serves it, and a resolved payload would
113
+ // carry the map twice again. Older utils (below this package's floor): the
114
+ // payload as it is.
115
+ const withTranslations = (data) => {
116
+ const view = utilsIndex.withPolyglotTranslations
117
+ return typeof view === 'function' ? view(data) : data
118
+ }
119
+
85
120
  // One label lookup, the order the client's translate() reads: static
86
121
  // translations, then the labels loaded into the root state, then the
87
122
  // default language's static ones. `undefined` when no table has the key.
@@ -1135,7 +1170,7 @@ export const render = (data, options = {}) => {
1135
1170
  } catch (err) {
1136
1171
  return Promise.reject(err)
1137
1172
  }
1138
- return inRenderQueue(() => renderInTurn(data, options, timeout))
1173
+ return inRenderQueue(() => renderInTurn(withTranslations(data), options, timeout))
1139
1174
  }
1140
1175
 
1141
1176
  const renderInTurn = async (data, options, timeout) => {
@@ -1501,24 +1536,41 @@ const renderWithDiagnostics = async (data, { route, locationPath, locationSearch
1501
1536
 
1502
1537
  // Extract CSS from style tags in virtual head (atomic CSS engine writes here)
1503
1538
  const capturedRules = []
1539
+ // The cascade tier each captured rule was filed in (XMA #1283), by its
1540
+ // text: the tier of the engine sheet it was read from (tierOfStyle). A
1541
+ // <style> the engine did not make (the element's data-smbls-scoped sheet, a
1542
+ // helmet style) takes the tier of the engine sheet before it, whose rules
1543
+ // its own follow in the head. The head holds the tier sheets in cascade
1544
+ // order, so this capture is in the app's order and its tiers never go down;
1545
+ // renderPage merges the rules of a build's pages and writes them by tier.
1546
+ const capturedTiers = new Map()
1504
1547
  const head = document.head || document.querySelector('head')
1505
1548
  if (head) {
1549
+ let tier = null
1506
1550
  for (const style of head.querySelectorAll('style')) {
1551
+ tier = tierOfStyle(style) || tier
1507
1552
  if (style.sheet && style.sheet.cssRules) {
1508
1553
  for (const rule of style.sheet.cssRules) {
1509
- if (rule.cssText) capturedRules.push(rule)
1554
+ if (!rule.cssText) continue
1555
+ capturedRules.push(rule)
1556
+ if (tier && !capturedTiers.has(rule.cssText)) capturedTiers.set(rule.cssText, tier)
1510
1557
  }
1511
1558
  }
1512
1559
  if (!capturedRules.length) {
1513
1560
  const content = style.textContent || ''
1514
- if (content) capturedRules.push({ cssText: content })
1561
+ if (content) {
1562
+ capturedRules.push({ cssText: content })
1563
+ if (tier && !capturedTiers.has(content)) capturedTiers.set(content, tier)
1564
+ }
1515
1565
  }
1516
1566
  }
1517
1567
  }
1518
1568
  const emotionCSS = capturedRules.map((rule) => rule.cssText)
1519
1569
  // globalCSS: the init-injected globals; classRules: everything else, in
1520
- // capture order (see splitCapturedCSS).
1570
+ // capture order (see splitCapturedCSS); classRuleTiers: the tier of each
1571
+ // class rule, beside it (null where no engine sheet came before it).
1521
1572
  const { globalCSS, classRules } = splitCapturedCSS(capturedRules)
1573
+ const classRuleTiers = classRules.map((rule) => capturedTiers.get(rule) || null)
1522
1574
 
1523
1575
  let html = fixSvgContent(body.innerHTML)
1524
1576
 
@@ -1549,7 +1601,7 @@ const renderWithDiagnostics = async (data, { route, locationPath, locationSearch
1549
1601
  const firstViews = ((element && element.context) || ctx).__lazyFirstViews
1550
1602
  const lazyGroupsShown = firstViews && typeof firstViews.forEach === 'function' ? [...firstViews] : []
1551
1603
 
1552
- return { html, metadata, registry, brRegistry, element, emotionCSS, lazyGroups: lazyGroupsShown, globalCSS, classRules, fetchSeed, fetchRuns, document, window, ssrTranslations: labels || undefined, activeLang, diagnostics, preparedDesignSystem: ctx.preparedDesignSystem || null,
1604
+ return { html, metadata, registry, brRegistry, element, emotionCSS, lazyGroups: lazyGroupsShown, globalCSS, classRules, classRuleTiers, fetchSeed, fetchRuns, document, window, ssrTranslations: labels || undefined, activeLang, diagnostics, preparedDesignSystem: ctx.preparedDesignSystem || null,
1553
1605
  // the registry encodings the client of this smbls reads (smbls
1554
1606
  // prerender.js PRERENDER_REGISTRY_FORMATS); an older smbls reads paths
1555
1607
  registryFormats: Array.isArray(PRERENDER_REGISTRY_FORMATS) ? PRERENDER_REGISTRY_FORMATS.slice() : ['paths'] }
@@ -1885,18 +1937,28 @@ export const splitCapturedCSS = (rules) => {
1885
1937
  // Emotion's singleton cache marks classes as "inserted" after the first render,
1886
1938
  // so subsequent renders only produce NEW classes not seen before.
1887
1939
  // We merge all CSS rules across renders to ensure every page has complete styles.
1888
- let _accumulatedEmotionCSS = new Set()
1940
+ // Rule text → the cascade tier its first render read it in (render's
1941
+ // classRuleTiers). The map keeps the order rules were first captured in — a
1942
+ // rule an earlier page minted stays ahead of every rule a later page mints, so
1943
+ // it is written by tier (inTierOrder), never in this order (XMA #1283: `/`
1944
+ // minted the ≤560 px rule, `/b` the ≤768 px one, and `/b` wrote 560 first).
1945
+ let _accumulatedEmotionCSS = new Map()
1946
+
1947
+ // The accumulated rules given, in the app's cascade-tier order: the tier
1948
+ // sheets' order in the app's <head>, the first-written order inside a tier.
1949
+ const inTierOrder = (rules) => sortByTier(rules, (rule) => _accumulatedEmotionCSS.get(rule))
1889
1950
 
1890
1951
  /**
1891
1952
  * Reset the cached global CSS and emotion CSS (useful when rendering multiple projects).
1892
1953
  */
1893
- export const resetGlobalCSSCache = () => { _accumulatedEmotionCSS = new Set() }
1954
+ export const resetGlobalCSSCache = () => { _accumulatedEmotionCSS = new Map() }
1894
1955
 
1895
1956
  /**
1896
- * Returns the complete accumulated emotion CSS from all renders so far.
1957
+ * Returns the complete accumulated emotion CSS from all renders so far, in
1958
+ * the app's cascade-tier order.
1897
1959
  * Call this after rendering ALL pages to get the full CSS needed by every page.
1898
1960
  */
1899
- export const getAccumulatedEmotionCSS = () => Array.from(_accumulatedEmotionCSS).join('\n')
1961
+ export const getAccumulatedEmotionCSS = () => inTierOrder(_accumulatedEmotionCSS.keys()).join('\n')
1900
1962
 
1901
1963
  /**
1902
1964
  * Replace the emotion CSS in a rendered HTML page with updated CSS.
@@ -1954,6 +2016,10 @@ export const renderRoute = async (data, options = {}) => {
1954
2016
  // the same rules as a list — a caller that unions several routes' CSS
1955
2017
  // (the publish-time ssrCache) dedupes by rule
1956
2018
  classRules: result.classRules.slice(),
2019
+ // the cascade tier of each of them (render's capture, XMA #1283): a
2020
+ // caller that unions several routes' rules writes the union in the app's
2021
+ // order with sortByTier — one route's own rules already are in it
2022
+ classRuleTiers: result.classRuleTiers.slice(),
1957
2023
  globalCSS,
1958
2024
  resetCss: globalCSS.resetRules,
1959
2025
  fontLinks: generateFontLinks(ds),
@@ -2011,7 +2077,7 @@ const collectFetchedState = (element) => {
2011
2077
  *
2012
2078
  * Includes head, metadata, fonts, reset CSS, component CSS, and body.
2013
2079
  *
2014
- * @param {object} data - Full project data (from loadProject)
2080
+ * @param {object} payload - Full project data (from loadProject); not written to
2015
2081
  * @param {string} route - Route to render (e.g. '/', '/about')
2016
2082
  * @param {object} [options]
2017
2083
  * @param {string} [options.lang='en'] - HTML lang attribute
@@ -2066,7 +2132,9 @@ const collectFetchedState = (element) => {
2066
2132
  * paint waits until the page's markup is in (see withWholePaint)
2067
2133
  * @returns {Promise<{ html: string, route: string, brKeyCount: number, shell?: true }>}
2068
2134
  */
2069
- export const renderPage = async (data, route = '/', options = {}) => {
2135
+ export const renderPage = async (payload, route = '/', options = {}) => {
2136
+ // the strings of a polyglot that names them by pointer (withTranslations)
2137
+ const data = withTranslations(payload)
2070
2138
  const { lang, themeColor, isr, hydrate = true, prefetch = true, shell, adoptDom = false, pathname, search, eagerImages = EAGER_IMAGES_DEFAULT, preloadScripts = true, nonce, timeout, stamp, time, spriteIcons = 'all', cssClasses = 'all', cssVariables = 'all', registryFormat = 'paths', lazyGroups, paint } = options
2071
2139
  const whole = paintsWhole(paint)
2072
2140
  const nonceAttr = nonceAttribute(nonce)
@@ -2110,9 +2178,11 @@ export const renderPage = async (data, route = '/', options = {}) => {
2110
2178
  // collect all rules across renders to build the complete stylesheet.
2111
2179
  // Only the classes accumulate: the globals are this page's own (one :root,
2112
2180
  // one copy of each @keyframes — they used to pile up across pages).
2113
- for (const rule of result.classRules) {
2114
- if (rule) _accumulatedEmotionCSS.add(rule)
2115
- }
2181
+ // Each with the tier its render read it in.
2182
+ const tiers = result.classRuleTiers || []
2183
+ result.classRules.forEach((rule, i) => {
2184
+ if (rule && !_accumulatedEmotionCSS.has(rule)) _accumulatedEmotionCSS.set(rule, tiers[i] || null)
2185
+ })
2116
2186
 
2117
2187
  // Images past the first `eagerImages` load lazily unless they say how to
2118
2188
  // load (see markLazyImages).
@@ -2137,9 +2207,16 @@ export const renderPage = async (data, route = '/', options = {}) => {
2137
2207
  // sheet the takeover never touches keeps them loaded; smbls applyFontFaces
2138
2208
  // finds them declared and adds none of its own (smbls prerender.js
2139
2209
  // serverStyles does not select it, so it stays for the page's life).
2140
- const accumulated = Array.from(_accumulatedEmotionCSS)
2210
+ //
2211
+ // The class rules go in the app's cascade-tier order (XMA #1283): in the
2212
+ // order they were first captured, the ≤560 px rule `/` minted stayed ahead
2213
+ // of the ≤768 px rule `/b` minted after it, and `/b` showed 2 columns at
2214
+ // 390 px where the app shows 1 (and a longhand class an earlier page minted
2215
+ // lost to its shorthand). One page's own rules are already in this order;
2216
+ // a stable sort leaves them so. The faces keep their first-captured order.
2217
+ const accumulated = Array.from(_accumulatedEmotionCSS.keys())
2141
2218
  const faceRules = accumulated.filter(isFontFaceText)
2142
- const classRules = faceRules.length ? accumulated.filter((rule) => !isFontFaceText(rule)) : accumulated
2219
+ const classRules = inTierOrder(faceRules.length ? accumulated.filter((rule) => !isFontFaceText(rule)) : accumulated)
2143
2220
  const emotionCSS = cssClasses === 'page'
2144
2221
  ? classRulesForPage(classRules, markupClasses(bodyHtml, typeof shell === 'string' ? shell : '')).join('\n')
2145
2222
  : classRules.join('\n')