@simai-studio/ui 5.20261019.1827 → 5.20261019.1921

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.
Files changed (37) hide show
  1. package/README.md +4 -4
  2. package/distr/component/country-code/js/country-code.min.js +1 -1
  3. package/distr/component/dropdown/js/dropdown.min.js +1 -1
  4. package/distr/component/file-upload/js/file-upload.min.js +1 -1
  5. package/distr/component/inputs/js/inputs.min.js +1 -1
  6. package/distr/component/pagination/css/pagination.min.css +1 -1
  7. package/distr/component/quantity/js/quantity.min.js +1 -1
  8. package/distr/component/textarea/js/textarea.min.js +1 -1
  9. package/distr/core/contracts/adaptive-sizing.schema.json +1 -1
  10. package/distr/core/contracts/composite-host-port.v1.schema.json +1 -1
  11. package/distr/core/contracts/composition-document.v1.schema.json +1 -1
  12. package/distr/core/contracts/composition-editor-field-kind.v1.schema.json +1 -1
  13. package/distr/core/contracts/composition-editor-manifest.v1.schema.json +1 -1
  14. package/distr/core/contracts/composition-port-manifest.v1.schema.json +1 -1
  15. package/distr/core/contracts/composition-type-manifest.v1.schema.json +1 -1
  16. package/distr/core/js/core-loader.js +12 -10
  17. package/distr/core/js/core-loader.min.js +1 -1
  18. package/distr/core/js/core.js +42 -17
  19. package/distr/core/js/core.min.js +1 -1
  20. package/distr/core/js/smart-base.js +2 -2
  21. package/distr/core/js/smart-base.min.js +1 -1
  22. package/distr/smart/avatar/js/avatar.min.js +1 -1
  23. package/distr/smart/badges/js/badges.min.js +1 -1
  24. package/distr/smart/buttons/js/buttons.min.js +1 -1
  25. package/distr/smart/country-code/js/country-code.min.js +1 -1
  26. package/distr/smart/datepicker/js/datepicker.min.js +1 -1
  27. package/distr/smart/dropdown/js/dropdown.min.js +1 -1
  28. package/distr/smart/file-upload/js/file-upload.min.js +1 -1
  29. package/distr/smart/inputs/js/inputs.min.js +1 -1
  30. package/distr/smart/list-item/js/list-item.min.js +16 -16
  31. package/distr/smart/modal/contract.json +1 -1
  32. package/distr/smart/progress-scale/js/progress-scale.min.js +1 -1
  33. package/distr/smart/reference-link/js/reference-link.min.js +1 -1
  34. package/distr/smart/tags/js/tags.min.js +1 -1
  35. package/distr/smart/textarea/js/textarea.min.js +5 -5
  36. package/package-manifest.json +37 -37
  37. package/package.json +4 -4
@@ -1,4 +1,4 @@
1
- (()=>{var e={"6c7f357fe960"(e,t,n){"use strict";n.d(t,{$Y:()=>l,VE:()=>c,c6:()=>s,ub:()=>a,vq:()=>r});const o=Object.freeze({width:31.68,height:48,distance:6,cycle:1800,rotateAt:1458,rotationStep:90,transition:300,easing:"cubic-bezier(0.3, 1.85, 0.55, 1)"}),i="__sfPreloaderMotion";function s(e=document.documentElement){return`var(--sf-on-surface, ${e?.classList?.contains("theme-dark")?"#e3e2e7":"#1a1b1f"})`}function r(e=document.documentElement){return`var(--sf-color--surface-highest, var(--sf-surface-0, ${e?.classList?.contains("theme-dark")?"#0f1115":"#ffffff"}))`}function a(e={}){const t={...o,...e};return`<svg data-sf-preloader-mark id="sv_li_1" xmlns="http://www.w3.org/2000/svg" width="${t.width}" height="${t.height}" viewBox="0 0 66 100" fill="none">\n<path fill-rule="evenodd" clip-rule="evenodd" d="M0 50.0013L49.812 0L66 16.2495L32.3722 50.0051L65.9938 83.7543L49.8097 100L0 50.0013Z" fill="${t.color}"/>\n</svg>\n<svg data-sf-preloader-mark id="sv_li_2" xmlns="http://www.w3.org/2000/svg" width="${t.width}" height="${t.height}" viewBox="0 0 66 100" fill="none">\n<path fill-rule="evenodd" clip-rule="evenodd" d="M66 50.0013L16.188 0L0 16.2495L33.6278 50.0051L0.00615692 83.7543L16.1903 100L66 50.0013Z" fill="${t.color}"/>\n</svg>`}function l(e){e?.[i]?.()}function c(e,t=()=>!0,n={}){if(!e)return()=>{};l(e);const s={...o,...n},r=Array.from(e.querySelectorAll("[data-sf-preloader-mark]"));if(2!==r.length||"function"!=typeof r[0].animate)return()=>{};if(window.matchMedia?.("(prefers-reduced-motion: reduce)").matches){e.style.transition="none",e.style.transform="rotate(0deg)",r.forEach(e=>{e.style.transform="none"});const t=()=>{e[i]===t&&delete e[i]};return e[i]=t,t}e.style.transition=`${s.transition}ms transform ease-in-out`;let a=0,c=null,u=!1;const d=r.map((e,t)=>{const n=0===t?-s.distance:s.distance;return e.animate([{transform:"translateX(0)",offset:0,easing:s.easing},{transform:`translateX(${n}px)`,offset:.36,easing:s.easing},{transform:`translateX(${n}px)`,offset:.48,easing:s.easing},{transform:"translateX(0)",offset:.84,easing:s.easing},{transform:"translateX(0)",offset:1}],{duration:s.cycle,iterations:Number.POSITIVE_INFINITY})}),f=()=>{!u&&t()&&(a+=s.rotationStep,e.style.transform=`rotate(${a}deg)`,c=window.setTimeout(f,s.cycle))};c=window.setTimeout(f,s.rotateAt);const p=()=>{u||(u=!0,window.clearTimeout(c),d.forEach(e=>e.cancel()),e.style.transform="rotate(0deg)",r.forEach(e=>{e.style.transform="none"}),e[i]===p&&delete e[i])};return e[i]=p,p}n.d(t,["Hg",0,o])},"3924cca3566b"(e,t,n){(()=>{const e="https://cdn.jsdelivr.net/gh/simai/ui@main/distr/";if("undefined"==typeof window)return;if(!window.sfPath){window.sfPath=e;try{console.warn(`SIMAI Framework: window.sfPath is not set, so the runtime is loading from ${e} — an unpinned branch that changes without notice. Set window.sfPath to your own copy of distr/, before core.js, or to a released commit: https://cdn.jsdelivr.net/gh/simai/ui@<commit>/distr/ .`)}catch{}}const t=e=>{try{return new URL(window.sfPath,e||void 0)}catch{return null}},o=t("undefined"==typeof document?"":document.baseURI)||t(window.location?.href)||new URL(e);o.pathname.endsWith("/")||(o.pathname+="/");const i=o.pathname.endsWith("/core/")?o:new URL("core/",o),s="undefined"==typeof document?null:Array.from(document.scripts).reverse().find(e=>{if(!e.src)return!1;try{return/\/core\/js\/core(?:\.min)?\.js$/.test(new URL(e.src,document.baseURI).pathname)}catch{return!1}}),r=s?new URL("../",new URL(s.src,document.baseURI)):i;n.p!==r.href&&(n.p=r.href)})()},"987c832cfe13"(){window.SF=window.SF||{},SF.RuleLoader={}},"3a00b12d226d"(e,t,n){"use strict";function o(e){if(!e||"[object Object]"!==Object.prototype.toString.call(e))return!1;const t=Object.getPrototypeOf(e);return t===Object.prototype||null===t}function i(e){return Array.isArray(e)?e.map(i):o(e)?Object.fromEntries(Object.keys(e).sort().map(t=>[t,i(e[t])])):e}function s(e){return JSON.stringify(i(e))}n.d(t,{normalize:()=>sn});const r=Object.freeze(["banner","navigation","main","complementary","contentinfo","region","none"]),a=Object.freeze(["block","start","center","end"]),l=Object.freeze(["layout","content","smart"]),c=Object.freeze({maxRegionsPerLayout:12,maxRegionLayoutNesting:4}),u=Object.freeze({banner:"header",navigation:"nav",main:"main",complementary:"aside",contentinfo:"footer",region:"section",none:"div"}),d=new Set(["banner","main","contentinfo"]),f={start:0,center:1,end:2},p=(e,t,n)=>({code:e,path:t,message:n});function m(e){return"layout.region"===e?.type&&"string"==typeof e.props?.landmark?e.props.landmark:null}function h(e,t,n){const i=new Map,s=(e,r,a)=>{if(!o(e))return;"layout.region"===e.type&&"layout.regions"!==a.parentType&&n.push(p("region_parent_invalid",r,"layout.region must be a direct child of layout.regions"));let l={...a,parentType:e.type};if("layout.page"===e.type&&(l.insidePage=!0),"layout.regions"===e.type&&(l.regionDepth=a.regionDepth+1,l.regionDepth>c.maxRegionLayoutNesting&&n.push(p("region_nesting_limit",r,"Region layouts are nested too deeply")),function(e,t,n){const o=Array.isArray(e.slots?.regions)?e.slots.regions:[],i=new Set;let s=-1;o.forEach((e,o)=>{const r=`${t}.slots.regions[${o}]`;if("layout.region"!==e?.type)return;const a=e.props?.name;"string"==typeof a&&(i.has(a)&&n.push(p("region_name_duplicate",`${r}.props.name`,`Region ${a} is declared twice in one layout`)),i.add(a));const l=e.props?.placement??"block";if("block"===l)return void(s=-1);const c=f[l];void 0!==c&&(c<s&&n.push(p("region_order_invalid",`${r}.props.placement`,"Side-by-side regions must be declared in start, center, end order")),s=Math.max(s,c))})}(e,r,n)),"layout.region"===e.type){!function(e,t,n,i){const s=o(e.props)?e.props:{},r=m(e);r&&d.has(r)&&(n.insideLandmark||n.insidePage)&&i.push(p("region_landmark_context",`${t}.props.landmark`,`${r} is only allowed outside other landmarks and layout.page`)),"region"===r&&void 0===s.label&&i.push(p("region_label_required",`${t}.props.label`,"A region landmark requires an accessible label")),"none"===r&&void 0!==s.label&&i.push(p("region_label_forbidden",`${t}.props.label`,"A region without a landmark cannot carry an accessible label"));const a=Array.isArray(e.slots?.default)?e.slots.default:[],l=Number.isInteger(s.min_items)?s.min_items:0,c=Number.isInteger(s.max_items)?s.max_items:500;if(l>c?i.push(p("region_bounds_invalid",`${t}.props`,"min_items must not exceed max_items")):(a.length<l||a.length>c)&&i.push(p("region_cardinality",`${t}.slots.default`,"Region child count is outside its declared range")),Array.isArray(s.accepts)){const e=new Set(s.accepts);a.forEach((o,s)=>{const r=n.registry.types.get(o?.type);r&&!e.has(r.category)&&i.push(p("region_child_category_forbidden",`${t}.slots.default[${s}]`,`${r.category} is not accepted by this region`))})}}(e,r,{...a,registry:t},n);const s=m(e);s&&"none"!==s&&(i.has(s)||i.set(s,[]),i.get(s).push({path:r,label:e.props?.label}),l={...l,insideLandmark:!0})}for(const[t,n]of Object.entries(o(e.slots)?e.slots:{}))Array.isArray(n)&&n.forEach((e,n)=>s(e,`${r}.slots.${t}[${n}]`,l))};s(e,"$.root",{parentType:null,insidePage:!1,insideLandmark:!1,regionDepth:0});for(const[e,t]of i){if("main"===e&&t.length>1){for(const e of t.slice(1))n.push(p("region_landmark_duplicate",`${e.path}.props.landmark`,"A document can contain only one main region"));continue}if(t.length<2)continue;const o=new Set;for(const i of t)void 0!==i.label?o.has(i.label)?n.push(p("region_label_duplicate",`${i.path}.props.label`,`Repeated ${e} regions require distinct labels`)):o.add(i.label):"region"!==e&&n.push(p("region_label_required",`${i.path}.props.label`,`Repeated ${e} regions require distinct labels`))}}async function g(e){const t=(new globalThis.TextEncoder).encode(e),n=await globalThis.crypto.subtle.digest("SHA-256",t);return[...new Uint8Array(n)].map(e=>e.toString(16).padStart(2,"0")).join("")}async function y(e){const t=[],n=async(e,r,a)=>{if(!o(e))return;if("layout.region"===e.type&&a){const n=e.props||{};t.push({layout:a,node:e.id,name:n.name,landmark:n.landmark,placement:n.placement??"block",path:r,digest:`sha256:${await g(s(i(e)))}`})}const l="layout.regions"===e.type?e.id:null;for(const[t,i]of Object.entries(o(e.slots)?e.slots:{}))if(Array.isArray(i))for(let e=0;e<i.length;e+=1)await n(i[e],`${r}.slots.${t}[${e}]`,l)};return await n(e?.root,"$.root",null),t}var b=n("ac24888e7d3e");const w={type:"array",items:{oneOf:[{type:"object",required:["type","value"],additionalProperties:!1,properties:{type:{const:"text"},value:{type:"string",maxLength:1e5},marks:{type:"array",uniqueItems:!0,items:{enum:["strong","em","code"]}}}},{type:"object",required:["type","href","children"],additionalProperties:!1,properties:{type:{const:"link"},href:{type:"string",minLength:1,maxLength:2048},children:{type:"array",minItems:1,items:{type:"object",required:["type","value"],additionalProperties:!1,properties:{type:{const:"text"},value:{type:"string",maxLength:1e5},marks:{type:"array",uniqueItems:!0,items:{enum:["strong","em","code"]}}}}}}}]}},v={type:"object",required:["endpoint","port"],additionalProperties:!1,properties:{endpoint:{type:"string",pattern:"^[a-z][a-z0-9-]{0,31}$"},port:{type:"string",pattern:"^[a-z][a-z0-9-]{0,31}$"}}},_={type:"object",additionalProperties:!1,properties:{}},x=Object.freeze([{...(0,b.xZ)("simai.composition.type-manifest",1),type:"layout.page",version:"1.0.0",category:"layout",mode:"composite",profiles:["ui-layout"],data_schema:_,props_schema:_,presentation:{views:["default"],presets:[],modifiers:[]},slots:{default:{min:0,max:500,categories:["layout","content","smart"]}},renderer:{kind:"builtin",name:"layout.page"},assets:[],capabilities:["html"]},{...(0,b.xZ)("simai.composition.type-manifest",1),type:"layout.section",version:"1.0.0",category:"layout",mode:"composite",profiles:["ui-layout"],data_schema:_,props_schema:_,presentation:{views:["default"],presets:["surface","contrast"],modifiers:["contained","spacious"]},slots:{default:{min:0,max:500,categories:["layout","content","smart"]}},renderer:{kind:"builtin",name:"layout.section"},assets:[],capabilities:["html"]},{...(0,b.xZ)("simai.composition.type-manifest",1),type:"layout.columns",version:"1.0.0",category:"layout",mode:"composite",profiles:["ui-layout"],data_schema:_,props_schema:{type:"object",additionalProperties:!1,properties:{columns:{type:"integer",minimum:1,maximum:12}}},presentation:{views:["default"],presets:[],modifiers:["equal","responsive"]},slots:{columns:{min:1,max:12,categories:["layout","content","smart"]}},renderer:{kind:"builtin",name:"layout.columns"},assets:["composition/layout"],capabilities:["html"]},{...(0,b.xZ)("simai.composition.type-manifest",1),type:"content.heading",version:"1.0.0",category:"content",mode:"leaf",profiles:["ui-layout","structured-content"],data_schema:{type:"object",required:["content"],additionalProperties:!1,properties:{level:{type:"integer",minimum:1,maximum:6},content:w}},props_schema:_,presentation:{views:["default"],presets:[],modifiers:[]},slots:{},renderer:{kind:"builtin",name:"content.heading"},assets:[],capabilities:["html","rich-text"]},{...(0,b.xZ)("simai.composition.type-manifest",1),type:"content.paragraph",version:"1.0.0",category:"content",mode:"leaf",profiles:["ui-layout","structured-content"],data_schema:{type:"object",required:["content"],additionalProperties:!1,properties:{content:w}},props_schema:_,presentation:{views:["default"],presets:[],modifiers:["lead","muted"]},slots:{},renderer:{kind:"builtin",name:"content.paragraph"},assets:[],capabilities:["html","rich-text"]},{...(0,b.xZ)("simai.composition.type-manifest",1),type:"layout.regions",version:"1.0.0",category:"layout",mode:"composite",profiles:["ui-layout"],data_schema:_,props_schema:_,presentation:{views:["default"],presets:[],modifiers:[]},slots:{regions:{min:1,max:12,types:["layout.region"]}},renderer:{kind:"builtin",name:"layout.regions"},assets:[],capabilities:["html","regions"]},{...(0,b.xZ)("simai.composition.type-manifest",1),type:"layout.region",version:"1.0.0",category:"layout",mode:"composite",profiles:["ui-layout"],data_schema:_,props_schema:{type:"object",required:["name","landmark"],additionalProperties:!1,properties:{name:{type:"string",pattern:"^[a-z][a-z0-9-]{0,31}$"},landmark:{enum:[...r]},placement:{enum:[...a]},label:{type:"string",minLength:1,maxLength:120},sticky:{type:"boolean"},accepts:{type:"array",minItems:1,uniqueItems:!0,items:{enum:[...l]}},min_items:{type:"integer",minimum:0,maximum:500},max_items:{type:"integer",minimum:0,maximum:500}}},presentation:{views:["default"],presets:[],modifiers:[]},slots:{default:{min:0,max:500,categories:["layout","content","smart"]}},renderer:{kind:"builtin",name:"layout.region"},assets:[],capabilities:["html","regions"]},{...(0,b.xZ)("simai.composition.type-manifest",1),type:"layout.scope",version:"1.0.0",category:"layout",mode:"composite",profiles:["ui-layout"],data_schema:_,props_schema:{type:"object",required:["routes"],additionalProperties:!1,properties:{routes:{type:"array",minItems:1,maxItems:32,items:{type:"object",required:["id","from","to"],additionalProperties:!1,properties:{id:{type:"string",pattern:"^[a-z][a-z0-9-]{0,63}$"},from:v,to:v}}}}},presentation:{views:["default"],presets:[],modifiers:[]},slots:{default:{min:1,max:500,categories:["layout","content","smart"]}},renderer:{kind:"builtin",name:"layout.scope"},assets:[],capabilities:["html","hydration","routing"]}]),$=Object.freeze([{...(0,b.xZ)("simai.composition.port-manifest",1),element:"sf-table",version:"1.0.0",component:"smart.data-view",component_version:"1.2.0",outputs:{selection:{value:"record-ids.v1",summary:"Explicit current-result selection of this instance, emitted once per change, including clearing."}},inputs:{context:{value:"record-ids.v1",effect:"request",summary:"Restricts this collection to records related to the given identities. The table clears its selection, enters loading and emits sf-table-query-intent with the route sequence; the host resolves the relation and access and answers with applyQueryResult.",request_event:"sf-table-query-intent",result_method:"applyQueryResult"}}}]),k=Object.freeze([{...(0,b.xZ)("simai.composition.editor-manifest",1),type:"layout.section",type_version:"1.0.0",fields:[{key:"surface",plane:"presentation",target:"preset",property:{type:"string",version:2},constraints:{min_length:1,max_length:32},group:"preset",visibility:"visible",choices:["surface","contrast"],default:"surface",label_key:"sf.composition.layout_section.surface",help_key:"sf.composition.layout_section.surface_help",capability_hints:["composition.presentation.preset"],permission_hints:["composition.node.update"],owner:"simai/framework"}]},{...(0,b.xZ)("simai.composition.editor-manifest",1),type:"layout.columns",type_version:"1.0.0",fields:[{key:"columns",plane:"props",target:"columns",property:{type:"integer",version:1},constraints:{min:1,max:12},group:"basic",visibility:"visible",default:2,label_key:"sf.composition.layout_columns.columns",help_key:"sf.composition.layout_columns.columns_help",capability_hints:["composition.props.columns"],permission_hints:["composition.node.update"],owner:"simai/framework"}]},{...(0,b.xZ)("simai.composition.editor-manifest",1),type:"content.heading",type_version:"1.0.0",fields:[{key:"level",plane:"data",target:"level",property:{type:"integer",version:1},constraints:{min:1,max:6},group:"advanced",visibility:"collapsed",default:2,label_key:"sf.composition.content_heading.level",help_key:"sf.composition.content_heading.level_help",capability_hints:["composition.data.level"],permission_hints:["composition.node.update"],owner:"simai/framework"}]},{...(0,b.xZ)("simai.composition.editor-manifest",1),type:"layout.region",type_version:"1.0.0",fields:[{key:"placement",plane:"props",target:"placement",property:{type:"string",version:2},constraints:{min_length:1,max_length:16},group:"basic",visibility:"visible",choices:[...a],default:"block",label_key:"sf.composition.layout_region.placement",help_key:"sf.composition.layout_region.placement_help",capability_hints:["composition.props.placement"],permission_hints:["composition.node.update"],owner:"simai/framework"},{key:"label",plane:"props",target:"label",property:{type:"string",version:2},constraints:{min_length:1,max_length:120},group:"basic",visibility:"visible",label_key:"sf.composition.layout_region.label",help_key:"sf.composition.layout_region.label_help",capability_hints:["composition.props.label"],permission_hints:["composition.node.update"],owner:"simai/framework"},{key:"landmark",plane:"props",target:"landmark",property:{type:"string",version:2},constraints:{min_length:1,max_length:16},group:"advanced",visibility:"collapsed",choices:[...r],label_key:"sf.composition.layout_region.landmark",help_key:"sf.composition.layout_region.landmark_help",capability_hints:["composition.props.landmark"],permission_hints:["composition.node.update"],owner:"simai/framework"},{key:"sticky",plane:"props",target:"sticky",property:{type:"boolean",version:1},constraints:{},group:"advanced",visibility:"collapsed",default:!1,label_key:"sf.composition.layout_region.sticky",help_key:"sf.composition.layout_region.sticky_help",capability_hints:["composition.props.sticky"],permission_hints:["composition.node.update"],owner:"simai/framework"}]}]),S=new Set(["schema","schema_version","type","type_version","applies_to","fields"]),E=new Set(["views","presets","modifiers"]),O=new Set(["key","plane","target","property","constraints","group","visibility","choices","default","label_key","help_key","capability_hints","permission_hints","owner"]),T=new Set(["type","version"]),j=new Set(["props","data","presentation"]),A=new Set(["preset","basic","advanced"]),L=new Set(["visible","collapsed","hidden"]),P=new Set(["view","preset"]),z=new Set(["actor","authorization","class","classname","cookie","endpoint","eval","expression","function","handler","html","innerhtml","javascript","method","password","php","query","request","script","secret","sql","token"]),R=(e,t,n)=>({code:e,path:t,message:n}),C=e=>"string"==typeof e&&/^[a-z][a-z0-9_]*(?:\.[a-z][a-z0-9_]*)*$/u.test(e),F=e=>null===e||"string"==typeof e||"boolean"==typeof e||"number"==typeof e&&Number.isFinite(e),N=e=>"string"==typeof e&&e.split(".").some(e=>z.has(e.toLowerCase().replaceAll("-","").replaceAll("_","")));function I(e,t,n,i){if(o(e))for(const o of Object.keys(e))t.has(o)||i.push(R("editor_unknown_field",`${n}.${o}`,`Unknown editor field ${o}`))}function M(e,t,n){if(Array.isArray(e))e.forEach((e,o)=>M(e,`${t}[${o}]`,n));else if(o(e))for(const[o,i]of Object.entries(e)){const e=o.toLowerCase().replaceAll("-","").replaceAll("_","");z.has(e)&&n.push(R("editor_executable_or_secret_field_forbidden",`${t}.${o}`,`Field ${o} is not portable editor metadata`)),M(i,`${t}.${o}`,n)}}function q(e,t,n){void 0!==e&&(!Array.isArray(e)||e.length>50||e.some(e=>!C(e))||new Set(e).size!==e.length)&&n.push(R("editor_hint_list_invalid",t,"Hints must be a bounded unique stable-key list"))}function D(e,t,n={}){const i=[];if(!o(e))return{valid:!1,diagnostics:[R("editor_manifest_invalid","$","Editor manifest must be an object")]};var r;if(I(e,S,"$",i),M(e,"$",i),(0,b.Wl)(e,"simai.composition.editor-manifest",1)||i.push(R("editor_schema_unknown","$.schema","Expected simai.composition.editor-manifest.v1, or simai.composition.editor-manifest with schema_version 1")),"string"==typeof(r=e.type)&&/^[a-z][a-z0-9-]*(?:\.[a-z][a-z0-9-]*)+$/u.test(r)||i.push(R("editor_type_invalid","$.type","Component type is invalid")),(e=>"string"==typeof e&&/^[0-9]+\.[0-9]+\.[0-9]+$/u.test(e))(e.type_version)||i.push(R("editor_type_version_invalid","$.type_version","Component type version is invalid")),o(t)&&t.type===e.type&&t.version===e.type_version||i.push(R("editor_type_registration_mismatch","$.type","Editor manifest must bind one exact registered type revision")),function(e,t,n){if(void 0!==e)if(o(e)){I(e,E,"$.applies_to",n);for(const[o,i]of[["views","views"],["presets","presets"],["modifiers","modifiers"]]){if(void 0===e[o])continue;if(!Array.isArray(e[o])||0===e[o].length||e[o].some(e=>"string"!=typeof e)||new Set(e[o]).size!==e[o].length){n.push(R("editor_applies_to_invalid",`$.applies_to.${o}`,`${o} must be a non-empty unique string list`));continue}const s=new Set(t.presentation?.[i]||[]);for(const t of e[o])s.has(t)||n.push(R("editor_presentation_choice_unknown",`$.applies_to.${o}`,`${t} is not registered by the type manifest`))}}else n.push(R("editor_applies_to_invalid","$.applies_to","applies_to must be an object"))}(e.applies_to,t||{},i),!Array.isArray(e.fields)||e.fields.length>200)return i.push(R("editor_fields_invalid","$.fields","fields must be a bounded array")),{valid:!1,diagnostics:i};const a=new Set,l=new Set,c=function(e){if(void 0===e)return null;const t=new Set;for(const n of e)"string"==typeof n?t.add(n):o(n)&&t.add(`${n.type}@${n.version}`);return t}(n.propertyTypes);return e.fields.forEach((e,n)=>{const r=`$.fields[${n}]`;if(!o(e))return void i.push(R("editor_field_invalid",r,"Editor field must be an object"));I(e,O,r,i),C(e.key)?a.has(e.key)?i.push(R("editor_field_key_duplicate",`${r}.key`,`Duplicate field key ${e.key}`)):a.add(e.key):i.push(R("editor_field_key_invalid",`${r}.key`,"Field key must be stable")),j.has(e.plane)||i.push(R("editor_plane_unknown",`${r}.plane`,"Field plane is unknown")),C(e.target)||i.push(R("editor_target_invalid",`${r}.target`,"Field target must be stable")),N(e.key)&&i.push(R("editor_executable_or_secret_field_forbidden",`${r}.key`,"Field key names executable or secret data")),N(e.target)&&i.push(R("editor_executable_or_secret_field_forbidden",`${r}.target`,"Field target names executable or secret data"));const u=`${e.plane}.${e.target}`;if(l.has(u)?i.push(R("editor_destination_duplicate",`${r}.target`,`Duplicate destination ${u}`)):l.add(u),A.has(e.group)||i.push(R("editor_group_unknown",`${r}.group`,"Field group is unknown")),L.has(e.visibility)||i.push(R("editor_visibility_unknown",`${r}.visibility`,"Field visibility is unknown")),C(e.label_key)||i.push(R("editor_label_key_invalid",`${r}.label_key`,"Localization key must be stable")),void 0===e.help_key||C(e.help_key)||i.push(R("editor_help_key_invalid",`${r}.help_key`,"Help localization key must be stable")),q(e.capability_hints,`${r}.capability_hints`,i),q(e.permission_hints,`${r}.permission_hints`,i),(e=>"string"==typeof e&&/^[a-z][a-z0-9.-]*\/[a-z][a-z0-9.-]*$/u.test(e))(e.owner)||i.push(R("editor_owner_invalid",`${r}.owner`,"Owner must be a portable owner id")),o(e.constraints)||i.push(R("editor_constraints_invalid",`${r}.constraints`,"Constraints must be an object")),o(e.property)?(I(e.property,T,`${r}.property`,i),C(e.property.type)||i.push(R("editor_property_type_invalid",`${r}.property.type`,"Property type must be stable")),(!Number.isInteger(e.property.version)||e.property.version<1)&&i.push(R("editor_property_version_invalid",`${r}.property.version`,"Property version must be positive")),c&&!c.has(`${e.property.type}@${e.property.version}`)&&i.push(R("editor_property_registration_unknown",`${r}.property`,"Property type and version are not registered by the host"))):i.push(R("editor_property_invalid",`${r}.property`,"Property identity must be an object")),void 0!==e.choices&&(!Array.isArray(e.choices)||0===e.choices.length||e.choices.length>200||e.choices.some(e=>!F(e))||new Set(e.choices.map(s)).size!==e.choices.length)&&i.push(R("editor_choices_invalid",`${r}.choices`,"Choices must be a bounded unique scalar list")),"default"in e&&!F(e.default)&&i.push(R("editor_default_invalid",`${r}.default`,"Default must be scalar")),"default"in e&&Array.isArray(e.choices)&&!e.choices.some(t=>s(t)===s(e.default))&&i.push(R("editor_default_choice_unknown",`${r}.default`,"Default must be one of the allowed choices")),"presentation"===e.plane){P.has(e.target)||i.push(R("editor_presentation_target_unsupported",`${r}.target`,"Only view and preset are scalar editable presentation targets"));const n=new Set(function(e,t){return"view"===t?e.presentation?.views||[]:"preset"===t&&e.presentation?.presets||[]}(t||{},e.target));for(const t of e.choices||[])"string"==typeof t&&n.has(t)||i.push(R("editor_presentation_choice_unknown",`${r}.choices`,`${String(t)} is not registered by the type manifest`))}else if(j.has(e.plane)&&o(t)){const n="props"===e.plane?t.props_schema:t.data_schema;o(n?.properties)&&e.target in n.properties||i.push(R("editor_destination_unknown",`${r}.target`,`${u} is not declared by the type manifest`))}}),{valid:0===i.length,diagnostics:i}}function B(e,t,n,r={}){const a=D(e,t,r);if(!a.valid)return{valid:!1,fields:[],diagnostics:a.diagnostics};const l=[],c=e.fields.map(e=>{const t=function(e,t){const n=e?.[t.plane];return o(n)&&t.target in n?{value:n[t.target],source:"node"}:"default"in t?{value:t.default,source:"default"}:{value:null,source:"unset"}}(n,e);return"unset"!==t.source&&e.choices&&!e.choices.some(e=>s(e)===s(t.value))&&l.push(R("editor_choice_unknown",`node:${n?.id||""}.${e.plane}.${e.target}`,"Current value is not an allowed choice")),i({...e,destination:`${e.plane}.${e.target}`,...t})});return{valid:0===l.length,fields:c,diagnostics:l}}function U(e,t,n,o={}){const i=new Map;for(const e of n||[]){const t=`${e.type}@${e.type_version}`;if(i.has(t))return{valid:!1,instances:[],diagnostics:[R("editor_manifest_duplicate","$",`Duplicate editor manifest ${t}`)]};i.set(t,e)}const s=[],r=[],a=e=>{const n=t?.types instanceof Map?t.types.get(e.type):void 0;if(n){const t=i.get(`${n.type}@${n.version}`);if(t){const i=B(t,n,e,o);r.push(...i.diagnostics.map(t=>({...t,instance:e.id}))),s.push({id:e.id,type:e.type,fields:i.fields})}}for(const t of Object.values(e.slots||{}))for(const e of t)a(e)};return e?.root&&a(e.root),{valid:0===r.length,instances:s,diagnostics:r}}const W=/^[a-z][a-z0-9_]*$/u,H=/^-?(?:0|[1-9][0-9]*)$/u,V=Object.freeze([{...(0,b.xZ)("simai.composition.editor-field-kind",1),kind:"choice",version:1,status:"formalized-existing",match:{property:[{type:"string",version:1},{type:"string",version:2}],choices:"required"},value_schema:{type:"string",minLength:1},default:{kind:null,field:"must-be-a-choice"},constraints:{allowed:["min_length","max_length"]},normalization:{form:"exact-string",unset:"absent-field",stored:"value"},validation:["choice-member"],accessibility:{control:"select",role:"combobox",name:"label_key",description:"help_key via aria-describedby",keyboard:["Tab","ArrowUp","ArrowDown","Enter","Space","Escape"]},themes:{modes:["light","dark"],tokens:["--sf-surface-1","--sf-on-surface","--sf-outline","--sf-primary"],contrast:"WCAG 2.2 AA"},localization:{label:"label_key",help:"help_key",value_labels:"<label_key>.<choice> when the choice is a stable segment, otherwise the raw choice",direction:"logical"},server_fallback:{element:"select",value:"option value",enhanced_control:"sf-dropdown"}},{...(0,b.xZ)("simai.composition.editor-field-kind",1),kind:"integer",version:1,status:"formalized-existing",match:{property:[{type:"integer",version:1}],choices:"forbidden"},value_schema:{type:"integer",minimum:-9007199254740991,maximum:9007199254740991},default:{kind:null,field:"must-satisfy-constraints"},constraints:{allowed:["min","max"],required:["min","max"]},normalization:{form:"decimal-integer-text",unset:"empty-text",stored:"safe-integer"},validation:["integer-text","range"],accessibility:{control:"input[type=number]",role:"spinbutton",name:"label_key",description:"help_key via aria-describedby",keyboard:["Tab","ArrowUp","ArrowDown","digits"]},themes:{modes:["light","dark"],tokens:["--sf-surface-1","--sf-on-surface","--sf-outline","--sf-primary"],contrast:"WCAG 2.2 AA"},localization:{label:"label_key",help:"help_key",value_labels:"none",direction:"logical",digits:"ASCII decimal"},server_fallback:{element:"input",type:"number",attributes:["min","max","step=1","inputmode=numeric"],enhanced_control:"sf-input"}},{...(0,b.xZ)("simai.composition.editor-field-kind",1),kind:"text",version:1,status:"new",match:{property:[{type:"string",version:2}],choices:"forbidden"},value_schema:{type:"string",minLength:1,maxLength:2e3},default:{kind:null,field:"must-satisfy-constraints"},constraints:{allowed:["min_length","max_length"],required:["max_length"]},normalization:{form:"exact-string-no-trim-no-unicode-normalization",unset:"empty-text",stored:"value"},validation:["code-point-length","no-control-characters","well-formed-unicode"],accessibility:{control:"input[type=text]",role:"textbox",name:"label_key",description:"help_key via aria-describedby",keyboard:["Tab","text entry"],attributes:["dir=auto","maxlength"]},themes:{modes:["light","dark"],tokens:["--sf-surface-1","--sf-on-surface","--sf-outline","--sf-primary"],contrast:"WCAG 2.2 AA"},localization:{label:"label_key",help:"help_key",value_labels:"none",direction:"dir=auto per value; value is author content in the Document locale"},server_fallback:{element:"input",type:"text",attributes:["maxlength","dir=auto"],enhanced_control:"sf-input"}},{...(0,b.xZ)("simai.composition.editor-field-kind",1),kind:"toggle",version:1,status:"new",match:{property:[{type:"boolean",version:1}],choices:"forbidden"},value_schema:{type:"boolean"},default:{kind:!1,field:"false-or-absent"},constraints:{allowed:[]},normalization:{form:"present-true-absent-false",unset:"false",stored:"true only; false removes the key"},validation:["strict-boolean"],accessibility:{control:"input[type=checkbox][role=switch]",role:"switch",name:"label_key",description:"help_key via aria-describedby",keyboard:["Tab","Space"],states:["checked"]},themes:{modes:["light","dark"],tokens:["--sf-surface-1","--sf-on-surface","--sf-outline","--sf-primary"],contrast:"WCAG 2.2 AA"},localization:{label:"label_key",help:"help_key",value_labels:"none",direction:"logical"},server_fallback:{element:"input",type:"checkbox",attributes:["role=switch","value=true"],enhanced_control:"sf-switch"}}]),Z=(e,t,n)=>({code:e,path:t,message:n});function J(e){return[...e].length}function G(e,t=V){if(!o(e?.property))return null;const n=Array.isArray(e.choices),i=t.filter(t=>t.match.property.some(t=>t.type===e.property.type&&t.version===e.property.version)&&("required"===t.match.choices?n:!n));return 1===i.length?i[0]:null}function X(e,t,n="$"){const i=G(e);if(!i)return[Z("field_kind_unknown",n,"The field does not map to exactly one published kind")];const s=o(e.constraints)?e.constraints:{},r=[];if("choice"===i.kind)"string"==typeof t&&e.choices.includes(t)||r.push(Z("field_value_choice",n,"Value is not an allowed choice"));else if("integer"===i.kind)Number.isSafeInteger(t)?(Number.isInteger(s.min)&&t<s.min||Number.isInteger(s.max)&&t>s.max)&&r.push(Z("field_value_range",n,"Value is outside the allowed range")):r.push(Z("field_value_type",n,"Value must be a safe integer"));else if("text"===i.kind)if("string"!=typeof t)r.push(Z("field_value_type",n,"Value must be a string"));else if(function(e){for(let t=0;t<e.length;t+=1){const n=e.charCodeAt(t);if(n>=55296&&n<=56319){const n=e.charCodeAt(t+1);if(!(n>=56320&&n<=57343))return!1;t+=1}else if(n>=56320&&n<=57343)return!1}return!0}(t))if(function(e){for(let t=0;t<e.length;t+=1){const n=e.charCodeAt(t);if(n<32||127===n)return!0}return!1}(t))r.push(Z("field_value_control",n,"Value cannot contain control characters"));else{const e=J(t),o=Math.max(1,Number.isInteger(s.min_length)?s.min_length:1),i=Math.min(2e3,Number.isInteger(s.max_length)?s.max_length:2e3);(e<o||e>i)&&r.push(Z("field_value_length",n,"Value length is outside the allowed range"))}else r.push(Z("field_value_unicode",n,"Value must be well-formed Unicode"));else"toggle"===i.kind&&"boolean"!=typeof t&&r.push(Z("field_value_type",n,"Value must be a boolean"));return r}function Y(e){const t=[];return(Array.isArray(e?.fields)?e.fields:[]).forEach((e,n)=>{const i=`$.fields[${n}]`,s=G(e);if(!s)return void t.push(Z("field_kind_unknown",i,"The field does not map to exactly one published kind"));const r=o(e.constraints)?e.constraints:{};for(const e of Object.keys(r))s.constraints.allowed.includes(e)||t.push(Z("field_constraint_unknown",`${i}.constraints.${e}`,`${e} is not a ${s.kind} constraint`));for(const e of s.constraints.required||[])Number.isInteger(r[e])||t.push(Z("field_constraint_required",`${i}.constraints.${e}`,`${s.kind} requires ${e}`));if("choice"===s.kind){const n=Number.isInteger(r.min_length)?r.min_length:0,o=Number.isInteger(r.max_length)?r.max_length:1/0;n>o&&t.push(Z("field_constraint_invalid",`${i}.constraints`,"min_length must not exceed max_length"));for(const s of e.choices)("string"!=typeof s||J(s)<n||J(s)>o)&&t.push(Z("field_choice_invalid",`${i}.choices`,`${String(s)} violates the choice constraints`))}"integer"===s.kind&&Number.isInteger(r.min)&&Number.isInteger(r.max)&&r.min>r.max&&t.push(Z("field_constraint_invalid",`${i}.constraints`,"min must not exceed max")),"text"===s.kind&&Number.isInteger(r.min_length)&&Number.isInteger(r.max_length)&&r.min_length>r.max_length&&t.push(Z("field_constraint_invalid",`${i}.constraints`,"min_length must not exceed max_length")),"toggle"===s.kind&&"default"in e&&!1!==e.default&&t.push(Z("field_default_invalid",`${i}.default`,"A toggle default must be false or absent")),"toggle"!==s.kind&&"default"in e&&t.push(...X(e,e.default,`${i}.default`).map(e=>({...e,code:"field_default_invalid"})))}),t}function K(e,t){const n=G(e);if(!n)return{error:Z("field_kind_unknown","$","The field does not map to exactly one published kind")};if(null!==t&&"string"!=typeof t)return{error:Z("field_submission_invalid","$","A submission must be a string or absent")};let o;if("toggle"===n.kind)return null!==t&&"true"!==t?{error:Z("field_submission_invalid","$","A toggle submits only true")}:"true"===t?{value:!0}:{unset:!0};if(null===t||""===t)return{unset:!0};if("integer"===n.kind){if(!H.test(t))return{error:Z("field_value_type","$","Value must be a decimal integer")};o=Number(t)}else o=t;const i=X(e,o);return i.length?{error:i[0]}:{value:o}}function Q(e,t,n){if(!o(n)||n.error||!0!==n.unset&&!("value"in n))throw new TypeError("applyFieldValue requires a successful parseFieldSubmission result");const s=i(JSON.parse(JSON.stringify(e))),r=o(s[t.plane])?{...s[t.plane]}:{};return n.unset||"toggle"===G(t)?.kind&&!1===n.value?delete r[t.target]:r[t.target]=n.value,Object.keys(r).length?s[t.plane]=r:delete s[t.plane],i(s)}function ee(e){return String(e).replaceAll("&","&amp;").replaceAll("<","&lt;").replaceAll(">","&gt;").replaceAll('"',"&quot;").replaceAll("'","&#39;")}function te(e,{instance:t,messages:n={}}={}){const o=G(e);if(!o)throw new TypeError("field_kind_unknown");if("hidden"===e.visibility)return"";const i=function(e,t){return`sf-field-${e}-${t.key}`.replace(/[^A-Za-z0-9_-]/gu,"-")}(t,e),s=ee(`${t}.${e.plane}.${e.target}`),r=ee(n[e.label_key]??e.label_key),a=e.help_key?`${i}-help`:null,l=a?` aria-describedby="${a}"`:"",c=a?`<small class="sf-editor-field-help" id="${a}">${ee(n[e.help_key]??e.help_key)}</small>`:"",u=e.value??e.default??null,d=e.constraints||{};let f;if("toggle"===o.kind)f=`<input class="sf-editor-field-control" type="checkbox" role="switch" id="${i}" name="${s}" value="true"${!0===u?" checked":""}${l}><label for="${i}">${r}</label>`;else if("choice"===o.kind){const t=e.choices.map(t=>{const o=W.test(t)?n[`${e.label_key}.${t}`]??t:t;return`<option value="${ee(t)}"${t===u?" selected":""}>${ee(o)}</option>`}).join("");f=`<label for="${i}">${r}</label><select class="sf-editor-field-control" id="${i}" name="${s}"${l}>${null===u?'<option value="" selected></option>':""}${t}</select>`}else if("integer"===o.kind){f=`<label for="${i}">${r}</label><input class="sf-editor-field-control" type="number" inputmode="numeric" step="1"${`${Number.isInteger(d.min)?` min="${d.min}"`:""}${Number.isInteger(d.max)?` max="${d.max}"`:""}`} id="${i}" name="${s}" value="${null===u?"":ee(u)}"${l}>`}else{f=`<label for="${i}">${r}</label><input class="sf-editor-field-control" type="text" dir="auto" maxlength="${Math.min(2e3,Number.isInteger(d.max_length)?d.max_length:2e3)}" id="${i}" name="${s}" value="${null===u?"":ee(u)}"${l}>`}const p=`<div class="sf-editor-field" data-sf-field-kind="${o.kind}" data-sf-field-group="${ee(e.group)}">${f}${c}</div>`;return"collapsed"===e.visibility?`<details class="sf-editor-field-disclosure"><summary>${r}</summary>${p}</details>`:p}const ne="simai.recipe.canonical-json.v1",oe=new Set([ne,"simai.recipe.canonical-json"]);function ie(e,t){return"name"===(0,b.G7)(e)?.form?(0,b.xZ)(t,1):{schema:`${t}.v1`}}const se=e=>ie(e,"simai.composition.document"),re=Object.freeze({maxRecipeBytes:1048576,maxSourceBytes:1048576,maxTotalSourceBytes:8388608,maxInputBytes:1048576,maxTotalInputBytes:4194304,maxUniqueReferences:128,maxInputs:256,maxReferenceDepth:16,maxExpansionSteps:1e4,maxIntermediateBytes:4194304,maxOutputBytes:1048576,maxOutputNodes:2e3,maxOutputDepth:32,maxChildrenPerSlot:500,maxSelectCases:64}),ae=re,le={node:new Set(["id","node"]),ref:new Set(["id","ref","params","slots","extensions"]),select:new Set(["id","select"]),insertSlot:new Set(["id","insertSlot"])},ce=new Set(["type","data","props","presentation","slots","bindings","extensions"]),ue=new Set(["schema","schema_version","id","profile","locale","inputs","root","extensions"]),de=new Set(["schema","schema_version","scope","values","extensions"]),fe=new Set(["schema","schema_version","id","parameters","slots","body","extensions"]),pe=new Set(["kind","schema","default","expectedOrigin","extensions"]),me=/^[A-Za-z0-9][A-Za-z0-9._:-]{0,119}$/u;function he(e){if(!e||"[object Object]"!==Object.prototype.toString.call(e))return!1;const t=Object.getPrototypeOf(e);return t===Object.prototype||null===t}function ge(e){return JSON.parse(JSON.stringify(e))}function ye(e){return(new globalThis.TextEncoder).encode("string"==typeof e?e:JSON.stringify(e)).byteLength}function be(e){if("string"!=typeof e||65279===e.charCodeAt(0))throw Object.assign(new SyntaxError("Invalid JSON input"),{code:"invalid_json",sourcePath:"$"});let t=0;const n=()=>{for(;/\s/u.test(e[t]||"")&&![" "].includes(e[t]);)t+=1},o=()=>{if('"'!==e[t])throw new SyntaxError("Expected string");const n=t++;for(;t<e.length;){const o=e.charCodeAt(t);if(34===o){t+=1;const o=JSON.parse(e.slice(n,t));for(let e=0;e<o.length;e+=1){const t=o.charCodeAt(e);if(t>=55296&&t<=56319){const t=o.charCodeAt(e+1);if(!(t>=56320&&t<=57343))throw new SyntaxError("Unpaired surrogate");e+=1}else if(t>=56320&&t<=57343)throw new SyntaxError("Unpaired surrogate")}return o}if(o<32)throw new SyntaxError("Control character in string");if(92===o){if(t+=1,"u"===e[t]){if(!/^[0-9a-fA-F]{4}$/u.test(e.slice(t+1,t+5)))throw new SyntaxError("Invalid Unicode escape");t+=5;continue}if(!/["\\/bfnrt]/u.test(e[t]||""))throw new SyntaxError("Invalid escape")}t+=1}throw new SyntaxError("Unterminated string")},i=()=>{if(n(),"{"===e[t]){t+=1,n();const s=new Set;if("}"===e[t])return void(t+=1);for(;t<e.length;){n();const r=o();if(s.has(r))throw new SyntaxError(`Duplicate key ${r}`);if(s.add(r),n(),":"!==e[t++])throw new SyntaxError("Expected colon");if(i(),n(),"}"===e[t])return void(t+=1);if(","!==e[t++])throw new SyntaxError("Expected comma")}throw new SyntaxError("Unterminated object")}if("["===e[t]){if(t+=1,n(),"]"===e[t])return void(t+=1);for(;t<e.length;){if(i(),n(),"]"===e[t])return void(t+=1);if(","!==e[t++])throw new SyntaxError("Expected comma")}throw new SyntaxError("Unterminated array")}if('"'===e[t])return void o();const s=/^(?:true|false|null|-?(?:0|[1-9][0-9]*)(?:\.[0-9]+)?(?:[eE][+-]?[0-9]+)?)/u.exec(e.slice(t));if(!s)throw new SyntaxError("Invalid JSON value");t+=s[0].length};try{if(i(),n(),t!==e.length)throw new SyntaxError("Trailing JSON data");const o=JSON.parse(e);return xe(o),o}catch(e){if("invalid_value"===e?.code)throw e;throw Object.assign(new SyntaxError(e.message),{code:"invalid_json",sourcePath:"$"})}}async function we(e){if(!globalThis.crypto?.subtle)throw new Error("composition_crypto_unavailable");const t=await globalThis.crypto.subtle.digest("SHA-256",(new globalThis.TextEncoder).encode(e));return[...new Uint8Array(t)].map(e=>e.toString(16).padStart(2,"0")).join("")}async function ve(e){return xe(e),`sha256:${await we(s(e))}`}async function _e(e,t){return`n-${await we(s(["sf-composition-node-v1",e,t]))}`}function xe(e,t="$",n=new Set){if(null!==e&&"string"!=typeof e&&"boolean"!=typeof e)if("number"!=typeof e){if("object"!=typeof e||!Array.isArray(e)&&!he(e)||n.has(e))throw Object.assign(new TypeError("value is not canonical JSON"),{code:"invalid_json",sourcePath:t});n.add(e),Array.isArray(e)?e.forEach((e,o)=>xe(e,`${t}/${o}`,n)):Object.entries(e).forEach(([e,o])=>{/^[0-9]+$/u.test(e)&&Number(e),xe(o,`${t}/${e.replaceAll("~","~0").replaceAll("/","~1")}`,n)}),n.delete(e)}else if(!Number.isSafeInteger(e)||e<-9007199254740991||e>9007199254740991)throw Object.assign(new TypeError("invalid canonical number"),{code:"invalid_value",sourcePath:t})}function $e(e,t,n){if(!he(e))throw Object.assign(new TypeError("Expected object"),{code:"invalid_value",sourcePath:n});for(const o of Object.keys(e))if(!t.has(o))throw Object.assign(new TypeError(`Unknown field ${o}`),{code:"unknown_field",sourcePath:`${n}/${o}`})}function ke(e,t,n){if(void 0!==e){if(!he(e))throw Object.assign(new TypeError("Extensions must be an object"),{code:"invalid_value",sourcePath:t});for(const[o,i]of Object.entries(e)){if(!/^[a-z][a-z0-9.-]*:[a-z][a-z0-9._-]*$/u.test(o))throw Object.assign(new TypeError("Extension name must be namespaced"),{code:"invalid_value",sourcePath:`${t}/${o}`});if(he(i)&&!0===i.required&&!n.has(o))throw Object.assign(new Error(`Required extension ${o} is unsupported`),{code:"unsupported_extension",sourcePath:`${t}/${o}`})}}}function Se(e,t){if(!he(e))throw Object.assign(new TypeError("Value wrapper is required"),{code:"invalid_value",sourcePath:t});const n=["literal","input","parameter"].filter(t=>Object.hasOwn(e,t));if(1!==n.length||1!==Object.keys(e).length)throw Object.assign(new TypeError("Value must have exactly one form"),{code:"invalid_value",sourcePath:t});if("literal"!==n[0]&&!me.test(e[n[0]]||""))throw Object.assign(new TypeError("Value reference is invalid"),{code:"invalid_value",sourcePath:t})}function Ee(e){const t=["node","ref","select","insertSlot"].filter(t=>Object.hasOwn(e||{},t));if(1!==t.length)throw Object.assign(new TypeError("Entry must contain one form"),{code:"invalid_value"});return t[0]}function Oe(e,t,{insertionAllowed:n=!1,localIds:o=new Set,maxSelectCases:i=ae.maxSelectCases,supportedExtensions:s=new Set}={}){if(!he(e)||!me.test(e.id||""))throw Object.assign(new TypeError("Invalid entry id"),{code:"invalid_value",sourcePath:`${t}/id`});const r=Ee(e);if("insertSlot"===r&&!n)throw Object.assign(new TypeError("Insertion is only valid inside a slot"),{code:"invalid_value",sourcePath:t});if($e(e,le[r],t),o.has(e.id))throw Object.assign(new TypeError("Duplicate local id"),{code:"duplicate_id",sourcePath:`${t}/id`});if(o.add(e.id),"node"===r){if($e(e.node,ce,`${t}/node`),!/^[a-z][a-z0-9-]*(?:\.[a-z][a-z0-9-]*)+$/u.test(e.node.type||""))throw Object.assign(new TypeError("Node type is invalid"),{code:"unknown_type",sourcePath:`${t}/node/type`});for(const[n,o]of Object.entries({data:e.node.data,props:e.node.props,presentation:e.node.presentation}))for(const[e,i]of Object.entries(o||{}))Se(i,`${t}/node/${n}/${e}`);for(const[n,o]of(e.node.bindings||[]).entries())if($e(o,new Set(["input","target"]),`${t}/node/bindings/${n}`),!me.test(o.input||"")||!me.test(o.target||""))throw Object.assign(new TypeError("Binding is invalid"),{code:"invalid_value",sourcePath:`${t}/node/bindings/${n}`});ke(e.node.extensions,`${t}/node/extensions`,s);for(const[n,r]of Object.entries(e.node.slots||{})){if(!Array.isArray(r))throw Object.assign(new TypeError("Slot must be an array"),{code:"invalid_value",sourcePath:`${t}/node/slots/${n}`});r.forEach((e,r)=>Oe(e,`${t}/node/slots/${n}/${r}`,{insertionAllowed:!0,localIds:o,maxSelectCases:i,supportedExtensions:s}))}}else if("ref"===r){if(!he(e.ref))throw Object.assign(new TypeError("Reference is invalid"),{code:"invalid_value",sourcePath:`${t}/ref`});const n="pinned"===e.ref.policy?new Set(["kind","owner","ref","policy","revision","extensions"]):new Set(["kind","owner","ref","policy","pointer","extensions"]);if($e(e.ref,n,`${t}/ref`),!["template","fragment"].includes(e.ref.kind)||!["pinned","follow-published"].includes(e.ref.policy))throw Object.assign(new TypeError("Reference kind or policy is invalid"),{code:"invalid_value",sourcePath:`${t}/ref`});const r="pinned"===e.ref.policy?e.ref.revision:e.ref.pointer;if(![e.ref.owner,e.ref.ref,r].every(e=>"string"==typeof e&&e))throw Object.assign(new TypeError("Reference identity is incomplete"),{code:"invalid_value",sourcePath:`${t}/ref`});for(const[n,o]of Object.entries(e.params||{}))Se(o,`${t}/params/${n}`);ke(e.ref.extensions,`${t}/ref/extensions`,s),ke(e.extensions,`${t}/extensions`,s);for(const[n,r]of Object.entries(e.slots||{})){if(!Array.isArray(r))throw Object.assign(new TypeError("Slot must be an array"),{code:"invalid_value",sourcePath:`${t}/slots/${n}`});r.forEach((e,r)=>Oe(e,`${t}/slots/${n}/${r}`,{insertionAllowed:!1,localIds:o,maxSelectCases:i,supportedExtensions:s}))}}else if("select"===r){$e(e.select,new Set(["value","cases","missingCase"]),`${t}/select`),Se(e.select.value,`${t}/select/value`);const n=e.select?.cases;if(!he(n)||0===Object.keys(n).length)throw Object.assign(new TypeError("Select needs cases"),{code:"invalid_value",sourcePath:`${t}/select/cases`});if(Object.keys(n).length>i)throw Object.assign(new RangeError("Select case limit exceeded"),{code:"limit_exceeded",sourcePath:`${t}/select/cases`});if(void 0!==e.select.missingCase&&!Object.hasOwn(n,e.select.missingCase))throw Object.assign(new TypeError("Missing case must name an existing case"),{code:"invalid_value",sourcePath:`${t}/select/missingCase`});for(const[e,o]of Object.entries(n))Oe(o,`${t}/select/cases/${e}`,{localIds:new Set,maxSelectCases:i,supportedExtensions:s})}else if(!me.test(e.insertSlot||""))throw Object.assign(new TypeError("Insertion slot is invalid"),{code:"unknown_slot",sourcePath:`${t}/insertSlot`});return r}function Te(e,t,n){const o=[],i=null===e?"null":Array.isArray(e)?"array":Number.isInteger(e)?"integer":typeof e;if(t.type&&t.type!==i&&o.push(`expected ${t.type}`),void 0!==t.const&&s(t.const)!==s(e)&&o.push("const mismatch"),t.enum&&!t.enum.some(t=>s(t)===s(e))&&o.push("enum mismatch"),"string"==typeof e&&(void 0!==t.minLength&&e.length<t.minLength&&o.push("string too short"),void 0!==t.maxLength&&e.length>t.maxLength&&o.push("string too long")),"number"==typeof e&&(void 0!==t.minimum&&e<t.minimum&&o.push("number too small"),void 0!==t.maximum&&e>t.maximum&&o.push("number too large")),Array.isArray(e)&&(void 0!==t.minItems&&e.length<t.minItems&&o.push("array too short"),void 0!==t.maxItems&&e.length>t.maxItems&&o.push("array too long"),t.items&&e.forEach((e,o)=>Te(e,t.items,`${n}/${o}`))),he(e)){for(const n of t.required||[])Object.hasOwn(e,n)||o.push(`missing ${n}`);if(!1===t.additionalProperties)for(const n of Object.keys(e))Object.hasOwn(t.properties||{},n)||o.push(`unknown ${n}`);for(const[o,i]of Object.entries(t.properties||{}))Object.hasOwn(e,o)&&Te(e[o],i,`${n}/${o}`)}if(o.length)throw Object.assign(new TypeError(o[0]),{code:"invalid_value",sourcePath:n})}async function je(e,t={}){const o=[],i=[],r=[];try{const a=function(e={}){const t={};for(const[n,o]of Object.entries(ae)){const i=e[n]??o;if(!Number.isInteger(i)||i<=0)throw Object.assign(new RangeError(`Invalid limit ${n}`),{code:"invalid_value",sourcePath:`/limits/${n}`});if(i>o)throw Object.assign(new RangeError(`Limit ${n} exceeds the hard maximum`),{code:"limit_exceeded",sourcePath:`/limits/${n}`});t[n]=i}return t}(t.limits);if(xe(e),ye(e)>a.maxRecipeBytes)throw Object.assign(new RangeError("Recipe byte limit exceeded"),{code:"limit_exceeded",sourcePath:"$"});if(!he(e)||!(0,b.Wl)(e,"simai.composition.recipe",1))throw Object.assign(new TypeError("Unsupported recipe schema"),{code:"invalid_value",sourcePath:"/schema"});if($e(e,ue,""),!me.test(e.id||"")||!["ui-layout","structured-content"].includes(e.profile))throw Object.assign(new TypeError("Recipe identity or profile is invalid"),{code:"invalid_value",sourcePath:"/"});const l=new Set(t.supportedExtensions||[]);for(const[t,n]of Object.entries(e.inputs||{})){if($e(n,pe,`/inputs/${t}`),!["parameter","setting","content"].includes(n.kind)||!he(n.schema))throw Object.assign(new TypeError("Input declaration is invalid"),{code:"invalid_value",sourcePath:`/inputs/${t}`});if(n.default&&Se(n.default,`/inputs/${t}/default`),n.default&&!Object.hasOwn(n.default,"literal"))throw Object.assign(new TypeError("Input default must be literal"),{code:"invalid_value",sourcePath:`/inputs/${t}/default`});if(!("content"!==n.kind||n.expectedOrigin?.owner&&n.expectedOrigin?.ref))throw Object.assign(new TypeError("Content origin is required"),{code:"input_origin_mismatch",sourcePath:`/inputs/${t}/expectedOrigin`});ke(n.extensions,`/inputs/${t}/extensions`,l)}if(ke(e.extensions,"/extensions",l),Oe(e.root,"/root",{localIds:new Set,maxSelectCases:a.maxSelectCases,supportedExtensions:l}),Object.keys(e.inputs||{}).length>a.maxInputs)throw Object.assign(new RangeError("Input limit exceeded"),{code:"limit_exceeded",sourcePath:"/inputs"});const c=t.trustedContext?.scope;if("string"!=typeof c||!c)throw Object.assign(new TypeError("Trusted scope is required"),{code:"invalid_value",sourcePath:"/trustedContext/scope"});const u=t.inputs||{...(0,b.xZ)("simai.composition.inputs",1),scope:c,values:{}};if(xe(u,"/inputs"),$e(u,de,"/inputs"),!(0,b.Wl)(u,"simai.composition.inputs",1)||u.scope!==c)throw Object.assign(new TypeError("Input scope mismatch"),{code:"input_origin_mismatch",sourcePath:"/inputs"});const d=await ve(e),f={steps:0,sourceBytes:0,inputBytes:0,nodes:0,intermediateBytes:0},p=new Set,m=new Map,h=new Map,g=[],y=[],w=[],v=e=>{if(f.steps+=1,f.steps>a.maxExpansionSteps)throw Object.assign(new RangeError("Expansion step limit exceeded"),{code:"limit_exceeded",sourcePath:e})},_=async(n,i)=>{if(v(i),h.has(n))return h.get(n);const s=e.inputs?.[n];if(!s)throw Object.assign(new TypeError(`Unknown input ${n}`),{code:"missing_input",sourcePath:i});o.push({operation:"read-input",name:n,sourcePath:i});let r,l=u.values?.[n];if(void 0===l&&t.ports?.readInput&&(l=await t.ports.readInput(n,s,{scope:c})),"denied"===l?.status)throw Object.assign(new Error("Input access denied"),{code:"access_denied",sourcePath:i});if("error"===l?.status)throw Object.assign(new Error("Input source failed"),{code:"source_error",sourcePath:i});if(void 0===l||"missing"===l?.status){if(!s.default)throw Object.assign(new Error(`Input ${n} is missing`),{code:"missing_input",sourcePath:i});const e=ge(s.default.literal);Te(e,s.schema,i);const t=await ve(e),o=l?.missingSource||("parameter"===s.kind?void 0:{scope:c,owner:s.expectedOrigin?.owner,ref:s.expectedOrigin?.ref});if(!("parameter"===s.kind||o?.owner&&o?.ref))throw Object.assign(new Error("Missing source identity is required"),{code:"input_origin_mismatch",sourcePath:i});r={value:e,receipt:{name:n,kind:s.kind,valueDigest:t,...o?{missingSource:o}:{},resolution:"default"}}}else{if(f.inputBytes+=ye(l),ye(l)>a.maxInputBytes||f.inputBytes>a.maxTotalInputBytes)throw Object.assign(new RangeError("Input byte limit exceeded"),{code:"limit_exceeded",sourcePath:i});if(l.kind!==s.kind)throw Object.assign(new Error("Input kind mismatch"),{code:"input_origin_mismatch",sourcePath:i});Te(l.value,s.schema,i);const e=await ve(l.value);if(e!==l.valueDigest)throw Object.assign(new Error("Input digest mismatch"),{code:"input_digest_mismatch",sourcePath:i});const t=s.expectedOrigin;if("parameter"!==s.kind&&(!l.origin||l.origin.scope!==c||t?.owner!==l.origin.owner||t?.ref!==l.origin.ref||t?.revision&&t.revision!==l.origin.revision))throw Object.assign(new Error("Input origin mismatch"),{code:"input_origin_mismatch",sourcePath:i});r={value:ge(l.value),receipt:{name:n,kind:s.kind,valueDigest:e,...l.origin?{origin:ge(l.origin)}:{},resolution:"provided"}}}return h.set(n,r),y.push(r.receipt),r},x=async(e,t,n)=>{if(v(n),!he(e))throw Object.assign(new TypeError("Value wrapper is required"),{code:"invalid_value",sourcePath:n});if(Object.hasOwn(e,"literal"))return ge(e.literal);if(Object.hasOwn(e,"input"))return(await _(e.input,n)).value;if(Object.hasOwn(e,"parameter")){if(!t.has(e.parameter))throw Object.assign(new Error(`Parameter ${e.parameter} is missing`),{code:"unknown_parameter",sourcePath:n});return ge(t.get(e.parameter))}throw Object.assign(new TypeError("Unknown value wrapper"),{code:"invalid_value",sourcePath:n})},$=async(e,n)=>{v(n);const i="pinned"===e.policy?e.revision:`pointer:${e.pointer}`,r=s([c,e.kind,e.owner,e.ref,i]);if(m.has(r))return m.get(r);if(m.size>=a.maxUniqueReferences)throw Object.assign(new RangeError("Reference limit exceeded"),{code:"limit_exceeded",sourcePath:n});if(!t.ports?.readReference)throw Object.assign(new Error("Reference port is unavailable"),{code:"missing_reference",sourcePath:n});o.push({operation:"read-reference",kind:e.kind,owner:e.owner,ref:e.ref,revision:e.revision,pointer:e.pointer,sourcePath:n});const l=await t.ports.readReference(e,{scope:c,maxBytes:a.maxSourceBytes});if("denied"===l?.status)throw Object.assign(new Error("Reference access denied"),{code:"access_denied",sourcePath:n});if("error"===l?.status)throw Object.assign(new Error("Reference source failed"),{code:"source_error",sourcePath:n});if(!l?.source)throw Object.assign(new Error("Reference not found"),{code:"missing_reference",sourcePath:n});const u=l.revision;if("pinned"===e.policy&&u!==e.revision)throw Object.assign(new Error("Reference revision mismatch"),{code:"revision_mismatch",sourcePath:n});const d=ye(l.source);if(f.sourceBytes+=d,d>a.maxSourceBytes||f.sourceBytes>a.maxTotalSourceBytes)throw Object.assign(new RangeError("Source byte limit exceeded"),{code:"limit_exceeded",sourcePath:n});const p=await ve(l.source);if(l.digest&&l.digest!==p)throw Object.assign(new Error("Reference digest mismatch"),{code:"revision_mismatch",sourcePath:n});const h={source:ge(l.source),revision:u,digest:p};return m.set(r,h),g.push({kind:e.kind,owner:e.owner,ref:e.ref,revision:u,digest:p,scope:c}),"follow-published"===e.policy&&w.push({kind:e.kind,owner:e.owner,ref:e.ref,pointer:e.pointer,generation:l.generation,resolvedRevision:u,scope:c}),h},k=async(t,n,o)=>{v(o);const i=Ee(t);if("select"===i){const e=await x(t.select.value,n.parameters,`${o}/select/value`);if("string"!=typeof e)throw Object.assign(new Error("Select value must be a string"),{code:"invalid_value",sourcePath:`${o}/select/value`});let i=String(e);if(Object.hasOwn(t.select.cases,i)||(i=t.select.missingCase),!i||!Object.hasOwn(t.select.cases,i))throw Object.assign(new Error("Select value has no case"),{code:"invalid_value",sourcePath:o});return k(t.select.cases[i],{...n,segments:[...n.segments,["select",t.id],["case",i]]},`${o}/select/cases/${i}`)}if("insertSlot"===i){const e=n.callSlots?.[t.insertSlot]??n.slotDefaults?.[t.insertSlot]??[],i=[];for(let s=0;s<e.length;s+=1)i.push(await k(e[s],{...n,segments:[...n.segments,["insertion",t.id],["argument-slot",t.insertSlot]]},`${o}/inserted/${t.insertSlot}/${s}`));const s=i.flat(),r=n.slotSpecs?.[t.insertSlot];if(!r)throw Object.assign(new Error(`Unknown insertion slot ${t.insertSlot}`),{code:"unknown_slot",sourcePath:o});if(s.length<r.min||s.length>r.max)throw Object.assign(new Error(`Slot ${t.insertSlot} has invalid cardinality`),{code:"invalid_value",sourcePath:o});if(r.types?.length&&s.some(e=>!r.types.includes(e.type)))throw Object.assign(new Error(`Slot ${t.insertSlot} contains a forbidden type`),{code:"unknown_type",sourcePath:o});return n.usedCallSlots?.add(t.insertSlot),s}if("ref"===i){if(r.length>=a.maxReferenceDepth)throw Object.assign(new RangeError("Reference depth exceeded"),{code:"limit_exceeded",sourcePath:o});const e=s([c,t.ref.kind,t.ref.owner,t.ref.ref,t.ref.revision||t.ref.pointer]);if(r.includes(e))throw Object.assign(new Error("Reference cycle"),{code:"reference_cycle",sourcePath:o});const i=await $(t.ref,o);r.push(e);try{if("fragment"===t.ref.kind){if(t.params||t.slots)throw Object.assign(new Error("Fragment cannot receive parameters or slots"),{code:"invalid_value",sourcePath:o});return Oe(i.source,`${o}/source`,{localIds:new Set,maxSelectCases:a.maxSelectCases,supportedExtensions:l}),await k(i.source,{...n,segments:[...n.segments,["placement",t.id]]},`${o}/source`)}if(!(0,b.Wl)(i.source,"simai.composition.recipe-manifest",1))throw Object.assign(new Error("Template manifest is invalid"),{code:"invalid_value",sourcePath:o});$e(i.source,fe,`${o}/source`),ke(i.source.extensions,`${o}/source/extensions`,l),Oe(i.source.body,`${o}/source/body`,{localIds:new Set,maxSelectCases:a.maxSelectCases,supportedExtensions:l});const e=new Map;for(const[s,r]of Object.entries(i.source.parameters||{})){const i=t.params?.[s]??r.default;if(!i)throw Object.assign(new Error(`Parameter ${s} is missing`),{code:"unknown_parameter",sourcePath:o});const a=await x(i,n.parameters,`${o}/params/${s}`);Te(a,r,`${o}/params/${s}`),e.set(s,a)}for(const e of Object.keys(t.params||{}))if(!Object.hasOwn(i.source.parameters||{},e))throw Object.assign(new Error(`Unknown parameter ${e}`),{code:"unknown_parameter",sourcePath:`${o}/params/${e}`});for(const e of Object.keys(t.slots||{}))if(!Object.hasOwn(i.source.slots||{},e))throw Object.assign(new Error(`Unknown slot ${e}`),{code:"unknown_slot",sourcePath:`${o}/slots/${e}`});const s=Object.fromEntries(Object.entries(i.source.slots||{}).map(([e,t])=>[e,t.defaults||[]]));for(const[e,t]of Object.entries(i.source.slots||{}))if($e(t,new Set(["min","max","types","defaults"]),`${o}/source/slots/${e}`),!Number.isInteger(t.min)||!Number.isInteger(t.max)||t.min<0||t.max>a.maxChildrenPerSlot||t.min>t.max)throw Object.assign(new Error(`Slot ${e} has invalid limits`),{code:"invalid_value",sourcePath:o});const r=new Set,c=await k(i.source.body,{...n,parameters:e,callSlots:t.slots||{},slotDefaults:s,slotSpecs:i.source.slots||{},usedCallSlots:r,segments:[...n.segments,["placement",t.id]]},`${o}/source/body`);for(const e of Object.keys(t.slots||{}))if(!r.has(e))throw Object.assign(new Error(`Slot ${e} was not inserted`),{code:"unknown_slot",sourcePath:`${o}/slots/${e}`});return c}catch(e){throw e.referenceChain||(e.referenceChain=[...r]),e}finally{r.pop()}}const u=[...n.segments,["node",t.id]],d={id:await _e(e.id,u),type:t.node.type};if(p.has(d.id))throw Object.assign(new Error("Duplicate resolved identity"),{code:"duplicate_id",sourcePath:o});p.add(d.id);for(const e of["data","props"])if(t.node[e]){d[e]={};for(const[i,s]of Object.entries(t.node[e]))d[e][i]=await x(s,n.parameters,`${o}/node/${e}/${i}`)}if(t.node.presentation){d.presentation={};for(const[e,i]of Object.entries(t.node.presentation))d.presentation[e]=await x(i,n.parameters,`${o}/node/presentation/${e}`)}if(t.node.bindings){d.bindings=[];for(const n of t.node.bindings){const i=e.inputs?.[n.input];if("content"!==i?.kind||!t.node.data?.[n.target]||t.node.data[n.target].input!==n.input)throw Object.assign(new Error("Binding must match content data input"),{code:"invalid_value",sourcePath:o});const s=await _(n.input,`${o}/node/bindings/${n.target}`);d.bindings.push({owner:s.receipt.origin.owner,ref:s.receipt.origin.ref,target:n.target,revision:s.receipt.origin.revision})}}var m;if(t.node.extensions&&(d.extensions=void 0===(m=t.node.extensions)?void 0:ge(m)),t.node.slots){d.slots={};for(const[e,i]of Object.entries(t.node.slots)){const t=[];for(let s=0;s<i.length;s+=1)t.push(await k(i[s],{...n,segments:[...u,["slot",e]]},`${o}/node/slots/${e}/${s}`));if(d.slots[e]=t.flat(),d.slots[e].length>a.maxChildrenPerSlot)throw Object.assign(new RangeError("Slot child limit exceeded"),{code:"limit_exceeded",sourcePath:o})}}if(f.nodes+=1,f.nodes>a.maxOutputNodes)throw Object.assign(new RangeError("Output node limit exceeded"),{code:"limit_exceeded",sourcePath:o});if(f.intermediateBytes+=ye(d),f.intermediateBytes>a.maxIntermediateBytes)throw Object.assign(new RangeError("Intermediate byte limit exceeded"),{code:"limit_exceeded",sourcePath:o});return d},S=await k(e.root,{parameters:new Map,callSlots:{},slotDefaults:{},segments:[]},"/root");if(Array.isArray(S))throw Object.assign(new Error("Root must resolve to one node"),{code:"invalid_resolved_document",sourcePath:"/root"});const E={...se(e),id:e.id,profile:e.profile,...e.locale?{locale:e.locale}:{},root:S},O=e=>1+Math.max(0,...Object.values(e.slots||{}).flat().map(O));if(O(S)>a.maxOutputDepth)throw Object.assign(new RangeError("Output depth limit exceeded"),{code:"limit_exceeded",sourcePath:"/root"});if(ye(E)>a.maxOutputBytes)throw Object.assign(new RangeError("Output byte limit exceeded"),{code:"limit_exceeded",sourcePath:"/root"});const{normalize:T}=await Promise.resolve().then(n.bind(n,"3a00b12d226d")),j=await T(E,t.registry,{limits:{maxDocumentBytes:a.maxOutputBytes,maxDepth:a.maxOutputDepth,maxNodes:a.maxOutputNodes,maxChildrenPerSlot:a.maxChildrenPerSlot},supportedExtensions:t.supportedExtensions,ports:t.compositionPorts});if(!j.document)throw Object.assign(new Error("Resolved document is invalid"),{code:"invalid_resolved_document",sourcePath:"/root",details:j.diagnostics});const A=t.executionContract;if(!A?.contractDigest||!A?.registryDigest||!A?.rendererDigest)throw Object.assign(new Error("Execution contract is required"),{code:"invalid_value",sourcePath:"/executionContract"});const L=A.canonicalization??ne;if(!oe.has(L))throw Object.assign(new Error("Unsupported canonicalization profile"),{code:"incompatible_profile",sourcePath:"/executionContract/canonicalization"});const P={...ie(e,"simai.composition.dependencies"),scope:c,recipeDigest:d,documentDigest:`sha256:${j.digest}`,references:g,inputs:y,logicalPointers:w,executionContract:{...ge(A),canonicalization:L}};return{document:j.document,dependencyReceipt:P,trace:o,diagnostics:i}}catch(e){return i.push(function(e,t,n,o=[]){return{code:e,sourcePath:t,referenceChain:[...o],message:n}}(e.code||"source_error",e.sourcePath||"$",e.message||"Recipe resolution failed",e.referenceChain||r)),e.details&&i.push(...e.details.map(t=>({...t,sourcePath:t.path||e.sourcePath||"$"}))),{document:null,dependencyReceipt:null,trace:o,diagnostics:i}}}const Ae=Object.freeze({defaultLimits:re,digest:ve,nodeId:_e,parseJson:be,resolve:je}),Le=Object.freeze(["strong","em","code"]),Pe=new Map(Le.map((e,t)=>[e,t])),ze=new Set(["http:","https:","mailto:","tel:"]),Re=Object.freeze({maxTextLength:1e5,maxHrefLength:2048});function Ce(e){if("string"!=typeof e||e.length<1||e.length>Re.maxHrefLength)return!1;if(/^(?:\/|\.?\.\/|#)/u.test(e))return!e.startsWith("//")&&!e.includes("\\");try{return ze.has(new globalThis.URL(e).protocol)}catch{return!1}}function Fe(e){return[...new Set(e)].filter(e=>Pe.has(e)).sort((e,t)=>Pe.get(e)-Pe.get(t))}function Ne(e){const t=[],n=(e,n)=>{"text"===e?.type&&"string"==typeof e.value&&e.value&&t.push({text:e.value,marks:Fe(Array.isArray(e.marks)?e.marks:[]),href:n})};for(const t of Array.isArray(e)?e:[])if("link"===t?.type){const e=Ce(t.href)?t.href:null;for(const o of Array.isArray(t.children)?t.children:[])n(o,e)}else n(t,null);return t}const Ie=(e,t)=>e.href===t.href&&e.marks.join()===t.marks.join();function Me(e){const t=[];for(const n of e){if(!n.text)continue;const e={text:n.text,marks:Fe(n.marks||[]),href:n.href&&Ce(n.href)?n.href:null},o=t.at(-1);o&&Ie(o,e)?o.text+=e.text:t.push(e)}const n=[];for(const e of t){const t={type:"text",value:e.text,...e.marks.length?{marks:e.marks}:{}},o=n.at(-1);e.href?"link"===o?.type&&o.href===e.href?o.children.push(t):n.push({type:"link",href:e.href,children:[t]}):n.push(t)}return n}function qe(e){return Me(Ne(e))}function De(e){return Ne(e).map(({text:e})=>e).join("")}const Be="simai.composition:endpoint",Ue=Object.freeze({maxRoutesPerScope:32,maxEndpointsPerScope:64,maxFanOut:8,maxScopeNesting:4,maxReentrancy:8,maxValueBytes:65536}),We=/^[a-z][a-z0-9-]{0,31}$/u,He=/^[a-z][a-z0-9-]{0,63}$/u,Ve=/[\u0000-\u001f\u007f]/u,Ze=(e,t,n)=>({code:e,path:t,message:n});function Je(e){return"string"==typeof e?e.length>0&&e.length<=256&&!Ve.test(e):Number.isSafeInteger(e)}function Ge(e){return Object.freeze([...e])}function Xe(e,t,n,i){if(!o(e))throw new TypeError(`${i} value is not an object`);const s=Object.keys(e);if(!t.every(e=>s.includes(e)))throw new TypeError(`${i} value misses a required key`);if(!s.every(e=>t.includes(e)||n.includes(e)))throw new TypeError(`${i} value has an undeclared key`)}const Ye=/^[a-z][a-z0-9._:-]{0,127}$/u,Ke=e=>"string"==typeof e&&Ye.test(e),Qe=e=>"string"==typeof e&&e.length>0&&e.length<=128&&!Ve.test(e),et=/^[\w.*:-]+(?:\/[\w.*:/-]+)?$/u,tt={type:"string",minLength:1,maxLength:128},nt={oneOf:[{type:"string",minLength:1,maxLength:256},{type:"integer",minimum:-9007199254740991,maximum:9007199254740991}]},ot={type:"string",pattern:"^[a-z][a-z0-9._:-]{0,127}$"},it=Object.freeze({"record-ids.v1":Object.freeze({summary:"Ordered unique opaque record identities: nonempty strings up to 256 code units without control characters, or safe integers. Up to 1000 items; empty means no selection.",schema:{type:"array",maxItems:1e3,uniqueItems:!0,items:{oneOf:[{type:"string",minLength:1,maxLength:256},{type:"integer",minimum:-9007199254740991,maximum:9007199254740991}]}},check(e){if(!Array.isArray(e)||e.length>1e3||!e.every(Je))throw new TypeError("record-ids.v1 value is invalid");if(new Set(e.map(e=>`${typeof e}:${e}`)).size!==e.length)throw new TypeError("record-ids.v1 value has duplicates");return Ge(e)}}),"record-id.v1":Object.freeze({summary:"One opaque record identity or null for none.",schema:{oneOf:[{type:"null"},{type:"string",minLength:1,maxLength:256},{type:"integer",minimum:-9007199254740991,maximum:9007199254740991}]},check(e){if(null!==e&&!Je(e))throw new TypeError("record-id.v1 value is invalid");return e}}),"text.v1":Object.freeze({summary:"Plain text up to 2000 code units; never interpreted as markup or a query language.",schema:{type:"string",maxLength:2e3},check(e){if("string"!=typeof e||e.length>2e3)throw new TypeError("text.v1 value is invalid");return e}}),"boolean.v1":Object.freeze({summary:"A strict boolean.",schema:{type:"boolean"},check(e){if("boolean"!=typeof e)throw new TypeError("boolean.v1 value is invalid");return e}}),"record-changed.v1":Object.freeze({summary:"A record changed: its collection, identity and new revision, and optionally the keys of the fields that changed (up to 256). Says what changed, never the values.",schema:{type:"object",additionalProperties:!1,required:["collection","id","revision"],properties:{collection:tt,id:nt,revision:{oneOf:[{type:"string",minLength:1,maxLength:128},{type:"integer",minimum:-9007199254740991,maximum:9007199254740991}]},fields:{type:"array",maxItems:256,uniqueItems:!0,items:{type:"string",minLength:1,maxLength:128}}}},check(e){if(Xe(e,["collection","id","revision"],["fields"],"record-changed.v1"),!Qe(e.collection)||!Je(e.id)||!(e=>"string"==typeof e&&e.length>0&&e.length<=128&&!Ve.test(e)||Number.isSafeInteger(e))(e.revision))throw new TypeError("record-changed.v1 value is invalid");const t={collection:e.collection,id:e.id,revision:e.revision};if(void 0!==e.fields){const n=e.fields;if(!Array.isArray(n)||n.length>256||!n.every(Qe)||new Set(n).size!==n.length)throw new TypeError("record-changed.v1 fields are invalid");t.fields=Ge(n)}return Object.freeze(t)}}),"record-removed.v1":Object.freeze({summary:"A record was removed from its collection.",schema:{type:"object",additionalProperties:!1,required:["collection","id"],properties:{collection:tt,id:nt}},check(e){if(Xe(e,["collection","id"],[],"record-removed.v1"),!Qe(e.collection)||!Je(e.id))throw new TypeError("record-removed.v1 value is invalid");return Object.freeze({collection:e.collection,id:e.id})}}),"collection-changed.v1":Object.freeze({summary:"Something in a collection changed that a list should read again; reason is a short token (created, imported, reordered, settings ...).",schema:{type:"object",additionalProperties:!1,required:["collection","reason"],properties:{collection:tt,reason:ot}},check(e){if(Xe(e,["collection","reason"],[],"collection-changed.v1"),!Qe(e.collection)||!Ke(e.reason))throw new TypeError("collection-changed.v1 value is invalid");return Object.freeze({collection:e.collection,reason:e.reason})}}),"files-moved.v1":Object.freeze({summary:"Files moved between folders: their identities (1 to 1000, unique), the folder they left and the one they went to; null is the root.",schema:{type:"object",additionalProperties:!1,required:["ids","from","to"],properties:{ids:{type:"array",minItems:1,maxItems:1e3,uniqueItems:!0,items:nt},from:{oneOf:[{type:"null"},...nt.oneOf]},to:{oneOf:[{type:"null"},...nt.oneOf]}}},check(e){Xe(e,["ids","from","to"],[],"files-moved.v1");const t=e.ids;if(!Array.isArray(t)||0===t.length||t.length>1e3||!t.every(Je))throw new TypeError("files-moved.v1 ids are invalid");if(new Set(t.map(e=>`${typeof e}:${e}`)).size!==t.length)throw new TypeError("files-moved.v1 ids have duplicates");const n=e=>null===e||Je(e);if(!n(e.from)||!n(e.to))throw new TypeError("files-moved.v1 folder is invalid");return Object.freeze({ids:Ge(t),from:e.from,to:e.to})}}),"counter.v1":Object.freeze({summary:"A named count changed: key is a token (notifications, requests.new ...), value a non-negative safe integer.",schema:{type:"object",additionalProperties:!1,required:["key","value"],properties:{key:ot,value:{type:"integer",minimum:0,maximum:9007199254740991}}},check(e){if(Xe(e,["key","value"],[],"counter.v1"),!Ke(e.key)||!Number.isSafeInteger(e.value)||e.value<0)throw new TypeError("counter.v1 value is invalid");return Object.freeze({key:e.key,value:e.value})}}),"navigation.v1":Object.freeze({summary:"Go to an address of the same site, in a named region: url is a path (starting with one slash, up to 2048 code units), region a region name.",schema:{type:"object",additionalProperties:!1,required:["url","region"],properties:{url:{type:"string",minLength:1,maxLength:2048,pattern:"^/(?!/)"},region:{type:"string",pattern:"^[a-z][a-z0-9-]{0,31}$"}}},check(e){if(Xe(e,["url","region"],[],"navigation.v1"),!(e=>"string"==typeof e&&e.length>0&&e.length<=2048&&!Ve.test(e)&&e.startsWith("/")&&!e.startsWith("//"))(e.url)||"string"!=typeof e.region||!We.test(e.region))throw new TypeError("navigation.v1 value is invalid");return Object.freeze({url:e.url,region:e.region})}}),"preference-changed.v1":Object.freeze({summary:"A person changed a view preference: the SF.Preferences key (sf-table/<key>, sf-table/*, sf-admin-menu/main ...). Says which, never the value.",schema:{type:"object",additionalProperties:!1,required:["key"],properties:{key:{type:"string",minLength:1,maxLength:256,pattern:"^[\\w.*:-]+(?:/[\\w.*:/-]+)?$"}}},check(e){if(Xe(e,["key"],[],"preference-changed.v1"),"string"!=typeof e.key||e.key.length>256||!et.test(e.key))throw new TypeError("preference-changed.v1 value is invalid");return Object.freeze({key:e.key})}})}),st=(e,t)=>o(e)&&"string"==typeof t&&Object.hasOwn(e,t),rt=Object.freeze(Object.assign(Object.create(null),Object.fromEntries(Object.keys(it).map(e=>[e.replace(/\.v1$/u,""),e]))));function at(e){return"string"!=typeof e?null:Object.hasOwn(rt,e)?e:Object.hasOwn(it,e)?e.replace(/\.v1$/u,""):null}function lt(e,t){const n=at(e);return null!==n&&n===at(t)}function ct(e){const t=at(e);return null===t?null:it[rt[t]]}const ut=e=>null!==at(e);function dt(e,t){if(!ut(e))throw new TypeError(`Unknown value type ${e}`);const n=ct(e).check(t);if((new globalThis.TextEncoder).encode(JSON.stringify(n)).byteLength>Ue.maxValueBytes)throw new TypeError("Port value is too large");return n}function ft(e=[],t={}){const n=new Map;for(const t of e){if(!o(t)||!(0,b.Wl)(t,"simai.composition.port-manifest",1))throw new TypeError("composition_port_manifest_invalid");if(n.has(t.element))throw new TypeError(`composition_port_manifest_duplicate:${t.element}`);for(const e of[...Object.values(t.outputs||{}),...Object.values(t.inputs||{})])if(!ut(e.value))throw new TypeError(`composition_port_value_type_unknown:${e.value}`);n.set(t.element,i(t))}const s=new Map(Object.entries(t.bindings||{}));for(const[e,t]of s)if(!n.has(t))throw new TypeError(`composition_port_binding_unknown:${e}`);return{elements:n,bindings:s}}function pt(e,t){if(!e||!t)return null;const n=t.bindings.get(e.type);return n?t.elements.get(n)||null:"custom-element"===e.renderer?.kind&&t.elements.get(e.renderer.name)||null}function mt(e){return o(e)&&1===Object.keys(e).length&&"string"==typeof e.name&&We.test(e.name)}function ht(e){const t=st(e?.extensions,Be)?e.extensions[Be]:void 0;return mt(t)?t.name:void 0}function gt(e,t,n,i=[]){const s=new Map,r=(e,a,l)=>{if(!o(e))return;st(e.extensions,Be)&&!mt(e.extensions[Be])&&i.push(Ze("route_endpoint_invalid",`${a}.extensions.${Be}`,"Endpoint extension must contain only a valid name"));let c=l;if("layout.scope"===e.type){c+=1,c>Ue.maxScopeNesting&&i.push(Ze("scope_nesting_limit",a,"Routing scopes are nested too deeply"));const r=Array.isArray(e.props?.routes)?e.props.routes:[],{endpoints:l,problems:u}=function(e,t){const n=new Map,i=[],s=(t,r,a)=>{if(o(t)){if(t!==e){const e=st(t.extensions,Be)?t.extensions[Be]:void 0;mt(e)&&!a&&(n.has(e.name)?i.push(Ze("route_endpoint_duplicate",`${r}.extensions.${Be}`,`Endpoint ${e.name} is declared twice in one scope`)):n.set(e.name,{node:t,path:r})),"layout.scope"===t.type&&(a=!0)}for(const[e,n]of Object.entries(o(t.slots)?t.slots:{}))Array.isArray(n)&&n.forEach((t,n)=>s(t,`${r}.slots.${e}[${n}]`,a))}};return s(e,t,!1),{endpoints:n,problems:i}}(e,a);i.push(...u),l.size>Ue.maxEndpointsPerScope&&i.push(Ze("route_limit",a,"Scope declares too many endpoints"));const d=new Set,f=new Set,p=new Map,m=[],h=[];r.forEach((e,s)=>{const r=`${a}.props.routes[${s}]`;if(!o(e)||!o(e.from)||!o(e.to))return;d.has(e.id)&&i.push(Ze("route_id_duplicate",`${r}.id`,`Route ${e.id} is declared twice`)),d.add(e.id);const c={};for(const o of["from","to"]){const s="string"==typeof e[o].endpoint?l.get(e[o].endpoint):void 0;if(!s){i.push(Ze("route_endpoint_unknown",`${r}.${o}.endpoint`,`Endpoint ${e[o].endpoint} is not declared in this scope`));continue}const a=pt(t.types.get(s.node.type),n),u="from"===o?"outputs":"inputs",d="from"===o?"inputs":"outputs",f=st(a?.[u],e[o].port)?a[u][e[o].port]:void 0;if(!f){const t=st(a?.[d],e[o].port);i.push(t?Ze("route_port_direction",`${r}.${o}.port`,`${e[o].port} is not ${"from"===o?"an output":"an input"}`):Ze("route_port_unknown",`${r}.${o}.port`,`${s.node.type} publishes no ${"from"===o?"output":"input"} ${e[o].port}`));continue}c[o]={endpoint:e[o].endpoint,port:e[o].port,value:f.value,element:a.element}}e.from.endpoint===e.to.endpoint&&i.push(Ze("route_self",r,"A route cannot connect an endpoint to itself"));const u=`${e.to.endpoint}.${e.to.port}`;f.has(u)&&i.push(Ze("route_input_conflict",`${r}.to`,`Input ${u} already has a route`)),f.add(u);const g=`${e.from.endpoint}.${e.from.port}`;p.set(g,(p.get(g)||0)+1),p.get(g)>Ue.maxFanOut&&i.push(Ze("route_fanout_limit",`${r}.from`,`Output ${g} feeds too many routes`)),m.push([e.from.endpoint,e.to.endpoint]),c.from&&c.to&&(lt(c.from.value,c.to.value)?h.push({id:e.id,from:c.from,to:c.to}):i.push(Ze("route_type_mismatch",r,`${c.from.value} cannot feed ${c.to.value}`)))}),function(e){const t=new Map;for(const[n,o]of e)t.has(n)||t.set(n,new Set),t.get(n).add(o);const n=new Map,o=e=>{n.set(e,"active");for(const i of t.get(e)||[]){if("active"===n.get(i))return!0;if(!n.has(i)&&o(i))return!0}return n.set(e,"done"),!1};return[...t.keys()].some(e=>!n.has(e)&&o(e))}(m.filter(([e,t])=>e!==t))&&i.push(Ze("route_cycle",`${a}.props.routes`,"Routes form a cycle between endpoints")),s.set(e.id,h)}for(const[t,n]of Object.entries(o(e.slots)?e.slots:{}))Array.isArray(n)&&n.forEach((e,n)=>r(e,`${a}.slots.${t}[${n}]`,c))};return r(e,"$.root",0),s}class yt{constructor(e,t,n={}){this.host=e,this.routes=Object.freeze(t.map(e=>Object.freeze({...e,from:Object.freeze({...e.from}),to:Object.freeze({...e.to})}))),this.options=n,this.sequence=0,this.depth=0,this.states=new Map,this.pending=new Map,this.counters={outputs:0,deliveries:0,settled:0,stale:0,rejected:0},this.connection=null,this.onOutput=this.onOutput.bind(this)}get connected(){return null!==this.connection}connect(){if(this.connection)return!1;this.connection=new AbortController,this.host.addEventListener("sf-port-output",this.onOutput,{signal:this.connection.signal});for(const e of this.routes)this.setState(e.id,{status:"idle",sequence:0});return!0}disconnect(){if(!this.connection)return!1;this.connection.abort(),this.connection=null;for(const e of this.pending.values())e.abort();this.pending.clear();for(const e of this.routes)this.setState(e.id,{status:"disposed",sequence:this.states.get(e.id)?.sequence||0});return!0}getState(e){const t=this.states.get(e);return t?{...t}:null}setState(e,t){const n=Object.freeze({route:e,...t});this.states.set(e,n),this.options.onState?.(n)}onOutput(e){const t=this.options.sourceEndpoint?.(e);if(!t)return;const n=e.detail;if(o(n)&&"string"==typeof n.port){this.counters.outputs+=1;for(const e of this.routes){if(e.from.endpoint!==t||e.from.port!==n.port)continue;let o;try{o=dt(e.from.value,n.value)}catch{this.counters.rejected+=1,this.pending.get(e.id)?.abort(),this.pending.delete(e.id),this.setState(e.id,{status:"error",error:"value_invalid",sequence:++this.sequence});continue}this.deliver(e,o)}}}deliver(e,t){if(!this.connection)return;const n=++this.sequence;this.pending.get(e.id)?.abort();const o=new AbortController;this.pending.set(e.id,o),this.setState(e.id,{status:"pending",sequence:n});const i=()=>null!==this.connection&&!o.signal.aborted&&this.states.get(e.id)?.sequence===n,s=Object.freeze({route:e.id,sequence:n,signal:o.signal,isLatest:i}),r=()=>{if(!i())return;const o=this.options.targetEndpoint?.(e.to.endpoint);if(!o)return void this.setState(e.id,{status:"error",error:"endpoint_unresolved",sequence:n});if("function"!=typeof o.sfPortInput){const t=this.options.whenReady?.(o);return void(t?(this.setState(e.id,{status:"waiting",sequence:n}),t.then(r,()=>this.setState(e.id,{status:"error",error:"endpoint_unavailable",sequence:n}))):this.setState(e.id,{status:"error",error:"port_unsupported",sequence:n}))}const a=o.constructor?.sfPorts?.inputs?.[e.to.port];if(!lt(a,e.to.value))return this.counters.rejected+=1,void this.setState(e.id,{status:"error",error:"port_mismatch",sequence:n});if(this.depth>=Ue.maxReentrancy)return this.counters.rejected+=1,void this.setState(e.id,{status:"error",error:"reentrancy_limit",sequence:n});let l;this.depth+=1;try{this.counters.deliveries+=1,l=o.sfPortInput(e.to.port,t,s)}catch{return this.depth-=1,this.counters.rejected+=1,void this.setState(e.id,{status:"error",error:"port_rejected",sequence:n})}this.depth-=1,l&&"function"==typeof l.then?(this.setState(e.id,{status:"pending",sequence:n}),l.then(()=>{i()?(this.counters.settled+=1,this.pending.delete(e.id),this.setState(e.id,{status:"settled",sequence:n})):this.counters.stale+=1},()=>{i()?this.setState(e.id,{status:"error",error:"port_rejected",sequence:n}):this.counters.stale+=1})):(this.counters.settled+=1,this.pending.delete(e.id),this.setState(e.id,{status:"settled",sequence:n}))};r()}}function bt(e){return e?.parentElement?.closest?.("sf-composition-scope")||null}const wt=e=>"string"==typeof e?.localName&&e.localName.includes("-"),vt=e=>wt(e)&&!globalThis.customElements?.get(e.localName);function _t(e,t){if("function"==typeof e.sfPortInput||vt(e))return e;const n=[...e.querySelectorAll("*")].filter(e=>wt(e)&&"sf-composition-scope"!==e.localName&&bt(e)===t),o=n.filter(e=>"function"==typeof e.sfPortInput);if(1===o.length)return o[0];const i=n.filter(vt);return 0===o.length&&1===i.length?i[0]:null}function xt(e=globalThis.customElements){if(!e||"function"!=typeof globalThis.HTMLElement)return null;const t=e.get("sf-composition-scope");if(t)return t;class n extends globalThis.HTMLElement{constructor(){super(),this.routeController=null,this.routeDiagnostics=[]}connectedCallback(){if(!this.routeController){const e=function(e){let t;try{t=JSON.parse(e||"[]")}catch{return null}if(!Array.isArray(t)||t.length>Ue.maxRoutesPerScope)return null;const n=new Set;for(const e of t){if(!o(e)||"string"!=typeof e.id||!He.test(e.id))return null;for(const t of["from","to"]){const n=e[t];if(!(o(n)&&"string"==typeof n.endpoint&&"string"==typeof n.port&&We.test(n.endpoint)&&We.test(n.port)&&ut(n.value)))return null}if(!lt(e.from.value,e.to.value)||n.has(e.id))return null;n.add(e.id)}return t}(this.getAttribute("data-sf-routes"));if(!e)return this.routeDiagnostics=[{code:"routes_invalid",path:"data-sf-routes",message:"Rendered routes are invalid"}],void this.setAttribute("data-sf-routing","error");this.routeController=new yt(this,e,{sourceEndpoint:e=>{const t=e.target?.closest?.("[data-sf-endpoint]");return t&&bt(t)===this&&_t(t,this)===e.target?t.getAttribute("data-sf-endpoint"):null},targetEndpoint:e=>{const t=[...this.querySelectorAll("[data-sf-endpoint]")].filter(t=>t.getAttribute("data-sf-endpoint")===e&&bt(t)===this);return 1===t.length?_t(t[0],this):null},whenReady:e=>e.localName?.includes("-")&&globalThis.customElements?globalThis.customElements.whenDefined(e.localName):null,onState:e=>this.dispatchEvent(new globalThis.CustomEvent("sf-composition-route-state",{detail:e}))})}this.routeController.connect(),this.setAttribute("data-sf-routing","connected")}disconnectedCallback(){this.routeController?.disconnect(),this.routeController&&this.setAttribute("data-sf-routing","disposed")}getRouteState(e){return this.routeController?.getState(e)||null}getRoutingCounters(){return this.routeController?{...this.routeController.counters}:null}}return e.define("sf-composition-scope",n),n}const $t=["schema","id","element","regions","port","outputs","inputs","operation","url_state","budget"],kt=/^[a-z][a-z0-9-]*(?:\.[a-z][a-z0-9-]*)+$/u,St=/^[a-z][a-z0-9]*-[a-z0-9-]+$/u,Et=/^[a-z][a-z0-9-]{0,31}$/u,Ot=/^[a-z][a-z0-9.-]*$/u,Tt=/^[0-9]+\.[0-9]+\.[0-9]+$/u,jt=/^[a-z][a-z0-9._:-]{0,127}$/u,At=/^[a-z][a-z0-9_-]{0,63}$/u,Lt=(e,t)=>o(e)&&Object.keys(e).every(e=>t.includes(e)),Pt=(e,t,n)=>Array.isArray(e)&&e.length<=t&&new Set(e).size===e.length&&e.every(n);function zt(e,t){if(!o(e))return[`${t}: not an object`];const n=Object.keys(e),i=n.length>16?[`${t}: more than 16 ports`]:[];for(const o of n){const n=e[o];Et.test(o)||i.push(`${t}.${o}: name`),Lt(n,["value","summary"])?(null===at(n.value)&&i.push(`${t}.${o}: unknown value type ${n.value}`),("string"!=typeof n.summary||!n.summary.trim()||n.summary.length>1e3)&&i.push(`${t}.${o}: summary`)):i.push(`${t}.${o}: undeclared keys`)}return i}const Rt=["record-changed.v1","record-removed.v1","collection-changed.v1","files-moved.v1","counter.v1","navigation.v1","preference-changed.v1"],Ct=e=>at(e),Ft=Rt.map(Ct);const Nt={ru:{heading:"Не удалось показать этот блок"},en:{heading:"This block could not be shown"}};const It=new Set(["ui-layout","structured-content"]),Mt=new Set(["schema","schema_version","id","profile","locale","root","extensions"]),qt=new Set(["id","type","data","props","slots","presentation","bindings","extensions"]),Dt=new Set(["view","preset","modifiers"]),Bt=new Set(["owner","ref","target","revision"]),Ut=new Set(["html","innerhtml","script","javascript","php","eval","function","expression","query","sql","graphql","class","classname","rootclass","cssclass","secret","password","token","cookie","authorization","request"]),Wt=new Set(["http:","https:","mailto:","tel:"]),Ht=Object.freeze({maxDocumentBytes:1048576,maxDepth:32,maxNodes:2e3,maxChildrenPerSlot:500});function Vt(e,t,n,o={}){return{code:e,path:t,message:n,...o}}async function Zt(e){if(!globalThis.crypto?.subtle)throw new Error("composition_crypto_unavailable");const t=(new globalThis.TextEncoder).encode(e),n=await globalThis.crypto.subtle.digest("SHA-256",t);return[...new Uint8Array(n)].map(e=>e.toString(16).padStart(2,"0")).join("")}function Jt(e,t,n,i){if(o(e))for(const o of Object.keys(e))t.has(o)||i.push(Vt("unknown_field",`${n}.${o}`,`Unknown field ${o}`))}function Gt(e,t,n){if(Array.isArray(e))e.forEach((e,o)=>Gt(e,`${t}[${o}]`,n));else if(o(e))for(const[o,i]of Object.entries(e)){const e=o.toLowerCase().replaceAll("-","");Ut.has(e)&&n.push(Vt("executable_or_secret_field_forbidden",`${t}.${o}`,`Field ${o} is not portable composition data`)),Gt(i,`${t}.${o}`,n)}}function Xt(e,t,n,i=new Set){if(o(e))for(const s of Object.keys(e))/^[a-z][a-z0-9.-]*:[a-z][a-z0-9._-]*$/u.test(s)||n.push(Vt("extension_name_invalid",`${t}.${s}`,"Extension keys must be namespaced")),o(e[s])&&!0===e[s].required&&!i.has(s)&&n.push(Vt("extension_required_unknown",`${t}.${s}`,`Required extension ${s} is not supported`));else n.push(Vt("extensions_invalid",t,"Extensions must be an object"))}function Yt(e,t,n,i){if(!t)return;if(t.oneOf){return void(1!==t.oneOf.filter(t=>{const o=[];return Yt(e,t,n,o),0===o.length}).length&&i.push(Vt("schema_one_of",n,"Value must match exactly one allowed shape")))}if(void 0!==t.const&&e!==t.const)return void i.push(Vt("schema_const",n,`Value must equal ${t.const}`));if(t.enum&&!t.enum.includes(e))return void i.push(Vt("schema_enum",n,"Value is not in the allowed list"));const r=Array.isArray(t.type)?t.type:[t.type];if(t.type){const t=null===e?"null":Array.isArray(e)?"array":Number.isInteger(e)?"integer":"number"==typeof e?"number":typeof e;if(!r.includes(t)&&("integer"!==t||!r.includes("number"))&&("object"!==t||o(e)))return void i.push(Vt("schema_type",n,`Expected ${r.join(" or ")}`))}if("string"==typeof e&&(void 0!==t.minLength&&e.length<t.minLength&&i.push(Vt("schema_min_length",n,"String is too short")),void 0!==t.maxLength&&e.length>t.maxLength&&i.push(Vt("schema_max_length",n,"String is too long")),t.pattern&&!new RegExp(t.pattern,"u").test(e)&&i.push(Vt("schema_pattern",n,"String has an invalid format"))),"number"==typeof e&&(void 0!==t.minimum&&e<t.minimum&&i.push(Vt("schema_minimum",n,"Number is too small")),void 0!==t.maximum&&e>t.maximum&&i.push(Vt("schema_maximum",n,"Number is too large"))),Array.isArray(e)&&(void 0!==t.minItems&&e.length<t.minItems&&i.push(Vt("schema_min_items",n,"Array has too few items")),void 0!==t.maxItems&&e.length>t.maxItems&&i.push(Vt("schema_max_items",n,"Array has too many items")),t.uniqueItems&&new Set(e.map(s)).size!==e.length&&i.push(Vt("schema_unique_items",n,"Array items must be unique")),t.items&&e.forEach((e,o)=>Yt(e,t.items,`${n}[${o}]`,i))),o(e)){for(const o of t.required||[])o in e||i.push(Vt("schema_required",`${n}.${o}`,`Required field ${o} is missing`));if(!1===t.additionalProperties){const o=t.properties||{};for(const t of Object.keys(e))t in o||i.push(Vt("schema_additional_property",`${n}.${t}`,`Field ${t} is not allowed`))}for(const[o,s]of Object.entries(t.properties||{}))o in e&&Yt(e[o],s,`${n}.${o}`,i)}}function Kt(e){if(/^(?:\/|\.?\.\/|#)/u.test(e))return!e.startsWith("//")&&!e.includes("\\");try{return Wt.has(new globalThis.URL(e).protocol)}catch{return!1}}let Qt=null;function en(e){return e?.elements instanceof Map?e:Array.isArray(e)?ft(e):e&&Array.isArray(e.manifests)?ft(e.manifests,{bindings:e.bindings}):(Qt=Qt||ft($),Qt)}function tn(e){return e?.types instanceof Map?e:nn(Array.isArray(e)?e:x)}function nn(e=x,t={}){const n=new Map;for(const t of e){if(!o(t)||!(0,b.Wl)(t,"simai.composition.type-manifest",1))throw new TypeError("composition_manifest_invalid");if(n.has(t.type))throw new TypeError(`composition_manifest_duplicate:${t.type}`);n.set(t.type,i(t))}return{types:n,renderers:new Map(Object.entries(t))}}function on(e,t=void 0,n={}){const i=[],s=tn(t),r={...Ht,...n.limits||{}},a=new Set([Be,...n.supportedExtensions||[]]);let l;try{l=JSON.stringify(e)}catch{return{valid:!1,diagnostics:[Vt("document_not_json","$","Document must be JSON serializable")]}}if((new globalThis.TextEncoder).encode(l).byteLength>r.maxDocumentBytes&&i.push(Vt("document_too_large","$","Document exceeds the byte limit")),!o(e))return{valid:!1,diagnostics:[Vt("document_invalid","$","Document must be an object")]};Jt(e,Mt,"$",i),(0,b.Wl)(e,"simai.composition.document",1)||i.push(Vt("schema_unknown","$.schema","Expected simai.composition.document.v1, or simai.composition.document with schema_version 1")),"string"==typeof e.id&&/^[a-zA-Z0-9][a-zA-Z0-9._:-]{0,119}$/u.test(e.id)||i.push(Vt("document_id_invalid","$.id","Document id is invalid")),It.has(e.profile)||i.push(Vt("profile_unknown","$.profile","Profile is not supported")),void 0===e.locale||"string"==typeof e.locale&&/^[a-zA-Z]{2,8}(?:-[a-zA-Z0-9]{1,8})*$/u.test(e.locale)||i.push(Vt("locale_invalid","$.locale","Locale is invalid")),void 0!==e.extensions&&Xt(e.extensions,"$.extensions",i,a),Gt(e,"$",i);const c=new Set;let u=0;const d=(t,n,l)=>{if(u+=1,u>r.maxNodes)return;if(l>r.maxDepth&&i.push(Vt("depth_limit",n,"Composition is too deeply nested")),!o(t))return void i.push(Vt("node_invalid",n,"Node must be an object"));Jt(t,qt,n,i),"string"==typeof t.id&&/^[a-zA-Z0-9][a-zA-Z0-9._:-]{0,119}$/u.test(t.id)?c.has(t.id)?i.push(Vt("node_id_duplicate",`${n}.id`,`Duplicate node id ${t.id}`)):c.add(t.id):i.push(Vt("node_id_invalid",`${n}.id`,"Node id is invalid"));const f=s.types.get(t.type);if(!f)return void i.push(Vt("type_unknown",`${n}.type`,`Unknown type ${t.type||""}`));if(f.profiles.includes(e.profile)||i.push(Vt("type_profile_unsupported",`${n}.type`,`${t.type} does not support ${e.profile}`)),Yt(t.data||{},f.data_schema,`${n}.data`,i),Yt(t.props||{},f.props_schema,`${n}.props`,i),"content.heading"!==t.type&&"content.paragraph"!==t.type||function(e,t,n){if(Array.isArray(e))for(let o=0;o<e.length;o+=1){const i=e[o];"link"!==i?.type||Kt(i.href)||n.push(Vt("unsafe_url",`${t}[${o}].href`,"Link protocol is not allowed"))}}(t.data?.content,`${n}.data.content`,i),void 0!==t.presentation)if(o(t.presentation)){Jt(t.presentation,Dt,`${n}.presentation`,i);const e=f.presentation||{};if(t.presentation.view&&!(e.views||[]).includes(t.presentation.view)&&i.push(Vt("view_unknown",`${n}.presentation.view`,"View is not registered")),t.presentation.preset&&!(e.presets||[]).includes(t.presentation.preset)&&i.push(Vt("preset_unknown",`${n}.presentation.preset`,"Preset is not registered")),void 0!==t.presentation.modifiers)if(Array.isArray(t.presentation.modifiers))for(const o of t.presentation.modifiers)(e.modifiers||[]).includes(o)||i.push(Vt("modifier_unknown",`${n}.presentation.modifiers`,`Modifier ${o} is not registered`));else i.push(Vt("modifiers_invalid",`${n}.presentation.modifiers`,"Modifiers must be an array"))}else i.push(Vt("presentation_invalid",`${n}.presentation`,"Presentation must be an object"));void 0!==t.extensions&&Xt(t.extensions,`${n}.extensions`,i,a),void 0!==t.bindings&&(Array.isArray(t.bindings)?t.bindings.forEach((e,t)=>{const s=`${n}.bindings[${t}]`;if(o(e)){Jt(e,Bt,s,i);for(const t of["owner","ref","target"])"string"==typeof e[t]&&e[t]||i.push(Vt("binding_field_invalid",`${s}.${t}`,`${t} is required`));void 0===e.revision||"string"==typeof e.revision&&e.revision||i.push(Vt("binding_revision_invalid",`${s}.revision`,"Revision must be a non-empty string"))}else i.push(Vt("binding_invalid",s,"Binding must be an object"))}):i.push(Vt("bindings_invalid",`${n}.bindings`,"Bindings must be an array")));const p=t.slots||{};if(o(p)){"leaf"===f.mode&&Object.keys(p).length&&i.push(Vt("leaf_slots_forbidden",`${n}.slots`,"Leaf type cannot contain slots"));for(const[e,t]of Object.entries(p)){const o=f.slots?.[e];o?Array.isArray(t)?((t.length>r.maxChildrenPerSlot||t.length>o.max||t.length<o.min)&&i.push(Vt("slot_cardinality",`${n}.slots.${e}`,"Slot child count is outside the allowed range")),t.forEach((t,r)=>{const a=s.types.get(t?.type);a&&o.types&&!o.types.includes(t.type)&&i.push(Vt("slot_child_type_forbidden",`${n}.slots.${e}[${r}]`,`${t.type} is not allowed in this slot`)),a&&o.categories&&!o.categories.includes(a.category)&&i.push(Vt("slot_child_category_forbidden",`${n}.slots.${e}[${r}]`,`${a.category} is not allowed in this slot`)),d(t,`${n}.slots.${e}[${r}]`,l+1)})):i.push(Vt("slot_children_invalid",`${n}.slots.${e}`,"Slot children must be an array")):i.push(Vt("slot_unknown",`${n}.slots.${e}`,`Slot ${e} is not registered`))}for(const[e,t]of Object.entries(f.slots||{}))t.min>0&&!(e in p)&&i.push(Vt("slot_required",`${n}.slots.${e}`,`Slot ${e} is required`))}else i.push(Vt("slots_invalid",`${n}.slots`,"Slots must be an object"))};return d(e.root,"$.root",1),u>r.maxNodes?i.push(Vt("node_limit","$.root","Composition has too many nodes")):(h(e.root,s,i),gt(e.root,s,en(n.ports),i)),{valid:0===i.length,diagnostics:i}}async function sn(e,t=void 0,n={}){const o=tn(t),r=on(e,o,n);if(!r.valid)return{document:null,digest:null,dependencies:{assets:[],bindings:[]},diagnostics:r.diagnostics};const a=i(JSON.parse(JSON.stringify(e))),l={assets:new Set,bindings:new Map},c=e=>{!function(e,t,n){for(const e of t.assets||[])n.assets.add(e);for(const t of e.bindings||[])n.bindings.set(`${t.owner}:${t.ref}:${t.target}:${t.revision||""}`,i(t))}(e,o.types.get(e.type),l),Object.values(e.slots||{}).flat().forEach(c)};return c(a.root),{document:a,digest:await Zt(s(a)),dependencies:{assets:[...l.assets].sort(),bindings:[...l.bindings.values()].sort((e,t)=>s(e).localeCompare(s(t)))},diagnostics:[]}}function rn(e){return String(e).replaceAll("&","&amp;").replaceAll("<","&lt;").replaceAll(">","&gt;").replaceAll('"',"&quot;").replaceAll("'","&#39;")}function an(e){return(e||[]).map(e=>{if("link"===e.type)return`<a href="${rn(e.href)}">${an(e.children)}</a>`;let t=rn(e.value);for(const n of e.marks||[])t="strong"===n?`<strong>${t}</strong>`:"em"===n?`<em>${t}</em>`:`<code>${t}</code>`;return t}).join("")}const ln={"layout.page":({node:e,slots:t})=>`<main data-sf-composition-id="${rn(e.id)}">${t.default||""}</main>`,"layout.section":({node:e,slots:t})=>`<section data-sf-composition-id="${rn(e.id)}">${t.default||""}</section>`,"layout.columns":({node:e,slots:t})=>{const n=Number.isInteger(e.props?.columns)?` data-composition-columns="${e.props.columns}"`:"";return`<div class="sf-composition-columns" data-sf-composition-id="${rn(e.id)}"${n}>${(t.columnsList||[]).map(e=>`<div class="sf-composition-column">${e}</div>`).join("")}</div>`},"content.heading":({node:e})=>`<h${e.data.level||2} data-sf-composition-id="${rn(e.id)}">${an(e.data.content)}</h${e.data.level||2}>`,"content.paragraph":({node:e})=>`<p data-sf-composition-id="${rn(e.id)}">${an(e.data.content)}</p>`,"layout.regions":({node:e,slots:t})=>`<div class="sf-composition-regions" data-sf-composition-id="${rn(e.id)}"><div class="sf-composition-regions-grid">${t.regions||""}</div></div>`,"layout.region":({node:e,slots:t})=>{const n=e.props,o=u[n.landmark],i=!0===n.sticky?' data-sf-region-sticky=""':"",s=void 0!==n.label?` aria-label="${rn(n.label)}"`:"";return`<${o} class="sf-composition-region" data-sf-composition-id="${rn(e.id)}" data-sf-region="${rn(n.name)}" data-sf-region-placement="${rn(n.placement??"block")}"${i}${s}>${t.default||""}</${o}>`},"layout.scope":({node:e,slots:t,routes:n})=>`<sf-composition-scope data-sf-composition-id="${rn(e.id)}" data-sf-routes="${rn(function(e){return s(e.map(e=>({id:e.id,from:{endpoint:e.from.endpoint,port:e.from.port,value:e.from.value},to:{endpoint:e.to.endpoint,port:e.to.port,value:e.to.value}})))}(n||[]))}">${t.default||""}</sf-composition-scope>`};const cn=Object.freeze({BUILTIN_EDITOR_MANIFESTS:k,BUILTIN_FIELD_KINDS:V,BUILTIN_PORT_MANIFESTS:$,Recipe:Ae,applyFieldValue:Q,parseFieldSubmission:K,renderFieldFallback:te,resolveFieldKind:G,validateFieldKinds:Y,validateFieldValue:X,VALUE_TYPES:it,checkPortValue:dt,checkFragmentDescriptor:function(e){if(!o(e))return["descriptor: not an object"];const t=[],n=Object.keys(e);for(const e of $t)n.includes(e)||t.push(`${e}: required`);for(const e of n)$t.includes(e)||"schema_version"===e||t.push(`${e}: undeclared`);(0,b.Wl)(e,"simai.interface-fragment",1)||t.push("schema: not simai.interface-fragment, schema_version 1"),"string"==typeof e.id&&kt.test(e.id)||t.push("id: a dotted identity"),"string"==typeof e.element&&St.test(e.element)||t.push("element: a custom element name"),Pt(e.regions,8,e=>"string"==typeof e&&Et.test(e))&&e.regions.length||t.push("regions: one to eight region names");const i=e.port;Lt(i,["standard","version"])&&Ot.test(i?.standard??"")&&Tt.test(i?.version??"")||t.push("port: {standard, version}"),"outputs"in e&&t.push(...zt(e.outputs,"outputs")),"inputs"in e&&t.push(...zt(e.inputs,"inputs")),"string"==typeof e.operation&&jt.test(e.operation)||t.push("operation: an access operation token"),Pt(e.url_state,16,e=>"string"==typeof e&&At.test(e))||t.push("url_state: up to sixteen query keys");const s=e.budget;return(!Lt(s,["kb","first_answer_ms"])||!Number.isSafeInteger(s.kb)||s.kb<0||s.kb>2048||!Number.isSafeInteger(s.first_answer_ms)||s.first_answer_ms<0||s.first_answer_ms>1e4)&&t.push("budget: {kb 0-2048, first_answer_ms 0-10000}"),t},FRAGMENT_DESCRIPTOR_SCHEMA:"simai.interface-fragment.v1",publishEffects:function(e,{origin:t=null}={}){if(!Array.isArray(e)||!e.length)return{published:[],refused:[]};const n=globalThis.document,o=t?.closest?.("sf-composition-scope"),i=o?[...o.querySelectorAll("sf-page-host")].filter(e=>e.parentElement?.closest("sf-composition-scope")===o):[...n?.querySelectorAll("sf-page-host")??[]],s=1===i.length?i[0]:null;return s&&"function"==typeof s.publish?s.publish(e):{published:[],refused:e.map(e=>({type:e?.type??null,reason:"no_page_host"}))}},createPortRegistry:ft,defineCompositionScope:xt,startInlineEdit:function(e,t){const n=globalThis.SF?.InlineEditor;if("function"!=typeof n?.startInlineEdit)throw new TypeError("inline_editor_not_loaded");return n.startInlineEdit(e,t)},normalizeInline:qe,inlineText:De,BUILTIN_TYPE_MANIFESTS:x,createRegistry:nn,extendRegistry:function(e=[],t={}){return nn([...x,...e],t)},compositionTypeFromSmartManifest:function(e){const t=e?.composition?.declarative;if(!t)return null;const n=e.inputs?.properties||{},o=Object.fromEntries(Object.entries(t.data||{}).map(([n,o])=>{const i=e.contracts?.[o.contract];if(!i)throw new TypeError(`composition_data_contract_missing:${t.type}:${n}`);return[n,i]})),i=Object.fromEntries((t.events||[]).filter(t=>e.events?.[t]).map(t=>[t,{summary:e.events[t].summary,payload:e.events[t].payload}])),s=e.persistence?{mode:e.persistence.mode,source_of_truth:e.persistence.source_of_truth,network_owner:e.persistence.network_owner,settings_key_prop:t.persistence?.settings_key_prop??null,revision_prop:t.persistence?.revision_prop??null}:void 0;return{...(0,b.xZ)("simai.composition.type-manifest",1),type:t.type,version:e.version,category:"smart",mode:t.mode,profiles:t.profiles,data_schema:{type:"object",additionalProperties:!1,properties:o},props_schema:{type:"object",additionalProperties:!1,properties:(r=t.props,Object.fromEntries(Object.entries(n).filter(([e])=>new Set(r||[]).has(e))))},presentation:t.presentation||{views:["default"],presets:[],modifiers:[]},slots:t.slots||{},renderer:t.renderer,assets:t.assets||[],capabilities:["html","hydration"],...Object.keys(i).length?{events:i}:{},...s?{persistence:s}:{}};var r},describeRegions:y,normalize:sn,projectDocumentEditorFields:U,projectEditorFields:B,render:async function(e,t={}){const n=tn(t.registry),o=await sn(e,n,t.options||{});if(!o.document)return{html:"",assets:[],hydration:[],diagnostics:o.diagnostics,digest:null};const i=[],s=[],r=gt(o.document.root,n,en(t.options?.ports),[]),a=async e=>{const l=n.types.get(e.type),c={};for(const[t,n]of Object.entries(e.slots||{})){const e=[];for(const t of n)e.push(await a(t));c[t]=e.join(""),c[`${t}List`]=e}const u={};for(const n of e.bindings||[])t.resolveBinding&&(u[n.target]=await t.resolveBinding(n,{document:o.document,node:e}));let d=n.renderers.get(l.renderer.name)||ln[l.renderer.name];return!d&&"custom-element"===l.renderer.kind&&l.renderer.name&&(d=({node:e,slots:t,endpoint:n})=>{const o=n?` data-sf-endpoint="${rn(n)}"`:"",i=Object.entries(e.props||{}).map(([e,t])=>` ${rn(e)}="${rn(t)}"`).join("")+o;return s.push({id:e.id,type:e.type,element:l.renderer.name}),`<${l.renderer.name}${i}>${Object.values(t).filter(e=>"string"==typeof e).join("")}</${l.renderer.name}>`}),d?("layout.scope"===e.type&&s.push({id:e.id,type:e.type,element:"sf-composition-scope"}),d({node:e,slots:c,context:t,resolvedBindings:u,manifest:l,routes:r.get(e.id),endpoint:ht(e)})):(i.push(Vt("renderer_unavailable",`node:${e.id}`,`Renderer ${l.renderer.name} is unavailable`)),"")};return{html:await a(o.document.root),assets:o.dependencies.assets,hydration:s,diagnostics:i,digest:o.digest}},resolveRecipe:je,parseRecipeJson:be,stableStringify:s,validate:on,validateEditorManifest:D});"undefined"!=typeof globalThis&&(globalThis.SF=globalThis.SF||{},globalThis.SF.Composition=cn,xt(),function(e=globalThis.customElements){if(!e||"function"!=typeof globalThis.HTMLElement)return null;const t=e.get("sf-page-host");if(t)return t;class n extends globalThis.HTMLElement{static sfPorts=Object.freeze({outputs:Object.freeze(Object.fromEntries(Rt.map(e=>[Ct(e),e]))),inputs:Object.freeze({})});connectedCallback(){this.hidden=!0}sfPortInput(){throw new TypeError("sf-page-host has no inputs")}publish(e=[]){const t=[],n=[];for(const o of Array.isArray(e)?e:[]){const e=o?.type;if(!Ft.includes(at(e))){n.push({type:e??null,reason:"type_not_published"});continue}let i;try{i=ct(e).check(o.value)}catch(t){n.push({type:e,reason:"value_invalid",message:String(t?.message??t)});continue}this.dispatchEvent(new globalThis.CustomEvent("sf-port-output",{bubbles:!0,detail:{port:Ct(e),value:i}})),t.push(e)}return n.length&&this.dispatchEvent(new globalThis.CustomEvent("sf-page-host-refused",{bubbles:!0,detail:{refused:n}})),{published:t,refused:n}}}e.define("sf-page-host",n)}(),function(e=globalThis.customElements){if(!e||"function"!=typeof globalThis.HTMLElement)return null;const t=e.get("sf-fragment");if(t)return t;class n extends globalThis.HTMLElement{constructor(){super(),this.markup=null,this.failed=null,this.timer=null,this.onError=e=>{this.failed||(e.stopPropagation(),this.fail(e.detail?.phase??"render",e.detail?.message??""))},this.onAction=e=>{this.failed&&"retry"===e.detail?.id&&(e.stopPropagation(),this.retry())}}connectedCallback(){null===this.markup&&(this.markup=this.innerHTML),this.addEventListener("sf-component-error",this.onError),this.addEventListener("sf-empty-state-action",this.onAction),this.failed||this.watchLoad()}disconnectedCallback(){clearTimeout(this.timer),this.removeEventListener("sf-component-error",this.onError),this.removeEventListener("sf-empty-state-action",this.onAction)}get fragmentElement(){return[...this.children].find(e=>e.localName.includes("-"))??null}watchLoad(){clearTimeout(this.timer);const e=this.fragmentElement;if(!e||globalThis.customElements.get(e.localName))return;const t=Number(this.getAttribute("load-timeout"))||1e4;this.timer=setTimeout(()=>{!globalThis.customElements.get(e.localName)&&e.isConnected&&this.fail("load",`${e.localName} did not load`)},t)}text(e){const t=(this.closest("[lang]")?.getAttribute("lang")||"en").slice(0,2);return(Nt[t]??Nt.en)[e]}fail(e,t){clearTimeout(this.timer),this.failed={phase:e,message:t},this.setAttribute("data-sf-fragment-state","error");const n=globalThis.document.createElement("sf-empty-state");n.setAttribute("kind","error"),n.setAttribute("title",this.text("heading")),this.replaceChildren(n),this.dispatchEvent(new globalThis.CustomEvent("sf-fragment-error",{bubbles:!0,composed:!0,detail:{fragment:this.getAttribute("data-sf-fragment"),phase:e,message:t}}))}retry(){this.failed=null,this.removeAttribute("data-sf-fragment-state"),this.innerHTML=this.markup??"",this.watchLoad(),this.dispatchEvent(new globalThis.CustomEvent("sf-fragment-retry",{bubbles:!0,composed:!0,detail:{fragment:this.getAttribute("data-sf-fragment")}}))}}e.define("sf-fragment",n)}())},ac24888e7d3e(e,t,n){"use strict";n.d(t,{G7:()=>i,Wl:()=>s,xZ:()=>r});const o=/^(.+)\.v([0-9]+)$/u;function i(e){const t=e?.schema??e?.schema_id;if("string"!=typeof t||!t)return null;const n=t.match(o);if(n)return{name:n[1],version:Number(n[2]),form:"versioned-name"};const i=e?.schema_version;return{name:t,version:Number.isInteger(i)?i:null,form:"name"}}function s(e,t,n){const o=i(e);return!(!o||o.name!==t||o.version!==n)&&(void 0===e.schema_version||e.schema_version===n)}function r(e,t){if(o.test(e))throw new TypeError(`A format name carries no version: ${e}`);if(!Number.isInteger(t)||t<1)throw new TypeError(`A format's version is a whole major: ${t}`);return{schema:e,schema_version:t}}}};const t={};function n(o){const i=t[o];if(void 0!==i)return i.exports;const s=t[o]={exports:{}};return e[o](s,s.exports,n),s.exports}n.m=e,n.n=e=>{const t=e&&e.__esModule?()=>e.default:()=>e;return n.d(t,{a:t}),t},n.d=(e,t)=>{if(Array.isArray(t))for(var o=0;o<t.length;){var i=t[o++],s=t[o++];n.o(e,i)?0===s&&o++:0===s?Object.defineProperty(e,i,{enumerable:!0,value:t[o++]}):Object.defineProperty(e,i,{enumerable:!0,get:s})}else for(var i in t)n.o(t,i)&&!n.o(e,i)&&Object.defineProperty(e,i,{enumerable:!0,get:t[i]})},n.f={},n.e=e=>Promise.all(Object.keys(n.f).reduce((t,o)=>(n.f[o](e,t),t),[])),n.u=e=>"js/"+{80841737880868:"core-rules",88616323197113:"core-system",66700837013363:"core-loader"}[e]+".min.js",n.miniCssF=e=>"css/core.min.css",n.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(e){if("object"==typeof window)return window}}(),n.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),(()=>{const e={};n.l=(t,o,i,s)=>{if(e[t])return void e[t].push(o);let r,a;if(void 0!==i){const e=document.getElementsByTagName("script");for(var l=0;l<e.length;l++){const n=e[l];if(n.getAttribute("src")==t){r=n;break}}}r||(a=!0,r=document.createElement("script"),r.charset="utf-8",n.nc&&r.setAttribute("nonce",n.nc),r.src=t),e[t]=[o];const c=(n,o)=>{r.onerror=r.onload=null,clearTimeout(u);const i=e[t];if(delete e[t],r.parentNode?.removeChild(r),i?.forEach(e=>e(o)),n)return n(o)},u=setTimeout(c.bind(null,void 0,{type:"timeout",target:r}),12e4);r.onerror=c.bind(null,r.onerror),r.onload=c.bind(null,r.onload),a&&document.head.appendChild(r)}})(),n.r=e=>{Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},(()=>{let e;n.g.importScripts&&(e=n.g.location+"");const t=n.g.document;if(!e&&t&&("SCRIPT"===t.currentScript?.tagName.toUpperCase()&&(e=t.currentScript.src),!e)){const n=t.getElementsByTagName("script");if(n.length){let t=n.length-1;for(;t>-1&&(!e||!/^http(s?):/.test(e));)e=n[t--].src}}if(!e)throw new Error("Automatic publicPath is not supported in this browser");e=e.replace(/^blob:/,"").replace(/#.*$/,"").replace(/\?.*$/,"").replace(/\/[^\/]+$/,"/"),n.p=e+"../"})(),(()=>{const e={20514231357218:0};n.f.j=(t,o)=>{let i=n.o(e,t)?e[t]:void 0;if(0!==i)if(i)o.push(i[2]);else{const s=new Promise((n,o)=>i=e[t]=[n,o]);o.push(i[2]=s);const r=n.p+n.u(t),a=new Error,l=o=>{if(n.o(e,t)&&(i=e[t],0!==i&&(e[t]=void 0),i)){const e=o&&("load"===o.type?"missing":o.type),n=o&&o.target&&o.target.src;a.message="Loading chunk "+t+" failed.\n("+e+": "+n+")",a.name="ChunkLoadError",a.type=e,a.request=n,i[1](a)}};n.l(r,l,"chunk-"+t,t)}};const t=(t,o)=>{let[i,s,r]=o;var a,l,c=0;if(i.some(t=>0!==e[t])){for(a in s)n.o(s,a)&&(n.m[a]=s[a]);if(r)r(n)}for(t&&t(o);c<i.length;c++)l=i[c],n.o(e,l)&&e[l]&&e[l][0](),e[l]=0},o=self.webpackChunk=self.webpackChunk||[];o.forEach(t.bind(null,0)),o.push=t.bind(null,o.push.bind(o))})(),(()=>{"use strict";n("3924cca3566b");function e(){const e=globalThis.SF=globalThis.SF||{};return e.__deprecationNotes instanceof Map||Object.defineProperty(e,"__deprecationNotes",{value:new Map,configurable:!0}),e.__deprecationNotes}function t({component:t="",kind:n="attribute",attribute:o="",from:i,to:s=null}={}){if(!i)return;const r=[t,n,o,i].join("|"),a=e(),l=a.get(r);if(l)l.count+=1;else if(a.set(r,{component:t,kind:n,attribute:o,from:i,to:s,count:1}),function(){const e=globalThis.document?.documentElement;return"warn"===e?.dataset?.sfDeprecations||!0===globalThis.SF?.deprecations?.warn}()){const e=t?`${t}: `:"",r="value"===n?`${o}="${i}"`:`${n} ${i}`;globalThis.console?.warn?.(`[Simai Framework] ${e}${r} is a legacy name${s?`; write ${s}`:""}. See contracts/changes/journal.json.`)}}if("undefined"!=typeof globalThis){globalThis.SF=globalThis.SF||{};const n=globalThis.SF.deprecations||{};n.list=function(){return[...e().values()].map(e=>({...e}))},n.clear=function(){e().clear()},n.note=t,globalThis.SF.deprecations=n}const o=Object.freeze(["send","receive","runtimeModules","runtimeArrived","runtimeLoading","runtimeSettled","smartBaseAnnounced","litHtml"]);"undefined"!=typeof globalThis&&function(e=globalThis){const n=e.SF=e.SF||{};n.__internal&&"object"==typeof n.__internal||Object.defineProperty(n,"__internal",{value:{},configurable:!0,enumerable:!1,writable:!1});const i=n.__internal;for(const e of o){const o=Object.getOwnPropertyDescriptor(n,e);if(o?.get?.sfInternalAlias)continue;o&&"value"in o&&!(e in i)&&(i[e]=o.value);const s=()=>(t({kind:"global",from:`SF.${e}`,to:`SF.__internal.${e}`}),i[e]);s.sfInternalAlias=!0,Object.defineProperty(n,e,{configurable:!0,enumerable:!1,get:s,set(t){i[e]=t}})}}(globalThis);n("987c832cfe13");function i(e){return String(e??"").replace(/\D+/g,"")}const s={0:e=>/\d/u.test(e),a:e=>/\p{L}/u.test(e),"*":()=>!0};function r(e){const t=[];let n=!1;for(let o=0;o<e.length;o+=1){const i=e[o];"\\"===i?(o+=1,o<e.length&&t.push({fixed:e[o],unmasked:n})):"{"===i?n=!0:"}"===i?n=!1:"["===i||"]"===i||(s[i]?t.push({test:s[i]}):t.push({fixed:i,unmasked:n}))}return t}function a(e,t,n={},o=-1){const i=n.placeholderChar||"_",s=String(e??""),r=t.filter(e=>e.test),a=[];let l=0,c=0;for(let e=0;e<s.length;e+=1){const u=s[e];for(;c<t.length&&void 0!==t[c].fixed&&t[c].fixed!==u;)c+=1;if(c>=t.length){!1===n.lazy&&a.length<r.length&&r[a.length].test(u)&&(a.push(u),e<o&&(l=a.length));continue}const d=t[c];void 0!==d.fixed||!1===n.lazy&&u===i?c+=1:d.test(u)&&(a.push(u),e<o&&(l=a.length),c+=1)}return{accepted:a,before:l}}function l(e,t,n={}){const o=n.placeholderChar||"_",i=!1===n.lazy;let s="",r="";const a=[];let l=-1,c=0;for(const n of t)if(void 0!==n.fixed){if(c>=e.length&&!i)break;s+=n.fixed,n.unmasked&&c<e.length&&(r+=n.fixed)}else if(c<e.length)0===c&&(l=s.length),s+=e[c],r+=e[c],c+=1,a[c]=s.length;else{if(!i)break;s+=o}return i||0!==c||(s=""),a[0]=l>=0?l:i&&s.includes(o)?s.indexOf(o):s.length,{display:s,unmasked:r,caretAfter:a}}function c(e){const{mask:t}=e;return t===Number||"Number"===t||"function"==typeof t&&"Number"===t.name&&1===t(" 1 ")}function u(e){return e.radix||","}function d(e,t={}){let n=String(e??"");t.thousandsSeparator&&(n=n.replaceAll(t.thousandsSeparator,"")),n=n.replace(/\s+/gu,"");const o=u(t);if("."!==o&&(n=n.replace(o,".")),""===n||"-"===n||"."===n)return null;const i=Number(n);return Number.isFinite(i)?i:null}function f(e,t){return t?e.replace(/\B(?=(\d{3})+(?!\d))/gu,t):e}function p(e,t={},n=-1){const o=u(t),i=new Set([o,...t.mapToRadix||[".",","]]),s=Math.max(0,Number(t.scale??2)||0),r=!0===t.signed||Number.isFinite(t.min)&&t.min<0;let a=!1,l="",c="",d=!1,p=0;const m=String(e??"");for(let e=0;e<m.length;e+=1){const o=m[e],u=e<n;if(/\d/u.test(o)){if(d){if(c.length>=s)continue;c+=o}else l+=o;u&&(p+=1)}else"-"!==o||!r||a||l||d?i.has(o)&&o!==t.thousandsSeparator&&s>0&&!d&&(d=!0,u&&(p+=1)):(a=!0,u&&(p+=1))}!1!==t.normalizeZeros&&(l=l.replace(/^0+(?=\d)/u,"")),d&&!l&&(l="0");return{display:`${a?"-":""}${f(l,t.thousandsSeparator)}`+(d?`${o}${c}`:""),typedBefore:p}}function m(e,t={}){if(""===e||null==e)return"";const n="number"==typeof e?e:d(p(e,t).display,t);if(null===n||!Number.isFinite(n))return"";const o=Number.isFinite(t.min)?t.min:n,i=Number.isFinite(t.max)?t.max:n,s=Math.min(i,Math.max(o,n)),r=Math.max(0,Number(t.scale??2)||0),a=s.toFixed(r),[l,c=""]=(t.padFractionalZeros?a:String(Number(a))).split(".");return`${l.startsWith("-")?"-":""}${f(l.replace("-",""),t.thousandsSeparator)}${c?`${u(t)}${c}`:""}`}function h(e,t={}){if(c(t))return m(e,t);if("function"==typeof t.mask)return String(t.mask(e));if(t.mask instanceof RegExp){const n=String(e??"");return t.mask.test(n)?n:n.slice(0,-1)}return function(e,t,n={}){if("string"!=typeof t||""===t)return String(e??"");const o=r(t);return l(a(e,o,n).accepted,o,n).display}(e,t.mask,t)}function g(e){try{return"number"==typeof e.selectionStart?e.selectionStart:-1}catch{return-1}}function y(e,t){if(!(t<0||"function"!=typeof e.setSelectionRange)&&e.ownerDocument?.activeElement===e)try{e.setSelectionRange(t,t)}catch{}}function b(e,t){const n={destroyed:!1},o="string"!=typeof t.mask||c(t)?null:r(t.mask),s=(t,n)=>{t!==e.value&&(e.value=t),y(e,n)},f=()=>{if(n.destroyed)return;const i=g(e);if(o){const{accepted:n,before:r}=a(e.value,o,t,i),c=l(n,o,t);s(c.display,i<0?-1:c.caretAfter[r]??c.display.length)}else if(c(t)){const{display:n,typedBefore:o}=p(e.value,t,i);let r=n.length;if(i>=0){let e=0;r=0;const i=u(t);for(;r<n.length&&e<o;){const t=n[r];(/\d/u.test(t)||t===i||"-"===t)&&(e+=1),r+=1}}s(n,i<0?-1:r)}else s(h(e.value,t),-1)},b=()=>{if(n.destroyed||!c(t))return;const o=m(e.value,t);o!==e.value&&(e.value=o)},w=()=>{if(n.destroyed||!o||!1!==t.lazy)return;const i=g(e),s="number"==typeof e.selectionEnd?e.selectionEnd:i;if(i<0||i!==s)return;const{accepted:r}=a(e.value,o,t),c=l(r,o,t),u=c.caretAfter[r.length]??c.display.length;i>u&&y(e,u)},v=()=>{!n.destroyed&&o&&!1===t.lazy&&setTimeout(w,0)};e.addEventListener("input",f),e.addEventListener("blur",b),e.addEventListener("focus",v),e.addEventListener("click",w),c(t)?""!==e.value&&(e.value=m(e.value,t)):f();return{get value(){return e.value},set value(n){e.value=h(n,t)},get unmaskedValue(){return(()=>{if(o)return l(a(e.value,o,t).accepted,o,t).unmasked;if(c(t)){const n=d(e.value,t);return null===n?"":String(n)}return i(e.value)})()},set unmaskedValue(n){e.value=h(o?String(n??""):i(n),t)},get typedValue(){return c(t)&&""!==e.value.trim()?d(e.value,t):null},set typedValue(n){e.value=h(n,t)},updateValue:f,destroy(){n.destroyed||(n.destroyed=!0,e.removeEventListener("input",f),e.removeEventListener("blur",b),e.removeEventListener("focus",v),e.removeEventListener("click",w))}}}const w={load:async()=>b,async create(e,t){const n=function(e){return e?e instanceof HTMLElement?e:"string"==typeof e?document.querySelector(e):null:null}(e);return n&&t?b(n,t):null},pipe:async(e,t)=>h(e,"object"==typeof t?t:{mask:t}),destroy(e){e?.destroy?.()}};(window.SF||(window.SF={}),window.SF).Mask=w,"function"==typeof window.dispatchEvent&&"function"==typeof CustomEvent&&window.dispatchEvent(new CustomEvent("sf-mask-ready"));n("3a00b12d226d");const v=Math.min,_=Math.max,x=Math.round,$=Math.floor,k=e=>({x:e,y:e}),S={left:"right",right:"left",bottom:"top",top:"bottom"};function E(e,t){return"function"==typeof e?e(t):e}function O(e){return e.split("-")[0]}function T(e){return e.split("-")[1]}function j(e){return"x"===e?"y":"x"}function A(e){return"y"===e?"height":"width"}function L(e){const t=e[0];return"t"===t||"b"===t?"y":"x"}function P(e){return j(L(e))}function z(e){return e.includes("start")?e.replace("start","end"):e.replace("end","start")}const R=["left","right"],C=["right","left"],F=["top","bottom"],N=["bottom","top"];function I(e,t,n,o){const i=T(e);let s=function(e,t,n){switch(e){case"top":case"bottom":return n?t?C:R:t?R:C;case"left":case"right":return t?F:N;default:return[]}}(O(e),"start"===n,o);return i&&(s=s.map(e=>e+"-"+i),t&&(s=s.concat(s.map(z)))),s}function M(e){const t=O(e);return S[t]+e.slice(t.length)}function q(e){const{x:t,y:n,width:o,height:i}=e;return{width:o,height:i,top:n,left:t,right:t+o,bottom:n+i,x:t,y:n}}function D(e,t,n){let{reference:o,floating:i}=e;const s=L(t),r=P(t),a=A(r),l=O(t),c="y"===s,u=o.x+o.width/2-i.width/2,d=o.y+o.height/2-i.height/2,f=o[a]/2-i[a]/2;let p;switch(l){case"top":p={x:u,y:o.y-i.height};break;case"bottom":p={x:u,y:o.y+o.height};break;case"right":p={x:o.x+o.width,y:d};break;case"left":p={x:o.x-i.width,y:d};break;default:p={x:o.x,y:o.y}}const m=T(t);return m&&(p[r]+=f*("end"===m?1:-1)*(n&&c?-1:1)),p}async function B(e,t){var n;void 0===t&&(t={});const{x:o,y:i,platform:s,rects:r,elements:a,strategy:l}=e,{boundary:c="clippingAncestors",rootBoundary:u="viewport",elementContext:d="floating",altBoundary:f=!1,padding:p=0}=E(t,e),m=function(e){return"number"!=typeof e?function(e){var t,n,o,i;return{top:null!=(t=e.top)?t:0,right:null!=(n=e.right)?n:0,bottom:null!=(o=e.bottom)?o:0,left:null!=(i=e.left)?i:0}}(e):{top:e,right:e,bottom:e,left:e}}(p),h=a[f?"floating"===d?"reference":"floating":d],g=q(await s.getClippingRect({element:null==(n=await(null==s.isElement?void 0:s.isElement(h)))||n?h:h.contextElement||await(null==s.getDocumentElement?void 0:s.getDocumentElement(a.floating)),boundary:c,rootBoundary:u,strategy:l})),y="floating"===d?{x:o,y:i,width:r.floating.width,height:r.floating.height}:r.reference,b=await(null==s.getOffsetParent?void 0:s.getOffsetParent(a.floating)),w=await(null==s.isElement?void 0:s.isElement(b))&&await(null==s.getScale?void 0:s.getScale(b))||{x:1,y:1},v=q(s.convertOffsetParentRelativeRectToViewportRelativeRect?await s.convertOffsetParentRelativeRectToViewportRelativeRect({elements:a,rect:y,offsetParent:b,strategy:l}):y);return{top:(g.top-v.top+m.top)/w.y,bottom:(v.bottom-g.bottom+m.bottom)/w.y,left:(g.left-v.left+m.left)/w.x,right:(v.right-g.right+m.right)/w.x}}const U=new Set(["left","top"]);function W(){return"undefined"!=typeof window}function H(e){return J(e)?(e.nodeName||"").toLowerCase():"#document"}function V(e){var t;return(null==e||null==(t=e.ownerDocument)?void 0:t.defaultView)||window}function Z(e){var t;return null==(t=(J(e)?e.ownerDocument:e.document)||window.document)?void 0:t.documentElement}function J(e){return!!W()&&(e instanceof Node||e instanceof V(e).Node)}function G(e){return!!W()&&(e instanceof Element||e instanceof V(e).Element)}function X(e){return!!W()&&(e instanceof HTMLElement||e instanceof V(e).HTMLElement)}function Y(e){return!(!W()||"undefined"==typeof ShadowRoot)&&(e instanceof ShadowRoot||e instanceof V(e).ShadowRoot)}function K(e){const{overflow:t,overflowX:n,overflowY:o,display:i}=le(e);return/auto|scroll|overlay|hidden|clip/.test(t+o+n)&&"inline"!==i&&"contents"!==i}function Q(e){return/^(table|td|th)$/.test(H(e))}function ee(e){try{if(e.matches(":popover-open"))return!0}catch(e){}try{return e.matches(":modal")}catch(e){return!1}}const te=/transform|translate|scale|rotate|perspective|filter/,ne=/paint|layout|strict|content/,oe=e=>!!e&&"none"!==e;let ie;function se(e){const t=G(e)?le(e):e;return oe(t.transform)||oe(t.translate)||oe(t.scale)||oe(t.rotate)||oe(t.perspective)||!re()&&(oe(t.backdropFilter)||oe(t.filter))||te.test(t.willChange||"")||ne.test(t.contain||"")}function re(){return null==ie&&(ie="undefined"!=typeof CSS&&CSS.supports&&CSS.supports("-webkit-backdrop-filter","none")),ie}function ae(e){return/^(html|body|#document)$/.test(H(e))}function le(e){return V(e).getComputedStyle(e)}function ce(e){return G(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function ue(e){if("html"===H(e))return e;const t=e.assignedSlot||e.parentNode||Y(e)&&e.host||Z(e);return Y(t)?t.host:t}function de(e){const t=ue(e);return ae(t)?(e.ownerDocument||e).body:X(t)&&K(t)?t:de(t)}function fe(e,t,n){var o;void 0===t&&(t=[]),void 0===n&&(n=!0);const i=de(e),s=i===(null==(o=e.ownerDocument)?void 0:o.body),r=V(i);if(s){const e=pe(r);return t.concat(r,r.visualViewport||[],K(i)?i:[],e&&n?fe(e):[])}return t.concat(i,fe(i,[],n))}function pe(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}function me(e){const t=le(e);let n=parseFloat(t.width)||0,o=parseFloat(t.height)||0;const i=X(e),s=i?e.offsetWidth:n,r=i?e.offsetHeight:o,a=x(n)!==s||x(o)!==r;return a&&(n=s,o=r),{width:n,height:o,$:a}}function he(e){return G(e)?e:e.contextElement}function ge(e){const t=he(e);if(!X(t))return k(1);const n=t.getBoundingClientRect(),{width:o,height:i,$:s}=me(t);let r=(s?x(n.width):n.width)/o,a=(s?x(n.height):n.height)/i;return r&&Number.isFinite(r)||(r=1),a&&Number.isFinite(a)||(a=1),{x:r,y:a}}const ye=k(0);function be(e){const t=V(e);return re()&&t.visualViewport?{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}:ye}function we(e,t,n,o){void 0===t&&(t=!1),void 0===n&&(n=!1);const i=e.getBoundingClientRect(),s=he(e);let r=k(1);t&&(o?G(o)&&(r=ge(o)):r=ge(e));const a=function(e,t,n){return void 0===t&&(t=!1),!!n&&t&&n===V(e)}(s,n,o)?be(s):k(0);let l=(i.left+a.x)/r.x,c=(i.top+a.y)/r.y,u=i.width/r.x,d=i.height/r.y;if(s&&o){const e=V(s),t=G(o)?V(o):o;let n=e,i=pe(n);for(;i&&t!==n;){const e=ge(i),t=i.getBoundingClientRect(),o=le(i),s=t.left+(i.clientLeft+parseFloat(o.paddingLeft))*e.x,r=t.top+(i.clientTop+parseFloat(o.paddingTop))*e.y;l*=e.x,c*=e.y,u*=e.x,d*=e.y,l+=s,c+=r,n=V(i),i=pe(n)}}return q({width:u,height:d,x:l,y:c})}function ve(e,t){const n=ce(e).scrollLeft;return t?t.left+n:we(Z(e)).left+n}function _e(e,t){const n=e.getBoundingClientRect();return{x:n.left+t.scrollLeft-ve(e,n),y:n.top+t.scrollTop}}function xe(e,t,n){let o;if("viewport"===t||"layoutViewport"===t)o=function(e,t,n){void 0===n&&(n="viewport");const o="layoutViewport"===n,i=V(e),s=Z(e),r=i.visualViewport;let a=s.clientWidth,l=s.clientHeight,c=0,u=0;if(r){const e=!re()||"fixed"===t;o?e||(c=-r.offsetLeft,u=-r.offsetTop):(a=r.width,l=r.height,e&&(c=r.offsetLeft,u=r.offsetTop))}if(ve(s)<=0){const e=s.ownerDocument,t=e.body,n=getComputedStyle(t),o="CSS1Compat"===e.compatMode&&parseFloat(n.marginLeft)+parseFloat(n.marginRight)||0,i=Math.abs(s.clientWidth-t.clientWidth-o),r="stable both-edges"===getComputedStyle(s).scrollbarGutter?i/2:i;r<=25&&(a-=r)}return{width:a,height:l,x:c,y:u}}(e,n,t);else if("document"===t)o=function(e){const t=ce(e),n=e.ownerDocument.body,o=_(e.scrollWidth,e.clientWidth,n.scrollWidth,n.clientWidth),i=_(e.scrollHeight,e.clientHeight,n.scrollHeight,n.clientHeight);let s=-t.scrollLeft+ve(e);const r=-t.scrollTop;return"rtl"===le(n).direction&&(s+=_(e.clientWidth,n.clientWidth)-o),{width:o,height:i,x:s,y:r}}(Z(e));else if(G(t))o=function(e,t){const n=we(e,!0,"fixed"===t),o=n.top+e.clientTop,i=n.left+e.clientLeft,s=ge(e);return{width:e.clientWidth*s.x,height:e.clientHeight*s.y,x:i*s.x,y:o*s.y}}(t,n);else{const n=be(e);o={x:t.x-n.x,y:t.y-n.y,width:t.width,height:t.height}}return q(o)}function $e(e,t,n){const o=X(t),i=Z(t),s="fixed"===n,r=we(e,!0,s,t);let a={scrollLeft:0,scrollTop:0};const l=k(0);if((o||!s)&&(("body"!==H(t)||K(i))&&(a=ce(t)),o)){const e=we(t,!0,s,t);l.x=e.x+t.clientLeft,l.y=e.y+t.clientTop}!o&&i&&(l.x=ve(i));const c=!i||o||s?k(0):_e(i,a);return{x:r.left+a.scrollLeft-l.x-c.x,y:r.top+a.scrollTop-l.y-c.y,width:r.width,height:r.height}}function ke(e){return"static"===le(e).position}function Se(e,t){if(!X(e)||"fixed"===le(e).position)return null;if(t)return t(e);let n=e.offsetParent;return Z(e)===n&&(n=n.ownerDocument.body),n}function Ee(e,t){const n=V(e);if(ee(e))return n;if(!X(e)){let t=ue(e);for(;t&&!ae(t);){if(G(t)&&!ke(t))return t;t=ue(t)}return n}let o=Se(e,t);for(;o&&Q(o)&&ke(o);)o=Se(o,t);return o&&ae(o)&&ke(o)&&!se(o)?n:o||function(e){let t=ue(e);for(;X(t)&&!ae(t);){if(se(t))return t;if(ee(t))return null;t=ue(t)}return null}(e)||n}const Oe={convertOffsetParentRelativeRectToViewportRelativeRect:function(e){let{elements:t,rect:n,offsetParent:o,strategy:i}=e;const s="fixed"===i,r=Z(o),a=!!t&&ee(t.floating);if(o===r||a&&s)return n;let l={scrollLeft:0,scrollTop:0},c=k(1);const u=k(0),d=X(o);if((d||!s)&&(("body"!==H(o)||K(r))&&(l=ce(o)),d)){const e=we(o);c=ge(o),u.x=e.x+o.clientLeft,u.y=e.y+o.clientTop}const f=!r||d||s?k(0):_e(r,l);return{width:n.width*c.x,height:n.height*c.y,x:n.x*c.x-l.scrollLeft*c.x+u.x+f.x,y:n.y*c.y-l.scrollTop*c.y+u.y+f.y}},getDocumentElement:Z,getClippingRect:function(e){let{element:t,boundary:n,rootBoundary:o,strategy:i}=e;const s=[..."clippingAncestors"===n?ee(t)?[]:function(e,t){const n=t.get(e);if(n)return n;let o=fe(e,[],!1).filter(e=>G(e)&&"body"!==H(e)),i=null;const s="fixed"===le(e).position;let r=s?ue(e):e;for(;G(r)&&!ae(r);){const e=le(r),t=se(r),n=i?i.position:s?"fixed":"";t||"fixed"!==n&&("absolute"!==n||"static"!==e.position)?i=e:o=o.filter(e=>e!==r),r=ue(r)}return t.set(e,o),o}(t,this._c):[].concat(n),o],r=xe(t,s[0],i);let a=r.top,l=r.right,c=r.bottom,u=r.left;for(let e=1;e<s.length;e++){const n=xe(t,s[e],i);a=_(n.top,a),l=v(n.right,l),c=v(n.bottom,c),u=_(n.left,u)}return{width:l-u,height:c-a,x:u,y:a}},getOffsetParent:Ee,getElementRects:async function(e){const t=this.getOffsetParent||Ee,n=this.getDimensions,o=await n(e.floating);return{reference:$e(e.reference,await t(e.floating),e.strategy),floating:{x:0,y:0,width:o.width,height:o.height}}},getClientRects:function(e){return e.getClientRects?Array.from(e.getClientRects()):[]},getDimensions:function(e){const{width:t,height:n}=me(e);return{width:t,height:n}},getScale:ge,isElement:G,isRTL:function(e){return"rtl"===le(e).direction}};function Te(e,t){return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}function je(e,t,n,o){void 0===o&&(o={});const{ancestorScroll:i=!0,ancestorResize:s=!0,elementResize:r="function"==typeof ResizeObserver,layoutShift:a="function"==typeof IntersectionObserver,animationFrame:l=!1}=o,c=he(e),u=i||s?[...c?fe(c):[],...t?fe(t):[]]:[];u.forEach(e=>{i&&e.addEventListener("scroll",n),s&&e.addEventListener("resize",n)});const d=c&&a?function(e,t,n){let o,i=null;const s=Z(e);function r(){var e;clearTimeout(o),null==(e=i)||e.disconnect(),i=null}function a(n,l){void 0===n&&(n=!1),void 0===l&&(l=1),r();const c=e.getBoundingClientRect(),{left:u,top:d,width:f,height:p}=c;if(n||t(),!f||!p)return;const m={rootMargin:-$(d)+"px "+-$(s.clientWidth-(u+f))+"px "+-$(s.clientHeight-(d+p))+"px "+-$(u)+"px",threshold:_(0,v(1,l))||1};let h=!0;function g(t){const n=t[0].intersectionRatio;if(!Te(c,e.getBoundingClientRect()))return a();if(n!==l){if(!h)return a();n?a(!1,n):o=setTimeout(()=>{a(!1,1e-7)},1e3)}h=!1}try{i=new IntersectionObserver(g,{...m,root:s.ownerDocument})}catch(e){i=new IntersectionObserver(g,m)}i.observe(e)}const l=V(e),c=()=>a(n);return l.addEventListener("resize",c),a(!0),()=>{l.removeEventListener("resize",c),r()}}(c,n,s):null;let f,p=-1,m=null;r&&(m=new ResizeObserver(e=>{let[o]=e;o&&o.target===c&&m&&t&&(m.unobserve(t),cancelAnimationFrame(p),p=requestAnimationFrame(()=>{var e;null==(e=m)||e.observe(t)})),n()}),c&&!l&&m.observe(c),t&&m.observe(t));let h=l?we(e):null;return l&&function t(){const o=we(e);h&&!Te(h,o)&&n();h=o,f=requestAnimationFrame(t)}(),n(),()=>{var e;u.forEach(e=>{i&&e.removeEventListener("scroll",n),s&&e.removeEventListener("resize",n)}),null==d||d(),null==(e=m)||e.disconnect(),m=null,l&&cancelAnimationFrame(f)}}const Ae=function(e){return void 0===e&&(e=0),{name:"offset",options:e,async fn(t){var n,o;const{x:i,y:s,placement:r,middlewareData:a}=t,l=await async function(e,t){const{placement:n,platform:o,elements:i}=e,s=await(null==o.isRTL?void 0:o.isRTL(i.floating)),r=O(n),a=T(n),l="y"===L(n),c=U.has(r)?-1:1,u=s&&l?-1:1,d=E(t,e);let{mainAxis:f,crossAxis:p,alignmentAxis:m}="number"==typeof d?{mainAxis:d,crossAxis:0,alignmentAxis:null}:{mainAxis:d.mainAxis||0,crossAxis:d.crossAxis||0,alignmentAxis:d.alignmentAxis};return a&&"number"==typeof m&&(p="end"===a?-1*m:m),l?{x:p*u,y:f*c}:{x:f*c,y:p*u}}(t,e);return r===(null==(n=a.offset)?void 0:n.placement)&&null!=(o=a.arrow)&&o.alignmentOffset?{}:{x:i+l.x,y:s+l.y,data:{...l,placement:r}}}}},Le=function(e){return void 0===e&&(e={}),{name:"shift",options:e,async fn(t){const{x:n,y:o,placement:i,platform:s}=t,{mainAxis:r=!0,crossAxis:a=!1,limiter:l={fn:e=>{let{x:t,y:n}=e;return{x:t,y:n}}},...c}=E(e,t),u={x:n,y:o},d=await s.detectOverflow(t,c),f=L(i),p=j(f);let m=u[p],h=u[f];const g=(e,t)=>{return n=t+d["y"===e?"top":"left"],o=t,i=t-d["y"===e?"bottom":"right"],_(n,v(o,i));var n,o,i};r&&(m=g(p,m)),a&&(h=g(f,h));const y=l.fn({...t,[p]:m,[f]:h});return{...y,data:{x:y.x-n,y:y.y-o,enabled:{[p]:r,[f]:a}}}}}},Pe=function(e){return void 0===e&&(e={}),{name:"flip",options:e,async fn(t){var n,o;const{placement:i,middlewareData:s,rects:r,initialPlacement:a,platform:l,elements:c}=t,{mainAxis:u=!0,crossAxis:d=!0,fallbackPlacements:f,fallbackStrategy:p="bestFit",fallbackAxisSideDirection:m="none",flipAlignment:h=!0,...g}=E(e,t);if(null!=(n=s.arrow)&&n.alignmentOffset)return{};const y=O(i),b=L(a),w=O(a)===a,v=await(null==l.isRTL?void 0:l.isRTL(c.floating)),_=f||(w||!h?[M(a)]:function(e){const t=M(e);return[z(e),t,z(t)]}(a)),x="none"!==m;!f&&x&&_.push(...I(a,h,m,v));const $=[a,..._],k=await l.detectOverflow(t,g),S=[];let j=(null==(o=s.flip)?void 0:o.overflows)||[];if(u&&S.push(k[y]),d){const e=function(e,t,n){void 0===n&&(n=!1);const o=T(e),i=P(e),s=A(i);let r="x"===i?o===(n?"end":"start")?"right":"left":"start"===o?"bottom":"top";return t.reference[s]>t.floating[s]&&(r=M(r)),[r,M(r)]}(i,r,v);S.push(k[e[0]],k[e[1]])}if(j=[...j,{placement:i,overflows:S}],!S.every(e=>e<=0)){var R,C;const e=((null==(R=s.flip)?void 0:R.index)||0)+1,t=$[e];if(t){if(!("alignment"===d&&b!==L(t))||j.every(e=>L(e.placement)!==b||e.overflows[0]>0))return{data:{index:e,overflows:j},reset:{placement:t}}}let n=null==(C=j.filter(e=>e.overflows[0]<=0).sort((e,t)=>e.overflows[1]-t.overflows[1])[0])?void 0:C.placement;if(!n)switch(p){case"bestFit":{var F;const e=null==(F=j.filter(e=>{if(x){const t=L(e.placement);return t===b||"y"===t}return!0}).map(e=>[e.placement,e.overflows.filter(e=>e>0).reduce((e,t)=>e+t,0)]).sort((e,t)=>e[1]-t[1])[0])?void 0:F[0];e&&(n=e);break}case"initialPlacement":n=a}if(i!==n)return{reset:{placement:n}}}return{}}}},ze=function(e){return void 0===e&&(e={}),{name:"size",options:e,async fn(t){const{placement:n,rects:o,platform:i,elements:s}=t,{apply:r=()=>{},...a}=E(e,t),l=await i.detectOverflow(t,a),c=O(n),u=T(n),d="y"===L(n),{width:f,height:p}=o.floating;let m,h;"top"===c||"bottom"===c?(m=c,h=u===(await(null==i.isRTL?void 0:i.isRTL(s.floating))?"start":"end")?"left":"right"):(h=c,m="end"===u?"top":"bottom");const g=p-l.top-l.bottom,y=f-l.left-l.right,b=v(p-l[m],g),w=v(f-l[h],y),x=t.middlewareData.shift,$=!x;let k=b,S=w;null!=x&&x.enabled.x&&(S=y),null!=x&&x.enabled.y&&(k=g),$&&!u&&(d?S=f-2*_(l.left,l.right):k=p-2*_(l.top,l.bottom)),await r({...t,availableWidth:S,availableHeight:k});const j=await i.getDimensions(s.floating);return f!==j.width||p!==j.height?{reset:{rects:!0}}:{}}}},Re=(e,t,n)=>{const o=new Map,i=null!=n?n:{},s={...Oe,...i.platform,_c:o};return(async(e,t,n)=>{const{placement:o="bottom",strategy:i="absolute",middleware:s=[],platform:r}=n,a=r.detectOverflow?r:{...r,detectOverflow:B},l=await(null==r.isRTL?void 0:r.isRTL(t));let c=await r.getElementRects({reference:e,floating:t,strategy:i}),{x:u,y:d}=D(c,o,l),f=o,p=0;const m={};for(let n=0;n<s.length;n++){const h=s[n];if(!h)continue;const{name:g,fn:y}=h,{x:b,y:w,data:v,reset:_}=await y({x:u,y:d,initialPlacement:o,placement:f,strategy:i,middlewareData:m,rects:c,platform:a,elements:{reference:e,floating:t}});u=null!=b?b:u,d=null!=w?w:d,m[g]={...m[g],...v},_&&p<50&&(p++,"object"==typeof _&&(_.placement&&(f=_.placement),_.rects&&(c=!0===_.rects?await r.getElementRects({reference:e,floating:t,strategy:i}):_.rects),({x:u,y:d}=D(c,f,l))),n=-1)}return{x:u,y:d,placement:f,strategy:i,middlewareData:m}})(e,t,{...i,platform:s})},Ce=["block-start","block-end","inline-start","inline-end"],Fe=["start","center","end"];function Ne(e="block-end",t="start",n=!1){if(!Ce.includes(e))throw new TypeError(`Unknown placement side: ${e}`);if(!Fe.includes(t))throw new TypeError(`Unknown placement alignment: ${t}`);const o="block-start"===e?"top":"block-end"===e?"bottom":"inline-start"===e?n?"right":"left":n?"left":"right";return"center"===t?o:`${o}-${t}`}function Ie(e,t=!1){const n=String(e).split("-")[0];return"top"===n?"block-start":"bottom"===n?"block-end":"left"===n?t?"inline-end":"inline-start":t?"inline-start":"inline-end"}function Me(e,t=document.body){if("number"==typeof e)return Number.isFinite(e)?e:0;if("string"!=typeof e||""===e.trim())return 0;const n=document.createElement("span");n.style.cssText="position:absolute;visibility:hidden;pointer-events:none;block-size:0;padding:0;border:0",n.style.inlineSize=e,(t?.isConnected?t:document.body).append(n);const o=parseFloat(getComputedStyle(n).width)||0;return n.remove(),o}const qe=Object.freeze({anchor:function(e,t,n={}){if(!(e instanceof Element&&t instanceof HTMLElement))throw new TypeError("Anchored positioning needs a reference element and a floating element");const o={side:"block-end",align:"start",offset:"var(--sf-space-1\\/4)",alignmentOffset:0,padding:"var(--sf-space-1\\/2)",flip:!0,shift:!0,matchWidth:!1,fitHeight:!0,autoUpdate:!0,onPosition:null,...n},i=["position","left","top","right","bottom","margin","max-height","max-width",...o.matchWidth?["width"]:[]].map(e=>[e,t.style.getPropertyValue(e),t.style.getPropertyPriority(e)]),s={maxHeight:t.style.getPropertyValue("max-height")},r=getComputedStyle(t),a=(e,t)=>{const n=parseFloat(e);return Number.isFinite(n)?String(e).trim().endsWith("%")?n/100*t:n:1/0},l=a(r.maxHeight,document.documentElement.clientHeight),c=a(r.maxWidth,document.documentElement.clientWidth),u={side:o.side,stopped:!1};let d=null,f=!1;const p=async()=>{const n="rtl"===getComputedStyle(e).direction;const i=Me(o.offset,e.parentElement),r=Me(o.padding,e.parentElement);o.fitHeight&&(t.style.maxHeight=s.maxHeight||"");const a=e.getBoundingClientRect(),d=document.documentElement.clientWidth,f={top:r,bottom:r,left:Math.min(r,Math.max(0,a.left)),right:Math.min(r,Math.max(0,d-a.right))},p=[Ae({mainAxis:i,alignmentAxis:Me(o.alignmentOffset,e.parentElement)})];o.flip&&p.push(Pe({padding:r,crossAxis:!1})),o.shift&&p.push(Le({padding:f,crossAxis:!1})),p.push(ze({padding:f,apply({availableWidth:e,availableHeight:t,rects:n,elements:i}){if(u.stopped)return;const s=d-f.left-f.right;o.matchWidth&&(i.floating.style.width=`${Math.max(0,Math.min(n.reference.width,s))}px`),i.floating.style.maxWidth=`${Math.max(0,Math.min(e,s,c))}px`,o.fitHeight&&(i.floating.style.maxHeight=`${Math.max(0,Math.min(t,l))}px`)}}));const m=await Re(e,t,{strategy:"fixed",placement:Ne(o.side,o.align,n),middleware:p});return u.stopped||(Object.assign(t.style,{position:"fixed",left:`${m.x}px`,top:`${m.y}px`,right:"auto",bottom:"auto",margin:"0"}),u.side=Ie(m.placement,n),t.dataset.sfSide=u.side,o.onPosition?.({side:u.side,placement:m.placement,x:m.x,y:m.y})),m};u.update=()=>u.stopped?Promise.resolve(null):d?(f=!0,d):(d=p().finally(()=>{d=null,f&&!u.stopped&&(f=!1,u.update())}),d);const m=o.autoUpdate?je(e,t,u.update):null;return u.stop=()=>{u.stopped=!0,m?.(),delete t.dataset.sfSide;for(const[e,n,o]of i)n?t.style.setProperty(e,n,o):t.style.removeProperty(e)},o.autoUpdate||u.update(),u},logicalSide:Ie,physicalPlacement:Ne,resolveLength:Me});"undefined"!=typeof globalThis&&(globalThis.SF=globalThis.SF||{},globalThis.SF.Position||(globalThis.SF.Position=qe));const De="sf-pref:",Be=/^[\w.*:-]+(?:\/[\w.*:/-]+)?$/u;function Ue(){try{return globalThis.localStorage??null}catch{return null}}function We(e){return"string"==typeof e&&e.length>0&&e.length<=200&&Be.test(e)}function He(e,t){try{return JSON.stringify(e)===JSON.stringify(t)}catch{return!1}}function Ve(e){return null==e?null:JSON.parse(JSON.stringify(e))}"undefined"!=typeof globalThis&&(globalThis.SF=globalThis.SF||{},globalThis.SF.Preferences||(globalThis.SF.Preferences=function(){const e={adapter:null,values:new Map},t=new Map,n=new Map;let o=!1;const i=()=>{if(o)return;const e=globalThis.document?.querySelector?.('script[type="application/json"][data-sf-preferences], script#sf-preferences[type="application/json"]');if(e){o=!0;try{u.preload(JSON.parse(e.textContent||"{}"))}catch{}}},s=(e,n)=>{for(const o of t.get(e)??[])try{o(Ve(n),e)}catch(t){console.error("SF.Preferences listener failed",e,t)}},r=e=>{const t=Ue();if(!t)return null;try{const n=t.getItem(De+e);return null===n?null:JSON.parse(n)}catch{return null}},a=(e,t)=>{const n=Ue();if(n)try{null===t?n.removeItem(De+e):n.setItem(De+e,JSON.stringify(t))}catch{}},l=t=>{clearTimeout(n.get(t)),n.delete(t);const o=e.adapter;if(!o)return;const i=e.values.has(t)?e.values.get(t):r(t);try{const e=null===i?o.remove?.(t):o.save?.(t,Ve(i));Promise.resolve(e).catch(e=>console.warn("SF.Preferences: the host did not keep",t,e))}catch(e){console.warn("SF.Preferences: the host did not keep",t,e)}},c=t=>{e.adapter&&(clearTimeout(n.get(t)),n.set(t,setTimeout(()=>l(t),400)))},u={read:t=>We(t)?(i(),e.values.has(t)?Ve(e.values.get(t)):Ve(r(t))):null,readMerged(...e){const t={};let n=!1;for(const o of e.flat()){const e=u.read(o);e&&"object"==typeof e&&!Array.isArray(e)&&(Object.assign(t,e),n=!0)}return n?t:null},write(t,n){if(!We(t))return!1;const o=Ve(n);return JSON.stringify(u.read(t))===JSON.stringify(o)||(e.values.has(t)&&e.values.set(t,o),a(t,o),c(t)),!0},remove:t=>!!We(t)&&(e.values.has(t)&&e.values.set(t,null),a(t,null),c(t),s(t,null),!0),subscribe:(e,n)=>We(e)&&"function"==typeof n?(t.has(e)||t.set(e,new Set),t.get(e).add(n),()=>t.get(e)?.delete(n)):()=>{},preload(t){if(t&&"object"==typeof t)for(const[n,o]of Object.entries(t)){if(!We(n))continue;const t=Ve(o),i=u.read(n);e.values.set(n,t),a(n,t),He(i,t)||s(n,t)}},useHost(t){if(!t||"function"!=typeof t.save)throw new TypeError("A preferences host saves: {save(key, value)}");return e.adapter=t,u},async load(t){const n=[].concat(t).filter(t=>We(t)&&!e.values.has(t));if(n.length&&"function"==typeof e.adapter?.load)try{u.preload(await e.adapter.load(n))}catch(e){console.warn("SF.Preferences: the host did not answer",n,e)}},get hosted(){return Boolean(e.adapter)},flush(){for(const e of[...n.keys()])l(e)}};return globalThis.addEventListener?.("storage",t=>{if(!t.key?.startsWith(De)||t.storageArea!==Ue())return;const n=t.key.slice(8);if(e.values.has(n))return;let o=null;try{o=null===t.newValue?null:JSON.parse(t.newValue)}catch{o=null}s(n,o)}),globalThis.addEventListener?.("pagehide",()=>u.flush()),i(),Object.freeze(u)}()));globalThis.SF;let Ze=null,Je=null,Ge=0;const Xe=new Map,Ye=e=>{try{return new URL(e,globalThis.location.href).href}catch{return null}};function Ke(e){const t=function(e){if(!Ze||e.defaultPrevented||0!==e.button)return null;if(e.metaKey||e.ctrlKey||e.shiftKey||e.altKey)return null;const t=e.composedPath().find(e=>e instanceof globalThis.Element&&e.matches("a[href]"));if(!t)return null;if(t.closest("[data-full-load]")||t.hasAttribute("download"))return null;const n=t.getAttribute("target");if(n&&"_self"!==n)return null;const o=new URL(t.href,globalThis.location.href),i=new URL(globalThis.location.href);return o.origin!==i.origin?null:o.pathname.startsWith(Ze.scope)?o.hash&&o.pathname===i.pathname&&o.search===i.search?null:o.href:null}(e);t&&(e.preventDefault(),nt(t))}function Qe(e){const t=e.state;Ze&&t?.sfRegion&&nt(globalThis.location.href,{history:"none",scroll:t.scroll??0})}function et(e,t){globalThis.document.dispatchEvent(new CustomEvent("sf-region-fallback",{detail:{url:e,reason:t}})),Ze?.onFullLoad?Ze.onFullLoad(e,t):e===globalThis.location.href?globalThis.location.reload():globalThis.location.assign(e)}function tt({href:e,kind:t,key:n}){const o=Ye(e);if(!o||!["css","javascript"].includes(t))return Promise.resolve();if(Xe.has(o))return Xe.get(o);if(function(e,t){const n=globalThis.document;return[..."css"===t?n.querySelectorAll('link[rel~="stylesheet"][href]'):n.querySelectorAll("script[src]")].some(n=>Ye(n.getAttribute("css"===t?"href":"src"))===e)}(o,t))return Xe.set(o,Promise.resolve()),Xe.get(o);const i=globalThis.document,s=i.createElement("css"===t?"link":"script");"css"===t?(s.rel="stylesheet",s.href=o):(s.src=o,s.async=!1),n&&s.setAttribute("data-sf-asset",n);const r=new Promise(e=>{s.addEventListener("load",()=>e(),{once:!0}),s.addEventListener("error",()=>e(),{once:!0})});return i.head.append(s),Xe.set(o,r),r}async function nt(e,{history:t="push",scroll:n=0}={}){if(!Ze)return globalThis.location.assign(e),!1;const o=Ze?"string"==typeof Ze.root?globalThis.document.querySelector(Ze.root):Ze.root:null,i=globalThis.document.querySelector(`meta[name="${Ze.revisionMeta}"]`)?.getAttribute("content")??null;if(!o||!i)return et(e,"no-region"),!1;if(!globalThis.document.dispatchEvent(new CustomEvent("sf-region-navigate",{cancelable:!0,detail:{url:e,region:Ze.region}})))return!1;Je?.abort(),Je=new AbortController;const s=++Ge,r=setTimeout(()=>{s===Ge&&(o.setAttribute("aria-busy","true"),o.setAttribute("data-sf-region-loading",""))},150),a=setTimeout(()=>Je?.abort(),15e3);let l;try{const t=await globalThis.fetch(e,{method:"GET",credentials:"same-origin",headers:{[Ze.header]:Ze.region,Accept:"application/json"},signal:Je.signal});if(t.redirected||200!==t.status||!/application\/json/u.test(t.headers.get("content-type")??""))throw new Error(`region answer ${t.status}${t.redirected?" redirected":""}`);if(l=await t.json(),!function(e,t){return e&&"object"==typeof e&&e.region===Ze.region&&"string"==typeof e.html&&"string"==typeof e.shell_revision&&e.shell_revision===t&&(void 0===e.assets||Array.isArray(e.assets))}(l,i))throw new Error(l?.shell_revision!==i?"shell-revision":"region-answer")}catch(t){return clearTimeout(r),clearTimeout(a),s!==Ge?!1:(o.removeAttribute("aria-busy"),o.removeAttribute("data-sf-region-loading"),"AbortError"===t?.name&&Je?.signal.aborted&&s===Ge?(et(e,"timeout"),!1):(et(e,String(t?.message??t)),!1))}if(clearTimeout(a),s!==Ge)return!1;const c="string"==typeof l.url&&Ye(l.url)?.startsWith(globalThis.location.origin)?Ye(l.url):e,u=function(e){const t=globalThis.document.createElement("template");t.innerHTML=String(e??"");const n=[];for(const e of t.content.querySelectorAll('link[rel~="stylesheet"][href]'))n.push({href:e.getAttribute("href"),kind:"css"}),e.remove();for(const e of t.content.querySelectorAll("script"))e.getAttribute("src")&&n.push({href:e.getAttribute("src"),kind:"javascript"}),e.remove();return{content:t.content,assets:n}}(l.html),d=[...l.assets??[],...u.assets];if(await Promise.all(d.filter(e=>"css"===e.kind).map(tt)),s!==Ge)return!1;"push"===t?(!function(){const e=globalThis.history.state??{};globalThis.history.replaceState({...e,sfRegion:!0,scroll:globalThis.scrollY},"")}(),globalThis.history.pushState({sfRegion:!0,scroll:0},"",c)):"replace"===t&&globalThis.history.replaceState({sfRegion:!0,scroll:0},"",c);const f=()=>{clearTimeout(r),o.replaceChildren(u.content),o.removeAttribute("aria-busy"),o.removeAttribute("data-sf-region-loading"),"string"==typeof l.title&&l.title&&(globalThis.document.title=l.title)},p="function"!=typeof globalThis.document.startViewTransition||globalThis.matchMedia?.("(prefers-reduced-motion: reduce)").matches?null:globalThis.document.startViewTransition(f);p?await p.updateCallbackDone.catch(()=>{}):f();for(const e of d.filter(e=>"javascript"===e.kind))await tt(e);globalThis.scrollTo(0,"none"===t?n:0);const m=o.querySelector("h1");return m&&(m.hasAttribute("tabindex")||m.setAttribute("tabindex","-1"),m.focus({preventScroll:!0})),globalThis.document.dispatchEvent(new CustomEvent("sf-region-load",{detail:{url:c,region:Ze.region,title:globalThis.document.title}})),!0}function ot(){Ze&&(globalThis.document.removeEventListener("click",Ke),globalThis.removeEventListener("popstate",Qe),Je?.abort(),Ze=null)}"undefined"!=typeof window&&(window.SF=window.SF||{},window.SF.RegionNavigation=Object.freeze({enable:function(e={}){const t={region:e.region??"content",root:e.root,header:e.header,revisionMeta:e.revisionMeta,scope:e.scope??"/",onFullLoad:"function"==typeof e.onFullLoad?e.onFullLoad:null};if(!t.root||!t.header||!t.revisionMeta)throw new TypeError("region navigation needs root, header and revisionMeta");Ze&&ot(),Ze=t,globalThis.document.addEventListener("click",Ke),globalThis.addEventListener("popstate",Qe),"scrollRestoration"in globalThis.history&&(globalThis.history.scrollRestoration="manual");const n=globalThis.history.state??{};return globalThis.history.replaceState({...n,sfRegion:!0,scroll:n.scroll??globalThis.scrollY},""),!0},disable:ot,navigate:nt,get enabled(){return Boolean(Ze)}}));var it=n("ac24888e7d3e");const st=Object.freeze((0,it.xZ)("simai.effect",1)),rt=new Set(["choice","integer","number","boolean","string","text","color","file"]),at=/^[a-z][a-z0-9-]{1,40}$/u,lt=/^[0-9]+\.[0-9]+\.[0-9]+$/u,ct=/^[a-zA-Z][a-zA-Z0-9]{0,40}$/u,ut=/^[a-z0-9][a-z0-9._-]*$/u,dt=/^#(?:[0-9a-f]{3}|[0-9a-f]{6}|[0-9a-f]{8})$/iu,ft=["dark","light"],pt=new Set(["windows"]),mt=/^https:\/\/[^\s?#]+\/effect\.json$/u,ht=e=>null!==e&&"object"==typeof e&&!Array.isArray(e),gt=e=>ht(e)&&Object.keys(e).length>0&&Object.entries(e).every(([e,t])=>/^[a-z]{2}(-[A-Z]{2})?$/u.test(e)&&"string"==typeof t&&t.length>0);function yt(e){if(!ht(e))return["manifest: not an object"];const t=[],n=["schema","schema_version","id","version","label","author","entry","styles","preview","surfaces","schemes","pair","capabilities","settings","needs"];for(const o of Object.keys(e))n.includes(o)||t.push(`${o}: undeclared`);(0,it.Wl)(e,"simai.effect",1)||t.push("schema: not simai.effect, schema_version 1"),"string"==typeof e.id&&at.test(e.id)||t.push("id"),"string"==typeof e.version&&lt.test(e.version)||t.push("version"),gt(e.label)||t.push("label"),"string"==typeof e.entry&&ut.test(e.entry)&&/\.m?js$/u.test(e.entry)||t.push("entry: one module file"),void 0===e.styles||Array.isArray(e.styles)&&e.styles.every(e=>"string"==typeof e&&ut.test(e)&&e.endsWith(".css"))||t.push("styles"),Array.isArray(e.surfaces)&&e.surfaces.length||t.push("surfaces");const o=e.schemes;if(void 0===o||Array.isArray(o)&&o.length&&!(o.length>2)&&o.every(e=>ft.includes(e))&&new Set(o).size===o.length||t.push("schemes: one or both of dark, light"),void 0!==e.pair&&("string"==typeof e.pair&&(at.test(e.pair)||mt.test(e.pair)&&e.pair.length<=2048)||t.push("pair: a catalogue id or the https URL of an effect.json"),Array.isArray(o)&&1===o.length||t.push("pair: only a single-scheme effect names a pair")),void 0===e.capabilities||Array.isArray(e.capabilities)&&e.capabilities.every(e=>pt.has(e))&&new Set(e.capabilities).size===e.capabilities.length||t.push("capabilities: known names, each once"),ht(e.needs)&&!1===e.needs.network&&1===Object.keys(e.needs).length||t.push("needs: {network: false}"),!Array.isArray(e.settings))return t.push("settings"),t;const i=new Set;return e.settings.forEach((e,n)=>{const o=`settings[${n}]`;if(ht(e)){if("string"==typeof e.key&&ct.test(e.key)?i.has(e.key)&&t.push(`${o}: key ${e.key} twice`):t.push(`${o}: key`),i.add(e.key),rt.has(e.type)||t.push(`${o}: type`),gt(e.label)||t.push(`${o}: label`),"default"in e||t.push(`${o}: default`),"choice"!==e.type||Array.isArray(e.options)&&e.options.length||t.push(`${o}: a choice names its options`),!["integer","number"].includes(e.type)||"number"==typeof e.min&&"number"==typeof e.max||t.push(`${o}: a number states min and max`),["string","text"].includes(e.type)&&"number"!=typeof e.max&&t.push(`${o}: a string states its max length`),"default"in e&&rt.has(e.type)){bt(e,e.default).ok||t.push(`${o}: default is not a valid value`)}}else t.push(`${o}: not an object`)}),t}function bt(e,t){const n={ok:!1,value:void 0};switch(e.type){case"boolean":return"boolean"==typeof t?{ok:!0,value:t}:"1"===t||"true"===t?{ok:!0,value:!0}:"0"===t||"false"===t?{ok:!0,value:!1}:n;case"integer":case"number":{const o="string"==typeof t&&""!==t.trim()?Number(t):t;return"number"==typeof o&&Number.isFinite(o)&&("integer"!==e.type||Number.isInteger(o))?o<e.min||o>e.max?n:{ok:!0,value:o}:n}case"choice":{const o=(e.options??[]).find(e=>String(e.value)===String(t));return o?{ok:!0,value:o.value}:n}case"string":case"text":return"string"!=typeof t||t.length>e.max||"string"===e.type&&/[\r\n]/u.test(t)?n:{ok:!0,value:t};case"color":return"string"==typeof t&&dt.test(t)?{ok:!0,value:t.toLowerCase()}:n;case"file":return null===t||""===t||"string"==typeof t&&t.length<=2048?{ok:!0,value:t||null}:n;default:return n}}function wt(e,t={}){const n={},o=[];for(const i of e.settings??[]){if(Object.hasOwn(t??{},i.key)){const e=bt(i,t[i.key]);if(e.ok){n[i.key]=e.value;continue}o.push(i.key)}n[i.key]=bt(i,i.default).value}return{settings:Object.freeze(n),invalid:o}}function vt(e){return Array.isArray(e?.schemes)&&e.schemes.length?[...e.schemes]:[...ft]}const _t=e=>"string"==typeof e?.pair&&mt.test(e.pair),xt=e=>Array.isArray(e?.capabilities)?e.capabilities:[],$t="data-sf-effect-state",kt="data-sf-effect-reason",St="[data-sf-effect-window]",Et=new WeakSet;function Ot(){return globalThis.SF_BOOT_CONFIG?.effects??{}}function Tt(e=Ot().foreign){return void 0===e||"sandbox"===e?"sandbox":"refuse"}const jt=String.raw`(() => {
1
+ (()=>{var e={"6c7f357fe960"(e,t,n){"use strict";n.d(t,{$Y:()=>l,VE:()=>c,c6:()=>s,ub:()=>a,vq:()=>r});const o=Object.freeze({width:31.68,height:48,distance:6,cycle:1800,rotateAt:1458,rotationStep:90,transition:300,easing:"cubic-bezier(0.3, 1.85, 0.55, 1)"}),i="__sfPreloaderMotion";function s(e=document.documentElement){return`var(--sf-on-surface, ${e?.classList?.contains("theme-dark")?"#e3e2e7":"#1a1b1f"})`}function r(e=document.documentElement){return`var(--sf-color--surface-highest, var(--sf-surface-0, ${e?.classList?.contains("theme-dark")?"#0f1115":"#ffffff"}))`}function a(e={}){const t={...o,...e};return`<svg data-sf-preloader-mark id="sv_li_1" xmlns="http://www.w3.org/2000/svg" width="${t.width}" height="${t.height}" viewBox="0 0 66 100" fill="none">\n<path fill-rule="evenodd" clip-rule="evenodd" d="M0 50.0013L49.812 0L66 16.2495L32.3722 50.0051L65.9938 83.7543L49.8097 100L0 50.0013Z" fill="${t.color}"/>\n</svg>\n<svg data-sf-preloader-mark id="sv_li_2" xmlns="http://www.w3.org/2000/svg" width="${t.width}" height="${t.height}" viewBox="0 0 66 100" fill="none">\n<path fill-rule="evenodd" clip-rule="evenodd" d="M66 50.0013L16.188 0L0 16.2495L33.6278 50.0051L0.00615692 83.7543L16.1903 100L66 50.0013Z" fill="${t.color}"/>\n</svg>`}function l(e){e?.[i]?.()}function c(e,t=()=>!0,n={}){if(!e)return()=>{};l(e);const s={...o,...n},r=Array.from(e.querySelectorAll("[data-sf-preloader-mark]"));if(2!==r.length||"function"!=typeof r[0].animate)return()=>{};if(window.matchMedia?.("(prefers-reduced-motion: reduce)").matches){e.style.transition="none",e.style.transform="rotate(0deg)",r.forEach(e=>{e.style.transform="none"});const t=()=>{e[i]===t&&delete e[i]};return e[i]=t,t}e.style.transition=`${s.transition}ms transform ease-in-out`;let a=0,c=null,u=!1;const d=r.map((e,t)=>{const n=0===t?-s.distance:s.distance;return e.animate([{transform:"translateX(0)",offset:0,easing:s.easing},{transform:`translateX(${n}px)`,offset:.36,easing:s.easing},{transform:`translateX(${n}px)`,offset:.48,easing:s.easing},{transform:"translateX(0)",offset:.84,easing:s.easing},{transform:"translateX(0)",offset:1}],{duration:s.cycle,iterations:Number.POSITIVE_INFINITY})}),f=()=>{!u&&t()&&(a+=s.rotationStep,e.style.transform=`rotate(${a}deg)`,c=window.setTimeout(f,s.cycle))};c=window.setTimeout(f,s.rotateAt);const p=()=>{u||(u=!0,window.clearTimeout(c),d.forEach(e=>e.cancel()),e.style.transform="rotate(0deg)",r.forEach(e=>{e.style.transform="none"}),e[i]===p&&delete e[i])};return e[i]=p,p}n.d(t,["Hg",0,o])},"3924cca3566b"(e,t,n){(()=>{const e="https://cdn.jsdelivr.net/gh/simai/ui@main/distr/";if("undefined"==typeof window)return;const t=/\/core\/js\/core(?:\.min)?\.js$/u,o=e=>{if(!e?.src)return!1;try{return t.test(new URL(e.src,document.baseURI).pathname)}catch{return!1}},i="undefined"==typeof document?null:o(document.currentScript)?document.currentScript:Array.from(document.scripts||[]).reverse().find(o)||null;if(!window.sfPath&&i)try{window.sfPath=new URL("../../",new URL(i.src,document.baseURI)).href}catch{}if(!window.sfPath){window.sfPath=e;try{console.warn(`SIMAI Framework: window.sfPath is not set and Core could not tell where it was loaded from, so the runtime is loading from ${e} — an unpinned branch that changes without notice. Set window.sfPath, before core.js, to your own copy of distr/ or to a released package: https://cdn.jsdelivr.net/npm/@simai-studio/ui@<version>/distr/ .`)}catch{}}const s=e=>{try{return new URL(window.sfPath,e||void 0)}catch{return null}},r=s("undefined"==typeof document?"":document.baseURI)||s(window.location?.href)||new URL(e);r.pathname.endsWith("/")||(r.pathname+="/");const a=r.pathname.endsWith("/core/")?r:new URL("core/",r),l=i?new URL("../",new URL(i.src,document.baseURI)):a;n.p!==l.href&&(n.p=l.href)})()},"987c832cfe13"(){window.SF=window.SF||{},SF.RuleLoader={}},"3a00b12d226d"(e,t,n){"use strict";function o(e){if(!e||"[object Object]"!==Object.prototype.toString.call(e))return!1;const t=Object.getPrototypeOf(e);return t===Object.prototype||null===t}function i(e){return Array.isArray(e)?e.map(i):o(e)?Object.fromEntries(Object.keys(e).sort().map(t=>[t,i(e[t])])):e}function s(e){return JSON.stringify(i(e))}n.d(t,{normalize:()=>sn});const r=Object.freeze(["banner","navigation","main","complementary","contentinfo","region","none"]),a=Object.freeze(["block","start","center","end"]),l=Object.freeze(["layout","content","smart"]),c=Object.freeze({maxRegionsPerLayout:12,maxRegionLayoutNesting:4}),u=Object.freeze({banner:"header",navigation:"nav",main:"main",complementary:"aside",contentinfo:"footer",region:"section",none:"div"}),d=new Set(["banner","main","contentinfo"]),f={start:0,center:1,end:2},p=(e,t,n)=>({code:e,path:t,message:n});function m(e){return"layout.region"===e?.type&&"string"==typeof e.props?.landmark?e.props.landmark:null}function h(e,t,n){const i=new Map,s=(e,r,a)=>{if(!o(e))return;"layout.region"===e.type&&"layout.regions"!==a.parentType&&n.push(p("region_parent_invalid",r,"layout.region must be a direct child of layout.regions"));let l={...a,parentType:e.type};if("layout.page"===e.type&&(l.insidePage=!0),"layout.regions"===e.type&&(l.regionDepth=a.regionDepth+1,l.regionDepth>c.maxRegionLayoutNesting&&n.push(p("region_nesting_limit",r,"Region layouts are nested too deeply")),function(e,t,n){const o=Array.isArray(e.slots?.regions)?e.slots.regions:[],i=new Set;let s=-1;o.forEach((e,o)=>{const r=`${t}.slots.regions[${o}]`;if("layout.region"!==e?.type)return;const a=e.props?.name;"string"==typeof a&&(i.has(a)&&n.push(p("region_name_duplicate",`${r}.props.name`,`Region ${a} is declared twice in one layout`)),i.add(a));const l=e.props?.placement??"block";if("block"===l)return void(s=-1);const c=f[l];void 0!==c&&(c<s&&n.push(p("region_order_invalid",`${r}.props.placement`,"Side-by-side regions must be declared in start, center, end order")),s=Math.max(s,c))})}(e,r,n)),"layout.region"===e.type){!function(e,t,n,i){const s=o(e.props)?e.props:{},r=m(e);r&&d.has(r)&&(n.insideLandmark||n.insidePage)&&i.push(p("region_landmark_context",`${t}.props.landmark`,`${r} is only allowed outside other landmarks and layout.page`)),"region"===r&&void 0===s.label&&i.push(p("region_label_required",`${t}.props.label`,"A region landmark requires an accessible label")),"none"===r&&void 0!==s.label&&i.push(p("region_label_forbidden",`${t}.props.label`,"A region without a landmark cannot carry an accessible label"));const a=Array.isArray(e.slots?.default)?e.slots.default:[],l=Number.isInteger(s.min_items)?s.min_items:0,c=Number.isInteger(s.max_items)?s.max_items:500;if(l>c?i.push(p("region_bounds_invalid",`${t}.props`,"min_items must not exceed max_items")):(a.length<l||a.length>c)&&i.push(p("region_cardinality",`${t}.slots.default`,"Region child count is outside its declared range")),Array.isArray(s.accepts)){const e=new Set(s.accepts);a.forEach((o,s)=>{const r=n.registry.types.get(o?.type);r&&!e.has(r.category)&&i.push(p("region_child_category_forbidden",`${t}.slots.default[${s}]`,`${r.category} is not accepted by this region`))})}}(e,r,{...a,registry:t},n);const s=m(e);s&&"none"!==s&&(i.has(s)||i.set(s,[]),i.get(s).push({path:r,label:e.props?.label}),l={...l,insideLandmark:!0})}for(const[t,n]of Object.entries(o(e.slots)?e.slots:{}))Array.isArray(n)&&n.forEach((e,n)=>s(e,`${r}.slots.${t}[${n}]`,l))};s(e,"$.root",{parentType:null,insidePage:!1,insideLandmark:!1,regionDepth:0});for(const[e,t]of i){if("main"===e&&t.length>1){for(const e of t.slice(1))n.push(p("region_landmark_duplicate",`${e.path}.props.landmark`,"A document can contain only one main region"));continue}if(t.length<2)continue;const o=new Set;for(const i of t)void 0!==i.label?o.has(i.label)?n.push(p("region_label_duplicate",`${i.path}.props.label`,`Repeated ${e} regions require distinct labels`)):o.add(i.label):"region"!==e&&n.push(p("region_label_required",`${i.path}.props.label`,`Repeated ${e} regions require distinct labels`))}}async function g(e){const t=(new globalThis.TextEncoder).encode(e),n=await globalThis.crypto.subtle.digest("SHA-256",t);return[...new Uint8Array(n)].map(e=>e.toString(16).padStart(2,"0")).join("")}async function y(e){const t=[],n=async(e,r,a)=>{if(!o(e))return;if("layout.region"===e.type&&a){const n=e.props||{};t.push({layout:a,node:e.id,name:n.name,landmark:n.landmark,placement:n.placement??"block",path:r,digest:`sha256:${await g(s(i(e)))}`})}const l="layout.regions"===e.type?e.id:null;for(const[t,i]of Object.entries(o(e.slots)?e.slots:{}))if(Array.isArray(i))for(let e=0;e<i.length;e+=1)await n(i[e],`${r}.slots.${t}[${e}]`,l)};return await n(e?.root,"$.root",null),t}var b=n("ac24888e7d3e");const w={type:"array",items:{oneOf:[{type:"object",required:["type","value"],additionalProperties:!1,properties:{type:{const:"text"},value:{type:"string",maxLength:1e5},marks:{type:"array",uniqueItems:!0,items:{enum:["strong","em","code"]}}}},{type:"object",required:["type","href","children"],additionalProperties:!1,properties:{type:{const:"link"},href:{type:"string",minLength:1,maxLength:2048},children:{type:"array",minItems:1,items:{type:"object",required:["type","value"],additionalProperties:!1,properties:{type:{const:"text"},value:{type:"string",maxLength:1e5},marks:{type:"array",uniqueItems:!0,items:{enum:["strong","em","code"]}}}}}}}]}},v={type:"object",required:["endpoint","port"],additionalProperties:!1,properties:{endpoint:{type:"string",pattern:"^[a-z][a-z0-9-]{0,31}$"},port:{type:"string",pattern:"^[a-z][a-z0-9-]{0,31}$"}}},_={type:"object",additionalProperties:!1,properties:{}},x=Object.freeze([{...(0,b.xZ)("simai.composition.type-manifest",1),type:"layout.page",version:"1.0.0",category:"layout",mode:"composite",profiles:["ui-layout"],data_schema:_,props_schema:_,presentation:{views:["default"],presets:[],modifiers:[]},slots:{default:{min:0,max:500,categories:["layout","content","smart"]}},renderer:{kind:"builtin",name:"layout.page"},assets:[],capabilities:["html"]},{...(0,b.xZ)("simai.composition.type-manifest",1),type:"layout.section",version:"1.0.0",category:"layout",mode:"composite",profiles:["ui-layout"],data_schema:_,props_schema:_,presentation:{views:["default"],presets:["surface","contrast"],modifiers:["contained","spacious"]},slots:{default:{min:0,max:500,categories:["layout","content","smart"]}},renderer:{kind:"builtin",name:"layout.section"},assets:[],capabilities:["html"]},{...(0,b.xZ)("simai.composition.type-manifest",1),type:"layout.columns",version:"1.0.0",category:"layout",mode:"composite",profiles:["ui-layout"],data_schema:_,props_schema:{type:"object",additionalProperties:!1,properties:{columns:{type:"integer",minimum:1,maximum:12}}},presentation:{views:["default"],presets:[],modifiers:["equal","responsive"]},slots:{columns:{min:1,max:12,categories:["layout","content","smart"]}},renderer:{kind:"builtin",name:"layout.columns"},assets:["composition/layout"],capabilities:["html"]},{...(0,b.xZ)("simai.composition.type-manifest",1),type:"content.heading",version:"1.0.0",category:"content",mode:"leaf",profiles:["ui-layout","structured-content"],data_schema:{type:"object",required:["content"],additionalProperties:!1,properties:{level:{type:"integer",minimum:1,maximum:6},content:w}},props_schema:_,presentation:{views:["default"],presets:[],modifiers:[]},slots:{},renderer:{kind:"builtin",name:"content.heading"},assets:[],capabilities:["html","rich-text"]},{...(0,b.xZ)("simai.composition.type-manifest",1),type:"content.paragraph",version:"1.0.0",category:"content",mode:"leaf",profiles:["ui-layout","structured-content"],data_schema:{type:"object",required:["content"],additionalProperties:!1,properties:{content:w}},props_schema:_,presentation:{views:["default"],presets:[],modifiers:["lead","muted"]},slots:{},renderer:{kind:"builtin",name:"content.paragraph"},assets:[],capabilities:["html","rich-text"]},{...(0,b.xZ)("simai.composition.type-manifest",1),type:"layout.regions",version:"1.0.0",category:"layout",mode:"composite",profiles:["ui-layout"],data_schema:_,props_schema:_,presentation:{views:["default"],presets:[],modifiers:[]},slots:{regions:{min:1,max:12,types:["layout.region"]}},renderer:{kind:"builtin",name:"layout.regions"},assets:[],capabilities:["html","regions"]},{...(0,b.xZ)("simai.composition.type-manifest",1),type:"layout.region",version:"1.0.0",category:"layout",mode:"composite",profiles:["ui-layout"],data_schema:_,props_schema:{type:"object",required:["name","landmark"],additionalProperties:!1,properties:{name:{type:"string",pattern:"^[a-z][a-z0-9-]{0,31}$"},landmark:{enum:[...r]},placement:{enum:[...a]},label:{type:"string",minLength:1,maxLength:120},sticky:{type:"boolean"},accepts:{type:"array",minItems:1,uniqueItems:!0,items:{enum:[...l]}},min_items:{type:"integer",minimum:0,maximum:500},max_items:{type:"integer",minimum:0,maximum:500}}},presentation:{views:["default"],presets:[],modifiers:[]},slots:{default:{min:0,max:500,categories:["layout","content","smart"]}},renderer:{kind:"builtin",name:"layout.region"},assets:[],capabilities:["html","regions"]},{...(0,b.xZ)("simai.composition.type-manifest",1),type:"layout.scope",version:"1.0.0",category:"layout",mode:"composite",profiles:["ui-layout"],data_schema:_,props_schema:{type:"object",required:["routes"],additionalProperties:!1,properties:{routes:{type:"array",minItems:1,maxItems:32,items:{type:"object",required:["id","from","to"],additionalProperties:!1,properties:{id:{type:"string",pattern:"^[a-z][a-z0-9-]{0,63}$"},from:v,to:v}}}}},presentation:{views:["default"],presets:[],modifiers:[]},slots:{default:{min:1,max:500,categories:["layout","content","smart"]}},renderer:{kind:"builtin",name:"layout.scope"},assets:[],capabilities:["html","hydration","routing"]}]),$=Object.freeze([{...(0,b.xZ)("simai.composition.port-manifest",1),element:"sf-table",version:"1.0.0",component:"smart.data-view",component_version:"1.2.0",outputs:{selection:{value:"record-ids.v1",summary:"Explicit current-result selection of this instance, emitted once per change, including clearing."}},inputs:{context:{value:"record-ids.v1",effect:"request",summary:"Restricts this collection to records related to the given identities. The table clears its selection, enters loading and emits sf-table-query-intent with the route sequence; the host resolves the relation and access and answers with applyQueryResult.",request_event:"sf-table-query-intent",result_method:"applyQueryResult"}}}]),k=Object.freeze([{...(0,b.xZ)("simai.composition.editor-manifest",1),type:"layout.section",type_version:"1.0.0",fields:[{key:"surface",plane:"presentation",target:"preset",property:{type:"string",version:2},constraints:{min_length:1,max_length:32},group:"preset",visibility:"visible",choices:["surface","contrast"],default:"surface",label_key:"sf.composition.layout_section.surface",help_key:"sf.composition.layout_section.surface_help",capability_hints:["composition.presentation.preset"],permission_hints:["composition.node.update"],owner:"simai/framework"}]},{...(0,b.xZ)("simai.composition.editor-manifest",1),type:"layout.columns",type_version:"1.0.0",fields:[{key:"columns",plane:"props",target:"columns",property:{type:"integer",version:1},constraints:{min:1,max:12},group:"basic",visibility:"visible",default:2,label_key:"sf.composition.layout_columns.columns",help_key:"sf.composition.layout_columns.columns_help",capability_hints:["composition.props.columns"],permission_hints:["composition.node.update"],owner:"simai/framework"}]},{...(0,b.xZ)("simai.composition.editor-manifest",1),type:"content.heading",type_version:"1.0.0",fields:[{key:"level",plane:"data",target:"level",property:{type:"integer",version:1},constraints:{min:1,max:6},group:"advanced",visibility:"collapsed",default:2,label_key:"sf.composition.content_heading.level",help_key:"sf.composition.content_heading.level_help",capability_hints:["composition.data.level"],permission_hints:["composition.node.update"],owner:"simai/framework"}]},{...(0,b.xZ)("simai.composition.editor-manifest",1),type:"layout.region",type_version:"1.0.0",fields:[{key:"placement",plane:"props",target:"placement",property:{type:"string",version:2},constraints:{min_length:1,max_length:16},group:"basic",visibility:"visible",choices:[...a],default:"block",label_key:"sf.composition.layout_region.placement",help_key:"sf.composition.layout_region.placement_help",capability_hints:["composition.props.placement"],permission_hints:["composition.node.update"],owner:"simai/framework"},{key:"label",plane:"props",target:"label",property:{type:"string",version:2},constraints:{min_length:1,max_length:120},group:"basic",visibility:"visible",label_key:"sf.composition.layout_region.label",help_key:"sf.composition.layout_region.label_help",capability_hints:["composition.props.label"],permission_hints:["composition.node.update"],owner:"simai/framework"},{key:"landmark",plane:"props",target:"landmark",property:{type:"string",version:2},constraints:{min_length:1,max_length:16},group:"advanced",visibility:"collapsed",choices:[...r],label_key:"sf.composition.layout_region.landmark",help_key:"sf.composition.layout_region.landmark_help",capability_hints:["composition.props.landmark"],permission_hints:["composition.node.update"],owner:"simai/framework"},{key:"sticky",plane:"props",target:"sticky",property:{type:"boolean",version:1},constraints:{},group:"advanced",visibility:"collapsed",default:!1,label_key:"sf.composition.layout_region.sticky",help_key:"sf.composition.layout_region.sticky_help",capability_hints:["composition.props.sticky"],permission_hints:["composition.node.update"],owner:"simai/framework"}]}]),S=new Set(["schema","schema_version","type","type_version","applies_to","fields"]),E=new Set(["views","presets","modifiers"]),O=new Set(["key","plane","target","property","constraints","group","visibility","choices","default","label_key","help_key","capability_hints","permission_hints","owner"]),T=new Set(["type","version"]),j=new Set(["props","data","presentation"]),A=new Set(["preset","basic","advanced"]),L=new Set(["visible","collapsed","hidden"]),P=new Set(["view","preset"]),z=new Set(["actor","authorization","class","classname","cookie","endpoint","eval","expression","function","handler","html","innerhtml","javascript","method","password","php","query","request","script","secret","sql","token"]),R=(e,t,n)=>({code:e,path:t,message:n}),C=e=>"string"==typeof e&&/^[a-z][a-z0-9_]*(?:\.[a-z][a-z0-9_]*)*$/u.test(e),F=e=>null===e||"string"==typeof e||"boolean"==typeof e||"number"==typeof e&&Number.isFinite(e),N=e=>"string"==typeof e&&e.split(".").some(e=>z.has(e.toLowerCase().replaceAll("-","").replaceAll("_","")));function I(e,t,n,i){if(o(e))for(const o of Object.keys(e))t.has(o)||i.push(R("editor_unknown_field",`${n}.${o}`,`Unknown editor field ${o}`))}function M(e,t,n){if(Array.isArray(e))e.forEach((e,o)=>M(e,`${t}[${o}]`,n));else if(o(e))for(const[o,i]of Object.entries(e)){const e=o.toLowerCase().replaceAll("-","").replaceAll("_","");z.has(e)&&n.push(R("editor_executable_or_secret_field_forbidden",`${t}.${o}`,`Field ${o} is not portable editor metadata`)),M(i,`${t}.${o}`,n)}}function q(e,t,n){void 0!==e&&(!Array.isArray(e)||e.length>50||e.some(e=>!C(e))||new Set(e).size!==e.length)&&n.push(R("editor_hint_list_invalid",t,"Hints must be a bounded unique stable-key list"))}function D(e,t,n={}){const i=[];if(!o(e))return{valid:!1,diagnostics:[R("editor_manifest_invalid","$","Editor manifest must be an object")]};var r;if(I(e,S,"$",i),M(e,"$",i),(0,b.Wl)(e,"simai.composition.editor-manifest",1)||i.push(R("editor_schema_unknown","$.schema","Expected simai.composition.editor-manifest.v1, or simai.composition.editor-manifest with schema_version 1")),"string"==typeof(r=e.type)&&/^[a-z][a-z0-9-]*(?:\.[a-z][a-z0-9-]*)+$/u.test(r)||i.push(R("editor_type_invalid","$.type","Component type is invalid")),(e=>"string"==typeof e&&/^[0-9]+\.[0-9]+\.[0-9]+$/u.test(e))(e.type_version)||i.push(R("editor_type_version_invalid","$.type_version","Component type version is invalid")),o(t)&&t.type===e.type&&t.version===e.type_version||i.push(R("editor_type_registration_mismatch","$.type","Editor manifest must bind one exact registered type revision")),function(e,t,n){if(void 0!==e)if(o(e)){I(e,E,"$.applies_to",n);for(const[o,i]of[["views","views"],["presets","presets"],["modifiers","modifiers"]]){if(void 0===e[o])continue;if(!Array.isArray(e[o])||0===e[o].length||e[o].some(e=>"string"!=typeof e)||new Set(e[o]).size!==e[o].length){n.push(R("editor_applies_to_invalid",`$.applies_to.${o}`,`${o} must be a non-empty unique string list`));continue}const s=new Set(t.presentation?.[i]||[]);for(const t of e[o])s.has(t)||n.push(R("editor_presentation_choice_unknown",`$.applies_to.${o}`,`${t} is not registered by the type manifest`))}}else n.push(R("editor_applies_to_invalid","$.applies_to","applies_to must be an object"))}(e.applies_to,t||{},i),!Array.isArray(e.fields)||e.fields.length>200)return i.push(R("editor_fields_invalid","$.fields","fields must be a bounded array")),{valid:!1,diagnostics:i};const a=new Set,l=new Set,c=function(e){if(void 0===e)return null;const t=new Set;for(const n of e)"string"==typeof n?t.add(n):o(n)&&t.add(`${n.type}@${n.version}`);return t}(n.propertyTypes);return e.fields.forEach((e,n)=>{const r=`$.fields[${n}]`;if(!o(e))return void i.push(R("editor_field_invalid",r,"Editor field must be an object"));I(e,O,r,i),C(e.key)?a.has(e.key)?i.push(R("editor_field_key_duplicate",`${r}.key`,`Duplicate field key ${e.key}`)):a.add(e.key):i.push(R("editor_field_key_invalid",`${r}.key`,"Field key must be stable")),j.has(e.plane)||i.push(R("editor_plane_unknown",`${r}.plane`,"Field plane is unknown")),C(e.target)||i.push(R("editor_target_invalid",`${r}.target`,"Field target must be stable")),N(e.key)&&i.push(R("editor_executable_or_secret_field_forbidden",`${r}.key`,"Field key names executable or secret data")),N(e.target)&&i.push(R("editor_executable_or_secret_field_forbidden",`${r}.target`,"Field target names executable or secret data"));const u=`${e.plane}.${e.target}`;if(l.has(u)?i.push(R("editor_destination_duplicate",`${r}.target`,`Duplicate destination ${u}`)):l.add(u),A.has(e.group)||i.push(R("editor_group_unknown",`${r}.group`,"Field group is unknown")),L.has(e.visibility)||i.push(R("editor_visibility_unknown",`${r}.visibility`,"Field visibility is unknown")),C(e.label_key)||i.push(R("editor_label_key_invalid",`${r}.label_key`,"Localization key must be stable")),void 0===e.help_key||C(e.help_key)||i.push(R("editor_help_key_invalid",`${r}.help_key`,"Help localization key must be stable")),q(e.capability_hints,`${r}.capability_hints`,i),q(e.permission_hints,`${r}.permission_hints`,i),(e=>"string"==typeof e&&/^[a-z][a-z0-9.-]*\/[a-z][a-z0-9.-]*$/u.test(e))(e.owner)||i.push(R("editor_owner_invalid",`${r}.owner`,"Owner must be a portable owner id")),o(e.constraints)||i.push(R("editor_constraints_invalid",`${r}.constraints`,"Constraints must be an object")),o(e.property)?(I(e.property,T,`${r}.property`,i),C(e.property.type)||i.push(R("editor_property_type_invalid",`${r}.property.type`,"Property type must be stable")),(!Number.isInteger(e.property.version)||e.property.version<1)&&i.push(R("editor_property_version_invalid",`${r}.property.version`,"Property version must be positive")),c&&!c.has(`${e.property.type}@${e.property.version}`)&&i.push(R("editor_property_registration_unknown",`${r}.property`,"Property type and version are not registered by the host"))):i.push(R("editor_property_invalid",`${r}.property`,"Property identity must be an object")),void 0!==e.choices&&(!Array.isArray(e.choices)||0===e.choices.length||e.choices.length>200||e.choices.some(e=>!F(e))||new Set(e.choices.map(s)).size!==e.choices.length)&&i.push(R("editor_choices_invalid",`${r}.choices`,"Choices must be a bounded unique scalar list")),"default"in e&&!F(e.default)&&i.push(R("editor_default_invalid",`${r}.default`,"Default must be scalar")),"default"in e&&Array.isArray(e.choices)&&!e.choices.some(t=>s(t)===s(e.default))&&i.push(R("editor_default_choice_unknown",`${r}.default`,"Default must be one of the allowed choices")),"presentation"===e.plane){P.has(e.target)||i.push(R("editor_presentation_target_unsupported",`${r}.target`,"Only view and preset are scalar editable presentation targets"));const n=new Set(function(e,t){return"view"===t?e.presentation?.views||[]:"preset"===t&&e.presentation?.presets||[]}(t||{},e.target));for(const t of e.choices||[])"string"==typeof t&&n.has(t)||i.push(R("editor_presentation_choice_unknown",`${r}.choices`,`${String(t)} is not registered by the type manifest`))}else if(j.has(e.plane)&&o(t)){const n="props"===e.plane?t.props_schema:t.data_schema;o(n?.properties)&&e.target in n.properties||i.push(R("editor_destination_unknown",`${r}.target`,`${u} is not declared by the type manifest`))}}),{valid:0===i.length,diagnostics:i}}function B(e,t,n,r={}){const a=D(e,t,r);if(!a.valid)return{valid:!1,fields:[],diagnostics:a.diagnostics};const l=[],c=e.fields.map(e=>{const t=function(e,t){const n=e?.[t.plane];return o(n)&&t.target in n?{value:n[t.target],source:"node"}:"default"in t?{value:t.default,source:"default"}:{value:null,source:"unset"}}(n,e);return"unset"!==t.source&&e.choices&&!e.choices.some(e=>s(e)===s(t.value))&&l.push(R("editor_choice_unknown",`node:${n?.id||""}.${e.plane}.${e.target}`,"Current value is not an allowed choice")),i({...e,destination:`${e.plane}.${e.target}`,...t})});return{valid:0===l.length,fields:c,diagnostics:l}}function U(e,t,n,o={}){const i=new Map;for(const e of n||[]){const t=`${e.type}@${e.type_version}`;if(i.has(t))return{valid:!1,instances:[],diagnostics:[R("editor_manifest_duplicate","$",`Duplicate editor manifest ${t}`)]};i.set(t,e)}const s=[],r=[],a=e=>{const n=t?.types instanceof Map?t.types.get(e.type):void 0;if(n){const t=i.get(`${n.type}@${n.version}`);if(t){const i=B(t,n,e,o);r.push(...i.diagnostics.map(t=>({...t,instance:e.id}))),s.push({id:e.id,type:e.type,fields:i.fields})}}for(const t of Object.values(e.slots||{}))for(const e of t)a(e)};return e?.root&&a(e.root),{valid:0===r.length,instances:s,diagnostics:r}}const W=/^[a-z][a-z0-9_]*$/u,H=/^-?(?:0|[1-9][0-9]*)$/u,V=Object.freeze([{...(0,b.xZ)("simai.composition.editor-field-kind",1),kind:"choice",version:1,status:"formalized-existing",match:{property:[{type:"string",version:1},{type:"string",version:2}],choices:"required"},value_schema:{type:"string",minLength:1},default:{kind:null,field:"must-be-a-choice"},constraints:{allowed:["min_length","max_length"]},normalization:{form:"exact-string",unset:"absent-field",stored:"value"},validation:["choice-member"],accessibility:{control:"select",role:"combobox",name:"label_key",description:"help_key via aria-describedby",keyboard:["Tab","ArrowUp","ArrowDown","Enter","Space","Escape"]},themes:{modes:["light","dark"],tokens:["--sf-surface-1","--sf-on-surface","--sf-outline","--sf-primary"],contrast:"WCAG 2.2 AA"},localization:{label:"label_key",help:"help_key",value_labels:"<label_key>.<choice> when the choice is a stable segment, otherwise the raw choice",direction:"logical"},server_fallback:{element:"select",value:"option value",enhanced_control:"sf-dropdown"}},{...(0,b.xZ)("simai.composition.editor-field-kind",1),kind:"integer",version:1,status:"formalized-existing",match:{property:[{type:"integer",version:1}],choices:"forbidden"},value_schema:{type:"integer",minimum:-9007199254740991,maximum:9007199254740991},default:{kind:null,field:"must-satisfy-constraints"},constraints:{allowed:["min","max"],required:["min","max"]},normalization:{form:"decimal-integer-text",unset:"empty-text",stored:"safe-integer"},validation:["integer-text","range"],accessibility:{control:"input[type=number]",role:"spinbutton",name:"label_key",description:"help_key via aria-describedby",keyboard:["Tab","ArrowUp","ArrowDown","digits"]},themes:{modes:["light","dark"],tokens:["--sf-surface-1","--sf-on-surface","--sf-outline","--sf-primary"],contrast:"WCAG 2.2 AA"},localization:{label:"label_key",help:"help_key",value_labels:"none",direction:"logical",digits:"ASCII decimal"},server_fallback:{element:"input",type:"number",attributes:["min","max","step=1","inputmode=numeric"],enhanced_control:"sf-input"}},{...(0,b.xZ)("simai.composition.editor-field-kind",1),kind:"text",version:1,status:"new",match:{property:[{type:"string",version:2}],choices:"forbidden"},value_schema:{type:"string",minLength:1,maxLength:2e3},default:{kind:null,field:"must-satisfy-constraints"},constraints:{allowed:["min_length","max_length"],required:["max_length"]},normalization:{form:"exact-string-no-trim-no-unicode-normalization",unset:"empty-text",stored:"value"},validation:["code-point-length","no-control-characters","well-formed-unicode"],accessibility:{control:"input[type=text]",role:"textbox",name:"label_key",description:"help_key via aria-describedby",keyboard:["Tab","text entry"],attributes:["dir=auto","maxlength"]},themes:{modes:["light","dark"],tokens:["--sf-surface-1","--sf-on-surface","--sf-outline","--sf-primary"],contrast:"WCAG 2.2 AA"},localization:{label:"label_key",help:"help_key",value_labels:"none",direction:"dir=auto per value; value is author content in the Document locale"},server_fallback:{element:"input",type:"text",attributes:["maxlength","dir=auto"],enhanced_control:"sf-input"}},{...(0,b.xZ)("simai.composition.editor-field-kind",1),kind:"toggle",version:1,status:"new",match:{property:[{type:"boolean",version:1}],choices:"forbidden"},value_schema:{type:"boolean"},default:{kind:!1,field:"false-or-absent"},constraints:{allowed:[]},normalization:{form:"present-true-absent-false",unset:"false",stored:"true only; false removes the key"},validation:["strict-boolean"],accessibility:{control:"input[type=checkbox][role=switch]",role:"switch",name:"label_key",description:"help_key via aria-describedby",keyboard:["Tab","Space"],states:["checked"]},themes:{modes:["light","dark"],tokens:["--sf-surface-1","--sf-on-surface","--sf-outline","--sf-primary"],contrast:"WCAG 2.2 AA"},localization:{label:"label_key",help:"help_key",value_labels:"none",direction:"logical"},server_fallback:{element:"input",type:"checkbox",attributes:["role=switch","value=true"],enhanced_control:"sf-switch"}}]),Z=(e,t,n)=>({code:e,path:t,message:n});function J(e){return[...e].length}function G(e,t=V){if(!o(e?.property))return null;const n=Array.isArray(e.choices),i=t.filter(t=>t.match.property.some(t=>t.type===e.property.type&&t.version===e.property.version)&&("required"===t.match.choices?n:!n));return 1===i.length?i[0]:null}function X(e,t,n="$"){const i=G(e);if(!i)return[Z("field_kind_unknown",n,"The field does not map to exactly one published kind")];const s=o(e.constraints)?e.constraints:{},r=[];if("choice"===i.kind)"string"==typeof t&&e.choices.includes(t)||r.push(Z("field_value_choice",n,"Value is not an allowed choice"));else if("integer"===i.kind)Number.isSafeInteger(t)?(Number.isInteger(s.min)&&t<s.min||Number.isInteger(s.max)&&t>s.max)&&r.push(Z("field_value_range",n,"Value is outside the allowed range")):r.push(Z("field_value_type",n,"Value must be a safe integer"));else if("text"===i.kind)if("string"!=typeof t)r.push(Z("field_value_type",n,"Value must be a string"));else if(function(e){for(let t=0;t<e.length;t+=1){const n=e.charCodeAt(t);if(n>=55296&&n<=56319){const n=e.charCodeAt(t+1);if(!(n>=56320&&n<=57343))return!1;t+=1}else if(n>=56320&&n<=57343)return!1}return!0}(t))if(function(e){for(let t=0;t<e.length;t+=1){const n=e.charCodeAt(t);if(n<32||127===n)return!0}return!1}(t))r.push(Z("field_value_control",n,"Value cannot contain control characters"));else{const e=J(t),o=Math.max(1,Number.isInteger(s.min_length)?s.min_length:1),i=Math.min(2e3,Number.isInteger(s.max_length)?s.max_length:2e3);(e<o||e>i)&&r.push(Z("field_value_length",n,"Value length is outside the allowed range"))}else r.push(Z("field_value_unicode",n,"Value must be well-formed Unicode"));else"toggle"===i.kind&&"boolean"!=typeof t&&r.push(Z("field_value_type",n,"Value must be a boolean"));return r}function Y(e){const t=[];return(Array.isArray(e?.fields)?e.fields:[]).forEach((e,n)=>{const i=`$.fields[${n}]`,s=G(e);if(!s)return void t.push(Z("field_kind_unknown",i,"The field does not map to exactly one published kind"));const r=o(e.constraints)?e.constraints:{};for(const e of Object.keys(r))s.constraints.allowed.includes(e)||t.push(Z("field_constraint_unknown",`${i}.constraints.${e}`,`${e} is not a ${s.kind} constraint`));for(const e of s.constraints.required||[])Number.isInteger(r[e])||t.push(Z("field_constraint_required",`${i}.constraints.${e}`,`${s.kind} requires ${e}`));if("choice"===s.kind){const n=Number.isInteger(r.min_length)?r.min_length:0,o=Number.isInteger(r.max_length)?r.max_length:1/0;n>o&&t.push(Z("field_constraint_invalid",`${i}.constraints`,"min_length must not exceed max_length"));for(const s of e.choices)("string"!=typeof s||J(s)<n||J(s)>o)&&t.push(Z("field_choice_invalid",`${i}.choices`,`${String(s)} violates the choice constraints`))}"integer"===s.kind&&Number.isInteger(r.min)&&Number.isInteger(r.max)&&r.min>r.max&&t.push(Z("field_constraint_invalid",`${i}.constraints`,"min must not exceed max")),"text"===s.kind&&Number.isInteger(r.min_length)&&Number.isInteger(r.max_length)&&r.min_length>r.max_length&&t.push(Z("field_constraint_invalid",`${i}.constraints`,"min_length must not exceed max_length")),"toggle"===s.kind&&"default"in e&&!1!==e.default&&t.push(Z("field_default_invalid",`${i}.default`,"A toggle default must be false or absent")),"toggle"!==s.kind&&"default"in e&&t.push(...X(e,e.default,`${i}.default`).map(e=>({...e,code:"field_default_invalid"})))}),t}function K(e,t){const n=G(e);if(!n)return{error:Z("field_kind_unknown","$","The field does not map to exactly one published kind")};if(null!==t&&"string"!=typeof t)return{error:Z("field_submission_invalid","$","A submission must be a string or absent")};let o;if("toggle"===n.kind)return null!==t&&"true"!==t?{error:Z("field_submission_invalid","$","A toggle submits only true")}:"true"===t?{value:!0}:{unset:!0};if(null===t||""===t)return{unset:!0};if("integer"===n.kind){if(!H.test(t))return{error:Z("field_value_type","$","Value must be a decimal integer")};o=Number(t)}else o=t;const i=X(e,o);return i.length?{error:i[0]}:{value:o}}function Q(e,t,n){if(!o(n)||n.error||!0!==n.unset&&!("value"in n))throw new TypeError("applyFieldValue requires a successful parseFieldSubmission result");const s=i(JSON.parse(JSON.stringify(e))),r=o(s[t.plane])?{...s[t.plane]}:{};return n.unset||"toggle"===G(t)?.kind&&!1===n.value?delete r[t.target]:r[t.target]=n.value,Object.keys(r).length?s[t.plane]=r:delete s[t.plane],i(s)}function ee(e){return String(e).replaceAll("&","&amp;").replaceAll("<","&lt;").replaceAll(">","&gt;").replaceAll('"',"&quot;").replaceAll("'","&#39;")}function te(e,{instance:t,messages:n={}}={}){const o=G(e);if(!o)throw new TypeError("field_kind_unknown");if("hidden"===e.visibility)return"";const i=function(e,t){return`sf-field-${e}-${t.key}`.replace(/[^A-Za-z0-9_-]/gu,"-")}(t,e),s=ee(`${t}.${e.plane}.${e.target}`),r=ee(n[e.label_key]??e.label_key),a=e.help_key?`${i}-help`:null,l=a?` aria-describedby="${a}"`:"",c=a?`<small class="sf-editor-field-help" id="${a}">${ee(n[e.help_key]??e.help_key)}</small>`:"",u=e.value??e.default??null,d=e.constraints||{};let f;if("toggle"===o.kind)f=`<input class="sf-editor-field-control" type="checkbox" role="switch" id="${i}" name="${s}" value="true"${!0===u?" checked":""}${l}><label for="${i}">${r}</label>`;else if("choice"===o.kind){const t=e.choices.map(t=>{const o=W.test(t)?n[`${e.label_key}.${t}`]??t:t;return`<option value="${ee(t)}"${t===u?" selected":""}>${ee(o)}</option>`}).join("");f=`<label for="${i}">${r}</label><select class="sf-editor-field-control" id="${i}" name="${s}"${l}>${null===u?'<option value="" selected></option>':""}${t}</select>`}else if("integer"===o.kind){f=`<label for="${i}">${r}</label><input class="sf-editor-field-control" type="number" inputmode="numeric" step="1"${`${Number.isInteger(d.min)?` min="${d.min}"`:""}${Number.isInteger(d.max)?` max="${d.max}"`:""}`} id="${i}" name="${s}" value="${null===u?"":ee(u)}"${l}>`}else{f=`<label for="${i}">${r}</label><input class="sf-editor-field-control" type="text" dir="auto" maxlength="${Math.min(2e3,Number.isInteger(d.max_length)?d.max_length:2e3)}" id="${i}" name="${s}" value="${null===u?"":ee(u)}"${l}>`}const p=`<div class="sf-editor-field" data-sf-field-kind="${o.kind}" data-sf-field-group="${ee(e.group)}">${f}${c}</div>`;return"collapsed"===e.visibility?`<details class="sf-editor-field-disclosure"><summary>${r}</summary>${p}</details>`:p}const ne="simai.recipe.canonical-json.v1",oe=new Set([ne,"simai.recipe.canonical-json"]);function ie(e,t){return"name"===(0,b.G7)(e)?.form?(0,b.xZ)(t,1):{schema:`${t}.v1`}}const se=e=>ie(e,"simai.composition.document"),re=Object.freeze({maxRecipeBytes:1048576,maxSourceBytes:1048576,maxTotalSourceBytes:8388608,maxInputBytes:1048576,maxTotalInputBytes:4194304,maxUniqueReferences:128,maxInputs:256,maxReferenceDepth:16,maxExpansionSteps:1e4,maxIntermediateBytes:4194304,maxOutputBytes:1048576,maxOutputNodes:2e3,maxOutputDepth:32,maxChildrenPerSlot:500,maxSelectCases:64}),ae=re,le={node:new Set(["id","node"]),ref:new Set(["id","ref","params","slots","extensions"]),select:new Set(["id","select"]),insertSlot:new Set(["id","insertSlot"])},ce=new Set(["type","data","props","presentation","slots","bindings","extensions"]),ue=new Set(["schema","schema_version","id","profile","locale","inputs","root","extensions"]),de=new Set(["schema","schema_version","scope","values","extensions"]),fe=new Set(["schema","schema_version","id","parameters","slots","body","extensions"]),pe=new Set(["kind","schema","default","expectedOrigin","extensions"]),me=/^[A-Za-z0-9][A-Za-z0-9._:-]{0,119}$/u;function he(e){if(!e||"[object Object]"!==Object.prototype.toString.call(e))return!1;const t=Object.getPrototypeOf(e);return t===Object.prototype||null===t}function ge(e){return JSON.parse(JSON.stringify(e))}function ye(e){return(new globalThis.TextEncoder).encode("string"==typeof e?e:JSON.stringify(e)).byteLength}function be(e){if("string"!=typeof e||65279===e.charCodeAt(0))throw Object.assign(new SyntaxError("Invalid JSON input"),{code:"invalid_json",sourcePath:"$"});let t=0;const n=()=>{for(;/\s/u.test(e[t]||"")&&![" "].includes(e[t]);)t+=1},o=()=>{if('"'!==e[t])throw new SyntaxError("Expected string");const n=t++;for(;t<e.length;){const o=e.charCodeAt(t);if(34===o){t+=1;const o=JSON.parse(e.slice(n,t));for(let e=0;e<o.length;e+=1){const t=o.charCodeAt(e);if(t>=55296&&t<=56319){const t=o.charCodeAt(e+1);if(!(t>=56320&&t<=57343))throw new SyntaxError("Unpaired surrogate");e+=1}else if(t>=56320&&t<=57343)throw new SyntaxError("Unpaired surrogate")}return o}if(o<32)throw new SyntaxError("Control character in string");if(92===o){if(t+=1,"u"===e[t]){if(!/^[0-9a-fA-F]{4}$/u.test(e.slice(t+1,t+5)))throw new SyntaxError("Invalid Unicode escape");t+=5;continue}if(!/["\\/bfnrt]/u.test(e[t]||""))throw new SyntaxError("Invalid escape")}t+=1}throw new SyntaxError("Unterminated string")},i=()=>{if(n(),"{"===e[t]){t+=1,n();const s=new Set;if("}"===e[t])return void(t+=1);for(;t<e.length;){n();const r=o();if(s.has(r))throw new SyntaxError(`Duplicate key ${r}`);if(s.add(r),n(),":"!==e[t++])throw new SyntaxError("Expected colon");if(i(),n(),"}"===e[t])return void(t+=1);if(","!==e[t++])throw new SyntaxError("Expected comma")}throw new SyntaxError("Unterminated object")}if("["===e[t]){if(t+=1,n(),"]"===e[t])return void(t+=1);for(;t<e.length;){if(i(),n(),"]"===e[t])return void(t+=1);if(","!==e[t++])throw new SyntaxError("Expected comma")}throw new SyntaxError("Unterminated array")}if('"'===e[t])return void o();const s=/^(?:true|false|null|-?(?:0|[1-9][0-9]*)(?:\.[0-9]+)?(?:[eE][+-]?[0-9]+)?)/u.exec(e.slice(t));if(!s)throw new SyntaxError("Invalid JSON value");t+=s[0].length};try{if(i(),n(),t!==e.length)throw new SyntaxError("Trailing JSON data");const o=JSON.parse(e);return xe(o),o}catch(e){if("invalid_value"===e?.code)throw e;throw Object.assign(new SyntaxError(e.message),{code:"invalid_json",sourcePath:"$"})}}async function we(e){if(!globalThis.crypto?.subtle)throw new Error("composition_crypto_unavailable");const t=await globalThis.crypto.subtle.digest("SHA-256",(new globalThis.TextEncoder).encode(e));return[...new Uint8Array(t)].map(e=>e.toString(16).padStart(2,"0")).join("")}async function ve(e){return xe(e),`sha256:${await we(s(e))}`}async function _e(e,t){return`n-${await we(s(["sf-composition-node-v1",e,t]))}`}function xe(e,t="$",n=new Set){if(null!==e&&"string"!=typeof e&&"boolean"!=typeof e)if("number"!=typeof e){if("object"!=typeof e||!Array.isArray(e)&&!he(e)||n.has(e))throw Object.assign(new TypeError("value is not canonical JSON"),{code:"invalid_json",sourcePath:t});n.add(e),Array.isArray(e)?e.forEach((e,o)=>xe(e,`${t}/${o}`,n)):Object.entries(e).forEach(([e,o])=>{/^[0-9]+$/u.test(e)&&Number(e),xe(o,`${t}/${e.replaceAll("~","~0").replaceAll("/","~1")}`,n)}),n.delete(e)}else if(!Number.isSafeInteger(e)||e<-9007199254740991||e>9007199254740991)throw Object.assign(new TypeError("invalid canonical number"),{code:"invalid_value",sourcePath:t})}function $e(e,t,n){if(!he(e))throw Object.assign(new TypeError("Expected object"),{code:"invalid_value",sourcePath:n});for(const o of Object.keys(e))if(!t.has(o))throw Object.assign(new TypeError(`Unknown field ${o}`),{code:"unknown_field",sourcePath:`${n}/${o}`})}function ke(e,t,n){if(void 0!==e){if(!he(e))throw Object.assign(new TypeError("Extensions must be an object"),{code:"invalid_value",sourcePath:t});for(const[o,i]of Object.entries(e)){if(!/^[a-z][a-z0-9.-]*:[a-z][a-z0-9._-]*$/u.test(o))throw Object.assign(new TypeError("Extension name must be namespaced"),{code:"invalid_value",sourcePath:`${t}/${o}`});if(he(i)&&!0===i.required&&!n.has(o))throw Object.assign(new Error(`Required extension ${o} is unsupported`),{code:"unsupported_extension",sourcePath:`${t}/${o}`})}}}function Se(e,t){if(!he(e))throw Object.assign(new TypeError("Value wrapper is required"),{code:"invalid_value",sourcePath:t});const n=["literal","input","parameter"].filter(t=>Object.hasOwn(e,t));if(1!==n.length||1!==Object.keys(e).length)throw Object.assign(new TypeError("Value must have exactly one form"),{code:"invalid_value",sourcePath:t});if("literal"!==n[0]&&!me.test(e[n[0]]||""))throw Object.assign(new TypeError("Value reference is invalid"),{code:"invalid_value",sourcePath:t})}function Ee(e){const t=["node","ref","select","insertSlot"].filter(t=>Object.hasOwn(e||{},t));if(1!==t.length)throw Object.assign(new TypeError("Entry must contain one form"),{code:"invalid_value"});return t[0]}function Oe(e,t,{insertionAllowed:n=!1,localIds:o=new Set,maxSelectCases:i=ae.maxSelectCases,supportedExtensions:s=new Set}={}){if(!he(e)||!me.test(e.id||""))throw Object.assign(new TypeError("Invalid entry id"),{code:"invalid_value",sourcePath:`${t}/id`});const r=Ee(e);if("insertSlot"===r&&!n)throw Object.assign(new TypeError("Insertion is only valid inside a slot"),{code:"invalid_value",sourcePath:t});if($e(e,le[r],t),o.has(e.id))throw Object.assign(new TypeError("Duplicate local id"),{code:"duplicate_id",sourcePath:`${t}/id`});if(o.add(e.id),"node"===r){if($e(e.node,ce,`${t}/node`),!/^[a-z][a-z0-9-]*(?:\.[a-z][a-z0-9-]*)+$/u.test(e.node.type||""))throw Object.assign(new TypeError("Node type is invalid"),{code:"unknown_type",sourcePath:`${t}/node/type`});for(const[n,o]of Object.entries({data:e.node.data,props:e.node.props,presentation:e.node.presentation}))for(const[e,i]of Object.entries(o||{}))Se(i,`${t}/node/${n}/${e}`);for(const[n,o]of(e.node.bindings||[]).entries())if($e(o,new Set(["input","target"]),`${t}/node/bindings/${n}`),!me.test(o.input||"")||!me.test(o.target||""))throw Object.assign(new TypeError("Binding is invalid"),{code:"invalid_value",sourcePath:`${t}/node/bindings/${n}`});ke(e.node.extensions,`${t}/node/extensions`,s);for(const[n,r]of Object.entries(e.node.slots||{})){if(!Array.isArray(r))throw Object.assign(new TypeError("Slot must be an array"),{code:"invalid_value",sourcePath:`${t}/node/slots/${n}`});r.forEach((e,r)=>Oe(e,`${t}/node/slots/${n}/${r}`,{insertionAllowed:!0,localIds:o,maxSelectCases:i,supportedExtensions:s}))}}else if("ref"===r){if(!he(e.ref))throw Object.assign(new TypeError("Reference is invalid"),{code:"invalid_value",sourcePath:`${t}/ref`});const n="pinned"===e.ref.policy?new Set(["kind","owner","ref","policy","revision","extensions"]):new Set(["kind","owner","ref","policy","pointer","extensions"]);if($e(e.ref,n,`${t}/ref`),!["template","fragment"].includes(e.ref.kind)||!["pinned","follow-published"].includes(e.ref.policy))throw Object.assign(new TypeError("Reference kind or policy is invalid"),{code:"invalid_value",sourcePath:`${t}/ref`});const r="pinned"===e.ref.policy?e.ref.revision:e.ref.pointer;if(![e.ref.owner,e.ref.ref,r].every(e=>"string"==typeof e&&e))throw Object.assign(new TypeError("Reference identity is incomplete"),{code:"invalid_value",sourcePath:`${t}/ref`});for(const[n,o]of Object.entries(e.params||{}))Se(o,`${t}/params/${n}`);ke(e.ref.extensions,`${t}/ref/extensions`,s),ke(e.extensions,`${t}/extensions`,s);for(const[n,r]of Object.entries(e.slots||{})){if(!Array.isArray(r))throw Object.assign(new TypeError("Slot must be an array"),{code:"invalid_value",sourcePath:`${t}/slots/${n}`});r.forEach((e,r)=>Oe(e,`${t}/slots/${n}/${r}`,{insertionAllowed:!1,localIds:o,maxSelectCases:i,supportedExtensions:s}))}}else if("select"===r){$e(e.select,new Set(["value","cases","missingCase"]),`${t}/select`),Se(e.select.value,`${t}/select/value`);const n=e.select?.cases;if(!he(n)||0===Object.keys(n).length)throw Object.assign(new TypeError("Select needs cases"),{code:"invalid_value",sourcePath:`${t}/select/cases`});if(Object.keys(n).length>i)throw Object.assign(new RangeError("Select case limit exceeded"),{code:"limit_exceeded",sourcePath:`${t}/select/cases`});if(void 0!==e.select.missingCase&&!Object.hasOwn(n,e.select.missingCase))throw Object.assign(new TypeError("Missing case must name an existing case"),{code:"invalid_value",sourcePath:`${t}/select/missingCase`});for(const[e,o]of Object.entries(n))Oe(o,`${t}/select/cases/${e}`,{localIds:new Set,maxSelectCases:i,supportedExtensions:s})}else if(!me.test(e.insertSlot||""))throw Object.assign(new TypeError("Insertion slot is invalid"),{code:"unknown_slot",sourcePath:`${t}/insertSlot`});return r}function Te(e,t,n){const o=[],i=null===e?"null":Array.isArray(e)?"array":Number.isInteger(e)?"integer":typeof e;if(t.type&&t.type!==i&&o.push(`expected ${t.type}`),void 0!==t.const&&s(t.const)!==s(e)&&o.push("const mismatch"),t.enum&&!t.enum.some(t=>s(t)===s(e))&&o.push("enum mismatch"),"string"==typeof e&&(void 0!==t.minLength&&e.length<t.minLength&&o.push("string too short"),void 0!==t.maxLength&&e.length>t.maxLength&&o.push("string too long")),"number"==typeof e&&(void 0!==t.minimum&&e<t.minimum&&o.push("number too small"),void 0!==t.maximum&&e>t.maximum&&o.push("number too large")),Array.isArray(e)&&(void 0!==t.minItems&&e.length<t.minItems&&o.push("array too short"),void 0!==t.maxItems&&e.length>t.maxItems&&o.push("array too long"),t.items&&e.forEach((e,o)=>Te(e,t.items,`${n}/${o}`))),he(e)){for(const n of t.required||[])Object.hasOwn(e,n)||o.push(`missing ${n}`);if(!1===t.additionalProperties)for(const n of Object.keys(e))Object.hasOwn(t.properties||{},n)||o.push(`unknown ${n}`);for(const[o,i]of Object.entries(t.properties||{}))Object.hasOwn(e,o)&&Te(e[o],i,`${n}/${o}`)}if(o.length)throw Object.assign(new TypeError(o[0]),{code:"invalid_value",sourcePath:n})}async function je(e,t={}){const o=[],i=[],r=[];try{const a=function(e={}){const t={};for(const[n,o]of Object.entries(ae)){const i=e[n]??o;if(!Number.isInteger(i)||i<=0)throw Object.assign(new RangeError(`Invalid limit ${n}`),{code:"invalid_value",sourcePath:`/limits/${n}`});if(i>o)throw Object.assign(new RangeError(`Limit ${n} exceeds the hard maximum`),{code:"limit_exceeded",sourcePath:`/limits/${n}`});t[n]=i}return t}(t.limits);if(xe(e),ye(e)>a.maxRecipeBytes)throw Object.assign(new RangeError("Recipe byte limit exceeded"),{code:"limit_exceeded",sourcePath:"$"});if(!he(e)||!(0,b.Wl)(e,"simai.composition.recipe",1))throw Object.assign(new TypeError("Unsupported recipe schema"),{code:"invalid_value",sourcePath:"/schema"});if($e(e,ue,""),!me.test(e.id||"")||!["ui-layout","structured-content"].includes(e.profile))throw Object.assign(new TypeError("Recipe identity or profile is invalid"),{code:"invalid_value",sourcePath:"/"});const l=new Set(t.supportedExtensions||[]);for(const[t,n]of Object.entries(e.inputs||{})){if($e(n,pe,`/inputs/${t}`),!["parameter","setting","content"].includes(n.kind)||!he(n.schema))throw Object.assign(new TypeError("Input declaration is invalid"),{code:"invalid_value",sourcePath:`/inputs/${t}`});if(n.default&&Se(n.default,`/inputs/${t}/default`),n.default&&!Object.hasOwn(n.default,"literal"))throw Object.assign(new TypeError("Input default must be literal"),{code:"invalid_value",sourcePath:`/inputs/${t}/default`});if(!("content"!==n.kind||n.expectedOrigin?.owner&&n.expectedOrigin?.ref))throw Object.assign(new TypeError("Content origin is required"),{code:"input_origin_mismatch",sourcePath:`/inputs/${t}/expectedOrigin`});ke(n.extensions,`/inputs/${t}/extensions`,l)}if(ke(e.extensions,"/extensions",l),Oe(e.root,"/root",{localIds:new Set,maxSelectCases:a.maxSelectCases,supportedExtensions:l}),Object.keys(e.inputs||{}).length>a.maxInputs)throw Object.assign(new RangeError("Input limit exceeded"),{code:"limit_exceeded",sourcePath:"/inputs"});const c=t.trustedContext?.scope;if("string"!=typeof c||!c)throw Object.assign(new TypeError("Trusted scope is required"),{code:"invalid_value",sourcePath:"/trustedContext/scope"});const u=t.inputs||{...(0,b.xZ)("simai.composition.inputs",1),scope:c,values:{}};if(xe(u,"/inputs"),$e(u,de,"/inputs"),!(0,b.Wl)(u,"simai.composition.inputs",1)||u.scope!==c)throw Object.assign(new TypeError("Input scope mismatch"),{code:"input_origin_mismatch",sourcePath:"/inputs"});const d=await ve(e),f={steps:0,sourceBytes:0,inputBytes:0,nodes:0,intermediateBytes:0},p=new Set,m=new Map,h=new Map,g=[],y=[],w=[],v=e=>{if(f.steps+=1,f.steps>a.maxExpansionSteps)throw Object.assign(new RangeError("Expansion step limit exceeded"),{code:"limit_exceeded",sourcePath:e})},_=async(n,i)=>{if(v(i),h.has(n))return h.get(n);const s=e.inputs?.[n];if(!s)throw Object.assign(new TypeError(`Unknown input ${n}`),{code:"missing_input",sourcePath:i});o.push({operation:"read-input",name:n,sourcePath:i});let r,l=u.values?.[n];if(void 0===l&&t.ports?.readInput&&(l=await t.ports.readInput(n,s,{scope:c})),"denied"===l?.status)throw Object.assign(new Error("Input access denied"),{code:"access_denied",sourcePath:i});if("error"===l?.status)throw Object.assign(new Error("Input source failed"),{code:"source_error",sourcePath:i});if(void 0===l||"missing"===l?.status){if(!s.default)throw Object.assign(new Error(`Input ${n} is missing`),{code:"missing_input",sourcePath:i});const e=ge(s.default.literal);Te(e,s.schema,i);const t=await ve(e),o=l?.missingSource||("parameter"===s.kind?void 0:{scope:c,owner:s.expectedOrigin?.owner,ref:s.expectedOrigin?.ref});if(!("parameter"===s.kind||o?.owner&&o?.ref))throw Object.assign(new Error("Missing source identity is required"),{code:"input_origin_mismatch",sourcePath:i});r={value:e,receipt:{name:n,kind:s.kind,valueDigest:t,...o?{missingSource:o}:{},resolution:"default"}}}else{if(f.inputBytes+=ye(l),ye(l)>a.maxInputBytes||f.inputBytes>a.maxTotalInputBytes)throw Object.assign(new RangeError("Input byte limit exceeded"),{code:"limit_exceeded",sourcePath:i});if(l.kind!==s.kind)throw Object.assign(new Error("Input kind mismatch"),{code:"input_origin_mismatch",sourcePath:i});Te(l.value,s.schema,i);const e=await ve(l.value);if(e!==l.valueDigest)throw Object.assign(new Error("Input digest mismatch"),{code:"input_digest_mismatch",sourcePath:i});const t=s.expectedOrigin;if("parameter"!==s.kind&&(!l.origin||l.origin.scope!==c||t?.owner!==l.origin.owner||t?.ref!==l.origin.ref||t?.revision&&t.revision!==l.origin.revision))throw Object.assign(new Error("Input origin mismatch"),{code:"input_origin_mismatch",sourcePath:i});r={value:ge(l.value),receipt:{name:n,kind:s.kind,valueDigest:e,...l.origin?{origin:ge(l.origin)}:{},resolution:"provided"}}}return h.set(n,r),y.push(r.receipt),r},x=async(e,t,n)=>{if(v(n),!he(e))throw Object.assign(new TypeError("Value wrapper is required"),{code:"invalid_value",sourcePath:n});if(Object.hasOwn(e,"literal"))return ge(e.literal);if(Object.hasOwn(e,"input"))return(await _(e.input,n)).value;if(Object.hasOwn(e,"parameter")){if(!t.has(e.parameter))throw Object.assign(new Error(`Parameter ${e.parameter} is missing`),{code:"unknown_parameter",sourcePath:n});return ge(t.get(e.parameter))}throw Object.assign(new TypeError("Unknown value wrapper"),{code:"invalid_value",sourcePath:n})},$=async(e,n)=>{v(n);const i="pinned"===e.policy?e.revision:`pointer:${e.pointer}`,r=s([c,e.kind,e.owner,e.ref,i]);if(m.has(r))return m.get(r);if(m.size>=a.maxUniqueReferences)throw Object.assign(new RangeError("Reference limit exceeded"),{code:"limit_exceeded",sourcePath:n});if(!t.ports?.readReference)throw Object.assign(new Error("Reference port is unavailable"),{code:"missing_reference",sourcePath:n});o.push({operation:"read-reference",kind:e.kind,owner:e.owner,ref:e.ref,revision:e.revision,pointer:e.pointer,sourcePath:n});const l=await t.ports.readReference(e,{scope:c,maxBytes:a.maxSourceBytes});if("denied"===l?.status)throw Object.assign(new Error("Reference access denied"),{code:"access_denied",sourcePath:n});if("error"===l?.status)throw Object.assign(new Error("Reference source failed"),{code:"source_error",sourcePath:n});if(!l?.source)throw Object.assign(new Error("Reference not found"),{code:"missing_reference",sourcePath:n});const u=l.revision;if("pinned"===e.policy&&u!==e.revision)throw Object.assign(new Error("Reference revision mismatch"),{code:"revision_mismatch",sourcePath:n});const d=ye(l.source);if(f.sourceBytes+=d,d>a.maxSourceBytes||f.sourceBytes>a.maxTotalSourceBytes)throw Object.assign(new RangeError("Source byte limit exceeded"),{code:"limit_exceeded",sourcePath:n});const p=await ve(l.source);if(l.digest&&l.digest!==p)throw Object.assign(new Error("Reference digest mismatch"),{code:"revision_mismatch",sourcePath:n});const h={source:ge(l.source),revision:u,digest:p};return m.set(r,h),g.push({kind:e.kind,owner:e.owner,ref:e.ref,revision:u,digest:p,scope:c}),"follow-published"===e.policy&&w.push({kind:e.kind,owner:e.owner,ref:e.ref,pointer:e.pointer,generation:l.generation,resolvedRevision:u,scope:c}),h},k=async(t,n,o)=>{v(o);const i=Ee(t);if("select"===i){const e=await x(t.select.value,n.parameters,`${o}/select/value`);if("string"!=typeof e)throw Object.assign(new Error("Select value must be a string"),{code:"invalid_value",sourcePath:`${o}/select/value`});let i=String(e);if(Object.hasOwn(t.select.cases,i)||(i=t.select.missingCase),!i||!Object.hasOwn(t.select.cases,i))throw Object.assign(new Error("Select value has no case"),{code:"invalid_value",sourcePath:o});return k(t.select.cases[i],{...n,segments:[...n.segments,["select",t.id],["case",i]]},`${o}/select/cases/${i}`)}if("insertSlot"===i){const e=n.callSlots?.[t.insertSlot]??n.slotDefaults?.[t.insertSlot]??[],i=[];for(let s=0;s<e.length;s+=1)i.push(await k(e[s],{...n,segments:[...n.segments,["insertion",t.id],["argument-slot",t.insertSlot]]},`${o}/inserted/${t.insertSlot}/${s}`));const s=i.flat(),r=n.slotSpecs?.[t.insertSlot];if(!r)throw Object.assign(new Error(`Unknown insertion slot ${t.insertSlot}`),{code:"unknown_slot",sourcePath:o});if(s.length<r.min||s.length>r.max)throw Object.assign(new Error(`Slot ${t.insertSlot} has invalid cardinality`),{code:"invalid_value",sourcePath:o});if(r.types?.length&&s.some(e=>!r.types.includes(e.type)))throw Object.assign(new Error(`Slot ${t.insertSlot} contains a forbidden type`),{code:"unknown_type",sourcePath:o});return n.usedCallSlots?.add(t.insertSlot),s}if("ref"===i){if(r.length>=a.maxReferenceDepth)throw Object.assign(new RangeError("Reference depth exceeded"),{code:"limit_exceeded",sourcePath:o});const e=s([c,t.ref.kind,t.ref.owner,t.ref.ref,t.ref.revision||t.ref.pointer]);if(r.includes(e))throw Object.assign(new Error("Reference cycle"),{code:"reference_cycle",sourcePath:o});const i=await $(t.ref,o);r.push(e);try{if("fragment"===t.ref.kind){if(t.params||t.slots)throw Object.assign(new Error("Fragment cannot receive parameters or slots"),{code:"invalid_value",sourcePath:o});return Oe(i.source,`${o}/source`,{localIds:new Set,maxSelectCases:a.maxSelectCases,supportedExtensions:l}),await k(i.source,{...n,segments:[...n.segments,["placement",t.id]]},`${o}/source`)}if(!(0,b.Wl)(i.source,"simai.composition.recipe-manifest",1))throw Object.assign(new Error("Template manifest is invalid"),{code:"invalid_value",sourcePath:o});$e(i.source,fe,`${o}/source`),ke(i.source.extensions,`${o}/source/extensions`,l),Oe(i.source.body,`${o}/source/body`,{localIds:new Set,maxSelectCases:a.maxSelectCases,supportedExtensions:l});const e=new Map;for(const[s,r]of Object.entries(i.source.parameters||{})){const i=t.params?.[s]??r.default;if(!i)throw Object.assign(new Error(`Parameter ${s} is missing`),{code:"unknown_parameter",sourcePath:o});const a=await x(i,n.parameters,`${o}/params/${s}`);Te(a,r,`${o}/params/${s}`),e.set(s,a)}for(const e of Object.keys(t.params||{}))if(!Object.hasOwn(i.source.parameters||{},e))throw Object.assign(new Error(`Unknown parameter ${e}`),{code:"unknown_parameter",sourcePath:`${o}/params/${e}`});for(const e of Object.keys(t.slots||{}))if(!Object.hasOwn(i.source.slots||{},e))throw Object.assign(new Error(`Unknown slot ${e}`),{code:"unknown_slot",sourcePath:`${o}/slots/${e}`});const s=Object.fromEntries(Object.entries(i.source.slots||{}).map(([e,t])=>[e,t.defaults||[]]));for(const[e,t]of Object.entries(i.source.slots||{}))if($e(t,new Set(["min","max","types","defaults"]),`${o}/source/slots/${e}`),!Number.isInteger(t.min)||!Number.isInteger(t.max)||t.min<0||t.max>a.maxChildrenPerSlot||t.min>t.max)throw Object.assign(new Error(`Slot ${e} has invalid limits`),{code:"invalid_value",sourcePath:o});const r=new Set,c=await k(i.source.body,{...n,parameters:e,callSlots:t.slots||{},slotDefaults:s,slotSpecs:i.source.slots||{},usedCallSlots:r,segments:[...n.segments,["placement",t.id]]},`${o}/source/body`);for(const e of Object.keys(t.slots||{}))if(!r.has(e))throw Object.assign(new Error(`Slot ${e} was not inserted`),{code:"unknown_slot",sourcePath:`${o}/slots/${e}`});return c}catch(e){throw e.referenceChain||(e.referenceChain=[...r]),e}finally{r.pop()}}const u=[...n.segments,["node",t.id]],d={id:await _e(e.id,u),type:t.node.type};if(p.has(d.id))throw Object.assign(new Error("Duplicate resolved identity"),{code:"duplicate_id",sourcePath:o});p.add(d.id);for(const e of["data","props"])if(t.node[e]){d[e]={};for(const[i,s]of Object.entries(t.node[e]))d[e][i]=await x(s,n.parameters,`${o}/node/${e}/${i}`)}if(t.node.presentation){d.presentation={};for(const[e,i]of Object.entries(t.node.presentation))d.presentation[e]=await x(i,n.parameters,`${o}/node/presentation/${e}`)}if(t.node.bindings){d.bindings=[];for(const n of t.node.bindings){const i=e.inputs?.[n.input];if("content"!==i?.kind||!t.node.data?.[n.target]||t.node.data[n.target].input!==n.input)throw Object.assign(new Error("Binding must match content data input"),{code:"invalid_value",sourcePath:o});const s=await _(n.input,`${o}/node/bindings/${n.target}`);d.bindings.push({owner:s.receipt.origin.owner,ref:s.receipt.origin.ref,target:n.target,revision:s.receipt.origin.revision})}}var m;if(t.node.extensions&&(d.extensions=void 0===(m=t.node.extensions)?void 0:ge(m)),t.node.slots){d.slots={};for(const[e,i]of Object.entries(t.node.slots)){const t=[];for(let s=0;s<i.length;s+=1)t.push(await k(i[s],{...n,segments:[...u,["slot",e]]},`${o}/node/slots/${e}/${s}`));if(d.slots[e]=t.flat(),d.slots[e].length>a.maxChildrenPerSlot)throw Object.assign(new RangeError("Slot child limit exceeded"),{code:"limit_exceeded",sourcePath:o})}}if(f.nodes+=1,f.nodes>a.maxOutputNodes)throw Object.assign(new RangeError("Output node limit exceeded"),{code:"limit_exceeded",sourcePath:o});if(f.intermediateBytes+=ye(d),f.intermediateBytes>a.maxIntermediateBytes)throw Object.assign(new RangeError("Intermediate byte limit exceeded"),{code:"limit_exceeded",sourcePath:o});return d},S=await k(e.root,{parameters:new Map,callSlots:{},slotDefaults:{},segments:[]},"/root");if(Array.isArray(S))throw Object.assign(new Error("Root must resolve to one node"),{code:"invalid_resolved_document",sourcePath:"/root"});const E={...se(e),id:e.id,profile:e.profile,...e.locale?{locale:e.locale}:{},root:S},O=e=>1+Math.max(0,...Object.values(e.slots||{}).flat().map(O));if(O(S)>a.maxOutputDepth)throw Object.assign(new RangeError("Output depth limit exceeded"),{code:"limit_exceeded",sourcePath:"/root"});if(ye(E)>a.maxOutputBytes)throw Object.assign(new RangeError("Output byte limit exceeded"),{code:"limit_exceeded",sourcePath:"/root"});const{normalize:T}=await Promise.resolve().then(n.bind(n,"3a00b12d226d")),j=await T(E,t.registry,{limits:{maxDocumentBytes:a.maxOutputBytes,maxDepth:a.maxOutputDepth,maxNodes:a.maxOutputNodes,maxChildrenPerSlot:a.maxChildrenPerSlot},supportedExtensions:t.supportedExtensions,ports:t.compositionPorts});if(!j.document)throw Object.assign(new Error("Resolved document is invalid"),{code:"invalid_resolved_document",sourcePath:"/root",details:j.diagnostics});const A=t.executionContract;if(!A?.contractDigest||!A?.registryDigest||!A?.rendererDigest)throw Object.assign(new Error("Execution contract is required"),{code:"invalid_value",sourcePath:"/executionContract"});const L=A.canonicalization??ne;if(!oe.has(L))throw Object.assign(new Error("Unsupported canonicalization profile"),{code:"incompatible_profile",sourcePath:"/executionContract/canonicalization"});const P={...ie(e,"simai.composition.dependencies"),scope:c,recipeDigest:d,documentDigest:`sha256:${j.digest}`,references:g,inputs:y,logicalPointers:w,executionContract:{...ge(A),canonicalization:L}};return{document:j.document,dependencyReceipt:P,trace:o,diagnostics:i}}catch(e){return i.push(function(e,t,n,o=[]){return{code:e,sourcePath:t,referenceChain:[...o],message:n}}(e.code||"source_error",e.sourcePath||"$",e.message||"Recipe resolution failed",e.referenceChain||r)),e.details&&i.push(...e.details.map(t=>({...t,sourcePath:t.path||e.sourcePath||"$"}))),{document:null,dependencyReceipt:null,trace:o,diagnostics:i}}}const Ae=Object.freeze({defaultLimits:re,digest:ve,nodeId:_e,parseJson:be,resolve:je}),Le=Object.freeze(["strong","em","code"]),Pe=new Map(Le.map((e,t)=>[e,t])),ze=new Set(["http:","https:","mailto:","tel:"]),Re=Object.freeze({maxTextLength:1e5,maxHrefLength:2048});function Ce(e){if("string"!=typeof e||e.length<1||e.length>Re.maxHrefLength)return!1;if(/^(?:\/|\.?\.\/|#)/u.test(e))return!e.startsWith("//")&&!e.includes("\\");try{return ze.has(new globalThis.URL(e).protocol)}catch{return!1}}function Fe(e){return[...new Set(e)].filter(e=>Pe.has(e)).sort((e,t)=>Pe.get(e)-Pe.get(t))}function Ne(e){const t=[],n=(e,n)=>{"text"===e?.type&&"string"==typeof e.value&&e.value&&t.push({text:e.value,marks:Fe(Array.isArray(e.marks)?e.marks:[]),href:n})};for(const t of Array.isArray(e)?e:[])if("link"===t?.type){const e=Ce(t.href)?t.href:null;for(const o of Array.isArray(t.children)?t.children:[])n(o,e)}else n(t,null);return t}const Ie=(e,t)=>e.href===t.href&&e.marks.join()===t.marks.join();function Me(e){const t=[];for(const n of e){if(!n.text)continue;const e={text:n.text,marks:Fe(n.marks||[]),href:n.href&&Ce(n.href)?n.href:null},o=t.at(-1);o&&Ie(o,e)?o.text+=e.text:t.push(e)}const n=[];for(const e of t){const t={type:"text",value:e.text,...e.marks.length?{marks:e.marks}:{}},o=n.at(-1);e.href?"link"===o?.type&&o.href===e.href?o.children.push(t):n.push({type:"link",href:e.href,children:[t]}):n.push(t)}return n}function qe(e){return Me(Ne(e))}function De(e){return Ne(e).map(({text:e})=>e).join("")}const Be="simai.composition:endpoint",Ue=Object.freeze({maxRoutesPerScope:32,maxEndpointsPerScope:64,maxFanOut:8,maxScopeNesting:4,maxReentrancy:8,maxValueBytes:65536}),We=/^[a-z][a-z0-9-]{0,31}$/u,He=/^[a-z][a-z0-9-]{0,63}$/u,Ve=/[\u0000-\u001f\u007f]/u,Ze=(e,t,n)=>({code:e,path:t,message:n});function Je(e){return"string"==typeof e?e.length>0&&e.length<=256&&!Ve.test(e):Number.isSafeInteger(e)}function Ge(e){return Object.freeze([...e])}function Xe(e,t,n,i){if(!o(e))throw new TypeError(`${i} value is not an object`);const s=Object.keys(e);if(!t.every(e=>s.includes(e)))throw new TypeError(`${i} value misses a required key`);if(!s.every(e=>t.includes(e)||n.includes(e)))throw new TypeError(`${i} value has an undeclared key`)}const Ye=/^[a-z][a-z0-9._:-]{0,127}$/u,Ke=e=>"string"==typeof e&&Ye.test(e),Qe=e=>"string"==typeof e&&e.length>0&&e.length<=128&&!Ve.test(e),et=/^[\w.*:-]+(?:\/[\w.*:/-]+)?$/u,tt={type:"string",minLength:1,maxLength:128},nt={oneOf:[{type:"string",minLength:1,maxLength:256},{type:"integer",minimum:-9007199254740991,maximum:9007199254740991}]},ot={type:"string",pattern:"^[a-z][a-z0-9._:-]{0,127}$"},it=Object.freeze({"record-ids.v1":Object.freeze({summary:"Ordered unique opaque record identities: nonempty strings up to 256 code units without control characters, or safe integers. Up to 1000 items; empty means no selection.",schema:{type:"array",maxItems:1e3,uniqueItems:!0,items:{oneOf:[{type:"string",minLength:1,maxLength:256},{type:"integer",minimum:-9007199254740991,maximum:9007199254740991}]}},check(e){if(!Array.isArray(e)||e.length>1e3||!e.every(Je))throw new TypeError("record-ids.v1 value is invalid");if(new Set(e.map(e=>`${typeof e}:${e}`)).size!==e.length)throw new TypeError("record-ids.v1 value has duplicates");return Ge(e)}}),"record-id.v1":Object.freeze({summary:"One opaque record identity or null for none.",schema:{oneOf:[{type:"null"},{type:"string",minLength:1,maxLength:256},{type:"integer",minimum:-9007199254740991,maximum:9007199254740991}]},check(e){if(null!==e&&!Je(e))throw new TypeError("record-id.v1 value is invalid");return e}}),"text.v1":Object.freeze({summary:"Plain text up to 2000 code units; never interpreted as markup or a query language.",schema:{type:"string",maxLength:2e3},check(e){if("string"!=typeof e||e.length>2e3)throw new TypeError("text.v1 value is invalid");return e}}),"boolean.v1":Object.freeze({summary:"A strict boolean.",schema:{type:"boolean"},check(e){if("boolean"!=typeof e)throw new TypeError("boolean.v1 value is invalid");return e}}),"record-changed.v1":Object.freeze({summary:"A record changed: its collection, identity and new revision, and optionally the keys of the fields that changed (up to 256). Says what changed, never the values.",schema:{type:"object",additionalProperties:!1,required:["collection","id","revision"],properties:{collection:tt,id:nt,revision:{oneOf:[{type:"string",minLength:1,maxLength:128},{type:"integer",minimum:-9007199254740991,maximum:9007199254740991}]},fields:{type:"array",maxItems:256,uniqueItems:!0,items:{type:"string",minLength:1,maxLength:128}}}},check(e){if(Xe(e,["collection","id","revision"],["fields"],"record-changed.v1"),!Qe(e.collection)||!Je(e.id)||!(e=>"string"==typeof e&&e.length>0&&e.length<=128&&!Ve.test(e)||Number.isSafeInteger(e))(e.revision))throw new TypeError("record-changed.v1 value is invalid");const t={collection:e.collection,id:e.id,revision:e.revision};if(void 0!==e.fields){const n=e.fields;if(!Array.isArray(n)||n.length>256||!n.every(Qe)||new Set(n).size!==n.length)throw new TypeError("record-changed.v1 fields are invalid");t.fields=Ge(n)}return Object.freeze(t)}}),"record-removed.v1":Object.freeze({summary:"A record was removed from its collection.",schema:{type:"object",additionalProperties:!1,required:["collection","id"],properties:{collection:tt,id:nt}},check(e){if(Xe(e,["collection","id"],[],"record-removed.v1"),!Qe(e.collection)||!Je(e.id))throw new TypeError("record-removed.v1 value is invalid");return Object.freeze({collection:e.collection,id:e.id})}}),"collection-changed.v1":Object.freeze({summary:"Something in a collection changed that a list should read again; reason is a short token (created, imported, reordered, settings ...).",schema:{type:"object",additionalProperties:!1,required:["collection","reason"],properties:{collection:tt,reason:ot}},check(e){if(Xe(e,["collection","reason"],[],"collection-changed.v1"),!Qe(e.collection)||!Ke(e.reason))throw new TypeError("collection-changed.v1 value is invalid");return Object.freeze({collection:e.collection,reason:e.reason})}}),"files-moved.v1":Object.freeze({summary:"Files moved between folders: their identities (1 to 1000, unique), the folder they left and the one they went to; null is the root.",schema:{type:"object",additionalProperties:!1,required:["ids","from","to"],properties:{ids:{type:"array",minItems:1,maxItems:1e3,uniqueItems:!0,items:nt},from:{oneOf:[{type:"null"},...nt.oneOf]},to:{oneOf:[{type:"null"},...nt.oneOf]}}},check(e){Xe(e,["ids","from","to"],[],"files-moved.v1");const t=e.ids;if(!Array.isArray(t)||0===t.length||t.length>1e3||!t.every(Je))throw new TypeError("files-moved.v1 ids are invalid");if(new Set(t.map(e=>`${typeof e}:${e}`)).size!==t.length)throw new TypeError("files-moved.v1 ids have duplicates");const n=e=>null===e||Je(e);if(!n(e.from)||!n(e.to))throw new TypeError("files-moved.v1 folder is invalid");return Object.freeze({ids:Ge(t),from:e.from,to:e.to})}}),"counter.v1":Object.freeze({summary:"A named count changed: key is a token (notifications, requests.new ...), value a non-negative safe integer.",schema:{type:"object",additionalProperties:!1,required:["key","value"],properties:{key:ot,value:{type:"integer",minimum:0,maximum:9007199254740991}}},check(e){if(Xe(e,["key","value"],[],"counter.v1"),!Ke(e.key)||!Number.isSafeInteger(e.value)||e.value<0)throw new TypeError("counter.v1 value is invalid");return Object.freeze({key:e.key,value:e.value})}}),"navigation.v1":Object.freeze({summary:"Go to an address of the same site, in a named region: url is a path (starting with one slash, up to 2048 code units), region a region name.",schema:{type:"object",additionalProperties:!1,required:["url","region"],properties:{url:{type:"string",minLength:1,maxLength:2048,pattern:"^/(?!/)"},region:{type:"string",pattern:"^[a-z][a-z0-9-]{0,31}$"}}},check(e){if(Xe(e,["url","region"],[],"navigation.v1"),!(e=>"string"==typeof e&&e.length>0&&e.length<=2048&&!Ve.test(e)&&e.startsWith("/")&&!e.startsWith("//"))(e.url)||"string"!=typeof e.region||!We.test(e.region))throw new TypeError("navigation.v1 value is invalid");return Object.freeze({url:e.url,region:e.region})}}),"preference-changed.v1":Object.freeze({summary:"A person changed a view preference: the SF.Preferences key (sf-table/<key>, sf-table/*, sf-admin-menu/main ...). Says which, never the value.",schema:{type:"object",additionalProperties:!1,required:["key"],properties:{key:{type:"string",minLength:1,maxLength:256,pattern:"^[\\w.*:-]+(?:/[\\w.*:/-]+)?$"}}},check(e){if(Xe(e,["key"],[],"preference-changed.v1"),"string"!=typeof e.key||e.key.length>256||!et.test(e.key))throw new TypeError("preference-changed.v1 value is invalid");return Object.freeze({key:e.key})}})}),st=(e,t)=>o(e)&&"string"==typeof t&&Object.hasOwn(e,t),rt=Object.freeze(Object.assign(Object.create(null),Object.fromEntries(Object.keys(it).map(e=>[e.replace(/\.v1$/u,""),e]))));function at(e){return"string"!=typeof e?null:Object.hasOwn(rt,e)?e:Object.hasOwn(it,e)?e.replace(/\.v1$/u,""):null}function lt(e,t){const n=at(e);return null!==n&&n===at(t)}function ct(e){const t=at(e);return null===t?null:it[rt[t]]}const ut=e=>null!==at(e);function dt(e,t){if(!ut(e))throw new TypeError(`Unknown value type ${e}`);const n=ct(e).check(t);if((new globalThis.TextEncoder).encode(JSON.stringify(n)).byteLength>Ue.maxValueBytes)throw new TypeError("Port value is too large");return n}function ft(e=[],t={}){const n=new Map;for(const t of e){if(!o(t)||!(0,b.Wl)(t,"simai.composition.port-manifest",1))throw new TypeError("composition_port_manifest_invalid");if(n.has(t.element))throw new TypeError(`composition_port_manifest_duplicate:${t.element}`);for(const e of[...Object.values(t.outputs||{}),...Object.values(t.inputs||{})])if(!ut(e.value))throw new TypeError(`composition_port_value_type_unknown:${e.value}`);n.set(t.element,i(t))}const s=new Map(Object.entries(t.bindings||{}));for(const[e,t]of s)if(!n.has(t))throw new TypeError(`composition_port_binding_unknown:${e}`);return{elements:n,bindings:s}}function pt(e,t){if(!e||!t)return null;const n=t.bindings.get(e.type);return n?t.elements.get(n)||null:"custom-element"===e.renderer?.kind&&t.elements.get(e.renderer.name)||null}function mt(e){return o(e)&&1===Object.keys(e).length&&"string"==typeof e.name&&We.test(e.name)}function ht(e){const t=st(e?.extensions,Be)?e.extensions[Be]:void 0;return mt(t)?t.name:void 0}function gt(e,t,n,i=[]){const s=new Map,r=(e,a,l)=>{if(!o(e))return;st(e.extensions,Be)&&!mt(e.extensions[Be])&&i.push(Ze("route_endpoint_invalid",`${a}.extensions.${Be}`,"Endpoint extension must contain only a valid name"));let c=l;if("layout.scope"===e.type){c+=1,c>Ue.maxScopeNesting&&i.push(Ze("scope_nesting_limit",a,"Routing scopes are nested too deeply"));const r=Array.isArray(e.props?.routes)?e.props.routes:[],{endpoints:l,problems:u}=function(e,t){const n=new Map,i=[],s=(t,r,a)=>{if(o(t)){if(t!==e){const e=st(t.extensions,Be)?t.extensions[Be]:void 0;mt(e)&&!a&&(n.has(e.name)?i.push(Ze("route_endpoint_duplicate",`${r}.extensions.${Be}`,`Endpoint ${e.name} is declared twice in one scope`)):n.set(e.name,{node:t,path:r})),"layout.scope"===t.type&&(a=!0)}for(const[e,n]of Object.entries(o(t.slots)?t.slots:{}))Array.isArray(n)&&n.forEach((t,n)=>s(t,`${r}.slots.${e}[${n}]`,a))}};return s(e,t,!1),{endpoints:n,problems:i}}(e,a);i.push(...u),l.size>Ue.maxEndpointsPerScope&&i.push(Ze("route_limit",a,"Scope declares too many endpoints"));const d=new Set,f=new Set,p=new Map,m=[],h=[];r.forEach((e,s)=>{const r=`${a}.props.routes[${s}]`;if(!o(e)||!o(e.from)||!o(e.to))return;d.has(e.id)&&i.push(Ze("route_id_duplicate",`${r}.id`,`Route ${e.id} is declared twice`)),d.add(e.id);const c={};for(const o of["from","to"]){const s="string"==typeof e[o].endpoint?l.get(e[o].endpoint):void 0;if(!s){i.push(Ze("route_endpoint_unknown",`${r}.${o}.endpoint`,`Endpoint ${e[o].endpoint} is not declared in this scope`));continue}const a=pt(t.types.get(s.node.type),n),u="from"===o?"outputs":"inputs",d="from"===o?"inputs":"outputs",f=st(a?.[u],e[o].port)?a[u][e[o].port]:void 0;if(!f){const t=st(a?.[d],e[o].port);i.push(t?Ze("route_port_direction",`${r}.${o}.port`,`${e[o].port} is not ${"from"===o?"an output":"an input"}`):Ze("route_port_unknown",`${r}.${o}.port`,`${s.node.type} publishes no ${"from"===o?"output":"input"} ${e[o].port}`));continue}c[o]={endpoint:e[o].endpoint,port:e[o].port,value:f.value,element:a.element}}e.from.endpoint===e.to.endpoint&&i.push(Ze("route_self",r,"A route cannot connect an endpoint to itself"));const u=`${e.to.endpoint}.${e.to.port}`;f.has(u)&&i.push(Ze("route_input_conflict",`${r}.to`,`Input ${u} already has a route`)),f.add(u);const g=`${e.from.endpoint}.${e.from.port}`;p.set(g,(p.get(g)||0)+1),p.get(g)>Ue.maxFanOut&&i.push(Ze("route_fanout_limit",`${r}.from`,`Output ${g} feeds too many routes`)),m.push([e.from.endpoint,e.to.endpoint]),c.from&&c.to&&(lt(c.from.value,c.to.value)?h.push({id:e.id,from:c.from,to:c.to}):i.push(Ze("route_type_mismatch",r,`${c.from.value} cannot feed ${c.to.value}`)))}),function(e){const t=new Map;for(const[n,o]of e)t.has(n)||t.set(n,new Set),t.get(n).add(o);const n=new Map,o=e=>{n.set(e,"active");for(const i of t.get(e)||[]){if("active"===n.get(i))return!0;if(!n.has(i)&&o(i))return!0}return n.set(e,"done"),!1};return[...t.keys()].some(e=>!n.has(e)&&o(e))}(m.filter(([e,t])=>e!==t))&&i.push(Ze("route_cycle",`${a}.props.routes`,"Routes form a cycle between endpoints")),s.set(e.id,h)}for(const[t,n]of Object.entries(o(e.slots)?e.slots:{}))Array.isArray(n)&&n.forEach((e,n)=>r(e,`${a}.slots.${t}[${n}]`,c))};return r(e,"$.root",0),s}class yt{constructor(e,t,n={}){this.host=e,this.routes=Object.freeze(t.map(e=>Object.freeze({...e,from:Object.freeze({...e.from}),to:Object.freeze({...e.to})}))),this.options=n,this.sequence=0,this.depth=0,this.states=new Map,this.pending=new Map,this.counters={outputs:0,deliveries:0,settled:0,stale:0,rejected:0},this.connection=null,this.onOutput=this.onOutput.bind(this)}get connected(){return null!==this.connection}connect(){if(this.connection)return!1;this.connection=new AbortController,this.host.addEventListener("sf-port-output",this.onOutput,{signal:this.connection.signal});for(const e of this.routes)this.setState(e.id,{status:"idle",sequence:0});return!0}disconnect(){if(!this.connection)return!1;this.connection.abort(),this.connection=null;for(const e of this.pending.values())e.abort();this.pending.clear();for(const e of this.routes)this.setState(e.id,{status:"disposed",sequence:this.states.get(e.id)?.sequence||0});return!0}getState(e){const t=this.states.get(e);return t?{...t}:null}setState(e,t){const n=Object.freeze({route:e,...t});this.states.set(e,n),this.options.onState?.(n)}onOutput(e){const t=this.options.sourceEndpoint?.(e);if(!t)return;const n=e.detail;if(o(n)&&"string"==typeof n.port){this.counters.outputs+=1;for(const e of this.routes){if(e.from.endpoint!==t||e.from.port!==n.port)continue;let o;try{o=dt(e.from.value,n.value)}catch{this.counters.rejected+=1,this.pending.get(e.id)?.abort(),this.pending.delete(e.id),this.setState(e.id,{status:"error",error:"value_invalid",sequence:++this.sequence});continue}this.deliver(e,o)}}}deliver(e,t){if(!this.connection)return;const n=++this.sequence;this.pending.get(e.id)?.abort();const o=new AbortController;this.pending.set(e.id,o),this.setState(e.id,{status:"pending",sequence:n});const i=()=>null!==this.connection&&!o.signal.aborted&&this.states.get(e.id)?.sequence===n,s=Object.freeze({route:e.id,sequence:n,signal:o.signal,isLatest:i}),r=()=>{if(!i())return;const o=this.options.targetEndpoint?.(e.to.endpoint);if(!o)return void this.setState(e.id,{status:"error",error:"endpoint_unresolved",sequence:n});if("function"!=typeof o.sfPortInput){const t=this.options.whenReady?.(o);return void(t?(this.setState(e.id,{status:"waiting",sequence:n}),t.then(r,()=>this.setState(e.id,{status:"error",error:"endpoint_unavailable",sequence:n}))):this.setState(e.id,{status:"error",error:"port_unsupported",sequence:n}))}const a=o.constructor?.sfPorts?.inputs?.[e.to.port];if(!lt(a,e.to.value))return this.counters.rejected+=1,void this.setState(e.id,{status:"error",error:"port_mismatch",sequence:n});if(this.depth>=Ue.maxReentrancy)return this.counters.rejected+=1,void this.setState(e.id,{status:"error",error:"reentrancy_limit",sequence:n});let l;this.depth+=1;try{this.counters.deliveries+=1,l=o.sfPortInput(e.to.port,t,s)}catch{return this.depth-=1,this.counters.rejected+=1,void this.setState(e.id,{status:"error",error:"port_rejected",sequence:n})}this.depth-=1,l&&"function"==typeof l.then?(this.setState(e.id,{status:"pending",sequence:n}),l.then(()=>{i()?(this.counters.settled+=1,this.pending.delete(e.id),this.setState(e.id,{status:"settled",sequence:n})):this.counters.stale+=1},()=>{i()?this.setState(e.id,{status:"error",error:"port_rejected",sequence:n}):this.counters.stale+=1})):(this.counters.settled+=1,this.pending.delete(e.id),this.setState(e.id,{status:"settled",sequence:n}))};r()}}function bt(e){return e?.parentElement?.closest?.("sf-composition-scope")||null}const wt=e=>"string"==typeof e?.localName&&e.localName.includes("-"),vt=e=>wt(e)&&!globalThis.customElements?.get(e.localName);function _t(e,t){if("function"==typeof e.sfPortInput||vt(e))return e;const n=[...e.querySelectorAll("*")].filter(e=>wt(e)&&"sf-composition-scope"!==e.localName&&bt(e)===t),o=n.filter(e=>"function"==typeof e.sfPortInput);if(1===o.length)return o[0];const i=n.filter(vt);return 0===o.length&&1===i.length?i[0]:null}function xt(e=globalThis.customElements){if(!e||"function"!=typeof globalThis.HTMLElement)return null;const t=e.get("sf-composition-scope");if(t)return t;class n extends globalThis.HTMLElement{constructor(){super(),this.routeController=null,this.routeDiagnostics=[]}connectedCallback(){if(!this.routeController){const e=function(e){let t;try{t=JSON.parse(e||"[]")}catch{return null}if(!Array.isArray(t)||t.length>Ue.maxRoutesPerScope)return null;const n=new Set;for(const e of t){if(!o(e)||"string"!=typeof e.id||!He.test(e.id))return null;for(const t of["from","to"]){const n=e[t];if(!(o(n)&&"string"==typeof n.endpoint&&"string"==typeof n.port&&We.test(n.endpoint)&&We.test(n.port)&&ut(n.value)))return null}if(!lt(e.from.value,e.to.value)||n.has(e.id))return null;n.add(e.id)}return t}(this.getAttribute("data-sf-routes"));if(!e)return this.routeDiagnostics=[{code:"routes_invalid",path:"data-sf-routes",message:"Rendered routes are invalid"}],void this.setAttribute("data-sf-routing","error");this.routeController=new yt(this,e,{sourceEndpoint:e=>{const t=e.target?.closest?.("[data-sf-endpoint]");return t&&bt(t)===this&&_t(t,this)===e.target?t.getAttribute("data-sf-endpoint"):null},targetEndpoint:e=>{const t=[...this.querySelectorAll("[data-sf-endpoint]")].filter(t=>t.getAttribute("data-sf-endpoint")===e&&bt(t)===this);return 1===t.length?_t(t[0],this):null},whenReady:e=>e.localName?.includes("-")&&globalThis.customElements?globalThis.customElements.whenDefined(e.localName):null,onState:e=>this.dispatchEvent(new globalThis.CustomEvent("sf-composition-route-state",{detail:e}))})}this.routeController.connect(),this.setAttribute("data-sf-routing","connected")}disconnectedCallback(){this.routeController?.disconnect(),this.routeController&&this.setAttribute("data-sf-routing","disposed")}getRouteState(e){return this.routeController?.getState(e)||null}getRoutingCounters(){return this.routeController?{...this.routeController.counters}:null}}return e.define("sf-composition-scope",n),n}const $t=["schema","id","element","regions","port","outputs","inputs","operation","url_state","budget"],kt=/^[a-z][a-z0-9-]*(?:\.[a-z][a-z0-9-]*)+$/u,St=/^[a-z][a-z0-9]*-[a-z0-9-]+$/u,Et=/^[a-z][a-z0-9-]{0,31}$/u,Ot=/^[a-z][a-z0-9.-]*$/u,Tt=/^[0-9]+\.[0-9]+\.[0-9]+$/u,jt=/^[a-z][a-z0-9._:-]{0,127}$/u,At=/^[a-z][a-z0-9_-]{0,63}$/u,Lt=(e,t)=>o(e)&&Object.keys(e).every(e=>t.includes(e)),Pt=(e,t,n)=>Array.isArray(e)&&e.length<=t&&new Set(e).size===e.length&&e.every(n);function zt(e,t){if(!o(e))return[`${t}: not an object`];const n=Object.keys(e),i=n.length>16?[`${t}: more than 16 ports`]:[];for(const o of n){const n=e[o];Et.test(o)||i.push(`${t}.${o}: name`),Lt(n,["value","summary"])?(null===at(n.value)&&i.push(`${t}.${o}: unknown value type ${n.value}`),("string"!=typeof n.summary||!n.summary.trim()||n.summary.length>1e3)&&i.push(`${t}.${o}: summary`)):i.push(`${t}.${o}: undeclared keys`)}return i}const Rt=["record-changed.v1","record-removed.v1","collection-changed.v1","files-moved.v1","counter.v1","navigation.v1","preference-changed.v1"],Ct=e=>at(e),Ft=Rt.map(Ct);const Nt={ru:{heading:"Не удалось показать этот блок"},en:{heading:"This block could not be shown"}};const It=new Set(["ui-layout","structured-content"]),Mt=new Set(["schema","schema_version","id","profile","locale","root","extensions"]),qt=new Set(["id","type","data","props","slots","presentation","bindings","extensions"]),Dt=new Set(["view","preset","modifiers"]),Bt=new Set(["owner","ref","target","revision"]),Ut=new Set(["html","innerhtml","script","javascript","php","eval","function","expression","query","sql","graphql","class","classname","rootclass","cssclass","secret","password","token","cookie","authorization","request"]),Wt=new Set(["http:","https:","mailto:","tel:"]),Ht=Object.freeze({maxDocumentBytes:1048576,maxDepth:32,maxNodes:2e3,maxChildrenPerSlot:500});function Vt(e,t,n,o={}){return{code:e,path:t,message:n,...o}}async function Zt(e){if(!globalThis.crypto?.subtle)throw new Error("composition_crypto_unavailable");const t=(new globalThis.TextEncoder).encode(e),n=await globalThis.crypto.subtle.digest("SHA-256",t);return[...new Uint8Array(n)].map(e=>e.toString(16).padStart(2,"0")).join("")}function Jt(e,t,n,i){if(o(e))for(const o of Object.keys(e))t.has(o)||i.push(Vt("unknown_field",`${n}.${o}`,`Unknown field ${o}`))}function Gt(e,t,n){if(Array.isArray(e))e.forEach((e,o)=>Gt(e,`${t}[${o}]`,n));else if(o(e))for(const[o,i]of Object.entries(e)){const e=o.toLowerCase().replaceAll("-","");Ut.has(e)&&n.push(Vt("executable_or_secret_field_forbidden",`${t}.${o}`,`Field ${o} is not portable composition data`)),Gt(i,`${t}.${o}`,n)}}function Xt(e,t,n,i=new Set){if(o(e))for(const s of Object.keys(e))/^[a-z][a-z0-9.-]*:[a-z][a-z0-9._-]*$/u.test(s)||n.push(Vt("extension_name_invalid",`${t}.${s}`,"Extension keys must be namespaced")),o(e[s])&&!0===e[s].required&&!i.has(s)&&n.push(Vt("extension_required_unknown",`${t}.${s}`,`Required extension ${s} is not supported`));else n.push(Vt("extensions_invalid",t,"Extensions must be an object"))}function Yt(e,t,n,i){if(!t)return;if(t.oneOf){return void(1!==t.oneOf.filter(t=>{const o=[];return Yt(e,t,n,o),0===o.length}).length&&i.push(Vt("schema_one_of",n,"Value must match exactly one allowed shape")))}if(void 0!==t.const&&e!==t.const)return void i.push(Vt("schema_const",n,`Value must equal ${t.const}`));if(t.enum&&!t.enum.includes(e))return void i.push(Vt("schema_enum",n,"Value is not in the allowed list"));const r=Array.isArray(t.type)?t.type:[t.type];if(t.type){const t=null===e?"null":Array.isArray(e)?"array":Number.isInteger(e)?"integer":"number"==typeof e?"number":typeof e;if(!r.includes(t)&&("integer"!==t||!r.includes("number"))&&("object"!==t||o(e)))return void i.push(Vt("schema_type",n,`Expected ${r.join(" or ")}`))}if("string"==typeof e&&(void 0!==t.minLength&&e.length<t.minLength&&i.push(Vt("schema_min_length",n,"String is too short")),void 0!==t.maxLength&&e.length>t.maxLength&&i.push(Vt("schema_max_length",n,"String is too long")),t.pattern&&!new RegExp(t.pattern,"u").test(e)&&i.push(Vt("schema_pattern",n,"String has an invalid format"))),"number"==typeof e&&(void 0!==t.minimum&&e<t.minimum&&i.push(Vt("schema_minimum",n,"Number is too small")),void 0!==t.maximum&&e>t.maximum&&i.push(Vt("schema_maximum",n,"Number is too large"))),Array.isArray(e)&&(void 0!==t.minItems&&e.length<t.minItems&&i.push(Vt("schema_min_items",n,"Array has too few items")),void 0!==t.maxItems&&e.length>t.maxItems&&i.push(Vt("schema_max_items",n,"Array has too many items")),t.uniqueItems&&new Set(e.map(s)).size!==e.length&&i.push(Vt("schema_unique_items",n,"Array items must be unique")),t.items&&e.forEach((e,o)=>Yt(e,t.items,`${n}[${o}]`,i))),o(e)){for(const o of t.required||[])o in e||i.push(Vt("schema_required",`${n}.${o}`,`Required field ${o} is missing`));if(!1===t.additionalProperties){const o=t.properties||{};for(const t of Object.keys(e))t in o||i.push(Vt("schema_additional_property",`${n}.${t}`,`Field ${t} is not allowed`))}for(const[o,s]of Object.entries(t.properties||{}))o in e&&Yt(e[o],s,`${n}.${o}`,i)}}function Kt(e){if(/^(?:\/|\.?\.\/|#)/u.test(e))return!e.startsWith("//")&&!e.includes("\\");try{return Wt.has(new globalThis.URL(e).protocol)}catch{return!1}}let Qt=null;function en(e){return e?.elements instanceof Map?e:Array.isArray(e)?ft(e):e&&Array.isArray(e.manifests)?ft(e.manifests,{bindings:e.bindings}):(Qt=Qt||ft($),Qt)}function tn(e){return e?.types instanceof Map?e:nn(Array.isArray(e)?e:x)}function nn(e=x,t={}){const n=new Map;for(const t of e){if(!o(t)||!(0,b.Wl)(t,"simai.composition.type-manifest",1))throw new TypeError("composition_manifest_invalid");if(n.has(t.type))throw new TypeError(`composition_manifest_duplicate:${t.type}`);n.set(t.type,i(t))}return{types:n,renderers:new Map(Object.entries(t))}}function on(e,t=void 0,n={}){const i=[],s=tn(t),r={...Ht,...n.limits||{}},a=new Set([Be,...n.supportedExtensions||[]]);let l;try{l=JSON.stringify(e)}catch{return{valid:!1,diagnostics:[Vt("document_not_json","$","Document must be JSON serializable")]}}if((new globalThis.TextEncoder).encode(l).byteLength>r.maxDocumentBytes&&i.push(Vt("document_too_large","$","Document exceeds the byte limit")),!o(e))return{valid:!1,diagnostics:[Vt("document_invalid","$","Document must be an object")]};Jt(e,Mt,"$",i),(0,b.Wl)(e,"simai.composition.document",1)||i.push(Vt("schema_unknown","$.schema","Expected simai.composition.document.v1, or simai.composition.document with schema_version 1")),"string"==typeof e.id&&/^[a-zA-Z0-9][a-zA-Z0-9._:-]{0,119}$/u.test(e.id)||i.push(Vt("document_id_invalid","$.id","Document id is invalid")),It.has(e.profile)||i.push(Vt("profile_unknown","$.profile","Profile is not supported")),void 0===e.locale||"string"==typeof e.locale&&/^[a-zA-Z]{2,8}(?:-[a-zA-Z0-9]{1,8})*$/u.test(e.locale)||i.push(Vt("locale_invalid","$.locale","Locale is invalid")),void 0!==e.extensions&&Xt(e.extensions,"$.extensions",i,a),Gt(e,"$",i);const c=new Set;let u=0;const d=(t,n,l)=>{if(u+=1,u>r.maxNodes)return;if(l>r.maxDepth&&i.push(Vt("depth_limit",n,"Composition is too deeply nested")),!o(t))return void i.push(Vt("node_invalid",n,"Node must be an object"));Jt(t,qt,n,i),"string"==typeof t.id&&/^[a-zA-Z0-9][a-zA-Z0-9._:-]{0,119}$/u.test(t.id)?c.has(t.id)?i.push(Vt("node_id_duplicate",`${n}.id`,`Duplicate node id ${t.id}`)):c.add(t.id):i.push(Vt("node_id_invalid",`${n}.id`,"Node id is invalid"));const f=s.types.get(t.type);if(!f)return void i.push(Vt("type_unknown",`${n}.type`,`Unknown type ${t.type||""}`));if(f.profiles.includes(e.profile)||i.push(Vt("type_profile_unsupported",`${n}.type`,`${t.type} does not support ${e.profile}`)),Yt(t.data||{},f.data_schema,`${n}.data`,i),Yt(t.props||{},f.props_schema,`${n}.props`,i),"content.heading"!==t.type&&"content.paragraph"!==t.type||function(e,t,n){if(Array.isArray(e))for(let o=0;o<e.length;o+=1){const i=e[o];"link"!==i?.type||Kt(i.href)||n.push(Vt("unsafe_url",`${t}[${o}].href`,"Link protocol is not allowed"))}}(t.data?.content,`${n}.data.content`,i),void 0!==t.presentation)if(o(t.presentation)){Jt(t.presentation,Dt,`${n}.presentation`,i);const e=f.presentation||{};if(t.presentation.view&&!(e.views||[]).includes(t.presentation.view)&&i.push(Vt("view_unknown",`${n}.presentation.view`,"View is not registered")),t.presentation.preset&&!(e.presets||[]).includes(t.presentation.preset)&&i.push(Vt("preset_unknown",`${n}.presentation.preset`,"Preset is not registered")),void 0!==t.presentation.modifiers)if(Array.isArray(t.presentation.modifiers))for(const o of t.presentation.modifiers)(e.modifiers||[]).includes(o)||i.push(Vt("modifier_unknown",`${n}.presentation.modifiers`,`Modifier ${o} is not registered`));else i.push(Vt("modifiers_invalid",`${n}.presentation.modifiers`,"Modifiers must be an array"))}else i.push(Vt("presentation_invalid",`${n}.presentation`,"Presentation must be an object"));void 0!==t.extensions&&Xt(t.extensions,`${n}.extensions`,i,a),void 0!==t.bindings&&(Array.isArray(t.bindings)?t.bindings.forEach((e,t)=>{const s=`${n}.bindings[${t}]`;if(o(e)){Jt(e,Bt,s,i);for(const t of["owner","ref","target"])"string"==typeof e[t]&&e[t]||i.push(Vt("binding_field_invalid",`${s}.${t}`,`${t} is required`));void 0===e.revision||"string"==typeof e.revision&&e.revision||i.push(Vt("binding_revision_invalid",`${s}.revision`,"Revision must be a non-empty string"))}else i.push(Vt("binding_invalid",s,"Binding must be an object"))}):i.push(Vt("bindings_invalid",`${n}.bindings`,"Bindings must be an array")));const p=t.slots||{};if(o(p)){"leaf"===f.mode&&Object.keys(p).length&&i.push(Vt("leaf_slots_forbidden",`${n}.slots`,"Leaf type cannot contain slots"));for(const[e,t]of Object.entries(p)){const o=f.slots?.[e];o?Array.isArray(t)?((t.length>r.maxChildrenPerSlot||t.length>o.max||t.length<o.min)&&i.push(Vt("slot_cardinality",`${n}.slots.${e}`,"Slot child count is outside the allowed range")),t.forEach((t,r)=>{const a=s.types.get(t?.type);a&&o.types&&!o.types.includes(t.type)&&i.push(Vt("slot_child_type_forbidden",`${n}.slots.${e}[${r}]`,`${t.type} is not allowed in this slot`)),a&&o.categories&&!o.categories.includes(a.category)&&i.push(Vt("slot_child_category_forbidden",`${n}.slots.${e}[${r}]`,`${a.category} is not allowed in this slot`)),d(t,`${n}.slots.${e}[${r}]`,l+1)})):i.push(Vt("slot_children_invalid",`${n}.slots.${e}`,"Slot children must be an array")):i.push(Vt("slot_unknown",`${n}.slots.${e}`,`Slot ${e} is not registered`))}for(const[e,t]of Object.entries(f.slots||{}))t.min>0&&!(e in p)&&i.push(Vt("slot_required",`${n}.slots.${e}`,`Slot ${e} is required`))}else i.push(Vt("slots_invalid",`${n}.slots`,"Slots must be an object"))};return d(e.root,"$.root",1),u>r.maxNodes?i.push(Vt("node_limit","$.root","Composition has too many nodes")):(h(e.root,s,i),gt(e.root,s,en(n.ports),i)),{valid:0===i.length,diagnostics:i}}async function sn(e,t=void 0,n={}){const o=tn(t),r=on(e,o,n);if(!r.valid)return{document:null,digest:null,dependencies:{assets:[],bindings:[]},diagnostics:r.diagnostics};const a=i(JSON.parse(JSON.stringify(e))),l={assets:new Set,bindings:new Map},c=e=>{!function(e,t,n){for(const e of t.assets||[])n.assets.add(e);for(const t of e.bindings||[])n.bindings.set(`${t.owner}:${t.ref}:${t.target}:${t.revision||""}`,i(t))}(e,o.types.get(e.type),l),Object.values(e.slots||{}).flat().forEach(c)};return c(a.root),{document:a,digest:await Zt(s(a)),dependencies:{assets:[...l.assets].sort(),bindings:[...l.bindings.values()].sort((e,t)=>s(e).localeCompare(s(t)))},diagnostics:[]}}function rn(e){return String(e).replaceAll("&","&amp;").replaceAll("<","&lt;").replaceAll(">","&gt;").replaceAll('"',"&quot;").replaceAll("'","&#39;")}function an(e){return(e||[]).map(e=>{if("link"===e.type)return`<a href="${rn(e.href)}">${an(e.children)}</a>`;let t=rn(e.value);for(const n of e.marks||[])t="strong"===n?`<strong>${t}</strong>`:"em"===n?`<em>${t}</em>`:`<code>${t}</code>`;return t}).join("")}const ln={"layout.page":({node:e,slots:t})=>`<main data-sf-composition-id="${rn(e.id)}">${t.default||""}</main>`,"layout.section":({node:e,slots:t})=>`<section data-sf-composition-id="${rn(e.id)}">${t.default||""}</section>`,"layout.columns":({node:e,slots:t})=>{const n=Number.isInteger(e.props?.columns)?` data-composition-columns="${e.props.columns}"`:"";return`<div class="sf-composition-columns" data-sf-composition-id="${rn(e.id)}"${n}>${(t.columnsList||[]).map(e=>`<div class="sf-composition-column">${e}</div>`).join("")}</div>`},"content.heading":({node:e})=>`<h${e.data.level||2} data-sf-composition-id="${rn(e.id)}">${an(e.data.content)}</h${e.data.level||2}>`,"content.paragraph":({node:e})=>`<p data-sf-composition-id="${rn(e.id)}">${an(e.data.content)}</p>`,"layout.regions":({node:e,slots:t})=>`<div class="sf-composition-regions" data-sf-composition-id="${rn(e.id)}"><div class="sf-composition-regions-grid">${t.regions||""}</div></div>`,"layout.region":({node:e,slots:t})=>{const n=e.props,o=u[n.landmark],i=!0===n.sticky?' data-sf-region-sticky=""':"",s=void 0!==n.label?` aria-label="${rn(n.label)}"`:"";return`<${o} class="sf-composition-region" data-sf-composition-id="${rn(e.id)}" data-sf-region="${rn(n.name)}" data-sf-region-placement="${rn(n.placement??"block")}"${i}${s}>${t.default||""}</${o}>`},"layout.scope":({node:e,slots:t,routes:n})=>`<sf-composition-scope data-sf-composition-id="${rn(e.id)}" data-sf-routes="${rn(function(e){return s(e.map(e=>({id:e.id,from:{endpoint:e.from.endpoint,port:e.from.port,value:e.from.value},to:{endpoint:e.to.endpoint,port:e.to.port,value:e.to.value}})))}(n||[]))}">${t.default||""}</sf-composition-scope>`};const cn=Object.freeze({BUILTIN_EDITOR_MANIFESTS:k,BUILTIN_FIELD_KINDS:V,BUILTIN_PORT_MANIFESTS:$,Recipe:Ae,applyFieldValue:Q,parseFieldSubmission:K,renderFieldFallback:te,resolveFieldKind:G,validateFieldKinds:Y,validateFieldValue:X,VALUE_TYPES:it,checkPortValue:dt,checkFragmentDescriptor:function(e){if(!o(e))return["descriptor: not an object"];const t=[],n=Object.keys(e);for(const e of $t)n.includes(e)||t.push(`${e}: required`);for(const e of n)$t.includes(e)||"schema_version"===e||t.push(`${e}: undeclared`);(0,b.Wl)(e,"simai.interface-fragment",1)||t.push("schema: not simai.interface-fragment, schema_version 1"),"string"==typeof e.id&&kt.test(e.id)||t.push("id: a dotted identity"),"string"==typeof e.element&&St.test(e.element)||t.push("element: a custom element name"),Pt(e.regions,8,e=>"string"==typeof e&&Et.test(e))&&e.regions.length||t.push("regions: one to eight region names");const i=e.port;Lt(i,["standard","version"])&&Ot.test(i?.standard??"")&&Tt.test(i?.version??"")||t.push("port: {standard, version}"),"outputs"in e&&t.push(...zt(e.outputs,"outputs")),"inputs"in e&&t.push(...zt(e.inputs,"inputs")),"string"==typeof e.operation&&jt.test(e.operation)||t.push("operation: an access operation token"),Pt(e.url_state,16,e=>"string"==typeof e&&At.test(e))||t.push("url_state: up to sixteen query keys");const s=e.budget;return(!Lt(s,["kb","first_answer_ms"])||!Number.isSafeInteger(s.kb)||s.kb<0||s.kb>2048||!Number.isSafeInteger(s.first_answer_ms)||s.first_answer_ms<0||s.first_answer_ms>1e4)&&t.push("budget: {kb 0-2048, first_answer_ms 0-10000}"),t},FRAGMENT_DESCRIPTOR_SCHEMA:"simai.interface-fragment.v1",publishEffects:function(e,{origin:t=null}={}){if(!Array.isArray(e)||!e.length)return{published:[],refused:[]};const n=globalThis.document,o=t?.closest?.("sf-composition-scope"),i=o?[...o.querySelectorAll("sf-page-host")].filter(e=>e.parentElement?.closest("sf-composition-scope")===o):[...n?.querySelectorAll("sf-page-host")??[]],s=1===i.length?i[0]:null;return s&&"function"==typeof s.publish?s.publish(e):{published:[],refused:e.map(e=>({type:e?.type??null,reason:"no_page_host"}))}},createPortRegistry:ft,defineCompositionScope:xt,startInlineEdit:function(e,t){const n=globalThis.SF?.InlineEditor;if("function"!=typeof n?.startInlineEdit)throw new TypeError("inline_editor_not_loaded");return n.startInlineEdit(e,t)},normalizeInline:qe,inlineText:De,BUILTIN_TYPE_MANIFESTS:x,createRegistry:nn,extendRegistry:function(e=[],t={}){return nn([...x,...e],t)},compositionTypeFromSmartManifest:function(e){const t=e?.composition?.declarative;if(!t)return null;const n=e.inputs?.properties||{},o=Object.fromEntries(Object.entries(t.data||{}).map(([n,o])=>{const i=e.contracts?.[o.contract];if(!i)throw new TypeError(`composition_data_contract_missing:${t.type}:${n}`);return[n,i]})),i=Object.fromEntries((t.events||[]).filter(t=>e.events?.[t]).map(t=>[t,{summary:e.events[t].summary,payload:e.events[t].payload}])),s=e.persistence?{mode:e.persistence.mode,source_of_truth:e.persistence.source_of_truth,network_owner:e.persistence.network_owner,settings_key_prop:t.persistence?.settings_key_prop??null,revision_prop:t.persistence?.revision_prop??null}:void 0;return{...(0,b.xZ)("simai.composition.type-manifest",1),type:t.type,version:e.version,category:"smart",mode:t.mode,profiles:t.profiles,data_schema:{type:"object",additionalProperties:!1,properties:o},props_schema:{type:"object",additionalProperties:!1,properties:(r=t.props,Object.fromEntries(Object.entries(n).filter(([e])=>new Set(r||[]).has(e))))},presentation:t.presentation||{views:["default"],presets:[],modifiers:[]},slots:t.slots||{},renderer:t.renderer,assets:t.assets||[],capabilities:["html","hydration"],...Object.keys(i).length?{events:i}:{},...s?{persistence:s}:{}};var r},describeRegions:y,normalize:sn,projectDocumentEditorFields:U,projectEditorFields:B,render:async function(e,t={}){const n=tn(t.registry),o=await sn(e,n,t.options||{});if(!o.document)return{html:"",assets:[],hydration:[],diagnostics:o.diagnostics,digest:null};const i=[],s=[],r=gt(o.document.root,n,en(t.options?.ports),[]),a=async e=>{const l=n.types.get(e.type),c={};for(const[t,n]of Object.entries(e.slots||{})){const e=[];for(const t of n)e.push(await a(t));c[t]=e.join(""),c[`${t}List`]=e}const u={};for(const n of e.bindings||[])t.resolveBinding&&(u[n.target]=await t.resolveBinding(n,{document:o.document,node:e}));let d=n.renderers.get(l.renderer.name)||ln[l.renderer.name];return!d&&"custom-element"===l.renderer.kind&&l.renderer.name&&(d=({node:e,slots:t,endpoint:n})=>{const o=n?` data-sf-endpoint="${rn(n)}"`:"",i=Object.entries(e.props||{}).map(([e,t])=>` ${rn(e)}="${rn(t)}"`).join("")+o;return s.push({id:e.id,type:e.type,element:l.renderer.name}),`<${l.renderer.name}${i}>${Object.values(t).filter(e=>"string"==typeof e).join("")}</${l.renderer.name}>`}),d?("layout.scope"===e.type&&s.push({id:e.id,type:e.type,element:"sf-composition-scope"}),d({node:e,slots:c,context:t,resolvedBindings:u,manifest:l,routes:r.get(e.id),endpoint:ht(e)})):(i.push(Vt("renderer_unavailable",`node:${e.id}`,`Renderer ${l.renderer.name} is unavailable`)),"")};return{html:await a(o.document.root),assets:o.dependencies.assets,hydration:s,diagnostics:i,digest:o.digest}},resolveRecipe:je,parseRecipeJson:be,stableStringify:s,validate:on,validateEditorManifest:D});"undefined"!=typeof globalThis&&(globalThis.SF=globalThis.SF||{},globalThis.SF.Composition=cn,xt(),function(e=globalThis.customElements){if(!e||"function"!=typeof globalThis.HTMLElement)return null;const t=e.get("sf-page-host");if(t)return t;class n extends globalThis.HTMLElement{static sfPorts=Object.freeze({outputs:Object.freeze(Object.fromEntries(Rt.map(e=>[Ct(e),e]))),inputs:Object.freeze({})});connectedCallback(){this.hidden=!0}sfPortInput(){throw new TypeError("sf-page-host has no inputs")}publish(e=[]){const t=[],n=[];for(const o of Array.isArray(e)?e:[]){const e=o?.type;if(!Ft.includes(at(e))){n.push({type:e??null,reason:"type_not_published"});continue}let i;try{i=ct(e).check(o.value)}catch(t){n.push({type:e,reason:"value_invalid",message:String(t?.message??t)});continue}this.dispatchEvent(new globalThis.CustomEvent("sf-port-output",{bubbles:!0,detail:{port:Ct(e),value:i}})),t.push(e)}return n.length&&this.dispatchEvent(new globalThis.CustomEvent("sf-page-host-refused",{bubbles:!0,detail:{refused:n}})),{published:t,refused:n}}}e.define("sf-page-host",n)}(),function(e=globalThis.customElements){if(!e||"function"!=typeof globalThis.HTMLElement)return null;const t=e.get("sf-fragment");if(t)return t;class n extends globalThis.HTMLElement{constructor(){super(),this.markup=null,this.failed=null,this.timer=null,this.onError=e=>{this.failed||(e.stopPropagation(),this.fail(e.detail?.phase??"render",e.detail?.message??""))},this.onAction=e=>{this.failed&&"retry"===e.detail?.id&&(e.stopPropagation(),this.retry())}}connectedCallback(){null===this.markup&&(this.markup=this.innerHTML),this.addEventListener("sf-component-error",this.onError),this.addEventListener("sf-empty-state-action",this.onAction),this.failed||this.watchLoad()}disconnectedCallback(){clearTimeout(this.timer),this.removeEventListener("sf-component-error",this.onError),this.removeEventListener("sf-empty-state-action",this.onAction)}get fragmentElement(){return[...this.children].find(e=>e.localName.includes("-"))??null}watchLoad(){clearTimeout(this.timer);const e=this.fragmentElement;if(!e||globalThis.customElements.get(e.localName))return;const t=Number(this.getAttribute("load-timeout"))||1e4;this.timer=setTimeout(()=>{!globalThis.customElements.get(e.localName)&&e.isConnected&&this.fail("load",`${e.localName} did not load`)},t)}text(e){const t=(this.closest("[lang]")?.getAttribute("lang")||"en").slice(0,2);return(Nt[t]??Nt.en)[e]}fail(e,t){clearTimeout(this.timer),this.failed={phase:e,message:t},this.setAttribute("data-sf-fragment-state","error");const n=globalThis.document.createElement("sf-empty-state");n.setAttribute("kind","error"),n.setAttribute("title",this.text("heading")),this.replaceChildren(n),this.dispatchEvent(new globalThis.CustomEvent("sf-fragment-error",{bubbles:!0,composed:!0,detail:{fragment:this.getAttribute("data-sf-fragment"),phase:e,message:t}}))}retry(){this.failed=null,this.removeAttribute("data-sf-fragment-state"),this.innerHTML=this.markup??"",this.watchLoad(),this.dispatchEvent(new globalThis.CustomEvent("sf-fragment-retry",{bubbles:!0,composed:!0,detail:{fragment:this.getAttribute("data-sf-fragment")}}))}}e.define("sf-fragment",n)}())},ac24888e7d3e(e,t,n){"use strict";n.d(t,{G7:()=>i,Wl:()=>s,xZ:()=>r});const o=/^(.+)\.v([0-9]+)$/u;function i(e){const t=e?.schema??e?.schema_id;if("string"!=typeof t||!t)return null;const n=t.match(o);if(n)return{name:n[1],version:Number(n[2]),form:"versioned-name"};const i=e?.schema_version;return{name:t,version:Number.isInteger(i)?i:null,form:"name"}}function s(e,t,n){const o=i(e);return!(!o||o.name!==t||o.version!==n)&&(void 0===e.schema_version||e.schema_version===n)}function r(e,t){if(o.test(e))throw new TypeError(`A format name carries no version: ${e}`);if(!Number.isInteger(t)||t<1)throw new TypeError(`A format's version is a whole major: ${t}`);return{schema:e,schema_version:t}}}};const t={};function n(o){const i=t[o];if(void 0!==i)return i.exports;const s=t[o]={exports:{}};return e[o](s,s.exports,n),s.exports}n.m=e,n.n=e=>{const t=e&&e.__esModule?()=>e.default:()=>e;return n.d(t,{a:t}),t},n.d=(e,t)=>{if(Array.isArray(t))for(var o=0;o<t.length;){var i=t[o++],s=t[o++];n.o(e,i)?0===s&&o++:0===s?Object.defineProperty(e,i,{enumerable:!0,value:t[o++]}):Object.defineProperty(e,i,{enumerable:!0,get:s})}else for(var i in t)n.o(t,i)&&!n.o(e,i)&&Object.defineProperty(e,i,{enumerable:!0,get:t[i]})},n.f={},n.e=e=>Promise.all(Object.keys(n.f).reduce((t,o)=>(n.f[o](e,t),t),[])),n.u=e=>"js/"+{80841737880868:"core-rules",88616323197113:"core-system",66700837013363:"core-loader"}[e]+".min.js",n.miniCssF=e=>"css/core.min.css",n.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(e){if("object"==typeof window)return window}}(),n.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),(()=>{const e={};n.l=(t,o,i,s)=>{if(e[t])return void e[t].push(o);let r,a;if(void 0!==i){const e=document.getElementsByTagName("script");for(var l=0;l<e.length;l++){const n=e[l];if(n.getAttribute("src")==t){r=n;break}}}r||(a=!0,r=document.createElement("script"),r.charset="utf-8",n.nc&&r.setAttribute("nonce",n.nc),r.src=t),e[t]=[o];const c=(n,o)=>{r.onerror=r.onload=null,clearTimeout(u);const i=e[t];if(delete e[t],r.parentNode?.removeChild(r),i?.forEach(e=>e(o)),n)return n(o)},u=setTimeout(c.bind(null,void 0,{type:"timeout",target:r}),12e4);r.onerror=c.bind(null,r.onerror),r.onload=c.bind(null,r.onload),a&&document.head.appendChild(r)}})(),n.r=e=>{Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},(()=>{let e;n.g.importScripts&&(e=n.g.location+"");const t=n.g.document;if(!e&&t&&("SCRIPT"===t.currentScript?.tagName.toUpperCase()&&(e=t.currentScript.src),!e)){const n=t.getElementsByTagName("script");if(n.length){let t=n.length-1;for(;t>-1&&(!e||!/^http(s?):/.test(e));)e=n[t--].src}}if(!e)throw new Error("Automatic publicPath is not supported in this browser");e=e.replace(/^blob:/,"").replace(/#.*$/,"").replace(/\?.*$/,"").replace(/\/[^\/]+$/,"/"),n.p=e+"../"})(),(()=>{const e={20514231357218:0};n.f.j=(t,o)=>{let i=n.o(e,t)?e[t]:void 0;if(0!==i)if(i)o.push(i[2]);else{const s=new Promise((n,o)=>i=e[t]=[n,o]);o.push(i[2]=s);const r=n.p+n.u(t),a=new Error,l=o=>{if(n.o(e,t)&&(i=e[t],0!==i&&(e[t]=void 0),i)){const e=o&&("load"===o.type?"missing":o.type),n=o&&o.target&&o.target.src;a.message="Loading chunk "+t+" failed.\n("+e+": "+n+")",a.name="ChunkLoadError",a.type=e,a.request=n,i[1](a)}};n.l(r,l,"chunk-"+t,t)}};const t=(t,o)=>{let[i,s,r]=o;var a,l,c=0;if(i.some(t=>0!==e[t])){for(a in s)n.o(s,a)&&(n.m[a]=s[a]);if(r)r(n)}for(t&&t(o);c<i.length;c++)l=i[c],n.o(e,l)&&e[l]&&e[l][0](),e[l]=0},o=self.webpackChunk=self.webpackChunk||[];o.forEach(t.bind(null,0)),o.push=t.bind(null,o.push.bind(o))})(),(()=>{"use strict";n("3924cca3566b");function e(){const e=globalThis.SF=globalThis.SF||{};return e.__deprecationNotes instanceof Map||Object.defineProperty(e,"__deprecationNotes",{value:new Map,configurable:!0}),e.__deprecationNotes}function t({component:t="",kind:n="attribute",attribute:o="",from:i,to:s=null}={}){if(!i)return;const r=[t,n,o,i].join("|"),a=e(),l=a.get(r);if(l)l.count+=1;else if(a.set(r,{component:t,kind:n,attribute:o,from:i,to:s,count:1}),function(){const e=globalThis.document?.documentElement;return"warn"===e?.dataset?.sfDeprecations||!0===globalThis.SF?.deprecations?.warn}()){const e=t?`${t}: `:"",r="value"===n?`${o}="${i}"`:`${n} ${i}`;globalThis.console?.warn?.(`[SIMAI Framework] ${e}${r} is a legacy name${s?`; write ${s}`:""}. See contracts/changes/journal.json.`)}}if("undefined"!=typeof globalThis){globalThis.SF=globalThis.SF||{};const n=globalThis.SF.deprecations||{};n.list=function(){return[...e().values()].map(e=>({...e}))},n.clear=function(){e().clear()},n.note=t,globalThis.SF.deprecations=n}const o=Object.freeze(["send","receive","runtimeModules","runtimeArrived","runtimeLoading","runtimeSettled","smartBaseAnnounced","litHtml"]);"undefined"!=typeof globalThis&&function(e=globalThis){const n=e.SF=e.SF||{};n.__internal&&"object"==typeof n.__internal||Object.defineProperty(n,"__internal",{value:{},configurable:!0,enumerable:!1,writable:!1});const i=n.__internal;for(const e of o){const o=Object.getOwnPropertyDescriptor(n,e);if(o?.get?.sfInternalAlias)continue;o&&"value"in o&&!(e in i)&&(i[e]=o.value);const s=()=>(t({kind:"global",from:`SF.${e}`,to:`SF.__internal.${e}`}),i[e]);s.sfInternalAlias=!0,Object.defineProperty(n,e,{configurable:!0,enumerable:!1,get:s,set(t){i[e]=t}})}}(globalThis);n("987c832cfe13");function i(e){return String(e??"").replace(/\D+/g,"")}const s={0:e=>/\d/u.test(e),a:e=>/\p{L}/u.test(e),"*":()=>!0};function r(e){const t=[];let n=!1;for(let o=0;o<e.length;o+=1){const i=e[o];"\\"===i?(o+=1,o<e.length&&t.push({fixed:e[o],unmasked:n})):"{"===i?n=!0:"}"===i?n=!1:"["===i||"]"===i||(s[i]?t.push({test:s[i]}):t.push({fixed:i,unmasked:n}))}return t}function a(e,t,n={},o=-1){const i=n.placeholderChar||"_",s=String(e??""),r=t.filter(e=>e.test),a=[];let l=0,c=0;for(let e=0;e<s.length;e+=1){const u=s[e];for(;c<t.length&&void 0!==t[c].fixed&&t[c].fixed!==u;)c+=1;if(c>=t.length){!1===n.lazy&&a.length<r.length&&r[a.length].test(u)&&(a.push(u),e<o&&(l=a.length));continue}const d=t[c];void 0!==d.fixed||!1===n.lazy&&u===i?c+=1:d.test(u)&&(a.push(u),e<o&&(l=a.length),c+=1)}return{accepted:a,before:l}}function l(e,t,n={}){const o=n.placeholderChar||"_",i=!1===n.lazy;let s="",r="";const a=[];let l=-1,c=0;for(const n of t)if(void 0!==n.fixed){if(c>=e.length&&!i)break;s+=n.fixed,n.unmasked&&c<e.length&&(r+=n.fixed)}else if(c<e.length)0===c&&(l=s.length),s+=e[c],r+=e[c],c+=1,a[c]=s.length;else{if(!i)break;s+=o}return i||0!==c||(s=""),a[0]=l>=0?l:i&&s.includes(o)?s.indexOf(o):s.length,{display:s,unmasked:r,caretAfter:a}}function c(e){const{mask:t}=e;return t===Number||"Number"===t||"function"==typeof t&&"Number"===t.name&&1===t(" 1 ")}function u(e){return e.radix||","}function d(e,t={}){let n=String(e??"");t.thousandsSeparator&&(n=n.replaceAll(t.thousandsSeparator,"")),n=n.replace(/\s+/gu,"");const o=u(t);if("."!==o&&(n=n.replace(o,".")),""===n||"-"===n||"."===n)return null;const i=Number(n);return Number.isFinite(i)?i:null}function f(e,t){return t?e.replace(/\B(?=(\d{3})+(?!\d))/gu,t):e}function p(e,t={},n=-1){const o=u(t),i=new Set([o,...t.mapToRadix||[".",","]]),s=Math.max(0,Number(t.scale??2)||0),r=!0===t.signed||Number.isFinite(t.min)&&t.min<0;let a=!1,l="",c="",d=!1,p=0;const m=String(e??"");for(let e=0;e<m.length;e+=1){const o=m[e],u=e<n;if(/\d/u.test(o)){if(d){if(c.length>=s)continue;c+=o}else l+=o;u&&(p+=1)}else"-"!==o||!r||a||l||d?i.has(o)&&o!==t.thousandsSeparator&&s>0&&!d&&(d=!0,u&&(p+=1)):(a=!0,u&&(p+=1))}!1!==t.normalizeZeros&&(l=l.replace(/^0+(?=\d)/u,"")),d&&!l&&(l="0");return{display:`${a?"-":""}${f(l,t.thousandsSeparator)}`+(d?`${o}${c}`:""),typedBefore:p}}function m(e,t={}){if(""===e||null==e)return"";const n="number"==typeof e?e:d(p(e,t).display,t);if(null===n||!Number.isFinite(n))return"";const o=Number.isFinite(t.min)?t.min:n,i=Number.isFinite(t.max)?t.max:n,s=Math.min(i,Math.max(o,n)),r=Math.max(0,Number(t.scale??2)||0),a=s.toFixed(r),[l,c=""]=(t.padFractionalZeros?a:String(Number(a))).split(".");return`${l.startsWith("-")?"-":""}${f(l.replace("-",""),t.thousandsSeparator)}${c?`${u(t)}${c}`:""}`}function h(e,t={}){if(c(t))return m(e,t);if("function"==typeof t.mask)return String(t.mask(e));if(t.mask instanceof RegExp){const n=String(e??"");return t.mask.test(n)?n:n.slice(0,-1)}return function(e,t,n={}){if("string"!=typeof t||""===t)return String(e??"");const o=r(t);return l(a(e,o,n).accepted,o,n).display}(e,t.mask,t)}function g(e){try{return"number"==typeof e.selectionStart?e.selectionStart:-1}catch{return-1}}function y(e,t){if(!(t<0||"function"!=typeof e.setSelectionRange)&&e.ownerDocument?.activeElement===e)try{e.setSelectionRange(t,t)}catch{}}function b(e,t){const n={destroyed:!1},o="string"!=typeof t.mask||c(t)?null:r(t.mask),s=(t,n)=>{t!==e.value&&(e.value=t),y(e,n)},f=()=>{if(n.destroyed)return;const i=g(e);if(o){const{accepted:n,before:r}=a(e.value,o,t,i),c=l(n,o,t);s(c.display,i<0?-1:c.caretAfter[r]??c.display.length)}else if(c(t)){const{display:n,typedBefore:o}=p(e.value,t,i);let r=n.length;if(i>=0){let e=0;r=0;const i=u(t);for(;r<n.length&&e<o;){const t=n[r];(/\d/u.test(t)||t===i||"-"===t)&&(e+=1),r+=1}}s(n,i<0?-1:r)}else s(h(e.value,t),-1)},b=()=>{if(n.destroyed||!c(t))return;const o=m(e.value,t);o!==e.value&&(e.value=o)},w=()=>{if(n.destroyed||!o||!1!==t.lazy)return;const i=g(e),s="number"==typeof e.selectionEnd?e.selectionEnd:i;if(i<0||i!==s)return;const{accepted:r}=a(e.value,o,t),c=l(r,o,t),u=c.caretAfter[r.length]??c.display.length;i>u&&y(e,u)},v=()=>{!n.destroyed&&o&&!1===t.lazy&&setTimeout(w,0)};e.addEventListener("input",f),e.addEventListener("blur",b),e.addEventListener("focus",v),e.addEventListener("click",w),c(t)?""!==e.value&&(e.value=m(e.value,t)):f();return{get value(){return e.value},set value(n){e.value=h(n,t)},get unmaskedValue(){return(()=>{if(o)return l(a(e.value,o,t).accepted,o,t).unmasked;if(c(t)){const n=d(e.value,t);return null===n?"":String(n)}return i(e.value)})()},set unmaskedValue(n){e.value=h(o?String(n??""):i(n),t)},get typedValue(){return c(t)&&""!==e.value.trim()?d(e.value,t):null},set typedValue(n){e.value=h(n,t)},updateValue:f,destroy(){n.destroyed||(n.destroyed=!0,e.removeEventListener("input",f),e.removeEventListener("blur",b),e.removeEventListener("focus",v),e.removeEventListener("click",w))}}}const w={load:async()=>b,async create(e,t){const n=function(e){return e?e instanceof HTMLElement?e:"string"==typeof e?document.querySelector(e):null:null}(e);return n&&t?b(n,t):null},pipe:async(e,t)=>h(e,"object"==typeof t?t:{mask:t}),destroy(e){e?.destroy?.()}};(window.SF||(window.SF={}),window.SF).Mask=w,"function"==typeof window.dispatchEvent&&"function"==typeof CustomEvent&&window.dispatchEvent(new CustomEvent("sf-mask-ready"));n("3a00b12d226d");const v=Math.min,_=Math.max,x=Math.round,$=Math.floor,k=e=>({x:e,y:e}),S={left:"right",right:"left",bottom:"top",top:"bottom"};function E(e,t){return"function"==typeof e?e(t):e}function O(e){return e.split("-")[0]}function T(e){return e.split("-")[1]}function j(e){return"x"===e?"y":"x"}function A(e){return"y"===e?"height":"width"}function L(e){const t=e[0];return"t"===t||"b"===t?"y":"x"}function P(e){return j(L(e))}function z(e){return e.includes("start")?e.replace("start","end"):e.replace("end","start")}const R=["left","right"],C=["right","left"],F=["top","bottom"],N=["bottom","top"];function I(e,t,n,o){const i=T(e);let s=function(e,t,n){switch(e){case"top":case"bottom":return n?t?C:R:t?R:C;case"left":case"right":return t?F:N;default:return[]}}(O(e),"start"===n,o);return i&&(s=s.map(e=>e+"-"+i),t&&(s=s.concat(s.map(z)))),s}function M(e){const t=O(e);return S[t]+e.slice(t.length)}function q(e){const{x:t,y:n,width:o,height:i}=e;return{width:o,height:i,top:n,left:t,right:t+o,bottom:n+i,x:t,y:n}}function D(e,t,n){let{reference:o,floating:i}=e;const s=L(t),r=P(t),a=A(r),l=O(t),c="y"===s,u=o.x+o.width/2-i.width/2,d=o.y+o.height/2-i.height/2,f=o[a]/2-i[a]/2;let p;switch(l){case"top":p={x:u,y:o.y-i.height};break;case"bottom":p={x:u,y:o.y+o.height};break;case"right":p={x:o.x+o.width,y:d};break;case"left":p={x:o.x-i.width,y:d};break;default:p={x:o.x,y:o.y}}const m=T(t);return m&&(p[r]+=f*("end"===m?1:-1)*(n&&c?-1:1)),p}async function B(e,t){var n;void 0===t&&(t={});const{x:o,y:i,platform:s,rects:r,elements:a,strategy:l}=e,{boundary:c="clippingAncestors",rootBoundary:u="viewport",elementContext:d="floating",altBoundary:f=!1,padding:p=0}=E(t,e),m=function(e){return"number"!=typeof e?function(e){var t,n,o,i;return{top:null!=(t=e.top)?t:0,right:null!=(n=e.right)?n:0,bottom:null!=(o=e.bottom)?o:0,left:null!=(i=e.left)?i:0}}(e):{top:e,right:e,bottom:e,left:e}}(p),h=a[f?"floating"===d?"reference":"floating":d],g=q(await s.getClippingRect({element:null==(n=await(null==s.isElement?void 0:s.isElement(h)))||n?h:h.contextElement||await(null==s.getDocumentElement?void 0:s.getDocumentElement(a.floating)),boundary:c,rootBoundary:u,strategy:l})),y="floating"===d?{x:o,y:i,width:r.floating.width,height:r.floating.height}:r.reference,b=await(null==s.getOffsetParent?void 0:s.getOffsetParent(a.floating)),w=await(null==s.isElement?void 0:s.isElement(b))&&await(null==s.getScale?void 0:s.getScale(b))||{x:1,y:1},v=q(s.convertOffsetParentRelativeRectToViewportRelativeRect?await s.convertOffsetParentRelativeRectToViewportRelativeRect({elements:a,rect:y,offsetParent:b,strategy:l}):y);return{top:(g.top-v.top+m.top)/w.y,bottom:(v.bottom-g.bottom+m.bottom)/w.y,left:(g.left-v.left+m.left)/w.x,right:(v.right-g.right+m.right)/w.x}}const U=new Set(["left","top"]);function W(){return"undefined"!=typeof window}function H(e){return J(e)?(e.nodeName||"").toLowerCase():"#document"}function V(e){var t;return(null==e||null==(t=e.ownerDocument)?void 0:t.defaultView)||window}function Z(e){var t;return null==(t=(J(e)?e.ownerDocument:e.document)||window.document)?void 0:t.documentElement}function J(e){return!!W()&&(e instanceof Node||e instanceof V(e).Node)}function G(e){return!!W()&&(e instanceof Element||e instanceof V(e).Element)}function X(e){return!!W()&&(e instanceof HTMLElement||e instanceof V(e).HTMLElement)}function Y(e){return!(!W()||"undefined"==typeof ShadowRoot)&&(e instanceof ShadowRoot||e instanceof V(e).ShadowRoot)}function K(e){const{overflow:t,overflowX:n,overflowY:o,display:i}=le(e);return/auto|scroll|overlay|hidden|clip/.test(t+o+n)&&"inline"!==i&&"contents"!==i}function Q(e){return/^(table|td|th)$/.test(H(e))}function ee(e){try{if(e.matches(":popover-open"))return!0}catch(e){}try{return e.matches(":modal")}catch(e){return!1}}const te=/transform|translate|scale|rotate|perspective|filter/,ne=/paint|layout|strict|content/,oe=e=>!!e&&"none"!==e;let ie;function se(e){const t=G(e)?le(e):e;return oe(t.transform)||oe(t.translate)||oe(t.scale)||oe(t.rotate)||oe(t.perspective)||!re()&&(oe(t.backdropFilter)||oe(t.filter))||te.test(t.willChange||"")||ne.test(t.contain||"")}function re(){return null==ie&&(ie="undefined"!=typeof CSS&&CSS.supports&&CSS.supports("-webkit-backdrop-filter","none")),ie}function ae(e){return/^(html|body|#document)$/.test(H(e))}function le(e){return V(e).getComputedStyle(e)}function ce(e){return G(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function ue(e){if("html"===H(e))return e;const t=e.assignedSlot||e.parentNode||Y(e)&&e.host||Z(e);return Y(t)?t.host:t}function de(e){const t=ue(e);return ae(t)?(e.ownerDocument||e).body:X(t)&&K(t)?t:de(t)}function fe(e,t,n){var o;void 0===t&&(t=[]),void 0===n&&(n=!0);const i=de(e),s=i===(null==(o=e.ownerDocument)?void 0:o.body),r=V(i);if(s){const e=pe(r);return t.concat(r,r.visualViewport||[],K(i)?i:[],e&&n?fe(e):[])}return t.concat(i,fe(i,[],n))}function pe(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}function me(e){const t=le(e);let n=parseFloat(t.width)||0,o=parseFloat(t.height)||0;const i=X(e),s=i?e.offsetWidth:n,r=i?e.offsetHeight:o,a=x(n)!==s||x(o)!==r;return a&&(n=s,o=r),{width:n,height:o,$:a}}function he(e){return G(e)?e:e.contextElement}function ge(e){const t=he(e);if(!X(t))return k(1);const n=t.getBoundingClientRect(),{width:o,height:i,$:s}=me(t);let r=(s?x(n.width):n.width)/o,a=(s?x(n.height):n.height)/i;return r&&Number.isFinite(r)||(r=1),a&&Number.isFinite(a)||(a=1),{x:r,y:a}}const ye=k(0);function be(e){const t=V(e);return re()&&t.visualViewport?{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}:ye}function we(e,t,n,o){void 0===t&&(t=!1),void 0===n&&(n=!1);const i=e.getBoundingClientRect(),s=he(e);let r=k(1);t&&(o?G(o)&&(r=ge(o)):r=ge(e));const a=function(e,t,n){return void 0===t&&(t=!1),!!n&&t&&n===V(e)}(s,n,o)?be(s):k(0);let l=(i.left+a.x)/r.x,c=(i.top+a.y)/r.y,u=i.width/r.x,d=i.height/r.y;if(s&&o){const e=V(s),t=G(o)?V(o):o;let n=e,i=pe(n);for(;i&&t!==n;){const e=ge(i),t=i.getBoundingClientRect(),o=le(i),s=t.left+(i.clientLeft+parseFloat(o.paddingLeft))*e.x,r=t.top+(i.clientTop+parseFloat(o.paddingTop))*e.y;l*=e.x,c*=e.y,u*=e.x,d*=e.y,l+=s,c+=r,n=V(i),i=pe(n)}}return q({width:u,height:d,x:l,y:c})}function ve(e,t){const n=ce(e).scrollLeft;return t?t.left+n:we(Z(e)).left+n}function _e(e,t){const n=e.getBoundingClientRect();return{x:n.left+t.scrollLeft-ve(e,n),y:n.top+t.scrollTop}}function xe(e,t,n){let o;if("viewport"===t||"layoutViewport"===t)o=function(e,t,n){void 0===n&&(n="viewport");const o="layoutViewport"===n,i=V(e),s=Z(e),r=i.visualViewport;let a=s.clientWidth,l=s.clientHeight,c=0,u=0;if(r){const e=!re()||"fixed"===t;o?e||(c=-r.offsetLeft,u=-r.offsetTop):(a=r.width,l=r.height,e&&(c=r.offsetLeft,u=r.offsetTop))}if(ve(s)<=0){const e=s.ownerDocument,t=e.body,n=getComputedStyle(t),o="CSS1Compat"===e.compatMode&&parseFloat(n.marginLeft)+parseFloat(n.marginRight)||0,i=Math.abs(s.clientWidth-t.clientWidth-o),r="stable both-edges"===getComputedStyle(s).scrollbarGutter?i/2:i;r<=25&&(a-=r)}return{width:a,height:l,x:c,y:u}}(e,n,t);else if("document"===t)o=function(e){const t=ce(e),n=e.ownerDocument.body,o=_(e.scrollWidth,e.clientWidth,n.scrollWidth,n.clientWidth),i=_(e.scrollHeight,e.clientHeight,n.scrollHeight,n.clientHeight);let s=-t.scrollLeft+ve(e);const r=-t.scrollTop;return"rtl"===le(n).direction&&(s+=_(e.clientWidth,n.clientWidth)-o),{width:o,height:i,x:s,y:r}}(Z(e));else if(G(t))o=function(e,t){const n=we(e,!0,"fixed"===t),o=n.top+e.clientTop,i=n.left+e.clientLeft,s=ge(e);return{width:e.clientWidth*s.x,height:e.clientHeight*s.y,x:i*s.x,y:o*s.y}}(t,n);else{const n=be(e);o={x:t.x-n.x,y:t.y-n.y,width:t.width,height:t.height}}return q(o)}function $e(e,t,n){const o=X(t),i=Z(t),s="fixed"===n,r=we(e,!0,s,t);let a={scrollLeft:0,scrollTop:0};const l=k(0);if((o||!s)&&(("body"!==H(t)||K(i))&&(a=ce(t)),o)){const e=we(t,!0,s,t);l.x=e.x+t.clientLeft,l.y=e.y+t.clientTop}!o&&i&&(l.x=ve(i));const c=!i||o||s?k(0):_e(i,a);return{x:r.left+a.scrollLeft-l.x-c.x,y:r.top+a.scrollTop-l.y-c.y,width:r.width,height:r.height}}function ke(e){return"static"===le(e).position}function Se(e,t){if(!X(e)||"fixed"===le(e).position)return null;if(t)return t(e);let n=e.offsetParent;return Z(e)===n&&(n=n.ownerDocument.body),n}function Ee(e,t){const n=V(e);if(ee(e))return n;if(!X(e)){let t=ue(e);for(;t&&!ae(t);){if(G(t)&&!ke(t))return t;t=ue(t)}return n}let o=Se(e,t);for(;o&&Q(o)&&ke(o);)o=Se(o,t);return o&&ae(o)&&ke(o)&&!se(o)?n:o||function(e){let t=ue(e);for(;X(t)&&!ae(t);){if(se(t))return t;if(ee(t))return null;t=ue(t)}return null}(e)||n}const Oe={convertOffsetParentRelativeRectToViewportRelativeRect:function(e){let{elements:t,rect:n,offsetParent:o,strategy:i}=e;const s="fixed"===i,r=Z(o),a=!!t&&ee(t.floating);if(o===r||a&&s)return n;let l={scrollLeft:0,scrollTop:0},c=k(1);const u=k(0),d=X(o);if((d||!s)&&(("body"!==H(o)||K(r))&&(l=ce(o)),d)){const e=we(o);c=ge(o),u.x=e.x+o.clientLeft,u.y=e.y+o.clientTop}const f=!r||d||s?k(0):_e(r,l);return{width:n.width*c.x,height:n.height*c.y,x:n.x*c.x-l.scrollLeft*c.x+u.x+f.x,y:n.y*c.y-l.scrollTop*c.y+u.y+f.y}},getDocumentElement:Z,getClippingRect:function(e){let{element:t,boundary:n,rootBoundary:o,strategy:i}=e;const s=[..."clippingAncestors"===n?ee(t)?[]:function(e,t){const n=t.get(e);if(n)return n;let o=fe(e,[],!1).filter(e=>G(e)&&"body"!==H(e)),i=null;const s="fixed"===le(e).position;let r=s?ue(e):e;for(;G(r)&&!ae(r);){const e=le(r),t=se(r),n=i?i.position:s?"fixed":"";t||"fixed"!==n&&("absolute"!==n||"static"!==e.position)?i=e:o=o.filter(e=>e!==r),r=ue(r)}return t.set(e,o),o}(t,this._c):[].concat(n),o],r=xe(t,s[0],i);let a=r.top,l=r.right,c=r.bottom,u=r.left;for(let e=1;e<s.length;e++){const n=xe(t,s[e],i);a=_(n.top,a),l=v(n.right,l),c=v(n.bottom,c),u=_(n.left,u)}return{width:l-u,height:c-a,x:u,y:a}},getOffsetParent:Ee,getElementRects:async function(e){const t=this.getOffsetParent||Ee,n=this.getDimensions,o=await n(e.floating);return{reference:$e(e.reference,await t(e.floating),e.strategy),floating:{x:0,y:0,width:o.width,height:o.height}}},getClientRects:function(e){return e.getClientRects?Array.from(e.getClientRects()):[]},getDimensions:function(e){const{width:t,height:n}=me(e);return{width:t,height:n}},getScale:ge,isElement:G,isRTL:function(e){return"rtl"===le(e).direction}};function Te(e,t){return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}function je(e,t,n,o){void 0===o&&(o={});const{ancestorScroll:i=!0,ancestorResize:s=!0,elementResize:r="function"==typeof ResizeObserver,layoutShift:a="function"==typeof IntersectionObserver,animationFrame:l=!1}=o,c=he(e),u=i||s?[...c?fe(c):[],...t?fe(t):[]]:[];u.forEach(e=>{i&&e.addEventListener("scroll",n),s&&e.addEventListener("resize",n)});const d=c&&a?function(e,t,n){let o,i=null;const s=Z(e);function r(){var e;clearTimeout(o),null==(e=i)||e.disconnect(),i=null}function a(n,l){void 0===n&&(n=!1),void 0===l&&(l=1),r();const c=e.getBoundingClientRect(),{left:u,top:d,width:f,height:p}=c;if(n||t(),!f||!p)return;const m={rootMargin:-$(d)+"px "+-$(s.clientWidth-(u+f))+"px "+-$(s.clientHeight-(d+p))+"px "+-$(u)+"px",threshold:_(0,v(1,l))||1};let h=!0;function g(t){const n=t[0].intersectionRatio;if(!Te(c,e.getBoundingClientRect()))return a();if(n!==l){if(!h)return a();n?a(!1,n):o=setTimeout(()=>{a(!1,1e-7)},1e3)}h=!1}try{i=new IntersectionObserver(g,{...m,root:s.ownerDocument})}catch(e){i=new IntersectionObserver(g,m)}i.observe(e)}const l=V(e),c=()=>a(n);return l.addEventListener("resize",c),a(!0),()=>{l.removeEventListener("resize",c),r()}}(c,n,s):null;let f,p=-1,m=null;r&&(m=new ResizeObserver(e=>{let[o]=e;o&&o.target===c&&m&&t&&(m.unobserve(t),cancelAnimationFrame(p),p=requestAnimationFrame(()=>{var e;null==(e=m)||e.observe(t)})),n()}),c&&!l&&m.observe(c),t&&m.observe(t));let h=l?we(e):null;return l&&function t(){const o=we(e);h&&!Te(h,o)&&n();h=o,f=requestAnimationFrame(t)}(),n(),()=>{var e;u.forEach(e=>{i&&e.removeEventListener("scroll",n),s&&e.removeEventListener("resize",n)}),null==d||d(),null==(e=m)||e.disconnect(),m=null,l&&cancelAnimationFrame(f)}}const Ae=function(e){return void 0===e&&(e=0),{name:"offset",options:e,async fn(t){var n,o;const{x:i,y:s,placement:r,middlewareData:a}=t,l=await async function(e,t){const{placement:n,platform:o,elements:i}=e,s=await(null==o.isRTL?void 0:o.isRTL(i.floating)),r=O(n),a=T(n),l="y"===L(n),c=U.has(r)?-1:1,u=s&&l?-1:1,d=E(t,e);let{mainAxis:f,crossAxis:p,alignmentAxis:m}="number"==typeof d?{mainAxis:d,crossAxis:0,alignmentAxis:null}:{mainAxis:d.mainAxis||0,crossAxis:d.crossAxis||0,alignmentAxis:d.alignmentAxis};return a&&"number"==typeof m&&(p="end"===a?-1*m:m),l?{x:p*u,y:f*c}:{x:f*c,y:p*u}}(t,e);return r===(null==(n=a.offset)?void 0:n.placement)&&null!=(o=a.arrow)&&o.alignmentOffset?{}:{x:i+l.x,y:s+l.y,data:{...l,placement:r}}}}},Le=function(e){return void 0===e&&(e={}),{name:"shift",options:e,async fn(t){const{x:n,y:o,placement:i,platform:s}=t,{mainAxis:r=!0,crossAxis:a=!1,limiter:l={fn:e=>{let{x:t,y:n}=e;return{x:t,y:n}}},...c}=E(e,t),u={x:n,y:o},d=await s.detectOverflow(t,c),f=L(i),p=j(f);let m=u[p],h=u[f];const g=(e,t)=>{return n=t+d["y"===e?"top":"left"],o=t,i=t-d["y"===e?"bottom":"right"],_(n,v(o,i));var n,o,i};r&&(m=g(p,m)),a&&(h=g(f,h));const y=l.fn({...t,[p]:m,[f]:h});return{...y,data:{x:y.x-n,y:y.y-o,enabled:{[p]:r,[f]:a}}}}}},Pe=function(e){return void 0===e&&(e={}),{name:"flip",options:e,async fn(t){var n,o;const{placement:i,middlewareData:s,rects:r,initialPlacement:a,platform:l,elements:c}=t,{mainAxis:u=!0,crossAxis:d=!0,fallbackPlacements:f,fallbackStrategy:p="bestFit",fallbackAxisSideDirection:m="none",flipAlignment:h=!0,...g}=E(e,t);if(null!=(n=s.arrow)&&n.alignmentOffset)return{};const y=O(i),b=L(a),w=O(a)===a,v=await(null==l.isRTL?void 0:l.isRTL(c.floating)),_=f||(w||!h?[M(a)]:function(e){const t=M(e);return[z(e),t,z(t)]}(a)),x="none"!==m;!f&&x&&_.push(...I(a,h,m,v));const $=[a,..._],k=await l.detectOverflow(t,g),S=[];let j=(null==(o=s.flip)?void 0:o.overflows)||[];if(u&&S.push(k[y]),d){const e=function(e,t,n){void 0===n&&(n=!1);const o=T(e),i=P(e),s=A(i);let r="x"===i?o===(n?"end":"start")?"right":"left":"start"===o?"bottom":"top";return t.reference[s]>t.floating[s]&&(r=M(r)),[r,M(r)]}(i,r,v);S.push(k[e[0]],k[e[1]])}if(j=[...j,{placement:i,overflows:S}],!S.every(e=>e<=0)){var R,C;const e=((null==(R=s.flip)?void 0:R.index)||0)+1,t=$[e];if(t){if(!("alignment"===d&&b!==L(t))||j.every(e=>L(e.placement)!==b||e.overflows[0]>0))return{data:{index:e,overflows:j},reset:{placement:t}}}let n=null==(C=j.filter(e=>e.overflows[0]<=0).sort((e,t)=>e.overflows[1]-t.overflows[1])[0])?void 0:C.placement;if(!n)switch(p){case"bestFit":{var F;const e=null==(F=j.filter(e=>{if(x){const t=L(e.placement);return t===b||"y"===t}return!0}).map(e=>[e.placement,e.overflows.filter(e=>e>0).reduce((e,t)=>e+t,0)]).sort((e,t)=>e[1]-t[1])[0])?void 0:F[0];e&&(n=e);break}case"initialPlacement":n=a}if(i!==n)return{reset:{placement:n}}}return{}}}},ze=function(e){return void 0===e&&(e={}),{name:"size",options:e,async fn(t){const{placement:n,rects:o,platform:i,elements:s}=t,{apply:r=()=>{},...a}=E(e,t),l=await i.detectOverflow(t,a),c=O(n),u=T(n),d="y"===L(n),{width:f,height:p}=o.floating;let m,h;"top"===c||"bottom"===c?(m=c,h=u===(await(null==i.isRTL?void 0:i.isRTL(s.floating))?"start":"end")?"left":"right"):(h=c,m="end"===u?"top":"bottom");const g=p-l.top-l.bottom,y=f-l.left-l.right,b=v(p-l[m],g),w=v(f-l[h],y),x=t.middlewareData.shift,$=!x;let k=b,S=w;null!=x&&x.enabled.x&&(S=y),null!=x&&x.enabled.y&&(k=g),$&&!u&&(d?S=f-2*_(l.left,l.right):k=p-2*_(l.top,l.bottom)),await r({...t,availableWidth:S,availableHeight:k});const j=await i.getDimensions(s.floating);return f!==j.width||p!==j.height?{reset:{rects:!0}}:{}}}},Re=(e,t,n)=>{const o=new Map,i=null!=n?n:{},s={...Oe,...i.platform,_c:o};return(async(e,t,n)=>{const{placement:o="bottom",strategy:i="absolute",middleware:s=[],platform:r}=n,a=r.detectOverflow?r:{...r,detectOverflow:B},l=await(null==r.isRTL?void 0:r.isRTL(t));let c=await r.getElementRects({reference:e,floating:t,strategy:i}),{x:u,y:d}=D(c,o,l),f=o,p=0;const m={};for(let n=0;n<s.length;n++){const h=s[n];if(!h)continue;const{name:g,fn:y}=h,{x:b,y:w,data:v,reset:_}=await y({x:u,y:d,initialPlacement:o,placement:f,strategy:i,middlewareData:m,rects:c,platform:a,elements:{reference:e,floating:t}});u=null!=b?b:u,d=null!=w?w:d,m[g]={...m[g],...v},_&&p<50&&(p++,"object"==typeof _&&(_.placement&&(f=_.placement),_.rects&&(c=!0===_.rects?await r.getElementRects({reference:e,floating:t,strategy:i}):_.rects),({x:u,y:d}=D(c,f,l))),n=-1)}return{x:u,y:d,placement:f,strategy:i,middlewareData:m}})(e,t,{...i,platform:s})},Ce=["block-start","block-end","inline-start","inline-end"],Fe=["start","center","end"];function Ne(e="block-end",t="start",n=!1){if(!Ce.includes(e))throw new TypeError(`Unknown placement side: ${e}`);if(!Fe.includes(t))throw new TypeError(`Unknown placement alignment: ${t}`);const o="block-start"===e?"top":"block-end"===e?"bottom":"inline-start"===e?n?"right":"left":n?"left":"right";return"center"===t?o:`${o}-${t}`}function Ie(e,t=!1){const n=String(e).split("-")[0];return"top"===n?"block-start":"bottom"===n?"block-end":"left"===n?t?"inline-end":"inline-start":t?"inline-start":"inline-end"}function Me(e,t=document.body){if("number"==typeof e)return Number.isFinite(e)?e:0;if("string"!=typeof e||""===e.trim())return 0;const n=document.createElement("span");n.style.cssText="position:absolute;visibility:hidden;pointer-events:none;block-size:0;padding:0;border:0",n.style.inlineSize=e,(t?.isConnected?t:document.body).append(n);const o=parseFloat(getComputedStyle(n).width)||0;return n.remove(),o}const qe=Object.freeze({anchor:function(e,t,n={}){if(!(e instanceof Element&&t instanceof HTMLElement))throw new TypeError("Anchored positioning needs a reference element and a floating element");const o={side:"block-end",align:"start",offset:"var(--sf-space-1\\/4)",alignmentOffset:0,padding:"var(--sf-space-1\\/2)",flip:!0,shift:!0,matchWidth:!1,fitHeight:!0,autoUpdate:!0,onPosition:null,...n},i=["position","left","top","right","bottom","margin","max-height","max-width",...o.matchWidth?["width"]:[]].map(e=>[e,t.style.getPropertyValue(e),t.style.getPropertyPriority(e)]),s={maxHeight:t.style.getPropertyValue("max-height")},r=getComputedStyle(t),a=(e,t)=>{const n=parseFloat(e);return Number.isFinite(n)?String(e).trim().endsWith("%")?n/100*t:n:1/0},l=a(r.maxHeight,document.documentElement.clientHeight),c=a(r.maxWidth,document.documentElement.clientWidth),u={side:o.side,stopped:!1};let d=null,f=!1;const p=async()=>{const n="rtl"===getComputedStyle(e).direction;const i=Me(o.offset,e.parentElement),r=Me(o.padding,e.parentElement);o.fitHeight&&(t.style.maxHeight=s.maxHeight||"");const a=e.getBoundingClientRect(),d=document.documentElement.clientWidth,f={top:r,bottom:r,left:Math.min(r,Math.max(0,a.left)),right:Math.min(r,Math.max(0,d-a.right))},p=[Ae({mainAxis:i,alignmentAxis:Me(o.alignmentOffset,e.parentElement)})];o.flip&&p.push(Pe({padding:r,crossAxis:!1})),o.shift&&p.push(Le({padding:f,crossAxis:!1})),p.push(ze({padding:f,apply({availableWidth:e,availableHeight:t,rects:n,elements:i}){if(u.stopped)return;const s=d-f.left-f.right;o.matchWidth&&(i.floating.style.width=`${Math.max(0,Math.min(n.reference.width,s))}px`),i.floating.style.maxWidth=`${Math.max(0,Math.min(e,s,c))}px`,o.fitHeight&&(i.floating.style.maxHeight=`${Math.max(0,Math.min(t,l))}px`)}}));const m=await Re(e,t,{strategy:"fixed",placement:Ne(o.side,o.align,n),middleware:p});return u.stopped||(Object.assign(t.style,{position:"fixed",left:`${m.x}px`,top:`${m.y}px`,right:"auto",bottom:"auto",margin:"0"}),u.side=Ie(m.placement,n),t.dataset.sfSide=u.side,o.onPosition?.({side:u.side,placement:m.placement,x:m.x,y:m.y})),m};u.update=()=>u.stopped?Promise.resolve(null):d?(f=!0,d):(d=p().finally(()=>{d=null,f&&!u.stopped&&(f=!1,u.update())}),d);const m=o.autoUpdate?je(e,t,u.update):null;return u.stop=()=>{u.stopped=!0,m?.(),delete t.dataset.sfSide;for(const[e,n,o]of i)n?t.style.setProperty(e,n,o):t.style.removeProperty(e)},o.autoUpdate||u.update(),u},logicalSide:Ie,physicalPlacement:Ne,resolveLength:Me});"undefined"!=typeof globalThis&&(globalThis.SF=globalThis.SF||{},globalThis.SF.Position||(globalThis.SF.Position=qe));const De="sf-pref:",Be=/^[\w.*:-]+(?:\/[\w.*:/-]+)?$/u;function Ue(){try{return globalThis.localStorage??null}catch{return null}}function We(e){return"string"==typeof e&&e.length>0&&e.length<=200&&Be.test(e)}function He(e,t){try{return JSON.stringify(e)===JSON.stringify(t)}catch{return!1}}function Ve(e){return null==e?null:JSON.parse(JSON.stringify(e))}"undefined"!=typeof globalThis&&(globalThis.SF=globalThis.SF||{},globalThis.SF.Preferences||(globalThis.SF.Preferences=function(){const e={adapter:null,values:new Map},t=new Map,n=new Map;let o=!1;const i=()=>{if(o)return;const e=globalThis.document?.querySelector?.('script[type="application/json"][data-sf-preferences], script#sf-preferences[type="application/json"]');if(e){o=!0;try{u.preload(JSON.parse(e.textContent||"{}"))}catch{}}},s=(e,n)=>{for(const o of t.get(e)??[])try{o(Ve(n),e)}catch(t){console.error("SF.Preferences listener failed",e,t)}},r=e=>{const t=Ue();if(!t)return null;try{const n=t.getItem(De+e);return null===n?null:JSON.parse(n)}catch{return null}},a=(e,t)=>{const n=Ue();if(n)try{null===t?n.removeItem(De+e):n.setItem(De+e,JSON.stringify(t))}catch{}},l=t=>{clearTimeout(n.get(t)),n.delete(t);const o=e.adapter;if(!o)return;const i=e.values.has(t)?e.values.get(t):r(t);try{const e=null===i?o.remove?.(t):o.save?.(t,Ve(i));Promise.resolve(e).catch(e=>console.warn("SF.Preferences: the host did not keep",t,e))}catch(e){console.warn("SF.Preferences: the host did not keep",t,e)}},c=t=>{e.adapter&&(clearTimeout(n.get(t)),n.set(t,setTimeout(()=>l(t),400)))},u={read:t=>We(t)?(i(),e.values.has(t)?Ve(e.values.get(t)):Ve(r(t))):null,readMerged(...e){const t={};let n=!1;for(const o of e.flat()){const e=u.read(o);e&&"object"==typeof e&&!Array.isArray(e)&&(Object.assign(t,e),n=!0)}return n?t:null},write(t,n){if(!We(t))return!1;const o=Ve(n);return JSON.stringify(u.read(t))===JSON.stringify(o)||(e.values.has(t)&&e.values.set(t,o),a(t,o),c(t)),!0},remove:t=>!!We(t)&&(e.values.has(t)&&e.values.set(t,null),a(t,null),c(t),s(t,null),!0),subscribe:(e,n)=>We(e)&&"function"==typeof n?(t.has(e)||t.set(e,new Set),t.get(e).add(n),()=>t.get(e)?.delete(n)):()=>{},preload(t){if(t&&"object"==typeof t)for(const[n,o]of Object.entries(t)){if(!We(n))continue;const t=Ve(o),i=u.read(n);e.values.set(n,t),a(n,t),He(i,t)||s(n,t)}},useHost(t){if(!t||"function"!=typeof t.save)throw new TypeError("A preferences host saves: {save(key, value)}");return e.adapter=t,u},async load(t){const n=[].concat(t).filter(t=>We(t)&&!e.values.has(t));if(n.length&&"function"==typeof e.adapter?.load)try{u.preload(await e.adapter.load(n))}catch(e){console.warn("SF.Preferences: the host did not answer",n,e)}},get hosted(){return Boolean(e.adapter)},flush(){for(const e of[...n.keys()])l(e)}};return globalThis.addEventListener?.("storage",t=>{if(!t.key?.startsWith(De)||t.storageArea!==Ue())return;const n=t.key.slice(8);if(e.values.has(n))return;let o=null;try{o=null===t.newValue?null:JSON.parse(t.newValue)}catch{o=null}s(n,o)}),globalThis.addEventListener?.("pagehide",()=>u.flush()),i(),Object.freeze(u)}()));globalThis.SF;let Ze=null,Je=null,Ge=0;const Xe=new Map,Ye=e=>{try{return new URL(e,globalThis.location.href).href}catch{return null}};function Ke(e){const t=function(e){if(!Ze||e.defaultPrevented||0!==e.button)return null;if(e.metaKey||e.ctrlKey||e.shiftKey||e.altKey)return null;const t=e.composedPath().find(e=>e instanceof globalThis.Element&&e.matches("a[href]"));if(!t)return null;if(t.closest("[data-full-load]")||t.hasAttribute("download"))return null;const n=t.getAttribute("target");if(n&&"_self"!==n)return null;const o=new URL(t.href,globalThis.location.href),i=new URL(globalThis.location.href);return o.origin!==i.origin?null:o.pathname.startsWith(Ze.scope)?o.hash&&o.pathname===i.pathname&&o.search===i.search?null:o.href:null}(e);t&&(e.preventDefault(),nt(t))}function Qe(e){const t=e.state;Ze&&t?.sfRegion&&nt(globalThis.location.href,{history:"none",scroll:t.scroll??0})}function et(e,t){globalThis.document.dispatchEvent(new CustomEvent("sf-region-fallback",{detail:{url:e,reason:t}})),Ze?.onFullLoad?Ze.onFullLoad(e,t):e===globalThis.location.href?globalThis.location.reload():globalThis.location.assign(e)}function tt({href:e,kind:t,key:n}){const o=Ye(e);if(!o||!["css","javascript"].includes(t))return Promise.resolve();if(Xe.has(o))return Xe.get(o);if(function(e,t){const n=globalThis.document;return[..."css"===t?n.querySelectorAll('link[rel~="stylesheet"][href]'):n.querySelectorAll("script[src]")].some(n=>Ye(n.getAttribute("css"===t?"href":"src"))===e)}(o,t))return Xe.set(o,Promise.resolve()),Xe.get(o);const i=globalThis.document,s=i.createElement("css"===t?"link":"script");"css"===t?(s.rel="stylesheet",s.href=o):(s.src=o,s.async=!1),n&&s.setAttribute("data-sf-asset",n);const r=new Promise(e=>{s.addEventListener("load",()=>e(),{once:!0}),s.addEventListener("error",()=>e(),{once:!0})});return i.head.append(s),Xe.set(o,r),r}async function nt(e,{history:t="push",scroll:n=0}={}){if(!Ze)return globalThis.location.assign(e),!1;const o=Ze?"string"==typeof Ze.root?globalThis.document.querySelector(Ze.root):Ze.root:null,i=globalThis.document.querySelector(`meta[name="${Ze.revisionMeta}"]`)?.getAttribute("content")??null;if(!o||!i)return et(e,"no-region"),!1;if(!globalThis.document.dispatchEvent(new CustomEvent("sf-region-navigate",{cancelable:!0,detail:{url:e,region:Ze.region}})))return!1;Je?.abort(),Je=new AbortController;const s=++Ge,r=setTimeout(()=>{s===Ge&&(o.setAttribute("aria-busy","true"),o.setAttribute("data-sf-region-loading",""))},150),a=setTimeout(()=>Je?.abort(),15e3);let l;try{const t=await globalThis.fetch(e,{method:"GET",credentials:"same-origin",headers:{[Ze.header]:Ze.region,Accept:"application/json"},signal:Je.signal});if(t.redirected||200!==t.status||!/application\/json/u.test(t.headers.get("content-type")??""))throw new Error(`region answer ${t.status}${t.redirected?" redirected":""}`);if(l=await t.json(),!function(e,t){return e&&"object"==typeof e&&e.region===Ze.region&&"string"==typeof e.html&&"string"==typeof e.shell_revision&&e.shell_revision===t&&(void 0===e.assets||Array.isArray(e.assets))}(l,i))throw new Error(l?.shell_revision!==i?"shell-revision":"region-answer")}catch(t){return clearTimeout(r),clearTimeout(a),s!==Ge?!1:(o.removeAttribute("aria-busy"),o.removeAttribute("data-sf-region-loading"),"AbortError"===t?.name&&Je?.signal.aborted&&s===Ge?(et(e,"timeout"),!1):(et(e,String(t?.message??t)),!1))}if(clearTimeout(a),s!==Ge)return!1;const c="string"==typeof l.url&&Ye(l.url)?.startsWith(globalThis.location.origin)?Ye(l.url):e,u=function(e){const t=globalThis.document.createElement("template");t.innerHTML=String(e??"");const n=[];for(const e of t.content.querySelectorAll('link[rel~="stylesheet"][href]'))n.push({href:e.getAttribute("href"),kind:"css"}),e.remove();for(const e of t.content.querySelectorAll("script"))e.getAttribute("src")&&n.push({href:e.getAttribute("src"),kind:"javascript"}),e.remove();return{content:t.content,assets:n}}(l.html),d=[...l.assets??[],...u.assets];if(await Promise.all(d.filter(e=>"css"===e.kind).map(tt)),s!==Ge)return!1;"push"===t?(!function(){const e=globalThis.history.state??{};globalThis.history.replaceState({...e,sfRegion:!0,scroll:globalThis.scrollY},"")}(),globalThis.history.pushState({sfRegion:!0,scroll:0},"",c)):"replace"===t&&globalThis.history.replaceState({sfRegion:!0,scroll:0},"",c);const f=()=>{clearTimeout(r),o.replaceChildren(u.content),o.removeAttribute("aria-busy"),o.removeAttribute("data-sf-region-loading"),"string"==typeof l.title&&l.title&&(globalThis.document.title=l.title)},p="function"!=typeof globalThis.document.startViewTransition||globalThis.matchMedia?.("(prefers-reduced-motion: reduce)").matches?null:globalThis.document.startViewTransition(f);p?await p.updateCallbackDone.catch(()=>{}):f();for(const e of d.filter(e=>"javascript"===e.kind))await tt(e);globalThis.scrollTo(0,"none"===t?n:0);const m=o.querySelector("h1");return m&&(m.hasAttribute("tabindex")||m.setAttribute("tabindex","-1"),m.focus({preventScroll:!0})),globalThis.document.dispatchEvent(new CustomEvent("sf-region-load",{detail:{url:c,region:Ze.region,title:globalThis.document.title}})),!0}function ot(){Ze&&(globalThis.document.removeEventListener("click",Ke),globalThis.removeEventListener("popstate",Qe),Je?.abort(),Ze=null)}"undefined"!=typeof window&&(window.SF=window.SF||{},window.SF.RegionNavigation=Object.freeze({enable:function(e={}){const t={region:e.region??"content",root:e.root,header:e.header,revisionMeta:e.revisionMeta,scope:e.scope??"/",onFullLoad:"function"==typeof e.onFullLoad?e.onFullLoad:null};if(!t.root||!t.header||!t.revisionMeta)throw new TypeError("region navigation needs root, header and revisionMeta");Ze&&ot(),Ze=t,globalThis.document.addEventListener("click",Ke),globalThis.addEventListener("popstate",Qe),"scrollRestoration"in globalThis.history&&(globalThis.history.scrollRestoration="manual");const n=globalThis.history.state??{};return globalThis.history.replaceState({...n,sfRegion:!0,scroll:n.scroll??globalThis.scrollY},""),!0},disable:ot,navigate:nt,get enabled(){return Boolean(Ze)}}));var it=n("ac24888e7d3e");const st=Object.freeze((0,it.xZ)("simai.effect",1)),rt=new Set(["choice","integer","number","boolean","string","text","color","file"]),at=/^[a-z][a-z0-9-]{1,40}$/u,lt=/^[0-9]+\.[0-9]+\.[0-9]+$/u,ct=/^[a-zA-Z][a-zA-Z0-9]{0,40}$/u,ut=/^[a-z0-9][a-z0-9._-]*$/u,dt=/^#(?:[0-9a-f]{3}|[0-9a-f]{6}|[0-9a-f]{8})$/iu,ft=["dark","light"],pt=new Set(["windows"]),mt=/^https:\/\/[^\s?#]+\/effect\.json$/u,ht=e=>null!==e&&"object"==typeof e&&!Array.isArray(e),gt=e=>ht(e)&&Object.keys(e).length>0&&Object.entries(e).every(([e,t])=>/^[a-z]{2}(-[A-Z]{2})?$/u.test(e)&&"string"==typeof t&&t.length>0);function yt(e){if(!ht(e))return["manifest: not an object"];const t=[],n=["schema","schema_version","id","version","label","author","entry","styles","preview","surfaces","schemes","pair","capabilities","settings","needs"];for(const o of Object.keys(e))n.includes(o)||t.push(`${o}: undeclared`);(0,it.Wl)(e,"simai.effect",1)||t.push("schema: not simai.effect, schema_version 1"),"string"==typeof e.id&&at.test(e.id)||t.push("id"),"string"==typeof e.version&&lt.test(e.version)||t.push("version"),gt(e.label)||t.push("label"),"string"==typeof e.entry&&ut.test(e.entry)&&/\.m?js$/u.test(e.entry)||t.push("entry: one module file"),void 0===e.styles||Array.isArray(e.styles)&&e.styles.every(e=>"string"==typeof e&&ut.test(e)&&e.endsWith(".css"))||t.push("styles"),Array.isArray(e.surfaces)&&e.surfaces.length||t.push("surfaces");const o=e.schemes;if(void 0===o||Array.isArray(o)&&o.length&&!(o.length>2)&&o.every(e=>ft.includes(e))&&new Set(o).size===o.length||t.push("schemes: one or both of dark, light"),void 0!==e.pair&&("string"==typeof e.pair&&(at.test(e.pair)||mt.test(e.pair)&&e.pair.length<=2048)||t.push("pair: a catalogue id or the https URL of an effect.json"),Array.isArray(o)&&1===o.length||t.push("pair: only a single-scheme effect names a pair")),void 0===e.capabilities||Array.isArray(e.capabilities)&&e.capabilities.every(e=>pt.has(e))&&new Set(e.capabilities).size===e.capabilities.length||t.push("capabilities: known names, each once"),ht(e.needs)&&!1===e.needs.network&&1===Object.keys(e.needs).length||t.push("needs: {network: false}"),!Array.isArray(e.settings))return t.push("settings"),t;const i=new Set;return e.settings.forEach((e,n)=>{const o=`settings[${n}]`;if(ht(e)){if("string"==typeof e.key&&ct.test(e.key)?i.has(e.key)&&t.push(`${o}: key ${e.key} twice`):t.push(`${o}: key`),i.add(e.key),rt.has(e.type)||t.push(`${o}: type`),gt(e.label)||t.push(`${o}: label`),"default"in e||t.push(`${o}: default`),"choice"!==e.type||Array.isArray(e.options)&&e.options.length||t.push(`${o}: a choice names its options`),!["integer","number"].includes(e.type)||"number"==typeof e.min&&"number"==typeof e.max||t.push(`${o}: a number states min and max`),["string","text"].includes(e.type)&&"number"!=typeof e.max&&t.push(`${o}: a string states its max length`),"default"in e&&rt.has(e.type)){bt(e,e.default).ok||t.push(`${o}: default is not a valid value`)}}else t.push(`${o}: not an object`)}),t}function bt(e,t){const n={ok:!1,value:void 0};switch(e.type){case"boolean":return"boolean"==typeof t?{ok:!0,value:t}:"1"===t||"true"===t?{ok:!0,value:!0}:"0"===t||"false"===t?{ok:!0,value:!1}:n;case"integer":case"number":{const o="string"==typeof t&&""!==t.trim()?Number(t):t;return"number"==typeof o&&Number.isFinite(o)&&("integer"!==e.type||Number.isInteger(o))?o<e.min||o>e.max?n:{ok:!0,value:o}:n}case"choice":{const o=(e.options??[]).find(e=>String(e.value)===String(t));return o?{ok:!0,value:o.value}:n}case"string":case"text":return"string"!=typeof t||t.length>e.max||"string"===e.type&&/[\r\n]/u.test(t)?n:{ok:!0,value:t};case"color":return"string"==typeof t&&dt.test(t)?{ok:!0,value:t.toLowerCase()}:n;case"file":return null===t||""===t||"string"==typeof t&&t.length<=2048?{ok:!0,value:t||null}:n;default:return n}}function wt(e,t={}){const n={},o=[];for(const i of e.settings??[]){if(Object.hasOwn(t??{},i.key)){const e=bt(i,t[i.key]);if(e.ok){n[i.key]=e.value;continue}o.push(i.key)}n[i.key]=bt(i,i.default).value}return{settings:Object.freeze(n),invalid:o}}function vt(e){return Array.isArray(e?.schemes)&&e.schemes.length?[...e.schemes]:[...ft]}const _t=e=>"string"==typeof e?.pair&&mt.test(e.pair),xt=e=>Array.isArray(e?.capabilities)?e.capabilities:[],$t="data-sf-effect-state",kt="data-sf-effect-reason",St="[data-sf-effect-window]",Et=new WeakSet;function Ot(){return globalThis.SF_BOOT_CONFIG?.effects??{}}function Tt(e=Ot().foreign){return void 0===e||"sandbox"===e?"sandbox":"refuse"}const jt=String.raw`(() => {
2
2
  'use strict';
3
3
  const root = document.documentElement;
4
4
  const host = document.getElementById('host');