@uibot/application 0.12.0 → 0.14.0

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.
@@ -1,25 +1,25 @@
1
- function ee(e){return{...e,components:e.components,actions:e.actions??{},templates:e.templates??{}}}var te=["SetState","ResetState","Request","Link","Validate","DisplayMessage","Login","Logout","CallMethod"],H={SetState:{name:"SetState",description:"Set a page state path to an evaluated declarative value",params:{path:{type:"string"},value:{description:"Literal or supported PropValue expression"}},generation:{evaluatedParams:["value"],prerequisites:["Declare the state path on the same page"],example:{action:"SetState",params:{path:"open",value:{_not:{_state:"open"}}}}}},ResetState:{name:"ResetState",description:"Restore paths from the supplied initial map; missing values become null",params:{paths:{type:"array",items:{type:"string"}},initial:{type:"object"}},generation:{evaluatedParams:[],prerequisites:["Supply literal initial values; omitting paths resets keys in initial"],example:{action:"ResetState",params:{paths:["open"],initial:{open:!1}}}}},Request:{name:"Request",description:"Execute a configured connection request",params:{connectionId:{type:"string"},request:{type:"object"},loadingPath:{type:"string"},responsePath:{type:"string"},errorPath:{type:"string"}},generation:{evaluatedParams:["connectionId","request"],prerequisites:["Host must inject the declared connection driver and secrets; Studio local Spec preview does not"],example:{action:"Request",params:{connectionId:"projects",request:{id:"list",connectionId:"projects",payload:{operation:"FindAll",resource:"projects"}},responsePath:"rows"}}}},Link:{name:"Link",description:"Emit navigation to a literal URL or page path",params:{path:{type:"string"},url:{type:"string"},target:{enum:["_self","_blank"]}},generation:{evaluatedParams:[],prerequisites:["Host handles navigation; local page paths must exist"],example:{action:"Link",params:{path:"/details"}}}},Validate:{name:"Validate",description:"Emit form validation event; does not itself throw for invalid fields",params:{formId:{type:"string"},errorPath:{type:"string"}},generation:{evaluatedParams:[],prerequisites:["Requires host form:validate listener; prefer native required controls and Form.Submit"],example:{action:"Validate",params:{formId:"contact"}}}},DisplayMessage:{name:"DisplayMessage",description:"Emit an evaluated message for the host to display",params:{message:{description:"Literal or supported PropValue expression"},level:{enum:["info","success","warning","error"]},duration:{type:"number"}},generation:{evaluatedParams:["message"],prerequisites:["Requires host message:display listener"],example:{action:"DisplayMessage",params:{message:"Saved locally",level:"success"}}}},Login:{name:"Login",description:"Set a supplied local session user or request external login",params:{user:{type:"object"},provider:{type:"string"}},generation:{evaluatedParams:[],prerequisites:["Requires host session/auth; setting a local user is not server authentication"],example:{action:"Login",params:{provider:"configured-provider"}}}},Logout:{name:"Logout",description:"Clear the local session and emit auth:logout",params:{},generation:{evaluatedParams:[],prerequisites:["Host owns server session invalidation"],example:{action:"Logout",params:{}}}},CallMethod:{name:"CallMethod",description:"Emit a call to an existing block method",params:{blockId:{type:"string"},method:{type:"string"},args:{type:"array"}},generation:{evaluatedParams:["args"],prerequisites:["Requires an explicitly documented installed block method/listener; never invent a method"],example:{action:"CallMethod",params:{blockId:"documented-block",method:"documented-method",args:[]}}}}};var Fe={spec:["html","markdown","zip"],prototype:["html","zip"],deck:["html","pptx","zip"],poster:["html","zip"]},_r=Array.from(new Set(Object.values(Fe).flat()));var Or=Object.freeze([Object.freeze({name:"manifest",summary:"Describe query operations and list the derived resource index.",positionals:Object.freeze([]),options:Object.freeze([])}),Object.freeze({name:"search",summary:"Search resources with deterministic bilingual ranking and reasons.",positionals:Object.freeze([Object.freeze({name:"text",property:"text",type:"string",required:!1})]),options:Object.freeze([Object.freeze({name:"kind",property:"kinds",type:"resource-kind",multiple:!0,cliEncoding:"comma-separated"}),Object.freeze({name:"tag",property:"tags",type:"string",multiple:!0,cliEncoding:"comma-separated"}),Object.freeze({name:"category",property:"categories",type:"string",multiple:!0,cliEncoding:"comma-separated"}),Object.freeze({name:"capability",property:"capabilities",type:"string",multiple:!0,cliEncoding:"comma-separated"}),Object.freeze({name:"maturity",property:"maturities",type:"resource-maturity",multiple:!0,cliEncoding:"comma-separated"}),Object.freeze({name:"limit",property:"limit",type:"positive-integer"})])}),Object.freeze({name:"get",summary:"Resolve one canonical resource id or unambiguous alias.",positionals:Object.freeze([Object.freeze({name:"id-or-alias",property:"id",type:"string",required:!0})]),options:Object.freeze([])}),Object.freeze({name:"build",summary:"Plan dependency closure and gaps without writing or installing.",positionals:Object.freeze([Object.freeze({name:"root",property:"roots",type:"string",required:!0,variadic:!0})]),options:Object.freeze([])})]);var P=(e)=>e!==null&&typeof e==="object"&&!Array.isArray(e),S=(e,t)=>Object.keys(e).every((r)=>t.includes(r)),R=(e,t)=>typeof e==="string"&&e.length>0&&e.length<=t,re=(e)=>typeof e==="number"&&Number.isSafeInteger(e)&&e>0,M=(e)=>typeof e==="string"&&/^[A-Za-z0-9_]{1,64}$/.test(e),ne=(e,t=100)=>Array.isArray(e)&&e.length<=t&&e.every(M)&&new Set(e).size===e.length;function Me(e){if(!P(e)||!S(e,["id","name","type","required","options","link","lookup","formula","rollup"])||!M(e.id)||!R(e.name,200)||!["singleLineText","longText","number","checkbox","date","singleSelect","multipleSelect","linkedRecord","lookup","formula","rollup"].includes(String(e.type))||e.required!==void 0&&typeof e.required!=="boolean")return!1;if(e.options!==void 0&&(!Array.isArray(e.options)||e.options.length>100||e.options.some((t)=>!P(t)||!S(t,["id","name"])||!M(t.id)||!R(t.name,200))||new Set(e.options.map((t)=>t.id)).size!==e.options.length))return!1;if(e.options!==void 0&&!["singleSelect","multipleSelect"].includes(String(e.type)))return!1;for(let[t,r,n]of[["linkedRecord","link",["collectionId","displayFieldId"]],["lookup","lookup",["linkFieldId","targetFieldId"]],["formula","formula",["expression"]],["rollup","rollup",["linkFieldId","targetFieldId","function"]]]){let o=e[r];if(e.type===t!==(o!==void 0))return!1;if(o!==void 0&&(!P(o)||!S(o,[...n])||n.some((i)=>!R(o[i],i==="expression"?2048:512))))return!1}return!0}function oe(e){if(!P(e)||!S(e,["id","collectionId","descriptor","view","uibotCommit","authorId","createdAt","digest"])||!/^[a-f0-9]{64}$/.test(String(e.id))||!/^[a-f0-9]{64}$/.test(String(e.digest))||!/^[a-f0-9]{40}$/.test(String(e.uibotCommit))||!R(e.collectionId,512)||!R(e.authorId,512)||typeof e.createdAt!=="string"||!/^\d{4}-\d{2}-\d{2}T/.test(e.createdAt)||!Number.isFinite(Date.parse(e.createdAt)))return!1;try{if(new TextEncoder().encode(JSON.stringify(e)).length>131072)return!1}catch{return!1}let{descriptor:t,view:r}=e;if(!P(t)||!S(t,["id","name","schemaVersion","fields"])||t.id!==e.collectionId||!R(t.name,200)||!re(t.schemaVersion)||!Array.isArray(t.fields)||t.fields.length<1||t.fields.length>100||!t.fields.every(Me)||new Set(t.fields.map((i)=>i.id)).size!==t.fields.length)return!1;if(!P(r)||!S(r,["id","name","version","type","groupByFieldId","dateFieldId","search","filter","sort","columnOrder","hiddenColumns","columnWidths"])||!M(r.id)||!R(r.name,200)||!re(r.version)||!ne(r.columnOrder)||!ne(r.hiddenColumns)||!P(r.columnWidths)||Object.values(r.columnWidths).some((i)=>typeof i!=="number"||!Number.isInteger(i)||i<72||i>800))return!1;let n=t.fields,o=(i)=>n.some((s)=>P(s)&&s.id===i);if([...r.columnOrder,...r.hiddenColumns,...Object.keys(r.columnWidths)].some((i)=>!o(i)))return!1;if(r.type!==void 0&&!["grid","kanban","gallery","calendar","form"].includes(String(r.type)))return!1;if(r.type==="kanban"&&!t.fields.some((i)=>i.id===r.groupByFieldId&&["singleSelect","checkbox"].includes(i.type)))return!1;if(r.type==="calendar"&&!t.fields.some((i)=>i.id===r.dateFieldId&&i.type==="date"))return!1;if(r.search!==void 0&&(typeof r.search!=="string"||r.search.length>200))return!1;if(r.sort!==void 0&&(!Array.isArray(r.sort)||r.sort.length>4||r.sort.some((i)=>!P(i)||!S(i,["fieldId","direction"])||!o(i.fieldId)||!["asc","desc"].includes(String(i.direction)))))return!1;return!0}import{parse as oo}from"yaml";class b extends Error{code;details;constructor(e,t,r){super(t);this.name="CompileSpecError",this.code=e,this.details=r}}function Le(e,t){let r=Object.hasOwn(t,e)?t[e]:void 0;if(!r)throw new b("unknown-template",`unknown template "${e}"`,{template:e});let n=r.pages[0]?.blocks[0];if(!n||n.type!=="PageLayout")throw new b("invalid-shell-root",`template "${e}" root is not PageLayout`,{template:e});return n}function L(e,t,r,n){let o=e;if(e.template){if(r.has(e.template))throw new b("template-cycle",`template cycle at "${e.template}"`,{template:e.template});let i=Le(e.template,t),s=new Set(r);s.add(e.template);let a={...i.slots,...e.slots};if(n&&!e.slots?.sidebar)delete a.sidebar;let l=e.children??i.children,c=e.events??i.events,p=e.visible??i.visible;return o={...i,...e.id?{id:e.id}:{},props:{...i.props,...e.props},slots:a,...l?{children:l}:{},...c?{events:c}:{},...p!==void 0?{visible:p}:{}},L(o,t,s,n)}return{...o,...o.children?{children:o.children.map((i)=>L(i,t,r,n))}:{},...o.slots?{slots:Object.fromEntries(Object.entries(o.slots).map(([i,s])=>[i,s.map((a)=>L(a,t,r,n))]))}:{}}}function Be(e){let t=(r)=>{if(r.template)return!0;if(r.children?.some(t))return!0;return Object.values(r.slots??{}).some((n)=>n.some(t))};return e.pages.some((r)=>r.blocks.some(t))}function ie(e,t){return e.map((r)=>{if("children"in r&&Array.isArray(r.children))return{type:"MenuGroup",props:{title:r.label},children:ie(r.children,t)};let n=r,o={label:n.label,href:n.path};if(n.icon)o.icon=n.icon;if(n.path===t)o.active=!0;return{type:"MenuLink",props:o}})}function Ne(e){let t=e.menus?.items;if(!t?.length)return e;return{...e,pages:e.pages.map((r)=>({...r,blocks:r.blocks.map((n)=>{if(n.type!=="PageLayout")return n;if(n.slots?.sidebar?.length)return n;return{...n,slots:{...n.slots,sidebar:[{type:"PageSiderMenu",props:{title:r.title??n.props?.title??"Menu"},children:ie(t,r.path)}]}}})}))}}function W(e,t={}){let r=Boolean(e.menus?.items?.length),n=Be(e)?{...e,pages:e.pages.map((o)=>({...o,blocks:o.blocks.map((i)=>L(i,t,new Set,r))}))}:e;return Ne(n)}function je(e){let t=new Map,r=new Map,n=new Map,o=(i,s)=>{if(i.id!==void 0){if(n.has(i.id)){let a=n.get(i.id);throw new b("duplicate-block-id",`Block id "${i.id}" is declared more than once`,{blockId:i.id,firstPageId:a,pageId:s})}n.set(i.id,s)}for(let a of i.children??[])o(a,s);for(let a of Object.values(i.slots??{}))for(let l of a)o(l,s)};return e.pages.forEach((i,s)=>{let a=t.get(i.id);if(a!==void 0)throw new b("duplicate-page-id",`Page id "${i.id}" is declared more than once`,{pageId:i.id,firstIndex:a,pageIndex:s});if(t.set(i.id,s),r.has(i.path)){let l=r.get(i.path);throw new b("duplicate-page-path",`Page path "${i.path}" is declared more than once`,{path:i.path,firstPageId:l,pageId:i.id})}r.set(i.path,i.id);for(let l of i.blocks)o(l,i.id)}),new Set(n.keys())}function Ve(e,t,r){while(!0){let n=t.counter++,o=r?`${r}_${n}`:`${e}_${n}`;if(!t.reservedIds.has(o)&&!t.assignedIds.has(o))return o}}function z(e,t,r,n,o,i){let s=e.id??Ve(t,n,i??o);if(n.assignedIds.has(s))throw new b("duplicate-block-id",`Block id "${s}" is declared more than once`,{blockId:s,pageId:t});n.assignedIds.add(s);let a=(e.children??[]).map((p)=>z(p,t,r,n,s,s)),l={};for(let[p,u]of Object.entries(e.slots??{}))l[p]=u.map((d)=>z(d,t,r,n,s,`${s}_${p}`));let c={id:s,pageId:t,type:e.type,...o?{parentId:o}:{},...e.props?{props:e.props}:{},...a.length?{children:a}:{},...Object.keys(l).length?{slots:l}:{},...e.events?{events:e.events}:{},...e.visible!==void 0?{visible:e.visible}:{},...e.template?{template:e.template}:{},...e.variant?{variant:e.variant}:{}};return r[s]=c,s}function G(e,t={}){e=W(e,t);let n={counter:0,reservedIds:je(e),assignedIds:new Set},o=Object.create(null);return{version:"2.0",pages:e.pages.map((s)=>{let a=[];for(let l of s.blocks)a.push(z(l,s.id,o,n));return{id:s.id,path:s.path,...s.title?{title:s.title}:{},rootBlockIds:a,...s.state?{state:s.state}:{},...s.auth?{auth:s.auth}:{},...s.lifecycle?{lifecycle:s.lifecycle}:{},...s.computed?{computed:s.computed}:{},...s.urlState?{urlState:s.urlState}:{}}}),...e.design?{design:e.design}:{},...e.connections?{connections:e.connections.map((s)=>({...s}))}:{},blocks:o}}var T=[{id:"_state",generation:{syntax:"page-state path",positions:["props","computed","action-value","visible"],example:{_state:"open"},prerequisite:"Declare the path on the same page"},bucket:"client",description:"Reads a value from the page state store"},{id:"_bindState",generation:{syntax:"page-state path",positions:["binding"],example:{_bindState:"name"},prerequisite:"Only installed controls implementing two-way binding"},bucket:"client",description:"Two-way state binding (read + write)"},{id:"_payload",generation:{syntax:"payload field",positions:["request-context"],example:{_payload:"name"},prerequisite:"Caller must supply request payload; ordinary preview props have no payload"},bucket:"client",description:"Request payload field"},{id:"_event",generation:{syntax:"event field",positions:["action-value"],example:{_event:"value"},prerequisite:"Only within an event action; permitted fields: type,name,value,checked,values"},bucket:"client",description:"Event payload field (e.g. form submit value)"},{id:"_global",generation:{syntax:"host-global field",positions:["host-context"],example:{_global:"configuredValue"},prerequisite:"Host-dependent and excluded from ordinary creation; no secrets"},bucket:"client",description:"Global (window) property access"},{id:"_if",generation:{syntax:"[condition, then, else]",positions:["props","computed","action-value"],example:{_if:[{_state:"open"},"Open","Closed"]}},bucket:"client",description:"Conditional ternary: [condition, then, else]"},{id:"_eq",generation:{syntax:"[a, b]",positions:["props","computed","action-value","visible","predicate"],example:{_eq:[{_state:"status"},"Active"]}},bucket:"client",description:"Equality: [a, b] → a === b"},{id:"_ne",generation:{syntax:"[a, b]",positions:["props","computed","action-value","visible","predicate"],example:{_ne:[{_state:"status"},"Active"]}},bucket:"client",description:"Inequality: [a, b] → a !== b"},{id:"_contains",generation:{syntax:"[haystack, needle]",positions:["props","computed","action-value","visible","predicate"],example:{_contains:[{_state:"name"},"orion"]}},bucket:"client",description:"Case-insensitive substring match: [haystack, needle] → haystack contains needle (empty needle → true)"},{id:"_gt",generation:{syntax:"[finite-number, finite-number]",positions:["props","computed","action-value","visible","predicate"],example:{_gt:[{_state:"count"},0]}},bucket:"client",description:"Greater-than for finite numbers: [a, b] → a > b. Non-numbers are false"},{id:"_lt",generation:{syntax:"[finite-number, finite-number]",positions:["props","computed","action-value","visible","predicate"],example:{_lt:[{_state:"count"},10]}},bucket:"client",description:"Less-than for finite numbers: [a, b] → a < b. Non-numbers are false"},{id:"_gte",generation:{syntax:"[finite-number, finite-number]",positions:["props","computed","action-value","visible","predicate"],example:{_gte:[{_state:"count"},0]}},bucket:"client",description:"Greater-or-equal for finite numbers: [a, b] → a >= b. Non-numbers are false"},{id:"_lte",generation:{syntax:"[finite-number, finite-number]",positions:["props","computed","action-value","visible","predicate"],example:{_lte:[{_state:"count"},10]}},bucket:"client",description:"Less-or-equal for finite numbers: [a, b] → a <= b. Non-numbers are false"},{id:"_in",generation:{syntax:"[value, array]",positions:["props","computed","action-value","visible","predicate"],example:{_in:[{_state:"status"},["Active","Draft"]]}},bucket:"client",description:"Membership: [value, array] → array includes value"},{id:"_not",generation:{syntax:"condition",positions:["props","computed","action-value","visible","predicate"],example:{_not:{_state:"open"}}},bucket:"client",description:"Logical NOT"},{id:"_and",generation:{syntax:"[condition, ...]",positions:["props","computed","action-value","visible","predicate"],example:{_and:[{_state:"ready"},{_state:"open"}]}},bucket:"client",description:"Logical AND over a list of conditions"},{id:"_or",generation:{syntax:"[condition, ...]",positions:["props","computed","action-value","visible","predicate"],example:{_or:[{_state:"ready"},{_state:"open"}]}},bucket:"client",description:"Logical OR over a list of conditions"},{id:"_user",generation:{syntax:"session user field",positions:["props","computed","action-value"],example:{_user:"name"},prerequisite:"Requires injected host session; no server ACL guarantee"},bucket:"client",description:"Current session user field (client-visible)"},{id:"_item",generation:{syntax:"item field or empty string",positions:["predicate","loop-props"],example:{_item:"name"},prerequisite:"Only inside a declared loop or filter/find predicate"},bucket:"client",description:"Current list item in a loop scope"},{id:"_index",generation:{syntax:"ignored scalar marker",positions:["predicate","loop-props"],example:{_index:0},prerequisite:"Only inside a declared loop or filter/find predicate"},bucket:"client",description:"Current list index in a loop scope"},{id:"_array.length",generation:{syntax:"array expression",positions:["props","computed","action-value"],example:{"_array.length":{_state:"rows"}}},bucket:"client",description:"Array length"},{id:"_string.concat",generation:{syntax:"[value, ...]",positions:["props","computed","action-value"],example:{"_string.concat":["Hello ",{_state:"name"}]}},bucket:"client",description:"String concatenation over a list"},{id:"_number.add",generation:{syntax:"[left, right] (finite numbers)",positions:["action-value"],example:{"_number.add":[{_state:"count"},1]},prerequisite:"Both operands must evaluate to finite numbers or the action fails and writes nothing; use it in SetState value for counters (e.g. SetState count = count + 1), never for strings or arrays"},bucket:"client",description:"Finite number addition: [left, right] → left + right. Throws on non-number, non-finite or overflowing operands (no coercion, no fallback to 0)"},{id:"_computed",generation:{syntax:"computed name",positions:["props","computed","action-value","visible"],example:{_computed:"filtered"},prerequisite:"Declare page computed expression"},bucket:"client",description:"Reads a derived (computed) state value by name from the __computed namespace"},{id:"_filter",generation:{syntax:"[array, predicate]",positions:["props","computed","action-value"],example:{_filter:[{_state:"rows"},{_eq:[{_item:"status"},"Active"]}]}},bucket:"client",description:"Filters an array: [arrayExpr, predExpr] with { _item, _index } scope"},{id:"_find",generation:{syntax:"[array, predicate]",positions:["props","computed","action-value"],example:{_find:[{_state:"rows"},{_eq:[{_item:"name"},"Orion"]}]}},bucket:"client",description:"Finds the first matching element: [arrayExpr, predExpr] with { _item, _index } scope"},{id:"_len",generation:{syntax:"array/string/object expression",positions:["props","computed","action-value"],example:{_len:{_state:"rows"}}},bucket:"client",description:"Length of an array, string, or object (0 if empty)"},{id:"_concat",generation:{syntax:"[value, ...]",positions:["props","computed","action-value"],example:{_concat:[[1],[2]]},prerequisite:"Concatenation is not numeric addition"},bucket:"client",description:"Concatenates a list: arrays are joined, otherwise values are string-concatenated"},{id:"_count",generation:{syntax:"array or [array, predicate?]",positions:["props","computed","action-value"],example:{_count:[{_state:"rows"}]}},bucket:"client",description:"Count of an array, or of elements matching a predicate: [array, predicate?]"},{id:"_groupCount",generation:{syntax:"[array, field]",positions:["props","computed","action-value"],example:{_groupCount:[{_state:"rows"},"status"]}},bucket:"client",description:"Counts array items by a field in one pass: [array, field] → { value: count }"},{id:"_sort",generation:{syntax:"[array, {by, order?, rank?}]",positions:["props","computed","action-value"],example:{_sort:[{_state:"rows"},{by:"name",order:"asc"}]}},bucket:"client",description:"Stable sort: [array, { by, order?: asc|desc, rank?: { field: values[] } }]. rank is enum order"},{id:"_js",generation:{syntax:"disabled",positions:[],example:{_js:"disabled"},prerequisite:"Arbitrary code execution is disabled; permissions do not enable it",disabled:!0},bucket:"client",description:"Legacy JS expression; execution is always disabled"}],B=new Set(T.map((e)=>e.id));var se=new Set(te),$e=new Map(T.map((e)=>[e.id,e])),ce=new Set(["array","boolean","integer","null","number","object","string"]),pe=new Set(["default","description","enum","items","properties","required","type"]);function ae(e){if(!e)return[];return Object.keys(e)}function Ue(e){if(!e||e.type!=="array")return;let t=e.items;if(!t||typeof t!=="object"||t.type!=="object"||!t.properties)return;return new Set(Object.keys(t.properties))}function Y(e,t,r){if(!e||typeof e!=="object")return;if(Array.isArray(e)){for(let[n,o]of e.entries())Y(o,`${t}[${n}]`,r);return}for(let[n,o]of Object.entries(e)){let i=t?`${t}.${n}`:n;r(n,o,i),Y(o,i,r)}}function N(e,t,r,n,o,i,s,a){Y(n,o,(l,c,p)=>{if((l==="_state"||l==="_bindState")&&typeof c==="string"){let u=c.split("."),d=u[0]??"";if(d==="__computed"){let g=u[1]??"";if(!s.has(g))e.push({code:"refs:computed-declared",message:`${t}: _computed "${g}" is not declared`,elementKey:r,path:p});return}if(!i.has(d))e.push({code:"refs:state-declared",message:`${t}: _state "${d}" is not declared in state`,elementKey:r,path:p})}if(l==="_computed"&&typeof c==="string"&&!s.has(c))e.push({code:"refs:computed-declared",message:`${t}: _computed "${c}" is not declared`,elementKey:r,path:p});if(l==="_item"&&typeof c==="string"&&c!==""&&a&&!a.has(c))e.push({code:"item:field-exists",message:`${t}: _item "${c}" is not in the item schema`,elementKey:r,path:p})})}function h(e){return e!==null&&typeof e==="object"&&!Array.isArray(e)}function D(e){return h(e)&&Object.keys(e).some((t)=>t.startsWith("_"))}var le=new Set(["_eq","_ne","_contains","_gt","_lt","_gte","_lte","_in","_not","_and","_or"]);function qe(e,t){if(new Set(["_eq","_ne","_contains","_gt","_lt","_gte","_lte","_in","_filter","_find","_groupCount","_sort","_number.add"]).has(e)){if(!Array.isArray(t)||t.length!==2)return!1;if(e==="_groupCount")return typeof t[1]==="string";if(e==="_sort"){let n=t[1];if(!h(n))return!1;if(!(typeof n.by==="string"&&n.by.length>0||Array.isArray(n.by)&&n.by.length>0&&n.by.every((i)=>typeof i==="string"&&i.length>0)))return!1;if(n.order!==void 0&&n.order!=="asc"&&n.order!=="desc")return!1;if(n.rank!==void 0&&(!h(n.rank)||Object.values(n.rank).some((i)=>!Array.isArray(i))))return!1;return Object.keys(n).every((i)=>["by","order","rank"].includes(i))}return!0}if(e==="_if")return Array.isArray(t)&&t.length===3;if(e==="_and"||e==="_or")return Array.isArray(t)&&t.length>0;if(e==="_string.concat"||e==="_concat")return Array.isArray(t)&&t.length>0;if(e==="_count")return!Array.isArray(t)||t.length===1||t.length===2;if(e==="_index")return typeof t==="number"&&Number.isFinite(t);if(["_state","_bindState","_computed","_event","_global","_payload","_user"].includes(e))return typeof t==="string"&&t.length>0;if(e==="_item")return typeof t==="string";return!0}function de(e){return e.enum===void 0||Array.isArray(e.enum)&&e.enum.length>0&&e.enum.every((t)=>t===null||typeof t==="string"||typeof t==="boolean"||typeof t==="number"&&Number.isFinite(t))}function I(e,t,r,n,o,i){if(r==="predicate"&&(!D(e)||!le.has(Object.keys(e)[0]??"")))return n.push({code:"props:expression",message:`${o}: predicate must be a supported expression node`,elementKey:i,path:t}),!1;if(e===void 0)return n.push({code:"props:expression",message:`${o}: value is not part of the supported serialized expression syntax`,elementKey:i,path:t}),!1;if(Array.isArray(e))return e.reduce((d,g,m)=>I(g,`${t}[${m}]`,r,n,o,i)&&d,!0);if(!h(e)){if(typeof e==="number"&&!Number.isFinite(e)||e!==null&&!["string","number","boolean"].includes(typeof e))return n.push({code:"props:expression",message:`${o}: value is not part of the supported serialized expression syntax`,elementKey:i,path:t}),!1;return e===null||["string","number","boolean"].includes(typeof e)}let s=Object.keys(e).filter((d)=>d.startsWith("_"));if(s.length===0)return Object.entries(e).reduce((d,[g,m])=>I(m,`${t}.${g}`,r,n,o,i)&&d,!0);let a=s[0]??"",l=$e.get(a),c=`${t}.${a}`;if(s.length!==1||Object.keys(e).length!==1||!l)return n.push({code:"props:expression",message:`${o}: expression shape is not supported`,elementKey:i,path:c}),!1;if(l.generation?.disabled||!l.generation?.positions.includes(r)&&!(r==="props"&&l.generation?.positions.includes("binding"))&&!(r==="predicate-value"&&l.generation?.positions.some((d)=>["props","computed","predicate"].includes(d))))return n.push({code:"props:expression",message:`${o}: expression is not supported in this value position`,elementKey:i,path:c}),!1;let p=e[a];if(!qe(a,p))return n.push({code:"props:expression",message:`${o}: expression operand shape is not supported`,elementKey:i,path:c}),!1;let u=(d)=>D(d)||Array.isArray(d);if(["_filter","_find","_groupCount","_sort"].includes(a)&&!u(Array.isArray(p)?p[0]:void 0)||a==="_in"&&!u(Array.isArray(p)?p[1]:void 0))return n.push({code:"props:expression",message:`${o}: expression array operand has an unsupported literal shape`,elementKey:i,path:c}),!1;if(a==="_count"&&(Array.isArray(p)?!u(p[0]):!u(p))||a==="_array.length"&&!u(p))return n.push({code:"props:expression",message:`${o}: expression array operand has an unsupported literal shape`,elementKey:i,path:c}),!1;if(["_gt","_lt","_gte","_lte"].includes(a)&&Array.isArray(p)){if(p.some((g)=>!D(g)&&(typeof g!=="number"||!Number.isFinite(g))))return n.push({code:"props:expression",message:`${o}: numeric comparison literals must be finite numbers`,elementKey:i,path:c}),!1}if(Array.isArray(p))return p.reduce((d,g,m)=>{let y=r;if((["_filter","_find"].includes(a)||a==="_count")&&m===1)y="predicate";else if(r==="predicate"||r==="predicate-value"){if(y=le.has(a)?"predicate-value":r,r==="predicate"&&["_and","_or"].includes(a))y="predicate"}return I(g,`${c}[${m}]`,y,n,o,i)&&d},!0);if(h(p))return I(p,c,r==="predicate"&&a==="_not"?"predicate-value":r,n,o,i);return!0}function K(e,t,r,n,o,i,s){let a=(u)=>s==="props"?`props:${u}`:`actions:params-${u}`;if(Object.keys(t).filter((u)=>!pe.has(u)).length>0){n.push({code:"schema:unsupported",message:`${o}: schema contains unsupported constraints`,elementKey:i,path:r});return}if(t.type!==void 0&&!ce.has(t.type)){n.push({code:"schema:unsupported",message:`${o}: schema type is not supported`,elementKey:i,path:r});return}if(!de(t)){n.push({code:"schema:unsupported",message:`${o}: schema enum is not supported`,elementKey:i,path:r});return}if(t.required!==void 0&&(!Array.isArray(t.required)||t.required.some((u)=>typeof u!=="string"))){n.push({code:"schema:unsupported",message:`${o}: schema required list is not supported`,elementKey:i,path:r});return}if(t.items!==void 0&&(t.type!=="array"||!h(t.items))){n.push({code:"schema:unsupported",message:`${o}: schema items must describe an array`,elementKey:i,path:r});return}if(t.properties!==void 0&&(t.type!=="object"||!h(t.properties))){n.push({code:"schema:unsupported",message:`${o}: schema properties must describe an object`,elementKey:i,path:r});return}if(t.required?.length&&t.type!=="object"){n.push({code:"schema:unsupported",message:`${o}: schema required list is only supported for objects`,elementKey:i,path:r});return}if(D(e))return;let c=t.type;if(!(c===void 0||c==="null"&&e===null||c==="string"&&typeof e==="string"||c==="boolean"&&typeof e==="boolean"||c==="number"&&typeof e==="number"&&Number.isFinite(e)||c==="integer"&&typeof e==="number"&&Number.isInteger(e)||c==="array"&&Array.isArray(e)||c==="object"&&h(e))){n.push({code:a("type"),message:`${o}: value does not match the declared type`,elementKey:i,path:r});return}if(t.enum&&!t.enum.some((u)=>Object.is(u,e)))n.push({code:a("enum"),message:`${o}: value is outside the declared enum`,elementKey:i,path:r});if(c==="object"&&h(e)){for(let u of t.required??[])if(!Object.hasOwn(e,u))n.push({code:a("required"),message:`${o}: required object field is missing`,elementKey:i,path:`${r}.${u}`});for(let[u,d]of Object.entries(t.properties??{}))if(Object.hasOwn(e,u))K(e[u],d,`${r}.${u}`,n,o,i,s)}if(c==="array"&&Array.isArray(e)&&t.items)e.forEach((u,d)=>{K(u,t.items,`${r}[${d}]`,n,o,i,s)})}function ue(e,t,r,n,o,i,s){if(!r)return;for(let[a,l]of Object.entries(r)){let c=`${n}.${a}`;if(J(l,c,e,o,i)&&t&&Object.hasOwn(t,a))K(t[a],l,c,e,o,i,s)}}function ge(e,t,r,n,o,i,s={}){for(let[a,l]of Object.entries(t??{})){let c=n==="action-value"&&!s.evaluatedParams?.has(a)?"action-literal":n;I(l,`${r}.${a}`,c,e,o,i)}}function J(e,t,r,n,o){if(Object.keys(e).some((s)=>!pe.has(s))||e.type!==void 0&&!ce.has(e.type)||!de(e)||e.required!==void 0&&(!Array.isArray(e.required)||e.required.some((s)=>typeof s!=="string"))||e.items!==void 0&&(e.type!=="array"||!h(e.items))||e.properties!==void 0&&(e.type!=="object"||!h(e.properties))||Boolean(e.required?.length)&&e.type!=="object")return r.push({code:"schema:unsupported",message:`${n}: schema contains unsupported constraints`,elementKey:o,path:t}),!1;for(let[s,a]of Object.entries(e.properties??{}))if(!J(a,`${t}.${s}`,r,n,o))return!1;if(e.items&&!J(e.items,`${t}[]`,r,n,o))return!1;return!0}function j(e,t,r,n,o,i,s){if(!Array.isArray(n)){if(s)e.push({code:"actions:chain",message:`${t}: action chain must be an array`,elementKey:r,path:o});return}for(let[a,l]of n.entries()){if(!h(l)){if(s)e.push({code:"actions:chain",message:`${t}: action step must be an object`,elementKey:r,path:`${o}[${a}]`});continue}let c=l.action,p=`${o}[${a}]`;if(s&&(typeof c!=="string"||c.length===0))e.push({code:"actions:chain",message:`${t}: action step needs an action name`,elementKey:r,path:`${p}.action`});if(typeof c==="string"&&!se.has(c)&&!Object.hasOwn(i.actions??{},c))e.push({code:"actions:registered",message:`${t}: action "${c}" is not in the catalog. Registered actions: ${[...se,...Object.keys(i.actions??{})].join(", ")}. No equivalent is guaranteed: preserve the requirement and report unsupported behavior instead of disabling it.`,elementKey:r,path:`${p}.action`});if(s&&typeof c==="string"){let u=Object.hasOwn(i.actions??{},c)?i.actions[c]:Object.hasOwn(H,c)?H[c]:void 0,d=l.params;if(d!==void 0&&!h(d))e.push({code:"actions:chain",message:`${t}: action params must be an object`,elementKey:r,path:`${p}.params`});else{if(h(d))ge(e,d,`${p}.params`,"action-value",t,r,{evaluatedParams:new Set(u?.generation?.evaluatedParams??[])});if(u)ue(e,h(d)?d:void 0,u.params,`${p}.params`,t,r,"actions:params")}}if(Object.hasOwn(l,"onSuccess"))j(e,t,r,l.onSuccess,`${p}.onSuccess`,i,s);if(Object.hasOwn(l,"onError"))j(e,t,r,l.onError,`${p}.onError`,i,s)}}function me(e,t,r=!1){let n=[],o=new Set([...ae(e.state),...e.connectionIds??[]]),i=new Set(ae(e.computed)),s=e.pageId??e.root;if(e.computed)for(let[a,l]of Object.entries(e.computed)){if(r)I(l,`computed.${a}`,"computed",n,`${s}.computed`,s);N(n,`${s}.computed`,s,l,`computed.${a}`,o,i,He(e,t))}if(e.urlState)for(let[a,l]of Object.entries(e.urlState)){if(!o.has(a))n.push({code:"refs:url-state-declared",message:`${s}: urlState "${a}" is not declared in state`,elementKey:s,path:`urlState.${a}`});if(!l||typeof l.param!=="string"||l.param.length===0)n.push({code:"refs:url-state-declared",message:`${s}: urlState "${a}" needs a param name`,elementKey:s,path:`urlState.${a}.param`})}for(let[a,l]of Object.entries(e.elements)){let c=Object.hasOwn(t.components,l.type)?t.components[l.type]:void 0;if(!c)continue;let p=`${s}/${a}`,u=fe(c.props);if(r)ge(n,l.props,"props","props",p,a);if(l.visible!==null&&typeof l.visible==="object"){let d=Object.keys(l.visible);if(Array.isArray(l.visible)||d.length!==1||!d[0]?.startsWith("_"))n.push({code:"visibility:expression",message:`${p}: visible must be a boolean or an operator expression, not a literal record`,elementKey:a,path:"visible"})}if(r&&l.visible!==void 0)if(typeof l.visible!=="boolean"&&!D(l.visible))n.push({code:"visibility:expression",message:`${p}: visible must be a boolean or an operator expression`,elementKey:a,path:"visible"});else I(l.visible,"visible","visible",n,p,a);if(N(n,p,a,l.props,"props",o,i,u),N(n,p,a,l.visible,"visible",o,i,u),N(n,p,a,l.events,"events",o,i,u),c.props){let d=new Set(Object.keys(c.props));for(let g of Object.keys(l.props??{}))if(!d.has(g))n.push({code:"props:declared",message:`${p}: prop "${g}" is not declared on ${l.type}`,elementKey:a,path:`props.${g}`});if(r)ue(n,l.props,c.props,"props",p,a,"props")}if(c.events){let d=new Set(Object.keys(c.events));for(let[g,m]of Object.entries(l.events??{})){if(!d.has(g))n.push({code:"events:declared",message:`${p}: event "${g}" is not declared on ${l.type}`,elementKey:a,path:`events.${g}`});j(n,p,a,m,`events.${g}`,t,r)}}else for(let[d,g]of Object.entries(l.events??{}))j(n,p,a,g,`events.${d}`,t,r)}return n.map((a)=>({...a,path:a.elementKey===s?`${s}/${a.path}`:`${s}/${a.elementKey}/${a.path}`}))}function fe(e){let t=new Set;for(let r of Object.values(e??{})){let n=Ue(r);if(!n)continue;for(let o of n)t.add(o)}return t.size>0?t:void 0}function He(e,t){let r=new Set;for(let n of Object.values(e.elements)){let o=Object.hasOwn(t.components,n.type)?t.components[n.type]:void 0,i=fe(o?.props);if(!i)continue;for(let s of i)r.add(s)}return r.size>0?r:void 0}function ye(e){return e.map((t)=>({code:t.code,message:t.message,elementKey:t.elementKey,path:t.path}))}var Ce=[{id:"_request",bucket:"server",description:"Executes a connection request server-side and injects the result"},{id:"_secret",bucket:"server",description:"Reads a server-side secret value; never transmitted to the client"}],V=new Set(Ce.map((e)=>e.id));function X(e){return{...e,...e.props?{props:{...e.props}}:{},...e.children?{children:[...e.children]}:{},...e.slots?{slots:{...e.slots}}:{},...e.events?{events:{...e.events}}:{}}}function he(e){return{...e,...e.roots?{roots:[...e.roots]}:{},...e.state?{state:{...e.state}}:{},elements:Object.fromEntries(Object.entries(e.elements).map(([t,r])=>[t,X(r)]))}}function ze(e){return e.type==="compiler:operator"}function Ge(e){return e.type==="compiler:validator"}class O{operators;validators;constructor(e={}){let t=(e.capabilities??[]).filter(ze).map((n)=>n.contribution),r=(e.capabilities??[]).filter(Ge).map((n)=>n.contribution);this.operators=[...e.operators??[],...t],this.validators=[...e.validators??[],...r]}merge(e){if(e instanceof O)return new O({operators:[...this.operators,...e.operators],validators:[...this.validators,...e.validators]});return new O({operators:[...this.operators,...e.operators??[]],validators:[...this.validators,...e.validators??[]],...e.capabilities?{capabilities:e.capabilities}:{}})}}function Ye(e={}){return new O(e)}function Ke(e,t,r){let n=e.pages.find((s)=>s.id===t),o=[...n?.rootBlockIds??[]],i=Object.fromEntries(Object.entries(e.blocks).filter(([,s])=>s.pageId===t).map(([s,a])=>{let{id:l,pageId:c,parentId:p,...u}=a;return[s,X(u)]}));if(r&&o.length===0){let s=e.blocks.__empty__?`__empty__:${t}`:"__empty__";o.push(s),i[s]={type:"Empty"}}return{version:e.version,root:o[0]??"__empty__",roots:o,pageId:t,...n?.state?{state:n.state}:{},...n?.computed?{computed:n.computed}:{},...n?.urlState?{urlState:n.urlState}:{},...e.connections?{connectionIds:e.connections.map((s)=>s.id)}:{},elements:i}}function Je(e,t){let r=[...t.roots??e.roots??[]];if(r.length>0&&t.root!==e.root)r[0]=t.root;else if(r.length===0&&t.elements[t.root])r.push(t.root);return r}async function Xe(e,t,r,n){let o=he(e);for(let i of r.operators){let s={spec:o,catalog:t,warnings:n,getElement(l){return o.elements[l]},updateElement(l,c){o={...o,elements:{...o.elements,[l]:X(c)}}},addWarning(l){n.push(l)}},a=await i.apply(s);if(a)o=he(a)}return o}function be(e,t){return Object.hasOwn(e,t)?e[t]:void 0}function Ze(e,t,r,n,o){let i=Object.entries(e.elements);for(let a of e.roots?.length?e.roots:[e.root])if(!e.elements[a])r.push({code:"missing-root",message:`Root element "${a}" is missing from the elements map`,elementKey:a});for(let[a,l]of i){if(!(be(t.components,l.type)??be(t.templates,l.type)))n.push({missingType:l.type,elementKey:a,reason:l.template?"missing-template":"missing-component",context:`Element ${a} references ${l.type}`,path:`blocks.${a}.type`});for(let p of l.children??[])if(!e.elements[p])r.push({code:"dangling-child",message:`Element "${a}" references missing child "${p}"`,elementKey:a})}let s=me(e,t,o);if(o){for(let a of s)n.push({missingType:a.code,elementKey:a.elementKey,reason:"invalid-spec",context:a.message,code:a.code,path:a.path});return}r.push(...ye(s))}async function Qe(e,t,r,n,o){for(let i of r.validators){let s={spec:e,catalog:t,warnings:n,gaps:o,addWarning(a){n.push(a)},addGap(a){o.push(a)}};await i.validate(s)}}function A(e,t){if(!e||typeof e!=="object")return;if(Array.isArray(e)){for(let r of e)A(r,t);return}for(let[r,n]of Object.entries(e)){if(r.startsWith("_"))t.add(r);A(n,t)}}function et(e){let t=new Map;for(let[n,o]of Object.entries(e.blocks)){let i=new Set;A(o.props,i),A(o.visible,i);for(let s of i){let a=t.get(s)??new Set;a.add(n),t.set(s,a)}}for(let n of e.pages){let o=new Set;A(n.computed,o),A(n.lifecycle,o);for(let i of o){let s=t.get(i)??new Set;s.add(n.id),t.set(i,s)}}let r=[];for(let[n,o]of t){let i=B.has(n)?"client":V.has(n)?"server":n==="_ref"?"build":"shared";r.push({operatorId:n,bucket:i,blockIds:[...o]})}return r}async function xe(e,t,r={}){let n=[],o=[],i=r.registry??Ye(),s=G(e,r.templates),a=Object.create(null),l=[];for(let[u,d]of s.pages.entries()){let g=Ke(s,d.id,u===0),m=await Xe(g,t,i,n);Ze(m,t,n,o,r.strict===!0),await Qe(m,t,i,n,o);for(let[y,_]of Object.entries(m.elements)){let Q=a[y];if(Q)throw new b("duplicate-block-id",`Compiler output block id "${y}" conflicts across pages`,{blockId:y,firstPageId:Q.pageId,pageId:d.id});let q=s.blocks[y];a[y]={..._,id:y,pageId:d.id,...q?.pageId===d.id&&q.parentId?{parentId:q.parentId}:{}}}l.push({...d,rootBlockIds:Je(g,m)})}let c={version:"2.0",pages:l,...s.design?{design:s.design}:{},...s.connections?{connections:s.connections.map((u)=>({...u}))}:{},blocks:a};if(r.strict===!0&&e.version!=="2.0")o.push({missingType:"spec:version",elementKey:"spec",reason:"invalid-spec",context:"Native Spec version must be 2.0",code:"spec:version",path:"version"});let p=et(c);return{spec:c,gaps:o,warnings:n,...p.length>0?{operatorUsage:p}:{}}}function ve(e){let t=_e(e.title??Ot(e.source)??"artifact");switch(e.format){case"html":return{bytes:Re(Pe(e.source,e.title)),filename:`${t}.html`,contentType:"text/html; charset=utf-8"};case"markdown":return{bytes:Re(e.source),filename:`${t}.md`,contentType:"text/markdown; charset=utf-8"};case"zip":{let r=tt(t),o=((e.files?.length)?e.files:[{path:"index.html",content:Pe(e.source,e.title)}]).map((a)=>({...a,path:`${r}/${a.path}`})),i=e.title??t,s=[...o,{path:`${r}/DESIGN-HANDOFF.md`,content:nt(i,o,r)},{path:`${r}/design-manifest.json`,content:JSON.stringify(rt(i,o),null,2)}];return{bytes:Ae(s),filename:`${t}.zip`,contentType:"application/zip"}}case"pptx":return{bytes:dt(e.source,e.title??t),filename:`${t}.pptx`,contentType:"application/vnd.openxmlformats-officedocument.presentationml.presentation"}}}function tt(e){return _e(e??"artifact")}function rt(e,t){return{contract:"uibot.artifact.zip",title:e,generator:"UIBot",files:t.map((r)=>r.path)}}function nt(e,t,r){let n=t.map((l)=>`- \`${l.path}\``).join(`
2
- `),o=[],i=t.filter((l)=>/\.html?$/i.test(l.path)),s=t.filter((l)=>/\.md$/i.test(l.path)),a=t.filter((l)=>/\.ya?ml$/i.test(l.path));if(i.length>0)o.push(`- Preview the HTML files in a browser: ${i.map((l)=>`\`${l.path}\``).join(", ")} — no build step required.`);if(s.length>0)o.push(`- Read or edit the Markdown files in a Markdown reader or editor: ${s.map((l)=>`\`${l.path}\``).join(", ")}.`);if(a.length>0)o.push(`- Keep the Spec YAML files as editable source: ${a.map((l)=>`\`${l.path}\``).join(", ")}.`);if(o.length===0)o.push("- No HTML, Markdown, or Spec YAML files are included with specialized usage guidance.");return[`# ${e} — Design Handoff`,"","Exported from UIBot. This bundle is self-contained: the artifact files plus","this note and a machine-readable manifest.","","## Contents","",n,`- \`${r}/DESIGN-HANDOFF.md\` (this file)`,`- \`${r}/design-manifest.json\` (machine-readable file list)`,"","## Usage","",...o,"","_Generated by UIBot._"].join(`
3
- `)}function Pe(e,t="UIBot artifact"){let r=e.trim(),n=r.slice(0,128).toLowerCase();if(n.startsWith("<!doctype")||n.startsWith("<html"))return r;return["<!doctype html>",'<html lang="en">',"<head>",' <meta charset="utf-8" />',' <meta name="viewport" content="width=device-width, initial-scale=1" />',` <title>${Te(t)}</title>`,"</head>","<body>",e,"</body>","</html>"].join(`
4
- `)}var ot=/^\uE000(ul|ol)(\d+)\uE001/;function it(e){let t=[];return e.replace(/<(\/?)(ul|ol|li)\b[^>]*>/gi,(r,n,o)=>{let i=o.toLowerCase();if(i==="li"){if(n)return`
1
+ function ee(e){return{...e,components:e.components,actions:e.actions??{},templates:e.templates??{}}}var te=["SetState","ResetState","Request","Link","Validate","DisplayMessage","Login","Logout","CallMethod"],H={SetState:{name:"SetState",description:"Set a page state path to an evaluated declarative value",params:{path:{type:"string"},value:{description:"Literal or supported PropValue expression"}},generation:{evaluatedParams:["value"],prerequisites:["Declare the state path on the same page"],example:{action:"SetState",params:{path:"open",value:{_not:{_state:"open"}}}}}},ResetState:{name:"ResetState",description:"Restore paths from the supplied initial map; missing values become null",params:{paths:{type:"array",items:{type:"string"}},initial:{type:"object"}},generation:{evaluatedParams:[],prerequisites:["Supply literal initial values; omitting paths resets keys in initial"],example:{action:"ResetState",params:{paths:["open"],initial:{open:!1}}}}},Request:{name:"Request",description:"Execute a configured connection request",params:{connectionId:{type:"string"},request:{type:"object"},loadingPath:{type:"string"},responsePath:{type:"string"},errorPath:{type:"string"}},generation:{evaluatedParams:["connectionId","request"],prerequisites:["Host must inject the declared connection driver and secrets; Studio local Spec preview does not"],example:{action:"Request",params:{connectionId:"projects",request:{id:"list",connectionId:"projects",payload:{operation:"FindAll",resource:"projects"}},responsePath:"rows"}}}},Link:{name:"Link",description:"Emit navigation to a literal URL or page path",params:{path:{type:"string"},url:{type:"string"},target:{enum:["_self","_blank"]}},generation:{evaluatedParams:[],prerequisites:["Host handles navigation; local page paths must exist"],example:{action:"Link",params:{path:"/details"}}}},Validate:{name:"Validate",description:"Emit form validation event; does not itself throw for invalid fields",params:{formId:{type:"string"},errorPath:{type:"string"}},generation:{evaluatedParams:[],prerequisites:["Requires host form:validate listener; prefer native required controls and Form.Submit"],example:{action:"Validate",params:{formId:"contact"}}}},DisplayMessage:{name:"DisplayMessage",description:"Emit an evaluated message for the host to display",params:{message:{description:"Literal or supported PropValue expression"},level:{enum:["info","success","warning","error"]},duration:{type:"number"}},generation:{evaluatedParams:["message"],prerequisites:["Requires host message:display listener"],example:{action:"DisplayMessage",params:{message:"Saved locally",level:"success"}}}},Login:{name:"Login",description:"Set a supplied local session user or request external login",params:{user:{type:"object"},provider:{type:"string"}},generation:{evaluatedParams:[],prerequisites:["Requires host session/auth; setting a local user is not server authentication"],example:{action:"Login",params:{provider:"configured-provider"}}}},Logout:{name:"Logout",description:"Clear the local session and emit auth:logout",params:{},generation:{evaluatedParams:[],prerequisites:["Host owns server session invalidation"],example:{action:"Logout",params:{}}}},CallMethod:{name:"CallMethod",description:"Emit a call to an existing block method",params:{blockId:{type:"string"},method:{type:"string"},args:{type:"array"}},generation:{evaluatedParams:["args"],prerequisites:["Requires an explicitly documented installed block method/listener; never invent a method"],example:{action:"CallMethod",params:{blockId:"documented-block",method:"documented-method",args:[]}}}}};var Fe={spec:["html","markdown","zip"],prototype:["html","zip"],deck:["html","pptx","zip"],poster:["html","zip"]},Tn=Array.from(new Set(Object.values(Fe).flat()));var Fn=Object.freeze([Object.freeze({name:"manifest",summary:"Describe query operations and list the derived resource index.",positionals:Object.freeze([]),options:Object.freeze([])}),Object.freeze({name:"search",summary:"Search resources with deterministic bilingual ranking and reasons.",positionals:Object.freeze([Object.freeze({name:"text",property:"text",type:"string",required:!1})]),options:Object.freeze([Object.freeze({name:"kind",property:"kinds",type:"resource-kind",multiple:!0,cliEncoding:"comma-separated"}),Object.freeze({name:"tag",property:"tags",type:"string",multiple:!0,cliEncoding:"comma-separated"}),Object.freeze({name:"category",property:"categories",type:"string",multiple:!0,cliEncoding:"comma-separated"}),Object.freeze({name:"capability",property:"capabilities",type:"string",multiple:!0,cliEncoding:"comma-separated"}),Object.freeze({name:"maturity",property:"maturities",type:"resource-maturity",multiple:!0,cliEncoding:"comma-separated"}),Object.freeze({name:"limit",property:"limit",type:"positive-integer"})])}),Object.freeze({name:"get",summary:"Resolve one canonical resource id or unambiguous alias.",positionals:Object.freeze([Object.freeze({name:"id-or-alias",property:"id",type:"string",required:!0})]),options:Object.freeze([])}),Object.freeze({name:"build",summary:"Plan dependency closure and gaps without writing or installing.",positionals:Object.freeze([Object.freeze({name:"root",property:"roots",type:"string",required:!0,variadic:!0})]),options:Object.freeze([])})]);var P=(e)=>e!==null&&typeof e==="object"&&!Array.isArray(e),S=(e,t)=>Object.keys(e).every((n)=>t.includes(n)),R=(e,t)=>typeof e==="string"&&e.length>0&&e.length<=t,ne=(e)=>typeof e==="number"&&Number.isSafeInteger(e)&&e>0,M=(e)=>typeof e==="string"&&/^[A-Za-z0-9_]{1,64}$/.test(e),re=(e,t=100)=>Array.isArray(e)&&e.length<=t&&e.every(M)&&new Set(e).size===e.length;function Me(e){if(!P(e)||!S(e,["id","name","type","required","options","link","lookup","formula","rollup"])||!M(e.id)||!R(e.name,200)||!["singleLineText","longText","number","checkbox","date","singleSelect","multipleSelect","linkedRecord","lookup","formula","rollup"].includes(String(e.type))||e.required!==void 0&&typeof e.required!=="boolean")return!1;if(e.options!==void 0&&(!Array.isArray(e.options)||e.options.length>100||e.options.some((t)=>!P(t)||!S(t,["id","name"])||!M(t.id)||!R(t.name,200))||new Set(e.options.map((t)=>t.id)).size!==e.options.length))return!1;if(e.options!==void 0&&!["singleSelect","multipleSelect"].includes(String(e.type)))return!1;for(let[t,n,r]of[["linkedRecord","link",["collectionId","displayFieldId"]],["lookup","lookup",["linkFieldId","targetFieldId"]],["formula","formula",["expression"]],["rollup","rollup",["linkFieldId","targetFieldId","function"]]]){let o=e[n];if(e.type===t!==(o!==void 0))return!1;if(o!==void 0&&(!P(o)||!S(o,[...r])||r.some((i)=>!R(o[i],i==="expression"?2048:512))))return!1}return!0}function oe(e){if(!P(e)||!S(e,["id","collectionId","descriptor","view","uibotCommit","authorId","createdAt","digest"])||!/^[a-f0-9]{64}$/.test(String(e.id))||!/^[a-f0-9]{64}$/.test(String(e.digest))||!/^[a-f0-9]{40}$/.test(String(e.uibotCommit))||!R(e.collectionId,512)||!R(e.authorId,512)||typeof e.createdAt!=="string"||!/^\d{4}-\d{2}-\d{2}T/.test(e.createdAt)||!Number.isFinite(Date.parse(e.createdAt)))return!1;try{if(new TextEncoder().encode(JSON.stringify(e)).length>131072)return!1}catch{return!1}let{descriptor:t,view:n}=e;if(!P(t)||!S(t,["id","name","schemaVersion","fields"])||t.id!==e.collectionId||!R(t.name,200)||!ne(t.schemaVersion)||!Array.isArray(t.fields)||t.fields.length<1||t.fields.length>100||!t.fields.every(Me)||new Set(t.fields.map((i)=>i.id)).size!==t.fields.length)return!1;if(!P(n)||!S(n,["id","name","version","type","groupByFieldId","dateFieldId","search","filter","sort","columnOrder","hiddenColumns","columnWidths"])||!M(n.id)||!R(n.name,200)||!ne(n.version)||!re(n.columnOrder)||!re(n.hiddenColumns)||!P(n.columnWidths)||Object.values(n.columnWidths).some((i)=>typeof i!=="number"||!Number.isInteger(i)||i<72||i>800))return!1;let r=t.fields,o=(i)=>r.some((s)=>P(s)&&s.id===i);if([...n.columnOrder,...n.hiddenColumns,...Object.keys(n.columnWidths)].some((i)=>!o(i)))return!1;if(n.type!==void 0&&!["grid","kanban","gallery","calendar","form"].includes(String(n.type)))return!1;if(n.type==="kanban"&&!t.fields.some((i)=>i.id===n.groupByFieldId&&["singleSelect","checkbox"].includes(i.type)))return!1;if(n.type==="calendar"&&!t.fields.some((i)=>i.id===n.dateFieldId&&i.type==="date"))return!1;if(n.search!==void 0&&(typeof n.search!=="string"||n.search.length>200))return!1;if(n.sort!==void 0&&(!Array.isArray(n.sort)||n.sort.length>4||n.sort.some((i)=>!P(i)||!S(i,["fieldId","direction"])||!o(i.fieldId)||!["asc","desc"].includes(String(i.direction)))))return!1;return!0}import{parse as oo}from"yaml";class b extends Error{code;details;constructor(e,t,n){super(t);this.name="CompileSpecError",this.code=e,this.details=n}}function Le(e,t){let n=Object.hasOwn(t,e)?t[e]:void 0;if(!n)throw new b("unknown-template",`unknown template "${e}"`,{template:e});let r=n.pages[0]?.blocks[0];if(!r||r.type!=="PageLayout")throw new b("invalid-shell-root",`template "${e}" root is not PageLayout`,{template:e});return r}function L(e,t,n,r){let o=e;if(e.template){if(n.has(e.template))throw new b("template-cycle",`template cycle at "${e.template}"`,{template:e.template});let i=Le(e.template,t),s=new Set(n);s.add(e.template);let a={...i.slots,...e.slots};if(r&&!e.slots?.sidebar)delete a.sidebar;let l=e.children??i.children,c=e.events??i.events,p=e.visible??i.visible;return o={...i,...e.id?{id:e.id}:{},props:{...i.props,...e.props},slots:a,...l?{children:l}:{},...c?{events:c}:{},...p!==void 0?{visible:p}:{}},L(o,t,s,r)}return{...o,...o.children?{children:o.children.map((i)=>L(i,t,n,r))}:{},...o.slots?{slots:Object.fromEntries(Object.entries(o.slots).map(([i,s])=>[i,s.map((a)=>L(a,t,n,r))]))}:{}}}function Be(e){let t=(n)=>{if(n.template)return!0;if(n.children?.some(t))return!0;return Object.values(n.slots??{}).some((r)=>r.some(t))};return e.pages.some((n)=>n.blocks.some(t))}function ie(e,t){return e.map((n)=>{if("children"in n&&Array.isArray(n.children))return{type:"MenuGroup",props:{title:n.label},children:ie(n.children,t)};let r=n,o={label:r.label,href:r.path};if(r.icon)o.icon=r.icon;if(r.path===t)o.active=!0;return{type:"MenuLink",props:o}})}function Ne(e){let t=e.menus?.items;if(!t?.length)return e;return{...e,pages:e.pages.map((n)=>({...n,blocks:n.blocks.map((r)=>{if(r.type!=="PageLayout")return r;if(r.slots?.sidebar?.length)return r;return{...r,slots:{...r.slots,sidebar:[{type:"PageSiderMenu",props:{title:n.title??r.props?.title??"Menu"},children:ie(t,n.path)}]}}})}))}}function W(e,t={}){let n=Boolean(e.menus?.items?.length),r=Be(e)?{...e,pages:e.pages.map((o)=>({...o,blocks:o.blocks.map((i)=>L(i,t,new Set,n))}))}:e;return Ne(r)}function je(e){let t=new Map,n=new Map,r=new Map,o=(i,s)=>{if(i.id!==void 0){if(r.has(i.id)){let a=r.get(i.id);throw new b("duplicate-block-id",`Block id "${i.id}" is declared more than once`,{blockId:i.id,firstPageId:a,pageId:s})}r.set(i.id,s)}for(let a of i.children??[])o(a,s);for(let a of Object.values(i.slots??{}))for(let l of a)o(l,s)};return e.pages.forEach((i,s)=>{let a=t.get(i.id);if(a!==void 0)throw new b("duplicate-page-id",`Page id "${i.id}" is declared more than once`,{pageId:i.id,firstIndex:a,pageIndex:s});if(t.set(i.id,s),n.has(i.path)){let l=n.get(i.path);throw new b("duplicate-page-path",`Page path "${i.path}" is declared more than once`,{path:i.path,firstPageId:l,pageId:i.id})}n.set(i.path,i.id);for(let l of i.blocks)o(l,i.id)}),new Set(r.keys())}function Ve(e,t,n){while(!0){let r=t.counter++,o=n?`${n}_${r}`:`${e}_${r}`;if(!t.reservedIds.has(o)&&!t.assignedIds.has(o))return o}}function z(e,t,n,r,o,i){let s=e.id??Ve(t,r,i??o);if(r.assignedIds.has(s))throw new b("duplicate-block-id",`Block id "${s}" is declared more than once`,{blockId:s,pageId:t});r.assignedIds.add(s);let a=(e.children??[]).map((p)=>z(p,t,n,r,s,s)),l={};for(let[p,u]of Object.entries(e.slots??{}))l[p]=u.map((d)=>z(d,t,n,r,s,`${s}_${p}`));let c={id:s,pageId:t,type:e.type,...o?{parentId:o}:{},...e.props?{props:e.props}:{},...a.length?{children:a}:{},...Object.keys(l).length?{slots:l}:{},...e.events?{events:e.events}:{},...e.visible!==void 0?{visible:e.visible}:{},...e.template?{template:e.template}:{},...e.variant?{variant:e.variant}:{}};return n[s]=c,s}function G(e,t={}){e=W(e,t);let r={counter:0,reservedIds:je(e),assignedIds:new Set},o=Object.create(null);return{version:"2.0",pages:e.pages.map((s)=>{let a=[];for(let l of s.blocks)a.push(z(l,s.id,o,r));return{id:s.id,path:s.path,...s.title?{title:s.title}:{},rootBlockIds:a,...s.state?{state:s.state}:{},...s.auth?{auth:s.auth}:{},...s.lifecycle?{lifecycle:s.lifecycle}:{},...s.computed?{computed:s.computed}:{},...s.urlState?{urlState:s.urlState}:{}}}),...e.design?{design:e.design}:{},...e.connections?{connections:e.connections.map((s)=>({...s}))}:{},blocks:o}}var T=[{id:"_state",generation:{syntax:"page-state path",positions:["props","computed","action-value","visible"],example:{_state:"open"},prerequisite:"Declare the path on the same page"},bucket:"client",description:"Reads a value from the page state store"},{id:"_bindState",generation:{syntax:"page-state path",positions:["binding"],example:{_bindState:"name"},prerequisite:"Only installed controls implementing two-way binding"},bucket:"client",description:"Two-way state binding (read + write)"},{id:"_payload",generation:{syntax:"payload field",positions:["request-context"],example:{_payload:"name"},prerequisite:"Caller must supply request payload; ordinary preview props have no payload"},bucket:"client",description:"Request payload field"},{id:"_event",generation:{syntax:"event field",positions:["action-value"],example:{_event:"value"},prerequisite:"Only within an event action; permitted fields: type,name,value,checked,values"},bucket:"client",description:"Event payload field (e.g. form submit value)"},{id:"_global",generation:{syntax:"host-global field",positions:["host-context"],example:{_global:"configuredValue"},prerequisite:"Host-dependent and excluded from ordinary creation; no secrets"},bucket:"client",description:"Global (window) property access"},{id:"_if",generation:{syntax:"[condition, then, else]",positions:["props","computed","action-value"],example:{_if:[{_state:"open"},"Open","Closed"]}},bucket:"client",description:"Conditional ternary: [condition, then, else]"},{id:"_eq",generation:{syntax:"[a, b]",positions:["props","computed","action-value","visible","predicate"],example:{_eq:[{_state:"status"},"Active"]}},bucket:"client",description:"Equality: [a, b] → a === b"},{id:"_ne",generation:{syntax:"[a, b]",positions:["props","computed","action-value","visible","predicate"],example:{_ne:[{_state:"status"},"Active"]}},bucket:"client",description:"Inequality: [a, b] → a !== b"},{id:"_contains",generation:{syntax:"[haystack, needle]",positions:["props","computed","action-value","visible","predicate"],example:{_contains:[{_state:"name"},"orion"]}},bucket:"client",description:"Case-insensitive substring match: [haystack, needle] → haystack contains needle (empty needle → true)"},{id:"_gt",generation:{syntax:"[finite-number, finite-number]",positions:["props","computed","action-value","visible","predicate"],example:{_gt:[{_state:"count"},0]}},bucket:"client",description:"Greater-than for finite numbers: [a, b] → a > b. Non-numbers are false"},{id:"_lt",generation:{syntax:"[finite-number, finite-number]",positions:["props","computed","action-value","visible","predicate"],example:{_lt:[{_state:"count"},10]}},bucket:"client",description:"Less-than for finite numbers: [a, b] → a < b. Non-numbers are false"},{id:"_gte",generation:{syntax:"[finite-number, finite-number]",positions:["props","computed","action-value","visible","predicate"],example:{_gte:[{_state:"count"},0]}},bucket:"client",description:"Greater-or-equal for finite numbers: [a, b] → a >= b. Non-numbers are false"},{id:"_lte",generation:{syntax:"[finite-number, finite-number]",positions:["props","computed","action-value","visible","predicate"],example:{_lte:[{_state:"count"},10]}},bucket:"client",description:"Less-or-equal for finite numbers: [a, b] → a <= b. Non-numbers are false"},{id:"_in",generation:{syntax:"[value, array]",positions:["props","computed","action-value","visible","predicate"],example:{_in:[{_state:"status"},["Active","Draft"]]}},bucket:"client",description:"Membership: [value, array] → array includes value"},{id:"_not",generation:{syntax:"condition",positions:["props","computed","action-value","visible","predicate"],example:{_not:{_state:"open"}}},bucket:"client",description:"Logical NOT"},{id:"_and",generation:{syntax:"[condition, ...]",positions:["props","computed","action-value","visible","predicate"],example:{_and:[{_state:"ready"},{_state:"open"}]}},bucket:"client",description:"Logical AND over a list of conditions"},{id:"_or",generation:{syntax:"[condition, ...]",positions:["props","computed","action-value","visible","predicate"],example:{_or:[{_state:"ready"},{_state:"open"}]}},bucket:"client",description:"Logical OR over a list of conditions"},{id:"_user",generation:{syntax:"session user field",positions:["props","computed","action-value"],example:{_user:"name"},prerequisite:"Requires injected host session; no server ACL guarantee"},bucket:"client",description:"Current session user field (client-visible)"},{id:"_item",generation:{syntax:"item field or empty string",positions:["predicate","loop-props"],example:{_item:"name"},prerequisite:"Only inside a declared loop or filter/find predicate"},bucket:"client",description:"Current list item in a loop scope"},{id:"_index",generation:{syntax:"ignored scalar marker",positions:["predicate","loop-props"],example:{_index:0},prerequisite:"Only inside a declared loop or filter/find predicate"},bucket:"client",description:"Current list index in a loop scope"},{id:"_array.length",generation:{syntax:"array expression",positions:["props","computed","action-value"],example:{"_array.length":{_state:"rows"}}},bucket:"client",description:"Array length"},{id:"_string.concat",generation:{syntax:"[value, ...]",positions:["props","computed","action-value"],example:{"_string.concat":["Hello ",{_state:"name"}]}},bucket:"client",description:"String concatenation over a list"},{id:"_number.add",generation:{syntax:"[left, right] (finite numbers)",positions:["action-value"],example:{"_number.add":[{_state:"count"},1]},prerequisite:"Both operands must evaluate to finite numbers or the action fails and writes nothing; use it in SetState value for counters (e.g. SetState count = count + 1), never for strings or arrays"},bucket:"client",description:"Finite number addition: [left, right] → left + right. Throws on non-number, non-finite or overflowing operands (no coercion, no fallback to 0)"},{id:"_computed",generation:{syntax:"computed name",positions:["props","computed","action-value","visible"],example:{_computed:"filtered"},prerequisite:"Declare page computed expression"},bucket:"client",description:"Reads a derived (computed) state value by name from the __computed namespace"},{id:"_filter",generation:{syntax:"[array, predicate]",positions:["props","computed","action-value"],example:{_filter:[{_state:"rows"},{_eq:[{_item:"status"},"Active"]}]}},bucket:"client",description:"Filters an array: [arrayExpr, predExpr] with { _item, _index } scope"},{id:"_find",generation:{syntax:"[array, predicate]",positions:["props","computed","action-value"],example:{_find:[{_state:"rows"},{_eq:[{_item:"name"},"Orion"]}]}},bucket:"client",description:"Finds the first matching element: [arrayExpr, predExpr] with { _item, _index } scope"},{id:"_len",generation:{syntax:"array/string/object expression",positions:["props","computed","action-value"],example:{_len:{_state:"rows"}}},bucket:"client",description:"Length of an array, string, or object (0 if empty)"},{id:"_concat",generation:{syntax:"[value, ...]",positions:["props","computed","action-value"],example:{_concat:[[1],[2]]},prerequisite:"Concatenation is not numeric addition"},bucket:"client",description:"Concatenates a list: arrays are joined, otherwise values are string-concatenated"},{id:"_count",generation:{syntax:"array or [array, predicate?]",positions:["props","computed","action-value"],example:{_count:[{_state:"rows"}]}},bucket:"client",description:"Count of an array, or of elements matching a predicate: [array, predicate?]"},{id:"_groupCount",generation:{syntax:"[array, field]",positions:["props","computed","action-value"],example:{_groupCount:[{_state:"rows"},"status"]}},bucket:"client",description:"Counts array items by a field in one pass: [array, field] → { value: count }"},{id:"_sort",generation:{syntax:"[array, {by, order?, rank?}]",positions:["props","computed","action-value"],example:{_sort:[{_state:"rows"},{by:"name",order:"asc"}]}},bucket:"client",description:"Stable sort: [array, { by, order?: asc|desc, rank?: { field: values[] } }]. rank is enum order"},{id:"_js",generation:{syntax:"disabled",positions:[],example:{_js:"disabled"},prerequisite:"Arbitrary code execution is disabled; permissions do not enable it",disabled:!0},bucket:"client",description:"Legacy JS expression; execution is always disabled"}],B=new Set(T.map((e)=>e.id));var se=new Set(te),$e=new Map(T.map((e)=>[e.id,e])),ce=new Set(["array","boolean","integer","null","number","object","string"]),pe=new Set(["default","description","enum","items","properties","required","type"]);function ae(e){if(!e)return[];return Object.keys(e)}function Ue(e){if(!e||e.type!=="array")return;let t=e.items;if(!t||typeof t!=="object"||t.type!=="object"||!t.properties)return;return new Set(Object.keys(t.properties))}function Y(e,t,n){if(!e||typeof e!=="object")return;if(Array.isArray(e)){for(let[r,o]of e.entries())Y(o,`${t}[${r}]`,n);return}for(let[r,o]of Object.entries(e)){let i=t?`${t}.${r}`:r;n(r,o,i),Y(o,i,n)}}function N(e,t,n,r,o,i,s,a){Y(r,o,(l,c,p)=>{if((l==="_state"||l==="_bindState")&&typeof c==="string"){let u=c.split("."),d=u[0]??"";if(d==="__computed"){let g=u[1]??"";if(!s.has(g))e.push({code:"refs:computed-declared",message:`${t}: _computed "${g}" is not declared`,elementKey:n,path:p});return}if(!i.has(d))e.push({code:"refs:state-declared",message:`${t}: _state "${d}" is not declared in state`,elementKey:n,path:p})}if(l==="_computed"&&typeof c==="string"&&!s.has(c))e.push({code:"refs:computed-declared",message:`${t}: _computed "${c}" is not declared`,elementKey:n,path:p});if(l==="_item"&&typeof c==="string"&&c!==""&&a&&!a.has(c))e.push({code:"item:field-exists",message:`${t}: _item "${c}" is not in the item schema`,elementKey:n,path:p})})}function h(e){return e!==null&&typeof e==="object"&&!Array.isArray(e)}function D(e){return h(e)&&Object.keys(e).some((t)=>t.startsWith("_"))}var le=new Set(["_eq","_ne","_contains","_gt","_lt","_gte","_lte","_in","_not","_and","_or"]);function qe(e,t){if(new Set(["_eq","_ne","_contains","_gt","_lt","_gte","_lte","_in","_filter","_find","_groupCount","_sort","_number.add"]).has(e)){if(!Array.isArray(t)||t.length!==2)return!1;if(e==="_groupCount")return typeof t[1]==="string";if(e==="_sort"){let r=t[1];if(!h(r))return!1;if(!(typeof r.by==="string"&&r.by.length>0||Array.isArray(r.by)&&r.by.length>0&&r.by.every((i)=>typeof i==="string"&&i.length>0)))return!1;if(r.order!==void 0&&r.order!=="asc"&&r.order!=="desc")return!1;if(r.rank!==void 0&&(!h(r.rank)||Object.values(r.rank).some((i)=>!Array.isArray(i))))return!1;return Object.keys(r).every((i)=>["by","order","rank"].includes(i))}return!0}if(e==="_if")return Array.isArray(t)&&t.length===3;if(e==="_and"||e==="_or")return Array.isArray(t)&&t.length>0;if(e==="_string.concat"||e==="_concat")return Array.isArray(t)&&t.length>0;if(e==="_count")return!Array.isArray(t)||t.length===1||t.length===2;if(e==="_index")return typeof t==="number"&&Number.isFinite(t);if(["_state","_bindState","_computed","_event","_global","_payload","_user"].includes(e))return typeof t==="string"&&t.length>0;if(e==="_item")return typeof t==="string";return!0}function de(e){return e.enum===void 0||Array.isArray(e.enum)&&e.enum.length>0&&e.enum.every((t)=>t===null||typeof t==="string"||typeof t==="boolean"||typeof t==="number"&&Number.isFinite(t))}function I(e,t,n,r,o,i){if(n==="predicate"&&(!D(e)||!le.has(Object.keys(e)[0]??"")))return r.push({code:"props:expression",message:`${o}: predicate must be a supported expression node`,elementKey:i,path:t}),!1;if(e===void 0)return r.push({code:"props:expression",message:`${o}: value is not part of the supported serialized expression syntax`,elementKey:i,path:t}),!1;if(Array.isArray(e))return e.reduce((d,g,m)=>I(g,`${t}[${m}]`,n,r,o,i)&&d,!0);if(!h(e)){if(typeof e==="number"&&!Number.isFinite(e)||e!==null&&!["string","number","boolean"].includes(typeof e))return r.push({code:"props:expression",message:`${o}: value is not part of the supported serialized expression syntax`,elementKey:i,path:t}),!1;return e===null||["string","number","boolean"].includes(typeof e)}let s=Object.keys(e).filter((d)=>d.startsWith("_"));if(s.length===0)return Object.entries(e).reduce((d,[g,m])=>I(m,`${t}.${g}`,n,r,o,i)&&d,!0);let a=s[0]??"",l=$e.get(a),c=`${t}.${a}`;if(s.length!==1||Object.keys(e).length!==1||!l)return r.push({code:"props:expression",message:`${o}: expression shape is not supported`,elementKey:i,path:c}),!1;if(l.generation?.disabled||!l.generation?.positions.includes(n)&&!(n==="props"&&l.generation?.positions.includes("binding"))&&!(n==="predicate-value"&&l.generation?.positions.some((d)=>["props","computed","predicate"].includes(d))))return r.push({code:"props:expression",message:`${o}: expression is not supported in this value position`,elementKey:i,path:c}),!1;let p=e[a];if(!qe(a,p))return r.push({code:"props:expression",message:`${o}: expression operand shape is not supported`,elementKey:i,path:c}),!1;let u=(d)=>D(d)||Array.isArray(d);if(["_filter","_find","_groupCount","_sort"].includes(a)&&!u(Array.isArray(p)?p[0]:void 0)||a==="_in"&&!u(Array.isArray(p)?p[1]:void 0))return r.push({code:"props:expression",message:`${o}: expression array operand has an unsupported literal shape`,elementKey:i,path:c}),!1;if(a==="_count"&&(Array.isArray(p)?!u(p[0]):!u(p))||a==="_array.length"&&!u(p))return r.push({code:"props:expression",message:`${o}: expression array operand has an unsupported literal shape`,elementKey:i,path:c}),!1;if(["_gt","_lt","_gte","_lte"].includes(a)&&Array.isArray(p)){if(p.some((g)=>!D(g)&&(typeof g!=="number"||!Number.isFinite(g))))return r.push({code:"props:expression",message:`${o}: numeric comparison literals must be finite numbers`,elementKey:i,path:c}),!1}if(Array.isArray(p))return p.reduce((d,g,m)=>{let y=n;if((["_filter","_find"].includes(a)||a==="_count")&&m===1)y="predicate";else if(n==="predicate"||n==="predicate-value"){if(y=le.has(a)?"predicate-value":n,n==="predicate"&&["_and","_or"].includes(a))y="predicate"}return I(g,`${c}[${m}]`,y,r,o,i)&&d},!0);if(h(p))return I(p,c,n==="predicate"&&a==="_not"?"predicate-value":n,r,o,i);return!0}function K(e,t,n,r,o,i,s){let a=(u)=>s==="props"?`props:${u}`:`actions:params-${u}`;if(Object.keys(t).filter((u)=>!pe.has(u)).length>0){r.push({code:"schema:unsupported",message:`${o}: schema contains unsupported constraints`,elementKey:i,path:n});return}if(t.type!==void 0&&!ce.has(t.type)){r.push({code:"schema:unsupported",message:`${o}: schema type is not supported`,elementKey:i,path:n});return}if(!de(t)){r.push({code:"schema:unsupported",message:`${o}: schema enum is not supported`,elementKey:i,path:n});return}if(t.required!==void 0&&(!Array.isArray(t.required)||t.required.some((u)=>typeof u!=="string"))){r.push({code:"schema:unsupported",message:`${o}: schema required list is not supported`,elementKey:i,path:n});return}if(t.items!==void 0&&(t.type!=="array"||!h(t.items))){r.push({code:"schema:unsupported",message:`${o}: schema items must describe an array`,elementKey:i,path:n});return}if(t.properties!==void 0&&(t.type!=="object"||!h(t.properties))){r.push({code:"schema:unsupported",message:`${o}: schema properties must describe an object`,elementKey:i,path:n});return}if(t.required?.length&&t.type!=="object"){r.push({code:"schema:unsupported",message:`${o}: schema required list is only supported for objects`,elementKey:i,path:n});return}if(D(e))return;let c=t.type;if(!(c===void 0||c==="null"&&e===null||c==="string"&&typeof e==="string"||c==="boolean"&&typeof e==="boolean"||c==="number"&&typeof e==="number"&&Number.isFinite(e)||c==="integer"&&typeof e==="number"&&Number.isInteger(e)||c==="array"&&Array.isArray(e)||c==="object"&&h(e))){r.push({code:a("type"),message:`${o}: value does not match the declared type`,elementKey:i,path:n});return}if(t.enum&&!t.enum.some((u)=>Object.is(u,e)))r.push({code:a("enum"),message:`${o}: value is outside the declared enum`,elementKey:i,path:n});if(c==="object"&&h(e)){for(let u of t.required??[])if(!Object.hasOwn(e,u))r.push({code:a("required"),message:`${o}: required object field is missing`,elementKey:i,path:`${n}.${u}`});for(let[u,d]of Object.entries(t.properties??{}))if(Object.hasOwn(e,u))K(e[u],d,`${n}.${u}`,r,o,i,s)}if(c==="array"&&Array.isArray(e)&&t.items)e.forEach((u,d)=>{K(u,t.items,`${n}[${d}]`,r,o,i,s)})}function ue(e,t,n,r,o,i,s){if(!n)return;for(let[a,l]of Object.entries(n)){let c=`${r}.${a}`;if(J(l,c,e,o,i)&&t&&Object.hasOwn(t,a))K(t[a],l,c,e,o,i,s)}}function ge(e,t,n,r,o,i,s={}){for(let[a,l]of Object.entries(t??{})){let c=r==="action-value"&&!s.evaluatedParams?.has(a)?"action-literal":r;I(l,`${n}.${a}`,c,e,o,i)}}function J(e,t,n,r,o){if(Object.keys(e).some((s)=>!pe.has(s))||e.type!==void 0&&!ce.has(e.type)||!de(e)||e.required!==void 0&&(!Array.isArray(e.required)||e.required.some((s)=>typeof s!=="string"))||e.items!==void 0&&(e.type!=="array"||!h(e.items))||e.properties!==void 0&&(e.type!=="object"||!h(e.properties))||Boolean(e.required?.length)&&e.type!=="object")return n.push({code:"schema:unsupported",message:`${r}: schema contains unsupported constraints`,elementKey:o,path:t}),!1;for(let[s,a]of Object.entries(e.properties??{}))if(!J(a,`${t}.${s}`,n,r,o))return!1;if(e.items&&!J(e.items,`${t}[]`,n,r,o))return!1;return!0}function j(e,t,n,r,o,i,s){if(!Array.isArray(r)){if(s)e.push({code:"actions:chain",message:`${t}: action chain must be an array`,elementKey:n,path:o});return}for(let[a,l]of r.entries()){if(!h(l)){if(s)e.push({code:"actions:chain",message:`${t}: action step must be an object`,elementKey:n,path:`${o}[${a}]`});continue}let c=l.action,p=`${o}[${a}]`;if(s&&(typeof c!=="string"||c.length===0))e.push({code:"actions:chain",message:`${t}: action step needs an action name`,elementKey:n,path:`${p}.action`});if(typeof c==="string"&&!se.has(c)&&!Object.hasOwn(i.actions??{},c))e.push({code:"actions:registered",message:`${t}: action "${c}" is not in the catalog. Registered actions: ${[...se,...Object.keys(i.actions??{})].join(", ")}. No equivalent is guaranteed: preserve the requirement and report unsupported behavior instead of disabling it.`,elementKey:n,path:`${p}.action`});if(s&&typeof c==="string"){let u=Object.hasOwn(i.actions??{},c)?i.actions[c]:Object.hasOwn(H,c)?H[c]:void 0,d=l.params;if(d!==void 0&&!h(d))e.push({code:"actions:chain",message:`${t}: action params must be an object`,elementKey:n,path:`${p}.params`});else{if(h(d))ge(e,d,`${p}.params`,"action-value",t,n,{evaluatedParams:new Set(u?.generation?.evaluatedParams??[])});if(u)ue(e,h(d)?d:void 0,u.params,`${p}.params`,t,n,"actions:params")}}if(Object.hasOwn(l,"onSuccess"))j(e,t,n,l.onSuccess,`${p}.onSuccess`,i,s);if(Object.hasOwn(l,"onError"))j(e,t,n,l.onError,`${p}.onError`,i,s)}}function me(e,t,n=!1){let r=[],o=new Set([...ae(e.state),...e.connectionIds??[]]),i=new Set(ae(e.computed)),s=e.pageId??e.root;if(e.computed)for(let[a,l]of Object.entries(e.computed)){if(n)I(l,`computed.${a}`,"computed",r,`${s}.computed`,s);N(r,`${s}.computed`,s,l,`computed.${a}`,o,i,He(e,t))}if(e.urlState)for(let[a,l]of Object.entries(e.urlState)){if(!o.has(a))r.push({code:"refs:url-state-declared",message:`${s}: urlState "${a}" is not declared in state`,elementKey:s,path:`urlState.${a}`});if(!l||typeof l.param!=="string"||l.param.length===0)r.push({code:"refs:url-state-declared",message:`${s}: urlState "${a}" needs a param name`,elementKey:s,path:`urlState.${a}.param`})}for(let[a,l]of Object.entries(e.elements)){let c=Object.hasOwn(t.components,l.type)?t.components[l.type]:void 0;if(!c)continue;let p=`${s}/${a}`,u=fe(c.props);if(n)ge(r,l.props,"props","props",p,a);if(l.visible!==null&&typeof l.visible==="object"){let d=Object.keys(l.visible);if(Array.isArray(l.visible)||d.length!==1||!d[0]?.startsWith("_"))r.push({code:"visibility:expression",message:`${p}: visible must be a boolean or an operator expression, not a literal record`,elementKey:a,path:"visible"})}if(n&&l.visible!==void 0)if(typeof l.visible!=="boolean"&&!D(l.visible))r.push({code:"visibility:expression",message:`${p}: visible must be a boolean or an operator expression`,elementKey:a,path:"visible"});else I(l.visible,"visible","visible",r,p,a);if(N(r,p,a,l.props,"props",o,i,u),N(r,p,a,l.visible,"visible",o,i,u),N(r,p,a,l.events,"events",o,i,u),c.props){let d=new Set(Object.keys(c.props));for(let g of Object.keys(l.props??{}))if(!d.has(g))r.push({code:"props:declared",message:`${p}: prop "${g}" is not declared on ${l.type}`,elementKey:a,path:`props.${g}`});if(n)ue(r,l.props,c.props,"props",p,a,"props")}if(c.events){let d=new Set(Object.keys(c.events));for(let[g,m]of Object.entries(l.events??{})){if(!d.has(g))r.push({code:"events:declared",message:`${p}: event "${g}" is not declared on ${l.type}`,elementKey:a,path:`events.${g}`});j(r,p,a,m,`events.${g}`,t,n)}}else for(let[d,g]of Object.entries(l.events??{}))j(r,p,a,g,`events.${d}`,t,n)}return r.map((a)=>({...a,path:a.elementKey===s?`${s}/${a.path}`:`${s}/${a.elementKey}/${a.path}`}))}function fe(e){let t=new Set;for(let n of Object.values(e??{})){let r=Ue(n);if(!r)continue;for(let o of r)t.add(o)}return t.size>0?t:void 0}function He(e,t){let n=new Set;for(let r of Object.values(e.elements)){let o=Object.hasOwn(t.components,r.type)?t.components[r.type]:void 0,i=fe(o?.props);if(!i)continue;for(let s of i)n.add(s)}return n.size>0?n:void 0}function ye(e){return e.map((t)=>({code:t.code,message:t.message,elementKey:t.elementKey,path:t.path}))}var Ce=[{id:"_request",bucket:"server",description:"Executes a connection request server-side and injects the result"},{id:"_secret",bucket:"server",description:"Reads a server-side secret value; never transmitted to the client"}],V=new Set(Ce.map((e)=>e.id));function X(e){return{...e,...e.props?{props:{...e.props}}:{},...e.children?{children:[...e.children]}:{},...e.slots?{slots:{...e.slots}}:{},...e.events?{events:{...e.events}}:{}}}function he(e){return{...e,...e.roots?{roots:[...e.roots]}:{},...e.state?{state:{...e.state}}:{},elements:Object.fromEntries(Object.entries(e.elements).map(([t,n])=>[t,X(n)]))}}function ze(e){return e.type==="compiler:operator"}function Ge(e){return e.type==="compiler:validator"}class O{operators;validators;constructor(e={}){let t=(e.capabilities??[]).filter(ze).map((r)=>r.contribution),n=(e.capabilities??[]).filter(Ge).map((r)=>r.contribution);this.operators=[...e.operators??[],...t],this.validators=[...e.validators??[],...n]}merge(e){if(e instanceof O)return new O({operators:[...this.operators,...e.operators],validators:[...this.validators,...e.validators]});return new O({operators:[...this.operators,...e.operators??[]],validators:[...this.validators,...e.validators??[]],...e.capabilities?{capabilities:e.capabilities}:{}})}}function Ye(e={}){return new O(e)}function Ke(e,t,n){let r=e.pages.find((s)=>s.id===t),o=[...r?.rootBlockIds??[]],i=Object.fromEntries(Object.entries(e.blocks).filter(([,s])=>s.pageId===t).map(([s,a])=>{let{id:l,pageId:c,parentId:p,...u}=a;return[s,X(u)]}));if(n&&o.length===0){let s=e.blocks.__empty__?`__empty__:${t}`:"__empty__";o.push(s),i[s]={type:"Empty"}}return{version:e.version,root:o[0]??"__empty__",roots:o,pageId:t,...r?.state?{state:r.state}:{},...r?.computed?{computed:r.computed}:{},...r?.urlState?{urlState:r.urlState}:{},...e.connections?{connectionIds:e.connections.map((s)=>s.id)}:{},elements:i}}function Je(e,t){let n=[...t.roots??e.roots??[]];if(n.length>0&&t.root!==e.root)n[0]=t.root;else if(n.length===0&&t.elements[t.root])n.push(t.root);return n}async function Xe(e,t,n,r){let o=he(e);for(let i of n.operators){let s={spec:o,catalog:t,warnings:r,getElement(l){return o.elements[l]},updateElement(l,c){o={...o,elements:{...o.elements,[l]:X(c)}}},addWarning(l){r.push(l)}},a=await i.apply(s);if(a)o=he(a)}return o}function be(e,t){return Object.hasOwn(e,t)?e[t]:void 0}function Ze(e,t,n,r,o){let i=Object.entries(e.elements);for(let a of e.roots?.length?e.roots:[e.root])if(!e.elements[a])n.push({code:"missing-root",message:`Root element "${a}" is missing from the elements map`,elementKey:a});for(let[a,l]of i){if(!(be(t.components,l.type)??be(t.templates,l.type)))r.push({missingType:l.type,elementKey:a,reason:l.template?"missing-template":"missing-component",context:`Element ${a} references ${l.type}`,path:`blocks.${a}.type`});for(let p of l.children??[])if(!e.elements[p])n.push({code:"dangling-child",message:`Element "${a}" references missing child "${p}"`,elementKey:a})}let s=me(e,t,o);if(o){for(let a of s)r.push({missingType:a.code,elementKey:a.elementKey,reason:"invalid-spec",context:a.message,code:a.code,path:a.path});return}n.push(...ye(s))}async function Qe(e,t,n,r,o){for(let i of n.validators){let s={spec:e,catalog:t,warnings:r,gaps:o,addWarning(a){r.push(a)},addGap(a){o.push(a)}};await i.validate(s)}}function A(e,t){if(!e||typeof e!=="object")return;if(Array.isArray(e)){for(let n of e)A(n,t);return}for(let[n,r]of Object.entries(e)){if(n.startsWith("_"))t.add(n);A(r,t)}}function et(e){let t=new Map;for(let[r,o]of Object.entries(e.blocks)){let i=new Set;A(o.props,i),A(o.visible,i);for(let s of i){let a=t.get(s)??new Set;a.add(r),t.set(s,a)}}for(let r of e.pages){let o=new Set;A(r.computed,o),A(r.lifecycle,o);for(let i of o){let s=t.get(i)??new Set;s.add(r.id),t.set(i,s)}}let n=[];for(let[r,o]of t){let i=B.has(r)?"client":V.has(r)?"server":r==="_ref"?"build":"shared";n.push({operatorId:r,bucket:i,blockIds:[...o]})}return n}async function xe(e,t,n={}){let r=[],o=[],i=n.registry??Ye(),s=G(e,n.templates),a=Object.create(null),l=[];for(let[u,d]of s.pages.entries()){let g=Ke(s,d.id,u===0),m=await Xe(g,t,i,r);Ze(m,t,r,o,n.strict===!0),await Qe(m,t,i,r,o);for(let[y,_]of Object.entries(m.elements)){let Q=a[y];if(Q)throw new b("duplicate-block-id",`Compiler output block id "${y}" conflicts across pages`,{blockId:y,firstPageId:Q.pageId,pageId:d.id});let q=s.blocks[y];a[y]={..._,id:y,pageId:d.id,...q?.pageId===d.id&&q.parentId?{parentId:q.parentId}:{}}}l.push({...d,rootBlockIds:Je(g,m)})}let c={version:"2.0",pages:l,...s.design?{design:s.design}:{},...s.connections?{connections:s.connections.map((u)=>({...u}))}:{},blocks:a};if(n.strict===!0&&e.version!=="2.0")o.push({missingType:"spec:version",elementKey:"spec",reason:"invalid-spec",context:"Native Spec version must be 2.0",code:"spec:version",path:"version"});let p=et(c);return{spec:c,gaps:o,warnings:r,...p.length>0?{operatorUsage:p}:{}}}function ve(e){let t=_e(e.title??Ot(e.source)??"artifact");switch(e.format){case"html":return{bytes:Re(Pe(e.source,e.title)),filename:`${t}.html`,contentType:"text/html; charset=utf-8"};case"markdown":return{bytes:Re(e.source),filename:`${t}.md`,contentType:"text/markdown; charset=utf-8"};case"zip":{let n=tt(t),o=((e.files?.length)?e.files:[{path:"index.html",content:Pe(e.source,e.title)}]).map((a)=>({...a,path:`${n}/${a.path}`})),i=e.title??t,s=[...o,{path:`${n}/DESIGN-HANDOFF.md`,content:rt(i,o,n)},{path:`${n}/design-manifest.json`,content:JSON.stringify(nt(i,o),null,2)}];return{bytes:Ae(s),filename:`${t}.zip`,contentType:"application/zip"}}case"pptx":return{bytes:dt(e.source,e.title??t),filename:`${t}.pptx`,contentType:"application/vnd.openxmlformats-officedocument.presentationml.presentation"}}}function tt(e){return _e(e??"artifact")}function nt(e,t){return{contract:"uibot.artifact.zip",title:e,generator:"UIBot",files:t.map((n)=>n.path)}}function rt(e,t,n){let r=t.map((l)=>`- \`${l.path}\``).join(`
2
+ `),o=[],i=t.filter((l)=>/\.html?$/i.test(l.path)),s=t.filter((l)=>/\.md$/i.test(l.path)),a=t.filter((l)=>/\.ya?ml$/i.test(l.path));if(i.length>0)o.push(`- Preview the HTML files in a browser: ${i.map((l)=>`\`${l.path}\``).join(", ")} — no build step required.`);if(s.length>0)o.push(`- Read or edit the Markdown files in a Markdown reader or editor: ${s.map((l)=>`\`${l.path}\``).join(", ")}.`);if(a.length>0)o.push(`- Keep the Spec YAML files as editable source: ${a.map((l)=>`\`${l.path}\``).join(", ")}.`);if(o.length===0)o.push("- No HTML, Markdown, or Spec YAML files are included with specialized usage guidance.");return[`# ${e} — Design Handoff`,"","Exported from UIBot. This bundle is self-contained: the artifact files plus","this note and a machine-readable manifest.","","## Contents","",r,`- \`${n}/DESIGN-HANDOFF.md\` (this file)`,`- \`${n}/design-manifest.json\` (machine-readable file list)`,"","## Usage","",...o,"","_Generated by UIBot._"].join(`
3
+ `)}function Pe(e,t="UIBot artifact"){let n=e.trim(),r=n.slice(0,128).toLowerCase();if(r.startsWith("<!doctype")||r.startsWith("<html"))return n;return["<!doctype html>",'<html lang="en">',"<head>",' <meta charset="utf-8" />',' <meta name="viewport" content="width=device-width, initial-scale=1" />',` <title>${Te(t)}</title>`,"</head>","<body>",e,"</body>","</html>"].join(`
4
+ `)}var ot=/^\uE000(ul|ol)(\d+)\uE001/;function it(e){let t=[];return e.replace(/<(\/?)(ul|ol|li)\b[^>]*>/gi,(n,r,o)=>{let i=o.toLowerCase();if(i==="li"){if(r)return`
5
5
  `;return`
6
- ${t[t.length-1]??"ul"}${Math.max(0,t.length-1)}`}if(n)t.pop();else t.push(i);return`
7
- `})}function st(e){let t=ot.exec(e);if(!t)return{text:k(e)};return{text:k(e.slice(t[0].length)),list:{kind:t[1],lvl:Number(t[2])}}}function at(e){let t=/<html\b[^>]*>/i.exec(e)?.[0];if(!t)return null;let r=/\s(?:xml:)?lang\s*=\s*(?:"([^"]*)"|'([^']*)'|([^\s>]+))/i.exec(t);return(r?.[1]??r?.[2]??r?.[3]??"").trim()||null}function lt(e){if(/[\u3040-\u30ff\u31f0-\u31ff\uff66-\uff9f]/.test(e))return"ja-JP";if(/[\uac00-\ud7af\u1100-\u11ff\u3130-\u318f]/.test(e))return"ko-KR";if(/[\u3400-\u4dbf\u4e00-\u9fff\uf900-\ufaff]/.test(e))return"zh-CN";return"en-US"}var ct=/^(?:zh|ja|ko)(?:-|$)/i;function Z(e,t){let r=t??lt(e),n=ct.test(r)?' altLang="en-US"':"";return`lang="${E(r)}"${n}`}function pt(e){let t=w(e,"section"),r=t.length>0?[]:Tt(e);return(t.length>0?t:r.length>0?r:w(e,"article").length>0?w(e,"article"):[e]).map((o,i)=>{let s=Dt(o),a=s.reduce((m,y)=>m.replace(y,""),o),l=Ee(a,["h1","h2","h3"])||Se(a,"data-title")||`Slide ${i+1}`,c=w(a,"li").map((m)=>k(v(m))).filter(Boolean),p=k(v(U(a,["script","style","svg"]))),u=s.flatMap((m)=>{if(k(v(U(m,["script","style","svg"]))))return m.split(/\n{2,}|<\/p>|<br\s*\/?>/i);let _=/^<[^>]*>/.exec(m)?.[0]??"";return[Se(_,"data-notes")]}).map((m)=>k(v(U(m,["script","style","svg"])))).filter(Boolean),d=U(a,["script","style","svg"]);for(let m of["h1","h2","h3"]){let y=w(d,m)[0];if(y){d=d.replace(y,"");break}}d=it(d).replace(/<tr\b[^>]*>([\s\S]*?)<\/tr>/gi,(m,y)=>`${(y.match(/<t[dh]\b[^>]*>[\s\S]*?<\/t[dh]>/gi)??[]).map((_)=>k(v(_))).join(" | ")}
6
+ ${t[t.length-1]??"ul"}${Math.max(0,t.length-1)}`}if(r)t.pop();else t.push(i);return`
7
+ `})}function st(e){let t=ot.exec(e);if(!t)return{text:k(e)};return{text:k(e.slice(t[0].length)),list:{kind:t[1],lvl:Number(t[2])}}}function at(e){let t=/<html\b[^>]*>/i.exec(e)?.[0];if(!t)return null;let n=/\s(?:xml:)?lang\s*=\s*(?:"([^"]*)"|'([^']*)'|([^\s>]+))/i.exec(t);return(n?.[1]??n?.[2]??n?.[3]??"").trim()||null}function lt(e){if(/[\u3040-\u30ff\u31f0-\u31ff\uff66-\uff9f]/.test(e))return"ja-JP";if(/[\uac00-\ud7af\u1100-\u11ff\u3130-\u318f]/.test(e))return"ko-KR";if(/[\u3400-\u4dbf\u4e00-\u9fff\uf900-\ufaff]/.test(e))return"zh-CN";return"en-US"}var ct=/^(?:zh|ja|ko)(?:-|$)/i;function Z(e,t){let n=t??lt(e),r=ct.test(n)?' altLang="en-US"':"";return`lang="${E(n)}"${r}`}function pt(e){let t=w(e,"section"),n=t.length>0?[]:Tt(e);return(t.length>0?t:n.length>0?n:w(e,"article").length>0?w(e,"article"):[e]).map((o,i)=>{let s=Dt(o),a=s.reduce((m,y)=>m.replace(y,""),o),l=Ee(a,["h1","h2","h3"])||Se(a,"data-title")||`Slide ${i+1}`,c=w(a,"li").map((m)=>k(v(m))).filter(Boolean),p=k(v(U(a,["script","style","svg"]))),u=s.flatMap((m)=>{if(k(v(U(m,["script","style","svg"]))))return m.split(/\n{2,}|<\/p>|<br\s*\/?>/i);let _=/^<[^>]*>/.exec(m)?.[0]??"";return[Se(_,"data-notes")]}).map((m)=>k(v(U(m,["script","style","svg"])))).filter(Boolean),d=U(a,["script","style","svg"]);for(let m of["h1","h2","h3"]){let y=w(d,m)[0];if(y){d=d.replace(y,"");break}}d=it(d).replace(/<tr\b[^>]*>([\s\S]*?)<\/tr>/gi,(m,y)=>`${(y.match(/<t[dh]\b[^>]*>[\s\S]*?<\/t[dh]>/gi)??[]).map((_)=>k(v(_))).join(" | ")}
8
8
  `).replace(/<\/(?:p|div|h[1-6]|table|header|footer)>/gi,`
9
9
  `);let g=v(d).split(`
10
- `).map(st).filter((m)=>m.text);return{title:k(l),bullets:c,body:p,notes:u,paragraphs:g}})}function dt(e,t="UIBot artifact"){let r=pt(e).flatMap(St),n=at(e),o=r.some((s)=>s.notes.length>0),i=[{path:"[Content_Types].xml",content:ut(r)},{path:"_rels/.rels",content:gt()},{path:"docProps/app.xml",content:mt(r.length)},{path:"docProps/core.xml",content:ft(t)},{path:"ppt/presentation.xml",content:yt(r.length,o)},{path:"ppt/_rels/presentation.xml.rels",content:Ct(r.length,o)},{path:"ppt/theme/theme1.xml",content:_t()},{path:"ppt/slideMasters/slideMaster1.xml",content:ht()},{path:"ppt/slideMasters/_rels/slideMaster1.xml.rels",content:bt()},{path:"ppt/slideLayouts/slideLayout1.xml",content:xt()},{path:"ppt/slideLayouts/_rels/slideLayout1.xml.rels",content:Pt()}];if(o)i.push({path:"ppt/notesMasters/notesMaster1.xml",content:wt()}),i.push({path:"ppt/notesMasters/_rels/notesMaster1.xml.rels",content:Et()});return r.forEach((s,a)=>{let l=a+1;if(i.push({path:`ppt/slides/slide${l}.xml`,content:It(s,l,n)}),i.push({path:`ppt/slides/_rels/slide${l}.xml.rels`,content:kt(l,s.notes.length>0)}),s.notes.length>0)i.push({path:`ppt/notesSlides/notesSlide${l}.xml`,content:vt(s,l,n)}),i.push({path:`ppt/notesSlides/_rels/notesSlide${l}.xml.rels`,content:At(l)})}),Ae(i)}function Ae(e){let t=new TextEncoder,r=[],n=[],o=0;for(let l of e){let c=Mt(l.path),p=t.encode(c),u=typeof l.content==="string"?t.encode(l.content):l.content,d=Lt(u),g=F([x(67324752),f(20),f(2048),f(0),f(0),f(0),x(d),x(u.length),x(u.length),f(p.length),f(0),p,u]);r.push(g),n.push(F([x(33639248),f(20),f(20),f(2048),f(0),f(0),f(0),x(d),x(u.length),x(u.length),f(p.length),f(0),f(0),f(0),f(0),x(0),x(o),p])),o+=g.length}let i=o,s=F(n),a=F([x(101010256),f(0),f(0),f(e.length),f(e.length),x(s.length),x(i),f(0)]);return F([...r,s,a])}function ut(e){let t=e.map((n,o)=>`<Override PartName="/ppt/slides/slide${o+1}.xml" ContentType="application/vnd.openxmlformats-officedocument.presentationml.slide+xml"/>`).join(""),r=e.map((n,o)=>n.notes.length>0?`<Override PartName="/ppt/notesSlides/notesSlide${o+1}.xml" ContentType="application/vnd.openxmlformats-officedocument.presentationml.notesSlide+xml"/>`:"").join("");return C(['<Types xmlns="http://schemas.openxmlformats.org/package/2006/content-types">','<Default Extension="rels" ContentType="application/vnd.openxmlformats-package.relationships+xml"/>','<Default Extension="xml" ContentType="application/xml"/>','<Override PartName="/docProps/app.xml" ContentType="application/vnd.openxmlformats-officedocument.extended-properties+xml"/>','<Override PartName="/docProps/core.xml" ContentType="application/vnd.openxmlformats-package.core-properties+xml"/>','<Override PartName="/ppt/presentation.xml" ContentType="application/vnd.openxmlformats-officedocument.presentationml.presentation.main+xml"/>','<Override PartName="/ppt/theme/theme1.xml" ContentType="application/vnd.openxmlformats-officedocument.theme+xml"/>','<Override PartName="/ppt/slideMasters/slideMaster1.xml" ContentType="application/vnd.openxmlformats-officedocument.presentationml.slideMaster+xml"/>','<Override PartName="/ppt/slideLayouts/slideLayout1.xml" ContentType="application/vnd.openxmlformats-officedocument.presentationml.slideLayout+xml"/>',t,e.some((n)=>n.notes.length>0)?'<Override PartName="/ppt/notesMasters/notesMaster1.xml" ContentType="application/vnd.openxmlformats-officedocument.presentationml.notesMaster+xml"/>':"",r,"</Types>"])}function gt(){return C(['<Relationships xmlns="http://schemas.openxmlformats.org/package/2006/relationships">','<Relationship Id="rId1" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/officeDocument" Target="ppt/presentation.xml"/>','<Relationship Id="rId2" Type="http://schemas.openxmlformats.org/package/2006/relationships/metadata/core-properties" Target="docProps/core.xml"/>','<Relationship Id="rId3" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/extended-properties" Target="docProps/app.xml"/>',"</Relationships>"])}function mt(e){return C(['<Properties xmlns="http://schemas.openxmlformats.org/officeDocument/2006/extended-properties" xmlns:vt="http://schemas.openxmlformats.org/officeDocument/2006/docPropsVTypes">',"<Application>UIBot</Application>",`<Slides>${e}</Slides>`,"</Properties>"])}function ft(e){let t=new Date().toISOString();return C(['<cp:coreProperties xmlns:cp="http://schemas.openxmlformats.org/package/2006/metadata/core-properties" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:dcterms="http://purl.org/dc/terms/" xmlns:dcmitype="http://purl.org/dc/dcmitype/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">',`<dc:title>${E(e)}</dc:title>`,"<dc:creator>UIBot</dc:creator>",`<dcterms:created xsi:type="dcterms:W3CDTF">${t}</dcterms:created>`,`<dcterms:modified xsi:type="dcterms:W3CDTF">${t}</dcterms:modified>`,"</cp:coreProperties>"])}function yt(e,t){let r=Array.from({length:e},(n,o)=>`<p:sldId id="${256+o}" r:id="rId${o+2}"/>`).join("");return C(['<p:presentation xmlns:a="http://schemas.openxmlformats.org/drawingml/2006/main" xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships" xmlns:p="http://schemas.openxmlformats.org/presentationml/2006/main">','<p:sldMasterIdLst><p:sldMasterId id="2147483648" r:id="rId1"/></p:sldMasterIdLst>',t?'<p:notesMasterIdLst><p:notesMasterId r:id="rIdNotes"/></p:notesMasterIdLst>':"",`<p:sldIdLst>${r}</p:sldIdLst>`,'<p:sldSz cx="12192000" cy="6858000" type="screen16x9"/>','<p:notesSz cx="6858000" cy="9144000"/>',"</p:presentation>"])}function Ct(e,t){let r=[t?'<Relationship Id="rIdNotes" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/notesMaster" Target="notesMasters/notesMaster1.xml"/>':"",'<Relationship Id="rId1" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/slideMaster" Target="slideMasters/slideMaster1.xml"/>',...Array.from({length:e},(n,o)=>`<Relationship Id="rId${o+2}" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/slide" Target="slides/slide${o+1}.xml"/>`)].join("");return C([`<Relationships xmlns="http://schemas.openxmlformats.org/package/2006/relationships">${r}</Relationships>`])}function ht(){return C(['<p:sldMaster xmlns:a="http://schemas.openxmlformats.org/drawingml/2006/main" xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships" xmlns:p="http://schemas.openxmlformats.org/presentationml/2006/main">','<p:cSld><p:bg><p:bgPr><a:solidFill><a:srgbClr val="FFFFFF"/></a:solidFill></p:bgPr></p:bg><p:spTree><p:nvGrpSpPr><p:cNvPr id="1" name=""/><p:cNvGrpSpPr/><p:nvPr/></p:nvGrpSpPr><p:grpSpPr><a:xfrm><a:off x="0" y="0"/><a:ext cx="0" cy="0"/><a:chOff x="0" y="0"/><a:chExt cx="0" cy="0"/></a:xfrm></p:grpSpPr></p:spTree></p:cSld>','<p:clrMap bg1="lt1" tx1="dk1" bg2="lt2" tx2="dk2" accent1="accent1" accent2="accent2" accent3="accent3" accent4="accent4" accent5="accent5" accent6="accent6" hlink="hlink" folHlink="folHlink"/>','<p:sldLayoutIdLst><p:sldLayoutId id="2147483649" r:id="rId1"/></p:sldLayoutIdLst>',"<p:txStyles><p:titleStyle/><p:bodyStyle/><p:otherStyle/></p:txStyles>","</p:sldMaster>"])}function bt(){return C(['<Relationships xmlns="http://schemas.openxmlformats.org/package/2006/relationships">','<Relationship Id="rId1" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/slideLayout" Target="../slideLayouts/slideLayout1.xml"/>','<Relationship Id="rId2" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/theme" Target="../theme/theme1.xml"/>',"</Relationships>"])}function xt(){return C(['<p:sldLayout xmlns:a="http://schemas.openxmlformats.org/drawingml/2006/main" xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships" xmlns:p="http://schemas.openxmlformats.org/presentationml/2006/main" type="blank" preserve="1">','<p:cSld name="Blank"><p:spTree><p:nvGrpSpPr><p:cNvPr id="1" name=""/><p:cNvGrpSpPr/><p:nvPr/></p:nvGrpSpPr><p:grpSpPr><a:xfrm><a:off x="0" y="0"/><a:ext cx="0" cy="0"/><a:chOff x="0" y="0"/><a:chExt cx="0" cy="0"/></a:xfrm></p:grpSpPr></p:spTree></p:cSld>',"</p:sldLayout>"])}function Pt(){return C(['<Relationships xmlns="http://schemas.openxmlformats.org/package/2006/relationships">','<Relationship Id="rId1" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/slideMaster" Target="../slideMasters/slideMaster1.xml"/>',"</Relationships>"])}function kt(e,t){return C(['<Relationships xmlns="http://schemas.openxmlformats.org/package/2006/relationships">','<Relationship Id="rId1" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/slideLayout" Target="../slideLayouts/slideLayout1.xml"/>',t?`<Relationship Id="rId2" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/notesSlide" Target="../notesSlides/notesSlide${e}.xml"/>`:"","</Relationships>"])}function St(e){let t=[],r=[];for(let n of e.paragraphs){let o=n.text,i=!1,s=(c)=>{r.push(i?{...n,text:c,continued:!0}:{...n,text:c}),i=!0},a="",l=0;for(let c of o){let p=(c.codePointAt(0)??0)>255?2:/[MWmw]/.test(c)?1.8:1;if(l+p>64){let u=a.lastIndexOf(" "),d=u>0?u+1:a.length;s(a.slice(0,d)),a=a.slice(d),l=Array.from(a).reduce((g,m)=>g+((m.codePointAt(0)??0)>255?2:/[MWmw]/.test(m)?1.8:1),0)}if(r.length===8)t.push({...e,paragraphs:r}),r=[];a+=c,l+=p}if(a)s(a);if(r.length===8)t.push({...e,paragraphs:r}),r=[]}if(r.length>0||t.length===0)t.push({...e,paragraphs:r});return t}var ke=342900;function Rt(e){if(!e.list)return'<a:pPr><a:lnSpc><a:spcPct val="115000"/></a:lnSpc><a:spcAft><a:spcPts val="600"/></a:spcAft><a:buNone/></a:pPr>';let{kind:r,lvl:n}=e.list,o=ke*(n+1);if(e.continued)return`<a:pPr marL="${o}" lvl="${n}" indent="0"><a:lnSpc><a:spcPct val="115000"/></a:lnSpc><a:spcAft><a:spcPts val="600"/></a:spcAft><a:buNone/></a:pPr>`;return`<a:pPr marL="${o}" lvl="${n}" indent="-${ke}"><a:lnSpc><a:spcPct val="115000"/></a:lnSpc><a:spcAft><a:spcPts val="600"/></a:spcAft>${r==="ol"?'<a:buAutoNum type="arabicPeriod"/>':'<a:buFont typeface="Arial"/><a:buChar char="•"/>'}</a:pPr>`}function It(e,t,r=null){let n=e.paragraphs.map((o)=>`<a:p>${Rt(o)}<a:r><a:rPr ${Z(o.text,r)} sz="2200"/><a:t xml:space="preserve">${E(o.text)}</a:t></a:r></a:p>`).join("");return C(['<p:sld xmlns:a="http://schemas.openxmlformats.org/drawingml/2006/main" xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships" xmlns:p="http://schemas.openxmlformats.org/presentationml/2006/main">','<p:cSld><p:bg><p:bgPr><a:solidFill><a:srgbClr val="FFFFFF"/></a:solidFill></p:bgPr></p:bg><p:spTree>','<p:nvGrpSpPr><p:cNvPr id="1" name=""/><p:cNvGrpSpPr/><p:nvPr/></p:nvGrpSpPr><p:grpSpPr><a:xfrm><a:off x="0" y="0"/><a:ext cx="0" cy="0"/><a:chOff x="0" y="0"/><a:chExt cx="0" cy="0"/></a:xfrm></p:grpSpPr>',we(2,`Title ${t}`,e.title,685800,609600,10972800,914400,3600,!0,r),`<p:sp><p:nvSpPr><p:cNvPr id="3" name="Body ${t}"/><p:cNvSpPr txBox="1"/><p:nvPr/></p:nvSpPr><p:spPr><a:xfrm><a:off x="914400" y="1828800"/><a:ext cx="10363200" cy="4267200"/></a:xfrm><a:prstGeom prst="rect"><a:avLst/></a:prstGeom><a:noFill/></p:spPr><p:txBody><a:bodyPr wrap="square"/><a:lstStyle/>${n||"<a:p/>"}</p:txBody></p:sp>`,"</p:spTree></p:cSld>","</p:sld>"])}function vt(e,t,r=null){let n=e.notes.map((o)=>`<a:p><a:r><a:rPr ${Z(o,r)} sz="1800"/><a:t>${E(o)}</a:t></a:r></a:p>`).join("");return C(['<p:notes xmlns:a="http://schemas.openxmlformats.org/drawingml/2006/main" xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships" xmlns:p="http://schemas.openxmlformats.org/presentationml/2006/main">',"<p:cSld><p:spTree>",'<p:nvGrpSpPr><p:cNvPr id="1" name=""/><p:cNvGrpSpPr/><p:nvPr/></p:nvGrpSpPr><p:grpSpPr><a:xfrm><a:off x="0" y="0"/><a:ext cx="0" cy="0"/><a:chOff x="0" y="0"/><a:chExt cx="0" cy="0"/></a:xfrm></p:grpSpPr>',we(2,`Notes title ${t}`,e.title,685800,457200,5486400,457200,1600,!0,r),`<p:sp><p:nvSpPr><p:cNvPr id="3" name="Speaker notes ${t}"/><p:cNvSpPr txBox="1"/><p:nvPr><p:ph type="body" idx="1"/></p:nvPr></p:nvSpPr><p:spPr><a:xfrm><a:off x="685800" y="1066800"/><a:ext cx="5486400" cy="7010400"/></a:xfrm><a:prstGeom prst="rect"><a:avLst/></a:prstGeom><a:noFill/></p:spPr><p:txBody><a:bodyPr wrap="square"/><a:lstStyle/>${n||"<a:p/>"}</p:txBody></p:sp>`,"</p:spTree></p:cSld><p:clrMapOvr><a:masterClrMapping/></p:clrMapOvr>","</p:notes>"])}function At(e){return C(['<Relationships xmlns="http://schemas.openxmlformats.org/package/2006/relationships">',`<Relationship Id="rId1" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/slide" Target="../slides/slide${e}.xml"/>`,'<Relationship Id="rId2" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/notesMaster" Target="../notesMasters/notesMaster1.xml"/>',"</Relationships>"])}function wt(){return C(['<p:notesMaster xmlns:a="http://schemas.openxmlformats.org/drawingml/2006/main" xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships" xmlns:p="http://schemas.openxmlformats.org/presentationml/2006/main">','<p:cSld><p:spTree><p:nvGrpSpPr><p:cNvPr id="1" name=""/><p:cNvGrpSpPr/><p:nvPr/></p:nvGrpSpPr><p:grpSpPr><a:xfrm><a:off x="0" y="0"/><a:ext cx="0" cy="0"/><a:chOff x="0" y="0"/><a:chExt cx="0" cy="0"/></a:xfrm></p:grpSpPr></p:spTree></p:cSld>','<p:clrMap bg1="lt1" tx1="dk1" bg2="lt2" tx2="dk2" accent1="accent1" accent2="accent2" accent3="accent3" accent4="accent4" accent5="accent5" accent6="accent6" hlink="hlink" folHlink="folHlink"/>',"<p:notesStyle/>","</p:notesMaster>"])}function Et(){return C(['<Relationships xmlns="http://schemas.openxmlformats.org/package/2006/relationships">','<Relationship Id="rId1" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/theme" Target="../theme/theme1.xml"/>',"</Relationships>"])}function we(e,t,r,n,o,i,s,a,l,c=null){let p=l?' b="1"':"";return`<p:sp><p:nvSpPr><p:cNvPr id="${e}" name="${E(t)}"/><p:cNvSpPr txBox="1"/><p:nvPr/></p:nvSpPr><p:spPr><a:xfrm><a:off x="${n}" y="${o}"/><a:ext cx="${i}" cy="${s}"/></a:xfrm><a:prstGeom prst="rect"><a:avLst/></a:prstGeom><a:noFill/></p:spPr><p:txBody><a:bodyPr wrap="square"/><a:lstStyle/><a:p><a:r><a:rPr ${Z(r,c)} sz="${a}"${p}/><a:t>${E(r)}</a:t></a:r></a:p></p:txBody></p:sp>`}function _t(){return C(['<a:theme xmlns:a="http://schemas.openxmlformats.org/drawingml/2006/main" name="UIBot">','<a:themeElements><a:clrScheme name="UIBot"><a:dk1><a:srgbClr val="111111"/></a:dk1><a:lt1><a:srgbClr val="FFFFFF"/></a:lt1><a:dk2><a:srgbClr val="222222"/></a:dk2><a:lt2><a:srgbClr val="F5F5F5"/></a:lt2><a:accent1><a:srgbClr val="C15F3C"/></a:accent1><a:accent2><a:srgbClr val="3C7A89"/></a:accent2><a:accent3><a:srgbClr val="E0B44C"/></a:accent3><a:accent4><a:srgbClr val="6F6A5F"/></a:accent4><a:accent5><a:srgbClr val="8F4D2F"/></a:accent5><a:accent6><a:srgbClr val="4D5D53"/></a:accent6><a:hlink><a:srgbClr val="0563C1"/></a:hlink><a:folHlink><a:srgbClr val="954F72"/></a:folHlink></a:clrScheme><a:fontScheme name="UIBot"><a:majorFont><a:latin typeface="Arial"/><a:ea typeface=""/><a:cs typeface=""/></a:majorFont><a:minorFont><a:latin typeface="Arial"/><a:ea typeface=""/><a:cs typeface=""/></a:minorFont></a:fontScheme><a:fmtScheme name="UIBot"><a:fillStyleLst><a:solidFill><a:schemeClr val="phClr"/></a:solidFill><a:solidFill><a:schemeClr val="phClr"/></a:solidFill><a:solidFill><a:schemeClr val="phClr"/></a:solidFill></a:fillStyleLst><a:lnStyleLst><a:ln w="6350"><a:solidFill><a:schemeClr val="phClr"/></a:solidFill></a:ln><a:ln w="6350"><a:solidFill><a:schemeClr val="phClr"/></a:solidFill></a:ln><a:ln w="6350"><a:solidFill><a:schemeClr val="phClr"/></a:solidFill></a:ln></a:lnStyleLst><a:effectStyleLst><a:effectStyle><a:effectLst/></a:effectStyle><a:effectStyle><a:effectLst/></a:effectStyle><a:effectStyle><a:effectLst/></a:effectStyle></a:effectStyleLst><a:bgFillStyleLst><a:solidFill><a:schemeClr val="phClr"/></a:solidFill><a:solidFill><a:schemeClr val="phClr"/></a:solidFill><a:solidFill><a:schemeClr val="phClr"/></a:solidFill></a:bgFillStyleLst></a:fmtScheme></a:themeElements>',"</a:theme>"])}function C(e){return`<?xml version="1.0" encoding="UTF-8" standalone="yes"?>${e.join("")}`}function w(e,t){let r=new RegExp(`<${t}\\b[^>]*>[\\s\\S]*?<\\/${t}>`,"gi");return e.match(r)??[]}function Tt(e){let t=/<([a-z][\w:-]*)\b(?=[^>]*(?:data-(?:pptx-)?slide(?:-container)?\b|class\s*=\s*["'][^"']*\bslide\b))[^>]*>[\s\S]*?<\/\1>/gi;return e.match(t)??[]}function Dt(e){let t=/<([a-z][\w:-]*)\b(?=[^>]*(?:\sdata-notes(?:\s|=|>)|class\s*=\s*["'][^"']*(?<![\w-])(?:notes|note|speaker-note)(?![\w-])))[^>]*>[\s\S]*?<\/\1>/gi;return e.match(t)??[]}function U(e,t){let r=e;for(let n of t)r=r.replace(new RegExp(`<${n}\\b[^>]*>[\\s\\S]*?<\\/${n}>`,"gi"),"");return r}function Ee(e,t){for(let r of t){let n=w(e,r)[0];if(n)return v(n)}return""}function Se(e,t){let n=new RegExp(`\\b${t}\\s*=\\s*(?:"([^"]*)"|'([^']*)')`,"i").exec(e);return n?.[1]??n?.[2]??""}function v(e){return e.replace(/<br\s*\/?>/gi,`
10
+ `).map(st).filter((m)=>m.text);return{title:k(l),bullets:c,body:p,notes:u,paragraphs:g}})}function dt(e,t="UIBot artifact"){let n=pt(e).flatMap(St),r=at(e),o=n.some((s)=>s.notes.length>0),i=[{path:"[Content_Types].xml",content:ut(n)},{path:"_rels/.rels",content:gt()},{path:"docProps/app.xml",content:mt(n.length)},{path:"docProps/core.xml",content:ft(t)},{path:"ppt/presentation.xml",content:yt(n.length,o)},{path:"ppt/_rels/presentation.xml.rels",content:Ct(n.length,o)},{path:"ppt/theme/theme1.xml",content:_t()},{path:"ppt/slideMasters/slideMaster1.xml",content:ht()},{path:"ppt/slideMasters/_rels/slideMaster1.xml.rels",content:bt()},{path:"ppt/slideLayouts/slideLayout1.xml",content:xt()},{path:"ppt/slideLayouts/_rels/slideLayout1.xml.rels",content:Pt()}];if(o)i.push({path:"ppt/notesMasters/notesMaster1.xml",content:wt()}),i.push({path:"ppt/notesMasters/_rels/notesMaster1.xml.rels",content:Et()});return n.forEach((s,a)=>{let l=a+1;if(i.push({path:`ppt/slides/slide${l}.xml`,content:It(s,l,r)}),i.push({path:`ppt/slides/_rels/slide${l}.xml.rels`,content:kt(l,s.notes.length>0)}),s.notes.length>0)i.push({path:`ppt/notesSlides/notesSlide${l}.xml`,content:vt(s,l,r)}),i.push({path:`ppt/notesSlides/_rels/notesSlide${l}.xml.rels`,content:At(l)})}),Ae(i)}function Ae(e){let t=new TextEncoder,n=[],r=[],o=0;for(let l of e){let c=Mt(l.path),p=t.encode(c),u=typeof l.content==="string"?t.encode(l.content):l.content,d=Lt(u),g=F([x(67324752),f(20),f(2048),f(0),f(0),f(0),x(d),x(u.length),x(u.length),f(p.length),f(0),p,u]);n.push(g),r.push(F([x(33639248),f(20),f(20),f(2048),f(0),f(0),f(0),x(d),x(u.length),x(u.length),f(p.length),f(0),f(0),f(0),f(0),x(0),x(o),p])),o+=g.length}let i=o,s=F(r),a=F([x(101010256),f(0),f(0),f(e.length),f(e.length),x(s.length),x(i),f(0)]);return F([...n,s,a])}function ut(e){let t=e.map((r,o)=>`<Override PartName="/ppt/slides/slide${o+1}.xml" ContentType="application/vnd.openxmlformats-officedocument.presentationml.slide+xml"/>`).join(""),n=e.map((r,o)=>r.notes.length>0?`<Override PartName="/ppt/notesSlides/notesSlide${o+1}.xml" ContentType="application/vnd.openxmlformats-officedocument.presentationml.notesSlide+xml"/>`:"").join("");return C(['<Types xmlns="http://schemas.openxmlformats.org/package/2006/content-types">','<Default Extension="rels" ContentType="application/vnd.openxmlformats-package.relationships+xml"/>','<Default Extension="xml" ContentType="application/xml"/>','<Override PartName="/docProps/app.xml" ContentType="application/vnd.openxmlformats-officedocument.extended-properties+xml"/>','<Override PartName="/docProps/core.xml" ContentType="application/vnd.openxmlformats-package.core-properties+xml"/>','<Override PartName="/ppt/presentation.xml" ContentType="application/vnd.openxmlformats-officedocument.presentationml.presentation.main+xml"/>','<Override PartName="/ppt/theme/theme1.xml" ContentType="application/vnd.openxmlformats-officedocument.theme+xml"/>','<Override PartName="/ppt/slideMasters/slideMaster1.xml" ContentType="application/vnd.openxmlformats-officedocument.presentationml.slideMaster+xml"/>','<Override PartName="/ppt/slideLayouts/slideLayout1.xml" ContentType="application/vnd.openxmlformats-officedocument.presentationml.slideLayout+xml"/>',t,e.some((r)=>r.notes.length>0)?'<Override PartName="/ppt/notesMasters/notesMaster1.xml" ContentType="application/vnd.openxmlformats-officedocument.presentationml.notesMaster+xml"/>':"",n,"</Types>"])}function gt(){return C(['<Relationships xmlns="http://schemas.openxmlformats.org/package/2006/relationships">','<Relationship Id="rId1" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/officeDocument" Target="ppt/presentation.xml"/>','<Relationship Id="rId2" Type="http://schemas.openxmlformats.org/package/2006/relationships/metadata/core-properties" Target="docProps/core.xml"/>','<Relationship Id="rId3" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/extended-properties" Target="docProps/app.xml"/>',"</Relationships>"])}function mt(e){return C(['<Properties xmlns="http://schemas.openxmlformats.org/officeDocument/2006/extended-properties" xmlns:vt="http://schemas.openxmlformats.org/officeDocument/2006/docPropsVTypes">',"<Application>UIBot</Application>",`<Slides>${e}</Slides>`,"</Properties>"])}function ft(e){let t=new Date().toISOString();return C(['<cp:coreProperties xmlns:cp="http://schemas.openxmlformats.org/package/2006/metadata/core-properties" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:dcterms="http://purl.org/dc/terms/" xmlns:dcmitype="http://purl.org/dc/dcmitype/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">',`<dc:title>${E(e)}</dc:title>`,"<dc:creator>UIBot</dc:creator>",`<dcterms:created xsi:type="dcterms:W3CDTF">${t}</dcterms:created>`,`<dcterms:modified xsi:type="dcterms:W3CDTF">${t}</dcterms:modified>`,"</cp:coreProperties>"])}function yt(e,t){let n=Array.from({length:e},(r,o)=>`<p:sldId id="${256+o}" r:id="rId${o+2}"/>`).join("");return C(['<p:presentation xmlns:a="http://schemas.openxmlformats.org/drawingml/2006/main" xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships" xmlns:p="http://schemas.openxmlformats.org/presentationml/2006/main">','<p:sldMasterIdLst><p:sldMasterId id="2147483648" r:id="rId1"/></p:sldMasterIdLst>',t?'<p:notesMasterIdLst><p:notesMasterId r:id="rIdNotes"/></p:notesMasterIdLst>':"",`<p:sldIdLst>${n}</p:sldIdLst>`,'<p:sldSz cx="12192000" cy="6858000" type="screen16x9"/>','<p:notesSz cx="6858000" cy="9144000"/>',"</p:presentation>"])}function Ct(e,t){let n=[t?'<Relationship Id="rIdNotes" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/notesMaster" Target="notesMasters/notesMaster1.xml"/>':"",'<Relationship Id="rId1" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/slideMaster" Target="slideMasters/slideMaster1.xml"/>',...Array.from({length:e},(r,o)=>`<Relationship Id="rId${o+2}" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/slide" Target="slides/slide${o+1}.xml"/>`)].join("");return C([`<Relationships xmlns="http://schemas.openxmlformats.org/package/2006/relationships">${n}</Relationships>`])}function ht(){return C(['<p:sldMaster xmlns:a="http://schemas.openxmlformats.org/drawingml/2006/main" xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships" xmlns:p="http://schemas.openxmlformats.org/presentationml/2006/main">','<p:cSld><p:bg><p:bgPr><a:solidFill><a:srgbClr val="FFFFFF"/></a:solidFill></p:bgPr></p:bg><p:spTree><p:nvGrpSpPr><p:cNvPr id="1" name=""/><p:cNvGrpSpPr/><p:nvPr/></p:nvGrpSpPr><p:grpSpPr><a:xfrm><a:off x="0" y="0"/><a:ext cx="0" cy="0"/><a:chOff x="0" y="0"/><a:chExt cx="0" cy="0"/></a:xfrm></p:grpSpPr></p:spTree></p:cSld>','<p:clrMap bg1="lt1" tx1="dk1" bg2="lt2" tx2="dk2" accent1="accent1" accent2="accent2" accent3="accent3" accent4="accent4" accent5="accent5" accent6="accent6" hlink="hlink" folHlink="folHlink"/>','<p:sldLayoutIdLst><p:sldLayoutId id="2147483649" r:id="rId1"/></p:sldLayoutIdLst>',"<p:txStyles><p:titleStyle/><p:bodyStyle/><p:otherStyle/></p:txStyles>","</p:sldMaster>"])}function bt(){return C(['<Relationships xmlns="http://schemas.openxmlformats.org/package/2006/relationships">','<Relationship Id="rId1" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/slideLayout" Target="../slideLayouts/slideLayout1.xml"/>','<Relationship Id="rId2" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/theme" Target="../theme/theme1.xml"/>',"</Relationships>"])}function xt(){return C(['<p:sldLayout xmlns:a="http://schemas.openxmlformats.org/drawingml/2006/main" xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships" xmlns:p="http://schemas.openxmlformats.org/presentationml/2006/main" type="blank" preserve="1">','<p:cSld name="Blank"><p:spTree><p:nvGrpSpPr><p:cNvPr id="1" name=""/><p:cNvGrpSpPr/><p:nvPr/></p:nvGrpSpPr><p:grpSpPr><a:xfrm><a:off x="0" y="0"/><a:ext cx="0" cy="0"/><a:chOff x="0" y="0"/><a:chExt cx="0" cy="0"/></a:xfrm></p:grpSpPr></p:spTree></p:cSld>',"</p:sldLayout>"])}function Pt(){return C(['<Relationships xmlns="http://schemas.openxmlformats.org/package/2006/relationships">','<Relationship Id="rId1" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/slideMaster" Target="../slideMasters/slideMaster1.xml"/>',"</Relationships>"])}function kt(e,t){return C(['<Relationships xmlns="http://schemas.openxmlformats.org/package/2006/relationships">','<Relationship Id="rId1" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/slideLayout" Target="../slideLayouts/slideLayout1.xml"/>',t?`<Relationship Id="rId2" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/notesSlide" Target="../notesSlides/notesSlide${e}.xml"/>`:"","</Relationships>"])}function St(e){let t=[],n=[];for(let r of e.paragraphs){let o=r.text,i=!1,s=(c)=>{n.push(i?{...r,text:c,continued:!0}:{...r,text:c}),i=!0},a="",l=0;for(let c of o){let p=(c.codePointAt(0)??0)>255?2:/[MWmw]/.test(c)?1.8:1;if(l+p>64){let u=a.lastIndexOf(" "),d=u>0?u+1:a.length;s(a.slice(0,d)),a=a.slice(d),l=Array.from(a).reduce((g,m)=>g+((m.codePointAt(0)??0)>255?2:/[MWmw]/.test(m)?1.8:1),0)}if(n.length===8)t.push({...e,paragraphs:n}),n=[];a+=c,l+=p}if(a)s(a);if(n.length===8)t.push({...e,paragraphs:n}),n=[]}if(n.length>0||t.length===0)t.push({...e,paragraphs:n});return t}var ke=342900;function Rt(e){if(!e.list)return'<a:pPr><a:lnSpc><a:spcPct val="115000"/></a:lnSpc><a:spcAft><a:spcPts val="600"/></a:spcAft><a:buNone/></a:pPr>';let{kind:n,lvl:r}=e.list,o=ke*(r+1);if(e.continued)return`<a:pPr marL="${o}" lvl="${r}" indent="0"><a:lnSpc><a:spcPct val="115000"/></a:lnSpc><a:spcAft><a:spcPts val="600"/></a:spcAft><a:buNone/></a:pPr>`;return`<a:pPr marL="${o}" lvl="${r}" indent="-${ke}"><a:lnSpc><a:spcPct val="115000"/></a:lnSpc><a:spcAft><a:spcPts val="600"/></a:spcAft>${n==="ol"?'<a:buAutoNum type="arabicPeriod"/>':'<a:buFont typeface="Arial"/><a:buChar char="•"/>'}</a:pPr>`}function It(e,t,n=null){let r=e.paragraphs.map((o)=>`<a:p>${Rt(o)}<a:r><a:rPr ${Z(o.text,n)} sz="2200"/><a:t xml:space="preserve">${E(o.text)}</a:t></a:r></a:p>`).join("");return C(['<p:sld xmlns:a="http://schemas.openxmlformats.org/drawingml/2006/main" xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships" xmlns:p="http://schemas.openxmlformats.org/presentationml/2006/main">','<p:cSld><p:bg><p:bgPr><a:solidFill><a:srgbClr val="FFFFFF"/></a:solidFill></p:bgPr></p:bg><p:spTree>','<p:nvGrpSpPr><p:cNvPr id="1" name=""/><p:cNvGrpSpPr/><p:nvPr/></p:nvGrpSpPr><p:grpSpPr><a:xfrm><a:off x="0" y="0"/><a:ext cx="0" cy="0"/><a:chOff x="0" y="0"/><a:chExt cx="0" cy="0"/></a:xfrm></p:grpSpPr>',we(2,`Title ${t}`,e.title,685800,609600,10972800,914400,3600,!0,n),`<p:sp><p:nvSpPr><p:cNvPr id="3" name="Body ${t}"/><p:cNvSpPr txBox="1"/><p:nvPr/></p:nvSpPr><p:spPr><a:xfrm><a:off x="914400" y="1828800"/><a:ext cx="10363200" cy="4267200"/></a:xfrm><a:prstGeom prst="rect"><a:avLst/></a:prstGeom><a:noFill/></p:spPr><p:txBody><a:bodyPr wrap="square"/><a:lstStyle/>${r||"<a:p/>"}</p:txBody></p:sp>`,"</p:spTree></p:cSld>","</p:sld>"])}function vt(e,t,n=null){let r=e.notes.map((o)=>`<a:p><a:r><a:rPr ${Z(o,n)} sz="1800"/><a:t>${E(o)}</a:t></a:r></a:p>`).join("");return C(['<p:notes xmlns:a="http://schemas.openxmlformats.org/drawingml/2006/main" xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships" xmlns:p="http://schemas.openxmlformats.org/presentationml/2006/main">',"<p:cSld><p:spTree>",'<p:nvGrpSpPr><p:cNvPr id="1" name=""/><p:cNvGrpSpPr/><p:nvPr/></p:nvGrpSpPr><p:grpSpPr><a:xfrm><a:off x="0" y="0"/><a:ext cx="0" cy="0"/><a:chOff x="0" y="0"/><a:chExt cx="0" cy="0"/></a:xfrm></p:grpSpPr>',we(2,`Notes title ${t}`,e.title,685800,457200,5486400,457200,1600,!0,n),`<p:sp><p:nvSpPr><p:cNvPr id="3" name="Speaker notes ${t}"/><p:cNvSpPr txBox="1"/><p:nvPr><p:ph type="body" idx="1"/></p:nvPr></p:nvSpPr><p:spPr><a:xfrm><a:off x="685800" y="1066800"/><a:ext cx="5486400" cy="7010400"/></a:xfrm><a:prstGeom prst="rect"><a:avLst/></a:prstGeom><a:noFill/></p:spPr><p:txBody><a:bodyPr wrap="square"/><a:lstStyle/>${r||"<a:p/>"}</p:txBody></p:sp>`,"</p:spTree></p:cSld><p:clrMapOvr><a:masterClrMapping/></p:clrMapOvr>","</p:notes>"])}function At(e){return C(['<Relationships xmlns="http://schemas.openxmlformats.org/package/2006/relationships">',`<Relationship Id="rId1" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/slide" Target="../slides/slide${e}.xml"/>`,'<Relationship Id="rId2" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/notesMaster" Target="../notesMasters/notesMaster1.xml"/>',"</Relationships>"])}function wt(){return C(['<p:notesMaster xmlns:a="http://schemas.openxmlformats.org/drawingml/2006/main" xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships" xmlns:p="http://schemas.openxmlformats.org/presentationml/2006/main">','<p:cSld><p:spTree><p:nvGrpSpPr><p:cNvPr id="1" name=""/><p:cNvGrpSpPr/><p:nvPr/></p:nvGrpSpPr><p:grpSpPr><a:xfrm><a:off x="0" y="0"/><a:ext cx="0" cy="0"/><a:chOff x="0" y="0"/><a:chExt cx="0" cy="0"/></a:xfrm></p:grpSpPr></p:spTree></p:cSld>','<p:clrMap bg1="lt1" tx1="dk1" bg2="lt2" tx2="dk2" accent1="accent1" accent2="accent2" accent3="accent3" accent4="accent4" accent5="accent5" accent6="accent6" hlink="hlink" folHlink="folHlink"/>',"<p:notesStyle/>","</p:notesMaster>"])}function Et(){return C(['<Relationships xmlns="http://schemas.openxmlformats.org/package/2006/relationships">','<Relationship Id="rId1" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/theme" Target="../theme/theme1.xml"/>',"</Relationships>"])}function we(e,t,n,r,o,i,s,a,l,c=null){let p=l?' b="1"':"";return`<p:sp><p:nvSpPr><p:cNvPr id="${e}" name="${E(t)}"/><p:cNvSpPr txBox="1"/><p:nvPr/></p:nvSpPr><p:spPr><a:xfrm><a:off x="${r}" y="${o}"/><a:ext cx="${i}" cy="${s}"/></a:xfrm><a:prstGeom prst="rect"><a:avLst/></a:prstGeom><a:noFill/></p:spPr><p:txBody><a:bodyPr wrap="square"/><a:lstStyle/><a:p><a:r><a:rPr ${Z(n,c)} sz="${a}"${p}/><a:t>${E(n)}</a:t></a:r></a:p></p:txBody></p:sp>`}function _t(){return C(['<a:theme xmlns:a="http://schemas.openxmlformats.org/drawingml/2006/main" name="UIBot">','<a:themeElements><a:clrScheme name="UIBot"><a:dk1><a:srgbClr val="111111"/></a:dk1><a:lt1><a:srgbClr val="FFFFFF"/></a:lt1><a:dk2><a:srgbClr val="222222"/></a:dk2><a:lt2><a:srgbClr val="F5F5F5"/></a:lt2><a:accent1><a:srgbClr val="C15F3C"/></a:accent1><a:accent2><a:srgbClr val="3C7A89"/></a:accent2><a:accent3><a:srgbClr val="E0B44C"/></a:accent3><a:accent4><a:srgbClr val="6F6A5F"/></a:accent4><a:accent5><a:srgbClr val="8F4D2F"/></a:accent5><a:accent6><a:srgbClr val="4D5D53"/></a:accent6><a:hlink><a:srgbClr val="0563C1"/></a:hlink><a:folHlink><a:srgbClr val="954F72"/></a:folHlink></a:clrScheme><a:fontScheme name="UIBot"><a:majorFont><a:latin typeface="Arial"/><a:ea typeface=""/><a:cs typeface=""/></a:majorFont><a:minorFont><a:latin typeface="Arial"/><a:ea typeface=""/><a:cs typeface=""/></a:minorFont></a:fontScheme><a:fmtScheme name="UIBot"><a:fillStyleLst><a:solidFill><a:schemeClr val="phClr"/></a:solidFill><a:solidFill><a:schemeClr val="phClr"/></a:solidFill><a:solidFill><a:schemeClr val="phClr"/></a:solidFill></a:fillStyleLst><a:lnStyleLst><a:ln w="6350"><a:solidFill><a:schemeClr val="phClr"/></a:solidFill></a:ln><a:ln w="6350"><a:solidFill><a:schemeClr val="phClr"/></a:solidFill></a:ln><a:ln w="6350"><a:solidFill><a:schemeClr val="phClr"/></a:solidFill></a:ln></a:lnStyleLst><a:effectStyleLst><a:effectStyle><a:effectLst/></a:effectStyle><a:effectStyle><a:effectLst/></a:effectStyle><a:effectStyle><a:effectLst/></a:effectStyle></a:effectStyleLst><a:bgFillStyleLst><a:solidFill><a:schemeClr val="phClr"/></a:solidFill><a:solidFill><a:schemeClr val="phClr"/></a:solidFill><a:solidFill><a:schemeClr val="phClr"/></a:solidFill></a:bgFillStyleLst></a:fmtScheme></a:themeElements>',"</a:theme>"])}function C(e){return`<?xml version="1.0" encoding="UTF-8" standalone="yes"?>${e.join("")}`}function w(e,t){let n=new RegExp(`<${t}\\b[^>]*>[\\s\\S]*?<\\/${t}>`,"gi");return e.match(n)??[]}function Tt(e){let t=/<([a-z][\w:-]*)\b(?=[^>]*(?:data-(?:pptx-)?slide(?:-container)?\b|class\s*=\s*["'][^"']*\bslide\b))[^>]*>[\s\S]*?<\/\1>/gi;return e.match(t)??[]}function Dt(e){let t=/<([a-z][\w:-]*)\b(?=[^>]*(?:\sdata-notes(?:\s|=|>)|class\s*=\s*["'][^"']*(?<![\w-])(?:notes|note|speaker-note)(?![\w-])))[^>]*>[\s\S]*?<\/\1>/gi;return e.match(t)??[]}function U(e,t){let n=e;for(let r of t)n=n.replace(new RegExp(`<${r}\\b[^>]*>[\\s\\S]*?<\\/${r}>`,"gi"),"");return n}function Ee(e,t){for(let n of t){let r=w(e,n)[0];if(r)return v(r)}return""}function Se(e,t){let r=new RegExp(`\\b${t}\\s*=\\s*(?:"([^"]*)"|'([^']*)')`,"i").exec(e);return r?.[1]??r?.[2]??""}function v(e){return e.replace(/<br\s*\/?>/gi,`
11
11
  `).replace(/<[^>]+>/g," ").replace(/&nbsp;/g," ").replace(/&amp;/g,"&").replace(/&lt;/g,"<").replace(/&gt;/g,">").replace(/&quot;/g,'"').replace(/&#39;/g,"'").replace(/&#(?:10|13);/g,`
12
- `)}function k(e){return e.replace(/\s+/g," ").trim()}function Ot(e){return k(Ee(e,["title","h1","h2"]))||null}function _e(e){return Array.from(e.trim().replace(/[^\p{L}\p{N}\p{M}_.-]+/gu,"-").replace(/^[.-]+|[.-]+$/g,"")).slice(0,80).join("")||"artifact"}function Ft(e){let r=e.replaceAll("\\","/").replace(/^\/+/,"").split("/").filter(Boolean);if(r.length===0||r.some((n)=>n==="."||n===".."))return null;return r}function Mt(e){let t=Ft(e);if(!t)throw Error(`invalid zip path: ${e}`);return t.join("/")}function Te(e){return e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}function E(e){return Te(e).replace(/"/g,"&quot;").replace(/'/g,"&apos;")}function Re(e){return new TextEncoder().encode(e)}function F(e){let t=e.reduce((o,i)=>o+i.length,0),r=new Uint8Array(t),n=0;for(let o of e)r.set(o,n),n+=o.length;return r}function f(e){let t=new Uint8Array(2);return new DataView(t.buffer).setUint16(0,e,!0),t}function x(e){let t=new Uint8Array(4);return new DataView(t.buffer).setUint32(0,e>>>0,!0),t}var Ie=null;function Lt(e){let t=Ie??Bt();Ie=t;let r=4294967295;for(let n of e)r=t[(r^n)&255]^r>>>8;return(r^4294967295)>>>0}function Bt(){let e=new Uint32Array(256);for(let t=0;t<256;t++){let r=t;for(let n=0;n<8;n++)r=r&1?3988292384^r>>>1:r>>>1;e[t]=r>>>0}return e}async function Nt(e,t){if(!oe(e))throw Error("Invalid application snapshot");if(e.uibotCommit!==t)throw Error("Application toolchain mismatch");let r=structuredClone(e),n={version:"2.0",pages:[{id:"main",path:"/",blocks:[{id:"collection_app",type:"CollectionApplication",props:{buildId:r.id}}]}]},o=ee({components:{CollectionApplication:{name:"CollectionApplication",description:"Version-bound read-only paged Collection preview",category:"app",level:"L5",props:{buildId:{type:"string"}}}}}),i=await xe(n,o,{strict:!0});if(i.gaps.length)throw Error("Application compile gaps");return{build:r,source:n,spec:i.spec}}async function ko(e,t){let r=await Nt(e,t),n=["# Collection application","","Read-only generated application. Inject an authenticated PagedCollectionApplicationClient in App.tsx; its rows port must use the version-fenced build endpoint. No credentials or records are included.","",`UIBot source: ${e.uibotCommit}`,`Build: ${e.id}`,`Schema: ${e.descriptor.schemaVersion}; view: ${e.view.id}@${e.view.version}`,"","Deployment and rollback require operator configuration; this archive is not a deployment receipt."].join(`
12
+ `)}function k(e){return e.replace(/\s+/g," ").trim()}function Ot(e){return k(Ee(e,["title","h1","h2"]))||null}function _e(e){return Array.from(e.trim().replace(/[^\p{L}\p{N}\p{M}_.-]+/gu,"-").replace(/^[.-]+|[.-]+$/g,"")).slice(0,80).join("")||"artifact"}function Ft(e){let n=e.replaceAll("\\","/").replace(/^\/+/,"").split("/").filter(Boolean);if(n.length===0||n.some((r)=>r==="."||r===".."))return null;return n}function Mt(e){let t=Ft(e);if(!t)throw Error(`invalid zip path: ${e}`);return t.join("/")}function Te(e){return e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}function E(e){return Te(e).replace(/"/g,"&quot;").replace(/'/g,"&apos;")}function Re(e){return new TextEncoder().encode(e)}function F(e){let t=e.reduce((o,i)=>o+i.length,0),n=new Uint8Array(t),r=0;for(let o of e)n.set(o,r),r+=o.length;return n}function f(e){let t=new Uint8Array(2);return new DataView(t.buffer).setUint16(0,e,!0),t}function x(e){let t=new Uint8Array(4);return new DataView(t.buffer).setUint32(0,e>>>0,!0),t}var Ie=null;function Lt(e){let t=Ie??Bt();Ie=t;let n=4294967295;for(let r of e)n=t[(n^r)&255]^n>>>8;return(n^4294967295)>>>0}function Bt(){let e=new Uint32Array(256);for(let t=0;t<256;t++){let n=t;for(let r=0;r<8;r++)n=n&1?3988292384^n>>>1:n>>>1;e[t]=n>>>0}return e}async function Nt(e,t){if(!oe(e))throw Error("Invalid application snapshot");if(e.uibotCommit!==t)throw Error("Application toolchain mismatch");let n=structuredClone(e),r={version:"2.0",pages:[{id:"main",path:"/",blocks:[{id:"collection_app",type:"CollectionApplication",props:{buildId:n.id}}]}]},o=ee({components:{CollectionApplication:{name:"CollectionApplication",description:"Version-bound read-only paged Collection preview",category:"app",level:"L5",props:{buildId:{type:"string"}}}}}),i=await xe(r,o,{strict:!0});if(i.gaps.length)throw Error("Application compile gaps");return{build:n,source:r,spec:i.spec}}async function ko(e,t){let n=await Nt(e,t),r=["# Collection application","","Read-only generated application. Inject an authenticated PagedCollectionApplicationClient in App.tsx; its rows port must use the version-fenced build endpoint. No credentials or records are included.","",`UIBot source: ${e.uibotCommit}`,`Build: ${e.id}`,`Schema: ${e.descriptor.schemaVersion}; view: ${e.view.id}@${e.view.version}`,"","Deployment and rollback require operator configuration; this archive is not a deployment receipt."].join(`
13
13
  `),o=`import React from "react";
14
14
  import { CollectionApplicationPreview } from "@uibot/renderer-react/collection-application";
15
15
  import type { CompiledCollectionApplication, PagedCollectionApplicationClient } from "@uibot/contracts";
16
16
  import artifact from "./application.json";
17
17
  const application = artifact as CompiledCollectionApplication;
18
18
  export default function App({ client }: { client: Pick<PagedCollectionApplicationClient, "rows"> }) { return <CollectionApplicationPreview application={application} client={client} />; }
19
- `;return ve({format:"zip",title:"collection-application",source:n,files:[{path:"application.json",content:JSON.stringify(r,null,2)},{path:"source.uibot.json",content:JSON.stringify(r.source,null,2)},{path:"App.tsx",content:`import React from "react";
19
+ `;return ve({format:"zip",title:"collection-application",source:r,files:[{path:"application.json",content:JSON.stringify(n,null,2)},{path:"source.uibot.json",content:JSON.stringify(n.source,null,2)},{path:"App.tsx",content:`import React from "react";
20
20
  import { CollectionApplicationPreview } from "@uibot/renderer-react/collection-application";
21
21
  import type { CompiledCollectionApplication, PagedCollectionApplicationClient } from "@uibot/contracts";
22
22
  import artifact from "./application.json";
23
23
  const application = artifact as CompiledCollectionApplication;
24
24
  export default function App({ client }: { client: Pick<PagedCollectionApplicationClient, "rows"> }) { return <CollectionApplicationPreview application={application} client={client} />; }
25
- `},{path:"README.md",content:n}]})}export{Nt as compileCollectionApplication,ko as exportCollectionApplication};
25
+ `},{path:"README.md",content:r}]})}export{Nt as compileCollectionApplication,ko as exportCollectionApplication};
@@ -94,6 +94,22 @@ export interface CreateCreationHandlerOptions {
94
94
  * that project version. A stale or widened claim does not commit or re-authorize.
95
95
  */
96
96
  authorizeRecovery?: CreationRecoveryAuthorizer;
97
+ /**
98
+ * Optional runtime check of a generated HTML candidate before it is committed (e.g. a headless
99
+ * render that reports script errors or a blank page). A failed check fails the run; a check that
100
+ * throws fails it as unavailable, never as passed.
101
+ */
102
+ htmlSelfCheck?: CreationHtmlSelfCheck;
97
103
  }
104
+ export type CreationHtmlSelfCheckResult = {
105
+ ok: true;
106
+ } | {
107
+ ok: false;
108
+ detail: string;
109
+ };
110
+ export type CreationHtmlSelfCheck = (input: {
111
+ html: string;
112
+ signal: AbortSignal;
113
+ }) => Promise<CreationHtmlSelfCheckResult>;
98
114
  /** Durable single-service workflow: generate -> validate -> conditional commit. */
99
115
  export declare function createUIBotStudioCreationHandler(options: CreateCreationHandlerOptions): Promise<(request: Request) => Promise<Response | null>>;