@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
package/dist/renderer.min.js
CHANGED
|
@@ -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(He(t[r])),r++;r++;let c=a?` data-language="${He(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>${En(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 Oo(e,t){let n=document.createElement("kbd");return n.className="pf-kbd",n.textContent=w(e.content,t),n}function Tn(){p("Card",Do),p("CardHeader",Et("pf-card-header")),p("CardTitle",Rn("pf-card-title","h3")),p("CardDescription",Rn("pf-card-description","p")),p("CardContent",Et("pf-card-content")),p("CardFooter",Et("pf-card-footer"))}function Do(e,t){let n=g("div","pf-card");return n.style.overflow="hidden",N(e,n,t),n}function Et(e){return(t,n)=>{let r=g("div",e);return r.style.padding="16px 24px",N(t,r,n),r}}function Rn(e,t){return(n,r)=>{let o=document.createElement(t);return o.className=e,o.textContent=w(n.content,r),o}}function An(){p("DataTable",Io),p("Badge",jo),p("Dot",Fo),p("Metric",Bo),p("Ring",Vo),p("Progress",_o),p("Separator",zo),p("Loader",Wo),p("Icon",Ko),p("Sparkline",Jo)}function Io(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=W(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?W(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});O(P(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=W(`{{ $item.${x.accessor} }}`,{...t,scope:{...t.scope,$item:C}});else if(R=y?m:f[x.key],x.format&&R!=null)R=W(`{{ __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 jo(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),Go(n,r),n}function Fo(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 Bo(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 Vo(e,t){let n=g("div","pf-ring"),r=D(e.size)??80,o=D(e.thickness)??8,i=Number(W(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 _o(e,t){let n=g("div","pf-progress");n.setAttribute("role","progressbar");let r=Number(W(e.value,t)??0),o=D(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 zo(e,t){let n=document.createElement("hr");return n.className="pf-separator",n.style.border="none",n.style.margin="8px 0",n}function Wo(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 Ko(e,t){let n=g("span","pf-icon");return n.setAttribute("data-icon",w(e.name??e.content,t)),n}function Jo(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=D(e.width)??120,i=D(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 Go(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 Mn(){p("Form",qo),p("Input",Uo),p("Textarea",Ce(Xo)),p("Button",Yo),p("ButtonGroup",Zo),p("Checkbox",Qo),p("Switch",ei),p("Slider",Ce(ti)),p("Calendar",ri),p("DatePicker",Ce(oi)),p("Field",Pe("pf-field")),p("FieldTitle",xe("pf-field-title")),p("FieldDescription",xe("pf-field-description")),p("FieldContent",Pe("pf-field-content")),p("FieldError",xe("pf-field-error"))}function qo(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},O(P(e.onSubmit,s),"onSubmit")}}),N(e,n,t),n}function Nn(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 Ce(e){return(t,n)=>{let r=e(t,n);return r.style.display="flex",r.style.flexDirection="column",r.style.gap="4px",Nn(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 Uo(e,t){let n=g("div","pf-input-wrapper");n.style.display="flex",n.style.flexDirection="column",n.style.gap="4px",Nn(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)O(P(e.onChange,{...V(t),scope:{...t.scope,$event:r.value}}),"onChange")})}return Qe(r),n.appendChild(r),n}function Xo(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)O(P(e.onChange,{...V(t),scope:{...t.scope,$event:r.value}}),"onChange")})}return Qe(r),n.appendChild(r),n}function Yo(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),ni(n,r),e.size!=null)n.setAttribute("data-size",k(e.size));if(e.disabled===!0)n.disabled=!0;return n}function Zo(e,t){let n=g("div","pf-button-group");return n.style.display="flex",n.style.gap="8px",N(e,n,t),n}function Qo(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)O(P(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 ei(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)O(P(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 ti(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)O(P(e.onChange,{...V(t),scope:{...t.scope,$event:Number(r.value)}}),"onChange")})}return n.appendChild(r),n}function Qe(e){e.style.padding="8px 12px",e.style.fontSize="14px",e.style.width="100%",e.style.boxSizing="border-box"}function ni(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 Pe(e){return(t,n)=>{let r=g("div",e);return N(t,r,n),r}}function xe(e){return(t,n)=>{let r=g("span",e);return r.textContent=w(t.content,n),r}}function Rt(){let e=document.createElement("hr");return e.className="pf-separator",e.style.border="none",e.style.margin="4px 0",e}function ri(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)O(P(e.onChange,V(t)),"onChange")}),n.appendChild(r),n}function oi(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)O(P(e.onChange,V(t)),"onChange")}),n.appendChild(r),n}function Ln(){p("Select",Ce(ii)),p("SelectOption",li),p("SelectGroup",Pe("pf-select-group")),p("SelectLabel",xe("pf-select-label")),p("SelectSeparator",Rt),p("Radio",ci),p("RadioGroup",di),p("Combobox",Ce(pi)),p("ComboboxOption",ui),p("ComboboxGroup",Pe("pf-combobox-group")),p("ComboboxLabel",xe("pf-combobox-label")),p("ComboboxSeparator",Rt),p("ChoiceCard",fi)}function ii(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),Qe(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)ai(r,s);r.addEventListener("change",()=>{let a=si(r);if(t.store.set(i,a),e.onChange!=null)O(P(e.onChange,{...V(t),scope:{...t.scope,$event:a}}),"onChange")})}return n.appendChild(r),n}function si(e){if(!e.multiple)return e.value;return Array.from(e.selectedOptions,(t)=>t.value)}function ai(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 li(e,t){return g("span")}function ci(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 di(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)}N(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)O(P(e.onChange,V(t)),"onChange")}}),n}function pi(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",N(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",()=>{O(P(e.onChange,{...V(t),scope:{...t.scope,$event:r.value}}),"onChange")});return n.style.position="relative",n.appendChild(r),n.appendChild(s),n}function ui(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 fi(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 N(e,n,t),n}function Hn(){p("Tabs",mi),p("Tab",gi),p("Accordion",hi),p("AccordionItem",bi),p("Dialog",yi),p("Popover",Ci),p("Tooltip",xi),p("HoverCard",wi),p("Carousel",vi)}function mi(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,N(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 gi(e,t){let n=g("div","pf-tab");return N(e,n,t),n}function hi(e,t){let n=g("div","pf-accordion");return N(e,n,t),n}function bi(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",N(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 yi(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(N(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 Ci(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)}N(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 xi(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",N(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 wi(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 N(e,r,t),n.addEventListener("mouseenter",()=>{r.style.display="block"}),n.addEventListener("mouseleave",()=>{r.style.display="none"}),n.appendChild(r),n}function vi(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",N(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 ki(e){if(!S(e))return{};return Object.fromEntries(Object.entries(e).map(([t,n])=>[t,Array.isArray(n)?n.filter(Le):[]]))}function Pn(){p("ForEach",Si),p("If",$n),p("Elif",Ei),p("Else",Ri),p("Condition",Ti),p("Define",Ai),p("Use",Mi),p("Slot",Ni)}function Si(e,t){let n=document.createDocumentFragment(),r=b(e.expression);if(!r)return n;let o;if(J(r)){let s=G(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 $n(e,t){if(On(b(e.condition)??"",t)){let r=document.createDocumentFragment();if(e.children)ie(e.children,r,t);return r}return document.createDocumentFragment()}function Ei(e,t){return $n(e,t)}function Ri(e,t){let n=document.createDocumentFragment();if(e.children)ie(e.children,n,t);return n}function On(e,t){if(!e)return!1;if(J(e))return Boolean(G(e,t.store,t.scope));return Boolean(t.store.get(e))}function Ti(e,t){let n=document.createDocumentFragment(),{cases:r,else:o}=e;if(r){for(let i of r)if(On(i.when,t)){if(i.children)ie(i.children,n,t);return n}}if(o)ie(o,n,t);return n}function Ai(e,t){let n=b(e.name);if(n&&e.children)t.templates=t.templates??{},t.templates[n]=e.children;return document.createDocumentFragment()}function Mi(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??{},...ki(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 Ni(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",Li),p("AlertTitle",Hi),p("AlertDescription",Pi)}function Li(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 N(e,n,t),n}function Hi(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 Pi(e,t){let n=g("p","pf-alert-description");return n.textContent=w(e.content,t),n.style.fontSize="14px",n}function In(){p("Image",$i),p("Audio",Oi),p("Video",Di),p("Embed",Ii),p("Svg",Fi),p("DropZone",Vi),p("Mermaid",_i)}function $i(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 Oi(e,t){let n=document.createElement("audio");return n.className="pf-audio",n.src=w(e.src,t),n.controls=!0,n}function Di(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 Ii(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 ji=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 Fi(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 jn(i),n.appendChild(document.importNode(i,!0)),n}function jn(e){let t=Array.from(e.children);for(let n of t){if(!ji.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)}jn(n)}}function Bi(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 Vi(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)=>Bi(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)O(P(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 _i(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 zi="https://cdn.jsdelivr.net/npm/pdfjs-dist@4.9/build/pdf.min.mjs",Wi="https://cdn.jsdelivr.net/npm/pdfjs-dist@4.9/build/pdf.worker.min.mjs",Tt=null,et=null;function Ki(e){return S(e)&&typeof e.getDocument==="function"&&S(e.GlobalWorkerOptions)}function At(e,t){let n=typeof e==="string"&&e.trim()!==""?Number(e):e;return typeof n==="number"&&Number.isFinite(n)?n:t}function Ji(e){return e==="fit-page"||e==="fit-width"?e:At(e,0)||"fit-width"}async function Gi(){if(Tt)return Tt;if(et)return et;return et=import(zi).then((e)=>{if(!Ki(e))throw Error("PDF.js did not load");let t=e;return t.GlobalWorkerOptions.workerSrc=Wi,Tt=t,t}),et}function Bn(){p("PdfViewer",qi)}function qi(e,t){let n=g("div","pf-pdf-viewer"),r=e.src!=null?w(e.src,t):void 0,o=b(e.data),i=At(e.page,1),s=Ji(e.zoom),a=e.toolbar!==!1,l=At(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),Ui(n,c,{src:r,data:o,initialPage:i,zoom:s,showToolbar:a}),n}async function Ui(e,t,n){try{let r=await Gi(),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=Xi(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 Xi(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",Fn(o),o.addEventListener("click",n.onPrev);let i=document.createElement("button");i.textContent="›",i.title="Next page",i.className="pf-pdf-btn",Fn(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 Fn(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 tt(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 Vn(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 _n(e,t,n,r,o){let i=Vn(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=Nt(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 zn(e,t,n,r){let o=Vn(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=Nt(i,r),e.appendChild(a)}}function Mt(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 nt(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=W(`{{ __v | ${t} }}`,{...n,scope:{...n.scope,__v:e}});return k(r??e)}function Nt(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 Lt(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 Nt(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 $e(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 Ht(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 Pt(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">${rt(r)}</div>`;for(let y of o)l+='<div class="pf-chart-tooltip-row">',l+=`<span class="pf-chart-tooltip-dot" style="background:${rt(y.color)}"></span>`,l+=`<span>${rt(y.label)}:</span> <strong>${rt(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 rt(e){return e.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""")}function we(e,t,n,r,o,i){let s=()=>{Pt(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 Wn(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=()=>Pt(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 Kn(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(Pt(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 Ee(W(e.data,t))}function Jn(e,t){let n=W(e.data,t);if(!Array.isArray(n)||n.length===0)return;return n.filter((r)=>typeof r==="number"&&Number.isFinite(r))}function Yi(e){return e==="left"||e==="right"?e:void 0}function Zi(e){if(!S(e)||typeof e.dataKey!=="string")return;let t=b(e.label),n=b(e.color),r=Yi(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=Zi(t);return n?[n]:[]})}function de(e,t){return D(e.height)??t}function Oe(e,t){return Math.max(...e.flatMap((n)=>t.map((r)=>Number(n[r.dataKey]??0))),1)}function $t(e,t){return{valueKey:b(e.dataKey)??t[0]?.dataKey,nameKey:b(e.nameKey)??b(e.tooltipXKey)??b(e.xAxis)}}function Ot(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 Gn(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?Oe(t.rows,r):1,a=i?Oe(t.rows,o):1,l=400,c=tt(400,t.height,t.showYAxis,i),u=te(400,t.height,n);if(t.showYAxis)_n(u,c,s,t.showGrid,ce(e));if(i)zn(u,c,a,t.yAxisRightFormat);return nt(u,c),{layout:c,svg:u,leftMax:s,rightMax:a}}function ot(e,t){return e?(n)=>le(n,e,t):void 0}function qn(e,t){let n=g("div","pf-chart pf-bar-chart"),r=Ot(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}=Gn(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)Mt(a,o,r.xAxisKey,(m)=>s.plotLeft+m*u+u/2,s.plotBottom,ot(r.xAxisFormat,t));if(r.showTooltip){let m=re(n,a),h=Lt(t,ce(e),r.yAxisRightFormat);Wn(m,a,o,i,s,r.tooltipXKey??r.xAxisKey,h,ot(r.tooltipXFormat,t))}return ne(n,i,r.showLegend),n.appendChild(a),n}function Qi(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 es(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 ts(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 ns(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 Dt(e,t){let n=g("div",`pf-chart pf-${e.type.toLowerCase()}-chart`),r=Ot(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}=Gn(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,H=B?a.plotBottom:a.plotBottom-Number(A)/x*a.plotHeight;return{x:d(E),y:H,isNull:B}});if(s)Qi(l,R,a.plotBottom,v);es(l,R,v,y),m.push(ts(l,R,v))}let h=ns(l,a);if(r.xAxisKey)Mt(l,o,r.xAxisKey,d,a.plotBottom,ot(r.xAxisFormat,t));if(r.showTooltip){let C=re(n,l),f=Lt(t,ce(e),r.yAxisRightFormat);Kn(C,l,o,i,a,r.tooltipXKey??r.xAxisKey,f,h,m,ot(r.tooltipXFormat,t))}return ne(n,i,r.showLegend),n.appendChild(l),n}function It(e,t){let n=ce(e);return(r)=>n?le(r,n,t):String(r)}function Un(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}=$t(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=It(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,H=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 ${H},${_} 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)}%`,pt=d+h*0.6*Math.cos(R+E/2);we(U,v,pt,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 Xn(e,t){let n=g("div","pf-chart pf-radial-chart"),r=me(e,t),o=ge(e),{valueKey:i,nameKey:s}=$t(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(D(e.innerRadius)??30,u-10)),m=D(e.startAngle)??180,h=D(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=It(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,H=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:H}),y.appendChild(z("path",{d:Ht(l,c,B,m,h),fill:"none",stroke:ue,"stroke-width":v,"stroke-linecap":"round"}));let Q=z("path",{d:Ht(l,c,B,m,_),fill:"none",stroke:H,"stroke-width":v,"stroke-linecap":"round"});if(T){let U=fe(l,c,B,(m+_)/2);we(Q,T,U.x,U.y,Z||i,[{label:i,value:R(C[A]),color:H}])}y.appendChild(Q)}return ne(n,E,e.showLegend!==!1),n.appendChild(y),n}function Yn(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=Oe(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},(H,_)=>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($e({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=It(e,t);for(let T=0;T<o.length;T++){let E=o[T],A=E.color??F[T%F.length],B=r.map((H,_)=>fe(u,d,Number(H[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 H=0;H<B.length;H++){let _=z("circle",{cx:B[H].x,cy:B[H].y,r:a?3:6,fill:a?A:"transparent","fill-opacity":a?1:0});if(v){let Y=i?r[H][i]:null,Z=Y!=null?k(Y):E.label??E.dataKey,Q=[{label:E.label??E.dataKey,value:R(Number(r[H][E.dataKey]??0)),color:A}];we(_,v,B[H].x,B[H].y,Z,Q)}x.appendChild(_)}}return ne(n,o,e.showLegend!==!1),n.appendChild(x),n}function Zn(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,H=tt(B,l,!0),_=te(B,l,"Scatter"),Y=(L)=>H.plotLeft+(L-f)/R*H.plotWidth,Z=(L)=>H.plotBottom-(L-x)/T*H.plotHeight,Q=4;for(let L=0;L<=Q;L++){let pe=x+T*L/Q,oe=Z(pe);if(_.appendChild($e({x:H.plotLeft-6,y:oe+3,"text-anchor":"end","font-size":ae,fill:X},m(pe))),c&&L>0)_.appendChild(z("line",{x1:H.plotLeft,y1:oe,x2:H.plotRight,y2:oe,stroke:ue,"stroke-width":1,"stroke-dasharray":"4 3"}))}nt(_,H);for(let L of[f,(f+y)/2,y])_.appendChild($e({x:Y(L),y:H.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]),pt=s?4+Math.sqrt(E[L]/A)*14:4,qt=z("circle",{cx:pe,cy:oe,r:pt,fill:u,"fill-opacity":s?0.6:0.85});if(U){let xr=[{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}]:[]],wr=a[0]?.label??"Point";we(qt,U,pe,oe,wr,xr)}_.appendChild(qt)}return ne(n,a,e.showLegend!==!1),n.appendChild(_),n}function Qn(e,t){let n=g("div","pf-chart pf-histogram"),r=Jn(e,t);if(!r)return n.textContent="No data",n;let o=D(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 er(){p("BarChart",qn),p("LineChart",Dt),p("AreaChart",Dt),p("PieChart",Un),p("RadarChart",Yn),p("ScatterChart",Zn),p("RadialChart",Xn),p("Histogram",Qn)}function tr(){p("Table",rs),p("TableHead",jt("thead")),p("TableBody",jt("tbody")),p("TableFooter",jt("tfoot")),p("TableRow",os),p("TableHeader",is),p("TableCell",ss),p("TableCaption",as),p("ExpandableRow",ls)}function rs(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",N(e,n,t),n}function jt(e){return(t,n)=>{let r=document.createElement(e);return r.className=`pf-${e}`,N(t,r,n),r}}function os(e,t){let n=document.createElement("tr");return n.className="pf-table-row",N(e,n,t),n}function is(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 ss(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 N(e,n,t),n}function as(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 ls(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",N(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 nr=!1;function it(){if(nr)return;nr=!0;let e=new Set(kt());wn(),Sn(),Tn(),An(),Mn(),Ln(),Hn(),Pn(),Dn(),In(),Bn(),er(),tr(),hn(kt().filter((t)=>!e.has(t)))}function Bt(e){return e.replace(/[^a-zA-Z0-9_-]/g,"")}function Vt(e){return e.replace(/[{}<>;]/g,"").replace(/\b(url|expression)\s*\(/gi,"")}function Ft(e,t=" "){return Object.entries(e).map(([n,r])=>`${t}--${Bt(n)}: ${Vt(r)};`).join(`
|
|
6
|
+
`)}function Oo(e,t){let n=document.createElement("kbd");return n.className="pf-kbd",n.textContent=w(e.content,t),n}function Tn(){p("Card",Do),p("CardHeader",Et("pf-card-header")),p("CardTitle",Rn("pf-card-title","h3")),p("CardDescription",Rn("pf-card-description","p")),p("CardContent",Et("pf-card-content")),p("CardFooter",Et("pf-card-footer"))}function Do(e,t){let n=g("div","pf-card");return n.style.overflow="hidden",N(e,n,t),n}function Et(e){return(t,n)=>{let r=g("div",e);return r.style.padding="16px 24px",N(t,r,n),r}}function Rn(e,t){return(n,r)=>{let o=document.createElement(t);return o.className=e,o.textContent=w(n.content,r),o}}function An(){p("DataTable",Io),p("Badge",jo),p("Dot",Fo),p("Metric",Bo),p("Ring",Vo),p("Progress",_o),p("Separator",zo),p("Loader",Wo),p("Icon",Ko),p("Sparkline",Jo)}function Io(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=W(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?W(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});O(P(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=W(`{{ $item.${x.accessor} }}`,{...t,scope:{...t.scope,$item:C}});else if(R=y?m:f[x.key],x.format&&R!=null)R=W(`{{ __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 jo(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),Go(n,r),n}function Fo(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 Bo(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 Vo(e,t){let n=g("div","pf-ring"),r=D(e.size)??80,o=D(e.thickness)??8,i=Number(W(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 _o(e,t){let n=g("div","pf-progress");n.setAttribute("role","progressbar");let r=Number(W(e.value,t)??0),o=D(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 zo(e,t){let n=document.createElement("hr");return n.className="pf-separator",n.style.border="none",n.style.margin="8px 0",n}function Wo(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 Ko(e,t){let n=g("span","pf-icon");return n.setAttribute("data-icon",w(e.name??e.content,t)),n}function Jo(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=D(e.width)??120,i=D(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 Go(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 Mn(){p("Form",qo),p("Input",Uo),p("Textarea",Ce(Xo)),p("Button",Yo),p("ButtonGroup",Zo),p("Checkbox",Qo),p("Switch",ei),p("Slider",Ce(ti)),p("Calendar",ri),p("DatePicker",Ce(oi)),p("Field",Pe("pf-field")),p("FieldTitle",xe("pf-field-title")),p("FieldDescription",xe("pf-field-description")),p("FieldContent",Pe("pf-field-content")),p("FieldError",xe("pf-field-error"))}function qo(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},O(P(e.onSubmit,s),"onSubmit")}}),N(e,n,t),n}function Nn(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 Ce(e){return(t,n)=>{let r=e(t,n);return r.style.display="flex",r.style.flexDirection="column",r.style.gap="4px",Nn(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 Uo(e,t){let n=g("div","pf-input-wrapper");n.style.display="flex",n.style.flexDirection="column",n.style.gap="4px",Nn(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)O(P(e.onChange,{...V(t),scope:{...t.scope,$event:r.value}}),"onChange")})}return Qe(r),n.appendChild(r),n}function Xo(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)O(P(e.onChange,{...V(t),scope:{...t.scope,$event:r.value}}),"onChange")})}return Qe(r),n.appendChild(r),n}function Yo(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),ni(n,r),e.size!=null)n.setAttribute("data-size",k(e.size));if(e.disabled===!0)n.disabled=!0;return n}function Zo(e,t){let n=g("div","pf-button-group");return n.style.display="flex",n.style.gap="8px",N(e,n,t),n}function Qo(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)O(P(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 ei(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)O(P(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 ti(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)O(P(e.onChange,{...V(t),scope:{...t.scope,$event:Number(r.value)}}),"onChange")})}return n.appendChild(r),n}function Qe(e){e.style.padding="8px 12px",e.style.fontSize="14px",e.style.width="100%",e.style.boxSizing="border-box"}function ni(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 Pe(e){return(t,n)=>{let r=g("div",e);return N(t,r,n),r}}function xe(e){return(t,n)=>{let r=g("span",e);return r.textContent=w(t.content,n),r}}function Rt(){let e=document.createElement("hr");return e.className="pf-separator",e.style.border="none",e.style.margin="4px 0",e}function ri(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)O(P(e.onChange,V(t)),"onChange")}),n.appendChild(r),n}function oi(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)O(P(e.onChange,V(t)),"onChange")}),n.appendChild(r),n}function Ln(){p("Select",Ce(ii)),p("SelectOption",li),p("SelectGroup",Pe("pf-select-group")),p("SelectLabel",xe("pf-select-label")),p("SelectSeparator",Rt),p("Radio",ci),p("RadioGroup",di),p("Combobox",Ce(pi)),p("ComboboxOption",ui),p("ComboboxGroup",Pe("pf-combobox-group")),p("ComboboxLabel",xe("pf-combobox-label")),p("ComboboxSeparator",Rt),p("ChoiceCard",fi)}function ii(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),Qe(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)ai(r,s);r.addEventListener("change",()=>{let a=si(r);if(t.store.set(i,a),e.onChange!=null)O(P(e.onChange,{...V(t),scope:{...t.scope,$event:a}}),"onChange")})}return n.appendChild(r),n}function si(e){if(!e.multiple)return e.value;return Array.from(e.selectedOptions,(t)=>t.value)}function ai(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 li(e,t){return g("span")}function ci(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 di(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)}N(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)O(P(e.onChange,V(t)),"onChange")}}),n}function pi(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",N(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",()=>{O(P(e.onChange,{...V(t),scope:{...t.scope,$event:r.value}}),"onChange")});return n.style.position="relative",n.appendChild(r),n.appendChild(s),n}function ui(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 fi(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 N(e,n,t),n}function Hn(){p("Tabs",mi),p("Tab",gi),p("Accordion",hi),p("AccordionItem",bi),p("Dialog",yi),p("Popover",Ci),p("Tooltip",xi),p("HoverCard",wi),p("Carousel",vi)}function mi(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,N(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 gi(e,t){let n=g("div","pf-tab");return N(e,n,t),n}function hi(e,t){let n=g("div","pf-accordion");return N(e,n,t),n}function bi(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",N(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 yi(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(N(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 Ci(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)}N(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 xi(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",N(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 wi(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 N(e,r,t),n.addEventListener("mouseenter",()=>{r.style.display="block"}),n.addEventListener("mouseleave",()=>{r.style.display="none"}),n.appendChild(r),n}function vi(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",N(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 ki(e){if(!S(e))return{};return Object.fromEntries(Object.entries(e).map(([t,n])=>[t,Array.isArray(n)?n.filter(Le):[]]))}function Pn(){p("ForEach",Si),p("If",$n),p("Elif",Ei),p("Else",Ri),p("Condition",Ti),p("Define",Ai),p("Use",Mi),p("Slot",Ni)}function Si(e,t){let n=document.createDocumentFragment(),r=b(e.expression);if(!r)return n;let o;if(J(r)){let s=G(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 $n(e,t){if(On(b(e.condition)??"",t)){let r=document.createDocumentFragment();if(e.children)ie(e.children,r,t);return r}return document.createDocumentFragment()}function Ei(e,t){return $n(e,t)}function Ri(e,t){let n=document.createDocumentFragment();if(e.children)ie(e.children,n,t);return n}function On(e,t){if(!e)return!1;if(J(e))return Boolean(G(e,t.store,t.scope));return Boolean(t.store.get(e))}function Ti(e,t){let n=document.createDocumentFragment(),{cases:r,else:o}=e;if(r){for(let i of r)if(On(i.when,t)){if(i.children)ie(i.children,n,t);return n}}if(o)ie(o,n,t);return n}function Ai(e,t){let n=b(e.name);if(n&&e.children)t.templates=t.templates??{},t.templates[n]=e.children;return document.createDocumentFragment()}function Mi(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??{},...ki(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 Ni(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",Li),p("AlertTitle",Hi),p("AlertDescription",Pi)}function Li(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 N(e,n,t),n}function Hi(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 Pi(e,t){let n=g("p","pf-alert-description");return n.textContent=w(e.content,t),n.style.fontSize="14px",n}function In(){p("Image",$i),p("Audio",Oi),p("Video",Di),p("Embed",Ii),p("Svg",Fi),p("DropZone",Vi),p("Mermaid",_i)}function $i(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 Oi(e,t){let n=document.createElement("audio");return n.className="pf-audio",n.src=w(e.src,t),n.controls=!0,n}function Di(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 Ii(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 ji=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 Fi(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 jn(i),n.appendChild(document.importNode(i,!0)),n}function jn(e){let t=Array.from(e.children);for(let n of t){if(!ji.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)}jn(n)}}function Bi(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 Vi(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)=>Bi(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)O(P(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 _i(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 zi="https://cdn.jsdelivr.net/npm/pdfjs-dist@4.9/build/pdf.min.mjs",Wi="https://cdn.jsdelivr.net/npm/pdfjs-dist@4.9/build/pdf.worker.min.mjs",Tt=null,et=null;function Ki(e){return S(e)&&typeof e.getDocument==="function"&&S(e.GlobalWorkerOptions)}function At(e,t){let n=typeof e==="string"&&e.trim()!==""?Number(e):e;return typeof n==="number"&&Number.isFinite(n)?n:t}function Ji(e){return e==="fit-page"||e==="fit-width"?e:At(e,0)||"fit-width"}async function Gi(){if(Tt)return Tt;if(et)return et;return et=import(zi).then((e)=>{if(!Ki(e))throw Error("PDF.js did not load");let t=e;return t.GlobalWorkerOptions.workerSrc=Wi,Tt=t,t}),et}function Bn(){p("PdfViewer",qi)}function qi(e,t){let n=g("div","pf-pdf-viewer"),r=e.src!=null?w(e.src,t):void 0,o=b(e.data),i=At(e.page,1),s=Ji(e.zoom),a=e.toolbar!==!1,l=At(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),Ui(n,c,{src:r,data:o,initialPage:i,zoom:s,showToolbar:a}),n}async function Ui(e,t,n){try{let r=await Gi(),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=Xi(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 Xi(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",Fn(o),o.addEventListener("click",n.onPrev);let i=document.createElement("button");i.textContent="›",i.title="Next page",i.className="pf-pdf-btn",Fn(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 Fn(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 tt(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 Vn(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 _n(e,t,n,r,o){let i=Vn(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=Nt(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 zn(e,t,n,r){let o=Vn(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=Nt(i,r),e.appendChild(a)}}function Mt(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 nt(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=W(`{{ __v | ${t} }}`,{...n,scope:{...n.scope,__v:e}});return k(r??e)}function Nt(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 Lt(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 Nt(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 $e(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 Ht(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 Pt(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">${rt(r)}</div>`;for(let y of o)l+='<div class="pf-chart-tooltip-row">',l+=`<span class="pf-chart-tooltip-dot" style="background:${rt(y.color)}"></span>`,l+=`<span>${rt(y.label)}:</span> <strong>${rt(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 rt(e){return e.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""")}function we(e,t,n,r,o,i){let s=()=>{Pt(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 Wn(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=()=>Pt(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 Kn(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(Pt(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 Ee(W(e.data,t))}function Jn(e,t){let n=W(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 Yi(e){return e==="left"||e==="right"?e:void 0}function Zi(e){if(!S(e)||typeof e.dataKey!=="string")return;let t=b(e.label),n=b(e.color),r=Yi(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=Zi(t);return n?[n]:[]})}function de(e,t){return D(e.height)??t}function Oe(e,t){return Math.max(...e.flatMap((n)=>t.map((r)=>Number(n[r.dataKey]??0))),1)}function $t(e,t){return{valueKey:b(e.dataKey)??t[0]?.dataKey,nameKey:b(e.nameKey)??b(e.tooltipXKey)??b(e.xAxis)}}function Ot(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 Gn(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?Oe(t.rows,r):1,a=i?Oe(t.rows,o):1,l=400,c=tt(400,t.height,t.showYAxis,i),u=te(400,t.height,n);if(t.showYAxis)_n(u,c,s,t.showGrid,ce(e));if(i)zn(u,c,a,t.yAxisRightFormat);return nt(u,c),{layout:c,svg:u,leftMax:s,rightMax:a}}function ot(e,t){return e?(n)=>le(n,e,t):void 0}function qn(e,t){let n=g("div","pf-chart pf-bar-chart"),r=Ot(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}=Gn(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)Mt(a,o,r.xAxisKey,(m)=>s.plotLeft+m*u+u/2,s.plotBottom,ot(r.xAxisFormat,t));if(r.showTooltip){let m=re(n,a),h=Lt(t,ce(e),r.yAxisRightFormat);Wn(m,a,o,i,s,r.tooltipXKey??r.xAxisKey,h,ot(r.tooltipXFormat,t))}return ne(n,i,r.showLegend),n.appendChild(a),n}function Qi(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 es(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 ts(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 ns(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 Dt(e,t){let n=g("div",`pf-chart pf-${e.type.toLowerCase()}-chart`),r=Ot(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}=Gn(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,H=B?a.plotBottom:a.plotBottom-Number(A)/x*a.plotHeight;return{x:d(E),y:H,isNull:B}});if(s)Qi(l,R,a.plotBottom,v);es(l,R,v,y),m.push(ts(l,R,v))}let h=ns(l,a);if(r.xAxisKey)Mt(l,o,r.xAxisKey,d,a.plotBottom,ot(r.xAxisFormat,t));if(r.showTooltip){let C=re(n,l),f=Lt(t,ce(e),r.yAxisRightFormat);Kn(C,l,o,i,a,r.tooltipXKey??r.xAxisKey,f,h,m,ot(r.tooltipXFormat,t))}return ne(n,i,r.showLegend),n.appendChild(l),n}function It(e,t){let n=ce(e);return(r)=>n?le(r,n,t):String(r)}function Un(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}=$t(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=It(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,H=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 ${H},${_} 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)}%`,pt=d+h*0.6*Math.cos(R+E/2);we(U,v,pt,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 Xn(e,t){let n=g("div","pf-chart pf-radial-chart"),r=me(e,t),o=ge(e),{valueKey:i,nameKey:s}=$t(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(D(e.innerRadius)??30,u-10)),m=D(e.startAngle)??180,h=D(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=It(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,H=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:H}),y.appendChild(z("path",{d:Ht(l,c,B,m,h),fill:"none",stroke:ue,"stroke-width":v,"stroke-linecap":"round"}));let Q=z("path",{d:Ht(l,c,B,m,_),fill:"none",stroke:H,"stroke-width":v,"stroke-linecap":"round"});if(T){let U=fe(l,c,B,(m+_)/2);we(Q,T,U.x,U.y,Z||i,[{label:i,value:R(C[A]),color:H}])}y.appendChild(Q)}return ne(n,E,e.showLegend!==!1),n.appendChild(y),n}function Yn(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=Oe(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},(H,_)=>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($e({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=It(e,t);for(let T=0;T<o.length;T++){let E=o[T],A=E.color??F[T%F.length],B=r.map((H,_)=>fe(u,d,Number(H[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 H=0;H<B.length;H++){let _=z("circle",{cx:B[H].x,cy:B[H].y,r:a?3:6,fill:a?A:"transparent","fill-opacity":a?1:0});if(v){let Y=i?r[H][i]:null,Z=Y!=null?k(Y):E.label??E.dataKey,Q=[{label:E.label??E.dataKey,value:R(Number(r[H][E.dataKey]??0)),color:A}];we(_,v,B[H].x,B[H].y,Z,Q)}x.appendChild(_)}}return ne(n,o,e.showLegend!==!1),n.appendChild(x),n}function Zn(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,H=tt(B,l,!0),_=te(B,l,"Scatter"),Y=(L)=>H.plotLeft+(L-f)/R*H.plotWidth,Z=(L)=>H.plotBottom-(L-x)/T*H.plotHeight,Q=4;for(let L=0;L<=Q;L++){let pe=x+T*L/Q,oe=Z(pe);if(_.appendChild($e({x:H.plotLeft-6,y:oe+3,"text-anchor":"end","font-size":ae,fill:X},m(pe))),c&&L>0)_.appendChild(z("line",{x1:H.plotLeft,y1:oe,x2:H.plotRight,y2:oe,stroke:ue,"stroke-width":1,"stroke-dasharray":"4 3"}))}nt(_,H);for(let L of[f,(f+y)/2,y])_.appendChild($e({x:Y(L),y:H.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]),pt=s?4+Math.sqrt(E[L]/A)*14:4,qt=z("circle",{cx:pe,cy:oe,r:pt,fill:u,"fill-opacity":s?0.6:0.85});if(U){let xr=[{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}]:[]],wr=a[0]?.label??"Point";we(qt,U,pe,oe,wr,xr)}_.appendChild(qt)}return ne(n,a,e.showLegend!==!1),n.appendChild(_),n}function Qn(e,t){let n=g("div","pf-chart pf-histogram"),r=Jn(e,t);if(!r)return n.textContent="No data",n;let o=D(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 er(){p("BarChart",qn),p("LineChart",Dt),p("AreaChart",Dt),p("PieChart",Un),p("RadarChart",Yn),p("ScatterChart",Zn),p("RadialChart",Xn),p("Histogram",Qn)}function tr(){p("Table",rs),p("TableHead",jt("thead")),p("TableBody",jt("tbody")),p("TableFooter",jt("tfoot")),p("TableRow",os),p("TableHeader",is),p("TableCell",ss),p("TableCaption",as),p("ExpandableRow",ls)}function rs(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",N(e,n,t),n}function jt(e){return(t,n)=>{let r=document.createElement(e);return r.className=`pf-${e}`,N(t,r,n),r}}function os(e,t){let n=document.createElement("tr");return n.className="pf-table-row",N(e,n,t),n}function is(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 ss(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 N(e,n,t),n}function as(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 ls(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",N(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 nr=!1;function it(){if(nr)return;nr=!0;let e=new Set(kt());wn(),Sn(),Tn(),An(),Mn(),Ln(),Hn(),Pn(),Dn(),In(),Bn(),er(),tr(),hn(kt().filter((t)=>!e.has(t)))}function Bt(e){return e.replace(/[^a-zA-Z0-9_-]/g,"")}function Vt(e){return e.replace(/[{}<>;]/g,"").replace(/\b(url|expression)\s*\(/gi,"")}function Ft(e,t=" "){return Object.entries(e).map(([n,r])=>`${t}--${Bt(n)}: ${Vt(r)};`).join(`
|
|
7
7
|
`)}function rr(e){if(!e)return"";let t=[];if(e.light&&Object.keys(e.light).length>0)t.push(`:root {
|
|
8
8
|
${Ft(e.light)}
|
|
9
9
|
}`);if(e.dark&&Object.keys(e.dark).length>0){let n=Ft(e.dark);t.push(`.dark, [data-theme="dark"] {
|
|
@@ -13,4 +13,4 @@ ${n}
|
|
|
13
13
|
${Ft(e.dark," ")}
|
|
14
14
|
}
|
|
15
15
|
}`)}return t.join(`
|
|
16
|
-
`)}function ve(e,t){e.setAttribute("data-theme",t),e.classList.toggle("dark",t==="dark"),e.classList.toggle("light",t==="light")}function _t(e,t){if(!t)return;if(t.light)for(let[n,r]of Object.entries(t.light))e.style.setProperty(`--${Bt(n)}`,Vt(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=rr({dark:t.dark})}}function zt(e,t){if(!e||typeof document>"u")return;let n=(r)=>{for(let[o,i]of Object.entries(e))if(cs(o,r))r.preventDefault(),t(i)};return document.addEventListener("keydown",n),()=>document.removeEventListener("keydown",n)}function cs(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 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="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>',ir='<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>',sr={"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 ds(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 De(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=sr[n]??sr["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(ve(e,d),o)ve(document.documentElement,d);s.innerHTML=d==="dark"?ir:or;try{localStorage.setItem(r,d)}catch{}}let c=ds(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")){ve(e,h),s.innerHTML=h==="dark"?ir:or;try{localStorage.setItem(r,h)}catch{}}}}),u.observe(document.documentElement,{attributes:!0,attributeFilter:["data-theme"]});return()=>{u?.disconnect(),s.remove()}}function st(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 at(){return{callTool(e){return M.warn(`No MCP transport: callTool('${e}') ignored`),Promise.resolve(null)},sendMessage(e){return M.warn("No MCP transport: sendMessage ignored",e),Promise.resolve()}}}var ar="0.3.19";var ps=["light","dark","auto"],us=["inline","fullscreen","pip"];function lr(e){return S(e)&&typeof e.type==="string"&&(e.id===void 0||typeof e.id==="string")&&(e.payload===void 0||S(e.payload))}function lt(e){return typeof e==="boolean"?e:void 0}function cr(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:lt(t.toast),clipboard:lt(t.clipboard),navigation:lt(t.navigation),messaging:lt(t.messaging),displayModes:Wt(t.displayModes)},...n&&{theme:fs(n)},...r&&{toolInput:r},...o&&{meta:o}}}function fs(e){let t=b(e.fontCss);return{...ct({theme:e.colorScheme,styles:{variables:e.variables}}),...t!=null&&{fontCss:t}}}function Wt(e){let t=Array.isArray(e)?e:[];return us.filter((n)=>t.includes(n))}function ct(e){let t={},n=ps.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 ms(e){return S(e)&&e.jsonrpc==="2.0"}class he{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=hs();if(e)this.postFn=(n)=>e.postMessage(n);let t=(n)=>{if(this.hostOrigin!=="*"&&n.origin!==this.hostOrigin)return;let r=n.data;if(ms(r)){this.handleJsonRpc(r);return}if(!lr(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 dr;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(dr);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(cr(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",{...ct(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)?ct(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:Wt(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:ar},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 dr=()=>{};function Ie(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)gs(t.fontCss)}function gs(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 ke(){if(typeof window>"u")return!1;try{return window.self!==window.top}catch{return!0}}function hs(){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}async function dt(e){it();let t=e?.mode??"auto",n=t==="bridge"||t==="auto"&&ke(),r,o,i={capabilities:{}};if(n)o=new he(e?.hostOrigin),o.connect(),i=await o.initialize(e?.capabilities??{toolInput:!0}),r=o.createTransport();else if(e?.transport)r=st(e.transport);else r=at();if(i.theme&&typeof document<"u")Ie(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")Ie(document.documentElement,f)}),o.on("prefab:host-context-changed",(f)=>{u?.(f)});function h(f,...y){let x=Kt(f),v=new Re,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=Kt(f);return q.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"?Kt(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 Kt(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 pr=["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 mr=new Set(pr);function Se(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 Jt(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)xs(o.theme,n);if(o.css!==void 0)fr(o.css,"$.css",n);if(o.stylesheets!==void 0)fr(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))Jt(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))Gt(c,`$.keyBindings.${l}`,n);return{valid:n.length===0,errors:n}}function gr(e){return Se(e).valid}function Jt(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&&!mr.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++)Jt(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)Gt(o[s],`${t}.${s}`,n);for(let[s,a]of Object.entries(o)){if(s==="type"||Cs.has(s)||i.includes(s))continue;if(ur(a)||Array.isArray(a)&&a.some(ur))n.push({path:`${t}.${s}`,message:`Components under "${s}" are ignored by the renderer; move them into "children"`})}}var Cs=new Set(["children","fallback","trigger","empty","else","summary"]);function ur(e){return S(e)&&typeof e.type==="string"&&mr.has(e.type)}function Gt(e,t,n){if(Array.isArray(e)){for(let i=0;i<e.length;i++)Gt(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 fr(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 xs(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 q={mount(e,t,n){if(it(),n?.validate!==!1)for(let x of Se(t).errors)M.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))hr(x,v,o);let i=new Re(r.state),s;if(n?.transport&&"callTool"in n.transport)s=n.transport;else if(n?.transport)s=st(n.transport);else s=at();let a=n?.onToast??vs,l=new Ne;function c(x){if(!q.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)_t(e,v.theme);if(v.mode)br(e,v.mode);if(v.pipes)for(let[R,T]of Object.entries(v.pipes))hr(R,T,o);for(let R of m)R.remove();if(m.length=0,m.push(...yr(v.css,v.stylesheets)),Cr(e,v.layout),h?.(),h=void 0,v.keyBindings)h=zt(v.keyBindings,(R)=>{O(P(R,{store:i,transport:s,scope:{},rerender:()=>y(),remount:c,onToast:a}),"keyBinding")});y(),u(v)}function u(x){if(x.onMount!=null)O(P(x.onMount,d),"onMount")}let d={store:i,scope:{},transport:s,rerender:()=>y(),remount:c,onToast:a,defs:r.defs,destroyRegistry:l};if(_t(e,r.theme),r.mode)br(e,r.mode);Cr(e,r.layout);let m=yr(r.css,r.stylesheets),h;if(r.keyBindings)h=zt(r.keyBindings,(x)=>{O(P(x,{store:i,transport:s,scope:{},rerender:()=>y(),remount:c,onToast:a}),"keyBinding")});let C,f=n?.themeToggle??!0;if(f!==!1)C=De(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)O(P(x.update.actions,d),"update action")},store:i,destroy(){l.flush(),C?.(),h?.(),on(),ln();for(let x of m)x.remove();for(let x of o.tracked)Ae(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 ws(e){if(e instanceof EvalError)return!0;return e instanceof Error&&/unsafe-eval|Content Security Policy|call to Function/i.test(e.message)}function hr(e,t,n){if(rn.has(e)){M.warn(`wire pipe "${e}" ignored — shadows built-in`);return}if(Be(e)!=null){M.debug(`wire pipe "${e}" — already registered, keeping local implementation`);return}if(n.evalBlocked)return;try{let r=Function("return ("+t+")")();if(typeof r!=="function"){M.warn(`wire pipe "${e}" — source did not evaluate to a function`);return}Te(e,r),n.tracked.push(e)}catch(r){if(ws(r)){n.evalBlocked=!0,M.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}M.warn(`wire pipe "${e}" — failed to hydrate:`,r)}}function vs(e){if(typeof document>"u")return;let t=Ss(),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 br(e,t){if(ve(e,t),typeof document<"u")ve(document.documentElement,t)}function ks(e){let t=e.trim();if(t.includes("{")||t.includes("}"))return!1;return/^(https?:)?\/\//i.test(t)||t.startsWith("/")||/\.css(\?|#|$)/i.test(t)}function yr(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(ks(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 Cr(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 Ss(){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:q}),Object.assign(window,{prefab:{app:dt,mount:q.mount.bind(q),isPrefabData:q.isPrefabData.bind(q),isPrefabUpdate:q.isPrefabUpdate.bind(q),Bridge:he,isIframe:ke,registerPipe:Te,unregisterPipe:Ae,listPipes:Fe,registerComponent:p,createThemeToggle:De,validateWireFormat:Se,setLogLevel:je}});let e=Reflect.get(window,"__PREFAB_DATA__");if(q.isPrefabData(e)){let t=document.getElementById("prefab-root");if(t)q.mount(t,e)}}})();
|
|
16
|
+
`)}function ve(e,t){e.setAttribute("data-theme",t),e.classList.toggle("dark",t==="dark"),e.classList.toggle("light",t==="light")}function _t(e,t){if(!t)return;if(t.light)for(let[n,r]of Object.entries(t.light))e.style.setProperty(`--${Bt(n)}`,Vt(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=rr({dark:t.dark})}}function zt(e,t){if(!e||typeof document>"u")return;let n=(r)=>{for(let[o,i]of Object.entries(e))if(cs(o,r))r.preventDefault(),t(i)};return document.addEventListener("keydown",n),()=>document.removeEventListener("keydown",n)}function cs(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 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="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>',ir='<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>',sr={"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 ds(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 De(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=sr[n]??sr["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(ve(e,d),o)ve(document.documentElement,d);s.innerHTML=d==="dark"?ir:or;try{localStorage.setItem(r,d)}catch{}}let c=ds(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")){ve(e,h),s.innerHTML=h==="dark"?ir:or;try{localStorage.setItem(r,h)}catch{}}}}),u.observe(document.documentElement,{attributes:!0,attributeFilter:["data-theme"]});return()=>{u?.disconnect(),s.remove()}}function st(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 at(){return{callTool(e){return M.warn(`No MCP transport: callTool('${e}') ignored`),Promise.resolve(null)},sendMessage(e){return M.warn("No MCP transport: sendMessage ignored",e),Promise.resolve()}}}var ar="0.3.20";var ps=["light","dark","auto"],us=["inline","fullscreen","pip"];function lr(e){return S(e)&&typeof e.type==="string"&&(e.id===void 0||typeof e.id==="string")&&(e.payload===void 0||S(e.payload))}function lt(e){return typeof e==="boolean"?e:void 0}function cr(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:lt(t.toast),clipboard:lt(t.clipboard),navigation:lt(t.navigation),messaging:lt(t.messaging),displayModes:Wt(t.displayModes)},...n&&{theme:fs(n)},...r&&{toolInput:r},...o&&{meta:o}}}function fs(e){let t=b(e.fontCss);return{...ct({theme:e.colorScheme,styles:{variables:e.variables}}),...t!=null&&{fontCss:t}}}function Wt(e){let t=Array.isArray(e)?e:[];return us.filter((n)=>t.includes(n))}function ct(e){let t={},n=ps.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 ms(e){return S(e)&&e.jsonrpc==="2.0"}class he{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=hs();if(e)this.postFn=(n)=>e.postMessage(n);let t=(n)=>{if(this.hostOrigin!=="*"&&n.origin!==this.hostOrigin)return;let r=n.data;if(ms(r)){this.handleJsonRpc(r);return}if(!lr(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 dr;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(dr);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(cr(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",{...ct(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)?ct(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:Wt(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:ar},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 dr=()=>{};function Ie(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)gs(t.fontCss)}function gs(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 ke(){if(typeof window>"u")return!1;try{return window.self!==window.top}catch{return!0}}function hs(){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}async function dt(e){it();let t=e?.mode??"auto",n=t==="bridge"||t==="auto"&&ke(),r,o,i={capabilities:{}};if(n)o=new he(e?.hostOrigin),o.connect(),i=await o.initialize(e?.capabilities??{toolInput:!0}),r=o.createTransport();else if(e?.transport)r=st(e.transport);else r=at();if(i.theme&&typeof document<"u")Ie(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")Ie(document.documentElement,f)}),o.on("prefab:host-context-changed",(f)=>{u?.(f)});function h(f,...y){let x=Kt(f),v=new Re,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=Kt(f);return q.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"?Kt(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 Kt(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 pr=["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 mr=new Set(pr);function Se(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 Jt(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)xs(o.theme,n);if(o.css!==void 0)fr(o.css,"$.css",n);if(o.stylesheets!==void 0)fr(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))Jt(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))Gt(c,`$.keyBindings.${l}`,n);return{valid:n.length===0,errors:n}}function gr(e){return Se(e).valid}function Jt(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&&!mr.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++)Jt(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)Gt(o[s],`${t}.${s}`,n);for(let[s,a]of Object.entries(o)){if(s==="type"||Cs.has(s)||i.includes(s))continue;if(ur(a)||Array.isArray(a)&&a.some(ur))n.push({path:`${t}.${s}`,message:`Components under "${s}" are ignored by the renderer; move them into "children"`})}}var Cs=new Set(["children","fallback","trigger","empty","else","summary"]);function ur(e){return S(e)&&typeof e.type==="string"&&mr.has(e.type)}function Gt(e,t,n){if(Array.isArray(e)){for(let i=0;i<e.length;i++)Gt(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 fr(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 xs(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 q={mount(e,t,n){if(it(),n?.validate!==!1)for(let x of Se(t).errors)M.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))hr(x,v,o);let i=new Re(r.state),s;if(n?.transport&&"callTool"in n.transport)s=n.transport;else if(n?.transport)s=st(n.transport);else s=at();let a=n?.onToast??vs,l=new Ne;function c(x){if(!q.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)_t(e,v.theme);if(v.mode)br(e,v.mode);if(v.pipes)for(let[R,T]of Object.entries(v.pipes))hr(R,T,o);for(let R of m)R.remove();if(m.length=0,m.push(...yr(v.css,v.stylesheets)),Cr(e,v.layout),h?.(),h=void 0,v.keyBindings)h=zt(v.keyBindings,(R)=>{O(P(R,{store:i,transport:s,scope:{},rerender:()=>y(),remount:c,onToast:a}),"keyBinding")});y(),u(v)}function u(x){if(x.onMount!=null)O(P(x.onMount,d),"onMount")}let d={store:i,scope:{},transport:s,rerender:()=>y(),remount:c,onToast:a,defs:r.defs,destroyRegistry:l};if(_t(e,r.theme),r.mode)br(e,r.mode);Cr(e,r.layout);let m=yr(r.css,r.stylesheets),h;if(r.keyBindings)h=zt(r.keyBindings,(x)=>{O(P(x,{store:i,transport:s,scope:{},rerender:()=>y(),remount:c,onToast:a}),"keyBinding")});let C,f=n?.themeToggle??!0;if(f!==!1)C=De(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)O(P(x.update.actions,d),"update action")},store:i,destroy(){l.flush(),C?.(),h?.(),on(),ln();for(let x of m)x.remove();for(let x of o.tracked)Ae(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 ws(e){if(e instanceof EvalError)return!0;return e instanceof Error&&/unsafe-eval|Content Security Policy|call to Function/i.test(e.message)}function hr(e,t,n){if(rn.has(e)){M.warn(`wire pipe "${e}" ignored — shadows built-in`);return}if(Be(e)!=null){M.debug(`wire pipe "${e}" — already registered, keeping local implementation`);return}if(n.evalBlocked)return;try{let r=Function("return ("+t+")")();if(typeof r!=="function"){M.warn(`wire pipe "${e}" — source did not evaluate to a function`);return}Te(e,r),n.tracked.push(e)}catch(r){if(ws(r)){n.evalBlocked=!0,M.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}M.warn(`wire pipe "${e}" — failed to hydrate:`,r)}}function vs(e){if(typeof document>"u")return;let t=Ss(),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 br(e,t){if(ve(e,t),typeof document<"u")ve(document.documentElement,t)}function ks(e){let t=e.trim();if(t.includes("{")||t.includes("}"))return!1;return/^(https?:)?\/\//i.test(t)||t.startsWith("/")||/\.css(\?|#|$)/i.test(t)}function yr(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(ks(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 Cr(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 Ss(){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:q}),Object.assign(window,{prefab:{app:dt,mount:q.mount.bind(q),isPrefabData:q.isPrefabData.bind(q),isPrefabUpdate:q.isPrefabUpdate.bind(q),Bridge:he,isIframe:ke,registerPipe:Te,unregisterPipe:Ae,listPipes:Fe,registerComponent:p,createThemeToggle:De,validateWireFormat:Se,setLogLevel:je}});let e=Reflect.get(window,"__PREFAB_DATA__");if(q.isPrefabData(e)){let t=document.getElementById("prefab-root");if(t)q.mount(t,e)}}})();
|
package/package.json
CHANGED