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