@symbo.ls/brender 3.14.674 → 3.14.675

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,18 @@
1
1
  # @symbo.ls/brender
2
2
 
3
+ ## 3.14.675
4
+
5
+ ### Patch Changes
6
+
7
+ - 7b3795b: A part of a pre-built page whose query runs after its create (on a state change, once its `enabled` turns true) is taken over as the page shows it. The render records which of its queries each element ran (`fetchRunsOf`), the page carries that record in its seed block, and the element takes those queries' recorded answers at its init — no loading look between the takeover and its data, no request. An element that never ran a query never takes another element's answer. `elementPath` moves to `@symbo.ls/utils` (still exported by `@symbo.ls/element`).
8
+ - Updated dependencies [7b3795b]
9
+ - Updated dependencies [8700d85]
10
+ - Updated dependencies [9184c58]
11
+ - @symbo.ls/fetch@3.14.671
12
+ - @symbo.ls/utils@3.14.852
13
+ - @symbo.ls/element@3.14.817
14
+ - smbls@3.14.857
15
+
3
16
  ## 3.14.674
4
17
 
5
18
  ### Patch Changes
package/README.md CHANGED
@@ -40,7 +40,7 @@ In the browser, when the app JS loads (`smbls` `src/prerender.js`):
40
40
  3. With a registry (an adoption page): the app's normal `create()` runs, but each element takes the server's node at its path — its attributes and text are written again by the client, its element children are adopted the same way. A node of another tag is not adopted (that element gets a fresh one)
41
41
  4. The adoption stays open until the first view has settled: the first route rendered (also behind a guard that waits), and no `@symbo.ls/fetch` request in flight — so a list that renders with its first data adopts the server's rows. Meanwhile the server nodes still waiting for their element stay on screen, where they were. It closes at the latest after 3 s (`hydrate: { timeout }` in the project's config), or at the visitor's first click or key press; then whatever no element adopted goes, with the server's `<style>` tags
42
42
  5. Without a registry (a replace page, or `hydrate: false` in the project's config): the server's markup and styles go and the app renders fresh
43
- 6. Either way the recorded data answers (`data-fetch-seed`, below) are adopted by the requests that ask for them, so the client does not ask again for what the server had, and `el.context.prerendered` is `true` — a gate that hides the app until its data is in can let the server's first view count as ready
43
+ 6. Either way the recorded data answers (`data-fetch-seed`, below) are adopted by the requests that ask for them, so the client does not ask again for what the server had, and `el.context.prerendered` is `true`. An element whose query the render ran — at its create, or later (a state change, an `enabled` that turned true) — takes that query's recorded answer at its init, so it is taken over with the server's data and never shows its loading look in between; a gate that reads that data (a part busy until its rows are in) needs no special case for the takeover
44
44
 
45
45
  ```
46
46
  Browser DOM (static) DOMQL Tree (no nodes) After hydrate()
@@ -1,25 +1,25 @@
1
- import{resolve as m,join as Je,dirname as E}from"path";import{existsSync as b,unlinkSync as Ye,readFileSync as z,realpathSync as ze}from"fs";import{resolvePackageEntry as Ve}from"./packageEntry.js";import{tmpdir as Xe}from"os";import{randomBytes as Qe}from"crypto";import{createRequire as pe}from"module";import{pathToFileURL as Ze}from"url";import{createEnv as ke}from"./env.js";import{resetKeys as we,assignKeys as _e,mapKeysToElements as je}from"./keys.js";import{extractMetadata as ue,generateHeadHtml as et}from"./metadata.js";import"./hydrate.js";import{composeIntoShell as tt}from"./shell.js";import{trimSpriteToPage as ot,classRulesForPage as nt,markupClasses as st,trimVariablesToPage as rt}from"./pageWeight.js";import{fetchSSRTranslations as ct}from"./prefetch.js";import{createEarlySeedScript as at}from"@symbo.ls/fetch";import{headerEntries as it}from"@symbo.ls/fetch/rest";import{brenderStampMeta as lt,escapeRegExp as ft,jsonForScript as pt,libraryPackageSpecs as ut,polyglotFallbackLang as te,polyglotLangStorageKey as mt,polyglotAddressLang as dt,polyglotStartupScript as gt}from"@symbo.ls/utils";import{brenderRegistryBlock as ht,brenderRegistryTreeBlock as yt}from"@symbo.ls/utils/server";let oe=null;const bt=async()=>{if(oe)return oe;try{return oe=(await import("@symbo.ls/funcql")).funcqlPlugin,oe}catch{return null}};import"linkedom";import{createEarlySeedBlock as St}from"@symbo.ls/fetch";import{reset as Rt}from"@symbo.ls/css";const ne=(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},se=(e,t)=>te(e?.lang,t),xe=(e,t,o,n)=>{if(o?.translations){const r=o.translations[t];if(r){const a=ne(r,e);if(a!==void 0)return a}}if(n?.translations){const r=n.translations[t];if(r){const a=ne(r,e);if(a!==void 0)return a}}const s=te(void 0,o);if(s!==t&&o?.translations){const r=o.translations[s];if(r){const a=ne(r,e);if(a!==void 0)return a}}},kt=function(e,t){if(!e)return"";const o=this?.context,n=o?.polyglot,s=this?.state?.root||o?.state?.root,r=xe(e,t||se(s,n),n,s);if(r!==void 0)return r;const a=he(ge);return n&&a&&a.labelKeys.add(e),e},Te=function(){return se(this?.state?.root,this?.context?.polyglot)},$=(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?$(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?$(s,t):s}return o};let O=null;try{import.meta.url&&(O=pe(import.meta.url))}catch{}const wt=()=>{if(!import.meta.url||!O)return{isMonorepo:!1,monorepoRoot:null,resolvePackage:l=>l};const e=ze(new URL(".",import.meta.url).pathname),t=m(e,"../..");if(b(m(t,"packages","smbls","src","createDomql.js")))return{isMonorepo:!0,monorepoRoot:t};let n;try{const l=O.resolve("smbls/package.json");n=E(l)}catch{let l=e;for(;l!==E(l);){const h=m(l,"node_modules","smbls");if(b(m(h,"package.json"))){n=h;break}l=E(l)}}let s=O;if(n)try{s=pe(m(n,"package.json"))}catch{}let r,a=process.cwd();for(;a!==E(a);){if(b(m(a,"package.json"))){r=a;break}a=E(a)}let p=s;if(r)try{p=pe(m(r,"package.json"))}catch{}return{isMonorepo:!1,smblsRoot:n,brenderDir:e,projectRoot:r,_smblsRequire:s,_projectRequire:p}},G=(e,t)=>{const o=e.isMonorepo?[O]:[e._smblsRequire,e._projectRequire,O].filter(Boolean);for(const n of o)try{return n.resolve(t)}catch{}return null},Fo=(e,t,...o)=>{if(e.isMonorepo)return m(e.monorepoRoot,"packages",t,...o);const n=G(e,`${t}/package.json`);return n?m(E(n),...o):null},Bo=(e,t,...o)=>{if(e.isMonorepo)return m(e.monorepoRoot,"plugins",t,...o);const n=G(e,`@symbo.ls/${t}/package.json`);return n?m(E(n),...o):null},me=(e,t,...o)=>{if(e.isMonorepo){for(const s of["packages","plugins"]){const r=m(e.monorepoRoot,s,t,...o);if(b(r))return r}return null}const n=G(e,`@symbo.ls/${t}/package.json`);return n?m(E(n),...o):null},Ee=(e,t,...o)=>{if(e.isMonorepo)return m(e.monorepoRoot,"packages","domql","packages",t,...o);const n=G(e,`@symbo.ls/${t}/package.json`);return n?m(E(n),...o):null};let re=null;const ve="smbls/ssr",_t=async()=>{const e=await import("smbls/ssr");if(typeof e?.createDomqlElement!="function")throw new Error("smbls/ssr does not export createDomqlElement");return e},Le=()=>(re||(re=jt().catch(e=>{throw re=null,e})),re),jt=async()=>{const e=wt();let t;if(O&&e.isMonorepo)t=m(e.monorepoRoot,"packages","smbls","src","createDomql.js");else{let f;try{return await _t()}catch(i){f=i}if(!O)throw new Error(`brender: ${ve} is not available in this bundled runtime (${f.message}). Bundle smbls \u2265 the release that adds the smbls/ssr export alongside @symbo.ls/brender.`);const c=e.smblsRoot&&m(e.smblsRoot,"src","createDomql.js");if(c&&b(c))t=c;else throw new Error(`brender: cannot load ${ve} (${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=Je(Xe(),`br_createDomql_${Qe(6).toString("hex")}.mjs`),s=Ve,r=e.isMonorepo?await import(Ze(m(e.monorepoRoot,"scripts","vite-workspace-source.mjs")).href):null,a=r?new Set(r.workspacePackageRoots().map(f=>r.workspacePackageAt(f).name)):null,p=/^(?:smbls(?:\/.*)?|domql|css-in-props(?:\/.*)?|@symbo\.ls\/[^/]+)$/,l={name:"workspace-resolve",setup(f){r&&(f.onResolve({filter:/^[^./]/},c=>{if(p.test(c.path))return;const i=c.path.split("/"),u=c.path.startsWith("@")?i.slice(0,2).join("/"):i[0];if(!a.has(u))return;const g=r.resolveWorkspaceSource(c.path,c.importer||t);return g?{path:g}:{errors:[{text:`"${c.path}" names no source file in the workspace`}]}}),f.onLoad({filter:/[\\/]dist[\\/]/},c=>r.isWorkspaceDist(c.path)?{errors:[{text:`${c.path} is a BUILD of a workspace package \u2014 the render bundles source`}]}:void 0)),f.onResolve({filter:/^smbls/},c=>{const i=c.path.replace(/^smbls\/?/,""),u=e.isMonorepo?m(e.monorepoRoot,"packages","smbls"):e.smblsRoot;if(!u)return;if(!i){const x=s(u);return x?{path:x}:void 0}const g=m(u,i);if(b(g))return{path:g};if(b(g+".js"))return{path:g+".js"};const y=m(g,"index.js");if(b(y))return{path:y}}),f.onResolve({filter:/^domql$/},c=>{if(e.isMonorepo){const i=m(e.monorepoRoot,"packages","domql","src","index.js");if(b(i))return{path:i};const u=m(e.monorepoRoot,"packages","domql","index.js");if(b(u))return{path:u}}else try{const i=_require.resolve("domql/package.json"),u=s(E(i));if(u)return{path:u}}catch{}}),f.onResolve({filter:/^@symbo\.ls\//},c=>{const i=c.path.replace("@symbo.ls/","");if(i==="sync")return{path:"sync-stub",namespace:"brender-stub"};if(e.isMonorepo){for(const g of["packages","plugins"]){const y=m(e.monorepoRoot,g,i,"src","index.js");if(b(y))return{path:y};const x=m(e.monorepoRoot,g,i,"index.js");if(b(x))return{path:x}}const u=m(e.monorepoRoot,"packages","default-config","blank","index.js");if(i==="default-config"&&b(u))return{path:u}}else{const u=me(e,i,"src","index.js");if(u&&b(u))return{path:u};const g=me(e,i,"index.js");if(g&&b(g))return{path:g};if(i==="default-config"){const y=me(e,"default-config","blank","index.js");if(y&&b(y))return{path:y}}}}),f.onResolve({filter:/^@domql\//},c=>{const i=c.path.replace("@symbo.ls/","");if(e.isMonorepo){const u=m(e.monorepoRoot,"packages","domql","packages",i,"src","index.js");if(b(u))return{path:u};const g=m(e.monorepoRoot,"packages","domql","packages",i,"index.js");if(b(g))return{path:g}}else{const u=Ee(e,i,"src","index.js");if(u&&b(u))return{path:u};const g=Ee(e,i,"index.js");if(g&&b(g))return{path:g}}}),f.onResolve({filter:/^css-in-props/},c=>{let i;if(e.isMonorepo)i=m(e.monorepoRoot,"packages","css-in-props");else{const y=G(e,"css-in-props/package.json");y&&(i=E(y))}if(!i)return;const u=c.path.replace(/^css-in-props\/?/,"");if(u){const y=m(i,u),x=m(y,"index.js");if(b(x))return{path:x};if(b(y+".js"))return{path:y+".js"};if(b(y))return{path:y}}const g=s(i);if(g)return{path:g}}),f.onResolve({filter:/^@emotion\//},c=>{let i;if(e.isMonorepo)i=m(e.monorepoRoot,"node_modules",c.path);else{const u=G(e,`${c.path}/package.json`);if(!u)return;i=E(u)}if(b(i)){const u=m(i,"package.json");if(b(u))try{const g=JSON.parse(z(u,"utf8")),y=g.module||g.main||"dist/emotion-css.esm.js";return{path:m(i,y)}}catch{}return{path:i}}}),f.onResolve({filter:/\.json$/},c=>{if(c.resolveDir){const i=m(c.resolveDir,c.path);if(b(i))return{path:i}}}),f.onLoad({filter:/smbls\/.*options\.js$/},async c=>{if(!c.path.includes("smbls/")||!c.path.endsWith("options.js"))return;let i=z(c.path,"utf8");return i=i.replace(/import\s*\{[^}]*version[^}]*\}\s*from\s*['"][^'"]*package\.json['"][^;\n]*/,"const version = '0.0.0'"),i=i.replace(/import\s*\{[^}]*createRequire[^}]*\}\s*from\s*['"]module['"][^;\n]*/g,"// createRequire removed for brender build"),{contents:i,loader:"js"}}),f.onLoad({filter:/smbls\/.*init\.js$/},async c=>{if(!c.path.includes("smbls/")||!c.path.endsWith("init.js"))return;let i=z(c.path,"utf8");return i=i.replace(/import\s*\{[^}]*createRequire[^}]*\}\s*from\s*['"]module['"][^;\n]*/g,"// createRequire removed for brender build"),{contents:i,loader:"js"}}),f.onLoad({filter:/.*/,namespace:"brender-stub"},()=>({contents:"export const SyncComponent = {}; export const Inspect = {}; export const Notifications = {}; export const syncPlugin = () => ({}); export const notificationsPlugin = () => ({}); export const seedRawDesignSystem = () => {}; export const inspectPlugin = () => ({}); export default {}",loader:"js"})),f.onLoad({filter:/smbls\/src\/router\.js$/},async c=>{let i=z(c.path,"utf8");return i=i.replace(/import\s*\{\s*Link\s*\}\s*from\s*['"]smbls['"]/,"const Link = { tag: 'a', attr: { href: (el) => el.href } }"),{contents:i,loader:"js"}}),f.onLoad({filter:/fetchOnCreate\.js$/},async c=>{if(!c.path.includes("smbls/"))return;let i=z(c.path,"utf8");return i=i.replace(/window\s*&&\s*window\.location\s*\?\s*window\.location\.host\.includes/g,"window && window.location && window.location.host ? window.location.host.includes"),{contents:i,loader:"js"}})}};await o.build({entryPoints:[t],bundle:!0,format:"esm",platform:"node",outfile:n,write:!0,logLevel:"warning",plugins:[l],nodePaths:e.isMonorepo?[m(e.monorepoRoot,"node_modules")]:[...e.smblsRoot?[m(e.smblsRoot,"node_modules")]:[],...e.projectRoot?[m(e.projectRoot,"node_modules")]:[],...e.smblsRoot?[m(e.smblsRoot,"..","..","node_modules")]:[]].filter(f=>b(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 h=await import(`file://${n}`);if(process.env.BRENDER_DEBUG)console.log("[brender] Bundle saved:",n);else try{Ye(n)}catch{}return h},xt={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"}},Tt=(e,t)=>{const o={};return $e(e,(n,s)=>{if(!s.__brKey)return;const r=t(n);o[r===""?"__root":r]=s.__brKey}),o},$e=(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)},Et=new Set(["app","config","pages","components","state","snippets","designSystem","dependencies","functions","methods","files","sharedLibraries"]);let N=0;const De=Symbol.for("brender.fetchTracked"),de=()=>N,vt=256*1024,Lt=1024*1024,$t=new Set(["accept-language","accept"]),Ae={renders:0,record:null},Dt=50,ge={renders:0,record:null},Ce=(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)}}},he=e=>e.record&&!e.record.tainted?e.record:null,At=e=>{try{const t=new URL(e);return t.origin+t.pathname}catch{return String(e).split("?")[0]}},ye=(e,t,o)=>{!e||e.tainted||e.failures.length>=Dt||e.failures.push({url:At(t),reason:o})},qe=e=>e&&typeof e=="object"&&typeof e.url=="string"?e.url:String(e),Ct=e=>{const[t,o]=e,n=t&&typeof t=="object"&&typeof t.url=="string",s=qe(t),r=String(o&&o.method||n&&t.method||"GET").toUpperCase(),a={},p=l=>{if(!l)return;const h=!Array.isArray(l)&&typeof l.entries!="function";for(const[f,c]of it(l))h&&c==null||(a[String(f).toLowerCase()]=String(c))};return n&&p(t.headers),o&&p(o.headers),{url:s,method:r,headers:a}},qt=(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>vt||e.bytes+a.length>Lt||(e.bytes+=a.length,e.entries.push({url:t.url,lang:t.headers["accept-language"]||"",status:o.status,type:s,body:a}))},()=>{}))},Mt=()=>{const e=globalThis.fetch;if(typeof e!="function"||e[De])return;const t=function(...o){N++;let n=!1;const s=()=>{n||(n=!0,N--)},r=c=>{N++,c.then(()=>{N--},()=>{N--})},a=he(Ae),p=he(ge);let l=null;if(a)try{l=Ct(o),(l.method!=="GET"||!/^https?:/i.test(l.url)||Object.keys(l.headers).some(c=>!$t.has(c)))&&(l=null)}catch{l=null}const h=()=>qe(o[0]);let f;try{f=e.apply(this,o)}catch(c){throw ye(p,h(),c&&c.message||"failed"),s(),c}return f&&typeof f.then=="function"?f.then(c=>{l&&qt(a,l,c,r),p&&c&&c.ok===!1&&ye(p,h(),"HTTP "+c.status),s()},c=>{ye(p,h(),c&&c.message||"network error"),s()}):s(),f};t[De]=!0,globalThis.fetch=t},Ko=({brRegistry:e,fetchSeed:t,hydrateFlag:o=!0}={})=>{if(!e||!Object.keys(e).length)return"";const n=pt(e);return o?`<script>window.__BR_REGISTRY__=${n};window.__BRENDER_HYDRATE__=true<\/script>`+(t&&t.length?`
2
- `+at(t):""):`<script>window.__BR_REGISTRY__=${n}<\/script>`},Ot=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=ut(e())}catch{return}for(const[r]of s)!o.has(r)&&Object.prototype.hasOwnProperty.call(n,r)&&Reflect.deleteProperty(n,r)}},Pt=3e4,It=2147483647;let Me=Promise.resolve();const Oe=()=>{},Ft=e=>{const t=Me.then(e);return Me=t.then(Oe,Oe),t},Bt=e=>{if(e===void 0)return Pt;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,It)},Kt=(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},Gt=e=>{e.closed=!0;for(const t of e.undo.splice(0))t()},Nt=e=>{let t=!1;return()=>{t||(t=!0,e())}},Pe=(e,t={})=>{let o;try{o=Bt(t.timeout)}catch(n){return Promise.reject(n)}return Ft(()=>Ht(e,t,o))},Ht=async(e,t,o)=>{await Le();const n={closed:!1,undo:[]},s=Ut(e,t,n);if(!o)return s;let r;const a=new Promise((p,l)=>{r=setTimeout(()=>{Gt(n),l(Kt(t,o))},o)});try{return await Promise.race([s,a])}finally{clearTimeout(r)}},Ut=async(e,t,o)=>{const{route:n="/",pathname:s,state:r,context:a,prefetch:p=!1}=t,l=s||n;Mt();const h=Ce(ge,()=>({failures:[],labelKeys:new Set,tainted:!1}));try{return await Wt(e,{route:n,locationPath:l,stateOverrides:r,contextOverrides:a,prefetch:p},h.record,o)}finally{h.close()}},Wt=async(e,{route:t,locationPath:o,stateOverrides:n,contextOverrides:s,prefetch:r},a,p)=>{const l=()=>{if(p.closed)throw new Error("brender: this render was abandoned at its timeout")};let h;if(r){try{h=await ct(e)}catch(y){p.closed||console.warn("[brender] SSR translation fetch failed:",y.message)}l()}const{window:f,document:c}=ke(),i=c.body;f.location.pathname=o;let u=null;const g=[ce("document",c),ce("location",f.location),ce("localStorage",f.localStorage),ce("sessionStorage",f.sessionStorage),Ot(()=>u&&u.sharedLibraries)].map(Nt);p.undo.push(...g);try{const{createDomqlElement:y,PRERENDER_REGISTRY_FORMATS:x}=await Le();l();const ie=$(e.app||{}),j={...e.config||{}};e.polyglot&&!j.polyglot&&(j.polyglot=e.polyglot),e.fetch&&!j.fetch&&(j.fetch=e.fetch),e.router&&!j.router&&(j.router=e.router);for(const R of Qt)e[R]!=null&&j[R]==null&&(j[R]=e[R]);const w=j.polyglot?{...j.polyglot}:void 0,H=dt(o,w);H&&f.localStorage.setItem(mt(w),H),h&&w&&(w.translations={...w.translations||{},...h});const T=$(e.state||{});(h||w)&&(T.root||(T.root={}),w&&(T.root.lang=te(T.root.lang,w)),h&&(T.root.translations={...T.root.translations||{},...h})),Rt();const V={};for(const R in e){if(Et.has(R))continue;const d=e[R];V[R]=d&&typeof d=="object"?$(d):d}const v={...V,state:T,...n?{state:{...T,...n}}:{},dependencies:$(e.dependencies||{}),components:$(e.components||{}),snippets:$(e.snippets||{}),pages:$(e.pages||{}),functions:{...e.functions||{},polyglot:kt,getActiveLang:Te,getLang:Te},methods:e.methods||{},designSystem:$(e.designSystem||{}),files:e.files||{},sharedLibraries:e.sharedLibraries||[],...j,...w?{polyglot:w}:{},document:c,window:f,parent:{node:i},initOptions:{},domqlOptions:{sourcemap:!1},firstRender:!1,sync:!1,inspect:!1,notifications:!1,isolateDesignSystem:!0,isolateFetchCache:!0,captureDesignSystem:!0,...s||{}};u=v;const S=await bt();l(),S&&(v.plugins=v.plugins||[],v.plugins.some(R=>R.name==="funcql")||v.plugins.push(S)),we();const P=Ce(Ae,()=>({entries:[],bytes:0,tainted:!1})),K=P.record;let k;try{k=await y(ie,v),l();const R=Date.now(),d=r?2e3:50,_=D=>new Promise(fe=>setTimeout(fe,D));for(await _(Math.min(50,d));r&&!p.closed&&de()>0&&Date.now()-R<d;)await _(10),de()===0&&await _(Math.max(0,Math.min(50,d-(Date.now()-R))));if(l(),r&&await Jt(k,w)){l();const D=Date.now();for(await _(Math.min(50,d));!p.closed&&de()>0&&Date.now()-D<d;)await _(10);l()}}finally{P.close()}const U=K&&!K.tainted&&!(j.fetch&&j.fetch.seed===!1)?K.entries.slice():[];_e(i);const W=je(k),{elementPath:X}=await import("@symbo.ls/element");l();const J=Tt(k,X),Q=k?.context?.routerOptions?.contentElementKey||"content",L=k&&k[Q],Re=L&&typeof L=="object"&&L.__ref?L:void 0,Z=ue(e,t,k,k?.state,Re),A=[],Y=c.head||c.querySelector("head");if(Y)for(const R of Y.querySelectorAll("style")){if(R.sheet&&R.sheet.cssRules)for(const d of R.sheet.cssRules)d.cssText&&A.push(d);if(!A.length){const d=R.textContent||"";d&&A.push({cssText:d})}}const ee=A.map(R=>R.cssText),{globalCSS:le,classRules:I}=so(A);let C=Be(i.innerHTML);const F=k?.state?.root,q=se(F,w),M=Yt(h,F);M&&(C=Fe(C,Ie(M,q,w)));const B=a&&!a.tainted?{failedRequests:a.failures.slice(),rawLabelKeys:Xt(a.labelKeys,C,q,w,F)}:null;return{html:C,metadata:Z,registry:W,brRegistry:J,element:k,emotionCSS:ee,globalCSS:le,classRules:I,fetchSeed:U,document:c,window:f,ssrTranslations:M||void 0,activeLang:q,diagnostics:B,preparedDesignSystem:v.preparedDesignSystem||null,registryFormats:Array.isArray(x)?x.slice():["paths"]}}finally{for(const y of g)y()}},ce=(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]})},Jt=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=se(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},be=/\{\{\s*([^|{}]+?)\s*\|\s*polyglot\s*\}\}/g,Se=e=>e&&typeof e.parse=="function"?e.parse():e,Yt=(e,t)=>{const o=Se(t?.translations),n={};for(const s of[e,o])if(!(!s||typeof s!="object"))for(const r in s){const a=Se(s[r]);a&&typeof a=="object"&&(n[r]={...n[r]||{},...a})}return Object.keys(n).length?n:null},Ie=(e,t,o)=>e[t]||e[te(void 0,o)]||Object.values(e)[0]||{},Fe=(e,t)=>e.replace(be,(o,n)=>ne(t,n.trim())??o),zt=/<script\b[^>]*\btype\s*=\s*["']?application\/json["']?[^>]*>[\s\S]*?<\/script\s*>/gi,Vt=(e,t)=>new RegExp(`(?:^|[^\\w.-])${ft(t)}(?![\\w-]|\\.\\w)`).test(e),Xt=(e,t,o,n,s)=>{const r=new Set,a=t.replace(zt,"");for(const p of e)/\s/.test(p)||xe(p,o,n,s)===void 0&&Vt(a,p)&&r.add(p);for(const p of a.matchAll(be))r.add(p[1].trim());return[...r]},Go=async(e,t={})=>{const{context:o={}}=t,{window:n,document:s}=ke(),r=s.body,{create:a}=await import("@symbo.ls/element"),p=await import("@symbo.ls/utils"),l={...xt,...o.components||{}},h={...p,...o.utils||{},...o.functions||{}};we();let f;try{f=a(e,{node:r},"root",{context:{document:s,window:n,...o,components:l,utils:h}})}catch{}_e(r);const c=f?je(f):{};return{html:Be(r.innerHTML),registry:c,element:f}},Be=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}),Qt=["globalTheme","themeStorageKey","themeRoot","useReset","useVariable","useFontImport","useIconSprite","useSvgSprite","useDocumentTheme","useDefaultConfig","useDefaultIcons","useThemeSuffixedVars","verbose","semanticIcons"],Zt=new Set(["auto","system"]),Ke=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||Zt.has(s)?null:s},eo=e=>String(e).replace(/&/g,"&amp;").replace(/"/g,"&quot;").replace(/</g,"&lt;"),to=/\.[A-Za-z_\\-]/,oo=e=>{if(typeof e!="string"||!e)return!1;const t=e.replace(/"(?:[^"\\]|\\.)*"|'(?:[^'\\]|\\.)*'/g,'""').replace(/\[[^\]]*\]/g,"[]");return!to.test(t)},no=/^\s*(:root|\[data-theme|\[data-skin)/,Ge=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 oo(e.selectorText)?no.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(Ge));return n.has(null)||n.size!==1?n.has(null)?null:"reset":[...n][0]}return null},Ne=e=>typeof e=="string"&&/^\s*@font-face\b/i.test(e),so=e=>{const t={root:[],reset:[],keyframes:[]},o=[];for(const n of e||[]){const s=Ge(n);s?t[s].push(n.cssText):n&&n.cssText&&o.push(n.cssText)}return{globalCSS:{rootRule:t.root.join(`
1
+ import{resolve as m,join as Je,dirname as E}from"path";import{existsSync as S,unlinkSync as Ye,readFileSync as X,realpathSync as ze}from"fs";import{resolvePackageEntry as Ve}from"./packageEntry.js";import{tmpdir as Xe}from"os";import{randomBytes as Qe}from"crypto";import{createRequire as ue}from"module";import{pathToFileURL as Ze}from"url";import{createEnv as we}from"./env.js";import{resetKeys as _e,assignKeys as je,mapKeysToElements as xe}from"./keys.js";import{extractMetadata as me,generateHeadHtml as et}from"./metadata.js";import"./hydrate.js";import{composeIntoShell as tt}from"./shell.js";import{trimSpriteToPage as ot,classRulesForPage as nt,markupClasses as st,trimVariablesToPage as rt}from"./pageWeight.js";import{fetchSSRTranslations as ct}from"./prefetch.js";import{createEarlySeedScript as at}from"@symbo.ls/fetch";import{headerEntries as it}from"@symbo.ls/fetch/rest";import{brenderStampMeta as lt,escapeRegExp as ft,jsonForScript as pt,libraryPackageSpecs as ut,polyglotFallbackLang as oe,polyglotLangStorageKey as mt,polyglotAddressLang as dt,polyglotStartupScript as gt}from"@symbo.ls/utils";import{brenderRegistryBlock as ht,brenderRegistryTreeBlock as yt}from"@symbo.ls/utils/server";let ne=null;const bt=async()=>{if(ne)return ne;try{return ne=(await import("@symbo.ls/funcql")).funcqlPlugin,ne}catch{return null}};import"linkedom";import{createEarlySeedBlock as St,fetchRunsOf as Rt}from"@symbo.ls/fetch";import{reset as kt}from"@symbo.ls/css";const se=(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},re=(e,t)=>oe(e?.lang,t),Te=(e,t,o,n)=>{if(o?.translations){const r=o.translations[t];if(r){const a=se(r,e);if(a!==void 0)return a}}if(n?.translations){const r=n.translations[t];if(r){const a=se(r,e);if(a!==void 0)return a}}const s=oe(void 0,o);if(s!==t&&o?.translations){const r=o.translations[s];if(r){const a=se(r,e);if(a!==void 0)return a}}},wt=function(e,t){if(!e)return"";const o=this?.context,n=o?.polyglot,s=this?.state?.root||o?.state?.root,r=Te(e,t||re(s,n),n,s);if(r!==void 0)return r;const a=ye(he);return n&&a&&a.labelKeys.add(e),e},Ee=function(){return re(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 O=null;try{import.meta.url&&(O=ue(import.meta.url))}catch{}const _t=()=>{if(!import.meta.url||!O)return{isMonorepo:!1,monorepoRoot:null,resolvePackage:l=>l};const e=ze(new URL(".",import.meta.url).pathname),t=m(e,"../..");if(S(m(t,"packages","smbls","src","createDomql.js")))return{isMonorepo:!0,monorepoRoot:t};let n;try{const l=O.resolve("smbls/package.json");n=E(l)}catch{let l=e;for(;l!==E(l);){const g=m(l,"node_modules","smbls");if(S(m(g,"package.json"))){n=g;break}l=E(l)}}let s=O;if(n)try{s=ue(m(n,"package.json"))}catch{}let r,a=process.cwd();for(;a!==E(a);){if(S(m(a,"package.json"))){r=a;break}a=E(a)}let u=s;if(r)try{u=ue(m(r,"package.json"))}catch{}return{isMonorepo:!1,smblsRoot:n,brenderDir:e,projectRoot:r,_smblsRequire:s,_projectRequire:u}},K=(e,t)=>{const o=e.isMonorepo?[O]:[e._smblsRequire,e._projectRequire,O].filter(Boolean);for(const n of o)try{return n.resolve(t)}catch{}return null},Bo=(e,t,...o)=>{if(e.isMonorepo)return m(e.monorepoRoot,"packages",t,...o);const n=K(e,`${t}/package.json`);return n?m(E(n),...o):null},Ko=(e,t,...o)=>{if(e.isMonorepo)return m(e.monorepoRoot,"plugins",t,...o);const n=K(e,`@symbo.ls/${t}/package.json`);return n?m(E(n),...o):null},de=(e,t,...o)=>{if(e.isMonorepo){for(const s of["packages","plugins"]){const r=m(e.monorepoRoot,s,t,...o);if(S(r))return r}return null}const n=K(e,`@symbo.ls/${t}/package.json`);return n?m(E(n),...o):null},ve=(e,t,...o)=>{if(e.isMonorepo)return m(e.monorepoRoot,"packages","domql","packages",t,...o);const n=K(e,`@symbo.ls/${t}/package.json`);return n?m(E(n),...o):null};let ce=null;const Le="smbls/ssr",jt=async()=>{const e=await import("smbls/ssr");if(typeof e?.createDomqlElement!="function")throw new Error("smbls/ssr does not export createDomqlElement");return e},$e=()=>(ce||(ce=xt().catch(e=>{throw ce=null,e})),ce),xt=async()=>{const e=_t();let t;if(O&&e.isMonorepo)t=m(e.monorepoRoot,"packages","smbls","src","createDomql.js");else{let f;try{return await jt()}catch(i){f=i}if(!O)throw new Error(`brender: ${Le} is not available in this bundled runtime (${f.message}). Bundle smbls \u2265 the release that adds the smbls/ssr export alongside @symbo.ls/brender.`);const c=e.smblsRoot&&m(e.smblsRoot,"src","createDomql.js");if(c&&S(c))t=c;else throw new Error(`brender: cannot load ${Le} (${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=Je(Xe(),`br_createDomql_${Qe(6).toString("hex")}.mjs`),s=Ve,r=e.isMonorepo?await import(Ze(m(e.monorepoRoot,"scripts","vite-workspace-source.mjs")).href):null,a=r?new Set(r.workspacePackageRoots().map(f=>r.workspacePackageAt(f).name)):null,u=/^(?:smbls(?:\/.*)?|domql|css-in-props(?:\/.*)?|@symbo\.ls\/[^/]+)$/,l={name:"workspace-resolve",setup(f){r&&(f.onResolve({filter:/^[^./]/},c=>{if(u.test(c.path))return;const i=c.path.split("/"),p=c.path.startsWith("@")?i.slice(0,2).join("/"):i[0];if(!a.has(p))return;const h=r.resolveWorkspaceSource(c.path,c.importer||t);return h?{path:h}:{errors:[{text:`"${c.path}" names no source file in the workspace`}]}}),f.onLoad({filter:/[\\/]dist[\\/]/},c=>r.isWorkspaceDist(c.path)?{errors:[{text:`${c.path} is a BUILD of a workspace package \u2014 the render bundles source`}]}:void 0)),f.onResolve({filter:/^smbls/},c=>{const i=c.path.replace(/^smbls\/?/,""),p=e.isMonorepo?m(e.monorepoRoot,"packages","smbls"):e.smblsRoot;if(!p)return;if(!i){const j=s(p);return j?{path:j}:void 0}const h=m(p,i);if(S(h))return{path:h};if(S(h+".js"))return{path:h+".js"};const y=m(h,"index.js");if(S(y))return{path:y}}),f.onResolve({filter:/^domql$/},c=>{if(e.isMonorepo){const i=m(e.monorepoRoot,"packages","domql","src","index.js");if(S(i))return{path:i};const p=m(e.monorepoRoot,"packages","domql","index.js");if(S(p))return{path:p}}else try{const i=_require.resolve("domql/package.json"),p=s(E(i));if(p)return{path:p}}catch{}}),f.onResolve({filter:/^@symbo\.ls\//},c=>{const i=c.path.replace("@symbo.ls/","");if(i==="sync")return{path:"sync-stub",namespace:"brender-stub"};if(e.isMonorepo){for(const h of["packages","plugins"]){const y=m(e.monorepoRoot,h,i,"src","index.js");if(S(y))return{path:y};const j=m(e.monorepoRoot,h,i,"index.js");if(S(j))return{path:j}}const p=m(e.monorepoRoot,"packages","default-config","blank","index.js");if(i==="default-config"&&S(p))return{path:p}}else{const p=de(e,i,"src","index.js");if(p&&S(p))return{path:p};const h=de(e,i,"index.js");if(h&&S(h))return{path:h};if(i==="default-config"){const y=de(e,"default-config","blank","index.js");if(y&&S(y))return{path:y}}}}),f.onResolve({filter:/^@domql\//},c=>{const i=c.path.replace("@symbo.ls/","");if(e.isMonorepo){const p=m(e.monorepoRoot,"packages","domql","packages",i,"src","index.js");if(S(p))return{path:p};const h=m(e.monorepoRoot,"packages","domql","packages",i,"index.js");if(S(h))return{path:h}}else{const p=ve(e,i,"src","index.js");if(p&&S(p))return{path:p};const h=ve(e,i,"index.js");if(h&&S(h))return{path:h}}}),f.onResolve({filter:/^css-in-props/},c=>{let i;if(e.isMonorepo)i=m(e.monorepoRoot,"packages","css-in-props");else{const y=K(e,"css-in-props/package.json");y&&(i=E(y))}if(!i)return;const p=c.path.replace(/^css-in-props\/?/,"");if(p){const y=m(i,p),j=m(y,"index.js");if(S(j))return{path:j};if(S(y+".js"))return{path:y+".js"};if(S(y))return{path:y}}const h=s(i);if(h)return{path:h}}),f.onResolve({filter:/^@emotion\//},c=>{let i;if(e.isMonorepo)i=m(e.monorepoRoot,"node_modules",c.path);else{const p=K(e,`${c.path}/package.json`);if(!p)return;i=E(p)}if(S(i)){const p=m(i,"package.json");if(S(p))try{const h=JSON.parse(X(p,"utf8")),y=h.module||h.main||"dist/emotion-css.esm.js";return{path:m(i,y)}}catch{}return{path:i}}}),f.onResolve({filter:/\.json$/},c=>{if(c.resolveDir){const i=m(c.resolveDir,c.path);if(S(i))return{path:i}}}),f.onLoad({filter:/smbls\/.*options\.js$/},async c=>{if(!c.path.includes("smbls/")||!c.path.endsWith("options.js"))return;let i=X(c.path,"utf8");return i=i.replace(/import\s*\{[^}]*version[^}]*\}\s*from\s*['"][^'"]*package\.json['"][^;\n]*/,"const version = '0.0.0'"),i=i.replace(/import\s*\{[^}]*createRequire[^}]*\}\s*from\s*['"]module['"][^;\n]*/g,"// createRequire removed for brender build"),{contents:i,loader:"js"}}),f.onLoad({filter:/smbls\/.*init\.js$/},async c=>{if(!c.path.includes("smbls/")||!c.path.endsWith("init.js"))return;let i=X(c.path,"utf8");return i=i.replace(/import\s*\{[^}]*createRequire[^}]*\}\s*from\s*['"]module['"][^;\n]*/g,"// createRequire removed for brender build"),{contents:i,loader:"js"}}),f.onLoad({filter:/.*/,namespace:"brender-stub"},()=>({contents:"export const SyncComponent = {}; export const Inspect = {}; export const Notifications = {}; export const syncPlugin = () => ({}); export const notificationsPlugin = () => ({}); export const seedRawDesignSystem = () => {}; export const inspectPlugin = () => ({}); export default {}",loader:"js"})),f.onLoad({filter:/smbls\/src\/router\.js$/},async c=>{let i=X(c.path,"utf8");return i=i.replace(/import\s*\{\s*Link\s*\}\s*from\s*['"]smbls['"]/,"const Link = { tag: 'a', attr: { href: (el) => el.href } }"),{contents:i,loader:"js"}}),f.onLoad({filter:/fetchOnCreate\.js$/},async c=>{if(!c.path.includes("smbls/"))return;let i=X(c.path,"utf8");return i=i.replace(/window\s*&&\s*window\.location\s*\?\s*window\.location\.host\.includes/g,"window && window.location && window.location.host ? window.location.host.includes"),{contents:i,loader:"js"}})}};await o.build({entryPoints:[t],bundle:!0,format:"esm",platform:"node",outfile:n,write:!0,logLevel:"warning",plugins:[l],nodePaths:e.isMonorepo?[m(e.monorepoRoot,"node_modules")]:[...e.smblsRoot?[m(e.smblsRoot,"node_modules")]:[],...e.projectRoot?[m(e.projectRoot,"node_modules")]:[],...e.smblsRoot?[m(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{Ye(n)}catch{}return g},Tt={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"}},Et=(e,t)=>{const o={};return De(e,(n,s)=>{if(!s.__brKey)return;const r=t(n);o[r===""?"__root":r]=s.__brKey}),o},De=(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)},vt=new Set(["app","config","pages","components","state","snippets","designSystem","dependencies","functions","methods","files","sharedLibraries"]);let G=0;const Ae=Symbol.for("brender.fetchTracked"),ge=()=>G,Lt=256*1024,$t=1024*1024,Dt=new Set(["accept-language","accept"]),Ce={renders:0,record:null},At=50,he={renders:0,record:null},qe=(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)}}},ye=e=>e.record&&!e.record.tainted?e.record:null,Ct=e=>{try{const t=new URL(e);return t.origin+t.pathname}catch{return String(e).split("?")[0]}},be=(e,t,o)=>{!e||e.tainted||e.failures.length>=At||e.failures.push({url:Ct(t),reason:o})},Me=e=>e&&typeof e=="object"&&typeof e.url=="string"?e.url:String(e),qt=e=>{const[t,o]=e,n=t&&typeof t=="object"&&typeof t.url=="string",s=Me(t),r=String(o&&o.method||n&&t.method||"GET").toUpperCase(),a={},u=l=>{if(!l)return;const g=!Array.isArray(l)&&typeof l.entries!="function";for(const[f,c]of it(l))g&&c==null||(a[String(f).toLowerCase()]=String(c))};return n&&u(t.headers),o&&u(o.headers),{url:s,method:r,headers:a}},Mt=(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>Lt||e.bytes+a.length>$t||(e.bytes+=a.length,e.entries.push({url:t.url,lang:t.headers["accept-language"]||"",status:o.status,type:s,body:a}))},()=>{}))},Ot=()=>{const e=globalThis.fetch;if(typeof e!="function"||e[Ae])return;const t=function(...o){G++;let n=!1;const s=()=>{n||(n=!0,G--)},r=c=>{G++,c.then(()=>{G--},()=>{G--})},a=ye(Ce),u=ye(he);let l=null;if(a)try{l=qt(o),(l.method!=="GET"||!/^https?:/i.test(l.url)||Object.keys(l.headers).some(c=>!Dt.has(c)))&&(l=null)}catch{l=null}const g=()=>Me(o[0]);let f;try{f=e.apply(this,o)}catch(c){throw be(u,g(),c&&c.message||"failed"),s(),c}return f&&typeof f.then=="function"?f.then(c=>{l&&Mt(a,l,c,r),u&&c&&c.ok===!1&&be(u,g(),"HTTP "+c.status),s()},c=>{be(u,g(),c&&c.message||"network error"),s()}):s(),f};t[Ae]=!0,globalThis.fetch=t},Go=({brRegistry:e,fetchSeed:t,hydrateFlag:o=!0}={})=>{if(!e||!Object.keys(e).length)return"";const n=pt(e);return o?`<script>window.__BR_REGISTRY__=${n};window.__BRENDER_HYDRATE__=true<\/script>`+(t&&t.length?`
2
+ `+at(t):""):`<script>window.__BR_REGISTRY__=${n}<\/script>`},Pt=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=ut(e())}catch{return}for(const[r]of s)!o.has(r)&&Object.prototype.hasOwnProperty.call(n,r)&&Reflect.deleteProperty(n,r)}},It=3e4,Ft=2147483647;let Oe=Promise.resolve();const Pe=()=>{},Bt=e=>{const t=Oe.then(e);return Oe=t.then(Pe,Pe),t},Kt=e=>{if(e===void 0)return It;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,Ft)},Gt=(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},Nt=e=>{e.closed=!0;for(const t of e.undo.splice(0))t()},Ht=e=>{let t=!1;return()=>{t||(t=!0,e())}},Ie=(e,t={})=>{let o;try{o=Kt(t.timeout)}catch(n){return Promise.reject(n)}return Bt(()=>Ut(e,t,o))},Ut=async(e,t,o)=>{await $e();const n={closed:!1,undo:[]},s=Wt(e,t,n);if(!o)return s;let r;const a=new Promise((u,l)=>{r=setTimeout(()=>{Nt(n),l(Gt(t,o))},o)});try{return await Promise.race([s,a])}finally{clearTimeout(r)}},Wt=async(e,t,o)=>{const{route:n="/",pathname:s,state:r,context:a,prefetch:u=!1}=t,l=s||n;Ot();const g=qe(he,()=>({failures:[],labelKeys:new Set,tainted:!1}));try{return await Jt(e,{route:n,locationPath:l,stateOverrides:r,contextOverrides:a,prefetch:u},g.record,o)}finally{g.close()}},Jt=async(e,{route:t,locationPath:o,stateOverrides:n,contextOverrides:s,prefetch:r},a,u)=>{const l=()=>{if(u.closed)throw new Error("brender: this render was abandoned at its timeout")};let g;if(r){try{g=await ct(e)}catch(y){u.closed||console.warn("[brender] SSR translation fetch failed:",y.message)}l()}const{window:f,document:c}=we(),i=c.body;f.location.pathname=o;let p=null;const h=[ae("document",c),ae("location",f.location),ae("localStorage",f.localStorage),ae("sessionStorage",f.sessionStorage),Pt(()=>p&&p.sharedLibraries)].map(Ht);u.undo.push(...h);try{const{createDomqlElement:y,PRERENDER_REGISTRY_FORMATS:j}=await $e();l();const le=L(e.app||{}),_={...e.config||{}};e.polyglot&&!_.polyglot&&(_.polyglot=e.polyglot),e.fetch&&!_.fetch&&(_.fetch=e.fetch),e.router&&!_.router&&(_.router=e.router);for(const d of Zt)e[d]!=null&&_[d]==null&&(_[d]=e[d]);const w=_.polyglot?{..._.polyglot}:void 0,N=dt(o,w);N&&f.localStorage.setItem(mt(w),N),g&&w&&(w.translations={...w.translations||{},...g});const x=L(e.state||{});(g||w)&&(x.root||(x.root={}),w&&(x.root.lang=oe(x.root.lang,w)),g&&(x.root.translations={...x.root.translations||{},...g})),kt();const Q={};for(const d in e){if(vt.has(d))continue;const b=e[d];Q[d]=b&&typeof b=="object"?L(b):b}const T={...Q,state:x,...n?{state:{...x,...n}}:{},dependencies:L(e.dependencies||{}),components:L(e.components||{}),snippets:L(e.snippets||{}),pages:L(e.pages||{}),functions:{...e.functions||{},polyglot:wt,getActiveLang:Ee,getLang:Ee},methods:e.methods||{},designSystem:L(e.designSystem||{}),files:e.files||{},sharedLibraries:e.sharedLibraries||[],..._,...w?{polyglot:w}:{},document:c,window:f,parent:{node:i},initOptions:{},domqlOptions:{sourcemap:!1},firstRender:!1,sync:!1,inspect:!1,notifications:!1,isolateDesignSystem:!0,isolateFetchCache:!0,captureDesignSystem:!0,...s||{}};p=T;const R=await bt();l(),R&&(T.plugins=T.plugins||[],T.plugins.some(d=>d.name==="funcql")||T.plugins.push(R)),_e();const P=qe(Ce,()=>({entries:[],bytes:0,tainted:!1})),F=P.record;let k;try{k=await y(le,T),l();const d=Date.now(),b=r?2e3:50,v=V=>new Promise(pe=>setTimeout(pe,V));for(await v(Math.min(50,b));r&&!u.closed&&ge()>0&&Date.now()-d<b;)await v(10),ge()===0&&await v(Math.max(0,Math.min(50,b-(Date.now()-d))));if(l(),r&&await Yt(k,w)){l();const V=Date.now();for(await v(Math.min(50,b));!u.closed&&ge()>0&&Date.now()-V<b;)await v(10);l()}}finally{P.close()}const B=F&&!F.tainted&&!(_.fetch&&_.fetch.seed===!1)?F.entries.slice():[];je(i);const H=xe(k),{elementPath:U}=await import("@symbo.ls/element");l();const W=Et(k,U),Z=B.length?Rt(k&&k.context||T,U):{},D=k?.context?.routerOptions?.contentElementKey||"content",J=k&&k[D],ee=J&&typeof J=="object"&&J.__ref?J:void 0,te=me(e,t,k,k?.state,ee),A=[],Y=c.head||c.querySelector("head");if(Y)for(const d of Y.querySelectorAll("style")){if(d.sheet&&d.sheet.cssRules)for(const b of d.sheet.cssRules)b.cssText&&A.push(b);if(!A.length){const b=d.textContent||"";b&&A.push({cssText:b})}}const fe=A.map(d=>d.cssText),{globalCSS:I,classRules:z}=ro(A);let C=Ke(i.innerHTML);const q=k?.state?.root,M=re(q,w),$=zt(g,q);$&&(C=Be(C,Fe($,M,w)));const ke=a&&!a.tainted?{failedRequests:a.failures.slice(),rawLabelKeys:Qt(a.labelKeys,C,M,w,q)}:null;return{html:C,metadata:te,registry:H,brRegistry:W,element:k,emotionCSS:fe,globalCSS:I,classRules:z,fetchSeed:B,fetchRuns:Z,document:c,window:f,ssrTranslations:$||void 0,activeLang:M,diagnostics:ke,preparedDesignSystem:T.preparedDesignSystem||null,registryFormats:Array.isArray(j)?j.slice():["paths"]}}finally{for(const y of h)y()}},ae=(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]})},Yt=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=re(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},Se=/\{\{\s*([^|{}]+?)\s*\|\s*polyglot\s*\}\}/g,Re=e=>e&&typeof e.parse=="function"?e.parse():e,zt=(e,t)=>{const o=Re(t?.translations),n={};for(const s of[e,o])if(!(!s||typeof s!="object"))for(const r in s){const a=Re(s[r]);a&&typeof a=="object"&&(n[r]={...n[r]||{},...a})}return Object.keys(n).length?n:null},Fe=(e,t,o)=>e[t]||e[oe(void 0,o)]||Object.values(e)[0]||{},Be=(e,t)=>e.replace(Se,(o,n)=>se(t,n.trim())??o),Vt=/<script\b[^>]*\btype\s*=\s*["']?application\/json["']?[^>]*>[\s\S]*?<\/script\s*>/gi,Xt=(e,t)=>new RegExp(`(?:^|[^\\w.-])${ft(t)}(?![\\w-]|\\.\\w)`).test(e),Qt=(e,t,o,n,s)=>{const r=new Set,a=t.replace(Vt,"");for(const u of e)/\s/.test(u)||Te(u,o,n,s)===void 0&&Xt(a,u)&&r.add(u);for(const u of a.matchAll(Se))r.add(u[1].trim());return[...r]},No=async(e,t={})=>{const{context:o={}}=t,{window:n,document:s}=we(),r=s.body,{create:a}=await import("@symbo.ls/element"),u=await import("@symbo.ls/utils"),l={...Tt,...o.components||{}},g={...u,...o.utils||{},...o.functions||{}};_e();let f;try{f=a(e,{node:r},"root",{context:{document:s,window:n,...o,components:l,utils:g}})}catch{}je(r);const c=f?xe(f):{};return{html:Ke(r.innerHTML),registry:c,element:f}},Ke=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}),Zt=["globalTheme","themeStorageKey","themeRoot","useReset","useVariable","useFontImport","useIconSprite","useSvgSprite","useDocumentTheme","useDefaultConfig","useDefaultIcons","useThemeSuffixedVars","verbose","semanticIcons"],eo=new Set(["auto","system"]),Ge=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||eo.has(s)?null:s},to=e=>String(e).replace(/&/g,"&amp;").replace(/"/g,"&quot;").replace(/</g,"&lt;"),oo=/\.[A-Za-z_\\-]/,no=e=>{if(typeof e!="string"||!e)return!1;const t=e.replace(/"(?:[^"\\]|\\.)*"|'(?:[^'\\]|\\.)*'/g,'""').replace(/\[[^\]]*\]/g,"[]");return!oo.test(t)},so=/^\s*(:root|\[data-theme|\[data-skin)/,Ne=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 no(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(Ne));return n.has(null)||n.size!==1?n.has(null)?null:"reset":[...n][0]}return null},He=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=Ne(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 ae=new Set;const No=()=>{ae=new Set},Ho=()=>Array.from(ae).join(`
6
- `),Uo=(e,t)=>e.replace(/<style data-emotion="smbls">[\s\S]*?<\/style>/,t?`<style data-emotion="smbls">
5
+ `),fontFaceCSS:""},classRules:o}};let ie=new Set;const Ho=()=>{ie=new Set},Uo=()=>Array.from(ie).join(`
6
+ `),Wo=(e,t)=>e.replace(/<style data-emotion="smbls">[\s\S]*?<\/style>/,t?`<style data-emotion="smbls">
7
7
  ${t}
8
- </style>`:""),Wo=async(e,t={})=>{const{route:o="/",pathname:n,prefetch:s=!0,timeout:r}=t,a=await Pe(e,{route:o,pathname:n,prefetch:s,timeout:r});if(!a)return null;const p=e.designSystem||{},l=a.globalCSS;let h=null;try{const c=ro(a.element);Object.keys(c).length&&(h=c)}catch{}const f=a.activeLang;return{html:a.html,css:a.classRules.join(`
9
- `),classRules:a.classRules.slice(),globalCSS:l,resetCss:l.resetRules,fontLinks:Ue(p),metadata:a.metadata||ue(e,o),brKeyCount:a.registry?Object.keys(a.registry).length:0,brRegistry:a.brRegistry||{},fetchSeed:a.fetchSeed||[],ssrTranslations:a.ssrTranslations,prefetchedState:h,activeLang:f,theme:Ke(e),diagnostics:a.diagnostics,preparedDesignSystem:a.preparedDesignSystem||null}},ro=e=>{const t={};return $e(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("~/"),p=a?r.slice(2):r,l=a?o.state.root:o.state,h=Se(l&&l[p]);p&&h!=null&&typeof h!="function"&&(t[p]=h)}}),t},Jo=async(e,t="/",o={})=>{const{lang:n,themeColor:s,isr:r,hydrate:a=!0,prefetch:p=!0,shell:l,adoptDom:h=!1,pathname:f,eagerImages:c=He,preloadScripts:i=!0,nonce:u,timeout:g,stamp:y,time:x,spriteIcons:ie="all",cssClasses:j="all",cssVariables:w="all",registryFormat:H="paths"}=o,T=po(u),V=n||e.state?.lang||e.app?.metadata?.lang||"en",v=Ke(e),S=await Pe(e,{route:t,pathname:f,prefetch:p,timeout:g});if(!S)return null;const P={...S.metadata};if(s&&(P["theme-color"]=s),typeof l=="string"&&!e.name){const d="\0brender-undeclared-title\0";if(ue({...e,name:d},t,S.element,S.element?.state).title===d)for(const D of["title","og:title","twitter:title"])P[D]===S.metadata.title&&delete P[D]}const K=et(P);for(const d of S.classRules)d&&ae.add(d);let k=io(S.html,c);ie==="page"&&(k=ot(k,typeof l=="string"?l:"").html);const U=Array.from(ae),W=U.filter(Ne),X=W.length?U.filter(d=>!Ne(d)):U,J=j==="page"?nt(X,st(k,typeof l=="string"?l:"")).join(`
10
- `):X.join(`
11
- `),Q=W.length?`<style data-smbls-faces>
12
- ${W.join(`
8
+ </style>`:""),Jo=async(e,t={})=>{const{route:o="/",pathname:n,prefetch:s=!0,timeout:r}=t,a=await Ie(e,{route:o,pathname:n,prefetch:s,timeout:r});if(!a)return null;const u=e.designSystem||{},l=a.globalCSS;let g=null;try{const c=co(a.element);Object.keys(c).length&&(g=c)}catch{}const f=a.activeLang;return{html:a.html,css:a.classRules.join(`
9
+ `),classRules:a.classRules.slice(),globalCSS:l,resetCss:l.resetRules,fontLinks:We(u),metadata:a.metadata||me(e,o),brKeyCount:a.registry?Object.keys(a.registry).length:0,brRegistry:a.brRegistry||{},fetchSeed:a.fetchSeed||[],fetchRuns:a.fetchRuns||{},ssrTranslations:a.ssrTranslations,prefetchedState:g,activeLang:f,theme:Ge(e),diagnostics:a.diagnostics,preparedDesignSystem:a.preparedDesignSystem||null}},co=e=>{const t={};return De(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("~/"),u=a?r.slice(2):r,l=a?o.state.root:o.state,g=Re(l&&l[u]);u&&g!=null&&typeof g!="function"&&(t[u]=g)}}),t},Yo=async(e,t="/",o={})=>{const{lang:n,themeColor:s,isr:r,hydrate:a=!0,prefetch:u=!0,shell:l,adoptDom:g=!1,pathname:f,eagerImages:c=Ue,preloadScripts:i=!0,nonce:p,timeout:h,stamp:y,time:j,spriteIcons:le="all",cssClasses:_="all",cssVariables:w="all",registryFormat:N="paths"}=o,x=uo(p),Q=n||e.state?.lang||e.app?.metadata?.lang||"en",T=Ge(e),R=await Ie(e,{route:t,pathname:f,prefetch:u,timeout:h});if(!R)return null;const P={...R.metadata};if(s&&(P["theme-color"]=s),typeof l=="string"&&!e.name){const d="\0brender-undeclared-title\0";if(me({...e,name:d},t,R.element,R.element?.state).title===d)for(const v of["title","og:title","twitter:title"])P[v]===R.metadata.title&&delete P[v]}const F=et(P);for(const d of R.classRules)d&&ie.add(d);let k=lo(R.html,c);le==="page"&&(k=ot(k,typeof l=="string"?l:"").html);const B=Array.from(ie),H=B.filter(He),U=H.length?B.filter(d=>!He(d)):B,W=_==="page"?nt(U,st(k,typeof l=="string"?l:"")).join(`
10
+ `):U.join(`
11
+ `),Z=H.length?`<style data-smbls-faces>
12
+ ${H.join(`
13
13
  `)}
14
- </style>`:"",L=S.globalCSS,Z=`<style data-brender>
15
- ${(w==="page"?rt(L.rootRule||"",L.resetRules,L.keyframeRules,J,k,typeof l=="string"?l:"").css:L.rootRule)||""}
16
- ${L.resetRules||""}
17
- ${L.keyframeRules||""}
18
- </style>`,A=J?`<style data-emotion="smbls">
19
- ${J}
20
- </style>`:"",Y=Ue(e.designSystem||{}),ee=Object.keys(S.registry).length,le=H==="tree"||H==="auto"&&(S.registryFormats||[]).includes("tree"),I=lo({brRegistry:S.brRegistry,fetchSeed:S.fetchSeed,adoptDom:h,stamp:y,time:x,registryFormat:le?"tree":"paths"});let C="";if(r&&r.clientScript){const d=Number.isInteger(o.depth)?o.depth:t==="/"?0:t.replace(/^\/|\/$/g,"").split("/").length,_=d>0?"../".repeat(d):"./";if(a){const D=gt({polyglot:e.polyglot||e.config?.polyglot,translations:S.ssrTranslations,lang:S.activeLang,pathname:f||t,attrs:T}),fe=D?D+`
21
- `:"",We=I.blocks?I.blocks+`
22
- `:"";C=`${fe}${We}<script type="module" src="${_}${r.clientScript}"${T}><\/script>`}else C=`<script type="module"${T}>
14
+ </style>`:"",D=R.globalCSS,ee=`<style data-brender>
15
+ ${(w==="page"?rt(D.rootRule||"",D.resetRules,D.keyframeRules,W,k,typeof l=="string"?l:"").css:D.rootRule)||""}
16
+ ${D.resetRules||""}
17
+ ${D.keyframeRules||""}
18
+ </style>`,te=W?`<style data-emotion="smbls">
19
+ ${W}
20
+ </style>`:"",A=We(e.designSystem||{}),Y=Object.keys(R.registry).length,fe=N==="tree"||N==="auto"&&(R.registryFormats||[]).includes("tree"),I=fo({brRegistry:R.brRegistry,fetchSeed:R.fetchSeed,fetchRuns:R.fetchRuns,adoptDom:g,stamp:y,time:j,registryFormat:fe?"tree":"paths"});let z="";if(r&&r.clientScript){const d=Number.isInteger(o.depth)?o.depth:t==="/"?0:t.replace(/^\/|\/$/g,"").split("/").length,b=d>0?"../".repeat(d):"./";if(a){const v=gt({polyglot:e.polyglot||e.config?.polyglot,translations:R.ssrTranslations,lang:R.activeLang,pathname:f||t,attrs:x}),V=v?v+`
21
+ `:"",pe=I.blocks?I.blocks+`
22
+ `:"";z=`${V}${pe}<script type="module" src="${b}${r.clientScript}"${x}><\/script>`}else z=`<script type="module"${x}>
23
23
  {
24
24
  const brEls = document.querySelectorAll('body > :not(script):not(style)')
25
25
  const observer = new MutationObserver((mutations) => {
@@ -36,23 +36,23 @@ ${J}
36
36
  observer.observe(document.body, { childList: true })
37
37
  }
38
38
  <\/script>
39
- <script type="module" src="${_}${r.clientScript}"${T}><\/script>`}const F={...e.config||{}};e.polyglot&&!F.polyglot&&(F.polyglot=e.polyglot);const q=F.polyglot;let M=K;if(q){const d={...q.translations||{}};for(const _ in S.ssrTranslations||{})d[_]={...d[_]||{},...S.ssrTranslations[_]};M=Fe(K,Ie(d,S.activeLang,q))}const B=S.diagnostics;if(B)for(const d of M.matchAll(be)){const _=d[1].trim();B.rawLabelKeys.includes(_)||B.rawLabelKeys.push(_)}return typeof l=="string"?{html:tt(l,{headTags:`${M}
40
- ${I.meta}`,headEnd:[Y,Q,Z,A].filter(Boolean).join(`
41
- `),body:k,depth:Number.isInteger(o.depth)?o.depth:0,bootScripts:I.blocks,lang:n||(q?S.activeLang:void 0),theme:v,preloadScripts:i}),route:t,brKeyCount:ee,shell:!0,diagnostics:B,preparedDesignSystem:S.preparedDesignSystem||null}:{html:`<!DOCTYPE html>
42
- <html lang="${V}"${v?` data-theme="${eo(v)}"`:""}>
39
+ <script type="module" src="${b}${r.clientScript}"${x}><\/script>`}const C={...e.config||{}};e.polyglot&&!C.polyglot&&(C.polyglot=e.polyglot);const q=C.polyglot;let M=F;if(q){const d={...q.translations||{}};for(const b in R.ssrTranslations||{})d[b]={...d[b]||{},...R.ssrTranslations[b]};M=Be(F,Fe(d,R.activeLang,q))}const $=R.diagnostics;if($)for(const d of M.matchAll(Se)){const b=d[1].trim();$.rawLabelKeys.includes(b)||$.rawLabelKeys.push(b)}return typeof l=="string"?{html:tt(l,{headTags:`${M}
40
+ ${I.meta}`,headEnd:[A,Z,ee,te].filter(Boolean).join(`
41
+ `),body:k,depth:Number.isInteger(o.depth)?o.depth:0,bootScripts:I.blocks,lang:n||(q?R.activeLang:void 0),theme:T,preloadScripts:i}),route:t,brKeyCount:Y,shell:!0,diagnostics:$,preparedDesignSystem:R.preparedDesignSystem||null}:{html:`<!DOCTYPE html>
42
+ <html lang="${Q}"${T?` data-theme="${to(T)}"`:""}>
43
43
  <head>
44
44
  ${M}${r&&r.clientScript&&a?`
45
45
  ${I.meta}`:""}
46
- ${Y}
47
- ${Q}
48
- ${Z}
49
46
  ${A}
47
+ ${Z}
48
+ ${ee}
49
+ ${te}
50
50
  </head>
51
51
  <body>
52
52
  ${k}
53
- ${C}
53
+ ${z}
54
54
  </body>
55
- </html>`,route:t,brKeyCount:ee,diagnostics:B,preparedDesignSystem:S.preparedDesignSystem||null}},He=2,co=/<img\b(?:[^>"']|"[^"]*"|'[^']*')*>/gi,ao=/\sloading\s*=/i,io=(e,t=He)=>{if(t===!1||t==null||typeof e!="string")return e;const o=Math.max(0,Number(t)||0);let n=0;return e.replace(co,s=>n++<o||ao.test(s)?s:s.replace(/^<img\b/i,'<img loading="lazy"'))},Ue=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(`
56
- `):""},lo=({brRegistry:e,fetchSeed:t,adoptDom:o=!1,stamp:n,time:s,registryFormat:r="paths"}={})=>{const p=o&&e&&Object.keys(e).length?r==="tree"&&yt(e)||ht(e):"",l=St(t);return{meta:`<meta name="brender" content="${p?"hydrate":"replace"}">
57
- `+lt(fo(n,s)),blocks:[p,l].filter(Boolean).join(`
58
- `)}},fo=(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}},po=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{He as EAGER_IMAGES_DEFAULT,ve as SMBLS_SSR_SPECIFIER,Ko as adoptionScripts,fo as buildStamp,Ke as fixedThemeOf,Ho as getAccumulatedEmotionCSS,io as markLazyImages,lo as prerenderParts,Pe as render,Go as renderElement,Jo as renderPage,Wo as renderRoute,Uo as replaceEmotionCSS,No as resetGlobalCSSCache,so as splitCapturedCSS};
55
+ </html>`,route:t,brKeyCount:Y,diagnostics:$,preparedDesignSystem:R.preparedDesignSystem||null}},Ue=2,ao=/<img\b(?:[^>"']|"[^"]*"|'[^']*')*>/gi,io=/\sloading\s*=/i,lo=(e,t=Ue)=>{if(t===!1||t==null||typeof e!="string")return e;const o=Math.max(0,Number(t)||0);let n=0;return e.replace(ao,s=>n++<o||io.test(s)?s:s.replace(/^<img\b/i,'<img loading="lazy"'))},We=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(`
56
+ `):""},fo=({brRegistry:e,fetchSeed:t,fetchRuns:o,adoptDom:n=!1,stamp:s,time:r,registryFormat:a="paths"}={})=>{const l=n&&e&&Object.keys(e).length?a==="tree"&&yt(e)||ht(e):"",g=St(t,o);return{meta:`<meta name="brender" content="${l?"hydrate":"replace"}">
57
+ `+lt(po(s,r)),blocks:[l,g].filter(Boolean).join(`
58
+ `)}},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}},uo=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{Ue as EAGER_IMAGES_DEFAULT,Le as SMBLS_SSR_SPECIFIER,Go as adoptionScripts,po as buildStamp,Ge as fixedThemeOf,Uo as getAccumulatedEmotionCSS,lo as markLazyImages,fo as prerenderParts,Ie as render,No as renderElement,Yo as renderPage,Jo as renderRoute,Wo as replaceEmotionCSS,Ho as resetGlobalCSSCache,ro as splitCapturedCSS};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@symbo.ls/brender",
3
- "version": "3.14.674",
3
+ "version": "3.14.675",
4
4
  "license": "CC-BY-NC-4.0",
5
5
  "type": "module",
6
6
  "module": "./dist/esm/index.js",
@@ -48,16 +48,16 @@
48
48
  "dependencies": {
49
49
  "@symbo.ls/css": "^3.14.782",
50
50
  "@symbo.ls/default-config": "^3.14.789",
51
- "@symbo.ls/element": "^3.14.813",
52
- "@symbo.ls/fetch": "^3.14.669",
51
+ "@symbo.ls/element": "^3.14.817",
52
+ "@symbo.ls/fetch": "^3.14.671",
53
53
  "@symbo.ls/helmet": "^3.14.671",
54
54
  "@symbo.ls/scratch": "^3.14.795",
55
- "@symbo.ls/utils": "^3.14.851",
55
+ "@symbo.ls/utils": "^3.14.852",
56
56
  "esbuild": "^0.28.1",
57
57
  "linkedom": "^0.16.8"
58
58
  },
59
59
  "peerDependencies": {
60
- "smbls": "^3.14.856"
60
+ "smbls": "^3.14.857"
61
61
  },
62
62
  "optionalDependencies": {
63
63
  "@symbo.ls/funcql": "^3.14.0"
package/render.js CHANGED
@@ -31,7 +31,7 @@ const getFuncqlPlugin = async () => {
31
31
  }
32
32
  }
33
33
  import { parseHTML } from 'linkedom'
34
- import { createEarlySeedBlock } from '@symbo.ls/fetch'
34
+ import { createEarlySeedBlock, fetchRunsOf } from '@symbo.ls/fetch'
35
35
  import { css, injectGlobal, reset as resetCss } from '@symbo.ls/css'
36
36
 
37
37
  // Lightweight SSR polyglot functions — resolve translations from context
@@ -1408,6 +1408,11 @@ const renderWithDiagnostics = async (data, { route, locationPath, stateOverrides
1408
1408
  const { elementPath } = await import('@symbo.ls/element')
1409
1409
  live()
1410
1410
  const brRegistry = buildPathRegistry(element, elementPath)
1411
+ // Which queries each element ran (@symbo.ls/fetch fetchRunsOf), named by
1412
+ // the same paths: the page carries it beside the recorded answers, so a
1413
+ // part whose query ran after its create starts from that query's answer
1414
+ // when the browser takes it over (fetch "Queries the build ran later").
1415
+ const fetchRuns = fetchSeed.length ? fetchRunsOf((element && element.context) || ctx, elementPath) : {}
1411
1416
 
1412
1417
  // Extract metadata for the rendered route
1413
1418
  // Pass the rendered element and its state so function-valued metadata
@@ -1464,7 +1469,7 @@ const renderWithDiagnostics = async (data, { route, locationPath, stateOverrides
1464
1469
  }
1465
1470
  : null
1466
1471
 
1467
- return { html, metadata, registry, brRegistry, element, emotionCSS, globalCSS, classRules, fetchSeed, document, window, ssrTranslations: labels || undefined, activeLang, diagnostics, preparedDesignSystem: ctx.preparedDesignSystem || null,
1472
+ return { html, metadata, registry, brRegistry, element, emotionCSS, globalCSS, classRules, fetchSeed, fetchRuns, document, window, ssrTranslations: labels || undefined, activeLang, diagnostics, preparedDesignSystem: ctx.preparedDesignSystem || null,
1468
1473
  // the registry encodings the client of this smbls reads (smbls
1469
1474
  // prerender.js PRERENDER_REGISTRY_FORMATS); an older smbls reads paths
1470
1475
  registryFormats: Array.isArray(PRERENDER_REGISTRY_FORMATS) ? PRERENDER_REGISTRY_FORMATS.slice() : ['paths'] }
@@ -1856,6 +1861,8 @@ export const renderRoute = async (data, options = {}) => {
1856
1861
  brRegistry: result.brRegistry || {},
1857
1862
  // anonymous GET answers this render got (see `SEED`) — for adoptionScripts
1858
1863
  fetchSeed: result.fetchSeed || [],
1864
+ // which queries each element ran (fetchRunsOf) — beside the seed
1865
+ fetchRuns: result.fetchRuns || {},
1859
1866
  ssrTranslations: result.ssrTranslations,
1860
1867
  prefetchedState,
1861
1868
  activeLang,
@@ -2056,7 +2063,7 @@ export const renderPage = async (data, route = '/', options = {}) => {
2056
2063
  // `registryFormat: 'auto'` — the tree when the smbls this page renders
2057
2064
  // with (the page's own client) reads it, else paths (XMA round 8, E13).
2058
2065
  const treeRegistry = registryFormat === 'tree' || (registryFormat === 'auto' && (result.registryFormats || []).includes('tree'))
2059
- const prerender = prerenderParts({ brRegistry: result.brRegistry, fetchSeed: result.fetchSeed, adoptDom, stamp, time, registryFormat: treeRegistry ? 'tree' : 'paths' })
2066
+ const prerender = prerenderParts({ brRegistry: result.brRegistry, fetchSeed: result.fetchSeed, fetchRuns: result.fetchRuns, adoptDom, stamp, time, registryFormat: treeRegistry ? 'tree' : 'paths' })
2060
2067
 
2061
2068
  // ISR: include client SPA bundle for hydration + data fetching
2062
2069
  let isrBody = ''
@@ -2260,12 +2267,14 @@ const generateFontLinks = (ds) => {
2260
2267
  // `registryFormat: 'tree'` writes the registry as a tree (@symbo.ls/utils
2261
2268
  // encodeBrenderRegistry, XMA round 8, E13) — the same data, a third of the
2262
2269
  // bytes — in its own block; a registry that cannot be one stays paths.
2263
- export const prerenderParts = ({ brRegistry, fetchSeed, adoptDom = false, stamp, time, registryFormat = 'paths' } = {}) => {
2270
+ // `fetchRuns` — which queries each element ran (@symbo.ls/fetch
2271
+ // fetchRunsOf), carried in the seed block with the answers.
2272
+ export const prerenderParts = ({ brRegistry, fetchSeed, fetchRuns, adoptDom = false, stamp, time, registryFormat = 'paths' } = {}) => {
2264
2273
  const has = adoptDom && brRegistry && Object.keys(brRegistry).length
2265
2274
  const registry = has
2266
2275
  ? (registryFormat === 'tree' && brenderRegistryTreeBlock(brRegistry)) || brenderRegistryBlock(brRegistry)
2267
2276
  : ''
2268
- const seed = createEarlySeedBlock(fetchSeed)
2277
+ const seed = createEarlySeedBlock(fetchSeed, fetchRuns)
2269
2278
  return {
2270
2279
  meta: `<meta name="brender" content="${registry ? 'hydrate' : 'replace'}">\n` + brenderStampMeta(buildStamp(stamp, time)),
2271
2280
  blocks: [registry, seed].filter(Boolean).join('\n')