@maxhealth.tech/prefab 0.3.7 → 0.3.9
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 +45 -0
- package/README.md +7 -5
- package/dist/app.d.ts +19 -2
- package/dist/app.d.ts.map +1 -1
- package/dist/app.js +1 -8
- package/dist/app.js.map +1 -1
- package/dist/components/charts/index.d.ts +4 -0
- package/dist/components/charts/index.d.ts.map +1 -1
- package/dist/components/charts/index.js +2 -0
- package/dist/components/charts/index.js.map +1 -1
- package/dist/components/form/index.d.ts +1 -6
- package/dist/components/form/index.d.ts.map +1 -1
- package/dist/components/form/index.js +7 -37
- package/dist/components/form/index.js.map +1 -1
- package/dist/components/interactive/index.d.ts +5 -1
- package/dist/components/interactive/index.d.ts.map +1 -1
- package/dist/components/interactive/index.js +5 -2
- package/dist/components/interactive/index.js.map +1 -1
- package/dist/components/media/index.d.ts +20 -2
- package/dist/components/media/index.d.ts.map +1 -1
- package/dist/components/media/index.js +13 -1
- package/dist/components/media/index.js.map +1 -1
- package/dist/components/table/index.d.ts +5 -1
- package/dist/components/table/index.d.ts.map +1 -1
- package/dist/components/table/index.js +5 -2
- package/dist/components/table/index.js.map +1 -1
- package/dist/core/component-types.d.ts +15 -0
- package/dist/core/component-types.d.ts.map +1 -0
- package/dist/core/component-types.js +135 -0
- package/dist/core/component-types.js.map +1 -0
- package/dist/core/component.d.ts +11 -0
- package/dist/core/component.d.ts.map +1 -1
- package/dist/core/component.js +22 -9
- package/dist/core/component.js.map +1 -1
- package/dist/core/escape.d.ts +21 -0
- package/dist/core/escape.d.ts.map +1 -0
- package/dist/core/escape.js +30 -0
- package/dist/core/escape.js.map +1 -0
- package/dist/core/validate.d.ts.map +1 -1
- package/dist/core/validate.js +6 -36
- package/dist/core/validate.js.map +1 -1
- package/dist/core/version.d.ts +1 -1
- package/dist/core/version.js +1 -1
- package/dist/mcp/display.d.ts +11 -2
- package/dist/mcp/display.d.ts.map +1 -1
- package/dist/mcp/display.js.map +1 -1
- package/dist/mcp/resource.d.ts.map +1 -1
- package/dist/mcp/resource.js +3 -9
- package/dist/mcp/resource.js.map +1 -1
- package/dist/prefab.css +4 -0
- package/dist/renderer/components/data.js +2 -2
- package/dist/renderer/components/data.js.map +1 -1
- package/dist/renderer/components/form.js +41 -15
- package/dist/renderer/components/form.js.map +1 -1
- package/dist/renderer/components/interactive.js +17 -4
- package/dist/renderer/components/interactive.js.map +1 -1
- package/dist/renderer/components/media.d.ts +7 -0
- package/dist/renderer/components/media.d.ts.map +1 -1
- package/dist/renderer/components/media.js +63 -2
- package/dist/renderer/components/media.js.map +1 -1
- package/dist/renderer/components/table.js +1 -1
- package/dist/renderer/components/table.js.map +1 -1
- package/dist/renderer/components/typography.d.ts.map +1 -1
- package/dist/renderer/components/typography.js +1 -8
- package/dist/renderer/components/typography.js.map +1 -1
- package/dist/renderer/engine.d.ts +8 -0
- package/dist/renderer/engine.d.ts.map +1 -1
- package/dist/renderer/engine.js +10 -0
- package/dist/renderer/engine.js.map +1 -1
- package/dist/renderer.auto.min.js +10 -10
- package/dist/renderer.min.js +7 -7
- package/package.json +7 -1
package/dist/renderer.min.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
(()=>{var{defineProperty:e1,getOwnPropertyNames:f8,getOwnPropertyDescriptor:w8}=Object,C8=Object.prototype.hasOwnProperty;function b8($){return this[$]}var y8=($)=>{var Z=(A0??=new WeakMap).get($),J;if(Z)return Z;if(Z=e1({},"__esModule",{value:!0}),$&&typeof $==="object"||typeof $==="function"){for(var q of f8($))if(!C8.call(Z,q))e1(Z,q,{get:b8.bind($,q),enumerable:!(J=w8($,q))||J.enumerable})}return A0.set($,Z),Z},A0;var m8=($)=>$;function h8($,Z){this[$]=m8.bind(null,Z)}var v8=($,Z)=>{for(var J in Z)e1($,J,{get:Z[J],enumerable:!0,configurable:!0,set:h8.bind(Z,J)})};var L5={};v8(L5,{validateWireFormat:()=>F1,unregisterPipe:()=>T1,setLogLevel:()=>j1,registerPipe:()=>O1,registerComponent:()=>G,log:()=>C,listPipes:()=>k1,isValidWireFormat:()=>V8,isIframe:()=>L1,getLogLevel:()=>f0,createThemeToggle:()=>V1,createLogger:()=>Z0,applyHostTheme:()=>R1,app:()=>t1,PrefabRenderer:()=>Z1,DestroyRegistry:()=>I1,Bridge:()=>_1});var S0={silent:0,error:1,warn:2,info:3,debug:4},$0="warn";function j1($){$0=$}function f0(){return $0}function Z0($){let Z=$?`[prefab:${$}]`:"[prefab]",J=(q,Q,Y)=>{if(S0[q]>S0[$0])return;console[q](`${Z} ${Q}`,...Y)};return{error:(q,...Q)=>J("error",q,Q),warn:(q,...Q)=>J("warn",q,Q),info:(q,...Q)=>J("info",q,Q),debug:(q,...Q)=>J("debug",q,Q)}}var C=Z0();class D1{data={};subscribers=new Map;globalSubscribers=new Set;generation=0;constructor($){if($)this.data=structuredClone($)}get($){return g8(this.data,$)}getAll(){return this.data}set($,Z){w0(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($))w0(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 g8($,Z){let J=Z.split("."),q=$;for(let Q of J){if(q==null||typeof q!=="object")return;q=q[Q]}return q}var u8=new Set(["__proto__","constructor","prototype"]);function w0($,Z,J){let q=Z.split(".");if(q.some((Y)=>u8.has(Y))){C.warn(`Blocked prototype pollution attempt: ${Z}`);return}let Q=$;for(let Y=0;Y<q.length-1;Y++){let U=q[Y];if(Q[U]==null||typeof Q[U]!=="object")Q[U]={};Q=Q[U]}Q[q[q.length-1]]=J}var N1=new Map;function O1($,Z){if(N1.has($)&&N1.get($)!==Z)C.warn(`pipe "${$}" re-registered`);N1.set($,Z)}function T1($){return N1.delete($)}function k1(){return[...N1.keys()]}function A1($){return N1.get($)}function b($){if($==null)return"";if(typeof $==="string")return $;if(typeof $==="number"||typeof $==="boolean"||typeof $==="bigint")return String($);if(typeof $==="symbol")return $.description??"";if(typeof $==="function")return $.name;if($ instanceof Date)return Number.isNaN($.getTime())?"":$.toISOString();if(Array.isArray($))return $.map(b).join(", ");try{return JSON.stringify($)??""}catch{return""}}var C0=-1,J0=new Map,x8=/\{\{\s*(.+?)\s*\}\}/g;function o($){return typeof $==="string"&&$.includes("{{")&&$.includes("}}")}function t($,Z,J){let q=$.trim();if(q.startsWith("{{")&&q.endsWith("}}")&&n8(q,"{{")===1){let Q=q.slice(2,-2).trim();return b0(Q,Z,J)}return $.replace(x8,(Q,Y)=>{let U=b0(Y.trim(),Z,J);return b(U)})}function b0($,Z,J){let[q,...Q]=s8($),Y=a(q.trim(),Z,J);for(let U of Q)Y=p8(U.trim(),Y,Z,J);return Y}function a($,Z,J){let q=l8($);if(q>=0){let U=$.slice(0,q).trim(),W=$.slice(q+1),H=i8(W);if(H>=0){let _=W.slice(0,H).trim(),z=W.slice(H+1).trim(),X=a(U,Z,J);return X!==null&&X!==void 0&&X!==!1&&X!==0&&X!==""?a(_,Z,J):a(z,Z,J)}}let Q=S1($,"||");if(Q>=0){let U=a($.slice(0,Q).trim(),Z,J);return U!==null&&U!==void 0&&U!==!1&&U!==0&&U!==""?U:a($.slice(Q+2).trim(),Z,J)}let Y=S1($,"&&");if(Y>=0){let U=a($.slice(0,Y).trim(),Z,J);if(U===null||U===void 0||U===!1||U===0||U==="")return U;return a($.slice(Y+2).trim(),Z,J)}for(let[U,W]of c8){let H=S1($,U);if(H>=0){let _=a($.slice(0,H).trim(),Z,J),z=a($.slice(H+U.length).trim(),Z,J);return W(_,z)}}if($.startsWith("!")){let U=a($.slice(1).trim(),Z,J);return U===null||U===void 0||U===!1||U===0||U===""}for(let[U,W]of d8){let H=S1($,U);if(H>=0){let _=a($.slice(0,H).trim(),Z,J),z=a($.slice(H+U.length).trim(),Z,J);return W(Number(_),Number(z))}}if($==="true")return!0;if($==="false")return!1;if($==="null"||$==="undefined")return null;if(/^-?\d+(\.\d+)?$/.test($))return Number($);if($.startsWith("'")&&$.endsWith("'")||$.startsWith('"')&&$.endsWith('"'))return $.slice(1,-1);if(J&&$.startsWith("$")){let U=$.indexOf(".");if(U>=0){let W=$.slice(0,U),H=$.slice(U+1),_=J[W];return f1(_,H)}return J[$]}if(J){let U=$.split(".")[0];if(U in J)return f1(J[U],$.includes(".")?$.slice(U.length+1):"")}return Z.get($)}function p8($,Z,J,q){let Q=$.indexOf(":"),Y=Q>=0?$.slice(0,Q).trim():$,U=Q>=0?$.slice(Q+1).trim():void 0,W=U?q0(U):void 0;switch(Y){case"find":{if(!Array.isArray(Z)||!U)return;let H=y0(U);if(H.length<2)return;let _=q0(H[0]),z=H[1].trim(),X;if(z.startsWith("'")&&z.endsWith("'")||z.startsWith('"')&&z.endsWith('"'))X=z.slice(1,-1);else if(J){if(q&&z.startsWith("$")){let M=z.indexOf(".");if(M>=0){let E=z.slice(0,M);if(E in q)X=f1(q[E],z.slice(M+1))}else if(z in q)X=q[z]}if(X===void 0&&!(q&&z.startsWith("$")))if(q){let M=z.split(".")[0];X=M in q?f1(q[M],z.includes(".")?z.slice(M.length+1):""):J.get(z)}else X=J.get(z)}else X=z;if(X==null)return;let B=J?.generation??0;if(B!==C0)J0=new Map,C0=B;let K=J0.get(Z);if(!K)K=new Map,J0.set(Z,K);let F=K.get(_);if(!F){F=new Map;for(let M of Z)if(M!=null&&typeof M==="object"){let E=M[_];if(E!=null)F.set(b(E),M)}K.set(_,F)}return F.get(b(X))}case"dot":{if(Z==null||typeof Z!=="object"||typeof W!=="string")return;return Z[W]}case"length":return Array.isArray(Z)?Z.length:typeof Z==="string"?Z.length:0;case"upper":return typeof Z==="string"?Z.toUpperCase():Z;case"lower":return typeof Z==="string"?Z.toLowerCase():Z;case"truncate":if(typeof Z==="string"&&typeof W==="number")return Z.slice(0,W);return Z;case"join":return Array.isArray(Z)?Z.join(typeof W==="string"?W:", "):Z;case"first":return Array.isArray(Z)?Z[0]:Z;case"last":return Array.isArray(Z)?Z[Z.length-1]:Z;case"abs":return Math.abs(Number(Z));case"round":return typeof W==="number"?Number(Number(Z).toFixed(W)):Math.round(Number(Z));case"number":return typeof W==="number"?Number(Number(Z).toFixed(W)):Number(Z);case"currency":{let H=typeof W==="string"?W:"USD";try{return new Intl.NumberFormat("en-US",{style:"currency",currency:H}).format(Number(Z))}catch{return Z}}case"percent":return typeof W==="number"?`${(Number(Z)*100).toFixed(W)}%`:`${Math.round(Number(Z)*100)}%`;case"compact":{let H=typeof W==="number"?W:1;try{return new Intl.NumberFormat("en-US",{notation:"compact",maximumFractionDigits:H}).format(Number(Z))}catch{return Z}}case"date":try{return new Date(Z).toLocaleDateString()}catch{return Z}case"time":try{return new Date(Z).toLocaleTimeString()}catch{return Z}case"datetime":try{return new Date(Z).toLocaleString()}catch{return Z}case"pluralize":{let H=Number(Z),_=typeof W==="string"?W:"";return H===1?_:`${_}s`}case"default":return Z==null||Z===""?W:Z;case"selectattr":return Array.isArray(Z)&&typeof W==="string"?Z.filter((H)=>H!=null&&typeof H==="object"&&Boolean(H[W])):Z;case"rejectattr":return Array.isArray(Z)&&typeof W==="string"?Z.filter((H)=>{if(H==null||typeof H!=="object")return!1;let _=H[W];return _==null||_===!1||_===0||_===""}):Z;default:{let H=A1(Y);if(H){let _=U?y0(U).map(q0):[];return H(Z,..._)}return Z}}}var c8=[["!==",($,Z)=>$!==Z],["===",($,Z)=>$===Z],["!=",($,Z)=>$!=Z],["==",($,Z)=>$==Z],[">=",($,Z)=>Number($)>=Number(Z)],["<=",($,Z)=>Number($)<=Number(Z)],[">",($,Z)=>Number($)>Number(Z)],["<",($,Z)=>Number($)<Number(Z)]],d8=[[" + ",($,Z)=>$+Z],[" - ",($,Z)=>$-Z],[" * ",($,Z)=>$*Z],[" / ",($,Z)=>Z!==0?$/Z:0],[" % ",($,Z)=>Z!==0?$%Z:0]];function S1($,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 l8($){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 i8($){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 s8($){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 q0($){let Z=$.replace(/^['"]|['"]$/g,"");if(Z==="true")return!0;if(Z==="false")return!1;let J=Number(Z);return isNaN(J)?Z:J}function y0($){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 f1($,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 n8($,Z){let J=0,q=0;while((q=$.indexOf(Z,q))!==-1)J++,q+=Z.length;return J}function w1($){return $.replace(/_([a-z])/g,(Z,J)=>J.toUpperCase())}function Y0($){let Z={};for(let[J,q]of Object.entries($)){let Q=J.startsWith("$")?J:w1(J);if(Array.isArray(q))Z[Q]=q.map((Y)=>Y!=null&&typeof Y==="object"&&!Array.isArray(Y)?Y0(Y):Y);else if(q!=null&&typeof q==="object"&&!Array.isArray(q))Z[Q]=Y0(q);else Z[Q]=q}return Z}async function h($,Z){let J=Array.isArray($)?$:[$];for(let q of J)await r8(q,Z)}function v($,Z){$.catch((J)=>C.error(`${Z} failed:`,J))}async function y1($,Z,J,q){if(J!=null)C.debug(`${$} failed:`,Z),await H1(J,q,{$error:Z});else C.warn(`${$} failed:`,Z)}async function r8($,Z){let J=Y0($),q=J.action;switch(q){case"setState":{a8(J,Z);return}case"toggleState":{o8(J,Z);return}case"appendState":{t8(J,Z);return}case"popState":{e8(J,Z);return}case"showToast":{$4(J,Z);return}case"closeOverlay":{Z4(J,Z);return}case"openLink":{J4(J);return}case"setInterval":{Q4(J,Z);return}case"toolCall":case"callTool":return Y4(J,Z);case"sendMessage":return U4(J,Z);case"updateContext":{W4(J,Z);return}case"fetch":return H4(J,Z);case"openFilePicker":{X4(J,Z);return}case"callHandler":return G4(J,Z);case"requestDisplayMode":{B4(J,Z);return}case"subscribe":{N4(J,Z);return}case"unsubscribe":{z4(J);return}default:C.warn(`Unknown action: ${q}`)}}function a8($,Z){let{key:J,value:q}=$;if(o(q))q=t(q,Z.store,Z.scope);Z.store.set(J,q),Z.rerender(),H1($.onSuccess,Z)}function o8($,Z){Z.store.toggle($.key),Z.rerender()}function t8($,Z){let J=$.value??$.item;if(o(J))J=t(J,Z.store,Z.scope);Z.store.append($.key,J,$.index),Z.rerender()}function e8($,Z){Z.store.pop($.key,$.index),Z.rerender()}function $4($,Z){Z.onToast?.({message:b1($.message,Z),description:$.description!=null?b1($.description,Z):void 0,variant:$.variant,duration:$.duration})}function Z4($,Z){if(typeof document<"u")document.dispatchEvent(new CustomEvent("prefab:close-overlay"))}function J4($){if(typeof window<"u"){let Z=$.url;if(!Z){C.warn("openLink: missing url");return}if(!g0(Z)){C.warn(`Blocked unsafe URL scheme: ${Z}`);return}window.open(Z,$.target??"_blank")}}var C1=new Set,q4=20,m0=100;function Q4($,Z){let J=Math.max($.intervalMs,m0),q=$.onTick;if(typeof globalThis.setInterval!=="function")return;if(C1.size>=q4){C.warn("Max intervals reached, ignoring new setInterval");return}let Q=globalThis.setInterval(()=>v(h(q,Z),"interval action"),J);C1.add(Q)}function h0(){for(let $ of C1)globalThis.clearInterval($);C1.clear()}async function Y4($,Z){if(!Z.transport){C.warn("No MCP transport configured for toolCall");return}let J=$.tool,q=U0($.arguments,Z);try{let Q=await Z.transport.callTool(J,q);if($.resultKey!=null)Z.store.set($.resultKey,Q);let Y=m1(Q);if(Y&&Z.remount)Z.remount(Y);else h1(Q,Z),Z.rerender();await H1($.onSuccess,Z,{$result:Q})}catch(Q){await y1("toolCall",Q,$.onError,Z)}}async function U4($,Z){if(!Z.transport){C.warn("No MCP transport configured for sendMessage");return}await Z.transport.sendMessage(b1($.message,Z))}function W4($,Z){let J=$.context;if(J!=null)Z.store.merge(J),Z.rerender()}async function H4($,Z){let J=b1($.url,Z);if(!g0(J)){C.warn(`Blocked unsafe URL in fetch: ${J}`);return}let q=$.method??"GET",Q=$.headers,Y=$.body!==void 0?JSON.stringify($.body):void 0;try{let U=await globalThis.fetch(J,{method:q,headers:{"Content-Type":"application/json",...Q},...Y&&{body:Y}}),W=await U.json().catch(()=>U.text());if($.resultKey!=null)Z.store.set($.resultKey,W);let H=m1(W);if(H&&Z.remount)Z.remount(H);else h1(W,Z),Z.rerender();await H1($.onSuccess,Z,{$result:W})}catch(U){await y1("fetch",U,$.onError,Z)}}function X4($,Z){if(typeof document>"u")return;let J=document.createElement("input");if(J.type="file",$.accept!=null)J.accept=$.accept;if($.multiple===!0)J.multiple=!0;J.addEventListener("change",()=>{let q=Array.from(J.files??[]);if($.resultKey!=null)Z.store.set($.resultKey,q);Z.rerender(),H1($.onSuccess,Z,{$result:q})}),J.click()}async function G4($,Z){let J=$.handler,q=U0($.arguments,Z);if(!Z.transport){C.warn(`No transport configured for callHandler: ${J}`);return}try{let Q=await Z.transport.callTool(J,q);if($.resultKey!=null)Z.store.set($.resultKey,Q);let Y=m1(Q);if(Y&&Z.remount)Z.remount(Y);else h1(Q,Z),Z.rerender();await H1($.onSuccess,Z,{$result:Q})}catch(Q){await y1("callHandler",Q,$.onError,Z)}}function B4($,Z){if(typeof document<"u")document.dispatchEvent(new CustomEvent("prefab:request-display-mode",{detail:{mode:$.mode}}))}var Q1=new Map,M4=50,_4=2000;function N4($,Z){let{uri:J,stateKey:q}=$;if(!J||!q){C.warn("subscribe: missing uri or stateKey");return}if(Q1.has(J))return;if(Q1.size>=M4){C.warn("Max subscriptions reached, ignoring new subscribe");return}let Q=(X)=>{let B=m1(X);if(B&&Z.remount)Z.remount(B);else{if(!h1(X,Z))Z.store.set(q,X);Z.rerender()}H1($.onData,Z,{$data:X})};if(Z.transport?.subscribe&&Z.transport.capabilities?.subscriptions){let X=Z.transport.subscribe(J,Q);Q1.set(J,X);return}let Y=$.fallbackTool,U=$.fallbackInterval??_4;if(!Y){C.warn("subscribe: host lacks subscriptions and no fallbackTool specified");return}if(!Z.transport){C.warn("No MCP transport configured for subscribe fallback");return}let W=$.fallbackArgs??{},H=Math.max(U,m0),_=Z.transport,z=globalThis.setInterval(()=>{(async()=>{try{let X=U0(W,Z),B=await _.callTool(Y,X);Q(B)}catch(X){y1("subscribe",X,$.onError,Z)}})()},H);Q1.set(J,()=>globalThis.clearInterval(z))}function z4($){let Z=$.uri;if(!Z){C.warn("unsubscribe: missing uri");return}let J=Q1.get(Z);if(J)J(),Q1.delete(Z)}function v0(){for(let[$,Z]of Q1)try{Z()}catch(J){C.warn(`Error cleaning up subscription '${$}':`,J)}Q1.clear()}function m1($){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(Q0(Z))return Z;if("structuredContent"in Z){let J=Z.structuredContent;if(J!=null&&typeof J==="object"&&Q0(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"&&Q0(q))return q}catch{}}return null}function Q0($){if(!("$prefab"in $)||!("update"in $))return!1;let Z=$.update;return Z!=null&&typeof Z==="object"&&"state"in Z}function h1($,Z){let J=E4($);if(!J)return!1;let q=J.update;if(Z.store.merge(q.state),q.actions!=null)v(h(q.actions,Z),"update action");return!0}var K4=/^\s*(javascript|vbscript|data):/i;function g0($){return!K4.test($)}function b1($,Z){if(o($)){let J=t($,Z.store,Z.scope);return b(J)}return b($)}function U0($,Z){if(!$)return{};let J={};for(let[q,Q]of Object.entries($))J[q]=o(Q)?t(Q,Z.store,Z.scope):Q;return J}async function H1($,Z,J){if($==null)return;let q={...Z.scope,...J};await h($,{...Z,scope:q})}function H0($){let Z={};for(let[J,q]of Object.entries($)){let Q=J.startsWith("$")?J:w1(J);if(Array.isArray(q))Z[Q]=q.map((Y)=>Y!=null&&typeof Y==="object"&&!Array.isArray(Y)?H0(Y):Y);else if(q!=null&&typeof q==="object"&&!Array.isArray(q))Z[Q]=H0(q);else Z[Q]=q}return Z}class I1{callbacks=[];track($){this.callbacks.push($)}flush(){for(let $ of this.callbacks)try{$()}catch(Z){C.warn("destroy callback error:",Z)}this.callbacks=[]}get size(){return this.callbacks.length}}function L4($){return typeof $==="object"&&"element"in $}var X0=new Map;function G($,Z){if(X0.has($))C.warn(`overriding existing renderer for "${$}"`);X0.set($,Z)}function u($,Z){let J=H0($);if(Z.defs?.[J.type]){let Y={...Z.defs[J.type],...J,type:Z.defs[J.type].type};return u(Y,Z)}let q=X0.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(u(Y,Z));if(Q instanceof HTMLElement){if(J.id)Q.id=J.id;if(J.cssClass){let Y=L(J.cssClass,Z);if(Y)Q.className=(Q.className?Q.className+" ":"")+Y}if(J.onClick!=null){if(Q.addEventListener("click",()=>{v(h(J.onClick,l(Z)),"onClick")}),Q.tagName!=="BUTTON"&&Q.tagName!=="A")Q.setAttribute("role","button"),Q.setAttribute("tabindex","0"),Q.addEventListener("keydown",(Y)=>{let U=Y.key;if(U==="Enter"||U===" ")Y.preventDefault(),v(h(J.onClick,l(Z)),"onClick")})}}if(J.onMount){let Y=J.onMount,U=l(Z);queueMicrotask(()=>v(h(Y,U),"onMount"))}return Q}function w($,Z,J){if(!$.children)return;Y1($.children,Z,J)}function Y1($,Z,J){let q=0;while(q<$.length){let Q=$[q];if(Q.type==="If")q=F4($,q,Z,J);else if(Q.type==="Elif"||Q.type==="Else")q++;else Z.appendChild(u(Q,J)),q++}}function F4($,Z,J,q){let Q=!1,Y=Z,U=$[Y];if(u0(U.condition,q))W0(U,J,q),Q=!0;Y++;while(Y<$.length){let W=$[Y];if(W.type==="Elif"){if(!Q&&u0(W.condition,q))W0(W,J,q),Q=!0;Y++}else if(W.type==="Else"){if(!Q)W0(W,J,q);Y++;break}else break}return Y}function u0($,Z){if(!$)return!1;if(o($))return Boolean(t($,Z.store,Z.scope));return Boolean(Z.store.get($))}function W0($,Z,J){if(!$.children)return;Y1($.children,Z,J)}function L($,Z){if(o($)){let J=t($,Z.store,Z.scope);return b(J)}return b($)}function d($,Z){if(o($))return t($,Z.store,Z.scope);return $}function l($){return{store:$.store,transport:$.transport,scope:$.scope,rerender:$.rerender,onToast:$.onToast,remount:$.remount}}function N($,Z){let J=document.createElement($);if(Z)J.className=Z;return J}function G0($,Z){return $.textContent=Z,$}function d0(){G("Column",D4),G("Row",O4),G("Grid",x0),G("GridItem",p0),G("Container",T4),G("Div",c0),G("Span",I4),G("Dashboard",x0),G("DashboardItem",p0),G("Pages",P4),G("Page",c0),G("Detail",V4),G("MasterDetail",R4)}function D4($,Z){let J=N("div","pf-column");J.style.display="flex",J.style.flexDirection="column";let q=v1($);if(q!=null)J.style.gap=`${q*4}px`;if($.align!=null)J.style.alignItems=l0($.align);if($.justify!=null)J.style.justifyContent=i0($.justify);return w($,J,Z),J}function O4($,Z){let J=N("div","pf-row");J.style.display="flex",J.style.flexDirection="row";let q=v1($);if(q!=null)J.style.gap=`${q*4}px`;if($.align!=null)J.style.alignItems=l0($.align);if($.justify!=null)J.style.justifyContent=i0($.justify);if($.wrap===!0)J.style.flexWrap="wrap";return w($,J,Z),J}function x0($,Z){let J=N("div","pf-grid");J.style.display="grid";let q=$.columns??3;J.style.gridTemplateColumns=`repeat(${q}, 1fr)`;let Q=v1($);if(Q!=null)J.style.gap=`${Q*4}px`;return w($,J,Z),J}function p0($,Z){let J=N("div","pf-grid-item");if($.colSpan!=null)J.style.gridColumn=`span ${$.colSpan}`;if($.rowSpan!=null)J.style.gridRow=`span ${$.rowSpan}`;return w($,J,Z),J}function T4($,Z){let J=N("div","pf-container");if(J.style.maxWidth=$.maxWidth??"1200px",J.style.margin="0 auto",$.padding!=null)J.style.padding=`${$.padding*4}px`;return w($,J,Z),J}function c0($,Z){let J=N("div","pf-div");return w($,J,Z),J}function I4($,Z){let J=N("span","pf-span");return w($,J,Z),J}function P4($,Z){let J=N("div","pf-pages");return w($,J,Z),J}function V4($,Z){let J=N("div","pf-detail"),q=$.of!=null?d($.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 R4($,Z){let J=N("div","pf-master-detail");J.style.display="flex",J.style.flexDirection="row";let q=v1($);if(q!=null)J.style.gap=`${q*4}px`;let Q=$.masterWidth??"33%",Y=$.children??[];if(Y.length>0){let U=N("div","pf-master-detail-master");U.style.width=Q,U.style.flexShrink="0",U.style.overflow="auto",U.appendChild(u(Y[0],Z)),J.appendChild(U)}if(Y.length>1){let U=N("div","pf-master-detail-detail");U.style.flex="1",U.style.overflow="auto",U.appendChild(u(Y[1],Z)),J.appendChild(U)}return J}var j4=/\bgap-(\d+)\b/;function v1($){if($.gap!=null)return $.gap;if(typeof $.cssClass==="string"){let Z=j4.exec($.cssClass);if(Z)return Number(Z[1])}return null}function l0($){return{start:"flex-start",end:"flex-end",center:"center",stretch:"stretch",baseline:"baseline"}[$]??$}function i0($){return{start:"flex-start",end:"flex-end",center:"center",between:"space-between",around:"space-around",evenly:"space-evenly"}[$]??$}function n0(){G("Heading",k4),G("H1",($,Z)=>g1($,Z,"h1")),G("H2",($,Z)=>g1($,Z,"h2")),G("H3",($,Z)=>g1($,Z,"h3")),G("H4",($,Z)=>g1($,Z,"h4")),G("Text",A4),G("P",S4),G("Lead",($,Z)=>z1($,Z,"p","pf-lead")),G("Large",($,Z)=>z1($,Z,"span","pf-large")),G("Small",($,Z)=>z1($,Z,"small","pf-small")),G("Muted",($,Z)=>z1($,Z,"p","pf-muted")),G("BlockQuote",($,Z)=>z1($,Z,"blockquote","pf-blockquote")),G("Label",($,Z)=>z1($,Z,"label","pf-label")),G("Link",w4),G("Code",C4),G("Markdown",b4),G("Kbd",y4)}function k4($,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=L($.content,Z),Q}function g1($,Z,J){let q=document.createElement(J);return q.className=`pf-heading pf-${J}`,q.textContent=L($.content,Z),q}function A4($,Z){return G0(N("span","pf-text"),L($.content,Z))}function S4($,Z){return G0(N("p","pf-p"),L($.content,Z))}function z1($,Z,J,q){let Q=document.createElement(J);return Q.className=q,Q.textContent=L($.content,Z),Q}var f4=/^\s*(javascript|vbscript|data):/i;function w4($,Z){let J=document.createElement("a");if(J.className="pf-link",J.textContent=L($.content,Z),$.href!=null){let q=L($.href,Z);if(!f4.test(q))J.href=q}if($.target!=null)J.target=L($.target,Z);return J}function C4($,Z){let J=N("pre","pf-code"),q=N("code");if(q.textContent=L($.content,Z),$.language!=null)q.setAttribute("data-language",$.language);return J.appendChild(q),J}function b4($,Z){let J=N("div","pf-markdown"),q=L($.content,Z);return J.innerHTML=r0(q),J.setAttribute("data-markdown","true"),J}var s0=/^\s*(javascript|vbscript|data):/i;function x1($){return $.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""")}function u1($){let Z=x1($),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(s0.test(Y))return x1(Q);return`<img src="${Y}" alt="${Q}" />`}),Z=Z.replace(/\[([^\]]+)\]\(([^)]+)\)/g,(q,Q,Y)=>{if(s0.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 r0($){let Z=$.replace(/\r\n?/g,`
|
|
1
|
+
(()=>{var{defineProperty:$0,getOwnPropertyNames:b4,getOwnPropertyDescriptor:y4}=Object,m4=Object.prototype.hasOwnProperty;function h4($){return this[$]}var v4=($)=>{var Z=(S0??=new WeakMap).get($),J;if(Z)return Z;if(Z=$0({},"__esModule",{value:!0}),$&&typeof $==="object"||typeof $==="function"){for(var q of b4($))if(!m4.call(Z,q))$0(Z,q,{get:h4.bind($,q),enumerable:!(J=y4($,q))||J.enumerable})}return S0.set($,Z),Z},S0;var g4=($)=>$;function u4($,Z){this[$]=g4.bind(null,Z)}var x4=($,Z)=>{for(var J in Z)$0($,J,{get:Z[J],enumerable:!0,configurable:!0,set:u4.bind(Z,J)})};var I5={};x4(I5,{validateWireFormat:()=>D1,unregisterPipe:()=>O1,setLogLevel:()=>A1,registerPipe:()=>T1,registerComponent:()=>B,log:()=>w,listPipes:()=>S1,isValidWireFormat:()=>k4,isIframe:()=>F1,getLogLevel:()=>C0,createThemeToggle:()=>j1,createLogger:()=>J0,applyHostTheme:()=>k1,app:()=>e1,PrefabRenderer:()=>Z1,DestroyRegistry:()=>I1,Bridge:()=>_1});var f0={silent:0,error:1,warn:2,info:3,debug:4},Z0="warn";function A1($){Z0=$}function C0(){return Z0}function J0($){let Z=$?`[prefab:${$}]`:"[prefab]",J=(q,Q,Y)=>{if(f0[q]>f0[Z0])return;console[q](`${Z} ${Q}`,...Y)};return{error:(q,...Q)=>J("error",q,Q),warn:(q,...Q)=>J("warn",q,Q),info:(q,...Q)=>J("info",q,Q),debug:(q,...Q)=>J("debug",q,Q)}}var w=J0();class L1{data={};subscribers=new Map;globalSubscribers=new Set;generation=0;constructor($){if($)this.data=structuredClone($)}get($){return c4(this.data,$)}getAll(){return this.data}set($,Z){w0(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($))w0(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 c4($,Z){let J=Z.split("."),q=$;for(let Q of J){if(q==null||typeof q!=="object")return;q=q[Q]}return q}var p4=new Set(["__proto__","constructor","prototype"]);function w0($,Z,J){let q=Z.split(".");if(q.some((Y)=>p4.has(Y))){w.warn(`Blocked prototype pollution attempt: ${Z}`);return}let Q=$;for(let Y=0;Y<q.length-1;Y++){let U=q[Y];if(Q[U]==null||typeof Q[U]!=="object")Q[U]={};Q=Q[U]}Q[q[q.length-1]]=J}var N1=new Map;function T1($,Z){if(N1.has($)&&N1.get($)!==Z)w.warn(`pipe "${$}" re-registered`);N1.set($,Z)}function O1($){return N1.delete($)}function S1(){return[...N1.keys()]}function f1($){return N1.get($)}function b($){if($==null)return"";if(typeof $==="string")return $;if(typeof $==="number"||typeof $==="boolean"||typeof $==="bigint")return String($);if(typeof $==="symbol")return $.description??"";if(typeof $==="function")return $.name;if($ instanceof Date)return Number.isNaN($.getTime())?"":$.toISOString();if(Array.isArray($))return $.map(b).join(", ");try{return JSON.stringify($)??""}catch{return""}}var b0=-1,q0=new Map,d4=/\{\{\s*(.+?)\s*\}\}/g;function o($){return typeof $==="string"&&$.includes("{{")&&$.includes("}}")}function t($,Z,J){let q=$.trim();if(q.startsWith("{{")&&q.endsWith("}}")&&o4(q,"{{")===1){let Q=q.slice(2,-2).trim();return y0(Q,Z,J)}return $.replace(d4,(Q,Y)=>{let U=y0(Y.trim(),Z,J);return b(U)})}function y0($,Z,J){let[q,...Q]=a4($),Y=a(q.trim(),Z,J);for(let U of Q)Y=l4(U.trim(),Y,Z,J);return Y}function a($,Z,J){let q=n4($);if(q>=0){let U=$.slice(0,q).trim(),H=$.slice(q+1),W=r4(H);if(W>=0){let X=H.slice(0,W).trim(),M=H.slice(W+1).trim(),G=a(U,Z,J);return G!==null&&G!==void 0&&G!==!1&&G!==0&&G!==""?a(X,Z,J):a(M,Z,J)}}let Q=C1($,"||");if(Q>=0){let U=a($.slice(0,Q).trim(),Z,J);return U!==null&&U!==void 0&&U!==!1&&U!==0&&U!==""?U:a($.slice(Q+2).trim(),Z,J)}let Y=C1($,"&&");if(Y>=0){let U=a($.slice(0,Y).trim(),Z,J);if(U===null||U===void 0||U===!1||U===0||U==="")return U;return a($.slice(Y+2).trim(),Z,J)}for(let[U,H]of i4){let W=C1($,U);if(W>=0){let X=a($.slice(0,W).trim(),Z,J),M=a($.slice(W+U.length).trim(),Z,J);return H(X,M)}}if($.startsWith("!")){let U=a($.slice(1).trim(),Z,J);return U===null||U===void 0||U===!1||U===0||U===""}for(let[U,H]of s4){let W=C1($,U);if(W>=0){let X=a($.slice(0,W).trim(),Z,J),M=a($.slice(W+U.length).trim(),Z,J);return H(Number(X),Number(M))}}if($==="true")return!0;if($==="false")return!1;if($==="null"||$==="undefined")return null;if(/^-?\d+(\.\d+)?$/.test($))return Number($);if($.startsWith("'")&&$.endsWith("'")||$.startsWith('"')&&$.endsWith('"'))return $.slice(1,-1);if(J&&$.startsWith("$")){let U=$.indexOf(".");if(U>=0){let H=$.slice(0,U),W=$.slice(U+1),X=J[H];return w1(X,W)}return J[$]}if(J){let U=$.split(".")[0];if(U in J)return w1(J[U],$.includes(".")?$.slice(U.length+1):"")}return Z.get($)}function l4($,Z,J,q){let Q=$.indexOf(":"),Y=Q>=0?$.slice(0,Q).trim():$,U=Q>=0?$.slice(Q+1).trim():void 0,H=U?Q0(U):void 0;switch(Y){case"find":{if(!Array.isArray(Z)||!U)return;let W=m0(U);if(W.length<2)return;let X=Q0(W[0]),M=W[1].trim(),G;if(M.startsWith("'")&&M.endsWith("'")||M.startsWith('"')&&M.endsWith('"'))G=M.slice(1,-1);else if(J){if(q&&M.startsWith("$")){let _=M.indexOf(".");if(_>=0){let K=M.slice(0,_);if(K in q)G=w1(q[K],M.slice(_+1))}else if(M in q)G=q[M]}if(G===void 0&&!(q&&M.startsWith("$")))if(q){let _=M.split(".")[0];G=_ in q?w1(q[_],M.includes(".")?M.slice(_.length+1):""):J.get(M)}else G=J.get(M)}else G=M;if(G==null)return;let E=J?.generation??0;if(E!==b0)q0=new Map,b0=E;let z=q0.get(Z);if(!z)z=new Map,q0.set(Z,z);let F=z.get(X);if(!F){F=new Map;for(let _ of Z)if(_!=null&&typeof _==="object"){let K=_[X];if(K!=null)F.set(b(K),_)}z.set(X,F)}return F.get(b(G))}case"dot":{if(Z==null||typeof Z!=="object"||typeof H!=="string")return;return Z[H]}case"length":return Array.isArray(Z)?Z.length:typeof Z==="string"?Z.length:0;case"upper":return typeof Z==="string"?Z.toUpperCase():Z;case"lower":return typeof Z==="string"?Z.toLowerCase():Z;case"truncate":if(typeof Z==="string"&&typeof H==="number")return Z.slice(0,H);return Z;case"join":return Array.isArray(Z)?Z.join(typeof H==="string"?H:", "):Z;case"first":return Array.isArray(Z)?Z[0]:Z;case"last":return Array.isArray(Z)?Z[Z.length-1]:Z;case"abs":return Math.abs(Number(Z));case"round":return typeof H==="number"?Number(Number(Z).toFixed(H)):Math.round(Number(Z));case"number":return typeof H==="number"?Number(Number(Z).toFixed(H)):Number(Z);case"currency":{let W=typeof H==="string"?H:"USD";try{return new Intl.NumberFormat("en-US",{style:"currency",currency:W}).format(Number(Z))}catch{return Z}}case"percent":return typeof H==="number"?`${(Number(Z)*100).toFixed(H)}%`:`${Math.round(Number(Z)*100)}%`;case"compact":{let W=typeof H==="number"?H:1;try{return new Intl.NumberFormat("en-US",{notation:"compact",maximumFractionDigits:W}).format(Number(Z))}catch{return Z}}case"date":try{return new Date(Z).toLocaleDateString()}catch{return Z}case"time":try{return new Date(Z).toLocaleTimeString()}catch{return Z}case"datetime":try{return new Date(Z).toLocaleString()}catch{return Z}case"pluralize":{let W=Number(Z),X=typeof H==="string"?H:"";return W===1?X:`${X}s`}case"default":return Z==null||Z===""?H:Z;case"selectattr":return Array.isArray(Z)&&typeof H==="string"?Z.filter((W)=>W!=null&&typeof W==="object"&&Boolean(W[H])):Z;case"rejectattr":return Array.isArray(Z)&&typeof H==="string"?Z.filter((W)=>{if(W==null||typeof W!=="object")return!1;let X=W[H];return X==null||X===!1||X===0||X===""}):Z;default:{let W=f1(Y);if(W){let X=U?m0(U).map(Q0):[];return W(Z,...X)}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)]],s4=[[" + ",($,Z)=>$+Z],[" - ",($,Z)=>$-Z],[" * ",($,Z)=>$*Z],[" / ",($,Z)=>Z!==0?$/Z:0],[" % ",($,Z)=>Z!==0?$%Z:0]];function C1($,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 n4($){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 r4($){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 a4($){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 Q0($){let Z=$.replace(/^['"]|['"]$/g,"");if(Z==="true")return!0;if(Z==="false")return!1;let J=Number(Z);return isNaN(J)?Z:J}function m0($){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 w1($,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 o4($,Z){let J=0,q=0;while((q=$.indexOf(Z,q))!==-1)J++,q+=Z.length;return J}function b1($){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:b1(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 m($,Z){let J=Array.isArray($)?$:[$];for(let q of J)await t4(q,Z)}function v($,Z){$.catch((J)=>w.error(`${Z} failed:`,J))}async function h1($,Z,J,q){if(J!=null)w.debug(`${$} failed:`,Z),await W1(J,q,{$error:Z});else w.warn(`${$} failed:`,Z)}async function t4($,Z){let J=U0($),q=J.action;switch(q){case"setState":{e4(J,Z);return}case"toggleState":{$8(J,Z);return}case"appendState":{Z8(J,Z);return}case"popState":{J8(J,Z);return}case"showToast":{q8(J,Z);return}case"closeOverlay":{Q8(J,Z);return}case"openLink":{Y8(J);return}case"setInterval":{H8(J,Z);return}case"toolCall":case"callTool":return W8(J,Z);case"sendMessage":return G8(J,Z);case"updateContext":{X8(J,Z);return}case"fetch":return B8(J,Z);case"openFilePicker":{M8(J,Z);return}case"callHandler":return _8(J,Z);case"requestDisplayMode":{N8(J,Z);return}case"subscribe":{K8(J,Z);return}case"unsubscribe":{F8(J);return}default:w.warn(`Unknown action: ${q}`)}}function e4($,Z){let{key:J,value:q}=$;if(o(q))q=t(q,Z.store,Z.scope);Z.store.set(J,q),Z.rerender(),W1($.onSuccess,Z)}function $8($,Z){Z.store.toggle($.key),Z.rerender()}function Z8($,Z){let J=$.value??$.item;if(o(J))J=t(J,Z.store,Z.scope);Z.store.append($.key,J,$.index),Z.rerender()}function J8($,Z){Z.store.pop($.key,$.index),Z.rerender()}function q8($,Z){Z.onToast?.({message:m1($.message,Z),description:$.description!=null?m1($.description,Z):void 0,variant:$.variant,duration:$.duration})}function Q8($,Z){if(typeof document<"u")document.dispatchEvent(new CustomEvent("prefab:close-overlay"))}function Y8($){if(typeof window<"u"){let Z=$.url;if(!Z){w.warn("openLink: missing url");return}if(!u0(Z)){w.warn(`Blocked unsafe URL scheme: ${Z}`);return}window.open(Z,$.target??"_blank")}}var y1=new Set,U8=20,h0=100;function H8($,Z){let J=Math.max($.intervalMs,h0),q=$.onTick;if(typeof globalThis.setInterval!=="function")return;if(y1.size>=U8){w.warn("Max intervals reached, ignoring new setInterval");return}let Q=globalThis.setInterval(()=>v(m(q,Z),"interval action"),J);y1.add(Q)}function v0(){for(let $ of y1)globalThis.clearInterval($);y1.clear()}async function W8($,Z){if(!Z.transport){w.warn("No MCP transport configured for toolCall");return}let J=$.tool,q=H0($.arguments,Z);try{let Q=await Z.transport.callTool(J,q);if($.resultKey!=null)Z.store.set($.resultKey,Q);let Y=v1(Q);if(Y&&Z.remount)Z.remount(Y);else g1(Q,Z),Z.rerender();await W1($.onSuccess,Z,{$result:Q})}catch(Q){await h1("toolCall",Q,$.onError,Z)}}async function G8($,Z){if(!Z.transport){w.warn("No MCP transport configured for sendMessage");return}await Z.transport.sendMessage(m1($.message,Z))}function X8($,Z){let J=$.context;if(J!=null)Z.store.merge(J),Z.rerender()}async function B8($,Z){let J=m1($.url,Z);if(!u0(J)){w.warn(`Blocked unsafe URL in fetch: ${J}`);return}let q=$.method??"GET",Q=$.headers,Y=$.body!==void 0?JSON.stringify($.body):void 0;try{let U=await globalThis.fetch(J,{method:q,headers:{"Content-Type":"application/json",...Q},...Y&&{body:Y}}),H=await U.json().catch(()=>U.text());if($.resultKey!=null)Z.store.set($.resultKey,H);let W=v1(H);if(W&&Z.remount)Z.remount(W);else g1(H,Z),Z.rerender();await W1($.onSuccess,Z,{$result:H})}catch(U){await h1("fetch",U,$.onError,Z)}}function M8($,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(),W1($.onSuccess,Z,{$result:q})}),J.click()}async function _8($,Z){let J=$.handler,q=H0($.arguments,Z);if(!Z.transport){w.warn(`No transport configured for callHandler: ${J}`);return}try{let Q=await Z.transport.callTool(J,q);if($.resultKey!=null)Z.store.set($.resultKey,Q);let Y=v1(Q);if(Y&&Z.remount)Z.remount(Y);else g1(Q,Z),Z.rerender();await W1($.onSuccess,Z,{$result:Q})}catch(Q){await h1("callHandler",Q,$.onError,Z)}}function N8($,Z){if(typeof document<"u")document.dispatchEvent(new CustomEvent("prefab:request-display-mode",{detail:{mode:$.mode}}))}var Q1=new Map,E8=50,z8=2000;function K8($,Z){let{uri:J,stateKey:q}=$;if(!J||!q){w.warn("subscribe: missing uri or stateKey");return}if(Q1.has(J))return;if(Q1.size>=E8){w.warn("Max subscriptions reached, ignoring new subscribe");return}let Q=(G)=>{let E=v1(G);if(E&&Z.remount)Z.remount(E);else{if(!g1(G,Z))Z.store.set(q,G);Z.rerender()}W1($.onData,Z,{$data:G})};if(Z.transport?.subscribe&&Z.transport.capabilities?.subscriptions){let G=Z.transport.subscribe(J,Q);Q1.set(J,G);return}let Y=$.fallbackTool,U=$.fallbackInterval??z8;if(!Y){w.warn("subscribe: host lacks subscriptions and no fallbackTool specified");return}if(!Z.transport){w.warn("No MCP transport configured for subscribe fallback");return}let H=$.fallbackArgs??{},W=Math.max(U,h0),X=Z.transport,M=globalThis.setInterval(()=>{(async()=>{try{let G=H0(H,Z),E=await X.callTool(Y,G);Q(E)}catch(G){h1("subscribe",G,$.onError,Z)}})()},W);Q1.set(J,()=>globalThis.clearInterval(M))}function F8($){let Z=$.uri;if(!Z){w.warn("unsubscribe: missing uri");return}let J=Q1.get(Z);if(J)J(),Q1.delete(Z)}function g0(){for(let[$,Z]of Q1)try{Z()}catch(J){w.warn(`Error cleaning up subscription '${$}':`,J)}Q1.clear()}function v1($){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 D8($){if($==null||typeof $!=="object")return null;let Z=$;if(Y0(Z))return Z;if("structuredContent"in Z){let J=Z.structuredContent;if(J!=null&&typeof J==="object"&&Y0(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"&&Y0(q))return q}catch{}}return null}function Y0($){if(!("$prefab"in $)||!("update"in $))return!1;let Z=$.update;return Z!=null&&typeof Z==="object"&&"state"in Z}function g1($,Z){let J=D8($);if(!J)return!1;let q=J.update;if(Z.store.merge(q.state),q.actions!=null)v(m(q.actions,Z),"update action");return!0}var L8=/^\s*(javascript|vbscript|data):/i;function u0($){return!L8.test($)}function m1($,Z){if(o($)){let J=t($,Z.store,Z.scope);return b(J)}return b($)}function H0($,Z){if(!$)return{};let J={};for(let[q,Q]of Object.entries($))J[q]=o(Q)?t(Q,Z.store,Z.scope):Q;return J}async function W1($,Z,J){if($==null)return;let q={...Z.scope,...J};await m($,{...Z,scope:q})}function G0($){let Z={};for(let[J,q]of Object.entries($)){let Q=J.startsWith("$")?J:b1(J);if(Array.isArray(q))Z[Q]=q.map((Y)=>Y!=null&&typeof Y==="object"&&!Array.isArray(Y)?G0(Y):Y);else if(q!=null&&typeof q==="object"&&!Array.isArray(q))Z[Q]=G0(q);else Z[Q]=q}return Z}class I1{callbacks=[];track($){this.callbacks.push($)}flush(){for(let $ of this.callbacks)try{$()}catch(Z){w.warn("destroy callback error:",Z)}this.callbacks=[]}get size(){return this.callbacks.length}}function T8($){return typeof $==="object"&&"element"in $}var X0=new Map;function B($,Z){if(X0.has($))w.warn(`overriding existing renderer for "${$}"`);X0.set($,Z)}function u($,Z){let J=G0($);if(Z.defs?.[J.type]){let Y={...Z.defs[J.type],...J,type:Z.defs[J.type].type};return u(Y,Z)}let q=X0.get(J.type),Q;if(q){let Y=q(J,Z);if(T8(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=D(J.cssClass,Z);if(Y)Q.className=(Q.className?Q.className+" ":"")+Y}if(J.onClick!=null){if(Q.addEventListener("click",()=>{v(m(J.onClick,d(Z)),"onClick")}),Q.tagName!=="BUTTON"&&Q.tagName!=="A")Q.setAttribute("role","button"),Q.setAttribute("tabindex","0"),Q.addEventListener("keydown",(Y)=>{let U=Y.key;if(U==="Enter"||U===" ")Y.preventDefault(),v(m(J.onClick,d(Z)),"onClick")})}}if(J.onMount){let Y=J.onMount,U=d(Z);queueMicrotask(()=>v(m(Y,U),"onMount"))}return Q}function C($,Z,J){if(!$.children)return;Y1($.children,Z,J)}function Y1($,Z,J){let q=0;while(q<$.length){let Q=$[q];if(Q.type==="If")q=O8($,q,Z,J);else if(Q.type==="Elif"||Q.type==="Else")q++;else Z.appendChild(u(Q,J)),q++}}function O8($,Z,J,q){let Q=!1,Y=Z,U=$[Y];if(x0(U.condition,q))W0(U,J,q),Q=!0;Y++;while(Y<$.length){let H=$[Y];if(H.type==="Elif"){if(!Q&&x0(H.condition,q))W0(H,J,q),Q=!0;Y++}else if(H.type==="Else"){if(!Q)W0(H,J,q);Y++;break}else break}return Y}function x0($,Z){if(!$)return!1;if(o($))return Boolean(t($,Z.store,Z.scope));return Boolean(Z.store.get($))}function W0($,Z,J){if(!$.children)return;Y1($.children,Z,J)}function D($,Z){if(o($)){let J=t($,Z.store,Z.scope);return b(J)}return b($)}function l($,Z){if(o($))return t($,Z.store,Z.scope);return $}function d($){return{store:$.store,transport:$.transport,scope:$.scope,rerender:$.rerender,onToast:$.onToast,remount:$.remount}}function N($,Z){let J=document.createElement($);if(Z)J.className=Z;return J}function B0($,Z){return $.textContent=Z,$}function l0(){B("Column",I8),B("Row",P8),B("Grid",c0),B("GridItem",p0),B("Container",R8),B("Div",d0),B("Span",V8),B("Dashboard",c0),B("DashboardItem",p0),B("Pages",j8),B("Page",d0),B("Detail",k8),B("MasterDetail",A8)}function I8($,Z){let J=N("div","pf-column");J.style.display="flex",J.style.flexDirection="column";let q=u1($);if(q!=null)J.style.gap=`${q*4}px`;if($.align!=null)J.style.alignItems=i0($.align);if($.justify!=null)J.style.justifyContent=s0($.justify);return C($,J,Z),J}function P8($,Z){let J=N("div","pf-row");J.style.display="flex",J.style.flexDirection="row";let q=u1($);if(q!=null)J.style.gap=`${q*4}px`;if($.align!=null)J.style.alignItems=i0($.align);if($.justify!=null)J.style.justifyContent=s0($.justify);if($.wrap===!0)J.style.flexWrap="wrap";return C($,J,Z),J}function c0($,Z){let J=N("div","pf-grid");J.style.display="grid";let q=$.columns??3;J.style.gridTemplateColumns=`repeat(${q}, 1fr)`;let Q=u1($);if(Q!=null)J.style.gap=`${Q*4}px`;return C($,J,Z),J}function p0($,Z){let J=N("div","pf-grid-item");if($.colSpan!=null)J.style.gridColumn=`span ${$.colSpan}`;if($.rowSpan!=null)J.style.gridRow=`span ${$.rowSpan}`;return C($,J,Z),J}function R8($,Z){let J=N("div","pf-container");if(J.style.maxWidth=$.maxWidth??"1200px",J.style.margin="0 auto",$.padding!=null)J.style.padding=`${$.padding*4}px`;return C($,J,Z),J}function d0($,Z){let J=N("div","pf-div");return C($,J,Z),J}function V8($,Z){let J=N("span","pf-span");return C($,J,Z),J}function j8($,Z){let J=N("div","pf-pages");return C($,J,Z),J}function k8($,Z){let J=N("div","pf-detail"),q=$.of!=null?l($.of,Z):void 0;if(q!=null&&q!==""&&q!==!1&&q!==0)C($,J,Z);else if($.empty!=null){let Q=$.empty;J.appendChild(u(Q,Z))}return J}function A8($,Z){let J=N("div","pf-master-detail");J.style.display="flex",J.style.flexDirection="row";let q=u1($);if(q!=null)J.style.gap=`${q*4}px`;let Q=$.masterWidth??"33%",Y=$.children??[];if(Y.length>0){let U=N("div","pf-master-detail-master");U.style.width=Q,U.style.flexShrink="0",U.style.overflow="auto",U.appendChild(u(Y[0],Z)),J.appendChild(U)}if(Y.length>1){let U=N("div","pf-master-detail-detail");U.style.flex="1",U.style.overflow="auto",U.appendChild(u(Y[1],Z)),J.appendChild(U)}return J}var S8=/\bgap-(\d+)\b/;function u1($){if($.gap!=null)return $.gap;if(typeof $.cssClass==="string"){let Z=S8.exec($.cssClass);if(Z)return Number(Z[1])}return null}function i0($){return{start:"flex-start",end:"flex-end",center:"center",stretch:"stretch",baseline:"baseline"}[$]??$}function s0($){return{start:"flex-start",end:"flex-end",center:"center",between:"space-between",around:"space-around",evenly:"space-evenly"}[$]??$}var f8={"&":"&","<":"<",">":">",'"':""","'":"'"};function P1($){return $.replace(/[&<>"']/g,(Z)=>f8[Z]??Z)}function r0(){B("Heading",C8),B("H1",($,Z)=>x1($,Z,"h1")),B("H2",($,Z)=>x1($,Z,"h2")),B("H3",($,Z)=>x1($,Z,"h3")),B("H4",($,Z)=>x1($,Z,"h4")),B("Text",w8),B("P",b8),B("Lead",($,Z)=>E1($,Z,"p","pf-lead")),B("Large",($,Z)=>E1($,Z,"span","pf-large")),B("Small",($,Z)=>E1($,Z,"small","pf-small")),B("Muted",($,Z)=>E1($,Z,"p","pf-muted")),B("BlockQuote",($,Z)=>E1($,Z,"blockquote","pf-blockquote")),B("Label",($,Z)=>E1($,Z,"label","pf-label")),B("Link",m8),B("Code",h8),B("Markdown",v8),B("Kbd",g8)}function C8($,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=D($.content,Z),Q}function x1($,Z,J){let q=document.createElement(J);return q.className=`pf-heading pf-${J}`,q.textContent=D($.content,Z),q}function w8($,Z){return B0(N("span","pf-text"),D($.content,Z))}function b8($,Z){return B0(N("p","pf-p"),D($.content,Z))}function E1($,Z,J,q){let Q=document.createElement(J);return Q.className=q,Q.textContent=D($.content,Z),Q}var y8=/^\s*(javascript|vbscript|data):/i;function m8($,Z){let J=document.createElement("a");if(J.className="pf-link",J.textContent=D($.content,Z),$.href!=null){let q=D($.href,Z);if(!y8.test(q))J.href=q}if($.target!=null)J.target=D($.target,Z);return J}function h8($,Z){let J=N("pre","pf-code"),q=N("code");if(q.textContent=D($.content,Z),$.language!=null)q.setAttribute("data-language",$.language);return J.appendChild(q),J}function v8($,Z){let J=N("div","pf-markdown"),q=D($.content,Z);return J.innerHTML=a0(q),J.setAttribute("data-markdown","true"),J}var n0=/^\s*(javascript|vbscript|data):/i;function c1($){let Z=P1($),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(n0.test(Y))return P1(Q);return`<img src="${Y}" alt="${Q}" />`}),Z=Z.replace(/\[([^\]]+)\]\(([^)]+)\)/g,(q,Q,Y)=>{if(n0.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 a0($){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
|
|
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
|
|
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 y4($,Z){let J=document.createElement("kbd");return J.className="pf-kbd",J.textContent=L($.content,Z),J}function o0(){G("Card",m4),G("CardHeader",B0("pf-card-header")),G("CardTitle",a0("pf-card-title","h3")),G("CardDescription",a0("pf-card-description","p")),G("CardContent",B0("pf-card-content")),G("CardFooter",B0("pf-card-footer"))}function m4($,Z){let J=N("div","pf-card");return J.style.overflow="hidden",w($,J,Z),J}function B0($){return(Z,J)=>{let q=N("div",$);return q.style.padding="16px 24px",w(Z,q,J),q}}function a0($,Z){return(J,q)=>{let Q=document.createElement(Z);return Q.className=$,Q.textContent=L(J.content,q),Q}}function t0(){G("DataTable",h4),G("Badge",v4),G("Dot",g4),G("Metric",u4),G("Ring",x4),G("Progress",p4),G("Separator",c4),G("Loader",d4),G("Icon",l4),G("Sparkline",i4)}function h4($,Z){let J=N("div","pf-datatable-wrapper"),q=document.createElement("table");q.className="pf-datatable",q.style.width="100%",q.style.borderCollapse="collapse";let Q=$.columns??[],Y=d($.rows,Z),U=$.rowKey,W=$.selected,H=document.createElement("thead"),_=document.createElement("tr");for(let X of Q){let B=document.createElement("th");B.className="pf-datatable-th",B.textContent=X.header??X.key,B.style.padding="8px 12px",B.style.textAlign="left",_.appendChild(B)}H.appendChild(_),q.appendChild(H);let z=document.createElement("tbody");if(Array.isArray(Y)){let X=W!=null?d(W,Z):void 0;for(let B of Y){let K=document.createElement("tr");K.className="pf-datatable-row";let F=B,M=B===null||typeof B!=="object";if(U&&X!=null&&F[U]!=null&&b(F[U])===b(X))K.classList.add("pf-datatable-row-selected");if($.onRowClick!=null&&U)K.style.cursor="pointer",K.addEventListener("click",()=>{let E={...Z.scope,$item:F,$index:Y.indexOf(B)},O=l({...Z,scope:E});v(h($.onRowClick,O),"onRowClick")});for(let E of Q){let O=document.createElement("td");O.className="pf-datatable-td";let P;if(E.accessor)P=d(`{{ $item.${E.accessor} }}`,{...Z,scope:{...Z.scope,$item:F}});else if(P=M?B:F[E.key],E.format&&P!=null)P=d(`{{ __fmtVal | ${E.format} }}`,{...Z,scope:{...Z.scope,__fmtVal:P}});O.textContent=b(P),O.style.padding="8px 12px",K.appendChild(O)}z.appendChild(K)}}if(q.appendChild(z),$.search===!0){let X=document.createElement("input");X.type="text",X.placeholder="Search...",X.className="pf-datatable-search",X.style.marginBottom="8px",X.style.padding="6px 12px",X.style.width="100%",X.style.boxSizing="border-box",X.addEventListener("input",()=>{let B=X.value.toLowerCase(),K=Array.from(z.querySelectorAll("tr"));for(let F of K){let M=(F.textContent??"").toLowerCase();F.style.display=M.includes(B)?"":"none"}}),J.appendChild(X)}return J.appendChild(q),J}function v4($,Z){let J=N("span","pf-badge"),q=$.variant??"default";return J.setAttribute("data-variant",q),J.style.alignItems="center",J.style.padding="2px 10px",J.style.borderRadius="9999px",J.style.fontSize="12px",J.style.fontWeight="500",J.textContent=L($.label??$.content,Z),s4(J,q),J}function g4($,Z){let J=N("span","pf-dot"),q=$.color??"gray";return J.style.display="inline-block",J.style.width="8px",J.style.height="8px",J.style.borderRadius="50%",J.style.backgroundColor=q,J}function u4($,Z){let J=N("div","pf-metric"),q=N("div","pf-metric-label");q.textContent=L($.label,Z),q.style.fontSize="14px",J.appendChild(q);let Q=N("div","pf-metric-value");if(Q.textContent=L($.value,Z),Q.style.fontSize="28px",Q.style.fontWeight="700",J.appendChild(Q),$.delta!=null){let Y=N("span","pf-metric-delta");Y.textContent=L($.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=N("div","pf-metric-desc");Y.textContent=L($.description,Z),Y.style.fontSize="12px",J.appendChild(Y)}return J}function x4($,Z){let J=N("div","pf-ring"),q=$.size??80,Q=$.thickness??8,Y=Number(d($.value,Z)??0),U=Math.max(0,Math.min(100,Y)),W=(q-Q)/2,H=2*Math.PI*W,_=H*(1-U/100),z=document.createElementNS("http://www.w3.org/2000/svg","svg");z.setAttribute("width",String(q)),z.setAttribute("height",String(q)),z.setAttribute("viewBox",`0 0 ${q} ${q}`);let X=document.createElementNS("http://www.w3.org/2000/svg","circle");X.setAttribute("cx",String(q/2)),X.setAttribute("cy",String(q/2)),X.setAttribute("r",String(W)),X.setAttribute("fill","none"),X.setAttribute("stroke","var(--muted, #e5e7eb)"),X.setAttribute("stroke-width",String(Q));let B=document.createElementNS("http://www.w3.org/2000/svg","circle");if(B.setAttribute("cx",String(q/2)),B.setAttribute("cy",String(q/2)),B.setAttribute("r",String(W)),B.setAttribute("fill","none"),B.setAttribute("stroke","var(--primary, #3b82f6)"),B.setAttribute("stroke-width",String(Q)),B.setAttribute("stroke-dasharray",String(H)),B.setAttribute("stroke-dashoffset",String(_)),B.setAttribute("stroke-linecap","round"),B.style.transform="rotate(-90deg)",B.style.transformOrigin="center",z.appendChild(X),z.appendChild(B),J.appendChild(z),$.label!=null){let K=N("div","pf-ring-label");K.textContent=L($.label,Z),K.style.textAlign="center",K.style.fontSize="12px",J.appendChild(K)}return J}function p4($,Z){let J=N("div","pf-progress");J.setAttribute("role","progressbar");let q=Number(d($.value,Z)??0),Q=$.max??100,Y=Q>0?Math.max(0,Math.min(100,q/Q*100)):0;J.setAttribute("aria-valuenow",String(q)),J.setAttribute("aria-valuemin","0"),J.setAttribute("aria-valuemax",String(Q)),J.style.height="8px",J.style.borderRadius="4px",J.style.overflow="hidden";let U=N("div","pf-progress-fill");return U.style.height="100%",U.style.width=`${Y}%`,U.style.borderRadius="4px",U.style.transition="width 0.3s ease",J.appendChild(U),J}function c4($,Z){let J=document.createElement("hr");return J.className="pf-separator",J.style.border="none",J.style.margin="8px 0",J}function d4($,Z){let J=N("div","pf-loader");return J.textContent="⏳",J.style.display="flex",J.style.justifyContent="center",J.style.padding="16px",J}function l4($,Z){let J=N("span","pf-icon");return J.setAttribute("data-icon",L($.name??$.content,Z)),J}function i4($,Z){let J=N("div","pf-sparkline"),q=$.data??[];if(q.length===0)return J;let Q=120,Y=32,U=Math.max(...q),W=Math.min(...q),H=U-W||1,_=document.createElementNS("http://www.w3.org/2000/svg","svg");_.setAttribute("width",String(Q)),_.setAttribute("height",String(Y)),_.setAttribute("viewBox",`0 0 ${Q} ${Y}`);let z=q.length>1?q.length-1:1,X=q.map((K,F)=>{let M=F/z*Q,E=Y-(K-W)/H*(Y-4)-2;return`${M},${E}`}).join(" "),B=document.createElementNS("http://www.w3.org/2000/svg","polyline");return B.setAttribute("points",X),B.setAttribute("fill","none"),B.setAttribute("stroke","var(--primary, #3b82f6)"),B.setAttribute("stroke-width","1.5"),_.appendChild(B),J.appendChild(_),J}function s4($,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 $8(){G("Form",n4),G("Input",r4),G("Textarea",a4),G("Button",o4),G("ButtonGroup",t4),G("Select",e4),G("SelectOption",$6),G("SelectGroup",p1("pf-select-group")),G("SelectLabel",P1("pf-select-label")),G("SelectSeparator",e0),G("Checkbox",Z6),G("Switch",J6),G("Slider",q6),G("Radio",Y6),G("RadioGroup",U6),G("Combobox",W6),G("ComboboxOption",H6),G("ComboboxGroup",p1("pf-combobox-group")),G("ComboboxLabel",P1("pf-combobox-label")),G("ComboboxSeparator",e0),G("Calendar",X6),G("DatePicker",G6),G("Field",p1("pf-field")),G("FieldTitle",P1("pf-field-title")),G("FieldDescription",P1("pf-field-description")),G("FieldContent",p1("pf-field-content")),G("FieldError",P1("pf-field-error")),G("ChoiceCard",B6)}function n4($,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=l(Z);U.scope={...Z.scope,...Y},v(h($.onSubmit,U),"onSubmit")}}),w($,J,Z),J}function r4($,Z){let J=N("div","pf-input-wrapper");if(J.style.display="flex",J.style.flexDirection="column",J.style.gap="4px",$.label!=null){let Y=document.createElement("label");if(Y.className="pf-input-label",Y.textContent=L($.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=L($.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=b(Y);q.addEventListener("input",()=>{if(Z.store.set(Q,q.value),$.onChange!=null)v(h($.onChange,{...l(Z),scope:{...Z.scope,$event:q.value}}),"onChange")})}return M0(q),J.appendChild(q),J}function a4($,Z){let J=N("div","pf-textarea-wrapper"),q=document.createElement("textarea");if(q.className="pf-textarea",$.name!=null)q.name=$.name;if($.name!=null)q.id=`pf-textarea-${$.name}`;if($.placeholder!=null)q.placeholder=L($.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=b(Y);q.addEventListener("input",()=>{if(Z.store.set(Q,q.value),$.onChange!=null)v(h($.onChange,{...l(Z),scope:{...Z.scope,$event:q.value}}),"onChange")})}return M0(q),J.appendChild(q),J}function o4($,Z){let J=document.createElement("button");J.className="pf-button",J.type=$.submit===!0?"submit":"button",J.textContent=L($.label,Z);let q=$.variant??"default";if(J.setAttribute("data-variant",q),Q6(J,q),$.size!=null)J.setAttribute("data-size",$.size);if($.disabled===!0)J.disabled=!0;return J}function t4($,Z){let J=N("div","pf-button-group");return J.style.display="flex",J.style.gap="8px",w($,J,Z),J}function e4($,Z){let J=N("div","pf-select-wrapper"),q=document.createElement("select");if(q.className="pf-select",$.name!=null)q.name=$.name;if(M0(q),$.placeholder!=null){let U=document.createElement("option");U.value="",U.textContent=L($.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=b(U);q.addEventListener("change",()=>{if(Z.store.set(Y,q.value),$.onChange!=null)v(h($.onChange,{...l(Z),scope:{...Z.scope,$event:q.value}}),"onChange")})}return J.appendChild(q),J}function $6($,Z){return N("span")}function Z6($,Z){let J=N("label","pf-checkbox-wrapper");J.style.display="flex",J.style.alignItems="center",J.style.gap="8px",J.style.cursor="pointer";let q=document.createElement("input");if(q.type="checkbox",q.className="pf-checkbox",$.name!=null)q.name=$.name;if($.checked===!0)q.checked=!0;let Q=$.name;if(Q){let Y=Z.store.get(Q);if(typeof Y==="boolean")q.checked=Y;q.addEventListener("change",()=>{if(Z.store.set(Q,q.checked),$.onChange!=null)v(h($.onChange,{...l(Z),scope:{...Z.scope,$event:q.checked}}),"onChange")})}if(J.appendChild(q),$.label!=null){let Y=N("span");Y.textContent=L($.label,Z),J.appendChild(Y)}return J}function J6($,Z){let J=N("label","pf-switch-wrapper");J.style.display="flex",J.style.alignItems="center",J.style.gap="8px",J.style.cursor="pointer";let q=document.createElement("input");if(q.type="checkbox",q.className="pf-switch",q.setAttribute("role","switch"),$.name!=null)q.name=$.name;let Q=$.name;if(Q){let Y=Z.store.get(Q);if(typeof Y==="boolean")q.checked=Y;q.addEventListener("change",()=>{if(Z.store.set(Q,q.checked),$.onChange!=null)v(h($.onChange,{...l(Z),scope:{...Z.scope,$event:q.checked}}),"onChange")})}if(J.appendChild(q),$.label!=null){let Y=N("span");Y.textContent=L($.label,Z),J.appendChild(Y)}return J}function q6($,Z){let J=N("div","pf-slider-wrapper"),q=document.createElement("input");if(q.type="range",q.className="pf-slider",$.name!=null)q.name=$.name;if($.min!=null)q.min=b($.min);if($.max!=null)q.max=b($.max);if($.step!=null)q.step=b($.step);let Q=$.name;if(Q){let Y=Z.store.get(Q);if(Y!=null)q.value=b(Y);q.addEventListener("input",()=>{if(Z.store.set(Q,Number(q.value)),$.onChange!=null)v(h($.onChange,{...l(Z),scope:{...Z.scope,$event:Number(q.value)}}),"onChange")})}return J.appendChild(q),J}function M0($){$.style.padding="8px 12px",$.style.fontSize="14px",$.style.width="100%",$.style.boxSizing="border-box"}function Q6($,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 p1($){return(Z,J)=>{let q=N("div",$);return w(Z,q,J),q}}function P1($){return(Z,J)=>{let q=N("span",$);return q.textContent=L(Z.content,J),q}}function e0(){let $=document.createElement("hr");return $.className="pf-separator",$.style.border="none",$.style.margin="4px 0",$}function Y6($,Z){let J=N("label","pf-radio");J.style.display="flex",J.style.alignItems="center",J.style.gap="8px",J.style.cursor="pointer";let q=document.createElement("input");if(q.type="radio",q.value=L($.value,Z),J.appendChild(q),$.label!=null){let Q=N("span","pf-radio-label");Q.textContent=L($.label,Z),J.appendChild(Q)}return J}function U6($,Z){let J=N("fieldset","pf-radio-group");if(J.style.border="none",J.style.padding="0",J.style.display="flex",J.style.flexDirection="column",J.style.gap="8px",$.label!=null){let Y=document.createElement("legend");Y.textContent=L($.label,Z),Y.style.fontWeight="500",Y.style.marginBottom="4px",J.appendChild(Y)}w($,J,Z);let q=L($.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===b(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)v(h($.onChange,l(Z)),"onChange")}}),J}function W6($,Z){let J=N("div","pf-combobox"),q=document.createElement("input");if(q.className="pf-combobox-input",q.type="text",q.name=L($.name,Z),$.placeholder!=null)q.placeholder=L($.placeholder,Z);if($.value!==void 0)q.value=L($.value,Z);let Q=q.name,Y=Z.store.get(Q);if(Y!=null)q.value=b(Y);q.style.padding="6px 12px",q.style.borderRadius="6px",q.style.width="100%",q.style.boxSizing="border-box";let U=N("div","pf-combobox-dropdown");if(U.style.display="none",U.style.position="absolute",U.style.borderRadius="6px",U.style.maxHeight="200px",U.style.overflowY="auto",U.style.zIndex="50",w($,U,Z),q.addEventListener("focus",()=>{U.style.display="block"}),q.addEventListener("blur",()=>{setTimeout(()=>{U.style.display="none"},150)}),$.searchable!==!1)q.addEventListener("input",()=>{let W=q.value.toLowerCase();for(let H of Array.from(U.querySelectorAll(".pf-combobox-option"))){let _=(H.textContent??"").toLowerCase();H.style.display=_.includes(W)?"":"none"}});if($.onChange!=null)J.addEventListener("pf-combobox-select",()=>{v(h($.onChange,{...l(Z),scope:{...Z.scope,$event:q.value}}),"onChange")});return J.style.position="relative",J.appendChild(q),J.appendChild(U),J}function H6($,Z){let J=N("div","pf-combobox-option");return J.style.padding="6px 12px",J.style.cursor="pointer",J.textContent=L($.label??$.value,Z),J.dataset.value=L($.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 X6($,Z){let J=N("div","pf-calendar"),q=document.createElement("input");if(q.type="date",q.name=L($.name,Z),$.value!==void 0)q.value=L($.value,Z);let Q=q.name,Y=Z.store.get(Q);if(Y!=null)q.value=b(Y);if($.minDate!=null)q.min=L($.minDate,Z);if($.maxDate!=null)q.max=L($.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)v(h($.onChange,l(Z)),"onChange")}),J.appendChild(q),J}function G6($,Z){let J=N("div","pf-datepicker"),q=document.createElement("input");if(q.type="date",q.name=L($.name,Z),$.placeholder!=null)q.placeholder=L($.placeholder,Z);if($.value!==void 0)q.value=L($.value,Z);let Q=q.name,Y=Z.store.get(Q);if(Y!=null)q.value=b(Y);if($.minDate!=null)q.min=L($.minDate,Z);if($.maxDate!=null)q.max=L($.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)v(h($.onChange,l(Z)),"onChange")}),J.appendChild(q),J}function B6($,Z){let J=N("div","pf-choice-card");if(J.style.padding="16px",J.style.cursor="pointer",J.style.transition="border-color 0.2s",J.dataset.value=L($.value,Z),$.selected===!0)J.dataset.selected="true";if($.label!=null){let q=N("div","pf-choice-card-label");q.textContent=L($.label,Z),q.style.fontWeight="600",J.appendChild(q)}if($.description!=null){let q=N("div","pf-choice-card-description");q.textContent=L($.description,Z),q.style.fontSize="14px",J.appendChild(q)}return w($,J,Z),J}function Z8(){G("Tabs",M6),G("Tab",_6),G("Accordion",N6),G("AccordionItem",z6),G("Dialog",E6),G("Popover",K6),G("Tooltip",L6),G("HoverCard",F6),G("Carousel",D6)}function M6($,Z){let J=N("div","pf-tabs"),q=N("div","pf-tabs-bar");q.setAttribute("role","tablist"),q.style.display="flex",q.style.gap="4px",q.style.marginBottom="12px";let Q=[],Y=[];if($.children)for(let W=0;W<$.children.length;W++){let H=$.children[W],_=`pf-tab-${Math.random().toString(36).slice(2,8)}`,z=`pf-panel-${Math.random().toString(36).slice(2,8)}`,X=document.createElement("button");X.type="button",X.className="pf-tab-trigger",X.textContent=H.title??`Tab ${W+1}`,X.setAttribute("role","tab"),X.setAttribute("aria-selected",W===0?"true":"false"),X.setAttribute("aria-controls",z),X.id=_,X.tabIndex=W===0?0:-1,X.style.padding="8px 16px",X.style.border="none",X.style.background="none",X.style.cursor="pointer",X.style.borderBottom="2px solid transparent",X.style.marginBottom="-2px",X.style.fontSize="14px";let B=N("div","pf-tab-panel");if(B.style.display=W===0?"block":"none",B.setAttribute("role","tabpanel"),B.setAttribute("aria-labelledby",_),B.id=z,B.tabIndex=0,w(H,B,Z),X.addEventListener("click",()=>{U(W)}),W===0)X.classList.add("pf-tab-active"),X.style.fontWeight="600";Y.push(X),Q.push(B),q.appendChild(X)}function U(W){Q.forEach((H)=>H.style.display="none"),Y.forEach((H)=>{H.style.borderBottomColor="transparent",H.style.fontWeight="normal",H.classList.remove("pf-tab-active"),H.setAttribute("aria-selected","false"),H.tabIndex=-1}),Q[W].style.display="block",Y[W].classList.add("pf-tab-active"),Y[W].style.fontWeight="600",Y[W].setAttribute("aria-selected","true"),Y[W].tabIndex=0,Y[W].focus()}q.addEventListener("keydown",(W)=>{let H=Y.indexOf(W.target);if(H<0)return;let _;if(W.key==="ArrowRight")_=(H+1)%Y.length;else if(W.key==="ArrowLeft")_=(H-1+Y.length)%Y.length;else if(W.key==="Home")_=0;else if(W.key==="End")_=Y.length-1;else return;W.preventDefault(),U(_)}),J.appendChild(q);for(let W of Q)J.appendChild(W);return J}function _6($,Z){let J=N("div","pf-tab");return w($,J,Z),J}function N6($,Z){let J=N("div","pf-accordion");return w($,J,Z),J}function z6($,Z){let J=N("div","pf-accordion-item"),q=`pf-acc-${Math.random().toString(36).slice(2,8)}`,Q=document.createElement("button");Q.type="button",Q.className="pf-accordion-trigger",Q.textContent=$.title??"",Q.setAttribute("aria-expanded","false"),Q.setAttribute("aria-controls",q),Q.style.width="100%",Q.style.textAlign="left",Q.style.padding="12px 0",Q.style.border="none",Q.style.background="none",Q.style.cursor="pointer",Q.style.fontSize="14px",Q.style.fontWeight="500";let Y=N("div","pf-accordion-content");return Y.id=q,Y.setAttribute("role","region"),Y.setAttribute("aria-labelledby",Q.id),Y.style.display="none",Y.style.paddingBottom="12px",w($,Y,Z),Q.addEventListener("click",()=>{let U=Y.style.display!=="none";Y.style.display=U?"none":"block",Q.setAttribute("aria-expanded",U?"false":"true")}),J.appendChild(Q),J.appendChild(Y),J}function E6($,Z){let J=N("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=N("h2","pf-dialog-title");Y.textContent=L($.title,Z),Y.id=`pf-dialog-title-${Math.random().toString(36).slice(2,8)}`,q.setAttribute("aria-labelledby",Y.id),q.appendChild(Y)}if($.description!=null){let Y=N("p","pf-dialog-desc");Y.textContent=L($.description,Z),q.appendChild(Y)}let Q=N("div","pf-dialog-body");if(w($,Q,Z),q.appendChild(Q),$.dismissible!==!1)q.addEventListener("click",(Y)=>{if(Y.target===q)q.close()});return document.addEventListener("prefab:close-overlay",()=>q.close()),J.appendChild(q),J}function K6($,Z){let J=N("div","pf-popover");J.style.position="relative",J.style.display="inline-block";let q=N("div","pf-popover-content");if(q.style.display="none",q.style.position="absolute",q.style.zIndex="50",q.style.padding="12px",q.style.boxShadow="0 4px 6px -1px rgb(0 0 0 / 0.1)",$.title!=null){let Y=N("div","pf-popover-title");Y.textContent=L($.title,Z),Y.style.fontWeight="600",Y.style.marginBottom="4px",q.appendChild(Y)}w($,q,Z);let Q=()=>{q.style.display=q.style.display==="none"?"block":"none"};if($.trigger!=null){let Y=u($.trigger,Z);Y.addEventListener("click",(U)=>{U.stopPropagation(),Q()}),J.appendChild(Y)}else J.addEventListener("click",(Y)=>{if(q.contains(Y.target)&&q.style.display!=="none")return;Q()});return J.appendChild(q),J}function L6($,Z){let J=N("div","pf-tooltip");J.style.position="relative",J.style.display="inline-block";let q=`pf-tip-${Math.random().toString(36).slice(2,8)}`,Q=N("div","pf-tooltip-content");return Q.id=q,Q.setAttribute("role","tooltip"),Q.textContent=L($.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 F6($,Z){let J=N("div","pf-hover-card");J.style.position="relative",J.style.display="inline-block";let q=N("div","pf-hover-card-content");if(q.style.display="none",q.style.position="absolute",q.style.zIndex="50",q.style.padding="16px",q.style.boxShadow="0 4px 6px -1px rgb(0 0 0 / 0.1)",q.style.minWidth="200px",$.trigger!=null)J.appendChild(u($.trigger,Z));return w($,q,Z),J.addEventListener("mouseenter",()=>{q.style.display="block"}),J.addEventListener("mouseleave",()=>{q.style.display="none"}),J.appendChild(q),J}function D6($,Z){let J=N("div","pf-carousel");J.style.position="relative",J.style.overflow="hidden",J.setAttribute("role","region"),J.setAttribute("aria-roledescription","carousel"),J.setAttribute("aria-label",L($.label??"Carousel",Z));let q=N("div","pf-carousel-track");q.style.display="flex",q.style.transition="transform 0.3s ease",w($,q,Z);let Q=0,Y=$.children?.length??0,U=document.createElement("button");U.type="button",U.textContent="‹",U.className="pf-carousel-prev",U.setAttribute("aria-label","Previous slide"),U.style.position="absolute",U.style.left="4px",U.style.top="50%",U.style.transform="translateY(-50%)",U.style.zIndex="10";let 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 J8(){G("ForEach",O6),G("If",q8),G("Elif",T6),G("Else",I6),G("Condition",P6),G("Define",V6),G("Use",R6),G("Slot",j6)}function O6($,Z){let J=document.createDocumentFragment(),q=$.expression;if(!q)return J;let Q;if(o(q)){let U=t(q,Z.store,Z.scope);Q=Array.isArray(U)?U:[]}else{let U=Z.store.get(q);Q=Array.isArray(U)?U:[]}let Y=$.let??{};for(let U=0;U<Q.length;U++){let W=Q[U],H={...Z.scope,$item:W,$index:U,...Y},_={...Z,scope:H};if($.children)Y1($.children,J,_)}return J}function q8($,Z){if(Q8($.condition,Z)){let q=document.createDocumentFragment();if($.children)Y1($.children,q,Z);return q}return document.createDocumentFragment()}function T6($,Z){return q8($,Z)}function I6($,Z){let J=document.createDocumentFragment();if($.children)Y1($.children,J,Z);return J}function Q8($,Z){if(!$)return!1;if(o($))return Boolean(t($,Z.store,Z.scope));return Boolean(Z.store.get($))}function P6($,Z){let J=document.createDocumentFragment(),q=$.cases,Q=$.else;if(q){for(let Y of q)if(Q8(Y.when,Z)){if(Y.children)Y1(Y.children,J,Z);return J}}if(Q)Y1(Q,J,Z);return J}function V6($,Z){let J=$.name;if(J&&$.children)Z.templates=Z.templates??{},Z.templates[J]=$.children;return document.createDocumentFragment()}function R6($,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.slots??{},...$.slots??{}};if(Array.isArray($.children))W.default=$.children;let H={...Z,scope:U,slots:W};for(let _ of Q)J.appendChild(u(_,H));return J}function j6($,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 Y8(){G("Alert",k6),G("AlertTitle",A6),G("AlertDescription",S6)}function k6($,Z){let J=N("div","pf-alert");J.setAttribute("role","alert");let q=$.variant??"default";if(J.setAttribute("data-variant",q),J.style.padding="12px 16px",$.icon!=null){let Q=N("span","pf-alert-icon");Q.setAttribute("data-icon",$.icon),Q.style.marginRight="8px",J.appendChild(Q)}return w($,J,Z),J}function A6($,Z){let J=N("h5","pf-alert-title");return J.textContent=L($.content,Z),J.style.fontWeight="600",J.style.marginBottom="4px",J}function S6($,Z){let J=N("p","pf-alert-description");return J.textContent=L($.content,Z),J.style.fontSize="14px",J}function U8(){G("Image",f6),G("Audio",w6),G("Video",C6),G("Embed",b6),G("Svg",m6),G("DropZone",h6),G("Mermaid",v6)}function f6($,Z){let J=document.createElement("img");if(J.className="pf-image",J.src=L($.src,Z),$.alt!=null)J.alt=L($.alt,Z);if($.width!=null)J.width=$.width;if($.height!=null)J.height=$.height;return J.style.maxWidth="100%",J}function w6($,Z){let J=document.createElement("audio");return J.className="pf-audio",J.src=L($.src,Z),J.controls=!0,J}function C6($,Z){let J=document.createElement("video");if(J.className="pf-video",J.src=L($.src,Z),J.controls=!0,$.width!=null)J.width=$.width;if($.height!=null)J.height=$.height;return J.style.maxWidth="100%",J}function b6($,Z){let J=N("div","pf-embed"),q=document.createElement("iframe");return q.src=L($.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 y6=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 m6($,Z){let J=N("div","pf-svg"),q=L($.content,Z);if(!q.includes("<svg"))return J;if(!/<svg[^>]*\sxmlns\s*=/.test(q))q=q.replace(/<svg\b/,'<svg xmlns="http://www.w3.org/2000/svg"');let Y=new DOMParser().parseFromString(q,"image/svg+xml").querySelector("svg");if(!Y)return J;return W8(Y),J.appendChild(document.importNode(Y,!0)),J}function W8($){let Z=Array.from($.children);for(let J of Z){if(!y6.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)}W8(J)}}function h6($,Z){let J=N("div","pf-dropzone");return J.style.padding="32px",J.style.textAlign="center",J.style.cursor="pointer",J.textContent=L($.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 v6($,Z){let J=N("div","pf-mermaid");J.setAttribute("data-mermaid","true");let q=L($.content,Z);if(J.textContent=q,typeof globalThis.mermaid<"u")J.classList.add("mermaid"),J.textContent=q;return J}var g6="https://cdn.jsdelivr.net/npm/pdfjs-dist@4.9/build/pdf.min.mjs",u6="https://cdn.jsdelivr.net/npm/pdfjs-dist@4.9/build/pdf.worker.min.mjs",_0=null,c1=null;async function x6(){if(_0)return _0;if(c1)return c1;return c1=import(g6).then(($)=>{let Z=$;return Z.GlobalWorkerOptions.workerSrc=u6,_0=Z,Z}),c1}function X8(){G("PdfViewer",p6)}function p6($,Z){let J=N("div","pf-pdf-viewer"),q=$.src!=null?L($.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("div","pf-pdf-loading");return _.textContent="Loading PDF…",_.style.display="flex",_.style.alignItems="center",_.style.justifyContent="center",_.style.flex="1",_.style.color="var(--color-text-secondary, #6b7280)",J.appendChild(_),c6(J,_,{src:q,data:Q,initialPage:Y,zoom:U,showToolbar:W}),J}async function c6($,Z,J){try{let q=await x6(),Q;if(J.src)Q={url:J.src};else if(J.data){let B=atob(J.data),K=new Uint8Array(B.length);for(let F=0;F<B.length;F++)K[F]=B.charCodeAt(F);Q={data:K}}else{Z.textContent="Error: No PDF source provided";return}let Y=await q.getDocument(Q).promise;Z.remove();let U=Math.max(1,Math.min(J.initialPage,Y.numPages)),W=null,H=null;if(J.showToolbar){let B=d6(Y.numPages,U,{onPrev:()=>{if(U>1)U--,X()},onNext:()=>{if(U<Y.numPages)U++,X()},onPageChange:(K)=>{let F=Math.max(1,Math.min(K,Y.numPages));if(F!==U)U=F,X()}});W=B.pageInput,H=B.pageCount,$.insertBefore(B.el,$.firstChild)}let _=N("div","pf-pdf-canvas-container");_.style.flex="1",_.style.overflow="auto",_.style.display="flex",_.style.justifyContent="center",_.style.padding="8px",$.appendChild(_);let z=document.createElement("canvas");z.style.display="block",z.style.boxShadow="var(--shadow-md, 0 4px 6px -1px rgba(0,0,0,.1))",_.appendChild(z);async function X(){let B=await Y.getPage(U),K=_.clientWidth-16,F,M=B.getViewport({scale:1});if(J.zoom==="fit-width")F=K/M.width;else if(J.zoom==="fit-page"){let P=_.clientHeight-16,A=K/M.width,I=P/M.height;F=Math.min(A,I)}else F=typeof J.zoom==="number"?J.zoom:1;let E=B.getViewport({scale:F});z.width=E.width,z.height=E.height,z.style.width=`${E.width}px`,z.style.height=`${E.height}px`;let O=z.getContext("2d");if(!O)return;if(await B.render({canvasContext:O,viewport:E}).promise,W)W.value=String(U);if(H)H.textContent=`/ ${Y.numPages}`}await X()}catch(q){Z.textContent=`PDF Error: ${q instanceof Error?q.message:String(q)}`,Z.style.color="var(--color-text-danger, #dc2626)"}}function d6($,Z,J){let q=N("div","pf-pdf-toolbar");q.style.display="flex",q.style.alignItems="center",q.style.gap="8px",q.style.padding="6px 12px",q.style.borderBottom="1px solid var(--color-border-primary, #e5e7eb)",q.style.background="var(--color-background-primary, #fff)",q.style.flexShrink="0",q.style.fontSize="13px";let Q=document.createElement("button");Q.textContent="‹",Q.title="Previous page",Q.className="pf-pdf-btn",H8(Q),Q.addEventListener("click",J.onPrev);let Y=document.createElement("button");Y.textContent="›",Y.title="Next page",Y.className="pf-pdf-btn",H8(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 H8($){$.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 l1=["#3b82f6","#10b981","#f59e0b","#ef4444","#8b5cf6","#ec4899"];function X1($,Z){let J=document.createElement("div");return J.className="pf-chart-tooltip",$.appendChild(J),$.addEventListener("mouseleave",()=>{J.classList.remove("pf-visible")}),{wrapper:$,tooltip:J,svgEl:Z}}function e($,Z,J,q,Q){let{tooltip:Y,svgEl:U,wrapper:W}=$;if(Q.length===0)return;let H="";if(q)H+=`<div class="pf-chart-tooltip-label">${d1(q)}</div>`;for(let E of Q)H+='<div class="pf-chart-tooltip-row">',H+=`<span class="pf-chart-tooltip-dot" style="background:${d1(E.color)}"></span>`,H+=`<span>${d1(E.label)}:</span> <strong>${d1(String(E.value))}</strong>`,H+="</div>";Y.innerHTML=H;let _=U.getBoundingClientRect(),z=W.getBoundingClientRect(),X=U.viewBox.baseVal,B=_.width/(X.width||1),K=_.left-z.left+Z*B,F=Y.offsetWidth||100,M=K+12;if(M+F>z.width)M=K-F-12;Y.style.left=`${Math.max(0,M)}px`,Y.style.top="4px",Y.classList.add("pf-visible")}function d1($){return $.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""")}function G8($,Z,J,q,Q,Y,U,W){let H=Q.plotWidth/J.length;for(let _=0;_<J.length;_++){let z=Q.plotLeft+_*H,X=document.createElementNS("http://www.w3.org/2000/svg","rect");X.setAttribute("x",String(z)),X.setAttribute("y",String(Q.plotTop)),X.setAttribute("width",String(H)),X.setAttribute("height",String(Q.plotHeight)),X.setAttribute("fill","transparent"),X.style.cursor="default";let B=Y?J[_][Y]:void 0,K=B!=null?W?W(B):b(B):void 0,F=q.map((P,A)=>({label:P.label??P.dataKey,value:U(J[_][P.dataKey],P,A),color:P.color??l1[A%l1.length]})),M=z+H/2,E=()=>e($,M,Q.plotTop,K,F),O=()=>$.tooltip.classList.remove("pf-visible");X.addEventListener("mouseenter",E),X.addEventListener("mouseleave",O),X.addEventListener("touchstart",E,{passive:!0}),X.addEventListener("touchend",O,{passive:!0}),Z.appendChild(X)}}function B8($,Z,J,q,Q,Y,U,W,H,_){let z=J.length===1?Q.plotWidth:Q.plotWidth/(J.length-1);for(let X=0;X<J.length;X++){let B=J.length===1?(Q.plotLeft+Q.plotRight)/2:Q.plotLeft+X/(J.length-1)*Q.plotWidth,K=J.length===1?Q.plotLeft:B-z/2,F=J.length===1?Q.plotWidth:z,M=document.createElementNS("http://www.w3.org/2000/svg","rect");M.setAttribute("x",String(Math.max(Q.plotLeft,K))),M.setAttribute("y",String(Q.plotTop)),M.setAttribute("width",String(Math.min(F,Q.plotRight-Math.max(Q.plotLeft,K)))),M.setAttribute("height",String(Q.plotHeight)),M.setAttribute("fill","transparent"),M.style.cursor="default";let E=Y?J[X][Y]:void 0,O=E!=null?_?_(E):b(E):void 0,P=q.map((j,f)=>({label:j.label??j.dataKey,value:U(J[X][j.dataKey],j,f),color:j.color??l1[f%l1.length]})),A=()=>{if(e($,B,Q.plotTop,O,P),W)W.setAttribute("x1",String(B)),W.setAttribute("x2",String(B)),W.setAttribute("opacity","1");if(H)for(let j of H){for(let f of j)f.setAttribute("data-visible","false");j[X]?.setAttribute("data-visible","true")}},I=()=>{if($.tooltip.classList.remove("pf-visible"),W)W.setAttribute("opacity","0");if(H)for(let j of H)for(let f of j)f.setAttribute("data-visible","false")};M.addEventListener("mouseenter",A),M.addEventListener("mouseleave",I),M.addEventListener("touchstart",A,{passive:!0}),M.addEventListener("touchend",I,{passive:!0}),Z.appendChild(M)}}var s=["#3b82f6","#10b981","#f59e0b","#ef4444","#8b5cf6","#ec4899"],J1="var(--muted-foreground, #6b7280)",E1="var(--border, #e5e7eb)",G1="10";function i1($,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 M8($,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 N0($,Z,J,q,Q){let Y=M8(J);for(let U of Y){let W=Z.plotBottom-(J>0?U/J*Z.plotHeight:0),H=n("text",{x:Z.plotLeft-6,y:W+3,"text-anchor":"end","font-size":G1,fill:J1});if(H.textContent=K0(U,Q),$.appendChild(H),q&&U>0)$.appendChild(n("line",{x1:Z.plotLeft,y1:W,x2:Z.plotRight,y2:W,stroke:E1,"stroke-width":1,"stroke-dasharray":"4 3"}))}}function z0($,Z,J,q){let Q=M8(J);for(let Y of Q){let U=Z.plotBottom-(J>0?Y/J*Z.plotHeight:0),W=n("text",{x:Z.plotRight+6,y:U+3,"text-anchor":"start","font-size":G1,fill:J1});W.textContent=K0(Y,q),$.appendChild(W)}}function E0($,Z,J,q,Q,Y){for(let U=0;U<Z.length;U++){let W=Z[U][J],H=n("text",{x:q(U),y:Q+14,"text-anchor":"middle","font-size":G1,fill:J1});H.textContent=W==null?"":Y?Y(W):b(W),$.appendChild(H)}}function s1($,Z){$.appendChild(n("line",{x1:Z.plotLeft,y1:Z.plotBottom,x2:Z.plotRight,y2:Z.plotBottom,stroke:J1,"stroke-width":1}))}function $1($,Z,J){if($==null)return"";let q=d(`{{ __v | ${Z} }}`,{...J,scope:{...J.scope,__v:$}});return b(q??$)}function K0($,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 q1($){let Z=$.yAxisFormat??$.valueFormat;return Z&&Z!=="auto"?Z:void 0}function L0($,Z,J){return(q,Q)=>{if(q===null||q===void 0)return"—";if(Q.tooltipFormat)return $1(q,Q.tooltipFormat,$);let Y=Q.yAxisId==="right"?J:Z;return K0(Number(q),Y)}}function U1($,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 n($,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 n1($,Z){let J=n("text",$);return J.textContent=Z,J}function B1($,Z,J,q){let Q=q*Math.PI/180;return{x:$+J*Math.cos(Q),y:Z-J*Math.sin(Q)}}function F0($,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=B1($,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 M1($,Z,J){if(J===!1||Z.length<=1)return;let q=N("div","pf-chart-legend");q.style.display="flex",q.style.gap="12px",q.style.fontSize="12px",q.style.marginBottom="8px";for(let Q=0;Q<Z.length;Q++){let Y=N("div","pf-chart-legend-item");Y.style.display="flex",Y.style.alignItems="center",Y.style.gap="4px";let U=N("span");U.style.width="8px",U.style.height="8px",U.style.borderRadius="50%",U.style.backgroundColor=Z[Q].color??s[Q%s.length];let W=N("span");W.textContent=Z[Q].label??Z[Q].dataKey,Y.appendChild(U),Y.appendChild(W),q.appendChild(Y)}$.appendChild(q)}function N8(){G("BarChart",l6),G("LineChart",_8),G("AreaChart",_8),G("PieChart",i6),G("RadarChart",r6),G("ScatterChart",s6),G("RadialChart",n6),G("Histogram",a6)}function l6($,Z){let J=N("div","pf-chart pf-bar-chart"),q=d($.data,Z)??[],Q=$.series??[],Y=$.height??300;if(q.length===0||Q.length===0)return J.textContent="No chart data",J;let U=$.showYAxis!==!1,W=$.showGrid===!0,H=$.showYAxisRight===!0,_=$.showTooltip!==!1,z=$.xAxis,X=$.tooltipXKey,B=$.xAxisFormat,K=$.tooltipXFormat,F=Q.filter((T)=>T.yAxisId!=="right"),M=Q.filter((T)=>T.yAxisId==="right"),E=H&&M.length>0,O=F.length>0?Math.max(...q.flatMap((T)=>F.map((D)=>Number(T[D.dataKey]??0))),1):1,P=E?Math.max(...q.flatMap((T)=>M.map((D)=>Number(T[D.dataKey]??0))),1):1,A=400,I=i1(A,Y,U,E),j=U1(A,Y,"Bar");if(U)N0(j,I,O,W,q1($));if(E)z0(j,I,P,$.yAxisRightFormat);s1(j,I);let f=I.plotWidth/q.length,S=f/(Q.length+1);for(let T=0;T<q.length;T++)for(let D=0;D<Q.length;D++){let k=Q[D],y=q[T][k.dataKey];if(y===null||y===void 0)continue;let i=k.yAxisId==="right"?P:O,g=Number(y),V=Math.max(0,g/i*I.plotHeight),p=I.plotLeft+T*f+D*S+S/2,R=document.createElementNS("http://www.w3.org/2000/svg","rect");R.setAttribute("x",String(p)),R.setAttribute("y",String(I.plotBottom-V)),R.setAttribute("width",String(S*0.8)),R.setAttribute("height",String(V)),R.setAttribute("fill",k.color??s[D%s.length]),R.setAttribute("rx","2"),j.appendChild(R)}if(z){let T=B?(D)=>$1(D,B,Z):void 0;E0(j,q,z,(D)=>{return I.plotLeft+D*f+f/2},I.plotBottom,T)}if(_){let T=X1(J,j),D=L0(Z,q1($),$.yAxisRightFormat);G8(T,j,q,Q,I,X??z,D,K?(y)=>$1(y,K,Z):void 0)}return M1(J,Q,$.showLegend),J.appendChild(j),J}function _8($,Z){let J=N("div",`pf-chart pf-${$.type.toLowerCase()}-chart`),q=d($.data,Z)??[],Q=$.series??[],Y=$.height??300;if(q.length===0||Q.length===0)return J.textContent="No chart data",J;let U=$.showYAxis!==!1,W=$.showGrid===!0,H=$.showYAxisRight===!0,_=$.showTooltip!==!1,z=$.xAxis,X=$.tooltipXKey,B=$.xAxisFormat,K=$.tooltipXFormat,F=Q.filter((D)=>D.yAxisId!=="right"),M=Q.filter((D)=>D.yAxisId==="right"),E=H&&M.length>0,O=F.length>0?Math.max(...q.flatMap((D)=>F.map((k)=>Number(D[k.dataKey]??0))),1):1,P=E?Math.max(...q.flatMap((D)=>M.map((k)=>Number(D[k.dataKey]??0))),1):1,A=400,I=i1(A,Y,U,E),j=U1(A,Y,$.type==="AreaChart"?"Area":"Line"),f=$.type==="AreaChart";if(U)N0(j,I,O,W,q1($));if(E)z0(j,I,P,$.yAxisRightFormat);s1(j,I);let S=[];for(let D=0;D<Q.length;D++){let k=Q[D],y=k.yAxisId==="right",x=y?P:O,i=k.color??s[D%s.length],g=q.map((R,m)=>{let c=R[k.dataKey],r=c===null||c===void 0,W1=q.length===1?(I.plotLeft+I.plotRight)/2:I.plotLeft+m/(q.length-1)*I.plotWidth,S8=r?I.plotBottom:I.plotBottom-Number(c)/x*I.plotHeight;return{x:W1,y:S8,isNull:r}});if(f){let R=[],m=()=>{if(R.length<2){R=[];return}let c=`M ${R[0].x},${I.plotBottom} `+R.map((W1)=>`L ${W1.x},${W1.y}`).join(" ")+` L ${R[R.length-1].x},${I.plotBottom} Z`,r=document.createElementNS("http://www.w3.org/2000/svg","path");r.setAttribute("d",c),r.setAttribute("fill",i),r.setAttribute("opacity","0.15"),j.appendChild(r),R=[]};for(let c of g){if(c.isNull){m();continue}R.push(c)}m()}let V="";for(let R of g){if(R.isNull)continue;let m=g.indexOf(R),c=m===0||g[m-1].isNull;V+=`${c?"M":"L"} ${R.x},${R.y} `}if(V){let R=document.createElementNS("http://www.w3.org/2000/svg","path");if(R.setAttribute("d",V.trim()),R.setAttribute("fill","none"),R.setAttribute("stroke",i),R.setAttribute("stroke-width","2"),y)R.setAttribute("stroke-dasharray","6 3");j.appendChild(R)}let p=[];for(let R of g){let m=document.createElementNS("http://www.w3.org/2000/svg","circle");if(m.setAttribute("cx",String(R.x)),m.setAttribute("cy",String(R.y)),m.setAttribute("r","4"),m.setAttribute("fill",i),m.setAttribute("class","pf-data-dot"),m.setAttribute("data-visible","false"),m.style.pointerEvents="none",R.isNull)m.style.display="none";j.appendChild(m),p.push(m)}S.push(p)}let T=document.createElementNS("http://www.w3.org/2000/svg","line");if(T.setAttribute("class","pf-crosshair"),T.setAttribute("x1",String(I.plotLeft)),T.setAttribute("x2",String(I.plotLeft)),T.setAttribute("y1",String(I.plotTop)),T.setAttribute("y2",String(I.plotBottom)),T.setAttribute("stroke",J1),T.setAttribute("stroke-width","1"),T.setAttribute("stroke-dasharray","3 3"),T.setAttribute("opacity","0"),j.appendChild(T),z){let D=B?(k)=>$1(k,B,Z):void 0;E0(j,q,z,(k)=>{return q.length===1?(I.plotLeft+I.plotRight)/2:I.plotLeft+k/(q.length-1)*I.plotWidth},I.plotBottom,D)}if(_){let D=X1(J,j),k=L0(Z,q1($),$.yAxisRightFormat);B8(D,j,q,Q,I,X??z,k,T,S,K?(x)=>$1(x,K,Z):void 0)}return M1(J,Q,$.showLegend),J.appendChild(j),J}function i6($,Z){let J=N("div","pf-chart pf-pie-chart"),q=d($.data,Z)??[],Q=$.series??[],Y=$.height??300,U=Math.min(Y,300),W=$.showTooltip!==!1,H=$.dataKey??Q[0]?.dataKey,_=$.nameKey??$.tooltipXKey??$.xAxis,z=Q.length>0?Q:H?[{dataKey:H,label:H}]:[];if(q.length===0||!H)return J.textContent="No chart data",J;let X=U1(U,U,"Pie"),B=U/2,K=U/2,F=U/2-10,M=$.tooltipXFormat,E=q1($),O=(f)=>E?$1(f,E,Z):String(f),P=q.map((f)=>Number(f[H]??0)),A=P.reduce((f,S)=>f+S,0);if(A===0)return J.textContent="No chart data",J.appendChild(X),J;let I=W?X1(J,X):void 0,j=-Math.PI/2;for(let f=0;f<P.length;f++){let S=P[f]/A*2*Math.PI,T=j+S,D=S>Math.PI?1:0,k=B+F*Math.cos(j),y=K+F*Math.sin(j),x=B+F*Math.cos(T),i=K+F*Math.sin(T),g=s[f%s.length],V=document.createElementNS("http://www.w3.org/2000/svg","path");if(V.setAttribute("d",`M ${B},${K} L ${k},${y} A ${F},${F} 0 ${D} 1 ${x},${i} Z`),V.setAttribute("fill",g),V.style.cursor="default",I){let p=_?q[f][_]:void 0,R=p!=null?M?$1(p,M,Z):b(p):`Slice ${f+1}`,m=`${(P[f]/A*100).toFixed(1)}%`,c=j+S/2,r=B+F*0.6*Math.cos(c);V.addEventListener("mouseenter",()=>{e(I,r,K,R,[{label:z[0].label??H,value:`${O(P[f])} (${m})`,color:g}])}),V.addEventListener("mouseleave",()=>{I.tooltip.classList.remove("pf-visible")}),V.addEventListener("touchstart",()=>{e(I,r,K,R,[{label:z[0].label??H,value:`${O(P[f])} (${m})`,color:g}])},{passive:!0}),V.addEventListener("touchend",()=>{I.tooltip.classList.remove("pf-visible")},{passive:!0})}X.appendChild(V),j=T}return M1(J,z,$.showLegend),J.appendChild(X),J}function s6($,Z){let J=N("div","pf-chart pf-scatter-chart"),q=d($.data,Z)??[],Q=$.xAxis,Y=$.yAxis,U=$.zAxis,W=$.series??[],H=$.height??300;if(q.length===0||!Q||!Y)return J.textContent="No chart data",J;let _=$.showGrid!==!1,z=$.showTooltip!==!1,X=W[0]?.color??s[0],B=q1($),K=(V)=>B?$1(V,B,Z):String(Math.round(V*100)/100),F=q.map((V)=>Number(V[Q]??0)),M=q.map((V)=>Number(V[Y]??0)),E=Math.min(...F),O=Math.max(...F),P=Math.min(...M),A=Math.max(...M),I=O-E||1,j=A-P||1,f=U?q.map((V)=>Number(V[U]??0)):[],S=U?Math.max(...f,1):1,T=400,D=i1(T,H,!0),k=U1(T,H,"Scatter"),y=(V)=>D.plotLeft+(V-E)/I*D.plotWidth,x=(V)=>D.plotBottom-(V-P)/j*D.plotHeight,i=4;for(let V=0;V<=i;V++){let p=P+j*V/i,R=x(p);if(k.appendChild(n1({x:D.plotLeft-6,y:R+3,"text-anchor":"end","font-size":G1,fill:J1},K(p))),_&&V>0)k.appendChild(n("line",{x1:D.plotLeft,y1:R,x2:D.plotRight,y2:R,stroke:E1,"stroke-width":1,"stroke-dasharray":"4 3"}))}s1(k,D);for(let V of[E,(E+O)/2,O])k.appendChild(n1({x:y(V),y:D.plotBottom+14,"text-anchor":"middle","font-size":G1,fill:J1},String(Math.round(V*100)/100)));let g=z?X1(J,k):void 0;for(let V=0;V<q.length;V++){let p=y(F[V]),R=x(M[V]),m=U?4+Math.sqrt(f[V]/S)*14:4,c=n("circle",{cx:p,cy:R,r:m,fill:X,"fill-opacity":U?0.6:0.85});if(g){let r=[{label:Q,value:K(F[V]),color:X},{label:Y,value:K(M[V]),color:X},...U?[{label:U,value:K(f[V]),color:X}]:[]],W1=W[0]?.label??"Point";c.addEventListener("mouseenter",()=>e(g,p,R,W1,r)),c.addEventListener("mouseleave",()=>g.tooltip.classList.remove("pf-visible")),c.addEventListener("touchstart",()=>e(g,p,R,W1,r),{passive:!0}),c.addEventListener("touchend",()=>g.tooltip.classList.remove("pf-visible"),{passive:!0})}k.appendChild(c)}return M1(J,W,$.showLegend),J.appendChild(k),J}function n6($,Z){let J=N("div","pf-chart pf-radial-chart"),q=d($.data,Z)??[],Q=$.series??[],Y=$.dataKey??Q[0]?.dataKey,U=$.nameKey??$.tooltipXKey??$.xAxis,W=$.height??300;if(q.length===0||!Y)return J.textContent="No chart data",J;let H=Math.min(W,300),_=H/2,z=H/2,X=H/2-10,B=Math.max(0,Math.min($.innerRadius??30,X-10)),K=$.startAngle??180,F=$.endAngle??0,M=$.showTooltip!==!1,E=q.map((D)=>Number(D[Y]??0)),O=Math.max(...E,1),P=U1(H,H,"Radial"),A=(X-B)/q.length,I=Math.max(2,A*0.7),j=q1($),f=(D)=>j?$1(D,j,Z):String(D),S=M?X1(J,P):void 0,T=[];for(let D=0;D<q.length;D++){let k=X-A*D-A/2,y=Q[D]?.color??s[D%s.length],x=E[D]/O,i=K+x*(F-K),g=U?q[D][U]:null,V=g!=null?b(g):Q[D]?.label??Y;T.push({dataKey:V||Y,label:V||Y,color:y}),P.appendChild(n("path",{d:F0(_,z,k,K,F),fill:"none",stroke:E1,"stroke-width":I,"stroke-linecap":"round"}));let p=n("path",{d:F0(_,z,k,K,i),fill:"none",stroke:y,"stroke-width":I,"stroke-linecap":"round"});if(S){let R=B1(_,z,k,(K+i)/2),m=[{label:Y,value:f(E[D]),color:y}],c=V||Y;p.addEventListener("mouseenter",()=>e(S,R.x,R.y,c,m)),p.addEventListener("mouseleave",()=>S.tooltip.classList.remove("pf-visible")),p.addEventListener("touchstart",()=>e(S,R.x,R.y,c,m),{passive:!0}),p.addEventListener("touchend",()=>S.tooltip.classList.remove("pf-visible"),{passive:!0})}P.appendChild(p)}return M1(J,T,$.showLegend),J.appendChild(P),J}function r6($,Z){let J=N("div","pf-chart pf-radar-chart"),q=d($.data,Z)??[],Q=$.series??[],Y=$.axisKey??$.xAxis,U=$.height??300;if(q.length===0||Q.length===0)return J.textContent="No chart data",J;let W=$.filled!==!1,H=$.showDots===!0,_=$.showGrid!==!1,z=$.showTooltip!==!1,X=Math.min(U,320),B=X/2,K=X/2,F=X/2-24,M=q.length,E=Math.max(...q.flatMap((S)=>Q.map((T)=>Number(S[T.dataKey]??0))),1),O=(S)=>90-360*S/M,P=(S)=>S.map((T)=>`${T.x.toFixed(1)},${T.y.toFixed(1)}`).join(" "),A=U1(X,X,"Radar");if(_){for(let T=1;T<=4;T++){let D=F*T/4,k=Array.from({length:M},(y,x)=>B1(B,K,D,O(x)));A.appendChild(n("polygon",{points:P(k),fill:"none",stroke:E1,"stroke-width":1}))}for(let T=0;T<M;T++){let D=B1(B,K,F,O(T));A.appendChild(n("line",{x1:B,y1:K,x2:D.x,y2:D.y,stroke:E1,"stroke-width":1}))}}for(let S=0;S<M;S++){let T=B1(B,K,F+12,O(S)),D=Y?q[S][Y]:null;A.appendChild(n1({x:T.x,y:T.y+3,"text-anchor":"middle","font-size":G1,fill:J1},D!=null?String(D):""))}let I=z?X1(J,A):void 0,j=q1($),f=(S)=>j?$1(S,j,Z):String(S);for(let S=0;S<Q.length;S++){let T=Q[S],D=T.color??s[S%s.length],k=q.map((y,x)=>B1(B,K,Number(y[T.dataKey]??0)/E*F,O(x)));if(A.appendChild(n("polygon",{points:P(k),fill:W?D:"none","fill-opacity":W?0.2:0,stroke:D,"stroke-width":2})),H||I)for(let y=0;y<k.length;y++){let x=n("circle",{cx:k[y].x,cy:k[y].y,r:H?3:6,fill:H?D:"transparent","fill-opacity":H?1:0});if(I){let i=Y?q[y][Y]:null,g=i!=null?b(i):T.label??T.dataKey,V=[{label:T.label??T.dataKey,value:f(Number(q[y][T.dataKey]??0)),color:D}];x.addEventListener("mouseenter",()=>e(I,k[y].x,k[y].y,g,V)),x.addEventListener("mouseleave",()=>I.tooltip.classList.remove("pf-visible")),x.addEventListener("touchstart",()=>e(I,k[y].x,k[y].y,g,V),{passive:!0}),x.addEventListener("touchend",()=>I.tooltip.classList.remove("pf-visible"),{passive:!0})}A.appendChild(x)}}return M1(J,Q,$.showLegend),J.appendChild(A),J}function a6($,Z){let J=N("div","pf-chart pf-histogram"),q=d($.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],H=Math.min(...Q),z=(Math.max(...Q)-H)/Y||1,X=Array(Y).fill(0);for(let O of Q){let P=Math.min(Math.floor((O-H)/z),Y-1);X[P]++}let B=Math.max(...X),K=300,F=U,M=K/Y,E=U1(K,F,"Histogram");for(let O=0;O<Y;O++){let P=B>0?X[O]/B*F:0,A=document.createElementNS("http://www.w3.org/2000/svg","rect");A.setAttribute("x",String(O*M)),A.setAttribute("y",String(F-P)),A.setAttribute("width",String(M-1)),A.setAttribute("height",String(P)),A.setAttribute("fill",W),E.appendChild(A)}return J.appendChild(E),J}function z8(){G("Table",o6),G("TableHead",D0("thead")),G("TableBody",D0("tbody")),G("TableFooter",D0("tfoot")),G("TableRow",t6),G("TableHeader",e6),G("TableCell",$5),G("TableCaption",Z5),G("ExpandableRow",J5)}function o6($,Z){let J=document.createElement("table");return J.className="pf-table",J.style.width="100%",J.style.borderCollapse="collapse",w($,J,Z),J}function D0($){return(Z,J)=>{let q=document.createElement($);return q.className=`pf-${$}`,w(Z,q,J),q}}function t6($,Z){let J=document.createElement("tr");return J.className="pf-table-row",w($,J,Z),J}function e6($,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=L($.content,Z),J}function $5($,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 Z5($,Z){let J=document.createElement("caption");return J.className="pf-table-caption",J.style.padding="8px",J.style.fontSize="14px",J.textContent=L($.content,Z),J}function J5($,Z){let J=N("div","pf-expandable-row"),q=N("div","pf-expandable-row-summary");q.style.cursor="pointer",q.style.display="flex",q.style.alignItems="center",q.style.gap="8px";let Q=N("span","pf-expandable-arrow");Q.textContent="▶",Q.style.transition="transform 0.2s",Q.style.fontSize="10px",q.appendChild(Q);let Y=$.summary;if(Y)for(let H of Y)q.appendChild(u(H,Z));let U=N("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 E8=!1;function r1(){if(E8)return;E8=!0,d0(),n0(),o0(),t0(),$8(),Z8(),J8(),Y8(),U8(),X8(),N8(),z8()}function T0($){return $.replace(/[^a-zA-Z0-9_-]/g,"")}function I0($){return $.replace(/[{}<>;]/g,"").replace(/\b(url|expression)\s*\(/gi,"")}function O0($,Z=" "){return Object.entries($).map(([J,q])=>`${Z}--${T0(J)}: ${I0(q)};`).join(`
|
|
7
|
-
`)}function
|
|
3
|
+
`),J=[],q=0;while(q<Z.length){let Q=Z[q];if(Q.trimStart().startsWith("```")){let H=Q.trimStart().slice(3).trim(),W=[];q++;while(q<Z.length&&!Z[q].trimStart().startsWith("```"))W.push(P1(Z[q])),q++;q++;let X=H?` data-language="${P1(H)}"`:"";J.push(`<pre class="pf-code"><code${X}>${W.join(`
|
|
4
|
+
`)}</code></pre>`);continue}if(/^(\s*[-*_]\s*){3,}$/.test(Q)){J.push("<hr />"),q++;continue}let Y=/^(#{1,6})\s+(.+)$/.exec(Q);if(Y){let H=Y[1].length;J.push(`<h${H}>${c1(Y[2])}</h${H}>`),q++;continue}if(Q.startsWith("> ")||Q===">"){let H=[];while(q<Z.length&&(Z[q].startsWith("> ")||Z[q]===">"))H.push(Z[q].replace(/^>\s?/,"")),q++;J.push(`<blockquote>${a0(H.join(`
|
|
5
|
+
`))}</blockquote>`);continue}if(/^[\s]*[-*+]\s+/.test(Q)){J.push("<ul>");while(q<Z.length&&/^[\s]*[-*+]\s+/.test(Z[q]))J.push(`<li>${c1(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>${c1(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(c1).join("<br />")}</p>`)}return J.join(`
|
|
6
|
+
`)}function g8($,Z){let J=document.createElement("kbd");return J.className="pf-kbd",J.textContent=D($.content,Z),J}function t0(){B("Card",u8),B("CardHeader",M0("pf-card-header")),B("CardTitle",o0("pf-card-title","h3")),B("CardDescription",o0("pf-card-description","p")),B("CardContent",M0("pf-card-content")),B("CardFooter",M0("pf-card-footer"))}function u8($,Z){let J=N("div","pf-card");return J.style.overflow="hidden",C($,J,Z),J}function M0($){return(Z,J)=>{let q=N("div",$);return q.style.padding="16px 24px",C(Z,q,J),q}}function o0($,Z){return(J,q)=>{let Q=document.createElement(Z);return Q.className=$,Q.textContent=D(J.content,q),Q}}function e0(){B("DataTable",x8),B("Badge",c8),B("Dot",p8),B("Metric",d8),B("Ring",l8),B("Progress",i8),B("Separator",s8),B("Loader",n8),B("Icon",r8),B("Sparkline",a8)}function x8($,Z){let J=N("div","pf-datatable-wrapper"),q=document.createElement("table");q.className="pf-datatable",q.style.width="100%",q.style.borderCollapse="collapse";let Q=$.columns??[],Y=l($.rows,Z),U=$.rowKey,H=$.selected,W=document.createElement("thead"),X=document.createElement("tr");for(let G of Q){let E=document.createElement("th");E.className="pf-datatable-th",E.textContent=G.header??G.key,E.style.padding="8px 12px",E.style.textAlign="left",X.appendChild(E)}W.appendChild(X),q.appendChild(W);let M=document.createElement("tbody");if(Array.isArray(Y)){let G=H!=null?l(H,Z):void 0;for(let E of Y){let z=document.createElement("tr");z.className="pf-datatable-row";let F=E,_=E===null||typeof E!=="object";if(U&&G!=null&&F[U]!=null&&b(F[U])===b(G))z.classList.add("pf-datatable-row-selected");if($.onRowClick!=null&&U)z.style.cursor="pointer",z.addEventListener("click",()=>{let K={...Z.scope,$item:F,$index:Y.indexOf(E)},T=d({...Z,scope:K});v(m($.onRowClick,T),"onRowClick")});for(let K of Q){let T=document.createElement("td");T.className="pf-datatable-td";let P;if(K.accessor)P=l(`{{ $item.${K.accessor} }}`,{...Z,scope:{...Z.scope,$item:F}});else if(P=_?E:F[K.key],K.format&&P!=null)P=l(`{{ __fmtVal | ${K.format} }}`,{...Z,scope:{...Z.scope,__fmtVal:P}});T.textContent=b(P),T.style.padding="8px 12px",z.appendChild(T)}M.appendChild(z)}}if(q.appendChild(M),$.search===!0){let G=document.createElement("input");G.type="text",G.placeholder="Search...",G.className="pf-datatable-search",G.style.marginBottom="8px",G.style.padding="6px 12px",G.style.width="100%",G.style.boxSizing="border-box",G.addEventListener("input",()=>{let E=G.value.toLowerCase(),z=Array.from(M.querySelectorAll("tr"));for(let F of z){let _=(F.textContent??"").toLowerCase();F.style.display=_.includes(E)?"":"none"}}),J.appendChild(G)}return J.appendChild(q),J}function c8($,Z){let J=N("span","pf-badge"),q=$.variant??"default";return J.setAttribute("data-variant",q),J.style.alignItems="center",J.style.padding="2px 10px",J.style.borderRadius="9999px",J.style.fontSize="12px",J.style.fontWeight="500",J.textContent=D($.label??$.content,Z),o8(J,q),J}function p8($,Z){let J=N("span","pf-dot"),q=$.color??"gray";return J.style.display="inline-block",J.style.width="8px",J.style.height="8px",J.style.borderRadius="50%",J.style.backgroundColor=q,J}function d8($,Z){let J=N("div","pf-metric"),q=N("div","pf-metric-label");q.textContent=D($.label,Z),q.style.fontSize="14px",J.appendChild(q);let Q=N("div","pf-metric-value");if(Q.textContent=D($.value,Z),Q.style.fontSize="28px",Q.style.fontWeight="700",J.appendChild(Q),$.delta!=null){let Y=N("span","pf-metric-delta");Y.textContent=D($.delta,Z);let U=$.trend??"",H=$.trendSentiment??"neutral";if(Y.style.fontSize="14px",Y.style.color=H==="positive"?"green":H==="negative"?"red":"inherit",U==="up")Y.textContent="↑ "+Y.textContent;else if(U==="down")Y.textContent="↓ "+Y.textContent;J.appendChild(Y)}if($.description!=null){let Y=N("div","pf-metric-desc");Y.textContent=D($.description,Z),Y.style.fontSize="12px",J.appendChild(Y)}return J}function l8($,Z){let J=N("div","pf-ring"),q=$.size??80,Q=$.thickness??8,Y=Number(l($.value,Z)??0),U=Math.max(0,Math.min(100,Y)),H=(q-Q)/2,W=2*Math.PI*H,X=W*(1-U/100),M=document.createElementNS("http://www.w3.org/2000/svg","svg");M.setAttribute("width",String(q)),M.setAttribute("height",String(q)),M.setAttribute("viewBox",`0 0 ${q} ${q}`);let G=document.createElementNS("http://www.w3.org/2000/svg","circle");G.setAttribute("cx",String(q/2)),G.setAttribute("cy",String(q/2)),G.setAttribute("r",String(H)),G.setAttribute("fill","none"),G.setAttribute("stroke","var(--muted, #e5e7eb)"),G.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(H)),E.setAttribute("fill","none"),E.setAttribute("stroke","var(--primary, #3b82f6)"),E.setAttribute("stroke-width",String(Q)),E.setAttribute("stroke-dasharray",String(W)),E.setAttribute("stroke-dashoffset",String(X)),E.setAttribute("stroke-linecap","round"),E.style.transform="rotate(-90deg)",E.style.transformOrigin="center",M.appendChild(G),M.appendChild(E),J.appendChild(M),$.label!=null){let z=N("div","pf-ring-label");z.textContent=D($.label,Z),z.style.textAlign="center",z.style.fontSize="12px",J.appendChild(z)}return J}function i8($,Z){let J=N("div","pf-progress");J.setAttribute("role","progressbar");let q=Number(l($.value,Z)??0),Q=$.max??100,Y=Q>0?Math.max(0,Math.min(100,q/Q*100)):0;J.setAttribute("aria-valuenow",String(q)),J.setAttribute("aria-valuemin","0"),J.setAttribute("aria-valuemax",String(Q)),J.style.height="8px",J.style.borderRadius="4px",J.style.overflow="hidden";let U=N("div","pf-progress-fill");return U.style.height="100%",U.style.width=`${Y}%`,U.style.borderRadius="4px",U.style.transition="width 0.3s ease",J.appendChild(U),J}function s8($,Z){let J=document.createElement("hr");return J.className="pf-separator",J.style.border="none",J.style.margin="8px 0",J}function n8($,Z){let J=N("div","pf-loader");return J.textContent="⏳",J.style.display="flex",J.style.justifyContent="center",J.style.padding="16px",J}function r8($,Z){let J=N("span","pf-icon");return J.setAttribute("data-icon",D($.name??$.content,Z)),J}function a8($,Z){let J=N("div","pf-sparkline"),q=$.data??[];if(q.length===0)return J;let Q=$.width??120,Y=$.height??32,U=Math.max(...q),H=Math.min(...q),W=U-H||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 M=q.length>1?q.length-1:1,G=q.map((z,F)=>{let _=F/M*Q,K=Y-(z-H)/W*(Y-4)-2;return`${_},${K}`}).join(" "),E=document.createElementNS("http://www.w3.org/2000/svg","polyline");return E.setAttribute("points",G),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 Z4(){B("Form",t8),B("Input",e8),B("Textarea",R1($6)),B("Button",Z6),B("ButtonGroup",J6),B("Select",R1(q6)),B("SelectOption",Q6),B("SelectGroup",p1("pf-select-group")),B("SelectLabel",V1("pf-select-label")),B("SelectSeparator",$4),B("Checkbox",Y6),B("Switch",U6),B("Slider",R1(H6)),B("Radio",G6),B("RadioGroup",X6),B("Combobox",R1(B6)),B("ComboboxOption",M6),B("ComboboxGroup",p1("pf-combobox-group")),B("ComboboxLabel",V1("pf-combobox-label")),B("ComboboxSeparator",$4),B("Calendar",_6),B("DatePicker",R1(N6)),B("Field",p1("pf-field")),B("FieldTitle",V1("pf-field-title")),B("FieldDescription",V1("pf-field-description")),B("FieldContent",p1("pf-field-content")),B("FieldError",V1("pf-field-error")),B("ChoiceCard",E6)}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,H)=>{Y[H]=U}),Z.store.merge(Y),$.onSubmit!=null){let U=d(Z);U.scope={...Z.scope,...Y},v(m($.onSubmit,U),"onSubmit")}}),C($,J,Z),J}function J4($,Z,J){if(Z.label==null)return;let q=document.createElement("label");if(q.className="pf-input-label",q.textContent=D(Z.label,J),Z.name!=null)q.htmlFor=Z.name;q.style.fontSize="14px",q.style.fontWeight="500",$.insertBefore(q,$.firstChild)}function R1($){return(Z,J)=>{let q=$(Z,J);return q.style.display="flex",q.style.flexDirection="column",q.style.gap="4px",J4(q,Z,J),q}}function e8($,Z){let J=N("div","pf-input-wrapper");J.style.display="flex",J.style.flexDirection="column",J.style.gap="4px",J4(J,$,Z);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=D($.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=b(Y);q.addEventListener("input",()=>{if(Z.store.set(Q,q.value),$.onChange!=null)v(m($.onChange,{...d(Z),scope:{...Z.scope,$event:q.value}}),"onChange")})}return _0(q),J.appendChild(q),J}function $6($,Z){let J=N("div","pf-textarea-wrapper"),q=document.createElement("textarea");if(q.className="pf-textarea",$.name!=null)q.name=$.name;if($.name!=null)q.id=`pf-textarea-${$.name}`;if($.placeholder!=null)q.placeholder=D($.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=b(Y);q.addEventListener("input",()=>{if(Z.store.set(Q,q.value),$.onChange!=null)v(m($.onChange,{...d(Z),scope:{...Z.scope,$event:q.value}}),"onChange")})}return _0(q),J.appendChild(q),J}function Z6($,Z){let J=document.createElement("button");J.className="pf-button",J.type=$.submit===!0?"submit":"button",J.textContent=D($.label,Z);let q=$.variant??"default";if(J.setAttribute("data-variant",q),W6(J,q),$.size!=null)J.setAttribute("data-size",$.size);if($.disabled===!0)J.disabled=!0;return J}function J6($,Z){let J=N("div","pf-button-group");return J.style.display="flex",J.style.gap="8px",C($,J,Z),J}function q6($,Z){let J=N("div","pf-select-wrapper"),q=document.createElement("select");if(q.className="pf-select",$.name!=null)q.name=$.name;if(_0(q),$.placeholder!=null){let U=document.createElement("option");U.value="",U.textContent=D($.placeholder,Z),U.disabled=!0,U.selected=!0,U.hidden=!0,q.appendChild(U)}let Q=$.options;if(Array.isArray(Q))for(let U of Q){let H=document.createElement("option");H.value=U.value??"",H.textContent=U.label??H.value,q.appendChild(H)}if($.children)for(let U of $.children)if(U.type==="SelectOption"){let H=document.createElement("option");H.value=U.value??"",H.textContent=U.label??H.value,q.appendChild(H)}else q.appendChild(u(U,Z));let Y=$.name;if(Y){let U=Z.store.get(Y);if(U!=null)q.value=b(U);q.addEventListener("change",()=>{if(Z.store.set(Y,q.value),$.onChange!=null)v(m($.onChange,{...d(Z),scope:{...Z.scope,$event:q.value}}),"onChange")})}return J.appendChild(q),J}function Q6($,Z){return N("span")}function Y6($,Z){let J=N("label","pf-checkbox-wrapper");J.style.display="flex",J.style.alignItems="center",J.style.gap="8px",J.style.cursor="pointer";let q=document.createElement("input");if(q.type="checkbox",q.className="pf-checkbox",$.name!=null)q.name=$.name;if($.checked===!0)q.checked=!0;let Q=$.name;if(Q){let Y=Z.store.get(Q);if(typeof Y==="boolean")q.checked=Y;q.addEventListener("change",()=>{if(Z.store.set(Q,q.checked),$.onChange!=null)v(m($.onChange,{...d(Z),scope:{...Z.scope,$event:q.checked}}),"onChange")})}if(J.appendChild(q),$.label!=null){let Y=N("span");Y.textContent=D($.label,Z),J.appendChild(Y)}return J}function U6($,Z){let J=N("label","pf-switch-wrapper");J.style.display="flex",J.style.alignItems="center",J.style.gap="8px",J.style.cursor="pointer";let q=document.createElement("input");if(q.type="checkbox",q.className="pf-switch",q.setAttribute("role","switch"),$.name!=null)q.name=$.name;let Q=$.name;if(Q){let Y=Z.store.get(Q);if(typeof Y==="boolean")q.checked=Y;q.addEventListener("change",()=>{if(Z.store.set(Q,q.checked),$.onChange!=null)v(m($.onChange,{...d(Z),scope:{...Z.scope,$event:q.checked}}),"onChange")})}if(J.appendChild(q),$.label!=null){let Y=N("span");Y.textContent=D($.label,Z),J.appendChild(Y)}return J}function H6($,Z){let J=N("div","pf-slider-wrapper"),q=document.createElement("input");if(q.type="range",q.className="pf-slider",$.name!=null)q.name=$.name;if($.min!=null)q.min=b($.min);if($.max!=null)q.max=b($.max);if($.step!=null)q.step=b($.step);let Q=$.name;if(Q){let Y=Z.store.get(Q);if(Y!=null)q.value=b(Y);q.addEventListener("input",()=>{if(Z.store.set(Q,Number(q.value)),$.onChange!=null)v(m($.onChange,{...d(Z),scope:{...Z.scope,$event:Number(q.value)}}),"onChange")})}return J.appendChild(q),J}function _0($){$.style.padding="8px 12px",$.style.fontSize="14px",$.style.width="100%",$.style.boxSizing="border-box"}function W6($,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 p1($){return(Z,J)=>{let q=N("div",$);return C(Z,q,J),q}}function V1($){return(Z,J)=>{let q=N("span",$);return q.textContent=D(Z.content,J),q}}function $4(){let $=document.createElement("hr");return $.className="pf-separator",$.style.border="none",$.style.margin="4px 0",$}function G6($,Z){let J=N("label","pf-radio");J.style.display="flex",J.style.alignItems="center",J.style.gap="8px",J.style.cursor="pointer";let q=document.createElement("input");if(q.type="radio",q.value=D($.value,Z),J.appendChild(q),$.label!=null){let Q=N("span","pf-radio-label");Q.textContent=D($.label,Z),J.appendChild(Q)}return J}function X6($,Z){let J=N("fieldset","pf-radio-group");if(J.style.border="none",J.style.padding="0",J.style.display="flex",J.style.flexDirection="column",J.style.gap="8px",$.label!=null){let Y=document.createElement("legend");Y.textContent=D($.label,Z),Y.style.fontWeight="500",Y.style.marginBottom="4px",J.appendChild(Y)}C($,J,Z);let q=D($.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===b(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)v(m($.onChange,d(Z)),"onChange")}}),J}function B6($,Z){let J=N("div","pf-combobox"),q=document.createElement("input");if(q.className="pf-combobox-input",q.type="text",q.name=D($.name,Z),$.placeholder!=null)q.placeholder=D($.placeholder,Z);if($.value!==void 0)q.value=D($.value,Z);let Q=q.name,Y=Z.store.get(Q);if(Y!=null)q.value=b(Y);q.style.padding="6px 12px",q.style.borderRadius="6px",q.style.width="100%",q.style.boxSizing="border-box";let U=N("div","pf-combobox-dropdown");if(U.style.display="none",U.style.position="absolute",U.style.borderRadius="6px",U.style.maxHeight="200px",U.style.overflowY="auto",U.style.zIndex="50",C($,U,Z),q.addEventListener("focus",()=>{U.style.display="block"}),q.addEventListener("blur",()=>{setTimeout(()=>{U.style.display="none"},150)}),$.searchable!==!1)q.addEventListener("input",()=>{let H=q.value.toLowerCase();for(let W of Array.from(U.querySelectorAll(".pf-combobox-option"))){let X=(W.textContent??"").toLowerCase();W.style.display=X.includes(H)?"":"none"}});if($.onChange!=null)J.addEventListener("pf-combobox-select",()=>{v(m($.onChange,{...d(Z),scope:{...Z.scope,$event:q.value}}),"onChange")});return J.style.position="relative",J.appendChild(q),J.appendChild(U),J}function M6($,Z){let J=N("div","pf-combobox-option");return J.style.padding="6px 12px",J.style.cursor="pointer",J.textContent=D($.label??$.value,Z),J.dataset.value=D($.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 _6($,Z){let J=N("div","pf-calendar"),q=document.createElement("input");if(q.type="date",q.name=D($.name,Z),$.value!==void 0)q.value=D($.value,Z);let Q=q.name,Y=Z.store.get(Q);if(Y!=null)q.value=b(Y);if($.minDate!=null)q.min=D($.minDate,Z);if($.maxDate!=null)q.max=D($.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)v(m($.onChange,d(Z)),"onChange")}),J.appendChild(q),J}function N6($,Z){let J=N("div","pf-datepicker"),q=document.createElement("input");if(q.type="date",q.name=D($.name,Z),$.placeholder!=null)q.placeholder=D($.placeholder,Z);if($.value!==void 0)q.value=D($.value,Z);let Q=q.name,Y=Z.store.get(Q);if(Y!=null)q.value=b(Y);if($.minDate!=null)q.min=D($.minDate,Z);if($.maxDate!=null)q.max=D($.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)v(m($.onChange,d(Z)),"onChange")}),J.appendChild(q),J}function E6($,Z){let J=N("div","pf-choice-card");if(J.style.padding="16px",J.style.cursor="pointer",J.style.transition="border-color 0.2s",J.dataset.value=D($.value,Z),$.selected===!0)J.dataset.selected="true";if($.label!=null){let q=N("div","pf-choice-card-label");q.textContent=D($.label,Z),q.style.fontWeight="600",J.appendChild(q)}if($.description!=null){let q=N("div","pf-choice-card-description");q.textContent=D($.description,Z),q.style.fontSize="14px",J.appendChild(q)}return C($,J,Z),J}function q4(){B("Tabs",z6),B("Tab",K6),B("Accordion",F6),B("AccordionItem",D6),B("Dialog",L6),B("Popover",T6),B("Tooltip",O6),B("HoverCard",I6),B("Carousel",P6)}function z6($,Z){let J=N("div","pf-tabs"),q=N("div","pf-tabs-bar");q.setAttribute("role","tablist"),q.style.display="flex",q.style.gap="4px",q.style.marginBottom="12px";let Q=[],Y=[],U=$.children??[],H=(()=>{let X=$.defaultTab;if(typeof X==="number")return X>=0&&X<U.length?X:0;if(typeof X==="string"){let M=U.findIndex((G)=>G.title===X);return M>=0?M:0}return 0})();if($.children)for(let X=0;X<$.children.length;X++){let M=$.children[X],G=`pf-tab-${Math.random().toString(36).slice(2,8)}`,E=`pf-panel-${Math.random().toString(36).slice(2,8)}`,z=document.createElement("button");z.type="button",z.className="pf-tab-trigger",z.textContent=M.title??`Tab ${X+1}`,z.setAttribute("role","tab"),z.setAttribute("aria-selected",X===H?"true":"false"),z.setAttribute("aria-controls",E),z.id=G,z.tabIndex=X===H?0:-1,z.style.padding="8px 16px",z.style.border="none",z.style.background="none",z.style.cursor="pointer",z.style.borderBottom="2px solid transparent",z.style.marginBottom="-2px",z.style.fontSize="14px";let F=N("div","pf-tab-panel");if(F.style.display=X===H?"block":"none",F.setAttribute("role","tabpanel"),F.setAttribute("aria-labelledby",G),F.id=E,F.tabIndex=0,C(M,F,Z),z.addEventListener("click",()=>{W(X)}),X===H)z.classList.add("pf-tab-active"),z.style.fontWeight="600";Y.push(z),Q.push(F),q.appendChild(z)}function W(X){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[X].style.display="block",Y[X].classList.add("pf-tab-active"),Y[X].style.fontWeight="600",Y[X].setAttribute("aria-selected","true"),Y[X].tabIndex=0,Y[X].focus()}q.addEventListener("keydown",(X)=>{let M=Y.indexOf(X.target);if(M<0)return;let G;if(X.key==="ArrowRight")G=(M+1)%Y.length;else if(X.key==="ArrowLeft")G=(M-1+Y.length)%Y.length;else if(X.key==="Home")G=0;else if(X.key==="End")G=Y.length-1;else return;X.preventDefault(),W(G)}),J.appendChild(q);for(let X of Q)J.appendChild(X);return J}function K6($,Z){let J=N("div","pf-tab");return C($,J,Z),J}function F6($,Z){let J=N("div","pf-accordion");return C($,J,Z),J}function D6($,Z){let J=N("div","pf-accordion-item"),q=`pf-acc-${Math.random().toString(36).slice(2,8)}`,Q=document.createElement("button");Q.type="button",Q.className="pf-accordion-trigger",Q.textContent=$.title??"",Q.setAttribute("aria-expanded","false"),Q.setAttribute("aria-controls",q),Q.style.width="100%",Q.style.textAlign="left",Q.style.padding="12px 0",Q.style.border="none",Q.style.background="none",Q.style.cursor="pointer",Q.style.fontSize="14px",Q.style.fontWeight="500";let Y=N("div","pf-accordion-content");return Y.id=q,Y.setAttribute("role","region"),Y.setAttribute("aria-labelledby",Q.id),Y.style.display="none",Y.style.paddingBottom="12px",C($,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 L6($,Z){let J=N("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=N("h2","pf-dialog-title");Y.textContent=D($.title,Z),Y.id=`pf-dialog-title-${Math.random().toString(36).slice(2,8)}`,q.setAttribute("aria-labelledby",Y.id),q.appendChild(Y)}if($.description!=null){let Y=N("p","pf-dialog-desc");Y.textContent=D($.description,Z),q.appendChild(Y)}let Q=N("div","pf-dialog-body");if(C($,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 T6($,Z){let J=N("div","pf-popover");J.style.position="relative",J.style.display="inline-block";let q=N("div","pf-popover-content");if(q.style.display="none",q.style.position="absolute",q.style.zIndex="50",q.style.padding="12px",q.style.boxShadow="0 4px 6px -1px rgb(0 0 0 / 0.1)",$.title!=null){let Y=N("div","pf-popover-title");Y.textContent=D($.title,Z),Y.style.fontWeight="600",Y.style.marginBottom="4px",q.appendChild(Y)}C($,q,Z);let Q=()=>{q.style.display=q.style.display==="none"?"block":"none"};if($.trigger!=null){let Y=u($.trigger,Z);Y.addEventListener("click",(U)=>{U.stopPropagation(),Q()}),J.appendChild(Y)}else J.addEventListener("click",(Y)=>{if(q.contains(Y.target)&&q.style.display!=="none")return;Q()});return J.appendChild(q),J}function O6($,Z){let J=N("div","pf-tooltip");J.style.position="relative",J.style.display="inline-block";let q=`pf-tip-${Math.random().toString(36).slice(2,8)}`,Q=N("div","pf-tooltip-content");return Q.id=q,Q.setAttribute("role","tooltip"),Q.textContent=D($.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",C($,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 I6($,Z){let J=N("div","pf-hover-card");J.style.position="relative",J.style.display="inline-block";let q=N("div","pf-hover-card-content");if(q.style.display="none",q.style.position="absolute",q.style.zIndex="50",q.style.padding="16px",q.style.boxShadow="0 4px 6px -1px rgb(0 0 0 / 0.1)",q.style.minWidth="200px",$.trigger!=null)J.appendChild(u($.trigger,Z));return C($,q,Z),J.addEventListener("mouseenter",()=>{q.style.display="block"}),J.addEventListener("mouseleave",()=>{q.style.display="none"}),J.appendChild(q),J}function P6($,Z){let J=N("div","pf-carousel");J.style.position="relative",J.style.overflow="hidden",J.setAttribute("role","region"),J.setAttribute("aria-roledescription","carousel"),J.setAttribute("aria-label",D($.label??"Carousel",Z));let q=N("div","pf-carousel-track");q.style.display="flex",q.style.transition="transform 0.3s ease",C($,q,Z);let Q=0,Y=$.children?.length??0,U=document.createElement("button");U.type="button",U.textContent="‹",U.className="pf-carousel-prev",U.setAttribute("aria-label","Previous slide"),U.style.position="absolute",U.style.left="4px",U.style.top="50%",U.style.transform="translateY(-50%)",U.style.zIndex="10";let H=document.createElement("button");H.type="button",H.textContent="›",H.className="pf-carousel-next",H.setAttribute("aria-label","Next slide"),H.style.position="absolute",H.style.right="4px",H.style.top="50%",H.style.transform="translateY(-50%)",H.style.zIndex="10";let W=()=>{q.style.transform=`translateX(-${Q*100}%)`};return U.addEventListener("click",()=>{if(Y===0)return;Q=Math.max(0,Q-1),W()}),H.addEventListener("click",()=>{if(Y===0)return;Q=Math.min(Y-1,Q+1),W()}),J.appendChild(q),J.appendChild(U),J.appendChild(H),J}function Q4(){B("ForEach",R6),B("If",Y4),B("Elif",V6),B("Else",j6),B("Condition",k6),B("Define",A6),B("Use",S6),B("Slot",f6)}function R6($,Z){let J=document.createDocumentFragment(),q=$.expression;if(!q)return J;let Q;if(o(q)){let U=t(q,Z.store,Z.scope);Q=Array.isArray(U)?U:[]}else{let U=Z.store.get(q);Q=Array.isArray(U)?U:[]}let Y=$.let??{};for(let U=0;U<Q.length;U++){let H=Q[U],W={...Z.scope,$item:H,$index:U,...Y},X={...Z,scope:W};if($.children)Y1($.children,J,X)}return J}function Y4($,Z){if(U4($.condition,Z)){let q=document.createDocumentFragment();if($.children)Y1($.children,q,Z);return q}return document.createDocumentFragment()}function V6($,Z){return Y4($,Z)}function j6($,Z){let J=document.createDocumentFragment();if($.children)Y1($.children,J,Z);return J}function U4($,Z){if(!$)return!1;if(o($))return Boolean(t($,Z.store,Z.scope));return Boolean(Z.store.get($))}function k6($,Z){let J=document.createDocumentFragment(),q=$.cases,Q=$.else;if(q){for(let Y of q)if(U4(Y.when,Z)){if(Y.children)Y1(Y.children,J,Z);return J}}if(Q)Y1(Q,J,Z);return J}function A6($,Z){let J=$.name;if(J&&$.children)Z.templates=Z.templates??{},Z.templates[J]=$.children;return document.createDocumentFragment()}function S6($,Z){let J=document.createDocumentFragment(),q=$.def??$.name,Q=Z.templates?.[q];if(!Q)return J;let Y=$.overrides??{},U={...Z.scope,...Y},H={...Z.slots??{},...$.slots??{}};if(Array.isArray($.children))H.default=$.children;let W={...Z,scope:U,slots:H};for(let X of Q)J.appendChild(u(X,W));return J}function f6($,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 H4(){B("Alert",C6),B("AlertTitle",w6),B("AlertDescription",b6)}function C6($,Z){let J=N("div","pf-alert");J.setAttribute("role","alert");let q=$.variant??"default";if(J.setAttribute("data-variant",q),J.style.padding="12px 16px",$.icon!=null){let Q=N("span","pf-alert-icon");Q.setAttribute("data-icon",$.icon),Q.style.marginRight="8px",J.appendChild(Q)}return C($,J,Z),J}function w6($,Z){let J=N("h5","pf-alert-title");return J.textContent=D($.content,Z),J.style.fontWeight="600",J.style.marginBottom="4px",J}function b6($,Z){let J=N("p","pf-alert-description");return J.textContent=D($.content,Z),J.style.fontSize="14px",J}function W4(){B("Image",y6),B("Audio",m6),B("Video",h6),B("Embed",v6),B("Svg",u6),B("DropZone",c6),B("Mermaid",p6)}function y6($,Z){let J=document.createElement("img");if(J.className="pf-image",J.src=D($.src,Z),$.alt!=null)J.alt=D($.alt,Z);if($.width!=null)J.width=$.width;if($.height!=null)J.height=$.height;return J.style.maxWidth="100%",J}function m6($,Z){let J=document.createElement("audio");return J.className="pf-audio",J.src=D($.src,Z),J.controls=!0,J}function h6($,Z){let J=document.createElement("video");if(J.className="pf-video",J.src=D($.src,Z),J.controls=!0,$.width!=null)J.width=$.width;if($.height!=null)J.height=$.height;return J.style.maxWidth="100%",J}function v6($,Z){let J=N("div","pf-embed"),q=document.createElement("iframe");return q.src=D($.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 g6=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 u6($,Z){let J=N("div","pf-svg"),q=D($.content,Z);if(!q.includes("<svg"))return J;if(!/<svg[^>]*\sxmlns\s*=/.test(q))q=q.replace(/<svg\b/,'<svg xmlns="http://www.w3.org/2000/svg"');let Y=new DOMParser().parseFromString(q,"image/svg+xml").querySelector("svg");if(!Y)return J;return G4(Y),J.appendChild(document.importNode(Y,!0)),J}function G4($){let Z=Array.from($.children);for(let J of Z){if(!g6.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)}G4(J)}}function x6($,Z){let J=(Z??"").split(",").map((Y)=>Y.trim().toLowerCase()).filter(Boolean);if(J.length===0)return!0;let q=$.name.toLowerCase(),Q=$.type.toLowerCase();return J.some((Y)=>{if(Y.startsWith("."))return q.endsWith(Y);if(Y.endsWith("/*"))return Q.startsWith(Y.slice(0,-1));return Q===Y})}function c6($,Z){let J=N("div","pf-dropzone");J.style.padding="32px",J.style.textAlign="center",J.style.cursor="pointer",J.textContent=D($.label??"Drop files here",Z);let q=document.createElement("input");if(q.type="file",q.style.display="none",$.accept!=null)q.accept=$.accept;if($.multiple===!0)q.multiple=!0;J.appendChild(q),J.setAttribute("role","button"),J.tabIndex=0;function Q(U){let H=Array.from(U??[]).filter((W)=>x6(W,$.accept));return $.multiple===!0?H:H.slice(0,1)}function Y(U){if(U.length===0)return;if($.resultKey!=null)Z.store.set($.resultKey,U),Z.rerender();if($.onDrop!=null)v(m($.onDrop,{...d(Z),scope:{...Z.scope,$result:U}}),"onDrop")}return q.addEventListener("change",()=>{Y(Q(q.files)),q.value=""}),J.addEventListener("click",()=>q.click()),J.addEventListener("keydown",(U)=>{if(U.key==="Enter"||U.key===" ")U.preventDefault(),q.click()}),J.addEventListener("dragover",(U)=>{U.preventDefault(),J.classList.add("pf-dropzone-active")}),J.addEventListener("dragleave",()=>{J.classList.remove("pf-dropzone-active")}),J.addEventListener("drop",(U)=>{U.preventDefault(),J.classList.remove("pf-dropzone-active"),Y(Q(U.dataTransfer?.files??null))}),J}function p6($,Z){let J=N("div","pf-mermaid");J.setAttribute("data-mermaid","true");let q=D($.content,Z);if(J.textContent=q,typeof globalThis.mermaid<"u")J.classList.add("mermaid"),J.textContent=q;return J}var d6="https://cdn.jsdelivr.net/npm/pdfjs-dist@4.9/build/pdf.min.mjs",l6="https://cdn.jsdelivr.net/npm/pdfjs-dist@4.9/build/pdf.worker.min.mjs",N0=null,d1=null;async function i6(){if(N0)return N0;if(d1)return d1;return d1=import(d6).then(($)=>{let Z=$;return Z.GlobalWorkerOptions.workerSrc=l6,N0=Z,Z}),d1}function B4(){B("PdfViewer",s6)}function s6($,Z){let J=N("div","pf-pdf-viewer"),q=$.src!=null?D($.src,Z):void 0,Q=$.data,Y=$.page!=null?$.page:1,U=$.zoom!=null?$.zoom:"fit-width",H=$.toolbar!==!1,W=$.height!=null?$.height:600;J.style.height=`${W}px`,J.style.display="flex",J.style.flexDirection="column",J.style.overflow="hidden",J.style.border="1px solid var(--color-border-primary, #e5e7eb)",J.style.borderRadius="var(--border-radius-md, 0.375rem)",J.style.background="var(--color-background-secondary, #f9fafb)";let X=N("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),n6(J,X,{src:q,data:Q,initialPage:Y,zoom:U,showToolbar:H}),J}async function n6($,Z,J){try{let q=await i6(),Q;if(J.src)Q={url:J.src};else if(J.data){let E=atob(J.data),z=new Uint8Array(E.length);for(let F=0;F<E.length;F++)z[F]=E.charCodeAt(F);Q={data:z}}else{Z.textContent="Error: No PDF source provided";return}let Y=await q.getDocument(Q).promise;Z.remove();let U=Math.max(1,Math.min(J.initialPage,Y.numPages)),H=null,W=null;if(J.showToolbar){let E=r6(Y.numPages,U,{onPrev:()=>{if(U>1)U--,G()},onNext:()=>{if(U<Y.numPages)U++,G()},onPageChange:(z)=>{let F=Math.max(1,Math.min(z,Y.numPages));if(F!==U)U=F,G()}});H=E.pageInput,W=E.pageCount,$.insertBefore(E.el,$.firstChild)}let X=N("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 M=document.createElement("canvas");M.style.display="block",M.style.boxShadow="var(--shadow-md, 0 4px 6px -1px rgba(0,0,0,.1))",X.appendChild(M);async function G(){let E=await Y.getPage(U),z=X.clientWidth-16,F,_=E.getViewport({scale:1});if(J.zoom==="fit-width")F=z/_.width;else if(J.zoom==="fit-page"){let P=X.clientHeight-16,A=z/_.width,I=P/_.height;F=Math.min(A,I)}else F=typeof J.zoom==="number"?J.zoom:1;let K=E.getViewport({scale:F});M.width=K.width,M.height=K.height,M.style.width=`${K.width}px`,M.style.height=`${K.height}px`;let T=M.getContext("2d");if(!T)return;if(await E.render({canvasContext:T,viewport:K}).promise,H)H.value=String(U);if(W)W.textContent=`/ ${Y.numPages}`}await G()}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=N("div","pf-pdf-toolbar");q.style.display="flex",q.style.alignItems="center",q.style.gap="8px",q.style.padding="6px 12px",q.style.borderBottom="1px solid var(--color-border-primary, #e5e7eb)",q.style.background="var(--color-background-primary, #fff)",q.style.flexShrink="0",q.style.fontSize="13px";let Q=document.createElement("button");Q.textContent="‹",Q.title="Previous page",Q.className="pf-pdf-btn",X4(Q),Q.addEventListener("click",J.onPrev);let Y=document.createElement("button");Y.textContent="›",Y.title="Next page",Y.className="pf-pdf-btn",X4(Y),Y.addEventListener("click",J.onNext);let U=document.createElement("input");U.type="number",U.min="1",U.max=String($),U.value=String(Z),U.style.width="48px",U.style.textAlign="center",U.style.border="1px solid var(--color-border-primary, #e5e7eb)",U.style.borderRadius="4px",U.style.padding="2px 4px",U.style.fontSize="13px",U.addEventListener("change",()=>{let W=parseInt(U.value,10);if(!isNaN(W))J.onPageChange(W)});let H=document.createElement("span");return H.textContent=`/ ${$}`,H.style.color="var(--color-text-secondary, #6b7280)",q.appendChild(Q),q.appendChild(U),q.appendChild(H),q.appendChild(Y),{el:q,pageInput:U,pageCount:H}}function X4($){$.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 i1=["#3b82f6","#10b981","#f59e0b","#ef4444","#8b5cf6","#ec4899"];function G1($,Z){let J=document.createElement("div");return J.className="pf-chart-tooltip",$.appendChild(J),$.addEventListener("mouseleave",()=>{J.classList.remove("pf-visible")}),{wrapper:$,tooltip:J,svgEl:Z}}function e($,Z,J,q,Q){let{tooltip:Y,svgEl:U,wrapper:H}=$;if(Q.length===0)return;let W="";if(q)W+=`<div class="pf-chart-tooltip-label">${l1(q)}</div>`;for(let K of Q)W+='<div class="pf-chart-tooltip-row">',W+=`<span class="pf-chart-tooltip-dot" style="background:${l1(K.color)}"></span>`,W+=`<span>${l1(K.label)}:</span> <strong>${l1(String(K.value))}</strong>`,W+="</div>";Y.innerHTML=W;let X=U.getBoundingClientRect(),M=H.getBoundingClientRect(),G=U.viewBox.baseVal,E=X.width/(G.width||1),z=X.left-M.left+Z*E,F=Y.offsetWidth||100,_=z+12;if(_+F>M.width)_=z-F-12;Y.style.left=`${Math.max(0,_)}px`,Y.style.top="4px",Y.classList.add("pf-visible")}function l1($){return $.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""")}function M4($,Z,J,q,Q,Y,U,H){let W=Q.plotWidth/J.length;for(let X=0;X<J.length;X++){let M=Q.plotLeft+X*W,G=document.createElementNS("http://www.w3.org/2000/svg","rect");G.setAttribute("x",String(M)),G.setAttribute("y",String(Q.plotTop)),G.setAttribute("width",String(W)),G.setAttribute("height",String(Q.plotHeight)),G.setAttribute("fill","transparent"),G.style.cursor="default";let E=Y?J[X][Y]:void 0,z=E!=null?H?H(E):b(E):void 0,F=q.map((P,A)=>({label:P.label??P.dataKey,value:U(J[X][P.dataKey],P,A),color:P.color??i1[A%i1.length]})),_=M+W/2,K=()=>e($,_,Q.plotTop,z,F),T=()=>$.tooltip.classList.remove("pf-visible");G.addEventListener("mouseenter",K),G.addEventListener("mouseleave",T),G.addEventListener("touchstart",K,{passive:!0}),G.addEventListener("touchend",T,{passive:!0}),Z.appendChild(G)}}function _4($,Z,J,q,Q,Y,U,H,W,X){let M=J.length===1?Q.plotWidth:Q.plotWidth/(J.length-1);for(let G=0;G<J.length;G++){let E=J.length===1?(Q.plotLeft+Q.plotRight)/2:Q.plotLeft+G/(J.length-1)*Q.plotWidth,z=J.length===1?Q.plotLeft:E-M/2,F=J.length===1?Q.plotWidth:M,_=document.createElementNS("http://www.w3.org/2000/svg","rect");_.setAttribute("x",String(Math.max(Q.plotLeft,z))),_.setAttribute("y",String(Q.plotTop)),_.setAttribute("width",String(Math.min(F,Q.plotRight-Math.max(Q.plotLeft,z)))),_.setAttribute("height",String(Q.plotHeight)),_.setAttribute("fill","transparent"),_.style.cursor="default";let K=Y?J[G][Y]:void 0,T=K!=null?X?X(K):b(K):void 0,P=q.map((j,f)=>({label:j.label??j.dataKey,value:U(J[G][j.dataKey],j,f),color:j.color??i1[f%i1.length]})),A=()=>{if(e($,E,Q.plotTop,T,P),H)H.setAttribute("x1",String(E)),H.setAttribute("x2",String(E)),H.setAttribute("opacity","1");if(W)for(let j of W){for(let f of j)f.setAttribute("data-visible","false");j[G]?.setAttribute("data-visible","true")}},I=()=>{if($.tooltip.classList.remove("pf-visible"),H)H.setAttribute("opacity","0");if(W)for(let j of W)for(let f of j)f.setAttribute("data-visible","false")};_.addEventListener("mouseenter",A),_.addEventListener("mouseleave",I),_.addEventListener("touchstart",A,{passive:!0}),_.addEventListener("touchend",I,{passive:!0}),Z.appendChild(_)}}var s=["#3b82f6","#10b981","#f59e0b","#ef4444","#8b5cf6","#ec4899"],J1="var(--muted-foreground, #6b7280)",z1="var(--border, #e5e7eb)",X1="10";function s1($,Z,J,q=!1){let Q=J?44:0,Y=$-(q?44:0),U=10,H=Z-24;return{plotLeft:Q,plotRight:Y,plotTop:10,plotBottom:H,plotWidth:Y-Q,plotHeight:H-10}}function N4($,Z=5){if($<=0)return[0];let J=$/Z,q=Math.pow(10,Math.floor(Math.log10(J))),Q=J/q,Y=Q<=1.5?q:Q<=3?2*q:Q<=7?5*q:10*q,U=[];for(let H=0;H<=$+Y*0.01;H+=Y)U.push(Math.round(H*1000)/1000);return U}function E0($,Z,J,q,Q){let Y=N4(J);for(let U of Y){let H=Z.plotBottom-(J>0?U/J*Z.plotHeight:0),W=n("text",{x:Z.plotLeft-6,y:H+3,"text-anchor":"end","font-size":X1,fill:J1});if(W.textContent=F0(U,Q),$.appendChild(W),q&&U>0)$.appendChild(n("line",{x1:Z.plotLeft,y1:H,x2:Z.plotRight,y2:H,stroke:z1,"stroke-width":1,"stroke-dasharray":"4 3"}))}}function z0($,Z,J,q){let Q=N4(J);for(let Y of Q){let U=Z.plotBottom-(J>0?Y/J*Z.plotHeight:0),H=n("text",{x:Z.plotRight+6,y:U+3,"text-anchor":"start","font-size":X1,fill:J1});H.textContent=F0(Y,q),$.appendChild(H)}}function K0($,Z,J,q,Q,Y){for(let U=0;U<Z.length;U++){let H=Z[U][J],W=n("text",{x:q(U),y:Q+14,"text-anchor":"middle","font-size":X1,fill:J1});W.textContent=H==null?"":Y?Y(H):b(H),$.appendChild(W)}}function n1($,Z){$.appendChild(n("line",{x1:Z.plotLeft,y1:Z.plotBottom,x2:Z.plotRight,y2:Z.plotBottom,stroke:J1,"stroke-width":1}))}function $1($,Z,J){if($==null)return"";let q=l(`{{ __v | ${Z} }}`,{...J,scope:{...J.scope,__v:$}});return b(q??$)}function F0($,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 q1($){let Z=$.yAxisFormat??$.valueFormat;return Z&&Z!=="auto"?Z:void 0}function D0($,Z,J){return(q,Q)=>{if(q===null||q===void 0)return"—";if(Q.tooltipFormat)return $1(q,Q.tooltipFormat,$);let Y=Q.yAxisId==="right"?J:Z;return F0(Number(q),Y)}}function U1($,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 n($,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 r1($,Z){let J=n("text",$);return J.textContent=Z,J}function B1($,Z,J,q){let Q=q*Math.PI/180;return{x:$+J*Math.cos(Q),y:Z-J*Math.sin(Q)}}function L0($,Z,J,q,Q){let Y=Math.max(2,Math.ceil(Math.abs(Q-q)/4)),U=[];for(let H=0;H<=Y;H++){let W=B1($,Z,J,q+(Q-q)*H/Y);U.push(`${H===0?"M":"L"} ${W.x.toFixed(2)} ${W.y.toFixed(2)}`)}return U.join(" ")}function M1($,Z,J){if(J===!1||Z.length<=1)return;let q=N("div","pf-chart-legend");q.style.display="flex",q.style.gap="12px",q.style.fontSize="12px",q.style.marginBottom="8px";for(let Q=0;Q<Z.length;Q++){let Y=N("div","pf-chart-legend-item");Y.style.display="flex",Y.style.alignItems="center",Y.style.gap="4px";let U=N("span");U.style.width="8px",U.style.height="8px",U.style.borderRadius="50%",U.style.backgroundColor=Z[Q].color??s[Q%s.length];let H=N("span");H.textContent=Z[Q].label??Z[Q].dataKey,Y.appendChild(U),Y.appendChild(H),q.appendChild(Y)}$.appendChild(q)}function z4(){B("BarChart",a6),B("LineChart",E4),B("AreaChart",E4),B("PieChart",o6),B("RadarChart",$5),B("ScatterChart",t6),B("RadialChart",e6),B("Histogram",Z5)}function a6($,Z){let J=N("div","pf-chart pf-bar-chart"),q=l($.data,Z)??[],Q=$.series??[],Y=$.height??300;if(q.length===0||Q.length===0)return J.textContent="No chart data",J;let U=$.showYAxis!==!1,H=$.showGrid===!0,W=$.showYAxisRight===!0,X=$.showTooltip!==!1,M=$.xAxis,G=$.tooltipXKey,E=$.xAxisFormat,z=$.tooltipXFormat,F=Q.filter((O)=>O.yAxisId!=="right"),_=Q.filter((O)=>O.yAxisId==="right"),K=W&&_.length>0,T=F.length>0?Math.max(...q.flatMap((O)=>F.map((L)=>Number(O[L.dataKey]??0))),1):1,P=K?Math.max(...q.flatMap((O)=>_.map((L)=>Number(O[L.dataKey]??0))),1):1,A=400,I=s1(A,Y,U,K),j=U1(A,Y,"Bar");if(U)E0(j,I,T,H,q1($));if(K)z0(j,I,P,$.yAxisRightFormat);n1(j,I);let f=I.plotWidth/q.length,S=f/(Q.length+1);for(let O=0;O<q.length;O++)for(let L=0;L<Q.length;L++){let k=Q[L],y=q[O][k.dataKey];if(y===null||y===void 0)continue;let i=k.yAxisId==="right"?P:T,g=Number(y),R=Math.max(0,g/i*I.plotHeight),c=I.plotLeft+O*f+L*S+S/2,V=document.createElementNS("http://www.w3.org/2000/svg","rect");V.setAttribute("x",String(c)),V.setAttribute("y",String(I.plotBottom-R)),V.setAttribute("width",String(S*0.8)),V.setAttribute("height",String(R)),V.setAttribute("fill",k.color??s[L%s.length]),V.setAttribute("rx","2"),j.appendChild(V)}if(M){let O=E?(L)=>$1(L,E,Z):void 0;K0(j,q,M,(L)=>{return I.plotLeft+L*f+f/2},I.plotBottom,O)}if(X){let O=G1(J,j),L=D0(Z,q1($),$.yAxisRightFormat);M4(O,j,q,Q,I,G??M,L,z?(y)=>$1(y,z,Z):void 0)}return M1(J,Q,$.showLegend),J.appendChild(j),J}function E4($,Z){let J=N("div",`pf-chart pf-${$.type.toLowerCase()}-chart`),q=l($.data,Z)??[],Q=$.series??[],Y=$.height??300;if(q.length===0||Q.length===0)return J.textContent="No chart data",J;let U=$.showYAxis!==!1,H=$.showGrid===!0,W=$.showYAxisRight===!0,X=$.showTooltip!==!1,M=$.xAxis,G=$.tooltipXKey,E=$.xAxisFormat,z=$.tooltipXFormat,F=Q.filter((L)=>L.yAxisId!=="right"),_=Q.filter((L)=>L.yAxisId==="right"),K=W&&_.length>0,T=F.length>0?Math.max(...q.flatMap((L)=>F.map((k)=>Number(L[k.dataKey]??0))),1):1,P=K?Math.max(...q.flatMap((L)=>_.map((k)=>Number(L[k.dataKey]??0))),1):1,A=400,I=s1(A,Y,U,K),j=U1(A,Y,$.type==="AreaChart"?"Area":"Line"),f=$.type==="AreaChart";if(U)E0(j,I,T,H,q1($));if(K)z0(j,I,P,$.yAxisRightFormat);n1(j,I);let S=[];for(let L=0;L<Q.length;L++){let k=Q[L],y=k.yAxisId==="right",x=y?P:T,i=k.color??s[L%s.length],g=q.map((V,h)=>{let p=V[k.dataKey],r=p===null||p===void 0,H1=q.length===1?(I.plotLeft+I.plotRight)/2:I.plotLeft+h/(q.length-1)*I.plotWidth,w4=r?I.plotBottom:I.plotBottom-Number(p)/x*I.plotHeight;return{x:H1,y:w4,isNull:r}});if(f){let V=[],h=()=>{if(V.length<2){V=[];return}let p=`M ${V[0].x},${I.plotBottom} `+V.map((H1)=>`L ${H1.x},${H1.y}`).join(" ")+` L ${V[V.length-1].x},${I.plotBottom} Z`,r=document.createElementNS("http://www.w3.org/2000/svg","path");r.setAttribute("d",p),r.setAttribute("fill",i),r.setAttribute("opacity","0.15"),j.appendChild(r),V=[]};for(let p of g){if(p.isNull){h();continue}V.push(p)}h()}let R="";for(let V of g){if(V.isNull)continue;let h=g.indexOf(V),p=h===0||g[h-1].isNull;R+=`${p?"M":"L"} ${V.x},${V.y} `}if(R){let V=document.createElementNS("http://www.w3.org/2000/svg","path");if(V.setAttribute("d",R.trim()),V.setAttribute("fill","none"),V.setAttribute("stroke",i),V.setAttribute("stroke-width","2"),y)V.setAttribute("stroke-dasharray","6 3");j.appendChild(V)}let c=[];for(let V of g){let h=document.createElementNS("http://www.w3.org/2000/svg","circle");if(h.setAttribute("cx",String(V.x)),h.setAttribute("cy",String(V.y)),h.setAttribute("r","4"),h.setAttribute("fill",i),h.setAttribute("class","pf-data-dot"),h.setAttribute("data-visible","false"),h.style.pointerEvents="none",V.isNull)h.style.display="none";j.appendChild(h),c.push(h)}S.push(c)}let O=document.createElementNS("http://www.w3.org/2000/svg","line");if(O.setAttribute("class","pf-crosshair"),O.setAttribute("x1",String(I.plotLeft)),O.setAttribute("x2",String(I.plotLeft)),O.setAttribute("y1",String(I.plotTop)),O.setAttribute("y2",String(I.plotBottom)),O.setAttribute("stroke",J1),O.setAttribute("stroke-width","1"),O.setAttribute("stroke-dasharray","3 3"),O.setAttribute("opacity","0"),j.appendChild(O),M){let L=E?(k)=>$1(k,E,Z):void 0;K0(j,q,M,(k)=>{return q.length===1?(I.plotLeft+I.plotRight)/2:I.plotLeft+k/(q.length-1)*I.plotWidth},I.plotBottom,L)}if(X){let L=G1(J,j),k=D0(Z,q1($),$.yAxisRightFormat);_4(L,j,q,Q,I,G??M,k,O,S,z?(x)=>$1(x,z,Z):void 0)}return M1(J,Q,$.showLegend),J.appendChild(j),J}function o6($,Z){let J=N("div","pf-chart pf-pie-chart"),q=l($.data,Z)??[],Q=$.series??[],Y=$.height??300,U=Math.min(Y,300),H=$.showTooltip!==!1,W=$.dataKey??Q[0]?.dataKey,X=$.nameKey??$.tooltipXKey??$.xAxis,M=Q.length>0?Q:W?[{dataKey:W,label:W}]:[];if(q.length===0||!W)return J.textContent="No chart data",J;let G=U1(U,U,"Pie"),E=U/2,z=U/2,F=U/2-10,_=$.tooltipXFormat,K=q1($),T=(f)=>K?$1(f,K,Z):String(f),P=q.map((f)=>Number(f[W]??0)),A=P.reduce((f,S)=>f+S,0);if(A===0)return J.textContent="No chart data",J.appendChild(G),J;let I=H?G1(J,G):void 0,j=-Math.PI/2;for(let f=0;f<P.length;f++){let S=P[f]/A*2*Math.PI,O=j+S,L=S>Math.PI?1:0,k=E+F*Math.cos(j),y=z+F*Math.sin(j),x=E+F*Math.cos(O),i=z+F*Math.sin(O),g=s[f%s.length],R=document.createElementNS("http://www.w3.org/2000/svg","path");if(R.setAttribute("d",`M ${E},${z} L ${k},${y} A ${F},${F} 0 ${L} 1 ${x},${i} Z`),R.setAttribute("fill",g),R.style.cursor="default",I){let c=X?q[f][X]:void 0,V=c!=null?_?$1(c,_,Z):b(c):`Slice ${f+1}`,h=`${(P[f]/A*100).toFixed(1)}%`,p=j+S/2,r=E+F*0.6*Math.cos(p);R.addEventListener("mouseenter",()=>{e(I,r,z,V,[{label:M[0].label??W,value:`${T(P[f])} (${h})`,color:g}])}),R.addEventListener("mouseleave",()=>{I.tooltip.classList.remove("pf-visible")}),R.addEventListener("touchstart",()=>{e(I,r,z,V,[{label:M[0].label??W,value:`${T(P[f])} (${h})`,color:g}])},{passive:!0}),R.addEventListener("touchend",()=>{I.tooltip.classList.remove("pf-visible")},{passive:!0})}G.appendChild(R),j=O}return M1(J,M,$.showLegend),J.appendChild(G),J}function t6($,Z){let J=N("div","pf-chart pf-scatter-chart"),q=l($.data,Z)??[],Q=$.xAxis,Y=$.yAxis,U=$.zAxis,H=$.series??[],W=$.height??300;if(q.length===0||!Q||!Y)return J.textContent="No chart data",J;let X=$.showGrid!==!1,M=$.showTooltip!==!1,G=H[0]?.color??s[0],E=q1($),z=(R)=>E?$1(R,E,Z):String(Math.round(R*100)/100),F=q.map((R)=>Number(R[Q]??0)),_=q.map((R)=>Number(R[Y]??0)),K=Math.min(...F),T=Math.max(...F),P=Math.min(..._),A=Math.max(..._),I=T-K||1,j=A-P||1,f=U?q.map((R)=>Number(R[U]??0)):[],S=U?Math.max(...f,1):1,O=400,L=s1(O,W,!0),k=U1(O,W,"Scatter"),y=(R)=>L.plotLeft+(R-K)/I*L.plotWidth,x=(R)=>L.plotBottom-(R-P)/j*L.plotHeight,i=4;for(let R=0;R<=i;R++){let c=P+j*R/i,V=x(c);if(k.appendChild(r1({x:L.plotLeft-6,y:V+3,"text-anchor":"end","font-size":X1,fill:J1},z(c))),X&&R>0)k.appendChild(n("line",{x1:L.plotLeft,y1:V,x2:L.plotRight,y2:V,stroke:z1,"stroke-width":1,"stroke-dasharray":"4 3"}))}n1(k,L);for(let R of[K,(K+T)/2,T])k.appendChild(r1({x:y(R),y:L.plotBottom+14,"text-anchor":"middle","font-size":X1,fill:J1},String(Math.round(R*100)/100)));let g=M?G1(J,k):void 0;for(let R=0;R<q.length;R++){let c=y(F[R]),V=x(_[R]),h=U?4+Math.sqrt(f[R]/S)*14:4,p=n("circle",{cx:c,cy:V,r:h,fill:G,"fill-opacity":U?0.6:0.85});if(g){let r=[{label:Q,value:z(F[R]),color:G},{label:Y,value:z(_[R]),color:G},...U?[{label:U,value:z(f[R]),color:G}]:[]],H1=H[0]?.label??"Point";p.addEventListener("mouseenter",()=>e(g,c,V,H1,r)),p.addEventListener("mouseleave",()=>g.tooltip.classList.remove("pf-visible")),p.addEventListener("touchstart",()=>e(g,c,V,H1,r),{passive:!0}),p.addEventListener("touchend",()=>g.tooltip.classList.remove("pf-visible"),{passive:!0})}k.appendChild(p)}return M1(J,H,$.showLegend),J.appendChild(k),J}function e6($,Z){let J=N("div","pf-chart pf-radial-chart"),q=l($.data,Z)??[],Q=$.series??[],Y=$.dataKey??Q[0]?.dataKey,U=$.nameKey??$.tooltipXKey??$.xAxis,H=$.height??300;if(q.length===0||!Y)return J.textContent="No chart data",J;let W=Math.min(H,300),X=W/2,M=W/2,G=W/2-10,E=Math.max(0,Math.min($.innerRadius??30,G-10)),z=$.startAngle??180,F=$.endAngle??0,_=$.showTooltip!==!1,K=q.map((L)=>Number(L[Y]??0)),T=Math.max(...K,1),P=U1(W,W,"Radial"),A=(G-E)/q.length,I=Math.max(2,A*0.7),j=q1($),f=(L)=>j?$1(L,j,Z):String(L),S=_?G1(J,P):void 0,O=[];for(let L=0;L<q.length;L++){let k=G-A*L-A/2,y=Q[L]?.color??s[L%s.length],x=K[L]/T,i=z+x*(F-z),g=U?q[L][U]:null,R=g!=null?b(g):Q[L]?.label??Y;O.push({dataKey:R||Y,label:R||Y,color:y}),P.appendChild(n("path",{d:L0(X,M,k,z,F),fill:"none",stroke:z1,"stroke-width":I,"stroke-linecap":"round"}));let c=n("path",{d:L0(X,M,k,z,i),fill:"none",stroke:y,"stroke-width":I,"stroke-linecap":"round"});if(S){let V=B1(X,M,k,(z+i)/2),h=[{label:Y,value:f(K[L]),color:y}],p=R||Y;c.addEventListener("mouseenter",()=>e(S,V.x,V.y,p,h)),c.addEventListener("mouseleave",()=>S.tooltip.classList.remove("pf-visible")),c.addEventListener("touchstart",()=>e(S,V.x,V.y,p,h),{passive:!0}),c.addEventListener("touchend",()=>S.tooltip.classList.remove("pf-visible"),{passive:!0})}P.appendChild(c)}return M1(J,O,$.showLegend),J.appendChild(P),J}function $5($,Z){let J=N("div","pf-chart pf-radar-chart"),q=l($.data,Z)??[],Q=$.series??[],Y=$.axisKey??$.xAxis,U=$.height??300;if(q.length===0||Q.length===0)return J.textContent="No chart data",J;let H=$.filled!==!1,W=$.showDots===!0,X=$.showGrid!==!1,M=$.showTooltip!==!1,G=Math.min(U,320),E=G/2,z=G/2,F=G/2-24,_=q.length,K=Math.max(...q.flatMap((S)=>Q.map((O)=>Number(S[O.dataKey]??0))),1),T=(S)=>90-360*S/_,P=(S)=>S.map((O)=>`${O.x.toFixed(1)},${O.y.toFixed(1)}`).join(" "),A=U1(G,G,"Radar");if(X){for(let O=1;O<=4;O++){let L=F*O/4,k=Array.from({length:_},(y,x)=>B1(E,z,L,T(x)));A.appendChild(n("polygon",{points:P(k),fill:"none",stroke:z1,"stroke-width":1}))}for(let O=0;O<_;O++){let L=B1(E,z,F,T(O));A.appendChild(n("line",{x1:E,y1:z,x2:L.x,y2:L.y,stroke:z1,"stroke-width":1}))}}for(let S=0;S<_;S++){let O=B1(E,z,F+12,T(S)),L=Y?q[S][Y]:null;A.appendChild(r1({x:O.x,y:O.y+3,"text-anchor":"middle","font-size":X1,fill:J1},L!=null?String(L):""))}let I=M?G1(J,A):void 0,j=q1($),f=(S)=>j?$1(S,j,Z):String(S);for(let S=0;S<Q.length;S++){let O=Q[S],L=O.color??s[S%s.length],k=q.map((y,x)=>B1(E,z,Number(y[O.dataKey]??0)/K*F,T(x)));if(A.appendChild(n("polygon",{points:P(k),fill:H?L:"none","fill-opacity":H?0.2:0,stroke:L,"stroke-width":2})),W||I)for(let y=0;y<k.length;y++){let x=n("circle",{cx:k[y].x,cy:k[y].y,r:W?3:6,fill:W?L:"transparent","fill-opacity":W?1:0});if(I){let i=Y?q[y][Y]:null,g=i!=null?b(i):O.label??O.dataKey,R=[{label:O.label??O.dataKey,value:f(Number(q[y][O.dataKey]??0)),color:L}];x.addEventListener("mouseenter",()=>e(I,k[y].x,k[y].y,g,R)),x.addEventListener("mouseleave",()=>I.tooltip.classList.remove("pf-visible")),x.addEventListener("touchstart",()=>e(I,k[y].x,k[y].y,g,R),{passive:!0}),x.addEventListener("touchend",()=>I.tooltip.classList.remove("pf-visible"),{passive:!0})}A.appendChild(x)}}return M1(J,Q,$.showLegend),J.appendChild(A),J}function Z5($,Z){let J=N("div","pf-chart pf-histogram"),q=l($.data,Z);if(!q||q.length===0)return J.textContent="No data",J;let Q=q,Y=$.bins??10,U=$.height??200,H=$.color??s[0],W=Math.min(...Q),M=(Math.max(...Q)-W)/Y||1,G=Array(Y).fill(0);for(let T of Q){let P=Math.min(Math.floor((T-W)/M),Y-1);G[P]++}let E=Math.max(...G),z=300,F=U,_=z/Y,K=U1(z,F,"Histogram");for(let T=0;T<Y;T++){let P=E>0?G[T]/E*F:0,A=document.createElementNS("http://www.w3.org/2000/svg","rect");A.setAttribute("x",String(T*_)),A.setAttribute("y",String(F-P)),A.setAttribute("width",String(_-1)),A.setAttribute("height",String(P)),A.setAttribute("fill",H),K.appendChild(A)}return J.appendChild(K),J}function K4(){B("Table",J5),B("TableHead",T0("thead")),B("TableBody",T0("tbody")),B("TableFooter",T0("tfoot")),B("TableRow",q5),B("TableHeader",Q5),B("TableCell",Y5),B("TableCaption",U5),B("ExpandableRow",H5)}function J5($,Z){let J=document.createElement("table");return J.className=$.striped===!0?"pf-table pf-table-striped":"pf-table",J.style.width="100%",J.style.borderCollapse="collapse",C($,J,Z),J}function T0($){return(Z,J)=>{let q=document.createElement($);return q.className=`pf-${$}`,C(Z,q,J),q}}function q5($,Z){let J=document.createElement("tr");return J.className="pf-table-row",C($,J,Z),J}function Q5($,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=D($.content,Z),J}function Y5($,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 C($,J,Z),J}function U5($,Z){let J=document.createElement("caption");return J.className="pf-table-caption",J.style.padding="8px",J.style.fontSize="14px",J.textContent=D($.content,Z),J}function H5($,Z){let J=N("div","pf-expandable-row"),q=N("div","pf-expandable-row-summary");q.style.cursor="pointer",q.style.display="flex",q.style.alignItems="center",q.style.gap="8px";let Q=N("span","pf-expandable-arrow");Q.textContent="▶",Q.style.transition="transform 0.2s",Q.style.fontSize="10px",q.appendChild(Q);let Y=$.summary;if(Y)for(let W of Y)q.appendChild(u(W,Z));let U=N("div","pf-expandable-row-detail");U.style.display="none",U.style.paddingLeft="24px",C($,U,Z);let H=!1;return q.addEventListener("click",()=>{H=!H,U.style.display=H?"block":"none",Q.style.transform=H?"rotate(90deg)":""}),J.appendChild(q),J.appendChild(U),J}var F4=!1;function a1(){if(F4)return;F4=!0,l0(),r0(),t0(),e0(),Z4(),q4(),Q4(),H4(),W4(),B4(),z4(),K4()}function I0($){return $.replace(/[^a-zA-Z0-9_-]/g,"")}function P0($){return $.replace(/[{}<>;]/g,"").replace(/\b(url|expression)\s*\(/gi,"")}function O0($,Z=" "){return Object.entries($).map(([J,q])=>`${Z}--${I0(J)}: ${P0(q)};`).join(`
|
|
7
|
+
`)}function D4($){if(!$)return"";let Z=[];if($.light&&Object.keys($.light).length>0)Z.push(`:root {
|
|
8
8
|
${O0($.light)}
|
|
9
9
|
}`);if($.dark&&Object.keys($.dark).length>0){let J=O0($.dark);Z.push(`.dark, [data-theme="dark"] {
|
|
10
10
|
${J}
|
|
@@ -13,4 +13,4 @@ ${J}
|
|
|
13
13
|
${O0($.dark," ")}
|
|
14
14
|
}
|
|
15
15
|
}`)}return Z.join(`
|
|
16
|
-
`)}function K1($,Z){$.setAttribute("data-theme",Z),$.classList.toggle("dark",Z==="dark"),$.classList.toggle("light",Z==="light")}function P0($,Z){if(!Z)return;if(Z.light)for(let[J,q]of Object.entries(Z.light))$.style.setProperty(`--${T0(J)}`,I0(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=K8({dark:Z.dark})}}function V0($,Z){if(!$||typeof document>"u")return;let J=(q)=>{for(let[Q,Y]of Object.entries($))if(q5(Q,q))q.preventDefault(),Z(Y)};return document.addEventListener("keydown",J),()=>document.removeEventListener("keydown",J)}function q5($,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 L8='<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>',F8='<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>',D8={"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 Q5($,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 V1($,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=D8[J]??D8["top-right"];for(let X of W.split(";")){let[B,K]=X.split(":").map((F)=>F.trim());if(B&&K)U.style.setProperty(B,K)}U.addEventListener("mouseenter",()=>{U.style.opacity="1"}),U.addEventListener("mouseleave",()=>{U.style.opacity="0.7"});function H(X){if(K1($,X),Q)K1(document.documentElement,X);U.innerHTML=X==="dark"?F8:L8;try{localStorage.setItem(q,X)}catch{}}let _=Q5($,q);H(_),U.addEventListener("click",()=>{let X=$.getAttribute("data-theme")??"dark";H(X==="dark"?"light":"dark")}),$.appendChild(U);let z;if(Q)z=new MutationObserver((X)=>{for(let B of X)if(B.type==="attributes"&&B.attributeName==="data-theme"){let K=document.documentElement.getAttribute("data-theme");if((K==="light"||K==="dark")&&K!==$.getAttribute("data-theme")){K1($,K),U.innerHTML=K==="dark"?F8:L8;try{localStorage.setItem(q,K)}catch{}}}}),z.observe(document.documentElement,{attributes:!0,attributeFilter:["data-theme"]});return()=>{z?.disconnect(),U.remove()}}function a1($){let Z=$?.baseUrl??(typeof window<"u"?window.location.origin:""),J={"Content-Type":"application/json",...$?.headers},q=$?.fetch??globalThis.fetch.bind(globalThis);return{async callTool(Q,Y){let U=await q(`${Z}/mcp/tools/call`,{method:"POST",headers:J,body:JSON.stringify({jsonrpc:"2.0",method:"tools/call",params:{name:Q,arguments:Y}})});if(!U.ok)throw Error(`MCP tool call failed: ${U.status} ${U.statusText}`);let W=await U.json();if(W.error)throw Error(W.error.message??"MCP tool call returned error");let H=W.result?.content??W.content??[];for(let _ of H)if(_.type==="text"&&_.text!==void 0){try{let z=JSON.parse(_.text);if(typeof z==="object"&&z!==null&&"$prefab"in z)return z;return z}catch{}return _.text}return W.result??W},async sendMessage(Q){await q(`${Z}/mcp/messages`,{method:"POST",headers:J,body:JSON.stringify({message:Q})})}}}function o1(){return{callTool($){return C.warn(`No MCP transport: callTool('${$}') ignored`),Promise.resolve(null)},sendMessage($){return C.warn("No MCP transport: sendMessage ignored",$),Promise.resolve()}}}var O8="0.3.7";function Y5($){return $!==null&&typeof $==="object"&&$.jsonrpc==="2.0"}class _1{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 $=H5();if($)this.postFn=(J)=>$.postMessage(J);let Z=(J)=>{if(this.hostOrigin!=="*"&&J.origin!==this.hostOrigin)return;let q=J.data;if(Y5(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 U5;let Z=-1,J=-1,q=(U,W)=>{if(U===Z&&W===J)return;if(Z=U,J=W,this.protocol==="jsonrpc")this.sendRpcNotification("ui/notifications/size-changed",{width:U,height:W});else this.sendPrefab("prefab:size-changed",{width:U,height:W})},Q=new ResizeObserver((U)=>{for(let W of U)if(W.borderBoxSize.length){let H=W.borderBoxSize[0];q(Math.ceil(H.inlineSize),Math.ceil(H.blockSize))}else{let H=W.target.getBoundingClientRect();q(Math.ceil(H.width),Math.ceil(H.height))}});Q.observe($);let Y=$.getBoundingClientRect();return q(Math.ceil(Y.width),Math.ceil(Y.height)),()=>Q.disconnect()}notifyPreferredSize($){if(this.protocol==="jsonrpc")this.sendRpcNotification("ui/notifications/preferred-size",$);else this.sendPrefab("prefab:preferred-size",$)}subscribe($,Z){let J=(q)=>{if(q.uri!==$)return;Z(q.contents??q.data??q)};if(this.protocol==="jsonrpc")this.on("prefab:resource-updated",J),this.sendRpcRequest("resources/subscribe",{uri:$});else this.on("prefab:resource-updated",J),this.sendPrefab("prefab:subscribe",{uri:$});return()=>{if(this.off("prefab:resource-updated",J),this.protocol==="jsonrpc")this.sendRpcRequest("resources/unsubscribe",{uri:$});else this.sendPrefab("prefab:unsubscribe",{uri:$})}}get supportsSubscriptions(){return this._hostSupportsSubscriptions}on($,Z){if(!this.listeners.has($))this.listeners.set($,new Set);let J=this.listeners.get($);if(J)J.add(Z)}off($,Z){this.listeners.get($)?.delete(Z)}disconnect(){this.cleanup?.(),this.listeners.clear();for(let[,$]of this.pending)$.reject(Error("Bridge disconnected"));this.pending.clear();for(let[,$]of this.rpcPending)$.reject(Error("Bridge disconnected"));this.rpcPending.clear(),this.sentRpcIds.clear()}get activeProtocol(){return this.protocol}initPrefab($){return new Promise((Z,J)=>{let q=!1,Q=(Y)=>{if(q)return;q=!0,this.off("prefab:init-response",Q),this.protocol="prefab";let U=Y.capabilities;this._hostSupportsSubscriptions=U?.subscriptions===!0,Z(Y)};this.on("prefab:init-response",Q),this.sendPrefab("prefab:init",{capabilities:$}),setTimeout(()=>{if(!q)q=!0,this.off("prefab:init-response",Q),J(Error("prefab:init timeout"))},2000)})}createPrefabTransport(){return{callTool:($,Z)=>{let J=`tc-${++this.callIdCounter}`;return new Promise((q,Q)=>{this.pending.set(J,{resolve:q,reject:Q}),this.sendPrefab("prefab:tool-call",{tool:$,arguments:Z},J),setTimeout(()=>{if(this.pending.has(J))this.pending.delete(J),Q(Error(`Tool call '${$}' timed out`))},30000)})},sendMessage:($)=>{return this.sendPrefab("prefab:send-message",{message:$}),Promise.resolve()},subscribe:($,Z)=>{return this.subscribe($,Z)},capabilities:{subscriptions:this._hostSupportsSubscriptions}}}sendPrefab($,Z,J){if(typeof window>"u")return;let q=window.parent!==window?window.parent:window,Q={type:$,payload:Z,id:J};q.postMessage(Q,this.hostOrigin)}handleJsonRpc($){if(!("method"in $)){let q=this.rpcPending.get($.id);if(q)if(this.rpcPending.delete($.id),$.error)q.reject(Error($.error.message));else q.resolve($.result);return}let Z=$.method,J=$.params??{};if($.id!=null&&this.sentRpcIds.delete($.id))return;if($.id!=null)this.postJsonRpc({jsonrpc:"2.0",id:$.id,result:{}});switch(Z){case"ui/notifications/tool-input":this.dispatch("prefab:tool-input",{args:J.arguments??J});break;case"ui/notifications/tool-input-partial":this.dispatch("prefab:tool-input-partial",{args:J.arguments??J});break;case"ui/notifications/tool-result":this.dispatch("prefab:tool-result",{result:J});break;case"ui/notifications/tool-cancelled":this.dispatch("prefab:tool-cancelled",J);break;case"ui/notifications/host-context-changed":{let q={};if(typeof J.theme==="string")q.colorScheme=J.theme;if(typeof J.styles==="object"&&J.styles!==null){let Q=J.styles;if(Q.variables)q.variables=Q.variables;if(typeof Q.css?.fonts==="string")q.fontCss=Q.css.fonts}this.dispatch("prefab:theme-update",q),this.dispatch("prefab:host-context-changed",J);break}case"ui/resource-teardown":this.dispatch("prefab:teardown",J);break;case"ui/notifications/resource-updated":case"notifications/resources/updated":this.dispatch("prefab:resource-updated",J);break}}initJsonRpc($){return new Promise((Z,J)=>{let q=++this.rpcIdCounter,Q=!1;this.rpcPending.set(q,{resolve:(Y)=>{if(Q)return;Q=!0,this.protocol="jsonrpc";let U=Y??{},W=U.hostInfo??{},H=U.hostContext??{},_=U.hostCapabilities??{},z;if(typeof H.theme==="string"||typeof H.styles==="object"){if(z={},typeof H.theme==="string")z.colorScheme=H.theme;if(typeof H.styles==="object"&&H.styles!==null){let B=H.styles;if(B.variables)z.variables=B.variables;if(typeof B.css?.fonts==="string")z.fontCss=B.css.fonts}}this.postJsonRpc({jsonrpc:"2.0",method:"ui/notifications/initialized",params:{}});let X=_.resources;this._hostSupportsSubscriptions=_.subscriptions===!0||X?.subscribe===!0,Z({hostName:W.name,hostVersion:W.version,capabilities:{toast:!0,navigation:_.openLinks!=null,messaging:!0,displayModes:H.availableDisplayModes??[]},theme:z,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:O8},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 U5=()=>{};function R1($,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)W5(Z.fontCss)}function W5($){if(document.getElementById("__prefab-host-fonts"))return;let J=document.createElement("style");J.id="__prefab-host-fonts",J.textContent=$,document.head.appendChild(J)}function L1(){if(typeof window>"u")return!1;try{return window.self!==window.top}catch{return!0}}function H5(){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 t1($){r1();let Z=$?.mode??"auto",J=Z==="bridge"||Z==="auto"&&L1(),q,Q,Y={capabilities:{}};if(J)Q=new _1($?.hostOrigin),Q.connect(),Y=await Q.initialize($?.capabilities??{toolInput:!0}),q=Q.createTransport();else if($?.transport)q=a1($.transport);else q=o1();if(Y.theme&&typeof document<"u")R1(document.documentElement,Y.theme);if(typeof document<"u"&&!Q)G5();let U,W,H,_,z,X=Y.toolInput,B;if(Q)Q.on("prefab:tool-input",(M)=>{let E=M.args??M;if(U)U(E);else X=E}),Q.on("prefab:tool-result",(M)=>{let E=M.result??M;if(W)W(E);else B=E}),Q.on("prefab:tool-cancelled",()=>{H?.()}),Q.on("prefab:tool-input-partial",(M)=>{_?.(M.args??M)}),Q.on("prefab:theme-update",(M)=>{if(typeof document<"u")R1(document.documentElement,M)}),Q.on("prefab:host-context-changed",(M)=>{z?.(M)});function K(M,...E){let O=R0(M),P=new D1,A={store:P,scope:{},transport:q,rerender:()=>I(),onToast:void 0};function I(){O.innerHTML="";for(let j of E)O.appendChild(u(j,A))}return I(),{rerender:I,store:P,destroy:()=>{O.innerHTML=""}}}return{callTool:(M,E={})=>q.callTool(M,E),sendMessage:(M)=>q.sendMessage(M),onToolInput:(M)=>{if(U=M,X){let E=X;X=void 0,queueMicrotask(()=>M(E))}},onToolResult:(M)=>{if(W=M,B!==void 0){let E=B;B=void 0,queueMicrotask(()=>M(E))}},onToolCancelled:(M)=>{H=M},onToolInputPartial:(M)=>{_=M},onHostContextChanged:(M)=>{z=M},render:K,mount:(M,E,O)=>{let P=R0(M);return Z1.mount(P,E,{transport:q,...O})},requestMode:(M)=>Q?.requestMode(M),openLink:(M,E)=>{if(Q)Q.openLink(M,E);else if(typeof window<"u")window.open(M,E??"_blank")},updateContext:(M)=>{if(Q)Q.updateContext(M)},setupAutoResize:(M)=>{if(!Q)return X5;let E=typeof M==="string"?R0(M):M;return Q.setupAutoResize(E)},notifyPreferredSize:(M)=>{if(Q)Q.notifyPreferredSize(M)},host:Y,capabilities:Y.capabilities,theme:Y.theme,transport:q,destroy:()=>Q?.disconnect()}}var X5=()=>{};function R0($){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 G5(){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 P8=new Set(["Column","Row","Grid","GridItem","Container","Div","Span","Dashboard","DashboardItem","Pages","Page","Heading","H1","H2","H3","H4","Text","P","Lead","Large","Small","Muted","BlockQuote","Label","Link","Code","Markdown","Kbd","Card","CardHeader","CardTitle","CardDescription","CardContent","CardFooter","DataTable","Badge","Dot","Metric","Ring","Progress","Separator","Loader","Icon","Table","TableHead","TableBody","TableFooter","TableRow","TableHeader","TableCell","TableCaption","ExpandableRow","Form","Input","Textarea","Button","ButtonGroup","Select","SelectOption","SelectGroup","SelectLabel","SelectSeparator","Checkbox","Switch","Slider","Radio","RadioGroup","Combobox","ComboboxOption","ComboboxGroup","ComboboxLabel","ComboboxSeparator","Calendar","DatePicker","Field","FieldTitle","FieldDescription","FieldContent","FieldError","ChoiceCard","Tabs","Tab","Accordion","AccordionItem","Dialog","Popover","Tooltip","HoverCard","Carousel","ForEach","If","Elif","Else","Define","Use","Slot","Alert","AlertTitle","AlertDescription","Image","Audio","Video","Embed","Svg","DropZone","Mermaid","BarChart","LineChart","AreaChart","PieChart","RadarChart","ScatterChart","Sparkline","RadialChart","Histogram"]);function F1($,Z={}){let J=[],q=Z.strict??!1;if($==null||typeof $!=="object")return J.push({path:"$",message:"Wire data must be a non-null object"}),{valid:!1,errors:J};let Q=$;if(Q.$prefab==null||typeof Q.$prefab!=="object")J.push({path:"$.$prefab",message:"Missing or invalid $prefab header"});else if(typeof Q.$prefab.version!=="string")J.push({path:"$.$prefab.version",message:"version must be a string"});if(Q.view==null)J.push({path:"$.view",message:'Missing required "view" field'});else j0(Q.view,"$.view",J,q);if(Q.state!==void 0){if(Q.state===null||typeof Q.state!=="object"||Array.isArray(Q.state))J.push({path:"$.state",message:"state must be a plain object"})}if(Q.theme!==void 0)M5(Q.theme,J);if(Q.css!==void 0)I8(Q.css,"$.css",J);if(Q.stylesheets!==void 0)I8(Q.stylesheets,"$.stylesheets",J);if(Q.mode!==void 0&&Q.mode!=="light"&&Q.mode!=="dark")J.push({path:"$.mode",message:'mode must be "light" or "dark"'});if(Q.defs!==void 0)if(Q.defs===null||typeof Q.defs!=="object"||Array.isArray(Q.defs))J.push({path:"$.defs",message:"defs must be a plain object"});else for(let[Y,U]of Object.entries(Q.defs))j0(U,`$.defs.${Y}`,J,q);if(Q.keyBindings!==void 0)if(Q.keyBindings===null||typeof Q.keyBindings!=="object"||Array.isArray(Q.keyBindings))J.push({path:"$.keyBindings",message:"keyBindings must be a plain object"});else for(let[Y,U]of Object.entries(Q.keyBindings))k0(U,`$.keyBindings.${Y}`,J);return{valid:J.length===0,errors:J}}function V8($){return F1($).valid}function j0($,Z,J,q){if($==null||typeof $!=="object"||Array.isArray($)){J.push({path:Z,message:"Component must be a plain object"});return}let Q=$;if(typeof Q.type!=="string"||Q.type.length===0){J.push({path:`${Z}.type`,message:'Component must have a non-empty "type" string'});return}if(q&&!P8.has(Q.type))J.push({path:`${Z}.type`,message:`Unknown component type: "${Q.type}"`});if(Q.children!==void 0)if(!Array.isArray(Q.children))J.push({path:`${Z}.children`,message:"children must be an array"});else for(let U=0;U<Q.children.length;U++)j0(Q.children[U],`${Z}.children[${U}]`,J,q);let Y=["onClick","on_click","onChange","on_change","onSubmit","on_submit","onMount","on_mount","onClose","on_close"];for(let U of Y)if(Q[U]!==void 0)k0(Q[U],`${Z}.${U}`,J);for(let[U,W]of Object.entries(Q)){if(U==="type"||B5.has(U)||Y.includes(U))continue;if(T8(W)||Array.isArray(W)&&W.some(T8))J.push({path:`${Z}.${U}`,message:`Components under "${U}" are ignored by the renderer; move them into "children"`})}}var B5=new Set(["children","fallback","trigger","empty","else","summary"]);function T8($){if($==null||typeof $!=="object"||Array.isArray($))return!1;let Z=$.type;return typeof Z==="string"&&P8.has(Z)}function k0($,Z,J){if(Array.isArray($)){for(let W=0;W<$.length;W++)k0($[W],`${Z}[${W}]`,J);return}if($==null||typeof $!=="object"){J.push({path:Z,message:"Action must be an object or array of objects"});return}let q=$,Q=typeof q.type==="string"&&q.type.length>0,Y=typeof q.action==="string"&&q.action.length>0;if(!Q&&!Y){J.push({path:`${Z}.type`,message:'Action must have a non-empty "type" or "action" string'});return}if((Y?q.action:q.type).toLowerCase()==="showtoast"){if(typeof q.message!=="string"||q.message.length===0)J.push({path:`${Z}.message`,message:'showToast requires a non-empty "message" string'})}}function I8($,Z,J){if(!Array.isArray($)){J.push({path:Z,message:`${Z} must be an array of strings`});return}for(let q=0;q<$.length;q++)if(typeof $[q]!=="string")J.push({path:`${Z}[${q}]`,message:"must be a string"})}function M5($,Z){if($===null||typeof $!=="object"||Array.isArray($)){Z.push({path:"$.theme",message:"theme must be a plain object"});return}let J=$;for(let q of["light","dark"])if(J[q]!==void 0){if(J[q]===null||typeof J[q]!=="object"||Array.isArray(J[q]))Z.push({path:`$.theme.${q}`,message:`theme.${q} must be a plain object`})}}var Z1={mount($,Z,J){if(r1(),J?.validate!==!1)for(let E of F1(Z).errors)C.warn(`wire validation ${E.path}: ${E.message}`);let q=Z,Q={tracked:[],evalBlocked:!1};if(q.pipes)for(let[E,O]of Object.entries(q.pipes))R8(E,O,Q);let Y=new D1(q.state),U;if(J?.transport&&"callTool"in J.transport)U=J.transport;else if(J?.transport)U=a1(J.transport);else U=o1();let W=J?.onToast??z5,H=new I1;function _(E){let O=E;if(q=O,O.state)Y.merge(O.state);if(O.defs)z.defs=O.defs;if(O.theme)P0($,O.theme);if(O.mode)j8($,O.mode);if(O.pipes)for(let[P,A]of Object.entries(O.pipes))R8(P,A,Q);for(let P of X)P.remove();if(X.length=0,X.push(...k8(O.css,O.stylesheets)),A8($,O.layout),B?.(),B=void 0,O.keyBindings)B=V0(O.keyBindings,(P)=>{v(h(P,{store:Y,transport:U,scope:{},rerender:()=>M(),remount:_,onToast:W}),"keyBinding")});M()}let z={store:Y,scope:{},transport:U,rerender:()=>M(),remount:_,onToast:W,defs:q.defs,destroyRegistry:H};if(P0($,q.theme),q.mode)j8($,q.mode);A8($,q.layout);let X=k8(q.css,q.stylesheets),B;if(q.keyBindings)B=V0(q.keyBindings,(E)=>{v(h(E,{store:Y,transport:U,scope:{},rerender:()=>M(),remount:_,onToast:W}),"keyBinding")});let K,F=J?.themeToggle??!0;if(F!==!1)K=V1($,typeof F==="object"?F:void 0);function M(){H.flush();let E=$.querySelector(".pf-theme-toggle");$.innerHTML="";let O=u(q.view,z);if($.appendChild(O),E)$.appendChild(E)}return M(),{rerender:()=>M(),update(E){if(Y.merge(E.update.state),M(),E.update.actions!=null)v(h(E.update.actions,z),"update action")},store:Y,destroy(){H.flush(),K?.(),B?.(),h0(),v0();for(let E of X)E.remove();for(let E of Q.tracked)T1(E);$.innerHTML=""}}},isPrefabData($){return $!=null&&typeof $==="object"&&"$prefab"in $},isPrefabUpdate($){return $!=null&&typeof $==="object"&&"$prefab"in $&&"update"in $}},_5=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 N5($){if($ instanceof EvalError)return!0;return $ instanceof Error&&/unsafe-eval|Content Security Policy|call to Function/i.test($.message)}function R8($,Z,J){if(_5.has($)){C.warn(`wire pipe "${$}" ignored — shadows built-in`);return}if(A1($)!=null){C.debug(`wire pipe "${$}" — already registered, keeping local implementation`);return}if(J.evalBlocked)return;try{let q=Function("return ("+Z+")")();if(typeof q!=="function"){C.warn(`wire pipe "${$}" — source did not evaluate to a function`);return}O1($,q),J.tracked.push($)}catch(q){if(N5(q)){J.evalBlocked=!0,C.warn("wire pipes cannot be hydrated — this host's CSP forbids eval. Pre-register them with "+"prefab.registerPipe() from a companion script (rendererHtml({ scripts })) and they are used as-is.");return}C.warn(`wire pipe "${$}" — failed to hydrate:`,q)}}function z5($){if(typeof document>"u")return;let Z=K5(),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 j8($,Z){if(K1($,Z),typeof document<"u")K1(document.documentElement,Z)}function E5($){let Z=$.trim();if(Z.includes("{")||Z.includes("}"))return!1;return/^(https?:)?\/\//i.test(Z)||Z.startsWith("/")||/\.css(\?|#|$)/i.test(Z)}function k8($,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(E5(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 A8($,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 K5(){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=Z1,$.prefab={app:t1,mount:Z1.mount.bind(Z1),isPrefabData:Z1.isPrefabData.bind(Z1),isPrefabUpdate:Z1.isPrefabUpdate.bind(Z1),Bridge:_1,isIframe:L1,registerPipe:O1,unregisterPipe:T1,listPipes:k1,registerComponent:G,createThemeToggle:V1,validateWireFormat:F1,setLogLevel:j1};let Z=$.__PREFAB_DATA__;if(Z!=null){let J=document.getElementById("prefab-root");if(J)Z1.mount(J,Z)}}})();
|
|
16
|
+
`)}function K1($,Z){$.setAttribute("data-theme",Z),$.classList.toggle("dark",Z==="dark"),$.classList.toggle("light",Z==="light")}function R0($,Z){if(!Z)return;if(Z.light)for(let[J,q]of Object.entries(Z.light))$.style.setProperty(`--${I0(J)}`,P0(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=D4({dark:Z.dark})}}function V0($,Z){if(!$||typeof document>"u")return;let J=(q)=>{for(let[Q,Y]of Object.entries($))if(W5(Q,q))q.preventDefault(),Z(Y)};return document.addEventListener("keydown",J),()=>document.removeEventListener("keydown",J)}function W5($,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 L4='<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>',T4='<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>',O4={"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 G5($,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 j1($,Z){if(typeof document>"u")return()=>{};let J=Z?.position??"top-right",q=Z?.storageKey??"prefab-theme",Q=Z?.syncDocument??!0,Y=getComputedStyle($).position;if(Y==="static"||Y==="")$.style.position="relative";let U=document.createElement("button");U.className="pf-theme-toggle",U.setAttribute("aria-label","Toggle theme"),U.setAttribute("title","Toggle light/dark"),Object.assign(U.style,{position:"absolute",zIndex:"100",width:"28px",height:"28px",border:"1px solid var(--border, #e5e7eb)",borderRadius:"6px",background:"var(--card, rgba(255,255,255,0.8))",color:"var(--foreground, #333)",cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",padding:"0",opacity:"0.7",transition:"opacity 0.15s, border-color 0.15s"});let H=O4[J]??O4["top-right"];for(let G of H.split(";")){let[E,z]=G.split(":").map((F)=>F.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 W(G){if(K1($,G),Q)K1(document.documentElement,G);U.innerHTML=G==="dark"?T4:L4;try{localStorage.setItem(q,G)}catch{}}let X=G5($,q);W(X),U.addEventListener("click",()=>{let G=$.getAttribute("data-theme")??"dark";W(G==="dark"?"light":"dark")}),$.appendChild(U);let M;if(Q)M=new MutationObserver((G)=>{for(let E of G)if(E.type==="attributes"&&E.attributeName==="data-theme"){let z=document.documentElement.getAttribute("data-theme");if((z==="light"||z==="dark")&&z!==$.getAttribute("data-theme")){K1($,z),U.innerHTML=z==="dark"?T4:L4;try{localStorage.setItem(q,z)}catch{}}}}),M.observe(document.documentElement,{attributes:!0,attributeFilter:["data-theme"]});return()=>{M?.disconnect(),U.remove()}}function o1($){let Z=$?.baseUrl??(typeof window<"u"?window.location.origin:""),J={"Content-Type":"application/json",...$?.headers},q=$?.fetch??globalThis.fetch.bind(globalThis);return{async callTool(Q,Y){let U=await q(`${Z}/mcp/tools/call`,{method:"POST",headers:J,body:JSON.stringify({jsonrpc:"2.0",method:"tools/call",params:{name:Q,arguments:Y}})});if(!U.ok)throw Error(`MCP tool call failed: ${U.status} ${U.statusText}`);let H=await U.json();if(H.error)throw Error(H.error.message??"MCP tool call returned error");let W=H.result?.content??H.content??[];for(let X of W)if(X.type==="text"&&X.text!==void 0){try{let M=JSON.parse(X.text);if(typeof M==="object"&&M!==null&&"$prefab"in M)return M;return M}catch{}return X.text}return H.result??H},async sendMessage(Q){await q(`${Z}/mcp/messages`,{method:"POST",headers:J,body:JSON.stringify({message:Q})})}}}function t1(){return{callTool($){return w.warn(`No MCP transport: callTool('${$}') ignored`),Promise.resolve(null)},sendMessage($){return w.warn("No MCP transport: sendMessage ignored",$),Promise.resolve()}}}var I4="0.3.9";function X5($){return $!==null&&typeof $==="object"&&$.jsonrpc==="2.0"}class _1{hostOrigin;listeners=new Map;protocol="prefab";cleanup;pending=new Map;callIdCounter=0;rpcPending=new Map;rpcIdCounter=0;sentRpcIds=new Set;postFn;_hostSupportsSubscriptions=!1;constructor($="*"){this.hostOrigin=$}connect(){if(typeof window>"u")return;let $=_5();if($)this.postFn=(J)=>$.postMessage(J);let Z=(J)=>{if(this.hostOrigin!=="*"&&J.origin!==this.hostOrigin)return;let q=J.data;if(X5(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 B5;let Z=-1,J=-1,q=(U,H)=>{if(U===Z&&H===J)return;if(Z=U,J=H,this.protocol==="jsonrpc")this.sendRpcNotification("ui/notifications/size-changed",{width:U,height:H});else this.sendPrefab("prefab:size-changed",{width:U,height:H})},Q=new ResizeObserver((U)=>{for(let H of U)if(H.borderBoxSize.length){let W=H.borderBoxSize[0];q(Math.ceil(W.inlineSize),Math.ceil(W.blockSize))}else{let W=H.target.getBoundingClientRect();q(Math.ceil(W.width),Math.ceil(W.height))}});Q.observe($);let Y=$.getBoundingClientRect();return q(Math.ceil(Y.width),Math.ceil(Y.height)),()=>Q.disconnect()}notifyPreferredSize($){if(this.protocol==="jsonrpc")this.sendRpcNotification("ui/notifications/preferred-size",$);else this.sendPrefab("prefab:preferred-size",$)}subscribe($,Z){let J=(q)=>{if(q.uri!==$)return;Z(q.contents??q.data??q)};if(this.protocol==="jsonrpc")this.on("prefab:resource-updated",J),this.sendRpcRequest("resources/subscribe",{uri:$});else this.on("prefab:resource-updated",J),this.sendPrefab("prefab:subscribe",{uri:$});return()=>{if(this.off("prefab:resource-updated",J),this.protocol==="jsonrpc")this.sendRpcRequest("resources/unsubscribe",{uri:$});else this.sendPrefab("prefab:unsubscribe",{uri:$})}}get supportsSubscriptions(){return this._hostSupportsSubscriptions}on($,Z){if(!this.listeners.has($))this.listeners.set($,new Set);let J=this.listeners.get($);if(J)J.add(Z)}off($,Z){this.listeners.get($)?.delete(Z)}disconnect(){this.cleanup?.(),this.listeners.clear();for(let[,$]of this.pending)$.reject(Error("Bridge disconnected"));this.pending.clear();for(let[,$]of this.rpcPending)$.reject(Error("Bridge disconnected"));this.rpcPending.clear(),this.sentRpcIds.clear()}get activeProtocol(){return this.protocol}initPrefab($){return new Promise((Z,J)=>{let q=!1,Q=(Y)=>{if(q)return;q=!0,this.off("prefab:init-response",Q),this.protocol="prefab";let U=Y.capabilities;this._hostSupportsSubscriptions=U?.subscriptions===!0,Z(Y)};this.on("prefab:init-response",Q),this.sendPrefab("prefab:init",{capabilities:$}),setTimeout(()=>{if(!q)q=!0,this.off("prefab:init-response",Q),J(Error("prefab:init timeout"))},2000)})}createPrefabTransport(){return{callTool:($,Z)=>{let J=`tc-${++this.callIdCounter}`;return new Promise((q,Q)=>{this.pending.set(J,{resolve:q,reject:Q}),this.sendPrefab("prefab:tool-call",{tool:$,arguments:Z},J),setTimeout(()=>{if(this.pending.has(J))this.pending.delete(J),Q(Error(`Tool call '${$}' timed out`))},30000)})},sendMessage:($)=>{return this.sendPrefab("prefab:send-message",{message:$}),Promise.resolve()},subscribe:($,Z)=>{return this.subscribe($,Z)},capabilities:{subscriptions:this._hostSupportsSubscriptions}}}sendPrefab($,Z,J){if(typeof window>"u")return;let q=window.parent!==window?window.parent:window,Q={type:$,payload:Z,id:J};q.postMessage(Q,this.hostOrigin)}handleJsonRpc($){if(!("method"in $)){let q=this.rpcPending.get($.id);if(q)if(this.rpcPending.delete($.id),$.error)q.reject(Error($.error.message));else q.resolve($.result);return}let Z=$.method,J=$.params??{};if($.id!=null&&this.sentRpcIds.delete($.id))return;if($.id!=null)this.postJsonRpc({jsonrpc:"2.0",id:$.id,result:{}});switch(Z){case"ui/notifications/tool-input":this.dispatch("prefab:tool-input",{args:J.arguments??J});break;case"ui/notifications/tool-input-partial":this.dispatch("prefab:tool-input-partial",{args:J.arguments??J});break;case"ui/notifications/tool-result":this.dispatch("prefab:tool-result",{result:J});break;case"ui/notifications/tool-cancelled":this.dispatch("prefab:tool-cancelled",J);break;case"ui/notifications/host-context-changed":{let q={};if(typeof J.theme==="string")q.colorScheme=J.theme;if(typeof J.styles==="object"&&J.styles!==null){let Q=J.styles;if(Q.variables)q.variables=Q.variables;if(typeof Q.css?.fonts==="string")q.fontCss=Q.css.fonts}this.dispatch("prefab:theme-update",q),this.dispatch("prefab:host-context-changed",J);break}case"ui/resource-teardown":this.dispatch("prefab:teardown",J);break;case"ui/notifications/resource-updated":case"notifications/resources/updated":this.dispatch("prefab:resource-updated",J);break}}initJsonRpc($){return new Promise((Z,J)=>{let q=++this.rpcIdCounter,Q=!1;this.rpcPending.set(q,{resolve:(Y)=>{if(Q)return;Q=!0,this.protocol="jsonrpc";let U=Y??{},H=U.hostInfo??{},W=U.hostContext??{},X=U.hostCapabilities??{},M;if(typeof W.theme==="string"||typeof W.styles==="object"){if(M={},typeof W.theme==="string")M.colorScheme=W.theme;if(typeof W.styles==="object"&&W.styles!==null){let E=W.styles;if(E.variables)M.variables=E.variables;if(typeof E.css?.fonts==="string")M.fontCss=E.css.fonts}}this.postJsonRpc({jsonrpc:"2.0",method:"ui/notifications/initialized",params:{}});let G=X.resources;this._hostSupportsSubscriptions=X.subscriptions===!0||G?.subscribe===!0,Z({hostName:H.name,hostVersion:H.version,capabilities:{toast:!0,navigation:X.openLinks!=null,messaging:!0,displayModes:W.availableDisplayModes??[]},theme:M,toolInput:void 0,meta:W})},reject:(Y)=>{if(Q)return;Q=!0,J(Y)}}),this.postJsonRpc({jsonrpc:"2.0",id:q,method:"ui/initialize",params:{protocolVersion:"2026-01-26",appInfo:{name:"prefab",version:I4},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 B5=()=>{};function k1($,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)M5(Z.fontCss)}function M5($){if(document.getElementById("__prefab-host-fonts"))return;let J=document.createElement("style");J.id="__prefab-host-fonts",J.textContent=$,document.head.appendChild(J)}function F1(){if(typeof window>"u")return!1;try{return window.self!==window.top}catch{return!0}}function _5(){if(typeof window>"u")return;let $=window;if(typeof $.acquireVsCodeApi==="function")try{let Z=$.acquireVsCodeApi();if(Z!==null&&typeof Z==="object"&&"postMessage"in Z)return Z}catch{return}return}async function e1($){a1();let Z=$?.mode??"auto",J=Z==="bridge"||Z==="auto"&&F1(),q,Q,Y={capabilities:{}};if(J)Q=new _1($?.hostOrigin),Q.connect(),Y=await Q.initialize($?.capabilities??{toolInput:!0}),q=Q.createTransport();else if($?.transport)q=o1($.transport);else q=t1();if(Y.theme&&typeof document<"u")k1(document.documentElement,Y.theme);if(typeof document<"u"&&!Q)E5();let U,H,W,X,M,G=Y.toolInput,E;if(Q)Q.on("prefab:tool-input",(_)=>{let K=_.args??_;if(U)U(K);else G=K}),Q.on("prefab:tool-result",(_)=>{let K=_.result??_;if(H)H(K);else E=K}),Q.on("prefab:tool-cancelled",()=>{W?.()}),Q.on("prefab:tool-input-partial",(_)=>{X?.(_.args??_)}),Q.on("prefab:theme-update",(_)=>{if(typeof document<"u")k1(document.documentElement,_)}),Q.on("prefab:host-context-changed",(_)=>{M?.(_)});function z(_,...K){let T=j0(_),P=new L1,A={store:P,scope:{},transport:q,rerender:()=>I(),onToast:void 0};function I(){T.innerHTML="";for(let j of K)T.appendChild(u(j,A))}return I(),{rerender:I,store:P,destroy:()=>{T.innerHTML=""}}}return{callTool:(_,K={})=>q.callTool(_,K),sendMessage:(_)=>q.sendMessage(_),onToolInput:(_)=>{if(U=_,G){let K=G;G=void 0,queueMicrotask(()=>_(K))}},onToolResult:(_)=>{if(H=_,E!==void 0){let K=E;E=void 0,queueMicrotask(()=>_(K))}},onToolCancelled:(_)=>{W=_},onToolInputPartial:(_)=>{X=_},onHostContextChanged:(_)=>{M=_},render:z,mount:(_,K,T)=>{let P=j0(_);return Z1.mount(P,K,{transport:q,...T})},requestMode:(_)=>Q?.requestMode(_),openLink:(_,K)=>{if(Q)Q.openLink(_,K);else if(typeof window<"u")window.open(_,K??"_blank")},updateContext:(_)=>{if(Q)Q.updateContext(_)},setupAutoResize:(_)=>{if(!Q)return N5;let K=typeof _==="string"?j0(_):_;return Q.setupAutoResize(K)},notifyPreferredSize:(_)=>{if(Q)Q.notifyPreferredSize(_)},host:Y,capabilities:Y.capabilities,theme:Y.theme,transport:q,destroy:()=>Q?.disconnect()}}var N5=()=>{};function j0($){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 E5(){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 P4=["Accordion","AccordionItem","Alert","AlertDescription","AlertTitle","AreaChart","Audio","Badge","BarChart","BlockQuote","Button","ButtonGroup","Calendar","Card","CardContent","CardDescription","CardFooter","CardHeader","CardTitle","Carousel","Checkbox","ChoiceCard","Code","Column","Combobox","ComboboxGroup","ComboboxLabel","ComboboxOption","ComboboxSeparator","Condition","Container","Dashboard","DashboardItem","DataTable","DatePicker","Define","Detail","Dialog","Div","Dot","DropZone","Elif","Else","Embed","ExpandableRow","Field","FieldContent","FieldDescription","FieldError","FieldTitle","ForEach","Form","Grid","GridItem","H1","H2","H3","H4","Heading","Histogram","HoverCard","Icon","If","Image","Input","Kbd","Label","Large","Lead","LineChart","Link","Loader","Markdown","MasterDetail","Mermaid","Metric","Muted","P","Page","Pages","PdfViewer","PieChart","Popover","Progress","RadarChart","RadialChart","Radio","RadioGroup","Ring","Row","ScatterChart","Select","SelectGroup","SelectLabel","SelectOption","SelectSeparator","Separator","Slider","Slot","Small","Span","Sparkline","Svg","Switch","Tab","Table","TableBody","TableCaption","TableCell","TableFooter","TableHead","TableHeader","TableRow","Tabs","Text","Textarea","Tooltip","Use","Video"];var j4=new Set(P4);function D1($,Z={}){let J=[],q=Z.strict??!1;if($==null||typeof $!=="object")return J.push({path:"$",message:"Wire data must be a non-null object"}),{valid:!1,errors:J};let Q=$;if(Q.$prefab==null||typeof Q.$prefab!=="object")J.push({path:"$.$prefab",message:"Missing or invalid $prefab header"});else if(typeof Q.$prefab.version!=="string")J.push({path:"$.$prefab.version",message:"version must be a string"});if(Q.view==null)J.push({path:"$.view",message:'Missing required "view" field'});else k0(Q.view,"$.view",J,q);if(Q.state!==void 0){if(Q.state===null||typeof Q.state!=="object"||Array.isArray(Q.state))J.push({path:"$.state",message:"state must be a plain object"})}if(Q.theme!==void 0)K5(Q.theme,J);if(Q.css!==void 0)V4(Q.css,"$.css",J);if(Q.stylesheets!==void 0)V4(Q.stylesheets,"$.stylesheets",J);if(Q.mode!==void 0&&Q.mode!=="light"&&Q.mode!=="dark")J.push({path:"$.mode",message:'mode must be "light" or "dark"'});if(Q.defs!==void 0)if(Q.defs===null||typeof Q.defs!=="object"||Array.isArray(Q.defs))J.push({path:"$.defs",message:"defs must be a plain object"});else for(let[Y,U]of Object.entries(Q.defs))k0(U,`$.defs.${Y}`,J,q);if(Q.keyBindings!==void 0)if(Q.keyBindings===null||typeof Q.keyBindings!=="object"||Array.isArray(Q.keyBindings))J.push({path:"$.keyBindings",message:"keyBindings must be a plain object"});else for(let[Y,U]of Object.entries(Q.keyBindings))A0(U,`$.keyBindings.${Y}`,J);return{valid:J.length===0,errors:J}}function k4($){return D1($).valid}function k0($,Z,J,q){if($==null||typeof $!=="object"||Array.isArray($)){J.push({path:Z,message:"Component must be a plain object"});return}let Q=$;if(typeof Q.type!=="string"||Q.type.length===0){J.push({path:`${Z}.type`,message:'Component must have a non-empty "type" string'});return}if(q&&!j4.has(Q.type))J.push({path:`${Z}.type`,message:`Unknown component type: "${Q.type}"`});if(Q.children!==void 0)if(!Array.isArray(Q.children))J.push({path:`${Z}.children`,message:"children must be an array"});else for(let U=0;U<Q.children.length;U++)k0(Q.children[U],`${Z}.children[${U}]`,J,q);let Y=["onClick","on_click","onChange","on_change","onSubmit","on_submit","onMount","on_mount","onClose","on_close"];for(let U of Y)if(Q[U]!==void 0)A0(Q[U],`${Z}.${U}`,J);for(let[U,H]of Object.entries(Q)){if(U==="type"||z5.has(U)||Y.includes(U))continue;if(R4(H)||Array.isArray(H)&&H.some(R4))J.push({path:`${Z}.${U}`,message:`Components under "${U}" are ignored by the renderer; move them into "children"`})}}var z5=new Set(["children","fallback","trigger","empty","else","summary"]);function R4($){if($==null||typeof $!=="object"||Array.isArray($))return!1;let Z=$.type;return typeof Z==="string"&&j4.has(Z)}function A0($,Z,J){if(Array.isArray($)){for(let H=0;H<$.length;H++)A0($[H],`${Z}[${H}]`,J);return}if($==null||typeof $!=="object"){J.push({path:Z,message:"Action must be an object or array of objects"});return}let q=$,Q=typeof q.type==="string"&&q.type.length>0,Y=typeof q.action==="string"&&q.action.length>0;if(!Q&&!Y){J.push({path:`${Z}.type`,message:'Action must have a non-empty "type" or "action" string'});return}if((Y?q.action:q.type).toLowerCase()==="showtoast"){if(typeof q.message!=="string"||q.message.length===0)J.push({path:`${Z}.message`,message:'showToast requires a non-empty "message" string'})}}function V4($,Z,J){if(!Array.isArray($)){J.push({path:Z,message:`${Z} must be an array of strings`});return}for(let q=0;q<$.length;q++)if(typeof $[q]!=="string")J.push({path:`${Z}[${q}]`,message:"must be a string"})}function K5($,Z){if($===null||typeof $!=="object"||Array.isArray($)){Z.push({path:"$.theme",message:"theme must be a plain object"});return}let J=$;for(let q of["light","dark"])if(J[q]!==void 0){if(J[q]===null||typeof J[q]!=="object"||Array.isArray(J[q]))Z.push({path:`$.theme.${q}`,message:`theme.${q} must be a plain object`})}}var Z1={mount($,Z,J){if(a1(),J?.validate!==!1)for(let K of D1(Z).errors)w.warn(`wire validation ${K.path}: ${K.message}`);let q=Z,Q={tracked:[],evalBlocked:!1};if(q.pipes)for(let[K,T]of Object.entries(q.pipes))A4(K,T,Q);let Y=new L1(q.state),U;if(J?.transport&&"callTool"in J.transport)U=J.transport;else if(J?.transport)U=o1(J.transport);else U=t1();let H=J?.onToast??L5,W=new I1;function X(K){let T=K;if(q=T,T.state)Y.merge(T.state);if(T.defs)M.defs=T.defs;if(T.theme)R0($,T.theme);if(T.mode)S4($,T.mode);if(T.pipes)for(let[P,A]of Object.entries(T.pipes))A4(P,A,Q);for(let P of G)P.remove();if(G.length=0,G.push(...f4(T.css,T.stylesheets)),C4($,T.layout),E?.(),E=void 0,T.keyBindings)E=V0(T.keyBindings,(P)=>{v(m(P,{store:Y,transport:U,scope:{},rerender:()=>_(),remount:X,onToast:H}),"keyBinding")});_()}let M={store:Y,scope:{},transport:U,rerender:()=>_(),remount:X,onToast:H,defs:q.defs,destroyRegistry:W};if(R0($,q.theme),q.mode)S4($,q.mode);C4($,q.layout);let G=f4(q.css,q.stylesheets),E;if(q.keyBindings)E=V0(q.keyBindings,(K)=>{v(m(K,{store:Y,transport:U,scope:{},rerender:()=>_(),remount:X,onToast:H}),"keyBinding")});let z,F=J?.themeToggle??!0;if(F!==!1)z=j1($,typeof F==="object"?F:void 0);function _(){W.flush();let K=$.querySelector(".pf-theme-toggle");$.innerHTML="";let T=u(q.view,M);if($.appendChild(T),K)$.appendChild(K)}return _(),{rerender:()=>_(),update(K){if(Y.merge(K.update.state),_(),K.update.actions!=null)v(m(K.update.actions,M),"update action")},store:Y,destroy(){W.flush(),z?.(),E?.(),v0(),g0();for(let K of G)K.remove();for(let K of Q.tracked)O1(K);$.innerHTML=""}}},isPrefabData($){return $!=null&&typeof $==="object"&&"$prefab"in $},isPrefabUpdate($){return $!=null&&typeof $==="object"&&"$prefab"in $&&"update"in $}},F5=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 D5($){if($ instanceof EvalError)return!0;return $ instanceof Error&&/unsafe-eval|Content Security Policy|call to Function/i.test($.message)}function A4($,Z,J){if(F5.has($)){w.warn(`wire pipe "${$}" ignored — shadows built-in`);return}if(f1($)!=null){w.debug(`wire pipe "${$}" — already registered, keeping local implementation`);return}if(J.evalBlocked)return;try{let q=Function("return ("+Z+")")();if(typeof q!=="function"){w.warn(`wire pipe "${$}" — source did not evaluate to a function`);return}T1($,q),J.tracked.push($)}catch(q){if(D5(q)){J.evalBlocked=!0,w.warn("wire pipes cannot be hydrated — this host's CSP forbids eval. Pre-register them with "+"prefab.registerPipe() from a companion script (rendererHtml({ scripts })) and they are used as-is.");return}w.warn(`wire pipe "${$}" — failed to hydrate:`,q)}}function L5($){if(typeof document>"u")return;let Z=O5(),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 S4($,Z){if(K1($,Z),typeof document<"u")K1(document.documentElement,Z)}function T5($){let Z=$.trim();if(Z.includes("{")||Z.includes("}"))return!1;return/^(https?:)?\/\//i.test(Z)||Z.startsWith("/")||/\.css(\?|#|$)/i.test(Z)}function f4($,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(T5(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 C4($,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 O5(){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=Z1,$.prefab={app:e1,mount:Z1.mount.bind(Z1),isPrefabData:Z1.isPrefabData.bind(Z1),isPrefabUpdate:Z1.isPrefabUpdate.bind(Z1),Bridge:_1,isIframe:F1,registerPipe:T1,unregisterPipe:O1,listPipes:S1,registerComponent:B,createThemeToggle:j1,validateWireFormat:D1,setLogLevel:A1};let Z=$.__PREFAB_DATA__;if(Z!=null){let J=document.getElementById("prefab-root");if(J)Z1.mount(J,Z)}}})();
|