@maxhealth.tech/prefab 0.2.22 → 0.2.24

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 J0{data={};subscribers=new Map;globalSubscribers=new Set;generation=0;constructor($){if($)this.data=structuredClone($)}get($){return d1(this.data,$)}getAll(){return this.data}set($,J){l0(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($))l0(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 d1($,J){let Z=J.split("."),q=$;for(let U of Z){if(q==null||typeof q!=="object")return;q=q[U]}return q}var i1=new Set(["__proto__","constructor","prototype"]);function l0($,J,Z){let q=J.split(".");if(q.some((Q)=>i1.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 O0($,J){if(t.has($)&&t.get($)!==J)console.warn(`[prefab] pipe "${$}" re-registered`);t.set($,J)}function I0($){return t.delete($)}function s0(){return[...t.keys()]}function d0($){return t.get($)}var i0=-1,R0=new Map,r1=/\{\{\s*(.+?)\s*\}\}/g;function u($){return typeof $==="string"&&$.includes("{{")&&$.includes("}}")}function x($,J,Z){let q=$.trim();if(q.startsWith("{{")&&q.endsWith("}}")&&J4(q,"{{")===1){let U=q.slice(2,-2).trim();return r0(U,J,Z)}return $.replace(r1,(U,Q)=>{let Y=r0(Q.trim(),J,Z);return Y==null?"":String(Y)})}function r0($,J,Z){let[q,...U]=$4($),Q=h(q.trim(),J,Z);for(let Y of U)Q=n1(Y.trim(),Q,J,Z);return Q}function h($,J,Z){let q=t1($);if(q>=0){let Y=$.slice(0,q).trim(),W=$.slice(q+1),H=e1(W);if(H>=0){let N=W.slice(0,H).trim(),G=W.slice(H+1).trim(),B=h(Y,J,Z);return B!==null&&B!==void 0&&B!==!1&&B!==0&&B!==""?h(N,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 a1){let H=W0($,Y);if(H>=0){let N=h($.slice(0,H).trim(),J,Z),G=h($.slice(H+Y.length).trim(),J,Z);return W(N,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 o1){let H=W0($,Y);if(H>=0){let N=h($.slice(0,H).trim(),J,Z),G=h($.slice(H+Y.length).trim(),J,Z);return W(Number(N),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),H=$.slice(Y+1),N=Z[W];return H0(N,H)}return Z[$]}if(Z){let Y=$.split(".")[0];if(Y in Z)return H0(Z[Y],$.includes(".")?$.slice(Y.length+1):"")}return J.get($)}function n1($,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 H=n0(Y);if(H.length<2)return;let N=A0(H[0]),G=H[1].trim(),B;if(G.startsWith("'")&&G.endsWith("'")||G.startsWith('"')&&G.endsWith('"'))B=G.slice(1,-1);else if(Z){if(q&&G.startsWith("$")){let z=G.indexOf(".");if(z>=0){let L=G.slice(0,z);if(L in q)B=H0(q[L],G.slice(z+1))}else if(G in q)B=q[G]}if(B===void 0&&!(q&&G.startsWith("$")))if(q){let z=G.split(".")[0];B=z in q?H0(q[z],G.includes(".")?G.slice(z.length+1):""):Z.get(G)}else B=Z.get(G)}else B=G;if(B==null)return;let E=Z?.generation??0;if(E!==i0)R0=new Map,i0=E;let F=R0.get(J);if(!F)F=new Map,R0.set(J,F);let X=F.get(N);if(!X){X=new Map;for(let z of J)if(z!=null&&typeof z==="object"){let L=z[N];if(L!=null)X.set(String(L),z)}F.set(N,X)}return X.get(String(B))}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 H=typeof W==="string"?W:"USD";try{return new Intl.NumberFormat("en-US",{style:"currency",currency:H}).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 H=typeof W==="number"?W:1;try{return new Intl.NumberFormat("en-US",{notation:"compact",maximumFractionDigits:H}).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 H=Number(J),N=typeof W==="string"?W:"";return H===1?N:`${N}s`}case"default":return J==null||J===""?W:J;case"selectattr":return Array.isArray(J)&&typeof W==="string"?J.filter((H)=>H!=null&&typeof H==="object"&&Boolean(H[W])):J;case"rejectattr":return Array.isArray(J)&&typeof W==="string"?J.filter((H)=>{if(H==null||typeof H!=="object")return!1;let N=H[W];return N==null||N===!1||N===0||N===""}):J;default:{let H=d0(Q);if(H){let N=Y?n0(Y).map(A0):[];return H(J,...N)}return J}}}var a1=[["!==",($,J)=>$!==J],["===",($,J)=>$===J],["!=",($,J)=>$!=J],["==",($,J)=>$==J],[">=",($,J)=>Number($)>=Number(J)],["<=",($,J)=>Number($)<=Number(J)],[">",($,J)=>Number($)>Number(J)],["<",($,J)=>Number($)<Number(J)]],o1=[[" + ",($,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 t1($){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 e1($){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 $4($){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 n0($){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 H0($,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 J4($,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 Z4(q,J)}async function Z4($,J){let Z=$.action;switch(Z){case"setState":{q4($,J);return}case"toggleState":{U4($,J);return}case"appendState":{Q4($,J);return}case"popState":{Y4($,J);return}case"showToast":{W4($,J);return}case"closeOverlay":{H4($,J);return}case"openLink":{M4($);return}case"setInterval":{N4($,J);return}case"toolCall":case"callTool":return X4($,J);case"sendMessage":return G4($,J);case"updateContext":{z4($,J);return}case"fetch":return E4($,J);case"openFilePicker":{K4($,J);return}case"callHandler":return F4($,J);case"requestDisplayMode":{D4($,J);return}default:console.warn(`[prefab] Unknown action: ${Z}`)}}function q4($,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 U4($,J){J.store.toggle($.key),J.rerender()}function Q4($,J){let Z=$.value??$.item;if(u(Z))Z=x(Z,J.store,J.scope);J.store.append($.key,Z,$.index),J.rerender()}function Y4($,J){J.store.pop($.key,$.index),J.rerender()}function W4($,J){J.onToast?.({message:B0($.message,J),description:$.description!=null?B0($.description,J):void 0,variant:$.variant,duration:$.duration})}function H4($,J){if(typeof document<"u")document.dispatchEvent(new CustomEvent("prefab:close-overlay"))}function M4($){if(typeof window<"u"){let J=$.url;if(!J){console.warn("[prefab] openLink: missing url");return}if(!o0(J)){console.warn(`[prefab] Blocked unsafe URL scheme: ${J}`);return}window.open(J,$.target??"_blank")}}var M0=new Set,B4=20,_4=100;function N4($,J){let Z=Math.max($.intervalMs,_4),q=$.onTick;if(typeof globalThis.setInterval!=="function")return;if(M0.size>=B4){console.warn("[prefab] Max intervals reached, ignoring new setInterval");return}let U=globalThis.setInterval(()=>void k(q,J),Z);M0.add(U)}function a0(){for(let $ of M0)globalThis.clearInterval($);M0.clear()}async function X4($,J){if(!J.transport){console.warn("[prefab] No MCP transport configured for toolCall");return}let Z=$.tool,q=t0($.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 G4($,J){if(!J.transport){console.warn("[prefab] No MCP transport configured for sendMessage");return}await J.transport.sendMessage(B0($.message,J))}function z4($,J){let Z=$.context;if(Z!=null)J.store.merge(Z),J.rerender()}async function E4($,J){let Z=B0($.url,J);if(!o0(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 K4($,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 F4($,J){let Z=$.handler,q=t0($.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 D4($,J){if(typeof document<"u")document.dispatchEvent(new CustomEvent("prefab:request-display-mode",{detail:{mode:$.mode}}))}var L4=/^\s*(javascript|vbscript|data):/i;function o0($){return!L4.test($)}function B0($,J){if(u($)){let Z=x($,J.store,J.scope);return Z==null?"":String(Z)}return $==null?"":String($)}function t0($,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})}class S0{callbacks=[];track($){this.callbacks.push($)}flush(){for(let $ of this.callbacks)try{$()}catch(J){console.warn("[prefab] destroy callback error:",J)}this.callbacks=[]}get size(){return this.callbacks.length}}function j4($){return typeof $==="object"&&"element"in $}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){let U=Z($,J);if(j4(U))q=U.element,J.destroyRegistry?.track(U.destroy);else q=U}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=K($.cssClass,J);if(U)q.className=(q.className?q.className+" ":"")+U}}if($.onMount){let U=$.onMount,Q=b(J);queueMicrotask(()=>void k(U,Q))}return q}function j($,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=T4($,q,J,Z);else if(U.type==="Elif"||U.type==="Else")q++;else J.appendChild(w(U,Z)),q++}}function T4($,J,Z,q){let U=!1,Q=J,Y=$[Q];if(e0(Y.condition,q))k0(Y,Z,q),U=!0;Q++;while(Q<$.length){let W=$[Q];if(W.type==="Elif"){if(!U&&e0(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 e0($,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 K($,J){if(u($)){let Z=x($,J.store,J.scope);return Z==null?"":String(Z)}return $==null?"":String($)}function y($,J){if(u($))return x($,J.store,J.scope);return $}function b($){return{store:$.store,transport:$.transport,scope:$.scope,rerender:$.rerender,onToast:$.onToast}}function _($,J){let Z=document.createElement($);if(J)Z.className=J;return Z}function w0($,J){return $.textContent=J,$}function q1(){M("Column",P4),M("Row",V4),M("Grid",$1),M("GridItem",J1),M("Container",O4),M("Div",Z1),M("Span",I4),M("Dashboard",$1),M("DashboardItem",J1),M("Pages",R4),M("Page",Z1),M("Detail",A4),M("MasterDetail",k4)}function P4($,J){let Z=_("div","pf-column");Z.style.display="flex",Z.style.flexDirection="column";let q=_0($);if(q!=null)Z.style.gap=`${q*4}px`;if($.align!=null)Z.style.alignItems=U1($.align);if($.justify!=null)Z.style.justifyContent=Q1($.justify);return j($,Z,J),Z}function V4($,J){let Z=_("div","pf-row");Z.style.display="flex",Z.style.flexDirection="row";let q=_0($);if(q!=null)Z.style.gap=`${q*4}px`;if($.align!=null)Z.style.alignItems=U1($.align);if($.justify!=null)Z.style.justifyContent=Q1($.justify);if($.wrap===!0)Z.style.flexWrap="wrap";return j($,Z,J),Z}function $1($,J){let Z=_("div","pf-grid");Z.style.display="grid";let q=$.columns??3;Z.style.gridTemplateColumns=`repeat(${q}, 1fr)`;let U=_0($);if(U!=null)Z.style.gap=`${U*4}px`;return j($,Z,J),Z}function J1($,J){let Z=_("div","pf-grid-item");if($.colSpan!=null)Z.style.gridColumn=`span ${$.colSpan}`;if($.rowSpan!=null)Z.style.gridRow=`span ${$.rowSpan}`;return j($,Z,J),Z}function O4($,J){let Z=_("div","pf-container");if(Z.style.maxWidth=$.maxWidth??"1200px",Z.style.margin="0 auto",$.padding!=null)Z.style.padding=`${$.padding*4}px`;return j($,Z,J),Z}function Z1($,J){let Z=_("div","pf-div");return j($,Z,J),Z}function I4($,J){let Z=_("span","pf-span");return j($,Z,J),Z}function R4($,J){let Z=_("div","pf-pages");return j($,Z,J),Z}function A4($,J){let Z=_("div","pf-detail"),q=$.of!=null?y($.of,J):void 0;if(q!=null&&q!==""&&q!==!1&&q!==0)j($,Z,J);else if($.empty!=null){let U=$.empty;Z.appendChild(w(U,J))}return Z}function k4($,J){let Z=_("div","pf-master-detail");Z.style.display="flex",Z.style.flexDirection="row";let q=_0($);if(q!=null)Z.style.gap=`${q*4}px`;let U=$.masterWidth??"33%",Q=$.children??[];if(Q.length>0){let Y=_("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=_("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 f4=/\bgap-(\d+)\b/;function _0($){if($.gap!=null)return $.gap;if(typeof $.cssClass==="string"){let J=f4.exec($.cssClass);if(J)return Number(J[1])}return null}function U1($){return{start:"flex-start",end:"flex-end",center:"center",stretch:"stretch",baseline:"baseline"}[$]??$}function Q1($){return{start:"flex-start",end:"flex-end",center:"center",between:"space-between",around:"space-around",evenly:"space-evenly"}[$]??$}function W1(){M("Heading",S4),M("H1",($,J)=>N0($,J,"h1")),M("H2",($,J)=>N0($,J,"h2")),M("H3",($,J)=>N0($,J,"h3")),M("H4",($,J)=>N0($,J,"h4")),M("Text",w4),M("P",C4),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",y4),M("Code",m4),M("Markdown",v4),M("Kbd",h4)}function S4($,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=K($.content,J),U}function N0($,J,Z){let q=document.createElement(Z);return q.className=`pf-heading pf-${Z}`,q.textContent=K($.content,J),q}function w4($,J){return w0(_("span","pf-text"),K($.content,J))}function C4($,J){return w0(_("p","pf-p"),K($.content,J))}function e($,J,Z,q){let U=document.createElement(Z);return U.className=q,U.textContent=K($.content,J),U}var b4=/^\s*(javascript|vbscript|data):/i;function y4($,J){let Z=document.createElement("a");if(Z.className="pf-link",Z.textContent=K($.content,J),$.href!=null){let q=K($.href,J);if(!b4.test(q))Z.href=q}if($.target!=null)Z.target=K($.target,J);return Z}function m4($,J){let Z=_("pre","pf-code"),q=_("code");if(q.textContent=K($.content,J),$.language!=null)q.setAttribute("data-language",$.language);return Z.appendChild(q),Z}function v4($,J){let Z=_("div","pf-markdown"),q=K($.content,J);return Z.innerHTML=H1(q),Z.setAttribute("data-markdown","true"),Z}var Y1=/^\s*(javascript|vbscript|data):/i;function G0($){return $.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;")}function X0($){let J=G0($),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(Y1.test(Q))return G0(U);return`<img src="${Q}" alt="${U}" />`}),J=J.replace(/\[([^\]]+)\]\(([^)]+)\)/g,(q,U,Q)=>{if(Y1.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 H1($){let J=$.replace(/\r\n?/g,`
1
+ (()=>{class J0{data={};subscribers=new Map;globalSubscribers=new Set;generation=0;constructor($){if($)this.data=structuredClone($)}get($){return d1(this.data,$)}getAll(){return this.data}set($,J){l0(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($))l0(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 d1($,J){let Z=J.split("."),q=$;for(let U of Z){if(q==null||typeof q!=="object")return;q=q[U]}return q}var i1=new Set(["__proto__","constructor","prototype"]);function l0($,J,Z){let q=J.split(".");if(q.some((Q)=>i1.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 T0($,J){if(t.has($)&&t.get($)!==J)console.warn(`[prefab] pipe "${$}" re-registered`);t.set($,J)}function I0($){return t.delete($)}function s0(){return[...t.keys()]}function d0($){return t.get($)}var i0=-1,R0=new Map,r1=/\{\{\s*(.+?)\s*\}\}/g;function u($){return typeof $==="string"&&$.includes("{{")&&$.includes("}}")}function x($,J,Z){let q=$.trim();if(q.startsWith("{{")&&q.endsWith("}}")&&J4(q,"{{")===1){let U=q.slice(2,-2).trim();return r0(U,J,Z)}return $.replace(r1,(U,Q)=>{let Y=r0(Q.trim(),J,Z);return Y==null?"":String(Y)})}function r0($,J,Z){let[q,...U]=$4($),Q=h(q.trim(),J,Z);for(let Y of U)Q=n1(Y.trim(),Q,J,Z);return Q}function h($,J,Z){let q=t1($);if(q>=0){let Y=$.slice(0,q).trim(),W=$.slice(q+1),H=e1(W);if(H>=0){let N=W.slice(0,H).trim(),G=W.slice(H+1).trim(),B=h(Y,J,Z);return B!==null&&B!==void 0&&B!==!1&&B!==0&&B!==""?h(N,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 a1){let H=W0($,Y);if(H>=0){let N=h($.slice(0,H).trim(),J,Z),G=h($.slice(H+Y.length).trim(),J,Z);return W(N,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 o1){let H=W0($,Y);if(H>=0){let N=h($.slice(0,H).trim(),J,Z),G=h($.slice(H+Y.length).trim(),J,Z);return W(Number(N),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),H=$.slice(Y+1),N=Z[W];return H0(N,H)}return Z[$]}if(Z){let Y=$.split(".")[0];if(Y in Z)return H0(Z[Y],$.includes(".")?$.slice(Y.length+1):"")}return J.get($)}function n1($,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 H=n0(Y);if(H.length<2)return;let N=A0(H[0]),G=H[1].trim(),B;if(G.startsWith("'")&&G.endsWith("'")||G.startsWith('"')&&G.endsWith('"'))B=G.slice(1,-1);else if(Z){if(q&&G.startsWith("$")){let z=G.indexOf(".");if(z>=0){let L=G.slice(0,z);if(L in q)B=H0(q[L],G.slice(z+1))}else if(G in q)B=q[G]}if(B===void 0&&!(q&&G.startsWith("$")))if(q){let z=G.split(".")[0];B=z in q?H0(q[z],G.includes(".")?G.slice(z.length+1):""):Z.get(G)}else B=Z.get(G)}else B=G;if(B==null)return;let E=Z?.generation??0;if(E!==i0)R0=new Map,i0=E;let F=R0.get(J);if(!F)F=new Map,R0.set(J,F);let X=F.get(N);if(!X){X=new Map;for(let z of J)if(z!=null&&typeof z==="object"){let L=z[N];if(L!=null)X.set(String(L),z)}F.set(N,X)}return X.get(String(B))}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 H=typeof W==="string"?W:"USD";try{return new Intl.NumberFormat("en-US",{style:"currency",currency:H}).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 H=typeof W==="number"?W:1;try{return new Intl.NumberFormat("en-US",{notation:"compact",maximumFractionDigits:H}).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 H=Number(J),N=typeof W==="string"?W:"";return H===1?N:`${N}s`}case"default":return J==null||J===""?W:J;case"selectattr":return Array.isArray(J)&&typeof W==="string"?J.filter((H)=>H!=null&&typeof H==="object"&&Boolean(H[W])):J;case"rejectattr":return Array.isArray(J)&&typeof W==="string"?J.filter((H)=>{if(H==null||typeof H!=="object")return!1;let N=H[W];return N==null||N===!1||N===0||N===""}):J;default:{let H=d0(Q);if(H){let N=Y?n0(Y).map(A0):[];return H(J,...N)}return J}}}var a1=[["!==",($,J)=>$!==J],["===",($,J)=>$===J],["!=",($,J)=>$!=J],["==",($,J)=>$==J],[">=",($,J)=>Number($)>=Number(J)],["<=",($,J)=>Number($)<=Number(J)],[">",($,J)=>Number($)>Number(J)],["<",($,J)=>Number($)<Number(J)]],o1=[[" + ",($,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 t1($){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 e1($){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 $4($){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 n0($){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 H0($,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 J4($,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 Z4(q,J)}async function Z4($,J){let Z=$.action;switch(Z){case"setState":{q4($,J);return}case"toggleState":{U4($,J);return}case"appendState":{Q4($,J);return}case"popState":{Y4($,J);return}case"showToast":{W4($,J);return}case"closeOverlay":{H4($,J);return}case"openLink":{M4($);return}case"setInterval":{N4($,J);return}case"toolCall":case"callTool":return X4($,J);case"sendMessage":return G4($,J);case"updateContext":{z4($,J);return}case"fetch":return E4($,J);case"openFilePicker":{K4($,J);return}case"callHandler":return F4($,J);case"requestDisplayMode":{D4($,J);return}default:console.warn(`[prefab] Unknown action: ${Z}`)}}function q4($,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 U4($,J){J.store.toggle($.key),J.rerender()}function Q4($,J){let Z=$.value??$.item;if(u(Z))Z=x(Z,J.store,J.scope);J.store.append($.key,Z,$.index),J.rerender()}function Y4($,J){J.store.pop($.key,$.index),J.rerender()}function W4($,J){J.onToast?.({message:B0($.message,J),description:$.description!=null?B0($.description,J):void 0,variant:$.variant,duration:$.duration})}function H4($,J){if(typeof document<"u")document.dispatchEvent(new CustomEvent("prefab:close-overlay"))}function M4($){if(typeof window<"u"){let J=$.url;if(!J){console.warn("[prefab] openLink: missing url");return}if(!o0(J)){console.warn(`[prefab] Blocked unsafe URL scheme: ${J}`);return}window.open(J,$.target??"_blank")}}var M0=new Set,B4=20,_4=100;function N4($,J){let Z=Math.max($.intervalMs,_4),q=$.onTick;if(typeof globalThis.setInterval!=="function")return;if(M0.size>=B4){console.warn("[prefab] Max intervals reached, ignoring new setInterval");return}let U=globalThis.setInterval(()=>void k(q,J),Z);M0.add(U)}function a0(){for(let $ of M0)globalThis.clearInterval($);M0.clear()}async function X4($,J){if(!J.transport){console.warn("[prefab] No MCP transport configured for toolCall");return}let Z=$.tool,q=t0($.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 G4($,J){if(!J.transport){console.warn("[prefab] No MCP transport configured for sendMessage");return}await J.transport.sendMessage(B0($.message,J))}function z4($,J){let Z=$.context;if(Z!=null)J.store.merge(Z),J.rerender()}async function E4($,J){let Z=B0($.url,J);if(!o0(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 K4($,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 F4($,J){let Z=$.handler,q=t0($.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 D4($,J){if(typeof document<"u")document.dispatchEvent(new CustomEvent("prefab:request-display-mode",{detail:{mode:$.mode}}))}var L4=/^\s*(javascript|vbscript|data):/i;function o0($){return!L4.test($)}function B0($,J){if(u($)){let Z=x($,J.store,J.scope);return Z==null?"":String(Z)}return $==null?"":String($)}function t0($,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})}class S0{callbacks=[];track($){this.callbacks.push($)}flush(){for(let $ of this.callbacks)try{$()}catch(J){console.warn("[prefab] destroy callback error:",J)}this.callbacks=[]}get size(){return this.callbacks.length}}function j4($){return typeof $==="object"&&"element"in $}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){let U=Z($,J);if(j4(U))q=U.element,J.destroyRegistry?.track(U.destroy);else q=U}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=K($.cssClass,J);if(U)q.className=(q.className?q.className+" ":"")+U}}if($.onMount){let U=$.onMount,Q=b(J);queueMicrotask(()=>void k(U,Q))}return q}function j($,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=P4($,q,J,Z);else if(U.type==="Elif"||U.type==="Else")q++;else J.appendChild(w(U,Z)),q++}}function P4($,J,Z,q){let U=!1,Q=J,Y=$[Q];if(e0(Y.condition,q))k0(Y,Z,q),U=!0;Q++;while(Q<$.length){let W=$[Q];if(W.type==="Elif"){if(!U&&e0(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 e0($,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 K($,J){if(u($)){let Z=x($,J.store,J.scope);return Z==null?"":String(Z)}return $==null?"":String($)}function y($,J){if(u($))return x($,J.store,J.scope);return $}function b($){return{store:$.store,transport:$.transport,scope:$.scope,rerender:$.rerender,onToast:$.onToast}}function _($,J){let Z=document.createElement($);if(J)Z.className=J;return Z}function w0($,J){return $.textContent=J,$}function q1(){M("Column",V4),M("Row",O4),M("Grid",$1),M("GridItem",J1),M("Container",T4),M("Div",Z1),M("Span",I4),M("Dashboard",$1),M("DashboardItem",J1),M("Pages",R4),M("Page",Z1),M("Detail",A4),M("MasterDetail",k4)}function V4($,J){let Z=_("div","pf-column");Z.style.display="flex",Z.style.flexDirection="column";let q=_0($);if(q!=null)Z.style.gap=`${q*4}px`;if($.align!=null)Z.style.alignItems=U1($.align);if($.justify!=null)Z.style.justifyContent=Q1($.justify);return j($,Z,J),Z}function O4($,J){let Z=_("div","pf-row");Z.style.display="flex",Z.style.flexDirection="row";let q=_0($);if(q!=null)Z.style.gap=`${q*4}px`;if($.align!=null)Z.style.alignItems=U1($.align);if($.justify!=null)Z.style.justifyContent=Q1($.justify);if($.wrap===!0)Z.style.flexWrap="wrap";return j($,Z,J),Z}function $1($,J){let Z=_("div","pf-grid");Z.style.display="grid";let q=$.columns??3;Z.style.gridTemplateColumns=`repeat(${q}, 1fr)`;let U=_0($);if(U!=null)Z.style.gap=`${U*4}px`;return j($,Z,J),Z}function J1($,J){let Z=_("div","pf-grid-item");if($.colSpan!=null)Z.style.gridColumn=`span ${$.colSpan}`;if($.rowSpan!=null)Z.style.gridRow=`span ${$.rowSpan}`;return j($,Z,J),Z}function T4($,J){let Z=_("div","pf-container");if(Z.style.maxWidth=$.maxWidth??"1200px",Z.style.margin="0 auto",$.padding!=null)Z.style.padding=`${$.padding*4}px`;return j($,Z,J),Z}function Z1($,J){let Z=_("div","pf-div");return j($,Z,J),Z}function I4($,J){let Z=_("span","pf-span");return j($,Z,J),Z}function R4($,J){let Z=_("div","pf-pages");return j($,Z,J),Z}function A4($,J){let Z=_("div","pf-detail"),q=$.of!=null?y($.of,J):void 0;if(q!=null&&q!==""&&q!==!1&&q!==0)j($,Z,J);else if($.empty!=null){let U=$.empty;Z.appendChild(w(U,J))}return Z}function k4($,J){let Z=_("div","pf-master-detail");Z.style.display="flex",Z.style.flexDirection="row";let q=_0($);if(q!=null)Z.style.gap=`${q*4}px`;let U=$.masterWidth??"33%",Q=$.children??[];if(Q.length>0){let Y=_("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=_("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 f4=/\bgap-(\d+)\b/;function _0($){if($.gap!=null)return $.gap;if(typeof $.cssClass==="string"){let J=f4.exec($.cssClass);if(J)return Number(J[1])}return null}function U1($){return{start:"flex-start",end:"flex-end",center:"center",stretch:"stretch",baseline:"baseline"}[$]??$}function Q1($){return{start:"flex-start",end:"flex-end",center:"center",between:"space-between",around:"space-around",evenly:"space-evenly"}[$]??$}function W1(){M("Heading",S4),M("H1",($,J)=>N0($,J,"h1")),M("H2",($,J)=>N0($,J,"h2")),M("H3",($,J)=>N0($,J,"h3")),M("H4",($,J)=>N0($,J,"h4")),M("Text",w4),M("P",C4),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",y4),M("Code",m4),M("Markdown",v4),M("Kbd",h4)}function S4($,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=K($.content,J),U}function N0($,J,Z){let q=document.createElement(Z);return q.className=`pf-heading pf-${Z}`,q.textContent=K($.content,J),q}function w4($,J){return w0(_("span","pf-text"),K($.content,J))}function C4($,J){return w0(_("p","pf-p"),K($.content,J))}function e($,J,Z,q){let U=document.createElement(Z);return U.className=q,U.textContent=K($.content,J),U}var b4=/^\s*(javascript|vbscript|data):/i;function y4($,J){let Z=document.createElement("a");if(Z.className="pf-link",Z.textContent=K($.content,J),$.href!=null){let q=K($.href,J);if(!b4.test(q))Z.href=q}if($.target!=null)Z.target=K($.target,J);return Z}function m4($,J){let Z=_("pre","pf-code"),q=_("code");if(q.textContent=K($.content,J),$.language!=null)q.setAttribute("data-language",$.language);return Z.appendChild(q),Z}function v4($,J){let Z=_("div","pf-markdown"),q=K($.content,J);return Z.innerHTML=H1(q),Z.setAttribute("data-markdown","true"),Z}var Y1=/^\s*(javascript|vbscript|data):/i;function G0($){return $.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;")}function X0($){let J=G0($),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(Y1.test(Q))return G0(U);return`<img src="${Q}" alt="${U}" />`}),J=J.replace(/\[([^\]]+)\]\(([^)]+)\)/g,(q,U,Q)=>{if(Y1.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 H1($){let J=$.replace(/\r\n?/g,`
2
2
  `).split(`
3
3
  `),Z=[],q=0;while(q<J.length){let U=J[q];if(U.trimStart().startsWith("```")){let W=U.trimStart().slice(3).trim(),H=[];q++;while(q<J.length&&!J[q].trimStart().startsWith("```"))H.push(G0(J[q])),q++;q++;let N=W?` data-language="${G0(W)}"`:"";Z.push(`<pre class="pf-code"><code${N}>${H.join(`
4
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}>${X0(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>${H1(W.join(`
5
5
  `))}</blockquote>`);continue}if(/^[\s]*[-*+]\s+/.test(U)){Z.push("<ul>");while(q<J.length&&/^[\s]*[-*+]\s+/.test(J[q]))Z.push(`<li>${X0(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>${X0(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(X0).join("<br />")}</p>`)}return Z.join(`
6
- `)}function h4($,J){let Z=document.createElement("kbd");return Z.className="pf-kbd",Z.textContent=K($.content,J),Z}function B1(){M("Card",g4),M("CardHeader",C0("pf-card-header")),M("CardTitle",M1("pf-card-title","h3")),M("CardDescription",M1("pf-card-description","p")),M("CardContent",C0("pf-card-content")),M("CardFooter",C0("pf-card-footer"))}function g4($,J){let Z=_("div","pf-card");return Z.style.overflow="hidden",j($,Z,J),Z}function C0($){return(J,Z)=>{let q=_("div",$);return q.style.padding="16px 24px",j(J,q,Z),q}}function M1($,J){return(Z,q)=>{let U=document.createElement(J);return U.className=$,U.textContent=K(Z.content,q),U}}function _1(){M("DataTable",u4),M("Badge",x4),M("Dot",p4),M("Metric",c4),M("Ring",l4),M("Progress",s4),M("Separator",d4),M("Loader",i4),M("Icon",r4),M("Sparkline",n4)}function u4($,J){let Z=_("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,J),Y=$.rowKey,W=$.selected,H=document.createElement("thead"),N=document.createElement("tr");for(let B of U){let E=document.createElement("th");E.className="pf-datatable-th",E.textContent=B.header??B.key,E.style.padding="8px 12px",E.style.textAlign="left",N.appendChild(E)}H.appendChild(N),q.appendChild(H);let G=document.createElement("tbody");if(Array.isArray(Q)){let B=W!=null?y(W,J):void 0;for(let E of Q){let F=document.createElement("tr");F.className="pf-datatable-row";let X=E;if(Y&&B!=null&&X[Y]!=null&&String(X[Y])===String(B))F.classList.add("pf-datatable-row-selected");if($.onRowClick!=null&&Y)F.style.cursor="pointer",F.addEventListener("click",()=>{let z={...J.scope,$item:X,$index:Q.indexOf(E)},L=b({...J,scope:z});k($.onRowClick,L)});for(let z of U){let L=document.createElement("td");L.className="pf-datatable-td";let V;if(z.accessor)V=y(`{{ $item.${z.accessor} }}`,{...J,scope:{...J.scope,$item:X}});else if(V=X[z.key],z.format&&V!=null)V=y(`{{ __fmtVal | ${z.format} }}`,{...J,scope:{...J.scope,__fmtVal:V}});L.textContent=V==null?"":String(V),L.style.padding="8px 12px",F.appendChild(L)}G.appendChild(F)}}if(q.appendChild(G),$.search===!0){let B=document.createElement("input");B.type="text",B.placeholder="Search...",B.className="pf-datatable-search",B.style.marginBottom="8px",B.style.padding="6px 12px",B.style.width="100%",B.style.boxSizing="border-box",B.addEventListener("input",()=>{let E=B.value.toLowerCase(),F=Array.from(G.querySelectorAll("tr"));for(let X of F){let z=X.textContent.toLowerCase();X.style.display=z.includes(E)?"":"none"}}),Z.appendChild(B)}return Z.appendChild(q),Z}function x4($,J){let Z=_("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=K($.label??$.content,J),a4(Z,q),Z}function p4($,J){let Z=_("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 c4($,J){let Z=_("div","pf-metric"),q=_("div","pf-metric-label");q.textContent=K($.label,J),q.style.fontSize="14px",Z.appendChild(q);let U=_("div","pf-metric-value");if(U.textContent=K($.value,J),U.style.fontSize="28px",U.style.fontWeight="700",Z.appendChild(U),$.delta!=null){let Q=_("span","pf-metric-delta");Q.textContent=K($.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=_("div","pf-metric-desc");Q.textContent=K($.description,J),Q.style.fontSize="12px",Z.appendChild(Q)}return Z}function l4($,J){let Z=_("div","pf-ring"),q=$.size??80,U=$.thickness??8,Q=Number(y($.value,J)??0),Y=Math.max(0,Math.min(100,Q)),W=(q-U)/2,H=2*Math.PI*W,N=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 B=document.createElementNS("http://www.w3.org/2000/svg","circle");B.setAttribute("cx",String(q/2)),B.setAttribute("cy",String(q/2)),B.setAttribute("r",String(W)),B.setAttribute("fill","none"),B.setAttribute("stroke","var(--muted, #e5e7eb)"),B.setAttribute("stroke-width",String(U));let E=document.createElementNS("http://www.w3.org/2000/svg","circle");if(E.setAttribute("cx",String(q/2)),E.setAttribute("cy",String(q/2)),E.setAttribute("r",String(W)),E.setAttribute("fill","none"),E.setAttribute("stroke","var(--primary, #3b82f6)"),E.setAttribute("stroke-width",String(U)),E.setAttribute("stroke-dasharray",String(H)),E.setAttribute("stroke-dashoffset",String(N)),E.setAttribute("stroke-linecap","round"),E.style.transform="rotate(-90deg)",E.style.transformOrigin="center",G.appendChild(B),G.appendChild(E),Z.appendChild(G),$.label!=null){let F=_("div","pf-ring-label");F.textContent=K($.label,J),F.style.textAlign="center",F.style.fontSize="12px",Z.appendChild(F)}return Z}function s4($,J){let Z=_("div","pf-progress");Z.setAttribute("role","progressbar");let q=Number(y($.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=_("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 d4($,J){let Z=document.createElement("hr");return Z.className="pf-separator",Z.style.border="none",Z.style.margin="8px 0",Z}function i4($,J){let Z=_("div","pf-loader");return Z.textContent="⏳",Z.style.display="flex",Z.style.justifyContent="center",Z.style.padding="16px",Z}function r4($,J){let Z=_("span","pf-icon");return Z.setAttribute("data-icon",K($.name??$.content,J)),Z}function n4($,J){let Z=_("div","pf-sparkline"),q=$.data??[];if(q.length===0)return Z;let U=120,Q=32,Y=Math.max(...q),W=Math.min(...q),H=Y-W||1,N=document.createElementNS("http://www.w3.org/2000/svg","svg");N.setAttribute("width",String(U)),N.setAttribute("height",String(Q)),N.setAttribute("viewBox",`0 0 ${U} ${Q}`);let G=q.length>1?q.length-1:1,B=q.map((F,X)=>{let z=X/G*U,L=Q-(F-W)/H*(Q-4)-2;return`${z},${L}`}).join(" "),E=document.createElementNS("http://www.w3.org/2000/svg","polyline");return E.setAttribute("points",B),E.setAttribute("fill","none"),E.setAttribute("stroke","var(--primary, #3b82f6)"),E.setAttribute("stroke-width","1.5"),N.appendChild(E),Z.appendChild(N),Z}function a4($,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 X1(){M("Form",o4),M("Input",t4),M("Textarea",e4),M("Button",$8),M("ButtonGroup",J8),M("Select",Z8),M("SelectOption",q8),M("SelectGroup",z0("pf-select-group")),M("SelectLabel",Z0("pf-select-label")),M("SelectSeparator",N1),M("Checkbox",U8),M("Switch",Q8),M("Slider",Y8),M("Radio",H8),M("RadioGroup",M8),M("Combobox",B8),M("ComboboxOption",_8),M("ComboboxGroup",z0("pf-combobox-group")),M("ComboboxLabel",Z0("pf-combobox-label")),M("ComboboxSeparator",N1),M("Calendar",N8),M("DatePicker",X8),M("Field",z0("pf-field")),M("FieldTitle",Z0("pf-field-title")),M("FieldDescription",Z0("pf-field-description")),M("FieldContent",z0("pf-field-content")),M("FieldError",Z0("pf-field-error")),M("ChoiceCard",G8)}function o4($,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=b(J);Y.scope={...J.scope,...Q},k($.onSubmit,Y)}}),j($,Z,J),Z}function t4($,J){let Z=_("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=K($.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=K($.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,{...b(J),scope:{...J.scope,$event:q.value}})})}return b0(q),Z.appendChild(q),Z}function e4($,J){let Z=_("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,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,{...b(J),scope:{...J.scope,$event:q.value}})})}return b0(q),Z.appendChild(q),Z}function $8($,J){let Z=document.createElement("button");Z.className="pf-button",Z.type=$.submit===!0?"submit":"button",Z.textContent=K($.label,J);let q=$.variant??"default";if(Z.setAttribute("data-variant",q),W8(Z,q),$.size!=null)Z.setAttribute("data-size",$.size);if($.disabled===!0)Z.disabled=!0;if($.onClick!=null)Z.addEventListener("click",()=>{k($.onClick,b(J))});return Z}function J8($,J){let Z=_("div","pf-button-group");return Z.style.display="flex",Z.style.gap="8px",j($,Z,J),Z}function Z8($,J){let Z=_("div","pf-select-wrapper"),q=document.createElement("select");if(q.className="pf-select",$.name!=null)q.name=$.name;if(b0(q),$.placeholder!=null){let Y=document.createElement("option");Y.value="",Y.textContent=K($.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,{...b(J),scope:{...J.scope,$event:q.value}})})}return Z.appendChild(q),Z}function q8($,J){return _("span")}function U8($,J){let Z=_("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,{...b(J),scope:{...J.scope,$event:q.checked}})})}if(Z.appendChild(q),$.label!=null){let Q=_("span");Q.textContent=K($.label,J),Z.appendChild(Q)}return Z}function Q8($,J){let Z=_("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,{...b(J),scope:{...J.scope,$event:q.checked}})})}if(Z.appendChild(q),$.label!=null){let Q=_("span");Q.textContent=K($.label,J),Z.appendChild(Q)}return Z}function Y8($,J){let Z=_("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,{...b(J),scope:{...J.scope,$event:Number(q.value)}})})}return Z.appendChild(q),Z}function b0($){$.style.padding="8px 12px",$.style.fontSize="14px",$.style.width="100%",$.style.boxSizing="border-box"}function W8($,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 z0($){return(J,Z)=>{let q=_("div",$);return j(J,q,Z),q}}function Z0($){return(J,Z)=>{let q=_("span",$);return q.textContent=K(J.content,Z),q}}function N1(){let $=document.createElement("hr");return $.className="pf-separator",$.style.border="none",$.style.margin="4px 0",$}function H8($,J){let Z=_("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=K($.value,J),Z.appendChild(q),$.label!=null){let U=_("span","pf-radio-label");U.textContent=K($.label,J),Z.appendChild(U)}return Z}function M8($,J){let Z=_("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=K($.label,J),Q.style.fontWeight="500",Q.style.marginBottom="4px",Z.appendChild(Q)}j($,Z,J);let q=K($.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,b(J))}}),Z}function B8($,J){let Z=_("div","pf-combobox"),q=document.createElement("input");if(q.className="pf-combobox-input",q.type="text",q.name=K($.name,J),$.placeholder!=null)q.placeholder=K($.placeholder,J);if($.value!==void 0)q.value=K($.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=_("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",j($,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 H of Array.from(Y.querySelectorAll(".pf-combobox-option"))){let N=H.textContent.toLowerCase();H.style.display=N.includes(W)?"":"none"}});if($.onChange!=null)Z.addEventListener("pf-combobox-select",()=>{k($.onChange,{...b(J),scope:{...J.scope,$event:q.value}})});return Z.style.position="relative",Z.appendChild(q),Z.appendChild(Y),Z}function _8($,J){let Z=_("div","pf-combobox-option");return Z.style.padding="6px 12px",Z.style.cursor="pointer",Z.textContent=K($.label??$.value,J),Z.dataset.value=K($.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 N8($,J){let Z=_("div","pf-calendar"),q=document.createElement("input");if(q.type="date",q.name=K($.name,J),$.value!==void 0)q.value=K($.value,J);let U=q.name,Q=J.store.get(U);if(Q!=null)q.value=String(Q);if($.minDate!=null)q.min=K($.minDate,J);if($.maxDate!=null)q.max=K($.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,b(J))}),Z.appendChild(q),Z}function X8($,J){let Z=_("div","pf-datepicker"),q=document.createElement("input");if(q.type="date",q.name=K($.name,J),$.placeholder!=null)q.placeholder=K($.placeholder,J);if($.value!==void 0)q.value=K($.value,J);let U=q.name,Q=J.store.get(U);if(Q!=null)q.value=String(Q);if($.minDate!=null)q.min=K($.minDate,J);if($.maxDate!=null)q.max=K($.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,b(J))}),Z.appendChild(q),Z}function G8($,J){let Z=_("div","pf-choice-card");if(Z.style.padding="16px",Z.style.cursor="pointer",Z.style.transition="border-color 0.2s",Z.dataset.value=K($.value,J),$.selected===!0)Z.dataset.selected="true";if($.label!=null){let q=_("div","pf-choice-card-label");q.textContent=K($.label,J),q.style.fontWeight="600",Z.appendChild(q)}if($.description!=null){let q=_("div","pf-choice-card-description");q.textContent=K($.description,J),q.style.fontSize="14px",Z.appendChild(q)}if(j($,Z,J),$.onClick!=null)Z.addEventListener("click",()=>{k($.onClick,b(J))});return Z}function G1(){M("Tabs",z8),M("Tab",E8),M("Accordion",K8),M("AccordionItem",F8),M("Dialog",D8),M("Popover",L8),M("Tooltip",j8),M("HoverCard",T8),M("Carousel",P8)}function z8($,J){let Z=_("div","pf-tabs"),q=_("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 H=$.children[W],N=`pf-tab-${Math.random().toString(36).slice(2,8)}`,G=`pf-panel-${Math.random().toString(36).slice(2,8)}`,B=document.createElement("button");B.type="button",B.className="pf-tab-trigger",B.textContent=H.title??`Tab ${W+1}`,B.setAttribute("role","tab"),B.setAttribute("aria-selected",W===0?"true":"false"),B.setAttribute("aria-controls",G),B.id=N,B.tabIndex=W===0?0:-1,B.style.padding="8px 16px",B.style.border="none",B.style.background="none",B.style.cursor="pointer",B.style.borderBottom="2px solid transparent",B.style.marginBottom="-2px",B.style.fontSize="14px";let E=_("div","pf-tab-panel");if(E.style.display=W===0?"block":"none",E.setAttribute("role","tabpanel"),E.setAttribute("aria-labelledby",N),E.id=G,E.tabIndex=0,j(H,E,J),B.addEventListener("click",()=>{Y(W)}),W===0)B.classList.add("pf-tab-active"),B.style.fontWeight="600";Q.push(B),U.push(E),q.appendChild(B)}function Y(W){U.forEach((H)=>H.style.display="none"),Q.forEach((H)=>{H.style.borderBottomColor="transparent",H.style.fontWeight="normal",H.classList.remove("pf-tab-active"),H.setAttribute("aria-selected","false"),H.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 H=Q.indexOf(W.target);if(H<0)return;let N;if(W.key==="ArrowRight")N=(H+1)%Q.length;else if(W.key==="ArrowLeft")N=(H-1+Q.length)%Q.length;else if(W.key==="Home")N=0;else if(W.key==="End")N=Q.length-1;else return;W.preventDefault(),Y(N)}),Z.appendChild(q);for(let W of U)Z.appendChild(W);return Z}function E8($,J){let Z=_("div","pf-tab");return j($,Z,J),Z}function K8($,J){let Z=_("div","pf-accordion");return j($,Z,J),Z}function F8($,J){let Z=_("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=_("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",j($,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 D8($,J){let Z=_("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=_("h2","pf-dialog-title");Q.textContent=K($.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=_("p","pf-dialog-desc");Q.textContent=K($.description,J),q.appendChild(Q)}let U=_("div","pf-dialog-body");if(j($,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 L8($,J){let Z=_("div","pf-popover");Z.style.position="relative",Z.style.display="inline-block";let q=_("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=_("div","pf-popover-title");U.textContent=K($.title,J),U.style.fontWeight="600",U.style.marginBottom="4px",q.appendChild(U)}return j($,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 j8($,J){let Z=_("div","pf-tooltip");Z.style.position="relative",Z.style.display="inline-block";let q=`pf-tip-${Math.random().toString(36).slice(2,8)}`,U=_("div","pf-tooltip-content");return U.id=q,U.setAttribute("role","tooltip"),U.textContent=K($.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",j($,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 T8($,J){let Z=_("div","pf-hover-card");Z.style.position="relative",Z.style.display="inline-block";let q=_("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",j($,q,J),Z.addEventListener("mouseenter",()=>{q.style.display="block"}),Z.addEventListener("mouseleave",()=>{q.style.display="none"}),Z.appendChild(q),Z}function P8($,J){let Z=_("div","pf-carousel");Z.style.position="relative",Z.style.overflow="hidden",Z.setAttribute("role","region"),Z.setAttribute("aria-roledescription","carousel"),Z.setAttribute("aria-label",K($.label??"Carousel",J));let q=_("div","pf-carousel-track");q.style.display="flex",q.style.transition="transform 0.3s ease",j($,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 H=()=>{q.style.transform=`translateX(-${U*100}%)`};return Y.addEventListener("click",()=>{if(Q===0)return;U=Math.max(0,U-1),H()}),W.addEventListener("click",()=>{if(Q===0)return;U=Math.min(Q-1,U+1),H()}),Z.appendChild(q),Z.appendChild(Y),Z.appendChild(W),Z}function z1(){M("ForEach",V8),M("If",E1),M("Elif",O8),M("Else",I8),M("Condition",R8),M("Define",A8),M("Use",k8),M("Slot",f8)}function V8($,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],H={...J.scope,$item:W,$index:Y,...Q},N={...J,scope:H};if($.children)n($.children,Z,N)}return Z}function E1($,J){if(K1($.condition,J)){let q=document.createDocumentFragment();if($.children)n($.children,q,J);return q}return document.createDocumentFragment()}function O8($,J){return E1($,J)}function I8($,J){let Z=document.createDocumentFragment();if($.children)n($.children,Z,J);return Z}function K1($,J){if(!$)return!1;if(u($))return Boolean(x($,J.store,J.scope));return Boolean(J.store.get($))}function R8($,J){let Z=document.createDocumentFragment(),q=$.cases,U=$.else;if(q){for(let Q of q)if(K1(Q.when,J)){if(Q.children)n(Q.children,Z,J);return Z}}if(U)n(U,Z,J);return Z}function A8($,J){let Z=$.name;if(Z&&$.children)J.templates=J.templates??{},J.templates[Z]=$.children;return document.createDocumentFragment()}function k8($,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 H of U)Z.appendChild(w(H,W));return Z}function f8($,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 F1(){M("Alert",S8),M("AlertTitle",w8),M("AlertDescription",C8)}function S8($,J){let Z=_("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=_("span","pf-alert-icon");U.setAttribute("data-icon",$.icon),U.style.marginRight="8px",Z.appendChild(U)}return j($,Z,J),Z}function w8($,J){let Z=_("h5","pf-alert-title");return Z.textContent=K($.content,J),Z.style.fontWeight="600",Z.style.marginBottom="4px",Z}function C8($,J){let Z=_("p","pf-alert-description");return Z.textContent=K($.content,J),Z.style.fontSize="14px",Z}function D1(){M("Image",b8),M("Audio",y8),M("Video",m8),M("Embed",v8),M("Svg",g8),M("DropZone",u8),M("Mermaid",x8)}function b8($,J){let Z=document.createElement("img");if(Z.className="pf-image",Z.src=K($.src,J),$.alt!=null)Z.alt=K($.alt,J);if($.width!=null)Z.width=$.width;if($.height!=null)Z.height=$.height;return Z.style.maxWidth="100%",Z}function y8($,J){let Z=document.createElement("audio");return Z.className="pf-audio",Z.src=K($.src,J),Z.controls=!0,Z}function m8($,J){let Z=document.createElement("video");if(Z.className="pf-video",Z.src=K($.src,J),Z.controls=!0,$.width!=null)Z.width=$.width;if($.height!=null)Z.height=$.height;return Z.style.maxWidth="100%",Z}function v8($,J){let Z=_("div","pf-embed"),q=document.createElement("iframe");return q.src=K($.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 h8=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 g8($,J){let Z=_("div","pf-svg"),q=K($.content,J);if(!q.includes("<svg"))return Z;let Q=new DOMParser().parseFromString(q,"image/svg+xml").querySelector("svg");if(!Q)return Z;return L1(Q),Z.appendChild(document.importNode(Q,!0)),Z}function L1($){let J=Array.from($.children);for(let Z of J){if(!h8.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)}L1(Z)}}function u8($,J){let Z=_("div","pf-dropzone");return Z.style.padding="32px",Z.style.textAlign="center",Z.style.cursor="pointer",Z.textContent=K($.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 x8($,J){let Z=_("div","pf-mermaid");Z.setAttribute("data-mermaid","true");let q=K($.content,J);if(Z.textContent=q,typeof globalThis.mermaid<"u")Z.classList.add("mermaid"),Z.textContent=q;return Z}var K0=["#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 H="";if(q)H+=`<div class="pf-chart-tooltip-label">${E0(q)}</div>`;for(let L of U)H+='<div class="pf-chart-tooltip-row">',H+=`<span class="pf-chart-tooltip-dot" style="background:${E0(L.color)}"></span>`,H+=`<span>${E0(L.label)}:</span> <strong>${E0(String(L.value))}</strong>`,H+="</div>";Q.innerHTML=H;let N=Y.getBoundingClientRect(),G=W.getBoundingClientRect(),B=Y.viewBox.baseVal,E=N.width/(B.width||1),F=N.left-G.left+J*E,X=Q.offsetWidth||100,z=F+12;if(z+X>G.width)z=F-X-12;Q.style.left=`${Math.max(0,z)}px`,Q.style.top="4px",Q.classList.add("pf-visible")}function E0($){return $.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;")}function j1($,J,Z,q,U,Q,Y,W){let H=U.plotWidth/Z.length;for(let N=0;N<Z.length;N++){let G=U.plotLeft+N*H,B=document.createElementNS("http://www.w3.org/2000/svg","rect");B.setAttribute("x",String(G)),B.setAttribute("y",String(U.plotTop)),B.setAttribute("width",String(H)),B.setAttribute("height",String(U.plotHeight)),B.setAttribute("fill","transparent"),B.style.cursor="default";let E=Q?Z[N][Q]:void 0,F=E!=null?W?W(E):String(E):void 0,X=q.map((A,R)=>({label:A.label??A.dataKey,value:Y(Z[N][A.dataKey],A,R),color:A.color??K0[R%K0.length]})),z=G+H/2,L=()=>q0($,z,U.plotTop,F,X),V=()=>$.tooltip.classList.remove("pf-visible");B.addEventListener("mouseenter",L),B.addEventListener("mouseleave",V),B.addEventListener("touchstart",L,{passive:!0}),B.addEventListener("touchend",V,{passive:!0}),J.appendChild(B)}}function T1($,J,Z,q,U,Q,Y,W,H,N){let G=Z.length===1?U.plotWidth:U.plotWidth/(Z.length-1);for(let B=0;B<Z.length;B++){let E=Z.length===1?(U.plotLeft+U.plotRight)/2:U.plotLeft+B/(Z.length-1)*U.plotWidth,F=Z.length===1?U.plotLeft:E-G/2,X=Z.length===1?U.plotWidth:G,z=document.createElementNS("http://www.w3.org/2000/svg","rect");z.setAttribute("x",String(Math.max(U.plotLeft,F))),z.setAttribute("y",String(U.plotTop)),z.setAttribute("width",String(Math.min(X,U.plotRight-Math.max(U.plotLeft,F)))),z.setAttribute("height",String(U.plotHeight)),z.setAttribute("fill","transparent"),z.style.cursor="default";let L=Q?Z[B][Q]:void 0,V=L!=null?N?N(L):String(L):void 0,A=q.map((T,C)=>({label:T.label??T.dataKey,value:Y(Z[B][T.dataKey],T,C),color:T.color??K0[C%K0.length]})),R=()=>{if(q0($,E,U.plotTop,V,A),W)W.setAttribute("x1",String(E)),W.setAttribute("x2",String(E)),W.setAttribute("opacity","1");if(H)for(let T of H){for(let C of T)C.setAttribute("data-visible","false");T[B]?.setAttribute("data-visible","true")}},D=()=>{if($.tooltip.classList.remove("pf-visible"),W)W.setAttribute("opacity","0");if(H)for(let T of H)for(let C of T)C.setAttribute("data-visible","false")};z.addEventListener("mouseenter",R),z.addEventListener("mouseleave",D),z.addEventListener("touchstart",R,{passive:!0}),z.addEventListener("touchend",D,{passive:!0}),J.appendChild(z)}}function V1(){M("BarChart",c8),M("LineChart",P1),M("AreaChart",P1),M("PieChart",l8),M("RadarChart",y0),M("ScatterChart",y0),M("RadialChart",y0),M("Histogram",s8)}var s=["#3b82f6","#10b981","#f59e0b","#ef4444","#8b5cf6","#ec4899"],U0="var(--muted-foreground, #6b7280)",p8="var(--border, #e5e7eb)",m0="10";function O1($,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 I1($,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 R1($,J,Z,q,U){let Q=I1(Z);for(let Y of Q){let W=J.plotBottom-(Z>0?Y/Z*J.plotHeight:0),H=document.createElementNS("http://www.w3.org/2000/svg","text");if(H.setAttribute("x",String(J.plotLeft-6)),H.setAttribute("y",String(W+3)),H.setAttribute("text-anchor","end"),H.setAttribute("font-size",m0),H.setAttribute("fill",U0),H.textContent=v0(Y,U),$.appendChild(H),q&&Y>0){let N=document.createElementNS("http://www.w3.org/2000/svg","line");N.setAttribute("x1",String(J.plotLeft)),N.setAttribute("y1",String(W)),N.setAttribute("x2",String(J.plotRight)),N.setAttribute("y2",String(W)),N.setAttribute("stroke",p8),N.setAttribute("stroke-width","1"),N.setAttribute("stroke-dasharray","4 3"),$.appendChild(N)}}}function A1($,J,Z,q){let U=I1(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",m0),W.setAttribute("fill",U0),W.textContent=v0(Q,q),$.appendChild(W)}}function k1($,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",m0),W.setAttribute("fill",U0);let H=J[Y][Z];W.textContent=H==null?"":Q?Q(H):String(H),$.appendChild(W)}}function f1($,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=y(`{{ __v | ${J} }}`,{...Z,scope:{...Z.scope,__v:$}});return q==null?String($):String(q)}function v0($,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 S1($,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 v0(Number(q),Q)}}function c8($,J){let Z=_("div","pf-chart pf-bar-chart"),q=y($.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,H=$.showYAxisRight===!0,N=$.showTooltip!==!1,G=$.xAxis,B=$.tooltipXKey,E=$.xAxisFormat,F=$.tooltipXFormat,X=U.filter((I)=>I.yAxisId!=="right"),z=U.filter((I)=>I.yAxisId==="right"),L=H&&z.length>0,V=X.length>0?Math.max(...q.flatMap((I)=>X.map((O)=>Number(I[O.dataKey]??0))),1):1,A=L?Math.max(...q.flatMap((I)=>z.map((O)=>Number(I[O.dataKey]??0))),1):1,R=400,D=O1(R,Q,Y,L),T=D0(R,Q,"Bar");if(Y)R1(T,D,V,W,$.yAxisFormat);if(L)A1(T,D,A,$.yAxisRightFormat);f1(T,D);let C=D.plotWidth/q.length,d=C/(U.length+1);for(let I=0;I<q.length;I++)for(let O=0;O<U.length;O++){let f=U[O],p=q[I][f.dataKey];if(p===null||p===void 0)continue;let m=f.yAxisId==="right"?A:V,c=Number(p),l=Math.max(0,c/m*D.plotHeight),a=D.plotLeft+I*C+O*d+d/2,P=document.createElementNS("http://www.w3.org/2000/svg","rect");P.setAttribute("x",String(a)),P.setAttribute("y",String(D.plotBottom-l)),P.setAttribute("width",String(d*0.8)),P.setAttribute("height",String(l)),P.setAttribute("fill",f.color??s[O%s.length]),P.setAttribute("rx","2"),T.appendChild(P)}if(G){let I=E?(O)=>$0(O,E,J):void 0;k1(T,q,G,(O)=>{return D.plotLeft+O*C+C/2},D.plotBottom,I)}if(N){let I=F0(Z,T),O=S1(J,$.yAxisFormat,$.yAxisRightFormat);j1(I,T,q,U,D,B??G,O,F?(p)=>$0(p,F,J):void 0)}return h0(Z,U,$.showLegend),Z.appendChild(T),Z}function P1($,J){let Z=_("div",`pf-chart pf-${$.type.toLowerCase()}-chart`),q=y($.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,H=$.showYAxisRight===!0,N=$.showTooltip!==!1,G=$.xAxis,B=$.tooltipXKey,E=$.xAxisFormat,F=$.tooltipXFormat,X=U.filter((O)=>O.yAxisId!=="right"),z=U.filter((O)=>O.yAxisId==="right"),L=H&&z.length>0,V=X.length>0?Math.max(...q.flatMap((O)=>X.map((f)=>Number(O[f.dataKey]??0))),1):1,A=L?Math.max(...q.flatMap((O)=>z.map((f)=>Number(O[f.dataKey]??0))),1):1,R=400,D=O1(R,Q,Y,L),T=D0(R,Q,$.type==="AreaChart"?"Area":"Line"),C=$.type==="AreaChart";if(Y)R1(T,D,V,W,$.yAxisFormat);if(L)A1(T,D,A,$.yAxisRightFormat);f1(T,D);let d=[];for(let O=0;O<U.length;O++){let f=U[O],p=f.yAxisId==="right",i=p?A:V,m=f.color??s[O%s.length],c=q.map((P,S)=>{let v=P[f.dataKey],o=v===null||v===void 0,Y0=q.length===1?(D.plotLeft+D.plotRight)/2:D.plotLeft+S/(q.length-1)*D.plotWidth,s1=o?D.plotBottom:D.plotBottom-Number(v)/i*D.plotHeight;return{x:Y0,y:s1,isNull:o}});if(C){let P=[],S=()=>{if(P.length<2){P=[];return}let v=`M ${P[0].x},${D.plotBottom} `+P.map((Y0)=>`L ${Y0.x},${Y0.y}`).join(" ")+` L ${P[P.length-1].x},${D.plotBottom} Z`,o=document.createElementNS("http://www.w3.org/2000/svg","path");o.setAttribute("d",v),o.setAttribute("fill",m),o.setAttribute("opacity","0.15"),T.appendChild(o),P=[]};for(let v of c){if(v.isNull){S();continue}P.push(v)}S()}let l="";for(let P of c){if(P.isNull)continue;let S=c.indexOf(P),v=S===0||c[S-1].isNull;l+=`${v?"M":"L"} ${P.x},${P.y} `}if(l){let P=document.createElementNS("http://www.w3.org/2000/svg","path");if(P.setAttribute("d",l.trim()),P.setAttribute("fill","none"),P.setAttribute("stroke",m),P.setAttribute("stroke-width","2"),p)P.setAttribute("stroke-dasharray","6 3");T.appendChild(P)}let a=[];for(let P of c){let S=document.createElementNS("http://www.w3.org/2000/svg","circle");if(S.setAttribute("cx",String(P.x)),S.setAttribute("cy",String(P.y)),S.setAttribute("r","4"),S.setAttribute("fill",m),S.setAttribute("class","pf-data-dot"),S.setAttribute("data-visible","false"),S.style.pointerEvents="none",P.isNull)S.style.display="none";T.appendChild(S),a.push(S)}d.push(a)}let I=document.createElementNS("http://www.w3.org/2000/svg","line");if(I.setAttribute("class","pf-crosshair"),I.setAttribute("x1",String(D.plotLeft)),I.setAttribute("x2",String(D.plotLeft)),I.setAttribute("y1",String(D.plotTop)),I.setAttribute("y2",String(D.plotBottom)),I.setAttribute("stroke",U0),I.setAttribute("stroke-width","1"),I.setAttribute("stroke-dasharray","3 3"),I.setAttribute("opacity","0"),T.appendChild(I),G){let O=E?(f)=>$0(f,E,J):void 0;k1(T,q,G,(f)=>{return q.length===1?(D.plotLeft+D.plotRight)/2:D.plotLeft+f/(q.length-1)*D.plotWidth},D.plotBottom,O)}if(N){let O=F0(Z,T),f=S1(J,$.yAxisFormat,$.yAxisRightFormat);T1(O,T,q,U,D,B??G,f,I,d,F?(i)=>$0(i,F,J):void 0)}return h0(Z,U,$.showLegend),Z.appendChild(T),Z}function l8($,J){let Z=_("div","pf-chart pf-pie-chart"),q=y($.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 H=D0(Y,Y,"Pie"),N=Y/2,G=Y/2,B=Y/2-10,E=U[0].dataKey,F=$.xAxis,X=$.tooltipXKey,z=$.tooltipXFormat,L=q.map((D)=>Number(D[E]??0)),V=L.reduce((D,T)=>D+T,0);if(V===0)return Z.textContent="No chart data",Z.appendChild(H),Z;let A=W?F0(Z,H):void 0,R=-Math.PI/2;for(let D=0;D<L.length;D++){let T=L[D]/V*2*Math.PI,C=R+T,d=T>Math.PI?1:0,I=N+B*Math.cos(R),O=G+B*Math.sin(R),f=N+B*Math.cos(C),p=G+B*Math.sin(C),i=s[D%s.length],m=document.createElementNS("http://www.w3.org/2000/svg","path");if(m.setAttribute("d",`M ${N},${G} L ${I},${O} A ${B},${B} 0 ${d} 1 ${f},${p} Z`),m.setAttribute("fill",i),m.style.cursor="default",A){let c=X??F,l=c?q[D][c]:void 0,a=l!=null?z?$0(l,z,J):String(l):`Slice ${D+1}`,P=`${(L[D]/V*100).toFixed(1)}%`,S=R+T/2,v=N+B*0.6*Math.cos(S);m.addEventListener("mouseenter",()=>{q0(A,v,G,a,[{label:U[0].label??E,value:`${L[D]} (${P})`,color:i}])}),m.addEventListener("mouseleave",()=>{A.tooltip.classList.remove("pf-visible")}),m.addEventListener("touchstart",()=>{q0(A,v,G,a,[{label:U[0].label??E,value:`${L[D]} (${P})`,color:i}])},{passive:!0}),m.addEventListener("touchend",()=>{A.tooltip.classList.remove("pf-visible")},{passive:!0})}H.appendChild(m),R=C}return h0(Z,U,$.showLegend),Z.appendChild(H),Z}function y0($,J){let Z=_("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 D0($,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 h0($,J,Z){if(Z===!1||J.length<=1)return;let q=_("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=_("div","pf-chart-legend-item");Q.style.display="flex",Q.style.alignItems="center",Q.style.gap="4px";let Y=_("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=_("span");W.textContent=J[U].label??J[U].dataKey,Q.appendChild(Y),Q.appendChild(W),q.appendChild(Q)}$.appendChild(q)}function s8($,J){let Z=_("div","pf-chart pf-histogram"),q=y($.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],H=Math.min(...U),G=(Math.max(...U)-H)/Q||1,B=Array(Q).fill(0);for(let V of U){let A=Math.min(Math.floor((V-H)/G),Q-1);B[A]++}let E=Math.max(...B),F=300,X=Y,z=F/Q,L=D0(F,X,"Histogram");for(let V=0;V<Q;V++){let A=E>0?B[V]/E*X:0,R=document.createElementNS("http://www.w3.org/2000/svg","rect");R.setAttribute("x",String(V*z)),R.setAttribute("y",String(X-A)),R.setAttribute("width",String(z-1)),R.setAttribute("height",String(A)),R.setAttribute("fill",W),L.appendChild(R)}return Z.appendChild(L),Z}function w1(){M("Table",d8),M("TableHead",g0("thead")),M("TableBody",g0("tbody")),M("TableFooter",g0("tfoot")),M("TableRow",i8),M("TableHeader",r8),M("TableCell",n8),M("TableCaption",a8),M("ExpandableRow",o8)}function d8($,J){let Z=document.createElement("table");return Z.className="pf-table",Z.style.width="100%",Z.style.borderCollapse="collapse",j($,Z,J),Z}function g0($){return(J,Z)=>{let q=document.createElement($);return q.className=`pf-${$}`,j(J,q,Z),q}}function i8($,J){let Z=document.createElement("tr");return Z.className="pf-table-row",j($,Z,J),Z}function r8($,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=K($.content,J),Z}function n8($,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 j($,Z,J),Z}function a8($,J){let Z=document.createElement("caption");return Z.className="pf-table-caption",Z.style.padding="8px",Z.style.fontSize="14px",Z.textContent=K($.content,J),Z}function o8($,J){let Z=_("div","pf-expandable-row"),q=_("div","pf-expandable-row-summary");q.style.cursor="pointer",q.style.display="flex",q.style.alignItems="center",q.style.gap="8px";let U=_("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 H of Q)q.appendChild(w(H,J));let Y=_("div","pf-expandable-row-detail");Y.style.display="none",Y.style.paddingLeft="24px",j($,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 C1=!1;function L0(){if(C1)return;C1=!0,q1(),W1(),B1(),_1(),X1(),G1(),z1(),F1(),D1(),V1(),w1()}function b1($){return $.replace(/[^a-zA-Z0-9_-]/g,"")}function y1($){return $.replace(/[{}<>;]/g,"").replace(/\b(url|expression)\s*\(/gi,"")}function g1($,J){if(!J)return;if(J.light)for(let[Z,q]of Object.entries(J.light))$.style.setProperty(`--${b1(Z)}`,y1(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])=>` --${b1(Q)}: ${y1(Y)};`).join(`
6
+ `)}function h4($,J){let Z=document.createElement("kbd");return Z.className="pf-kbd",Z.textContent=K($.content,J),Z}function B1(){M("Card",g4),M("CardHeader",C0("pf-card-header")),M("CardTitle",M1("pf-card-title","h3")),M("CardDescription",M1("pf-card-description","p")),M("CardContent",C0("pf-card-content")),M("CardFooter",C0("pf-card-footer"))}function g4($,J){let Z=_("div","pf-card");return Z.style.overflow="hidden",j($,Z,J),Z}function C0($){return(J,Z)=>{let q=_("div",$);return q.style.padding="16px 24px",j(J,q,Z),q}}function M1($,J){return(Z,q)=>{let U=document.createElement(J);return U.className=$,U.textContent=K(Z.content,q),U}}function _1(){M("DataTable",u4),M("Badge",x4),M("Dot",p4),M("Metric",c4),M("Ring",l4),M("Progress",s4),M("Separator",d4),M("Loader",i4),M("Icon",r4),M("Sparkline",n4)}function u4($,J){let Z=_("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,J),Y=$.rowKey,W=$.selected,H=document.createElement("thead"),N=document.createElement("tr");for(let B of U){let E=document.createElement("th");E.className="pf-datatable-th",E.textContent=B.header??B.key,E.style.padding="8px 12px",E.style.textAlign="left",N.appendChild(E)}H.appendChild(N),q.appendChild(H);let G=document.createElement("tbody");if(Array.isArray(Q)){let B=W!=null?y(W,J):void 0;for(let E of Q){let F=document.createElement("tr");F.className="pf-datatable-row";let X=E;if(Y&&B!=null&&X[Y]!=null&&String(X[Y])===String(B))F.classList.add("pf-datatable-row-selected");if($.onRowClick!=null&&Y)F.style.cursor="pointer",F.addEventListener("click",()=>{let z={...J.scope,$item:X,$index:Q.indexOf(E)},L=b({...J,scope:z});k($.onRowClick,L)});for(let z of U){let L=document.createElement("td");L.className="pf-datatable-td";let O;if(z.accessor)O=y(`{{ $item.${z.accessor} }}`,{...J,scope:{...J.scope,$item:X}});else if(O=X[z.key],z.format&&O!=null)O=y(`{{ __fmtVal | ${z.format} }}`,{...J,scope:{...J.scope,__fmtVal:O}});L.textContent=O==null?"":String(O),L.style.padding="8px 12px",F.appendChild(L)}G.appendChild(F)}}if(q.appendChild(G),$.search===!0){let B=document.createElement("input");B.type="text",B.placeholder="Search...",B.className="pf-datatable-search",B.style.marginBottom="8px",B.style.padding="6px 12px",B.style.width="100%",B.style.boxSizing="border-box",B.addEventListener("input",()=>{let E=B.value.toLowerCase(),F=Array.from(G.querySelectorAll("tr"));for(let X of F){let z=X.textContent.toLowerCase();X.style.display=z.includes(E)?"":"none"}}),Z.appendChild(B)}return Z.appendChild(q),Z}function x4($,J){let Z=_("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=K($.label??$.content,J),a4(Z,q),Z}function p4($,J){let Z=_("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 c4($,J){let Z=_("div","pf-metric"),q=_("div","pf-metric-label");q.textContent=K($.label,J),q.style.fontSize="14px",Z.appendChild(q);let U=_("div","pf-metric-value");if(U.textContent=K($.value,J),U.style.fontSize="28px",U.style.fontWeight="700",Z.appendChild(U),$.delta!=null){let Q=_("span","pf-metric-delta");Q.textContent=K($.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=_("div","pf-metric-desc");Q.textContent=K($.description,J),Q.style.fontSize="12px",Z.appendChild(Q)}return Z}function l4($,J){let Z=_("div","pf-ring"),q=$.size??80,U=$.thickness??8,Q=Number(y($.value,J)??0),Y=Math.max(0,Math.min(100,Q)),W=(q-U)/2,H=2*Math.PI*W,N=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 B=document.createElementNS("http://www.w3.org/2000/svg","circle");B.setAttribute("cx",String(q/2)),B.setAttribute("cy",String(q/2)),B.setAttribute("r",String(W)),B.setAttribute("fill","none"),B.setAttribute("stroke","var(--muted, #e5e7eb)"),B.setAttribute("stroke-width",String(U));let E=document.createElementNS("http://www.w3.org/2000/svg","circle");if(E.setAttribute("cx",String(q/2)),E.setAttribute("cy",String(q/2)),E.setAttribute("r",String(W)),E.setAttribute("fill","none"),E.setAttribute("stroke","var(--primary, #3b82f6)"),E.setAttribute("stroke-width",String(U)),E.setAttribute("stroke-dasharray",String(H)),E.setAttribute("stroke-dashoffset",String(N)),E.setAttribute("stroke-linecap","round"),E.style.transform="rotate(-90deg)",E.style.transformOrigin="center",G.appendChild(B),G.appendChild(E),Z.appendChild(G),$.label!=null){let F=_("div","pf-ring-label");F.textContent=K($.label,J),F.style.textAlign="center",F.style.fontSize="12px",Z.appendChild(F)}return Z}function s4($,J){let Z=_("div","pf-progress");Z.setAttribute("role","progressbar");let q=Number(y($.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=_("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 d4($,J){let Z=document.createElement("hr");return Z.className="pf-separator",Z.style.border="none",Z.style.margin="8px 0",Z}function i4($,J){let Z=_("div","pf-loader");return Z.textContent="⏳",Z.style.display="flex",Z.style.justifyContent="center",Z.style.padding="16px",Z}function r4($,J){let Z=_("span","pf-icon");return Z.setAttribute("data-icon",K($.name??$.content,J)),Z}function n4($,J){let Z=_("div","pf-sparkline"),q=$.data??[];if(q.length===0)return Z;let U=120,Q=32,Y=Math.max(...q),W=Math.min(...q),H=Y-W||1,N=document.createElementNS("http://www.w3.org/2000/svg","svg");N.setAttribute("width",String(U)),N.setAttribute("height",String(Q)),N.setAttribute("viewBox",`0 0 ${U} ${Q}`);let G=q.length>1?q.length-1:1,B=q.map((F,X)=>{let z=X/G*U,L=Q-(F-W)/H*(Q-4)-2;return`${z},${L}`}).join(" "),E=document.createElementNS("http://www.w3.org/2000/svg","polyline");return E.setAttribute("points",B),E.setAttribute("fill","none"),E.setAttribute("stroke","var(--primary, #3b82f6)"),E.setAttribute("stroke-width","1.5"),N.appendChild(E),Z.appendChild(N),Z}function a4($,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 X1(){M("Form",o4),M("Input",t4),M("Textarea",e4),M("Button",$8),M("ButtonGroup",J8),M("Select",Z8),M("SelectOption",q8),M("SelectGroup",z0("pf-select-group")),M("SelectLabel",Z0("pf-select-label")),M("SelectSeparator",N1),M("Checkbox",U8),M("Switch",Q8),M("Slider",Y8),M("Radio",H8),M("RadioGroup",M8),M("Combobox",B8),M("ComboboxOption",_8),M("ComboboxGroup",z0("pf-combobox-group")),M("ComboboxLabel",Z0("pf-combobox-label")),M("ComboboxSeparator",N1),M("Calendar",N8),M("DatePicker",X8),M("Field",z0("pf-field")),M("FieldTitle",Z0("pf-field-title")),M("FieldDescription",Z0("pf-field-description")),M("FieldContent",z0("pf-field-content")),M("FieldError",Z0("pf-field-error")),M("ChoiceCard",G8)}function o4($,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=b(J);Y.scope={...J.scope,...Q},k($.onSubmit,Y)}}),j($,Z,J),Z}function t4($,J){let Z=_("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=K($.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=K($.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,{...b(J),scope:{...J.scope,$event:q.value}})})}return b0(q),Z.appendChild(q),Z}function e4($,J){let Z=_("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,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,{...b(J),scope:{...J.scope,$event:q.value}})})}return b0(q),Z.appendChild(q),Z}function $8($,J){let Z=document.createElement("button");Z.className="pf-button",Z.type=$.submit===!0?"submit":"button",Z.textContent=K($.label,J);let q=$.variant??"default";if(Z.setAttribute("data-variant",q),W8(Z,q),$.size!=null)Z.setAttribute("data-size",$.size);if($.disabled===!0)Z.disabled=!0;if($.onClick!=null)Z.addEventListener("click",()=>{k($.onClick,b(J))});return Z}function J8($,J){let Z=_("div","pf-button-group");return Z.style.display="flex",Z.style.gap="8px",j($,Z,J),Z}function Z8($,J){let Z=_("div","pf-select-wrapper"),q=document.createElement("select");if(q.className="pf-select",$.name!=null)q.name=$.name;if(b0(q),$.placeholder!=null){let Y=document.createElement("option");Y.value="",Y.textContent=K($.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,{...b(J),scope:{...J.scope,$event:q.value}})})}return Z.appendChild(q),Z}function q8($,J){return _("span")}function U8($,J){let Z=_("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,{...b(J),scope:{...J.scope,$event:q.checked}})})}if(Z.appendChild(q),$.label!=null){let Q=_("span");Q.textContent=K($.label,J),Z.appendChild(Q)}return Z}function Q8($,J){let Z=_("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,{...b(J),scope:{...J.scope,$event:q.checked}})})}if(Z.appendChild(q),$.label!=null){let Q=_("span");Q.textContent=K($.label,J),Z.appendChild(Q)}return Z}function Y8($,J){let Z=_("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,{...b(J),scope:{...J.scope,$event:Number(q.value)}})})}return Z.appendChild(q),Z}function b0($){$.style.padding="8px 12px",$.style.fontSize="14px",$.style.width="100%",$.style.boxSizing="border-box"}function W8($,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 z0($){return(J,Z)=>{let q=_("div",$);return j(J,q,Z),q}}function Z0($){return(J,Z)=>{let q=_("span",$);return q.textContent=K(J.content,Z),q}}function N1(){let $=document.createElement("hr");return $.className="pf-separator",$.style.border="none",$.style.margin="4px 0",$}function H8($,J){let Z=_("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=K($.value,J),Z.appendChild(q),$.label!=null){let U=_("span","pf-radio-label");U.textContent=K($.label,J),Z.appendChild(U)}return Z}function M8($,J){let Z=_("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=K($.label,J),Q.style.fontWeight="500",Q.style.marginBottom="4px",Z.appendChild(Q)}j($,Z,J);let q=K($.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,b(J))}}),Z}function B8($,J){let Z=_("div","pf-combobox"),q=document.createElement("input");if(q.className="pf-combobox-input",q.type="text",q.name=K($.name,J),$.placeholder!=null)q.placeholder=K($.placeholder,J);if($.value!==void 0)q.value=K($.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=_("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",j($,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 H of Array.from(Y.querySelectorAll(".pf-combobox-option"))){let N=H.textContent.toLowerCase();H.style.display=N.includes(W)?"":"none"}});if($.onChange!=null)Z.addEventListener("pf-combobox-select",()=>{k($.onChange,{...b(J),scope:{...J.scope,$event:q.value}})});return Z.style.position="relative",Z.appendChild(q),Z.appendChild(Y),Z}function _8($,J){let Z=_("div","pf-combobox-option");return Z.style.padding="6px 12px",Z.style.cursor="pointer",Z.textContent=K($.label??$.value,J),Z.dataset.value=K($.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 N8($,J){let Z=_("div","pf-calendar"),q=document.createElement("input");if(q.type="date",q.name=K($.name,J),$.value!==void 0)q.value=K($.value,J);let U=q.name,Q=J.store.get(U);if(Q!=null)q.value=String(Q);if($.minDate!=null)q.min=K($.minDate,J);if($.maxDate!=null)q.max=K($.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,b(J))}),Z.appendChild(q),Z}function X8($,J){let Z=_("div","pf-datepicker"),q=document.createElement("input");if(q.type="date",q.name=K($.name,J),$.placeholder!=null)q.placeholder=K($.placeholder,J);if($.value!==void 0)q.value=K($.value,J);let U=q.name,Q=J.store.get(U);if(Q!=null)q.value=String(Q);if($.minDate!=null)q.min=K($.minDate,J);if($.maxDate!=null)q.max=K($.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,b(J))}),Z.appendChild(q),Z}function G8($,J){let Z=_("div","pf-choice-card");if(Z.style.padding="16px",Z.style.cursor="pointer",Z.style.transition="border-color 0.2s",Z.dataset.value=K($.value,J),$.selected===!0)Z.dataset.selected="true";if($.label!=null){let q=_("div","pf-choice-card-label");q.textContent=K($.label,J),q.style.fontWeight="600",Z.appendChild(q)}if($.description!=null){let q=_("div","pf-choice-card-description");q.textContent=K($.description,J),q.style.fontSize="14px",Z.appendChild(q)}if(j($,Z,J),$.onClick!=null)Z.addEventListener("click",()=>{k($.onClick,b(J))});return Z}function G1(){M("Tabs",z8),M("Tab",E8),M("Accordion",K8),M("AccordionItem",F8),M("Dialog",D8),M("Popover",L8),M("Tooltip",j8),M("HoverCard",P8),M("Carousel",V8)}function z8($,J){let Z=_("div","pf-tabs"),q=_("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 H=$.children[W],N=`pf-tab-${Math.random().toString(36).slice(2,8)}`,G=`pf-panel-${Math.random().toString(36).slice(2,8)}`,B=document.createElement("button");B.type="button",B.className="pf-tab-trigger",B.textContent=H.title??`Tab ${W+1}`,B.setAttribute("role","tab"),B.setAttribute("aria-selected",W===0?"true":"false"),B.setAttribute("aria-controls",G),B.id=N,B.tabIndex=W===0?0:-1,B.style.padding="8px 16px",B.style.border="none",B.style.background="none",B.style.cursor="pointer",B.style.borderBottom="2px solid transparent",B.style.marginBottom="-2px",B.style.fontSize="14px";let E=_("div","pf-tab-panel");if(E.style.display=W===0?"block":"none",E.setAttribute("role","tabpanel"),E.setAttribute("aria-labelledby",N),E.id=G,E.tabIndex=0,j(H,E,J),B.addEventListener("click",()=>{Y(W)}),W===0)B.classList.add("pf-tab-active"),B.style.fontWeight="600";Q.push(B),U.push(E),q.appendChild(B)}function Y(W){U.forEach((H)=>H.style.display="none"),Q.forEach((H)=>{H.style.borderBottomColor="transparent",H.style.fontWeight="normal",H.classList.remove("pf-tab-active"),H.setAttribute("aria-selected","false"),H.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 H=Q.indexOf(W.target);if(H<0)return;let N;if(W.key==="ArrowRight")N=(H+1)%Q.length;else if(W.key==="ArrowLeft")N=(H-1+Q.length)%Q.length;else if(W.key==="Home")N=0;else if(W.key==="End")N=Q.length-1;else return;W.preventDefault(),Y(N)}),Z.appendChild(q);for(let W of U)Z.appendChild(W);return Z}function E8($,J){let Z=_("div","pf-tab");return j($,Z,J),Z}function K8($,J){let Z=_("div","pf-accordion");return j($,Z,J),Z}function F8($,J){let Z=_("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=_("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",j($,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 D8($,J){let Z=_("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=_("h2","pf-dialog-title");Q.textContent=K($.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=_("p","pf-dialog-desc");Q.textContent=K($.description,J),q.appendChild(Q)}let U=_("div","pf-dialog-body");if(j($,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 L8($,J){let Z=_("div","pf-popover");Z.style.position="relative",Z.style.display="inline-block";let q=_("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=_("div","pf-popover-title");U.textContent=K($.title,J),U.style.fontWeight="600",U.style.marginBottom="4px",q.appendChild(U)}return j($,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 j8($,J){let Z=_("div","pf-tooltip");Z.style.position="relative",Z.style.display="inline-block";let q=`pf-tip-${Math.random().toString(36).slice(2,8)}`,U=_("div","pf-tooltip-content");return U.id=q,U.setAttribute("role","tooltip"),U.textContent=K($.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",j($,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 P8($,J){let Z=_("div","pf-hover-card");Z.style.position="relative",Z.style.display="inline-block";let q=_("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",j($,q,J),Z.addEventListener("mouseenter",()=>{q.style.display="block"}),Z.addEventListener("mouseleave",()=>{q.style.display="none"}),Z.appendChild(q),Z}function V8($,J){let Z=_("div","pf-carousel");Z.style.position="relative",Z.style.overflow="hidden",Z.setAttribute("role","region"),Z.setAttribute("aria-roledescription","carousel"),Z.setAttribute("aria-label",K($.label??"Carousel",J));let q=_("div","pf-carousel-track");q.style.display="flex",q.style.transition="transform 0.3s ease",j($,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 H=()=>{q.style.transform=`translateX(-${U*100}%)`};return Y.addEventListener("click",()=>{if(Q===0)return;U=Math.max(0,U-1),H()}),W.addEventListener("click",()=>{if(Q===0)return;U=Math.min(Q-1,U+1),H()}),Z.appendChild(q),Z.appendChild(Y),Z.appendChild(W),Z}function z1(){M("ForEach",O8),M("If",E1),M("Elif",T8),M("Else",I8),M("Condition",R8),M("Define",A8),M("Use",k8),M("Slot",f8)}function O8($,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],H={...J.scope,$item:W,$index:Y,...Q},N={...J,scope:H};if($.children)n($.children,Z,N)}return Z}function E1($,J){if(K1($.condition,J)){let q=document.createDocumentFragment();if($.children)n($.children,q,J);return q}return document.createDocumentFragment()}function T8($,J){return E1($,J)}function I8($,J){let Z=document.createDocumentFragment();if($.children)n($.children,Z,J);return Z}function K1($,J){if(!$)return!1;if(u($))return Boolean(x($,J.store,J.scope));return Boolean(J.store.get($))}function R8($,J){let Z=document.createDocumentFragment(),q=$.cases,U=$.else;if(q){for(let Q of q)if(K1(Q.when,J)){if(Q.children)n(Q.children,Z,J);return Z}}if(U)n(U,Z,J);return Z}function A8($,J){let Z=$.name;if(Z&&$.children)J.templates=J.templates??{},J.templates[Z]=$.children;return document.createDocumentFragment()}function k8($,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 H of U)Z.appendChild(w(H,W));return Z}function f8($,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 F1(){M("Alert",S8),M("AlertTitle",w8),M("AlertDescription",C8)}function S8($,J){let Z=_("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=_("span","pf-alert-icon");U.setAttribute("data-icon",$.icon),U.style.marginRight="8px",Z.appendChild(U)}return j($,Z,J),Z}function w8($,J){let Z=_("h5","pf-alert-title");return Z.textContent=K($.content,J),Z.style.fontWeight="600",Z.style.marginBottom="4px",Z}function C8($,J){let Z=_("p","pf-alert-description");return Z.textContent=K($.content,J),Z.style.fontSize="14px",Z}function D1(){M("Image",b8),M("Audio",y8),M("Video",m8),M("Embed",v8),M("Svg",g8),M("DropZone",u8),M("Mermaid",x8)}function b8($,J){let Z=document.createElement("img");if(Z.className="pf-image",Z.src=K($.src,J),$.alt!=null)Z.alt=K($.alt,J);if($.width!=null)Z.width=$.width;if($.height!=null)Z.height=$.height;return Z.style.maxWidth="100%",Z}function y8($,J){let Z=document.createElement("audio");return Z.className="pf-audio",Z.src=K($.src,J),Z.controls=!0,Z}function m8($,J){let Z=document.createElement("video");if(Z.className="pf-video",Z.src=K($.src,J),Z.controls=!0,$.width!=null)Z.width=$.width;if($.height!=null)Z.height=$.height;return Z.style.maxWidth="100%",Z}function v8($,J){let Z=_("div","pf-embed"),q=document.createElement("iframe");return q.src=K($.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 h8=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 g8($,J){let Z=_("div","pf-svg"),q=K($.content,J);if(!q.includes("<svg"))return Z;let Q=new DOMParser().parseFromString(q,"image/svg+xml").querySelector("svg");if(!Q)return Z;return L1(Q),Z.appendChild(document.importNode(Q,!0)),Z}function L1($){let J=Array.from($.children);for(let Z of J){if(!h8.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)}L1(Z)}}function u8($,J){let Z=_("div","pf-dropzone");return Z.style.padding="32px",Z.style.textAlign="center",Z.style.cursor="pointer",Z.textContent=K($.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 x8($,J){let Z=_("div","pf-mermaid");Z.setAttribute("data-mermaid","true");let q=K($.content,J);if(Z.textContent=q,typeof globalThis.mermaid<"u")Z.classList.add("mermaid"),Z.textContent=q;return Z}var K0=["#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 H="";if(q)H+=`<div class="pf-chart-tooltip-label">${E0(q)}</div>`;for(let L of U)H+='<div class="pf-chart-tooltip-row">',H+=`<span class="pf-chart-tooltip-dot" style="background:${E0(L.color)}"></span>`,H+=`<span>${E0(L.label)}:</span> <strong>${E0(String(L.value))}</strong>`,H+="</div>";Q.innerHTML=H;let N=Y.getBoundingClientRect(),G=W.getBoundingClientRect(),B=Y.viewBox.baseVal,E=N.width/(B.width||1),F=N.left-G.left+J*E,X=Q.offsetWidth||100,z=F+12;if(z+X>G.width)z=F-X-12;Q.style.left=`${Math.max(0,z)}px`,Q.style.top="4px",Q.classList.add("pf-visible")}function E0($){return $.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;")}function j1($,J,Z,q,U,Q,Y,W){let H=U.plotWidth/Z.length;for(let N=0;N<Z.length;N++){let G=U.plotLeft+N*H,B=document.createElementNS("http://www.w3.org/2000/svg","rect");B.setAttribute("x",String(G)),B.setAttribute("y",String(U.plotTop)),B.setAttribute("width",String(H)),B.setAttribute("height",String(U.plotHeight)),B.setAttribute("fill","transparent"),B.style.cursor="default";let E=Q?Z[N][Q]:void 0,F=E!=null?W?W(E):String(E):void 0,X=q.map((A,R)=>({label:A.label??A.dataKey,value:Y(Z[N][A.dataKey],A,R),color:A.color??K0[R%K0.length]})),z=G+H/2,L=()=>q0($,z,U.plotTop,F,X),O=()=>$.tooltip.classList.remove("pf-visible");B.addEventListener("mouseenter",L),B.addEventListener("mouseleave",O),B.addEventListener("touchstart",L,{passive:!0}),B.addEventListener("touchend",O,{passive:!0}),J.appendChild(B)}}function P1($,J,Z,q,U,Q,Y,W,H,N){let G=Z.length===1?U.plotWidth:U.plotWidth/(Z.length-1);for(let B=0;B<Z.length;B++){let E=Z.length===1?(U.plotLeft+U.plotRight)/2:U.plotLeft+B/(Z.length-1)*U.plotWidth,F=Z.length===1?U.plotLeft:E-G/2,X=Z.length===1?U.plotWidth:G,z=document.createElementNS("http://www.w3.org/2000/svg","rect");z.setAttribute("x",String(Math.max(U.plotLeft,F))),z.setAttribute("y",String(U.plotTop)),z.setAttribute("width",String(Math.min(X,U.plotRight-Math.max(U.plotLeft,F)))),z.setAttribute("height",String(U.plotHeight)),z.setAttribute("fill","transparent"),z.style.cursor="default";let L=Q?Z[B][Q]:void 0,O=L!=null?N?N(L):String(L):void 0,A=q.map((P,C)=>({label:P.label??P.dataKey,value:Y(Z[B][P.dataKey],P,C),color:P.color??K0[C%K0.length]})),R=()=>{if(q0($,E,U.plotTop,O,A),W)W.setAttribute("x1",String(E)),W.setAttribute("x2",String(E)),W.setAttribute("opacity","1");if(H)for(let P of H){for(let C of P)C.setAttribute("data-visible","false");P[B]?.setAttribute("data-visible","true")}},D=()=>{if($.tooltip.classList.remove("pf-visible"),W)W.setAttribute("opacity","0");if(H)for(let P of H)for(let C of P)C.setAttribute("data-visible","false")};z.addEventListener("mouseenter",R),z.addEventListener("mouseleave",D),z.addEventListener("touchstart",R,{passive:!0}),z.addEventListener("touchend",D,{passive:!0}),J.appendChild(z)}}function O1(){M("BarChart",c8),M("LineChart",V1),M("AreaChart",V1),M("PieChart",l8),M("RadarChart",y0),M("ScatterChart",y0),M("RadialChart",y0),M("Histogram",s8)}var s=["#3b82f6","#10b981","#f59e0b","#ef4444","#8b5cf6","#ec4899"],U0="var(--muted-foreground, #6b7280)",p8="var(--border, #e5e7eb)",m0="10";function T1($,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 I1($,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 R1($,J,Z,q,U){let Q=I1(Z);for(let Y of Q){let W=J.plotBottom-(Z>0?Y/Z*J.plotHeight:0),H=document.createElementNS("http://www.w3.org/2000/svg","text");if(H.setAttribute("x",String(J.plotLeft-6)),H.setAttribute("y",String(W+3)),H.setAttribute("text-anchor","end"),H.setAttribute("font-size",m0),H.setAttribute("fill",U0),H.textContent=v0(Y,U),$.appendChild(H),q&&Y>0){let N=document.createElementNS("http://www.w3.org/2000/svg","line");N.setAttribute("x1",String(J.plotLeft)),N.setAttribute("y1",String(W)),N.setAttribute("x2",String(J.plotRight)),N.setAttribute("y2",String(W)),N.setAttribute("stroke",p8),N.setAttribute("stroke-width","1"),N.setAttribute("stroke-dasharray","4 3"),$.appendChild(N)}}}function A1($,J,Z,q){let U=I1(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",m0),W.setAttribute("fill",U0),W.textContent=v0(Q,q),$.appendChild(W)}}function k1($,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",m0),W.setAttribute("fill",U0);let H=J[Y][Z];W.textContent=H==null?"":Q?Q(H):String(H),$.appendChild(W)}}function f1($,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=y(`{{ __v | ${J} }}`,{...Z,scope:{...Z.scope,__v:$}});return q==null?String($):String(q)}function v0($,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 S1($,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 v0(Number(q),Q)}}function c8($,J){let Z=_("div","pf-chart pf-bar-chart"),q=y($.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,H=$.showYAxisRight===!0,N=$.showTooltip!==!1,G=$.xAxis,B=$.tooltipXKey,E=$.xAxisFormat,F=$.tooltipXFormat,X=U.filter((I)=>I.yAxisId!=="right"),z=U.filter((I)=>I.yAxisId==="right"),L=H&&z.length>0,O=X.length>0?Math.max(...q.flatMap((I)=>X.map((T)=>Number(I[T.dataKey]??0))),1):1,A=L?Math.max(...q.flatMap((I)=>z.map((T)=>Number(I[T.dataKey]??0))),1):1,R=400,D=T1(R,Q,Y,L),P=D0(R,Q,"Bar");if(Y)R1(P,D,O,W,$.yAxisFormat);if(L)A1(P,D,A,$.yAxisRightFormat);f1(P,D);let C=D.plotWidth/q.length,d=C/(U.length+1);for(let I=0;I<q.length;I++)for(let T=0;T<U.length;T++){let f=U[T],p=q[I][f.dataKey];if(p===null||p===void 0)continue;let m=f.yAxisId==="right"?A:O,c=Number(p),l=Math.max(0,c/m*D.plotHeight),a=D.plotLeft+I*C+T*d+d/2,V=document.createElementNS("http://www.w3.org/2000/svg","rect");V.setAttribute("x",String(a)),V.setAttribute("y",String(D.plotBottom-l)),V.setAttribute("width",String(d*0.8)),V.setAttribute("height",String(l)),V.setAttribute("fill",f.color??s[T%s.length]),V.setAttribute("rx","2"),P.appendChild(V)}if(G){let I=E?(T)=>$0(T,E,J):void 0;k1(P,q,G,(T)=>{return D.plotLeft+T*C+C/2},D.plotBottom,I)}if(N){let I=F0(Z,P),T=S1(J,$.yAxisFormat,$.yAxisRightFormat);j1(I,P,q,U,D,B??G,T,F?(p)=>$0(p,F,J):void 0)}return h0(Z,U,$.showLegend),Z.appendChild(P),Z}function V1($,J){let Z=_("div",`pf-chart pf-${$.type.toLowerCase()}-chart`),q=y($.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,H=$.showYAxisRight===!0,N=$.showTooltip!==!1,G=$.xAxis,B=$.tooltipXKey,E=$.xAxisFormat,F=$.tooltipXFormat,X=U.filter((T)=>T.yAxisId!=="right"),z=U.filter((T)=>T.yAxisId==="right"),L=H&&z.length>0,O=X.length>0?Math.max(...q.flatMap((T)=>X.map((f)=>Number(T[f.dataKey]??0))),1):1,A=L?Math.max(...q.flatMap((T)=>z.map((f)=>Number(T[f.dataKey]??0))),1):1,R=400,D=T1(R,Q,Y,L),P=D0(R,Q,$.type==="AreaChart"?"Area":"Line"),C=$.type==="AreaChart";if(Y)R1(P,D,O,W,$.yAxisFormat);if(L)A1(P,D,A,$.yAxisRightFormat);f1(P,D);let d=[];for(let T=0;T<U.length;T++){let f=U[T],p=f.yAxisId==="right",i=p?A:O,m=f.color??s[T%s.length],c=q.map((V,S)=>{let v=V[f.dataKey],o=v===null||v===void 0,Y0=q.length===1?(D.plotLeft+D.plotRight)/2:D.plotLeft+S/(q.length-1)*D.plotWidth,s1=o?D.plotBottom:D.plotBottom-Number(v)/i*D.plotHeight;return{x:Y0,y:s1,isNull:o}});if(C){let V=[],S=()=>{if(V.length<2){V=[];return}let v=`M ${V[0].x},${D.plotBottom} `+V.map((Y0)=>`L ${Y0.x},${Y0.y}`).join(" ")+` L ${V[V.length-1].x},${D.plotBottom} Z`,o=document.createElementNS("http://www.w3.org/2000/svg","path");o.setAttribute("d",v),o.setAttribute("fill",m),o.setAttribute("opacity","0.15"),P.appendChild(o),V=[]};for(let v of c){if(v.isNull){S();continue}V.push(v)}S()}let l="";for(let V of c){if(V.isNull)continue;let S=c.indexOf(V),v=S===0||c[S-1].isNull;l+=`${v?"M":"L"} ${V.x},${V.y} `}if(l){let V=document.createElementNS("http://www.w3.org/2000/svg","path");if(V.setAttribute("d",l.trim()),V.setAttribute("fill","none"),V.setAttribute("stroke",m),V.setAttribute("stroke-width","2"),p)V.setAttribute("stroke-dasharray","6 3");P.appendChild(V)}let a=[];for(let V of c){let S=document.createElementNS("http://www.w3.org/2000/svg","circle");if(S.setAttribute("cx",String(V.x)),S.setAttribute("cy",String(V.y)),S.setAttribute("r","4"),S.setAttribute("fill",m),S.setAttribute("class","pf-data-dot"),S.setAttribute("data-visible","false"),S.style.pointerEvents="none",V.isNull)S.style.display="none";P.appendChild(S),a.push(S)}d.push(a)}let I=document.createElementNS("http://www.w3.org/2000/svg","line");if(I.setAttribute("class","pf-crosshair"),I.setAttribute("x1",String(D.plotLeft)),I.setAttribute("x2",String(D.plotLeft)),I.setAttribute("y1",String(D.plotTop)),I.setAttribute("y2",String(D.plotBottom)),I.setAttribute("stroke",U0),I.setAttribute("stroke-width","1"),I.setAttribute("stroke-dasharray","3 3"),I.setAttribute("opacity","0"),P.appendChild(I),G){let T=E?(f)=>$0(f,E,J):void 0;k1(P,q,G,(f)=>{return q.length===1?(D.plotLeft+D.plotRight)/2:D.plotLeft+f/(q.length-1)*D.plotWidth},D.plotBottom,T)}if(N){let T=F0(Z,P),f=S1(J,$.yAxisFormat,$.yAxisRightFormat);P1(T,P,q,U,D,B??G,f,I,d,F?(i)=>$0(i,F,J):void 0)}return h0(Z,U,$.showLegend),Z.appendChild(P),Z}function l8($,J){let Z=_("div","pf-chart pf-pie-chart"),q=y($.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 H=D0(Y,Y,"Pie"),N=Y/2,G=Y/2,B=Y/2-10,E=U[0].dataKey,F=$.xAxis,X=$.tooltipXKey,z=$.tooltipXFormat,L=q.map((D)=>Number(D[E]??0)),O=L.reduce((D,P)=>D+P,0);if(O===0)return Z.textContent="No chart data",Z.appendChild(H),Z;let A=W?F0(Z,H):void 0,R=-Math.PI/2;for(let D=0;D<L.length;D++){let P=L[D]/O*2*Math.PI,C=R+P,d=P>Math.PI?1:0,I=N+B*Math.cos(R),T=G+B*Math.sin(R),f=N+B*Math.cos(C),p=G+B*Math.sin(C),i=s[D%s.length],m=document.createElementNS("http://www.w3.org/2000/svg","path");if(m.setAttribute("d",`M ${N},${G} L ${I},${T} A ${B},${B} 0 ${d} 1 ${f},${p} Z`),m.setAttribute("fill",i),m.style.cursor="default",A){let c=X??F,l=c?q[D][c]:void 0,a=l!=null?z?$0(l,z,J):String(l):`Slice ${D+1}`,V=`${(L[D]/O*100).toFixed(1)}%`,S=R+P/2,v=N+B*0.6*Math.cos(S);m.addEventListener("mouseenter",()=>{q0(A,v,G,a,[{label:U[0].label??E,value:`${L[D]} (${V})`,color:i}])}),m.addEventListener("mouseleave",()=>{A.tooltip.classList.remove("pf-visible")}),m.addEventListener("touchstart",()=>{q0(A,v,G,a,[{label:U[0].label??E,value:`${L[D]} (${V})`,color:i}])},{passive:!0}),m.addEventListener("touchend",()=>{A.tooltip.classList.remove("pf-visible")},{passive:!0})}H.appendChild(m),R=C}return h0(Z,U,$.showLegend),Z.appendChild(H),Z}function y0($,J){let Z=_("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 D0($,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 h0($,J,Z){if(Z===!1||J.length<=1)return;let q=_("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=_("div","pf-chart-legend-item");Q.style.display="flex",Q.style.alignItems="center",Q.style.gap="4px";let Y=_("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=_("span");W.textContent=J[U].label??J[U].dataKey,Q.appendChild(Y),Q.appendChild(W),q.appendChild(Q)}$.appendChild(q)}function s8($,J){let Z=_("div","pf-chart pf-histogram"),q=y($.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],H=Math.min(...U),G=(Math.max(...U)-H)/Q||1,B=Array(Q).fill(0);for(let O of U){let A=Math.min(Math.floor((O-H)/G),Q-1);B[A]++}let E=Math.max(...B),F=300,X=Y,z=F/Q,L=D0(F,X,"Histogram");for(let O=0;O<Q;O++){let A=E>0?B[O]/E*X:0,R=document.createElementNS("http://www.w3.org/2000/svg","rect");R.setAttribute("x",String(O*z)),R.setAttribute("y",String(X-A)),R.setAttribute("width",String(z-1)),R.setAttribute("height",String(A)),R.setAttribute("fill",W),L.appendChild(R)}return Z.appendChild(L),Z}function w1(){M("Table",d8),M("TableHead",g0("thead")),M("TableBody",g0("tbody")),M("TableFooter",g0("tfoot")),M("TableRow",i8),M("TableHeader",r8),M("TableCell",n8),M("TableCaption",a8),M("ExpandableRow",o8)}function d8($,J){let Z=document.createElement("table");return Z.className="pf-table",Z.style.width="100%",Z.style.borderCollapse="collapse",j($,Z,J),Z}function g0($){return(J,Z)=>{let q=document.createElement($);return q.className=`pf-${$}`,j(J,q,Z),q}}function i8($,J){let Z=document.createElement("tr");return Z.className="pf-table-row",j($,Z,J),Z}function r8($,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=K($.content,J),Z}function n8($,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 j($,Z,J),Z}function a8($,J){let Z=document.createElement("caption");return Z.className="pf-table-caption",Z.style.padding="8px",Z.style.fontSize="14px",Z.textContent=K($.content,J),Z}function o8($,J){let Z=_("div","pf-expandable-row"),q=_("div","pf-expandable-row-summary");q.style.cursor="pointer",q.style.display="flex",q.style.alignItems="center",q.style.gap="8px";let U=_("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 H of Q)q.appendChild(w(H,J));let Y=_("div","pf-expandable-row-detail");Y.style.display="none",Y.style.paddingLeft="24px",j($,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 C1=!1;function L0(){if(C1)return;C1=!0,q1(),W1(),B1(),_1(),X1(),G1(),z1(),F1(),D1(),O1(),w1()}function b1($){return $.replace(/[^a-zA-Z0-9_-]/g,"")}function y1($){return $.replace(/[{}<>;]/g,"").replace(/\b(url|expression)\s*\(/gi,"")}function g1($,J){if(!J)return;if(J.light)for(let[Z,q]of Object.entries(J.light))$.style.setProperty(`--${b1(Z)}`,y1(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])=>` --${b1(Q)}: ${y1(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 u1($,J){if(!$||typeof document>"u")return;let Z=(q)=>{for(let[U,Q]of Object.entries($))if(t8(U,q))q.preventDefault(),J(Q)};return document.addEventListener("keydown",Z),()=>document.removeEventListener("keydown",Z)}function t8($,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}var m1='<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor"><path stroke-linecap="round" stroke-linejoin="round" d="M12 3v2.25m6.364.386-1.591 1.591M21 12h-2.25m-.386 6.364-1.591-1.591M12 18.75V21m-4.773-4.227-1.591 1.591M5.25 12H3m4.227-4.773L5.636 5.636M15.75 12a3.75 3.75 0 1 1-7.5 0 3.75 3.75 0 0 1 7.5 0Z"/></svg>',v1='<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor"><path stroke-linecap="round" stroke-linejoin="round" d="M21.752 15.002A9.72 9.72 0 0 1 18 15.75c-5.385 0-9.75-4.365-9.75-9.75 0-1.33.266-2.597.748-3.752A9.753 9.753 0 0 0 3 11.25C3 16.635 7.365 21 12.75 21a9.753 9.753 0 0 0 9.002-5.998Z"/></svg>',h1={"top-right":"top: 8px; right: 8px;","top-left":"top: 8px; left: 8px;","bottom-right":"bottom: 8px; right: 8px;","bottom-left":"bottom: 8px; left: 8px;"};function e8($,J){try{let q=localStorage.getItem(J);if(q==="light"||q==="dark")return q}catch{}let Z=$.getAttribute("data-theme")??document.documentElement.getAttribute("data-theme");if(Z==="light"||Z==="dark")return Z;if(typeof window<"u"&&window.matchMedia("(prefers-color-scheme: light)").matches)return"light";return"dark"}function u0($,J){if(typeof document>"u")return()=>{};let Z=J?.position??"top-right",q=J?.storageKey??"prefab-theme",U=J?.syncDocument??!0,Q=getComputedStyle($).position;if(Q==="static"||Q==="")$.style.position="relative";let Y=document.createElement("button");Y.className="pf-theme-toggle",Y.setAttribute("aria-label","Toggle theme"),Y.setAttribute("title","Toggle light/dark"),Object.assign(Y.style,{position:"absolute",zIndex:"100",width:"28px",height:"28px",border:"1px solid var(--border, #e5e7eb)",borderRadius:"6px",background:"var(--card, rgba(255,255,255,0.8))",color:"var(--foreground, #333)",cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",padding:"0",opacity:"0.7",transition:"opacity 0.15s, border-color 0.15s"});let W=h1[Z]??h1["top-right"];for(let B of W.split(";")){let[E,F]=B.split(":").map((X)=>X.trim());if(E&&F)Y.style.setProperty(E,F)}Y.addEventListener("mouseenter",()=>{Y.style.opacity="1"}),Y.addEventListener("mouseleave",()=>{Y.style.opacity="0.7"});function H(B){if($.setAttribute("data-theme",B),U)document.documentElement.setAttribute("data-theme",B);Y.innerHTML=B==="dark"?v1:m1;try{localStorage.setItem(q,B)}catch{}}let N=e8($,q);H(N),Y.addEventListener("click",()=>{let B=$.getAttribute("data-theme")??"dark";H(B==="dark"?"light":"dark")}),$.appendChild(Y);let G;if(U)G=new MutationObserver((B)=>{for(let E of B)if(E.type==="attributes"&&E.attributeName==="data-theme"){let F=document.documentElement.getAttribute("data-theme");if((F==="light"||F==="dark")&&F!==$.getAttribute("data-theme")){$.setAttribute("data-theme",F),Y.innerHTML=F==="dark"?v1:m1;try{localStorage.setItem(q,F)}catch{}}}}),G.observe(document.documentElement,{attributes:!0,attributeFilter:["data-theme"]});return()=>{G?.disconnect(),Y.remove()}}function j0($){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 H=W.result?.content??W.content??[];for(let N of H)if(N.type==="text"&&N.text!==void 0){try{let G=JSON.parse(N.text);if(typeof G==="object"&&G!==null&&"$prefab"in G)return G;return G}catch{}return N.text}return W.result??W},async sendMessage(U){await q(`${J}/mcp/messages`,{method:"POST",headers:Z,body:JSON.stringify({message:U})})}}}function T0(){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 $2($){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 $=q2();if($)this.postFn=(Z)=>$.postMessage(Z);let J=(Z)=>{if(this.hostOrigin!=="*"&&Z.origin!==this.hostOrigin)return;let q=Z.data;if($2(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($){try{return await Promise.any([this.initPrefab($),this.initJsonRpc($)])}catch(J){let Z=J instanceof AggregateError?J.errors.map((q)=>q.message).join("; "):String(J);throw Error(`Bridge init failed — no host responded. Tried: ${Z}`,{cause:J})}}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:$})}setupAutoResize($){if(typeof ResizeObserver>"u")return J2;let J=-1,Z=-1,q=(Y,W)=>{if(Y===J&&W===Z)return;if(J=Y,Z=W,this.protocol==="jsonrpc")this.sendRpcNotification("ui/notifications/size-changed",{width:Y,height:W});else this.sendPrefab("prefab:size-changed",{width:Y,height:W})},U=new ResizeObserver((Y)=>{for(let W of Y)if(W.borderBoxSize.length){let H=W.borderBoxSize[0];q(Math.ceil(H.inlineSize),Math.ceil(H.blockSize))}else{let H=W.target.getBoundingClientRect();q(Math.ceil(H.width),Math.ceil(H.height))}});U.observe($);let Q=$.getBoundingClientRect();return q(Math.ceil(Q.width),Math.ceil(Q.height)),()=>U.disconnect()}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;if(typeof U.css?.fonts==="string")q.fontCss=U.css.fonts}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??{},H=Y.hostContext??{},N=Y.hostCapabilities??{},G;if(typeof H.theme==="string"||typeof H.styles==="object"){if(G={},typeof H.theme==="string")G.colorScheme=H.theme;if(typeof H.styles==="object"&&H.styles!==null){let B=H.styles;if(B.variables)G.variables=B.variables;if(typeof B.css?.fonts==="string")G.fontCss=B.css.fonts}}this.postJsonRpc({jsonrpc:"2.0",method:"ui/notifications/initialized",params:{}}),J({hostName:W.name,hostVersion:W.version,capabilities:{toast:!0,navigation:N.openLinks!=null,messaging:!0,displayModes:H.availableDisplayModes??[]},theme:G,toolInput:void 0,meta:H})},reject:(Q)=>{if(U)return;U=!0,Z(Q)}}),this.postJsonRpc({jsonrpc:"2.0",id:q,method:"ui/initialize",params:{protocolVersion:"2026-01-26",appInfo:{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)})}sendRpcNotification($,J){this.postJsonRpc({jsonrpc:"2.0",method:$,params:J})}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)}}var J2=()=>{};function x0($,J){if(J.variables)for(let[Z,q]of Object.entries(J.variables))$.style.setProperty(Z.startsWith("--")?Z:`--${Z}`,q);if(J.fontCss)Z2(J.fontCss)}function Z2($){if(document.getElementById("__prefab-host-fonts"))return;let Z=document.createElement("style");Z.id="__prefab-host-fonts",Z.textContent=$,document.head.appendChild(Z)}function P0(){if(typeof window>"u")return!1;try{return window.self!==window.top}catch{return!0}}function q2(){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){L0();let q=[];if(J.pipes)for(let[X,z]of Object.entries(J.pipes))Q2(X,z,q);let U=new J0(J.state),Q;if(Z?.transport&&"callTool"in Z.transport)Q=Z.transport;else if(Z?.transport)Q=j0(Z.transport);else Q=T0();let Y=Z?.onToast??Y2,W=new S0,H={store:U,scope:{},transport:Q,rerender:()=>F(),onToast:Y,defs:J.defs,destroyRegistry:W};g1($,J.theme);let N=[];if(J.stylesheets)for(let X of J.stylesheets){let z=document.createElement("style");z.textContent=X,z.dataset.prefab="injected",document.head.appendChild(z),N.push(z)}let G;if(J.keyBindings)G=u1(J.keyBindings,async(X)=>{await k(X,{store:U,transport:Q,scope:{},rerender:()=>F(),onToast:Y})});let B,E=Z?.themeToggle??!0;if(E!==!1)B=u0($,typeof E==="object"?E:void 0);function F(){W.flush();let X=$.querySelector(".pf-theme-toggle");$.innerHTML="";let z=w(J.view,H);if($.appendChild(z),X)$.appendChild(X)}return F(),{rerender:()=>F(),update(X){U.merge(X.update.state),F()},store:U,destroy(){W.flush(),B?.(),G?.(),a0();for(let X of N)X.remove();for(let X of q)I0(X);$.innerHTML=""}}},isPrefabData($){return $!=null&&typeof $==="object"&&"$prefab"in $},isPrefabUpdate($){return $!=null&&typeof $==="object"&&"$prefab"in $&&"update"in $}},U2=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 Q2($,J,Z){if(U2.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}O0($,q),Z.push($)}catch(q){console.warn(`[prefab] wire pipe "${$}" — failed to hydrate:`,q)}}function Y2($){if(typeof document>"u")return;let J=W2(),Z=document.createElement("div"),q=$.variant??"default";Z.className=`pf-toast${q!=="default"?` pf-toast--${q}`:""}`,Z.setAttribute("data-variant",q),Z.style.marginBottom="8px",Z.style.transition="opacity 0.3s ease";let U=document.createElement("div");if(U.textContent=$.message,U.style.fontWeight="500",Z.appendChild(U),$.description){let Y=document.createElement("div");Y.textContent=$.description,Y.style.fontSize="14px",Y.style.color="var(--muted-foreground, #6b7280)",Z.appendChild(Y)}J.appendChild(Z);let Q=$.duration??4000;setTimeout(()=>{Z.style.opacity="0",setTimeout(()=>Z.remove(),300)},Q)}function W2(){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:V0,mount:g.mount.bind(g),isPrefabData:g.isPrefabData.bind(g),isPrefabUpdate:g.isPrefabUpdate.bind(g),Bridge:Q0,isIframe:P0,registerPipe:O0,unregisterPipe:I0,listPipes:s0,registerComponent:M,createThemeToggle:u0};let J=$.__PREFAB_DATA__;if(J!=null){let Z=document.getElementById("prefab-root");if(Z)g.mount(Z,J)}}async function V0($){L0();let J=$?.mode??"auto",Z=J==="bridge"||J==="auto"&&P0(),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=j0($.transport);else q=T0();if(Q.theme&&typeof document<"u")x0(document.documentElement,Q.theme);let Y,W,H,N,G=Q.toolInput,B;if(U)U.on("prefab:tool-input",(X)=>{let z=X.args??X;if(Y)Y(z);else G=z}),U.on("prefab:tool-result",(X)=>{let z=X.result??X;if(W)W(z);else B=z}),U.on("prefab:tool-cancelled",()=>{H?.()}),U.on("prefab:tool-input-partial",(X)=>{N?.(X.args??X)}),U.on("prefab:theme-update",(X)=>{if(typeof document<"u")x0(document.documentElement,X)});function E(X,...z){let L=p0(X),V=new J0,A={store:V,scope:{},transport:q,rerender:()=>R(),onToast:void 0};function R(){L.innerHTML="";for(let D of z)L.appendChild(w(D,A))}return R(),{rerender:R,store:V,destroy:()=>{L.innerHTML=""}}}return{callTool:(X,z={})=>q.callTool(X,z),sendMessage:(X)=>q.sendMessage(X),onToolInput:(X)=>{if(Y=X,G){let z=G;G=void 0,queueMicrotask(()=>X(z))}},onToolResult:(X)=>{if(W=X,B!==void 0){let z=B;B=void 0,queueMicrotask(()=>X(z))}},onToolCancelled:(X)=>{H=X},onToolInputPartial:(X)=>{N=X},render:E,mount:(X,z,L)=>{let V=p0(X);return g.mount(V,z,{transport:q,...L})},requestMode:(X)=>U?.requestMode(X),openLink:(X,z)=>{if(U)U.openLink(X,z);else if(typeof window<"u")window.open(X,z??"_blank")},updateContext:(X)=>{if(U)U.updateContext(X)},setupAutoResize:(X)=>{if(!U)return H2;let z=typeof X==="string"?p0(X):X;return U.setupAutoResize(z)},host:Q,capabilities:Q.capabilities,theme:Q.theme,transport:q,destroy:()=>U?.disconnect()}}var H2=()=>{};function p0($){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 x1="#root";function c0($){return g.isPrefabData($)}function p1($){return g.isPrefabUpdate($)}function c1($){if(c0($))return $;if($!==null&&typeof $==="object"){let J=$;if(c0(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(c0(U))return U}catch{}}}return null}async function l1(){let $=document.querySelector(x1);if(!$){console.error(`[prefab:auto] Mount target "${x1}" not found`);return}let J=$,Z=await V0();Z.setupAutoResize(J);let q;function U(Q){if(q)q.destroy();q=Z.mount(J,Q)}Z.onToolResult((Q)=>{let Y=c1(Q);if(Y)U(Y);else if(p1(Q)&&q)q.update(Q)}),Z.onToolInput((Q)=>{let Y=c1(Q);if(Y)U(Y);else if(p1(Q)&&q)q.update(Q)})}function M2(){if(document.readyState==="loading")document.addEventListener("DOMContentLoaded",()=>{l1().catch(($)=>{console.error("[prefab:auto] Boot failed:",$)})},{once:!0});else queueMicrotask(()=>{l1().catch(($)=>{console.error("[prefab:auto] Boot failed:",$)})})}M2();})();
14
+ }`}}function u1($,J){if(!$||typeof document>"u")return;let Z=(q)=>{for(let[U,Q]of Object.entries($))if(t8(U,q))q.preventDefault(),J(Q)};return document.addEventListener("keydown",Z),()=>document.removeEventListener("keydown",Z)}function t8($,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}var m1='<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor"><path stroke-linecap="round" stroke-linejoin="round" d="M12 3v2.25m6.364.386-1.591 1.591M21 12h-2.25m-.386 6.364-1.591-1.591M12 18.75V21m-4.773-4.227-1.591 1.591M5.25 12H3m4.227-4.773L5.636 5.636M15.75 12a3.75 3.75 0 1 1-7.5 0 3.75 3.75 0 0 1 7.5 0Z"/></svg>',v1='<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor"><path stroke-linecap="round" stroke-linejoin="round" d="M21.752 15.002A9.72 9.72 0 0 1 18 15.75c-5.385 0-9.75-4.365-9.75-9.75 0-1.33.266-2.597.748-3.752A9.753 9.753 0 0 0 3 11.25C3 16.635 7.365 21 12.75 21a9.753 9.753 0 0 0 9.002-5.998Z"/></svg>',h1={"top-right":"top: 8px; right: 8px;","top-left":"top: 8px; left: 8px;","bottom-right":"bottom: 8px; right: 8px;","bottom-left":"bottom: 8px; left: 8px;"};function e8($,J){try{let q=localStorage.getItem(J);if(q==="light"||q==="dark")return q}catch{}let Z=$.getAttribute("data-theme")??document.documentElement.getAttribute("data-theme");if(Z==="light"||Z==="dark")return Z;if(typeof window<"u"&&window.matchMedia("(prefers-color-scheme: light)").matches)return"light";return"dark"}function u0($,J){if(typeof document>"u")return()=>{};let Z=J?.position??"top-right",q=J?.storageKey??"prefab-theme",U=J?.syncDocument??!0,Q=getComputedStyle($).position;if(Q==="static"||Q==="")$.style.position="relative";let Y=document.createElement("button");Y.className="pf-theme-toggle",Y.setAttribute("aria-label","Toggle theme"),Y.setAttribute("title","Toggle light/dark"),Object.assign(Y.style,{position:"absolute",zIndex:"100",width:"28px",height:"28px",border:"1px solid var(--border, #e5e7eb)",borderRadius:"6px",background:"var(--card, rgba(255,255,255,0.8))",color:"var(--foreground, #333)",cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",padding:"0",opacity:"0.7",transition:"opacity 0.15s, border-color 0.15s"});let W=h1[Z]??h1["top-right"];for(let B of W.split(";")){let[E,F]=B.split(":").map((X)=>X.trim());if(E&&F)Y.style.setProperty(E,F)}Y.addEventListener("mouseenter",()=>{Y.style.opacity="1"}),Y.addEventListener("mouseleave",()=>{Y.style.opacity="0.7"});function H(B){if($.setAttribute("data-theme",B),U)document.documentElement.setAttribute("data-theme",B);Y.innerHTML=B==="dark"?v1:m1;try{localStorage.setItem(q,B)}catch{}}let N=e8($,q);H(N),Y.addEventListener("click",()=>{let B=$.getAttribute("data-theme")??"dark";H(B==="dark"?"light":"dark")}),$.appendChild(Y);let G;if(U)G=new MutationObserver((B)=>{for(let E of B)if(E.type==="attributes"&&E.attributeName==="data-theme"){let F=document.documentElement.getAttribute("data-theme");if((F==="light"||F==="dark")&&F!==$.getAttribute("data-theme")){$.setAttribute("data-theme",F),Y.innerHTML=F==="dark"?v1:m1;try{localStorage.setItem(q,F)}catch{}}}}),G.observe(document.documentElement,{attributes:!0,attributeFilter:["data-theme"]});return()=>{G?.disconnect(),Y.remove()}}function j0($){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 H=W.result?.content??W.content??[];for(let N of H)if(N.type==="text"&&N.text!==void 0){try{let G=JSON.parse(N.text);if(typeof G==="object"&&G!==null&&"$prefab"in G)return G;return G}catch{}return N.text}return W.result??W},async sendMessage(U){await q(`${J}/mcp/messages`,{method:"POST",headers:Z,body:JSON.stringify({message:U})})}}}function P0(){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 $2($){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 $=q2();if($)this.postFn=(Z)=>$.postMessage(Z);let J=(Z)=>{if(this.hostOrigin!=="*"&&Z.origin!==this.hostOrigin)return;let q=Z.data;if($2(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($){try{return await Promise.any([this.initPrefab($),this.initJsonRpc($)])}catch(J){let Z=J instanceof AggregateError?J.errors.map((q)=>q.message).join("; "):String(J);throw Error(`Bridge init failed — no host responded. Tried: ${Z}`,{cause:J})}}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:$})}setupAutoResize($){if(typeof ResizeObserver>"u")return J2;let J=-1,Z=-1,q=(Y,W)=>{if(Y===J&&W===Z)return;if(J=Y,Z=W,this.protocol==="jsonrpc")this.sendRpcNotification("ui/notifications/size-changed",{width:Y,height:W});else this.sendPrefab("prefab:size-changed",{width:Y,height:W})},U=new ResizeObserver((Y)=>{for(let W of Y)if(W.borderBoxSize.length){let H=W.borderBoxSize[0];q(Math.ceil(H.inlineSize),Math.ceil(H.blockSize))}else{let H=W.target.getBoundingClientRect();q(Math.ceil(H.width),Math.ceil(H.height))}});U.observe($);let Q=$.getBoundingClientRect();return q(Math.ceil(Q.width),Math.ceil(Q.height)),()=>U.disconnect()}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;if(typeof U.css?.fonts==="string")q.fontCss=U.css.fonts}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??{},H=Y.hostContext??{},N=Y.hostCapabilities??{},G;if(typeof H.theme==="string"||typeof H.styles==="object"){if(G={},typeof H.theme==="string")G.colorScheme=H.theme;if(typeof H.styles==="object"&&H.styles!==null){let B=H.styles;if(B.variables)G.variables=B.variables;if(typeof B.css?.fonts==="string")G.fontCss=B.css.fonts}}this.postJsonRpc({jsonrpc:"2.0",method:"ui/notifications/initialized",params:{}}),J({hostName:W.name,hostVersion:W.version,capabilities:{toast:!0,navigation:N.openLinks!=null,messaging:!0,displayModes:H.availableDisplayModes??[]},theme:G,toolInput:void 0,meta:H})},reject:(Q)=>{if(U)return;U=!0,Z(Q)}}),this.postJsonRpc({jsonrpc:"2.0",id:q,method:"ui/initialize",params:{protocolVersion:"2026-01-26",appInfo:{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)})}sendRpcNotification($,J){this.postJsonRpc({jsonrpc:"2.0",method:$,params:J})}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)}}var J2=()=>{};function x0($,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);if(J.fontCss)Z2(J.fontCss)}function Z2($){if(document.getElementById("__prefab-host-fonts"))return;let Z=document.createElement("style");Z.id="__prefab-host-fonts",Z.textContent=$,document.head.appendChild(Z)}function V0(){if(typeof window>"u")return!1;try{return window.self!==window.top}catch{return!0}}function q2(){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){L0();let q=[];if(J.pipes)for(let[X,z]of Object.entries(J.pipes))Q2(X,z,q);let U=new J0(J.state),Q;if(Z?.transport&&"callTool"in Z.transport)Q=Z.transport;else if(Z?.transport)Q=j0(Z.transport);else Q=P0();let Y=Z?.onToast??Y2,W=new S0,H={store:U,scope:{},transport:Q,rerender:()=>F(),onToast:Y,defs:J.defs,destroyRegistry:W};g1($,J.theme);let N=[];if(J.stylesheets)for(let X of J.stylesheets){let z=document.createElement("style");z.textContent=X,z.dataset.prefab="injected",document.head.appendChild(z),N.push(z)}let G;if(J.keyBindings)G=u1(J.keyBindings,async(X)=>{await k(X,{store:U,transport:Q,scope:{},rerender:()=>F(),onToast:Y})});let B,E=Z?.themeToggle??!0;if(E!==!1)B=u0($,typeof E==="object"?E:void 0);function F(){W.flush();let X=$.querySelector(".pf-theme-toggle");$.innerHTML="";let z=w(J.view,H);if($.appendChild(z),X)$.appendChild(X)}return F(),{rerender:()=>F(),update(X){U.merge(X.update.state),F()},store:U,destroy(){W.flush(),B?.(),G?.(),a0();for(let X of N)X.remove();for(let X of q)I0(X);$.innerHTML=""}}},isPrefabData($){return $!=null&&typeof $==="object"&&"$prefab"in $},isPrefabUpdate($){return $!=null&&typeof $==="object"&&"$prefab"in $&&"update"in $}},U2=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 Q2($,J,Z){if(U2.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}T0($,q),Z.push($)}catch(q){console.warn(`[prefab] wire pipe "${$}" — failed to hydrate:`,q)}}function Y2($){if(typeof document>"u")return;let J=W2(),Z=document.createElement("div"),q=$.variant??"default";Z.className=`pf-toast${q!=="default"?` pf-toast--${q}`:""}`,Z.setAttribute("data-variant",q),Z.style.marginBottom="8px",Z.style.transition="opacity 0.3s ease";let U=document.createElement("div");if(U.textContent=$.message,U.style.fontWeight="500",Z.appendChild(U),$.description){let Y=document.createElement("div");Y.textContent=$.description,Y.style.fontSize="14px",Y.style.color="var(--muted-foreground, #6b7280)",Z.appendChild(Y)}J.appendChild(Z);let Q=$.duration??4000;setTimeout(()=>{Z.style.opacity="0",setTimeout(()=>Z.remove(),300)},Q)}function W2(){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:O0,mount:g.mount.bind(g),isPrefabData:g.isPrefabData.bind(g),isPrefabUpdate:g.isPrefabUpdate.bind(g),Bridge:Q0,isIframe:V0,registerPipe:T0,unregisterPipe:I0,listPipes:s0,registerComponent:M,createThemeToggle:u0};let J=$.__PREFAB_DATA__;if(J!=null){let Z=document.getElementById("prefab-root");if(Z)g.mount(Z,J)}}async function O0($){L0();let J=$?.mode??"auto",Z=J==="bridge"||J==="auto"&&V0(),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=j0($.transport);else q=P0();if(Q.theme&&typeof document<"u")x0(document.documentElement,Q.theme);if(typeof document<"u"&&!U)M2();let Y,W,H,N,G=Q.toolInput,B;if(U)U.on("prefab:tool-input",(X)=>{let z=X.args??X;if(Y)Y(z);else G=z}),U.on("prefab:tool-result",(X)=>{let z=X.result??X;if(W)W(z);else B=z}),U.on("prefab:tool-cancelled",()=>{H?.()}),U.on("prefab:tool-input-partial",(X)=>{N?.(X.args??X)}),U.on("prefab:theme-update",(X)=>{if(typeof document<"u")x0(document.documentElement,X)});function E(X,...z){let L=p0(X),O=new J0,A={store:O,scope:{},transport:q,rerender:()=>R(),onToast:void 0};function R(){L.innerHTML="";for(let D of z)L.appendChild(w(D,A))}return R(),{rerender:R,store:O,destroy:()=>{L.innerHTML=""}}}return{callTool:(X,z={})=>q.callTool(X,z),sendMessage:(X)=>q.sendMessage(X),onToolInput:(X)=>{if(Y=X,G){let z=G;G=void 0,queueMicrotask(()=>X(z))}},onToolResult:(X)=>{if(W=X,B!==void 0){let z=B;B=void 0,queueMicrotask(()=>X(z))}},onToolCancelled:(X)=>{H=X},onToolInputPartial:(X)=>{N=X},render:E,mount:(X,z,L)=>{let O=p0(X);return g.mount(O,z,{transport:q,...L})},requestMode:(X)=>U?.requestMode(X),openLink:(X,z)=>{if(U)U.openLink(X,z);else if(typeof window<"u")window.open(X,z??"_blank")},updateContext:(X)=>{if(U)U.updateContext(X)},setupAutoResize:(X)=>{if(!U)return H2;let z=typeof X==="string"?p0(X):X;return U.setupAutoResize(z)},host:Q,capabilities:Q.capabilities,theme:Q.theme,transport:q,destroy:()=>U?.disconnect()}}var H2=()=>{};function p0($){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 $}function M2(){function $(){let Z=document.body.getAttribute("data-vscode-theme-kind");if(!Z)return;let q=Z.includes("light")?"light":"dark";document.documentElement.setAttribute("data-theme",q)}$(),new MutationObserver($).observe(document.body,{attributes:!0,attributeFilter:["data-vscode-theme-kind"]})}var x1="#root";function c0($){return g.isPrefabData($)}function p1($){return g.isPrefabUpdate($)}function c1($){if(c0($))return $;if($!==null&&typeof $==="object"){let J=$;if(c0(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(c0(U))return U}catch{}}}return null}async function l1(){let $=document.querySelector(x1);if(!$){console.error(`[prefab:auto] Mount target "${x1}" not found`);return}let J=$,Z=await O0();Z.setupAutoResize(J);let q;function U(Q){if(q)q.destroy();q=Z.mount(J,Q)}Z.onToolResult((Q)=>{let Y=c1(Q);if(Y)U(Y);else if(p1(Q)&&q)q.update(Q)}),Z.onToolInput((Q)=>{let Y=c1(Q);if(Y)U(Y);else if(p1(Q)&&q)q.update(Q)})}function B2(){if(document.readyState==="loading")document.addEventListener("DOMContentLoaded",()=>{l1().catch(($)=>{console.error("[prefab:auto] Boot failed:",$)})},{once:!0});else queueMicrotask(()=>{l1().catch(($)=>{console.error("[prefab:auto] Boot failed:",$)})})}B2();})();