@maxhealth.tech/prefab 0.3.3 → 0.3.5

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,16 +1,16 @@
1
- (()=>{var T1={silent:0,error:1,warn:2,info:3,debug:4},I1="warn";function P1($){I1=$}function x0($){let Z=$?`[prefab:${$}]`:"[prefab]",J=(q,Q,Y)=>{if(T1[q]>T1[I1])return;console[q](`${Z} ${Q}`,...Y)};return{error:(q,...Q)=>J("error",q,Q),warn:(q,...Q)=>J("warn",q,Q),info:(q,...Q)=>J("info",q,Q),debug:(q,...Q)=>J("debug",q,Q)}}var b=x0();class E0{data={};subscribers=new Map;globalSubscribers=new Set;generation=0;constructor($){if($)this.data=structuredClone($)}get($){return k4(this.data,$)}getAll(){return this.data}set($,Z){R1(this.data,$,Z),this.notify($)}toggle($){let Z=this.get($),J=Z==null||Z===!1||Z===0||Z==="";this.set($,J)}append($,Z,J){let q=this.get($);if(!Array.isArray(q)){this.set($,[Z]);return}if(J!==void 0)q.splice(J,0,Z);else q.push(Z);this.notify($)}pop($,Z){let J=this.get($);if(!Array.isArray(J))return;if(typeof Z==="number")J.splice(Z,1);else{let q=J.indexOf(Z);if(q>=0)J.splice(q,1)}this.notify($)}merge($){for(let[Z,J]of Object.entries($))R1(this.data,Z,J);for(let Z of Object.keys($))this.notify(Z)}subscribe($,Z){if(!this.subscribers.has($))this.subscribers.set($,new Set);return this.subscribers.get($)?.add(Z),()=>this.subscribers.get($)?.delete(Z)}subscribeAll($){return this.globalSubscribers.add($),()=>this.globalSubscribers.delete($)}notify($){this.generation++;let Z=$.split(".");for(let J=1;J<=Z.length;J++){let q=Z.slice(0,J).join("."),Q=this.subscribers.get(q);if(Q)Q.forEach((Y)=>Y())}this.globalSubscribers.forEach((J)=>J())}}function k4($,Z){let J=Z.split("."),q=$;for(let Q of J){if(q==null||typeof q!=="object")return;q=q[Q]}return q}var f4=new Set(["__proto__","constructor","prototype"]);function R1($,Z,J){let q=Z.split(".");if(q.some((Y)=>f4.has(Y))){b.warn(`Blocked prototype pollution attempt: ${Z}`);return}let Q=$;for(let Y=0;Y<q.length-1;Y++){let U=q[Y];if(Q[U]==null||typeof Q[U]!=="object")Q[U]={};Q=Q[U]}Q[q[q.length-1]]=J}var B0=new Map;function p0($,Z){if(B0.has($)&&B0.get($)!==Z)b.warn(`pipe "${$}" re-registered`);B0.set($,Z)}function c0($){return B0.delete($)}function j1(){return[...B0.keys()]}function A1($){return B0.get($)}var k1=-1,l0=new Map,S4=/\{\{\s*(.+?)\s*\}\}/g;function o($){return typeof $==="string"&&$.includes("{{")&&$.includes("}}")}function a($,Z,J){let q=$.trim();if(q.startsWith("{{")&&q.endsWith("}}")&&v4(q,"{{")===1){let Q=q.slice(2,-2).trim();return f1(Q,Z,J)}return $.replace(S4,(Q,Y)=>{let U=f1(Y.trim(),Z,J);return U==null?"":String(U)})}function f1($,Z,J){let[q,...Q]=h4($),Y=n(q.trim(),Z,J);for(let U of Q)Y=w4(U.trim(),Y,Z,J);return Y}function n($,Z,J){let q=y4($);if(q>=0){let U=$.slice(0,q).trim(),H=$.slice(q+1),W=m4(H);if(W>=0){let N=H.slice(0,W).trim(),E=H.slice(W+1).trim(),X=n(U,Z,J);return X!==null&&X!==void 0&&X!==!1&&X!==0&&X!==""?n(N,Z,J):n(E,Z,J)}}let Q=K0($,"||");if(Q>=0){let U=n($.slice(0,Q).trim(),Z,J);return U!==null&&U!==void 0&&U!==!1&&U!==0&&U!==""?U:n($.slice(Q+2).trim(),Z,J)}let Y=K0($,"&&");if(Y>=0){let U=n($.slice(0,Y).trim(),Z,J);if(U===null||U===void 0||U===!1||U===0||U==="")return U;return n($.slice(Y+2).trim(),Z,J)}for(let[U,H]of C4){let W=K0($,U);if(W>=0){let N=n($.slice(0,W).trim(),Z,J),E=n($.slice(W+U.length).trim(),Z,J);return H(N,E)}}if($.startsWith("!")){let U=n($.slice(1).trim(),Z,J);return U===null||U===void 0||U===!1||U===0||U===""}for(let[U,H]of b4){let W=K0($,U);if(W>=0){let N=n($.slice(0,W).trim(),Z,J),E=n($.slice(W+U.length).trim(),Z,J);return H(Number(N),Number(E))}}if($==="true")return!0;if($==="false")return!1;if($==="null"||$==="undefined")return null;if(/^-?\d+(\.\d+)?$/.test($))return Number($);if($.startsWith("'")&&$.endsWith("'")||$.startsWith('"')&&$.endsWith('"'))return $.slice(1,-1);if(J&&$.startsWith("$")){let U=$.indexOf(".");if(U>=0){let H=$.slice(0,U),W=$.slice(U+1),N=J[H];return L0(N,W)}return J[$]}if(J){let U=$.split(".")[0];if(U in J)return L0(J[U],$.includes(".")?$.slice(U.length+1):"")}return Z.get($)}function w4($,Z,J,q){let Q=$.indexOf(":"),Y=Q>=0?$.slice(0,Q).trim():$,U=Q>=0?$.slice(Q+1).trim():void 0,H=U?d0(U):void 0;switch(Y){case"find":{if(!Array.isArray(Z)||!U)return;let W=S1(U);if(W.length<2)return;let N=d0(W[0]),E=W[1].trim(),X;if(E.startsWith("'")&&E.endsWith("'")||E.startsWith('"')&&E.endsWith('"'))X=E.slice(1,-1);else if(J){if(q&&E.startsWith("$")){let M=E.indexOf(".");if(M>=0){let F=E.slice(0,M);if(F in q)X=L0(q[F],E.slice(M+1))}else if(E in q)X=q[E]}if(X===void 0&&!(q&&E.startsWith("$")))if(q){let M=E.split(".")[0];X=M in q?L0(q[M],E.includes(".")?E.slice(M.length+1):""):J.get(E)}else X=J.get(E)}else X=E;if(X==null)return;let B=J?.generation??0;if(B!==k1)l0=new Map,k1=B;let z=l0.get(Z);if(!z)z=new Map,l0.set(Z,z);let L=z.get(N);if(!L){L=new Map;for(let M of Z)if(M!=null&&typeof M==="object"){let F=M[N];if(F!=null)L.set(String(F),M)}z.set(N,L)}return L.get(String(X))}case"dot":{if(Z==null||typeof Z!=="object"||typeof H!=="string")return;return Z[H]}case"length":return Array.isArray(Z)?Z.length:typeof Z==="string"?Z.length:0;case"upper":return typeof Z==="string"?Z.toUpperCase():Z;case"lower":return typeof Z==="string"?Z.toLowerCase():Z;case"truncate":if(typeof Z==="string"&&typeof H==="number")return Z.slice(0,H);return Z;case"join":return Array.isArray(Z)?Z.join(typeof H==="string"?H:", "):Z;case"first":return Array.isArray(Z)?Z[0]:Z;case"last":return Array.isArray(Z)?Z[Z.length-1]:Z;case"abs":return Math.abs(Number(Z));case"round":return typeof H==="number"?Number(Number(Z).toFixed(H)):Math.round(Number(Z));case"number":return typeof H==="number"?Number(Number(Z).toFixed(H)):Number(Z);case"currency":{let W=typeof H==="string"?H:"USD";try{return new Intl.NumberFormat("en-US",{style:"currency",currency:W}).format(Number(Z))}catch{return Z}}case"percent":return typeof H==="number"?`${(Number(Z)*100).toFixed(H)}%`:`${Math.round(Number(Z)*100)}%`;case"compact":{let W=typeof H==="number"?H:1;try{return new Intl.NumberFormat("en-US",{notation:"compact",maximumFractionDigits:W}).format(Number(Z))}catch{return Z}}case"date":try{return new Date(Z).toLocaleDateString()}catch{return Z}case"time":try{return new Date(Z).toLocaleTimeString()}catch{return Z}case"datetime":try{return new Date(Z).toLocaleString()}catch{return Z}case"pluralize":{let W=Number(Z),N=typeof H==="string"?H:"";return W===1?N:`${N}s`}case"default":return Z==null||Z===""?H:Z;case"selectattr":return Array.isArray(Z)&&typeof H==="string"?Z.filter((W)=>W!=null&&typeof W==="object"&&Boolean(W[H])):Z;case"rejectattr":return Array.isArray(Z)&&typeof H==="string"?Z.filter((W)=>{if(W==null||typeof W!=="object")return!1;let N=W[H];return N==null||N===!1||N===0||N===""}):Z;default:{let W=A1(Y);if(W){let N=U?S1(U).map(d0):[];return W(Z,...N)}return Z}}}var C4=[["!==",($,Z)=>$!==Z],["===",($,Z)=>$===Z],["!=",($,Z)=>$!=Z],["==",($,Z)=>$==Z],[">=",($,Z)=>Number($)>=Number(Z)],["<=",($,Z)=>Number($)<=Number(Z)],[">",($,Z)=>Number($)>Number(Z)],["<",($,Z)=>Number($)<Number(Z)]],b4=[[" + ",($,Z)=>$+Z],[" - ",($,Z)=>$-Z],[" * ",($,Z)=>$*Z],[" / ",($,Z)=>Z!==0?$/Z:0],[" % ",($,Z)=>Z!==0?$%Z:0]];function K0($,Z){let J=null;for(let q=0;q<$.length;q++){let Q=$[q];if(Q==="'"||Q==='"')J=J===Q?null:J??Q;if(!J&&$.slice(q,q+Z.length)===Z)return q}return-1}function y4($){let Z=0,J=null;for(let q=0;q<$.length;q++){let Q=$[q];if(Q==="'"||Q==='"')J=J===Q?null:J??Q;if(!J){if(Q==="(")Z++;else if(Q===")")Z--;else if(Q==="?"&&Z===0)return q}}return-1}function m4($){let Z=0,J=null;for(let q=0;q<$.length;q++){let Q=$[q];if(Q==="'"||Q==='"')J=J===Q?null:J??Q;if(!J){if(Q==="?"||Q==="(")Z++;else if(Q===")")Z--;else if(Q===":"&&Z===0)return q}}return-1}function h4($){let Z=[],J="",q=null;for(let Q=0;Q<$.length;Q++){let Y=$[Q];if(Y==="'"||Y==='"')q=q===Y?null:q??Y;if(Y==="|"&&!q)if($[Q+1]==="|")J+="||",Q++;else Z.push(J),J="";else J+=Y}return Z.push(J),Z}function d0($){let Z=$.replace(/^['"]|['"]$/g,"");if(Z==="true")return!0;if(Z==="false")return!1;let J=Number(Z);return isNaN(J)?Z:J}function S1($){let Z=[],J="",q=null;for(let Q of $){if(Q==="'"||Q==='"')q=q===Q?null:q??Q;if(Q===","&&!q)Z.push(J),J="";else J+=Q}return Z.push(J),Z}function L0($,Z){if(!Z)return $;let J=Z.split("."),q=$;for(let Q of J){if(q==null||typeof q!=="object")return;q=q[Q]}return q}function v4($,Z){let J=0,q=0;while((q=$.indexOf(Z,q))!==-1)J++,q+=Z.length;return J}function V0($){return $.replace(/_([a-z])/g,(Z,J)=>J.toUpperCase())}function s0($){let Z={};for(let[J,q]of Object.entries($)){let Q=J.startsWith("$")?J:V0(J);if(Array.isArray(q))Z[Q]=q.map((Y)=>Y!=null&&typeof Y==="object"&&!Array.isArray(Y)?s0(Y):Y);else if(q!=null&&typeof q==="object"&&!Array.isArray(q))Z[Q]=s0(q);else Z[Q]=q}return Z}async function m($,Z){let J=Array.isArray($)?$:[$];for(let q of J)await g4(q,Z)}async function g4($,Z){let J=s0($),q=J.action;switch(q){case"setState":{u4(J,Z);return}case"toggleState":{x4(J,Z);return}case"appendState":{p4(J,Z);return}case"popState":{c4(J,Z);return}case"showToast":{l4(J,Z);return}case"closeOverlay":{d4(J,Z);return}case"openLink":{i4(J);return}case"setInterval":{n4(J,Z);return}case"toolCall":case"callTool":return r4(J,Z);case"sendMessage":return o4(J,Z);case"updateContext":{a4(J,Z);return}case"fetch":return t4(J,Z);case"openFilePicker":{e4(J,Z);return}case"callHandler":return $8(J,Z);case"requestDisplayMode":{Z8(J,Z);return}case"subscribe":{Q8(J,Z);return}case"unsubscribe":{Y8(J);return}default:b.warn(`Unknown action: ${q}`)}}function u4($,Z){let{key:J,value:q}=$;if(o(q))q=a(q,Z.store,Z.scope);Z.store.set(J,q),Z.rerender(),$0($.onSuccess,Z)}function x4($,Z){Z.store.toggle($.key),Z.rerender()}function p4($,Z){let J=$.value??$.item;if(o(J))J=a(J,Z.store,Z.scope);Z.store.append($.key,J,$.index),Z.rerender()}function c4($,Z){Z.store.pop($.key,$.index),Z.rerender()}function l4($,Z){Z.onToast?.({message:O0($.message,Z),description:$.description!=null?O0($.description,Z):void 0,variant:$.variant,duration:$.duration})}function d4($,Z){if(typeof document<"u")document.dispatchEvent(new CustomEvent("prefab:close-overlay"))}function i4($){if(typeof window<"u"){let Z=$.url;if(!Z){b.warn("openLink: missing url");return}if(!y1(Z)){b.warn(`Blocked unsafe URL scheme: ${Z}`);return}window.open(Z,$.target??"_blank")}}var D0=new Set,s4=20,w1=100;function n4($,Z){let J=Math.max($.intervalMs,w1),q=$.onTick;if(typeof globalThis.setInterval!=="function")return;if(D0.size>=s4){b.warn("Max intervals reached, ignoring new setInterval");return}let Q=globalThis.setInterval(()=>void m(q,Z),J);D0.add(Q)}function C1(){for(let $ of D0)globalThis.clearInterval($);D0.clear()}async function r4($,Z){if(!Z.transport){b.warn("No MCP transport configured for toolCall");return}let J=$.tool,q=n0($.arguments,Z);try{let Q=await Z.transport.callTool(J,q);if($.resultKey!=null)Z.store.set($.resultKey,Q);let Y=T0(Q);if(Y&&Z.remount)Z.remount(Y);else I0(Q,Z),Z.rerender();await $0($.onSuccess,Z,{$result:Q})}catch(Q){await $0($.onError,Z,{$error:Q})}}async function o4($,Z){if(!Z.transport){b.warn("No MCP transport configured for sendMessage");return}await Z.transport.sendMessage(O0($.message,Z))}function a4($,Z){let J=$.context;if(J!=null)Z.store.merge(J),Z.rerender()}async function t4($,Z){let J=O0($.url,Z);if(!y1(J)){b.warn(`Blocked unsafe URL in fetch: ${J}`);return}let q=$.method??"GET",Q=$.headers,Y=$.body!==void 0?JSON.stringify($.body):void 0;try{let U=await globalThis.fetch(J,{method:q,headers:{"Content-Type":"application/json",...Q},...Y&&{body:Y}}),H=await U.json().catch(()=>U.text());if($.resultKey!=null)Z.store.set($.resultKey,H);let W=T0(H);if(W&&Z.remount)Z.remount(W);else I0(H,Z),Z.rerender();await $0($.onSuccess,Z,{$result:H})}catch(U){await $0($.onError,Z,{$error:U})}}function e4($,Z){if(typeof document>"u")return;let J=document.createElement("input");if(J.type="file",$.accept!=null)J.accept=$.accept;if($.multiple===!0)J.multiple=!0;J.addEventListener("change",()=>{let q=Array.from(J.files??[]);if($.resultKey!=null)Z.store.set($.resultKey,q);Z.rerender(),$0($.onSuccess,Z,{$result:q})}),J.click()}async function $8($,Z){let J=$.handler,q=n0($.arguments,Z);if(!Z.transport){b.warn(`No transport configured for callHandler: ${J}`);return}try{let Q=await Z.transport.callTool(J,q);if($.resultKey!=null)Z.store.set($.resultKey,Q);let Y=T0(Q);if(Y&&Z.remount)Z.remount(Y);else I0(Q,Z),Z.rerender();await $0($.onSuccess,Z,{$result:Q})}catch(Q){await $0($.onError,Z,{$error:Q})}}function Z8($,Z){if(typeof document<"u")document.dispatchEvent(new CustomEvent("prefab:request-display-mode",{detail:{mode:$.mode}}))}var q0=new Map,J8=50,q8=2000;function Q8($,Z){let{uri:J,stateKey:q}=$;if(!J||!q){b.warn("subscribe: missing uri or stateKey");return}if(q0.has(J))return;if(q0.size>=J8){b.warn("Max subscriptions reached, ignoring new subscribe");return}let Q=(X)=>{let B=T0(X);if(B&&Z.remount)Z.remount(B);else{if(!I0(X,Z))Z.store.set(q,X);Z.rerender()}$0($.onData,Z,{$data:X})};if(Z.transport?.subscribe&&Z.transport.capabilities?.subscriptions){let X=Z.transport.subscribe(J,Q);q0.set(J,X);return}let Y=$.fallbackTool,U=$.fallbackInterval??q8;if(!Y){b.warn("subscribe: host lacks subscriptions and no fallbackTool specified");return}if(!Z.transport){b.warn("No MCP transport configured for subscribe fallback");return}let H=$.fallbackArgs??{},W=Math.max(U,w1),N=Z.transport,E=globalThis.setInterval(()=>{(async()=>{try{let X=n0(H,Z),B=await N.callTool(Y,X);Q(B)}catch(X){$0($.onError,Z,{$error:X})}})()},W);q0.set(J,()=>globalThis.clearInterval(E))}function Y8($){let Z=$.uri;if(!Z){b.warn("unsubscribe: missing uri");return}let J=q0.get(Z);if(J)J(),q0.delete(Z)}function b1(){for(let[$,Z]of q0)try{Z()}catch(J){b.warn(`Error cleaning up subscription '${$}':`,J)}q0.clear()}function T0($){if($==null||typeof $!=="object")return null;let Z=$;if("$prefab"in Z&&"view"in Z)return Z;if("structuredContent"in Z){let J=Z.structuredContent;if(J!=null&&typeof J==="object"){let q=J;if("$prefab"in q&&"view"in q)return q}}if("content"in Z&&Array.isArray(Z.content)){for(let J of Z.content)if(J.type==="text"&&typeof J.text==="string")try{let q=JSON.parse(J.text);if(q!=null&&typeof q==="object"){let Q=q;if("$prefab"in Q&&"view"in Q)return Q}}catch{}}return null}function U8($){if($==null||typeof $!=="object")return null;let Z=$;if(i0(Z))return Z;if("structuredContent"in Z){let J=Z.structuredContent;if(J!=null&&typeof J==="object"&&i0(J))return J}if("content"in Z&&Array.isArray(Z.content)){for(let J of Z.content)if(J.type==="text"&&typeof J.text==="string")try{let q=JSON.parse(J.text);if(q!=null&&typeof q==="object"&&i0(q))return q}catch{}}return null}function i0($){if(!("$prefab"in $)||!("update"in $))return!1;let Z=$.update;return Z!=null&&typeof Z==="object"&&"state"in Z}function I0($,Z){let J=U8($);if(!J)return!1;let q=J.update;if(Z.store.merge(q.state),q.actions!=null)m(q.actions,Z);return!0}var H8=/^\s*(javascript|vbscript|data):/i;function y1($){return!H8.test($)}function O0($,Z){if(o($)){let J=a($,Z.store,Z.scope);return J==null?"":String(J)}return $==null?"":String($)}function n0($,Z){if(!$)return{};let J={};for(let[q,Q]of Object.entries($))J[q]=o(Q)?a(Q,Z.store,Z.scope):Q;return J}async function $0($,Z,J){if($==null)return;let q={...Z.scope,...J};await m($,{...Z,scope:q})}function o0($){let Z={};for(let[J,q]of Object.entries($)){let Q=J.startsWith("$")?J:V0(J);if(Array.isArray(q))Z[Q]=q.map((Y)=>Y!=null&&typeof Y==="object"&&!Array.isArray(Y)?o0(Y):Y);else if(q!=null&&typeof q==="object"&&!Array.isArray(q))Z[Q]=o0(q);else Z[Q]=q}return Z}class t0{callbacks=[];track($){this.callbacks.push($)}flush(){for(let $ of this.callbacks)try{$()}catch(Z){b.warn("destroy callback error:",Z)}this.callbacks=[]}get size(){return this.callbacks.length}}function W8($){return typeof $==="object"&&"element"in $}var a0=new Map;function G($,Z){if(a0.has($))b.warn(`overriding existing renderer for "${$}"`);a0.set($,Z)}function x($,Z){let J=o0($);if(Z.defs?.[J.type]){let Y={...Z.defs[J.type],...J,type:Z.defs[J.type].type};return x(Y,Z)}let q=a0.get(J.type),Q;if(q){let Y=q(J,Z);if(W8(Y))Q=Y.element,Z.destroyRegistry?.track(Y.destroy);else Q=Y}else if(Q=document.createElement("div"),Q.setAttribute("data-prefab-type",J.type),J.children)for(let Y of J.children)Q.appendChild(x(Y,Z));if(Q instanceof HTMLElement){if(J.id)Q.id=J.id;if(J.cssClass){let Y=K(J.cssClass,Z);if(Y)Q.className=(Q.className?Q.className+" ":"")+Y}if(J.onClick!=null){if(Q.addEventListener("click",()=>{m(J.onClick,c(Z))}),Q.tagName!=="BUTTON"&&Q.tagName!=="A")Q.setAttribute("role","button"),Q.setAttribute("tabindex","0"),Q.addEventListener("keydown",(Y)=>{let U=Y.key;if(U==="Enter"||U===" ")Y.preventDefault(),m(J.onClick,c(Z))})}}if(J.onMount){let Y=J.onMount,U=c(Z);queueMicrotask(()=>void m(Y,U))}return Q}function w($,Z,J){if(!$.children)return;Q0($.children,Z,J)}function Q0($,Z,J){let q=0;while(q<$.length){let Q=$[q];if(Q.type==="If")q=X8($,q,Z,J);else if(Q.type==="Elif"||Q.type==="Else")q++;else Z.appendChild(x(Q,J)),q++}}function X8($,Z,J,q){let Q=!1,Y=Z,U=$[Y];if(m1(U.condition,q))r0(U,J,q),Q=!0;Y++;while(Y<$.length){let H=$[Y];if(H.type==="Elif"){if(!Q&&m1(H.condition,q))r0(H,J,q),Q=!0;Y++}else if(H.type==="Else"){if(!Q)r0(H,J,q);Y++;break}else break}return Y}function m1($,Z){if(!$)return!1;if(o($))return Boolean(a($,Z.store,Z.scope));return Boolean(Z.store.get($))}function r0($,Z,J){if(!$.children)return;Q0($.children,Z,J)}function K($,Z){if(o($)){let J=a($,Z.store,Z.scope);return J==null?"":String(J)}return $==null?"":String($)}function p($,Z){if(o($))return a($,Z.store,Z.scope);return $}function c($){return{store:$.store,transport:$.transport,scope:$.scope,rerender:$.rerender,onToast:$.onToast,remount:$.remount}}function _($,Z){let J=document.createElement($);if(Z)J.className=Z;return J}function e0($,Z){return $.textContent=Z,$}function u1(){G("Column",G8),G("Row",B8),G("Grid",h1),G("GridItem",v1),G("Container",M8),G("Div",g1),G("Span",_8),G("Dashboard",h1),G("DashboardItem",v1),G("Pages",N8),G("Page",g1),G("Detail",E8),G("MasterDetail",F8)}function G8($,Z){let J=_("div","pf-column");J.style.display="flex",J.style.flexDirection="column";let q=P0($);if(q!=null)J.style.gap=`${q*4}px`;if($.align!=null)J.style.alignItems=x1($.align);if($.justify!=null)J.style.justifyContent=p1($.justify);return w($,J,Z),J}function B8($,Z){let J=_("div","pf-row");J.style.display="flex",J.style.flexDirection="row";let q=P0($);if(q!=null)J.style.gap=`${q*4}px`;if($.align!=null)J.style.alignItems=x1($.align);if($.justify!=null)J.style.justifyContent=p1($.justify);if($.wrap===!0)J.style.flexWrap="wrap";return w($,J,Z),J}function h1($,Z){let J=_("div","pf-grid");J.style.display="grid";let q=$.columns??3;J.style.gridTemplateColumns=`repeat(${q}, 1fr)`;let Q=P0($);if(Q!=null)J.style.gap=`${Q*4}px`;return w($,J,Z),J}function v1($,Z){let J=_("div","pf-grid-item");if($.colSpan!=null)J.style.gridColumn=`span ${$.colSpan}`;if($.rowSpan!=null)J.style.gridRow=`span ${$.rowSpan}`;return w($,J,Z),J}function M8($,Z){let J=_("div","pf-container");if(J.style.maxWidth=$.maxWidth??"1200px",J.style.margin="0 auto",$.padding!=null)J.style.padding=`${$.padding*4}px`;return w($,J,Z),J}function g1($,Z){let J=_("div","pf-div");return w($,J,Z),J}function _8($,Z){let J=_("span","pf-span");return w($,J,Z),J}function N8($,Z){let J=_("div","pf-pages");return w($,J,Z),J}function E8($,Z){let J=_("div","pf-detail"),q=$.of!=null?p($.of,Z):void 0;if(q!=null&&q!==""&&q!==!1&&q!==0)w($,J,Z);else if($.empty!=null){let Q=$.empty;J.appendChild(x(Q,Z))}return J}function F8($,Z){let J=_("div","pf-master-detail");J.style.display="flex",J.style.flexDirection="row";let q=P0($);if(q!=null)J.style.gap=`${q*4}px`;let Q=$.masterWidth??"33%",Y=$.children??[];if(Y.length>0){let U=_("div","pf-master-detail-master");U.style.width=Q,U.style.flexShrink="0",U.style.overflow="auto",U.appendChild(x(Y[0],Z)),J.appendChild(U)}if(Y.length>1){let U=_("div","pf-master-detail-detail");U.style.flex="1",U.style.overflow="auto",U.appendChild(x(Y[1],Z)),J.appendChild(U)}return J}var z8=/\bgap-(\d+)\b/;function P0($){if($.gap!=null)return $.gap;if(typeof $.cssClass==="string"){let Z=z8.exec($.cssClass);if(Z)return Number(Z[1])}return null}function x1($){return{start:"flex-start",end:"flex-end",center:"center",stretch:"stretch",baseline:"baseline"}[$]??$}function p1($){return{start:"flex-start",end:"flex-end",center:"center",between:"space-between",around:"space-around",evenly:"space-evenly"}[$]??$}function l1(){G("Heading",K8),G("H1",($,Z)=>R0($,Z,"h1")),G("H2",($,Z)=>R0($,Z,"h2")),G("H3",($,Z)=>R0($,Z,"h3")),G("H4",($,Z)=>R0($,Z,"h4")),G("Text",L8),G("P",V8),G("Lead",($,Z)=>M0($,Z,"p","pf-lead")),G("Large",($,Z)=>M0($,Z,"span","pf-large")),G("Small",($,Z)=>M0($,Z,"small","pf-small")),G("Muted",($,Z)=>M0($,Z,"p","pf-muted")),G("BlockQuote",($,Z)=>M0($,Z,"blockquote","pf-blockquote")),G("Label",($,Z)=>M0($,Z,"label","pf-label")),G("Link",O8),G("Code",T8),G("Markdown",I8),G("Kbd",P8)}function K8($,Z){let J=$.level??2,q=`h${Math.min(Math.max(J,1),6)}`,Q=document.createElement(q);return Q.className=`pf-heading pf-${q}`,Q.textContent=K($.content,Z),Q}function R0($,Z,J){let q=document.createElement(J);return q.className=`pf-heading pf-${J}`,q.textContent=K($.content,Z),q}function L8($,Z){return e0(_("span","pf-text"),K($.content,Z))}function V8($,Z){return e0(_("p","pf-p"),K($.content,Z))}function M0($,Z,J,q){let Q=document.createElement(J);return Q.className=q,Q.textContent=K($.content,Z),Q}var D8=/^\s*(javascript|vbscript|data):/i;function O8($,Z){let J=document.createElement("a");if(J.className="pf-link",J.textContent=K($.content,Z),$.href!=null){let q=K($.href,Z);if(!D8.test(q))J.href=q}if($.target!=null)J.target=K($.target,Z);return J}function T8($,Z){let J=_("pre","pf-code"),q=_("code");if(q.textContent=K($.content,Z),$.language!=null)q.setAttribute("data-language",$.language);return J.appendChild(q),J}function I8($,Z){let J=_("div","pf-markdown"),q=K($.content,Z);return J.innerHTML=d1(q),J.setAttribute("data-markdown","true"),J}var c1=/^\s*(javascript|vbscript|data):/i;function A0($){return $.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;")}function j0($){let Z=A0($),J=[];return Z=Z.replace(/`([^`]+)`/g,(q,Q)=>{return J.push(`<code>${Q}</code>`),`﷐CODE${J.length-1}﷐`}),Z=Z.replace(/!\[([^\]]*)\]\(([^)]+)\)/g,(q,Q,Y)=>{if(c1.test(Y))return A0(Q);return`<img src="${Y}" alt="${Q}" />`}),Z=Z.replace(/\[([^\]]+)\]\(([^)]+)\)/g,(q,Q,Y)=>{if(c1.test(Y))return Q;return`<a href="${Y}">${Q}</a>`}),Z=Z.replace(/\*{3}(.+?)\*{3}/g,"<strong><em>$1</em></strong>"),Z=Z.replace(/_{3}(.+?)_{3}/g,"<strong><em>$1</em></strong>"),Z=Z.replace(/\*{2}(.+?)\*{2}/g,"<strong>$1</strong>"),Z=Z.replace(/_{2}(.+?)_{2}/g,"<strong>$1</strong>"),Z=Z.replace(/\*(.+?)\*/g,"<em>$1</em>"),Z=Z.replace(/(?<!\w)_(.+?)_(?!\w)/g,"<em>$1</em>"),Z=Z.replace(/~~(.+?)~~/g,"<del>$1</del>"),Z=Z.replace(/\uFDD0CODE(\d+)\uFDD0/g,(q,Q)=>J[parseInt(Q)]),Z}function d1($){let Z=$.replace(/\r\n?/g,`
1
+ (()=>{var P1={silent:0,error:1,warn:2,info:3,debug:4},R1="warn";function j1($){R1=$}function c0($){let Z=$?`[prefab:${$}]`:"[prefab]",J=(q,Q,Y)=>{if(P1[q]>P1[R1])return;console[q](`${Z} ${Q}`,...Y)};return{error:(q,...Q)=>J("error",q,Q),warn:(q,...Q)=>J("warn",q,Q),info:(q,...Q)=>J("info",q,Q),debug:(q,...Q)=>J("debug",q,Q)}}var C=c0();class E0{data={};subscribers=new Map;globalSubscribers=new Set;generation=0;constructor($){if($)this.data=structuredClone($)}get($){return S4(this.data,$)}getAll(){return this.data}set($,Z){k1(this.data,$,Z),this.notify($)}toggle($){let Z=this.get($),J=Z==null||Z===!1||Z===0||Z==="";this.set($,J)}append($,Z,J){let q=this.get($);if(!Array.isArray(q)){this.set($,[Z]);return}if(J!==void 0)q.splice(J,0,Z);else q.push(Z);this.notify($)}pop($,Z){let J=this.get($);if(!Array.isArray(J))return;if(typeof Z==="number")J.splice(Z,1);else{let q=J.indexOf(Z);if(q>=0)J.splice(q,1)}this.notify($)}merge($){for(let[Z,J]of Object.entries($))k1(this.data,Z,J);for(let Z of Object.keys($))this.notify(Z)}subscribe($,Z){if(!this.subscribers.has($))this.subscribers.set($,new Set);return this.subscribers.get($)?.add(Z),()=>this.subscribers.get($)?.delete(Z)}subscribeAll($){return this.globalSubscribers.add($),()=>this.globalSubscribers.delete($)}notify($){this.generation++;let Z=$.split(".");for(let J=1;J<=Z.length;J++){let q=Z.slice(0,J).join("."),Q=this.subscribers.get(q);if(Q)Q.forEach((Y)=>Y())}this.globalSubscribers.forEach((J)=>J())}}function S4($,Z){let J=Z.split("."),q=$;for(let Q of J){if(q==null||typeof q!=="object")return;q=q[Q]}return q}var w4=new Set(["__proto__","constructor","prototype"]);function k1($,Z,J){let q=Z.split(".");if(q.some((Y)=>w4.has(Y))){C.warn(`Blocked prototype pollution attempt: ${Z}`);return}let Q=$;for(let Y=0;Y<q.length-1;Y++){let U=q[Y];if(Q[U]==null||typeof Q[U]!=="object")Q[U]={};Q=Q[U]}Q[q[q.length-1]]=J}var M0=new Map;function l0($,Z){if(M0.has($)&&M0.get($)!==Z)C.warn(`pipe "${$}" re-registered`);M0.set($,Z)}function d0($){return M0.delete($)}function A1(){return[...M0.keys()]}function f1($){return M0.get($)}var S1=-1,i0=new Map,C4=/\{\{\s*(.+?)\s*\}\}/g;function o($){return typeof $==="string"&&$.includes("{{")&&$.includes("}}")}function t($,Z,J){let q=$.trim();if(q.startsWith("{{")&&q.endsWith("}}")&&u4(q,"{{")===1){let Q=q.slice(2,-2).trim();return w1(Q,Z,J)}return $.replace(C4,(Q,Y)=>{let U=w1(Y.trim(),Z,J);return U==null?"":String(U)})}function w1($,Z,J){let[q,...Q]=g4($),Y=r(q.trim(),Z,J);for(let U of Q)Y=b4(U.trim(),Y,Z,J);return Y}function r($,Z,J){let q=h4($);if(q>=0){let U=$.slice(0,q).trim(),H=$.slice(q+1),W=v4(H);if(W>=0){let _=H.slice(0,W).trim(),z=H.slice(W+1).trim(),X=r(U,Z,J);return X!==null&&X!==void 0&&X!==!1&&X!==0&&X!==""?r(_,Z,J):r(z,Z,J)}}let Q=L0($,"||");if(Q>=0){let U=r($.slice(0,Q).trim(),Z,J);return U!==null&&U!==void 0&&U!==!1&&U!==0&&U!==""?U:r($.slice(Q+2).trim(),Z,J)}let Y=L0($,"&&");if(Y>=0){let U=r($.slice(0,Y).trim(),Z,J);if(U===null||U===void 0||U===!1||U===0||U==="")return U;return r($.slice(Y+2).trim(),Z,J)}for(let[U,H]of y4){let W=L0($,U);if(W>=0){let _=r($.slice(0,W).trim(),Z,J),z=r($.slice(W+U.length).trim(),Z,J);return H(_,z)}}if($.startsWith("!")){let U=r($.slice(1).trim(),Z,J);return U===null||U===void 0||U===!1||U===0||U===""}for(let[U,H]of m4){let W=L0($,U);if(W>=0){let _=r($.slice(0,W).trim(),Z,J),z=r($.slice(W+U.length).trim(),Z,J);return H(Number(_),Number(z))}}if($==="true")return!0;if($==="false")return!1;if($==="null"||$==="undefined")return null;if(/^-?\d+(\.\d+)?$/.test($))return Number($);if($.startsWith("'")&&$.endsWith("'")||$.startsWith('"')&&$.endsWith('"'))return $.slice(1,-1);if(J&&$.startsWith("$")){let U=$.indexOf(".");if(U>=0){let H=$.slice(0,U),W=$.slice(U+1),_=J[H];return V0(_,W)}return J[$]}if(J){let U=$.split(".")[0];if(U in J)return V0(J[U],$.includes(".")?$.slice(U.length+1):"")}return Z.get($)}function b4($,Z,J,q){let Q=$.indexOf(":"),Y=Q>=0?$.slice(0,Q).trim():$,U=Q>=0?$.slice(Q+1).trim():void 0,H=U?s0(U):void 0;switch(Y){case"find":{if(!Array.isArray(Z)||!U)return;let W=C1(U);if(W.length<2)return;let _=s0(W[0]),z=W[1].trim(),X;if(z.startsWith("'")&&z.endsWith("'")||z.startsWith('"')&&z.endsWith('"'))X=z.slice(1,-1);else if(J){if(q&&z.startsWith("$")){let M=z.indexOf(".");if(M>=0){let E=z.slice(0,M);if(E in q)X=V0(q[E],z.slice(M+1))}else if(z in q)X=q[z]}if(X===void 0&&!(q&&z.startsWith("$")))if(q){let M=z.split(".")[0];X=M in q?V0(q[M],z.includes(".")?z.slice(M.length+1):""):J.get(z)}else X=J.get(z)}else X=z;if(X==null)return;let B=J?.generation??0;if(B!==S1)i0=new Map,S1=B;let K=i0.get(Z);if(!K)K=new Map,i0.set(Z,K);let L=K.get(_);if(!L){L=new Map;for(let M of Z)if(M!=null&&typeof M==="object"){let E=M[_];if(E!=null)L.set(String(E),M)}K.set(_,L)}return L.get(String(X))}case"dot":{if(Z==null||typeof Z!=="object"||typeof H!=="string")return;return Z[H]}case"length":return Array.isArray(Z)?Z.length:typeof Z==="string"?Z.length:0;case"upper":return typeof Z==="string"?Z.toUpperCase():Z;case"lower":return typeof Z==="string"?Z.toLowerCase():Z;case"truncate":if(typeof Z==="string"&&typeof H==="number")return Z.slice(0,H);return Z;case"join":return Array.isArray(Z)?Z.join(typeof H==="string"?H:", "):Z;case"first":return Array.isArray(Z)?Z[0]:Z;case"last":return Array.isArray(Z)?Z[Z.length-1]:Z;case"abs":return Math.abs(Number(Z));case"round":return typeof H==="number"?Number(Number(Z).toFixed(H)):Math.round(Number(Z));case"number":return typeof H==="number"?Number(Number(Z).toFixed(H)):Number(Z);case"currency":{let W=typeof H==="string"?H:"USD";try{return new Intl.NumberFormat("en-US",{style:"currency",currency:W}).format(Number(Z))}catch{return Z}}case"percent":return typeof H==="number"?`${(Number(Z)*100).toFixed(H)}%`:`${Math.round(Number(Z)*100)}%`;case"compact":{let W=typeof H==="number"?H:1;try{return new Intl.NumberFormat("en-US",{notation:"compact",maximumFractionDigits:W}).format(Number(Z))}catch{return Z}}case"date":try{return new Date(Z).toLocaleDateString()}catch{return Z}case"time":try{return new Date(Z).toLocaleTimeString()}catch{return Z}case"datetime":try{return new Date(Z).toLocaleString()}catch{return Z}case"pluralize":{let W=Number(Z),_=typeof H==="string"?H:"";return W===1?_:`${_}s`}case"default":return Z==null||Z===""?H:Z;case"selectattr":return Array.isArray(Z)&&typeof H==="string"?Z.filter((W)=>W!=null&&typeof W==="object"&&Boolean(W[H])):Z;case"rejectattr":return Array.isArray(Z)&&typeof H==="string"?Z.filter((W)=>{if(W==null||typeof W!=="object")return!1;let _=W[H];return _==null||_===!1||_===0||_===""}):Z;default:{let W=f1(Y);if(W){let _=U?C1(U).map(s0):[];return W(Z,..._)}return Z}}}var y4=[["!==",($,Z)=>$!==Z],["===",($,Z)=>$===Z],["!=",($,Z)=>$!=Z],["==",($,Z)=>$==Z],[">=",($,Z)=>Number($)>=Number(Z)],["<=",($,Z)=>Number($)<=Number(Z)],[">",($,Z)=>Number($)>Number(Z)],["<",($,Z)=>Number($)<Number(Z)]],m4=[[" + ",($,Z)=>$+Z],[" - ",($,Z)=>$-Z],[" * ",($,Z)=>$*Z],[" / ",($,Z)=>Z!==0?$/Z:0],[" % ",($,Z)=>Z!==0?$%Z:0]];function L0($,Z){let J=null;for(let q=0;q<$.length;q++){let Q=$[q];if(Q==="'"||Q==='"')J=J===Q?null:J??Q;if(!J&&$.slice(q,q+Z.length)===Z)return q}return-1}function h4($){let Z=0,J=null;for(let q=0;q<$.length;q++){let Q=$[q];if(Q==="'"||Q==='"')J=J===Q?null:J??Q;if(!J){if(Q==="(")Z++;else if(Q===")")Z--;else if(Q==="?"&&Z===0)return q}}return-1}function v4($){let Z=0,J=null;for(let q=0;q<$.length;q++){let Q=$[q];if(Q==="'"||Q==='"')J=J===Q?null:J??Q;if(!J){if(Q==="?"||Q==="(")Z++;else if(Q===")")Z--;else if(Q===":"&&Z===0)return q}}return-1}function g4($){let Z=[],J="",q=null;for(let Q=0;Q<$.length;Q++){let Y=$[Q];if(Y==="'"||Y==='"')q=q===Y?null:q??Y;if(Y==="|"&&!q)if($[Q+1]==="|")J+="||",Q++;else Z.push(J),J="";else J+=Y}return Z.push(J),Z}function s0($){let Z=$.replace(/^['"]|['"]$/g,"");if(Z==="true")return!0;if(Z==="false")return!1;let J=Number(Z);return isNaN(J)?Z:J}function C1($){let Z=[],J="",q=null;for(let Q of $){if(Q==="'"||Q==='"')q=q===Q?null:q??Q;if(Q===","&&!q)Z.push(J),J="";else J+=Q}return Z.push(J),Z}function V0($,Z){if(!Z)return $;let J=Z.split("."),q=$;for(let Q of J){if(q==null||typeof q!=="object")return;q=q[Q]}return q}function u4($,Z){let J=0,q=0;while((q=$.indexOf(Z,q))!==-1)J++,q+=Z.length;return J}function D0($){return $.replace(/_([a-z])/g,(Z,J)=>J.toUpperCase())}function r0($){let Z={};for(let[J,q]of Object.entries($)){let Q=J.startsWith("$")?J:D0(J);if(Array.isArray(q))Z[Q]=q.map((Y)=>Y!=null&&typeof Y==="object"&&!Array.isArray(Y)?r0(Y):Y);else if(q!=null&&typeof q==="object"&&!Array.isArray(q))Z[Q]=r0(q);else Z[Q]=q}return Z}async function m($,Z){let J=Array.isArray($)?$:[$];for(let q of J)await x4(q,Z)}function h($,Z){$.catch((J)=>C.error(`${Z} failed:`,J))}async function I0($,Z,J,q){if(J!=null)C.debug(`${$} failed:`,Z),await H0(J,q,{$error:Z});else C.warn(`${$} failed:`,Z)}async function x4($,Z){let J=r0($),q=J.action;switch(q){case"setState":{p4(J,Z);return}case"toggleState":{c4(J,Z);return}case"appendState":{l4(J,Z);return}case"popState":{d4(J,Z);return}case"showToast":{i4(J,Z);return}case"closeOverlay":{s4(J,Z);return}case"openLink":{n4(J);return}case"setInterval":{a4(J,Z);return}case"toolCall":case"callTool":return o4(J,Z);case"sendMessage":return t4(J,Z);case"updateContext":{e4(J,Z);return}case"fetch":return $8(J,Z);case"openFilePicker":{Z8(J,Z);return}case"callHandler":return J8(J,Z);case"requestDisplayMode":{q8(J,Z);return}case"subscribe":{U8(J,Z);return}case"unsubscribe":{H8(J);return}default:C.warn(`Unknown action: ${q}`)}}function p4($,Z){let{key:J,value:q}=$;if(o(q))q=t(q,Z.store,Z.scope);Z.store.set(J,q),Z.rerender(),H0($.onSuccess,Z)}function c4($,Z){Z.store.toggle($.key),Z.rerender()}function l4($,Z){let J=$.value??$.item;if(o(J))J=t(J,Z.store,Z.scope);Z.store.append($.key,J,$.index),Z.rerender()}function d4($,Z){Z.store.pop($.key,$.index),Z.rerender()}function i4($,Z){Z.onToast?.({message:T0($.message,Z),description:$.description!=null?T0($.description,Z):void 0,variant:$.variant,duration:$.duration})}function s4($,Z){if(typeof document<"u")document.dispatchEvent(new CustomEvent("prefab:close-overlay"))}function n4($){if(typeof window<"u"){let Z=$.url;if(!Z){C.warn("openLink: missing url");return}if(!h1(Z)){C.warn(`Blocked unsafe URL scheme: ${Z}`);return}window.open(Z,$.target??"_blank")}}var O0=new Set,r4=20,b1=100;function a4($,Z){let J=Math.max($.intervalMs,b1),q=$.onTick;if(typeof globalThis.setInterval!=="function")return;if(O0.size>=r4){C.warn("Max intervals reached, ignoring new setInterval");return}let Q=globalThis.setInterval(()=>h(m(q,Z),"interval action"),J);O0.add(Q)}function y1(){for(let $ of O0)globalThis.clearInterval($);O0.clear()}async function o4($,Z){if(!Z.transport){C.warn("No MCP transport configured for toolCall");return}let J=$.tool,q=a0($.arguments,Z);try{let Q=await Z.transport.callTool(J,q);if($.resultKey!=null)Z.store.set($.resultKey,Q);let Y=P0(Q);if(Y&&Z.remount)Z.remount(Y);else R0(Q,Z),Z.rerender();await H0($.onSuccess,Z,{$result:Q})}catch(Q){await I0("toolCall",Q,$.onError,Z)}}async function t4($,Z){if(!Z.transport){C.warn("No MCP transport configured for sendMessage");return}await Z.transport.sendMessage(T0($.message,Z))}function e4($,Z){let J=$.context;if(J!=null)Z.store.merge(J),Z.rerender()}async function $8($,Z){let J=T0($.url,Z);if(!h1(J)){C.warn(`Blocked unsafe URL in fetch: ${J}`);return}let q=$.method??"GET",Q=$.headers,Y=$.body!==void 0?JSON.stringify($.body):void 0;try{let U=await globalThis.fetch(J,{method:q,headers:{"Content-Type":"application/json",...Q},...Y&&{body:Y}}),H=await U.json().catch(()=>U.text());if($.resultKey!=null)Z.store.set($.resultKey,H);let W=P0(H);if(W&&Z.remount)Z.remount(W);else R0(H,Z),Z.rerender();await H0($.onSuccess,Z,{$result:H})}catch(U){await I0("fetch",U,$.onError,Z)}}function Z8($,Z){if(typeof document>"u")return;let J=document.createElement("input");if(J.type="file",$.accept!=null)J.accept=$.accept;if($.multiple===!0)J.multiple=!0;J.addEventListener("change",()=>{let q=Array.from(J.files??[]);if($.resultKey!=null)Z.store.set($.resultKey,q);Z.rerender(),H0($.onSuccess,Z,{$result:q})}),J.click()}async function J8($,Z){let J=$.handler,q=a0($.arguments,Z);if(!Z.transport){C.warn(`No transport configured for callHandler: ${J}`);return}try{let Q=await Z.transport.callTool(J,q);if($.resultKey!=null)Z.store.set($.resultKey,Q);let Y=P0(Q);if(Y&&Z.remount)Z.remount(Y);else R0(Q,Z),Z.rerender();await H0($.onSuccess,Z,{$result:Q})}catch(Q){await I0("callHandler",Q,$.onError,Z)}}function q8($,Z){if(typeof document<"u")document.dispatchEvent(new CustomEvent("prefab:request-display-mode",{detail:{mode:$.mode}}))}var q0=new Map,Q8=50,Y8=2000;function U8($,Z){let{uri:J,stateKey:q}=$;if(!J||!q){C.warn("subscribe: missing uri or stateKey");return}if(q0.has(J))return;if(q0.size>=Q8){C.warn("Max subscriptions reached, ignoring new subscribe");return}let Q=(X)=>{let B=P0(X);if(B&&Z.remount)Z.remount(B);else{if(!R0(X,Z))Z.store.set(q,X);Z.rerender()}H0($.onData,Z,{$data:X})};if(Z.transport?.subscribe&&Z.transport.capabilities?.subscriptions){let X=Z.transport.subscribe(J,Q);q0.set(J,X);return}let Y=$.fallbackTool,U=$.fallbackInterval??Y8;if(!Y){C.warn("subscribe: host lacks subscriptions and no fallbackTool specified");return}if(!Z.transport){C.warn("No MCP transport configured for subscribe fallback");return}let H=$.fallbackArgs??{},W=Math.max(U,b1),_=Z.transport,z=globalThis.setInterval(()=>{(async()=>{try{let X=a0(H,Z),B=await _.callTool(Y,X);Q(B)}catch(X){I0("subscribe",X,$.onError,Z)}})()},W);q0.set(J,()=>globalThis.clearInterval(z))}function H8($){let Z=$.uri;if(!Z){C.warn("unsubscribe: missing uri");return}let J=q0.get(Z);if(J)J(),q0.delete(Z)}function m1(){for(let[$,Z]of q0)try{Z()}catch(J){C.warn(`Error cleaning up subscription '${$}':`,J)}q0.clear()}function P0($){if($==null||typeof $!=="object")return null;let Z=$;if("$prefab"in Z&&"view"in Z)return Z;if("structuredContent"in Z){let J=Z.structuredContent;if(J!=null&&typeof J==="object"){let q=J;if("$prefab"in q&&"view"in q)return q}}if("content"in Z&&Array.isArray(Z.content)){for(let J of Z.content)if(J.type==="text"&&typeof J.text==="string")try{let q=JSON.parse(J.text);if(q!=null&&typeof q==="object"){let Q=q;if("$prefab"in Q&&"view"in Q)return Q}}catch{}}return null}function W8($){if($==null||typeof $!=="object")return null;let Z=$;if(n0(Z))return Z;if("structuredContent"in Z){let J=Z.structuredContent;if(J!=null&&typeof J==="object"&&n0(J))return J}if("content"in Z&&Array.isArray(Z.content)){for(let J of Z.content)if(J.type==="text"&&typeof J.text==="string")try{let q=JSON.parse(J.text);if(q!=null&&typeof q==="object"&&n0(q))return q}catch{}}return null}function n0($){if(!("$prefab"in $)||!("update"in $))return!1;let Z=$.update;return Z!=null&&typeof Z==="object"&&"state"in Z}function R0($,Z){let J=W8($);if(!J)return!1;let q=J.update;if(Z.store.merge(q.state),q.actions!=null)h(m(q.actions,Z),"update action");return!0}var X8=/^\s*(javascript|vbscript|data):/i;function h1($){return!X8.test($)}function T0($,Z){if(o($)){let J=t($,Z.store,Z.scope);return J==null?"":String(J)}return $==null?"":String($)}function a0($,Z){if(!$)return{};let J={};for(let[q,Q]of Object.entries($))J[q]=o(Q)?t(Q,Z.store,Z.scope):Q;return J}async function H0($,Z,J){if($==null)return;let q={...Z.scope,...J};await m($,{...Z,scope:q})}function t0($){let Z={};for(let[J,q]of Object.entries($)){let Q=J.startsWith("$")?J:D0(J);if(Array.isArray(q))Z[Q]=q.map((Y)=>Y!=null&&typeof Y==="object"&&!Array.isArray(Y)?t0(Y):Y);else if(q!=null&&typeof q==="object"&&!Array.isArray(q))Z[Q]=t0(q);else Z[Q]=q}return Z}class $1{callbacks=[];track($){this.callbacks.push($)}flush(){for(let $ of this.callbacks)try{$()}catch(Z){C.warn("destroy callback error:",Z)}this.callbacks=[]}get size(){return this.callbacks.length}}function G8($){return typeof $==="object"&&"element"in $}var e0=new Map;function G($,Z){if(e0.has($))C.warn(`overriding existing renderer for "${$}"`);e0.set($,Z)}function g($,Z){let J=t0($);if(Z.defs?.[J.type]){let Y={...Z.defs[J.type],...J,type:Z.defs[J.type].type};return g(Y,Z)}let q=e0.get(J.type),Q;if(q){let Y=q(J,Z);if(G8(Y))Q=Y.element,Z.destroyRegistry?.track(Y.destroy);else Q=Y}else if(Q=document.createElement("div"),Q.setAttribute("data-prefab-type",J.type),J.children)for(let Y of J.children)Q.appendChild(g(Y,Z));if(Q instanceof HTMLElement){if(J.id)Q.id=J.id;if(J.cssClass){let Y=F(J.cssClass,Z);if(Y)Q.className=(Q.className?Q.className+" ":"")+Y}if(J.onClick!=null){if(Q.addEventListener("click",()=>{h(m(J.onClick,l(Z)),"onClick")}),Q.tagName!=="BUTTON"&&Q.tagName!=="A")Q.setAttribute("role","button"),Q.setAttribute("tabindex","0"),Q.addEventListener("keydown",(Y)=>{let U=Y.key;if(U==="Enter"||U===" ")Y.preventDefault(),h(m(J.onClick,l(Z)),"onClick")})}}if(J.onMount){let Y=J.onMount,U=l(Z);queueMicrotask(()=>h(m(Y,U),"onMount"))}return Q}function w($,Z,J){if(!$.children)return;Q0($.children,Z,J)}function Q0($,Z,J){let q=0;while(q<$.length){let Q=$[q];if(Q.type==="If")q=B8($,q,Z,J);else if(Q.type==="Elif"||Q.type==="Else")q++;else Z.appendChild(g(Q,J)),q++}}function B8($,Z,J,q){let Q=!1,Y=Z,U=$[Y];if(v1(U.condition,q))o0(U,J,q),Q=!0;Y++;while(Y<$.length){let H=$[Y];if(H.type==="Elif"){if(!Q&&v1(H.condition,q))o0(H,J,q),Q=!0;Y++}else if(H.type==="Else"){if(!Q)o0(H,J,q);Y++;break}else break}return Y}function v1($,Z){if(!$)return!1;if(o($))return Boolean(t($,Z.store,Z.scope));return Boolean(Z.store.get($))}function o0($,Z,J){if(!$.children)return;Q0($.children,Z,J)}function F($,Z){if(o($)){let J=t($,Z.store,Z.scope);return J==null?"":String(J)}return $==null?"":String($)}function c($,Z){if(o($))return t($,Z.store,Z.scope);return $}function l($){return{store:$.store,transport:$.transport,scope:$.scope,rerender:$.rerender,onToast:$.onToast,remount:$.remount}}function N($,Z){let J=document.createElement($);if(Z)J.className=Z;return J}function Z1($,Z){return $.textContent=Z,$}function p1(){G("Column",M8),G("Row",_8),G("Grid",g1),G("GridItem",u1),G("Container",N8),G("Div",x1),G("Span",z8),G("Dashboard",g1),G("DashboardItem",u1),G("Pages",E8),G("Page",x1),G("Detail",K8),G("MasterDetail",F8)}function M8($,Z){let J=N("div","pf-column");J.style.display="flex",J.style.flexDirection="column";let q=j0($);if(q!=null)J.style.gap=`${q*4}px`;if($.align!=null)J.style.alignItems=c1($.align);if($.justify!=null)J.style.justifyContent=l1($.justify);return w($,J,Z),J}function _8($,Z){let J=N("div","pf-row");J.style.display="flex",J.style.flexDirection="row";let q=j0($);if(q!=null)J.style.gap=`${q*4}px`;if($.align!=null)J.style.alignItems=c1($.align);if($.justify!=null)J.style.justifyContent=l1($.justify);if($.wrap===!0)J.style.flexWrap="wrap";return w($,J,Z),J}function g1($,Z){let J=N("div","pf-grid");J.style.display="grid";let q=$.columns??3;J.style.gridTemplateColumns=`repeat(${q}, 1fr)`;let Q=j0($);if(Q!=null)J.style.gap=`${Q*4}px`;return w($,J,Z),J}function u1($,Z){let J=N("div","pf-grid-item");if($.colSpan!=null)J.style.gridColumn=`span ${$.colSpan}`;if($.rowSpan!=null)J.style.gridRow=`span ${$.rowSpan}`;return w($,J,Z),J}function N8($,Z){let J=N("div","pf-container");if(J.style.maxWidth=$.maxWidth??"1200px",J.style.margin="0 auto",$.padding!=null)J.style.padding=`${$.padding*4}px`;return w($,J,Z),J}function x1($,Z){let J=N("div","pf-div");return w($,J,Z),J}function z8($,Z){let J=N("span","pf-span");return w($,J,Z),J}function E8($,Z){let J=N("div","pf-pages");return w($,J,Z),J}function K8($,Z){let J=N("div","pf-detail"),q=$.of!=null?c($.of,Z):void 0;if(q!=null&&q!==""&&q!==!1&&q!==0)w($,J,Z);else if($.empty!=null){let Q=$.empty;J.appendChild(g(Q,Z))}return J}function F8($,Z){let J=N("div","pf-master-detail");J.style.display="flex",J.style.flexDirection="row";let q=j0($);if(q!=null)J.style.gap=`${q*4}px`;let Q=$.masterWidth??"33%",Y=$.children??[];if(Y.length>0){let U=N("div","pf-master-detail-master");U.style.width=Q,U.style.flexShrink="0",U.style.overflow="auto",U.appendChild(g(Y[0],Z)),J.appendChild(U)}if(Y.length>1){let U=N("div","pf-master-detail-detail");U.style.flex="1",U.style.overflow="auto",U.appendChild(g(Y[1],Z)),J.appendChild(U)}return J}var L8=/\bgap-(\d+)\b/;function j0($){if($.gap!=null)return $.gap;if(typeof $.cssClass==="string"){let Z=L8.exec($.cssClass);if(Z)return Number(Z[1])}return null}function c1($){return{start:"flex-start",end:"flex-end",center:"center",stretch:"stretch",baseline:"baseline"}[$]??$}function l1($){return{start:"flex-start",end:"flex-end",center:"center",between:"space-between",around:"space-around",evenly:"space-evenly"}[$]??$}function i1(){G("Heading",V8),G("H1",($,Z)=>k0($,Z,"h1")),G("H2",($,Z)=>k0($,Z,"h2")),G("H3",($,Z)=>k0($,Z,"h3")),G("H4",($,Z)=>k0($,Z,"h4")),G("Text",D8),G("P",O8),G("Lead",($,Z)=>_0($,Z,"p","pf-lead")),G("Large",($,Z)=>_0($,Z,"span","pf-large")),G("Small",($,Z)=>_0($,Z,"small","pf-small")),G("Muted",($,Z)=>_0($,Z,"p","pf-muted")),G("BlockQuote",($,Z)=>_0($,Z,"blockquote","pf-blockquote")),G("Label",($,Z)=>_0($,Z,"label","pf-label")),G("Link",I8),G("Code",P8),G("Markdown",R8),G("Kbd",j8)}function V8($,Z){let J=$.level??2,q=`h${Math.min(Math.max(J,1),6)}`,Q=document.createElement(q);return Q.className=`pf-heading pf-${q}`,Q.textContent=F($.content,Z),Q}function k0($,Z,J){let q=document.createElement(J);return q.className=`pf-heading pf-${J}`,q.textContent=F($.content,Z),q}function D8($,Z){return Z1(N("span","pf-text"),F($.content,Z))}function O8($,Z){return Z1(N("p","pf-p"),F($.content,Z))}function _0($,Z,J,q){let Q=document.createElement(J);return Q.className=q,Q.textContent=F($.content,Z),Q}var T8=/^\s*(javascript|vbscript|data):/i;function I8($,Z){let J=document.createElement("a");if(J.className="pf-link",J.textContent=F($.content,Z),$.href!=null){let q=F($.href,Z);if(!T8.test(q))J.href=q}if($.target!=null)J.target=F($.target,Z);return J}function P8($,Z){let J=N("pre","pf-code"),q=N("code");if(q.textContent=F($.content,Z),$.language!=null)q.setAttribute("data-language",$.language);return J.appendChild(q),J}function R8($,Z){let J=N("div","pf-markdown"),q=F($.content,Z);return J.innerHTML=s1(q),J.setAttribute("data-markdown","true"),J}var d1=/^\s*(javascript|vbscript|data):/i;function f0($){return $.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;")}function A0($){let Z=f0($),J=[];return Z=Z.replace(/`([^`]+)`/g,(q,Q)=>{return J.push(`<code>${Q}</code>`),`﷐CODE${J.length-1}﷐`}),Z=Z.replace(/!\[([^\]]*)\]\(([^)]+)\)/g,(q,Q,Y)=>{if(d1.test(Y))return f0(Q);return`<img src="${Y}" alt="${Q}" />`}),Z=Z.replace(/\[([^\]]+)\]\(([^)]+)\)/g,(q,Q,Y)=>{if(d1.test(Y))return Q;return`<a href="${Y}">${Q}</a>`}),Z=Z.replace(/\*{3}(.+?)\*{3}/g,"<strong><em>$1</em></strong>"),Z=Z.replace(/_{3}(.+?)_{3}/g,"<strong><em>$1</em></strong>"),Z=Z.replace(/\*{2}(.+?)\*{2}/g,"<strong>$1</strong>"),Z=Z.replace(/_{2}(.+?)_{2}/g,"<strong>$1</strong>"),Z=Z.replace(/\*(.+?)\*/g,"<em>$1</em>"),Z=Z.replace(/(?<!\w)_(.+?)_(?!\w)/g,"<em>$1</em>"),Z=Z.replace(/~~(.+?)~~/g,"<del>$1</del>"),Z=Z.replace(/\uFDD0CODE(\d+)\uFDD0/g,(q,Q)=>J[parseInt(Q)]),Z}function s1($){let Z=$.replace(/\r\n?/g,`
2
2
  `).split(`
3
- `),J=[],q=0;while(q<Z.length){let Q=Z[q];if(Q.trimStart().startsWith("```")){let H=Q.trimStart().slice(3).trim(),W=[];q++;while(q<Z.length&&!Z[q].trimStart().startsWith("```"))W.push(A0(Z[q])),q++;q++;let N=H?` data-language="${A0(H)}"`:"";J.push(`<pre class="pf-code"><code${N}>${W.join(`
4
- `)}</code></pre>`);continue}if(/^(\s*[-*_]\s*){3,}$/.test(Q)){J.push("<hr />"),q++;continue}let Y=/^(#{1,6})\s+(.+)$/.exec(Q);if(Y){let H=Y[1].length;J.push(`<h${H}>${j0(Y[2])}</h${H}>`),q++;continue}if(Q.startsWith("> ")||Q===">"){let H=[];while(q<Z.length&&(Z[q].startsWith("> ")||Z[q]===">"))H.push(Z[q].replace(/^>\s?/,"")),q++;J.push(`<blockquote>${d1(H.join(`
5
- `))}</blockquote>`);continue}if(/^[\s]*[-*+]\s+/.test(Q)){J.push("<ul>");while(q<Z.length&&/^[\s]*[-*+]\s+/.test(Z[q]))J.push(`<li>${j0(Z[q].replace(/^[\s]*[-*+]\s+/,""))}</li>`),q++;J.push("</ul>");continue}if(/^[\s]*\d+\.\s+/.test(Q)){J.push("<ol>");while(q<Z.length&&/^[\s]*\d+\.\s+/.test(Z[q]))J.push(`<li>${j0(Z[q].replace(/^[\s]*\d+\.\s+/,""))}</li>`),q++;J.push("</ol>");continue}if(Q.trim()===""){q++;continue}let U=[];while(q<Z.length&&Z[q].trim()!==""&&!/^#{1,6}\s/.test(Z[q])&&!/^[-*+]\s/.test(Z[q])&&!/^\d+\.\s/.test(Z[q])&&!Z[q].startsWith("> ")&&!Z[q].trimStart().startsWith("```")&&!/^(\s*[-*_]\s*){3,}$/.test(Z[q]))U.push(Z[q]),q++;J.push(`<p>${U.map(j0).join("<br />")}</p>`)}return J.join(`
6
- `)}function P8($,Z){let J=document.createElement("kbd");return J.className="pf-kbd",J.textContent=K($.content,Z),J}function s1(){G("Card",R8),G("CardHeader",$1("pf-card-header")),G("CardTitle",i1("pf-card-title","h3")),G("CardDescription",i1("pf-card-description","p")),G("CardContent",$1("pf-card-content")),G("CardFooter",$1("pf-card-footer"))}function R8($,Z){let J=_("div","pf-card");return J.style.overflow="hidden",w($,J,Z),J}function $1($){return(Z,J)=>{let q=_("div",$);return q.style.padding="16px 24px",w(Z,q,J),q}}function i1($,Z){return(J,q)=>{let Q=document.createElement(Z);return Q.className=$,Q.textContent=K(J.content,q),Q}}function n1(){G("DataTable",j8),G("Badge",A8),G("Dot",k8),G("Metric",f8),G("Ring",S8),G("Progress",w8),G("Separator",C8),G("Loader",b8),G("Icon",y8),G("Sparkline",m8)}function j8($,Z){let J=_("div","pf-datatable-wrapper"),q=document.createElement("table");q.className="pf-datatable",q.style.width="100%",q.style.borderCollapse="collapse";let Q=$.columns??[],Y=p($.rows,Z),U=$.rowKey,H=$.selected,W=document.createElement("thead"),N=document.createElement("tr");for(let X of Q){let B=document.createElement("th");B.className="pf-datatable-th",B.textContent=X.header??X.key,B.style.padding="8px 12px",B.style.textAlign="left",N.appendChild(B)}W.appendChild(N),q.appendChild(W);let E=document.createElement("tbody");if(Array.isArray(Y)){let X=H!=null?p(H,Z):void 0;for(let B of Y){let z=document.createElement("tr");z.className="pf-datatable-row";let L=B,M=B===null||typeof B!=="object";if(U&&X!=null&&L[U]!=null&&String(L[U])===String(X))z.classList.add("pf-datatable-row-selected");if($.onRowClick!=null&&U)z.style.cursor="pointer",z.addEventListener("click",()=>{let F={...Z.scope,$item:L,$index:Y.indexOf(B)},D=c({...Z,scope:F});m($.onRowClick,D)});for(let F of Q){let D=document.createElement("td");D.className="pf-datatable-td";let I;if(F.accessor)I=p(`{{ $item.${F.accessor} }}`,{...Z,scope:{...Z.scope,$item:L}});else if(I=M?B:L[F.key],F.format&&I!=null)I=p(`{{ __fmtVal | ${F.format} }}`,{...Z,scope:{...Z.scope,__fmtVal:I}});D.textContent=I==null?"":String(I),D.style.padding="8px 12px",z.appendChild(D)}E.appendChild(z)}}if(q.appendChild(E),$.search===!0){let X=document.createElement("input");X.type="text",X.placeholder="Search...",X.className="pf-datatable-search",X.style.marginBottom="8px",X.style.padding="6px 12px",X.style.width="100%",X.style.boxSizing="border-box",X.addEventListener("input",()=>{let B=X.value.toLowerCase(),z=Array.from(E.querySelectorAll("tr"));for(let L of z){let M=(L.textContent??"").toLowerCase();L.style.display=M.includes(B)?"":"none"}}),J.appendChild(X)}return J.appendChild(q),J}function A8($,Z){let J=_("span","pf-badge"),q=$.variant??"default";return J.setAttribute("data-variant",q),J.style.alignItems="center",J.style.padding="2px 10px",J.style.borderRadius="9999px",J.style.fontSize="12px",J.style.fontWeight="500",J.textContent=K($.label??$.content,Z),h8(J,q),J}function k8($,Z){let J=_("span","pf-dot"),q=$.color??"gray";return J.style.display="inline-block",J.style.width="8px",J.style.height="8px",J.style.borderRadius="50%",J.style.backgroundColor=q,J}function f8($,Z){let J=_("div","pf-metric"),q=_("div","pf-metric-label");q.textContent=K($.label,Z),q.style.fontSize="14px",J.appendChild(q);let Q=_("div","pf-metric-value");if(Q.textContent=K($.value,Z),Q.style.fontSize="28px",Q.style.fontWeight="700",J.appendChild(Q),$.delta!=null){let Y=_("span","pf-metric-delta");Y.textContent=K($.delta,Z);let U=$.trend??"",H=$.trendSentiment??"neutral";if(Y.style.fontSize="14px",Y.style.color=H==="positive"?"green":H==="negative"?"red":"inherit",U==="up")Y.textContent="↑ "+Y.textContent;else if(U==="down")Y.textContent="↓ "+Y.textContent;J.appendChild(Y)}if($.description!=null){let Y=_("div","pf-metric-desc");Y.textContent=K($.description,Z),Y.style.fontSize="12px",J.appendChild(Y)}return J}function S8($,Z){let J=_("div","pf-ring"),q=$.size??80,Q=$.thickness??8,Y=Number(p($.value,Z)??0),U=Math.max(0,Math.min(100,Y)),H=(q-Q)/2,W=2*Math.PI*H,N=W*(1-U/100),E=document.createElementNS("http://www.w3.org/2000/svg","svg");E.setAttribute("width",String(q)),E.setAttribute("height",String(q)),E.setAttribute("viewBox",`0 0 ${q} ${q}`);let X=document.createElementNS("http://www.w3.org/2000/svg","circle");X.setAttribute("cx",String(q/2)),X.setAttribute("cy",String(q/2)),X.setAttribute("r",String(H)),X.setAttribute("fill","none"),X.setAttribute("stroke","var(--muted, #e5e7eb)"),X.setAttribute("stroke-width",String(Q));let B=document.createElementNS("http://www.w3.org/2000/svg","circle");if(B.setAttribute("cx",String(q/2)),B.setAttribute("cy",String(q/2)),B.setAttribute("r",String(H)),B.setAttribute("fill","none"),B.setAttribute("stroke","var(--primary, #3b82f6)"),B.setAttribute("stroke-width",String(Q)),B.setAttribute("stroke-dasharray",String(W)),B.setAttribute("stroke-dashoffset",String(N)),B.setAttribute("stroke-linecap","round"),B.style.transform="rotate(-90deg)",B.style.transformOrigin="center",E.appendChild(X),E.appendChild(B),J.appendChild(E),$.label!=null){let z=_("div","pf-ring-label");z.textContent=K($.label,Z),z.style.textAlign="center",z.style.fontSize="12px",J.appendChild(z)}return J}function w8($,Z){let J=_("div","pf-progress");J.setAttribute("role","progressbar");let q=Number(p($.value,Z)??0),Q=$.max??100,Y=Q>0?Math.max(0,Math.min(100,q/Q*100)):0;J.setAttribute("aria-valuenow",String(q)),J.setAttribute("aria-valuemin","0"),J.setAttribute("aria-valuemax",String(Q)),J.style.height="8px",J.style.borderRadius="4px",J.style.overflow="hidden";let U=_("div","pf-progress-fill");return U.style.height="100%",U.style.width=`${Y}%`,U.style.borderRadius="4px",U.style.transition="width 0.3s ease",J.appendChild(U),J}function C8($,Z){let J=document.createElement("hr");return J.className="pf-separator",J.style.border="none",J.style.margin="8px 0",J}function b8($,Z){let J=_("div","pf-loader");return J.textContent="⏳",J.style.display="flex",J.style.justifyContent="center",J.style.padding="16px",J}function y8($,Z){let J=_("span","pf-icon");return J.setAttribute("data-icon",K($.name??$.content,Z)),J}function m8($,Z){let J=_("div","pf-sparkline"),q=$.data??[];if(q.length===0)return J;let Q=120,Y=32,U=Math.max(...q),H=Math.min(...q),W=U-H||1,N=document.createElementNS("http://www.w3.org/2000/svg","svg");N.setAttribute("width",String(Q)),N.setAttribute("height",String(Y)),N.setAttribute("viewBox",`0 0 ${Q} ${Y}`);let E=q.length>1?q.length-1:1,X=q.map((z,L)=>{let M=L/E*Q,F=Y-(z-H)/W*(Y-4)-2;return`${M},${F}`}).join(" "),B=document.createElementNS("http://www.w3.org/2000/svg","polyline");return B.setAttribute("points",X),B.setAttribute("fill","none"),B.setAttribute("stroke","var(--primary, #3b82f6)"),B.setAttribute("stroke-width","1.5"),N.appendChild(B),J.appendChild(N),J}function h8($,Z){let q={success:{bg:"#10b981",fg:"#fff"},warning:{bg:"#f59e0b",fg:"#fff"},info:{bg:"#3b82f6",fg:"#fff"}}[Z];if(q)$.style.backgroundColor=q.bg,$.style.color=q.fg}function o1(){G("Form",v8),G("Input",g8),G("Textarea",u8),G("Button",x8),G("ButtonGroup",p8),G("Select",c8),G("SelectOption",l8),G("SelectGroup",k0("pf-select-group")),G("SelectLabel",F0("pf-select-label")),G("SelectSeparator",r1),G("Checkbox",d8),G("Switch",i8),G("Slider",s8),G("Radio",r8),G("RadioGroup",o8),G("Combobox",a8),G("ComboboxOption",t8),G("ComboboxGroup",k0("pf-combobox-group")),G("ComboboxLabel",F0("pf-combobox-label")),G("ComboboxSeparator",r1),G("Calendar",e8),G("DatePicker",$6),G("Field",k0("pf-field")),G("FieldTitle",F0("pf-field-title")),G("FieldDescription",F0("pf-field-description")),G("FieldContent",k0("pf-field-content")),G("FieldError",F0("pf-field-error")),G("ChoiceCard",Z6)}function v8($,Z){let J=document.createElement("form");return J.className="pf-form",J.addEventListener("submit",(q)=>{q.preventDefault();let Q=new FormData(J),Y={};if(Q.forEach((U,H)=>{Y[H]=U}),Z.store.merge(Y),$.onSubmit!=null){let U=c(Z);U.scope={...Z.scope,...Y},m($.onSubmit,U)}}),w($,J,Z),J}function g8($,Z){let J=_("div","pf-input-wrapper");if(J.style.display="flex",J.style.flexDirection="column",J.style.gap="4px",$.label!=null){let Y=document.createElement("label");if(Y.className="pf-input-label",Y.textContent=K($.label,Z),$.name!=null)Y.htmlFor=$.name;Y.style.fontSize="14px",Y.style.fontWeight="500",J.appendChild(Y)}let q=document.createElement("input");if(q.className="pf-input",q.type=$.inputType??"text",$.name!=null)q.name=$.name;if($.name!=null)q.id=`pf-input-${$.name}`;if($.placeholder!=null)q.placeholder=K($.placeholder,Z);if($.required===!0)q.required=!0,q.setAttribute("aria-required","true");if($.error!=null)q.setAttribute("aria-invalid","true");let Q=$.name;if(Q){let Y=Z.store.get(Q);if(Y!=null)q.value=String(Y);q.addEventListener("input",()=>{if(Z.store.set(Q,q.value),$.onChange!=null)m($.onChange,{...c(Z),scope:{...Z.scope,$event:q.value}})})}return Z1(q),J.appendChild(q),J}function u8($,Z){let J=_("div","pf-textarea-wrapper"),q=document.createElement("textarea");if(q.className="pf-textarea",$.name!=null)q.name=$.name;if($.name!=null)q.id=`pf-textarea-${$.name}`;if($.placeholder!=null)q.placeholder=K($.placeholder,Z);if($.rows!=null)q.rows=$.rows;if($.required===!0)q.setAttribute("aria-required","true");let Q=$.name;if(Q!=null){let Y=Z.store.get(Q);if(Y!=null)q.value=String(Y);q.addEventListener("input",()=>{if(Z.store.set(Q,q.value),$.onChange!=null)m($.onChange,{...c(Z),scope:{...Z.scope,$event:q.value}})})}return Z1(q),J.appendChild(q),J}function x8($,Z){let J=document.createElement("button");J.className="pf-button",J.type=$.submit===!0?"submit":"button",J.textContent=K($.label,Z);let q=$.variant??"default";if(J.setAttribute("data-variant",q),n8(J,q),$.size!=null)J.setAttribute("data-size",$.size);if($.disabled===!0)J.disabled=!0;return J}function p8($,Z){let J=_("div","pf-button-group");return J.style.display="flex",J.style.gap="8px",w($,J,Z),J}function c8($,Z){let J=_("div","pf-select-wrapper"),q=document.createElement("select");if(q.className="pf-select",$.name!=null)q.name=$.name;if(Z1(q),$.placeholder!=null){let U=document.createElement("option");U.value="",U.textContent=K($.placeholder,Z),U.disabled=!0,U.selected=!0,U.hidden=!0,q.appendChild(U)}let Q=$.options;if(Array.isArray(Q))for(let U of Q){let H=document.createElement("option");H.value=U.value??"",H.textContent=U.label??H.value,q.appendChild(H)}if($.children)for(let U of $.children)if(U.type==="SelectOption"){let H=document.createElement("option");H.value=U.value??"",H.textContent=U.label??H.value,q.appendChild(H)}else q.appendChild(x(U,Z));let Y=$.name;if(Y){let U=Z.store.get(Y);if(U!=null)q.value=String(U);q.addEventListener("change",()=>{if(Z.store.set(Y,q.value),$.onChange!=null)m($.onChange,{...c(Z),scope:{...Z.scope,$event:q.value}})})}return J.appendChild(q),J}function l8($,Z){return _("span")}function d8($,Z){let J=_("label","pf-checkbox-wrapper");J.style.display="flex",J.style.alignItems="center",J.style.gap="8px",J.style.cursor="pointer";let q=document.createElement("input");if(q.type="checkbox",q.className="pf-checkbox",$.name!=null)q.name=$.name;if($.checked===!0)q.checked=!0;let Q=$.name;if(Q){let Y=Z.store.get(Q);if(typeof Y==="boolean")q.checked=Y;q.addEventListener("change",()=>{if(Z.store.set(Q,q.checked),$.onChange!=null)m($.onChange,{...c(Z),scope:{...Z.scope,$event:q.checked}})})}if(J.appendChild(q),$.label!=null){let Y=_("span");Y.textContent=K($.label,Z),J.appendChild(Y)}return J}function i8($,Z){let J=_("label","pf-switch-wrapper");J.style.display="flex",J.style.alignItems="center",J.style.gap="8px",J.style.cursor="pointer";let q=document.createElement("input");if(q.type="checkbox",q.className="pf-switch",q.setAttribute("role","switch"),$.name!=null)q.name=$.name;let Q=$.name;if(Q){let Y=Z.store.get(Q);if(typeof Y==="boolean")q.checked=Y;q.addEventListener("change",()=>{if(Z.store.set(Q,q.checked),$.onChange!=null)m($.onChange,{...c(Z),scope:{...Z.scope,$event:q.checked}})})}if(J.appendChild(q),$.label!=null){let Y=_("span");Y.textContent=K($.label,Z),J.appendChild(Y)}return J}function s8($,Z){let J=_("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 Q=$.name;if(Q){let Y=Z.store.get(Q);if(Y!=null)q.value=String(Y);q.addEventListener("input",()=>{if(Z.store.set(Q,Number(q.value)),$.onChange!=null)m($.onChange,{...c(Z),scope:{...Z.scope,$event:Number(q.value)}})})}return J.appendChild(q),J}function Z1($){$.style.padding="8px 12px",$.style.fontSize="14px",$.style.width="100%",$.style.boxSizing="border-box"}function n8($,Z){if($.style.padding="8px 16px",$.style.fontSize="14px",$.style.fontWeight="500",$.style.cursor="pointer",$.style.border="none",Z==="ghost")$.style.backgroundColor="transparent",$.style.color="inherit"}function k0($){return(Z,J)=>{let q=_("div",$);return w(Z,q,J),q}}function F0($){return(Z,J)=>{let q=_("span",$);return q.textContent=K(Z.content,J),q}}function r1(){let $=document.createElement("hr");return $.className="pf-separator",$.style.border="none",$.style.margin="4px 0",$}function r8($,Z){let J=_("label","pf-radio");J.style.display="flex",J.style.alignItems="center",J.style.gap="8px",J.style.cursor="pointer";let q=document.createElement("input");if(q.type="radio",q.value=K($.value,Z),J.appendChild(q),$.label!=null){let Q=_("span","pf-radio-label");Q.textContent=K($.label,Z),J.appendChild(Q)}return J}function o8($,Z){let J=_("fieldset","pf-radio-group");if(J.style.border="none",J.style.padding="0",J.style.display="flex",J.style.flexDirection="column",J.style.gap="8px",$.label!=null){let Y=document.createElement("legend");Y.textContent=K($.label,Z),Y.style.fontWeight="500",Y.style.marginBottom="4px",J.appendChild(Y)}w($,J,Z);let q=K($.name,Z),Q=Z.store.get(q);for(let Y of Array.from(J.querySelectorAll('input[type="radio"]')))if(Y.name=q,Q!=null&&Y.value===String(Q))Y.checked=!0;return J.addEventListener("change",(Y)=>{let U=Y.target;if(U.type==="radio"){if(Z.store.set(q,U.value),$.onChange!=null)m($.onChange,c(Z))}}),J}function a8($,Z){let J=_("div","pf-combobox"),q=document.createElement("input");if(q.className="pf-combobox-input",q.type="text",q.name=K($.name,Z),$.placeholder!=null)q.placeholder=K($.placeholder,Z);if($.value!==void 0)q.value=K($.value,Z);let Q=q.name,Y=Z.store.get(Q);if(Y!=null)q.value=String(Y);q.style.padding="6px 12px",q.style.borderRadius="6px",q.style.width="100%",q.style.boxSizing="border-box";let U=_("div","pf-combobox-dropdown");if(U.style.display="none",U.style.position="absolute",U.style.borderRadius="6px",U.style.maxHeight="200px",U.style.overflowY="auto",U.style.zIndex="50",w($,U,Z),q.addEventListener("focus",()=>{U.style.display="block"}),q.addEventListener("blur",()=>{setTimeout(()=>{U.style.display="none"},150)}),$.searchable!==!1)q.addEventListener("input",()=>{let H=q.value.toLowerCase();for(let W of Array.from(U.querySelectorAll(".pf-combobox-option"))){let N=(W.textContent??"").toLowerCase();W.style.display=N.includes(H)?"":"none"}});if($.onChange!=null)J.addEventListener("pf-combobox-select",()=>{m($.onChange,{...c(Z),scope:{...Z.scope,$event:q.value}})});return J.style.position="relative",J.appendChild(q),J.appendChild(U),J}function t8($,Z){let J=_("div","pf-combobox-option");return J.style.padding="6px 12px",J.style.cursor="pointer",J.textContent=K($.label??$.value,Z),J.dataset.value=K($.value,Z),J.addEventListener("mousedown",()=>{let q=J.closest(".pf-combobox"),Q=q?.querySelector("input");if(Q)Q.value=J.dataset.value??"",Z.store.set(Q.name,Q.value),q?.dispatchEvent(new CustomEvent("pf-combobox-select",{bubbles:!1}))}),J}function e8($,Z){let J=_("div","pf-calendar"),q=document.createElement("input");if(q.type="date",q.name=K($.name,Z),$.value!==void 0)q.value=K($.value,Z);let Q=q.name,Y=Z.store.get(Q);if(Y!=null)q.value=String(Y);if($.minDate!=null)q.min=K($.minDate,Z);if($.maxDate!=null)q.max=K($.maxDate,Z);return q.style.padding="6px 12px",q.style.borderRadius="6px",q.addEventListener("change",()=>{if(Z.store.set(q.name,q.value),$.onChange!=null)m($.onChange,c(Z))}),J.appendChild(q),J}function $6($,Z){let J=_("div","pf-datepicker"),q=document.createElement("input");if(q.type="date",q.name=K($.name,Z),$.placeholder!=null)q.placeholder=K($.placeholder,Z);if($.value!==void 0)q.value=K($.value,Z);let Q=q.name,Y=Z.store.get(Q);if(Y!=null)q.value=String(Y);if($.minDate!=null)q.min=K($.minDate,Z);if($.maxDate!=null)q.max=K($.maxDate,Z);return q.style.padding="6px 12px",q.style.borderRadius="6px",q.style.width="100%",q.style.boxSizing="border-box",q.addEventListener("change",()=>{if(Z.store.set(q.name,q.value),$.onChange!=null)m($.onChange,c(Z))}),J.appendChild(q),J}function Z6($,Z){let J=_("div","pf-choice-card");if(J.style.padding="16px",J.style.cursor="pointer",J.style.transition="border-color 0.2s",J.dataset.value=K($.value,Z),$.selected===!0)J.dataset.selected="true";if($.label!=null){let q=_("div","pf-choice-card-label");q.textContent=K($.label,Z),q.style.fontWeight="600",J.appendChild(q)}if($.description!=null){let q=_("div","pf-choice-card-description");q.textContent=K($.description,Z),q.style.fontSize="14px",J.appendChild(q)}return w($,J,Z),J}function a1(){G("Tabs",J6),G("Tab",q6),G("Accordion",Q6),G("AccordionItem",Y6),G("Dialog",U6),G("Popover",H6),G("Tooltip",W6),G("HoverCard",X6),G("Carousel",G6)}function J6($,Z){let J=_("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 Q=[],Y=[];if($.children)for(let H=0;H<$.children.length;H++){let W=$.children[H],N=`pf-tab-${Math.random().toString(36).slice(2,8)}`,E=`pf-panel-${Math.random().toString(36).slice(2,8)}`,X=document.createElement("button");X.type="button",X.className="pf-tab-trigger",X.textContent=W.title??`Tab ${H+1}`,X.setAttribute("role","tab"),X.setAttribute("aria-selected",H===0?"true":"false"),X.setAttribute("aria-controls",E),X.id=N,X.tabIndex=H===0?0:-1,X.style.padding="8px 16px",X.style.border="none",X.style.background="none",X.style.cursor="pointer",X.style.borderBottom="2px solid transparent",X.style.marginBottom="-2px",X.style.fontSize="14px";let B=_("div","pf-tab-panel");if(B.style.display=H===0?"block":"none",B.setAttribute("role","tabpanel"),B.setAttribute("aria-labelledby",N),B.id=E,B.tabIndex=0,w(W,B,Z),X.addEventListener("click",()=>{U(H)}),H===0)X.classList.add("pf-tab-active"),X.style.fontWeight="600";Y.push(X),Q.push(B),q.appendChild(X)}function U(H){Q.forEach((W)=>W.style.display="none"),Y.forEach((W)=>{W.style.borderBottomColor="transparent",W.style.fontWeight="normal",W.classList.remove("pf-tab-active"),W.setAttribute("aria-selected","false"),W.tabIndex=-1}),Q[H].style.display="block",Y[H].classList.add("pf-tab-active"),Y[H].style.fontWeight="600",Y[H].setAttribute("aria-selected","true"),Y[H].tabIndex=0,Y[H].focus()}q.addEventListener("keydown",(H)=>{let W=Y.indexOf(H.target);if(W<0)return;let N;if(H.key==="ArrowRight")N=(W+1)%Y.length;else if(H.key==="ArrowLeft")N=(W-1+Y.length)%Y.length;else if(H.key==="Home")N=0;else if(H.key==="End")N=Y.length-1;else return;H.preventDefault(),U(N)}),J.appendChild(q);for(let H of Q)J.appendChild(H);return J}function q6($,Z){let J=_("div","pf-tab");return w($,J,Z),J}function Q6($,Z){let J=_("div","pf-accordion");return w($,J,Z),J}function Y6($,Z){let J=_("div","pf-accordion-item"),q=`pf-acc-${Math.random().toString(36).slice(2,8)}`,Q=document.createElement("button");Q.type="button",Q.className="pf-accordion-trigger",Q.textContent=$.title??"",Q.setAttribute("aria-expanded","false"),Q.setAttribute("aria-controls",q),Q.style.width="100%",Q.style.textAlign="left",Q.style.padding="12px 0",Q.style.border="none",Q.style.background="none",Q.style.cursor="pointer",Q.style.fontSize="14px",Q.style.fontWeight="500";let Y=_("div","pf-accordion-content");return Y.id=q,Y.setAttribute("role","region"),Y.setAttribute("aria-labelledby",Q.id),Y.style.display="none",Y.style.paddingBottom="12px",w($,Y,Z),Q.addEventListener("click",()=>{let U=Y.style.display!=="none";Y.style.display=U?"none":"block",Q.setAttribute("aria-expanded",U?"false":"true")}),J.appendChild(Q),J.appendChild(Y),J}function U6($,Z){let J=_("div","pf-dialog-wrapper");if($.trigger!=null){let Y=x($.trigger,Z);Y.addEventListener("click",()=>{q.showModal()}),J.appendChild(Y)}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 Y=_("h2","pf-dialog-title");Y.textContent=K($.title,Z),Y.id=`pf-dialog-title-${Math.random().toString(36).slice(2,8)}`,q.setAttribute("aria-labelledby",Y.id),q.appendChild(Y)}if($.description!=null){let Y=_("p","pf-dialog-desc");Y.textContent=K($.description,Z),q.appendChild(Y)}let Q=_("div","pf-dialog-body");if(w($,Q,Z),q.appendChild(Q),$.dismissible!==!1)q.addEventListener("click",(Y)=>{if(Y.target===q)q.close()});return document.addEventListener("prefab:close-overlay",()=>q.close()),J.appendChild(q),J}function H6($,Z){let J=_("div","pf-popover");J.style.position="relative",J.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 Q=_("div","pf-popover-title");Q.textContent=K($.title,Z),Q.style.fontWeight="600",Q.style.marginBottom="4px",q.appendChild(Q)}return w($,q,Z),J.addEventListener("click",(Q)=>{if(q.contains(Q.target)&&q.style.display!=="none")return;q.style.display=q.style.display==="none"?"block":"none"}),J.appendChild(q),J}function W6($,Z){let J=_("div","pf-tooltip");J.style.position="relative",J.style.display="inline-block";let q=`pf-tip-${Math.random().toString(36).slice(2,8)}`,Q=_("div","pf-tooltip-content");return Q.id=q,Q.setAttribute("role","tooltip"),Q.textContent=K($.content??"",Z),Q.style.display="none",Q.style.position="absolute",Q.style.bottom="100%",Q.style.left="50%",Q.style.transform="translateX(-50%)",Q.style.padding="4px 8px",Q.style.borderRadius="4px",Q.style.color="#fff",Q.style.fontSize="12px",Q.style.whiteSpace="nowrap",Q.style.zIndex="50",w($,J,Z),J.setAttribute("aria-describedby",q),J.addEventListener("mouseenter",()=>{Q.style.display="block"}),J.addEventListener("mouseleave",()=>{Q.style.display="none"}),J.addEventListener("focus",()=>{Q.style.display="block"},!0),J.addEventListener("blur",()=>{Q.style.display="none"},!0),J.appendChild(Q),J}function X6($,Z){let J=_("div","pf-hover-card");J.style.position="relative",J.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",w($,q,Z),J.addEventListener("mouseenter",()=>{q.style.display="block"}),J.addEventListener("mouseleave",()=>{q.style.display="none"}),J.appendChild(q),J}function G6($,Z){let J=_("div","pf-carousel");J.style.position="relative",J.style.overflow="hidden",J.setAttribute("role","region"),J.setAttribute("aria-roledescription","carousel"),J.setAttribute("aria-label",K($.label??"Carousel",Z));let q=_("div","pf-carousel-track");q.style.display="flex",q.style.transition="transform 0.3s ease",w($,q,Z);let Q=0,Y=$.children?.length??0,U=document.createElement("button");U.type="button",U.textContent="‹",U.className="pf-carousel-prev",U.setAttribute("aria-label","Previous slide"),U.style.position="absolute",U.style.left="4px",U.style.top="50%",U.style.transform="translateY(-50%)",U.style.zIndex="10";let H=document.createElement("button");H.type="button",H.textContent="›",H.className="pf-carousel-next",H.setAttribute("aria-label","Next slide"),H.style.position="absolute",H.style.right="4px",H.style.top="50%",H.style.transform="translateY(-50%)",H.style.zIndex="10";let W=()=>{q.style.transform=`translateX(-${Q*100}%)`};return U.addEventListener("click",()=>{if(Y===0)return;Q=Math.max(0,Q-1),W()}),H.addEventListener("click",()=>{if(Y===0)return;Q=Math.min(Y-1,Q+1),W()}),J.appendChild(q),J.appendChild(U),J.appendChild(H),J}function t1(){G("ForEach",B6),G("If",e1),G("Elif",M6),G("Else",_6),G("Condition",N6),G("Define",E6),G("Use",F6),G("Slot",z6)}function B6($,Z){let J=document.createDocumentFragment(),q=$.expression;if(!q)return J;let Q;if(o(q)){let U=a(q,Z.store,Z.scope);Q=Array.isArray(U)?U:[]}else{let U=Z.store.get(q);Q=Array.isArray(U)?U:[]}let Y=$.let??{};for(let U=0;U<Q.length;U++){let H=Q[U],W={...Z.scope,$item:H,$index:U,...Y},N={...Z,scope:W};if($.children)Q0($.children,J,N)}return J}function e1($,Z){if($4($.condition,Z)){let q=document.createDocumentFragment();if($.children)Q0($.children,q,Z);return q}return document.createDocumentFragment()}function M6($,Z){return e1($,Z)}function _6($,Z){let J=document.createDocumentFragment();if($.children)Q0($.children,J,Z);return J}function $4($,Z){if(!$)return!1;if(o($))return Boolean(a($,Z.store,Z.scope));return Boolean(Z.store.get($))}function N6($,Z){let J=document.createDocumentFragment(),q=$.cases,Q=$.else;if(q){for(let Y of q)if($4(Y.when,Z)){if(Y.children)Q0(Y.children,J,Z);return J}}if(Q)Q0(Q,J,Z);return J}function E6($,Z){let J=$.name;if(J&&$.children)Z.templates=Z.templates??{},Z.templates[J]=$.children;return document.createDocumentFragment()}function F6($,Z){let J=document.createDocumentFragment(),q=$.def??$.name,Q=Z.templates?.[q];if(!Q)return J;let Y=$.overrides??{},U={...Z.scope,...Y},H={...Z,scope:U};for(let W of Q)J.appendChild(x(W,H));return J}function z6($,Z){let J=document.createDocumentFragment(),q=$.name??"default",Y=Z.slots?.[q]??$.children;if(Y)for(let U of Y)J.appendChild(x(U,Z));return J}function Z4(){G("Alert",K6),G("AlertTitle",L6),G("AlertDescription",V6)}function K6($,Z){let J=_("div","pf-alert");J.setAttribute("role","alert");let q=$.variant??"default";if(J.setAttribute("data-variant",q),J.style.padding="12px 16px",$.icon!=null){let Q=_("span","pf-alert-icon");Q.setAttribute("data-icon",$.icon),Q.style.marginRight="8px",J.appendChild(Q)}return w($,J,Z),J}function L6($,Z){let J=_("h5","pf-alert-title");return J.textContent=K($.content,Z),J.style.fontWeight="600",J.style.marginBottom="4px",J}function V6($,Z){let J=_("p","pf-alert-description");return J.textContent=K($.content,Z),J.style.fontSize="14px",J}function J4(){G("Image",D6),G("Audio",O6),G("Video",T6),G("Embed",I6),G("Svg",R6),G("DropZone",j6),G("Mermaid",A6)}function D6($,Z){let J=document.createElement("img");if(J.className="pf-image",J.src=K($.src,Z),$.alt!=null)J.alt=K($.alt,Z);if($.width!=null)J.width=$.width;if($.height!=null)J.height=$.height;return J.style.maxWidth="100%",J}function O6($,Z){let J=document.createElement("audio");return J.className="pf-audio",J.src=K($.src,Z),J.controls=!0,J}function T6($,Z){let J=document.createElement("video");if(J.className="pf-video",J.src=K($.src,Z),J.controls=!0,$.width!=null)J.width=$.width;if($.height!=null)J.height=$.height;return J.style.maxWidth="100%",J}function I6($,Z){let J=_("div","pf-embed"),q=document.createElement("iframe");return q.src=K($.src,Z),q.style.width="100%",q.style.height=$.height!=null?`${$.height}px`:"400px",q.style.border="none",q.setAttribute("sandbox","allow-scripts"),J.appendChild(q),J}var P6=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 R6($,Z){let J=_("div","pf-svg"),q=K($.content,Z);if(!q.includes("<svg"))return J;let Y=new DOMParser().parseFromString(q,"image/svg+xml").querySelector("svg");if(!Y)return J;return q4(Y),J.appendChild(document.importNode(Y,!0)),J}function q4($){let Z=Array.from($.children);for(let J of Z){if(!P6.has(J.tagName.toLowerCase())){J.remove();continue}for(let q of Array.from(J.attributes)){let Q=q.name.toLowerCase();if(Q.startsWith("on")||Q==="href"&&q.value.trim().toLowerCase().startsWith("javascript:"))J.removeAttribute(q.name)}q4(J)}}function j6($,Z){let J=_("div","pf-dropzone");return J.style.padding="32px",J.style.textAlign="center",J.style.cursor="pointer",J.textContent=K($.label??"Drop files here",Z),J.addEventListener("dragover",(q)=>{q.preventDefault(),J.classList.add("pf-dropzone-active")}),J.addEventListener("dragleave",()=>{J.classList.remove("pf-dropzone-active")}),J.addEventListener("drop",(q)=>{q.preventDefault(),J.classList.remove("pf-dropzone-active")}),J}function A6($,Z){let J=_("div","pf-mermaid");J.setAttribute("data-mermaid","true");let q=K($.content,Z);if(J.textContent=q,typeof globalThis.mermaid<"u")J.classList.add("mermaid"),J.textContent=q;return J}var k6="https://cdn.jsdelivr.net/npm/pdfjs-dist@4.9/build/pdf.min.mjs",f6="https://cdn.jsdelivr.net/npm/pdfjs-dist@4.9/build/pdf.worker.min.mjs",J1=null,f0=null;async function S6(){if(J1)return J1;if(f0)return f0;return f0=import(k6).then(($)=>{let Z=$;return Z.GlobalWorkerOptions.workerSrc=f6,J1=Z,Z}),f0}function Y4(){G("PdfViewer",w6)}function w6($,Z){let J=_("div","pf-pdf-viewer"),q=$.src!=null?K($.src,Z):void 0,Q=$.data,Y=$.page!=null?$.page:1,U=$.zoom!=null?$.zoom:"fit-width",H=$.toolbar!==!1,W=$.height!=null?$.height:600;J.style.height=`${W}px`,J.style.display="flex",J.style.flexDirection="column",J.style.overflow="hidden",J.style.border="1px solid var(--color-border-primary, #e5e7eb)",J.style.borderRadius="var(--border-radius-md, 0.375rem)",J.style.background="var(--color-background-secondary, #f9fafb)";let N=_("div","pf-pdf-loading");return N.textContent="Loading PDF…",N.style.display="flex",N.style.alignItems="center",N.style.justifyContent="center",N.style.flex="1",N.style.color="var(--color-text-secondary, #6b7280)",J.appendChild(N),C6(J,N,{src:q,data:Q,initialPage:Y,zoom:U,showToolbar:H}),J}async function C6($,Z,J){try{let q=await S6(),Q;if(J.src)Q={url:J.src};else if(J.data){let B=atob(J.data),z=new Uint8Array(B.length);for(let L=0;L<B.length;L++)z[L]=B.charCodeAt(L);Q={data:z}}else{Z.textContent="Error: No PDF source provided";return}let Y=await q.getDocument(Q).promise;Z.remove();let U=Math.max(1,Math.min(J.initialPage,Y.numPages)),H=null,W=null;if(J.showToolbar){let B=b6(Y.numPages,U,{onPrev:()=>{if(U>1)U--,X()},onNext:()=>{if(U<Y.numPages)U++,X()},onPageChange:(z)=>{let L=Math.max(1,Math.min(z,Y.numPages));if(L!==U)U=L,X()}});H=B.pageInput,W=B.pageCount,$.insertBefore(B.el,$.firstChild)}let N=_("div","pf-pdf-canvas-container");N.style.flex="1",N.style.overflow="auto",N.style.display="flex",N.style.justifyContent="center",N.style.padding="8px",$.appendChild(N);let E=document.createElement("canvas");E.style.display="block",E.style.boxShadow="var(--shadow-md, 0 4px 6px -1px rgba(0,0,0,.1))",N.appendChild(E);async function X(){let B=await Y.getPage(U),z=N.clientWidth-16,L,M=B.getViewport({scale:1});if(J.zoom==="fit-width")L=z/M.width;else if(J.zoom==="fit-page"){let I=N.clientHeight-16,k=z/M.width,T=I/M.height;L=Math.min(k,T)}else L=typeof J.zoom==="number"?J.zoom:1;let F=B.getViewport({scale:L});E.width=F.width,E.height=F.height,E.style.width=`${F.width}px`,E.style.height=`${F.height}px`;let D=E.getContext("2d");if(!D)return;if(await B.render({canvasContext:D,viewport:F}).promise,H)H.value=String(U);if(W)W.textContent=`/ ${Y.numPages}`}await X()}catch(q){Z.textContent=`PDF Error: ${q instanceof Error?q.message:String(q)}`,Z.style.color="var(--color-text-danger, #dc2626)"}}function b6($,Z,J){let q=_("div","pf-pdf-toolbar");q.style.display="flex",q.style.alignItems="center",q.style.gap="8px",q.style.padding="6px 12px",q.style.borderBottom="1px solid var(--color-border-primary, #e5e7eb)",q.style.background="var(--color-background-primary, #fff)",q.style.flexShrink="0",q.style.fontSize="13px";let Q=document.createElement("button");Q.textContent="‹",Q.title="Previous page",Q.className="pf-pdf-btn",Q4(Q),Q.addEventListener("click",J.onPrev);let Y=document.createElement("button");Y.textContent="›",Y.title="Next page",Y.className="pf-pdf-btn",Q4(Y),Y.addEventListener("click",J.onNext);let U=document.createElement("input");U.type="number",U.min="1",U.max=String($),U.value=String(Z),U.style.width="48px",U.style.textAlign="center",U.style.border="1px solid var(--color-border-primary, #e5e7eb)",U.style.borderRadius="4px",U.style.padding="2px 4px",U.style.fontSize="13px",U.addEventListener("change",()=>{let W=parseInt(U.value,10);if(!isNaN(W))J.onPageChange(W)});let H=document.createElement("span");return H.textContent=`/ ${$}`,H.style.color="var(--color-text-secondary, #6b7280)",q.appendChild(Q),q.appendChild(U),q.appendChild(H),q.appendChild(Y),{el:q,pageInput:U,pageCount:H}}function Q4($){$.style.border="1px solid var(--color-border-primary, #e5e7eb)",$.style.borderRadius="4px",$.style.background="var(--color-background-primary, #fff)",$.style.cursor="pointer",$.style.padding="2px 8px",$.style.fontSize="16px",$.style.lineHeight="1"}var w0=["#3b82f6","#10b981","#f59e0b","#ef4444","#8b5cf6","#ec4899"];function H0($,Z){let J=document.createElement("div");return J.className="pf-chart-tooltip",$.appendChild(J),$.addEventListener("mouseleave",()=>{J.classList.remove("pf-visible")}),{wrapper:$,tooltip:J,svgEl:Z}}function t($,Z,J,q,Q){let{tooltip:Y,svgEl:U,wrapper:H}=$;if(Q.length===0)return;let W="";if(q)W+=`<div class="pf-chart-tooltip-label">${S0(q)}</div>`;for(let F of Q)W+='<div class="pf-chart-tooltip-row">',W+=`<span class="pf-chart-tooltip-dot" style="background:${S0(F.color)}"></span>`,W+=`<span>${S0(F.label)}:</span> <strong>${S0(String(F.value))}</strong>`,W+="</div>";Y.innerHTML=W;let N=U.getBoundingClientRect(),E=H.getBoundingClientRect(),X=U.viewBox.baseVal,B=N.width/(X.width||1),z=N.left-E.left+Z*B,L=Y.offsetWidth||100,M=z+12;if(M+L>E.width)M=z-L-12;Y.style.left=`${Math.max(0,M)}px`,Y.style.top="4px",Y.classList.add("pf-visible")}function S0($){return $.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;")}function U4($,Z,J,q,Q,Y,U,H){let W=Q.plotWidth/J.length;for(let N=0;N<J.length;N++){let E=Q.plotLeft+N*W,X=document.createElementNS("http://www.w3.org/2000/svg","rect");X.setAttribute("x",String(E)),X.setAttribute("y",String(Q.plotTop)),X.setAttribute("width",String(W)),X.setAttribute("height",String(Q.plotHeight)),X.setAttribute("fill","transparent"),X.style.cursor="default";let B=Y?J[N][Y]:void 0,z=B!=null?H?H(B):String(B):void 0,L=q.map((I,k)=>({label:I.label??I.dataKey,value:U(J[N][I.dataKey],I,k),color:I.color??w0[k%w0.length]})),M=E+W/2,F=()=>t($,M,Q.plotTop,z,L),D=()=>$.tooltip.classList.remove("pf-visible");X.addEventListener("mouseenter",F),X.addEventListener("mouseleave",D),X.addEventListener("touchstart",F,{passive:!0}),X.addEventListener("touchend",D,{passive:!0}),Z.appendChild(X)}}function H4($,Z,J,q,Q,Y,U,H,W,N){let E=J.length===1?Q.plotWidth:Q.plotWidth/(J.length-1);for(let X=0;X<J.length;X++){let B=J.length===1?(Q.plotLeft+Q.plotRight)/2:Q.plotLeft+X/(J.length-1)*Q.plotWidth,z=J.length===1?Q.plotLeft:B-E/2,L=J.length===1?Q.plotWidth:E,M=document.createElementNS("http://www.w3.org/2000/svg","rect");M.setAttribute("x",String(Math.max(Q.plotLeft,z))),M.setAttribute("y",String(Q.plotTop)),M.setAttribute("width",String(Math.min(L,Q.plotRight-Math.max(Q.plotLeft,z)))),M.setAttribute("height",String(Q.plotHeight)),M.setAttribute("fill","transparent"),M.style.cursor="default";let F=Y?J[X][Y]:void 0,D=F!=null?N?N(F):String(F):void 0,I=q.map((j,S)=>({label:j.label??j.dataKey,value:U(J[X][j.dataKey],j,S),color:j.color??w0[S%w0.length]})),k=()=>{if(t($,B,Q.plotTop,D,I),H)H.setAttribute("x1",String(B)),H.setAttribute("x2",String(B)),H.setAttribute("opacity","1");if(W)for(let j of W){for(let S of j)S.setAttribute("data-visible","false");j[X]?.setAttribute("data-visible","true")}},T=()=>{if($.tooltip.classList.remove("pf-visible"),H)H.setAttribute("opacity","0");if(W)for(let j of W)for(let S of j)S.setAttribute("data-visible","false")};M.addEventListener("mouseenter",k),M.addEventListener("mouseleave",T),M.addEventListener("touchstart",k,{passive:!0}),M.addEventListener("touchend",T,{passive:!0}),Z.appendChild(M)}}var d=["#3b82f6","#10b981","#f59e0b","#ef4444","#8b5cf6","#ec4899"],Z0="var(--muted-foreground, #6b7280)",_0="var(--border, #e5e7eb)",W0="10";function C0($,Z,J,q=!1){let Q=J?44:0,Y=$-(q?44:0),U=10,H=Z-24;return{plotLeft:Q,plotRight:Y,plotTop:10,plotBottom:H,plotWidth:Y-Q,plotHeight:H-10}}function W4($,Z=5){if($<=0)return[0];let J=$/Z,q=Math.pow(10,Math.floor(Math.log10(J))),Q=J/q,Y=Q<=1.5?q:Q<=3?2*q:Q<=7?5*q:10*q,U=[];for(let H=0;H<=$+Y*0.01;H+=Y)U.push(Math.round(H*1000)/1000);return U}function q1($,Z,J,q,Q){let Y=W4(J);for(let U of Y){let H=Z.plotBottom-(J>0?U/J*Z.plotHeight:0),W=i("text",{x:Z.plotLeft-6,y:H+3,"text-anchor":"end","font-size":W0,fill:Z0});if(W.textContent=U1(U,Q),$.appendChild(W),q&&U>0)$.appendChild(i("line",{x1:Z.plotLeft,y1:H,x2:Z.plotRight,y2:H,stroke:_0,"stroke-width":1,"stroke-dasharray":"4 3"}))}}function Q1($,Z,J,q){let Q=W4(J);for(let Y of Q){let U=Z.plotBottom-(J>0?Y/J*Z.plotHeight:0),H=i("text",{x:Z.plotRight+6,y:U+3,"text-anchor":"start","font-size":W0,fill:Z0});H.textContent=U1(Y,q),$.appendChild(H)}}function Y1($,Z,J,q,Q,Y){for(let U=0;U<Z.length;U++){let H=Z[U][J],W=i("text",{x:q(U),y:Q+14,"text-anchor":"middle","font-size":W0,fill:Z0});W.textContent=H==null?"":Y?Y(H):String(H),$.appendChild(W)}}function b0($,Z){$.appendChild(i("line",{x1:Z.plotLeft,y1:Z.plotBottom,x2:Z.plotRight,y2:Z.plotBottom,stroke:Z0,"stroke-width":1}))}function e($,Z,J){if($==null)return"";let q=p(`{{ __v | ${Z} }}`,{...J,scope:{...J.scope,__v:$}});return q==null?String($):String(q)}function U1($,Z){if(Z==="currency")return`$${$.toLocaleString()}`;if(Z==="percent")return`${$}%`;if($>=1e6)return`${($/1e6).toFixed(1)}M`;if($>=1000)return`${($/1000).toFixed(1)}K`;return String($)}function J0($){let Z=$.yAxisFormat??$.valueFormat;return Z&&Z!=="auto"?Z:void 0}function H1($,Z,J){return(q,Q)=>{if(q===null||q===void 0)return"—";if(Q.tooltipFormat)return e(q,Q.tooltipFormat,$);let Y=Q.yAxisId==="right"?J:Z;return U1(Number(q),Y)}}function Y0($,Z,J){let q=document.createElementNS("http://www.w3.org/2000/svg","svg");if(q.setAttribute("width","100%"),q.setAttribute("height",String(Z)),q.setAttribute("viewBox",`0 0 ${$} ${Z}`),q.setAttribute("role","img"),J)q.setAttribute("aria-label",`${J} chart`);return q.style.overflow="visible",q}function i($,Z){let J=document.createElementNS("http://www.w3.org/2000/svg",$);for(let[q,Q]of Object.entries(Z))J.setAttribute(q,String(Q));return J}function y0($,Z){let J=i("text",$);return J.textContent=Z,J}function X0($,Z,J,q){let Q=q*Math.PI/180;return{x:$+J*Math.cos(Q),y:Z-J*Math.sin(Q)}}function W1($,Z,J,q,Q){let Y=Math.max(2,Math.ceil(Math.abs(Q-q)/4)),U=[];for(let H=0;H<=Y;H++){let W=X0($,Z,J,q+(Q-q)*H/Y);U.push(`${H===0?"M":"L"} ${W.x.toFixed(2)} ${W.y.toFixed(2)}`)}return U.join(" ")}function G0($,Z,J){if(J===!1||Z.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 Q=0;Q<Z.length;Q++){let Y=_("div","pf-chart-legend-item");Y.style.display="flex",Y.style.alignItems="center",Y.style.gap="4px";let U=_("span");U.style.width="8px",U.style.height="8px",U.style.borderRadius="50%",U.style.backgroundColor=Z[Q].color??d[Q%d.length];let H=_("span");H.textContent=Z[Q].label??Z[Q].dataKey,Y.appendChild(U),Y.appendChild(H),q.appendChild(Y)}$.appendChild(q)}function G4(){G("BarChart",y6),G("LineChart",X4),G("AreaChart",X4),G("PieChart",m6),G("RadarChart",g6),G("ScatterChart",h6),G("RadialChart",v6),G("Histogram",u6)}function y6($,Z){let J=_("div","pf-chart pf-bar-chart"),q=p($.data,Z)??[],Q=$.series??[],Y=$.height??300;if(q.length===0||Q.length===0)return J.textContent="No chart data",J;let U=$.showYAxis!==!1,H=$.showGrid===!0,W=$.showYAxisRight===!0,N=$.showTooltip!==!1,E=$.xAxis,X=$.tooltipXKey,B=$.xAxisFormat,z=$.tooltipXFormat,L=Q.filter((O)=>O.yAxisId!=="right"),M=Q.filter((O)=>O.yAxisId==="right"),F=W&&M.length>0,D=L.length>0?Math.max(...q.flatMap((O)=>L.map((V)=>Number(O[V.dataKey]??0))),1):1,I=F?Math.max(...q.flatMap((O)=>M.map((V)=>Number(O[V.dataKey]??0))),1):1,k=400,T=C0(k,Y,U,F),j=Y0(k,Y,"Bar");if(U)q1(j,T,D,H,J0($));if(F)Q1(j,T,I,$.yAxisRightFormat);b0(j,T);let S=T.plotWidth/q.length,f=S/(Q.length+1);for(let O=0;O<q.length;O++)for(let V=0;V<Q.length;V++){let A=Q[V],C=q[O][A.dataKey];if(C===null||C===void 0)continue;let l=A.yAxisId==="right"?I:D,h=Number(C),P=Math.max(0,h/l*T.plotHeight),g=T.plotLeft+O*S+V*f+f/2,R=document.createElementNS("http://www.w3.org/2000/svg","rect");R.setAttribute("x",String(g)),R.setAttribute("y",String(T.plotBottom-P)),R.setAttribute("width",String(f*0.8)),R.setAttribute("height",String(P)),R.setAttribute("fill",A.color??d[V%d.length]),R.setAttribute("rx","2"),j.appendChild(R)}if(E){let O=B?(V)=>e(V,B,Z):void 0;Y1(j,q,E,(V)=>{return T.plotLeft+V*S+S/2},T.plotBottom,O)}if(N){let O=H0(J,j),V=H1(Z,J0($),$.yAxisRightFormat);U4(O,j,q,Q,T,X??E,V,z?(C)=>e(C,z,Z):void 0)}return G0(J,Q,$.showLegend),J.appendChild(j),J}function X4($,Z){let J=_("div",`pf-chart pf-${$.type.toLowerCase()}-chart`),q=p($.data,Z)??[],Q=$.series??[],Y=$.height??300;if(q.length===0||Q.length===0)return J.textContent="No chart data",J;let U=$.showYAxis!==!1,H=$.showGrid===!0,W=$.showYAxisRight===!0,N=$.showTooltip!==!1,E=$.xAxis,X=$.tooltipXKey,B=$.xAxisFormat,z=$.tooltipXFormat,L=Q.filter((V)=>V.yAxisId!=="right"),M=Q.filter((V)=>V.yAxisId==="right"),F=W&&M.length>0,D=L.length>0?Math.max(...q.flatMap((V)=>L.map((A)=>Number(V[A.dataKey]??0))),1):1,I=F?Math.max(...q.flatMap((V)=>M.map((A)=>Number(V[A.dataKey]??0))),1):1,k=400,T=C0(k,Y,U,F),j=Y0(k,Y,$.type==="AreaChart"?"Area":"Line"),S=$.type==="AreaChart";if(U)q1(j,T,D,H,J0($));if(F)Q1(j,T,I,$.yAxisRightFormat);b0(j,T);let f=[];for(let V=0;V<Q.length;V++){let A=Q[V],C=A.yAxisId==="right",v=C?I:D,l=A.color??d[V%d.length],h=q.map((R,y)=>{let u=R[A.dataKey],s=u===null||u===void 0,U0=q.length===1?(T.plotLeft+T.plotRight)/2:T.plotLeft+y/(q.length-1)*T.plotWidth,A4=s?T.plotBottom:T.plotBottom-Number(u)/v*T.plotHeight;return{x:U0,y:A4,isNull:s}});if(S){let R=[],y=()=>{if(R.length<2){R=[];return}let u=`M ${R[0].x},${T.plotBottom} `+R.map((U0)=>`L ${U0.x},${U0.y}`).join(" ")+` L ${R[R.length-1].x},${T.plotBottom} Z`,s=document.createElementNS("http://www.w3.org/2000/svg","path");s.setAttribute("d",u),s.setAttribute("fill",l),s.setAttribute("opacity","0.15"),j.appendChild(s),R=[]};for(let u of h){if(u.isNull){y();continue}R.push(u)}y()}let P="";for(let R of h){if(R.isNull)continue;let y=h.indexOf(R),u=y===0||h[y-1].isNull;P+=`${u?"M":"L"} ${R.x},${R.y} `}if(P){let R=document.createElementNS("http://www.w3.org/2000/svg","path");if(R.setAttribute("d",P.trim()),R.setAttribute("fill","none"),R.setAttribute("stroke",l),R.setAttribute("stroke-width","2"),C)R.setAttribute("stroke-dasharray","6 3");j.appendChild(R)}let g=[];for(let R of h){let y=document.createElementNS("http://www.w3.org/2000/svg","circle");if(y.setAttribute("cx",String(R.x)),y.setAttribute("cy",String(R.y)),y.setAttribute("r","4"),y.setAttribute("fill",l),y.setAttribute("class","pf-data-dot"),y.setAttribute("data-visible","false"),y.style.pointerEvents="none",R.isNull)y.style.display="none";j.appendChild(y),g.push(y)}f.push(g)}let O=document.createElementNS("http://www.w3.org/2000/svg","line");if(O.setAttribute("class","pf-crosshair"),O.setAttribute("x1",String(T.plotLeft)),O.setAttribute("x2",String(T.plotLeft)),O.setAttribute("y1",String(T.plotTop)),O.setAttribute("y2",String(T.plotBottom)),O.setAttribute("stroke",Z0),O.setAttribute("stroke-width","1"),O.setAttribute("stroke-dasharray","3 3"),O.setAttribute("opacity","0"),j.appendChild(O),E){let V=B?(A)=>e(A,B,Z):void 0;Y1(j,q,E,(A)=>{return q.length===1?(T.plotLeft+T.plotRight)/2:T.plotLeft+A/(q.length-1)*T.plotWidth},T.plotBottom,V)}if(N){let V=H0(J,j),A=H1(Z,J0($),$.yAxisRightFormat);H4(V,j,q,Q,T,X??E,A,O,f,z?(v)=>e(v,z,Z):void 0)}return G0(J,Q,$.showLegend),J.appendChild(j),J}function m6($,Z){let J=_("div","pf-chart pf-pie-chart"),q=p($.data,Z)??[],Q=$.series??[],Y=$.height??300,U=Math.min(Y,300),H=$.showTooltip!==!1,W=$.dataKey??Q[0]?.dataKey,N=$.nameKey??$.tooltipXKey??$.xAxis,E=Q.length>0?Q:W?[{dataKey:W,label:W}]:[];if(q.length===0||!W)return J.textContent="No chart data",J;let X=Y0(U,U,"Pie"),B=U/2,z=U/2,L=U/2-10,M=$.tooltipXFormat,F=J0($),D=(S)=>F?e(S,F,Z):String(S),I=q.map((S)=>Number(S[W]??0)),k=I.reduce((S,f)=>S+f,0);if(k===0)return J.textContent="No chart data",J.appendChild(X),J;let T=H?H0(J,X):void 0,j=-Math.PI/2;for(let S=0;S<I.length;S++){let f=I[S]/k*2*Math.PI,O=j+f,V=f>Math.PI?1:0,A=B+L*Math.cos(j),C=z+L*Math.sin(j),v=B+L*Math.cos(O),l=z+L*Math.sin(O),h=d[S%d.length],P=document.createElementNS("http://www.w3.org/2000/svg","path");if(P.setAttribute("d",`M ${B},${z} L ${A},${C} A ${L},${L} 0 ${V} 1 ${v},${l} Z`),P.setAttribute("fill",h),P.style.cursor="default",T){let g=N?q[S][N]:void 0,R=g!=null?M?e(g,M,Z):String(g):`Slice ${S+1}`,y=`${(I[S]/k*100).toFixed(1)}%`,u=j+f/2,s=B+L*0.6*Math.cos(u);P.addEventListener("mouseenter",()=>{t(T,s,z,R,[{label:E[0].label??W,value:`${D(I[S])} (${y})`,color:h}])}),P.addEventListener("mouseleave",()=>{T.tooltip.classList.remove("pf-visible")}),P.addEventListener("touchstart",()=>{t(T,s,z,R,[{label:E[0].label??W,value:`${D(I[S])} (${y})`,color:h}])},{passive:!0}),P.addEventListener("touchend",()=>{T.tooltip.classList.remove("pf-visible")},{passive:!0})}X.appendChild(P),j=O}return G0(J,E,$.showLegend),J.appendChild(X),J}function h6($,Z){let J=_("div","pf-chart pf-scatter-chart"),q=p($.data,Z)??[],Q=$.xAxis,Y=$.yAxis,U=$.zAxis,H=$.series??[],W=$.height??300;if(q.length===0||!Q||!Y)return J.textContent="No chart data",J;let N=$.showGrid!==!1,E=$.showTooltip!==!1,X=H[0]?.color??d[0],B=J0($),z=(P)=>B?e(P,B,Z):String(Math.round(P*100)/100),L=q.map((P)=>Number(P[Q]??0)),M=q.map((P)=>Number(P[Y]??0)),F=Math.min(...L),D=Math.max(...L),I=Math.min(...M),k=Math.max(...M),T=D-F||1,j=k-I||1,S=U?q.map((P)=>Number(P[U]??0)):[],f=U?Math.max(...S,1):1,O=400,V=C0(O,W,!0),A=Y0(O,W,"Scatter"),C=(P)=>V.plotLeft+(P-F)/T*V.plotWidth,v=(P)=>V.plotBottom-(P-I)/j*V.plotHeight,l=4;for(let P=0;P<=l;P++){let g=I+j*P/l,R=v(g);if(A.appendChild(y0({x:V.plotLeft-6,y:R+3,"text-anchor":"end","font-size":W0,fill:Z0},z(g))),N&&P>0)A.appendChild(i("line",{x1:V.plotLeft,y1:R,x2:V.plotRight,y2:R,stroke:_0,"stroke-width":1,"stroke-dasharray":"4 3"}))}b0(A,V);for(let P of[F,(F+D)/2,D])A.appendChild(y0({x:C(P),y:V.plotBottom+14,"text-anchor":"middle","font-size":W0,fill:Z0},String(Math.round(P*100)/100)));let h=E?H0(J,A):void 0;for(let P=0;P<q.length;P++){let g=C(L[P]),R=v(M[P]),y=U?4+Math.sqrt(S[P]/f)*14:4,u=i("circle",{cx:g,cy:R,r:y,fill:X,"fill-opacity":U?0.6:0.85});if(h){let s=[{label:Q,value:z(L[P]),color:X},{label:Y,value:z(M[P]),color:X},...U?[{label:U,value:z(S[P]),color:X}]:[]],U0=H[0]?.label??"Point";u.addEventListener("mouseenter",()=>t(h,g,R,U0,s)),u.addEventListener("mouseleave",()=>h.tooltip.classList.remove("pf-visible")),u.addEventListener("touchstart",()=>t(h,g,R,U0,s),{passive:!0}),u.addEventListener("touchend",()=>h.tooltip.classList.remove("pf-visible"),{passive:!0})}A.appendChild(u)}return G0(J,H,$.showLegend),J.appendChild(A),J}function v6($,Z){let J=_("div","pf-chart pf-radial-chart"),q=p($.data,Z)??[],Q=$.series??[],Y=$.dataKey??Q[0]?.dataKey,U=$.nameKey??$.tooltipXKey??$.xAxis,H=$.height??300;if(q.length===0||!Y)return J.textContent="No chart data",J;let W=Math.min(H,300),N=W/2,E=W/2,X=W/2-10,B=Math.max(0,Math.min($.innerRadius??30,X-10)),z=$.startAngle??180,L=$.endAngle??0,M=$.showTooltip!==!1,F=q.map((V)=>Number(V[Y]??0)),D=Math.max(...F,1),I=Y0(W,W,"Radial"),k=(X-B)/q.length,T=Math.max(2,k*0.7),j=J0($),S=(V)=>j?e(V,j,Z):String(V),f=M?H0(J,I):void 0,O=[];for(let V=0;V<q.length;V++){let A=X-k*V-k/2,C=Q[V]?.color??d[V%d.length],v=F[V]/D,l=z+v*(L-z),h=U?q[V][U]:null,P=h!=null?String(h):Q[V]?.label??Y;O.push({dataKey:P||Y,label:P||Y,color:C}),I.appendChild(i("path",{d:W1(N,E,A,z,L),fill:"none",stroke:_0,"stroke-width":T,"stroke-linecap":"round"}));let g=i("path",{d:W1(N,E,A,z,l),fill:"none",stroke:C,"stroke-width":T,"stroke-linecap":"round"});if(f){let R=X0(N,E,A,(z+l)/2),y=[{label:Y,value:S(F[V]),color:C}],u=P||Y;g.addEventListener("mouseenter",()=>t(f,R.x,R.y,u,y)),g.addEventListener("mouseleave",()=>f.tooltip.classList.remove("pf-visible")),g.addEventListener("touchstart",()=>t(f,R.x,R.y,u,y),{passive:!0}),g.addEventListener("touchend",()=>f.tooltip.classList.remove("pf-visible"),{passive:!0})}I.appendChild(g)}return G0(J,O,$.showLegend),J.appendChild(I),J}function g6($,Z){let J=_("div","pf-chart pf-radar-chart"),q=p($.data,Z)??[],Q=$.series??[],Y=$.axisKey??$.xAxis,U=$.height??300;if(q.length===0||Q.length===0)return J.textContent="No chart data",J;let H=$.filled!==!1,W=$.showDots===!0,N=$.showGrid!==!1,E=$.showTooltip!==!1,X=Math.min(U,320),B=X/2,z=X/2,L=X/2-24,M=q.length,F=Math.max(...q.flatMap((f)=>Q.map((O)=>Number(f[O.dataKey]??0))),1),D=(f)=>90-360*f/M,I=(f)=>f.map((O)=>`${O.x.toFixed(1)},${O.y.toFixed(1)}`).join(" "),k=Y0(X,X,"Radar");if(N){for(let O=1;O<=4;O++){let V=L*O/4,A=Array.from({length:M},(C,v)=>X0(B,z,V,D(v)));k.appendChild(i("polygon",{points:I(A),fill:"none",stroke:_0,"stroke-width":1}))}for(let O=0;O<M;O++){let V=X0(B,z,L,D(O));k.appendChild(i("line",{x1:B,y1:z,x2:V.x,y2:V.y,stroke:_0,"stroke-width":1}))}}for(let f=0;f<M;f++){let O=X0(B,z,L+12,D(f)),V=Y?q[f][Y]:null;k.appendChild(y0({x:O.x,y:O.y+3,"text-anchor":"middle","font-size":W0,fill:Z0},V!=null?String(V):""))}let T=E?H0(J,k):void 0,j=J0($),S=(f)=>j?e(f,j,Z):String(f);for(let f=0;f<Q.length;f++){let O=Q[f],V=O.color??d[f%d.length],A=q.map((C,v)=>X0(B,z,Number(C[O.dataKey]??0)/F*L,D(v)));if(k.appendChild(i("polygon",{points:I(A),fill:H?V:"none","fill-opacity":H?0.2:0,stroke:V,"stroke-width":2})),W||T)for(let C=0;C<A.length;C++){let v=i("circle",{cx:A[C].x,cy:A[C].y,r:W?3:6,fill:W?V:"transparent","fill-opacity":W?1:0});if(T){let l=Y?q[C][Y]:null,h=l!=null?String(l):O.label??O.dataKey,P=[{label:O.label??O.dataKey,value:S(Number(q[C][O.dataKey]??0)),color:V}];v.addEventListener("mouseenter",()=>t(T,A[C].x,A[C].y,h,P)),v.addEventListener("mouseleave",()=>T.tooltip.classList.remove("pf-visible")),v.addEventListener("touchstart",()=>t(T,A[C].x,A[C].y,h,P),{passive:!0}),v.addEventListener("touchend",()=>T.tooltip.classList.remove("pf-visible"),{passive:!0})}k.appendChild(v)}}return G0(J,Q,$.showLegend),J.appendChild(k),J}function u6($,Z){let J=_("div","pf-chart pf-histogram"),q=p($.data,Z);if(!q||q.length===0)return J.textContent="No data",J;let Q=q,Y=$.bins??10,U=$.height??200,H=$.color??d[0],W=Math.min(...Q),E=(Math.max(...Q)-W)/Y||1,X=Array(Y).fill(0);for(let D of Q){let I=Math.min(Math.floor((D-W)/E),Y-1);X[I]++}let B=Math.max(...X),z=300,L=U,M=z/Y,F=Y0(z,L,"Histogram");for(let D=0;D<Y;D++){let I=B>0?X[D]/B*L:0,k=document.createElementNS("http://www.w3.org/2000/svg","rect");k.setAttribute("x",String(D*M)),k.setAttribute("y",String(L-I)),k.setAttribute("width",String(M-1)),k.setAttribute("height",String(I)),k.setAttribute("fill",H),F.appendChild(k)}return J.appendChild(F),J}function B4(){G("Table",x6),G("TableHead",X1("thead")),G("TableBody",X1("tbody")),G("TableFooter",X1("tfoot")),G("TableRow",p6),G("TableHeader",c6),G("TableCell",l6),G("TableCaption",d6),G("ExpandableRow",i6)}function x6($,Z){let J=document.createElement("table");return J.className="pf-table",J.style.width="100%",J.style.borderCollapse="collapse",w($,J,Z),J}function X1($){return(Z,J)=>{let q=document.createElement($);return q.className=`pf-${$}`,w(Z,q,J),q}}function p6($,Z){let J=document.createElement("tr");return J.className="pf-table-row",w($,J,Z),J}function c6($,Z){let J=document.createElement("th");return J.className="pf-table-header",J.style.textAlign="left",J.style.padding="8px 12px",J.style.fontWeight="600",J.textContent=K($.content,Z),J}function l6($,Z){let J=document.createElement("td");if(J.className="pf-table-cell",J.style.padding="8px 12px",$.colSpan!=null)J.colSpan=$.colSpan;if($.rowSpan!=null)J.rowSpan=$.rowSpan;return w($,J,Z),J}function d6($,Z){let J=document.createElement("caption");return J.className="pf-table-caption",J.style.padding="8px",J.style.fontSize="14px",J.textContent=K($.content,Z),J}function i6($,Z){let J=_("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 Q=_("span","pf-expandable-arrow");Q.textContent="▶",Q.style.transition="transform 0.2s",Q.style.fontSize="10px",q.appendChild(Q);let Y=$.summary;if(Y)for(let W of Y)q.appendChild(x(W,Z));let U=_("div","pf-expandable-row-detail");U.style.display="none",U.style.paddingLeft="24px",w($,U,Z);let H=!1;return q.addEventListener("click",()=>{H=!H,U.style.display=H?"block":"none",Q.style.transform=H?"rotate(90deg)":""}),J.appendChild(q),J.appendChild(U),J}var M4=!1;function m0(){if(M4)return;M4=!0,u1(),l1(),s1(),n1(),o1(),a1(),t1(),Z4(),J4(),Y4(),G4(),B4()}function B1($){return $.replace(/[^a-zA-Z0-9_-]/g,"")}function M1($){return $.replace(/[{}<>;]/g,"").replace(/\b(url|expression)\s*\(/gi,"")}function G1($,Z=" "){return Object.entries($).map(([J,q])=>`${Z}--${B1(J)}: ${M1(q)};`).join(`
7
- `)}function _4($){if(!$)return"";let Z=[];if($.light&&Object.keys($.light).length>0)Z.push(`:root {
8
- ${G1($.light)}
9
- }`);if($.dark&&Object.keys($.dark).length>0){let J=G1($.dark);Z.push(`.dark, [data-theme="dark"] {
3
+ `),J=[],q=0;while(q<Z.length){let Q=Z[q];if(Q.trimStart().startsWith("```")){let H=Q.trimStart().slice(3).trim(),W=[];q++;while(q<Z.length&&!Z[q].trimStart().startsWith("```"))W.push(f0(Z[q])),q++;q++;let _=H?` data-language="${f0(H)}"`:"";J.push(`<pre class="pf-code"><code${_}>${W.join(`
4
+ `)}</code></pre>`);continue}if(/^(\s*[-*_]\s*){3,}$/.test(Q)){J.push("<hr />"),q++;continue}let Y=/^(#{1,6})\s+(.+)$/.exec(Q);if(Y){let H=Y[1].length;J.push(`<h${H}>${A0(Y[2])}</h${H}>`),q++;continue}if(Q.startsWith("> ")||Q===">"){let H=[];while(q<Z.length&&(Z[q].startsWith("> ")||Z[q]===">"))H.push(Z[q].replace(/^>\s?/,"")),q++;J.push(`<blockquote>${s1(H.join(`
5
+ `))}</blockquote>`);continue}if(/^[\s]*[-*+]\s+/.test(Q)){J.push("<ul>");while(q<Z.length&&/^[\s]*[-*+]\s+/.test(Z[q]))J.push(`<li>${A0(Z[q].replace(/^[\s]*[-*+]\s+/,""))}</li>`),q++;J.push("</ul>");continue}if(/^[\s]*\d+\.\s+/.test(Q)){J.push("<ol>");while(q<Z.length&&/^[\s]*\d+\.\s+/.test(Z[q]))J.push(`<li>${A0(Z[q].replace(/^[\s]*\d+\.\s+/,""))}</li>`),q++;J.push("</ol>");continue}if(Q.trim()===""){q++;continue}let U=[];while(q<Z.length&&Z[q].trim()!==""&&!/^#{1,6}\s/.test(Z[q])&&!/^[-*+]\s/.test(Z[q])&&!/^\d+\.\s/.test(Z[q])&&!Z[q].startsWith("> ")&&!Z[q].trimStart().startsWith("```")&&!/^(\s*[-*_]\s*){3,}$/.test(Z[q]))U.push(Z[q]),q++;J.push(`<p>${U.map(A0).join("<br />")}</p>`)}return J.join(`
6
+ `)}function j8($,Z){let J=document.createElement("kbd");return J.className="pf-kbd",J.textContent=F($.content,Z),J}function r1(){G("Card",k8),G("CardHeader",J1("pf-card-header")),G("CardTitle",n1("pf-card-title","h3")),G("CardDescription",n1("pf-card-description","p")),G("CardContent",J1("pf-card-content")),G("CardFooter",J1("pf-card-footer"))}function k8($,Z){let J=N("div","pf-card");return J.style.overflow="hidden",w($,J,Z),J}function J1($){return(Z,J)=>{let q=N("div",$);return q.style.padding="16px 24px",w(Z,q,J),q}}function n1($,Z){return(J,q)=>{let Q=document.createElement(Z);return Q.className=$,Q.textContent=F(J.content,q),Q}}function a1(){G("DataTable",A8),G("Badge",f8),G("Dot",S8),G("Metric",w8),G("Ring",C8),G("Progress",b8),G("Separator",y8),G("Loader",m8),G("Icon",h8),G("Sparkline",v8)}function A8($,Z){let J=N("div","pf-datatable-wrapper"),q=document.createElement("table");q.className="pf-datatable",q.style.width="100%",q.style.borderCollapse="collapse";let Q=$.columns??[],Y=c($.rows,Z),U=$.rowKey,H=$.selected,W=document.createElement("thead"),_=document.createElement("tr");for(let X of Q){let B=document.createElement("th");B.className="pf-datatable-th",B.textContent=X.header??X.key,B.style.padding="8px 12px",B.style.textAlign="left",_.appendChild(B)}W.appendChild(_),q.appendChild(W);let z=document.createElement("tbody");if(Array.isArray(Y)){let X=H!=null?c(H,Z):void 0;for(let B of Y){let K=document.createElement("tr");K.className="pf-datatable-row";let L=B,M=B===null||typeof B!=="object";if(U&&X!=null&&L[U]!=null&&String(L[U])===String(X))K.classList.add("pf-datatable-row-selected");if($.onRowClick!=null&&U)K.style.cursor="pointer",K.addEventListener("click",()=>{let E={...Z.scope,$item:L,$index:Y.indexOf(B)},D=l({...Z,scope:E});h(m($.onRowClick,D),"onRowClick")});for(let E of Q){let D=document.createElement("td");D.className="pf-datatable-td";let I;if(E.accessor)I=c(`{{ $item.${E.accessor} }}`,{...Z,scope:{...Z.scope,$item:L}});else if(I=M?B:L[E.key],E.format&&I!=null)I=c(`{{ __fmtVal | ${E.format} }}`,{...Z,scope:{...Z.scope,__fmtVal:I}});D.textContent=I==null?"":String(I),D.style.padding="8px 12px",K.appendChild(D)}z.appendChild(K)}}if(q.appendChild(z),$.search===!0){let X=document.createElement("input");X.type="text",X.placeholder="Search...",X.className="pf-datatable-search",X.style.marginBottom="8px",X.style.padding="6px 12px",X.style.width="100%",X.style.boxSizing="border-box",X.addEventListener("input",()=>{let B=X.value.toLowerCase(),K=Array.from(z.querySelectorAll("tr"));for(let L of K){let M=(L.textContent??"").toLowerCase();L.style.display=M.includes(B)?"":"none"}}),J.appendChild(X)}return J.appendChild(q),J}function f8($,Z){let J=N("span","pf-badge"),q=$.variant??"default";return J.setAttribute("data-variant",q),J.style.alignItems="center",J.style.padding="2px 10px",J.style.borderRadius="9999px",J.style.fontSize="12px",J.style.fontWeight="500",J.textContent=F($.label??$.content,Z),g8(J,q),J}function S8($,Z){let J=N("span","pf-dot"),q=$.color??"gray";return J.style.display="inline-block",J.style.width="8px",J.style.height="8px",J.style.borderRadius="50%",J.style.backgroundColor=q,J}function w8($,Z){let J=N("div","pf-metric"),q=N("div","pf-metric-label");q.textContent=F($.label,Z),q.style.fontSize="14px",J.appendChild(q);let Q=N("div","pf-metric-value");if(Q.textContent=F($.value,Z),Q.style.fontSize="28px",Q.style.fontWeight="700",J.appendChild(Q),$.delta!=null){let Y=N("span","pf-metric-delta");Y.textContent=F($.delta,Z);let U=$.trend??"",H=$.trendSentiment??"neutral";if(Y.style.fontSize="14px",Y.style.color=H==="positive"?"green":H==="negative"?"red":"inherit",U==="up")Y.textContent="↑ "+Y.textContent;else if(U==="down")Y.textContent="↓ "+Y.textContent;J.appendChild(Y)}if($.description!=null){let Y=N("div","pf-metric-desc");Y.textContent=F($.description,Z),Y.style.fontSize="12px",J.appendChild(Y)}return J}function C8($,Z){let J=N("div","pf-ring"),q=$.size??80,Q=$.thickness??8,Y=Number(c($.value,Z)??0),U=Math.max(0,Math.min(100,Y)),H=(q-Q)/2,W=2*Math.PI*H,_=W*(1-U/100),z=document.createElementNS("http://www.w3.org/2000/svg","svg");z.setAttribute("width",String(q)),z.setAttribute("height",String(q)),z.setAttribute("viewBox",`0 0 ${q} ${q}`);let X=document.createElementNS("http://www.w3.org/2000/svg","circle");X.setAttribute("cx",String(q/2)),X.setAttribute("cy",String(q/2)),X.setAttribute("r",String(H)),X.setAttribute("fill","none"),X.setAttribute("stroke","var(--muted, #e5e7eb)"),X.setAttribute("stroke-width",String(Q));let B=document.createElementNS("http://www.w3.org/2000/svg","circle");if(B.setAttribute("cx",String(q/2)),B.setAttribute("cy",String(q/2)),B.setAttribute("r",String(H)),B.setAttribute("fill","none"),B.setAttribute("stroke","var(--primary, #3b82f6)"),B.setAttribute("stroke-width",String(Q)),B.setAttribute("stroke-dasharray",String(W)),B.setAttribute("stroke-dashoffset",String(_)),B.setAttribute("stroke-linecap","round"),B.style.transform="rotate(-90deg)",B.style.transformOrigin="center",z.appendChild(X),z.appendChild(B),J.appendChild(z),$.label!=null){let K=N("div","pf-ring-label");K.textContent=F($.label,Z),K.style.textAlign="center",K.style.fontSize="12px",J.appendChild(K)}return J}function b8($,Z){let J=N("div","pf-progress");J.setAttribute("role","progressbar");let q=Number(c($.value,Z)??0),Q=$.max??100,Y=Q>0?Math.max(0,Math.min(100,q/Q*100)):0;J.setAttribute("aria-valuenow",String(q)),J.setAttribute("aria-valuemin","0"),J.setAttribute("aria-valuemax",String(Q)),J.style.height="8px",J.style.borderRadius="4px",J.style.overflow="hidden";let U=N("div","pf-progress-fill");return U.style.height="100%",U.style.width=`${Y}%`,U.style.borderRadius="4px",U.style.transition="width 0.3s ease",J.appendChild(U),J}function y8($,Z){let J=document.createElement("hr");return J.className="pf-separator",J.style.border="none",J.style.margin="8px 0",J}function m8($,Z){let J=N("div","pf-loader");return J.textContent="⏳",J.style.display="flex",J.style.justifyContent="center",J.style.padding="16px",J}function h8($,Z){let J=N("span","pf-icon");return J.setAttribute("data-icon",F($.name??$.content,Z)),J}function v8($,Z){let J=N("div","pf-sparkline"),q=$.data??[];if(q.length===0)return J;let Q=120,Y=32,U=Math.max(...q),H=Math.min(...q),W=U-H||1,_=document.createElementNS("http://www.w3.org/2000/svg","svg");_.setAttribute("width",String(Q)),_.setAttribute("height",String(Y)),_.setAttribute("viewBox",`0 0 ${Q} ${Y}`);let z=q.length>1?q.length-1:1,X=q.map((K,L)=>{let M=L/z*Q,E=Y-(K-H)/W*(Y-4)-2;return`${M},${E}`}).join(" "),B=document.createElementNS("http://www.w3.org/2000/svg","polyline");return B.setAttribute("points",X),B.setAttribute("fill","none"),B.setAttribute("stroke","var(--primary, #3b82f6)"),B.setAttribute("stroke-width","1.5"),_.appendChild(B),J.appendChild(_),J}function g8($,Z){let q={success:{bg:"#10b981",fg:"#fff"},warning:{bg:"#f59e0b",fg:"#fff"},info:{bg:"#3b82f6",fg:"#fff"}}[Z];if(q)$.style.backgroundColor=q.bg,$.style.color=q.fg}function t1(){G("Form",u8),G("Input",x8),G("Textarea",p8),G("Button",c8),G("ButtonGroup",l8),G("Select",d8),G("SelectOption",i8),G("SelectGroup",S0("pf-select-group")),G("SelectLabel",K0("pf-select-label")),G("SelectSeparator",o1),G("Checkbox",s8),G("Switch",n8),G("Slider",r8),G("Radio",o8),G("RadioGroup",t8),G("Combobox",e8),G("ComboboxOption",$6),G("ComboboxGroup",S0("pf-combobox-group")),G("ComboboxLabel",K0("pf-combobox-label")),G("ComboboxSeparator",o1),G("Calendar",Z6),G("DatePicker",J6),G("Field",S0("pf-field")),G("FieldTitle",K0("pf-field-title")),G("FieldDescription",K0("pf-field-description")),G("FieldContent",S0("pf-field-content")),G("FieldError",K0("pf-field-error")),G("ChoiceCard",q6)}function u8($,Z){let J=document.createElement("form");return J.className="pf-form",J.addEventListener("submit",(q)=>{q.preventDefault();let Q=new FormData(J),Y={};if(Q.forEach((U,H)=>{Y[H]=U}),Z.store.merge(Y),$.onSubmit!=null){let U=l(Z);U.scope={...Z.scope,...Y},h(m($.onSubmit,U),"onSubmit")}}),w($,J,Z),J}function x8($,Z){let J=N("div","pf-input-wrapper");if(J.style.display="flex",J.style.flexDirection="column",J.style.gap="4px",$.label!=null){let Y=document.createElement("label");if(Y.className="pf-input-label",Y.textContent=F($.label,Z),$.name!=null)Y.htmlFor=$.name;Y.style.fontSize="14px",Y.style.fontWeight="500",J.appendChild(Y)}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=F($.placeholder,Z);if($.required===!0)q.required=!0,q.setAttribute("aria-required","true");if($.error!=null)q.setAttribute("aria-invalid","true");let Q=$.name;if(Q){let Y=Z.store.get(Q);if(Y!=null)q.value=String(Y);q.addEventListener("input",()=>{if(Z.store.set(Q,q.value),$.onChange!=null)h(m($.onChange,{...l(Z),scope:{...Z.scope,$event:q.value}}),"onChange")})}return q1(q),J.appendChild(q),J}function p8($,Z){let J=N("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=F($.placeholder,Z);if($.rows!=null)q.rows=$.rows;if($.required===!0)q.setAttribute("aria-required","true");let Q=$.name;if(Q!=null){let Y=Z.store.get(Q);if(Y!=null)q.value=String(Y);q.addEventListener("input",()=>{if(Z.store.set(Q,q.value),$.onChange!=null)h(m($.onChange,{...l(Z),scope:{...Z.scope,$event:q.value}}),"onChange")})}return q1(q),J.appendChild(q),J}function c8($,Z){let J=document.createElement("button");J.className="pf-button",J.type=$.submit===!0?"submit":"button",J.textContent=F($.label,Z);let q=$.variant??"default";if(J.setAttribute("data-variant",q),a8(J,q),$.size!=null)J.setAttribute("data-size",$.size);if($.disabled===!0)J.disabled=!0;return J}function l8($,Z){let J=N("div","pf-button-group");return J.style.display="flex",J.style.gap="8px",w($,J,Z),J}function d8($,Z){let J=N("div","pf-select-wrapper"),q=document.createElement("select");if(q.className="pf-select",$.name!=null)q.name=$.name;if(q1(q),$.placeholder!=null){let U=document.createElement("option");U.value="",U.textContent=F($.placeholder,Z),U.disabled=!0,U.selected=!0,U.hidden=!0,q.appendChild(U)}let Q=$.options;if(Array.isArray(Q))for(let U of Q){let H=document.createElement("option");H.value=U.value??"",H.textContent=U.label??H.value,q.appendChild(H)}if($.children)for(let U of $.children)if(U.type==="SelectOption"){let H=document.createElement("option");H.value=U.value??"",H.textContent=U.label??H.value,q.appendChild(H)}else q.appendChild(g(U,Z));let Y=$.name;if(Y){let U=Z.store.get(Y);if(U!=null)q.value=String(U);q.addEventListener("change",()=>{if(Z.store.set(Y,q.value),$.onChange!=null)h(m($.onChange,{...l(Z),scope:{...Z.scope,$event:q.value}}),"onChange")})}return J.appendChild(q),J}function i8($,Z){return N("span")}function s8($,Z){let J=N("label","pf-checkbox-wrapper");J.style.display="flex",J.style.alignItems="center",J.style.gap="8px",J.style.cursor="pointer";let q=document.createElement("input");if(q.type="checkbox",q.className="pf-checkbox",$.name!=null)q.name=$.name;if($.checked===!0)q.checked=!0;let Q=$.name;if(Q){let Y=Z.store.get(Q);if(typeof Y==="boolean")q.checked=Y;q.addEventListener("change",()=>{if(Z.store.set(Q,q.checked),$.onChange!=null)h(m($.onChange,{...l(Z),scope:{...Z.scope,$event:q.checked}}),"onChange")})}if(J.appendChild(q),$.label!=null){let Y=N("span");Y.textContent=F($.label,Z),J.appendChild(Y)}return J}function n8($,Z){let J=N("label","pf-switch-wrapper");J.style.display="flex",J.style.alignItems="center",J.style.gap="8px",J.style.cursor="pointer";let q=document.createElement("input");if(q.type="checkbox",q.className="pf-switch",q.setAttribute("role","switch"),$.name!=null)q.name=$.name;let Q=$.name;if(Q){let Y=Z.store.get(Q);if(typeof Y==="boolean")q.checked=Y;q.addEventListener("change",()=>{if(Z.store.set(Q,q.checked),$.onChange!=null)h(m($.onChange,{...l(Z),scope:{...Z.scope,$event:q.checked}}),"onChange")})}if(J.appendChild(q),$.label!=null){let Y=N("span");Y.textContent=F($.label,Z),J.appendChild(Y)}return J}function r8($,Z){let J=N("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 Q=$.name;if(Q){let Y=Z.store.get(Q);if(Y!=null)q.value=String(Y);q.addEventListener("input",()=>{if(Z.store.set(Q,Number(q.value)),$.onChange!=null)h(m($.onChange,{...l(Z),scope:{...Z.scope,$event:Number(q.value)}}),"onChange")})}return J.appendChild(q),J}function q1($){$.style.padding="8px 12px",$.style.fontSize="14px",$.style.width="100%",$.style.boxSizing="border-box"}function a8($,Z){if($.style.padding="8px 16px",$.style.fontSize="14px",$.style.fontWeight="500",$.style.cursor="pointer",$.style.border="none",Z==="ghost")$.style.backgroundColor="transparent",$.style.color="inherit"}function S0($){return(Z,J)=>{let q=N("div",$);return w(Z,q,J),q}}function K0($){return(Z,J)=>{let q=N("span",$);return q.textContent=F(Z.content,J),q}}function o1(){let $=document.createElement("hr");return $.className="pf-separator",$.style.border="none",$.style.margin="4px 0",$}function o8($,Z){let J=N("label","pf-radio");J.style.display="flex",J.style.alignItems="center",J.style.gap="8px",J.style.cursor="pointer";let q=document.createElement("input");if(q.type="radio",q.value=F($.value,Z),J.appendChild(q),$.label!=null){let Q=N("span","pf-radio-label");Q.textContent=F($.label,Z),J.appendChild(Q)}return J}function t8($,Z){let J=N("fieldset","pf-radio-group");if(J.style.border="none",J.style.padding="0",J.style.display="flex",J.style.flexDirection="column",J.style.gap="8px",$.label!=null){let Y=document.createElement("legend");Y.textContent=F($.label,Z),Y.style.fontWeight="500",Y.style.marginBottom="4px",J.appendChild(Y)}w($,J,Z);let q=F($.name,Z),Q=Z.store.get(q);for(let Y of Array.from(J.querySelectorAll('input[type="radio"]')))if(Y.name=q,Q!=null&&Y.value===String(Q))Y.checked=!0;return J.addEventListener("change",(Y)=>{let U=Y.target;if(U.type==="radio"){if(Z.store.set(q,U.value),$.onChange!=null)h(m($.onChange,l(Z)),"onChange")}}),J}function e8($,Z){let J=N("div","pf-combobox"),q=document.createElement("input");if(q.className="pf-combobox-input",q.type="text",q.name=F($.name,Z),$.placeholder!=null)q.placeholder=F($.placeholder,Z);if($.value!==void 0)q.value=F($.value,Z);let Q=q.name,Y=Z.store.get(Q);if(Y!=null)q.value=String(Y);q.style.padding="6px 12px",q.style.borderRadius="6px",q.style.width="100%",q.style.boxSizing="border-box";let U=N("div","pf-combobox-dropdown");if(U.style.display="none",U.style.position="absolute",U.style.borderRadius="6px",U.style.maxHeight="200px",U.style.overflowY="auto",U.style.zIndex="50",w($,U,Z),q.addEventListener("focus",()=>{U.style.display="block"}),q.addEventListener("blur",()=>{setTimeout(()=>{U.style.display="none"},150)}),$.searchable!==!1)q.addEventListener("input",()=>{let H=q.value.toLowerCase();for(let W of Array.from(U.querySelectorAll(".pf-combobox-option"))){let _=(W.textContent??"").toLowerCase();W.style.display=_.includes(H)?"":"none"}});if($.onChange!=null)J.addEventListener("pf-combobox-select",()=>{h(m($.onChange,{...l(Z),scope:{...Z.scope,$event:q.value}}),"onChange")});return J.style.position="relative",J.appendChild(q),J.appendChild(U),J}function $6($,Z){let J=N("div","pf-combobox-option");return J.style.padding="6px 12px",J.style.cursor="pointer",J.textContent=F($.label??$.value,Z),J.dataset.value=F($.value,Z),J.addEventListener("mousedown",()=>{let q=J.closest(".pf-combobox"),Q=q?.querySelector("input");if(Q)Q.value=J.dataset.value??"",Z.store.set(Q.name,Q.value),q?.dispatchEvent(new CustomEvent("pf-combobox-select",{bubbles:!1}))}),J}function Z6($,Z){let J=N("div","pf-calendar"),q=document.createElement("input");if(q.type="date",q.name=F($.name,Z),$.value!==void 0)q.value=F($.value,Z);let Q=q.name,Y=Z.store.get(Q);if(Y!=null)q.value=String(Y);if($.minDate!=null)q.min=F($.minDate,Z);if($.maxDate!=null)q.max=F($.maxDate,Z);return q.style.padding="6px 12px",q.style.borderRadius="6px",q.addEventListener("change",()=>{if(Z.store.set(q.name,q.value),$.onChange!=null)h(m($.onChange,l(Z)),"onChange")}),J.appendChild(q),J}function J6($,Z){let J=N("div","pf-datepicker"),q=document.createElement("input");if(q.type="date",q.name=F($.name,Z),$.placeholder!=null)q.placeholder=F($.placeholder,Z);if($.value!==void 0)q.value=F($.value,Z);let Q=q.name,Y=Z.store.get(Q);if(Y!=null)q.value=String(Y);if($.minDate!=null)q.min=F($.minDate,Z);if($.maxDate!=null)q.max=F($.maxDate,Z);return q.style.padding="6px 12px",q.style.borderRadius="6px",q.style.width="100%",q.style.boxSizing="border-box",q.addEventListener("change",()=>{if(Z.store.set(q.name,q.value),$.onChange!=null)h(m($.onChange,l(Z)),"onChange")}),J.appendChild(q),J}function q6($,Z){let J=N("div","pf-choice-card");if(J.style.padding="16px",J.style.cursor="pointer",J.style.transition="border-color 0.2s",J.dataset.value=F($.value,Z),$.selected===!0)J.dataset.selected="true";if($.label!=null){let q=N("div","pf-choice-card-label");q.textContent=F($.label,Z),q.style.fontWeight="600",J.appendChild(q)}if($.description!=null){let q=N("div","pf-choice-card-description");q.textContent=F($.description,Z),q.style.fontSize="14px",J.appendChild(q)}return w($,J,Z),J}function e1(){G("Tabs",Q6),G("Tab",Y6),G("Accordion",U6),G("AccordionItem",H6),G("Dialog",W6),G("Popover",X6),G("Tooltip",G6),G("HoverCard",B6),G("Carousel",M6)}function Q6($,Z){let J=N("div","pf-tabs"),q=N("div","pf-tabs-bar");q.setAttribute("role","tablist"),q.style.display="flex",q.style.gap="4px",q.style.marginBottom="12px";let Q=[],Y=[];if($.children)for(let H=0;H<$.children.length;H++){let W=$.children[H],_=`pf-tab-${Math.random().toString(36).slice(2,8)}`,z=`pf-panel-${Math.random().toString(36).slice(2,8)}`,X=document.createElement("button");X.type="button",X.className="pf-tab-trigger",X.textContent=W.title??`Tab ${H+1}`,X.setAttribute("role","tab"),X.setAttribute("aria-selected",H===0?"true":"false"),X.setAttribute("aria-controls",z),X.id=_,X.tabIndex=H===0?0:-1,X.style.padding="8px 16px",X.style.border="none",X.style.background="none",X.style.cursor="pointer",X.style.borderBottom="2px solid transparent",X.style.marginBottom="-2px",X.style.fontSize="14px";let B=N("div","pf-tab-panel");if(B.style.display=H===0?"block":"none",B.setAttribute("role","tabpanel"),B.setAttribute("aria-labelledby",_),B.id=z,B.tabIndex=0,w(W,B,Z),X.addEventListener("click",()=>{U(H)}),H===0)X.classList.add("pf-tab-active"),X.style.fontWeight="600";Y.push(X),Q.push(B),q.appendChild(X)}function U(H){Q.forEach((W)=>W.style.display="none"),Y.forEach((W)=>{W.style.borderBottomColor="transparent",W.style.fontWeight="normal",W.classList.remove("pf-tab-active"),W.setAttribute("aria-selected","false"),W.tabIndex=-1}),Q[H].style.display="block",Y[H].classList.add("pf-tab-active"),Y[H].style.fontWeight="600",Y[H].setAttribute("aria-selected","true"),Y[H].tabIndex=0,Y[H].focus()}q.addEventListener("keydown",(H)=>{let W=Y.indexOf(H.target);if(W<0)return;let _;if(H.key==="ArrowRight")_=(W+1)%Y.length;else if(H.key==="ArrowLeft")_=(W-1+Y.length)%Y.length;else if(H.key==="Home")_=0;else if(H.key==="End")_=Y.length-1;else return;H.preventDefault(),U(_)}),J.appendChild(q);for(let H of Q)J.appendChild(H);return J}function Y6($,Z){let J=N("div","pf-tab");return w($,J,Z),J}function U6($,Z){let J=N("div","pf-accordion");return w($,J,Z),J}function H6($,Z){let J=N("div","pf-accordion-item"),q=`pf-acc-${Math.random().toString(36).slice(2,8)}`,Q=document.createElement("button");Q.type="button",Q.className="pf-accordion-trigger",Q.textContent=$.title??"",Q.setAttribute("aria-expanded","false"),Q.setAttribute("aria-controls",q),Q.style.width="100%",Q.style.textAlign="left",Q.style.padding="12px 0",Q.style.border="none",Q.style.background="none",Q.style.cursor="pointer",Q.style.fontSize="14px",Q.style.fontWeight="500";let Y=N("div","pf-accordion-content");return Y.id=q,Y.setAttribute("role","region"),Y.setAttribute("aria-labelledby",Q.id),Y.style.display="none",Y.style.paddingBottom="12px",w($,Y,Z),Q.addEventListener("click",()=>{let U=Y.style.display!=="none";Y.style.display=U?"none":"block",Q.setAttribute("aria-expanded",U?"false":"true")}),J.appendChild(Q),J.appendChild(Y),J}function W6($,Z){let J=N("div","pf-dialog-wrapper");if($.trigger!=null){let Y=g($.trigger,Z);Y.addEventListener("click",()=>{q.showModal()}),J.appendChild(Y)}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 Y=N("h2","pf-dialog-title");Y.textContent=F($.title,Z),Y.id=`pf-dialog-title-${Math.random().toString(36).slice(2,8)}`,q.setAttribute("aria-labelledby",Y.id),q.appendChild(Y)}if($.description!=null){let Y=N("p","pf-dialog-desc");Y.textContent=F($.description,Z),q.appendChild(Y)}let Q=N("div","pf-dialog-body");if(w($,Q,Z),q.appendChild(Q),$.dismissible!==!1)q.addEventListener("click",(Y)=>{if(Y.target===q)q.close()});return document.addEventListener("prefab:close-overlay",()=>q.close()),J.appendChild(q),J}function X6($,Z){let J=N("div","pf-popover");J.style.position="relative",J.style.display="inline-block";let q=N("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 Y=N("div","pf-popover-title");Y.textContent=F($.title,Z),Y.style.fontWeight="600",Y.style.marginBottom="4px",q.appendChild(Y)}w($,q,Z);let Q=()=>{q.style.display=q.style.display==="none"?"block":"none"};if($.trigger!=null){let Y=g($.trigger,Z);Y.addEventListener("click",(U)=>{U.stopPropagation(),Q()}),J.appendChild(Y)}else J.addEventListener("click",(Y)=>{if(q.contains(Y.target)&&q.style.display!=="none")return;Q()});return J.appendChild(q),J}function G6($,Z){let J=N("div","pf-tooltip");J.style.position="relative",J.style.display="inline-block";let q=`pf-tip-${Math.random().toString(36).slice(2,8)}`,Q=N("div","pf-tooltip-content");return Q.id=q,Q.setAttribute("role","tooltip"),Q.textContent=F($.content??"",Z),Q.style.display="none",Q.style.position="absolute",Q.style.bottom="100%",Q.style.left="50%",Q.style.transform="translateX(-50%)",Q.style.padding="4px 8px",Q.style.borderRadius="4px",Q.style.color="#fff",Q.style.fontSize="12px",Q.style.whiteSpace="nowrap",Q.style.zIndex="50",w($,J,Z),J.setAttribute("aria-describedby",q),J.addEventListener("mouseenter",()=>{Q.style.display="block"}),J.addEventListener("mouseleave",()=>{Q.style.display="none"}),J.addEventListener("focus",()=>{Q.style.display="block"},!0),J.addEventListener("blur",()=>{Q.style.display="none"},!0),J.appendChild(Q),J}function B6($,Z){let J=N("div","pf-hover-card");J.style.position="relative",J.style.display="inline-block";let q=N("div","pf-hover-card-content");if(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",$.trigger!=null)J.appendChild(g($.trigger,Z));return w($,q,Z),J.addEventListener("mouseenter",()=>{q.style.display="block"}),J.addEventListener("mouseleave",()=>{q.style.display="none"}),J.appendChild(q),J}function M6($,Z){let J=N("div","pf-carousel");J.style.position="relative",J.style.overflow="hidden",J.setAttribute("role","region"),J.setAttribute("aria-roledescription","carousel"),J.setAttribute("aria-label",F($.label??"Carousel",Z));let q=N("div","pf-carousel-track");q.style.display="flex",q.style.transition="transform 0.3s ease",w($,q,Z);let Q=0,Y=$.children?.length??0,U=document.createElement("button");U.type="button",U.textContent="‹",U.className="pf-carousel-prev",U.setAttribute("aria-label","Previous slide"),U.style.position="absolute",U.style.left="4px",U.style.top="50%",U.style.transform="translateY(-50%)",U.style.zIndex="10";let H=document.createElement("button");H.type="button",H.textContent="›",H.className="pf-carousel-next",H.setAttribute("aria-label","Next slide"),H.style.position="absolute",H.style.right="4px",H.style.top="50%",H.style.transform="translateY(-50%)",H.style.zIndex="10";let W=()=>{q.style.transform=`translateX(-${Q*100}%)`};return U.addEventListener("click",()=>{if(Y===0)return;Q=Math.max(0,Q-1),W()}),H.addEventListener("click",()=>{if(Y===0)return;Q=Math.min(Y-1,Q+1),W()}),J.appendChild(q),J.appendChild(U),J.appendChild(H),J}function $4(){G("ForEach",_6),G("If",Z4),G("Elif",N6),G("Else",z6),G("Condition",E6),G("Define",K6),G("Use",F6),G("Slot",L6)}function _6($,Z){let J=document.createDocumentFragment(),q=$.expression;if(!q)return J;let Q;if(o(q)){let U=t(q,Z.store,Z.scope);Q=Array.isArray(U)?U:[]}else{let U=Z.store.get(q);Q=Array.isArray(U)?U:[]}let Y=$.let??{};for(let U=0;U<Q.length;U++){let H=Q[U],W={...Z.scope,$item:H,$index:U,...Y},_={...Z,scope:W};if($.children)Q0($.children,J,_)}return J}function Z4($,Z){if(J4($.condition,Z)){let q=document.createDocumentFragment();if($.children)Q0($.children,q,Z);return q}return document.createDocumentFragment()}function N6($,Z){return Z4($,Z)}function z6($,Z){let J=document.createDocumentFragment();if($.children)Q0($.children,J,Z);return J}function J4($,Z){if(!$)return!1;if(o($))return Boolean(t($,Z.store,Z.scope));return Boolean(Z.store.get($))}function E6($,Z){let J=document.createDocumentFragment(),q=$.cases,Q=$.else;if(q){for(let Y of q)if(J4(Y.when,Z)){if(Y.children)Q0(Y.children,J,Z);return J}}if(Q)Q0(Q,J,Z);return J}function K6($,Z){let J=$.name;if(J&&$.children)Z.templates=Z.templates??{},Z.templates[J]=$.children;return document.createDocumentFragment()}function F6($,Z){let J=document.createDocumentFragment(),q=$.def??$.name,Q=Z.templates?.[q];if(!Q)return J;let Y=$.overrides??{},U={...Z.scope,...Y},H={...Z.slots??{},...$.slots??{}};if(Array.isArray($.children))H.default=$.children;let W={...Z,scope:U,slots:H};for(let _ of Q)J.appendChild(g(_,W));return J}function L6($,Z){let J=document.createDocumentFragment(),q=$.name??"default",Y=Z.slots?.[q]??$.children;if(Y)for(let U of Y)J.appendChild(g(U,Z));return J}function q4(){G("Alert",V6),G("AlertTitle",D6),G("AlertDescription",O6)}function V6($,Z){let J=N("div","pf-alert");J.setAttribute("role","alert");let q=$.variant??"default";if(J.setAttribute("data-variant",q),J.style.padding="12px 16px",$.icon!=null){let Q=N("span","pf-alert-icon");Q.setAttribute("data-icon",$.icon),Q.style.marginRight="8px",J.appendChild(Q)}return w($,J,Z),J}function D6($,Z){let J=N("h5","pf-alert-title");return J.textContent=F($.content,Z),J.style.fontWeight="600",J.style.marginBottom="4px",J}function O6($,Z){let J=N("p","pf-alert-description");return J.textContent=F($.content,Z),J.style.fontSize="14px",J}function Q4(){G("Image",T6),G("Audio",I6),G("Video",P6),G("Embed",R6),G("Svg",k6),G("DropZone",A6),G("Mermaid",f6)}function T6($,Z){let J=document.createElement("img");if(J.className="pf-image",J.src=F($.src,Z),$.alt!=null)J.alt=F($.alt,Z);if($.width!=null)J.width=$.width;if($.height!=null)J.height=$.height;return J.style.maxWidth="100%",J}function I6($,Z){let J=document.createElement("audio");return J.className="pf-audio",J.src=F($.src,Z),J.controls=!0,J}function P6($,Z){let J=document.createElement("video");if(J.className="pf-video",J.src=F($.src,Z),J.controls=!0,$.width!=null)J.width=$.width;if($.height!=null)J.height=$.height;return J.style.maxWidth="100%",J}function R6($,Z){let J=N("div","pf-embed"),q=document.createElement("iframe");return q.src=F($.src,Z),q.style.width="100%",q.style.height=$.height!=null?`${$.height}px`:"400px",q.style.border="none",q.setAttribute("sandbox","allow-scripts"),J.appendChild(q),J}var j6=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 k6($,Z){let J=N("div","pf-svg"),q=F($.content,Z);if(!q.includes("<svg"))return J;let Y=new DOMParser().parseFromString(q,"image/svg+xml").querySelector("svg");if(!Y)return J;return Y4(Y),J.appendChild(document.importNode(Y,!0)),J}function Y4($){let Z=Array.from($.children);for(let J of Z){if(!j6.has(J.tagName.toLowerCase())){J.remove();continue}for(let q of Array.from(J.attributes)){let Q=q.name.toLowerCase();if(Q.startsWith("on")||Q==="href"&&q.value.trim().toLowerCase().startsWith("javascript:"))J.removeAttribute(q.name)}Y4(J)}}function A6($,Z){let J=N("div","pf-dropzone");return J.style.padding="32px",J.style.textAlign="center",J.style.cursor="pointer",J.textContent=F($.label??"Drop files here",Z),J.addEventListener("dragover",(q)=>{q.preventDefault(),J.classList.add("pf-dropzone-active")}),J.addEventListener("dragleave",()=>{J.classList.remove("pf-dropzone-active")}),J.addEventListener("drop",(q)=>{q.preventDefault(),J.classList.remove("pf-dropzone-active")}),J}function f6($,Z){let J=N("div","pf-mermaid");J.setAttribute("data-mermaid","true");let q=F($.content,Z);if(J.textContent=q,typeof globalThis.mermaid<"u")J.classList.add("mermaid"),J.textContent=q;return J}var S6="https://cdn.jsdelivr.net/npm/pdfjs-dist@4.9/build/pdf.min.mjs",w6="https://cdn.jsdelivr.net/npm/pdfjs-dist@4.9/build/pdf.worker.min.mjs",Q1=null,w0=null;async function C6(){if(Q1)return Q1;if(w0)return w0;return w0=import(S6).then(($)=>{let Z=$;return Z.GlobalWorkerOptions.workerSrc=w6,Q1=Z,Z}),w0}function H4(){G("PdfViewer",b6)}function b6($,Z){let J=N("div","pf-pdf-viewer"),q=$.src!=null?F($.src,Z):void 0,Q=$.data,Y=$.page!=null?$.page:1,U=$.zoom!=null?$.zoom:"fit-width",H=$.toolbar!==!1,W=$.height!=null?$.height:600;J.style.height=`${W}px`,J.style.display="flex",J.style.flexDirection="column",J.style.overflow="hidden",J.style.border="1px solid var(--color-border-primary, #e5e7eb)",J.style.borderRadius="var(--border-radius-md, 0.375rem)",J.style.background="var(--color-background-secondary, #f9fafb)";let _=N("div","pf-pdf-loading");return _.textContent="Loading PDF…",_.style.display="flex",_.style.alignItems="center",_.style.justifyContent="center",_.style.flex="1",_.style.color="var(--color-text-secondary, #6b7280)",J.appendChild(_),y6(J,_,{src:q,data:Q,initialPage:Y,zoom:U,showToolbar:H}),J}async function y6($,Z,J){try{let q=await C6(),Q;if(J.src)Q={url:J.src};else if(J.data){let B=atob(J.data),K=new Uint8Array(B.length);for(let L=0;L<B.length;L++)K[L]=B.charCodeAt(L);Q={data:K}}else{Z.textContent="Error: No PDF source provided";return}let Y=await q.getDocument(Q).promise;Z.remove();let U=Math.max(1,Math.min(J.initialPage,Y.numPages)),H=null,W=null;if(J.showToolbar){let B=m6(Y.numPages,U,{onPrev:()=>{if(U>1)U--,X()},onNext:()=>{if(U<Y.numPages)U++,X()},onPageChange:(K)=>{let L=Math.max(1,Math.min(K,Y.numPages));if(L!==U)U=L,X()}});H=B.pageInput,W=B.pageCount,$.insertBefore(B.el,$.firstChild)}let _=N("div","pf-pdf-canvas-container");_.style.flex="1",_.style.overflow="auto",_.style.display="flex",_.style.justifyContent="center",_.style.padding="8px",$.appendChild(_);let z=document.createElement("canvas");z.style.display="block",z.style.boxShadow="var(--shadow-md, 0 4px 6px -1px rgba(0,0,0,.1))",_.appendChild(z);async function X(){let B=await Y.getPage(U),K=_.clientWidth-16,L,M=B.getViewport({scale:1});if(J.zoom==="fit-width")L=K/M.width;else if(J.zoom==="fit-page"){let I=_.clientHeight-16,A=K/M.width,T=I/M.height;L=Math.min(A,T)}else L=typeof J.zoom==="number"?J.zoom:1;let E=B.getViewport({scale:L});z.width=E.width,z.height=E.height,z.style.width=`${E.width}px`,z.style.height=`${E.height}px`;let D=z.getContext("2d");if(!D)return;if(await B.render({canvasContext:D,viewport:E}).promise,H)H.value=String(U);if(W)W.textContent=`/ ${Y.numPages}`}await X()}catch(q){Z.textContent=`PDF Error: ${q instanceof Error?q.message:String(q)}`,Z.style.color="var(--color-text-danger, #dc2626)"}}function m6($,Z,J){let q=N("div","pf-pdf-toolbar");q.style.display="flex",q.style.alignItems="center",q.style.gap="8px",q.style.padding="6px 12px",q.style.borderBottom="1px solid var(--color-border-primary, #e5e7eb)",q.style.background="var(--color-background-primary, #fff)",q.style.flexShrink="0",q.style.fontSize="13px";let Q=document.createElement("button");Q.textContent="‹",Q.title="Previous page",Q.className="pf-pdf-btn",U4(Q),Q.addEventListener("click",J.onPrev);let Y=document.createElement("button");Y.textContent="›",Y.title="Next page",Y.className="pf-pdf-btn",U4(Y),Y.addEventListener("click",J.onNext);let U=document.createElement("input");U.type="number",U.min="1",U.max=String($),U.value=String(Z),U.style.width="48px",U.style.textAlign="center",U.style.border="1px solid var(--color-border-primary, #e5e7eb)",U.style.borderRadius="4px",U.style.padding="2px 4px",U.style.fontSize="13px",U.addEventListener("change",()=>{let W=parseInt(U.value,10);if(!isNaN(W))J.onPageChange(W)});let H=document.createElement("span");return H.textContent=`/ ${$}`,H.style.color="var(--color-text-secondary, #6b7280)",q.appendChild(Q),q.appendChild(U),q.appendChild(H),q.appendChild(Y),{el:q,pageInput:U,pageCount:H}}function U4($){$.style.border="1px solid var(--color-border-primary, #e5e7eb)",$.style.borderRadius="4px",$.style.background="var(--color-background-primary, #fff)",$.style.cursor="pointer",$.style.padding="2px 8px",$.style.fontSize="16px",$.style.lineHeight="1"}var b0=["#3b82f6","#10b981","#f59e0b","#ef4444","#8b5cf6","#ec4899"];function W0($,Z){let J=document.createElement("div");return J.className="pf-chart-tooltip",$.appendChild(J),$.addEventListener("mouseleave",()=>{J.classList.remove("pf-visible")}),{wrapper:$,tooltip:J,svgEl:Z}}function e($,Z,J,q,Q){let{tooltip:Y,svgEl:U,wrapper:H}=$;if(Q.length===0)return;let W="";if(q)W+=`<div class="pf-chart-tooltip-label">${C0(q)}</div>`;for(let E of Q)W+='<div class="pf-chart-tooltip-row">',W+=`<span class="pf-chart-tooltip-dot" style="background:${C0(E.color)}"></span>`,W+=`<span>${C0(E.label)}:</span> <strong>${C0(String(E.value))}</strong>`,W+="</div>";Y.innerHTML=W;let _=U.getBoundingClientRect(),z=H.getBoundingClientRect(),X=U.viewBox.baseVal,B=_.width/(X.width||1),K=_.left-z.left+Z*B,L=Y.offsetWidth||100,M=K+12;if(M+L>z.width)M=K-L-12;Y.style.left=`${Math.max(0,M)}px`,Y.style.top="4px",Y.classList.add("pf-visible")}function C0($){return $.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;")}function W4($,Z,J,q,Q,Y,U,H){let W=Q.plotWidth/J.length;for(let _=0;_<J.length;_++){let z=Q.plotLeft+_*W,X=document.createElementNS("http://www.w3.org/2000/svg","rect");X.setAttribute("x",String(z)),X.setAttribute("y",String(Q.plotTop)),X.setAttribute("width",String(W)),X.setAttribute("height",String(Q.plotHeight)),X.setAttribute("fill","transparent"),X.style.cursor="default";let B=Y?J[_][Y]:void 0,K=B!=null?H?H(B):String(B):void 0,L=q.map((I,A)=>({label:I.label??I.dataKey,value:U(J[_][I.dataKey],I,A),color:I.color??b0[A%b0.length]})),M=z+W/2,E=()=>e($,M,Q.plotTop,K,L),D=()=>$.tooltip.classList.remove("pf-visible");X.addEventListener("mouseenter",E),X.addEventListener("mouseleave",D),X.addEventListener("touchstart",E,{passive:!0}),X.addEventListener("touchend",D,{passive:!0}),Z.appendChild(X)}}function X4($,Z,J,q,Q,Y,U,H,W,_){let z=J.length===1?Q.plotWidth:Q.plotWidth/(J.length-1);for(let X=0;X<J.length;X++){let B=J.length===1?(Q.plotLeft+Q.plotRight)/2:Q.plotLeft+X/(J.length-1)*Q.plotWidth,K=J.length===1?Q.plotLeft:B-z/2,L=J.length===1?Q.plotWidth:z,M=document.createElementNS("http://www.w3.org/2000/svg","rect");M.setAttribute("x",String(Math.max(Q.plotLeft,K))),M.setAttribute("y",String(Q.plotTop)),M.setAttribute("width",String(Math.min(L,Q.plotRight-Math.max(Q.plotLeft,K)))),M.setAttribute("height",String(Q.plotHeight)),M.setAttribute("fill","transparent"),M.style.cursor="default";let E=Y?J[X][Y]:void 0,D=E!=null?_?_(E):String(E):void 0,I=q.map((j,S)=>({label:j.label??j.dataKey,value:U(J[X][j.dataKey],j,S),color:j.color??b0[S%b0.length]})),A=()=>{if(e($,B,Q.plotTop,D,I),H)H.setAttribute("x1",String(B)),H.setAttribute("x2",String(B)),H.setAttribute("opacity","1");if(W)for(let j of W){for(let S of j)S.setAttribute("data-visible","false");j[X]?.setAttribute("data-visible","true")}},T=()=>{if($.tooltip.classList.remove("pf-visible"),H)H.setAttribute("opacity","0");if(W)for(let j of W)for(let S of j)S.setAttribute("data-visible","false")};M.addEventListener("mouseenter",A),M.addEventListener("mouseleave",T),M.addEventListener("touchstart",A,{passive:!0}),M.addEventListener("touchend",T,{passive:!0}),Z.appendChild(M)}}var i=["#3b82f6","#10b981","#f59e0b","#ef4444","#8b5cf6","#ec4899"],Z0="var(--muted-foreground, #6b7280)",N0="var(--border, #e5e7eb)",X0="10";function y0($,Z,J,q=!1){let Q=J?44:0,Y=$-(q?44:0),U=10,H=Z-24;return{plotLeft:Q,plotRight:Y,plotTop:10,plotBottom:H,plotWidth:Y-Q,plotHeight:H-10}}function G4($,Z=5){if($<=0)return[0];let J=$/Z,q=Math.pow(10,Math.floor(Math.log10(J))),Q=J/q,Y=Q<=1.5?q:Q<=3?2*q:Q<=7?5*q:10*q,U=[];for(let H=0;H<=$+Y*0.01;H+=Y)U.push(Math.round(H*1000)/1000);return U}function Y1($,Z,J,q,Q){let Y=G4(J);for(let U of Y){let H=Z.plotBottom-(J>0?U/J*Z.plotHeight:0),W=s("text",{x:Z.plotLeft-6,y:H+3,"text-anchor":"end","font-size":X0,fill:Z0});if(W.textContent=W1(U,Q),$.appendChild(W),q&&U>0)$.appendChild(s("line",{x1:Z.plotLeft,y1:H,x2:Z.plotRight,y2:H,stroke:N0,"stroke-width":1,"stroke-dasharray":"4 3"}))}}function U1($,Z,J,q){let Q=G4(J);for(let Y of Q){let U=Z.plotBottom-(J>0?Y/J*Z.plotHeight:0),H=s("text",{x:Z.plotRight+6,y:U+3,"text-anchor":"start","font-size":X0,fill:Z0});H.textContent=W1(Y,q),$.appendChild(H)}}function H1($,Z,J,q,Q,Y){for(let U=0;U<Z.length;U++){let H=Z[U][J],W=s("text",{x:q(U),y:Q+14,"text-anchor":"middle","font-size":X0,fill:Z0});W.textContent=H==null?"":Y?Y(H):String(H),$.appendChild(W)}}function m0($,Z){$.appendChild(s("line",{x1:Z.plotLeft,y1:Z.plotBottom,x2:Z.plotRight,y2:Z.plotBottom,stroke:Z0,"stroke-width":1}))}function $0($,Z,J){if($==null)return"";let q=c(`{{ __v | ${Z} }}`,{...J,scope:{...J.scope,__v:$}});return q==null?String($):String(q)}function W1($,Z){if(Z==="currency")return`$${$.toLocaleString()}`;if(Z==="percent")return`${$}%`;if($>=1e6)return`${($/1e6).toFixed(1)}M`;if($>=1000)return`${($/1000).toFixed(1)}K`;return String($)}function J0($){let Z=$.yAxisFormat??$.valueFormat;return Z&&Z!=="auto"?Z:void 0}function X1($,Z,J){return(q,Q)=>{if(q===null||q===void 0)return"—";if(Q.tooltipFormat)return $0(q,Q.tooltipFormat,$);let Y=Q.yAxisId==="right"?J:Z;return W1(Number(q),Y)}}function Y0($,Z,J){let q=document.createElementNS("http://www.w3.org/2000/svg","svg");if(q.setAttribute("width","100%"),q.setAttribute("height",String(Z)),q.setAttribute("viewBox",`0 0 ${$} ${Z}`),q.setAttribute("role","img"),J)q.setAttribute("aria-label",`${J} chart`);return q.style.overflow="visible",q}function s($,Z){let J=document.createElementNS("http://www.w3.org/2000/svg",$);for(let[q,Q]of Object.entries(Z))J.setAttribute(q,String(Q));return J}function h0($,Z){let J=s("text",$);return J.textContent=Z,J}function G0($,Z,J,q){let Q=q*Math.PI/180;return{x:$+J*Math.cos(Q),y:Z-J*Math.sin(Q)}}function G1($,Z,J,q,Q){let Y=Math.max(2,Math.ceil(Math.abs(Q-q)/4)),U=[];for(let H=0;H<=Y;H++){let W=G0($,Z,J,q+(Q-q)*H/Y);U.push(`${H===0?"M":"L"} ${W.x.toFixed(2)} ${W.y.toFixed(2)}`)}return U.join(" ")}function B0($,Z,J){if(J===!1||Z.length<=1)return;let q=N("div","pf-chart-legend");q.style.display="flex",q.style.gap="12px",q.style.fontSize="12px",q.style.marginBottom="8px";for(let Q=0;Q<Z.length;Q++){let Y=N("div","pf-chart-legend-item");Y.style.display="flex",Y.style.alignItems="center",Y.style.gap="4px";let U=N("span");U.style.width="8px",U.style.height="8px",U.style.borderRadius="50%",U.style.backgroundColor=Z[Q].color??i[Q%i.length];let H=N("span");H.textContent=Z[Q].label??Z[Q].dataKey,Y.appendChild(U),Y.appendChild(H),q.appendChild(Y)}$.appendChild(q)}function M4(){G("BarChart",h6),G("LineChart",B4),G("AreaChart",B4),G("PieChart",v6),G("RadarChart",x6),G("ScatterChart",g6),G("RadialChart",u6),G("Histogram",p6)}function h6($,Z){let J=N("div","pf-chart pf-bar-chart"),q=c($.data,Z)??[],Q=$.series??[],Y=$.height??300;if(q.length===0||Q.length===0)return J.textContent="No chart data",J;let U=$.showYAxis!==!1,H=$.showGrid===!0,W=$.showYAxisRight===!0,_=$.showTooltip!==!1,z=$.xAxis,X=$.tooltipXKey,B=$.xAxisFormat,K=$.tooltipXFormat,L=Q.filter((O)=>O.yAxisId!=="right"),M=Q.filter((O)=>O.yAxisId==="right"),E=W&&M.length>0,D=L.length>0?Math.max(...q.flatMap((O)=>L.map((V)=>Number(O[V.dataKey]??0))),1):1,I=E?Math.max(...q.flatMap((O)=>M.map((V)=>Number(O[V.dataKey]??0))),1):1,A=400,T=y0(A,Y,U,E),j=Y0(A,Y,"Bar");if(U)Y1(j,T,D,H,J0($));if(E)U1(j,T,I,$.yAxisRightFormat);m0(j,T);let S=T.plotWidth/q.length,f=S/(Q.length+1);for(let O=0;O<q.length;O++)for(let V=0;V<Q.length;V++){let k=Q[V],b=q[O][k.dataKey];if(b===null||b===void 0)continue;let d=k.yAxisId==="right"?I:D,v=Number(b),P=Math.max(0,v/d*T.plotHeight),x=T.plotLeft+O*S+V*f+f/2,R=document.createElementNS("http://www.w3.org/2000/svg","rect");R.setAttribute("x",String(x)),R.setAttribute("y",String(T.plotBottom-P)),R.setAttribute("width",String(f*0.8)),R.setAttribute("height",String(P)),R.setAttribute("fill",k.color??i[V%i.length]),R.setAttribute("rx","2"),j.appendChild(R)}if(z){let O=B?(V)=>$0(V,B,Z):void 0;H1(j,q,z,(V)=>{return T.plotLeft+V*S+S/2},T.plotBottom,O)}if(_){let O=W0(J,j),V=X1(Z,J0($),$.yAxisRightFormat);W4(O,j,q,Q,T,X??z,V,K?(b)=>$0(b,K,Z):void 0)}return B0(J,Q,$.showLegend),J.appendChild(j),J}function B4($,Z){let J=N("div",`pf-chart pf-${$.type.toLowerCase()}-chart`),q=c($.data,Z)??[],Q=$.series??[],Y=$.height??300;if(q.length===0||Q.length===0)return J.textContent="No chart data",J;let U=$.showYAxis!==!1,H=$.showGrid===!0,W=$.showYAxisRight===!0,_=$.showTooltip!==!1,z=$.xAxis,X=$.tooltipXKey,B=$.xAxisFormat,K=$.tooltipXFormat,L=Q.filter((V)=>V.yAxisId!=="right"),M=Q.filter((V)=>V.yAxisId==="right"),E=W&&M.length>0,D=L.length>0?Math.max(...q.flatMap((V)=>L.map((k)=>Number(V[k.dataKey]??0))),1):1,I=E?Math.max(...q.flatMap((V)=>M.map((k)=>Number(V[k.dataKey]??0))),1):1,A=400,T=y0(A,Y,U,E),j=Y0(A,Y,$.type==="AreaChart"?"Area":"Line"),S=$.type==="AreaChart";if(U)Y1(j,T,D,H,J0($));if(E)U1(j,T,I,$.yAxisRightFormat);m0(j,T);let f=[];for(let V=0;V<Q.length;V++){let k=Q[V],b=k.yAxisId==="right",u=b?I:D,d=k.color??i[V%i.length],v=q.map((R,y)=>{let p=R[k.dataKey],n=p===null||p===void 0,U0=q.length===1?(T.plotLeft+T.plotRight)/2:T.plotLeft+y/(q.length-1)*T.plotWidth,f4=n?T.plotBottom:T.plotBottom-Number(p)/u*T.plotHeight;return{x:U0,y:f4,isNull:n}});if(S){let R=[],y=()=>{if(R.length<2){R=[];return}let p=`M ${R[0].x},${T.plotBottom} `+R.map((U0)=>`L ${U0.x},${U0.y}`).join(" ")+` L ${R[R.length-1].x},${T.plotBottom} Z`,n=document.createElementNS("http://www.w3.org/2000/svg","path");n.setAttribute("d",p),n.setAttribute("fill",d),n.setAttribute("opacity","0.15"),j.appendChild(n),R=[]};for(let p of v){if(p.isNull){y();continue}R.push(p)}y()}let P="";for(let R of v){if(R.isNull)continue;let y=v.indexOf(R),p=y===0||v[y-1].isNull;P+=`${p?"M":"L"} ${R.x},${R.y} `}if(P){let R=document.createElementNS("http://www.w3.org/2000/svg","path");if(R.setAttribute("d",P.trim()),R.setAttribute("fill","none"),R.setAttribute("stroke",d),R.setAttribute("stroke-width","2"),b)R.setAttribute("stroke-dasharray","6 3");j.appendChild(R)}let x=[];for(let R of v){let y=document.createElementNS("http://www.w3.org/2000/svg","circle");if(y.setAttribute("cx",String(R.x)),y.setAttribute("cy",String(R.y)),y.setAttribute("r","4"),y.setAttribute("fill",d),y.setAttribute("class","pf-data-dot"),y.setAttribute("data-visible","false"),y.style.pointerEvents="none",R.isNull)y.style.display="none";j.appendChild(y),x.push(y)}f.push(x)}let O=document.createElementNS("http://www.w3.org/2000/svg","line");if(O.setAttribute("class","pf-crosshair"),O.setAttribute("x1",String(T.plotLeft)),O.setAttribute("x2",String(T.plotLeft)),O.setAttribute("y1",String(T.plotTop)),O.setAttribute("y2",String(T.plotBottom)),O.setAttribute("stroke",Z0),O.setAttribute("stroke-width","1"),O.setAttribute("stroke-dasharray","3 3"),O.setAttribute("opacity","0"),j.appendChild(O),z){let V=B?(k)=>$0(k,B,Z):void 0;H1(j,q,z,(k)=>{return q.length===1?(T.plotLeft+T.plotRight)/2:T.plotLeft+k/(q.length-1)*T.plotWidth},T.plotBottom,V)}if(_){let V=W0(J,j),k=X1(Z,J0($),$.yAxisRightFormat);X4(V,j,q,Q,T,X??z,k,O,f,K?(u)=>$0(u,K,Z):void 0)}return B0(J,Q,$.showLegend),J.appendChild(j),J}function v6($,Z){let J=N("div","pf-chart pf-pie-chart"),q=c($.data,Z)??[],Q=$.series??[],Y=$.height??300,U=Math.min(Y,300),H=$.showTooltip!==!1,W=$.dataKey??Q[0]?.dataKey,_=$.nameKey??$.tooltipXKey??$.xAxis,z=Q.length>0?Q:W?[{dataKey:W,label:W}]:[];if(q.length===0||!W)return J.textContent="No chart data",J;let X=Y0(U,U,"Pie"),B=U/2,K=U/2,L=U/2-10,M=$.tooltipXFormat,E=J0($),D=(S)=>E?$0(S,E,Z):String(S),I=q.map((S)=>Number(S[W]??0)),A=I.reduce((S,f)=>S+f,0);if(A===0)return J.textContent="No chart data",J.appendChild(X),J;let T=H?W0(J,X):void 0,j=-Math.PI/2;for(let S=0;S<I.length;S++){let f=I[S]/A*2*Math.PI,O=j+f,V=f>Math.PI?1:0,k=B+L*Math.cos(j),b=K+L*Math.sin(j),u=B+L*Math.cos(O),d=K+L*Math.sin(O),v=i[S%i.length],P=document.createElementNS("http://www.w3.org/2000/svg","path");if(P.setAttribute("d",`M ${B},${K} L ${k},${b} A ${L},${L} 0 ${V} 1 ${u},${d} Z`),P.setAttribute("fill",v),P.style.cursor="default",T){let x=_?q[S][_]:void 0,R=x!=null?M?$0(x,M,Z):String(x):`Slice ${S+1}`,y=`${(I[S]/A*100).toFixed(1)}%`,p=j+f/2,n=B+L*0.6*Math.cos(p);P.addEventListener("mouseenter",()=>{e(T,n,K,R,[{label:z[0].label??W,value:`${D(I[S])} (${y})`,color:v}])}),P.addEventListener("mouseleave",()=>{T.tooltip.classList.remove("pf-visible")}),P.addEventListener("touchstart",()=>{e(T,n,K,R,[{label:z[0].label??W,value:`${D(I[S])} (${y})`,color:v}])},{passive:!0}),P.addEventListener("touchend",()=>{T.tooltip.classList.remove("pf-visible")},{passive:!0})}X.appendChild(P),j=O}return B0(J,z,$.showLegend),J.appendChild(X),J}function g6($,Z){let J=N("div","pf-chart pf-scatter-chart"),q=c($.data,Z)??[],Q=$.xAxis,Y=$.yAxis,U=$.zAxis,H=$.series??[],W=$.height??300;if(q.length===0||!Q||!Y)return J.textContent="No chart data",J;let _=$.showGrid!==!1,z=$.showTooltip!==!1,X=H[0]?.color??i[0],B=J0($),K=(P)=>B?$0(P,B,Z):String(Math.round(P*100)/100),L=q.map((P)=>Number(P[Q]??0)),M=q.map((P)=>Number(P[Y]??0)),E=Math.min(...L),D=Math.max(...L),I=Math.min(...M),A=Math.max(...M),T=D-E||1,j=A-I||1,S=U?q.map((P)=>Number(P[U]??0)):[],f=U?Math.max(...S,1):1,O=400,V=y0(O,W,!0),k=Y0(O,W,"Scatter"),b=(P)=>V.plotLeft+(P-E)/T*V.plotWidth,u=(P)=>V.plotBottom-(P-I)/j*V.plotHeight,d=4;for(let P=0;P<=d;P++){let x=I+j*P/d,R=u(x);if(k.appendChild(h0({x:V.plotLeft-6,y:R+3,"text-anchor":"end","font-size":X0,fill:Z0},K(x))),_&&P>0)k.appendChild(s("line",{x1:V.plotLeft,y1:R,x2:V.plotRight,y2:R,stroke:N0,"stroke-width":1,"stroke-dasharray":"4 3"}))}m0(k,V);for(let P of[E,(E+D)/2,D])k.appendChild(h0({x:b(P),y:V.plotBottom+14,"text-anchor":"middle","font-size":X0,fill:Z0},String(Math.round(P*100)/100)));let v=z?W0(J,k):void 0;for(let P=0;P<q.length;P++){let x=b(L[P]),R=u(M[P]),y=U?4+Math.sqrt(S[P]/f)*14:4,p=s("circle",{cx:x,cy:R,r:y,fill:X,"fill-opacity":U?0.6:0.85});if(v){let n=[{label:Q,value:K(L[P]),color:X},{label:Y,value:K(M[P]),color:X},...U?[{label:U,value:K(S[P]),color:X}]:[]],U0=H[0]?.label??"Point";p.addEventListener("mouseenter",()=>e(v,x,R,U0,n)),p.addEventListener("mouseleave",()=>v.tooltip.classList.remove("pf-visible")),p.addEventListener("touchstart",()=>e(v,x,R,U0,n),{passive:!0}),p.addEventListener("touchend",()=>v.tooltip.classList.remove("pf-visible"),{passive:!0})}k.appendChild(p)}return B0(J,H,$.showLegend),J.appendChild(k),J}function u6($,Z){let J=N("div","pf-chart pf-radial-chart"),q=c($.data,Z)??[],Q=$.series??[],Y=$.dataKey??Q[0]?.dataKey,U=$.nameKey??$.tooltipXKey??$.xAxis,H=$.height??300;if(q.length===0||!Y)return J.textContent="No chart data",J;let W=Math.min(H,300),_=W/2,z=W/2,X=W/2-10,B=Math.max(0,Math.min($.innerRadius??30,X-10)),K=$.startAngle??180,L=$.endAngle??0,M=$.showTooltip!==!1,E=q.map((V)=>Number(V[Y]??0)),D=Math.max(...E,1),I=Y0(W,W,"Radial"),A=(X-B)/q.length,T=Math.max(2,A*0.7),j=J0($),S=(V)=>j?$0(V,j,Z):String(V),f=M?W0(J,I):void 0,O=[];for(let V=0;V<q.length;V++){let k=X-A*V-A/2,b=Q[V]?.color??i[V%i.length],u=E[V]/D,d=K+u*(L-K),v=U?q[V][U]:null,P=v!=null?String(v):Q[V]?.label??Y;O.push({dataKey:P||Y,label:P||Y,color:b}),I.appendChild(s("path",{d:G1(_,z,k,K,L),fill:"none",stroke:N0,"stroke-width":T,"stroke-linecap":"round"}));let x=s("path",{d:G1(_,z,k,K,d),fill:"none",stroke:b,"stroke-width":T,"stroke-linecap":"round"});if(f){let R=G0(_,z,k,(K+d)/2),y=[{label:Y,value:S(E[V]),color:b}],p=P||Y;x.addEventListener("mouseenter",()=>e(f,R.x,R.y,p,y)),x.addEventListener("mouseleave",()=>f.tooltip.classList.remove("pf-visible")),x.addEventListener("touchstart",()=>e(f,R.x,R.y,p,y),{passive:!0}),x.addEventListener("touchend",()=>f.tooltip.classList.remove("pf-visible"),{passive:!0})}I.appendChild(x)}return B0(J,O,$.showLegend),J.appendChild(I),J}function x6($,Z){let J=N("div","pf-chart pf-radar-chart"),q=c($.data,Z)??[],Q=$.series??[],Y=$.axisKey??$.xAxis,U=$.height??300;if(q.length===0||Q.length===0)return J.textContent="No chart data",J;let H=$.filled!==!1,W=$.showDots===!0,_=$.showGrid!==!1,z=$.showTooltip!==!1,X=Math.min(U,320),B=X/2,K=X/2,L=X/2-24,M=q.length,E=Math.max(...q.flatMap((f)=>Q.map((O)=>Number(f[O.dataKey]??0))),1),D=(f)=>90-360*f/M,I=(f)=>f.map((O)=>`${O.x.toFixed(1)},${O.y.toFixed(1)}`).join(" "),A=Y0(X,X,"Radar");if(_){for(let O=1;O<=4;O++){let V=L*O/4,k=Array.from({length:M},(b,u)=>G0(B,K,V,D(u)));A.appendChild(s("polygon",{points:I(k),fill:"none",stroke:N0,"stroke-width":1}))}for(let O=0;O<M;O++){let V=G0(B,K,L,D(O));A.appendChild(s("line",{x1:B,y1:K,x2:V.x,y2:V.y,stroke:N0,"stroke-width":1}))}}for(let f=0;f<M;f++){let O=G0(B,K,L+12,D(f)),V=Y?q[f][Y]:null;A.appendChild(h0({x:O.x,y:O.y+3,"text-anchor":"middle","font-size":X0,fill:Z0},V!=null?String(V):""))}let T=z?W0(J,A):void 0,j=J0($),S=(f)=>j?$0(f,j,Z):String(f);for(let f=0;f<Q.length;f++){let O=Q[f],V=O.color??i[f%i.length],k=q.map((b,u)=>G0(B,K,Number(b[O.dataKey]??0)/E*L,D(u)));if(A.appendChild(s("polygon",{points:I(k),fill:H?V:"none","fill-opacity":H?0.2:0,stroke:V,"stroke-width":2})),W||T)for(let b=0;b<k.length;b++){let u=s("circle",{cx:k[b].x,cy:k[b].y,r:W?3:6,fill:W?V:"transparent","fill-opacity":W?1:0});if(T){let d=Y?q[b][Y]:null,v=d!=null?String(d):O.label??O.dataKey,P=[{label:O.label??O.dataKey,value:S(Number(q[b][O.dataKey]??0)),color:V}];u.addEventListener("mouseenter",()=>e(T,k[b].x,k[b].y,v,P)),u.addEventListener("mouseleave",()=>T.tooltip.classList.remove("pf-visible")),u.addEventListener("touchstart",()=>e(T,k[b].x,k[b].y,v,P),{passive:!0}),u.addEventListener("touchend",()=>T.tooltip.classList.remove("pf-visible"),{passive:!0})}A.appendChild(u)}}return B0(J,Q,$.showLegend),J.appendChild(A),J}function p6($,Z){let J=N("div","pf-chart pf-histogram"),q=c($.data,Z);if(!q||q.length===0)return J.textContent="No data",J;let Q=q,Y=$.bins??10,U=$.height??200,H=$.color??i[0],W=Math.min(...Q),z=(Math.max(...Q)-W)/Y||1,X=Array(Y).fill(0);for(let D of Q){let I=Math.min(Math.floor((D-W)/z),Y-1);X[I]++}let B=Math.max(...X),K=300,L=U,M=K/Y,E=Y0(K,L,"Histogram");for(let D=0;D<Y;D++){let I=B>0?X[D]/B*L:0,A=document.createElementNS("http://www.w3.org/2000/svg","rect");A.setAttribute("x",String(D*M)),A.setAttribute("y",String(L-I)),A.setAttribute("width",String(M-1)),A.setAttribute("height",String(I)),A.setAttribute("fill",H),E.appendChild(A)}return J.appendChild(E),J}function _4(){G("Table",c6),G("TableHead",B1("thead")),G("TableBody",B1("tbody")),G("TableFooter",B1("tfoot")),G("TableRow",l6),G("TableHeader",d6),G("TableCell",i6),G("TableCaption",s6),G("ExpandableRow",n6)}function c6($,Z){let J=document.createElement("table");return J.className="pf-table",J.style.width="100%",J.style.borderCollapse="collapse",w($,J,Z),J}function B1($){return(Z,J)=>{let q=document.createElement($);return q.className=`pf-${$}`,w(Z,q,J),q}}function l6($,Z){let J=document.createElement("tr");return J.className="pf-table-row",w($,J,Z),J}function d6($,Z){let J=document.createElement("th");return J.className="pf-table-header",J.style.textAlign="left",J.style.padding="8px 12px",J.style.fontWeight="600",J.textContent=F($.content,Z),J}function i6($,Z){let J=document.createElement("td");if(J.className="pf-table-cell",J.style.padding="8px 12px",$.colSpan!=null)J.colSpan=$.colSpan;if($.rowSpan!=null)J.rowSpan=$.rowSpan;return w($,J,Z),J}function s6($,Z){let J=document.createElement("caption");return J.className="pf-table-caption",J.style.padding="8px",J.style.fontSize="14px",J.textContent=F($.content,Z),J}function n6($,Z){let J=N("div","pf-expandable-row"),q=N("div","pf-expandable-row-summary");q.style.cursor="pointer",q.style.display="flex",q.style.alignItems="center",q.style.gap="8px";let Q=N("span","pf-expandable-arrow");Q.textContent="▶",Q.style.transition="transform 0.2s",Q.style.fontSize="10px",q.appendChild(Q);let Y=$.summary;if(Y)for(let W of Y)q.appendChild(g(W,Z));let U=N("div","pf-expandable-row-detail");U.style.display="none",U.style.paddingLeft="24px",w($,U,Z);let H=!1;return q.addEventListener("click",()=>{H=!H,U.style.display=H?"block":"none",Q.style.transform=H?"rotate(90deg)":""}),J.appendChild(q),J.appendChild(U),J}var N4=!1;function v0(){if(N4)return;N4=!0,p1(),i1(),r1(),a1(),t1(),e1(),$4(),q4(),Q4(),H4(),M4(),_4()}function _1($){return $.replace(/[^a-zA-Z0-9_-]/g,"")}function N1($){return $.replace(/[{}<>;]/g,"").replace(/\b(url|expression)\s*\(/gi,"")}function M1($,Z=" "){return Object.entries($).map(([J,q])=>`${Z}--${_1(J)}: ${N1(q)};`).join(`
7
+ `)}function z4($){if(!$)return"";let Z=[];if($.light&&Object.keys($.light).length>0)Z.push(`:root {
8
+ ${M1($.light)}
9
+ }`);if($.dark&&Object.keys($.dark).length>0){let J=M1($.dark);Z.push(`.dark, [data-theme="dark"] {
10
10
  ${J}
11
11
  }`),Z.push(`@media (prefers-color-scheme: dark) {
12
12
  :root:not([data-theme="light"]):not(.light) {
13
- ${G1($.dark," ")}
13
+ ${M1($.dark," ")}
14
14
  }
15
15
  }`)}return Z.join(`
16
- `)}function N0($,Z){$.setAttribute("data-theme",Z),$.classList.toggle("dark",Z==="dark"),$.classList.toggle("light",Z==="light")}function _1($,Z){if(!Z)return;if(Z.light)for(let[J,q]of Object.entries(Z.light))$.style.setProperty(`--${B1(J)}`,M1(q));if(Z.dark){let q=document.getElementById("prefab-dark-theme");if(!q)q=document.createElement("style"),q.id="prefab-dark-theme",document.head.appendChild(q);q.textContent=_4({dark:Z.dark})}}function N1($,Z){if(!$||typeof document>"u")return;let J=(q)=>{for(let[Q,Y]of Object.entries($))if(s6(Q,q))q.preventDefault(),Z(Y)};return document.addEventListener("keydown",J),()=>document.removeEventListener("keydown",J)}function s6($,Z){let J=$.toLowerCase().split("+").map((Y)=>Y.trim()),q=J[J.length-1],Q=new Set(J.slice(0,-1));if(Q.has("ctrl")!==(Z.ctrlKey||Z.metaKey))return!1;if(Q.has("shift")!==Z.shiftKey)return!1;if(Q.has("alt")!==Z.altKey)return!1;return Z.key.toLowerCase()===q}var N4='<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>',E4='<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>',F4={"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 n6($,Z){try{let q=localStorage.getItem(Z);if(q==="light"||q==="dark")return q}catch{}let J=$.getAttribute("data-theme")??document.documentElement.getAttribute("data-theme");if(J==="light"||J==="dark")return J;if(typeof window<"u"&&window.matchMedia("(prefers-color-scheme: light)").matches)return"light";return"dark"}function E1($,Z){if(typeof document>"u")return()=>{};let J=Z?.position??"top-right",q=Z?.storageKey??"prefab-theme",Q=Z?.syncDocument??!0,Y=getComputedStyle($).position;if(Y==="static"||Y==="")$.style.position="relative";let U=document.createElement("button");U.className="pf-theme-toggle",U.setAttribute("aria-label","Toggle theme"),U.setAttribute("title","Toggle light/dark"),Object.assign(U.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 H=F4[J]??F4["top-right"];for(let X of H.split(";")){let[B,z]=X.split(":").map((L)=>L.trim());if(B&&z)U.style.setProperty(B,z)}U.addEventListener("mouseenter",()=>{U.style.opacity="1"}),U.addEventListener("mouseleave",()=>{U.style.opacity="0.7"});function W(X){if(N0($,X),Q)N0(document.documentElement,X);U.innerHTML=X==="dark"?E4:N4;try{localStorage.setItem(q,X)}catch{}}let N=n6($,q);W(N),U.addEventListener("click",()=>{let X=$.getAttribute("data-theme")??"dark";W(X==="dark"?"light":"dark")}),$.appendChild(U);let E;if(Q)E=new MutationObserver((X)=>{for(let B of X)if(B.type==="attributes"&&B.attributeName==="data-theme"){let z=document.documentElement.getAttribute("data-theme");if((z==="light"||z==="dark")&&z!==$.getAttribute("data-theme")){N0($,z),U.innerHTML=z==="dark"?E4:N4;try{localStorage.setItem(q,z)}catch{}}}}),E.observe(document.documentElement,{attributes:!0,attributeFilter:["data-theme"]});return()=>{E?.disconnect(),U.remove()}}function h0($){let Z=$?.baseUrl??(typeof window<"u"?window.location.origin:""),J={"Content-Type":"application/json",...$?.headers},q=$?.fetch??globalThis.fetch.bind(globalThis);return{async callTool(Q,Y){let U=await q(`${Z}/mcp/tools/call`,{method:"POST",headers:J,body:JSON.stringify({jsonrpc:"2.0",method:"tools/call",params:{name:Q,arguments:Y}})});if(!U.ok)throw Error(`MCP tool call failed: ${U.status} ${U.statusText}`);let H=await U.json();if(H.error)throw Error(H.error.message??"MCP tool call returned error");let W=H.result?.content??H.content??[];for(let N of W)if(N.type==="text"&&N.text!==void 0){try{let E=JSON.parse(N.text);if(typeof E==="object"&&E!==null&&"$prefab"in E)return E;return E}catch{}return N.text}return H.result??H},async sendMessage(Q){await q(`${Z}/mcp/messages`,{method:"POST",headers:J,body:JSON.stringify({message:Q})})}}}function v0(){return{callTool($){return b.warn(`No MCP transport: callTool('${$}') ignored`),Promise.resolve(null)},sendMessage($){return b.warn("No MCP transport: sendMessage ignored",$),Promise.resolve()}}}function r6($){return $!==null&&typeof $==="object"&&$.jsonrpc==="2.0"}class z0{hostOrigin;listeners=new Map;protocol="prefab";cleanup;pending=new Map;callIdCounter=0;rpcPending=new Map;rpcIdCounter=0;sentRpcIds=new Set;postFn;_hostSupportsSubscriptions=!1;constructor($="*"){this.hostOrigin=$}connect(){if(typeof window>"u")return;let $=t6();if($)this.postFn=(J)=>$.postMessage(J);let Z=(J)=>{if(this.hostOrigin!=="*"&&J.origin!==this.hostOrigin)return;let q=J.data;if(r6(q)){this.handleJsonRpc(q);return}let Q=q;if(!Q?.type.startsWith("prefab:"))return;if(Q.type==="prefab:tool-call-response"&&Q.id){let U=this.pending.get(Q.id);if(U){if(this.pending.delete(Q.id),Q.payload?.error!=null)U.reject(Error(Q.payload.error));else U.resolve(Q.payload?.result);return}}let Y=this.listeners.get(Q.type);if(Y)for(let U of Y)U(Q.payload??{})};window.addEventListener("message",Z),this.cleanup=()=>window.removeEventListener("message",Z)}async initialize($){try{return await Promise.any([this.initPrefab($),this.initJsonRpc($)])}catch(Z){let J=Z instanceof AggregateError?Z.errors.map((q)=>q.message).join("; "):String(Z);throw Error(`Bridge init failed — no host responded. Tried: ${J}`,{cause:Z})}}createTransport(){if(this.protocol==="jsonrpc")return this.createJsonRpcTransport();return this.createPrefabTransport()}requestMode($){if(this.protocol==="jsonrpc")this.sendRpcRequest("ui/request-display-mode",{mode:$});else this.sendPrefab("prefab:request-mode",{mode:$})}openLink($,Z){if(this.protocol==="jsonrpc")this.sendRpcRequest("ui/open-link",{url:$,target:Z});else this.sendPrefab("prefab:open-link",{url:$,target:Z})}updateContext($){if(this.protocol==="jsonrpc")this.sendRpcRequest("ui/update-model-context",{structuredContent:$});else this.sendPrefab("prefab:update-context",{context:$})}setupAutoResize($){if(typeof ResizeObserver>"u")return o6;let Z=-1,J=-1,q=(U,H)=>{if(U===Z&&H===J)return;if(Z=U,J=H,this.protocol==="jsonrpc")this.sendRpcNotification("ui/notifications/size-changed",{width:U,height:H});else this.sendPrefab("prefab:size-changed",{width:U,height:H})},Q=new ResizeObserver((U)=>{for(let H of U)if(H.borderBoxSize.length){let W=H.borderBoxSize[0];q(Math.ceil(W.inlineSize),Math.ceil(W.blockSize))}else{let W=H.target.getBoundingClientRect();q(Math.ceil(W.width),Math.ceil(W.height))}});Q.observe($);let Y=$.getBoundingClientRect();return q(Math.ceil(Y.width),Math.ceil(Y.height)),()=>Q.disconnect()}notifyPreferredSize($){if(this.protocol==="jsonrpc")this.sendRpcNotification("ui/notifications/preferred-size",$);else this.sendPrefab("prefab:preferred-size",$)}subscribe($,Z){let J=(q)=>{if(q.uri!==$)return;Z(q.contents??q.data??q)};if(this.protocol==="jsonrpc")this.on("prefab:resource-updated",J),this.sendRpcRequest("resources/subscribe",{uri:$});else this.on("prefab:resource-updated",J),this.sendPrefab("prefab:subscribe",{uri:$});return()=>{if(this.off("prefab:resource-updated",J),this.protocol==="jsonrpc")this.sendRpcRequest("resources/unsubscribe",{uri:$});else this.sendPrefab("prefab:unsubscribe",{uri:$})}}get supportsSubscriptions(){return this._hostSupportsSubscriptions}on($,Z){if(!this.listeners.has($))this.listeners.set($,new Set);let J=this.listeners.get($);if(J)J.add(Z)}off($,Z){this.listeners.get($)?.delete(Z)}disconnect(){this.cleanup?.(),this.listeners.clear();for(let[,$]of this.pending)$.reject(Error("Bridge disconnected"));this.pending.clear();for(let[,$]of this.rpcPending)$.reject(Error("Bridge disconnected"));this.rpcPending.clear(),this.sentRpcIds.clear()}get activeProtocol(){return this.protocol}initPrefab($){return new Promise((Z,J)=>{let q=!1,Q=(Y)=>{if(q)return;q=!0,this.off("prefab:init-response",Q),this.protocol="prefab";let U=Y.capabilities;this._hostSupportsSubscriptions=U?.subscriptions===!0,Z(Y)};this.on("prefab:init-response",Q),this.sendPrefab("prefab:init",{capabilities:$}),setTimeout(()=>{if(!q)q=!0,this.off("prefab:init-response",Q),J(Error("prefab:init timeout"))},2000)})}createPrefabTransport(){return{callTool:($,Z)=>{let J=`tc-${++this.callIdCounter}`;return new Promise((q,Q)=>{this.pending.set(J,{resolve:q,reject:Q}),this.sendPrefab("prefab:tool-call",{tool:$,arguments:Z},J),setTimeout(()=>{if(this.pending.has(J))this.pending.delete(J),Q(Error(`Tool call '${$}' timed out`))},30000)})},sendMessage:($)=>{return this.sendPrefab("prefab:send-message",{message:$}),Promise.resolve()},subscribe:($,Z)=>{return this.subscribe($,Z)},capabilities:{subscriptions:this._hostSupportsSubscriptions}}}sendPrefab($,Z,J){if(typeof window>"u")return;let q=window.parent!==window?window.parent:window,Q={type:$,payload:Z,id:J};q.postMessage(Q,this.hostOrigin)}handleJsonRpc($){if(!("method"in $)){let q=this.rpcPending.get($.id);if(q)if(this.rpcPending.delete($.id),$.error)q.reject(Error($.error.message));else q.resolve($.result);return}let Z=$.method,J=$.params??{};if($.id!=null&&this.sentRpcIds.delete($.id))return;if($.id!=null)this.postJsonRpc({jsonrpc:"2.0",id:$.id,result:{}});switch(Z){case"ui/notifications/tool-input":this.dispatch("prefab:tool-input",{args:J.arguments??J});break;case"ui/notifications/tool-input-partial":this.dispatch("prefab:tool-input-partial",{args:J.arguments??J});break;case"ui/notifications/tool-result":this.dispatch("prefab:tool-result",{result:J});break;case"ui/notifications/tool-cancelled":this.dispatch("prefab:tool-cancelled",J);break;case"ui/notifications/host-context-changed":{let q={};if(typeof J.theme==="string")q.colorScheme=J.theme;if(typeof J.styles==="object"&&J.styles!==null){let Q=J.styles;if(Q.variables)q.variables=Q.variables;if(typeof Q.css?.fonts==="string")q.fontCss=Q.css.fonts}this.dispatch("prefab:theme-update",q),this.dispatch("prefab:host-context-changed",J);break}case"ui/resource-teardown":this.dispatch("prefab:teardown",J);break;case"ui/notifications/resource-updated":case"notifications/resources/updated":this.dispatch("prefab:resource-updated",J);break}}initJsonRpc($){return new Promise((Z,J)=>{let q=++this.rpcIdCounter,Q=!1;this.rpcPending.set(q,{resolve:(Y)=>{if(Q)return;Q=!0,this.protocol="jsonrpc";let U=Y??{},H=U.hostInfo??{},W=U.hostContext??{},N=U.hostCapabilities??{},E;if(typeof W.theme==="string"||typeof W.styles==="object"){if(E={},typeof W.theme==="string")E.colorScheme=W.theme;if(typeof W.styles==="object"&&W.styles!==null){let B=W.styles;if(B.variables)E.variables=B.variables;if(typeof B.css?.fonts==="string")E.fontCss=B.css.fonts}}this.postJsonRpc({jsonrpc:"2.0",method:"ui/notifications/initialized",params:{}});let X=N.resources;this._hostSupportsSubscriptions=N.subscriptions===!0||X?.subscribe===!0,Z({hostName:H.name,hostVersion:H.version,capabilities:{toast:!0,navigation:N.openLinks!=null,messaging:!0,displayModes:W.availableDisplayModes??[]},theme:E,toolInput:void 0,meta:W})},reject:(Y)=>{if(Q)return;Q=!0,J(Y)}}),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(!Q)Q=!0,this.rpcPending.delete(q),J(Error("ui/initialize timeout"))},2000)})}createJsonRpcTransport(){return{callTool:($,Z)=>{return this.sendRpcRequest("tools/call",{name:$,arguments:Z})},sendMessage:($)=>{return this.sendRpcRequest("ui/message",{role:"user",content:{type:"text",text:$}})},subscribe:($,Z)=>{return this.subscribe($,Z)},capabilities:{subscriptions:this._hostSupportsSubscriptions}}}sendRpcRequest($,Z){let J=++this.rpcIdCounter;return new Promise((q,Q)=>{this.rpcPending.set(J,{resolve:q,reject:Q}),this.postJsonRpc({jsonrpc:"2.0",id:J,method:$,params:Z}),setTimeout(()=>{if(this.rpcPending.has(J))this.rpcPending.delete(J),Q(Error(`JSON-RPC '${$}' timed out`))},30000)})}sendRpcNotification($,Z){this.postJsonRpc({jsonrpc:"2.0",method:$,params:Z})}postJsonRpc($){if(typeof window>"u")return;if($.id!=null&&typeof $.method==="string")this.sentRpcIds.add($.id);if(this.postFn)this.postFn($);else(window.parent!==window?window.parent:window).postMessage($,this.hostOrigin)}dispatch($,Z){let J=this.listeners.get($);if(J)for(let q of J)q(Z)}}var o6=()=>{};function F1($,Z){if(Z.variables)for(let[J,q]of Object.entries(Z.variables))$.style.setProperty(J.startsWith("--")?J:`--${J}`,q);if(Z.colorScheme&&Z.colorScheme!=="auto")$.setAttribute("data-theme",Z.colorScheme);if(Z.fontCss)a6(Z.fontCss)}function a6($){if(document.getElementById("__prefab-host-fonts"))return;let J=document.createElement("style");J.id="__prefab-host-fonts",J.textContent=$,document.head.appendChild(J)}function g0(){if(typeof window>"u")return!1;try{return window.self!==window.top}catch{return!0}}function t6(){if(typeof window>"u")return;let $=window;if(typeof $.acquireVsCodeApi==="function")try{let Z=$.acquireVsCodeApi();if(Z!==null&&typeof Z==="object"&&"postMessage"in Z)return Z}catch{return}return}var L4=new Set(["Column","Row","Grid","GridItem","Container","Div","Span","Dashboard","DashboardItem","Pages","Page","Heading","H1","H2","H3","H4","Text","P","Lead","Large","Small","Muted","BlockQuote","Label","Link","Code","Markdown","Kbd","Card","CardHeader","CardTitle","CardDescription","CardContent","CardFooter","DataTable","Badge","Dot","Metric","Ring","Progress","Separator","Loader","Icon","Table","TableHead","TableBody","TableFooter","TableRow","TableHeader","TableCell","TableCaption","ExpandableRow","Form","Input","Textarea","Button","ButtonGroup","Select","SelectOption","SelectGroup","SelectLabel","SelectSeparator","Checkbox","Switch","Slider","Radio","RadioGroup","Combobox","ComboboxOption","ComboboxGroup","ComboboxLabel","ComboboxSeparator","Calendar","DatePicker","Field","FieldTitle","FieldDescription","FieldContent","FieldError","ChoiceCard","Tabs","Tab","Accordion","AccordionItem","Dialog","Popover","Tooltip","HoverCard","Carousel","ForEach","If","Elif","Else","Define","Use","Slot","Alert","AlertTitle","AlertDescription","Image","Audio","Video","Embed","Svg","DropZone","Mermaid","BarChart","LineChart","AreaChart","PieChart","RadarChart","ScatterChart","Sparkline","RadialChart","Histogram"]);function K1($,Z={}){let J=[],q=Z.strict??!1;if($==null||typeof $!=="object")return J.push({path:"$",message:"Wire data must be a non-null object"}),{valid:!1,errors:J};let Q=$;if(Q.$prefab==null||typeof Q.$prefab!=="object")J.push({path:"$.$prefab",message:"Missing or invalid $prefab header"});else if(typeof Q.$prefab.version!=="string")J.push({path:"$.$prefab.version",message:"version must be a string"});if(Q.view==null)J.push({path:"$.view",message:'Missing required "view" field'});else z1(Q.view,"$.view",J,q);if(Q.state!==void 0){if(Q.state===null||typeof Q.state!=="object"||Array.isArray(Q.state))J.push({path:"$.state",message:"state must be a plain object"})}if(Q.theme!==void 0)$5(Q.theme,J);if(Q.css!==void 0)K4(Q.css,"$.css",J);if(Q.stylesheets!==void 0)K4(Q.stylesheets,"$.stylesheets",J);if(Q.mode!==void 0&&Q.mode!=="light"&&Q.mode!=="dark")J.push({path:"$.mode",message:'mode must be "light" or "dark"'});if(Q.defs!==void 0)if(Q.defs===null||typeof Q.defs!=="object"||Array.isArray(Q.defs))J.push({path:"$.defs",message:"defs must be a plain object"});else for(let[Y,U]of Object.entries(Q.defs))z1(U,`$.defs.${Y}`,J,q);if(Q.keyBindings!==void 0)if(Q.keyBindings===null||typeof Q.keyBindings!=="object"||Array.isArray(Q.keyBindings))J.push({path:"$.keyBindings",message:"keyBindings must be a plain object"});else for(let[Y,U]of Object.entries(Q.keyBindings))L1(U,`$.keyBindings.${Y}`,J);return{valid:J.length===0,errors:J}}function z1($,Z,J,q){if($==null||typeof $!=="object"||Array.isArray($)){J.push({path:Z,message:"Component must be a plain object"});return}let Q=$;if(typeof Q.type!=="string"||Q.type.length===0){J.push({path:`${Z}.type`,message:'Component must have a non-empty "type" string'});return}if(q&&!L4.has(Q.type))J.push({path:`${Z}.type`,message:`Unknown component type: "${Q.type}"`});if(Q.children!==void 0)if(!Array.isArray(Q.children))J.push({path:`${Z}.children`,message:"children must be an array"});else for(let U=0;U<Q.children.length;U++)z1(Q.children[U],`${Z}.children[${U}]`,J,q);let Y=["onClick","on_click","onChange","on_change","onSubmit","on_submit","onMount","on_mount","onClose","on_close"];for(let U of Y)if(Q[U]!==void 0)L1(Q[U],`${Z}.${U}`,J);for(let[U,H]of Object.entries(Q)){if(U==="type"||e6.has(U)||Y.includes(U))continue;if(z4(H)||Array.isArray(H)&&H.some(z4))J.push({path:`${Z}.${U}`,message:`Components under "${U}" are ignored by the renderer; move them into "children"`})}}var e6=new Set(["children","fallback"]);function z4($){if($==null||typeof $!=="object"||Array.isArray($))return!1;let Z=$.type;return typeof Z==="string"&&L4.has(Z)}function L1($,Z,J){if(Array.isArray($)){for(let H=0;H<$.length;H++)L1($[H],`${Z}[${H}]`,J);return}if($==null||typeof $!=="object"){J.push({path:Z,message:"Action must be an object or array of objects"});return}let q=$,Q=typeof q.type==="string"&&q.type.length>0,Y=typeof q.action==="string"&&q.action.length>0;if(!Q&&!Y){J.push({path:`${Z}.type`,message:'Action must have a non-empty "type" or "action" string'});return}if((Y?q.action:q.type).toLowerCase()==="showtoast"){if(typeof q.message!=="string"||q.message.length===0)J.push({path:`${Z}.message`,message:'showToast requires a non-empty "message" string'})}}function K4($,Z,J){if(!Array.isArray($)){J.push({path:Z,message:`${Z} must be an array of strings`});return}for(let q=0;q<$.length;q++)if(typeof $[q]!=="string")J.push({path:`${Z}[${q}]`,message:"must be a string"})}function $5($,Z){if($===null||typeof $!=="object"||Array.isArray($)){Z.push({path:"$.theme",message:"theme must be a plain object"});return}let J=$;for(let q of["light","dark"])if(J[q]!==void 0){if(J[q]===null||typeof J[q]!=="object"||Array.isArray(J[q]))Z.push({path:`$.theme.${q}`,message:`theme.${q} must be a plain object`})}}var r={mount($,Z,J){if(m0(),J?.validate!==!1)for(let F of K1(Z).errors)b.warn(`wire validation ${F.path}: ${F.message}`);let q=Z,Q=[];if(q.pipes)for(let[F,D]of Object.entries(q.pipes))V4(F,D,Q);let Y=new E0(q.state),U;if(J?.transport&&"callTool"in J.transport)U=J.transport;else if(J?.transport)U=h0(J.transport);else U=v0();let H=J?.onToast??J5,W=new t0;function N(F){let D=F;if(q=D,D.state)Y.merge(D.state);if(D.defs)E.defs=D.defs;if(D.theme)_1($,D.theme);if(D.mode)D4($,D.mode);if(D.pipes)for(let[I,k]of Object.entries(D.pipes))V4(I,k,Q);for(let I of X)I.remove();if(X.length=0,X.push(...O4(D.css,D.stylesheets)),T4($,D.layout),B?.(),B=void 0,D.keyBindings)B=N1(D.keyBindings,async(I)=>{await m(I,{store:Y,transport:U,scope:{},rerender:()=>M(),remount:N,onToast:H})});M()}let E={store:Y,scope:{},transport:U,rerender:()=>M(),remount:N,onToast:H,defs:q.defs,destroyRegistry:W};if(_1($,q.theme),q.mode)D4($,q.mode);T4($,q.layout);let X=O4(q.css,q.stylesheets),B;if(q.keyBindings)B=N1(q.keyBindings,async(F)=>{await m(F,{store:Y,transport:U,scope:{},rerender:()=>M(),remount:N,onToast:H})});let z,L=J?.themeToggle??!0;if(L!==!1)z=E1($,typeof L==="object"?L:void 0);function M(){W.flush();let F=$.querySelector(".pf-theme-toggle");$.innerHTML="";let D=x(q.view,E);if($.appendChild(D),F)$.appendChild(F)}return M(),{rerender:()=>M(),update(F){if(Y.merge(F.update.state),M(),F.update.actions!=null)m(F.update.actions,E)},store:Y,destroy(){W.flush(),z?.(),B?.(),C1(),b1();for(let F of X)F.remove();for(let F of Q)c0(F);$.innerHTML=""}}},isPrefabData($){return $!=null&&typeof $==="object"&&"$prefab"in $},isPrefabUpdate($){return $!=null&&typeof $==="object"&&"$prefab"in $&&"update"in $}},Z5=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 V4($,Z,J){if(Z5.has($)){b.warn(`wire pipe "${$}" ignored — shadows built-in`);return}try{let q=Function("return ("+Z+")")();if(typeof q!=="function"){b.warn(`wire pipe "${$}" — source did not evaluate to a function`);return}p0($,q),J.push($)}catch(q){b.warn(`wire pipe "${$}" — failed to hydrate:`,q)}}function J5($){if(typeof document>"u")return;let Z=Q5(),J=document.createElement("div"),q=$.variant??"default";J.className=`pf-toast${q!=="default"?` pf-toast--${q}`:""}`,J.setAttribute("data-variant",q),J.style.marginBottom="8px",J.style.transition="opacity 0.3s ease";let Q=document.createElement("div");if(Q.textContent=$.message,Q.style.fontWeight="500",J.appendChild(Q),$.description){let U=document.createElement("div");U.textContent=$.description,U.style.fontSize="14px",U.style.color="var(--muted-foreground, #6b7280)",J.appendChild(U)}Z.appendChild(J);let Y=$.duration??4000;setTimeout(()=>{J.style.opacity="0",setTimeout(()=>J.remove(),300)},Y)}function D4($,Z){if(N0($,Z),typeof document<"u")N0(document.documentElement,Z)}function q5($){let Z=$.trim();if(Z.includes("{")||Z.includes("}"))return!1;return/^(https?:)?\/\//i.test(Z)||Z.startsWith("/")||/\.css(\?|#|$)/i.test(Z)}function O4($,Z){let J=[];if(typeof document>"u")return J;for(let q of $??[]){let Q=document.createElement("style");Q.textContent=q,Q.dataset.prefab="injected",document.head.appendChild(Q),J.push(Q)}for(let q of Z??[])if(q5(q)){let Q=document.createElement("link");Q.rel="stylesheet",Q.href=q,Q.dataset.prefab="injected",document.head.appendChild(Q),J.push(Q)}else{let Q=document.createElement("style");Q.textContent=q,Q.dataset.prefab="injected",document.head.appendChild(Q),J.push(Q)}return J}function T4($,Z){if($.style.height="",$.style.minHeight="",$.style.maxHeight="",$.style.overflow="",!Z)return;if(Z.preferredHeight!=null)$.style.height=`${Z.preferredHeight}px`;if(Z.minHeight!=null)$.style.minHeight=`${Z.minHeight}px`;if(Z.maxHeight!=null)$.style.maxHeight=`${Z.maxHeight}px`,$.style.overflow="auto"}function Q5(){let Z=document.getElementById("prefab-toast-container");if(!Z)Z=document.createElement("div"),Z.id="prefab-toast-container",Z.style.position="fixed",Z.style.bottom="16px",Z.style.right="16px",Z.style.zIndex="9999",Z.style.maxWidth="400px",document.body.appendChild(Z);return Z}if(typeof window<"u"){let $=window;$.PrefabRenderer=r,$.prefab={app:u0,mount:r.mount.bind(r),isPrefabData:r.isPrefabData.bind(r),isPrefabUpdate:r.isPrefabUpdate.bind(r),Bridge:z0,isIframe:g0,registerPipe:p0,unregisterPipe:c0,listPipes:j1,registerComponent:G,createThemeToggle:E1,validateWireFormat:K1,setLogLevel:P1};let Z=$.__PREFAB_DATA__;if(Z!=null){let J=document.getElementById("prefab-root");if(J)r.mount(J,Z)}}async function u0($){m0();let Z=$?.mode??"auto",J=Z==="bridge"||Z==="auto"&&g0(),q,Q,Y={capabilities:{}};if(J)Q=new z0($?.hostOrigin),Q.connect(),Y=await Q.initialize($?.capabilities??{toolInput:!0}),q=Q.createTransport();else if($?.transport)q=h0($.transport);else q=v0();if(Y.theme&&typeof document<"u")F1(document.documentElement,Y.theme);if(typeof document<"u"&&!Q)U5();let U,H,W,N,E,X=Y.toolInput,B;if(Q)Q.on("prefab:tool-input",(M)=>{let F=M.args??M;if(U)U(F);else X=F}),Q.on("prefab:tool-result",(M)=>{let F=M.result??M;if(H)H(F);else B=F}),Q.on("prefab:tool-cancelled",()=>{W?.()}),Q.on("prefab:tool-input-partial",(M)=>{N?.(M.args??M)}),Q.on("prefab:theme-update",(M)=>{if(typeof document<"u")F1(document.documentElement,M)}),Q.on("prefab:host-context-changed",(M)=>{E?.(M)});function z(M,...F){let D=V1(M),I=new E0,k={store:I,scope:{},transport:q,rerender:()=>T(),onToast:void 0};function T(){D.innerHTML="";for(let j of F)D.appendChild(x(j,k))}return T(),{rerender:T,store:I,destroy:()=>{D.innerHTML=""}}}return{callTool:(M,F={})=>q.callTool(M,F),sendMessage:(M)=>q.sendMessage(M),onToolInput:(M)=>{if(U=M,X){let F=X;X=void 0,queueMicrotask(()=>M(F))}},onToolResult:(M)=>{if(H=M,B!==void 0){let F=B;B=void 0,queueMicrotask(()=>M(F))}},onToolCancelled:(M)=>{W=M},onToolInputPartial:(M)=>{N=M},onHostContextChanged:(M)=>{E=M},render:z,mount:(M,F,D)=>{let I=V1(M);return r.mount(I,F,{transport:q,...D})},requestMode:(M)=>Q?.requestMode(M),openLink:(M,F)=>{if(Q)Q.openLink(M,F);else if(typeof window<"u")window.open(M,F??"_blank")},updateContext:(M)=>{if(Q)Q.updateContext(M)},setupAutoResize:(M)=>{if(!Q)return Y5;let F=typeof M==="string"?V1(M):M;return Q.setupAutoResize(F)},notifyPreferredSize:(M)=>{if(Q)Q.notifyPreferredSize(M)},host:Y,capabilities:Y.capabilities,theme:Y.theme,transport:q,destroy:()=>Q?.disconnect()}}var Y5=()=>{};function V1($){if(typeof $==="string"){if(typeof document>"u")throw Error("Cannot resolve selector outside browser");let Z=document.querySelector($);if(!Z)throw Error(`Element not found: ${$}`);return Z}return $}function U5(){function $(){let J=document.body.getAttribute("data-vscode-theme-kind");if(!J)return;let q=J.includes("light")?"light":"dark";document.documentElement.setAttribute("data-theme",q)}$(),new MutationObserver($).observe(document.body,{attributes:!0,attributeFilter:["data-vscode-theme-kind"]})}var O1=x0("auto"),I4="#root";function D1($){return r.isPrefabData($)}function P4($){return r.isPrefabUpdate($)}function R4($){if(D1($))return $;if($!==null&&typeof $==="object"){let Z=$;if(D1(Z.structuredContent))return Z.structuredContent;if(Array.isArray(Z.content))for(let J of Z.content){let q=J;if(q.type==="text"&&typeof q.text==="string")try{let Q=JSON.parse(q.text);if(D1(Q))return Q}catch{}}}return null}async function j4(){let $=document.querySelector(I4);if(!$){O1.error(`Mount target "${I4}" not found`);return}let Z=$,J=await u0();J.setupAutoResize(Z);let q;function Q(Y){if(q)q.destroy();if(q=J.mount(Z,Y),Y.layout)J.notifyPreferredSize(Y.layout)}J.onToolResult((Y)=>{let U=R4(Y);if(U)Q(U);else if(P4(Y)&&q)q.update(Y)}),J.onToolInput((Y)=>{let U=R4(Y);if(U)Q(U);else if(P4(Y)&&q)q.update(Y)})}function H5(){if(document.readyState==="loading")document.addEventListener("DOMContentLoaded",()=>{j4().catch(($)=>{O1.error("Boot failed:",$)})},{once:!0});else queueMicrotask(()=>{j4().catch(($)=>{O1.error("Boot failed:",$)})})}H5();})();
16
+ `)}function z0($,Z){$.setAttribute("data-theme",Z),$.classList.toggle("dark",Z==="dark"),$.classList.toggle("light",Z==="light")}function z1($,Z){if(!Z)return;if(Z.light)for(let[J,q]of Object.entries(Z.light))$.style.setProperty(`--${_1(J)}`,N1(q));if(Z.dark){let q=document.getElementById("prefab-dark-theme");if(!q)q=document.createElement("style"),q.id="prefab-dark-theme",document.head.appendChild(q);q.textContent=z4({dark:Z.dark})}}function E1($,Z){if(!$||typeof document>"u")return;let J=(q)=>{for(let[Q,Y]of Object.entries($))if(r6(Q,q))q.preventDefault(),Z(Y)};return document.addEventListener("keydown",J),()=>document.removeEventListener("keydown",J)}function r6($,Z){let J=$.toLowerCase().split("+").map((Y)=>Y.trim()),q=J[J.length-1],Q=new Set(J.slice(0,-1));if(Q.has("ctrl")!==(Z.ctrlKey||Z.metaKey))return!1;if(Q.has("shift")!==Z.shiftKey)return!1;if(Q.has("alt")!==Z.altKey)return!1;return Z.key.toLowerCase()===q}var E4='<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>',K4='<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>',F4={"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 a6($,Z){try{let q=localStorage.getItem(Z);if(q==="light"||q==="dark")return q}catch{}let J=$.getAttribute("data-theme")??document.documentElement.getAttribute("data-theme");if(J==="light"||J==="dark")return J;if(typeof window<"u"&&window.matchMedia("(prefers-color-scheme: light)").matches)return"light";return"dark"}function K1($,Z){if(typeof document>"u")return()=>{};let J=Z?.position??"top-right",q=Z?.storageKey??"prefab-theme",Q=Z?.syncDocument??!0,Y=getComputedStyle($).position;if(Y==="static"||Y==="")$.style.position="relative";let U=document.createElement("button");U.className="pf-theme-toggle",U.setAttribute("aria-label","Toggle theme"),U.setAttribute("title","Toggle light/dark"),Object.assign(U.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 H=F4[J]??F4["top-right"];for(let X of H.split(";")){let[B,K]=X.split(":").map((L)=>L.trim());if(B&&K)U.style.setProperty(B,K)}U.addEventListener("mouseenter",()=>{U.style.opacity="1"}),U.addEventListener("mouseleave",()=>{U.style.opacity="0.7"});function W(X){if(z0($,X),Q)z0(document.documentElement,X);U.innerHTML=X==="dark"?K4:E4;try{localStorage.setItem(q,X)}catch{}}let _=a6($,q);W(_),U.addEventListener("click",()=>{let X=$.getAttribute("data-theme")??"dark";W(X==="dark"?"light":"dark")}),$.appendChild(U);let z;if(Q)z=new MutationObserver((X)=>{for(let B of X)if(B.type==="attributes"&&B.attributeName==="data-theme"){let K=document.documentElement.getAttribute("data-theme");if((K==="light"||K==="dark")&&K!==$.getAttribute("data-theme")){z0($,K),U.innerHTML=K==="dark"?K4:E4;try{localStorage.setItem(q,K)}catch{}}}}),z.observe(document.documentElement,{attributes:!0,attributeFilter:["data-theme"]});return()=>{z?.disconnect(),U.remove()}}function g0($){let Z=$?.baseUrl??(typeof window<"u"?window.location.origin:""),J={"Content-Type":"application/json",...$?.headers},q=$?.fetch??globalThis.fetch.bind(globalThis);return{async callTool(Q,Y){let U=await q(`${Z}/mcp/tools/call`,{method:"POST",headers:J,body:JSON.stringify({jsonrpc:"2.0",method:"tools/call",params:{name:Q,arguments:Y}})});if(!U.ok)throw Error(`MCP tool call failed: ${U.status} ${U.statusText}`);let H=await U.json();if(H.error)throw Error(H.error.message??"MCP tool call returned error");let W=H.result?.content??H.content??[];for(let _ of W)if(_.type==="text"&&_.text!==void 0){try{let z=JSON.parse(_.text);if(typeof z==="object"&&z!==null&&"$prefab"in z)return z;return z}catch{}return _.text}return H.result??H},async sendMessage(Q){await q(`${Z}/mcp/messages`,{method:"POST",headers:J,body:JSON.stringify({message:Q})})}}}function u0(){return{callTool($){return C.warn(`No MCP transport: callTool('${$}') ignored`),Promise.resolve(null)},sendMessage($){return C.warn("No MCP transport: sendMessage ignored",$),Promise.resolve()}}}function o6($){return $!==null&&typeof $==="object"&&$.jsonrpc==="2.0"}class F0{hostOrigin;listeners=new Map;protocol="prefab";cleanup;pending=new Map;callIdCounter=0;rpcPending=new Map;rpcIdCounter=0;sentRpcIds=new Set;postFn;_hostSupportsSubscriptions=!1;constructor($="*"){this.hostOrigin=$}connect(){if(typeof window>"u")return;let $=$5();if($)this.postFn=(J)=>$.postMessage(J);let Z=(J)=>{if(this.hostOrigin!=="*"&&J.origin!==this.hostOrigin)return;let q=J.data;if(o6(q)){this.handleJsonRpc(q);return}let Q=q;if(!Q?.type.startsWith("prefab:"))return;if(Q.type==="prefab:tool-call-response"&&Q.id){let U=this.pending.get(Q.id);if(U){if(this.pending.delete(Q.id),Q.payload?.error!=null)U.reject(Error(Q.payload.error));else U.resolve(Q.payload?.result);return}}let Y=this.listeners.get(Q.type);if(Y)for(let U of Y)U(Q.payload??{})};window.addEventListener("message",Z),this.cleanup=()=>window.removeEventListener("message",Z)}async initialize($){try{return await Promise.any([this.initPrefab($),this.initJsonRpc($)])}catch(Z){let J=Z instanceof AggregateError?Z.errors.map((q)=>q.message).join("; "):String(Z);throw Error(`Bridge init failed — no host responded. Tried: ${J}`,{cause:Z})}}createTransport(){if(this.protocol==="jsonrpc")return this.createJsonRpcTransport();return this.createPrefabTransport()}requestMode($){if(this.protocol==="jsonrpc")this.sendRpcRequest("ui/request-display-mode",{mode:$});else this.sendPrefab("prefab:request-mode",{mode:$})}openLink($,Z){if(this.protocol==="jsonrpc")this.sendRpcRequest("ui/open-link",{url:$,target:Z});else this.sendPrefab("prefab:open-link",{url:$,target:Z})}updateContext($){if(this.protocol==="jsonrpc")this.sendRpcRequest("ui/update-model-context",{structuredContent:$});else this.sendPrefab("prefab:update-context",{context:$})}setupAutoResize($){if(typeof ResizeObserver>"u")return t6;let Z=-1,J=-1,q=(U,H)=>{if(U===Z&&H===J)return;if(Z=U,J=H,this.protocol==="jsonrpc")this.sendRpcNotification("ui/notifications/size-changed",{width:U,height:H});else this.sendPrefab("prefab:size-changed",{width:U,height:H})},Q=new ResizeObserver((U)=>{for(let H of U)if(H.borderBoxSize.length){let W=H.borderBoxSize[0];q(Math.ceil(W.inlineSize),Math.ceil(W.blockSize))}else{let W=H.target.getBoundingClientRect();q(Math.ceil(W.width),Math.ceil(W.height))}});Q.observe($);let Y=$.getBoundingClientRect();return q(Math.ceil(Y.width),Math.ceil(Y.height)),()=>Q.disconnect()}notifyPreferredSize($){if(this.protocol==="jsonrpc")this.sendRpcNotification("ui/notifications/preferred-size",$);else this.sendPrefab("prefab:preferred-size",$)}subscribe($,Z){let J=(q)=>{if(q.uri!==$)return;Z(q.contents??q.data??q)};if(this.protocol==="jsonrpc")this.on("prefab:resource-updated",J),this.sendRpcRequest("resources/subscribe",{uri:$});else this.on("prefab:resource-updated",J),this.sendPrefab("prefab:subscribe",{uri:$});return()=>{if(this.off("prefab:resource-updated",J),this.protocol==="jsonrpc")this.sendRpcRequest("resources/unsubscribe",{uri:$});else this.sendPrefab("prefab:unsubscribe",{uri:$})}}get supportsSubscriptions(){return this._hostSupportsSubscriptions}on($,Z){if(!this.listeners.has($))this.listeners.set($,new Set);let J=this.listeners.get($);if(J)J.add(Z)}off($,Z){this.listeners.get($)?.delete(Z)}disconnect(){this.cleanup?.(),this.listeners.clear();for(let[,$]of this.pending)$.reject(Error("Bridge disconnected"));this.pending.clear();for(let[,$]of this.rpcPending)$.reject(Error("Bridge disconnected"));this.rpcPending.clear(),this.sentRpcIds.clear()}get activeProtocol(){return this.protocol}initPrefab($){return new Promise((Z,J)=>{let q=!1,Q=(Y)=>{if(q)return;q=!0,this.off("prefab:init-response",Q),this.protocol="prefab";let U=Y.capabilities;this._hostSupportsSubscriptions=U?.subscriptions===!0,Z(Y)};this.on("prefab:init-response",Q),this.sendPrefab("prefab:init",{capabilities:$}),setTimeout(()=>{if(!q)q=!0,this.off("prefab:init-response",Q),J(Error("prefab:init timeout"))},2000)})}createPrefabTransport(){return{callTool:($,Z)=>{let J=`tc-${++this.callIdCounter}`;return new Promise((q,Q)=>{this.pending.set(J,{resolve:q,reject:Q}),this.sendPrefab("prefab:tool-call",{tool:$,arguments:Z},J),setTimeout(()=>{if(this.pending.has(J))this.pending.delete(J),Q(Error(`Tool call '${$}' timed out`))},30000)})},sendMessage:($)=>{return this.sendPrefab("prefab:send-message",{message:$}),Promise.resolve()},subscribe:($,Z)=>{return this.subscribe($,Z)},capabilities:{subscriptions:this._hostSupportsSubscriptions}}}sendPrefab($,Z,J){if(typeof window>"u")return;let q=window.parent!==window?window.parent:window,Q={type:$,payload:Z,id:J};q.postMessage(Q,this.hostOrigin)}handleJsonRpc($){if(!("method"in $)){let q=this.rpcPending.get($.id);if(q)if(this.rpcPending.delete($.id),$.error)q.reject(Error($.error.message));else q.resolve($.result);return}let Z=$.method,J=$.params??{};if($.id!=null&&this.sentRpcIds.delete($.id))return;if($.id!=null)this.postJsonRpc({jsonrpc:"2.0",id:$.id,result:{}});switch(Z){case"ui/notifications/tool-input":this.dispatch("prefab:tool-input",{args:J.arguments??J});break;case"ui/notifications/tool-input-partial":this.dispatch("prefab:tool-input-partial",{args:J.arguments??J});break;case"ui/notifications/tool-result":this.dispatch("prefab:tool-result",{result:J});break;case"ui/notifications/tool-cancelled":this.dispatch("prefab:tool-cancelled",J);break;case"ui/notifications/host-context-changed":{let q={};if(typeof J.theme==="string")q.colorScheme=J.theme;if(typeof J.styles==="object"&&J.styles!==null){let Q=J.styles;if(Q.variables)q.variables=Q.variables;if(typeof Q.css?.fonts==="string")q.fontCss=Q.css.fonts}this.dispatch("prefab:theme-update",q),this.dispatch("prefab:host-context-changed",J);break}case"ui/resource-teardown":this.dispatch("prefab:teardown",J);break;case"ui/notifications/resource-updated":case"notifications/resources/updated":this.dispatch("prefab:resource-updated",J);break}}initJsonRpc($){return new Promise((Z,J)=>{let q=++this.rpcIdCounter,Q=!1;this.rpcPending.set(q,{resolve:(Y)=>{if(Q)return;Q=!0,this.protocol="jsonrpc";let U=Y??{},H=U.hostInfo??{},W=U.hostContext??{},_=U.hostCapabilities??{},z;if(typeof W.theme==="string"||typeof W.styles==="object"){if(z={},typeof W.theme==="string")z.colorScheme=W.theme;if(typeof W.styles==="object"&&W.styles!==null){let B=W.styles;if(B.variables)z.variables=B.variables;if(typeof B.css?.fonts==="string")z.fontCss=B.css.fonts}}this.postJsonRpc({jsonrpc:"2.0",method:"ui/notifications/initialized",params:{}});let X=_.resources;this._hostSupportsSubscriptions=_.subscriptions===!0||X?.subscribe===!0,Z({hostName:H.name,hostVersion:H.version,capabilities:{toast:!0,navigation:_.openLinks!=null,messaging:!0,displayModes:W.availableDisplayModes??[]},theme:z,toolInput:void 0,meta:W})},reject:(Y)=>{if(Q)return;Q=!0,J(Y)}}),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(!Q)Q=!0,this.rpcPending.delete(q),J(Error("ui/initialize timeout"))},2000)})}createJsonRpcTransport(){return{callTool:($,Z)=>{return this.sendRpcRequest("tools/call",{name:$,arguments:Z})},sendMessage:($)=>{return this.sendRpcRequest("ui/message",{role:"user",content:{type:"text",text:$}})},subscribe:($,Z)=>{return this.subscribe($,Z)},capabilities:{subscriptions:this._hostSupportsSubscriptions}}}sendRpcRequest($,Z){let J=++this.rpcIdCounter;return new Promise((q,Q)=>{this.rpcPending.set(J,{resolve:q,reject:Q}),this.postJsonRpc({jsonrpc:"2.0",id:J,method:$,params:Z}),setTimeout(()=>{if(this.rpcPending.has(J))this.rpcPending.delete(J),Q(Error(`JSON-RPC '${$}' timed out`))},30000)})}sendRpcNotification($,Z){this.postJsonRpc({jsonrpc:"2.0",method:$,params:Z})}postJsonRpc($){if(typeof window>"u")return;if($.id!=null&&typeof $.method==="string")this.sentRpcIds.add($.id);if(this.postFn)this.postFn($);else(window.parent!==window?window.parent:window).postMessage($,this.hostOrigin)}dispatch($,Z){let J=this.listeners.get($);if(J)for(let q of J)q(Z)}}var t6=()=>{};function F1($,Z){if(Z.variables)for(let[J,q]of Object.entries(Z.variables))$.style.setProperty(J.startsWith("--")?J:`--${J}`,q);if(Z.colorScheme&&Z.colorScheme!=="auto")$.setAttribute("data-theme",Z.colorScheme);if(Z.fontCss)e6(Z.fontCss)}function e6($){if(document.getElementById("__prefab-host-fonts"))return;let J=document.createElement("style");J.id="__prefab-host-fonts",J.textContent=$,document.head.appendChild(J)}function x0(){if(typeof window>"u")return!1;try{return window.self!==window.top}catch{return!0}}function $5(){if(typeof window>"u")return;let $=window;if(typeof $.acquireVsCodeApi==="function")try{let Z=$.acquireVsCodeApi();if(Z!==null&&typeof Z==="object"&&"postMessage"in Z)return Z}catch{return}return}var D4=new Set(["Column","Row","Grid","GridItem","Container","Div","Span","Dashboard","DashboardItem","Pages","Page","Heading","H1","H2","H3","H4","Text","P","Lead","Large","Small","Muted","BlockQuote","Label","Link","Code","Markdown","Kbd","Card","CardHeader","CardTitle","CardDescription","CardContent","CardFooter","DataTable","Badge","Dot","Metric","Ring","Progress","Separator","Loader","Icon","Table","TableHead","TableBody","TableFooter","TableRow","TableHeader","TableCell","TableCaption","ExpandableRow","Form","Input","Textarea","Button","ButtonGroup","Select","SelectOption","SelectGroup","SelectLabel","SelectSeparator","Checkbox","Switch","Slider","Radio","RadioGroup","Combobox","ComboboxOption","ComboboxGroup","ComboboxLabel","ComboboxSeparator","Calendar","DatePicker","Field","FieldTitle","FieldDescription","FieldContent","FieldError","ChoiceCard","Tabs","Tab","Accordion","AccordionItem","Dialog","Popover","Tooltip","HoverCard","Carousel","ForEach","If","Elif","Else","Define","Use","Slot","Alert","AlertTitle","AlertDescription","Image","Audio","Video","Embed","Svg","DropZone","Mermaid","BarChart","LineChart","AreaChart","PieChart","RadarChart","ScatterChart","Sparkline","RadialChart","Histogram"]);function V1($,Z={}){let J=[],q=Z.strict??!1;if($==null||typeof $!=="object")return J.push({path:"$",message:"Wire data must be a non-null object"}),{valid:!1,errors:J};let Q=$;if(Q.$prefab==null||typeof Q.$prefab!=="object")J.push({path:"$.$prefab",message:"Missing or invalid $prefab header"});else if(typeof Q.$prefab.version!=="string")J.push({path:"$.$prefab.version",message:"version must be a string"});if(Q.view==null)J.push({path:"$.view",message:'Missing required "view" field'});else L1(Q.view,"$.view",J,q);if(Q.state!==void 0){if(Q.state===null||typeof Q.state!=="object"||Array.isArray(Q.state))J.push({path:"$.state",message:"state must be a plain object"})}if(Q.theme!==void 0)J5(Q.theme,J);if(Q.css!==void 0)V4(Q.css,"$.css",J);if(Q.stylesheets!==void 0)V4(Q.stylesheets,"$.stylesheets",J);if(Q.mode!==void 0&&Q.mode!=="light"&&Q.mode!=="dark")J.push({path:"$.mode",message:'mode must be "light" or "dark"'});if(Q.defs!==void 0)if(Q.defs===null||typeof Q.defs!=="object"||Array.isArray(Q.defs))J.push({path:"$.defs",message:"defs must be a plain object"});else for(let[Y,U]of Object.entries(Q.defs))L1(U,`$.defs.${Y}`,J,q);if(Q.keyBindings!==void 0)if(Q.keyBindings===null||typeof Q.keyBindings!=="object"||Array.isArray(Q.keyBindings))J.push({path:"$.keyBindings",message:"keyBindings must be a plain object"});else for(let[Y,U]of Object.entries(Q.keyBindings))D1(U,`$.keyBindings.${Y}`,J);return{valid:J.length===0,errors:J}}function L1($,Z,J,q){if($==null||typeof $!=="object"||Array.isArray($)){J.push({path:Z,message:"Component must be a plain object"});return}let Q=$;if(typeof Q.type!=="string"||Q.type.length===0){J.push({path:`${Z}.type`,message:'Component must have a non-empty "type" string'});return}if(q&&!D4.has(Q.type))J.push({path:`${Z}.type`,message:`Unknown component type: "${Q.type}"`});if(Q.children!==void 0)if(!Array.isArray(Q.children))J.push({path:`${Z}.children`,message:"children must be an array"});else for(let U=0;U<Q.children.length;U++)L1(Q.children[U],`${Z}.children[${U}]`,J,q);let Y=["onClick","on_click","onChange","on_change","onSubmit","on_submit","onMount","on_mount","onClose","on_close"];for(let U of Y)if(Q[U]!==void 0)D1(Q[U],`${Z}.${U}`,J);for(let[U,H]of Object.entries(Q)){if(U==="type"||Z5.has(U)||Y.includes(U))continue;if(L4(H)||Array.isArray(H)&&H.some(L4))J.push({path:`${Z}.${U}`,message:`Components under "${U}" are ignored by the renderer; move them into "children"`})}}var Z5=new Set(["children","fallback","trigger","empty","else","summary"]);function L4($){if($==null||typeof $!=="object"||Array.isArray($))return!1;let Z=$.type;return typeof Z==="string"&&D4.has(Z)}function D1($,Z,J){if(Array.isArray($)){for(let H=0;H<$.length;H++)D1($[H],`${Z}[${H}]`,J);return}if($==null||typeof $!=="object"){J.push({path:Z,message:"Action must be an object or array of objects"});return}let q=$,Q=typeof q.type==="string"&&q.type.length>0,Y=typeof q.action==="string"&&q.action.length>0;if(!Q&&!Y){J.push({path:`${Z}.type`,message:'Action must have a non-empty "type" or "action" string'});return}if((Y?q.action:q.type).toLowerCase()==="showtoast"){if(typeof q.message!=="string"||q.message.length===0)J.push({path:`${Z}.message`,message:'showToast requires a non-empty "message" string'})}}function V4($,Z,J){if(!Array.isArray($)){J.push({path:Z,message:`${Z} must be an array of strings`});return}for(let q=0;q<$.length;q++)if(typeof $[q]!=="string")J.push({path:`${Z}[${q}]`,message:"must be a string"})}function J5($,Z){if($===null||typeof $!=="object"||Array.isArray($)){Z.push({path:"$.theme",message:"theme must be a plain object"});return}let J=$;for(let q of["light","dark"])if(J[q]!==void 0){if(J[q]===null||typeof J[q]!=="object"||Array.isArray(J[q]))Z.push({path:`$.theme.${q}`,message:`theme.${q} must be a plain object`})}}var a={mount($,Z,J){if(v0(),J?.validate!==!1)for(let E of V1(Z).errors)C.warn(`wire validation ${E.path}: ${E.message}`);let q=Z,Q=[];if(q.pipes)for(let[E,D]of Object.entries(q.pipes))O4(E,D,Q);let Y=new E0(q.state),U;if(J?.transport&&"callTool"in J.transport)U=J.transport;else if(J?.transport)U=g0(J.transport);else U=u0();let H=J?.onToast??Q5,W=new $1;function _(E){let D=E;if(q=D,D.state)Y.merge(D.state);if(D.defs)z.defs=D.defs;if(D.theme)z1($,D.theme);if(D.mode)T4($,D.mode);if(D.pipes)for(let[I,A]of Object.entries(D.pipes))O4(I,A,Q);for(let I of X)I.remove();if(X.length=0,X.push(...I4(D.css,D.stylesheets)),P4($,D.layout),B?.(),B=void 0,D.keyBindings)B=E1(D.keyBindings,(I)=>{h(m(I,{store:Y,transport:U,scope:{},rerender:()=>M(),remount:_,onToast:H}),"keyBinding")});M()}let z={store:Y,scope:{},transport:U,rerender:()=>M(),remount:_,onToast:H,defs:q.defs,destroyRegistry:W};if(z1($,q.theme),q.mode)T4($,q.mode);P4($,q.layout);let X=I4(q.css,q.stylesheets),B;if(q.keyBindings)B=E1(q.keyBindings,(E)=>{h(m(E,{store:Y,transport:U,scope:{},rerender:()=>M(),remount:_,onToast:H}),"keyBinding")});let K,L=J?.themeToggle??!0;if(L!==!1)K=K1($,typeof L==="object"?L:void 0);function M(){W.flush();let E=$.querySelector(".pf-theme-toggle");$.innerHTML="";let D=g(q.view,z);if($.appendChild(D),E)$.appendChild(E)}return M(),{rerender:()=>M(),update(E){if(Y.merge(E.update.state),M(),E.update.actions!=null)h(m(E.update.actions,z),"update action")},store:Y,destroy(){W.flush(),K?.(),B?.(),y1(),m1();for(let E of X)E.remove();for(let E of Q)d0(E);$.innerHTML=""}}},isPrefabData($){return $!=null&&typeof $==="object"&&"$prefab"in $},isPrefabUpdate($){return $!=null&&typeof $==="object"&&"$prefab"in $&&"update"in $}},q5=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 O4($,Z,J){if(q5.has($)){C.warn(`wire pipe "${$}" ignored — shadows built-in`);return}try{let q=Function("return ("+Z+")")();if(typeof q!=="function"){C.warn(`wire pipe "${$}" — source did not evaluate to a function`);return}l0($,q),J.push($)}catch(q){C.warn(`wire pipe "${$}" — failed to hydrate:`,q)}}function Q5($){if(typeof document>"u")return;let Z=U5(),J=document.createElement("div"),q=$.variant??"default";J.className=`pf-toast${q!=="default"?` pf-toast--${q}`:""}`,J.setAttribute("data-variant",q),J.style.marginBottom="8px",J.style.transition="opacity 0.3s ease";let Q=document.createElement("div");if(Q.textContent=$.message,Q.style.fontWeight="500",J.appendChild(Q),$.description){let U=document.createElement("div");U.textContent=$.description,U.style.fontSize="14px",U.style.color="var(--muted-foreground, #6b7280)",J.appendChild(U)}Z.appendChild(J);let Y=$.duration??4000;setTimeout(()=>{J.style.opacity="0",setTimeout(()=>J.remove(),300)},Y)}function T4($,Z){if(z0($,Z),typeof document<"u")z0(document.documentElement,Z)}function Y5($){let Z=$.trim();if(Z.includes("{")||Z.includes("}"))return!1;return/^(https?:)?\/\//i.test(Z)||Z.startsWith("/")||/\.css(\?|#|$)/i.test(Z)}function I4($,Z){let J=[];if(typeof document>"u")return J;for(let q of $??[]){let Q=document.createElement("style");Q.textContent=q,Q.dataset.prefab="injected",document.head.appendChild(Q),J.push(Q)}for(let q of Z??[])if(Y5(q)){let Q=document.createElement("link");Q.rel="stylesheet",Q.href=q,Q.dataset.prefab="injected",document.head.appendChild(Q),J.push(Q)}else{let Q=document.createElement("style");Q.textContent=q,Q.dataset.prefab="injected",document.head.appendChild(Q),J.push(Q)}return J}function P4($,Z){if($.style.height="",$.style.minHeight="",$.style.maxHeight="",$.style.overflow="",!Z)return;if(Z.preferredHeight!=null)$.style.height=`${Z.preferredHeight}px`;if(Z.minHeight!=null)$.style.minHeight=`${Z.minHeight}px`;if(Z.maxHeight!=null)$.style.maxHeight=`${Z.maxHeight}px`,$.style.overflow="auto"}function U5(){let Z=document.getElementById("prefab-toast-container");if(!Z)Z=document.createElement("div"),Z.id="prefab-toast-container",Z.style.position="fixed",Z.style.bottom="16px",Z.style.right="16px",Z.style.zIndex="9999",Z.style.maxWidth="400px",document.body.appendChild(Z);return Z}if(typeof window<"u"){let $=window;$.PrefabRenderer=a,$.prefab={app:p0,mount:a.mount.bind(a),isPrefabData:a.isPrefabData.bind(a),isPrefabUpdate:a.isPrefabUpdate.bind(a),Bridge:F0,isIframe:x0,registerPipe:l0,unregisterPipe:d0,listPipes:A1,registerComponent:G,createThemeToggle:K1,validateWireFormat:V1,setLogLevel:j1};let Z=$.__PREFAB_DATA__;if(Z!=null){let J=document.getElementById("prefab-root");if(J)a.mount(J,Z)}}async function p0($){v0();let Z=$?.mode??"auto",J=Z==="bridge"||Z==="auto"&&x0(),q,Q,Y={capabilities:{}};if(J)Q=new F0($?.hostOrigin),Q.connect(),Y=await Q.initialize($?.capabilities??{toolInput:!0}),q=Q.createTransport();else if($?.transport)q=g0($.transport);else q=u0();if(Y.theme&&typeof document<"u")F1(document.documentElement,Y.theme);if(typeof document<"u"&&!Q)W5();let U,H,W,_,z,X=Y.toolInput,B;if(Q)Q.on("prefab:tool-input",(M)=>{let E=M.args??M;if(U)U(E);else X=E}),Q.on("prefab:tool-result",(M)=>{let E=M.result??M;if(H)H(E);else B=E}),Q.on("prefab:tool-cancelled",()=>{W?.()}),Q.on("prefab:tool-input-partial",(M)=>{_?.(M.args??M)}),Q.on("prefab:theme-update",(M)=>{if(typeof document<"u")F1(document.documentElement,M)}),Q.on("prefab:host-context-changed",(M)=>{z?.(M)});function K(M,...E){let D=O1(M),I=new E0,A={store:I,scope:{},transport:q,rerender:()=>T(),onToast:void 0};function T(){D.innerHTML="";for(let j of E)D.appendChild(g(j,A))}return T(),{rerender:T,store:I,destroy:()=>{D.innerHTML=""}}}return{callTool:(M,E={})=>q.callTool(M,E),sendMessage:(M)=>q.sendMessage(M),onToolInput:(M)=>{if(U=M,X){let E=X;X=void 0,queueMicrotask(()=>M(E))}},onToolResult:(M)=>{if(H=M,B!==void 0){let E=B;B=void 0,queueMicrotask(()=>M(E))}},onToolCancelled:(M)=>{W=M},onToolInputPartial:(M)=>{_=M},onHostContextChanged:(M)=>{z=M},render:K,mount:(M,E,D)=>{let I=O1(M);return a.mount(I,E,{transport:q,...D})},requestMode:(M)=>Q?.requestMode(M),openLink:(M,E)=>{if(Q)Q.openLink(M,E);else if(typeof window<"u")window.open(M,E??"_blank")},updateContext:(M)=>{if(Q)Q.updateContext(M)},setupAutoResize:(M)=>{if(!Q)return H5;let E=typeof M==="string"?O1(M):M;return Q.setupAutoResize(E)},notifyPreferredSize:(M)=>{if(Q)Q.notifyPreferredSize(M)},host:Y,capabilities:Y.capabilities,theme:Y.theme,transport:q,destroy:()=>Q?.disconnect()}}var H5=()=>{};function O1($){if(typeof $==="string"){if(typeof document>"u")throw Error("Cannot resolve selector outside browser");let Z=document.querySelector($);if(!Z)throw Error(`Element not found: ${$}`);return Z}return $}function W5(){function $(){let J=document.body.getAttribute("data-vscode-theme-kind");if(!J)return;let q=J.includes("light")?"light":"dark";document.documentElement.setAttribute("data-theme",q)}$(),new MutationObserver($).observe(document.body,{attributes:!0,attributeFilter:["data-vscode-theme-kind"]})}var I1=c0("auto"),R4="#root";function T1($){return a.isPrefabData($)}function j4($){return a.isPrefabUpdate($)}function k4($){if(T1($))return $;if($!==null&&typeof $==="object"){let Z=$;if(T1(Z.structuredContent))return Z.structuredContent;if(Array.isArray(Z.content))for(let J of Z.content){let q=J;if(q.type==="text"&&typeof q.text==="string")try{let Q=JSON.parse(q.text);if(T1(Q))return Q}catch{}}}return null}async function A4(){let $=document.querySelector(R4);if(!$){I1.error(`Mount target "${R4}" not found`);return}let Z=$,J=await p0();J.setupAutoResize(Z);let q;function Q(Y){if(q)q.destroy();if(q=J.mount(Z,Y),Y.layout)J.notifyPreferredSize(Y.layout)}J.onToolResult((Y)=>{let U=k4(Y);if(U)Q(U);else if(j4(Y)&&q)q.update(Y)}),J.onToolInput((Y)=>{let U=k4(Y);if(U)Q(U);else if(j4(Y)&&q)q.update(Y)})}function X5(){if(document.readyState==="loading")document.addEventListener("DOMContentLoaded",()=>{A4().catch(($)=>{I1.error("Boot failed:",$)})},{once:!0});else queueMicrotask(()=>{A4().catch(($)=>{I1.error("Boot failed:",$)})})}X5();})();