@maxhealth.tech/prefab 0.3.2 → 0.3.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (49) hide show
  1. package/CHANGELOG.md +39 -0
  2. package/README.md +3 -1
  3. package/dist/app.d.ts +1 -1
  4. package/dist/app.js +1 -1
  5. package/dist/core/logger.d.ts +33 -0
  6. package/dist/core/logger.d.ts.map +1 -0
  7. package/dist/core/logger.js +48 -0
  8. package/dist/core/logger.js.map +1 -0
  9. package/dist/core/validate.js +33 -0
  10. package/dist/core/validate.js.map +1 -1
  11. package/dist/index.d.ts +2 -0
  12. package/dist/index.d.ts.map +1 -1
  13. package/dist/index.js +1 -0
  14. package/dist/index.js.map +1 -1
  15. package/dist/renderer/actions.d.ts +6 -0
  16. package/dist/renderer/actions.d.ts.map +1 -1
  17. package/dist/renderer/actions.js +43 -20
  18. package/dist/renderer/actions.js.map +1 -1
  19. package/dist/renderer/auto.js +5 -3
  20. package/dist/renderer/auto.js.map +1 -1
  21. package/dist/renderer/components/data.js +6 -3
  22. package/dist/renderer/components/data.js.map +1 -1
  23. package/dist/renderer/components/form.js +12 -12
  24. package/dist/renderer/components/form.js.map +1 -1
  25. package/dist/renderer/engine.d.ts.map +1 -1
  26. package/dist/renderer/engine.js +7 -6
  27. package/dist/renderer/engine.js.map +1 -1
  28. package/dist/renderer/index.d.ts +5 -0
  29. package/dist/renderer/index.d.ts.map +1 -1
  30. package/dist/renderer/index.js +26 -11
  31. package/dist/renderer/index.js.map +1 -1
  32. package/dist/renderer/state.d.ts.map +1 -1
  33. package/dist/renderer/state.js +2 -1
  34. package/dist/renderer/state.js.map +1 -1
  35. package/dist/renderer/theme.d.ts +1 -1
  36. package/dist/renderer/theme.d.ts.map +1 -1
  37. package/dist/renderer/theme.js.map +1 -1
  38. package/dist/renderer/transport.d.ts.map +1 -1
  39. package/dist/renderer/transport.js +3 -2
  40. package/dist/renderer/transport.js.map +1 -1
  41. package/dist/renderer.auto.min.js +10 -10
  42. package/dist/renderer.min.js +10 -10
  43. package/dist/rx/pipes.d.ts.map +1 -1
  44. package/dist/rx/pipes.js +2 -1
  45. package/dist/rx/pipes.js.map +1 -1
  46. package/dist/rx/state-collector.d.ts.map +1 -1
  47. package/dist/rx/state-collector.js +2 -1
  48. package/dist/rx/state-collector.js.map +1 -1
  49. package/package.json +1 -1
@@ -1,16 +1,16 @@
1
- (()=>{class _0{data={};subscribers=new Map;globalSubscribers=new Set;generation=0;constructor($){if($)this.data=structuredClone($)}get($){return z4(this.data,$)}getAll(){return this.data}set($,Z){z1(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($))z1(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 z4($,Z){let J=Z.split("."),q=$;for(let Q of J){if(q==null||typeof q!=="object")return;q=q[Q]}return q}var K4=new Set(["__proto__","constructor","prototype"]);function z1($,Z,J){let q=Z.split(".");if(q.some((Y)=>K4.has(Y))){console.warn(`[prefab] 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 G0=new Map;function u0($,Z){if(G0.has($)&&G0.get($)!==Z)console.warn(`[prefab] pipe "${$}" re-registered`);G0.set($,Z)}function x0($){return G0.delete($)}function K1(){return[...G0.keys()]}function L1($){return G0.get($)}var V1=-1,p0=new Map,L4=/\{\{\s*(.+?)\s*\}\}/g;function r($){return typeof $==="string"&&$.includes("{{")&&$.includes("}}")}function o($,Z,J){let q=$.trim();if(q.startsWith("{{")&&q.endsWith("}}")&&P4(q,"{{")===1){let Q=q.slice(2,-2).trim();return j1(Q,Z,J)}return $.replace(L4,(Q,Y)=>{let U=j1(Y.trim(),Z,J);return U==null?"":String(U)})}function j1($,Z,J){let[q,...Q]=I4($),Y=s(q.trim(),Z,J);for(let U of Q)Y=V4(U.trim(),Y,Z,J);return Y}function s($,Z,J){let q=O4($);if(q>=0){let U=$.slice(0,q).trim(),W=$.slice(q+1),H=T4(W);if(H>=0){let _=W.slice(0,H).trim(),E=W.slice(H+1).trim(),X=s(U,Z,J);return X!==null&&X!==void 0&&X!==!1&&X!==0&&X!==""?s(_,Z,J):s(E,Z,J)}}let Q=z0($,"||");if(Q>=0){let U=s($.slice(0,Q).trim(),Z,J);return U!==null&&U!==void 0&&U!==!1&&U!==0&&U!==""?U:s($.slice(Q+2).trim(),Z,J)}let Y=z0($,"&&");if(Y>=0){let U=s($.slice(0,Y).trim(),Z,J);if(U===null||U===void 0||U===!1||U===0||U==="")return U;return s($.slice(Y+2).trim(),Z,J)}for(let[U,W]of j4){let H=z0($,U);if(H>=0){let _=s($.slice(0,H).trim(),Z,J),E=s($.slice(H+U.length).trim(),Z,J);return W(_,E)}}if($.startsWith("!")){let U=s($.slice(1).trim(),Z,J);return U===null||U===void 0||U===!1||U===0||U===""}for(let[U,W]of D4){let H=z0($,U);if(H>=0){let _=s($.slice(0,H).trim(),Z,J),E=s($.slice(H+U.length).trim(),Z,J);return W(Number(_),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 W=$.slice(0,U),H=$.slice(U+1),_=J[W];return K0(_,H)}return J[$]}if(J){let U=$.split(".")[0];if(U in J)return K0(J[U],$.includes(".")?$.slice(U.length+1):"")}return Z.get($)}function V4($,Z,J,q){let Q=$.indexOf(":"),Y=Q>=0?$.slice(0,Q).trim():$,U=Q>=0?$.slice(Q+1).trim():void 0,W=U?c0(U):void 0;switch(Y){case"find":{if(!Array.isArray(Z)||!U)return;let H=D1(U);if(H.length<2)return;let _=c0(H[0]),E=H[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=K0(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?K0(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 N=J?.generation??0;if(N!==V1)p0=new Map,V1=N;let z=p0.get(Z);if(!z)z=new Map,p0.set(Z,z);let L=z.get(_);if(!L){L=new Map;for(let M of Z)if(M!=null&&typeof M==="object"){let F=M[_];if(F!=null)L.set(String(F),M)}z.set(_,L)}return L.get(String(X))}case"dot":{if(Z==null||typeof Z!=="object"||typeof W!=="string")return;return Z[W]}case"length":return Array.isArray(Z)?Z.length:typeof Z==="string"?Z.length:0;case"upper":return typeof Z==="string"?Z.toUpperCase():Z;case"lower":return typeof Z==="string"?Z.toLowerCase():Z;case"truncate":if(typeof Z==="string"&&typeof W==="number")return Z.slice(0,W);return Z;case"join":return Array.isArray(Z)?Z.join(typeof W==="string"?W:", "):Z;case"first":return Array.isArray(Z)?Z[0]:Z;case"last":return Array.isArray(Z)?Z[Z.length-1]:Z;case"abs":return Math.abs(Number(Z));case"round":return typeof W==="number"?Number(Number(Z).toFixed(W)):Math.round(Number(Z));case"number":return typeof W==="number"?Number(Number(Z).toFixed(W)):Number(Z);case"currency":{let H=typeof W==="string"?W:"USD";try{return new Intl.NumberFormat("en-US",{style:"currency",currency:H}).format(Number(Z))}catch{return Z}}case"percent":return typeof W==="number"?`${(Number(Z)*100).toFixed(W)}%`:`${Math.round(Number(Z)*100)}%`;case"compact":{let H=typeof W==="number"?W:1;try{return new Intl.NumberFormat("en-US",{notation:"compact",maximumFractionDigits:H}).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 H=Number(Z),_=typeof W==="string"?W:"";return H===1?_:`${_}s`}case"default":return Z==null||Z===""?W:Z;case"selectattr":return Array.isArray(Z)&&typeof W==="string"?Z.filter((H)=>H!=null&&typeof H==="object"&&Boolean(H[W])):Z;case"rejectattr":return Array.isArray(Z)&&typeof W==="string"?Z.filter((H)=>{if(H==null||typeof H!=="object")return!1;let _=H[W];return _==null||_===!1||_===0||_===""}):Z;default:{let H=L1(Y);if(H){let _=U?D1(U).map(c0):[];return H(Z,..._)}return Z}}}var j4=[["!==",($,Z)=>$!==Z],["===",($,Z)=>$===Z],["!=",($,Z)=>$!=Z],["==",($,Z)=>$==Z],[">=",($,Z)=>Number($)>=Number(Z)],["<=",($,Z)=>Number($)<=Number(Z)],[">",($,Z)=>Number($)>Number(Z)],["<",($,Z)=>Number($)<Number(Z)]],D4=[[" + ",($,Z)=>$+Z],[" - ",($,Z)=>$-Z],[" * ",($,Z)=>$*Z],[" / ",($,Z)=>Z!==0?$/Z:0],[" % ",($,Z)=>Z!==0?$%Z:0]];function z0($,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 O4($){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 T4($){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 I4($){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 c0($){let Z=$.replace(/^['"]|['"]$/g,"");if(Z==="true")return!0;if(Z==="false")return!1;let J=Number(Z);return isNaN(J)?Z:J}function D1($){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 K0($,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 P4($,Z){let J=0,q=0;while((q=$.indexOf(Z,q))!==-1)J++,q+=Z.length;return J}function L0($){return $.replace(/_([a-z])/g,(Z,J)=>J.toUpperCase())}function d0($){let Z={};for(let[J,q]of Object.entries($)){let Q=J.startsWith("$")?J:L0(J);if(Array.isArray(q))Z[Q]=q.map((Y)=>Y!=null&&typeof Y==="object"&&!Array.isArray(Y)?d0(Y):Y);else if(q!=null&&typeof q==="object"&&!Array.isArray(q))Z[Q]=d0(q);else Z[Q]=q}return Z}async function y($,Z){let J=Array.isArray($)?$:[$];for(let q of J)await R4(q,Z)}async function R4($,Z){let J=d0($),q=J.action;switch(q){case"setState":{A4(J,Z);return}case"toggleState":{k4(J,Z);return}case"appendState":{f4(J,Z);return}case"popState":{S4(J,Z);return}case"showToast":{w4(J,Z);return}case"closeOverlay":{C4(J,Z);return}case"openLink":{b4(J);return}case"setInterval":{m4(J,Z);return}case"toolCall":case"callTool":return h4(J,Z);case"sendMessage":return v4(J,Z);case"updateContext":{g4(J,Z);return}case"fetch":return u4(J,Z);case"openFilePicker":{x4(J,Z);return}case"callHandler":return p4(J,Z);case"requestDisplayMode":{c4(J,Z);return}case"subscribe":{i4(J,Z);return}case"unsubscribe":{s4(J);return}default:console.warn(`[prefab] Unknown action: ${q}`)}}function A4($,Z){let{key:J,value:q}=$;if(r(q))q=o(q,Z.store,Z.scope);Z.store.set(J,q),Z.rerender(),e($.onSuccess,Z)}function k4($,Z){Z.store.toggle($.key),Z.rerender()}function f4($,Z){let J=$.value??$.item;if(r(J))J=o(J,Z.store,Z.scope);Z.store.append($.key,J,$.index),Z.rerender()}function S4($,Z){Z.store.pop($.key,$.index),Z.rerender()}function w4($,Z){Z.onToast?.({message:j0($.message,Z),description:$.description!=null?j0($.description,Z):void 0,variant:$.variant,duration:$.duration})}function C4($,Z){if(typeof document<"u")document.dispatchEvent(new CustomEvent("prefab:close-overlay"))}function b4($){if(typeof window<"u"){let Z=$.url;if(!Z){console.warn("[prefab] openLink: missing url");return}if(!P1(Z)){console.warn(`[prefab] Blocked unsafe URL scheme: ${Z}`);return}window.open(Z,$.target??"_blank")}}var V0=new Set,y4=20,O1=100;function m4($,Z){let J=Math.max($.intervalMs,O1),q=$.onTick;if(typeof globalThis.setInterval!=="function")return;if(V0.size>=y4){console.warn("[prefab] Max intervals reached, ignoring new setInterval");return}let Q=globalThis.setInterval(()=>void y(q,Z),J);V0.add(Q)}function T1(){for(let $ of V0)globalThis.clearInterval($);V0.clear()}async function h4($,Z){if(!Z.transport){console.warn("[prefab] No MCP transport configured for toolCall");return}let J=$.tool,q=i0($.arguments,Z);try{let Q=await Z.transport.callTool(J,q);if($.resultKey!=null)Z.store.set($.resultKey,Q);let Y=D0(Q);if(Y&&Z.remount)Z.remount(Y);else O0(Q,Z),Z.rerender();await e($.onSuccess,Z,{$result:Q})}catch(Q){await e($.onError,Z,{$error:Q})}}async function v4($,Z){if(!Z.transport){console.warn("[prefab] No MCP transport configured for sendMessage");return}await Z.transport.sendMessage(j0($.message,Z))}function g4($,Z){let J=$.context;if(J!=null)Z.store.merge(J),Z.rerender()}async function u4($,Z){let J=j0($.url,Z);if(!P1(J)){console.warn(`[prefab] 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}}),W=await U.json().catch(()=>U.text());if($.resultKey!=null)Z.store.set($.resultKey,W);let H=D0(W);if(H&&Z.remount)Z.remount(H);else O0(W,Z),Z.rerender();await e($.onSuccess,Z,{$result:W})}catch(U){await e($.onError,Z,{$error:U})}}function x4($,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(),e($.onSuccess,Z,{$result:q})}),J.click()}async function p4($,Z){let J=$.handler,q=i0($.arguments,Z);if(!Z.transport){console.warn(`[prefab] 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=D0(Q);if(Y&&Z.remount)Z.remount(Y);else O0(Q,Z),Z.rerender();await e($.onSuccess,Z,{$result:Q})}catch(Q){await e($.onError,Z,{$error:Q})}}function c4($,Z){if(typeof document<"u")document.dispatchEvent(new CustomEvent("prefab:request-display-mode",{detail:{mode:$.mode}}))}var J0=new Map,l4=50,d4=2000;function i4($,Z){let{uri:J,stateKey:q}=$;if(!J||!q){console.warn("[prefab] subscribe: missing uri or stateKey");return}if(J0.has(J))return;if(J0.size>=l4){console.warn("[prefab] Max subscriptions reached, ignoring new subscribe");return}let Q=(X)=>{let N=D0(X);if(N&&Z.remount)Z.remount(N);else{if(!O0(X,Z))Z.store.set(q,X);Z.rerender()}e($.onData,Z,{$data:X})};if(Z.transport?.subscribe&&Z.transport.capabilities?.subscriptions){let X=Z.transport.subscribe(J,Q);J0.set(J,X);return}let Y=$.fallbackTool,U=$.fallbackInterval??d4;if(!Y){console.warn("[prefab] subscribe: host lacks subscriptions and no fallbackTool specified");return}if(!Z.transport){console.warn("[prefab] No MCP transport configured for subscribe fallback");return}let W=$.fallbackArgs??{},H=Math.max(U,O1),_=Z.transport,E=globalThis.setInterval(()=>{(async()=>{try{let X=i0(W,Z),N=await _.callTool(Y,X);Q(N)}catch(X){e($.onError,Z,{$error:X})}})()},H);J0.set(J,()=>globalThis.clearInterval(E))}function s4($){let Z=$.uri;if(!Z){console.warn("[prefab] unsubscribe: missing uri");return}let J=J0.get(Z);if(J)J(),J0.delete(Z)}function I1(){for(let[$,Z]of J0)try{Z()}catch(J){console.warn(`[prefab] Error cleaning up subscription '${$}':`,J)}J0.clear()}function D0($){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 n4($){if($==null||typeof $!=="object")return null;let Z=$;if(l0(Z))return Z;if("structuredContent"in Z){let J=Z.structuredContent;if(J!=null&&typeof J==="object"&&l0(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"&&l0(q))return q}catch{}}return null}function l0($){if(!("$prefab"in $)||!("update"in $))return!1;let Z=$.update;return Z!=null&&typeof Z==="object"&&"state"in Z}function O0($,Z){let J=n4($);if(!J)return!1;let q=J.update;if(Z.store.merge(q.state),q.actions!=null)y(q.actions,Z);return!0}var r4=/^\s*(javascript|vbscript|data):/i;function P1($){return!r4.test($)}function j0($,Z){if(r($)){let J=o($,Z.store,Z.scope);return J==null?"":String(J)}return $==null?"":String($)}function i0($,Z){if(!$)return{};let J={};for(let[q,Q]of Object.entries($))J[q]=r(Q)?o(Q,Z.store,Z.scope):Q;return J}async function e($,Z,J){if($==null)return;let q={...Z.scope,...J};await y($,{...Z,scope:q})}function n0($){let Z={};for(let[J,q]of Object.entries($)){let Q=J.startsWith("$")?J:L0(J);if(Array.isArray(q))Z[Q]=q.map((Y)=>Y!=null&&typeof Y==="object"&&!Array.isArray(Y)?n0(Y):Y);else if(q!=null&&typeof q==="object"&&!Array.isArray(q))Z[Q]=n0(q);else Z[Q]=q}return Z}class o0{callbacks=[];track($){this.callbacks.push($)}flush(){for(let $ of this.callbacks)try{$()}catch(Z){console.warn("[prefab] destroy callback error:",Z)}this.callbacks=[]}get size(){return this.callbacks.length}}function o4($){return typeof $==="object"&&"element"in $}var r0=new Map;function G($,Z){if(r0.has($))console.warn(`[prefab] overriding existing renderer for "${$}"`);r0.set($,Z)}function u($,Z){let J=n0($);if(Z.defs?.[J.type]){let Y={...Z.defs[J.type],...J,type:Z.defs[J.type].type};return u(Y,Z)}let q=r0.get(J.type),Q;if(q){let Y=q(J,Z);if(o4(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(u(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",()=>{y(J.onClick,p(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(),y(J.onClick,p(Z))})}}if(J.onMount){let Y=J.onMount,U=p(Z);queueMicrotask(()=>void y(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=a4($,q,Z,J);else if(Q.type==="Elif"||Q.type==="Else")q++;else Z.appendChild(u(Q,J)),q++}}function a4($,Z,J,q){let Q=!1,Y=Z,U=$[Y];if(R1(U.condition,q))s0(U,J,q),Q=!0;Y++;while(Y<$.length){let W=$[Y];if(W.type==="Elif"){if(!Q&&R1(W.condition,q))s0(W,J,q),Q=!0;Y++}else if(W.type==="Else"){if(!Q)s0(W,J,q);Y++;break}else break}return Y}function R1($,Z){if(!$)return!1;if(r($))return Boolean(o($,Z.store,Z.scope));return Boolean(Z.store.get($))}function s0($,Z,J){if(!$.children)return;q0($.children,Z,J)}function K($,Z){if(r($)){let J=o($,Z.store,Z.scope);return J==null?"":String(J)}return $==null?"":String($)}function x($,Z){if(r($))return o($,Z.store,Z.scope);return $}function p($){return{store:$.store,transport:$.transport,scope:$.scope,rerender:$.rerender,onToast:$.onToast,remount:$.remount}}function B($,Z){let J=document.createElement($);if(Z)J.className=Z;return J}function a0($,Z){return $.textContent=Z,$}function S1(){G("Column",t4),G("Row",e4),G("Grid",A1),G("GridItem",k1),G("Container",$8),G("Div",f1),G("Span",Z8),G("Dashboard",A1),G("DashboardItem",k1),G("Pages",J8),G("Page",f1),G("Detail",q8),G("MasterDetail",Q8)}function t4($,Z){let J=B("div","pf-column");J.style.display="flex",J.style.flexDirection="column";let q=T0($);if(q!=null)J.style.gap=`${q*4}px`;if($.align!=null)J.style.alignItems=w1($.align);if($.justify!=null)J.style.justifyContent=C1($.justify);return w($,J,Z),J}function e4($,Z){let J=B("div","pf-row");J.style.display="flex",J.style.flexDirection="row";let q=T0($);if(q!=null)J.style.gap=`${q*4}px`;if($.align!=null)J.style.alignItems=w1($.align);if($.justify!=null)J.style.justifyContent=C1($.justify);if($.wrap===!0)J.style.flexWrap="wrap";return w($,J,Z),J}function A1($,Z){let J=B("div","pf-grid");J.style.display="grid";let q=$.columns??3;J.style.gridTemplateColumns=`repeat(${q}, 1fr)`;let Q=T0($);if(Q!=null)J.style.gap=`${Q*4}px`;return w($,J,Z),J}function k1($,Z){let J=B("div","pf-grid-item");if($.colSpan!=null)J.style.gridColumn=`span ${$.colSpan}`;if($.rowSpan!=null)J.style.gridRow=`span ${$.rowSpan}`;return w($,J,Z),J}function $8($,Z){let J=B("div","pf-container");if(J.style.maxWidth=$.maxWidth??"1200px",J.style.margin="0 auto",$.padding!=null)J.style.padding=`${$.padding*4}px`;return w($,J,Z),J}function f1($,Z){let J=B("div","pf-div");return w($,J,Z),J}function Z8($,Z){let J=B("span","pf-span");return w($,J,Z),J}function J8($,Z){let J=B("div","pf-pages");return w($,J,Z),J}function q8($,Z){let J=B("div","pf-detail"),q=$.of!=null?x($.of,Z):void 0;if(q!=null&&q!==""&&q!==!1&&q!==0)w($,J,Z);else if($.empty!=null){let Q=$.empty;J.appendChild(u(Q,Z))}return J}function Q8($,Z){let J=B("div","pf-master-detail");J.style.display="flex",J.style.flexDirection="row";let q=T0($);if(q!=null)J.style.gap=`${q*4}px`;let Q=$.masterWidth??"33%",Y=$.children??[];if(Y.length>0){let U=B("div","pf-master-detail-master");U.style.width=Q,U.style.flexShrink="0",U.style.overflow="auto",U.appendChild(u(Y[0],Z)),J.appendChild(U)}if(Y.length>1){let U=B("div","pf-master-detail-detail");U.style.flex="1",U.style.overflow="auto",U.appendChild(u(Y[1],Z)),J.appendChild(U)}return J}var Y8=/\bgap-(\d+)\b/;function T0($){if($.gap!=null)return $.gap;if(typeof $.cssClass==="string"){let Z=Y8.exec($.cssClass);if(Z)return Number(Z[1])}return null}function w1($){return{start:"flex-start",end:"flex-end",center:"center",stretch:"stretch",baseline:"baseline"}[$]??$}function C1($){return{start:"flex-start",end:"flex-end",center:"center",between:"space-between",around:"space-around",evenly:"space-evenly"}[$]??$}function y1(){G("Heading",U8),G("H1",($,Z)=>I0($,Z,"h1")),G("H2",($,Z)=>I0($,Z,"h2")),G("H3",($,Z)=>I0($,Z,"h3")),G("H4",($,Z)=>I0($,Z,"h4")),G("Text",W8),G("P",H8),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",G8),G("Code",M8),G("Markdown",B8),G("Kbd",N8)}function U8($,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 I0($,Z,J){let q=document.createElement(J);return q.className=`pf-heading pf-${J}`,q.textContent=K($.content,Z),q}function W8($,Z){return a0(B("span","pf-text"),K($.content,Z))}function H8($,Z){return a0(B("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 X8=/^\s*(javascript|vbscript|data):/i;function G8($,Z){let J=document.createElement("a");if(J.className="pf-link",J.textContent=K($.content,Z),$.href!=null){let q=K($.href,Z);if(!X8.test(q))J.href=q}if($.target!=null)J.target=K($.target,Z);return J}function M8($,Z){let J=B("pre","pf-code"),q=B("code");if(q.textContent=K($.content,Z),$.language!=null)q.setAttribute("data-language",$.language);return J.appendChild(q),J}function B8($,Z){let J=B("div","pf-markdown"),q=K($.content,Z);return J.innerHTML=m1(q),J.setAttribute("data-markdown","true"),J}var b1=/^\s*(javascript|vbscript|data):/i;function R0($){return $.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;")}function P0($){let Z=R0($),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(b1.test(Y))return R0(Q);return`<img src="${Y}" alt="${Q}" />`}),Z=Z.replace(/\[([^\]]+)\]\(([^)]+)\)/g,(q,Q,Y)=>{if(b1.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 m1($){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 p0($){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=p0();class z0{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 N=H.slice(0,W).trim(),E=H.slice(W+1).trim(),X=r(U,Z,J);return X!==null&&X!==void 0&&X!==!1&&X!==0&&X!==""?r(N,Z,J):r(E,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 N=r($.slice(0,W).trim(),Z,J),E=r($.slice(W+U.length).trim(),Z,J);return H(N,E)}}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 N=r($.slice(0,W).trim(),Z,J),E=r($.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 V0(N,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 N=s0(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 z=E.slice(0,M);if(z in q)X=V0(q[z],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?V0(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!==S1)i0=new Map,S1=B;let K=i0.get(Z);if(!K)K=new Map,i0.set(Z,K);let L=K.get(N);if(!L){L=new Map;for(let M of Z)if(M!=null&&typeof M==="object"){let z=M[N];if(z!=null)L.set(String(z),M)}K.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=f1(Y);if(W){let N=U?C1(U).map(s0):[];return W(Z,...N)}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":{c4(J,Z);return}case"toggleState":{p4(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 c4($,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 p4($,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),N=Z.transport,E=globalThis.setInterval(()=>{(async()=>{try{let X=a0(H,Z),B=await N.callTool(Y,X);Q(B)}catch(X){I0("subscribe",X,$.onError,Z)}})()},W);q0.set(J,()=>globalThis.clearInterval(E))}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 c($,Z){let J=t0($);if(Z.defs?.[J.type]){let Y={...Z.defs[J.type],...J,type:Z.defs[J.type].type};return c(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(c(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(c(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 p($,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 _($,Z){let J=document.createElement($);if(Z)J.className=Z;return J}function Z1($,Z){return $.textContent=Z,$}function c1(){G("Column",M8),G("Row",_8),G("Grid",g1),G("GridItem",u1),G("Container",N8),G("Div",x1),G("Span",E8),G("Dashboard",g1),G("DashboardItem",u1),G("Pages",z8),G("Page",x1),G("Detail",K8),G("MasterDetail",F8)}function M8($,Z){let J=_("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=p1($.align);if($.justify!=null)J.style.justifyContent=l1($.justify);return w($,J,Z),J}function _8($,Z){let J=_("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=p1($.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=_("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=_("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=_("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=_("div","pf-div");return w($,J,Z),J}function E8($,Z){let J=_("span","pf-span");return w($,J,Z),J}function z8($,Z){let J=_("div","pf-pages");return w($,J,Z),J}function K8($,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(c(Q,Z))}return J}function F8($,Z){let J=_("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=_("div","pf-master-detail-master");U.style.width=Q,U.style.flexShrink="0",U.style.overflow="auto",U.appendChild(c(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(c(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 p1($){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(_("span","pf-text"),F($.content,Z))}function O8($,Z){return Z1(_("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=_("pre","pf-code"),q=_("code");if(q.textContent=F($.content,Z),$.language!=null)q.setAttribute("data-language",$.language);return J.appendChild(q),J}function R8($,Z){let J=_("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 W=Q.trimStart().slice(3).trim(),H=[];q++;while(q<Z.length&&!Z[q].trimStart().startsWith("```"))H.push(R0(Z[q])),q++;q++;let _=W?` data-language="${R0(W)}"`:"";J.push(`<pre class="pf-code"><code${_}>${H.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 W=Y[1].length;J.push(`<h${W}>${P0(Y[2])}</h${W}>`),q++;continue}if(Q.startsWith("> ")||Q===">"){let W=[];while(q<Z.length&&(Z[q].startsWith("> ")||Z[q]===">"))W.push(Z[q].replace(/^>\s?/,"")),q++;J.push(`<blockquote>${m1(W.join(`
5
- `))}</blockquote>`);continue}if(/^[\s]*[-*+]\s+/.test(Q)){J.push("<ul>");while(q<Z.length&&/^[\s]*[-*+]\s+/.test(Z[q]))J.push(`<li>${P0(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>${P0(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(P0).join("<br />")}</p>`)}return J.join(`
6
- `)}function N8($,Z){let J=document.createElement("kbd");return J.className="pf-kbd",J.textContent=K($.content,Z),J}function v1(){G("Card",_8),G("CardHeader",t0("pf-card-header")),G("CardTitle",h1("pf-card-title","h3")),G("CardDescription",h1("pf-card-description","p")),G("CardContent",t0("pf-card-content")),G("CardFooter",t0("pf-card-footer"))}function _8($,Z){let J=B("div","pf-card");return J.style.overflow="hidden",w($,J,Z),J}function t0($){return(Z,J)=>{let q=B("div",$);return q.style.padding="16px 24px",w(Z,q,J),q}}function h1($,Z){return(J,q)=>{let Q=document.createElement(Z);return Q.className=$,Q.textContent=K(J.content,q),Q}}function g1(){G("DataTable",E8),G("Badge",F8),G("Dot",z8),G("Metric",K8),G("Ring",L8),G("Progress",V8),G("Separator",j8),G("Loader",D8),G("Icon",O8),G("Sparkline",T8)}function E8($,Z){let J=B("div","pf-datatable-wrapper"),q=document.createElement("table");q.className="pf-datatable",q.style.width="100%",q.style.borderCollapse="collapse";let Q=$.columns??[],Y=x($.rows,Z),U=$.rowKey,W=$.selected,H=document.createElement("thead"),_=document.createElement("tr");for(let X of Q){let N=document.createElement("th");N.className="pf-datatable-th",N.textContent=X.header??X.key,N.style.padding="8px 12px",N.style.textAlign="left",_.appendChild(N)}H.appendChild(_),q.appendChild(H);let E=document.createElement("tbody");if(Array.isArray(Y)){let X=W!=null?x(W,Z):void 0;for(let N of Y){let z=document.createElement("tr");z.className="pf-datatable-row";let L=N;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 M={...Z.scope,$item:L,$index:Y.indexOf(N)},F=p({...Z,scope:M});y($.onRowClick,F)});for(let M of Q){let F=document.createElement("td");F.className="pf-datatable-td";let j;if(M.accessor)j=x(`{{ $item.${M.accessor} }}`,{...Z,scope:{...Z.scope,$item:L}});else if(j=L[M.key],M.format&&j!=null)j=x(`{{ __fmtVal | ${M.format} }}`,{...Z,scope:{...Z.scope,__fmtVal:j}});F.textContent=j==null?"":String(j),F.style.padding="8px 12px",z.appendChild(F)}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 N=X.value.toLowerCase(),z=Array.from(E.querySelectorAll("tr"));for(let L of z){let M=(L.textContent??"").toLowerCase();L.style.display=M.includes(N)?"":"none"}}),J.appendChild(X)}return J.appendChild(q),J}function F8($,Z){let J=B("span","pf-badge"),q=$.variant??"default";return J.setAttribute("data-variant",q),J.style.alignItems="center",J.style.padding="2px 10px",J.style.borderRadius="9999px",J.style.fontSize="12px",J.style.fontWeight="500",J.textContent=K($.label??$.content,Z),I8(J,q),J}function z8($,Z){let J=B("span","pf-dot"),q=$.color??"gray";return J.style.display="inline-block",J.style.width="8px",J.style.height="8px",J.style.borderRadius="50%",J.style.backgroundColor=q,J}function K8($,Z){let J=B("div","pf-metric"),q=B("div","pf-metric-label");q.textContent=K($.label,Z),q.style.fontSize="14px",J.appendChild(q);let Q=B("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=B("span","pf-metric-delta");Y.textContent=K($.delta,Z);let U=$.trend??"",W=$.trendSentiment??"neutral";if(Y.style.fontSize="14px",Y.style.color=W==="positive"?"green":W==="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=B("div","pf-metric-desc");Y.textContent=K($.description,Z),Y.style.fontSize="12px",J.appendChild(Y)}return J}function L8($,Z){let J=B("div","pf-ring"),q=$.size??80,Q=$.thickness??8,Y=Number(x($.value,Z)??0),U=Math.max(0,Math.min(100,Y)),W=(q-Q)/2,H=2*Math.PI*W,_=H*(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(W)),X.setAttribute("fill","none"),X.setAttribute("stroke","var(--muted, #e5e7eb)"),X.setAttribute("stroke-width",String(Q));let N=document.createElementNS("http://www.w3.org/2000/svg","circle");if(N.setAttribute("cx",String(q/2)),N.setAttribute("cy",String(q/2)),N.setAttribute("r",String(W)),N.setAttribute("fill","none"),N.setAttribute("stroke","var(--primary, #3b82f6)"),N.setAttribute("stroke-width",String(Q)),N.setAttribute("stroke-dasharray",String(H)),N.setAttribute("stroke-dashoffset",String(_)),N.setAttribute("stroke-linecap","round"),N.style.transform="rotate(-90deg)",N.style.transformOrigin="center",E.appendChild(X),E.appendChild(N),J.appendChild(E),$.label!=null){let z=B("div","pf-ring-label");z.textContent=K($.label,Z),z.style.textAlign="center",z.style.fontSize="12px",J.appendChild(z)}return J}function V8($,Z){let J=B("div","pf-progress");J.setAttribute("role","progressbar");let q=Number(x($.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=B("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 j8($,Z){let J=document.createElement("hr");return J.className="pf-separator",J.style.border="none",J.style.margin="8px 0",J}function D8($,Z){let J=B("div","pf-loader");return J.textContent="⏳",J.style.display="flex",J.style.justifyContent="center",J.style.padding="16px",J}function O8($,Z){let J=B("span","pf-icon");return J.setAttribute("data-icon",K($.name??$.content,Z)),J}function T8($,Z){let J=B("div","pf-sparkline"),q=$.data??[];if(q.length===0)return J;let Q=120,Y=32,U=Math.max(...q),W=Math.min(...q),H=U-W||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 E=q.length>1?q.length-1:1,X=q.map((z,L)=>{let M=L/E*Q,F=Y-(z-W)/H*(Y-4)-2;return`${M},${F}`}).join(" "),N=document.createElementNS("http://www.w3.org/2000/svg","polyline");return N.setAttribute("points",X),N.setAttribute("fill","none"),N.setAttribute("stroke","var(--primary, #3b82f6)"),N.setAttribute("stroke-width","1.5"),_.appendChild(N),J.appendChild(_),J}function I8($,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 x1(){G("Form",P8),G("Input",R8),G("Textarea",A8),G("Button",k8),G("ButtonGroup",f8),G("Select",S8),G("SelectOption",w8),G("SelectGroup",A0("pf-select-group")),G("SelectLabel",E0("pf-select-label")),G("SelectSeparator",u1),G("Checkbox",C8),G("Switch",b8),G("Slider",y8),G("Radio",h8),G("RadioGroup",v8),G("Combobox",g8),G("ComboboxOption",u8),G("ComboboxGroup",A0("pf-combobox-group")),G("ComboboxLabel",E0("pf-combobox-label")),G("ComboboxSeparator",u1),G("Calendar",x8),G("DatePicker",p8),G("Field",A0("pf-field")),G("FieldTitle",E0("pf-field-title")),G("FieldDescription",E0("pf-field-description")),G("FieldContent",A0("pf-field-content")),G("FieldError",E0("pf-field-error")),G("ChoiceCard",c8)}function P8($,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,W)=>{Y[W]=U}),Z.store.merge(Y),$.onSubmit!=null){let U=p(Z);U.scope={...Z.scope,...Y},y($.onSubmit,U)}}),w($,J,Z),J}function R8($,Z){let J=B("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)y($.onChange,{...p(Z),scope:{...Z.scope,$event:q.value}})})}return e0(q),J.appendChild(q),J}function A8($,Z){let J=B("div","pf-textarea-wrapper"),q=document.createElement("textarea");if(q.className="pf-textarea",$.name!=null)q.name=$.name;if($.name!=null)q.id=`pf-textarea-${$.name}`;if($.placeholder!=null)q.placeholder=K($.placeholder,Z);if($.rows!=null)q.rows=$.rows;if($.required===!0)q.setAttribute("aria-required","true");let 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)y($.onChange,{...p(Z),scope:{...Z.scope,$event:q.value}})})}return e0(q),J.appendChild(q),J}function k8($,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),m8(J,q),$.size!=null)J.setAttribute("data-size",$.size);if($.disabled===!0)J.disabled=!0;return J}function f8($,Z){let J=B("div","pf-button-group");return J.style.display="flex",J.style.gap="8px",w($,J,Z),J}function S8($,Z){let J=B("div","pf-select-wrapper"),q=document.createElement("select");if(q.className="pf-select",$.name!=null)q.name=$.name;if(e0(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 W=document.createElement("option");W.value=U.value??"",W.textContent=U.label??W.value,q.appendChild(W)}if($.children)for(let U of $.children)if(U.type==="SelectOption"){let W=document.createElement("option");W.value=U.value??"",W.textContent=U.label??W.value,q.appendChild(W)}else q.appendChild(u(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)y($.onChange,{...p(Z),scope:{...Z.scope,$event:q.value}})})}return J.appendChild(q),J}function w8($,Z){return B("span")}function C8($,Z){let J=B("label","pf-checkbox-wrapper");J.style.display="flex",J.style.alignItems="center",J.style.gap="8px",J.style.cursor="pointer";let q=document.createElement("input");if(q.type="checkbox",q.className="pf-checkbox",$.name!=null)q.name=$.name;if($.checked===!0)q.checked=!0;let 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)y($.onChange,{...p(Z),scope:{...Z.scope,$event:q.checked}})})}if(J.appendChild(q),$.label!=null){let Y=B("span");Y.textContent=K($.label,Z),J.appendChild(Y)}return J}function b8($,Z){let J=B("label","pf-switch-wrapper");J.style.display="flex",J.style.alignItems="center",J.style.gap="8px",J.style.cursor="pointer";let q=document.createElement("input");if(q.type="checkbox",q.className="pf-switch",q.setAttribute("role","switch"),$.name!=null)q.name=$.name;let 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)y($.onChange,{...p(Z),scope:{...Z.scope,$event:q.checked}})})}if(J.appendChild(q),$.label!=null){let Y=B("span");Y.textContent=K($.label,Z),J.appendChild(Y)}return J}function y8($,Z){let J=B("div","pf-slider-wrapper"),q=document.createElement("input");if(q.type="range",q.className="pf-slider",$.name!=null)q.name=$.name;if($.min!=null)q.min=String($.min);if($.max!=null)q.max=String($.max);if($.step!=null)q.step=String($.step);let 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)y($.onChange,{...p(Z),scope:{...Z.scope,$event:Number(q.value)}})})}return J.appendChild(q),J}function e0($){$.style.padding="8px 12px",$.style.fontSize="14px",$.style.width="100%",$.style.boxSizing="border-box"}function m8($,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 A0($){return(Z,J)=>{let q=B("div",$);return w(Z,q,J),q}}function E0($){return(Z,J)=>{let q=B("span",$);return q.textContent=K(Z.content,J),q}}function u1(){let $=document.createElement("hr");return $.className="pf-separator",$.style.border="none",$.style.margin="4px 0",$}function h8($,Z){let J=B("label","pf-radio");J.style.display="flex",J.style.alignItems="center",J.style.gap="8px",J.style.cursor="pointer";let q=document.createElement("input");if(q.type="radio",q.value=K($.value,Z),J.appendChild(q),$.label!=null){let Q=B("span","pf-radio-label");Q.textContent=K($.label,Z),J.appendChild(Q)}return J}function v8($,Z){let J=B("fieldset","pf-radio-group");if(J.style.border="none",J.style.padding="0",J.style.display="flex",J.style.flexDirection="column",J.style.gap="8px",$.label!=null){let 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)y($.onChange,p(Z))}}),J}function g8($,Z){let J=B("div","pf-combobox"),q=document.createElement("input");if(q.className="pf-combobox-input",q.type="text",q.name=K($.name,Z),$.placeholder!=null)q.placeholder=K($.placeholder,Z);if($.value!==void 0)q.value=K($.value,Z);let 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=B("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 W=q.value.toLowerCase();for(let H of Array.from(U.querySelectorAll(".pf-combobox-option"))){let _=(H.textContent??"").toLowerCase();H.style.display=_.includes(W)?"":"none"}});if($.onChange!=null)J.addEventListener("pf-combobox-select",()=>{y($.onChange,{...p(Z),scope:{...Z.scope,$event:q.value}})});return J.style.position="relative",J.appendChild(q),J.appendChild(U),J}function u8($,Z){let J=B("div","pf-combobox-option");return J.style.padding="6px 12px",J.style.cursor="pointer",J.textContent=K($.label??$.value,Z),J.dataset.value=K($.value,Z),J.addEventListener("mousedown",()=>{let q=J.closest(".pf-combobox"),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 x8($,Z){let J=B("div","pf-calendar"),q=document.createElement("input");if(q.type="date",q.name=K($.name,Z),$.value!==void 0)q.value=K($.value,Z);let 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)y($.onChange,p(Z))}),J.appendChild(q),J}function p8($,Z){let J=B("div","pf-datepicker"),q=document.createElement("input");if(q.type="date",q.name=K($.name,Z),$.placeholder!=null)q.placeholder=K($.placeholder,Z);if($.value!==void 0)q.value=K($.value,Z);let 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)y($.onChange,p(Z))}),J.appendChild(q),J}function c8($,Z){let J=B("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=B("div","pf-choice-card-label");q.textContent=K($.label,Z),q.style.fontWeight="600",J.appendChild(q)}if($.description!=null){let q=B("div","pf-choice-card-description");q.textContent=K($.description,Z),q.style.fontSize="14px",J.appendChild(q)}return w($,J,Z),J}function p1(){G("Tabs",l8),G("Tab",d8),G("Accordion",i8),G("AccordionItem",s8),G("Dialog",n8),G("Popover",r8),G("Tooltip",o8),G("HoverCard",a8),G("Carousel",t8)}function l8($,Z){let J=B("div","pf-tabs"),q=B("div","pf-tabs-bar");q.setAttribute("role","tablist"),q.style.display="flex",q.style.gap="4px",q.style.marginBottom="12px";let Q=[],Y=[];if($.children)for(let W=0;W<$.children.length;W++){let H=$.children[W],_=`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=H.title??`Tab ${W+1}`,X.setAttribute("role","tab"),X.setAttribute("aria-selected",W===0?"true":"false"),X.setAttribute("aria-controls",E),X.id=_,X.tabIndex=W===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 N=B("div","pf-tab-panel");if(N.style.display=W===0?"block":"none",N.setAttribute("role","tabpanel"),N.setAttribute("aria-labelledby",_),N.id=E,N.tabIndex=0,w(H,N,Z),X.addEventListener("click",()=>{U(W)}),W===0)X.classList.add("pf-tab-active"),X.style.fontWeight="600";Y.push(X),Q.push(N),q.appendChild(X)}function U(W){Q.forEach((H)=>H.style.display="none"),Y.forEach((H)=>{H.style.borderBottomColor="transparent",H.style.fontWeight="normal",H.classList.remove("pf-tab-active"),H.setAttribute("aria-selected","false"),H.tabIndex=-1}),Q[W].style.display="block",Y[W].classList.add("pf-tab-active"),Y[W].style.fontWeight="600",Y[W].setAttribute("aria-selected","true"),Y[W].tabIndex=0,Y[W].focus()}q.addEventListener("keydown",(W)=>{let H=Y.indexOf(W.target);if(H<0)return;let _;if(W.key==="ArrowRight")_=(H+1)%Y.length;else if(W.key==="ArrowLeft")_=(H-1+Y.length)%Y.length;else if(W.key==="Home")_=0;else if(W.key==="End")_=Y.length-1;else return;W.preventDefault(),U(_)}),J.appendChild(q);for(let W of Q)J.appendChild(W);return J}function d8($,Z){let J=B("div","pf-tab");return w($,J,Z),J}function i8($,Z){let J=B("div","pf-accordion");return w($,J,Z),J}function s8($,Z){let J=B("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=B("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 n8($,Z){let J=B("div","pf-dialog-wrapper");if($.trigger!=null){let Y=u($.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=B("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=B("p","pf-dialog-desc");Y.textContent=K($.description,Z),q.appendChild(Y)}let Q=B("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 r8($,Z){let J=B("div","pf-popover");J.style.position="relative",J.style.display="inline-block";let q=B("div","pf-popover-content");if(q.style.display="none",q.style.position="absolute",q.style.zIndex="50",q.style.padding="12px",q.style.boxShadow="0 4px 6px -1px rgb(0 0 0 / 0.1)",$.title!=null){let Q=B("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 o8($,Z){let J=B("div","pf-tooltip");J.style.position="relative",J.style.display="inline-block";let q=`pf-tip-${Math.random().toString(36).slice(2,8)}`,Q=B("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 a8($,Z){let J=B("div","pf-hover-card");J.style.position="relative",J.style.display="inline-block";let q=B("div","pf-hover-card-content");return q.style.display="none",q.style.position="absolute",q.style.zIndex="50",q.style.padding="16px",q.style.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 t8($,Z){let J=B("div","pf-carousel");J.style.position="relative",J.style.overflow="hidden",J.setAttribute("role","region"),J.setAttribute("aria-roledescription","carousel"),J.setAttribute("aria-label",K($.label??"Carousel",Z));let q=B("div","pf-carousel-track");q.style.display="flex",q.style.transition="transform 0.3s ease",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 W=document.createElement("button");W.type="button",W.textContent="›",W.className="pf-carousel-next",W.setAttribute("aria-label","Next slide"),W.style.position="absolute",W.style.right="4px",W.style.top="50%",W.style.transform="translateY(-50%)",W.style.zIndex="10";let H=()=>{q.style.transform=`translateX(-${Q*100}%)`};return U.addEventListener("click",()=>{if(Y===0)return;Q=Math.max(0,Q-1),H()}),W.addEventListener("click",()=>{if(Y===0)return;Q=Math.min(Y-1,Q+1),H()}),J.appendChild(q),J.appendChild(U),J.appendChild(W),J}function c1(){G("ForEach",e8),G("If",l1),G("Elif",$6),G("Else",Z6),G("Condition",J6),G("Define",q6),G("Use",Q6),G("Slot",Y6)}function e8($,Z){let J=document.createDocumentFragment(),q=$.expression;if(!q)return J;let Q;if(r(q)){let U=o(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 W=Q[U],H={...Z.scope,$item:W,$index:U,...Y},_={...Z,scope:H};if($.children)q0($.children,J,_)}return J}function l1($,Z){if(d1($.condition,Z)){let q=document.createDocumentFragment();if($.children)q0($.children,q,Z);return q}return document.createDocumentFragment()}function $6($,Z){return l1($,Z)}function Z6($,Z){let J=document.createDocumentFragment();if($.children)q0($.children,J,Z);return J}function d1($,Z){if(!$)return!1;if(r($))return Boolean(o($,Z.store,Z.scope));return Boolean(Z.store.get($))}function J6($,Z){let J=document.createDocumentFragment(),q=$.cases,Q=$.else;if(q){for(let Y of q)if(d1(Y.when,Z)){if(Y.children)q0(Y.children,J,Z);return J}}if(Q)q0(Q,J,Z);return J}function q6($,Z){let J=$.name;if(J&&$.children)Z.templates=Z.templates??{},Z.templates[J]=$.children;return document.createDocumentFragment()}function Q6($,Z){let J=document.createDocumentFragment(),q=$.def??$.name,Q=Z.templates?.[q];if(!Q)return J;let Y=$.overrides??{},U={...Z.scope,...Y},W={...Z,scope:U};for(let H of Q)J.appendChild(u(H,W));return J}function Y6($,Z){let J=document.createDocumentFragment(),q=$.name??"default",Y=Z.slots?.[q]??$.children;if(Y)for(let U of Y)J.appendChild(u(U,Z));return J}function i1(){G("Alert",U6),G("AlertTitle",W6),G("AlertDescription",H6)}function U6($,Z){let J=B("div","pf-alert");J.setAttribute("role","alert");let q=$.variant??"default";if(J.setAttribute("data-variant",q),J.style.padding="12px 16px",$.icon!=null){let Q=B("span","pf-alert-icon");Q.setAttribute("data-icon",$.icon),Q.style.marginRight="8px",J.appendChild(Q)}return w($,J,Z),J}function W6($,Z){let J=B("h5","pf-alert-title");return J.textContent=K($.content,Z),J.style.fontWeight="600",J.style.marginBottom="4px",J}function H6($,Z){let J=B("p","pf-alert-description");return J.textContent=K($.content,Z),J.style.fontSize="14px",J}function s1(){G("Image",X6),G("Audio",G6),G("Video",M6),G("Embed",B6),G("Svg",_6),G("DropZone",E6),G("Mermaid",F6)}function X6($,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 G6($,Z){let J=document.createElement("audio");return J.className="pf-audio",J.src=K($.src,Z),J.controls=!0,J}function M6($,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 B6($,Z){let J=B("div","pf-embed"),q=document.createElement("iframe");return q.src=K($.src,Z),q.style.width="100%",q.style.height=$.height!=null?`${$.height}px`:"400px",q.style.border="none",q.setAttribute("sandbox","allow-scripts"),J.appendChild(q),J}var N6=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 _6($,Z){let J=B("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 n1(Y),J.appendChild(document.importNode(Y,!0)),J}function n1($){let Z=Array.from($.children);for(let J of Z){if(!N6.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)}n1(J)}}function E6($,Z){let J=B("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 F6($,Z){let J=B("div","pf-mermaid");J.setAttribute("data-mermaid","true");let q=K($.content,Z);if(J.textContent=q,typeof globalThis.mermaid<"u")J.classList.add("mermaid"),J.textContent=q;return J}var z6="https://cdn.jsdelivr.net/npm/pdfjs-dist@4.9/build/pdf.min.mjs",K6="https://cdn.jsdelivr.net/npm/pdfjs-dist@4.9/build/pdf.worker.min.mjs",$1=null,k0=null;async function L6(){if($1)return $1;if(k0)return k0;return k0=import(z6).then(($)=>{let Z=$;return Z.GlobalWorkerOptions.workerSrc=K6,$1=Z,Z}),k0}function o1(){G("PdfViewer",V6)}function V6($,Z){let J=B("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",W=$.toolbar!==!1,H=$.height!=null?$.height:600;J.style.height=`${H}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 _=B("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(_),j6(J,_,{src:q,data:Q,initialPage:Y,zoom:U,showToolbar:W}),J}async function j6($,Z,J){try{let q=await L6(),Q;if(J.src)Q={url:J.src};else if(J.data){let N=atob(J.data),z=new Uint8Array(N.length);for(let L=0;L<N.length;L++)z[L]=N.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)),W=null,H=null;if(J.showToolbar){let N=D6(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()}});W=N.pageInput,H=N.pageCount,$.insertBefore(N.el,$.firstChild)}let _=B("div","pf-pdf-canvas-container");_.style.flex="1",_.style.overflow="auto",_.style.display="flex",_.style.justifyContent="center",_.style.padding="8px",$.appendChild(_);let E=document.createElement("canvas");E.style.display="block",E.style.boxShadow="var(--shadow-md, 0 4px 6px -1px rgba(0,0,0,.1))",_.appendChild(E);async function X(){let N=await Y.getPage(U),z=_.clientWidth-16,L,M=N.getViewport({scale:1});if(J.zoom==="fit-width")L=z/M.width;else if(J.zoom==="fit-page"){let I=_.clientHeight-16,k=z/M.width,O=I/M.height;L=Math.min(k,O)}else L=typeof J.zoom==="number"?J.zoom:1;let F=N.getViewport({scale:L});E.width=F.width,E.height=F.height,E.style.width=`${F.width}px`,E.style.height=`${F.height}px`;let j=E.getContext("2d");if(!j)return;if(await N.render({canvasContext:j,viewport:F}).promise,W)W.value=String(U);if(H)H.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 D6($,Z,J){let q=B("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",r1(Q),Q.addEventListener("click",J.onPrev);let Y=document.createElement("button");Y.textContent="›",Y.title="Next page",Y.className="pf-pdf-btn",r1(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 H=parseInt(U.value,10);if(!isNaN(H))J.onPageChange(H)});let W=document.createElement("span");return W.textContent=`/ ${$}`,W.style.color="var(--color-text-secondary, #6b7280)",q.appendChild(Q),q.appendChild(U),q.appendChild(W),q.appendChild(Y),{el:q,pageInput:U,pageCount:W}}function r1($){$.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 S0=["#3b82f6","#10b981","#f59e0b","#ef4444","#8b5cf6","#ec4899"];function U0($,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 a($,Z,J,q,Q){let{tooltip:Y,svgEl:U,wrapper:W}=$;if(Q.length===0)return;let H="";if(q)H+=`<div class="pf-chart-tooltip-label">${f0(q)}</div>`;for(let F of Q)H+='<div class="pf-chart-tooltip-row">',H+=`<span class="pf-chart-tooltip-dot" style="background:${f0(F.color)}"></span>`,H+=`<span>${f0(F.label)}:</span> <strong>${f0(String(F.value))}</strong>`,H+="</div>";Y.innerHTML=H;let _=U.getBoundingClientRect(),E=W.getBoundingClientRect(),X=U.viewBox.baseVal,N=_.width/(X.width||1),z=_.left-E.left+Z*N,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 f0($){return $.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;")}function a1($,Z,J,q,Q,Y,U,W){let H=Q.plotWidth/J.length;for(let _=0;_<J.length;_++){let E=Q.plotLeft+_*H,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(H)),X.setAttribute("height",String(Q.plotHeight)),X.setAttribute("fill","transparent"),X.style.cursor="default";let N=Y?J[_][Y]:void 0,z=N!=null?W?W(N):String(N):void 0,L=q.map((I,k)=>({label:I.label??I.dataKey,value:U(J[_][I.dataKey],I,k),color:I.color??S0[k%S0.length]})),M=E+H/2,F=()=>a($,M,Q.plotTop,z,L),j=()=>$.tooltip.classList.remove("pf-visible");X.addEventListener("mouseenter",F),X.addEventListener("mouseleave",j),X.addEventListener("touchstart",F,{passive:!0}),X.addEventListener("touchend",j,{passive:!0}),Z.appendChild(X)}}function t1($,Z,J,q,Q,Y,U,W,H,_){let E=J.length===1?Q.plotWidth:Q.plotWidth/(J.length-1);for(let X=0;X<J.length;X++){let N=J.length===1?(Q.plotLeft+Q.plotRight)/2:Q.plotLeft+X/(J.length-1)*Q.plotWidth,z=J.length===1?Q.plotLeft:N-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,j=F!=null?_?_(F):String(F):void 0,I=q.map((R,S)=>({label:R.label??R.dataKey,value:U(J[X][R.dataKey],R,S),color:R.color??S0[S%S0.length]})),k=()=>{if(a($,N,Q.plotTop,j,I),W)W.setAttribute("x1",String(N)),W.setAttribute("x2",String(N)),W.setAttribute("opacity","1");if(H)for(let R of H){for(let S of R)S.setAttribute("data-visible","false");R[X]?.setAttribute("data-visible","true")}},O=()=>{if($.tooltip.classList.remove("pf-visible"),W)W.setAttribute("opacity","0");if(H)for(let R of H)for(let S of R)S.setAttribute("data-visible","false")};M.addEventListener("mouseenter",k),M.addEventListener("mouseleave",O),M.addEventListener("touchstart",k,{passive:!0}),M.addEventListener("touchend",O,{passive:!0}),Z.appendChild(M)}}var l=["#3b82f6","#10b981","#f59e0b","#ef4444","#8b5cf6","#ec4899"],$0="var(--muted-foreground, #6b7280)",B0="var(--border, #e5e7eb)",W0="10";function w0($,Z,J,q=!1){let Q=J?44:0,Y=$-(q?44:0),U=10,W=Z-24;return{plotLeft:Q,plotRight:Y,plotTop:10,plotBottom:W,plotWidth:Y-Q,plotHeight:W-10}}function e1($,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 W=0;W<=$+Y*0.01;W+=Y)U.push(Math.round(W*1000)/1000);return U}function Z1($,Z,J,q,Q){let Y=e1(J);for(let U of Y){let W=Z.plotBottom-(J>0?U/J*Z.plotHeight:0),H=d("text",{x:Z.plotLeft-6,y:W+3,"text-anchor":"end","font-size":W0,fill:$0});if(H.textContent=Q1(U,Q),$.appendChild(H),q&&U>0)$.appendChild(d("line",{x1:Z.plotLeft,y1:W,x2:Z.plotRight,y2:W,stroke:B0,"stroke-width":1,"stroke-dasharray":"4 3"}))}}function J1($,Z,J,q){let Q=e1(J);for(let Y of Q){let U=Z.plotBottom-(J>0?Y/J*Z.plotHeight:0),W=d("text",{x:Z.plotRight+6,y:U+3,"text-anchor":"start","font-size":W0,fill:$0});W.textContent=Q1(Y,q),$.appendChild(W)}}function q1($,Z,J,q,Q,Y){for(let U=0;U<Z.length;U++){let W=Z[U][J],H=d("text",{x:q(U),y:Q+14,"text-anchor":"middle","font-size":W0,fill:$0});H.textContent=W==null?"":Y?Y(W):String(W),$.appendChild(H)}}function C0($,Z){$.appendChild(d("line",{x1:Z.plotLeft,y1:Z.plotBottom,x2:Z.plotRight,y2:Z.plotBottom,stroke:$0,"stroke-width":1}))}function t($,Z,J){if($==null)return"";let q=x(`{{ __v | ${Z} }}`,{...J,scope:{...J.scope,__v:$}});return q==null?String($):String(q)}function Q1($,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 Z0($){let Z=$.yAxisFormat??$.valueFormat;return Z&&Z!=="auto"?Z:void 0}function Y1($,Z,J){return(q,Q)=>{if(q===null||q===void 0)return"—";if(Q.tooltipFormat)return t(q,Q.tooltipFormat,$);let Y=Q.yAxisId==="right"?J:Z;return Q1(Number(q),Y)}}function Q0($,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 d($,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 b0($,Z){let J=d("text",$);return J.textContent=Z,J}function H0($,Z,J,q){let Q=q*Math.PI/180;return{x:$+J*Math.cos(Q),y:Z-J*Math.sin(Q)}}function U1($,Z,J,q,Q){let Y=Math.max(2,Math.ceil(Math.abs(Q-q)/4)),U=[];for(let W=0;W<=Y;W++){let H=H0($,Z,J,q+(Q-q)*W/Y);U.push(`${W===0?"M":"L"} ${H.x.toFixed(2)} ${H.y.toFixed(2)}`)}return U.join(" ")}function X0($,Z,J){if(J===!1||Z.length<=1)return;let q=B("div","pf-chart-legend");q.style.display="flex",q.style.gap="12px",q.style.fontSize="12px",q.style.marginBottom="8px";for(let Q=0;Q<Z.length;Q++){let Y=B("div","pf-chart-legend-item");Y.style.display="flex",Y.style.alignItems="center",Y.style.gap="4px";let U=B("span");U.style.width="8px",U.style.height="8px",U.style.borderRadius="50%",U.style.backgroundColor=Z[Q].color??l[Q%l.length];let W=B("span");W.textContent=Z[Q].label??Z[Q].dataKey,Y.appendChild(U),Y.appendChild(W),q.appendChild(Y)}$.appendChild(q)}function Z4(){G("BarChart",O6),G("LineChart",$4),G("AreaChart",$4),G("PieChart",T6),G("RadarChart",R6),G("ScatterChart",I6),G("RadialChart",P6),G("Histogram",A6)}function O6($,Z){let J=B("div","pf-chart pf-bar-chart"),q=x($.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,W=$.showGrid===!0,H=$.showYAxisRight===!0,_=$.showTooltip!==!1,E=$.xAxis,X=$.tooltipXKey,N=$.xAxisFormat,z=$.tooltipXFormat,L=Q.filter((D)=>D.yAxisId!=="right"),M=Q.filter((D)=>D.yAxisId==="right"),F=H&&M.length>0,j=L.length>0?Math.max(...q.flatMap((D)=>L.map((V)=>Number(D[V.dataKey]??0))),1):1,I=F?Math.max(...q.flatMap((D)=>M.map((V)=>Number(D[V.dataKey]??0))),1):1,k=400,O=w0(k,Y,U,F),R=Q0(k,Y,"Bar");if(U)Z1(R,O,j,W,Z0($));if(F)J1(R,O,I,$.yAxisRightFormat);C0(R,O);let S=O.plotWidth/q.length,f=S/(Q.length+1);for(let D=0;D<q.length;D++)for(let V=0;V<Q.length;V++){let A=Q[V],C=q[D][A.dataKey];if(C===null||C===void 0)continue;let c=A.yAxisId==="right"?I:j,m=Number(C),T=Math.max(0,m/c*O.plotHeight),v=O.plotLeft+D*S+V*f+f/2,P=document.createElementNS("http://www.w3.org/2000/svg","rect");P.setAttribute("x",String(v)),P.setAttribute("y",String(O.plotBottom-T)),P.setAttribute("width",String(f*0.8)),P.setAttribute("height",String(T)),P.setAttribute("fill",A.color??l[V%l.length]),P.setAttribute("rx","2"),R.appendChild(P)}if(E){let D=N?(V)=>t(V,N,Z):void 0;q1(R,q,E,(V)=>{return O.plotLeft+V*S+S/2},O.plotBottom,D)}if(_){let D=U0(J,R),V=Y1(Z,Z0($),$.yAxisRightFormat);a1(D,R,q,Q,O,X??E,V,z?(C)=>t(C,z,Z):void 0)}return X0(J,Q,$.showLegend),J.appendChild(R),J}function $4($,Z){let J=B("div",`pf-chart pf-${$.type.toLowerCase()}-chart`),q=x($.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,W=$.showGrid===!0,H=$.showYAxisRight===!0,_=$.showTooltip!==!1,E=$.xAxis,X=$.tooltipXKey,N=$.xAxisFormat,z=$.tooltipXFormat,L=Q.filter((V)=>V.yAxisId!=="right"),M=Q.filter((V)=>V.yAxisId==="right"),F=H&&M.length>0,j=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,O=w0(k,Y,U,F),R=Q0(k,Y,$.type==="AreaChart"?"Area":"Line"),S=$.type==="AreaChart";if(U)Z1(R,O,j,W,Z0($));if(F)J1(R,O,I,$.yAxisRightFormat);C0(R,O);let f=[];for(let V=0;V<Q.length;V++){let A=Q[V],C=A.yAxisId==="right",h=C?I:j,c=A.color??l[V%l.length],m=q.map((P,b)=>{let g=P[A.dataKey],i=g===null||g===void 0,Y0=q.length===1?(O.plotLeft+O.plotRight)/2:O.plotLeft+b/(q.length-1)*O.plotWidth,F4=i?O.plotBottom:O.plotBottom-Number(g)/h*O.plotHeight;return{x:Y0,y:F4,isNull:i}});if(S){let P=[],b=()=>{if(P.length<2){P=[];return}let g=`M ${P[0].x},${O.plotBottom} `+P.map((Y0)=>`L ${Y0.x},${Y0.y}`).join(" ")+` L ${P[P.length-1].x},${O.plotBottom} Z`,i=document.createElementNS("http://www.w3.org/2000/svg","path");i.setAttribute("d",g),i.setAttribute("fill",c),i.setAttribute("opacity","0.15"),R.appendChild(i),P=[]};for(let g of m){if(g.isNull){b();continue}P.push(g)}b()}let T="";for(let P of m){if(P.isNull)continue;let b=m.indexOf(P),g=b===0||m[b-1].isNull;T+=`${g?"M":"L"} ${P.x},${P.y} `}if(T){let P=document.createElementNS("http://www.w3.org/2000/svg","path");if(P.setAttribute("d",T.trim()),P.setAttribute("fill","none"),P.setAttribute("stroke",c),P.setAttribute("stroke-width","2"),C)P.setAttribute("stroke-dasharray","6 3");R.appendChild(P)}let v=[];for(let P of m){let b=document.createElementNS("http://www.w3.org/2000/svg","circle");if(b.setAttribute("cx",String(P.x)),b.setAttribute("cy",String(P.y)),b.setAttribute("r","4"),b.setAttribute("fill",c),b.setAttribute("class","pf-data-dot"),b.setAttribute("data-visible","false"),b.style.pointerEvents="none",P.isNull)b.style.display="none";R.appendChild(b),v.push(b)}f.push(v)}let D=document.createElementNS("http://www.w3.org/2000/svg","line");if(D.setAttribute("class","pf-crosshair"),D.setAttribute("x1",String(O.plotLeft)),D.setAttribute("x2",String(O.plotLeft)),D.setAttribute("y1",String(O.plotTop)),D.setAttribute("y2",String(O.plotBottom)),D.setAttribute("stroke",$0),D.setAttribute("stroke-width","1"),D.setAttribute("stroke-dasharray","3 3"),D.setAttribute("opacity","0"),R.appendChild(D),E){let V=N?(A)=>t(A,N,Z):void 0;q1(R,q,E,(A)=>{return q.length===1?(O.plotLeft+O.plotRight)/2:O.plotLeft+A/(q.length-1)*O.plotWidth},O.plotBottom,V)}if(_){let V=U0(J,R),A=Y1(Z,Z0($),$.yAxisRightFormat);t1(V,R,q,Q,O,X??E,A,D,f,z?(h)=>t(h,z,Z):void 0)}return X0(J,Q,$.showLegend),J.appendChild(R),J}function T6($,Z){let J=B("div","pf-chart pf-pie-chart"),q=x($.data,Z)??[],Q=$.series??[],Y=$.height??300,U=Math.min(Y,300),W=$.showTooltip!==!1,H=$.dataKey??Q[0]?.dataKey,_=$.nameKey??$.tooltipXKey??$.xAxis,E=Q.length>0?Q:H?[{dataKey:H,label:H}]:[];if(q.length===0||!H)return J.textContent="No chart data",J;let X=Q0(U,U,"Pie"),N=U/2,z=U/2,L=U/2-10,M=$.tooltipXFormat,F=Z0($),j=(S)=>F?t(S,F,Z):String(S),I=q.map((S)=>Number(S[H]??0)),k=I.reduce((S,f)=>S+f,0);if(k===0)return J.textContent="No chart data",J.appendChild(X),J;let O=W?U0(J,X):void 0,R=-Math.PI/2;for(let S=0;S<I.length;S++){let f=I[S]/k*2*Math.PI,D=R+f,V=f>Math.PI?1:0,A=N+L*Math.cos(R),C=z+L*Math.sin(R),h=N+L*Math.cos(D),c=z+L*Math.sin(D),m=l[S%l.length],T=document.createElementNS("http://www.w3.org/2000/svg","path");if(T.setAttribute("d",`M ${N},${z} L ${A},${C} A ${L},${L} 0 ${V} 1 ${h},${c} Z`),T.setAttribute("fill",m),T.style.cursor="default",O){let v=_?q[S][_]:void 0,P=v!=null?M?t(v,M,Z):String(v):`Slice ${S+1}`,b=`${(I[S]/k*100).toFixed(1)}%`,g=R+f/2,i=N+L*0.6*Math.cos(g);T.addEventListener("mouseenter",()=>{a(O,i,z,P,[{label:E[0].label??H,value:`${j(I[S])} (${b})`,color:m}])}),T.addEventListener("mouseleave",()=>{O.tooltip.classList.remove("pf-visible")}),T.addEventListener("touchstart",()=>{a(O,i,z,P,[{label:E[0].label??H,value:`${j(I[S])} (${b})`,color:m}])},{passive:!0}),T.addEventListener("touchend",()=>{O.tooltip.classList.remove("pf-visible")},{passive:!0})}X.appendChild(T),R=D}return X0(J,E,$.showLegend),J.appendChild(X),J}function I6($,Z){let J=B("div","pf-chart pf-scatter-chart"),q=x($.data,Z)??[],Q=$.xAxis,Y=$.yAxis,U=$.zAxis,W=$.series??[],H=$.height??300;if(q.length===0||!Q||!Y)return J.textContent="No chart data",J;let _=$.showGrid!==!1,E=$.showTooltip!==!1,X=W[0]?.color??l[0],N=Z0($),z=(T)=>N?t(T,N,Z):String(Math.round(T*100)/100),L=q.map((T)=>Number(T[Q]??0)),M=q.map((T)=>Number(T[Y]??0)),F=Math.min(...L),j=Math.max(...L),I=Math.min(...M),k=Math.max(...M),O=j-F||1,R=k-I||1,S=U?q.map((T)=>Number(T[U]??0)):[],f=U?Math.max(...S,1):1,D=400,V=w0(D,H,!0),A=Q0(D,H,"Scatter"),C=(T)=>V.plotLeft+(T-F)/O*V.plotWidth,h=(T)=>V.plotBottom-(T-I)/R*V.plotHeight,c=4;for(let T=0;T<=c;T++){let v=I+R*T/c,P=h(v);if(A.appendChild(b0({x:V.plotLeft-6,y:P+3,"text-anchor":"end","font-size":W0,fill:$0},z(v))),_&&T>0)A.appendChild(d("line",{x1:V.plotLeft,y1:P,x2:V.plotRight,y2:P,stroke:B0,"stroke-width":1,"stroke-dasharray":"4 3"}))}C0(A,V);for(let T of[F,(F+j)/2,j])A.appendChild(b0({x:C(T),y:V.plotBottom+14,"text-anchor":"middle","font-size":W0,fill:$0},String(Math.round(T*100)/100)));let m=E?U0(J,A):void 0;for(let T=0;T<q.length;T++){let v=C(L[T]),P=h(M[T]),b=U?4+Math.sqrt(S[T]/f)*14:4,g=d("circle",{cx:v,cy:P,r:b,fill:X,"fill-opacity":U?0.6:0.85});if(m){let i=[{label:Q,value:z(L[T]),color:X},{label:Y,value:z(M[T]),color:X},...U?[{label:U,value:z(S[T]),color:X}]:[]],Y0=W[0]?.label??"Point";g.addEventListener("mouseenter",()=>a(m,v,P,Y0,i)),g.addEventListener("mouseleave",()=>m.tooltip.classList.remove("pf-visible")),g.addEventListener("touchstart",()=>a(m,v,P,Y0,i),{passive:!0}),g.addEventListener("touchend",()=>m.tooltip.classList.remove("pf-visible"),{passive:!0})}A.appendChild(g)}return X0(J,W,$.showLegend),J.appendChild(A),J}function P6($,Z){let J=B("div","pf-chart pf-radial-chart"),q=x($.data,Z)??[],Q=$.series??[],Y=$.dataKey??Q[0]?.dataKey,U=$.nameKey??$.tooltipXKey??$.xAxis,W=$.height??300;if(q.length===0||!Y)return J.textContent="No chart data",J;let H=Math.min(W,300),_=H/2,E=H/2,X=H/2-10,N=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)),j=Math.max(...F,1),I=Q0(H,H,"Radial"),k=(X-N)/q.length,O=Math.max(2,k*0.7),R=Z0($),S=(V)=>R?t(V,R,Z):String(V),f=M?U0(J,I):void 0,D=[];for(let V=0;V<q.length;V++){let A=X-k*V-k/2,C=Q[V]?.color??l[V%l.length],h=F[V]/j,c=z+h*(L-z),m=U?q[V][U]:null,T=m!=null?String(m):Q[V]?.label??Y;D.push({dataKey:T||Y,label:T||Y,color:C}),I.appendChild(d("path",{d:U1(_,E,A,z,L),fill:"none",stroke:B0,"stroke-width":O,"stroke-linecap":"round"}));let v=d("path",{d:U1(_,E,A,z,c),fill:"none",stroke:C,"stroke-width":O,"stroke-linecap":"round"});if(f){let P=H0(_,E,A,(z+c)/2),b=[{label:Y,value:S(F[V]),color:C}],g=T||Y;v.addEventListener("mouseenter",()=>a(f,P.x,P.y,g,b)),v.addEventListener("mouseleave",()=>f.tooltip.classList.remove("pf-visible")),v.addEventListener("touchstart",()=>a(f,P.x,P.y,g,b),{passive:!0}),v.addEventListener("touchend",()=>f.tooltip.classList.remove("pf-visible"),{passive:!0})}I.appendChild(v)}return X0(J,D,$.showLegend),J.appendChild(I),J}function R6($,Z){let J=B("div","pf-chart pf-radar-chart"),q=x($.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 W=$.filled!==!1,H=$.showDots===!0,_=$.showGrid!==!1,E=$.showTooltip!==!1,X=Math.min(U,320),N=X/2,z=X/2,L=X/2-24,M=q.length,F=Math.max(...q.flatMap((f)=>Q.map((D)=>Number(f[D.dataKey]??0))),1),j=(f)=>90-360*f/M,I=(f)=>f.map((D)=>`${D.x.toFixed(1)},${D.y.toFixed(1)}`).join(" "),k=Q0(X,X,"Radar");if(_){for(let D=1;D<=4;D++){let V=L*D/4,A=Array.from({length:M},(C,h)=>H0(N,z,V,j(h)));k.appendChild(d("polygon",{points:I(A),fill:"none",stroke:B0,"stroke-width":1}))}for(let D=0;D<M;D++){let V=H0(N,z,L,j(D));k.appendChild(d("line",{x1:N,y1:z,x2:V.x,y2:V.y,stroke:B0,"stroke-width":1}))}}for(let f=0;f<M;f++){let D=H0(N,z,L+12,j(f)),V=Y?q[f][Y]:null;k.appendChild(b0({x:D.x,y:D.y+3,"text-anchor":"middle","font-size":W0,fill:$0},V!=null?String(V):""))}let O=E?U0(J,k):void 0,R=Z0($),S=(f)=>R?t(f,R,Z):String(f);for(let f=0;f<Q.length;f++){let D=Q[f],V=D.color??l[f%l.length],A=q.map((C,h)=>H0(N,z,Number(C[D.dataKey]??0)/F*L,j(h)));if(k.appendChild(d("polygon",{points:I(A),fill:W?V:"none","fill-opacity":W?0.2:0,stroke:V,"stroke-width":2})),H||O)for(let C=0;C<A.length;C++){let h=d("circle",{cx:A[C].x,cy:A[C].y,r:H?3:6,fill:H?V:"transparent","fill-opacity":H?1:0});if(O){let c=Y?q[C][Y]:null,m=c!=null?String(c):D.label??D.dataKey,T=[{label:D.label??D.dataKey,value:S(Number(q[C][D.dataKey]??0)),color:V}];h.addEventListener("mouseenter",()=>a(O,A[C].x,A[C].y,m,T)),h.addEventListener("mouseleave",()=>O.tooltip.classList.remove("pf-visible")),h.addEventListener("touchstart",()=>a(O,A[C].x,A[C].y,m,T),{passive:!0}),h.addEventListener("touchend",()=>O.tooltip.classList.remove("pf-visible"),{passive:!0})}k.appendChild(h)}}return X0(J,Q,$.showLegend),J.appendChild(k),J}function A6($,Z){let J=B("div","pf-chart pf-histogram"),q=x($.data,Z);if(!q||q.length===0)return J.textContent="No data",J;let Q=q,Y=$.bins??10,U=$.height??200,W=$.color??l[0],H=Math.min(...Q),E=(Math.max(...Q)-H)/Y||1,X=Array(Y).fill(0);for(let j of Q){let I=Math.min(Math.floor((j-H)/E),Y-1);X[I]++}let N=Math.max(...X),z=300,L=U,M=z/Y,F=Q0(z,L,"Histogram");for(let j=0;j<Y;j++){let I=N>0?X[j]/N*L:0,k=document.createElementNS("http://www.w3.org/2000/svg","rect");k.setAttribute("x",String(j*M)),k.setAttribute("y",String(L-I)),k.setAttribute("width",String(M-1)),k.setAttribute("height",String(I)),k.setAttribute("fill",W),F.appendChild(k)}return J.appendChild(F),J}function J4(){G("Table",k6),G("TableHead",W1("thead")),G("TableBody",W1("tbody")),G("TableFooter",W1("tfoot")),G("TableRow",f6),G("TableHeader",S6),G("TableCell",w6),G("TableCaption",C6),G("ExpandableRow",b6)}function k6($,Z){let J=document.createElement("table");return J.className="pf-table",J.style.width="100%",J.style.borderCollapse="collapse",w($,J,Z),J}function W1($){return(Z,J)=>{let q=document.createElement($);return q.className=`pf-${$}`,w(Z,q,J),q}}function f6($,Z){let J=document.createElement("tr");return J.className="pf-table-row",w($,J,Z),J}function S6($,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 w6($,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 C6($,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 b6($,Z){let J=B("div","pf-expandable-row"),q=B("div","pf-expandable-row-summary");q.style.cursor="pointer",q.style.display="flex",q.style.alignItems="center",q.style.gap="8px";let Q=B("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 H of Y)q.appendChild(u(H,Z));let U=B("div","pf-expandable-row-detail");U.style.display="none",U.style.paddingLeft="24px",w($,U,Z);let W=!1;return q.addEventListener("click",()=>{W=!W,U.style.display=W?"block":"none",Q.style.transform=W?"rotate(90deg)":""}),J.appendChild(q),J.appendChild(U),J}var q4=!1;function y0(){if(q4)return;q4=!0,S1(),y1(),v1(),g1(),x1(),p1(),c1(),i1(),s1(),o1(),Z4(),J4()}function X1($){return $.replace(/[^a-zA-Z0-9_-]/g,"")}function G1($){return $.replace(/[{}<>;]/g,"").replace(/\b(url|expression)\s*\(/gi,"")}function H1($,Z=" "){return Object.entries($).map(([J,q])=>`${Z}--${X1(J)}: ${G1(q)};`).join(`
7
- `)}function Q4($){if(!$)return"";let Z=[];if($.light&&Object.keys($.light).length>0)Z.push(`:root {
8
- ${H1($.light)}
9
- }`);if($.dark&&Object.keys($.dark).length>0){let J=H1($.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 N=H?` data-language="${f0(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}>${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=_("div","pf-card");return J.style.overflow="hidden",w($,J,Z),J}function J1($){return(Z,J)=>{let q=_("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=_("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 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 z={...Z.scope,$item:L,$index:Y.indexOf(B)},D=l({...Z,scope:z});h(m($.onRowClick,D),"onRowClick")});for(let z of Q){let D=document.createElement("td");D.className="pf-datatable-td";let I;if(z.accessor)I=p(`{{ $item.${z.accessor} }}`,{...Z,scope:{...Z.scope,$item:L}});else if(I=M?B:L[z.key],z.format&&I!=null)I=p(`{{ __fmtVal | ${z.format} }}`,{...Z,scope:{...Z.scope,__fmtVal:I}});D.textContent=I==null?"":String(I),D.style.padding="8px 12px",K.appendChild(D)}E.appendChild(K)}}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(),K=Array.from(E.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=_("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=_("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=_("div","pf-metric"),q=_("div","pf-metric-label");q.textContent=F($.label,Z),q.style.fontSize="14px",J.appendChild(q);let Q=_("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=_("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=_("div","pf-metric-desc");Y.textContent=F($.description,Z),Y.style.fontSize="12px",J.appendChild(Y)}return J}function C8($,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 K=_("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=_("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 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=_("div","pf-loader");return J.textContent="⏳",J.style.display="flex",J.style.justifyContent="center",J.style.padding="16px",J}function h8($,Z){let J=_("span","pf-icon");return J.setAttribute("data-icon",F($.name??$.content,Z)),J}function v8($,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((K,L)=>{let M=L/E*Q,z=Y-(K-H)/W*(Y-4)-2;return`${M},${z}`}).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 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",c8),G("Button",p8),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=_("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 c8($,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=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 p8($,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=_("div","pf-button-group");return J.style.display="flex",J.style.gap="8px",w($,J,Z),J}function d8($,Z){let J=_("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(c(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 _("span")}function s8($,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)h(m($.onChange,{...l(Z),scope:{...Z.scope,$event:q.checked}}),"onChange")})}if(J.appendChild(q),$.label!=null){let Y=_("span");Y.textContent=F($.label,Z),J.appendChild(Y)}return J}function n8($,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)h(m($.onChange,{...l(Z),scope:{...Z.scope,$event:q.checked}}),"onChange")})}if(J.appendChild(q),$.label!=null){let Y=_("span");Y.textContent=F($.label,Z),J.appendChild(Y)}return J}function r8($,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)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=_("div",$);return w(Z,q,J),q}}function K0($){return(Z,J)=>{let q=_("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=_("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=_("span","pf-radio-label");Q.textContent=F($.label,Z),J.appendChild(Q)}return J}function t8($,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=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=_("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=_("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",()=>{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=_("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=_("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=_("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=_("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=_("div","pf-choice-card-label");q.textContent=F($.label,Z),q.style.fontWeight="600",J.appendChild(q)}if($.description!=null){let q=_("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=_("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 Y6($,Z){let J=_("div","pf-tab");return w($,J,Z),J}function U6($,Z){let J=_("div","pf-accordion");return w($,J,Z),J}function H6($,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 W6($,Z){let J=_("div","pf-dialog-wrapper");if($.trigger!=null){let Y=c($.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=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=_("p","pf-dialog-desc");Y.textContent=F($.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 X6($,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=F($.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 G6($,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=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=_("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 M6($,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",F($.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 $4(){G("ForEach",_6),G("If",Z4),G("Elif",N6),G("Else",E6),G("Condition",z6),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},N={...Z,scope:W};if($.children)Q0($.children,J,N)}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 E6($,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 z6($,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,scope:U};for(let W of Q)J.appendChild(c(W,H));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(c(U,Z));return J}function q4(){G("Alert",V6),G("AlertTitle",D6),G("AlertDescription",O6)}function V6($,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 D6($,Z){let J=_("h5","pf-alert-title");return J.textContent=F($.content,Z),J.style.fontWeight="600",J.style.marginBottom="4px",J}function O6($,Z){let J=_("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=_("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=_("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=_("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=_("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=_("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 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),y6(J,N,{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");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),K=N.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=N.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 z=B.getViewport({scale:L});E.width=z.width,E.height=z.height,E.style.width=`${z.width}px`,E.style.height=`${z.height}px`;let D=E.getContext("2d");if(!D)return;if(await B.render({canvasContext:D,viewport:z}).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=_("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 z of Q)W+='<div class="pf-chart-tooltip-row">',W+=`<span class="pf-chart-tooltip-dot" style="background:${C0(z.color)}"></span>`,W+=`<span>${C0(z.label)}:</span> <strong>${C0(String(z.value))}</strong>`,W+="</div>";Y.innerHTML=W;let N=U.getBoundingClientRect(),E=H.getBoundingClientRect(),X=U.viewBox.baseVal,B=N.width/(X.width||1),K=N.left-E.left+Z*B,L=Y.offsetWidth||100,M=K+12;if(M+L>E.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 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,K=B!=null?H?H(B):String(B):void 0,L=q.map((I,A)=>({label:I.label??I.dataKey,value:U(J[N][I.dataKey],I,A),color:I.color??b0[A%b0.length]})),M=E+W/2,z=()=>e($,M,Q.plotTop,K,L),D=()=>$.tooltip.classList.remove("pf-visible");X.addEventListener("mouseenter",z),X.addEventListener("mouseleave",D),X.addEventListener("touchstart",z,{passive:!0}),X.addEventListener("touchend",D,{passive:!0}),Z.appendChild(X)}}function X4($,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,K=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,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 z=Y?J[X][Y]:void 0,D=z!=null?N?N(z):String(z):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=p(`{{ __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=_("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??i[Q%i.length];let H=_("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",c6)}function h6($,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,K=$.tooltipXFormat,L=Q.filter((O)=>O.yAxisId!=="right"),M=Q.filter((O)=>O.yAxisId==="right"),z=W&&M.length>0,D=L.length>0?Math.max(...q.flatMap((O)=>L.map((V)=>Number(O[V.dataKey]??0))),1):1,I=z?Math.max(...q.flatMap((O)=>M.map((V)=>Number(O[V.dataKey]??0))),1):1,A=400,T=y0(A,Y,U,z),j=Y0(A,Y,"Bar");if(U)Y1(j,T,D,H,J0($));if(z)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),u=T.plotLeft+O*S+V*f+f/2,R=document.createElementNS("http://www.w3.org/2000/svg","rect");R.setAttribute("x",String(u)),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(E){let O=B?(V)=>$0(V,B,Z):void 0;H1(j,q,E,(V)=>{return T.plotLeft+V*S+S/2},T.plotBottom,O)}if(N){let O=W0(J,j),V=X1(Z,J0($),$.yAxisRightFormat);W4(O,j,q,Q,T,X??E,V,K?(b)=>$0(b,K,Z):void 0)}return B0(J,Q,$.showLegend),J.appendChild(j),J}function B4($,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,K=$.tooltipXFormat,L=Q.filter((V)=>V.yAxisId!=="right"),M=Q.filter((V)=>V.yAxisId==="right"),z=W&&M.length>0,D=L.length>0?Math.max(...q.flatMap((V)=>L.map((k)=>Number(V[k.dataKey]??0))),1):1,I=z?Math.max(...q.flatMap((V)=>M.map((k)=>Number(V[k.dataKey]??0))),1):1,A=400,T=y0(A,Y,U,z),j=Y0(A,Y,$.type==="AreaChart"?"Area":"Line"),S=$.type==="AreaChart";if(U)Y1(j,T,D,H,J0($));if(z)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",g=b?I:D,d=k.color??i[V%i.length],v=q.map((R,y)=>{let x=R[k.dataKey],n=x===null||x===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(x)/g*T.plotHeight;return{x:U0,y:f4,isNull:n}});if(S){let R=[],y=()=>{if(R.length<2){R=[];return}let x=`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",x),n.setAttribute("fill",d),n.setAttribute("opacity","0.15"),j.appendChild(n),R=[]};for(let x of v){if(x.isNull){y();continue}R.push(x)}y()}let P="";for(let R of v){if(R.isNull)continue;let y=v.indexOf(R),x=y===0||v[y-1].isNull;P+=`${x?"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 u=[];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),u.push(y)}f.push(u)}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?(k)=>$0(k,B,Z):void 0;H1(j,q,E,(k)=>{return q.length===1?(T.plotLeft+T.plotRight)/2:T.plotLeft+k/(q.length-1)*T.plotWidth},T.plotBottom,V)}if(N){let V=W0(J,j),k=X1(Z,J0($),$.yAxisRightFormat);X4(V,j,q,Q,T,X??E,k,O,f,K?(g)=>$0(g,K,Z):void 0)}return B0(J,Q,$.showLegend),J.appendChild(j),J}function v6($,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,K=U/2,L=U/2-10,M=$.tooltipXFormat,z=J0($),D=(S)=>z?$0(S,z,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),g=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 ${g},${d} Z`),P.setAttribute("fill",v),P.style.cursor="default",T){let u=N?q[S][N]:void 0,R=u!=null?M?$0(u,M,Z):String(u):`Slice ${S+1}`,y=`${(I[S]/A*100).toFixed(1)}%`,x=j+f/2,n=B+L*0.6*Math.cos(x);P.addEventListener("mouseenter",()=>{e(T,n,K,R,[{label:E[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:E[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,E,$.showLegend),J.appendChild(X),J}function g6($,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??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)),z=Math.min(...L),D=Math.max(...L),I=Math.min(...M),A=Math.max(...M),T=D-z||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-z)/T*V.plotWidth,g=(P)=>V.plotBottom-(P-I)/j*V.plotHeight,d=4;for(let P=0;P<=d;P++){let u=I+j*P/d,R=g(u);if(k.appendChild(h0({x:V.plotLeft-6,y:R+3,"text-anchor":"end","font-size":X0,fill:Z0},K(u))),N&&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[z,(z+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=E?W0(J,k):void 0;for(let P=0;P<q.length;P++){let u=b(L[P]),R=g(M[P]),y=U?4+Math.sqrt(S[P]/f)*14:4,x=s("circle",{cx:u,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";x.addEventListener("mouseenter",()=>e(v,u,R,U0,n)),x.addEventListener("mouseleave",()=>v.tooltip.classList.remove("pf-visible")),x.addEventListener("touchstart",()=>e(v,u,R,U0,n),{passive:!0}),x.addEventListener("touchend",()=>v.tooltip.classList.remove("pf-visible"),{passive:!0})}k.appendChild(x)}return B0(J,H,$.showLegend),J.appendChild(k),J}function u6($,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)),K=$.startAngle??180,L=$.endAngle??0,M=$.showTooltip!==!1,z=q.map((V)=>Number(V[Y]??0)),D=Math.max(...z,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],g=z[V]/D,d=K+g*(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(N,E,k,K,L),fill:"none",stroke:N0,"stroke-width":T,"stroke-linecap":"round"}));let u=s("path",{d:G1(N,E,k,K,d),fill:"none",stroke:b,"stroke-width":T,"stroke-linecap":"round"});if(f){let R=G0(N,E,k,(K+d)/2),y=[{label:Y,value:S(z[V]),color:b}],x=P||Y;u.addEventListener("mouseenter",()=>e(f,R.x,R.y,x,y)),u.addEventListener("mouseleave",()=>f.tooltip.classList.remove("pf-visible")),u.addEventListener("touchstart",()=>e(f,R.x,R.y,x,y),{passive:!0}),u.addEventListener("touchend",()=>f.tooltip.classList.remove("pf-visible"),{passive:!0})}I.appendChild(u)}return B0(J,O,$.showLegend),J.appendChild(I),J}function x6($,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,K=X/2,L=X/2-24,M=q.length,z=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(N){for(let O=1;O<=4;O++){let V=L*O/4,k=Array.from({length:M},(b,g)=>G0(B,K,V,D(g)));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=E?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,g)=>G0(B,K,Number(b[O.dataKey]??0)/z*L,D(g)));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 g=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}];g.addEventListener("mouseenter",()=>e(T,k[b].x,k[b].y,v,P)),g.addEventListener("mouseleave",()=>T.tooltip.classList.remove("pf-visible")),g.addEventListener("touchstart",()=>e(T,k[b].x,k[b].y,v,P),{passive:!0}),g.addEventListener("touchend",()=>T.tooltip.classList.remove("pf-visible"),{passive:!0})}A.appendChild(g)}}return B0(J,Q,$.showLegend),J.appendChild(A),J}function c6($,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??i[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),K=300,L=U,M=K/Y,z=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),z.appendChild(A)}return J.appendChild(z),J}function _4(){G("Table",p6),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 p6($,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=_("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(c(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 N4=!1;function v0(){if(N4)return;N4=!0,c1(),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 E4($){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
- ${H1($.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 M1($,Z){if(!Z)return;if(Z.light)for(let[J,q]of Object.entries(Z.light))$.style.setProperty(`--${X1(J)}`,G1(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=Q4({dark:Z.dark})}}function B1($,Z){if(!$||typeof document>"u")return;let J=(q)=>{for(let[Q,Y]of Object.entries($))if(y6(Q,q))q.preventDefault(),Z(Y)};return document.addEventListener("keydown",J),()=>document.removeEventListener("keydown",J)}function y6($,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 Y4='<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>',U4='<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>',W4={"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 m6($,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 N1($,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 W=W4[J]??W4["top-right"];for(let X of W.split(";")){let[N,z]=X.split(":").map((L)=>L.trim());if(N&&z)U.style.setProperty(N,z)}U.addEventListener("mouseenter",()=>{U.style.opacity="1"}),U.addEventListener("mouseleave",()=>{U.style.opacity="0.7"});function H(X){if(N0($,X),Q)N0(document.documentElement,X);U.innerHTML=X==="dark"?U4:Y4;try{localStorage.setItem(q,X)}catch{}}let _=m6($,q);H(_),U.addEventListener("click",()=>{let X=$.getAttribute("data-theme")??"dark";H(X==="dark"?"light":"dark")}),$.appendChild(U);let E;if(Q)E=new MutationObserver((X)=>{for(let N of X)if(N.type==="attributes"&&N.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"?U4:Y4;try{localStorage.setItem(q,z)}catch{}}}}),E.observe(document.documentElement,{attributes:!0,attributeFilter:["data-theme"]});return()=>{E?.disconnect(),U.remove()}}function m0($){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 W=await U.json();if(W.error)throw Error(W.error.message??"MCP tool call returned error");let H=W.result?.content??W.content??[];for(let _ of H)if(_.type==="text"&&_.text!==void 0){try{let E=JSON.parse(_.text);if(typeof E==="object"&&E!==null&&"$prefab"in E)return E;return E}catch{}return _.text}return W.result??W},async sendMessage(Q){await q(`${Z}/mcp/messages`,{method:"POST",headers:J,body:JSON.stringify({message:Q})})}}}function h0(){return{callTool($){return console.warn(`[prefab] No MCP transport: callTool('${$}') ignored`),Promise.resolve(null)},sendMessage($){return console.warn("[prefab] No MCP transport: sendMessage ignored",$),Promise.resolve()}}}function h6($){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 $=u6();if($)this.postFn=(J)=>$.postMessage(J);let Z=(J)=>{if(this.hostOrigin!=="*"&&J.origin!==this.hostOrigin)return;let q=J.data;if(h6(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 v6;let Z=-1,J=-1,q=(U,W)=>{if(U===Z&&W===J)return;if(Z=U,J=W,this.protocol==="jsonrpc")this.sendRpcNotification("ui/notifications/size-changed",{width:U,height:W});else this.sendPrefab("prefab:size-changed",{width:U,height:W})},Q=new ResizeObserver((U)=>{for(let W of U)if(W.borderBoxSize.length){let H=W.borderBoxSize[0];q(Math.ceil(H.inlineSize),Math.ceil(H.blockSize))}else{let H=W.target.getBoundingClientRect();q(Math.ceil(H.width),Math.ceil(H.height))}});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??{},W=U.hostInfo??{},H=U.hostContext??{},_=U.hostCapabilities??{},E;if(typeof H.theme==="string"||typeof H.styles==="object"){if(E={},typeof H.theme==="string")E.colorScheme=H.theme;if(typeof H.styles==="object"&&H.styles!==null){let N=H.styles;if(N.variables)E.variables=N.variables;if(typeof N.css?.fonts==="string")E.fontCss=N.css.fonts}}this.postJsonRpc({jsonrpc:"2.0",method:"ui/notifications/initialized",params:{}});let X=_.resources;this._hostSupportsSubscriptions=_.subscriptions===!0||X?.subscribe===!0,Z({hostName:W.name,hostVersion:W.version,capabilities:{toast:!0,navigation:_.openLinks!=null,messaging:!0,displayModes:H.availableDisplayModes??[]},theme:E,toolInput:void 0,meta:H})},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 v6=()=>{};function _1($,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)g6(Z.fontCss)}function g6($){if(document.getElementById("__prefab-host-fonts"))return;let J=document.createElement("style");J.id="__prefab-host-fonts",J.textContent=$,document.head.appendChild(J)}function v0(){if(typeof window>"u")return!1;try{return window.self!==window.top}catch{return!0}}function u6(){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 n={mount($,Z,J){y0();let q=Z,Q=[];if(q.pipes)for(let[F,j]of Object.entries(q.pipes))H4(F,j,Q);let Y=new _0(q.state),U;if(J?.transport&&"callTool"in J.transport)U=J.transport;else if(J?.transport)U=m0(J.transport);else U=h0();let W=J?.onToast??p6,H=new o0;function _(F){let j=F;if(q=j,j.state)Y.merge(j.state);if(j.defs)E.defs=j.defs;if(j.theme)M1($,j.theme);if(j.mode)X4($,j.mode);if(j.pipes)for(let[I,k]of Object.entries(j.pipes))H4(I,k,Q);for(let I of X)I.remove();if(X.length=0,X.push(...G4(j.css,j.stylesheets)),M4($,j.layout),N?.(),N=void 0,j.keyBindings)N=B1(j.keyBindings,async(I)=>{await y(I,{store:Y,transport:U,scope:{},rerender:()=>M(),remount:_,onToast:W})});M()}let E={store:Y,scope:{},transport:U,rerender:()=>M(),remount:_,onToast:W,defs:q.defs,destroyRegistry:H};if(M1($,q.theme),q.mode)X4($,q.mode);M4($,q.layout);let X=G4(q.css,q.stylesheets),N;if(q.keyBindings)N=B1(q.keyBindings,async(F)=>{await y(F,{store:Y,transport:U,scope:{},rerender:()=>M(),remount:_,onToast:W})});let z,L=J?.themeToggle??!0;if(L!==!1)z=N1($,typeof L==="object"?L:void 0);function M(){H.flush();let F=$.querySelector(".pf-theme-toggle");$.innerHTML="";let j=u(q.view,E);if($.appendChild(j),F)$.appendChild(F)}return M(),{rerender:()=>M(),update(F){if(Y.merge(F.update.state),M(),F.update.actions!=null)y(F.update.actions,E)},store:Y,destroy(){H.flush(),z?.(),N?.(),T1(),I1();for(let F of X)F.remove();for(let F of Q)x0(F);$.innerHTML=""}}},isPrefabData($){return $!=null&&typeof $==="object"&&"$prefab"in $},isPrefabUpdate($){return $!=null&&typeof $==="object"&&"$prefab"in $&&"update"in $}},x6=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 H4($,Z,J){if(x6.has($)){console.warn(`[prefab] wire pipe "${$}" ignored — shadows built-in`);return}try{let q=Function("return ("+Z+")")();if(typeof q!=="function"){console.warn(`[prefab] wire pipe "${$}" — source did not evaluate to a function`);return}u0($,q),J.push($)}catch(q){console.warn(`[prefab] wire pipe "${$}" — failed to hydrate:`,q)}}function p6($){if(typeof document>"u")return;let Z=l6(),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 X4($,Z){if(N0($,Z),typeof document<"u")N0(document.documentElement,Z)}function c6($){let Z=$.trim();if(Z.includes("{")||Z.includes("}"))return!1;return/^(https?:)?\/\//i.test(Z)||Z.startsWith("/")||/\.css(\?|#|$)/i.test(Z)}function G4($,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(c6(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 M4($,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 l6(){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=n,$.prefab={app:g0,mount:n.mount.bind(n),isPrefabData:n.isPrefabData.bind(n),isPrefabUpdate:n.isPrefabUpdate.bind(n),Bridge:F0,isIframe:v0,registerPipe:u0,unregisterPipe:x0,listPipes:K1,registerComponent:G,createThemeToggle:N1};let Z=$.__PREFAB_DATA__;if(Z!=null){let J=document.getElementById("prefab-root");if(J)n.mount(J,Z)}}async function g0($){y0();let Z=$?.mode??"auto",J=Z==="bridge"||Z==="auto"&&v0(),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=m0($.transport);else q=h0();if(Y.theme&&typeof document<"u")_1(document.documentElement,Y.theme);if(typeof document<"u"&&!Q)i6();let U,W,H,_,E,X=Y.toolInput,N;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(W)W(F);else N=F}),Q.on("prefab:tool-cancelled",()=>{H?.()}),Q.on("prefab:tool-input-partial",(M)=>{_?.(M.args??M)}),Q.on("prefab:theme-update",(M)=>{if(typeof document<"u")_1(document.documentElement,M)}),Q.on("prefab:host-context-changed",(M)=>{E?.(M)});function z(M,...F){let j=E1(M),I=new _0,k={store:I,scope:{},transport:q,rerender:()=>O(),onToast:void 0};function O(){j.innerHTML="";for(let R of F)j.appendChild(u(R,k))}return O(),{rerender:O,store:I,destroy:()=>{j.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(W=M,N!==void 0){let F=N;N=void 0,queueMicrotask(()=>M(F))}},onToolCancelled:(M)=>{H=M},onToolInputPartial:(M)=>{_=M},onHostContextChanged:(M)=>{E=M},render:z,mount:(M,F,j)=>{let I=E1(M);return n.mount(I,F,{transport:q,...j})},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 d6;let F=typeof M==="string"?E1(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 d6=()=>{};function E1($){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 i6(){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 B4="#root";function F1($){return n.isPrefabData($)}function N4($){return n.isPrefabUpdate($)}function _4($){if(F1($))return $;if($!==null&&typeof $==="object"){let Z=$;if(F1(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(F1(Q))return Q}catch{}}}return null}async function E4(){let $=document.querySelector(B4);if(!$){console.error(`[prefab:auto] Mount target "${B4}" not found`);return}let Z=$,J=await g0();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=_4(Y);if(U)Q(U);else if(N4(Y)&&q)q.update(Y)}),J.onToolInput((Y)=>{let U=_4(Y);if(U)Q(U);else if(N4(Y)&&q)q.update(Y)})}function s6(){if(document.readyState==="loading")document.addEventListener("DOMContentLoaded",()=>{E4().catch(($)=>{console.error("[prefab:auto] Boot failed:",$)})},{once:!0});else queueMicrotask(()=>{E4().catch(($)=>{console.error("[prefab:auto] Boot failed:",$)})})}s6();})();
16
+ `)}function E0($,Z){$.setAttribute("data-theme",Z),$.classList.toggle("dark",Z==="dark"),$.classList.toggle("light",Z==="light")}function E1($,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=E4({dark:Z.dark})}}function z1($,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 z4='<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(E0($,X),Q)E0(document.documentElement,X);U.innerHTML=X==="dark"?K4:z4;try{localStorage.setItem(q,X)}catch{}}let N=a6($,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 K=document.documentElement.getAttribute("data-theme");if((K==="light"||K==="dark")&&K!==$.getAttribute("data-theme")){E0($,K),U.innerHTML=K==="dark"?K4:z4;try{localStorage.setItem(q,K)}catch{}}}}),E.observe(document.documentElement,{attributes:!0,attributeFilter:["data-theme"]});return()=>{E?.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 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 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??{},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 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"]);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 z of V1(Z).errors)C.warn(`wire validation ${z.path}: ${z.message}`);let q=Z,Q=[];if(q.pipes)for(let[z,D]of Object.entries(q.pipes))O4(z,D,Q);let Y=new z0(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 N(z){let D=z;if(q=D,D.state)Y.merge(D.state);if(D.defs)E.defs=D.defs;if(D.theme)E1($,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=z1(D.keyBindings,(I)=>{h(m(I,{store:Y,transport:U,scope:{},rerender:()=>M(),remount:N,onToast:H}),"keyBinding")});M()}let E={store:Y,scope:{},transport:U,rerender:()=>M(),remount:N,onToast:H,defs:q.defs,destroyRegistry:W};if(E1($,q.theme),q.mode)T4($,q.mode);P4($,q.layout);let X=I4(q.css,q.stylesheets),B;if(q.keyBindings)B=z1(q.keyBindings,(z)=>{h(m(z,{store:Y,transport:U,scope:{},rerender:()=>M(),remount:N,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 z=$.querySelector(".pf-theme-toggle");$.innerHTML="";let D=c(q.view,E);if($.appendChild(D),z)$.appendChild(z)}return M(),{rerender:()=>M(),update(z){if(Y.merge(z.update.state),M(),z.update.actions!=null)h(m(z.update.actions,E),"update action")},store:Y,destroy(){W.flush(),K?.(),B?.(),y1(),m1();for(let z of X)z.remove();for(let z of Q)d0(z);$.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(E0($,Z),typeof document<"u")E0(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:c0,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 c0($){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,N,E,X=Y.toolInput,B;if(Q)Q.on("prefab:tool-input",(M)=>{let z=M.args??M;if(U)U(z);else X=z}),Q.on("prefab:tool-result",(M)=>{let z=M.result??M;if(H)H(z);else B=z}),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 K(M,...z){let D=O1(M),I=new z0,A={store:I,scope:{},transport:q,rerender:()=>T(),onToast:void 0};function T(){D.innerHTML="";for(let j of z)D.appendChild(c(j,A))}return T(),{rerender:T,store:I,destroy:()=>{D.innerHTML=""}}}return{callTool:(M,z={})=>q.callTool(M,z),sendMessage:(M)=>q.sendMessage(M),onToolInput:(M)=>{if(U=M,X){let z=X;X=void 0,queueMicrotask(()=>M(z))}},onToolResult:(M)=>{if(H=M,B!==void 0){let z=B;B=void 0,queueMicrotask(()=>M(z))}},onToolCancelled:(M)=>{W=M},onToolInputPartial:(M)=>{N=M},onHostContextChanged:(M)=>{E=M},render:K,mount:(M,z,D)=>{let I=O1(M);return a.mount(I,z,{transport:q,...D})},requestMode:(M)=>Q?.requestMode(M),openLink:(M,z)=>{if(Q)Q.openLink(M,z);else if(typeof window<"u")window.open(M,z??"_blank")},updateContext:(M)=>{if(Q)Q.updateContext(M)},setupAutoResize:(M)=>{if(!Q)return H5;let z=typeof M==="string"?O1(M):M;return Q.setupAutoResize(z)},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=p0("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 c0();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();})();