@maxhealth.tech/prefab 0.2.33 → 0.2.35
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 +22 -0
- package/dist/app.d.ts +1 -1
- package/dist/app.js +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/mcp/display.d.ts +1 -5
- package/dist/mcp/display.d.ts.map +1 -1
- package/dist/mcp/display.js +7 -0
- package/dist/mcp/display.js.map +1 -1
- package/dist/renderer/actions.d.ts.map +1 -1
- package/dist/renderer/actions.js +15 -4
- package/dist/renderer/actions.js.map +1 -1
- package/dist/renderer.auto.min.js +6 -6
- package/dist/renderer.min.js +6 -6
- package/package.json +1 -1
package/dist/renderer.min.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
(()=>{var{defineProperty:y0,getOwnPropertyNames:Q4,getOwnPropertyDescriptor:Y4}=Object,U4=Object.prototype.hasOwnProperty;function W4($){return this[$]}var H4=($)=>{var Z=(q1??=new WeakMap).get($),J;if(Z)return Z;if(Z=y0({},"__esModule",{value:!0}),$&&typeof $==="object"||typeof $==="function"){for(var q of Q4($))if(!U4.call(Z,q))y0(Z,q,{get:W4.bind($,q),enumerable:!(J=Y4($,q))||J.enumerable})}return q1.set($,Z),Z},q1;var M4=($)=>$;function G4($,Z){this[$]=M4.bind(null,Z)}var X4=($,Z)=>{for(var J in Z)y0($,J,{get:Z[J],enumerable:!0,configurable:!0,set:G4.bind(Z,J)})};var g2={};X4(g2,{unregisterPipe:()=>U0,registerPipe:()=>Y0,registerComponent:()=>G,listPipes:()=>E0,isIframe:()=>q0,createThemeToggle:()=>X0,applyHostTheme:()=>_0,app:()=>C0,PrefabRenderer:()=>p,DestroyRegistry:()=>W0,Bridge:()=>e});class Q0{data={};subscribers=new Map;globalSubscribers=new Set;generation=0;constructor($){if($)this.data=structuredClone($)}get($){return _4(this.data,$)}getAll(){return this.data}set($,Z){Q1(this.data,$,Z),this.notify($)}toggle($){let Z=this.get($),J=Z==null||Z===!1||Z===0||Z==="";this.set($,J)}append($,Z,J){let q=this.get($);if(!Array.isArray(q)){this.set($,[Z]);return}if(J!==void 0)q.splice(J,0,Z);else q.push(Z);this.notify($)}pop($,Z){let J=this.get($);if(!Array.isArray(J))return;if(typeof Z==="number")J.splice(Z,1);else{let q=J.indexOf(Z);if(q>=0)J.splice(q,1)}this.notify($)}merge($){for(let[Z,J]of Object.entries($))Q1(this.data,Z,J);for(let Z of Object.keys($))this.notify(Z)}subscribe($,Z){if(!this.subscribers.has($))this.subscribers.set($,new Set);return this.subscribers.get($)?.add(Z),()=>this.subscribers.get($)?.delete(Z)}subscribeAll($){return this.globalSubscribers.add($),()=>this.globalSubscribers.delete($)}notify($){this.generation++;let Z=$.split(".");for(let J=1;J<=Z.length;J++){let q=Z.slice(0,J).join("."),Q=this.subscribers.get(q);if(Q)Q.forEach((Y)=>Y())}this.globalSubscribers.forEach((J)=>J())}}function _4($,Z){let J=Z.split("."),q=$;for(let Q of J){if(q==null||typeof q!=="object")return;q=q[Q]}return q}var N4=new Set(["__proto__","constructor","prototype"]);function Q1($,Z,J){let q=Z.split(".");if(q.some((Y)=>N4.has(Y))){console.warn(`[prefab] Blocked prototype pollution attempt: ${Z}`);return}let Q=$;for(let Y=0;Y<q.length-1;Y++){let U=q[Y];if(Q[U]==null||typeof Q[U]!=="object")Q[U]={};Q=Q[U]}Q[q[q.length-1]]=J}var $0=new Map;function Y0($,Z){if($0.has($)&&$0.get($)!==Z)console.warn(`[prefab] pipe "${$}" re-registered`);$0.set($,Z)}function U0($){return $0.delete($)}function E0(){return[...$0.keys()]}function Y1($){return $0.get($)}var U1=-1,b0=new Map,E4=/\{\{\s*(.+?)\s*\}\}/g;function g($){return typeof $==="string"&&$.includes("{{")&&$.includes("}}")}function u($,Z,J){let q=$.trim();if(q.startsWith("{{")&&q.endsWith("}}")&&D4(q,"{{")===1){let Q=q.slice(2,-2).trim();return W1(Q,Z,J)}return $.replace(E4,(Q,Y)=>{let U=W1(Y.trim(),Z,J);return U==null?"":String(U)})}function W1($,Z,J){let[q,...Q]=O4($),Y=v(q.trim(),Z,J);for(let U of Q)Y=B4(U.trim(),Y,Z,J);return Y}function v($,Z,J){let q=z4($);if(q>=0){let U=$.slice(0,q).trim(),W=$.slice(q+1),H=L4(W);if(H>=0){let X=W.slice(0,H).trim(),N=W.slice(H+1).trim(),M=v(U,Z,J);return M!==null&&M!==void 0&&M!==!1&&M!==0&&M!==""?v(X,Z,J):v(N,Z,J)}}let Q=B0($,"||");if(Q>=0){let U=v($.slice(0,Q).trim(),Z,J);return U!==null&&U!==void 0&&U!==!1&&U!==0&&U!==""?U:v($.slice(Q+2).trim(),Z,J)}let Y=B0($,"&&");if(Y>=0){let U=v($.slice(0,Y).trim(),Z,J);if(U===null||U===void 0||U===!1||U===0||U==="")return U;return v($.slice(Y+2).trim(),Z,J)}for(let[U,W]of F4){let H=B0($,U);if(H>=0){let X=v($.slice(0,H).trim(),Z,J),N=v($.slice(H+U.length).trim(),Z,J);return W(X,N)}}if($.startsWith("!")){let U=v($.slice(1).trim(),Z,J);return U===null||U===void 0||U===!1||U===0||U===""}for(let[U,W]of K4){let H=B0($,U);if(H>=0){let X=v($.slice(0,H).trim(),Z,J),N=v($.slice(H+U.length).trim(),Z,J);return W(Number(X),Number(N))}}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),X=J[W];return F0(X,H)}return J[$]}if(J){let U=$.split(".")[0];if(U in J)return F0(J[U],$.includes(".")?$.slice(U.length+1):"")}return Z.get($)}function B4($,Z,J,q){let Q=$.indexOf(":"),Y=Q>=0?$.slice(0,Q).trim():$,U=Q>=0?$.slice(Q+1).trim():void 0,W=U?m0(U):void 0;switch(Y){case"find":{if(!Array.isArray(Z)||!U)return;let H=H1(U);if(H.length<2)return;let X=m0(H[0]),N=H[1].trim(),M;if(N.startsWith("'")&&N.endsWith("'")||N.startsWith('"')&&N.endsWith('"'))M=N.slice(1,-1);else if(J){if(q&&N.startsWith("$")){let F=N.indexOf(".");if(F>=0){let z=N.slice(0,F);if(z in q)M=F0(q[z],N.slice(F+1))}else if(N in q)M=q[N]}if(M===void 0&&!(q&&N.startsWith("$")))if(q){let F=N.split(".")[0];M=F in q?F0(q[F],N.includes(".")?N.slice(F.length+1):""):J.get(N)}else M=J.get(N)}else M=N;if(M==null)return;let E=J?.generation??0;if(E!==U1)b0=new Map,U1=E;let L=b0.get(Z);if(!L)L=new Map,b0.set(Z,L);let B=L.get(X);if(!B){B=new Map;for(let F of Z)if(F!=null&&typeof F==="object"){let z=F[X];if(z!=null)B.set(String(z),F)}L.set(X,B)}return B.get(String(M))}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),X=typeof W==="string"?W:"";return H===1?X:`${X}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 X=H[W];return X==null||X===!1||X===0||X===""}):Z;default:{let H=Y1(Y);if(H){let X=U?H1(U).map(m0):[];return H(Z,...X)}return Z}}}var F4=[["!==",($,Z)=>$!==Z],["===",($,Z)=>$===Z],["!=",($,Z)=>$!=Z],["==",($,Z)=>$==Z],[">=",($,Z)=>Number($)>=Number(Z)],["<=",($,Z)=>Number($)<=Number(Z)],[">",($,Z)=>Number($)>Number(Z)],["<",($,Z)=>Number($)<Number(Z)]],K4=[[" + ",($,Z)=>$+Z],[" - ",($,Z)=>$-Z],[" * ",($,Z)=>$*Z],[" / ",($,Z)=>Z!==0?$/Z:0],[" % ",($,Z)=>Z!==0?$%Z:0]];function B0($,Z){let J=null;for(let q=0;q<$.length;q++){let Q=$[q];if(Q==="'"||Q==='"')J=J===Q?null:J??Q;if(!J&&$.slice(q,q+Z.length)===Z)return q}return-1}function z4($){let Z=0,J=null;for(let q=0;q<$.length;q++){let Q=$[q];if(Q==="'"||Q==='"')J=J===Q?null:J??Q;if(!J){if(Q==="(")Z++;else if(Q===")")Z--;else if(Q==="?"&&Z===0)return q}}return-1}function L4($){let Z=0,J=null;for(let q=0;q<$.length;q++){let Q=$[q];if(Q==="'"||Q==='"')J=J===Q?null:J??Q;if(!J){if(Q==="?"||Q==="(")Z++;else if(Q===")")Z--;else if(Q===":"&&Z===0)return q}}return-1}function O4($){let Z=[],J="",q=null;for(let Q=0;Q<$.length;Q++){let Y=$[Q];if(Y==="'"||Y==='"')q=q===Y?null:q??Y;if(Y==="|"&&!q)if($[Q+1]==="|")J+="||",Q++;else Z.push(J),J="";else J+=Y}return Z.push(J),Z}function m0($){let Z=$.replace(/^['"]|['"]$/g,"");if(Z==="true")return!0;if(Z==="false")return!1;let J=Number(Z);return isNaN(J)?Z:J}function H1($){let Z=[],J="",q=null;for(let Q of $){if(Q==="'"||Q==='"')q=q===Q?null:q??Q;if(Q===","&&!q)Z.push(J),J="";else J+=Q}return Z.push(J),Z}function F0($,Z){if(!Z)return $;let J=Z.split("."),q=$;for(let Q of J){if(q==null||typeof q!=="object")return;q=q[Q]}return q}function D4($,Z){let J=0,q=0;while((q=$.indexOf(Z,q))!==-1)J++,q+=Z.length;return J}function K0($){return $.replace(/_([a-z])/g,(Z,J)=>J.toUpperCase())}function v0($){let Z={};for(let[J,q]of Object.entries($)){let Q=J.startsWith("$")?J:K0(J);if(Array.isArray(q))Z[Q]=q.map((Y)=>Y!=null&&typeof Y==="object"&&!Array.isArray(Y)?v0(Y):Y);else if(q!=null&&typeof q==="object"&&!Array.isArray(q))Z[Q]=v0(q);else Z[Q]=q}return Z}async function k($,Z){let J=Array.isArray($)?$:[$];for(let q of J)await T4(q,Z)}async function T4($,Z){let J=v0($),q=J.action;switch(q){case"setState":{V4(J,Z);return}case"toggleState":{j4(J,Z);return}case"appendState":{R4(J,Z);return}case"popState":{I4(J,Z);return}case"showToast":{P4(J,Z);return}case"closeOverlay":{A4(J,Z);return}case"openLink":{k4(J);return}case"setInterval":{S4(J,Z);return}case"toolCall":case"callTool":return w4(J,Z);case"sendMessage":return C4(J,Z);case"updateContext":{y4(J,Z);return}case"fetch":return b4(J,Z);case"openFilePicker":{m4(J,Z);return}case"callHandler":return h4(J,Z);case"requestDisplayMode":{v4(J,Z);return}case"subscribe":{x4(J,Z);return}case"unsubscribe":{p4(J);return}default:console.warn(`[prefab] Unknown action: ${q}`)}}function V4($,Z){let{key:J,value:q}=$;if(g(q))q=u(q,Z.store,Z.scope);Z.store.set(J,q),Z.rerender(),l($.onSuccess,Z)}function j4($,Z){Z.store.toggle($.key),Z.rerender()}function R4($,Z){let J=$.value??$.item;if(g(J))J=u(J,Z.store,Z.scope);Z.store.append($.key,J,$.index),Z.rerender()}function I4($,Z){Z.store.pop($.key,$.index),Z.rerender()}function P4($,Z){Z.onToast?.({message:L0($.message,Z),description:$.description!=null?L0($.description,Z):void 0,variant:$.variant,duration:$.duration})}function A4($,Z){if(typeof document<"u")document.dispatchEvent(new CustomEvent("prefab:close-overlay"))}function k4($){if(typeof window<"u"){let Z=$.url;if(!Z){console.warn("[prefab] openLink: missing url");return}if(!_1(Z)){console.warn(`[prefab] Blocked unsafe URL scheme: ${Z}`);return}window.open(Z,$.target??"_blank")}}var z0=new Set,f4=20,M1=100;function S4($,Z){let J=Math.max($.intervalMs,M1),q=$.onTick;if(typeof globalThis.setInterval!=="function")return;if(z0.size>=f4){console.warn("[prefab] Max intervals reached, ignoring new setInterval");return}let Q=globalThis.setInterval(()=>void k(q,Z),J);z0.add(Q)}function G1(){for(let $ of z0)globalThis.clearInterval($);z0.clear()}async function w4($,Z){if(!Z.transport){console.warn("[prefab] No MCP transport configured for toolCall");return}let J=$.tool,q=x0($.arguments,Z);try{let Q=await Z.transport.callTool(J,q);if($.resultKey!=null)Z.store.set($.resultKey,Q);let Y=g0(Q);if(Y&&Z.remount)Z.remount(Y);else u0(Q,Z),Z.rerender();await l($.onSuccess,Z,{$result:Q})}catch(Q){await l($.onError,Z,{$error:Q})}}async function C4($,Z){if(!Z.transport){console.warn("[prefab] No MCP transport configured for sendMessage");return}await Z.transport.sendMessage(L0($.message,Z))}function y4($,Z){let J=$.context;if(J!=null)Z.store.merge(J),Z.rerender()}async function b4($,Z){let J=L0($.url,Z);if(!_1(J)){console.warn(`[prefab] Blocked unsafe URL in fetch: ${J}`);return}let q=$.method??"GET",Q=$.headers,Y=$.body!==void 0?JSON.stringify($.body):void 0;try{let U=await globalThis.fetch(J,{method:q,headers:{"Content-Type":"application/json",...Q},...Y&&{body:Y}}),W=await U.json().catch(()=>U.text());if($.resultKey!=null)Z.store.set($.resultKey,W);let H=g0(W);if(H&&Z.remount)Z.remount(H);else u0(W,Z),Z.rerender();await l($.onSuccess,Z,{$result:W})}catch(U){await l($.onError,Z,{$error:U})}}function m4($,Z){if(typeof document>"u")return;let J=document.createElement("input");if(J.type="file",$.accept!=null)J.accept=$.accept;if($.multiple===!0)J.multiple=!0;J.addEventListener("change",()=>{let q=Array.from(J.files??[]);if($.resultKey!=null)Z.store.set($.resultKey,q);Z.rerender(),l($.onSuccess,Z,{$result:q})}),J.click()}async function h4($,Z){let J=$.handler,q=x0($.arguments,Z);if(!Z.transport){console.warn(`[prefab] No transport configured for callHandler: ${J}`);return}try{let Q=await Z.transport.callTool(J,q);if($.resultKey!=null)Z.store.set($.resultKey,Q);let Y=g0(Q);if(Y&&Z.remount)Z.remount(Y);else u0(Q,Z),Z.rerender();await l($.onSuccess,Z,{$result:Q})}catch(Q){await l($.onError,Z,{$error:Q})}}function v4($,Z){if(typeof document<"u")document.dispatchEvent(new CustomEvent("prefab:request-display-mode",{detail:{mode:$.mode}}))}var r=new Map,g4=50,u4=2000;function x4($,Z){let{uri:J,stateKey:q}=$;if(!J||!q){console.warn("[prefab] subscribe: missing uri or stateKey");return}if(r.has(J))return;if(r.size>=g4){console.warn("[prefab] Max subscriptions reached, ignoring new subscribe");return}let Q=(M)=>{Z.store.set(q,M),Z.rerender(),l($.onData,Z,{$data:M})};if(Z.transport?.subscribe&&Z.transport.capabilities?.subscriptions){let M=Z.transport.subscribe(J,Q);r.set(J,M);return}let Y=$.fallbackTool,U=$.fallbackInterval??u4;if(!Y){console.warn("[prefab] subscribe: host lacks subscriptions and no fallbackTool specified");return}if(!Z.transport){console.warn("[prefab] No MCP transport configured for subscribe fallback");return}let W=$.fallbackArgs??{},H=Math.max(U,M1),X=Z.transport,N=globalThis.setInterval(()=>{(async()=>{try{let M=x0(W,Z),E=await X.callTool(Y,M);Q(E)}catch(M){l($.onError,Z,{$error:M})}})()},H);r.set(J,()=>globalThis.clearInterval(N))}function p4($){let Z=$.uri;if(!Z){console.warn("[prefab] unsubscribe: missing uri");return}let J=r.get(Z);if(J)J(),r.delete(Z)}function X1(){for(let[$,Z]of r)try{Z()}catch(J){console.warn(`[prefab] Error cleaning up subscription '${$}':`,J)}r.clear()}function g0($){if($==null||typeof $!=="object")return null;let Z=$;if("$prefab"in Z&&"view"in Z)return Z;if("structuredContent"in Z){let J=Z.structuredContent;if(J!=null&&typeof J==="object"){let q=J;if("$prefab"in q&&"view"in q)return q}}if("content"in Z&&Array.isArray(Z.content)){for(let J of Z.content)if(J.type==="text"&&typeof J.text==="string")try{let q=JSON.parse(J.text);if(q!=null&&typeof q==="object"){let Q=q;if("$prefab"in Q&&"view"in Q)return Q}}catch{}}return null}function c4($){if($==null||typeof $!=="object")return null;let Z=$;if(h0(Z))return Z;if("structuredContent"in Z){let J=Z.structuredContent;if(J!=null&&typeof J==="object"&&h0(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"&&h0(q))return q}catch{}}return null}function h0($){if(!("$prefab"in $)||!("update"in $))return!1;let Z=$.update;return Z!=null&&typeof Z==="object"&&"state"in Z}function u0($,Z){let J=c4($);if(!J)return;let q=J.update;Z.store.merge(q.state)}var d4=/^\s*(javascript|vbscript|data):/i;function _1($){return!d4.test($)}function L0($,Z){if(g($)){let J=u($,Z.store,Z.scope);return J==null?"":String(J)}return $==null?"":String($)}function x0($,Z){if(!$)return{};let J={};for(let[q,Q]of Object.entries($))J[q]=g(Q)?u(Q,Z.store,Z.scope):Q;return J}async function l($,Z,J){if($==null)return;let q={...Z.scope,...J};await k($,{...Z,scope:q})}function c0($){let Z={};for(let[J,q]of Object.entries($)){let Q=J.startsWith("$")?J:K0(J);if(Array.isArray(q))Z[Q]=q.map((Y)=>Y!=null&&typeof Y==="object"&&!Array.isArray(Y)?c0(Y):Y);else if(q!=null&&typeof q==="object"&&!Array.isArray(q))Z[Q]=c0(q);else Z[Q]=q}return Z}class W0{callbacks=[];track($){this.callbacks.push($)}flush(){for(let $ of this.callbacks)try{$()}catch(Z){console.warn("[prefab] destroy callback error:",Z)}this.callbacks=[]}get size(){return this.callbacks.length}}function l4($){return typeof $==="object"&&"element"in $}var d0=new Map;function G($,Z){if(d0.has($))console.warn(`[prefab] overriding existing renderer for "${$}"`);d0.set($,Z)}function w($,Z){let J=c0($);if(Z.defs?.[J.type]){let Y={...Z.defs[J.type],...J,type:Z.defs[J.type].type};return w(Y,Z)}let q=d0.get(J.type),Q;if(q){let Y=q(J,Z);if(l4(Y))Q=Y.element,Z.destroyRegistry?.track(Y.destroy);else Q=Y}else if(Q=document.createElement("div"),Q.setAttribute("data-prefab-type",J.type),J.children)for(let Y of J.children)Q.appendChild(w(Y,Z));if(Q instanceof HTMLElement){if(J.id)Q.id=J.id;if(J.cssClass){let Y=K(J.cssClass,Z);if(Y)Q.className=(Q.className?Q.className+" ":"")+Y}}if(J.onMount){let Y=J.onMount,U=y(Z);queueMicrotask(()=>void k(Y,U))}return Q}function T($,Z,J){if(!$.children)return;a($.children,Z,J)}function a($,Z,J){let q=0;while(q<$.length){let Q=$[q];if(Q.type==="If")q=s4($,q,Z,J);else if(Q.type==="Elif"||Q.type==="Else")q++;else Z.appendChild(w(Q,J)),q++}}function s4($,Z,J,q){let Q=!1,Y=Z,U=$[Y];if(N1(U.condition,q))p0(U,J,q),Q=!0;Y++;while(Y<$.length){let W=$[Y];if(W.type==="Elif"){if(!Q&&N1(W.condition,q))p0(W,J,q),Q=!0;Y++}else if(W.type==="Else"){if(!Q)p0(W,J,q);Y++;break}else break}return Y}function N1($,Z){if(!$)return!1;if(g($))return Boolean(u($,Z.store,Z.scope));return Boolean(Z.store.get($))}function p0($,Z,J){if(!$.children)return;a($.children,Z,J)}function K($,Z){if(g($)){let J=u($,Z.store,Z.scope);return J==null?"":String(J)}return $==null?"":String($)}function b($,Z){if(g($))return u($,Z.store,Z.scope);return $}function y($){return{store:$.store,transport:$.transport,scope:$.scope,rerender:$.rerender,onToast:$.onToast,remount:$.remount}}function _($,Z){let J=document.createElement($);if(Z)J.className=Z;return J}function l0($,Z){return $.textContent=Z,$}function K1(){G("Column",i4),G("Row",n4),G("Grid",E1),G("GridItem",B1),G("Container",r4),G("Div",F1),G("Span",a4),G("Dashboard",E1),G("DashboardItem",B1),G("Pages",o4),G("Page",F1),G("Detail",t4),G("MasterDetail",e4)}function i4($,Z){let J=_("div","pf-column");J.style.display="flex",J.style.flexDirection="column";let q=O0($);if(q!=null)J.style.gap=`${q*4}px`;if($.align!=null)J.style.alignItems=z1($.align);if($.justify!=null)J.style.justifyContent=L1($.justify);return T($,J,Z),J}function n4($,Z){let J=_("div","pf-row");J.style.display="flex",J.style.flexDirection="row";let q=O0($);if(q!=null)J.style.gap=`${q*4}px`;if($.align!=null)J.style.alignItems=z1($.align);if($.justify!=null)J.style.justifyContent=L1($.justify);if($.wrap===!0)J.style.flexWrap="wrap";return T($,J,Z),J}function E1($,Z){let J=_("div","pf-grid");J.style.display="grid";let q=$.columns??3;J.style.gridTemplateColumns=`repeat(${q}, 1fr)`;let Q=O0($);if(Q!=null)J.style.gap=`${Q*4}px`;return T($,J,Z),J}function B1($,Z){let J=_("div","pf-grid-item");if($.colSpan!=null)J.style.gridColumn=`span ${$.colSpan}`;if($.rowSpan!=null)J.style.gridRow=`span ${$.rowSpan}`;return T($,J,Z),J}function r4($,Z){let J=_("div","pf-container");if(J.style.maxWidth=$.maxWidth??"1200px",J.style.margin="0 auto",$.padding!=null)J.style.padding=`${$.padding*4}px`;return T($,J,Z),J}function F1($,Z){let J=_("div","pf-div");return T($,J,Z),J}function a4($,Z){let J=_("span","pf-span");return T($,J,Z),J}function o4($,Z){let J=_("div","pf-pages");return T($,J,Z),J}function t4($,Z){let J=_("div","pf-detail"),q=$.of!=null?b($.of,Z):void 0;if(q!=null&&q!==""&&q!==!1&&q!==0)T($,J,Z);else if($.empty!=null){let Q=$.empty;J.appendChild(w(Q,Z))}return J}function e4($,Z){let J=_("div","pf-master-detail");J.style.display="flex",J.style.flexDirection="row";let q=O0($);if(q!=null)J.style.gap=`${q*4}px`;let Q=$.masterWidth??"33%",Y=$.children??[];if(Y.length>0){let U=_("div","pf-master-detail-master");U.style.width=Q,U.style.flexShrink="0",U.style.overflow="auto",U.appendChild(w(Y[0],Z)),J.appendChild(U)}if(Y.length>1){let U=_("div","pf-master-detail-detail");U.style.flex="1",U.style.overflow="auto",U.appendChild(w(Y[1],Z)),J.appendChild(U)}return J}var $8=/\bgap-(\d+)\b/;function O0($){if($.gap!=null)return $.gap;if(typeof $.cssClass==="string"){let Z=$8.exec($.cssClass);if(Z)return Number(Z[1])}return null}function z1($){return{start:"flex-start",end:"flex-end",center:"center",stretch:"stretch",baseline:"baseline"}[$]??$}function L1($){return{start:"flex-start",end:"flex-end",center:"center",between:"space-between",around:"space-around",evenly:"space-evenly"}[$]??$}function D1(){G("Heading",Z8),G("H1",($,Z)=>D0($,Z,"h1")),G("H2",($,Z)=>D0($,Z,"h2")),G("H3",($,Z)=>D0($,Z,"h3")),G("H4",($,Z)=>D0($,Z,"h4")),G("Text",J8),G("P",q8),G("Lead",($,Z)=>Z0($,Z,"p","pf-lead")),G("Large",($,Z)=>Z0($,Z,"span","pf-large")),G("Small",($,Z)=>Z0($,Z,"small","pf-small")),G("Muted",($,Z)=>Z0($,Z,"p","pf-muted")),G("BlockQuote",($,Z)=>Z0($,Z,"blockquote","pf-blockquote")),G("Label",($,Z)=>Z0($,Z,"label","pf-label")),G("Link",Y8),G("Code",U8),G("Markdown",W8),G("Kbd",H8)}function Z8($,Z){let J=$.level??2,q=`h${Math.min(Math.max(J,1),6)}`,Q=document.createElement(q);return Q.className=`pf-heading pf-${q}`,Q.textContent=K($.content,Z),Q}function D0($,Z,J){let q=document.createElement(J);return q.className=`pf-heading pf-${J}`,q.textContent=K($.content,Z),q}function J8($,Z){return l0(_("span","pf-text"),K($.content,Z))}function q8($,Z){return l0(_("p","pf-p"),K($.content,Z))}function Z0($,Z,J,q){let Q=document.createElement(J);return Q.className=q,Q.textContent=K($.content,Z),Q}var Q8=/^\s*(javascript|vbscript|data):/i;function Y8($,Z){let J=document.createElement("a");if(J.className="pf-link",J.textContent=K($.content,Z),$.href!=null){let q=K($.href,Z);if(!Q8.test(q))J.href=q}if($.target!=null)J.target=K($.target,Z);return J}function U8($,Z){let J=_("pre","pf-code"),q=_("code");if(q.textContent=K($.content,Z),$.language!=null)q.setAttribute("data-language",$.language);return J.appendChild(q),J}function W8($,Z){let J=_("div","pf-markdown"),q=K($.content,Z);return J.innerHTML=T1(q),J.setAttribute("data-markdown","true"),J}var O1=/^\s*(javascript|vbscript|data):/i;function V0($){return $.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""")}function T0($){let Z=V0($),J=[];return Z=Z.replace(/`([^`]+)`/g,(q,Q)=>{return J.push(`<code>${Q}</code>`),`CODE${J.length-1}`}),Z=Z.replace(/!\[([^\]]*)\]\(([^)]+)\)/g,(q,Q,Y)=>{if(O1.test(Y))return V0(Q);return`<img src="${Y}" alt="${Q}" />`}),Z=Z.replace(/\[([^\]]+)\]\(([^)]+)\)/g,(q,Q,Y)=>{if(O1.test(Y))return Q;return`<a href="${Y}">${Q}</a>`}),Z=Z.replace(/\*{3}(.+?)\*{3}/g,"<strong><em>$1</em></strong>"),Z=Z.replace(/_{3}(.+?)_{3}/g,"<strong><em>$1</em></strong>"),Z=Z.replace(/\*{2}(.+?)\*{2}/g,"<strong>$1</strong>"),Z=Z.replace(/_{2}(.+?)_{2}/g,"<strong>$1</strong>"),Z=Z.replace(/\*(.+?)\*/g,"<em>$1</em>"),Z=Z.replace(/(?<!\w)_(.+?)_(?!\w)/g,"<em>$1</em>"),Z=Z.replace(/~~(.+?)~~/g,"<del>$1</del>"),Z=Z.replace(/\uFDD0CODE(\d+)\uFDD0/g,(q,Q)=>J[parseInt(Q)]),Z}function T1($){let Z=$.replace(/\r\n?/g,`
|
|
1
|
+
(()=>{var{defineProperty:m0,getOwnPropertyNames:Q4,getOwnPropertyDescriptor:Y4}=Object,U4=Object.prototype.hasOwnProperty;function W4($){return this[$]}var H4=($)=>{var Z=(q1??=new WeakMap).get($),J;if(Z)return Z;if(Z=m0({},"__esModule",{value:!0}),$&&typeof $==="object"||typeof $==="function"){for(var q of Q4($))if(!U4.call(Z,q))m0(Z,q,{get:W4.bind($,q),enumerable:!(J=Y4($,q))||J.enumerable})}return q1.set($,Z),Z},q1;var M4=($)=>$;function G4($,Z){this[$]=M4.bind(null,Z)}var X4=($,Z)=>{for(var J in Z)m0($,J,{get:Z[J],enumerable:!0,configurable:!0,set:G4.bind(Z,J)})};var g2={};X4(g2,{unregisterPipe:()=>U0,registerPipe:()=>Y0,registerComponent:()=>G,listPipes:()=>E0,isIframe:()=>q0,createThemeToggle:()=>X0,applyHostTheme:()=>_0,app:()=>b0,PrefabRenderer:()=>p,DestroyRegistry:()=>W0,Bridge:()=>e});class Q0{data={};subscribers=new Map;globalSubscribers=new Set;generation=0;constructor($){if($)this.data=structuredClone($)}get($){return _4(this.data,$)}getAll(){return this.data}set($,Z){Q1(this.data,$,Z),this.notify($)}toggle($){let Z=this.get($),J=Z==null||Z===!1||Z===0||Z==="";this.set($,J)}append($,Z,J){let q=this.get($);if(!Array.isArray(q)){this.set($,[Z]);return}if(J!==void 0)q.splice(J,0,Z);else q.push(Z);this.notify($)}pop($,Z){let J=this.get($);if(!Array.isArray(J))return;if(typeof Z==="number")J.splice(Z,1);else{let q=J.indexOf(Z);if(q>=0)J.splice(q,1)}this.notify($)}merge($){for(let[Z,J]of Object.entries($))Q1(this.data,Z,J);for(let Z of Object.keys($))this.notify(Z)}subscribe($,Z){if(!this.subscribers.has($))this.subscribers.set($,new Set);return this.subscribers.get($)?.add(Z),()=>this.subscribers.get($)?.delete(Z)}subscribeAll($){return this.globalSubscribers.add($),()=>this.globalSubscribers.delete($)}notify($){this.generation++;let Z=$.split(".");for(let J=1;J<=Z.length;J++){let q=Z.slice(0,J).join("."),Q=this.subscribers.get(q);if(Q)Q.forEach((Y)=>Y())}this.globalSubscribers.forEach((J)=>J())}}function _4($,Z){let J=Z.split("."),q=$;for(let Q of J){if(q==null||typeof q!=="object")return;q=q[Q]}return q}var N4=new Set(["__proto__","constructor","prototype"]);function Q1($,Z,J){let q=Z.split(".");if(q.some((Y)=>N4.has(Y))){console.warn(`[prefab] Blocked prototype pollution attempt: ${Z}`);return}let Q=$;for(let Y=0;Y<q.length-1;Y++){let U=q[Y];if(Q[U]==null||typeof Q[U]!=="object")Q[U]={};Q=Q[U]}Q[q[q.length-1]]=J}var $0=new Map;function Y0($,Z){if($0.has($)&&$0.get($)!==Z)console.warn(`[prefab] pipe "${$}" re-registered`);$0.set($,Z)}function U0($){return $0.delete($)}function E0(){return[...$0.keys()]}function Y1($){return $0.get($)}var U1=-1,h0=new Map,E4=/\{\{\s*(.+?)\s*\}\}/g;function g($){return typeof $==="string"&&$.includes("{{")&&$.includes("}}")}function u($,Z,J){let q=$.trim();if(q.startsWith("{{")&&q.endsWith("}}")&&D4(q,"{{")===1){let Q=q.slice(2,-2).trim();return W1(Q,Z,J)}return $.replace(E4,(Q,Y)=>{let U=W1(Y.trim(),Z,J);return U==null?"":String(U)})}function W1($,Z,J){let[q,...Q]=O4($),Y=v(q.trim(),Z,J);for(let U of Q)Y=B4(U.trim(),Y,Z,J);return Y}function v($,Z,J){let q=z4($);if(q>=0){let U=$.slice(0,q).trim(),W=$.slice(q+1),H=L4(W);if(H>=0){let X=W.slice(0,H).trim(),N=W.slice(H+1).trim(),M=v(U,Z,J);return M!==null&&M!==void 0&&M!==!1&&M!==0&&M!==""?v(X,Z,J):v(N,Z,J)}}let Q=B0($,"||");if(Q>=0){let U=v($.slice(0,Q).trim(),Z,J);return U!==null&&U!==void 0&&U!==!1&&U!==0&&U!==""?U:v($.slice(Q+2).trim(),Z,J)}let Y=B0($,"&&");if(Y>=0){let U=v($.slice(0,Y).trim(),Z,J);if(U===null||U===void 0||U===!1||U===0||U==="")return U;return v($.slice(Y+2).trim(),Z,J)}for(let[U,W]of F4){let H=B0($,U);if(H>=0){let X=v($.slice(0,H).trim(),Z,J),N=v($.slice(H+U.length).trim(),Z,J);return W(X,N)}}if($.startsWith("!")){let U=v($.slice(1).trim(),Z,J);return U===null||U===void 0||U===!1||U===0||U===""}for(let[U,W]of K4){let H=B0($,U);if(H>=0){let X=v($.slice(0,H).trim(),Z,J),N=v($.slice(H+U.length).trim(),Z,J);return W(Number(X),Number(N))}}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),X=J[W];return F0(X,H)}return J[$]}if(J){let U=$.split(".")[0];if(U in J)return F0(J[U],$.includes(".")?$.slice(U.length+1):"")}return Z.get($)}function B4($,Z,J,q){let Q=$.indexOf(":"),Y=Q>=0?$.slice(0,Q).trim():$,U=Q>=0?$.slice(Q+1).trim():void 0,W=U?v0(U):void 0;switch(Y){case"find":{if(!Array.isArray(Z)||!U)return;let H=H1(U);if(H.length<2)return;let X=v0(H[0]),N=H[1].trim(),M;if(N.startsWith("'")&&N.endsWith("'")||N.startsWith('"')&&N.endsWith('"'))M=N.slice(1,-1);else if(J){if(q&&N.startsWith("$")){let F=N.indexOf(".");if(F>=0){let z=N.slice(0,F);if(z in q)M=F0(q[z],N.slice(F+1))}else if(N in q)M=q[N]}if(M===void 0&&!(q&&N.startsWith("$")))if(q){let F=N.split(".")[0];M=F in q?F0(q[F],N.includes(".")?N.slice(F.length+1):""):J.get(N)}else M=J.get(N)}else M=N;if(M==null)return;let E=J?.generation??0;if(E!==U1)h0=new Map,U1=E;let L=h0.get(Z);if(!L)L=new Map,h0.set(Z,L);let B=L.get(X);if(!B){B=new Map;for(let F of Z)if(F!=null&&typeof F==="object"){let z=F[X];if(z!=null)B.set(String(z),F)}L.set(X,B)}return B.get(String(M))}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),X=typeof W==="string"?W:"";return H===1?X:`${X}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 X=H[W];return X==null||X===!1||X===0||X===""}):Z;default:{let H=Y1(Y);if(H){let X=U?H1(U).map(v0):[];return H(Z,...X)}return Z}}}var F4=[["!==",($,Z)=>$!==Z],["===",($,Z)=>$===Z],["!=",($,Z)=>$!=Z],["==",($,Z)=>$==Z],[">=",($,Z)=>Number($)>=Number(Z)],["<=",($,Z)=>Number($)<=Number(Z)],[">",($,Z)=>Number($)>Number(Z)],["<",($,Z)=>Number($)<Number(Z)]],K4=[[" + ",($,Z)=>$+Z],[" - ",($,Z)=>$-Z],[" * ",($,Z)=>$*Z],[" / ",($,Z)=>Z!==0?$/Z:0],[" % ",($,Z)=>Z!==0?$%Z:0]];function B0($,Z){let J=null;for(let q=0;q<$.length;q++){let Q=$[q];if(Q==="'"||Q==='"')J=J===Q?null:J??Q;if(!J&&$.slice(q,q+Z.length)===Z)return q}return-1}function z4($){let Z=0,J=null;for(let q=0;q<$.length;q++){let Q=$[q];if(Q==="'"||Q==='"')J=J===Q?null:J??Q;if(!J){if(Q==="(")Z++;else if(Q===")")Z--;else if(Q==="?"&&Z===0)return q}}return-1}function L4($){let Z=0,J=null;for(let q=0;q<$.length;q++){let Q=$[q];if(Q==="'"||Q==='"')J=J===Q?null:J??Q;if(!J){if(Q==="?"||Q==="(")Z++;else if(Q===")")Z--;else if(Q===":"&&Z===0)return q}}return-1}function O4($){let Z=[],J="",q=null;for(let Q=0;Q<$.length;Q++){let Y=$[Q];if(Y==="'"||Y==='"')q=q===Y?null:q??Y;if(Y==="|"&&!q)if($[Q+1]==="|")J+="||",Q++;else Z.push(J),J="";else J+=Y}return Z.push(J),Z}function v0($){let Z=$.replace(/^['"]|['"]$/g,"");if(Z==="true")return!0;if(Z==="false")return!1;let J=Number(Z);return isNaN(J)?Z:J}function H1($){let Z=[],J="",q=null;for(let Q of $){if(Q==="'"||Q==='"')q=q===Q?null:q??Q;if(Q===","&&!q)Z.push(J),J="";else J+=Q}return Z.push(J),Z}function F0($,Z){if(!Z)return $;let J=Z.split("."),q=$;for(let Q of J){if(q==null||typeof q!=="object")return;q=q[Q]}return q}function D4($,Z){let J=0,q=0;while((q=$.indexOf(Z,q))!==-1)J++,q+=Z.length;return J}function K0($){return $.replace(/_([a-z])/g,(Z,J)=>J.toUpperCase())}function u0($){let Z={};for(let[J,q]of Object.entries($)){let Q=J.startsWith("$")?J:K0(J);if(Array.isArray(q))Z[Q]=q.map((Y)=>Y!=null&&typeof Y==="object"&&!Array.isArray(Y)?u0(Y):Y);else if(q!=null&&typeof q==="object"&&!Array.isArray(q))Z[Q]=u0(q);else Z[Q]=q}return Z}async function k($,Z){let J=Array.isArray($)?$:[$];for(let q of J)await T4(q,Z)}async function T4($,Z){let J=u0($),q=J.action;switch(q){case"setState":{V4(J,Z);return}case"toggleState":{j4(J,Z);return}case"appendState":{R4(J,Z);return}case"popState":{I4(J,Z);return}case"showToast":{P4(J,Z);return}case"closeOverlay":{A4(J,Z);return}case"openLink":{k4(J);return}case"setInterval":{S4(J,Z);return}case"toolCall":case"callTool":return w4(J,Z);case"sendMessage":return C4(J,Z);case"updateContext":{y4(J,Z);return}case"fetch":return b4(J,Z);case"openFilePicker":{m4(J,Z);return}case"callHandler":return h4(J,Z);case"requestDisplayMode":{v4(J,Z);return}case"subscribe":{x4(J,Z);return}case"unsubscribe":{p4(J);return}default:console.warn(`[prefab] Unknown action: ${q}`)}}function V4($,Z){let{key:J,value:q}=$;if(g(q))q=u(q,Z.store,Z.scope);Z.store.set(J,q),Z.rerender(),l($.onSuccess,Z)}function j4($,Z){Z.store.toggle($.key),Z.rerender()}function R4($,Z){let J=$.value??$.item;if(g(J))J=u(J,Z.store,Z.scope);Z.store.append($.key,J,$.index),Z.rerender()}function I4($,Z){Z.store.pop($.key,$.index),Z.rerender()}function P4($,Z){Z.onToast?.({message:L0($.message,Z),description:$.description!=null?L0($.description,Z):void 0,variant:$.variant,duration:$.duration})}function A4($,Z){if(typeof document<"u")document.dispatchEvent(new CustomEvent("prefab:close-overlay"))}function k4($){if(typeof window<"u"){let Z=$.url;if(!Z){console.warn("[prefab] openLink: missing url");return}if(!_1(Z)){console.warn(`[prefab] Blocked unsafe URL scheme: ${Z}`);return}window.open(Z,$.target??"_blank")}}var z0=new Set,f4=20,M1=100;function S4($,Z){let J=Math.max($.intervalMs,M1),q=$.onTick;if(typeof globalThis.setInterval!=="function")return;if(z0.size>=f4){console.warn("[prefab] Max intervals reached, ignoring new setInterval");return}let Q=globalThis.setInterval(()=>void k(q,Z),J);z0.add(Q)}function G1(){for(let $ of z0)globalThis.clearInterval($);z0.clear()}async function w4($,Z){if(!Z.transport){console.warn("[prefab] No MCP transport configured for toolCall");return}let J=$.tool,q=x0($.arguments,Z);try{let Q=await Z.transport.callTool(J,q);if($.resultKey!=null)Z.store.set($.resultKey,Q);let Y=O0(Q);if(Y&&Z.remount)Z.remount(Y);else D0(Q,Z),Z.rerender();await l($.onSuccess,Z,{$result:Q})}catch(Q){await l($.onError,Z,{$error:Q})}}async function C4($,Z){if(!Z.transport){console.warn("[prefab] No MCP transport configured for sendMessage");return}await Z.transport.sendMessage(L0($.message,Z))}function y4($,Z){let J=$.context;if(J!=null)Z.store.merge(J),Z.rerender()}async function b4($,Z){let J=L0($.url,Z);if(!_1(J)){console.warn(`[prefab] Blocked unsafe URL in fetch: ${J}`);return}let q=$.method??"GET",Q=$.headers,Y=$.body!==void 0?JSON.stringify($.body):void 0;try{let U=await globalThis.fetch(J,{method:q,headers:{"Content-Type":"application/json",...Q},...Y&&{body:Y}}),W=await U.json().catch(()=>U.text());if($.resultKey!=null)Z.store.set($.resultKey,W);let H=O0(W);if(H&&Z.remount)Z.remount(H);else D0(W,Z),Z.rerender();await l($.onSuccess,Z,{$result:W})}catch(U){await l($.onError,Z,{$error:U})}}function m4($,Z){if(typeof document>"u")return;let J=document.createElement("input");if(J.type="file",$.accept!=null)J.accept=$.accept;if($.multiple===!0)J.multiple=!0;J.addEventListener("change",()=>{let q=Array.from(J.files??[]);if($.resultKey!=null)Z.store.set($.resultKey,q);Z.rerender(),l($.onSuccess,Z,{$result:q})}),J.click()}async function h4($,Z){let J=$.handler,q=x0($.arguments,Z);if(!Z.transport){console.warn(`[prefab] No transport configured for callHandler: ${J}`);return}try{let Q=await Z.transport.callTool(J,q);if($.resultKey!=null)Z.store.set($.resultKey,Q);let Y=O0(Q);if(Y&&Z.remount)Z.remount(Y);else D0(Q,Z),Z.rerender();await l($.onSuccess,Z,{$result:Q})}catch(Q){await l($.onError,Z,{$error:Q})}}function v4($,Z){if(typeof document<"u")document.dispatchEvent(new CustomEvent("prefab:request-display-mode",{detail:{mode:$.mode}}))}var r=new Map,g4=50,u4=2000;function x4($,Z){let{uri:J,stateKey:q}=$;if(!J||!q){console.warn("[prefab] subscribe: missing uri or stateKey");return}if(r.has(J))return;if(r.size>=g4){console.warn("[prefab] Max subscriptions reached, ignoring new subscribe");return}let Q=(M)=>{let E=O0(M);if(E&&Z.remount)Z.remount(E);else{if(!D0(M,Z))Z.store.set(q,M);Z.rerender()}l($.onData,Z,{$data:M})};if(Z.transport?.subscribe&&Z.transport.capabilities?.subscriptions){let M=Z.transport.subscribe(J,Q);r.set(J,M);return}let Y=$.fallbackTool,U=$.fallbackInterval??u4;if(!Y){console.warn("[prefab] subscribe: host lacks subscriptions and no fallbackTool specified");return}if(!Z.transport){console.warn("[prefab] No MCP transport configured for subscribe fallback");return}let W=$.fallbackArgs??{},H=Math.max(U,M1),X=Z.transport,N=globalThis.setInterval(()=>{(async()=>{try{let M=x0(W,Z),E=await X.callTool(Y,M);Q(E)}catch(M){l($.onError,Z,{$error:M})}})()},H);r.set(J,()=>globalThis.clearInterval(N))}function p4($){let Z=$.uri;if(!Z){console.warn("[prefab] unsubscribe: missing uri");return}let J=r.get(Z);if(J)J(),r.delete(Z)}function X1(){for(let[$,Z]of r)try{Z()}catch(J){console.warn(`[prefab] Error cleaning up subscription '${$}':`,J)}r.clear()}function O0($){if($==null||typeof $!=="object")return null;let Z=$;if("$prefab"in Z&&"view"in Z)return Z;if("structuredContent"in Z){let J=Z.structuredContent;if(J!=null&&typeof J==="object"){let q=J;if("$prefab"in q&&"view"in q)return q}}if("content"in Z&&Array.isArray(Z.content)){for(let J of Z.content)if(J.type==="text"&&typeof J.text==="string")try{let q=JSON.parse(J.text);if(q!=null&&typeof q==="object"){let Q=q;if("$prefab"in Q&&"view"in Q)return Q}}catch{}}return null}function c4($){if($==null||typeof $!=="object")return null;let Z=$;if(g0(Z))return Z;if("structuredContent"in Z){let J=Z.structuredContent;if(J!=null&&typeof J==="object"&&g0(J))return J}if("content"in Z&&Array.isArray(Z.content)){for(let J of Z.content)if(J.type==="text"&&typeof J.text==="string")try{let q=JSON.parse(J.text);if(q!=null&&typeof q==="object"&&g0(q))return q}catch{}}return null}function g0($){if(!("$prefab"in $)||!("update"in $))return!1;let Z=$.update;return Z!=null&&typeof Z==="object"&&"state"in Z}function D0($,Z){let J=c4($);if(!J)return!1;let q=J.update;return Z.store.merge(q.state),!0}var d4=/^\s*(javascript|vbscript|data):/i;function _1($){return!d4.test($)}function L0($,Z){if(g($)){let J=u($,Z.store,Z.scope);return J==null?"":String(J)}return $==null?"":String($)}function x0($,Z){if(!$)return{};let J={};for(let[q,Q]of Object.entries($))J[q]=g(Q)?u(Q,Z.store,Z.scope):Q;return J}async function l($,Z,J){if($==null)return;let q={...Z.scope,...J};await k($,{...Z,scope:q})}function c0($){let Z={};for(let[J,q]of Object.entries($)){let Q=J.startsWith("$")?J:K0(J);if(Array.isArray(q))Z[Q]=q.map((Y)=>Y!=null&&typeof Y==="object"&&!Array.isArray(Y)?c0(Y):Y);else if(q!=null&&typeof q==="object"&&!Array.isArray(q))Z[Q]=c0(q);else Z[Q]=q}return Z}class W0{callbacks=[];track($){this.callbacks.push($)}flush(){for(let $ of this.callbacks)try{$()}catch(Z){console.warn("[prefab] destroy callback error:",Z)}this.callbacks=[]}get size(){return this.callbacks.length}}function l4($){return typeof $==="object"&&"element"in $}var d0=new Map;function G($,Z){if(d0.has($))console.warn(`[prefab] overriding existing renderer for "${$}"`);d0.set($,Z)}function w($,Z){let J=c0($);if(Z.defs?.[J.type]){let Y={...Z.defs[J.type],...J,type:Z.defs[J.type].type};return w(Y,Z)}let q=d0.get(J.type),Q;if(q){let Y=q(J,Z);if(l4(Y))Q=Y.element,Z.destroyRegistry?.track(Y.destroy);else Q=Y}else if(Q=document.createElement("div"),Q.setAttribute("data-prefab-type",J.type),J.children)for(let Y of J.children)Q.appendChild(w(Y,Z));if(Q instanceof HTMLElement){if(J.id)Q.id=J.id;if(J.cssClass){let Y=K(J.cssClass,Z);if(Y)Q.className=(Q.className?Q.className+" ":"")+Y}}if(J.onMount){let Y=J.onMount,U=y(Z);queueMicrotask(()=>void k(Y,U))}return Q}function T($,Z,J){if(!$.children)return;a($.children,Z,J)}function a($,Z,J){let q=0;while(q<$.length){let Q=$[q];if(Q.type==="If")q=s4($,q,Z,J);else if(Q.type==="Elif"||Q.type==="Else")q++;else Z.appendChild(w(Q,J)),q++}}function s4($,Z,J,q){let Q=!1,Y=Z,U=$[Y];if(N1(U.condition,q))p0(U,J,q),Q=!0;Y++;while(Y<$.length){let W=$[Y];if(W.type==="Elif"){if(!Q&&N1(W.condition,q))p0(W,J,q),Q=!0;Y++}else if(W.type==="Else"){if(!Q)p0(W,J,q);Y++;break}else break}return Y}function N1($,Z){if(!$)return!1;if(g($))return Boolean(u($,Z.store,Z.scope));return Boolean(Z.store.get($))}function p0($,Z,J){if(!$.children)return;a($.children,Z,J)}function K($,Z){if(g($)){let J=u($,Z.store,Z.scope);return J==null?"":String(J)}return $==null?"":String($)}function b($,Z){if(g($))return u($,Z.store,Z.scope);return $}function y($){return{store:$.store,transport:$.transport,scope:$.scope,rerender:$.rerender,onToast:$.onToast,remount:$.remount}}function _($,Z){let J=document.createElement($);if(Z)J.className=Z;return J}function l0($,Z){return $.textContent=Z,$}function K1(){G("Column",i4),G("Row",n4),G("Grid",E1),G("GridItem",B1),G("Container",r4),G("Div",F1),G("Span",a4),G("Dashboard",E1),G("DashboardItem",B1),G("Pages",o4),G("Page",F1),G("Detail",t4),G("MasterDetail",e4)}function i4($,Z){let J=_("div","pf-column");J.style.display="flex",J.style.flexDirection="column";let q=T0($);if(q!=null)J.style.gap=`${q*4}px`;if($.align!=null)J.style.alignItems=z1($.align);if($.justify!=null)J.style.justifyContent=L1($.justify);return T($,J,Z),J}function n4($,Z){let J=_("div","pf-row");J.style.display="flex",J.style.flexDirection="row";let q=T0($);if(q!=null)J.style.gap=`${q*4}px`;if($.align!=null)J.style.alignItems=z1($.align);if($.justify!=null)J.style.justifyContent=L1($.justify);if($.wrap===!0)J.style.flexWrap="wrap";return T($,J,Z),J}function E1($,Z){let J=_("div","pf-grid");J.style.display="grid";let q=$.columns??3;J.style.gridTemplateColumns=`repeat(${q}, 1fr)`;let Q=T0($);if(Q!=null)J.style.gap=`${Q*4}px`;return T($,J,Z),J}function B1($,Z){let J=_("div","pf-grid-item");if($.colSpan!=null)J.style.gridColumn=`span ${$.colSpan}`;if($.rowSpan!=null)J.style.gridRow=`span ${$.rowSpan}`;return T($,J,Z),J}function r4($,Z){let J=_("div","pf-container");if(J.style.maxWidth=$.maxWidth??"1200px",J.style.margin="0 auto",$.padding!=null)J.style.padding=`${$.padding*4}px`;return T($,J,Z),J}function F1($,Z){let J=_("div","pf-div");return T($,J,Z),J}function a4($,Z){let J=_("span","pf-span");return T($,J,Z),J}function o4($,Z){let J=_("div","pf-pages");return T($,J,Z),J}function t4($,Z){let J=_("div","pf-detail"),q=$.of!=null?b($.of,Z):void 0;if(q!=null&&q!==""&&q!==!1&&q!==0)T($,J,Z);else if($.empty!=null){let Q=$.empty;J.appendChild(w(Q,Z))}return J}function e4($,Z){let J=_("div","pf-master-detail");J.style.display="flex",J.style.flexDirection="row";let q=T0($);if(q!=null)J.style.gap=`${q*4}px`;let Q=$.masterWidth??"33%",Y=$.children??[];if(Y.length>0){let U=_("div","pf-master-detail-master");U.style.width=Q,U.style.flexShrink="0",U.style.overflow="auto",U.appendChild(w(Y[0],Z)),J.appendChild(U)}if(Y.length>1){let U=_("div","pf-master-detail-detail");U.style.flex="1",U.style.overflow="auto",U.appendChild(w(Y[1],Z)),J.appendChild(U)}return J}var $8=/\bgap-(\d+)\b/;function T0($){if($.gap!=null)return $.gap;if(typeof $.cssClass==="string"){let Z=$8.exec($.cssClass);if(Z)return Number(Z[1])}return null}function z1($){return{start:"flex-start",end:"flex-end",center:"center",stretch:"stretch",baseline:"baseline"}[$]??$}function L1($){return{start:"flex-start",end:"flex-end",center:"center",between:"space-between",around:"space-around",evenly:"space-evenly"}[$]??$}function D1(){G("Heading",Z8),G("H1",($,Z)=>V0($,Z,"h1")),G("H2",($,Z)=>V0($,Z,"h2")),G("H3",($,Z)=>V0($,Z,"h3")),G("H4",($,Z)=>V0($,Z,"h4")),G("Text",J8),G("P",q8),G("Lead",($,Z)=>Z0($,Z,"p","pf-lead")),G("Large",($,Z)=>Z0($,Z,"span","pf-large")),G("Small",($,Z)=>Z0($,Z,"small","pf-small")),G("Muted",($,Z)=>Z0($,Z,"p","pf-muted")),G("BlockQuote",($,Z)=>Z0($,Z,"blockquote","pf-blockquote")),G("Label",($,Z)=>Z0($,Z,"label","pf-label")),G("Link",Y8),G("Code",U8),G("Markdown",W8),G("Kbd",H8)}function Z8($,Z){let J=$.level??2,q=`h${Math.min(Math.max(J,1),6)}`,Q=document.createElement(q);return Q.className=`pf-heading pf-${q}`,Q.textContent=K($.content,Z),Q}function V0($,Z,J){let q=document.createElement(J);return q.className=`pf-heading pf-${J}`,q.textContent=K($.content,Z),q}function J8($,Z){return l0(_("span","pf-text"),K($.content,Z))}function q8($,Z){return l0(_("p","pf-p"),K($.content,Z))}function Z0($,Z,J,q){let Q=document.createElement(J);return Q.className=q,Q.textContent=K($.content,Z),Q}var Q8=/^\s*(javascript|vbscript|data):/i;function Y8($,Z){let J=document.createElement("a");if(J.className="pf-link",J.textContent=K($.content,Z),$.href!=null){let q=K($.href,Z);if(!Q8.test(q))J.href=q}if($.target!=null)J.target=K($.target,Z);return J}function U8($,Z){let J=_("pre","pf-code"),q=_("code");if(q.textContent=K($.content,Z),$.language!=null)q.setAttribute("data-language",$.language);return J.appendChild(q),J}function W8($,Z){let J=_("div","pf-markdown"),q=K($.content,Z);return J.innerHTML=T1(q),J.setAttribute("data-markdown","true"),J}var O1=/^\s*(javascript|vbscript|data):/i;function R0($){return $.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""")}function j0($){let Z=R0($),J=[];return Z=Z.replace(/`([^`]+)`/g,(q,Q)=>{return J.push(`<code>${Q}</code>`),`CODE${J.length-1}`}),Z=Z.replace(/!\[([^\]]*)\]\(([^)]+)\)/g,(q,Q,Y)=>{if(O1.test(Y))return R0(Q);return`<img src="${Y}" alt="${Q}" />`}),Z=Z.replace(/\[([^\]]+)\]\(([^)]+)\)/g,(q,Q,Y)=>{if(O1.test(Y))return Q;return`<a href="${Y}">${Q}</a>`}),Z=Z.replace(/\*{3}(.+?)\*{3}/g,"<strong><em>$1</em></strong>"),Z=Z.replace(/_{3}(.+?)_{3}/g,"<strong><em>$1</em></strong>"),Z=Z.replace(/\*{2}(.+?)\*{2}/g,"<strong>$1</strong>"),Z=Z.replace(/_{2}(.+?)_{2}/g,"<strong>$1</strong>"),Z=Z.replace(/\*(.+?)\*/g,"<em>$1</em>"),Z=Z.replace(/(?<!\w)_(.+?)_(?!\w)/g,"<em>$1</em>"),Z=Z.replace(/~~(.+?)~~/g,"<del>$1</del>"),Z=Z.replace(/\uFDD0CODE(\d+)\uFDD0/g,(q,Q)=>J[parseInt(Q)]),Z}function T1($){let Z=$.replace(/\r\n?/g,`
|
|
2
2
|
`).split(`
|
|
3
|
-
`),J=[],q=0;while(q<Z.length){let Q=Z[q];if(Q.trimStart().startsWith("```")){let W=Q.trimStart().slice(3).trim(),H=[];q++;while(q<Z.length&&!Z[q].trimStart().startsWith("```"))H.push(
|
|
4
|
-
`)}</code></pre>`);continue}if(/^(\s*[-*_]\s*){3,}$/.test(Q)){J.push("<hr />"),q++;continue}let Y=/^(#{1,6})\s+(.+)$/.exec(Q);if(Y){let W=Y[1].length;J.push(`<h${W}>${
|
|
5
|
-
`))}</blockquote>`);continue}if(/^[\s]*[-*+]\s+/.test(Q)){J.push("<ul>");while(q<Z.length&&/^[\s]*[-*+]\s+/.test(Z[q]))J.push(`<li>${
|
|
6
|
-
`)}function H8($,Z){let J=document.createElement("kbd");return J.className="pf-kbd",J.textContent=K($.content,Z),J}function j1(){G("Card",M8),G("CardHeader",s0("pf-card-header")),G("CardTitle",V1("pf-card-title","h3")),G("CardDescription",V1("pf-card-description","p")),G("CardContent",s0("pf-card-content")),G("CardFooter",s0("pf-card-footer"))}function M8($,Z){let J=_("div","pf-card");return J.style.overflow="hidden",T($,J,Z),J}function s0($){return(Z,J)=>{let q=_("div",$);return q.style.padding="16px 24px",T(Z,q,J),q}}function V1($,Z){return(J,q)=>{let Q=document.createElement(Z);return Q.className=$,Q.textContent=K(J.content,q),Q}}function R1(){G("DataTable",G8),G("Badge",X8),G("Dot",_8),G("Metric",N8),G("Ring",E8),G("Progress",B8),G("Separator",F8),G("Loader",K8),G("Icon",z8),G("Sparkline",L8)}function G8($,Z){let J=_("div","pf-datatable-wrapper"),q=document.createElement("table");q.className="pf-datatable",q.style.width="100%",q.style.borderCollapse="collapse";let Q=$.columns??[],Y=b($.rows,Z),U=$.rowKey,W=$.selected,H=document.createElement("thead"),X=document.createElement("tr");for(let M of Q){let E=document.createElement("th");E.className="pf-datatable-th",E.textContent=M.header??M.key,E.style.padding="8px 12px",E.style.textAlign="left",X.appendChild(E)}H.appendChild(X),q.appendChild(H);let N=document.createElement("tbody");if(Array.isArray(Y)){let M=W!=null?b(W,Z):void 0;for(let E of Y){let L=document.createElement("tr");L.className="pf-datatable-row";let B=E;if(U&&M!=null&&B[U]!=null&&String(B[U])===String(M))L.classList.add("pf-datatable-row-selected");if($.onRowClick!=null&&U)L.style.cursor="pointer",L.addEventListener("click",()=>{let F={...Z.scope,$item:B,$index:Y.indexOf(E)},z=y({...Z,scope:F});k($.onRowClick,z)});for(let F of Q){let z=document.createElement("td");z.className="pf-datatable-td";let O;if(F.accessor)O=b(`{{ $item.${F.accessor} }}`,{...Z,scope:{...Z.scope,$item:B}});else if(O=B[F.key],F.format&&O!=null)O=b(`{{ __fmtVal | ${F.format} }}`,{...Z,scope:{...Z.scope,__fmtVal:O}});z.textContent=O==null?"":String(O),z.style.padding="8px 12px",L.appendChild(z)}N.appendChild(L)}}if(q.appendChild(N),$.search===!0){let M=document.createElement("input");M.type="text",M.placeholder="Search...",M.className="pf-datatable-search",M.style.marginBottom="8px",M.style.padding="6px 12px",M.style.width="100%",M.style.boxSizing="border-box",M.addEventListener("input",()=>{let E=M.value.toLowerCase(),L=Array.from(N.querySelectorAll("tr"));for(let B of L){let F=(B.textContent??"").toLowerCase();B.style.display=F.includes(E)?"":"none"}}),J.appendChild(M)}return J.appendChild(q),J}function X8($,Z){let J=_("span","pf-badge"),q=$.variant??"default";return J.setAttribute("data-variant",q),J.style.alignItems="center",J.style.padding="2px 10px",J.style.borderRadius="9999px",J.style.fontSize="12px",J.style.fontWeight="500",J.textContent=K($.label??$.content,Z),O8(J,q),J}function _8($,Z){let J=_("span","pf-dot"),q=$.color??"gray";return J.style.display="inline-block",J.style.width="8px",J.style.height="8px",J.style.borderRadius="50%",J.style.backgroundColor=q,J}function N8($,Z){let J=_("div","pf-metric"),q=_("div","pf-metric-label");q.textContent=K($.label,Z),q.style.fontSize="14px",J.appendChild(q);let Q=_("div","pf-metric-value");if(Q.textContent=K($.value,Z),Q.style.fontSize="28px",Q.style.fontWeight="700",J.appendChild(Q),$.delta!=null){let Y=_("span","pf-metric-delta");Y.textContent=K($.delta,Z);let U=$.trend??"",W=$.trendSentiment??"neutral";if(Y.style.fontSize="14px",Y.style.color=W==="positive"?"green":W==="negative"?"red":"inherit",U==="up")Y.textContent="↑ "+Y.textContent;else if(U==="down")Y.textContent="↓ "+Y.textContent;J.appendChild(Y)}if($.description!=null){let Y=_("div","pf-metric-desc");Y.textContent=K($.description,Z),Y.style.fontSize="12px",J.appendChild(Y)}return J}function E8($,Z){let J=_("div","pf-ring"),q=$.size??80,Q=$.thickness??8,Y=Number(b($.value,Z)??0),U=Math.max(0,Math.min(100,Y)),W=(q-Q)/2,H=2*Math.PI*W,X=H*(1-U/100),N=document.createElementNS("http://www.w3.org/2000/svg","svg");N.setAttribute("width",String(q)),N.setAttribute("height",String(q)),N.setAttribute("viewBox",`0 0 ${q} ${q}`);let M=document.createElementNS("http://www.w3.org/2000/svg","circle");M.setAttribute("cx",String(q/2)),M.setAttribute("cy",String(q/2)),M.setAttribute("r",String(W)),M.setAttribute("fill","none"),M.setAttribute("stroke","var(--muted, #e5e7eb)"),M.setAttribute("stroke-width",String(Q));let E=document.createElementNS("http://www.w3.org/2000/svg","circle");if(E.setAttribute("cx",String(q/2)),E.setAttribute("cy",String(q/2)),E.setAttribute("r",String(W)),E.setAttribute("fill","none"),E.setAttribute("stroke","var(--primary, #3b82f6)"),E.setAttribute("stroke-width",String(Q)),E.setAttribute("stroke-dasharray",String(H)),E.setAttribute("stroke-dashoffset",String(X)),E.setAttribute("stroke-linecap","round"),E.style.transform="rotate(-90deg)",E.style.transformOrigin="center",N.appendChild(M),N.appendChild(E),J.appendChild(N),$.label!=null){let L=_("div","pf-ring-label");L.textContent=K($.label,Z),L.style.textAlign="center",L.style.fontSize="12px",J.appendChild(L)}return J}function B8($,Z){let J=_("div","pf-progress");J.setAttribute("role","progressbar");let q=Number(b($.value,Z)??0),Q=$.max??100,Y=Q>0?Math.max(0,Math.min(100,q/Q*100)):0;J.setAttribute("aria-valuenow",String(q)),J.setAttribute("aria-valuemin","0"),J.setAttribute("aria-valuemax",String(Q)),J.style.height="8px",J.style.borderRadius="4px",J.style.overflow="hidden";let U=_("div","pf-progress-fill");return U.style.height="100%",U.style.width=`${Y}%`,U.style.borderRadius="4px",U.style.transition="width 0.3s ease",J.appendChild(U),J}function F8($,Z){let J=document.createElement("hr");return J.className="pf-separator",J.style.border="none",J.style.margin="8px 0",J}function K8($,Z){let J=_("div","pf-loader");return J.textContent="⏳",J.style.display="flex",J.style.justifyContent="center",J.style.padding="16px",J}function z8($,Z){let J=_("span","pf-icon");return J.setAttribute("data-icon",K($.name??$.content,Z)),J}function L8($,Z){let J=_("div","pf-sparkline"),q=$.data??[];if(q.length===0)return J;let Q=120,Y=32,U=Math.max(...q),W=Math.min(...q),H=U-W||1,X=document.createElementNS("http://www.w3.org/2000/svg","svg");X.setAttribute("width",String(Q)),X.setAttribute("height",String(Y)),X.setAttribute("viewBox",`0 0 ${Q} ${Y}`);let N=q.length>1?q.length-1:1,M=q.map((L,B)=>{let F=B/N*Q,z=Y-(L-W)/H*(Y-4)-2;return`${F},${z}`}).join(" "),E=document.createElementNS("http://www.w3.org/2000/svg","polyline");return E.setAttribute("points",M),E.setAttribute("fill","none"),E.setAttribute("stroke","var(--primary, #3b82f6)"),E.setAttribute("stroke-width","1.5"),X.appendChild(E),J.appendChild(X),J}function O8($,Z){let q={success:{bg:"#10b981",fg:"#fff"},warning:{bg:"#f59e0b",fg:"#fff"},info:{bg:"#3b82f6",fg:"#fff"}}[Z];if(q)$.style.backgroundColor=q.bg,$.style.color=q.fg}function P1(){G("Form",D8),G("Input",T8),G("Textarea",V8),G("Button",j8),G("ButtonGroup",R8),G("Select",I8),G("SelectOption",P8),G("SelectGroup",j0("pf-select-group")),G("SelectLabel",H0("pf-select-label")),G("SelectSeparator",I1),G("Checkbox",A8),G("Switch",k8),G("Slider",f8),G("Radio",w8),G("RadioGroup",C8),G("Combobox",y8),G("ComboboxOption",b8),G("ComboboxGroup",j0("pf-combobox-group")),G("ComboboxLabel",H0("pf-combobox-label")),G("ComboboxSeparator",I1),G("Calendar",m8),G("DatePicker",h8),G("Field",j0("pf-field")),G("FieldTitle",H0("pf-field-title")),G("FieldDescription",H0("pf-field-description")),G("FieldContent",j0("pf-field-content")),G("FieldError",H0("pf-field-error")),G("ChoiceCard",v8)}function D8($,Z){let J=document.createElement("form");return J.className="pf-form",J.addEventListener("submit",(q)=>{q.preventDefault();let Q=new FormData(J),Y={};if(Q.forEach((U,W)=>{Y[W]=U}),Z.store.merge(Y),$.onSubmit!=null){let U=y(Z);U.scope={...Z.scope,...Y},k($.onSubmit,U)}}),T($,J,Z),J}function T8($,Z){let J=_("div","pf-input-wrapper");if(J.style.display="flex",J.style.flexDirection="column",J.style.gap="4px",$.label!=null){let Y=document.createElement("label");if(Y.className="pf-input-label",Y.textContent=K($.label,Z),$.name!=null)Y.htmlFor=$.name;Y.style.fontSize="14px",Y.style.fontWeight="500",J.appendChild(Y)}let q=document.createElement("input");if(q.className="pf-input",q.type=$.inputType??"text",$.name!=null)q.name=$.name;if($.name!=null)q.id=`pf-input-${$.name}`;if($.placeholder!=null)q.placeholder=K($.placeholder,Z);if($.required===!0)q.required=!0,q.setAttribute("aria-required","true");if($.error!=null)q.setAttribute("aria-invalid","true");let Q=$.name;if(Q){let Y=Z.store.get(Q);if(Y!=null)q.value=String(Y);q.addEventListener("input",()=>{if(Z.store.set(Q,q.value),$.onChange!=null)k($.onChange,{...y(Z),scope:{...Z.scope,$event:q.value}})})}return i0(q),J.appendChild(q),J}function V8($,Z){let J=_("div","pf-textarea-wrapper"),q=document.createElement("textarea");if(q.className="pf-textarea",$.name!=null)q.name=$.name;if($.name!=null)q.id=`pf-textarea-${$.name}`;if($.placeholder!=null)q.placeholder=K($.placeholder,Z);if($.rows!=null)q.rows=$.rows;if($.required===!0)q.setAttribute("aria-required","true");let Q=$.name;if(Q!=null){let Y=Z.store.get(Q);if(Y!=null)q.value=String(Y);q.addEventListener("input",()=>{if(Z.store.set(Q,q.value),$.onChange!=null)k($.onChange,{...y(Z),scope:{...Z.scope,$event:q.value}})})}return i0(q),J.appendChild(q),J}function j8($,Z){let J=document.createElement("button");J.className="pf-button",J.type=$.submit===!0?"submit":"button",J.textContent=K($.label,Z);let q=$.variant??"default";if(J.setAttribute("data-variant",q),S8(J,q),$.size!=null)J.setAttribute("data-size",$.size);if($.disabled===!0)J.disabled=!0;if($.onClick!=null)J.addEventListener("click",()=>{k($.onClick,y(Z))});return J}function R8($,Z){let J=_("div","pf-button-group");return J.style.display="flex",J.style.gap="8px",T($,J,Z),J}function I8($,Z){let J=_("div","pf-select-wrapper"),q=document.createElement("select");if(q.className="pf-select",$.name!=null)q.name=$.name;if(i0(q),$.placeholder!=null){let U=document.createElement("option");U.value="",U.textContent=K($.placeholder,Z),U.disabled=!0,U.selected=!0,U.hidden=!0,q.appendChild(U)}let Q=$.options;if(Array.isArray(Q))for(let U of Q){let W=document.createElement("option");W.value=U.value??"",W.textContent=U.label??W.value,q.appendChild(W)}if($.children)for(let U of $.children)if(U.type==="SelectOption"){let W=document.createElement("option");W.value=U.value??"",W.textContent=U.label??W.value,q.appendChild(W)}else q.appendChild(w(U,Z));let Y=$.name;if(Y){let U=Z.store.get(Y);if(U!=null)q.value=String(U);q.addEventListener("change",()=>{if(Z.store.set(Y,q.value),$.onChange!=null)k($.onChange,{...y(Z),scope:{...Z.scope,$event:q.value}})})}return J.appendChild(q),J}function P8($,Z){return _("span")}function A8($,Z){let J=_("label","pf-checkbox-wrapper");J.style.display="flex",J.style.alignItems="center",J.style.gap="8px",J.style.cursor="pointer";let q=document.createElement("input");if(q.type="checkbox",q.className="pf-checkbox",$.name!=null)q.name=$.name;if($.checked===!0)q.checked=!0;let Q=$.name;if(Q){let Y=Z.store.get(Q);if(typeof Y==="boolean")q.checked=Y;q.addEventListener("change",()=>{if(Z.store.set(Q,q.checked),$.onChange!=null)k($.onChange,{...y(Z),scope:{...Z.scope,$event:q.checked}})})}if(J.appendChild(q),$.label!=null){let Y=_("span");Y.textContent=K($.label,Z),J.appendChild(Y)}return J}function k8($,Z){let J=_("label","pf-switch-wrapper");J.style.display="flex",J.style.alignItems="center",J.style.gap="8px",J.style.cursor="pointer";let q=document.createElement("input");if(q.type="checkbox",q.className="pf-switch",q.setAttribute("role","switch"),$.name!=null)q.name=$.name;let Q=$.name;if(Q){let Y=Z.store.get(Q);if(typeof Y==="boolean")q.checked=Y;q.addEventListener("change",()=>{if(Z.store.set(Q,q.checked),$.onChange!=null)k($.onChange,{...y(Z),scope:{...Z.scope,$event:q.checked}})})}if(J.appendChild(q),$.label!=null){let Y=_("span");Y.textContent=K($.label,Z),J.appendChild(Y)}return J}function f8($,Z){let J=_("div","pf-slider-wrapper"),q=document.createElement("input");if(q.type="range",q.className="pf-slider",$.name!=null)q.name=$.name;if($.min!=null)q.min=String($.min);if($.max!=null)q.max=String($.max);if($.step!=null)q.step=String($.step);let Q=$.name;if(Q){let Y=Z.store.get(Q);if(Y!=null)q.value=String(Y);q.addEventListener("input",()=>{if(Z.store.set(Q,Number(q.value)),$.onChange!=null)k($.onChange,{...y(Z),scope:{...Z.scope,$event:Number(q.value)}})})}return J.appendChild(q),J}function i0($){$.style.padding="8px 12px",$.style.fontSize="14px",$.style.width="100%",$.style.boxSizing="border-box"}function S8($,Z){if($.style.padding="8px 16px",$.style.fontSize="14px",$.style.fontWeight="500",$.style.cursor="pointer",$.style.border="none",Z==="ghost")$.style.backgroundColor="transparent",$.style.color="inherit"}function j0($){return(Z,J)=>{let q=_("div",$);return T(Z,q,J),q}}function H0($){return(Z,J)=>{let q=_("span",$);return q.textContent=K(Z.content,J),q}}function I1(){let $=document.createElement("hr");return $.className="pf-separator",$.style.border="none",$.style.margin="4px 0",$}function w8($,Z){let J=_("label","pf-radio");J.style.display="flex",J.style.alignItems="center",J.style.gap="8px",J.style.cursor="pointer";let q=document.createElement("input");if(q.type="radio",q.value=K($.value,Z),J.appendChild(q),$.label!=null){let Q=_("span","pf-radio-label");Q.textContent=K($.label,Z),J.appendChild(Q)}return J}function C8($,Z){let J=_("fieldset","pf-radio-group");if(J.style.border="none",J.style.padding="0",J.style.display="flex",J.style.flexDirection="column",J.style.gap="8px",$.label!=null){let Y=document.createElement("legend");Y.textContent=K($.label,Z),Y.style.fontWeight="500",Y.style.marginBottom="4px",J.appendChild(Y)}T($,J,Z);let q=K($.name,Z),Q=Z.store.get(q);for(let Y of Array.from(J.querySelectorAll('input[type="radio"]')))if(Y.name=q,Q!=null&&Y.value===String(Q))Y.checked=!0;return J.addEventListener("change",(Y)=>{let U=Y.target;if(U.type==="radio"){if(Z.store.set(q,U.value),$.onChange!=null)k($.onChange,y(Z))}}),J}function y8($,Z){let J=_("div","pf-combobox"),q=document.createElement("input");if(q.className="pf-combobox-input",q.type="text",q.name=K($.name,Z),$.placeholder!=null)q.placeholder=K($.placeholder,Z);if($.value!==void 0)q.value=K($.value,Z);let Q=q.name,Y=Z.store.get(Q);if(Y!=null)q.value=String(Y);q.style.padding="6px 12px",q.style.borderRadius="6px",q.style.width="100%",q.style.boxSizing="border-box";let U=_("div","pf-combobox-dropdown");if(U.style.display="none",U.style.position="absolute",U.style.borderRadius="6px",U.style.maxHeight="200px",U.style.overflowY="auto",U.style.zIndex="50",T($,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 X=(H.textContent??"").toLowerCase();H.style.display=X.includes(W)?"":"none"}});if($.onChange!=null)J.addEventListener("pf-combobox-select",()=>{k($.onChange,{...y(Z),scope:{...Z.scope,$event:q.value}})});return J.style.position="relative",J.appendChild(q),J.appendChild(U),J}function b8($,Z){let J=_("div","pf-combobox-option");return J.style.padding="6px 12px",J.style.cursor="pointer",J.textContent=K($.label??$.value,Z),J.dataset.value=K($.value,Z),J.addEventListener("mousedown",()=>{let q=J.closest(".pf-combobox"),Q=q?.querySelector("input");if(Q)Q.value=J.dataset.value??"",Z.store.set(Q.name,Q.value),q?.dispatchEvent(new CustomEvent("pf-combobox-select",{bubbles:!1}))}),J}function m8($,Z){let J=_("div","pf-calendar"),q=document.createElement("input");if(q.type="date",q.name=K($.name,Z),$.value!==void 0)q.value=K($.value,Z);let Q=q.name,Y=Z.store.get(Q);if(Y!=null)q.value=String(Y);if($.minDate!=null)q.min=K($.minDate,Z);if($.maxDate!=null)q.max=K($.maxDate,Z);return q.style.padding="6px 12px",q.style.borderRadius="6px",q.addEventListener("change",()=>{if(Z.store.set(q.name,q.value),$.onChange!=null)k($.onChange,y(Z))}),J.appendChild(q),J}function h8($,Z){let J=_("div","pf-datepicker"),q=document.createElement("input");if(q.type="date",q.name=K($.name,Z),$.placeholder!=null)q.placeholder=K($.placeholder,Z);if($.value!==void 0)q.value=K($.value,Z);let Q=q.name,Y=Z.store.get(Q);if(Y!=null)q.value=String(Y);if($.minDate!=null)q.min=K($.minDate,Z);if($.maxDate!=null)q.max=K($.maxDate,Z);return q.style.padding="6px 12px",q.style.borderRadius="6px",q.style.width="100%",q.style.boxSizing="border-box",q.addEventListener("change",()=>{if(Z.store.set(q.name,q.value),$.onChange!=null)k($.onChange,y(Z))}),J.appendChild(q),J}function v8($,Z){let J=_("div","pf-choice-card");if(J.style.padding="16px",J.style.cursor="pointer",J.style.transition="border-color 0.2s",J.dataset.value=K($.value,Z),$.selected===!0)J.dataset.selected="true";if($.label!=null){let q=_("div","pf-choice-card-label");q.textContent=K($.label,Z),q.style.fontWeight="600",J.appendChild(q)}if($.description!=null){let q=_("div","pf-choice-card-description");q.textContent=K($.description,Z),q.style.fontSize="14px",J.appendChild(q)}if(T($,J,Z),$.onClick!=null)J.addEventListener("click",()=>{k($.onClick,y(Z))});return J}function A1(){G("Tabs",g8),G("Tab",u8),G("Accordion",x8),G("AccordionItem",p8),G("Dialog",c8),G("Popover",d8),G("Tooltip",l8),G("HoverCard",s8),G("Carousel",i8)}function g8($,Z){let J=_("div","pf-tabs"),q=_("div","pf-tabs-bar");q.setAttribute("role","tablist"),q.style.display="flex",q.style.gap="4px",q.style.marginBottom="12px";let Q=[],Y=[];if($.children)for(let W=0;W<$.children.length;W++){let H=$.children[W],X=`pf-tab-${Math.random().toString(36).slice(2,8)}`,N=`pf-panel-${Math.random().toString(36).slice(2,8)}`,M=document.createElement("button");M.type="button",M.className="pf-tab-trigger",M.textContent=H.title??`Tab ${W+1}`,M.setAttribute("role","tab"),M.setAttribute("aria-selected",W===0?"true":"false"),M.setAttribute("aria-controls",N),M.id=X,M.tabIndex=W===0?0:-1,M.style.padding="8px 16px",M.style.border="none",M.style.background="none",M.style.cursor="pointer",M.style.borderBottom="2px solid transparent",M.style.marginBottom="-2px",M.style.fontSize="14px";let E=_("div","pf-tab-panel");if(E.style.display=W===0?"block":"none",E.setAttribute("role","tabpanel"),E.setAttribute("aria-labelledby",X),E.id=N,E.tabIndex=0,T(H,E,Z),M.addEventListener("click",()=>{U(W)}),W===0)M.classList.add("pf-tab-active"),M.style.fontWeight="600";Y.push(M),Q.push(E),q.appendChild(M)}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 X;if(W.key==="ArrowRight")X=(H+1)%Y.length;else if(W.key==="ArrowLeft")X=(H-1+Y.length)%Y.length;else if(W.key==="Home")X=0;else if(W.key==="End")X=Y.length-1;else return;W.preventDefault(),U(X)}),J.appendChild(q);for(let W of Q)J.appendChild(W);return J}function u8($,Z){let J=_("div","pf-tab");return T($,J,Z),J}function x8($,Z){let J=_("div","pf-accordion");return T($,J,Z),J}function p8($,Z){let J=_("div","pf-accordion-item"),q=`pf-acc-${Math.random().toString(36).slice(2,8)}`,Q=document.createElement("button");Q.type="button",Q.className="pf-accordion-trigger",Q.textContent=$.title??"",Q.setAttribute("aria-expanded","false"),Q.setAttribute("aria-controls",q),Q.style.width="100%",Q.style.textAlign="left",Q.style.padding="12px 0",Q.style.border="none",Q.style.background="none",Q.style.cursor="pointer",Q.style.fontSize="14px",Q.style.fontWeight="500";let Y=_("div","pf-accordion-content");return Y.id=q,Y.setAttribute("role","region"),Y.setAttribute("aria-labelledby",Q.id),Y.style.display="none",Y.style.paddingBottom="12px",T($,Y,Z),Q.addEventListener("click",()=>{let U=Y.style.display!=="none";Y.style.display=U?"none":"block",Q.setAttribute("aria-expanded",U?"false":"true")}),J.appendChild(Q),J.appendChild(Y),J}function c8($,Z){let J=_("div","pf-dialog-wrapper");if($.trigger!=null){let Y=w($.trigger,Z);Y.addEventListener("click",()=>{q.showModal()}),J.appendChild(Y)}let q=document.createElement("dialog");if(q.className="pf-dialog",q.setAttribute("aria-modal","true"),q.style.maxWidth="500px",q.style.width="100%",q.style.padding="24px",$.title!=null){let Y=_("h2","pf-dialog-title");Y.textContent=K($.title,Z),Y.id=`pf-dialog-title-${Math.random().toString(36).slice(2,8)}`,q.setAttribute("aria-labelledby",Y.id),q.appendChild(Y)}if($.description!=null){let Y=_("p","pf-dialog-desc");Y.textContent=K($.description,Z),q.appendChild(Y)}let Q=_("div","pf-dialog-body");if(T($,Q,Z),q.appendChild(Q),$.dismissible!==!1)q.addEventListener("click",(Y)=>{if(Y.target===q)q.close()});return document.addEventListener("prefab:close-overlay",()=>q.close()),J.appendChild(q),J}function d8($,Z){let J=_("div","pf-popover");J.style.position="relative",J.style.display="inline-block";let q=_("div","pf-popover-content");if(q.style.display="none",q.style.position="absolute",q.style.zIndex="50",q.style.padding="12px",q.style.boxShadow="0 4px 6px -1px rgb(0 0 0 / 0.1)",$.title!=null){let Q=_("div","pf-popover-title");Q.textContent=K($.title,Z),Q.style.fontWeight="600",Q.style.marginBottom="4px",q.appendChild(Q)}return T($,q,Z),J.addEventListener("click",(Q)=>{if(q.contains(Q.target)&&q.style.display!=="none")return;q.style.display=q.style.display==="none"?"block":"none"}),J.appendChild(q),J}function l8($,Z){let J=_("div","pf-tooltip");J.style.position="relative",J.style.display="inline-block";let q=`pf-tip-${Math.random().toString(36).slice(2,8)}`,Q=_("div","pf-tooltip-content");return Q.id=q,Q.setAttribute("role","tooltip"),Q.textContent=K($.content??"",Z),Q.style.display="none",Q.style.position="absolute",Q.style.bottom="100%",Q.style.left="50%",Q.style.transform="translateX(-50%)",Q.style.padding="4px 8px",Q.style.borderRadius="4px",Q.style.color="#fff",Q.style.fontSize="12px",Q.style.whiteSpace="nowrap",Q.style.zIndex="50",T($,J,Z),J.setAttribute("aria-describedby",q),J.addEventListener("mouseenter",()=>{Q.style.display="block"}),J.addEventListener("mouseleave",()=>{Q.style.display="none"}),J.addEventListener("focus",()=>{Q.style.display="block"},!0),J.addEventListener("blur",()=>{Q.style.display="none"},!0),J.appendChild(Q),J}function s8($,Z){let J=_("div","pf-hover-card");J.style.position="relative",J.style.display="inline-block";let q=_("div","pf-hover-card-content");return q.style.display="none",q.style.position="absolute",q.style.zIndex="50",q.style.padding="16px",q.style.boxShadow="0 4px 6px -1px rgb(0 0 0 / 0.1)",q.style.minWidth="200px",T($,q,Z),J.addEventListener("mouseenter",()=>{q.style.display="block"}),J.addEventListener("mouseleave",()=>{q.style.display="none"}),J.appendChild(q),J}function i8($,Z){let J=_("div","pf-carousel");J.style.position="relative",J.style.overflow="hidden",J.setAttribute("role","region"),J.setAttribute("aria-roledescription","carousel"),J.setAttribute("aria-label",K($.label??"Carousel",Z));let q=_("div","pf-carousel-track");q.style.display="flex",q.style.transition="transform 0.3s ease",T($,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 k1(){G("ForEach",n8),G("If",f1),G("Elif",r8),G("Else",a8),G("Condition",o8),G("Define",t8),G("Use",e8),G("Slot",$2)}function n8($,Z){let J=document.createDocumentFragment(),q=$.expression;if(!q)return J;let Q;if(g(q)){let U=u(q,Z.store,Z.scope);Q=Array.isArray(U)?U:[]}else{let U=Z.store.get(q);Q=Array.isArray(U)?U:[]}let Y=$.let??{};for(let U=0;U<Q.length;U++){let W=Q[U],H={...Z.scope,$item:W,$index:U,...Y},X={...Z,scope:H};if($.children)a($.children,J,X)}return J}function f1($,Z){if(S1($.condition,Z)){let q=document.createDocumentFragment();if($.children)a($.children,q,Z);return q}return document.createDocumentFragment()}function r8($,Z){return f1($,Z)}function a8($,Z){let J=document.createDocumentFragment();if($.children)a($.children,J,Z);return J}function S1($,Z){if(!$)return!1;if(g($))return Boolean(u($,Z.store,Z.scope));return Boolean(Z.store.get($))}function o8($,Z){let J=document.createDocumentFragment(),q=$.cases,Q=$.else;if(q){for(let Y of q)if(S1(Y.when,Z)){if(Y.children)a(Y.children,J,Z);return J}}if(Q)a(Q,J,Z);return J}function t8($,Z){let J=$.name;if(J&&$.children)Z.templates=Z.templates??{},Z.templates[J]=$.children;return document.createDocumentFragment()}function e8($,Z){let J=document.createDocumentFragment(),q=$.def??$.name,Q=Z.templates?.[q];if(!Q)return J;let Y=$.overrides??{},U={...Z.scope,...Y},W={...Z,scope:U};for(let H of Q)J.appendChild(w(H,W));return J}function $2($,Z){let J=document.createDocumentFragment(),q=$.name??"default",Y=Z.slots?.[q]??$.children;if(Y)for(let U of Y)J.appendChild(w(U,Z));return J}function w1(){G("Alert",Z2),G("AlertTitle",J2),G("AlertDescription",q2)}function Z2($,Z){let J=_("div","pf-alert");J.setAttribute("role","alert");let q=$.variant??"default";if(J.setAttribute("data-variant",q),J.style.padding="12px 16px",$.icon!=null){let Q=_("span","pf-alert-icon");Q.setAttribute("data-icon",$.icon),Q.style.marginRight="8px",J.appendChild(Q)}return T($,J,Z),J}function J2($,Z){let J=_("h5","pf-alert-title");return J.textContent=K($.content,Z),J.style.fontWeight="600",J.style.marginBottom="4px",J}function q2($,Z){let J=_("p","pf-alert-description");return J.textContent=K($.content,Z),J.style.fontSize="14px",J}function C1(){G("Image",Q2),G("Audio",Y2),G("Video",U2),G("Embed",W2),G("Svg",M2),G("DropZone",G2),G("Mermaid",X2)}function Q2($,Z){let J=document.createElement("img");if(J.className="pf-image",J.src=K($.src,Z),$.alt!=null)J.alt=K($.alt,Z);if($.width!=null)J.width=$.width;if($.height!=null)J.height=$.height;return J.style.maxWidth="100%",J}function Y2($,Z){let J=document.createElement("audio");return J.className="pf-audio",J.src=K($.src,Z),J.controls=!0,J}function U2($,Z){let J=document.createElement("video");if(J.className="pf-video",J.src=K($.src,Z),J.controls=!0,$.width!=null)J.width=$.width;if($.height!=null)J.height=$.height;return J.style.maxWidth="100%",J}function W2($,Z){let J=_("div","pf-embed"),q=document.createElement("iframe");return q.src=K($.src,Z),q.style.width="100%",q.style.height=$.height!=null?`${$.height}px`:"400px",q.style.border="none",q.setAttribute("sandbox","allow-scripts"),J.appendChild(q),J}var H2=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 M2($,Z){let J=_("div","pf-svg"),q=K($.content,Z);if(!q.includes("<svg"))return J;let Y=new DOMParser().parseFromString(q,"image/svg+xml").querySelector("svg");if(!Y)return J;return y1(Y),J.appendChild(document.importNode(Y,!0)),J}function y1($){let Z=Array.from($.children);for(let J of Z){if(!H2.has(J.tagName.toLowerCase())){J.remove();continue}for(let q of Array.from(J.attributes)){let Q=q.name.toLowerCase();if(Q.startsWith("on")||Q==="href"&&q.value.trim().toLowerCase().startsWith("javascript:"))J.removeAttribute(q.name)}y1(J)}}function G2($,Z){let J=_("div","pf-dropzone");return J.style.padding="32px",J.style.textAlign="center",J.style.cursor="pointer",J.textContent=K($.label??"Drop files here",Z),J.addEventListener("dragover",(q)=>{q.preventDefault(),J.classList.add("pf-dropzone-active")}),J.addEventListener("dragleave",()=>{J.classList.remove("pf-dropzone-active")}),J.addEventListener("drop",(q)=>{q.preventDefault(),J.classList.remove("pf-dropzone-active")}),J}function X2($,Z){let J=_("div","pf-mermaid");J.setAttribute("data-mermaid","true");let q=K($.content,Z);if(J.textContent=q,typeof globalThis.mermaid<"u")J.classList.add("mermaid"),J.textContent=q;return J}var _2="https://cdn.jsdelivr.net/npm/pdfjs-dist@4.9/build/pdf.min.mjs",N2="https://cdn.jsdelivr.net/npm/pdfjs-dist@4.9/build/pdf.worker.min.mjs",n0=null,R0=null;async function E2(){if(n0)return n0;if(R0)return R0;return R0=import(_2).then(($)=>{let Z=$;return Z.GlobalWorkerOptions.workerSrc=N2,n0=Z,Z}),R0}function m1(){G("PdfViewer",B2)}function B2($,Z){let J=_("div","pf-pdf-viewer"),q=$.src!=null?K($.src,Z):void 0,Q=$.data,Y=$.page!=null?$.page:1,U=$.zoom!=null?$.zoom:"fit-width",W=$.toolbar!==!1,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 X=_("div","pf-pdf-loading");return X.textContent="Loading PDF…",X.style.display="flex",X.style.alignItems="center",X.style.justifyContent="center",X.style.flex="1",X.style.color="var(--color-text-secondary, #6b7280)",J.appendChild(X),F2(J,X,{src:q,data:Q,initialPage:Y,zoom:U,showToolbar:W}),J}async function F2($,Z,J){try{let q=await E2(),Q;if(J.src)Q={url:J.src};else if(J.data){let E=atob(J.data),L=new Uint8Array(E.length);for(let B=0;B<E.length;B++)L[B]=E.charCodeAt(B);Q={data:L}}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 E=K2(Y.numPages,U,{onPrev:()=>{if(U>1)U--,M()},onNext:()=>{if(U<Y.numPages)U++,M()},onPageChange:(L)=>{let B=Math.max(1,Math.min(L,Y.numPages));if(B!==U)U=B,M()}});W=E.pageInput,H=E.pageCount,$.insertBefore(E.el,$.firstChild)}let X=_("div","pf-pdf-canvas-container");X.style.flex="1",X.style.overflow="auto",X.style.display="flex",X.style.justifyContent="center",X.style.padding="8px",$.appendChild(X);let N=document.createElement("canvas");N.style.display="block",N.style.boxShadow="var(--shadow-md, 0 4px 6px -1px rgba(0,0,0,.1))",X.appendChild(N);async function M(){let E=await Y.getPage(U),L=X.clientWidth-16,B,F=E.getViewport({scale:1});if(J.zoom==="fit-width")B=L/F.width;else if(J.zoom==="fit-page"){let I=X.clientHeight-16,V=L/F.width,D=I/F.height;B=Math.min(V,D)}else B=typeof J.zoom==="number"?J.zoom:1;let z=E.getViewport({scale:B});N.width=z.width,N.height=z.height,N.style.width=`${z.width}px`,N.style.height=`${z.height}px`;let O=N.getContext("2d");if(!O)return;if(await E.render({canvasContext:O,viewport:z}).promise,W)W.value=String(U);if(H)H.textContent=`/ ${Y.numPages}`}await M()}catch(q){Z.textContent=`PDF Error: ${q instanceof Error?q.message:String(q)}`,Z.style.color="var(--color-text-danger, #dc2626)"}}function K2($,Z,J){let q=_("div","pf-pdf-toolbar");q.style.display="flex",q.style.alignItems="center",q.style.gap="8px",q.style.padding="6px 12px",q.style.borderBottom="1px solid var(--color-border-primary, #e5e7eb)",q.style.background="var(--color-background-primary, #fff)",q.style.flexShrink="0",q.style.fontSize="13px";let Q=document.createElement("button");Q.textContent="‹",Q.title="Previous page",Q.className="pf-pdf-btn",b1(Q),Q.addEventListener("click",J.onPrev);let Y=document.createElement("button");Y.textContent="›",Y.title="Next page",Y.className="pf-pdf-btn",b1(Y),Y.addEventListener("click",J.onNext);let U=document.createElement("input");U.type="number",U.min="1",U.max=String($),U.value=String(Z),U.style.width="48px",U.style.textAlign="center",U.style.border="1px solid var(--color-border-primary, #e5e7eb)",U.style.borderRadius="4px",U.style.padding="2px 4px",U.style.fontSize="13px",U.addEventListener("change",()=>{let 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 b1($){$.style.border="1px solid var(--color-border-primary, #e5e7eb)",$.style.borderRadius="4px",$.style.background="var(--color-background-primary, #fff)",$.style.cursor="pointer",$.style.padding="2px 8px",$.style.fontSize="16px",$.style.lineHeight="1"}var P0=["#3b82f6","#10b981","#f59e0b","#ef4444","#8b5cf6","#ec4899"];function A0($,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 M0($,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">${I0(q)}</div>`;for(let z of Q)H+='<div class="pf-chart-tooltip-row">',H+=`<span class="pf-chart-tooltip-dot" style="background:${I0(z.color)}"></span>`,H+=`<span>${I0(z.label)}:</span> <strong>${I0(String(z.value))}</strong>`,H+="</div>";Y.innerHTML=H;let X=U.getBoundingClientRect(),N=W.getBoundingClientRect(),M=U.viewBox.baseVal,E=X.width/(M.width||1),L=X.left-N.left+Z*E,B=Y.offsetWidth||100,F=L+12;if(F+B>N.width)F=L-B-12;Y.style.left=`${Math.max(0,F)}px`,Y.style.top="4px",Y.classList.add("pf-visible")}function I0($){return $.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""")}function h1($,Z,J,q,Q,Y,U,W){let H=Q.plotWidth/J.length;for(let X=0;X<J.length;X++){let N=Q.plotLeft+X*H,M=document.createElementNS("http://www.w3.org/2000/svg","rect");M.setAttribute("x",String(N)),M.setAttribute("y",String(Q.plotTop)),M.setAttribute("width",String(H)),M.setAttribute("height",String(Q.plotHeight)),M.setAttribute("fill","transparent"),M.style.cursor="default";let E=Y?J[X][Y]:void 0,L=E!=null?W?W(E):String(E):void 0,B=q.map((I,V)=>({label:I.label??I.dataKey,value:U(J[X][I.dataKey],I,V),color:I.color??P0[V%P0.length]})),F=N+H/2,z=()=>M0($,F,Q.plotTop,L,B),O=()=>$.tooltip.classList.remove("pf-visible");M.addEventListener("mouseenter",z),M.addEventListener("mouseleave",O),M.addEventListener("touchstart",z,{passive:!0}),M.addEventListener("touchend",O,{passive:!0}),Z.appendChild(M)}}function v1($,Z,J,q,Q,Y,U,W,H,X){let N=J.length===1?Q.plotWidth:Q.plotWidth/(J.length-1);for(let M=0;M<J.length;M++){let E=J.length===1?(Q.plotLeft+Q.plotRight)/2:Q.plotLeft+M/(J.length-1)*Q.plotWidth,L=J.length===1?Q.plotLeft:E-N/2,B=J.length===1?Q.plotWidth:N,F=document.createElementNS("http://www.w3.org/2000/svg","rect");F.setAttribute("x",String(Math.max(Q.plotLeft,L))),F.setAttribute("y",String(Q.plotTop)),F.setAttribute("width",String(Math.min(B,Q.plotRight-Math.max(Q.plotLeft,L)))),F.setAttribute("height",String(Q.plotHeight)),F.setAttribute("fill","transparent"),F.style.cursor="default";let z=Y?J[M][Y]:void 0,O=z!=null?X?X(z):String(z):void 0,I=q.map((j,C)=>({label:j.label??j.dataKey,value:U(J[M][j.dataKey],j,C),color:j.color??P0[C%P0.length]})),V=()=>{if(M0($,E,Q.plotTop,O,I),W)W.setAttribute("x1",String(E)),W.setAttribute("x2",String(E)),W.setAttribute("opacity","1");if(H)for(let j of H){for(let C of j)C.setAttribute("data-visible","false");j[M]?.setAttribute("data-visible","true")}},D=()=>{if($.tooltip.classList.remove("pf-visible"),W)W.setAttribute("opacity","0");if(H)for(let j of H)for(let C of j)C.setAttribute("data-visible","false")};F.addEventListener("mouseenter",V),F.addEventListener("mouseleave",D),F.addEventListener("touchstart",V,{passive:!0}),F.addEventListener("touchend",D,{passive:!0}),Z.appendChild(F)}}function u1(){G("BarChart",L2),G("LineChart",g1),G("AreaChart",g1),G("PieChart",O2),G("RadarChart",r0),G("ScatterChart",r0),G("RadialChart",r0),G("Histogram",D2)}var s=["#3b82f6","#10b981","#f59e0b","#ef4444","#8b5cf6","#ec4899"],G0="var(--muted-foreground, #6b7280)",z2="var(--border, #e5e7eb)",a0="10";function x1($,Z,J,q=!1){let Q=J?44:0,Y=$-(q?44:0),U=10,W=Z-24;return{plotLeft:Q,plotRight:Y,plotTop:10,plotBottom:W,plotWidth:Y-Q,plotHeight:W-10}}function p1($,Z=5){if($<=0)return[0];let J=$/Z,q=Math.pow(10,Math.floor(Math.log10(J))),Q=J/q,Y=Q<=1.5?q:Q<=3?2*q:Q<=7?5*q:10*q,U=[];for(let W=0;W<=$+Y*0.01;W+=Y)U.push(Math.round(W*1000)/1000);return U}function c1($,Z,J,q,Q){let Y=p1(J);for(let U of Y){let W=Z.plotBottom-(J>0?U/J*Z.plotHeight:0),H=document.createElementNS("http://www.w3.org/2000/svg","text");if(H.setAttribute("x",String(Z.plotLeft-6)),H.setAttribute("y",String(W+3)),H.setAttribute("text-anchor","end"),H.setAttribute("font-size",a0),H.setAttribute("fill",G0),H.textContent=o0(U,Q),$.appendChild(H),q&&U>0){let X=document.createElementNS("http://www.w3.org/2000/svg","line");X.setAttribute("x1",String(Z.plotLeft)),X.setAttribute("y1",String(W)),X.setAttribute("x2",String(Z.plotRight)),X.setAttribute("y2",String(W)),X.setAttribute("stroke",z2),X.setAttribute("stroke-width","1"),X.setAttribute("stroke-dasharray","4 3"),$.appendChild(X)}}}function d1($,Z,J,q){let Q=p1(J);for(let Y of Q){let U=Z.plotBottom-(J>0?Y/J*Z.plotHeight:0),W=document.createElementNS("http://www.w3.org/2000/svg","text");W.setAttribute("x",String(Z.plotRight+6)),W.setAttribute("y",String(U+3)),W.setAttribute("text-anchor","start"),W.setAttribute("font-size",a0),W.setAttribute("fill",G0),W.textContent=o0(Y,q),$.appendChild(W)}}function l1($,Z,J,q,Q,Y){for(let U=0;U<Z.length;U++){let W=document.createElementNS("http://www.w3.org/2000/svg","text");W.setAttribute("x",String(q(U))),W.setAttribute("y",String(Q+14)),W.setAttribute("text-anchor","middle"),W.setAttribute("font-size",a0),W.setAttribute("fill",G0);let H=Z[U][J];W.textContent=H==null?"":Y?Y(H):String(H),$.appendChild(W)}}function s1($,Z){let J=document.createElementNS("http://www.w3.org/2000/svg","line");J.setAttribute("x1",String(Z.plotLeft)),J.setAttribute("y1",String(Z.plotBottom)),J.setAttribute("x2",String(Z.plotRight)),J.setAttribute("y2",String(Z.plotBottom)),J.setAttribute("stroke",G0),J.setAttribute("stroke-width","1"),$.appendChild(J)}function J0($,Z,J){if($==null)return"";let q=b(`{{ __v | ${Z} }}`,{...J,scope:{...J.scope,__v:$}});return q==null?String($):String(q)}function o0($,Z){if(Z==="currency")return`$${$.toLocaleString()}`;if(Z==="percent")return`${$}%`;if($>=1e6)return`${($/1e6).toFixed(1)}M`;if($>=1000)return`${($/1000).toFixed(1)}K`;return String($)}function i1($,Z,J){return(q,Q)=>{if(q===null||q===void 0)return"—";if(Q.tooltipFormat)return J0(q,Q.tooltipFormat,$);let Y=Q.yAxisId==="right"?J:Z;return o0(Number(q),Y)}}function L2($,Z){let J=_("div","pf-chart pf-bar-chart"),q=b($.data,Z)??[],Q=$.series??[],Y=$.height??300;if(q.length===0||Q.length===0)return J.textContent="No chart data",J;let U=$.showYAxis!==!1,W=$.showGrid===!0,H=$.showYAxisRight===!0,X=$.showTooltip!==!1,N=$.xAxis,M=$.tooltipXKey,E=$.xAxisFormat,L=$.tooltipXFormat,B=Q.filter((A)=>A.yAxisId!=="right"),F=Q.filter((A)=>A.yAxisId==="right"),z=H&&F.length>0,O=B.length>0?Math.max(...q.flatMap((A)=>B.map((P)=>Number(A[P.dataKey]??0))),1):1,I=z?Math.max(...q.flatMap((A)=>F.map((P)=>Number(A[P.dataKey]??0))),1):1,V=400,D=x1(V,Y,U,z),j=k0(V,Y,"Bar");if(U)c1(j,D,O,W,$.yAxisFormat);if(z)d1(j,D,I,$.yAxisRightFormat);s1(j,D);let C=D.plotWidth/q.length,i=C/(Q.length+1);for(let A=0;A<q.length;A++)for(let P=0;P<Q.length;P++){let f=Q[P],x=q[A][f.dataKey];if(x===null||x===void 0)continue;let m=f.yAxisId==="right"?I:O,c=Number(x),d=Math.max(0,c/m*D.plotHeight),o=D.plotLeft+A*C+P*i+i/2,R=document.createElementNS("http://www.w3.org/2000/svg","rect");R.setAttribute("x",String(o)),R.setAttribute("y",String(D.plotBottom-d)),R.setAttribute("width",String(i*0.8)),R.setAttribute("height",String(d)),R.setAttribute("fill",f.color??s[P%s.length]),R.setAttribute("rx","2"),j.appendChild(R)}if(N){let A=E?(P)=>J0(P,E,Z):void 0;l1(j,q,N,(P)=>{return D.plotLeft+P*C+C/2},D.plotBottom,A)}if(X){let A=A0(J,j),P=i1(Z,$.yAxisFormat,$.yAxisRightFormat);h1(A,j,q,Q,D,M??N,P,L?(x)=>J0(x,L,Z):void 0)}return t0(J,Q,$.showLegend),J.appendChild(j),J}function g1($,Z){let J=_("div",`pf-chart pf-${$.type.toLowerCase()}-chart`),q=b($.data,Z)??[],Q=$.series??[],Y=$.height??300;if(q.length===0||Q.length===0)return J.textContent="No chart data",J;let U=$.showYAxis!==!1,W=$.showGrid===!0,H=$.showYAxisRight===!0,X=$.showTooltip!==!1,N=$.xAxis,M=$.tooltipXKey,E=$.xAxisFormat,L=$.tooltipXFormat,B=Q.filter((P)=>P.yAxisId!=="right"),F=Q.filter((P)=>P.yAxisId==="right"),z=H&&F.length>0,O=B.length>0?Math.max(...q.flatMap((P)=>B.map((f)=>Number(P[f.dataKey]??0))),1):1,I=z?Math.max(...q.flatMap((P)=>F.map((f)=>Number(P[f.dataKey]??0))),1):1,V=400,D=x1(V,Y,U,z),j=k0(V,Y,$.type==="AreaChart"?"Area":"Line"),C=$.type==="AreaChart";if(U)c1(j,D,O,W,$.yAxisFormat);if(z)d1(j,D,I,$.yAxisRightFormat);s1(j,D);let i=[];for(let P=0;P<Q.length;P++){let f=Q[P],x=f.yAxisId==="right",n=x?I:O,m=f.color??s[P%s.length],c=q.map((R,S)=>{let h=R[f.dataKey],t=h===null||h===void 0,N0=q.length===1?(D.plotLeft+D.plotRight)/2:D.plotLeft+S/(q.length-1)*D.plotWidth,q4=t?D.plotBottom:D.plotBottom-Number(h)/n*D.plotHeight;return{x:N0,y:q4,isNull:t}});if(C){let R=[],S=()=>{if(R.length<2){R=[];return}let h=`M ${R[0].x},${D.plotBottom} `+R.map((N0)=>`L ${N0.x},${N0.y}`).join(" ")+` L ${R[R.length-1].x},${D.plotBottom} Z`,t=document.createElementNS("http://www.w3.org/2000/svg","path");t.setAttribute("d",h),t.setAttribute("fill",m),t.setAttribute("opacity","0.15"),j.appendChild(t),R=[]};for(let h of c){if(h.isNull){S();continue}R.push(h)}S()}let d="";for(let R of c){if(R.isNull)continue;let S=c.indexOf(R),h=S===0||c[S-1].isNull;d+=`${h?"M":"L"} ${R.x},${R.y} `}if(d){let R=document.createElementNS("http://www.w3.org/2000/svg","path");if(R.setAttribute("d",d.trim()),R.setAttribute("fill","none"),R.setAttribute("stroke",m),R.setAttribute("stroke-width","2"),x)R.setAttribute("stroke-dasharray","6 3");j.appendChild(R)}let o=[];for(let R of c){let S=document.createElementNS("http://www.w3.org/2000/svg","circle");if(S.setAttribute("cx",String(R.x)),S.setAttribute("cy",String(R.y)),S.setAttribute("r","4"),S.setAttribute("fill",m),S.setAttribute("class","pf-data-dot"),S.setAttribute("data-visible","false"),S.style.pointerEvents="none",R.isNull)S.style.display="none";j.appendChild(S),o.push(S)}i.push(o)}let A=document.createElementNS("http://www.w3.org/2000/svg","line");if(A.setAttribute("class","pf-crosshair"),A.setAttribute("x1",String(D.plotLeft)),A.setAttribute("x2",String(D.plotLeft)),A.setAttribute("y1",String(D.plotTop)),A.setAttribute("y2",String(D.plotBottom)),A.setAttribute("stroke",G0),A.setAttribute("stroke-width","1"),A.setAttribute("stroke-dasharray","3 3"),A.setAttribute("opacity","0"),j.appendChild(A),N){let P=E?(f)=>J0(f,E,Z):void 0;l1(j,q,N,(f)=>{return q.length===1?(D.plotLeft+D.plotRight)/2:D.plotLeft+f/(q.length-1)*D.plotWidth},D.plotBottom,P)}if(X){let P=A0(J,j),f=i1(Z,$.yAxisFormat,$.yAxisRightFormat);v1(P,j,q,Q,D,M??N,f,A,i,L?(n)=>J0(n,L,Z):void 0)}return t0(J,Q,$.showLegend),J.appendChild(j),J}function O2($,Z){let J=_("div","pf-chart pf-pie-chart"),q=b($.data,Z)??[],Q=$.series??[],Y=$.height??300,U=Math.min(Y,300),W=$.showTooltip!==!1;if(q.length===0||Q.length===0)return J.textContent="No chart data",J;let H=k0(U,U,"Pie"),X=U/2,N=U/2,M=U/2-10,E=Q[0].dataKey,L=$.xAxis,B=$.tooltipXKey,F=$.tooltipXFormat,z=q.map((D)=>Number(D[E]??0)),O=z.reduce((D,j)=>D+j,0);if(O===0)return J.textContent="No chart data",J.appendChild(H),J;let I=W?A0(J,H):void 0,V=-Math.PI/2;for(let D=0;D<z.length;D++){let j=z[D]/O*2*Math.PI,C=V+j,i=j>Math.PI?1:0,A=X+M*Math.cos(V),P=N+M*Math.sin(V),f=X+M*Math.cos(C),x=N+M*Math.sin(C),n=s[D%s.length],m=document.createElementNS("http://www.w3.org/2000/svg","path");if(m.setAttribute("d",`M ${X},${N} L ${A},${P} A ${M},${M} 0 ${i} 1 ${f},${x} Z`),m.setAttribute("fill",n),m.style.cursor="default",I){let c=B??L,d=c?q[D][c]:void 0,o=d!=null?F?J0(d,F,Z):String(d):`Slice ${D+1}`,R=`${(z[D]/O*100).toFixed(1)}%`,S=V+j/2,h=X+M*0.6*Math.cos(S);m.addEventListener("mouseenter",()=>{M0(I,h,N,o,[{label:Q[0].label??E,value:`${z[D]} (${R})`,color:n}])}),m.addEventListener("mouseleave",()=>{I.tooltip.classList.remove("pf-visible")}),m.addEventListener("touchstart",()=>{M0(I,h,N,o,[{label:Q[0].label??E,value:`${z[D]} (${R})`,color:n}])},{passive:!0}),m.addEventListener("touchend",()=>{I.tooltip.classList.remove("pf-visible")},{passive:!0})}H.appendChild(m),V=C}return t0(J,Q,$.showLegend),J.appendChild(H),J}function r0($,Z){let J=_("div",`pf-chart pf-${$.type.toLowerCase()}`);return J.textContent=`${$.type} — not yet supported in renderer`,J.style.padding="24px",J.style.textAlign="center",J}function k0($,Z,J){let q=document.createElementNS("http://www.w3.org/2000/svg","svg");if(q.setAttribute("width","100%"),q.setAttribute("height",String(Z)),q.setAttribute("viewBox",`0 0 ${$} ${Z}`),q.setAttribute("role","img"),J)q.setAttribute("aria-label",`${J} chart`);return q.style.overflow="visible",q}function t0($,Z,J){if(J===!1||Z.length<=1)return;let q=_("div","pf-chart-legend");q.style.display="flex",q.style.gap="12px",q.style.fontSize="12px",q.style.marginBottom="8px";for(let Q=0;Q<Z.length;Q++){let Y=_("div","pf-chart-legend-item");Y.style.display="flex",Y.style.alignItems="center",Y.style.gap="4px";let U=_("span");U.style.width="8px",U.style.height="8px",U.style.borderRadius="50%",U.style.backgroundColor=Z[Q].color??s[Q%s.length];let W=_("span");W.textContent=Z[Q].label??Z[Q].dataKey,Y.appendChild(U),Y.appendChild(W),q.appendChild(Y)}$.appendChild(q)}function D2($,Z){let J=_("div","pf-chart pf-histogram"),q=b($.data,Z);if(!q||q.length===0)return J.textContent="No data",J;let Q=q,Y=$.bins??10,U=$.height??200,W=$.color??s[0],H=Math.min(...Q),N=(Math.max(...Q)-H)/Y||1,M=Array(Y).fill(0);for(let O of Q){let I=Math.min(Math.floor((O-H)/N),Y-1);M[I]++}let E=Math.max(...M),L=300,B=U,F=L/Y,z=k0(L,B,"Histogram");for(let O=0;O<Y;O++){let I=E>0?M[O]/E*B:0,V=document.createElementNS("http://www.w3.org/2000/svg","rect");V.setAttribute("x",String(O*F)),V.setAttribute("y",String(B-I)),V.setAttribute("width",String(F-1)),V.setAttribute("height",String(I)),V.setAttribute("fill",W),z.appendChild(V)}return J.appendChild(z),J}function n1(){G("Table",T2),G("TableHead",e0("thead")),G("TableBody",e0("tbody")),G("TableFooter",e0("tfoot")),G("TableRow",V2),G("TableHeader",j2),G("TableCell",R2),G("TableCaption",I2),G("ExpandableRow",P2)}function T2($,Z){let J=document.createElement("table");return J.className="pf-table",J.style.width="100%",J.style.borderCollapse="collapse",T($,J,Z),J}function e0($){return(Z,J)=>{let q=document.createElement($);return q.className=`pf-${$}`,T(Z,q,J),q}}function V2($,Z){let J=document.createElement("tr");return J.className="pf-table-row",T($,J,Z),J}function j2($,Z){let J=document.createElement("th");return J.className="pf-table-header",J.style.textAlign="left",J.style.padding="8px 12px",J.style.fontWeight="600",J.textContent=K($.content,Z),J}function R2($,Z){let J=document.createElement("td");if(J.className="pf-table-cell",J.style.padding="8px 12px",$.colSpan!=null)J.colSpan=$.colSpan;if($.rowSpan!=null)J.rowSpan=$.rowSpan;return T($,J,Z),J}function I2($,Z){let J=document.createElement("caption");return J.className="pf-table-caption",J.style.padding="8px",J.style.fontSize="14px",J.textContent=K($.content,Z),J}function P2($,Z){let J=_("div","pf-expandable-row"),q=_("div","pf-expandable-row-summary");q.style.cursor="pointer",q.style.display="flex",q.style.alignItems="center",q.style.gap="8px";let Q=_("span","pf-expandable-arrow");Q.textContent="▶",Q.style.transition="transform 0.2s",Q.style.fontSize="10px",q.appendChild(Q);let Y=$.summary;if(Y)for(let H of Y)q.appendChild(w(H,Z));let U=_("div","pf-expandable-row-detail");U.style.display="none",U.style.paddingLeft="24px",T($,U,Z);let W=!1;return q.addEventListener("click",()=>{W=!W,U.style.display=W?"block":"none",Q.style.transform=W?"rotate(90deg)":""}),J.appendChild(q),J.appendChild(U),J}var r1=!1;function f0(){if(r1)return;r1=!0,K1(),D1(),j1(),R1(),P1(),A1(),k1(),w1(),C1(),m1(),u1(),n1()}function a1($){return $.replace(/[^a-zA-Z0-9_-]/g,"")}function o1($){return $.replace(/[{}<>;]/g,"").replace(/\b(url|expression)\s*\(/gi,"")}function $1($,Z){if(!Z)return;if(Z.light)for(let[J,q]of Object.entries(Z.light))$.style.setProperty(`--${a1(J)}`,o1(q));if(Z.dark){let q=document.getElementById("prefab-dark-theme");if(!q)q=document.createElement("style"),q.id="prefab-dark-theme",document.head.appendChild(q);let Q=Object.entries(Z.dark).map(([Y,U])=>` --${a1(Y)}: ${o1(U)};`).join(`
|
|
3
|
+
`),J=[],q=0;while(q<Z.length){let Q=Z[q];if(Q.trimStart().startsWith("```")){let W=Q.trimStart().slice(3).trim(),H=[];q++;while(q<Z.length&&!Z[q].trimStart().startsWith("```"))H.push(R0(Z[q])),q++;q++;let X=W?` data-language="${R0(W)}"`:"";J.push(`<pre class="pf-code"><code${X}>${H.join(`
|
|
4
|
+
`)}</code></pre>`);continue}if(/^(\s*[-*_]\s*){3,}$/.test(Q)){J.push("<hr />"),q++;continue}let Y=/^(#{1,6})\s+(.+)$/.exec(Q);if(Y){let W=Y[1].length;J.push(`<h${W}>${j0(Y[2])}</h${W}>`),q++;continue}if(Q.startsWith("> ")||Q===">"){let W=[];while(q<Z.length&&(Z[q].startsWith("> ")||Z[q]===">"))W.push(Z[q].replace(/^>\s?/,"")),q++;J.push(`<blockquote>${T1(W.join(`
|
|
5
|
+
`))}</blockquote>`);continue}if(/^[\s]*[-*+]\s+/.test(Q)){J.push("<ul>");while(q<Z.length&&/^[\s]*[-*+]\s+/.test(Z[q]))J.push(`<li>${j0(Z[q].replace(/^[\s]*[-*+]\s+/,""))}</li>`),q++;J.push("</ul>");continue}if(/^[\s]*\d+\.\s+/.test(Q)){J.push("<ol>");while(q<Z.length&&/^[\s]*\d+\.\s+/.test(Z[q]))J.push(`<li>${j0(Z[q].replace(/^[\s]*\d+\.\s+/,""))}</li>`),q++;J.push("</ol>");continue}if(Q.trim()===""){q++;continue}let U=[];while(q<Z.length&&Z[q].trim()!==""&&!/^#{1,6}\s/.test(Z[q])&&!/^[-*+]\s/.test(Z[q])&&!/^\d+\.\s/.test(Z[q])&&!Z[q].startsWith("> ")&&!Z[q].trimStart().startsWith("```")&&!/^(\s*[-*_]\s*){3,}$/.test(Z[q]))U.push(Z[q]),q++;J.push(`<p>${U.map(j0).join("<br />")}</p>`)}return J.join(`
|
|
6
|
+
`)}function H8($,Z){let J=document.createElement("kbd");return J.className="pf-kbd",J.textContent=K($.content,Z),J}function j1(){G("Card",M8),G("CardHeader",s0("pf-card-header")),G("CardTitle",V1("pf-card-title","h3")),G("CardDescription",V1("pf-card-description","p")),G("CardContent",s0("pf-card-content")),G("CardFooter",s0("pf-card-footer"))}function M8($,Z){let J=_("div","pf-card");return J.style.overflow="hidden",T($,J,Z),J}function s0($){return(Z,J)=>{let q=_("div",$);return q.style.padding="16px 24px",T(Z,q,J),q}}function V1($,Z){return(J,q)=>{let Q=document.createElement(Z);return Q.className=$,Q.textContent=K(J.content,q),Q}}function R1(){G("DataTable",G8),G("Badge",X8),G("Dot",_8),G("Metric",N8),G("Ring",E8),G("Progress",B8),G("Separator",F8),G("Loader",K8),G("Icon",z8),G("Sparkline",L8)}function G8($,Z){let J=_("div","pf-datatable-wrapper"),q=document.createElement("table");q.className="pf-datatable",q.style.width="100%",q.style.borderCollapse="collapse";let Q=$.columns??[],Y=b($.rows,Z),U=$.rowKey,W=$.selected,H=document.createElement("thead"),X=document.createElement("tr");for(let M of Q){let E=document.createElement("th");E.className="pf-datatable-th",E.textContent=M.header??M.key,E.style.padding="8px 12px",E.style.textAlign="left",X.appendChild(E)}H.appendChild(X),q.appendChild(H);let N=document.createElement("tbody");if(Array.isArray(Y)){let M=W!=null?b(W,Z):void 0;for(let E of Y){let L=document.createElement("tr");L.className="pf-datatable-row";let B=E;if(U&&M!=null&&B[U]!=null&&String(B[U])===String(M))L.classList.add("pf-datatable-row-selected");if($.onRowClick!=null&&U)L.style.cursor="pointer",L.addEventListener("click",()=>{let F={...Z.scope,$item:B,$index:Y.indexOf(E)},z=y({...Z,scope:F});k($.onRowClick,z)});for(let F of Q){let z=document.createElement("td");z.className="pf-datatable-td";let O;if(F.accessor)O=b(`{{ $item.${F.accessor} }}`,{...Z,scope:{...Z.scope,$item:B}});else if(O=B[F.key],F.format&&O!=null)O=b(`{{ __fmtVal | ${F.format} }}`,{...Z,scope:{...Z.scope,__fmtVal:O}});z.textContent=O==null?"":String(O),z.style.padding="8px 12px",L.appendChild(z)}N.appendChild(L)}}if(q.appendChild(N),$.search===!0){let M=document.createElement("input");M.type="text",M.placeholder="Search...",M.className="pf-datatable-search",M.style.marginBottom="8px",M.style.padding="6px 12px",M.style.width="100%",M.style.boxSizing="border-box",M.addEventListener("input",()=>{let E=M.value.toLowerCase(),L=Array.from(N.querySelectorAll("tr"));for(let B of L){let F=(B.textContent??"").toLowerCase();B.style.display=F.includes(E)?"":"none"}}),J.appendChild(M)}return J.appendChild(q),J}function X8($,Z){let J=_("span","pf-badge"),q=$.variant??"default";return J.setAttribute("data-variant",q),J.style.alignItems="center",J.style.padding="2px 10px",J.style.borderRadius="9999px",J.style.fontSize="12px",J.style.fontWeight="500",J.textContent=K($.label??$.content,Z),O8(J,q),J}function _8($,Z){let J=_("span","pf-dot"),q=$.color??"gray";return J.style.display="inline-block",J.style.width="8px",J.style.height="8px",J.style.borderRadius="50%",J.style.backgroundColor=q,J}function N8($,Z){let J=_("div","pf-metric"),q=_("div","pf-metric-label");q.textContent=K($.label,Z),q.style.fontSize="14px",J.appendChild(q);let Q=_("div","pf-metric-value");if(Q.textContent=K($.value,Z),Q.style.fontSize="28px",Q.style.fontWeight="700",J.appendChild(Q),$.delta!=null){let Y=_("span","pf-metric-delta");Y.textContent=K($.delta,Z);let U=$.trend??"",W=$.trendSentiment??"neutral";if(Y.style.fontSize="14px",Y.style.color=W==="positive"?"green":W==="negative"?"red":"inherit",U==="up")Y.textContent="↑ "+Y.textContent;else if(U==="down")Y.textContent="↓ "+Y.textContent;J.appendChild(Y)}if($.description!=null){let Y=_("div","pf-metric-desc");Y.textContent=K($.description,Z),Y.style.fontSize="12px",J.appendChild(Y)}return J}function E8($,Z){let J=_("div","pf-ring"),q=$.size??80,Q=$.thickness??8,Y=Number(b($.value,Z)??0),U=Math.max(0,Math.min(100,Y)),W=(q-Q)/2,H=2*Math.PI*W,X=H*(1-U/100),N=document.createElementNS("http://www.w3.org/2000/svg","svg");N.setAttribute("width",String(q)),N.setAttribute("height",String(q)),N.setAttribute("viewBox",`0 0 ${q} ${q}`);let M=document.createElementNS("http://www.w3.org/2000/svg","circle");M.setAttribute("cx",String(q/2)),M.setAttribute("cy",String(q/2)),M.setAttribute("r",String(W)),M.setAttribute("fill","none"),M.setAttribute("stroke","var(--muted, #e5e7eb)"),M.setAttribute("stroke-width",String(Q));let E=document.createElementNS("http://www.w3.org/2000/svg","circle");if(E.setAttribute("cx",String(q/2)),E.setAttribute("cy",String(q/2)),E.setAttribute("r",String(W)),E.setAttribute("fill","none"),E.setAttribute("stroke","var(--primary, #3b82f6)"),E.setAttribute("stroke-width",String(Q)),E.setAttribute("stroke-dasharray",String(H)),E.setAttribute("stroke-dashoffset",String(X)),E.setAttribute("stroke-linecap","round"),E.style.transform="rotate(-90deg)",E.style.transformOrigin="center",N.appendChild(M),N.appendChild(E),J.appendChild(N),$.label!=null){let L=_("div","pf-ring-label");L.textContent=K($.label,Z),L.style.textAlign="center",L.style.fontSize="12px",J.appendChild(L)}return J}function B8($,Z){let J=_("div","pf-progress");J.setAttribute("role","progressbar");let q=Number(b($.value,Z)??0),Q=$.max??100,Y=Q>0?Math.max(0,Math.min(100,q/Q*100)):0;J.setAttribute("aria-valuenow",String(q)),J.setAttribute("aria-valuemin","0"),J.setAttribute("aria-valuemax",String(Q)),J.style.height="8px",J.style.borderRadius="4px",J.style.overflow="hidden";let U=_("div","pf-progress-fill");return U.style.height="100%",U.style.width=`${Y}%`,U.style.borderRadius="4px",U.style.transition="width 0.3s ease",J.appendChild(U),J}function F8($,Z){let J=document.createElement("hr");return J.className="pf-separator",J.style.border="none",J.style.margin="8px 0",J}function K8($,Z){let J=_("div","pf-loader");return J.textContent="⏳",J.style.display="flex",J.style.justifyContent="center",J.style.padding="16px",J}function z8($,Z){let J=_("span","pf-icon");return J.setAttribute("data-icon",K($.name??$.content,Z)),J}function L8($,Z){let J=_("div","pf-sparkline"),q=$.data??[];if(q.length===0)return J;let Q=120,Y=32,U=Math.max(...q),W=Math.min(...q),H=U-W||1,X=document.createElementNS("http://www.w3.org/2000/svg","svg");X.setAttribute("width",String(Q)),X.setAttribute("height",String(Y)),X.setAttribute("viewBox",`0 0 ${Q} ${Y}`);let N=q.length>1?q.length-1:1,M=q.map((L,B)=>{let F=B/N*Q,z=Y-(L-W)/H*(Y-4)-2;return`${F},${z}`}).join(" "),E=document.createElementNS("http://www.w3.org/2000/svg","polyline");return E.setAttribute("points",M),E.setAttribute("fill","none"),E.setAttribute("stroke","var(--primary, #3b82f6)"),E.setAttribute("stroke-width","1.5"),X.appendChild(E),J.appendChild(X),J}function O8($,Z){let q={success:{bg:"#10b981",fg:"#fff"},warning:{bg:"#f59e0b",fg:"#fff"},info:{bg:"#3b82f6",fg:"#fff"}}[Z];if(q)$.style.backgroundColor=q.bg,$.style.color=q.fg}function P1(){G("Form",D8),G("Input",T8),G("Textarea",V8),G("Button",j8),G("ButtonGroup",R8),G("Select",I8),G("SelectOption",P8),G("SelectGroup",I0("pf-select-group")),G("SelectLabel",H0("pf-select-label")),G("SelectSeparator",I1),G("Checkbox",A8),G("Switch",k8),G("Slider",f8),G("Radio",w8),G("RadioGroup",C8),G("Combobox",y8),G("ComboboxOption",b8),G("ComboboxGroup",I0("pf-combobox-group")),G("ComboboxLabel",H0("pf-combobox-label")),G("ComboboxSeparator",I1),G("Calendar",m8),G("DatePicker",h8),G("Field",I0("pf-field")),G("FieldTitle",H0("pf-field-title")),G("FieldDescription",H0("pf-field-description")),G("FieldContent",I0("pf-field-content")),G("FieldError",H0("pf-field-error")),G("ChoiceCard",v8)}function D8($,Z){let J=document.createElement("form");return J.className="pf-form",J.addEventListener("submit",(q)=>{q.preventDefault();let Q=new FormData(J),Y={};if(Q.forEach((U,W)=>{Y[W]=U}),Z.store.merge(Y),$.onSubmit!=null){let U=y(Z);U.scope={...Z.scope,...Y},k($.onSubmit,U)}}),T($,J,Z),J}function T8($,Z){let J=_("div","pf-input-wrapper");if(J.style.display="flex",J.style.flexDirection="column",J.style.gap="4px",$.label!=null){let Y=document.createElement("label");if(Y.className="pf-input-label",Y.textContent=K($.label,Z),$.name!=null)Y.htmlFor=$.name;Y.style.fontSize="14px",Y.style.fontWeight="500",J.appendChild(Y)}let q=document.createElement("input");if(q.className="pf-input",q.type=$.inputType??"text",$.name!=null)q.name=$.name;if($.name!=null)q.id=`pf-input-${$.name}`;if($.placeholder!=null)q.placeholder=K($.placeholder,Z);if($.required===!0)q.required=!0,q.setAttribute("aria-required","true");if($.error!=null)q.setAttribute("aria-invalid","true");let Q=$.name;if(Q){let Y=Z.store.get(Q);if(Y!=null)q.value=String(Y);q.addEventListener("input",()=>{if(Z.store.set(Q,q.value),$.onChange!=null)k($.onChange,{...y(Z),scope:{...Z.scope,$event:q.value}})})}return i0(q),J.appendChild(q),J}function V8($,Z){let J=_("div","pf-textarea-wrapper"),q=document.createElement("textarea");if(q.className="pf-textarea",$.name!=null)q.name=$.name;if($.name!=null)q.id=`pf-textarea-${$.name}`;if($.placeholder!=null)q.placeholder=K($.placeholder,Z);if($.rows!=null)q.rows=$.rows;if($.required===!0)q.setAttribute("aria-required","true");let Q=$.name;if(Q!=null){let Y=Z.store.get(Q);if(Y!=null)q.value=String(Y);q.addEventListener("input",()=>{if(Z.store.set(Q,q.value),$.onChange!=null)k($.onChange,{...y(Z),scope:{...Z.scope,$event:q.value}})})}return i0(q),J.appendChild(q),J}function j8($,Z){let J=document.createElement("button");J.className="pf-button",J.type=$.submit===!0?"submit":"button",J.textContent=K($.label,Z);let q=$.variant??"default";if(J.setAttribute("data-variant",q),S8(J,q),$.size!=null)J.setAttribute("data-size",$.size);if($.disabled===!0)J.disabled=!0;if($.onClick!=null)J.addEventListener("click",()=>{k($.onClick,y(Z))});return J}function R8($,Z){let J=_("div","pf-button-group");return J.style.display="flex",J.style.gap="8px",T($,J,Z),J}function I8($,Z){let J=_("div","pf-select-wrapper"),q=document.createElement("select");if(q.className="pf-select",$.name!=null)q.name=$.name;if(i0(q),$.placeholder!=null){let U=document.createElement("option");U.value="",U.textContent=K($.placeholder,Z),U.disabled=!0,U.selected=!0,U.hidden=!0,q.appendChild(U)}let Q=$.options;if(Array.isArray(Q))for(let U of Q){let W=document.createElement("option");W.value=U.value??"",W.textContent=U.label??W.value,q.appendChild(W)}if($.children)for(let U of $.children)if(U.type==="SelectOption"){let W=document.createElement("option");W.value=U.value??"",W.textContent=U.label??W.value,q.appendChild(W)}else q.appendChild(w(U,Z));let Y=$.name;if(Y){let U=Z.store.get(Y);if(U!=null)q.value=String(U);q.addEventListener("change",()=>{if(Z.store.set(Y,q.value),$.onChange!=null)k($.onChange,{...y(Z),scope:{...Z.scope,$event:q.value}})})}return J.appendChild(q),J}function P8($,Z){return _("span")}function A8($,Z){let J=_("label","pf-checkbox-wrapper");J.style.display="flex",J.style.alignItems="center",J.style.gap="8px",J.style.cursor="pointer";let q=document.createElement("input");if(q.type="checkbox",q.className="pf-checkbox",$.name!=null)q.name=$.name;if($.checked===!0)q.checked=!0;let Q=$.name;if(Q){let Y=Z.store.get(Q);if(typeof Y==="boolean")q.checked=Y;q.addEventListener("change",()=>{if(Z.store.set(Q,q.checked),$.onChange!=null)k($.onChange,{...y(Z),scope:{...Z.scope,$event:q.checked}})})}if(J.appendChild(q),$.label!=null){let Y=_("span");Y.textContent=K($.label,Z),J.appendChild(Y)}return J}function k8($,Z){let J=_("label","pf-switch-wrapper");J.style.display="flex",J.style.alignItems="center",J.style.gap="8px",J.style.cursor="pointer";let q=document.createElement("input");if(q.type="checkbox",q.className="pf-switch",q.setAttribute("role","switch"),$.name!=null)q.name=$.name;let Q=$.name;if(Q){let Y=Z.store.get(Q);if(typeof Y==="boolean")q.checked=Y;q.addEventListener("change",()=>{if(Z.store.set(Q,q.checked),$.onChange!=null)k($.onChange,{...y(Z),scope:{...Z.scope,$event:q.checked}})})}if(J.appendChild(q),$.label!=null){let Y=_("span");Y.textContent=K($.label,Z),J.appendChild(Y)}return J}function f8($,Z){let J=_("div","pf-slider-wrapper"),q=document.createElement("input");if(q.type="range",q.className="pf-slider",$.name!=null)q.name=$.name;if($.min!=null)q.min=String($.min);if($.max!=null)q.max=String($.max);if($.step!=null)q.step=String($.step);let Q=$.name;if(Q){let Y=Z.store.get(Q);if(Y!=null)q.value=String(Y);q.addEventListener("input",()=>{if(Z.store.set(Q,Number(q.value)),$.onChange!=null)k($.onChange,{...y(Z),scope:{...Z.scope,$event:Number(q.value)}})})}return J.appendChild(q),J}function i0($){$.style.padding="8px 12px",$.style.fontSize="14px",$.style.width="100%",$.style.boxSizing="border-box"}function S8($,Z){if($.style.padding="8px 16px",$.style.fontSize="14px",$.style.fontWeight="500",$.style.cursor="pointer",$.style.border="none",Z==="ghost")$.style.backgroundColor="transparent",$.style.color="inherit"}function I0($){return(Z,J)=>{let q=_("div",$);return T(Z,q,J),q}}function H0($){return(Z,J)=>{let q=_("span",$);return q.textContent=K(Z.content,J),q}}function I1(){let $=document.createElement("hr");return $.className="pf-separator",$.style.border="none",$.style.margin="4px 0",$}function w8($,Z){let J=_("label","pf-radio");J.style.display="flex",J.style.alignItems="center",J.style.gap="8px",J.style.cursor="pointer";let q=document.createElement("input");if(q.type="radio",q.value=K($.value,Z),J.appendChild(q),$.label!=null){let Q=_("span","pf-radio-label");Q.textContent=K($.label,Z),J.appendChild(Q)}return J}function C8($,Z){let J=_("fieldset","pf-radio-group");if(J.style.border="none",J.style.padding="0",J.style.display="flex",J.style.flexDirection="column",J.style.gap="8px",$.label!=null){let Y=document.createElement("legend");Y.textContent=K($.label,Z),Y.style.fontWeight="500",Y.style.marginBottom="4px",J.appendChild(Y)}T($,J,Z);let q=K($.name,Z),Q=Z.store.get(q);for(let Y of Array.from(J.querySelectorAll('input[type="radio"]')))if(Y.name=q,Q!=null&&Y.value===String(Q))Y.checked=!0;return J.addEventListener("change",(Y)=>{let U=Y.target;if(U.type==="radio"){if(Z.store.set(q,U.value),$.onChange!=null)k($.onChange,y(Z))}}),J}function y8($,Z){let J=_("div","pf-combobox"),q=document.createElement("input");if(q.className="pf-combobox-input",q.type="text",q.name=K($.name,Z),$.placeholder!=null)q.placeholder=K($.placeholder,Z);if($.value!==void 0)q.value=K($.value,Z);let Q=q.name,Y=Z.store.get(Q);if(Y!=null)q.value=String(Y);q.style.padding="6px 12px",q.style.borderRadius="6px",q.style.width="100%",q.style.boxSizing="border-box";let U=_("div","pf-combobox-dropdown");if(U.style.display="none",U.style.position="absolute",U.style.borderRadius="6px",U.style.maxHeight="200px",U.style.overflowY="auto",U.style.zIndex="50",T($,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 X=(H.textContent??"").toLowerCase();H.style.display=X.includes(W)?"":"none"}});if($.onChange!=null)J.addEventListener("pf-combobox-select",()=>{k($.onChange,{...y(Z),scope:{...Z.scope,$event:q.value}})});return J.style.position="relative",J.appendChild(q),J.appendChild(U),J}function b8($,Z){let J=_("div","pf-combobox-option");return J.style.padding="6px 12px",J.style.cursor="pointer",J.textContent=K($.label??$.value,Z),J.dataset.value=K($.value,Z),J.addEventListener("mousedown",()=>{let q=J.closest(".pf-combobox"),Q=q?.querySelector("input");if(Q)Q.value=J.dataset.value??"",Z.store.set(Q.name,Q.value),q?.dispatchEvent(new CustomEvent("pf-combobox-select",{bubbles:!1}))}),J}function m8($,Z){let J=_("div","pf-calendar"),q=document.createElement("input");if(q.type="date",q.name=K($.name,Z),$.value!==void 0)q.value=K($.value,Z);let Q=q.name,Y=Z.store.get(Q);if(Y!=null)q.value=String(Y);if($.minDate!=null)q.min=K($.minDate,Z);if($.maxDate!=null)q.max=K($.maxDate,Z);return q.style.padding="6px 12px",q.style.borderRadius="6px",q.addEventListener("change",()=>{if(Z.store.set(q.name,q.value),$.onChange!=null)k($.onChange,y(Z))}),J.appendChild(q),J}function h8($,Z){let J=_("div","pf-datepicker"),q=document.createElement("input");if(q.type="date",q.name=K($.name,Z),$.placeholder!=null)q.placeholder=K($.placeholder,Z);if($.value!==void 0)q.value=K($.value,Z);let Q=q.name,Y=Z.store.get(Q);if(Y!=null)q.value=String(Y);if($.minDate!=null)q.min=K($.minDate,Z);if($.maxDate!=null)q.max=K($.maxDate,Z);return q.style.padding="6px 12px",q.style.borderRadius="6px",q.style.width="100%",q.style.boxSizing="border-box",q.addEventListener("change",()=>{if(Z.store.set(q.name,q.value),$.onChange!=null)k($.onChange,y(Z))}),J.appendChild(q),J}function v8($,Z){let J=_("div","pf-choice-card");if(J.style.padding="16px",J.style.cursor="pointer",J.style.transition="border-color 0.2s",J.dataset.value=K($.value,Z),$.selected===!0)J.dataset.selected="true";if($.label!=null){let q=_("div","pf-choice-card-label");q.textContent=K($.label,Z),q.style.fontWeight="600",J.appendChild(q)}if($.description!=null){let q=_("div","pf-choice-card-description");q.textContent=K($.description,Z),q.style.fontSize="14px",J.appendChild(q)}if(T($,J,Z),$.onClick!=null)J.addEventListener("click",()=>{k($.onClick,y(Z))});return J}function A1(){G("Tabs",g8),G("Tab",u8),G("Accordion",x8),G("AccordionItem",p8),G("Dialog",c8),G("Popover",d8),G("Tooltip",l8),G("HoverCard",s8),G("Carousel",i8)}function g8($,Z){let J=_("div","pf-tabs"),q=_("div","pf-tabs-bar");q.setAttribute("role","tablist"),q.style.display="flex",q.style.gap="4px",q.style.marginBottom="12px";let Q=[],Y=[];if($.children)for(let W=0;W<$.children.length;W++){let H=$.children[W],X=`pf-tab-${Math.random().toString(36).slice(2,8)}`,N=`pf-panel-${Math.random().toString(36).slice(2,8)}`,M=document.createElement("button");M.type="button",M.className="pf-tab-trigger",M.textContent=H.title??`Tab ${W+1}`,M.setAttribute("role","tab"),M.setAttribute("aria-selected",W===0?"true":"false"),M.setAttribute("aria-controls",N),M.id=X,M.tabIndex=W===0?0:-1,M.style.padding="8px 16px",M.style.border="none",M.style.background="none",M.style.cursor="pointer",M.style.borderBottom="2px solid transparent",M.style.marginBottom="-2px",M.style.fontSize="14px";let E=_("div","pf-tab-panel");if(E.style.display=W===0?"block":"none",E.setAttribute("role","tabpanel"),E.setAttribute("aria-labelledby",X),E.id=N,E.tabIndex=0,T(H,E,Z),M.addEventListener("click",()=>{U(W)}),W===0)M.classList.add("pf-tab-active"),M.style.fontWeight="600";Y.push(M),Q.push(E),q.appendChild(M)}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 X;if(W.key==="ArrowRight")X=(H+1)%Y.length;else if(W.key==="ArrowLeft")X=(H-1+Y.length)%Y.length;else if(W.key==="Home")X=0;else if(W.key==="End")X=Y.length-1;else return;W.preventDefault(),U(X)}),J.appendChild(q);for(let W of Q)J.appendChild(W);return J}function u8($,Z){let J=_("div","pf-tab");return T($,J,Z),J}function x8($,Z){let J=_("div","pf-accordion");return T($,J,Z),J}function p8($,Z){let J=_("div","pf-accordion-item"),q=`pf-acc-${Math.random().toString(36).slice(2,8)}`,Q=document.createElement("button");Q.type="button",Q.className="pf-accordion-trigger",Q.textContent=$.title??"",Q.setAttribute("aria-expanded","false"),Q.setAttribute("aria-controls",q),Q.style.width="100%",Q.style.textAlign="left",Q.style.padding="12px 0",Q.style.border="none",Q.style.background="none",Q.style.cursor="pointer",Q.style.fontSize="14px",Q.style.fontWeight="500";let Y=_("div","pf-accordion-content");return Y.id=q,Y.setAttribute("role","region"),Y.setAttribute("aria-labelledby",Q.id),Y.style.display="none",Y.style.paddingBottom="12px",T($,Y,Z),Q.addEventListener("click",()=>{let U=Y.style.display!=="none";Y.style.display=U?"none":"block",Q.setAttribute("aria-expanded",U?"false":"true")}),J.appendChild(Q),J.appendChild(Y),J}function c8($,Z){let J=_("div","pf-dialog-wrapper");if($.trigger!=null){let Y=w($.trigger,Z);Y.addEventListener("click",()=>{q.showModal()}),J.appendChild(Y)}let q=document.createElement("dialog");if(q.className="pf-dialog",q.setAttribute("aria-modal","true"),q.style.maxWidth="500px",q.style.width="100%",q.style.padding="24px",$.title!=null){let Y=_("h2","pf-dialog-title");Y.textContent=K($.title,Z),Y.id=`pf-dialog-title-${Math.random().toString(36).slice(2,8)}`,q.setAttribute("aria-labelledby",Y.id),q.appendChild(Y)}if($.description!=null){let Y=_("p","pf-dialog-desc");Y.textContent=K($.description,Z),q.appendChild(Y)}let Q=_("div","pf-dialog-body");if(T($,Q,Z),q.appendChild(Q),$.dismissible!==!1)q.addEventListener("click",(Y)=>{if(Y.target===q)q.close()});return document.addEventListener("prefab:close-overlay",()=>q.close()),J.appendChild(q),J}function d8($,Z){let J=_("div","pf-popover");J.style.position="relative",J.style.display="inline-block";let q=_("div","pf-popover-content");if(q.style.display="none",q.style.position="absolute",q.style.zIndex="50",q.style.padding="12px",q.style.boxShadow="0 4px 6px -1px rgb(0 0 0 / 0.1)",$.title!=null){let Q=_("div","pf-popover-title");Q.textContent=K($.title,Z),Q.style.fontWeight="600",Q.style.marginBottom="4px",q.appendChild(Q)}return T($,q,Z),J.addEventListener("click",(Q)=>{if(q.contains(Q.target)&&q.style.display!=="none")return;q.style.display=q.style.display==="none"?"block":"none"}),J.appendChild(q),J}function l8($,Z){let J=_("div","pf-tooltip");J.style.position="relative",J.style.display="inline-block";let q=`pf-tip-${Math.random().toString(36).slice(2,8)}`,Q=_("div","pf-tooltip-content");return Q.id=q,Q.setAttribute("role","tooltip"),Q.textContent=K($.content??"",Z),Q.style.display="none",Q.style.position="absolute",Q.style.bottom="100%",Q.style.left="50%",Q.style.transform="translateX(-50%)",Q.style.padding="4px 8px",Q.style.borderRadius="4px",Q.style.color="#fff",Q.style.fontSize="12px",Q.style.whiteSpace="nowrap",Q.style.zIndex="50",T($,J,Z),J.setAttribute("aria-describedby",q),J.addEventListener("mouseenter",()=>{Q.style.display="block"}),J.addEventListener("mouseleave",()=>{Q.style.display="none"}),J.addEventListener("focus",()=>{Q.style.display="block"},!0),J.addEventListener("blur",()=>{Q.style.display="none"},!0),J.appendChild(Q),J}function s8($,Z){let J=_("div","pf-hover-card");J.style.position="relative",J.style.display="inline-block";let q=_("div","pf-hover-card-content");return q.style.display="none",q.style.position="absolute",q.style.zIndex="50",q.style.padding="16px",q.style.boxShadow="0 4px 6px -1px rgb(0 0 0 / 0.1)",q.style.minWidth="200px",T($,q,Z),J.addEventListener("mouseenter",()=>{q.style.display="block"}),J.addEventListener("mouseleave",()=>{q.style.display="none"}),J.appendChild(q),J}function i8($,Z){let J=_("div","pf-carousel");J.style.position="relative",J.style.overflow="hidden",J.setAttribute("role","region"),J.setAttribute("aria-roledescription","carousel"),J.setAttribute("aria-label",K($.label??"Carousel",Z));let q=_("div","pf-carousel-track");q.style.display="flex",q.style.transition="transform 0.3s ease",T($,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 k1(){G("ForEach",n8),G("If",f1),G("Elif",r8),G("Else",a8),G("Condition",o8),G("Define",t8),G("Use",e8),G("Slot",$2)}function n8($,Z){let J=document.createDocumentFragment(),q=$.expression;if(!q)return J;let Q;if(g(q)){let U=u(q,Z.store,Z.scope);Q=Array.isArray(U)?U:[]}else{let U=Z.store.get(q);Q=Array.isArray(U)?U:[]}let Y=$.let??{};for(let U=0;U<Q.length;U++){let W=Q[U],H={...Z.scope,$item:W,$index:U,...Y},X={...Z,scope:H};if($.children)a($.children,J,X)}return J}function f1($,Z){if(S1($.condition,Z)){let q=document.createDocumentFragment();if($.children)a($.children,q,Z);return q}return document.createDocumentFragment()}function r8($,Z){return f1($,Z)}function a8($,Z){let J=document.createDocumentFragment();if($.children)a($.children,J,Z);return J}function S1($,Z){if(!$)return!1;if(g($))return Boolean(u($,Z.store,Z.scope));return Boolean(Z.store.get($))}function o8($,Z){let J=document.createDocumentFragment(),q=$.cases,Q=$.else;if(q){for(let Y of q)if(S1(Y.when,Z)){if(Y.children)a(Y.children,J,Z);return J}}if(Q)a(Q,J,Z);return J}function t8($,Z){let J=$.name;if(J&&$.children)Z.templates=Z.templates??{},Z.templates[J]=$.children;return document.createDocumentFragment()}function e8($,Z){let J=document.createDocumentFragment(),q=$.def??$.name,Q=Z.templates?.[q];if(!Q)return J;let Y=$.overrides??{},U={...Z.scope,...Y},W={...Z,scope:U};for(let H of Q)J.appendChild(w(H,W));return J}function $2($,Z){let J=document.createDocumentFragment(),q=$.name??"default",Y=Z.slots?.[q]??$.children;if(Y)for(let U of Y)J.appendChild(w(U,Z));return J}function w1(){G("Alert",Z2),G("AlertTitle",J2),G("AlertDescription",q2)}function Z2($,Z){let J=_("div","pf-alert");J.setAttribute("role","alert");let q=$.variant??"default";if(J.setAttribute("data-variant",q),J.style.padding="12px 16px",$.icon!=null){let Q=_("span","pf-alert-icon");Q.setAttribute("data-icon",$.icon),Q.style.marginRight="8px",J.appendChild(Q)}return T($,J,Z),J}function J2($,Z){let J=_("h5","pf-alert-title");return J.textContent=K($.content,Z),J.style.fontWeight="600",J.style.marginBottom="4px",J}function q2($,Z){let J=_("p","pf-alert-description");return J.textContent=K($.content,Z),J.style.fontSize="14px",J}function C1(){G("Image",Q2),G("Audio",Y2),G("Video",U2),G("Embed",W2),G("Svg",M2),G("DropZone",G2),G("Mermaid",X2)}function Q2($,Z){let J=document.createElement("img");if(J.className="pf-image",J.src=K($.src,Z),$.alt!=null)J.alt=K($.alt,Z);if($.width!=null)J.width=$.width;if($.height!=null)J.height=$.height;return J.style.maxWidth="100%",J}function Y2($,Z){let J=document.createElement("audio");return J.className="pf-audio",J.src=K($.src,Z),J.controls=!0,J}function U2($,Z){let J=document.createElement("video");if(J.className="pf-video",J.src=K($.src,Z),J.controls=!0,$.width!=null)J.width=$.width;if($.height!=null)J.height=$.height;return J.style.maxWidth="100%",J}function W2($,Z){let J=_("div","pf-embed"),q=document.createElement("iframe");return q.src=K($.src,Z),q.style.width="100%",q.style.height=$.height!=null?`${$.height}px`:"400px",q.style.border="none",q.setAttribute("sandbox","allow-scripts"),J.appendChild(q),J}var H2=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 M2($,Z){let J=_("div","pf-svg"),q=K($.content,Z);if(!q.includes("<svg"))return J;let Y=new DOMParser().parseFromString(q,"image/svg+xml").querySelector("svg");if(!Y)return J;return y1(Y),J.appendChild(document.importNode(Y,!0)),J}function y1($){let Z=Array.from($.children);for(let J of Z){if(!H2.has(J.tagName.toLowerCase())){J.remove();continue}for(let q of Array.from(J.attributes)){let Q=q.name.toLowerCase();if(Q.startsWith("on")||Q==="href"&&q.value.trim().toLowerCase().startsWith("javascript:"))J.removeAttribute(q.name)}y1(J)}}function G2($,Z){let J=_("div","pf-dropzone");return J.style.padding="32px",J.style.textAlign="center",J.style.cursor="pointer",J.textContent=K($.label??"Drop files here",Z),J.addEventListener("dragover",(q)=>{q.preventDefault(),J.classList.add("pf-dropzone-active")}),J.addEventListener("dragleave",()=>{J.classList.remove("pf-dropzone-active")}),J.addEventListener("drop",(q)=>{q.preventDefault(),J.classList.remove("pf-dropzone-active")}),J}function X2($,Z){let J=_("div","pf-mermaid");J.setAttribute("data-mermaid","true");let q=K($.content,Z);if(J.textContent=q,typeof globalThis.mermaid<"u")J.classList.add("mermaid"),J.textContent=q;return J}var _2="https://cdn.jsdelivr.net/npm/pdfjs-dist@4.9/build/pdf.min.mjs",N2="https://cdn.jsdelivr.net/npm/pdfjs-dist@4.9/build/pdf.worker.min.mjs",n0=null,P0=null;async function E2(){if(n0)return n0;if(P0)return P0;return P0=import(_2).then(($)=>{let Z=$;return Z.GlobalWorkerOptions.workerSrc=N2,n0=Z,Z}),P0}function m1(){G("PdfViewer",B2)}function B2($,Z){let J=_("div","pf-pdf-viewer"),q=$.src!=null?K($.src,Z):void 0,Q=$.data,Y=$.page!=null?$.page:1,U=$.zoom!=null?$.zoom:"fit-width",W=$.toolbar!==!1,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 X=_("div","pf-pdf-loading");return X.textContent="Loading PDF…",X.style.display="flex",X.style.alignItems="center",X.style.justifyContent="center",X.style.flex="1",X.style.color="var(--color-text-secondary, #6b7280)",J.appendChild(X),F2(J,X,{src:q,data:Q,initialPage:Y,zoom:U,showToolbar:W}),J}async function F2($,Z,J){try{let q=await E2(),Q;if(J.src)Q={url:J.src};else if(J.data){let E=atob(J.data),L=new Uint8Array(E.length);for(let B=0;B<E.length;B++)L[B]=E.charCodeAt(B);Q={data:L}}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 E=K2(Y.numPages,U,{onPrev:()=>{if(U>1)U--,M()},onNext:()=>{if(U<Y.numPages)U++,M()},onPageChange:(L)=>{let B=Math.max(1,Math.min(L,Y.numPages));if(B!==U)U=B,M()}});W=E.pageInput,H=E.pageCount,$.insertBefore(E.el,$.firstChild)}let X=_("div","pf-pdf-canvas-container");X.style.flex="1",X.style.overflow="auto",X.style.display="flex",X.style.justifyContent="center",X.style.padding="8px",$.appendChild(X);let N=document.createElement("canvas");N.style.display="block",N.style.boxShadow="var(--shadow-md, 0 4px 6px -1px rgba(0,0,0,.1))",X.appendChild(N);async function M(){let E=await Y.getPage(U),L=X.clientWidth-16,B,F=E.getViewport({scale:1});if(J.zoom==="fit-width")B=L/F.width;else if(J.zoom==="fit-page"){let I=X.clientHeight-16,V=L/F.width,D=I/F.height;B=Math.min(V,D)}else B=typeof J.zoom==="number"?J.zoom:1;let z=E.getViewport({scale:B});N.width=z.width,N.height=z.height,N.style.width=`${z.width}px`,N.style.height=`${z.height}px`;let O=N.getContext("2d");if(!O)return;if(await E.render({canvasContext:O,viewport:z}).promise,W)W.value=String(U);if(H)H.textContent=`/ ${Y.numPages}`}await M()}catch(q){Z.textContent=`PDF Error: ${q instanceof Error?q.message:String(q)}`,Z.style.color="var(--color-text-danger, #dc2626)"}}function K2($,Z,J){let q=_("div","pf-pdf-toolbar");q.style.display="flex",q.style.alignItems="center",q.style.gap="8px",q.style.padding="6px 12px",q.style.borderBottom="1px solid var(--color-border-primary, #e5e7eb)",q.style.background="var(--color-background-primary, #fff)",q.style.flexShrink="0",q.style.fontSize="13px";let Q=document.createElement("button");Q.textContent="‹",Q.title="Previous page",Q.className="pf-pdf-btn",b1(Q),Q.addEventListener("click",J.onPrev);let Y=document.createElement("button");Y.textContent="›",Y.title="Next page",Y.className="pf-pdf-btn",b1(Y),Y.addEventListener("click",J.onNext);let U=document.createElement("input");U.type="number",U.min="1",U.max=String($),U.value=String(Z),U.style.width="48px",U.style.textAlign="center",U.style.border="1px solid var(--color-border-primary, #e5e7eb)",U.style.borderRadius="4px",U.style.padding="2px 4px",U.style.fontSize="13px",U.addEventListener("change",()=>{let 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 b1($){$.style.border="1px solid var(--color-border-primary, #e5e7eb)",$.style.borderRadius="4px",$.style.background="var(--color-background-primary, #fff)",$.style.cursor="pointer",$.style.padding="2px 8px",$.style.fontSize="16px",$.style.lineHeight="1"}var k0=["#3b82f6","#10b981","#f59e0b","#ef4444","#8b5cf6","#ec4899"];function f0($,Z){let J=document.createElement("div");return J.className="pf-chart-tooltip",$.appendChild(J),$.addEventListener("mouseleave",()=>{J.classList.remove("pf-visible")}),{wrapper:$,tooltip:J,svgEl:Z}}function M0($,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">${A0(q)}</div>`;for(let z of Q)H+='<div class="pf-chart-tooltip-row">',H+=`<span class="pf-chart-tooltip-dot" style="background:${A0(z.color)}"></span>`,H+=`<span>${A0(z.label)}:</span> <strong>${A0(String(z.value))}</strong>`,H+="</div>";Y.innerHTML=H;let X=U.getBoundingClientRect(),N=W.getBoundingClientRect(),M=U.viewBox.baseVal,E=X.width/(M.width||1),L=X.left-N.left+Z*E,B=Y.offsetWidth||100,F=L+12;if(F+B>N.width)F=L-B-12;Y.style.left=`${Math.max(0,F)}px`,Y.style.top="4px",Y.classList.add("pf-visible")}function A0($){return $.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""")}function h1($,Z,J,q,Q,Y,U,W){let H=Q.plotWidth/J.length;for(let X=0;X<J.length;X++){let N=Q.plotLeft+X*H,M=document.createElementNS("http://www.w3.org/2000/svg","rect");M.setAttribute("x",String(N)),M.setAttribute("y",String(Q.plotTop)),M.setAttribute("width",String(H)),M.setAttribute("height",String(Q.plotHeight)),M.setAttribute("fill","transparent"),M.style.cursor="default";let E=Y?J[X][Y]:void 0,L=E!=null?W?W(E):String(E):void 0,B=q.map((I,V)=>({label:I.label??I.dataKey,value:U(J[X][I.dataKey],I,V),color:I.color??k0[V%k0.length]})),F=N+H/2,z=()=>M0($,F,Q.plotTop,L,B),O=()=>$.tooltip.classList.remove("pf-visible");M.addEventListener("mouseenter",z),M.addEventListener("mouseleave",O),M.addEventListener("touchstart",z,{passive:!0}),M.addEventListener("touchend",O,{passive:!0}),Z.appendChild(M)}}function v1($,Z,J,q,Q,Y,U,W,H,X){let N=J.length===1?Q.plotWidth:Q.plotWidth/(J.length-1);for(let M=0;M<J.length;M++){let E=J.length===1?(Q.plotLeft+Q.plotRight)/2:Q.plotLeft+M/(J.length-1)*Q.plotWidth,L=J.length===1?Q.plotLeft:E-N/2,B=J.length===1?Q.plotWidth:N,F=document.createElementNS("http://www.w3.org/2000/svg","rect");F.setAttribute("x",String(Math.max(Q.plotLeft,L))),F.setAttribute("y",String(Q.plotTop)),F.setAttribute("width",String(Math.min(B,Q.plotRight-Math.max(Q.plotLeft,L)))),F.setAttribute("height",String(Q.plotHeight)),F.setAttribute("fill","transparent"),F.style.cursor="default";let z=Y?J[M][Y]:void 0,O=z!=null?X?X(z):String(z):void 0,I=q.map((j,C)=>({label:j.label??j.dataKey,value:U(J[M][j.dataKey],j,C),color:j.color??k0[C%k0.length]})),V=()=>{if(M0($,E,Q.plotTop,O,I),W)W.setAttribute("x1",String(E)),W.setAttribute("x2",String(E)),W.setAttribute("opacity","1");if(H)for(let j of H){for(let C of j)C.setAttribute("data-visible","false");j[M]?.setAttribute("data-visible","true")}},D=()=>{if($.tooltip.classList.remove("pf-visible"),W)W.setAttribute("opacity","0");if(H)for(let j of H)for(let C of j)C.setAttribute("data-visible","false")};F.addEventListener("mouseenter",V),F.addEventListener("mouseleave",D),F.addEventListener("touchstart",V,{passive:!0}),F.addEventListener("touchend",D,{passive:!0}),Z.appendChild(F)}}function u1(){G("BarChart",L2),G("LineChart",g1),G("AreaChart",g1),G("PieChart",O2),G("RadarChart",r0),G("ScatterChart",r0),G("RadialChart",r0),G("Histogram",D2)}var s=["#3b82f6","#10b981","#f59e0b","#ef4444","#8b5cf6","#ec4899"],G0="var(--muted-foreground, #6b7280)",z2="var(--border, #e5e7eb)",a0="10";function x1($,Z,J,q=!1){let Q=J?44:0,Y=$-(q?44:0),U=10,W=Z-24;return{plotLeft:Q,plotRight:Y,plotTop:10,plotBottom:W,plotWidth:Y-Q,plotHeight:W-10}}function p1($,Z=5){if($<=0)return[0];let J=$/Z,q=Math.pow(10,Math.floor(Math.log10(J))),Q=J/q,Y=Q<=1.5?q:Q<=3?2*q:Q<=7?5*q:10*q,U=[];for(let W=0;W<=$+Y*0.01;W+=Y)U.push(Math.round(W*1000)/1000);return U}function c1($,Z,J,q,Q){let Y=p1(J);for(let U of Y){let W=Z.plotBottom-(J>0?U/J*Z.plotHeight:0),H=document.createElementNS("http://www.w3.org/2000/svg","text");if(H.setAttribute("x",String(Z.plotLeft-6)),H.setAttribute("y",String(W+3)),H.setAttribute("text-anchor","end"),H.setAttribute("font-size",a0),H.setAttribute("fill",G0),H.textContent=o0(U,Q),$.appendChild(H),q&&U>0){let X=document.createElementNS("http://www.w3.org/2000/svg","line");X.setAttribute("x1",String(Z.plotLeft)),X.setAttribute("y1",String(W)),X.setAttribute("x2",String(Z.plotRight)),X.setAttribute("y2",String(W)),X.setAttribute("stroke",z2),X.setAttribute("stroke-width","1"),X.setAttribute("stroke-dasharray","4 3"),$.appendChild(X)}}}function d1($,Z,J,q){let Q=p1(J);for(let Y of Q){let U=Z.plotBottom-(J>0?Y/J*Z.plotHeight:0),W=document.createElementNS("http://www.w3.org/2000/svg","text");W.setAttribute("x",String(Z.plotRight+6)),W.setAttribute("y",String(U+3)),W.setAttribute("text-anchor","start"),W.setAttribute("font-size",a0),W.setAttribute("fill",G0),W.textContent=o0(Y,q),$.appendChild(W)}}function l1($,Z,J,q,Q,Y){for(let U=0;U<Z.length;U++){let W=document.createElementNS("http://www.w3.org/2000/svg","text");W.setAttribute("x",String(q(U))),W.setAttribute("y",String(Q+14)),W.setAttribute("text-anchor","middle"),W.setAttribute("font-size",a0),W.setAttribute("fill",G0);let H=Z[U][J];W.textContent=H==null?"":Y?Y(H):String(H),$.appendChild(W)}}function s1($,Z){let J=document.createElementNS("http://www.w3.org/2000/svg","line");J.setAttribute("x1",String(Z.plotLeft)),J.setAttribute("y1",String(Z.plotBottom)),J.setAttribute("x2",String(Z.plotRight)),J.setAttribute("y2",String(Z.plotBottom)),J.setAttribute("stroke",G0),J.setAttribute("stroke-width","1"),$.appendChild(J)}function J0($,Z,J){if($==null)return"";let q=b(`{{ __v | ${Z} }}`,{...J,scope:{...J.scope,__v:$}});return q==null?String($):String(q)}function o0($,Z){if(Z==="currency")return`$${$.toLocaleString()}`;if(Z==="percent")return`${$}%`;if($>=1e6)return`${($/1e6).toFixed(1)}M`;if($>=1000)return`${($/1000).toFixed(1)}K`;return String($)}function i1($,Z,J){return(q,Q)=>{if(q===null||q===void 0)return"—";if(Q.tooltipFormat)return J0(q,Q.tooltipFormat,$);let Y=Q.yAxisId==="right"?J:Z;return o0(Number(q),Y)}}function L2($,Z){let J=_("div","pf-chart pf-bar-chart"),q=b($.data,Z)??[],Q=$.series??[],Y=$.height??300;if(q.length===0||Q.length===0)return J.textContent="No chart data",J;let U=$.showYAxis!==!1,W=$.showGrid===!0,H=$.showYAxisRight===!0,X=$.showTooltip!==!1,N=$.xAxis,M=$.tooltipXKey,E=$.xAxisFormat,L=$.tooltipXFormat,B=Q.filter((A)=>A.yAxisId!=="right"),F=Q.filter((A)=>A.yAxisId==="right"),z=H&&F.length>0,O=B.length>0?Math.max(...q.flatMap((A)=>B.map((P)=>Number(A[P.dataKey]??0))),1):1,I=z?Math.max(...q.flatMap((A)=>F.map((P)=>Number(A[P.dataKey]??0))),1):1,V=400,D=x1(V,Y,U,z),j=S0(V,Y,"Bar");if(U)c1(j,D,O,W,$.yAxisFormat);if(z)d1(j,D,I,$.yAxisRightFormat);s1(j,D);let C=D.plotWidth/q.length,i=C/(Q.length+1);for(let A=0;A<q.length;A++)for(let P=0;P<Q.length;P++){let f=Q[P],x=q[A][f.dataKey];if(x===null||x===void 0)continue;let m=f.yAxisId==="right"?I:O,c=Number(x),d=Math.max(0,c/m*D.plotHeight),o=D.plotLeft+A*C+P*i+i/2,R=document.createElementNS("http://www.w3.org/2000/svg","rect");R.setAttribute("x",String(o)),R.setAttribute("y",String(D.plotBottom-d)),R.setAttribute("width",String(i*0.8)),R.setAttribute("height",String(d)),R.setAttribute("fill",f.color??s[P%s.length]),R.setAttribute("rx","2"),j.appendChild(R)}if(N){let A=E?(P)=>J0(P,E,Z):void 0;l1(j,q,N,(P)=>{return D.plotLeft+P*C+C/2},D.plotBottom,A)}if(X){let A=f0(J,j),P=i1(Z,$.yAxisFormat,$.yAxisRightFormat);h1(A,j,q,Q,D,M??N,P,L?(x)=>J0(x,L,Z):void 0)}return t0(J,Q,$.showLegend),J.appendChild(j),J}function g1($,Z){let J=_("div",`pf-chart pf-${$.type.toLowerCase()}-chart`),q=b($.data,Z)??[],Q=$.series??[],Y=$.height??300;if(q.length===0||Q.length===0)return J.textContent="No chart data",J;let U=$.showYAxis!==!1,W=$.showGrid===!0,H=$.showYAxisRight===!0,X=$.showTooltip!==!1,N=$.xAxis,M=$.tooltipXKey,E=$.xAxisFormat,L=$.tooltipXFormat,B=Q.filter((P)=>P.yAxisId!=="right"),F=Q.filter((P)=>P.yAxisId==="right"),z=H&&F.length>0,O=B.length>0?Math.max(...q.flatMap((P)=>B.map((f)=>Number(P[f.dataKey]??0))),1):1,I=z?Math.max(...q.flatMap((P)=>F.map((f)=>Number(P[f.dataKey]??0))),1):1,V=400,D=x1(V,Y,U,z),j=S0(V,Y,$.type==="AreaChart"?"Area":"Line"),C=$.type==="AreaChart";if(U)c1(j,D,O,W,$.yAxisFormat);if(z)d1(j,D,I,$.yAxisRightFormat);s1(j,D);let i=[];for(let P=0;P<Q.length;P++){let f=Q[P],x=f.yAxisId==="right",n=x?I:O,m=f.color??s[P%s.length],c=q.map((R,S)=>{let h=R[f.dataKey],t=h===null||h===void 0,N0=q.length===1?(D.plotLeft+D.plotRight)/2:D.plotLeft+S/(q.length-1)*D.plotWidth,q4=t?D.plotBottom:D.plotBottom-Number(h)/n*D.plotHeight;return{x:N0,y:q4,isNull:t}});if(C){let R=[],S=()=>{if(R.length<2){R=[];return}let h=`M ${R[0].x},${D.plotBottom} `+R.map((N0)=>`L ${N0.x},${N0.y}`).join(" ")+` L ${R[R.length-1].x},${D.plotBottom} Z`,t=document.createElementNS("http://www.w3.org/2000/svg","path");t.setAttribute("d",h),t.setAttribute("fill",m),t.setAttribute("opacity","0.15"),j.appendChild(t),R=[]};for(let h of c){if(h.isNull){S();continue}R.push(h)}S()}let d="";for(let R of c){if(R.isNull)continue;let S=c.indexOf(R),h=S===0||c[S-1].isNull;d+=`${h?"M":"L"} ${R.x},${R.y} `}if(d){let R=document.createElementNS("http://www.w3.org/2000/svg","path");if(R.setAttribute("d",d.trim()),R.setAttribute("fill","none"),R.setAttribute("stroke",m),R.setAttribute("stroke-width","2"),x)R.setAttribute("stroke-dasharray","6 3");j.appendChild(R)}let o=[];for(let R of c){let S=document.createElementNS("http://www.w3.org/2000/svg","circle");if(S.setAttribute("cx",String(R.x)),S.setAttribute("cy",String(R.y)),S.setAttribute("r","4"),S.setAttribute("fill",m),S.setAttribute("class","pf-data-dot"),S.setAttribute("data-visible","false"),S.style.pointerEvents="none",R.isNull)S.style.display="none";j.appendChild(S),o.push(S)}i.push(o)}let A=document.createElementNS("http://www.w3.org/2000/svg","line");if(A.setAttribute("class","pf-crosshair"),A.setAttribute("x1",String(D.plotLeft)),A.setAttribute("x2",String(D.plotLeft)),A.setAttribute("y1",String(D.plotTop)),A.setAttribute("y2",String(D.plotBottom)),A.setAttribute("stroke",G0),A.setAttribute("stroke-width","1"),A.setAttribute("stroke-dasharray","3 3"),A.setAttribute("opacity","0"),j.appendChild(A),N){let P=E?(f)=>J0(f,E,Z):void 0;l1(j,q,N,(f)=>{return q.length===1?(D.plotLeft+D.plotRight)/2:D.plotLeft+f/(q.length-1)*D.plotWidth},D.plotBottom,P)}if(X){let P=f0(J,j),f=i1(Z,$.yAxisFormat,$.yAxisRightFormat);v1(P,j,q,Q,D,M??N,f,A,i,L?(n)=>J0(n,L,Z):void 0)}return t0(J,Q,$.showLegend),J.appendChild(j),J}function O2($,Z){let J=_("div","pf-chart pf-pie-chart"),q=b($.data,Z)??[],Q=$.series??[],Y=$.height??300,U=Math.min(Y,300),W=$.showTooltip!==!1;if(q.length===0||Q.length===0)return J.textContent="No chart data",J;let H=S0(U,U,"Pie"),X=U/2,N=U/2,M=U/2-10,E=Q[0].dataKey,L=$.xAxis,B=$.tooltipXKey,F=$.tooltipXFormat,z=q.map((D)=>Number(D[E]??0)),O=z.reduce((D,j)=>D+j,0);if(O===0)return J.textContent="No chart data",J.appendChild(H),J;let I=W?f0(J,H):void 0,V=-Math.PI/2;for(let D=0;D<z.length;D++){let j=z[D]/O*2*Math.PI,C=V+j,i=j>Math.PI?1:0,A=X+M*Math.cos(V),P=N+M*Math.sin(V),f=X+M*Math.cos(C),x=N+M*Math.sin(C),n=s[D%s.length],m=document.createElementNS("http://www.w3.org/2000/svg","path");if(m.setAttribute("d",`M ${X},${N} L ${A},${P} A ${M},${M} 0 ${i} 1 ${f},${x} Z`),m.setAttribute("fill",n),m.style.cursor="default",I){let c=B??L,d=c?q[D][c]:void 0,o=d!=null?F?J0(d,F,Z):String(d):`Slice ${D+1}`,R=`${(z[D]/O*100).toFixed(1)}%`,S=V+j/2,h=X+M*0.6*Math.cos(S);m.addEventListener("mouseenter",()=>{M0(I,h,N,o,[{label:Q[0].label??E,value:`${z[D]} (${R})`,color:n}])}),m.addEventListener("mouseleave",()=>{I.tooltip.classList.remove("pf-visible")}),m.addEventListener("touchstart",()=>{M0(I,h,N,o,[{label:Q[0].label??E,value:`${z[D]} (${R})`,color:n}])},{passive:!0}),m.addEventListener("touchend",()=>{I.tooltip.classList.remove("pf-visible")},{passive:!0})}H.appendChild(m),V=C}return t0(J,Q,$.showLegend),J.appendChild(H),J}function r0($,Z){let J=_("div",`pf-chart pf-${$.type.toLowerCase()}`);return J.textContent=`${$.type} — not yet supported in renderer`,J.style.padding="24px",J.style.textAlign="center",J}function S0($,Z,J){let q=document.createElementNS("http://www.w3.org/2000/svg","svg");if(q.setAttribute("width","100%"),q.setAttribute("height",String(Z)),q.setAttribute("viewBox",`0 0 ${$} ${Z}`),q.setAttribute("role","img"),J)q.setAttribute("aria-label",`${J} chart`);return q.style.overflow="visible",q}function t0($,Z,J){if(J===!1||Z.length<=1)return;let q=_("div","pf-chart-legend");q.style.display="flex",q.style.gap="12px",q.style.fontSize="12px",q.style.marginBottom="8px";for(let Q=0;Q<Z.length;Q++){let Y=_("div","pf-chart-legend-item");Y.style.display="flex",Y.style.alignItems="center",Y.style.gap="4px";let U=_("span");U.style.width="8px",U.style.height="8px",U.style.borderRadius="50%",U.style.backgroundColor=Z[Q].color??s[Q%s.length];let W=_("span");W.textContent=Z[Q].label??Z[Q].dataKey,Y.appendChild(U),Y.appendChild(W),q.appendChild(Y)}$.appendChild(q)}function D2($,Z){let J=_("div","pf-chart pf-histogram"),q=b($.data,Z);if(!q||q.length===0)return J.textContent="No data",J;let Q=q,Y=$.bins??10,U=$.height??200,W=$.color??s[0],H=Math.min(...Q),N=(Math.max(...Q)-H)/Y||1,M=Array(Y).fill(0);for(let O of Q){let I=Math.min(Math.floor((O-H)/N),Y-1);M[I]++}let E=Math.max(...M),L=300,B=U,F=L/Y,z=S0(L,B,"Histogram");for(let O=0;O<Y;O++){let I=E>0?M[O]/E*B:0,V=document.createElementNS("http://www.w3.org/2000/svg","rect");V.setAttribute("x",String(O*F)),V.setAttribute("y",String(B-I)),V.setAttribute("width",String(F-1)),V.setAttribute("height",String(I)),V.setAttribute("fill",W),z.appendChild(V)}return J.appendChild(z),J}function n1(){G("Table",T2),G("TableHead",e0("thead")),G("TableBody",e0("tbody")),G("TableFooter",e0("tfoot")),G("TableRow",V2),G("TableHeader",j2),G("TableCell",R2),G("TableCaption",I2),G("ExpandableRow",P2)}function T2($,Z){let J=document.createElement("table");return J.className="pf-table",J.style.width="100%",J.style.borderCollapse="collapse",T($,J,Z),J}function e0($){return(Z,J)=>{let q=document.createElement($);return q.className=`pf-${$}`,T(Z,q,J),q}}function V2($,Z){let J=document.createElement("tr");return J.className="pf-table-row",T($,J,Z),J}function j2($,Z){let J=document.createElement("th");return J.className="pf-table-header",J.style.textAlign="left",J.style.padding="8px 12px",J.style.fontWeight="600",J.textContent=K($.content,Z),J}function R2($,Z){let J=document.createElement("td");if(J.className="pf-table-cell",J.style.padding="8px 12px",$.colSpan!=null)J.colSpan=$.colSpan;if($.rowSpan!=null)J.rowSpan=$.rowSpan;return T($,J,Z),J}function I2($,Z){let J=document.createElement("caption");return J.className="pf-table-caption",J.style.padding="8px",J.style.fontSize="14px",J.textContent=K($.content,Z),J}function P2($,Z){let J=_("div","pf-expandable-row"),q=_("div","pf-expandable-row-summary");q.style.cursor="pointer",q.style.display="flex",q.style.alignItems="center",q.style.gap="8px";let Q=_("span","pf-expandable-arrow");Q.textContent="▶",Q.style.transition="transform 0.2s",Q.style.fontSize="10px",q.appendChild(Q);let Y=$.summary;if(Y)for(let H of Y)q.appendChild(w(H,Z));let U=_("div","pf-expandable-row-detail");U.style.display="none",U.style.paddingLeft="24px",T($,U,Z);let W=!1;return q.addEventListener("click",()=>{W=!W,U.style.display=W?"block":"none",Q.style.transform=W?"rotate(90deg)":""}),J.appendChild(q),J.appendChild(U),J}var r1=!1;function w0(){if(r1)return;r1=!0,K1(),D1(),j1(),R1(),P1(),A1(),k1(),w1(),C1(),m1(),u1(),n1()}function a1($){return $.replace(/[^a-zA-Z0-9_-]/g,"")}function o1($){return $.replace(/[{}<>;]/g,"").replace(/\b(url|expression)\s*\(/gi,"")}function $1($,Z){if(!Z)return;if(Z.light)for(let[J,q]of Object.entries(Z.light))$.style.setProperty(`--${a1(J)}`,o1(q));if(Z.dark){let q=document.getElementById("prefab-dark-theme");if(!q)q=document.createElement("style"),q.id="prefab-dark-theme",document.head.appendChild(q);let Q=Object.entries(Z.dark).map(([Y,U])=>` --${a1(Y)}: ${o1(U)};`).join(`
|
|
7
7
|
`);q.textContent=`[data-theme="dark"] {
|
|
8
8
|
${Q}
|
|
9
9
|
}
|
|
@@ -11,4 +11,4 @@ ${Q}
|
|
|
11
11
|
:root:not([data-theme="light"]) {
|
|
12
12
|
${Q}
|
|
13
13
|
}
|
|
14
|
-
}`}}function Z1($,Z){if(!$||typeof document>"u")return;let J=(q)=>{for(let[Q,Y]of Object.entries($))if(A2(Q,q))q.preventDefault(),Z(Y)};return document.addEventListener("keydown",J),()=>document.removeEventListener("keydown",J)}function A2($,Z){let J=$.toLowerCase().split("+").map((Y)=>Y.trim()),q=J[J.length-1],Q=new Set(J.slice(0,-1));if(Q.has("ctrl")!==(Z.ctrlKey||Z.metaKey))return!1;if(Q.has("shift")!==Z.shiftKey)return!1;if(Q.has("alt")!==Z.altKey)return!1;return Z.key.toLowerCase()===q}var t1='<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor"><path stroke-linecap="round" stroke-linejoin="round" d="M12 3v2.25m6.364.386-1.591 1.591M21 12h-2.25m-.386 6.364-1.591-1.591M12 18.75V21m-4.773-4.227-1.591 1.591M5.25 12H3m4.227-4.773L5.636 5.636M15.75 12a3.75 3.75 0 1 1-7.5 0 3.75 3.75 0 0 1 7.5 0Z"/></svg>',e1='<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor"><path stroke-linecap="round" stroke-linejoin="round" d="M21.752 15.002A9.72 9.72 0 0 1 18 15.75c-5.385 0-9.75-4.365-9.75-9.75 0-1.33.266-2.597.748-3.752A9.753 9.753 0 0 0 3 11.25C3 16.635 7.365 21 12.75 21a9.753 9.753 0 0 0 9.002-5.998Z"/></svg>',$4={"top-right":"top: 8px; right: 8px;","top-left":"top: 8px; left: 8px;","bottom-right":"bottom: 8px; right: 8px;","bottom-left":"bottom: 8px; left: 8px;"};function k2($,Z){try{let q=localStorage.getItem(Z);if(q==="light"||q==="dark")return q}catch{}let J=$.getAttribute("data-theme")??document.documentElement.getAttribute("data-theme");if(J==="light"||J==="dark")return J;if(typeof window<"u"&&window.matchMedia("(prefers-color-scheme: light)").matches)return"light";return"dark"}function X0($,Z){if(typeof document>"u")return()=>{};let J=Z?.position??"top-right",q=Z?.storageKey??"prefab-theme",Q=Z?.syncDocument??!0,Y=getComputedStyle($).position;if(Y==="static"||Y==="")$.style.position="relative";let U=document.createElement("button");U.className="pf-theme-toggle",U.setAttribute("aria-label","Toggle theme"),U.setAttribute("title","Toggle light/dark"),Object.assign(U.style,{position:"absolute",zIndex:"100",width:"28px",height:"28px",border:"1px solid var(--border, #e5e7eb)",borderRadius:"6px",background:"var(--card, rgba(255,255,255,0.8))",color:"var(--foreground, #333)",cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",padding:"0",opacity:"0.7",transition:"opacity 0.15s, border-color 0.15s"});let W=$4[J]??$4["top-right"];for(let M of W.split(";")){let[E,L]=M.split(":").map((B)=>B.trim());if(E&&L)U.style.setProperty(E,L)}U.addEventListener("mouseenter",()=>{U.style.opacity="1"}),U.addEventListener("mouseleave",()=>{U.style.opacity="0.7"});function H(M){if($.setAttribute("data-theme",M),Q)document.documentElement.setAttribute("data-theme",M);U.innerHTML=M==="dark"?e1:t1;try{localStorage.setItem(q,M)}catch{}}let X=k2($,q);H(X),U.addEventListener("click",()=>{let M=$.getAttribute("data-theme")??"dark";H(M==="dark"?"light":"dark")}),$.appendChild(U);let N;if(Q)N=new MutationObserver((M)=>{for(let E of M)if(E.type==="attributes"&&E.attributeName==="data-theme"){let L=document.documentElement.getAttribute("data-theme");if((L==="light"||L==="dark")&&L!==$.getAttribute("data-theme")){$.setAttribute("data-theme",L),U.innerHTML=L==="dark"?e1:t1;try{localStorage.setItem(q,L)}catch{}}}}),N.observe(document.documentElement,{attributes:!0,attributeFilter:["data-theme"]});return()=>{N?.disconnect(),U.remove()}}function S0($){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 X of H)if(X.type==="text"&&X.text!==void 0){try{let N=JSON.parse(X.text);if(typeof N==="object"&&N!==null&&"$prefab"in N)return N;return N}catch{}return X.text}return W.result??W},async sendMessage(Q){await q(`${Z}/mcp/messages`,{method:"POST",headers:J,body:JSON.stringify({message:Q})})}}}function w0(){return{callTool($){return console.warn(`[prefab] No MCP transport: callTool('${$}') ignored`),Promise.resolve(null)},sendMessage($){return console.warn("[prefab] No MCP transport: sendMessage ignored",$),Promise.resolve()}}}function f2($){return $!==null&&typeof $==="object"&&$.jsonrpc==="2.0"}class e{hostOrigin;listeners=new Map;protocol="prefab";cleanup;pending=new Map;callIdCounter=0;rpcPending=new Map;rpcIdCounter=0;sentRpcIds=new Set;postFn;_hostSupportsSubscriptions=!1;constructor($="*"){this.hostOrigin=$}connect(){if(typeof window>"u")return;let $=C2();if($)this.postFn=(J)=>$.postMessage(J);let Z=(J)=>{if(this.hostOrigin!=="*"&&J.origin!==this.hostOrigin)return;let q=J.data;if(f2(q)){this.handleJsonRpc(q);return}let Q=q;if(!Q?.type.startsWith("prefab:"))return;if(Q.type==="prefab:tool-call-response"&&Q.id){let U=this.pending.get(Q.id);if(U){if(this.pending.delete(Q.id),Q.payload?.error!=null)U.reject(Error(Q.payload.error));else U.resolve(Q.payload?.result);return}}let Y=this.listeners.get(Q.type);if(Y)for(let U of Y)U(Q.payload??{})};window.addEventListener("message",Z),this.cleanup=()=>window.removeEventListener("message",Z)}async initialize($){try{return await Promise.any([this.initPrefab($),this.initJsonRpc($)])}catch(Z){let J=Z instanceof AggregateError?Z.errors.map((q)=>q.message).join("; "):String(Z);throw Error(`Bridge init failed — no host responded. Tried: ${J}`,{cause:Z})}}createTransport(){if(this.protocol==="jsonrpc")return this.createJsonRpcTransport();return this.createPrefabTransport()}requestMode($){if(this.protocol==="jsonrpc")this.sendRpcRequest("ui/request-display-mode",{mode:$});else this.sendPrefab("prefab:request-mode",{mode:$})}openLink($,Z){if(this.protocol==="jsonrpc")this.sendRpcRequest("ui/open-link",{url:$,target:Z});else this.sendPrefab("prefab:open-link",{url:$,target:Z})}updateContext($){if(this.protocol==="jsonrpc")this.sendRpcRequest("ui/update-model-context",{structuredContent:$});else this.sendPrefab("prefab:update-context",{context:$})}setupAutoResize($){if(typeof ResizeObserver>"u")return S2;let Z=-1,J=-1,q=(U,W)=>{if(U===Z&&W===J)return;if(Z=U,J=W,this.protocol==="jsonrpc")this.sendRpcNotification("ui/notifications/size-changed",{width:U,height:W});else this.sendPrefab("prefab:size-changed",{width:U,height:W})},Q=new ResizeObserver((U)=>{for(let W of U)if(W.borderBoxSize.length){let 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);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??{},X=U.hostCapabilities??{},N;if(typeof H.theme==="string"||typeof H.styles==="object"){if(N={},typeof H.theme==="string")N.colorScheme=H.theme;if(typeof H.styles==="object"&&H.styles!==null){let E=H.styles;if(E.variables)N.variables=E.variables;if(typeof E.css?.fonts==="string")N.fontCss=E.css.fonts}}this.postJsonRpc({jsonrpc:"2.0",method:"ui/notifications/initialized",params:{}});let M=X.resources;this._hostSupportsSubscriptions=X.subscriptions===!0||M?.subscribe===!0,Z({hostName:W.name,hostVersion:W.version,capabilities:{toast:!0,navigation:X.openLinks!=null,messaging:!0,displayModes:H.availableDisplayModes??[]},theme:N,toolInput:void 0,meta:H})},reject:(Y)=>{if(Q)return;Q=!0,J(Y)}}),this.postJsonRpc({jsonrpc:"2.0",id:q,method:"ui/initialize",params:{protocolVersion:"2026-01-26",appInfo:{name:"prefab",version:"0.2"},appCapabilities:{...$.displayModes&&{availableDisplayModes:$.displayModes}}}}),setTimeout(()=>{if(!Q)Q=!0,this.rpcPending.delete(q),J(Error("ui/initialize timeout"))},2000)})}createJsonRpcTransport(){return{callTool:($,Z)=>{return this.sendRpcRequest("tools/call",{name:$,arguments:Z})},sendMessage:($)=>{return this.sendRpcRequest("ui/message",{role:"user",content:{type:"text",text:$}})},subscribe:($,Z)=>{return this.subscribe($,Z)},capabilities:{subscriptions:this._hostSupportsSubscriptions}}}sendRpcRequest($,Z){let J=++this.rpcIdCounter;return new Promise((q,Q)=>{this.rpcPending.set(J,{resolve:q,reject:Q}),this.postJsonRpc({jsonrpc:"2.0",id:J,method:$,params:Z}),setTimeout(()=>{if(this.rpcPending.has(J))this.rpcPending.delete(J),Q(Error(`JSON-RPC '${$}' timed out`))},30000)})}sendRpcNotification($,Z){this.postJsonRpc({jsonrpc:"2.0",method:$,params:Z})}postJsonRpc($){if(typeof window>"u")return;if($.id!=null&&typeof $.method==="string")this.sentRpcIds.add($.id);if(this.postFn)this.postFn($);else(window.parent!==window?window.parent:window).postMessage($,this.hostOrigin)}dispatch($,Z){let J=this.listeners.get($);if(J)for(let q of J)q(Z)}}var S2=()=>{};function _0($,Z){if(Z.variables)for(let[J,q]of Object.entries(Z.variables))$.style.setProperty(J.startsWith("--")?J:`--${J}`,q);if(Z.colorScheme&&Z.colorScheme!=="auto")$.setAttribute("data-theme",Z.colorScheme);if(Z.fontCss)w2(Z.fontCss)}function w2($){if(document.getElementById("__prefab-host-fonts"))return;let J=document.createElement("style");J.id="__prefab-host-fonts",J.textContent=$,document.head.appendChild(J)}function q0(){if(typeof window>"u")return!1;try{return window.self!==window.top}catch{return!0}}function C2(){if(typeof window>"u")return;let $=window;if(typeof $.acquireVsCodeApi==="function")try{let Z=$.acquireVsCodeApi();if(Z!==null&&typeof Z==="object"&&"postMessage"in Z)return Z}catch{return}return}async function C0($){f0();let Z=$?.mode??"auto",J=Z==="bridge"||Z==="auto"&&q0(),q,Q,Y={capabilities:{}};if(J)Q=new e($?.hostOrigin),Q.connect(),Y=await Q.initialize($?.capabilities??{toolInput:!0}),q=Q.createTransport();else if($?.transport)q=S0($.transport);else q=w0();if(Y.theme&&typeof document<"u")_0(document.documentElement,Y.theme);if(typeof document<"u"&&!Q)b2();let U,W,H,X,N=Y.toolInput,M;if(Q)Q.on("prefab:tool-input",(B)=>{let F=B.args??B;if(U)U(F);else N=F}),Q.on("prefab:tool-result",(B)=>{let F=B.result??B;if(W)W(F);else M=F}),Q.on("prefab:tool-cancelled",()=>{H?.()}),Q.on("prefab:tool-input-partial",(B)=>{X?.(B.args??B)}),Q.on("prefab:theme-update",(B)=>{if(typeof document<"u")_0(document.documentElement,B)});function E(B,...F){let z=J1(B),O=new Q0,I={store:O,scope:{},transport:q,rerender:()=>V(),onToast:void 0};function V(){z.innerHTML="";for(let D of F)z.appendChild(w(D,I))}return V(),{rerender:V,store:O,destroy:()=>{z.innerHTML=""}}}return{callTool:(B,F={})=>q.callTool(B,F),sendMessage:(B)=>q.sendMessage(B),onToolInput:(B)=>{if(U=B,N){let F=N;N=void 0,queueMicrotask(()=>B(F))}},onToolResult:(B)=>{if(W=B,M!==void 0){let F=M;M=void 0,queueMicrotask(()=>B(F))}},onToolCancelled:(B)=>{H=B},onToolInputPartial:(B)=>{X=B},render:E,mount:(B,F,z)=>{let O=J1(B);return p.mount(O,F,{transport:q,...z})},requestMode:(B)=>Q?.requestMode(B),openLink:(B,F)=>{if(Q)Q.openLink(B,F);else if(typeof window<"u")window.open(B,F??"_blank")},updateContext:(B)=>{if(Q)Q.updateContext(B)},setupAutoResize:(B)=>{if(!Q)return y2;let F=typeof B==="string"?J1(B):B;return Q.setupAutoResize(F)},notifyPreferredSize:(B)=>{if(Q)Q.notifyPreferredSize(B)},host:Y,capabilities:Y.capabilities,theme:Y.theme,transport:q,destroy:()=>Q?.disconnect()}}var y2=()=>{};function J1($){if(typeof $==="string"){if(typeof document>"u")throw Error("Cannot resolve selector outside browser");let Z=document.querySelector($);if(!Z)throw Error(`Element not found: ${$}`);return Z}return $}function b2(){function $(){let J=document.body.getAttribute("data-vscode-theme-kind");if(!J)return;let q=J.includes("light")?"light":"dark";document.documentElement.setAttribute("data-theme",q)}$(),new MutationObserver($).observe(document.body,{attributes:!0,attributeFilter:["data-vscode-theme-kind"]})}var p={mount($,Z,J){f0();let q=Z,Q=[];if(q.pipes)for(let[z,O]of Object.entries(q.pipes))Z4(z,O,Q);let Y=new Q0(q.state),U;if(J?.transport&&"callTool"in J.transport)U=J.transport;else if(J?.transport)U=S0(J.transport);else U=w0();let W=J?.onToast??h2,H=new W0;function X(z){let O=z;if(q=O,O.state)Y.merge(O.state);if(O.defs)N.defs=O.defs;if(O.theme)$1($,O.theme);if(O.pipes)for(let[I,V]of Object.entries(O.pipes))Z4(I,V,Q);for(let I of M)I.remove();if(M.length=0,O.stylesheets)for(let I of O.stylesheets){let V=document.createElement("style");V.textContent=I,V.dataset.prefab="injected",document.head.appendChild(V),M.push(V)}if(J4($,O.layout),E?.(),E=void 0,O.keyBindings)E=Z1(O.keyBindings,async(I)=>{await k(I,{store:Y,transport:U,scope:{},rerender:()=>F(),remount:X,onToast:W})});F()}let N={store:Y,scope:{},transport:U,rerender:()=>F(),remount:X,onToast:W,defs:q.defs,destroyRegistry:H};$1($,q.theme),J4($,q.layout);let M=[];if(q.stylesheets)for(let z of q.stylesheets){let O=document.createElement("style");O.textContent=z,O.dataset.prefab="injected",document.head.appendChild(O),M.push(O)}let E;if(q.keyBindings)E=Z1(q.keyBindings,async(z)=>{await k(z,{store:Y,transport:U,scope:{},rerender:()=>F(),remount:X,onToast:W})});let L,B=J?.themeToggle??!0;if(B!==!1)L=X0($,typeof B==="object"?B:void 0);function F(){H.flush();let z=$.querySelector(".pf-theme-toggle");$.innerHTML="";let O=w(q.view,N);if($.appendChild(O),z)$.appendChild(z)}return F(),{rerender:()=>F(),update(z){Y.merge(z.update.state),F()},store:Y,destroy(){H.flush(),L?.(),E?.(),G1(),X1();for(let z of M)z.remove();for(let z of Q)U0(z);$.innerHTML=""}}},isPrefabData($){return $!=null&&typeof $==="object"&&"$prefab"in $},isPrefabUpdate($){return $!=null&&typeof $==="object"&&"$prefab"in $&&"update"in $}},m2=new Set(["find","dot","length","upper","lower","truncate","join","first","last","abs","round","number","currency","percent","compact","date","time","datetime","pluralize","default","selectattr","rejectattr"]);function Z4($,Z,J){if(m2.has($)){console.warn(`[prefab] wire pipe "${$}" ignored — shadows built-in`);return}try{let q=Function("return ("+Z+")")();if(typeof q!=="function"){console.warn(`[prefab] wire pipe "${$}" — source did not evaluate to a function`);return}Y0($,q),J.push($)}catch(q){console.warn(`[prefab] wire pipe "${$}" — failed to hydrate:`,q)}}function h2($){if(typeof document>"u")return;let Z=v2(),J=document.createElement("div"),q=$.variant??"default";J.className=`pf-toast${q!=="default"?` pf-toast--${q}`:""}`,J.setAttribute("data-variant",q),J.style.marginBottom="8px",J.style.transition="opacity 0.3s ease";let Q=document.createElement("div");if(Q.textContent=$.message,Q.style.fontWeight="500",J.appendChild(Q),$.description){let U=document.createElement("div");U.textContent=$.description,U.style.fontSize="14px",U.style.color="var(--muted-foreground, #6b7280)",J.appendChild(U)}Z.appendChild(J);let Y=$.duration??4000;setTimeout(()=>{J.style.opacity="0",setTimeout(()=>J.remove(),300)},Y)}function J4($,Z){if($.style.height="",$.style.minHeight="",$.style.maxHeight="",$.style.overflow="",!Z)return;if(Z.preferredHeight!=null)$.style.height=`${Z.preferredHeight}px`;if(Z.minHeight!=null)$.style.minHeight=`${Z.minHeight}px`;if(Z.maxHeight!=null)$.style.maxHeight=`${Z.maxHeight}px`,$.style.overflow="auto"}function v2(){let Z=document.getElementById("prefab-toast-container");if(!Z)Z=document.createElement("div"),Z.id="prefab-toast-container",Z.style.position="fixed",Z.style.bottom="16px",Z.style.right="16px",Z.style.zIndex="9999",Z.style.maxWidth="400px",document.body.appendChild(Z);return Z}if(typeof window<"u"){let $=window;$.PrefabRenderer=p,$.prefab={app:C0,mount:p.mount.bind(p),isPrefabData:p.isPrefabData.bind(p),isPrefabUpdate:p.isPrefabUpdate.bind(p),Bridge:e,isIframe:q0,registerPipe:Y0,unregisterPipe:U0,listPipes:E0,registerComponent:G,createThemeToggle:X0};let Z=$.__PREFAB_DATA__;if(Z!=null){let J=document.getElementById("prefab-root");if(J)p.mount(J,Z)}}})();
|
|
14
|
+
}`}}function Z1($,Z){if(!$||typeof document>"u")return;let J=(q)=>{for(let[Q,Y]of Object.entries($))if(A2(Q,q))q.preventDefault(),Z(Y)};return document.addEventListener("keydown",J),()=>document.removeEventListener("keydown",J)}function A2($,Z){let J=$.toLowerCase().split("+").map((Y)=>Y.trim()),q=J[J.length-1],Q=new Set(J.slice(0,-1));if(Q.has("ctrl")!==(Z.ctrlKey||Z.metaKey))return!1;if(Q.has("shift")!==Z.shiftKey)return!1;if(Q.has("alt")!==Z.altKey)return!1;return Z.key.toLowerCase()===q}var t1='<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor"><path stroke-linecap="round" stroke-linejoin="round" d="M12 3v2.25m6.364.386-1.591 1.591M21 12h-2.25m-.386 6.364-1.591-1.591M12 18.75V21m-4.773-4.227-1.591 1.591M5.25 12H3m4.227-4.773L5.636 5.636M15.75 12a3.75 3.75 0 1 1-7.5 0 3.75 3.75 0 0 1 7.5 0Z"/></svg>',e1='<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor"><path stroke-linecap="round" stroke-linejoin="round" d="M21.752 15.002A9.72 9.72 0 0 1 18 15.75c-5.385 0-9.75-4.365-9.75-9.75 0-1.33.266-2.597.748-3.752A9.753 9.753 0 0 0 3 11.25C3 16.635 7.365 21 12.75 21a9.753 9.753 0 0 0 9.002-5.998Z"/></svg>',$4={"top-right":"top: 8px; right: 8px;","top-left":"top: 8px; left: 8px;","bottom-right":"bottom: 8px; right: 8px;","bottom-left":"bottom: 8px; left: 8px;"};function k2($,Z){try{let q=localStorage.getItem(Z);if(q==="light"||q==="dark")return q}catch{}let J=$.getAttribute("data-theme")??document.documentElement.getAttribute("data-theme");if(J==="light"||J==="dark")return J;if(typeof window<"u"&&window.matchMedia("(prefers-color-scheme: light)").matches)return"light";return"dark"}function X0($,Z){if(typeof document>"u")return()=>{};let J=Z?.position??"top-right",q=Z?.storageKey??"prefab-theme",Q=Z?.syncDocument??!0,Y=getComputedStyle($).position;if(Y==="static"||Y==="")$.style.position="relative";let U=document.createElement("button");U.className="pf-theme-toggle",U.setAttribute("aria-label","Toggle theme"),U.setAttribute("title","Toggle light/dark"),Object.assign(U.style,{position:"absolute",zIndex:"100",width:"28px",height:"28px",border:"1px solid var(--border, #e5e7eb)",borderRadius:"6px",background:"var(--card, rgba(255,255,255,0.8))",color:"var(--foreground, #333)",cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",padding:"0",opacity:"0.7",transition:"opacity 0.15s, border-color 0.15s"});let W=$4[J]??$4["top-right"];for(let M of W.split(";")){let[E,L]=M.split(":").map((B)=>B.trim());if(E&&L)U.style.setProperty(E,L)}U.addEventListener("mouseenter",()=>{U.style.opacity="1"}),U.addEventListener("mouseleave",()=>{U.style.opacity="0.7"});function H(M){if($.setAttribute("data-theme",M),Q)document.documentElement.setAttribute("data-theme",M);U.innerHTML=M==="dark"?e1:t1;try{localStorage.setItem(q,M)}catch{}}let X=k2($,q);H(X),U.addEventListener("click",()=>{let M=$.getAttribute("data-theme")??"dark";H(M==="dark"?"light":"dark")}),$.appendChild(U);let N;if(Q)N=new MutationObserver((M)=>{for(let E of M)if(E.type==="attributes"&&E.attributeName==="data-theme"){let L=document.documentElement.getAttribute("data-theme");if((L==="light"||L==="dark")&&L!==$.getAttribute("data-theme")){$.setAttribute("data-theme",L),U.innerHTML=L==="dark"?e1:t1;try{localStorage.setItem(q,L)}catch{}}}}),N.observe(document.documentElement,{attributes:!0,attributeFilter:["data-theme"]});return()=>{N?.disconnect(),U.remove()}}function C0($){let Z=$?.baseUrl??(typeof window<"u"?window.location.origin:""),J={"Content-Type":"application/json",...$?.headers},q=$?.fetch??globalThis.fetch.bind(globalThis);return{async callTool(Q,Y){let U=await q(`${Z}/mcp/tools/call`,{method:"POST",headers:J,body:JSON.stringify({jsonrpc:"2.0",method:"tools/call",params:{name:Q,arguments:Y}})});if(!U.ok)throw Error(`MCP tool call failed: ${U.status} ${U.statusText}`);let W=await U.json();if(W.error)throw Error(W.error.message??"MCP tool call returned error");let H=W.result?.content??W.content??[];for(let X of H)if(X.type==="text"&&X.text!==void 0){try{let N=JSON.parse(X.text);if(typeof N==="object"&&N!==null&&"$prefab"in N)return N;return N}catch{}return X.text}return W.result??W},async sendMessage(Q){await q(`${Z}/mcp/messages`,{method:"POST",headers:J,body:JSON.stringify({message:Q})})}}}function y0(){return{callTool($){return console.warn(`[prefab] No MCP transport: callTool('${$}') ignored`),Promise.resolve(null)},sendMessage($){return console.warn("[prefab] No MCP transport: sendMessage ignored",$),Promise.resolve()}}}function f2($){return $!==null&&typeof $==="object"&&$.jsonrpc==="2.0"}class e{hostOrigin;listeners=new Map;protocol="prefab";cleanup;pending=new Map;callIdCounter=0;rpcPending=new Map;rpcIdCounter=0;sentRpcIds=new Set;postFn;_hostSupportsSubscriptions=!1;constructor($="*"){this.hostOrigin=$}connect(){if(typeof window>"u")return;let $=C2();if($)this.postFn=(J)=>$.postMessage(J);let Z=(J)=>{if(this.hostOrigin!=="*"&&J.origin!==this.hostOrigin)return;let q=J.data;if(f2(q)){this.handleJsonRpc(q);return}let Q=q;if(!Q?.type.startsWith("prefab:"))return;if(Q.type==="prefab:tool-call-response"&&Q.id){let U=this.pending.get(Q.id);if(U){if(this.pending.delete(Q.id),Q.payload?.error!=null)U.reject(Error(Q.payload.error));else U.resolve(Q.payload?.result);return}}let Y=this.listeners.get(Q.type);if(Y)for(let U of Y)U(Q.payload??{})};window.addEventListener("message",Z),this.cleanup=()=>window.removeEventListener("message",Z)}async initialize($){try{return await Promise.any([this.initPrefab($),this.initJsonRpc($)])}catch(Z){let J=Z instanceof AggregateError?Z.errors.map((q)=>q.message).join("; "):String(Z);throw Error(`Bridge init failed — no host responded. Tried: ${J}`,{cause:Z})}}createTransport(){if(this.protocol==="jsonrpc")return this.createJsonRpcTransport();return this.createPrefabTransport()}requestMode($){if(this.protocol==="jsonrpc")this.sendRpcRequest("ui/request-display-mode",{mode:$});else this.sendPrefab("prefab:request-mode",{mode:$})}openLink($,Z){if(this.protocol==="jsonrpc")this.sendRpcRequest("ui/open-link",{url:$,target:Z});else this.sendPrefab("prefab:open-link",{url:$,target:Z})}updateContext($){if(this.protocol==="jsonrpc")this.sendRpcRequest("ui/update-model-context",{structuredContent:$});else this.sendPrefab("prefab:update-context",{context:$})}setupAutoResize($){if(typeof ResizeObserver>"u")return S2;let Z=-1,J=-1,q=(U,W)=>{if(U===Z&&W===J)return;if(Z=U,J=W,this.protocol==="jsonrpc")this.sendRpcNotification("ui/notifications/size-changed",{width:U,height:W});else this.sendPrefab("prefab:size-changed",{width:U,height:W})},Q=new ResizeObserver((U)=>{for(let W of U)if(W.borderBoxSize.length){let 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);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??{},X=U.hostCapabilities??{},N;if(typeof H.theme==="string"||typeof H.styles==="object"){if(N={},typeof H.theme==="string")N.colorScheme=H.theme;if(typeof H.styles==="object"&&H.styles!==null){let E=H.styles;if(E.variables)N.variables=E.variables;if(typeof E.css?.fonts==="string")N.fontCss=E.css.fonts}}this.postJsonRpc({jsonrpc:"2.0",method:"ui/notifications/initialized",params:{}});let M=X.resources;this._hostSupportsSubscriptions=X.subscriptions===!0||M?.subscribe===!0,Z({hostName:W.name,hostVersion:W.version,capabilities:{toast:!0,navigation:X.openLinks!=null,messaging:!0,displayModes:H.availableDisplayModes??[]},theme:N,toolInput:void 0,meta:H})},reject:(Y)=>{if(Q)return;Q=!0,J(Y)}}),this.postJsonRpc({jsonrpc:"2.0",id:q,method:"ui/initialize",params:{protocolVersion:"2026-01-26",appInfo:{name:"prefab",version:"0.2"},appCapabilities:{...$.displayModes&&{availableDisplayModes:$.displayModes}}}}),setTimeout(()=>{if(!Q)Q=!0,this.rpcPending.delete(q),J(Error("ui/initialize timeout"))},2000)})}createJsonRpcTransport(){return{callTool:($,Z)=>{return this.sendRpcRequest("tools/call",{name:$,arguments:Z})},sendMessage:($)=>{return this.sendRpcRequest("ui/message",{role:"user",content:{type:"text",text:$}})},subscribe:($,Z)=>{return this.subscribe($,Z)},capabilities:{subscriptions:this._hostSupportsSubscriptions}}}sendRpcRequest($,Z){let J=++this.rpcIdCounter;return new Promise((q,Q)=>{this.rpcPending.set(J,{resolve:q,reject:Q}),this.postJsonRpc({jsonrpc:"2.0",id:J,method:$,params:Z}),setTimeout(()=>{if(this.rpcPending.has(J))this.rpcPending.delete(J),Q(Error(`JSON-RPC '${$}' timed out`))},30000)})}sendRpcNotification($,Z){this.postJsonRpc({jsonrpc:"2.0",method:$,params:Z})}postJsonRpc($){if(typeof window>"u")return;if($.id!=null&&typeof $.method==="string")this.sentRpcIds.add($.id);if(this.postFn)this.postFn($);else(window.parent!==window?window.parent:window).postMessage($,this.hostOrigin)}dispatch($,Z){let J=this.listeners.get($);if(J)for(let q of J)q(Z)}}var S2=()=>{};function _0($,Z){if(Z.variables)for(let[J,q]of Object.entries(Z.variables))$.style.setProperty(J.startsWith("--")?J:`--${J}`,q);if(Z.colorScheme&&Z.colorScheme!=="auto")$.setAttribute("data-theme",Z.colorScheme);if(Z.fontCss)w2(Z.fontCss)}function w2($){if(document.getElementById("__prefab-host-fonts"))return;let J=document.createElement("style");J.id="__prefab-host-fonts",J.textContent=$,document.head.appendChild(J)}function q0(){if(typeof window>"u")return!1;try{return window.self!==window.top}catch{return!0}}function C2(){if(typeof window>"u")return;let $=window;if(typeof $.acquireVsCodeApi==="function")try{let Z=$.acquireVsCodeApi();if(Z!==null&&typeof Z==="object"&&"postMessage"in Z)return Z}catch{return}return}async function b0($){w0();let Z=$?.mode??"auto",J=Z==="bridge"||Z==="auto"&&q0(),q,Q,Y={capabilities:{}};if(J)Q=new e($?.hostOrigin),Q.connect(),Y=await Q.initialize($?.capabilities??{toolInput:!0}),q=Q.createTransport();else if($?.transport)q=C0($.transport);else q=y0();if(Y.theme&&typeof document<"u")_0(document.documentElement,Y.theme);if(typeof document<"u"&&!Q)b2();let U,W,H,X,N=Y.toolInput,M;if(Q)Q.on("prefab:tool-input",(B)=>{let F=B.args??B;if(U)U(F);else N=F}),Q.on("prefab:tool-result",(B)=>{let F=B.result??B;if(W)W(F);else M=F}),Q.on("prefab:tool-cancelled",()=>{H?.()}),Q.on("prefab:tool-input-partial",(B)=>{X?.(B.args??B)}),Q.on("prefab:theme-update",(B)=>{if(typeof document<"u")_0(document.documentElement,B)});function E(B,...F){let z=J1(B),O=new Q0,I={store:O,scope:{},transport:q,rerender:()=>V(),onToast:void 0};function V(){z.innerHTML="";for(let D of F)z.appendChild(w(D,I))}return V(),{rerender:V,store:O,destroy:()=>{z.innerHTML=""}}}return{callTool:(B,F={})=>q.callTool(B,F),sendMessage:(B)=>q.sendMessage(B),onToolInput:(B)=>{if(U=B,N){let F=N;N=void 0,queueMicrotask(()=>B(F))}},onToolResult:(B)=>{if(W=B,M!==void 0){let F=M;M=void 0,queueMicrotask(()=>B(F))}},onToolCancelled:(B)=>{H=B},onToolInputPartial:(B)=>{X=B},render:E,mount:(B,F,z)=>{let O=J1(B);return p.mount(O,F,{transport:q,...z})},requestMode:(B)=>Q?.requestMode(B),openLink:(B,F)=>{if(Q)Q.openLink(B,F);else if(typeof window<"u")window.open(B,F??"_blank")},updateContext:(B)=>{if(Q)Q.updateContext(B)},setupAutoResize:(B)=>{if(!Q)return y2;let F=typeof B==="string"?J1(B):B;return Q.setupAutoResize(F)},notifyPreferredSize:(B)=>{if(Q)Q.notifyPreferredSize(B)},host:Y,capabilities:Y.capabilities,theme:Y.theme,transport:q,destroy:()=>Q?.disconnect()}}var y2=()=>{};function J1($){if(typeof $==="string"){if(typeof document>"u")throw Error("Cannot resolve selector outside browser");let Z=document.querySelector($);if(!Z)throw Error(`Element not found: ${$}`);return Z}return $}function b2(){function $(){let J=document.body.getAttribute("data-vscode-theme-kind");if(!J)return;let q=J.includes("light")?"light":"dark";document.documentElement.setAttribute("data-theme",q)}$(),new MutationObserver($).observe(document.body,{attributes:!0,attributeFilter:["data-vscode-theme-kind"]})}var p={mount($,Z,J){w0();let q=Z,Q=[];if(q.pipes)for(let[z,O]of Object.entries(q.pipes))Z4(z,O,Q);let Y=new Q0(q.state),U;if(J?.transport&&"callTool"in J.transport)U=J.transport;else if(J?.transport)U=C0(J.transport);else U=y0();let W=J?.onToast??h2,H=new W0;function X(z){let O=z;if(q=O,O.state)Y.merge(O.state);if(O.defs)N.defs=O.defs;if(O.theme)$1($,O.theme);if(O.pipes)for(let[I,V]of Object.entries(O.pipes))Z4(I,V,Q);for(let I of M)I.remove();if(M.length=0,O.stylesheets)for(let I of O.stylesheets){let V=document.createElement("style");V.textContent=I,V.dataset.prefab="injected",document.head.appendChild(V),M.push(V)}if(J4($,O.layout),E?.(),E=void 0,O.keyBindings)E=Z1(O.keyBindings,async(I)=>{await k(I,{store:Y,transport:U,scope:{},rerender:()=>F(),remount:X,onToast:W})});F()}let N={store:Y,scope:{},transport:U,rerender:()=>F(),remount:X,onToast:W,defs:q.defs,destroyRegistry:H};$1($,q.theme),J4($,q.layout);let M=[];if(q.stylesheets)for(let z of q.stylesheets){let O=document.createElement("style");O.textContent=z,O.dataset.prefab="injected",document.head.appendChild(O),M.push(O)}let E;if(q.keyBindings)E=Z1(q.keyBindings,async(z)=>{await k(z,{store:Y,transport:U,scope:{},rerender:()=>F(),remount:X,onToast:W})});let L,B=J?.themeToggle??!0;if(B!==!1)L=X0($,typeof B==="object"?B:void 0);function F(){H.flush();let z=$.querySelector(".pf-theme-toggle");$.innerHTML="";let O=w(q.view,N);if($.appendChild(O),z)$.appendChild(z)}return F(),{rerender:()=>F(),update(z){Y.merge(z.update.state),F()},store:Y,destroy(){H.flush(),L?.(),E?.(),G1(),X1();for(let z of M)z.remove();for(let z of Q)U0(z);$.innerHTML=""}}},isPrefabData($){return $!=null&&typeof $==="object"&&"$prefab"in $},isPrefabUpdate($){return $!=null&&typeof $==="object"&&"$prefab"in $&&"update"in $}},m2=new Set(["find","dot","length","upper","lower","truncate","join","first","last","abs","round","number","currency","percent","compact","date","time","datetime","pluralize","default","selectattr","rejectattr"]);function Z4($,Z,J){if(m2.has($)){console.warn(`[prefab] wire pipe "${$}" ignored — shadows built-in`);return}try{let q=Function("return ("+Z+")")();if(typeof q!=="function"){console.warn(`[prefab] wire pipe "${$}" — source did not evaluate to a function`);return}Y0($,q),J.push($)}catch(q){console.warn(`[prefab] wire pipe "${$}" — failed to hydrate:`,q)}}function h2($){if(typeof document>"u")return;let Z=v2(),J=document.createElement("div"),q=$.variant??"default";J.className=`pf-toast${q!=="default"?` pf-toast--${q}`:""}`,J.setAttribute("data-variant",q),J.style.marginBottom="8px",J.style.transition="opacity 0.3s ease";let Q=document.createElement("div");if(Q.textContent=$.message,Q.style.fontWeight="500",J.appendChild(Q),$.description){let U=document.createElement("div");U.textContent=$.description,U.style.fontSize="14px",U.style.color="var(--muted-foreground, #6b7280)",J.appendChild(U)}Z.appendChild(J);let Y=$.duration??4000;setTimeout(()=>{J.style.opacity="0",setTimeout(()=>J.remove(),300)},Y)}function J4($,Z){if($.style.height="",$.style.minHeight="",$.style.maxHeight="",$.style.overflow="",!Z)return;if(Z.preferredHeight!=null)$.style.height=`${Z.preferredHeight}px`;if(Z.minHeight!=null)$.style.minHeight=`${Z.minHeight}px`;if(Z.maxHeight!=null)$.style.maxHeight=`${Z.maxHeight}px`,$.style.overflow="auto"}function v2(){let Z=document.getElementById("prefab-toast-container");if(!Z)Z=document.createElement("div"),Z.id="prefab-toast-container",Z.style.position="fixed",Z.style.bottom="16px",Z.style.right="16px",Z.style.zIndex="9999",Z.style.maxWidth="400px",document.body.appendChild(Z);return Z}if(typeof window<"u"){let $=window;$.PrefabRenderer=p,$.prefab={app:b0,mount:p.mount.bind(p),isPrefabData:p.isPrefabData.bind(p),isPrefabUpdate:p.isPrefabUpdate.bind(p),Bridge:e,isIframe:q0,registerPipe:Y0,unregisterPipe:U0,listPipes:E0,registerComponent:G,createThemeToggle:X0};let Z=$.__PREFAB_DATA__;if(Z!=null){let J=document.getElementById("prefab-root");if(J)p.mount(J,Z)}}})();
|
package/package.json
CHANGED