@maxhealth.tech/prefab 0.2.12 → 0.2.13

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,9 +1,9 @@
1
- (()=>{class J4{data={};subscribers=new Map;globalSubscribers=new Set;generation=0;constructor($){if($)this.data=structuredClone($)}get($){return x1(this.data,$)}getAll(){return this.data}set($,Z){x4(this.data,$,Z),this.notify($)}toggle($){let Z=this.get($),J=Z==null||Z===!1||Z===0||Z==="";this.set($,J)}append($,Z,J){let q=this.get($);if(!Array.isArray(q)){this.set($,[Z]);return}if(J!==void 0)q.splice(J,0,Z);else q.push(Z);this.notify($)}pop($,Z){let J=this.get($);if(!Array.isArray(J))return;if(typeof Z==="number")J.splice(Z,1);else{let q=J.indexOf(Z);if(q>=0)J.splice(q,1)}this.notify($)}merge($){for(let[Z,J]of Object.entries($))x4(this.data,Z,J);for(let Z of Object.keys($))this.notify(Z)}subscribe($,Z){if(!this.subscribers.has($))this.subscribers.set($,new Set);return this.subscribers.get($)?.add(Z),()=>this.subscribers.get($)?.delete(Z)}subscribeAll($){return this.globalSubscribers.add($),()=>this.globalSubscribers.delete($)}notify($){this.generation++;let Z=$.split(".");for(let J=1;J<=Z.length;J++){let q=Z.slice(0,J).join("."),U=this.subscribers.get(q);if(U)U.forEach((Q)=>Q())}this.globalSubscribers.forEach((J)=>J())}}function x1($,Z){let J=Z.split("."),q=$;for(let U of J){if(q==null||typeof q!=="object")return;q=q[U]}return q}var p1=new Set(["__proto__","constructor","prototype"]);function x4($,Z,J){let q=Z.split(".");if(q.some((Q)=>p1.has(Q))){console.warn(`[prefab] Blocked prototype pollution attempt: ${Z}`);return}let U=$;for(let Q=0;Q<q.length-1;Q++){let Y=q[Q];if(U[Y]==null||typeof U[Y]!=="object")U[Y]={};U=U[Y]}U[q[q.length-1]]=J}var t=new Map;function V4($,Z){if(t.has($)&&t.get($)!==Z)console.warn(`[prefab] pipe "${$}" re-registered`);t.set($,Z)}function I4($){return t.delete($)}function p4(){return[...t.keys()]}function c4($){return t.get($)}var s4=-1,R4=new Map,c1=/\{\{\s*(.+?)\s*\}\}/g;function u($){return typeof $==="string"&&$.includes("{{")&&$.includes("}}")}function x($,Z,J){let q=$.trim();if(q.startsWith("{{")&&q.endsWith("}}")&&o1(q,"{{")===1){let U=q.slice(2,-2).trim();return l4(U,Z,J)}return $.replace(c1,(U,Q)=>{let Y=l4(Q.trim(),Z,J);return Y==null?"":String(Y)})}function l4($,Z,J){let[q,...U]=n1($),Q=h(q.trim(),Z,J);for(let Y of U)Q=s1(Y.trim(),Q,Z,J);return Q}function h($,Z,J){let q=d1($);if(q>=0){let Y=$.slice(0,q).trim(),W=$.slice(q+1),_=r1(W);if(_>=0){let H=W.slice(0,_).trim(),G=W.slice(_+1).trim(),N=h(Y,Z,J);return N!==null&&N!==void 0&&N!==!1&&N!==0&&N!==""?h(H,Z,J):h(G,Z,J)}}let U=W4($,"||");if(U>=0){let Y=h($.slice(0,U).trim(),Z,J);return Y!==null&&Y!==void 0&&Y!==!1&&Y!==0&&Y!==""?Y:h($.slice(U+2).trim(),Z,J)}let Q=W4($,"&&");if(Q>=0){let Y=h($.slice(0,Q).trim(),Z,J);if(Y===null||Y===void 0||Y===!1||Y===0||Y==="")return Y;return h($.slice(Q+2).trim(),Z,J)}for(let[Y,W]of l1){let _=W4($,Y);if(_>=0){let H=h($.slice(0,_).trim(),Z,J),G=h($.slice(_+Y.length).trim(),Z,J);return W(H,G)}}if($.startsWith("!")){let Y=h($.slice(1).trim(),Z,J);return Y===null||Y===void 0||Y===!1||Y===0||Y===""}for(let[Y,W]of i1){let _=W4($,Y);if(_>=0){let H=h($.slice(0,_).trim(),Z,J),G=h($.slice(_+Y.length).trim(),Z,J);return W(Number(H),Number(G))}}if($==="true")return!0;if($==="false")return!1;if($==="null"||$==="undefined")return null;if(/^-?\d+(\.\d+)?$/.test($))return Number($);if($.startsWith("'")&&$.endsWith("'")||$.startsWith('"')&&$.endsWith('"'))return $.slice(1,-1);if(J&&$.startsWith("$")){let Y=$.indexOf(".");if(Y>=0){let W=$.slice(0,Y),_=$.slice(Y+1),H=J[W];return M4(H,_)}return J[$]}if(J){let Y=$.split(".")[0];if(Y in J)return M4(J[Y],$.includes(".")?$.slice(Y.length+1):"")}return Z.get($)}function s1($,Z,J,q){let U=$.indexOf(":"),Q=U>=0?$.slice(0,U).trim():$,Y=U>=0?$.slice(U+1).trim():void 0,W=Y?A4(Y):void 0;switch(Q){case"find":{if(!Array.isArray(Z)||!Y)return;let _=i4(Y);if(_.length<2)return;let H=A4(_[0]),G=_[1].trim(),N;if(G.startsWith("'")&&G.endsWith("'")||G.startsWith('"')&&G.endsWith('"'))N=G.slice(1,-1);else if(J){if(q&&G.startsWith("$")){let z=G.indexOf(".");if(z>=0){let E=G.slice(0,z);if(E in q)N=M4(q[E],G.slice(z+1))}else if(G in q)N=q[G]}if(N===void 0&&!(q&&G.startsWith("$")))if(q){let z=G.split(".")[0];N=z in q?M4(q[z],G.includes(".")?G.slice(z.length+1):""):J.get(G)}else N=J.get(G)}else N=G;if(N==null)return;let X=J?.generation??0;if(X!==s4)R4=new Map,s4=X;let T=R4.get(Z);if(!T)T=new Map,R4.set(Z,T);let D=T.get(H);if(!D){D=new Map;for(let z of Z)if(z!=null&&typeof z==="object"){let E=z[H];if(E!=null)D.set(String(E),z)}T.set(H,D)}return D.get(String(N))}case"dot":{if(Z==null||typeof Z!=="object"||typeof W!=="string")return;return Z[W]}case"length":return Array.isArray(Z)?Z.length:typeof Z==="string"?Z.length:0;case"upper":return typeof Z==="string"?Z.toUpperCase():Z;case"lower":return typeof Z==="string"?Z.toLowerCase():Z;case"truncate":if(typeof Z==="string"&&typeof W==="number")return Z.slice(0,W);return Z;case"join":return Array.isArray(Z)?Z.join(typeof W==="string"?W:", "):Z;case"first":return Array.isArray(Z)?Z[0]:Z;case"last":return Array.isArray(Z)?Z[Z.length-1]:Z;case"abs":return Math.abs(Number(Z));case"round":return typeof W==="number"?Number(Number(Z).toFixed(W)):Math.round(Number(Z));case"number":return typeof W==="number"?Number(Number(Z).toFixed(W)):Number(Z);case"currency":{let _=typeof W==="string"?W:"USD";try{return new Intl.NumberFormat("en-US",{style:"currency",currency:_}).format(Number(Z))}catch{return Z}}case"percent":return typeof W==="number"?`${(Number(Z)*100).toFixed(W)}%`:`${Math.round(Number(Z)*100)}%`;case"compact":{let _=typeof W==="number"?W:1;try{return new Intl.NumberFormat("en-US",{notation:"compact",maximumFractionDigits:_}).format(Number(Z))}catch{return Z}}case"date":try{return new Date(Z).toLocaleDateString()}catch{return Z}case"time":try{return new Date(Z).toLocaleTimeString()}catch{return Z}case"datetime":try{return new Date(Z).toLocaleString()}catch{return Z}case"pluralize":{let _=Number(Z),H=typeof W==="string"?W:"";return _===1?H:`${H}s`}case"default":return Z==null||Z===""?W:Z;case"selectattr":return Array.isArray(Z)&&typeof W==="string"?Z.filter((_)=>_!=null&&typeof _==="object"&&Boolean(_[W])):Z;case"rejectattr":return Array.isArray(Z)&&typeof W==="string"?Z.filter((_)=>{if(_==null||typeof _!=="object")return!1;let H=_[W];return H==null||H===!1||H===0||H===""}):Z;default:{let _=c4(Q);if(_){let H=Y?i4(Y).map(A4):[];return _(Z,...H)}return Z}}}var l1=[["!==",($,Z)=>$!==Z],["===",($,Z)=>$===Z],["!=",($,Z)=>$!=Z],["==",($,Z)=>$==Z],[">=",($,Z)=>Number($)>=Number(Z)],["<=",($,Z)=>Number($)<=Number(Z)],[">",($,Z)=>Number($)>Number(Z)],["<",($,Z)=>Number($)<Number(Z)]],i1=[[" + ",($,Z)=>$+Z],[" - ",($,Z)=>$-Z],[" * ",($,Z)=>$*Z],[" / ",($,Z)=>Z!==0?$/Z:0],[" % ",($,Z)=>Z!==0?$%Z:0]];function W4($,Z){let J=null;for(let q=0;q<$.length;q++){let U=$[q];if(U==="'"||U==='"')J=J===U?null:J??U;if(!J&&$.slice(q,q+Z.length)===Z)return q}return-1}function d1($){let Z=0,J=null;for(let q=0;q<$.length;q++){let U=$[q];if(U==="'"||U==='"')J=J===U?null:J??U;if(!J){if(U==="(")Z++;else if(U===")")Z--;else if(U==="?"&&Z===0)return q}}return-1}function r1($){let Z=0,J=null;for(let q=0;q<$.length;q++){let U=$[q];if(U==="'"||U==='"')J=J===U?null:J??U;if(!J){if(U==="?"||U==="(")Z++;else if(U===")")Z--;else if(U===":"&&Z===0)return q}}return-1}function n1($){let Z=[],J="",q=null;for(let U=0;U<$.length;U++){let Q=$[U];if(Q==="'"||Q==='"')q=q===Q?null:q??Q;if(Q==="|"&&!q)if($[U+1]==="|")J+="||",U++;else Z.push(J),J="";else J+=Q}return Z.push(J),Z}function A4($){let Z=$.replace(/^['"]|['"]$/g,"");if(Z==="true")return!0;if(Z==="false")return!1;let J=Number(Z);return isNaN(J)?Z:J}function i4($){let Z=[],J="",q=null;for(let U of $){if(U==="'"||U==='"')q=q===U?null:q??U;if(U===","&&!q)Z.push(J),J="";else J+=U}return Z.push(J),Z}function M4($,Z){if(!Z)return $;let J=Z.split("."),q=$;for(let U of J){if(q==null||typeof q!=="object")return;q=q[U]}return q}function o1($,Z){let J=0,q=0;while((q=$.indexOf(Z,q))!==-1)J++,q+=Z.length;return J}async function k($,Z){let J=Array.isArray($)?$:[$];for(let q of J)await a1(q,Z)}async function a1($,Z){let J=$.action;switch(J){case"setState":{t1($,Z);return}case"toggleState":{e1($,Z);return}case"appendState":{$0($,Z);return}case"popState":{J0($,Z);return}case"showToast":{Z0($,Z);return}case"closeOverlay":{q0($,Z);return}case"openLink":{U0($);return}case"setInterval":{W0($,Z);return}case"toolCall":case"callTool":return M0($,Z);case"sendMessage":return _0($,Z);case"updateContext":{N0($,Z);return}case"fetch":return B0($,Z);case"openFilePicker":{H0($,Z);return}case"callHandler":return G0($,Z);case"requestDisplayMode":{X0($,Z);return}default:console.warn(`[prefab] Unknown action: ${J}`)}}function t1($,Z){let{key:J,value:q}=$;if(u(q))q=x(q,Z.store,Z.scope);Z.store.set(J,q),Z.rerender(),r($.onSuccess,Z)}function e1($,Z){Z.store.toggle($.key),Z.rerender()}function $0($,Z){let J=$.value;if(u(J))J=x(J,Z.store,Z.scope);Z.store.append($.key,J,$.index),Z.rerender()}function J0($,Z){Z.store.pop($.key,$.index),Z.rerender()}function Z0($,Z){Z.onToast?.({message:N4($.message,Z),description:$.description!=null?N4($.description,Z):void 0,variant:$.variant,duration:$.duration})}function q0($,Z){if(typeof document<"u")document.dispatchEvent(new CustomEvent("prefab:close-overlay"))}function U0($){if(typeof window<"u"){let Z=$.url;if(!Z){console.warn("[prefab] openLink: missing url");return}if(!r4(Z)){console.warn(`[prefab] Blocked unsafe URL scheme: ${Z}`);return}window.open(Z,$.target??"_blank")}}var _4=new Set,Q0=20,Y0=100;function W0($,Z){let J=Math.max($.intervalMs,Y0),q=$.onTick;if(typeof globalThis.setInterval!=="function")return;if(_4.size>=Q0){console.warn("[prefab] Max intervals reached, ignoring new setInterval");return}let U=globalThis.setInterval(()=>void k(q,Z),J);_4.add(U)}function d4(){for(let $ of _4)globalThis.clearInterval($);_4.clear()}async function M0($,Z){if(!Z.transport){console.warn("[prefab] No MCP transport configured for toolCall");return}let J=$.tool,q=n4($.arguments,Z);try{let U=await Z.transport.callTool(J,q);if($.resultKey!=null)Z.store.set($.resultKey,U);Z.rerender(),await r($.onSuccess,Z,{$result:U})}catch(U){await r($.onError,Z,{$error:U})}}async function _0($,Z){if(!Z.transport){console.warn("[prefab] No MCP transport configured for sendMessage");return}await Z.transport.sendMessage(N4($.message,Z))}function N0($,Z){let J=$.context;if(J!=null)Z.store.merge(J),Z.rerender()}async function B0($,Z){let J=N4($.url,Z);if(!r4(J)){console.warn(`[prefab] Blocked unsafe URL in fetch: ${J}`);return}let q=$.method??"GET",U=$.headers,Q=$.body!==void 0?JSON.stringify($.body):void 0;try{let Y=await globalThis.fetch(J,{method:q,headers:{"Content-Type":"application/json",...U},...Q&&{body:Q}}),W=await Y.json().catch(()=>Y.text());if($.resultKey!=null)Z.store.set($.resultKey,W);Z.rerender(),await r($.onSuccess,Z,{$result:W})}catch(Y){await r($.onError,Z,{$error:Y})}}function H0($,Z){if(typeof document>"u")return;let J=document.createElement("input");if(J.type="file",$.accept!=null)J.accept=$.accept;if($.multiple===!0)J.multiple=!0;J.addEventListener("change",()=>{let q=Array.from(J.files??[]);if($.resultKey!=null)Z.store.set($.resultKey,q);Z.rerender(),r($.onSuccess,Z,{$result:q})}),J.click()}async function G0($,Z){let J=$.handler,q=n4($.arguments,Z);if(!Z.transport){console.warn(`[prefab] No transport configured for callHandler: ${J}`);return}try{let U=await Z.transport.callTool(J,q);if($.resultKey!=null)Z.store.set($.resultKey,U);Z.rerender(),await r($.onSuccess,Z,{$result:U})}catch(U){await r($.onError,Z,{$error:U})}}function X0($,Z){if(typeof document<"u")document.dispatchEvent(new CustomEvent("prefab:request-display-mode",{detail:{mode:$.mode}}))}var K0=/^\s*(javascript|vbscript|data):/i;function r4($){return!K0.test($)}function N4($,Z){if(u($)){let J=x($,Z.store,Z.scope);return J==null?"":String(J)}return $==null?"":String($)}function n4($,Z){if(!$)return{};let J={};for(let[q,U]of Object.entries($))J[q]=u(U)?x(U,Z.store,Z.scope):U;return J}async function r($,Z,J){if($==null)return;let q={...Z.scope,...J};await k($,{...Z,scope:q})}var f4=new Map;function M($,Z){if(f4.has($))console.warn(`[prefab] overriding existing renderer for "${$}"`);f4.set($,Z)}function w($,Z){if(Z.defs?.[$.type]){let U={...Z.defs[$.type],...$,type:Z.defs[$.type].type};return w(U,Z)}let J=f4.get($.type),q;if(J)q=J($,Z);else if(q=document.createElement("div"),q.setAttribute("data-prefab-type",$.type),$.children)for(let U of $.children)q.appendChild(w(U,Z));if(q instanceof HTMLElement){if($.id)q.id=$.id;if($.cssClass){let U=K($.cssClass,Z);if(U)q.className=(q.className?q.className+" ":"")+U}}if($.onMount){let U=$.onMount,Q=b(Z);queueMicrotask(()=>void k(U,Q))}return q}function L($,Z,J){if(!$.children)return;n($.children,Z,J)}function n($,Z,J){let q=0;while(q<$.length){let U=$[q];if(U.type==="If")q=z0($,q,Z,J);else if(U.type==="Elif"||U.type==="Else")q++;else Z.appendChild(w(U,J)),q++}}function z0($,Z,J,q){let U=!1,Q=Z,Y=$[Q];if(o4(Y.condition,q))k4(Y,J,q),U=!0;Q++;while(Q<$.length){let W=$[Q];if(W.type==="Elif"){if(!U&&o4(W.condition,q))k4(W,J,q),U=!0;Q++}else if(W.type==="Else"){if(!U)k4(W,J,q);Q++;break}else break}return Q}function o4($,Z){if(!$)return!1;if(u($))return Boolean(x($,Z.store,Z.scope));return Boolean(Z.store.get($))}function k4($,Z,J){if(!$.children)return;n($.children,Z,J)}function K($,Z){if(u($)){let J=x($,Z.store,Z.scope);return J==null?"":String(J)}return $==null?"":String($)}function y($,Z){if(u($))return x($,Z.store,Z.scope);return $}function b($){return{store:$.store,transport:$.transport,scope:$.scope,rerender:$.rerender,onToast:$.onToast}}function B($,Z){let J=document.createElement($);if(Z)J.className=Z;return J}function S4($,Z){return $.textContent=Z,$}function $1(){M("Column",D0),M("Row",F0),M("Grid",a4),M("GridItem",t4),M("Container",E0),M("Div",e4),M("Span",T0),M("Dashboard",a4),M("DashboardItem",t4),M("Pages",L0),M("Page",e4),M("Detail",j0),M("MasterDetail",O0)}function D0($,Z){let J=B("div","pf-column");J.style.display="flex",J.style.flexDirection="column";let q=B4($);if(q!=null)J.style.gap=`${q*4}px`;if($.align!=null)J.style.alignItems=J1($.align);if($.justify!=null)J.style.justifyContent=Z1($.justify);return L($,J,Z),J}function F0($,Z){let J=B("div","pf-row");J.style.display="flex",J.style.flexDirection="row";let q=B4($);if(q!=null)J.style.gap=`${q*4}px`;if($.align!=null)J.style.alignItems=J1($.align);if($.justify!=null)J.style.justifyContent=Z1($.justify);if($.wrap===!0)J.style.flexWrap="wrap";return L($,J,Z),J}function a4($,Z){let J=B("div","pf-grid");J.style.display="grid";let q=$.columns??3;J.style.gridTemplateColumns=`repeat(${q}, 1fr)`;let U=B4($);if(U!=null)J.style.gap=`${U*4}px`;return L($,J,Z),J}function t4($,Z){let J=B("div","pf-grid-item");if($.colSpan!=null)J.style.gridColumn=`span ${$.colSpan}`;if($.rowSpan!=null)J.style.gridRow=`span ${$.rowSpan}`;return L($,J,Z),J}function E0($,Z){let J=B("div","pf-container");if(J.style.maxWidth=$.maxWidth??"1200px",J.style.margin="0 auto",$.padding!=null)J.style.padding=`${$.padding*4}px`;return L($,J,Z),J}function e4($,Z){let J=B("div","pf-div");return L($,J,Z),J}function T0($,Z){let J=B("span","pf-span");return L($,J,Z),J}function L0($,Z){let J=B("div","pf-pages");return L($,J,Z),J}function j0($,Z){let J=B("div","pf-detail"),q=$.of!=null?y($.of,Z):void 0;if(q!=null&&q!==""&&q!==!1&&q!==0)L($,J,Z);else if($.empty!=null){let U=$.empty;J.appendChild(w(U,Z))}return J}function O0($,Z){let J=B("div","pf-master-detail");J.style.display="flex",J.style.flexDirection="row";let q=B4($);if(q!=null)J.style.gap=`${q*4}px`;let U=$.masterWidth??"33%",Q=$.children??[];if(Q.length>0){let Y=B("div","pf-master-detail-master");Y.style.width=U,Y.style.flexShrink="0",Y.style.overflow="auto",Y.appendChild(w(Q[0],Z)),J.appendChild(Y)}if(Q.length>1){let Y=B("div","pf-master-detail-detail");Y.style.flex="1",Y.style.overflow="auto",Y.appendChild(w(Q[1],Z)),J.appendChild(Y)}return J}var P0=/\bgap-(\d+)\b/;function B4($){if($.gap!=null)return $.gap;if(typeof $.cssClass==="string"){let Z=P0.exec($.cssClass);if(Z)return Number(Z[1])}return null}function J1($){return{start:"flex-start",end:"flex-end",center:"center",stretch:"stretch",baseline:"baseline"}[$]??$}function Z1($){return{start:"flex-start",end:"flex-end",center:"center",between:"space-between",around:"space-around",evenly:"space-evenly"}[$]??$}function U1(){M("Heading",V0),M("H1",($,Z)=>H4($,Z,"h1")),M("H2",($,Z)=>H4($,Z,"h2")),M("H3",($,Z)=>H4($,Z,"h3")),M("H4",($,Z)=>H4($,Z,"h4")),M("Text",I0),M("P",R0),M("Lead",($,Z)=>e($,Z,"p","pf-lead")),M("Large",($,Z)=>e($,Z,"span","pf-large")),M("Small",($,Z)=>e($,Z,"small","pf-small")),M("Muted",($,Z)=>e($,Z,"p","pf-muted")),M("BlockQuote",($,Z)=>e($,Z,"blockquote","pf-blockquote")),M("Label",($,Z)=>e($,Z,"label","pf-label")),M("Link",k0),M("Code",f0),M("Markdown",S0),M("Kbd",w0)}function V0($,Z){let J=$.level??2,q=`h${Math.min(Math.max(J,1),6)}`,U=document.createElement(q);return U.className=`pf-heading pf-${q}`,U.textContent=K($.content,Z),U}function H4($,Z,J){let q=document.createElement(J);return q.className=`pf-heading pf-${J}`,q.textContent=K($.content,Z),q}function I0($,Z){return S4(B("span","pf-text"),K($.content,Z))}function R0($,Z){return S4(B("p","pf-p"),K($.content,Z))}function e($,Z,J,q){let U=document.createElement(J);return U.className=q,U.textContent=K($.content,Z),U}var A0=/^\s*(javascript|vbscript|data):/i;function k0($,Z){let J=document.createElement("a");if(J.className="pf-link",J.textContent=K($.content,Z),$.href!=null){let q=K($.href,Z);if(!A0.test(q))J.href=q}if($.target!=null)J.target=K($.target,Z);return J}function f0($,Z){let J=B("pre","pf-code"),q=B("code");if(q.textContent=K($.content,Z),$.language!=null)q.setAttribute("data-language",$.language);return J.appendChild(q),J}function S0($,Z){let J=B("div","pf-markdown"),q=K($.content,Z);return J.innerHTML=Q1(q),J.setAttribute("data-markdown","true"),J}var q1=/^\s*(javascript|vbscript|data):/i;function X4($){return $.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;")}function G4($){let Z=X4($),J=[];return Z=Z.replace(/`([^`]+)`/g,(q,U)=>{return J.push(`<code>${U}</code>`),`﷐CODE${J.length-1}﷐`}),Z=Z.replace(/!\[([^\]]*)\]\(([^)]+)\)/g,(q,U,Q)=>{if(q1.test(Q))return X4(U);return`<img src="${Q}" alt="${U}" />`}),Z=Z.replace(/\[([^\]]+)\]\(([^)]+)\)/g,(q,U,Q)=>{if(q1.test(Q))return U;return`<a href="${Q}">${U}</a>`}),Z=Z.replace(/\*{3}(.+?)\*{3}/g,"<strong><em>$1</em></strong>"),Z=Z.replace(/_{3}(.+?)_{3}/g,"<strong><em>$1</em></strong>"),Z=Z.replace(/\*{2}(.+?)\*{2}/g,"<strong>$1</strong>"),Z=Z.replace(/_{2}(.+?)_{2}/g,"<strong>$1</strong>"),Z=Z.replace(/\*(.+?)\*/g,"<em>$1</em>"),Z=Z.replace(/(?<!\w)_(.+?)_(?!\w)/g,"<em>$1</em>"),Z=Z.replace(/~~(.+?)~~/g,"<del>$1</del>"),Z=Z.replace(/\uFDD0CODE(\d+)\uFDD0/g,(q,U)=>J[parseInt(U)]),Z}function Q1($){let Z=$.replace(/\r\n?/g,`
1
+ (()=>{class J0{data={};subscribers=new Map;globalSubscribers=new Set;generation=0;constructor($){if($)this.data=structuredClone($)}get($){return x1(this.data,$)}getAll(){return this.data}set($,J){x0(this.data,$,J),this.notify($)}toggle($){let J=this.get($),Z=J==null||J===!1||J===0||J==="";this.set($,Z)}append($,J,Z){let q=this.get($);if(!Array.isArray(q)){this.set($,[J]);return}if(Z!==void 0)q.splice(Z,0,J);else q.push(J);this.notify($)}pop($,J){let Z=this.get($);if(!Array.isArray(Z))return;if(typeof J==="number")Z.splice(J,1);else{let q=Z.indexOf(J);if(q>=0)Z.splice(q,1)}this.notify($)}merge($){for(let[J,Z]of Object.entries($))x0(this.data,J,Z);for(let J of Object.keys($))this.notify(J)}subscribe($,J){if(!this.subscribers.has($))this.subscribers.set($,new Set);return this.subscribers.get($)?.add(J),()=>this.subscribers.get($)?.delete(J)}subscribeAll($){return this.globalSubscribers.add($),()=>this.globalSubscribers.delete($)}notify($){this.generation++;let J=$.split(".");for(let Z=1;Z<=J.length;Z++){let q=J.slice(0,Z).join("."),U=this.subscribers.get(q);if(U)U.forEach((Q)=>Q())}this.globalSubscribers.forEach((Z)=>Z())}}function x1($,J){let Z=J.split("."),q=$;for(let U of Z){if(q==null||typeof q!=="object")return;q=q[U]}return q}var p1=new Set(["__proto__","constructor","prototype"]);function x0($,J,Z){let q=J.split(".");if(q.some((Q)=>p1.has(Q))){console.warn(`[prefab] Blocked prototype pollution attempt: ${J}`);return}let U=$;for(let Q=0;Q<q.length-1;Q++){let Y=q[Q];if(U[Y]==null||typeof U[Y]!=="object")U[Y]={};U=U[Y]}U[q[q.length-1]]=Z}var t=new Map;function V0($,J){if(t.has($)&&t.get($)!==J)console.warn(`[prefab] pipe "${$}" re-registered`);t.set($,J)}function I0($){return t.delete($)}function p0(){return[...t.keys()]}function c0($){return t.get($)}var l0=-1,R0=new Map,c1=/\{\{\s*(.+?)\s*\}\}/g;function u($){return typeof $==="string"&&$.includes("{{")&&$.includes("}}")}function x($,J,Z){let q=$.trim();if(q.startsWith("{{")&&q.endsWith("}}")&&o1(q,"{{")===1){let U=q.slice(2,-2).trim();return s0(U,J,Z)}return $.replace(c1,(U,Q)=>{let Y=s0(Q.trim(),J,Z);return Y==null?"":String(Y)})}function s0($,J,Z){let[q,...U]=n1($),Q=h(q.trim(),J,Z);for(let Y of U)Q=l1(Y.trim(),Q,J,Z);return Q}function h($,J,Z){let q=d1($);if(q>=0){let Y=$.slice(0,q).trim(),W=$.slice(q+1),_=r1(W);if(_>=0){let B=W.slice(0,_).trim(),G=W.slice(_+1).trim(),N=h(Y,J,Z);return N!==null&&N!==void 0&&N!==!1&&N!==0&&N!==""?h(B,J,Z):h(G,J,Z)}}let U=W0($,"||");if(U>=0){let Y=h($.slice(0,U).trim(),J,Z);return Y!==null&&Y!==void 0&&Y!==!1&&Y!==0&&Y!==""?Y:h($.slice(U+2).trim(),J,Z)}let Q=W0($,"&&");if(Q>=0){let Y=h($.slice(0,Q).trim(),J,Z);if(Y===null||Y===void 0||Y===!1||Y===0||Y==="")return Y;return h($.slice(Q+2).trim(),J,Z)}for(let[Y,W]of s1){let _=W0($,Y);if(_>=0){let B=h($.slice(0,_).trim(),J,Z),G=h($.slice(_+Y.length).trim(),J,Z);return W(B,G)}}if($.startsWith("!")){let Y=h($.slice(1).trim(),J,Z);return Y===null||Y===void 0||Y===!1||Y===0||Y===""}for(let[Y,W]of i1){let _=W0($,Y);if(_>=0){let B=h($.slice(0,_).trim(),J,Z),G=h($.slice(_+Y.length).trim(),J,Z);return W(Number(B),Number(G))}}if($==="true")return!0;if($==="false")return!1;if($==="null"||$==="undefined")return null;if(/^-?\d+(\.\d+)?$/.test($))return Number($);if($.startsWith("'")&&$.endsWith("'")||$.startsWith('"')&&$.endsWith('"'))return $.slice(1,-1);if(Z&&$.startsWith("$")){let Y=$.indexOf(".");if(Y>=0){let W=$.slice(0,Y),_=$.slice(Y+1),B=Z[W];return M0(B,_)}return Z[$]}if(Z){let Y=$.split(".")[0];if(Y in Z)return M0(Z[Y],$.includes(".")?$.slice(Y.length+1):"")}return J.get($)}function l1($,J,Z,q){let U=$.indexOf(":"),Q=U>=0?$.slice(0,U).trim():$,Y=U>=0?$.slice(U+1).trim():void 0,W=Y?A0(Y):void 0;switch(Q){case"find":{if(!Array.isArray(J)||!Y)return;let _=i0(Y);if(_.length<2)return;let B=A0(_[0]),G=_[1].trim(),N;if(G.startsWith("'")&&G.endsWith("'")||G.startsWith('"')&&G.endsWith('"'))N=G.slice(1,-1);else if(Z){if(q&&G.startsWith("$")){let K=G.indexOf(".");if(K>=0){let E=G.slice(0,K);if(E in q)N=M0(q[E],G.slice(K+1))}else if(G in q)N=q[G]}if(N===void 0&&!(q&&G.startsWith("$")))if(q){let K=G.split(".")[0];N=K in q?M0(q[K],G.includes(".")?G.slice(K.length+1):""):Z.get(G)}else N=Z.get(G)}else N=G;if(N==null)return;let z=Z?.generation??0;if(z!==l0)R0=new Map,l0=z;let T=R0.get(J);if(!T)T=new Map,R0.set(J,T);let D=T.get(B);if(!D){D=new Map;for(let K of J)if(K!=null&&typeof K==="object"){let E=K[B];if(E!=null)D.set(String(E),K)}T.set(B,D)}return D.get(String(N))}case"dot":{if(J==null||typeof J!=="object"||typeof W!=="string")return;return J[W]}case"length":return Array.isArray(J)?J.length:typeof J==="string"?J.length:0;case"upper":return typeof J==="string"?J.toUpperCase():J;case"lower":return typeof J==="string"?J.toLowerCase():J;case"truncate":if(typeof J==="string"&&typeof W==="number")return J.slice(0,W);return J;case"join":return Array.isArray(J)?J.join(typeof W==="string"?W:", "):J;case"first":return Array.isArray(J)?J[0]:J;case"last":return Array.isArray(J)?J[J.length-1]:J;case"abs":return Math.abs(Number(J));case"round":return typeof W==="number"?Number(Number(J).toFixed(W)):Math.round(Number(J));case"number":return typeof W==="number"?Number(Number(J).toFixed(W)):Number(J);case"currency":{let _=typeof W==="string"?W:"USD";try{return new Intl.NumberFormat("en-US",{style:"currency",currency:_}).format(Number(J))}catch{return J}}case"percent":return typeof W==="number"?`${(Number(J)*100).toFixed(W)}%`:`${Math.round(Number(J)*100)}%`;case"compact":{let _=typeof W==="number"?W:1;try{return new Intl.NumberFormat("en-US",{notation:"compact",maximumFractionDigits:_}).format(Number(J))}catch{return J}}case"date":try{return new Date(J).toLocaleDateString()}catch{return J}case"time":try{return new Date(J).toLocaleTimeString()}catch{return J}case"datetime":try{return new Date(J).toLocaleString()}catch{return J}case"pluralize":{let _=Number(J),B=typeof W==="string"?W:"";return _===1?B:`${B}s`}case"default":return J==null||J===""?W:J;case"selectattr":return Array.isArray(J)&&typeof W==="string"?J.filter((_)=>_!=null&&typeof _==="object"&&Boolean(_[W])):J;case"rejectattr":return Array.isArray(J)&&typeof W==="string"?J.filter((_)=>{if(_==null||typeof _!=="object")return!1;let B=_[W];return B==null||B===!1||B===0||B===""}):J;default:{let _=c0(Q);if(_){let B=Y?i0(Y).map(A0):[];return _(J,...B)}return J}}}var s1=[["!==",($,J)=>$!==J],["===",($,J)=>$===J],["!=",($,J)=>$!=J],["==",($,J)=>$==J],[">=",($,J)=>Number($)>=Number(J)],["<=",($,J)=>Number($)<=Number(J)],[">",($,J)=>Number($)>Number(J)],["<",($,J)=>Number($)<Number(J)]],i1=[[" + ",($,J)=>$+J],[" - ",($,J)=>$-J],[" * ",($,J)=>$*J],[" / ",($,J)=>J!==0?$/J:0],[" % ",($,J)=>J!==0?$%J:0]];function W0($,J){let Z=null;for(let q=0;q<$.length;q++){let U=$[q];if(U==="'"||U==='"')Z=Z===U?null:Z??U;if(!Z&&$.slice(q,q+J.length)===J)return q}return-1}function d1($){let J=0,Z=null;for(let q=0;q<$.length;q++){let U=$[q];if(U==="'"||U==='"')Z=Z===U?null:Z??U;if(!Z){if(U==="(")J++;else if(U===")")J--;else if(U==="?"&&J===0)return q}}return-1}function r1($){let J=0,Z=null;for(let q=0;q<$.length;q++){let U=$[q];if(U==="'"||U==='"')Z=Z===U?null:Z??U;if(!Z){if(U==="?"||U==="(")J++;else if(U===")")J--;else if(U===":"&&J===0)return q}}return-1}function n1($){let J=[],Z="",q=null;for(let U=0;U<$.length;U++){let Q=$[U];if(Q==="'"||Q==='"')q=q===Q?null:q??Q;if(Q==="|"&&!q)if($[U+1]==="|")Z+="||",U++;else J.push(Z),Z="";else Z+=Q}return J.push(Z),J}function A0($){let J=$.replace(/^['"]|['"]$/g,"");if(J==="true")return!0;if(J==="false")return!1;let Z=Number(J);return isNaN(Z)?J:Z}function i0($){let J=[],Z="",q=null;for(let U of $){if(U==="'"||U==='"')q=q===U?null:q??U;if(U===","&&!q)J.push(Z),Z="";else Z+=U}return J.push(Z),J}function M0($,J){if(!J)return $;let Z=J.split("."),q=$;for(let U of Z){if(q==null||typeof q!=="object")return;q=q[U]}return q}function o1($,J){let Z=0,q=0;while((q=$.indexOf(J,q))!==-1)Z++,q+=J.length;return Z}async function k($,J){let Z=Array.isArray($)?$:[$];for(let q of Z)await a1(q,J)}async function a1($,J){let Z=$.action;switch(Z){case"setState":{t1($,J);return}case"toggleState":{e1($,J);return}case"appendState":{$4($,J);return}case"popState":{J4($,J);return}case"showToast":{Z4($,J);return}case"closeOverlay":{q4($,J);return}case"openLink":{U4($);return}case"setInterval":{W4($,J);return}case"toolCall":case"callTool":return M4($,J);case"sendMessage":return _4($,J);case"updateContext":{N4($,J);return}case"fetch":return H4($,J);case"openFilePicker":{B4($,J);return}case"callHandler":return G4($,J);case"requestDisplayMode":{X4($,J);return}default:console.warn(`[prefab] Unknown action: ${Z}`)}}function t1($,J){let{key:Z,value:q}=$;if(u(q))q=x(q,J.store,J.scope);J.store.set(Z,q),J.rerender(),r($.onSuccess,J)}function e1($,J){J.store.toggle($.key),J.rerender()}function $4($,J){let Z=$.value;if(u(Z))Z=x(Z,J.store,J.scope);J.store.append($.key,Z,$.index),J.rerender()}function J4($,J){J.store.pop($.key,$.index),J.rerender()}function Z4($,J){J.onToast?.({message:N0($.message,J),description:$.description!=null?N0($.description,J):void 0,variant:$.variant,duration:$.duration})}function q4($,J){if(typeof document<"u")document.dispatchEvent(new CustomEvent("prefab:close-overlay"))}function U4($){if(typeof window<"u"){let J=$.url;if(!J){console.warn("[prefab] openLink: missing url");return}if(!r0(J)){console.warn(`[prefab] Blocked unsafe URL scheme: ${J}`);return}window.open(J,$.target??"_blank")}}var _0=new Set,Q4=20,Y4=100;function W4($,J){let Z=Math.max($.intervalMs,Y4),q=$.onTick;if(typeof globalThis.setInterval!=="function")return;if(_0.size>=Q4){console.warn("[prefab] Max intervals reached, ignoring new setInterval");return}let U=globalThis.setInterval(()=>void k(q,J),Z);_0.add(U)}function d0(){for(let $ of _0)globalThis.clearInterval($);_0.clear()}async function M4($,J){if(!J.transport){console.warn("[prefab] No MCP transport configured for toolCall");return}let Z=$.tool,q=n0($.arguments,J);try{let U=await J.transport.callTool(Z,q);if($.resultKey!=null)J.store.set($.resultKey,U);J.rerender(),await r($.onSuccess,J,{$result:U})}catch(U){await r($.onError,J,{$error:U})}}async function _4($,J){if(!J.transport){console.warn("[prefab] No MCP transport configured for sendMessage");return}await J.transport.sendMessage(N0($.message,J))}function N4($,J){let Z=$.context;if(Z!=null)J.store.merge(Z),J.rerender()}async function H4($,J){let Z=N0($.url,J);if(!r0(Z)){console.warn(`[prefab] Blocked unsafe URL in fetch: ${Z}`);return}let q=$.method??"GET",U=$.headers,Q=$.body!==void 0?JSON.stringify($.body):void 0;try{let Y=await globalThis.fetch(Z,{method:q,headers:{"Content-Type":"application/json",...U},...Q&&{body:Q}}),W=await Y.json().catch(()=>Y.text());if($.resultKey!=null)J.store.set($.resultKey,W);J.rerender(),await r($.onSuccess,J,{$result:W})}catch(Y){await r($.onError,J,{$error:Y})}}function B4($,J){if(typeof document>"u")return;let Z=document.createElement("input");if(Z.type="file",$.accept!=null)Z.accept=$.accept;if($.multiple===!0)Z.multiple=!0;Z.addEventListener("change",()=>{let q=Array.from(Z.files??[]);if($.resultKey!=null)J.store.set($.resultKey,q);J.rerender(),r($.onSuccess,J,{$result:q})}),Z.click()}async function G4($,J){let Z=$.handler,q=n0($.arguments,J);if(!J.transport){console.warn(`[prefab] No transport configured for callHandler: ${Z}`);return}try{let U=await J.transport.callTool(Z,q);if($.resultKey!=null)J.store.set($.resultKey,U);J.rerender(),await r($.onSuccess,J,{$result:U})}catch(U){await r($.onError,J,{$error:U})}}function X4($,J){if(typeof document<"u")document.dispatchEvent(new CustomEvent("prefab:request-display-mode",{detail:{mode:$.mode}}))}var K4=/^\s*(javascript|vbscript|data):/i;function r0($){return!K4.test($)}function N0($,J){if(u($)){let Z=x($,J.store,J.scope);return Z==null?"":String(Z)}return $==null?"":String($)}function n0($,J){if(!$)return{};let Z={};for(let[q,U]of Object.entries($))Z[q]=u(U)?x(U,J.store,J.scope):U;return Z}async function r($,J,Z){if($==null)return;let q={...J.scope,...Z};await k($,{...J,scope:q})}var f0=new Map;function M($,J){if(f0.has($))console.warn(`[prefab] overriding existing renderer for "${$}"`);f0.set($,J)}function w($,J){if(J.defs?.[$.type]){let U={...J.defs[$.type],...$,type:J.defs[$.type].type};return w(U,J)}let Z=f0.get($.type),q;if(Z)q=Z($,J);else if(q=document.createElement("div"),q.setAttribute("data-prefab-type",$.type),$.children)for(let U of $.children)q.appendChild(w(U,J));if(q instanceof HTMLElement){if($.id)q.id=$.id;if($.cssClass){let U=X($.cssClass,J);if(U)q.className=(q.className?q.className+" ":"")+U}}if($.onMount){let U=$.onMount,Q=y(J);queueMicrotask(()=>void k(U,Q))}return q}function L($,J,Z){if(!$.children)return;n($.children,J,Z)}function n($,J,Z){let q=0;while(q<$.length){let U=$[q];if(U.type==="If")q=z4($,q,J,Z);else if(U.type==="Elif"||U.type==="Else")q++;else J.appendChild(w(U,Z)),q++}}function z4($,J,Z,q){let U=!1,Q=J,Y=$[Q];if(o0(Y.condition,q))k0(Y,Z,q),U=!0;Q++;while(Q<$.length){let W=$[Q];if(W.type==="Elif"){if(!U&&o0(W.condition,q))k0(W,Z,q),U=!0;Q++}else if(W.type==="Else"){if(!U)k0(W,Z,q);Q++;break}else break}return Q}function o0($,J){if(!$)return!1;if(u($))return Boolean(x($,J.store,J.scope));return Boolean(J.store.get($))}function k0($,J,Z){if(!$.children)return;n($.children,J,Z)}function X($,J){if(u($)){let Z=x($,J.store,J.scope);return Z==null?"":String(Z)}return $==null?"":String($)}function b($,J){if(u($))return x($,J.store,J.scope);return $}function y($){return{store:$.store,transport:$.transport,scope:$.scope,rerender:$.rerender,onToast:$.onToast}}function H($,J){let Z=document.createElement($);if(J)Z.className=J;return Z}function S0($,J){return $.textContent=J,$}function $1(){M("Column",D4),M("Row",F4),M("Grid",a0),M("GridItem",t0),M("Container",E4),M("Div",e0),M("Span",T4),M("Dashboard",a0),M("DashboardItem",t0),M("Pages",L4),M("Page",e0),M("Detail",j4),M("MasterDetail",O4)}function D4($,J){let Z=H("div","pf-column");Z.style.display="flex",Z.style.flexDirection="column";let q=H0($);if(q!=null)Z.style.gap=`${q*4}px`;if($.align!=null)Z.style.alignItems=J1($.align);if($.justify!=null)Z.style.justifyContent=Z1($.justify);return L($,Z,J),Z}function F4($,J){let Z=H("div","pf-row");Z.style.display="flex",Z.style.flexDirection="row";let q=H0($);if(q!=null)Z.style.gap=`${q*4}px`;if($.align!=null)Z.style.alignItems=J1($.align);if($.justify!=null)Z.style.justifyContent=Z1($.justify);if($.wrap===!0)Z.style.flexWrap="wrap";return L($,Z,J),Z}function a0($,J){let Z=H("div","pf-grid");Z.style.display="grid";let q=$.columns??3;Z.style.gridTemplateColumns=`repeat(${q}, 1fr)`;let U=H0($);if(U!=null)Z.style.gap=`${U*4}px`;return L($,Z,J),Z}function t0($,J){let Z=H("div","pf-grid-item");if($.colSpan!=null)Z.style.gridColumn=`span ${$.colSpan}`;if($.rowSpan!=null)Z.style.gridRow=`span ${$.rowSpan}`;return L($,Z,J),Z}function E4($,J){let Z=H("div","pf-container");if(Z.style.maxWidth=$.maxWidth??"1200px",Z.style.margin="0 auto",$.padding!=null)Z.style.padding=`${$.padding*4}px`;return L($,Z,J),Z}function e0($,J){let Z=H("div","pf-div");return L($,Z,J),Z}function T4($,J){let Z=H("span","pf-span");return L($,Z,J),Z}function L4($,J){let Z=H("div","pf-pages");return L($,Z,J),Z}function j4($,J){let Z=H("div","pf-detail"),q=$.of!=null?b($.of,J):void 0;if(q!=null&&q!==""&&q!==!1&&q!==0)L($,Z,J);else if($.empty!=null){let U=$.empty;Z.appendChild(w(U,J))}return Z}function O4($,J){let Z=H("div","pf-master-detail");Z.style.display="flex",Z.style.flexDirection="row";let q=H0($);if(q!=null)Z.style.gap=`${q*4}px`;let U=$.masterWidth??"33%",Q=$.children??[];if(Q.length>0){let Y=H("div","pf-master-detail-master");Y.style.width=U,Y.style.flexShrink="0",Y.style.overflow="auto",Y.appendChild(w(Q[0],J)),Z.appendChild(Y)}if(Q.length>1){let Y=H("div","pf-master-detail-detail");Y.style.flex="1",Y.style.overflow="auto",Y.appendChild(w(Q[1],J)),Z.appendChild(Y)}return Z}var P4=/\bgap-(\d+)\b/;function H0($){if($.gap!=null)return $.gap;if(typeof $.cssClass==="string"){let J=P4.exec($.cssClass);if(J)return Number(J[1])}return null}function J1($){return{start:"flex-start",end:"flex-end",center:"center",stretch:"stretch",baseline:"baseline"}[$]??$}function Z1($){return{start:"flex-start",end:"flex-end",center:"center",between:"space-between",around:"space-around",evenly:"space-evenly"}[$]??$}function U1(){M("Heading",V4),M("H1",($,J)=>B0($,J,"h1")),M("H2",($,J)=>B0($,J,"h2")),M("H3",($,J)=>B0($,J,"h3")),M("H4",($,J)=>B0($,J,"h4")),M("Text",I4),M("P",R4),M("Lead",($,J)=>e($,J,"p","pf-lead")),M("Large",($,J)=>e($,J,"span","pf-large")),M("Small",($,J)=>e($,J,"small","pf-small")),M("Muted",($,J)=>e($,J,"p","pf-muted")),M("BlockQuote",($,J)=>e($,J,"blockquote","pf-blockquote")),M("Label",($,J)=>e($,J,"label","pf-label")),M("Link",k4),M("Code",f4),M("Markdown",S4),M("Kbd",w4)}function V4($,J){let Z=$.level??2,q=`h${Math.min(Math.max(Z,1),6)}`,U=document.createElement(q);return U.className=`pf-heading pf-${q}`,U.textContent=X($.content,J),U}function B0($,J,Z){let q=document.createElement(Z);return q.className=`pf-heading pf-${Z}`,q.textContent=X($.content,J),q}function I4($,J){return S0(H("span","pf-text"),X($.content,J))}function R4($,J){return S0(H("p","pf-p"),X($.content,J))}function e($,J,Z,q){let U=document.createElement(Z);return U.className=q,U.textContent=X($.content,J),U}var A4=/^\s*(javascript|vbscript|data):/i;function k4($,J){let Z=document.createElement("a");if(Z.className="pf-link",Z.textContent=X($.content,J),$.href!=null){let q=X($.href,J);if(!A4.test(q))Z.href=q}if($.target!=null)Z.target=X($.target,J);return Z}function f4($,J){let Z=H("pre","pf-code"),q=H("code");if(q.textContent=X($.content,J),$.language!=null)q.setAttribute("data-language",$.language);return Z.appendChild(q),Z}function S4($,J){let Z=H("div","pf-markdown"),q=X($.content,J);return Z.innerHTML=Q1(q),Z.setAttribute("data-markdown","true"),Z}var q1=/^\s*(javascript|vbscript|data):/i;function X0($){return $.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;")}function G0($){let J=X0($),Z=[];return J=J.replace(/`([^`]+)`/g,(q,U)=>{return Z.push(`<code>${U}</code>`),`﷐CODE${Z.length-1}﷐`}),J=J.replace(/!\[([^\]]*)\]\(([^)]+)\)/g,(q,U,Q)=>{if(q1.test(Q))return X0(U);return`<img src="${Q}" alt="${U}" />`}),J=J.replace(/\[([^\]]+)\]\(([^)]+)\)/g,(q,U,Q)=>{if(q1.test(Q))return U;return`<a href="${Q}">${U}</a>`}),J=J.replace(/\*{3}(.+?)\*{3}/g,"<strong><em>$1</em></strong>"),J=J.replace(/_{3}(.+?)_{3}/g,"<strong><em>$1</em></strong>"),J=J.replace(/\*{2}(.+?)\*{2}/g,"<strong>$1</strong>"),J=J.replace(/_{2}(.+?)_{2}/g,"<strong>$1</strong>"),J=J.replace(/\*(.+?)\*/g,"<em>$1</em>"),J=J.replace(/(?<!\w)_(.+?)_(?!\w)/g,"<em>$1</em>"),J=J.replace(/~~(.+?)~~/g,"<del>$1</del>"),J=J.replace(/\uFDD0CODE(\d+)\uFDD0/g,(q,U)=>Z[parseInt(U)]),J}function Q1($){let J=$.replace(/\r\n?/g,`
2
2
  `).split(`
3
- `),J=[],q=0;while(q<Z.length){let U=Z[q];if(U.trimStart().startsWith("```")){let W=U.trimStart().slice(3).trim(),_=[];q++;while(q<Z.length&&!Z[q].trimStart().startsWith("```"))_.push(X4(Z[q])),q++;q++;let H=W?` data-language="${X4(W)}"`:"";J.push(`<pre class="pf-code"><code${H}>${_.join(`
4
- `)}</code></pre>`);continue}if(/^(\s*[-*_]\s*){3,}$/.test(U)){J.push("<hr />"),q++;continue}let Q=/^(#{1,6})\s+(.+)$/.exec(U);if(Q){let W=Q[1].length;J.push(`<h${W}>${G4(Q[2])}</h${W}>`),q++;continue}if(U.startsWith("> ")||U===">"){let W=[];while(q<Z.length&&(Z[q].startsWith("> ")||Z[q]===">"))W.push(Z[q].replace(/^>\s?/,"")),q++;J.push(`<blockquote>${Q1(W.join(`
5
- `))}</blockquote>`);continue}if(/^[\s]*[-*+]\s+/.test(U)){J.push("<ul>");while(q<Z.length&&/^[\s]*[-*+]\s+/.test(Z[q]))J.push(`<li>${G4(Z[q].replace(/^[\s]*[-*+]\s+/,""))}</li>`),q++;J.push("</ul>");continue}if(/^[\s]*\d+\.\s+/.test(U)){J.push("<ol>");while(q<Z.length&&/^[\s]*\d+\.\s+/.test(Z[q]))J.push(`<li>${G4(Z[q].replace(/^[\s]*\d+\.\s+/,""))}</li>`),q++;J.push("</ol>");continue}if(U.trim()===""){q++;continue}let Y=[];while(q<Z.length&&Z[q].trim()!==""&&!/^#{1,6}\s/.test(Z[q])&&!/^[-*+]\s/.test(Z[q])&&!/^\d+\.\s/.test(Z[q])&&!Z[q].startsWith("> ")&&!Z[q].trimStart().startsWith("```")&&!/^(\s*[-*_]\s*){3,}$/.test(Z[q]))Y.push(Z[q]),q++;J.push(`<p>${Y.map(G4).join("<br />")}</p>`)}return J.join(`
6
- `)}function w0($,Z){let J=document.createElement("kbd");return J.className="pf-kbd",J.textContent=K($.content,Z),J}function W1(){M("Card",C0),M("CardHeader",w4("pf-card-header")),M("CardTitle",Y1("pf-card-title","h3")),M("CardDescription",Y1("pf-card-description","p")),M("CardContent",w4("pf-card-content")),M("CardFooter",w4("pf-card-footer"))}function C0($,Z){let J=B("div","pf-card");return J.style.border="1px solid var(--border, #e5e7eb)",J.style.borderRadius="var(--radius, 8px)",J.style.backgroundColor="var(--card, #fff)",J.style.overflow="hidden",L($,J,Z),J}function w4($){return(Z,J)=>{let q=B("div",$);return q.style.padding="16px 24px",L(Z,q,J),q}}function Y1($,Z){return(J,q)=>{let U=document.createElement(Z);return U.className=$,U.textContent=K(J.content,q),U}}function M1(){M("DataTable",b0),M("Badge",y0),M("Dot",m0),M("Metric",v0),M("Ring",h0),M("Progress",g0),M("Separator",u0),M("Loader",x0),M("Icon",p0),M("Sparkline",c0)}function b0($,Z){let J=B("div","pf-datatable-wrapper"),q=document.createElement("table");q.className="pf-datatable",q.style.width="100%",q.style.borderCollapse="collapse";let U=$.columns??[],Q=y($.rows,Z),Y=$.rowKey,W=$.selected,_=document.createElement("thead"),H=document.createElement("tr");for(let N of U){let X=document.createElement("th");X.className="pf-datatable-th",X.textContent=N.header??N.key,X.style.padding="8px 12px",X.style.textAlign="left",X.style.borderBottom="2px solid var(--border, #e5e7eb)",H.appendChild(X)}_.appendChild(H),q.appendChild(_);let G=document.createElement("tbody");if(Array.isArray(Q)){let N=W!=null?y(W,Z):void 0;for(let X of Q){let T=document.createElement("tr");T.className="pf-datatable-row";let D=X;if(Y&&N!=null&&D[Y]!=null&&String(D[Y])===String(N))T.classList.add("pf-datatable-row-selected"),T.style.backgroundColor="var(--primary-bg, #eff6ff)";if($.onRowClick!=null&&Y)T.style.cursor="pointer",T.addEventListener("click",()=>{let z={...Z.scope,$item:D,$index:Q.indexOf(X)},E=b({...Z,scope:z});k($.onRowClick,E)});for(let z of U){let E=document.createElement("td");E.className="pf-datatable-td";let P;if(z.accessor)P=y(`{{ $item.${z.accessor} }}`,{...Z,scope:{...Z.scope,$item:D}});else if(P=D[z.key],z.format&&P!=null)P=y(`{{ __fmtVal | ${z.format} }}`,{...Z,scope:{...Z.scope,__fmtVal:P}});E.textContent=P==null?"":String(P),E.style.padding="8px 12px",E.style.borderBottom="1px solid var(--border, #e5e7eb)",T.appendChild(E)}G.appendChild(T)}}if(q.appendChild(G),$.search===!0){let N=document.createElement("input");N.type="text",N.placeholder="Search...",N.className="pf-datatable-search",N.style.marginBottom="8px",N.style.padding="6px 12px",N.style.width="100%",N.style.boxSizing="border-box",N.addEventListener("input",()=>{let X=N.value.toLowerCase(),T=Array.from(G.querySelectorAll("tr"));for(let D of T){let z=D.textContent.toLowerCase();D.style.display=z.includes(X)?"":"none"}}),J.appendChild(N)}return J.appendChild(q),J}function y0($,Z){let J=B("span","pf-badge"),q=$.variant??"default";return J.setAttribute("data-variant",q),J.style.alignItems="center",J.style.padding="2px 10px",J.style.borderRadius="9999px",J.style.fontSize="12px",J.style.fontWeight="500",J.textContent=K($.label??$.content,Z),s0(J,q),J}function m0($,Z){let J=B("span","pf-dot"),q=$.color??"gray";return J.style.display="inline-block",J.style.width="8px",J.style.height="8px",J.style.borderRadius="50%",J.style.backgroundColor=q,J}function v0($,Z){let J=B("div","pf-metric"),q=B("div","pf-metric-label");q.textContent=K($.label,Z),q.style.fontSize="14px",q.style.color="var(--muted-foreground, #6b7280)",J.appendChild(q);let U=B("div","pf-metric-value");if(U.textContent=K($.value,Z),U.style.fontSize="28px",U.style.fontWeight="700",J.appendChild(U),$.delta!=null){let Q=B("span","pf-metric-delta");Q.textContent=K($.delta,Z);let Y=$.trend??"",W=$.trendSentiment??"neutral";if(Q.style.fontSize="14px",Q.style.color=W==="positive"?"green":W==="negative"?"red":"inherit",Y==="up")Q.textContent="↑ "+Q.textContent;else if(Y==="down")Q.textContent="↓ "+Q.textContent;J.appendChild(Q)}if($.description!=null){let Q=B("div","pf-metric-desc");Q.textContent=K($.description,Z),Q.style.fontSize="12px",Q.style.color="var(--muted-foreground, #6b7280)",J.appendChild(Q)}return J}function h0($,Z){let J=B("div","pf-ring"),q=$.size??80,U=$.thickness??8,Q=Number(y($.value,Z)??0),Y=Math.max(0,Math.min(100,Q)),W=(q-U)/2,_=2*Math.PI*W,H=_*(1-Y/100),G=document.createElementNS("http://www.w3.org/2000/svg","svg");G.setAttribute("width",String(q)),G.setAttribute("height",String(q)),G.setAttribute("viewBox",`0 0 ${q} ${q}`);let N=document.createElementNS("http://www.w3.org/2000/svg","circle");N.setAttribute("cx",String(q/2)),N.setAttribute("cy",String(q/2)),N.setAttribute("r",String(W)),N.setAttribute("fill","none"),N.setAttribute("stroke","var(--muted, #e5e7eb)"),N.setAttribute("stroke-width",String(U));let X=document.createElementNS("http://www.w3.org/2000/svg","circle");if(X.setAttribute("cx",String(q/2)),X.setAttribute("cy",String(q/2)),X.setAttribute("r",String(W)),X.setAttribute("fill","none"),X.setAttribute("stroke","var(--primary, #3b82f6)"),X.setAttribute("stroke-width",String(U)),X.setAttribute("stroke-dasharray",String(_)),X.setAttribute("stroke-dashoffset",String(H)),X.setAttribute("stroke-linecap","round"),X.style.transform="rotate(-90deg)",X.style.transformOrigin="center",G.appendChild(N),G.appendChild(X),J.appendChild(G),$.label!=null){let T=B("div","pf-ring-label");T.textContent=K($.label,Z),T.style.textAlign="center",T.style.fontSize="12px",J.appendChild(T)}return J}function g0($,Z){let J=B("div","pf-progress");J.setAttribute("role","progressbar");let q=Number(y($.value,Z)??0),U=$.max??100,Q=U>0?Math.max(0,Math.min(100,q/U*100)):0;J.setAttribute("aria-valuenow",String(q)),J.setAttribute("aria-valuemin","0"),J.setAttribute("aria-valuemax",String(U)),J.style.height="8px",J.style.backgroundColor="var(--muted, #e5e7eb)",J.style.borderRadius="4px",J.style.overflow="hidden";let Y=B("div","pf-progress-fill");return Y.style.height="100%",Y.style.width=`${Q}%`,Y.style.backgroundColor="var(--primary, #3b82f6)",Y.style.borderRadius="4px",Y.style.transition="width 0.3s ease",J.appendChild(Y),J}function u0($,Z){let J=document.createElement("hr");return J.className="pf-separator",J.style.border="none",J.style.borderTop="1px solid var(--border, #e5e7eb)",J.style.margin="8px 0",J}function x0($,Z){let J=B("div","pf-loader");return J.textContent="⏳",J.style.display="flex",J.style.justifyContent="center",J.style.padding="16px",J}function p0($,Z){let J=B("span","pf-icon");return J.setAttribute("data-icon",K($.name??$.content,Z)),J}function c0($,Z){let J=B("div","pf-sparkline"),q=$.data??[];if(q.length===0)return J;let U=120,Q=32,Y=Math.max(...q),W=Math.min(...q),_=Y-W||1,H=document.createElementNS("http://www.w3.org/2000/svg","svg");H.setAttribute("width",String(U)),H.setAttribute("height",String(Q)),H.setAttribute("viewBox",`0 0 ${U} ${Q}`);let G=q.length>1?q.length-1:1,N=q.map((T,D)=>{let z=D/G*U,E=Q-(T-W)/_*(Q-4)-2;return`${z},${E}`}).join(" "),X=document.createElementNS("http://www.w3.org/2000/svg","polyline");return X.setAttribute("points",N),X.setAttribute("fill","none"),X.setAttribute("stroke","var(--primary, #3b82f6)"),X.setAttribute("stroke-width","1.5"),H.appendChild(X),J.appendChild(H),J}function s0($,Z){let J={default:{bg:"var(--primary, #3b82f6)",fg:"#fff"},secondary:{bg:"var(--secondary, #f3f4f6)",fg:"var(--secondary-foreground, #1f2937)"},destructive:{bg:"var(--destructive, #ef4444)",fg:"#fff"},success:{bg:"#10b981",fg:"#fff"},warning:{bg:"#f59e0b",fg:"#fff"},info:{bg:"#3b82f6",fg:"#fff"},outline:{bg:"transparent",fg:"inherit"}},q=J[Z]??J.default;if($.style.backgroundColor=q.bg,$.style.color=q.fg,Z==="outline")$.style.border="1px solid var(--border, #e5e7eb)"}function N1(){M("Form",l0),M("Input",i0),M("Textarea",d0),M("Button",r0),M("ButtonGroup",n0),M("Select",o0),M("SelectOption",a0),M("SelectGroup",K4("pf-select-group")),M("SelectLabel",Z4("pf-select-label")),M("SelectSeparator",_1),M("Checkbox",t0),M("Switch",e0),M("Slider",$8),M("Radio",Z8),M("RadioGroup",q8),M("Combobox",U8),M("ComboboxOption",Q8),M("ComboboxGroup",K4("pf-combobox-group")),M("ComboboxLabel",Z4("pf-combobox-label")),M("ComboboxSeparator",_1),M("Calendar",Y8),M("DatePicker",W8),M("Field",K4("pf-field")),M("FieldTitle",Z4("pf-field-title")),M("FieldDescription",Z4("pf-field-description")),M("FieldContent",K4("pf-field-content")),M("FieldError",Z4("pf-field-error")),M("ChoiceCard",M8)}function l0($,Z){let J=document.createElement("form");return J.className="pf-form",J.addEventListener("submit",(q)=>{q.preventDefault();let U=new FormData(J),Q={};if(U.forEach((Y,W)=>{Q[W]=Y}),Z.store.merge(Q),$.onSubmit!=null){let Y=b(Z);Y.scope={...Z.scope,...Q},k($.onSubmit,Y)}}),L($,J,Z),J}function i0($,Z){let J=B("div","pf-input-wrapper");if(J.style.display="flex",J.style.flexDirection="column",J.style.gap="4px",$.label!=null){let Q=document.createElement("label");if(Q.className="pf-input-label",Q.textContent=K($.label,Z),$.name!=null)Q.htmlFor=$.name;Q.style.fontSize="14px",Q.style.fontWeight="500",J.appendChild(Q)}let q=document.createElement("input");if(q.className="pf-input",q.type=$.inputType??"text",$.name!=null)q.name=$.name;if($.name!=null)q.id=`pf-input-${$.name}`;if($.placeholder!=null)q.placeholder=K($.placeholder,Z);if($.required===!0)q.required=!0,q.setAttribute("aria-required","true");if($.error!=null)q.setAttribute("aria-invalid","true");let U=$.name;if(U){let Q=Z.store.get(U);if(Q!=null)q.value=String(Q);q.addEventListener("input",()=>{if(Z.store.set(U,q.value),$.onChange!=null)k($.onChange,{...b(Z),scope:{...Z.scope,$event:q.value}})})}return C4(q),J.appendChild(q),J}function d0($,Z){let J=B("div","pf-textarea-wrapper"),q=document.createElement("textarea");if(q.className="pf-textarea",$.name!=null)q.name=$.name;if($.name!=null)q.id=`pf-textarea-${$.name}`;if($.placeholder!=null)q.placeholder=K($.placeholder,Z);if($.rows!=null)q.rows=$.rows;if($.required===!0)q.setAttribute("aria-required","true");let U=$.name;if(U!=null){let Q=Z.store.get(U);if(Q!=null)q.value=String(Q);q.addEventListener("input",()=>{if(Z.store.set(U,q.value),$.onChange!=null)k($.onChange,{...b(Z),scope:{...Z.scope,$event:q.value}})})}return C4(q),J.appendChild(q),J}function r0($,Z){let J=document.createElement("button");J.className="pf-button",J.type=$.submit===!0?"submit":"button",J.textContent=K($.label,Z);let q=$.variant??"default";if(J.setAttribute("data-variant",q),J8(J,q),$.size!=null)J.setAttribute("data-size",$.size);if($.disabled===!0)J.disabled=!0;if($.onClick!=null)J.addEventListener("click",()=>{k($.onClick,b(Z))});return J}function n0($,Z){let J=B("div","pf-button-group");return J.style.display="flex",J.style.gap="8px",L($,J,Z),J}function o0($,Z){let J=B("div","pf-select-wrapper"),q=document.createElement("select");if(q.className="pf-select",$.name!=null)q.name=$.name;if(C4(q),$.placeholder!=null){let Y=document.createElement("option");Y.value="",Y.textContent=K($.placeholder,Z),Y.disabled=!0,Y.selected=!0,Y.hidden=!0,q.appendChild(Y)}let U=$.options;if(Array.isArray(U))for(let Y of U){let W=document.createElement("option");W.value=Y.value??"",W.textContent=Y.label??W.value,q.appendChild(W)}if($.children)for(let Y of $.children)if(Y.type==="SelectOption"){let W=document.createElement("option");W.value=Y.value??"",W.textContent=Y.label??W.value,q.appendChild(W)}else q.appendChild(w(Y,Z));let Q=$.name;if(Q){let Y=Z.store.get(Q);if(Y!=null)q.value=String(Y);q.addEventListener("change",()=>{if(Z.store.set(Q,q.value),$.onChange!=null)k($.onChange,{...b(Z),scope:{...Z.scope,$event:q.value}})})}return J.appendChild(q),J}function a0($,Z){return B("span")}function t0($,Z){let J=B("label","pf-checkbox-wrapper");J.style.display="flex",J.style.alignItems="center",J.style.gap="8px",J.style.cursor="pointer";let q=document.createElement("input");if(q.type="checkbox",q.className="pf-checkbox",$.name!=null)q.name=$.name;if($.checked===!0)q.checked=!0;let U=$.name;if(U){let Q=Z.store.get(U);if(typeof Q==="boolean")q.checked=Q;q.addEventListener("change",()=>{if(Z.store.set(U,q.checked),$.onChange!=null)k($.onChange,{...b(Z),scope:{...Z.scope,$event:q.checked}})})}if(J.appendChild(q),$.label!=null){let Q=B("span");Q.textContent=K($.label,Z),J.appendChild(Q)}return J}function e0($,Z){let J=B("label","pf-switch-wrapper");J.style.display="flex",J.style.alignItems="center",J.style.gap="8px",J.style.cursor="pointer";let q=document.createElement("input");if(q.type="checkbox",q.className="pf-switch",q.setAttribute("role","switch"),$.name!=null)q.name=$.name;let U=$.name;if(U){let Q=Z.store.get(U);if(typeof Q==="boolean")q.checked=Q;q.addEventListener("change",()=>{if(Z.store.set(U,q.checked),$.onChange!=null)k($.onChange,{...b(Z),scope:{...Z.scope,$event:q.checked}})})}if(J.appendChild(q),$.label!=null){let Q=B("span");Q.textContent=K($.label,Z),J.appendChild(Q)}return J}function $8($,Z){let J=B("div","pf-slider-wrapper"),q=document.createElement("input");if(q.type="range",q.className="pf-slider",$.name!=null)q.name=$.name;if($.min!=null)q.min=String($.min);if($.max!=null)q.max=String($.max);if($.step!=null)q.step=String($.step);let U=$.name;if(U){let Q=Z.store.get(U);if(Q!=null)q.value=String(Q);q.addEventListener("input",()=>{if(Z.store.set(U,Number(q.value)),$.onChange!=null)k($.onChange,{...b(Z),scope:{...Z.scope,$event:Number(q.value)}})})}return J.appendChild(q),J}function C4($){$.style.padding="8px 12px",$.style.border="1px solid var(--border, #d1d5db)",$.style.borderRadius="var(--radius, 6px)",$.style.fontSize="14px",$.style.width="100%",$.style.boxSizing="border-box"}function J8($,Z){$.style.padding="8px 16px",$.style.borderRadius="var(--radius, 6px)",$.style.fontSize="14px",$.style.fontWeight="500",$.style.cursor="pointer",$.style.border="none";let J={default:{bg:"var(--primary, #3b82f6)",fg:"#fff"},secondary:{bg:"var(--secondary, #f3f4f6)",fg:"var(--secondary-foreground, #1f2937)"},destructive:{bg:"var(--destructive, #ef4444)",fg:"#fff"},outline:{bg:"transparent",fg:"inherit"},ghost:{bg:"transparent",fg:"inherit"},link:{bg:"transparent",fg:"var(--primary, #3b82f6)"}},q=J[Z]??J.default;if($.style.backgroundColor=q.bg,$.style.color=q.fg,Z==="outline")$.style.border="1px solid var(--border, #d1d5db)"}function K4($){return(Z,J)=>{let q=B("div",$);return L(Z,q,J),q}}function Z4($){return(Z,J)=>{let q=B("span",$);return q.textContent=K(Z.content,J),q}}function _1(){let $=document.createElement("hr");return $.className="pf-separator",$.style.border="none",$.style.borderTop="1px solid var(--border, #e5e7eb)",$.style.margin="4px 0",$}function Z8($,Z){let J=B("label","pf-radio");J.style.display="flex",J.style.alignItems="center",J.style.gap="8px",J.style.cursor="pointer";let q=document.createElement("input");if(q.type="radio",q.value=K($.value,Z),J.appendChild(q),$.label!=null){let U=B("span","pf-radio-label");U.textContent=K($.label,Z),J.appendChild(U)}return J}function q8($,Z){let J=B("fieldset","pf-radio-group");if(J.style.border="none",J.style.padding="0",J.style.display="flex",J.style.flexDirection="column",J.style.gap="8px",$.label!=null){let Q=document.createElement("legend");Q.textContent=K($.label,Z),Q.style.fontWeight="500",Q.style.marginBottom="4px",J.appendChild(Q)}L($,J,Z);let q=K($.name,Z),U=Z.store.get(q);for(let Q of Array.from(J.querySelectorAll('input[type="radio"]')))if(Q.name=q,U!=null&&Q.value===String(U))Q.checked=!0;return J.addEventListener("change",(Q)=>{let Y=Q.target;if(Y.type==="radio"){if(Z.store.set(q,Y.value),$.onChange!=null)k($.onChange,b(Z))}}),J}function U8($,Z){let J=B("div","pf-combobox"),q=document.createElement("input");if(q.className="pf-combobox-input",q.type="text",q.name=K($.name,Z),$.placeholder!=null)q.placeholder=K($.placeholder,Z);if($.value!==void 0)q.value=K($.value,Z);let U=q.name,Q=Z.store.get(U);if(Q!=null)q.value=String(Q);q.style.padding="6px 12px",q.style.borderRadius="6px",q.style.border="1px solid var(--border, #d1d5db)",q.style.width="100%",q.style.boxSizing="border-box";let Y=B("div","pf-combobox-dropdown");if(Y.style.display="none",Y.style.position="absolute",Y.style.background="var(--popover, #fff)",Y.style.border="1px solid var(--border, #d1d5db)",Y.style.borderRadius="6px",Y.style.maxHeight="200px",Y.style.overflowY="auto",Y.style.zIndex="50",L($,Y,Z),q.addEventListener("focus",()=>{Y.style.display="block"}),q.addEventListener("blur",()=>{setTimeout(()=>{Y.style.display="none"},150)}),$.searchable!==!1)q.addEventListener("input",()=>{let W=q.value.toLowerCase();for(let _ of Array.from(Y.querySelectorAll(".pf-combobox-option"))){let H=_.textContent.toLowerCase();_.style.display=H.includes(W)?"":"none"}});if($.onChange!=null)J.addEventListener("pf-combobox-select",()=>{k($.onChange,{...b(Z),scope:{...Z.scope,$event:q.value}})});return J.style.position="relative",J.appendChild(q),J.appendChild(Y),J}function Q8($,Z){let J=B("div","pf-combobox-option");return J.style.padding="6px 12px",J.style.cursor="pointer",J.textContent=K($.label??$.value,Z),J.dataset.value=K($.value,Z),J.addEventListener("mousedown",()=>{let q=J.closest(".pf-combobox"),U=q?.querySelector("input");if(U)U.value=J.dataset.value??"",Z.store.set(U.name,U.value),q?.dispatchEvent(new CustomEvent("pf-combobox-select",{bubbles:!1}))}),J}function Y8($,Z){let J=B("div","pf-calendar"),q=document.createElement("input");if(q.type="date",q.name=K($.name,Z),$.value!==void 0)q.value=K($.value,Z);let U=q.name,Q=Z.store.get(U);if(Q!=null)q.value=String(Q);if($.minDate!=null)q.min=K($.minDate,Z);if($.maxDate!=null)q.max=K($.maxDate,Z);return q.style.padding="6px 12px",q.style.borderRadius="6px",q.style.border="1px solid var(--border, #d1d5db)",q.addEventListener("change",()=>{if(Z.store.set(q.name,q.value),$.onChange!=null)k($.onChange,b(Z))}),J.appendChild(q),J}function W8($,Z){let J=B("div","pf-datepicker"),q=document.createElement("input");if(q.type="date",q.name=K($.name,Z),$.placeholder!=null)q.placeholder=K($.placeholder,Z);if($.value!==void 0)q.value=K($.value,Z);let U=q.name,Q=Z.store.get(U);if(Q!=null)q.value=String(Q);if($.minDate!=null)q.min=K($.minDate,Z);if($.maxDate!=null)q.max=K($.maxDate,Z);return q.style.padding="6px 12px",q.style.borderRadius="6px",q.style.border="1px solid var(--border, #d1d5db)",q.style.width="100%",q.style.boxSizing="border-box",q.addEventListener("change",()=>{if(Z.store.set(q.name,q.value),$.onChange!=null)k($.onChange,b(Z))}),J.appendChild(q),J}function M8($,Z){let J=B("div","pf-choice-card");if(J.style.border="2px solid var(--border, #d1d5db)",J.style.borderRadius="8px",J.style.padding="16px",J.style.cursor="pointer",J.style.transition="border-color 0.2s",J.dataset.value=K($.value,Z),$.selected===!0)J.dataset.selected="true",J.style.borderColor="var(--primary, #3b82f6)",J.style.backgroundColor="var(--accent, #eff6ff)";if($.label!=null){let q=B("div","pf-choice-card-label");q.textContent=K($.label,Z),q.style.fontWeight="600",J.appendChild(q)}if($.description!=null){let q=B("div","pf-choice-card-description");q.textContent=K($.description,Z),q.style.fontSize="14px",q.style.color="var(--muted-foreground, #6b7280)",J.appendChild(q)}if(L($,J,Z),$.onClick!=null)J.addEventListener("click",()=>{k($.onClick,b(Z))});return J}function B1(){M("Tabs",_8),M("Tab",N8),M("Accordion",B8),M("AccordionItem",H8),M("Dialog",G8),M("Popover",X8),M("Tooltip",K8),M("HoverCard",z8),M("Carousel",D8)}function _8($,Z){let J=B("div","pf-tabs"),q=B("div","pf-tabs-bar");q.setAttribute("role","tablist"),q.style.display="flex",q.style.gap="4px",q.style.borderBottom="2px solid var(--border, #e5e7eb)",q.style.marginBottom="12px";let U=[],Q=[];if($.children)for(let W=0;W<$.children.length;W++){let _=$.children[W],H=`pf-tab-${Math.random().toString(36).slice(2,8)}`,G=`pf-panel-${Math.random().toString(36).slice(2,8)}`,N=document.createElement("button");N.type="button",N.className="pf-tab-trigger",N.textContent=_.title??`Tab ${W+1}`,N.setAttribute("role","tab"),N.setAttribute("aria-selected",W===0?"true":"false"),N.setAttribute("aria-controls",G),N.id=H,N.tabIndex=W===0?0:-1,N.style.padding="8px 16px",N.style.border="none",N.style.background="none",N.style.cursor="pointer",N.style.borderBottom="2px solid transparent",N.style.marginBottom="-2px",N.style.fontSize="14px";let X=B("div","pf-tab-panel");if(X.style.display=W===0?"block":"none",X.setAttribute("role","tabpanel"),X.setAttribute("aria-labelledby",H),X.id=G,X.tabIndex=0,L(_,X,Z),N.addEventListener("click",()=>{Y(W)}),W===0)N.style.borderBottomColor="var(--primary, #3b82f6)",N.style.fontWeight="600";Q.push(N),U.push(X),q.appendChild(N)}function Y(W){U.forEach((_)=>_.style.display="none"),Q.forEach((_)=>{_.style.borderBottomColor="transparent",_.style.fontWeight="normal",_.setAttribute("aria-selected","false"),_.tabIndex=-1}),U[W].style.display="block",Q[W].style.borderBottomColor="var(--primary, #3b82f6)",Q[W].style.fontWeight="600",Q[W].setAttribute("aria-selected","true"),Q[W].tabIndex=0,Q[W].focus()}q.addEventListener("keydown",(W)=>{let _=Q.indexOf(W.target);if(_<0)return;let H;if(W.key==="ArrowRight")H=(_+1)%Q.length;else if(W.key==="ArrowLeft")H=(_-1+Q.length)%Q.length;else if(W.key==="Home")H=0;else if(W.key==="End")H=Q.length-1;else return;W.preventDefault(),Y(H)}),J.appendChild(q);for(let W of U)J.appendChild(W);return J}function N8($,Z){let J=B("div","pf-tab");return L($,J,Z),J}function B8($,Z){let J=B("div","pf-accordion");return L($,J,Z),J}function H8($,Z){let J=B("div","pf-accordion-item");J.style.borderBottom="1px solid var(--border, #e5e7eb)";let q=`pf-acc-${Math.random().toString(36).slice(2,8)}`,U=document.createElement("button");U.type="button",U.className="pf-accordion-trigger",U.textContent=$.title??"",U.setAttribute("aria-expanded","false"),U.setAttribute("aria-controls",q),U.style.width="100%",U.style.textAlign="left",U.style.padding="12px 0",U.style.border="none",U.style.background="none",U.style.cursor="pointer",U.style.fontSize="14px",U.style.fontWeight="500";let Q=B("div","pf-accordion-content");return Q.id=q,Q.setAttribute("role","region"),Q.setAttribute("aria-labelledby",U.id),Q.style.display="none",Q.style.paddingBottom="12px",L($,Q,Z),U.addEventListener("click",()=>{let Y=Q.style.display!=="none";Q.style.display=Y?"none":"block",U.setAttribute("aria-expanded",Y?"false":"true")}),J.appendChild(U),J.appendChild(Q),J}function G8($,Z){let J=B("div","pf-dialog-wrapper");if($.trigger!=null){let Q=w($.trigger,Z);Q.addEventListener("click",()=>{q.showModal()}),J.appendChild(Q)}let q=document.createElement("dialog");if(q.className="pf-dialog",q.setAttribute("aria-modal","true"),q.style.maxWidth="500px",q.style.width="100%",q.style.border="1px solid var(--border, #e5e7eb)",q.style.borderRadius="var(--radius, 8px)",q.style.padding="24px",$.title!=null){let Q=B("h2","pf-dialog-title");Q.textContent=K($.title,Z),Q.id=`pf-dialog-title-${Math.random().toString(36).slice(2,8)}`,q.setAttribute("aria-labelledby",Q.id),q.appendChild(Q)}if($.description!=null){let Q=B("p","pf-dialog-desc");Q.textContent=K($.description,Z),Q.style.color="var(--muted-foreground, #6b7280)",q.appendChild(Q)}let U=B("div","pf-dialog-body");if(L($,U,Z),q.appendChild(U),$.dismissible!==!1)q.addEventListener("click",(Q)=>{if(Q.target===q)q.close()});return document.addEventListener("prefab:close-overlay",()=>q.close()),J.appendChild(q),J}function X8($,Z){let J=B("div","pf-popover");J.style.position="relative",J.style.display="inline-block";let q=B("div","pf-popover-content");if(q.style.display="none",q.style.position="absolute",q.style.zIndex="50",q.style.padding="12px",q.style.border="1px solid var(--border, #e5e7eb)",q.style.borderRadius="var(--radius, 8px)",q.style.backgroundColor="var(--popover, #fff)",q.style.boxShadow="0 4px 6px -1px rgb(0 0 0 / 0.1)",$.title!=null){let U=B("div","pf-popover-title");U.textContent=K($.title,Z),U.style.fontWeight="600",U.style.marginBottom="4px",q.appendChild(U)}return L($,q,Z),J.addEventListener("click",(U)=>{if(q.contains(U.target)&&q.style.display!=="none")return;q.style.display=q.style.display==="none"?"block":"none"}),J.appendChild(q),J}function K8($,Z){let J=B("div","pf-tooltip");J.style.position="relative",J.style.display="inline-block";let q=`pf-tip-${Math.random().toString(36).slice(2,8)}`,U=B("div","pf-tooltip-content");return U.id=q,U.setAttribute("role","tooltip"),U.textContent=K($.content??"",Z),U.style.display="none",U.style.position="absolute",U.style.bottom="100%",U.style.left="50%",U.style.transform="translateX(-50%)",U.style.padding="4px 8px",U.style.borderRadius="4px",U.style.backgroundColor="var(--popover, #1f2937)",U.style.color="#fff",U.style.fontSize="12px",U.style.whiteSpace="nowrap",U.style.zIndex="50",L($,J,Z),J.setAttribute("aria-describedby",q),J.addEventListener("mouseenter",()=>{U.style.display="block"}),J.addEventListener("mouseleave",()=>{U.style.display="none"}),J.addEventListener("focus",()=>{U.style.display="block"},!0),J.addEventListener("blur",()=>{U.style.display="none"},!0),J.appendChild(U),J}function z8($,Z){let J=B("div","pf-hover-card");J.style.position="relative",J.style.display="inline-block";let q=B("div","pf-hover-card-content");return q.style.display="none",q.style.position="absolute",q.style.zIndex="50",q.style.padding="16px",q.style.border="1px solid var(--border, #e5e7eb)",q.style.borderRadius="var(--radius, 8px)",q.style.backgroundColor="var(--card, #fff)",q.style.boxShadow="0 4px 6px -1px rgb(0 0 0 / 0.1)",q.style.minWidth="200px",L($,q,Z),J.addEventListener("mouseenter",()=>{q.style.display="block"}),J.addEventListener("mouseleave",()=>{q.style.display="none"}),J.appendChild(q),J}function D8($,Z){let J=B("div","pf-carousel");J.style.position="relative",J.style.overflow="hidden",J.setAttribute("role","region"),J.setAttribute("aria-roledescription","carousel"),J.setAttribute("aria-label",K($.label??"Carousel",Z));let q=B("div","pf-carousel-track");q.style.display="flex",q.style.transition="transform 0.3s ease",L($,q,Z);let U=0,Q=$.children?.length??0,Y=document.createElement("button");Y.type="button",Y.textContent="‹",Y.className="pf-carousel-prev",Y.setAttribute("aria-label","Previous slide"),Y.style.position="absolute",Y.style.left="4px",Y.style.top="50%",Y.style.transform="translateY(-50%)",Y.style.zIndex="10";let W=document.createElement("button");W.type="button",W.textContent="›",W.className="pf-carousel-next",W.setAttribute("aria-label","Next slide"),W.style.position="absolute",W.style.right="4px",W.style.top="50%",W.style.transform="translateY(-50%)",W.style.zIndex="10";let _=()=>{q.style.transform=`translateX(-${U*100}%)`};return Y.addEventListener("click",()=>{if(Q===0)return;U=Math.max(0,U-1),_()}),W.addEventListener("click",()=>{if(Q===0)return;U=Math.min(Q-1,U+1),_()}),J.appendChild(q),J.appendChild(Y),J.appendChild(W),J}function H1(){M("ForEach",F8),M("If",G1),M("Elif",E8),M("Else",T8),M("Condition",L8),M("Define",j8),M("Use",O8),M("Slot",P8)}function F8($,Z){let J=document.createDocumentFragment(),q=$.expression;if(!q)return J;let U;if(u(q)){let Y=x(q,Z.store,Z.scope);U=Array.isArray(Y)?Y:[]}else{let Y=Z.store.get(q);U=Array.isArray(Y)?Y:[]}let Q=$.let??{};for(let Y=0;Y<U.length;Y++){let W=U[Y],_={...Z.scope,$item:W,$index:Y,...Q},H={...Z,scope:_};if($.children)n($.children,J,H)}return J}function G1($,Z){if(X1($.condition,Z)){let q=document.createDocumentFragment();if($.children)n($.children,q,Z);return q}return document.createDocumentFragment()}function E8($,Z){return G1($,Z)}function T8($,Z){let J=document.createDocumentFragment();if($.children)n($.children,J,Z);return J}function X1($,Z){if(!$)return!1;if(u($))return Boolean(x($,Z.store,Z.scope));return Boolean(Z.store.get($))}function L8($,Z){let J=document.createDocumentFragment(),q=$.cases,U=$.else;if(q){for(let Q of q)if(X1(Q.when,Z)){if(Q.children)n(Q.children,J,Z);return J}}if(U)n(U,J,Z);return J}function j8($,Z){let J=$.name;if(J&&$.children)Z.templates=Z.templates??{},Z.templates[J]=$.children;return document.createDocumentFragment()}function O8($,Z){let J=document.createDocumentFragment(),q=$.def??$.name,U=Z.templates?.[q];if(!U)return J;let Q=$.overrides??{},Y={...Z.scope,...Q},W={...Z,scope:Y};for(let _ of U)J.appendChild(w(_,W));return J}function P8($,Z){let J=document.createDocumentFragment(),q=$.name??"default",Q=Z.slots?.[q]??$.children;if(Q)for(let Y of Q)J.appendChild(w(Y,Z));return J}function K1(){M("Alert",V8),M("AlertTitle",I8),M("AlertDescription",R8)}function V8($,Z){let J=B("div","pf-alert");J.setAttribute("role","alert");let q=$.variant??"default";if(J.setAttribute("data-variant",q),J.style.padding="12px 16px",J.style.borderRadius="var(--radius, 8px)",J.style.border="1px solid var(--border, #e5e7eb)",q==="destructive")J.style.borderColor="var(--destructive, #ef4444)",J.style.color="var(--destructive, #ef4444)";if($.icon!=null){let U=B("span","pf-alert-icon");U.setAttribute("data-icon",$.icon),U.style.marginRight="8px",J.appendChild(U)}return L($,J,Z),J}function I8($,Z){let J=B("h5","pf-alert-title");return J.textContent=K($.content,Z),J.style.fontWeight="600",J.style.marginBottom="4px",J}function R8($,Z){let J=B("p","pf-alert-description");return J.textContent=K($.content,Z),J.style.fontSize="14px",J}function z1(){M("Image",A8),M("Audio",k8),M("Video",f8),M("Embed",S8),M("Svg",C8),M("DropZone",b8),M("Mermaid",y8)}function A8($,Z){let J=document.createElement("img");if(J.className="pf-image",J.src=K($.src,Z),$.alt!=null)J.alt=K($.alt,Z);if($.width!=null)J.width=$.width;if($.height!=null)J.height=$.height;return J.style.maxWidth="100%",J}function k8($,Z){let J=document.createElement("audio");return J.className="pf-audio",J.src=K($.src,Z),J.controls=!0,J}function f8($,Z){let J=document.createElement("video");if(J.className="pf-video",J.src=K($.src,Z),J.controls=!0,$.width!=null)J.width=$.width;if($.height!=null)J.height=$.height;return J.style.maxWidth="100%",J}function S8($,Z){let J=B("div","pf-embed"),q=document.createElement("iframe");return q.src=K($.src,Z),q.style.width="100%",q.style.height=$.height!=null?`${$.height}px`:"400px",q.style.border="none",q.setAttribute("sandbox","allow-scripts"),J.appendChild(q),J}var w8=new Set(["svg","g","path","rect","circle","ellipse","line","polyline","polygon","text","tspan","textpath","defs","use","symbol","clippath","mask","pattern","lineargradient","radialgradient","stop","filter","fegaussianblur","feoffset","femerge","femergenode","fecolormatrix","feblend","title","desc"]);function C8($,Z){let J=B("div","pf-svg"),q=K($.content,Z);if(!q.includes("<svg"))return J;let Q=new DOMParser().parseFromString(q,"image/svg+xml").querySelector("svg");if(!Q)return J;return D1(Q),J.appendChild(document.importNode(Q,!0)),J}function D1($){let Z=Array.from($.children);for(let J of Z){if(!w8.has(J.tagName.toLowerCase())){J.remove();continue}for(let q of Array.from(J.attributes)){let U=q.name.toLowerCase();if(U.startsWith("on")||U==="href"&&q.value.trim().toLowerCase().startsWith("javascript:"))J.removeAttribute(q.name)}D1(J)}}function b8($,Z){let J=B("div","pf-dropzone");return J.style.border="2px dashed var(--border, #d1d5db)",J.style.borderRadius="var(--radius, 8px)",J.style.padding="32px",J.style.textAlign="center",J.style.cursor="pointer",J.textContent=K($.label??"Drop files here",Z),J.addEventListener("dragover",(q)=>{q.preventDefault(),J.style.borderColor="var(--primary, #3b82f6)"}),J.addEventListener("dragleave",()=>{J.style.borderColor="var(--border, #d1d5db)"}),J.addEventListener("drop",(q)=>{q.preventDefault(),J.style.borderColor="var(--border, #d1d5db)"}),J}function y8($,Z){let J=B("div","pf-mermaid");J.setAttribute("data-mermaid","true");let q=K($.content,Z);if(J.textContent=q,typeof globalThis.mermaid<"u")J.classList.add("mermaid"),J.textContent=q;return J}var D4=["#3b82f6","#10b981","#f59e0b","#ef4444","#8b5cf6","#ec4899"];function F4($,Z){let J=document.createElement("div");return J.className="pf-chart-tooltip",$.appendChild(J),$.addEventListener("mouseleave",()=>{J.classList.remove("pf-visible")}),{wrapper:$,tooltip:J,svgEl:Z}}function q4($,Z,J,q,U){let{tooltip:Q,svgEl:Y,wrapper:W}=$;if(U.length===0)return;let _="";if(q)_+=`<div class="pf-chart-tooltip-label">${z4(q)}</div>`;for(let E of U)_+='<div class="pf-chart-tooltip-row">',_+=`<span class="pf-chart-tooltip-dot" style="background:${z4(E.color)}"></span>`,_+=`<span>${z4(E.label)}:</span> <strong>${z4(String(E.value))}</strong>`,_+="</div>";Q.innerHTML=_;let H=Y.getBoundingClientRect(),G=W.getBoundingClientRect(),N=Y.viewBox.baseVal,X=H.width/(N.width||1),T=H.left-G.left+Z*X,D=Q.offsetWidth||100,z=T+12;if(z+D>G.width)z=T-D-12;Q.style.left=`${Math.max(0,z)}px`,Q.style.top="4px",Q.classList.add("pf-visible")}function z4($){return $.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;")}function F1($,Z,J,q,U,Q,Y,W){let _=U.plotWidth/J.length;for(let H=0;H<J.length;H++){let G=U.plotLeft+H*_,N=document.createElementNS("http://www.w3.org/2000/svg","rect");N.setAttribute("x",String(G)),N.setAttribute("y",String(U.plotTop)),N.setAttribute("width",String(_)),N.setAttribute("height",String(U.plotHeight)),N.setAttribute("fill","transparent"),N.style.cursor="default";let X=Q?J[H][Q]:void 0,T=X!=null?W?W(X):String(X):void 0,D=q.map((A,R)=>({label:A.label??A.dataKey,value:Y(J[H][A.dataKey],A,R),color:A.color??D4[R%D4.length]})),z=G+_/2,E=()=>q4($,z,U.plotTop,T,D),P=()=>$.tooltip.classList.remove("pf-visible");N.addEventListener("mouseenter",E),N.addEventListener("mouseleave",P),N.addEventListener("touchstart",E,{passive:!0}),N.addEventListener("touchend",P,{passive:!0}),Z.appendChild(N)}}function E1($,Z,J,q,U,Q,Y,W,_,H){let G=J.length===1?U.plotWidth:U.plotWidth/(J.length-1);for(let N=0;N<J.length;N++){let X=J.length===1?(U.plotLeft+U.plotRight)/2:U.plotLeft+N/(J.length-1)*U.plotWidth,T=J.length===1?U.plotLeft:X-G/2,D=J.length===1?U.plotWidth:G,z=document.createElementNS("http://www.w3.org/2000/svg","rect");z.setAttribute("x",String(Math.max(U.plotLeft,T))),z.setAttribute("y",String(U.plotTop)),z.setAttribute("width",String(Math.min(D,U.plotRight-Math.max(U.plotLeft,T)))),z.setAttribute("height",String(U.plotHeight)),z.setAttribute("fill","transparent"),z.style.cursor="default";let E=Q?J[N][Q]:void 0,P=E!=null?H?H(E):String(E):void 0,A=q.map((j,C)=>({label:j.label??j.dataKey,value:Y(J[N][j.dataKey],j,C),color:j.color??D4[C%D4.length]})),R=()=>{if(q4($,X,U.plotTop,P,A),W)W.setAttribute("x1",String(X)),W.setAttribute("x2",String(X)),W.setAttribute("opacity","1");if(_)for(let j of _){for(let C of j)C.setAttribute("data-visible","false");j[N]?.setAttribute("data-visible","true")}},F=()=>{if($.tooltip.classList.remove("pf-visible"),W)W.setAttribute("opacity","0");if(_)for(let j of _)for(let C of j)C.setAttribute("data-visible","false")};z.addEventListener("mouseenter",R),z.addEventListener("mouseleave",F),z.addEventListener("touchstart",R,{passive:!0}),z.addEventListener("touchend",F,{passive:!0}),Z.appendChild(z)}}function L1(){M("BarChart",v8),M("LineChart",T1),M("AreaChart",T1),M("PieChart",h8),M("RadarChart",b4),M("ScatterChart",b4),M("RadialChart",b4),M("Histogram",g8)}var l=["#3b82f6","#10b981","#f59e0b","#ef4444","#8b5cf6","#ec4899"],U4="var(--muted-foreground, #6b7280)",m8="var(--border, #e5e7eb)",y4="10";function j1($,Z,J,q=!1){let U=J?44:0,Q=$-(q?44:0),Y=10,W=Z-24;return{plotLeft:U,plotRight:Q,plotTop:10,plotBottom:W,plotWidth:Q-U,plotHeight:W-10}}function O1($,Z=5){if($<=0)return[0];let J=$/Z,q=Math.pow(10,Math.floor(Math.log10(J))),U=J/q,Q=U<=1.5?q:U<=3?2*q:U<=7?5*q:10*q,Y=[];for(let W=0;W<=$+Q*0.01;W+=Q)Y.push(Math.round(W*1000)/1000);return Y}function P1($,Z,J,q,U){let Q=O1(J);for(let Y of Q){let W=Z.plotBottom-(J>0?Y/J*Z.plotHeight:0),_=document.createElementNS("http://www.w3.org/2000/svg","text");if(_.setAttribute("x",String(Z.plotLeft-6)),_.setAttribute("y",String(W+3)),_.setAttribute("text-anchor","end"),_.setAttribute("font-size",y4),_.setAttribute("fill",U4),_.textContent=m4(Y,U),$.appendChild(_),q&&Y>0){let H=document.createElementNS("http://www.w3.org/2000/svg","line");H.setAttribute("x1",String(Z.plotLeft)),H.setAttribute("y1",String(W)),H.setAttribute("x2",String(Z.plotRight)),H.setAttribute("y2",String(W)),H.setAttribute("stroke",m8),H.setAttribute("stroke-width","1"),H.setAttribute("stroke-dasharray","4 3"),$.appendChild(H)}}}function V1($,Z,J,q){let U=O1(J);for(let Q of U){let Y=Z.plotBottom-(J>0?Q/J*Z.plotHeight:0),W=document.createElementNS("http://www.w3.org/2000/svg","text");W.setAttribute("x",String(Z.plotRight+6)),W.setAttribute("y",String(Y+3)),W.setAttribute("text-anchor","start"),W.setAttribute("font-size",y4),W.setAttribute("fill",U4),W.textContent=m4(Q,q),$.appendChild(W)}}function I1($,Z,J,q,U,Q){for(let Y=0;Y<Z.length;Y++){let W=document.createElementNS("http://www.w3.org/2000/svg","text");W.setAttribute("x",String(q(Y))),W.setAttribute("y",String(U+14)),W.setAttribute("text-anchor","middle"),W.setAttribute("font-size",y4),W.setAttribute("fill",U4);let _=Z[Y][J];W.textContent=_==null?"":Q?Q(_):String(_),$.appendChild(W)}}function R1($,Z){let J=document.createElementNS("http://www.w3.org/2000/svg","line");J.setAttribute("x1",String(Z.plotLeft)),J.setAttribute("y1",String(Z.plotBottom)),J.setAttribute("x2",String(Z.plotRight)),J.setAttribute("y2",String(Z.plotBottom)),J.setAttribute("stroke",U4),J.setAttribute("stroke-width","1"),$.appendChild(J)}function $4($,Z,J){if($==null)return"";let q=y(`{{ __v | ${Z} }}`,{...J,scope:{...J.scope,__v:$}});return q==null?String($):String(q)}function m4($,Z){if(Z==="currency")return`$${$.toLocaleString()}`;if(Z==="percent")return`${$}%`;if($>=1e6)return`${($/1e6).toFixed(1)}M`;if($>=1000)return`${($/1000).toFixed(1)}K`;return String($)}function A1($,Z,J){return(q,U)=>{if(q===null||q===void 0)return"—";if(U.tooltipFormat)return $4(q,U.tooltipFormat,$);let Q=U.yAxisId==="right"?J:Z;return m4(Number(q),Q)}}function v8($,Z){let J=B("div","pf-chart pf-bar-chart"),q=y($.data,Z)??[],U=$.series??[],Q=$.height??300;if(q.length===0||U.length===0)return J.textContent="No chart data",J;let Y=$.showYAxis!==!1,W=$.showGrid===!0,_=$.showYAxisRight===!0,H=$.showTooltip!==!1,G=$.xAxis,N=$.tooltipXKey,X=$.xAxisFormat,T=$.tooltipXFormat,D=U.filter((I)=>I.yAxisId!=="right"),z=U.filter((I)=>I.yAxisId==="right"),E=_&&z.length>0,P=D.length>0?Math.max(...q.flatMap((I)=>D.map((V)=>Number(I[V.dataKey]??0))),1):1,A=E?Math.max(...q.flatMap((I)=>z.map((V)=>Number(I[V.dataKey]??0))),1):1,R=400,F=j1(R,Q,Y,E),j=E4(R,Q,"Bar");if(Y)P1(j,F,P,W,$.yAxisFormat);if(E)V1(j,F,A,$.yAxisRightFormat);R1(j,F);let C=F.plotWidth/q.length,i=C/(U.length+1);for(let I=0;I<q.length;I++)for(let V=0;V<U.length;V++){let f=U[V],p=q[I][f.dataKey];if(p===null||p===void 0)continue;let m=f.yAxisId==="right"?A:P,c=Number(p),s=Math.max(0,c/m*F.plotHeight),o=F.plotLeft+I*C+V*i+i/2,O=document.createElementNS("http://www.w3.org/2000/svg","rect");O.setAttribute("x",String(o)),O.setAttribute("y",String(F.plotBottom-s)),O.setAttribute("width",String(i*0.8)),O.setAttribute("height",String(s)),O.setAttribute("fill",f.color??l[V%l.length]),O.setAttribute("rx","2"),j.appendChild(O)}if(G){let I=X?(V)=>$4(V,X,Z):void 0;I1(j,q,G,(V)=>{return F.plotLeft+V*C+C/2},F.plotBottom,I)}if(H){let I=F4(J,j),V=A1(Z,$.yAxisFormat,$.yAxisRightFormat);F1(I,j,q,U,F,N??G,V,T?(p)=>$4(p,T,Z):void 0)}return v4(J,U,$.showLegend),J.appendChild(j),J}function T1($,Z){let J=B("div",`pf-chart pf-${$.type.toLowerCase()}-chart`),q=y($.data,Z)??[],U=$.series??[],Q=$.height??300;if(q.length===0||U.length===0)return J.textContent="No chart data",J;let Y=$.showYAxis!==!1,W=$.showGrid===!0,_=$.showYAxisRight===!0,H=$.showTooltip!==!1,G=$.xAxis,N=$.tooltipXKey,X=$.xAxisFormat,T=$.tooltipXFormat,D=U.filter((V)=>V.yAxisId!=="right"),z=U.filter((V)=>V.yAxisId==="right"),E=_&&z.length>0,P=D.length>0?Math.max(...q.flatMap((V)=>D.map((f)=>Number(V[f.dataKey]??0))),1):1,A=E?Math.max(...q.flatMap((V)=>z.map((f)=>Number(V[f.dataKey]??0))),1):1,R=400,F=j1(R,Q,Y,E),j=E4(R,Q,$.type==="AreaChart"?"Area":"Line"),C=$.type==="AreaChart";if(Y)P1(j,F,P,W,$.yAxisFormat);if(E)V1(j,F,A,$.yAxisRightFormat);R1(j,F);let i=[];for(let V=0;V<U.length;V++){let f=U[V],p=f.yAxisId==="right",d=p?A:P,m=f.color??l[V%l.length],c=q.map((O,S)=>{let v=O[f.dataKey],a=v===null||v===void 0,Y4=q.length===1?(F.plotLeft+F.plotRight)/2:F.plotLeft+S/(q.length-1)*F.plotWidth,u1=a?F.plotBottom:F.plotBottom-Number(v)/d*F.plotHeight;return{x:Y4,y:u1,isNull:a}});if(C){let O=[],S=()=>{if(O.length<2){O=[];return}let v=`M ${O[0].x},${F.plotBottom} `+O.map((Y4)=>`L ${Y4.x},${Y4.y}`).join(" ")+` L ${O[O.length-1].x},${F.plotBottom} Z`,a=document.createElementNS("http://www.w3.org/2000/svg","path");a.setAttribute("d",v),a.setAttribute("fill",m),a.setAttribute("opacity","0.15"),j.appendChild(a),O=[]};for(let v of c){if(v.isNull){S();continue}O.push(v)}S()}let s="";for(let O of c){if(O.isNull)continue;let S=c.indexOf(O),v=S===0||c[S-1].isNull;s+=`${v?"M":"L"} ${O.x},${O.y} `}if(s){let O=document.createElementNS("http://www.w3.org/2000/svg","path");if(O.setAttribute("d",s.trim()),O.setAttribute("fill","none"),O.setAttribute("stroke",m),O.setAttribute("stroke-width","2"),p)O.setAttribute("stroke-dasharray","6 3");j.appendChild(O)}let o=[];for(let O of c){let S=document.createElementNS("http://www.w3.org/2000/svg","circle");if(S.setAttribute("cx",String(O.x)),S.setAttribute("cy",String(O.y)),S.setAttribute("r","4"),S.setAttribute("fill",m),S.setAttribute("class","pf-data-dot"),S.setAttribute("data-visible","false"),S.style.pointerEvents="none",O.isNull)S.style.display="none";j.appendChild(S),o.push(S)}i.push(o)}let I=document.createElementNS("http://www.w3.org/2000/svg","line");if(I.setAttribute("class","pf-crosshair"),I.setAttribute("x1",String(F.plotLeft)),I.setAttribute("x2",String(F.plotLeft)),I.setAttribute("y1",String(F.plotTop)),I.setAttribute("y2",String(F.plotBottom)),I.setAttribute("stroke",U4),I.setAttribute("stroke-width","1"),I.setAttribute("stroke-dasharray","3 3"),I.setAttribute("opacity","0"),j.appendChild(I),G){let V=X?(f)=>$4(f,X,Z):void 0;I1(j,q,G,(f)=>{return q.length===1?(F.plotLeft+F.plotRight)/2:F.plotLeft+f/(q.length-1)*F.plotWidth},F.plotBottom,V)}if(H){let V=F4(J,j),f=A1(Z,$.yAxisFormat,$.yAxisRightFormat);E1(V,j,q,U,F,N??G,f,I,i,T?(d)=>$4(d,T,Z):void 0)}return v4(J,U,$.showLegend),J.appendChild(j),J}function h8($,Z){let J=B("div","pf-chart pf-pie-chart"),q=y($.data,Z)??[],U=$.series??[],Q=$.height??300,Y=Math.min(Q,300),W=$.showTooltip!==!1;if(q.length===0||U.length===0)return J.textContent="No chart data",J;let _=E4(Y,Y,"Pie"),H=Y/2,G=Y/2,N=Y/2-10,X=U[0].dataKey,T=$.xAxis,D=$.tooltipXKey,z=$.tooltipXFormat,E=q.map((F)=>Number(F[X]??0)),P=E.reduce((F,j)=>F+j,0);if(P===0)return J.textContent="No chart data",J.appendChild(_),J;let A=W?F4(J,_):void 0,R=-Math.PI/2;for(let F=0;F<E.length;F++){let j=E[F]/P*2*Math.PI,C=R+j,i=j>Math.PI?1:0,I=H+N*Math.cos(R),V=G+N*Math.sin(R),f=H+N*Math.cos(C),p=G+N*Math.sin(C),d=l[F%l.length],m=document.createElementNS("http://www.w3.org/2000/svg","path");if(m.setAttribute("d",`M ${H},${G} L ${I},${V} A ${N},${N} 0 ${i} 1 ${f},${p} Z`),m.setAttribute("fill",d),m.style.cursor="default",A){let c=D??T,s=c?q[F][c]:void 0,o=s!=null?z?$4(s,z,Z):String(s):`Slice ${F+1}`,O=`${(E[F]/P*100).toFixed(1)}%`,S=R+j/2,v=H+N*0.6*Math.cos(S);m.addEventListener("mouseenter",()=>{q4(A,v,G,o,[{label:U[0].label??X,value:`${E[F]} (${O})`,color:d}])}),m.addEventListener("mouseleave",()=>{A.tooltip.classList.remove("pf-visible")}),m.addEventListener("touchstart",()=>{q4(A,v,G,o,[{label:U[0].label??X,value:`${E[F]} (${O})`,color:d}])},{passive:!0}),m.addEventListener("touchend",()=>{A.tooltip.classList.remove("pf-visible")},{passive:!0})}_.appendChild(m),R=C}return v4(J,U,$.showLegend),J.appendChild(_),J}function b4($,Z){let J=B("div",`pf-chart pf-${$.type.toLowerCase()}`);return J.textContent=`${$.type} — not yet supported in renderer`,J.style.padding="24px",J.style.textAlign="center",J.style.color="var(--muted-foreground, #6b7280)",J}function E4($,Z,J){let q=document.createElementNS("http://www.w3.org/2000/svg","svg");if(q.setAttribute("width","100%"),q.setAttribute("height",String(Z)),q.setAttribute("viewBox",`0 0 ${$} ${Z}`),q.setAttribute("role","img"),J)q.setAttribute("aria-label",`${J} chart`);return q.style.overflow="visible",q}function v4($,Z,J){if(J===!1||Z.length<=1)return;let q=B("div","pf-chart-legend");q.style.display="flex",q.style.gap="12px",q.style.fontSize="12px",q.style.marginBottom="8px";for(let U=0;U<Z.length;U++){let Q=B("div","pf-chart-legend-item");Q.style.display="flex",Q.style.alignItems="center",Q.style.gap="4px";let Y=B("span");Y.style.width="8px",Y.style.height="8px",Y.style.borderRadius="50%",Y.style.backgroundColor=Z[U].color??l[U%l.length];let W=B("span");W.textContent=Z[U].label??Z[U].dataKey,Q.appendChild(Y),Q.appendChild(W),q.appendChild(Q)}$.appendChild(q)}function g8($,Z){let J=B("div","pf-chart pf-histogram"),q=y($.data,Z);if(!q||q.length===0)return J.textContent="No data",J;let U=q,Q=$.bins??10,Y=$.height??200,W=$.color??l[0],_=Math.min(...U),G=(Math.max(...U)-_)/Q||1,N=Array(Q).fill(0);for(let P of U){let A=Math.min(Math.floor((P-_)/G),Q-1);N[A]++}let X=Math.max(...N),T=300,D=Y,z=T/Q,E=E4(T,D,"Histogram");for(let P=0;P<Q;P++){let A=X>0?N[P]/X*D:0,R=document.createElementNS("http://www.w3.org/2000/svg","rect");R.setAttribute("x",String(P*z)),R.setAttribute("y",String(D-A)),R.setAttribute("width",String(z-1)),R.setAttribute("height",String(A)),R.setAttribute("fill",W),E.appendChild(R)}return J.appendChild(E),J}function k1(){M("Table",u8),M("TableHead",h4("thead")),M("TableBody",h4("tbody")),M("TableFooter",h4("tfoot")),M("TableRow",x8),M("TableHeader",p8),M("TableCell",c8),M("TableCaption",s8),M("ExpandableRow",l8)}function u8($,Z){let J=document.createElement("table");return J.className="pf-table",J.style.width="100%",J.style.borderCollapse="collapse",L($,J,Z),J}function h4($){return(Z,J)=>{let q=document.createElement($);return q.className=`pf-${$}`,L(Z,q,J),q}}function x8($,Z){let J=document.createElement("tr");return J.className="pf-table-row",L($,J,Z),J}function p8($,Z){let J=document.createElement("th");return J.className="pf-table-header",J.style.textAlign="left",J.style.padding="8px 12px",J.style.borderBottom="2px solid var(--border, #e5e7eb)",J.style.fontWeight="600",J.textContent=K($.content,Z),J}function c8($,Z){let J=document.createElement("td");if(J.className="pf-table-cell",J.style.padding="8px 12px",J.style.borderBottom="1px solid var(--border, #e5e7eb)",$.colSpan!=null)J.colSpan=$.colSpan;if($.rowSpan!=null)J.rowSpan=$.rowSpan;return L($,J,Z),J}function s8($,Z){let J=document.createElement("caption");return J.className="pf-table-caption",J.style.padding="8px",J.style.color="var(--muted-foreground, #6b7280)",J.style.fontSize="14px",J.textContent=K($.content,Z),J}function l8($,Z){let J=B("div","pf-expandable-row"),q=B("div","pf-expandable-row-summary");q.style.cursor="pointer",q.style.display="flex",q.style.alignItems="center",q.style.gap="8px";let U=B("span","pf-expandable-arrow");U.textContent="▶",U.style.transition="transform 0.2s",U.style.fontSize="10px",q.appendChild(U);let Q=$.summary;if(Q)for(let _ of Q)q.appendChild(w(_,Z));let Y=B("div","pf-expandable-row-detail");Y.style.display="none",Y.style.paddingLeft="24px",L($,Y,Z);let W=!1;return q.addEventListener("click",()=>{W=!W,Y.style.display=W?"block":"none",U.style.transform=W?"rotate(90deg)":""}),J.appendChild(q),J.appendChild(Y),J}var f1=!1;function T4(){if(f1)return;f1=!0,$1(),U1(),W1(),M1(),N1(),B1(),H1(),K1(),z1(),L1(),k1()}function S1($){return $.replace(/[^a-zA-Z0-9_-]/g,"")}function w1($){return $.replace(/[{}<>;]/g,"").replace(/\b(url|expression)\s*\(/gi,"")}function C1($,Z){if(!Z)return;if(Z.light)for(let[J,q]of Object.entries(Z.light))$.style.setProperty(`--${S1(J)}`,w1(q));if(Z.dark){let q=document.getElementById("prefab-dark-theme");if(!q)q=document.createElement("style"),q.id="prefab-dark-theme",document.head.appendChild(q);let U=Object.entries(Z.dark).map(([Q,Y])=>` --${S1(Q)}: ${w1(Y)};`).join(`
3
+ `),Z=[],q=0;while(q<J.length){let U=J[q];if(U.trimStart().startsWith("```")){let W=U.trimStart().slice(3).trim(),_=[];q++;while(q<J.length&&!J[q].trimStart().startsWith("```"))_.push(X0(J[q])),q++;q++;let B=W?` data-language="${X0(W)}"`:"";Z.push(`<pre class="pf-code"><code${B}>${_.join(`
4
+ `)}</code></pre>`);continue}if(/^(\s*[-*_]\s*){3,}$/.test(U)){Z.push("<hr />"),q++;continue}let Q=/^(#{1,6})\s+(.+)$/.exec(U);if(Q){let W=Q[1].length;Z.push(`<h${W}>${G0(Q[2])}</h${W}>`),q++;continue}if(U.startsWith("> ")||U===">"){let W=[];while(q<J.length&&(J[q].startsWith("> ")||J[q]===">"))W.push(J[q].replace(/^>\s?/,"")),q++;Z.push(`<blockquote>${Q1(W.join(`
5
+ `))}</blockquote>`);continue}if(/^[\s]*[-*+]\s+/.test(U)){Z.push("<ul>");while(q<J.length&&/^[\s]*[-*+]\s+/.test(J[q]))Z.push(`<li>${G0(J[q].replace(/^[\s]*[-*+]\s+/,""))}</li>`),q++;Z.push("</ul>");continue}if(/^[\s]*\d+\.\s+/.test(U)){Z.push("<ol>");while(q<J.length&&/^[\s]*\d+\.\s+/.test(J[q]))Z.push(`<li>${G0(J[q].replace(/^[\s]*\d+\.\s+/,""))}</li>`),q++;Z.push("</ol>");continue}if(U.trim()===""){q++;continue}let Y=[];while(q<J.length&&J[q].trim()!==""&&!/^#{1,6}\s/.test(J[q])&&!/^[-*+]\s/.test(J[q])&&!/^\d+\.\s/.test(J[q])&&!J[q].startsWith("> ")&&!J[q].trimStart().startsWith("```")&&!/^(\s*[-*_]\s*){3,}$/.test(J[q]))Y.push(J[q]),q++;Z.push(`<p>${Y.map(G0).join("<br />")}</p>`)}return Z.join(`
6
+ `)}function w4($,J){let Z=document.createElement("kbd");return Z.className="pf-kbd",Z.textContent=X($.content,J),Z}function W1(){M("Card",C4),M("CardHeader",w0("pf-card-header")),M("CardTitle",Y1("pf-card-title","h3")),M("CardDescription",Y1("pf-card-description","p")),M("CardContent",w0("pf-card-content")),M("CardFooter",w0("pf-card-footer"))}function C4($,J){let Z=H("div","pf-card");return Z.style.overflow="hidden",L($,Z,J),Z}function w0($){return(J,Z)=>{let q=H("div",$);return q.style.padding="16px 24px",L(J,q,Z),q}}function Y1($,J){return(Z,q)=>{let U=document.createElement(J);return U.className=$,U.textContent=X(Z.content,q),U}}function M1(){M("DataTable",y4),M("Badge",b4),M("Dot",m4),M("Metric",v4),M("Ring",h4),M("Progress",g4),M("Separator",u4),M("Loader",x4),M("Icon",p4),M("Sparkline",c4)}function y4($,J){let Z=H("div","pf-datatable-wrapper"),q=document.createElement("table");q.className="pf-datatable",q.style.width="100%",q.style.borderCollapse="collapse";let U=$.columns??[],Q=b($.rows,J),Y=$.rowKey,W=$.selected,_=document.createElement("thead"),B=document.createElement("tr");for(let N of U){let z=document.createElement("th");z.className="pf-datatable-th",z.textContent=N.header??N.key,z.style.padding="8px 12px",z.style.textAlign="left",B.appendChild(z)}_.appendChild(B),q.appendChild(_);let G=document.createElement("tbody");if(Array.isArray(Q)){let N=W!=null?b(W,J):void 0;for(let z of Q){let T=document.createElement("tr");T.className="pf-datatable-row";let D=z;if(Y&&N!=null&&D[Y]!=null&&String(D[Y])===String(N))T.classList.add("pf-datatable-row-selected");if($.onRowClick!=null&&Y)T.style.cursor="pointer",T.addEventListener("click",()=>{let K={...J.scope,$item:D,$index:Q.indexOf(z)},E=y({...J,scope:K});k($.onRowClick,E)});for(let K of U){let E=document.createElement("td");E.className="pf-datatable-td";let P;if(K.accessor)P=b(`{{ $item.${K.accessor} }}`,{...J,scope:{...J.scope,$item:D}});else if(P=D[K.key],K.format&&P!=null)P=b(`{{ __fmtVal | ${K.format} }}`,{...J,scope:{...J.scope,__fmtVal:P}});E.textContent=P==null?"":String(P),E.style.padding="8px 12px",T.appendChild(E)}G.appendChild(T)}}if(q.appendChild(G),$.search===!0){let N=document.createElement("input");N.type="text",N.placeholder="Search...",N.className="pf-datatable-search",N.style.marginBottom="8px",N.style.padding="6px 12px",N.style.width="100%",N.style.boxSizing="border-box",N.addEventListener("input",()=>{let z=N.value.toLowerCase(),T=Array.from(G.querySelectorAll("tr"));for(let D of T){let K=D.textContent.toLowerCase();D.style.display=K.includes(z)?"":"none"}}),Z.appendChild(N)}return Z.appendChild(q),Z}function b4($,J){let Z=H("span","pf-badge"),q=$.variant??"default";return Z.setAttribute("data-variant",q),Z.style.alignItems="center",Z.style.padding="2px 10px",Z.style.borderRadius="9999px",Z.style.fontSize="12px",Z.style.fontWeight="500",Z.textContent=X($.label??$.content,J),l4(Z,q),Z}function m4($,J){let Z=H("span","pf-dot"),q=$.color??"gray";return Z.style.display="inline-block",Z.style.width="8px",Z.style.height="8px",Z.style.borderRadius="50%",Z.style.backgroundColor=q,Z}function v4($,J){let Z=H("div","pf-metric"),q=H("div","pf-metric-label");q.textContent=X($.label,J),q.style.fontSize="14px",Z.appendChild(q);let U=H("div","pf-metric-value");if(U.textContent=X($.value,J),U.style.fontSize="28px",U.style.fontWeight="700",Z.appendChild(U),$.delta!=null){let Q=H("span","pf-metric-delta");Q.textContent=X($.delta,J);let Y=$.trend??"",W=$.trendSentiment??"neutral";if(Q.style.fontSize="14px",Q.style.color=W==="positive"?"green":W==="negative"?"red":"inherit",Y==="up")Q.textContent="↑ "+Q.textContent;else if(Y==="down")Q.textContent="↓ "+Q.textContent;Z.appendChild(Q)}if($.description!=null){let Q=H("div","pf-metric-desc");Q.textContent=X($.description,J),Q.style.fontSize="12px",Z.appendChild(Q)}return Z}function h4($,J){let Z=H("div","pf-ring"),q=$.size??80,U=$.thickness??8,Q=Number(b($.value,J)??0),Y=Math.max(0,Math.min(100,Q)),W=(q-U)/2,_=2*Math.PI*W,B=_*(1-Y/100),G=document.createElementNS("http://www.w3.org/2000/svg","svg");G.setAttribute("width",String(q)),G.setAttribute("height",String(q)),G.setAttribute("viewBox",`0 0 ${q} ${q}`);let N=document.createElementNS("http://www.w3.org/2000/svg","circle");N.setAttribute("cx",String(q/2)),N.setAttribute("cy",String(q/2)),N.setAttribute("r",String(W)),N.setAttribute("fill","none"),N.setAttribute("stroke-width",String(U));let z=document.createElementNS("http://www.w3.org/2000/svg","circle");if(z.setAttribute("cx",String(q/2)),z.setAttribute("cy",String(q/2)),z.setAttribute("r",String(W)),z.setAttribute("fill","none"),z.setAttribute("stroke-width",String(U)),z.setAttribute("stroke-dasharray",String(_)),z.setAttribute("stroke-dashoffset",String(B)),z.setAttribute("stroke-linecap","round"),z.style.transform="rotate(-90deg)",z.style.transformOrigin="center",G.appendChild(N),G.appendChild(z),Z.appendChild(G),$.label!=null){let T=H("div","pf-ring-label");T.textContent=X($.label,J),T.style.textAlign="center",T.style.fontSize="12px",Z.appendChild(T)}return Z}function g4($,J){let Z=H("div","pf-progress");Z.setAttribute("role","progressbar");let q=Number(b($.value,J)??0),U=$.max??100,Q=U>0?Math.max(0,Math.min(100,q/U*100)):0;Z.setAttribute("aria-valuenow",String(q)),Z.setAttribute("aria-valuemin","0"),Z.setAttribute("aria-valuemax",String(U)),Z.style.height="8px",Z.style.borderRadius="4px",Z.style.overflow="hidden";let Y=H("div","pf-progress-fill");return Y.style.height="100%",Y.style.width=`${Q}%`,Y.style.borderRadius="4px",Y.style.transition="width 0.3s ease",Z.appendChild(Y),Z}function u4($,J){let Z=document.createElement("hr");return Z.className="pf-separator",Z.style.border="none",Z.style.margin="8px 0",Z}function x4($,J){let Z=H("div","pf-loader");return Z.textContent="⏳",Z.style.display="flex",Z.style.justifyContent="center",Z.style.padding="16px",Z}function p4($,J){let Z=H("span","pf-icon");return Z.setAttribute("data-icon",X($.name??$.content,J)),Z}function c4($,J){let Z=H("div","pf-sparkline"),q=$.data??[];if(q.length===0)return Z;let U=120,Q=32,Y=Math.max(...q),W=Math.min(...q),_=Y-W||1,B=document.createElementNS("http://www.w3.org/2000/svg","svg");B.setAttribute("width",String(U)),B.setAttribute("height",String(Q)),B.setAttribute("viewBox",`0 0 ${U} ${Q}`);let G=q.length>1?q.length-1:1,N=q.map((T,D)=>{let K=D/G*U,E=Q-(T-W)/_*(Q-4)-2;return`${K},${E}`}).join(" "),z=document.createElementNS("http://www.w3.org/2000/svg","polyline");return z.setAttribute("points",N),z.setAttribute("fill","none"),z.setAttribute("stroke-width","1.5"),B.appendChild(z),Z.appendChild(B),Z}function l4($,J){let q={success:{bg:"#10b981",fg:"#fff"},warning:{bg:"#f59e0b",fg:"#fff"},info:{bg:"#3b82f6",fg:"#fff"}}[J];if(q)$.style.backgroundColor=q.bg,$.style.color=q.fg}function N1(){M("Form",s4),M("Input",i4),M("Textarea",d4),M("Button",r4),M("ButtonGroup",n4),M("Select",o4),M("SelectOption",a4),M("SelectGroup",K0("pf-select-group")),M("SelectLabel",Z0("pf-select-label")),M("SelectSeparator",_1),M("Checkbox",t4),M("Switch",e4),M("Slider",$8),M("Radio",Z8),M("RadioGroup",q8),M("Combobox",U8),M("ComboboxOption",Q8),M("ComboboxGroup",K0("pf-combobox-group")),M("ComboboxLabel",Z0("pf-combobox-label")),M("ComboboxSeparator",_1),M("Calendar",Y8),M("DatePicker",W8),M("Field",K0("pf-field")),M("FieldTitle",Z0("pf-field-title")),M("FieldDescription",Z0("pf-field-description")),M("FieldContent",K0("pf-field-content")),M("FieldError",Z0("pf-field-error")),M("ChoiceCard",M8)}function s4($,J){let Z=document.createElement("form");return Z.className="pf-form",Z.addEventListener("submit",(q)=>{q.preventDefault();let U=new FormData(Z),Q={};if(U.forEach((Y,W)=>{Q[W]=Y}),J.store.merge(Q),$.onSubmit!=null){let Y=y(J);Y.scope={...J.scope,...Q},k($.onSubmit,Y)}}),L($,Z,J),Z}function i4($,J){let Z=H("div","pf-input-wrapper");if(Z.style.display="flex",Z.style.flexDirection="column",Z.style.gap="4px",$.label!=null){let Q=document.createElement("label");if(Q.className="pf-input-label",Q.textContent=X($.label,J),$.name!=null)Q.htmlFor=$.name;Q.style.fontSize="14px",Q.style.fontWeight="500",Z.appendChild(Q)}let q=document.createElement("input");if(q.className="pf-input",q.type=$.inputType??"text",$.name!=null)q.name=$.name;if($.name!=null)q.id=`pf-input-${$.name}`;if($.placeholder!=null)q.placeholder=X($.placeholder,J);if($.required===!0)q.required=!0,q.setAttribute("aria-required","true");if($.error!=null)q.setAttribute("aria-invalid","true");let U=$.name;if(U){let Q=J.store.get(U);if(Q!=null)q.value=String(Q);q.addEventListener("input",()=>{if(J.store.set(U,q.value),$.onChange!=null)k($.onChange,{...y(J),scope:{...J.scope,$event:q.value}})})}return C0(q),Z.appendChild(q),Z}function d4($,J){let Z=H("div","pf-textarea-wrapper"),q=document.createElement("textarea");if(q.className="pf-textarea",$.name!=null)q.name=$.name;if($.name!=null)q.id=`pf-textarea-${$.name}`;if($.placeholder!=null)q.placeholder=X($.placeholder,J);if($.rows!=null)q.rows=$.rows;if($.required===!0)q.setAttribute("aria-required","true");let U=$.name;if(U!=null){let Q=J.store.get(U);if(Q!=null)q.value=String(Q);q.addEventListener("input",()=>{if(J.store.set(U,q.value),$.onChange!=null)k($.onChange,{...y(J),scope:{...J.scope,$event:q.value}})})}return C0(q),Z.appendChild(q),Z}function r4($,J){let Z=document.createElement("button");Z.className="pf-button",Z.type=$.submit===!0?"submit":"button",Z.textContent=X($.label,J);let q=$.variant??"default";if(Z.setAttribute("data-variant",q),J8(Z,q),$.size!=null)Z.setAttribute("data-size",$.size);if($.disabled===!0)Z.disabled=!0;if($.onClick!=null)Z.addEventListener("click",()=>{k($.onClick,y(J))});return Z}function n4($,J){let Z=H("div","pf-button-group");return Z.style.display="flex",Z.style.gap="8px",L($,Z,J),Z}function o4($,J){let Z=H("div","pf-select-wrapper"),q=document.createElement("select");if(q.className="pf-select",$.name!=null)q.name=$.name;if(C0(q),$.placeholder!=null){let Y=document.createElement("option");Y.value="",Y.textContent=X($.placeholder,J),Y.disabled=!0,Y.selected=!0,Y.hidden=!0,q.appendChild(Y)}let U=$.options;if(Array.isArray(U))for(let Y of U){let W=document.createElement("option");W.value=Y.value??"",W.textContent=Y.label??W.value,q.appendChild(W)}if($.children)for(let Y of $.children)if(Y.type==="SelectOption"){let W=document.createElement("option");W.value=Y.value??"",W.textContent=Y.label??W.value,q.appendChild(W)}else q.appendChild(w(Y,J));let Q=$.name;if(Q){let Y=J.store.get(Q);if(Y!=null)q.value=String(Y);q.addEventListener("change",()=>{if(J.store.set(Q,q.value),$.onChange!=null)k($.onChange,{...y(J),scope:{...J.scope,$event:q.value}})})}return Z.appendChild(q),Z}function a4($,J){return H("span")}function t4($,J){let Z=H("label","pf-checkbox-wrapper");Z.style.display="flex",Z.style.alignItems="center",Z.style.gap="8px",Z.style.cursor="pointer";let q=document.createElement("input");if(q.type="checkbox",q.className="pf-checkbox",$.name!=null)q.name=$.name;if($.checked===!0)q.checked=!0;let U=$.name;if(U){let Q=J.store.get(U);if(typeof Q==="boolean")q.checked=Q;q.addEventListener("change",()=>{if(J.store.set(U,q.checked),$.onChange!=null)k($.onChange,{...y(J),scope:{...J.scope,$event:q.checked}})})}if(Z.appendChild(q),$.label!=null){let Q=H("span");Q.textContent=X($.label,J),Z.appendChild(Q)}return Z}function e4($,J){let Z=H("label","pf-switch-wrapper");Z.style.display="flex",Z.style.alignItems="center",Z.style.gap="8px",Z.style.cursor="pointer";let q=document.createElement("input");if(q.type="checkbox",q.className="pf-switch",q.setAttribute("role","switch"),$.name!=null)q.name=$.name;let U=$.name;if(U){let Q=J.store.get(U);if(typeof Q==="boolean")q.checked=Q;q.addEventListener("change",()=>{if(J.store.set(U,q.checked),$.onChange!=null)k($.onChange,{...y(J),scope:{...J.scope,$event:q.checked}})})}if(Z.appendChild(q),$.label!=null){let Q=H("span");Q.textContent=X($.label,J),Z.appendChild(Q)}return Z}function $8($,J){let Z=H("div","pf-slider-wrapper"),q=document.createElement("input");if(q.type="range",q.className="pf-slider",$.name!=null)q.name=$.name;if($.min!=null)q.min=String($.min);if($.max!=null)q.max=String($.max);if($.step!=null)q.step=String($.step);let U=$.name;if(U){let Q=J.store.get(U);if(Q!=null)q.value=String(Q);q.addEventListener("input",()=>{if(J.store.set(U,Number(q.value)),$.onChange!=null)k($.onChange,{...y(J),scope:{...J.scope,$event:Number(q.value)}})})}return Z.appendChild(q),Z}function C0($){$.style.padding="8px 12px",$.style.fontSize="14px",$.style.width="100%",$.style.boxSizing="border-box"}function J8($,J){if($.style.padding="8px 16px",$.style.fontSize="14px",$.style.fontWeight="500",$.style.cursor="pointer",$.style.border="none",J==="ghost")$.style.backgroundColor="transparent",$.style.color="inherit"}function K0($){return(J,Z)=>{let q=H("div",$);return L(J,q,Z),q}}function Z0($){return(J,Z)=>{let q=H("span",$);return q.textContent=X(J.content,Z),q}}function _1(){let $=document.createElement("hr");return $.className="pf-separator",$.style.border="none",$.style.margin="4px 0",$}function Z8($,J){let Z=H("label","pf-radio");Z.style.display="flex",Z.style.alignItems="center",Z.style.gap="8px",Z.style.cursor="pointer";let q=document.createElement("input");if(q.type="radio",q.value=X($.value,J),Z.appendChild(q),$.label!=null){let U=H("span","pf-radio-label");U.textContent=X($.label,J),Z.appendChild(U)}return Z}function q8($,J){let Z=H("fieldset","pf-radio-group");if(Z.style.border="none",Z.style.padding="0",Z.style.display="flex",Z.style.flexDirection="column",Z.style.gap="8px",$.label!=null){let Q=document.createElement("legend");Q.textContent=X($.label,J),Q.style.fontWeight="500",Q.style.marginBottom="4px",Z.appendChild(Q)}L($,Z,J);let q=X($.name,J),U=J.store.get(q);for(let Q of Array.from(Z.querySelectorAll('input[type="radio"]')))if(Q.name=q,U!=null&&Q.value===String(U))Q.checked=!0;return Z.addEventListener("change",(Q)=>{let Y=Q.target;if(Y.type==="radio"){if(J.store.set(q,Y.value),$.onChange!=null)k($.onChange,y(J))}}),Z}function U8($,J){let Z=H("div","pf-combobox"),q=document.createElement("input");if(q.className="pf-combobox-input",q.type="text",q.name=X($.name,J),$.placeholder!=null)q.placeholder=X($.placeholder,J);if($.value!==void 0)q.value=X($.value,J);let U=q.name,Q=J.store.get(U);if(Q!=null)q.value=String(Q);q.style.padding="6px 12px",q.style.borderRadius="6px",q.style.width="100%",q.style.boxSizing="border-box";let Y=H("div","pf-combobox-dropdown");if(Y.style.display="none",Y.style.position="absolute",Y.style.borderRadius="6px",Y.style.maxHeight="200px",Y.style.overflowY="auto",Y.style.zIndex="50",L($,Y,J),q.addEventListener("focus",()=>{Y.style.display="block"}),q.addEventListener("blur",()=>{setTimeout(()=>{Y.style.display="none"},150)}),$.searchable!==!1)q.addEventListener("input",()=>{let W=q.value.toLowerCase();for(let _ of Array.from(Y.querySelectorAll(".pf-combobox-option"))){let B=_.textContent.toLowerCase();_.style.display=B.includes(W)?"":"none"}});if($.onChange!=null)Z.addEventListener("pf-combobox-select",()=>{k($.onChange,{...y(J),scope:{...J.scope,$event:q.value}})});return Z.style.position="relative",Z.appendChild(q),Z.appendChild(Y),Z}function Q8($,J){let Z=H("div","pf-combobox-option");return Z.style.padding="6px 12px",Z.style.cursor="pointer",Z.textContent=X($.label??$.value,J),Z.dataset.value=X($.value,J),Z.addEventListener("mousedown",()=>{let q=Z.closest(".pf-combobox"),U=q?.querySelector("input");if(U)U.value=Z.dataset.value??"",J.store.set(U.name,U.value),q?.dispatchEvent(new CustomEvent("pf-combobox-select",{bubbles:!1}))}),Z}function Y8($,J){let Z=H("div","pf-calendar"),q=document.createElement("input");if(q.type="date",q.name=X($.name,J),$.value!==void 0)q.value=X($.value,J);let U=q.name,Q=J.store.get(U);if(Q!=null)q.value=String(Q);if($.minDate!=null)q.min=X($.minDate,J);if($.maxDate!=null)q.max=X($.maxDate,J);return q.style.padding="6px 12px",q.style.borderRadius="6px",q.addEventListener("change",()=>{if(J.store.set(q.name,q.value),$.onChange!=null)k($.onChange,y(J))}),Z.appendChild(q),Z}function W8($,J){let Z=H("div","pf-datepicker"),q=document.createElement("input");if(q.type="date",q.name=X($.name,J),$.placeholder!=null)q.placeholder=X($.placeholder,J);if($.value!==void 0)q.value=X($.value,J);let U=q.name,Q=J.store.get(U);if(Q!=null)q.value=String(Q);if($.minDate!=null)q.min=X($.minDate,J);if($.maxDate!=null)q.max=X($.maxDate,J);return q.style.padding="6px 12px",q.style.borderRadius="6px",q.style.width="100%",q.style.boxSizing="border-box",q.addEventListener("change",()=>{if(J.store.set(q.name,q.value),$.onChange!=null)k($.onChange,y(J))}),Z.appendChild(q),Z}function M8($,J){let Z=H("div","pf-choice-card");if(Z.style.padding="16px",Z.style.cursor="pointer",Z.style.transition="border-color 0.2s",Z.dataset.value=X($.value,J),$.selected===!0)Z.dataset.selected="true";if($.label!=null){let q=H("div","pf-choice-card-label");q.textContent=X($.label,J),q.style.fontWeight="600",Z.appendChild(q)}if($.description!=null){let q=H("div","pf-choice-card-description");q.textContent=X($.description,J),q.style.fontSize="14px",Z.appendChild(q)}if(L($,Z,J),$.onClick!=null)Z.addEventListener("click",()=>{k($.onClick,y(J))});return Z}function H1(){M("Tabs",_8),M("Tab",N8),M("Accordion",H8),M("AccordionItem",B8),M("Dialog",G8),M("Popover",X8),M("Tooltip",K8),M("HoverCard",z8),M("Carousel",D8)}function _8($,J){let Z=H("div","pf-tabs"),q=H("div","pf-tabs-bar");q.setAttribute("role","tablist"),q.style.display="flex",q.style.gap="4px",q.style.marginBottom="12px";let U=[],Q=[];if($.children)for(let W=0;W<$.children.length;W++){let _=$.children[W],B=`pf-tab-${Math.random().toString(36).slice(2,8)}`,G=`pf-panel-${Math.random().toString(36).slice(2,8)}`,N=document.createElement("button");N.type="button",N.className="pf-tab-trigger",N.textContent=_.title??`Tab ${W+1}`,N.setAttribute("role","tab"),N.setAttribute("aria-selected",W===0?"true":"false"),N.setAttribute("aria-controls",G),N.id=B,N.tabIndex=W===0?0:-1,N.style.padding="8px 16px",N.style.border="none",N.style.background="none",N.style.cursor="pointer",N.style.borderBottom="2px solid transparent",N.style.marginBottom="-2px",N.style.fontSize="14px";let z=H("div","pf-tab-panel");if(z.style.display=W===0?"block":"none",z.setAttribute("role","tabpanel"),z.setAttribute("aria-labelledby",B),z.id=G,z.tabIndex=0,L(_,z,J),N.addEventListener("click",()=>{Y(W)}),W===0)N.classList.add("pf-tab-active"),N.style.fontWeight="600";Q.push(N),U.push(z),q.appendChild(N)}function Y(W){U.forEach((_)=>_.style.display="none"),Q.forEach((_)=>{_.style.borderBottomColor="transparent",_.style.fontWeight="normal",_.classList.remove("pf-tab-active"),_.setAttribute("aria-selected","false"),_.tabIndex=-1}),U[W].style.display="block",Q[W].classList.add("pf-tab-active"),Q[W].style.fontWeight="600",Q[W].setAttribute("aria-selected","true"),Q[W].tabIndex=0,Q[W].focus()}q.addEventListener("keydown",(W)=>{let _=Q.indexOf(W.target);if(_<0)return;let B;if(W.key==="ArrowRight")B=(_+1)%Q.length;else if(W.key==="ArrowLeft")B=(_-1+Q.length)%Q.length;else if(W.key==="Home")B=0;else if(W.key==="End")B=Q.length-1;else return;W.preventDefault(),Y(B)}),Z.appendChild(q);for(let W of U)Z.appendChild(W);return Z}function N8($,J){let Z=H("div","pf-tab");return L($,Z,J),Z}function H8($,J){let Z=H("div","pf-accordion");return L($,Z,J),Z}function B8($,J){let Z=H("div","pf-accordion-item"),q=`pf-acc-${Math.random().toString(36).slice(2,8)}`,U=document.createElement("button");U.type="button",U.className="pf-accordion-trigger",U.textContent=$.title??"",U.setAttribute("aria-expanded","false"),U.setAttribute("aria-controls",q),U.style.width="100%",U.style.textAlign="left",U.style.padding="12px 0",U.style.border="none",U.style.background="none",U.style.cursor="pointer",U.style.fontSize="14px",U.style.fontWeight="500";let Q=H("div","pf-accordion-content");return Q.id=q,Q.setAttribute("role","region"),Q.setAttribute("aria-labelledby",U.id),Q.style.display="none",Q.style.paddingBottom="12px",L($,Q,J),U.addEventListener("click",()=>{let Y=Q.style.display!=="none";Q.style.display=Y?"none":"block",U.setAttribute("aria-expanded",Y?"false":"true")}),Z.appendChild(U),Z.appendChild(Q),Z}function G8($,J){let Z=H("div","pf-dialog-wrapper");if($.trigger!=null){let Q=w($.trigger,J);Q.addEventListener("click",()=>{q.showModal()}),Z.appendChild(Q)}let q=document.createElement("dialog");if(q.className="pf-dialog",q.setAttribute("aria-modal","true"),q.style.maxWidth="500px",q.style.width="100%",q.style.padding="24px",$.title!=null){let Q=H("h2","pf-dialog-title");Q.textContent=X($.title,J),Q.id=`pf-dialog-title-${Math.random().toString(36).slice(2,8)}`,q.setAttribute("aria-labelledby",Q.id),q.appendChild(Q)}if($.description!=null){let Q=H("p","pf-dialog-desc");Q.textContent=X($.description,J),q.appendChild(Q)}let U=H("div","pf-dialog-body");if(L($,U,J),q.appendChild(U),$.dismissible!==!1)q.addEventListener("click",(Q)=>{if(Q.target===q)q.close()});return document.addEventListener("prefab:close-overlay",()=>q.close()),Z.appendChild(q),Z}function X8($,J){let Z=H("div","pf-popover");Z.style.position="relative",Z.style.display="inline-block";let q=H("div","pf-popover-content");if(q.style.display="none",q.style.position="absolute",q.style.zIndex="50",q.style.padding="12px",q.style.boxShadow="0 4px 6px -1px rgb(0 0 0 / 0.1)",$.title!=null){let U=H("div","pf-popover-title");U.textContent=X($.title,J),U.style.fontWeight="600",U.style.marginBottom="4px",q.appendChild(U)}return L($,q,J),Z.addEventListener("click",(U)=>{if(q.contains(U.target)&&q.style.display!=="none")return;q.style.display=q.style.display==="none"?"block":"none"}),Z.appendChild(q),Z}function K8($,J){let Z=H("div","pf-tooltip");Z.style.position="relative",Z.style.display="inline-block";let q=`pf-tip-${Math.random().toString(36).slice(2,8)}`,U=H("div","pf-tooltip-content");return U.id=q,U.setAttribute("role","tooltip"),U.textContent=X($.content??"",J),U.style.display="none",U.style.position="absolute",U.style.bottom="100%",U.style.left="50%",U.style.transform="translateX(-50%)",U.style.padding="4px 8px",U.style.borderRadius="4px",U.style.color="#fff",U.style.fontSize="12px",U.style.whiteSpace="nowrap",U.style.zIndex="50",L($,Z,J),Z.setAttribute("aria-describedby",q),Z.addEventListener("mouseenter",()=>{U.style.display="block"}),Z.addEventListener("mouseleave",()=>{U.style.display="none"}),Z.addEventListener("focus",()=>{U.style.display="block"},!0),Z.addEventListener("blur",()=>{U.style.display="none"},!0),Z.appendChild(U),Z}function z8($,J){let Z=H("div","pf-hover-card");Z.style.position="relative",Z.style.display="inline-block";let q=H("div","pf-hover-card-content");return q.style.display="none",q.style.position="absolute",q.style.zIndex="50",q.style.padding="16px",q.style.boxShadow="0 4px 6px -1px rgb(0 0 0 / 0.1)",q.style.minWidth="200px",L($,q,J),Z.addEventListener("mouseenter",()=>{q.style.display="block"}),Z.addEventListener("mouseleave",()=>{q.style.display="none"}),Z.appendChild(q),Z}function D8($,J){let Z=H("div","pf-carousel");Z.style.position="relative",Z.style.overflow="hidden",Z.setAttribute("role","region"),Z.setAttribute("aria-roledescription","carousel"),Z.setAttribute("aria-label",X($.label??"Carousel",J));let q=H("div","pf-carousel-track");q.style.display="flex",q.style.transition="transform 0.3s ease",L($,q,J);let U=0,Q=$.children?.length??0,Y=document.createElement("button");Y.type="button",Y.textContent="‹",Y.className="pf-carousel-prev",Y.setAttribute("aria-label","Previous slide"),Y.style.position="absolute",Y.style.left="4px",Y.style.top="50%",Y.style.transform="translateY(-50%)",Y.style.zIndex="10";let W=document.createElement("button");W.type="button",W.textContent="›",W.className="pf-carousel-next",W.setAttribute("aria-label","Next slide"),W.style.position="absolute",W.style.right="4px",W.style.top="50%",W.style.transform="translateY(-50%)",W.style.zIndex="10";let _=()=>{q.style.transform=`translateX(-${U*100}%)`};return Y.addEventListener("click",()=>{if(Q===0)return;U=Math.max(0,U-1),_()}),W.addEventListener("click",()=>{if(Q===0)return;U=Math.min(Q-1,U+1),_()}),Z.appendChild(q),Z.appendChild(Y),Z.appendChild(W),Z}function B1(){M("ForEach",F8),M("If",G1),M("Elif",E8),M("Else",T8),M("Condition",L8),M("Define",j8),M("Use",O8),M("Slot",P8)}function F8($,J){let Z=document.createDocumentFragment(),q=$.expression;if(!q)return Z;let U;if(u(q)){let Y=x(q,J.store,J.scope);U=Array.isArray(Y)?Y:[]}else{let Y=J.store.get(q);U=Array.isArray(Y)?Y:[]}let Q=$.let??{};for(let Y=0;Y<U.length;Y++){let W=U[Y],_={...J.scope,$item:W,$index:Y,...Q},B={...J,scope:_};if($.children)n($.children,Z,B)}return Z}function G1($,J){if(X1($.condition,J)){let q=document.createDocumentFragment();if($.children)n($.children,q,J);return q}return document.createDocumentFragment()}function E8($,J){return G1($,J)}function T8($,J){let Z=document.createDocumentFragment();if($.children)n($.children,Z,J);return Z}function X1($,J){if(!$)return!1;if(u($))return Boolean(x($,J.store,J.scope));return Boolean(J.store.get($))}function L8($,J){let Z=document.createDocumentFragment(),q=$.cases,U=$.else;if(q){for(let Q of q)if(X1(Q.when,J)){if(Q.children)n(Q.children,Z,J);return Z}}if(U)n(U,Z,J);return Z}function j8($,J){let Z=$.name;if(Z&&$.children)J.templates=J.templates??{},J.templates[Z]=$.children;return document.createDocumentFragment()}function O8($,J){let Z=document.createDocumentFragment(),q=$.def??$.name,U=J.templates?.[q];if(!U)return Z;let Q=$.overrides??{},Y={...J.scope,...Q},W={...J,scope:Y};for(let _ of U)Z.appendChild(w(_,W));return Z}function P8($,J){let Z=document.createDocumentFragment(),q=$.name??"default",Q=J.slots?.[q]??$.children;if(Q)for(let Y of Q)Z.appendChild(w(Y,J));return Z}function K1(){M("Alert",V8),M("AlertTitle",I8),M("AlertDescription",R8)}function V8($,J){let Z=H("div","pf-alert");Z.setAttribute("role","alert");let q=$.variant??"default";if(Z.setAttribute("data-variant",q),Z.style.padding="12px 16px",$.icon!=null){let U=H("span","pf-alert-icon");U.setAttribute("data-icon",$.icon),U.style.marginRight="8px",Z.appendChild(U)}return L($,Z,J),Z}function I8($,J){let Z=H("h5","pf-alert-title");return Z.textContent=X($.content,J),Z.style.fontWeight="600",Z.style.marginBottom="4px",Z}function R8($,J){let Z=H("p","pf-alert-description");return Z.textContent=X($.content,J),Z.style.fontSize="14px",Z}function z1(){M("Image",A8),M("Audio",k8),M("Video",f8),M("Embed",S8),M("Svg",C8),M("DropZone",y8),M("Mermaid",b8)}function A8($,J){let Z=document.createElement("img");if(Z.className="pf-image",Z.src=X($.src,J),$.alt!=null)Z.alt=X($.alt,J);if($.width!=null)Z.width=$.width;if($.height!=null)Z.height=$.height;return Z.style.maxWidth="100%",Z}function k8($,J){let Z=document.createElement("audio");return Z.className="pf-audio",Z.src=X($.src,J),Z.controls=!0,Z}function f8($,J){let Z=document.createElement("video");if(Z.className="pf-video",Z.src=X($.src,J),Z.controls=!0,$.width!=null)Z.width=$.width;if($.height!=null)Z.height=$.height;return Z.style.maxWidth="100%",Z}function S8($,J){let Z=H("div","pf-embed"),q=document.createElement("iframe");return q.src=X($.src,J),q.style.width="100%",q.style.height=$.height!=null?`${$.height}px`:"400px",q.style.border="none",q.setAttribute("sandbox","allow-scripts"),Z.appendChild(q),Z}var w8=new Set(["svg","g","path","rect","circle","ellipse","line","polyline","polygon","text","tspan","textpath","defs","use","symbol","clippath","mask","pattern","lineargradient","radialgradient","stop","filter","fegaussianblur","feoffset","femerge","femergenode","fecolormatrix","feblend","title","desc"]);function C8($,J){let Z=H("div","pf-svg"),q=X($.content,J);if(!q.includes("<svg"))return Z;let Q=new DOMParser().parseFromString(q,"image/svg+xml").querySelector("svg");if(!Q)return Z;return D1(Q),Z.appendChild(document.importNode(Q,!0)),Z}function D1($){let J=Array.from($.children);for(let Z of J){if(!w8.has(Z.tagName.toLowerCase())){Z.remove();continue}for(let q of Array.from(Z.attributes)){let U=q.name.toLowerCase();if(U.startsWith("on")||U==="href"&&q.value.trim().toLowerCase().startsWith("javascript:"))Z.removeAttribute(q.name)}D1(Z)}}function y8($,J){let Z=H("div","pf-dropzone");return Z.style.padding="32px",Z.style.textAlign="center",Z.style.cursor="pointer",Z.textContent=X($.label??"Drop files here",J),Z.addEventListener("dragover",(q)=>{q.preventDefault(),Z.classList.add("pf-dropzone-active")}),Z.addEventListener("dragleave",()=>{Z.classList.remove("pf-dropzone-active")}),Z.addEventListener("drop",(q)=>{q.preventDefault(),Z.classList.remove("pf-dropzone-active")}),Z}function b8($,J){let Z=H("div","pf-mermaid");Z.setAttribute("data-mermaid","true");let q=X($.content,J);if(Z.textContent=q,typeof globalThis.mermaid<"u")Z.classList.add("mermaid"),Z.textContent=q;return Z}var D0=["#3b82f6","#10b981","#f59e0b","#ef4444","#8b5cf6","#ec4899"];function F0($,J){let Z=document.createElement("div");return Z.className="pf-chart-tooltip",$.appendChild(Z),$.addEventListener("mouseleave",()=>{Z.classList.remove("pf-visible")}),{wrapper:$,tooltip:Z,svgEl:J}}function q0($,J,Z,q,U){let{tooltip:Q,svgEl:Y,wrapper:W}=$;if(U.length===0)return;let _="";if(q)_+=`<div class="pf-chart-tooltip-label">${z0(q)}</div>`;for(let E of U)_+='<div class="pf-chart-tooltip-row">',_+=`<span class="pf-chart-tooltip-dot" style="background:${z0(E.color)}"></span>`,_+=`<span>${z0(E.label)}:</span> <strong>${z0(String(E.value))}</strong>`,_+="</div>";Q.innerHTML=_;let B=Y.getBoundingClientRect(),G=W.getBoundingClientRect(),N=Y.viewBox.baseVal,z=B.width/(N.width||1),T=B.left-G.left+J*z,D=Q.offsetWidth||100,K=T+12;if(K+D>G.width)K=T-D-12;Q.style.left=`${Math.max(0,K)}px`,Q.style.top="4px",Q.classList.add("pf-visible")}function z0($){return $.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;")}function F1($,J,Z,q,U,Q,Y,W){let _=U.plotWidth/Z.length;for(let B=0;B<Z.length;B++){let G=U.plotLeft+B*_,N=document.createElementNS("http://www.w3.org/2000/svg","rect");N.setAttribute("x",String(G)),N.setAttribute("y",String(U.plotTop)),N.setAttribute("width",String(_)),N.setAttribute("height",String(U.plotHeight)),N.setAttribute("fill","transparent"),N.style.cursor="default";let z=Q?Z[B][Q]:void 0,T=z!=null?W?W(z):String(z):void 0,D=q.map((A,R)=>({label:A.label??A.dataKey,value:Y(Z[B][A.dataKey],A,R),color:A.color??D0[R%D0.length]})),K=G+_/2,E=()=>q0($,K,U.plotTop,T,D),P=()=>$.tooltip.classList.remove("pf-visible");N.addEventListener("mouseenter",E),N.addEventListener("mouseleave",P),N.addEventListener("touchstart",E,{passive:!0}),N.addEventListener("touchend",P,{passive:!0}),J.appendChild(N)}}function E1($,J,Z,q,U,Q,Y,W,_,B){let G=Z.length===1?U.plotWidth:U.plotWidth/(Z.length-1);for(let N=0;N<Z.length;N++){let z=Z.length===1?(U.plotLeft+U.plotRight)/2:U.plotLeft+N/(Z.length-1)*U.plotWidth,T=Z.length===1?U.plotLeft:z-G/2,D=Z.length===1?U.plotWidth:G,K=document.createElementNS("http://www.w3.org/2000/svg","rect");K.setAttribute("x",String(Math.max(U.plotLeft,T))),K.setAttribute("y",String(U.plotTop)),K.setAttribute("width",String(Math.min(D,U.plotRight-Math.max(U.plotLeft,T)))),K.setAttribute("height",String(U.plotHeight)),K.setAttribute("fill","transparent"),K.style.cursor="default";let E=Q?Z[N][Q]:void 0,P=E!=null?B?B(E):String(E):void 0,A=q.map((j,C)=>({label:j.label??j.dataKey,value:Y(Z[N][j.dataKey],j,C),color:j.color??D0[C%D0.length]})),R=()=>{if(q0($,z,U.plotTop,P,A),W)W.setAttribute("x1",String(z)),W.setAttribute("x2",String(z)),W.setAttribute("opacity","1");if(_)for(let j of _){for(let C of j)C.setAttribute("data-visible","false");j[N]?.setAttribute("data-visible","true")}},F=()=>{if($.tooltip.classList.remove("pf-visible"),W)W.setAttribute("opacity","0");if(_)for(let j of _)for(let C of j)C.setAttribute("data-visible","false")};K.addEventListener("mouseenter",R),K.addEventListener("mouseleave",F),K.addEventListener("touchstart",R,{passive:!0}),K.addEventListener("touchend",F,{passive:!0}),J.appendChild(K)}}function L1(){M("BarChart",v8),M("LineChart",T1),M("AreaChart",T1),M("PieChart",h8),M("RadarChart",y0),M("ScatterChart",y0),M("RadialChart",y0),M("Histogram",g8)}var s=["#3b82f6","#10b981","#f59e0b","#ef4444","#8b5cf6","#ec4899"],U0="#6b7280",m8="#e5e7eb",b0="10";function j1($,J,Z,q=!1){let U=Z?44:0,Q=$-(q?44:0),Y=10,W=J-24;return{plotLeft:U,plotRight:Q,plotTop:10,plotBottom:W,plotWidth:Q-U,plotHeight:W-10}}function O1($,J=5){if($<=0)return[0];let Z=$/J,q=Math.pow(10,Math.floor(Math.log10(Z))),U=Z/q,Q=U<=1.5?q:U<=3?2*q:U<=7?5*q:10*q,Y=[];for(let W=0;W<=$+Q*0.01;W+=Q)Y.push(Math.round(W*1000)/1000);return Y}function P1($,J,Z,q,U){let Q=O1(Z);for(let Y of Q){let W=J.plotBottom-(Z>0?Y/Z*J.plotHeight:0),_=document.createElementNS("http://www.w3.org/2000/svg","text");if(_.setAttribute("x",String(J.plotLeft-6)),_.setAttribute("y",String(W+3)),_.setAttribute("text-anchor","end"),_.setAttribute("font-size",b0),_.setAttribute("fill",U0),_.textContent=m0(Y,U),$.appendChild(_),q&&Y>0){let B=document.createElementNS("http://www.w3.org/2000/svg","line");B.setAttribute("x1",String(J.plotLeft)),B.setAttribute("y1",String(W)),B.setAttribute("x2",String(J.plotRight)),B.setAttribute("y2",String(W)),B.setAttribute("stroke",m8),B.setAttribute("stroke-width","1"),B.setAttribute("stroke-dasharray","4 3"),$.appendChild(B)}}}function V1($,J,Z,q){let U=O1(Z);for(let Q of U){let Y=J.plotBottom-(Z>0?Q/Z*J.plotHeight:0),W=document.createElementNS("http://www.w3.org/2000/svg","text");W.setAttribute("x",String(J.plotRight+6)),W.setAttribute("y",String(Y+3)),W.setAttribute("text-anchor","start"),W.setAttribute("font-size",b0),W.setAttribute("fill",U0),W.textContent=m0(Q,q),$.appendChild(W)}}function I1($,J,Z,q,U,Q){for(let Y=0;Y<J.length;Y++){let W=document.createElementNS("http://www.w3.org/2000/svg","text");W.setAttribute("x",String(q(Y))),W.setAttribute("y",String(U+14)),W.setAttribute("text-anchor","middle"),W.setAttribute("font-size",b0),W.setAttribute("fill",U0);let _=J[Y][Z];W.textContent=_==null?"":Q?Q(_):String(_),$.appendChild(W)}}function R1($,J){let Z=document.createElementNS("http://www.w3.org/2000/svg","line");Z.setAttribute("x1",String(J.plotLeft)),Z.setAttribute("y1",String(J.plotBottom)),Z.setAttribute("x2",String(J.plotRight)),Z.setAttribute("y2",String(J.plotBottom)),Z.setAttribute("stroke",U0),Z.setAttribute("stroke-width","1"),$.appendChild(Z)}function $0($,J,Z){if($==null)return"";let q=b(`{{ __v | ${J} }}`,{...Z,scope:{...Z.scope,__v:$}});return q==null?String($):String(q)}function m0($,J){if(J==="currency")return`$${$.toLocaleString()}`;if(J==="percent")return`${$}%`;if($>=1e6)return`${($/1e6).toFixed(1)}M`;if($>=1000)return`${($/1000).toFixed(1)}K`;return String($)}function A1($,J,Z){return(q,U)=>{if(q===null||q===void 0)return"—";if(U.tooltipFormat)return $0(q,U.tooltipFormat,$);let Q=U.yAxisId==="right"?Z:J;return m0(Number(q),Q)}}function v8($,J){let Z=H("div","pf-chart pf-bar-chart"),q=b($.data,J)??[],U=$.series??[],Q=$.height??300;if(q.length===0||U.length===0)return Z.textContent="No chart data",Z;let Y=$.showYAxis!==!1,W=$.showGrid===!0,_=$.showYAxisRight===!0,B=$.showTooltip!==!1,G=$.xAxis,N=$.tooltipXKey,z=$.xAxisFormat,T=$.tooltipXFormat,D=U.filter((I)=>I.yAxisId!=="right"),K=U.filter((I)=>I.yAxisId==="right"),E=_&&K.length>0,P=D.length>0?Math.max(...q.flatMap((I)=>D.map((V)=>Number(I[V.dataKey]??0))),1):1,A=E?Math.max(...q.flatMap((I)=>K.map((V)=>Number(I[V.dataKey]??0))),1):1,R=400,F=j1(R,Q,Y,E),j=E0(R,Q,"Bar");if(Y)P1(j,F,P,W,$.yAxisFormat);if(E)V1(j,F,A,$.yAxisRightFormat);R1(j,F);let C=F.plotWidth/q.length,i=C/(U.length+1);for(let I=0;I<q.length;I++)for(let V=0;V<U.length;V++){let f=U[V],p=q[I][f.dataKey];if(p===null||p===void 0)continue;let m=f.yAxisId==="right"?A:P,c=Number(p),l=Math.max(0,c/m*F.plotHeight),o=F.plotLeft+I*C+V*i+i/2,O=document.createElementNS("http://www.w3.org/2000/svg","rect");O.setAttribute("x",String(o)),O.setAttribute("y",String(F.plotBottom-l)),O.setAttribute("width",String(i*0.8)),O.setAttribute("height",String(l)),O.setAttribute("fill",f.color??s[V%s.length]),O.setAttribute("rx","2"),j.appendChild(O)}if(G){let I=z?(V)=>$0(V,z,J):void 0;I1(j,q,G,(V)=>{return F.plotLeft+V*C+C/2},F.plotBottom,I)}if(B){let I=F0(Z,j),V=A1(J,$.yAxisFormat,$.yAxisRightFormat);F1(I,j,q,U,F,N??G,V,T?(p)=>$0(p,T,J):void 0)}return v0(Z,U,$.showLegend),Z.appendChild(j),Z}function T1($,J){let Z=H("div",`pf-chart pf-${$.type.toLowerCase()}-chart`),q=b($.data,J)??[],U=$.series??[],Q=$.height??300;if(q.length===0||U.length===0)return Z.textContent="No chart data",Z;let Y=$.showYAxis!==!1,W=$.showGrid===!0,_=$.showYAxisRight===!0,B=$.showTooltip!==!1,G=$.xAxis,N=$.tooltipXKey,z=$.xAxisFormat,T=$.tooltipXFormat,D=U.filter((V)=>V.yAxisId!=="right"),K=U.filter((V)=>V.yAxisId==="right"),E=_&&K.length>0,P=D.length>0?Math.max(...q.flatMap((V)=>D.map((f)=>Number(V[f.dataKey]??0))),1):1,A=E?Math.max(...q.flatMap((V)=>K.map((f)=>Number(V[f.dataKey]??0))),1):1,R=400,F=j1(R,Q,Y,E),j=E0(R,Q,$.type==="AreaChart"?"Area":"Line"),C=$.type==="AreaChart";if(Y)P1(j,F,P,W,$.yAxisFormat);if(E)V1(j,F,A,$.yAxisRightFormat);R1(j,F);let i=[];for(let V=0;V<U.length;V++){let f=U[V],p=f.yAxisId==="right",d=p?A:P,m=f.color??s[V%s.length],c=q.map((O,S)=>{let v=O[f.dataKey],a=v===null||v===void 0,Y0=q.length===1?(F.plotLeft+F.plotRight)/2:F.plotLeft+S/(q.length-1)*F.plotWidth,u1=a?F.plotBottom:F.plotBottom-Number(v)/d*F.plotHeight;return{x:Y0,y:u1,isNull:a}});if(C){let O=[],S=()=>{if(O.length<2){O=[];return}let v=`M ${O[0].x},${F.plotBottom} `+O.map((Y0)=>`L ${Y0.x},${Y0.y}`).join(" ")+` L ${O[O.length-1].x},${F.plotBottom} Z`,a=document.createElementNS("http://www.w3.org/2000/svg","path");a.setAttribute("d",v),a.setAttribute("fill",m),a.setAttribute("opacity","0.15"),j.appendChild(a),O=[]};for(let v of c){if(v.isNull){S();continue}O.push(v)}S()}let l="";for(let O of c){if(O.isNull)continue;let S=c.indexOf(O),v=S===0||c[S-1].isNull;l+=`${v?"M":"L"} ${O.x},${O.y} `}if(l){let O=document.createElementNS("http://www.w3.org/2000/svg","path");if(O.setAttribute("d",l.trim()),O.setAttribute("fill","none"),O.setAttribute("stroke",m),O.setAttribute("stroke-width","2"),p)O.setAttribute("stroke-dasharray","6 3");j.appendChild(O)}let o=[];for(let O of c){let S=document.createElementNS("http://www.w3.org/2000/svg","circle");if(S.setAttribute("cx",String(O.x)),S.setAttribute("cy",String(O.y)),S.setAttribute("r","4"),S.setAttribute("fill",m),S.setAttribute("class","pf-data-dot"),S.setAttribute("data-visible","false"),S.style.pointerEvents="none",O.isNull)S.style.display="none";j.appendChild(S),o.push(S)}i.push(o)}let I=document.createElementNS("http://www.w3.org/2000/svg","line");if(I.setAttribute("class","pf-crosshair"),I.setAttribute("x1",String(F.plotLeft)),I.setAttribute("x2",String(F.plotLeft)),I.setAttribute("y1",String(F.plotTop)),I.setAttribute("y2",String(F.plotBottom)),I.setAttribute("stroke",U0),I.setAttribute("stroke-width","1"),I.setAttribute("stroke-dasharray","3 3"),I.setAttribute("opacity","0"),j.appendChild(I),G){let V=z?(f)=>$0(f,z,J):void 0;I1(j,q,G,(f)=>{return q.length===1?(F.plotLeft+F.plotRight)/2:F.plotLeft+f/(q.length-1)*F.plotWidth},F.plotBottom,V)}if(B){let V=F0(Z,j),f=A1(J,$.yAxisFormat,$.yAxisRightFormat);E1(V,j,q,U,F,N??G,f,I,i,T?(d)=>$0(d,T,J):void 0)}return v0(Z,U,$.showLegend),Z.appendChild(j),Z}function h8($,J){let Z=H("div","pf-chart pf-pie-chart"),q=b($.data,J)??[],U=$.series??[],Q=$.height??300,Y=Math.min(Q,300),W=$.showTooltip!==!1;if(q.length===0||U.length===0)return Z.textContent="No chart data",Z;let _=E0(Y,Y,"Pie"),B=Y/2,G=Y/2,N=Y/2-10,z=U[0].dataKey,T=$.xAxis,D=$.tooltipXKey,K=$.tooltipXFormat,E=q.map((F)=>Number(F[z]??0)),P=E.reduce((F,j)=>F+j,0);if(P===0)return Z.textContent="No chart data",Z.appendChild(_),Z;let A=W?F0(Z,_):void 0,R=-Math.PI/2;for(let F=0;F<E.length;F++){let j=E[F]/P*2*Math.PI,C=R+j,i=j>Math.PI?1:0,I=B+N*Math.cos(R),V=G+N*Math.sin(R),f=B+N*Math.cos(C),p=G+N*Math.sin(C),d=s[F%s.length],m=document.createElementNS("http://www.w3.org/2000/svg","path");if(m.setAttribute("d",`M ${B},${G} L ${I},${V} A ${N},${N} 0 ${i} 1 ${f},${p} Z`),m.setAttribute("fill",d),m.style.cursor="default",A){let c=D??T,l=c?q[F][c]:void 0,o=l!=null?K?$0(l,K,J):String(l):`Slice ${F+1}`,O=`${(E[F]/P*100).toFixed(1)}%`,S=R+j/2,v=B+N*0.6*Math.cos(S);m.addEventListener("mouseenter",()=>{q0(A,v,G,o,[{label:U[0].label??z,value:`${E[F]} (${O})`,color:d}])}),m.addEventListener("mouseleave",()=>{A.tooltip.classList.remove("pf-visible")}),m.addEventListener("touchstart",()=>{q0(A,v,G,o,[{label:U[0].label??z,value:`${E[F]} (${O})`,color:d}])},{passive:!0}),m.addEventListener("touchend",()=>{A.tooltip.classList.remove("pf-visible")},{passive:!0})}_.appendChild(m),R=C}return v0(Z,U,$.showLegend),Z.appendChild(_),Z}function y0($,J){let Z=H("div",`pf-chart pf-${$.type.toLowerCase()}`);return Z.textContent=`${$.type} — not yet supported in renderer`,Z.style.padding="24px",Z.style.textAlign="center",Z}function E0($,J,Z){let q=document.createElementNS("http://www.w3.org/2000/svg","svg");if(q.setAttribute("width","100%"),q.setAttribute("height",String(J)),q.setAttribute("viewBox",`0 0 ${$} ${J}`),q.setAttribute("role","img"),Z)q.setAttribute("aria-label",`${Z} chart`);return q.style.overflow="visible",q}function v0($,J,Z){if(Z===!1||J.length<=1)return;let q=H("div","pf-chart-legend");q.style.display="flex",q.style.gap="12px",q.style.fontSize="12px",q.style.marginBottom="8px";for(let U=0;U<J.length;U++){let Q=H("div","pf-chart-legend-item");Q.style.display="flex",Q.style.alignItems="center",Q.style.gap="4px";let Y=H("span");Y.style.width="8px",Y.style.height="8px",Y.style.borderRadius="50%",Y.style.backgroundColor=J[U].color??s[U%s.length];let W=H("span");W.textContent=J[U].label??J[U].dataKey,Q.appendChild(Y),Q.appendChild(W),q.appendChild(Q)}$.appendChild(q)}function g8($,J){let Z=H("div","pf-chart pf-histogram"),q=b($.data,J);if(!q||q.length===0)return Z.textContent="No data",Z;let U=q,Q=$.bins??10,Y=$.height??200,W=$.color??s[0],_=Math.min(...U),G=(Math.max(...U)-_)/Q||1,N=Array(Q).fill(0);for(let P of U){let A=Math.min(Math.floor((P-_)/G),Q-1);N[A]++}let z=Math.max(...N),T=300,D=Y,K=T/Q,E=E0(T,D,"Histogram");for(let P=0;P<Q;P++){let A=z>0?N[P]/z*D:0,R=document.createElementNS("http://www.w3.org/2000/svg","rect");R.setAttribute("x",String(P*K)),R.setAttribute("y",String(D-A)),R.setAttribute("width",String(K-1)),R.setAttribute("height",String(A)),R.setAttribute("fill",W),E.appendChild(R)}return Z.appendChild(E),Z}function k1(){M("Table",u8),M("TableHead",h0("thead")),M("TableBody",h0("tbody")),M("TableFooter",h0("tfoot")),M("TableRow",x8),M("TableHeader",p8),M("TableCell",c8),M("TableCaption",l8),M("ExpandableRow",s8)}function u8($,J){let Z=document.createElement("table");return Z.className="pf-table",Z.style.width="100%",Z.style.borderCollapse="collapse",L($,Z,J),Z}function h0($){return(J,Z)=>{let q=document.createElement($);return q.className=`pf-${$}`,L(J,q,Z),q}}function x8($,J){let Z=document.createElement("tr");return Z.className="pf-table-row",L($,Z,J),Z}function p8($,J){let Z=document.createElement("th");return Z.className="pf-table-header",Z.style.textAlign="left",Z.style.padding="8px 12px",Z.style.fontWeight="600",Z.textContent=X($.content,J),Z}function c8($,J){let Z=document.createElement("td");if(Z.className="pf-table-cell",Z.style.padding="8px 12px",$.colSpan!=null)Z.colSpan=$.colSpan;if($.rowSpan!=null)Z.rowSpan=$.rowSpan;return L($,Z,J),Z}function l8($,J){let Z=document.createElement("caption");return Z.className="pf-table-caption",Z.style.padding="8px",Z.style.fontSize="14px",Z.textContent=X($.content,J),Z}function s8($,J){let Z=H("div","pf-expandable-row"),q=H("div","pf-expandable-row-summary");q.style.cursor="pointer",q.style.display="flex",q.style.alignItems="center",q.style.gap="8px";let U=H("span","pf-expandable-arrow");U.textContent="▶",U.style.transition="transform 0.2s",U.style.fontSize="10px",q.appendChild(U);let Q=$.summary;if(Q)for(let _ of Q)q.appendChild(w(_,J));let Y=H("div","pf-expandable-row-detail");Y.style.display="none",Y.style.paddingLeft="24px",L($,Y,J);let W=!1;return q.addEventListener("click",()=>{W=!W,Y.style.display=W?"block":"none",U.style.transform=W?"rotate(90deg)":""}),Z.appendChild(q),Z.appendChild(Y),Z}var f1=!1;function T0(){if(f1)return;f1=!0,$1(),U1(),W1(),M1(),N1(),H1(),B1(),K1(),z1(),L1(),k1()}function S1($){return $.replace(/[^a-zA-Z0-9_-]/g,"")}function w1($){return $.replace(/[{}<>;]/g,"").replace(/\b(url|expression)\s*\(/gi,"")}function C1($,J){if(!J)return;if(J.light)for(let[Z,q]of Object.entries(J.light))$.style.setProperty(`--${S1(Z)}`,w1(q));if(J.dark){let q=document.getElementById("prefab-dark-theme");if(!q)q=document.createElement("style"),q.id="prefab-dark-theme",document.head.appendChild(q);let U=Object.entries(J.dark).map(([Q,Y])=>` --${S1(Q)}: ${w1(Y)};`).join(`
7
7
  `);q.textContent=`[data-theme="dark"] {
8
8
  ${U}
9
9
  }
@@ -11,4 +11,4 @@ ${U}
11
11
  :root:not([data-theme="light"]) {
12
12
  ${U}
13
13
  }
14
- }`}}function b1($,Z){if(!$||typeof document>"u")return;let J=(q)=>{for(let[U,Q]of Object.entries($))if(i8(U,q))q.preventDefault(),Z(Q)};return document.addEventListener("keydown",J),()=>document.removeEventListener("keydown",J)}function i8($,Z){let J=$.toLowerCase().split("+").map((Q)=>Q.trim()),q=J[J.length-1],U=new Set(J.slice(0,-1));if(U.has("ctrl")!==(Z.ctrlKey||Z.metaKey))return!1;if(U.has("shift")!==Z.shiftKey)return!1;if(U.has("alt")!==Z.altKey)return!1;return Z.key.toLowerCase()===q}function L4($){let Z=$?.baseUrl??(typeof window<"u"?window.location.origin:""),J={"Content-Type":"application/json",...$?.headers},q=$?.fetch??globalThis.fetch.bind(globalThis);return{async callTool(U,Q){let Y=await q(`${Z}/mcp/tools/call`,{method:"POST",headers:J,body:JSON.stringify({jsonrpc:"2.0",method:"tools/call",params:{name:U,arguments:Q}})});if(!Y.ok)throw Error(`MCP tool call failed: ${Y.status} ${Y.statusText}`);let W=await Y.json();if(W.error)throw Error(W.error.message??"MCP tool call returned error");let _=W.result?.content??W.content??[];for(let H of _)if(H.type==="text"&&H.text!==void 0){try{let G=JSON.parse(H.text);if(typeof G==="object"&&G!==null&&"$prefab"in G)return G;return G}catch{}return H.text}return W.result??W},async sendMessage(U){await q(`${Z}/mcp/messages`,{method:"POST",headers:J,body:JSON.stringify({message:U})})}}}function j4(){return{callTool($){return console.warn(`[prefab] No MCP transport: callTool('${$}') ignored`),Promise.resolve(null)},sendMessage($){return console.warn("[prefab] No MCP transport: sendMessage ignored",$),Promise.resolve()}}}function d8($){return $!==null&&typeof $==="object"&&$.jsonrpc==="2.0"}class Q4{hostOrigin;listeners=new Map;protocol="prefab";cleanup;pending=new Map;callIdCounter=0;rpcPending=new Map;rpcIdCounter=0;sentRpcIds=new Set;postFn;constructor($="*"){this.hostOrigin=$}connect(){if(typeof window>"u")return;let $=r8();if($)this.postFn=(J)=>$.postMessage(J);let Z=(J)=>{if(this.hostOrigin!=="*"&&J.origin!==this.hostOrigin)return;let q=J.data;if(d8(q)){this.handleJsonRpc(q);return}let U=q;if(!U?.type.startsWith("prefab:"))return;if(U.type==="prefab:tool-call-response"&&U.id){let Y=this.pending.get(U.id);if(Y){if(this.pending.delete(U.id),U.payload?.error!=null)Y.reject(Error(U.payload.error));else Y.resolve(U.payload?.result);return}}let Q=this.listeners.get(U.type);if(Q)for(let Y of Q)Y(U.payload??{})};window.addEventListener("message",Z),this.cleanup=()=>window.removeEventListener("message",Z)}async initialize($){return Promise.any([this.initPrefab($),this.initJsonRpc($)])}createTransport(){if(this.protocol==="jsonrpc")return this.createJsonRpcTransport();return this.createPrefabTransport()}requestMode($){if(this.protocol==="jsonrpc")this.sendRpcRequest("ui/request-display-mode",{mode:$});else this.sendPrefab("prefab:request-mode",{mode:$})}openLink($,Z){if(this.protocol==="jsonrpc")this.sendRpcRequest("ui/open-link",{url:$,target:Z});else this.sendPrefab("prefab:open-link",{url:$,target:Z})}updateContext($){if(this.protocol==="jsonrpc")this.sendRpcRequest("ui/update-model-context",{structuredContent:$});else this.sendPrefab("prefab:update-context",{context:$})}on($,Z){if(!this.listeners.has($))this.listeners.set($,new Set);let J=this.listeners.get($);if(J)J.add(Z)}off($,Z){this.listeners.get($)?.delete(Z)}disconnect(){this.cleanup?.(),this.listeners.clear();for(let[,$]of this.pending)$.reject(Error("Bridge disconnected"));this.pending.clear();for(let[,$]of this.rpcPending)$.reject(Error("Bridge disconnected"));this.rpcPending.clear(),this.sentRpcIds.clear()}get activeProtocol(){return this.protocol}initPrefab($){return new Promise((Z,J)=>{let q=!1,U=(Q)=>{if(q)return;q=!0,this.off("prefab:init-response",U),this.protocol="prefab",Z(Q)};this.on("prefab:init-response",U),this.sendPrefab("prefab:init",{capabilities:$}),setTimeout(()=>{if(!q)q=!0,this.off("prefab:init-response",U),J(Error("prefab:init timeout"))},2000)})}createPrefabTransport(){return{callTool:($,Z)=>{let J=`tc-${++this.callIdCounter}`;return new Promise((q,U)=>{this.pending.set(J,{resolve:q,reject:U}),this.sendPrefab("prefab:tool-call",{tool:$,arguments:Z},J),setTimeout(()=>{if(this.pending.has(J))this.pending.delete(J),U(Error(`Tool call '${$}' timed out`))},30000)})},sendMessage:($)=>{return this.sendPrefab("prefab:send-message",{message:$}),Promise.resolve()}}}sendPrefab($,Z,J){if(typeof window>"u")return;let q=window.parent!==window?window.parent:window,U={type:$,payload:Z,id:J};q.postMessage(U,this.hostOrigin)}handleJsonRpc($){if(!("method"in $)){let q=this.rpcPending.get($.id);if(q)if(this.rpcPending.delete($.id),$.error)q.reject(Error($.error.message));else q.resolve($.result);return}let Z=$.method,J=$.params??{};if($.id!=null&&this.sentRpcIds.delete($.id))return;if($.id!=null)this.postJsonRpc({jsonrpc:"2.0",id:$.id,result:{}});switch(Z){case"ui/notifications/tool-input":this.dispatch("prefab:tool-input",{args:J.arguments??J});break;case"ui/notifications/tool-input-partial":this.dispatch("prefab:tool-input-partial",{args:J.arguments??J});break;case"ui/notifications/tool-result":this.dispatch("prefab:tool-result",{result:J});break;case"ui/notifications/tool-cancelled":this.dispatch("prefab:tool-cancelled",J);break;case"ui/notifications/host-context-changed":{let q={};if(typeof J.theme==="string")q.colorScheme=J.theme;if(typeof J.styles==="object"&&J.styles!==null){let U=J.styles;if(U.variables)q.variables=U.variables}this.dispatch("prefab:theme-update",q);break}case"ui/resource-teardown":this.dispatch("prefab:teardown",J);break}}initJsonRpc($){return new Promise((Z,J)=>{let q=++this.rpcIdCounter,U=!1;this.rpcPending.set(q,{resolve:(Q)=>{if(U)return;U=!0,this.protocol="jsonrpc";let Y=Q??{},W=Y.hostInfo??{},_=Y.hostContext??{},H=Y.hostCapabilities??{},G;if(typeof _.theme==="string"||typeof _.styles==="object"){if(G={},typeof _.theme==="string")G.colorScheme=_.theme;if(typeof _.styles==="object"&&_.styles!==null){let N=_.styles;if(N.variables)G.variables=N.variables}}this.postJsonRpc({jsonrpc:"2.0",method:"ui/notifications/initialized",params:{}}),Z({hostName:W.name,hostVersion:W.version,capabilities:{toast:!0,navigation:H.openLinks!=null,messaging:!0,displayModes:_.availableDisplayModes??[]},theme:G,toolInput:void 0,meta:_})},reject:(Q)=>{if(U)return;U=!0,J(Q)}}),this.postJsonRpc({jsonrpc:"2.0",id:q,method:"ui/initialize",params:{protocolVersion:"2026-01-26",capabilities:{},clientInfo:{name:"prefab",version:"0.2"},appCapabilities:{...$.displayModes&&{availableDisplayModes:$.displayModes}}}}),setTimeout(()=>{if(!U)U=!0,this.rpcPending.delete(q),J(Error("ui/initialize timeout"))},2000)})}createJsonRpcTransport(){return{callTool:($,Z)=>{return this.sendRpcRequest("tools/call",{name:$,arguments:Z})},sendMessage:($)=>{return this.sendRpcRequest("ui/message",{role:"user",content:{type:"text",text:$}})}}}sendRpcRequest($,Z){let J=++this.rpcIdCounter;return new Promise((q,U)=>{this.rpcPending.set(J,{resolve:q,reject:U}),this.postJsonRpc({jsonrpc:"2.0",id:J,method:$,params:Z}),setTimeout(()=>{if(this.rpcPending.has(J))this.rpcPending.delete(J),U(Error(`JSON-RPC '${$}' timed out`))},30000)})}postJsonRpc($){if(typeof window>"u")return;if($.id!=null&&typeof $.method==="string")this.sentRpcIds.add($.id);if(this.postFn)this.postFn($);else(window.parent!==window?window.parent:window).postMessage($,this.hostOrigin)}dispatch($,Z){let J=this.listeners.get($);if(J)for(let q of J)q(Z)}}function g4($,Z){if(Z.variables)for(let[J,q]of Object.entries(Z.variables))$.style.setProperty(J.startsWith("--")?J:`--${J}`,q);if(Z.colorScheme&&Z.colorScheme!=="auto")$.setAttribute("data-theme",Z.colorScheme)}function O4(){if(typeof window>"u")return!1;try{return window.self!==window.top}catch{return!0}}function r8(){if(typeof window>"u")return;let $=window;if(typeof $.acquireVsCodeApi==="function")try{let Z=$.acquireVsCodeApi();if(Z!==null&&typeof Z==="object"&&"postMessage"in Z)return Z}catch{return}return}var g={mount($,Z,J){T4();let q=[];if(Z.pipes)for(let[N,X]of Object.entries(Z.pipes))o8(N,X,q);let U=new J4(Z.state),Q;if(J?.transport&&"callTool"in J.transport)Q=J.transport;else if(J?.transport)Q=L4(J.transport);else Q=j4();let Y=J?.onToast??a8,W={store:U,scope:{},transport:Q,rerender:()=>G(),onToast:Y,defs:Z.defs};C1($,Z.theme);let _=[];if(Z.stylesheets)for(let N of Z.stylesheets){let X=document.createElement("style");X.textContent=N,X.dataset.prefab="injected",document.head.appendChild(X),_.push(X)}let H;if(Z.keyBindings)H=b1(Z.keyBindings,async(N)=>{await k(N,{store:U,transport:Q,scope:{},rerender:()=>G(),onToast:Y})});function G(){$.innerHTML="";let N=w(Z.view,W);$.appendChild(N)}return G(),{rerender:()=>G(),update(N){U.merge(N.update.state),G()},store:U,destroy(){H?.(),d4();for(let N of _)N.remove();for(let N of q)I4(N);$.innerHTML=""}}},isPrefabData($){return $!=null&&typeof $==="object"&&"$prefab"in $},isPrefabUpdate($){return $!=null&&typeof $==="object"&&"$prefab"in $&&"update"in $}},n8=new Set(["find","dot","length","upper","lower","truncate","join","first","last","abs","round","number","currency","percent","compact","date","time","datetime","pluralize","default","selectattr","rejectattr"]);function o8($,Z,J){if(n8.has($)){console.warn(`[prefab] wire pipe "${$}" ignored — shadows built-in`);return}try{let q=Function("return ("+Z+")")();if(typeof q!=="function"){console.warn(`[prefab] wire pipe "${$}" — source did not evaluate to a function`);return}V4($,q),J.push($)}catch(q){console.warn(`[prefab] wire pipe "${$}" — failed to hydrate:`,q)}}function a8($){if(typeof document>"u")return;let Z=t8(),J=document.createElement("div");J.className="pf-toast",J.setAttribute("data-variant",$.variant??"default"),J.style.padding="12px 16px",J.style.borderRadius="8px",J.style.backgroundColor="var(--card, #fff)",J.style.border="1px solid var(--border, #e5e7eb)",J.style.boxShadow="0 4px 12px rgb(0 0 0 / 0.15)",J.style.marginBottom="8px",J.style.transition="opacity 0.3s ease";let q=document.createElement("div");if(q.textContent=$.message,q.style.fontWeight="500",J.appendChild(q),$.description){let Q=document.createElement("div");Q.textContent=$.description,Q.style.fontSize="14px",Q.style.color="var(--muted-foreground, #6b7280)",J.appendChild(Q)}Z.appendChild(J);let U=$.duration??4000;setTimeout(()=>{J.style.opacity="0",setTimeout(()=>J.remove(),300)},U)}function t8(){let Z=document.getElementById("prefab-toast-container");if(!Z)Z=document.createElement("div"),Z.id="prefab-toast-container",Z.style.position="fixed",Z.style.bottom="16px",Z.style.right="16px",Z.style.zIndex="9999",Z.style.maxWidth="400px",document.body.appendChild(Z);return Z}if(typeof window<"u"){let $=window;$.PrefabRenderer=g,$.prefab={app:P4,mount:g.mount.bind(g),isPrefabData:g.isPrefabData.bind(g),isPrefabUpdate:g.isPrefabUpdate.bind(g),Bridge:Q4,isIframe:O4,registerPipe:V4,unregisterPipe:I4,listPipes:p4,registerComponent:M};let Z=$.__PREFAB_DATA__;if(Z!=null){let J=document.getElementById("prefab-root");if(J)g.mount(J,Z)}}async function P4($){T4();let Z=$?.mode??"auto",J=Z==="bridge"||Z==="auto"&&O4(),q,U,Q={capabilities:{}};if(J)U=new Q4($?.hostOrigin),U.connect(),Q=await U.initialize($?.capabilities??{toolInput:!0}),q=U.createTransport();else if($?.transport)q=L4($.transport);else q=j4();if(Q.theme&&typeof document<"u")g4(document.documentElement,Q.theme);let Y,W,_,H,G=Q.toolInput,N;if(U)U.on("prefab:tool-input",(D)=>{let z=D.args??D;if(Y)Y(z);else G=z}),U.on("prefab:tool-result",(D)=>{let z=D.result??D;if(W)W(z);else N=z}),U.on("prefab:tool-cancelled",()=>{_?.()}),U.on("prefab:tool-input-partial",(D)=>{H?.(D.args??D)}),U.on("prefab:theme-update",(D)=>{if(typeof document<"u")g4(document.documentElement,D)});function X(D,...z){let E=y1(D),P=new J4,A={store:P,scope:{},transport:q,rerender:()=>R(),onToast:void 0};function R(){E.innerHTML="";for(let F of z)E.appendChild(w(F,A))}return R(),{rerender:R,store:P,destroy:()=>{E.innerHTML=""}}}return{callTool:(D,z={})=>q.callTool(D,z),sendMessage:(D)=>q.sendMessage(D),onToolInput:(D)=>{if(Y=D,G){let z=G;G=void 0,queueMicrotask(()=>D(z))}},onToolResult:(D)=>{if(W=D,N!==void 0){let z=N;N=void 0,queueMicrotask(()=>D(z))}},onToolCancelled:(D)=>{_=D},onToolInputPartial:(D)=>{H=D},render:X,mount:(D,z,E)=>{let P=y1(D);return g.mount(P,z,{transport:q,...E})},requestMode:(D)=>U?.requestMode(D),openLink:(D,z)=>{if(U)U.openLink(D,z);else if(typeof window<"u")window.open(D,z??"_blank")},updateContext:(D)=>{if(U)U.updateContext(D)},host:Q,capabilities:Q.capabilities,theme:Q.theme,transport:q,destroy:()=>U?.disconnect()}}function y1($){if(typeof $==="string"){if(typeof document>"u")throw Error("Cannot resolve selector outside browser");let Z=document.querySelector($);if(!Z)throw Error(`Element not found: ${$}`);return Z}return $}var m1="#root";function u4($){return g.isPrefabData($)}function v1($){return g.isPrefabUpdate($)}function h1($){if(u4($))return $;if($!==null&&typeof $==="object"){let Z=$;if(u4(Z.structuredContent))return Z.structuredContent;if(Array.isArray(Z.content))for(let J of Z.content){let q=J;if(q.type==="text"&&typeof q.text==="string")try{let U=JSON.parse(q.text);if(u4(U))return U}catch{}}}return null}async function g1(){let $=document.querySelector(m1);if(!$){console.error(`[prefab:auto] Mount target "${m1}" not found`);return}let Z=$,J=await P4(),q;function U(Q){if(q)q.destroy();q=J.mount(Z,Q)}J.onToolResult((Q)=>{let Y=h1(Q);if(Y)U(Y);else if(v1(Q)&&q)q.update(Q)}),J.onToolInput((Q)=>{let Y=h1(Q);if(Y)U(Y);else if(v1(Q)&&q)q.update(Q)})}function e8(){if(document.readyState==="loading")document.addEventListener("DOMContentLoaded",()=>{g1().catch(($)=>{console.error("[prefab:auto] Boot failed:",$)})},{once:!0});else queueMicrotask(()=>{g1().catch(($)=>{console.error("[prefab:auto] Boot failed:",$)})})}e8();})();
14
+ }`}}function y1($,J){if(!$||typeof document>"u")return;let Z=(q)=>{for(let[U,Q]of Object.entries($))if(i8(U,q))q.preventDefault(),J(Q)};return document.addEventListener("keydown",Z),()=>document.removeEventListener("keydown",Z)}function i8($,J){let Z=$.toLowerCase().split("+").map((Q)=>Q.trim()),q=Z[Z.length-1],U=new Set(Z.slice(0,-1));if(U.has("ctrl")!==(J.ctrlKey||J.metaKey))return!1;if(U.has("shift")!==J.shiftKey)return!1;if(U.has("alt")!==J.altKey)return!1;return J.key.toLowerCase()===q}function L0($){let J=$?.baseUrl??(typeof window<"u"?window.location.origin:""),Z={"Content-Type":"application/json",...$?.headers},q=$?.fetch??globalThis.fetch.bind(globalThis);return{async callTool(U,Q){let Y=await q(`${J}/mcp/tools/call`,{method:"POST",headers:Z,body:JSON.stringify({jsonrpc:"2.0",method:"tools/call",params:{name:U,arguments:Q}})});if(!Y.ok)throw Error(`MCP tool call failed: ${Y.status} ${Y.statusText}`);let W=await Y.json();if(W.error)throw Error(W.error.message??"MCP tool call returned error");let _=W.result?.content??W.content??[];for(let B of _)if(B.type==="text"&&B.text!==void 0){try{let G=JSON.parse(B.text);if(typeof G==="object"&&G!==null&&"$prefab"in G)return G;return G}catch{}return B.text}return W.result??W},async sendMessage(U){await q(`${J}/mcp/messages`,{method:"POST",headers:Z,body:JSON.stringify({message:U})})}}}function j0(){return{callTool($){return console.warn(`[prefab] No MCP transport: callTool('${$}') ignored`),Promise.resolve(null)},sendMessage($){return console.warn("[prefab] No MCP transport: sendMessage ignored",$),Promise.resolve()}}}function d8($){return $!==null&&typeof $==="object"&&$.jsonrpc==="2.0"}class Q0{hostOrigin;listeners=new Map;protocol="prefab";cleanup;pending=new Map;callIdCounter=0;rpcPending=new Map;rpcIdCounter=0;sentRpcIds=new Set;postFn;constructor($="*"){this.hostOrigin=$}connect(){if(typeof window>"u")return;let $=r8();if($)this.postFn=(Z)=>$.postMessage(Z);let J=(Z)=>{if(this.hostOrigin!=="*"&&Z.origin!==this.hostOrigin)return;let q=Z.data;if(d8(q)){this.handleJsonRpc(q);return}let U=q;if(!U?.type.startsWith("prefab:"))return;if(U.type==="prefab:tool-call-response"&&U.id){let Y=this.pending.get(U.id);if(Y){if(this.pending.delete(U.id),U.payload?.error!=null)Y.reject(Error(U.payload.error));else Y.resolve(U.payload?.result);return}}let Q=this.listeners.get(U.type);if(Q)for(let Y of Q)Y(U.payload??{})};window.addEventListener("message",J),this.cleanup=()=>window.removeEventListener("message",J)}async initialize($){return Promise.any([this.initPrefab($),this.initJsonRpc($)])}createTransport(){if(this.protocol==="jsonrpc")return this.createJsonRpcTransport();return this.createPrefabTransport()}requestMode($){if(this.protocol==="jsonrpc")this.sendRpcRequest("ui/request-display-mode",{mode:$});else this.sendPrefab("prefab:request-mode",{mode:$})}openLink($,J){if(this.protocol==="jsonrpc")this.sendRpcRequest("ui/open-link",{url:$,target:J});else this.sendPrefab("prefab:open-link",{url:$,target:J})}updateContext($){if(this.protocol==="jsonrpc")this.sendRpcRequest("ui/update-model-context",{structuredContent:$});else this.sendPrefab("prefab:update-context",{context:$})}on($,J){if(!this.listeners.has($))this.listeners.set($,new Set);let Z=this.listeners.get($);if(Z)Z.add(J)}off($,J){this.listeners.get($)?.delete(J)}disconnect(){this.cleanup?.(),this.listeners.clear();for(let[,$]of this.pending)$.reject(Error("Bridge disconnected"));this.pending.clear();for(let[,$]of this.rpcPending)$.reject(Error("Bridge disconnected"));this.rpcPending.clear(),this.sentRpcIds.clear()}get activeProtocol(){return this.protocol}initPrefab($){return new Promise((J,Z)=>{let q=!1,U=(Q)=>{if(q)return;q=!0,this.off("prefab:init-response",U),this.protocol="prefab",J(Q)};this.on("prefab:init-response",U),this.sendPrefab("prefab:init",{capabilities:$}),setTimeout(()=>{if(!q)q=!0,this.off("prefab:init-response",U),Z(Error("prefab:init timeout"))},2000)})}createPrefabTransport(){return{callTool:($,J)=>{let Z=`tc-${++this.callIdCounter}`;return new Promise((q,U)=>{this.pending.set(Z,{resolve:q,reject:U}),this.sendPrefab("prefab:tool-call",{tool:$,arguments:J},Z),setTimeout(()=>{if(this.pending.has(Z))this.pending.delete(Z),U(Error(`Tool call '${$}' timed out`))},30000)})},sendMessage:($)=>{return this.sendPrefab("prefab:send-message",{message:$}),Promise.resolve()}}}sendPrefab($,J,Z){if(typeof window>"u")return;let q=window.parent!==window?window.parent:window,U={type:$,payload:J,id:Z};q.postMessage(U,this.hostOrigin)}handleJsonRpc($){if(!("method"in $)){let q=this.rpcPending.get($.id);if(q)if(this.rpcPending.delete($.id),$.error)q.reject(Error($.error.message));else q.resolve($.result);return}let J=$.method,Z=$.params??{};if($.id!=null&&this.sentRpcIds.delete($.id))return;if($.id!=null)this.postJsonRpc({jsonrpc:"2.0",id:$.id,result:{}});switch(J){case"ui/notifications/tool-input":this.dispatch("prefab:tool-input",{args:Z.arguments??Z});break;case"ui/notifications/tool-input-partial":this.dispatch("prefab:tool-input-partial",{args:Z.arguments??Z});break;case"ui/notifications/tool-result":this.dispatch("prefab:tool-result",{result:Z});break;case"ui/notifications/tool-cancelled":this.dispatch("prefab:tool-cancelled",Z);break;case"ui/notifications/host-context-changed":{let q={};if(typeof Z.theme==="string")q.colorScheme=Z.theme;if(typeof Z.styles==="object"&&Z.styles!==null){let U=Z.styles;if(U.variables)q.variables=U.variables}this.dispatch("prefab:theme-update",q);break}case"ui/resource-teardown":this.dispatch("prefab:teardown",Z);break}}initJsonRpc($){return new Promise((J,Z)=>{let q=++this.rpcIdCounter,U=!1;this.rpcPending.set(q,{resolve:(Q)=>{if(U)return;U=!0,this.protocol="jsonrpc";let Y=Q??{},W=Y.hostInfo??{},_=Y.hostContext??{},B=Y.hostCapabilities??{},G;if(typeof _.theme==="string"||typeof _.styles==="object"){if(G={},typeof _.theme==="string")G.colorScheme=_.theme;if(typeof _.styles==="object"&&_.styles!==null){let N=_.styles;if(N.variables)G.variables=N.variables}}this.postJsonRpc({jsonrpc:"2.0",method:"ui/notifications/initialized",params:{}}),J({hostName:W.name,hostVersion:W.version,capabilities:{toast:!0,navigation:B.openLinks!=null,messaging:!0,displayModes:_.availableDisplayModes??[]},theme:G,toolInput:void 0,meta:_})},reject:(Q)=>{if(U)return;U=!0,Z(Q)}}),this.postJsonRpc({jsonrpc:"2.0",id:q,method:"ui/initialize",params:{protocolVersion:"2026-01-26",capabilities:{},clientInfo:{name:"prefab",version:"0.2"},appCapabilities:{...$.displayModes&&{availableDisplayModes:$.displayModes}}}}),setTimeout(()=>{if(!U)U=!0,this.rpcPending.delete(q),Z(Error("ui/initialize timeout"))},2000)})}createJsonRpcTransport(){return{callTool:($,J)=>{return this.sendRpcRequest("tools/call",{name:$,arguments:J})},sendMessage:($)=>{return this.sendRpcRequest("ui/message",{role:"user",content:{type:"text",text:$}})}}}sendRpcRequest($,J){let Z=++this.rpcIdCounter;return new Promise((q,U)=>{this.rpcPending.set(Z,{resolve:q,reject:U}),this.postJsonRpc({jsonrpc:"2.0",id:Z,method:$,params:J}),setTimeout(()=>{if(this.rpcPending.has(Z))this.rpcPending.delete(Z),U(Error(`JSON-RPC '${$}' timed out`))},30000)})}postJsonRpc($){if(typeof window>"u")return;if($.id!=null&&typeof $.method==="string")this.sentRpcIds.add($.id);if(this.postFn)this.postFn($);else(window.parent!==window?window.parent:window).postMessage($,this.hostOrigin)}dispatch($,J){let Z=this.listeners.get($);if(Z)for(let q of Z)q(J)}}function g0($,J){if(J.variables)for(let[Z,q]of Object.entries(J.variables))$.style.setProperty(Z.startsWith("--")?Z:`--${Z}`,q);if(J.colorScheme&&J.colorScheme!=="auto")$.setAttribute("data-theme",J.colorScheme)}function O0(){if(typeof window>"u")return!1;try{return window.self!==window.top}catch{return!0}}function r8(){if(typeof window>"u")return;let $=window;if(typeof $.acquireVsCodeApi==="function")try{let J=$.acquireVsCodeApi();if(J!==null&&typeof J==="object"&&"postMessage"in J)return J}catch{return}return}var g={mount($,J,Z){T0();let q=[];if(J.pipes)for(let[N,z]of Object.entries(J.pipes))o8(N,z,q);let U=new J0(J.state),Q;if(Z?.transport&&"callTool"in Z.transport)Q=Z.transport;else if(Z?.transport)Q=L0(Z.transport);else Q=j0();let Y=Z?.onToast??a8,W={store:U,scope:{},transport:Q,rerender:()=>G(),onToast:Y,defs:J.defs};C1($,J.theme);let _=[];if(J.stylesheets)for(let N of J.stylesheets){let z=document.createElement("style");z.textContent=N,z.dataset.prefab="injected",document.head.appendChild(z),_.push(z)}let B;if(J.keyBindings)B=y1(J.keyBindings,async(N)=>{await k(N,{store:U,transport:Q,scope:{},rerender:()=>G(),onToast:Y})});function G(){$.innerHTML="";let N=w(J.view,W);$.appendChild(N)}return G(),{rerender:()=>G(),update(N){U.merge(N.update.state),G()},store:U,destroy(){B?.(),d0();for(let N of _)N.remove();for(let N of q)I0(N);$.innerHTML=""}}},isPrefabData($){return $!=null&&typeof $==="object"&&"$prefab"in $},isPrefabUpdate($){return $!=null&&typeof $==="object"&&"$prefab"in $&&"update"in $}},n8=new Set(["find","dot","length","upper","lower","truncate","join","first","last","abs","round","number","currency","percent","compact","date","time","datetime","pluralize","default","selectattr","rejectattr"]);function o8($,J,Z){if(n8.has($)){console.warn(`[prefab] wire pipe "${$}" ignored — shadows built-in`);return}try{let q=Function("return ("+J+")")();if(typeof q!=="function"){console.warn(`[prefab] wire pipe "${$}" — source did not evaluate to a function`);return}V0($,q),Z.push($)}catch(q){console.warn(`[prefab] wire pipe "${$}" — failed to hydrate:`,q)}}function a8($){if(typeof document>"u")return;let J=t8(),Z=document.createElement("div");Z.className="pf-toast",Z.setAttribute("data-variant",$.variant??"default"),Z.style.padding="12px 16px",Z.style.borderRadius="8px",Z.style.backgroundColor="var(--card, #fff)",Z.style.border="1px solid var(--border, #e5e7eb)",Z.style.boxShadow="0 4px 12px rgb(0 0 0 / 0.15)",Z.style.marginBottom="8px",Z.style.transition="opacity 0.3s ease";let q=document.createElement("div");if(q.textContent=$.message,q.style.fontWeight="500",Z.appendChild(q),$.description){let Q=document.createElement("div");Q.textContent=$.description,Q.style.fontSize="14px",Q.style.color="var(--muted-foreground, #6b7280)",Z.appendChild(Q)}J.appendChild(Z);let U=$.duration??4000;setTimeout(()=>{Z.style.opacity="0",setTimeout(()=>Z.remove(),300)},U)}function t8(){let J=document.getElementById("prefab-toast-container");if(!J)J=document.createElement("div"),J.id="prefab-toast-container",J.style.position="fixed",J.style.bottom="16px",J.style.right="16px",J.style.zIndex="9999",J.style.maxWidth="400px",document.body.appendChild(J);return J}if(typeof window<"u"){let $=window;$.PrefabRenderer=g,$.prefab={app:P0,mount:g.mount.bind(g),isPrefabData:g.isPrefabData.bind(g),isPrefabUpdate:g.isPrefabUpdate.bind(g),Bridge:Q0,isIframe:O0,registerPipe:V0,unregisterPipe:I0,listPipes:p0,registerComponent:M};let J=$.__PREFAB_DATA__;if(J!=null){let Z=document.getElementById("prefab-root");if(Z)g.mount(Z,J)}}async function P0($){T0();let J=$?.mode??"auto",Z=J==="bridge"||J==="auto"&&O0(),q,U,Q={capabilities:{}};if(Z)U=new Q0($?.hostOrigin),U.connect(),Q=await U.initialize($?.capabilities??{toolInput:!0}),q=U.createTransport();else if($?.transport)q=L0($.transport);else q=j0();if(Q.theme&&typeof document<"u")g0(document.documentElement,Q.theme);let Y,W,_,B,G=Q.toolInput,N;if(U)U.on("prefab:tool-input",(D)=>{let K=D.args??D;if(Y)Y(K);else G=K}),U.on("prefab:tool-result",(D)=>{let K=D.result??D;if(W)W(K);else N=K}),U.on("prefab:tool-cancelled",()=>{_?.()}),U.on("prefab:tool-input-partial",(D)=>{B?.(D.args??D)}),U.on("prefab:theme-update",(D)=>{if(typeof document<"u")g0(document.documentElement,D)});function z(D,...K){let E=b1(D),P=new J0,A={store:P,scope:{},transport:q,rerender:()=>R(),onToast:void 0};function R(){E.innerHTML="";for(let F of K)E.appendChild(w(F,A))}return R(),{rerender:R,store:P,destroy:()=>{E.innerHTML=""}}}return{callTool:(D,K={})=>q.callTool(D,K),sendMessage:(D)=>q.sendMessage(D),onToolInput:(D)=>{if(Y=D,G){let K=G;G=void 0,queueMicrotask(()=>D(K))}},onToolResult:(D)=>{if(W=D,N!==void 0){let K=N;N=void 0,queueMicrotask(()=>D(K))}},onToolCancelled:(D)=>{_=D},onToolInputPartial:(D)=>{B=D},render:z,mount:(D,K,E)=>{let P=b1(D);return g.mount(P,K,{transport:q,...E})},requestMode:(D)=>U?.requestMode(D),openLink:(D,K)=>{if(U)U.openLink(D,K);else if(typeof window<"u")window.open(D,K??"_blank")},updateContext:(D)=>{if(U)U.updateContext(D)},host:Q,capabilities:Q.capabilities,theme:Q.theme,transport:q,destroy:()=>U?.disconnect()}}function b1($){if(typeof $==="string"){if(typeof document>"u")throw Error("Cannot resolve selector outside browser");let J=document.querySelector($);if(!J)throw Error(`Element not found: ${$}`);return J}return $}var m1="#root";function u0($){return g.isPrefabData($)}function v1($){return g.isPrefabUpdate($)}function h1($){if(u0($))return $;if($!==null&&typeof $==="object"){let J=$;if(u0(J.structuredContent))return J.structuredContent;if(Array.isArray(J.content))for(let Z of J.content){let q=Z;if(q.type==="text"&&typeof q.text==="string")try{let U=JSON.parse(q.text);if(u0(U))return U}catch{}}}return null}async function g1(){let $=document.querySelector(m1);if(!$){console.error(`[prefab:auto] Mount target "${m1}" not found`);return}let J=$,Z=await P0(),q;function U(Q){if(q)q.destroy();q=Z.mount(J,Q)}Z.onToolResult((Q)=>{let Y=h1(Q);if(Y)U(Y);else if(v1(Q)&&q)q.update(Q)}),Z.onToolInput((Q)=>{let Y=h1(Q);if(Y)U(Y);else if(v1(Q)&&q)q.update(Q)})}function e8(){if(document.readyState==="loading")document.addEventListener("DOMContentLoaded",()=>{g1().catch(($)=>{console.error("[prefab:auto] Boot failed:",$)})},{once:!0});else queueMicrotask(()=>{g1().catch(($)=>{console.error("[prefab:auto] Boot failed:",$)})})}e8();})();