@maxhealth.tech/prefab 0.3.19 → 0.3.20
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 +10 -0
- package/dist/a2ui.min.js +1 -1
- package/dist/core/version.d.ts +1 -1
- package/dist/core/version.js +1 -1
- package/dist/renderer/components/charts/props.d.ts.map +1 -1
- package/dist/renderer/components/charts/props.js +3 -2
- package/dist/renderer/components/charts/props.js.map +1 -1
- package/dist/renderer.auto.min.js +2 -2
- package/dist/renderer.min.js +2 -2
- package/package.json +1 -1
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
`),n=[],r=0;while(r<t.length){let o=t[r];if(o.trimStart().startsWith("```")){let a=o.trimStart().slice(3).trim(),l=[];r++;while(r<t.length&&!t[r].trimStart().startsWith("```"))l.push(Re(t[r])),r++;r++;let c=a?` data-language="${Re(a)}"`:"";n.push(`<pre class="pf-code"><code${c}>${l.join(`
|
|
4
4
|
`)}</code></pre>`);continue}if(/^(\s*[-*_]\s*){3,}$/.test(o)){n.push("<hr />"),r++;continue}let i=/^(#{1,6})\s+(.+)$/.exec(o);if(i){let a=i[1].length;n.push(`<h${a}>${ze(i[2])}</h${a}>`),r++;continue}if(o.startsWith("> ")||o===">"){let a=[];while(r<t.length&&(t[r].startsWith("> ")||t[r]===">"))a.push(t[r].replace(/^>\s?/,"")),r++;n.push(`<blockquote>${Sn(a.join(`
|
|
5
5
|
`))}</blockquote>`);continue}if(/^[\s]*[-*+]\s+/.test(o)){n.push("<ul>");while(r<t.length&&/^[\s]*[-*+]\s+/.test(t[r]))n.push(`<li>${ze(t[r].replace(/^[\s]*[-*+]\s+/,""))}</li>`),r++;n.push("</ul>");continue}if(/^[\s]*\d+\.\s+/.test(o)){n.push("<ol>");while(r<t.length&&/^[\s]*\d+\.\s+/.test(t[r]))n.push(`<li>${ze(t[r].replace(/^[\s]*\d+\.\s+/,""))}</li>`),r++;n.push("</ol>");continue}if(o.trim()===""){r++;continue}let s=[];while(r<t.length&&t[r].trim()!==""&&!/^#{1,6}\s/.test(t[r])&&!/^[-*+]\s/.test(t[r])&&!/^\d+\.\s/.test(t[r])&&!t[r].startsWith("> ")&&!t[r].trimStart().startsWith("```")&&!/^(\s*[-*_]\s*){3,}$/.test(t[r]))s.push(t[r]),r++;n.push(`<p>${s.map(ze).join("<br />")}</p>`)}return n.join(`
|
|
6
|
-
`)}function Mo(e,t){let n=document.createElement("kbd");return n.className="pf-kbd",n.textContent=w(e.content,t),n}function Rn(){p("Card",No),p("CardHeader",yt("pf-card-header")),p("CardTitle",En("pf-card-title","h3")),p("CardDescription",En("pf-card-description","p")),p("CardContent",yt("pf-card-content")),p("CardFooter",yt("pf-card-footer"))}function No(e,t){let n=g("div","pf-card");return n.style.overflow="hidden",M(e,n,t),n}function yt(e){return(t,n)=>{let r=g("div",e);return r.style.padding="16px 24px",M(t,r,n),r}}function En(e,t){return(n,r)=>{let o=document.createElement(t);return o.className=e,o.textContent=w(n.content,r),o}}function Tn(){p("DataTable",Lo),p("Badge",Po),p("Dot",Ho),p("Metric",$o),p("Ring",Do),p("Progress",Oo),p("Separator",Io),p("Loader",jo),p("Icon",Fo),p("Sparkline",Bo)}function Lo(e,t){let n=g("div","pf-datatable-wrapper"),r=document.createElement("table");r.className="pf-datatable",r.style.width="100%",r.style.borderCollapse="collapse";let o=e.columns??[],i=K(e.rows,t),s=b(e.rowKey),a=b(e.selected),l=document.createElement("thead"),c=document.createElement("tr");for(let d of o){let m=document.createElement("th");m.className="pf-datatable-th",m.textContent=d.header??d.key,m.style.padding="8px 12px",m.style.textAlign="left",c.appendChild(m)}l.appendChild(c),r.appendChild(l);let u=document.createElement("tbody");if(Array.isArray(i)){let d=a!=null?K(a,t):void 0;for(let m of i){let h=document.createElement("tr");h.className="pf-datatable-row";let C=m,f=S(C)?C:{},y=m===null||typeof m!=="object";if(s&&d!=null&&f[s]!=null&&k(f[s])===k(d))h.classList.add("pf-datatable-row-selected");if(e.onRowClick!=null&&s)h.style.cursor="pointer",h.addEventListener("click",()=>{let x={...t.scope,$item:C,$index:i.indexOf(m)},v=V({...t,scope:x});D(H(e.onRowClick,v),"onRowClick")});for(let x of o){let v=document.createElement("td");v.className="pf-datatable-td";let R;if(x.accessor)R=K(`{{ $item.${x.accessor} }}`,{...t,scope:{...t.scope,$item:C}});else if(R=y?m:f[x.key],x.format&&R!=null)R=K(`{{ __fmtVal | ${x.format} }}`,{...t,scope:{...t.scope,__fmtVal:R}});v.textContent=k(R),v.style.padding="8px 12px",h.appendChild(v)}u.appendChild(h)}}if(r.appendChild(u),e.search===!0){let d=document.createElement("input");d.type="text",d.placeholder="Search...",d.className="pf-datatable-search",d.style.marginBottom="8px",d.style.padding="6px 12px",d.style.width="100%",d.style.boxSizing="border-box",d.addEventListener("input",()=>{let m=d.value.toLowerCase(),h=Array.from(u.querySelectorAll("tr"));for(let C of h){let f=(C.textContent??"").toLowerCase();C.style.display=f.includes(m)?"":"none"}}),n.appendChild(d)}return n.appendChild(r),n}function Po(e,t){let n=g("span","pf-badge"),r=b(e.variant)??"default";return n.setAttribute("data-variant",r),n.style.alignItems="center",n.style.padding="2px 10px",n.style.borderRadius="9999px",n.style.fontSize="12px",n.style.fontWeight="500",n.textContent=w(e.label??e.content,t),Vo(n,r),n}function Ho(e,t){let n=g("span","pf-dot"),r=b(e.color)??"gray";return n.style.display="inline-block",n.style.width="8px",n.style.height="8px",n.style.borderRadius="50%",n.style.backgroundColor=r,n}function $o(e,t){let n=g("div","pf-metric"),r=g("div","pf-metric-label");r.textContent=w(e.label,t),r.style.fontSize="14px",n.appendChild(r);let o=g("div","pf-metric-value");if(o.textContent=w(e.value,t),o.style.fontSize="28px",o.style.fontWeight="700",n.appendChild(o),e.delta!=null){let i=g("span","pf-metric-delta");i.textContent=w(e.delta,t);let s=b(e.trend)??"",a=b(e.trendSentiment)??"neutral";if(i.style.fontSize="14px",i.style.color=a==="positive"?"green":a==="negative"?"red":"inherit",s==="up")i.textContent="↑ "+i.textContent;else if(s==="down")i.textContent="↓ "+i.textContent;n.appendChild(i)}if(e.description!=null){let i=g("div","pf-metric-desc");i.textContent=w(e.description,t),i.style.fontSize="12px",n.appendChild(i)}return n}function Do(e,t){let n=g("div","pf-ring"),r=O(e.size)??80,o=O(e.thickness)??8,i=Number(K(e.value,t)??0),s=Math.max(0,Math.min(100,i)),a=(r-o)/2,l=2*Math.PI*a,c=l*(1-s/100),u=document.createElementNS("http://www.w3.org/2000/svg","svg");u.setAttribute("width",String(r)),u.setAttribute("height",String(r)),u.setAttribute("viewBox",`0 0 ${r} ${r}`);let d=document.createElementNS("http://www.w3.org/2000/svg","circle");d.setAttribute("cx",String(r/2)),d.setAttribute("cy",String(r/2)),d.setAttribute("r",String(a)),d.setAttribute("fill","none"),d.setAttribute("stroke","var(--muted, #e5e7eb)"),d.setAttribute("stroke-width",String(o));let m=document.createElementNS("http://www.w3.org/2000/svg","circle");if(m.setAttribute("cx",String(r/2)),m.setAttribute("cy",String(r/2)),m.setAttribute("r",String(a)),m.setAttribute("fill","none"),m.setAttribute("stroke","var(--primary, #3b82f6)"),m.setAttribute("stroke-width",String(o)),m.setAttribute("stroke-dasharray",String(l)),m.setAttribute("stroke-dashoffset",String(c)),m.setAttribute("stroke-linecap","round"),m.style.transform="rotate(-90deg)",m.style.transformOrigin="center",u.appendChild(d),u.appendChild(m),n.appendChild(u),e.label!=null){let h=g("div","pf-ring-label");h.textContent=w(e.label,t),h.style.textAlign="center",h.style.fontSize="12px",n.appendChild(h)}return n}function Oo(e,t){let n=g("div","pf-progress");n.setAttribute("role","progressbar");let r=Number(K(e.value,t)??0),o=O(e.max)??100,i=o>0?Math.max(0,Math.min(100,r/o*100)):0;n.setAttribute("aria-valuenow",String(r)),n.setAttribute("aria-valuemin","0"),n.setAttribute("aria-valuemax",String(o)),n.style.height="8px",n.style.borderRadius="4px",n.style.overflow="hidden";let s=g("div","pf-progress-fill");return s.style.height="100%",s.style.width=`${i}%`,s.style.borderRadius="4px",s.style.transition="width 0.3s ease",n.appendChild(s),n}function Io(e,t){let n=document.createElement("hr");return n.className="pf-separator",n.style.border="none",n.style.margin="8px 0",n}function jo(e,t){let n=g("div","pf-loader");return n.textContent="⏳",n.style.display="flex",n.style.justifyContent="center",n.style.padding="16px",n}function Fo(e,t){let n=g("span","pf-icon");return n.setAttribute("data-icon",w(e.name??e.content,t)),n}function Bo(e,t){let n=g("div","pf-sparkline"),r=Array.isArray(e.data)?e.data.filter((h)=>typeof h==="number"&&Number.isFinite(h)):[];if(r.length===0)return n;let o=O(e.width)??120,i=O(e.height)??32,s=Math.max(...r),a=Math.min(...r),l=s-a||1,c=document.createElementNS("http://www.w3.org/2000/svg","svg");c.setAttribute("width",String(o)),c.setAttribute("height",String(i)),c.setAttribute("viewBox",`0 0 ${o} ${i}`);let u=r.length>1?r.length-1:1,d=r.map((h,C)=>{let f=C/u*o,y=i-(h-a)/l*(i-4)-2;return`${f},${y}`}).join(" "),m=document.createElementNS("http://www.w3.org/2000/svg","polyline");return m.setAttribute("points",d),m.setAttribute("fill","none"),m.setAttribute("stroke","var(--primary, #3b82f6)"),m.setAttribute("stroke-width","1.5"),c.appendChild(m),n.appendChild(c),n}function Vo(e,t){let r={success:{bg:"#10b981",fg:"#fff"},warning:{bg:"#f59e0b",fg:"#fff"},info:{bg:"#3b82f6",fg:"#fff"}}[t];if(r)e.style.backgroundColor=r.bg,e.style.color=r.fg}function An(){p("Form",_o),p("Input",zo),p("Textarea",ye(Wo)),p("Button",Ko),p("ButtonGroup",Jo),p("Checkbox",Go),p("Switch",qo),p("Slider",ye(Uo)),p("Calendar",Yo),p("DatePicker",ye(Zo)),p("Field",Te("pf-field")),p("FieldTitle",Ce("pf-field-title")),p("FieldDescription",Ce("pf-field-description")),p("FieldContent",Te("pf-field-content")),p("FieldError",Ce("pf-field-error"))}function _o(e,t){let n=document.createElement("form");return n.className="pf-form",n.addEventListener("submit",(r)=>{r.preventDefault();let o=new FormData(n),i={};for(let s of new Set(o.keys())){let a=o.getAll(s),l=n.elements.namedItem(s),c=l instanceof HTMLSelectElement&&l.multiple||a.length>1;i[s]=c?a:a[0]}if(t.store.merge(i),e.onSubmit!=null){let s=V(t);s.scope={...t.scope,...i},D(H(e.onSubmit,s),"onSubmit")}}),M(e,n,t),n}function Mn(e,t,n){if(t.label==null)return;let r=document.createElement("label");if(r.className="pf-input-label",r.textContent=w(t.label,n),t.name!=null)r.htmlFor=k(t.name);r.style.fontSize="14px",r.style.fontWeight="500",e.insertBefore(r,e.firstChild)}function ye(e){return(t,n)=>{let r=e(t,n);return r.style.display="flex",r.style.flexDirection="column",r.style.gap="4px",Mn(r,t,n),r}}function se(e,t){if(t.required!==!0)return;if("required"in e)e.required=!0;e.setAttribute("aria-required","true")}function zo(e,t){let n=g("div","pf-input-wrapper");n.style.display="flex",n.style.flexDirection="column",n.style.gap="4px",Mn(n,e,t);let r=document.createElement("input");if(r.className="pf-input",r.type=b(e.inputType)??"text",e.name!=null)r.name=k(e.name);if(e.name!=null)r.id=`pf-input-${k(e.name)}`;if(e.placeholder!=null)r.placeholder=w(e.placeholder,t);if(se(r,e),e.error!=null)r.setAttribute("aria-invalid","true");let o=b(e.name);if(o){let i=t.store.get(o);if(i!=null)r.value=k(i);r.addEventListener("input",()=>{if(t.store.set(o,r.value),e.onChange!=null)D(H(e.onChange,{...V(t),scope:{...t.scope,$event:r.value}}),"onChange")})}return We(r),n.appendChild(r),n}function Wo(e,t){let n=g("div","pf-textarea-wrapper"),r=document.createElement("textarea");if(r.className="pf-textarea",e.name!=null)r.name=k(e.name);if(e.name!=null)r.id=`pf-textarea-${k(e.name)}`;if(e.placeholder!=null)r.placeholder=w(e.placeholder,t);if(e.rows!=null)r.rows=Number(e.rows);se(r,e);let o=b(e.name);if(o!=null){let i=t.store.get(o);if(i!=null)r.value=k(i);r.addEventListener("input",()=>{if(t.store.set(o,r.value),e.onChange!=null)D(H(e.onChange,{...V(t),scope:{...t.scope,$event:r.value}}),"onChange")})}return We(r),n.appendChild(r),n}function Ko(e,t){let n=document.createElement("button");n.className="pf-button",n.type=e.submit===!0?"submit":"button",n.textContent=w(e.label,t);let r=b(e.variant)??"default";if(n.setAttribute("data-variant",r),Xo(n,r),e.size!=null)n.setAttribute("data-size",k(e.size));if(e.disabled===!0)n.disabled=!0;return n}function Jo(e,t){let n=g("div","pf-button-group");return n.style.display="flex",n.style.gap="8px",M(e,n,t),n}function Go(e,t){let n=g("label","pf-checkbox-wrapper");n.style.display="flex",n.style.alignItems="center",n.style.gap="8px",n.style.cursor="pointer";let r=document.createElement("input");if(r.type="checkbox",r.className="pf-checkbox",e.name!=null)r.name=k(e.name);if(e.checked===!0)r.checked=!0;let o=b(e.name);if(o){let i=t.store.get(o);if(typeof i==="boolean")r.checked=i;r.addEventListener("change",()=>{if(t.store.set(o,r.checked),e.onChange!=null)D(H(e.onChange,{...V(t),scope:{...t.scope,$event:r.checked}}),"onChange")})}if(n.appendChild(r),e.label!=null){let i=g("span");i.textContent=w(e.label,t),n.appendChild(i)}return n}function qo(e,t){let n=g("label","pf-switch-wrapper");n.style.display="flex",n.style.alignItems="center",n.style.gap="8px",n.style.cursor="pointer";let r=document.createElement("input");if(r.type="checkbox",r.className="pf-switch",r.setAttribute("role","switch"),e.name!=null)r.name=k(e.name);let o=b(e.name);if(o){let i=t.store.get(o);if(typeof i==="boolean")r.checked=i;r.addEventListener("change",()=>{if(t.store.set(o,r.checked),e.onChange!=null)D(H(e.onChange,{...V(t),scope:{...t.scope,$event:r.checked}}),"onChange")})}if(n.appendChild(r),e.label!=null){let i=g("span");i.textContent=w(e.label,t),n.appendChild(i)}return n}function Uo(e,t){let n=g("div","pf-slider-wrapper"),r=document.createElement("input");if(r.type="range",r.className="pf-slider",e.name!=null)r.name=k(e.name);if(e.min!=null)r.min=k(e.min);if(e.max!=null)r.max=k(e.max);if(e.step!=null)r.step=k(e.step);let o=b(e.name);if(o){let i=t.store.get(o);if(i!=null)r.value=k(i);r.addEventListener("input",()=>{if(t.store.set(o,Number(r.value)),e.onChange!=null)D(H(e.onChange,{...V(t),scope:{...t.scope,$event:Number(r.value)}}),"onChange")})}return n.appendChild(r),n}function We(e){e.style.padding="8px 12px",e.style.fontSize="14px",e.style.width="100%",e.style.boxSizing="border-box"}function Xo(e,t){if(e.style.padding="8px 16px",e.style.fontSize="14px",e.style.fontWeight="500",e.style.cursor="pointer",e.style.border="none",t==="ghost")e.style.backgroundColor="transparent",e.style.color="inherit"}function Te(e){return(t,n)=>{let r=g("div",e);return M(t,r,n),r}}function Ce(e){return(t,n)=>{let r=g("span",e);return r.textContent=w(t.content,n),r}}function Ct(){let e=document.createElement("hr");return e.className="pf-separator",e.style.border="none",e.style.margin="4px 0",e}function Yo(e,t){let n=g("div","pf-calendar"),r=document.createElement("input");if(r.type="date",r.name=w(e.name,t),se(r,e),e.value!==void 0)r.value=w(e.value,t);let o=r.name,i=t.store.get(o);if(i!=null)r.value=k(i);if(e.minDate!=null)r.min=w(e.minDate,t);if(e.maxDate!=null)r.max=w(e.maxDate,t);return r.style.padding="6px 12px",r.style.borderRadius="6px",r.addEventListener("change",()=>{if(t.store.set(r.name,r.value),e.onChange!=null)D(H(e.onChange,V(t)),"onChange")}),n.appendChild(r),n}function Zo(e,t){let n=g("div","pf-datepicker"),r=document.createElement("input");if(r.type="date",r.name=w(e.name,t),se(r,e),e.placeholder!=null)r.placeholder=w(e.placeholder,t);if(e.value!==void 0)r.value=w(e.value,t);let o=r.name,i=t.store.get(o);if(i!=null)r.value=k(i);if(e.minDate!=null)r.min=w(e.minDate,t);if(e.maxDate!=null)r.max=w(e.maxDate,t);return r.style.padding="6px 12px",r.style.borderRadius="6px",r.style.width="100%",r.style.boxSizing="border-box",r.addEventListener("change",()=>{if(t.store.set(r.name,r.value),e.onChange!=null)D(H(e.onChange,V(t)),"onChange")}),n.appendChild(r),n}function Nn(){p("Select",ye(Qo)),p("SelectOption",ni),p("SelectGroup",Te("pf-select-group")),p("SelectLabel",Ce("pf-select-label")),p("SelectSeparator",Ct),p("Radio",ri),p("RadioGroup",oi),p("Combobox",ye(ii)),p("ComboboxOption",si),p("ComboboxGroup",Te("pf-combobox-group")),p("ComboboxLabel",Ce("pf-combobox-label")),p("ComboboxSeparator",Ct),p("ChoiceCard",ai)}function Qo(e,t){let n=g("div","pf-select-wrapper"),r=document.createElement("select");if(r.className="pf-select",e.name!=null)r.name=k(e.name);if(e.multiple===!0)r.multiple=!0;if(se(r,e),We(r),e.placeholder!=null){let s=document.createElement("option");s.value="",s.textContent=w(e.placeholder,t),s.disabled=!0,s.selected=!0,s.hidden=!0,r.appendChild(s)}let o=e.options;if(Array.isArray(o))for(let s of o){let a=document.createElement("option");a.value=s.value??"",a.textContent=s.label??a.value,r.appendChild(a)}if(e.children)for(let s of e.children)if(s.type==="SelectOption"){let a=document.createElement("option");a.value=b(s.value)??"",a.textContent=b(s.label)??a.value,r.appendChild(a)}else r.appendChild(j(s,t));let i=b(e.name);if(i){let s=t.store.get(i);if(s!=null)ti(r,s);r.addEventListener("change",()=>{let a=ei(r);if(t.store.set(i,a),e.onChange!=null)D(H(e.onChange,{...V(t),scope:{...t.scope,$event:a}}),"onChange")})}return n.appendChild(r),n}function ei(e){if(!e.multiple)return e.value;return Array.from(e.selectedOptions,(t)=>t.value)}function ti(e,t){if(!e.multiple){e.value=k(t);return}let n=new Set((Array.isArray(t)?t:[t]).map((r)=>k(r)));for(let r of e.options)r.selected=n.has(r.value)}function ni(e,t){return g("span")}function ri(e,t){let n=g("label","pf-radio");n.style.display="flex",n.style.alignItems="center",n.style.gap="8px",n.style.cursor="pointer";let r=document.createElement("input");if(r.type="radio",r.value=w(e.value,t),n.appendChild(r),e.label!=null){let o=g("span","pf-radio-label");o.textContent=w(e.label,t),n.appendChild(o)}return n}function oi(e,t){let n=g("fieldset","pf-radio-group");if(se(n,e),n.style.border="none",n.style.padding="0",n.style.display="flex",n.style.flexDirection="column",n.style.gap="8px",e.label!=null){let i=document.createElement("legend");i.textContent=w(e.label,t),i.style.fontWeight="500",i.style.marginBottom="4px",n.appendChild(i)}M(e,n,t);let r=w(e.name,t),o=t.store.get(r);for(let i of Array.from(n.querySelectorAll('input[type="radio"]')))if(i.name=r,o!=null&&i.value===k(o))i.checked=!0;return n.addEventListener("change",(i)=>{let s=i.target;if(s.type==="radio"){if(t.store.set(r,s.value),e.onChange!=null)D(H(e.onChange,V(t)),"onChange")}}),n}function ii(e,t){let n=g("div","pf-combobox"),r=document.createElement("input");if(r.className="pf-combobox-input",r.type="text",r.name=w(e.name,t),se(r,e),e.placeholder!=null)r.placeholder=w(e.placeholder,t);if(e.value!==void 0)r.value=w(e.value,t);let o=r.name,i=t.store.get(o);if(i!=null)r.value=k(i);r.style.padding="6px 12px",r.style.borderRadius="6px",r.style.width="100%",r.style.boxSizing="border-box";let s=g("div","pf-combobox-dropdown");if(s.style.display="none",s.style.position="absolute",s.style.borderRadius="6px",s.style.maxHeight="200px",s.style.overflowY="auto",s.style.zIndex="50",M(e,s,t),r.addEventListener("focus",()=>{s.style.display="block"}),r.addEventListener("blur",()=>{setTimeout(()=>{s.style.display="none"},150)}),e.searchable!==!1)r.addEventListener("input",()=>{let a=r.value.toLowerCase();for(let l of Array.from(s.querySelectorAll(".pf-combobox-option"))){let c=(l.textContent??"").toLowerCase();l.style.display=c.includes(a)?"":"none"}});if(e.onChange!=null)n.addEventListener("pf-combobox-select",()=>{D(H(e.onChange,{...V(t),scope:{...t.scope,$event:r.value}}),"onChange")});return n.style.position="relative",n.appendChild(r),n.appendChild(s),n}function si(e,t){let n=g("div","pf-combobox-option");return n.style.padding="6px 12px",n.style.cursor="pointer",n.textContent=w(e.label??e.value,t),n.dataset.value=w(e.value,t),n.addEventListener("mousedown",()=>{let r=n.closest(".pf-combobox"),o=r?.querySelector("input");if(o)o.value=n.dataset.value??"",t.store.set(o.name,o.value),r?.dispatchEvent(new CustomEvent("pf-combobox-select",{bubbles:!1}))}),n}function ai(e,t){let n=g("div","pf-choice-card");if(n.style.padding="16px",n.style.cursor="pointer",n.style.transition="border-color 0.2s",n.dataset.value=w(e.value,t),e.selected===!0)n.dataset.selected="true";if(e.label!=null){let r=g("div","pf-choice-card-label");r.textContent=w(e.label,t),r.style.fontWeight="600",n.appendChild(r)}if(e.description!=null){let r=g("div","pf-choice-card-description");r.textContent=w(e.description,t),r.style.fontSize="14px",n.appendChild(r)}return M(e,n,t),n}function Ln(){p("Tabs",li),p("Tab",ci),p("Accordion",di),p("AccordionItem",pi),p("Dialog",ui),p("Popover",fi),p("Tooltip",mi),p("HoverCard",gi),p("Carousel",hi)}function li(e,t){let n=g("div","pf-tabs"),r=g("div","pf-tabs-bar");r.setAttribute("role","tablist"),r.style.display="flex",r.style.gap="4px",r.style.marginBottom="12px";let o=[],i=[],s=e.children??[],a=(()=>{let c=e.defaultTab;if(typeof c==="number")return c>=0&&c<s.length?c:0;if(typeof c==="string"){let u=s.findIndex((d)=>d.title===c);return u>=0?u:0}return 0})();if(e.children)for(let c=0;c<e.children.length;c++){let u=e.children[c],d=`pf-tab-${Math.random().toString(36).slice(2,8)}`,m=`pf-panel-${Math.random().toString(36).slice(2,8)}`,h=document.createElement("button");h.type="button",h.className="pf-tab-trigger",h.textContent=b(u.title)??`Tab ${String(c+1)}`,h.setAttribute("role","tab"),h.setAttribute("aria-selected",c===a?"true":"false"),h.setAttribute("aria-controls",m),h.id=d,h.tabIndex=c===a?0:-1,h.style.padding="8px 16px",h.style.border="none",h.style.background="none",h.style.cursor="pointer",h.style.borderBottom="2px solid transparent",h.style.marginBottom="-2px",h.style.fontSize="14px";let C=g("div","pf-tab-panel");if(C.style.display=c===a?"block":"none",C.setAttribute("role","tabpanel"),C.setAttribute("aria-labelledby",d),C.id=m,C.tabIndex=0,M(u,C,t),h.addEventListener("click",()=>{l(c)}),c===a)h.classList.add("pf-tab-active"),h.style.fontWeight="600";i.push(h),o.push(C),r.appendChild(h)}function l(c){o.forEach((u)=>u.style.display="none"),i.forEach((u)=>{u.style.borderBottomColor="transparent",u.style.fontWeight="normal",u.classList.remove("pf-tab-active"),u.setAttribute("aria-selected","false"),u.tabIndex=-1}),o[c].style.display="block",i[c].classList.add("pf-tab-active"),i[c].style.fontWeight="600",i[c].setAttribute("aria-selected","true"),i[c].tabIndex=0,i[c].focus()}r.addEventListener("keydown",(c)=>{let u=i.indexOf(c.target);if(u<0)return;let d;if(c.key==="ArrowRight")d=(u+1)%i.length;else if(c.key==="ArrowLeft")d=(u-1+i.length)%i.length;else if(c.key==="Home")d=0;else if(c.key==="End")d=i.length-1;else return;c.preventDefault(),l(d)}),n.appendChild(r);for(let c of o)n.appendChild(c);return n}function ci(e,t){let n=g("div","pf-tab");return M(e,n,t),n}function di(e,t){let n=g("div","pf-accordion");return M(e,n,t),n}function pi(e,t){let n=g("div","pf-accordion-item"),r=`pf-acc-${Math.random().toString(36).slice(2,8)}`,o=document.createElement("button");o.type="button",o.className="pf-accordion-trigger",o.textContent=b(e.title)??"",o.setAttribute("aria-expanded","false"),o.setAttribute("aria-controls",r),o.style.width="100%",o.style.textAlign="left",o.style.padding="12px 0",o.style.border="none",o.style.background="none",o.style.cursor="pointer",o.style.fontSize="14px",o.style.fontWeight="500";let i=g("div","pf-accordion-content");return i.id=r,i.setAttribute("role","region"),i.setAttribute("aria-labelledby",o.id),i.style.display="none",i.style.paddingBottom="12px",M(e,i,t),o.addEventListener("click",()=>{let s=i.style.display!=="none";i.style.display=s?"none":"block",o.setAttribute("aria-expanded",s?"false":"true")}),n.appendChild(o),n.appendChild(i),n}function ui(e,t){let n=g("div","pf-dialog-wrapper");if(e.trigger!=null){let i=j(e.trigger,t);i.addEventListener("click",()=>{r.showModal()}),n.appendChild(i)}let r=document.createElement("dialog");if(r.className="pf-dialog",r.setAttribute("aria-modal","true"),r.style.maxWidth="500px",r.style.width="100%",r.style.padding="24px",e.title!=null){let i=g("h2","pf-dialog-title");i.textContent=w(e.title,t),i.id=`pf-dialog-title-${Math.random().toString(36).slice(2,8)}`,r.setAttribute("aria-labelledby",i.id),r.appendChild(i)}if(e.description!=null){let i=g("p","pf-dialog-desc");i.textContent=w(e.description,t),r.appendChild(i)}let o=g("div","pf-dialog-body");if(M(e,o,t),r.appendChild(o),e.dismissible!==!1)r.addEventListener("click",(i)=>{if(i.target===r)r.close()});return document.addEventListener("prefab:close-overlay",()=>r.close()),n.appendChild(r),n}function fi(e,t){let n=g("div","pf-popover");n.style.position="relative",n.style.display="inline-block";let r=g("div","pf-popover-content");if(r.style.display="none",r.style.position="absolute",r.style.zIndex="50",r.style.padding="12px",r.style.boxShadow="0 4px 6px -1px rgb(0 0 0 / 0.1)",e.title!=null){let i=g("div","pf-popover-title");i.textContent=w(e.title,t),i.style.fontWeight="600",i.style.marginBottom="4px",r.appendChild(i)}M(e,r,t);let o=()=>{r.style.display=r.style.display==="none"?"block":"none"};if(e.trigger!=null){let i=j(e.trigger,t);i.addEventListener("click",(s)=>{s.stopPropagation(),o()}),n.appendChild(i)}else n.addEventListener("click",(i)=>{if(r.contains(i.target)&&r.style.display!=="none")return;o()});return n.appendChild(r),n}function mi(e,t){let n=g("div","pf-tooltip");n.style.position="relative",n.style.display="inline-block";let r=`pf-tip-${Math.random().toString(36).slice(2,8)}`,o=g("div","pf-tooltip-content");return o.id=r,o.setAttribute("role","tooltip"),o.textContent=w(e.content??"",t),o.style.display="none",o.style.position="absolute",o.style.bottom="100%",o.style.left="50%",o.style.transform="translateX(-50%)",o.style.padding="4px 8px",o.style.borderRadius="4px",o.style.color="#fff",o.style.fontSize="12px",o.style.whiteSpace="nowrap",o.style.zIndex="50",M(e,n,t),n.setAttribute("aria-describedby",r),n.addEventListener("mouseenter",()=>{o.style.display="block"}),n.addEventListener("mouseleave",()=>{o.style.display="none"}),n.addEventListener("focus",()=>{o.style.display="block"},!0),n.addEventListener("blur",()=>{o.style.display="none"},!0),n.appendChild(o),n}function gi(e,t){let n=g("div","pf-hover-card");n.style.position="relative",n.style.display="inline-block";let r=g("div","pf-hover-card-content");if(r.style.display="none",r.style.position="absolute",r.style.zIndex="50",r.style.padding="16px",r.style.boxShadow="0 4px 6px -1px rgb(0 0 0 / 0.1)",r.style.minWidth="200px",e.trigger!=null)n.appendChild(j(e.trigger,t));return M(e,r,t),n.addEventListener("mouseenter",()=>{r.style.display="block"}),n.addEventListener("mouseleave",()=>{r.style.display="none"}),n.appendChild(r),n}function hi(e,t){let n=g("div","pf-carousel");n.style.position="relative",n.style.overflow="hidden",n.setAttribute("role","region"),n.setAttribute("aria-roledescription","carousel"),n.setAttribute("aria-label",w(e.label??"Carousel",t));let r=g("div","pf-carousel-track");r.style.display="flex",r.style.transition="transform 0.3s ease",M(e,r,t);let o=0,i=e.children?.length??0,s=document.createElement("button");s.type="button",s.textContent="‹",s.className="pf-carousel-prev",s.setAttribute("aria-label","Previous slide"),s.style.position="absolute",s.style.left="4px",s.style.top="50%",s.style.transform="translateY(-50%)",s.style.zIndex="10";let a=document.createElement("button");a.type="button",a.textContent="›",a.className="pf-carousel-next",a.setAttribute("aria-label","Next slide"),a.style.position="absolute",a.style.right="4px",a.style.top="50%",a.style.transform="translateY(-50%)",a.style.zIndex="10";let l=()=>{r.style.transform=`translateX(-${o*100}%)`};return s.addEventListener("click",()=>{if(i===0)return;o=Math.max(0,o-1),l()}),a.addEventListener("click",()=>{if(i===0)return;o=Math.min(i-1,o+1),l()}),n.appendChild(r),n.appendChild(s),n.appendChild(a),n}function bi(e){if(!S(e))return{};return Object.fromEntries(Object.entries(e).map(([t,n])=>[t,Array.isArray(n)?n.filter(Ee):[]]))}function Pn(){p("ForEach",yi),p("If",Hn),p("Elif",Ci),p("Else",xi),p("Condition",wi),p("Define",vi),p("Use",ki),p("Slot",Si)}function yi(e,t){let n=document.createDocumentFragment(),r=b(e.expression);if(!r)return n;let o;if(G(r)){let s=q(r,t.store,t.scope);o=Array.isArray(s)?s:[]}else{let s=t.store.get(r);o=Array.isArray(s)?s:[]}let i=I(e.let)??{};for(let s=0;s<o.length;s++){let a=o[s],l={...t.scope,$item:a,$index:s,...i},c={...t,scope:l};if(e.children)ie(e.children,n,c)}return n}function Hn(e,t){if($n(b(e.condition)??"",t)){let r=document.createDocumentFragment();if(e.children)ie(e.children,r,t);return r}return document.createDocumentFragment()}function Ci(e,t){return Hn(e,t)}function xi(e,t){let n=document.createDocumentFragment();if(e.children)ie(e.children,n,t);return n}function $n(e,t){if(!e)return!1;if(G(e))return Boolean(q(e,t.store,t.scope));return Boolean(t.store.get(e))}function wi(e,t){let n=document.createDocumentFragment(),{cases:r,else:o}=e;if(r){for(let i of r)if($n(i.when,t)){if(i.children)ie(i.children,n,t);return n}}if(o)ie(o,n,t);return n}function vi(e,t){let n=b(e.name);if(n&&e.children)t.templates=t.templates??{},t.templates[n]=e.children;return document.createDocumentFragment()}function ki(e,t){let n=document.createDocumentFragment(),r=b(e.def??e.name),o=r!=null?t.templates?.[r]:void 0;if(!o)return n;let i=I(e.overrides)??{},s={...t.scope,...i},a={...t.slots??{},...bi(e.slots)};if(Array.isArray(e.children))a.default=e.children;let l={...t,scope:s,slots:a};for(let c of o)n.appendChild(j(c,l));return n}function Si(e,t){let n=document.createDocumentFragment(),r=b(e.name)??"default",i=t.slots?.[r]??e.children;if(i)for(let s of i)n.appendChild(j(s,t));return n}function Dn(){p("Alert",Ei),p("AlertTitle",Ri),p("AlertDescription",Ti)}function Ei(e,t){let n=g("div","pf-alert");n.setAttribute("role","alert");let r=b(e.variant)??"default";if(n.setAttribute("data-variant",r),n.style.padding="12px 16px",e.icon!=null){let o=g("span","pf-alert-icon");o.setAttribute("data-icon",k(e.icon)),o.style.marginRight="8px",n.appendChild(o)}return M(e,n,t),n}function Ri(e,t){let n=g("h5","pf-alert-title");return n.textContent=w(e.content,t),n.style.fontWeight="600",n.style.marginBottom="4px",n}function Ti(e,t){let n=g("p","pf-alert-description");return n.textContent=w(e.content,t),n.style.fontSize="14px",n}function On(){p("Image",Ai),p("Audio",Mi),p("Video",Ni),p("Embed",Li),p("Svg",Hi),p("DropZone",Di),p("Mermaid",Oi)}function Ai(e,t){let n=document.createElement("img");if(n.className="pf-image",n.src=w(e.src,t),e.alt!=null)n.alt=w(e.alt,t);if(e.width!=null)n.width=Number(e.width);if(e.height!=null)n.height=Number(e.height);return n.style.maxWidth="100%",n}function Mi(e,t){let n=document.createElement("audio");return n.className="pf-audio",n.src=w(e.src,t),n.controls=!0,n}function Ni(e,t){let n=document.createElement("video");if(n.className="pf-video",n.src=w(e.src,t),n.controls=!0,e.width!=null)n.width=Number(e.width);if(e.height!=null)n.height=Number(e.height);return n.style.maxWidth="100%",n}function Li(e,t){let n=g("div","pf-embed"),r=document.createElement("iframe");return r.src=w(e.src,t),r.style.width="100%",r.style.height=e.height!=null?`${String(Number(e.height))}px`:"400px",r.style.border="none",r.setAttribute("sandbox","allow-scripts"),n.appendChild(r),n}var Pi=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 Hi(e,t){let n=g("div","pf-svg"),r=w(e.content,t);if(!r.includes("<svg"))return n;if(!/<svg[^>]*\sxmlns\s*=/.test(r))r=r.replace(/<svg\b/,'<svg xmlns="http://www.w3.org/2000/svg"');let i=new DOMParser().parseFromString(r,"image/svg+xml").querySelector("svg");if(!i)return n;return In(i),n.appendChild(document.importNode(i,!0)),n}function In(e){let t=Array.from(e.children);for(let n of t){if(!Pi.has(n.tagName.toLowerCase())){n.remove();continue}for(let r of Array.from(n.attributes)){let o=r.name.toLowerCase();if(o.startsWith("on")||o==="href"&&r.value.trim().toLowerCase().startsWith("javascript:"))n.removeAttribute(r.name)}In(n)}}function $i(e,t){let n=(t??"").split(",").map((i)=>i.trim().toLowerCase()).filter(Boolean);if(n.length===0)return!0;let r=e.name.toLowerCase(),o=e.type.toLowerCase();return n.some((i)=>{if(i.startsWith("."))return r.endsWith(i);if(i.endsWith("/*"))return o.startsWith(i.slice(0,-1));return o===i})}function Di(e,t){let n=g("div","pf-dropzone");n.style.padding="32px",n.style.textAlign="center",n.style.cursor="pointer",n.textContent=w(e.label??"Drop files here",t);let r=document.createElement("input");if(r.type="file",r.style.display="none",e.accept!=null)r.accept=k(e.accept);if(e.multiple===!0)r.multiple=!0;n.appendChild(r),n.setAttribute("role","button"),n.tabIndex=0;function o(s){let a=Array.from(s??[]).filter((l)=>$i(l,b(e.accept)));return e.multiple===!0?a:a.slice(0,1)}function i(s){if(s.length===0)return;let a=b(e.resultKey);if(a!=null)t.store.set(a,s),t.rerender();if(e.onDrop!=null)D(H(e.onDrop,{...V(t),scope:{...t.scope,$result:s}}),"onDrop")}return r.addEventListener("change",()=>{i(o(r.files)),r.value=""}),n.addEventListener("click",()=>r.click()),n.addEventListener("keydown",(s)=>{if(s.key==="Enter"||s.key===" ")s.preventDefault(),r.click()}),n.addEventListener("dragover",(s)=>{s.preventDefault(),n.classList.add("pf-dropzone-active")}),n.addEventListener("dragleave",()=>{n.classList.remove("pf-dropzone-active")}),n.addEventListener("drop",(s)=>{s.preventDefault(),n.classList.remove("pf-dropzone-active"),i(o(s.dataTransfer?.files??null))}),n}function Oi(e,t){let n=g("div","pf-mermaid");n.setAttribute("data-mermaid","true");let r=w(e.content,t);if(n.textContent=r,"mermaid"in globalThis)n.classList.add("mermaid"),n.textContent=r;return n}var Ii="https://cdn.jsdelivr.net/npm/pdfjs-dist@4.9/build/pdf.min.mjs",ji="https://cdn.jsdelivr.net/npm/pdfjs-dist@4.9/build/pdf.worker.min.mjs",xt=null,Ke=null;function Fi(e){return S(e)&&typeof e.getDocument==="function"&&S(e.GlobalWorkerOptions)}function wt(e,t){let n=typeof e==="string"&&e.trim()!==""?Number(e):e;return typeof n==="number"&&Number.isFinite(n)?n:t}function Bi(e){return e==="fit-page"||e==="fit-width"?e:wt(e,0)||"fit-width"}async function Vi(){if(xt)return xt;if(Ke)return Ke;return Ke=import(Ii).then((e)=>{if(!Fi(e))throw Error("PDF.js did not load");let t=e;return t.GlobalWorkerOptions.workerSrc=ji,xt=t,t}),Ke}function Fn(){p("PdfViewer",_i)}function _i(e,t){let n=g("div","pf-pdf-viewer"),r=e.src!=null?w(e.src,t):void 0,o=b(e.data),i=wt(e.page,1),s=Bi(e.zoom),a=e.toolbar!==!1,l=wt(e.height,600);n.style.height=`${l}px`,n.style.display="flex",n.style.flexDirection="column",n.style.overflow="hidden",n.style.border="1px solid var(--color-border-primary, #e5e7eb)",n.style.borderRadius="var(--border-radius-md, 0.375rem)",n.style.background="var(--color-background-secondary, #f9fafb)";let c=g("div","pf-pdf-loading");return c.textContent="Loading PDF…",c.style.display="flex",c.style.alignItems="center",c.style.justifyContent="center",c.style.flex="1",c.style.color="var(--color-text-secondary, #6b7280)",n.appendChild(c),zi(n,c,{src:r,data:o,initialPage:i,zoom:s,showToolbar:a}),n}async function zi(e,t,n){try{let r=await Vi(),o;if(n.src)o={url:n.src};else if(n.data){let m=atob(n.data),h=new Uint8Array(m.length);for(let C=0;C<m.length;C++)h[C]=m.charCodeAt(C);o={data:h}}else{t.textContent="Error: No PDF source provided";return}let i=await r.getDocument(o).promise;t.remove();let s=Math.max(1,Math.min(n.initialPage,i.numPages)),a=null,l=null;if(n.showToolbar){let m=Wi(i.numPages,s,{onPrev:()=>{if(s>1)s--,d()},onNext:()=>{if(s<i.numPages)s++,d()},onPageChange:(h)=>{let C=Math.max(1,Math.min(h,i.numPages));if(C!==s)s=C,d()}});a=m.pageInput,l=m.pageCount,e.insertBefore(m.el,e.firstChild)}let c=g("div","pf-pdf-canvas-container");c.style.flex="1",c.style.overflow="auto",c.style.display="flex",c.style.justifyContent="center",c.style.padding="8px",e.appendChild(c);let u=document.createElement("canvas");u.style.display="block",u.style.boxShadow="var(--shadow-md, 0 4px 6px -1px rgba(0,0,0,.1))",c.appendChild(u);async function d(){let m=await i.getPage(s),h=c.clientWidth-16,C,f=m.getViewport({scale:1});if(n.zoom==="fit-width")C=h/f.width;else if(n.zoom==="fit-page"){let v=c.clientHeight-16,R=h/f.width,T=v/f.height;C=Math.min(R,T)}else C=typeof n.zoom==="number"?n.zoom:1;let y=m.getViewport({scale:C});u.width=y.width,u.height=y.height,u.style.width=`${y.width}px`,u.style.height=`${y.height}px`;let x=u.getContext("2d");if(!x)return;if(await m.render({canvasContext:x,viewport:y}).promise,a)a.value=String(s);if(l)l.textContent=`/ ${i.numPages}`}await d()}catch(r){t.textContent=`PDF Error: ${r instanceof Error?r.message:String(r)}`,t.style.color="var(--color-text-danger, #dc2626)"}}function Wi(e,t,n){let r=g("div","pf-pdf-toolbar");r.style.display="flex",r.style.alignItems="center",r.style.gap="8px",r.style.padding="6px 12px",r.style.borderBottom="1px solid var(--color-border-primary, #e5e7eb)",r.style.background="var(--color-background-primary, #fff)",r.style.flexShrink="0",r.style.fontSize="13px";let o=document.createElement("button");o.textContent="‹",o.title="Previous page",o.className="pf-pdf-btn",jn(o),o.addEventListener("click",n.onPrev);let i=document.createElement("button");i.textContent="›",i.title="Next page",i.className="pf-pdf-btn",jn(i),i.addEventListener("click",n.onNext);let s=document.createElement("input");s.type="number",s.min="1",s.max=String(e),s.value=String(t),s.style.width="48px",s.style.textAlign="center",s.style.border="1px solid var(--color-border-primary, #e5e7eb)",s.style.borderRadius="4px",s.style.padding="2px 4px",s.style.fontSize="13px",s.addEventListener("change",()=>{let l=parseInt(s.value,10);if(!isNaN(l))n.onPageChange(l)});let a=document.createElement("span");return a.textContent=`/ ${e}`,a.style.color="var(--color-text-secondary, #6b7280)",r.appendChild(o),r.appendChild(s),r.appendChild(a),r.appendChild(i),{el:r,pageInput:s,pageCount:a}}function jn(e){e.style.border="1px solid var(--color-border-primary, #e5e7eb)",e.style.borderRadius="4px",e.style.background="var(--color-background-primary, #fff)",e.style.cursor="pointer",e.style.padding="2px 8px",e.style.fontSize="16px",e.style.lineHeight="1"}var F=["#3b82f6","#10b981","#f59e0b","#ef4444","#8b5cf6","#ec4899"],X="var(--muted-foreground, #6b7280)",ue="var(--border, #e5e7eb)",ae="10";function Je(e,t,n,r=!1){let o=n?44:0,i=e-(r?44:0),s=10,a=t-24;return{plotLeft:o,plotRight:i,plotTop:10,plotBottom:a,plotWidth:i-o,plotHeight:a-10}}function Bn(e,t=5){if(e<=0)return[0];let n=e/t,r=Math.pow(10,Math.floor(Math.log10(n))),o=n/r,i=o<=1.5?r:o<=3?2*r:o<=7?5*r:10*r,s=[];for(let a=0;a<=e+i*0.01;a+=i)s.push(Math.round(a*1000)/1000);return s}function Vn(e,t,n,r,o){let i=Bn(n);for(let s of i){let a=t.plotBottom-(n>0?s/n*t.plotHeight:0),l=z("text",{x:t.plotLeft-6,y:a+3,"text-anchor":"end","font-size":ae,fill:X});if(l.textContent=kt(s,o),e.appendChild(l),r&&s>0)e.appendChild(z("line",{x1:t.plotLeft,y1:a,x2:t.plotRight,y2:a,stroke:ue,"stroke-width":1,"stroke-dasharray":"4 3"}))}}function _n(e,t,n,r){let o=Bn(n);for(let i of o){let s=t.plotBottom-(n>0?i/n*t.plotHeight:0),a=z("text",{x:t.plotRight+6,y:s+3,"text-anchor":"start","font-size":ae,fill:X});a.textContent=kt(i,r),e.appendChild(a)}}function vt(e,t,n,r,o,i){for(let s=0;s<t.length;s++){let a=t[s][n],l=z("text",{x:r(s),y:o+14,"text-anchor":"middle","font-size":ae,fill:X});l.textContent=a==null?"":i?i(a):k(a),e.appendChild(l)}}function Ge(e,t){e.appendChild(z("line",{x1:t.plotLeft,y1:t.plotBottom,x2:t.plotRight,y2:t.plotBottom,stroke:X,"stroke-width":1}))}function le(e,t,n){if(e==null)return"";let r=K(`{{ __v | ${t} }}`,{...n,scope:{...n.scope,__v:e}});return k(r??e)}function kt(e,t){if(t==="currency")return`$${e.toLocaleString()}`;if(t==="percent")return`${e}%`;if(e>=1e6)return`${(e/1e6).toFixed(1)}M`;if(e>=1000)return`${(e/1000).toFixed(1)}K`;return String(e)}function ce(e){let t=b(e.yAxisFormat)??b(e.valueFormat);return t&&t!=="auto"?t:void 0}function St(e,t,n){return(r,o)=>{if(r===null||r===void 0)return"—";if(o.tooltipFormat)return le(r,o.tooltipFormat,e);let i=o.yAxisId==="right"?n:t;return kt(Number(r),i)}}function te(e,t,n){let r=document.createElementNS("http://www.w3.org/2000/svg","svg");if(r.setAttribute("width","100%"),r.setAttribute("height",String(t)),r.setAttribute("viewBox",`0 0 ${e} ${t}`),r.setAttribute("role","img"),n)r.setAttribute("aria-label",`${n} chart`);return r.style.overflow="visible",r}function z(e,t){let n=document.createElementNS("http://www.w3.org/2000/svg",e);for(let[r,o]of Object.entries(t))n.setAttribute(r,String(o));return n}function Ae(e,t){let n=z("text",e);return n.textContent=t,n}function fe(e,t,n,r){let o=r*Math.PI/180;return{x:e+n*Math.cos(o),y:t-n*Math.sin(o)}}function Et(e,t,n,r,o){let i=Math.max(2,Math.ceil(Math.abs(o-r)/4)),s=[];for(let a=0;a<=i;a++){let l=fe(e,t,n,r+(o-r)*a/i);s.push(`${a===0?"M":"L"} ${l.x.toFixed(2)} ${l.y.toFixed(2)}`)}return s.join(" ")}function ne(e,t,n){if(!n||t.length<=1)return;let r=g("div","pf-chart-legend");r.style.display="flex",r.style.gap="12px",r.style.fontSize="12px",r.style.marginBottom="8px";for(let o=0;o<t.length;o++){let i=g("div","pf-chart-legend-item");i.style.display="flex",i.style.alignItems="center",i.style.gap="4px";let s=g("span");s.style.width="8px",s.style.height="8px",s.style.borderRadius="50%",s.style.backgroundColor=t[o].color??F[o%F.length];let a=g("span");a.textContent=t[o].label??t[o].dataKey,i.appendChild(s),i.appendChild(a),r.appendChild(i)}e.appendChild(r)}function re(e,t){let n=document.createElement("div");return n.className="pf-chart-tooltip",e.appendChild(n),e.addEventListener("mouseleave",()=>{n.classList.remove("pf-visible")}),{wrapper:e,tooltip:n,svgEl:t}}function Rt(e,t,n,r,o){let{tooltip:i,svgEl:s,wrapper:a}=e;if(o.length===0)return;let l="";if(r)l+=`<div class="pf-chart-tooltip-label">${qe(r)}</div>`;for(let y of o)l+='<div class="pf-chart-tooltip-row">',l+=`<span class="pf-chart-tooltip-dot" style="background:${qe(y.color)}"></span>`,l+=`<span>${qe(y.label)}:</span> <strong>${qe(String(y.value))}</strong>`,l+="</div>";i.innerHTML=l;let c=s.getBoundingClientRect(),u=a.getBoundingClientRect(),d=s.viewBox.baseVal,m=c.width/(d.width||1),h=c.left-u.left+t*m,C=i.offsetWidth||100,f=h+12;if(f+C>u.width)f=h-C-12;i.style.left=`${Math.max(0,f)}px`,i.style.top="4px",i.classList.add("pf-visible")}function qe(e){return e.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""")}function xe(e,t,n,r,o,i){let s=()=>{Rt(t,n,r,o,i)},a=()=>{t.tooltip.classList.remove("pf-visible")};e.addEventListener("mouseenter",s),e.addEventListener("mouseleave",a),e.addEventListener("touchstart",s,{passive:!0}),e.addEventListener("touchend",a,{passive:!0})}function zn(e,t,n,r,o,i,s,a){let l=o.plotWidth/n.length;for(let c=0;c<n.length;c++){let u=o.plotLeft+c*l,d=document.createElementNS("http://www.w3.org/2000/svg","rect");d.setAttribute("x",String(u)),d.setAttribute("y",String(o.plotTop)),d.setAttribute("width",String(l)),d.setAttribute("height",String(o.plotHeight)),d.setAttribute("fill","transparent"),d.style.cursor="default";let m=i?n[c][i]:void 0,h=m!=null?a?a(m):k(m):void 0,C=r.map((v,R)=>({label:v.label??v.dataKey,value:s(n[c][v.dataKey],v,R),color:v.color??F[R%F.length]})),f=u+l/2,y=()=>Rt(e,f,o.plotTop,h,C),x=()=>e.tooltip.classList.remove("pf-visible");d.addEventListener("mouseenter",y),d.addEventListener("mouseleave",x),d.addEventListener("touchstart",y,{passive:!0}),d.addEventListener("touchend",x,{passive:!0}),t.appendChild(d)}}function Wn(e,t,n,r,o,i,s,a,l,c){let u=n.length===1?o.plotWidth:o.plotWidth/(n.length-1);for(let d=0;d<n.length;d++){let m=n.length===1?(o.plotLeft+o.plotRight)/2:o.plotLeft+d/(n.length-1)*o.plotWidth,h=n.length===1?o.plotLeft:m-u/2,C=n.length===1?o.plotWidth:u,f=document.createElementNS("http://www.w3.org/2000/svg","rect");f.setAttribute("x",String(Math.max(o.plotLeft,h))),f.setAttribute("y",String(o.plotTop)),f.setAttribute("width",String(Math.min(C,o.plotRight-Math.max(o.plotLeft,h)))),f.setAttribute("height",String(o.plotHeight)),f.setAttribute("fill","transparent"),f.style.cursor="default";let y=i?n[d][i]:void 0,x=y!=null?c?c(y):k(y):void 0,v=r.map((E,A)=>({label:E.label??E.dataKey,value:s(n[d][E.dataKey],E,A),color:E.color??F[A%F.length]})),R=()=>{if(Rt(e,m,o.plotTop,x,v),a)a.setAttribute("x1",String(m)),a.setAttribute("x2",String(m)),a.setAttribute("opacity","1");if(l)for(let E of l){for(let A of E)A.setAttribute("data-visible","false");E[d]?.setAttribute("data-visible","true")}},T=()=>{if(e.tooltip.classList.remove("pf-visible"),a)a.setAttribute("opacity","0");if(l)for(let E of l)for(let A of E)A.setAttribute("data-visible","false")};f.addEventListener("mouseenter",R),f.addEventListener("mouseleave",T),f.addEventListener("touchstart",R,{passive:!0}),f.addEventListener("touchend",T,{passive:!0}),t.appendChild(f)}}function me(e,t){return ve(K(e.data,t))}function Kn(e,t){let n=K(e.data,t);if(!Array.isArray(n)||n.length===0)return;return n.filter((r)=>typeof r==="number"&&Number.isFinite(r))}function Ki(e){return e==="left"||e==="right"?e:void 0}function Ji(e){if(!S(e)||typeof e.dataKey!=="string")return;let t=b(e.label),n=b(e.color),r=Ki(e.yAxisId),o=b(e.tooltipFormat);return{dataKey:e.dataKey,...t!==void 0&&{label:t},...n!==void 0&&{color:n},...r!==void 0&&{yAxisId:r},...o!==void 0&&{tooltipFormat:o}}}function ge(e){if(!Array.isArray(e.series))return[];return e.series.flatMap((t)=>{let n=Ji(t);return n?[n]:[]})}function de(e,t){return O(e.height)??t}function Me(e,t){return Math.max(...e.flatMap((n)=>t.map((r)=>Number(n[r.dataKey]??0))),1)}function Tt(e,t){return{valueKey:b(e.dataKey)??t[0]?.dataKey,nameKey:b(e.nameKey)??b(e.tooltipXKey)??b(e.xAxis)}}function At(e,t){return{rows:me(e,t),series:ge(e),height:de(e,300),showYAxis:e.showYAxis!==!1,showGrid:e.showGrid===!0,showYAxisRight:e.showYAxisRight===!0,showTooltip:e.showTooltip!==!1,showLegend:e.showLegend!==!1,xAxisKey:b(e.xAxis),tooltipXKey:b(e.tooltipXKey),xAxisFormat:b(e.xAxisFormat),tooltipXFormat:b(e.tooltipXFormat),yAxisRightFormat:b(e.yAxisRightFormat)}}function Jn(e,t,n){let r=t.series.filter((d)=>d.yAxisId!=="right"),o=t.series.filter((d)=>d.yAxisId==="right"),i=t.showYAxisRight&&o.length>0,s=r.length>0?Me(t.rows,r):1,a=i?Me(t.rows,o):1,l=400,c=Je(400,t.height,t.showYAxis,i),u=te(400,t.height,n);if(t.showYAxis)Vn(u,c,s,t.showGrid,ce(e));if(i)_n(u,c,a,t.yAxisRightFormat);return Ge(u,c),{layout:c,svg:u,leftMax:s,rightMax:a}}function Ue(e,t){return e?(n)=>le(n,e,t):void 0}function Gn(e,t){let n=g("div","pf-chart pf-bar-chart"),r=At(e,t),{rows:o,series:i}=r;if(o.length===0||i.length===0)return n.textContent="No chart data",n;let{layout:s,svg:a,leftMax:l,rightMax:c}=Jn(e,r,"Bar"),u=s.plotWidth/o.length,d=u/(i.length+1);for(let m=0;m<o.length;m++)for(let h=0;h<i.length;h++){let C=i[h],f=o[m][C.dataKey];if(f===null||f===void 0)continue;let y=C.yAxisId==="right"?c:l,x=Math.max(0,Number(f)/y*s.plotHeight),v=s.plotLeft+m*u+h*d+d/2,R=document.createElementNS("http://www.w3.org/2000/svg","rect");R.setAttribute("x",String(v)),R.setAttribute("y",String(s.plotBottom-x)),R.setAttribute("width",String(d*0.8)),R.setAttribute("height",String(x)),R.setAttribute("fill",C.color??F[h%F.length]),R.setAttribute("rx","2"),a.appendChild(R)}if(r.xAxisKey)vt(a,o,r.xAxisKey,(m)=>s.plotLeft+m*u+u/2,s.plotBottom,Ue(r.xAxisFormat,t));if(r.showTooltip){let m=re(n,a),h=St(t,ce(e),r.yAxisRightFormat);zn(m,a,o,i,s,r.tooltipXKey??r.xAxisKey,h,Ue(r.tooltipXFormat,t))}return ne(n,i,r.showLegend),n.appendChild(a),n}function Gi(e,t,n,r){let o=[],i=()=>{if(o.length<2){o=[];return}let s=`M ${o[0].x},${n} `+o.map((l)=>`L ${l.x},${l.y}`).join(" ")+` L ${o[o.length-1].x},${n} Z`,a=document.createElementNS("http://www.w3.org/2000/svg","path");a.setAttribute("d",s),a.setAttribute("fill",r),a.setAttribute("opacity","0.15"),e.appendChild(a),o=[]};for(let s of t){if(s.isNull){i();continue}o.push(s)}i()}function qi(e,t,n,r){let o="";for(let s of t){if(s.isNull)continue;let a=t.indexOf(s),l=a===0||t[a-1].isNull;o+=`${l?"M":"L"} ${s.x},${s.y} `}if(!o)return;let i=document.createElementNS("http://www.w3.org/2000/svg","path");if(i.setAttribute("d",o.trim()),i.setAttribute("fill","none"),i.setAttribute("stroke",n),i.setAttribute("stroke-width","2"),r)i.setAttribute("stroke-dasharray","6 3");e.appendChild(i)}function Ui(e,t,n){let r=[];for(let o of t){let i=document.createElementNS("http://www.w3.org/2000/svg","circle");if(i.setAttribute("cx",String(o.x)),i.setAttribute("cy",String(o.y)),i.setAttribute("r","4"),i.setAttribute("fill",n),i.setAttribute("class","pf-data-dot"),i.setAttribute("data-visible","false"),i.style.pointerEvents="none",o.isNull)i.style.display="none";e.appendChild(i),r.push(i)}return r}function Xi(e,t){let n=document.createElementNS("http://www.w3.org/2000/svg","line");return n.setAttribute("class","pf-crosshair"),n.setAttribute("x1",String(t.plotLeft)),n.setAttribute("x2",String(t.plotLeft)),n.setAttribute("y1",String(t.plotTop)),n.setAttribute("y2",String(t.plotBottom)),n.setAttribute("stroke",X),n.setAttribute("stroke-width","1"),n.setAttribute("stroke-dasharray","3 3"),n.setAttribute("opacity","0"),e.appendChild(n),n}function Mt(e,t){let n=g("div",`pf-chart pf-${e.type.toLowerCase()}-chart`),r=At(e,t),{rows:o,series:i}=r;if(o.length===0||i.length===0)return n.textContent="No chart data",n;let s=e.type==="AreaChart",{layout:a,svg:l,leftMax:c,rightMax:u}=Jn(e,r,s?"Area":"Line"),d=(C)=>o.length===1?(a.plotLeft+a.plotRight)/2:a.plotLeft+C/(o.length-1)*a.plotWidth,m=[];for(let C=0;C<i.length;C++){let f=i[C],y=f.yAxisId==="right",x=y?u:c,v=f.color??F[C%F.length],R=o.map((T,E)=>{let A=T[f.dataKey],B=A===null||A===void 0,P=B?a.plotBottom:a.plotBottom-Number(A)/x*a.plotHeight;return{x:d(E),y:P,isNull:B}});if(s)Gi(l,R,a.plotBottom,v);qi(l,R,v,y),m.push(Ui(l,R,v))}let h=Xi(l,a);if(r.xAxisKey)vt(l,o,r.xAxisKey,d,a.plotBottom,Ue(r.xAxisFormat,t));if(r.showTooltip){let C=re(n,l),f=St(t,ce(e),r.yAxisRightFormat);Wn(C,l,o,i,a,r.tooltipXKey??r.xAxisKey,f,h,m,Ue(r.tooltipXFormat,t))}return ne(n,i,r.showLegend),n.appendChild(l),n}function Nt(e,t){let n=ce(e);return(r)=>n?le(r,n,t):String(r)}function qn(e,t){let n=g("div","pf-chart pf-pie-chart"),r=me(e,t),o=ge(e),i=Math.min(de(e,300),300),s=e.showTooltip!==!1,{valueKey:a,nameKey:l}=Tt(e,o),c=o.length>0?o:a?[{dataKey:a,label:a}]:[];if(r.length===0||!a)return n.textContent="No chart data",n;let u=te(i,i,"Pie"),d=i/2,m=i/2,h=i/2-10,C=b(e.tooltipXFormat),f=Nt(e,t),y=r.map((T)=>Number(T[a]??0)),x=y.reduce((T,E)=>T+E,0);if(x===0)return n.textContent="No chart data",n.appendChild(u),n;let v=s?re(n,u):void 0,R=-Math.PI/2;for(let T=0;T<y.length;T++){let E=y[T]/x*2*Math.PI,A=R+E,B=E>Math.PI?1:0,P=d+h*Math.cos(R),_=m+h*Math.sin(R),Y=d+h*Math.cos(A),Z=m+h*Math.sin(A),Q=F[T%F.length],U=document.createElementNS("http://www.w3.org/2000/svg","path");if(U.setAttribute("d",`M ${d},${m} L ${P},${_} A ${h},${h} 0 ${B} 1 ${Y},${Z} Z`),U.setAttribute("fill",Q),U.style.cursor="default",v){let L=l?r[T][l]:void 0,pe=L!=null?C?le(L,C,t):k(L):`Slice ${T+1}`,oe=`${(y[T]/x*100).toFixed(1)}%`,rt=d+h*0.6*Math.cos(R+E/2);xe(U,v,rt,m,pe,[{label:c[0].label??a,value:`${f(y[T])} (${oe})`,color:Q}])}u.appendChild(U),R=A}return ne(n,c,e.showLegend!==!1),n.appendChild(u),n}function Un(e,t){let n=g("div","pf-chart pf-radial-chart"),r=me(e,t),o=ge(e),{valueKey:i,nameKey:s}=Tt(e,o);if(r.length===0||!i)return n.textContent="No chart data",n;let a=Math.min(de(e,300),300),l=a/2,c=a/2,u=a/2-10,d=Math.max(0,Math.min(O(e.innerRadius)??30,u-10)),m=O(e.startAngle)??180,h=O(e.endAngle)??0,C=r.map((A)=>Number(A[i]??0)),f=Math.max(...C,1),y=te(a,a,"Radial"),x=(u-d)/r.length,v=Math.max(2,x*0.7),R=Nt(e,t),T=e.showTooltip!==!1?re(n,y):void 0,E=[];for(let A=0;A<r.length;A++){let B=u-x*A-x/2,P=o[A]?.color??F[A%F.length],_=m+C[A]/f*(h-m),Y=s?r[A][s]:null,Z=Y!=null?k(Y):o[A]?.label??i;E.push({dataKey:Z||i,label:Z||i,color:P}),y.appendChild(z("path",{d:Et(l,c,B,m,h),fill:"none",stroke:ue,"stroke-width":v,"stroke-linecap":"round"}));let Q=z("path",{d:Et(l,c,B,m,_),fill:"none",stroke:P,"stroke-width":v,"stroke-linecap":"round"});if(T){let U=fe(l,c,B,(m+_)/2);xe(Q,T,U.x,U.y,Z||i,[{label:i,value:R(C[A]),color:P}])}y.appendChild(Q)}return ne(n,E,e.showLegend!==!1),n.appendChild(y),n}function Xn(e,t){let n=g("div","pf-chart pf-radar-chart"),r=me(e,t),o=ge(e),i=b(e.axisKey)??b(e.xAxis);if(r.length===0||o.length===0)return n.textContent="No chart data",n;let s=e.filled!==!1,a=e.showDots===!0,l=e.showGrid!==!1,c=Math.min(de(e,300),320),u=c/2,d=c/2,m=c/2-24,h=r.length,C=Me(r,o),f=(T)=>90-360*T/h,y=(T)=>T.map((E)=>`${E.x.toFixed(1)},${E.y.toFixed(1)}`).join(" "),x=te(c,c,"Radar");if(l){for(let E=1;E<=4;E++){let A=m*E/4,B=Array.from({length:h},(P,_)=>fe(u,d,A,f(_)));x.appendChild(z("polygon",{points:y(B),fill:"none",stroke:ue,"stroke-width":1}))}for(let E=0;E<h;E++){let A=fe(u,d,m,f(E));x.appendChild(z("line",{x1:u,y1:d,x2:A.x,y2:A.y,stroke:ue,"stroke-width":1}))}}for(let T=0;T<h;T++){let E=fe(u,d,m+12,f(T)),A=i?r[T][i]:null;x.appendChild(Ae({x:E.x,y:E.y+3,"text-anchor":"middle","font-size":ae,fill:X},k(A)))}let v=e.showTooltip!==!1?re(n,x):void 0,R=Nt(e,t);for(let T=0;T<o.length;T++){let E=o[T],A=E.color??F[T%F.length],B=r.map((P,_)=>fe(u,d,Number(P[E.dataKey]??0)/C*m,f(_)));if(x.appendChild(z("polygon",{points:y(B),fill:s?A:"none","fill-opacity":s?0.2:0,stroke:A,"stroke-width":2})),!a&&!v)continue;for(let P=0;P<B.length;P++){let _=z("circle",{cx:B[P].x,cy:B[P].y,r:a?3:6,fill:a?A:"transparent","fill-opacity":a?1:0});if(v){let Y=i?r[P][i]:null,Z=Y!=null?k(Y):E.label??E.dataKey,Q=[{label:E.label??E.dataKey,value:R(Number(r[P][E.dataKey]??0)),color:A}];xe(_,v,B[P].x,B[P].y,Z,Q)}x.appendChild(_)}}return ne(n,o,e.showLegend!==!1),n.appendChild(x),n}function Yn(e,t){let n=g("div","pf-chart pf-scatter-chart"),r=me(e,t),o=b(e.xAxis),i=b(e.yAxis),s=b(e.zAxis),a=ge(e),l=de(e,300);if(r.length===0||!o||!i)return n.textContent="No chart data",n;let c=e.showGrid!==!1,u=a[0]?.color??F[0],d=ce(e),m=(L)=>d?le(L,d,t):String(Math.round(L*100)/100),h=r.map((L)=>Number(L[o]??0)),C=r.map((L)=>Number(L[i]??0)),f=Math.min(...h),y=Math.max(...h),x=Math.min(...C),v=Math.max(...C),R=y-f||1,T=v-x||1,E=s?r.map((L)=>Number(L[s]??0)):[],A=s?Math.max(...E,1):1,B=400,P=Je(B,l,!0),_=te(B,l,"Scatter"),Y=(L)=>P.plotLeft+(L-f)/R*P.plotWidth,Z=(L)=>P.plotBottom-(L-x)/T*P.plotHeight,Q=4;for(let L=0;L<=Q;L++){let pe=x+T*L/Q,oe=Z(pe);if(_.appendChild(Ae({x:P.plotLeft-6,y:oe+3,"text-anchor":"end","font-size":ae,fill:X},m(pe))),c&&L>0)_.appendChild(z("line",{x1:P.plotLeft,y1:oe,x2:P.plotRight,y2:oe,stroke:ue,"stroke-width":1,"stroke-dasharray":"4 3"}))}Ge(_,P);for(let L of[f,(f+y)/2,y])_.appendChild(Ae({x:Y(L),y:P.plotBottom+14,"text-anchor":"middle","font-size":ae,fill:X},String(Math.round(L*100)/100)));let U=e.showTooltip!==!1?re(n,_):void 0;for(let L=0;L<r.length;L++){let pe=Y(h[L]),oe=Z(C[L]),rt=s?4+Math.sqrt(E[L]/A)*14:4,Jt=z("circle",{cx:pe,cy:oe,r:rt,fill:u,"fill-opacity":s?0.6:0.85});if(U){let vr=[{label:o,value:m(h[L]),color:u},{label:i,value:m(C[L]),color:u},...s?[{label:s,value:m(E[L]),color:u}]:[]],kr=a[0]?.label??"Point";xe(Jt,U,pe,oe,kr,vr)}_.appendChild(Jt)}return ne(n,a,e.showLegend!==!1),n.appendChild(_),n}function Zn(e,t){let n=g("div","pf-chart pf-histogram"),r=Kn(e,t);if(!r)return n.textContent="No data",n;let o=O(e.bins)??10,i=de(e,200),s=b(e.color)??F[0],a=Math.min(...r),c=(Math.max(...r)-a)/o||1,u=Array(o).fill(0);for(let f of r){let y=Math.min(Math.floor((f-a)/c),o-1);u[y]++}let d=Math.max(...u),m=300,h=m/o,C=te(m,i,"Histogram");for(let f=0;f<o;f++){let y=d>0?u[f]/d*i:0,x=document.createElementNS("http://www.w3.org/2000/svg","rect");x.setAttribute("x",String(f*h)),x.setAttribute("y",String(i-y)),x.setAttribute("width",String(h-1)),x.setAttribute("height",String(y)),x.setAttribute("fill",s),C.appendChild(x)}return n.appendChild(C),n}function Qn(){p("BarChart",Gn),p("LineChart",Mt),p("AreaChart",Mt),p("PieChart",qn),p("RadarChart",Xn),p("ScatterChart",Yn),p("RadialChart",Un),p("Histogram",Zn)}function er(){p("Table",Yi),p("TableHead",Lt("thead")),p("TableBody",Lt("tbody")),p("TableFooter",Lt("tfoot")),p("TableRow",Zi),p("TableHeader",Qi),p("TableCell",es),p("TableCaption",ts),p("ExpandableRow",ns)}function Yi(e,t){let n=document.createElement("table");return n.className=e.striped===!0?"pf-table pf-table-striped":"pf-table",n.style.width="100%",n.style.borderCollapse="collapse",M(e,n,t),n}function Lt(e){return(t,n)=>{let r=document.createElement(e);return r.className=`pf-${e}`,M(t,r,n),r}}function Zi(e,t){let n=document.createElement("tr");return n.className="pf-table-row",M(e,n,t),n}function Qi(e,t){let n=document.createElement("th");return n.className="pf-table-header",n.style.textAlign="left",n.style.padding="8px 12px",n.style.fontWeight="600",n.textContent=w(e.content,t),n}function es(e,t){let n=document.createElement("td");if(n.className="pf-table-cell",n.style.padding="8px 12px",e.colSpan!=null)n.colSpan=Number(e.colSpan);if(e.rowSpan!=null)n.rowSpan=Number(e.rowSpan);return M(e,n,t),n}function ts(e,t){let n=document.createElement("caption");return n.className="pf-table-caption",n.style.padding="8px",n.style.fontSize="14px",n.textContent=w(e.content,t),n}function ns(e,t){let n=g("div","pf-expandable-row"),r=g("div","pf-expandable-row-summary");r.style.cursor="pointer",r.style.display="flex",r.style.alignItems="center",r.style.gap="8px";let o=g("span","pf-expandable-arrow");o.textContent="▶",o.style.transition="transform 0.2s",o.style.fontSize="10px",r.appendChild(o);let i=e.summary;if(i)for(let l of i)r.appendChild(j(l,t));let s=g("div","pf-expandable-row-detail");s.style.display="none",s.style.paddingLeft="24px",M(e,s,t);let a=!1;return r.addEventListener("click",()=>{a=!a,s.style.display=a?"block":"none",o.style.transform=a?"rotate(90deg)":""}),n.appendChild(r),n.appendChild(s),n}var tr=!1;function Xe(){if(tr)return;tr=!0;let e=new Set(ht());xn(),kn(),Rn(),Tn(),An(),Nn(),Ln(),Pn(),Dn(),On(),Fn(),Qn(),er(),gn(ht().filter((t)=>!e.has(t)))}function Ht(e){return e.replace(/[^a-zA-Z0-9_-]/g,"")}function $t(e){return e.replace(/[{}<>;]/g,"").replace(/\b(url|expression)\s*\(/gi,"")}function Pt(e,t=" "){return Object.entries(e).map(([n,r])=>`${t}--${Ht(n)}: ${$t(r)};`).join(`
|
|
6
|
+
`)}function Mo(e,t){let n=document.createElement("kbd");return n.className="pf-kbd",n.textContent=w(e.content,t),n}function Rn(){p("Card",No),p("CardHeader",yt("pf-card-header")),p("CardTitle",En("pf-card-title","h3")),p("CardDescription",En("pf-card-description","p")),p("CardContent",yt("pf-card-content")),p("CardFooter",yt("pf-card-footer"))}function No(e,t){let n=g("div","pf-card");return n.style.overflow="hidden",M(e,n,t),n}function yt(e){return(t,n)=>{let r=g("div",e);return r.style.padding="16px 24px",M(t,r,n),r}}function En(e,t){return(n,r)=>{let o=document.createElement(t);return o.className=e,o.textContent=w(n.content,r),o}}function Tn(){p("DataTable",Lo),p("Badge",Po),p("Dot",Ho),p("Metric",$o),p("Ring",Do),p("Progress",Oo),p("Separator",Io),p("Loader",jo),p("Icon",Fo),p("Sparkline",Bo)}function Lo(e,t){let n=g("div","pf-datatable-wrapper"),r=document.createElement("table");r.className="pf-datatable",r.style.width="100%",r.style.borderCollapse="collapse";let o=e.columns??[],i=K(e.rows,t),s=b(e.rowKey),a=b(e.selected),l=document.createElement("thead"),c=document.createElement("tr");for(let d of o){let m=document.createElement("th");m.className="pf-datatable-th",m.textContent=d.header??d.key,m.style.padding="8px 12px",m.style.textAlign="left",c.appendChild(m)}l.appendChild(c),r.appendChild(l);let u=document.createElement("tbody");if(Array.isArray(i)){let d=a!=null?K(a,t):void 0;for(let m of i){let h=document.createElement("tr");h.className="pf-datatable-row";let C=m,f=S(C)?C:{},y=m===null||typeof m!=="object";if(s&&d!=null&&f[s]!=null&&k(f[s])===k(d))h.classList.add("pf-datatable-row-selected");if(e.onRowClick!=null&&s)h.style.cursor="pointer",h.addEventListener("click",()=>{let x={...t.scope,$item:C,$index:i.indexOf(m)},v=V({...t,scope:x});D(H(e.onRowClick,v),"onRowClick")});for(let x of o){let v=document.createElement("td");v.className="pf-datatable-td";let R;if(x.accessor)R=K(`{{ $item.${x.accessor} }}`,{...t,scope:{...t.scope,$item:C}});else if(R=y?m:f[x.key],x.format&&R!=null)R=K(`{{ __fmtVal | ${x.format} }}`,{...t,scope:{...t.scope,__fmtVal:R}});v.textContent=k(R),v.style.padding="8px 12px",h.appendChild(v)}u.appendChild(h)}}if(r.appendChild(u),e.search===!0){let d=document.createElement("input");d.type="text",d.placeholder="Search...",d.className="pf-datatable-search",d.style.marginBottom="8px",d.style.padding="6px 12px",d.style.width="100%",d.style.boxSizing="border-box",d.addEventListener("input",()=>{let m=d.value.toLowerCase(),h=Array.from(u.querySelectorAll("tr"));for(let C of h){let f=(C.textContent??"").toLowerCase();C.style.display=f.includes(m)?"":"none"}}),n.appendChild(d)}return n.appendChild(r),n}function Po(e,t){let n=g("span","pf-badge"),r=b(e.variant)??"default";return n.setAttribute("data-variant",r),n.style.alignItems="center",n.style.padding="2px 10px",n.style.borderRadius="9999px",n.style.fontSize="12px",n.style.fontWeight="500",n.textContent=w(e.label??e.content,t),Vo(n,r),n}function Ho(e,t){let n=g("span","pf-dot"),r=b(e.color)??"gray";return n.style.display="inline-block",n.style.width="8px",n.style.height="8px",n.style.borderRadius="50%",n.style.backgroundColor=r,n}function $o(e,t){let n=g("div","pf-metric"),r=g("div","pf-metric-label");r.textContent=w(e.label,t),r.style.fontSize="14px",n.appendChild(r);let o=g("div","pf-metric-value");if(o.textContent=w(e.value,t),o.style.fontSize="28px",o.style.fontWeight="700",n.appendChild(o),e.delta!=null){let i=g("span","pf-metric-delta");i.textContent=w(e.delta,t);let s=b(e.trend)??"",a=b(e.trendSentiment)??"neutral";if(i.style.fontSize="14px",i.style.color=a==="positive"?"green":a==="negative"?"red":"inherit",s==="up")i.textContent="↑ "+i.textContent;else if(s==="down")i.textContent="↓ "+i.textContent;n.appendChild(i)}if(e.description!=null){let i=g("div","pf-metric-desc");i.textContent=w(e.description,t),i.style.fontSize="12px",n.appendChild(i)}return n}function Do(e,t){let n=g("div","pf-ring"),r=O(e.size)??80,o=O(e.thickness)??8,i=Number(K(e.value,t)??0),s=Math.max(0,Math.min(100,i)),a=(r-o)/2,l=2*Math.PI*a,c=l*(1-s/100),u=document.createElementNS("http://www.w3.org/2000/svg","svg");u.setAttribute("width",String(r)),u.setAttribute("height",String(r)),u.setAttribute("viewBox",`0 0 ${r} ${r}`);let d=document.createElementNS("http://www.w3.org/2000/svg","circle");d.setAttribute("cx",String(r/2)),d.setAttribute("cy",String(r/2)),d.setAttribute("r",String(a)),d.setAttribute("fill","none"),d.setAttribute("stroke","var(--muted, #e5e7eb)"),d.setAttribute("stroke-width",String(o));let m=document.createElementNS("http://www.w3.org/2000/svg","circle");if(m.setAttribute("cx",String(r/2)),m.setAttribute("cy",String(r/2)),m.setAttribute("r",String(a)),m.setAttribute("fill","none"),m.setAttribute("stroke","var(--primary, #3b82f6)"),m.setAttribute("stroke-width",String(o)),m.setAttribute("stroke-dasharray",String(l)),m.setAttribute("stroke-dashoffset",String(c)),m.setAttribute("stroke-linecap","round"),m.style.transform="rotate(-90deg)",m.style.transformOrigin="center",u.appendChild(d),u.appendChild(m),n.appendChild(u),e.label!=null){let h=g("div","pf-ring-label");h.textContent=w(e.label,t),h.style.textAlign="center",h.style.fontSize="12px",n.appendChild(h)}return n}function Oo(e,t){let n=g("div","pf-progress");n.setAttribute("role","progressbar");let r=Number(K(e.value,t)??0),o=O(e.max)??100,i=o>0?Math.max(0,Math.min(100,r/o*100)):0;n.setAttribute("aria-valuenow",String(r)),n.setAttribute("aria-valuemin","0"),n.setAttribute("aria-valuemax",String(o)),n.style.height="8px",n.style.borderRadius="4px",n.style.overflow="hidden";let s=g("div","pf-progress-fill");return s.style.height="100%",s.style.width=`${i}%`,s.style.borderRadius="4px",s.style.transition="width 0.3s ease",n.appendChild(s),n}function Io(e,t){let n=document.createElement("hr");return n.className="pf-separator",n.style.border="none",n.style.margin="8px 0",n}function jo(e,t){let n=g("div","pf-loader");return n.textContent="⏳",n.style.display="flex",n.style.justifyContent="center",n.style.padding="16px",n}function Fo(e,t){let n=g("span","pf-icon");return n.setAttribute("data-icon",w(e.name??e.content,t)),n}function Bo(e,t){let n=g("div","pf-sparkline"),r=Array.isArray(e.data)?e.data.filter((h)=>typeof h==="number"&&Number.isFinite(h)):[];if(r.length===0)return n;let o=O(e.width)??120,i=O(e.height)??32,s=Math.max(...r),a=Math.min(...r),l=s-a||1,c=document.createElementNS("http://www.w3.org/2000/svg","svg");c.setAttribute("width",String(o)),c.setAttribute("height",String(i)),c.setAttribute("viewBox",`0 0 ${o} ${i}`);let u=r.length>1?r.length-1:1,d=r.map((h,C)=>{let f=C/u*o,y=i-(h-a)/l*(i-4)-2;return`${f},${y}`}).join(" "),m=document.createElementNS("http://www.w3.org/2000/svg","polyline");return m.setAttribute("points",d),m.setAttribute("fill","none"),m.setAttribute("stroke","var(--primary, #3b82f6)"),m.setAttribute("stroke-width","1.5"),c.appendChild(m),n.appendChild(c),n}function Vo(e,t){let r={success:{bg:"#10b981",fg:"#fff"},warning:{bg:"#f59e0b",fg:"#fff"},info:{bg:"#3b82f6",fg:"#fff"}}[t];if(r)e.style.backgroundColor=r.bg,e.style.color=r.fg}function An(){p("Form",_o),p("Input",zo),p("Textarea",ye(Wo)),p("Button",Ko),p("ButtonGroup",Jo),p("Checkbox",Go),p("Switch",qo),p("Slider",ye(Uo)),p("Calendar",Yo),p("DatePicker",ye(Zo)),p("Field",Te("pf-field")),p("FieldTitle",Ce("pf-field-title")),p("FieldDescription",Ce("pf-field-description")),p("FieldContent",Te("pf-field-content")),p("FieldError",Ce("pf-field-error"))}function _o(e,t){let n=document.createElement("form");return n.className="pf-form",n.addEventListener("submit",(r)=>{r.preventDefault();let o=new FormData(n),i={};for(let s of new Set(o.keys())){let a=o.getAll(s),l=n.elements.namedItem(s),c=l instanceof HTMLSelectElement&&l.multiple||a.length>1;i[s]=c?a:a[0]}if(t.store.merge(i),e.onSubmit!=null){let s=V(t);s.scope={...t.scope,...i},D(H(e.onSubmit,s),"onSubmit")}}),M(e,n,t),n}function Mn(e,t,n){if(t.label==null)return;let r=document.createElement("label");if(r.className="pf-input-label",r.textContent=w(t.label,n),t.name!=null)r.htmlFor=k(t.name);r.style.fontSize="14px",r.style.fontWeight="500",e.insertBefore(r,e.firstChild)}function ye(e){return(t,n)=>{let r=e(t,n);return r.style.display="flex",r.style.flexDirection="column",r.style.gap="4px",Mn(r,t,n),r}}function se(e,t){if(t.required!==!0)return;if("required"in e)e.required=!0;e.setAttribute("aria-required","true")}function zo(e,t){let n=g("div","pf-input-wrapper");n.style.display="flex",n.style.flexDirection="column",n.style.gap="4px",Mn(n,e,t);let r=document.createElement("input");if(r.className="pf-input",r.type=b(e.inputType)??"text",e.name!=null)r.name=k(e.name);if(e.name!=null)r.id=`pf-input-${k(e.name)}`;if(e.placeholder!=null)r.placeholder=w(e.placeholder,t);if(se(r,e),e.error!=null)r.setAttribute("aria-invalid","true");let o=b(e.name);if(o){let i=t.store.get(o);if(i!=null)r.value=k(i);r.addEventListener("input",()=>{if(t.store.set(o,r.value),e.onChange!=null)D(H(e.onChange,{...V(t),scope:{...t.scope,$event:r.value}}),"onChange")})}return We(r),n.appendChild(r),n}function Wo(e,t){let n=g("div","pf-textarea-wrapper"),r=document.createElement("textarea");if(r.className="pf-textarea",e.name!=null)r.name=k(e.name);if(e.name!=null)r.id=`pf-textarea-${k(e.name)}`;if(e.placeholder!=null)r.placeholder=w(e.placeholder,t);if(e.rows!=null)r.rows=Number(e.rows);se(r,e);let o=b(e.name);if(o!=null){let i=t.store.get(o);if(i!=null)r.value=k(i);r.addEventListener("input",()=>{if(t.store.set(o,r.value),e.onChange!=null)D(H(e.onChange,{...V(t),scope:{...t.scope,$event:r.value}}),"onChange")})}return We(r),n.appendChild(r),n}function Ko(e,t){let n=document.createElement("button");n.className="pf-button",n.type=e.submit===!0?"submit":"button",n.textContent=w(e.label,t);let r=b(e.variant)??"default";if(n.setAttribute("data-variant",r),Xo(n,r),e.size!=null)n.setAttribute("data-size",k(e.size));if(e.disabled===!0)n.disabled=!0;return n}function Jo(e,t){let n=g("div","pf-button-group");return n.style.display="flex",n.style.gap="8px",M(e,n,t),n}function Go(e,t){let n=g("label","pf-checkbox-wrapper");n.style.display="flex",n.style.alignItems="center",n.style.gap="8px",n.style.cursor="pointer";let r=document.createElement("input");if(r.type="checkbox",r.className="pf-checkbox",e.name!=null)r.name=k(e.name);if(e.checked===!0)r.checked=!0;let o=b(e.name);if(o){let i=t.store.get(o);if(typeof i==="boolean")r.checked=i;r.addEventListener("change",()=>{if(t.store.set(o,r.checked),e.onChange!=null)D(H(e.onChange,{...V(t),scope:{...t.scope,$event:r.checked}}),"onChange")})}if(n.appendChild(r),e.label!=null){let i=g("span");i.textContent=w(e.label,t),n.appendChild(i)}return n}function qo(e,t){let n=g("label","pf-switch-wrapper");n.style.display="flex",n.style.alignItems="center",n.style.gap="8px",n.style.cursor="pointer";let r=document.createElement("input");if(r.type="checkbox",r.className="pf-switch",r.setAttribute("role","switch"),e.name!=null)r.name=k(e.name);let o=b(e.name);if(o){let i=t.store.get(o);if(typeof i==="boolean")r.checked=i;r.addEventListener("change",()=>{if(t.store.set(o,r.checked),e.onChange!=null)D(H(e.onChange,{...V(t),scope:{...t.scope,$event:r.checked}}),"onChange")})}if(n.appendChild(r),e.label!=null){let i=g("span");i.textContent=w(e.label,t),n.appendChild(i)}return n}function Uo(e,t){let n=g("div","pf-slider-wrapper"),r=document.createElement("input");if(r.type="range",r.className="pf-slider",e.name!=null)r.name=k(e.name);if(e.min!=null)r.min=k(e.min);if(e.max!=null)r.max=k(e.max);if(e.step!=null)r.step=k(e.step);let o=b(e.name);if(o){let i=t.store.get(o);if(i!=null)r.value=k(i);r.addEventListener("input",()=>{if(t.store.set(o,Number(r.value)),e.onChange!=null)D(H(e.onChange,{...V(t),scope:{...t.scope,$event:Number(r.value)}}),"onChange")})}return n.appendChild(r),n}function We(e){e.style.padding="8px 12px",e.style.fontSize="14px",e.style.width="100%",e.style.boxSizing="border-box"}function Xo(e,t){if(e.style.padding="8px 16px",e.style.fontSize="14px",e.style.fontWeight="500",e.style.cursor="pointer",e.style.border="none",t==="ghost")e.style.backgroundColor="transparent",e.style.color="inherit"}function Te(e){return(t,n)=>{let r=g("div",e);return M(t,r,n),r}}function Ce(e){return(t,n)=>{let r=g("span",e);return r.textContent=w(t.content,n),r}}function Ct(){let e=document.createElement("hr");return e.className="pf-separator",e.style.border="none",e.style.margin="4px 0",e}function Yo(e,t){let n=g("div","pf-calendar"),r=document.createElement("input");if(r.type="date",r.name=w(e.name,t),se(r,e),e.value!==void 0)r.value=w(e.value,t);let o=r.name,i=t.store.get(o);if(i!=null)r.value=k(i);if(e.minDate!=null)r.min=w(e.minDate,t);if(e.maxDate!=null)r.max=w(e.maxDate,t);return r.style.padding="6px 12px",r.style.borderRadius="6px",r.addEventListener("change",()=>{if(t.store.set(r.name,r.value),e.onChange!=null)D(H(e.onChange,V(t)),"onChange")}),n.appendChild(r),n}function Zo(e,t){let n=g("div","pf-datepicker"),r=document.createElement("input");if(r.type="date",r.name=w(e.name,t),se(r,e),e.placeholder!=null)r.placeholder=w(e.placeholder,t);if(e.value!==void 0)r.value=w(e.value,t);let o=r.name,i=t.store.get(o);if(i!=null)r.value=k(i);if(e.minDate!=null)r.min=w(e.minDate,t);if(e.maxDate!=null)r.max=w(e.maxDate,t);return r.style.padding="6px 12px",r.style.borderRadius="6px",r.style.width="100%",r.style.boxSizing="border-box",r.addEventListener("change",()=>{if(t.store.set(r.name,r.value),e.onChange!=null)D(H(e.onChange,V(t)),"onChange")}),n.appendChild(r),n}function Nn(){p("Select",ye(Qo)),p("SelectOption",ni),p("SelectGroup",Te("pf-select-group")),p("SelectLabel",Ce("pf-select-label")),p("SelectSeparator",Ct),p("Radio",ri),p("RadioGroup",oi),p("Combobox",ye(ii)),p("ComboboxOption",si),p("ComboboxGroup",Te("pf-combobox-group")),p("ComboboxLabel",Ce("pf-combobox-label")),p("ComboboxSeparator",Ct),p("ChoiceCard",ai)}function Qo(e,t){let n=g("div","pf-select-wrapper"),r=document.createElement("select");if(r.className="pf-select",e.name!=null)r.name=k(e.name);if(e.multiple===!0)r.multiple=!0;if(se(r,e),We(r),e.placeholder!=null){let s=document.createElement("option");s.value="",s.textContent=w(e.placeholder,t),s.disabled=!0,s.selected=!0,s.hidden=!0,r.appendChild(s)}let o=e.options;if(Array.isArray(o))for(let s of o){let a=document.createElement("option");a.value=s.value??"",a.textContent=s.label??a.value,r.appendChild(a)}if(e.children)for(let s of e.children)if(s.type==="SelectOption"){let a=document.createElement("option");a.value=b(s.value)??"",a.textContent=b(s.label)??a.value,r.appendChild(a)}else r.appendChild(j(s,t));let i=b(e.name);if(i){let s=t.store.get(i);if(s!=null)ti(r,s);r.addEventListener("change",()=>{let a=ei(r);if(t.store.set(i,a),e.onChange!=null)D(H(e.onChange,{...V(t),scope:{...t.scope,$event:a}}),"onChange")})}return n.appendChild(r),n}function ei(e){if(!e.multiple)return e.value;return Array.from(e.selectedOptions,(t)=>t.value)}function ti(e,t){if(!e.multiple){e.value=k(t);return}let n=new Set((Array.isArray(t)?t:[t]).map((r)=>k(r)));for(let r of e.options)r.selected=n.has(r.value)}function ni(e,t){return g("span")}function ri(e,t){let n=g("label","pf-radio");n.style.display="flex",n.style.alignItems="center",n.style.gap="8px",n.style.cursor="pointer";let r=document.createElement("input");if(r.type="radio",r.value=w(e.value,t),n.appendChild(r),e.label!=null){let o=g("span","pf-radio-label");o.textContent=w(e.label,t),n.appendChild(o)}return n}function oi(e,t){let n=g("fieldset","pf-radio-group");if(se(n,e),n.style.border="none",n.style.padding="0",n.style.display="flex",n.style.flexDirection="column",n.style.gap="8px",e.label!=null){let i=document.createElement("legend");i.textContent=w(e.label,t),i.style.fontWeight="500",i.style.marginBottom="4px",n.appendChild(i)}M(e,n,t);let r=w(e.name,t),o=t.store.get(r);for(let i of Array.from(n.querySelectorAll('input[type="radio"]')))if(i.name=r,o!=null&&i.value===k(o))i.checked=!0;return n.addEventListener("change",(i)=>{let s=i.target;if(s.type==="radio"){if(t.store.set(r,s.value),e.onChange!=null)D(H(e.onChange,V(t)),"onChange")}}),n}function ii(e,t){let n=g("div","pf-combobox"),r=document.createElement("input");if(r.className="pf-combobox-input",r.type="text",r.name=w(e.name,t),se(r,e),e.placeholder!=null)r.placeholder=w(e.placeholder,t);if(e.value!==void 0)r.value=w(e.value,t);let o=r.name,i=t.store.get(o);if(i!=null)r.value=k(i);r.style.padding="6px 12px",r.style.borderRadius="6px",r.style.width="100%",r.style.boxSizing="border-box";let s=g("div","pf-combobox-dropdown");if(s.style.display="none",s.style.position="absolute",s.style.borderRadius="6px",s.style.maxHeight="200px",s.style.overflowY="auto",s.style.zIndex="50",M(e,s,t),r.addEventListener("focus",()=>{s.style.display="block"}),r.addEventListener("blur",()=>{setTimeout(()=>{s.style.display="none"},150)}),e.searchable!==!1)r.addEventListener("input",()=>{let a=r.value.toLowerCase();for(let l of Array.from(s.querySelectorAll(".pf-combobox-option"))){let c=(l.textContent??"").toLowerCase();l.style.display=c.includes(a)?"":"none"}});if(e.onChange!=null)n.addEventListener("pf-combobox-select",()=>{D(H(e.onChange,{...V(t),scope:{...t.scope,$event:r.value}}),"onChange")});return n.style.position="relative",n.appendChild(r),n.appendChild(s),n}function si(e,t){let n=g("div","pf-combobox-option");return n.style.padding="6px 12px",n.style.cursor="pointer",n.textContent=w(e.label??e.value,t),n.dataset.value=w(e.value,t),n.addEventListener("mousedown",()=>{let r=n.closest(".pf-combobox"),o=r?.querySelector("input");if(o)o.value=n.dataset.value??"",t.store.set(o.name,o.value),r?.dispatchEvent(new CustomEvent("pf-combobox-select",{bubbles:!1}))}),n}function ai(e,t){let n=g("div","pf-choice-card");if(n.style.padding="16px",n.style.cursor="pointer",n.style.transition="border-color 0.2s",n.dataset.value=w(e.value,t),e.selected===!0)n.dataset.selected="true";if(e.label!=null){let r=g("div","pf-choice-card-label");r.textContent=w(e.label,t),r.style.fontWeight="600",n.appendChild(r)}if(e.description!=null){let r=g("div","pf-choice-card-description");r.textContent=w(e.description,t),r.style.fontSize="14px",n.appendChild(r)}return M(e,n,t),n}function Ln(){p("Tabs",li),p("Tab",ci),p("Accordion",di),p("AccordionItem",pi),p("Dialog",ui),p("Popover",fi),p("Tooltip",mi),p("HoverCard",gi),p("Carousel",hi)}function li(e,t){let n=g("div","pf-tabs"),r=g("div","pf-tabs-bar");r.setAttribute("role","tablist"),r.style.display="flex",r.style.gap="4px",r.style.marginBottom="12px";let o=[],i=[],s=e.children??[],a=(()=>{let c=e.defaultTab;if(typeof c==="number")return c>=0&&c<s.length?c:0;if(typeof c==="string"){let u=s.findIndex((d)=>d.title===c);return u>=0?u:0}return 0})();if(e.children)for(let c=0;c<e.children.length;c++){let u=e.children[c],d=`pf-tab-${Math.random().toString(36).slice(2,8)}`,m=`pf-panel-${Math.random().toString(36).slice(2,8)}`,h=document.createElement("button");h.type="button",h.className="pf-tab-trigger",h.textContent=b(u.title)??`Tab ${String(c+1)}`,h.setAttribute("role","tab"),h.setAttribute("aria-selected",c===a?"true":"false"),h.setAttribute("aria-controls",m),h.id=d,h.tabIndex=c===a?0:-1,h.style.padding="8px 16px",h.style.border="none",h.style.background="none",h.style.cursor="pointer",h.style.borderBottom="2px solid transparent",h.style.marginBottom="-2px",h.style.fontSize="14px";let C=g("div","pf-tab-panel");if(C.style.display=c===a?"block":"none",C.setAttribute("role","tabpanel"),C.setAttribute("aria-labelledby",d),C.id=m,C.tabIndex=0,M(u,C,t),h.addEventListener("click",()=>{l(c)}),c===a)h.classList.add("pf-tab-active"),h.style.fontWeight="600";i.push(h),o.push(C),r.appendChild(h)}function l(c){o.forEach((u)=>u.style.display="none"),i.forEach((u)=>{u.style.borderBottomColor="transparent",u.style.fontWeight="normal",u.classList.remove("pf-tab-active"),u.setAttribute("aria-selected","false"),u.tabIndex=-1}),o[c].style.display="block",i[c].classList.add("pf-tab-active"),i[c].style.fontWeight="600",i[c].setAttribute("aria-selected","true"),i[c].tabIndex=0,i[c].focus()}r.addEventListener("keydown",(c)=>{let u=i.indexOf(c.target);if(u<0)return;let d;if(c.key==="ArrowRight")d=(u+1)%i.length;else if(c.key==="ArrowLeft")d=(u-1+i.length)%i.length;else if(c.key==="Home")d=0;else if(c.key==="End")d=i.length-1;else return;c.preventDefault(),l(d)}),n.appendChild(r);for(let c of o)n.appendChild(c);return n}function ci(e,t){let n=g("div","pf-tab");return M(e,n,t),n}function di(e,t){let n=g("div","pf-accordion");return M(e,n,t),n}function pi(e,t){let n=g("div","pf-accordion-item"),r=`pf-acc-${Math.random().toString(36).slice(2,8)}`,o=document.createElement("button");o.type="button",o.className="pf-accordion-trigger",o.textContent=b(e.title)??"",o.setAttribute("aria-expanded","false"),o.setAttribute("aria-controls",r),o.style.width="100%",o.style.textAlign="left",o.style.padding="12px 0",o.style.border="none",o.style.background="none",o.style.cursor="pointer",o.style.fontSize="14px",o.style.fontWeight="500";let i=g("div","pf-accordion-content");return i.id=r,i.setAttribute("role","region"),i.setAttribute("aria-labelledby",o.id),i.style.display="none",i.style.paddingBottom="12px",M(e,i,t),o.addEventListener("click",()=>{let s=i.style.display!=="none";i.style.display=s?"none":"block",o.setAttribute("aria-expanded",s?"false":"true")}),n.appendChild(o),n.appendChild(i),n}function ui(e,t){let n=g("div","pf-dialog-wrapper");if(e.trigger!=null){let i=j(e.trigger,t);i.addEventListener("click",()=>{r.showModal()}),n.appendChild(i)}let r=document.createElement("dialog");if(r.className="pf-dialog",r.setAttribute("aria-modal","true"),r.style.maxWidth="500px",r.style.width="100%",r.style.padding="24px",e.title!=null){let i=g("h2","pf-dialog-title");i.textContent=w(e.title,t),i.id=`pf-dialog-title-${Math.random().toString(36).slice(2,8)}`,r.setAttribute("aria-labelledby",i.id),r.appendChild(i)}if(e.description!=null){let i=g("p","pf-dialog-desc");i.textContent=w(e.description,t),r.appendChild(i)}let o=g("div","pf-dialog-body");if(M(e,o,t),r.appendChild(o),e.dismissible!==!1)r.addEventListener("click",(i)=>{if(i.target===r)r.close()});return document.addEventListener("prefab:close-overlay",()=>r.close()),n.appendChild(r),n}function fi(e,t){let n=g("div","pf-popover");n.style.position="relative",n.style.display="inline-block";let r=g("div","pf-popover-content");if(r.style.display="none",r.style.position="absolute",r.style.zIndex="50",r.style.padding="12px",r.style.boxShadow="0 4px 6px -1px rgb(0 0 0 / 0.1)",e.title!=null){let i=g("div","pf-popover-title");i.textContent=w(e.title,t),i.style.fontWeight="600",i.style.marginBottom="4px",r.appendChild(i)}M(e,r,t);let o=()=>{r.style.display=r.style.display==="none"?"block":"none"};if(e.trigger!=null){let i=j(e.trigger,t);i.addEventListener("click",(s)=>{s.stopPropagation(),o()}),n.appendChild(i)}else n.addEventListener("click",(i)=>{if(r.contains(i.target)&&r.style.display!=="none")return;o()});return n.appendChild(r),n}function mi(e,t){let n=g("div","pf-tooltip");n.style.position="relative",n.style.display="inline-block";let r=`pf-tip-${Math.random().toString(36).slice(2,8)}`,o=g("div","pf-tooltip-content");return o.id=r,o.setAttribute("role","tooltip"),o.textContent=w(e.content??"",t),o.style.display="none",o.style.position="absolute",o.style.bottom="100%",o.style.left="50%",o.style.transform="translateX(-50%)",o.style.padding="4px 8px",o.style.borderRadius="4px",o.style.color="#fff",o.style.fontSize="12px",o.style.whiteSpace="nowrap",o.style.zIndex="50",M(e,n,t),n.setAttribute("aria-describedby",r),n.addEventListener("mouseenter",()=>{o.style.display="block"}),n.addEventListener("mouseleave",()=>{o.style.display="none"}),n.addEventListener("focus",()=>{o.style.display="block"},!0),n.addEventListener("blur",()=>{o.style.display="none"},!0),n.appendChild(o),n}function gi(e,t){let n=g("div","pf-hover-card");n.style.position="relative",n.style.display="inline-block";let r=g("div","pf-hover-card-content");if(r.style.display="none",r.style.position="absolute",r.style.zIndex="50",r.style.padding="16px",r.style.boxShadow="0 4px 6px -1px rgb(0 0 0 / 0.1)",r.style.minWidth="200px",e.trigger!=null)n.appendChild(j(e.trigger,t));return M(e,r,t),n.addEventListener("mouseenter",()=>{r.style.display="block"}),n.addEventListener("mouseleave",()=>{r.style.display="none"}),n.appendChild(r),n}function hi(e,t){let n=g("div","pf-carousel");n.style.position="relative",n.style.overflow="hidden",n.setAttribute("role","region"),n.setAttribute("aria-roledescription","carousel"),n.setAttribute("aria-label",w(e.label??"Carousel",t));let r=g("div","pf-carousel-track");r.style.display="flex",r.style.transition="transform 0.3s ease",M(e,r,t);let o=0,i=e.children?.length??0,s=document.createElement("button");s.type="button",s.textContent="‹",s.className="pf-carousel-prev",s.setAttribute("aria-label","Previous slide"),s.style.position="absolute",s.style.left="4px",s.style.top="50%",s.style.transform="translateY(-50%)",s.style.zIndex="10";let a=document.createElement("button");a.type="button",a.textContent="›",a.className="pf-carousel-next",a.setAttribute("aria-label","Next slide"),a.style.position="absolute",a.style.right="4px",a.style.top="50%",a.style.transform="translateY(-50%)",a.style.zIndex="10";let l=()=>{r.style.transform=`translateX(-${o*100}%)`};return s.addEventListener("click",()=>{if(i===0)return;o=Math.max(0,o-1),l()}),a.addEventListener("click",()=>{if(i===0)return;o=Math.min(i-1,o+1),l()}),n.appendChild(r),n.appendChild(s),n.appendChild(a),n}function bi(e){if(!S(e))return{};return Object.fromEntries(Object.entries(e).map(([t,n])=>[t,Array.isArray(n)?n.filter(Ee):[]]))}function Pn(){p("ForEach",yi),p("If",Hn),p("Elif",Ci),p("Else",xi),p("Condition",wi),p("Define",vi),p("Use",ki),p("Slot",Si)}function yi(e,t){let n=document.createDocumentFragment(),r=b(e.expression);if(!r)return n;let o;if(G(r)){let s=q(r,t.store,t.scope);o=Array.isArray(s)?s:[]}else{let s=t.store.get(r);o=Array.isArray(s)?s:[]}let i=I(e.let)??{};for(let s=0;s<o.length;s++){let a=o[s],l={...t.scope,$item:a,$index:s,...i},c={...t,scope:l};if(e.children)ie(e.children,n,c)}return n}function Hn(e,t){if($n(b(e.condition)??"",t)){let r=document.createDocumentFragment();if(e.children)ie(e.children,r,t);return r}return document.createDocumentFragment()}function Ci(e,t){return Hn(e,t)}function xi(e,t){let n=document.createDocumentFragment();if(e.children)ie(e.children,n,t);return n}function $n(e,t){if(!e)return!1;if(G(e))return Boolean(q(e,t.store,t.scope));return Boolean(t.store.get(e))}function wi(e,t){let n=document.createDocumentFragment(),{cases:r,else:o}=e;if(r){for(let i of r)if($n(i.when,t)){if(i.children)ie(i.children,n,t);return n}}if(o)ie(o,n,t);return n}function vi(e,t){let n=b(e.name);if(n&&e.children)t.templates=t.templates??{},t.templates[n]=e.children;return document.createDocumentFragment()}function ki(e,t){let n=document.createDocumentFragment(),r=b(e.def??e.name),o=r!=null?t.templates?.[r]:void 0;if(!o)return n;let i=I(e.overrides)??{},s={...t.scope,...i},a={...t.slots??{},...bi(e.slots)};if(Array.isArray(e.children))a.default=e.children;let l={...t,scope:s,slots:a};for(let c of o)n.appendChild(j(c,l));return n}function Si(e,t){let n=document.createDocumentFragment(),r=b(e.name)??"default",i=t.slots?.[r]??e.children;if(i)for(let s of i)n.appendChild(j(s,t));return n}function Dn(){p("Alert",Ei),p("AlertTitle",Ri),p("AlertDescription",Ti)}function Ei(e,t){let n=g("div","pf-alert");n.setAttribute("role","alert");let r=b(e.variant)??"default";if(n.setAttribute("data-variant",r),n.style.padding="12px 16px",e.icon!=null){let o=g("span","pf-alert-icon");o.setAttribute("data-icon",k(e.icon)),o.style.marginRight="8px",n.appendChild(o)}return M(e,n,t),n}function Ri(e,t){let n=g("h5","pf-alert-title");return n.textContent=w(e.content,t),n.style.fontWeight="600",n.style.marginBottom="4px",n}function Ti(e,t){let n=g("p","pf-alert-description");return n.textContent=w(e.content,t),n.style.fontSize="14px",n}function On(){p("Image",Ai),p("Audio",Mi),p("Video",Ni),p("Embed",Li),p("Svg",Hi),p("DropZone",Di),p("Mermaid",Oi)}function Ai(e,t){let n=document.createElement("img");if(n.className="pf-image",n.src=w(e.src,t),e.alt!=null)n.alt=w(e.alt,t);if(e.width!=null)n.width=Number(e.width);if(e.height!=null)n.height=Number(e.height);return n.style.maxWidth="100%",n}function Mi(e,t){let n=document.createElement("audio");return n.className="pf-audio",n.src=w(e.src,t),n.controls=!0,n}function Ni(e,t){let n=document.createElement("video");if(n.className="pf-video",n.src=w(e.src,t),n.controls=!0,e.width!=null)n.width=Number(e.width);if(e.height!=null)n.height=Number(e.height);return n.style.maxWidth="100%",n}function Li(e,t){let n=g("div","pf-embed"),r=document.createElement("iframe");return r.src=w(e.src,t),r.style.width="100%",r.style.height=e.height!=null?`${String(Number(e.height))}px`:"400px",r.style.border="none",r.setAttribute("sandbox","allow-scripts"),n.appendChild(r),n}var Pi=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 Hi(e,t){let n=g("div","pf-svg"),r=w(e.content,t);if(!r.includes("<svg"))return n;if(!/<svg[^>]*\sxmlns\s*=/.test(r))r=r.replace(/<svg\b/,'<svg xmlns="http://www.w3.org/2000/svg"');let i=new DOMParser().parseFromString(r,"image/svg+xml").querySelector("svg");if(!i)return n;return In(i),n.appendChild(document.importNode(i,!0)),n}function In(e){let t=Array.from(e.children);for(let n of t){if(!Pi.has(n.tagName.toLowerCase())){n.remove();continue}for(let r of Array.from(n.attributes)){let o=r.name.toLowerCase();if(o.startsWith("on")||o==="href"&&r.value.trim().toLowerCase().startsWith("javascript:"))n.removeAttribute(r.name)}In(n)}}function $i(e,t){let n=(t??"").split(",").map((i)=>i.trim().toLowerCase()).filter(Boolean);if(n.length===0)return!0;let r=e.name.toLowerCase(),o=e.type.toLowerCase();return n.some((i)=>{if(i.startsWith("."))return r.endsWith(i);if(i.endsWith("/*"))return o.startsWith(i.slice(0,-1));return o===i})}function Di(e,t){let n=g("div","pf-dropzone");n.style.padding="32px",n.style.textAlign="center",n.style.cursor="pointer",n.textContent=w(e.label??"Drop files here",t);let r=document.createElement("input");if(r.type="file",r.style.display="none",e.accept!=null)r.accept=k(e.accept);if(e.multiple===!0)r.multiple=!0;n.appendChild(r),n.setAttribute("role","button"),n.tabIndex=0;function o(s){let a=Array.from(s??[]).filter((l)=>$i(l,b(e.accept)));return e.multiple===!0?a:a.slice(0,1)}function i(s){if(s.length===0)return;let a=b(e.resultKey);if(a!=null)t.store.set(a,s),t.rerender();if(e.onDrop!=null)D(H(e.onDrop,{...V(t),scope:{...t.scope,$result:s}}),"onDrop")}return r.addEventListener("change",()=>{i(o(r.files)),r.value=""}),n.addEventListener("click",()=>r.click()),n.addEventListener("keydown",(s)=>{if(s.key==="Enter"||s.key===" ")s.preventDefault(),r.click()}),n.addEventListener("dragover",(s)=>{s.preventDefault(),n.classList.add("pf-dropzone-active")}),n.addEventListener("dragleave",()=>{n.classList.remove("pf-dropzone-active")}),n.addEventListener("drop",(s)=>{s.preventDefault(),n.classList.remove("pf-dropzone-active"),i(o(s.dataTransfer?.files??null))}),n}function Oi(e,t){let n=g("div","pf-mermaid");n.setAttribute("data-mermaid","true");let r=w(e.content,t);if(n.textContent=r,"mermaid"in globalThis)n.classList.add("mermaid"),n.textContent=r;return n}var Ii="https://cdn.jsdelivr.net/npm/pdfjs-dist@4.9/build/pdf.min.mjs",ji="https://cdn.jsdelivr.net/npm/pdfjs-dist@4.9/build/pdf.worker.min.mjs",xt=null,Ke=null;function Fi(e){return S(e)&&typeof e.getDocument==="function"&&S(e.GlobalWorkerOptions)}function wt(e,t){let n=typeof e==="string"&&e.trim()!==""?Number(e):e;return typeof n==="number"&&Number.isFinite(n)?n:t}function Bi(e){return e==="fit-page"||e==="fit-width"?e:wt(e,0)||"fit-width"}async function Vi(){if(xt)return xt;if(Ke)return Ke;return Ke=import(Ii).then((e)=>{if(!Fi(e))throw Error("PDF.js did not load");let t=e;return t.GlobalWorkerOptions.workerSrc=ji,xt=t,t}),Ke}function Fn(){p("PdfViewer",_i)}function _i(e,t){let n=g("div","pf-pdf-viewer"),r=e.src!=null?w(e.src,t):void 0,o=b(e.data),i=wt(e.page,1),s=Bi(e.zoom),a=e.toolbar!==!1,l=wt(e.height,600);n.style.height=`${l}px`,n.style.display="flex",n.style.flexDirection="column",n.style.overflow="hidden",n.style.border="1px solid var(--color-border-primary, #e5e7eb)",n.style.borderRadius="var(--border-radius-md, 0.375rem)",n.style.background="var(--color-background-secondary, #f9fafb)";let c=g("div","pf-pdf-loading");return c.textContent="Loading PDF…",c.style.display="flex",c.style.alignItems="center",c.style.justifyContent="center",c.style.flex="1",c.style.color="var(--color-text-secondary, #6b7280)",n.appendChild(c),zi(n,c,{src:r,data:o,initialPage:i,zoom:s,showToolbar:a}),n}async function zi(e,t,n){try{let r=await Vi(),o;if(n.src)o={url:n.src};else if(n.data){let m=atob(n.data),h=new Uint8Array(m.length);for(let C=0;C<m.length;C++)h[C]=m.charCodeAt(C);o={data:h}}else{t.textContent="Error: No PDF source provided";return}let i=await r.getDocument(o).promise;t.remove();let s=Math.max(1,Math.min(n.initialPage,i.numPages)),a=null,l=null;if(n.showToolbar){let m=Wi(i.numPages,s,{onPrev:()=>{if(s>1)s--,d()},onNext:()=>{if(s<i.numPages)s++,d()},onPageChange:(h)=>{let C=Math.max(1,Math.min(h,i.numPages));if(C!==s)s=C,d()}});a=m.pageInput,l=m.pageCount,e.insertBefore(m.el,e.firstChild)}let c=g("div","pf-pdf-canvas-container");c.style.flex="1",c.style.overflow="auto",c.style.display="flex",c.style.justifyContent="center",c.style.padding="8px",e.appendChild(c);let u=document.createElement("canvas");u.style.display="block",u.style.boxShadow="var(--shadow-md, 0 4px 6px -1px rgba(0,0,0,.1))",c.appendChild(u);async function d(){let m=await i.getPage(s),h=c.clientWidth-16,C,f=m.getViewport({scale:1});if(n.zoom==="fit-width")C=h/f.width;else if(n.zoom==="fit-page"){let v=c.clientHeight-16,R=h/f.width,T=v/f.height;C=Math.min(R,T)}else C=typeof n.zoom==="number"?n.zoom:1;let y=m.getViewport({scale:C});u.width=y.width,u.height=y.height,u.style.width=`${y.width}px`,u.style.height=`${y.height}px`;let x=u.getContext("2d");if(!x)return;if(await m.render({canvasContext:x,viewport:y}).promise,a)a.value=String(s);if(l)l.textContent=`/ ${i.numPages}`}await d()}catch(r){t.textContent=`PDF Error: ${r instanceof Error?r.message:String(r)}`,t.style.color="var(--color-text-danger, #dc2626)"}}function Wi(e,t,n){let r=g("div","pf-pdf-toolbar");r.style.display="flex",r.style.alignItems="center",r.style.gap="8px",r.style.padding="6px 12px",r.style.borderBottom="1px solid var(--color-border-primary, #e5e7eb)",r.style.background="var(--color-background-primary, #fff)",r.style.flexShrink="0",r.style.fontSize="13px";let o=document.createElement("button");o.textContent="‹",o.title="Previous page",o.className="pf-pdf-btn",jn(o),o.addEventListener("click",n.onPrev);let i=document.createElement("button");i.textContent="›",i.title="Next page",i.className="pf-pdf-btn",jn(i),i.addEventListener("click",n.onNext);let s=document.createElement("input");s.type="number",s.min="1",s.max=String(e),s.value=String(t),s.style.width="48px",s.style.textAlign="center",s.style.border="1px solid var(--color-border-primary, #e5e7eb)",s.style.borderRadius="4px",s.style.padding="2px 4px",s.style.fontSize="13px",s.addEventListener("change",()=>{let l=parseInt(s.value,10);if(!isNaN(l))n.onPageChange(l)});let a=document.createElement("span");return a.textContent=`/ ${e}`,a.style.color="var(--color-text-secondary, #6b7280)",r.appendChild(o),r.appendChild(s),r.appendChild(a),r.appendChild(i),{el:r,pageInput:s,pageCount:a}}function jn(e){e.style.border="1px solid var(--color-border-primary, #e5e7eb)",e.style.borderRadius="4px",e.style.background="var(--color-background-primary, #fff)",e.style.cursor="pointer",e.style.padding="2px 8px",e.style.fontSize="16px",e.style.lineHeight="1"}var F=["#3b82f6","#10b981","#f59e0b","#ef4444","#8b5cf6","#ec4899"],X="var(--muted-foreground, #6b7280)",ue="var(--border, #e5e7eb)",ae="10";function Je(e,t,n,r=!1){let o=n?44:0,i=e-(r?44:0),s=10,a=t-24;return{plotLeft:o,plotRight:i,plotTop:10,plotBottom:a,plotWidth:i-o,plotHeight:a-10}}function Bn(e,t=5){if(e<=0)return[0];let n=e/t,r=Math.pow(10,Math.floor(Math.log10(n))),o=n/r,i=o<=1.5?r:o<=3?2*r:o<=7?5*r:10*r,s=[];for(let a=0;a<=e+i*0.01;a+=i)s.push(Math.round(a*1000)/1000);return s}function Vn(e,t,n,r,o){let i=Bn(n);for(let s of i){let a=t.plotBottom-(n>0?s/n*t.plotHeight:0),l=z("text",{x:t.plotLeft-6,y:a+3,"text-anchor":"end","font-size":ae,fill:X});if(l.textContent=kt(s,o),e.appendChild(l),r&&s>0)e.appendChild(z("line",{x1:t.plotLeft,y1:a,x2:t.plotRight,y2:a,stroke:ue,"stroke-width":1,"stroke-dasharray":"4 3"}))}}function _n(e,t,n,r){let o=Bn(n);for(let i of o){let s=t.plotBottom-(n>0?i/n*t.plotHeight:0),a=z("text",{x:t.plotRight+6,y:s+3,"text-anchor":"start","font-size":ae,fill:X});a.textContent=kt(i,r),e.appendChild(a)}}function vt(e,t,n,r,o,i){for(let s=0;s<t.length;s++){let a=t[s][n],l=z("text",{x:r(s),y:o+14,"text-anchor":"middle","font-size":ae,fill:X});l.textContent=a==null?"":i?i(a):k(a),e.appendChild(l)}}function Ge(e,t){e.appendChild(z("line",{x1:t.plotLeft,y1:t.plotBottom,x2:t.plotRight,y2:t.plotBottom,stroke:X,"stroke-width":1}))}function le(e,t,n){if(e==null)return"";let r=K(`{{ __v | ${t} }}`,{...n,scope:{...n.scope,__v:e}});return k(r??e)}function kt(e,t){if(t==="currency")return`$${e.toLocaleString()}`;if(t==="percent")return`${e}%`;if(e>=1e6)return`${(e/1e6).toFixed(1)}M`;if(e>=1000)return`${(e/1000).toFixed(1)}K`;return String(e)}function ce(e){let t=b(e.yAxisFormat)??b(e.valueFormat);return t&&t!=="auto"?t:void 0}function St(e,t,n){return(r,o)=>{if(r===null||r===void 0)return"—";if(o.tooltipFormat)return le(r,o.tooltipFormat,e);let i=o.yAxisId==="right"?n:t;return kt(Number(r),i)}}function te(e,t,n){let r=document.createElementNS("http://www.w3.org/2000/svg","svg");if(r.setAttribute("width","100%"),r.setAttribute("height",String(t)),r.setAttribute("viewBox",`0 0 ${e} ${t}`),r.setAttribute("role","img"),n)r.setAttribute("aria-label",`${n} chart`);return r.style.overflow="visible",r}function z(e,t){let n=document.createElementNS("http://www.w3.org/2000/svg",e);for(let[r,o]of Object.entries(t))n.setAttribute(r,String(o));return n}function Ae(e,t){let n=z("text",e);return n.textContent=t,n}function fe(e,t,n,r){let o=r*Math.PI/180;return{x:e+n*Math.cos(o),y:t-n*Math.sin(o)}}function Et(e,t,n,r,o){let i=Math.max(2,Math.ceil(Math.abs(o-r)/4)),s=[];for(let a=0;a<=i;a++){let l=fe(e,t,n,r+(o-r)*a/i);s.push(`${a===0?"M":"L"} ${l.x.toFixed(2)} ${l.y.toFixed(2)}`)}return s.join(" ")}function ne(e,t,n){if(!n||t.length<=1)return;let r=g("div","pf-chart-legend");r.style.display="flex",r.style.gap="12px",r.style.fontSize="12px",r.style.marginBottom="8px";for(let o=0;o<t.length;o++){let i=g("div","pf-chart-legend-item");i.style.display="flex",i.style.alignItems="center",i.style.gap="4px";let s=g("span");s.style.width="8px",s.style.height="8px",s.style.borderRadius="50%",s.style.backgroundColor=t[o].color??F[o%F.length];let a=g("span");a.textContent=t[o].label??t[o].dataKey,i.appendChild(s),i.appendChild(a),r.appendChild(i)}e.appendChild(r)}function re(e,t){let n=document.createElement("div");return n.className="pf-chart-tooltip",e.appendChild(n),e.addEventListener("mouseleave",()=>{n.classList.remove("pf-visible")}),{wrapper:e,tooltip:n,svgEl:t}}function Rt(e,t,n,r,o){let{tooltip:i,svgEl:s,wrapper:a}=e;if(o.length===0)return;let l="";if(r)l+=`<div class="pf-chart-tooltip-label">${qe(r)}</div>`;for(let y of o)l+='<div class="pf-chart-tooltip-row">',l+=`<span class="pf-chart-tooltip-dot" style="background:${qe(y.color)}"></span>`,l+=`<span>${qe(y.label)}:</span> <strong>${qe(String(y.value))}</strong>`,l+="</div>";i.innerHTML=l;let c=s.getBoundingClientRect(),u=a.getBoundingClientRect(),d=s.viewBox.baseVal,m=c.width/(d.width||1),h=c.left-u.left+t*m,C=i.offsetWidth||100,f=h+12;if(f+C>u.width)f=h-C-12;i.style.left=`${Math.max(0,f)}px`,i.style.top="4px",i.classList.add("pf-visible")}function qe(e){return e.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""")}function xe(e,t,n,r,o,i){let s=()=>{Rt(t,n,r,o,i)},a=()=>{t.tooltip.classList.remove("pf-visible")};e.addEventListener("mouseenter",s),e.addEventListener("mouseleave",a),e.addEventListener("touchstart",s,{passive:!0}),e.addEventListener("touchend",a,{passive:!0})}function zn(e,t,n,r,o,i,s,a){let l=o.plotWidth/n.length;for(let c=0;c<n.length;c++){let u=o.plotLeft+c*l,d=document.createElementNS("http://www.w3.org/2000/svg","rect");d.setAttribute("x",String(u)),d.setAttribute("y",String(o.plotTop)),d.setAttribute("width",String(l)),d.setAttribute("height",String(o.plotHeight)),d.setAttribute("fill","transparent"),d.style.cursor="default";let m=i?n[c][i]:void 0,h=m!=null?a?a(m):k(m):void 0,C=r.map((v,R)=>({label:v.label??v.dataKey,value:s(n[c][v.dataKey],v,R),color:v.color??F[R%F.length]})),f=u+l/2,y=()=>Rt(e,f,o.plotTop,h,C),x=()=>e.tooltip.classList.remove("pf-visible");d.addEventListener("mouseenter",y),d.addEventListener("mouseleave",x),d.addEventListener("touchstart",y,{passive:!0}),d.addEventListener("touchend",x,{passive:!0}),t.appendChild(d)}}function Wn(e,t,n,r,o,i,s,a,l,c){let u=n.length===1?o.plotWidth:o.plotWidth/(n.length-1);for(let d=0;d<n.length;d++){let m=n.length===1?(o.plotLeft+o.plotRight)/2:o.plotLeft+d/(n.length-1)*o.plotWidth,h=n.length===1?o.plotLeft:m-u/2,C=n.length===1?o.plotWidth:u,f=document.createElementNS("http://www.w3.org/2000/svg","rect");f.setAttribute("x",String(Math.max(o.plotLeft,h))),f.setAttribute("y",String(o.plotTop)),f.setAttribute("width",String(Math.min(C,o.plotRight-Math.max(o.plotLeft,h)))),f.setAttribute("height",String(o.plotHeight)),f.setAttribute("fill","transparent"),f.style.cursor="default";let y=i?n[d][i]:void 0,x=y!=null?c?c(y):k(y):void 0,v=r.map((E,A)=>({label:E.label??E.dataKey,value:s(n[d][E.dataKey],E,A),color:E.color??F[A%F.length]})),R=()=>{if(Rt(e,m,o.plotTop,x,v),a)a.setAttribute("x1",String(m)),a.setAttribute("x2",String(m)),a.setAttribute("opacity","1");if(l)for(let E of l){for(let A of E)A.setAttribute("data-visible","false");E[d]?.setAttribute("data-visible","true")}},T=()=>{if(e.tooltip.classList.remove("pf-visible"),a)a.setAttribute("opacity","0");if(l)for(let E of l)for(let A of E)A.setAttribute("data-visible","false")};f.addEventListener("mouseenter",R),f.addEventListener("mouseleave",T),f.addEventListener("touchstart",R,{passive:!0}),f.addEventListener("touchend",T,{passive:!0}),t.appendChild(f)}}function me(e,t){return ve(K(e.data,t))}function Kn(e,t){let n=K(e.data,t);if(!Array.isArray(n))return;let r=n.filter((o)=>typeof o==="number"&&Number.isFinite(o));return r.length>0?r:void 0}function Ki(e){return e==="left"||e==="right"?e:void 0}function Ji(e){if(!S(e)||typeof e.dataKey!=="string")return;let t=b(e.label),n=b(e.color),r=Ki(e.yAxisId),o=b(e.tooltipFormat);return{dataKey:e.dataKey,...t!==void 0&&{label:t},...n!==void 0&&{color:n},...r!==void 0&&{yAxisId:r},...o!==void 0&&{tooltipFormat:o}}}function ge(e){if(!Array.isArray(e.series))return[];return e.series.flatMap((t)=>{let n=Ji(t);return n?[n]:[]})}function de(e,t){return O(e.height)??t}function Me(e,t){return Math.max(...e.flatMap((n)=>t.map((r)=>Number(n[r.dataKey]??0))),1)}function Tt(e,t){return{valueKey:b(e.dataKey)??t[0]?.dataKey,nameKey:b(e.nameKey)??b(e.tooltipXKey)??b(e.xAxis)}}function At(e,t){return{rows:me(e,t),series:ge(e),height:de(e,300),showYAxis:e.showYAxis!==!1,showGrid:e.showGrid===!0,showYAxisRight:e.showYAxisRight===!0,showTooltip:e.showTooltip!==!1,showLegend:e.showLegend!==!1,xAxisKey:b(e.xAxis),tooltipXKey:b(e.tooltipXKey),xAxisFormat:b(e.xAxisFormat),tooltipXFormat:b(e.tooltipXFormat),yAxisRightFormat:b(e.yAxisRightFormat)}}function Jn(e,t,n){let r=t.series.filter((d)=>d.yAxisId!=="right"),o=t.series.filter((d)=>d.yAxisId==="right"),i=t.showYAxisRight&&o.length>0,s=r.length>0?Me(t.rows,r):1,a=i?Me(t.rows,o):1,l=400,c=Je(400,t.height,t.showYAxis,i),u=te(400,t.height,n);if(t.showYAxis)Vn(u,c,s,t.showGrid,ce(e));if(i)_n(u,c,a,t.yAxisRightFormat);return Ge(u,c),{layout:c,svg:u,leftMax:s,rightMax:a}}function Ue(e,t){return e?(n)=>le(n,e,t):void 0}function Gn(e,t){let n=g("div","pf-chart pf-bar-chart"),r=At(e,t),{rows:o,series:i}=r;if(o.length===0||i.length===0)return n.textContent="No chart data",n;let{layout:s,svg:a,leftMax:l,rightMax:c}=Jn(e,r,"Bar"),u=s.plotWidth/o.length,d=u/(i.length+1);for(let m=0;m<o.length;m++)for(let h=0;h<i.length;h++){let C=i[h],f=o[m][C.dataKey];if(f===null||f===void 0)continue;let y=C.yAxisId==="right"?c:l,x=Math.max(0,Number(f)/y*s.plotHeight),v=s.plotLeft+m*u+h*d+d/2,R=document.createElementNS("http://www.w3.org/2000/svg","rect");R.setAttribute("x",String(v)),R.setAttribute("y",String(s.plotBottom-x)),R.setAttribute("width",String(d*0.8)),R.setAttribute("height",String(x)),R.setAttribute("fill",C.color??F[h%F.length]),R.setAttribute("rx","2"),a.appendChild(R)}if(r.xAxisKey)vt(a,o,r.xAxisKey,(m)=>s.plotLeft+m*u+u/2,s.plotBottom,Ue(r.xAxisFormat,t));if(r.showTooltip){let m=re(n,a),h=St(t,ce(e),r.yAxisRightFormat);zn(m,a,o,i,s,r.tooltipXKey??r.xAxisKey,h,Ue(r.tooltipXFormat,t))}return ne(n,i,r.showLegend),n.appendChild(a),n}function Gi(e,t,n,r){let o=[],i=()=>{if(o.length<2){o=[];return}let s=`M ${o[0].x},${n} `+o.map((l)=>`L ${l.x},${l.y}`).join(" ")+` L ${o[o.length-1].x},${n} Z`,a=document.createElementNS("http://www.w3.org/2000/svg","path");a.setAttribute("d",s),a.setAttribute("fill",r),a.setAttribute("opacity","0.15"),e.appendChild(a),o=[]};for(let s of t){if(s.isNull){i();continue}o.push(s)}i()}function qi(e,t,n,r){let o="";for(let s of t){if(s.isNull)continue;let a=t.indexOf(s),l=a===0||t[a-1].isNull;o+=`${l?"M":"L"} ${s.x},${s.y} `}if(!o)return;let i=document.createElementNS("http://www.w3.org/2000/svg","path");if(i.setAttribute("d",o.trim()),i.setAttribute("fill","none"),i.setAttribute("stroke",n),i.setAttribute("stroke-width","2"),r)i.setAttribute("stroke-dasharray","6 3");e.appendChild(i)}function Ui(e,t,n){let r=[];for(let o of t){let i=document.createElementNS("http://www.w3.org/2000/svg","circle");if(i.setAttribute("cx",String(o.x)),i.setAttribute("cy",String(o.y)),i.setAttribute("r","4"),i.setAttribute("fill",n),i.setAttribute("class","pf-data-dot"),i.setAttribute("data-visible","false"),i.style.pointerEvents="none",o.isNull)i.style.display="none";e.appendChild(i),r.push(i)}return r}function Xi(e,t){let n=document.createElementNS("http://www.w3.org/2000/svg","line");return n.setAttribute("class","pf-crosshair"),n.setAttribute("x1",String(t.plotLeft)),n.setAttribute("x2",String(t.plotLeft)),n.setAttribute("y1",String(t.plotTop)),n.setAttribute("y2",String(t.plotBottom)),n.setAttribute("stroke",X),n.setAttribute("stroke-width","1"),n.setAttribute("stroke-dasharray","3 3"),n.setAttribute("opacity","0"),e.appendChild(n),n}function Mt(e,t){let n=g("div",`pf-chart pf-${e.type.toLowerCase()}-chart`),r=At(e,t),{rows:o,series:i}=r;if(o.length===0||i.length===0)return n.textContent="No chart data",n;let s=e.type==="AreaChart",{layout:a,svg:l,leftMax:c,rightMax:u}=Jn(e,r,s?"Area":"Line"),d=(C)=>o.length===1?(a.plotLeft+a.plotRight)/2:a.plotLeft+C/(o.length-1)*a.plotWidth,m=[];for(let C=0;C<i.length;C++){let f=i[C],y=f.yAxisId==="right",x=y?u:c,v=f.color??F[C%F.length],R=o.map((T,E)=>{let A=T[f.dataKey],B=A===null||A===void 0,P=B?a.plotBottom:a.plotBottom-Number(A)/x*a.plotHeight;return{x:d(E),y:P,isNull:B}});if(s)Gi(l,R,a.plotBottom,v);qi(l,R,v,y),m.push(Ui(l,R,v))}let h=Xi(l,a);if(r.xAxisKey)vt(l,o,r.xAxisKey,d,a.plotBottom,Ue(r.xAxisFormat,t));if(r.showTooltip){let C=re(n,l),f=St(t,ce(e),r.yAxisRightFormat);Wn(C,l,o,i,a,r.tooltipXKey??r.xAxisKey,f,h,m,Ue(r.tooltipXFormat,t))}return ne(n,i,r.showLegend),n.appendChild(l),n}function Nt(e,t){let n=ce(e);return(r)=>n?le(r,n,t):String(r)}function qn(e,t){let n=g("div","pf-chart pf-pie-chart"),r=me(e,t),o=ge(e),i=Math.min(de(e,300),300),s=e.showTooltip!==!1,{valueKey:a,nameKey:l}=Tt(e,o),c=o.length>0?o:a?[{dataKey:a,label:a}]:[];if(r.length===0||!a)return n.textContent="No chart data",n;let u=te(i,i,"Pie"),d=i/2,m=i/2,h=i/2-10,C=b(e.tooltipXFormat),f=Nt(e,t),y=r.map((T)=>Number(T[a]??0)),x=y.reduce((T,E)=>T+E,0);if(x===0)return n.textContent="No chart data",n.appendChild(u),n;let v=s?re(n,u):void 0,R=-Math.PI/2;for(let T=0;T<y.length;T++){let E=y[T]/x*2*Math.PI,A=R+E,B=E>Math.PI?1:0,P=d+h*Math.cos(R),_=m+h*Math.sin(R),Y=d+h*Math.cos(A),Z=m+h*Math.sin(A),Q=F[T%F.length],U=document.createElementNS("http://www.w3.org/2000/svg","path");if(U.setAttribute("d",`M ${d},${m} L ${P},${_} A ${h},${h} 0 ${B} 1 ${Y},${Z} Z`),U.setAttribute("fill",Q),U.style.cursor="default",v){let L=l?r[T][l]:void 0,pe=L!=null?C?le(L,C,t):k(L):`Slice ${T+1}`,oe=`${(y[T]/x*100).toFixed(1)}%`,rt=d+h*0.6*Math.cos(R+E/2);xe(U,v,rt,m,pe,[{label:c[0].label??a,value:`${f(y[T])} (${oe})`,color:Q}])}u.appendChild(U),R=A}return ne(n,c,e.showLegend!==!1),n.appendChild(u),n}function Un(e,t){let n=g("div","pf-chart pf-radial-chart"),r=me(e,t),o=ge(e),{valueKey:i,nameKey:s}=Tt(e,o);if(r.length===0||!i)return n.textContent="No chart data",n;let a=Math.min(de(e,300),300),l=a/2,c=a/2,u=a/2-10,d=Math.max(0,Math.min(O(e.innerRadius)??30,u-10)),m=O(e.startAngle)??180,h=O(e.endAngle)??0,C=r.map((A)=>Number(A[i]??0)),f=Math.max(...C,1),y=te(a,a,"Radial"),x=(u-d)/r.length,v=Math.max(2,x*0.7),R=Nt(e,t),T=e.showTooltip!==!1?re(n,y):void 0,E=[];for(let A=0;A<r.length;A++){let B=u-x*A-x/2,P=o[A]?.color??F[A%F.length],_=m+C[A]/f*(h-m),Y=s?r[A][s]:null,Z=Y!=null?k(Y):o[A]?.label??i;E.push({dataKey:Z||i,label:Z||i,color:P}),y.appendChild(z("path",{d:Et(l,c,B,m,h),fill:"none",stroke:ue,"stroke-width":v,"stroke-linecap":"round"}));let Q=z("path",{d:Et(l,c,B,m,_),fill:"none",stroke:P,"stroke-width":v,"stroke-linecap":"round"});if(T){let U=fe(l,c,B,(m+_)/2);xe(Q,T,U.x,U.y,Z||i,[{label:i,value:R(C[A]),color:P}])}y.appendChild(Q)}return ne(n,E,e.showLegend!==!1),n.appendChild(y),n}function Xn(e,t){let n=g("div","pf-chart pf-radar-chart"),r=me(e,t),o=ge(e),i=b(e.axisKey)??b(e.xAxis);if(r.length===0||o.length===0)return n.textContent="No chart data",n;let s=e.filled!==!1,a=e.showDots===!0,l=e.showGrid!==!1,c=Math.min(de(e,300),320),u=c/2,d=c/2,m=c/2-24,h=r.length,C=Me(r,o),f=(T)=>90-360*T/h,y=(T)=>T.map((E)=>`${E.x.toFixed(1)},${E.y.toFixed(1)}`).join(" "),x=te(c,c,"Radar");if(l){for(let E=1;E<=4;E++){let A=m*E/4,B=Array.from({length:h},(P,_)=>fe(u,d,A,f(_)));x.appendChild(z("polygon",{points:y(B),fill:"none",stroke:ue,"stroke-width":1}))}for(let E=0;E<h;E++){let A=fe(u,d,m,f(E));x.appendChild(z("line",{x1:u,y1:d,x2:A.x,y2:A.y,stroke:ue,"stroke-width":1}))}}for(let T=0;T<h;T++){let E=fe(u,d,m+12,f(T)),A=i?r[T][i]:null;x.appendChild(Ae({x:E.x,y:E.y+3,"text-anchor":"middle","font-size":ae,fill:X},k(A)))}let v=e.showTooltip!==!1?re(n,x):void 0,R=Nt(e,t);for(let T=0;T<o.length;T++){let E=o[T],A=E.color??F[T%F.length],B=r.map((P,_)=>fe(u,d,Number(P[E.dataKey]??0)/C*m,f(_)));if(x.appendChild(z("polygon",{points:y(B),fill:s?A:"none","fill-opacity":s?0.2:0,stroke:A,"stroke-width":2})),!a&&!v)continue;for(let P=0;P<B.length;P++){let _=z("circle",{cx:B[P].x,cy:B[P].y,r:a?3:6,fill:a?A:"transparent","fill-opacity":a?1:0});if(v){let Y=i?r[P][i]:null,Z=Y!=null?k(Y):E.label??E.dataKey,Q=[{label:E.label??E.dataKey,value:R(Number(r[P][E.dataKey]??0)),color:A}];xe(_,v,B[P].x,B[P].y,Z,Q)}x.appendChild(_)}}return ne(n,o,e.showLegend!==!1),n.appendChild(x),n}function Yn(e,t){let n=g("div","pf-chart pf-scatter-chart"),r=me(e,t),o=b(e.xAxis),i=b(e.yAxis),s=b(e.zAxis),a=ge(e),l=de(e,300);if(r.length===0||!o||!i)return n.textContent="No chart data",n;let c=e.showGrid!==!1,u=a[0]?.color??F[0],d=ce(e),m=(L)=>d?le(L,d,t):String(Math.round(L*100)/100),h=r.map((L)=>Number(L[o]??0)),C=r.map((L)=>Number(L[i]??0)),f=Math.min(...h),y=Math.max(...h),x=Math.min(...C),v=Math.max(...C),R=y-f||1,T=v-x||1,E=s?r.map((L)=>Number(L[s]??0)):[],A=s?Math.max(...E,1):1,B=400,P=Je(B,l,!0),_=te(B,l,"Scatter"),Y=(L)=>P.plotLeft+(L-f)/R*P.plotWidth,Z=(L)=>P.plotBottom-(L-x)/T*P.plotHeight,Q=4;for(let L=0;L<=Q;L++){let pe=x+T*L/Q,oe=Z(pe);if(_.appendChild(Ae({x:P.plotLeft-6,y:oe+3,"text-anchor":"end","font-size":ae,fill:X},m(pe))),c&&L>0)_.appendChild(z("line",{x1:P.plotLeft,y1:oe,x2:P.plotRight,y2:oe,stroke:ue,"stroke-width":1,"stroke-dasharray":"4 3"}))}Ge(_,P);for(let L of[f,(f+y)/2,y])_.appendChild(Ae({x:Y(L),y:P.plotBottom+14,"text-anchor":"middle","font-size":ae,fill:X},String(Math.round(L*100)/100)));let U=e.showTooltip!==!1?re(n,_):void 0;for(let L=0;L<r.length;L++){let pe=Y(h[L]),oe=Z(C[L]),rt=s?4+Math.sqrt(E[L]/A)*14:4,Jt=z("circle",{cx:pe,cy:oe,r:rt,fill:u,"fill-opacity":s?0.6:0.85});if(U){let vr=[{label:o,value:m(h[L]),color:u},{label:i,value:m(C[L]),color:u},...s?[{label:s,value:m(E[L]),color:u}]:[]],kr=a[0]?.label??"Point";xe(Jt,U,pe,oe,kr,vr)}_.appendChild(Jt)}return ne(n,a,e.showLegend!==!1),n.appendChild(_),n}function Zn(e,t){let n=g("div","pf-chart pf-histogram"),r=Kn(e,t);if(!r)return n.textContent="No data",n;let o=O(e.bins)??10,i=de(e,200),s=b(e.color)??F[0],a=Math.min(...r),c=(Math.max(...r)-a)/o||1,u=Array(o).fill(0);for(let f of r){let y=Math.min(Math.floor((f-a)/c),o-1);u[y]++}let d=Math.max(...u),m=300,h=m/o,C=te(m,i,"Histogram");for(let f=0;f<o;f++){let y=d>0?u[f]/d*i:0,x=document.createElementNS("http://www.w3.org/2000/svg","rect");x.setAttribute("x",String(f*h)),x.setAttribute("y",String(i-y)),x.setAttribute("width",String(h-1)),x.setAttribute("height",String(y)),x.setAttribute("fill",s),C.appendChild(x)}return n.appendChild(C),n}function Qn(){p("BarChart",Gn),p("LineChart",Mt),p("AreaChart",Mt),p("PieChart",qn),p("RadarChart",Xn),p("ScatterChart",Yn),p("RadialChart",Un),p("Histogram",Zn)}function er(){p("Table",Yi),p("TableHead",Lt("thead")),p("TableBody",Lt("tbody")),p("TableFooter",Lt("tfoot")),p("TableRow",Zi),p("TableHeader",Qi),p("TableCell",es),p("TableCaption",ts),p("ExpandableRow",ns)}function Yi(e,t){let n=document.createElement("table");return n.className=e.striped===!0?"pf-table pf-table-striped":"pf-table",n.style.width="100%",n.style.borderCollapse="collapse",M(e,n,t),n}function Lt(e){return(t,n)=>{let r=document.createElement(e);return r.className=`pf-${e}`,M(t,r,n),r}}function Zi(e,t){let n=document.createElement("tr");return n.className="pf-table-row",M(e,n,t),n}function Qi(e,t){let n=document.createElement("th");return n.className="pf-table-header",n.style.textAlign="left",n.style.padding="8px 12px",n.style.fontWeight="600",n.textContent=w(e.content,t),n}function es(e,t){let n=document.createElement("td");if(n.className="pf-table-cell",n.style.padding="8px 12px",e.colSpan!=null)n.colSpan=Number(e.colSpan);if(e.rowSpan!=null)n.rowSpan=Number(e.rowSpan);return M(e,n,t),n}function ts(e,t){let n=document.createElement("caption");return n.className="pf-table-caption",n.style.padding="8px",n.style.fontSize="14px",n.textContent=w(e.content,t),n}function ns(e,t){let n=g("div","pf-expandable-row"),r=g("div","pf-expandable-row-summary");r.style.cursor="pointer",r.style.display="flex",r.style.alignItems="center",r.style.gap="8px";let o=g("span","pf-expandable-arrow");o.textContent="▶",o.style.transition="transform 0.2s",o.style.fontSize="10px",r.appendChild(o);let i=e.summary;if(i)for(let l of i)r.appendChild(j(l,t));let s=g("div","pf-expandable-row-detail");s.style.display="none",s.style.paddingLeft="24px",M(e,s,t);let a=!1;return r.addEventListener("click",()=>{a=!a,s.style.display=a?"block":"none",o.style.transform=a?"rotate(90deg)":""}),n.appendChild(r),n.appendChild(s),n}var tr=!1;function Xe(){if(tr)return;tr=!0;let e=new Set(ht());xn(),kn(),Rn(),Tn(),An(),Nn(),Ln(),Pn(),Dn(),On(),Fn(),Qn(),er(),gn(ht().filter((t)=>!e.has(t)))}function Ht(e){return e.replace(/[^a-zA-Z0-9_-]/g,"")}function $t(e){return e.replace(/[{}<>;]/g,"").replace(/\b(url|expression)\s*\(/gi,"")}function Pt(e,t=" "){return Object.entries(e).map(([n,r])=>`${t}--${Ht(n)}: ${$t(r)};`).join(`
|
|
7
7
|
`)}function nr(e){if(!e)return"";let t=[];if(e.light&&Object.keys(e.light).length>0)t.push(`:root {
|
|
8
8
|
${Pt(e.light)}
|
|
9
9
|
}`);if(e.dark&&Object.keys(e.dark).length>0){let n=Pt(e.dark);t.push(`.dark, [data-theme="dark"] {
|
|
@@ -13,4 +13,4 @@ ${n}
|
|
|
13
13
|
${Pt(e.dark," ")}
|
|
14
14
|
}
|
|
15
15
|
}`)}return t.join(`
|
|
16
|
-
`)}function we(e,t){e.setAttribute("data-theme",t),e.classList.toggle("dark",t==="dark"),e.classList.toggle("light",t==="light")}function Dt(e,t){if(!t)return;if(t.light)for(let[n,r]of Object.entries(t.light))e.style.setProperty(`--${Ht(n)}`,$t(r));if(t.dark){let r=document.getElementById("prefab-dark-theme");if(!r)r=document.createElement("style"),r.id="prefab-dark-theme",document.head.appendChild(r);r.textContent=nr({dark:t.dark})}}function Ot(e,t){if(!e||typeof document>"u")return;let n=(r)=>{for(let[o,i]of Object.entries(e))if(rs(o,r))r.preventDefault(),t(i)};return document.addEventListener("keydown",n),()=>document.removeEventListener("keydown",n)}function rs(e,t){let n=e.toLowerCase().split("+").map((i)=>i.trim()),r=n[n.length-1],o=new Set(n.slice(0,-1));if(o.has("ctrl")!==(t.ctrlKey||t.metaKey))return!1;if(o.has("shift")!==t.shiftKey)return!1;if(o.has("alt")!==t.altKey)return!1;return t.key.toLowerCase()===r}var rr='<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>',or='<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>',ir={"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 os(e,t){try{let r=localStorage.getItem(t);if(r==="light"||r==="dark")return r}catch{}let n=e.getAttribute("data-theme")??document.documentElement.getAttribute("data-theme");if(n==="light"||n==="dark")return n;if(typeof window<"u"&&window.matchMedia("(prefers-color-scheme: light)").matches)return"light";return"dark"}function It(e,t){if(typeof document>"u")return()=>{};let n=t?.position??"top-right",r=t?.storageKey??"prefab-theme",o=t?.syncDocument??!0,i=getComputedStyle(e).position;if(i==="static"||i==="")e.style.position="relative";let s=document.createElement("button");s.className="pf-theme-toggle",s.setAttribute("aria-label","Toggle theme"),s.setAttribute("title","Toggle light/dark"),Object.assign(s.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 a=ir[n]??ir["top-right"];for(let d of a.split(";")){let[m,h]=d.split(":").map((C)=>C.trim());if(m&&h)s.style.setProperty(m,h)}s.addEventListener("mouseenter",()=>{s.style.opacity="1"}),s.addEventListener("mouseleave",()=>{s.style.opacity="0.7"});function l(d){if(we(e,d),o)we(document.documentElement,d);s.innerHTML=d==="dark"?or:rr;try{localStorage.setItem(r,d)}catch{}}let c=os(e,r);l(c),s.addEventListener("click",()=>{let d=e.getAttribute("data-theme")??"dark";l(d==="dark"?"light":"dark")}),e.appendChild(s);let u;if(o)u=new MutationObserver((d)=>{for(let m of d)if(m.type==="attributes"&&m.attributeName==="data-theme"){let h=document.documentElement.getAttribute("data-theme");if((h==="light"||h==="dark")&&h!==e.getAttribute("data-theme")){we(e,h),s.innerHTML=h==="dark"?or:rr;try{localStorage.setItem(r,h)}catch{}}}}),u.observe(document.documentElement,{attributes:!0,attributeFilter:["data-theme"]});return()=>{u?.disconnect(),s.remove()}}function Ye(e){let t=e?.baseUrl??(typeof window<"u"?window.location.origin:""),n={"Content-Type":"application/json",...e?.headers},r=e?.fetch??globalThis.fetch.bind(globalThis);return{async callTool(o,i){let s=await r(`${t}/mcp/tools/call`,{method:"POST",headers:n,body:JSON.stringify({jsonrpc:"2.0",method:"tools/call",params:{name:o,arguments:i}})});if(!s.ok)throw Error(`MCP tool call failed: ${s.status} ${s.statusText}`);let a=await s.json();if(a.error)throw Error(a.error.message??"MCP tool call returned error");let l=a.result?.content??a.content??[];for(let c of l)if(c.type==="text"&&c.text!==void 0){try{let u=JSON.parse(c.text);if(typeof u==="object"&&u!==null&&"$prefab"in u)return u;return u}catch{}return c.text}return a.result??a},async sendMessage(o){await r(`${t}/mcp/messages`,{method:"POST",headers:n,body:JSON.stringify({message:o})})}}}function Ze(){return{callTool(e){return N.warn(`No MCP transport: callTool('${e}') ignored`),Promise.resolve(null)},sendMessage(e){return N.warn("No MCP transport: sendMessage ignored",e),Promise.resolve()}}}var sr="0.3.19";var is=["light","dark","auto"],ss=["inline","fullscreen","pip"];function ar(e){return S(e)&&typeof e.type==="string"&&(e.id===void 0||typeof e.id==="string")&&(e.payload===void 0||S(e.payload))}function Qe(e){return typeof e==="boolean"?e:void 0}function lr(e){let t=I(e.capabilities)??{},n=I(e.theme),r=I(e.toolInput),o=I(e.meta);return{hostName:b(e.hostName),hostVersion:b(e.hostVersion),capabilities:{toast:Qe(t.toast),clipboard:Qe(t.clipboard),navigation:Qe(t.navigation),messaging:Qe(t.messaging),displayModes:jt(t.displayModes)},...n&&{theme:as(n)},...r&&{toolInput:r},...o&&{meta:o}}}function as(e){let t=b(e.fontCss);return{...et({theme:e.colorScheme,styles:{variables:e.variables}}),...t!=null&&{fontCss:t}}}function jt(e){let t=Array.isArray(e)?e:[];return ss.filter((n)=>t.includes(n))}function et(e){let t={},n=is.find((s)=>s===e.theme);if(n)t.colorScheme=n;let r=I(e.styles),o=I(r?.variables);if(o)t.variables=Object.fromEntries(Object.entries(o).filter((s)=>typeof s[1]==="string"));let i=b(I(r?.css)?.fonts);if(i!=null)t.fontCss=i;return t}function ls(e){return S(e)&&e.jsonrpc==="2.0"}class Ne{hostOrigin;listeners=new Map;protocol="prefab";cleanup;pending=new Map;callIdCounter=0;rpcPending=new Map;rpcIdCounter=0;sentRpcIds=new Set;postFn;_hostSupportsSubscriptions=!1;constructor(e="*"){this.hostOrigin=e}connect(){if(typeof window>"u")return;let e=ds();if(e)this.postFn=(n)=>e.postMessage(n);let t=(n)=>{if(this.hostOrigin!=="*"&&n.origin!==this.hostOrigin)return;let r=n.data;if(ls(r)){this.handleJsonRpc(r);return}if(!ar(r)||!r.type.startsWith("prefab:"))return;let o=r;if(o.type==="prefab:tool-call-response"&&o.id){let s=this.pending.get(o.id);if(s){if(this.pending.delete(o.id),o.payload?.error!=null)s.reject(Error(k(o.payload.error)));else s.resolve(o.payload?.result);return}}let i=this.listeners.get(o.type);if(i)for(let s of i)s(o.payload??{})};window.addEventListener("message",t),this.cleanup=()=>window.removeEventListener("message",t)}async initialize(e){try{return await Promise.any([this.initPrefab(e),this.initJsonRpc(e)])}catch(t){let n=t instanceof AggregateError?t.errors.map((r)=>r.message).join("; "):String(t);throw Error(`Bridge init failed — no host responded. Tried: ${n}`,{cause:t})}}createTransport(){if(this.protocol==="jsonrpc")return this.createJsonRpcTransport();return this.createPrefabTransport()}requestMode(e){if(this.protocol==="jsonrpc")this.sendRpcRequest("ui/request-display-mode",{mode:e});else this.sendPrefab("prefab:request-mode",{mode:e})}openLink(e,t){if(this.protocol==="jsonrpc")this.sendRpcRequest("ui/open-link",{url:e,target:t});else this.sendPrefab("prefab:open-link",{url:e,target:t})}updateContext(e){if(this.protocol==="jsonrpc")this.sendRpcRequest("ui/update-model-context",{structuredContent:e});else this.sendPrefab("prefab:update-context",{context:e})}setupAutoResize(e){if(typeof ResizeObserver>"u")return cr;let t=-1,n=-1,r=(s,a)=>{if(s===t&&a===n)return;if(t=s,n=a,this.protocol==="jsonrpc")this.sendRpcNotification("ui/notifications/size-changed",{width:s,height:a});else this.sendPrefab("prefab:size-changed",{width:s,height:a})},o=new ResizeObserver((s)=>{for(let a of s)if(a.borderBoxSize.length){let l=a.borderBoxSize[0];r(Math.ceil(l.inlineSize),Math.ceil(l.blockSize))}else{let l=a.target.getBoundingClientRect();r(Math.ceil(l.width),Math.ceil(l.height))}});o.observe(e);let i=e.getBoundingClientRect();return r(Math.ceil(i.width),Math.ceil(i.height)),()=>o.disconnect()}notifyPreferredSize(e){if(this.protocol==="jsonrpc")this.sendRpcNotification("ui/notifications/preferred-size",e);else this.sendPrefab("prefab:preferred-size",e)}subscribe(e,t,n){let r=(o)=>{if(o.uri!==e)return;t(o.contents??o.data??o)};if(this.protocol==="jsonrpc")this.on("prefab:resource-updated",r),this.sendRpcRequest("resources/subscribe",{uri:e}).catch((o)=>{this.off("prefab:resource-updated",r),n?.(o)});else this.on("prefab:resource-updated",r),this.sendPrefab("prefab:subscribe",{uri:e});return()=>{if(this.off("prefab:resource-updated",r),this.protocol==="jsonrpc")this.sendRpcRequest("resources/unsubscribe",{uri:e}).catch(cr);else this.sendPrefab("prefab:unsubscribe",{uri:e})}}get supportsSubscriptions(){return this._hostSupportsSubscriptions}on(e,t){if(!this.listeners.has(e))this.listeners.set(e,new Set);let n=this.listeners.get(e);if(n)n.add(t)}off(e,t){this.listeners.get(e)?.delete(t)}disconnect(){this.cleanup?.(),this.listeners.clear();for(let[,e]of this.pending)e.reject(Error("Bridge disconnected"));this.pending.clear();for(let[,e]of this.rpcPending)e.reject(Error("Bridge disconnected"));this.rpcPending.clear(),this.sentRpcIds.clear()}get activeProtocol(){return this.protocol}initPrefab(e){return new Promise((t,n)=>{let r=!1,o=(i)=>{if(r)return;r=!0,this.off("prefab:init-response",o),this.protocol="prefab",this._hostSupportsSubscriptions=I(i.capabilities)?.subscriptions===!0,t(lr(i))};this.on("prefab:init-response",o),this.sendPrefab("prefab:init",{capabilities:e}),setTimeout(()=>{if(!r)r=!0,this.off("prefab:init-response",o),n(Error("prefab:init timeout"))},2000)})}createPrefabTransport(){return{callTool:(e,t)=>{let n=`tc-${++this.callIdCounter}`;return new Promise((r,o)=>{this.pending.set(n,{resolve:r,reject:o}),this.sendPrefab("prefab:tool-call",{tool:e,arguments:t},n),setTimeout(()=>{if(this.pending.has(n))this.pending.delete(n),o(Error(`Tool call '${e}' timed out`))},30000)})},sendMessage:(e)=>(this.sendPrefab("prefab:send-message",{message:e}),Promise.resolve()),updateModelContext:(e)=>(this.sendPrefab("prefab:update-context",{context:e.structuredContent,content:e.content}),Promise.resolve()),subscribe:(e,t,n)=>this.subscribe(e,t,n),capabilities:{subscriptions:this._hostSupportsSubscriptions}}}sendPrefab(e,t,n){if(typeof window>"u")return;let r=window.parent!==window?window.parent:window,o={type:e,payload:t,id:n};r.postMessage(o,this.hostOrigin)}handleJsonRpc(e){if(!("method"in e)){let r=this.rpcPending.get(e.id);if(r)if(this.rpcPending.delete(e.id),e.error)r.reject(Error(e.error.message));else r.resolve(e.result);return}let t=e.method,n=e.params??{};if(e.id!=null&&this.sentRpcIds.delete(e.id))return;if(e.id!=null)this.postJsonRpc({jsonrpc:"2.0",id:e.id,result:{}});switch(t){case"ui/notifications/tool-input":this.dispatch("prefab:tool-input",{args:n.arguments??n});break;case"ui/notifications/tool-input-partial":this.dispatch("prefab:tool-input-partial",{args:n.arguments??n});break;case"ui/notifications/tool-result":this.dispatch("prefab:tool-result",{result:n});break;case"ui/notifications/tool-cancelled":this.dispatch("prefab:tool-cancelled",n);break;case"ui/notifications/host-context-changed":{this.dispatch("prefab:theme-update",{...et(n)}),this.dispatch("prefab:host-context-changed",n);break}case"ui/resource-teardown":this.dispatch("prefab:teardown",n);break;case"ui/notifications/resource-updated":case"notifications/resources/updated":this.dispatch("prefab:resource-updated",n);break}}initJsonRpc(e){return new Promise((t,n)=>{let r=++this.rpcIdCounter,o=!1;this.rpcPending.set(r,{resolve:(i)=>{if(o)return;o=!0,this.protocol="jsonrpc";let s=I(i)??{},a=I(s.hostInfo)??{},l=I(s.hostContext)??{},c=I(s.hostCapabilities)??{},u=typeof l.theme==="string"||S(l.styles)?et(l):void 0;this.postJsonRpc({jsonrpc:"2.0",method:"ui/notifications/initialized",params:{}});let d=I(c.resources);this._hostSupportsSubscriptions=c.subscriptions===!0||d?.subscribe===!0,t({hostName:b(a.name),hostVersion:b(a.version),capabilities:{toast:!0,navigation:c.openLinks!=null,messaging:!0,displayModes:jt(l.availableDisplayModes)},theme:u,toolInput:void 0,meta:l})},reject:(i)=>{if(o)return;o=!0,n(i)}}),this.postJsonRpc({jsonrpc:"2.0",id:r,method:"ui/initialize",params:{protocolVersion:"2026-01-26",appInfo:{name:"prefab",version:sr},appCapabilities:{...e.displayModes&&{availableDisplayModes:e.displayModes}}}}),setTimeout(()=>{if(!o)o=!0,this.rpcPending.delete(r),n(Error("ui/initialize timeout"))},2000)})}createJsonRpcTransport(){return{callTool:(e,t)=>this.sendRpcRequest("tools/call",{name:e,arguments:t}),sendMessage:async(e)=>{await this.sendRpcRequest("ui/message",{role:"user",content:[{type:"text",text:e}]})},updateModelContext:async(e)=>{await this.sendRpcRequest("ui/update-model-context",{...e})},subscribe:(e,t,n)=>this.subscribe(e,t,n),capabilities:{subscriptions:this._hostSupportsSubscriptions}}}sendRpcRequest(e,t){let n=++this.rpcIdCounter;return new Promise((r,o)=>{this.rpcPending.set(n,{resolve:r,reject:o}),this.postJsonRpc({jsonrpc:"2.0",id:n,method:e,params:t}),setTimeout(()=>{if(this.rpcPending.has(n))this.rpcPending.delete(n),o(Error(`JSON-RPC '${e}' timed out`))},30000)})}sendRpcNotification(e,t){this.postJsonRpc({jsonrpc:"2.0",method:e,params:t})}postJsonRpc(e){if(typeof window>"u")return;if((typeof e.id==="number"||typeof e.id==="string")&&typeof e.method==="string")this.sentRpcIds.add(e.id);if(this.postFn)this.postFn(e);else(window.parent!==window?window.parent:window).postMessage(e,this.hostOrigin)}dispatch(e,t){let n=this.listeners.get(e);if(n)for(let r of n)r(t)}}var cr=()=>{};function Ft(e,t){if(t.variables)for(let[n,r]of Object.entries(t.variables))e.style.setProperty(n.startsWith("--")?n:`--${n}`,r);if(t.colorScheme&&t.colorScheme!=="auto")e.setAttribute("data-theme",t.colorScheme);if(t.fontCss)cs(t.fontCss)}function cs(e){if(document.getElementById("__prefab-host-fonts"))return;let n=document.createElement("style");n.id="__prefab-host-fonts",n.textContent=e,document.head.appendChild(n)}function tt(){if(typeof window>"u")return!1;try{return window.self!==window.top}catch{return!0}}function ds(){if(typeof window>"u")return;let e=Reflect.get(window,"acquireVsCodeApi");if(typeof e==="function")try{let t=Reflect.apply(e,void 0,[]);if(S(t)&&typeof t.postMessage==="function"){let n=t.postMessage;return{postMessage:(r)=>{Reflect.apply(n,t,[r])}}}}catch{return}return}var dr=["Accordion","AccordionItem","Alert","AlertDescription","AlertTitle","AreaChart","Audio","Badge","BarChart","BlockQuote","Button","ButtonGroup","Calendar","Card","CardContent","CardDescription","CardFooter","CardHeader","CardTitle","Carousel","Checkbox","ChoiceCard","Code","Column","Combobox","ComboboxGroup","ComboboxLabel","ComboboxOption","ComboboxSeparator","Condition","Container","Dashboard","DashboardItem","DataTable","DatePicker","Define","Detail","Dialog","Div","Dot","DropZone","Elif","Else","Embed","ExpandableRow","Field","FieldContent","FieldDescription","FieldError","FieldTitle","ForEach","Form","Grid","GridItem","H1","H2","H3","H4","Heading","Histogram","HoverCard","Icon","If","Image","Input","Kbd","Label","Large","Lead","LineChart","Link","Loader","Markdown","MasterDetail","Mermaid","Metric","Muted","P","Page","Pages","PdfViewer","PieChart","Popover","Progress","RadarChart","RadialChart","Radio","RadioGroup","Ring","Row","ScatterChart","Select","SelectGroup","SelectLabel","SelectOption","SelectSeparator","Separator","Slider","Slot","Small","Span","Sparkline","Svg","Switch","Tab","Table","TableBody","TableCaption","TableCell","TableFooter","TableHead","TableHeader","TableRow","Tabs","Text","Textarea","Tooltip","Use","Video"];var fr=new Set(dr);function Vt(e,t={}){let n=[],r=t.strict??!1;if(!S(e))return n.push({path:"$",message:"Wire data must be a non-null object"}),{valid:!1,errors:n};let o=e,i=o.$prefab;if(!S(i))n.push({path:"$.$prefab",message:"Missing or invalid $prefab header"});else if(typeof i.version!=="string")n.push({path:"$.$prefab.version",message:"version must be a string"});if(o.view==null)n.push({path:"$.view",message:'Missing required "view" field'});else Bt(o.view,"$.view",n,r);if(o.state!==void 0){if(o.state===null||typeof o.state!=="object"||Array.isArray(o.state))n.push({path:"$.state",message:"state must be a plain object"})}if(o.theme!==void 0)us(o.theme,n);if(o.css!==void 0)ur(o.css,"$.css",n);if(o.stylesheets!==void 0)ur(o.stylesheets,"$.stylesheets",n);if(o.mode!==void 0&&o.mode!=="light"&&o.mode!=="dark")n.push({path:"$.mode",message:'mode must be "light" or "dark"'});let s=o.defs;if(s!==void 0)if(!S(s))n.push({path:"$.defs",message:"defs must be a plain object"});else for(let[l,c]of Object.entries(s))Bt(c,`$.defs.${l}`,n,r);let a=o.keyBindings;if(a!==void 0)if(!S(a))n.push({path:"$.keyBindings",message:"keyBindings must be a plain object"});else for(let[l,c]of Object.entries(a))_t(c,`$.keyBindings.${l}`,n);return{valid:n.length===0,errors:n}}function Bt(e,t,n,r){if(!S(e)){n.push({path:t,message:"Component must be a plain object"});return}let o=e;if(typeof o.type!=="string"||o.type.length===0){n.push({path:`${t}.type`,message:'Component must have a non-empty "type" string'});return}if(r&&!fr.has(o.type))n.push({path:`${t}.type`,message:`Unknown component type: "${o.type}"`});if(o.children!==void 0)if(!Array.isArray(o.children))n.push({path:`${t}.children`,message:"children must be an array"});else for(let s=0;s<o.children.length;s++)Bt(o.children[s],`${t}.children[${s}]`,n,r);let i=["onClick","on_click","onChange","on_change","onSubmit","on_submit","onMount","on_mount","onClose","on_close"];for(let s of i)if(o[s]!==void 0)_t(o[s],`${t}.${s}`,n);for(let[s,a]of Object.entries(o)){if(s==="type"||ps.has(s)||i.includes(s))continue;if(pr(a)||Array.isArray(a)&&a.some(pr))n.push({path:`${t}.${s}`,message:`Components under "${s}" are ignored by the renderer; move them into "children"`})}}var ps=new Set(["children","fallback","trigger","empty","else","summary"]);function pr(e){return S(e)&&typeof e.type==="string"&&fr.has(e.type)}function _t(e,t,n){if(Array.isArray(e)){for(let i=0;i<e.length;i++)_t(e[i],`${t}[${i}]`,n);return}if(!S(e)){n.push({path:t,message:"Action must be an object or array of objects"});return}let r=e,o=typeof r.action==="string"&&r.action.length>0?r.action:typeof r.type==="string"&&r.type.length>0?r.type:void 0;if(o===void 0){n.push({path:`${t}.type`,message:'Action must have a non-empty "type" or "action" string'});return}if(o.toLowerCase()==="showtoast"){if(typeof r.message!=="string"||r.message.length===0)n.push({path:`${t}.message`,message:'showToast requires a non-empty "message" string'})}}function ur(e,t,n){if(!Array.isArray(e)){n.push({path:t,message:`${t} must be an array of strings`});return}for(let r=0;r<e.length;r++)if(typeof e[r]!=="string")n.push({path:`${t}[${r}]`,message:"must be a string"})}function us(e,t){if(!S(e)){t.push({path:"$.theme",message:"theme must be a plain object"});return}for(let n of["light","dark"])if(e[n]!==void 0){if(!S(e[n]))t.push({path:`$.theme.${n}`,message:`theme.${n} must be a plain object`})}}var W={mount(e,t,n){if(Xe(),n?.validate!==!1)for(let x of Vt(t).errors)N.warn(`wire validation ${x.path}: ${x.message}`);let r=t,o={tracked:[],evalBlocked:!1};if(r.pipes)for(let[x,v]of Object.entries(r.pipes))mr(x,v,o);let i=new ke(r.state),s;if(n?.transport&&"callTool"in n.transport)s=n.transport;else if(n?.transport)s=Ye(n.transport);else s=Ze();let a=n?.onToast??ms,l=new gt;function c(x){if(!W.isPrefabData(x))return;let v=x;if(r=v,v.state)i.merge(v.state);if(v.defs)d.defs=v.defs;if(v.theme)Dt(e,v.theme);if(v.mode)gr(e,v.mode);if(v.pipes)for(let[R,T]of Object.entries(v.pipes))mr(R,T,o);for(let R of m)R.remove();if(m.length=0,m.push(...hr(v.css,v.stylesheets)),br(e,v.layout),h?.(),h=void 0,v.keyBindings)h=Ot(v.keyBindings,(R)=>{D(H(R,{store:i,transport:s,scope:{},rerender:()=>y(),remount:c,onToast:a}),"keyBinding")});y(),u(v)}function u(x){if(x.onMount!=null)D(H(x.onMount,d),"onMount")}let d={store:i,scope:{},transport:s,rerender:()=>y(),remount:c,onToast:a,defs:r.defs,destroyRegistry:l};if(Dt(e,r.theme),r.mode)gr(e,r.mode);br(e,r.layout);let m=hr(r.css,r.stylesheets),h;if(r.keyBindings)h=Ot(r.keyBindings,(x)=>{D(H(x,{store:i,transport:s,scope:{},rerender:()=>y(),remount:c,onToast:a}),"keyBinding")});let C,f=n?.themeToggle??!0;if(f!==!1)C=It(e,typeof f==="object"?f:void 0);function y(){l.flush();let x=e.querySelector(".pf-theme-toggle");e.innerHTML="";let v=j(r.view,d);if(e.appendChild(v),x)e.appendChild(x)}return y(),u(r),{rerender:()=>y(),update(x){if(i.merge(x.update.state),y(),x.update.actions!=null)D(H(x.update.actions,d),"update action")},store:i,destroy(){l.flush(),C?.(),h?.(),rn(),an();for(let x of m)x.remove();for(let x of o.tracked)at(x);e.innerHTML=""}}},isPrefabData(e){return e!=null&&typeof e==="object"&&"$prefab"in e},isPrefabUpdate(e){return e!=null&&typeof e==="object"&&"$prefab"in e&&"update"in e}};function fs(e){if(e instanceof EvalError)return!0;return e instanceof Error&&/unsafe-eval|Content Security Policy|call to Function/i.test(e.message)}function mr(e,t,n){if(nn.has(e)){N.warn(`wire pipe "${e}" ignored — shadows built-in`);return}if(Le(e)!=null){N.debug(`wire pipe "${e}" — already registered, keeping local implementation`);return}if(n.evalBlocked)return;try{let r=Function("return ("+t+")")();if(typeof r!=="function"){N.warn(`wire pipe "${e}" — source did not evaluate to a function`);return}st(e,r),n.tracked.push(e)}catch(r){if(fs(r)){n.evalBlocked=!0,N.warn("wire pipes cannot be hydrated — this host's CSP forbids eval. Pre-register them with "+"prefab.registerPipe() from a companion script (rendererHtml({ scripts })) and they are used as-is.");return}N.warn(`wire pipe "${e}" — failed to hydrate:`,r)}}function ms(e){if(typeof document>"u")return;let t=hs(),n=document.createElement("div"),r=e.variant??"default";n.className=`pf-toast${r!=="default"?` pf-toast--${r}`:""}`,n.setAttribute("data-variant",r),n.style.marginBottom="8px",n.style.transition="opacity 0.3s ease";let o=document.createElement("div");if(o.textContent=e.message,o.style.fontWeight="500",n.appendChild(o),e.description){let s=document.createElement("div");s.textContent=e.description,s.style.fontSize="14px",s.style.color="var(--muted-foreground, #6b7280)",n.appendChild(s)}t.appendChild(n);let i=e.duration??4000;setTimeout(()=>{n.style.opacity="0",setTimeout(()=>n.remove(),300)},i)}function gr(e,t){if(we(e,t),typeof document<"u")we(document.documentElement,t)}function gs(e){let t=e.trim();if(t.includes("{")||t.includes("}"))return!1;return/^(https?:)?\/\//i.test(t)||t.startsWith("/")||/\.css(\?|#|$)/i.test(t)}function hr(e,t){let n=[];if(typeof document>"u")return n;for(let r of e??[]){let o=document.createElement("style");o.textContent=r,o.dataset.prefab="injected",document.head.appendChild(o),n.push(o)}for(let r of t??[])if(gs(r)){let o=document.createElement("link");o.rel="stylesheet",o.href=r,o.dataset.prefab="injected",document.head.appendChild(o),n.push(o)}else{let o=document.createElement("style");o.textContent=r,o.dataset.prefab="injected",document.head.appendChild(o),n.push(o)}return n}function br(e,t){if(e.style.height="",e.style.minHeight="",e.style.maxHeight="",e.style.overflow="",!t)return;if(t.preferredHeight!=null)e.style.height=`${t.preferredHeight}px`;if(t.minHeight!=null)e.style.minHeight=`${t.minHeight}px`;if(t.maxHeight!=null)e.style.maxHeight=`${t.maxHeight}px`,e.style.overflow="auto"}function hs(){let t=document.getElementById("prefab-toast-container");if(!t)t=document.createElement("div"),t.id="prefab-toast-container",t.style.position="fixed",t.style.bottom="16px",t.style.right="16px",t.style.zIndex="9999",t.style.maxWidth="400px",document.body.appendChild(t);return t}if(typeof window<"u"){Object.assign(window,{PrefabRenderer:W}),Object.assign(window,{prefab:{app:nt,mount:W.mount.bind(W),isPrefabData:W.isPrefabData.bind(W),isPrefabUpdate:W.isPrefabUpdate.bind(W),Bridge:Ne,isIframe:tt,registerPipe:st,unregisterPipe:at,listPipes:Zt,registerComponent:p,createThemeToggle:It,validateWireFormat:Vt,setLogLevel:Ut}});let e=Reflect.get(window,"__PREFAB_DATA__");if(W.isPrefabData(e)){let t=document.getElementById("prefab-root");if(t)W.mount(t,e)}}async function nt(e){Xe();let t=e?.mode??"auto",n=t==="bridge"||t==="auto"&&tt(),r,o,i={capabilities:{}};if(n)o=new Ne(e?.hostOrigin),o.connect(),i=await o.initialize(e?.capabilities??{toolInput:!0}),r=o.createTransport();else if(e?.transport)r=Ye(e.transport);else r=Ze();if(i.theme&&typeof document<"u")Ft(document.documentElement,i.theme);if(typeof document<"u"&&!o)ys();let s,a,l,c,u,d=i.toolInput,m;if(o)o.on("prefab:tool-input",(f)=>{let y=I(f.args)??f;if(s)s(y);else d=y}),o.on("prefab:tool-result",(f)=>{let y=f.result??f;if(a)a(y);else m=y}),o.on("prefab:tool-cancelled",()=>{l?.()}),o.on("prefab:tool-input-partial",(f)=>{c?.(I(f.args)??f)}),o.on("prefab:theme-update",(f)=>{if(typeof document<"u")Ft(document.documentElement,f)}),o.on("prefab:host-context-changed",(f)=>{u?.(f)});function h(f,...y){let x=zt(f),v=new ke,R={store:v,scope:{},transport:r,rerender:()=>T(),onToast:void 0};function T(){x.innerHTML="";for(let E of y)x.appendChild(j(E,R))}return T(),{rerender:T,store:v,destroy:()=>{x.innerHTML=""}}}return{callTool:(f,y={})=>r.callTool(f,y),sendMessage:(f)=>r.sendMessage(f),onToolInput:(f)=>{if(s=f,d){let y=d;d=void 0,queueMicrotask(()=>f(y))}},onToolResult:(f)=>{if(a=f,m!==void 0){let y=m;m=void 0,queueMicrotask(()=>f(y))}},onToolCancelled:(f)=>{l=f},onToolInputPartial:(f)=>{c=f},onHostContextChanged:(f)=>{u=f},render:h,mount:(f,y,x)=>{let v=zt(f);return W.mount(v,y,{transport:r,...x})},requestMode:(f)=>o?.requestMode(f),openLink:(f,y)=>{if(o)o.openLink(f,y);else if(typeof window<"u")window.open(f,y??"_blank")},updateContext:(f)=>{if(o)o.updateContext(f)},setupAutoResize:(f)=>{if(!o)return bs;let y=typeof f==="string"?zt(f):f;return o.setupAutoResize(y)},notifyPreferredSize:(f)=>{if(o)o.notifyPreferredSize(f)},host:i,capabilities:i.capabilities,theme:i.theme,transport:r,destroy:()=>o?.disconnect()}}var bs=()=>{};function zt(e){if(typeof e==="string"){if(typeof document>"u")throw Error("Cannot resolve selector outside browser");let t=document.querySelector(e);if(!t)throw Error(`Element not found: ${e}`);return t}return e}function ys(){function e(){let n=document.body.getAttribute("data-vscode-theme-kind");if(!n)return;let r=n.includes("light")?"light":"dark";document.documentElement.setAttribute("data-theme",r)}e(),new MutationObserver(e).observe(document.body,{attributes:!0,attributeFilter:["data-vscode-theme-kind"]})}var Kt=ot("auto"),yr="#root";function Wt(e){return W.isPrefabData(e)}function Cr(e){return W.isPrefabUpdate(e)}function xr(e){if(Wt(e))return e;if(S(e)){let t=e;if(Wt(t.structuredContent))return t.structuredContent;if(Array.isArray(t.content)){for(let n of t.content)if(S(n)&&n.type==="text"&&typeof n.text==="string")try{let r=JSON.parse(n.text);if(Wt(r))return r}catch{}}}return null}async function wr(){let e=document.querySelector(yr);if(!e){Kt.error(`Mount target "${yr}" not found`);return}let t=e,n=await nt();n.setupAutoResize(t);let r;function o(i){if(r)r.destroy();if(r=n.mount(t,i),i.layout)n.notifyPreferredSize(i.layout)}n.onToolResult((i)=>{let s=xr(i);if(s)o(s);else if(Cr(i)&&r)r.update(i)}),n.onToolInput((i)=>{let s=xr(i);if(s)o(s);else if(Cr(i)&&r)r.update(i)})}function Cs(){if(document.readyState==="loading")document.addEventListener("DOMContentLoaded",()=>{wr().catch((e)=>{Kt.error("Boot failed:",e)})},{once:!0});else queueMicrotask(()=>{wr().catch((e)=>{Kt.error("Boot failed:",e)})})}Cs();})();
|
|
16
|
+
`)}function we(e,t){e.setAttribute("data-theme",t),e.classList.toggle("dark",t==="dark"),e.classList.toggle("light",t==="light")}function Dt(e,t){if(!t)return;if(t.light)for(let[n,r]of Object.entries(t.light))e.style.setProperty(`--${Ht(n)}`,$t(r));if(t.dark){let r=document.getElementById("prefab-dark-theme");if(!r)r=document.createElement("style"),r.id="prefab-dark-theme",document.head.appendChild(r);r.textContent=nr({dark:t.dark})}}function Ot(e,t){if(!e||typeof document>"u")return;let n=(r)=>{for(let[o,i]of Object.entries(e))if(rs(o,r))r.preventDefault(),t(i)};return document.addEventListener("keydown",n),()=>document.removeEventListener("keydown",n)}function rs(e,t){let n=e.toLowerCase().split("+").map((i)=>i.trim()),r=n[n.length-1],o=new Set(n.slice(0,-1));if(o.has("ctrl")!==(t.ctrlKey||t.metaKey))return!1;if(o.has("shift")!==t.shiftKey)return!1;if(o.has("alt")!==t.altKey)return!1;return t.key.toLowerCase()===r}var rr='<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>',or='<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>',ir={"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 os(e,t){try{let r=localStorage.getItem(t);if(r==="light"||r==="dark")return r}catch{}let n=e.getAttribute("data-theme")??document.documentElement.getAttribute("data-theme");if(n==="light"||n==="dark")return n;if(typeof window<"u"&&window.matchMedia("(prefers-color-scheme: light)").matches)return"light";return"dark"}function It(e,t){if(typeof document>"u")return()=>{};let n=t?.position??"top-right",r=t?.storageKey??"prefab-theme",o=t?.syncDocument??!0,i=getComputedStyle(e).position;if(i==="static"||i==="")e.style.position="relative";let s=document.createElement("button");s.className="pf-theme-toggle",s.setAttribute("aria-label","Toggle theme"),s.setAttribute("title","Toggle light/dark"),Object.assign(s.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 a=ir[n]??ir["top-right"];for(let d of a.split(";")){let[m,h]=d.split(":").map((C)=>C.trim());if(m&&h)s.style.setProperty(m,h)}s.addEventListener("mouseenter",()=>{s.style.opacity="1"}),s.addEventListener("mouseleave",()=>{s.style.opacity="0.7"});function l(d){if(we(e,d),o)we(document.documentElement,d);s.innerHTML=d==="dark"?or:rr;try{localStorage.setItem(r,d)}catch{}}let c=os(e,r);l(c),s.addEventListener("click",()=>{let d=e.getAttribute("data-theme")??"dark";l(d==="dark"?"light":"dark")}),e.appendChild(s);let u;if(o)u=new MutationObserver((d)=>{for(let m of d)if(m.type==="attributes"&&m.attributeName==="data-theme"){let h=document.documentElement.getAttribute("data-theme");if((h==="light"||h==="dark")&&h!==e.getAttribute("data-theme")){we(e,h),s.innerHTML=h==="dark"?or:rr;try{localStorage.setItem(r,h)}catch{}}}}),u.observe(document.documentElement,{attributes:!0,attributeFilter:["data-theme"]});return()=>{u?.disconnect(),s.remove()}}function Ye(e){let t=e?.baseUrl??(typeof window<"u"?window.location.origin:""),n={"Content-Type":"application/json",...e?.headers},r=e?.fetch??globalThis.fetch.bind(globalThis);return{async callTool(o,i){let s=await r(`${t}/mcp/tools/call`,{method:"POST",headers:n,body:JSON.stringify({jsonrpc:"2.0",method:"tools/call",params:{name:o,arguments:i}})});if(!s.ok)throw Error(`MCP tool call failed: ${s.status} ${s.statusText}`);let a=await s.json();if(a.error)throw Error(a.error.message??"MCP tool call returned error");let l=a.result?.content??a.content??[];for(let c of l)if(c.type==="text"&&c.text!==void 0){try{let u=JSON.parse(c.text);if(typeof u==="object"&&u!==null&&"$prefab"in u)return u;return u}catch{}return c.text}return a.result??a},async sendMessage(o){await r(`${t}/mcp/messages`,{method:"POST",headers:n,body:JSON.stringify({message:o})})}}}function Ze(){return{callTool(e){return N.warn(`No MCP transport: callTool('${e}') ignored`),Promise.resolve(null)},sendMessage(e){return N.warn("No MCP transport: sendMessage ignored",e),Promise.resolve()}}}var sr="0.3.20";var is=["light","dark","auto"],ss=["inline","fullscreen","pip"];function ar(e){return S(e)&&typeof e.type==="string"&&(e.id===void 0||typeof e.id==="string")&&(e.payload===void 0||S(e.payload))}function Qe(e){return typeof e==="boolean"?e:void 0}function lr(e){let t=I(e.capabilities)??{},n=I(e.theme),r=I(e.toolInput),o=I(e.meta);return{hostName:b(e.hostName),hostVersion:b(e.hostVersion),capabilities:{toast:Qe(t.toast),clipboard:Qe(t.clipboard),navigation:Qe(t.navigation),messaging:Qe(t.messaging),displayModes:jt(t.displayModes)},...n&&{theme:as(n)},...r&&{toolInput:r},...o&&{meta:o}}}function as(e){let t=b(e.fontCss);return{...et({theme:e.colorScheme,styles:{variables:e.variables}}),...t!=null&&{fontCss:t}}}function jt(e){let t=Array.isArray(e)?e:[];return ss.filter((n)=>t.includes(n))}function et(e){let t={},n=is.find((s)=>s===e.theme);if(n)t.colorScheme=n;let r=I(e.styles),o=I(r?.variables);if(o)t.variables=Object.fromEntries(Object.entries(o).filter((s)=>typeof s[1]==="string"));let i=b(I(r?.css)?.fonts);if(i!=null)t.fontCss=i;return t}function ls(e){return S(e)&&e.jsonrpc==="2.0"}class Ne{hostOrigin;listeners=new Map;protocol="prefab";cleanup;pending=new Map;callIdCounter=0;rpcPending=new Map;rpcIdCounter=0;sentRpcIds=new Set;postFn;_hostSupportsSubscriptions=!1;constructor(e="*"){this.hostOrigin=e}connect(){if(typeof window>"u")return;let e=ds();if(e)this.postFn=(n)=>e.postMessage(n);let t=(n)=>{if(this.hostOrigin!=="*"&&n.origin!==this.hostOrigin)return;let r=n.data;if(ls(r)){this.handleJsonRpc(r);return}if(!ar(r)||!r.type.startsWith("prefab:"))return;let o=r;if(o.type==="prefab:tool-call-response"&&o.id){let s=this.pending.get(o.id);if(s){if(this.pending.delete(o.id),o.payload?.error!=null)s.reject(Error(k(o.payload.error)));else s.resolve(o.payload?.result);return}}let i=this.listeners.get(o.type);if(i)for(let s of i)s(o.payload??{})};window.addEventListener("message",t),this.cleanup=()=>window.removeEventListener("message",t)}async initialize(e){try{return await Promise.any([this.initPrefab(e),this.initJsonRpc(e)])}catch(t){let n=t instanceof AggregateError?t.errors.map((r)=>r.message).join("; "):String(t);throw Error(`Bridge init failed — no host responded. Tried: ${n}`,{cause:t})}}createTransport(){if(this.protocol==="jsonrpc")return this.createJsonRpcTransport();return this.createPrefabTransport()}requestMode(e){if(this.protocol==="jsonrpc")this.sendRpcRequest("ui/request-display-mode",{mode:e});else this.sendPrefab("prefab:request-mode",{mode:e})}openLink(e,t){if(this.protocol==="jsonrpc")this.sendRpcRequest("ui/open-link",{url:e,target:t});else this.sendPrefab("prefab:open-link",{url:e,target:t})}updateContext(e){if(this.protocol==="jsonrpc")this.sendRpcRequest("ui/update-model-context",{structuredContent:e});else this.sendPrefab("prefab:update-context",{context:e})}setupAutoResize(e){if(typeof ResizeObserver>"u")return cr;let t=-1,n=-1,r=(s,a)=>{if(s===t&&a===n)return;if(t=s,n=a,this.protocol==="jsonrpc")this.sendRpcNotification("ui/notifications/size-changed",{width:s,height:a});else this.sendPrefab("prefab:size-changed",{width:s,height:a})},o=new ResizeObserver((s)=>{for(let a of s)if(a.borderBoxSize.length){let l=a.borderBoxSize[0];r(Math.ceil(l.inlineSize),Math.ceil(l.blockSize))}else{let l=a.target.getBoundingClientRect();r(Math.ceil(l.width),Math.ceil(l.height))}});o.observe(e);let i=e.getBoundingClientRect();return r(Math.ceil(i.width),Math.ceil(i.height)),()=>o.disconnect()}notifyPreferredSize(e){if(this.protocol==="jsonrpc")this.sendRpcNotification("ui/notifications/preferred-size",e);else this.sendPrefab("prefab:preferred-size",e)}subscribe(e,t,n){let r=(o)=>{if(o.uri!==e)return;t(o.contents??o.data??o)};if(this.protocol==="jsonrpc")this.on("prefab:resource-updated",r),this.sendRpcRequest("resources/subscribe",{uri:e}).catch((o)=>{this.off("prefab:resource-updated",r),n?.(o)});else this.on("prefab:resource-updated",r),this.sendPrefab("prefab:subscribe",{uri:e});return()=>{if(this.off("prefab:resource-updated",r),this.protocol==="jsonrpc")this.sendRpcRequest("resources/unsubscribe",{uri:e}).catch(cr);else this.sendPrefab("prefab:unsubscribe",{uri:e})}}get supportsSubscriptions(){return this._hostSupportsSubscriptions}on(e,t){if(!this.listeners.has(e))this.listeners.set(e,new Set);let n=this.listeners.get(e);if(n)n.add(t)}off(e,t){this.listeners.get(e)?.delete(t)}disconnect(){this.cleanup?.(),this.listeners.clear();for(let[,e]of this.pending)e.reject(Error("Bridge disconnected"));this.pending.clear();for(let[,e]of this.rpcPending)e.reject(Error("Bridge disconnected"));this.rpcPending.clear(),this.sentRpcIds.clear()}get activeProtocol(){return this.protocol}initPrefab(e){return new Promise((t,n)=>{let r=!1,o=(i)=>{if(r)return;r=!0,this.off("prefab:init-response",o),this.protocol="prefab",this._hostSupportsSubscriptions=I(i.capabilities)?.subscriptions===!0,t(lr(i))};this.on("prefab:init-response",o),this.sendPrefab("prefab:init",{capabilities:e}),setTimeout(()=>{if(!r)r=!0,this.off("prefab:init-response",o),n(Error("prefab:init timeout"))},2000)})}createPrefabTransport(){return{callTool:(e,t)=>{let n=`tc-${++this.callIdCounter}`;return new Promise((r,o)=>{this.pending.set(n,{resolve:r,reject:o}),this.sendPrefab("prefab:tool-call",{tool:e,arguments:t},n),setTimeout(()=>{if(this.pending.has(n))this.pending.delete(n),o(Error(`Tool call '${e}' timed out`))},30000)})},sendMessage:(e)=>(this.sendPrefab("prefab:send-message",{message:e}),Promise.resolve()),updateModelContext:(e)=>(this.sendPrefab("prefab:update-context",{context:e.structuredContent,content:e.content}),Promise.resolve()),subscribe:(e,t,n)=>this.subscribe(e,t,n),capabilities:{subscriptions:this._hostSupportsSubscriptions}}}sendPrefab(e,t,n){if(typeof window>"u")return;let r=window.parent!==window?window.parent:window,o={type:e,payload:t,id:n};r.postMessage(o,this.hostOrigin)}handleJsonRpc(e){if(!("method"in e)){let r=this.rpcPending.get(e.id);if(r)if(this.rpcPending.delete(e.id),e.error)r.reject(Error(e.error.message));else r.resolve(e.result);return}let t=e.method,n=e.params??{};if(e.id!=null&&this.sentRpcIds.delete(e.id))return;if(e.id!=null)this.postJsonRpc({jsonrpc:"2.0",id:e.id,result:{}});switch(t){case"ui/notifications/tool-input":this.dispatch("prefab:tool-input",{args:n.arguments??n});break;case"ui/notifications/tool-input-partial":this.dispatch("prefab:tool-input-partial",{args:n.arguments??n});break;case"ui/notifications/tool-result":this.dispatch("prefab:tool-result",{result:n});break;case"ui/notifications/tool-cancelled":this.dispatch("prefab:tool-cancelled",n);break;case"ui/notifications/host-context-changed":{this.dispatch("prefab:theme-update",{...et(n)}),this.dispatch("prefab:host-context-changed",n);break}case"ui/resource-teardown":this.dispatch("prefab:teardown",n);break;case"ui/notifications/resource-updated":case"notifications/resources/updated":this.dispatch("prefab:resource-updated",n);break}}initJsonRpc(e){return new Promise((t,n)=>{let r=++this.rpcIdCounter,o=!1;this.rpcPending.set(r,{resolve:(i)=>{if(o)return;o=!0,this.protocol="jsonrpc";let s=I(i)??{},a=I(s.hostInfo)??{},l=I(s.hostContext)??{},c=I(s.hostCapabilities)??{},u=typeof l.theme==="string"||S(l.styles)?et(l):void 0;this.postJsonRpc({jsonrpc:"2.0",method:"ui/notifications/initialized",params:{}});let d=I(c.resources);this._hostSupportsSubscriptions=c.subscriptions===!0||d?.subscribe===!0,t({hostName:b(a.name),hostVersion:b(a.version),capabilities:{toast:!0,navigation:c.openLinks!=null,messaging:!0,displayModes:jt(l.availableDisplayModes)},theme:u,toolInput:void 0,meta:l})},reject:(i)=>{if(o)return;o=!0,n(i)}}),this.postJsonRpc({jsonrpc:"2.0",id:r,method:"ui/initialize",params:{protocolVersion:"2026-01-26",appInfo:{name:"prefab",version:sr},appCapabilities:{...e.displayModes&&{availableDisplayModes:e.displayModes}}}}),setTimeout(()=>{if(!o)o=!0,this.rpcPending.delete(r),n(Error("ui/initialize timeout"))},2000)})}createJsonRpcTransport(){return{callTool:(e,t)=>this.sendRpcRequest("tools/call",{name:e,arguments:t}),sendMessage:async(e)=>{await this.sendRpcRequest("ui/message",{role:"user",content:[{type:"text",text:e}]})},updateModelContext:async(e)=>{await this.sendRpcRequest("ui/update-model-context",{...e})},subscribe:(e,t,n)=>this.subscribe(e,t,n),capabilities:{subscriptions:this._hostSupportsSubscriptions}}}sendRpcRequest(e,t){let n=++this.rpcIdCounter;return new Promise((r,o)=>{this.rpcPending.set(n,{resolve:r,reject:o}),this.postJsonRpc({jsonrpc:"2.0",id:n,method:e,params:t}),setTimeout(()=>{if(this.rpcPending.has(n))this.rpcPending.delete(n),o(Error(`JSON-RPC '${e}' timed out`))},30000)})}sendRpcNotification(e,t){this.postJsonRpc({jsonrpc:"2.0",method:e,params:t})}postJsonRpc(e){if(typeof window>"u")return;if((typeof e.id==="number"||typeof e.id==="string")&&typeof e.method==="string")this.sentRpcIds.add(e.id);if(this.postFn)this.postFn(e);else(window.parent!==window?window.parent:window).postMessage(e,this.hostOrigin)}dispatch(e,t){let n=this.listeners.get(e);if(n)for(let r of n)r(t)}}var cr=()=>{};function Ft(e,t){if(t.variables)for(let[n,r]of Object.entries(t.variables))e.style.setProperty(n.startsWith("--")?n:`--${n}`,r);if(t.colorScheme&&t.colorScheme!=="auto")e.setAttribute("data-theme",t.colorScheme);if(t.fontCss)cs(t.fontCss)}function cs(e){if(document.getElementById("__prefab-host-fonts"))return;let n=document.createElement("style");n.id="__prefab-host-fonts",n.textContent=e,document.head.appendChild(n)}function tt(){if(typeof window>"u")return!1;try{return window.self!==window.top}catch{return!0}}function ds(){if(typeof window>"u")return;let e=Reflect.get(window,"acquireVsCodeApi");if(typeof e==="function")try{let t=Reflect.apply(e,void 0,[]);if(S(t)&&typeof t.postMessage==="function"){let n=t.postMessage;return{postMessage:(r)=>{Reflect.apply(n,t,[r])}}}}catch{return}return}var dr=["Accordion","AccordionItem","Alert","AlertDescription","AlertTitle","AreaChart","Audio","Badge","BarChart","BlockQuote","Button","ButtonGroup","Calendar","Card","CardContent","CardDescription","CardFooter","CardHeader","CardTitle","Carousel","Checkbox","ChoiceCard","Code","Column","Combobox","ComboboxGroup","ComboboxLabel","ComboboxOption","ComboboxSeparator","Condition","Container","Dashboard","DashboardItem","DataTable","DatePicker","Define","Detail","Dialog","Div","Dot","DropZone","Elif","Else","Embed","ExpandableRow","Field","FieldContent","FieldDescription","FieldError","FieldTitle","ForEach","Form","Grid","GridItem","H1","H2","H3","H4","Heading","Histogram","HoverCard","Icon","If","Image","Input","Kbd","Label","Large","Lead","LineChart","Link","Loader","Markdown","MasterDetail","Mermaid","Metric","Muted","P","Page","Pages","PdfViewer","PieChart","Popover","Progress","RadarChart","RadialChart","Radio","RadioGroup","Ring","Row","ScatterChart","Select","SelectGroup","SelectLabel","SelectOption","SelectSeparator","Separator","Slider","Slot","Small","Span","Sparkline","Svg","Switch","Tab","Table","TableBody","TableCaption","TableCell","TableFooter","TableHead","TableHeader","TableRow","Tabs","Text","Textarea","Tooltip","Use","Video"];var fr=new Set(dr);function Vt(e,t={}){let n=[],r=t.strict??!1;if(!S(e))return n.push({path:"$",message:"Wire data must be a non-null object"}),{valid:!1,errors:n};let o=e,i=o.$prefab;if(!S(i))n.push({path:"$.$prefab",message:"Missing or invalid $prefab header"});else if(typeof i.version!=="string")n.push({path:"$.$prefab.version",message:"version must be a string"});if(o.view==null)n.push({path:"$.view",message:'Missing required "view" field'});else Bt(o.view,"$.view",n,r);if(o.state!==void 0){if(o.state===null||typeof o.state!=="object"||Array.isArray(o.state))n.push({path:"$.state",message:"state must be a plain object"})}if(o.theme!==void 0)us(o.theme,n);if(o.css!==void 0)ur(o.css,"$.css",n);if(o.stylesheets!==void 0)ur(o.stylesheets,"$.stylesheets",n);if(o.mode!==void 0&&o.mode!=="light"&&o.mode!=="dark")n.push({path:"$.mode",message:'mode must be "light" or "dark"'});let s=o.defs;if(s!==void 0)if(!S(s))n.push({path:"$.defs",message:"defs must be a plain object"});else for(let[l,c]of Object.entries(s))Bt(c,`$.defs.${l}`,n,r);let a=o.keyBindings;if(a!==void 0)if(!S(a))n.push({path:"$.keyBindings",message:"keyBindings must be a plain object"});else for(let[l,c]of Object.entries(a))_t(c,`$.keyBindings.${l}`,n);return{valid:n.length===0,errors:n}}function Bt(e,t,n,r){if(!S(e)){n.push({path:t,message:"Component must be a plain object"});return}let o=e;if(typeof o.type!=="string"||o.type.length===0){n.push({path:`${t}.type`,message:'Component must have a non-empty "type" string'});return}if(r&&!fr.has(o.type))n.push({path:`${t}.type`,message:`Unknown component type: "${o.type}"`});if(o.children!==void 0)if(!Array.isArray(o.children))n.push({path:`${t}.children`,message:"children must be an array"});else for(let s=0;s<o.children.length;s++)Bt(o.children[s],`${t}.children[${s}]`,n,r);let i=["onClick","on_click","onChange","on_change","onSubmit","on_submit","onMount","on_mount","onClose","on_close"];for(let s of i)if(o[s]!==void 0)_t(o[s],`${t}.${s}`,n);for(let[s,a]of Object.entries(o)){if(s==="type"||ps.has(s)||i.includes(s))continue;if(pr(a)||Array.isArray(a)&&a.some(pr))n.push({path:`${t}.${s}`,message:`Components under "${s}" are ignored by the renderer; move them into "children"`})}}var ps=new Set(["children","fallback","trigger","empty","else","summary"]);function pr(e){return S(e)&&typeof e.type==="string"&&fr.has(e.type)}function _t(e,t,n){if(Array.isArray(e)){for(let i=0;i<e.length;i++)_t(e[i],`${t}[${i}]`,n);return}if(!S(e)){n.push({path:t,message:"Action must be an object or array of objects"});return}let r=e,o=typeof r.action==="string"&&r.action.length>0?r.action:typeof r.type==="string"&&r.type.length>0?r.type:void 0;if(o===void 0){n.push({path:`${t}.type`,message:'Action must have a non-empty "type" or "action" string'});return}if(o.toLowerCase()==="showtoast"){if(typeof r.message!=="string"||r.message.length===0)n.push({path:`${t}.message`,message:'showToast requires a non-empty "message" string'})}}function ur(e,t,n){if(!Array.isArray(e)){n.push({path:t,message:`${t} must be an array of strings`});return}for(let r=0;r<e.length;r++)if(typeof e[r]!=="string")n.push({path:`${t}[${r}]`,message:"must be a string"})}function us(e,t){if(!S(e)){t.push({path:"$.theme",message:"theme must be a plain object"});return}for(let n of["light","dark"])if(e[n]!==void 0){if(!S(e[n]))t.push({path:`$.theme.${n}`,message:`theme.${n} must be a plain object`})}}var W={mount(e,t,n){if(Xe(),n?.validate!==!1)for(let x of Vt(t).errors)N.warn(`wire validation ${x.path}: ${x.message}`);let r=t,o={tracked:[],evalBlocked:!1};if(r.pipes)for(let[x,v]of Object.entries(r.pipes))mr(x,v,o);let i=new ke(r.state),s;if(n?.transport&&"callTool"in n.transport)s=n.transport;else if(n?.transport)s=Ye(n.transport);else s=Ze();let a=n?.onToast??ms,l=new gt;function c(x){if(!W.isPrefabData(x))return;let v=x;if(r=v,v.state)i.merge(v.state);if(v.defs)d.defs=v.defs;if(v.theme)Dt(e,v.theme);if(v.mode)gr(e,v.mode);if(v.pipes)for(let[R,T]of Object.entries(v.pipes))mr(R,T,o);for(let R of m)R.remove();if(m.length=0,m.push(...hr(v.css,v.stylesheets)),br(e,v.layout),h?.(),h=void 0,v.keyBindings)h=Ot(v.keyBindings,(R)=>{D(H(R,{store:i,transport:s,scope:{},rerender:()=>y(),remount:c,onToast:a}),"keyBinding")});y(),u(v)}function u(x){if(x.onMount!=null)D(H(x.onMount,d),"onMount")}let d={store:i,scope:{},transport:s,rerender:()=>y(),remount:c,onToast:a,defs:r.defs,destroyRegistry:l};if(Dt(e,r.theme),r.mode)gr(e,r.mode);br(e,r.layout);let m=hr(r.css,r.stylesheets),h;if(r.keyBindings)h=Ot(r.keyBindings,(x)=>{D(H(x,{store:i,transport:s,scope:{},rerender:()=>y(),remount:c,onToast:a}),"keyBinding")});let C,f=n?.themeToggle??!0;if(f!==!1)C=It(e,typeof f==="object"?f:void 0);function y(){l.flush();let x=e.querySelector(".pf-theme-toggle");e.innerHTML="";let v=j(r.view,d);if(e.appendChild(v),x)e.appendChild(x)}return y(),u(r),{rerender:()=>y(),update(x){if(i.merge(x.update.state),y(),x.update.actions!=null)D(H(x.update.actions,d),"update action")},store:i,destroy(){l.flush(),C?.(),h?.(),rn(),an();for(let x of m)x.remove();for(let x of o.tracked)at(x);e.innerHTML=""}}},isPrefabData(e){return e!=null&&typeof e==="object"&&"$prefab"in e},isPrefabUpdate(e){return e!=null&&typeof e==="object"&&"$prefab"in e&&"update"in e}};function fs(e){if(e instanceof EvalError)return!0;return e instanceof Error&&/unsafe-eval|Content Security Policy|call to Function/i.test(e.message)}function mr(e,t,n){if(nn.has(e)){N.warn(`wire pipe "${e}" ignored — shadows built-in`);return}if(Le(e)!=null){N.debug(`wire pipe "${e}" — already registered, keeping local implementation`);return}if(n.evalBlocked)return;try{let r=Function("return ("+t+")")();if(typeof r!=="function"){N.warn(`wire pipe "${e}" — source did not evaluate to a function`);return}st(e,r),n.tracked.push(e)}catch(r){if(fs(r)){n.evalBlocked=!0,N.warn("wire pipes cannot be hydrated — this host's CSP forbids eval. Pre-register them with "+"prefab.registerPipe() from a companion script (rendererHtml({ scripts })) and they are used as-is.");return}N.warn(`wire pipe "${e}" — failed to hydrate:`,r)}}function ms(e){if(typeof document>"u")return;let t=hs(),n=document.createElement("div"),r=e.variant??"default";n.className=`pf-toast${r!=="default"?` pf-toast--${r}`:""}`,n.setAttribute("data-variant",r),n.style.marginBottom="8px",n.style.transition="opacity 0.3s ease";let o=document.createElement("div");if(o.textContent=e.message,o.style.fontWeight="500",n.appendChild(o),e.description){let s=document.createElement("div");s.textContent=e.description,s.style.fontSize="14px",s.style.color="var(--muted-foreground, #6b7280)",n.appendChild(s)}t.appendChild(n);let i=e.duration??4000;setTimeout(()=>{n.style.opacity="0",setTimeout(()=>n.remove(),300)},i)}function gr(e,t){if(we(e,t),typeof document<"u")we(document.documentElement,t)}function gs(e){let t=e.trim();if(t.includes("{")||t.includes("}"))return!1;return/^(https?:)?\/\//i.test(t)||t.startsWith("/")||/\.css(\?|#|$)/i.test(t)}function hr(e,t){let n=[];if(typeof document>"u")return n;for(let r of e??[]){let o=document.createElement("style");o.textContent=r,o.dataset.prefab="injected",document.head.appendChild(o),n.push(o)}for(let r of t??[])if(gs(r)){let o=document.createElement("link");o.rel="stylesheet",o.href=r,o.dataset.prefab="injected",document.head.appendChild(o),n.push(o)}else{let o=document.createElement("style");o.textContent=r,o.dataset.prefab="injected",document.head.appendChild(o),n.push(o)}return n}function br(e,t){if(e.style.height="",e.style.minHeight="",e.style.maxHeight="",e.style.overflow="",!t)return;if(t.preferredHeight!=null)e.style.height=`${t.preferredHeight}px`;if(t.minHeight!=null)e.style.minHeight=`${t.minHeight}px`;if(t.maxHeight!=null)e.style.maxHeight=`${t.maxHeight}px`,e.style.overflow="auto"}function hs(){let t=document.getElementById("prefab-toast-container");if(!t)t=document.createElement("div"),t.id="prefab-toast-container",t.style.position="fixed",t.style.bottom="16px",t.style.right="16px",t.style.zIndex="9999",t.style.maxWidth="400px",document.body.appendChild(t);return t}if(typeof window<"u"){Object.assign(window,{PrefabRenderer:W}),Object.assign(window,{prefab:{app:nt,mount:W.mount.bind(W),isPrefabData:W.isPrefabData.bind(W),isPrefabUpdate:W.isPrefabUpdate.bind(W),Bridge:Ne,isIframe:tt,registerPipe:st,unregisterPipe:at,listPipes:Zt,registerComponent:p,createThemeToggle:It,validateWireFormat:Vt,setLogLevel:Ut}});let e=Reflect.get(window,"__PREFAB_DATA__");if(W.isPrefabData(e)){let t=document.getElementById("prefab-root");if(t)W.mount(t,e)}}async function nt(e){Xe();let t=e?.mode??"auto",n=t==="bridge"||t==="auto"&&tt(),r,o,i={capabilities:{}};if(n)o=new Ne(e?.hostOrigin),o.connect(),i=await o.initialize(e?.capabilities??{toolInput:!0}),r=o.createTransport();else if(e?.transport)r=Ye(e.transport);else r=Ze();if(i.theme&&typeof document<"u")Ft(document.documentElement,i.theme);if(typeof document<"u"&&!o)ys();let s,a,l,c,u,d=i.toolInput,m;if(o)o.on("prefab:tool-input",(f)=>{let y=I(f.args)??f;if(s)s(y);else d=y}),o.on("prefab:tool-result",(f)=>{let y=f.result??f;if(a)a(y);else m=y}),o.on("prefab:tool-cancelled",()=>{l?.()}),o.on("prefab:tool-input-partial",(f)=>{c?.(I(f.args)??f)}),o.on("prefab:theme-update",(f)=>{if(typeof document<"u")Ft(document.documentElement,f)}),o.on("prefab:host-context-changed",(f)=>{u?.(f)});function h(f,...y){let x=zt(f),v=new ke,R={store:v,scope:{},transport:r,rerender:()=>T(),onToast:void 0};function T(){x.innerHTML="";for(let E of y)x.appendChild(j(E,R))}return T(),{rerender:T,store:v,destroy:()=>{x.innerHTML=""}}}return{callTool:(f,y={})=>r.callTool(f,y),sendMessage:(f)=>r.sendMessage(f),onToolInput:(f)=>{if(s=f,d){let y=d;d=void 0,queueMicrotask(()=>f(y))}},onToolResult:(f)=>{if(a=f,m!==void 0){let y=m;m=void 0,queueMicrotask(()=>f(y))}},onToolCancelled:(f)=>{l=f},onToolInputPartial:(f)=>{c=f},onHostContextChanged:(f)=>{u=f},render:h,mount:(f,y,x)=>{let v=zt(f);return W.mount(v,y,{transport:r,...x})},requestMode:(f)=>o?.requestMode(f),openLink:(f,y)=>{if(o)o.openLink(f,y);else if(typeof window<"u")window.open(f,y??"_blank")},updateContext:(f)=>{if(o)o.updateContext(f)},setupAutoResize:(f)=>{if(!o)return bs;let y=typeof f==="string"?zt(f):f;return o.setupAutoResize(y)},notifyPreferredSize:(f)=>{if(o)o.notifyPreferredSize(f)},host:i,capabilities:i.capabilities,theme:i.theme,transport:r,destroy:()=>o?.disconnect()}}var bs=()=>{};function zt(e){if(typeof e==="string"){if(typeof document>"u")throw Error("Cannot resolve selector outside browser");let t=document.querySelector(e);if(!t)throw Error(`Element not found: ${e}`);return t}return e}function ys(){function e(){let n=document.body.getAttribute("data-vscode-theme-kind");if(!n)return;let r=n.includes("light")?"light":"dark";document.documentElement.setAttribute("data-theme",r)}e(),new MutationObserver(e).observe(document.body,{attributes:!0,attributeFilter:["data-vscode-theme-kind"]})}var Kt=ot("auto"),yr="#root";function Wt(e){return W.isPrefabData(e)}function Cr(e){return W.isPrefabUpdate(e)}function xr(e){if(Wt(e))return e;if(S(e)){let t=e;if(Wt(t.structuredContent))return t.structuredContent;if(Array.isArray(t.content)){for(let n of t.content)if(S(n)&&n.type==="text"&&typeof n.text==="string")try{let r=JSON.parse(n.text);if(Wt(r))return r}catch{}}}return null}async function wr(){let e=document.querySelector(yr);if(!e){Kt.error(`Mount target "${yr}" not found`);return}let t=e,n=await nt();n.setupAutoResize(t);let r;function o(i){if(r)r.destroy();if(r=n.mount(t,i),i.layout)n.notifyPreferredSize(i.layout)}n.onToolResult((i)=>{let s=xr(i);if(s)o(s);else if(Cr(i)&&r)r.update(i)}),n.onToolInput((i)=>{let s=xr(i);if(s)o(s);else if(Cr(i)&&r)r.update(i)})}function Cs(){if(document.readyState==="loading")document.addEventListener("DOMContentLoaded",()=>{wr().catch((e)=>{Kt.error("Boot failed:",e)})},{once:!0});else queueMicrotask(()=>{wr().catch((e)=>{Kt.error("Boot failed:",e)})})}Cs();})();
|