@synertech/ui 0.43.0 → 0.44.0

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/dist/index.cjs CHANGED
@@ -1,6 +1,7 @@
1
- 'use strict';var el=require('react'),jsxRuntime=require('react/jsx-runtime'),reactDom=require('react-dom'),client=require('react-dom/client'),Ix=require('dompurify'),Ax=require('react-markdown'),zx=require('remark-gfm');function _interopDefault(e){return e&&e.__esModule?e:{default:e}}function _interopNamespace(e){if(e&&e.__esModule)return e;var n=Object.create(null);if(e){Object.keys(e).forEach(function(k){if(k!=='default'){var d=Object.getOwnPropertyDescriptor(e,k);Object.defineProperty(n,k,d.get?d:{enumerable:true,get:function(){return e[k]}});}})}n.default=e;return Object.freeze(n)}var el__namespace=/*#__PURE__*/_interopNamespace(el);var Ix__default=/*#__PURE__*/_interopDefault(Ix);var Ax__default=/*#__PURE__*/_interopDefault(Ax);var zx__default=/*#__PURE__*/_interopDefault(zx);function g(...e){return e.filter(Boolean).join(" ")}var Mc=el.createContext(null),Ic=el.createContext(null);function Ii(){let e=el.useContext(Mc);if(!e)throw new Error("Accordion sub-components must be used within <Accordion>");return e}function Ac(){let e=el.useContext(Ic);if(!e)throw new Error("AccordionTrigger/AccordionContent must be used within <AccordionItem>");return e}var zc={sm:{trigger:"px-3 py-2",content:"px-3 pb-2",text:"text-sm",icon:"w-3.5 h-3.5"},md:{trigger:"px-4 py-3",content:"px-4 pb-3",text:"text-base",icon:"w-4 h-4"},lg:{trigger:"px-5 py-4",content:"px-5 pb-4",text:"text-lg",icon:"w-5 h-5"}},Xg=({className:e})=>jsxRuntime.jsx("svg",{className:e,viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true",children:jsxRuntime.jsx("path",{fillRule:"evenodd",d:"M5.23 7.21a.75.75 0 011.06.02L10 11.168l3.71-3.938a.75.75 0 111.08 1.04l-4.25 4.5a.75.75 0 01-1.08 0l-4.25-4.5a.75.75 0 01.02-1.06z",clipRule:"evenodd"})}),Gg={default:"border border-gray-200 dark:border-gray-700 rounded-lg divide-y divide-gray-200 dark:divide-gray-700",bordered:"border-2 border-gray-300 dark:border-gray-600 rounded-lg divide-y divide-gray-300 dark:divide-gray-600",separated:"space-y-2",ghost:""},Kg={default:"",bordered:"",separated:"border border-gray-200 dark:border-gray-700 rounded-lg overflow-hidden",ghost:"border-b border-gray-200 dark:border-gray-700 last:border-b-0"};function Ug({type:e="single",value:t,defaultValue:r,onValueChange:n,collapsible:o=false,variant:a="default",size:s="md",disabled:l=false,iconPosition:i="right",icon:c,hideIcon:d=false,className:u,children:f}){let[m,p]=el.useState(()=>r?Array.isArray(r)?r:[r]:[]),w=t!==void 0,v=w?Array.isArray(t)?t:[t]:m,x=el.useCallback(I=>{let S;e==="single"?v.includes(I)?S=o?[]:[I]:S=[I]:S=v.includes(I)?v.filter(L=>L!==I):[...v,I],w||p(S),n?.(e==="single"?S[0]??"":S);},[e,v,o,w,n]),h=el.useMemo(()=>({openItems:v,toggle:x,variant:a,size:s,disabled:l,iconPosition:i,icon:c??null,hideIcon:d}),[v,x,a,s,l,i,c,d]);return jsxRuntime.jsx(Mc.Provider,{value:h,children:jsxRuntime.jsx("div",{className:g(Gg[a],u),"data-testid":"accordion",children:f})})}function Yg({value:e,disabled:t,className:r,children:n}){let o=Ii(),a=o.openItems.includes(e),s=t??o.disabled,l=el.useId(),i=`accordion-trigger-${l}`,c=`accordion-content-${l}`,d=el.useMemo(()=>({value:e,isOpen:a,disabled:s,triggerId:i,contentId:c}),[e,a,s,i,c]);return jsxRuntime.jsx(Ic.Provider,{value:d,children:jsxRuntime.jsx("div",{className:g(Kg[o.variant],r),"data-state":a?"open":"closed","data-testid":"accordion-item",children:n})})}function qg({className:e,icon:t,children:r}){let n=Ii(),o=Ac(),a=zc[n.size],s=()=>{o.disabled||n.toggle(o.value);},l=d=>{(d.key==="Enter"||d.key===" ")&&(d.preventDefault(),s());},i=t??n.icon??jsxRuntime.jsx(Xg,{className:a.icon}),c=!n.hideIcon&&jsxRuntime.jsx("span",{className:g("shrink-0 text-gray-500 dark:text-gray-400 transition-transform duration-200",o.isOpen&&"rotate-180"),"data-testid":"accordion-icon",children:i});return jsxRuntime.jsxs("button",{type:"button",id:o.triggerId,"aria-expanded":o.isOpen,"aria-controls":o.contentId,disabled:o.disabled,onClick:s,onKeyDown:l,className:g("flex items-center w-full text-left font-medium transition-colors cursor-pointer",a.trigger,a.text,"text-gray-900 dark:text-gray-100",!o.disabled&&"hover:bg-gray-50 dark:hover:bg-gray-800/50",o.disabled&&"opacity-50 cursor-not-allowed",e),"data-testid":"accordion-trigger",children:[n.iconPosition==="left"&&c,jsxRuntime.jsx("span",{className:"flex-1",children:r}),n.iconPosition==="right"&&c]})}function jg({className:e,children:t}){let r=Ii(),n=Ac(),o=zc[r.size],a=el.useRef(null),[s,l]=el.useState(n.isOpen?void 0:0),i=el.useRef(true);return el.useEffect(()=>{if(i.current){i.current=false,l(n.isOpen?void 0:0);return}if(n.isOpen){let c=a.current;if(c){l(c.scrollHeight);let d=setTimeout(()=>l(void 0),200);return ()=>clearTimeout(d)}}else {let c=a.current;c&&(l(c.scrollHeight),requestAnimationFrame(()=>l(0)));}},[n.isOpen]),jsxRuntime.jsx("div",{id:n.contentId,role:"region","aria-labelledby":n.triggerId,className:"overflow-hidden transition-[height] duration-200 ease-in-out",style:{height:s===void 0?"auto":s},"data-testid":"accordion-content","data-state":n.isOpen?"open":"closed",children:jsxRuntime.jsx("div",{ref:a,className:g(o.content,"text-gray-600 dark:text-gray-400",o.text==="text-lg"?"text-base":"text-sm",e),children:t})})}function tp(...e){return e.filter(Boolean).join(" ")}var rp="@synertech/ui/AdvanceDetachable",np=300,op="width=800,height=600,menubar=no,toolbar=no,location=no,status=no,scrollbars=yes,resizable=yes",ap=0;function sp(){return `${Date.now()}-${++ap}-${Math.random().toString(36).slice(2,8)}`}function Wc(e){try{return JSON.stringify(e)}catch{return String(e)}}function Hc(e){try{return JSON.parse(e)}catch{return e}}function ip(e,t){e.querySelectorAll("style").forEach(r=>{let n=t.createElement("style");n.textContent=r.textContent,t.head.appendChild(n);}),e.querySelectorAll('link[rel="stylesheet"]').forEach(r=>{let n=r,o=t.createElement("link");o.rel="stylesheet",o.href=n.href,n.crossOrigin&&(o.crossOrigin=n.crossOrigin),t.head.appendChild(o);}),e.documentElement.className&&(t.documentElement.className=e.documentElement.className),e.body.className&&(t.body.className=e.body.className);}function lp(e,t){let r=new MutationObserver(n=>{for(let o of n)for(let a of Array.from(o.addedNodes))if(a instanceof HTMLStyleElement){let s=t.createElement("style");s.textContent=a.textContent,t.head.appendChild(s);}else if(a instanceof HTMLLinkElement&&a.rel==="stylesheet"){let s=t.createElement("link");s.rel="stylesheet",s.href=a.href,t.head.appendChild(s);}});return r.observe(e.head,{childList:true}),r}function cp(){return typeof BroadcastChannel<"u"}function dp({mode:e,id:t,title:r="",children:n,value:o,defaultValue:a,onValueChange:s,isDetached:l,defaultDetached:i=false,onDetachedChange:c,features:d,target:u,autoFocus:f=true,className:m,detachedBodyClassName:p,disabled:w=false,readOnly:v=false,closeOnMainWindowUnload:x=true,name:h,serialize:I,deserialize:S},L){let R=l!==void 0,[T,y]=el.useState(i),M=R?l:T,k=o!==void 0,[z,H]=el.useState(a),P=k?o:z,[B,C]=el.useState(null),b=el.useRef(null),E=el.useRef(null),N=el.useRef(null),W=el.useRef(null),F=el.useRef(false),K=el.useRef(null),j=el.useRef(null),A=el.useRef(null),[D]=el.useState(()=>`${Date.now().toString(36)}-${Math.random().toString(36).slice(2,8)}`),V=el.useRef({title:r,features:d,target:u,autoFocus:f,detachedBodyClassName:p,closeOnMainWindowUnload:x,disabled:w,readOnly:v,mode:e,id:t});V.current={title:r,features:d,target:u,autoFocus:f,detachedBodyClassName:p,closeOnMainWindowUnload:x,disabled:w,readOnly:v,mode:e,id:t};let O=el.useRef(I??Wc);O.current=I??Wc;let _=el.useRef(S??Hc);_.current=S??Hc;let X=el.useRef(s);X.current=s;let G=el.useRef(c);G.current=c;let $=el.useRef(M);$.current=M;let Y=`${rp}/${t}`,se=el.useCallback(()=>{N.current&&(clearInterval(N.current),N.current=null),W.current&&(W.current.disconnect(),W.current=null),C(null);},[]),ae=el.useCallback(()=>{E.current&&(E.current.close(),E.current=null),K.current&&typeof window<"u"&&(window.removeEventListener("message",K.current),K.current=null);},[]),U=el.useCallback(Ie=>{if(!(!Ie||Ie.channel!==Y)&&Ie.instanceId!==D&&!V.current.readOnly&&Ie.type==="value-sync"&&Ie.payload!==void 0){j.current=Ie.payload;let we=_.current(Ie.payload);k||H(we),X.current?.(we);}},[Y,D,k]),Q=el.useCallback(()=>{if(ae(),!(typeof window>"u"))if(cp()){let Ie=new BroadcastChannel(Y),we=pt=>U(pt.data);Ie.addEventListener("message",we),E.current=Ie;}else {let Ie=we=>{we.data?.channel===Y&&U(we.data);};window.addEventListener("message",Ie),K.current=Ie;}},[Y,ae,U]),le=el.useCallback(Ie=>{if(V.current.readOnly)return;let we=O.current(Ie);if(we===A.current)return;if(we===j.current){j.current=null;return}A.current=we;let pt={channel:Y,instanceId:D,messageId:sp(),origin:"main",timestamp:Date.now(),type:"value-sync",payload:we};E.current?E.current.postMessage(pt):b.current&&!b.current.closed&&b.current.postMessage(pt,"*");},[Y,D]),ye=el.useCallback(()=>{if(typeof window>"u"||V.current.disabled||F.current||b.current&&!b.current.closed)return;F.current=true;let Ie=V.current,we=window.open("",Ie.target||"",Ie.features||op);if(!we){F.current=false;return}b.current=we,we.document.title=Ie.title||document.title,Ie.detachedBodyClassName&&(we.document.body.className=Ie.detachedBodyClassName);let pt=we.document.createElement("div");we.document.body.appendChild(pt),C(pt),ip(document,we.document),W.current=lp(document,we.document),N.current=setInterval(()=>{we.closed&&(se(),b.current=null,R||y(false),G.current?.(false));},np),Ie.autoFocus&&we.focus(),F.current=false;},[R,se]),te=el.useCallback(()=>{b.current&&!b.current.closed&&b.current.close(),b.current=null,se();},[se]),Ce=el.useRef(ye);Ce.current=ye;let Pe=el.useRef(te);Pe.current=te;let Se=el.useRef(le);Se.current=le;let De=el.useCallback(()=>{V.current.disabled||(R||y(true),G.current?.(true));},[R]),Ne=el.useCallback(()=>{R||y(false),G.current?.(false);},[R]),re=el.useCallback(()=>{let Ie=!$.current;Ie&&V.current.disabled||(R||y(Ie),G.current?.(Ie));},[R]);el.useImperativeHandle(L,()=>({open:De,close:Ne,toggle:re,get isDetached(){return $.current},get window(){return b.current}}),[De,Ne,re]),el.useEffect(()=>(Q(),()=>ae()),[Q,ae]),el.useEffect(()=>{if(M)return Ce.current(),()=>Pe.current();Pe.current();},[M]),el.useEffect(()=>{P!==void 0&&Se.current(P);},[P]),el.useEffect(()=>{b.current&&!b.current.closed&&r&&(b.current.document.title=r);},[r]),el.useEffect(()=>{if(typeof window>"u")return;let Ie=()=>{V.current.closeOnMainWindowUnload&&b.current&&!b.current.closed&&b.current.close();};return window.addEventListener("beforeunload",Ie),()=>{window.removeEventListener("beforeunload",Ie),b.current&&!b.current.closed&&b.current.close(),b.current=null;}},[]);let fe=typeof n=="function"?n({open:De,close:Ne,toggle:re,detached:M,windowRef:b.current}):n,je=e==="clone"||!M,Dt=M&&B!==null;return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[h&&P!==void 0&&jsxRuntime.jsx("input",{type:"hidden",name:h,value:O.current(P)}),je&&jsxRuntime.jsx("div",{className:tp(m),children:fe}),Dt&&reactDom.createPortal(fe,B)]})}var Vc=el.forwardRef(dp);Vc.displayName="AdvanceDetachable";var Oc={closeModal:"Close modal",closeDrawer:"Close drawer",closeSidebar:"Close sidebar",openSidebar:"Open sidebar",expandSidebar:"Expand sidebar",collapseSidebar:"Collapse sidebar",sidebar:"Sidebar",enterFullScreen:"Enter full screen",exitFullScreen:"Exit full screen",confirm:"Confirm",cancel:"Cancel",markdownEditorUnavailable:"Markdown editor unavailable. Pass markdownEditor from @synertech/ui/markdown-editor.",chartShowTable:"Show data table",chartHideTable:"Hide data table",chartNoData:"No data",chartLoading:"Loading chart",chartOther:"Other",chartValue:"Value",chartTarget:"Target",chartIncrease:"Increase",chartDecrease:"Decrease",chartRunningTotal:"Running total",chartConversion:"Conversion",chartDropOff:"Drop-off",chartChange:"Change",chartMedian:"Median",chartCount:"Count",chartOutliers:"Outliers",chartOpen:"Open",chartHigh:"High",chartLow:"Low",chartClose:"Close",chartRise:"Up",chartFall:"Down",chartStart:"Start",chartEnd:"End",chartProgress:"Progress",chartToday:"Today",chartAnnotations:"Annotations",chartFilters:"Filters",chartPeriod:"Period",chartPeriodLast7Days:"Last 7 days",chartPeriodLast30Days:"Last 30 days",chartPeriodLast90Days:"Last 90 days",chartPeriodLast12Months:"Last 12 months",chartPeriodMonthToDate:"Month to date",chartPeriodQuarterToDate:"Quarter to date",chartPeriodYearToDate:"Year to date",chartPeriodCustom:"Custom range"},fp={closeModal:"Fermer la fen\xEAtre",closeDrawer:"Fermer le panneau",closeSidebar:"Fermer le menu lat\xE9ral",openSidebar:"Ouvrir le menu lat\xE9ral",expandSidebar:"D\xE9plier le menu lat\xE9ral",collapseSidebar:"Replier le menu lat\xE9ral",sidebar:"Menu lat\xE9ral",enterFullScreen:"Passer en plein \xE9cran",exitFullScreen:"Quitter le plein \xE9cran",confirm:"Confirmer",cancel:"Annuler",markdownEditorUnavailable:"\xC9diteur Markdown indisponible. Passez markdownEditor depuis @synertech/ui/markdown-editor.",chartShowTable:"Afficher le tableau de donn\xE9es",chartHideTable:"Masquer le tableau de donn\xE9es",chartNoData:"Aucune donn\xE9e",chartLoading:"Chargement du graphique",chartOther:"Autres",chartValue:"Valeur",chartTarget:"Objectif",chartIncrease:"Hausse",chartDecrease:"Baisse",chartRunningTotal:"Cumul",chartConversion:"Conversion",chartDropOff:"D\xE9perdition",chartChange:"\xC9cart",chartMedian:"M\xE9diane",chartCount:"Effectif",chartOutliers:"Valeurs aberrantes",chartOpen:"Ouverture",chartHigh:"Haut",chartLow:"Bas",chartClose:"Cl\xF4ture",chartRise:"Hausse",chartFall:"Baisse",chartStart:"D\xE9but",chartEnd:"Fin",chartProgress:"Avancement",chartToday:"Aujourd'hui",chartAnnotations:"Annotations",chartFilters:"Filtres",chartPeriod:"P\xE9riode",chartPeriodLast7Days:"7 derniers jours",chartPeriodLast30Days:"30 derniers jours",chartPeriodLast90Days:"90 derniers jours",chartPeriodLast12Months:"12 derniers mois",chartPeriodMonthToDate:"Mois en cours",chartPeriodQuarterToDate:"Trimestre en cours",chartPeriodYearToDate:"Ann\xE9e en cours",chartPeriodCustom:"P\xE9riode personnalis\xE9e"},Ai=el.createContext(Oc);function hp({labels:e,children:t}){let r=el.useContext(Ai),n=el.useMemo(()=>({...r,...e}),[r,e]);return jsxRuntime.jsx(Ai.Provider,{value:n,children:t})}function We(){return el.useContext(Ai)}function tr(e,t=11){return e.length*t*.6}function wr(e,t=11){let r=0;for(let n of e){let o=tr(n,t);o>r&&(r=o);}return r}function ha(e,t,r,n=12){if(e<=1||t<=0)return 1;let o=r+n,a=Math.max(1,Math.floor(t/o));return Math.max(1,Math.ceil(e/a))}var cs=10,us=15,ba=5,Qn=6,ls=4,yp=.1;function zi({x:e,y:t,text:r,align:n}){let o=tr(r,cs)+ba*2,a=n==="start"?e:e-o;return jsxRuntime.jsxs("g",{children:[jsxRuntime.jsx("rect",{x:a,y:t,width:o,height:us,rx:3,className:"fill-white stroke-gray-200 dark:fill-gray-800 dark:stroke-gray-700",strokeWidth:1}),jsxRuntime.jsx("text",{x:a+ba,y:t+us/2,dominantBaseline:"central",className:"fill-gray-600 text-[10px] dark:fill-gray-300",children:r})]})}function tn({annotations:e,xAt:t,yAt:r,width:n,height:o,bandwidth:a=0,layer:s="over"}){if(e.length===0)return null;if(s==="under"){let i=e.filter(c=>c.type==="band");return i.length===0?null:jsxRuntime.jsx("g",{"aria-hidden":"true",children:i.map((c,d)=>{let u=t(c.from),f=t(c.to);if(u===null||f===null)return null;let m=Math.max(0,Math.min(u,f)-a/2),w=Math.min(n,Math.max(u,f)+a/2)-m;if(w<=0)return null;let v=c.label??"",x=tr(v,cs)+ba*2;return jsxRuntime.jsxs("g",{children:[jsxRuntime.jsx("rect",{x:m,y:0,width:w,height:o,fill:c.color??"var(--color-chart-muted)",opacity:yp}),v&&x<=w?jsxRuntime.jsx(zi,{x:m+2,y:2,text:v,align:"start"}):null]},`band-${d}`)})})}let l=e.filter(i=>i.type!=="band");return l.length===0?null:jsxRuntime.jsx("g",{"aria-hidden":"true",children:l.map((i,c)=>{let d=t(i.x);if(d===null)return null;let u=i.color??"var(--color-chart-muted)";if(i.type==="line"){let x=i.label??"",h=tr(x,cs)+ba*2,I=d+Qn+h<=n?"start":"end";return jsxRuntime.jsxs("g",{children:[jsxRuntime.jsx("line",{x1:d,y1:0,x2:d,y2:o,stroke:u,strokeWidth:1,strokeDasharray:i.dashed===false?void 0:"3 3"}),x?jsxRuntime.jsx(zi,{x:I==="start"?d+Qn:d-Qn,y:2,text:x,align:I}):null]},`line-${c}`)}let f=r(i.y);if(!Number.isFinite(f))return null;let m=i.label??"",p=tr(m,cs)+ba*2,w=d+ls+Qn+p<=n?"start":"end",v=Math.min(Math.max(0,f-us-Qn),o-us);return jsxRuntime.jsxs("g",{children:[jsxRuntime.jsx("circle",{cx:d,cy:f,r:ls,fill:"none",stroke:u,strokeWidth:2}),m?jsxRuntime.jsx(zi,{x:w==="start"?d+ls+Qn:d-ls-Qn,y:v,text:m,align:w}):null]},`point-${c}`)})})}function Jn(e,t){if(!e||e.length===0)return "";let r=e.map(n=>n.label).filter(n=>!!n);return r.length===0?"":`${t}: ${r.join(", ")}`}var xp=10,vp={sm:"text-[10px]",md:"text-[11px]",lg:"text-xs"};function Ue({orientation:e,ticks:t,length:r,showLine:n=true,tickSize:o=4,tickPadding:a=6,label:s,size:l="md",className:i,...c}){let d=e==="bottom";return jsxRuntime.jsxs("g",{className:g(vp[l],i),"aria-hidden":"true",...c,children:[n&&jsxRuntime.jsx("line",{x1:0,y1:0,x2:d?r:0,y2:d?0:r,className:"stroke-gray-300 dark:stroke-gray-600",strokeWidth:1,shapeRendering:"crispEdges"}),t.map(u=>{let f=d?u.offset:0,m=d?0:u.offset;return jsxRuntime.jsxs("g",{transform:`translate(${f}, ${m})`,children:[o>0?jsxRuntime.jsx("line",{x1:0,y1:0,x2:d?0:-o,y2:d?o:0,className:"stroke-gray-300 dark:stroke-gray-600",strokeWidth:1}):null,jsxRuntime.jsx("text",{x:d?0:-(o+a),y:d?o+a:0,textAnchor:d?"middle":"end",dominantBaseline:d?"hanging":"middle",className:"fill-gray-500 dark:fill-gray-400 [font-variant-numeric:tabular-nums]",children:u.label})]},`${u.label}-${u.offset}`)}),s?jsxRuntime.jsx("text",{x:d?r/2:0,y:d?o+a+16:0,textAnchor:"middle",dominantBaseline:d?"hanging":"middle",transform:d?void 0:`translate(${-(o+a+wr(t.map(u=>u.label))+xp)}, ${r/2}) rotate(-90)`,className:"fill-gray-600 dark:fill-gray-300 font-medium",children:s}):null]})}var Cp={default:"stroke-gray-500 dark:stroke-gray-400",primary:"stroke-blue-600 dark:stroke-blue-500",success:"stroke-green-600 dark:stroke-green-500",warning:"stroke-yellow-500 dark:stroke-yellow-400",error:"stroke-red-600 dark:stroke-red-500",info:"stroke-cyan-600 dark:stroke-cyan-500"},kp={default:"text-gray-700 dark:text-gray-300",primary:"text-blue-600 dark:text-blue-400",success:"text-green-600 dark:text-green-400",warning:"text-yellow-600 dark:text-yellow-400",error:"text-red-600 dark:text-red-400",info:"text-cyan-600 dark:text-cyan-400"},wp={xs:24,sm:32,md:48,lg:64,xl:96},Np={xs:"text-[8px]",sm:"text-[10px]",md:"text-sm",lg:"text-base",xl:"text-xl"},Sp={thin:2,normal:4,thick:8};function Po({value:e=0,indeterminate:t=false,size:r="md",thickness:n="normal",color:o="primary",progressColor:a,trackColor:s,showValue:l=false,children:i,valueFormat:c,animated:d=true,className:u,...f}){let m=Math.min(100,Math.max(0,e)),p=wp[r],w=Sp[n],v=(p-w)/2,x=2*Math.PI*v,h=p/2,I=x-m/100*x,S=a||Cp[o],L=s||"stroke-gray-200 dark:stroke-gray-700",R=kp[o],T=i??(l&&!t?jsxRuntime.jsx("span",{className:g("font-semibold",Np[r],R),children:c?c(m):`${Math.round(m)}%`}):null);return jsxRuntime.jsxs("div",{className:g("relative inline-flex items-center justify-center",u),role:"progressbar","aria-valuenow":t?void 0:m,"aria-valuemin":0,"aria-valuemax":100,...f,children:[jsxRuntime.jsxs("svg",{width:p,height:p,viewBox:`0 0 ${p} ${p}`,className:g(t&&"animate-spin"),style:{transform:"rotate(-90deg)"},children:[jsxRuntime.jsx("circle",{cx:h,cy:h,r:v,fill:"none",strokeWidth:w,className:L}),jsxRuntime.jsx("circle",{cx:h,cy:h,r:v,fill:"none",strokeWidth:w,strokeLinecap:"round",strokeDasharray:x,strokeDashoffset:t?x*.75:I,className:g(S,d&&!t&&"transition-[stroke-dashoffset] duration-300 ease-out")})]}),T&&jsxRuntime.jsx("div",{className:"absolute inset-0 flex items-center justify-center",style:{transform:"rotate(0deg)"},children:T})]})}Po.displayName="CircularProgress";var Xc=640;function Wi(e={}){let{width:t,fallbackWidth:r=Xc}=e,n=el.useRef(null),[o,a]=el.useState(0);return el.useEffect(()=>{if(t!==void 0)return;let s=n.current;if(!s)return;let l=c=>{a(d=>Math.abs(d-c)<1?d:c);};if(l(s.getBoundingClientRect().width),typeof ResizeObserver>"u")return;let i=new ResizeObserver(c=>{for(let d of c)l(d.contentRect.width);});return i.observe(s),()=>i.disconnect()},[t]),t!==void 0?{ref:n,width:t,measured:true}:{ref:n,width:o>0?o:r,measured:o>0}}var Ep={sm:"text-xs",md:"text-sm",lg:"text-base"};function lt({title:e,description:t,height:r=240,width:n,size:o="md",legend:a,legendPosition:s="bottom",actions:l,loading:i=false,empty:c=false,emptyState:d,table:u,tableView:f=false,showTableLabel:m,hideTableLabel:p,noDataLabel:w,loadingLabel:v,ariaLabel:x,children:h,className:I,...S}){let L=We(),[R,T]=el.useState(false),y=el.useId(),M=`${y}-table`,k=`${y}-title`,z=`${y}-description`,{ref:H,width:P,measured:B}=Wi({width:n}),C=!!u&&f==="toggle",b=!!u&&(f===true||C&&R),W=jsxRuntime.jsx("div",{ref:H,className:"relative w-full",style:{height:r},"aria-busy":i||void 0,children:i&&c?jsxRuntime.jsx("div",{className:"flex h-full w-full items-center justify-center",children:jsxRuntime.jsx(Po,{indeterminate:true,size:"md","aria-label":v??L.chartLoading})}):c&&!i?jsxRuntime.jsx("div",{className:"flex h-full w-full items-center justify-center text-sm text-gray-500 dark:text-gray-400",children:d??w??L.chartNoData}):jsxRuntime.jsx("div",{className:g("h-full w-full transition-opacity duration-200",i&&"opacity-60"),children:typeof h=="function"?h({width:P,height:r,measured:B}):h})});return jsxRuntime.jsxs("figure",{className:g("flex w-full flex-col gap-3",I),"aria-label":x,"aria-labelledby":!x&&e?k:void 0,"aria-describedby":t?z:void 0,...S,children:[e||t||l?jsxRuntime.jsxs("figcaption",{className:"flex items-start justify-between gap-3",children:[jsxRuntime.jsxs("div",{className:"flex flex-col gap-0.5",children:[e?jsxRuntime.jsx("span",{id:k,className:g("font-semibold text-gray-900 dark:text-gray-100",Ep[o]),children:e}):null,t?jsxRuntime.jsx("span",{id:z,className:"text-xs text-gray-500 dark:text-gray-400",children:t}):null]}),l]}):null,a&&s==="top"?a:null,a&&s==="right"?jsxRuntime.jsxs("div",{className:"flex items-start gap-4",children:[jsxRuntime.jsx("div",{className:"min-w-0 grow",children:W}),a]}):W,a&&s==="bottom"?a:null,C&&jsxRuntime.jsx("div",{className:"flex",children:jsxRuntime.jsx("button",{type:"button",onClick:()=>T(F=>!F),"aria-expanded":R,"aria-controls":b?M:void 0,className:"cursor-pointer rounded-sm text-xs font-medium text-gray-600 underline underline-offset-2 hover:text-gray-900 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-blue-500 dark:text-gray-400 dark:hover:text-white",children:R?p??L.chartHideTable:m??L.chartShowTable})}),b&&jsxRuntime.jsx("div",{id:M,children:u})]})}var Gc=[];function _t({width:e,height:t,horizontal:r=Gc,vertical:n=Gc,className:o,...a}){return jsxRuntime.jsxs("g",{className:g("stroke-gray-200 dark:stroke-gray-700",o),strokeWidth:1,shapeRendering:"crispEdges","aria-hidden":"true",...a,children:[r.map(s=>jsxRuntime.jsx("line",{x1:0,y1:s,x2:e,y2:s},`h-${s}`)),n.map(s=>jsxRuntime.jsx("line",{x1:s,y1:0,x2:s,y2:t},`v-${s}`))]})}var eo="var(--color-chart-surface)",Hi=["solid","diagonal","diagonal-reverse","cross","dots","diagonal-wide","diagonal-reverse-wide","dots-wide"],Yc={solid:null,diagonal:{tile:6,rotate:45,stroke:2},"diagonal-reverse":{tile:6,rotate:-45,stroke:2},cross:{tile:6,rotate:45,stroke:1.25,crossed:true},dots:{tile:6,rotate:0,stroke:0,dot:1.5},"diagonal-wide":{tile:10,rotate:45,stroke:3},"diagonal-reverse-wide":{tile:10,rotate:-45,stroke:3},"dots-wide":{tile:10,rotate:0,stroke:0,dot:2.6}};function hs(e){return !Number.isFinite(e)||e<0?"solid":Hi[Math.floor(e)%Hi.length]}function fs(e,t){return `${e.replace(/[^a-zA-Z0-9_-]/g,"")}-texture-${Math.max(0,Math.floor(t))}`}function to(e,t,r,n){return !e||hs(r)==="solid"?n:`url(#${fs(t,r)})`}function ro({id:e,entries:t}){return jsxRuntime.jsx("defs",{children:t.map(({slot:r,color:n})=>{let o=Yc[hs(r)];if(!o)return null;let{tile:a,rotate:s,stroke:l,crossed:i,dot:c}=o;return jsxRuntime.jsxs("pattern",{id:fs(e,r),width:a,height:a,patternUnits:"userSpaceOnUse",patternTransform:s===0?void 0:`rotate(${s})`,children:[jsxRuntime.jsx("rect",{width:a,height:a,fill:n}),c?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("circle",{cx:a/4,cy:a/4,r:c,fill:eo}),jsxRuntime.jsx("circle",{cx:a*3/4,cy:a*3/4,r:c,fill:eo})]}):null,l>0?jsxRuntime.jsx("line",{x1:a/2,y1:0,x2:a/2,y2:a,stroke:eo,strokeWidth:l}):null,i?jsxRuntime.jsx("line",{x1:0,y1:a/2,x2:a,y2:a/2,stroke:eo,strokeWidth:l}):null]},fs(e,r))})})}function Bi(e,t){let r=Yc[hs(e)];if(!r)return {backgroundColor:t};let{tile:n,rotate:o,stroke:a,crossed:s,dot:l}=r;if(l)return {backgroundColor:t,backgroundImage:`radial-gradient(${eo} ${l-.4}px, transparent ${l}px)`,backgroundSize:`${n/2}px ${n/2}px`};let i=c=>`repeating-linear-gradient(${c}deg, ${eo} 0 ${a}px, transparent ${a}px ${n}px)`;return {backgroundColor:t,backgroundImage:s?`${i(o)}, ${i(o+90)}`:i(o)}}var Ap={line:"h-0.5 w-3 rounded-full",rect:"h-2.5 w-2.5 rounded-sm",dot:"h-2 w-2 rounded-full"},zp={sm:"text-[11px]",md:"text-xs",lg:"text-sm"};function Xt({items:e,position:t="bottom",marker:r="line",onToggle:n,size:o="md",className:a,...s}){return e.length===0?null:jsxRuntime.jsx("ul",{className:g("flex list-none flex-wrap gap-x-4 gap-y-1 p-0",t==="right"?"flex-col":"flex-row",t==="top"||t==="bottom"?"justify-center":"",zp[o],a),...s,children:e.map(l=>{let i=l.pattern!==void 0&&(l.marker??r)==="rect",c=jsxRuntime.jsx("span",{className:g("shrink-0",i?"h-3 w-3.5 rounded-sm":Ap[l.marker??r]),style:i?Bi(l.pattern,l.color):{backgroundColor:l.color},"aria-hidden":"true"}),d=jsxRuntime.jsx("span",{className:g(l.hidden&&"line-through"),children:l.label}),u=jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[c,d]}),f=g("flex items-center gap-1.5 text-gray-600 dark:text-gray-300",l.hidden&&"text-gray-400 dark:text-gray-500");return jsxRuntime.jsx("li",{children:n?jsxRuntime.jsx("button",{type:"button",onClick:()=>n(l.key),"aria-pressed":!l.hidden,className:g(f,"cursor-pointer rounded-sm hover:text-gray-900 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-blue-500 dark:hover:text-white"),children:u}):jsxRuntime.jsx("span",{className:f,children:u})},l.key)})})}function fn({children:e,className:t,...r}){return jsxRuntime.jsx("table",{className:g("w-full text-sm text-left rtl:text-right text-gray-500 dark:text-gray-400",t),...r,children:e})}function hn({children:e,className:t,...r}){return jsxRuntime.jsx("tbody",{className:g(t),...r,children:e})}function Gt({children:e,onClick:t,hidden:r=false,className:n,...o}){return jsxRuntime.jsx("td",{className:g("px-6 py-4",n),onClick:t,hidden:r,...o,children:e})}function bn({children:e,className:t,...r}){return jsxRuntime.jsx("thead",{className:g("text-xs text-gray-700 uppercase bg-gray-50 dark:bg-gray-700 dark:text-gray-400",t),...r,children:jsxRuntime.jsx("tr",{children:e})})}function St({children:e,onClick:t,hidden:r=false,className:n,sortable:o=false,...a}){return jsxRuntime.jsx("th",{scope:"col",className:g("px-6 py-3",o&&"cursor-pointer hover:bg-gray-100 dark:hover:bg-gray-600",n),onClick:t,hidden:r,...a,children:e})}function yn({children:e,onClick:t,clickable:r=true,className:n,...o}){return jsxRuntime.jsx("tr",{className:g("bg-white border-b dark:bg-gray-800 dark:border-gray-700",r&&"hover:bg-gray-50 hover:cursor-pointer dark:hover:bg-gray-600",n),onClick:t,...o,children:e})}var _p=8,bs=["var(--color-chart-1)","var(--color-chart-2)","var(--color-chart-3)","var(--color-chart-4)","var(--color-chart-5)","var(--color-chart-6)","var(--color-chart-7)","var(--color-chart-8)"],Pr="var(--color-chart-muted)",Fi="var(--color-chart-up)",Oi="var(--color-chart-down)",oo=3,jc=false;function Dr(e,t){return t||(e<0||e>=8?(jc||(jc=true,console.warn('[@synertech/ui] A chart was given more than 8 series. Extra series share the de-emphasis grey: fold the tail into an "Other" bucket, or split the chart, instead of relying on a ninth colour.')),Pr):bs[e])}function Lr(e,t,r){return r&&e.key!==r?Pr:Dr(t,e.color)}function Kt(e){return e.label??e.key}function $r(e,t,r=false){return e.map((n,o)=>({key:n.key,label:Kt(n),color:Lr(n,o,t),hidden:n.hidden,...n.type==="line"?{marker:"line"}:{},...r&&n.type!=="line"?{pattern:o}:{}}))}var Vi=["var(--color-chart-seq-1)","var(--color-chart-seq-2)","var(--color-chart-seq-3)","var(--color-chart-seq-4)","var(--color-chart-seq-5)","var(--color-chart-seq-6)"],ya=["var(--color-chart-ord-1)","var(--color-chart-ord-2)","var(--color-chart-ord-3)","var(--color-chart-ord-4)","var(--color-chart-ord-5)"],no=["var(--color-chart-div-1)","var(--color-chart-div-2)","var(--color-chart-div-3)","var(--color-chart-div-4)","var(--color-chart-div-5)","var(--color-chart-div-6)","var(--color-chart-div-7)"],Zc=3,Qc=[false,false,false,false,true,true],$i=[false,false,true,true,true],Jc=[true,false,false,false,false,false,true],ys=7;function xa(e){return Number.isFinite(e)?e<0?0:e>1?1:e:0}function Eo(e,t){if(e.length===0)return Pr;if(e.length===1)return e[0];let r=xa(t)*(e.length-1),n=Math.min(e.length-2,Math.floor(r)),o=r-n;if(o<=.005)return e[n];if(o>=.995)return e[n+1];let a=Math.round(o*1e3)/10;return `color-mix(in oklab, ${e[n+1]} ${a}%, ${e[n]})`}function Xp(e,t){return t<=1?.5:Math.min(t-1,Math.floor(xa(e)*t))/(t-1)}function ed(e,t,r,n,o){let a=l=>{let i=n(l);return r===null?i:Xp(i,r)},s=(l=>Number.isFinite(l)?Eo(t,a(l)):Pr);return Object.defineProperties(s,{domain:{value:[e[0],e[1]],enumerable:true},colors:{value:t,enumerable:true},steps:{value:r,enumerable:true},position:{value:l=>Number.isFinite(l)?a(l):0,enumerable:true},onDark:{value:l=>{if(!Number.isFinite(l)||o.length===0)return false;let i=Math.round(a(l)*(o.length-1));return o[i]??false},enumerable:true}}),s}function va(e,t={}){let{steps:r,colors:n=Vi,darkStops:o}=t,[a,s]=e,l=s-a;return ed(e,n,r??null,i=>l===0?0:(i-a)/l,o??(n===Vi?Qc:[]))}function Mo(e,t={}){let{steps:r,colors:n=no,darkStops:o,center:a=0,symmetric:s=true}=t,[l,i]=e;if(s){let u=Math.max(Math.abs(i-a),Math.abs(a-l));l=a-u,i=a+u;}let c=n===no?Zc:(n.length-1)/2,d=n.length-1;return ed([l,i],n,r??null,u=>{if(u>=a){let p=i-a,w=p<=0?0:xa((u-a)/p);return (c+w*(d-c))/d}let f=a-l,m=f<=0?0:xa((a-u)/f);return (c-m*c)/d},o??(n===no?Jc:[]))}function Gp(e,t=ya.length,r=ya){return t<=1?r[r.length-1]??Pr:Eo(r,xa(e/(t-1)))}function Ee(e,t){let r=e[t];if(r==null||r==="")return null;if(typeof r=="number")return Number.isFinite(r)?r:null;if(typeof r=="boolean")return r?1:0;if(typeof r=="string"){let n=Number(r);return Number.isFinite(n)?n:null}return null}function ct(e,t,r){let n=e[t];return n instanceof Date||typeof n=="number"||typeof n=="string"?n:n==null?r:String(n)}function fr(e,t){let r=[];for(let n of e)for(let o of t)r.push(Ee(n,o));return r}function Ca(e,t={}){if(!Number.isFinite(e))return "\u2014";let{locale:r,compact:n,currency:o,unit:a,minimumFractionDigits:s,maximumFractionDigits:l}=t,i=new Intl.NumberFormat(r,{notation:n?"compact":"standard",...o?{style:"currency",currency:o}:{},...s!==void 0?{minimumFractionDigits:s}:{},...l!==void 0?{maximumFractionDigits:l}:n?{maximumFractionDigits:1}:{}}).format(e);return a?`${i}${a}`:i}function Kp(e,t){return Ca(e,{locale:t,compact:true})}function nt(e,t){return Number.isFinite(e)?Math.abs(e)<1e4?Ca(e,{locale:t}):Kp(e,t):"\u2014"}function Ut(e,t={}){if(!Number.isFinite(e))return "\u2014";let{locale:r,maximumFractionDigits:n=1,alreadyScaled:o,signed:a}=t;return new Intl.NumberFormat(r,{style:"percent",maximumFractionDigits:n,...a?{signDisplay:"exceptZero"}:{}}).format(o?e/100:e)}function Ze(e,t){return e instanceof Date?new Intl.DateTimeFormat(t,{day:"2-digit",month:"short"}).format(e):typeof e=="number"?Ca(e,{locale:t}):e}function zt({data:e,series:t,xKey:r,xLabel:n,formatX:o,formatValue:a,caption:s,emptyLabel:l,className:i,...c}){let d=t.filter(m=>!m.hidden);if(e.length===0||d.length===0)return jsxRuntime.jsx("div",{className:g("text-sm text-gray-500 dark:text-gray-400",i),...c,children:l});let u=(m,p)=>{let w=ct(m,r,p);return o?o(w,p):Ze(w)},f=m=>m===null?"\u2014":a?a(m):Ca(m);return jsxRuntime.jsx("div",{className:g("w-full overflow-x-auto",i),...c,children:jsxRuntime.jsxs(fn,{children:[s?jsxRuntime.jsx("caption",{className:"sr-only",children:s}):null,jsxRuntime.jsxs(bn,{children:[jsxRuntime.jsx(St,{children:n??r}),d.map(m=>jsxRuntime.jsx(St,{className:"text-right",children:Kt(m)},m.key))]}),jsxRuntime.jsx(hn,{children:e.map((m,p)=>jsxRuntime.jsxs(yn,{clickable:false,children:[jsxRuntime.jsx(Gt,{className:"font-medium text-gray-900 dark:text-gray-100",children:u(m,p)}),d.map(w=>jsxRuntime.jsx(Gt,{className:"text-right [font-variant-numeric:tabular-nums]",children:f(Ee(m,w.key))},w.key))]},p))})]})})}function dt({x:e,y:t,visible:r=true,containerWidth:n,offset:o=12,className:a,style:s,children:l,...i}){if(!r)return null;let c=n!==void 0&&e>n*.6;return jsxRuntime.jsx("div",{role:"tooltip",className:g("pointer-events-none absolute top-0 left-0 z-10 min-w-24 rounded-md border border-gray-200 bg-white px-2.5 py-2 text-xs shadow-lg dark:border-gray-700 dark:bg-gray-800",a),style:{transform:`translate(${c?e-o:e+o}px, ${t}px) translate(${c?"-100%":"0"}, -50%)`,...s},...i,children:l})}function Nr({title:e,points:t}){return jsxRuntime.jsxs("div",{className:"flex flex-col gap-1",children:[e!=null&&jsxRuntime.jsx("div",{className:"font-medium text-gray-900 dark:text-gray-100",children:e}),jsxRuntime.jsx("div",{className:"flex flex-col gap-0.5",children:t.map(r=>jsxRuntime.jsxs("div",{className:"flex items-center gap-2",children:[jsxRuntime.jsx("span",{className:"h-0.5 w-3 shrink-0 rounded-full",style:{backgroundColor:r.color},"aria-hidden":"true"}),jsxRuntime.jsx("span",{className:"grow text-gray-500 dark:text-gray-400",children:r.seriesLabel}),jsxRuntime.jsx("span",{className:"font-semibold text-gray-900 [font-variant-numeric:tabular-nums] dark:text-gray-100",children:r.formattedValue})]},r.seriesKey))})]})}function ft(e){return e instanceof Date?e.toISOString():String(e)}function _r(e){if(e instanceof Date)return e.getTime();if(typeof e=="number")return e;let t=Number(e);return Number.isFinite(t)?t:Number.NaN}function Er(e,t){let[r,n]=e,[o,a]=t,s=n-r,l=s===0?0:(a-o)/s,i=(c=>Number.isFinite(c)?s===0?(o+a)/2:o+(c-r)*l:Number.NaN);return Object.defineProperties(i,{domain:{value:[r,n],enumerable:true},range:{value:[o,a],enumerable:true},invert:{value:c=>l===0?r:r+(c-o)/l,enumerable:true}}),i}function xn(e,t,r={}){let{paddingInner:n=.2,paddingOuter:o=n/2}=r,[a,s]=t,l=e.length,i=l===0?0:(s-a)/Math.max(1,l-n+o*2),c=i*(1-n),d=a+(s-a-i*(l-n))/2,u=new Map;e.forEach((p,w)=>{u.has(ft(p))||u.set(ft(p),w);});let f=p=>d+i*p,m=(p=>{let w=u.get(ft(p));return w===void 0?Number.NaN:f(w)});return Object.defineProperties(m,{bandwidth:{value:c,enumerable:true},step:{value:i,enumerable:true},domain:{value:e,enumerable:true},range:{value:[a,s],enumerable:true},center:{value:p=>{let w=u.get(ft(p));return w===void 0?Number.NaN:f(w)+c/2},enumerable:true},positions:{value:()=>e.map((p,w)=>f(w)),enumerable:true},indexOf:{value:p=>u.get(ft(p))??-1,enumerable:true}}),m}function Vt(e,t){if(e.length===0)return -1;let r=0,n=Number.POSITIVE_INFINITY;for(let o=0;o<e.length;o+=1){let a=Math.abs(e[o]-t);a<n&&(n=a,r=o);}return r}function ka(e){let t=Number(e.toPrecision(12));return Object.is(t,-0)?0:t}function rd(e){if(!Number.isFinite(e)||e<=0)return 1;let t=Math.floor(Math.log10(e)),r=Math.pow(10,t),n=e/r,o=n<=1?1:n<=2?2:n<=5?5:10;return ka(o*r)}function xs(e,t,r=5){if(!Number.isFinite(e)||!Number.isFinite(t))return [0,1];if(e===t){if(e===0)return [0,1];let o=Math.abs(e)*.5;[e,t]=[e-o,e+o];}let n=rd((t-e)/Math.max(1,r));return [ka(Math.floor(e/n)*n),ka(Math.ceil(t/n)*n)]}function wa(e,t,r=5){if(!Number.isFinite(e)||!Number.isFinite(t))return [];if(r<=0)return [];if(e===t)return [ka(e)];e>t&&([e,t]=[t,e]);let n=rd((t-e)/r),o=Math.ceil(e/n),a=Math.floor(t/n),s=[];for(let l=o;l<=a&&s.length<=1e3;l+=1)s.push(ka(l*n));return s}function Yt(e){let t=Number.POSITIVE_INFINITY,r=Number.NEGATIVE_INFINITY,n=false;for(let o of e)o==null||!Number.isFinite(o)||(n=true,o<t&&(t=o),o>r&&(r=o));return n?[t,r]:null}function Ao(e,t={}){let{domain:r,includeZero:n=true,ticks:o=5}=t;if(Array.isArray(r))return r;let a=Yt(e);if(!a)return [0,1];let[s,l]=a;return n&&(s=Math.min(s,0),l=Math.max(l,0)),xs(s,l,o)}var Xi={top:10,right:16,bottom:28},nd=16,Up=14,Yp=32;function rr({width:e,height:t,data:r,x:n,y:o,bounds:a,margin:s,orientation:l="vertical",placement:i="point",bandPaddingInner:c=.2,formatValue:d,formatX:u,extraTop:f=0,defaultIncludeZero:m=false}){let p=l==="vertical",w=r.map((O,_)=>ct(O,n.key,_)),v=Ao(a??[],{domain:o?.domain,includeZero:o?.includeZero??m,ticks:o?.ticks??5}),x=o?.hidden??false,h=n.hidden??false,I=x?[]:wa(v[0],v[1],o?.ticks??5),S=I.map(d),L=p&&(n.scale==="linear"||n.scale==="time"),R=w.map((O,_)=>u(O,_)),T=p?x:h,y=p?S:R,M=p?o?.width:n.height,k=p?h:x,z=p?n.height:void 0,H=p?n.label:o?.label,P=p?o?.label:n.label,B=p&&!h&&i!=="band"?R:[],C=O=>O?tr(O)/2+4:0,b={top:s?.top??Xi.top+f,right:s?.right??Math.max(Xi.right,C(B[B.length-1])),bottom:s?.bottom??(k?8:z??Xi.bottom+(H?nd:0)),left:s?.left??(T?8:M??Math.max(Math.max(Yp,wr(y)+Up)+(P?nd:0),C(B[0])))},E=Math.max(0,e-b.left-b.right),N=Math.max(0,t-b.top-b.bottom),W=p?Er(v,[N,0]):Er(v,[0,E]),F=p?E:N,K,j=0,A,D=null;if(L){let O=w.map(_r),_=Yt(O)??[0,1],X=Er(_,[0,F]);D=X,K=O.map(G=>X(G)),A=h?[]:wa(_[0],_[1],n.ticks??5).map(G=>({value:G,offset:X(G),label:u(n.scale==="time"?new Date(G):G,0)}));}else if(i==="band"){let O=xn(r.map((_,X)=>X),[0,F],{paddingInner:c});K=r.map((_,X)=>O(X)),j=O.bandwidth,A=[];}else {let O=r.length>1?F/(r.length-1):0;K=r.map((_,X)=>r.length>1?X*O:F/2),A=[];}let V=K.map(O=>O+j/2);if(!L&&!h){let O=p?wr(R):15,_=ha(R.length,F,O);A=R.map((X,G)=>({value:w[G],offset:V[G],label:X})).filter((X,G)=>G%_===0);}return {margin:b,innerWidth:E,innerHeight:N,orientation:l,valueScale:W,domain:v,valueTicks:I.map(O=>({value:O,offset:W(O),label:d(O)})),xValues:w,categoryPositions:K,bandwidth:j,categoryCenters:V,categoryTicks:A,categoryLength:F,categoryScale:D}}function zo(e){let{categoryScale:t,xValues:r,categoryCenters:n,categoryLength:o}=e;return a=>{if(t){let i=t(_r(a));return Number.isFinite(i)?i<-0.5||i>o+.5?null:i:null}let s=ft(a),l=r.findIndex(i=>ft(i)===s);return l<0?null:n[l]}}function kt(e){return Math.round(e*100)/100}function od(e){return e.defined!==false&&Number.isFinite(e.x)&&Number.isFinite(e.y)}function ad(e,t=false){if(t){let o=e.filter(od);return o.length>0?[o]:[]}let r=[],n=[];for(let o of e)od(o)?n.push(o):n.length>0&&(r.push(n),n=[]);return n.length>0&&r.push(n),r}function qp(e){let t=e.length,r=[],n=[];for(let a=0;a<t-1;a+=1){let s=e[a+1].x-e[a].x;r.push(s),n.push(s===0?0:(e[a+1].y-e[a].y)/s);}let o=new Array(t);o[0]=n[0],o[t-1]=n[t-2];for(let a=1;a<t-1;a+=1){let s=n[a-1],l=n[a];if(s*l<=0)o[a]=0;else {let i=2*r[a]+r[a-1],c=r[a]+2*r[a-1];o[a]=(i+c)/(i/s+c/l);}}return o}function Ki(e,t){if(e.length<2)return "";if(t==="monotone"&&e.length>2){let n=qp(e),o="";for(let a=0;a<e.length-1;a+=1){let s=e[a],l=e[a+1],i=(l.x-s.x)/3;o+=` C${kt(s.x+i)},${kt(s.y+n[a]*i)} ${kt(l.x-i)},${kt(l.y-n[a+1]*i)} ${kt(l.x)},${kt(l.y)}`;}return o}let r="";for(let n=1;n<e.length;n+=1){let o=e[n-1],a=e[n];if(t==="step"){let s=kt((o.x+a.x)/2);r+=` L${s},${kt(o.y)} L${s},${kt(a.y)}`;}else t==="stepAfter"&&(r+=` L${kt(a.x)},${kt(o.y)}`);r+=` L${kt(a.x)},${kt(a.y)}`;}return r}function Xr(e,t="linear",r={}){return ad(e,r.connectNulls).map(n=>{let[o]=n;return `M${kt(o.x)},${kt(o.y)}${Ki(n,t)}`}).join(" ")}function Na(e,t,r="linear",n={}){let o=ad(e,n.connectNulls);if(o.length===0)return "";let a=typeof t=="number"?null:new Map(t.map(s=>[kt(s.x),s]));return o.map(s=>{let[l]=s,i=s[s.length-1],c=`M${kt(l.x)},${kt(l.y)}${Ki(s,r)}`;if(a===null){let f=kt(t);return `${c} L${kt(i.x)},${f} L${kt(l.x)},${f} Z`}let d=s.map(f=>a.get(kt(f.x))).filter(f=>f!==void 0).reverse();if(d.length===0)return `${c} Z`;let[u]=d;return `${c} L${kt(u.x)},${kt(u.y)}${Ki(d,r)} Z`}).join(" ")}function cr({x:e,y:t,width:r,height:n,radius:o=4,round:a="none"}){if(!(r>0)||!(n>0))return "";let s=Math.max(0,Math.min(o,r/2,n/2)),[l,i]=[_e(e),_e(t)],[c,d]=[_e(e+r),_e(t+n)];if(s===0||a==="none")return `M${l},${i} L${c},${i} L${c},${d} L${l},${d} Z`;switch(a){case "top":return `M${l},${d} L${l},${_e(t+s)} Q${l},${i} ${_e(e+s)},${i} L${_e(e+r-s)},${i} Q${c},${i} ${c},${_e(t+s)} L${c},${d} Z`;case "bottom":return `M${l},${i} L${c},${i} L${c},${_e(t+n-s)} Q${c},${d} ${_e(e+r-s)},${d} L${_e(e+s)},${d} Q${l},${d} ${l},${_e(t+n-s)} Z`;case "right":return `M${l},${i} L${_e(e+r-s)},${i} Q${c},${i} ${c},${_e(t+s)} L${c},${_e(t+n-s)} Q${c},${d} ${_e(e+r-s)},${d} L${l},${d} Z`;case "left":return `M${c},${i} L${_e(e+s)},${i} Q${l},${i} ${l},${_e(t+s)} L${l},${_e(t+n-s)} Q${l},${d} ${_e(e+s)},${d} L${c},${d} Z`;default:return `M${l},${i} L${c},${i} L${c},${d} L${l},${d} Z`}}function _e(e){return Math.round(e*100)/100}function Wn(e,t,r,n){return {x:_e(e+r*Math.sin(n)),y:_e(t-r*Math.cos(n))}}function sd({cx:e,cy:t,innerRadius:r,outerRadius:n,startAngle:o,endAngle:a}){let s=a-o;if(!(n>0)||!(s>0))return "";let l=s>=Math.PI*2-1e-9,i=Math.max(0,Math.min(r,n));if(l){let p=Wn(e,t,n,0),w=Wn(e,t,n,Math.PI),v=`M${p.x},${p.y} A${_e(n)},${_e(n)} 0 1 1 ${w.x},${w.y} A${_e(n)},${_e(n)} 0 1 1 ${p.x},${p.y} Z`;if(i===0)return v;let x=Wn(e,t,i,0),h=Wn(e,t,i,Math.PI);return `${v} M${x.x},${x.y} A${_e(i)},${_e(i)} 0 1 0 ${h.x},${h.y} A${_e(i)},${_e(i)} 0 1 0 ${x.x},${x.y} Z`}let c=s>Math.PI?1:0,d=Wn(e,t,n,o),u=Wn(e,t,n,a);if(i===0)return `M${_e(e)},${_e(t)} L${d.x},${d.y} A${_e(n)},${_e(n)} 0 ${c} 1 ${u.x},${u.y} Z`;let f=Wn(e,t,i,a),m=Wn(e,t,i,o);return `M${d.x},${d.y} A${_e(n)},${_e(n)} 0 ${c} 1 ${u.x},${u.y} L${f.x},${f.y} A${_e(i)},${_e(i)} 0 ${c} 0 ${m.x},${m.y} Z`}function vs(e,t,r="none"){return e.map((n,o)=>{let a=t.map(d=>Ee(n,d)),s=a.reduce((d,u)=>d+(u===null?0:Math.abs(u)),0),l=0,i=0,c=t.map((d,u)=>{let f=a[u];if(r==="none")return {key:d,value:f,start:0,end:f??0};if(f===null)return {key:d,value:null,start:l,end:l};let m=r==="percent"?s===0?0:f/s*100:f;if(m>=0){let w=l;return l+=m,{key:d,value:f,start:w,end:l}}let p=i;return i+=m,{key:d,value:f,start:i,end:p}});return {index:o,datum:n,total:s,segments:c}})}function Cs(e){let t=Number.POSITIVE_INFINITY,r=Number.NEGATIVE_INFINITY,n=false;for(let o of e)for(let a of o.segments)a.value!==null&&(n=true,t=Math.min(t,a.start,a.end),r=Math.max(r,a.start,a.end));return n?[t,r]:null}function id(e,t,r={}){let{centerKey:n,percent:o=false}=r,a=n?t.indexOf(n):-1,s=a>=0?a:Math.max(0,Math.min(t.length,r.negativeCount??Math.floor(t.length/2)));return e.map((l,i)=>{let c=t.map(x=>Ee(l,x)),d=c.reduce((x,h)=>x+(h===null?0:Math.abs(h)),0),u=c.map(x=>x===null?null:o?d===0?0:x/d*100:x),f=t.map(x=>({key:x,value:null,start:0,end:0,base:false,outer:false})),m=0;a>=0&&(m=(u[a]??0)/2,f[a]={key:t[a],value:c[a],start:m===0?0:-m,end:m,base:true,outer:false});let p=m===0?0:-m,w=-1;for(let x=s-1;x>=0;x-=1){let h=u[x];if(h===null){f[x]={...f[x],value:null,start:p,end:p};continue}let I=p-Math.abs(h);f[x]={key:t[x],value:c[x],start:p,end:I,base:a<0&&w===-1,outer:false},p=I,w=x;}w>=0&&(f[w].outer=true),p=m;let v=-1;for(let x=a>=0?a+1:s;x<t.length;x+=1){let h=u[x];if(h===null){f[x]={...f[x],value:null,start:p,end:p};continue}let I=p+Math.abs(h);f[x]={key:t[x],value:c[x],start:p,end:I,base:a<0&&v===-1,outer:false},p=I,v=x;}return v>=0?f[v].outer=true:a>=0&&(f[a].outer=true),{index:i,datum:l,total:d,segments:f}})}var Qp=.12,Jp=.9,ef=10,tf=el.memo(function({bands:t,stacked:r,patterns:n,patternBaseId:o}){return jsxRuntime.jsx("g",{children:t.map(a=>jsxRuntime.jsxs("g",{children:[jsxRuntime.jsx("path",{d:a.area,fill:to(n,o,a.slot,a.color),fillOpacity:r?Jp:Qp,stroke:"none"}),a.gap?jsxRuntime.jsx("path",{d:a.gap,fill:"none",strokeWidth:2,className:"stroke-white dark:stroke-gray-800"}):null,jsxRuntime.jsx("path",{d:a.edge,fill:"none",stroke:a.color,strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"})]},a.key))})});function rf({width:e,height:t,data:r,resolvedSeries:n,x:o,y:a,grid:s,size:l,curve:i,stack:c,baseline:d,connectNulls:u,referenceLines:f,annotations:m,annotationsLabel:p,patterns:w,patternBaseId:v,margin:x,tooltip:h,onPointClick:I,plotLabel:S,formatValue:L,formatRaw:R,formatX:T}){let[y,M]=el.useState(null),k=el.useMemo(()=>{let N=n.filter(X=>!X.hidden),W=N.map(X=>X.key),F=c!=="none",K=vs(r,W,c),j=F?Cs(K):Yt([...fr(r,W),d]),A=rr({width:e,height:t,data:r,x:o,y:a,bounds:j,margin:x,placement:"point",formatValue:L,formatX:T,defaultIncludeZero:true}),D=A.categoryCenters,V=A.valueScale,O=V(F?0:d),_=N.map((X,G)=>{let $=r.map((ae,U)=>{let Q=K[U].segments[G];return {x:D[U],y:Q.value===null?Number.NaN:V(Q.end),defined:Q.value!==null}}),Y=r.map((ae,U)=>{let Q=K[U].segments[G];return {x:D[U],y:Q.value===null?Number.NaN:V(F?Q.start:d),defined:Q.value!==null}}),se={connectNulls:u};return {key:X.key,color:X.color,slot:X.slot,area:F?Na($,Y,i,se):Na($,O,i,se),edge:Xr($,i,se),gap:F&&G>0?Xr(Y,i,se):""}});return {visible:N,locate:zo(A),rows:K,stacked:F,xValues:A.xValues,positions:D,xTicks:A.categoryTicks,yTicks:A.valueTicks,valueScale:V,innerWidth:A.innerWidth,innerHeight:A.innerHeight,margin:A.margin,bands:_}},[r,n,o,a,e,t,x,i,c,d,u,L,T]),z=el.useCallback(N=>k.visible.map((W,F)=>{let K=Ee(r[N],W.key),j=k.rows[N].segments[F],A=K===null?"\u2014":c==="percent"?`${R(K)} (${L(j.end-j.start)})`:L(K);return {seriesKey:W.key,seriesLabel:Kt(W),color:W.color,value:K,formattedValue:A,datum:r[N]}}),[r,k.visible,k.rows,c,L,R]),H=el.useCallback(N=>{if(h===false||r.length===0)return;let W=N.currentTarget.getBoundingClientRect(),F=N.clientX-W.left-k.margin.left,K=Vt(k.positions,F);M(K>=0?K:null);},[h,r.length,k.margin.left,k.positions]),P=el.useCallback(N=>{if(r.length===0)return;let W=r.length-1,F=y??0,K=N.key==="ArrowRight"?Math.min(W,F+1):N.key==="ArrowLeft"?Math.max(0,F-1):N.key==="Home"?0:N.key==="End"?W:N.key==="Escape"?null:void 0;K!==void 0&&(N.preventDefault(),M(K));},[r.length,y]),B=el.useCallback(()=>{if(!I||y===null)return;let[N]=z(y);N&&I({...N,index:y,x:k.xValues[y]});},[I,y,z,k.xValues]),C=y===null?null:z(y),b=y===null?[]:k.visible.map((N,W)=>{let F=k.rows[y].segments[W];return F.value===null?null:{key:N.key,color:N.color,y:k.valueScale(F.end)}}).filter(N=>N!==null),E=y===null||C===null?null:{x:k.xValues[y],xLabel:T(k.xValues[y],y),index:y,points:C};return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsxs("svg",{width:e,height:t,role:"img","aria-label":S??[k.visible.map(N=>Kt(N)).join(", "),Jn(m,p)].filter(Boolean).join(". "),tabIndex:0,className:"touch-none focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-blue-500",onPointerMove:H,onPointerLeave:()=>M(null),onKeyDown:P,onBlur:()=>M(null),onClick:B,children:[w?jsxRuntime.jsx(ro,{id:v,entries:n.map(N=>({slot:N.slot,color:N.color}))}):null,jsxRuntime.jsxs("g",{transform:`translate(${k.margin.left}, ${k.margin.top})`,children:[jsxRuntime.jsx(_t,{width:k.innerWidth,height:k.innerHeight,horizontal:s==="y"||s==="both"?k.yTicks.map(N=>N.offset):void 0,vertical:s==="x"||s==="both"?k.xTicks.map(N=>N.offset):void 0}),m?jsxRuntime.jsx(tn,{layer:"under",annotations:m,xAt:k.locate,yAt:k.valueScale,width:k.innerWidth,height:k.innerHeight}):null,jsxRuntime.jsx(tf,{bands:k.bands,stacked:k.stacked,patterns:w&&k.stacked,patternBaseId:v}),m?jsxRuntime.jsx(tn,{annotations:m,xAt:k.locate,yAt:k.valueScale,width:k.innerWidth,height:k.innerHeight}):null,f?.map(N=>{let W=k.valueScale(N.value),F=W<ef?W+12:W-4;return jsxRuntime.jsxs("g",{children:[jsxRuntime.jsx("line",{x1:0,y1:W,x2:k.innerWidth,y2:W,stroke:N.color??"var(--color-chart-muted)",strokeWidth:1,strokeDasharray:N.dashed===false?void 0:"4 4"}),N.label?jsxRuntime.jsx("text",{x:k.innerWidth,y:F,textAnchor:"end",className:"fill-gray-500 text-[10px] dark:fill-gray-400",children:N.label}):null]},`${N.value}-${N.label??""}`)}),y!==null?jsxRuntime.jsxs("g",{"aria-hidden":"true",children:[jsxRuntime.jsx("line",{x1:k.positions[y],y1:0,x2:k.positions[y],y2:k.innerHeight,className:"stroke-gray-400 dark:stroke-gray-500",strokeWidth:1}),b.map(N=>jsxRuntime.jsx("circle",{cx:k.positions[y],cy:N.y,r:4,fill:N.color,strokeWidth:2,className:"stroke-white dark:stroke-gray-800"},N.key))]}):null]}),jsxRuntime.jsx("g",{transform:`translate(${k.margin.left}, ${k.margin.top+k.innerHeight})`,children:o.hidden?null:jsxRuntime.jsx(Ue,{orientation:"bottom",ticks:k.xTicks,length:k.innerWidth,label:o.label,size:l})}),jsxRuntime.jsx("g",{transform:`translate(${k.margin.left}, ${k.margin.top})`,children:a?.hidden?null:jsxRuntime.jsx(Ue,{orientation:"left",ticks:k.yTicks,length:k.innerHeight,showLine:false,label:a?.label,size:l})})]}),E&&h!==false?jsxRuntime.jsx(dt,{x:k.margin.left+k.positions[E.index],y:k.margin.top+(b.length>0?Math.min(...b.map(N=>N.y)):k.innerHeight/2),containerWidth:e,children:typeof h=="function"?h(E):jsxRuntime.jsx(Nr,{title:E.xLabel,points:E.points})}):null]})}function nf({data:e,series:t,x:r,y:n,height:o=240,width:a,size:s="md",grid:l="y",legend:i,tooltip:c=true,tableView:d=false,emphasis:u,title:f,description:m,loading:p=false,emptyState:w,onPointClick:v,curve:x="monotone",stack:h="none",baseline:I=0,connectNulls:S=false,referenceLines:L,annotations:R,patterns:T=false,legendToggle:y=true,margin:M,locale:k,plotLabel:z,className:H,...P}){let B=We(),[C,b]=el.useState(()=>new Set),E=el.useId(),N=el.useMemo(()=>t.map((X,G)=>({...X,slot:G,hidden:X.hidden||C.has(X.key),color:Lr(X,G,u)})),[t,C,u]),W=h==="percent",F=el.useMemo(()=>W?{domain:[0,100],...n}:n,[W,n]),K=el.useMemo(()=>n?.format??(W?X=>Ut(X,{locale:k,alreadyScaled:true,maximumFractionDigits:0}):X=>nt(X,k)),[n?.format,W,k]),j=el.useMemo(()=>X=>nt(X,k),[k]),A=el.useMemo(()=>r.format??(X=>r.scale==="time"?Ze(X instanceof Date?X:new Date(_r(X)),k):Ze(X,k)),[r.format,r.scale,k]),D=el.useCallback(X=>{b(G=>{let $=new Set(G);return $.has(X)?$.delete(X):$.add(X),$});},[]),V=i===void 0?t.length>=2:i!==false,O=typeof i=="string"?i:"bottom",_=N.filter(X=>!X.hidden).length;return jsxRuntime.jsx(lt,{title:f,description:m,height:o,width:a,size:s,loading:p,empty:e.length===0||_===0,emptyState:w,tableView:d,legendPosition:O,legend:V?jsxRuntime.jsx(Xt,{items:$r(N,u,T&&h!=="none"),position:O,marker:"rect",size:s,onToggle:y?D:void 0}):void 0,table:d?jsxRuntime.jsx(zt,{data:e,series:N,xKey:r.key,xLabel:r.label??r.key,formatX:A,formatValue:j,caption:typeof f=="string"?f:void 0}):void 0,className:H,...P,children:({width:X})=>jsxRuntime.jsx(rf,{width:X,height:o,data:e,resolvedSeries:N,x:r,y:F,grid:l,size:s,curve:x,stack:h,baseline:I,connectNulls:S,referenceLines:L,annotations:R,annotationsLabel:B.chartAnnotations,patterns:T,patternBaseId:E,margin:M,tooltip:c,onPointClick:v,plotLabel:z,formatValue:K,formatRaw:j,formatX:A})})}var af={xs:"h-6 w-6 text-xs",sm:"h-8 w-8 text-sm",md:"h-10 w-10 text-base",lg:"h-12 w-12 text-lg",xl:"h-16 w-16 text-xl"},sf={circle:"rounded-full",square:"rounded-none",rounded:"rounded-md"};function lf({src:e,alt:t="Avatar",fallback:r,size:n="md",variant:o="circle",border:a=false,className:s,...l}){return jsxRuntime.jsx("div",{className:g("inline-flex items-center justify-center overflow-hidden bg-gray-200 font-medium text-gray-600 dark:bg-gray-700 dark:text-gray-300",af[n],sf[o],a&&"ring-2 ring-white dark:ring-gray-900",s),...l,children:e?jsxRuntime.jsx("img",{src:e,alt:t,className:"h-full w-full object-cover"}):jsxRuntime.jsx("span",{children:r||t.charAt(0).toUpperCase()})})}var cf={default:{solid:"bg-gray-500 text-white",soft:"bg-gray-100 text-gray-700 dark:bg-gray-700 dark:text-gray-300",outlined:"border border-gray-300 text-gray-600 dark:border-gray-600 dark:text-gray-400",subtle:"bg-gray-50 text-gray-600 dark:bg-gray-800 dark:text-gray-400"},primary:{solid:"bg-blue-600 text-white",soft:"bg-blue-100 text-blue-700 dark:bg-blue-900/50 dark:text-blue-300",outlined:"border border-blue-500 text-blue-600 dark:border-blue-400 dark:text-blue-400",subtle:"bg-blue-50 text-blue-600 dark:bg-blue-900/30 dark:text-blue-400"},success:{solid:"bg-green-600 text-white",soft:"bg-green-100 text-green-700 dark:bg-green-900/50 dark:text-green-300",outlined:"border border-green-500 text-green-600 dark:border-green-400 dark:text-green-400",subtle:"bg-green-50 text-green-600 dark:bg-green-900/30 dark:text-green-400"},warning:{solid:"bg-yellow-500 text-white",soft:"bg-yellow-100 text-yellow-700 dark:bg-yellow-900/50 dark:text-yellow-300",outlined:"border border-yellow-400 text-yellow-600 dark:border-yellow-400 dark:text-yellow-400",subtle:"bg-yellow-50 text-yellow-600 dark:bg-yellow-900/30 dark:text-yellow-400"},error:{solid:"bg-red-600 text-white",soft:"bg-red-100 text-red-700 dark:bg-red-900/50 dark:text-red-300",outlined:"border border-red-500 text-red-600 dark:border-red-400 dark:text-red-400",subtle:"bg-red-50 text-red-600 dark:bg-red-900/30 dark:text-red-400"},info:{solid:"bg-cyan-600 text-white",soft:"bg-cyan-100 text-cyan-700 dark:bg-cyan-900/50 dark:text-cyan-300",outlined:"border border-cyan-500 text-cyan-600 dark:border-cyan-400 dark:text-cyan-400",subtle:"bg-cyan-50 text-cyan-600 dark:bg-cyan-900/30 dark:text-cyan-400"},purple:{solid:"bg-purple-600 text-white",soft:"bg-purple-100 text-purple-700 dark:bg-purple-900/50 dark:text-purple-300",outlined:"border border-purple-500 text-purple-600 dark:border-purple-400 dark:text-purple-400",subtle:"bg-purple-50 text-purple-600 dark:bg-purple-900/30 dark:text-purple-400"},indigo:{solid:"bg-indigo-600 text-white",soft:"bg-indigo-100 text-indigo-700 dark:bg-indigo-900/50 dark:text-indigo-300",outlined:"border border-indigo-500 text-indigo-600 dark:border-indigo-400 dark:text-indigo-400",subtle:"bg-indigo-50 text-indigo-600 dark:bg-indigo-900/30 dark:text-indigo-400"},teal:{solid:"bg-teal-600 text-white",soft:"bg-teal-100 text-teal-700 dark:bg-teal-900/50 dark:text-teal-300",outlined:"border border-teal-500 text-teal-600 dark:border-teal-400 dark:text-teal-400",subtle:"bg-teal-50 text-teal-600 dark:bg-teal-900/30 dark:text-teal-400"}},df={default:"bg-gray-500",primary:"bg-blue-500",success:"bg-green-500",warning:"bg-yellow-400",error:"bg-red-500",info:"bg-cyan-500",purple:"bg-purple-500",indigo:"bg-indigo-500",teal:"bg-teal-500"},uf={sm:"text-[10px] px-1.5 py-0.5 gap-1",md:"text-xs px-2 py-0.5 gap-1",lg:"text-sm px-2.5 py-1 gap-1.5"},mf={sm:"w-1.5 h-1.5",md:"w-1.5 h-1.5",lg:"w-2 h-2"},gf={sm:"w-2.5 h-2.5",md:"w-3 h-3",lg:"w-3.5 h-3.5"};function dd({children:e,color:t="default",size:r="md",variant:n="soft",dot:o=false,icon:a,pill:s=true,className:l,...i}){return jsxRuntime.jsxs("span",{className:g("inline-flex items-center font-medium",uf[r],s?"rounded-full":"rounded",cf[t][n],l),...i,children:[o&&jsxRuntime.jsx("span",{className:g("shrink-0 rounded-full",mf[r],df[t]),"aria-hidden":"true"}),a&&!o&&jsxRuntime.jsx("span",{className:g("shrink-0",gf[r]),"aria-hidden":"true",children:a}),e]})}dd.displayName="Badge";var ff={sm:"text-[10px]",md:"text-[11px]",lg:"text-xs"};function Ra({scale:e,label:t,format:r,ticks:n=3,size:o="md",thickness:a=10,locale:s,className:l,...i}){let[c,d]=e.domain,u=r??(h=>nt(h,s)),f=e.steps,m=f!==null&&f>0,p=Math.max(2,Math.round(n)),w=m?Array.from({length:f+1},(h,I)=>I/f):Array.from({length:p},(h,I)=>I/(p-1)),v=h=>c+h*(d-c),x=m?jsxRuntime.jsx("div",{className:"flex h-full w-full overflow-hidden rounded-sm",children:Array.from({length:f},(h,I)=>jsxRuntime.jsx("span",{className:"h-full grow",style:{backgroundColor:e(v((I+.5)/f))}},I))}):jsxRuntime.jsx("div",{className:"h-full w-full rounded-sm",style:{backgroundImage:`linear-gradient(to right, ${e.colors.join(", ")})`}});return jsxRuntime.jsxs("div",{className:g("flex w-full max-w-80 flex-col gap-1",ff[o],l),...i,children:[t?jsxRuntime.jsx("span",{className:"text-gray-600 dark:text-gray-300",children:t}):null,jsxRuntime.jsx("div",{style:{height:a},"aria-hidden":"true",children:x}),jsxRuntime.jsx("div",{className:"relative h-4 w-full",children:w.map((h,I)=>jsxRuntime.jsx("span",{className:"absolute top-0 whitespace-nowrap text-gray-500 [font-variant-numeric:tabular-nums] dark:text-gray-400",style:{left:`${h*100}%`,transform:`translateX(${I===0?"0":I===w.length-1?"-100%":"-50%"})`},children:u(v(h))},h))})]})}function ud(e){return e<=1?1:Math.min(60,Math.max(1,Math.ceil(Math.log2(e))+1))}function bf(e){let t=Math.pow(10,Math.floor(Math.log10(e)));return [.5,1,2,5,10].map(r=>Number((r*t).toPrecision(12)))}function md(e,t=true){if(Array.isArray(t)){let m=[...t].filter(p=>Number.isFinite(p)).sort((p,w)=>p-w);return m.length>=2?m:[]}let r=e.filter(m=>Number.isFinite(m));if(r.length===0)return [];let n=Math.min(...r),o=Math.max(...r);if(n===o){let m=Math.abs(n)>0?Math.abs(n)*.5:.5;n-=m,o+=m;}let a=typeof t=="number"?t:ud(r.length),s=Math.min(60,Math.max(1,Math.round(a))),l=(o-n)/s;if(!(l>0))return [];let i=0,c=0,d=Number.POSITIVE_INFINITY;for(let m of bf(l)){let p=Math.floor(n/m)*m,w=Math.ceil(o/m)*m,v=Math.max(1,Math.round((w-p)/m));if(v>60)continue;let x=Math.abs(v-s);x<=d&&(d=x,i=m,c=v);}if(i===0)return [];let u=Math.floor(n/i)*i,f=[];for(let m=0;m<=c;m+=1)f.push(Number((u+m*i).toPrecision(12)));return f}function Yi(e,t=true){let r=e.filter(a=>typeof a=="number"&&Number.isFinite(a)),n=md(r,t);if(n.length<2)return [];let o=[];for(let a=0;a<n.length-1;a+=1)o.push({from:n[a],to:n[a+1],count:0,last:a===n.length-2});for(let a of r){if(a<n[0]||a>n[n.length-1])continue;let s=0,l=o.length-1;for(;s<l;){let i=s+l+1>>1;a>=n[i]?s=i:l=i-1;}o[s].count+=1;}return o}var xf=24,so=2,vf=4,Bo=6,Cf=10,qi=false,ji=false;function kf(){qi=false,ji=false;}var wf=el.memo(function({bars:t,patterns:r,patternBaseId:n}){return jsxRuntime.jsx("g",{children:t.map((o,a)=>jsxRuntime.jsxs("g",{children:[jsxRuntime.jsx("path",{d:o.d,fill:to(r,n,o.slot,o.color)}),o.label?jsxRuntime.jsx("text",{x:o.label.x,y:o.label.y,textAnchor:o.label.anchor,dominantBaseline:"middle",className:"fill-gray-600 text-[10px] [font-variant-numeric:tabular-nums] dark:fill-gray-300",children:o.label.text}):null]},`${o.key}-${a}`))})}),Nf=el.memo(function({lines:t}){return jsxRuntime.jsx("g",{children:t.map(r=>jsxRuntime.jsxs("g",{children:[jsxRuntime.jsx("path",{d:r.d,fill:"none",stroke:r.color,strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round",strokeDasharray:r.dashed?"5 4":void 0}),r.markers.map(n=>jsxRuntime.jsx("circle",{cx:n.x,cy:n.y,r:3,fill:r.color,strokeWidth:2,className:"stroke-white dark:stroke-gray-800"},`${n.x}-${n.y}`))]},r.key))})});function Sf({width:e,height:t,data:r,resolvedSeries:n,x:o,y:a,grid:s,size:l,orientation:i,stack:c,center:d,centerKey:u,valueColors:f,binned:m,curve:p,barSize:w,showValues:v,referenceLines:x,annotations:h,annotationsLabel:I,patterns:S,patternBaseId:L,margin:R,tooltip:T,onPointClick:y,plotLabel:M,formatValue:k,formatRaw:z,formatX:H}){let[P,B]=el.useState(null),C=el.useMemo(()=>{let D=i==="vertical",V=n.filter(we=>!we.hidden),O=V.filter(we=>we.type!=="line"),_=V.filter(we=>we.type==="line"),X=O.map(we=>we.key),G=u!==null||c!=="none",$=u!==null?id(r,X,{centerKey:u,percent:c==="percent"}):vs(r,X,c),Y=G?Cs($):Yt(fr(r,X)),se=Yt(fr(r,_.map(we=>we.key))),ae=Y===null?se:se===null?Y:[Math.min(Y[0],se[0]),Math.max(Y[1],se[1])],U=rr({width:e,height:t,data:r,x:o,y:a,bounds:ae===null?null:[Math.min(ae[0],d),Math.max(ae[1],d)],margin:R,orientation:i,placement:"band",bandPaddingInner:m?0:void 0,formatValue:k,formatX:H,defaultIncludeZero:d===0}),{valueScale:Q,bandwidth:le,categoryPositions:ye,innerWidth:te,innerHeight:Ce}=U,Pe=Q(d),Se=Math.max(1,O.length),De=G?le:le/Se,Ne=Math.min(w??(m?Number.POSITIVE_INFINITY:xf),Math.max(1,De-(G&&!m?0:so))),re=G?Ne:Se*Ne+(Se-1)*so,fe=(le-re)/2,je=[],Dt=we=>G?we.end>=we.start:we.end>=d;$.forEach((we,pt)=>{let Bt=-1,yt=-1;we.segments.forEach((Nt,gr)=>{Nt.value!==null&&Nt.outer!==false&&(Dt(Nt)?Bt=gr:yt=gr);});let er=0,Mt=0;we.segments.forEach((Nt,gr)=>{if(Nt.value===null)return;let pr=O[gr],vt=Dt(Nt),Cr=Q(G?Nt.start:d),he=Q(Nt.end),ge=Math.min(Cr,he),J=Math.abs(he-Cr),ne=Nt.base??(vt?er===0:Mt===0),be=D?!vt:vt;G&&!ne&&J>so&&(J-=so,be&&(ge+=so)),vt?er+=1:Mt+=1;let me=ye[pt]+(G?fe:fe+gr*(Ne+so)),ke=gr===(vt?Bt:yt)?D?vt?"top":"bottom":vt?"right":"left":"none",Re=D?{x:me,y:ge,width:Ne,height:J}:{x:ge,y:me,width:J,height:Ne},Be=null;if(v&&!G){let ze=z(Nt.value),st=tr(ze,10);if(D){let qe=vt?ge:ge+J,Oe=vt?qe-Bo:qe+Bo,Ot=Se>1?Ne+so:le;st<=Ot&&(vt?Oe>8:Oe<Ce-4)&&(Be={x:me+Ne/2,y:Oe,anchor:"middle",text:ze});}else {let qe=vt?ge+J:ge,Oe=vt?te-qe-Bo:qe-Bo;st<=Oe&&(Be={x:vt?qe+Bo:qe-Bo,y:me+Ne/2,anchor:vt?"start":"end",text:ze});}}je.push({key:pr.key,slot:pr.slot,color:f&&Nt.value!==null?f(Nt.value):pr.color,d:cr({...Re,radius:vf,round:ke}),label:Be});});});let Ie=_.map(we=>{let pt=U.categoryCenters.map((Bt,yt)=>{let er=Ee(r[yt],we.key),Mt=er===null?Number.NaN:Q(er);return {x:D?Bt:Mt,y:D?Mt:Bt,defined:er!==null}});return {key:we.key,color:we.color,dashed:we.dashed,d:Xr(pt,p),markers:pt.filter(Bt=>Bt.defined!==false)}});return {vertical:D,visible:V,locate:zo(U),barSeries:O,rows:$,stacked:G,xValues:U.xValues,categoryPositions:ye,categoryCenters:U.categoryCenters,bandwidth:le,categoryTicks:U.categoryTicks,valueTicks:U.valueTicks,valueScale:Q,baseline:Pe,innerWidth:te,innerHeight:Ce,margin:U.margin,bars:je,lines:Ie}},[r,n,o,a,e,t,R,i,c,d,u,f,m,p,w,v,k,z,H]),b=el.useCallback(D=>C.visible.map(V=>{let O=Ee(r[D],V.key),_=C.barSeries.indexOf(V),X=_===-1?null:C.rows[D].segments[_],G=O===null?"\u2014":c==="percent"&&X!==null?`${z(O)} (${k(X.end-X.start)})`:k(O);return {seriesKey:V.key,seriesLabel:Kt(V),color:V.color,value:O,formattedValue:G,datum:r[D]}}),[r,C.visible,C.barSeries,C.rows,c,k,z]),E=el.useCallback(D=>{if(T===false||r.length===0)return;let V=D.currentTarget.getBoundingClientRect(),O=C.vertical?D.clientX-V.left-C.margin.left:D.clientY-V.top-C.margin.top,_=Vt(C.categoryCenters,O);B(_>=0?_:null);},[T,r.length,C.vertical,C.margin,C.categoryCenters]),N=el.useCallback(D=>{if(r.length===0)return;let V=r.length-1,O=P??0,_=C.vertical?"ArrowRight":"ArrowDown",X=C.vertical?"ArrowLeft":"ArrowUp",G=D.key===_?Math.min(V,O+1):D.key===X?Math.max(0,O-1):D.key==="Home"?0:D.key==="End"?V:D.key==="Escape"?null:void 0;G!==void 0&&(D.preventDefault(),B(G));},[r.length,P,C.vertical]),W=el.useCallback(()=>{if(!y||P===null)return;let[D]=b(P);D&&y({...D,index:P,x:C.xValues[P]});},[y,P,b,C.xValues]),F=P===null?null:b(P),K=P===null||F===null?null:{x:C.xValues[P],xLabel:H(C.xValues[P],P),index:P,points:F},j=D=>{let V=C.rows[D].segments.filter(O=>O.value!==null).map(O=>C.valueScale(O.end));for(let O of C.lines){let _=Ee(r[D],O.key);_!==null&&V.push(C.valueScale(_));}return V},A=P===null?null:C.vertical?{x:C.margin.left+C.categoryCenters[P],y:C.margin.top+Math.min(...j(P),C.baseline)}:{x:C.margin.left+Math.max(...j(P),C.baseline),y:C.margin.top+C.categoryCenters[P]};return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsxs("svg",{width:e,height:t,role:"img","aria-label":M??[C.visible.map(D=>Kt(D)).join(", "),Jn(h,I)].filter(Boolean).join(". "),tabIndex:0,className:"touch-none focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-blue-500",onPointerMove:E,onPointerLeave:()=>B(null),onKeyDown:N,onBlur:()=>B(null),onClick:W,children:[S?jsxRuntime.jsx(ro,{id:L,entries:n.map(D=>({slot:D.slot,color:D.color}))}):null,jsxRuntime.jsxs("g",{transform:`translate(${C.margin.left}, ${C.margin.top})`,children:[jsxRuntime.jsx(_t,{width:C.innerWidth,height:C.innerHeight,horizontal:C.vertical&&(s==="y"||s==="both")?C.valueTicks.map(D=>D.offset):void 0,vertical:!C.vertical&&(s==="y"||s==="both")?C.valueTicks.map(D=>D.offset):void 0}),h?jsxRuntime.jsx(tn,{layer:"under",annotations:h,xAt:C.locate,yAt:C.valueScale,width:C.innerWidth,height:C.innerHeight,bandwidth:C.bandwidth}):null,P!==null?jsxRuntime.jsx("rect",{x:C.vertical?C.categoryPositions[P]:0,y:C.vertical?0:C.categoryPositions[P],width:C.vertical?C.bandwidth:C.innerWidth,height:C.vertical?C.innerHeight:C.bandwidth,className:"fill-gray-400 dark:fill-gray-500",opacity:.12,"aria-hidden":"true"}):null,jsxRuntime.jsx(wf,{bars:C.bars,patterns:S,patternBaseId:L}),C.lines.length>0?jsxRuntime.jsx(Nf,{lines:C.lines}):null,jsxRuntime.jsx("line",{x1:C.vertical?0:C.baseline,y1:C.vertical?C.baseline:0,x2:C.vertical?C.innerWidth:C.baseline,y2:C.vertical?C.baseline:C.innerHeight,className:"stroke-gray-300 dark:stroke-gray-600",strokeWidth:1,shapeRendering:"crispEdges"}),h?jsxRuntime.jsx(tn,{annotations:h,xAt:C.locate,yAt:C.valueScale,width:C.innerWidth,height:C.innerHeight,bandwidth:C.bandwidth}):null,x?.map(D=>{let V=C.valueScale(D.value),O=V<Cf?V+12:V-4;return jsxRuntime.jsxs("g",{children:[jsxRuntime.jsx("line",{x1:C.vertical?0:V,y1:C.vertical?V:0,x2:C.vertical?C.innerWidth:V,y2:C.vertical?V:C.innerHeight,stroke:D.color??"var(--color-chart-muted)",strokeWidth:1,strokeDasharray:D.dashed===false?void 0:"4 4"}),D.label?jsxRuntime.jsx("text",{x:C.vertical?C.innerWidth:V+4,y:C.vertical?O:8,textAnchor:C.vertical?"end":"start",className:"fill-gray-500 text-[10px] dark:fill-gray-400",children:D.label}):null]},`${D.value}-${D.label??""}`)})]}),jsxRuntime.jsx("g",{transform:`translate(${C.margin.left}, ${C.margin.top+C.innerHeight})`,children:(C.vertical?o.hidden:a?.hidden)?null:jsxRuntime.jsx(Ue,{orientation:"bottom",ticks:C.vertical?C.categoryTicks:C.valueTicks,length:C.innerWidth,label:C.vertical?o.label:a?.label,size:l})}),jsxRuntime.jsx("g",{transform:`translate(${C.margin.left}, ${C.margin.top})`,children:(C.vertical?a?.hidden:o.hidden)?null:jsxRuntime.jsx(Ue,{orientation:"left",ticks:C.vertical?C.valueTicks:C.categoryTicks,length:C.innerHeight,showLine:false,label:C.vertical?a?.label:o.label,size:l})})]}),K&&A&&T!==false?jsxRuntime.jsx(dt,{x:A.x,y:A.y,containerWidth:e,children:typeof T=="function"?T(K):jsxRuntime.jsx(Nr,{title:K.xLabel,points:K.points})}):null]})}function Rf({data:e,series:t,x:r,y:n,height:o=260,width:a,size:s="md",grid:l="y",legend:i,tooltip:c=true,tableView:d=false,emphasis:u,title:f,description:m,loading:p=false,emptyState:w,onPointClick:v,orientation:x="vertical",stack:h="none",diverging:I,bins:S,curve:L="linear",barSize:R,sort:T="none",showValues:y=false,referenceLines:M,annotations:k,patterns:z=false,legendToggle:H=true,margin:P,locale:B,plotLabel:C,className:b,...E}){let N=We(),[W,F]=el.useState(()=>new Set),K=el.useId(),j=S!==void 0&&S!==false,A=j||typeof I!="string"?null:I,D=!j&&typeof I=="number"?I:0,V=el.useMemo(()=>{let Se=A===null?null:Mo([0,Math.max(1,t.length-1)],{center:Math.max(0,t.findIndex(De=>De.key===A)),symmetric:false});return t.map((De,Ne)=>({...De,slot:Ne,hidden:De.hidden||W.has(De.key),color:Se&&!De.color&&!u?De.key===A?Pr:Se(Ne):Lr(De,Ne,u)}))},[t,W,u,A]),O=el.useMemo(()=>Se=>nt(Se,B),[B]),_=el.useMemo(()=>{if(!j)return null;t.length>1&&!qi&&(qi=true,console.warn("[@synertech/ui] BarChart was given `bins` and more than one series. A histogram counts a single field \u2014 the extra series are ignored. Facet the chart, or draw the distributions side by side."));let Se=t[0]?.key??"count",De=r.format?re=>r.format(re,0):re=>O(re),Ne=Yi(e.map(re=>Ee(re,r.key)),S);return {rows:Ne.map(re=>({[r.key]:re.from,[Se]:re.count})),labels:Ne.map(re=>`${De(re.from)}\u2013${De(re.to)}`)}},[j,S,e,r.key,r.format,t,O]),X=el.useMemo(()=>{if(_)return _.rows;if(T==="none")return e;let Se=V.filter(Ne=>!Ne.hidden).map(Ne=>Ne.key),De=Ne=>Se.reduce((re,fe)=>re+(Ee(Ne,fe)??0),0);return [...e].sort((Ne,re)=>T==="asc"?De(Ne)-De(re):De(re)-De(Ne))},[_,e,T,V]),G=!j&&h==="percent",$=el.useMemo(()=>G?{domain:A===null?[0,100]:[-100,100],...n}:n,[G,A,n]),Y=el.useMemo(()=>{let Se=n?.format??(G?De=>Ut(De,{locale:B,alreadyScaled:true,maximumFractionDigits:0}):O);return A===null?Se:De=>Se(Math.abs(De))},[n?.format,G,B,O,A]),se=el.useMemo(()=>_?(Se,De)=>_.labels[De]??"":r.format??(Se=>Ze(Se,B)),[_,r.format,B]),ae=el.useMemo(()=>_?{...r,scale:"category"}:r,[_,r]),U=el.useCallback(Se=>{F(De=>{let Ne=new Set(De);return Ne.has(Se)?Ne.delete(Se):Ne.add(Se),Ne});},[]),Q=x==="vertical"?k:void 0;k&&x!=="vertical"&&!ji&&(ji=true,console.warn("[@synertech/ui] BarChart was given `annotations` and a horizontal orientation. Annotations are read on the category axis, which runs up the side there: they are ignored. Use `referenceLines` for a threshold on the value axis."));let le=i===void 0?t.length>=2:i!==false,ye=typeof i=="string"?i:"bottom",te=V.filter(Se=>!Se.hidden),Ce=te.length,Pe=el.useMemo(()=>{if(j||I===void 0||I===false||A!==null||Ce!==1)return null;let Se=fr(X,te.map(Ne=>Ne.key)),De=Ao([...Se,D],{domain:n?.domain,includeZero:n?.includeZero??D===0,ticks:n?.ticks??5});return Mo(De,{center:D})},[j,I,A,Ce,te,X,D,n]);return jsxRuntime.jsx(lt,{title:f,description:m,height:o,width:a,size:s,loading:p,empty:X.length===0||Ce===0,emptyState:w,tableView:d,legendPosition:ye,legend:Pe?jsxRuntime.jsx(Ra,{scale:Pe,label:n?.label,format:Y,size:s,locale:B}):le?jsxRuntime.jsx(Xt,{items:$r(V,u,z),position:ye,marker:"rect",size:s,onToggle:H?U:void 0}):void 0,table:d?jsxRuntime.jsx(zt,{data:X,series:V,xKey:ae.key,xLabel:r.label??r.key,formatX:se,formatValue:O,caption:typeof f=="string"?f:void 0}):void 0,className:b,...E,children:({width:Se})=>jsxRuntime.jsx(Sf,{width:Se,height:o,data:X,resolvedSeries:V,x:ae,y:$,grid:l,size:s,orientation:x,stack:j?"none":h,center:D,centerKey:A,valueColors:Pe,binned:j,curve:L,barSize:R,showValues:y,referenceLines:M,annotations:Q,annotationsLabel:N.chartAnnotations,patterns:z&&Pe===null,patternBaseId:K,margin:P,tooltip:c,onPointClick:v,plotLabel:C,formatValue:Y,formatRaw:O,formatX:se})})}function fd({className:e}){return jsxRuntime.jsx("svg",{className:e,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",children:jsxRuntime.jsx("path",{d:"M13 16H12V12H11M12 8H12.01M21 12C21 16.97 16.97 21 12 21C7.03 21 3 16.97 3 12C3 7.03 7.03 3 12 3C16.97 3 21 7.03 21 12Z",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})})}function Pf({className:e}){return jsxRuntime.jsx("svg",{className:e,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",children:jsxRuntime.jsx("path",{d:"M9 12L11 14L15 10M21 12C21 16.97 16.97 21 12 21C7.03 21 3 16.97 3 12C3 7.03 7.03 3 12 3C16.97 3 21 7.03 21 12Z",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})})}function Df({className:e}){return jsxRuntime.jsx("svg",{className:e,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",children:jsxRuntime.jsx("path",{d:"M12 9V13M12 17H12.01M10.29 3.86L1.82 18C1.65 18.3 1.55 18.65 1.55 18.99C1.55 19.34 1.64 19.69 1.81 19.99C1.99 20.29 2.24 20.55 2.54 20.72C2.84 20.901 3.18 20.99 3.53 21H20.47C20.82 20.99 21.16 20.901 21.46 20.72C21.76 20.55 22.01 20.29 22.19 19.99C22.36 19.69 22.449 19.34 22.448 18.99C22.447 18.65 22.35 18.3 22.18 18L13.71 3.86C13.53 3.57 13.28 3.32 12.98 3.15C12.68 2.99 12.34 2.9 12 2.9C11.66 2.9 11.32 2.99 11.02 3.15C10.72 3.32 10.47 3.57 10.29 3.86Z",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})})}function Lf({className:e}){return jsxRuntime.jsx("svg",{className:e,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",children:jsxRuntime.jsx("path",{d:"M12 8V12M12 16H12.01M21 12C21 16.97 16.97 21 12 21C7.03 21 3 16.97 3 12C3 7.03 7.03 3 12 3C16.97 3 21 7.03 21 12Z",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})})}function Qi({className:e}){return jsxRuntime.jsx("svg",{className:e,viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",children:jsxRuntime.jsx("path",{d:"M4 4L12 12M12 4L4 12",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})})}var Ef={info:fd,success:Pf,warning:Df,error:Lf,default:fd},Mf={info:"bg-blue-50 text-blue-800 border-blue-200 dark:bg-blue-900/20 dark:text-blue-300 dark:border-blue-800",success:"bg-green-50 text-green-800 border-green-200 dark:bg-green-900/20 dark:text-green-300 dark:border-green-800",warning:"bg-yellow-50 text-yellow-800 border-yellow-200 dark:bg-yellow-900/20 dark:text-yellow-300 dark:border-yellow-800",error:"bg-red-50 text-red-800 border-red-200 dark:bg-red-900/20 dark:text-red-300 dark:border-red-800",default:"bg-gray-50 text-gray-800 border-gray-200 dark:bg-gray-800 dark:text-gray-300 dark:border-gray-700"},If={info:"text-blue-600 dark:text-blue-400",success:"text-green-600 dark:text-green-400",warning:"text-yellow-600 dark:text-yellow-400",error:"text-red-600 dark:text-red-400",default:"text-gray-600 dark:text-gray-400"};function Af({type:e="default",title:t,description:r,children:n,icon:o,action:a,closable:s=false,onClose:l,fullWidth:i=false,className:c,...d}){let[u,f]=el.useState(true);if(!u)return null;let m=()=>{f(false),l?.();},p=Ef[e],w=n??r;return jsxRuntime.jsxs("div",{role:"alert",className:g("flex items-start gap-3 border px-4 py-3",i?"w-full":"rounded-lg",Mf[e],c),...d,children:[jsxRuntime.jsx("div",{className:g("shrink-0 mt-0.5",If[e]),children:o??jsxRuntime.jsx(p,{className:"w-5 h-5"})}),jsxRuntime.jsxs("div",{className:"flex-1 min-w-0",children:[t&&jsxRuntime.jsx("div",{className:"font-semibold text-sm",children:t}),w&&jsxRuntime.jsx("div",{className:g("text-sm",t?"mt-1 opacity-90":false),children:w}),a&&jsxRuntime.jsx("div",{className:"mt-3",children:a})]}),s&&jsxRuntime.jsx("button",{type:"button",onClick:m,className:g("shrink-0 rounded-md p-1 transition-colors","hover:bg-black/10 dark:hover:bg-white/10","focus:outline-none focus-visible:ring-2 focus-visible:ring-offset-2 focus-visible:ring-current"),"aria-label":"Close banner",children:jsxRuntime.jsx(Qi,{className:"w-4 h-4"})})]})}function zf({title:e,description:t,children:r,action:n,backgroundImage:o,closable:a=false,onClose:s,fullWidth:l=false,className:i,...c}){let[d,u]=el.useState(true);if(!d)return null;let f=()=>{u(false),s?.();},m=r??t;return jsxRuntime.jsxs("div",{className:g("relative overflow-hidden bg-gray-900 text-white",l?"w-full":"rounded-xl","py-12 px-6 sm:px-12",i),style:o?{backgroundImage:`url(${o})`,backgroundSize:"cover",backgroundPosition:"center"}:void 0,...c,children:[o&&jsxRuntime.jsx("div",{className:"absolute inset-0 bg-black/50","aria-hidden":"true"}),jsxRuntime.jsxs("div",{className:"relative z-10 max-w-3xl mx-auto text-center",children:[e&&jsxRuntime.jsx("h2",{className:"text-2xl sm:text-3xl lg:text-4xl font-bold tracking-tight",children:e}),m&&jsxRuntime.jsx("div",{className:g("text-base sm:text-lg opacity-90",e?"mt-4":false),children:m}),n&&jsxRuntime.jsx("div",{className:"mt-6",children:n})]}),a&&jsxRuntime.jsx("button",{type:"button",onClick:f,className:g("absolute top-4 right-4 z-10 rounded-md p-1.5 text-white/80 transition-colors","hover:text-white hover:bg-white/10","focus:outline-none focus-visible:ring-2 focus-visible:ring-offset-2 focus-visible:ring-white"),"aria-label":"Close banner",children:jsxRuntime.jsx(Qi,{className:"w-5 h-5"})})]})}function Wf({title:e,description:t,children:r,icon:n,action:o,badge:a,closable:s=false,onClose:l,fullWidth:i=false,className:c,...d}){let[u,f]=el.useState(true);if(!u)return null;let m=()=>{f(false),l?.();},p=r??t;return jsxRuntime.jsxs("div",{className:g("relative flex items-center gap-4 bg-linear-to-r from-indigo-600 to-purple-600 text-white px-4 py-3",i?"w-full":"rounded-lg",c),...d,children:[n&&jsxRuntime.jsx("div",{className:"shrink-0",children:n}),a&&jsxRuntime.jsx("span",{className:"shrink-0 inline-flex items-center rounded-full bg-white/20 px-2.5 py-0.5 text-xs font-semibold uppercase tracking-wide",children:a}),jsxRuntime.jsxs("div",{className:"flex-1 min-w-0 flex flex-wrap items-center gap-x-4 gap-y-1",children:[e&&jsxRuntime.jsx("span",{className:"font-semibold text-sm",children:e}),p&&jsxRuntime.jsx("span",{className:"text-sm opacity-90",children:p})]}),o&&jsxRuntime.jsx("div",{className:"shrink-0",children:o}),s&&jsxRuntime.jsx("button",{type:"button",onClick:m,className:g("shrink-0 rounded-md p-1 text-white/80 transition-colors","hover:text-white hover:bg-white/10","focus:outline-none focus-visible:ring-2 focus-visible:ring-offset-2 focus-visible:ring-white"),"aria-label":"Close banner",children:jsxRuntime.jsx(Qi,{className:"w-4 h-4"})})]})}function hd({variant:e="notification",...t}){switch(e){case "hero":return jsxRuntime.jsx(zf,{...t});case "promotion":return jsxRuntime.jsx(Wf,{...t});default:return jsxRuntime.jsx(Af,{...t})}}hd.displayName="Banner";var Hf={sm:"text-xs",md:"text-sm",lg:"text-base"};function Bf({items:e,separator:t="/",size:r="md",maxItems:n,itemColor:o="text-gray-500 hover:text-gray-900 dark:text-gray-400 dark:hover:text-gray-100",activeColor:a="text-gray-700 font-medium dark:text-gray-200",separatorColor:s="text-gray-400 dark:text-gray-500",className:l,...i}){let c=e,d=false;if(n&&e.length>n){d=true;let u=e[0],f=e.slice(-(n-1));c=[u,...f];}return jsxRuntime.jsx("nav",{"aria-label":"Breadcrumb",className:g("inline-flex items-center",Hf[r],l),...i,children:jsxRuntime.jsx("ol",{className:"inline-flex items-center space-x-1 md:space-x-2",children:c.map((u,f)=>{let m=f===c.length-1;return jsxRuntime.jsxs("li",{className:"inline-flex items-center",children:[d&&f===1&&jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("span",{className:g("mx-1 select-none",s),children:"..."}),jsxRuntime.jsx("span",{className:g("mx-1 select-none",s),"aria-hidden":"true",children:t})]}),u.href||u.onClick?jsxRuntime.jsxs("a",{href:u.href,onClick:u.onClick,className:g("inline-flex items-center gap-1.5 transition-colors",m?a:o),"aria-current":m?"page":void 0,children:[u.icon&&jsxRuntime.jsx("span",{className:"inline-flex","aria-hidden":"true",children:u.icon}),jsxRuntime.jsx("span",{children:u.label})]}):jsxRuntime.jsxs("span",{className:g("inline-flex items-center gap-1.5",m?a:o),"aria-current":m?"page":void 0,children:[u.icon&&jsxRuntime.jsx("span",{className:"inline-flex","aria-hidden":"true",children:u.icon}),jsxRuntime.jsx("span",{children:u.label})]}),!m&&jsxRuntime.jsx("span",{className:g("mx-2 select-none",s),"aria-hidden":"true",children:t})]},u.href??u.label)})})})}var $f=22,_f=.42,bd=3,yd=8,Xf=12,Gf=["fill-gray-300 dark:fill-gray-500","fill-gray-200 dark:fill-gray-600","fill-gray-100 dark:fill-gray-700","fill-gray-50 dark:fill-gray-800"],Kf=el.memo(function({rows:t,color:r}){return jsxRuntime.jsx("g",{children:t.map(n=>jsxRuntime.jsxs("g",{children:[n.bands.map(o=>jsxRuntime.jsx("path",{d:o.d,className:o.className,fill:o.fill},o.key)),n.measure?jsxRuntime.jsx("path",{d:n.measure,fill:r}):null,n.target?jsxRuntime.jsx("line",{x1:n.target.x,y1:n.target.y1,x2:n.target.x,y2:n.target.y2,strokeWidth:2,strokeLinecap:"round",className:"stroke-gray-900 dark:stroke-white"}):null,n.label?jsxRuntime.jsx("text",{x:n.label.x,y:n.label.y,dominantBaseline:"middle",className:"fill-gray-700 text-[11px] font-medium [font-variant-numeric:tabular-nums] dark:fill-gray-200",children:n.label.text}):null]},n.key))})});function Uf({width:e,height:t,rows:r,x:n,size:o,sharedDomain:a,showValues:s,trackSize:l,rangeColors:i,color:c,tooltip:d,plotLabel:u,formatValue:f,onRowClick:m}){let[p,w]=el.useState(null),v=el.useMemo(()=>{let L=r.map(N=>N.label),R=s?r.map(N=>N.formattedValue):[],T={top:6,right:s?wr(R)+yd*2:8,bottom:a?26+(n.label?16:0):6,left:n.hidden?8:n.height??wr(L)+Xf},y=Math.max(0,e-T.left-T.right),M=Math.max(0,t-T.top-T.bottom),k=xn(r.map((N,W)=>W),[0,M],{paddingInner:.34}),z=Math.min(l??$f,k.bandwidth),H=Math.max(3,z*_f),P=i??Gf,B=i!==void 0,C=r.map((N,W)=>{let F=Math.max(0,N.value??0,N.target??0,...N.ranges.length>0?N.ranges:[0]),K=a??(N.ranges.length>0?[0,F]:xs(0,F,4)),j=Er(K,[0,y]),A=k(W)+(k.bandwidth-z)/2,D=A+z/2,V=N.ranges.length>0?[...N.ranges].sort((G,$)=>G-$):[K[1]],O=K[0],_=V.map((G,$)=>{let Y=j(O),se=j(Math.max(O,G));O=G;let ae=P[Math.min($,P.length-1)];return {key:`${W}-${$}`,d:cr({x:Y,y:A,width:Math.max(0,se-Y),height:z,radius:0}),className:B?void 0:ae,fill:B?ae:void 0}}),X=N.value===null?null:cr({x:j(K[0]),y:D-H/2,width:Math.max(0,j(N.value)-j(K[0])),height:H,radius:2,round:"right"});return {key:`${W}`,bands:_,measure:X,target:N.target===null?null:{x:j(N.target),y1:A-bd,y2:A+z+bd},label:s?{x:y+yd,y:D,text:N.formattedValue}:null,top:k(W),height:k.bandwidth}}),b=n.hidden?[]:r.map((N,W)=>({value:N.x,offset:k.center(W),label:N.label})),E=a?wa(a[0],a[1],5).map(N=>({value:N,offset:Er(a,[0,y])(N),label:f(N)})):[];return {margin:T,innerWidth:y,innerHeight:M,band:k,rendered:C,categoryTicks:b,valueTicks:E,centers:r.map((N,W)=>k.center(W))}},[r,n,e,t,a,s,l,i,f]),x=el.useCallback(L=>{if(d===false||r.length===0)return;let R=L.currentTarget.getBoundingClientRect(),T=L.clientY-R.top-v.margin.top;w(Vt(v.centers,T));},[d,r.length,v.margin.top,v.centers]),h=el.useCallback(L=>{if(r.length===0)return;let R=r.length-1,T=p??0,y=L.key==="ArrowDown"?Math.min(R,T+1):L.key==="ArrowUp"?Math.max(0,T-1):L.key==="Home"?0:L.key==="End"?R:L.key==="Escape"?null:void 0;y!==void 0&&(L.preventDefault(),w(y));},[r.length,p]),I=el.useCallback(()=>{!m||p===null||m(r[p]);},[m,p,r]),S=p===null?null:r[p];return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsxs("svg",{width:e,height:t,role:"img","aria-label":u??r.map(L=>L.label).join(", "),tabIndex:0,className:"touch-none focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-blue-500",onPointerMove:x,onPointerLeave:()=>w(null),onKeyDown:h,onBlur:()=>w(null),onClick:I,children:[jsxRuntime.jsxs("g",{transform:`translate(${v.margin.left}, ${v.margin.top})`,children:[p!==null&&v.rendered[p]?jsxRuntime.jsx("rect",{x:-4,y:v.rendered[p].top,width:v.innerWidth+8,height:v.rendered[p].height,rx:4,className:"fill-gray-400 dark:fill-gray-500",opacity:.12,"aria-hidden":"true"}):null,jsxRuntime.jsx(Kf,{rows:v.rendered,color:c})]}),jsxRuntime.jsx("g",{transform:`translate(${v.margin.left}, ${v.margin.top})`,children:n.hidden?null:jsxRuntime.jsx(Ue,{orientation:"left",ticks:v.categoryTicks,length:v.innerHeight,showLine:false,tickSize:0,size:o})}),a?jsxRuntime.jsx("g",{transform:`translate(${v.margin.left}, ${v.margin.top+v.innerHeight})`,children:jsxRuntime.jsx(Ue,{orientation:"bottom",ticks:v.valueTicks,length:v.innerWidth,label:n.label,size:o})}):null]}),S&&p!==null&&d!==false?jsxRuntime.jsx(dt,{x:v.margin.left+v.innerWidth/2,y:v.margin.top+v.centers[p],containerWidth:e,children:typeof d=="function"?d(S):jsxRuntime.jsxs("div",{className:"flex flex-col gap-1",children:[jsxRuntime.jsx("div",{className:"font-medium text-gray-900 dark:text-gray-100",children:S.label}),jsxRuntime.jsxs("div",{className:"flex items-center gap-2",children:[jsxRuntime.jsx("span",{className:"h-0.5 w-3 shrink-0 rounded-full",style:{backgroundColor:c},"aria-hidden":"true"}),jsxRuntime.jsx("span",{className:"font-semibold text-gray-900 [font-variant-numeric:tabular-nums] dark:text-gray-100",children:S.formattedValue}),S.attainment!==null?jsxRuntime.jsx("span",{className:"text-gray-500 [font-variant-numeric:tabular-nums] dark:text-gray-400",children:Ut(S.attainment)}):null]})]})}):null]})}function Yf({data:e,x:t,value:r,target:n,ranges:o,domain:a,normalize:s="row",showValues:l=true,trackSize:i,rangeColors:c,color:d,height:u,width:f,size:m="md",tooltip:p=true,tableView:w=false,title:v,description:x,loading:h=false,emptyState:I,locale:S,plotLabel:L,valueLabel:R,targetLabel:T,format:y,onRowClick:M,className:k,...z}){let H=We(),P=el.useMemo(()=>y??(F=>nt(F,S)),[y,S]),B=el.useMemo(()=>t.format??(F=>Ze(F,S)),[t.format,S]),C=el.useMemo(()=>e.map((F,K)=>{let j=ct(F,t.key,K),A=Ee(F,r),D=n?Ee(F,n):null,V=o?F[o]:void 0,O=Array.isArray(V)?V.map(_=>typeof _=="number"?_:Number(_)).filter(_=>Number.isFinite(_)):[];return {index:K,x:j,label:B(j,K),value:A,target:D,ranges:O,formattedValue:A===null?"\u2014":P(A),formattedTarget:D===null?"\u2014":P(D),attainment:A===null||D===null||D===0?null:A/D,datum:F}}),[e,t.key,r,n,o,P,B]),b=el.useMemo(()=>{if(a)return a;if(s!=="shared")return null;let F=C.reduce((K,j)=>Math.max(K,j.value??0,j.target??0,...j.ranges),0);return xs(0,F,5)},[a,s,C]),E=u??Math.max(72,C.length*34+(b?30:12)),N=el.useMemo(()=>[{key:r,label:R??H.chartValue},...n?[{key:n,label:T??H.chartTarget}]:[]],[r,n,R,T,H.chartValue,H.chartTarget]),W=d??Dr(0);return jsxRuntime.jsx(lt,{title:v,description:x,height:E,width:f,size:m,loading:h,empty:C.length===0,emptyState:I,tableView:w,table:w?jsxRuntime.jsx(zt,{data:e,series:N,xKey:t.key,xLabel:t.label??t.key,formatX:B,formatValue:P,caption:typeof v=="string"?v:void 0}):void 0,className:k,...z,children:({width:F})=>jsxRuntime.jsx(Uf,{width:F,height:E,rows:C,x:t,size:m,sharedDomain:b,showValues:l,trackSize:i,rangeColors:c,color:W,tooltip:p,plotLabel:L,formatValue:P,onRowClick:M})})}function jf({className:e}){return jsxRuntime.jsxs("svg",{className:g("animate-spin",e),xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24","aria-hidden":"true",children:[jsxRuntime.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),jsxRuntime.jsx("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"})]})}var Zf={sm:"px-3 py-1.5 text-xs gap-1.5",md:"px-4 py-2 text-sm gap-2",lg:"px-5 py-2.5 text-base gap-2",xl:"px-6 py-3 text-lg gap-2.5"},Qf={sm:"p-1.5",md:"p-2",lg:"p-2.5",xl:"p-3"},ws={sm:"h-3.5 w-3.5",md:"h-4 w-4",lg:"h-5 w-5",xl:"h-6 w-6"},Jf={none:"rounded-none",sm:"rounded-sm",md:"rounded-md",lg:"rounded-lg",full:"rounded-full"};function Wt({label:e,children:t,onClick:r,disabled:n=false,className:o,type:a="button",size:s="md",loading:l=false,leftIcon:i,rightIcon:c,icon:d,fullWidth:u=false,rounded:f="lg",bgColor:m="bg-blue-600 hover:bg-blue-700",textColor:p="text-white",focusColor:w="focus:ring-blue-300",selected:v=false,value:x,showFocusOnClick:h=false,...I}){let S=n||l,L=d!==void 0&&!t&&!e,R=g("inline-flex items-center justify-center font-medium transition-colors focus:outline-none disabled:opacity-50 disabled:cursor-not-allowed",h?"focus:ring-4":"focus-visible:ring-4"),T=g(v?"bg-blue-700 text-white ring-2 ring-blue-500":m,!v&&p,w&&h&&`focus:ring-4 ${w}`,w&&!h&&`focus-visible:ring-4 ${w}`);return jsxRuntime.jsx("button",{type:a,onClick:r,disabled:S,"data-value":x,className:g(R,L?Qf[s]:Zf[s],Jf[f],T,u&&"w-full",o),...I,children:l?jsxRuntime.jsx(jf,{className:ws[s]}):L?jsxRuntime.jsx("span",{className:ws[s],children:d}):jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[i&&jsxRuntime.jsx("span",{className:ws[s],children:i}),t??e,c&&jsxRuntime.jsx("span",{className:ws[s],children:c})]})})}function _o({children:e,orientation:t="horizontal",size:r,fullWidth:n=false,selectedValue:o,onChange:a,className:s}){let i=el__namespace.default.Children.toArray(e).filter(d=>el__namespace.default.isValidElement(d)&&typeof d.type!="string"),c=(d,u)=>f=>{d!==void 0&&a&&a(d),u&&u(f);};return jsxRuntime.jsx("div",{className:g("inline-flex",t==="horizontal"?"flex-row":"flex-col",n&&"w-full",s),role:"group",children:i.map((d,u)=>{let f=u===0,m=u===i.length-1,p=!f&&!m,w=d.props.value,v=o!==void 0&&w===o,x=g(t==="horizontal"&&f&&"rounded-r-none",t==="horizontal"&&m&&"rounded-l-none",t==="horizontal"&&p&&"rounded-none",t==="horizontal"&&!f&&"-ml-px",t==="vertical"&&f&&"rounded-b-none",t==="vertical"&&m&&"rounded-t-none",t==="vertical"&&p&&"rounded-none",t==="vertical"&&!f&&"-mt-px",n&&"flex-1");return el__namespace.default.cloneElement(d,{...d.props,size:r??d.props.size,selected:v||d.props.selected,onClick:c(w,d.props.onClick),className:g(x,d.props.className)})})})}var n0=10080*60*1e3;function jt(e){return new Date(e.getFullYear(),e.getMonth(),e.getDate())}function co(e){return new Date(e.getFullYear(),e.getMonth(),1)}function Cn(e,t){return new Date(e.getFullYear(),e.getMonth(),e.getDate()+t)}function Gr(e,t){return new Date(e.getFullYear(),e.getMonth()+t,1)}function rl(e){return new Date(e.getFullYear(),e.getMonth()+1,0).getDate()}function nn(e,t){return !e||!t?false:e.getFullYear()===t.getFullYear()&&e.getMonth()===t.getMonth()&&e.getDate()===t.getDate()}function tl(e,t){return e.getFullYear()===t.getFullYear()&&e.getMonth()===t.getMonth()}function Hn(e,t){return e.getFullYear()*12+e.getMonth()-(t.getFullYear()*12+t.getMonth())}function Ss(e){let t=`${e.getMonth()+1}`.padStart(2,"0"),r=`${e.getDate()}`.padStart(2,"0");return `${e.getFullYear()}-${t}-${r}`}function o0(e){let t=jt(e);t.setDate(t.getDate()-(t.getDay()+6)%7+3);let r=new Date(t.getFullYear(),0,4);return r.setDate(r.getDate()-(r.getDay()+6)%7+3),1+Math.round((t.getTime()-r.getTime())/n0)}function Cd(e,t,r){return t&&e<jt(t)?jt(t):r&&e>jt(r)?jt(r):e}function a0(e,t,r){let n=co(e),o=(n.getDay()-t+7)%7,a=Cn(n,-o),s=r?6:Math.ceil((o+rl(e))/7);return Array.from({length:s},(l,i)=>Array.from({length:7},(c,d)=>Cn(a,i*7+d)))}function s0({className:e}){return jsxRuntime.jsx("svg",{className:e,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24","aria-hidden":"true",children:jsxRuntime.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M15 19l-7-7 7-7"})})}function i0({className:e}){return jsxRuntime.jsx("svg",{className:e,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24","aria-hidden":"true",children:jsxRuntime.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 5l7 7-7 7"})})}var l0={sm:{day:"h-7 w-7 text-xs",head:"h-7 w-7 text-[10px]",caption:"text-xs",nav:"h-6 w-6",icon:"h-3 w-3",padding:"p-2",gap:"gap-3",footer:"text-xs",select:"text-xs py-0.5 pl-1 pr-5"},md:{day:"h-9 w-9 text-sm",head:"h-9 w-9 text-xs",caption:"text-sm",nav:"h-7 w-7",icon:"h-4 w-4",padding:"p-3",gap:"gap-4",footer:"text-sm",select:"text-sm py-1 pl-1.5 pr-6"},lg:{day:"h-11 w-11 text-base",head:"h-11 w-11 text-sm",caption:"text-base",nav:"h-9 w-9",icon:"h-5 w-5",padding:"p-4",gap:"gap-5",footer:"text-sm",select:"text-base py-1.5 pl-2 pr-7"}},c0={primary:"bg-blue-600 text-white hover:bg-blue-700 dark:bg-blue-500 dark:hover:bg-blue-600",success:"bg-green-600 text-white hover:bg-green-700 dark:bg-green-500 dark:hover:bg-green-600",warning:"bg-yellow-500 text-white hover:bg-yellow-600 dark:bg-yellow-400 dark:text-gray-900 dark:hover:bg-yellow-500",error:"bg-red-600 text-white hover:bg-red-700 dark:bg-red-500 dark:hover:bg-red-600",info:"bg-cyan-600 text-white hover:bg-cyan-700 dark:bg-cyan-500 dark:hover:bg-cyan-600",neutral:"bg-gray-700 text-white hover:bg-gray-800 dark:bg-gray-500 dark:hover:bg-gray-400"},d0={primary:"bg-blue-50 dark:bg-blue-900/30",success:"bg-green-50 dark:bg-green-900/30",warning:"bg-yellow-50 dark:bg-yellow-900/30",error:"bg-red-50 dark:bg-red-900/30",info:"bg-cyan-50 dark:bg-cyan-900/30",neutral:"bg-gray-100 dark:bg-gray-700/40"},u0={primary:"text-blue-900 dark:text-blue-100",success:"text-green-900 dark:text-green-100",warning:"text-yellow-900 dark:text-yellow-100",error:"text-red-900 dark:text-red-100",info:"text-cyan-900 dark:text-cyan-100",neutral:"text-gray-900 dark:text-gray-100"},m0={primary:"font-semibold text-blue-600 dark:text-blue-400",success:"font-semibold text-green-600 dark:text-green-400",warning:"font-semibold text-yellow-600 dark:text-yellow-400",error:"font-semibold text-red-600 dark:text-red-400",info:"font-semibold text-cyan-600 dark:text-cyan-400",neutral:"font-semibold text-gray-900 dark:text-gray-100"},lo={primary:"focus-visible:ring-blue-500",success:"focus-visible:ring-green-500",warning:"focus-visible:ring-yellow-500",error:"focus-visible:ring-red-500",info:"focus-visible:ring-cyan-500",neutral:"focus-visible:ring-gray-500"};function Rs(e,t){if(e==="multiple")return Array.isArray(t)?t.map(jt):[];if(e==="range"){let r=t??null;return {from:r?.from?jt(r.from):null,to:r?.to?jt(r.to):null}}return t instanceof Date?jt(t):null}function kd(e){return e?e instanceof Date?e:Array.isArray(e)?e[0]??null:e.from??e.to??null:null}function nl(e){let{mode:t="single",value:r,defaultValue:n,onChange:o,max:a,month:s,defaultMonth:l,onMonthChange:i,numberOfMonths:c=1,weekStartsOn:d=0,locale:u,size:f="md",color:m="primary",minDate:p,maxDate:w,disabledDates:v,disabled:x=false,showOutsideDays:h=true,showWeekNumbers:I=false,fixedWeeks:S=false,captionLayout:L="label",fromYear:R,toYear:T,todayButton:y=false,clearButton:M=false,footer:k,bordered:z=true,renderDay:H,labels:P,className:B,...C}=e,b=l0[f],E=Math.max(1,c),N=el.useMemo(()=>jt(new Date),[]),W=r!==void 0,[F,K]=el.useState(()=>Rs(t,n)),j=W?Rs(t,r):F,A=s!==void 0,[D,V]=el.useState(()=>co(l??kd(Rs(t,n??r))??new Date)),O=A?co(s):D,_=el.useCallback(he=>{let ge=co(he);A||V(ge),i?.(ge);},[A,i]),X=el.useRef(null),G=el.useRef(false),[$,Y]=el.useState(()=>{let he=kd(Rs(t,n??r)),ge=co(l??s??he??new Date),J=he&&tl(he,ge)?he:tl(jt(new Date),ge)?jt(new Date):ge;return Cd(J,p,w)}),se=Gr(O,E-1),U=Hn($,O)>=0&&Hn($,se)<=0?$:O;el.useEffect(()=>{if(!G.current)return;G.current=false,X.current?.querySelector(`[data-day="${Ss($)}"]:not([data-outside])`)?.focus();},[$,O]);let Q=el.useCallback(he=>{let ge=Cd(jt(he),p,w);G.current=true,Y(ge);let J=Gr(O,E-1);Hn(ge,O)<0?_(ge):Hn(ge,J)>0&&_(Gr(ge,-(E-1)));},[O,E,p,w,_]),le=el.useCallback(he=>x||p&&he<jt(p)||w&&he>jt(w)?true:typeof v=="function"?v(he):Array.isArray(v)?v.some(ge=>nn(ge,he)):false,[x,p,w,v]),[ye,te]=el.useState(null),Ce=el.useCallback(he=>{W||K(he),o?.(he);},[W,o]),Pe=el.useCallback(he=>{let ge=jt(he);if(le(ge))return;if(t==="multiple"){let ne=j??[];if(ne.some(me=>nn(me,ge))){Ce(ne.filter(me=>!nn(me,ge)));return}if(a!==void 0&&ne.length>=a)return;Ce([...ne,ge].sort((me,Me)=>me.getTime()-Me.getTime()));return}if(t==="range"){let ne=j??{from:null,to:null};if(!ne.from||ne.to){Ce({from:ge,to:null});return}Ce(ge<ne.from?{from:ge,to:ne.from}:{from:ne.from,to:ge});return}Ce(nn(j,ge)?null:ge);},[t,j,a,Ce,le]),Se=el.useCallback(he=>{Pe(he),Y(jt(he)),Hn(he,O)<0?_(he):Hn(he,Gr(O,E-1))>0&&_(Gr(he,-(E-1)));},[Pe,O,E,_]),De=!x&&(!p||Hn(O,co(p))>0),Ne=!x&&(!w||Hn(Gr(O,E-1),co(w))<0),re=el.useCallback(()=>{_(Gr(O,-1));},[O,_]),fe=el.useCallback(()=>{_(Gr(O,1));},[O,_]),je=el.useCallback(he=>{if(x)return;let ge=$;switch(he.key){case "ArrowLeft":he.preventDefault(),Q(Cn(ge,-1));break;case "ArrowRight":he.preventDefault(),Q(Cn(ge,1));break;case "ArrowUp":he.preventDefault(),Q(Cn(ge,-7));break;case "ArrowDown":he.preventDefault(),Q(Cn(ge,7));break;case "Home":he.preventDefault(),Q(Cn(ge,-((ge.getDay()-d+7)%7)));break;case "End":he.preventDefault(),Q(Cn(ge,6-(ge.getDay()-d+7)%7));break;case "PageUp":{he.preventDefault();let J=he.shiftKey?-12:-1,ne=Gr(ge,J),be=Math.min(ge.getDate(),rl(ne));Q(new Date(ne.getFullYear(),ne.getMonth(),be));break}case "PageDown":{he.preventDefault();let J=he.shiftKey?12:1,ne=Gr(ge,J),be=Math.min(ge.getDate(),rl(ne));Q(new Date(ne.getFullYear(),ne.getMonth(),be));break}}},[x,$,Q,d]),Dt=el.useMemo(()=>{let he=new Intl.DateTimeFormat(u,{weekday:"short"}),ge=new Intl.DateTimeFormat(u,{weekday:"long"}),J=new Date(2024,0,7);return Array.from({length:7},(ne,be)=>{let me=Cn(J,(d+be)%7);return {short:he.format(me),long:ge.format(me)}})},[u,d]),Ie=el.useMemo(()=>{let he=new Intl.DateTimeFormat(u,{month:"long"});return Array.from({length:12},(ge,J)=>he.format(new Date(2024,J,1)))},[u]),we=el.useMemo(()=>new Intl.DateTimeFormat(u,{month:"long",year:"numeric"}),[u]),pt=el.useMemo(()=>new Intl.DateTimeFormat(u,{dateStyle:"full"}),[u]),Bt=el.useMemo(()=>{if(L!=="dropdown")return [];let he=N.getFullYear(),ge=R??p?.getFullYear()??he-100,J=T??w?.getFullYear()??he+10;return J<ge?[ge]:Array.from({length:J-ge+1},(ne,be)=>ge+be)},[L,R,T,p,w,N]),yt=t==="range"?j:null,er=yt&&yt.from&&!yt.to&&ye&&ye>yt.from?ye:null,Mt=yt?.to??er,Nt=el.useCallback((he,ge)=>{let J=!tl(he,ge),ne=le(he),be=false,me=false,Me=false,ke=false;return t==="multiple"?be=(j??[]).some(Re=>nn(Re,he)):t==="range"?(me=nn(yt?.from,he),Me=nn(Mt,he),be=me||Me,ke=!!(yt?.from&&Mt&&he>yt.from&&he<Mt)):be=nn(j,he),{selected:be,today:nn(he,N),outside:J,disabled:ne,rangeStart:me,rangeEnd:Me,inRange:ke}},[t,j,yt,Mt,le,N]),gr=he=>{let ge=Gr(O,he),J=a0(ge,d,S),ne=he===0,be=he===E-1;return jsxRuntime.jsxs("div",{className:"flex flex-col",children:[jsxRuntime.jsxs("div",{className:"mb-2 flex items-center justify-between",children:[jsxRuntime.jsx("button",{type:"button",onClick:re,disabled:!De,"aria-label":P?.previousMonth??"Previous month",className:g("inline-flex items-center justify-center rounded-md transition-colors","text-gray-600 hover:bg-gray-100 dark:text-gray-300 dark:hover:bg-gray-700","focus:outline-none focus-visible:ring-2 focus-visible:ring-offset-1 dark:focus-visible:ring-offset-gray-900",lo[m],b.nav,!De&&"cursor-not-allowed opacity-40 hover:bg-transparent dark:hover:bg-transparent",!ne&&"invisible"),children:jsxRuntime.jsx(s0,{className:b.icon})}),L==="dropdown"?jsxRuntime.jsxs("div",{className:"flex items-center gap-1",children:[jsxRuntime.jsx("select",{"aria-label":P?.monthSelect??"Month",value:ge.getMonth(),disabled:x,onChange:me=>_(new Date(ge.getFullYear(),Number(me.target.value)-he,1)),className:g("rounded-md border border-gray-300 bg-white font-medium text-gray-900","dark:border-gray-600 dark:bg-gray-800 dark:text-gray-100","focus:outline-none focus-visible:ring-2",lo[m],b.select,x&&"cursor-not-allowed opacity-50"),children:Ie.map((me,Me)=>jsxRuntime.jsx("option",{value:Me,children:me},me))}),jsxRuntime.jsx("select",{"aria-label":P?.yearSelect??"Year",value:ge.getFullYear(),disabled:x,onChange:me=>_(new Date(Number(me.target.value),ge.getMonth()-he,1)),className:g("rounded-md border border-gray-300 bg-white font-medium text-gray-900","dark:border-gray-600 dark:bg-gray-800 dark:text-gray-100","focus:outline-none focus-visible:ring-2",lo[m],b.select,x&&"cursor-not-allowed opacity-50"),children:Bt.map(me=>jsxRuntime.jsx("option",{value:me,children:me},me))})]}):jsxRuntime.jsx("div",{"aria-live":"polite",className:g("font-semibold text-gray-900 dark:text-gray-100",b.caption),children:we.format(ge)}),jsxRuntime.jsx("button",{type:"button",onClick:fe,disabled:!Ne,"aria-label":P?.nextMonth??"Next month",className:g("inline-flex items-center justify-center rounded-md transition-colors","text-gray-600 hover:bg-gray-100 dark:text-gray-300 dark:hover:bg-gray-700","focus:outline-none focus-visible:ring-2 focus-visible:ring-offset-1 dark:focus-visible:ring-offset-gray-900",lo[m],b.nav,!Ne&&"cursor-not-allowed opacity-40 hover:bg-transparent dark:hover:bg-transparent",!be&&"invisible"),children:jsxRuntime.jsx(i0,{className:b.icon})})]}),jsxRuntime.jsxs("table",{role:"grid","aria-label":we.format(ge),className:"border-collapse",children:[jsxRuntime.jsx("thead",{children:jsxRuntime.jsxs("tr",{children:[I&&jsxRuntime.jsxs("th",{scope:"col",className:g("font-normal text-gray-400 dark:text-gray-500",b.head),children:[jsxRuntime.jsx("span",{className:"sr-only",children:P?.weekNumber??"Week number"}),jsxRuntime.jsx("span",{"aria-hidden":"true",children:"#"})]}),Dt.map(me=>jsxRuntime.jsx("th",{scope:"col",abbr:me.long,className:g("font-medium uppercase text-gray-500 dark:text-gray-400",b.head),children:me.short},me.long))]})}),jsxRuntime.jsx("tbody",{children:J.map(me=>jsxRuntime.jsxs("tr",{children:[I&&jsxRuntime.jsx("td",{className:g("text-center align-middle text-gray-400 dark:text-gray-500",b.head),children:o0(me[0])}),me.map(Me=>{let ke=Nt(Me,ge),Re=Ss(Me);if(ke.outside&&!h)return jsxRuntime.jsx("td",{className:"p-0"},Re);let Be=nn(Me,U)&&!ke.outside,ze=ke.inRange||ke.rangeStart&&!!Mt||ke.rangeEnd&&!!yt?.from;return jsxRuntime.jsx("td",{role:"presentation",className:g("p-0",ze&&d0[m],ze&&ke.rangeStart&&"rounded-l-full",ze&&ke.rangeEnd&&"rounded-r-full"),children:jsxRuntime.jsx("button",{type:"button","data-day":Re,"data-selected":ke.selected||void 0,"data-today":ke.today||void 0,"data-outside":ke.outside||void 0,role:"gridcell",tabIndex:Be?0:-1,disabled:x,"aria-selected":ke.selected,"aria-disabled":ke.disabled||void 0,"aria-current":ke.today?"date":void 0,"aria-label":pt.format(Me),onClick:()=>{ke.disabled||Se(Me);},onMouseEnter:()=>t==="range"&&te(jt(Me)),onMouseLeave:()=>t==="range"&&te(null),onFocus:()=>Y(jt(Me)),className:g("inline-flex items-center justify-center rounded-full transition-colors","focus:outline-none focus-visible:ring-2 focus-visible:ring-offset-1 dark:focus-visible:ring-offset-gray-900",lo[m],b.day,ke.selected?c0[m]:ke.inRange?g(u0[m],"hover:bg-gray-200/60 dark:hover:bg-gray-600/60"):ke.today?g(m0[m],"hover:bg-gray-100 dark:hover:bg-gray-700"):g("text-gray-900 dark:text-gray-100","hover:bg-gray-100 dark:hover:bg-gray-700"),ke.outside&&!ke.selected&&"text-gray-400 dark:text-gray-500",ke.disabled&&"cursor-not-allowed opacity-40 hover:bg-transparent dark:hover:bg-transparent"),children:H?H(Me,ke):Me.getDate()})},Re)})]},Ss(me[0])))})]})]},Ss(ge))},pr=el.useCallback(()=>{_(N),Y(N),le(N)||Pe(N);},[N,_,le,Pe]),vt=el.useCallback(()=>{Ce(t==="multiple"?[]:t==="range"?{from:null,to:null}:null);},[t,Ce]),Cr=!!k||y||M;return jsxRuntime.jsxs("div",{ref:X,onKeyDown:je,className:g("inline-block bg-white dark:bg-gray-900",z&&"rounded-lg border border-gray-200 shadow-sm dark:border-gray-700",b.padding,x&&"opacity-60",B),...C,children:[jsxRuntime.jsx("div",{className:g("flex flex-wrap",b.gap),children:Array.from({length:E},(he,ge)=>gr(ge))}),Cr&&jsxRuntime.jsxs("div",{className:g("mt-3 flex items-center justify-between gap-2 border-t border-gray-200 pt-3 dark:border-gray-700",b.footer),children:[jsxRuntime.jsx("div",{className:"text-gray-600 dark:text-gray-400",children:k}),(y||M)&&jsxRuntime.jsxs("div",{className:"flex items-center gap-2",children:[y&&jsxRuntime.jsx("button",{type:"button",onClick:pr,disabled:x,className:g("rounded-md px-2 py-1 font-medium transition-colors","text-gray-700 hover:bg-gray-100 dark:text-gray-300 dark:hover:bg-gray-700","focus:outline-none focus-visible:ring-2",lo[m],x&&"cursor-not-allowed opacity-50"),children:P?.today??"Today"}),M&&jsxRuntime.jsx("button",{type:"button",onClick:vt,disabled:x,className:g("rounded-md px-2 py-1 font-medium transition-colors","text-gray-700 hover:bg-gray-100 dark:text-gray-300 dark:hover:bg-gray-700","focus:outline-none focus-visible:ring-2",lo[m],x&&"cursor-not-allowed opacity-50"),children:P?.clear??"Clear"})]})]})]})}function g0(e,t,r){let n=r||"bg-white dark:bg-gray-800",o=t||"border-gray-200 dark:border-gray-700";switch(e){case "outlined":return g("border-2 bg-transparent",o);case "elevated":return g("shadow-lg border-0",n);case "filled":return g(r||"bg-gray-100 dark:bg-gray-700","border-0");default:return g("border",o,n)}}function p0(e){switch(e){case "sm":return "max-w-sm";case "lg":return "max-w-2xl";default:return "max-w-md"}}function f0(e){switch(e){case "none":return "rounded-none";case "sm":return "rounded-sm";case "md":return "rounded-md";case "xl":return "rounded-xl";case "full":return "rounded-3xl";default:return "rounded-lg"}}function h0(e){switch(e){case "none":return "";case "sm":return "p-2";case "lg":return "p-6";default:return ""}}function wd({variant:e="default",size:t="md",rounded:r="lg",padding:n="none",bgColor:o,borderColor:a,shadowColor:s,hoverable:l=false,clickable:i=false,as:c="div",className:d,children:u,onClick:f,...m}){let p=c,w=l?"transition-all duration-200 hover:shadow-lg hover:-translate-y-0.5":"",v=i?"cursor-pointer active:scale-[0.98] transition-transform":"",x=s||"";return jsxRuntime.jsx(p,{className:g("overflow-hidden",g0(e,a,o),p0(t),f0(r),h0(n),w,v,x,d),onClick:i||f?f:void 0,...m,children:u})}wd.displayName="Card";function y0(e){switch(e){case "none":return "p-0";case "sm":return "px-3 py-2";case "lg":return "px-6 py-5";default:return "px-4 py-4"}}function Sd({actions:e,divider:t=false,padding:r="md",className:n,children:o,...a}){return jsxRuntime.jsxs("div",{className:g("flex items-center justify-between",y0(r),t&&"border-b border-gray-200 dark:border-gray-700",n),...a,children:[jsxRuntime.jsx("div",{className:"flex-1",children:o}),e&&jsxRuntime.jsx("div",{className:"flex items-center gap-2 ml-4",children:e})]})}Sd.displayName="CardHeader";function v0(e){switch(e){case "none":return "p-0";case "sm":return "px-3 py-2";case "lg":return "px-6 py-5";default:return "px-4 py-4"}}function Rd({padding:e="md",className:t,children:r,...n}){return jsxRuntime.jsx("div",{className:g(v0(e),t),...n,children:r})}Rd.displayName="CardBody";function k0(e){switch(e){case "none":return "p-0";case "sm":return "px-3 py-2";case "lg":return "px-6 py-5";default:return "px-4 py-4"}}function w0(e){switch(e){case "center":return "justify-center";case "right":return "justify-end";case "between":return "justify-between";default:return "justify-start"}}function Td({divider:e=false,align:t="left",padding:r="md",className:n,children:o,...a}){return jsxRuntime.jsx("div",{className:g("flex items-center gap-2",k0(r),w0(t),e&&"border-t border-gray-200 dark:border-gray-700",n),...a,children:o})}Td.displayName="CardFooter";function S0(e){switch(e){case "square":return "aspect-square";case "video":return "aspect-video";case "wide":return "aspect-[21/9]";default:return ""}}function R0(e){switch(e){case "contain":return "object-contain";case "fill":return "object-fill";case "none":return "object-none";default:return "object-cover"}}function Pd({position:e="top",aspectRatio:t="auto",objectFit:r="cover",src:n,alt:o,className:a,...s}){let l=e==="top"?"rounded-t-lg":"rounded-b-lg";return jsxRuntime.jsx("img",{src:n,alt:o,className:g("w-full",S0(t),R0(r),l,a),...s})}Pd.displayName="CardImage";function P0(e){switch(e){case "sm":return "text-base font-medium";case "lg":return "text-2xl font-bold";default:return "text-xl font-semibold"}}function Dd({as:e="h3",size:t="md",className:r,children:n,...o}){return jsxRuntime.jsx(e,{className:g("text-gray-900 dark:text-white",P0(t),r),...o,children:n})}Dd.displayName="CardTitle";function L0(e){switch(e){case "sm":return "text-xs";case "lg":return "text-base";default:return "text-sm"}}function Ld({size:e="md",className:t,children:r,...n}){return jsxRuntime.jsx("p",{className:g("text-gray-500 dark:text-gray-400",L0(e),t),...n,children:r})}Ld.displayName="CardDescription";function Pa(e,t){if(e.length===0)return Number.NaN;if(e.length===1)return e[0];let r=(e.length-1)*Math.min(1,Math.max(0,t)),n=Math.floor(r),o=r-n;return o===0?e[n]:e[n]+(e[n+1]-e[n])*o}function M0(e,t){let r=e.filter(Number.isFinite).sort((n,o)=>n-o);return Pa(r,t)}function ol(e,t=1.5){let r=e.filter(f=>typeof f=="number"&&Number.isFinite(f)).sort((f,m)=>f-m);if(r.length===0)return null;let n=Pa(r,.25),o=Pa(r,.5),a=Pa(r,.75),s=a-n,l=Math.max(0,t)*s,i=n-l,c=a+l,d=r.filter(f=>f>=i&&f<=c),u=r.filter(f=>f<i||f>c);return {count:r.length,min:r[0],max:r[r.length-1],q1:n,median:o,q3:a,iqr:s,lower:d.length>0?d[0]:n,upper:d.length>0?d[d.length-1]:a,outliers:u}}var z0=40,W0=3,Ts=4,sl="text-right [font-variant-numeric:tabular-nums]",H0=el.memo(function({boxes:t,color:r}){return jsxRuntime.jsx("g",{children:t.map(n=>jsxRuntime.jsxs("g",{children:[jsxRuntime.jsx("g",{stroke:r,strokeWidth:1.5,strokeLinecap:"round",children:n.whiskers.map(o=>jsxRuntime.jsx("line",{x1:o.x1,y1:o.y1,x2:o.x2,y2:o.y2},o.key))}),n.body?jsxRuntime.jsx("path",{d:n.body,fill:r}):null,n.median?jsxRuntime.jsx("line",{x1:n.median.x1,y1:n.median.y1,x2:n.median.x2,y2:n.median.y2,strokeWidth:2,className:"stroke-white dark:stroke-gray-800"}):null,n.mean?jsxRuntime.jsx("path",{d:`M${n.mean.cx},${n.mean.cy-Ts} L${n.mean.cx+Ts},${n.mean.cy} L${n.mean.cx},${n.mean.cy+Ts} L${n.mean.cx-Ts},${n.mean.cy} Z`,strokeWidth:1.5,stroke:r,className:"fill-white dark:fill-gray-800"}):null,n.outliers.map(o=>jsxRuntime.jsx("circle",{cx:o.cx,cy:o.cy,r:W0,fill:r,strokeWidth:1.5,className:"stroke-white dark:stroke-gray-800"},o.key))]},n.key))})});function B0({width:e,height:t,data:r,boxes:n,x:o,y:a,grid:s,size:l,orientation:i,boxSize:c,showOutliers:d,showMean:u,color:f,referenceLines:m,margin:p,tooltip:w,plotLabel:v,formatValue:x,formatX:h,onBoxClick:I}){let[S,L]=el.useState(null),R=We(),T=el.useMemo(()=>{let P=i==="vertical",B=n.flatMap(V=>V.stats===null?[]:[V.stats.min,V.stats.max,...u&&V.mean!==null?[V.mean]:[]]),C=rr({width:e,height:t,data:r,x:o,y:a,bounds:B.length===0?null:[Math.min(...B),Math.max(...B)],margin:p,orientation:i,placement:"band",formatValue:x,formatX:h,defaultIncludeZero:false}),{valueScale:b,bandwidth:E,categoryPositions:N,innerWidth:W,innerHeight:F}=C,K=Math.min(c??z0,E),j=K*.5,A=(V,O)=>P?{x:V,y:O}:{x:O,y:V},D=n.map((V,O)=>{let _=N[O]+(E-K)/2,X=_+K/2;if(V.stats===null)return {key:`${O}`,body:"",median:null,whiskers:[],outliers:[],mean:null,top:N[O],height:E};let{q1:G,q3:$,median:Y,lower:se,upper:ae,outliers:U}=V.stats,Q=b(G),le=b($),ye=Math.min(Q,le),te=Math.abs(le-Q),Ce=cr({...P?{x:_,y:ye,width:K,height:Math.max(1,te)}:{x:ye,y:_,width:Math.max(1,te),height:K},radius:2,round:"none"}),Pe=b(Y),Se=P?{x1:_,y1:Pe,x2:_+K,y2:Pe}:{x1:Pe,y1:_,x2:Pe,y2:_+K},De=[];for(let[Ne,re,fe]of [["lower",se,G],["upper",ae,$]]){let je=b(re),Dt=b(fe),Ie=A(X,je),we=A(X,Dt);De.push({key:`${Ne}-stem`,x1:we.x,y1:we.y,x2:Ie.x,y2:Ie.y});let pt=A(X-j/2,je),Bt=A(X+j/2,je);De.push({key:`${Ne}-cap`,x1:pt.x,y1:pt.y,x2:Bt.x,y2:Bt.y});}return {key:`${O}`,body:Ce,median:Se,whiskers:De,outliers:d?U.map((Ne,re)=>{let fe=A(X,b(Ne));return {key:`${re}`,cx:fe.x,cy:fe.y}}):[],mean:u&&V.mean!==null?(()=>{let Ne=A(X,b(V.mean));return {cx:Ne.x,cy:Ne.y}})():null,top:N[O],height:E}});return {vertical:P,rendered:D,categoryPositions:N,categoryCenters:C.categoryCenters,bandwidth:E,categoryTicks:C.categoryTicks,valueTicks:C.valueTicks,valueScale:b,innerWidth:W,innerHeight:F,margin:C.margin}},[n,r,o,a,e,t,p,i,c,d,u,x,h]),y=el.useCallback(P=>{if(w===false||n.length===0)return;let B=P.currentTarget.getBoundingClientRect(),C=T.vertical?P.clientX-B.left-T.margin.left:P.clientY-B.top-T.margin.top;L(Vt(T.categoryCenters,C));},[w,n.length,T.vertical,T.margin,T.categoryCenters]),M=el.useCallback(P=>{if(n.length===0)return;let B=n.length-1,C=S??0,b=T.vertical?"ArrowRight":"ArrowDown",E=T.vertical?"ArrowLeft":"ArrowUp",N=P.key===b?Math.min(B,C+1):P.key===E?Math.max(0,C-1):P.key==="Home"?0:P.key==="End"?B:P.key==="Escape"?null:void 0;N!==void 0&&(P.preventDefault(),L(N));},[n.length,S,T.vertical]),k=el.useCallback(()=>{!I||S===null||I(n[S]);},[I,S,n]),z=S===null?null:n[S],H=S===null||z===null||z.stats===null?null:T.vertical?{x:T.margin.left+T.categoryCenters[S],y:T.margin.top+T.valueScale(z.stats.q3)}:{x:T.margin.left+T.valueScale(z.stats.q3),y:T.margin.top+T.categoryCenters[S]};return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsxs("svg",{width:e,height:t,role:"img","aria-label":v??n.map(P=>P.label).join(", "),tabIndex:0,className:"touch-none focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-blue-500",onPointerMove:y,onPointerLeave:()=>L(null),onKeyDown:M,onBlur:()=>L(null),onClick:k,children:[jsxRuntime.jsxs("g",{transform:`translate(${T.margin.left}, ${T.margin.top})`,children:[jsxRuntime.jsx(_t,{width:T.innerWidth,height:T.innerHeight,horizontal:T.vertical&&(s==="y"||s==="both")?T.valueTicks.map(P=>P.offset):void 0,vertical:!T.vertical&&(s==="y"||s==="both")?T.valueTicks.map(P=>P.offset):void 0}),S!==null?jsxRuntime.jsx("rect",{x:T.vertical?T.categoryPositions[S]:0,y:T.vertical?0:T.categoryPositions[S],width:T.vertical?T.bandwidth:T.innerWidth,height:T.vertical?T.innerHeight:T.bandwidth,className:"fill-gray-400 dark:fill-gray-500",opacity:.12,"aria-hidden":"true"}):null,m?.map(P=>{let B=T.valueScale(P.value);return jsxRuntime.jsxs("g",{children:[jsxRuntime.jsx("line",{x1:T.vertical?0:B,y1:T.vertical?B:0,x2:T.vertical?T.innerWidth:B,y2:T.vertical?B:T.innerHeight,stroke:P.color??"var(--color-chart-muted)",strokeWidth:1,strokeDasharray:P.dashed===false?void 0:"4 4"}),P.label?jsxRuntime.jsx("text",{x:T.vertical?T.innerWidth:B+4,y:T.vertical?B-4:8,textAnchor:T.vertical?"end":"start",className:"fill-gray-500 text-[10px] dark:fill-gray-400",children:P.label}):null]},`${P.value}-${P.label??""}`)}),jsxRuntime.jsx(H0,{boxes:T.rendered,color:f})]}),jsxRuntime.jsx("g",{transform:`translate(${T.margin.left}, ${T.margin.top+T.innerHeight})`,children:(T.vertical?o.hidden:a?.hidden)?null:jsxRuntime.jsx(Ue,{orientation:"bottom",ticks:T.vertical?T.categoryTicks:T.valueTicks,length:T.innerWidth,label:T.vertical?o.label:a?.label,size:l})}),jsxRuntime.jsx("g",{transform:`translate(${T.margin.left}, ${T.margin.top})`,children:(T.vertical?a?.hidden:o.hidden)?null:jsxRuntime.jsx(Ue,{orientation:"left",ticks:T.vertical?T.valueTicks:T.categoryTicks,length:T.innerHeight,showLine:false,label:T.vertical?a?.label:o.label,size:l})})]}),z&&z.stats&&H&&w!==false?jsxRuntime.jsx(dt,{x:H.x,y:H.y,containerWidth:e,children:typeof w=="function"?w(z):jsxRuntime.jsxs("div",{className:"flex flex-col gap-1",children:[jsxRuntime.jsx("div",{className:"font-medium text-gray-900 dark:text-gray-100",children:z.label}),jsxRuntime.jsxs("dl",{className:"grid grid-cols-[auto_auto] gap-x-3 gap-y-0.5",children:[[["Max",z.stats.max],["Q3",z.stats.q3],[R.chartMedian,z.stats.median],["Q1",z.stats.q1],["Min",z.stats.min]].map(([P,B])=>jsxRuntime.jsxs("div",{className:"contents",children:[jsxRuntime.jsx("dt",{className:"text-gray-500 dark:text-gray-400",children:P}),jsxRuntime.jsx("dd",{className:"justify-self-end font-medium text-gray-900 [font-variant-numeric:tabular-nums] dark:text-gray-100",children:x(B)})]},P)),jsxRuntime.jsxs("div",{className:"contents",children:[jsxRuntime.jsx("dt",{className:"text-gray-500 dark:text-gray-400",children:R.chartCount}),jsxRuntime.jsx("dd",{className:"justify-self-end font-medium text-gray-900 [font-variant-numeric:tabular-nums] dark:text-gray-100",children:z.stats.count})]})]})]})}):null]})}function V0({data:e,x:t,y:r,values:n,quantiles:o,whisker:a=1.5,orientation:s="vertical",boxSize:l,showOutliers:i=true,showMean:c=false,color:d,referenceLines:u,height:f=280,width:m,size:p="md",grid:w="y",tooltip:v=true,tableView:x=false,title:h,description:I,loading:S=false,emptyState:L,margin:R,locale:T,plotLabel:y,format:M,onBoxClick:k,className:z,...H}){let P=We(),B=el.useMemo(()=>r?.format??M??(N=>nt(N,T)),[r?.format,M,T]),C=el.useMemo(()=>t.format??(N=>Ze(N,T)),[t.format,T]),b=el.useMemo(()=>e.map((N,W)=>{let F=ct(N,t.key,W),K=n?(()=>{let D=N[n];return Array.isArray(D)?D.map(V=>typeof V=="number"?V:Number(V)).filter(V=>Number.isFinite(V)):null})():null,j=null,A=null;if(K!==null)j=ol(K,a),A=K.length===0?null:K.reduce((D,V)=>D+V,0)/K.length;else if(o){let D=Ee(N,o.q1),V=Ee(N,o.median),O=Ee(N,o.q3);if(D!==null&&V!==null&&O!==null){let _=o.min?Ee(N,o.min)??D:D,X=o.max?Ee(N,o.max)??O:O;j={count:0,min:_,max:X,q1:D,median:V,q3:O,iqr:O-D,lower:_,upper:X,outliers:[]};}}return {index:W,x:F,label:C(F,W),stats:j,mean:A,datum:N}}),[e,t.key,n,o,a,C]),E=b.filter(N=>N.stats!==null);return jsxRuntime.jsx(lt,{title:h,description:I,height:f,width:m,size:p,loading:S,empty:E.length===0,emptyState:L,tableView:x,table:x?jsxRuntime.jsx("div",{className:"w-full overflow-x-auto",children:jsxRuntime.jsxs(fn,{children:[typeof h=="string"?jsxRuntime.jsx("caption",{className:"sr-only",children:h}):null,jsxRuntime.jsxs(bn,{children:[jsxRuntime.jsx(St,{children:t.label??t.key}),n?jsxRuntime.jsx(St,{className:"text-right",children:P.chartCount}):null,jsxRuntime.jsx(St,{className:"text-right",children:"Min"}),jsxRuntime.jsx(St,{className:"text-right",children:"Q1"}),jsxRuntime.jsx(St,{className:"text-right",children:P.chartMedian}),jsxRuntime.jsx(St,{className:"text-right",children:"Q3"}),jsxRuntime.jsx(St,{className:"text-right",children:"Max"}),n&&i?jsxRuntime.jsx(St,{className:"text-right",children:P.chartOutliers}):null]}),jsxRuntime.jsx(hn,{children:b.map(N=>jsxRuntime.jsxs(yn,{clickable:false,children:[jsxRuntime.jsx(Gt,{className:"font-medium text-gray-900 dark:text-gray-100",children:N.label}),n?jsxRuntime.jsx(Gt,{className:sl,children:N.stats?.count??"\u2014"}):null,["min","q1","median","q3","max"].map(W=>jsxRuntime.jsx(Gt,{className:sl,children:N.stats===null?"\u2014":B(N.stats[W])},W)),n&&i?jsxRuntime.jsx(Gt,{className:sl,children:N.stats===null||N.stats.outliers.length===0?"\u2014":N.stats.outliers.map(B).join(", ")}):null]},N.index))})]})}):void 0,className:z,...H,children:({width:N})=>jsxRuntime.jsx(B0,{width:N,height:f,data:e,boxes:b,x:t,y:r,grid:w,size:p,orientation:s,boxSize:l,showOutliers:i,showMean:c,color:d??Dr(0),referenceLines:u,margin:R,tooltip:v,plotLabel:y,formatValue:B,formatX:C,onBoxClick:k})})}var _0=16,X0=1.5,G0=el.memo(function({candles:t}){return jsxRuntime.jsx("g",{children:t.map(r=>jsxRuntime.jsxs("g",{children:[r.wick?jsxRuntime.jsx("line",{x1:r.wick.x,y1:r.wick.y1,x2:r.wick.x,y2:r.wick.y2,stroke:r.color,strokeWidth:1.5}):null,r.body?jsxRuntime.jsx("path",{d:r.body,fill:r.hollow?"none":r.color,stroke:r.color,strokeWidth:r.hollow?1.5:0}):null]},r.key))})});function K0({width:e,height:t,data:r,candles:n,x:o,y:a,grid:s,size:l,candleSize:i,fillRising:c,palette:d,referenceLines:u,margin:f,tooltip:m,plotLabel:p,formatValue:w,formatX:v,onCandleClick:x}){let[h,I]=el.useState(null),S=We(),L=el.useMemo(()=>{let k=n.flatMap(W=>W.high===null||W.low===null?[]:[W.low,W.high]),z=rr({width:e,height:t,data:r,x:o,y:a,bounds:k.length===0?null:[Math.min(...k),Math.max(...k)],margin:f,orientation:"vertical",placement:"band",formatValue:w,formatX:v,defaultIncludeZero:false}),{valueScale:H,bandwidth:P,categoryPositions:B,innerWidth:C,innerHeight:b}=z,E=Math.min(i??_0,Math.max(1,P-2));return {rendered:n.map((W,F)=>{let K=B[F]+(P-E)/2,j=K+E/2,A=W.rising?d.up:d.down,D=W.high===null||W.low===null?null:{x:j,y1:H(W.high),y2:H(W.low)},V=null;if(W.open!==null&&W.close!==null){let O=H(W.open),_=H(W.close);V=cr({x:K,y:Math.min(O,_),width:E,height:Math.max(X0,Math.abs(_-O)),radius:0,round:"none"});}return {key:`${F}`,color:A,body:V,hollow:W.rising&&!c,wick:D,left:K,width:E}}),categoryPositions:B,categoryCenters:z.categoryCenters,bandwidth:P,categoryTicks:z.categoryTicks,valueTicks:z.valueTicks,valueScale:H,innerWidth:C,innerHeight:b,margin:z.margin}},[n,r,o,a,e,t,f,i,c,d,w,v]),R=el.useCallback(k=>{if(m===false||n.length===0)return;let z=k.currentTarget.getBoundingClientRect(),H=k.clientX-z.left-L.margin.left;I(Vt(L.categoryCenters,H));},[m,n.length,L.margin.left,L.categoryCenters]),T=el.useCallback(k=>{if(n.length===0)return;let z=n.length-1,H=h??0,P=k.key==="ArrowRight"?Math.min(z,H+1):k.key==="ArrowLeft"?Math.max(0,H-1):k.key==="Home"?0:k.key==="End"?z:k.key==="Escape"?null:void 0;P!==void 0&&(k.preventDefault(),I(P));},[n.length,h]),y=el.useCallback(()=>{!x||h===null||x(n[h]);},[x,h,n]),M=h===null?null:n[h];return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsxs("svg",{width:e,height:t,role:"img","aria-label":p??n.map(k=>k.label).join(", "),tabIndex:0,className:"touch-none focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-blue-500",onPointerMove:R,onPointerLeave:()=>I(null),onKeyDown:T,onBlur:()=>I(null),onClick:y,children:[jsxRuntime.jsxs("g",{transform:`translate(${L.margin.left}, ${L.margin.top})`,children:[jsxRuntime.jsx(_t,{width:L.innerWidth,height:L.innerHeight,horizontal:s==="y"||s==="both"?L.valueTicks.map(k=>k.offset):void 0}),h!==null?jsxRuntime.jsx("rect",{x:L.categoryPositions[h],y:0,width:L.bandwidth,height:L.innerHeight,className:"fill-gray-400 dark:fill-gray-500",opacity:.12,"aria-hidden":"true"}):null,u?.map(k=>jsxRuntime.jsxs("g",{children:[jsxRuntime.jsx("line",{x1:0,y1:L.valueScale(k.value),x2:L.innerWidth,y2:L.valueScale(k.value),stroke:k.color??"var(--color-chart-muted)",strokeWidth:1,strokeDasharray:k.dashed===false?void 0:"4 4"}),k.label?jsxRuntime.jsx("text",{x:L.innerWidth,y:L.valueScale(k.value)-4,textAnchor:"end",className:"fill-gray-500 text-[10px] dark:fill-gray-400",children:k.label}):null]},`${k.value}-${k.label??""}`)),jsxRuntime.jsx(G0,{candles:L.rendered})]}),jsxRuntime.jsx("g",{transform:`translate(${L.margin.left}, ${L.margin.top+L.innerHeight})`,children:o.hidden?null:jsxRuntime.jsx(Ue,{orientation:"bottom",ticks:L.categoryTicks,length:L.innerWidth,label:o.label,size:l})}),jsxRuntime.jsx("g",{transform:`translate(${L.margin.left}, ${L.margin.top})`,children:a?.hidden?null:jsxRuntime.jsx(Ue,{orientation:"left",ticks:L.valueTicks,length:L.innerHeight,showLine:false,label:a?.label,size:l})})]}),M&&h!==null&&m!==false?jsxRuntime.jsx(dt,{x:L.margin.left+L.categoryCenters[h],y:L.margin.top+(M.high===null?L.innerHeight/2:L.valueScale(M.high)),containerWidth:e,children:typeof m=="function"?m(M):jsxRuntime.jsxs("div",{className:"flex flex-col gap-1",children:[jsxRuntime.jsx("div",{className:"font-medium text-gray-900 dark:text-gray-100",children:M.label}),jsxRuntime.jsx("dl",{className:"grid grid-cols-[auto_auto] gap-x-3 gap-y-0.5",children:[[S.chartOpen,M.open],[S.chartHigh,M.high],[S.chartLow,M.low],[S.chartClose,M.close]].map(([k,z])=>jsxRuntime.jsxs("div",{className:"contents",children:[jsxRuntime.jsx("dt",{className:"text-gray-500 dark:text-gray-400",children:k}),jsxRuntime.jsx("dd",{className:"justify-self-end font-medium text-gray-900 [font-variant-numeric:tabular-nums] dark:text-gray-100",children:z===null?"\u2014":w(z)})]},k))}),M.change===null?null:jsxRuntime.jsxs("div",{className:"flex items-center gap-2 border-t border-gray-200 pt-1 dark:border-gray-700",children:[jsxRuntime.jsx("span",{className:"text-gray-500 dark:text-gray-400",children:M.rising?S.chartRise:S.chartFall}),jsxRuntime.jsxs("span",{className:"[font-variant-numeric:tabular-nums] font-semibold text-gray-900 dark:text-gray-100",children:[M.change>0?"+":"",w(M.change)]})]})]})}):null]})}function U0({data:e,x:t,y:r,open:n,high:o,low:a,close:s,candleSize:l,fillRising:i=false,colors:c,referenceLines:d,height:u=300,width:f,size:m="md",grid:p="y",legend:w,tooltip:v=true,tableView:x=false,title:h,description:I,loading:S=false,emptyState:L,margin:R,locale:T,plotLabel:y,openLabel:M,highLabel:k,lowLabel:z,closeLabel:H,riseLabel:P,fallLabel:B,format:C,onCandleClick:b,className:E,...N}){let W=We(),F=el.useMemo(()=>r?.format??C??(_=>nt(_,T)),[r?.format,C,T]),K=el.useMemo(()=>t.format??(_=>Ze(_,T)),[t.format,T]),j=el.useMemo(()=>e.map((_,X)=>{let G=ct(_,t.key,X),$=Ee(_,n),Y=Ee(_,s);return {index:X,x:G,label:K(G,X),open:$,high:Ee(_,o),low:Ee(_,a),close:Y,change:$===null||Y===null?null:Y-$,rising:$===null||Y===null?true:Y>=$,datum:_}}),[e,t.key,n,o,a,s,K]),A=el.useMemo(()=>({up:c?.up??Fi,down:c?.down??Oi}),[c]),D=el.useMemo(()=>[{key:"up",label:P??W.chartRise,color:A.up,marker:"rect"},{key:"down",label:B??W.chartFall,color:A.down,marker:"rect"}],[A,P,B,W.chartRise,W.chartFall]),V=w===void 0?true:w!==false,O=typeof w=="string"?w:"bottom";return jsxRuntime.jsx(lt,{title:h,description:I,height:u,width:f,size:m,loading:S,empty:j.length===0,emptyState:L,tableView:x,legendPosition:O,legend:V?jsxRuntime.jsx(Xt,{items:D,position:O,marker:"rect",size:m}):void 0,table:x?jsxRuntime.jsx(zt,{data:e,series:[{key:n,label:M??W.chartOpen},{key:o,label:k??W.chartHigh},{key:a,label:z??W.chartLow},{key:s,label:H??W.chartClose}],xKey:t.key,xLabel:t.label??t.key,formatX:K,formatValue:F,caption:typeof h=="string"?h:void 0}):void 0,className:E,...N,children:({width:_})=>jsxRuntime.jsx(K0,{width:_,height:u,data:e,candles:j,x:t,y:r,grid:p,size:m,candleSize:l,fillRising:i,palette:A,referenceLines:d,margin:R,tooltip:v,plotLabel:y,formatValue:F,formatX:K,onCandleClick:b})})}var Ed=12,cl=false,q0={sm:"text-[11px]",md:"text-xs",lg:"text-sm"},j0={sm:"text-xs",md:"text-sm",lg:"text-base"};function Z0({data:e,by:t,values:r,domain:n,includeZero:o=false,ticks:a=5,order:s,sort:l="none",columns:i,minPanelWidth:c=220,formatLabel:d,showLabels:u=true,title:f,description:m,size:p="md",locale:w,emptyState:v,children:x,className:h,...I}){let S=d??(y=>Ze(y,w)),L=new Map;e.forEach((y,M)=>{let k=ct(y,t,M),z=ft(k),H=L.get(z);H?H.rows.push(y):L.set(z,{value:k,rows:[y]});});let R=[...L.entries()];if(s)R=s.map(ft).map(M=>R.find(([k])=>k===M)).filter(M=>M!==void 0);else if(l!=="none"){let y=M=>M.reduce((k,z)=>k+r.reduce((H,P)=>H+(Ee(z,P)??0),0),0);R=[...R].sort(([,M],[,k])=>l==="asc"?y(M.rows)-y(k.rows):y(k.rows)-y(M.rows));}let T=n??Ao(fr(e,r),{includeZero:o,ticks:a});return R.length>Ed&&!cl&&(cl=true,console.warn(`[@synertech/ui] ChartFacets was given ${R.length} panels. Past ${Ed} a facet grid stops being a comparison \u2014 filter the data down to the panels the reader is actually comparing.`)),R.length===0?jsxRuntime.jsx("div",{className:g("text-sm text-gray-500 dark:text-gray-400",h),...I,children:v}):jsxRuntime.jsxs("div",{className:g("flex w-full flex-col gap-3",h),...I,children:[f||m?jsxRuntime.jsxs("div",{className:"flex flex-col gap-0.5",children:[f?jsxRuntime.jsx("span",{className:g("font-semibold text-gray-900 dark:text-gray-100",j0[p]),children:f}):null,m?jsxRuntime.jsx("span",{className:"text-xs text-gray-500 dark:text-gray-400",children:m}):null]}):null,jsxRuntime.jsx("div",{className:"grid gap-x-4 gap-y-3",style:{gridTemplateColumns:i?`repeat(${i}, minmax(0, 1fr))`:`repeat(auto-fit, minmax(${c}px, 1fr))`},children:R.map(([y,M],k)=>{let z=S(M.value,k);return jsxRuntime.jsxs("div",{role:"group","aria-label":z,className:"flex min-w-0 flex-col gap-1",children:[u?jsxRuntime.jsx("span",{className:g("font-medium text-gray-700 dark:text-gray-200",q0[p]),children:z}):null,x({key:y,label:z,data:M.rows,domain:T,index:k,count:R.length})]},y)})})]})}function Q0(){cl=false;}var J0={sm:"gap-1.5",md:"gap-2",lg:"gap-3"};function eh({label:e,actions:t,sticky:r=false,bordered:n=true,size:o="md",children:a,className:s,...l}){let i=We();return jsxRuntime.jsxs("div",{role:"group","aria-label":e??i.chartFilters,className:g("flex w-full flex-wrap items-center",J0[o],n&&"border-b border-gray-200 pb-3 dark:border-gray-700",r&&"sticky top-0 z-10 bg-white/95 pt-3 backdrop-blur-sm dark:bg-gray-900/95",s),...l,children:[a,t?jsxRuntime.jsx("div",{className:"ml-auto flex items-center gap-2",children:t}):null]})}var nh=new Set(["SCRIPT","STYLE","LINK","META","NOSCRIPT","TEMPLATE","BASE","TITLE"]),Md="data-synertech-inert-ignore",La=new WeakMap,dl=new WeakMap,ul=new WeakMap;function oh(e){let t=La.get(e)??0;t===0&&(dl.set(e,e.getAttribute("aria-hidden")),ul.set(e,e.hasAttribute("inert")),e.setAttribute("aria-hidden","true"),e.setAttribute("inert","")),La.set(e,t+1);}function ah(e){let t=La.get(e)??0;if(t===0)return;if(t>1){La.set(e,t-1);return}La.delete(e);let r=dl.get(e)??null;r===null?e.removeAttribute("aria-hidden"):e.setAttribute("aria-hidden",r),dl.delete(e),ul.get(e)||e.removeAttribute("inert"),ul.delete(e);}var Ds=new Map;function wn(e,t){return Ds.set(e,t),()=>{Ds.delete(e);}}function Ls(e){if(Ds.size===0)return [];let t=[];for(let[r,n]of Ds){let o=n();o&&e.some(a=>a.contains(o))&&t.push(r);}return t}function sh(e){return !(nh.has(e.tagName)||e.hasAttribute(Md))}function ml(e){let t=(Array.isArray(e)?e:[e]).filter(Boolean),r=t[0]?.ownerDocument?.body;if(!r||!t.every(i=>r.contains(i)))return ()=>{};let n=[...t,...Ls(t).filter(i=>r.contains(i))],o=[],a=new Set,s=i=>n.some(c=>i===c||i.contains(c));for(let i of t){let c=i;for(;c&&c!==r;){let d=c.parentElement;if(!d)break;for(let u of Array.from(d.children))a.has(u)||s(u)||sh(u)&&(a.add(u),oh(u),o.push(u));c=d;}}let l=false;return ()=>{if(!l){l=true;for(let i of o)ah(i);}}}function Bn({triggerRef:e,contentRef:t,isOpen:r,side:n="bottom",align:o="start",sideOffset:a=4,alignOffset:s=0,avoidCollisions:l=true,collisionPadding:i=8}){let[c,d]=el.useState({top:0,left:0,actualSide:n,actualAlign:o,isReady:false}),u=el.useRef(false),f=el.useCallback(()=>{if(!e.current||!t.current)return;let m=e.current.getBoundingClientRect(),p=t.current.getBoundingClientRect();if(!(m.width>0&&m.height>0&&p.width>0&&p.height>0)){u.current=false;return}let v={width:window.innerWidth,height:window.innerHeight},x=n,h=o,I=R=>{switch(R){case "bottom":return {top:m.bottom+a,left:m.left};case "top":return {top:m.top-p.height-a,left:m.left};case "right":return {top:m.top,left:m.right+a};case "left":return {top:m.top,left:m.left-p.width-a}}},S=(R,T,y)=>{if(R==="top"||R==="bottom")switch(T){case "start":return {...y,left:m.left+s};case "center":return {...y,left:m.left+m.width/2-p.width/2+s};case "end":return {...y,left:m.right-p.width+s}}else switch(T){case "start":return {...y,top:m.top+s};case "center":return {...y,top:m.top+m.height/2-p.height/2+s};case "end":return {...y,top:m.bottom-p.height+s}}},L=I(x);if(L=S(x,h,L),l){let{top:R,left:T}=L,{height:y,width:M}=p,{height:k,width:z}=v,H=R+y>k-i,P=R<i,B=T+M>z-i,C=T<i;x==="bottom"&&H&&!P?(x="top",L=I(x),L=S(x,h,L)):x==="top"&&P&&!H&&(x="bottom",L=I(x),L=S(x,h,L)),x==="right"&&B&&!C?(x="left",L=I(x),L=S(x,h,L)):x==="left"&&C&&!B&&(x="right",L=I(x),L=S(x,h,L));let b=L.left+M>z-i,E=L.left<i,N=L.top+y>k-i,W=L.top<i;(x==="top"||x==="bottom")&&(b&&(L.left=z-M-i,h="end"),E&&(L.left=i,h="start")),(x==="left"||x==="right")&&(N&&(L.top=k-y-i,h="end"),W&&(L.top=i,h="start"));}u.current=true,d({top:L.top,left:L.left,actualSide:x,actualAlign:h,isReady:true});},[e,t,n,o,a,s,l,i]);return el.useLayoutEffect(()=>{let m=0;if(r){u.current=false;let w=()=>{f(),u.current||(m=requestAnimationFrame(w));};m=requestAnimationFrame(w);}let p=()=>f();return window.addEventListener("resize",p),window.addEventListener("scroll",p,{passive:true,capture:true}),()=>{m&&cancelAnimationFrame(m),window.removeEventListener("resize",p),window.removeEventListener("scroll",p,{capture:true});}},[f,r]),c}var gl=["7d","30d","90d","12m","mtd","ytd"];function Es(e){let t=new Date(e);return t.setHours(0,0,0,0),t}function Ms(e){let t=new Date(e);return t.setHours(23,59,59,999),t}function Id(e,t=new Date){let r=Ms(t),n=Es(t);switch(e){case "7d":n.setDate(n.getDate()-6);break;case "30d":n.setDate(n.getDate()-29);break;case "90d":n.setDate(n.getDate()-89);break;case "12m":n.setMonth(n.getMonth()-12),n.setDate(n.getDate()+1);break;case "mtd":n.setDate(1);break;case "qtd":n.setMonth(Math.floor(n.getMonth()/3)*3,1);break;case "ytd":n.setMonth(0,1);break;}return {from:n,to:r}}function Ea(e,t=new Date){return {preset:e,...Id(e,t)}}function pl(e,t,r){let n=new Intl.DateTimeFormat(r,{day:"numeric",month:"short",year:"numeric"});if(typeof n.formatRange=="function")try{return n.formatRange(e,t)}catch{}return `${n.format(e)} \u2013 ${n.format(t)}`}function uh(e,t){return !e||!t?e===t:e.preset===t.preset&&e.from.getTime()===t.from.getTime()&&e.to.getTime()===t.to.getTime()}var gh={"7d":"chartPeriodLast7Days","30d":"chartPeriodLast30Days","90d":"chartPeriodLast90Days","12m":"chartPeriodLast12Months",mtd:"chartPeriodMonthToDate",qtd:"chartPeriodQuarterToDate",ytd:"chartPeriodYearToDate",custom:"chartPeriodCustom"},ph={sm:"h-7 px-2.5 text-xs",md:"h-8 px-3 text-sm",lg:"h-10 px-4 text-sm"},fh=jsxRuntime.jsx("svg",{width:"14",height:"14",viewBox:"0 0 16 16",fill:"none","aria-hidden":"true",className:"shrink-0",children:jsxRuntime.jsx("path",{d:"M5 1.5v2M11 1.5v2M2.5 6h11M3.5 3h9a1 1 0 011 1v9a1 1 0 01-1 1h-9a1 1 0 01-1-1V4a1 1 0 011-1z",stroke:"currentColor",strokeWidth:"1.3",strokeLinecap:"round",strokeLinejoin:"round"})});function hh({value:e,defaultValue:t,onChange:r,presets:n=gl,custom:o=true,presetLabels:a,now:s,minDate:l,maxDate:i,numberOfMonths:c=1,weekStartsOn:d,locale:u,size:f="md",align:m="start",disabled:p=false,label:w,className:v,...x}){let h=We(),I=el.useRef(null),S=el.useRef(null),L=el.useRef(null),[R,T]=el.useState(false),[y,M]=el.useState(false),[k,z]=el.useState(null),[H,P]=el.useState(()=>typeof t=="string"?Ea(t,s):t||Ea(n[0]??"30d",s)),B=e??H,C=Bn({triggerRef:I,contentRef:S,isOpen:R,side:"bottom",align:m}),b=el.useCallback((A=true)=>{T(false),M(false),z(null),A&&I.current?.focus();},[]);el.useEffect(()=>{if(!R)return;let A=D=>{let V=D.target;S.current?.contains(V)||I.current?.contains(V)||b(false);};return document.addEventListener("mousedown",A),document.addEventListener("touchstart",A,{passive:true}),()=>{document.removeEventListener("mousedown",A),document.removeEventListener("touchstart",A);}},[R,b]),el.useEffect(()=>{if(!R)return;let A=D=>{D.key==="Escape"&&(D.stopPropagation(),b());};return document.addEventListener("keydown",A),()=>document.removeEventListener("keydown",A)},[R,b]),el.useEffect(()=>{let A=S.current;if(A)return wn(A,()=>I.current)},[R]),el.useEffect(()=>{if(!R)return;let A=requestAnimationFrame(()=>L.current?.focus());return ()=>cancelAnimationFrame(A)},[R]);let E=el.useCallback(A=>{e===void 0&&P(A),r?.(A),b();},[e,r,b]),N=el.useCallback(A=>E(Ea(A,s)),[E,s]),W=el.useCallback(A=>{z(A),!(!A.from||!A.to)&&E({preset:"custom",from:Es(A.from),to:Ms(A.to)});},[E]),F=A=>a?.[A]??h[gh[A]],K=B.preset==="custom"?pl(B.from,B.to,u):F(B.preset),j=jsxRuntime.jsxs("div",{ref:S,role:"dialog","aria-label":w??h.chartPeriod,style:{position:"fixed",top:C.top,left:C.left,visibility:C.isReady?"visible":"hidden"},className:"z-50 flex overflow-hidden rounded-lg border border-gray-200 bg-white shadow-lg dark:border-gray-700 dark:bg-gray-800",children:[jsxRuntime.jsxs("div",{ref:L,tabIndex:-1,className:"flex min-w-44 flex-col p-1 outline-none",children:[n.map(A=>jsxRuntime.jsx("button",{type:"button","aria-pressed":B.preset===A,onClick:()=>N(A),className:g("cursor-pointer rounded-md px-3 py-1.5 text-left text-sm text-gray-700 hover:bg-gray-100 focus-visible:outline-2 focus-visible:outline-offset-[-2px] focus-visible:outline-blue-500 dark:text-gray-200 dark:hover:bg-gray-700",B.preset===A&&"bg-blue-50 font-medium text-blue-700 dark:bg-blue-950 dark:text-blue-300"),children:F(A)},A)),o?jsxRuntime.jsx("button",{type:"button","aria-pressed":B.preset==="custom","aria-expanded":y,onClick:()=>M(true),className:g("cursor-pointer rounded-md px-3 py-1.5 text-left text-sm text-gray-700 hover:bg-gray-100 focus-visible:outline-2 focus-visible:outline-offset-[-2px] focus-visible:outline-blue-500 dark:text-gray-200 dark:hover:bg-gray-700",B.preset==="custom"&&"bg-blue-50 font-medium text-blue-700 dark:bg-blue-950 dark:text-blue-300"),children:F("custom")}):null]}),o&&y?jsxRuntime.jsx("div",{className:"border-l border-gray-200 p-2 dark:border-gray-700",children:jsxRuntime.jsx(nl,{mode:"range",value:k??{from:B.from,to:B.to},onChange:W,numberOfMonths:c,weekStartsOn:d,locale:u,minDate:l,maxDate:i,size:"sm"})}):null]});return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsxs("button",{ref:I,type:"button",disabled:p,"aria-haspopup":"dialog","aria-expanded":R,"aria-label":`${w??h.chartPeriod}: ${K}`,onClick:()=>R?b():T(true),className:g("inline-flex cursor-pointer items-center gap-2 rounded-full border border-gray-300 bg-white font-medium text-gray-700 transition-colors hover:bg-gray-50 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-blue-500 disabled:cursor-not-allowed disabled:opacity-50 dark:border-gray-600 dark:bg-gray-800 dark:text-gray-200 dark:hover:bg-gray-700",ph[f],v),...x,children:[fh,jsxRuntime.jsx("span",{children:K})]}),R&&typeof document<"u"?reactDom.createPortal(j,document.body):null]})}var hl=[{unit:"second",step:1,span:1e3},{unit:"second",step:5,span:5e3},{unit:"second",step:15,span:15e3},{unit:"second",step:30,span:3e4},{unit:"minute",step:1,span:6e4},{unit:"minute",step:5,span:3e5},{unit:"minute",step:15,span:9e5},{unit:"minute",step:30,span:18e5},{unit:"hour",step:1,span:36e5},{unit:"hour",step:3,span:108e5},{unit:"hour",step:6,span:216e5},{unit:"hour",step:12,span:432e5},{unit:"day",step:1,span:864e5},{unit:"day",step:2,span:1728e5},{unit:"week",step:1,span:6048e5},{unit:"week",step:2,span:12096e5},{unit:"month",step:1,span:2592e6},{unit:"month",step:3,span:78624e5},{unit:"month",step:6,span:157248e5},{unit:"year",step:1,span:31536e6},{unit:"year",step:2,span:63072e6},{unit:"year",step:5,span:1577664e5},{unit:"year",step:10,span:3155328e5}];function yh(e,t,r){let n=new Date(e.getTime());switch(t){case "year":return n.setMonth(0,1),n.setHours(0,0,0,0),n.setFullYear(Math.floor(n.getFullYear()/r)*r),n;case "month":return n.setDate(1),n.setHours(0,0,0,0),n.setMonth(Math.floor(n.getMonth()/r)*r),n;case "week":return n.setHours(0,0,0,0),n.setDate(n.getDate()-(n.getDay()+6)%7),n;case "day":return n.setHours(0,0,0,0),n;case "hour":return n.setMinutes(0,0,0),n.setHours(Math.floor(n.getHours()/r)*r),n;case "minute":return n.setSeconds(0,0),n.setMinutes(Math.floor(n.getMinutes()/r)*r),n;default:return n.setMilliseconds(0),n.setSeconds(Math.floor(n.getSeconds()/r)*r),n}}function Ad(e,t,r){let n=new Date(e.getTime());switch(t){case "year":return n.setFullYear(n.getFullYear()+r),n;case "month":return n.setMonth(n.getMonth()+r),n;case "week":return n.setDate(n.getDate()+r*7),n;case "day":return n.setDate(n.getDate()+r),n;case "hour":return n.setHours(n.getHours()+r),n;case "minute":return n.setMinutes(n.getMinutes()+r),n;default:return n.setSeconds(n.getSeconds()+r),n}}function bl(e,t,r=6){if(!Number.isFinite(e)||!Number.isFinite(t))return {values:[],unit:"day",step:1};e>t&&([e,t]=[t,e]);let n=Math.max(1,r),o=(t-e)/n,a=hl.find(i=>i.span>=o)??hl[hl.length-1],s=[],l=yh(new Date(e),a.unit,a.step);for(;l.getTime()<e;)l=Ad(l,a.unit,a.step);for(;l.getTime()<=t&&s.length<=500;)s.push(l.getTime()),l=Ad(l,a.unit,a.step);return {values:s,unit:a.unit,step:a.step}}function Hs(e,t,r){let n=new Date(e);switch(t){case "year":return new Intl.DateTimeFormat(r,{year:"numeric"}).format(n);case "month":return new Intl.DateTimeFormat(r,{month:"short",year:"2-digit"}).format(n);case "week":case "day":return new Intl.DateTimeFormat(r,{day:"numeric",month:"short"}).format(n);case "hour":return new Intl.DateTimeFormat(r,{hour:"2-digit",minute:"2-digit"}).format(n);default:return new Intl.DateTimeFormat(r,{minute:"2-digit",second:"2-digit"}).format(n)}}function mo(e){if(e instanceof Date){let t=e.getTime();return Number.isFinite(t)?t:null}if(typeof e=="number")return Number.isFinite(e)?e:null;if(typeof e=="string"&&e!==""){let t=Date.parse(e);if(Number.isFinite(t))return t;let r=Number(e);return Number.isFinite(r)?r:null}return null}var vh=5,Ch=3,zd=10,yl=false;function kh(){yl=false;}var wh=el.memo(function({rows:t,radius:r}){return jsxRuntime.jsx("g",{children:t.map(n=>jsxRuntime.jsxs("g",{children:[n.connector?jsxRuntime.jsx("line",{x1:n.connector.x1,y1:n.connector.y,x2:n.connector.x2,y2:n.connector.y,strokeWidth:Ch,strokeLinecap:"round",className:"stroke-gray-300 dark:stroke-gray-600"}):null,n.dots.map(o=>jsxRuntime.jsx("circle",{cx:o.cx,cy:o.cy,r,fill:o.color,strokeWidth:2,className:"stroke-white dark:stroke-gray-800"},o.key)),n.label?jsxRuntime.jsx("text",{x:n.label.x,y:n.label.y,dominantBaseline:"middle",className:"fill-gray-600 text-[10px] [font-variant-numeric:tabular-nums] dark:fill-gray-300",children:n.label.text}):null]},n.key))})});function Nh({width:e,height:t,data:r,rows:n,resolvedSeries:o,x:a,y:s,grid:l,size:i,showValues:c,dotSize:d,referenceLines:u,margin:f,tooltip:m,plotLabel:p,formatValue:w,formatX:v,onRowClick:x}){let[h,I]=el.useState(null),S=el.useMemo(()=>{let k=o.filter(N=>!N.hidden).map(N=>N.key),z=rr({width:e,height:t,data:r,x:a,y:s,bounds:Yt(fr(r,k)),margin:f,orientation:"horizontal",placement:"band",formatValue:w,formatX:v,defaultIncludeZero:false}),{valueScale:H,bandwidth:P,categoryPositions:B,innerWidth:C,innerHeight:b}=z;return {rendered:n.map((N,W)=>{let F=B[W]+P/2,K=N.points.map((D,V)=>({key:D.seriesKey,value:D.value,cx:D.value===null?Number.NaN:H(D.value),cy:F,color:D.color,order:V})).filter(D=>D.value!==null),j=N.from===null||N.to===null||K.length<2?null:{x1:H(N.from),x2:H(N.to),y:F},A=null;if(c&&N.to!==null){let D=w(N.to),V=H(N.to);tr(D,10)<=C-V-zd&&(A={x:V+zd,y:F,text:D});}return {key:`${W}`,connector:j,dots:K.map(D=>({key:D.key,cx:D.cx,cy:D.cy,color:D.color})),label:A,top:B[W],height:P}}),categoryPositions:B,categoryCenters:z.categoryCenters,bandwidth:P,categoryTicks:z.categoryTicks,valueTicks:z.valueTicks,valueScale:H,innerWidth:C,innerHeight:b,margin:z.margin}},[r,n,o,a,s,e,t,f,c,w,v]),L=el.useCallback(M=>{if(m===false||n.length===0)return;let k=M.currentTarget.getBoundingClientRect(),z=M.clientY-k.top-S.margin.top;I(Vt(S.categoryCenters,z));},[m,n.length,S.margin.top,S.categoryCenters]),R=el.useCallback(M=>{if(n.length===0)return;let k=n.length-1,z=h??0,H=M.key==="ArrowDown"?Math.min(k,z+1):M.key==="ArrowUp"?Math.max(0,z-1):M.key==="Home"?0:M.key==="End"?k:M.key==="Escape"?null:void 0;H!==void 0&&(M.preventDefault(),I(H));},[n.length,h]),T=el.useCallback(()=>{!x||h===null||x(n[h]);},[x,h,n]),y=h===null?null:n[h];return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsxs("svg",{width:e,height:t,role:"img","aria-label":p??o.map(M=>Kt(M)).join(", "),tabIndex:0,className:"touch-none focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-blue-500",onPointerMove:L,onPointerLeave:()=>I(null),onKeyDown:R,onBlur:()=>I(null),onClick:T,children:[jsxRuntime.jsxs("g",{transform:`translate(${S.margin.left}, ${S.margin.top})`,children:[jsxRuntime.jsx(_t,{width:S.innerWidth,height:S.innerHeight,vertical:l==="y"||l==="both"?S.valueTicks.map(M=>M.offset):void 0}),h!==null?jsxRuntime.jsx("rect",{x:0,y:S.categoryPositions[h],width:S.innerWidth,height:S.bandwidth,className:"fill-gray-400 dark:fill-gray-500",opacity:.12,"aria-hidden":"true"}):null,u?.map(M=>jsxRuntime.jsxs("g",{children:[jsxRuntime.jsx("line",{x1:S.valueScale(M.value),y1:0,x2:S.valueScale(M.value),y2:S.innerHeight,stroke:M.color??"var(--color-chart-muted)",strokeWidth:1,strokeDasharray:M.dashed===false?void 0:"4 4"}),M.label?jsxRuntime.jsx("text",{x:S.valueScale(M.value)+4,y:8,className:"fill-gray-500 text-[10px] dark:fill-gray-400",children:M.label}):null]},`${M.value}-${M.label??""}`)),jsxRuntime.jsx(wh,{rows:S.rendered,radius:d})]}),jsxRuntime.jsx("g",{transform:`translate(${S.margin.left}, ${S.margin.top+S.innerHeight})`,children:s?.hidden?null:jsxRuntime.jsx(Ue,{orientation:"bottom",ticks:S.valueTicks,length:S.innerWidth,label:s?.label,size:i})}),jsxRuntime.jsx("g",{transform:`translate(${S.margin.left}, ${S.margin.top})`,children:a.hidden?null:jsxRuntime.jsx(Ue,{orientation:"left",ticks:S.categoryTicks,length:S.innerHeight,showLine:false,tickSize:0,label:a.label,size:i})})]}),y&&h!==null&&m!==false?jsxRuntime.jsx(dt,{x:S.margin.left+(y.to===null?S.innerWidth/2:S.valueScale(y.to)),y:S.margin.top+S.categoryCenters[h],containerWidth:e,children:typeof m=="function"?m(y):jsxRuntime.jsx(Nr,{title:y.label,points:y.points})}):null]})}function Sh({data:e,x:t,y:r,series:n,sort:o="none",sortBy:a,showValues:s=false,dotSize:l=vh,referenceLines:i,height:c,width:d,size:u="md",grid:f="y",legend:m,legendToggle:p=true,tooltip:w=true,tableView:v=false,showChange:x=true,title:h,description:I,loading:S=false,emptyState:L,margin:R,locale:T,plotLabel:y,changeLabel:M,format:k,onRowClick:z,className:H,...P}){let B=We(),[C,b]=el.useState(()=>new Set);n.length>3&&!yl&&(yl=true,console.warn(`[@synertech/ui] A DumbbellChart was given ${n.length} series. Any two dots of a row can sit side by side, and only the first ${3} palette slots stay tellable apart under that test: facet the chart instead.`));let E=el.useMemo(()=>n.map((X,G)=>({...X,hidden:X.hidden||C.has(X.key),color:Lr(X,G)})),[n,C]),N=el.useMemo(()=>r?.format??k??(X=>nt(X,T)),[r?.format,k,T]),W=el.useMemo(()=>t.format??(X=>Ze(X,T)),[t.format,T]),F=el.useMemo(()=>E.filter(X=>!X.hidden),[E]),K=el.useMemo(()=>e.map((X,G)=>{let $=ct(X,t.key,G),Y=F.map(Q=>{let le=Ee(X,Q.key);return {seriesKey:Q.key,seriesLabel:Kt(Q),color:Q.color,value:le,formattedValue:le===null?"\u2014":N(le),datum:X}}),se=Y.map(Q=>Q.value).filter(Q=>Q!==null),ae=Y[0]?.value??null,U=Y[Y.length-1]?.value??null;return {index:G,x:$,label:W($,G),points:Y,from:se.length>0?Math.min(...se):null,to:se.length>0?Math.max(...se):null,change:ae===null||U===null?null:U-ae,datum:X}}),[e,t.key,F,N,W]),j=el.useMemo(()=>{if(o==="none")return K;let X=a??F[F.length-1]?.key,G=Y=>o==="gap"?Math.abs(Y.change??0):Y.points.find(se=>se.seriesKey===X)?.value??0,$=[...K].sort((Y,se)=>G(Y)-G(se));return o==="asc"?$:$.reverse()},[K,o,a,F]),A=el.useCallback(X=>{b(G=>{let $=new Set(G);return $.has(X)?$.delete(X):$.add(X),$});},[]),D=c??Math.max(96,j.length*30+44),V=el.useMemo(()=>j.map(X=>({...X.datum,__change:X.change})),[j]),O=m===void 0?n.length>=2:m!==false,_=typeof m=="string"?m:"bottom";return jsxRuntime.jsx(lt,{title:h,description:I,height:D,width:d,size:u,loading:S,empty:j.length===0||F.length===0,emptyState:L,tableView:v,legendPosition:_,legend:O?jsxRuntime.jsx(Xt,{items:$r(E),position:_,marker:"dot",size:u,onToggle:p?A:void 0}):void 0,table:v?jsxRuntime.jsx(zt,{data:V,series:[...E,...x?[{key:"__change",label:M??B.chartChange}]:[]],xKey:t.key,xLabel:t.label??t.key,formatX:W,formatValue:N,caption:typeof h=="string"?h:void 0}):void 0,className:H,...P,children:({width:X})=>jsxRuntime.jsx(Nh,{width:X,height:D,data:j.map(G=>G.datum),rows:j,resolvedSeries:E,x:t,y:r,grid:f,size:u,showValues:s,dotSize:l,referenceLines:i,margin:R,tooltip:w,plotLabel:y,formatValue:N,formatX:W,onRowClick:z})})}var Dh=8,Lh=12,Eh=44,vl="text-right [font-variant-numeric:tabular-nums]",Mh=el.memo(function({stages:t}){return jsxRuntime.jsx("g",{children:t.map(r=>jsxRuntime.jsxs("g",{children:[jsxRuntime.jsx("path",{d:r.d,fill:r.color}),r.value?jsxRuntime.jsx("text",{x:r.value.x,y:r.value.y,textAnchor:r.value.anchor,dominantBaseline:"middle",className:r.value.inside?r.value.onDark?"fill-gray-50 text-[11px] font-semibold [font-variant-numeric:tabular-nums] dark:fill-gray-900":"fill-gray-900 text-[11px] font-semibold [font-variant-numeric:tabular-nums] dark:fill-gray-50":"fill-gray-700 text-[11px] font-semibold [font-variant-numeric:tabular-nums] dark:fill-gray-200",children:r.value.text}):null,r.conversion?jsxRuntime.jsx("text",{x:r.conversion.x,y:r.conversion.y,textAnchor:"middle",dominantBaseline:"middle",className:"fill-gray-500 text-[10px] [font-variant-numeric:tabular-nums] dark:fill-gray-400",children:r.conversion.text}):null]},r.key))})});function Ih({width:e,height:t,stages:r,x:n,size:o,align:a,showConversion:s,showValues:l,stageSize:i,ramp:c,tooltip:d,plotLabel:u,locale:f,onStageClick:m}){let[p,w]=el.useState(null),v=We(),x=el.useMemo(()=>{let R=r.map(b=>b.label),T={top:6,right:12,bottom:6,left:n.hidden?8:n.height??wr(R)+Lh},y=Math.max(0,e-T.left-T.right),M=Math.max(0,t-T.top-T.bottom),k=xn(r.map((b,E)=>E),[0,M],{paddingInner:s?.45:.28}),z=Math.min(i??Eh,k.bandwidth),H=Math.max(0,...r.map(b=>b.value??0)),P=Er([0,H],[0,y]),B=r.map((b,E)=>{let N=b.value===null?0:Math.max(0,P(b.value)),W=a==="center"?(y-N)/2:0,F=k(E)+(k.bandwidth-z)/2,K=F+z/2,j=null;if(l&&b.value!==null){let V=b.formattedValue;j=tr(V,11)+16<=N?{x:W+N/2,y:K,anchor:"middle",text:V,inside:true,onDark:c.onDark(E)}:{x:W+N+Dh,y:K,anchor:"start",text:V,inside:false,onDark:false};}let A=k(E-1)+(k.bandwidth-z)/2+z,D=s&&b.conversion!==null&&E>0?{x:y/2,y:(A+F)/2,text:Ut(b.conversion,{locale:f,maximumFractionDigits:0})}:null;return {key:`${E}`,d:cr({x:W,y:F,width:N,height:z,radius:4,round:a==="center"?"none":"right"}),color:c(E),value:j,conversion:D,top:k(E),height:k.bandwidth}}),C=n.hidden?[]:r.map((b,E)=>({value:b.x,offset:k.center(E),label:b.label}));return {margin:T,innerWidth:y,innerHeight:M,rendered:B,stageTicks:C,centers:r.map((b,E)=>k.center(E))}},[r,n,e,t,a,s,l,i,c,f]),h=el.useCallback(R=>{if(d===false||r.length===0)return;let T=R.currentTarget.getBoundingClientRect(),y=R.clientY-T.top-x.margin.top;w(Vt(x.centers,y));},[d,r.length,x.margin.top,x.centers]),I=el.useCallback(R=>{if(r.length===0)return;let T=r.length-1,y=p??0,M=R.key==="ArrowDown"?Math.min(T,y+1):R.key==="ArrowUp"?Math.max(0,y-1):R.key==="Home"?0:R.key==="End"?T:R.key==="Escape"?null:void 0;M!==void 0&&(R.preventDefault(),w(M));},[r.length,p]),S=el.useCallback(()=>{!m||p===null||m(r[p]);},[m,p,r]),L=p===null?null:r[p];return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsxs("svg",{width:e,height:t,role:"img","aria-label":u??r.map(R=>R.label).join(", "),tabIndex:0,className:"touch-none focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-blue-500",onPointerMove:h,onPointerLeave:()=>w(null),onKeyDown:I,onBlur:()=>w(null),onClick:S,children:[jsxRuntime.jsxs("g",{transform:`translate(${x.margin.left}, ${x.margin.top})`,children:[p!==null&&x.rendered[p]?jsxRuntime.jsx("rect",{x:-4,y:x.rendered[p].top,width:x.innerWidth+8,height:x.rendered[p].height,rx:4,className:"fill-gray-400 dark:fill-gray-500",opacity:.12,"aria-hidden":"true"}):null,jsxRuntime.jsx(Mh,{stages:x.rendered})]}),jsxRuntime.jsx("g",{transform:`translate(${x.margin.left}, ${x.margin.top})`,children:n.hidden?null:jsxRuntime.jsx(Ue,{orientation:"left",ticks:x.stageTicks,length:x.innerHeight,showLine:false,tickSize:0,size:o})})]}),L&&p!==null&&d!==false?jsxRuntime.jsx(dt,{x:x.margin.left+x.innerWidth/2,y:x.margin.top+x.centers[p],containerWidth:e,children:typeof d=="function"?d(L):jsxRuntime.jsxs("div",{className:"flex flex-col gap-1",children:[jsxRuntime.jsx("div",{className:"font-medium text-gray-900 dark:text-gray-100",children:L.label}),jsxRuntime.jsxs("div",{className:"flex items-center gap-2",children:[jsxRuntime.jsx("span",{className:"h-2.5 w-2.5 shrink-0 rounded-sm",style:{backgroundColor:x.rendered[p]?.color},"aria-hidden":"true"}),jsxRuntime.jsx("span",{className:"font-semibold text-gray-900 [font-variant-numeric:tabular-nums] dark:text-gray-100",children:L.formattedValue})]}),L.conversion!==null?jsxRuntime.jsxs("div",{className:"flex items-center gap-2 text-gray-500 dark:text-gray-400",children:[jsxRuntime.jsx("span",{children:v.chartConversion}),jsxRuntime.jsx("span",{className:"[font-variant-numeric:tabular-nums]",children:Ut(L.conversion,{locale:f,maximumFractionDigits:1})})]}):null,L.overall!==null?jsxRuntime.jsxs("div",{className:"flex items-center gap-2 text-gray-500 dark:text-gray-400",children:[jsxRuntime.jsx("span",{children:r[0]?.label}),jsxRuntime.jsx("span",{className:"[font-variant-numeric:tabular-nums]",children:Ut(L.overall,{locale:f,maximumFractionDigits:1})})]}):null]})}):null]})}function Ah({data:e,x:t,value:r,align:n="center",showConversion:o=true,showValues:a=true,stageSize:s,colors:l,height:i,width:c,size:d="md",tooltip:u=true,tableView:f=false,title:m,description:p,loading:w=false,emptyState:v,locale:x,plotLabel:h,valueLabel:I,conversionLabel:S,dropOffLabel:L,format:R,onStageClick:T,className:y,...M}){let k=We(),z=el.useMemo(()=>R??(b=>nt(b,x)),[R,x]),H=el.useMemo(()=>t.format??(b=>Ze(b,x)),[t.format,x]),P=el.useMemo(()=>{let b=Ee(e[0]??{},r);return e.map((E,N)=>{let W=ct(E,t.key,N),F=Ee(E,r),K=N===0?null:Ee(e[N-1],r);return {index:N,x:W,label:H(W,N),value:F,overall:N===0||b===null||b===0||F===null?null:F/b,conversion:K===null||K===0||F===null?null:F/K,dropOff:K===null||F===null?null:K-F,formattedValue:F===null?"\u2014":z(F),datum:E}})},[e,t.key,r,z,H]),B=el.useMemo(()=>va([0,Math.max(1,P.length-1)],{colors:l??ya,...l?{}:{darkStops:$i}}),[P.length,l]),C=i??Math.max(96,P.length*(o?56:44)+12);return jsxRuntime.jsx(lt,{title:m,description:p,height:C,width:c,size:d,loading:w,empty:P.length===0,emptyState:v,tableView:f,table:f?jsxRuntime.jsx("div",{className:"w-full overflow-x-auto",children:jsxRuntime.jsxs(fn,{children:[typeof m=="string"?jsxRuntime.jsx("caption",{className:"sr-only",children:m}):null,jsxRuntime.jsxs(bn,{children:[jsxRuntime.jsx(St,{children:t.label??t.key}),jsxRuntime.jsx(St,{className:"text-right",children:I??k.chartValue}),jsxRuntime.jsx(St,{className:"text-right",children:S??k.chartConversion}),jsxRuntime.jsx(St,{className:"text-right",children:L??k.chartDropOff})]}),jsxRuntime.jsx(hn,{children:P.map(b=>jsxRuntime.jsxs(yn,{clickable:false,children:[jsxRuntime.jsx(Gt,{className:"font-medium text-gray-900 dark:text-gray-100",children:b.label}),jsxRuntime.jsx(Gt,{className:vl,children:b.formattedValue}),jsxRuntime.jsx(Gt,{className:vl,children:b.conversion===null?"\u2014":Ut(b.conversion,{locale:x,maximumFractionDigits:1})}),jsxRuntime.jsx(Gt,{className:vl,children:b.dropOff===null?"\u2014":z(b.dropOff)})]},b.index))})]})}):void 0,className:y,...M,children:({width:b})=>jsxRuntime.jsx(Ih,{width:b,height:C,stages:P,x:t,size:d,align:n,showConversion:o,showValues:a,stageSize:s,ramp:B,tooltip:u,plotLabel:h,locale:x,onStageClick:T})})}var Bh=18,Hd=.5,Vh=.3,Vs=7,Bd=10,Vd=.02,Cl="text-right [font-variant-numeric:tabular-nums]",Fh=el.memo(function({tasks:t,arrows:r}){return jsxRuntime.jsxs("g",{children:[jsxRuntime.jsx("g",{className:"fill-gray-400 stroke-gray-400 dark:fill-gray-500 dark:stroke-gray-500",children:r.map(n=>jsxRuntime.jsxs("g",{children:[jsxRuntime.jsx("path",{d:n.d,fill:"none",strokeWidth:1}),jsxRuntime.jsx("path",{d:n.head,strokeWidth:0})]},n.key))}),t.map(n=>jsxRuntime.jsxs("g",{children:[n.track?jsxRuntime.jsx("path",{d:n.track,fill:n.color,fillOpacity:n.trackOpacity}):null,n.progress?jsxRuntime.jsx("path",{d:n.progress,fill:n.color}):null,n.milestone?jsxRuntime.jsx("path",{d:n.milestone,fill:n.color,strokeWidth:2,className:"stroke-white dark:stroke-gray-800"}):null]},n.key))]})});function Oh({width:e,height:t,data:r,tasks:n,x:o,domain:a,unit:s,timeTicks:l,today:i,grid:c,size:d,barSize:u,colorOf:f,margin:m,tooltip:p,plotLabel:w,todayLabel:v,locale:x,formatDate:h,formatX:I,onTaskClick:S}){let[L,R]=el.useState(null),T=We(),y=el.useMemo(()=>{let P=rr({width:e,height:t,data:r,x:o,y:{domain:a},bounds:a,margin:m,orientation:"horizontal",placement:"band",formatValue:D=>Hs(D,s,x),formatX:I}),{valueScale:B,bandwidth:C,categoryPositions:b,innerWidth:E,innerHeight:N}=P,W=Math.min(u??Bh,C),F=new Map(n.map((D,V)=>[D.id,V])),K=n.map((D,V)=>{let O=b[V]+(C-W)/2,_=O+W/2,X=f(D);if(D.start===null)return {key:`${V}`,color:X,track:null,trackOpacity:1,progress:null,milestone:null,top:b[V],height:C};let G=B(D.start);if(D.milestone)return {key:`${V}`,color:X,track:null,trackOpacity:1,progress:null,milestone:`M${G},${_-Vs} L${G+Vs},${_} L${G},${_+Vs} L${G-Vs},${_} Z`,top:b[V],height:C};let $=B(D.end??D.start),Y=Math.max(2,$-G);return {key:`${V}`,color:X,track:cr({x:G,y:O,width:Y,height:W,radius:3}),trackOpacity:D.progress===null?1:Vh,progress:D.progress===null?null:cr({x:G,y:_-W*Hd/2,width:Math.max(0,Y*Math.min(1,Math.max(0,D.progress))),height:W*Hd,radius:2,round:"right"}),milestone:null,top:b[V],height:C}}),j=[];n.forEach((D,V)=>{if(D.start!==null)for(let O of D.dependsOn){let _=F.get(O);if(_===void 0||_===V)continue;let X=n[_];if(X.start===null)continue;let G=B(X.end??X.start),$=b[_]+C/2,Y=B(D.start),se=b[V]+C/2,ae=Math.max(G+Bd,Y-Bd);j.push({key:`${O}-${D.id}`,d:`M${G},${$} L${ae},${$} L${ae},${se} L${Y-5},${se}`,head:`M${Y},${se} L${Y-5},${se-3.5} L${Y-5},${se+3.5} Z`});}});let A=l.map(D=>({value:D,offset:B(D),label:Hs(D,s,x)}));return {rendered:K,arrows:j,categoryPositions:b,categoryCenters:P.categoryCenters,bandwidth:C,categoryTicks:P.categoryTicks,valueTicks:A,valueScale:B,innerWidth:E,innerHeight:N,margin:P.margin}},[n,r,o,a,s,l,e,t,m,u,f,x,I]),M=el.useCallback(P=>{if(p===false||n.length===0)return;let B=P.currentTarget.getBoundingClientRect(),C=P.clientY-B.top-y.margin.top;R(Vt(y.categoryCenters,C));},[p,n.length,y.margin.top,y.categoryCenters]),k=el.useCallback(P=>{if(n.length===0)return;let B=n.length-1,C=L??0,b=P.key==="ArrowDown"?Math.min(B,C+1):P.key==="ArrowUp"?Math.max(0,C-1):P.key==="Home"?0:P.key==="End"?B:P.key==="Escape"?null:void 0;b!==void 0&&(P.preventDefault(),R(b));},[n.length,L]),z=el.useCallback(()=>{!S||L===null||S(n[L]);},[S,L,n]),H=L===null?null:n[L];return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsxs("svg",{width:e,height:t,role:"img","aria-label":w??n.map(P=>P.label).join(", "),tabIndex:0,className:"touch-none focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-blue-500",onPointerMove:M,onPointerLeave:()=>R(null),onKeyDown:k,onBlur:()=>R(null),onClick:z,children:[jsxRuntime.jsxs("g",{transform:`translate(${y.margin.left}, ${y.margin.top})`,children:[jsxRuntime.jsx(_t,{width:y.innerWidth,height:y.innerHeight,vertical:c?y.valueTicks.map(P=>P.offset):void 0}),L!==null?jsxRuntime.jsx("rect",{x:0,y:y.categoryPositions[L],width:y.innerWidth,height:y.bandwidth,className:"fill-gray-400 dark:fill-gray-500",opacity:.12,"aria-hidden":"true"}):null,jsxRuntime.jsx(Fh,{tasks:y.rendered,arrows:y.arrows}),i!==null?jsxRuntime.jsxs("g",{children:[jsxRuntime.jsx("line",{x1:y.valueScale(i),y1:0,x2:y.valueScale(i),y2:y.innerHeight,className:"stroke-gray-900 dark:stroke-white",strokeWidth:1,strokeDasharray:"4 4"}),jsxRuntime.jsx("text",{x:y.valueScale(i)+4,y:8,className:"fill-gray-500 text-[10px] dark:fill-gray-400",children:v})]}):null]}),jsxRuntime.jsx("g",{transform:`translate(${y.margin.left}, ${y.margin.top+y.innerHeight})`,children:jsxRuntime.jsx(Ue,{orientation:"bottom",ticks:y.valueTicks,length:y.innerWidth,size:d})}),jsxRuntime.jsx("g",{transform:`translate(${y.margin.left}, ${y.margin.top})`,children:o.hidden?null:jsxRuntime.jsx(Ue,{orientation:"left",ticks:y.categoryTicks,length:y.innerHeight,showLine:false,tickSize:0,label:o.label,size:d})})]}),H&&L!==null&&p!==false?jsxRuntime.jsx(dt,{x:y.margin.left+(H.start===null?y.innerWidth/2:y.valueScale(H.start)),y:y.margin.top+y.categoryCenters[L],containerWidth:e,children:typeof p=="function"?p(H):jsxRuntime.jsxs("div",{className:"flex flex-col gap-1",children:[jsxRuntime.jsx("div",{className:"font-medium text-gray-900 dark:text-gray-100",children:H.label}),jsxRuntime.jsxs("div",{className:"flex items-center gap-2 text-gray-500 dark:text-gray-400",children:[jsxRuntime.jsx("span",{children:T.chartStart}),jsxRuntime.jsx("span",{className:"[font-variant-numeric:tabular-nums] text-gray-900 dark:text-gray-100",children:H.start===null?"\u2014":h(H.start)})]}),H.milestone?null:jsxRuntime.jsxs("div",{className:"flex items-center gap-2 text-gray-500 dark:text-gray-400",children:[jsxRuntime.jsx("span",{children:T.chartEnd}),jsxRuntime.jsx("span",{className:"[font-variant-numeric:tabular-nums] text-gray-900 dark:text-gray-100",children:H.end===null?"\u2014":h(H.end)})]}),H.progress===null?null:jsxRuntime.jsxs("div",{className:"flex items-center gap-2 text-gray-500 dark:text-gray-400",children:[jsxRuntime.jsx("span",{children:T.chartProgress}),jsxRuntime.jsx("span",{className:"[font-variant-numeric:tabular-nums] text-gray-900 dark:text-gray-100",children:Ut(H.progress,{locale:x,maximumFractionDigits:0})})]})]})}):null]})}function $h({data:e,x:t,start:r,end:n,id:o,progress:a,milestone:s,dependencies:l,group:i,domain:c,today:d,ticks:u=6,barSize:f,rowSize:m=30,color:p,height:w,width:v,size:x="md",grid:h=true,legend:I,tooltip:S=true,tableView:L=false,title:R,description:T,loading:y=false,emptyState:M,margin:k,locale:z,plotLabel:H,startLabel:P,endLabel:B,progressLabel:C,todayLabel:b,formatDate:E,onTaskClick:N,className:W,...F}){let K=We(),j=el.useMemo(()=>t.format??(U=>Ze(U,z)),[t.format,z]),A=el.useMemo(()=>e.map((U,Q)=>{let le=ct(U,t.key,Q),ye=mo(U[r]),te=n?mo(U[n]):null,Ce=s?!!U[s]:te===null,Pe=l?U[l]:void 0;return {index:Q,id:String(o?U[o]??Q:Q),x:le,label:j(le,Q),start:ye,end:Ce?ye:te??ye,progress:a?Ee(U,a):null,milestone:Ce,dependsOn:Array.isArray(Pe)?Pe.map(Se=>String(Se)):[],group:i?U[i]??null:null,datum:U}}),[e,t.key,r,n,o,a,s,l,i,j]),D=el.useMemo(()=>{let U=[];for(let Q of A)Q.group!==null&&!U.includes(Q.group)&&U.push(Q.group);return U},[A]),V=el.useCallback(U=>U.group===null?p??Dr(0):Dr(D.indexOf(U.group)),[D,p]),O=el.useMemo(()=>{if(c){let te=mo(c[0]),Ce=mo(c[1]);if(te!==null&&Ce!==null)return [te,Ce]}let U=A.flatMap(te=>te.start===null?[]:[te.start,te.end??te.start]);if(U.length===0)return [0,1];let Q=Math.min(...U),le=Math.max(...U),ye=le-Q||864e5;return [Q-ye*Vd,le+ye*Vd]},[c,A]),_=el.useMemo(()=>bl(O[0],O[1],u),[O,u]),X=el.useMemo(()=>E??(U=>new Intl.DateTimeFormat(z,{day:"numeric",month:"short",year:"numeric"}).format(new Date(U))),[E,z]),G=el.useMemo(()=>d===false?null:mo(d??Date.now()),[d]),$=el.useMemo(()=>D.map((U,Q)=>({key:U,label:U,color:Dr(Q),marker:"rect"})),[D]),Y=w??Math.max(120,A.length*m+48),se=I===void 0?D.length>=2:I!==false,ae=typeof I=="string"?I:"bottom";return jsxRuntime.jsx(lt,{title:R,description:T,height:Y,width:v,size:x,loading:y,empty:A.length===0,emptyState:M,tableView:L,legendPosition:ae,legend:se&&$.length>0?jsxRuntime.jsx(Xt,{items:$,position:ae,marker:"rect",size:x}):void 0,table:L?jsxRuntime.jsx("div",{className:"w-full overflow-x-auto",children:jsxRuntime.jsxs(fn,{children:[typeof R=="string"?jsxRuntime.jsx("caption",{className:"sr-only",children:R}):null,jsxRuntime.jsxs(bn,{children:[jsxRuntime.jsx(St,{children:t.label??t.key}),jsxRuntime.jsx(St,{className:"text-right",children:P??K.chartStart}),jsxRuntime.jsx(St,{className:"text-right",children:B??K.chartEnd}),a?jsxRuntime.jsx(St,{className:"text-right",children:C??K.chartProgress}):null]}),jsxRuntime.jsx(hn,{children:A.map(U=>jsxRuntime.jsxs(yn,{clickable:false,children:[jsxRuntime.jsx(Gt,{className:"font-medium text-gray-900 dark:text-gray-100",children:U.label}),jsxRuntime.jsx(Gt,{className:Cl,children:U.start===null?"\u2014":X(U.start)}),jsxRuntime.jsx(Gt,{className:Cl,children:U.milestone||U.end===null?"\u2014":X(U.end)}),a?jsxRuntime.jsx(Gt,{className:Cl,children:U.progress===null?"\u2014":Ut(U.progress,{locale:z,maximumFractionDigits:0})}):null]},U.index))})]})}):void 0,className:W,...F,children:({width:U})=>jsxRuntime.jsx(Oh,{width:U,height:Y,data:e,tasks:A,x:t,domain:O,unit:_.unit,timeTicks:_.values,today:G,grid:h,size:x,barSize:f,colorOf:V,margin:k,tooltip:S,plotLabel:H,todayLabel:b??K.chartToday,locale:z,formatDate:X,formatX:j,onTaskClick:N})})}var Kh=24,Uh=4,Ko=6,Yh=Eo(no,1),qh=Eo(no,0),jh=el.memo(function({bars:t,connectors:r}){return jsxRuntime.jsxs("g",{children:[jsxRuntime.jsx("g",{className:"stroke-gray-300 dark:stroke-gray-600",strokeWidth:1,shapeRendering:"crispEdges","aria-hidden":"true",children:r.map(n=>jsxRuntime.jsx("line",{x1:n.x1,y1:n.y1,x2:n.x2,y2:n.y2},n.key))}),t.map(n=>jsxRuntime.jsxs("g",{children:[jsxRuntime.jsx("path",{d:n.d,fill:n.color}),n.label?jsxRuntime.jsx("text",{x:n.label.x,y:n.label.y,textAnchor:n.label.anchor,dominantBaseline:"middle",className:"fill-gray-600 text-[10px] [font-variant-numeric:tabular-nums] dark:fill-gray-300",children:n.label.text}):null]},n.key))]})});function Zh({width:e,height:t,steps:r,data:n,x:o,y:a,grid:s,size:l,orientation:i,connectors:c,showValues:d,barSize:u,palette:f,margin:m,tooltip:p,plotLabel:w,totalLabel:v,formatValue:x,formatX:h,onStepClick:I}){let[S,L]=el.useState(null),R=el.useMemo(()=>{let H=i==="vertical",P=r.flatMap(D=>[D.start,D.end]),B=rr({width:e,height:t,data:n,x:o,y:a,bounds:P.length===0?null:[Math.min(...P),Math.max(...P)],margin:m,orientation:i,placement:"band",formatValue:x,formatX:h,defaultIncludeZero:true}),{valueScale:C,bandwidth:b,categoryPositions:E,innerWidth:N,innerHeight:W}=B,F=C(0),K=Math.min(u??Kh,b),j=[],A=[];return r.forEach((D,V)=>{let O=E[V]+(b-K)/2,_=C(D.start),X=C(D.end),G=Math.min(_,X),$=Math.abs(X-_),Y=D.end>=D.start,se=H?Y?"top":"bottom":Y?"right":"left",ae=H?{x:O,y:G,width:K,height:$}:{x:G,y:O,width:$,height:K},U=null;if(d&&D.value!==null){let le=D.kind==="total"?D.formattedEnd:D.formattedValue,ye=tr(le,10),te=C(Y?Math.max(D.start,D.end):Math.min(D.start,D.end));if(H){let Ce=Y?te-Ko:te+Ko;ye<=b&&Ce>8&&Ce<W-4&&(U={x:O+K/2,y:Ce,anchor:"middle",text:le});}else {let Ce=Y?N-te-Ko:te-Ko;ye<=Ce&&(U={x:Y?te+Ko:te-Ko,y:O+K/2,anchor:Y?"start":"end",text:le});}}j.push({key:`${V}`,color:f[D.kind],d:cr({...ae,radius:Uh,round:se}),label:U});let Q=r[V+1];if(c&&Q){let le=C(D.end),ye=E[V+1]+(b-K)/2;A.push(H?{key:`${V}`,x1:O+K,y1:le,x2:ye,y2:le}:{key:`${V}`,x1:le,y1:O+K,x2:le,y2:ye});}}),{vertical:H,bars:j,rules:A,baseline:F,bandwidth:b,categoryPositions:E,categoryCenters:B.categoryCenters,categoryTicks:B.categoryTicks,valueTicks:B.valueTicks,valueScale:C,innerWidth:N,innerHeight:W,margin:B.margin}},[r,n,o,a,e,t,m,i,c,d,u,f,x,h]),T=el.useCallback(H=>{if(p===false||r.length===0)return;let P=H.currentTarget.getBoundingClientRect(),B=R.vertical?H.clientX-P.left-R.margin.left:H.clientY-P.top-R.margin.top;L(Vt(R.categoryCenters,B));},[p,r.length,R.vertical,R.margin,R.categoryCenters]),y=el.useCallback(H=>{if(r.length===0)return;let P=r.length-1,B=S??0,C=R.vertical?"ArrowRight":"ArrowDown",b=R.vertical?"ArrowLeft":"ArrowUp",E=H.key===C?Math.min(P,B+1):H.key===b?Math.max(0,B-1):H.key==="Home"?0:H.key==="End"?P:H.key==="Escape"?null:void 0;E!==void 0&&(H.preventDefault(),L(E));},[r.length,S,R.vertical]),M=el.useCallback(()=>{!I||S===null||I(r[S]);},[I,S,r]),k=S===null?null:r[S],z=S===null||k===void 0||k===null?null:R.vertical?{x:R.margin.left+R.categoryCenters[S],y:R.margin.top+Math.min(R.valueScale(k.start),R.valueScale(k.end))}:{x:R.margin.left+Math.max(R.valueScale(k.start),R.valueScale(k.end)),y:R.margin.top+R.categoryCenters[S]};return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsxs("svg",{width:e,height:t,role:"img","aria-label":w??r.map(H=>H.label).join(", "),tabIndex:0,className:"touch-none focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-blue-500",onPointerMove:T,onPointerLeave:()=>L(null),onKeyDown:y,onBlur:()=>L(null),onClick:M,children:[jsxRuntime.jsxs("g",{transform:`translate(${R.margin.left}, ${R.margin.top})`,children:[jsxRuntime.jsx(_t,{width:R.innerWidth,height:R.innerHeight,horizontal:R.vertical&&(s==="y"||s==="both")?R.valueTicks.map(H=>H.offset):void 0,vertical:!R.vertical&&(s==="y"||s==="both")?R.valueTicks.map(H=>H.offset):void 0}),S!==null?jsxRuntime.jsx("rect",{x:R.vertical?R.categoryPositions[S]:0,y:R.vertical?0:R.categoryPositions[S],width:R.vertical?R.bandwidth:R.innerWidth,height:R.vertical?R.innerHeight:R.bandwidth,className:"fill-gray-400 dark:fill-gray-500",opacity:.12,"aria-hidden":"true"}):null,jsxRuntime.jsx(jh,{bars:R.bars,connectors:R.rules}),jsxRuntime.jsx("line",{x1:R.vertical?0:R.baseline,y1:R.vertical?R.baseline:0,x2:R.vertical?R.innerWidth:R.baseline,y2:R.vertical?R.baseline:R.innerHeight,className:"stroke-gray-300 dark:stroke-gray-600",strokeWidth:1,shapeRendering:"crispEdges"})]}),jsxRuntime.jsx("g",{transform:`translate(${R.margin.left}, ${R.margin.top+R.innerHeight})`,children:(R.vertical?o.hidden:a?.hidden)?null:jsxRuntime.jsx(Ue,{orientation:"bottom",ticks:R.vertical?R.categoryTicks:R.valueTicks,length:R.innerWidth,label:R.vertical?o.label:a?.label,size:l})}),jsxRuntime.jsx("g",{transform:`translate(${R.margin.left}, ${R.margin.top})`,children:(R.vertical?a?.hidden:o.hidden)?null:jsxRuntime.jsx(Ue,{orientation:"left",ticks:R.vertical?R.valueTicks:R.categoryTicks,length:R.innerHeight,showLine:false,label:R.vertical?a?.label:o.label,size:l})})]}),k&&z&&p!==false?jsxRuntime.jsx(dt,{x:z.x,y:z.y,containerWidth:e,children:typeof p=="function"?p(k):jsxRuntime.jsxs("div",{className:"flex flex-col gap-1",children:[jsxRuntime.jsx("div",{className:"font-medium text-gray-900 dark:text-gray-100",children:k.label}),jsxRuntime.jsxs("div",{className:"flex items-center gap-2",children:[jsxRuntime.jsx("span",{className:"h-2.5 w-2.5 shrink-0 rounded-sm",style:{backgroundColor:f[k.kind]},"aria-hidden":"true"}),jsxRuntime.jsx("span",{className:"font-semibold text-gray-900 [font-variant-numeric:tabular-nums] dark:text-gray-100",children:k.kind==="total"?k.formattedEnd:k.formattedValue})]}),k.kind==="total"?null:jsxRuntime.jsxs("div",{className:"flex items-center gap-2 text-gray-500 dark:text-gray-400",children:[jsxRuntime.jsx("span",{children:v}),jsxRuntime.jsx("span",{className:"[font-variant-numeric:tabular-nums]",children:k.formattedEnd})]})]})}):null]})}function Qh({data:e,x:t,y:r,value:n,total:o,start:a=0,orientation:s="vertical",connectors:l=true,showValues:i=true,barSize:c,colors:d,height:u=280,width:f,size:m="md",grid:p="y",legend:w,tooltip:v=true,tableView:x=false,title:h,description:I,loading:S=false,emptyState:L,margin:R,locale:T,plotLabel:y,valueLabel:M,totalLabel:k,increaseLabel:z,decreaseLabel:H,format:P,onStepClick:B,className:C,...b}){let E=We(),N=el.useMemo(()=>P??(_=>nt(_,T)),[P,T]),W=el.useMemo(()=>t.format??(_=>Ze(_,T)),[t.format,T]),F=el.useMemo(()=>{let _=a;return e.map((X,G)=>{let $=ct(X,t.key,G),Y=Ee(X,n);if(o?!!X[o]:false){let Q=Y??_;return _=Q,{index:G,x:$,label:W($,G),value:Q,start:0,end:Q,kind:"total",formattedValue:N(Q),formattedEnd:N(Q),datum:X}}let ae=_,U=Y===null?_:_+Y;return _=U,{index:G,x:$,label:W($,G),value:Y,start:ae,end:U,kind:Y!==null&&Y<0?"decrease":"increase",formattedValue:Y===null?"\u2014":`${Y>0?"+":""}${N(Y)}`,formattedEnd:N(U),datum:X}})},[e,t.key,n,o,a,N,W]),K=el.useMemo(()=>({increase:d?.increase??Yh,decrease:d?.decrease??qh,total:d?.total??Pr}),[d]),j=k??E.chartRunningTotal,A=el.useMemo(()=>{let _=[{key:"increase",label:z??E.chartIncrease,color:K.increase,marker:"rect"},{key:"decrease",label:H??E.chartDecrease,color:K.decrease,marker:"rect"}];return F.some(X=>X.kind==="total")&&_.push({key:"total",label:j,color:K.total,marker:"rect"}),_},[K,F,z,H,j,E.chartIncrease,E.chartDecrease]),D=el.useMemo(()=>F.map(_=>({[t.key]:_.x,[n]:_.kind==="total"?null:_.value,__running:_.end})),[F,t.key,n]),V=w===void 0?true:w!==false,O=typeof w=="string"?w:"bottom";return jsxRuntime.jsx(lt,{title:h,description:I,height:u,width:f,size:m,loading:S,empty:F.length===0,emptyState:L,tableView:x,legendPosition:O,legend:V?jsxRuntime.jsx(Xt,{items:A,position:O,marker:"rect",size:m}):void 0,table:x?jsxRuntime.jsx(zt,{data:D,series:[{key:n,label:M??E.chartValue},{key:"__running",label:j}],xKey:t.key,xLabel:t.label??t.key,formatX:W,formatValue:N,caption:typeof h=="string"?h:void 0}):void 0,className:C,...b,children:({width:_})=>jsxRuntime.jsx(Zh,{width:_,height:u,steps:F,data:e,x:t,y:r,grid:p,size:m,orientation:s,connectors:l,showValues:i,barSize:c,palette:K,margin:R,tooltip:v,plotLabel:y,totalLabel:j,formatValue:N,formatX:W,onStepClick:B})})}var ab=e=>{switch(e){case "sm":return {checkbox:"w-4 h-4",label:"text-xs",description:"text-xs"};case "lg":return {checkbox:"w-6 h-6",label:"text-base",description:"text-sm"};default:return {checkbox:"w-5 h-5",label:"text-sm",description:"text-xs"}}},sb=e=>{switch(e){case "circle":return "rounded-full";case "rounded":return "rounded-md";default:return "rounded"}},ib=({className:e})=>jsxRuntime.jsx("svg",{className:e,viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:jsxRuntime.jsx("path",{d:"M13.5 4.5L6 12L2.5 8.5",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round"})}),lb=({className:e})=>jsxRuntime.jsx("svg",{className:e,viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:jsxRuntime.jsx("path",{d:"M3 8H13",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round"})}),Aa=el.forwardRef(({checked:e,defaultChecked:t=false,onChange:r,disabled:n=false,readOnly:o=false,required:a=false,name:s,value:l,id:i,label:c,description:d,error:u=false,size:f="md",labelPosition:m="right",checkedColor:p="bg-blue-600",uncheckedColor:w="bg-white dark:bg-gray-800",borderColor:v="border-gray-300 dark:border-gray-600",labelColor:x,errorColor:h="text-red-500",checkmarkColor:I="text-white",hoverColor:S,focusRingColor:L="ring-blue-500",indeterminate:R=false,icon:T,variant:y="default",shape:M="square",animation:k=true,showFocusRing:z=true,className:H,containerClassName:P,style:B,tabIndex:C,...b},E)=>{let N=el.useId(),W=i||N,F=`${W}-error`,K=`${W}-description`,[j,A]=el.useState(t),D=e!==void 0,V=D?e:j,O=el.useRef(null);el.useEffect(()=>{O.current&&(O.current.indeterminate=R);},[R]);let _=ae=>{if(n||o)return;let U=ae.target.checked;D||A(U),r?.(U,ae);},X=ab(f),G=sb(M),$=()=>{let ae=g("relative flex items-center justify-center border-2 transition-all",X.checkbox,G,k&&"duration-200 ease-in-out");return n?g(ae,"opacity-50 cursor-not-allowed",V||R?p:w,v):y==="filled"?g(ae,V||R?p:"bg-gray-100 dark:bg-gray-700",V||R?"border-transparent":v,S&&!o&&`hover:${S}`,"cursor-pointer"):y==="outlined"?g(ae,w,V||R?`border-current ${p.replace("bg-","text-")}`:v,"border-2",S&&!o&&`hover:${S}`,"cursor-pointer"):g(ae,V||R?p:w,V||R?"border-transparent":v,S&&!o&&`hover:${S}`,"cursor-pointer")},Y=u!==false,se=typeof u=="string"?u:void 0;return jsxRuntime.jsxs("div",{className:g("inline-flex flex-col",P),children:[jsxRuntime.jsxs("label",{htmlFor:W,className:g("inline-flex items-start gap-2",n?"cursor-not-allowed":"cursor-pointer",m==="left"&&"flex-row-reverse justify-end"),children:[jsxRuntime.jsx("input",{ref:ae=>{O&&(O.current=ae),typeof E=="function"?E(ae):E&&(E.current=ae);},type:"checkbox",id:W,name:s,value:l,checked:V,onChange:_,disabled:n,readOnly:o,required:a,tabIndex:o?-1:C,"aria-invalid":Y,"aria-describedby":g(se&&F,d&&K),className:"sr-only peer",style:B,...b}),jsxRuntime.jsx("span",{className:g($(),z&&`peer-focus-visible:ring-2 peer-focus-visible:ring-offset-2 peer-focus-visible:${L}`,k&&V&&"scale-100",Y&&"border-red-500"),"aria-hidden":"true",children:(V||R)&&jsxRuntime.jsx("span",{className:g(I,k&&"animate-in zoom-in-50 duration-200"),children:R?T||jsxRuntime.jsx(lb,{className:"w-full h-full"}):T||jsxRuntime.jsx(ib,{className:"w-full h-full"})})}),c&&jsxRuntime.jsxs("span",{className:"flex flex-col gap-1",children:[jsxRuntime.jsxs("span",{className:g(X.label,n&&"opacity-50",x,Y&&h),children:[c,a&&jsxRuntime.jsx("span",{className:"text-red-500 ml-1",children:"*"})]}),d&&jsxRuntime.jsx("span",{id:K,className:g(X.description,"text-gray-500 dark:text-gray-400",n&&"opacity-50"),children:d})]})]}),se&&jsxRuntime.jsx("p",{id:F,className:g("mt-1 text-xs",h),children:se})]})});Aa.displayName="Checkbox";var Fd=el.createContext(null),Od=({label:e,description:t,value:r,defaultValue:n=[],onChange:o,orientation:a="vertical",spacing:s="md",disabled:l=false,size:i="md",error:c=false,required:d=false,children:u,className:f,labelClassName:m,...p})=>{let[w,v]=el__namespace.useState(n),x=r!==void 0,h=x?r:w,I=el__namespace.useCallback(y=>{let M=h.includes(y)?h.filter(k=>k!==y):[...h,y];x||v(M),o?.(M);},[h,x,o]),S=el__namespace.useMemo(()=>({value:h,onChange:I,disabled:l,size:i}),[h,I,l,i]),L={sm:a==="vertical"?"gap-2":"gap-3",md:a==="vertical"?"gap-3":"gap-4",lg:a==="vertical"?"gap-4":"gap-6"},R=c!==false,T=typeof c=="string"?c:void 0;return jsxRuntime.jsxs("div",{className:g("flex flex-col gap-2",f),...p,children:[(e||t)&&jsxRuntime.jsxs("div",{className:"flex flex-col gap-1",children:[e&&jsxRuntime.jsxs("label",{className:g("text-sm font-medium text-gray-900 dark:text-gray-100",l&&"opacity-50",R&&"text-red-500",m),children:[e,d&&jsxRuntime.jsx("span",{className:"text-red-500 ml-1",children:"*"})]}),t&&jsxRuntime.jsx("p",{className:g("text-xs text-gray-500 dark:text-gray-400",l&&"opacity-50"),children:t})]}),jsxRuntime.jsx(Fd.Provider,{value:S,children:jsxRuntime.jsx("div",{className:g("flex",a==="vertical"?"flex-col":"flex-row flex-wrap",L[s]),role:"group",children:u})}),T&&jsxRuntime.jsx("p",{className:"text-xs text-red-500",children:T})]})};Od.displayName="CheckboxGroup";var $d=({value:e,disabled:t,size:r,...n})=>{let o=el.useContext(Fd);if(!o)return console.warn("CheckboxGroupItem doit \xEAtre utilis\xE9 dans un CheckboxGroup"),jsxRuntime.jsx(Aa,{...n,disabled:t,size:r});let{value:a,onChange:s,disabled:l,size:i}=o,c=a.includes(e);return jsxRuntime.jsx(Aa,{...n,checked:c,onChange:()=>s(e),disabled:l||t,size:r||i})};$d.displayName="CheckboxGroupItem";var dr={compact:"px-3 py-1.5",default:"px-4 py-3",comfortable:"px-6 py-4"},_s={compact:"text-xs",default:"text-sm",comfortable:"text-base"},pb=()=>jsxRuntime.jsx("svg",{className:"w-3.5 h-3.5",viewBox:"0 0 16 16",fill:"currentColor",children:jsxRuntime.jsx("path",{d:"M8 3l4 5H4l4-5z"})}),fb=()=>jsxRuntime.jsx("svg",{className:"w-3.5 h-3.5",viewBox:"0 0 16 16",fill:"currentColor",children:jsxRuntime.jsx("path",{d:"M8 13l4-5H4l4 5z"})}),hb=()=>jsxRuntime.jsx("svg",{className:"w-3.5 h-3.5 opacity-30",viewBox:"0 0 16 16",fill:"currentColor",children:jsxRuntime.jsx("path",{d:"M8 3l3 4H5l3-4zM8 13l3-4H5l3 4z"})}),_d=({className:e})=>jsxRuntime.jsx("svg",{className:g("w-4 h-4",e),viewBox:"0 0 20 20",fill:"currentColor",children:jsxRuntime.jsx("path",{fillRule:"evenodd",d:"M5.23 7.21a.75.75 0 011.06.02L10 11.168l3.71-3.938a.75.75 0 111.08 1.04l-4.25 4.5a.75.75 0 01-1.08 0l-4.25-4.5a.75.75 0 01.02-1.06z",clipRule:"evenodd"})}),bb=()=>jsxRuntime.jsx("svg",{className:"w-4 h-4 text-gray-400",viewBox:"0 0 20 20",fill:"currentColor",children:jsxRuntime.jsx("path",{fillRule:"evenodd",d:"M9 3.5a5.5 5.5 0 100 11 5.5 5.5 0 000-11zM2 9a7 7 0 1112.452 4.391l3.328 3.329a.75.75 0 11-1.06 1.06l-3.329-3.328A7 7 0 012 9z",clipRule:"evenodd"})}),yb=()=>jsxRuntime.jsx("svg",{className:"w-4 h-4 text-gray-400",viewBox:"0 0 20 20",fill:"currentColor",children:jsxRuntime.jsx("path",{d:"M7 4a1.5 1.5 0 110-3 1.5 1.5 0 010 3zm6 0a1.5 1.5 0 110-3 1.5 1.5 0 010 3zM7 10.5a1.5 1.5 0 110-3 1.5 1.5 0 010 3zm6 0a1.5 1.5 0 110-3 1.5 1.5 0 010 3zM7 17a1.5 1.5 0 110-3 1.5 1.5 0 010 3zm6 0a1.5 1.5 0 110-3 1.5 1.5 0 010 3z"})}),xb=()=>jsxRuntime.jsx("svg",{className:"w-3.5 h-3.5",viewBox:"0 0 20 20",fill:"currentColor",children:jsxRuntime.jsx("path",{fillRule:"evenodd",d:"M2.628 1.601C5.028 1.206 7.49 1 10 1s4.973.206 7.372.601a.75.75 0 01.628.74v2.288a2.25 2.25 0 01-.659 1.59l-4.682 4.683a2.25 2.25 0 00-.659 1.59v3.037c0 .684-.31 1.33-.844 1.757l-1.937 1.55A.75.75 0 018 18.25v-5.757a2.25 2.25 0 00-.659-1.591L2.659 6.22A2.25 2.25 0 012 4.629V2.34a.75.75 0 01.628-.74z",clipRule:"evenodd"})}),vb=()=>jsxRuntime.jsxs("svg",{className:"w-4 h-4",viewBox:"0 0 20 20",fill:"currentColor",children:[jsxRuntime.jsx("path",{d:"M10.75 2.75a.75.75 0 00-1.5 0v8.614L6.295 8.235a.75.75 0 10-1.09 1.03l4.25 4.5a.75.75 0 001.09 0l4.25-4.5a.75.75 0 00-1.09-1.03l-2.955 3.129V2.75z"}),jsxRuntime.jsx("path",{d:"M3.5 12.75a.75.75 0 00-1.5 0v2.5A2.75 2.75 0 004.75 18h10.5A2.75 2.75 0 0018 15.25v-2.5a.75.75 0 00-1.5 0v2.5c0 .69-.56 1.25-1.25 1.25H4.75c-.69 0-1.25-.56-1.25-1.25v-2.5z"})]}),Cb=()=>jsxRuntime.jsx("svg",{className:"w-4 h-4",viewBox:"0 0 20 20",fill:"currentColor",children:jsxRuntime.jsx("path",{fillRule:"evenodd",d:"M2.5 3A1.5 1.5 0 001 4.5v11A1.5 1.5 0 002.5 17h15a1.5 1.5 0 001.5-1.5v-11A1.5 1.5 0 0017.5 3h-15zM2.5 4.5h6v11h-6v-11zm7.5 0h7.5v11H10v-11z",clipRule:"evenodd"})});function $s(e,t,r){return typeof r=="function"?r(e,t):String(typeof r=="string"?e[r]:t)}function an(e,t){return e[t]}function kb(e,t){return e==null&&t==null?0:e==null?-1:t==null?1:typeof e=="number"&&typeof t=="number"?e-t:String(e).localeCompare(String(t))}function wb(e,t){let r=String(e??"").toLowerCase(),n=t.value.toLowerCase();switch(t.operator){case "contains":return r.includes(n);case "equals":return r===n;case "startsWith":return r.startsWith(n);case "endsWith":return r.endsWith(n);case "gt":return Number(e)>Number(t.value);case "gte":return Number(e)>=Number(t.value);case "lt":return Number(e)<Number(t.value);case "lte":return Number(e)<=Number(t.value);case "isEmpty":return r==="";case "isNotEmpty":return r!=="";default:return true}}function Xd(e,t,r){let n=[];for(let o of e){let a=Number(an(o,t));isNaN(a)||n.push(a);}if(n.length===0)return 0;switch(r){case "sum":return n.reduce((o,a)=>o+a,0);case "avg":return n.reduce((o,a)=>o+a,0)/n.length;case "count":return n.length;case "min":return Math.min(...n);case "max":return Math.max(...n)}}function Nb({cols:e,density:t}){return jsxRuntime.jsx("tr",{className:"border-b border-gray-200 dark:border-gray-700",children:Array.from({length:e}).map((r,n)=>jsxRuntime.jsx("td",{className:dr[t],children:jsxRuntime.jsx("div",{className:"h-4 bg-gray-200 dark:bg-gray-700 rounded animate-pulse"})},n))})}function Sb({column:e,value:t,onApply:r,onClear:n}){let[o,a]=el.useState(false),[s,l]=el.useState(t?.operator??"contains"),[i,c]=el.useState(t?.value??""),d=el.useRef(null),u=e.filterType??"text",f=u==="number"?[{value:"equals",label:"Equals"},{value:"gt",label:"Greater than"},{value:"gte",label:"Greater or equal"},{value:"lt",label:"Less than"},{value:"lte",label:"Less or equal"}]:[{value:"contains",label:"Contains"},{value:"equals",label:"Equals"},{value:"startsWith",label:"Starts with"},{value:"endsWith",label:"Ends with"},{value:"isEmpty",label:"Is empty"},{value:"isNotEmpty",label:"Is not empty"}];return el.useEffect(()=>{let m=p=>{d.current&&!d.current.contains(p.target)&&a(false);};return o&&document.addEventListener("mousedown",m),()=>document.removeEventListener("mousedown",m)},[o]),jsxRuntime.jsxs("div",{className:"relative inline-block",ref:d,children:[jsxRuntime.jsx("button",{type:"button",onClick:m=>{m.stopPropagation(),a(!o);},className:g("p-0.5 rounded hover:bg-gray-200 dark:hover:bg-gray-600 cursor-pointer",t&&"text-blue-600 dark:text-blue-400"),"aria-label":`Filter ${String(e.header)}`,children:jsxRuntime.jsx(xb,{})}),o&&jsxRuntime.jsx("div",{className:"absolute z-50 top-full left-0 mt-1 bg-white dark:bg-gray-800 border border-gray-200 dark:border-gray-700 rounded-lg shadow-lg p-3 min-w-[220px]",children:u==="select"&&e.filterOptions?jsxRuntime.jsxs("div",{className:"flex flex-col gap-1.5",children:[e.filterOptions.map(m=>jsxRuntime.jsxs("label",{className:"flex items-center gap-2 text-sm cursor-pointer",children:[jsxRuntime.jsx("input",{type:"radio",name:`filter-${e.key}`,value:m,checked:i===m,onChange:()=>c(m),className:"cursor-pointer"}),jsxRuntime.jsx("span",{className:"text-gray-700 dark:text-gray-300",children:m})]},m)),jsxRuntime.jsxs("div",{className:"flex gap-2 mt-2",children:[jsxRuntime.jsx("button",{type:"button",onClick:()=>{r({column:e.key,operator:"equals",value:i}),a(false);},className:"px-2 py-1 text-xs bg-blue-600 text-white rounded hover:bg-blue-700 cursor-pointer",children:"Apply"}),jsxRuntime.jsx("button",{type:"button",onClick:()=>{c(""),n(),a(false);},className:"px-2 py-1 text-xs text-gray-600 dark:text-gray-400 hover:text-gray-800 dark:hover:text-gray-200 cursor-pointer",children:"Clear"})]})]}):jsxRuntime.jsxs("div",{className:"flex flex-col gap-2",children:[jsxRuntime.jsx("select",{value:s,onChange:m=>l(m.target.value),className:"text-xs border border-gray-300 dark:border-gray-600 rounded px-2 py-1 bg-white dark:bg-gray-700 text-gray-700 dark:text-gray-200",children:f.map(m=>jsxRuntime.jsx("option",{value:m.value,children:m.label},m.value))}),s!=="isEmpty"&&s!=="isNotEmpty"&&jsxRuntime.jsx("input",{type:u==="number"?"number":u==="date"?"date":"text",value:i,onChange:m=>c(m.target.value),placeholder:"Filter value...",className:"text-xs border border-gray-300 dark:border-gray-600 rounded px-2 py-1 bg-white dark:bg-gray-700 text-gray-700 dark:text-gray-200",autoFocus:true,"aria-label":`Filter ${String(e.header)} value`}),jsxRuntime.jsxs("div",{className:"flex gap-2",children:[jsxRuntime.jsx("button",{type:"button",onClick:()=>{r({column:e.key,operator:s,value:i}),a(false);},className:"px-2 py-1 text-xs bg-blue-600 text-white rounded hover:bg-blue-700 cursor-pointer",children:"Apply"}),jsxRuntime.jsx("button",{type:"button",onClick:()=>{c(""),n(),a(false);},className:"px-2 py-1 text-xs text-gray-600 dark:text-gray-400 hover:text-gray-800 dark:hover:text-gray-200 cursor-pointer",children:"Clear"})]})]})})]})}function Rb({value:e,onSave:t,density:r}){let[n,o]=el.useState(false),[a,s]=el.useState(String(e??"")),l=el.useRef(null);if(el.useEffect(()=>{n&&l.current&&(l.current.focus(),l.current.select());},[n]),!n)return jsxRuntime.jsx("div",{onDoubleClick:()=>{s(String(e??"")),o(true);},className:"cursor-text min-h-[1.5em]",title:"Double-click to edit",children:String(e??"")});let i=()=>{o(false),a!==String(e??"")&&t(a);};return jsxRuntime.jsx("input",{ref:l,type:"text",value:a,onChange:c=>s(c.target.value),onBlur:i,"aria-label":"Edit cell value",onKeyDown:c=>{c.key==="Enter"&&i(),c.key==="Escape"&&o(false);},className:g("w-full border border-blue-500 rounded px-1 py-0.5 bg-white dark:bg-gray-700 text-gray-900 dark:text-gray-100 outline-none",_s[r])})}function Tb(e,t){let{columns:r,data:n,rowKey:o,mode:a="client",sortable:s=false,multiSort:l=false,sort:i,defaultSort:c,onSort:d,pagination:u=false,page:f,onPageChange:m,onPageSizeChange:p,totalItems:w,selectable:v=false,selectionMode:x="multiple",selectedRows:h,onSelectionChange:I,searchable:S=false,searchPlaceholder:L="Search...",searchValue:R,onSearch:T,filters:y,onFilterChange:M,expandable:k=false,expandedContent:z,expandedRows:H,onExpandChange:P,editable:B=false,onCellEdit:C,reorderable:b=false,onReorder:E,columnReorderable:N=false,onColumnReorder:W,columnToggle:F=false,hiddenColumns:K,onColumnVisibilityChange:j,groupBy:A,renderGroupHeader:D,exportable:V=false,exportFormats:O=["csv","json"],exportFilename:_="export",virtualized:X=false,rowHeight:G=40,virtualHeight:$=400,density:Y="default",striped:se=false,bordered:ae=false,borderless:U=false,stickyHeader:Q=false,maxHeight:le,loading:ye=false,loadingRows:te=5,emptyState:Ce,showFooter:Pe=false,onRowClick:Se,onRowDoubleClick:De,onRowContextMenu:Ne,className:re,rowClassName:fe,cellClassName:je,headerClassName:Dt}=e,[Ie,we]=el.useState(c??[]),[pt,Bt]=el.useState(1),[yt,er]=el.useState(typeof u=="object"?u.pageSize??10:10),[Mt,Nt]=el.useState([]),[gr,pr]=el.useState(""),[vt,Cr]=el.useState([]),[he,ge]=el.useState([]),[J,ne]=el.useState(()=>r.flatMap(q=>q.hidden?[q.key]:[])),[be,me]=el.useState({}),[Me,ke]=el.useState(()=>r.map(q=>q.key)),[Re,Be]=el.useState(null),[ze,st]=el.useState(null),[qe,Oe]=el.useState(false),[Ot,xt]=el.useState(new Set),Br=el.useRef(null),[pn,jn]=el.useState(0),So=el.useRef(null),Yr=i??Ie,Vr=f??pt,Z=h??Mt,oe=R??gr,ie=y??vt,ce=H??he,pe=K??J,Ke=u?typeof u=="object"?u:{pageSize:10,pageSizeOptions:[10,25,50,100]}:null,ot=Ke?.pageSize??yt,Je=el.useMemo(()=>{let q=new Map(r.map(Le=>[Le.key,Le])),ee=Me.flatMap(Le=>{let $e=q.get(Le);return $e?[$e]:[]}),ue=new Set(ee.map(Le=>Le.key));for(let Le of r)ue.has(Le.key)||(ee.push(Le),ue.add(Le.key));return ee.filter(Le=>!pe.includes(Le.key))},[r,Me,pe]),Ve=el.useMemo(()=>{if(a==="server")return n;let q=[...n];if(oe){let ee=oe.toLowerCase();q=q.filter(ue=>Je.some(Le=>{let $e=an(ue,Le.key);return String($e??"").toLowerCase().includes(ee)}));}if(ie.length>0&&(q=q.filter(ee=>ie.every(ue=>wb(an(ee,ue.column),ue)))),Yr.length>0){let ee=new Map(r.map(ue=>[ue.key,ue]));q.sort((ue,Le)=>{for(let $e of Yr){if(!$e.direction)continue;let At=ee.get($e.key),yr=At?.sortComparator?At.sortComparator(ue,Le):kb(an(ue,$e.key),an(Le,$e.key));if(yr!==0)return $e.direction==="asc"?yr:-yr}return 0});}return q},[n,a,oe,ie,Yr,Je,r]),or=el.useMemo(()=>{if(!A)return null;let q=Array.isArray(A)?A:[A],ee=new Map;for(let ue of Ve){let Le=q.map(At=>String(an(ue,At)??"")).join(" / "),$e=ee.get(Le)??[];$e.push(ue),ee.set(Le,$e);}return ee},[Ve,A]),et=w??Ve.length,It=Math.max(1,Math.ceil(et/ot)),$t=el.useMemo(()=>{if(!Ke||a==="server")return Ve;let q=(Vr-1)*ot;return Ve.slice(q,q+ot)},[Ve,Ke,Vr,ot,a]),Ct=Ke?$t:Ve,lr=el.useMemo(()=>{if(!X)return {start:0,end:Ct.length};let q=Math.floor(pn/G),ee=Math.ceil($/G),ue=5;return {start:Math.max(0,q-ue),end:Math.min(Ct.length,q+ee+ue)}},[X,pn,G,$,Ct.length]),qr=el.useCallback(q=>{i||we(q),d?.(q);},[i,d]),jr=el.useCallback(q=>{let ee=Yr.find(Le=>Le.key===q),ue;if(!ee||!ee.direction?ue="asc":ee.direction==="asc"?ue="desc":ue=null,l){let Le=Yr.filter($e=>$e.key!==q);ue&&Le.push({key:q,direction:ue}),qr(Le);}else qr(ue?[{key:q,direction:ue}]:[]);},[Yr,l,qr]),kr=el.useCallback(q=>{let ee=Math.max(1,Math.min(q,It));f||Bt(ee),m?.(ee);},[f,m,It]),Si=el.useCallback(q=>{er(q),kr(1),p?.(q);},[kr,p]),ss=el.useCallback(q=>{let ee;x==="single"?ee=Z.includes(q)?[]:[q]:ee=Z.includes(q)?Z.filter(ue=>ue!==q):[...Z,q],h||Nt(ee),I?.(ee);},[x,Z,h,I]),Ri=el.useCallback(()=>{let q=Ct.map((ee,ue)=>$s(ee,ue,o));h||Nt(q),I?.(q);},[Ct,o,h,I]),Ti=el.useCallback(()=>{h||Nt([]),I?.([]);},[h,I]),Pi=Ct.length>0&&Ct.every((q,ee)=>Z.includes($s(q,ee,o))),Rg=!Pi&&Ct.some((q,ee)=>Z.includes($s(q,ee,o))),Tg=el.useCallback(q=>{let ee=ce.includes(q)?ce.filter(ue=>ue!==q):[...ce,q];H||ge(ee),P?.(ee);},[ce,H,P]),Pg=el.useCallback(q=>{let ee=q.target.value;R||pr(ee),T?.(ee),kr(1);},[R,T,kr]),Dg=el.useCallback(q=>{let ee=[...ie.filter(ue=>ue.column!==q.column),q];y||Cr(ee),M?.(ee);},[ie,y,M]),Lg=el.useCallback(q=>{let ee=ie.filter(ue=>ue.column!==q);y||Cr(ee),M?.(ee);},[ie,y,M]),Eg=el.useCallback(q=>{let ee=pe.includes(q)?pe.filter(ue=>ue!==q):[...pe,q];K||ne(ee),j?.(ee);},[pe,K,j]),Mg=el.useCallback((q,ee)=>{q.preventDefault(),q.stopPropagation();let ue=q.clientX,Le=be[ee]??q.currentTarget.parentElement?.getBoundingClientRect().width??100,$e=r.find(xr=>xr.key===ee),At=$e?.minWidth??50,yr=$e?.maxWidth??1/0,it=xr=>{let Zn=xr.clientX-ue,Qr=Math.min(yr,Math.max(At,Le+Zn));me(To=>({...To,[ee]:Qr}));},Zr=()=>{document.removeEventListener("mousemove",it),document.removeEventListener("mouseup",Zr);};document.addEventListener("mousemove",it),document.addEventListener("mouseup",Zr);},[be,r]),Ig=el.useCallback(q=>{b&&Be(q);},[b]),Ag=el.useCallback((q,ee)=>{!b||Re===null||q.preventDefault();},[b,Re]),zg=el.useCallback(q=>{!b||Re===null||Re===q||(E?.(Re,q),Be(null));},[b,Re,E]),Wg=el.useCallback(q=>{N&&st(q);},[N]),Hg=el.useCallback(q=>{if(!N||!ze||ze===q)return;let ee=[...Me],ue=ee.indexOf(ze),Le=ee.indexOf(q);ue===-1||Le===-1||(ee.splice(ue,1),ee.splice(Le,0,ze),ke(ee),W?.(ze,q),st(null));},[N,ze,Me,W]),Di=el.useCallback(q=>{let ee=Je.filter(xr=>xr.type!=="actions"&&xr.type!=="selection"&&xr.type!=="expand"),ue=Ve,Le,$e,At;if(q==="csv"){let xr=ee.map(Qr=>String(Qr.header)).join(","),Zn=ue.map(Qr=>ee.map(To=>{let Mi=String(an(Qr,To.key)??"");return Mi.includes(",")?`"${Mi}"`:Mi}).join(","));Le=[xr,...Zn].join(`
2
- `),$e="text/csv",At="csv";}else {let xr=ue.map(Zn=>{let Qr={};for(let To of ee)Qr[To.key]=an(Zn,To.key);return Qr});Le=JSON.stringify(xr,null,2),$e="application/json",At="json";}let yr=new Blob([Le],{type:$e}),it=URL.createObjectURL(yr),Zr=document.createElement("a");Zr.href=it,Zr.download=`${_}.${At}`,Zr.click(),URL.revokeObjectURL(it);},[Je,Ve,_]);el.useEffect(()=>{if(!qe)return;let q=ee=>{So.current&&!So.current.contains(ee.target)&&Oe(false);};return document.addEventListener("mousedown",q),()=>document.removeEventListener("mousedown",q)},[qe]),el.useImperativeHandle(t,()=>({getVisibleData:()=>Ct,resetFilters:()=>{y||Cr([]),R||pr(""),M?.([]),T?.("");},resetSort:()=>{i||we([]),d?.([]);},selectAll:Ri,deselectAll:Ti,exportData:Di,scrollToRow:q=>{Br.current&&X&&(Br.current.scrollTop=q*G);}}),[Ct,y,R,i,M,T,d,Ri,Ti,Di,X,G]);let Li=q=>{let ee={},ue=be[q.key]??q.width;return ue&&(ee.width=typeof ue=="number"?`${ue}px`:ue,ee.minWidth=typeof ue=="number"?`${ue}px`:ue),q.sticky&&(ee.position="sticky",ee[q.sticky]=0,ee.zIndex=10),ee},Ro=Je.length+(v?1:0)+(k?1:0)+(b?1:0),Bg=q=>{let ee=s&&q.sortable!==false&&q.type!=="actions",ue=Yr.find($e=>$e.key===q.key),Le=q.filterable&&(q.filterType||q.filterOptions);return jsxRuntime.jsxs("th",{className:g(dr[Y],_s[Y],"font-semibold text-gray-700 dark:text-gray-300 whitespace-nowrap",q.align==="center"&&"text-center",q.align==="right"&&"text-right",ee&&"cursor-pointer select-none hover:bg-gray-100 dark:hover:bg-gray-700",ae&&"border border-gray-200 dark:border-gray-700",q.sticky&&"bg-gray-50 dark:bg-gray-800",q.headerClassName,Dt),style:Li(q),onClick:ee?()=>jr(q.key):void 0,draggable:N,onDragStart:N?()=>Wg(q.key):void 0,onDragOver:N?$e=>$e.preventDefault():void 0,onDrop:N?()=>Hg(q.key):void 0,"aria-sort":ue?.direction==="asc"?"ascending":ue?.direction==="desc"?"descending":void 0,children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-1",children:[q.renderHeader?q.renderHeader(q):q.header,ee&&jsxRuntime.jsx("span",{className:"inline-flex ml-1",children:ue?.direction==="asc"?jsxRuntime.jsx(pb,{}):ue?.direction==="desc"?jsxRuntime.jsx(fb,{}):jsxRuntime.jsx(hb,{})}),Le&&jsxRuntime.jsx(Sb,{column:q,value:ie.find($e=>$e.column===q.key),onApply:Dg,onClear:()=>Lg(q.key)})]}),q.resizable!==false&&jsxRuntime.jsx("div",{className:"absolute top-0 right-0 w-1 h-full cursor-col-resize hover:bg-blue-500 opacity-0 hover:opacity-100",onMouseDown:$e=>Mg($e,q.key)})]},q.key)},Ei=(q,ee,ue)=>{let Le=$s(q,ue,o),$e=Z.includes(Le),At=ce.includes(Le),yr=typeof fe=="function"?fe(q,ue):fe;return jsxRuntime.jsxs(el__namespace.default.Fragment,{children:[jsxRuntime.jsxs("tr",{className:g("border-b border-gray-200 dark:border-gray-700 transition-colors",se&&ue%2===1&&"bg-gray-50/50 dark:bg-gray-800/50",$e&&"bg-blue-50 dark:bg-blue-900/20",Se&&"cursor-pointer hover:bg-gray-50 dark:hover:bg-gray-700/50",Re===ee&&"opacity-50",yr),onClick:Se?()=>Se(q,ue):void 0,onDoubleClick:De?()=>De(q,ue):void 0,onContextMenu:Ne?it=>Ne(q,ue,it):void 0,draggable:b,onDragStart:b?()=>Ig(ee):void 0,onDragOver:b?it=>Ag(it,ee):void 0,onDrop:b?()=>zg(ee):void 0,"data-row-key":Le,"aria-selected":v?$e:void 0,children:[b&&jsxRuntime.jsx("td",{className:g(dr[Y],"cursor-grab active:cursor-grabbing"),children:jsxRuntime.jsx(yb,{})}),v&&jsxRuntime.jsx("td",{className:g(dr[Y],"w-10"),children:jsxRuntime.jsx("input",{type:"checkbox",checked:$e,onChange:()=>ss(Le),onClick:it=>it.stopPropagation(),className:"rounded border-gray-300 dark:border-gray-600 cursor-pointer","aria-label":`Select row ${Le}`})}),k&&jsxRuntime.jsx("td",{className:g(dr[Y],"w-10"),children:jsxRuntime.jsx("button",{type:"button",onClick:it=>{it.stopPropagation(),Tg(Le);},className:"p-0.5 rounded hover:bg-gray-200 dark:hover:bg-gray-600 cursor-pointer","aria-label":At?"Collapse row":"Expand row","aria-expanded":At,children:jsxRuntime.jsx(_d,{className:g("transition-transform",At&&"rotate-180")})})}),Je.map(it=>{let Zr=an(q,it.key),xr=it.colSpan?.(q,ue);if(xr===0)return null;let Zn=B&&it.editable!==false&&it.type!=="actions";return jsxRuntime.jsx("td",{className:g(dr[Y],_s[Y],"text-gray-700 dark:text-gray-300",it.align==="center"&&"text-center",it.align==="right"&&"text-right",ae&&"border border-gray-200 dark:border-gray-700",it.sticky&&($e?"bg-blue-50 dark:bg-blue-900/20":se&&ue%2===1?"bg-gray-50/50 dark:bg-gray-800/50":"bg-white dark:bg-gray-900"),it.cellClassName,je),style:Li(it),colSpan:xr,children:Zn?jsxRuntime.jsx(Rb,{value:Zr,onSave:Qr=>C?.(Le,it.key,Qr),density:Y}):it.render?it.render(Zr,q,ue):String(Zr??"")},it.key)})]}),k&&At&&z&&jsxRuntime.jsx("tr",{className:"bg-gray-50 dark:bg-gray-800/70",children:jsxRuntime.jsx("td",{colSpan:Ro,className:g(dr[Y]),children:z(q,ue)})})]},Le)},Vg=()=>{if(ye)return Array.from({length:te}).map((q,ee)=>jsxRuntime.jsx(Nb,{cols:Ro,density:Y},ee));if(Ct.length===0)return jsxRuntime.jsx("tr",{children:jsxRuntime.jsx("td",{colSpan:Ro,className:g("text-center text-gray-400 dark:text-gray-500",dr[Y]),children:Ce??"No data available"})});if(or){let q=[],ee=0;for(let[ue,Le]of or){let $e=Ot.has(ue);if(q.push(jsxRuntime.jsx("tr",{className:"bg-gray-100 dark:bg-gray-800 font-medium",children:jsxRuntime.jsx("td",{colSpan:Ro,className:g(dr[Y],"cursor-pointer"),onClick:()=>{xt(At=>{let yr=new Set(At);return yr.has(ue)?yr.delete(ue):yr.add(ue),yr});},children:jsxRuntime.jsxs("div",{className:"flex items-center gap-2",children:[jsxRuntime.jsx(_d,{className:g("transition-transform",$e&&"-rotate-90")}),D?D(ue,an(Le[0],Array.isArray(A)?A[0]:A),Le):`${ue} (${Le.length})`]})})},`group-${ue}`)),$e)ee+=Le.length;else for(let At=0;At<Le.length;At++)q.push(Ei(Le[At],ee,ee)),ee++;}return q}if(X){let q=[];for(let ee=lr.start;ee<lr.end;ee++)q.push(Ei(Ct[ee],ee,ee));return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[lr.start>0&&jsxRuntime.jsx("tr",{children:jsxRuntime.jsx("td",{colSpan:Ro,style:{height:lr.start*G,padding:0}})}),q,lr.end<Ct.length&&jsxRuntime.jsx("tr",{children:jsxRuntime.jsx("td",{colSpan:Ro,style:{height:(Ct.length-lr.end)*G,padding:0}})})]})}return Ct.map((q,ee)=>Ei(q,ee,ee))},Fg=()=>!Pe||!Je.some(ee=>ee.aggregate)?null:jsxRuntime.jsx("tfoot",{children:jsxRuntime.jsxs("tr",{className:"bg-gray-50 dark:bg-gray-800 font-semibold border-t-2 border-gray-300 dark:border-gray-600",children:[b&&jsxRuntime.jsx("td",{className:dr[Y]}),v&&jsxRuntime.jsx("td",{className:dr[Y]}),k&&jsxRuntime.jsx("td",{className:dr[Y]}),Je.map(ee=>jsxRuntime.jsx("td",{className:g(dr[Y],_s[Y],"text-gray-700 dark:text-gray-300",ee.align==="center"&&"text-center",ee.align==="right"&&"text-right",ae&&"border border-gray-200 dark:border-gray-700"),style:Li(ee),children:ee.aggregate?ee.renderAggregate?ee.renderAggregate(Xd(Ve,ee.key,ee.aggregate),Ve):`${ee.aggregate==="count"?"":ee.aggregate==="avg"?"Avg: ":ee.aggregate==="sum"?"Total: ":ee.aggregate==="min"?"Min: ":"Max: "}${Xd(Ve,ee.key,ee.aggregate).toLocaleString()}`:""},ee.key))]})});return jsxRuntime.jsxs("div",{className:g("flex flex-col gap-3",re),children:[(S||V||F)&&jsxRuntime.jsxs("div",{className:"flex items-center justify-between gap-3 flex-wrap",children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-3 flex-1",children:[S&&jsxRuntime.jsxs("div",{className:"relative flex-1 max-w-xs",children:[jsxRuntime.jsx("div",{className:"absolute inset-y-0 left-0 flex items-center pl-3 pointer-events-none",children:jsxRuntime.jsx(bb,{})}),jsxRuntime.jsx("input",{type:"text",value:oe,onChange:Pg,placeholder:L,className:"w-full pl-9 pr-3 py-1.5 text-sm border border-gray-300 dark:border-gray-600 rounded-md bg-white dark:bg-gray-800 text-gray-700 dark:text-gray-200 focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-blue-500","aria-label":"Search table"})]}),Z.length>0&&jsxRuntime.jsxs("span",{className:"text-sm text-gray-500 dark:text-gray-400",children:[Z.length," selected"]})]}),jsxRuntime.jsxs("div",{className:"flex items-center gap-2",children:[F&&jsxRuntime.jsxs("div",{className:"relative",ref:So,children:[jsxRuntime.jsx("button",{type:"button",onClick:()=>Oe(!qe),className:"p-1.5 rounded-md border border-gray-300 dark:border-gray-600 text-gray-600 dark:text-gray-400 hover:bg-gray-100 dark:hover:bg-gray-700 cursor-pointer","aria-label":"Toggle columns",title:"Toggle columns",children:jsxRuntime.jsx(Cb,{})}),qe&&jsxRuntime.jsx("div",{className:"absolute z-50 right-0 top-full mt-1 bg-white dark:bg-gray-800 border border-gray-200 dark:border-gray-700 rounded-lg shadow-lg p-2 min-w-[180px]",children:r.filter(q=>q.type!=="selection"&&q.type!=="expand").map(q=>jsxRuntime.jsxs("label",{className:"flex items-center gap-2 px-2 py-1.5 text-sm rounded hover:bg-gray-100 dark:hover:bg-gray-700 cursor-pointer",children:[jsxRuntime.jsx("input",{type:"checkbox",checked:!pe.includes(q.key),onChange:()=>Eg(q.key),className:"rounded border-gray-300 dark:border-gray-600 cursor-pointer"}),jsxRuntime.jsx("span",{className:"text-gray-700 dark:text-gray-300",children:String(q.header)})]},q.key))})]}),V&&O.map(q=>jsxRuntime.jsxs("button",{type:"button",onClick:()=>Di(q),className:"inline-flex items-center gap-1.5 px-2.5 py-1.5 text-xs font-medium rounded-md border border-gray-300 dark:border-gray-600 text-gray-600 dark:text-gray-400 hover:bg-gray-100 dark:hover:bg-gray-700 cursor-pointer",title:`Export as ${q.toUpperCase()}`,children:[jsxRuntime.jsx(vb,{}),q.toUpperCase()]},q))]})]}),jsxRuntime.jsx("div",{ref:Br,className:g("overflow-auto rounded-lg",!U&&"border border-gray-200 dark:border-gray-700",Q&&"relative"),style:le?{maxHeight:typeof le=="number"?`${le}px`:le}:X?{maxHeight:$,overflow:"auto"}:void 0,onScroll:X?q=>jn(q.target.scrollTop):void 0,children:jsxRuntime.jsxs("table",{className:"w-full text-left",children:[jsxRuntime.jsx("thead",{className:g("bg-gray-50 dark:bg-gray-800 text-xs uppercase",Q&&"sticky top-0 z-20"),children:jsxRuntime.jsxs("tr",{children:[b&&jsxRuntime.jsx("th",{className:g(dr[Y],"w-10 font-semibold text-gray-700 dark:text-gray-300")}),v&&jsxRuntime.jsx("th",{className:g(dr[Y],"w-10"),children:x==="multiple"&&jsxRuntime.jsx("input",{type:"checkbox",checked:Pi,ref:q=>{q&&(q.indeterminate=Rg);},onChange:Pi?Ti:Ri,className:"rounded border-gray-300 dark:border-gray-600 cursor-pointer","aria-label":"Select all rows"})}),k&&jsxRuntime.jsx("th",{className:g(dr[Y],"w-10 font-semibold text-gray-700 dark:text-gray-300")}),Je.map(Bg)]})}),jsxRuntime.jsx("tbody",{children:Vg()}),Fg()]})}),Ke&&jsxRuntime.jsxs("div",{className:"flex items-center justify-between flex-wrap gap-3 text-sm text-gray-600 dark:text-gray-400",children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-3",children:[Ke.showTotalItems!==false&&jsxRuntime.jsxs("span",{children:[et," item",et!==1?"s":""]}),Ke.showPageSizeSelector!==false&&Ke.pageSizeOptions&&jsxRuntime.jsxs("div",{className:"flex items-center gap-1.5",children:[jsxRuntime.jsx("span",{children:"Rows per page:"}),jsxRuntime.jsx("select",{value:ot,onChange:q=>Si(Number(q.target.value)),className:"border border-gray-300 dark:border-gray-600 rounded px-1.5 py-0.5 bg-white dark:bg-gray-800 text-gray-700 dark:text-gray-200 text-sm",children:Ke.pageSizeOptions.map(q=>jsxRuntime.jsx("option",{value:q,children:q},q))})]})]}),jsxRuntime.jsxs("div",{className:"flex items-center gap-1",children:[jsxRuntime.jsxs("span",{className:"mr-2",children:["Page ",Vr," of ",It]}),jsxRuntime.jsx("button",{type:"button",onClick:()=>kr(1),disabled:Vr<=1,className:"px-2 py-1 rounded border border-gray-300 dark:border-gray-600 disabled:opacity-50 disabled:cursor-not-allowed hover:bg-gray-100 dark:hover:bg-gray-700 cursor-pointer","aria-label":"First page",children:"\xAB\xAB"}),jsxRuntime.jsx("button",{type:"button",onClick:()=>kr(Vr-1),disabled:Vr<=1,className:"px-2 py-1 rounded border border-gray-300 dark:border-gray-600 disabled:opacity-50 disabled:cursor-not-allowed hover:bg-gray-100 dark:hover:bg-gray-700 cursor-pointer","aria-label":"Previous page",children:"\xAB"}),jsxRuntime.jsx("button",{type:"button",onClick:()=>kr(Vr+1),disabled:Vr>=It,className:"px-2 py-1 rounded border border-gray-300 dark:border-gray-600 disabled:opacity-50 disabled:cursor-not-allowed hover:bg-gray-100 dark:hover:bg-gray-700 cursor-pointer","aria-label":"Next page",children:"\xBB"}),jsxRuntime.jsx("button",{type:"button",onClick:()=>kr(It),disabled:Vr>=It,className:"px-2 py-1 rounded border border-gray-300 dark:border-gray-600 disabled:opacity-50 disabled:cursor-not-allowed hover:bg-gray-100 dark:hover:bg-gray-700 cursor-pointer","aria-label":"Last page",children:"\xBB\xBB"})]})]})]})}var Pb=el.forwardRef(Tb);function Lb({className:e}){return jsxRuntime.jsx("svg",{className:e,viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",children:jsxRuntime.jsx("path",{d:"M4 4L12 12M12 4L4 12",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})})}var Eb={default:{solid:"bg-gray-500 text-white",outlined:"border-gray-300 text-gray-700 dark:border-gray-600 dark:text-gray-300 bg-transparent",soft:"bg-gray-100 text-gray-700 dark:bg-gray-700 dark:text-gray-300",dot:"bg-gray-100 text-gray-700 dark:bg-gray-800 dark:text-gray-300"},primary:{solid:"bg-blue-600 text-white",outlined:"border-blue-600 text-blue-600 dark:border-blue-400 dark:text-blue-400 bg-transparent",soft:"bg-blue-100 text-blue-700 dark:bg-blue-900/50 dark:text-blue-300",dot:"bg-blue-50 text-blue-700 dark:bg-blue-900/30 dark:text-blue-300"},success:{solid:"bg-green-600 text-white",outlined:"border-green-600 text-green-600 dark:border-green-400 dark:text-green-400 bg-transparent",soft:"bg-green-100 text-green-700 dark:bg-green-900/50 dark:text-green-300",dot:"bg-green-50 text-green-700 dark:bg-green-900/30 dark:text-green-300"},warning:{solid:"bg-yellow-500 text-white",outlined:"border-yellow-500 text-yellow-600 dark:border-yellow-400 dark:text-yellow-400 bg-transparent",soft:"bg-yellow-100 text-yellow-700 dark:bg-yellow-900/50 dark:text-yellow-300",dot:"bg-yellow-50 text-yellow-700 dark:bg-yellow-900/30 dark:text-yellow-300"},error:{solid:"bg-red-600 text-white",outlined:"border-red-600 text-red-600 dark:border-red-400 dark:text-red-400 bg-transparent",soft:"bg-red-100 text-red-700 dark:bg-red-900/50 dark:text-red-300",dot:"bg-red-50 text-red-700 dark:bg-red-900/30 dark:text-red-300"},info:{solid:"bg-cyan-600 text-white",outlined:"border-cyan-600 text-cyan-600 dark:border-cyan-400 dark:text-cyan-400 bg-transparent",soft:"bg-cyan-100 text-cyan-700 dark:bg-cyan-900/50 dark:text-cyan-300",dot:"bg-cyan-50 text-cyan-700 dark:bg-cyan-900/30 dark:text-cyan-300"}},Mb={default:"bg-gray-500",primary:"bg-blue-600",success:"bg-green-600",warning:"bg-yellow-500",error:"bg-red-600",info:"bg-cyan-600"},Ib={sm:"h-5 text-xs px-2 gap-1",md:"h-6 text-sm px-2.5 gap-1.5",lg:"h-8 text-sm px-3 gap-2"},Sl={sm:"w-3 h-3",md:"w-3.5 h-3.5",lg:"w-4 h-4"},Ab={sm:"w-4 h-4 -ml-1",md:"w-5 h-5 -ml-1.5",lg:"w-6 h-6 -ml-1.5"},zb={sm:"w-1.5 h-1.5",md:"w-2 h-2",lg:"w-2.5 h-2.5"},Wb={none:"rounded-none",sm:"rounded-sm",md:"rounded-md",lg:"rounded-lg",full:"rounded-full"};function Gs({label:e,children:t,variant:r="solid",size:n="md",color:o="default",bgColor:a,textColor:s,borderColor:l,rounded:i="full",icon:c,endIcon:d,avatar:u,onClose:f,closable:m=false,clickable:p=false,selected:w=false,disabled:v=false,as:x="span",className:h,onClick:I,...S}){let L=x,R=g("inline-flex items-center justify-center font-medium transition-all",Ib[n],Wb[i],r==="outlined"&&"border"),T=g(a||s||l?g(a,s,l):Eb[o][r]),y=w?"ring-2 ring-offset-1 ring-blue-500":"",M=p&&!v?"cursor-pointer hover:opacity-80 active:scale-95":"",k=v?"opacity-50 cursor-not-allowed":"",z=B=>{B.stopPropagation(),f?.();},H=B=>{v||I?.(B);},P=t??e;return jsxRuntime.jsxs(L,{className:g(R,T,y,M,k,h),onClick:H,"aria-disabled":v,...S,children:[r==="dot"&&jsxRuntime.jsx("span",{className:g("rounded-full shrink-0",zb[n],Mb[o]),"aria-hidden":"true"}),u&&jsxRuntime.jsx("span",{className:g("rounded-full overflow-hidden shrink-0",Ab[n]),children:u}),c&&!u&&jsxRuntime.jsx("span",{className:g("shrink-0",Sl[n]),children:c}),P&&jsxRuntime.jsx("span",{className:"truncate",children:P}),d&&!m&&jsxRuntime.jsx("span",{className:g("shrink-0",Sl[n]),children:d}),m&&jsxRuntime.jsx("button",{type:"button",onClick:z,disabled:v,className:g("shrink-0 rounded-full hover:bg-black/10 dark:hover:bg-white/10 p-0.5 -mr-1 transition-colors","focus:outline-none focus-visible:ring-2 focus-visible:ring-offset-1 focus-visible:ring-current",v&&"pointer-events-none"),"aria-label":"Remove",children:jsxRuntime.jsx(Lb,{className:Sl[n]})})]})}Gs.displayName="Chip";var Ob=500,$b=800,_b=600;function Xb(e,t,r){let n=[`width=${e}`,`height=${t}`,"menubar=no","toolbar=no","location=no","status=no","scrollbars=yes","resizable=yes"];if(r.left!==void 0)n.push(`left=${r.left}`);else if(r.center!==false&&typeof window<"u"){let o=window.screenLeft??window.screenX,a=window.screenTop??window.screenY,s=window.outerWidth??screen.availWidth,l=window.outerHeight??screen.availHeight;n.push(`left=${o+(s-e)/2}`),n.push(`top=${a+(l-t)/2}`);}if(r.top!==void 0){let o=n.filter(a=>!a.startsWith("top="));return o.push(`top=${r.top}`),o.join(",")}return n.join(",")}function Gb(e,t){e.querySelectorAll("style").forEach(s=>{let l=t.createElement("style");l.textContent=s.textContent,t.head.appendChild(l);}),e.querySelectorAll('link[rel="stylesheet"]').forEach(s=>{let l=t.createElement("link");l.rel="stylesheet",l.href=s.href,s.crossOrigin&&(l.crossOrigin=s.crossOrigin),t.head.appendChild(l);});let o=e.documentElement.className;o&&(t.documentElement.className=o);let a=e.body.className;a&&(t.body.className=a);}function Kb(e,t){let r=new MutationObserver(n=>{for(let o of n)for(let a of Array.from(o.addedNodes))if(a instanceof HTMLStyleElement){let s=t.createElement("style");s.textContent=a.textContent,t.head.appendChild(s);}else if(a instanceof HTMLLinkElement&&a.rel==="stylesheet"){let s=t.createElement("link");s.rel="stylesheet",s.href=a.href,t.head.appendChild(s);}});return r.observe(e.head,{childList:true}),r}var Kd=el.forwardRef(function({children:t,detached:r,defaultDetached:n=false,onClose:o,onDetach:a,title:s="",width:l=$b,height:i=_b,left:c,top:d,center:u=true,copyStyles:f=true,closeOnParentUnmount:m=true,className:p,windowClassName:w,onPopupBlocked:v},x){let h=r!==void 0,[I,S]=el.useState(n),L=h?r:I,[R,T]=el.useState(null),y=el.useRef(null),M=el.useRef(null),k=el.useRef(null),z=el.useRef(false),H=el.useRef({width:l,height:i,left:c,top:d,center:u,shouldCopyStyles:f,title:s,windowClassName:w,closeOnParentUnmount:m});H.current={width:l,height:i,left:c,top:d,center:u,shouldCopyStyles:f,title:s,windowClassName:w,closeOnParentUnmount:m};let P=el.useCallback(()=>{M.current&&(clearInterval(M.current),M.current=null),k.current&&(k.current.disconnect(),k.current=null),T(null);},[]),B=el.useCallback(()=>{y.current&&!y.current.closed&&y.current.close(),y.current=null,P();},[P]),C=el.useCallback(()=>{if(typeof window>"u"||z.current||y.current&&!y.current.closed)return;z.current=true;let b=H.current,E=Xb(b.width,b.height,{center:b.center,left:b.left,top:b.top}),N=window.open("","",E);if(!N){z.current=false,v?.();return}y.current=N,N.document.title=b.title||document.title;let W=N.document.createElement("div");b.windowClassName&&(W.className=b.windowClassName),N.document.body.appendChild(W),T(W),b.shouldCopyStyles&&(Gb(document,N.document),k.current=Kb(document,N.document)),M.current=setInterval(()=>{N.closed&&(P(),y.current=null,h||S(false),o?.());},Ob),z.current=false,a?.();},[h,o,a,v,P]);return el.useEffect(()=>{L?C():B();},[L,C,B]),el.useEffect(()=>{y.current&&!y.current.closed&&s&&(y.current.document.title=s);},[s]),el.useEffect(()=>()=>{H.current.closeOnParentUnmount&&y.current&&!y.current.closed&&y.current.close(),P(),y.current=null;},[P]),el.useImperativeHandle(x,()=>({detach:()=>{h||S(true);},attach:()=>{h||S(false);},get isDetached(){return h?!!r:I},get window(){return y.current}}),[h,r,I]),L&&R?reactDom.createPortal(t,R):L?null:jsxRuntime.jsx("div",{className:g(p),children:t})});Kd.displayName="Detachable";var qb={phone:{sm:{w:180,h:320},md:{w:240,h:480},lg:{w:300,h:600}},android:{sm:{w:180,h:320},md:{w:240,h:480},lg:{w:300,h:600}},tablet:{sm:{w:320,h:420},md:{w:420,h:560},lg:{w:540,h:720}},laptop:{sm:{w:400,h:250},md:{w:560,h:350},lg:{w:720,h:450}},desktop:{sm:{w:400,h:300},md:{w:560,h:400},lg:{w:720,h:520}},watch:{sm:{w:80,h:96},md:{w:120,h:144},lg:{w:160,h:192}},browser:{sm:{w:400,h:280},md:{w:560,h:380},lg:{w:720,h:480}}},jb=({className:e})=>jsxRuntime.jsxs("svg",{className:g("w-3 h-3",e),viewBox:"0 0 16 16",fill:"currentColor",children:[jsxRuntime.jsx("rect",{x:"1",y:"11",width:"2.5",height:"4",rx:"0.5"}),jsxRuntime.jsx("rect",{x:"5",y:"8",width:"2.5",height:"7",rx:"0.5"}),jsxRuntime.jsx("rect",{x:"9",y:"5",width:"2.5",height:"10",rx:"0.5"}),jsxRuntime.jsx("rect",{x:"13",y:"1",width:"2.5",height:"14",rx:"0.5"})]}),Zb=({className:e})=>jsxRuntime.jsxs("svg",{className:g("w-3 h-3",e),viewBox:"0 0 20 20",fill:"currentColor",children:[jsxRuntime.jsx("path",{d:"M10 14.5a1.5 1.5 0 100 3 1.5 1.5 0 000-3z"}),jsxRuntime.jsx("path",{fillRule:"evenodd",d:"M6.05 11.95a5.5 5.5 0 017.9 0 .75.75 0 001.08-1.04 7 7 0 00-10.06 0 .75.75 0 001.08 1.04z",clipRule:"evenodd"}),jsxRuntime.jsx("path",{fillRule:"evenodd",d:"M2.81 8.72a10 10 0 0114.38 0 .75.75 0 001.06-1.06 11.5 11.5 0 00-16.5 0 .75.75 0 001.06 1.06z",clipRule:"evenodd"})]}),Qb=({className:e})=>jsxRuntime.jsxs("svg",{className:g("w-4 h-3",e),viewBox:"0 0 24 14",fill:"currentColor",children:[jsxRuntime.jsx("rect",{x:"0.5",y:"0.5",width:"20",height:"13",rx:"2",stroke:"currentColor",fill:"none",strokeWidth:"1"}),jsxRuntime.jsx("rect",{x:"22",y:"4",width:"2",height:"6",rx:"0.5"}),jsxRuntime.jsx("rect",{x:"2.5",y:"2.5",width:"14",height:"9",rx:"1"})]});function Ha({time:e="9:41",theme:t,device:r}){let n=r==="watch",o=t==="dark"?"text-white":"text-gray-900";return n?jsxRuntime.jsx("div",{className:g("flex items-center justify-center py-0.5",o),style:{fontSize:"8px"},children:jsxRuntime.jsx("span",{className:"font-medium",children:e})}):jsxRuntime.jsxs("div",{className:g("flex items-center justify-between px-4 py-1",t==="dark"?"bg-black/20":"bg-white/20",o),style:{fontSize:"10px"},"data-testid":"status-bar",children:[jsxRuntime.jsx("span",{className:"font-semibold",children:e}),jsxRuntime.jsxs("div",{className:"flex items-center gap-1",children:[jsxRuntime.jsx(jb,{className:o}),jsxRuntime.jsx(Zb,{className:o}),jsxRuntime.jsx(Qb,{className:o})]})]})}function Jb({theme:e}){let t=e==="dark";return jsxRuntime.jsxs("div",{className:g("flex items-center gap-2 px-3 py-2 border-b",t?"bg-gray-800 border-gray-700":"bg-gray-100 border-gray-200"),"data-testid":"browser-chrome",children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-1.5",children:[jsxRuntime.jsx("div",{className:"w-2.5 h-2.5 rounded-full bg-red-400"}),jsxRuntime.jsx("div",{className:"w-2.5 h-2.5 rounded-full bg-yellow-400"}),jsxRuntime.jsx("div",{className:"w-2.5 h-2.5 rounded-full bg-green-400"})]}),jsxRuntime.jsx("div",{className:g("flex-1 rounded-md px-3 py-1 text-center",t?"bg-gray-700 text-gray-400":"bg-white text-gray-500 border border-gray-200"),style:{fontSize:"11px"},children:jsxRuntime.jsxs("span",{className:"flex items-center justify-center gap-1",children:[jsxRuntime.jsx("svg",{className:"w-2.5 h-2.5",viewBox:"0 0 16 16",fill:"currentColor",children:jsxRuntime.jsx("path",{fillRule:"evenodd",d:"M8 1a4 4 0 00-4 4v3.5H3a1 1 0 00-1 1V14a1 1 0 001 1h10a1 1 0 001-1V9.5a1 1 0 00-1-1h-1V5a4 4 0 00-4-4zm2.5 7.5V5a2.5 2.5 0 00-5 0v3.5h5z",clipRule:"evenodd"})}),"example.com"]})})]})}function ey({children:e,theme:t,screenW:r,screenH:n,showStatusBar:o,statusBarTime:a,frameColor:s,landscape:l=false}){let i=t==="dark",c=s??(i?"#1a1a1a":"#e5e7eb");if(l){let u=Math.round(n*.35);return jsxRuntime.jsxs("div",{className:"relative inline-flex flex-row items-center rounded-[2.5rem] shadow-xl",style:{backgroundColor:c,padding:"8px 12px",height:n+16},"data-testid":"device-frame","data-device":"phone",children:[jsxRuntime.jsx("div",{className:g("rounded-full mr-2",i?"bg-gray-600":"bg-gray-400"),style:{width:4,height:Math.round(n*.35)},"data-testid":"home-indicator"}),jsxRuntime.jsxs("div",{className:"rounded-[2rem] overflow-hidden bg-black relative",style:{width:r,height:n},children:[o&&jsxRuntime.jsx(Ha,{time:a,theme:t,device:"phone"}),e]}),jsxRuntime.jsx("div",{className:"absolute rounded-full bg-black z-10",style:{width:20,height:u,right:10,top:"50%",transform:"translateY(-50%)"},"data-testid":"phone-notch"})]})}let d=Math.round(r*.35);return jsxRuntime.jsxs("div",{className:"relative inline-flex flex-col items-center rounded-[2.5rem] shadow-xl",style:{backgroundColor:c,padding:"12px 8px",width:r+16},"data-testid":"device-frame","data-device":"phone",children:[jsxRuntime.jsx("div",{className:"absolute top-[10px] rounded-full bg-black z-10",style:{width:d,height:20,left:"50%",transform:"translateX(-50%)"},"data-testid":"phone-notch"}),jsxRuntime.jsxs("div",{className:"rounded-[2rem] overflow-hidden bg-black relative",style:{width:r,height:n},children:[o&&jsxRuntime.jsx(Ha,{time:a,theme:t,device:"phone"}),e]}),jsxRuntime.jsx("div",{className:g("rounded-full mt-2",i?"bg-gray-600":"bg-gray-400"),style:{width:Math.round(r*.35),height:4},"data-testid":"home-indicator"})]})}function ty({children:e,theme:t,screenW:r,screenH:n,showStatusBar:o,statusBarTime:a,frameColor:s}){return jsxRuntime.jsxs("div",{className:"relative inline-flex flex-col items-center rounded-[2rem] shadow-xl",style:{backgroundColor:s??(t==="dark"?"#1a1a1a":"#e5e7eb"),padding:"10px 6px",width:r+12},"data-testid":"device-frame","data-device":"android",children:[jsxRuntime.jsx("div",{className:"absolute top-[6px] rounded-full bg-gray-800 z-10 border border-gray-700",style:{width:8,height:8,left:"50%",transform:"translateX(-50%)"},"data-testid":"camera-dot"}),jsxRuntime.jsxs("div",{className:"rounded-[1.5rem] overflow-hidden bg-black relative",style:{width:r,height:n},children:[o&&jsxRuntime.jsx(Ha,{time:a,theme:t,device:"android"}),e]})]})}function ry({children:e,theme:t,screenW:r,screenH:n,showStatusBar:o,statusBarTime:a,frameColor:s}){return jsxRuntime.jsxs("div",{className:"relative inline-flex flex-col items-center rounded-[1.5rem] shadow-xl",style:{backgroundColor:s??(t==="dark"?"#1a1a1a":"#e5e7eb"),padding:"16px 12px",width:r+24},"data-testid":"device-frame","data-device":"tablet",children:[jsxRuntime.jsx("div",{className:"absolute top-[8px] rounded-full bg-gray-700 z-10",style:{width:6,height:6,left:"50%",transform:"translateX(-50%)"}}),jsxRuntime.jsxs("div",{className:"rounded-lg overflow-hidden bg-black relative",style:{width:r,height:n},children:[o&&jsxRuntime.jsx(Ha,{time:a,theme:t,device:"tablet"}),e]})]})}function ny({children:e,theme:t,screenW:r,screenH:n,frameColor:o}){let a=t==="dark",s=o??(a?"#1a1a1a":"#d1d5db"),l=r+60;return jsxRuntime.jsxs("div",{className:"inline-flex flex-col items-center","data-testid":"device-frame","data-device":"laptop",children:[jsxRuntime.jsxs("div",{className:"rounded-t-xl shadow-xl relative",style:{backgroundColor:s,padding:"8px 8px 0",width:r+16},children:[jsxRuntime.jsx("div",{className:"absolute top-[3px] rounded-full bg-gray-700 z-10",style:{width:4,height:4,left:"50%",transform:"translateX(-50%)"}}),jsxRuntime.jsx("div",{className:"rounded-t-sm overflow-hidden bg-black",style:{width:r,height:n},children:e})]}),jsxRuntime.jsx("div",{className:g(a?"bg-gray-800":"bg-gray-400"),style:{width:r+16,height:3}}),jsxRuntime.jsx("div",{className:"rounded-b-xl shadow-lg",style:{backgroundColor:s,width:l,height:12,clipPath:"polygon(3% 0%, 97% 0%, 100% 100%, 0% 100%)"},"data-testid":"laptop-base"})]})}function oy({children:e,theme:t,screenW:r,screenH:n,frameColor:o}){let a=t==="dark";return jsxRuntime.jsxs("div",{className:"inline-flex flex-col items-center","data-testid":"device-frame","data-device":"desktop",children:[jsxRuntime.jsx("div",{className:"rounded-lg shadow-xl",style:{backgroundColor:o??(a?"#1a1a1a":"#d1d5db"),padding:"8px 8px 20px",width:r+16},children:jsxRuntime.jsx("div",{className:"rounded-sm overflow-hidden bg-black",style:{width:r,height:n},children:e})}),jsxRuntime.jsx("div",{className:g(a?"bg-gray-800":"bg-gray-400"),style:{width:40,height:24},"data-testid":"monitor-stand"}),jsxRuntime.jsx("div",{className:g("rounded-t-sm",a?"bg-gray-800":"bg-gray-400"),style:{width:Math.round(r*.4),height:6,borderRadius:"2px 2px 4px 4px"}})]})}function ay({children:e,theme:t,screenW:r,screenH:n,showStatusBar:o,statusBarTime:a,frameColor:s}){let l=t==="dark",i=s??(l?"#1a1a1a":"#d1d5db"),c=Math.round(r*.7);return jsxRuntime.jsxs("div",{className:"inline-flex flex-col items-center","data-testid":"device-frame","data-device":"watch",children:[jsxRuntime.jsx("div",{className:g("rounded-t-lg",l?"bg-gray-800":"bg-gray-400"),style:{width:c,height:30},"data-testid":"watch-band"}),jsxRuntime.jsxs("div",{className:"relative rounded-[1.2rem] shadow-xl",style:{backgroundColor:i,padding:"8px 6px",width:r+12},children:[jsxRuntime.jsx("div",{className:g("absolute rounded-sm",l?"bg-gray-600":"bg-gray-400"),style:{width:4,height:16,right:-4,top:"30%"},"data-testid":"watch-crown"}),jsxRuntime.jsxs("div",{className:"rounded-xl overflow-hidden bg-black",style:{width:r,height:n},children:[o&&jsxRuntime.jsx(Ha,{time:a,theme:t,device:"watch"}),e]})]}),jsxRuntime.jsx("div",{className:g("rounded-b-lg",l?"bg-gray-800":"bg-gray-400"),style:{width:c,height:30}})]})}function sy({children:e,theme:t,screenW:r,screenH:n,frameColor:o}){return jsxRuntime.jsxs("div",{className:"inline-flex flex-col rounded-lg shadow-xl overflow-hidden",style:{backgroundColor:o??(t==="dark"?"#1f2937":"#f3f4f6"),width:r},"data-testid":"device-frame","data-device":"browser",children:[jsxRuntime.jsx(Jb,{theme:t}),jsxRuntime.jsx("div",{className:"overflow-hidden bg-white",style:{width:r,height:n},children:e})]})}function iy({device:e="phone",src:t,alt:r="Device screen content",children:n,orientation:o="portrait",theme:a="dark",size:s="md",showStatusBar:l=false,statusBarTime:i,animated:c=false,scrollSpeed:d=30,frameColor:u,className:f,contentClassName:m}){let p=el.useRef(null),w=el.useRef(null),v=qb[e][s],x=o==="landscape"&&e!=="watch"&&e!=="browser",h=x?v.h:v.w,I=x?v.w:v.h;el.useEffect(()=>{if(!c||!p.current)return;let T=p.current,y=null,M=k=>{y===null&&(y=k);let z=(k-y)/1e3;y=k,T.scrollTop+=d*z,T.scrollTop>=T.scrollHeight-T.clientHeight&&(T.scrollTop=0),w.current=requestAnimationFrame(M);};return w.current=requestAnimationFrame(M),()=>{w.current!==null&&cancelAnimationFrame(w.current);}},[c,d]);let S=jsxRuntime.jsx("div",{ref:c?p:void 0,className:g("w-full h-full overflow-hidden",c&&"overflow-y-auto scrollbar-hide",m),style:c?{scrollBehavior:"auto"}:void 0,children:t?jsxRuntime.jsx("img",{src:t,alt:r,className:"w-full h-auto object-cover",draggable:false}):n}),L={showStatusBar:l,statusBarTime:i},R=()=>{switch(e){case "phone":return jsxRuntime.jsx(ey,{theme:a,screenW:h,screenH:I,frameColor:u,landscape:x,...L,children:S});case "android":return jsxRuntime.jsx(ty,{theme:a,screenW:h,screenH:I,frameColor:u,...L,children:S});case "tablet":return jsxRuntime.jsx(ry,{theme:a,screenW:h,screenH:I,frameColor:u,...L,children:S});case "laptop":return jsxRuntime.jsx(ny,{theme:a,screenW:h,screenH:I,frameColor:u,children:S});case "desktop":return jsxRuntime.jsx(oy,{theme:a,screenW:h,screenH:I,frameColor:u,children:S});case "watch":return jsxRuntime.jsx(ay,{theme:a,screenW:h,screenH:I,frameColor:u,...L,children:S});case "browser":return jsxRuntime.jsx(sy,{theme:a,screenW:h,screenH:I,frameColor:u,children:S})}};return jsxRuntime.jsx("div",{className:g("inline-flex",f),"data-testid":"device-mockup","data-orientation":o,"data-theme":a,"data-size":s,children:R()})}var Ks={solid:"border-solid",dashed:"border-dashed",dotted:"border-dotted"},ly={left:{before:"flex-[0.1]",after:"flex-1"},center:{before:"flex-1",after:"flex-1"},right:{before:"flex-1",after:"flex-[0.1]"}};function Yd({orientation:e="horizontal",variant:t="solid",label:r,textAlign:n="center",thickness:o=1,color:a="border-gray-300 dark:border-gray-700",spacing:s,className:l,...i}){if(e==="vertical")return jsxRuntime.jsx("hr",{"aria-orientation":"vertical",className:g("h-full border-l-0 border-r",Ks[t],a,s||"mx-2",l),style:{borderRightWidth:`${o}px`},...i});if(r){let c=ly[n];return jsxRuntime.jsxs("div",{role:"separator","aria-orientation":"horizontal",className:g("flex items-center text-sm text-gray-500 dark:text-gray-400",s||"my-4",l),...i,children:[jsxRuntime.jsx("div",{className:g("border-t",Ks[t],a,c.before),style:{borderTopWidth:`${o}px`}}),jsxRuntime.jsx("span",{className:"px-3 whitespace-nowrap",children:r}),jsxRuntime.jsx("div",{className:g("border-t",Ks[t],a,c.after),style:{borderTopWidth:`${o}px`}})]})}return jsxRuntime.jsx("hr",{"aria-orientation":"horizontal",className:g("border-t-0 border-b",Ks[t],a,s||"my-4",l),style:{borderBottomWidth:`${o}px`},...i})}Yd.displayName="Divider";var On=[];function qd(e){let t=On.indexOf(e);t!==-1&&On.splice(t,1),On.push(e);}function jd(e){let t=On.indexOf(e);t!==-1&&On.splice(t,1);}function Zd(e){return On.length>0&&On[On.length-1]===e}var Va=0,Pl=null;function Qd(e=document){let t=e.body;if(!t)return ()=>{};Va===0&&(Pl=t.style.overflow,t.style.overflow="hidden"),Va+=1;let r=false;return ()=>{r||(r=true,Va=Math.max(0,Va-1),Va===0&&(t.style.overflow=Pl??"",Pl=null));}}var Jd=["a[href]","area[href]","button","input","select","textarea","details > summary:first-of-type","iframe","object","embed","audio[controls]","video[controls]",'[contenteditable]:not([contenteditable="false"])',"[tabindex]"].join(",");function dy(e){let t=e.ownerDocument?.defaultView;if(!t)return null;try{return t.getComputedStyle(e)}catch{return null}}function eu(e){let t=e;for(;t;){if(t.hasAttribute("hidden")||t.hasAttribute("inert")||t.getAttribute("aria-hidden")==="true")return false;let r=dy(t);if(r&&(r.display==="none"||r.visibility==="hidden"||r.visibility==="collapse"))return false;t=t.parentElement;}return true}function tu(e){if(e.hasAttribute("disabled")||e.getAttribute("tabindex")==="-1")return false;let t=e.closest("fieldset[disabled]");if(t){let r=t.querySelector("legend");if(!r||!r.contains(e))return false}return eu(e)}function Us(e){return Array.from(e.querySelectorAll(Jd)).filter(tu).sort((r,n)=>{let o=r.compareDocumentPosition(n);return o&Node.DOCUMENT_POSITION_FOLLOWING?-1:o&Node.DOCUMENT_POSITION_PRECEDING?1:0})}var uy={role:"dialog","aria-modal":true,tabIndex:-1};function my(e,t){return t==="none"?null:t&&typeof t=="object"?t.current??e:t==="first"?Us(e)[0]??e:e}function gy(e){return e?e.map(t=>t&&"current"in t?t.current:t).filter(t=>!!t):[]}function Yo(e){if(e)try{e.focus();}catch{}}function fo(e){let{open:t}=e,r=el.useRef(null),n=el.useRef(e);return n.current=e,el.useEffect(()=>{if(!t)return;let o=r.current;if(!o)return;let a=o.ownerDocument,s=a.activeElement,{hideBackground:l,lockScroll:i,initialFocus:c,keepInteractive:d}=n.current;qd(o);let u=l===false?void 0:ml([o,...gy(d)]),f=i===false?void 0:Qd(a);return Yo(my(o,c)),()=>{u?.(),f?.(),jd(o);let{returnFocus:m}=n.current;if(m===false)return;let p=a.activeElement;if(!(!p||p===a.body||o.contains(p)))return;let v=m&&typeof m=="object"?m.current:s;v&&a.contains(v)&&Yo(v);}},[t]),el.useEffect(()=>{if(!t)return;let o=r.current;if(!o)return;let a=o.ownerDocument,s=a.defaultView??a,l=c=>c?o.contains(c)?true:Ls([o]).some(d=>d.contains(c)):false,i=c=>{if(c.defaultPrevented||!Zd(o))return;let{closeOnEscape:d,trapFocus:u,onClose:f}=n.current;if(c.key==="Escape"){if(d===false)return;c.preventDefault(),f?.();return}if(c.key!=="Tab"||u===false)return;let m=a.activeElement;if(m&&!o.contains(m)&&l(m))return;let p=Us(o);if(p.length===0){c.preventDefault(),Yo(o);return}let w=p[0],v=p[p.length-1];if(!m||!o.contains(m)){c.preventDefault(),Yo(c.shiftKey?v:w);return}if(c.shiftKey&&(m===w||m===o)){c.preventDefault(),Yo(v);return}!c.shiftKey&&m===v&&(c.preventDefault(),Yo(w));};return s.addEventListener("keydown",i),()=>s.removeEventListener("keydown",i)},[t]),{dialogRef:r,dialogProps:uy}}var yy={left:{sm:"w-64",md:"w-80",lg:"w-96",xl:"w-[32rem]",full:"w-full",half:"w-1/2 h-full"},right:{sm:"w-64",md:"w-80",lg:"w-96",xl:"w-[32rem]",full:"w-full",half:"w-1/2 h-full"},top:{sm:"h-64",md:"h-80",lg:"h-96",xl:"h-[32rem]",full:"h-full",half:"w-1/2 h-full"},bottom:{sm:"h-64",md:"h-80",lg:"h-96",xl:"h-[32rem]",full:"h-full",half:"w-1/2 h-full"}},xy={left:"left-0 top-0 bottom-0",right:"right-0 top-0 bottom-0",top:"top-0 left-0 right-0",bottom:"bottom-0 left-0 right-0"},ou={left:{enter:"animate-in slide-in-from-left duration-300",exit:"animate-out slide-out-to-left duration-200"},right:{enter:"animate-in slide-in-from-right duration-300",exit:"animate-out slide-out-to-right duration-200"},top:{enter:"animate-in slide-in-from-top duration-300",exit:"animate-out slide-out-to-top duration-200"},bottom:{enter:"animate-in slide-in-from-bottom duration-300",exit:"animate-out slide-out-to-bottom duration-200"}},vy=jsxRuntime.jsx("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:jsxRuntime.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})});function au({open:e,onClose:t,children:r,position:n="right",size:o="md",customWidth:a,customHeight:s,showOverlay:l=true,closeOnOverlayClick:i=true,closeOnEscape:c=true,title:d,footer:u,className:f,overlayClassName:m,closeLabel:p,"aria-label":w,trapFocus:v=true,initialFocus:x,returnFocus:h,lockScroll:I=true}){let S=!!(a||s),L=el.useRef(null),R=We(),y=`${el.useId()}-drawer-title`,{dialogRef:M,dialogProps:k}=fo({open:e,onClose:t,closeOnEscape:c,trapFocus:v,initialFocus:x,returnFocus:h,lockScroll:I,keepInteractive:[L]}),z=el.useCallback(()=>{i&&t();},[i,t]);if(!e)return null;let H=jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[l&&jsxRuntime.jsx("div",{ref:L,className:g("fixed inset-0 bg-black/50 z-40 transition-opacity",e?"animate-in fade-in duration-200":"animate-out fade-out duration-150",m),onClick:z,"aria-hidden":"true"}),jsxRuntime.jsxs("div",{ref:M,...k,"aria-labelledby":d?y:void 0,"aria-label":d?void 0:w,className:g("fixed z-50 bg-white dark:bg-gray-900","shadow-xl overflow-hidden","flex flex-col focus:outline-none",xy[n],!S&&yy[n][o],e?ou[n].enter:ou[n].exit,f),style:{...a?{width:a}:{},...s?{height:s}:{}},children:[d&&jsxRuntime.jsxs("div",{className:"flex items-center justify-between px-6 py-4 border-b border-gray-200 dark:border-gray-700",children:[jsxRuntime.jsx("h2",{id:y,className:"text-lg font-semibold text-gray-900 dark:text-white",children:d}),jsxRuntime.jsx("button",{type:"button",onClick:t,className:g("rounded-lg p-1.5 text-gray-400 hover:bg-gray-100 hover:text-gray-900","dark:hover:bg-gray-800 dark:hover:text-white","focus:outline-none focus:ring-2 focus:ring-gray-300 dark:focus:ring-gray-600"),"aria-label":p??R.closeDrawer,children:vy})]}),jsxRuntime.jsx("div",{className:"flex-1 overflow-y-auto px-6 py-4",children:r}),u&&jsxRuntime.jsx("div",{className:"px-6 py-4 border-t border-gray-200 dark:border-gray-700",children:u})]})]});return typeof document<"u"?reactDom.createPortal(H,document.body):H}au.displayName="Drawer";var Ny={sm:{dropzone:"py-4 px-3",text:"text-xs",subtext:"text-[10px]",icon:"w-6 h-6",button:"px-2.5 py-1.5 text-xs",fileItem:"py-1 px-2 text-xs",gap:"gap-1"},md:{dropzone:"py-6 px-4",text:"text-sm",subtext:"text-xs",icon:"w-8 h-8",button:"px-3 py-2 text-sm",fileItem:"py-1.5 px-3 text-sm",gap:"gap-1.5"},lg:{dropzone:"py-8 px-6",text:"text-base",subtext:"text-sm",icon:"w-10 h-10",button:"px-4 py-2.5 text-base",fileItem:"py-2 px-4 text-base",gap:"gap-2"}},cu=e=>{if(e===0)return "0 B";let t=["B","KB","MB","GB"],r=Math.floor(Math.log(e)/Math.log(1024));return `${(e/Math.pow(1024,r)).toFixed(r===0?0:1)} ${t[r]}`},Ll=e=>e.webkitRelativePath||e.name,Sy=jsxRuntime.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",strokeWidth:1.5,stroke:"currentColor",className:"w-full h-full",children:jsxRuntime.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M3 16.5v2.25A2.25 2.25 0 005.25 21h13.5A2.25 2.25 0 0021 18.75V16.5m-13.5-9L12 3m0 0l4.5 4.5M12 3v13.5"})}),Ry=jsxRuntime.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",strokeWidth:1.5,stroke:"currentColor",className:"w-full h-full",children:jsxRuntime.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M3.75 9.776c.112-.017.227-.026.344-.026h15.812c.117 0 .232.009.344.026m-16.5 0a2.25 2.25 0 00-1.883 2.542l.857 6a2.25 2.25 0 002.227 1.932H19.05a2.25 2.25 0 002.227-1.932l.857-6a2.25 2.25 0 00-1.883-2.542m-16.5 0V6A2.25 2.25 0 016 3.75h3.879a1.5 1.5 0 011.06.44l2.122 2.12a1.5 1.5 0 001.06.44H18A2.25 2.25 0 0120.25 9v.776"})}),Ty=0;async function Py(e){let t=[],r=async n=>{if(n.isFile){let o=await new Promise((a,s)=>n.file(a,s));t.push(o);}else if(n.isDirectory){let o=n.createReader(),a=()=>new Promise((l,i)=>o.readEntries(l,i)),s=await a();for(;s.length>0;){for(let l of s)await r(l);s=await a();}}};for(let n of e)await r(n);return t}function Dy({value:e,onChange:t,accept:r,multiple:n=false,maxSize:o=10*1024*1024,maxFiles:a,mode:s="file",variant:l="dropzone",size:i="md",disabled:c=false,readOnly:d=false,label:u,helperText:f,error:m,showFileList:p=true,placeholder:w,browseLabel:v,browseFolderLabel:x,icon:h,onReject:I,className:S}){let[L,R]=el.useState([]),[T,y]=el.useState(false),M=el.useRef(null),k=el.useRef(null),z=el.useId(),H=e!==void 0,P=H?e.map((U,Q)=>({file:U,id:`ctrl-${Q}`})):L,B=Ny[i];el.useEffect(()=>{s==="directory"&&M.current&&M.current.setAttribute("webkitdirectory",""),s==="both"&&k.current&&k.current.setAttribute("webkitdirectory","");},[s]);let C=el.useMemo(()=>cu(o),[o]),b=el.useMemo(()=>r?r.split(",").map(U=>U.trim()).map(U=>U.startsWith(".")?U.toUpperCase():U.endsWith("/*")?U.replace("/*","").toUpperCase():U).join(", "):"All files",[r]),E=s==="directory"?"Drag & drop a folder here, or":s==="both"?"Drag & drop files or folders here, or":n?"Drag & drop files here, or":"Drag & drop a file here, or",N=s==="directory"?"Browse folder":"Browse",W="Browse folder",F=el.useCallback(U=>{if(U.size>o)return `File exceeds maximum size of ${C}`;if(r){let Q=r.split(",").map(te=>te.trim()),le=`.${U.name.split(".").pop()?.toLowerCase()}`;if(!Q.some(te=>te.startsWith(".")?le===te.toLowerCase():te.endsWith("/*")?U.type.startsWith(te.replace("/*","/")):U.type===te))return `File type not accepted. Expected: ${b}`}return null},[r,b,o,C]),K=el.useCallback(U=>{if(c||d)return;let Q=Array.from(U),le=[];for(let ye of Q){let te=F(ye);te?I?.(ye,te):le.push(ye);}if(le.length!==0)if(H)if(n){let te=[...e??[],...le],Ce=a?te.slice(0,a):te;t?.(Ce);}else t?.([le[0]]);else R(ye=>{let te=le.map(Ce=>({file:Ce,id:`file-${++Ty}`}));if(n){let Ce=[...ye,...te],Pe=a?Ce.slice(0,a):Ce,Se=Pe.map(De=>De.file);return t?.(Se),Pe}return t?.([le[0]]),[te[0]]});},[c,d,H,n,a,e,t,I,F]),j=el.useCallback(U=>{if(!(c||d)){if(H){let Q=(e??[]).filter((le,ye)=>ye!==U);t?.(Q);}else R(Q=>{let le=Q.filter((ye,te)=>te!==U);return t?.(le.map(ye=>ye.file)),le});M.current&&(M.current.value="");}},[c,d,H,e,t]),A=el.useCallback(()=>{c||d||(H?t?.([]):(R([]),t?.([])),M.current&&(M.current.value=""));},[c,d,H,t]),D=el.useCallback(U=>{U.target.files&&U.target.files.length>0&&K(U.target.files);},[K]),V=el.useCallback(U=>{U.preventDefault(),U.stopPropagation(),!c&&!d&&y(true);},[c,d]),O=el.useCallback(U=>{U.preventDefault(),U.stopPropagation(),y(false);},[]),_=el.useCallback(U=>{if(U.preventDefault(),U.stopPropagation(),y(false),c||d)return;let Q=U.dataTransfer.items;if(Q&&Q.length>0&&(s==="directory"||s==="both")){let le=[];for(let te=0;te<Q.length;te++){let Ce=Q[te].webkitGetAsEntry?.();Ce&&le.push(Ce);}if(le.some(te=>te.isDirectory)){Py(le).then(te=>{te.length>0&&K(te);});return}}U.dataTransfer.files&&U.dataTransfer.files.length>0&&K(U.dataTransfer.files);},[c,d,s,K]),X=el.useCallback(()=>{!c&&!d&&M.current?.click();},[c,d]),G=el.useCallback(()=>{!c&&!d&&k.current?.click();},[c,d]),$=P.length>0,Y=h||(s==="directory"?Ry:Sy),se=p&&$&&jsxRuntime.jsxs("div",{className:g("flex flex-col",B.gap),children:[P.map((U,Q)=>jsxRuntime.jsxs("div",{className:g("flex items-center justify-between rounded-md border border-gray-200 dark:border-gray-700 bg-gray-50 dark:bg-gray-800/50",B.fileItem),children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-2 min-w-0 flex-1",children:[jsxRuntime.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",strokeWidth:1.5,stroke:"currentColor",className:"w-4 h-4 shrink-0 text-gray-400 dark:text-gray-500",children:jsxRuntime.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M19.5 14.25v-2.625a3.375 3.375 0 00-3.375-3.375h-1.5A1.125 1.125 0 0113.5 7.125v-1.5a3.375 3.375 0 00-3.375-3.375H8.25m2.25 0H5.625c-.621 0-1.125.504-1.125 1.125v17.25c0 .621.504 1.125 1.125 1.125h12.75c.621 0 1.125-.504 1.125-1.125V11.25a9 9 0 00-9-9z"})}),jsxRuntime.jsx("span",{className:"truncate text-gray-700 dark:text-gray-300",children:Ll(U.file)}),jsxRuntime.jsxs("span",{className:"shrink-0 text-gray-400 dark:text-gray-500",children:["(",cu(U.file.size),")"]})]}),!c&&!d&&jsxRuntime.jsx("button",{type:"button",onClick:()=>j(Q),className:"shrink-0 ml-2 text-gray-400 hover:text-red-500 dark:text-gray-500 dark:hover:text-red-400 transition-colors cursor-pointer","aria-label":`Remove ${Ll(U.file)}`,children:jsxRuntime.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",strokeWidth:1.5,stroke:"currentColor",className:"w-4 h-4",children:jsxRuntime.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M6 18L18 6M6 6l12 12"})})})]},U.id)),n&&P.length>1&&!c&&!d&&jsxRuntime.jsx("button",{type:"button",onClick:A,className:g("self-start text-gray-400 hover:text-red-500 dark:text-gray-500 dark:hover:text-red-400 transition-colors cursor-pointer",B.subtext),children:"Remove all"})]}),ae=g("rounded-md border border-gray-300 dark:border-gray-600 bg-white dark:bg-gray-800 text-gray-700 dark:text-gray-200 font-medium transition-colors","hover:bg-gray-50 dark:hover:bg-gray-700","disabled:opacity-50 disabled:cursor-not-allowed cursor-pointer","focus:outline-none focus:ring-2 focus:ring-blue-500 focus:ring-offset-1",B.button,m&&"border-red-300 dark:border-red-600");return jsxRuntime.jsxs("div",{className:g("flex flex-col",B.gap,S),children:[u&&jsxRuntime.jsx("label",{htmlFor:z,className:g("block font-medium text-gray-700 dark:text-gray-300",B.text),children:u}),jsxRuntime.jsx("input",{ref:M,id:z,type:"file",accept:s!=="directory"?r:void 0,multiple:n,onChange:D,className:"sr-only",disabled:c||d,"aria-describedby":m?`${z}-error`:f?`${z}-helper`:void 0,"aria-invalid":!!m}),s==="both"&&jsxRuntime.jsx("input",{ref:k,type:"file",onChange:D,className:"sr-only",disabled:c||d,tabIndex:-1,"aria-hidden":"true"}),l==="dropzone"?jsxRuntime.jsxs("div",{role:s==="both"?"group":"button",tabIndex:s==="both"?void 0:c||d?-1:0,onClick:s==="both"?void 0:X,onKeyDown:s==="both"?void 0:U=>{(U.key==="Enter"||U.key===" ")&&(U.preventDefault(),X());},onDragOver:V,onDragLeave:O,onDrop:_,className:g("flex flex-col items-center justify-center rounded-lg border-2 border-dashed transition-colors",B.dropzone,T&&!c&&!d?"border-blue-500 bg-blue-50 dark:bg-blue-900/20":"border-gray-300 dark:border-gray-600 bg-white dark:bg-gray-800",!c&&!d&&"hover:border-blue-400 dark:hover:border-blue-500 hover:bg-gray-50 dark:hover:bg-gray-800/70",s!=="both"&&!c&&!d&&"cursor-pointer",c&&"opacity-50 cursor-not-allowed",d&&"cursor-default",m&&"border-red-300 dark:border-red-600"),"aria-label":s==="both"?"File and folder drop zone":w||E,children:[jsxRuntime.jsx("div",{className:g("text-gray-400 dark:text-gray-500 mb-2",B.icon,T&&"text-blue-500 dark:text-blue-400"),children:Y}),jsxRuntime.jsxs("p",{className:g("text-gray-600 dark:text-gray-400",B.text),children:[w||E," ",!c&&!d&&s!=="both"&&jsxRuntime.jsx("span",{className:"text-blue-600 dark:text-blue-400 font-medium",children:v||N})]}),s==="both"&&!c&&!d&&jsxRuntime.jsxs("div",{className:g("flex items-center gap-3 mt-1",B.text),children:[jsxRuntime.jsx("button",{type:"button",onClick:X,className:"text-blue-600 dark:text-blue-400 font-medium hover:underline cursor-pointer focus:outline-none focus:ring-2 focus:ring-blue-500 focus:ring-offset-1 rounded",children:v||"Browse files"}),jsxRuntime.jsx("span",{className:"text-gray-300 dark:text-gray-600",children:"\xB7"}),jsxRuntime.jsx("button",{type:"button",onClick:G,className:"text-blue-600 dark:text-blue-400 font-medium hover:underline cursor-pointer focus:outline-none focus:ring-2 focus:ring-blue-500 focus:ring-offset-1 rounded",children:x||W})]}),jsxRuntime.jsxs("p",{className:g("text-gray-400 dark:text-gray-500 mt-1",B.subtext),children:[b," - Max ",C,n&&a&&` - Up to ${a} files`]})]}):jsxRuntime.jsxs("div",{className:"flex items-center gap-2",children:[s==="both"?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("button",{type:"button",onClick:X,disabled:c||d,className:ae,children:v||($?"Change files":"Choose files")}),jsxRuntime.jsx("button",{type:"button",onClick:G,disabled:c||d,className:ae,children:x||"Choose folder"})]}):jsxRuntime.jsx("button",{type:"button",onClick:X,disabled:c||d,className:ae,children:v||(s==="directory"?$?"Change folder":"Choose folder":$?"Change file":"Choose file")}),!$&&jsxRuntime.jsx("span",{className:g("text-gray-400 dark:text-gray-500",B.text),children:s==="directory"?"No folder selected":s==="both"?"No file or folder selected":"No file selected"}),$&&!p&&jsxRuntime.jsx("span",{className:g("text-gray-600 dark:text-gray-400 truncate",B.text),children:P.length===1?Ll(P[0].file):`${P.length} files selected`})]}),se,m&&jsxRuntime.jsx("p",{id:`${z}-error`,className:g("text-red-600 dark:text-red-400",B.subtext),role:"alert",children:m}),f&&!m&&jsxRuntime.jsx("p",{id:`${z}-helper`,className:g("text-gray-400 dark:text-gray-500",B.subtext),children:f})]})}var mu=el.createContext(null);function Sr(){let e=el.useContext(mu);if(!e)throw new Error("Dropdown compound components must be used within a Dropdown");return e}function gu({open:e,defaultOpen:t=false,onOpenChange:r,closeOnSelect:n=true,closeOnClickOutside:o=true,closeOnEscape:a=true,modal:s=false,children:l}){let[i,c]=el.useState(t),d=e!==void 0,u=d?e:i,f=el.useRef(null),m=el.useRef(null),p=el.useRef([]),[w,v]=el.useState(-1),x=el.useRef(0),h=el.useId(),I={triggerId:`dropdown-trigger-${h}`,contentId:`dropdown-content-${h}`},S=el.useCallback(y=>{d||c(y),r?.(y),y||v(-1);},[d,r]),L=el.useCallback((y,M)=>{p.current&&(p.current[y]=M);},[]),R=el.useCallback(()=>x.current++,[]),T={isOpen:u,setIsOpen:S,triggerRef:f,contentRef:m,closeOnSelect:n,closeOnClickOutside:o,closeOnEscape:a,modal:s,focusedIndex:w,setFocusedIndex:v,itemsRef:p,registerItem:L,getNextItemIndex:R,triggerId:I.triggerId,contentId:I.contentId};return jsxRuntime.jsx(mu.Provider,{value:T,children:jsxRuntime.jsx("div",{className:"relative inline-block",children:l})})}gu.displayName="Dropdown";var pu=el.memo(({isOpen:e})=>jsxRuntime.jsx("span",{className:g("inline-block transition-transform",e&&"rotate-180"),children:jsxRuntime.jsx("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24","aria-hidden":"true",children:jsxRuntime.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 9l-7 7-7-7"})})}));pu.displayName="ChevronIcon";function fu({asChild:e=false,disabled:t=false,children:r,className:n}){let{isOpen:o,setIsOpen:a,triggerRef:s,triggerId:l,contentId:i}=Sr(),u={ref:s,id:l,"aria-haspopup":"menu","aria-expanded":o,"aria-controls":o?i:void 0,disabled:t,onClick:()=>{t||a(!o);},onKeyDown:f=>{t||((f.key==="Enter"||f.key===" ")&&(f.preventDefault(),a(!o)),f.key==="ArrowDown"&&!o&&(f.preventDefault(),a(true)));}};return e&&el.isValidElement(r)?el.cloneElement(r,{...u,className:g(r.props.className,n)}):jsxRuntime.jsxs("button",{type:"button",...u,className:g("inline-flex items-center justify-center gap-2","rounded-md px-4 py-2","bg-white border border-gray-300","text-sm font-medium text-gray-700","hover:bg-gray-50","focus:outline-none focus-visible:ring-2 focus-visible:ring-blue-500 focus-visible:ring-offset-2","disabled:opacity-50 disabled:cursor-not-allowed","transition-colors",n),children:[r,jsxRuntime.jsx(pu,{isOpen:o})]})}fu.displayName="DropdownTrigger";function qo(e){let t=el.useRef(e);return el.useLayoutEffect(()=>{t.current=e;}),t}function jo(e,t,r=true){let n=qo(t);el.useEffect(()=>{if(!r)return;let o=a=>{let s=a.target;!e.current||e.current.contains(s)||n.current();};return document.addEventListener("mousedown",o),document.addEventListener("touchstart",o,{passive:true}),()=>{document.removeEventListener("mousedown",o),document.removeEventListener("touchstart",o);}},[r,n,e]);}function js({isOpen:e,onClose:t,itemsCount:r,focusedIndex:n,setFocusedIndex:o,onSelect:a,loop:s=true}){let l=qo(t),i=qo(a),c=qo(n),d=el.useCallback(u=>{if(!(!e||r===0))switch(u.key){case "ArrowDown":u.preventDefault(),o(s?f=>f<r-1?f+1:0:f=>Math.min(f+1,r-1));break;case "ArrowUp":u.preventDefault(),o(s?f=>f>0?f-1:r-1:f=>Math.max(f-1,0));break;case "Home":u.preventDefault(),o(0);break;case "End":u.preventDefault(),o(r-1);break;case "Enter":case " ":u.preventDefault(),i.current?.(c.current);break;case "Escape":u.preventDefault(),l.current();break;case "Tab":l.current();break}},[e,r,o,s,l,i,c]);return el.useEffect(()=>{if(e)return document.addEventListener("keydown",d),()=>document.removeEventListener("keydown",d)},[e,d]),{focusedIndex:n}}function bu(e,t,r){el.useEffect(()=>{r&&e.current&&e.current[t]&&e.current[t]?.focus();},[t,r,e]);}var Ky={fade:"animate-in fade-in-0 duration-200",scale:"animate-in fade-in-0 zoom-in-95 duration-200",slide:"animate-in fade-in-0 slide-in-from-top-2 duration-200",none:""};function xu({side:e="bottom",align:t="start",sideOffset:r=4,alignOffset:n=0,avoidCollisions:o=true,collisionPadding:a=8,minWidth:s,maxWidth:l,maxHeight:i=300,animation:c="scale",portal:d=true,children:u,className:f}){let{isOpen:m,setIsOpen:p,triggerRef:w,contentRef:v,closeOnClickOutside:x,closeOnEscape:h,modal:I,contentId:S,focusedIndex:L,setFocusedIndex:R,itemsRef:T}=Sr(),[y,M]=el.useState(false),k=Bn({triggerRef:w,contentRef:v,isOpen:m,side:e,align:t,sideOffset:r,alignOffset:n,avoidCollisions:o,collisionPadding:a});jo(v,()=>{x&&p(false);},m);let z=T.current?.filter(Boolean).length||0,H=el.useCallback(B=>{let C=T.current?.[B];C&&!C.hasAttribute("data-disabled")&&C.click();},[T]);js({isOpen:m,onClose:()=>{h&&(p(false),w.current?.focus());},itemsCount:z,focusedIndex:L,setFocusedIndex:R,onSelect:H}),el.useEffect(()=>{let B=v.current;if(B)return wn(B,()=>w.current)},[v,w]),el.useEffect(()=>{if(m&&T.current&&T.current.length>0){let B=setTimeout(()=>{R(0),T.current?.[0]?.focus();},10);return ()=>clearTimeout(B)}},[m,T,R]),el.useLayoutEffect(()=>{let B=0;if(!m){M(false);return}let C=()=>{let b=w.current?.getBoundingClientRect(),E=v.current?.getBoundingClientRect();if(k.isReady&&!!b&&!!E&&b.width>0&&b.height>0&&E.width>0&&E.height>0){M(true);return}B=requestAnimationFrame(C);};return M(false),B=requestAnimationFrame(C),()=>{B&&cancelAnimationFrame(B);}},[m,k.isReady,w,v]);let P=jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[I&&m&&jsxRuntime.jsx("div",{className:"fixed inset-0 z-40 bg-black/20",onClick:()=>p(false)}),jsxRuntime.jsx("div",{ref:v,id:S,role:"menu","aria-orientation":"vertical","aria-hidden":!m,tabIndex:-1,style:{position:"fixed",top:k.top,left:k.left,minWidth:s??w.current?.offsetWidth,maxWidth:l,maxHeight:i,visibility:m&&y?"visible":"hidden",opacity:m&&y?1:0,pointerEvents:m&&y?"auto":"none"},className:g("z-50 overflow-auto rounded-lg","border border-gray-200 bg-white shadow-lg","dark:border-gray-700 dark:bg-gray-800",m&&y&&Ky[c],f),children:jsxRuntime.jsx("div",{className:"py-1",children:u})})]});return d&&typeof document<"u"?reactDom.createPortal(P,document.body):P}xu.displayName="DropdownContent";var Qy={default:"text-gray-700 dark:text-gray-200 hover:bg-gray-100 dark:hover:bg-gray-700",danger:"text-red-600 dark:text-red-400 hover:bg-red-50 dark:hover:bg-red-900/20",success:"text-green-600 dark:text-green-400 hover:bg-green-50 dark:hover:bg-green-900/20"};function Cu({children:e,icon:t,iconPosition:r="left",description:n,shortcut:o,variant:a="default",closeOnSelect:s,onSelect:l,disabled:i=false,className:c,onClick:d,index:u,...f}){let{setIsOpen:m,closeOnSelect:p,focusedIndex:w,setFocusedIndex:v,registerItem:x,getNextItemIndex:h}=Sr(),I=el.useRef(null),[S]=el.useState(()=>u??h());el.useEffect(()=>(x(S,I.current),()=>{x(S,null);}),[S,x]);let L=s??p,R=w===S;return jsxRuntime.jsxs("button",{ref:I,role:"menuitem",type:"button",tabIndex:R?0:-1,disabled:i,"data-disabled":i||void 0,"data-focused":R||void 0,onClick:M=>{i||(l?.(),d?.(M),L&&m(false));},onMouseEnter:()=>{i||v(S);},className:g("relative flex w-full items-center px-3 py-2 text-left text-sm","outline-none transition-colors","focus:bg-gray-100 dark:focus:bg-gray-700",Qy[a],i&&"opacity-50 cursor-not-allowed hover:bg-transparent",R&&"bg-gray-100 dark:bg-gray-700",c),...f,children:[t&&r==="left"&&jsxRuntime.jsx("span",{className:"mr-2 shrink-0 w-5 h-5",children:t}),jsxRuntime.jsxs("span",{className:"flex-1 min-w-0",children:[jsxRuntime.jsx("span",{className:"block truncate",children:e}),n&&jsxRuntime.jsx("span",{className:"block text-xs text-gray-500 dark:text-gray-400 truncate",children:n})]}),t&&r==="right"&&jsxRuntime.jsx("span",{className:"ml-2 shrink-0 w-5 h-5",children:t}),o&&jsxRuntime.jsx("span",{className:"ml-auto pl-4 text-xs text-gray-400 dark:text-gray-500",children:o})]})}Cu.displayName="DropdownItem";function ku({className:e}){return jsxRuntime.jsx("hr",{className:g("my-1 h-px border-0 bg-gray-200 dark:bg-gray-700",e)})}ku.displayName="DropdownSeparator";function wu({children:e,className:t}){return jsxRuntime.jsx("div",{className:g("px-3 py-1.5 text-xs font-semibold text-gray-500 dark:text-gray-400",t),children:e})}wu.displayName="DropdownLabel";function Tu({checked:e,defaultChecked:t=false,onCheckedChange:r,children:n,icon:o,description:a,disabled:s=false,closeOnChange:l=false,className:i,index:c}){let{setIsOpen:d,focusedIndex:u,setFocusedIndex:f,registerItem:m,getNextItemIndex:p}=Sr(),w=el.useRef(null),[v]=el.useState(()=>c??p()),[x,h]=el.useState(t),I=e!==void 0,S=I?e:x;el.useEffect(()=>(m(v,w.current),()=>{m(v,null);}),[v,m]);let L=u===v;return jsxRuntime.jsxs("button",{ref:w,role:"menuitemcheckbox",type:"button",tabIndex:L?0:-1,"aria-checked":S,disabled:s,"data-disabled":s||void 0,"data-focused":L||void 0,onClick:()=>{if(s)return;let y=!S;I||h(y),r?.(y),l&&d(false);},onMouseEnter:()=>{s||f(v);},className:g("relative flex w-full items-center px-3 py-2 text-left text-sm","outline-none transition-colors","text-gray-700 dark:text-gray-200","hover:bg-gray-100 dark:hover:bg-gray-700","focus:bg-gray-100 dark:focus:bg-gray-700",s&&"opacity-50 cursor-not-allowed hover:bg-transparent",L&&"bg-gray-100 dark:bg-gray-700",i),children:[jsxRuntime.jsx("span",{className:"mr-2 shrink-0 w-4 h-4",children:o||jsxRuntime.jsx("span",{className:g("flex items-center justify-center w-4 h-4 rounded border-2 transition-colors",S?"bg-blue-600 border-blue-600":"border-gray-300 dark:border-gray-600"),children:S&&jsxRuntime.jsx("svg",{className:"w-3 h-3 text-white",viewBox:"0 0 16 16",fill:"none",children:jsxRuntime.jsx("path",{d:"M13.5 4.5L6 12L2.5 8.5",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round"})})})}),jsxRuntime.jsxs("span",{className:"flex-1 min-w-0",children:[jsxRuntime.jsx("span",{className:"block truncate",children:n}),a&&jsxRuntime.jsx("span",{className:"block text-xs text-gray-500 dark:text-gray-400 truncate",children:a})]})]})}Tu.displayName="DropdownCheckboxItem";var Lu=el.createContext(null);function ix(){let e=el.useContext(Lu);if(!e)throw new Error("DropdownRadioItem must be used within a DropdownRadioGroup");return e}function Eu({value:e,defaultValue:t="",onValueChange:r,children:n,className:o}){let[a,s]=el.useState(t),l=e!==void 0,i=l?e:a,c=el.useCallback(u=>{l||s(u),r?.(u);},[l,r]),d=el.useMemo(()=>({value:i,onValueChange:c}),[i,c]);return jsxRuntime.jsx(Lu.Provider,{value:d,children:jsxRuntime.jsx("div",{role:"group",className:o,children:n})})}Eu.displayName="DropdownRadioGroup";function Mu({value:e,children:t,icon:r,description:n,disabled:o=false,closeOnChange:a=true,className:s,index:l}){let{value:i,onValueChange:c}=ix(),{setIsOpen:d,focusedIndex:u,setFocusedIndex:f,registerItem:m,getNextItemIndex:p}=Sr(),w=el.useRef(null),[v]=el.useState(()=>l??p()),x=i===e;el.useEffect(()=>(m(v,w.current),()=>{m(v,null);}),[v,m]);let h=u===v;return jsxRuntime.jsxs("button",{ref:w,role:"menuitemradio",type:"button",tabIndex:h?0:-1,"aria-checked":x,disabled:o,"data-disabled":o||void 0,"data-focused":h||void 0,onClick:()=>{o||(c(e),a&&d(false));},onMouseEnter:()=>{o||f(v);},className:g("relative flex w-full items-center px-3 py-2 text-left text-sm","outline-none transition-colors","text-gray-700 dark:text-gray-200","hover:bg-gray-100 dark:hover:bg-gray-700","focus:bg-gray-100 dark:focus:bg-gray-700",o&&"opacity-50 cursor-not-allowed hover:bg-transparent",h&&"bg-gray-100 dark:bg-gray-700",s),children:[jsxRuntime.jsx("span",{className:"mr-2 shrink-0 w-4 h-4",children:r||jsxRuntime.jsx("span",{className:g("flex items-center justify-center w-4 h-4 rounded-full border-2 transition-colors",x?"border-blue-600":"border-gray-300 dark:border-gray-600"),children:x&&jsxRuntime.jsx("span",{className:"w-2 h-2 rounded-full bg-blue-600"})})}),jsxRuntime.jsxs("span",{className:"flex-1 min-w-0",children:[jsxRuntime.jsx("span",{className:"block truncate",children:t}),n&&jsxRuntime.jsx("span",{className:"block text-xs text-gray-500 dark:text-gray-400 truncate",children:n})]}),x&&!r&&jsxRuntime.jsx("svg",{className:"ml-auto w-4 h-4 text-blue-600",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:jsxRuntime.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M5 13l4 4L19 7"})})]})}Mu.displayName="DropdownRadioItem";var Wu=el.createContext(null);function Hu(){let e=el.useContext(Wu);if(!e)throw new Error("DropdownSubMenu components must be used within a DropdownSubMenu");return e}function Bu({children:e}){let[t,r]=el.useState(false),n=el.useRef(null),o=el.useRef(null),a=el.useMemo(()=>({isOpen:t,setIsOpen:r,triggerRef:n,contentRef:o}),[t]);return jsxRuntime.jsx(Wu.Provider,{value:a,children:jsxRuntime.jsx("div",{className:"relative",children:e})})}Bu.displayName="DropdownSubMenu";var Au=0;function Vu({children:e,icon:t,disabled:r=false,className:n,index:o}){let{isOpen:a,setIsOpen:s,triggerRef:l}=Hu(),{focusedIndex:i,setFocusedIndex:c,registerItem:d}=Sr(),u=el.useRef(o??-1);el.useEffect(()=>(o===void 0&&(u.current=Au++),d(u.current,l.current),()=>{d(u.current,null);}),[o,d,l]),el.useEffect(()=>()=>{Au=0;},[]);let f=i===u.current;return jsxRuntime.jsxs("button",{ref:l,role:"menuitem",type:"button",tabIndex:f?0:-1,"aria-haspopup":"menu","aria-expanded":a,disabled:r,"data-disabled":r||void 0,"data-focused":f||void 0,onMouseEnter:()=>{r||(c(u.current),s(true));},onMouseLeave:()=>{setTimeout(()=>{s(false);},100);},onKeyDown:v=>{r||(v.key==="ArrowRight"||v.key==="Enter")&&(v.preventDefault(),s(true));},className:g("relative flex w-full items-center px-3 py-2 text-left text-sm","outline-none transition-colors","text-gray-700 dark:text-gray-200","hover:bg-gray-100 dark:hover:bg-gray-700","focus:bg-gray-100 dark:focus:bg-gray-700",r&&"opacity-50 cursor-not-allowed hover:bg-transparent",f&&"bg-gray-100 dark:bg-gray-700",n),children:[t&&jsxRuntime.jsx("span",{className:"mr-2 shrink-0 w-5 h-5",children:t}),jsxRuntime.jsx("span",{className:"flex-1",children:e}),jsxRuntime.jsx("svg",{className:"ml-auto w-4 h-4 text-gray-400",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:jsxRuntime.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 5l7 7-7 7"})})]})}Vu.displayName="DropdownSubMenuTrigger";function Fu({children:e,sideOffset:t=0,className:r}){let{isOpen:n,setIsOpen:o,triggerRef:a,contentRef:s}=Hu(),[l,i]=el.useState(false),c=Bn({triggerRef:a,contentRef:s,isOpen:n,side:"right",align:"start",sideOffset:t,avoidCollisions:true});jo(s,()=>o(false),n),el.useEffect(()=>{let p=s.current;if(p)return wn(p,()=>a.current)},[s,a]);let d=el.useCallback(()=>{o(true);},[o]),u=el.useCallback(()=>{o(false);},[o]),f=p=>{(p.key==="ArrowLeft"||p.key==="Escape")&&(p.preventDefault(),o(false),a.current?.focus());};el.useLayoutEffect(()=>{let p=0;if(!n){i(false);return}let w=()=>{let v=a.current?.getBoundingClientRect(),x=s.current?.getBoundingClientRect();if(c.isReady&&!!v&&!!x&&v.width>0&&v.height>0&&x.width>0&&x.height>0){i(true);return}p=requestAnimationFrame(w);};return i(false),p=requestAnimationFrame(w),()=>{p&&cancelAnimationFrame(p);}},[n,c.isReady,a,s]);let m=jsxRuntime.jsx("div",{ref:s,role:"menu","aria-orientation":"vertical","aria-hidden":!n,tabIndex:-1,onMouseEnter:d,onMouseLeave:u,onKeyDown:f,style:{position:"fixed",top:c.top,left:c.left,visibility:n&&l?"visible":"hidden",opacity:n&&l?1:0,pointerEvents:n&&l?"auto":"none"},className:g("z-50 min-w-40 overflow-hidden rounded-lg","border border-gray-200 bg-white shadow-lg","dark:border-gray-700 dark:bg-gray-800",n&&l&&"animate-in fade-in-0 zoom-in-95 duration-150",r),children:jsxRuntime.jsx("div",{className:"py-1",children:e})});return typeof document<"u"?reactDom.createPortal(m,document.body):m}Fu.displayName="DropdownSubMenuContent";var px=(e="md")=>({sm:"text-xs p-1.5",md:"text-sm p-2.5",lg:"text-base p-3.5"})[e],Qo=({size:e="md",error:t,disabled:r,readOnly:n,icon:o,iconPosition:a})=>g("bg-gray-50 rounded-lg block w-full","border focus:outline-none focus:ring-0","dark:bg-gray-700 dark:placeholder-gray-400",px(e),o&&a==="left"?"pl-9":"",o&&a==="right"?"pr-9":"",r?"opacity-50 cursor-not-allowed":"",n?"bg-gray-100 dark:bg-gray-600 cursor-default":"",t?"border-red-500 dark:border-red-500":"border-gray-300 dark:border-gray-600"),Ou=(e,t)=>g("text-sm font-medium",e?"min-w-[120px]":"block mb-2",!t&&"text-gray-900 dark:text-white"),$u=e=>g("mt-1 text-xs",e?"text-red-500 dark:text-red-400":"text-gray-500 dark:text-gray-400"),bo=e=>g("absolute inset-y-0 flex items-center pointer-events-none",e==="left"?"left-2.5":"right-2.5");var Jo=({label:e,hideLabel:t,labelColor:r,error:n,helperText:o,inline:a,children:s,htmlFor:l})=>jsxRuntime.jsxs("div",{className:a?"flex items-center gap-4":"flex flex-col",children:[e&&!t&&jsxRuntime.jsx("label",{htmlFor:l,className:Ou(a||false,r),style:r?{color:r}:void 0,children:e}),jsxRuntime.jsx("div",{className:a?"flex-1":"w-full",children:s}),o&&jsxRuntime.jsx("p",{className:g($u(n),a&&"ml-34"),children:o})]});var ln=el.forwardRef(({label:e,inline:t=false,size:r="md",labelColor:n,borderColor:o,textColor:a,disabled:s=false,readOnly:l=false,error:i=false,helperText:c,hideLabel:d=false,icon:u,iconPosition:f="left",multiline:m=false,rows:p=3,focused:w=false,className:v,...x},h)=>{let I=el.useRef(null),S=k=>{I.current=k,typeof h=="function"?h(k):h&&(h.current=k);};el.useEffect(()=>{w&&I.current?.focus();},[w]);let L=el.useId(),R=g(Qo({size:r,error:i,disabled:s,readOnly:l,icon:u,iconPosition:f}),m&&"resize-vertical",v),T={...o&&{borderColor:o},...a&&{color:a}},y=o||a?T:void 0;return jsxRuntime.jsx(Jo,{label:e,hideLabel:d,labelColor:n,error:i,helperText:c,inline:t,htmlFor:L,children:jsxRuntime.jsxs("div",{className:"relative w-full",children:[u&&jsxRuntime.jsx("span",{className:bo(f),children:u}),m?jsxRuntime.jsx("textarea",{ref:S,id:L,disabled:s,readOnly:l,rows:p,tabIndex:l||s?-1:void 0,className:R,style:y,...x}):jsxRuntime.jsx("input",{ref:S,id:L,disabled:s,readOnly:l,tabIndex:l||s?-1:void 0,className:R,style:y,...x})]})})});ln.displayName="Input";var Sx=e=>jsxRuntime.jsxs("div",{className:"flex items-center gap-2 px-3 py-2 hover:bg-gray-100 dark:hover:bg-gray-700 cursor-pointer",children:[e.avatar&&jsxRuntime.jsx("img",{src:e.avatar,alt:e.label,className:"w-6 h-6 rounded-full"}),jsxRuntime.jsx("span",{className:"text-sm text-gray-900 dark:text-white",children:e.label})]}),Hl=el.forwardRef(({label:e,inline:t=false,size:r="md",labelColor:n,borderColor:o,textColor:a,disabled:s=false,readOnly:l=false,error:i=false,helperText:c,hideLabel:d=false,icon:u,iconPosition:f="left",mentionTrigger:m="@",suggestions:p=[],onMentionSearch:w,onMentionSelect:v,onMentionRemove:x,renderSuggestion:h,value:I,onChange:S,placeholder:L,loading:R=false,maxSuggestions:T=10,chipVariant:y="soft",chipColor:M="primary",chipSize:k="sm"},z)=>{let H=el.useId(),P=el.useRef(null),[B,C]=el.useState(false),[b,E]=el.useState(0),[N,W]=el.useState(""),F=g(Qo({size:r,error:i,disabled:s,readOnly:l,icon:u,iconPosition:f}),"min-h-[42px]","whitespace-pre-wrap","break-words"),K={...o&&{borderColor:o},...a&&{color:a}},j=o||a?K:void 0,A=el.useCallback(()=>{if(!P.current)return {text:"",mentions:[]};let $="",Y=[],se=0,ae=U=>{if(U.nodeType===Node.TEXT_NODE)$+=U.textContent||"",se+=(U.textContent||"").length;else if(U.nodeType===Node.ELEMENT_NODE){let Q=U;if(Q.hasAttribute("data-mention-id")){let le=Q.getAttribute("data-mention-id"),ye=Q.getAttribute("data-mention-label")||"",te=Q.getAttribute("data-mention-avatar")||void 0,Ce=`@${ye}`,Pe=se;Y.push({trigger:m,suggestion:{id:le||"",label:ye,avatar:te},startIndex:Pe,endIndex:Pe+Ce.length}),$+=Ce,se+=Ce.length;}else Q.childNodes.forEach(ae);}};return P.current.childNodes.forEach(ae),{text:$,mentions:Y}},[m]),D=el.useCallback(($,Y)=>{let se=document.createElement("span");return se.contentEditable="false",se.setAttribute("data-mention-id",$.id),se.setAttribute("data-mention-label",$.label),$.avatar&&se.setAttribute("data-mention-avatar",$.avatar),se.className="inline-block align-middle mx-0.5",se.style.userSelect="none",client.createRoot(se).render(jsxRuntime.jsx(Gs,{label:$.label,variant:y,color:M,size:k,closable:!s&&!l,onClose:Y,disabled:s,avatar:$.avatar?jsxRuntime.jsx("img",{src:$.avatar,alt:$.label,className:"w-full h-full object-cover"}):void 0})),se},[y,M,k,s,l]),V=el.useCallback($=>{if(!P.current)return;let Y=P.current.querySelector(`[data-mention-id="${$}"]`);if(Y){Y.remove();let se=A();S?.(se);let ae=I?.mentions.find(U=>U.suggestion.id===$)?.suggestion;ae&&x?.(ae);}},[A,S,x,I?.mentions]),O=el.useCallback(()=>{if(!P.current)return;let $=window.getSelection();if(!$||$.rangeCount===0)return;let Y=$.getRangeAt(0),se="";Y.startContainer.nodeType===Node.TEXT_NODE&&(se=Y.startContainer.textContent?.substring(0,Y.startOffset)||"");let ae=se.match(new RegExp(`${m}(\\w*)$`));if(ae){let Q=ae[1];W(Q),C(true),E(0),w?.(Q);}else C(false),W("");let U=A();S?.(U);},[m,w,S,A]),_=el.useCallback($=>{if(!P.current)return;let Y=window.getSelection();if(!Y||Y.rangeCount===0)return;let se=Y.getRangeAt(0);if(se.startContainer.nodeType===Node.TEXT_NODE){let U=se.startContainer,Q=U.textContent||"",le=se.startOffset,te=Q.substring(0,le).lastIndexOf(m);if(te!==-1){let Ce=Q.substring(0,te),Pe=Q.substring(le),Se=D($,()=>{V($.id);});if(Ce?(U.textContent=Ce,U.parentNode?.insertBefore(Se,U.nextSibling)):(U.parentNode?.insertBefore(Se,U),U.textContent="",U.textContent||U.remove()),Pe){let re=document.createTextNode(Pe);Se.parentNode?.insertBefore(re,Se.nextSibling);}let De=document.createTextNode(" ");Se.parentNode?.insertBefore(De,Se.nextSibling);let Ne=document.createRange();Ne.setStartAfter(De),Ne.collapse(true),Y.removeAllRanges(),Y.addRange(Ne);}}C(false),W("");let ae=A();S?.(ae),v?.($),P.current.focus();},[m,D,V,A,S,v]),X=el.useCallback($=>{let Y=p.slice(0,T);if(B&&Y.length>0)switch($.key){case "ArrowDown":$.preventDefault(),E(se=>se<Y.length-1?se+1:0);return;case "ArrowUp":$.preventDefault(),E(se=>se>0?se-1:Y.length-1);return;case "Enter":case "Tab":$.preventDefault(),Y[b]&&_(Y[b]);return;case "Escape":$.preventDefault(),C(false);return}if($.key==="Backspace"){let se=window.getSelection();if(!se||se.rangeCount===0)return;let ae=se.getRangeAt(0);if(ae.collapsed&&ae.startOffset===0){let U=ae.startContainer.previousSibling;if(U&&U.nodeType===Node.ELEMENT_NODE){let Q=U;if(Q.hasAttribute("data-mention-id")){$.preventDefault();let le=Q.getAttribute("data-mention-id");le&&V(le);return}}}if(ae.collapsed&&ae.startContainer.nodeType===Node.TEXT_NODE){let U=ae.startContainer;if(ae.startOffset===0){let Q=U.previousSibling;if(Q&&Q.nodeType===Node.ELEMENT_NODE){let le=Q;if(le.hasAttribute("data-mention-id")){$.preventDefault();let ye=le.getAttribute("data-mention-id");ye&&V(ye);return}}}}}},[B,p,b,T,_,V]);return el.useEffect(()=>{P.current&&(!(P.current.textContent||P.current.querySelector("[data-mention-id]"))&&L?P.current.setAttribute("data-placeholder",L):P.current.removeAttribute("data-placeholder"));},[L,I]),el.useEffect(()=>{P.current&&I?.text===""&&I?.mentions.length===0&&P.current.innerHTML.trim()&&(P.current.innerHTML="");},[I?.text,I?.mentions.length]),jsxRuntime.jsx(Jo,{label:e,hideLabel:d,labelColor:n,error:i,helperText:c,inline:t,htmlFor:H,children:jsxRuntime.jsxs("div",{className:"relative w-full",children:[u&&jsxRuntime.jsx("span",{className:bo(f),children:u}),jsxRuntime.jsx("div",{ref:$=>{typeof z=="function"?z($):z&&(z.current=$),P.current=$;},id:H,contentEditable:!s&&!l,suppressContentEditableWarning:true,onInput:O,onKeyDown:X,className:g(F,"empty:before:content-[attr(data-placeholder)] empty:before:text-gray-400 empty:before:dark:text-gray-500"),style:j,role:"textbox","aria-label":e,"aria-multiline":"true",tabIndex:l||s?-1:0}),B&&p.length>0&&jsxRuntime.jsx("div",{className:"absolute z-10 mt-1 w-full max-h-60 overflow-auto rounded-lg border border-gray-300 bg-white dark:bg-gray-700 dark:border-gray-600 shadow-lg",children:R?jsxRuntime.jsx("div",{className:"px-3 py-2 text-sm text-gray-500 dark:text-gray-400",children:"Loading..."}):p.slice(0,T).map(($,Y)=>jsxRuntime.jsx("div",{onClick:()=>_($),className:g(Y===b&&"bg-gray-100 dark:bg-gray-600"),children:h?h($):Sx($)},$.id))})]})})});Hl.displayName="MentionInput";var Bl=el.forwardRef(({label:e,inline:t=false,size:r="md",labelColor:n,borderColor:o,textColor:a,disabled:s=false,readOnly:l=false,error:i=false,helperText:c,hideLabel:d=false,icon:u,iconPosition:f="left",className:m,value:p,onChange:w,format:v="number",currency:x="USD",locale:h="en-US",decimals:I,min:S,max:L,step:R=1,prefix:T,suffix:y,thousandSeparator:M=true,allowNegative:k=true,onBlur:z,onFocus:H,...P},B)=>{let C=el.useId(),[b,E]=el.useState(null),N=el.useMemo(()=>{let G=v==="currency"?{style:"currency",currency:x,minimumFractionDigits:I??2,maximumFractionDigits:I??2}:v==="percentage"?{minimumFractionDigits:I??0,maximumFractionDigits:I??2}:{minimumFractionDigits:I??0,maximumFractionDigits:I??(v==="decimal"?2:0),useGrouping:M};try{return new Intl.NumberFormat(h,G)}catch{return null}},[v,x,h,I,M]),W=G=>{if(G==null)return "";if(!N)return String(G);let $=N.format(G);return v==="percentage"?($=T?`${T}${$}`:$,$=y||!$.includes("%")?`${$}%`:$,$):(T&&($=`${T}${$}`),y&&($=`${$}${y}`),$)},F=G=>{if(!G||G.trim()==="")return null;let $=G;if(T&&($=$.replace(T,"")),y&&($=$.replace(y,"")),$=$.replace(/[^\d.,-]/g,""),h.includes("fr")||h.includes("de")?$=$.replace(/\s/g,"").replace(",","."):$=$.replace(",",""),!$||$==="-"||$===".")return null;let Y=parseFloat($);return isNaN(Y)?null:!k&&Y<0?Math.abs(Y):S!==void 0&&Y<S?S:L!==void 0&&Y>L?L:Y},K=b??W(p??null),j=G=>{let $=h.includes("fr")||h.includes("de")?",":".";return new RegExp(`^-?[0-9${$===","?",":"\\."}]*$`).test(G)},A=G=>{let $=G.target.value;if($===""||j($)){E($);let Y=F($);w&&w(Y);}},D=G=>{let $=h.includes("fr")||h.includes("de")?",":".",Y=["Backspace","Delete","Tab","Escape","Enter","ArrowLeft","ArrowRight","ArrowUp","ArrowDown","Home","End"],se=/^[0-9]$/.test(G.key),ae=G.key===$,U=G.key==="-"&&k&&K.indexOf("-")===-1,Q=G.ctrlKey||G.metaKey;!se&&!ae&&!U&&!Y.includes(G.key)&&!Q&&G.preventDefault();},V=G=>{let $=p!=null?String(p):"";E($),H&&H(G);},O=G=>{let $=F(b??"");w&&$!==p&&w($),E(null),z&&z(G);},_=g(Qo({size:r,error:i,disabled:s,readOnly:l,icon:u,iconPosition:f}),o&&`border-[${o}]`,a&&`text-[${a}]`,m),X=jsxRuntime.jsxs("div",{className:"relative",children:[u&&f==="left"&&jsxRuntime.jsx("div",{className:bo(f),children:u}),jsxRuntime.jsx("input",{ref:B,id:C,type:"text",inputMode:"decimal",className:_,style:{borderColor:o,color:a},disabled:s,readOnly:l,value:K,onChange:A,onKeyDown:D,onFocus:V,onBlur:O,...P}),u&&f==="right"&&jsxRuntime.jsx("div",{className:bo(f),children:u})]});return jsxRuntime.jsx(Jo,{label:e,hideLabel:d,labelColor:n,error:i,helperText:c,inline:t,htmlFor:C,children:X})});Bl.displayName="NumberInput";function Ex({logo:e,logoHref:t="/",onLogoClick:r,navItems:n=[],actions:o,rightContent:a,variant:s="default",size:l="md",backgroundColor:i,textColor:c,hoverColor:d,navItemTextColor:u,navItemHoverColor:f,navItemBgHover:m,navItemActiveColor:p,sticky:w=false,fixed:v=false,showSearch:x=false,onSearch:h,searchPlaceholder:I="Search...",className:S,containerClassName:L}){let[R,T]=el.useState(false),[y,M]=el.useState(null),[k,z]=el.useState(""),H=()=>{T(!R);},P=A=>{M(y===A?null:A);},B=A=>{A.preventDefault(),h&&h(k);},C=g(w&&"sticky top-0 z-50",v&&"fixed top-0 left-0 right-0 z-50"),b=g(s==="default"&&!i&&"bg-neutral text-white",s==="transparent"&&!i&&"bg-transparent",s==="bordered"&&!i&&"bg-white border-b border-gray-200 text-gray-900 dark:bg-gray-900 dark:border-gray-800 dark:text-gray-100",s==="shadow"&&!i&&"bg-white shadow-md text-gray-900 dark:bg-gray-900 dark:text-gray-100"),E=g(l==="sm"&&"py-2",l==="md"&&"py-4",l==="lg"&&"py-6"),N=i||"",W=c||"",F=d||"",K=g(C,b,E,N,W,S),j=(A,D,V=false)=>{let O=A.children&&A.children.length>0,_=y===D,X=g("px-4 py-2 transition-colors flex items-center gap-2",V?"block w-full text-left":"inline-flex",A.active&&"font-semibold border-b-2",A.active&&(p||"border-current"),u||(s==="default"||s==="transparent"?"text-gray-300":"text-gray-600 dark:text-gray-300"),f||F||(s==="default"||s==="transparent"?"hover:text-white":"hover:text-blue-600 dark:hover:text-blue-400"),m||"");if(O)return jsxRuntime.jsxs("div",{className:V?"w-full":"relative",children:[jsxRuntime.jsxs("button",{type:"button",onClick:()=>P(D),className:X,children:[A.icon&&jsxRuntime.jsx("span",{className:"w-5 h-5",children:A.icon}),jsxRuntime.jsx("span",{children:A.label}),A.badge&&jsxRuntime.jsx("span",{className:"bg-red-500 text-white text-xs px-2 py-0.5 rounded-full",children:A.badge}),jsxRuntime.jsx("svg",{className:g("w-4 h-4 transition-transform",_&&"rotate-180"),fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:jsxRuntime.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 9l-7 7-7-7"})})]}),_&&jsxRuntime.jsx("div",{className:g("bg-white shadow-lg rounded-lg overflow-hidden dark:bg-gray-800 dark:shadow-black/40",V?"mt-2 mb-2":"absolute top-full left-0 mt-1 min-w-[200px]"),children:A.children?.map($=>jsxRuntime.jsx("a",{href:$.href,onClick:$.onClick,target:$.external?"_blank":void 0,rel:$.external?"noopener noreferrer":void 0,className:"block px-4 py-2 text-gray-700 hover:bg-gray-100 transition-colors dark:text-gray-200 dark:hover:bg-gray-700",children:jsxRuntime.jsxs("div",{className:"flex items-center gap-2",children:[$.icon&&jsxRuntime.jsx("span",{className:"w-5 h-5",children:$.icon}),jsxRuntime.jsx("span",{children:$.label}),$.badge&&jsxRuntime.jsx("span",{className:"bg-red-500 text-white text-xs px-2 py-0.5 rounded-full ml-auto",children:$.badge}),$.external&&jsxRuntime.jsx("svg",{className:"w-4 h-4 ml-auto",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:jsxRuntime.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M10 6H6a2 2 0 00-2 2v10a2 2 0 002 2h10a2 2 0 002-2v-4M14 4h6m0 0v6m0-6L10 14"})})]})},$.href??$.label))})]},A.href??A.label);let G=jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[A.icon&&jsxRuntime.jsx("span",{className:"w-5 h-5",children:A.icon}),jsxRuntime.jsx("span",{children:A.label}),A.badge&&jsxRuntime.jsx("span",{className:"bg-red-500 text-white text-xs px-2 py-0.5 rounded-full",children:A.badge}),A.external&&jsxRuntime.jsx("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:jsxRuntime.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M10 6H6a2 2 0 00-2 2v10a2 2 0 002 2h10a2 2 0 002-2v-4M14 4h6m0 0v6m0-6L10 14"})})]});return A.onClick?jsxRuntime.jsx("button",{type:"button",onClick:A.onClick,className:X,children:G},A.href??A.label):jsxRuntime.jsx("a",{href:A.href,target:A.external?"_blank":void 0,rel:A.external?"noopener noreferrer":void 0,className:X,children:G},A.href??A.label)};return jsxRuntime.jsxs("header",{className:K,children:[jsxRuntime.jsxs("nav",{className:g("container mx-auto flex items-center justify-between px-4",L),children:[e&&jsxRuntime.jsx("div",{className:"flex items-center",children:t?jsxRuntime.jsx("a",{href:t,onClick:r,className:"flex items-center hover:opacity-80 transition-opacity",children:e}):jsxRuntime.jsx("div",{className:"flex items-center",children:e})}),x&&jsxRuntime.jsx("form",{onSubmit:B,className:"hidden md:flex flex-1 max-w-md mx-8",children:jsxRuntime.jsx("input",{type:"search","aria-label":I,value:k,onChange:A=>z(A.target.value),placeholder:I,className:"w-full px-4 py-2 rounded-lg border border-gray-300 focus:outline-none focus:ring-2 focus:ring-blue-500 text-gray-900 dark:border-gray-700 dark:bg-gray-800 dark:text-gray-100 dark:placeholder-gray-500"})}),jsxRuntime.jsx("div",{className:"hidden md:flex items-center gap-2",children:n.map((A,D)=>j(A,D,false))}),(o||a)&&jsxRuntime.jsxs("div",{className:"hidden md:flex items-center gap-2 ml-4",children:[o,a]}),n.length>0&&jsxRuntime.jsx("div",{className:"md:hidden",children:jsxRuntime.jsx("button",{type:"button",className:g("inline-flex rounded-lg border-2 p-2 w-10 h-10 justify-center transition-colors focus:outline-none",s==="default"||s==="transparent"?"text-gray-300 hover:text-white":"text-gray-600 hover:text-gray-900 dark:text-gray-300 dark:hover:text-gray-100"),onClick:H,"aria-label":"Toggle menu","aria-expanded":R,children:jsxRuntime.jsx("svg",{className:"w-5 h-5","aria-hidden":"true",xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 17 14",children:jsxRuntime.jsx("path",{stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",d:"M1 1h15M1 7h15M1 13h15"})})})})]}),R&&n.length>0&&jsxRuntime.jsx("div",{className:g("md:hidden border-t animate-in slide-in-from-top duration-300",s==="default"||s==="transparent"?"border-gray-700":"border-gray-200 dark:border-gray-800"),children:jsxRuntime.jsxs("div",{className:"flex flex-col py-2 px-4",children:[x&&jsxRuntime.jsx("form",{onSubmit:B,className:"mb-4",children:jsxRuntime.jsx("input",{type:"search","aria-label":I,value:k,onChange:A=>z(A.target.value),placeholder:I,className:"w-full px-4 py-2 rounded-lg border border-gray-300 focus:outline-none focus:ring-2 focus:ring-blue-500 text-gray-900 dark:border-gray-700 dark:bg-gray-800 dark:text-gray-100 dark:placeholder-gray-500"})}),n.map((A,D)=>j(A,D,true)),(o||a)&&jsxRuntime.jsxs("div",{className:"flex flex-col gap-2 mt-4 pt-4 border-t border-gray-700",children:[o,a]})]})})]})}var Wx=jsxRuntime.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[jsxRuntime.jsx("path",{d:"M11 4H4a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7"}),jsxRuntime.jsx("path",{d:"M18.5 2.5a2.121 2.121 0 0 1 3 3L12 15l-4 1 1-4 9.5-9.5z"})]}),Hx=jsxRuntime.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[jsxRuntime.jsx("path",{d:"M19 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h11l5 5v11a2 2 0 0 1-2 2z"}),jsxRuntime.jsx("polyline",{points:"17 21 17 13 7 13 7 21"}),jsxRuntime.jsx("polyline",{points:"7 3 7 8 15 8"})]}),Bx=jsxRuntime.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[jsxRuntime.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),jsxRuntime.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]}),Vx=jsxRuntime.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[jsxRuntime.jsx("polyline",{points:"1 4 1 10 7 10"}),jsxRuntime.jsx("path",{d:"M3.51 15a9 9 0 1 0 2.13-9.36L1 10"})]}),Fx=jsxRuntime.jsxs("svg",{className:"animate-spin h-4 w-4",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[jsxRuntime.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10"}),jsxRuntime.jsx("path",{className:"opacity-75",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4z",fill:"currentColor"})]}),Ox={xs:"w-4 h-4 text-[10px]",sm:"w-5 h-5 text-xs",md:"w-6 h-6 text-sm",lg:"w-7 h-7 text-base"},$x={top:"bottom-full left-1/2 -translate-x-1/2 mb-2",bottom:"top-full left-1/2 -translate-x-1/2 mt-2",left:"right-full top-1/2 -translate-y-1/2 mr-2",right:"left-full top-1/2 -translate-y-1/2 ml-2"},_x={sm:"w-56",md:"w-72",lg:"w-96",xl:"w-[32rem]"},Xx=[zx__default.default],Gx={h1:({...e})=>jsxRuntime.jsx("h1",{className:"text-xl font-bold mb-2 text-gray-900 dark:text-gray-100",...e}),h2:({...e})=>jsxRuntime.jsx("h2",{className:"text-lg font-semibold mt-4 mb-2 text-gray-900 dark:text-gray-100",...e}),h3:({...e})=>jsxRuntime.jsx("h3",{className:"text-base font-semibold mt-3 mb-1 text-gray-900 dark:text-gray-100",...e}),p:({...e})=>jsxRuntime.jsx("p",{className:"my-1 text-gray-700 dark:text-gray-300",...e}),ul:({...e})=>jsxRuntime.jsx("ul",{className:"list-disc list-inside space-y-1 my-2 text-gray-700 dark:text-gray-300",...e}),ol:({...e})=>jsxRuntime.jsx("ol",{className:"list-decimal list-inside space-y-1 my-2 text-gray-700 dark:text-gray-300",...e}),code:({className:e,children:t,...r})=>!e?.includes("language-")?jsxRuntime.jsx("code",{className:"bg-gray-100 dark:bg-gray-800 px-1.5 py-0.5 rounded text-sm font-mono text-gray-900 dark:text-gray-100",...r,children:t}):jsxRuntime.jsx("code",{className:"block bg-gray-100 dark:bg-gray-800 rounded-lg p-3 my-2 overflow-x-auto text-sm font-mono text-gray-900 dark:text-gray-100",...r,children:t}),pre:({...e})=>jsxRuntime.jsx("pre",{className:"my-2",...e}),a:({...e})=>jsxRuntime.jsx("a",{className:"text-blue-600 dark:text-blue-400 hover:underline",...e}),strong:({...e})=>jsxRuntime.jsx("strong",{className:"font-semibold text-gray-900 dark:text-gray-100",...e}),em:({...e})=>jsxRuntime.jsx("em",{className:"italic",...e}),blockquote:({...e})=>jsxRuntime.jsx("blockquote",{className:"border-l-4 border-gray-300 dark:border-gray-600 pl-4 my-2 italic text-gray-600 dark:text-gray-400",...e})};function Gu({content:e,markdown:t=false,position:r="bottom",size:n="sm",className:o="",visible:a=true,editable:s=false,onSave:l,onReset:i,width:c="md",title:d,markdownEditor:u,markdownEditorUnavailableLabel:f}){let m=We(),[p,w]=el.useState(false),[v,x]=el.useState(false),[h,I]=el.useState(""),[S,L]=el.useState(false),[R,T]=el.useState(null),y=el.useRef(null),M=el.useRef(null),k=el.useRef(null),z=el.useRef(null);el.useEffect(()=>{if(!p)return;let E=W=>{y.current&&!y.current.contains(W.target)&&M.current&&!M.current.contains(W.target)&&(v||w(false));},N=W=>{W.key==="Escape"&&(v?(x(false),I("")):w(false));};return document.addEventListener("mousedown",E),document.addEventListener("keydown",N),()=>{document.removeEventListener("mousedown",E),document.removeEventListener("keydown",N);}},[p,v]),el.useEffect(()=>{v&&k.current&&k.current.focus();},[v]),el.useEffect(()=>()=>{z.current&&clearTimeout(z.current);},[]);let H=el.useCallback(()=>{I(typeof e=="string"?e:""),x(true),T(null);},[e]),P=el.useCallback(()=>{x(false),I(""),T(null);},[]),B=el.useCallback(async()=>{if(!l){T({type:"error",text:"Aucune fonction de sauvegarde fournie"});return}L(true);try{await l(h)?(T({type:"success",text:"Sauvegard\xE9 avec succ\xE8s !"}),x(!1),z.current&&clearTimeout(z.current),z.current=setTimeout(()=>T(null),2e3)):T({type:"error",text:"Erreur lors de la sauvegarde"});}catch{T({type:"error",text:"Erreur lors de la sauvegarde"});}finally{L(false);}},[h,l]),C=el.useCallback(async()=>{if(i&&confirm("\xCAtes-vous s\xFBr de vouloir r\xE9initialiser ce contenu ?")){L(true);try{await i()?(T({type:"success",text:"R\xE9initialis\xE9 avec succ\xE8s !"}),x(!1),z.current&&clearTimeout(z.current),z.current=setTimeout(()=>T(null),2e3)):T({type:"error",text:"Erreur lors de la r\xE9initialisation"});}catch{T({type:"error",text:"Erreur lors de la r\xE9initialisation"});}finally{L(false);}}},[i]),b=e;return a?jsxRuntime.jsxs("div",{className:"relative inline-flex items-center",children:[jsxRuntime.jsx("button",{type:"button",ref:y,onClick:()=>w(!p),className:`
3
- ${Ox[n]}
1
+ 'use strict';var Cl=require('react'),jsxRuntime=require('react/jsx-runtime'),reactDom=require('react-dom'),client=require('react-dom/client'),wv=require('dompurify'),Nv=require('react-markdown'),Sv=require('remark-gfm');function _interopDefault(e){return e&&e.__esModule?e:{default:e}}function _interopNamespace(e){if(e&&e.__esModule)return e;var n=Object.create(null);if(e){Object.keys(e).forEach(function(k){if(k!=='default'){var d=Object.getOwnPropertyDescriptor(e,k);Object.defineProperty(n,k,d.get?d:{enumerable:true,get:function(){return e[k]}});}})}n.default=e;return Object.freeze(n)}var Cl__namespace=/*#__PURE__*/_interopNamespace(Cl);var wv__default=/*#__PURE__*/_interopDefault(wv);var Nv__default=/*#__PURE__*/_interopDefault(Nv);var Sv__default=/*#__PURE__*/_interopDefault(Sv);function p(...e){return e.filter(Boolean).join(" ")}var td=Cl.createContext(null),rd=Cl.createContext(null);function Ki(){let e=Cl.useContext(td);if(!e)throw new Error("Accordion sub-components must be used within <Accordion>");return e}function nd(){let e=Cl.useContext(rd);if(!e)throw new Error("AccordionTrigger/AccordionContent must be used within <AccordionItem>");return e}var od={sm:{trigger:"px-3 py-2",content:"px-3 pb-2",text:"text-sm",icon:"w-3.5 h-3.5"},md:{trigger:"px-4 py-3",content:"px-4 pb-3",text:"text-base",icon:"w-4 h-4"},lg:{trigger:"px-5 py-4",content:"px-5 pb-4",text:"text-lg",icon:"w-5 h-5"}},hg=({className:e})=>jsxRuntime.jsx("svg",{className:e,viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true",children:jsxRuntime.jsx("path",{fillRule:"evenodd",d:"M5.23 7.21a.75.75 0 011.06.02L10 11.168l3.71-3.938a.75.75 0 111.08 1.04l-4.25 4.5a.75.75 0 01-1.08 0l-4.25-4.5a.75.75 0 01.02-1.06z",clipRule:"evenodd"})}),bg={default:"border border-gray-200 dark:border-gray-700 rounded-lg divide-y divide-gray-200 dark:divide-gray-700",bordered:"border-2 border-gray-300 dark:border-gray-600 rounded-lg divide-y divide-gray-300 dark:divide-gray-600",separated:"space-y-2",ghost:""},yg={default:"",bordered:"",separated:"border border-gray-200 dark:border-gray-700 rounded-lg overflow-hidden",ghost:"border-b border-gray-200 dark:border-gray-700 last:border-b-0"};function xg({type:e="single",value:t,defaultValue:r,onValueChange:n,collapsible:o=false,variant:a="default",size:s="md",disabled:l=false,iconPosition:i="right",icon:c,hideIcon:d=false,className:u,children:f}){let[m,g]=Cl.useState(()=>r?Array.isArray(r)?r:[r]:[]),y=t!==void 0,b=y?Array.isArray(t)?t:[t]:m,h=Cl.useCallback(L=>{let C;e==="single"?b.includes(L)?C=o?[]:[L]:C=[L]:C=b.includes(L)?b.filter(S=>S!==L):[...b,L],y||g(C),n?.(e==="single"?C[0]??"":C);},[e,b,o,y,n]),x=Cl.useMemo(()=>({openItems:b,toggle:h,variant:a,size:s,disabled:l,iconPosition:i,icon:c??null,hideIcon:d}),[b,h,a,s,l,i,c,d]);return jsxRuntime.jsx(td.Provider,{value:x,children:jsxRuntime.jsx("div",{className:p(bg[a],u),"data-testid":"accordion",children:f})})}function vg({value:e,disabled:t,className:r,children:n}){let o=Ki(),a=o.openItems.includes(e),s=t??o.disabled,l=Cl.useId(),i=`accordion-trigger-${l}`,c=`accordion-content-${l}`,d=Cl.useMemo(()=>({value:e,isOpen:a,disabled:s,triggerId:i,contentId:c}),[e,a,s,i,c]);return jsxRuntime.jsx(rd.Provider,{value:d,children:jsxRuntime.jsx("div",{className:p(yg[o.variant],r),"data-state":a?"open":"closed","data-testid":"accordion-item",children:n})})}function Cg({className:e,icon:t,children:r}){let n=Ki(),o=nd(),a=od[n.size],s=()=>{o.disabled||n.toggle(o.value);},l=d=>{(d.key==="Enter"||d.key===" ")&&(d.preventDefault(),s());},i=t??n.icon??jsxRuntime.jsx(hg,{className:a.icon}),c=!n.hideIcon&&jsxRuntime.jsx("span",{className:p("shrink-0 text-gray-500 dark:text-gray-400 transition-transform duration-200",o.isOpen&&"rotate-180"),"data-testid":"accordion-icon",children:i});return jsxRuntime.jsxs("button",{type:"button",id:o.triggerId,"aria-expanded":o.isOpen,"aria-controls":o.contentId,disabled:o.disabled,onClick:s,onKeyDown:l,className:p("flex items-center w-full text-left font-medium transition-colors cursor-pointer",a.trigger,a.text,"text-gray-900 dark:text-gray-100",!o.disabled&&"hover:bg-gray-50 dark:hover:bg-gray-800/50",o.disabled&&"opacity-50 cursor-not-allowed",e),"data-testid":"accordion-trigger",children:[n.iconPosition==="left"&&c,jsxRuntime.jsx("span",{className:"flex-1",children:r}),n.iconPosition==="right"&&c]})}function kg({className:e,children:t}){let r=Ki(),n=nd(),o=od[r.size],a=Cl.useRef(null),[s,l]=Cl.useState(n.isOpen?void 0:0),i=Cl.useRef(true);return Cl.useEffect(()=>{if(i.current){i.current=false,l(n.isOpen?void 0:0);return}if(n.isOpen){let c=a.current;if(c){l(c.scrollHeight);let d=setTimeout(()=>l(void 0),200);return ()=>clearTimeout(d)}}else {let c=a.current;c&&(l(c.scrollHeight),requestAnimationFrame(()=>l(0)));}},[n.isOpen]),jsxRuntime.jsx("div",{id:n.contentId,role:"region","aria-labelledby":n.triggerId,className:"overflow-hidden transition-[height] duration-200 ease-in-out",style:{height:s===void 0?"auto":s},"data-testid":"accordion-content","data-state":n.isOpen?"open":"closed",children:jsxRuntime.jsx("div",{ref:a,className:p(o.content,"text-gray-600 dark:text-gray-400",o.text==="text-lg"?"text-base":"text-sm",e),children:t})})}function Pg(...e){return e.filter(Boolean).join(" ")}var Tg="@synertech/ui/AdvanceDetachable",Dg=300,Eg="width=800,height=600,menubar=no,toolbar=no,location=no,status=no,scrollbars=yes,resizable=yes",Lg=0;function Mg(){return `${Date.now()}-${++Lg}-${Math.random().toString(36).slice(2,8)}`}function ad(e){try{return JSON.stringify(e)}catch{return String(e)}}function sd(e){try{return JSON.parse(e)}catch{return e}}function Ig(e,t){e.querySelectorAll("style").forEach(r=>{let n=t.createElement("style");n.textContent=r.textContent,t.head.appendChild(n);}),e.querySelectorAll('link[rel="stylesheet"]').forEach(r=>{let n=r,o=t.createElement("link");o.rel="stylesheet",o.href=n.href,n.crossOrigin&&(o.crossOrigin=n.crossOrigin),t.head.appendChild(o);}),e.documentElement.className&&(t.documentElement.className=e.documentElement.className),e.body.className&&(t.body.className=e.body.className);}function Ag(e,t){let r=new MutationObserver(n=>{for(let o of n)for(let a of Array.from(o.addedNodes))if(a instanceof HTMLStyleElement){let s=t.createElement("style");s.textContent=a.textContent,t.head.appendChild(s);}else if(a instanceof HTMLLinkElement&&a.rel==="stylesheet"){let s=t.createElement("link");s.rel="stylesheet",s.href=a.href,t.head.appendChild(s);}});return r.observe(e.head,{childList:true}),r}function zg(){return typeof BroadcastChannel<"u"}function Bg({mode:e,id:t,title:r="",children:n,value:o,defaultValue:a,onValueChange:s,isDetached:l,defaultDetached:i=false,onDetachedChange:c,features:d,target:u,autoFocus:f=true,className:m,detachedBodyClassName:g,disabled:y=false,readOnly:b=false,closeOnMainWindowUnload:h=true,name:x,serialize:L,deserialize:C},S){let v=l!==void 0,[R,N]=Cl.useState(i),M=v?l:R,P=o!==void 0,[E,W]=Cl.useState(a),T=P?o:E,[O,H]=Cl.useState(null),k=Cl.useRef(null),z=Cl.useRef(null),A=Cl.useRef(null),I=Cl.useRef(null),X=Cl.useRef(false),$=Cl.useRef(null),K=Cl.useRef(null),D=Cl.useRef(null),[B]=Cl.useState(()=>`${Date.now().toString(36)}-${Math.random().toString(36).slice(2,8)}`),w=Cl.useRef({title:r,features:d,target:u,autoFocus:f,detachedBodyClassName:g,closeOnMainWindowUnload:h,disabled:y,readOnly:b,mode:e,id:t});w.current={title:r,features:d,target:u,autoFocus:f,detachedBodyClassName:g,closeOnMainWindowUnload:h,disabled:y,readOnly:b,mode:e,id:t};let G=Cl.useRef(L??ad);G.current=L??ad;let q=Cl.useRef(C??sd);q.current=C??sd;let j=Cl.useRef(s);j.current=s;let U=Cl.useRef(c);U.current=c;let F=Cl.useRef(M);F.current=M;let _=`${Tg}/${t}`,J=Cl.useCallback(()=>{A.current&&(clearInterval(A.current),A.current=null),I.current&&(I.current.disconnect(),I.current=null),H(null);},[]),ne=Cl.useCallback(()=>{z.current&&(z.current.close(),z.current=null),$.current&&typeof window<"u"&&(window.removeEventListener("message",$.current),$.current=null);},[]),Y=Cl.useCallback(be=>{if(!(!be||be.channel!==_)&&be.instanceId!==B&&!w.current.readOnly&&be.type==="value-sync"&&be.payload!==void 0){K.current=be.payload;let Me=q.current(be.payload);P||W(Me),j.current?.(Me);}},[_,B,P]),ee=Cl.useCallback(()=>{if(ne(),!(typeof window>"u"))if(zg()){let be=new BroadcastChannel(_),Me=Re=>Y(Re.data);be.addEventListener("message",Me),z.current=be;}else {let be=Me=>{Me.data?.channel===_&&Y(Me.data);};window.addEventListener("message",be),$.current=be;}},[_,ne,Y]),Z=Cl.useCallback(be=>{if(w.current.readOnly)return;let Me=G.current(be);if(Me===D.current)return;if(Me===K.current){K.current=null;return}D.current=Me;let Re={channel:_,instanceId:B,messageId:Mg(),origin:"main",timestamp:Date.now(),type:"value-sync",payload:Me};z.current?z.current.postMessage(Re):k.current&&!k.current.closed&&k.current.postMessage(Re,"*");},[_,B]),ie=Cl.useCallback(()=>{if(typeof window>"u"||w.current.disabled||X.current||k.current&&!k.current.closed)return;X.current=true;let be=w.current,Me=window.open("",be.target||"",be.features||Eg);if(!Me){X.current=false;return}k.current=Me,Me.document.title=be.title||document.title,be.detachedBodyClassName&&(Me.document.body.className=be.detachedBodyClassName);let Re=Me.document.createElement("div");Me.document.body.appendChild(Re),H(Re),Ig(document,Me.document),I.current=Ag(document,Me.document),A.current=setInterval(()=>{Me.closed&&(J(),k.current=null,v||N(false),U.current?.(false));},Dg),be.autoFocus&&Me.focus(),X.current=false;},[v,J]),V=Cl.useCallback(()=>{k.current&&!k.current.closed&&k.current.close(),k.current=null,J();},[J]),oe=Cl.useRef(ie);oe.current=ie;let pe=Cl.useRef(V);pe.current=V;let Te=Cl.useRef(Z);Te.current=Z;let ze=Cl.useCallback(()=>{w.current.disabled||(v||N(true),U.current?.(true));},[v]),ae=Cl.useCallback(()=>{v||N(false),U.current?.(false);},[v]),re=Cl.useCallback(()=>{let be=!F.current;be&&w.current.disabled||(v||N(be),U.current?.(be));},[v]);Cl.useImperativeHandle(S,()=>({open:ze,close:ae,toggle:re,get isDetached(){return F.current},get window(){return k.current}}),[ze,ae,re]),Cl.useEffect(()=>(ee(),()=>ne()),[ee,ne]),Cl.useEffect(()=>{if(M)return oe.current(),()=>pe.current();pe.current();},[M]),Cl.useEffect(()=>{T!==void 0&&Te.current(T);},[T]),Cl.useEffect(()=>{k.current&&!k.current.closed&&r&&(k.current.document.title=r);},[r]),Cl.useEffect(()=>{if(typeof window>"u")return;let be=()=>{w.current.closeOnMainWindowUnload&&k.current&&!k.current.closed&&k.current.close();};return window.addEventListener("beforeunload",be),()=>{window.removeEventListener("beforeunload",be),k.current&&!k.current.closed&&k.current.close(),k.current=null;}},[]);let ce=typeof n=="function"?n({open:ze,close:ae,toggle:re,detached:M,windowRef:k.current}):n,De=e==="clone"||!M,Ge=M&&O!==null;return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[x&&T!==void 0&&jsxRuntime.jsx("input",{type:"hidden",name:x,value:G.current(T)}),De&&jsxRuntime.jsx("div",{className:Pg(m),children:ce}),Ge&&reactDom.createPortal(ce,O)]})}var ld=Cl.forwardRef(Bg);ld.displayName="AdvanceDetachable";var dd={closeModal:"Close modal",closeDrawer:"Close drawer",closeSidebar:"Close sidebar",openSidebar:"Open sidebar",expandSidebar:"Expand sidebar",collapseSidebar:"Collapse sidebar",sidebar:"Sidebar",enterFullScreen:"Enter full screen",exitFullScreen:"Exit full screen",confirm:"Confirm",cancel:"Cancel",markdownEditorUnavailable:"Markdown editor unavailable. Pass markdownEditor from @synertech/ui/markdown-editor.",chartShowTable:"Show data table",chartHideTable:"Hide data table",chartNoData:"No data",chartLoading:"Loading chart",chartOther:"Other",chartValue:"Value",chartTarget:"Target",chartIncrease:"Increase",chartDecrease:"Decrease",chartRunningTotal:"Running total",chartConversion:"Conversion",chartDropOff:"Drop-off",chartChange:"Change",chartMedian:"Median",chartCount:"Count",chartOutliers:"Outliers",chartOpen:"Open",chartHigh:"High",chartLow:"Low",chartClose:"Close",chartRise:"Up",chartFall:"Down",chartStart:"Start",chartEnd:"End",chartProgress:"Progress",chartToday:"Today",chartAnnotations:"Annotations",chartFilters:"Filters",chartPeriod:"Period",chartPeriodLast7Days:"Last 7 days",chartPeriodLast30Days:"Last 30 days",chartPeriodLast90Days:"Last 90 days",chartPeriodLast12Months:"Last 12 months",chartPeriodMonthToDate:"Month to date",chartPeriodQuarterToDate:"Quarter to date",chartPeriodYearToDate:"Year to date",chartPeriodCustom:"Custom range",chartError:"Chart could not be loaded",chartErrorHint:"Something went wrong while loading this data.",chartRetry:"Retry",chartExport:"Export",chartExportCsv:"Export as CSV",chartExportJson:"Export as JSON",chartBrush:"Selected range",chartClearSelection:"Clear selection"},Fg={closeModal:"Fermer la fen\xEAtre",closeDrawer:"Fermer le panneau",closeSidebar:"Fermer le menu lat\xE9ral",openSidebar:"Ouvrir le menu lat\xE9ral",expandSidebar:"D\xE9plier le menu lat\xE9ral",collapseSidebar:"Replier le menu lat\xE9ral",sidebar:"Menu lat\xE9ral",enterFullScreen:"Passer en plein \xE9cran",exitFullScreen:"Quitter le plein \xE9cran",confirm:"Confirmer",cancel:"Annuler",markdownEditorUnavailable:"\xC9diteur Markdown indisponible. Passez markdownEditor depuis @synertech/ui/markdown-editor.",chartShowTable:"Afficher le tableau de donn\xE9es",chartHideTable:"Masquer le tableau de donn\xE9es",chartNoData:"Aucune donn\xE9e",chartLoading:"Chargement du graphique",chartOther:"Autres",chartValue:"Valeur",chartTarget:"Objectif",chartIncrease:"Hausse",chartDecrease:"Baisse",chartRunningTotal:"Cumul",chartConversion:"Conversion",chartDropOff:"D\xE9perdition",chartChange:"\xC9cart",chartMedian:"M\xE9diane",chartCount:"Effectif",chartOutliers:"Valeurs aberrantes",chartOpen:"Ouverture",chartHigh:"Haut",chartLow:"Bas",chartClose:"Cl\xF4ture",chartRise:"Hausse",chartFall:"Baisse",chartStart:"D\xE9but",chartEnd:"Fin",chartProgress:"Avancement",chartToday:"Aujourd'hui",chartAnnotations:"Annotations",chartFilters:"Filtres",chartPeriod:"P\xE9riode",chartPeriodLast7Days:"7 derniers jours",chartPeriodLast30Days:"30 derniers jours",chartPeriodLast90Days:"90 derniers jours",chartPeriodLast12Months:"12 derniers mois",chartPeriodMonthToDate:"Mois en cours",chartPeriodQuarterToDate:"Trimestre en cours",chartPeriodYearToDate:"Ann\xE9e en cours",chartPeriodCustom:"P\xE9riode personnalis\xE9e",chartError:"Chargement impossible",chartErrorHint:"Une erreur est survenue pendant le chargement des donn\xE9es.",chartRetry:"R\xE9essayer",chartExport:"Exporter",chartExportCsv:"Exporter en CSV",chartExportJson:"Exporter en JSON",chartBrush:"Plage s\xE9lectionn\xE9e",chartClearSelection:"Effacer la s\xE9lection"},Yi=Cl.createContext(dd);function $g({labels:e,children:t}){let r=Cl.useContext(Yi),n=Cl.useMemo(()=>({...r,...e}),[r,e]);return jsxRuntime.jsx(Yi.Provider,{value:n,children:t})}function Ve(){return Cl.useContext(Yi)}function ir(e,t=11){return e.length*t*.6}function Pr(e,t=11){let r=0;for(let n of e){let o=ir(n,t);o>r&&(r=o);}return r}function Ea(e,t,r,n=12){if(e<=1||t<=0)return 1;let o=r+n,a=Math.max(1,Math.floor(t/o));return Math.max(1,Math.ceil(e/a))}var vs=10,ks=15,La=5,ro=6,xs=4,Xg=.1;function ji({x:e,y:t,text:r,align:n}){let o=ir(r,vs)+La*2,a=n==="start"?e:e-o;return jsxRuntime.jsxs("g",{children:[jsxRuntime.jsx("rect",{x:a,y:t,width:o,height:ks,rx:3,className:"fill-white stroke-gray-200 dark:fill-gray-800 dark:stroke-gray-700",strokeWidth:1}),jsxRuntime.jsx("text",{x:a+La,y:t+ks/2,dominantBaseline:"central",className:"fill-gray-600 text-[10px] dark:fill-gray-300",children:r})]})}function rn({annotations:e,xAt:t,yAt:r,width:n,height:o,bandwidth:a=0,layer:s="over"}){if(e.length===0)return null;if(s==="under"){let i=e.filter(c=>c.type==="band");return i.length===0?null:jsxRuntime.jsx("g",{"aria-hidden":"true",children:i.map((c,d)=>{let u=t(c.from),f=t(c.to);if(u===null||f===null)return null;let m=Math.max(0,Math.min(u,f)-a/2),y=Math.min(n,Math.max(u,f)+a/2)-m;if(y<=0)return null;let b=c.label??"",h=ir(b,vs)+La*2;return jsxRuntime.jsxs("g",{children:[jsxRuntime.jsx("rect",{x:m,y:0,width:y,height:o,fill:c.color??"var(--color-chart-muted)",opacity:Xg}),b&&h<=y?jsxRuntime.jsx(ji,{x:m+2,y:2,text:b,align:"start"}):null]},`band-${d}`)})})}let l=e.filter(i=>i.type!=="band");return l.length===0?null:jsxRuntime.jsx("g",{"aria-hidden":"true",children:l.map((i,c)=>{let d=t(i.x);if(d===null)return null;let u=i.color??"var(--color-chart-muted)";if(i.type==="line"){let h=i.label??"",x=ir(h,vs)+La*2,L=d+ro+x<=n?"start":"end";return jsxRuntime.jsxs("g",{children:[jsxRuntime.jsx("line",{x1:d,y1:0,x2:d,y2:o,stroke:u,strokeWidth:1,strokeDasharray:i.dashed===false?void 0:"3 3"}),h?jsxRuntime.jsx(ji,{x:L==="start"?d+ro:d-ro,y:2,text:h,align:L}):null]},`line-${c}`)}let f=r(i.y);if(!Number.isFinite(f))return null;let m=i.label??"",g=ir(m,vs)+La*2,y=d+xs+ro+g<=n?"start":"end",b=Math.min(Math.max(0,f-ks-ro),o-ks);return jsxRuntime.jsxs("g",{children:[jsxRuntime.jsx("circle",{cx:d,cy:f,r:xs,fill:"none",stroke:u,strokeWidth:2}),m?jsxRuntime.jsx(ji,{x:y==="start"?d+xs+ro:d-xs-ro,y:b,text:m,align:y}):null]},`point-${c}`)})})}function no(e,t){if(!e||e.length===0)return "";let r=e.map(n=>n.label).filter(n=>!!n);return r.length===0?"":`${t}: ${r.join(", ")}`}var Gg=10,Ug={sm:"text-[10px]",md:"text-[11px]",lg:"text-xs"};function tt({orientation:e,ticks:t,length:r,showLine:n=true,tickSize:o=4,tickPadding:a=6,label:s,size:l="md",className:i,...c}){let d=e==="bottom";return jsxRuntime.jsxs("g",{className:p(Ug[l],i),"aria-hidden":"true",...c,children:[n&&jsxRuntime.jsx("line",{x1:0,y1:0,x2:d?r:0,y2:d?0:r,className:"stroke-gray-300 dark:stroke-gray-600",strokeWidth:1,shapeRendering:"crispEdges"}),t.map(u=>{let f=d?u.offset:0,m=d?0:u.offset;return jsxRuntime.jsxs("g",{transform:`translate(${f}, ${m})`,children:[o>0?jsxRuntime.jsx("line",{x1:0,y1:0,x2:d?0:-o,y2:d?o:0,className:"stroke-gray-300 dark:stroke-gray-600",strokeWidth:1}):null,jsxRuntime.jsx("text",{x:d?0:-(o+a),y:d?o+a:0,textAnchor:d?"middle":"end",dominantBaseline:d?"hanging":"middle",className:"fill-gray-500 dark:fill-gray-400 [font-variant-numeric:tabular-nums]",children:u.label})]},`${u.label}-${u.offset}`)}),s?jsxRuntime.jsx("text",{x:d?r/2:0,y:d?o+a+16:0,textAnchor:"middle",dominantBaseline:d?"hanging":"middle",transform:d?void 0:`translate(${-(o+a+Pr(t.map(u=>u.label))+Gg)}, ${r/2}) rotate(-90)`,className:"fill-gray-600 dark:fill-gray-300 font-medium",children:s}):null]})}function rt(e){return e instanceof Date?e.toISOString():String(e)}function Xr(e){if(e instanceof Date)return e.getTime();if(typeof e=="number")return e;let t=Number(e);return Number.isFinite(t)?t:Number.NaN}function Ir(e,t){let[r,n]=e,[o,a]=t,s=n-r,l=s===0?0:(a-o)/s,i=(c=>Number.isFinite(c)?s===0?(o+a)/2:o+(c-r)*l:Number.NaN);return Object.defineProperties(i,{domain:{value:[r,n],enumerable:true},range:{value:[o,a],enumerable:true},invert:{value:c=>l===0?r:r+(c-o)/l,enumerable:true}}),i}function bn(e,t,r={}){let{paddingInner:n=.2,paddingOuter:o=n/2}=r,[a,s]=t,l=e.length,i=l===0?0:(s-a)/Math.max(1,l-n+o*2),c=i*(1-n),d=a+(s-a-i*(l-n))/2,u=new Map;e.forEach((g,y)=>{u.has(rt(g))||u.set(rt(g),y);});let f=g=>d+i*g,m=(g=>{let y=u.get(rt(g));return y===void 0?Number.NaN:f(y)});return Object.defineProperties(m,{bandwidth:{value:c,enumerable:true},step:{value:i,enumerable:true},domain:{value:e,enumerable:true},range:{value:[a,s],enumerable:true},center:{value:g=>{let y=u.get(rt(g));return y===void 0?Number.NaN:f(y)+c/2},enumerable:true},positions:{value:()=>e.map((g,y)=>f(y)),enumerable:true},indexOf:{value:g=>u.get(rt(g))??-1,enumerable:true}}),m}function Dt(e,t){if(e.length===0)return -1;let r=0,n=Number.POSITIVE_INFINITY;for(let o=0;o<e.length;o+=1){let a=Math.abs(e[o]-t);a<n&&(n=a,r=o);}return r}var Yg=4,jg=.14;function ao({from:e,to:t,width:r,height:n,orientation:o="vertical",live:a=false,label:s}){let l=Math.max(0,Math.min(e,t)),i=Math.min(o==="vertical"?r:n,Math.max(e,t)),c=i-l;if(c<=0)return null;let d=o==="vertical",u=d?{x:l,y:0,width:c,height:n}:{x:0,y:l,width:r,height:c},f=m=>d?{x1:m,y1:0,x2:m,y2:n}:{x1:0,y1:m,x2:r,y2:m};return jsxRuntime.jsxs("g",{"aria-hidden":s?void 0:"true",role:s?"img":void 0,"aria-label":s,children:[jsxRuntime.jsx("rect",{...u,className:"fill-blue-500",opacity:jg}),[l,i].map(m=>jsxRuntime.jsx("line",{...f(m),className:"stroke-blue-600 dark:stroke-blue-400",strokeWidth:1.5,strokeDasharray:a?"3 3":void 0},m))]})}function so({enabled:e,active:t,centers:r,xValues:n,offset:o,orientation:a,onCommit:s}){let[l,i]=Cl.useState(null),c=Cl.useRef(null),d=Cl.useRef(false),u=Cl.useRef(false),f=Cl.useRef(null),m=Cl.useCallback((C,S)=>{let[v,R]=C<=S?[C,S]:[S,C];return {from:n[v],to:n[R],fromIndex:v,toIndex:R}},[n]),g=Cl.useCallback(C=>{let S=C.currentTarget.getBoundingClientRect();return a==="vertical"?C.clientX-S.left-o:C.clientY-S.top-o},[a,o]),y=Cl.useCallback(C=>{if(!e||r.length===0||C.button!==0)return;let S=g(C),v=Dt(r,S);v<0||(c.current={index:v,pixel:S},d.current=false,u.current=false,C.currentTarget.setPointerCapture?.(C.pointerId));},[e,r,g]),b=Cl.useCallback(C=>{let S=c.current;if(!e||!S)return;let v=g(C);!d.current&&Math.abs(v-S.pixel)<Yg||(d.current=true,i(m(S.index,Dt(r,v))));},[e,r,g,m]),h=Cl.useCallback(C=>{let S=c.current;if(c.current=null,!e||!S)return;if(C.currentTarget.hasPointerCapture?.(C.pointerId)&&C.currentTarget.releasePointerCapture?.(C.pointerId),!d.current){i(null),t&&s(null);return}u.current=true,d.current=false;let v=m(S.index,Dt(r,g(C)));i(null),f.current=v.fromIndex,s(v);},[e,t,r,g,m,s]),x=Cl.useCallback((C,S)=>{if(!e||r.length===0)return;if(C.key==="Escape"){f.current=null,i(null),t&&s(null);return}if(!C.shiftKey){f.current=null;return}let v=a==="vertical",R=v?"ArrowRight":"ArrowDown",N=v?"ArrowLeft":"ArrowUp";if(C.key!==R&&C.key!==N)return;let M=r.length-1,P=f.current??S??0,E=Math.min(M,Math.max(0,(S??P)+(C.key===R?1:-1)));f.current=P,s(m(P,E));},[e,t,r.length,a,m,s]),L=Cl.useCallback(()=>{let C=u.current;return u.current=false,C},[]);return {dragging:l,onPointerDown:y,onPointerMove:b,onPointerUp:h,onKeyDown:x,consumedClick:L}}var Zg={default:"stroke-gray-500 dark:stroke-gray-400",primary:"stroke-blue-600 dark:stroke-blue-500",success:"stroke-green-600 dark:stroke-green-500",warning:"stroke-yellow-500 dark:stroke-yellow-400",error:"stroke-red-600 dark:stroke-red-500",info:"stroke-cyan-600 dark:stroke-cyan-500"},Qg={default:"text-gray-700 dark:text-gray-300",primary:"text-blue-600 dark:text-blue-400",success:"text-green-600 dark:text-green-400",warning:"text-yellow-600 dark:text-yellow-400",error:"text-red-600 dark:text-red-400",info:"text-cyan-600 dark:text-cyan-400"},Jg={xs:24,sm:32,md:48,lg:64,xl:96},ef={xs:"text-[8px]",sm:"text-[10px]",md:"text-sm",lg:"text-base",xl:"text-xl"},tf={thin:2,normal:4,thick:8};function Wo({value:e=0,indeterminate:t=false,size:r="md",thickness:n="normal",color:o="primary",progressColor:a,trackColor:s,showValue:l=false,children:i,valueFormat:c,animated:d=true,className:u,...f}){let m=Math.min(100,Math.max(0,e)),g=Jg[r],y=tf[n],b=(g-y)/2,h=2*Math.PI*b,x=g/2,L=h-m/100*h,C=a||Zg[o],S=s||"stroke-gray-200 dark:stroke-gray-700",v=Qg[o],R=i??(l&&!t?jsxRuntime.jsx("span",{className:p("font-semibold",ef[r],v),children:c?c(m):`${Math.round(m)}%`}):null);return jsxRuntime.jsxs("div",{className:p("relative inline-flex items-center justify-center",u),role:"progressbar","aria-valuenow":t?void 0:m,"aria-valuemin":0,"aria-valuemax":100,...f,children:[jsxRuntime.jsxs("svg",{width:g,height:g,viewBox:`0 0 ${g} ${g}`,className:p(t&&"animate-spin"),style:{transform:"rotate(-90deg)"},children:[jsxRuntime.jsx("circle",{cx:x,cy:x,r:b,fill:"none",strokeWidth:y,className:S}),jsxRuntime.jsx("circle",{cx:x,cy:x,r:b,fill:"none",strokeWidth:y,strokeLinecap:"round",strokeDasharray:h,strokeDashoffset:t?h*.75:L,className:p(C,d&&!t&&"transition-[stroke-dashoffset] duration-300 ease-out")})]}),R&&jsxRuntime.jsx("div",{className:"absolute inset-0 flex items-center justify-center",style:{transform:"rotate(0deg)"},children:R})]})}Wo.displayName="CircularProgress";var gd=640;function qi(e={}){let{width:t,fallbackWidth:r=gd}=e,n=Cl.useRef(null),[o,a]=Cl.useState(0);return Cl.useEffect(()=>{if(t!==void 0)return;let s=n.current;if(!s)return;let l=c=>{a(d=>Math.abs(d-c)<1?d:c);};if(l(s.getBoundingClientRect().width),typeof ResizeObserver>"u")return;let i=new ResizeObserver(c=>{for(let d of c)l(d.contentRect.width);});return i.observe(s),()=>i.disconnect()},[t]),t!==void 0?{ref:n,width:t,measured:true}:{ref:n,width:o>0?o:r,measured:o>0}}var lf=jsxRuntime.jsxs("svg",{width:"20",height:"20",viewBox:"0 0 20 20",fill:"none","aria-hidden":"true",className:"text-red-600 dark:text-red-400",children:[jsxRuntime.jsx("path",{d:"M10 3.5 2.5 16.5h15L10 3.5Z",stroke:"currentColor",strokeWidth:"1.4",strokeLinejoin:"round"}),jsxRuntime.jsx("path",{d:"M10 8v3.5",stroke:"currentColor",strokeWidth:"1.4",strokeLinecap:"round"}),jsxRuntime.jsx("circle",{cx:"10",cy:"14",r:"0.9",fill:"currentColor"})]}),cf={sm:"text-xs",md:"text-sm",lg:"text-base"};function xt({title:e,description:t,height:r=240,width:n,size:o="md",legend:a,legendPosition:s="bottom",actions:l,loading:i=false,empty:c=false,emptyState:d,error:u=false,errorState:f,onRetry:m,errorLabel:g,errorHintLabel:y,retryLabel:b,table:h,tableView:x=false,showTableLabel:L,hideTableLabel:C,noDataLabel:S,loadingLabel:v,ariaLabel:R,children:N,className:M,...P}){let E=Ve(),[W,T]=Cl.useState(false),O=Cl.useId(),H=`${O}-table`,k=`${O}-title`,z=`${O}-description`,{ref:A,width:I,measured:X}=qi({width:n}),$=!!h&&x==="toggle",K=!!h&&(x===true||$&&W),G=jsxRuntime.jsx("div",{ref:A,className:"relative w-full",style:{height:r},"aria-busy":i||void 0,children:i&&(c||u)?jsxRuntime.jsx("div",{className:"flex h-full w-full items-center justify-center",children:jsxRuntime.jsx(Wo,{indeterminate:true,size:"md","aria-label":v??E.chartLoading})}):u&&!i?jsxRuntime.jsx("div",{role:"alert",className:"flex h-full w-full flex-col items-center justify-center gap-2 px-4 text-center",children:f??jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[lf,jsxRuntime.jsx("span",{className:"text-sm font-medium text-gray-900 dark:text-gray-100",children:g??E.chartError}),jsxRuntime.jsx("span",{className:"text-xs text-gray-500 dark:text-gray-400",children:y??E.chartErrorHint}),m?jsxRuntime.jsx("button",{type:"button",onClick:m,className:"mt-1 cursor-pointer rounded-md border border-gray-300 bg-white px-3 py-1.5 text-xs font-medium text-gray-700 transition-colors hover:bg-gray-50 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-blue-500 dark:border-gray-600 dark:bg-gray-800 dark:text-gray-200 dark:hover:bg-gray-700",children:b??E.chartRetry}):null]})}):c&&!i&&!u?jsxRuntime.jsx("div",{className:"flex h-full w-full items-center justify-center text-sm text-gray-500 dark:text-gray-400",children:d??S??E.chartNoData}):jsxRuntime.jsx("div",{className:p("h-full w-full transition-opacity duration-200",i&&"opacity-60"),children:typeof N=="function"?N({width:I,height:r,measured:X}):N})});return jsxRuntime.jsxs("figure",{className:p("flex w-full flex-col gap-3",M),"aria-label":R,"aria-labelledby":!R&&e?k:void 0,"aria-describedby":t?z:void 0,...P,children:[e||t||l?jsxRuntime.jsxs("figcaption",{className:"flex items-start justify-between gap-3",children:[jsxRuntime.jsxs("div",{className:"flex flex-col gap-0.5",children:[e?jsxRuntime.jsx("span",{id:k,className:p("font-semibold text-gray-900 dark:text-gray-100",cf[o]),children:e}):null,t?jsxRuntime.jsx("span",{id:z,className:"text-xs text-gray-500 dark:text-gray-400",children:t}):null]}),l]}):null,a&&s==="top"?a:null,a&&s==="right"?jsxRuntime.jsxs("div",{className:"flex items-start gap-4",children:[jsxRuntime.jsx("div",{className:"min-w-0 grow",children:G}),a]}):G,a&&s==="bottom"?a:null,$&&jsxRuntime.jsx("div",{className:"flex",children:jsxRuntime.jsx("button",{type:"button",onClick:()=>T(q=>!q),"aria-expanded":W,"aria-controls":K?H:void 0,className:"cursor-pointer rounded-sm text-xs font-medium text-gray-600 underline underline-offset-2 hover:text-gray-900 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-blue-500 dark:text-gray-400 dark:hover:text-white",children:W?C??E.chartHideTable:L??E.chartShowTable})}),K&&jsxRuntime.jsx("div",{id:H,children:h})]})}var fd=[];function Yt({width:e,height:t,horizontal:r=fd,vertical:n=fd,className:o,...a}){return jsxRuntime.jsxs("g",{className:p("stroke-gray-200 dark:stroke-gray-700",o),strokeWidth:1,shapeRendering:"crispEdges","aria-hidden":"true",...a,children:[r.map(s=>jsxRuntime.jsx("line",{x1:0,y1:s,x2:e,y2:s},`h-${s}`)),n.map(s=>jsxRuntime.jsx("line",{x1:s,y1:0,x2:s,y2:t},`v-${s}`))]})}var io="var(--color-chart-surface)",Zi=["solid","diagonal","diagonal-reverse","cross","dots","diagonal-wide","diagonal-reverse-wide","dots-wide"],yd={solid:null,diagonal:{tile:6,rotate:45,stroke:2},"diagonal-reverse":{tile:6,rotate:-45,stroke:2},cross:{tile:6,rotate:45,stroke:1.25,crossed:true},dots:{tile:6,rotate:0,stroke:0,dot:1.5},"diagonal-wide":{tile:10,rotate:45,stroke:3},"diagonal-reverse-wide":{tile:10,rotate:-45,stroke:3},"dots-wide":{tile:10,rotate:0,stroke:0,dot:2.6}};function Ps(e){return !Number.isFinite(e)||e<0?"solid":Zi[Math.floor(e)%Zi.length]}function Rs(e,t){return `${e.replace(/[^a-zA-Z0-9_-]/g,"")}-texture-${Math.max(0,Math.floor(t))}`}function lo(e,t,r,n){return !e||Ps(r)==="solid"?n:`url(#${Rs(t,r)})`}function co({id:e,entries:t}){return jsxRuntime.jsx("defs",{children:t.map(({slot:r,color:n})=>{let o=yd[Ps(r)];if(!o)return null;let{tile:a,rotate:s,stroke:l,crossed:i,dot:c}=o;return jsxRuntime.jsxs("pattern",{id:Rs(e,r),width:a,height:a,patternUnits:"userSpaceOnUse",patternTransform:s===0?void 0:`rotate(${s})`,children:[jsxRuntime.jsx("rect",{width:a,height:a,fill:n}),c?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("circle",{cx:a/4,cy:a/4,r:c,fill:io}),jsxRuntime.jsx("circle",{cx:a*3/4,cy:a*3/4,r:c,fill:io})]}):null,l>0?jsxRuntime.jsx("line",{x1:a/2,y1:0,x2:a/2,y2:a,stroke:io,strokeWidth:l}):null,i?jsxRuntime.jsx("line",{x1:0,y1:a/2,x2:a,y2:a/2,stroke:io,strokeWidth:l}):null]},Rs(e,r))})})}function Qi(e,t){let r=yd[Ps(e)];if(!r)return {backgroundColor:t};let{tile:n,rotate:o,stroke:a,crossed:s,dot:l}=r;if(l)return {backgroundColor:t,backgroundImage:`radial-gradient(${io} ${l-.4}px, transparent ${l}px)`,backgroundSize:`${n/2}px ${n/2}px`};let i=c=>`repeating-linear-gradient(${c}deg, ${io} 0 ${a}px, transparent ${a}px ${n}px)`;return {backgroundColor:t,backgroundImage:s?`${i(o)}, ${i(o+90)}`:i(o)}}var pf={line:"h-0.5 w-3 rounded-full",rect:"h-2.5 w-2.5 rounded-sm",dot:"h-2 w-2 rounded-full"},gf={sm:"text-[11px]",md:"text-xs",lg:"text-sm"};function jt({items:e,position:t="bottom",marker:r="line",onToggle:n,size:o="md",className:a,...s}){return e.length===0?null:jsxRuntime.jsx("ul",{className:p("flex list-none flex-wrap gap-x-4 gap-y-1 p-0",t==="right"?"flex-col":"flex-row",t==="top"||t==="bottom"?"justify-center":"",gf[o],a),...s,children:e.map(l=>{let i=l.pattern!==void 0&&(l.marker??r)==="rect",c=jsxRuntime.jsx("span",{className:p("shrink-0",i?"h-3 w-3.5 rounded-sm":pf[l.marker??r]),style:i?Qi(l.pattern,l.color):{backgroundColor:l.color},"aria-hidden":"true"}),d=jsxRuntime.jsx("span",{className:p(l.hidden&&"line-through"),children:l.label}),u=jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[c,d]}),f=p("flex items-center gap-1.5 text-gray-600 dark:text-gray-300",l.hidden&&"text-gray-400 dark:text-gray-500");return jsxRuntime.jsx("li",{children:n?jsxRuntime.jsx("button",{type:"button",onClick:()=>n(l.key),"aria-pressed":!l.hidden,className:p(f,"cursor-pointer rounded-sm hover:text-gray-900 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-blue-500 dark:hover:text-white"),children:u}):jsxRuntime.jsx("span",{className:f,children:u})},l.key)})})}var Ji=["7d","30d","90d","12m","mtd","ytd"];function $o(e){let t=new Date(e);return t.setHours(0,0,0,0),t}function _o(e){let t=new Date(e);return t.setHours(23,59,59,999),t}function xd(e,t=new Date){let r=_o(t),n=$o(t);switch(e){case "7d":n.setDate(n.getDate()-6);break;case "30d":n.setDate(n.getDate()-29);break;case "90d":n.setDate(n.getDate()-89);break;case "12m":n.setMonth(n.getMonth()-12),n.setDate(n.getDate()+1);break;case "mtd":n.setDate(1);break;case "qtd":n.setMonth(Math.floor(n.getMonth()/3)*3,1);break;case "ytd":n.setMonth(0,1);break;}return {from:n,to:r}}function Ma(e,t=new Date){return {preset:e,...xd(e,t)}}function el(e,t,r){let n=new Intl.DateTimeFormat(r,{day:"numeric",month:"short",year:"numeric"});if(typeof n.formatRange=="function")try{return n.formatRange(e,t)}catch{}return `${n.format(e)} \u2013 ${n.format(t)}`}function bf(e,t){return !e||!t?e===t:e.preset===t.preset&&e.from.getTime()===t.from.getTime()&&e.to.getTime()===t.to.getTime()}var wd=Cl.createContext(null);function uo(){return Cl.useContext(wd)}function Cf({children:e,hover:t=true,brush:r,defaultBrush:n=null,onBrushChange:o}){let[a,s]=Cl.useState(null),[l,i]=Cl.useState(n),c=r!==void 0,d=c?r:l,u=Cl.useCallback(g=>{if(!t)return;let y=b=>b===null?"\0":rt(b);s(b=>y(b)===y(g)?b:g);},[t]),f=Cl.useCallback(g=>{c||i(g),o?.(g);},[c,o]),m=Cl.useMemo(()=>({hovered:t?a:null,brush:d??null,hoverShared:t,setHovered:u,setBrush:f}),[t,a,d,u,f]);return jsxRuntime.jsx(wd.Provider,{value:m,children:e})}function kf(e){let t=kd(e.from),r=kd(e.to);if(!t||!r)return null;let[n,o]=t<=r?[t,r]:[r,t];return {preset:"custom",from:$o(n),to:_o(o)}}function kd(e){if(e instanceof Date)return Number.isNaN(e.getTime())?null:e;let t=new Date(e);return Number.isNaN(t.getTime())?null:t}function yn({children:e,className:t,...r}){return jsxRuntime.jsx("table",{className:p("w-full text-sm text-left rtl:text-right text-gray-500 dark:text-gray-400",t),...r,children:e})}function xn({children:e,className:t,...r}){return jsxRuntime.jsx("tbody",{className:p(t),...r,children:e})}function qt({children:e,onClick:t,hidden:r=false,className:n,...o}){return jsxRuntime.jsx("td",{className:p("px-6 py-4",n),onClick:t,hidden:r,...o,children:e})}function vn({children:e,className:t,...r}){return jsxRuntime.jsx("thead",{className:p("text-xs text-gray-700 uppercase bg-gray-50 dark:bg-gray-700 dark:text-gray-400",t),...r,children:jsxRuntime.jsx("tr",{children:e})})}function It({children:e,onClick:t,hidden:r=false,className:n,sortable:o=false,...a}){return jsxRuntime.jsx("th",{scope:"col",className:p("px-6 py-3",o&&"cursor-pointer hover:bg-gray-100 dark:hover:bg-gray-600",n),onClick:t,hidden:r,...a,children:e})}function Cn({children:e,onClick:t,clickable:r=true,className:n,...o}){return jsxRuntime.jsx("tr",{className:p("bg-white border-b dark:bg-gray-800 dark:border-gray-700",r&&"hover:bg-gray-50 hover:cursor-pointer dark:hover:bg-gray-600",n),onClick:t,...o,children:e})}var Df=8,Ts=["var(--color-chart-1)","var(--color-chart-2)","var(--color-chart-3)","var(--color-chart-4)","var(--color-chart-5)","var(--color-chart-6)","var(--color-chart-7)","var(--color-chart-8)"],Ar="var(--color-chart-muted)",rl="var(--color-chart-up)",nl="var(--color-chart-down)",po=3,Sd=false;function zr(e,t){return t||(e<0||e>=8?(Sd||(Sd=true,console.warn('[@synertech/ui] A chart was given more than 8 series. Extra series share the de-emphasis grey: fold the tail into an "Other" bucket, or split the chart, instead of relying on a ninth colour.')),Ar):Ts[e])}function Br(e,t,r){return r&&e.key!==r?Ar:zr(t,e.color)}function Vt(e){return e.label??e.key}function Gr(e,t,r=false){return e.map((n,o)=>({key:n.key,label:Vt(n),color:Br(n,o,t),hidden:n.hidden,...n.type==="line"?{marker:"line"}:{},...r&&n.type!=="line"?{pattern:o}:{}}))}var tl=["var(--color-chart-seq-1)","var(--color-chart-seq-2)","var(--color-chart-seq-3)","var(--color-chart-seq-4)","var(--color-chart-seq-5)","var(--color-chart-seq-6)"],Ia=["var(--color-chart-ord-1)","var(--color-chart-ord-2)","var(--color-chart-ord-3)","var(--color-chart-ord-4)","var(--color-chart-ord-5)"],mo=["var(--color-chart-div-1)","var(--color-chart-div-2)","var(--color-chart-div-3)","var(--color-chart-div-4)","var(--color-chart-div-5)","var(--color-chart-div-6)","var(--color-chart-div-7)"],Rd=3,Pd=[false,false,false,false,true,true],ol=[false,false,true,true,true],Td=[true,false,false,false,false,false,true],Ds=7;function Aa(e){return Number.isFinite(e)?e<0?0:e>1?1:e:0}function Xo(e,t){if(e.length===0)return Ar;if(e.length===1)return e[0];let r=Aa(t)*(e.length-1),n=Math.min(e.length-2,Math.floor(r)),o=r-n;if(o<=.005)return e[n];if(o>=.995)return e[n+1];let a=Math.round(o*1e3)/10;return `color-mix(in oklab, ${e[n+1]} ${a}%, ${e[n]})`}function Ef(e,t){return t<=1?.5:Math.min(t-1,Math.floor(Aa(e)*t))/(t-1)}function Dd(e,t,r,n,o){let a=l=>{let i=n(l);return r===null?i:Ef(i,r)},s=(l=>Number.isFinite(l)?Xo(t,a(l)):Ar);return Object.defineProperties(s,{domain:{value:[e[0],e[1]],enumerable:true},colors:{value:t,enumerable:true},steps:{value:r,enumerable:true},position:{value:l=>Number.isFinite(l)?a(l):0,enumerable:true},onDark:{value:l=>{if(!Number.isFinite(l)||o.length===0)return false;let i=Math.round(a(l)*(o.length-1));return o[i]??false},enumerable:true}}),s}function za(e,t={}){let{steps:r,colors:n=tl,darkStops:o}=t,[a,s]=e,l=s-a;return Dd(e,n,r??null,i=>l===0?0:(i-a)/l,o??(n===tl?Pd:[]))}function Go(e,t={}){let{steps:r,colors:n=mo,darkStops:o,center:a=0,symmetric:s=true}=t,[l,i]=e;if(s){let u=Math.max(Math.abs(i-a),Math.abs(a-l));l=a-u,i=a+u;}let c=n===mo?Rd:(n.length-1)/2,d=n.length-1;return Dd([l,i],n,r??null,u=>{if(u>=a){let g=i-a,y=g<=0?0:Aa((u-a)/g);return (c+y*(d-c))/d}let f=a-l,m=f<=0?0:Aa((a-u)/f);return (c-m*c)/d},o??(n===mo?Td:[]))}function Lf(e,t=Ia.length,r=Ia){return t<=1?r[r.length-1]??Ar:Xo(r,Aa(e/(t-1)))}function Ae(e,t){let r=e[t];if(r==null||r==="")return null;if(typeof r=="number")return Number.isFinite(r)?r:null;if(typeof r=="boolean")return r?1:0;if(typeof r=="string"){let n=Number(r);return Number.isFinite(n)?n:null}return null}function gt(e,t,r){let n=e[t];return n instanceof Date||typeof n=="number"||typeof n=="string"?n:n==null?r:String(n)}function vr(e,t){let r=[];for(let n of e)for(let o of t)r.push(Ae(n,o));return r}function Ba(e,t={}){if(!Number.isFinite(e))return "\u2014";let{locale:r,compact:n,currency:o,unit:a,minimumFractionDigits:s,maximumFractionDigits:l}=t,i=new Intl.NumberFormat(r,{notation:n?"compact":"standard",...o?{style:"currency",currency:o}:{},...s!==void 0?{minimumFractionDigits:s}:{},...l!==void 0?{maximumFractionDigits:l}:n?{maximumFractionDigits:1}:{}}).format(e);return a?`${i}${a}`:i}function Mf(e,t){return Ba(e,{locale:t,compact:true})}function pt(e,t){return Number.isFinite(e)?Math.abs(e)<1e4?Ba(e,{locale:t}):Mf(e,t):"\u2014"}function Zt(e,t={}){if(!Number.isFinite(e))return "\u2014";let{locale:r,maximumFractionDigits:n=1,alreadyScaled:o,signed:a}=t;return new Intl.NumberFormat(r,{style:"percent",maximumFractionDigits:n,...a?{signDisplay:"exceptZero"}:{}}).format(o?e/100:e)}function st(e,t){return e instanceof Date?new Intl.DateTimeFormat(t,{day:"2-digit",month:"short"}).format(e):typeof e=="number"?Ba(e,{locale:t}):e}function Ot({data:e,series:t,xKey:r,xLabel:n,formatX:o,formatValue:a,caption:s,emptyLabel:l,className:i,...c}){let d=t.filter(m=>!m.hidden);if(e.length===0||d.length===0)return jsxRuntime.jsx("div",{className:p("text-sm text-gray-500 dark:text-gray-400",i),...c,children:l});let u=(m,g)=>{let y=gt(m,r,g);return o?o(y,g):st(y)},f=m=>m===null?"\u2014":a?a(m):Ba(m);return jsxRuntime.jsx("div",{className:p("w-full overflow-x-auto",i),...c,children:jsxRuntime.jsxs(yn,{children:[s?jsxRuntime.jsx("caption",{className:"sr-only",children:s}):null,jsxRuntime.jsxs(vn,{children:[jsxRuntime.jsx(It,{children:n??r}),d.map(m=>jsxRuntime.jsx(It,{className:"text-right",children:Vt(m)},m.key))]}),jsxRuntime.jsx(xn,{children:e.map((m,g)=>jsxRuntime.jsxs(Cn,{clickable:false,children:[jsxRuntime.jsx(qt,{className:"font-medium text-gray-900 dark:text-gray-100",children:u(m,g)}),d.map(y=>jsxRuntime.jsx(qt,{className:"text-right [font-variant-numeric:tabular-nums]",children:f(Ae(m,y.key))},y.key))]},g))})]})})}function vt({x:e,y:t,visible:r=true,containerWidth:n,offset:o=12,className:a,style:s,children:l,...i}){if(!r)return null;let c=n!==void 0&&e>n*.6;return jsxRuntime.jsx("div",{role:"tooltip",className:p("pointer-events-none absolute top-0 left-0 z-10 min-w-24 rounded-md border border-gray-200 bg-white px-2.5 py-2 text-xs shadow-lg dark:border-gray-700 dark:bg-gray-800",a),style:{transform:`translate(${c?e-o:e+o}px, ${t}px) translate(${c?"-100%":"0"}, -50%)`,...s},...i,children:l})}function Tr({title:e,points:t}){return jsxRuntime.jsxs("div",{className:"flex flex-col gap-1",children:[e!=null&&jsxRuntime.jsx("div",{className:"font-medium text-gray-900 dark:text-gray-100",children:e}),jsxRuntime.jsx("div",{className:"flex flex-col gap-0.5",children:t.map(r=>jsxRuntime.jsxs("div",{className:"flex items-center gap-2",children:[jsxRuntime.jsx("span",{className:"h-0.5 w-3 shrink-0 rounded-full",style:{backgroundColor:r.color},"aria-hidden":"true"}),jsxRuntime.jsx("span",{className:"grow text-gray-500 dark:text-gray-400",children:r.seriesLabel}),jsxRuntime.jsx("span",{className:"font-semibold text-gray-900 [font-variant-numeric:tabular-nums] dark:text-gray-100",children:r.formattedValue})]},r.seriesKey))})]})}function Ha(e){let t=Number(e.toPrecision(12));return Object.is(t,-0)?0:t}function Ld(e){if(!Number.isFinite(e)||e<=0)return 1;let t=Math.floor(Math.log10(e)),r=Math.pow(10,t),n=e/r,o=n<=1?1:n<=2?2:n<=5?5:10;return Ha(o*r)}function Es(e,t,r=5){if(!Number.isFinite(e)||!Number.isFinite(t))return [0,1];if(e===t){if(e===0)return [0,1];let o=Math.abs(e)*.5;[e,t]=[e-o,e+o];}let n=Ld((t-e)/Math.max(1,r));return [Ha(Math.floor(e/n)*n),Ha(Math.ceil(t/n)*n)]}function Wa(e,t,r=5){if(!Number.isFinite(e)||!Number.isFinite(t))return [];if(r<=0)return [];if(e===t)return [Ha(e)];e>t&&([e,t]=[t,e]);let n=Ld((t-e)/r),o=Math.ceil(e/n),a=Math.floor(t/n),s=[];for(let l=o;l<=a&&s.length<=1e3;l+=1)s.push(Ha(l*n));return s}function Qt(e){let t=Number.POSITIVE_INFINITY,r=Number.NEGATIVE_INFINITY,n=false;for(let o of e)o==null||!Number.isFinite(o)||(n=true,o<t&&(t=o),o>r&&(r=o));return n?[t,r]:null}function Ko(e,t={}){let{domain:r,includeZero:n=true,ticks:o=5}=t;if(Array.isArray(r))return r;let a=Qt(e);if(!a)return [0,1];let[s,l]=a;return n&&(s=Math.min(s,0),l=Math.max(l,0)),Es(s,l,o)}var sl={top:10,right:16,bottom:28},Md=16,If=14,Af=32;function Jt({width:e,height:t,data:r,x:n,y:o,bounds:a,margin:s,orientation:l="vertical",placement:i="point",bandPaddingInner:c=.2,formatValue:d,formatX:u,extraTop:f=0,defaultIncludeZero:m=false}){let g=l==="vertical",y=r.map((G,q)=>gt(G,n.key,q)),b=Ko(a??[],{domain:o?.domain,includeZero:o?.includeZero??m,ticks:o?.ticks??5}),h=o?.hidden??false,x=n.hidden??false,L=h?[]:Wa(b[0],b[1],o?.ticks??5),C=L.map(d),S=g&&(n.scale==="linear"||n.scale==="time"),v=y.map((G,q)=>u(G,q)),R=g?h:x,N=g?C:v,M=g?o?.width:n.height,P=g?x:h,E=g?n.height:void 0,W=g?n.label:o?.label,T=g?o?.label:n.label,O=g&&!x&&i!=="band"?v:[],H=G=>G?ir(G)/2+4:0,k={top:s?.top??sl.top+f,right:s?.right??Math.max(sl.right,H(O[O.length-1])),bottom:s?.bottom??(P?8:E??sl.bottom+(W?Md:0)),left:s?.left??(R?8:M??Math.max(Math.max(Af,Pr(N)+If)+(T?Md:0),H(O[0])))},z=Math.max(0,e-k.left-k.right),A=Math.max(0,t-k.top-k.bottom),I=g?Ir(b,[A,0]):Ir(b,[0,z]),X=g?z:A,$,K=0,D,B=null;if(S){let G=y.map(Xr),q=Qt(G)??[0,1],j=Ir(q,[0,X]);B=j,$=G.map(U=>j(U)),D=x?[]:Wa(q[0],q[1],n.ticks??5).map(U=>({value:U,offset:j(U),label:u(n.scale==="time"?new Date(U):U,0)}));}else if(i==="band"){let G=bn(r.map((q,j)=>j),[0,X],{paddingInner:c});$=r.map((q,j)=>G(j)),K=G.bandwidth,D=[];}else {let G=r.length>1?X/(r.length-1):0;$=r.map((q,j)=>r.length>1?j*G:X/2),D=[];}let w=$.map(G=>G+K/2);if(!S&&!x){let G=g?Pr(v):15,q=Ea(v.length,X,G);D=v.map((j,U)=>({value:y[U],offset:w[U],label:j})).filter((j,U)=>U%q===0);}return {margin:k,innerWidth:z,innerHeight:A,orientation:l,valueScale:I,domain:b,valueTicks:L.map(G=>({value:G,offset:I(G),label:d(G)})),xValues:y,categoryPositions:$,bandwidth:K,categoryCenters:w,categoryTicks:D,categoryLength:X,categoryScale:B}}function On(e){let{categoryScale:t,xValues:r,categoryCenters:n,categoryLength:o}=e;return a=>{if(t){let i=t(Xr(a));return Number.isFinite(i)?i<-0.5||i>o+.5?null:i:null}let s=rt(a),l=r.findIndex(i=>rt(i)===s);return l<0?null:n[l]}}function kn({geometry:e,width:t,height:r,data:n,series:o,formatValue:a,formatX:s}){return {dimensions:{width:t,height:r,innerWidth:e.innerWidth,innerHeight:e.innerHeight,margin:e.margin},orientation:e.orientation,xAt:On(e),yAt:e.valueScale,categoryCenters:e.categoryCenters,bandwidth:e.bandwidth,xValues:e.xValues,domain:e.domain,data:n,series:o,formatValue:a,formatX:s}}function wn(e){return e?typeof e=="function"?{over:e}:e:{}}var zf=2e3;var ll=false;function Bf(){ll=false;}function Yo(e,t){t<=2e3||ll||(ll=true,console.warn(`[@synertech/ui] ${e} is drawing ${t} points in one series. Past 2000 the path costs more than it shows \u2014 pass \`maxPoints\` to draw the shape from fewer points. The data table keeps every row either way.`));}function Id(e,t){let r=e.length;if(t>=r)return e.map((l,i)=>i);if(t<3)return r===0||t<=0?[]:t===1?[0]:[0,r-1];let n=[0],o=t-2,a=(r-2)/o,s=0;for(let l=0;l<o;l+=1){let i=Math.floor((l+1)*a)+1,c=Math.min(Math.floor((l+2)*a)+1,r-1),d=0,u=0,f=0;for(let x=i;x<c;x+=1)d+=e[x].x,u+=e[x].y,f+=1;f===0?(d=e[r-1].x,u=e[r-1].y):(d/=f,u/=f);let m=Math.floor(l*a)+1,g=Math.min(Math.floor((l+1)*a)+1,r-1),y=e[s],b=m,h=-1;for(let x=m;x<g;x+=1){let L=Math.abs((y.x-d)*(e[x].y-y.y)-(y.x-e[x].x)*(u-y.y));L>h&&(h=L,b=x);}g>m&&(n.push(b),s=b);}return n.push(r-1),n}function cl(e,t){if(t>=e.length||t<1)return [...e];if(t===1)return [e[0]];let r=(e.length-1)/(t-1);return Array.from({length:t},(n,o)=>e[Math.round(o*r)])}function Ls(e,t){let r=e.map((d,u)=>u);if(t<=0||e.length<=t)return r;let n=d=>d.defined!==false&&Number.isFinite(d.x)&&Number.isFinite(d.y),o=[],a=[],s=0,l=()=>{a.length>0&&o.push({start:s,points:a}),a=[];};e.forEach((d,u)=>{n(d)?(a.length===0&&(s=u),a.push(d)):l();}),l();let i=o.reduce((d,u)=>d+u.points.length,0);if(i===0)return r;let c=[];return o.forEach((d,u)=>{u>0&&c.push(d.start-1);let f=Math.max(3,Math.round(d.points.length/i*t));for(let m of Id(d.points,f))c.push(d.start+m);}),c}function dl(e,t){return Ls(e,t).map(r=>e[r])}function Et(e){return Math.round(e*100)/100}function Ad(e){return e.defined!==false&&Number.isFinite(e.x)&&Number.isFinite(e.y)}function zd(e,t=false){if(t){let o=e.filter(Ad);return o.length>0?[o]:[]}let r=[],n=[];for(let o of e)Ad(o)?n.push(o):n.length>0&&(r.push(n),n=[]);return n.length>0&&r.push(n),r}function Hf(e){let t=e.length,r=[],n=[];for(let a=0;a<t-1;a+=1){let s=e[a+1].x-e[a].x;r.push(s),n.push(s===0?0:(e[a+1].y-e[a].y)/s);}let o=new Array(t);o[0]=n[0],o[t-1]=n[t-2];for(let a=1;a<t-1;a+=1){let s=n[a-1],l=n[a];if(s*l<=0)o[a]=0;else {let i=2*r[a]+r[a-1],c=r[a]+2*r[a-1];o[a]=(i+c)/(i/s+c/l);}}return o}function ul(e,t){if(e.length<2)return "";if(t==="monotone"&&e.length>2){let n=Hf(e),o="";for(let a=0;a<e.length-1;a+=1){let s=e[a],l=e[a+1],i=(l.x-s.x)/3;o+=` C${Et(s.x+i)},${Et(s.y+n[a]*i)} ${Et(l.x-i)},${Et(l.y-n[a+1]*i)} ${Et(l.x)},${Et(l.y)}`;}return o}let r="";for(let n=1;n<e.length;n+=1){let o=e[n-1],a=e[n];if(t==="step"){let s=Et((o.x+a.x)/2);r+=` L${s},${Et(o.y)} L${s},${Et(a.y)}`;}else t==="stepAfter"&&(r+=` L${Et(a.x)},${Et(o.y)}`);r+=` L${Et(a.x)},${Et(a.y)}`;}return r}function nn(e,t="linear",r={}){return zd(e,r.connectNulls).map(n=>{let[o]=n;return `M${Et(o.x)},${Et(o.y)}${ul(n,t)}`}).join(" ")}function Va(e,t,r="linear",n={}){let o=zd(e,n.connectNulls);if(o.length===0)return "";let a=typeof t=="number"?null:new Map(t.map(s=>[Et(s.x),s]));return o.map(s=>{let[l]=s,i=s[s.length-1],c=`M${Et(l.x)},${Et(l.y)}${ul(s,r)}`;if(a===null){let f=Et(t);return `${c} L${Et(i.x)},${f} L${Et(l.x)},${f} Z`}let d=s.map(f=>a.get(Et(f.x))).filter(f=>f!==void 0).reverse();if(d.length===0)return `${c} Z`;let[u]=d;return `${c} L${Et(u.x)},${Et(u.y)}${ul(d,r)} Z`}).join(" ")}function fr({x:e,y:t,width:r,height:n,radius:o=4,round:a="none"}){if(!(r>0)||!(n>0))return "";let s=Math.max(0,Math.min(o,r/2,n/2)),[l,i]=[Ze(e),Ze(t)],[c,d]=[Ze(e+r),Ze(t+n)];if(s===0||a==="none")return `M${l},${i} L${c},${i} L${c},${d} L${l},${d} Z`;switch(a){case "top":return `M${l},${d} L${l},${Ze(t+s)} Q${l},${i} ${Ze(e+s)},${i} L${Ze(e+r-s)},${i} Q${c},${i} ${c},${Ze(t+s)} L${c},${d} Z`;case "bottom":return `M${l},${i} L${c},${i} L${c},${Ze(t+n-s)} Q${c},${d} ${Ze(e+r-s)},${d} L${Ze(e+s)},${d} Q${l},${d} ${l},${Ze(t+n-s)} Z`;case "right":return `M${l},${i} L${Ze(e+r-s)},${i} Q${c},${i} ${c},${Ze(t+s)} L${c},${Ze(t+n-s)} Q${c},${d} ${Ze(e+r-s)},${d} L${l},${d} Z`;case "left":return `M${c},${i} L${Ze(e+s)},${i} Q${l},${i} ${l},${Ze(t+s)} L${l},${Ze(t+n-s)} Q${l},${d} ${Ze(e+s)},${d} L${c},${d} Z`;default:return `M${l},${i} L${c},${i} L${c},${d} L${l},${d} Z`}}function Ze(e){return Math.round(e*100)/100}function Fn(e,t,r,n){return {x:Ze(e+r*Math.sin(n)),y:Ze(t-r*Math.cos(n))}}function Bd({cx:e,cy:t,innerRadius:r,outerRadius:n,startAngle:o,endAngle:a}){let s=a-o;if(!(n>0)||!(s>0))return "";let l=s>=Math.PI*2-1e-9,i=Math.max(0,Math.min(r,n));if(l){let g=Fn(e,t,n,0),y=Fn(e,t,n,Math.PI),b=`M${g.x},${g.y} A${Ze(n)},${Ze(n)} 0 1 1 ${y.x},${y.y} A${Ze(n)},${Ze(n)} 0 1 1 ${g.x},${g.y} Z`;if(i===0)return b;let h=Fn(e,t,i,0),x=Fn(e,t,i,Math.PI);return `${b} M${h.x},${h.y} A${Ze(i)},${Ze(i)} 0 1 0 ${x.x},${x.y} A${Ze(i)},${Ze(i)} 0 1 0 ${h.x},${h.y} Z`}let c=s>Math.PI?1:0,d=Fn(e,t,n,o),u=Fn(e,t,n,a);if(i===0)return `M${Ze(e)},${Ze(t)} L${d.x},${d.y} A${Ze(n)},${Ze(n)} 0 ${c} 1 ${u.x},${u.y} Z`;let f=Fn(e,t,i,a),m=Fn(e,t,i,o);return `M${d.x},${d.y} A${Ze(n)},${Ze(n)} 0 ${c} 1 ${u.x},${u.y} L${f.x},${f.y} A${Ze(i)},${Ze(i)} 0 ${c} 0 ${m.x},${m.y} Z`}function Ms(e,t,r="none"){return e.map((n,o)=>{let a=t.map(d=>Ae(n,d)),s=a.reduce((d,u)=>d+(u===null?0:Math.abs(u)),0),l=0,i=0,c=t.map((d,u)=>{let f=a[u];if(r==="none")return {key:d,value:f,start:0,end:f??0};if(f===null)return {key:d,value:null,start:l,end:l};let m=r==="percent"?s===0?0:f/s*100:f;if(m>=0){let y=l;return l+=m,{key:d,value:f,start:y,end:l}}let g=i;return i+=m,{key:d,value:f,start:i,end:g}});return {index:o,datum:n,total:s,segments:c}})}function Is(e){let t=Number.POSITIVE_INFINITY,r=Number.NEGATIVE_INFINITY,n=false;for(let o of e)for(let a of o.segments)a.value!==null&&(n=true,t=Math.min(t,a.start,a.end),r=Math.max(r,a.start,a.end));return n?[t,r]:null}function Hd(e,t,r={}){let{centerKey:n,percent:o=false}=r,a=n?t.indexOf(n):-1,s=a>=0?a:Math.max(0,Math.min(t.length,r.negativeCount??Math.floor(t.length/2)));return e.map((l,i)=>{let c=t.map(h=>Ae(l,h)),d=c.reduce((h,x)=>h+(x===null?0:Math.abs(x)),0),u=c.map(h=>h===null?null:o?d===0?0:h/d*100:h),f=t.map(h=>({key:h,value:null,start:0,end:0,base:false,outer:false})),m=0;a>=0&&(m=(u[a]??0)/2,f[a]={key:t[a],value:c[a],start:m===0?0:-m,end:m,base:true,outer:false});let g=m===0?0:-m,y=-1;for(let h=s-1;h>=0;h-=1){let x=u[h];if(x===null){f[h]={...f[h],value:null,start:g,end:g};continue}let L=g-Math.abs(x);f[h]={key:t[h],value:c[h],start:g,end:L,base:a<0&&y===-1,outer:false},g=L,y=h;}y>=0&&(f[y].outer=true),g=m;let b=-1;for(let h=a>=0?a+1:s;h<t.length;h+=1){let x=u[h];if(x===null){f[h]={...f[h],value:null,start:g,end:g};continue}let L=g+Math.abs(x);f[h]={key:t[h],value:c[h],start:g,end:L,base:a<0&&b===-1,outer:false},g=L,b=h;}return b>=0?f[b].outer=true:a>=0&&(f[a].outer=true),{index:i,datum:l,total:d,segments:f}})}var Of=.12,Ff=.9,$f=10,_f=Cl.memo(function({bands:t,stacked:r,patterns:n,patternBaseId:o}){return jsxRuntime.jsx("g",{children:t.map(a=>jsxRuntime.jsxs("g",{children:[jsxRuntime.jsx("path",{d:a.area,fill:lo(n,o,a.slot,a.color),fillOpacity:r?Ff:Of,stroke:"none"}),a.gap?jsxRuntime.jsx("path",{d:a.gap,fill:"none",strokeWidth:2,className:"stroke-white dark:stroke-gray-800"}):null,jsxRuntime.jsx("path",{d:a.edge,fill:"none",stroke:a.color,strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"})]},a.key))})});function Xf({width:e,height:t,data:r,resolvedSeries:n,x:o,y:a,grid:s,size:l,curve:i,stack:c,baseline:d,connectNulls:u,referenceLines:f,annotations:m,annotationsLabel:g,patterns:y,patternBaseId:b,overlay:h,maxPoints:x,brush:L,onBrush:C,brushLabel:S,syncEnabled:v,margin:R,tooltip:N,onPointClick:M,plotLabel:P,formatValue:E,formatRaw:W,formatX:T}){let[O,H]=Cl.useState(null),k=O!==null&&O<r.length?O:null,[z,A]=Cl.useState(null),I=uo(),X=v?I:null,$=Cl.useMemo(()=>{let V=n.filter(be=>!be.hidden),oe=V.map(be=>be.key),pe=c!=="none",Te=Ms(r,oe,c),ze=pe?Is(Te):Qt([...vr(r,oe),d]),ae=Jt({width:e,height:t,data:r,x:o,y:a,bounds:ze,margin:R,placement:"point",formatValue:E,formatX:T,defaultIncludeZero:true}),re=ae.categoryCenters,ce=ae.valueScale,De=ce(pe?0:d),Ge=V.map((be,Me)=>{let Re=r.map((dr,_t)=>{let Xt=Te[_t].segments[Me];return {x:re[_t],y:Xt.value===null?Number.NaN:ce(Xt.end),defined:Xt.value!==null}}),He=r.map((dr,_t)=>{let Xt=Te[_t].segments[Me];return {x:re[_t],y:Xt.value===null?Number.NaN:ce(pe?Xt.start:d),defined:Xt.value!==null}}),Ee={connectNulls:u},$e=x&&x>0&&Re.length>x?Ls(Re,x):null,bt=$e?$e.map(dr=>Re[dr]):Re,Kt=$e?$e.map(dr=>He[dr]):He;return x||Yo("AreaChart",Re.length),{key:be.key,color:be.color,slot:be.slot,area:pe?Va(bt,Kt,i,Ee):Va(bt,De,i,Ee),edge:nn(bt,i,Ee),gap:pe&&Me>0?nn(Kt,i,Ee):""}});return {visible:V,locate:On(ae),plot:kn({geometry:ae,width:e,height:t,data:r,series:V,formatValue:E,formatX:T}),rows:Te,stacked:pe,xValues:ae.xValues,positions:re,xTicks:ae.categoryTicks,yTicks:ae.valueTicks,valueScale:ce,innerWidth:ae.innerWidth,innerHeight:ae.innerHeight,margin:ae.margin,bands:Ge}},[r,n,o,a,e,t,R,i,c,d,u,x,E,T]),K=Cl.useCallback(V=>$.visible.map((oe,pe)=>{let Te=Ae(r[V],oe.key),ze=$.rows[V].segments[pe],ae=Te===null?"\u2014":c==="percent"?`${W(Te)} (${E(ze.end-ze.start)})`:E(Te);return {seriesKey:oe.key,seriesLabel:Vt(oe),color:oe.color,value:Te,formattedValue:ae,datum:r[V]}}),[r,$.visible,$.rows,c,E,W]),D=X?X.brush:z,B=Cl.useCallback(V=>{A(V),X?.setBrush(V),C?.(V);},[X,C]),w=so({enabled:L,active:D!==null,centers:$.positions,xValues:$.xValues,offset:$.margin.left,orientation:"vertical",onCommit:B}),G=Cl.useCallback(V=>{if(w.onPointerMove(V),N===false||r.length===0)return;let oe=V.currentTarget.getBoundingClientRect(),pe=V.clientX-oe.left-$.margin.left,Te=Dt($.positions,pe);H(Te>=0?Te:null),X?.setHovered(Te>=0?$.xValues[Te]:null);},[w,N,r.length,$.margin.left,$.positions,$.xValues,X]),q=Cl.useCallback(()=>{H(null),X?.setHovered(null);},[X]),j=Cl.useCallback(V=>{if(r.length===0)return;w.onKeyDown(V,k);let oe=r.length-1,pe=k??0,Te=V.key==="ArrowRight"?Math.min(oe,pe+1):V.key==="ArrowLeft"?Math.max(0,pe-1):V.key==="Home"?0:V.key==="End"?oe:V.key==="Escape"?null:void 0;Te!==void 0&&(V.preventDefault(),H(Te),X?.setHovered(Te===null?null:$.xValues[Te]));},[r.length,k,w,X,$.xValues]),U=Cl.useCallback(()=>{if(w.consumedClick()||!M||k===null)return;let[V]=K(k);V&&M({...V,index:k,x:$.xValues[k]});},[w,M,k,K,$.xValues]),F=k!==null||!X?.hovered?null:(()=>{let V=rt(X.hovered),oe=$.xValues.findIndex(pe=>rt(pe)===V);return oe<0?null:oe})(),_=k??F,J=k===null?null:K(k),ne=_===null?[]:$.visible.map((V,oe)=>{let pe=$.rows[_].segments[oe];return pe.value===null?null:{key:V.key,color:V.color,y:$.valueScale(pe.end)}}).filter(V=>V!==null),Y=w.dragging??D,ee=(()=>{if(!Y)return null;let V=$.locate(Y.from),oe=$.locate(Y.to);return V===null||oe===null?null:{from:V,to:oe}})(),Z=wn(h),ie=k===null||J===null?null:{x:$.xValues[k],xLabel:T($.xValues[k],k),index:k,points:J};return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsxs("svg",{width:e,height:t,role:"img","aria-label":P??[$.visible.map(V=>Vt(V)).join(", "),no(m,g)].filter(Boolean).join(". "),tabIndex:0,className:p("touch-none focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-blue-500",L&&"select-none"),onPointerDown:w.onPointerDown,onPointerMove:G,onPointerUp:w.onPointerUp,onPointerCancel:w.onPointerUp,onPointerLeave:q,onKeyDown:j,onBlur:q,onClick:U,children:[y?jsxRuntime.jsx(co,{id:b,entries:n.map(V=>({slot:V.slot,color:V.color}))}):null,jsxRuntime.jsxs("g",{transform:`translate(${$.margin.left}, ${$.margin.top})`,children:[jsxRuntime.jsx(Yt,{width:$.innerWidth,height:$.innerHeight,horizontal:s==="y"||s==="both"?$.yTicks.map(V=>V.offset):void 0,vertical:s==="x"||s==="both"?$.xTicks.map(V=>V.offset):void 0}),m?jsxRuntime.jsx(rn,{layer:"under",annotations:m,xAt:$.locate,yAt:$.valueScale,width:$.innerWidth,height:$.innerHeight}):null,ee?jsxRuntime.jsx(ao,{from:ee.from,to:ee.to,width:$.innerWidth,height:$.innerHeight,live:w.dragging!==null,label:S}):null,Z.under?.($.plot),jsxRuntime.jsx(_f,{bands:$.bands,stacked:$.stacked,patterns:y&&$.stacked,patternBaseId:b}),m?jsxRuntime.jsx(rn,{annotations:m,xAt:$.locate,yAt:$.valueScale,width:$.innerWidth,height:$.innerHeight}):null,f?.map(V=>{let oe=$.valueScale(V.value),pe=oe<$f?oe+12:oe-4;return jsxRuntime.jsxs("g",{children:[jsxRuntime.jsx("line",{x1:0,y1:oe,x2:$.innerWidth,y2:oe,stroke:V.color??"var(--color-chart-muted)",strokeWidth:1,strokeDasharray:V.dashed===false?void 0:"4 4"}),V.label?jsxRuntime.jsx("text",{x:$.innerWidth,y:pe,textAnchor:"end",className:"fill-gray-500 text-[10px] dark:fill-gray-400",children:V.label}):null]},`${V.value}-${V.label??""}`)}),Z.over?.($.plot),_!==null?jsxRuntime.jsxs("g",{"aria-hidden":"true",children:[jsxRuntime.jsx("line",{x1:$.positions[_],y1:0,x2:$.positions[_],y2:$.innerHeight,className:"stroke-gray-400 dark:stroke-gray-500",strokeWidth:1,strokeDasharray:k===null?"3 3":void 0}),ne.map(V=>jsxRuntime.jsx("circle",{cx:$.positions[_],cy:V.y,r:4,fill:V.color,strokeWidth:2,className:"stroke-white dark:stroke-gray-800"},V.key))]}):null]}),jsxRuntime.jsx("g",{transform:`translate(${$.margin.left}, ${$.margin.top+$.innerHeight})`,children:o.hidden?null:jsxRuntime.jsx(tt,{orientation:"bottom",ticks:$.xTicks,length:$.innerWidth,label:o.label,size:l})}),jsxRuntime.jsx("g",{transform:`translate(${$.margin.left}, ${$.margin.top})`,children:a?.hidden?null:jsxRuntime.jsx(tt,{orientation:"left",ticks:$.yTicks,length:$.innerHeight,showLine:false,label:a?.label,size:l})})]}),ie&&N!==false?jsxRuntime.jsx(vt,{x:$.margin.left+$.positions[ie.index],y:$.margin.top+(ne.length>0?Math.min(...ne.map(V=>V.y)):$.innerHeight/2),containerWidth:e,children:typeof N=="function"?N(ie):jsxRuntime.jsx(Tr,{title:ie.xLabel,points:ie.points})}):null]})}function Gf({data:e,series:t,x:r,y:n,height:o=240,width:a,size:s="md",grid:l="y",legend:i,tooltip:c=true,tableView:d=false,emphasis:u,title:f,description:m,loading:g=false,emptyState:y,error:b=false,errorState:h,onRetry:x,actions:L,onPointClick:C,curve:S="monotone",stack:v="none",baseline:R=0,connectNulls:N=false,referenceLines:M,annotations:P,overlay:E,patterns:W=false,legendToggle:T=true,maxPoints:O,brush:H=false,onBrush:k,brushLabel:z,sync:A=true,margin:I,locale:X,plotLabel:$,className:K,...D}){let B=Ve(),[w,G]=Cl.useState(()=>new Set),q=Cl.useId(),j=Cl.useMemo(()=>t.map((V,oe)=>({...V,slot:oe,hidden:V.hidden||w.has(V.key),color:Br(V,oe,u)})),[t,w,u]),U=v==="percent",F=Cl.useMemo(()=>U?{domain:[0,100],...n}:n,[U,n]),_=Cl.useMemo(()=>n?.format??(U?V=>Zt(V,{locale:X,alreadyScaled:true,maximumFractionDigits:0}):V=>pt(V,X)),[n?.format,U,X]),J=Cl.useMemo(()=>V=>pt(V,X),[X]),ne=Cl.useMemo(()=>r.format??(V=>r.scale==="time"?st(V instanceof Date?V:new Date(Xr(V)),X):st(V,X)),[r.format,r.scale,X]),Y=Cl.useCallback(V=>{G(oe=>{let pe=new Set(oe);return pe.has(V)?pe.delete(V):pe.add(V),pe});},[]),ee=i===void 0?t.length>=2:i!==false,Z=typeof i=="string"?i:"bottom",ie=j.filter(V=>!V.hidden).length;return jsxRuntime.jsx(xt,{title:f,description:m,height:o,width:a,size:s,loading:g,empty:e.length===0||ie===0,emptyState:y,error:b,errorState:h,onRetry:x,actions:L,tableView:d,legendPosition:Z,legend:ee?jsxRuntime.jsx(jt,{items:Gr(j,u,W&&v!=="none"),position:Z,marker:"rect",size:s,onToggle:T?Y:void 0}):void 0,table:d?jsxRuntime.jsx(Ot,{data:e,series:j,xKey:r.key,xLabel:r.label??r.key,formatX:ne,formatValue:J,caption:typeof f=="string"?f:void 0}):void 0,className:K,...D,children:({width:V})=>jsxRuntime.jsx(Xf,{width:V,height:o,data:e,resolvedSeries:j,x:r,y:F,grid:l,size:s,curve:S,stack:v,baseline:R,connectNulls:N,referenceLines:M,annotations:P,annotationsLabel:B.chartAnnotations,patterns:W,patternBaseId:q,overlay:E,maxPoints:O,brush:H,onBrush:k,brushLabel:z??B.chartBrush,syncEnabled:A,margin:I,tooltip:c,onPointClick:C,plotLabel:$,formatValue:_,formatRaw:J,formatX:ne})})}var Kf={xs:"h-6 w-6 text-xs",sm:"h-8 w-8 text-sm",md:"h-10 w-10 text-base",lg:"h-12 w-12 text-lg",xl:"h-16 w-16 text-xl"},Yf={circle:"rounded-full",square:"rounded-none",rounded:"rounded-md"};function jf({src:e,alt:t="Avatar",fallback:r,size:n="md",variant:o="circle",border:a=false,className:s,...l}){return jsxRuntime.jsx("div",{className:p("inline-flex items-center justify-center overflow-hidden bg-gray-200 font-medium text-gray-600 dark:bg-gray-700 dark:text-gray-300",Kf[n],Yf[o],a&&"ring-2 ring-white dark:ring-gray-900",s),...l,children:e?jsxRuntime.jsx("img",{src:e,alt:t,className:"h-full w-full object-cover"}):jsxRuntime.jsx("span",{children:r||t.charAt(0).toUpperCase()})})}var qf={default:{solid:"bg-gray-500 text-white",soft:"bg-gray-100 text-gray-700 dark:bg-gray-700 dark:text-gray-300",outlined:"border border-gray-300 text-gray-600 dark:border-gray-600 dark:text-gray-400",subtle:"bg-gray-50 text-gray-600 dark:bg-gray-800 dark:text-gray-400"},primary:{solid:"bg-blue-600 text-white",soft:"bg-blue-100 text-blue-700 dark:bg-blue-900/50 dark:text-blue-300",outlined:"border border-blue-500 text-blue-600 dark:border-blue-400 dark:text-blue-400",subtle:"bg-blue-50 text-blue-600 dark:bg-blue-900/30 dark:text-blue-400"},success:{solid:"bg-green-600 text-white",soft:"bg-green-100 text-green-700 dark:bg-green-900/50 dark:text-green-300",outlined:"border border-green-500 text-green-600 dark:border-green-400 dark:text-green-400",subtle:"bg-green-50 text-green-600 dark:bg-green-900/30 dark:text-green-400"},warning:{solid:"bg-yellow-500 text-white",soft:"bg-yellow-100 text-yellow-700 dark:bg-yellow-900/50 dark:text-yellow-300",outlined:"border border-yellow-400 text-yellow-600 dark:border-yellow-400 dark:text-yellow-400",subtle:"bg-yellow-50 text-yellow-600 dark:bg-yellow-900/30 dark:text-yellow-400"},error:{solid:"bg-red-600 text-white",soft:"bg-red-100 text-red-700 dark:bg-red-900/50 dark:text-red-300",outlined:"border border-red-500 text-red-600 dark:border-red-400 dark:text-red-400",subtle:"bg-red-50 text-red-600 dark:bg-red-900/30 dark:text-red-400"},info:{solid:"bg-cyan-600 text-white",soft:"bg-cyan-100 text-cyan-700 dark:bg-cyan-900/50 dark:text-cyan-300",outlined:"border border-cyan-500 text-cyan-600 dark:border-cyan-400 dark:text-cyan-400",subtle:"bg-cyan-50 text-cyan-600 dark:bg-cyan-900/30 dark:text-cyan-400"},purple:{solid:"bg-purple-600 text-white",soft:"bg-purple-100 text-purple-700 dark:bg-purple-900/50 dark:text-purple-300",outlined:"border border-purple-500 text-purple-600 dark:border-purple-400 dark:text-purple-400",subtle:"bg-purple-50 text-purple-600 dark:bg-purple-900/30 dark:text-purple-400"},indigo:{solid:"bg-indigo-600 text-white",soft:"bg-indigo-100 text-indigo-700 dark:bg-indigo-900/50 dark:text-indigo-300",outlined:"border border-indigo-500 text-indigo-600 dark:border-indigo-400 dark:text-indigo-400",subtle:"bg-indigo-50 text-indigo-600 dark:bg-indigo-900/30 dark:text-indigo-400"},teal:{solid:"bg-teal-600 text-white",soft:"bg-teal-100 text-teal-700 dark:bg-teal-900/50 dark:text-teal-300",outlined:"border border-teal-500 text-teal-600 dark:border-teal-400 dark:text-teal-400",subtle:"bg-teal-50 text-teal-600 dark:bg-teal-900/30 dark:text-teal-400"}},Zf={default:"bg-gray-500",primary:"bg-blue-500",success:"bg-green-500",warning:"bg-yellow-400",error:"bg-red-500",info:"bg-cyan-500",purple:"bg-purple-500",indigo:"bg-indigo-500",teal:"bg-teal-500"},Qf={sm:"text-[10px] px-1.5 py-0.5 gap-1",md:"text-xs px-2 py-0.5 gap-1",lg:"text-sm px-2.5 py-1 gap-1.5"},Jf={sm:"w-1.5 h-1.5",md:"w-1.5 h-1.5",lg:"w-2 h-2"},e0={sm:"w-2.5 h-2.5",md:"w-3 h-3",lg:"w-3.5 h-3.5"};function Vd({children:e,color:t="default",size:r="md",variant:n="soft",dot:o=false,icon:a,pill:s=true,className:l,...i}){return jsxRuntime.jsxs("span",{className:p("inline-flex items-center font-medium",Qf[r],s?"rounded-full":"rounded",qf[t][n],l),...i,children:[o&&jsxRuntime.jsx("span",{className:p("shrink-0 rounded-full",Jf[r],Zf[t]),"aria-hidden":"true"}),a&&!o&&jsxRuntime.jsx("span",{className:p("shrink-0",e0[r]),"aria-hidden":"true",children:a}),e]})}Vd.displayName="Badge";var r0={sm:"text-[10px]",md:"text-[11px]",lg:"text-xs"};function Oa({scale:e,label:t,format:r,ticks:n=3,size:o="md",thickness:a=10,locale:s,className:l,...i}){let[c,d]=e.domain,u=r??(x=>pt(x,s)),f=e.steps,m=f!==null&&f>0,g=Math.max(2,Math.round(n)),y=m?Array.from({length:f+1},(x,L)=>L/f):Array.from({length:g},(x,L)=>L/(g-1)),b=x=>c+x*(d-c),h=m?jsxRuntime.jsx("div",{className:"flex h-full w-full overflow-hidden rounded-sm",children:Array.from({length:f},(x,L)=>jsxRuntime.jsx("span",{className:"h-full grow",style:{backgroundColor:e(b((L+.5)/f))}},L))}):jsxRuntime.jsx("div",{className:"h-full w-full rounded-sm",style:{backgroundImage:`linear-gradient(to right, ${e.colors.join(", ")})`}});return jsxRuntime.jsxs("div",{className:p("flex w-full max-w-80 flex-col gap-1",r0[o],l),...i,children:[t?jsxRuntime.jsx("span",{className:"text-gray-600 dark:text-gray-300",children:t}):null,jsxRuntime.jsx("div",{style:{height:a},"aria-hidden":"true",children:h}),jsxRuntime.jsx("div",{className:"relative h-4 w-full",children:y.map((x,L)=>jsxRuntime.jsx("span",{className:"absolute top-0 whitespace-nowrap text-gray-500 [font-variant-numeric:tabular-nums] dark:text-gray-400",style:{left:`${x*100}%`,transform:`translateX(${L===0?"0":L===y.length-1?"-100%":"-50%"})`},children:u(b(x))},x))})]})}function Od(e){return e<=1?1:Math.min(60,Math.max(1,Math.ceil(Math.log2(e))+1))}function o0(e){let t=Math.pow(10,Math.floor(Math.log10(e)));return [.5,1,2,5,10].map(r=>Number((r*t).toPrecision(12)))}function Fd(e,t=true){if(Array.isArray(t)){let m=[...t].filter(g=>Number.isFinite(g)).sort((g,y)=>g-y);return m.length>=2?m:[]}let r=e.filter(m=>Number.isFinite(m));if(r.length===0)return [];let n=Math.min(...r),o=Math.max(...r);if(n===o){let m=Math.abs(n)>0?Math.abs(n)*.5:.5;n-=m,o+=m;}let a=typeof t=="number"?t:Od(r.length),s=Math.min(60,Math.max(1,Math.round(a))),l=(o-n)/s;if(!(l>0))return [];let i=0,c=0,d=Number.POSITIVE_INFINITY;for(let m of o0(l)){let g=Math.floor(n/m)*m,y=Math.ceil(o/m)*m,b=Math.max(1,Math.round((y-g)/m));if(b>60)continue;let h=Math.abs(b-s);h<=d&&(d=h,i=m,c=b);}if(i===0)return [];let u=Math.floor(n/i)*i,f=[];for(let m=0;m<=c;m+=1)f.push(Number((u+m*i).toPrecision(12)));return f}function gl(e,t=true){let r=e.filter(a=>typeof a=="number"&&Number.isFinite(a)),n=Fd(r,t);if(n.length<2)return [];let o=[];for(let a=0;a<n.length-1;a+=1)o.push({from:n[a],to:n[a+1],count:0,last:a===n.length-2});for(let a of r){if(a<n[0]||a>n[n.length-1])continue;let s=0,l=o.length-1;for(;s<l;){let i=s+l+1>>1;a>=n[i]?s=i:l=i-1;}o[s].count+=1;}return o}var s0=24,ho=2,i0=4,Zo=6,l0=10,hl=false,bl=false;function c0(){hl=false,bl=false;}var d0=Cl.memo(function({bars:t,patterns:r,patternBaseId:n}){return jsxRuntime.jsx("g",{children:t.map((o,a)=>jsxRuntime.jsxs("g",{children:[jsxRuntime.jsx("path",{d:o.d,fill:lo(r,n,o.slot,o.color)}),o.label?jsxRuntime.jsx("text",{x:o.label.x,y:o.label.y,textAnchor:o.label.anchor,dominantBaseline:"middle",className:"fill-gray-600 text-[10px] [font-variant-numeric:tabular-nums] dark:fill-gray-300",children:o.label.text}):null]},`${o.key}-${a}`))})}),u0=Cl.memo(function({lines:t}){return jsxRuntime.jsx("g",{children:t.map(r=>jsxRuntime.jsxs("g",{children:[jsxRuntime.jsx("path",{d:r.d,fill:"none",stroke:r.color,strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round",strokeDasharray:r.dashed?"5 4":void 0}),r.markers.map(n=>jsxRuntime.jsx("circle",{cx:n.x,cy:n.y,r:3,fill:r.color,strokeWidth:2,className:"stroke-white dark:stroke-gray-800"},`${n.x}-${n.y}`))]},r.key))})});function m0({width:e,height:t,data:r,resolvedSeries:n,x:o,y:a,grid:s,size:l,orientation:i,stack:c,center:d,centerKey:u,valueColors:f,binned:m,curve:g,barSize:y,showValues:b,referenceLines:h,annotations:x,annotationsLabel:L,patterns:C,patternBaseId:S,overlay:v,brush:R,onBrush:N,brushLabel:M,syncEnabled:P,margin:E,tooltip:W,onPointClick:T,plotLabel:O,formatValue:H,formatRaw:k,formatX:z}){let[A,I]=Cl.useState(null),X=A!==null&&A<r.length?A:null,[$,K]=Cl.useState(null),D=uo(),B=P?D:null,w=Cl.useMemo(()=>{let ae=i==="vertical",re=n.filter(ye=>!ye.hidden),ce=re.filter(ye=>ye.type!=="line"),De=re.filter(ye=>ye.type==="line"),Ge=ce.map(ye=>ye.key),be=u!==null||c!=="none",Me=u!==null?Hd(r,Ge,{centerKey:u,percent:c==="percent"}):Ms(r,Ge,c),Re=be?Is(Me):Qt(vr(r,Ge)),He=Qt(vr(r,De.map(ye=>ye.key))),Ee=Re===null?He:He===null?Re:[Math.min(Re[0],He[0]),Math.max(Re[1],He[1])],$e=Jt({width:e,height:t,data:r,x:o,y:a,bounds:Ee===null?null:[Math.min(Ee[0],d),Math.max(Ee[1],d)],margin:E,orientation:i,placement:"band",bandPaddingInner:m?0:void 0,formatValue:H,formatX:z,defaultIncludeZero:d===0}),{valueScale:bt,bandwidth:Kt,categoryPositions:dr,innerWidth:_t,innerHeight:Xt}=$e,Mr=bt(d),Ce=Math.max(1,ce.length),we=be?Kt:Kt/Ce,se=Math.min(y??(m?Number.POSITIVE_INFINITY:s0),Math.max(1,we-(be&&!m?0:ho))),de=be?se:Ce*se+(Ce-1)*ho,ke=(Kt-de)/2,ve=[],Be=ye=>be?ye.end>=ye.start:ye.end>=d;Me.forEach((ye,Xe)=>{let We=-1,ut=-1;ye.segments.forEach((mt,ct)=>{mt.value!==null&&mt.outer!==false&&(Be(mt)?We=ct:ut=ct);});let ot=0,Ke=0;ye.segments.forEach((mt,ct)=>{if(mt.value===null)return;let xr=ce[ct],Pt=Be(mt),jr=bt(be?mt.start:d),hn=bt(mt.end),ar=Math.min(jr,hn),sr=Math.abs(hn-jr),te=mt.base??(Pt?ot===0:Ke===0),ue=ae?!Pt:Pt;be&&!te&&sr>ho&&(sr-=ho,ue&&(ar+=ho)),Pt?ot+=1:Ke+=1;let me=dr[Xe]+(be?ke:ke+ct*(se+ho)),xe=ct===(Pt?We:ut)?ae?Pt?"top":"bottom":Pt?"right":"left":"none",Ye=ae?{x:me,y:ar,width:se,height:sr}:{x:ar,y:me,width:sr,height:se},at=null;if(b&&!be){let et=k(mt.value),Fe=ir(et,10);if(ae){let St=Pt?ar:ar+sr,je=Pt?St-Zo:St+Zo,Mt=Ce>1?se+ho:Kt;Fe<=Mt&&(Pt?je>8:je<Xt-4)&&(at={x:me+se/2,y:je,anchor:"middle",text:et});}else {let St=Pt?ar+sr:ar,je=Pt?_t-St-Zo:St-Zo;Fe<=je&&(at={x:Pt?St+Zo:St-Zo,y:me+se/2,anchor:Pt?"start":"end",text:et});}}ve.push({key:xr.key,slot:xr.slot,color:f&&mt.value!==null?f(mt.value):xr.color,d:fr({...Ye,radius:i0,round:xe}),label:at});});});let Pe=De.map(ye=>{let Xe=$e.categoryCenters.map((We,ut)=>{let ot=Ae(r[ut],ye.key),Ke=ot===null?Number.NaN:bt(ot);return {x:ae?We:Ke,y:ae?Ke:We,defined:ot!==null}});return {key:ye.key,color:ye.color,dashed:ye.dashed,d:nn(Xe,g),markers:Xe.filter(We=>We.defined!==false)}});return {vertical:ae,visible:re,locate:On($e),barSeries:ce,rows:Me,stacked:be,plot:kn({geometry:$e,width:e,height:t,data:r,series:re,formatValue:H,formatX:z}),xValues:$e.xValues,categoryPositions:dr,categoryCenters:$e.categoryCenters,bandwidth:Kt,categoryTicks:$e.categoryTicks,valueTicks:$e.valueTicks,valueScale:bt,baseline:Mr,innerWidth:_t,innerHeight:Xt,margin:$e.margin,bars:ve,lines:Pe}},[r,n,o,a,e,t,E,i,c,d,u,f,m,g,y,b,H,k,z]),G=Cl.useCallback(ae=>w.visible.map(re=>{let ce=Ae(r[ae],re.key),De=w.barSeries.indexOf(re),Ge=De===-1?null:w.rows[ae].segments[De],be=ce===null?"\u2014":c==="percent"&&Ge!==null?`${k(ce)} (${H(Ge.end-Ge.start)})`:H(ce);return {seriesKey:re.key,seriesLabel:Vt(re),color:re.color,value:ce,formattedValue:be,datum:r[ae]}}),[r,w.visible,w.barSeries,w.rows,c,H,k]),q=B?B.brush:$,j=Cl.useCallback(ae=>{K(ae),B?.setBrush(ae),N?.(ae);},[B,N]),U=so({enabled:R,active:q!==null,centers:w.categoryCenters,xValues:w.xValues,offset:w.vertical?w.margin.left:w.margin.top,orientation:i,onCommit:j}),F=Cl.useCallback(ae=>{if(U.onPointerMove(ae),W===false||r.length===0)return;let re=ae.currentTarget.getBoundingClientRect(),ce=w.vertical?ae.clientX-re.left-w.margin.left:ae.clientY-re.top-w.margin.top,De=Dt(w.categoryCenters,ce);I(De>=0?De:null),B?.setHovered(De>=0?w.xValues[De]:null);},[U,W,r.length,w.vertical,w.margin,w.categoryCenters,w.xValues,B]),_=Cl.useCallback(()=>{I(null),B?.setHovered(null);},[B]),J=Cl.useCallback(ae=>{if(r.length===0)return;U.onKeyDown(ae,X);let re=r.length-1,ce=X??0,De=w.vertical?"ArrowRight":"ArrowDown",Ge=w.vertical?"ArrowLeft":"ArrowUp",be=ae.key===De?Math.min(re,ce+1):ae.key===Ge?Math.max(0,ce-1):ae.key==="Home"?0:ae.key==="End"?re:ae.key==="Escape"?null:void 0;be!==void 0&&(ae.preventDefault(),I(be),B?.setHovered(be===null?null:w.xValues[be]));},[r.length,X,w.vertical,U,B,w.xValues]),ne=Cl.useCallback(()=>{if(U.consumedClick()||!T||X===null)return;let[ae]=G(X);ae&&T({...ae,index:X,x:w.xValues[X]});},[U,T,X,G,w.xValues]),Y=X!==null||!B?.hovered?null:(()=>{let ae=rt(B.hovered),re=w.xValues.findIndex(ce=>rt(ce)===ae);return re<0?null:re})(),ee=X??Y,Z=U.dragging??q,ie=(()=>{if(!Z)return null;let ae=w.locate(Z.from),re=w.locate(Z.to);if(ae===null||re===null)return null;let ce=w.bandwidth/2;return {from:Math.min(ae,re)-ce,to:Math.max(ae,re)+ce}})(),V=wn(v),oe=X===null?null:G(X),pe=X===null||oe===null?null:{x:w.xValues[X],xLabel:z(w.xValues[X],X),index:X,points:oe},Te=ae=>{let re=w.rows[ae].segments.filter(ce=>ce.value!==null).map(ce=>w.valueScale(ce.end));for(let ce of w.lines){let De=Ae(r[ae],ce.key);De!==null&&re.push(w.valueScale(De));}return re},ze=X===null?null:w.vertical?{x:w.margin.left+w.categoryCenters[X],y:w.margin.top+Math.min(...Te(X),w.baseline)}:{x:w.margin.left+Math.max(...Te(X),w.baseline),y:w.margin.top+w.categoryCenters[X]};return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsxs("svg",{width:e,height:t,role:"img","aria-label":O??[w.visible.map(ae=>Vt(ae)).join(", "),no(x,L)].filter(Boolean).join(". "),tabIndex:0,className:p("touch-none focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-blue-500",R&&"select-none"),onPointerDown:U.onPointerDown,onPointerMove:F,onPointerUp:U.onPointerUp,onPointerCancel:U.onPointerUp,onPointerLeave:_,onKeyDown:J,onBlur:_,onClick:ne,children:[C?jsxRuntime.jsx(co,{id:S,entries:n.map(ae=>({slot:ae.slot,color:ae.color}))}):null,jsxRuntime.jsxs("g",{transform:`translate(${w.margin.left}, ${w.margin.top})`,children:[jsxRuntime.jsx(Yt,{width:w.innerWidth,height:w.innerHeight,horizontal:w.vertical&&(s==="y"||s==="both")?w.valueTicks.map(ae=>ae.offset):void 0,vertical:!w.vertical&&(s==="y"||s==="both")?w.valueTicks.map(ae=>ae.offset):void 0}),x?jsxRuntime.jsx(rn,{layer:"under",annotations:x,xAt:w.locate,yAt:w.valueScale,width:w.innerWidth,height:w.innerHeight,bandwidth:w.bandwidth}):null,ie?jsxRuntime.jsx(ao,{from:ie.from,to:ie.to,width:w.innerWidth,height:w.innerHeight,orientation:i,live:U.dragging!==null,label:M}):null,ee!==null?jsxRuntime.jsx("rect",{x:w.vertical?w.categoryPositions[ee]:0,y:w.vertical?0:w.categoryPositions[ee],width:w.vertical?w.bandwidth:w.innerWidth,height:w.vertical?w.innerHeight:w.bandwidth,className:"fill-gray-400 dark:fill-gray-500",opacity:.12,"aria-hidden":"true"}):null,V.under?.(w.plot),jsxRuntime.jsx(d0,{bars:w.bars,patterns:C,patternBaseId:S}),w.lines.length>0?jsxRuntime.jsx(u0,{lines:w.lines}):null,jsxRuntime.jsx("line",{x1:w.vertical?0:w.baseline,y1:w.vertical?w.baseline:0,x2:w.vertical?w.innerWidth:w.baseline,y2:w.vertical?w.baseline:w.innerHeight,className:"stroke-gray-300 dark:stroke-gray-600",strokeWidth:1,shapeRendering:"crispEdges"}),x?jsxRuntime.jsx(rn,{annotations:x,xAt:w.locate,yAt:w.valueScale,width:w.innerWidth,height:w.innerHeight,bandwidth:w.bandwidth}):null,V.over?.(w.plot),h?.map(ae=>{let re=w.valueScale(ae.value),ce=re<l0?re+12:re-4;return jsxRuntime.jsxs("g",{children:[jsxRuntime.jsx("line",{x1:w.vertical?0:re,y1:w.vertical?re:0,x2:w.vertical?w.innerWidth:re,y2:w.vertical?re:w.innerHeight,stroke:ae.color??"var(--color-chart-muted)",strokeWidth:1,strokeDasharray:ae.dashed===false?void 0:"4 4"}),ae.label?jsxRuntime.jsx("text",{x:w.vertical?w.innerWidth:re+4,y:w.vertical?ce:8,textAnchor:w.vertical?"end":"start",className:"fill-gray-500 text-[10px] dark:fill-gray-400",children:ae.label}):null]},`${ae.value}-${ae.label??""}`)})]}),jsxRuntime.jsx("g",{transform:`translate(${w.margin.left}, ${w.margin.top+w.innerHeight})`,children:(w.vertical?o.hidden:a?.hidden)?null:jsxRuntime.jsx(tt,{orientation:"bottom",ticks:w.vertical?w.categoryTicks:w.valueTicks,length:w.innerWidth,label:w.vertical?o.label:a?.label,size:l})}),jsxRuntime.jsx("g",{transform:`translate(${w.margin.left}, ${w.margin.top})`,children:(w.vertical?a?.hidden:o.hidden)?null:jsxRuntime.jsx(tt,{orientation:"left",ticks:w.vertical?w.valueTicks:w.categoryTicks,length:w.innerHeight,showLine:false,label:w.vertical?a?.label:o.label,size:l})})]}),pe&&ze&&W!==false?jsxRuntime.jsx(vt,{x:ze.x,y:ze.y,containerWidth:e,children:typeof W=="function"?W(pe):jsxRuntime.jsx(Tr,{title:pe.xLabel,points:pe.points})}):null]})}function p0({data:e,series:t,x:r,y:n,height:o=260,width:a,size:s="md",grid:l="y",legend:i,tooltip:c=true,tableView:d=false,emphasis:u,title:f,description:m,loading:g=false,emptyState:y,error:b=false,errorState:h,onRetry:x,actions:L,onPointClick:C,orientation:S="vertical",stack:v="none",diverging:R,bins:N,curve:M="linear",barSize:P,sort:E="none",showValues:W=false,referenceLines:T,annotations:O,overlay:H,patterns:k=false,legendToggle:z=true,brush:A=false,onBrush:I,brushLabel:X,sync:$=true,margin:K,locale:D,plotLabel:B,className:w,...G}){let q=Ve(),[j,U]=Cl.useState(()=>new Set),F=Cl.useId(),_=N!==void 0&&N!==false,J=_||typeof R!="string"?null:R,ne=!_&&typeof R=="number"?R:0,Y=Cl.useMemo(()=>{let Re=J===null?null:Go([0,Math.max(1,t.length-1)],{center:Math.max(0,t.findIndex(He=>He.key===J)),symmetric:false});return t.map((He,Ee)=>({...He,slot:Ee,hidden:He.hidden||j.has(He.key),color:Re&&!He.color&&!u?He.key===J?Ar:Re(Ee):Br(He,Ee,u)}))},[t,j,u,J]),ee=Cl.useMemo(()=>Re=>pt(Re,D),[D]),Z=Cl.useMemo(()=>{if(!_)return null;t.length>1&&!hl&&(hl=true,console.warn("[@synertech/ui] BarChart was given `bins` and more than one series. A histogram counts a single field \u2014 the extra series are ignored. Facet the chart, or draw the distributions side by side."));let Re=t[0]?.key??"count",He=r.format?$e=>r.format($e,0):$e=>ee($e),Ee=gl(e.map($e=>Ae($e,r.key)),N);return {rows:Ee.map($e=>({[r.key]:$e.from,[Re]:$e.count})),labels:Ee.map($e=>`${He($e.from)}\u2013${He($e.to)}`)}},[_,N,e,r.key,r.format,t,ee]),ie=Cl.useMemo(()=>{if(Z)return Z.rows;if(E==="none")return e;let Re=Y.filter(Ee=>!Ee.hidden).map(Ee=>Ee.key),He=Ee=>Re.reduce(($e,bt)=>$e+(Ae(Ee,bt)??0),0);return [...e].sort((Ee,$e)=>E==="asc"?He(Ee)-He($e):He($e)-He(Ee))},[Z,e,E,Y]),V=!_&&v==="percent",oe=Cl.useMemo(()=>V?{domain:J===null?[0,100]:[-100,100],...n}:n,[V,J,n]),pe=Cl.useMemo(()=>{let Re=n?.format??(V?He=>Zt(He,{locale:D,alreadyScaled:true,maximumFractionDigits:0}):ee);return J===null?Re:He=>Re(Math.abs(He))},[n?.format,V,D,ee,J]),Te=Cl.useMemo(()=>Z?(Re,He)=>Z.labels[He]??"":r.format??(Re=>st(Re,D)),[Z,r.format,D]),ze=Cl.useMemo(()=>Z?{...r,scale:"category"}:r,[Z,r]),ae=Cl.useCallback(Re=>{U(He=>{let Ee=new Set(He);return Ee.has(Re)?Ee.delete(Re):Ee.add(Re),Ee});},[]),re=S==="vertical"?O:void 0;O&&S!=="vertical"&&!bl&&(bl=true,console.warn("[@synertech/ui] BarChart was given `annotations` and a horizontal orientation. Annotations are read on the category axis, which runs up the side there: they are ignored. Use `referenceLines` for a threshold on the value axis."));let ce=i===void 0?t.length>=2:i!==false,De=typeof i=="string"?i:"bottom",Ge=Y.filter(Re=>!Re.hidden),be=Ge.length,Me=Cl.useMemo(()=>{if(_||R===void 0||R===false||J!==null||be!==1)return null;let Re=vr(ie,Ge.map(Ee=>Ee.key)),He=Ko([...Re,ne],{domain:n?.domain,includeZero:n?.includeZero??ne===0,ticks:n?.ticks??5});return Go(He,{center:ne})},[_,R,J,be,Ge,ie,ne,n]);return jsxRuntime.jsx(xt,{title:f,description:m,height:o,width:a,size:s,loading:g,empty:ie.length===0||be===0,emptyState:y,error:b,errorState:h,onRetry:x,actions:L,tableView:d,legendPosition:De,legend:Me?jsxRuntime.jsx(Oa,{scale:Me,label:n?.label,format:pe,size:s,locale:D}):ce?jsxRuntime.jsx(jt,{items:Gr(Y,u,k),position:De,marker:"rect",size:s,onToggle:z?ae:void 0}):void 0,table:d?jsxRuntime.jsx(Ot,{data:ie,series:Y,xKey:ze.key,xLabel:r.label??r.key,formatX:Te,formatValue:ee,caption:typeof f=="string"?f:void 0}):void 0,className:w,...G,children:({width:Re})=>jsxRuntime.jsx(m0,{width:Re,height:o,data:ie,resolvedSeries:Y,x:ze,y:oe,grid:l,size:s,orientation:S,stack:_?"none":v,center:ne,centerKey:J,valueColors:Me,binned:_,curve:M,barSize:P,showValues:W,referenceLines:T,annotations:re,annotationsLabel:q.chartAnnotations,patterns:k&&Me===null,patternBaseId:F,overlay:H,brush:A,onBrush:I,brushLabel:X??q.chartBrush,syncEnabled:$,margin:K,tooltip:c,onPointClick:C,plotLabel:B,formatValue:pe,formatRaw:ee,formatX:Te})})}function _d({className:e}){return jsxRuntime.jsx("svg",{className:e,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",children:jsxRuntime.jsx("path",{d:"M13 16H12V12H11M12 8H12.01M21 12C21 16.97 16.97 21 12 21C7.03 21 3 16.97 3 12C3 7.03 7.03 3 12 3C16.97 3 21 7.03 21 12Z",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})})}function f0({className:e}){return jsxRuntime.jsx("svg",{className:e,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",children:jsxRuntime.jsx("path",{d:"M9 12L11 14L15 10M21 12C21 16.97 16.97 21 12 21C7.03 21 3 16.97 3 12C3 7.03 7.03 3 12 3C16.97 3 21 7.03 21 12Z",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})})}function h0({className:e}){return jsxRuntime.jsx("svg",{className:e,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",children:jsxRuntime.jsx("path",{d:"M12 9V13M12 17H12.01M10.29 3.86L1.82 18C1.65 18.3 1.55 18.65 1.55 18.99C1.55 19.34 1.64 19.69 1.81 19.99C1.99 20.29 2.24 20.55 2.54 20.72C2.84 20.901 3.18 20.99 3.53 21H20.47C20.82 20.99 21.16 20.901 21.46 20.72C21.76 20.55 22.01 20.29 22.19 19.99C22.36 19.69 22.449 19.34 22.448 18.99C22.447 18.65 22.35 18.3 22.18 18L13.71 3.86C13.53 3.57 13.28 3.32 12.98 3.15C12.68 2.99 12.34 2.9 12 2.9C11.66 2.9 11.32 2.99 11.02 3.15C10.72 3.32 10.47 3.57 10.29 3.86Z",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})})}function b0({className:e}){return jsxRuntime.jsx("svg",{className:e,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",children:jsxRuntime.jsx("path",{d:"M12 8V12M12 16H12.01M21 12C21 16.97 16.97 21 12 21C7.03 21 3 16.97 3 12C3 7.03 7.03 3 12 3C16.97 3 21 7.03 21 12Z",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})})}function xl({className:e}){return jsxRuntime.jsx("svg",{className:e,viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",children:jsxRuntime.jsx("path",{d:"M4 4L12 12M12 4L4 12",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})})}var y0={info:_d,success:f0,warning:h0,error:b0,default:_d},x0={info:"bg-blue-50 text-blue-800 border-blue-200 dark:bg-blue-900/20 dark:text-blue-300 dark:border-blue-800",success:"bg-green-50 text-green-800 border-green-200 dark:bg-green-900/20 dark:text-green-300 dark:border-green-800",warning:"bg-yellow-50 text-yellow-800 border-yellow-200 dark:bg-yellow-900/20 dark:text-yellow-300 dark:border-yellow-800",error:"bg-red-50 text-red-800 border-red-200 dark:bg-red-900/20 dark:text-red-300 dark:border-red-800",default:"bg-gray-50 text-gray-800 border-gray-200 dark:bg-gray-800 dark:text-gray-300 dark:border-gray-700"},v0={info:"text-blue-600 dark:text-blue-400",success:"text-green-600 dark:text-green-400",warning:"text-yellow-600 dark:text-yellow-400",error:"text-red-600 dark:text-red-400",default:"text-gray-600 dark:text-gray-400"};function C0({type:e="default",title:t,description:r,children:n,icon:o,action:a,closable:s=false,onClose:l,fullWidth:i=false,className:c,...d}){let[u,f]=Cl.useState(true);if(!u)return null;let m=()=>{f(false),l?.();},g=y0[e],y=n??r;return jsxRuntime.jsxs("div",{role:"alert",className:p("flex items-start gap-3 border px-4 py-3",i?"w-full":"rounded-lg",x0[e],c),...d,children:[jsxRuntime.jsx("div",{className:p("shrink-0 mt-0.5",v0[e]),children:o??jsxRuntime.jsx(g,{className:"w-5 h-5"})}),jsxRuntime.jsxs("div",{className:"flex-1 min-w-0",children:[t&&jsxRuntime.jsx("div",{className:"font-semibold text-sm",children:t}),y&&jsxRuntime.jsx("div",{className:p("text-sm",t?"mt-1 opacity-90":false),children:y}),a&&jsxRuntime.jsx("div",{className:"mt-3",children:a})]}),s&&jsxRuntime.jsx("button",{type:"button",onClick:m,className:p("shrink-0 rounded-md p-1 transition-colors","hover:bg-black/10 dark:hover:bg-white/10","focus:outline-none focus-visible:ring-2 focus-visible:ring-offset-2 focus-visible:ring-current"),"aria-label":"Close banner",children:jsxRuntime.jsx(xl,{className:"w-4 h-4"})})]})}function k0({title:e,description:t,children:r,action:n,backgroundImage:o,closable:a=false,onClose:s,fullWidth:l=false,className:i,...c}){let[d,u]=Cl.useState(true);if(!d)return null;let f=()=>{u(false),s?.();},m=r??t;return jsxRuntime.jsxs("div",{className:p("relative overflow-hidden bg-gray-900 text-white",l?"w-full":"rounded-xl","py-12 px-6 sm:px-12",i),style:o?{backgroundImage:`url(${o})`,backgroundSize:"cover",backgroundPosition:"center"}:void 0,...c,children:[o&&jsxRuntime.jsx("div",{className:"absolute inset-0 bg-black/50","aria-hidden":"true"}),jsxRuntime.jsxs("div",{className:"relative z-10 max-w-3xl mx-auto text-center",children:[e&&jsxRuntime.jsx("h2",{className:"text-2xl sm:text-3xl lg:text-4xl font-bold tracking-tight",children:e}),m&&jsxRuntime.jsx("div",{className:p("text-base sm:text-lg opacity-90",e?"mt-4":false),children:m}),n&&jsxRuntime.jsx("div",{className:"mt-6",children:n})]}),a&&jsxRuntime.jsx("button",{type:"button",onClick:f,className:p("absolute top-4 right-4 z-10 rounded-md p-1.5 text-white/80 transition-colors","hover:text-white hover:bg-white/10","focus:outline-none focus-visible:ring-2 focus-visible:ring-offset-2 focus-visible:ring-white"),"aria-label":"Close banner",children:jsxRuntime.jsx(xl,{className:"w-5 h-5"})})]})}function w0({title:e,description:t,children:r,icon:n,action:o,badge:a,closable:s=false,onClose:l,fullWidth:i=false,className:c,...d}){let[u,f]=Cl.useState(true);if(!u)return null;let m=()=>{f(false),l?.();},g=r??t;return jsxRuntime.jsxs("div",{className:p("relative flex items-center gap-4 bg-linear-to-r from-indigo-600 to-purple-600 text-white px-4 py-3",i?"w-full":"rounded-lg",c),...d,children:[n&&jsxRuntime.jsx("div",{className:"shrink-0",children:n}),a&&jsxRuntime.jsx("span",{className:"shrink-0 inline-flex items-center rounded-full bg-white/20 px-2.5 py-0.5 text-xs font-semibold uppercase tracking-wide",children:a}),jsxRuntime.jsxs("div",{className:"flex-1 min-w-0 flex flex-wrap items-center gap-x-4 gap-y-1",children:[e&&jsxRuntime.jsx("span",{className:"font-semibold text-sm",children:e}),g&&jsxRuntime.jsx("span",{className:"text-sm opacity-90",children:g})]}),o&&jsxRuntime.jsx("div",{className:"shrink-0",children:o}),s&&jsxRuntime.jsx("button",{type:"button",onClick:m,className:p("shrink-0 rounded-md p-1 text-white/80 transition-colors","hover:text-white hover:bg-white/10","focus:outline-none focus-visible:ring-2 focus-visible:ring-offset-2 focus-visible:ring-white"),"aria-label":"Close banner",children:jsxRuntime.jsx(xl,{className:"w-4 h-4"})})]})}function Xd({variant:e="notification",...t}){switch(e){case "hero":return jsxRuntime.jsx(k0,{...t});case "promotion":return jsxRuntime.jsx(w0,{...t});default:return jsxRuntime.jsx(C0,{...t})}}Xd.displayName="Banner";var N0={sm:"text-xs",md:"text-sm",lg:"text-base"};function S0({items:e,separator:t="/",size:r="md",maxItems:n,itemColor:o="text-gray-500 hover:text-gray-900 dark:text-gray-400 dark:hover:text-gray-100",activeColor:a="text-gray-700 font-medium dark:text-gray-200",separatorColor:s="text-gray-400 dark:text-gray-500",className:l,...i}){let c=e,d=false;if(n&&e.length>n){d=true;let u=e[0],f=e.slice(-(n-1));c=[u,...f];}return jsxRuntime.jsx("nav",{"aria-label":"Breadcrumb",className:p("inline-flex items-center",N0[r],l),...i,children:jsxRuntime.jsx("ol",{className:"inline-flex items-center space-x-1 md:space-x-2",children:c.map((u,f)=>{let m=f===c.length-1;return jsxRuntime.jsxs("li",{className:"inline-flex items-center",children:[d&&f===1&&jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("span",{className:p("mx-1 select-none",s),children:"..."}),jsxRuntime.jsx("span",{className:p("mx-1 select-none",s),"aria-hidden":"true",children:t})]}),u.href||u.onClick?jsxRuntime.jsxs("a",{href:u.href,onClick:u.onClick,className:p("inline-flex items-center gap-1.5 transition-colors",m?a:o),"aria-current":m?"page":void 0,children:[u.icon&&jsxRuntime.jsx("span",{className:"inline-flex","aria-hidden":"true",children:u.icon}),jsxRuntime.jsx("span",{children:u.label})]}):jsxRuntime.jsxs("span",{className:p("inline-flex items-center gap-1.5",m?a:o),"aria-current":m?"page":void 0,children:[u.icon&&jsxRuntime.jsx("span",{className:"inline-flex","aria-hidden":"true",children:u.icon}),jsxRuntime.jsx("span",{children:u.label})]}),!m&&jsxRuntime.jsx("span",{className:p("mx-2 select-none",s),"aria-hidden":"true",children:t})]},u.href??u.label)})})})}var D0=22,E0=.42,Gd=3,Ud=8,L0=12,M0=["fill-gray-300 dark:fill-gray-500","fill-gray-200 dark:fill-gray-600","fill-gray-100 dark:fill-gray-700","fill-gray-50 dark:fill-gray-800"],I0=Cl.memo(function({rows:t,color:r}){return jsxRuntime.jsx("g",{children:t.map(n=>jsxRuntime.jsxs("g",{children:[n.bands.map(o=>jsxRuntime.jsx("path",{d:o.d,className:o.className,fill:o.fill},o.key)),n.measure?jsxRuntime.jsx("path",{d:n.measure,fill:r}):null,n.target?jsxRuntime.jsx("line",{x1:n.target.x,y1:n.target.y1,x2:n.target.x,y2:n.target.y2,strokeWidth:2,strokeLinecap:"round",className:"stroke-gray-900 dark:stroke-white"}):null,n.label?jsxRuntime.jsx("text",{x:n.label.x,y:n.label.y,dominantBaseline:"middle",className:"fill-gray-700 text-[11px] font-medium [font-variant-numeric:tabular-nums] dark:fill-gray-200",children:n.label.text}):null]},n.key))})});function A0({width:e,height:t,rows:r,x:n,size:o,sharedDomain:a,showValues:s,trackSize:l,rangeColors:i,color:c,tooltip:d,plotLabel:u,formatValue:f,onRowClick:m}){let[g,y]=Cl.useState(null),b=Cl.useMemo(()=>{let S=r.map(A=>A.label),v=s?r.map(A=>A.formattedValue):[],R={top:6,right:s?Pr(v)+Ud*2:8,bottom:a?26+(n.label?16:0):6,left:n.hidden?8:n.height??Pr(S)+L0},N=Math.max(0,e-R.left-R.right),M=Math.max(0,t-R.top-R.bottom),P=bn(r.map((A,I)=>I),[0,M],{paddingInner:.34}),E=Math.min(l??D0,P.bandwidth),W=Math.max(3,E*E0),T=i??M0,O=i!==void 0,H=r.map((A,I)=>{let X=Math.max(0,A.value??0,A.target??0,...A.ranges.length>0?A.ranges:[0]),$=a??(A.ranges.length>0?[0,X]:Es(0,X,4)),K=Ir($,[0,N]),D=P(I)+(P.bandwidth-E)/2,B=D+E/2,w=A.ranges.length>0?[...A.ranges].sort((U,F)=>U-F):[$[1]],G=$[0],q=w.map((U,F)=>{let _=K(G),J=K(Math.max(G,U));G=U;let ne=T[Math.min(F,T.length-1)];return {key:`${I}-${F}`,d:fr({x:_,y:D,width:Math.max(0,J-_),height:E,radius:0}),className:O?void 0:ne,fill:O?ne:void 0}}),j=A.value===null?null:fr({x:K($[0]),y:B-W/2,width:Math.max(0,K(A.value)-K($[0])),height:W,radius:2,round:"right"});return {key:`${I}`,bands:q,measure:j,target:A.target===null?null:{x:K(A.target),y1:D-Gd,y2:D+E+Gd},label:s?{x:N+Ud,y:B,text:A.formattedValue}:null,top:P(I),height:P.bandwidth}}),k=n.hidden?[]:r.map((A,I)=>({value:A.x,offset:P.center(I),label:A.label})),z=a?Wa(a[0],a[1],5).map(A=>({value:A,offset:Ir(a,[0,N])(A),label:f(A)})):[];return {margin:R,innerWidth:N,innerHeight:M,band:P,rendered:H,categoryTicks:k,valueTicks:z,centers:r.map((A,I)=>P.center(I))}},[r,n,e,t,a,s,l,i,f]),h=Cl.useCallback(S=>{if(d===false||r.length===0)return;let v=S.currentTarget.getBoundingClientRect(),R=S.clientY-v.top-b.margin.top;y(Dt(b.centers,R));},[d,r.length,b.margin.top,b.centers]),x=Cl.useCallback(S=>{if(r.length===0)return;let v=r.length-1,R=g??0,N=S.key==="ArrowDown"?Math.min(v,R+1):S.key==="ArrowUp"?Math.max(0,R-1):S.key==="Home"?0:S.key==="End"?v:S.key==="Escape"?null:void 0;N!==void 0&&(S.preventDefault(),y(N));},[r.length,g]),L=Cl.useCallback(()=>{!m||g===null||m(r[g]);},[m,g,r]),C=g===null?null:r[g];return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsxs("svg",{width:e,height:t,role:"img","aria-label":u??r.map(S=>S.label).join(", "),tabIndex:0,className:"touch-none focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-blue-500",onPointerMove:h,onPointerLeave:()=>y(null),onKeyDown:x,onBlur:()=>y(null),onClick:L,children:[jsxRuntime.jsxs("g",{transform:`translate(${b.margin.left}, ${b.margin.top})`,children:[g!==null&&b.rendered[g]?jsxRuntime.jsx("rect",{x:-4,y:b.rendered[g].top,width:b.innerWidth+8,height:b.rendered[g].height,rx:4,className:"fill-gray-400 dark:fill-gray-500",opacity:.12,"aria-hidden":"true"}):null,jsxRuntime.jsx(I0,{rows:b.rendered,color:c})]}),jsxRuntime.jsx("g",{transform:`translate(${b.margin.left}, ${b.margin.top})`,children:n.hidden?null:jsxRuntime.jsx(tt,{orientation:"left",ticks:b.categoryTicks,length:b.innerHeight,showLine:false,tickSize:0,size:o})}),a?jsxRuntime.jsx("g",{transform:`translate(${b.margin.left}, ${b.margin.top+b.innerHeight})`,children:jsxRuntime.jsx(tt,{orientation:"bottom",ticks:b.valueTicks,length:b.innerWidth,label:n.label,size:o})}):null]}),C&&g!==null&&d!==false?jsxRuntime.jsx(vt,{x:b.margin.left+b.innerWidth/2,y:b.margin.top+b.centers[g],containerWidth:e,children:typeof d=="function"?d(C):jsxRuntime.jsxs("div",{className:"flex flex-col gap-1",children:[jsxRuntime.jsx("div",{className:"font-medium text-gray-900 dark:text-gray-100",children:C.label}),jsxRuntime.jsxs("div",{className:"flex items-center gap-2",children:[jsxRuntime.jsx("span",{className:"h-0.5 w-3 shrink-0 rounded-full",style:{backgroundColor:c},"aria-hidden":"true"}),jsxRuntime.jsx("span",{className:"font-semibold text-gray-900 [font-variant-numeric:tabular-nums] dark:text-gray-100",children:C.formattedValue}),C.attainment!==null?jsxRuntime.jsx("span",{className:"text-gray-500 [font-variant-numeric:tabular-nums] dark:text-gray-400",children:Zt(C.attainment)}):null]})]})}):null]})}function z0({data:e,x:t,value:r,target:n,ranges:o,domain:a,normalize:s="row",showValues:l=true,trackSize:i,rangeColors:c,color:d,height:u,width:f,size:m="md",tooltip:g=true,tableView:y=false,title:b,description:h,loading:x=false,emptyState:L,error:C=false,errorState:S,onRetry:v,actions:R,locale:N,plotLabel:M,valueLabel:P,targetLabel:E,format:W,onRowClick:T,className:O,...H}){let k=Ve(),z=Cl.useMemo(()=>W??(B=>pt(B,N)),[W,N]),A=Cl.useMemo(()=>t.format??(B=>st(B,N)),[t.format,N]),I=Cl.useMemo(()=>e.map((B,w)=>{let G=gt(B,t.key,w),q=Ae(B,r),j=n?Ae(B,n):null,U=o?B[o]:void 0,F=Array.isArray(U)?U.map(_=>typeof _=="number"?_:Number(_)).filter(_=>Number.isFinite(_)):[];return {index:w,x:G,label:A(G,w),value:q,target:j,ranges:F,formattedValue:q===null?"\u2014":z(q),formattedTarget:j===null?"\u2014":z(j),attainment:q===null||j===null||j===0?null:q/j,datum:B}}),[e,t.key,r,n,o,z,A]),X=Cl.useMemo(()=>{if(a)return a;if(s!=="shared")return null;let B=I.reduce((w,G)=>Math.max(w,G.value??0,G.target??0,...G.ranges),0);return Es(0,B,5)},[a,s,I]),$=u??Math.max(72,I.length*34+(X?30:12)),K=Cl.useMemo(()=>[{key:r,label:P??k.chartValue},...n?[{key:n,label:E??k.chartTarget}]:[]],[r,n,P,E,k.chartValue,k.chartTarget]),D=d??zr(0);return jsxRuntime.jsx(xt,{title:b,description:h,height:$,width:f,size:m,loading:x,empty:I.length===0,emptyState:L,error:C,errorState:S,onRetry:v,actions:R,tableView:y,table:y?jsxRuntime.jsx(Ot,{data:e,series:K,xKey:t.key,xLabel:t.label??t.key,formatX:A,formatValue:z,caption:typeof b=="string"?b:void 0}):void 0,className:O,...H,children:({width:B})=>jsxRuntime.jsx(A0,{width:B,height:$,rows:I,x:t,size:m,sharedDomain:X,showValues:l,trackSize:i,rangeColors:c,color:D,tooltip:g,plotLabel:M,formatValue:z,onRowClick:T})})}function H0({className:e}){return jsxRuntime.jsxs("svg",{className:p("animate-spin",e),xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24","aria-hidden":"true",children:[jsxRuntime.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),jsxRuntime.jsx("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"})]})}var W0={sm:"px-3 py-1.5 text-xs gap-1.5",md:"px-4 py-2 text-sm gap-2",lg:"px-5 py-2.5 text-base gap-2",xl:"px-6 py-3 text-lg gap-2.5"},V0={sm:"p-1.5",md:"p-2",lg:"p-2.5",xl:"p-3"},zs={sm:"h-3.5 w-3.5",md:"h-4 w-4",lg:"h-5 w-5",xl:"h-6 w-6"},O0={none:"rounded-none",sm:"rounded-sm",md:"rounded-md",lg:"rounded-lg",full:"rounded-full"};function Ft({label:e,children:t,onClick:r,disabled:n=false,className:o,type:a="button",size:s="md",loading:l=false,leftIcon:i,rightIcon:c,icon:d,fullWidth:u=false,rounded:f="lg",bgColor:m="bg-blue-600 hover:bg-blue-700",textColor:g="text-white",focusColor:y="focus:ring-blue-300",selected:b=false,value:h,showFocusOnClick:x=false,...L}){let C=n||l,S=d!==void 0&&!t&&!e,v=p("inline-flex items-center justify-center font-medium transition-colors focus:outline-none disabled:opacity-50 disabled:cursor-not-allowed",x?"focus:ring-4":"focus-visible:ring-4"),R=p(b?"bg-blue-700 text-white ring-2 ring-blue-500":m,!b&&g,y&&x&&`focus:ring-4 ${y}`,y&&!x&&`focus-visible:ring-4 ${y}`);return jsxRuntime.jsx("button",{type:a,onClick:r,disabled:C,"data-value":h,className:p(v,S?V0[s]:W0[s],O0[f],R,u&&"w-full",o),...L,children:l?jsxRuntime.jsx(H0,{className:zs[s]}):S?jsxRuntime.jsx("span",{className:zs[s],children:d}):jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[i&&jsxRuntime.jsx("span",{className:zs[s],children:i}),t??e,c&&jsxRuntime.jsx("span",{className:zs[s],children:c})]})})}function ra({children:e,orientation:t="horizontal",size:r,fullWidth:n=false,selectedValue:o,onChange:a,className:s}){let i=Cl__namespace.default.Children.toArray(e).filter(d=>Cl__namespace.default.isValidElement(d)&&typeof d.type!="string"),c=(d,u)=>f=>{d!==void 0&&a&&a(d),u&&u(f);};return jsxRuntime.jsx("div",{className:p("inline-flex",t==="horizontal"?"flex-row":"flex-col",n&&"w-full",s),role:"group",children:i.map((d,u)=>{let f=u===0,m=u===i.length-1,g=!f&&!m,y=d.props.value,b=o!==void 0&&y===o,h=p(t==="horizontal"&&f&&"rounded-r-none",t==="horizontal"&&m&&"rounded-l-none",t==="horizontal"&&g&&"rounded-none",t==="horizontal"&&!f&&"-ml-px",t==="vertical"&&f&&"rounded-b-none",t==="vertical"&&m&&"rounded-t-none",t==="vertical"&&g&&"rounded-none",t==="vertical"&&!f&&"-mt-px",n&&"flex-1");return Cl__namespace.default.cloneElement(d,{...d.props,size:r??d.props.size,selected:b||d.props.selected,onClick:c(y,d.props.onClick),className:p(h,d.props.className)})})})}var X0=10080*60*1e3;function tr(e){return new Date(e.getFullYear(),e.getMonth(),e.getDate())}function vo(e){return new Date(e.getFullYear(),e.getMonth(),1)}function Sn(e,t){return new Date(e.getFullYear(),e.getMonth(),e.getDate()+t)}function Ur(e,t){return new Date(e.getFullYear(),e.getMonth()+t,1)}function wl(e){return new Date(e.getFullYear(),e.getMonth()+1,0).getDate()}function an(e,t){return !e||!t?false:e.getFullYear()===t.getFullYear()&&e.getMonth()===t.getMonth()&&e.getDate()===t.getDate()}function kl(e,t){return e.getFullYear()===t.getFullYear()&&e.getMonth()===t.getMonth()}function $n(e,t){return e.getFullYear()*12+e.getMonth()-(t.getFullYear()*12+t.getMonth())}function Hs(e){let t=`${e.getMonth()+1}`.padStart(2,"0"),r=`${e.getDate()}`.padStart(2,"0");return `${e.getFullYear()}-${t}-${r}`}function G0(e){let t=tr(e);t.setDate(t.getDate()-(t.getDay()+6)%7+3);let r=new Date(t.getFullYear(),0,4);return r.setDate(r.getDate()-(r.getDay()+6)%7+3),1+Math.round((t.getTime()-r.getTime())/X0)}function jd(e,t,r){return t&&e<tr(t)?tr(t):r&&e>tr(r)?tr(r):e}function U0(e,t,r){let n=vo(e),o=(n.getDay()-t+7)%7,a=Sn(n,-o),s=r?6:Math.ceil((o+wl(e))/7);return Array.from({length:s},(l,i)=>Array.from({length:7},(c,d)=>Sn(a,i*7+d)))}function K0({className:e}){return jsxRuntime.jsx("svg",{className:e,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24","aria-hidden":"true",children:jsxRuntime.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M15 19l-7-7 7-7"})})}function Y0({className:e}){return jsxRuntime.jsx("svg",{className:e,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24","aria-hidden":"true",children:jsxRuntime.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 5l7 7-7 7"})})}var j0={sm:{day:"h-7 w-7 text-xs",head:"h-7 w-7 text-[10px]",caption:"text-xs",nav:"h-6 w-6",icon:"h-3 w-3",padding:"p-2",gap:"gap-3",footer:"text-xs",select:"text-xs py-0.5 pl-1 pr-5"},md:{day:"h-9 w-9 text-sm",head:"h-9 w-9 text-xs",caption:"text-sm",nav:"h-7 w-7",icon:"h-4 w-4",padding:"p-3",gap:"gap-4",footer:"text-sm",select:"text-sm py-1 pl-1.5 pr-6"},lg:{day:"h-11 w-11 text-base",head:"h-11 w-11 text-sm",caption:"text-base",nav:"h-9 w-9",icon:"h-5 w-5",padding:"p-4",gap:"gap-5",footer:"text-sm",select:"text-base py-1.5 pl-2 pr-7"}},q0={primary:"bg-blue-600 text-white hover:bg-blue-700 dark:bg-blue-500 dark:hover:bg-blue-600",success:"bg-green-600 text-white hover:bg-green-700 dark:bg-green-500 dark:hover:bg-green-600",warning:"bg-yellow-500 text-white hover:bg-yellow-600 dark:bg-yellow-400 dark:text-gray-900 dark:hover:bg-yellow-500",error:"bg-red-600 text-white hover:bg-red-700 dark:bg-red-500 dark:hover:bg-red-600",info:"bg-cyan-600 text-white hover:bg-cyan-700 dark:bg-cyan-500 dark:hover:bg-cyan-600",neutral:"bg-gray-700 text-white hover:bg-gray-800 dark:bg-gray-500 dark:hover:bg-gray-400"},Z0={primary:"bg-blue-50 dark:bg-blue-900/30",success:"bg-green-50 dark:bg-green-900/30",warning:"bg-yellow-50 dark:bg-yellow-900/30",error:"bg-red-50 dark:bg-red-900/30",info:"bg-cyan-50 dark:bg-cyan-900/30",neutral:"bg-gray-100 dark:bg-gray-700/40"},Q0={primary:"text-blue-900 dark:text-blue-100",success:"text-green-900 dark:text-green-100",warning:"text-yellow-900 dark:text-yellow-100",error:"text-red-900 dark:text-red-100",info:"text-cyan-900 dark:text-cyan-100",neutral:"text-gray-900 dark:text-gray-100"},J0={primary:"font-semibold text-blue-600 dark:text-blue-400",success:"font-semibold text-green-600 dark:text-green-400",warning:"font-semibold text-yellow-600 dark:text-yellow-400",error:"font-semibold text-red-600 dark:text-red-400",info:"font-semibold text-cyan-600 dark:text-cyan-400",neutral:"font-semibold text-gray-900 dark:text-gray-100"},xo={primary:"focus-visible:ring-blue-500",success:"focus-visible:ring-green-500",warning:"focus-visible:ring-yellow-500",error:"focus-visible:ring-red-500",info:"focus-visible:ring-cyan-500",neutral:"focus-visible:ring-gray-500"};function Ws(e,t){if(e==="multiple")return Array.isArray(t)?t.map(tr):[];if(e==="range"){let r=t??null;return {from:r?.from?tr(r.from):null,to:r?.to?tr(r.to):null}}return t instanceof Date?tr(t):null}function qd(e){return e?e instanceof Date?e:Array.isArray(e)?e[0]??null:e.from??e.to??null:null}function Nl(e){let{mode:t="single",value:r,defaultValue:n,onChange:o,max:a,month:s,defaultMonth:l,onMonthChange:i,numberOfMonths:c=1,weekStartsOn:d=0,locale:u,size:f="md",color:m="primary",minDate:g,maxDate:y,disabledDates:b,disabled:h=false,showOutsideDays:x=true,showWeekNumbers:L=false,fixedWeeks:C=false,captionLayout:S="label",fromYear:v,toYear:R,todayButton:N=false,clearButton:M=false,footer:P,bordered:E=true,renderDay:W,labels:T,className:O,...H}=e,k=j0[f],z=Math.max(1,c),A=Cl.useMemo(()=>tr(new Date),[]),I=r!==void 0,[X,$]=Cl.useState(()=>Ws(t,n)),K=I?Ws(t,r):X,D=s!==void 0,[B,w]=Cl.useState(()=>vo(l??qd(Ws(t,n??r))??new Date)),G=D?vo(s):B,q=Cl.useCallback(Ce=>{let we=vo(Ce);D||w(we),i?.(we);},[D,i]),j=Cl.useRef(null),U=Cl.useRef(false),[F,_]=Cl.useState(()=>{let Ce=qd(Ws(t,n??r)),we=vo(l??s??Ce??new Date),se=Ce&&kl(Ce,we)?Ce:kl(tr(new Date),we)?tr(new Date):we;return jd(se,g,y)}),J=Ur(G,z-1),Y=$n(F,G)>=0&&$n(F,J)<=0?F:G;Cl.useEffect(()=>{if(!U.current)return;U.current=false,j.current?.querySelector(`[data-day="${Hs(F)}"]:not([data-outside])`)?.focus();},[F,G]);let ee=Cl.useCallback(Ce=>{let we=jd(tr(Ce),g,y);U.current=true,_(we);let se=Ur(G,z-1);$n(we,G)<0?q(we):$n(we,se)>0&&q(Ur(we,-(z-1)));},[G,z,g,y,q]),Z=Cl.useCallback(Ce=>h||g&&Ce<tr(g)||y&&Ce>tr(y)?true:typeof b=="function"?b(Ce):Array.isArray(b)?b.some(we=>an(we,Ce)):false,[h,g,y,b]),[ie,V]=Cl.useState(null),oe=Cl.useCallback(Ce=>{I||$(Ce),o?.(Ce);},[I,o]),pe=Cl.useCallback(Ce=>{let we=tr(Ce);if(Z(we))return;if(t==="multiple"){let de=K??[];if(de.some(ve=>an(ve,we))){oe(de.filter(ve=>!an(ve,we)));return}if(a!==void 0&&de.length>=a)return;oe([...de,we].sort((ve,Be)=>ve.getTime()-Be.getTime()));return}if(t==="range"){let de=K??{from:null,to:null};if(!de.from||de.to){oe({from:we,to:null});return}oe(we<de.from?{from:we,to:de.from}:{from:de.from,to:we});return}oe(an(K,we)?null:we);},[t,K,a,oe,Z]),Te=Cl.useCallback(Ce=>{pe(Ce),_(tr(Ce)),$n(Ce,G)<0?q(Ce):$n(Ce,Ur(G,z-1))>0&&q(Ur(Ce,-(z-1)));},[pe,G,z,q]),ze=!h&&(!g||$n(G,vo(g))>0),ae=!h&&(!y||$n(Ur(G,z-1),vo(y))<0),re=Cl.useCallback(()=>{q(Ur(G,-1));},[G,q]),ce=Cl.useCallback(()=>{q(Ur(G,1));},[G,q]),De=Cl.useCallback(Ce=>{if(h)return;let we=F;switch(Ce.key){case "ArrowLeft":Ce.preventDefault(),ee(Sn(we,-1));break;case "ArrowRight":Ce.preventDefault(),ee(Sn(we,1));break;case "ArrowUp":Ce.preventDefault(),ee(Sn(we,-7));break;case "ArrowDown":Ce.preventDefault(),ee(Sn(we,7));break;case "Home":Ce.preventDefault(),ee(Sn(we,-((we.getDay()-d+7)%7)));break;case "End":Ce.preventDefault(),ee(Sn(we,6-(we.getDay()-d+7)%7));break;case "PageUp":{Ce.preventDefault();let se=Ce.shiftKey?-12:-1,de=Ur(we,se),ke=Math.min(we.getDate(),wl(de));ee(new Date(de.getFullYear(),de.getMonth(),ke));break}case "PageDown":{Ce.preventDefault();let se=Ce.shiftKey?12:1,de=Ur(we,se),ke=Math.min(we.getDate(),wl(de));ee(new Date(de.getFullYear(),de.getMonth(),ke));break}}},[h,F,ee,d]),Ge=Cl.useMemo(()=>{let Ce=new Intl.DateTimeFormat(u,{weekday:"short"}),we=new Intl.DateTimeFormat(u,{weekday:"long"}),se=new Date(2024,0,7);return Array.from({length:7},(de,ke)=>{let ve=Sn(se,(d+ke)%7);return {short:Ce.format(ve),long:we.format(ve)}})},[u,d]),be=Cl.useMemo(()=>{let Ce=new Intl.DateTimeFormat(u,{month:"long"});return Array.from({length:12},(we,se)=>Ce.format(new Date(2024,se,1)))},[u]),Me=Cl.useMemo(()=>new Intl.DateTimeFormat(u,{month:"long",year:"numeric"}),[u]),Re=Cl.useMemo(()=>new Intl.DateTimeFormat(u,{dateStyle:"full"}),[u]),He=Cl.useMemo(()=>{if(S!=="dropdown")return [];let Ce=A.getFullYear(),we=v??g?.getFullYear()??Ce-100,se=R??y?.getFullYear()??Ce+10;return se<we?[we]:Array.from({length:se-we+1},(de,ke)=>we+ke)},[S,v,R,g,y,A]),Ee=t==="range"?K:null,$e=Ee&&Ee.from&&!Ee.to&&ie&&ie>Ee.from?ie:null,bt=Ee?.to??$e,Kt=Cl.useCallback((Ce,we)=>{let se=!kl(Ce,we),de=Z(Ce),ke=false,ve=false,Be=false,Pe=false;return t==="multiple"?ke=(K??[]).some(ye=>an(ye,Ce)):t==="range"?(ve=an(Ee?.from,Ce),Be=an(bt,Ce),ke=ve||Be,Pe=!!(Ee?.from&&bt&&Ce>Ee.from&&Ce<bt)):ke=an(K,Ce),{selected:ke,today:an(Ce,A),outside:se,disabled:de,rangeStart:ve,rangeEnd:Be,inRange:Pe}},[t,K,Ee,bt,Z,A]),dr=Ce=>{let we=Ur(G,Ce),se=U0(we,d,C),de=Ce===0,ke=Ce===z-1;return jsxRuntime.jsxs("div",{className:"flex flex-col",children:[jsxRuntime.jsxs("div",{className:"mb-2 flex items-center justify-between",children:[jsxRuntime.jsx("button",{type:"button",onClick:re,disabled:!ze,"aria-label":T?.previousMonth??"Previous month",className:p("inline-flex items-center justify-center rounded-md transition-colors","text-gray-600 hover:bg-gray-100 dark:text-gray-300 dark:hover:bg-gray-700","focus:outline-none focus-visible:ring-2 focus-visible:ring-offset-1 dark:focus-visible:ring-offset-gray-900",xo[m],k.nav,!ze&&"cursor-not-allowed opacity-40 hover:bg-transparent dark:hover:bg-transparent",!de&&"invisible"),children:jsxRuntime.jsx(K0,{className:k.icon})}),S==="dropdown"?jsxRuntime.jsxs("div",{className:"flex items-center gap-1",children:[jsxRuntime.jsx("select",{"aria-label":T?.monthSelect??"Month",value:we.getMonth(),disabled:h,onChange:ve=>q(new Date(we.getFullYear(),Number(ve.target.value)-Ce,1)),className:p("rounded-md border border-gray-300 bg-white font-medium text-gray-900","dark:border-gray-600 dark:bg-gray-800 dark:text-gray-100","focus:outline-none focus-visible:ring-2",xo[m],k.select,h&&"cursor-not-allowed opacity-50"),children:be.map((ve,Be)=>jsxRuntime.jsx("option",{value:Be,children:ve},ve))}),jsxRuntime.jsx("select",{"aria-label":T?.yearSelect??"Year",value:we.getFullYear(),disabled:h,onChange:ve=>q(new Date(Number(ve.target.value),we.getMonth()-Ce,1)),className:p("rounded-md border border-gray-300 bg-white font-medium text-gray-900","dark:border-gray-600 dark:bg-gray-800 dark:text-gray-100","focus:outline-none focus-visible:ring-2",xo[m],k.select,h&&"cursor-not-allowed opacity-50"),children:He.map(ve=>jsxRuntime.jsx("option",{value:ve,children:ve},ve))})]}):jsxRuntime.jsx("div",{"aria-live":"polite",className:p("font-semibold text-gray-900 dark:text-gray-100",k.caption),children:Me.format(we)}),jsxRuntime.jsx("button",{type:"button",onClick:ce,disabled:!ae,"aria-label":T?.nextMonth??"Next month",className:p("inline-flex items-center justify-center rounded-md transition-colors","text-gray-600 hover:bg-gray-100 dark:text-gray-300 dark:hover:bg-gray-700","focus:outline-none focus-visible:ring-2 focus-visible:ring-offset-1 dark:focus-visible:ring-offset-gray-900",xo[m],k.nav,!ae&&"cursor-not-allowed opacity-40 hover:bg-transparent dark:hover:bg-transparent",!ke&&"invisible"),children:jsxRuntime.jsx(Y0,{className:k.icon})})]}),jsxRuntime.jsxs("table",{role:"grid","aria-label":Me.format(we),className:"border-collapse",children:[jsxRuntime.jsx("thead",{children:jsxRuntime.jsxs("tr",{children:[L&&jsxRuntime.jsxs("th",{scope:"col",className:p("font-normal text-gray-400 dark:text-gray-500",k.head),children:[jsxRuntime.jsx("span",{className:"sr-only",children:T?.weekNumber??"Week number"}),jsxRuntime.jsx("span",{"aria-hidden":"true",children:"#"})]}),Ge.map(ve=>jsxRuntime.jsx("th",{scope:"col",abbr:ve.long,className:p("font-medium uppercase text-gray-500 dark:text-gray-400",k.head),children:ve.short},ve.long))]})}),jsxRuntime.jsx("tbody",{children:se.map(ve=>jsxRuntime.jsxs("tr",{children:[L&&jsxRuntime.jsx("td",{className:p("text-center align-middle text-gray-400 dark:text-gray-500",k.head),children:G0(ve[0])}),ve.map(Be=>{let Pe=Kt(Be,we),ye=Hs(Be);if(Pe.outside&&!x)return jsxRuntime.jsx("td",{className:"p-0"},ye);let Xe=an(Be,Y)&&!Pe.outside,We=Pe.inRange||Pe.rangeStart&&!!bt||Pe.rangeEnd&&!!Ee?.from;return jsxRuntime.jsx("td",{role:"presentation",className:p("p-0",We&&Z0[m],We&&Pe.rangeStart&&"rounded-l-full",We&&Pe.rangeEnd&&"rounded-r-full"),children:jsxRuntime.jsx("button",{type:"button","data-day":ye,"data-selected":Pe.selected||void 0,"data-today":Pe.today||void 0,"data-outside":Pe.outside||void 0,role:"gridcell",tabIndex:Xe?0:-1,disabled:h,"aria-selected":Pe.selected,"aria-disabled":Pe.disabled||void 0,"aria-current":Pe.today?"date":void 0,"aria-label":Re.format(Be),onClick:()=>{Pe.disabled||Te(Be);},onMouseEnter:()=>t==="range"&&V(tr(Be)),onMouseLeave:()=>t==="range"&&V(null),onFocus:()=>_(tr(Be)),className:p("inline-flex items-center justify-center rounded-full transition-colors","focus:outline-none focus-visible:ring-2 focus-visible:ring-offset-1 dark:focus-visible:ring-offset-gray-900",xo[m],k.day,Pe.selected?q0[m]:Pe.inRange?p(Q0[m],"hover:bg-gray-200/60 dark:hover:bg-gray-600/60"):Pe.today?p(J0[m],"hover:bg-gray-100 dark:hover:bg-gray-700"):p("text-gray-900 dark:text-gray-100","hover:bg-gray-100 dark:hover:bg-gray-700"),Pe.outside&&!Pe.selected&&"text-gray-400 dark:text-gray-500",Pe.disabled&&"cursor-not-allowed opacity-40 hover:bg-transparent dark:hover:bg-transparent"),children:W?W(Be,Pe):Be.getDate()})},ye)})]},Hs(ve[0])))})]})]},Hs(we))},_t=Cl.useCallback(()=>{q(A),_(A),Z(A)||pe(A);},[A,q,Z,pe]),Xt=Cl.useCallback(()=>{oe(t==="multiple"?[]:t==="range"?{from:null,to:null}:null);},[t,oe]),Mr=!!P||N||M;return jsxRuntime.jsxs("div",{ref:j,onKeyDown:De,className:p("inline-block bg-white dark:bg-gray-900",E&&"rounded-lg border border-gray-200 shadow-sm dark:border-gray-700",k.padding,h&&"opacity-60",O),...H,children:[jsxRuntime.jsx("div",{className:p("flex flex-wrap",k.gap),children:Array.from({length:z},(Ce,we)=>dr(we))}),Mr&&jsxRuntime.jsxs("div",{className:p("mt-3 flex items-center justify-between gap-2 border-t border-gray-200 pt-3 dark:border-gray-700",k.footer),children:[jsxRuntime.jsx("div",{className:"text-gray-600 dark:text-gray-400",children:P}),(N||M)&&jsxRuntime.jsxs("div",{className:"flex items-center gap-2",children:[N&&jsxRuntime.jsx("button",{type:"button",onClick:_t,disabled:h,className:p("rounded-md px-2 py-1 font-medium transition-colors","text-gray-700 hover:bg-gray-100 dark:text-gray-300 dark:hover:bg-gray-700","focus:outline-none focus-visible:ring-2",xo[m],h&&"cursor-not-allowed opacity-50"),children:T?.today??"Today"}),M&&jsxRuntime.jsx("button",{type:"button",onClick:Xt,disabled:h,className:p("rounded-md px-2 py-1 font-medium transition-colors","text-gray-700 hover:bg-gray-100 dark:text-gray-300 dark:hover:bg-gray-700","focus:outline-none focus-visible:ring-2",xo[m],h&&"cursor-not-allowed opacity-50"),children:T?.clear??"Clear"})]})]})]})}function eh(e,t,r){let n=r||"bg-white dark:bg-gray-800",o=t||"border-gray-200 dark:border-gray-700";switch(e){case "outlined":return p("border-2 bg-transparent",o);case "elevated":return p("shadow-lg border-0",n);case "filled":return p(r||"bg-gray-100 dark:bg-gray-700","border-0");default:return p("border",o,n)}}function th(e){switch(e){case "sm":return "max-w-sm";case "lg":return "max-w-2xl";default:return "max-w-md"}}function rh(e){switch(e){case "none":return "rounded-none";case "sm":return "rounded-sm";case "md":return "rounded-md";case "xl":return "rounded-xl";case "full":return "rounded-3xl";default:return "rounded-lg"}}function nh(e){switch(e){case "none":return "";case "sm":return "p-2";case "lg":return "p-6";default:return ""}}function Zd({variant:e="default",size:t="md",rounded:r="lg",padding:n="none",bgColor:o,borderColor:a,shadowColor:s,hoverable:l=false,clickable:i=false,as:c="div",className:d,children:u,onClick:f,...m}){let g=c,y=l?"transition-all duration-200 hover:shadow-lg hover:-translate-y-0.5":"",b=i?"cursor-pointer active:scale-[0.98] transition-transform":"",h=s||"";return jsxRuntime.jsx(g,{className:p("overflow-hidden",eh(e,a,o),th(t),rh(r),nh(n),y,b,h,d),onClick:i||f?f:void 0,...m,children:u})}Zd.displayName="Card";function ah(e){switch(e){case "none":return "p-0";case "sm":return "px-3 py-2";case "lg":return "px-6 py-5";default:return "px-4 py-4"}}function Jd({actions:e,divider:t=false,padding:r="md",className:n,children:o,...a}){return jsxRuntime.jsxs("div",{className:p("flex items-center justify-between",ah(r),t&&"border-b border-gray-200 dark:border-gray-700",n),...a,children:[jsxRuntime.jsx("div",{className:"flex-1",children:o}),e&&jsxRuntime.jsx("div",{className:"flex items-center gap-2 ml-4",children:e})]})}Jd.displayName="CardHeader";function ih(e){switch(e){case "none":return "p-0";case "sm":return "px-3 py-2";case "lg":return "px-6 py-5";default:return "px-4 py-4"}}function eu({padding:e="md",className:t,children:r,...n}){return jsxRuntime.jsx("div",{className:p(ih(e),t),...n,children:r})}eu.displayName="CardBody";function ch(e){switch(e){case "none":return "p-0";case "sm":return "px-3 py-2";case "lg":return "px-6 py-5";default:return "px-4 py-4"}}function dh(e){switch(e){case "center":return "justify-center";case "right":return "justify-end";case "between":return "justify-between";default:return "justify-start"}}function tu({divider:e=false,align:t="left",padding:r="md",className:n,children:o,...a}){return jsxRuntime.jsx("div",{className:p("flex items-center gap-2",ch(r),dh(t),e&&"border-t border-gray-200 dark:border-gray-700",n),...a,children:o})}tu.displayName="CardFooter";function mh(e){switch(e){case "square":return "aspect-square";case "video":return "aspect-video";case "wide":return "aspect-[21/9]";default:return ""}}function ph(e){switch(e){case "contain":return "object-contain";case "fill":return "object-fill";case "none":return "object-none";default:return "object-cover"}}function ru({position:e="top",aspectRatio:t="auto",objectFit:r="cover",src:n,alt:o,className:a,...s}){let l=e==="top"?"rounded-t-lg":"rounded-b-lg";return jsxRuntime.jsx("img",{src:n,alt:o,className:p("w-full",mh(t),ph(r),l,a),...s})}ru.displayName="CardImage";function fh(e){switch(e){case "sm":return "text-base font-medium";case "lg":return "text-2xl font-bold";default:return "text-xl font-semibold"}}function nu({as:e="h3",size:t="md",className:r,children:n,...o}){return jsxRuntime.jsx(e,{className:p("text-gray-900 dark:text-white",fh(t),r),...o,children:n})}nu.displayName="CardTitle";function bh(e){switch(e){case "sm":return "text-xs";case "lg":return "text-base";default:return "text-sm"}}function ou({size:e="md",className:t,children:r,...n}){return jsxRuntime.jsx("p",{className:p("text-gray-500 dark:text-gray-400",bh(e),t),...n,children:r})}ou.displayName="CardDescription";function Fa(e,t){if(e.length===0)return Number.NaN;if(e.length===1)return e[0];let r=(e.length-1)*Math.min(1,Math.max(0,t)),n=Math.floor(r),o=r-n;return o===0?e[n]:e[n]+(e[n+1]-e[n])*o}function xh(e,t){let r=e.filter(Number.isFinite).sort((n,o)=>n-o);return Fa(r,t)}function Sl(e,t=1.5){let r=e.filter(f=>typeof f=="number"&&Number.isFinite(f)).sort((f,m)=>f-m);if(r.length===0)return null;let n=Fa(r,.25),o=Fa(r,.5),a=Fa(r,.75),s=a-n,l=Math.max(0,t)*s,i=n-l,c=a+l,d=r.filter(f=>f>=i&&f<=c),u=r.filter(f=>f<i||f>c);return {count:r.length,min:r[0],max:r[r.length-1],q1:n,median:o,q3:a,iqr:s,lower:d.length>0?d[0]:n,upper:d.length>0?d[d.length-1]:a,outliers:u}}var kh=40,wh=3,Vs=4,Pl="text-right [font-variant-numeric:tabular-nums]",Nh=Cl.memo(function({boxes:t,color:r}){return jsxRuntime.jsx("g",{children:t.map(n=>jsxRuntime.jsxs("g",{children:[jsxRuntime.jsx("g",{stroke:r,strokeWidth:1.5,strokeLinecap:"round",children:n.whiskers.map(o=>jsxRuntime.jsx("line",{x1:o.x1,y1:o.y1,x2:o.x2,y2:o.y2},o.key))}),n.body?jsxRuntime.jsx("path",{d:n.body,fill:r}):null,n.median?jsxRuntime.jsx("line",{x1:n.median.x1,y1:n.median.y1,x2:n.median.x2,y2:n.median.y2,strokeWidth:2,className:"stroke-white dark:stroke-gray-800"}):null,n.mean?jsxRuntime.jsx("path",{d:`M${n.mean.cx},${n.mean.cy-Vs} L${n.mean.cx+Vs},${n.mean.cy} L${n.mean.cx},${n.mean.cy+Vs} L${n.mean.cx-Vs},${n.mean.cy} Z`,strokeWidth:1.5,stroke:r,className:"fill-white dark:fill-gray-800"}):null,n.outliers.map(o=>jsxRuntime.jsx("circle",{cx:o.cx,cy:o.cy,r:wh,fill:r,strokeWidth:1.5,className:"stroke-white dark:stroke-gray-800"},o.key))]},n.key))})});function Sh({width:e,height:t,data:r,boxes:n,x:o,y:a,grid:s,size:l,orientation:i,boxSize:c,showOutliers:d,showMean:u,color:f,referenceLines:m,margin:g,tooltip:y,plotLabel:b,formatValue:h,formatX:x,onBoxClick:L}){let[C,S]=Cl.useState(null),v=Ve(),R=Cl.useMemo(()=>{let T=i==="vertical",O=n.flatMap(w=>w.stats===null?[]:[w.stats.min,w.stats.max,...u&&w.mean!==null?[w.mean]:[]]),H=Jt({width:e,height:t,data:r,x:o,y:a,bounds:O.length===0?null:[Math.min(...O),Math.max(...O)],margin:g,orientation:i,placement:"band",formatValue:h,formatX:x,defaultIncludeZero:false}),{valueScale:k,bandwidth:z,categoryPositions:A,innerWidth:I,innerHeight:X}=H,$=Math.min(c??kh,z),K=$*.5,D=(w,G)=>T?{x:w,y:G}:{x:G,y:w},B=n.map((w,G)=>{let q=A[G]+(z-$)/2,j=q+$/2;if(w.stats===null)return {key:`${G}`,body:"",median:null,whiskers:[],outliers:[],mean:null,top:A[G],height:z};let{q1:U,q3:F,median:_,lower:J,upper:ne,outliers:Y}=w.stats,ee=k(U),Z=k(F),ie=Math.min(ee,Z),V=Math.abs(Z-ee),oe=fr({...T?{x:q,y:ie,width:$,height:Math.max(1,V)}:{x:ie,y:q,width:Math.max(1,V),height:$},radius:2,round:"none"}),pe=k(_),Te=T?{x1:q,y1:pe,x2:q+$,y2:pe}:{x1:pe,y1:q,x2:pe,y2:q+$},ze=[];for(let[ae,re,ce]of [["lower",J,U],["upper",ne,F]]){let De=k(re),Ge=k(ce),be=D(j,De),Me=D(j,Ge);ze.push({key:`${ae}-stem`,x1:Me.x,y1:Me.y,x2:be.x,y2:be.y});let Re=D(j-K/2,De),He=D(j+K/2,De);ze.push({key:`${ae}-cap`,x1:Re.x,y1:Re.y,x2:He.x,y2:He.y});}return {key:`${G}`,body:oe,median:Te,whiskers:ze,outliers:d?Y.map((ae,re)=>{let ce=D(j,k(ae));return {key:`${re}`,cx:ce.x,cy:ce.y}}):[],mean:u&&w.mean!==null?(()=>{let ae=D(j,k(w.mean));return {cx:ae.x,cy:ae.y}})():null,top:A[G],height:z}});return {vertical:T,rendered:B,categoryPositions:A,categoryCenters:H.categoryCenters,bandwidth:z,categoryTicks:H.categoryTicks,valueTicks:H.valueTicks,valueScale:k,innerWidth:I,innerHeight:X,margin:H.margin}},[n,r,o,a,e,t,g,i,c,d,u,h,x]),N=Cl.useCallback(T=>{if(y===false||n.length===0)return;let O=T.currentTarget.getBoundingClientRect(),H=R.vertical?T.clientX-O.left-R.margin.left:T.clientY-O.top-R.margin.top;S(Dt(R.categoryCenters,H));},[y,n.length,R.vertical,R.margin,R.categoryCenters]),M=Cl.useCallback(T=>{if(n.length===0)return;let O=n.length-1,H=C??0,k=R.vertical?"ArrowRight":"ArrowDown",z=R.vertical?"ArrowLeft":"ArrowUp",A=T.key===k?Math.min(O,H+1):T.key===z?Math.max(0,H-1):T.key==="Home"?0:T.key==="End"?O:T.key==="Escape"?null:void 0;A!==void 0&&(T.preventDefault(),S(A));},[n.length,C,R.vertical]),P=Cl.useCallback(()=>{!L||C===null||L(n[C]);},[L,C,n]),E=C===null?null:n[C],W=C===null||E===null||E.stats===null?null:R.vertical?{x:R.margin.left+R.categoryCenters[C],y:R.margin.top+R.valueScale(E.stats.q3)}:{x:R.margin.left+R.valueScale(E.stats.q3),y:R.margin.top+R.categoryCenters[C]};return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsxs("svg",{width:e,height:t,role:"img","aria-label":b??n.map(T=>T.label).join(", "),tabIndex:0,className:"touch-none focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-blue-500",onPointerMove:N,onPointerLeave:()=>S(null),onKeyDown:M,onBlur:()=>S(null),onClick:P,children:[jsxRuntime.jsxs("g",{transform:`translate(${R.margin.left}, ${R.margin.top})`,children:[jsxRuntime.jsx(Yt,{width:R.innerWidth,height:R.innerHeight,horizontal:R.vertical&&(s==="y"||s==="both")?R.valueTicks.map(T=>T.offset):void 0,vertical:!R.vertical&&(s==="y"||s==="both")?R.valueTicks.map(T=>T.offset):void 0}),C!==null?jsxRuntime.jsx("rect",{x:R.vertical?R.categoryPositions[C]:0,y:R.vertical?0:R.categoryPositions[C],width:R.vertical?R.bandwidth:R.innerWidth,height:R.vertical?R.innerHeight:R.bandwidth,className:"fill-gray-400 dark:fill-gray-500",opacity:.12,"aria-hidden":"true"}):null,m?.map(T=>{let O=R.valueScale(T.value);return jsxRuntime.jsxs("g",{children:[jsxRuntime.jsx("line",{x1:R.vertical?0:O,y1:R.vertical?O:0,x2:R.vertical?R.innerWidth:O,y2:R.vertical?O:R.innerHeight,stroke:T.color??"var(--color-chart-muted)",strokeWidth:1,strokeDasharray:T.dashed===false?void 0:"4 4"}),T.label?jsxRuntime.jsx("text",{x:R.vertical?R.innerWidth:O+4,y:R.vertical?O-4:8,textAnchor:R.vertical?"end":"start",className:"fill-gray-500 text-[10px] dark:fill-gray-400",children:T.label}):null]},`${T.value}-${T.label??""}`)}),jsxRuntime.jsx(Nh,{boxes:R.rendered,color:f})]}),jsxRuntime.jsx("g",{transform:`translate(${R.margin.left}, ${R.margin.top+R.innerHeight})`,children:(R.vertical?o.hidden:a?.hidden)?null:jsxRuntime.jsx(tt,{orientation:"bottom",ticks:R.vertical?R.categoryTicks:R.valueTicks,length:R.innerWidth,label:R.vertical?o.label:a?.label,size:l})}),jsxRuntime.jsx("g",{transform:`translate(${R.margin.left}, ${R.margin.top})`,children:(R.vertical?a?.hidden:o.hidden)?null:jsxRuntime.jsx(tt,{orientation:"left",ticks:R.vertical?R.valueTicks:R.categoryTicks,length:R.innerHeight,showLine:false,label:R.vertical?a?.label:o.label,size:l})})]}),E&&E.stats&&W&&y!==false?jsxRuntime.jsx(vt,{x:W.x,y:W.y,containerWidth:e,children:typeof y=="function"?y(E):jsxRuntime.jsxs("div",{className:"flex flex-col gap-1",children:[jsxRuntime.jsx("div",{className:"font-medium text-gray-900 dark:text-gray-100",children:E.label}),jsxRuntime.jsxs("dl",{className:"grid grid-cols-[auto_auto] gap-x-3 gap-y-0.5",children:[[["Max",E.stats.max],["Q3",E.stats.q3],[v.chartMedian,E.stats.median],["Q1",E.stats.q1],["Min",E.stats.min]].map(([T,O])=>jsxRuntime.jsxs("div",{className:"contents",children:[jsxRuntime.jsx("dt",{className:"text-gray-500 dark:text-gray-400",children:T}),jsxRuntime.jsx("dd",{className:"justify-self-end font-medium text-gray-900 [font-variant-numeric:tabular-nums] dark:text-gray-100",children:h(O)})]},T)),jsxRuntime.jsxs("div",{className:"contents",children:[jsxRuntime.jsx("dt",{className:"text-gray-500 dark:text-gray-400",children:v.chartCount}),jsxRuntime.jsx("dd",{className:"justify-self-end font-medium text-gray-900 [font-variant-numeric:tabular-nums] dark:text-gray-100",children:E.stats.count})]})]})]})}):null]})}function Rh({data:e,x:t,y:r,values:n,quantiles:o,whisker:a=1.5,orientation:s="vertical",boxSize:l,showOutliers:i=true,showMean:c=false,color:d,referenceLines:u,height:f=280,width:m,size:g="md",grid:y="y",tooltip:b=true,tableView:h=false,title:x,description:L,loading:C=false,emptyState:S,error:v=false,errorState:R,onRetry:N,actions:M,margin:P,locale:E,plotLabel:W,format:T,onBoxClick:O,className:H,...k}){let z=Ve(),A=Cl.useMemo(()=>r?.format??T??(K=>pt(K,E)),[r?.format,T,E]),I=Cl.useMemo(()=>t.format??(K=>st(K,E)),[t.format,E]),X=Cl.useMemo(()=>e.map((K,D)=>{let B=gt(K,t.key,D),w=n?(()=>{let j=K[n];return Array.isArray(j)?j.map(U=>typeof U=="number"?U:Number(U)).filter(U=>Number.isFinite(U)):null})():null,G=null,q=null;if(w!==null)G=Sl(w,a),q=w.length===0?null:w.reduce((j,U)=>j+U,0)/w.length;else if(o){let j=Ae(K,o.q1),U=Ae(K,o.median),F=Ae(K,o.q3);if(j!==null&&U!==null&&F!==null){let _=o.min?Ae(K,o.min)??j:j,J=o.max?Ae(K,o.max)??F:F;G={count:0,min:_,max:J,q1:j,median:U,q3:F,iqr:F-j,lower:_,upper:J,outliers:[]};}}return {index:D,x:B,label:I(B,D),stats:G,mean:q,datum:K}}),[e,t.key,n,o,a,I]),$=X.filter(K=>K.stats!==null);return jsxRuntime.jsx(xt,{title:x,description:L,height:f,width:m,size:g,loading:C,empty:$.length===0,emptyState:S,error:v,errorState:R,onRetry:N,actions:M,tableView:h,table:h?jsxRuntime.jsx("div",{className:"w-full overflow-x-auto",children:jsxRuntime.jsxs(yn,{children:[typeof x=="string"?jsxRuntime.jsx("caption",{className:"sr-only",children:x}):null,jsxRuntime.jsxs(vn,{children:[jsxRuntime.jsx(It,{children:t.label??t.key}),n?jsxRuntime.jsx(It,{className:"text-right",children:z.chartCount}):null,jsxRuntime.jsx(It,{className:"text-right",children:"Min"}),jsxRuntime.jsx(It,{className:"text-right",children:"Q1"}),jsxRuntime.jsx(It,{className:"text-right",children:z.chartMedian}),jsxRuntime.jsx(It,{className:"text-right",children:"Q3"}),jsxRuntime.jsx(It,{className:"text-right",children:"Max"}),n&&i?jsxRuntime.jsx(It,{className:"text-right",children:z.chartOutliers}):null]}),jsxRuntime.jsx(xn,{children:X.map(K=>jsxRuntime.jsxs(Cn,{clickable:false,children:[jsxRuntime.jsx(qt,{className:"font-medium text-gray-900 dark:text-gray-100",children:K.label}),n?jsxRuntime.jsx(qt,{className:Pl,children:K.stats?.count??"\u2014"}):null,["min","q1","median","q3","max"].map(D=>jsxRuntime.jsx(qt,{className:Pl,children:K.stats===null?"\u2014":A(K.stats[D])},D)),n&&i?jsxRuntime.jsx(qt,{className:Pl,children:K.stats===null||K.stats.outliers.length===0?"\u2014":K.stats.outliers.map(A).join(", ")}):null]},K.index))})]})}):void 0,className:H,...k,children:({width:K})=>jsxRuntime.jsx(Sh,{width:K,height:f,data:e,boxes:X,x:t,y:r,grid:y,size:g,orientation:s,boxSize:l,showOutliers:i,showMean:c,color:d??zr(0),referenceLines:u,margin:P,tooltip:b,plotLabel:W,formatValue:A,formatX:I,onBoxClick:O})})}var Eh=16,Lh=1.5,Mh=Cl.memo(function({candles:t}){return jsxRuntime.jsx("g",{children:t.map(r=>jsxRuntime.jsxs("g",{children:[r.wick?jsxRuntime.jsx("line",{x1:r.wick.x,y1:r.wick.y1,x2:r.wick.x,y2:r.wick.y2,stroke:r.color,strokeWidth:1.5}):null,r.body?jsxRuntime.jsx("path",{d:r.body,fill:r.hollow?"none":r.color,stroke:r.color,strokeWidth:r.hollow?1.5:0}):null]},r.key))})});function Ih({width:e,height:t,data:r,candles:n,x:o,y:a,grid:s,size:l,candleSize:i,fillRising:c,palette:d,referenceLines:u,margin:f,tooltip:m,plotLabel:g,formatValue:y,formatX:b,onCandleClick:h}){let[x,L]=Cl.useState(null),C=Ve(),S=Cl.useMemo(()=>{let P=n.flatMap(I=>I.high===null||I.low===null?[]:[I.low,I.high]),E=Jt({width:e,height:t,data:r,x:o,y:a,bounds:P.length===0?null:[Math.min(...P),Math.max(...P)],margin:f,orientation:"vertical",placement:"band",formatValue:y,formatX:b,defaultIncludeZero:false}),{valueScale:W,bandwidth:T,categoryPositions:O,innerWidth:H,innerHeight:k}=E,z=Math.min(i??Eh,Math.max(1,T-2));return {rendered:n.map((I,X)=>{let $=O[X]+(T-z)/2,K=$+z/2,D=I.rising?d.up:d.down,B=I.high===null||I.low===null?null:{x:K,y1:W(I.high),y2:W(I.low)},w=null;if(I.open!==null&&I.close!==null){let G=W(I.open),q=W(I.close);w=fr({x:$,y:Math.min(G,q),width:z,height:Math.max(Lh,Math.abs(q-G)),radius:0,round:"none"});}return {key:`${X}`,color:D,body:w,hollow:I.rising&&!c,wick:B,left:$,width:z}}),categoryPositions:O,categoryCenters:E.categoryCenters,bandwidth:T,categoryTicks:E.categoryTicks,valueTicks:E.valueTicks,valueScale:W,innerWidth:H,innerHeight:k,margin:E.margin}},[n,r,o,a,e,t,f,i,c,d,y,b]),v=Cl.useCallback(P=>{if(m===false||n.length===0)return;let E=P.currentTarget.getBoundingClientRect(),W=P.clientX-E.left-S.margin.left;L(Dt(S.categoryCenters,W));},[m,n.length,S.margin.left,S.categoryCenters]),R=Cl.useCallback(P=>{if(n.length===0)return;let E=n.length-1,W=x??0,T=P.key==="ArrowRight"?Math.min(E,W+1):P.key==="ArrowLeft"?Math.max(0,W-1):P.key==="Home"?0:P.key==="End"?E:P.key==="Escape"?null:void 0;T!==void 0&&(P.preventDefault(),L(T));},[n.length,x]),N=Cl.useCallback(()=>{!h||x===null||h(n[x]);},[h,x,n]),M=x===null?null:n[x];return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsxs("svg",{width:e,height:t,role:"img","aria-label":g??n.map(P=>P.label).join(", "),tabIndex:0,className:"touch-none focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-blue-500",onPointerMove:v,onPointerLeave:()=>L(null),onKeyDown:R,onBlur:()=>L(null),onClick:N,children:[jsxRuntime.jsxs("g",{transform:`translate(${S.margin.left}, ${S.margin.top})`,children:[jsxRuntime.jsx(Yt,{width:S.innerWidth,height:S.innerHeight,horizontal:s==="y"||s==="both"?S.valueTicks.map(P=>P.offset):void 0}),x!==null?jsxRuntime.jsx("rect",{x:S.categoryPositions[x],y:0,width:S.bandwidth,height:S.innerHeight,className:"fill-gray-400 dark:fill-gray-500",opacity:.12,"aria-hidden":"true"}):null,u?.map(P=>jsxRuntime.jsxs("g",{children:[jsxRuntime.jsx("line",{x1:0,y1:S.valueScale(P.value),x2:S.innerWidth,y2:S.valueScale(P.value),stroke:P.color??"var(--color-chart-muted)",strokeWidth:1,strokeDasharray:P.dashed===false?void 0:"4 4"}),P.label?jsxRuntime.jsx("text",{x:S.innerWidth,y:S.valueScale(P.value)-4,textAnchor:"end",className:"fill-gray-500 text-[10px] dark:fill-gray-400",children:P.label}):null]},`${P.value}-${P.label??""}`)),jsxRuntime.jsx(Mh,{candles:S.rendered})]}),jsxRuntime.jsx("g",{transform:`translate(${S.margin.left}, ${S.margin.top+S.innerHeight})`,children:o.hidden?null:jsxRuntime.jsx(tt,{orientation:"bottom",ticks:S.categoryTicks,length:S.innerWidth,label:o.label,size:l})}),jsxRuntime.jsx("g",{transform:`translate(${S.margin.left}, ${S.margin.top})`,children:a?.hidden?null:jsxRuntime.jsx(tt,{orientation:"left",ticks:S.valueTicks,length:S.innerHeight,showLine:false,label:a?.label,size:l})})]}),M&&x!==null&&m!==false?jsxRuntime.jsx(vt,{x:S.margin.left+S.categoryCenters[x],y:S.margin.top+(M.high===null?S.innerHeight/2:S.valueScale(M.high)),containerWidth:e,children:typeof m=="function"?m(M):jsxRuntime.jsxs("div",{className:"flex flex-col gap-1",children:[jsxRuntime.jsx("div",{className:"font-medium text-gray-900 dark:text-gray-100",children:M.label}),jsxRuntime.jsx("dl",{className:"grid grid-cols-[auto_auto] gap-x-3 gap-y-0.5",children:[[C.chartOpen,M.open],[C.chartHigh,M.high],[C.chartLow,M.low],[C.chartClose,M.close]].map(([P,E])=>jsxRuntime.jsxs("div",{className:"contents",children:[jsxRuntime.jsx("dt",{className:"text-gray-500 dark:text-gray-400",children:P}),jsxRuntime.jsx("dd",{className:"justify-self-end font-medium text-gray-900 [font-variant-numeric:tabular-nums] dark:text-gray-100",children:E===null?"\u2014":y(E)})]},P))}),M.change===null?null:jsxRuntime.jsxs("div",{className:"flex items-center gap-2 border-t border-gray-200 pt-1 dark:border-gray-700",children:[jsxRuntime.jsx("span",{className:"text-gray-500 dark:text-gray-400",children:M.rising?C.chartRise:C.chartFall}),jsxRuntime.jsxs("span",{className:"[font-variant-numeric:tabular-nums] font-semibold text-gray-900 dark:text-gray-100",children:[M.change>0?"+":"",y(M.change)]})]})]})}):null]})}function Ah({data:e,x:t,y:r,open:n,high:o,low:a,close:s,candleSize:l,fillRising:i=false,colors:c,referenceLines:d,height:u=300,width:f,size:m="md",grid:g="y",legend:y,tooltip:b=true,tableView:h=false,title:x,description:L,loading:C=false,emptyState:S,error:v=false,errorState:R,onRetry:N,actions:M,margin:P,locale:E,plotLabel:W,openLabel:T,highLabel:O,lowLabel:H,closeLabel:k,riseLabel:z,fallLabel:A,format:I,onCandleClick:X,className:$,...K}){let D=Ve(),B=Cl.useMemo(()=>r?.format??I??(_=>pt(_,E)),[r?.format,I,E]),w=Cl.useMemo(()=>t.format??(_=>st(_,E)),[t.format,E]),G=Cl.useMemo(()=>e.map((_,J)=>{let ne=gt(_,t.key,J),Y=Ae(_,n),ee=Ae(_,s);return {index:J,x:ne,label:w(ne,J),open:Y,high:Ae(_,o),low:Ae(_,a),close:ee,change:Y===null||ee===null?null:ee-Y,rising:Y===null||ee===null?true:ee>=Y,datum:_}}),[e,t.key,n,o,a,s,w]),q=Cl.useMemo(()=>({up:c?.up??rl,down:c?.down??nl}),[c]),j=Cl.useMemo(()=>[{key:"up",label:z??D.chartRise,color:q.up,marker:"rect"},{key:"down",label:A??D.chartFall,color:q.down,marker:"rect"}],[q,z,A,D.chartRise,D.chartFall]),U=y===void 0?true:y!==false,F=typeof y=="string"?y:"bottom";return jsxRuntime.jsx(xt,{title:x,description:L,height:u,width:f,size:m,loading:C,empty:G.length===0,emptyState:S,error:v,errorState:R,onRetry:N,actions:M,tableView:h,legendPosition:F,legend:U?jsxRuntime.jsx(jt,{items:j,position:F,marker:"rect",size:m}):void 0,table:h?jsxRuntime.jsx(Ot,{data:e,series:[{key:n,label:T??D.chartOpen},{key:o,label:O??D.chartHigh},{key:a,label:H??D.chartLow},{key:s,label:k??D.chartClose}],xKey:t.key,xLabel:t.label??t.key,formatX:w,formatValue:B,caption:typeof x=="string"?x:void 0}):void 0,className:$,...K,children:({width:_})=>jsxRuntime.jsx(Ih,{width:_,height:u,data:e,candles:G,x:t,y:r,grid:g,size:m,candleSize:l,fillRising:i,palette:q,referenceLines:d,margin:P,tooltip:b,plotLabel:W,formatValue:B,formatX:w,onCandleClick:X})})}var iu=Cl.createContext(null);function Dr(){let e=Cl.useContext(iu);if(!e)throw new Error("Dropdown compound components must be used within a Dropdown");return e}function $s({open:e,defaultOpen:t=false,onOpenChange:r,closeOnSelect:n=true,closeOnClickOutside:o=true,closeOnEscape:a=true,modal:s=false,children:l}){let[i,c]=Cl.useState(t),d=e!==void 0,u=d?e:i,f=Cl.useRef(null),m=Cl.useRef(null),g=Cl.useRef([]),[y,b]=Cl.useState(-1),h=Cl.useRef(0),x=Cl.useId(),L={triggerId:`dropdown-trigger-${x}`,contentId:`dropdown-content-${x}`},C=Cl.useCallback(N=>{d||c(N),r?.(N),N||b(-1);},[d,r]),S=Cl.useCallback((N,M)=>{g.current&&(g.current[N]=M);},[]),v=Cl.useCallback(()=>h.current++,[]),R={isOpen:u,setIsOpen:C,triggerRef:f,contentRef:m,closeOnSelect:n,closeOnClickOutside:o,closeOnEscape:a,modal:s,focusedIndex:y,setFocusedIndex:b,itemsRef:g,registerItem:S,getNextItemIndex:v,triggerId:L.triggerId,contentId:L.contentId};return jsxRuntime.jsx(iu.Provider,{value:R,children:jsxRuntime.jsx("div",{className:"relative inline-block",children:l})})}$s.displayName="Dropdown";function aa(e){let t=Cl.useRef(e);return Cl.useLayoutEffect(()=>{t.current=e;}),t}function sa(e,t,r=true){let n=aa(t);Cl.useEffect(()=>{if(!r)return;let o=a=>{let s=a.target;!e.current||e.current.contains(s)||n.current();};return document.addEventListener("mousedown",o),document.addEventListener("touchstart",o,{passive:true}),()=>{document.removeEventListener("mousedown",o),document.removeEventListener("touchstart",o);}},[r,n,e]);}function _n({triggerRef:e,contentRef:t,isOpen:r,side:n="bottom",align:o="start",sideOffset:a=4,alignOffset:s=0,avoidCollisions:l=true,collisionPadding:i=8}){let[c,d]=Cl.useState({top:0,left:0,actualSide:n,actualAlign:o,isReady:false}),u=Cl.useRef(false),f=Cl.useCallback(()=>{if(!e.current||!t.current)return;let m=e.current.getBoundingClientRect(),g=t.current.getBoundingClientRect();if(!(m.width>0&&m.height>0&&g.width>0&&g.height>0)){u.current=false;return}let b={width:window.innerWidth,height:window.innerHeight},h=n,x=o,L=v=>{switch(v){case "bottom":return {top:m.bottom+a,left:m.left};case "top":return {top:m.top-g.height-a,left:m.left};case "right":return {top:m.top,left:m.right+a};case "left":return {top:m.top,left:m.left-g.width-a}}},C=(v,R,N)=>{if(v==="top"||v==="bottom")switch(R){case "start":return {...N,left:m.left+s};case "center":return {...N,left:m.left+m.width/2-g.width/2+s};case "end":return {...N,left:m.right-g.width+s}}else switch(R){case "start":return {...N,top:m.top+s};case "center":return {...N,top:m.top+m.height/2-g.height/2+s};case "end":return {...N,top:m.bottom-g.height+s}}},S=L(h);if(S=C(h,x,S),l){let{top:v,left:R}=S,{height:N,width:M}=g,{height:P,width:E}=b,W=v+N>P-i,T=v<i,O=R+M>E-i,H=R<i;h==="bottom"&&W&&!T?(h="top",S=L(h),S=C(h,x,S)):h==="top"&&T&&!W&&(h="bottom",S=L(h),S=C(h,x,S)),h==="right"&&O&&!H?(h="left",S=L(h),S=C(h,x,S)):h==="left"&&H&&!O&&(h="right",S=L(h),S=C(h,x,S));let k=S.left+M>E-i,z=S.left<i,A=S.top+N>P-i,I=S.top<i;(h==="top"||h==="bottom")&&(k&&(S.left=E-M-i,x="end"),z&&(S.left=i,x="start")),(h==="left"||h==="right")&&(A&&(S.top=P-N-i,x="end"),I&&(S.top=i,x="start"));}u.current=true,d({top:S.top,left:S.left,actualSide:h,actualAlign:x,isReady:true});},[e,t,n,o,a,s,l,i]);return Cl.useLayoutEffect(()=>{let m=0;if(r){u.current=false;let y=()=>{f(),u.current||(m=requestAnimationFrame(y));};m=requestAnimationFrame(y);}let g=()=>f();return window.addEventListener("resize",g),window.addEventListener("scroll",g,{passive:true,capture:true}),()=>{m&&cancelAnimationFrame(m),window.removeEventListener("resize",g),window.removeEventListener("scroll",g,{capture:true});}},[f,r]),c}function _s({isOpen:e,onClose:t,itemsCount:r,focusedIndex:n,setFocusedIndex:o,onSelect:a,loop:s=true}){let l=aa(t),i=aa(a),c=aa(n),d=Cl.useCallback(u=>{if(!(!e||r===0))switch(u.key){case "ArrowDown":u.preventDefault(),o(s?f=>f<r-1?f+1:0:f=>Math.min(f+1,r-1));break;case "ArrowUp":u.preventDefault(),o(s?f=>f>0?f-1:r-1:f=>Math.max(f-1,0));break;case "Home":u.preventDefault(),o(0);break;case "End":u.preventDefault(),o(r-1);break;case "Enter":case " ":u.preventDefault(),i.current?.(c.current);break;case "Escape":u.preventDefault(),l.current();break;case "Tab":l.current();break}},[e,r,o,s,l,i,c]);return Cl.useEffect(()=>{if(e)return document.addEventListener("keydown",d),()=>document.removeEventListener("keydown",d)},[e,d]),{focusedIndex:n}}function cu(e,t,r){Cl.useEffect(()=>{r&&e.current&&e.current[t]&&e.current[t]?.focus();},[t,r,e]);}var Kh=new Set(["SCRIPT","STYLE","LINK","META","NOSCRIPT","TEMPLATE","BASE","TITLE"]),du="data-synertech-inert-ignore",$a=new WeakMap,El=new WeakMap,Ll=new WeakMap;function Yh(e){let t=$a.get(e)??0;t===0&&(El.set(e,e.getAttribute("aria-hidden")),Ll.set(e,e.hasAttribute("inert")),e.setAttribute("aria-hidden","true"),e.setAttribute("inert","")),$a.set(e,t+1);}function jh(e){let t=$a.get(e)??0;if(t===0)return;if(t>1){$a.set(e,t-1);return}$a.delete(e);let r=El.get(e)??null;r===null?e.removeAttribute("aria-hidden"):e.setAttribute("aria-hidden",r),El.delete(e),Ll.get(e)||e.removeAttribute("inert"),Ll.delete(e);}var Xs=new Map;function Pn(e,t){return Xs.set(e,t),()=>{Xs.delete(e);}}function Gs(e){if(Xs.size===0)return [];let t=[];for(let[r,n]of Xs){let o=n();o&&e.some(a=>a.contains(o))&&t.push(r);}return t}function qh(e){return !(Kh.has(e.tagName)||e.hasAttribute(du))}function Ml(e){let t=(Array.isArray(e)?e:[e]).filter(Boolean),r=t[0]?.ownerDocument?.body;if(!r||!t.every(i=>r.contains(i)))return ()=>{};let n=[...t,...Gs(t).filter(i=>r.contains(i))],o=[],a=new Set,s=i=>n.some(c=>i===c||i.contains(c));for(let i of t){let c=i;for(;c&&c!==r;){let d=c.parentElement;if(!d)break;for(let u of Array.from(d.children))a.has(u)||s(u)||qh(u)&&(a.add(u),Yh(u),o.push(u));c=d;}}let l=false;return ()=>{if(!l){l=true;for(let i of o)jh(i);}}}var tb={fade:"animate-in fade-in-0 duration-200",scale:"animate-in fade-in-0 zoom-in-95 duration-200",slide:"animate-in fade-in-0 slide-in-from-top-2 duration-200",none:""};function Us({side:e="bottom",align:t="start",sideOffset:r=4,alignOffset:n=0,avoidCollisions:o=true,collisionPadding:a=8,minWidth:s,maxWidth:l,maxHeight:i=300,animation:c="scale",portal:d=true,children:u,className:f}){let{isOpen:m,setIsOpen:g,triggerRef:y,contentRef:b,closeOnClickOutside:h,closeOnEscape:x,modal:L,contentId:C,focusedIndex:S,setFocusedIndex:v,itemsRef:R}=Dr(),[N,M]=Cl.useState(false),P=_n({triggerRef:y,contentRef:b,isOpen:m,side:e,align:t,sideOffset:r,alignOffset:n,avoidCollisions:o,collisionPadding:a});sa(b,()=>{h&&g(false);},m);let E=R.current?.filter(Boolean).length||0,W=Cl.useCallback(O=>{let H=R.current?.[O];H&&!H.hasAttribute("data-disabled")&&H.click();},[R]);_s({isOpen:m,onClose:()=>{x&&(g(false),y.current?.focus());},itemsCount:E,focusedIndex:S,setFocusedIndex:v,onSelect:W}),Cl.useEffect(()=>{let O=b.current;if(O)return Pn(O,()=>y.current)},[b,y]),Cl.useEffect(()=>{if(m&&R.current&&R.current.length>0){let O=setTimeout(()=>{v(0),R.current?.[0]?.focus();},10);return ()=>clearTimeout(O)}},[m,R,v]),Cl.useLayoutEffect(()=>{let O=0;if(!m){M(false);return}let H=()=>{let k=y.current?.getBoundingClientRect(),z=b.current?.getBoundingClientRect();if(P.isReady&&!!k&&!!z&&k.width>0&&k.height>0&&z.width>0&&z.height>0){M(true);return}O=requestAnimationFrame(H);};return M(false),O=requestAnimationFrame(H),()=>{O&&cancelAnimationFrame(O);}},[m,P.isReady,y,b]);let T=jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[L&&m&&jsxRuntime.jsx("div",{className:"fixed inset-0 z-40 bg-black/20",onClick:()=>g(false)}),jsxRuntime.jsx("div",{ref:b,id:C,role:"menu","aria-orientation":"vertical","aria-hidden":!m,tabIndex:-1,style:{position:"fixed",top:P.top,left:P.left,minWidth:s??y.current?.offsetWidth,maxWidth:l,maxHeight:i,visibility:m&&N?"visible":"hidden",opacity:m&&N?1:0,pointerEvents:m&&N?"auto":"none"},className:p("z-50 overflow-auto rounded-lg","border border-gray-200 bg-white shadow-lg","dark:border-gray-700 dark:bg-gray-800",m&&N&&tb[c],f),children:jsxRuntime.jsx("div",{className:"py-1",children:u})})]});return d&&typeof document<"u"?reactDom.createPortal(T,document.body):T}Us.displayName="DropdownContent";var ib={default:"text-gray-700 dark:text-gray-200 hover:bg-gray-100 dark:hover:bg-gray-700",danger:"text-red-600 dark:text-red-400 hover:bg-red-50 dark:hover:bg-red-900/20",success:"text-green-600 dark:text-green-400 hover:bg-green-50 dark:hover:bg-green-900/20"};function Ks({children:e,icon:t,iconPosition:r="left",description:n,shortcut:o,variant:a="default",closeOnSelect:s,onSelect:l,disabled:i=false,className:c,onClick:d,index:u,...f}){let{setIsOpen:m,closeOnSelect:g,focusedIndex:y,setFocusedIndex:b,registerItem:h,getNextItemIndex:x}=Dr(),L=Cl.useRef(null),[C]=Cl.useState(()=>u??x());Cl.useEffect(()=>(h(C,L.current),()=>{h(C,null);}),[C,h]);let S=s??g,v=y===C;return jsxRuntime.jsxs("button",{ref:L,role:"menuitem",type:"button",tabIndex:v?0:-1,disabled:i,"data-disabled":i||void 0,"data-focused":v||void 0,onClick:M=>{i||(l?.(),d?.(M),S&&m(false));},onMouseEnter:()=>{i||b(C);},className:p("relative flex w-full items-center px-3 py-2 text-left text-sm","outline-none transition-colors","focus:bg-gray-100 dark:focus:bg-gray-700",ib[a],i&&"opacity-50 cursor-not-allowed hover:bg-transparent",v&&"bg-gray-100 dark:bg-gray-700",c),...f,children:[t&&r==="left"&&jsxRuntime.jsx("span",{className:"mr-2 shrink-0 w-5 h-5",children:t}),jsxRuntime.jsxs("span",{className:"flex-1 min-w-0",children:[jsxRuntime.jsx("span",{className:"block truncate",children:e}),n&&jsxRuntime.jsx("span",{className:"block text-xs text-gray-500 dark:text-gray-400 truncate",children:n})]}),t&&r==="right"&&jsxRuntime.jsx("span",{className:"ml-2 shrink-0 w-5 h-5",children:t}),o&&jsxRuntime.jsx("span",{className:"ml-auto pl-4 text-xs text-gray-400 dark:text-gray-500",children:o})]})}Ks.displayName="DropdownItem";var pu=Cl.memo(({isOpen:e})=>jsxRuntime.jsx("span",{className:p("inline-block transition-transform",e&&"rotate-180"),children:jsxRuntime.jsx("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24","aria-hidden":"true",children:jsxRuntime.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 9l-7 7-7-7"})})}));pu.displayName="ChevronIcon";function js({asChild:e=false,disabled:t=false,children:r,className:n}){let{isOpen:o,setIsOpen:a,triggerRef:s,triggerId:l,contentId:i}=Dr(),u={ref:s,id:l,"aria-haspopup":"menu","aria-expanded":o,"aria-controls":o?i:void 0,disabled:t,onClick:()=>{t||a(!o);},onKeyDown:f=>{t||((f.key==="Enter"||f.key===" ")&&(f.preventDefault(),a(!o)),f.key==="ArrowDown"&&!o&&(f.preventDefault(),a(true)));}};return e&&Cl.isValidElement(r)?Cl.cloneElement(r,{...u,className:p(r.props.className,n)}):jsxRuntime.jsxs("button",{type:"button",...u,className:p("inline-flex items-center justify-center gap-2","rounded-md px-4 py-2","bg-white border border-gray-300","text-sm font-medium text-gray-700","hover:bg-gray-50","focus:outline-none focus-visible:ring-2 focus-visible:ring-blue-500 focus-visible:ring-offset-2","disabled:opacity-50 disabled:cursor-not-allowed","transition-colors",n),children:[r,jsxRuntime.jsx(pu,{isOpen:o})]})}js.displayName="DropdownTrigger";function mb(e){return e instanceof Date?e.toISOString():e}function Al({data:e,series:t,xKey:r,xLabel:n,formatX:o}){let a=t.filter(l=>!l.hidden),s=n??r;return e.map((l,i)=>{let c=gt(l,r,i),d={[s]:o?o(c,i):mb(c)};for(let u of a)d[Vt(u)]=Ae(l,u.key);return d})}function gu(e,t){if(e===null)return "";let r=String(e);return !r.includes(t)&&!/["\n\r]/.test(r)?r:`"${r.replace(/"/g,'""')}"`}function fu(e,t=","){let r=Al(e);if(r.length===0)return "";let n=Object.keys(r[0]);return [n.map(o=>gu(o,t)).join(t),...r.map(o=>n.map(a=>gu(o[a]??null,t)).join(t))].join(`
2
+ `)}function hu(e){return JSON.stringify(Al(e),null,2)}function zl(e,t,r="chart"){if(typeof document>"u"||typeof URL.createObjectURL!="function")return;let n=e==="csv",o=n?fu(t):hu(t),a=new Blob([o],{type:n?"text/csv;charset=utf-8":"application/json"}),s=URL.createObjectURL(a),l=document.createElement("a");l.href=s,l.download=`${r}.${e}`,l.click(),URL.revokeObjectURL(s);}var gb={sm:"h-7 px-2.5 text-xs",md:"h-8 px-3 text-sm",lg:"h-10 px-4 text-sm"},bu=jsxRuntime.jsx("svg",{width:"14",height:"14",viewBox:"0 0 16 16",fill:"none","aria-hidden":"true",className:"shrink-0",children:jsxRuntime.jsx("path",{d:"M8 2v8m0 0 3-3m-3 3L5 7M2.5 12.5h11",stroke:"currentColor",strokeWidth:"1.3",strokeLinecap:"round",strokeLinejoin:"round"})});function fb({data:e,series:t,xKey:r,xLabel:n,formatX:o,formats:a=["csv","json"],filename:s="chart",size:l="md",label:i,onExport:c,className:d,disabled:u}){let f=Ve(),m=Cl.useCallback(h=>{let x={data:e,series:t,xKey:r,xLabel:n,formatX:o};c?c(h,x):zl(h,x,s);},[e,t,r,n,o,c,s]),g=i??f.chartExport,y=h=>h==="csv"?f.chartExportCsv:f.chartExportJson,b=p("inline-flex cursor-pointer items-center gap-2 rounded-full border border-gray-300 bg-white font-medium text-gray-700 transition-colors hover:bg-gray-50 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-blue-500 disabled:cursor-not-allowed disabled:opacity-50 dark:border-gray-600 dark:bg-gray-800 dark:text-gray-200 dark:hover:bg-gray-700",gb[l],d);if(a.length<=1){let h=a[0]??"csv";return jsxRuntime.jsxs("button",{type:"button",onClick:()=>m(h),disabled:u||e.length===0,className:b,children:[bu,jsxRuntime.jsx("span",{children:g})]})}return jsxRuntime.jsxs($s,{children:[jsxRuntime.jsxs(js,{disabled:u||e.length===0,className:b,children:[bu,jsxRuntime.jsx("span",{children:g})]}),jsxRuntime.jsx(Us,{children:a.map(h=>jsxRuntime.jsx(Ks,{onSelect:()=>m(h),children:y(h)},h))})]})}var yu=12,Wl=false,hb={sm:"text-[11px]",md:"text-xs",lg:"text-sm"},bb={sm:"text-xs",md:"text-sm",lg:"text-base"};function yb({data:e,by:t,values:r,domain:n,includeZero:o=false,ticks:a=5,order:s,sort:l="none",columns:i,minPanelWidth:c=220,formatLabel:d,showLabels:u=true,title:f,description:m,size:g="md",locale:y,emptyState:b,children:h,className:x,...L}){let C=d??(N=>st(N,y)),S=new Map;e.forEach((N,M)=>{let P=gt(N,t,M),E=rt(P),W=S.get(E);W?W.rows.push(N):S.set(E,{value:P,rows:[N]});});let v=[...S.entries()];if(s)v=s.map(rt).map(M=>v.find(([P])=>P===M)).filter(M=>M!==void 0);else if(l!=="none"){let N=M=>M.reduce((P,E)=>P+r.reduce((W,T)=>W+(Ae(E,T)??0),0),0);v=[...v].sort(([,M],[,P])=>l==="asc"?N(M.rows)-N(P.rows):N(P.rows)-N(M.rows));}let R=n??Ko(vr(e,r),{includeZero:o,ticks:a});return v.length>yu&&!Wl&&(Wl=true,console.warn(`[@synertech/ui] ChartFacets was given ${v.length} panels. Past ${yu} a facet grid stops being a comparison \u2014 filter the data down to the panels the reader is actually comparing.`)),v.length===0?jsxRuntime.jsx("div",{className:p("text-sm text-gray-500 dark:text-gray-400",x),...L,children:b}):jsxRuntime.jsxs("div",{className:p("flex w-full flex-col gap-3",x),...L,children:[f||m?jsxRuntime.jsxs("div",{className:"flex flex-col gap-0.5",children:[f?jsxRuntime.jsx("span",{className:p("font-semibold text-gray-900 dark:text-gray-100",bb[g]),children:f}):null,m?jsxRuntime.jsx("span",{className:"text-xs text-gray-500 dark:text-gray-400",children:m}):null]}):null,jsxRuntime.jsx("div",{className:"grid gap-x-4 gap-y-3",style:{gridTemplateColumns:i?`repeat(${i}, minmax(0, 1fr))`:`repeat(auto-fit, minmax(${c}px, 1fr))`},children:v.map(([N,M],P)=>{let E=C(M.value,P);return jsxRuntime.jsxs("div",{role:"group","aria-label":E,className:"flex min-w-0 flex-col gap-1",children:[u?jsxRuntime.jsx("span",{className:p("font-medium text-gray-700 dark:text-gray-200",hb[g]),children:E}):null,h({key:N,label:E,data:M.rows,domain:R,index:P,count:v.length})]},N)})})]})}function xb(){Wl=false;}var vb={sm:"gap-1.5",md:"gap-2",lg:"gap-3"};function Cb({label:e,actions:t,sticky:r=false,bordered:n=true,size:o="md",children:a,className:s,...l}){let i=Ve();return jsxRuntime.jsxs("div",{role:"group","aria-label":e??i.chartFilters,className:p("flex w-full flex-wrap items-center",vb[o],n&&"border-b border-gray-200 pb-3 dark:border-gray-700",r&&"sticky top-0 z-10 bg-white/95 pt-3 backdrop-blur-sm dark:bg-gray-900/95",s),...l,children:[a,t?jsxRuntime.jsx("div",{className:"ml-auto flex items-center gap-2",children:t}):null]})}var Sb={"7d":"chartPeriodLast7Days","30d":"chartPeriodLast30Days","90d":"chartPeriodLast90Days","12m":"chartPeriodLast12Months",mtd:"chartPeriodMonthToDate",qtd:"chartPeriodQuarterToDate",ytd:"chartPeriodYearToDate",custom:"chartPeriodCustom"},Rb={sm:"h-7 px-2.5 text-xs",md:"h-8 px-3 text-sm",lg:"h-10 px-4 text-sm"},Pb=jsxRuntime.jsx("svg",{width:"14",height:"14",viewBox:"0 0 16 16",fill:"none","aria-hidden":"true",className:"shrink-0",children:jsxRuntime.jsx("path",{d:"M5 1.5v2M11 1.5v2M2.5 6h11M3.5 3h9a1 1 0 011 1v9a1 1 0 01-1 1h-9a1 1 0 01-1-1V4a1 1 0 011-1z",stroke:"currentColor",strokeWidth:"1.3",strokeLinecap:"round",strokeLinejoin:"round"})});function Tb({value:e,defaultValue:t,onChange:r,presets:n=Ji,custom:o=true,presetLabels:a,now:s,minDate:l,maxDate:i,numberOfMonths:c=1,weekStartsOn:d,locale:u,size:f="md",align:m="start",disabled:g=false,label:y,className:b,...h}){let x=Ve(),L=Cl.useRef(null),C=Cl.useRef(null),S=Cl.useRef(null),[v,R]=Cl.useState(false),[N,M]=Cl.useState(false),[P,E]=Cl.useState(null),[W,T]=Cl.useState(()=>typeof t=="string"?Ma(t,s):t||Ma(n[0]??"30d",s)),O=e??W,H=_n({triggerRef:L,contentRef:C,isOpen:v,side:"bottom",align:m}),k=Cl.useCallback((D=true)=>{R(false),M(false),E(null),D&&L.current?.focus();},[]);Cl.useEffect(()=>{if(!v)return;let D=B=>{let w=B.target;C.current?.contains(w)||L.current?.contains(w)||k(false);};return document.addEventListener("mousedown",D),document.addEventListener("touchstart",D,{passive:true}),()=>{document.removeEventListener("mousedown",D),document.removeEventListener("touchstart",D);}},[v,k]),Cl.useEffect(()=>{if(!v)return;let D=B=>{B.key==="Escape"&&(B.stopPropagation(),k());};return document.addEventListener("keydown",D),()=>document.removeEventListener("keydown",D)},[v,k]),Cl.useEffect(()=>{let D=C.current;if(D)return Pn(D,()=>L.current)},[v]),Cl.useEffect(()=>{if(!v)return;let D=requestAnimationFrame(()=>S.current?.focus());return ()=>cancelAnimationFrame(D)},[v]);let z=Cl.useCallback(D=>{e===void 0&&T(D),r?.(D),k();},[e,r,k]),A=Cl.useCallback(D=>z(Ma(D,s)),[z,s]),I=Cl.useCallback(D=>{E(D),!(!D.from||!D.to)&&z({preset:"custom",from:$o(D.from),to:_o(D.to)});},[z]),X=D=>a?.[D]??x[Sb[D]],$=O.preset==="custom"?el(O.from,O.to,u):X(O.preset),K=jsxRuntime.jsxs("div",{ref:C,role:"dialog","aria-label":y??x.chartPeriod,style:{position:"fixed",top:H.top,left:H.left,visibility:H.isReady?"visible":"hidden"},className:"z-50 flex overflow-hidden rounded-lg border border-gray-200 bg-white shadow-lg dark:border-gray-700 dark:bg-gray-800",children:[jsxRuntime.jsxs("div",{ref:S,tabIndex:-1,className:"flex min-w-44 flex-col p-1 outline-none",children:[n.map(D=>jsxRuntime.jsx("button",{type:"button","aria-pressed":O.preset===D,onClick:()=>A(D),className:p("cursor-pointer rounded-md px-3 py-1.5 text-left text-sm text-gray-700 hover:bg-gray-100 focus-visible:outline-2 focus-visible:outline-offset-[-2px] focus-visible:outline-blue-500 dark:text-gray-200 dark:hover:bg-gray-700",O.preset===D&&"bg-blue-50 font-medium text-blue-700 dark:bg-blue-950 dark:text-blue-300"),children:X(D)},D)),o?jsxRuntime.jsx("button",{type:"button","aria-pressed":O.preset==="custom","aria-expanded":N,onClick:()=>M(true),className:p("cursor-pointer rounded-md px-3 py-1.5 text-left text-sm text-gray-700 hover:bg-gray-100 focus-visible:outline-2 focus-visible:outline-offset-[-2px] focus-visible:outline-blue-500 dark:text-gray-200 dark:hover:bg-gray-700",O.preset==="custom"&&"bg-blue-50 font-medium text-blue-700 dark:bg-blue-950 dark:text-blue-300"),children:X("custom")}):null]}),o&&N?jsxRuntime.jsx("div",{className:"border-l border-gray-200 p-2 dark:border-gray-700",children:jsxRuntime.jsx(Nl,{mode:"range",value:P??{from:O.from,to:O.to},onChange:I,numberOfMonths:c,weekStartsOn:d,locale:u,minDate:l,maxDate:i,size:"sm"})}):null]});return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsxs("button",{ref:L,type:"button",disabled:g,"aria-haspopup":"dialog","aria-expanded":v,"aria-label":`${y??x.chartPeriod}: ${$}`,onClick:()=>v?k():R(true),className:p("inline-flex cursor-pointer items-center gap-2 rounded-full border border-gray-300 bg-white font-medium text-gray-700 transition-colors hover:bg-gray-50 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-blue-500 disabled:cursor-not-allowed disabled:opacity-50 dark:border-gray-600 dark:bg-gray-800 dark:text-gray-200 dark:hover:bg-gray-700",Rb[f],b),...h,children:[Pb,jsxRuntime.jsx("span",{children:$})]}),v&&typeof document<"u"?reactDom.createPortal(K,document.body):null]})}var Ol=[{unit:"second",step:1,span:1e3},{unit:"second",step:5,span:5e3},{unit:"second",step:15,span:15e3},{unit:"second",step:30,span:3e4},{unit:"minute",step:1,span:6e4},{unit:"minute",step:5,span:3e5},{unit:"minute",step:15,span:9e5},{unit:"minute",step:30,span:18e5},{unit:"hour",step:1,span:36e5},{unit:"hour",step:3,span:108e5},{unit:"hour",step:6,span:216e5},{unit:"hour",step:12,span:432e5},{unit:"day",step:1,span:864e5},{unit:"day",step:2,span:1728e5},{unit:"week",step:1,span:6048e5},{unit:"week",step:2,span:12096e5},{unit:"month",step:1,span:2592e6},{unit:"month",step:3,span:78624e5},{unit:"month",step:6,span:157248e5},{unit:"year",step:1,span:31536e6},{unit:"year",step:2,span:63072e6},{unit:"year",step:5,span:1577664e5},{unit:"year",step:10,span:3155328e5}];function Eb(e,t,r){let n=new Date(e.getTime());switch(t){case "year":return n.setMonth(0,1),n.setHours(0,0,0,0),n.setFullYear(Math.floor(n.getFullYear()/r)*r),n;case "month":return n.setDate(1),n.setHours(0,0,0,0),n.setMonth(Math.floor(n.getMonth()/r)*r),n;case "week":return n.setHours(0,0,0,0),n.setDate(n.getDate()-(n.getDay()+6)%7),n;case "day":return n.setHours(0,0,0,0),n;case "hour":return n.setMinutes(0,0,0),n.setHours(Math.floor(n.getHours()/r)*r),n;case "minute":return n.setSeconds(0,0),n.setMinutes(Math.floor(n.getMinutes()/r)*r),n;default:return n.setMilliseconds(0),n.setSeconds(Math.floor(n.getSeconds()/r)*r),n}}function xu(e,t,r){let n=new Date(e.getTime());switch(t){case "year":return n.setFullYear(n.getFullYear()+r),n;case "month":return n.setMonth(n.getMonth()+r),n;case "week":return n.setDate(n.getDate()+r*7),n;case "day":return n.setDate(n.getDate()+r),n;case "hour":return n.setHours(n.getHours()+r),n;case "minute":return n.setMinutes(n.getMinutes()+r),n;default:return n.setSeconds(n.getSeconds()+r),n}}function Fl(e,t,r=6){if(!Number.isFinite(e)||!Number.isFinite(t))return {values:[],unit:"day",step:1};e>t&&([e,t]=[t,e]);let n=Math.max(1,r),o=(t-e)/n,a=Ol.find(i=>i.span>=o)??Ol[Ol.length-1],s=[],l=Eb(new Date(e),a.unit,a.step);for(;l.getTime()<e;)l=xu(l,a.unit,a.step);for(;l.getTime()<=t&&s.length<=500;)s.push(l.getTime()),l=xu(l,a.unit,a.step);return {values:s,unit:a.unit,step:a.step}}function ei(e,t,r){let n=new Date(e);switch(t){case "year":return new Intl.DateTimeFormat(r,{year:"numeric"}).format(n);case "month":return new Intl.DateTimeFormat(r,{month:"short",year:"2-digit"}).format(n);case "week":case "day":return new Intl.DateTimeFormat(r,{day:"numeric",month:"short"}).format(n);case "hour":return new Intl.DateTimeFormat(r,{hour:"2-digit",minute:"2-digit"}).format(n);default:return new Intl.DateTimeFormat(r,{minute:"2-digit",second:"2-digit"}).format(n)}}function ko(e){if(e instanceof Date){let t=e.getTime();return Number.isFinite(t)?t:null}if(typeof e=="number")return Number.isFinite(e)?e:null;if(typeof e=="string"&&e!==""){let t=Date.parse(e);if(Number.isFinite(t))return t;let r=Number(e);return Number.isFinite(r)?r:null}return null}var Mb=5,Ib=3,vu=10,$l=false;function Ab(){$l=false;}var zb=Cl.memo(function({rows:t,radius:r}){return jsxRuntime.jsx("g",{children:t.map(n=>jsxRuntime.jsxs("g",{children:[n.connector?jsxRuntime.jsx("line",{x1:n.connector.x1,y1:n.connector.y,x2:n.connector.x2,y2:n.connector.y,strokeWidth:Ib,strokeLinecap:"round",className:"stroke-gray-300 dark:stroke-gray-600"}):null,n.dots.map(o=>jsxRuntime.jsx("circle",{cx:o.cx,cy:o.cy,r,fill:o.color,strokeWidth:2,className:"stroke-white dark:stroke-gray-800"},o.key)),n.label?jsxRuntime.jsx("text",{x:n.label.x,y:n.label.y,dominantBaseline:"middle",className:"fill-gray-600 text-[10px] [font-variant-numeric:tabular-nums] dark:fill-gray-300",children:n.label.text}):null]},n.key))})});function Bb({width:e,height:t,data:r,rows:n,resolvedSeries:o,x:a,y:s,grid:l,size:i,showValues:c,dotSize:d,referenceLines:u,margin:f,tooltip:m,plotLabel:g,formatValue:y,formatX:b,onRowClick:h}){let[x,L]=Cl.useState(null),C=Cl.useMemo(()=>{let P=o.filter(A=>!A.hidden).map(A=>A.key),E=Jt({width:e,height:t,data:r,x:a,y:s,bounds:Qt(vr(r,P)),margin:f,orientation:"horizontal",placement:"band",formatValue:y,formatX:b,defaultIncludeZero:false}),{valueScale:W,bandwidth:T,categoryPositions:O,innerWidth:H,innerHeight:k}=E;return {rendered:n.map((A,I)=>{let X=O[I]+T/2,$=A.points.map((B,w)=>({key:B.seriesKey,value:B.value,cx:B.value===null?Number.NaN:W(B.value),cy:X,color:B.color,order:w})).filter(B=>B.value!==null),K=A.from===null||A.to===null||$.length<2?null:{x1:W(A.from),x2:W(A.to),y:X},D=null;if(c&&A.to!==null){let B=y(A.to),w=W(A.to);ir(B,10)<=H-w-vu&&(D={x:w+vu,y:X,text:B});}return {key:`${I}`,connector:K,dots:$.map(B=>({key:B.key,cx:B.cx,cy:B.cy,color:B.color})),label:D,top:O[I],height:T}}),categoryPositions:O,categoryCenters:E.categoryCenters,bandwidth:T,categoryTicks:E.categoryTicks,valueTicks:E.valueTicks,valueScale:W,innerWidth:H,innerHeight:k,margin:E.margin}},[r,n,o,a,s,e,t,f,c,y,b]),S=Cl.useCallback(M=>{if(m===false||n.length===0)return;let P=M.currentTarget.getBoundingClientRect(),E=M.clientY-P.top-C.margin.top;L(Dt(C.categoryCenters,E));},[m,n.length,C.margin.top,C.categoryCenters]),v=Cl.useCallback(M=>{if(n.length===0)return;let P=n.length-1,E=x??0,W=M.key==="ArrowDown"?Math.min(P,E+1):M.key==="ArrowUp"?Math.max(0,E-1):M.key==="Home"?0:M.key==="End"?P:M.key==="Escape"?null:void 0;W!==void 0&&(M.preventDefault(),L(W));},[n.length,x]),R=Cl.useCallback(()=>{!h||x===null||h(n[x]);},[h,x,n]),N=x===null?null:n[x];return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsxs("svg",{width:e,height:t,role:"img","aria-label":g??o.map(M=>Vt(M)).join(", "),tabIndex:0,className:"touch-none focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-blue-500",onPointerMove:S,onPointerLeave:()=>L(null),onKeyDown:v,onBlur:()=>L(null),onClick:R,children:[jsxRuntime.jsxs("g",{transform:`translate(${C.margin.left}, ${C.margin.top})`,children:[jsxRuntime.jsx(Yt,{width:C.innerWidth,height:C.innerHeight,vertical:l==="y"||l==="both"?C.valueTicks.map(M=>M.offset):void 0}),x!==null?jsxRuntime.jsx("rect",{x:0,y:C.categoryPositions[x],width:C.innerWidth,height:C.bandwidth,className:"fill-gray-400 dark:fill-gray-500",opacity:.12,"aria-hidden":"true"}):null,u?.map(M=>jsxRuntime.jsxs("g",{children:[jsxRuntime.jsx("line",{x1:C.valueScale(M.value),y1:0,x2:C.valueScale(M.value),y2:C.innerHeight,stroke:M.color??"var(--color-chart-muted)",strokeWidth:1,strokeDasharray:M.dashed===false?void 0:"4 4"}),M.label?jsxRuntime.jsx("text",{x:C.valueScale(M.value)+4,y:8,className:"fill-gray-500 text-[10px] dark:fill-gray-400",children:M.label}):null]},`${M.value}-${M.label??""}`)),jsxRuntime.jsx(zb,{rows:C.rendered,radius:d})]}),jsxRuntime.jsx("g",{transform:`translate(${C.margin.left}, ${C.margin.top+C.innerHeight})`,children:s?.hidden?null:jsxRuntime.jsx(tt,{orientation:"bottom",ticks:C.valueTicks,length:C.innerWidth,label:s?.label,size:i})}),jsxRuntime.jsx("g",{transform:`translate(${C.margin.left}, ${C.margin.top})`,children:a.hidden?null:jsxRuntime.jsx(tt,{orientation:"left",ticks:C.categoryTicks,length:C.innerHeight,showLine:false,tickSize:0,label:a.label,size:i})})]}),N&&x!==null&&m!==false?jsxRuntime.jsx(vt,{x:C.margin.left+(N.to===null?C.innerWidth/2:C.valueScale(N.to)),y:C.margin.top+C.categoryCenters[x],containerWidth:e,children:typeof m=="function"?m(N):jsxRuntime.jsx(Tr,{title:N.label,points:N.points})}):null]})}function Hb({data:e,x:t,y:r,series:n,sort:o="none",sortBy:a,showValues:s=false,dotSize:l=Mb,referenceLines:i,height:c,width:d,size:u="md",grid:f="y",legend:m,legendToggle:g=true,tooltip:y=true,tableView:b=false,showChange:h=true,title:x,description:L,loading:C=false,emptyState:S,error:v=false,errorState:R,onRetry:N,actions:M,margin:P,locale:E,plotLabel:W,changeLabel:T,format:O,onRowClick:H,className:k,...z}){let A=Ve(),[I,X]=Cl.useState(()=>new Set);n.length>3&&!$l&&($l=true,console.warn(`[@synertech/ui] A DumbbellChart was given ${n.length} series. Any two dots of a row can sit side by side, and only the first ${3} palette slots stay tellable apart under that test: facet the chart instead.`));let $=Cl.useMemo(()=>n.map((J,ne)=>({...J,hidden:J.hidden||I.has(J.key),color:Br(J,ne)})),[n,I]),K=Cl.useMemo(()=>r?.format??O??(J=>pt(J,E)),[r?.format,O,E]),D=Cl.useMemo(()=>t.format??(J=>st(J,E)),[t.format,E]),B=Cl.useMemo(()=>$.filter(J=>!J.hidden),[$]),w=Cl.useMemo(()=>e.map((J,ne)=>{let Y=gt(J,t.key,ne),ee=B.map(oe=>{let pe=Ae(J,oe.key);return {seriesKey:oe.key,seriesLabel:Vt(oe),color:oe.color,value:pe,formattedValue:pe===null?"\u2014":K(pe),datum:J}}),Z=ee.map(oe=>oe.value).filter(oe=>oe!==null),ie=ee[0]?.value??null,V=ee[ee.length-1]?.value??null;return {index:ne,x:Y,label:D(Y,ne),points:ee,from:Z.length>0?Math.min(...Z):null,to:Z.length>0?Math.max(...Z):null,change:ie===null||V===null?null:V-ie,datum:J}}),[e,t.key,B,K,D]),G=Cl.useMemo(()=>{if(o==="none")return w;let J=a??B[B.length-1]?.key,ne=ee=>o==="gap"?Math.abs(ee.change??0):ee.points.find(Z=>Z.seriesKey===J)?.value??0,Y=[...w].sort((ee,Z)=>ne(ee)-ne(Z));return o==="asc"?Y:Y.reverse()},[w,o,a,B]),q=Cl.useCallback(J=>{X(ne=>{let Y=new Set(ne);return Y.has(J)?Y.delete(J):Y.add(J),Y});},[]),j=c??Math.max(96,G.length*30+44),U=Cl.useMemo(()=>G.map(J=>({...J.datum,__change:J.change})),[G]),F=m===void 0?n.length>=2:m!==false,_=typeof m=="string"?m:"bottom";return jsxRuntime.jsx(xt,{title:x,description:L,height:j,width:d,size:u,loading:C,empty:G.length===0||B.length===0,emptyState:S,error:v,errorState:R,onRetry:N,actions:M,tableView:b,legendPosition:_,legend:F?jsxRuntime.jsx(jt,{items:Gr($),position:_,marker:"dot",size:u,onToggle:g?q:void 0}):void 0,table:b?jsxRuntime.jsx(Ot,{data:U,series:[...$,...h?[{key:"__change",label:T??A.chartChange}]:[]],xKey:t.key,xLabel:t.label??t.key,formatX:D,formatValue:K,caption:typeof x=="string"?x:void 0}):void 0,className:k,...z,children:({width:J})=>jsxRuntime.jsx(Bb,{width:J,height:j,data:G.map(ne=>ne.datum),rows:G,resolvedSeries:$,x:t,y:r,grid:f,size:u,showValues:s,dotSize:l,referenceLines:i,margin:P,tooltip:y,plotLabel:W,formatValue:K,formatX:D,onRowClick:H})})}var Fb=8,$b=12,_b=44,Xl="text-right [font-variant-numeric:tabular-nums]",Xb=Cl.memo(function({stages:t}){return jsxRuntime.jsx("g",{children:t.map(r=>jsxRuntime.jsxs("g",{children:[jsxRuntime.jsx("path",{d:r.d,fill:r.color}),r.value?jsxRuntime.jsx("text",{x:r.value.x,y:r.value.y,textAnchor:r.value.anchor,dominantBaseline:"middle",className:r.value.inside?r.value.onDark?"fill-gray-50 text-[11px] font-semibold [font-variant-numeric:tabular-nums] dark:fill-gray-900":"fill-gray-900 text-[11px] font-semibold [font-variant-numeric:tabular-nums] dark:fill-gray-50":"fill-gray-700 text-[11px] font-semibold [font-variant-numeric:tabular-nums] dark:fill-gray-200",children:r.value.text}):null,r.conversion?jsxRuntime.jsx("text",{x:r.conversion.x,y:r.conversion.y,textAnchor:"middle",dominantBaseline:"middle",className:"fill-gray-500 text-[10px] [font-variant-numeric:tabular-nums] dark:fill-gray-400",children:r.conversion.text}):null]},r.key))})});function Gb({width:e,height:t,stages:r,x:n,size:o,align:a,showConversion:s,showValues:l,stageSize:i,ramp:c,tooltip:d,plotLabel:u,locale:f,onStageClick:m}){let[g,y]=Cl.useState(null),b=Ve(),h=Cl.useMemo(()=>{let v=r.map(k=>k.label),R={top:6,right:12,bottom:6,left:n.hidden?8:n.height??Pr(v)+$b},N=Math.max(0,e-R.left-R.right),M=Math.max(0,t-R.top-R.bottom),P=bn(r.map((k,z)=>z),[0,M],{paddingInner:s?.45:.28}),E=Math.min(i??_b,P.bandwidth),W=Math.max(0,...r.map(k=>k.value??0)),T=Ir([0,W],[0,N]),O=r.map((k,z)=>{let A=k.value===null?0:Math.max(0,T(k.value)),I=a==="center"?(N-A)/2:0,X=P(z)+(P.bandwidth-E)/2,$=X+E/2,K=null;if(l&&k.value!==null){let w=k.formattedValue;K=ir(w,11)+16<=A?{x:I+A/2,y:$,anchor:"middle",text:w,inside:true,onDark:c.onDark(z)}:{x:I+A+Fb,y:$,anchor:"start",text:w,inside:false,onDark:false};}let D=P(z-1)+(P.bandwidth-E)/2+E,B=s&&k.conversion!==null&&z>0?{x:N/2,y:(D+X)/2,text:Zt(k.conversion,{locale:f,maximumFractionDigits:0})}:null;return {key:`${z}`,d:fr({x:I,y:X,width:A,height:E,radius:4,round:a==="center"?"none":"right"}),color:c(z),value:K,conversion:B,top:P(z),height:P.bandwidth}}),H=n.hidden?[]:r.map((k,z)=>({value:k.x,offset:P.center(z),label:k.label}));return {margin:R,innerWidth:N,innerHeight:M,rendered:O,stageTicks:H,centers:r.map((k,z)=>P.center(z))}},[r,n,e,t,a,s,l,i,c,f]),x=Cl.useCallback(v=>{if(d===false||r.length===0)return;let R=v.currentTarget.getBoundingClientRect(),N=v.clientY-R.top-h.margin.top;y(Dt(h.centers,N));},[d,r.length,h.margin.top,h.centers]),L=Cl.useCallback(v=>{if(r.length===0)return;let R=r.length-1,N=g??0,M=v.key==="ArrowDown"?Math.min(R,N+1):v.key==="ArrowUp"?Math.max(0,N-1):v.key==="Home"?0:v.key==="End"?R:v.key==="Escape"?null:void 0;M!==void 0&&(v.preventDefault(),y(M));},[r.length,g]),C=Cl.useCallback(()=>{!m||g===null||m(r[g]);},[m,g,r]),S=g===null?null:r[g];return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsxs("svg",{width:e,height:t,role:"img","aria-label":u??r.map(v=>v.label).join(", "),tabIndex:0,className:"touch-none focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-blue-500",onPointerMove:x,onPointerLeave:()=>y(null),onKeyDown:L,onBlur:()=>y(null),onClick:C,children:[jsxRuntime.jsxs("g",{transform:`translate(${h.margin.left}, ${h.margin.top})`,children:[g!==null&&h.rendered[g]?jsxRuntime.jsx("rect",{x:-4,y:h.rendered[g].top,width:h.innerWidth+8,height:h.rendered[g].height,rx:4,className:"fill-gray-400 dark:fill-gray-500",opacity:.12,"aria-hidden":"true"}):null,jsxRuntime.jsx(Xb,{stages:h.rendered})]}),jsxRuntime.jsx("g",{transform:`translate(${h.margin.left}, ${h.margin.top})`,children:n.hidden?null:jsxRuntime.jsx(tt,{orientation:"left",ticks:h.stageTicks,length:h.innerHeight,showLine:false,tickSize:0,size:o})})]}),S&&g!==null&&d!==false?jsxRuntime.jsx(vt,{x:h.margin.left+h.innerWidth/2,y:h.margin.top+h.centers[g],containerWidth:e,children:typeof d=="function"?d(S):jsxRuntime.jsxs("div",{className:"flex flex-col gap-1",children:[jsxRuntime.jsx("div",{className:"font-medium text-gray-900 dark:text-gray-100",children:S.label}),jsxRuntime.jsxs("div",{className:"flex items-center gap-2",children:[jsxRuntime.jsx("span",{className:"h-2.5 w-2.5 shrink-0 rounded-sm",style:{backgroundColor:h.rendered[g]?.color},"aria-hidden":"true"}),jsxRuntime.jsx("span",{className:"font-semibold text-gray-900 [font-variant-numeric:tabular-nums] dark:text-gray-100",children:S.formattedValue})]}),S.conversion!==null?jsxRuntime.jsxs("div",{className:"flex items-center gap-2 text-gray-500 dark:text-gray-400",children:[jsxRuntime.jsx("span",{children:b.chartConversion}),jsxRuntime.jsx("span",{className:"[font-variant-numeric:tabular-nums]",children:Zt(S.conversion,{locale:f,maximumFractionDigits:1})})]}):null,S.overall!==null?jsxRuntime.jsxs("div",{className:"flex items-center gap-2 text-gray-500 dark:text-gray-400",children:[jsxRuntime.jsx("span",{children:r[0]?.label}),jsxRuntime.jsx("span",{className:"[font-variant-numeric:tabular-nums]",children:Zt(S.overall,{locale:f,maximumFractionDigits:1})})]}):null]})}):null]})}function Ub({data:e,x:t,value:r,align:n="center",showConversion:o=true,showValues:a=true,stageSize:s,colors:l,height:i,width:c,size:d="md",tooltip:u=true,tableView:f=false,title:m,description:g,loading:y=false,emptyState:b,error:h=false,errorState:x,onRetry:L,actions:C,locale:S,plotLabel:v,valueLabel:R,conversionLabel:N,dropOffLabel:M,format:P,onStageClick:E,className:W,...T}){let O=Ve(),H=Cl.useMemo(()=>P??(X=>pt(X,S)),[P,S]),k=Cl.useMemo(()=>t.format??(X=>st(X,S)),[t.format,S]),z=Cl.useMemo(()=>{let X=Ae(e[0]??{},r);return e.map(($,K)=>{let D=gt($,t.key,K),B=Ae($,r),w=K===0?null:Ae(e[K-1],r);return {index:K,x:D,label:k(D,K),value:B,overall:K===0||X===null||X===0||B===null?null:B/X,conversion:w===null||w===0||B===null?null:B/w,dropOff:w===null||B===null?null:w-B,formattedValue:B===null?"\u2014":H(B),datum:$}})},[e,t.key,r,H,k]),A=Cl.useMemo(()=>za([0,Math.max(1,z.length-1)],{colors:l??Ia,...l?{}:{darkStops:ol}}),[z.length,l]),I=i??Math.max(96,z.length*(o?56:44)+12);return jsxRuntime.jsx(xt,{title:m,description:g,height:I,width:c,size:d,loading:y,empty:z.length===0,emptyState:b,error:h,errorState:x,onRetry:L,actions:C,tableView:f,table:f?jsxRuntime.jsx("div",{className:"w-full overflow-x-auto",children:jsxRuntime.jsxs(yn,{children:[typeof m=="string"?jsxRuntime.jsx("caption",{className:"sr-only",children:m}):null,jsxRuntime.jsxs(vn,{children:[jsxRuntime.jsx(It,{children:t.label??t.key}),jsxRuntime.jsx(It,{className:"text-right",children:R??O.chartValue}),jsxRuntime.jsx(It,{className:"text-right",children:N??O.chartConversion}),jsxRuntime.jsx(It,{className:"text-right",children:M??O.chartDropOff})]}),jsxRuntime.jsx(xn,{children:z.map(X=>jsxRuntime.jsxs(Cn,{clickable:false,children:[jsxRuntime.jsx(qt,{className:"font-medium text-gray-900 dark:text-gray-100",children:X.label}),jsxRuntime.jsx(qt,{className:Xl,children:X.formattedValue}),jsxRuntime.jsx(qt,{className:Xl,children:X.conversion===null?"\u2014":Zt(X.conversion,{locale:S,maximumFractionDigits:1})}),jsxRuntime.jsx(qt,{className:Xl,children:X.dropOff===null?"\u2014":H(X.dropOff)})]},X.index))})]})}):void 0,className:W,...T,children:({width:X})=>jsxRuntime.jsx(Gb,{width:X,height:I,stages:z,x:t,size:d,align:n,showConversion:o,showValues:a,stageSize:s,ramp:A,tooltip:u,plotLabel:v,locale:S,onStageClick:E})})}var qb=18,ku=.5,Zb=.3,ri=7,wu=10,Nu=.02,Gl="text-right [font-variant-numeric:tabular-nums]",Qb=Cl.memo(function({tasks:t,arrows:r}){return jsxRuntime.jsxs("g",{children:[jsxRuntime.jsx("g",{className:"fill-gray-400 stroke-gray-400 dark:fill-gray-500 dark:stroke-gray-500",children:r.map(n=>jsxRuntime.jsxs("g",{children:[jsxRuntime.jsx("path",{d:n.d,fill:"none",strokeWidth:1}),jsxRuntime.jsx("path",{d:n.head,strokeWidth:0})]},n.key))}),t.map(n=>jsxRuntime.jsxs("g",{children:[n.track?jsxRuntime.jsx("path",{d:n.track,fill:n.color,fillOpacity:n.trackOpacity}):null,n.progress?jsxRuntime.jsx("path",{d:n.progress,fill:n.color}):null,n.milestone?jsxRuntime.jsx("path",{d:n.milestone,fill:n.color,strokeWidth:2,className:"stroke-white dark:stroke-gray-800"}):null]},n.key))]})});function Jb({width:e,height:t,data:r,tasks:n,x:o,domain:a,unit:s,timeTicks:l,today:i,grid:c,size:d,barSize:u,colorOf:f,margin:m,tooltip:g,plotLabel:y,todayLabel:b,locale:h,formatDate:x,formatX:L,onTaskClick:C}){let[S,v]=Cl.useState(null),R=Ve(),N=Cl.useMemo(()=>{let T=Jt({width:e,height:t,data:r,x:o,y:{domain:a},bounds:a,margin:m,orientation:"horizontal",placement:"band",formatValue:B=>ei(B,s,h),formatX:L}),{valueScale:O,bandwidth:H,categoryPositions:k,innerWidth:z,innerHeight:A}=T,I=Math.min(u??qb,H),X=new Map(n.map((B,w)=>[B.id,w])),$=n.map((B,w)=>{let G=k[w]+(H-I)/2,q=G+I/2,j=f(B);if(B.start===null)return {key:`${w}`,color:j,track:null,trackOpacity:1,progress:null,milestone:null,top:k[w],height:H};let U=O(B.start);if(B.milestone)return {key:`${w}`,color:j,track:null,trackOpacity:1,progress:null,milestone:`M${U},${q-ri} L${U+ri},${q} L${U},${q+ri} L${U-ri},${q} Z`,top:k[w],height:H};let F=O(B.end??B.start),_=Math.max(2,F-U);return {key:`${w}`,color:j,track:fr({x:U,y:G,width:_,height:I,radius:3}),trackOpacity:B.progress===null?1:Zb,progress:B.progress===null?null:fr({x:U,y:q-I*ku/2,width:Math.max(0,_*Math.min(1,Math.max(0,B.progress))),height:I*ku,radius:2,round:"right"}),milestone:null,top:k[w],height:H}}),K=[];n.forEach((B,w)=>{if(B.start!==null)for(let G of B.dependsOn){let q=X.get(G);if(q===void 0||q===w)continue;let j=n[q];if(j.start===null)continue;let U=O(j.end??j.start),F=k[q]+H/2,_=O(B.start),J=k[w]+H/2,ne=Math.max(U+wu,_-wu);K.push({key:`${G}-${B.id}`,d:`M${U},${F} L${ne},${F} L${ne},${J} L${_-5},${J}`,head:`M${_},${J} L${_-5},${J-3.5} L${_-5},${J+3.5} Z`});}});let D=l.map(B=>({value:B,offset:O(B),label:ei(B,s,h)}));return {rendered:$,arrows:K,categoryPositions:k,categoryCenters:T.categoryCenters,bandwidth:H,categoryTicks:T.categoryTicks,valueTicks:D,valueScale:O,innerWidth:z,innerHeight:A,margin:T.margin}},[n,r,o,a,s,l,e,t,m,u,f,h,L]),M=Cl.useCallback(T=>{if(g===false||n.length===0)return;let O=T.currentTarget.getBoundingClientRect(),H=T.clientY-O.top-N.margin.top;v(Dt(N.categoryCenters,H));},[g,n.length,N.margin.top,N.categoryCenters]),P=Cl.useCallback(T=>{if(n.length===0)return;let O=n.length-1,H=S??0,k=T.key==="ArrowDown"?Math.min(O,H+1):T.key==="ArrowUp"?Math.max(0,H-1):T.key==="Home"?0:T.key==="End"?O:T.key==="Escape"?null:void 0;k!==void 0&&(T.preventDefault(),v(k));},[n.length,S]),E=Cl.useCallback(()=>{!C||S===null||C(n[S]);},[C,S,n]),W=S===null?null:n[S];return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsxs("svg",{width:e,height:t,role:"img","aria-label":y??n.map(T=>T.label).join(", "),tabIndex:0,className:"touch-none focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-blue-500",onPointerMove:M,onPointerLeave:()=>v(null),onKeyDown:P,onBlur:()=>v(null),onClick:E,children:[jsxRuntime.jsxs("g",{transform:`translate(${N.margin.left}, ${N.margin.top})`,children:[jsxRuntime.jsx(Yt,{width:N.innerWidth,height:N.innerHeight,vertical:c?N.valueTicks.map(T=>T.offset):void 0}),S!==null?jsxRuntime.jsx("rect",{x:0,y:N.categoryPositions[S],width:N.innerWidth,height:N.bandwidth,className:"fill-gray-400 dark:fill-gray-500",opacity:.12,"aria-hidden":"true"}):null,jsxRuntime.jsx(Qb,{tasks:N.rendered,arrows:N.arrows}),i!==null?jsxRuntime.jsxs("g",{children:[jsxRuntime.jsx("line",{x1:N.valueScale(i),y1:0,x2:N.valueScale(i),y2:N.innerHeight,className:"stroke-gray-900 dark:stroke-white",strokeWidth:1,strokeDasharray:"4 4"}),jsxRuntime.jsx("text",{x:N.valueScale(i)+4,y:8,className:"fill-gray-500 text-[10px] dark:fill-gray-400",children:b})]}):null]}),jsxRuntime.jsx("g",{transform:`translate(${N.margin.left}, ${N.margin.top+N.innerHeight})`,children:jsxRuntime.jsx(tt,{orientation:"bottom",ticks:N.valueTicks,length:N.innerWidth,size:d})}),jsxRuntime.jsx("g",{transform:`translate(${N.margin.left}, ${N.margin.top})`,children:o.hidden?null:jsxRuntime.jsx(tt,{orientation:"left",ticks:N.categoryTicks,length:N.innerHeight,showLine:false,tickSize:0,label:o.label,size:d})})]}),W&&S!==null&&g!==false?jsxRuntime.jsx(vt,{x:N.margin.left+(W.start===null?N.innerWidth/2:N.valueScale(W.start)),y:N.margin.top+N.categoryCenters[S],containerWidth:e,children:typeof g=="function"?g(W):jsxRuntime.jsxs("div",{className:"flex flex-col gap-1",children:[jsxRuntime.jsx("div",{className:"font-medium text-gray-900 dark:text-gray-100",children:W.label}),jsxRuntime.jsxs("div",{className:"flex items-center gap-2 text-gray-500 dark:text-gray-400",children:[jsxRuntime.jsx("span",{children:R.chartStart}),jsxRuntime.jsx("span",{className:"[font-variant-numeric:tabular-nums] text-gray-900 dark:text-gray-100",children:W.start===null?"\u2014":x(W.start)})]}),W.milestone?null:jsxRuntime.jsxs("div",{className:"flex items-center gap-2 text-gray-500 dark:text-gray-400",children:[jsxRuntime.jsx("span",{children:R.chartEnd}),jsxRuntime.jsx("span",{className:"[font-variant-numeric:tabular-nums] text-gray-900 dark:text-gray-100",children:W.end===null?"\u2014":x(W.end)})]}),W.progress===null?null:jsxRuntime.jsxs("div",{className:"flex items-center gap-2 text-gray-500 dark:text-gray-400",children:[jsxRuntime.jsx("span",{children:R.chartProgress}),jsxRuntime.jsx("span",{className:"[font-variant-numeric:tabular-nums] text-gray-900 dark:text-gray-100",children:Zt(W.progress,{locale:h,maximumFractionDigits:0})})]})]})}):null]})}function ey({data:e,x:t,start:r,end:n,id:o,progress:a,milestone:s,dependencies:l,group:i,domain:c,today:d,ticks:u=6,barSize:f,rowSize:m=30,color:g,height:y,width:b,size:h="md",grid:x=true,legend:L,tooltip:C=true,tableView:S=false,title:v,description:R,loading:N=false,emptyState:M,error:P=false,errorState:E,onRetry:W,actions:T,margin:O,locale:H,plotLabel:k,startLabel:z,endLabel:A,progressLabel:I,todayLabel:X,formatDate:$,onTaskClick:K,className:D,...B}){let w=Ve(),G=Cl.useMemo(()=>t.format??(V=>st(V,H)),[t.format,H]),q=Cl.useMemo(()=>e.map((V,oe)=>{let pe=gt(V,t.key,oe),Te=ko(V[r]),ze=n?ko(V[n]):null,ae=s?!!V[s]:ze===null,re=l?V[l]:void 0;return {index:oe,id:String(o?V[o]??oe:oe),x:pe,label:G(pe,oe),start:Te,end:ae?Te:ze??Te,progress:a?Ae(V,a):null,milestone:ae,dependsOn:Array.isArray(re)?re.map(ce=>String(ce)):[],group:i?V[i]??null:null,datum:V}}),[e,t.key,r,n,o,a,s,l,i,G]),j=Cl.useMemo(()=>{let V=[];for(let oe of q)oe.group!==null&&!V.includes(oe.group)&&V.push(oe.group);return V},[q]),U=Cl.useCallback(V=>V.group===null?g??zr(0):zr(j.indexOf(V.group)),[j,g]),F=Cl.useMemo(()=>{if(c){let ze=ko(c[0]),ae=ko(c[1]);if(ze!==null&&ae!==null)return [ze,ae]}let V=q.flatMap(ze=>ze.start===null?[]:[ze.start,ze.end??ze.start]);if(V.length===0)return [0,1];let oe=Math.min(...V),pe=Math.max(...V),Te=pe-oe||864e5;return [oe-Te*Nu,pe+Te*Nu]},[c,q]),_=Cl.useMemo(()=>Fl(F[0],F[1],u),[F,u]),J=Cl.useMemo(()=>$??(V=>new Intl.DateTimeFormat(H,{day:"numeric",month:"short",year:"numeric"}).format(new Date(V))),[$,H]),ne=Cl.useMemo(()=>d===false?null:ko(d??Date.now()),[d]),Y=Cl.useMemo(()=>j.map((V,oe)=>({key:V,label:V,color:zr(oe),marker:"rect"})),[j]),ee=y??Math.max(120,q.length*m+48),Z=L===void 0?j.length>=2:L!==false,ie=typeof L=="string"?L:"bottom";return jsxRuntime.jsx(xt,{title:v,description:R,height:ee,width:b,size:h,loading:N,empty:q.length===0,emptyState:M,error:P,errorState:E,onRetry:W,actions:T,tableView:S,legendPosition:ie,legend:Z&&Y.length>0?jsxRuntime.jsx(jt,{items:Y,position:ie,marker:"rect",size:h}):void 0,table:S?jsxRuntime.jsx("div",{className:"w-full overflow-x-auto",children:jsxRuntime.jsxs(yn,{children:[typeof v=="string"?jsxRuntime.jsx("caption",{className:"sr-only",children:v}):null,jsxRuntime.jsxs(vn,{children:[jsxRuntime.jsx(It,{children:t.label??t.key}),jsxRuntime.jsx(It,{className:"text-right",children:z??w.chartStart}),jsxRuntime.jsx(It,{className:"text-right",children:A??w.chartEnd}),a?jsxRuntime.jsx(It,{className:"text-right",children:I??w.chartProgress}):null]}),jsxRuntime.jsx(xn,{children:q.map(V=>jsxRuntime.jsxs(Cn,{clickable:false,children:[jsxRuntime.jsx(qt,{className:"font-medium text-gray-900 dark:text-gray-100",children:V.label}),jsxRuntime.jsx(qt,{className:Gl,children:V.start===null?"\u2014":J(V.start)}),jsxRuntime.jsx(qt,{className:Gl,children:V.milestone||V.end===null?"\u2014":J(V.end)}),a?jsxRuntime.jsx(qt,{className:Gl,children:V.progress===null?"\u2014":Zt(V.progress,{locale:H,maximumFractionDigits:0})}):null]},V.index))})]})}):void 0,className:D,...B,children:({width:V})=>jsxRuntime.jsx(Jb,{width:V,height:ee,data:e,tasks:q,x:t,domain:F,unit:_.unit,timeTicks:_.values,today:ne,grid:x,size:h,barSize:f,colorOf:U,margin:O,tooltip:C,plotLabel:k,todayLabel:X??w.chartToday,locale:H,formatDate:J,formatX:G,onTaskClick:K})})}var oy=24,ay=4,la=6,sy=Xo(mo,1),iy=Xo(mo,0),ly=Cl.memo(function({bars:t,connectors:r}){return jsxRuntime.jsxs("g",{children:[jsxRuntime.jsx("g",{className:"stroke-gray-300 dark:stroke-gray-600",strokeWidth:1,shapeRendering:"crispEdges","aria-hidden":"true",children:r.map(n=>jsxRuntime.jsx("line",{x1:n.x1,y1:n.y1,x2:n.x2,y2:n.y2},n.key))}),t.map(n=>jsxRuntime.jsxs("g",{children:[jsxRuntime.jsx("path",{d:n.d,fill:n.color}),n.label?jsxRuntime.jsx("text",{x:n.label.x,y:n.label.y,textAnchor:n.label.anchor,dominantBaseline:"middle",className:"fill-gray-600 text-[10px] [font-variant-numeric:tabular-nums] dark:fill-gray-300",children:n.label.text}):null]},n.key))]})});function cy({width:e,height:t,steps:r,data:n,x:o,y:a,grid:s,size:l,orientation:i,connectors:c,showValues:d,barSize:u,palette:f,margin:m,tooltip:g,plotLabel:y,totalLabel:b,formatValue:h,formatX:x,onStepClick:L}){let[C,S]=Cl.useState(null),v=Cl.useMemo(()=>{let W=i==="vertical",T=r.flatMap(B=>[B.start,B.end]),O=Jt({width:e,height:t,data:n,x:o,y:a,bounds:T.length===0?null:[Math.min(...T),Math.max(...T)],margin:m,orientation:i,placement:"band",formatValue:h,formatX:x,defaultIncludeZero:true}),{valueScale:H,bandwidth:k,categoryPositions:z,innerWidth:A,innerHeight:I}=O,X=H(0),$=Math.min(u??oy,k),K=[],D=[];return r.forEach((B,w)=>{let G=z[w]+(k-$)/2,q=H(B.start),j=H(B.end),U=Math.min(q,j),F=Math.abs(j-q),_=B.end>=B.start,J=W?_?"top":"bottom":_?"right":"left",ne=W?{x:G,y:U,width:$,height:F}:{x:U,y:G,width:F,height:$},Y=null;if(d&&B.value!==null){let Z=B.kind==="total"?B.formattedEnd:B.formattedValue,ie=ir(Z,10),V=H(_?Math.max(B.start,B.end):Math.min(B.start,B.end));if(W){let oe=_?V-la:V+la;ie<=k&&oe>8&&oe<I-4&&(Y={x:G+$/2,y:oe,anchor:"middle",text:Z});}else {let oe=_?A-V-la:V-la;ie<=oe&&(Y={x:_?V+la:V-la,y:G+$/2,anchor:_?"start":"end",text:Z});}}K.push({key:`${w}`,color:f[B.kind],d:fr({...ne,radius:ay,round:J}),label:Y});let ee=r[w+1];if(c&&ee){let Z=H(B.end),ie=z[w+1]+(k-$)/2;D.push(W?{key:`${w}`,x1:G+$,y1:Z,x2:ie,y2:Z}:{key:`${w}`,x1:Z,y1:G+$,x2:Z,y2:ie});}}),{vertical:W,bars:K,rules:D,baseline:X,bandwidth:k,categoryPositions:z,categoryCenters:O.categoryCenters,categoryTicks:O.categoryTicks,valueTicks:O.valueTicks,valueScale:H,innerWidth:A,innerHeight:I,margin:O.margin}},[r,n,o,a,e,t,m,i,c,d,u,f,h,x]),R=Cl.useCallback(W=>{if(g===false||r.length===0)return;let T=W.currentTarget.getBoundingClientRect(),O=v.vertical?W.clientX-T.left-v.margin.left:W.clientY-T.top-v.margin.top;S(Dt(v.categoryCenters,O));},[g,r.length,v.vertical,v.margin,v.categoryCenters]),N=Cl.useCallback(W=>{if(r.length===0)return;let T=r.length-1,O=C??0,H=v.vertical?"ArrowRight":"ArrowDown",k=v.vertical?"ArrowLeft":"ArrowUp",z=W.key===H?Math.min(T,O+1):W.key===k?Math.max(0,O-1):W.key==="Home"?0:W.key==="End"?T:W.key==="Escape"?null:void 0;z!==void 0&&(W.preventDefault(),S(z));},[r.length,C,v.vertical]),M=Cl.useCallback(()=>{!L||C===null||L(r[C]);},[L,C,r]),P=C===null?null:r[C],E=C===null||P===void 0||P===null?null:v.vertical?{x:v.margin.left+v.categoryCenters[C],y:v.margin.top+Math.min(v.valueScale(P.start),v.valueScale(P.end))}:{x:v.margin.left+Math.max(v.valueScale(P.start),v.valueScale(P.end)),y:v.margin.top+v.categoryCenters[C]};return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsxs("svg",{width:e,height:t,role:"img","aria-label":y??r.map(W=>W.label).join(", "),tabIndex:0,className:"touch-none focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-blue-500",onPointerMove:R,onPointerLeave:()=>S(null),onKeyDown:N,onBlur:()=>S(null),onClick:M,children:[jsxRuntime.jsxs("g",{transform:`translate(${v.margin.left}, ${v.margin.top})`,children:[jsxRuntime.jsx(Yt,{width:v.innerWidth,height:v.innerHeight,horizontal:v.vertical&&(s==="y"||s==="both")?v.valueTicks.map(W=>W.offset):void 0,vertical:!v.vertical&&(s==="y"||s==="both")?v.valueTicks.map(W=>W.offset):void 0}),C!==null?jsxRuntime.jsx("rect",{x:v.vertical?v.categoryPositions[C]:0,y:v.vertical?0:v.categoryPositions[C],width:v.vertical?v.bandwidth:v.innerWidth,height:v.vertical?v.innerHeight:v.bandwidth,className:"fill-gray-400 dark:fill-gray-500",opacity:.12,"aria-hidden":"true"}):null,jsxRuntime.jsx(ly,{bars:v.bars,connectors:v.rules}),jsxRuntime.jsx("line",{x1:v.vertical?0:v.baseline,y1:v.vertical?v.baseline:0,x2:v.vertical?v.innerWidth:v.baseline,y2:v.vertical?v.baseline:v.innerHeight,className:"stroke-gray-300 dark:stroke-gray-600",strokeWidth:1,shapeRendering:"crispEdges"})]}),jsxRuntime.jsx("g",{transform:`translate(${v.margin.left}, ${v.margin.top+v.innerHeight})`,children:(v.vertical?o.hidden:a?.hidden)?null:jsxRuntime.jsx(tt,{orientation:"bottom",ticks:v.vertical?v.categoryTicks:v.valueTicks,length:v.innerWidth,label:v.vertical?o.label:a?.label,size:l})}),jsxRuntime.jsx("g",{transform:`translate(${v.margin.left}, ${v.margin.top})`,children:(v.vertical?a?.hidden:o.hidden)?null:jsxRuntime.jsx(tt,{orientation:"left",ticks:v.vertical?v.valueTicks:v.categoryTicks,length:v.innerHeight,showLine:false,label:v.vertical?a?.label:o.label,size:l})})]}),P&&E&&g!==false?jsxRuntime.jsx(vt,{x:E.x,y:E.y,containerWidth:e,children:typeof g=="function"?g(P):jsxRuntime.jsxs("div",{className:"flex flex-col gap-1",children:[jsxRuntime.jsx("div",{className:"font-medium text-gray-900 dark:text-gray-100",children:P.label}),jsxRuntime.jsxs("div",{className:"flex items-center gap-2",children:[jsxRuntime.jsx("span",{className:"h-2.5 w-2.5 shrink-0 rounded-sm",style:{backgroundColor:f[P.kind]},"aria-hidden":"true"}),jsxRuntime.jsx("span",{className:"font-semibold text-gray-900 [font-variant-numeric:tabular-nums] dark:text-gray-100",children:P.kind==="total"?P.formattedEnd:P.formattedValue})]}),P.kind==="total"?null:jsxRuntime.jsxs("div",{className:"flex items-center gap-2 text-gray-500 dark:text-gray-400",children:[jsxRuntime.jsx("span",{children:b}),jsxRuntime.jsx("span",{className:"[font-variant-numeric:tabular-nums]",children:P.formattedEnd})]})]})}):null]})}function dy({data:e,x:t,y:r,value:n,total:o,start:a=0,orientation:s="vertical",connectors:l=true,showValues:i=true,barSize:c,colors:d,height:u=280,width:f,size:m="md",grid:g="y",legend:y,tooltip:b=true,tableView:h=false,title:x,description:L,loading:C=false,emptyState:S,error:v=false,errorState:R,onRetry:N,actions:M,margin:P,locale:E,plotLabel:W,valueLabel:T,totalLabel:O,increaseLabel:H,decreaseLabel:k,format:z,onStepClick:A,className:I,...X}){let $=Ve(),K=Cl.useMemo(()=>z??(_=>pt(_,E)),[z,E]),D=Cl.useMemo(()=>t.format??(_=>st(_,E)),[t.format,E]),B=Cl.useMemo(()=>{let _=a;return e.map((J,ne)=>{let Y=gt(J,t.key,ne),ee=Ae(J,n);if(o?!!J[o]:false){let oe=ee??_;return _=oe,{index:ne,x:Y,label:D(Y,ne),value:oe,start:0,end:oe,kind:"total",formattedValue:K(oe),formattedEnd:K(oe),datum:J}}let ie=_,V=ee===null?_:_+ee;return _=V,{index:ne,x:Y,label:D(Y,ne),value:ee,start:ie,end:V,kind:ee!==null&&ee<0?"decrease":"increase",formattedValue:ee===null?"\u2014":`${ee>0?"+":""}${K(ee)}`,formattedEnd:K(V),datum:J}})},[e,t.key,n,o,a,K,D]),w=Cl.useMemo(()=>({increase:d?.increase??sy,decrease:d?.decrease??iy,total:d?.total??Ar}),[d]),G=O??$.chartRunningTotal,q=Cl.useMemo(()=>{let _=[{key:"increase",label:H??$.chartIncrease,color:w.increase,marker:"rect"},{key:"decrease",label:k??$.chartDecrease,color:w.decrease,marker:"rect"}];return B.some(J=>J.kind==="total")&&_.push({key:"total",label:G,color:w.total,marker:"rect"}),_},[w,B,H,k,G,$.chartIncrease,$.chartDecrease]),j=Cl.useMemo(()=>B.map(_=>({[t.key]:_.x,[n]:_.kind==="total"?null:_.value,__running:_.end})),[B,t.key,n]),U=y===void 0?true:y!==false,F=typeof y=="string"?y:"bottom";return jsxRuntime.jsx(xt,{title:x,description:L,height:u,width:f,size:m,loading:C,empty:B.length===0,emptyState:S,error:v,errorState:R,onRetry:N,actions:M,tableView:h,legendPosition:F,legend:U?jsxRuntime.jsx(jt,{items:q,position:F,marker:"rect",size:m}):void 0,table:h?jsxRuntime.jsx(Ot,{data:j,series:[{key:n,label:T??$.chartValue},{key:"__running",label:G}],xKey:t.key,xLabel:t.label??t.key,formatX:D,formatValue:K,caption:typeof x=="string"?x:void 0}):void 0,className:I,...X,children:({width:_})=>jsxRuntime.jsx(cy,{width:_,height:u,steps:B,data:e,x:t,y:r,grid:g,size:m,orientation:s,connectors:l,showValues:i,barSize:c,palette:w,margin:P,tooltip:b,plotLabel:W,totalLabel:G,formatValue:K,formatX:D,onStepClick:A})})}var by=e=>{switch(e){case "sm":return {checkbox:"w-4 h-4",label:"text-xs",description:"text-xs"};case "lg":return {checkbox:"w-6 h-6",label:"text-base",description:"text-sm"};default:return {checkbox:"w-5 h-5",label:"text-sm",description:"text-xs"}}},yy=e=>{switch(e){case "circle":return "rounded-full";case "rounded":return "rounded-md";default:return "rounded"}},xy=({className:e})=>jsxRuntime.jsx("svg",{className:e,viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:jsxRuntime.jsx("path",{d:"M13.5 4.5L6 12L2.5 8.5",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round"})}),vy=({className:e})=>jsxRuntime.jsx("svg",{className:e,viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:jsxRuntime.jsx("path",{d:"M3 8H13",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round"})}),Ka=Cl.forwardRef(({checked:e,defaultChecked:t=false,onChange:r,disabled:n=false,readOnly:o=false,required:a=false,name:s,value:l,id:i,label:c,description:d,error:u=false,size:f="md",labelPosition:m="right",checkedColor:g="bg-blue-600",uncheckedColor:y="bg-white dark:bg-gray-800",borderColor:b="border-gray-300 dark:border-gray-600",labelColor:h,errorColor:x="text-red-500",checkmarkColor:L="text-white",hoverColor:C,focusRingColor:S="ring-blue-500",indeterminate:v=false,icon:R,variant:N="default",shape:M="square",animation:P=true,showFocusRing:E=true,className:W,containerClassName:T,style:O,tabIndex:H,...k},z)=>{let A=Cl.useId(),I=i||A,X=`${I}-error`,$=`${I}-description`,[K,D]=Cl.useState(t),B=e!==void 0,w=B?e:K,G=Cl.useRef(null);Cl.useEffect(()=>{G.current&&(G.current.indeterminate=v);},[v]);let q=ne=>{if(n||o)return;let Y=ne.target.checked;B||D(Y),r?.(Y,ne);},j=by(f),U=yy(M),F=()=>{let ne=p("relative flex items-center justify-center border-2 transition-all",j.checkbox,U,P&&"duration-200 ease-in-out");return n?p(ne,"opacity-50 cursor-not-allowed",w||v?g:y,b):N==="filled"?p(ne,w||v?g:"bg-gray-100 dark:bg-gray-700",w||v?"border-transparent":b,C&&!o&&`hover:${C}`,"cursor-pointer"):N==="outlined"?p(ne,y,w||v?`border-current ${g.replace("bg-","text-")}`:b,"border-2",C&&!o&&`hover:${C}`,"cursor-pointer"):p(ne,w||v?g:y,w||v?"border-transparent":b,C&&!o&&`hover:${C}`,"cursor-pointer")},_=u!==false,J=typeof u=="string"?u:void 0;return jsxRuntime.jsxs("div",{className:p("inline-flex flex-col",T),children:[jsxRuntime.jsxs("label",{htmlFor:I,className:p("inline-flex items-start gap-2",n?"cursor-not-allowed":"cursor-pointer",m==="left"&&"flex-row-reverse justify-end"),children:[jsxRuntime.jsx("input",{ref:ne=>{G&&(G.current=ne),typeof z=="function"?z(ne):z&&(z.current=ne);},type:"checkbox",id:I,name:s,value:l,checked:w,onChange:q,disabled:n,readOnly:o,required:a,tabIndex:o?-1:H,"aria-invalid":_,"aria-describedby":p(J&&X,d&&$),className:"sr-only peer",style:O,...k}),jsxRuntime.jsx("span",{className:p(F(),E&&`peer-focus-visible:ring-2 peer-focus-visible:ring-offset-2 peer-focus-visible:${S}`,P&&w&&"scale-100",_&&"border-red-500"),"aria-hidden":"true",children:(w||v)&&jsxRuntime.jsx("span",{className:p(L,P&&"animate-in zoom-in-50 duration-200"),children:v?R||jsxRuntime.jsx(vy,{className:"w-full h-full"}):R||jsxRuntime.jsx(xy,{className:"w-full h-full"})})}),c&&jsxRuntime.jsxs("span",{className:"flex flex-col gap-1",children:[jsxRuntime.jsxs("span",{className:p(j.label,n&&"opacity-50",h,_&&x),children:[c,a&&jsxRuntime.jsx("span",{className:"text-red-500 ml-1",children:"*"})]}),d&&jsxRuntime.jsx("span",{id:$,className:p(j.description,"text-gray-500 dark:text-gray-400",n&&"opacity-50"),children:d})]})]}),J&&jsxRuntime.jsx("p",{id:X,className:p("mt-1 text-xs",x),children:J})]})});Ka.displayName="Checkbox";var Su=Cl.createContext(null),Ru=({label:e,description:t,value:r,defaultValue:n=[],onChange:o,orientation:a="vertical",spacing:s="md",disabled:l=false,size:i="md",error:c=false,required:d=false,children:u,className:f,labelClassName:m,...g})=>{let[y,b]=Cl__namespace.useState(n),h=r!==void 0,x=h?r:y,L=Cl__namespace.useCallback(N=>{let M=x.includes(N)?x.filter(P=>P!==N):[...x,N];h||b(M),o?.(M);},[x,h,o]),C=Cl__namespace.useMemo(()=>({value:x,onChange:L,disabled:l,size:i}),[x,L,l,i]),S={sm:a==="vertical"?"gap-2":"gap-3",md:a==="vertical"?"gap-3":"gap-4",lg:a==="vertical"?"gap-4":"gap-6"},v=c!==false,R=typeof c=="string"?c:void 0;return jsxRuntime.jsxs("div",{className:p("flex flex-col gap-2",f),...g,children:[(e||t)&&jsxRuntime.jsxs("div",{className:"flex flex-col gap-1",children:[e&&jsxRuntime.jsxs("label",{className:p("text-sm font-medium text-gray-900 dark:text-gray-100",l&&"opacity-50",v&&"text-red-500",m),children:[e,d&&jsxRuntime.jsx("span",{className:"text-red-500 ml-1",children:"*"})]}),t&&jsxRuntime.jsx("p",{className:p("text-xs text-gray-500 dark:text-gray-400",l&&"opacity-50"),children:t})]}),jsxRuntime.jsx(Su.Provider,{value:C,children:jsxRuntime.jsx("div",{className:p("flex",a==="vertical"?"flex-col":"flex-row flex-wrap",S[s]),role:"group",children:u})}),R&&jsxRuntime.jsx("p",{className:"text-xs text-red-500",children:R})]})};Ru.displayName="CheckboxGroup";var Pu=({value:e,disabled:t,size:r,...n})=>{let o=Cl.useContext(Su);if(!o)return console.warn("CheckboxGroupItem doit \xEAtre utilis\xE9 dans un CheckboxGroup"),jsxRuntime.jsx(Ka,{...n,disabled:t,size:r});let{value:a,onChange:s,disabled:l,size:i}=o,c=a.includes(e);return jsxRuntime.jsx(Ka,{...n,checked:c,onChange:()=>s(e),disabled:l||t,size:r||i})};Pu.displayName="CheckboxGroupItem";var hr={compact:"px-3 py-1.5",default:"px-4 py-3",comfortable:"px-6 py-4"},si={compact:"text-xs",default:"text-sm",comfortable:"text-base"},Ry=()=>jsxRuntime.jsx("svg",{className:"w-3.5 h-3.5",viewBox:"0 0 16 16",fill:"currentColor",children:jsxRuntime.jsx("path",{d:"M8 3l4 5H4l4-5z"})}),Py=()=>jsxRuntime.jsx("svg",{className:"w-3.5 h-3.5",viewBox:"0 0 16 16",fill:"currentColor",children:jsxRuntime.jsx("path",{d:"M8 13l4-5H4l4 5z"})}),Ty=()=>jsxRuntime.jsx("svg",{className:"w-3.5 h-3.5 opacity-30",viewBox:"0 0 16 16",fill:"currentColor",children:jsxRuntime.jsx("path",{d:"M8 3l3 4H5l3-4zM8 13l3-4H5l3 4z"})}),Tu=({className:e})=>jsxRuntime.jsx("svg",{className:p("w-4 h-4",e),viewBox:"0 0 20 20",fill:"currentColor",children:jsxRuntime.jsx("path",{fillRule:"evenodd",d:"M5.23 7.21a.75.75 0 011.06.02L10 11.168l3.71-3.938a.75.75 0 111.08 1.04l-4.25 4.5a.75.75 0 01-1.08 0l-4.25-4.5a.75.75 0 01.02-1.06z",clipRule:"evenodd"})}),Dy=()=>jsxRuntime.jsx("svg",{className:"w-4 h-4 text-gray-400",viewBox:"0 0 20 20",fill:"currentColor",children:jsxRuntime.jsx("path",{fillRule:"evenodd",d:"M9 3.5a5.5 5.5 0 100 11 5.5 5.5 0 000-11zM2 9a7 7 0 1112.452 4.391l3.328 3.329a.75.75 0 11-1.06 1.06l-3.329-3.328A7 7 0 012 9z",clipRule:"evenodd"})}),Ey=()=>jsxRuntime.jsx("svg",{className:"w-4 h-4 text-gray-400",viewBox:"0 0 20 20",fill:"currentColor",children:jsxRuntime.jsx("path",{d:"M7 4a1.5 1.5 0 110-3 1.5 1.5 0 010 3zm6 0a1.5 1.5 0 110-3 1.5 1.5 0 010 3zM7 10.5a1.5 1.5 0 110-3 1.5 1.5 0 010 3zm6 0a1.5 1.5 0 110-3 1.5 1.5 0 010 3zM7 17a1.5 1.5 0 110-3 1.5 1.5 0 010 3zm6 0a1.5 1.5 0 110-3 1.5 1.5 0 010 3z"})}),Ly=()=>jsxRuntime.jsx("svg",{className:"w-3.5 h-3.5",viewBox:"0 0 20 20",fill:"currentColor",children:jsxRuntime.jsx("path",{fillRule:"evenodd",d:"M2.628 1.601C5.028 1.206 7.49 1 10 1s4.973.206 7.372.601a.75.75 0 01.628.74v2.288a2.25 2.25 0 01-.659 1.59l-4.682 4.683a2.25 2.25 0 00-.659 1.59v3.037c0 .684-.31 1.33-.844 1.757l-1.937 1.55A.75.75 0 018 18.25v-5.757a2.25 2.25 0 00-.659-1.591L2.659 6.22A2.25 2.25 0 012 4.629V2.34a.75.75 0 01.628-.74z",clipRule:"evenodd"})}),My=()=>jsxRuntime.jsxs("svg",{className:"w-4 h-4",viewBox:"0 0 20 20",fill:"currentColor",children:[jsxRuntime.jsx("path",{d:"M10.75 2.75a.75.75 0 00-1.5 0v8.614L6.295 8.235a.75.75 0 10-1.09 1.03l4.25 4.5a.75.75 0 001.09 0l4.25-4.5a.75.75 0 00-1.09-1.03l-2.955 3.129V2.75z"}),jsxRuntime.jsx("path",{d:"M3.5 12.75a.75.75 0 00-1.5 0v2.5A2.75 2.75 0 004.75 18h10.5A2.75 2.75 0 0018 15.25v-2.5a.75.75 0 00-1.5 0v2.5c0 .69-.56 1.25-1.25 1.25H4.75c-.69 0-1.25-.56-1.25-1.25v-2.5z"})]}),Iy=()=>jsxRuntime.jsx("svg",{className:"w-4 h-4",viewBox:"0 0 20 20",fill:"currentColor",children:jsxRuntime.jsx("path",{fillRule:"evenodd",d:"M2.5 3A1.5 1.5 0 001 4.5v11A1.5 1.5 0 002.5 17h15a1.5 1.5 0 001.5-1.5v-11A1.5 1.5 0 0017.5 3h-15zM2.5 4.5h6v11h-6v-11zm7.5 0h7.5v11H10v-11z",clipRule:"evenodd"})});function ai(e,t,r){return typeof r=="function"?r(e,t):String(typeof r=="string"?e[r]:t)}function ln(e,t){return e[t]}function Ay(e,t){return e==null&&t==null?0:e==null?-1:t==null?1:typeof e=="number"&&typeof t=="number"?e-t:String(e).localeCompare(String(t))}function zy(e,t){let r=String(e??"").toLowerCase(),n=t.value.toLowerCase();switch(t.operator){case "contains":return r.includes(n);case "equals":return r===n;case "startsWith":return r.startsWith(n);case "endsWith":return r.endsWith(n);case "gt":return Number(e)>Number(t.value);case "gte":return Number(e)>=Number(t.value);case "lt":return Number(e)<Number(t.value);case "lte":return Number(e)<=Number(t.value);case "isEmpty":return r==="";case "isNotEmpty":return r!=="";default:return true}}function Du(e,t,r){let n=[];for(let o of e){let a=Number(ln(o,t));isNaN(a)||n.push(a);}if(n.length===0)return 0;switch(r){case "sum":return n.reduce((o,a)=>o+a,0);case "avg":return n.reduce((o,a)=>o+a,0)/n.length;case "count":return n.length;case "min":return Math.min(...n);case "max":return Math.max(...n)}}function By({cols:e,density:t}){return jsxRuntime.jsx("tr",{className:"border-b border-gray-200 dark:border-gray-700",children:Array.from({length:e}).map((r,n)=>jsxRuntime.jsx("td",{className:hr[t],children:jsxRuntime.jsx("div",{className:"h-4 bg-gray-200 dark:bg-gray-700 rounded animate-pulse"})},n))})}function Hy({column:e,value:t,onApply:r,onClear:n}){let[o,a]=Cl.useState(false),[s,l]=Cl.useState(t?.operator??"contains"),[i,c]=Cl.useState(t?.value??""),d=Cl.useRef(null),u=e.filterType??"text",f=u==="number"?[{value:"equals",label:"Equals"},{value:"gt",label:"Greater than"},{value:"gte",label:"Greater or equal"},{value:"lt",label:"Less than"},{value:"lte",label:"Less or equal"}]:[{value:"contains",label:"Contains"},{value:"equals",label:"Equals"},{value:"startsWith",label:"Starts with"},{value:"endsWith",label:"Ends with"},{value:"isEmpty",label:"Is empty"},{value:"isNotEmpty",label:"Is not empty"}];return Cl.useEffect(()=>{let m=g=>{d.current&&!d.current.contains(g.target)&&a(false);};return o&&document.addEventListener("mousedown",m),()=>document.removeEventListener("mousedown",m)},[o]),jsxRuntime.jsxs("div",{className:"relative inline-block",ref:d,children:[jsxRuntime.jsx("button",{type:"button",onClick:m=>{m.stopPropagation(),a(!o);},className:p("p-0.5 rounded hover:bg-gray-200 dark:hover:bg-gray-600 cursor-pointer",t&&"text-blue-600 dark:text-blue-400"),"aria-label":`Filter ${String(e.header)}`,children:jsxRuntime.jsx(Ly,{})}),o&&jsxRuntime.jsx("div",{className:"absolute z-50 top-full left-0 mt-1 bg-white dark:bg-gray-800 border border-gray-200 dark:border-gray-700 rounded-lg shadow-lg p-3 min-w-[220px]",children:u==="select"&&e.filterOptions?jsxRuntime.jsxs("div",{className:"flex flex-col gap-1.5",children:[e.filterOptions.map(m=>jsxRuntime.jsxs("label",{className:"flex items-center gap-2 text-sm cursor-pointer",children:[jsxRuntime.jsx("input",{type:"radio",name:`filter-${e.key}`,value:m,checked:i===m,onChange:()=>c(m),className:"cursor-pointer"}),jsxRuntime.jsx("span",{className:"text-gray-700 dark:text-gray-300",children:m})]},m)),jsxRuntime.jsxs("div",{className:"flex gap-2 mt-2",children:[jsxRuntime.jsx("button",{type:"button",onClick:()=>{r({column:e.key,operator:"equals",value:i}),a(false);},className:"px-2 py-1 text-xs bg-blue-600 text-white rounded hover:bg-blue-700 cursor-pointer",children:"Apply"}),jsxRuntime.jsx("button",{type:"button",onClick:()=>{c(""),n(),a(false);},className:"px-2 py-1 text-xs text-gray-600 dark:text-gray-400 hover:text-gray-800 dark:hover:text-gray-200 cursor-pointer",children:"Clear"})]})]}):jsxRuntime.jsxs("div",{className:"flex flex-col gap-2",children:[jsxRuntime.jsx("select",{value:s,onChange:m=>l(m.target.value),className:"text-xs border border-gray-300 dark:border-gray-600 rounded px-2 py-1 bg-white dark:bg-gray-700 text-gray-700 dark:text-gray-200",children:f.map(m=>jsxRuntime.jsx("option",{value:m.value,children:m.label},m.value))}),s!=="isEmpty"&&s!=="isNotEmpty"&&jsxRuntime.jsx("input",{type:u==="number"?"number":u==="date"?"date":"text",value:i,onChange:m=>c(m.target.value),placeholder:"Filter value...",className:"text-xs border border-gray-300 dark:border-gray-600 rounded px-2 py-1 bg-white dark:bg-gray-700 text-gray-700 dark:text-gray-200",autoFocus:true,"aria-label":`Filter ${String(e.header)} value`}),jsxRuntime.jsxs("div",{className:"flex gap-2",children:[jsxRuntime.jsx("button",{type:"button",onClick:()=>{r({column:e.key,operator:s,value:i}),a(false);},className:"px-2 py-1 text-xs bg-blue-600 text-white rounded hover:bg-blue-700 cursor-pointer",children:"Apply"}),jsxRuntime.jsx("button",{type:"button",onClick:()=>{c(""),n(),a(false);},className:"px-2 py-1 text-xs text-gray-600 dark:text-gray-400 hover:text-gray-800 dark:hover:text-gray-200 cursor-pointer",children:"Clear"})]})]})})]})}function Wy({value:e,onSave:t,density:r}){let[n,o]=Cl.useState(false),[a,s]=Cl.useState(String(e??"")),l=Cl.useRef(null);if(Cl.useEffect(()=>{n&&l.current&&(l.current.focus(),l.current.select());},[n]),!n)return jsxRuntime.jsx("div",{onDoubleClick:()=>{s(String(e??"")),o(true);},className:"cursor-text min-h-[1.5em]",title:"Double-click to edit",children:String(e??"")});let i=()=>{o(false),a!==String(e??"")&&t(a);};return jsxRuntime.jsx("input",{ref:l,type:"text",value:a,onChange:c=>s(c.target.value),onBlur:i,"aria-label":"Edit cell value",onKeyDown:c=>{c.key==="Enter"&&i(),c.key==="Escape"&&o(false);},className:p("w-full border border-blue-500 rounded px-1 py-0.5 bg-white dark:bg-gray-700 text-gray-900 dark:text-gray-100 outline-none",si[r])})}function Vy(e,t){let{columns:r,data:n,rowKey:o,mode:a="client",sortable:s=false,multiSort:l=false,sort:i,defaultSort:c,onSort:d,pagination:u=false,page:f,onPageChange:m,onPageSizeChange:g,totalItems:y,selectable:b=false,selectionMode:h="multiple",selectedRows:x,onSelectionChange:L,searchable:C=false,searchPlaceholder:S="Search...",searchValue:v,onSearch:R,filters:N,onFilterChange:M,expandable:P=false,expandedContent:E,expandedRows:W,onExpandChange:T,editable:O=false,onCellEdit:H,reorderable:k=false,onReorder:z,columnReorderable:A=false,onColumnReorder:I,columnToggle:X=false,hiddenColumns:$,onColumnVisibilityChange:K,groupBy:D,renderGroupHeader:B,exportable:w=false,exportFormats:G=["csv","json"],exportFilename:q="export",virtualized:j=false,rowHeight:U=40,virtualHeight:F=400,density:_="default",striped:J=false,bordered:ne=false,borderless:Y=false,stickyHeader:ee=false,maxHeight:Z,loading:ie=false,loadingRows:V=5,emptyState:oe,showFooter:pe=false,onRowClick:Te,onRowDoubleClick:ze,onRowContextMenu:ae,className:re,rowClassName:ce,cellClassName:De,headerClassName:Ge}=e,[be,Me]=Cl.useState(c??[]),[Re,He]=Cl.useState(1),[Ee,$e]=Cl.useState(typeof u=="object"?u.pageSize??10:10),[bt,Kt]=Cl.useState([]),[dr,_t]=Cl.useState(""),[Xt,Mr]=Cl.useState([]),[Ce,we]=Cl.useState([]),[se,de]=Cl.useState(()=>r.flatMap(Q=>Q.hidden?[Q.key]:[])),[ke,ve]=Cl.useState({}),[Be,Pe]=Cl.useState(()=>r.map(Q=>Q.key)),[ye,Xe]=Cl.useState(null),[We,ut]=Cl.useState(null),[ot,Ke]=Cl.useState(false),[mt,ct]=Cl.useState(new Set),xr=Cl.useRef(null),[Pt,jr]=Cl.useState(0),hn=Cl.useRef(null),ar=i??be,sr=f??Re,te=x??bt,ue=v??dr,me=N??Xt,ge=W??Ce,xe=$??se,Ye=u?typeof u=="object"?u:{pageSize:10,pageSizeOptions:[10,25,50,100]}:null,at=Ye?.pageSize??Ee,et=Cl.useMemo(()=>{let Q=new Map(r.map(Ie=>[Ie.key,Ie])),le=Be.flatMap(Ie=>{let qe=Q.get(Ie);return qe?[qe]:[]}),he=new Set(le.map(Ie=>Ie.key));for(let Ie of r)he.has(Ie.key)||(le.push(Ie),he.add(Ie.key));return le.filter(Ie=>!xe.includes(Ie.key))},[r,Be,xe]),Fe=Cl.useMemo(()=>{if(a==="server")return n;let Q=[...n];if(ue){let le=ue.toLowerCase();Q=Q.filter(he=>et.some(Ie=>{let qe=ln(he,Ie.key);return String(qe??"").toLowerCase().includes(le)}));}if(me.length>0&&(Q=Q.filter(le=>me.every(he=>zy(ln(le,he.column),he)))),ar.length>0){let le=new Map(r.map(he=>[he.key,he]));Q.sort((he,Ie)=>{for(let qe of ar){if(!qe.direction)continue;let Wt=le.get(qe.key),wr=Wt?.sortComparator?Wt.sortComparator(he,Ie):Ay(ln(he,qe.key),ln(Ie,qe.key));if(wr!==0)return qe.direction==="asc"?wr:-wr}return 0});}return Q},[n,a,ue,me,ar,et,r]),St=Cl.useMemo(()=>{if(!D)return null;let Q=Array.isArray(D)?D:[D],le=new Map;for(let he of Fe){let Ie=Q.map(Wt=>String(ln(he,Wt)??"")).join(" / "),qe=le.get(Ie)??[];qe.push(he),le.set(Ie,qe);}return le},[Fe,D]),je=y??Fe.length,Mt=Math.max(1,Math.ceil(je/at)),Gt=Cl.useMemo(()=>{if(!Ye||a==="server")return Fe;let Q=(sr-1)*at;return Fe.slice(Q,Q+at)},[Fe,Ye,sr,at,a]),Tt=Ye?Gt:Fe,gr=Cl.useMemo(()=>{if(!j)return {start:0,end:Tt.length};let Q=Math.floor(Pt/U),le=Math.ceil(F/U),he=5;return {start:Math.max(0,Q-he),end:Math.min(Tt.length,Q+le+he)}},[j,Pt,U,F,Tt.length]),qr=Cl.useCallback(Q=>{i||Me(Q),d?.(Q);},[i,d]),Zr=Cl.useCallback(Q=>{let le=ar.find(Ie=>Ie.key===Q),he;if(!le||!le.direction?he="asc":le.direction==="asc"?he="desc":he=null,l){let Ie=ar.filter(qe=>qe.key!==Q);he&&Ie.push({key:Q,direction:he}),qr(Ie);}else qr(he?[{key:Q,direction:he}]:[]);},[ar,l,qr]),Rr=Cl.useCallback(Q=>{let le=Math.max(1,Math.min(Q,Mt));f||He(le),m?.(le);},[f,m,Mt]),Vi=Cl.useCallback(Q=>{$e(Q),Rr(1),g?.(Q);},[Rr,g]),bs=Cl.useCallback(Q=>{let le;h==="single"?le=te.includes(Q)?[]:[Q]:le=te.includes(Q)?te.filter(he=>he!==Q):[...te,Q],x||Kt(le),L?.(le);},[h,te,x,L]),Oi=Cl.useCallback(()=>{let Q=Tt.map((le,he)=>ai(le,he,o));x||Kt(Q),L?.(Q);},[Tt,o,x,L]),Fi=Cl.useCallback(()=>{x||Kt([]),L?.([]);},[x,L]),$i=Tt.length>0&&Tt.every((Q,le)=>te.includes(ai(Q,le,o))),Qp=!$i&&Tt.some((Q,le)=>te.includes(ai(Q,le,o))),Jp=Cl.useCallback(Q=>{let le=ge.includes(Q)?ge.filter(he=>he!==Q):[...ge,Q];W||we(le),T?.(le);},[ge,W,T]),eg=Cl.useCallback(Q=>{let le=Q.target.value;v||_t(le),R?.(le),Rr(1);},[v,R,Rr]),tg=Cl.useCallback(Q=>{let le=[...me.filter(he=>he.column!==Q.column),Q];N||Mr(le),M?.(le);},[me,N,M]),rg=Cl.useCallback(Q=>{let le=me.filter(he=>he.column!==Q);N||Mr(le),M?.(le);},[me,N,M]),ng=Cl.useCallback(Q=>{let le=xe.includes(Q)?xe.filter(he=>he!==Q):[...xe,Q];$||de(le),K?.(le);},[xe,$,K]),og=Cl.useCallback((Q,le)=>{Q.preventDefault(),Q.stopPropagation();let he=Q.clientX,Ie=ke[le]??Q.currentTarget.parentElement?.getBoundingClientRect().width??100,qe=r.find(Nr=>Nr.key===le),Wt=qe?.minWidth??50,wr=qe?.maxWidth??1/0,yt=Nr=>{let to=Nr.clientX-he,Jr=Math.min(wr,Math.max(Wt,Ie+to));ve(Ho=>({...Ho,[le]:Jr}));},Qr=()=>{document.removeEventListener("mousemove",yt),document.removeEventListener("mouseup",Qr);};document.addEventListener("mousemove",yt),document.addEventListener("mouseup",Qr);},[ke,r]),ag=Cl.useCallback(Q=>{k&&Xe(Q);},[k]),sg=Cl.useCallback((Q,le)=>{!k||ye===null||Q.preventDefault();},[k,ye]),ig=Cl.useCallback(Q=>{!k||ye===null||ye===Q||(z?.(ye,Q),Xe(null));},[k,ye,z]),lg=Cl.useCallback(Q=>{A&&ut(Q);},[A]),cg=Cl.useCallback(Q=>{if(!A||!We||We===Q)return;let le=[...Be],he=le.indexOf(We),Ie=le.indexOf(Q);he===-1||Ie===-1||(le.splice(he,1),le.splice(Ie,0,We),Pe(le),I?.(We,Q),ut(null));},[A,We,Be,I]),_i=Cl.useCallback(Q=>{let le=et.filter(Nr=>Nr.type!=="actions"&&Nr.type!=="selection"&&Nr.type!=="expand"),he=Fe,Ie,qe,Wt;if(Q==="csv"){let Nr=le.map(Jr=>String(Jr.header)).join(","),to=he.map(Jr=>le.map(Ho=>{let Ui=String(ln(Jr,Ho.key)??"");return Ui.includes(",")?`"${Ui}"`:Ui}).join(","));Ie=[Nr,...to].join(`
3
+ `),qe="text/csv",Wt="csv";}else {let Nr=he.map(to=>{let Jr={};for(let Ho of le)Jr[Ho.key]=ln(to,Ho.key);return Jr});Ie=JSON.stringify(Nr,null,2),qe="application/json",Wt="json";}let wr=new Blob([Ie],{type:qe}),yt=URL.createObjectURL(wr),Qr=document.createElement("a");Qr.href=yt,Qr.download=`${q}.${Wt}`,Qr.click(),URL.revokeObjectURL(yt);},[et,Fe,q]);Cl.useEffect(()=>{if(!ot)return;let Q=le=>{hn.current&&!hn.current.contains(le.target)&&Ke(false);};return document.addEventListener("mousedown",Q),()=>document.removeEventListener("mousedown",Q)},[ot]),Cl.useImperativeHandle(t,()=>({getVisibleData:()=>Tt,resetFilters:()=>{N||Mr([]),v||_t(""),M?.([]),R?.("");},resetSort:()=>{i||Me([]),d?.([]);},selectAll:Oi,deselectAll:Fi,exportData:_i,scrollToRow:Q=>{xr.current&&j&&(xr.current.scrollTop=Q*U);}}),[Tt,N,v,i,M,R,d,Oi,Fi,_i,j,U]);let Xi=Q=>{let le={},he=ke[Q.key]??Q.width;return he&&(le.width=typeof he=="number"?`${he}px`:he,le.minWidth=typeof he=="number"?`${he}px`:he),Q.sticky&&(le.position="sticky",le[Q.sticky]=0,le.zIndex=10),le},Bo=et.length+(b?1:0)+(P?1:0)+(k?1:0),dg=Q=>{let le=s&&Q.sortable!==false&&Q.type!=="actions",he=ar.find(qe=>qe.key===Q.key),Ie=Q.filterable&&(Q.filterType||Q.filterOptions);return jsxRuntime.jsxs("th",{className:p(hr[_],si[_],"font-semibold text-gray-700 dark:text-gray-300 whitespace-nowrap",Q.align==="center"&&"text-center",Q.align==="right"&&"text-right",le&&"cursor-pointer select-none hover:bg-gray-100 dark:hover:bg-gray-700",ne&&"border border-gray-200 dark:border-gray-700",Q.sticky&&"bg-gray-50 dark:bg-gray-800",Q.headerClassName,Ge),style:Xi(Q),onClick:le?()=>Zr(Q.key):void 0,draggable:A,onDragStart:A?()=>lg(Q.key):void 0,onDragOver:A?qe=>qe.preventDefault():void 0,onDrop:A?()=>cg(Q.key):void 0,"aria-sort":he?.direction==="asc"?"ascending":he?.direction==="desc"?"descending":void 0,children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-1",children:[Q.renderHeader?Q.renderHeader(Q):Q.header,le&&jsxRuntime.jsx("span",{className:"inline-flex ml-1",children:he?.direction==="asc"?jsxRuntime.jsx(Ry,{}):he?.direction==="desc"?jsxRuntime.jsx(Py,{}):jsxRuntime.jsx(Ty,{})}),Ie&&jsxRuntime.jsx(Hy,{column:Q,value:me.find(qe=>qe.column===Q.key),onApply:tg,onClear:()=>rg(Q.key)})]}),Q.resizable!==false&&jsxRuntime.jsx("div",{className:"absolute top-0 right-0 w-1 h-full cursor-col-resize hover:bg-blue-500 opacity-0 hover:opacity-100",onMouseDown:qe=>og(qe,Q.key)})]},Q.key)},Gi=(Q,le,he)=>{let Ie=ai(Q,he,o),qe=te.includes(Ie),Wt=ge.includes(Ie),wr=typeof ce=="function"?ce(Q,he):ce;return jsxRuntime.jsxs(Cl__namespace.default.Fragment,{children:[jsxRuntime.jsxs("tr",{className:p("border-b border-gray-200 dark:border-gray-700 transition-colors",J&&he%2===1&&"bg-gray-50/50 dark:bg-gray-800/50",qe&&"bg-blue-50 dark:bg-blue-900/20",Te&&"cursor-pointer hover:bg-gray-50 dark:hover:bg-gray-700/50",ye===le&&"opacity-50",wr),onClick:Te?()=>Te(Q,he):void 0,onDoubleClick:ze?()=>ze(Q,he):void 0,onContextMenu:ae?yt=>ae(Q,he,yt):void 0,draggable:k,onDragStart:k?()=>ag(le):void 0,onDragOver:k?yt=>sg(yt,le):void 0,onDrop:k?()=>ig(le):void 0,"data-row-key":Ie,"aria-selected":b?qe:void 0,children:[k&&jsxRuntime.jsx("td",{className:p(hr[_],"cursor-grab active:cursor-grabbing"),children:jsxRuntime.jsx(Ey,{})}),b&&jsxRuntime.jsx("td",{className:p(hr[_],"w-10"),children:jsxRuntime.jsx("input",{type:"checkbox",checked:qe,onChange:()=>bs(Ie),onClick:yt=>yt.stopPropagation(),className:"rounded border-gray-300 dark:border-gray-600 cursor-pointer","aria-label":`Select row ${Ie}`})}),P&&jsxRuntime.jsx("td",{className:p(hr[_],"w-10"),children:jsxRuntime.jsx("button",{type:"button",onClick:yt=>{yt.stopPropagation(),Jp(Ie);},className:"p-0.5 rounded hover:bg-gray-200 dark:hover:bg-gray-600 cursor-pointer","aria-label":Wt?"Collapse row":"Expand row","aria-expanded":Wt,children:jsxRuntime.jsx(Tu,{className:p("transition-transform",Wt&&"rotate-180")})})}),et.map(yt=>{let Qr=ln(Q,yt.key),Nr=yt.colSpan?.(Q,he);if(Nr===0)return null;let to=O&&yt.editable!==false&&yt.type!=="actions";return jsxRuntime.jsx("td",{className:p(hr[_],si[_],"text-gray-700 dark:text-gray-300",yt.align==="center"&&"text-center",yt.align==="right"&&"text-right",ne&&"border border-gray-200 dark:border-gray-700",yt.sticky&&(qe?"bg-blue-50 dark:bg-blue-900/20":J&&he%2===1?"bg-gray-50/50 dark:bg-gray-800/50":"bg-white dark:bg-gray-900"),yt.cellClassName,De),style:Xi(yt),colSpan:Nr,children:to?jsxRuntime.jsx(Wy,{value:Qr,onSave:Jr=>H?.(Ie,yt.key,Jr),density:_}):yt.render?yt.render(Qr,Q,he):String(Qr??"")},yt.key)})]}),P&&Wt&&E&&jsxRuntime.jsx("tr",{className:"bg-gray-50 dark:bg-gray-800/70",children:jsxRuntime.jsx("td",{colSpan:Bo,className:p(hr[_]),children:E(Q,he)})})]},Ie)},ug=()=>{if(ie)return Array.from({length:V}).map((Q,le)=>jsxRuntime.jsx(By,{cols:Bo,density:_},le));if(Tt.length===0)return jsxRuntime.jsx("tr",{children:jsxRuntime.jsx("td",{colSpan:Bo,className:p("text-center text-gray-400 dark:text-gray-500",hr[_]),children:oe??"No data available"})});if(St){let Q=[],le=0;for(let[he,Ie]of St){let qe=mt.has(he);if(Q.push(jsxRuntime.jsx("tr",{className:"bg-gray-100 dark:bg-gray-800 font-medium",children:jsxRuntime.jsx("td",{colSpan:Bo,className:p(hr[_],"cursor-pointer"),onClick:()=>{ct(Wt=>{let wr=new Set(Wt);return wr.has(he)?wr.delete(he):wr.add(he),wr});},children:jsxRuntime.jsxs("div",{className:"flex items-center gap-2",children:[jsxRuntime.jsx(Tu,{className:p("transition-transform",qe&&"-rotate-90")}),B?B(he,ln(Ie[0],Array.isArray(D)?D[0]:D),Ie):`${he} (${Ie.length})`]})})},`group-${he}`)),qe)le+=Ie.length;else for(let Wt=0;Wt<Ie.length;Wt++)Q.push(Gi(Ie[Wt],le,le)),le++;}return Q}if(j){let Q=[];for(let le=gr.start;le<gr.end;le++)Q.push(Gi(Tt[le],le,le));return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[gr.start>0&&jsxRuntime.jsx("tr",{children:jsxRuntime.jsx("td",{colSpan:Bo,style:{height:gr.start*U,padding:0}})}),Q,gr.end<Tt.length&&jsxRuntime.jsx("tr",{children:jsxRuntime.jsx("td",{colSpan:Bo,style:{height:(Tt.length-gr.end)*U,padding:0}})})]})}return Tt.map((Q,le)=>Gi(Q,le,le))},mg=()=>!pe||!et.some(le=>le.aggregate)?null:jsxRuntime.jsx("tfoot",{children:jsxRuntime.jsxs("tr",{className:"bg-gray-50 dark:bg-gray-800 font-semibold border-t-2 border-gray-300 dark:border-gray-600",children:[k&&jsxRuntime.jsx("td",{className:hr[_]}),b&&jsxRuntime.jsx("td",{className:hr[_]}),P&&jsxRuntime.jsx("td",{className:hr[_]}),et.map(le=>jsxRuntime.jsx("td",{className:p(hr[_],si[_],"text-gray-700 dark:text-gray-300",le.align==="center"&&"text-center",le.align==="right"&&"text-right",ne&&"border border-gray-200 dark:border-gray-700"),style:Xi(le),children:le.aggregate?le.renderAggregate?le.renderAggregate(Du(Fe,le.key,le.aggregate),Fe):`${le.aggregate==="count"?"":le.aggregate==="avg"?"Avg: ":le.aggregate==="sum"?"Total: ":le.aggregate==="min"?"Min: ":"Max: "}${Du(Fe,le.key,le.aggregate).toLocaleString()}`:""},le.key))]})});return jsxRuntime.jsxs("div",{className:p("flex flex-col gap-3",re),children:[(C||w||X)&&jsxRuntime.jsxs("div",{className:"flex items-center justify-between gap-3 flex-wrap",children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-3 flex-1",children:[C&&jsxRuntime.jsxs("div",{className:"relative flex-1 max-w-xs",children:[jsxRuntime.jsx("div",{className:"absolute inset-y-0 left-0 flex items-center pl-3 pointer-events-none",children:jsxRuntime.jsx(Dy,{})}),jsxRuntime.jsx("input",{type:"text",value:ue,onChange:eg,placeholder:S,className:"w-full pl-9 pr-3 py-1.5 text-sm border border-gray-300 dark:border-gray-600 rounded-md bg-white dark:bg-gray-800 text-gray-700 dark:text-gray-200 focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-blue-500","aria-label":"Search table"})]}),te.length>0&&jsxRuntime.jsxs("span",{className:"text-sm text-gray-500 dark:text-gray-400",children:[te.length," selected"]})]}),jsxRuntime.jsxs("div",{className:"flex items-center gap-2",children:[X&&jsxRuntime.jsxs("div",{className:"relative",ref:hn,children:[jsxRuntime.jsx("button",{type:"button",onClick:()=>Ke(!ot),className:"p-1.5 rounded-md border border-gray-300 dark:border-gray-600 text-gray-600 dark:text-gray-400 hover:bg-gray-100 dark:hover:bg-gray-700 cursor-pointer","aria-label":"Toggle columns",title:"Toggle columns",children:jsxRuntime.jsx(Iy,{})}),ot&&jsxRuntime.jsx("div",{className:"absolute z-50 right-0 top-full mt-1 bg-white dark:bg-gray-800 border border-gray-200 dark:border-gray-700 rounded-lg shadow-lg p-2 min-w-[180px]",children:r.filter(Q=>Q.type!=="selection"&&Q.type!=="expand").map(Q=>jsxRuntime.jsxs("label",{className:"flex items-center gap-2 px-2 py-1.5 text-sm rounded hover:bg-gray-100 dark:hover:bg-gray-700 cursor-pointer",children:[jsxRuntime.jsx("input",{type:"checkbox",checked:!xe.includes(Q.key),onChange:()=>ng(Q.key),className:"rounded border-gray-300 dark:border-gray-600 cursor-pointer"}),jsxRuntime.jsx("span",{className:"text-gray-700 dark:text-gray-300",children:String(Q.header)})]},Q.key))})]}),w&&G.map(Q=>jsxRuntime.jsxs("button",{type:"button",onClick:()=>_i(Q),className:"inline-flex items-center gap-1.5 px-2.5 py-1.5 text-xs font-medium rounded-md border border-gray-300 dark:border-gray-600 text-gray-600 dark:text-gray-400 hover:bg-gray-100 dark:hover:bg-gray-700 cursor-pointer",title:`Export as ${Q.toUpperCase()}`,children:[jsxRuntime.jsx(My,{}),Q.toUpperCase()]},Q))]})]}),jsxRuntime.jsx("div",{ref:xr,className:p("overflow-auto rounded-lg",!Y&&"border border-gray-200 dark:border-gray-700",ee&&"relative"),style:Z?{maxHeight:typeof Z=="number"?`${Z}px`:Z}:j?{maxHeight:F,overflow:"auto"}:void 0,onScroll:j?Q=>jr(Q.target.scrollTop):void 0,children:jsxRuntime.jsxs("table",{className:"w-full text-left",children:[jsxRuntime.jsx("thead",{className:p("bg-gray-50 dark:bg-gray-800 text-xs uppercase",ee&&"sticky top-0 z-20"),children:jsxRuntime.jsxs("tr",{children:[k&&jsxRuntime.jsx("th",{className:p(hr[_],"w-10 font-semibold text-gray-700 dark:text-gray-300")}),b&&jsxRuntime.jsx("th",{className:p(hr[_],"w-10"),children:h==="multiple"&&jsxRuntime.jsx("input",{type:"checkbox",checked:$i,ref:Q=>{Q&&(Q.indeterminate=Qp);},onChange:$i?Fi:Oi,className:"rounded border-gray-300 dark:border-gray-600 cursor-pointer","aria-label":"Select all rows"})}),P&&jsxRuntime.jsx("th",{className:p(hr[_],"w-10 font-semibold text-gray-700 dark:text-gray-300")}),et.map(dg)]})}),jsxRuntime.jsx("tbody",{children:ug()}),mg()]})}),Ye&&jsxRuntime.jsxs("div",{className:"flex items-center justify-between flex-wrap gap-3 text-sm text-gray-600 dark:text-gray-400",children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-3",children:[Ye.showTotalItems!==false&&jsxRuntime.jsxs("span",{children:[je," item",je!==1?"s":""]}),Ye.showPageSizeSelector!==false&&Ye.pageSizeOptions&&jsxRuntime.jsxs("div",{className:"flex items-center gap-1.5",children:[jsxRuntime.jsx("span",{children:"Rows per page:"}),jsxRuntime.jsx("select",{value:at,onChange:Q=>Vi(Number(Q.target.value)),className:"border border-gray-300 dark:border-gray-600 rounded px-1.5 py-0.5 bg-white dark:bg-gray-800 text-gray-700 dark:text-gray-200 text-sm",children:Ye.pageSizeOptions.map(Q=>jsxRuntime.jsx("option",{value:Q,children:Q},Q))})]})]}),jsxRuntime.jsxs("div",{className:"flex items-center gap-1",children:[jsxRuntime.jsxs("span",{className:"mr-2",children:["Page ",sr," of ",Mt]}),jsxRuntime.jsx("button",{type:"button",onClick:()=>Rr(1),disabled:sr<=1,className:"px-2 py-1 rounded border border-gray-300 dark:border-gray-600 disabled:opacity-50 disabled:cursor-not-allowed hover:bg-gray-100 dark:hover:bg-gray-700 cursor-pointer","aria-label":"First page",children:"\xAB\xAB"}),jsxRuntime.jsx("button",{type:"button",onClick:()=>Rr(sr-1),disabled:sr<=1,className:"px-2 py-1 rounded border border-gray-300 dark:border-gray-600 disabled:opacity-50 disabled:cursor-not-allowed hover:bg-gray-100 dark:hover:bg-gray-700 cursor-pointer","aria-label":"Previous page",children:"\xAB"}),jsxRuntime.jsx("button",{type:"button",onClick:()=>Rr(sr+1),disabled:sr>=Mt,className:"px-2 py-1 rounded border border-gray-300 dark:border-gray-600 disabled:opacity-50 disabled:cursor-not-allowed hover:bg-gray-100 dark:hover:bg-gray-700 cursor-pointer","aria-label":"Next page",children:"\xBB"}),jsxRuntime.jsx("button",{type:"button",onClick:()=>Rr(Mt),disabled:sr>=Mt,className:"px-2 py-1 rounded border border-gray-300 dark:border-gray-600 disabled:opacity-50 disabled:cursor-not-allowed hover:bg-gray-100 dark:hover:bg-gray-700 cursor-pointer","aria-label":"Last page",children:"\xBB\xBB"})]})]})]})}var Oy=Cl.forwardRef(Vy);function $y({className:e}){return jsxRuntime.jsx("svg",{className:e,viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",children:jsxRuntime.jsx("path",{d:"M4 4L12 12M12 4L4 12",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})})}var _y={default:{solid:"bg-gray-500 text-white",outlined:"border-gray-300 text-gray-700 dark:border-gray-600 dark:text-gray-300 bg-transparent",soft:"bg-gray-100 text-gray-700 dark:bg-gray-700 dark:text-gray-300",dot:"bg-gray-100 text-gray-700 dark:bg-gray-800 dark:text-gray-300"},primary:{solid:"bg-blue-600 text-white",outlined:"border-blue-600 text-blue-600 dark:border-blue-400 dark:text-blue-400 bg-transparent",soft:"bg-blue-100 text-blue-700 dark:bg-blue-900/50 dark:text-blue-300",dot:"bg-blue-50 text-blue-700 dark:bg-blue-900/30 dark:text-blue-300"},success:{solid:"bg-green-600 text-white",outlined:"border-green-600 text-green-600 dark:border-green-400 dark:text-green-400 bg-transparent",soft:"bg-green-100 text-green-700 dark:bg-green-900/50 dark:text-green-300",dot:"bg-green-50 text-green-700 dark:bg-green-900/30 dark:text-green-300"},warning:{solid:"bg-yellow-500 text-white",outlined:"border-yellow-500 text-yellow-600 dark:border-yellow-400 dark:text-yellow-400 bg-transparent",soft:"bg-yellow-100 text-yellow-700 dark:bg-yellow-900/50 dark:text-yellow-300",dot:"bg-yellow-50 text-yellow-700 dark:bg-yellow-900/30 dark:text-yellow-300"},error:{solid:"bg-red-600 text-white",outlined:"border-red-600 text-red-600 dark:border-red-400 dark:text-red-400 bg-transparent",soft:"bg-red-100 text-red-700 dark:bg-red-900/50 dark:text-red-300",dot:"bg-red-50 text-red-700 dark:bg-red-900/30 dark:text-red-300"},info:{solid:"bg-cyan-600 text-white",outlined:"border-cyan-600 text-cyan-600 dark:border-cyan-400 dark:text-cyan-400 bg-transparent",soft:"bg-cyan-100 text-cyan-700 dark:bg-cyan-900/50 dark:text-cyan-300",dot:"bg-cyan-50 text-cyan-700 dark:bg-cyan-900/30 dark:text-cyan-300"}},Xy={default:"bg-gray-500",primary:"bg-blue-600",success:"bg-green-600",warning:"bg-yellow-500",error:"bg-red-600",info:"bg-cyan-600"},Gy={sm:"h-5 text-xs px-2 gap-1",md:"h-6 text-sm px-2.5 gap-1.5",lg:"h-8 text-sm px-3 gap-2"},jl={sm:"w-3 h-3",md:"w-3.5 h-3.5",lg:"w-4 h-4"},Uy={sm:"w-4 h-4 -ml-1",md:"w-5 h-5 -ml-1.5",lg:"w-6 h-6 -ml-1.5"},Ky={sm:"w-1.5 h-1.5",md:"w-2 h-2",lg:"w-2.5 h-2.5"},Yy={none:"rounded-none",sm:"rounded-sm",md:"rounded-md",lg:"rounded-lg",full:"rounded-full"};function li({label:e,children:t,variant:r="solid",size:n="md",color:o="default",bgColor:a,textColor:s,borderColor:l,rounded:i="full",icon:c,endIcon:d,avatar:u,onClose:f,closable:m=false,clickable:g=false,selected:y=false,disabled:b=false,as:h="span",className:x,onClick:L,...C}){let S=h,v=p("inline-flex items-center justify-center font-medium transition-all",Gy[n],Yy[i],r==="outlined"&&"border"),R=p(a||s||l?p(a,s,l):_y[o][r]),N=y?"ring-2 ring-offset-1 ring-blue-500":"",M=g&&!b?"cursor-pointer hover:opacity-80 active:scale-95":"",P=b?"opacity-50 cursor-not-allowed":"",E=O=>{O.stopPropagation(),f?.();},W=O=>{b||L?.(O);},T=t??e;return jsxRuntime.jsxs(S,{className:p(v,R,N,M,P,x),onClick:W,"aria-disabled":b,...C,children:[r==="dot"&&jsxRuntime.jsx("span",{className:p("rounded-full shrink-0",Ky[n],Xy[o]),"aria-hidden":"true"}),u&&jsxRuntime.jsx("span",{className:p("rounded-full overflow-hidden shrink-0",Uy[n]),children:u}),c&&!u&&jsxRuntime.jsx("span",{className:p("shrink-0",jl[n]),children:c}),T&&jsxRuntime.jsx("span",{className:"truncate",children:T}),d&&!m&&jsxRuntime.jsx("span",{className:p("shrink-0",jl[n]),children:d}),m&&jsxRuntime.jsx("button",{type:"button",onClick:E,disabled:b,className:p("shrink-0 rounded-full hover:bg-black/10 dark:hover:bg-white/10 p-0.5 -mr-1 transition-colors","focus:outline-none focus-visible:ring-2 focus-visible:ring-offset-1 focus-visible:ring-current",b&&"pointer-events-none"),"aria-label":"Remove",children:jsxRuntime.jsx($y,{className:jl[n]})})]})}li.displayName="Chip";var Jy=500,ex=800,tx=600;function rx(e,t,r){let n=[`width=${e}`,`height=${t}`,"menubar=no","toolbar=no","location=no","status=no","scrollbars=yes","resizable=yes"];if(r.left!==void 0)n.push(`left=${r.left}`);else if(r.center!==false&&typeof window<"u"){let o=window.screenLeft??window.screenX,a=window.screenTop??window.screenY,s=window.outerWidth??screen.availWidth,l=window.outerHeight??screen.availHeight;n.push(`left=${o+(s-e)/2}`),n.push(`top=${a+(l-t)/2}`);}if(r.top!==void 0){let o=n.filter(a=>!a.startsWith("top="));return o.push(`top=${r.top}`),o.join(",")}return n.join(",")}function nx(e,t){e.querySelectorAll("style").forEach(s=>{let l=t.createElement("style");l.textContent=s.textContent,t.head.appendChild(l);}),e.querySelectorAll('link[rel="stylesheet"]').forEach(s=>{let l=t.createElement("link");l.rel="stylesheet",l.href=s.href,s.crossOrigin&&(l.crossOrigin=s.crossOrigin),t.head.appendChild(l);});let o=e.documentElement.className;o&&(t.documentElement.className=o);let a=e.body.className;a&&(t.body.className=a);}function ox(e,t){let r=new MutationObserver(n=>{for(let o of n)for(let a of Array.from(o.addedNodes))if(a instanceof HTMLStyleElement){let s=t.createElement("style");s.textContent=a.textContent,t.head.appendChild(s);}else if(a instanceof HTMLLinkElement&&a.rel==="stylesheet"){let s=t.createElement("link");s.rel="stylesheet",s.href=a.href,t.head.appendChild(s);}});return r.observe(e.head,{childList:true}),r}var Lu=Cl.forwardRef(function({children:t,detached:r,defaultDetached:n=false,onClose:o,onDetach:a,title:s="",width:l=ex,height:i=tx,left:c,top:d,center:u=true,copyStyles:f=true,closeOnParentUnmount:m=true,className:g,windowClassName:y,onPopupBlocked:b},h){let x=r!==void 0,[L,C]=Cl.useState(n),S=x?r:L,[v,R]=Cl.useState(null),N=Cl.useRef(null),M=Cl.useRef(null),P=Cl.useRef(null),E=Cl.useRef(false),W=Cl.useRef({width:l,height:i,left:c,top:d,center:u,shouldCopyStyles:f,title:s,windowClassName:y,closeOnParentUnmount:m});W.current={width:l,height:i,left:c,top:d,center:u,shouldCopyStyles:f,title:s,windowClassName:y,closeOnParentUnmount:m};let T=Cl.useCallback(()=>{M.current&&(clearInterval(M.current),M.current=null),P.current&&(P.current.disconnect(),P.current=null),R(null);},[]),O=Cl.useCallback(()=>{N.current&&!N.current.closed&&N.current.close(),N.current=null,T();},[T]),H=Cl.useCallback(()=>{if(typeof window>"u"||E.current||N.current&&!N.current.closed)return;E.current=true;let k=W.current,z=rx(k.width,k.height,{center:k.center,left:k.left,top:k.top}),A=window.open("","",z);if(!A){E.current=false,b?.();return}N.current=A,A.document.title=k.title||document.title;let I=A.document.createElement("div");k.windowClassName&&(I.className=k.windowClassName),A.document.body.appendChild(I),R(I),k.shouldCopyStyles&&(nx(document,A.document),P.current=ox(document,A.document)),M.current=setInterval(()=>{A.closed&&(T(),N.current=null,x||C(false),o?.());},Jy),E.current=false,a?.();},[x,o,a,b,T]);return Cl.useEffect(()=>{S?H():O();},[S,H,O]),Cl.useEffect(()=>{N.current&&!N.current.closed&&s&&(N.current.document.title=s);},[s]),Cl.useEffect(()=>()=>{W.current.closeOnParentUnmount&&N.current&&!N.current.closed&&N.current.close(),T(),N.current=null;},[T]),Cl.useImperativeHandle(h,()=>({detach:()=>{x||C(true);},attach:()=>{x||C(false);},get isDetached(){return x?!!r:L},get window(){return N.current}}),[x,r,L]),S&&v?reactDom.createPortal(t,v):S?null:jsxRuntime.jsx("div",{className:p(g),children:t})});Lu.displayName="Detachable";var ix={phone:{sm:{w:180,h:320},md:{w:240,h:480},lg:{w:300,h:600}},android:{sm:{w:180,h:320},md:{w:240,h:480},lg:{w:300,h:600}},tablet:{sm:{w:320,h:420},md:{w:420,h:560},lg:{w:540,h:720}},laptop:{sm:{w:400,h:250},md:{w:560,h:350},lg:{w:720,h:450}},desktop:{sm:{w:400,h:300},md:{w:560,h:400},lg:{w:720,h:520}},watch:{sm:{w:80,h:96},md:{w:120,h:144},lg:{w:160,h:192}},browser:{sm:{w:400,h:280},md:{w:560,h:380},lg:{w:720,h:480}}},lx=({className:e})=>jsxRuntime.jsxs("svg",{className:p("w-3 h-3",e),viewBox:"0 0 16 16",fill:"currentColor",children:[jsxRuntime.jsx("rect",{x:"1",y:"11",width:"2.5",height:"4",rx:"0.5"}),jsxRuntime.jsx("rect",{x:"5",y:"8",width:"2.5",height:"7",rx:"0.5"}),jsxRuntime.jsx("rect",{x:"9",y:"5",width:"2.5",height:"10",rx:"0.5"}),jsxRuntime.jsx("rect",{x:"13",y:"1",width:"2.5",height:"14",rx:"0.5"})]}),cx=({className:e})=>jsxRuntime.jsxs("svg",{className:p("w-3 h-3",e),viewBox:"0 0 20 20",fill:"currentColor",children:[jsxRuntime.jsx("path",{d:"M10 14.5a1.5 1.5 0 100 3 1.5 1.5 0 000-3z"}),jsxRuntime.jsx("path",{fillRule:"evenodd",d:"M6.05 11.95a5.5 5.5 0 017.9 0 .75.75 0 001.08-1.04 7 7 0 00-10.06 0 .75.75 0 001.08 1.04z",clipRule:"evenodd"}),jsxRuntime.jsx("path",{fillRule:"evenodd",d:"M2.81 8.72a10 10 0 0114.38 0 .75.75 0 001.06-1.06 11.5 11.5 0 00-16.5 0 .75.75 0 001.06 1.06z",clipRule:"evenodd"})]}),dx=({className:e})=>jsxRuntime.jsxs("svg",{className:p("w-4 h-3",e),viewBox:"0 0 24 14",fill:"currentColor",children:[jsxRuntime.jsx("rect",{x:"0.5",y:"0.5",width:"20",height:"13",rx:"2",stroke:"currentColor",fill:"none",strokeWidth:"1"}),jsxRuntime.jsx("rect",{x:"22",y:"4",width:"2",height:"6",rx:"0.5"}),jsxRuntime.jsx("rect",{x:"2.5",y:"2.5",width:"14",height:"9",rx:"1"})]});function qa({time:e="9:41",theme:t,device:r}){let n=r==="watch",o=t==="dark"?"text-white":"text-gray-900";return n?jsxRuntime.jsx("div",{className:p("flex items-center justify-center py-0.5",o),style:{fontSize:"8px"},children:jsxRuntime.jsx("span",{className:"font-medium",children:e})}):jsxRuntime.jsxs("div",{className:p("flex items-center justify-between px-4 py-1",t==="dark"?"bg-black/20":"bg-white/20",o),style:{fontSize:"10px"},"data-testid":"status-bar",children:[jsxRuntime.jsx("span",{className:"font-semibold",children:e}),jsxRuntime.jsxs("div",{className:"flex items-center gap-1",children:[jsxRuntime.jsx(lx,{className:o}),jsxRuntime.jsx(cx,{className:o}),jsxRuntime.jsx(dx,{className:o})]})]})}function ux({theme:e}){let t=e==="dark";return jsxRuntime.jsxs("div",{className:p("flex items-center gap-2 px-3 py-2 border-b",t?"bg-gray-800 border-gray-700":"bg-gray-100 border-gray-200"),"data-testid":"browser-chrome",children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-1.5",children:[jsxRuntime.jsx("div",{className:"w-2.5 h-2.5 rounded-full bg-red-400"}),jsxRuntime.jsx("div",{className:"w-2.5 h-2.5 rounded-full bg-yellow-400"}),jsxRuntime.jsx("div",{className:"w-2.5 h-2.5 rounded-full bg-green-400"})]}),jsxRuntime.jsx("div",{className:p("flex-1 rounded-md px-3 py-1 text-center",t?"bg-gray-700 text-gray-400":"bg-white text-gray-500 border border-gray-200"),style:{fontSize:"11px"},children:jsxRuntime.jsxs("span",{className:"flex items-center justify-center gap-1",children:[jsxRuntime.jsx("svg",{className:"w-2.5 h-2.5",viewBox:"0 0 16 16",fill:"currentColor",children:jsxRuntime.jsx("path",{fillRule:"evenodd",d:"M8 1a4 4 0 00-4 4v3.5H3a1 1 0 00-1 1V14a1 1 0 001 1h10a1 1 0 001-1V9.5a1 1 0 00-1-1h-1V5a4 4 0 00-4-4zm2.5 7.5V5a2.5 2.5 0 00-5 0v3.5h5z",clipRule:"evenodd"})}),"example.com"]})})]})}function mx({children:e,theme:t,screenW:r,screenH:n,showStatusBar:o,statusBarTime:a,frameColor:s,landscape:l=false}){let i=t==="dark",c=s??(i?"#1a1a1a":"#e5e7eb");if(l){let u=Math.round(n*.35);return jsxRuntime.jsxs("div",{className:"relative inline-flex flex-row items-center rounded-[2.5rem] shadow-xl",style:{backgroundColor:c,padding:"8px 12px",height:n+16},"data-testid":"device-frame","data-device":"phone",children:[jsxRuntime.jsx("div",{className:p("rounded-full mr-2",i?"bg-gray-600":"bg-gray-400"),style:{width:4,height:Math.round(n*.35)},"data-testid":"home-indicator"}),jsxRuntime.jsxs("div",{className:"rounded-[2rem] overflow-hidden bg-black relative",style:{width:r,height:n},children:[o&&jsxRuntime.jsx(qa,{time:a,theme:t,device:"phone"}),e]}),jsxRuntime.jsx("div",{className:"absolute rounded-full bg-black z-10",style:{width:20,height:u,right:10,top:"50%",transform:"translateY(-50%)"},"data-testid":"phone-notch"})]})}let d=Math.round(r*.35);return jsxRuntime.jsxs("div",{className:"relative inline-flex flex-col items-center rounded-[2.5rem] shadow-xl",style:{backgroundColor:c,padding:"12px 8px",width:r+16},"data-testid":"device-frame","data-device":"phone",children:[jsxRuntime.jsx("div",{className:"absolute top-[10px] rounded-full bg-black z-10",style:{width:d,height:20,left:"50%",transform:"translateX(-50%)"},"data-testid":"phone-notch"}),jsxRuntime.jsxs("div",{className:"rounded-[2rem] overflow-hidden bg-black relative",style:{width:r,height:n},children:[o&&jsxRuntime.jsx(qa,{time:a,theme:t,device:"phone"}),e]}),jsxRuntime.jsx("div",{className:p("rounded-full mt-2",i?"bg-gray-600":"bg-gray-400"),style:{width:Math.round(r*.35),height:4},"data-testid":"home-indicator"})]})}function px({children:e,theme:t,screenW:r,screenH:n,showStatusBar:o,statusBarTime:a,frameColor:s}){return jsxRuntime.jsxs("div",{className:"relative inline-flex flex-col items-center rounded-[2rem] shadow-xl",style:{backgroundColor:s??(t==="dark"?"#1a1a1a":"#e5e7eb"),padding:"10px 6px",width:r+12},"data-testid":"device-frame","data-device":"android",children:[jsxRuntime.jsx("div",{className:"absolute top-[6px] rounded-full bg-gray-800 z-10 border border-gray-700",style:{width:8,height:8,left:"50%",transform:"translateX(-50%)"},"data-testid":"camera-dot"}),jsxRuntime.jsxs("div",{className:"rounded-[1.5rem] overflow-hidden bg-black relative",style:{width:r,height:n},children:[o&&jsxRuntime.jsx(qa,{time:a,theme:t,device:"android"}),e]})]})}function gx({children:e,theme:t,screenW:r,screenH:n,showStatusBar:o,statusBarTime:a,frameColor:s}){return jsxRuntime.jsxs("div",{className:"relative inline-flex flex-col items-center rounded-[1.5rem] shadow-xl",style:{backgroundColor:s??(t==="dark"?"#1a1a1a":"#e5e7eb"),padding:"16px 12px",width:r+24},"data-testid":"device-frame","data-device":"tablet",children:[jsxRuntime.jsx("div",{className:"absolute top-[8px] rounded-full bg-gray-700 z-10",style:{width:6,height:6,left:"50%",transform:"translateX(-50%)"}}),jsxRuntime.jsxs("div",{className:"rounded-lg overflow-hidden bg-black relative",style:{width:r,height:n},children:[o&&jsxRuntime.jsx(qa,{time:a,theme:t,device:"tablet"}),e]})]})}function fx({children:e,theme:t,screenW:r,screenH:n,frameColor:o}){let a=t==="dark",s=o??(a?"#1a1a1a":"#d1d5db"),l=r+60;return jsxRuntime.jsxs("div",{className:"inline-flex flex-col items-center","data-testid":"device-frame","data-device":"laptop",children:[jsxRuntime.jsxs("div",{className:"rounded-t-xl shadow-xl relative",style:{backgroundColor:s,padding:"8px 8px 0",width:r+16},children:[jsxRuntime.jsx("div",{className:"absolute top-[3px] rounded-full bg-gray-700 z-10",style:{width:4,height:4,left:"50%",transform:"translateX(-50%)"}}),jsxRuntime.jsx("div",{className:"rounded-t-sm overflow-hidden bg-black",style:{width:r,height:n},children:e})]}),jsxRuntime.jsx("div",{className:p(a?"bg-gray-800":"bg-gray-400"),style:{width:r+16,height:3}}),jsxRuntime.jsx("div",{className:"rounded-b-xl shadow-lg",style:{backgroundColor:s,width:l,height:12,clipPath:"polygon(3% 0%, 97% 0%, 100% 100%, 0% 100%)"},"data-testid":"laptop-base"})]})}function hx({children:e,theme:t,screenW:r,screenH:n,frameColor:o}){let a=t==="dark";return jsxRuntime.jsxs("div",{className:"inline-flex flex-col items-center","data-testid":"device-frame","data-device":"desktop",children:[jsxRuntime.jsx("div",{className:"rounded-lg shadow-xl",style:{backgroundColor:o??(a?"#1a1a1a":"#d1d5db"),padding:"8px 8px 20px",width:r+16},children:jsxRuntime.jsx("div",{className:"rounded-sm overflow-hidden bg-black",style:{width:r,height:n},children:e})}),jsxRuntime.jsx("div",{className:p(a?"bg-gray-800":"bg-gray-400"),style:{width:40,height:24},"data-testid":"monitor-stand"}),jsxRuntime.jsx("div",{className:p("rounded-t-sm",a?"bg-gray-800":"bg-gray-400"),style:{width:Math.round(r*.4),height:6,borderRadius:"2px 2px 4px 4px"}})]})}function bx({children:e,theme:t,screenW:r,screenH:n,showStatusBar:o,statusBarTime:a,frameColor:s}){let l=t==="dark",i=s??(l?"#1a1a1a":"#d1d5db"),c=Math.round(r*.7);return jsxRuntime.jsxs("div",{className:"inline-flex flex-col items-center","data-testid":"device-frame","data-device":"watch",children:[jsxRuntime.jsx("div",{className:p("rounded-t-lg",l?"bg-gray-800":"bg-gray-400"),style:{width:c,height:30},"data-testid":"watch-band"}),jsxRuntime.jsxs("div",{className:"relative rounded-[1.2rem] shadow-xl",style:{backgroundColor:i,padding:"8px 6px",width:r+12},children:[jsxRuntime.jsx("div",{className:p("absolute rounded-sm",l?"bg-gray-600":"bg-gray-400"),style:{width:4,height:16,right:-4,top:"30%"},"data-testid":"watch-crown"}),jsxRuntime.jsxs("div",{className:"rounded-xl overflow-hidden bg-black",style:{width:r,height:n},children:[o&&jsxRuntime.jsx(qa,{time:a,theme:t,device:"watch"}),e]})]}),jsxRuntime.jsx("div",{className:p("rounded-b-lg",l?"bg-gray-800":"bg-gray-400"),style:{width:c,height:30}})]})}function yx({children:e,theme:t,screenW:r,screenH:n,frameColor:o}){return jsxRuntime.jsxs("div",{className:"inline-flex flex-col rounded-lg shadow-xl overflow-hidden",style:{backgroundColor:o??(t==="dark"?"#1f2937":"#f3f4f6"),width:r},"data-testid":"device-frame","data-device":"browser",children:[jsxRuntime.jsx(ux,{theme:t}),jsxRuntime.jsx("div",{className:"overflow-hidden bg-white",style:{width:r,height:n},children:e})]})}function xx({device:e="phone",src:t,alt:r="Device screen content",children:n,orientation:o="portrait",theme:a="dark",size:s="md",showStatusBar:l=false,statusBarTime:i,animated:c=false,scrollSpeed:d=30,frameColor:u,className:f,contentClassName:m}){let g=Cl.useRef(null),y=Cl.useRef(null),b=ix[e][s],h=o==="landscape"&&e!=="watch"&&e!=="browser",x=h?b.h:b.w,L=h?b.w:b.h;Cl.useEffect(()=>{if(!c||!g.current)return;let R=g.current,N=null,M=P=>{N===null&&(N=P);let E=(P-N)/1e3;N=P,R.scrollTop+=d*E,R.scrollTop>=R.scrollHeight-R.clientHeight&&(R.scrollTop=0),y.current=requestAnimationFrame(M);};return y.current=requestAnimationFrame(M),()=>{y.current!==null&&cancelAnimationFrame(y.current);}},[c,d]);let C=jsxRuntime.jsx("div",{ref:c?g:void 0,className:p("w-full h-full overflow-hidden",c&&"overflow-y-auto scrollbar-hide",m),style:c?{scrollBehavior:"auto"}:void 0,children:t?jsxRuntime.jsx("img",{src:t,alt:r,className:"w-full h-auto object-cover",draggable:false}):n}),S={showStatusBar:l,statusBarTime:i},v=()=>{switch(e){case "phone":return jsxRuntime.jsx(mx,{theme:a,screenW:x,screenH:L,frameColor:u,landscape:h,...S,children:C});case "android":return jsxRuntime.jsx(px,{theme:a,screenW:x,screenH:L,frameColor:u,...S,children:C});case "tablet":return jsxRuntime.jsx(gx,{theme:a,screenW:x,screenH:L,frameColor:u,...S,children:C});case "laptop":return jsxRuntime.jsx(fx,{theme:a,screenW:x,screenH:L,frameColor:u,children:C});case "desktop":return jsxRuntime.jsx(hx,{theme:a,screenW:x,screenH:L,frameColor:u,children:C});case "watch":return jsxRuntime.jsx(bx,{theme:a,screenW:x,screenH:L,frameColor:u,...S,children:C});case "browser":return jsxRuntime.jsx(yx,{theme:a,screenW:x,screenH:L,frameColor:u,children:C})}};return jsxRuntime.jsx("div",{className:p("inline-flex",f),"data-testid":"device-mockup","data-orientation":o,"data-theme":a,"data-size":s,children:v()})}var ci={solid:"border-solid",dashed:"border-dashed",dotted:"border-dotted"},vx={left:{before:"flex-[0.1]",after:"flex-1"},center:{before:"flex-1",after:"flex-1"},right:{before:"flex-1",after:"flex-[0.1]"}};function Iu({orientation:e="horizontal",variant:t="solid",label:r,textAlign:n="center",thickness:o=1,color:a="border-gray-300 dark:border-gray-700",spacing:s,className:l,...i}){if(e==="vertical")return jsxRuntime.jsx("hr",{"aria-orientation":"vertical",className:p("h-full border-l-0 border-r",ci[t],a,s||"mx-2",l),style:{borderRightWidth:`${o}px`},...i});if(r){let c=vx[n];return jsxRuntime.jsxs("div",{role:"separator","aria-orientation":"horizontal",className:p("flex items-center text-sm text-gray-500 dark:text-gray-400",s||"my-4",l),...i,children:[jsxRuntime.jsx("div",{className:p("border-t",ci[t],a,c.before),style:{borderTopWidth:`${o}px`}}),jsxRuntime.jsx("span",{className:"px-3 whitespace-nowrap",children:r}),jsxRuntime.jsx("div",{className:p("border-t",ci[t],a,c.after),style:{borderTopWidth:`${o}px`}})]})}return jsxRuntime.jsx("hr",{"aria-orientation":"horizontal",className:p("border-t-0 border-b",ci[t],a,s||"my-4",l),style:{borderBottomWidth:`${o}px`},...i})}Iu.displayName="Divider";var Un=[];function Au(e){let t=Un.indexOf(e);t!==-1&&Un.splice(t,1),Un.push(e);}function zu(e){let t=Un.indexOf(e);t!==-1&&Un.splice(t,1);}function Bu(e){return Un.length>0&&Un[Un.length-1]===e}var Qa=0,Ql=null;function Hu(e=document){let t=e.body;if(!t)return ()=>{};Qa===0&&(Ql=t.style.overflow,t.style.overflow="hidden"),Qa+=1;let r=false;return ()=>{r||(r=true,Qa=Math.max(0,Qa-1),Qa===0&&(t.style.overflow=Ql??"",Ql=null));}}var Wu=["a[href]","area[href]","button","input","select","textarea","details > summary:first-of-type","iframe","object","embed","audio[controls]","video[controls]",'[contenteditable]:not([contenteditable="false"])',"[tabindex]"].join(",");function kx(e){let t=e.ownerDocument?.defaultView;if(!t)return null;try{return t.getComputedStyle(e)}catch{return null}}function Vu(e){let t=e;for(;t;){if(t.hasAttribute("hidden")||t.hasAttribute("inert")||t.getAttribute("aria-hidden")==="true")return false;let r=kx(t);if(r&&(r.display==="none"||r.visibility==="hidden"||r.visibility==="collapse"))return false;t=t.parentElement;}return true}function Ou(e){if(e.hasAttribute("disabled")||e.getAttribute("tabindex")==="-1")return false;let t=e.closest("fieldset[disabled]");if(t){let r=t.querySelector("legend");if(!r||!r.contains(e))return false}return Vu(e)}function di(e){return Array.from(e.querySelectorAll(Wu)).filter(Ou).sort((r,n)=>{let o=r.compareDocumentPosition(n);return o&Node.DOCUMENT_POSITION_FOLLOWING?-1:o&Node.DOCUMENT_POSITION_PRECEDING?1:0})}var wx={role:"dialog","aria-modal":true,tabIndex:-1};function Nx(e,t){return t==="none"?null:t&&typeof t=="object"?t.current??e:t==="first"?di(e)[0]??e:e}function Sx(e){return e?e.map(t=>t&&"current"in t?t.current:t).filter(t=>!!t):[]}function da(e){if(e)try{e.focus();}catch{}}function So(e){let{open:t}=e,r=Cl.useRef(null),n=Cl.useRef(e);return n.current=e,Cl.useEffect(()=>{if(!t)return;let o=r.current;if(!o)return;let a=o.ownerDocument,s=a.activeElement,{hideBackground:l,lockScroll:i,initialFocus:c,keepInteractive:d}=n.current;Au(o);let u=l===false?void 0:Ml([o,...Sx(d)]),f=i===false?void 0:Hu(a);return da(Nx(o,c)),()=>{u?.(),f?.(),zu(o);let{returnFocus:m}=n.current;if(m===false)return;let g=a.activeElement;if(!(!g||g===a.body||o.contains(g)))return;let b=m&&typeof m=="object"?m.current:s;b&&a.contains(b)&&da(b);}},[t]),Cl.useEffect(()=>{if(!t)return;let o=r.current;if(!o)return;let a=o.ownerDocument,s=a.defaultView??a,l=c=>c?o.contains(c)?true:Gs([o]).some(d=>d.contains(c)):false,i=c=>{if(c.defaultPrevented||!Bu(o))return;let{closeOnEscape:d,trapFocus:u,onClose:f}=n.current;if(c.key==="Escape"){if(d===false)return;c.preventDefault(),f?.();return}if(c.key!=="Tab"||u===false)return;let m=a.activeElement;if(m&&!o.contains(m)&&l(m))return;let g=di(o);if(g.length===0){c.preventDefault(),da(o);return}let y=g[0],b=g[g.length-1];if(!m||!o.contains(m)){c.preventDefault(),da(c.shiftKey?b:y);return}if(c.shiftKey&&(m===y||m===o)){c.preventDefault(),da(b);return}!c.shiftKey&&m===b&&(c.preventDefault(),da(y));};return s.addEventListener("keydown",i),()=>s.removeEventListener("keydown",i)},[t]),{dialogRef:r,dialogProps:wx}}var Ex={left:{sm:"w-64",md:"w-80",lg:"w-96",xl:"w-[32rem]",full:"w-full",half:"w-1/2 h-full"},right:{sm:"w-64",md:"w-80",lg:"w-96",xl:"w-[32rem]",full:"w-full",half:"w-1/2 h-full"},top:{sm:"h-64",md:"h-80",lg:"h-96",xl:"h-[32rem]",full:"h-full",half:"w-1/2 h-full"},bottom:{sm:"h-64",md:"h-80",lg:"h-96",xl:"h-[32rem]",full:"h-full",half:"w-1/2 h-full"}},Lx={left:"left-0 top-0 bottom-0",right:"right-0 top-0 bottom-0",top:"top-0 left-0 right-0",bottom:"bottom-0 left-0 right-0"},_u={left:{enter:"animate-in slide-in-from-left duration-300",exit:"animate-out slide-out-to-left duration-200"},right:{enter:"animate-in slide-in-from-right duration-300",exit:"animate-out slide-out-to-right duration-200"},top:{enter:"animate-in slide-in-from-top duration-300",exit:"animate-out slide-out-to-top duration-200"},bottom:{enter:"animate-in slide-in-from-bottom duration-300",exit:"animate-out slide-out-to-bottom duration-200"}},Mx=jsxRuntime.jsx("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:jsxRuntime.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})});function Xu({open:e,onClose:t,children:r,position:n="right",size:o="md",customWidth:a,customHeight:s,showOverlay:l=true,closeOnOverlayClick:i=true,closeOnEscape:c=true,title:d,footer:u,className:f,overlayClassName:m,closeLabel:g,"aria-label":y,trapFocus:b=true,initialFocus:h,returnFocus:x,lockScroll:L=true}){let C=!!(a||s),S=Cl.useRef(null),v=Ve(),N=`${Cl.useId()}-drawer-title`,{dialogRef:M,dialogProps:P}=So({open:e,onClose:t,closeOnEscape:c,trapFocus:b,initialFocus:h,returnFocus:x,lockScroll:L,keepInteractive:[S]}),E=Cl.useCallback(()=>{i&&t();},[i,t]);if(!e)return null;let W=jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[l&&jsxRuntime.jsx("div",{ref:S,className:p("fixed inset-0 bg-black/50 z-40 transition-opacity",e?"animate-in fade-in duration-200":"animate-out fade-out duration-150",m),onClick:E,"aria-hidden":"true"}),jsxRuntime.jsxs("div",{ref:M,...P,"aria-labelledby":d?N:void 0,"aria-label":d?void 0:y,className:p("fixed z-50 bg-white dark:bg-gray-900","shadow-xl overflow-hidden","flex flex-col focus:outline-none",Lx[n],!C&&Ex[n][o],e?_u[n].enter:_u[n].exit,f),style:{...a?{width:a}:{},...s?{height:s}:{}},children:[d&&jsxRuntime.jsxs("div",{className:"flex items-center justify-between px-6 py-4 border-b border-gray-200 dark:border-gray-700",children:[jsxRuntime.jsx("h2",{id:N,className:"text-lg font-semibold text-gray-900 dark:text-white",children:d}),jsxRuntime.jsx("button",{type:"button",onClick:t,className:p("rounded-lg p-1.5 text-gray-400 hover:bg-gray-100 hover:text-gray-900","dark:hover:bg-gray-800 dark:hover:text-white","focus:outline-none focus:ring-2 focus:ring-gray-300 dark:focus:ring-gray-600"),"aria-label":g??v.closeDrawer,children:Mx})]}),jsxRuntime.jsx("div",{className:"flex-1 overflow-y-auto px-6 py-4",children:r}),u&&jsxRuntime.jsx("div",{className:"px-6 py-4 border-t border-gray-200 dark:border-gray-700",children:u})]})]});return typeof document<"u"?reactDom.createPortal(W,document.body):W}Xu.displayName="Drawer";var Bx={sm:{dropzone:"py-4 px-3",text:"text-xs",subtext:"text-[10px]",icon:"w-6 h-6",button:"px-2.5 py-1.5 text-xs",fileItem:"py-1 px-2 text-xs",gap:"gap-1"},md:{dropzone:"py-6 px-4",text:"text-sm",subtext:"text-xs",icon:"w-8 h-8",button:"px-3 py-2 text-sm",fileItem:"py-1.5 px-3 text-sm",gap:"gap-1.5"},lg:{dropzone:"py-8 px-6",text:"text-base",subtext:"text-sm",icon:"w-10 h-10",button:"px-4 py-2.5 text-base",fileItem:"py-2 px-4 text-base",gap:"gap-2"}},Yu=e=>{if(e===0)return "0 B";let t=["B","KB","MB","GB"],r=Math.floor(Math.log(e)/Math.log(1024));return `${(e/Math.pow(1024,r)).toFixed(r===0?0:1)} ${t[r]}`},ec=e=>e.webkitRelativePath||e.name,Hx=jsxRuntime.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",strokeWidth:1.5,stroke:"currentColor",className:"w-full h-full",children:jsxRuntime.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M3 16.5v2.25A2.25 2.25 0 005.25 21h13.5A2.25 2.25 0 0021 18.75V16.5m-13.5-9L12 3m0 0l4.5 4.5M12 3v13.5"})}),Wx=jsxRuntime.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",strokeWidth:1.5,stroke:"currentColor",className:"w-full h-full",children:jsxRuntime.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M3.75 9.776c.112-.017.227-.026.344-.026h15.812c.117 0 .232.009.344.026m-16.5 0a2.25 2.25 0 00-1.883 2.542l.857 6a2.25 2.25 0 002.227 1.932H19.05a2.25 2.25 0 002.227-1.932l.857-6a2.25 2.25 0 00-1.883-2.542m-16.5 0V6A2.25 2.25 0 016 3.75h3.879a1.5 1.5 0 011.06.44l2.122 2.12a1.5 1.5 0 001.06.44H18A2.25 2.25 0 0120.25 9v.776"})}),Vx=0;async function Ox(e){let t=[],r=async n=>{if(n.isFile){let o=await new Promise((a,s)=>n.file(a,s));t.push(o);}else if(n.isDirectory){let o=n.createReader(),a=()=>new Promise((l,i)=>o.readEntries(l,i)),s=await a();for(;s.length>0;){for(let l of s)await r(l);s=await a();}}};for(let n of e)await r(n);return t}function Fx({value:e,onChange:t,accept:r,multiple:n=false,maxSize:o=10*1024*1024,maxFiles:a,mode:s="file",variant:l="dropzone",size:i="md",disabled:c=false,readOnly:d=false,label:u,helperText:f,error:m,showFileList:g=true,placeholder:y,browseLabel:b,browseFolderLabel:h,icon:x,onReject:L,className:C}){let[S,v]=Cl.useState([]),[R,N]=Cl.useState(false),M=Cl.useRef(null),P=Cl.useRef(null),E=Cl.useId(),W=e!==void 0,T=W?e.map((Y,ee)=>({file:Y,id:`ctrl-${ee}`})):S,O=Bx[i];Cl.useEffect(()=>{s==="directory"&&M.current&&M.current.setAttribute("webkitdirectory",""),s==="both"&&P.current&&P.current.setAttribute("webkitdirectory","");},[s]);let H=Cl.useMemo(()=>Yu(o),[o]),k=Cl.useMemo(()=>r?r.split(",").map(Y=>Y.trim()).map(Y=>Y.startsWith(".")?Y.toUpperCase():Y.endsWith("/*")?Y.replace("/*","").toUpperCase():Y).join(", "):"All files",[r]),z=s==="directory"?"Drag & drop a folder here, or":s==="both"?"Drag & drop files or folders here, or":n?"Drag & drop files here, or":"Drag & drop a file here, or",A=s==="directory"?"Browse folder":"Browse",I="Browse folder",X=Cl.useCallback(Y=>{if(Y.size>o)return `File exceeds maximum size of ${H}`;if(r){let ee=r.split(",").map(V=>V.trim()),Z=`.${Y.name.split(".").pop()?.toLowerCase()}`;if(!ee.some(V=>V.startsWith(".")?Z===V.toLowerCase():V.endsWith("/*")?Y.type.startsWith(V.replace("/*","/")):Y.type===V))return `File type not accepted. Expected: ${k}`}return null},[r,k,o,H]),$=Cl.useCallback(Y=>{if(c||d)return;let ee=Array.from(Y),Z=[];for(let ie of ee){let V=X(ie);V?L?.(ie,V):Z.push(ie);}if(Z.length!==0)if(W)if(n){let V=[...e??[],...Z],oe=a?V.slice(0,a):V;t?.(oe);}else t?.([Z[0]]);else v(ie=>{let V=Z.map(oe=>({file:oe,id:`file-${++Vx}`}));if(n){let oe=[...ie,...V],pe=a?oe.slice(0,a):oe,Te=pe.map(ze=>ze.file);return t?.(Te),pe}return t?.([Z[0]]),[V[0]]});},[c,d,W,n,a,e,t,L,X]),K=Cl.useCallback(Y=>{if(!(c||d)){if(W){let ee=(e??[]).filter((Z,ie)=>ie!==Y);t?.(ee);}else v(ee=>{let Z=ee.filter((ie,V)=>V!==Y);return t?.(Z.map(ie=>ie.file)),Z});M.current&&(M.current.value="");}},[c,d,W,e,t]),D=Cl.useCallback(()=>{c||d||(W?t?.([]):(v([]),t?.([])),M.current&&(M.current.value=""));},[c,d,W,t]),B=Cl.useCallback(Y=>{Y.target.files&&Y.target.files.length>0&&$(Y.target.files);},[$]),w=Cl.useCallback(Y=>{Y.preventDefault(),Y.stopPropagation(),!c&&!d&&N(true);},[c,d]),G=Cl.useCallback(Y=>{Y.preventDefault(),Y.stopPropagation(),N(false);},[]),q=Cl.useCallback(Y=>{if(Y.preventDefault(),Y.stopPropagation(),N(false),c||d)return;let ee=Y.dataTransfer.items;if(ee&&ee.length>0&&(s==="directory"||s==="both")){let Z=[];for(let V=0;V<ee.length;V++){let oe=ee[V].webkitGetAsEntry?.();oe&&Z.push(oe);}if(Z.some(V=>V.isDirectory)){Ox(Z).then(V=>{V.length>0&&$(V);});return}}Y.dataTransfer.files&&Y.dataTransfer.files.length>0&&$(Y.dataTransfer.files);},[c,d,s,$]),j=Cl.useCallback(()=>{!c&&!d&&M.current?.click();},[c,d]),U=Cl.useCallback(()=>{!c&&!d&&P.current?.click();},[c,d]),F=T.length>0,_=x||(s==="directory"?Wx:Hx),J=g&&F&&jsxRuntime.jsxs("div",{className:p("flex flex-col",O.gap),children:[T.map((Y,ee)=>jsxRuntime.jsxs("div",{className:p("flex items-center justify-between rounded-md border border-gray-200 dark:border-gray-700 bg-gray-50 dark:bg-gray-800/50",O.fileItem),children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-2 min-w-0 flex-1",children:[jsxRuntime.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",strokeWidth:1.5,stroke:"currentColor",className:"w-4 h-4 shrink-0 text-gray-400 dark:text-gray-500",children:jsxRuntime.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M19.5 14.25v-2.625a3.375 3.375 0 00-3.375-3.375h-1.5A1.125 1.125 0 0113.5 7.125v-1.5a3.375 3.375 0 00-3.375-3.375H8.25m2.25 0H5.625c-.621 0-1.125.504-1.125 1.125v17.25c0 .621.504 1.125 1.125 1.125h12.75c.621 0 1.125-.504 1.125-1.125V11.25a9 9 0 00-9-9z"})}),jsxRuntime.jsx("span",{className:"truncate text-gray-700 dark:text-gray-300",children:ec(Y.file)}),jsxRuntime.jsxs("span",{className:"shrink-0 text-gray-400 dark:text-gray-500",children:["(",Yu(Y.file.size),")"]})]}),!c&&!d&&jsxRuntime.jsx("button",{type:"button",onClick:()=>K(ee),className:"shrink-0 ml-2 text-gray-400 hover:text-red-500 dark:text-gray-500 dark:hover:text-red-400 transition-colors cursor-pointer","aria-label":`Remove ${ec(Y.file)}`,children:jsxRuntime.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",strokeWidth:1.5,stroke:"currentColor",className:"w-4 h-4",children:jsxRuntime.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M6 18L18 6M6 6l12 12"})})})]},Y.id)),n&&T.length>1&&!c&&!d&&jsxRuntime.jsx("button",{type:"button",onClick:D,className:p("self-start text-gray-400 hover:text-red-500 dark:text-gray-500 dark:hover:text-red-400 transition-colors cursor-pointer",O.subtext),children:"Remove all"})]}),ne=p("rounded-md border border-gray-300 dark:border-gray-600 bg-white dark:bg-gray-800 text-gray-700 dark:text-gray-200 font-medium transition-colors","hover:bg-gray-50 dark:hover:bg-gray-700","disabled:opacity-50 disabled:cursor-not-allowed cursor-pointer","focus:outline-none focus:ring-2 focus:ring-blue-500 focus:ring-offset-1",O.button,m&&"border-red-300 dark:border-red-600");return jsxRuntime.jsxs("div",{className:p("flex flex-col",O.gap,C),children:[u&&jsxRuntime.jsx("label",{htmlFor:E,className:p("block font-medium text-gray-700 dark:text-gray-300",O.text),children:u}),jsxRuntime.jsx("input",{ref:M,id:E,type:"file",accept:s!=="directory"?r:void 0,multiple:n,onChange:B,className:"sr-only",disabled:c||d,"aria-describedby":m?`${E}-error`:f?`${E}-helper`:void 0,"aria-invalid":!!m}),s==="both"&&jsxRuntime.jsx("input",{ref:P,type:"file",onChange:B,className:"sr-only",disabled:c||d,tabIndex:-1,"aria-hidden":"true"}),l==="dropzone"?jsxRuntime.jsxs("div",{role:s==="both"?"group":"button",tabIndex:s==="both"?void 0:c||d?-1:0,onClick:s==="both"?void 0:j,onKeyDown:s==="both"?void 0:Y=>{(Y.key==="Enter"||Y.key===" ")&&(Y.preventDefault(),j());},onDragOver:w,onDragLeave:G,onDrop:q,className:p("flex flex-col items-center justify-center rounded-lg border-2 border-dashed transition-colors",O.dropzone,R&&!c&&!d?"border-blue-500 bg-blue-50 dark:bg-blue-900/20":"border-gray-300 dark:border-gray-600 bg-white dark:bg-gray-800",!c&&!d&&"hover:border-blue-400 dark:hover:border-blue-500 hover:bg-gray-50 dark:hover:bg-gray-800/70",s!=="both"&&!c&&!d&&"cursor-pointer",c&&"opacity-50 cursor-not-allowed",d&&"cursor-default",m&&"border-red-300 dark:border-red-600"),"aria-label":s==="both"?"File and folder drop zone":y||z,children:[jsxRuntime.jsx("div",{className:p("text-gray-400 dark:text-gray-500 mb-2",O.icon,R&&"text-blue-500 dark:text-blue-400"),children:_}),jsxRuntime.jsxs("p",{className:p("text-gray-600 dark:text-gray-400",O.text),children:[y||z," ",!c&&!d&&s!=="both"&&jsxRuntime.jsx("span",{className:"text-blue-600 dark:text-blue-400 font-medium",children:b||A})]}),s==="both"&&!c&&!d&&jsxRuntime.jsxs("div",{className:p("flex items-center gap-3 mt-1",O.text),children:[jsxRuntime.jsx("button",{type:"button",onClick:j,className:"text-blue-600 dark:text-blue-400 font-medium hover:underline cursor-pointer focus:outline-none focus:ring-2 focus:ring-blue-500 focus:ring-offset-1 rounded",children:b||"Browse files"}),jsxRuntime.jsx("span",{className:"text-gray-300 dark:text-gray-600",children:"\xB7"}),jsxRuntime.jsx("button",{type:"button",onClick:U,className:"text-blue-600 dark:text-blue-400 font-medium hover:underline cursor-pointer focus:outline-none focus:ring-2 focus:ring-blue-500 focus:ring-offset-1 rounded",children:h||I})]}),jsxRuntime.jsxs("p",{className:p("text-gray-400 dark:text-gray-500 mt-1",O.subtext),children:[k," - Max ",H,n&&a&&` - Up to ${a} files`]})]}):jsxRuntime.jsxs("div",{className:"flex items-center gap-2",children:[s==="both"?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("button",{type:"button",onClick:j,disabled:c||d,className:ne,children:b||(F?"Change files":"Choose files")}),jsxRuntime.jsx("button",{type:"button",onClick:U,disabled:c||d,className:ne,children:h||"Choose folder"})]}):jsxRuntime.jsx("button",{type:"button",onClick:j,disabled:c||d,className:ne,children:b||(s==="directory"?F?"Change folder":"Choose folder":F?"Change file":"Choose file")}),!F&&jsxRuntime.jsx("span",{className:p("text-gray-400 dark:text-gray-500",O.text),children:s==="directory"?"No folder selected":s==="both"?"No file or folder selected":"No file selected"}),F&&!g&&jsxRuntime.jsx("span",{className:p("text-gray-600 dark:text-gray-400 truncate",O.text),children:T.length===1?ec(T[0].file):`${T.length} files selected`})]}),J,m&&jsxRuntime.jsx("p",{id:`${E}-error`,className:p("text-red-600 dark:text-red-400",O.subtext),role:"alert",children:m}),f&&!m&&jsxRuntime.jsx("p",{id:`${E}-helper`,className:p("text-gray-400 dark:text-gray-500",O.subtext),children:f})]})}function ju({className:e}){return jsxRuntime.jsx("hr",{className:p("my-1 h-px border-0 bg-gray-200 dark:bg-gray-700",e)})}ju.displayName="DropdownSeparator";function qu({children:e,className:t}){return jsxRuntime.jsx("div",{className:p("px-3 py-1.5 text-xs font-semibold text-gray-500 dark:text-gray-400",t),children:e})}qu.displayName="DropdownLabel";function em({checked:e,defaultChecked:t=false,onCheckedChange:r,children:n,icon:o,description:a,disabled:s=false,closeOnChange:l=false,className:i,index:c}){let{setIsOpen:d,focusedIndex:u,setFocusedIndex:f,registerItem:m,getNextItemIndex:g}=Dr(),y=Cl.useRef(null),[b]=Cl.useState(()=>c??g()),[h,x]=Cl.useState(t),L=e!==void 0,C=L?e:h;Cl.useEffect(()=>(m(b,y.current),()=>{m(b,null);}),[b,m]);let S=u===b;return jsxRuntime.jsxs("button",{ref:y,role:"menuitemcheckbox",type:"button",tabIndex:S?0:-1,"aria-checked":C,disabled:s,"data-disabled":s||void 0,"data-focused":S||void 0,onClick:()=>{if(s)return;let N=!C;L||x(N),r?.(N),l&&d(false);},onMouseEnter:()=>{s||f(b);},className:p("relative flex w-full items-center px-3 py-2 text-left text-sm","outline-none transition-colors","text-gray-700 dark:text-gray-200","hover:bg-gray-100 dark:hover:bg-gray-700","focus:bg-gray-100 dark:focus:bg-gray-700",s&&"opacity-50 cursor-not-allowed hover:bg-transparent",S&&"bg-gray-100 dark:bg-gray-700",i),children:[jsxRuntime.jsx("span",{className:"mr-2 shrink-0 w-4 h-4",children:o||jsxRuntime.jsx("span",{className:p("flex items-center justify-center w-4 h-4 rounded border-2 transition-colors",C?"bg-blue-600 border-blue-600":"border-gray-300 dark:border-gray-600"),children:C&&jsxRuntime.jsx("svg",{className:"w-3 h-3 text-white",viewBox:"0 0 16 16",fill:"none",children:jsxRuntime.jsx("path",{d:"M13.5 4.5L6 12L2.5 8.5",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round"})})})}),jsxRuntime.jsxs("span",{className:"flex-1 min-w-0",children:[jsxRuntime.jsx("span",{className:"block truncate",children:n}),a&&jsxRuntime.jsx("span",{className:"block text-xs text-gray-500 dark:text-gray-400 truncate",children:a})]})]})}em.displayName="DropdownCheckboxItem";var nm=Cl.createContext(null);function Zx(){let e=Cl.useContext(nm);if(!e)throw new Error("DropdownRadioItem must be used within a DropdownRadioGroup");return e}function om({value:e,defaultValue:t="",onValueChange:r,children:n,className:o}){let[a,s]=Cl.useState(t),l=e!==void 0,i=l?e:a,c=Cl.useCallback(u=>{l||s(u),r?.(u);},[l,r]),d=Cl.useMemo(()=>({value:i,onValueChange:c}),[i,c]);return jsxRuntime.jsx(nm.Provider,{value:d,children:jsxRuntime.jsx("div",{role:"group",className:o,children:n})})}om.displayName="DropdownRadioGroup";function am({value:e,children:t,icon:r,description:n,disabled:o=false,closeOnChange:a=true,className:s,index:l}){let{value:i,onValueChange:c}=Zx(),{setIsOpen:d,focusedIndex:u,setFocusedIndex:f,registerItem:m,getNextItemIndex:g}=Dr(),y=Cl.useRef(null),[b]=Cl.useState(()=>l??g()),h=i===e;Cl.useEffect(()=>(m(b,y.current),()=>{m(b,null);}),[b,m]);let x=u===b;return jsxRuntime.jsxs("button",{ref:y,role:"menuitemradio",type:"button",tabIndex:x?0:-1,"aria-checked":h,disabled:o,"data-disabled":o||void 0,"data-focused":x||void 0,onClick:()=>{o||(c(e),a&&d(false));},onMouseEnter:()=>{o||f(b);},className:p("relative flex w-full items-center px-3 py-2 text-left text-sm","outline-none transition-colors","text-gray-700 dark:text-gray-200","hover:bg-gray-100 dark:hover:bg-gray-700","focus:bg-gray-100 dark:focus:bg-gray-700",o&&"opacity-50 cursor-not-allowed hover:bg-transparent",x&&"bg-gray-100 dark:bg-gray-700",s),children:[jsxRuntime.jsx("span",{className:"mr-2 shrink-0 w-4 h-4",children:r||jsxRuntime.jsx("span",{className:p("flex items-center justify-center w-4 h-4 rounded-full border-2 transition-colors",h?"border-blue-600":"border-gray-300 dark:border-gray-600"),children:h&&jsxRuntime.jsx("span",{className:"w-2 h-2 rounded-full bg-blue-600"})})}),jsxRuntime.jsxs("span",{className:"flex-1 min-w-0",children:[jsxRuntime.jsx("span",{className:"block truncate",children:t}),n&&jsxRuntime.jsx("span",{className:"block text-xs text-gray-500 dark:text-gray-400 truncate",children:n})]}),h&&!r&&jsxRuntime.jsx("svg",{className:"ml-auto w-4 h-4 text-blue-600",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:jsxRuntime.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M5 13l4 4L19 7"})})]})}am.displayName="DropdownRadioItem";var cm=Cl.createContext(null);function dm(){let e=Cl.useContext(cm);if(!e)throw new Error("DropdownSubMenu components must be used within a DropdownSubMenu");return e}function um({children:e}){let[t,r]=Cl.useState(false),n=Cl.useRef(null),o=Cl.useRef(null),a=Cl.useMemo(()=>({isOpen:t,setIsOpen:r,triggerRef:n,contentRef:o}),[t]);return jsxRuntime.jsx(cm.Provider,{value:a,children:jsxRuntime.jsx("div",{className:"relative",children:e})})}um.displayName="DropdownSubMenu";var im=0;function mm({children:e,icon:t,disabled:r=false,className:n,index:o}){let{isOpen:a,setIsOpen:s,triggerRef:l}=dm(),{focusedIndex:i,setFocusedIndex:c,registerItem:d}=Dr(),u=Cl.useRef(o??-1);Cl.useEffect(()=>(o===void 0&&(u.current=im++),d(u.current,l.current),()=>{d(u.current,null);}),[o,d,l]),Cl.useEffect(()=>()=>{im=0;},[]);let f=i===u.current;return jsxRuntime.jsxs("button",{ref:l,role:"menuitem",type:"button",tabIndex:f?0:-1,"aria-haspopup":"menu","aria-expanded":a,disabled:r,"data-disabled":r||void 0,"data-focused":f||void 0,onMouseEnter:()=>{r||(c(u.current),s(true));},onMouseLeave:()=>{setTimeout(()=>{s(false);},100);},onKeyDown:b=>{r||(b.key==="ArrowRight"||b.key==="Enter")&&(b.preventDefault(),s(true));},className:p("relative flex w-full items-center px-3 py-2 text-left text-sm","outline-none transition-colors","text-gray-700 dark:text-gray-200","hover:bg-gray-100 dark:hover:bg-gray-700","focus:bg-gray-100 dark:focus:bg-gray-700",r&&"opacity-50 cursor-not-allowed hover:bg-transparent",f&&"bg-gray-100 dark:bg-gray-700",n),children:[t&&jsxRuntime.jsx("span",{className:"mr-2 shrink-0 w-5 h-5",children:t}),jsxRuntime.jsx("span",{className:"flex-1",children:e}),jsxRuntime.jsx("svg",{className:"ml-auto w-4 h-4 text-gray-400",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:jsxRuntime.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 5l7 7-7 7"})})]})}mm.displayName="DropdownSubMenuTrigger";function pm({children:e,sideOffset:t=0,className:r}){let{isOpen:n,setIsOpen:o,triggerRef:a,contentRef:s}=dm(),[l,i]=Cl.useState(false),c=_n({triggerRef:a,contentRef:s,isOpen:n,side:"right",align:"start",sideOffset:t,avoidCollisions:true});sa(s,()=>o(false),n),Cl.useEffect(()=>{let g=s.current;if(g)return Pn(g,()=>a.current)},[s,a]);let d=Cl.useCallback(()=>{o(true);},[o]),u=Cl.useCallback(()=>{o(false);},[o]),f=g=>{(g.key==="ArrowLeft"||g.key==="Escape")&&(g.preventDefault(),o(false),a.current?.focus());};Cl.useLayoutEffect(()=>{let g=0;if(!n){i(false);return}let y=()=>{let b=a.current?.getBoundingClientRect(),h=s.current?.getBoundingClientRect();if(c.isReady&&!!b&&!!h&&b.width>0&&b.height>0&&h.width>0&&h.height>0){i(true);return}g=requestAnimationFrame(y);};return i(false),g=requestAnimationFrame(y),()=>{g&&cancelAnimationFrame(g);}},[n,c.isReady,a,s]);let m=jsxRuntime.jsx("div",{ref:s,role:"menu","aria-orientation":"vertical","aria-hidden":!n,tabIndex:-1,onMouseEnter:d,onMouseLeave:u,onKeyDown:f,style:{position:"fixed",top:c.top,left:c.left,visibility:n&&l?"visible":"hidden",opacity:n&&l?1:0,pointerEvents:n&&l?"auto":"none"},className:p("z-50 min-w-40 overflow-hidden rounded-lg","border border-gray-200 bg-white shadow-lg","dark:border-gray-700 dark:bg-gray-800",n&&l&&"animate-in fade-in-0 zoom-in-95 duration-150",r),children:jsxRuntime.jsx("div",{className:"py-1",children:e})});return typeof document<"u"?reactDom.createPortal(m,document.body):m}pm.displayName="DropdownSubMenuContent";var ov=(e="md")=>({sm:"text-xs p-1.5",md:"text-sm p-2.5",lg:"text-base p-3.5"})[e],ma=({size:e="md",error:t,disabled:r,readOnly:n,icon:o,iconPosition:a})=>p("bg-gray-50 rounded-lg block w-full","border focus:outline-none focus:ring-0","dark:bg-gray-700 dark:placeholder-gray-400",ov(e),o&&a==="left"?"pl-9":"",o&&a==="right"?"pr-9":"",r?"opacity-50 cursor-not-allowed":"",n?"bg-gray-100 dark:bg-gray-600 cursor-default":"",t?"border-red-500 dark:border-red-500":"border-gray-300 dark:border-gray-600"),gm=(e,t)=>p("text-sm font-medium",e?"min-w-[120px]":"block mb-2",!t&&"text-gray-900 dark:text-white"),fm=e=>p("mt-1 text-xs",e?"text-red-500 dark:text-red-400":"text-gray-500 dark:text-gray-400"),Po=e=>p("absolute inset-y-0 flex items-center pointer-events-none",e==="left"?"left-2.5":"right-2.5");var pa=({label:e,hideLabel:t,labelColor:r,error:n,helperText:o,inline:a,children:s,htmlFor:l})=>jsxRuntime.jsxs("div",{className:a?"flex items-center gap-4":"flex flex-col",children:[e&&!t&&jsxRuntime.jsx("label",{htmlFor:l,className:gm(a||false,r),style:r?{color:r}:void 0,children:e}),jsxRuntime.jsx("div",{className:a?"flex-1":"w-full",children:s}),o&&jsxRuntime.jsx("p",{className:p(fm(n),a&&"ml-34"),children:o})]});var dn=Cl.forwardRef(({label:e,inline:t=false,size:r="md",labelColor:n,borderColor:o,textColor:a,disabled:s=false,readOnly:l=false,error:i=false,helperText:c,hideLabel:d=false,icon:u,iconPosition:f="left",multiline:m=false,rows:g=3,focused:y=false,className:b,...h},x)=>{let L=Cl.useRef(null),C=P=>{L.current=P,typeof x=="function"?x(P):x&&(x.current=P);};Cl.useEffect(()=>{y&&L.current?.focus();},[y]);let S=Cl.useId(),v=p(ma({size:r,error:i,disabled:s,readOnly:l,icon:u,iconPosition:f}),m&&"resize-vertical",b),R={...o&&{borderColor:o},...a&&{color:a}},N=o||a?R:void 0;return jsxRuntime.jsx(pa,{label:e,hideLabel:d,labelColor:n,error:i,helperText:c,inline:t,htmlFor:S,children:jsxRuntime.jsxs("div",{className:"relative w-full",children:[u&&jsxRuntime.jsx("span",{className:Po(f),children:u}),m?jsxRuntime.jsx("textarea",{ref:C,id:S,disabled:s,readOnly:l,rows:g,tabIndex:l||s?-1:void 0,className:v,style:N,...h}):jsxRuntime.jsx("input",{ref:C,id:S,disabled:s,readOnly:l,tabIndex:l||s?-1:void 0,className:v,style:N,...h})]})})});dn.displayName="Input";var fv=e=>jsxRuntime.jsxs("div",{className:"flex items-center gap-2 px-3 py-2 hover:bg-gray-100 dark:hover:bg-gray-700 cursor-pointer",children:[e.avatar&&jsxRuntime.jsx("img",{src:e.avatar,alt:e.label,className:"w-6 h-6 rounded-full"}),jsxRuntime.jsx("span",{className:"text-sm text-gray-900 dark:text-white",children:e.label})]}),ac=Cl.forwardRef(({label:e,inline:t=false,size:r="md",labelColor:n,borderColor:o,textColor:a,disabled:s=false,readOnly:l=false,error:i=false,helperText:c,hideLabel:d=false,icon:u,iconPosition:f="left",mentionTrigger:m="@",suggestions:g=[],onMentionSearch:y,onMentionSelect:b,onMentionRemove:h,renderSuggestion:x,value:L,onChange:C,placeholder:S,loading:v=false,maxSuggestions:R=10,chipVariant:N="soft",chipColor:M="primary",chipSize:P="sm"},E)=>{let W=Cl.useId(),T=Cl.useRef(null),[O,H]=Cl.useState(false),[k,z]=Cl.useState(0),[A,I]=Cl.useState(""),X=p(ma({size:r,error:i,disabled:s,readOnly:l,icon:u,iconPosition:f}),"min-h-[42px]","whitespace-pre-wrap","break-words"),$={...o&&{borderColor:o},...a&&{color:a}},K=o||a?$:void 0,D=Cl.useCallback(()=>{if(!T.current)return {text:"",mentions:[]};let F="",_=[],J=0,ne=Y=>{if(Y.nodeType===Node.TEXT_NODE)F+=Y.textContent||"",J+=(Y.textContent||"").length;else if(Y.nodeType===Node.ELEMENT_NODE){let ee=Y;if(ee.hasAttribute("data-mention-id")){let Z=ee.getAttribute("data-mention-id"),ie=ee.getAttribute("data-mention-label")||"",V=ee.getAttribute("data-mention-avatar")||void 0,oe=`@${ie}`,pe=J;_.push({trigger:m,suggestion:{id:Z||"",label:ie,avatar:V},startIndex:pe,endIndex:pe+oe.length}),F+=oe,J+=oe.length;}else ee.childNodes.forEach(ne);}};return T.current.childNodes.forEach(ne),{text:F,mentions:_}},[m]),B=Cl.useCallback((F,_)=>{let J=document.createElement("span");return J.contentEditable="false",J.setAttribute("data-mention-id",F.id),J.setAttribute("data-mention-label",F.label),F.avatar&&J.setAttribute("data-mention-avatar",F.avatar),J.className="inline-block align-middle mx-0.5",J.style.userSelect="none",client.createRoot(J).render(jsxRuntime.jsx(li,{label:F.label,variant:N,color:M,size:P,closable:!s&&!l,onClose:_,disabled:s,avatar:F.avatar?jsxRuntime.jsx("img",{src:F.avatar,alt:F.label,className:"w-full h-full object-cover"}):void 0})),J},[N,M,P,s,l]),w=Cl.useCallback(F=>{if(!T.current)return;let _=T.current.querySelector(`[data-mention-id="${F}"]`);if(_){_.remove();let J=D();C?.(J);let ne=L?.mentions.find(Y=>Y.suggestion.id===F)?.suggestion;ne&&h?.(ne);}},[D,C,h,L?.mentions]),G=Cl.useCallback(()=>{if(!T.current)return;let F=window.getSelection();if(!F||F.rangeCount===0)return;let _=F.getRangeAt(0),J="";_.startContainer.nodeType===Node.TEXT_NODE&&(J=_.startContainer.textContent?.substring(0,_.startOffset)||"");let ne=J.match(new RegExp(`${m}(\\w*)$`));if(ne){let ee=ne[1];I(ee),H(true),z(0),y?.(ee);}else H(false),I("");let Y=D();C?.(Y);},[m,y,C,D]),q=Cl.useCallback(F=>{if(!T.current)return;let _=window.getSelection();if(!_||_.rangeCount===0)return;let J=_.getRangeAt(0);if(J.startContainer.nodeType===Node.TEXT_NODE){let Y=J.startContainer,ee=Y.textContent||"",Z=J.startOffset,V=ee.substring(0,Z).lastIndexOf(m);if(V!==-1){let oe=ee.substring(0,V),pe=ee.substring(Z),Te=B(F,()=>{w(F.id);});if(oe?(Y.textContent=oe,Y.parentNode?.insertBefore(Te,Y.nextSibling)):(Y.parentNode?.insertBefore(Te,Y),Y.textContent="",Y.textContent||Y.remove()),pe){let re=document.createTextNode(pe);Te.parentNode?.insertBefore(re,Te.nextSibling);}let ze=document.createTextNode(" ");Te.parentNode?.insertBefore(ze,Te.nextSibling);let ae=document.createRange();ae.setStartAfter(ze),ae.collapse(true),_.removeAllRanges(),_.addRange(ae);}}H(false),I("");let ne=D();C?.(ne),b?.(F),T.current.focus();},[m,B,w,D,C,b]),j=Cl.useCallback(F=>{let _=g.slice(0,R);if(O&&_.length>0)switch(F.key){case "ArrowDown":F.preventDefault(),z(J=>J<_.length-1?J+1:0);return;case "ArrowUp":F.preventDefault(),z(J=>J>0?J-1:_.length-1);return;case "Enter":case "Tab":F.preventDefault(),_[k]&&q(_[k]);return;case "Escape":F.preventDefault(),H(false);return}if(F.key==="Backspace"){let J=window.getSelection();if(!J||J.rangeCount===0)return;let ne=J.getRangeAt(0);if(ne.collapsed&&ne.startOffset===0){let Y=ne.startContainer.previousSibling;if(Y&&Y.nodeType===Node.ELEMENT_NODE){let ee=Y;if(ee.hasAttribute("data-mention-id")){F.preventDefault();let Z=ee.getAttribute("data-mention-id");Z&&w(Z);return}}}if(ne.collapsed&&ne.startContainer.nodeType===Node.TEXT_NODE){let Y=ne.startContainer;if(ne.startOffset===0){let ee=Y.previousSibling;if(ee&&ee.nodeType===Node.ELEMENT_NODE){let Z=ee;if(Z.hasAttribute("data-mention-id")){F.preventDefault();let ie=Z.getAttribute("data-mention-id");ie&&w(ie);return}}}}}},[O,g,k,R,q,w]);return Cl.useEffect(()=>{T.current&&(!(T.current.textContent||T.current.querySelector("[data-mention-id]"))&&S?T.current.setAttribute("data-placeholder",S):T.current.removeAttribute("data-placeholder"));},[S,L]),Cl.useEffect(()=>{T.current&&L?.text===""&&L?.mentions.length===0&&T.current.innerHTML.trim()&&(T.current.innerHTML="");},[L?.text,L?.mentions.length]),jsxRuntime.jsx(pa,{label:e,hideLabel:d,labelColor:n,error:i,helperText:c,inline:t,htmlFor:W,children:jsxRuntime.jsxs("div",{className:"relative w-full",children:[u&&jsxRuntime.jsx("span",{className:Po(f),children:u}),jsxRuntime.jsx("div",{ref:F=>{typeof E=="function"?E(F):E&&(E.current=F),T.current=F;},id:W,contentEditable:!s&&!l,suppressContentEditableWarning:true,onInput:G,onKeyDown:j,className:p(X,"empty:before:content-[attr(data-placeholder)] empty:before:text-gray-400 empty:before:dark:text-gray-500"),style:K,role:"textbox","aria-label":e,"aria-multiline":"true",tabIndex:l||s?-1:0}),O&&g.length>0&&jsxRuntime.jsx("div",{className:"absolute z-10 mt-1 w-full max-h-60 overflow-auto rounded-lg border border-gray-300 bg-white dark:bg-gray-700 dark:border-gray-600 shadow-lg",children:v?jsxRuntime.jsx("div",{className:"px-3 py-2 text-sm text-gray-500 dark:text-gray-400",children:"Loading..."}):g.slice(0,R).map((F,_)=>jsxRuntime.jsx("div",{onClick:()=>q(F),className:p(_===k&&"bg-gray-100 dark:bg-gray-600"),children:x?x(F):fv(F)},F.id))})]})})});ac.displayName="MentionInput";var sc=Cl.forwardRef(({label:e,inline:t=false,size:r="md",labelColor:n,borderColor:o,textColor:a,disabled:s=false,readOnly:l=false,error:i=false,helperText:c,hideLabel:d=false,icon:u,iconPosition:f="left",className:m,value:g,onChange:y,format:b="number",currency:h="USD",locale:x="en-US",decimals:L,min:C,max:S,step:v=1,prefix:R,suffix:N,thousandSeparator:M=true,allowNegative:P=true,onBlur:E,onFocus:W,...T},O)=>{let H=Cl.useId(),[k,z]=Cl.useState(null),A=Cl.useMemo(()=>{let U=b==="currency"?{style:"currency",currency:h,minimumFractionDigits:L??2,maximumFractionDigits:L??2}:b==="percentage"?{minimumFractionDigits:L??0,maximumFractionDigits:L??2}:{minimumFractionDigits:L??0,maximumFractionDigits:L??(b==="decimal"?2:0),useGrouping:M};try{return new Intl.NumberFormat(x,U)}catch{return null}},[b,h,x,L,M]),I=U=>{if(U==null)return "";if(!A)return String(U);let F=A.format(U);return b==="percentage"?(F=R?`${R}${F}`:F,F=N||!F.includes("%")?`${F}%`:F,F):(R&&(F=`${R}${F}`),N&&(F=`${F}${N}`),F)},X=U=>{if(!U||U.trim()==="")return null;let F=U;if(R&&(F=F.replace(R,"")),N&&(F=F.replace(N,"")),F=F.replace(/[^\d.,-]/g,""),x.includes("fr")||x.includes("de")?F=F.replace(/\s/g,"").replace(",","."):F=F.replace(",",""),!F||F==="-"||F===".")return null;let _=parseFloat(F);return isNaN(_)?null:!P&&_<0?Math.abs(_):C!==void 0&&_<C?C:S!==void 0&&_>S?S:_},$=k??I(g??null),K=U=>{let F=x.includes("fr")||x.includes("de")?",":".";return new RegExp(`^-?[0-9${F===","?",":"\\."}]*$`).test(U)},D=U=>{let F=U.target.value;if(F===""||K(F)){z(F);let _=X(F);y&&y(_);}},B=U=>{let F=x.includes("fr")||x.includes("de")?",":".",_=["Backspace","Delete","Tab","Escape","Enter","ArrowLeft","ArrowRight","ArrowUp","ArrowDown","Home","End"],J=/^[0-9]$/.test(U.key),ne=U.key===F,Y=U.key==="-"&&P&&$.indexOf("-")===-1,ee=U.ctrlKey||U.metaKey;!J&&!ne&&!Y&&!_.includes(U.key)&&!ee&&U.preventDefault();},w=U=>{let F=g!=null?String(g):"";z(F),W&&W(U);},G=U=>{let F=X(k??"");y&&F!==g&&y(F),z(null),E&&E(U);},q=p(ma({size:r,error:i,disabled:s,readOnly:l,icon:u,iconPosition:f}),o&&`border-[${o}]`,a&&`text-[${a}]`,m),j=jsxRuntime.jsxs("div",{className:"relative",children:[u&&f==="left"&&jsxRuntime.jsx("div",{className:Po(f),children:u}),jsxRuntime.jsx("input",{ref:O,id:H,type:"text",inputMode:"decimal",className:q,style:{borderColor:o,color:a},disabled:s,readOnly:l,value:$,onChange:D,onKeyDown:B,onFocus:w,onBlur:G,...T}),u&&f==="right"&&jsxRuntime.jsx("div",{className:Po(f),children:u})]});return jsxRuntime.jsx(pa,{label:e,hideLabel:d,labelColor:n,error:i,helperText:c,inline:t,htmlFor:H,children:j})});sc.displayName="NumberInput";function Cv({logo:e,logoHref:t="/",onLogoClick:r,navItems:n=[],actions:o,rightContent:a,variant:s="default",size:l="md",backgroundColor:i,textColor:c,hoverColor:d,navItemTextColor:u,navItemHoverColor:f,navItemBgHover:m,navItemActiveColor:g,sticky:y=false,fixed:b=false,showSearch:h=false,onSearch:x,searchPlaceholder:L="Search...",className:C,containerClassName:S}){let[v,R]=Cl.useState(false),[N,M]=Cl.useState(null),[P,E]=Cl.useState(""),W=()=>{R(!v);},T=D=>{M(N===D?null:D);},O=D=>{D.preventDefault(),x&&x(P);},H=p(y&&"sticky top-0 z-50",b&&"fixed top-0 left-0 right-0 z-50"),k=p(s==="default"&&!i&&"bg-neutral text-white",s==="transparent"&&!i&&"bg-transparent",s==="bordered"&&!i&&"bg-white border-b border-gray-200 text-gray-900 dark:bg-gray-900 dark:border-gray-800 dark:text-gray-100",s==="shadow"&&!i&&"bg-white shadow-md text-gray-900 dark:bg-gray-900 dark:text-gray-100"),z=p(l==="sm"&&"py-2",l==="md"&&"py-4",l==="lg"&&"py-6"),A=i||"",I=c||"",X=d||"",$=p(H,k,z,A,I,C),K=(D,B,w=false)=>{let G=D.children&&D.children.length>0,q=N===B,j=p("px-4 py-2 transition-colors flex items-center gap-2",w?"block w-full text-left":"inline-flex",D.active&&"font-semibold border-b-2",D.active&&(g||"border-current"),u||(s==="default"||s==="transparent"?"text-gray-300":"text-gray-600 dark:text-gray-300"),f||X||(s==="default"||s==="transparent"?"hover:text-white":"hover:text-blue-600 dark:hover:text-blue-400"),m||"");if(G)return jsxRuntime.jsxs("div",{className:w?"w-full":"relative",children:[jsxRuntime.jsxs("button",{type:"button",onClick:()=>T(B),className:j,children:[D.icon&&jsxRuntime.jsx("span",{className:"w-5 h-5",children:D.icon}),jsxRuntime.jsx("span",{children:D.label}),D.badge&&jsxRuntime.jsx("span",{className:"bg-red-500 text-white text-xs px-2 py-0.5 rounded-full",children:D.badge}),jsxRuntime.jsx("svg",{className:p("w-4 h-4 transition-transform",q&&"rotate-180"),fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:jsxRuntime.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 9l-7 7-7-7"})})]}),q&&jsxRuntime.jsx("div",{className:p("bg-white shadow-lg rounded-lg overflow-hidden dark:bg-gray-800 dark:shadow-black/40",w?"mt-2 mb-2":"absolute top-full left-0 mt-1 min-w-[200px]"),children:D.children?.map(F=>jsxRuntime.jsx("a",{href:F.href,onClick:F.onClick,target:F.external?"_blank":void 0,rel:F.external?"noopener noreferrer":void 0,className:"block px-4 py-2 text-gray-700 hover:bg-gray-100 transition-colors dark:text-gray-200 dark:hover:bg-gray-700",children:jsxRuntime.jsxs("div",{className:"flex items-center gap-2",children:[F.icon&&jsxRuntime.jsx("span",{className:"w-5 h-5",children:F.icon}),jsxRuntime.jsx("span",{children:F.label}),F.badge&&jsxRuntime.jsx("span",{className:"bg-red-500 text-white text-xs px-2 py-0.5 rounded-full ml-auto",children:F.badge}),F.external&&jsxRuntime.jsx("svg",{className:"w-4 h-4 ml-auto",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:jsxRuntime.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M10 6H6a2 2 0 00-2 2v10a2 2 0 002 2h10a2 2 0 002-2v-4M14 4h6m0 0v6m0-6L10 14"})})]})},F.href??F.label))})]},D.href??D.label);let U=jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[D.icon&&jsxRuntime.jsx("span",{className:"w-5 h-5",children:D.icon}),jsxRuntime.jsx("span",{children:D.label}),D.badge&&jsxRuntime.jsx("span",{className:"bg-red-500 text-white text-xs px-2 py-0.5 rounded-full",children:D.badge}),D.external&&jsxRuntime.jsx("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:jsxRuntime.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M10 6H6a2 2 0 00-2 2v10a2 2 0 002 2h10a2 2 0 002-2v-4M14 4h6m0 0v6m0-6L10 14"})})]});return D.onClick?jsxRuntime.jsx("button",{type:"button",onClick:D.onClick,className:j,children:U},D.href??D.label):jsxRuntime.jsx("a",{href:D.href,target:D.external?"_blank":void 0,rel:D.external?"noopener noreferrer":void 0,className:j,children:U},D.href??D.label)};return jsxRuntime.jsxs("header",{className:$,children:[jsxRuntime.jsxs("nav",{className:p("container mx-auto flex items-center justify-between px-4",S),children:[e&&jsxRuntime.jsx("div",{className:"flex items-center",children:t?jsxRuntime.jsx("a",{href:t,onClick:r,className:"flex items-center hover:opacity-80 transition-opacity",children:e}):jsxRuntime.jsx("div",{className:"flex items-center",children:e})}),h&&jsxRuntime.jsx("form",{onSubmit:O,className:"hidden md:flex flex-1 max-w-md mx-8",children:jsxRuntime.jsx("input",{type:"search","aria-label":L,value:P,onChange:D=>E(D.target.value),placeholder:L,className:"w-full px-4 py-2 rounded-lg border border-gray-300 focus:outline-none focus:ring-2 focus:ring-blue-500 text-gray-900 dark:border-gray-700 dark:bg-gray-800 dark:text-gray-100 dark:placeholder-gray-500"})}),jsxRuntime.jsx("div",{className:"hidden md:flex items-center gap-2",children:n.map((D,B)=>K(D,B,false))}),(o||a)&&jsxRuntime.jsxs("div",{className:"hidden md:flex items-center gap-2 ml-4",children:[o,a]}),n.length>0&&jsxRuntime.jsx("div",{className:"md:hidden",children:jsxRuntime.jsx("button",{type:"button",className:p("inline-flex rounded-lg border-2 p-2 w-10 h-10 justify-center transition-colors focus:outline-none",s==="default"||s==="transparent"?"text-gray-300 hover:text-white":"text-gray-600 hover:text-gray-900 dark:text-gray-300 dark:hover:text-gray-100"),onClick:W,"aria-label":"Toggle menu","aria-expanded":v,children:jsxRuntime.jsx("svg",{className:"w-5 h-5","aria-hidden":"true",xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 17 14",children:jsxRuntime.jsx("path",{stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",d:"M1 1h15M1 7h15M1 13h15"})})})})]}),v&&n.length>0&&jsxRuntime.jsx("div",{className:p("md:hidden border-t animate-in slide-in-from-top duration-300",s==="default"||s==="transparent"?"border-gray-700":"border-gray-200 dark:border-gray-800"),children:jsxRuntime.jsxs("div",{className:"flex flex-col py-2 px-4",children:[h&&jsxRuntime.jsx("form",{onSubmit:O,className:"mb-4",children:jsxRuntime.jsx("input",{type:"search","aria-label":L,value:P,onChange:D=>E(D.target.value),placeholder:L,className:"w-full px-4 py-2 rounded-lg border border-gray-300 focus:outline-none focus:ring-2 focus:ring-blue-500 text-gray-900 dark:border-gray-700 dark:bg-gray-800 dark:text-gray-100 dark:placeholder-gray-500"})}),n.map((D,B)=>K(D,B,true)),(o||a)&&jsxRuntime.jsxs("div",{className:"flex flex-col gap-2 mt-4 pt-4 border-t border-gray-700",children:[o,a]})]})})]})}var Rv=jsxRuntime.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[jsxRuntime.jsx("path",{d:"M11 4H4a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7"}),jsxRuntime.jsx("path",{d:"M18.5 2.5a2.121 2.121 0 0 1 3 3L12 15l-4 1 1-4 9.5-9.5z"})]}),Pv=jsxRuntime.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[jsxRuntime.jsx("path",{d:"M19 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h11l5 5v11a2 2 0 0 1-2 2z"}),jsxRuntime.jsx("polyline",{points:"17 21 17 13 7 13 7 21"}),jsxRuntime.jsx("polyline",{points:"7 3 7 8 15 8"})]}),Tv=jsxRuntime.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[jsxRuntime.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),jsxRuntime.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]}),Dv=jsxRuntime.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[jsxRuntime.jsx("polyline",{points:"1 4 1 10 7 10"}),jsxRuntime.jsx("path",{d:"M3.51 15a9 9 0 1 0 2.13-9.36L1 10"})]}),Ev=jsxRuntime.jsxs("svg",{className:"animate-spin h-4 w-4",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[jsxRuntime.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10"}),jsxRuntime.jsx("path",{className:"opacity-75",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4z",fill:"currentColor"})]}),Lv={xs:"w-4 h-4 text-[10px]",sm:"w-5 h-5 text-xs",md:"w-6 h-6 text-sm",lg:"w-7 h-7 text-base"},Mv={top:"bottom-full left-1/2 -translate-x-1/2 mb-2",bottom:"top-full left-1/2 -translate-x-1/2 mt-2",left:"right-full top-1/2 -translate-y-1/2 mr-2",right:"left-full top-1/2 -translate-y-1/2 ml-2"},Iv={sm:"w-56",md:"w-72",lg:"w-96",xl:"w-[32rem]"},Av=[Sv__default.default],zv={h1:({...e})=>jsxRuntime.jsx("h1",{className:"text-xl font-bold mb-2 text-gray-900 dark:text-gray-100",...e}),h2:({...e})=>jsxRuntime.jsx("h2",{className:"text-lg font-semibold mt-4 mb-2 text-gray-900 dark:text-gray-100",...e}),h3:({...e})=>jsxRuntime.jsx("h3",{className:"text-base font-semibold mt-3 mb-1 text-gray-900 dark:text-gray-100",...e}),p:({...e})=>jsxRuntime.jsx("p",{className:"my-1 text-gray-700 dark:text-gray-300",...e}),ul:({...e})=>jsxRuntime.jsx("ul",{className:"list-disc list-inside space-y-1 my-2 text-gray-700 dark:text-gray-300",...e}),ol:({...e})=>jsxRuntime.jsx("ol",{className:"list-decimal list-inside space-y-1 my-2 text-gray-700 dark:text-gray-300",...e}),code:({className:e,children:t,...r})=>!e?.includes("language-")?jsxRuntime.jsx("code",{className:"bg-gray-100 dark:bg-gray-800 px-1.5 py-0.5 rounded text-sm font-mono text-gray-900 dark:text-gray-100",...r,children:t}):jsxRuntime.jsx("code",{className:"block bg-gray-100 dark:bg-gray-800 rounded-lg p-3 my-2 overflow-x-auto text-sm font-mono text-gray-900 dark:text-gray-100",...r,children:t}),pre:({...e})=>jsxRuntime.jsx("pre",{className:"my-2",...e}),a:({...e})=>jsxRuntime.jsx("a",{className:"text-blue-600 dark:text-blue-400 hover:underline",...e}),strong:({...e})=>jsxRuntime.jsx("strong",{className:"font-semibold text-gray-900 dark:text-gray-100",...e}),em:({...e})=>jsxRuntime.jsx("em",{className:"italic",...e}),blockquote:({...e})=>jsxRuntime.jsx("blockquote",{className:"border-l-4 border-gray-300 dark:border-gray-600 pl-4 my-2 italic text-gray-600 dark:text-gray-400",...e})};function ym({content:e,markdown:t=false,position:r="bottom",size:n="sm",className:o="",visible:a=true,editable:s=false,onSave:l,onReset:i,width:c="md",title:d,markdownEditor:u,markdownEditorUnavailableLabel:f}){let m=Ve(),[g,y]=Cl.useState(false),[b,h]=Cl.useState(false),[x,L]=Cl.useState(""),[C,S]=Cl.useState(false),[v,R]=Cl.useState(null),N=Cl.useRef(null),M=Cl.useRef(null),P=Cl.useRef(null),E=Cl.useRef(null);Cl.useEffect(()=>{if(!g)return;let z=I=>{N.current&&!N.current.contains(I.target)&&M.current&&!M.current.contains(I.target)&&(b||y(false));},A=I=>{I.key==="Escape"&&(b?(h(false),L("")):y(false));};return document.addEventListener("mousedown",z),document.addEventListener("keydown",A),()=>{document.removeEventListener("mousedown",z),document.removeEventListener("keydown",A);}},[g,b]),Cl.useEffect(()=>{b&&P.current&&P.current.focus();},[b]),Cl.useEffect(()=>()=>{E.current&&clearTimeout(E.current);},[]);let W=Cl.useCallback(()=>{L(typeof e=="string"?e:""),h(true),R(null);},[e]),T=Cl.useCallback(()=>{h(false),L(""),R(null);},[]),O=Cl.useCallback(async()=>{if(!l){R({type:"error",text:"Aucune fonction de sauvegarde fournie"});return}S(true);try{await l(x)?(R({type:"success",text:"Sauvegard\xE9 avec succ\xE8s !"}),h(!1),E.current&&clearTimeout(E.current),E.current=setTimeout(()=>R(null),2e3)):R({type:"error",text:"Erreur lors de la sauvegarde"});}catch{R({type:"error",text:"Erreur lors de la sauvegarde"});}finally{S(false);}},[x,l]),H=Cl.useCallback(async()=>{if(i&&confirm("\xCAtes-vous s\xFBr de vouloir r\xE9initialiser ce contenu ?")){S(true);try{await i()?(R({type:"success",text:"R\xE9initialis\xE9 avec succ\xE8s !"}),h(!1),E.current&&clearTimeout(E.current),E.current=setTimeout(()=>R(null),2e3)):R({type:"error",text:"Erreur lors de la r\xE9initialisation"});}catch{R({type:"error",text:"Erreur lors de la r\xE9initialisation"});}finally{S(false);}}},[i]),k=e;return a?jsxRuntime.jsxs("div",{className:"relative inline-flex items-center",children:[jsxRuntime.jsx("button",{type:"button",ref:N,onClick:()=>y(!g),className:`
4
+ ${Lv[n]}
4
5
  inline-flex items-center justify-center
5
6
  rounded-full border border-gray-300 dark:border-gray-600
6
7
  bg-white dark:bg-gray-800
@@ -12,20 +13,20 @@
12
13
  transition-all duration-150
13
14
  focus:outline-none focus:ring-2 focus:ring-blue-500/50
14
15
  ${o}
15
- `,"aria-label":"Afficher l'aide","aria-expanded":p,children:jsxRuntime.jsx("span",{className:"font-medium",children:"?"})}),p&&jsxRuntime.jsxs("div",{ref:M,className:`
16
- absolute z-50 ${$x[r]}
17
- ${_x[c]} max-h-[80vh] overflow-hidden flex flex-col
16
+ `,"aria-label":"Afficher l'aide","aria-expanded":g,children:jsxRuntime.jsx("span",{className:"font-medium",children:"?"})}),g&&jsxRuntime.jsxs("div",{ref:M,className:`
17
+ absolute z-50 ${Mv[r]}
18
+ ${Iv[c]} max-h-[80vh] overflow-hidden flex flex-col
18
19
  bg-white dark:bg-gray-900
19
20
  border border-gray-200 dark:border-gray-700
20
21
  rounded-xl shadow-xl
21
22
  text-sm text-gray-700 dark:text-gray-300
22
23
  animate-in fade-in-0 zoom-in-95 duration-150
23
- `,role:"tooltip",children:[(d||s)&&jsxRuntime.jsxs("div",{className:"flex items-center justify-between px-4 py-2 border-b border-gray-200 dark:border-gray-700 bg-gray-50 dark:bg-gray-800/50",children:[jsxRuntime.jsx("div",{className:"flex items-center gap-2",children:d&&jsxRuntime.jsx("h3",{className:"text-sm font-semibold",children:d})}),s&&jsxRuntime.jsx("div",{className:"flex items-center gap-1",children:v?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("button",{type:"button",onClick:B,disabled:S,className:"p-1.5 rounded-md hover:bg-green-100 dark:hover:bg-green-900/30 text-green-600 dark:text-green-400 transition-colors disabled:opacity-50 cursor-pointer",title:"Sauvegarder",children:S?Fx:Hx}),jsxRuntime.jsx("button",{type:"button",onClick:P,className:"p-1.5 rounded-md hover:bg-gray-200 dark:hover:bg-gray-700 text-gray-500 hover:text-gray-700 dark:hover:text-gray-300 transition-colors cursor-pointer",title:"Annuler",children:Bx}),i&&jsxRuntime.jsx("button",{type:"button",onClick:C,disabled:S,className:"p-1.5 rounded-md hover:bg-orange-100 dark:hover:bg-orange-900/30 text-orange-600 dark:text-orange-400 transition-colors disabled:opacity-50 cursor-pointer",title:"R\xE9initialiser",children:Vx})]}):jsxRuntime.jsx("button",{type:"button",onClick:H,className:"p-1.5 rounded-md hover:bg-gray-200 dark:hover:bg-gray-700 text-gray-500 hover:text-gray-700 dark:hover:text-gray-300 transition-colors cursor-pointer",title:"Modifier",children:Wx})})]}),R&&jsxRuntime.jsx("div",{className:`px-4 py-2 text-xs ${R.type==="success"?"bg-green-50 dark:bg-green-900/20 text-green-600 dark:text-green-400":"bg-red-50 dark:bg-red-900/20 text-red-600 dark:text-red-400"}`,children:R.text}),jsxRuntime.jsx("div",{className:"flex-1 overflow-y-auto p-4",children:v?t?u?jsxRuntime.jsx(u,{value:h,onChange:I,placeholder:"\xC9crivez en Markdown..."}):jsxRuntime.jsx("p",{role:"alert",className:"p-3 text-sm text-gray-500 dark:text-gray-400",children:f??m.markdownEditorUnavailable}):jsxRuntime.jsx("div",{className:"space-y-2",children:jsxRuntime.jsx("textarea",{ref:k,"aria-label":"Contenu d'aide",value:h,onChange:E=>I(E.target.value),className:"w-full h-64 p-3 text-sm bg-gray-50 dark:bg-gray-800 border border-gray-200 dark:border-gray-700 rounded-lg resize-none focus:outline-none focus:ring-2 focus:ring-blue-500/50 text-gray-700 dark:text-gray-300 font-mono",placeholder:"\xC9crivez votre contenu d'aide..."})}):typeof b=="string"?jsxRuntime.jsx("div",{className:"prose prose-sm dark:prose-invert max-w-none",children:t?jsxRuntime.jsx(Ax__default.default,{remarkPlugins:Xx,components:Gx,children:b}):jsxRuntime.jsx("div",{dangerouslySetInnerHTML:{__html:Ix__default.default.sanitize(b)}})}):b})]})]}):null}function Kx({children:e,content:t,markdown:r=false,position:n="bottom",size:o="sm",visible:a=true,editable:s=false,onSave:l,onReset:i,width:c="md",title:d,className:u,markdownEditor:f,markdownEditorUnavailableLabel:m}){return jsxRuntime.jsxs("div",{className:"inline-flex items-center gap-2.5",children:[e,jsxRuntime.jsx(Gu,{content:t,markdown:r,position:n,size:o,visible:a,editable:s,onSave:l,onReset:i,width:c,title:d,className:u,markdownEditor:f,markdownEditorUnavailableLabel:m})]})}var Zx={"16/9":"aspect-[16/9]","4/3":"aspect-[4/3]","1/1":"aspect-square",auto:""},Qx=e=>new Promise((t,r)=>{let n=new FileReader;n.onload=o=>{let a=o.target?.result;t(a);},n.onerror=()=>{r(new Error("Erreur lors de la lecture du fichier"));},n.readAsDataURL(e);});function Jx({value:e,onChange:t,onUpload:r,label:n="Image",maxSize:o=5*1024*1024,accept:a="image/*",helpText:s,disabled:l=false,className:i="",showUrlInput:c=true,urlPlaceholder:d="https://example.com/image.jpg",aspectRatio:u="16/9"}){let[f,m]=el.useState(false),[p,w]=el.useState(null),v=el.useRef(null),x=el.useId(),h=el.useMemo(()=>(o/(1024*1024)).toFixed(0),[o]),I=`Formats accept\xE9s : ${a==="image/*"?"JPG, PNG, GIF, WebP":a} (max ${h}MB)`,S=el.useCallback(async M=>{let k=M.target.files?.[0];if(k){if(!k.type.startsWith("image/")){w("Le fichier doit \xEAtre une image");return}if(k.size>o){w(`Le fichier est trop volumineux (max ${h}MB)`);return}m(true),w(null);try{if(r){let z=await r(k);t(z);}else {let z=await Qx(k);t(z);}v.current&&(v.current.value="");}catch(z){console.error("Upload error:",z),w(z instanceof Error?z.message:"Erreur lors de l'upload");}finally{m(false);}}},[o,h,t,r]),L=el.useCallback(()=>{t(""),v.current&&(v.current.value=""),w(null);},[t]),R=el.useCallback(M=>{t(M),w(null);},[t]),T=el.useCallback(()=>{v.current?.click();},[]),y=el.useCallback(M=>{R(M.target.value);},[R]);return jsxRuntime.jsxs("div",{className:`space-y-2 ${i}`,children:[n&&jsxRuntime.jsx("label",{className:"block text-sm font-semibold text-gray-700 dark:text-gray-300",children:n}),e&&jsxRuntime.jsxs("div",{className:"relative w-full overflow-hidden rounded-lg border border-gray-300 dark:border-gray-600 bg-gray-50 dark:bg-gray-800/50",children:[jsxRuntime.jsx("div",{className:`relative ${Zx[u]} ${u==="auto"?"max-h-64":""} flex items-center justify-center`,children:jsxRuntime.jsx("img",{src:e,alt:"Aper\xE7u",className:"w-full h-full object-contain"})}),jsxRuntime.jsx("button",{type:"button",onClick:L,disabled:l,className:"absolute top-2 right-2 bg-red-500 text-white rounded-full w-6 h-6 flex items-center justify-center text-xs hover:bg-red-600 transition-colors cursor-pointer disabled:opacity-50 disabled:cursor-not-allowed",title:"Supprimer l'image",children:"\xD7"})]}),jsxRuntime.jsxs("div",{className:"flex gap-2",children:[jsxRuntime.jsx("input",{ref:v,type:"file","aria-label":"Choisir une image",accept:a,onChange:S,className:"hidden",disabled:l||f}),jsxRuntime.jsx("button",{type:"button",onClick:T,disabled:l||f,className:"px-3 py-2 text-sm border border-gray-300 dark:border-gray-600 rounded-md hover:bg-gray-50 dark:hover:bg-gray-700 disabled:opacity-50 disabled:cursor-not-allowed transition-colors cursor-pointer bg-white dark:bg-gray-800 text-gray-700 dark:text-gray-200",children:f?"\u23F3 Upload...":e?"\u{1F4C1} Changer l'image":"\u{1F4C1} Choisir une image"})]}),c&&jsxRuntime.jsxs("div",{className:"space-y-1",children:[jsxRuntime.jsx("label",{htmlFor:x,className:"block text-xs text-gray-500 dark:text-gray-400",children:"Ou URL directe :"}),jsxRuntime.jsx("input",{id:x,type:"url",value:e||"",onChange:y,placeholder:d,disabled:l,className:"w-full px-3 py-2 text-sm border border-gray-300 dark:border-gray-600 rounded-md focus:ring-2 focus:ring-blue-500 focus:border-blue-500 dark:bg-gray-800 dark:text-gray-200 disabled:opacity-50 disabled:cursor-not-allowed"})]}),p&&jsxRuntime.jsxs("div",{className:"text-red-600 dark:text-red-400 text-sm bg-red-50 dark:bg-red-900/20 p-2 rounded border border-red-200 dark:border-red-800",children:["\u274C ",p]}),jsxRuntime.jsx("div",{className:"text-xs text-gray-500 dark:text-gray-400",children:s||I})]})}var ti={default:"bg-gray-400",primary:"bg-blue-600",success:"bg-green-500",warning:"bg-yellow-400",error:"bg-red-500",info:"bg-cyan-500",dark:"bg-gray-900 dark:bg-gray-700",purple:"bg-purple-600",indigo:"bg-indigo-600",teal:"bg-teal-500"},Ol={xs:"w-2 h-2",sm:"w-2.5 h-2.5",md:"w-3 h-3",lg:"w-3.5 h-3.5",xl:"w-4 h-4"},ev={xs:"min-w-4 h-4 text-[10px] px-1",sm:"min-w-5 h-5 text-xs px-1",md:"min-w-5 h-5 text-xs px-1.5",lg:"min-w-6 h-6 text-sm px-1.5",xl:"min-w-7 h-7 text-sm px-2"},$l={"top-left":"top-0 left-0 -translate-x-1/2 -translate-y-1/2","top-center":"top-0 left-1/2 -translate-x-1/2 -translate-y-1/2","top-right":"top-0 right-0 translate-x-1/2 -translate-y-1/2","center-left":"top-1/2 left-0 -translate-x-1/2 -translate-y-1/2",center:"top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2","center-right":"top-1/2 right-0 translate-x-1/2 -translate-y-1/2","bottom-left":"bottom-0 left-0 -translate-x-1/2 translate-y-1/2","bottom-center":"bottom-0 left-1/2 -translate-x-1/2 translate-y-1/2","bottom-right":"bottom-0 right-0 translate-x-1/2 translate-y-1/2"},_l={"top-left":"top-0 left-0","top-center":"top-0 left-1/2 -translate-x-1/2","top-right":"top-0 right-0","center-left":"top-1/2 left-0 -translate-y-1/2",center:"top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2","center-right":"top-1/2 right-0 -translate-y-1/2","bottom-left":"bottom-0 left-0","bottom-center":"bottom-0 left-1/2 -translate-x-1/2","bottom-right":"bottom-0 right-0"};function tv(e,t){return e>t?`${t}+`:`${e}`}function rv({color:e="primary",size:t="md",placement:r="top-right",bordered:n=false,borderColor:o,pulse:a=false,offset:s=false,className:l,...i}){return jsxRuntime.jsx("span",{"data-testid":"indicator",className:g("absolute z-10 rounded-full",ti[e],Ol[t],s?_l[r]:$l[r],n&&g("ring-2 ring-white dark:ring-gray-900",o),a&&"animate-pulse",l),...i})}function nv({color:e="error",size:t="md",placement:r="top-right",count:n=0,maxCount:o=99,bordered:a=false,borderColor:s,pulse:l=false,offset:i=false,className:c,...d}){return jsxRuntime.jsx("span",{"data-testid":"indicator",className:g("absolute z-10 inline-flex items-center justify-center rounded-full font-semibold text-white",ti[e],ev[t],i?_l[r]:$l[r],a&&g("ring-2 ring-white dark:ring-gray-900",s),l&&"animate-pulse",c),...d,children:tv(n,o)})}function ov({color:e="success",size:t="md",placement:r="bottom-right",bordered:n=true,borderColor:o,pulse:a=false,offset:s=false,className:l,...i}){return jsxRuntime.jsx("span",{"data-testid":"indicator",className:g("absolute z-10 rounded-full",ti[e],Ol[t],s?_l[r]:$l[r],n&&g("ring-2 ring-white dark:ring-gray-900",o),a&&"animate-pulse",l),...i})}function av({color:e="primary",size:t="sm",label:r,className:n,...o}){return jsxRuntime.jsxs("span",{"data-testid":"indicator",className:g("inline-flex items-center gap-2",n),...o,children:[jsxRuntime.jsx("span",{className:g("rounded-full shrink-0",ti[e],Ol[t])}),r?jsxRuntime.jsx("span",{className:"text-sm text-gray-700 dark:text-gray-300",children:r}):null]})}function Uu({variant:e="dot",children:t,...r}){if(e==="legend")return jsxRuntime.jsx(av,{...r});let n=(()=>{switch(e){case "count":return jsxRuntime.jsx(nv,{...r});case "status":return jsxRuntime.jsx(ov,{...r});default:return jsxRuntime.jsx(rv,{...r})}})();return t?jsxRuntime.jsxs("div",{className:"relative inline-flex",children:[t,n]}):n}Uu.displayName="Indicator";var sv={xs:"text-xs",sm:"text-sm",md:"text-sm",lg:"text-base",xl:"text-lg"},qu={xs:"w-3 h-3",sm:"w-3.5 h-3.5",md:"w-4 h-4",lg:"w-4.5 h-4.5",xl:"w-5 h-5"},iv={normal:"font-normal",medium:"font-medium",semibold:"font-semibold",bold:"font-bold"},lv={default:{default:"text-gray-700 dark:text-gray-200",light:"text-gray-500 dark:text-gray-400",strong:"text-gray-900 dark:text-white"},primary:{default:"text-blue-600 dark:text-blue-400",light:"text-blue-400 dark:text-blue-300",strong:"text-blue-700 dark:text-blue-300"},secondary:{default:"text-purple-600 dark:text-purple-400",light:"text-purple-400 dark:text-purple-300",strong:"text-purple-700 dark:text-purple-300"},success:{default:"text-green-600 dark:text-green-400",light:"text-green-400 dark:text-green-300",strong:"text-green-700 dark:text-green-300"},warning:{default:"text-yellow-600 dark:text-yellow-400",light:"text-yellow-400 dark:text-yellow-300",strong:"text-yellow-700 dark:text-yellow-300"},error:{default:"text-red-600 dark:text-red-400",light:"text-red-400 dark:text-red-300",strong:"text-red-700 dark:text-red-300"},info:{default:"text-cyan-600 dark:text-cyan-400",light:"text-cyan-400 dark:text-cyan-300",strong:"text-cyan-700 dark:text-cyan-300"},muted:{default:"text-gray-500 dark:text-gray-400",light:"text-gray-400 dark:text-gray-500",strong:"text-gray-600 dark:text-gray-300"}};function Zu({children:e,size:t="md",color:r="default",variant:n="default",weight:o="medium",textColor:a,required:s=false,requiredIndicator:l="*",optional:i=false,optionalText:c="(optional)",tooltip:d,icon:u,endIcon:f,disabled:m=false,truncate:p=false,as:w="label",className:v,...x}){let h=w,I=g("inline-flex items-center gap-1.5 transition-colors",sv[t],iv[o]),S=a||lv[r][n];return jsxRuntime.jsxs(h,{className:g(I,S,m?"opacity-50 cursor-not-allowed":"cursor-default",v),title:d,"aria-disabled":m,...x,children:[u&&jsxRuntime.jsx("span",{className:g("shrink-0",qu[t]),children:u}),jsxRuntime.jsxs("span",{className:g(p&&"truncate"),children:[e,s&&jsxRuntime.jsx("span",{className:"text-red-500 ml-0.5","aria-hidden":"true",children:l}),s&&jsxRuntime.jsx("span",{className:"sr-only",children:"(required)"})]}),i&&!s&&jsxRuntime.jsx("span",{className:"text-gray-400 dark:text-gray-500 font-normal",children:c}),f&&jsxRuntime.jsx("span",{className:g("shrink-0",qu[t]),children:f})]})}Zu.displayName="Label";var uv=2,mv=2,gv=12,pv=16,Qu="cell:",Ju=false,fv=el.memo(function({cells:t,radius:r}){return jsxRuntime.jsx("g",{children:t.map(n=>jsxRuntime.jsxs("g",{children:[jsxRuntime.jsx("rect",{x:n.x,y:n.y,width:n.width,height:n.height,rx:r,fill:n.missing?void 0:n.color,className:n.missing?"fill-gray-100 dark:fill-gray-800":void 0}),n.label?jsxRuntime.jsx("text",{x:n.x+n.width/2,y:n.y+n.height/2,textAnchor:"middle",dominantBaseline:"central",className:g("text-[10px] [font-variant-numeric:tabular-nums]",n.onDark?"fill-gray-50 dark:fill-gray-900":"fill-gray-900 dark:fill-gray-50"),children:n.label}):null]},n.key))})});function hv({width:e,height:t,columns:r,rows:n,lookup:o,colorScale:a,x:s,y:l,size:i,cellGap:c,cellRadius:d,showValues:u,tooltip:f,plotLabel:m,formatValue:p,formatX:w,formatY:v,onCellClick:x}){let[h,I]=el.useState(null),S=el.useMemo(()=>{let k=r.map((D,V)=>w(D,V)),z=n.map((D,V)=>v(D,V)),H={top:8,right:8,bottom:s.hidden?8:s.height??24+(s.label?16:0),left:l.hidden?8:l.height??wr(z)+gv+(l.label?16:0)},P=Math.max(0,e-H.left-H.right),B=Math.max(0,t-H.top-H.bottom),C=xn(r.map((D,V)=>V),[0,P],{paddingInner:0,paddingOuter:0}),b=xn(n.map((D,V)=>V),[0,B],{paddingInner:0,paddingOuter:0}),E=Math.max(0,C.bandwidth-c),N=Math.max(0,b.bandwidth-c),W=[];n.forEach((D,V)=>{r.forEach((O,_)=>{let G=o.get(`${ft(O)}|${ft(D)}`)?.value??null,$=null;if(u&&G!==null&&N>=pv){let Y=p(G);tr(Y,10)+6<=E&&($=Y);}W.push({key:`${_}-${V}`,column:_,row:V,x:C(_)+c/2,y:b(V)+c/2,width:E,height:N,color:G===null?"transparent":a(G),label:$,onDark:G!==null&&a.onDark(G),missing:G===null});});});let F=ha(k.length,P,wr(k)),K=ha(z.length,B,15),j=s.hidden?[]:k.map((D,V)=>({value:r[V],offset:C.center(V),label:D})).filter((D,V)=>V%F===0),A=l.hidden?[]:z.map((D,V)=>({value:n[V],offset:b.center(V),label:D})).filter((D,V)=>V%K===0);return {margin:H,innerWidth:P,innerHeight:B,columnScale:C,rowScale:b,cells:W,columnTicks:j,rowTicks:A}},[r,n,o,a,s,l,e,t,c,u,p,w,v]),L=el.useCallback((k,z)=>{let H=r[k],P=n[z],B=o.get(`${ft(H)}|${ft(P)}`),C=B?.value??null;return {x:H,y:P,xLabel:w(H,k),yLabel:v(P,z),value:C,formattedValue:C===null?"\u2014":p(C),color:C===null?"transparent":a(C),datum:B?.datum}},[r,n,o,a,p,w,v]),R=el.useCallback(k=>{if(f===false||r.length===0||n.length===0)return;let z=k.currentTarget.getBoundingClientRect(),H=k.clientX-z.left-S.margin.left,P=k.clientY-z.top-S.margin.top,B=Math.floor(H/(S.columnScale.step||1)),C=Math.floor(P/(S.rowScale.step||1));if(B<0||B>=r.length||C<0||C>=n.length){I(null);return}I(b=>b?.column===B&&b.row===C?b:{column:B,row:C});},[f,r.length,n.length,S.margin,S.columnScale,S.rowScale]),T=el.useCallback(k=>{if(r.length===0||n.length===0)return;let z=h??{column:0,row:0},H;switch(k.key){case "ArrowRight":H={...z,column:Math.min(r.length-1,z.column+1)};break;case "ArrowLeft":H={...z,column:Math.max(0,z.column-1)};break;case "ArrowDown":H={...z,row:Math.min(n.length-1,z.row+1)};break;case "ArrowUp":H={...z,row:Math.max(0,z.row-1)};break;case "Home":H={...z,column:0};break;case "End":H={...z,column:r.length-1};break;case "Escape":H=null;break;default:H=void 0;}H!==void 0&&(k.preventDefault(),I(H));},[r.length,n.length,h]),y=el.useCallback(()=>{!x||!h||x(L(h.column,h.row));},[x,h,L]),M=h?L(h.column,h.row):null;return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsxs("svg",{width:e,height:t,role:"img","aria-label":m??`${s.label??s.key} / ${l.label??l.key}`,tabIndex:0,className:"touch-none focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-blue-500",onPointerMove:R,onPointerLeave:()=>I(null),onKeyDown:T,onBlur:()=>I(null),onClick:y,children:[jsxRuntime.jsxs("g",{transform:`translate(${S.margin.left}, ${S.margin.top})`,children:[jsxRuntime.jsx(fv,{cells:S.cells,radius:d}),h?jsxRuntime.jsx("rect",{x:S.columnScale(h.column)+c/2,y:S.rowScale(h.row)+c/2,width:Math.max(0,S.columnScale.bandwidth-c),height:Math.max(0,S.rowScale.bandwidth-c),rx:d,fill:"none",strokeWidth:2,className:"stroke-gray-900 dark:stroke-white","aria-hidden":"true"}):null]}),jsxRuntime.jsx("g",{transform:`translate(${S.margin.left}, ${S.margin.top+S.innerHeight})`,children:s.hidden?null:jsxRuntime.jsx(Ue,{orientation:"bottom",ticks:S.columnTicks,length:S.innerWidth,showLine:false,tickSize:0,label:s.label,size:i})}),jsxRuntime.jsx("g",{transform:`translate(${S.margin.left}, ${S.margin.top})`,children:l.hidden?null:jsxRuntime.jsx(Ue,{orientation:"left",ticks:S.rowTicks,length:S.innerHeight,showLine:false,tickSize:0,label:l.label,size:i})})]}),h&&M&&f!==false?jsxRuntime.jsx(dt,{x:S.margin.left+S.columnScale.center(h.column),y:S.margin.top+S.rowScale.center(h.row),containerWidth:e,children:typeof f=="function"?f(M):jsxRuntime.jsxs("div",{className:"flex flex-col gap-1",children:[jsxRuntime.jsxs("div",{className:"font-medium text-gray-900 dark:text-gray-100",children:[M.yLabel," \xB7 ",M.xLabel]}),jsxRuntime.jsxs("div",{className:"flex items-center gap-2",children:[jsxRuntime.jsx("span",{className:"h-2.5 w-2.5 shrink-0 rounded-sm",style:{backgroundColor:M.color},"aria-hidden":"true"}),jsxRuntime.jsx("span",{className:"font-semibold text-gray-900 [font-variant-numeric:tabular-nums] dark:text-gray-100",children:M.formattedValue})]})]})}):null]})}function em(e,t,r){if(r)return r;let n=new Map;return e.forEach((o,a)=>{let s=ct(o,t,a),l=ft(s);n.has(l)||n.set(l,s);}),[...n.values()]}function bv({data:e,x:t,y:r,value:n,format:o,domain:a,scale:s="sequential",center:l=0,steps:i,colors:c,xDomain:d,yDomain:u,cellGap:f=uv,cellRadius:m=mv,showValues:p=false,height:w=280,width:v,size:x="md",legend:h=true,legendLabel:I,tooltip:S=true,tableView:L=false,title:R,description:T,loading:y=false,emptyState:M,locale:k,plotLabel:z,onCellClick:H,className:P,...B}){i!==void 0&&i>ys&&!Ju&&(Ju=true,console.warn(`[@synertech/ui] A Heatmap was cut into ${i} colour classes. Past ${ys} two neighbouring cells stop being tellable apart: leave \`steps\` unset and let the ramp stay continuous.`));let C=el.useMemo(()=>em(e,t.key,d),[e,t.key,d]),b=el.useMemo(()=>em(e,r.key,u),[e,r.key,u]),E=el.useMemo(()=>{let O=new Map;return e.forEach((_,X)=>{let G=Ee(_,n);if(G===null)return;let $=ct(_,t.key,X),Y=ct(_,r.key,X);O.set(`${ft($)}|${ft(Y)}`,{value:G,datum:_});}),O},[e,t.key,r.key,n]),N=el.useMemo(()=>o??(O=>nt(O,k)),[o,k]),W=el.useMemo(()=>t.format??(O=>Ze(O,k)),[t.format,k]),F=el.useMemo(()=>r.format??(O=>Ze(O,k)),[r.format,k]),K=el.useMemo(()=>{let O=a??Yt([...E.values()].map(_=>_.value))??[0,1];return s==="diverging"?Mo(O,{center:l,steps:i,colors:c}):va(O,{steps:i,colors:c})},[a,E,s,l,i,c]),j=el.useMemo(()=>b.map(O=>{let _={[r.key]:O};return C.forEach(X=>{_[`${Qu}${ft(X)}`]=E.get(`${ft(X)}|${ft(O)}`)?.value??null;}),_}),[b,C,E,r.key]),A=el.useMemo(()=>C.map((O,_)=>({key:`${Qu}${ft(O)}`,label:W(O,_)})),[C,W]),D=h!==false,V=typeof h=="string"?h:"bottom";return jsxRuntime.jsx(lt,{title:R,description:T,height:w,width:v,size:x,loading:y,empty:E.size===0,emptyState:M,tableView:L,legendPosition:V,legend:D?jsxRuntime.jsx(Ra,{scale:K,label:I,format:N,size:x,locale:k}):void 0,table:L?jsxRuntime.jsx(zt,{data:j,series:A,xKey:r.key,xLabel:r.label??r.key,formatX:F,formatValue:N,caption:typeof R=="string"?R:void 0}):void 0,className:P,...B,children:({width:O})=>jsxRuntime.jsx(hv,{width:O,height:w,columns:C,rows:b,lookup:E,colorScale:K,x:t,y:r,size:x,cellGap:f,cellRadius:m,showValues:p,tooltip:S,plotLabel:z,formatValue:N,formatX:W,formatY:F,onCellClick:H})})}var vv=24,Cv=10,kv=10,wv=el.memo(function({lines:t,showMarkers:r}){return jsxRuntime.jsx("g",{children:t.map(n=>jsxRuntime.jsxs("g",{children:[n.solid?jsxRuntime.jsx("path",{d:n.solid,fill:"none",stroke:n.color,strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"}):null,n.dashed?jsxRuntime.jsx("path",{d:n.dashed,fill:"none",stroke:n.color,strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round",strokeDasharray:"5 4"}):null,r?n.markers.map(o=>jsxRuntime.jsx("circle",{cx:o.x,cy:o.y,r:3,fill:n.color,strokeWidth:2,className:"stroke-white dark:stroke-gray-800"},`${o.x}-${o.y}`)):null]},n.key))})});function Nv({width:e,height:t,data:r,resolvedSeries:n,x:o,y:a,grid:s,size:l,curve:i,forecastFrom:c,forecastLabel:d,markers:u,connectNulls:f,referenceLines:m,annotations:p,annotationsLabel:w,margin:v,tooltip:x,onPointClick:h,plotLabel:I,formatValue:S,formatX:L}){let[R,T]=el.useState(null),y=el.useMemo(()=>{let b=n.filter(A=>!A.hidden),E=rr({width:e,height:t,data:r,x:o,y:a,bounds:Yt(fr(r,b.map(A=>A.key))),margin:v,placement:"point",formatValue:S,formatX:L,extraTop:d?Cv:0}),N=E.categoryCenters,W=E.valueScale,F=c===void 0?-1:E.xValues.findIndex(A=>ft(A)===ft(c)),K=b.map(A=>{let D=r.map((_,X)=>{let G=Ee(_,A.key);return {x:N[X],y:G===null?Number.NaN:W(G),defined:G!==null}}),V={connectNulls:f},O=F>=0;return {key:A.key,color:A.color,solid:A.dashed?"":Xr(O?D.slice(0,F+1):D,i,V),dashed:A.dashed?Xr(D,i,V):O?Xr(D.slice(F),i,V):"",markers:D.filter(_=>_.defined!==false)}}),j=r.length>1?E.innerWidth/(r.length-1):0;return {visible:b,locate:zo(E),xValues:E.xValues,xPositions:N,xTicks:E.categoryTicks,yTicks:E.valueTicks,yScale:W,innerWidth:E.innerWidth,innerHeight:E.innerHeight,margin:E.margin,lines:K,forecastIndex:F,showMarkers:u==="always"||u==="auto"&&j>=vv&&r.length>1}},[r,n,o,a,e,t,v,i,f,c,d,u,S,L]),M=el.useCallback(b=>y.visible.map(E=>{let N=Ee(r[b],E.key);return {seriesKey:E.key,seriesLabel:Kt(E),color:E.color,value:N,formattedValue:N===null?"\u2014":S(N),datum:r[b]}}),[r,y.visible,S]),k=el.useCallback(b=>{if(x===false||r.length===0)return;let E=b.currentTarget.getBoundingClientRect(),N=b.clientX-E.left-y.margin.left,W=Vt(y.xPositions,N);T(W>=0?W:null);},[x,r.length,y.margin.left,y.xPositions]),z=el.useCallback(b=>{if(r.length===0)return;let E=r.length-1,N=R??0,W=b.key==="ArrowRight"?Math.min(E,N+1):b.key==="ArrowLeft"?Math.max(0,N-1):b.key==="Home"?0:b.key==="End"?E:b.key==="Escape"?null:void 0;W!==void 0&&(b.preventDefault(),T(W));},[r.length,R]),H=el.useCallback(()=>{if(!h||R===null)return;let[b]=M(R);b&&h({...b,index:R,x:y.xValues[R]});},[h,R,M,y.xValues]),P=R===null?null:M(R),B=(P??[]).filter(b=>b.value!==null),C=R===null||P===null?null:{x:y.xValues[R],xLabel:L(y.xValues[R],R),index:R,points:P};return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsxs("svg",{width:e,height:t,role:"img","aria-label":I??[y.visible.map(b=>Kt(b)).join(", "),Jn(p,w)].filter(Boolean).join(". "),tabIndex:0,className:"touch-none focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-blue-500",onPointerMove:k,onPointerLeave:()=>T(null),onKeyDown:z,onBlur:()=>T(null),onClick:H,children:[jsxRuntime.jsxs("g",{transform:`translate(${y.margin.left}, ${y.margin.top})`,children:[jsxRuntime.jsx(_t,{width:y.innerWidth,height:y.innerHeight,horizontal:s==="y"||s==="both"?y.yTicks.map(b=>b.offset):void 0,vertical:s==="x"||s==="both"?y.xTicks.map(b=>b.offset):void 0}),p?jsxRuntime.jsx(tn,{layer:"under",annotations:p,xAt:y.locate,yAt:y.yScale,width:y.innerWidth,height:y.innerHeight}):null,m?.map(b=>{let E=y.yScale(b.value),N=E<kv?E+12:E-4;return jsxRuntime.jsxs("g",{children:[jsxRuntime.jsx("line",{x1:0,y1:E,x2:y.innerWidth,y2:E,stroke:b.color??"var(--color-chart-muted)",strokeWidth:1,strokeDasharray:b.dashed===false?void 0:"4 4"}),b.label?jsxRuntime.jsx("text",{x:y.innerWidth,y:N,textAnchor:"end",className:"fill-gray-500 text-[10px] dark:fill-gray-400",children:b.label}):null]},`${b.value}-${b.label??""}`)}),y.forecastIndex>=0?jsxRuntime.jsxs("g",{children:[jsxRuntime.jsx("line",{x1:y.xPositions[y.forecastIndex],y1:0,x2:y.xPositions[y.forecastIndex],y2:y.innerHeight,className:"stroke-gray-300 dark:stroke-gray-600",strokeWidth:1,strokeDasharray:"3 3"}),d?jsxRuntime.jsx("text",{x:y.xPositions[y.forecastIndex]+4,y:-2,className:"fill-gray-500 text-[10px] dark:fill-gray-400",children:d}):null]}):null,jsxRuntime.jsx(wv,{lines:y.lines,showMarkers:y.showMarkers}),p?jsxRuntime.jsx(tn,{annotations:p,xAt:y.locate,yAt:y.yScale,width:y.innerWidth,height:y.innerHeight}):null,R!==null?jsxRuntime.jsxs("g",{"aria-hidden":"true",children:[jsxRuntime.jsx("line",{x1:y.xPositions[R],y1:0,x2:y.xPositions[R],y2:y.innerHeight,className:"stroke-gray-400 dark:stroke-gray-500",strokeWidth:1}),B.map(b=>jsxRuntime.jsx("circle",{cx:y.xPositions[R],cy:y.yScale(b.value),r:4,fill:b.color,strokeWidth:2,className:"stroke-white dark:stroke-gray-800"},b.seriesKey))]}):null]}),jsxRuntime.jsx("g",{transform:`translate(${y.margin.left}, ${y.margin.top+y.innerHeight})`,children:o.hidden?null:jsxRuntime.jsx(Ue,{orientation:"bottom",ticks:y.xTicks,length:y.innerWidth,label:o.label,size:l})}),jsxRuntime.jsx("g",{transform:`translate(${y.margin.left}, ${y.margin.top})`,children:a?.hidden?null:jsxRuntime.jsx(Ue,{orientation:"left",ticks:y.yTicks,length:y.innerHeight,showLine:false,label:a?.label,size:l})})]}),C&&x!==false?jsxRuntime.jsx(dt,{x:y.margin.left+y.xPositions[C.index],y:y.margin.top+(B.length>0?Math.min(...B.map(b=>y.yScale(b.value))):y.innerHeight/2),containerWidth:e,children:typeof x=="function"?x(C):jsxRuntime.jsx(Nr,{title:C.xLabel,points:C.points})}):null]})}function Sv({data:e,series:t,x:r,y:n,height:o=240,width:a,size:s="md",grid:l="y",legend:i,tooltip:c=true,tableView:d=false,emphasis:u,title:f,description:m,loading:p=false,emptyState:w,onPointClick:v,curve:x="monotone",forecastFrom:h,forecastLabel:I,markers:S="auto",connectNulls:L=false,referenceLines:R,annotations:T,legendToggle:y=true,margin:M,locale:k,plotLabel:z,className:H,...P}){let B=We(),[C,b]=el.useState(()=>new Set),E=el.useMemo(()=>t.map((D,V)=>({...D,hidden:D.hidden||C.has(D.key),color:Lr(D,V,u)})),[t,C,u]),N=el.useMemo(()=>n?.format??(D=>nt(D,k)),[n?.format,k]),W=el.useMemo(()=>r.format??(D=>r.scale==="time"?Ze(D instanceof Date?D:new Date(_r(D)),k):Ze(D,k)),[r.format,r.scale,k]),F=el.useCallback(D=>{b(V=>{let O=new Set(V);return O.has(D)?O.delete(D):O.add(D),O});},[]),K=i===void 0?t.length>=2:i!==false,j=typeof i=="string"?i:"bottom",A=E.filter(D=>!D.hidden).length;return jsxRuntime.jsx(lt,{title:f,description:m,height:o,width:a,size:s,loading:p,empty:e.length===0||A===0,emptyState:w,tableView:d,legendPosition:j,legend:K?jsxRuntime.jsx(Xt,{items:$r(E,u),position:j,marker:"line",size:s,onToggle:y?F:void 0}):void 0,table:d?jsxRuntime.jsx(zt,{data:e,series:E,xKey:r.key,xLabel:r.label??r.key,formatX:W,formatValue:N,caption:typeof f=="string"?f:void 0}):void 0,className:H,...P,children:({width:D})=>jsxRuntime.jsx(Nv,{width:D,height:o,data:e,resolvedSeries:E,x:r,y:n,grid:l,size:s,curve:x,forecastFrom:h,forecastLabel:I,markers:S,connectNulls:L,referenceLines:R,annotations:T,annotationsLabel:B.chartAnnotations,margin:M,tooltip:c,onPointClick:v,plotLabel:z,formatValue:N,formatX:W})})}var Lv={sm:"max-w-sm",md:"max-w-2xl",lg:"max-w-4xl",xl:"max-w-6xl",full:"max-w-full"},Ln=el.forwardRef(({isOpen:e,onClose:t,title:r="Modal Title",children:n,buttonLabel:o,onButtonClick:a,className:s,allowFullScreen:l=false,showSubmit:i=true,submitLabel:c,onSubmitClick:d,showCancel:u=false,cancelLabel:f,onCancelClick:m,buttonsPosition:p="right",showHeaderDivider:w=true,showFooterDivider:v=true,description:x,icon:h,size:I="md",reverseButtons:S=false,headerClassName:L,contentClassName:R,footerClassName:T,titleClassName:y,descriptionClassName:M,submitClassName:k,cancelClassName:z,closeLabel:H,enterFullScreenLabel:P,exitFullScreenLabel:B,"aria-label":C,closeOnEscape:b=true,trapFocus:E=true,initialFocus:N,returnFocus:W,lockScroll:F=true},K)=>{let[j,A]=el.useState(false),D=We(),V=el.useId(),O=`${V}-title`,_=`${V}-description`,{dialogRef:X,dialogProps:G}=fo({open:e,onClose:t,closeOnEscape:b,trapFocus:E,initialFocus:N,returnFocus:W,lockScroll:F});if(!e)return null;let $=o??c??D.confirm,Y=f??D.cancel,se=H??D.closeModal,ae=j?B??D.exitFullScreen:P??D.enterFullScreen,U=a??d,Q=async()=>{U&&await U(),t();},le=async()=>{m&&await m(),t();};return jsxRuntime.jsx("div",{className:g("overflow-y-auto overflow-x-hidden fixed inset-0 z-50 flex items-center justify-center bg-black/30 backdrop-blur-sm",s),"aria-hidden":!e,children:jsxRuntime.jsx("div",{className:g("relative p-4 w-full max-h-full transition-all duration-300",j?"max-w-full h-full p-0":Lv[I]),ref:K,children:jsxRuntime.jsxs("div",{...G,ref:X,"aria-labelledby":r?O:void 0,"aria-label":r?void 0:C,"aria-describedby":x?_:void 0,className:g("relative bg-white shadow dark:bg-gray-700 border-b-4 transition-all duration-300 focus:outline-none",j?"rounded-none h-full flex flex-col":"rounded-lg"),children:[jsxRuntime.jsxs("div",{className:g("flex items-center justify-between p-4 md:p-5 rounded-t",w&&"border-b border-gray-200 dark:border-gray-600",L),children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-3",children:[h&&jsxRuntime.jsx("div",{className:"shrink-0 text-gray-500 dark:text-gray-400",children:h}),jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("h3",{id:O,className:g("text-xl font-semibold text-gray-900 dark:text-white",y),children:r}),x&&jsxRuntime.jsx("p",{id:_,className:g("mt-1 text-sm text-gray-500 dark:text-gray-400",M),children:x})]})]}),jsxRuntime.jsxs("div",{className:"flex items-center gap-1 ms-auto",children:[l&&jsxRuntime.jsx("button",{type:"button",onClick:()=>A(ye=>!ye),className:"text-gray-400 bg-transparent hover:bg-gray-200 hover:text-gray-900 rounded-lg text-sm w-8 h-8 inline-flex justify-center items-center dark:hover:bg-gray-600 dark:hover:text-white","aria-label":ae,children:j?jsxRuntime.jsx("svg",{className:"w-3.5 h-3.5","aria-hidden":"true",xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 18 18",children:jsxRuntime.jsx("path",{stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",d:"M7 1H1v6m16 0V1h-6m0 16h6v-6M1 11v6h6"})}):jsxRuntime.jsx("svg",{className:"w-3.5 h-3.5","aria-hidden":"true",xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 18 18",children:jsxRuntime.jsx("path",{stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",d:"M11 1h6v6M1 11v6h6m0-12L1 1m16 16-6-6"})})}),jsxRuntime.jsxs("button",{type:"button",onClick:t,className:"text-gray-400 bg-transparent hover:bg-gray-200 hover:text-gray-900 rounded-lg text-sm w-8 h-8 inline-flex justify-center items-center dark:hover:bg-gray-600 dark:hover:text-white",children:[jsxRuntime.jsx("svg",{className:"w-3 h-3","aria-hidden":"true",xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 14 14",children:jsxRuntime.jsx("path",{stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",d:"m1 1 6 6m0 0 6 6M7 7l6-6M7 7l-6 6"})}),jsxRuntime.jsx("span",{className:"sr-only",children:se})]})]})]}),jsxRuntime.jsx("div",{className:g("p-4 md:p-5 space-y-4",j&&"flex-1 overflow-y-auto",R),children:n}),(i||u)&&jsxRuntime.jsxs("div",{className:g("flex items-center gap-2 p-4 md:p-5 rounded-b",v&&"border-t border-gray-200 dark:border-gray-600",p==="right"?"justify-end":p==="center"?"justify-center":"justify-start",S&&"flex-row-reverse",T),children:[u&&jsxRuntime.jsx("button",{type:"button",onClick:le,className:g("text-gray-500 bg-white hover:bg-gray-100 focus:ring-4 focus:outline-none focus:ring-gray-200 font-medium rounded-lg text-sm px-5 py-2.5 border border-gray-200 dark:bg-gray-700 dark:text-gray-300 dark:border-gray-500 dark:hover:bg-gray-600 dark:hover:text-white",z),children:Y}),i&&jsxRuntime.jsx("button",{type:"button",onClick:Q,className:g("text-white bg-blue-600 hover:bg-blue-700 focus:ring-4 focus:outline-none focus:ring-blue-300 font-medium rounded-lg text-sm px-5 py-2.5 text-center dark:bg-blue-500 dark:hover:bg-blue-600",k),children:$})]})]})})})});Ln.displayName="Modal";function Iv(e,t,r,n){let o=r*2+1+n*2+2;if(t<=o)return Array.from({length:t},(f,m)=>m+1);let a=Array.from({length:n},(f,m)=>m+1).filter(f=>f<=t),s=Array.from({length:n},(f,m)=>t-n+1+m).filter(f=>f>=1),l=Math.max(e-r,n+1),i=Math.min(e+r,t-n),c=l>n+2,d=i<t-n-1,u=[];for(let f of a)u.push(f);if(c)u.push("ellipsis");else for(let f=n+1;f<l;f++)u.push(f);for(let f=l;f<=i;f++)u.push(f);if(d)u.push("ellipsis");else for(let f=i+1;f<=t-n;f++)u.push(f);for(let f of s)u.includes(f)||u.push(f);return u}function Av({className:e}){return jsxRuntime.jsx("svg",{className:e,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24","aria-hidden":"true",children:jsxRuntime.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M15 19l-7-7 7-7"})})}function zv({className:e}){return jsxRuntime.jsx("svg",{className:e,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24","aria-hidden":"true",children:jsxRuntime.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 5l7 7-7 7"})})}function Wv({className:e}){return jsxRuntime.jsx("svg",{className:e,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24","aria-hidden":"true",children:jsxRuntime.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M11 19l-7-7 7-7M18 19l-7-7 7-7"})})}function Hv({className:e}){return jsxRuntime.jsx("svg",{className:e,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24","aria-hidden":"true",children:jsxRuntime.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M13 5l7 7-7 7M6 5l7 7-7 7"})})}var Bv={sm:{button:"h-7 min-w-7 px-1.5 text-xs",icon:"h-3 w-3",gap:"gap-0.5",text:"text-xs"},md:{button:"h-9 min-w-9 px-2.5 text-sm",icon:"h-4 w-4",gap:"gap-1",text:"text-sm"},lg:{button:"h-11 min-w-11 px-3.5 text-base",icon:"h-5 w-5",gap:"gap-1.5",text:"text-base"}},Vv={default:{base:"rounded-md font-medium transition-colors",idle:"text-gray-700 hover:bg-gray-100 dark:text-gray-300 dark:hover:bg-gray-700",active:"bg-blue-600 text-white hover:bg-blue-700 dark:bg-blue-500 dark:hover:bg-blue-600",disabled:"text-gray-300 cursor-not-allowed dark:text-gray-600"},outlined:{base:"rounded-md border font-medium transition-colors",idle:"border-gray-300 text-gray-700 hover:bg-gray-50 dark:border-gray-600 dark:text-gray-300 dark:hover:bg-gray-800",active:"border-blue-600 bg-blue-50 text-blue-600 hover:bg-blue-100 dark:border-blue-400 dark:bg-blue-900/30 dark:text-blue-400 dark:hover:bg-blue-900/50",disabled:"border-gray-200 text-gray-300 cursor-not-allowed dark:border-gray-700 dark:text-gray-600"},minimal:{base:"rounded-md font-medium transition-colors",idle:"text-gray-600 hover:text-gray-900 dark:text-gray-400 dark:hover:text-gray-200",active:"text-blue-600 font-semibold hover:text-blue-700 dark:text-blue-400 dark:hover:text-blue-300",disabled:"text-gray-300 cursor-not-allowed dark:text-gray-600"}};function Fv({page:e,totalPages:t,onPageChange:r,size:n="md",variant:o="default",showFirstLast:a=false,siblings:s=1,boundaries:l=1,disabled:i=false,labels:c,totalItems:d,pageSize:u,pageSizeOptions:f,onPageSizeChange:m,className:p,...w}){let v=Bv[n],x=Vv[o],h=el.useMemo(()=>Iv(e,t,s,l),[e,t,s,l]),I=el.useCallback(k=>{i||k<1||k>t||k===e||r(k);},[i,t,e,r]),S=e<=1,L=e>=t,R=g("inline-flex items-center justify-center select-none",v.button,x.base),T=(k,z,H,P)=>jsxRuntime.jsx("button",{type:"button",onClick:k,disabled:i||z,"aria-label":H,"aria-disabled":i||z,className:g(R,i||z?x.disabled:x.idle),children:P}),y=d!==void 0&&u?(e-1)*u+1:void 0,M=d!==void 0&&u?Math.min(e*u,d):void 0;return jsxRuntime.jsxs("nav",{"aria-label":"Pagination",className:g("flex items-center",v.gap,p),...w,children:[d!==void 0&&u&&jsxRuntime.jsxs("span",{className:g("mr-2 text-gray-600 dark:text-gray-400 whitespace-nowrap",v.text),children:[y,"\u2013",M," of ",d]}),f&&f.length>0&&m&&jsxRuntime.jsxs("div",{className:g("mr-2 flex items-center whitespace-nowrap",v.gap,v.text),children:[jsxRuntime.jsx("label",{htmlFor:"pagination-page-size",className:"text-gray-600 dark:text-gray-400",children:"Rows:"}),jsxRuntime.jsx("select",{id:"pagination-page-size",value:u,onChange:k=>m(Number(k.target.value)),disabled:i,className:g("rounded border border-gray-300 bg-white px-1.5 py-0.5 dark:border-gray-600 dark:bg-gray-800 dark:text-gray-200",v.text,i&&"cursor-not-allowed opacity-50"),children:f.map(k=>jsxRuntime.jsx("option",{value:k,children:k},k))})]}),jsxRuntime.jsxs("div",{className:g("flex items-center",v.gap),children:[a&&T(()=>I(1),S,c?.first??"Go to first page",jsxRuntime.jsx(Wv,{className:v.icon})),T(()=>I(e-1),S,c?.previous??"Go to previous page",jsxRuntime.jsx(Av,{className:v.icon})),h.map((k,z)=>k==="ellipsis"?jsxRuntime.jsx("span",{className:g("inline-flex items-center justify-center select-none",v.button,"text-gray-400 dark:text-gray-500"),"aria-hidden":"true",children:"\u2026"},`ellipsis-${z}`):jsxRuntime.jsx("button",{type:"button",onClick:()=>I(k),disabled:i,"aria-current":k===e?"page":void 0,"aria-label":`Page ${k}`,className:g(R,k===e?x.active:i?x.disabled:x.idle),children:k},k)),T(()=>I(e+1),L,c?.next??"Go to next page",jsxRuntime.jsx(zv,{className:v.icon})),a&&T(()=>I(t),L,c?.last??"Go to last page",jsxRuntime.jsx(Hv,{className:v.icon}))]})]})}var _v=.62,Xv=2,Gv=3,Kv=.16,Uv=64,Yv=22,Xl=6,rm=false;function qv({width:e,height:t,slices:r,variant:n,innerRadius:o,showLabels:a,centerLabel:s,tooltip:l,patterns:i,patternBaseId:c,plotLabel:d,formatValue:u,onSliceClick:f}){let[m,p]=el.useState(null),w=el.useMemo(()=>{let y=a?Uv:8,M=a?Yv:8,k=Math.max(0,Math.min((e-y*2)/2,(t-M*2)/2));return {cx:e/2,cy:t/2,outerRadius:k,inner:n==="donut"?k*(o??_v):(o??0)*k,pad:k>0&&r.length>1?Xv/k/2:0}},[e,t,n,o,a,r.length]),{cx:v,cy:x,outerRadius:h,inner:I,pad:S}=w,L=el.useCallback(y=>{let M=(y.startAngle+y.endAngle)/2,k=Math.sin(M)>=0,z={x:v+Math.sin(M)*(h+4),y:x-Math.cos(M)*(h+4)},H={x:v+Math.sin(M)*(h+14),y:x-Math.cos(M)*(h+14)},P={x:k?H.x+10:H.x-10,y:H.y};return {from:z,elbow:H,end:P,anchor:k?"start":"end"}},[v,x,h]),R=el.useCallback(y=>{if(r.length===0)return;let M=r.length-1,k=m??0,z=y.key==="ArrowRight"||y.key==="ArrowDown"?Math.min(M,k+1):y.key==="ArrowLeft"||y.key==="ArrowUp"?Math.max(0,k-1):y.key==="Home"?0:y.key==="End"?M:y.key==="Escape"?null:void 0;z!==void 0&&(y.preventDefault(),p(z));},[r.length,m]),T=m===null?null:r[m];return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsxs("svg",{width:e,height:t,role:"img","aria-label":d??r.map(y=>y.label).join(", "),tabIndex:0,className:"touch-none focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-blue-500",onPointerLeave:()=>p(null),onBlur:()=>p(null),onKeyDown:R,children:[i?jsxRuntime.jsx(ro,{id:c,entries:r.map(y=>({slot:y.slot,color:y.color}))}):null,r.map((y,M)=>jsxRuntime.jsx("path",{d:sd({cx:v,cy:x,innerRadius:I,outerRadius:h+(m===M?Gv:0),startAngle:y.startAngle+S,endAngle:Math.max(y.startAngle+S,y.endAngle-S)}),fill:to(i,c,y.slot,y.color),onPointerEnter:()=>l===false?void 0:p(M),onClick:()=>f?.({key:y.key,label:y.label,value:y.value,share:y.share})},y.key)),a?r.filter(y=>y.endAngle-y.startAngle>=Kv).map(y=>{let{from:M,elbow:k,end:z,anchor:H}=L(y);return jsxRuntime.jsxs("g",{"aria-hidden":"true",children:[jsxRuntime.jsx("polyline",{points:`${M.x},${M.y} ${k.x},${k.y} ${z.x},${z.y}`,fill:"none",className:"stroke-gray-300 dark:stroke-gray-600",strokeWidth:1}),jsxRuntime.jsx("text",{x:H==="start"?z.x+3:z.x-3,y:z.y,textAnchor:H,dominantBaseline:"middle",className:"fill-gray-600 text-[10px] dark:fill-gray-300",children:y.label})]},`label-${y.key}`)}):null,n==="donut"&&s?jsxRuntime.jsxs("g",{"aria-hidden":"true",children:[jsxRuntime.jsx("text",{x:v,y:x-(s.label?2:0),textAnchor:"middle",dominantBaseline:"middle",className:"fill-gray-900 text-lg font-semibold dark:fill-gray-100",children:s.value}),s.label?jsxRuntime.jsx("text",{x:v,y:x+14,textAnchor:"middle",dominantBaseline:"middle",className:"fill-gray-500 text-[10px] dark:fill-gray-400",children:s.label}):null]}):null]}),T&&l!==false?jsxRuntime.jsx(dt,{x:v+Math.sin((T.startAngle+T.endAngle)/2)*(h*.7),y:x-Math.cos((T.startAngle+T.endAngle)/2)*(h*.7),containerWidth:e,children:typeof l=="function"?l({seriesKey:T.key,seriesLabel:T.label,color:T.color,value:T.value,formattedValue:u(T.value),datum:{},share:T.share}):jsxRuntime.jsx(Nr,{title:T.label,points:[{seriesKey:T.key,seriesLabel:Ut(T.share),color:T.color,value:T.value,formattedValue:u(T.value),datum:{}}]})}):null]})}function jv({data:e,x:t,value:r,variant:n="pie",innerRadius:o,maxSlices:a=Xl,otherLabel:s,sort:l="desc",showLabels:i=true,centerLabel:c,patterns:d=false,height:u=260,width:f,size:m="md",legend:p,tooltip:w=true,tableView:v=false,title:x,description:h,loading:I=false,emptyState:S,locale:L,plotLabel:R,onSliceClick:T,className:y,...M}){let k=We(),z=el.useId(),H=el.useCallback(W=>nt(W,L),[L]),P=el.useCallback(W=>t.format?t.format(W,0):Ze(W,L),[t,L]),{slices:B,total:C,rows:b}=el.useMemo(()=>{let W=e.map((O,_)=>({key:String(ct(O,t.key,_)),label:P(ct(O,t.key,_)),value:Ee(O,r)??0,color:Dr(_),slot:_,datum:O})),F=l==="none"?W:[...W].sort((O,_)=>l==="asc"?O.value-_.value:_.value-O.value),K=F.slice(0,a),j=F.slice(a);j.length>0&&K.push({key:"__other__",label:s??k.chartOther,value:j.reduce((O,_)=>O+_.value,0),color:Pr,slot:-1,datum:{}}),K.length>Xl&&!rm&&(rm=true,console.warn(`[@synertech/ui] A PieChart is drawing ${K.length} slices. Past ${Xl} the slices stop being tellable apart: lower \`maxSlices\`, or use a BarChart, which compares lengths rather than angles.`));let A=K.reduce((O,_)=>O+Math.max(0,_.value),0),D=0;return {slices:K.map(O=>{let _=A===0?0:Math.max(0,O.value)/A,X=D;return D+=_*Math.PI*2,{...O,share:_,startAngle:X,endAngle:D}}),total:A,rows:K.map(O=>({[t.key]:O.label,[r]:O.value}))}},[e,t.key,r,l,a,s,k.chartOther,P]),E=p===void 0?true:p!==false,N=typeof p=="string"?p:"bottom";return jsxRuntime.jsx(lt,{title:x,description:h,height:u,width:f,size:m,loading:I,empty:B.length===0||C===0,emptyState:S,tableView:v,legendPosition:N,legend:E?jsxRuntime.jsx(Xt,{items:B.map(W=>({key:W.key,label:`${W.label} \xB7 ${Ut(W.share)}`,color:W.color,...d?{pattern:W.slot}:{}})),position:N,marker:"rect",size:m}):void 0,table:v?jsxRuntime.jsx(zt,{data:b,series:[{key:r,label:t.label??r}],xKey:t.key,xLabel:t.label??t.key,formatValue:H,caption:typeof x=="string"?x:void 0}):void 0,className:y,...M,children:({width:W})=>jsxRuntime.jsx(qv,{width:W,height:u,slices:B,variant:n,innerRadius:o,showLabels:i,centerLabel:c,tooltip:w,patterns:d,patternBaseId:z,plotLabel:R,formatValue:H,onSliceClick:T})})}var Qv={xs:"h-1",sm:"h-1.5",md:"h-2.5",lg:"h-4",xl:"h-6"},Jv={default:"bg-gray-500 dark:bg-gray-400",primary:"bg-blue-600 dark:bg-blue-500",success:"bg-green-600 dark:bg-green-500",warning:"bg-yellow-500 dark:bg-yellow-400",error:"bg-red-600 dark:bg-red-500",info:"bg-cyan-600 dark:bg-cyan-500"},e1={default:"text-gray-700 dark:text-gray-300",primary:"text-blue-600 dark:text-blue-400",success:"text-green-600 dark:text-green-400",warning:"text-yellow-600 dark:text-yellow-400",error:"text-red-600 dark:text-red-400",info:"text-cyan-600 dark:text-cyan-400"},om="bg-[repeating-linear-gradient(45deg,transparent,transparent_10px,rgba(255,255,255,0.2)_10px,rgba(255,255,255,0.2)_20px)]",t1={default:"bg-gradient-to-r from-gray-400 to-gray-600",primary:"bg-gradient-to-r from-blue-400 to-blue-700",success:"bg-gradient-to-r from-green-400 to-green-700",warning:"bg-gradient-to-r from-yellow-300 to-yellow-600",error:"bg-gradient-to-r from-red-400 to-red-700",info:"bg-gradient-to-r from-cyan-400 to-cyan-700"};function sm({value:e=0,indeterminate:t=false,size:r="md",color:n="primary",variant:o="default",showValue:a=false,valueFormat:s,label:l,animated:i=true,className:c,...d}){let u=Math.min(100,Math.max(0,e)),f=o==="gradient"?t1[n]:Jv[n],m=s?s(u):`${Math.round(u)}%`;return jsxRuntime.jsxs("div",{className:g("w-full",c),...d,children:[(l||a)&&jsxRuntime.jsxs("div",{className:"flex items-center justify-between mb-1",children:[l&&jsxRuntime.jsx("span",{className:"text-sm font-medium text-gray-700 dark:text-gray-300",children:l}),a&&!t&&jsxRuntime.jsx("span",{className:g("text-sm font-semibold",e1[n],!l&&"ml-auto"),children:m})]}),jsxRuntime.jsx("div",{role:"progressbar","aria-valuenow":t?void 0:u,"aria-valuemin":0,"aria-valuemax":100,"aria-label":l,className:g("relative w-full overflow-hidden rounded-full bg-gray-200 dark:bg-gray-700",Qv[r]),children:t?jsxRuntime.jsx("div",{className:g("absolute h-full w-1/3 rounded-full",f,o==="striped"&&om,"animate-[progress-indeterminate_1.5s_ease-in-out_infinite]")}):jsxRuntime.jsx("div",{className:g("h-full rounded-full",f,o==="striped"&&om,i&&"transition-[width] duration-300 ease-out"),style:{width:`${u}%`}})})]})}sm.displayName="ProgressBar";var a1=e=>({sm:"w-4 h-4",md:"w-5 h-5",lg:"w-6 h-6"})[e],s1=e=>({sm:"w-2 h-2",md:"w-2.5 h-2.5",lg:"w-3 h-3"})[e],i1=(e,t,r,n,o,a,s,l)=>{if(t)return g("border-2",n?"":"border-red-500",r&&!o?"bg-red-500":"");switch(e){case "filled":return g("border-2",l?"":"border-gray-300 dark:border-gray-600",r?a?"":"bg-blue-600 border-blue-600 dark:bg-blue-500 dark:border-blue-500":s?"":"bg-gray-200 border-gray-200 dark:bg-gray-700 dark:border-gray-700");case "outlined":return g("border-[3px]",l?"":r?"border-blue-600 dark:border-blue-500":"border-gray-300 dark:border-gray-600","bg-white dark:bg-gray-800");default:return g("border-2",l?"":r?"border-blue-600 dark:border-blue-500":"border-gray-300 dark:border-gray-600","bg-white dark:bg-gray-800")}},l1={},im=el.forwardRef(({label:e,description:t,value:r,checked:n,defaultChecked:o=false,onCheckedChange:a,size:s="md",variant:l="default",labelPosition:i="right",error:c=false,disabled:d=false,readOnly:u=false,required:f=false,checkedColor:m,uncheckedColor:p,borderColor:w,labelColor:v,errorColor:x,dotColor:h,hoverColor:I,focusRingColor:S,showFocusRing:L=true,className:R,containerClassName:T,...y},M)=>{let[k,z]=el.useState(o),H=n!==void 0,P=H?n:k,B=el.useId(),C=typeof c=="string"?c:void 0,b=!!c,E=_=>{if(d||u)return;let X=_.target.checked;H||z(X),a?.(X);},N=el.useMemo(()=>i1(l,b,P,x,h,m,p,w),[l,b,P,x,h,m,p,w]),W=el.useMemo(()=>{let _={};return m&&P&&(_.backgroundColor=m,_.borderColor=m),p&&!P&&(_.backgroundColor=p),w&&(_.borderColor=w),_},[m,p,w,P]),F=el.useMemo(()=>h?{backgroundColor:h}:{},[h]),K=el.useMemo(()=>v?{color:v}:{},[v]),j=el.useMemo(()=>x?{color:x}:{},[x]),A=v?"":"text-gray-700 dark:text-gray-200",D=x?"":"text-red-500",V=I?"":"hover:border-blue-500 dark:hover:border-blue-400",O=S?"":"focus-visible:ring-blue-500";return jsxRuntime.jsxs("div",{className:g("inline-flex flex-col",T),style:l1,children:[jsxRuntime.jsxs("label",{className:g("inline-flex items-center cursor-pointer",d&&"opacity-50 cursor-not-allowed",u&&"cursor-default",i==="left"&&"flex-row-reverse"),htmlFor:B,children:[jsxRuntime.jsxs("div",{className:"relative inline-flex items-center",children:[jsxRuntime.jsx("input",{ref:M,type:"radio",id:B,value:r,checked:P,onChange:E,disabled:d,readOnly:u,required:f,"aria-invalid":b,"aria-describedby":C?`${B}-error`:void 0,className:"sr-only peer",tabIndex:u?-1:void 0,...y}),jsxRuntime.jsx("div",{className:g("rounded-full transition-all duration-200",a1(s),N,!d&&!u&&V,!d&&!u&&L&&"peer-focus-visible:ring-2 ring-offset-2",!d&&!u&&L&&O,R),style:W,children:P&&jsxRuntime.jsx("div",{className:g("rounded-full absolute inset-0 m-auto transition-all duration-200",s1(s),h?"":l==="outlined"||l==="default"?"bg-blue-600 dark:bg-blue-500":"bg-white"),style:F})})]}),e&&jsxRuntime.jsxs("span",{className:g("select-none",i==="left"?"mr-2":"ml-2",A,d&&"opacity-50"),style:K,children:[e,f&&jsxRuntime.jsx("span",{className:"text-red-500 ml-1",children:"*"})]})]}),t&&!b&&jsxRuntime.jsx("p",{className:g("text-sm text-gray-500 dark:text-gray-400 mt-1",i==="left"?"text-right":"ml-7"),children:t}),C&&jsxRuntime.jsx("p",{id:`${B}-error`,className:g("text-sm mt-1",i==="left"?"text-right":"ml-7",D),style:j,children:C})]})});im.displayName="RadioButton";var Kl=()=>{},g1=[],p1=jsxRuntime.jsx("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none","aria-hidden":"true",className:"shrink-0",children:jsxRuntime.jsx("path",{d:"M4 6L8 10L12 6",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})}),f1=jsxRuntime.jsx("svg",{width:"14",height:"14",viewBox:"0 0 14 14",fill:"none","aria-hidden":"true",className:"shrink-0",children:jsxRuntime.jsx("path",{d:"M10.5 3.5L3.5 10.5M3.5 3.5L10.5 10.5",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})}),h1=jsxRuntime.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none","aria-hidden":"true",className:"shrink-0 animate-spin",children:[jsxRuntime.jsx("circle",{cx:"8",cy:"8",r:"6",stroke:"currentColor",strokeWidth:"2",strokeOpacity:"0.25"}),jsxRuntime.jsx("path",{d:"M14 8a6 6 0 00-6-6",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round"})]}),b1=jsxRuntime.jsx("svg",{width:"14",height:"14",viewBox:"0 0 14 14",fill:"none","aria-hidden":"true",className:"shrink-0",children:jsxRuntime.jsx("path",{d:"M11.5 3.5L5.5 10.5L2.5 7.5",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})}),ja={sm:{trigger:"h-8 px-2.5 text-xs gap-1.5",content:"text-xs",option:"px-2.5 py-1.5",searchInput:"px-2.5 py-1.5 text-xs"},md:{trigger:"h-10 px-3 text-sm gap-2",content:"text-sm",option:"px-3 py-2",searchInput:"px-3 py-2 text-sm"},lg:{trigger:"h-12 px-4 text-base gap-2.5",content:"text-base",option:"px-4 py-2.5",searchInput:"px-4 py-2.5 text-base"}},lm={default:{trigger:"border border-gray-300 bg-white dark:border-gray-600 dark:bg-gray-800",focus:"focus:ring-2 focus:ring-blue-500 focus:border-blue-500"},outlined:{trigger:"border-2 border-gray-300 bg-transparent dark:border-gray-600",focus:"focus:ring-2 focus:ring-blue-500 focus:border-blue-500"},filled:{trigger:"border border-transparent bg-gray-100 dark:bg-gray-700",focus:"focus:ring-2 focus:ring-blue-500 focus:border-blue-500"}};function _n(...e){let t="";for(let r=0;r<e.length;r++){let n=e[r];n&&(t&&(t+=" "),t+=n);}return t}function y1(e,t){if(!t)return e;let r=t.toLowerCase();return e.filter(n=>{if(n.label.toLowerCase().includes(r)||n.value.toLowerCase().includes(r))return true;if(n.keywords){for(let o of n.keywords)if(o.toLowerCase().includes(r))return true}return false})}var x1=el.memo(el.forwardRef(function({option:t,isSelected:r,isHighlighted:n,isDisabled:o,sizeKey:a,optionId:s,onClick:l,onMouseEnter:i,index:c},d){let u=()=>{o||l(t.value);},f=()=>{o||i(c);};return jsxRuntime.jsxs("div",{ref:d,id:s,role:"option","aria-selected":r,"aria-disabled":o||void 0,"data-highlighted":n||void 0,className:_n(ja[a].option,"flex items-center gap-2 cursor-pointer select-none transition-colors",n&&!o&&"bg-blue-50 dark:bg-blue-900/30",r&&!n&&"bg-gray-50 dark:bg-gray-700/50",o&&"opacity-50 cursor-not-allowed"),onClick:u,onMouseEnter:f,children:[t.icon?jsxRuntime.jsx("span",{className:"flex shrink-0 items-center",children:t.icon}):null,jsxRuntime.jsxs("span",{className:"flex flex-col min-w-0 flex-1",children:[jsxRuntime.jsx("span",{className:"truncate",children:t.label}),t.description?jsxRuntime.jsx("span",{className:"text-xs text-gray-500 dark:text-gray-400 truncate",children:t.description}):null]}),r?jsxRuntime.jsx("span",{className:"ml-auto text-blue-600 dark:text-blue-400",children:b1}):null]})}));function v1({options:e=g1,value:t,defaultValue:r,onValueChange:n,searchable:o=false,clearable:a=false,disabled:s=false,readOnly:l=false,loading:i=false,size:c="md",variant:d="default",placeholder:u="Select...",label:f,description:m,helperText:p,error:w,required:v=false,noOptionsText:x="No options",onSearchChange:h,name:I,className:S,triggerClassName:L,contentClassName:R,maxHeight:T=256}){let y=el.useId(),M=`${y}-label`,k=`${y}-trigger`,z=`${y}-listbox`,H=el.useRef(null),P=el.useRef(null),B=el.useRef(null),C=el.useRef([]),b=t!==void 0,[E,N]=el.useState(r??""),W=b?t:E,[F,K]=el.useState(false),[j,A]=el.useState(""),[D,V]=el.useState(-1),[O,_]=el.useState(null),X=el.useMemo(()=>o?y1(e,j):e,[e,j,o]),G=el.useMemo(()=>e.find(re=>re.value===W)??null,[e,W]),$=el.useMemo(()=>{let re=new Set;for(let fe of e)fe.disabled&&re.add(fe.value);return re},[e]),Y=el.useCallback(re=>{b||N(re),(n??Kl)(re),K(false),A(""),V(-1),H.current?.focus();},[b,n]),se=el.useCallback(re=>{re.stopPropagation(),b||N(""),(n??Kl)(""),A(""),H.current?.focus();},[b,n]),ae=el.useCallback(()=>{s||l||(K(true),A(""),V(-1));},[s,l]),U=el.useCallback(()=>{K(false),A(""),V(-1),H.current?.focus();},[]),Q=el.useCallback(()=>{F?U():ae();},[F,U,ae]),le=el.useCallback((re,fe)=>{let je=X.length;if(je===0)return -1;let Dt=re;for(let Ie=0;Ie<je;Ie++)if(Dt=((Dt+fe)%je+je)%je,!$.has(X[Dt].value))return Dt;return -1},[X,$]),ye=el.useCallback(re=>{if(!(s||l)){if(F){switch(re.key){case "ArrowDown":{re.preventDefault();let fe=le(D,1);fe!==-1&&V(fe);break}case "ArrowUp":{re.preventDefault();let fe=le(D,-1);fe!==-1&&V(fe);break}case "Home":{re.preventDefault();let fe=le(-1,1);fe!==-1&&V(fe);break}case "End":{re.preventDefault();let fe=le(X.length,-1);fe!==-1&&V(fe);break}case "Enter":{if(re.preventDefault(),D>=0&&D<X.length){let fe=X[D];$.has(fe.value)||Y(fe.value);}break}case " ":if(re.preventDefault(),D>=0&&D<X.length){let fe=X[D];$.has(fe.value)||Y(fe.value);}else U();break;case "Escape":re.preventDefault(),U();break;case "Tab":U();break}return}switch(re.key){case "ArrowDown":case "ArrowUp":re.preventDefault(),ae();break;case "Enter":case " ":re.preventDefault(),ae();break}}},[s,l,F,ae,U,D,X,$,le,Y]),te=el.useCallback(re=>{switch(re.key){case "ArrowDown":{re.preventDefault();let fe=le(D,1);fe!==-1&&V(fe);break}case "ArrowUp":{re.preventDefault();let fe=le(D,-1);fe!==-1&&V(fe);break}case "Home":{re.preventDefault();let fe=le(-1,1);fe!==-1&&V(fe);break}case "End":{re.preventDefault();let fe=le(X.length,-1);fe!==-1&&V(fe);break}case "Enter":{if(re.preventDefault(),D>=0&&D<X.length){let fe=X[D];$.has(fe.value)||Y(fe.value);}break}case "Escape":re.preventDefault(),U();break;case "Tab":U();break}},[D,X,$,le,Y,U]),Ce=el.useCallback(re=>{let fe=re.target.value;A(fe),V(-1),(h??Kl)(fe);},[h]);el.useEffect(()=>{if(!F)return;let re=fe=>{let je=fe.target;H.current?.contains(je)||P.current?.contains(je)||U();};return document.addEventListener("mousedown",re),document.addEventListener("touchstart",re,{passive:true}),()=>{document.removeEventListener("mousedown",re),document.removeEventListener("touchstart",re);}},[F,U]),el.useEffect(()=>{if(!F||!H.current){_(null);return}let re=()=>{let fe=H.current;if(!fe)return;let je=fe.getBoundingClientRect(),Dt=window.innerHeight-je.bottom,Ie=je.top,we=T+8,pt=Dt<we&&Ie>Dt?"top":"bottom";_({top:pt==="bottom"?je.bottom+window.scrollY+4:je.top+window.scrollY-we,left:je.left+window.scrollX,width:je.width,placement:pt});};return re(),window.addEventListener("scroll",re,true),window.addEventListener("resize",re),()=>{window.removeEventListener("scroll",re,true),window.removeEventListener("resize",re);}},[F,T]),el.useEffect(()=>{F&&o&&B.current?.focus();},[F,o]),el.useEffect(()=>{let re=P.current;if(!(!F||!re))return wn(re,()=>H.current)},[F]),el.useEffect(()=>{if(D>=0){let re=C.current[D];re&&typeof re.scrollIntoView=="function"&&re.scrollIntoView({block:"nearest"});}},[D]);let Pe=W!==""&&W!==void 0,Se=a&&Pe&&!s&&!l&&!i,De=!s&&!l,Ne=_n("w-full flex items-center justify-between rounded-md transition-colors","text-gray-900 dark:text-gray-100",ja[c].trigger,lm[d].trigger,!w&&De&&lm[d].focus,w&&"border-red-500 dark:border-red-400 focus:ring-2 focus:ring-red-500 focus:border-red-500",s&&"opacity-50 cursor-not-allowed bg-gray-50 dark:bg-gray-900",l&&"cursor-default",!s&&!l&&"cursor-pointer",L);return jsxRuntime.jsxs("div",{className:_n("flex flex-col gap-1",S),children:[f?jsxRuntime.jsxs("label",{id:M,htmlFor:k,className:"text-sm font-medium text-gray-700 dark:text-gray-300",children:[f,v?jsxRuntime.jsx("span",{className:"text-red-500 ml-0.5","aria-hidden":"true",children:"*"}):null]}):null,m?jsxRuntime.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400",children:m}):null,jsxRuntime.jsxs("button",{ref:H,id:k,type:"button",role:"combobox","aria-expanded":F,"aria-haspopup":"listbox","aria-controls":F?z:void 0,"aria-labelledby":f?M:void 0,"aria-required":v||void 0,"aria-invalid":w?true:void 0,"aria-activedescendant":F&&D>=0?`${y}-option-${D}`:void 0,disabled:s,className:Ne,onClick:De?Q:void 0,onKeyDown:ye,children:[jsxRuntime.jsxs("span",{className:_n("flex items-center gap-2 min-w-0 flex-1 truncate",!Pe&&"text-gray-400 dark:text-gray-500"),children:[G?.icon?jsxRuntime.jsx("span",{className:"flex shrink-0 items-center",children:G.icon}):null,jsxRuntime.jsx("span",{className:"truncate",children:Pe&&G?G.label:u})]}),jsxRuntime.jsxs("span",{className:"flex items-center gap-1 shrink-0",children:[i?jsxRuntime.jsx("span",{className:"text-gray-400",children:h1}):null,Se?jsxRuntime.jsx("span",{role:"button",tabIndex:-1,"aria-label":"Clear selection",className:"text-gray-400 hover:text-gray-600 dark:hover:text-gray-300 p-0.5 rounded transition-colors",onClick:se,onMouseDown:re=>re.preventDefault(),children:f1}):null,jsxRuntime.jsx("span",{className:_n("text-gray-400 transition-transform duration-200",F&&"rotate-180"),children:p1})]})]}),w?jsxRuntime.jsx("p",{role:"alert",className:"text-xs text-red-500 dark:text-red-400",children:w}):p?jsxRuntime.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400",children:p}):null,I?jsxRuntime.jsx("input",{type:"hidden",name:I,value:W??""}):null,F&&O?reactDom.createPortal(jsxRuntime.jsxs("div",{ref:P,role:"listbox",id:z,"aria-labelledby":f?M:void 0,className:_n("fixed z-50 bg-white dark:bg-gray-800 border border-gray-200 dark:border-gray-700","rounded-md shadow-lg overflow-hidden","animate-in fade-in-0 zoom-in-95",ja[c].content,R),style:{top:O.top,left:O.left,width:O.width,position:"absolute"},onKeyDown:te,children:[o?jsxRuntime.jsx("div",{className:"border-b border-gray-200 dark:border-gray-700",children:jsxRuntime.jsx("input",{ref:B,type:"text",role:"searchbox","aria-label":"Search options",className:_n(ja[c].searchInput,"w-full outline-none bg-transparent text-gray-900 dark:text-gray-100","placeholder:text-gray-400 dark:placeholder:text-gray-500"),placeholder:"Search...",value:j,onChange:Ce,onKeyDown:te})}):null,jsxRuntime.jsx("div",{className:"overflow-y-auto",style:{maxHeight:T},children:X.length===0?jsxRuntime.jsx("div",{className:_n(ja[c].option,"text-gray-500 dark:text-gray-400 text-center py-4"),children:x}):X.map((re,fe)=>jsxRuntime.jsx(x1,{option:re,isSelected:re.value===W,isHighlighted:fe===D,isDisabled:i||$.has(re.value),sizeKey:c,optionId:`${y}-option-${fe}`,onClick:Y,onMouseEnter:V,index:fe,ref:je=>{C.current[fe]=je;}},re.value))})]}),document.body):null]})}var Yl=el.createContext(null);function ko(){let e=el.useContext(Yl);if(!e)throw new Error("Sidebar sub-components must be used within <Sidebar>");return e}function w1(){return ko()}var N1=({className:e})=>jsxRuntime.jsx("svg",{className:g("w-4 h-4",e),viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true",children:jsxRuntime.jsx("path",{fillRule:"evenodd",d:"M12.79 5.23a.75.75 0 01-.02 1.06L8.832 10l3.938 3.71a.75.75 0 11-1.04 1.08l-4.5-4.25a.75.75 0 010-1.08l4.5-4.25a.75.75 0 011.06.02z",clipRule:"evenodd"})}),S1=({className:e})=>jsxRuntime.jsx("svg",{className:g("w-4 h-4",e),viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true",children:jsxRuntime.jsx("path",{fillRule:"evenodd",d:"M5.23 7.21a.75.75 0 011.06.02L10 11.168l3.71-3.938a.75.75 0 111.08 1.04l-4.25 4.5a.75.75 0 01-1.08 0l-4.25-4.5a.75.75 0 01.02-1.06z",clipRule:"evenodd"})}),R1=({className:e})=>jsxRuntime.jsx("svg",{className:g("w-5 h-5",e),viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true",children:jsxRuntime.jsx("path",{d:"M6.28 5.22a.75.75 0 00-1.06 1.06L8.94 10l-3.72 3.72a.75.75 0 101.06 1.06L10 11.06l3.72 3.72a.75.75 0 101.06-1.06L11.06 10l3.72-3.72a.75.75 0 00-1.06-1.06L10 8.94 6.28 5.22z"})});function um({text:e,position:t,children:r}){let[n,o]=el.useState(false),[a,s]=el.useState({top:0,left:0}),l=el.useRef(null);return jsxRuntime.jsxs("div",{ref:l,onMouseEnter:()=>{if(l.current){let c=l.current.getBoundingClientRect();s({top:c.top+c.height/2,left:t==="left"?c.right+8:c.left-8});}o(true);},onMouseLeave:()=>o(false),className:"relative",children:[r,n&&jsxRuntime.jsx("div",{className:g("fixed z-[9999] px-2.5 py-1.5 text-xs font-medium text-white bg-gray-900 dark:bg-gray-700 rounded-md shadow-lg whitespace-nowrap pointer-events-none",t==="right"&&"-translate-x-full"),style:{top:a.top,left:a.left,transform:`translateY(-50%)${t==="right"?" translateX(-100%)":""}`},role:"tooltip",children:e})]})}function T1({collapsed:e,defaultCollapsed:t=false,onCollapsedChange:r,expandedWidth:n=260,collapsedWidth:o=64,position:a="left",variant:s="default",mobileBreakpoint:l=768,mobileOpen:i,onMobileOpenChange:c,className:d,"aria-label":u,closeLabel:f,trapFocus:m=true,initialFocus:p,returnFocus:w,lockScroll:v=true,children:x}){let h=We(),I=el.useRef(null),S=el.useRef(null),[L,R]=el.useState(t),[T,y]=el.useState(false),[M,k]=el.useState(false),z=e!==void 0,H=z?e:L,P=i!==void 0,B=P?i:T;el.useEffect(()=>{let A=window.matchMedia(`(max-width: ${l}px)`),D=V=>{k(V.matches),V.matches||(P||y(false),c?.(false));};return D(A),A.addEventListener("change",D),()=>A.removeEventListener("change",D)},[l,P,c]);let C=el.useCallback(()=>{if(M){let A=!B;P||y(A),c?.(A);}else {let A=!H;z||R(A),r?.(A);}},[M,B,H,P,z,c,r]),b=el.useCallback(()=>{P||y(false),c?.(false);},[P,c]);el.useEffect(()=>{let A=S.current;A&&(M&&!B?(A.setAttribute("inert",""),A.setAttribute("aria-hidden","true")):(A.removeAttribute("inert"),A.removeAttribute("aria-hidden")));},[M,B]);let{dialogRef:E,dialogProps:N}=fo({open:M&&B,onClose:b,trapFocus:m,initialFocus:p,returnFocus:w,lockScroll:v,keepInteractive:[I]}),W={default:"bg-white dark:bg-gray-900",bordered:g("bg-white dark:bg-gray-900",a==="left"?"border-r border-gray-200 dark:border-gray-700":"border-l border-gray-200 dark:border-gray-700"),floating:"bg-white dark:bg-gray-900 m-3 rounded-xl shadow-xl border border-gray-200 dark:border-gray-700"},F=H&&!M?o:n,K=jsxRuntime.jsx("aside",{className:g("flex flex-col h-full overflow-hidden transition-[width] duration-200 ease-in-out",W[s],d),style:{width:M?n:F,minWidth:M?n:F},"data-testid":"sidebar","data-collapsed":H&&!M,"data-mobile":M,"data-position":a,children:x}),j={collapsed:H&&!M,isMobile:M,mobileOpen:B,position:a,variant:s,expandedWidth:n,collapsedWidth:o,toggle:C,closeMobile:b,closeLabel:f};return M?jsxRuntime.jsxs(Yl.Provider,{value:j,children:[B&&jsxRuntime.jsx("div",{ref:I,className:"fixed inset-0 z-40 bg-black/50 transition-opacity",onClick:b,"aria-hidden":"true","data-testid":"sidebar-overlay"}),jsxRuntime.jsx("div",{ref:A=>{S.current=A,E.current=A;},...N,"aria-label":u??h.sidebar,className:g("fixed top-0 z-50 h-full transition-transform duration-200 ease-in-out focus:outline-none",a==="left"?"left-0":"right-0",B?"translate-x-0":a==="left"?"-translate-x-full":"translate-x-full"),children:K})]}):jsxRuntime.jsx(Yl.Provider,{value:j,children:K})}function P1({className:e,children:t}){let r=ko(),n=We();return jsxRuntime.jsxs("div",{className:g("flex items-center shrink-0 px-4 h-14 overflow-hidden",r.collapsed&&"justify-center px-2",e),"data-testid":"sidebar-header",children:[t,r.isMobile&&r.mobileOpen&&jsxRuntime.jsx("button",{type:"button",onClick:r.closeMobile,className:"ml-auto p-1 rounded-md text-gray-400 hover:text-gray-600 dark:hover:text-gray-300 hover:bg-gray-100 dark:hover:bg-gray-800 cursor-pointer","aria-label":r.closeLabel??n.closeSidebar,children:jsxRuntime.jsx(R1,{})})]})}function D1({className:e,children:t}){return jsxRuntime.jsx("div",{className:g("flex-1 overflow-y-auto overflow-x-hidden py-2",e),"data-testid":"sidebar-content",children:t})}function L1({className:e,children:t}){let r=ko();return jsxRuntime.jsx("div",{className:g("shrink-0 border-t border-gray-200 dark:border-gray-700 px-4 py-3 overflow-hidden",r.collapsed&&"px-2 flex justify-center",e),"data-testid":"sidebar-footer",children:t})}function E1({label:e,className:t,children:r}){let n=ko();return jsxRuntime.jsxs("div",{className:g("py-2",t),"data-testid":"sidebar-group",children:[e&&!n.collapsed&&jsxRuntime.jsx("div",{className:"px-4 py-1.5 text-[11px] font-semibold uppercase tracking-wider text-gray-400 dark:text-gray-500",children:e}),e&&n.collapsed&&jsxRuntime.jsx("div",{className:"mx-auto my-1 w-6 border-t border-gray-200 dark:border-gray-700"}),jsxRuntime.jsx("div",{className:"space-y-0.5 px-2",children:r})]})}function M1({icon:e,label:t,badge:r,badgeColor:n="bg-blue-600 text-white",active:o=false,disabled:a=false,href:s,onClick:l,tooltip:i,className:c}){let d=ko(),u=d.collapsed,f=i??t,m=jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[e&&jsxRuntime.jsx("span",{className:g("shrink-0 w-5 h-5",u&&"w-5 h-5"),children:e}),!u&&jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("span",{className:"flex-1 truncate",children:t}),r!=null&&jsxRuntime.jsx("span",{className:g("shrink-0 inline-flex items-center justify-center rounded-full text-[10px] font-semibold min-w-[18px] h-[18px] px-1",n),children:r})]}),u&&r!==void 0&&r!==null&&jsxRuntime.jsx("span",{className:"absolute top-1 right-1 w-2 h-2 rounded-full bg-blue-600"})]}),p=g("relative flex items-center gap-3 rounded-md text-sm font-medium transition-colors w-full",u?"justify-center px-2 py-2.5":"px-3 py-2",o?"bg-blue-50 text-blue-700 dark:bg-blue-900/30 dark:text-blue-400":"text-gray-700 dark:text-gray-300 hover:bg-gray-100 dark:hover:bg-gray-800",a&&"opacity-50 pointer-events-none",!a&&"cursor-pointer",c),w=()=>{a||(l?.(),d.isMobile&&d.closeMobile());},v=s?jsxRuntime.jsx("a",{href:a?void 0:s,className:p,onClick:w,"aria-current":o?"page":void 0,"data-testid":"sidebar-item",children:m}):jsxRuntime.jsx("button",{type:"button",className:p,onClick:w,disabled:a,"aria-current":o?"page":void 0,"data-testid":"sidebar-item",children:m});return u?jsxRuntime.jsx(um,{text:f,position:d.position,children:v}):v}function I1({icon:e,label:t,badge:r,defaultOpen:n=false,className:o,children:a}){let s=ko(),[l,i]=el.useState(n),c=el.useRef(null),[d,u]=el.useState(n?void 0:0),f=el.useRef(true);return el.useEffect(()=>{if(f.current){f.current=false,u(l?void 0:0);return}if(l){let m=c.current;if(m){u(m.scrollHeight);let p=setTimeout(()=>u(void 0),200);return ()=>clearTimeout(p)}}else {let m=c.current;m&&(u(m.scrollHeight),requestAnimationFrame(()=>u(0)));}},[l]),s.collapsed?jsxRuntime.jsx(um,{text:t,position:s.position,children:jsxRuntime.jsxs("button",{type:"button",className:g("relative flex items-center justify-center gap-3 rounded-md text-sm font-medium transition-colors w-full px-2 py-2.5","text-gray-700 dark:text-gray-300 hover:bg-gray-100 dark:hover:bg-gray-800 cursor-pointer",o),onClick:()=>{s.toggle(),i(true);},"data-testid":"sidebar-submenu-trigger",children:[e&&jsxRuntime.jsx("span",{className:"shrink-0 w-5 h-5",children:e}),r!=null&&jsxRuntime.jsx("span",{className:"absolute top-1 right-1 w-2 h-2 rounded-full bg-blue-600"})]})}):jsxRuntime.jsxs("div",{className:o,"data-testid":"sidebar-submenu",children:[jsxRuntime.jsxs("button",{type:"button",className:g("flex items-center gap-3 rounded-md text-sm font-medium transition-colors w-full px-3 py-2","text-gray-700 dark:text-gray-300 hover:bg-gray-100 dark:hover:bg-gray-800 cursor-pointer"),onClick:()=>i(!l),"aria-expanded":l,"data-testid":"sidebar-submenu-trigger",children:[e&&jsxRuntime.jsx("span",{className:"shrink-0 w-5 h-5",children:e}),jsxRuntime.jsx("span",{className:"flex-1 truncate text-left",children:t}),r!=null&&jsxRuntime.jsx("span",{className:"shrink-0 inline-flex items-center justify-center rounded-full text-[10px] font-semibold min-w-[18px] h-[18px] px-1 bg-blue-600 text-white",children:r}),jsxRuntime.jsx(S1,{className:g("shrink-0 text-gray-400 transition-transform duration-200",l&&"rotate-180")})]}),jsxRuntime.jsx("div",{className:"overflow-hidden transition-[height] duration-200 ease-in-out",style:{height:d===void 0?"auto":d},children:jsxRuntime.jsx("div",{ref:c,className:"pl-4 py-0.5",children:a})})]})}function A1({className:e}){let t=ko(),r=We(),n=t.isMobile?t.mobileOpen?t.closeLabel??r.closeSidebar:r.openSidebar:t.collapsed?r.expandSidebar:r.collapseSidebar;return jsxRuntime.jsx("button",{type:"button",onClick:t.toggle,className:g("p-1.5 rounded-md text-gray-400 hover:text-gray-600 dark:hover:text-gray-300 hover:bg-gray-100 dark:hover:bg-gray-800 transition-colors cursor-pointer",e),"aria-label":n,"data-testid":"sidebar-toggle",children:jsxRuntime.jsx(N1,{className:g("transition-transform duration-200",t.collapsed&&"rotate-180",t.position==="right"&&!t.collapsed&&"rotate-180",t.position==="right"&&t.collapsed&&"rotate-0")})})}function jl({data:e,width:t=96,height:r=28,curve:n="monotone",color:o=bs[0],strokeWidth:a=2,area:s=false,emphasizeLast:l=false,domain:i,ariaLabel:c,className:d,...u}){let f=Math.max(a/2,l?a+2.5:0),m=i??Yt(e)??[0,1],p=Er([0,Math.max(1,e.length-1)],[f,t-f]),w=Er(m,[r-f,f]),v=e.map((h,I)=>({x:p(I),y:h==null?Number.NaN:w(h),defined:h!=null&&Number.isFinite(h)})),x=[...v].reverse().find(h=>h.defined!==false);return jsxRuntime.jsxs("svg",{width:t,height:r,viewBox:`0 0 ${t} ${r}`,className:g("overflow-visible",d),role:c?"img":void 0,"aria-label":c,"aria-hidden":c?void 0:true,...u,children:[s?jsxRuntime.jsx("path",{d:Na(v,r-f,n),fill:o,fillOpacity:.12,stroke:"none"}):null,jsxRuntime.jsx("path",{d:Xr(v,n),fill:"none",stroke:o,strokeWidth:a,strokeLinecap:"round",strokeLinejoin:"round",vectorEffect:"non-scaling-stroke"}),l&&x?jsxRuntime.jsx("circle",{cx:x.x,cy:x.y,r:a,fill:o,strokeWidth:2,className:"stroke-white dark:stroke-gray-800"}):null]})}var W1={sm:"p-3",md:"p-4",lg:"p-5"},H1={sm:"text-[11px]",md:"text-xs",lg:"text-sm"},B1={sm:"text-xl",md:"text-2xl",lg:"text-3xl"},mm={sm:{width:72,height:22},md:{width:96,height:28},lg:{width:120,height:34}};function V1(e){return e.direction?e.direction:e.value>0?"up":e.value<0?"down":"flat"}function F1(e,t){return e==="flat"||t==="neutral"?"text-gray-500 dark:text-gray-400":e===t?"text-green-600 dark:text-green-400":"text-red-600 dark:text-red-400"}function O1({direction:e}){return e==="flat"?jsxRuntime.jsx("svg",{width:"10",height:"10",viewBox:"0 0 10 10",fill:"currentColor","aria-hidden":"true",children:jsxRuntime.jsx("rect",{x:"1",y:"4.25",width:"8",height:"1.5",rx:"0.75"})}):jsxRuntime.jsx("svg",{width:"10",height:"10",viewBox:"0 0 10 10",fill:"currentColor","aria-hidden":"true",children:jsxRuntime.jsx("path",{d:e==="up"?"M5 1 L9.5 8 L0.5 8 Z":"M5 9 L0.5 2 L9.5 2 Z"})})}function $1({label:e,value:t,format:r,delta:n,trend:o,trendColor:a,icon:s,size:l="md",loading:i=false,variant:c="card",footer:d,className:u,...f}){let m=typeof t=="number"?(r??nt)(t):t,p=n?V1(n):"flat",w=n?(n.format??(v=>Ut(v,{signed:true})))(n.value):null;return jsxRuntime.jsxs("div",{className:g("flex flex-col gap-2",c==="card"&&g("rounded-lg border border-gray-200 bg-white dark:border-gray-700 dark:bg-gray-800",W1[l]),u),...f,children:[jsxRuntime.jsxs("div",{className:"flex items-start justify-between gap-2",children:[jsxRuntime.jsx("span",{className:g("font-medium text-gray-500 dark:text-gray-400",H1[l]),children:e}),s?jsxRuntime.jsx("span",{className:"shrink-0 text-gray-400",children:s}):null]}),jsxRuntime.jsxs("div",{className:"flex items-end justify-between gap-3",children:[jsxRuntime.jsxs("div",{className:"flex min-w-0 flex-col gap-1",children:[i?jsxRuntime.jsx("div",{className:"flex items-center",style:{height:l==="lg"?30:24},"aria-busy":"true","aria-live":"polite",children:jsxRuntime.jsx(Po,{indeterminate:true,size:l==="lg"?"sm":"xs",thickness:"thin","aria-hidden":"true"})}):jsxRuntime.jsx("span",{className:g("leading-none font-semibold text-gray-900 dark:text-gray-100",B1[l]),children:m}),n&&!i?jsxRuntime.jsxs("span",{className:g("flex items-center gap-1 text-xs font-medium",F1(p,n.goodWhen??"up")),children:[jsxRuntime.jsx(O1,{direction:p}),w,n.period?jsxRuntime.jsx("span",{className:"font-normal text-gray-500 dark:text-gray-400",children:n.period}):null]}):null]}),o&&o.length>0&&!i?jsxRuntime.jsx(jl,{data:o,color:a,emphasizeLast:true,area:true,width:mm[l].width,height:mm[l].height,className:"shrink-0"}):null]}),d?jsxRuntime.jsx("div",{className:"text-xs text-gray-500 dark:text-gray-400",children:d}):null]})}var _1={1:"sm:grid-cols-1",2:"sm:grid-cols-2",3:"sm:grid-cols-3",4:"sm:grid-cols-2 lg:grid-cols-4"};function X1({columns:e=4,className:t,children:r,...n}){return jsxRuntime.jsx("div",{className:g("grid grid-cols-1 gap-3",_1[e],t),...n,children:r})}var K1={text:"rounded h-4 w-full",circular:"rounded-full",rectangular:"rounded-none",rounded:"rounded-lg"},U1={pulse:"animate-pulse",wave:"animate-shimmer bg-gradient-to-r from-gray-200 via-gray-100 to-gray-200 dark:from-gray-700 dark:via-gray-600 dark:to-gray-700 bg-[length:200%_100%]",none:""},Y1="bg-gray-200 dark:bg-gray-700";function gm({variant:e="text",animation:t="pulse",width:r,height:n,count:o=1,className:a,style:s,...l}){let i={...r!==void 0&&{width:typeof r=="number"?`${r}px`:r},...n!==void 0&&{height:typeof n=="number"?`${n}px`:n},...s};e==="circular"&&r&&!n&&(i.height=i.width);let c=g(Y1,K1[e],U1[t],a);return o===1?jsxRuntime.jsx("div",{className:c,style:i,"aria-busy":"true","aria-live":"polite",...l}):jsxRuntime.jsx("div",{className:"space-y-2",children:Array.from({length:o}).map((d,u)=>jsxRuntime.jsx("div",{className:c,style:i,"aria-busy":"true","aria-live":"polite",...l},u))})}gm.displayName="Skeleton";var J1={sm:"h-1",md:"h-1.5",lg:"h-2"},eC={sm:"w-3.5 h-3.5",md:"w-4 h-4",lg:"w-5 h-5"},tC={sm:14,md:16,lg:20},rC="[&::-webkit-slider-thumb]:appearance-none [&::-webkit-slider-thumb]:rounded-full [&::-moz-range-thumb]:appearance-none [&::-moz-range-thumb]:rounded-full [&::-moz-range-thumb]:border-0",nC={sm:"[&::-webkit-slider-thumb]:h-3.5 [&::-webkit-slider-thumb]:w-3.5 [&::-moz-range-thumb]:h-3.5 [&::-moz-range-thumb]:w-3.5",md:"[&::-webkit-slider-thumb]:h-4 [&::-webkit-slider-thumb]:w-4 [&::-moz-range-thumb]:h-4 [&::-moz-range-thumb]:w-4",lg:"[&::-webkit-slider-thumb]:h-5 [&::-webkit-slider-thumb]:w-5 [&::-moz-range-thumb]:h-5 [&::-moz-range-thumb]:w-5"},oC={sm:"h-4",md:"h-5",lg:"h-6"},aC={primary:"bg-blue-600 dark:bg-blue-500",success:"bg-green-600 dark:bg-green-500",warning:"bg-yellow-500 dark:bg-yellow-400",error:"bg-red-600 dark:bg-red-500",info:"bg-cyan-600 dark:bg-cyan-500",neutral:"bg-gray-600 dark:bg-gray-400"},sC={primary:"border-blue-600 dark:border-blue-500",success:"border-green-600 dark:border-green-500",warning:"border-yellow-500 dark:border-yellow-400",error:"border-red-600 dark:border-red-500",info:"border-cyan-600 dark:border-cyan-500",neutral:"border-gray-600 dark:border-gray-400"},iC={primary:"peer-focus-visible:ring-blue-500",success:"peer-focus-visible:ring-green-500",warning:"peer-focus-visible:ring-yellow-500",error:"peer-focus-visible:ring-red-500",info:"peer-focus-visible:ring-cyan-500",neutral:"peer-focus-visible:ring-gray-500"},lC={primary:"text-blue-600 dark:text-blue-400",success:"text-green-600 dark:text-green-400",warning:"text-yellow-600 dark:text-yellow-400",error:"text-red-600 dark:text-red-400",info:"text-cyan-600 dark:text-cyan-400",neutral:"text-gray-700 dark:text-gray-300"},pm=(e,t,r)=>Math.min(r,Math.max(t,e)),Ql=(e,t,r)=>r>t?(pm(e,t,r)-t)/(r-t)*100:0,ci=(e,t)=>{let r=(.5-e/100)*t,n=Math.round(Math.abs(r)*1e3)/1e3;return `calc(${e}% ${r<0?"-":"+"} ${n}px)`},cC=(e,t,r,n)=>{if(!e)return [];if(Array.isArray(e))return e;let o=n>0?n:1,a=Math.floor((r-t)/o);return a<=0||a>20?[{value:t},{value:r}]:Array.from({length:a+1},(s,l)=>({value:t+l*o}))},fm=el.forwardRef(({value:e,defaultValue:t,onValueChange:r,min:n=0,max:o=100,step:a=1,size:s="md",color:l="primary",disabled:i=false,readOnly:c=false,label:d,description:u,error:f=false,showValue:m=false,showTooltip:p=false,valueFormat:w,marks:v,trackColor:x,fillColor:h,thumbColor:I,className:S,containerClassName:L,id:R,...T},y)=>{let[M,k]=el.useState(t??n),z=e!==void 0,P=pm(z?e:M,n,o),B=el.useId(),C=R??B,b=typeof f=="string"?f:void 0,E=!!f,N=!i&&!c,W=E?"error":l,F=Ql(P,n,o),K=tC[s],j=G=>{if(!N)return;let $=Number(G.target.value);z||k($),r?.($);},A=el.useMemo(()=>cC(v,n,o,a),[v,n,o,a]),D=A.some(G=>G.label!=null),V=w?w(P):`${P}`,O={width:ci(F,K)};h&&(O.backgroundColor=h);let _={left:ci(F,K)};I&&(_.backgroundColor=I,_.borderColor=I);let X=x?{backgroundColor:x}:{};return jsxRuntime.jsxs("div",{className:g("w-full",L),children:[(d||m)&&jsxRuntime.jsxs("div",{className:"flex items-center justify-between mb-1.5",children:[d?jsxRuntime.jsx("label",{htmlFor:C,className:g("text-sm font-medium text-gray-700 dark:text-gray-200",i&&"opacity-50"),children:d}):jsxRuntime.jsx("span",{}),m&&jsxRuntime.jsx("span",{className:g("text-sm font-semibold tabular-nums",lC[W]),children:V})]}),jsxRuntime.jsxs("div",{className:g("relative flex items-center",oC[s],i&&"opacity-50"),children:[jsxRuntime.jsx("input",{ref:y,type:"range",id:C,min:n,max:o,step:a,value:P,onChange:j,disabled:i,readOnly:c,"aria-invalid":E,"aria-readonly":c||void 0,"aria-describedby":b?`${C}-error`:void 0,tabIndex:N?void 0:-1,className:g("peer absolute inset-0 z-10 m-0 h-full w-full cursor-pointer appearance-none bg-transparent opacity-0",rC,nC[s],!N&&"pointer-events-none cursor-default",S),...T}),jsxRuntime.jsxs("div",{className:g("pointer-events-none relative w-full overflow-hidden rounded-full bg-gray-200 dark:bg-gray-700",J1[s]),style:X,children:[jsxRuntime.jsx("div",{className:g("absolute inset-y-0 left-0 rounded-full transition-[width] duration-150 ease-out",h?"":aC[W]),style:O}),A.map((G,$)=>{let Y=Ql(G.value,n,o),se=G.value<=P;return jsxRuntime.jsx("span",{"data-slider-mark":"",className:g("absolute top-1/2 h-1 w-1 -translate-x-1/2 -translate-y-1/2 rounded-full",se?"bg-white/80":"bg-gray-400 dark:bg-gray-500"),style:{left:ci(Y,K)}},`mark-${G.value}-${$}`)})]}),jsxRuntime.jsx("div",{"data-slider-thumb":"",className:g("pointer-events-none absolute top-1/2 -translate-x-1/2 -translate-y-1/2 rounded-full border-2 bg-white shadow transition-transform dark:bg-gray-100",eC[s],I?"":sC[W],N&&"peer-hover:scale-110 peer-active:scale-110","peer-focus-visible:scale-110 peer-focus-visible:ring-2 peer-focus-visible:ring-offset-2",iC[W]),style:_,children:p&&jsxRuntime.jsx("span",{"data-slider-tooltip":"",className:g("pointer-events-none absolute bottom-full left-1/2 mb-2 -translate-x-1/2 rounded bg-gray-900 px-1.5 py-0.5 text-xs font-medium text-white opacity-0 transition-opacity dark:bg-gray-700","peer-hover:opacity-100 peer-focus-visible:opacity-100 peer-active:opacity-100"),children:V})})]}),D&&jsxRuntime.jsx("div",{className:"relative mt-1.5 h-4",children:A.map((G,$)=>G.label!=null?jsxRuntime.jsx("span",{className:"absolute -translate-x-1/2 whitespace-nowrap text-xs text-gray-500 dark:text-gray-400",style:{left:ci(Ql(G.value,n,o),K)},children:G.label},`mark-label-${G.value}-${$}`):null)}),u&&!b&&jsxRuntime.jsx("p",{className:"mt-1.5 text-sm text-gray-500 dark:text-gray-400",children:u}),b&&jsxRuntime.jsx("p",{id:`${C}-error`,className:"mt-1.5 text-sm text-red-500 dark:text-red-400",children:b})]})});fm.displayName="Slider";var Jl=el.createContext(null);function ra(){let e=el.useContext(Jl);if(!e)throw new Error("Tabs components must be used within a Tabs provider");return e}function bm({children:e,defaultValue:t="",value:r,onValueChange:n,variant:o="underline",size:a="md",color:s="default",fullWidth:l=false,orientation:i="horizontal",className:c}){let[d,u]=el.useState(t),f=r!==void 0,m=f?r:d,p=el.useCallback(v=>{f||u(v),n?.(v);},[f,n]),w=el.useMemo(()=>({value:m,onValueChange:p,variant:o,size:a,color:s,orientation:i,fullWidth:l}),[m,p,o,a,s,i,l]);return jsxRuntime.jsx(Jl.Provider,{value:w,children:jsxRuntime.jsx("div",{className:g("w-full",i==="vertical"&&"flex gap-4",c),"data-orientation":i,children:e})})}bm.displayName="Tabs";var fC={none:"gap-0",sm:"gap-1",md:"gap-2",lg:"gap-4"};function ym({children:e,className:t,bgColor:r,gap:n="none"}){let{variant:o,orientation:a,fullWidth:s}=ra(),l=g("flex",a==="vertical"?"flex-col":"flex-row items-center",fC[n]),i={underline:"border-b border-gray-200 dark:border-gray-700",pills:g("p-1 rounded-lg",r||"bg-gray-100 dark:bg-gray-800"),enclosed:"border-b border-gray-200 dark:border-gray-700",soft:g("p-1 rounded-lg",r||"bg-gray-100/50 dark:bg-gray-800/50")};return jsxRuntime.jsx("div",{role:"tablist","aria-orientation":a,className:g(l,i[o],s&&"w-full",t),children:e})}ym.displayName="TabsList";var bC={sm:"px-3 py-1.5 text-xs gap-1.5",md:"px-4 py-2 text-sm gap-2",lg:"px-5 py-2.5 text-base gap-2"},xm={sm:"w-3.5 h-3.5",md:"w-4 h-4",lg:"w-5 h-5"},vm={default:{underline:{active:"text-gray-900 dark:text-white border-gray-900 dark:border-white",inactive:"text-gray-500 dark:text-gray-400 border-transparent hover:text-gray-700 dark:hover:text-gray-300"},pills:{active:"bg-white dark:bg-gray-700 text-gray-900 dark:text-white shadow-sm",inactive:"text-gray-600 dark:text-gray-400 hover:text-gray-900 dark:hover:text-white"},enclosed:{active:"bg-white dark:bg-gray-800 text-gray-900 dark:text-white border-gray-200 dark:border-gray-700 border-b-white dark:border-b-gray-800",inactive:"text-gray-500 dark:text-gray-400 hover:text-gray-700 dark:hover:text-gray-300 border-transparent"},soft:{active:"bg-gray-200 dark:bg-gray-700 text-gray-900 dark:text-white",inactive:"text-gray-600 dark:text-gray-400 hover:text-gray-900 dark:hover:text-white hover:bg-gray-100 dark:hover:bg-gray-700/50"}},primary:{underline:{active:"text-blue-600 dark:text-blue-400 border-blue-600 dark:border-blue-400",inactive:"text-gray-500 dark:text-gray-400 border-transparent hover:text-blue-600 dark:hover:text-blue-400"},pills:{active:"bg-blue-600 text-white",inactive:"text-gray-600 dark:text-gray-400 hover:text-blue-600 dark:hover:text-blue-400"},enclosed:{active:"bg-blue-50 dark:bg-blue-900/20 text-blue-600 dark:text-blue-400 border-blue-200 dark:border-blue-800 border-b-blue-50 dark:border-b-blue-900/20",inactive:"text-gray-500 dark:text-gray-400 hover:text-blue-600 dark:hover:text-blue-400 border-transparent"},soft:{active:"bg-blue-100 dark:bg-blue-900/50 text-blue-700 dark:text-blue-300",inactive:"text-gray-600 dark:text-gray-400 hover:text-blue-600 dark:hover:text-blue-400 hover:bg-blue-50 dark:hover:bg-blue-900/20"}},secondary:{underline:{active:"text-purple-600 dark:text-purple-400 border-purple-600 dark:border-purple-400",inactive:"text-gray-500 dark:text-gray-400 border-transparent hover:text-purple-600 dark:hover:text-purple-400"},pills:{active:"bg-purple-600 text-white",inactive:"text-gray-600 dark:text-gray-400 hover:text-purple-600 dark:hover:text-purple-400"},enclosed:{active:"bg-purple-50 dark:bg-purple-900/20 text-purple-600 dark:text-purple-400 border-purple-200 dark:border-purple-800 border-b-purple-50 dark:border-b-purple-900/20",inactive:"text-gray-500 dark:text-gray-400 hover:text-purple-600 dark:hover:text-purple-400 border-transparent"},soft:{active:"bg-purple-100 dark:bg-purple-900/50 text-purple-700 dark:text-purple-300",inactive:"text-gray-600 dark:text-gray-400 hover:text-purple-600 dark:hover:text-purple-400 hover:bg-purple-50 dark:hover:bg-purple-900/20"}},success:{underline:{active:"text-green-600 dark:text-green-400 border-green-600 dark:border-green-400",inactive:"text-gray-500 dark:text-gray-400 border-transparent hover:text-green-600 dark:hover:text-green-400"},pills:{active:"bg-green-600 text-white",inactive:"text-gray-600 dark:text-gray-400 hover:text-green-600 dark:hover:text-green-400"},enclosed:{active:"bg-green-50 dark:bg-green-900/20 text-green-600 dark:text-green-400 border-green-200 dark:border-green-800 border-b-green-50 dark:border-b-green-900/20",inactive:"text-gray-500 dark:text-gray-400 hover:text-green-600 dark:hover:text-green-400 border-transparent"},soft:{active:"bg-green-100 dark:bg-green-900/50 text-green-700 dark:text-green-300",inactive:"text-gray-600 dark:text-gray-400 hover:text-green-600 dark:hover:text-green-400 hover:bg-green-50 dark:hover:bg-green-900/20"}},warning:{underline:{active:"text-yellow-600 dark:text-yellow-400 border-yellow-600 dark:border-yellow-400",inactive:"text-gray-500 dark:text-gray-400 border-transparent hover:text-yellow-600 dark:hover:text-yellow-400"},pills:{active:"bg-yellow-500 text-white",inactive:"text-gray-600 dark:text-gray-400 hover:text-yellow-600 dark:hover:text-yellow-400"},enclosed:{active:"bg-yellow-50 dark:bg-yellow-900/20 text-yellow-600 dark:text-yellow-400 border-yellow-200 dark:border-yellow-800 border-b-yellow-50 dark:border-b-yellow-900/20",inactive:"text-gray-500 dark:text-gray-400 hover:text-yellow-600 dark:hover:text-yellow-400 border-transparent"},soft:{active:"bg-yellow-100 dark:bg-yellow-900/50 text-yellow-700 dark:text-yellow-300",inactive:"text-gray-600 dark:text-gray-400 hover:text-yellow-600 dark:hover:text-yellow-400 hover:bg-yellow-50 dark:hover:bg-yellow-900/20"}},error:{underline:{active:"text-red-600 dark:text-red-400 border-red-600 dark:border-red-400",inactive:"text-gray-500 dark:text-gray-400 border-transparent hover:text-red-600 dark:hover:text-red-400"},pills:{active:"bg-red-600 text-white",inactive:"text-gray-600 dark:text-gray-400 hover:text-red-600 dark:hover:text-red-400"},enclosed:{active:"bg-red-50 dark:bg-red-900/20 text-red-600 dark:text-red-400 border-red-200 dark:border-red-800 border-b-red-50 dark:border-b-red-900/20",inactive:"text-gray-500 dark:text-gray-400 hover:text-red-600 dark:hover:text-red-400 border-transparent"},soft:{active:"bg-red-100 dark:bg-red-900/50 text-red-700 dark:text-red-300",inactive:"text-gray-600 dark:text-gray-400 hover:text-red-600 dark:hover:text-red-400 hover:bg-red-50 dark:hover:bg-red-900/20"}}},yC={underline:"border-b-2 -mb-px",pills:"rounded-md",enclosed:"border border-b-0 rounded-t-md -mb-px",soft:"rounded-md"};function Cm({value:e,children:t,disabled:r=false,icon:n,endIcon:o,className:a,activeClassName:s,inactiveClassName:l}){let{value:i,onValueChange:c,variant:d,size:u,color:f,fullWidth:m}=ra(),p=i===e,w=()=>{r||c(e);},v=S=>{(S.key==="Enter"||S.key===" ")&&(S.preventDefault(),w());},x=g("inline-flex items-center justify-center font-medium transition-all duration-200","focus:outline-none focus-visible:ring-2 focus-visible:ring-offset-2 focus-visible:ring-blue-500",bC[u],m&&"flex-1"),h=p?g(vm[f][d].active,s):g(vm[f][d].inactive,l),I=r?"opacity-50 cursor-not-allowed":"cursor-pointer";return jsxRuntime.jsxs("button",{type:"button",role:"tab","aria-selected":p,"aria-disabled":r,tabIndex:p?0:-1,onClick:w,onKeyDown:v,disabled:r,className:g(x,yC[d],h,I,a),children:[n&&jsxRuntime.jsx("span",{className:g("shrink-0",xm[u]),children:n}),jsxRuntime.jsx("span",{children:t}),o&&jsxRuntime.jsx("span",{className:g("shrink-0",xm[u]),children:o})]})}Cm.displayName="TabsTrigger";function km({value:e,children:t,className:r,forceMount:n=false}){let{value:o}=ra(),a=o===e;return !a&&!n?null:jsxRuntime.jsx("div",{role:"tabpanel",hidden:!a,tabIndex:0,className:g("mt-4 focus:outline-none focus-visible:ring-2 focus-visible:ring-offset-2 focus-visible:ring-blue-500 rounded-md",!a&&"hidden",r),children:t})}km.displayName="TabsContent";function CC({className:e}){return jsxRuntime.jsx("svg",{className:e,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",children:jsxRuntime.jsx("path",{d:"M9 12L11 14L15 10M21 12C21 16.97 16.97 21 12 21C7.03 21 3 16.97 3 12C3 7.03 7.03 3 12 3C16.97 3 21 7.03 21 12Z",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})})}function kC({className:e}){return jsxRuntime.jsx("svg",{className:e,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",children:jsxRuntime.jsx("path",{d:"M12 8V12M12 16H12.01M21 12C21 16.97 16.97 21 12 21C7.03 21 3 16.97 3 12C3 7.03 7.03 3 12 3C16.97 3 21 7.03 21 12Z",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})})}function wC({className:e}){return jsxRuntime.jsx("svg",{className:e,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",children:jsxRuntime.jsx("path",{d:"M12 9V13M12 17H12.01M10.29 3.86L1.82 18C1.65 18.3 1.55 18.65 1.55 18.99C1.55 19.34 1.64 19.69 1.81 19.99C1.99 20.29 2.24 20.55 2.54 20.72C2.84 20.901 3.18 20.99 3.53 21H20.47C20.82 20.99 21.16 20.901 21.46 20.72C21.76 20.55 22.01 20.29 22.19 19.99C22.36 19.69 22.449 19.34 22.448 18.99C22.447 18.65 22.35 18.3 22.18 18L13.71 3.86C13.53 3.57 13.28 3.32 12.98 3.15C12.68 2.99 12.34 2.9 12 2.9C11.66 2.9 11.32 2.99 11.02 3.15C10.72 3.32 10.47 3.57 10.29 3.86Z",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})})}function wm({className:e}){return jsxRuntime.jsx("svg",{className:e,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",children:jsxRuntime.jsx("path",{d:"M13 16H12V12H11M12 8H12.01M21 12C21 16.97 16.97 21 12 21C7.03 21 3 16.97 3 12C3 7.03 7.03 3 12 3C16.97 3 21 7.03 21 12Z",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})})}function NC({className:e}){return jsxRuntime.jsx("svg",{className:e,viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",children:jsxRuntime.jsx("path",{d:"M4 4L12 12M12 4L4 12",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})})}var SC={success:CC,error:kC,warning:wC,info:wm,default:wm},RC={success:{solid:"bg-green-600 text-white border-green-600",outlined:"bg-white text-green-700 border-green-600 dark:bg-gray-900 dark:text-green-400",soft:"bg-green-50 text-green-700 border-green-200 dark:bg-green-900/20 dark:text-green-400 dark:border-green-800"},error:{solid:"bg-red-600 text-white border-red-600",outlined:"bg-white text-red-700 border-red-600 dark:bg-gray-900 dark:text-red-400",soft:"bg-red-50 text-red-700 border-red-200 dark:bg-red-900/20 dark:text-red-400 dark:border-red-800"},warning:{solid:"bg-yellow-500 text-white border-yellow-500",outlined:"bg-white text-yellow-700 border-yellow-500 dark:bg-gray-900 dark:text-yellow-400",soft:"bg-yellow-50 text-yellow-700 border-yellow-200 dark:bg-yellow-900/20 dark:text-yellow-400 dark:border-yellow-800"},info:{solid:"bg-blue-600 text-white border-blue-600",outlined:"bg-white text-blue-700 border-blue-600 dark:bg-gray-900 dark:text-blue-400",soft:"bg-blue-50 text-blue-700 border-blue-200 dark:bg-blue-900/20 dark:text-blue-400 dark:border-blue-800"},default:{solid:"bg-gray-700 text-white border-gray-700",outlined:"bg-white text-gray-700 border-gray-300 dark:bg-gray-900 dark:text-gray-300",soft:"bg-gray-50 text-gray-700 border-gray-200 dark:bg-gray-800 dark:text-gray-300 dark:border-gray-700"}},TC={success:"text-green-600 dark:text-green-400",error:"text-red-600 dark:text-red-400",warning:"text-yellow-600 dark:text-yellow-400",info:"text-blue-600 dark:text-blue-400",default:"text-gray-600 dark:text-gray-400"};function Sm({children:e,title:t,description:r,type:n="default",variant:o="soft",icon:a,action:s,onClose:l,closable:i=true,className:c,...d}){let u=SC[n],f=jsxRuntime.jsx(u,{className:"w-5 h-5"}),m=e??r;return jsxRuntime.jsxs("div",{role:"alert",className:g("flex items-start gap-3 p-4 rounded-lg border shadow-lg min-w-[320px] max-w-md","animate-in slide-in-from-top-2 fade-in duration-300",RC[n][o],c),...d,children:[jsxRuntime.jsx("div",{className:g("flex-shrink-0 mt-0.5",o==="solid"?"text-white":TC[n]),children:a??f}),jsxRuntime.jsxs("div",{className:"flex-1 min-w-0",children:[t&&jsxRuntime.jsx("div",{className:"font-semibold text-sm mb-1",children:t}),m&&jsxRuntime.jsx("div",{className:"text-sm opacity-90",children:m}),s&&jsxRuntime.jsx("div",{className:"mt-3",children:s})]}),i&&jsxRuntime.jsx("button",{type:"button",onClick:l,className:g("flex-shrink-0 rounded-md p-1 transition-colors hover:bg-black/10 dark:hover:bg-white/10","focus:outline-none focus-visible:ring-2 focus-visible:ring-offset-2 focus-visible:ring-current",o==="solid"?"text-white":""),"aria-label":"Close notification",children:jsxRuntime.jsx(NC,{className:"w-4 h-4"})})]})}Sm.displayName="Toast";var LC={default:"bg-gray-900 text-white dark:bg-gray-700",light:"bg-white text-gray-900 border border-gray-200 shadow-lg dark:bg-gray-800 dark:text-white dark:border-gray-600",error:"bg-red-600 text-white",success:"bg-green-600 text-white",warning:"bg-yellow-500 text-white",info:"bg-blue-600 text-white"},EC={default:{top:"border-t-gray-900 dark:border-t-gray-700",bottom:"border-b-gray-900 dark:border-b-gray-700",left:"border-l-gray-900 dark:border-l-gray-700",right:"border-r-gray-900 dark:border-r-gray-700"},light:{top:"border-t-white dark:border-t-gray-800",bottom:"border-b-white dark:border-b-gray-800",left:"border-l-white dark:border-l-gray-800",right:"border-r-white dark:border-r-gray-800"},error:{top:"border-t-red-600",bottom:"border-b-red-600",left:"border-l-red-600",right:"border-r-red-600"},success:{top:"border-t-green-600",bottom:"border-b-green-600",left:"border-l-green-600",right:"border-r-green-600"},warning:{top:"border-t-yellow-500",bottom:"border-b-yellow-500",left:"border-l-yellow-500",right:"border-r-yellow-500"},info:{top:"border-t-blue-600",bottom:"border-b-blue-600",left:"border-l-blue-600",right:"border-r-blue-600"}},MC={sm:"px-2 py-1 text-xs",md:"px-3 py-1.5 text-sm",lg:"px-4 py-2 text-base"},IC={sm:"border-4",md:"border-[5px]",lg:"border-[6px]"},AC={top:"bottom-full left-1/2 -translate-x-1/2 mb-2",bottom:"top-full left-1/2 -translate-x-1/2 mt-2",left:"right-full top-1/2 -translate-y-1/2 mr-2",right:"left-full top-1/2 -translate-y-1/2 ml-2"},zC={top:"top-full left-1/2 -translate-x-1/2 border-l-transparent border-r-transparent border-b-transparent",bottom:"bottom-full left-1/2 -translate-x-1/2 border-l-transparent border-r-transparent border-t-transparent",left:"left-full top-1/2 -translate-y-1/2 border-t-transparent border-b-transparent border-r-transparent",right:"right-full top-1/2 -translate-y-1/2 border-t-transparent border-b-transparent border-l-transparent"};function Ht({children:e,content:t,position:r="top",variant:n="default",size:o="md",trigger:a="hover",open:s,delay:l=0,showArrow:i=true,maxWidth:c="max-w-xs",className:d,contentClassName:u,disabled:f=false,...m}){let[p,w]=el.useState(false),v=el.useRef(null),x=el.useCallback(()=>{f||(l>0?v.current=setTimeout(()=>w(true),l):w(true));},[l,f]),h=el.useCallback(()=>{v.current&&(clearTimeout(v.current),v.current=null),w(false);},[]),I=el.useCallback(()=>{f||w(R=>!R);},[f]),S=a==="manual"?s:p,L={hover:{onMouseEnter:x,onMouseLeave:h,onFocus:x,onBlur:h},click:{onClick:I},manual:{}}[a];return jsxRuntime.jsxs("div",{className:g("relative inline-flex",d),...L,...m,children:[e,S&&!f&&jsxRuntime.jsxs("div",{role:"tooltip",className:g("absolute z-50 whitespace-normal wrap-break-word rounded-md","transition-opacity duration-150",AC[r],LC[n],MC[o],c,u),children:[t,i&&jsxRuntime.jsx("span",{className:g("absolute w-0 h-0 border-solid",IC[o],zC[r],EC[n][r]),"aria-hidden":"true"})]})]})}Ht.displayName="Tooltip";function HC(e){switch(e){case "bordered":return "border-t border-gray-200 dark:border-gray-700 bg-white dark:bg-gray-900 text-gray-700 dark:text-gray-300";case "minimal":return "bg-transparent text-gray-600 dark:text-gray-400";case "dark":return "bg-gray-900 text-gray-300";default:return "bg-gray-100 dark:bg-gray-800 text-gray-700 dark:text-gray-300"}}function BC(e){switch(e){case "sm":return "py-6";case "lg":return "py-16";default:return "py-10"}}function Pm({variant:e="default",size:t="md",sticky:r=false,className:n,children:o,...a}){return jsxRuntime.jsx("footer",{className:g(HC(e),BC(t),r&&"sticky bottom-0 z-40",n),...a,children:jsxRuntime.jsx("div",{className:"container mx-auto px-4",children:o})})}Pm.displayName="Footer";function VC(e){switch(e){case 1:return "grid-cols-1";case 2:return "grid-cols-1 sm:grid-cols-2";case 3:return "grid-cols-1 sm:grid-cols-2 lg:grid-cols-3";case 4:return "grid-cols-1 sm:grid-cols-2 lg:grid-cols-4";case 5:return "grid-cols-1 sm:grid-cols-2 lg:grid-cols-5";case 6:return "grid-cols-2 sm:grid-cols-3 lg:grid-cols-6";default:return ""}}function Dm({title:e,titleClassName:t,columns:r,className:n,children:o,...a}){return jsxRuntime.jsxs("div",{className:g(r&&"grid gap-8",VC(r),n),...a,children:[e&&jsxRuntime.jsx("h3",{className:g("text-sm font-semibold uppercase tracking-wider text-gray-900 dark:text-white",r&&"col-span-full",t),children:e}),o]})}Dm.displayName="FooterSection";function Lm({title:e,titleClassName:t,className:r,children:n,...o}){return jsxRuntime.jsxs("div",{className:g("flex flex-col gap-3",r),...o,children:[e&&jsxRuntime.jsx("h4",{className:g("text-sm font-semibold uppercase tracking-wider text-gray-900 dark:text-white",t),children:e}),n]})}Lm.displayName="FooterColumn";function Em({external:e=false,className:t,children:r,...n}){return jsxRuntime.jsx("a",{className:g("text-sm text-gray-600 dark:text-gray-400 hover:text-gray-900 dark:hover:text-white transition-colors",t),target:e?"_blank":void 0,rel:e?"noopener noreferrer":void 0,...n,children:r})}Em.displayName="FooterLink";function Mm({copyright:e,className:t,children:r,...n}){return jsxRuntime.jsxs("div",{className:g("mt-8 border-t border-gray-200 dark:border-gray-700 pt-6 flex flex-col sm:flex-row items-center justify-between gap-4",t),...n,children:[e&&jsxRuntime.jsx("p",{className:"text-sm text-gray-500 dark:text-gray-400",children:e}),r]})}Mm.displayName="FooterBottom";function Im({className:e,children:t,...r}){return jsxRuntime.jsx("div",{className:g("flex items-center gap-4",e),...r,children:t})}Im.displayName="FooterSocial";function Am({icon:e,label:t,className:r,...n}){return jsxRuntime.jsx("a",{className:g("text-gray-500 dark:text-gray-400 hover:text-gray-900 dark:hover:text-white transition-colors",r),target:"_blank",rel:"noopener noreferrer","aria-label":t,...n,children:e})}Am.displayName="FooterSocialLink";var YC=4.5,qC=48,Wm=false,jC=el.memo(function({points:t}){return jsxRuntime.jsx("g",{children:t.map(r=>jsxRuntime.jsx("circle",{cx:r.cx,cy:r.cy,r:r.r,fill:r.color,fillOpacity:.85,strokeWidth:2,className:"stroke-white dark:stroke-gray-800"},`${r.seriesKey}-${r.index}`))})});function ZC({width:e,height:t,data:r,resolvedSeries:n,x:o,y:a,grid:s,size:l,bubble:i,trendLine:c,quadrants:d,pointRadius:u,margin:f,tooltip:m,onPointClick:p,plotLabel:w,formatValue:v,formatX:x}){let[h,I]=el.useState(null),S=el.useMemo(()=>{let T=n.filter(E=>!E.hidden),y=T.map(E=>E.key),M=rr({width:e,height:t,data:r,x:{...o,scale:o.scale==="time"?"time":"linear"},y:a,bounds:Yt(fr(r,y)),margin:f,formatValue:v,formatX:x}),k=i?fr(r,[i.key]):[],z=i?Yt(k):null,[H,P]=i?.range??[4,14],B=E=>{if(!i||!z)return u;let N=Ee(E,i.key);if(N===null)return H;let[W,F]=z,K=F===W?1:(N-W)/(F-W);return Math.sqrt(H*H+K*(P*P-H*H))},C=[];T.forEach(E=>{r.forEach((N,W)=>{let F=Ee(N,E.key),K=M.categoryPositions[W];F===null||!Number.isFinite(K)||C.push({seriesKey:E.key,seriesLabel:Kt(E),color:E.color,index:W,cx:K,cy:M.valueScale(F),r:B(N),xValue:_r(M.xValues[W]),yValue:F});});});let b=null;if(c&&C.length>1){let E=C.length,N=C.reduce((A,D)=>A+D.xValue,0),W=C.reduce((A,D)=>A+D.yValue,0),F=C.reduce((A,D)=>A+D.xValue*D.yValue,0),K=C.reduce((A,D)=>A+D.xValue*D.xValue,0),j=E*K-N*N;if(j!==0){let A=(E*F-N*W)/j,D=(W-A*N)/E,V=C.map(G=>G.xValue),[O,_]=[Math.min(...V),Math.max(...V)],X=C.map(G=>G.cx);b={x1:Math.min(...X),y1:M.valueScale(A*O+D),x2:Math.max(...X),y2:M.valueScale(A*_+D)};}}return {visible:T,points:C,trend:b,xTicks:M.categoryTicks,yTicks:M.valueTicks,valueScale:M.valueScale,positions:M.categoryPositions,innerWidth:M.innerWidth,innerHeight:M.innerHeight,margin:M.margin,xValues:M.xValues}},[r,n,o,a,e,t,f,i,c,u,v,x]),L=el.useCallback(T=>{if(m===false||S.points.length===0)return;let y=T.currentTarget.getBoundingClientRect(),M=T.clientX-y.left-S.margin.left,k=T.clientY-y.top-S.margin.top,z=null,H=qC;for(let P of S.points){let B=Math.hypot(P.cx-M,P.cy-k);B<H&&(H=B,z=P);}I(z);},[m,S.points,S.margin]),R=el.useCallback(()=>{!p||!h||p({seriesKey:h.seriesKey,seriesLabel:h.seriesLabel,color:h.color,value:h.yValue,formattedValue:v(h.yValue),datum:r[h.index],index:h.index,x:S.xValues[h.index]});},[p,h,v,r,S.xValues]);return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsxs("svg",{width:e,height:t,role:"img","aria-label":w??S.visible.map(T=>Kt(T)).join(", "),tabIndex:0,className:"touch-none focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-blue-500",onPointerMove:L,onPointerLeave:()=>I(null),onBlur:()=>I(null),onClick:R,children:[jsxRuntime.jsxs("g",{transform:`translate(${S.margin.left}, ${S.margin.top})`,children:[jsxRuntime.jsx(_t,{width:S.innerWidth,height:S.innerHeight,horizontal:s==="y"||s==="both"?S.yTicks.map(T=>T.offset):void 0,vertical:s==="x"||s==="both"?S.xTicks.map(T=>T.offset):void 0}),d?.y!==void 0?jsxRuntime.jsx("line",{x1:0,y1:S.valueScale(d.y),x2:S.innerWidth,y2:S.valueScale(d.y),stroke:"var(--color-chart-muted)",strokeWidth:1,strokeDasharray:"4 4"}):null,S.trend?jsxRuntime.jsx("line",{x1:S.trend.x1,y1:S.trend.y1,x2:S.trend.x2,y2:S.trend.y2,stroke:"var(--color-chart-muted)",strokeWidth:1.5,strokeDasharray:"4 4"}):null,jsxRuntime.jsx(jC,{points:S.points}),h?jsxRuntime.jsx("circle",{cx:h.cx,cy:h.cy,r:h.r+3,fill:"none",stroke:h.color,strokeWidth:2,"aria-hidden":"true"}):null]}),jsxRuntime.jsx("g",{transform:`translate(${S.margin.left}, ${S.margin.top+S.innerHeight})`,children:o.hidden?null:jsxRuntime.jsx(Ue,{orientation:"bottom",ticks:S.xTicks,length:S.innerWidth,label:o.label,size:l})}),jsxRuntime.jsx("g",{transform:`translate(${S.margin.left}, ${S.margin.top})`,children:a?.hidden?null:jsxRuntime.jsx(Ue,{orientation:"left",ticks:S.yTicks,length:S.innerHeight,showLine:false,label:a?.label,size:l})})]}),h&&m!==false?jsxRuntime.jsx(dt,{x:S.margin.left+h.cx,y:S.margin.top+h.cy,containerWidth:e,children:typeof m=="function"?m({x:S.xValues[h.index],xLabel:x(S.xValues[h.index],h.index),index:h.index,points:[{seriesKey:h.seriesKey,seriesLabel:h.seriesLabel,color:h.color,value:h.yValue,formattedValue:v(h.yValue),datum:r[h.index]}]}):jsxRuntime.jsx(Nr,{title:`${o.label??o.key} ${x(S.xValues[h.index],h.index)}`,points:[{seriesKey:h.seriesKey,seriesLabel:h.seriesLabel,color:h.color,value:h.yValue,formattedValue:v(h.yValue),datum:r[h.index]}]})}):null]})}function QC({data:e,series:t,x:r,y:n,height:o=280,width:a,size:s="md",grid:l="both",legend:i,tooltip:c=true,tableView:d=false,emphasis:u,title:f,description:m,loading:p=false,emptyState:w,onPointClick:v,bubble:x,trendLine:h=false,quadrants:I,pointRadius:S=YC,legendToggle:L=true,margin:R,locale:T,plotLabel:y,className:M,...k}){let[z,H]=el.useState(()=>new Set);t.length>3&&!Wm&&(Wm=true,console.warn(`[@synertech/ui] A ScatterChart was given ${t.length} series. Any two marks can sit side by side here, and only the first ${3} palette slots stay tellable apart under that test: facet the chart instead.`));let P=el.useMemo(()=>t.map((F,K)=>({...F,hidden:F.hidden||z.has(F.key),color:Lr(F,K,u)})),[t,z,u]),B=el.useMemo(()=>n?.format??(F=>nt(F,T)),[n?.format,T]),C=el.useMemo(()=>r.format??(F=>r.scale==="time"?Ze(F instanceof Date?F:new Date(_r(F)),T):nt(_r(F),T)),[r.format,r.scale,T]),b=el.useCallback(F=>{H(K=>{let j=new Set(K);return j.has(F)?j.delete(F):j.add(F),j});},[]),E=i===void 0?t.length>=2:i!==false,N=typeof i=="string"?i:"bottom",W=P.filter(F=>!F.hidden).length;return jsxRuntime.jsx(lt,{title:f,description:m,height:o,width:a,size:s,loading:p,empty:e.length===0||W===0,emptyState:w,tableView:d,legendPosition:N,legend:E?jsxRuntime.jsx(Xt,{items:$r(P,u),position:N,marker:"dot",size:s,onToggle:L?b:void 0}):void 0,table:d?jsxRuntime.jsx(zt,{data:e,series:P,xKey:r.key,xLabel:r.label??r.key,formatX:C,formatValue:B,caption:typeof f=="string"?f:void 0}):void 0,className:M,...k,children:({width:F})=>jsxRuntime.jsx(ZC,{width:F,height:o,data:e,resolvedSeries:P,x:r,y:n,grid:l,size:s,bubble:x,trendLine:h,quadrants:I,pointRadius:S,margin:R,tooltip:c,onPointClick:v,plotLabel:y,formatValue:B,formatX:C})})}var Bm="se-grid-pattern",Vm=el.memo(function({gridSize:t,zoom:r}){let n=t*r;return jsxRuntime.jsxs("svg",{className:"absolute inset-0 w-full h-full pointer-events-none","aria-hidden":"true",children:[jsxRuntime.jsx("defs",{children:jsxRuntime.jsx("pattern",{id:Bm,width:n,height:n,patternUnits:"userSpaceOnUse",children:jsxRuntime.jsx("circle",{cx:1,cy:1,r:1,className:"fill-gray-300 dark:fill-gray-600"})})}),jsxRuntime.jsx("rect",{width:"100%",height:"100%",fill:`url(#${Bm})`})]})});function Xn(e,t){return e.collapsed?40:e.height?e.height:40+(e.notes?24:0)+e.fields.length*32+(t?36:0)}function na(e,t){return 40+(t?24:0)+e*32+32/2}function Fm(e,t,r){let n=e.fields.findIndex(i=>i.id===t);if(n===-1)return null;let o=e.width??260,a=!!e.notes,s=e.y+na(n,a);return {x:r==="left"?e.x+0:e.x+o-0,y:s}}function oc(e,t){return Math.round(e/t)*t}function Ja(e,t,r){return Math.min(r,Math.max(t,e))}function es(e,t,r,n){return {x:(e-n.left-r.x)/r.zoom,y:(t-n.top-r.y)/r.zoom}}function gi(e,t,r,n){let o=Math.abs(r-e),a=Math.max(50,o*.5),s=e+a,l=t,i=r-a;return `M ${e} ${t} C ${s} ${l}, ${i} ${n}, ${r} ${n}`}function Om(e,t,r,n,o=40){if(e.length===0)return {x:0,y:0,zoom:1};let a=1/0,s=1/0,l=-1/0,i=-1/0;for(let p of e){let w=p.width??260,v=Xn(p,n);a=Math.min(a,p.x),s=Math.min(s,p.y),l=Math.max(l,p.x+w),i=Math.max(i,p.y+v);}let c=l-a+o*2,d=i-s+o*2,u=Math.min(t/c,r/d,1),f=(t-c*u)/2-(a-o)*u,m=(r-d*u)/2-(s-o)*u;return {x:f,y:m,zoom:u}}var rs=["text","varchar","char","int2","int4","int8","serial","bigserial","float4","float8","numeric","decimal","bool","date","time","timestamp","timestamptz","uuid","json","jsonb","bytea"];function $m(){return `table-${Date.now()}-${Math.random().toString(36).slice(2,8)}`}function ts(){return `field-${Date.now()}-${Math.random().toString(36).slice(2,8)}`}function ac(){return `rel-${Date.now()}-${Math.random().toString(36).slice(2,8)}`}function sc(e="new_field"){return {id:ts(),name:e,type:"text",nullable:true}}function ic(e,t,r="new_table"){return {id:$m(),name:r,x:e,y:t,fields:[{id:ts(),name:"id",type:"serial",primaryKey:true},{id:ts(),name:"createdAt",type:"timestamp"},{id:ts(),name:"updatedAt",type:"timestamp"}]}}var pi=()=>jsxRuntime.jsxs("svg",{className:"w-3.5 h-3.5 text-indigo-500 flex-shrink-0",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",children:[jsxRuntime.jsx("path",{d:"M10 1l2 2-5 5M8.5 4.5L11 7"}),jsxRuntime.jsx("circle",{cx:"4.5",cy:"11.5",r:"3"})]}),Xm=()=>jsxRuntime.jsxs("svg",{className:"w-3.5 h-3.5 flex-shrink-0",viewBox:"0 0 16 16",fill:"currentColor",children:[jsxRuntime.jsx("circle",{cx:"8",cy:"8",r:"6",className:"fill-blue-500"}),jsxRuntime.jsx("path",{d:"M5 8h6M8 5l3 3-3 3",stroke:"white",strokeWidth:"1.5",fill:"none",strokeLinecap:"round",strokeLinejoin:"round"})]}),nk=({collapsed:e})=>jsxRuntime.jsx("svg",{className:"w-3.5 h-3.5",viewBox:"0 0 16 16",fill:"currentColor",children:e?jsxRuntime.jsx("path",{d:"M6 3l5 5-5 5V3z"}):jsxRuntime.jsx("path",{d:"M3 6l5 5 5-5H3z"})}),Gm=()=>jsxRuntime.jsx("svg",{className:"w-3.5 h-3.5 text-amber-500 flex-shrink-0",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",children:jsxRuntime.jsx("path",{d:"M3 2v12M7 4h6M7 8h4M7 12h5"})}),Km=()=>jsxRuntime.jsx("svg",{className:"w-3.5 h-3.5 text-purple-500 flex-shrink-0",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",children:jsxRuntime.jsx("path",{d:"M4 2v8a4 4 0 008 0V2"})}),ok=()=>jsxRuntime.jsx("svg",{className:"w-3 h-3",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",children:jsxRuntime.jsx("path",{d:"M4 8h8"})}),ak=()=>jsxRuntime.jsxs("svg",{className:"w-3 h-3 text-gray-300",viewBox:"0 0 16 16",fill:"currentColor",children:[jsxRuntime.jsx("circle",{cx:"5",cy:"4",r:"1.5"}),jsxRuntime.jsx("circle",{cx:"11",cy:"4",r:"1.5"}),jsxRuntime.jsx("circle",{cx:"5",cy:"8",r:"1.5"}),jsxRuntime.jsx("circle",{cx:"11",cy:"8",r:"1.5"}),jsxRuntime.jsx("circle",{cx:"5",cy:"12",r:"1.5"}),jsxRuntime.jsx("circle",{cx:"11",cy:"12",r:"1.5"})]}),sk=el.memo(function({field:t,tableId:r,editable:n,readOnly:o,disabled:a,onFieldChange:s}){let[l,i]=el.useState(false),[c,d]=el.useState(t.defaultValue??""),u=n&&!o&&!a,f=()=>{i(false),s?.(r,t.id,{defaultValue:c||void 0});};return u?l?jsxRuntime.jsx("input",{className:"text-xs w-16 text-emerald-500 bg-transparent border-b border-emerald-300 outline-none focus:ring-0 p-0 flex-shrink-0","aria-label":`Default value for ${t.name}`,value:c,onChange:m=>d(m.target.value),onBlur:f,onKeyDown:m=>{m.key==="Enter"&&f(),m.key==="Escape"&&i(false);},onMouseDown:m=>m.stopPropagation(),autoFocus:true}):t.defaultValue?jsxRuntime.jsxs("button",{type:"button",className:"text-xs text-emerald-500 flex-shrink-0 truncate max-w-16 cursor-pointer",onClick:m=>{m.stopPropagation(),d(t.defaultValue??""),i(true);},onMouseDown:m=>m.stopPropagation(),title:`Default: ${t.defaultValue}`,children:["= ",t.defaultValue]}):jsxRuntime.jsx("button",{type:"button",className:"text-xs text-gray-300 flex-shrink-0 opacity-0 group-hover:opacity-30 hover:!opacity-100 cursor-pointer transition-opacity",onClick:m=>{m.stopPropagation(),d(""),i(true);},onMouseDown:m=>m.stopPropagation(),title:"Set default value",children:"= \u2205"}):t.defaultValue?jsxRuntime.jsxs("span",{className:"text-xs text-emerald-500 flex-shrink-0 truncate max-w-16",title:`Default: ${t.defaultValue}`,children:["= ",t.defaultValue]}):null}),Ym=el.memo(function({table:t,selected:r,disabled:n,readOnly:o,editable:a,dropTarget:s,fieldTypes:l,onTableNameChange:i,onTableNotesChange:c,onToggleCollapse:d,onFieldChange:u,onFieldAdd:f,onFieldRemove:m,onFieldReorder:p,onResizeStart:w}){let v=t.width??260,x=t.collapsed??false,h=l.length>0?l:rs,[I,S]=el.useState(null),[L,R]=el.useState(null),T=el.useRef(null),y=el.useCallback(b=>{i?.(t.id,b.target.value);},[t.id,i]),M=el.useCallback((b,E)=>{u?.(t.id,b,{name:E});},[t.id,u]),k=el.useCallback((b,E)=>{u?.(t.id,b,{type:E});},[t.id,u]),z=el.useCallback((b,E)=>{u?.(t.id,b,{primaryKey:!E});},[t.id,u]),H=el.useCallback((b,E)=>{u?.(t.id,b,{nullable:!E});},[t.id,u]),P=el.useCallback((b,E)=>{u?.(t.id,b,{indexed:!E});},[t.id,u]),B=el.useCallback((b,E)=>{u?.(t.id,b,{unique:!E});},[t.id,u]),C=el.useCallback(()=>{f?.(t.id);},[t.id,f]);return jsxRuntime.jsxs("div",{"data-table-id":t.id,className:g("absolute bg-white dark:bg-gray-800 border-2 border-dashed rounded-lg shadow-sm cursor-grab active:cursor-grabbing",t.height?"flex flex-col":void 0,s?"border-green-400 shadow-green-100 dark:shadow-green-900/30 shadow-md":r?"border-blue-500 shadow-blue-100 dark:shadow-blue-900/30":"border-gray-300 dark:border-gray-600",n&&"opacity-60",t.locked&&"!cursor-default"),style:{left:t.x,top:t.y,width:v,height:t.height,userSelect:"none",overflow:t.height?"hidden":void 0},children:[jsxRuntime.jsxs("div",{className:g("flex items-center justify-between px-3 gap-2","bg-gray-50 dark:bg-gray-700 border-b border-gray-200 dark:border-gray-600"),style:{height:40},children:[a&&!o&&!n?jsxRuntime.jsx("input",{className:"flex-1 min-w-0 text-sm font-semibold text-gray-800 dark:text-gray-100 bg-transparent border-none outline-none focus:ring-0 p-0 truncate cursor-text","aria-label":"Table name",value:t.name,onChange:y,onMouseDown:b=>b.stopPropagation()}):jsxRuntime.jsx("span",{className:"flex-1 min-w-0 text-sm font-semibold text-gray-800 dark:text-gray-100 truncate",children:t.name}),jsxRuntime.jsx("button",{type:"button",className:"flex-shrink-0 p-1 rounded hover:bg-gray-200 dark:hover:bg-gray-600 text-gray-500 dark:text-gray-400",onClick:b=>{b.stopPropagation(),d?.(t.id);},onMouseDown:b=>b.stopPropagation(),"aria-label":x?"Expand table":"Collapse table",children:jsxRuntime.jsx(nk,{collapsed:x})})]}),!x&&(a&&!o&&!n?jsxRuntime.jsx("div",{className:"px-3 border-b border-gray-100 dark:border-gray-700 flex items-center",style:{height:24},children:jsxRuntime.jsx("input",{className:"w-full text-xs italic text-gray-400 dark:text-gray-500 bg-transparent border-none outline-none focus:ring-0 p-0 placeholder-gray-400 dark:placeholder-gray-500","aria-label":"Table notes",placeholder:"Add notes...",value:t.notes??"",onChange:b=>c?.(t.id,b.target.value),onMouseDown:b=>b.stopPropagation()})}):t.notes?jsxRuntime.jsx("div",{className:"px-3 border-b border-gray-100 dark:border-gray-700 flex items-center",style:{height:24},children:jsxRuntime.jsx("span",{className:"text-xs italic text-gray-400 dark:text-gray-500 truncate",children:t.notes})}):null),!x&&jsxRuntime.jsxs("div",{className:t.height?"overflow-y-auto flex-1 min-h-0":void 0,children:[t.fields.map((b,E)=>jsxRuntime.jsxs("div",{"data-field-id":b.id,"data-table-id":t.id,className:g("flex items-center gap-1.5 pr-2 relative group",a&&!o&&!n?"pl-[18px]":"pl-2","border-b border-gray-100 dark:border-gray-700 last:border-b-0",s?"bg-blue-50/50 dark:bg-blue-900/10":"hover:bg-gray-50 dark:hover:bg-gray-750",I===E&&"opacity-40",L===E&&"!border-t-2 !border-t-blue-400"),style:{height:32},draggable:a&&!o&&!n,onDragStart:N=>{!a||o||n||(N.stopPropagation(),T.current=E,S(E),N.dataTransfer.effectAllowed="move",N.dataTransfer.setData("text/plain",String(E)));},onDragOver:N=>{T.current!==null&&(N.preventDefault(),N.stopPropagation(),R(E));},onDragLeave:()=>{L===E&&R(null);},onDrop:N=>{N.preventDefault(),N.stopPropagation(),T.current!==null&&T.current!==E&&p?.(t.id,T.current,E),T.current=null,S(null),R(null);},onDragEnd:()=>{T.current=null,S(null),R(null);},children:[jsxRuntime.jsx("div",{"data-connection-side":"left","data-field-id":b.id,"data-table-id":t.id,className:g("absolute -left-[5px] w-2.5 h-2.5 rounded-full border-2 border-white dark:border-gray-800 cursor-crosshair z-10 transition-all",s?"opacity-100 bg-green-400 scale-150 shadow-[0_0_6px_rgba(74,222,128,0.6)]":"opacity-0 group-hover:opacity-100 bg-blue-400"),style:{top:32/2-5}}),a&&!o&&!n&&jsxRuntime.jsx("span",{className:"absolute left-[3px] cursor-grab active:cursor-grabbing opacity-0 group-hover:opacity-100 transition-opacity z-10",style:{top:32/2-6},children:jsxRuntime.jsx(ak,{})}),a&&!o&&!n?jsxRuntime.jsx("button",{type:"button",className:g("w-4 text-xs font-bold flex-shrink-0 text-center cursor-pointer",b.nullable?"text-gray-400":"text-transparent"),onClick:N=>{N.stopPropagation(),H(b.id,b.nullable??false);},onMouseDown:N=>N.stopPropagation(),title:b.nullable?"Nullable":"Not nullable",children:"?"}):jsxRuntime.jsx("span",{className:g("w-4 text-xs font-bold flex-shrink-0 text-center",b.nullable?"text-gray-400":"text-transparent"),children:b.nullable?"?":""}),b.primaryKey&&b.foreignKey?jsxRuntime.jsxs("span",{className:"flex items-center gap-0.5 flex-shrink-0",children:[a&&!o&&!n?jsxRuntime.jsx("button",{type:"button",className:"flex-shrink-0 cursor-pointer",onClick:N=>{N.stopPropagation(),z(b.id,true);},onMouseDown:N=>N.stopPropagation(),title:"Primary Key (click to remove)",children:jsxRuntime.jsx(pi,{})}):jsxRuntime.jsx(pi,{}),jsxRuntime.jsx(Xm,{})]}):b.primaryKey?a&&!o&&!n?jsxRuntime.jsx("button",{type:"button",className:"flex-shrink-0 cursor-pointer",onClick:N=>{N.stopPropagation(),z(b.id,true);},onMouseDown:N=>N.stopPropagation(),title:"Primary Key (click to remove)",children:jsxRuntime.jsx(pi,{})}):jsxRuntime.jsx(pi,{}):b.foreignKey?jsxRuntime.jsx(Xm,{}):a&&!o&&!n?jsxRuntime.jsx("button",{type:"button",className:"w-3.5 h-3.5 flex-shrink-0 rounded text-gray-300 hover:text-indigo-400 transition-colors cursor-pointer",onClick:N=>{N.stopPropagation(),z(b.id,false);},onMouseDown:N=>N.stopPropagation(),title:"Set as Primary Key","aria-label":"Set as primary key",children:jsxRuntime.jsxs("svg",{className:"w-3.5 h-3.5",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",opacity:"0.3",children:[jsxRuntime.jsx("path",{d:"M10 1l2 2-5 5M8.5 4.5L11 7"}),jsxRuntime.jsx("circle",{cx:"4.5",cy:"11.5",r:"3"})]})}):jsxRuntime.jsx("span",{className:"w-3.5 flex-shrink-0"}),a&&!o&&!n?jsxRuntime.jsx("input",{className:g("flex-1 min-w-0 text-xs bg-transparent border-none outline-none focus:ring-0 p-0 truncate cursor-text",b.primaryKey?"text-blue-600 dark:text-blue-400 font-medium":"text-gray-700 dark:text-gray-300"),"aria-label":"Field name",value:b.name,onChange:N=>M(b.id,N.target.value),onMouseDown:N=>N.stopPropagation()}):jsxRuntime.jsx("span",{className:g("flex-1 min-w-0 text-xs truncate",b.primaryKey?"text-blue-600 dark:text-blue-400 font-medium":"text-gray-700 dark:text-gray-300"),children:b.name}),a&&!o&&!n?jsxRuntime.jsxs("select",{className:"text-xs text-gray-400 dark:text-gray-500 bg-transparent border-none outline-none focus:ring-0 p-0 cursor-pointer text-right",value:b.type,onChange:N=>k(b.id,N.target.value),onMouseDown:N=>N.stopPropagation(),children:[h.map(N=>jsxRuntime.jsx("option",{value:N,children:N},N)),!h.includes(b.type)&&jsxRuntime.jsx("option",{value:b.type,children:b.type})]}):jsxRuntime.jsx("span",{className:"text-xs text-gray-400 dark:text-gray-500 flex-shrink-0",children:b.type}),jsxRuntime.jsx(sk,{field:b,tableId:t.id,editable:a,readOnly:o,disabled:n,onFieldChange:u}),b.indexed&&jsxRuntime.jsx(Gm,{}),b.unique&&jsxRuntime.jsx(Km,{}),a&&!o&&!n&&jsxRuntime.jsxs("div",{className:"absolute right-1 top-0 bottom-0 flex items-center gap-0.5 opacity-0 group-hover:opacity-100 transition-opacity bg-gradient-to-l from-white via-white to-transparent dark:from-gray-800 dark:via-gray-800 pl-4 pr-1 z-10",children:[jsxRuntime.jsx("button",{type:"button",className:g("cursor-pointer transition-opacity",b.indexed?"opacity-100":"opacity-30 hover:opacity-100"),onClick:N=>{N.stopPropagation(),P(b.id,b.indexed??false);},onMouseDown:N=>N.stopPropagation(),title:b.indexed?"Indexed (click to remove)":"Add index",children:jsxRuntime.jsx(Gm,{})}),jsxRuntime.jsx("button",{type:"button",className:g("cursor-pointer transition-opacity",b.unique?"opacity-100":"opacity-30 hover:opacity-100"),onClick:N=>{N.stopPropagation(),B(b.id,b.unique??false);},onMouseDown:N=>N.stopPropagation(),title:b.unique?"Unique (click to remove)":"Add unique constraint",children:jsxRuntime.jsx(Km,{})}),jsxRuntime.jsx("button",{type:"button",className:"p-0.5 rounded text-gray-300 hover:text-red-500 hover:bg-red-50 dark:hover:bg-red-900/20 cursor-pointer",onClick:N=>{N.stopPropagation(),m?.(t.id,b.id);},onMouseDown:N=>N.stopPropagation(),title:"Remove field",children:jsxRuntime.jsx(ok,{})})]}),jsxRuntime.jsx("div",{"data-connection-side":"right","data-field-id":b.id,"data-table-id":t.id,className:g("absolute -right-[5px] w-2.5 h-2.5 rounded-full border-2 border-white dark:border-gray-800 cursor-crosshair z-10 transition-all",s?"opacity-100 bg-green-400 scale-150 shadow-[0_0_6px_rgba(74,222,128,0.6)]":"opacity-0 group-hover:opacity-100 bg-green-400"),style:{top:32/2-5}})]},b.id)),a&&!o&&!n&&jsxRuntime.jsxs("button",{type:"button",className:"flex items-center justify-center w-full gap-1 text-xs text-gray-400 hover:text-blue-500 hover:bg-gray-50 dark:hover:bg-gray-750 transition-colors cursor-pointer",style:{height:36},onClick:b=>{b.stopPropagation(),C();},onMouseDown:b=>b.stopPropagation(),children:[jsxRuntime.jsx("svg",{className:"w-3 h-3",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",children:jsxRuntime.jsx("path",{d:"M8 4v8M4 8h8"})}),"Add field"]})]}),!n&&!o&&jsxRuntime.jsx("div",{"data-resize-handle":"corner",className:"absolute -bottom-[5px] -right-[5px] w-[14px] h-[14px] cursor-nwse-resize z-20 group/resize",onMouseDown:b=>{b.stopPropagation(),b.preventDefault();let E=t.height??Xn(t,a);w?.(t.id,b.clientX,b.clientY,v,E);},children:jsxRuntime.jsxs("svg",{className:"w-full h-full text-gray-300 group-hover/resize:text-blue-400 transition-colors",viewBox:"0 0 14 14",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",children:[jsxRuntime.jsx("path",{d:"M12 2v10H2",opacity:"0"}),jsxRuntime.jsx("path",{d:"M6 12L12 6"}),jsxRuntime.jsx("path",{d:"M10 12L12 10"})]})})]})});function lk(e,t){let r=t.find(p=>p.id===e.from.tableId),n=t.find(p=>p.id===e.to.tableId);if(!r||!n||r.collapsed||n.collapsed)return null;let o=r.fields.findIndex(p=>p.id===e.from.fieldId),a=n.fields.findIndex(p=>p.id===e.to.fieldId);if(o===-1||a===-1)return null;let s=r.width??260,l=n.width??260,i=r.x+s/2,c=n.x+l/2,d=r.y+na(o,!!r.notes),u=n.y+na(a,!!n.notes),f,m;return i<=c?(f=r.x+s,m=n.x):(f=r.x,m=n.x+l),{x1:f,y1:d,x2:m,y2:u,cardinality:e.cardinality??"1:n"}}var dc=["1:1","1:n","n:1","n:n"];function ck(e){let t=dc.indexOf(e);return dc[(t+1)%dc.length]}var jm=el.memo(function({relations:t,tables:r,viewport:n,selectedRelationId:o,disabled:a,onRelationClick:s,onCardinalityChange:l}){return jsxRuntime.jsx("svg",{className:"absolute top-0 left-0 pointer-events-none",style:{width:"100%",height:"100%",overflow:"visible"},children:jsxRuntime.jsx("g",{transform:`translate(${n.x}, ${n.y}) scale(${n.zoom})`,children:t.map(i=>{let c=lk(i,r);if(!c)return null;let{x1:d,y1:u,x2:f,y2:m,cardinality:p}=c,w=gi(d,u,f,m),v=o===i.id,x=(d+f)/2,h=(u+m)/2;return jsxRuntime.jsxs("g",{children:[jsxRuntime.jsx("path",{d:w,fill:"none",stroke:"transparent",strokeWidth:16,className:"pointer-events-auto cursor-pointer",onClick:I=>{a||s?.(i.id,I);}}),jsxRuntime.jsx("path",{d:w,fill:"none",stroke:v?"#3b82f6":"#9ca3af",strokeWidth:v?2.5:1.5,className:"transition-colors"}),jsxRuntime.jsx("circle",{cx:d,cy:u,r:3,fill:v?"#3b82f6":"#9ca3af"}),jsxRuntime.jsx("circle",{cx:f,cy:m,r:3,fill:v?"#3b82f6":"#9ca3af"}),p&&jsxRuntime.jsxs("g",{className:a?void 0:"pointer-events-auto cursor-pointer",onClick:a?void 0:I=>{I.stopPropagation(),l?.(i.id,ck(p));},children:[jsxRuntime.jsx("rect",{x:x-14,y:h-9,width:28,height:18,rx:4,fill:"white",stroke:v?"#3b82f6":"#d1d5db",strokeWidth:1}),jsxRuntime.jsx("text",{x,y:h+4,textAnchor:"middle",className:"text-[10px] font-mono",fill:v?"#3b82f6":"#6b7280",children:p})]})]},i.id)})})})});var uk=()=>jsxRuntime.jsx("svg",{className:"w-4 h-4",viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true",children:jsxRuntime.jsx("path",{fillRule:"evenodd",d:"M10 5a1 1 0 011 1v3h3a1 1 0 110 2h-3v3a1 1 0 11-2 0v-3H6a1 1 0 110-2h3V6a1 1 0 011-1z",clipRule:"evenodd"})}),mk=()=>jsxRuntime.jsx("svg",{className:"w-4 h-4",viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true",children:jsxRuntime.jsx("path",{fillRule:"evenodd",d:"M5 10a1 1 0 011-1h8a1 1 0 110 2H6a1 1 0 01-1-1z",clipRule:"evenodd"})}),gk=()=>jsxRuntime.jsx("svg",{className:"w-4 h-4",viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true",children:jsxRuntime.jsx("path",{fillRule:"evenodd",d:"M4 2a1 1 0 011 1v2.101a7.002 7.002 0 0111.601 2.566 1 1 0 11-1.885.666A5.002 5.002 0 005.999 7H9a1 1 0 010 2H4a1 1 0 01-1-1V3a1 1 0 011-1zm.008 9.057a1 1 0 011.276.61A5.002 5.002 0 0014.001 13H11a1 1 0 110-2h5a1 1 0 011 1v5a1 1 0 11-2 0v-2.101a7.002 7.002 0 01-11.601-2.566 1 1 0 01.61-1.276z",clipRule:"evenodd"})}),pk=()=>jsxRuntime.jsx("svg",{className:"w-4 h-4",viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true",children:jsxRuntime.jsx("path",{d:"M3 4a1 1 0 011-1h4a1 1 0 010 2H6.414l2.293 2.293a1 1 0 01-1.414 1.414L5 6.414V8a1 1 0 01-2 0V4zm9 1a1 1 0 010-2h4a1 1 0 011 1v4a1 1 0 01-2 0V6.414l-2.293 2.293a1 1 0 11-1.414-1.414L13.586 5H12zm-9 7a1 1 0 012 0v1.586l2.293-2.293a1 1 0 011.414 1.414L6.414 15H8a1 1 0 010 2H4a1 1 0 01-1-1v-4zm13 0a1 1 0 01-2 0v-1.586l-2.293 2.293a1 1 0 01-1.414-1.414L13.586 9H12a1 1 0 010-2h4a1 1 0 011 1v4z"})}),fk=()=>jsxRuntime.jsx("svg",{className:"w-4 h-4",viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true",children:jsxRuntime.jsx("path",{fillRule:"evenodd",d:"M6 2a2 2 0 00-2 2v12a2 2 0 002 2h8a2 2 0 002-2V4a2 2 0 00-2-2H6zm4 5a1 1 0 011 1v1h1a1 1 0 110 2h-1v1a1 1 0 11-2 0v-1H8a1 1 0 110-2h1V8a1 1 0 011-1z",clipRule:"evenodd"})}),hk=()=>jsxRuntime.jsx("svg",{className:"w-4 h-4",viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true",children:jsxRuntime.jsx("path",{fillRule:"evenodd",d:"M3 17a1 1 0 011-1h12a1 1 0 110 2H4a1 1 0 01-1-1zm3.293-7.707a1 1 0 011.414 0L9 10.586V3a1 1 0 112 0v7.586l1.293-1.293a1 1 0 111.414 1.414l-3 3a1 1 0 01-1.414 0l-3-3a1 1 0 010-1.414z",clipRule:"evenodd"})}),bk=()=>jsxRuntime.jsx("svg",{className:"w-4 h-4",viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true",children:jsxRuntime.jsx("path",{fillRule:"evenodd",d:"M3 17a1 1 0 011-1h12a1 1 0 110 2H4a1 1 0 01-1-1zM6.293 6.707a1 1 0 010-1.414l3-3a1 1 0 011.414 0l3 3a1 1 0 01-1.414 1.414L11 5.414V13a1 1 0 11-2 0V5.414L7.707 6.707a1 1 0 01-1.414 0z",clipRule:"evenodd"})}),yk=()=>jsxRuntime.jsx("svg",{className:"w-4 h-4",viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true",children:jsxRuntime.jsx("path",{fillRule:"evenodd",d:"M2 5a2 2 0 012-2h12a2 2 0 012 2v2a2 2 0 01-2 2H4a2 2 0 01-2-2V5zm14 1a1 1 0 11-2 0 1 1 0 012 0zM2 13a2 2 0 012-2h12a2 2 0 012 2v2a2 2 0 01-2 2H4a2 2 0 01-2-2v-2zm14 1a1 1 0 11-2 0 1 1 0 012 0z",clipRule:"evenodd"})}),xk=()=>jsxRuntime.jsx("svg",{className:"w-4 h-4",viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true",children:jsxRuntime.jsx("path",{fillRule:"evenodd",d:"M7.707 3.293a1 1 0 010 1.414L5.414 7H11a7 7 0 017 7v2a1 1 0 11-2 0v-2a5 5 0 00-5-5H5.414l2.293 2.293a1 1 0 11-1.414 1.414l-4-4a1 1 0 010-1.414l4-4a1 1 0 011.414 0z",clipRule:"evenodd"})}),vk=()=>jsxRuntime.jsx("svg",{className:"w-4 h-4",viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true",children:jsxRuntime.jsx("path",{fillRule:"evenodd",d:"M12.293 3.293a1 1 0 011.414 0l4 4a1 1 0 010 1.414l-4 4a1 1 0 01-1.414-1.414L14.586 9H9a5 5 0 00-5 5v2a1 1 0 11-2 0v-2a7 7 0 017-7h5.586l-2.293-2.293a1 1 0 010-1.414z",clipRule:"evenodd"})}),Ck=()=>jsxRuntime.jsx("svg",{className:"w-4 h-4",viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true",children:jsxRuntime.jsx("path",{d:"M3 3h4v4H3V3zm0 10h4v4H3v-4zm10-10h4v4h-4V3zm0 10h4v4h-4v-4zM7 5h6v1H7V5zm0 8h6v1H7v-1zM5 7v6h1V7H5zm8 0v6h1V7h-1z"})}),Zm=el.memo(function({zoom:t,onZoomIn:r,onZoomOut:n,onResetView:o,onFitToContent:a,onAddTable:s,onExportJSON:l,onImportJSON:i,onExportSQL:c,onUndo:d,onRedo:u,canUndo:f=false,canRedo:m=false,onAutoLayout:p,disabled:w,className:v}){let[x,h]=el.useState(false),[I,S]=el.useState(false),[L,R]=el.useState(false),[T,y]=el.useState(""),[M,k]=el.useState(""),[z,H]=el.useState(""),P=el.useCallback(()=>{y(l()),h(true);},[l]),B=el.useCallback(()=>{M.trim()&&(i(M.trim()),k(""),S(false));},[M,i]),C=el.useCallback(()=>{k(""),S(false);},[]),b=el.useCallback(()=>{h(false);},[]),E=el.useCallback(()=>{c&&(H(c()),R(true));},[c]),N=el.useCallback(()=>{R(false);},[]),W=Math.round(t*100);return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsxs("div",{className:g("absolute top-3 left-3 z-20 flex items-center gap-2 bg-white dark:bg-gray-800 rounded-lg shadow-md border border-gray-200 dark:border-gray-600 px-2 py-1.5",v),"data-testid":"schema-toolbar",onMouseDown:F=>F.stopPropagation(),children:[jsxRuntime.jsxs(_o,{size:"sm",children:[jsxRuntime.jsx(Ht,{content:"Zoom in",size:"sm",position:"bottom",children:jsxRuntime.jsx(Wt,{icon:jsxRuntime.jsx(uk,{}),size:"sm",bgColor:"bg-gray-100 hover:bg-gray-200 dark:bg-gray-700 dark:hover:bg-gray-600",textColor:"text-gray-700 dark:text-gray-200",onClick:r,disabled:w,"aria-label":"Zoom in"})}),jsxRuntime.jsx(Ht,{content:"Zoom out",size:"sm",position:"bottom",children:jsxRuntime.jsx(Wt,{icon:jsxRuntime.jsx(mk,{}),size:"sm",bgColor:"bg-gray-100 hover:bg-gray-200 dark:bg-gray-700 dark:hover:bg-gray-600",textColor:"text-gray-700 dark:text-gray-200",onClick:n,disabled:w,"aria-label":"Zoom out"})})]}),jsxRuntime.jsxs("span",{className:"text-xs font-mono text-gray-500 dark:text-gray-400 min-w-[3ch] text-center select-none",children:[W,"%"]}),jsxRuntime.jsx("div",{className:"w-px h-5 bg-gray-200 dark:bg-gray-600"}),jsxRuntime.jsx(Ht,{content:"Reset view",size:"sm",position:"bottom",children:jsxRuntime.jsx(Wt,{icon:jsxRuntime.jsx(gk,{}),size:"sm",bgColor:"bg-gray-100 hover:bg-gray-200 dark:bg-gray-700 dark:hover:bg-gray-600",textColor:"text-gray-700 dark:text-gray-200",onClick:o,disabled:w,"aria-label":"Reset view"})}),jsxRuntime.jsx(Ht,{content:"Fit to content",size:"sm",position:"bottom",children:jsxRuntime.jsx(Wt,{icon:jsxRuntime.jsx(pk,{}),size:"sm",bgColor:"bg-gray-100 hover:bg-gray-200 dark:bg-gray-700 dark:hover:bg-gray-600",textColor:"text-gray-700 dark:text-gray-200",onClick:a,disabled:w,"aria-label":"Fit to content"})}),jsxRuntime.jsx("div",{className:"w-px h-5 bg-gray-200 dark:bg-gray-600"}),jsxRuntime.jsx(Ht,{content:"Add table",size:"sm",position:"bottom",children:jsxRuntime.jsx(Wt,{icon:jsxRuntime.jsx(fk,{}),size:"sm",bgColor:"bg-gray-100 hover:bg-gray-200 dark:bg-gray-700 dark:hover:bg-gray-600",textColor:"text-gray-700 dark:text-gray-200",onClick:s,disabled:w,"aria-label":"Add table"})}),jsxRuntime.jsx("div",{className:"w-px h-5 bg-gray-200 dark:bg-gray-600"}),jsxRuntime.jsx(Ht,{content:"Export JSON",size:"sm",position:"bottom",children:jsxRuntime.jsx(Wt,{icon:jsxRuntime.jsx(hk,{}),size:"sm",bgColor:"bg-gray-100 hover:bg-gray-200 dark:bg-gray-700 dark:hover:bg-gray-600",textColor:"text-gray-700 dark:text-gray-200",onClick:P,disabled:w,"aria-label":"Export JSON"})}),jsxRuntime.jsx(Ht,{content:"Import JSON",size:"sm",position:"bottom",children:jsxRuntime.jsx(Wt,{icon:jsxRuntime.jsx(bk,{}),size:"sm",bgColor:"bg-gray-100 hover:bg-gray-200 dark:bg-gray-700 dark:hover:bg-gray-600",textColor:"text-gray-700 dark:text-gray-200",onClick:()=>S(true),disabled:w,"aria-label":"Import JSON"})}),c&&jsxRuntime.jsx(Ht,{content:"Export SQL",size:"sm",position:"bottom",children:jsxRuntime.jsx(Wt,{icon:jsxRuntime.jsx(yk,{}),size:"sm",bgColor:"bg-gray-100 hover:bg-gray-200 dark:bg-gray-700 dark:hover:bg-gray-600",textColor:"text-gray-700 dark:text-gray-200",onClick:E,disabled:w,"aria-label":"Export SQL"})}),(d||u)&&jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("div",{className:"w-px h-5 bg-gray-200 dark:bg-gray-600"}),jsxRuntime.jsxs(_o,{size:"sm",children:[jsxRuntime.jsx(Ht,{content:"Undo (Ctrl+Z)",size:"sm",position:"bottom",children:jsxRuntime.jsx(Wt,{icon:jsxRuntime.jsx(xk,{}),size:"sm",bgColor:"bg-gray-100 hover:bg-gray-200 dark:bg-gray-700 dark:hover:bg-gray-600",textColor:"text-gray-700 dark:text-gray-200",onClick:d,disabled:w||!f,"aria-label":"Undo"})}),jsxRuntime.jsx(Ht,{content:"Redo (Ctrl+Y)",size:"sm",position:"bottom",children:jsxRuntime.jsx(Wt,{icon:jsxRuntime.jsx(vk,{}),size:"sm",bgColor:"bg-gray-100 hover:bg-gray-200 dark:bg-gray-700 dark:hover:bg-gray-600",textColor:"text-gray-700 dark:text-gray-200",onClick:u,disabled:w||!m,"aria-label":"Redo"})})]})]}),p&&jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("div",{className:"w-px h-5 bg-gray-200 dark:bg-gray-600"}),jsxRuntime.jsx(Ht,{content:"Auto layout",size:"sm",position:"bottom",children:jsxRuntime.jsx(Wt,{icon:jsxRuntime.jsx(Ck,{}),size:"sm",bgColor:"bg-gray-100 hover:bg-gray-200 dark:bg-gray-700 dark:hover:bg-gray-600",textColor:"text-gray-700 dark:text-gray-200",onClick:p,disabled:w,"aria-label":"Auto layout"})})]})]}),jsxRuntime.jsx(Ln,{isOpen:x,onClose:b,title:"Export Schema",description:"Copy the JSON below to save your schema.",size:"lg",showSubmit:false,showCancel:true,cancelLabel:"Close",children:jsxRuntime.jsx(ln,{label:"Schema JSON",multiline:true,rows:12,value:T,readOnly:true,size:"sm"})}),jsxRuntime.jsx(Ln,{isOpen:I,onClose:C,title:"Import Schema",description:"Paste schema JSON to load it into the editor.",size:"lg",showSubmit:true,submitLabel:"Import",onSubmitClick:B,showCancel:true,cancelLabel:"Cancel",children:jsxRuntime.jsx(ln,{label:"Schema JSON",multiline:true,rows:12,value:M,onChange:F=>k(F.target.value),placeholder:'{"tables": [], "relations": []}',size:"sm"})}),jsxRuntime.jsx(Ln,{isOpen:L,onClose:N,title:"Export SQL",description:"Generated PostgreSQL CREATE TABLE statements.",size:"lg",showSubmit:false,showCancel:true,cancelLabel:"Close",children:jsxRuntime.jsx(ln,{label:"SQL",multiline:true,rows:16,value:z,readOnly:true,size:"sm"})})]})});var wk=()=>jsxRuntime.jsxs("svg",{className:"w-3.5 h-3.5",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",children:[jsxRuntime.jsx("path",{d:"M10 1l2 2-5 5M8.5 4.5L11 7"}),jsxRuntime.jsx("circle",{cx:"4.5",cy:"11.5",r:"3"})]}),Nk=()=>jsxRuntime.jsx("span",{className:"text-xs font-bold text-gray-500 w-3.5 text-center",children:"?"}),Sk=()=>jsxRuntime.jsxs("svg",{className:"w-3.5 h-3.5",viewBox:"0 0 16 16",fill:"currentColor",children:[jsxRuntime.jsx("circle",{cx:"8",cy:"8",r:"6",className:"fill-blue-500"}),jsxRuntime.jsx("path",{d:"M5 8h6M8 5l3 3-3 3",stroke:"white",strokeWidth:"1.5",fill:"none",strokeLinecap:"round",strokeLinejoin:"round"})]}),Rk=()=>jsxRuntime.jsx("svg",{className:"w-3.5 h-3.5 text-amber-500",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",children:jsxRuntime.jsx("path",{d:"M3 2v12M7 4h6M7 8h4M7 12h5"})}),Tk=()=>jsxRuntime.jsx("svg",{className:"w-3.5 h-3.5 text-purple-500",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",children:jsxRuntime.jsx("path",{d:"M4 2v8a4 4 0 008 0V2"})}),Qm=el.memo(function({className:t}){return jsxRuntime.jsxs("div",{className:g("absolute top-3 right-3 z-20 flex items-center gap-4 bg-white dark:bg-gray-800 rounded-lg shadow-md border border-gray-200 dark:border-gray-600 px-3 py-2",t),"data-testid":"schema-legend",children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-1.5",children:[jsxRuntime.jsx(wk,{}),jsxRuntime.jsx("span",{className:"text-xs text-gray-600 dark:text-gray-300",children:"Primary Key"})]}),jsxRuntime.jsxs("div",{className:"flex items-center gap-1.5",children:[jsxRuntime.jsx(Nk,{}),jsxRuntime.jsx("span",{className:"text-xs text-gray-600 dark:text-gray-300",children:"Nullable"})]}),jsxRuntime.jsxs("div",{className:"flex items-center gap-1.5",children:[jsxRuntime.jsx(Sk,{}),jsxRuntime.jsx("span",{className:"text-xs text-gray-600 dark:text-gray-300",children:"Foreign Key"})]}),jsxRuntime.jsxs("div",{className:"flex items-center gap-1.5",children:[jsxRuntime.jsx(Rk,{}),jsxRuntime.jsx("span",{className:"text-xs text-gray-600 dark:text-gray-300",children:"Index"})]}),jsxRuntime.jsxs("div",{className:"flex items-center gap-1.5",children:[jsxRuntime.jsx(Tk,{}),jsxRuntime.jsx("span",{className:"text-xs text-gray-600 dark:text-gray-300",children:"Unique"})]})]})});var hi=180,bi=120,ia=10,Jm=el.memo(function({tables:t,viewport:r,containerWidth:n,containerHeight:o,editable:a,onViewportChange:s,className:l}){let i=el.useRef(null),c=el.useMemo(()=>{if(t.length===0)return null;let L=1/0,R=1/0,T=-1/0,y=-1/0;for(let N of t){let W=N.width??260,F=Xn(N,a);L=Math.min(L,N.x),R=Math.min(R,N.y),T=Math.max(T,N.x+W),y=Math.max(y,N.y+F);}let M=-r.x/r.zoom,k=-r.y/r.zoom,z=M+n/r.zoom,H=k+o/r.zoom;L=Math.min(L,M),R=Math.min(R,k),T=Math.max(T,z),y=Math.max(y,H);let P=T-L+ia*2,B=y-R+ia*2,C=Math.min((hi-4)/P,(bi-4)/B),b=(hi-P*C)/2,E=(bi-B*C)/2;return {minX:L,minY:R,scale:C,offsetX:b,offsetY:E,vpMinX:M,vpMinY:k}},[t,r,n,o,a]),d=el.useCallback(L=>{if(!c)return;let R=i.current?.getBoundingClientRect();if(!R)return;let T=L.clientX-R.left,y=L.clientY-R.top,M=(T-c.offsetX)/c.scale+c.minX-ia,k=(y-c.offsetY)/c.scale+c.minY-ia;s({...r,x:-(M-n/(2*r.zoom))*r.zoom,y:-(k-o/(2*r.zoom))*r.zoom});},[c,r,n,o,s]);if(!c)return null;let{minX:u,minY:f,scale:m,offsetX:p,offsetY:w,vpMinX:v,vpMinY:x}=c,h=(L,R)=>({x:(L-u+ia)*m+p,y:(R-f+ia)*m+w}),I=h(v,x),S={w:n/r.zoom*m,h:o/r.zoom*m};return jsxRuntime.jsx("div",{ref:i,className:g("absolute bottom-3 right-3 z-20 bg-white/90 dark:bg-gray-800/90 rounded-lg shadow-md border border-gray-200 dark:border-gray-600 cursor-pointer overflow-hidden",l),style:{width:hi,height:bi},onClick:d,onMouseDown:L=>L.stopPropagation(),"data-testid":"schema-minimap",children:jsxRuntime.jsxs("svg",{width:hi,height:bi,children:[t.map(L=>{let R=L.width??260,T=Xn(L,a),y=h(L.x,L.y);return jsxRuntime.jsx("rect",{x:y.x,y:y.y,width:R*m,height:T*m,fill:L.color??"#e5e7eb",stroke:"#9ca3af",strokeWidth:.5,rx:1},L.id)}),jsxRuntime.jsx("rect",{x:I.x,y:I.y,width:S.w,height:S.h,fill:"rgba(59, 130, 246, 0.1)",stroke:"#3b82f6",strokeWidth:1,rx:1})]})})});function An(e){return `"${e.replace(/"/g,'""')}"`}function eg(e){return {text:"TEXT",varchar:"VARCHAR(255)",char:"CHAR(1)",int2:"SMALLINT",int4:"INTEGER",int8:"BIGINT",serial:"SERIAL",bigserial:"BIGSERIAL",float4:"REAL",float8:"DOUBLE PRECISION",numeric:"NUMERIC",decimal:"DECIMAL",bool:"BOOLEAN",date:"DATE",time:"TIME",timestamp:"TIMESTAMP",timestamptz:"TIMESTAMP WITH TIME ZONE",uuid:"UUID",json:"JSON",jsonb:"JSONB",bytea:"BYTEA"}[e]??e.toUpperCase()}function Ik(e){let t=[An(e.name)];return e.type==="serial"||e.type,t.push(eg(e.type)),e.primaryKey&&t.push("PRIMARY KEY"),!e.nullable&&!e.primaryKey&&t.push("NOT NULL"),e.unique&&!e.primaryKey&&t.push("UNIQUE"),e.defaultValue&&t.push(`DEFAULT ${e.defaultValue}`)," "+t.join(" ")}function Ak(e,t,r){let n=[],o=[];for(let i of e.fields)n.push(Ik(i));for(let i of e.fields)if(i.foreignKey){let c=r.find(u=>u.id===i.foreignKey.tableId),d=c?.fields.find(u=>u.id===i.foreignKey.fieldId);c&&d&&o.push(` CONSTRAINT ${An(`fk_${e.name}_${i.name}`)} FOREIGN KEY (${An(i.name)}) REFERENCES ${An(c.name)} (${An(d.name)})`);}let a=[];for(let i of e.fields)i.indexed&&!i.primaryKey&&!i.unique&&a.push(`CREATE INDEX ${An(`idx_${e.name}_${i.name}`)} ON ${An(e.name)} (${An(i.name)});`);let s=[...n,...o],l=`CREATE TABLE ${An(e.name)} (
24
+ `,role:"tooltip",children:[(d||s)&&jsxRuntime.jsxs("div",{className:"flex items-center justify-between px-4 py-2 border-b border-gray-200 dark:border-gray-700 bg-gray-50 dark:bg-gray-800/50",children:[jsxRuntime.jsx("div",{className:"flex items-center gap-2",children:d&&jsxRuntime.jsx("h3",{className:"text-sm font-semibold",children:d})}),s&&jsxRuntime.jsx("div",{className:"flex items-center gap-1",children:b?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("button",{type:"button",onClick:O,disabled:C,className:"p-1.5 rounded-md hover:bg-green-100 dark:hover:bg-green-900/30 text-green-600 dark:text-green-400 transition-colors disabled:opacity-50 cursor-pointer",title:"Sauvegarder",children:C?Ev:Pv}),jsxRuntime.jsx("button",{type:"button",onClick:T,className:"p-1.5 rounded-md hover:bg-gray-200 dark:hover:bg-gray-700 text-gray-500 hover:text-gray-700 dark:hover:text-gray-300 transition-colors cursor-pointer",title:"Annuler",children:Tv}),i&&jsxRuntime.jsx("button",{type:"button",onClick:H,disabled:C,className:"p-1.5 rounded-md hover:bg-orange-100 dark:hover:bg-orange-900/30 text-orange-600 dark:text-orange-400 transition-colors disabled:opacity-50 cursor-pointer",title:"R\xE9initialiser",children:Dv})]}):jsxRuntime.jsx("button",{type:"button",onClick:W,className:"p-1.5 rounded-md hover:bg-gray-200 dark:hover:bg-gray-700 text-gray-500 hover:text-gray-700 dark:hover:text-gray-300 transition-colors cursor-pointer",title:"Modifier",children:Rv})})]}),v&&jsxRuntime.jsx("div",{className:`px-4 py-2 text-xs ${v.type==="success"?"bg-green-50 dark:bg-green-900/20 text-green-600 dark:text-green-400":"bg-red-50 dark:bg-red-900/20 text-red-600 dark:text-red-400"}`,children:v.text}),jsxRuntime.jsx("div",{className:"flex-1 overflow-y-auto p-4",children:b?t?u?jsxRuntime.jsx(u,{value:x,onChange:L,placeholder:"\xC9crivez en Markdown..."}):jsxRuntime.jsx("p",{role:"alert",className:"p-3 text-sm text-gray-500 dark:text-gray-400",children:f??m.markdownEditorUnavailable}):jsxRuntime.jsx("div",{className:"space-y-2",children:jsxRuntime.jsx("textarea",{ref:P,"aria-label":"Contenu d'aide",value:x,onChange:z=>L(z.target.value),className:"w-full h-64 p-3 text-sm bg-gray-50 dark:bg-gray-800 border border-gray-200 dark:border-gray-700 rounded-lg resize-none focus:outline-none focus:ring-2 focus:ring-blue-500/50 text-gray-700 dark:text-gray-300 font-mono",placeholder:"\xC9crivez votre contenu d'aide..."})}):typeof k=="string"?jsxRuntime.jsx("div",{className:"prose prose-sm dark:prose-invert max-w-none",children:t?jsxRuntime.jsx(Nv__default.default,{remarkPlugins:Av,components:zv,children:k}):jsxRuntime.jsx("div",{dangerouslySetInnerHTML:{__html:wv__default.default.sanitize(k)}})}):k})]})]}):null}function Bv({children:e,content:t,markdown:r=false,position:n="bottom",size:o="sm",visible:a=true,editable:s=false,onSave:l,onReset:i,width:c="md",title:d,className:u,markdownEditor:f,markdownEditorUnavailableLabel:m}){return jsxRuntime.jsxs("div",{className:"inline-flex items-center gap-2.5",children:[e,jsxRuntime.jsx(ym,{content:t,markdown:r,position:n,size:o,visible:a,editable:s,onSave:l,onReset:i,width:c,title:d,className:u,markdownEditor:f,markdownEditorUnavailableLabel:m})]})}var Fv={"16/9":"aspect-[16/9]","4/3":"aspect-[4/3]","1/1":"aspect-square",auto:""},$v=e=>new Promise((t,r)=>{let n=new FileReader;n.onload=o=>{let a=o.target?.result;t(a);},n.onerror=()=>{r(new Error("Erreur lors de la lecture du fichier"));},n.readAsDataURL(e);});function _v({value:e,onChange:t,onUpload:r,label:n="Image",maxSize:o=5*1024*1024,accept:a="image/*",helpText:s,disabled:l=false,className:i="",showUrlInput:c=true,urlPlaceholder:d="https://example.com/image.jpg",aspectRatio:u="16/9"}){let[f,m]=Cl.useState(false),[g,y]=Cl.useState(null),b=Cl.useRef(null),h=Cl.useId(),x=Cl.useMemo(()=>(o/(1024*1024)).toFixed(0),[o]),L=`Formats accept\xE9s : ${a==="image/*"?"JPG, PNG, GIF, WebP":a} (max ${x}MB)`,C=Cl.useCallback(async M=>{let P=M.target.files?.[0];if(P){if(!P.type.startsWith("image/")){y("Le fichier doit \xEAtre une image");return}if(P.size>o){y(`Le fichier est trop volumineux (max ${x}MB)`);return}m(true),y(null);try{if(r){let E=await r(P);t(E);}else {let E=await $v(P);t(E);}b.current&&(b.current.value="");}catch(E){console.error("Upload error:",E),y(E instanceof Error?E.message:"Erreur lors de l'upload");}finally{m(false);}}},[o,x,t,r]),S=Cl.useCallback(()=>{t(""),b.current&&(b.current.value=""),y(null);},[t]),v=Cl.useCallback(M=>{t(M),y(null);},[t]),R=Cl.useCallback(()=>{b.current?.click();},[]),N=Cl.useCallback(M=>{v(M.target.value);},[v]);return jsxRuntime.jsxs("div",{className:`space-y-2 ${i}`,children:[n&&jsxRuntime.jsx("label",{className:"block text-sm font-semibold text-gray-700 dark:text-gray-300",children:n}),e&&jsxRuntime.jsxs("div",{className:"relative w-full overflow-hidden rounded-lg border border-gray-300 dark:border-gray-600 bg-gray-50 dark:bg-gray-800/50",children:[jsxRuntime.jsx("div",{className:`relative ${Fv[u]} ${u==="auto"?"max-h-64":""} flex items-center justify-center`,children:jsxRuntime.jsx("img",{src:e,alt:"Aper\xE7u",className:"w-full h-full object-contain"})}),jsxRuntime.jsx("button",{type:"button",onClick:S,disabled:l,className:"absolute top-2 right-2 bg-red-500 text-white rounded-full w-6 h-6 flex items-center justify-center text-xs hover:bg-red-600 transition-colors cursor-pointer disabled:opacity-50 disabled:cursor-not-allowed",title:"Supprimer l'image",children:"\xD7"})]}),jsxRuntime.jsxs("div",{className:"flex gap-2",children:[jsxRuntime.jsx("input",{ref:b,type:"file","aria-label":"Choisir une image",accept:a,onChange:C,className:"hidden",disabled:l||f}),jsxRuntime.jsx("button",{type:"button",onClick:R,disabled:l||f,className:"px-3 py-2 text-sm border border-gray-300 dark:border-gray-600 rounded-md hover:bg-gray-50 dark:hover:bg-gray-700 disabled:opacity-50 disabled:cursor-not-allowed transition-colors cursor-pointer bg-white dark:bg-gray-800 text-gray-700 dark:text-gray-200",children:f?"\u23F3 Upload...":e?"\u{1F4C1} Changer l'image":"\u{1F4C1} Choisir une image"})]}),c&&jsxRuntime.jsxs("div",{className:"space-y-1",children:[jsxRuntime.jsx("label",{htmlFor:h,className:"block text-xs text-gray-500 dark:text-gray-400",children:"Ou URL directe :"}),jsxRuntime.jsx("input",{id:h,type:"url",value:e||"",onChange:N,placeholder:d,disabled:l,className:"w-full px-3 py-2 text-sm border border-gray-300 dark:border-gray-600 rounded-md focus:ring-2 focus:ring-blue-500 focus:border-blue-500 dark:bg-gray-800 dark:text-gray-200 disabled:opacity-50 disabled:cursor-not-allowed"})]}),g&&jsxRuntime.jsxs("div",{className:"text-red-600 dark:text-red-400 text-sm bg-red-50 dark:bg-red-900/20 p-2 rounded border border-red-200 dark:border-red-800",children:["\u274C ",g]}),jsxRuntime.jsx("div",{className:"text-xs text-gray-500 dark:text-gray-400",children:s||L})]})}var fi={default:"bg-gray-400",primary:"bg-blue-600",success:"bg-green-500",warning:"bg-yellow-400",error:"bg-red-500",info:"bg-cyan-500",dark:"bg-gray-900 dark:bg-gray-700",purple:"bg-purple-600",indigo:"bg-indigo-600",teal:"bg-teal-500"},cc={xs:"w-2 h-2",sm:"w-2.5 h-2.5",md:"w-3 h-3",lg:"w-3.5 h-3.5",xl:"w-4 h-4"},Xv={xs:"min-w-4 h-4 text-[10px] px-1",sm:"min-w-5 h-5 text-xs px-1",md:"min-w-5 h-5 text-xs px-1.5",lg:"min-w-6 h-6 text-sm px-1.5",xl:"min-w-7 h-7 text-sm px-2"},dc={"top-left":"top-0 left-0 -translate-x-1/2 -translate-y-1/2","top-center":"top-0 left-1/2 -translate-x-1/2 -translate-y-1/2","top-right":"top-0 right-0 translate-x-1/2 -translate-y-1/2","center-left":"top-1/2 left-0 -translate-x-1/2 -translate-y-1/2",center:"top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2","center-right":"top-1/2 right-0 translate-x-1/2 -translate-y-1/2","bottom-left":"bottom-0 left-0 -translate-x-1/2 translate-y-1/2","bottom-center":"bottom-0 left-1/2 -translate-x-1/2 translate-y-1/2","bottom-right":"bottom-0 right-0 translate-x-1/2 translate-y-1/2"},uc={"top-left":"top-0 left-0","top-center":"top-0 left-1/2 -translate-x-1/2","top-right":"top-0 right-0","center-left":"top-1/2 left-0 -translate-y-1/2",center:"top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2","center-right":"top-1/2 right-0 -translate-y-1/2","bottom-left":"bottom-0 left-0","bottom-center":"bottom-0 left-1/2 -translate-x-1/2","bottom-right":"bottom-0 right-0"};function Gv(e,t){return e>t?`${t}+`:`${e}`}function Uv({color:e="primary",size:t="md",placement:r="top-right",bordered:n=false,borderColor:o,pulse:a=false,offset:s=false,className:l,...i}){return jsxRuntime.jsx("span",{"data-testid":"indicator",className:p("absolute z-10 rounded-full",fi[e],cc[t],s?uc[r]:dc[r],n&&p("ring-2 ring-white dark:ring-gray-900",o),a&&"animate-pulse",l),...i})}function Kv({color:e="error",size:t="md",placement:r="top-right",count:n=0,maxCount:o=99,bordered:a=false,borderColor:s,pulse:l=false,offset:i=false,className:c,...d}){return jsxRuntime.jsx("span",{"data-testid":"indicator",className:p("absolute z-10 inline-flex items-center justify-center rounded-full font-semibold text-white",fi[e],Xv[t],i?uc[r]:dc[r],a&&p("ring-2 ring-white dark:ring-gray-900",s),l&&"animate-pulse",c),...d,children:Gv(n,o)})}function Yv({color:e="success",size:t="md",placement:r="bottom-right",bordered:n=true,borderColor:o,pulse:a=false,offset:s=false,className:l,...i}){return jsxRuntime.jsx("span",{"data-testid":"indicator",className:p("absolute z-10 rounded-full",fi[e],cc[t],s?uc[r]:dc[r],n&&p("ring-2 ring-white dark:ring-gray-900",o),a&&"animate-pulse",l),...i})}function jv({color:e="primary",size:t="sm",label:r,className:n,...o}){return jsxRuntime.jsxs("span",{"data-testid":"indicator",className:p("inline-flex items-center gap-2",n),...o,children:[jsxRuntime.jsx("span",{className:p("rounded-full shrink-0",fi[e],cc[t])}),r?jsxRuntime.jsx("span",{className:"text-sm text-gray-700 dark:text-gray-300",children:r}):null]})}function vm({variant:e="dot",children:t,...r}){if(e==="legend")return jsxRuntime.jsx(jv,{...r});let n=(()=>{switch(e){case "count":return jsxRuntime.jsx(Kv,{...r});case "status":return jsxRuntime.jsx(Yv,{...r});default:return jsxRuntime.jsx(Uv,{...r})}})();return t?jsxRuntime.jsxs("div",{className:"relative inline-flex",children:[t,n]}):n}vm.displayName="Indicator";var qv={xs:"text-xs",sm:"text-sm",md:"text-sm",lg:"text-base",xl:"text-lg"},km={xs:"w-3 h-3",sm:"w-3.5 h-3.5",md:"w-4 h-4",lg:"w-4.5 h-4.5",xl:"w-5 h-5"},Zv={normal:"font-normal",medium:"font-medium",semibold:"font-semibold",bold:"font-bold"},Qv={default:{default:"text-gray-700 dark:text-gray-200",light:"text-gray-500 dark:text-gray-400",strong:"text-gray-900 dark:text-white"},primary:{default:"text-blue-600 dark:text-blue-400",light:"text-blue-400 dark:text-blue-300",strong:"text-blue-700 dark:text-blue-300"},secondary:{default:"text-purple-600 dark:text-purple-400",light:"text-purple-400 dark:text-purple-300",strong:"text-purple-700 dark:text-purple-300"},success:{default:"text-green-600 dark:text-green-400",light:"text-green-400 dark:text-green-300",strong:"text-green-700 dark:text-green-300"},warning:{default:"text-yellow-600 dark:text-yellow-400",light:"text-yellow-400 dark:text-yellow-300",strong:"text-yellow-700 dark:text-yellow-300"},error:{default:"text-red-600 dark:text-red-400",light:"text-red-400 dark:text-red-300",strong:"text-red-700 dark:text-red-300"},info:{default:"text-cyan-600 dark:text-cyan-400",light:"text-cyan-400 dark:text-cyan-300",strong:"text-cyan-700 dark:text-cyan-300"},muted:{default:"text-gray-500 dark:text-gray-400",light:"text-gray-400 dark:text-gray-500",strong:"text-gray-600 dark:text-gray-300"}};function Nm({children:e,size:t="md",color:r="default",variant:n="default",weight:o="medium",textColor:a,required:s=false,requiredIndicator:l="*",optional:i=false,optionalText:c="(optional)",tooltip:d,icon:u,endIcon:f,disabled:m=false,truncate:g=false,as:y="label",className:b,...h}){let x=y,L=p("inline-flex items-center gap-1.5 transition-colors",qv[t],Zv[o]),C=a||Qv[r][n];return jsxRuntime.jsxs(x,{className:p(L,C,m?"opacity-50 cursor-not-allowed":"cursor-default",b),title:d,"aria-disabled":m,...h,children:[u&&jsxRuntime.jsx("span",{className:p("shrink-0",km[t]),children:u}),jsxRuntime.jsxs("span",{className:p(g&&"truncate"),children:[e,s&&jsxRuntime.jsx("span",{className:"text-red-500 ml-0.5","aria-hidden":"true",children:l}),s&&jsxRuntime.jsx("span",{className:"sr-only",children:"(required)"})]}),i&&!s&&jsxRuntime.jsx("span",{className:"text-gray-400 dark:text-gray-500 font-normal",children:c}),f&&jsxRuntime.jsx("span",{className:p("shrink-0",km[t]),children:f})]})}Nm.displayName="Label";var tC=2,rC=2,nC=12,oC=16,Sm="cell:",Rm=false,aC=Cl.memo(function({cells:t,radius:r}){return jsxRuntime.jsx("g",{children:t.map(n=>jsxRuntime.jsxs("g",{children:[jsxRuntime.jsx("rect",{x:n.x,y:n.y,width:n.width,height:n.height,rx:r,fill:n.missing?void 0:n.color,className:n.missing?"fill-gray-100 dark:fill-gray-800":void 0}),n.label?jsxRuntime.jsx("text",{x:n.x+n.width/2,y:n.y+n.height/2,textAnchor:"middle",dominantBaseline:"central",className:p("text-[10px] [font-variant-numeric:tabular-nums]",n.onDark?"fill-gray-50 dark:fill-gray-900":"fill-gray-900 dark:fill-gray-50"),children:n.label}):null]},n.key))})});function sC({width:e,height:t,columns:r,rows:n,lookup:o,colorScale:a,x:s,y:l,size:i,cellGap:c,cellRadius:d,showValues:u,tooltip:f,plotLabel:m,formatValue:g,formatX:y,formatY:b,onCellClick:h}){let[x,L]=Cl.useState(null),C=Cl.useMemo(()=>{let P=r.map((B,w)=>y(B,w)),E=n.map((B,w)=>b(B,w)),W={top:8,right:8,bottom:s.hidden?8:s.height??24+(s.label?16:0),left:l.hidden?8:l.height??Pr(E)+nC+(l.label?16:0)},T=Math.max(0,e-W.left-W.right),O=Math.max(0,t-W.top-W.bottom),H=bn(r.map((B,w)=>w),[0,T],{paddingInner:0,paddingOuter:0}),k=bn(n.map((B,w)=>w),[0,O],{paddingInner:0,paddingOuter:0}),z=Math.max(0,H.bandwidth-c),A=Math.max(0,k.bandwidth-c),I=[];n.forEach((B,w)=>{r.forEach((G,q)=>{let U=o.get(`${rt(G)}|${rt(B)}`)?.value??null,F=null;if(u&&U!==null&&A>=oC){let _=g(U);ir(_,10)+6<=z&&(F=_);}I.push({key:`${q}-${w}`,column:q,row:w,x:H(q)+c/2,y:k(w)+c/2,width:z,height:A,color:U===null?"transparent":a(U),label:F,onDark:U!==null&&a.onDark(U),missing:U===null});});});let X=Ea(P.length,T,Pr(P)),$=Ea(E.length,O,15),K=s.hidden?[]:P.map((B,w)=>({value:r[w],offset:H.center(w),label:B})).filter((B,w)=>w%X===0),D=l.hidden?[]:E.map((B,w)=>({value:n[w],offset:k.center(w),label:B})).filter((B,w)=>w%$===0);return {margin:W,innerWidth:T,innerHeight:O,columnScale:H,rowScale:k,cells:I,columnTicks:K,rowTicks:D}},[r,n,o,a,s,l,e,t,c,u,g,y,b]),S=Cl.useCallback((P,E)=>{let W=r[P],T=n[E],O=o.get(`${rt(W)}|${rt(T)}`),H=O?.value??null;return {x:W,y:T,xLabel:y(W,P),yLabel:b(T,E),value:H,formattedValue:H===null?"\u2014":g(H),color:H===null?"transparent":a(H),datum:O?.datum}},[r,n,o,a,g,y,b]),v=Cl.useCallback(P=>{if(f===false||r.length===0||n.length===0)return;let E=P.currentTarget.getBoundingClientRect(),W=P.clientX-E.left-C.margin.left,T=P.clientY-E.top-C.margin.top,O=Math.floor(W/(C.columnScale.step||1)),H=Math.floor(T/(C.rowScale.step||1));if(O<0||O>=r.length||H<0||H>=n.length){L(null);return}L(k=>k?.column===O&&k.row===H?k:{column:O,row:H});},[f,r.length,n.length,C.margin,C.columnScale,C.rowScale]),R=Cl.useCallback(P=>{if(r.length===0||n.length===0)return;let E=x??{column:0,row:0},W;switch(P.key){case "ArrowRight":W={...E,column:Math.min(r.length-1,E.column+1)};break;case "ArrowLeft":W={...E,column:Math.max(0,E.column-1)};break;case "ArrowDown":W={...E,row:Math.min(n.length-1,E.row+1)};break;case "ArrowUp":W={...E,row:Math.max(0,E.row-1)};break;case "Home":W={...E,column:0};break;case "End":W={...E,column:r.length-1};break;case "Escape":W=null;break;default:W=void 0;}W!==void 0&&(P.preventDefault(),L(W));},[r.length,n.length,x]),N=Cl.useCallback(()=>{!h||!x||h(S(x.column,x.row));},[h,x,S]),M=x?S(x.column,x.row):null;return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsxs("svg",{width:e,height:t,role:"img","aria-label":m??`${s.label??s.key} / ${l.label??l.key}`,tabIndex:0,className:"touch-none focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-blue-500",onPointerMove:v,onPointerLeave:()=>L(null),onKeyDown:R,onBlur:()=>L(null),onClick:N,children:[jsxRuntime.jsxs("g",{transform:`translate(${C.margin.left}, ${C.margin.top})`,children:[jsxRuntime.jsx(aC,{cells:C.cells,radius:d}),x?jsxRuntime.jsx("rect",{x:C.columnScale(x.column)+c/2,y:C.rowScale(x.row)+c/2,width:Math.max(0,C.columnScale.bandwidth-c),height:Math.max(0,C.rowScale.bandwidth-c),rx:d,fill:"none",strokeWidth:2,className:"stroke-gray-900 dark:stroke-white","aria-hidden":"true"}):null]}),jsxRuntime.jsx("g",{transform:`translate(${C.margin.left}, ${C.margin.top+C.innerHeight})`,children:s.hidden?null:jsxRuntime.jsx(tt,{orientation:"bottom",ticks:C.columnTicks,length:C.innerWidth,showLine:false,tickSize:0,label:s.label,size:i})}),jsxRuntime.jsx("g",{transform:`translate(${C.margin.left}, ${C.margin.top})`,children:l.hidden?null:jsxRuntime.jsx(tt,{orientation:"left",ticks:C.rowTicks,length:C.innerHeight,showLine:false,tickSize:0,label:l.label,size:i})})]}),x&&M&&f!==false?jsxRuntime.jsx(vt,{x:C.margin.left+C.columnScale.center(x.column),y:C.margin.top+C.rowScale.center(x.row),containerWidth:e,children:typeof f=="function"?f(M):jsxRuntime.jsxs("div",{className:"flex flex-col gap-1",children:[jsxRuntime.jsxs("div",{className:"font-medium text-gray-900 dark:text-gray-100",children:[M.yLabel," \xB7 ",M.xLabel]}),jsxRuntime.jsxs("div",{className:"flex items-center gap-2",children:[jsxRuntime.jsx("span",{className:"h-2.5 w-2.5 shrink-0 rounded-sm",style:{backgroundColor:M.color},"aria-hidden":"true"}),jsxRuntime.jsx("span",{className:"font-semibold text-gray-900 [font-variant-numeric:tabular-nums] dark:text-gray-100",children:M.formattedValue})]})]})}):null]})}function Pm(e,t,r){if(r)return r;let n=new Map;return e.forEach((o,a)=>{let s=gt(o,t,a),l=rt(s);n.has(l)||n.set(l,s);}),[...n.values()]}function iC({data:e,x:t,y:r,value:n,format:o,domain:a,scale:s="sequential",center:l=0,steps:i,colors:c,xDomain:d,yDomain:u,cellGap:f=tC,cellRadius:m=rC,showValues:g=false,height:y=280,width:b,size:h="md",legend:x=true,legendLabel:L,tooltip:C=true,tableView:S=false,title:v,description:R,loading:N=false,emptyState:M,error:P=false,errorState:E,onRetry:W,actions:T,locale:O,plotLabel:H,onCellClick:k,className:z,...A}){i!==void 0&&i>Ds&&!Rm&&(Rm=true,console.warn(`[@synertech/ui] A Heatmap was cut into ${i} colour classes. Past ${Ds} two neighbouring cells stop being tellable apart: leave \`steps\` unset and let the ramp stay continuous.`));let I=Cl.useMemo(()=>Pm(e,t.key,d),[e,t.key,d]),X=Cl.useMemo(()=>Pm(e,r.key,u),[e,r.key,u]),$=Cl.useMemo(()=>{let F=new Map;return e.forEach((_,J)=>{let ne=Ae(_,n);if(ne===null)return;let Y=gt(_,t.key,J),ee=gt(_,r.key,J);F.set(`${rt(Y)}|${rt(ee)}`,{value:ne,datum:_});}),F},[e,t.key,r.key,n]),K=Cl.useMemo(()=>o??(F=>pt(F,O)),[o,O]),D=Cl.useMemo(()=>t.format??(F=>st(F,O)),[t.format,O]),B=Cl.useMemo(()=>r.format??(F=>st(F,O)),[r.format,O]),w=Cl.useMemo(()=>{let F=a??Qt([...$.values()].map(_=>_.value))??[0,1];return s==="diverging"?Go(F,{center:l,steps:i,colors:c}):za(F,{steps:i,colors:c})},[a,$,s,l,i,c]),G=Cl.useMemo(()=>X.map(F=>{let _={[r.key]:F};return I.forEach(J=>{_[`${Sm}${rt(J)}`]=$.get(`${rt(J)}|${rt(F)}`)?.value??null;}),_}),[X,I,$,r.key]),q=Cl.useMemo(()=>I.map((F,_)=>({key:`${Sm}${rt(F)}`,label:D(F,_)})),[I,D]),j=x!==false,U=typeof x=="string"?x:"bottom";return jsxRuntime.jsx(xt,{title:v,description:R,height:y,width:b,size:h,loading:N,empty:$.size===0,emptyState:M,error:P,errorState:E,onRetry:W,actions:T,tableView:S,legendPosition:U,legend:j?jsxRuntime.jsx(Oa,{scale:w,label:L,format:K,size:h,locale:O}):void 0,table:S?jsxRuntime.jsx(Ot,{data:G,series:q,xKey:r.key,xLabel:r.label??r.key,formatX:B,formatValue:K,caption:typeof v=="string"?v:void 0}):void 0,className:z,...A,children:({width:F})=>jsxRuntime.jsx(sC,{width:F,height:y,columns:I,rows:X,lookup:$,colorScale:w,x:t,y:r,size:h,cellGap:f,cellRadius:m,showValues:g,tooltip:C,plotLabel:H,formatValue:K,formatX:D,formatY:B,onCellClick:k})})}var dC=24,uC=10,mC=10,pC=Cl.memo(function({lines:t,showMarkers:r}){return jsxRuntime.jsx("g",{children:t.map(n=>jsxRuntime.jsxs("g",{children:[n.solid?jsxRuntime.jsx("path",{d:n.solid,fill:"none",stroke:n.color,strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"}):null,n.dashed?jsxRuntime.jsx("path",{d:n.dashed,fill:"none",stroke:n.color,strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round",strokeDasharray:"5 4"}):null,r?n.markers.map(o=>jsxRuntime.jsx("circle",{cx:o.x,cy:o.y,r:3,fill:n.color,strokeWidth:2,className:"stroke-white dark:stroke-gray-800"},`${o.x}-${o.y}`)):null]},n.key))})});function gC({width:e,height:t,data:r,resolvedSeries:n,x:o,y:a,grid:s,size:l,curve:i,forecastFrom:c,forecastLabel:d,markers:u,connectNulls:f,referenceLines:m,annotations:g,annotationsLabel:y,overlay:b,maxPoints:h,brush:x,onBrush:L,brushLabel:C,syncEnabled:S,margin:v,tooltip:R,onPointClick:N,plotLabel:M,formatValue:P,formatX:E}){let[W,T]=Cl.useState(null),O=W!==null&&W<r.length?W:null,[H,k]=Cl.useState(null),z=uo(),A=S?z:null,I=Cl.useMemo(()=>{let Z=n.filter(ae=>!ae.hidden),ie=Jt({width:e,height:t,data:r,x:o,y:a,bounds:Qt(vr(r,Z.map(ae=>ae.key))),margin:v,placement:"point",formatValue:P,formatX:E,extraTop:d?uC:0}),V=ie.categoryCenters,oe=ie.valueScale,pe=c===void 0?-1:ie.xValues.findIndex(ae=>rt(ae)===rt(c)),Te=Z.map(ae=>{let re=r.map((Re,He)=>{let Ee=Ae(Re,ae.key);return {x:V[He],y:Ee===null?Number.NaN:oe(Ee),defined:Ee!==null}}),ce={connectNulls:f},De=pe>=0,Ge=Re=>h&&h>0?dl(Re,h):Re,be=Ge(De?re.slice(0,pe+1):re),Me=ae.dashed?Ge(re):De?Ge(re.slice(pe)):[];return h||Yo("LineChart",re.length),{key:ae.key,color:ae.color,solid:ae.dashed?"":nn(be,i,ce),dashed:ae.dashed||De?nn(Me,i,ce):"",markers:[...be,...ae.dashed?[]:Me].filter(Re=>Re.defined!==false)}}),ze=r.length>1?ie.innerWidth/(r.length-1):0;return {visible:Z,locate:On(ie),plot:kn({geometry:ie,width:e,height:t,data:r,series:Z,formatValue:P,formatX:E}),xValues:ie.xValues,xPositions:V,xTicks:ie.categoryTicks,yTicks:ie.valueTicks,yScale:oe,innerWidth:ie.innerWidth,innerHeight:ie.innerHeight,margin:ie.margin,lines:Te,forecastIndex:pe,showMarkers:u==="always"||u==="auto"&&ze>=dC&&r.length>1}},[r,n,o,a,e,t,v,i,f,c,d,u,h,P,E]),X=Cl.useCallback(Z=>I.visible.map(ie=>{let V=Ae(r[Z],ie.key);return {seriesKey:ie.key,seriesLabel:Vt(ie),color:ie.color,value:V,formattedValue:V===null?"\u2014":P(V),datum:r[Z]}}),[r,I.visible,P]),$=A?A.brush:H,K=Cl.useCallback(Z=>{k(Z),A?.setBrush(Z),L?.(Z);},[A,L]),D=so({enabled:x,active:$!==null,centers:I.xPositions,xValues:I.xValues,offset:I.margin.left,orientation:"vertical",onCommit:K}),B=Cl.useCallback(Z=>{if(D.onPointerMove(Z),R===false||r.length===0)return;let ie=Z.currentTarget.getBoundingClientRect(),V=Z.clientX-ie.left-I.margin.left,oe=Dt(I.xPositions,V);T(oe>=0?oe:null),A?.setHovered(oe>=0?I.xValues[oe]:null);},[D,R,r.length,I.margin.left,I.xPositions,I.xValues,A]),w=Cl.useCallback(()=>{T(null),A?.setHovered(null);},[A]),G=Cl.useCallback(Z=>{if(r.length===0)return;D.onKeyDown(Z,O);let ie=r.length-1,V=O??0,oe=Z.key==="ArrowRight"?Math.min(ie,V+1):Z.key==="ArrowLeft"?Math.max(0,V-1):Z.key==="Home"?0:Z.key==="End"?ie:Z.key==="Escape"?null:void 0;oe!==void 0&&(Z.preventDefault(),T(oe),A?.setHovered(oe===null?null:I.xValues[oe]));},[r.length,O,D,A,I.xValues]),q=Cl.useCallback(()=>{if(D.consumedClick()||!N||O===null)return;let[Z]=X(O);Z&&N({...Z,index:O,x:I.xValues[O]});},[D,N,O,X,I.xValues]),j=O!==null||!A?.hovered?null:(()=>{let Z=rt(A.hovered),ie=I.xValues.findIndex(V=>rt(V)===Z);return ie<0?null:ie})(),U=O??j,F=U===null?null:X(U),_=(F??[]).filter(Z=>Z.value!==null),J=D.dragging??$,ne=(()=>{if(!J)return null;let Z=I.locate(J.from),ie=I.locate(J.to);return Z===null||ie===null?null:{from:Z,to:ie}})(),Y=wn(b),ee=O===null||F===null?null:{x:I.xValues[O],xLabel:E(I.xValues[O],O),index:O,points:F};return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsxs("svg",{width:e,height:t,role:"img","aria-label":M??[I.visible.map(Z=>Vt(Z)).join(", "),no(g,y)].filter(Boolean).join(". "),tabIndex:0,className:p("touch-none focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-blue-500",x&&"select-none"),onPointerDown:D.onPointerDown,onPointerMove:B,onPointerUp:D.onPointerUp,onPointerCancel:D.onPointerUp,onPointerLeave:w,onKeyDown:G,onBlur:w,onClick:q,children:[jsxRuntime.jsxs("g",{transform:`translate(${I.margin.left}, ${I.margin.top})`,children:[jsxRuntime.jsx(Yt,{width:I.innerWidth,height:I.innerHeight,horizontal:s==="y"||s==="both"?I.yTicks.map(Z=>Z.offset):void 0,vertical:s==="x"||s==="both"?I.xTicks.map(Z=>Z.offset):void 0}),g?jsxRuntime.jsx(rn,{layer:"under",annotations:g,xAt:I.locate,yAt:I.yScale,width:I.innerWidth,height:I.innerHeight}):null,ne?jsxRuntime.jsx(ao,{from:ne.from,to:ne.to,width:I.innerWidth,height:I.innerHeight,live:D.dragging!==null,label:C}):null,Y.under?.(I.plot),m?.map(Z=>{let ie=I.yScale(Z.value),V=ie<mC?ie+12:ie-4;return jsxRuntime.jsxs("g",{children:[jsxRuntime.jsx("line",{x1:0,y1:ie,x2:I.innerWidth,y2:ie,stroke:Z.color??"var(--color-chart-muted)",strokeWidth:1,strokeDasharray:Z.dashed===false?void 0:"4 4"}),Z.label?jsxRuntime.jsx("text",{x:I.innerWidth,y:V,textAnchor:"end",className:"fill-gray-500 text-[10px] dark:fill-gray-400",children:Z.label}):null]},`${Z.value}-${Z.label??""}`)}),I.forecastIndex>=0?jsxRuntime.jsxs("g",{children:[jsxRuntime.jsx("line",{x1:I.xPositions[I.forecastIndex],y1:0,x2:I.xPositions[I.forecastIndex],y2:I.innerHeight,className:"stroke-gray-300 dark:stroke-gray-600",strokeWidth:1,strokeDasharray:"3 3"}),d?jsxRuntime.jsx("text",{x:I.xPositions[I.forecastIndex]+4,y:-2,className:"fill-gray-500 text-[10px] dark:fill-gray-400",children:d}):null]}):null,jsxRuntime.jsx(pC,{lines:I.lines,showMarkers:I.showMarkers}),g?jsxRuntime.jsx(rn,{annotations:g,xAt:I.locate,yAt:I.yScale,width:I.innerWidth,height:I.innerHeight}):null,Y.over?.(I.plot),U!==null?jsxRuntime.jsxs("g",{"aria-hidden":"true",children:[jsxRuntime.jsx("line",{x1:I.xPositions[U],y1:0,x2:I.xPositions[U],y2:I.innerHeight,className:"stroke-gray-400 dark:stroke-gray-500",strokeWidth:1,strokeDasharray:O===null?"3 3":void 0}),_.map(Z=>jsxRuntime.jsx("circle",{cx:I.xPositions[U],cy:I.yScale(Z.value),r:4,fill:Z.color,strokeWidth:2,className:"stroke-white dark:stroke-gray-800"},Z.seriesKey))]}):null]}),jsxRuntime.jsx("g",{transform:`translate(${I.margin.left}, ${I.margin.top+I.innerHeight})`,children:o.hidden?null:jsxRuntime.jsx(tt,{orientation:"bottom",ticks:I.xTicks,length:I.innerWidth,label:o.label,size:l})}),jsxRuntime.jsx("g",{transform:`translate(${I.margin.left}, ${I.margin.top})`,children:a?.hidden?null:jsxRuntime.jsx(tt,{orientation:"left",ticks:I.yTicks,length:I.innerHeight,showLine:false,label:a?.label,size:l})})]}),ee&&R!==false?jsxRuntime.jsx(vt,{x:I.margin.left+I.xPositions[ee.index],y:I.margin.top+(_.length>0?Math.min(..._.map(Z=>I.yScale(Z.value))):I.innerHeight/2),containerWidth:e,children:typeof R=="function"?R(ee):jsxRuntime.jsx(Tr,{title:ee.xLabel,points:ee.points})}):null]})}function fC({data:e,series:t,x:r,y:n,height:o=240,width:a,size:s="md",grid:l="y",legend:i,tooltip:c=true,tableView:d=false,emphasis:u,title:f,description:m,loading:g=false,emptyState:y,error:b=false,errorState:h,onRetry:x,actions:L,onPointClick:C,curve:S="monotone",forecastFrom:v,forecastLabel:R,markers:N="auto",connectNulls:M=false,referenceLines:P,annotations:E,overlay:W,legendToggle:T=true,maxPoints:O,brush:H=false,onBrush:k,brushLabel:z,sync:A=true,margin:I,locale:X,plotLabel:$,className:K,...D}){let B=Ve(),[w,G]=Cl.useState(()=>new Set),q=Cl.useMemo(()=>t.map((Y,ee)=>({...Y,hidden:Y.hidden||w.has(Y.key),color:Br(Y,ee,u)})),[t,w,u]),j=Cl.useMemo(()=>n?.format??(Y=>pt(Y,X)),[n?.format,X]),U=Cl.useMemo(()=>r.format??(Y=>r.scale==="time"?st(Y instanceof Date?Y:new Date(Xr(Y)),X):st(Y,X)),[r.format,r.scale,X]),F=Cl.useCallback(Y=>{G(ee=>{let Z=new Set(ee);return Z.has(Y)?Z.delete(Y):Z.add(Y),Z});},[]),_=i===void 0?t.length>=2:i!==false,J=typeof i=="string"?i:"bottom",ne=q.filter(Y=>!Y.hidden).length;return jsxRuntime.jsx(xt,{title:f,description:m,height:o,width:a,size:s,loading:g,empty:e.length===0||ne===0,emptyState:y,error:b,errorState:h,onRetry:x,actions:L,tableView:d,legendPosition:J,legend:_?jsxRuntime.jsx(jt,{items:Gr(q,u),position:J,marker:"line",size:s,onToggle:T?F:void 0}):void 0,table:d?jsxRuntime.jsx(Ot,{data:e,series:q,xKey:r.key,xLabel:r.label??r.key,formatX:U,formatValue:j,caption:typeof f=="string"?f:void 0}):void 0,className:K,...D,children:({width:Y})=>jsxRuntime.jsx(gC,{width:Y,height:o,data:e,resolvedSeries:q,x:r,y:n,grid:l,size:s,curve:S,forecastFrom:v,forecastLabel:R,markers:N,connectNulls:M,referenceLines:P,annotations:E,annotationsLabel:B.chartAnnotations,overlay:W,maxPoints:O,brush:H,onBrush:k,brushLabel:z??B.chartBrush,syncEnabled:A,margin:I,tooltip:c,onPointClick:C,plotLabel:$,formatValue:j,formatX:U})})}var vC={sm:"max-w-sm",md:"max-w-2xl",lg:"max-w-4xl",xl:"max-w-6xl",full:"max-w-full"},An=Cl.forwardRef(({isOpen:e,onClose:t,title:r="Modal Title",children:n,buttonLabel:o,onButtonClick:a,className:s,allowFullScreen:l=false,showSubmit:i=true,submitLabel:c,onSubmitClick:d,showCancel:u=false,cancelLabel:f,onCancelClick:m,buttonsPosition:g="right",showHeaderDivider:y=true,showFooterDivider:b=true,description:h,icon:x,size:L="md",reverseButtons:C=false,headerClassName:S,contentClassName:v,footerClassName:R,titleClassName:N,descriptionClassName:M,submitClassName:P,cancelClassName:E,closeLabel:W,enterFullScreenLabel:T,exitFullScreenLabel:O,"aria-label":H,closeOnEscape:k=true,trapFocus:z=true,initialFocus:A,returnFocus:I,lockScroll:X=true},$)=>{let[K,D]=Cl.useState(false),B=Ve(),w=Cl.useId(),G=`${w}-title`,q=`${w}-description`,{dialogRef:j,dialogProps:U}=So({open:e,onClose:t,closeOnEscape:k,trapFocus:z,initialFocus:A,returnFocus:I,lockScroll:X});if(!e)return null;let F=o??c??B.confirm,_=f??B.cancel,J=W??B.closeModal,ne=K?O??B.exitFullScreen:T??B.enterFullScreen,Y=a??d,ee=async()=>{Y&&await Y(),t();},Z=async()=>{m&&await m(),t();};return jsxRuntime.jsx("div",{className:p("overflow-y-auto overflow-x-hidden fixed inset-0 z-50 flex items-center justify-center bg-black/30 backdrop-blur-sm",s),"aria-hidden":!e,children:jsxRuntime.jsx("div",{className:p("relative p-4 w-full max-h-full transition-all duration-300",K?"max-w-full h-full p-0":vC[L]),ref:$,children:jsxRuntime.jsxs("div",{...U,ref:j,"aria-labelledby":r?G:void 0,"aria-label":r?void 0:H,"aria-describedby":h?q:void 0,className:p("relative bg-white shadow dark:bg-gray-700 border-b-4 transition-all duration-300 focus:outline-none",K?"rounded-none h-full flex flex-col":"rounded-lg"),children:[jsxRuntime.jsxs("div",{className:p("flex items-center justify-between p-4 md:p-5 rounded-t",y&&"border-b border-gray-200 dark:border-gray-600",S),children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-3",children:[x&&jsxRuntime.jsx("div",{className:"shrink-0 text-gray-500 dark:text-gray-400",children:x}),jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("h3",{id:G,className:p("text-xl font-semibold text-gray-900 dark:text-white",N),children:r}),h&&jsxRuntime.jsx("p",{id:q,className:p("mt-1 text-sm text-gray-500 dark:text-gray-400",M),children:h})]})]}),jsxRuntime.jsxs("div",{className:"flex items-center gap-1 ms-auto",children:[l&&jsxRuntime.jsx("button",{type:"button",onClick:()=>D(ie=>!ie),className:"text-gray-400 bg-transparent hover:bg-gray-200 hover:text-gray-900 rounded-lg text-sm w-8 h-8 inline-flex justify-center items-center dark:hover:bg-gray-600 dark:hover:text-white","aria-label":ne,children:K?jsxRuntime.jsx("svg",{className:"w-3.5 h-3.5","aria-hidden":"true",xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 18 18",children:jsxRuntime.jsx("path",{stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",d:"M7 1H1v6m16 0V1h-6m0 16h6v-6M1 11v6h6"})}):jsxRuntime.jsx("svg",{className:"w-3.5 h-3.5","aria-hidden":"true",xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 18 18",children:jsxRuntime.jsx("path",{stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",d:"M11 1h6v6M1 11v6h6m0-12L1 1m16 16-6-6"})})}),jsxRuntime.jsxs("button",{type:"button",onClick:t,className:"text-gray-400 bg-transparent hover:bg-gray-200 hover:text-gray-900 rounded-lg text-sm w-8 h-8 inline-flex justify-center items-center dark:hover:bg-gray-600 dark:hover:text-white",children:[jsxRuntime.jsx("svg",{className:"w-3 h-3","aria-hidden":"true",xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 14 14",children:jsxRuntime.jsx("path",{stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",d:"m1 1 6 6m0 0 6 6M7 7l6-6M7 7l-6 6"})}),jsxRuntime.jsx("span",{className:"sr-only",children:J})]})]})]}),jsxRuntime.jsx("div",{className:p("p-4 md:p-5 space-y-4",K&&"flex-1 overflow-y-auto",v),children:n}),(i||u)&&jsxRuntime.jsxs("div",{className:p("flex items-center gap-2 p-4 md:p-5 rounded-b",b&&"border-t border-gray-200 dark:border-gray-600",g==="right"?"justify-end":g==="center"?"justify-center":"justify-start",C&&"flex-row-reverse",R),children:[u&&jsxRuntime.jsx("button",{type:"button",onClick:Z,className:p("text-gray-500 bg-white hover:bg-gray-100 focus:ring-4 focus:outline-none focus:ring-gray-200 font-medium rounded-lg text-sm px-5 py-2.5 border border-gray-200 dark:bg-gray-700 dark:text-gray-300 dark:border-gray-500 dark:hover:bg-gray-600 dark:hover:text-white",E),children:_}),i&&jsxRuntime.jsx("button",{type:"button",onClick:ee,className:p("text-white bg-blue-600 hover:bg-blue-700 focus:ring-4 focus:outline-none focus:ring-blue-300 font-medium rounded-lg text-sm px-5 py-2.5 text-center dark:bg-blue-500 dark:hover:bg-blue-600",P),children:F})]})]})})})});An.displayName="Modal";function wC(e,t,r,n){let o=r*2+1+n*2+2;if(t<=o)return Array.from({length:t},(f,m)=>m+1);let a=Array.from({length:n},(f,m)=>m+1).filter(f=>f<=t),s=Array.from({length:n},(f,m)=>t-n+1+m).filter(f=>f>=1),l=Math.max(e-r,n+1),i=Math.min(e+r,t-n),c=l>n+2,d=i<t-n-1,u=[];for(let f of a)u.push(f);if(c)u.push("ellipsis");else for(let f=n+1;f<l;f++)u.push(f);for(let f=l;f<=i;f++)u.push(f);if(d)u.push("ellipsis");else for(let f=i+1;f<=t-n;f++)u.push(f);for(let f of s)u.includes(f)||u.push(f);return u}function NC({className:e}){return jsxRuntime.jsx("svg",{className:e,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24","aria-hidden":"true",children:jsxRuntime.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M15 19l-7-7 7-7"})})}function SC({className:e}){return jsxRuntime.jsx("svg",{className:e,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24","aria-hidden":"true",children:jsxRuntime.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 5l7 7-7 7"})})}function RC({className:e}){return jsxRuntime.jsx("svg",{className:e,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24","aria-hidden":"true",children:jsxRuntime.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M11 19l-7-7 7-7M18 19l-7-7 7-7"})})}function PC({className:e}){return jsxRuntime.jsx("svg",{className:e,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24","aria-hidden":"true",children:jsxRuntime.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M13 5l7 7-7 7M6 5l7 7-7 7"})})}var TC={sm:{button:"h-7 min-w-7 px-1.5 text-xs",icon:"h-3 w-3",gap:"gap-0.5",text:"text-xs"},md:{button:"h-9 min-w-9 px-2.5 text-sm",icon:"h-4 w-4",gap:"gap-1",text:"text-sm"},lg:{button:"h-11 min-w-11 px-3.5 text-base",icon:"h-5 w-5",gap:"gap-1.5",text:"text-base"}},DC={default:{base:"rounded-md font-medium transition-colors",idle:"text-gray-700 hover:bg-gray-100 dark:text-gray-300 dark:hover:bg-gray-700",active:"bg-blue-600 text-white hover:bg-blue-700 dark:bg-blue-500 dark:hover:bg-blue-600",disabled:"text-gray-300 cursor-not-allowed dark:text-gray-600"},outlined:{base:"rounded-md border font-medium transition-colors",idle:"border-gray-300 text-gray-700 hover:bg-gray-50 dark:border-gray-600 dark:text-gray-300 dark:hover:bg-gray-800",active:"border-blue-600 bg-blue-50 text-blue-600 hover:bg-blue-100 dark:border-blue-400 dark:bg-blue-900/30 dark:text-blue-400 dark:hover:bg-blue-900/50",disabled:"border-gray-200 text-gray-300 cursor-not-allowed dark:border-gray-700 dark:text-gray-600"},minimal:{base:"rounded-md font-medium transition-colors",idle:"text-gray-600 hover:text-gray-900 dark:text-gray-400 dark:hover:text-gray-200",active:"text-blue-600 font-semibold hover:text-blue-700 dark:text-blue-400 dark:hover:text-blue-300",disabled:"text-gray-300 cursor-not-allowed dark:text-gray-600"}};function EC({page:e,totalPages:t,onPageChange:r,size:n="md",variant:o="default",showFirstLast:a=false,siblings:s=1,boundaries:l=1,disabled:i=false,labels:c,totalItems:d,pageSize:u,pageSizeOptions:f,onPageSizeChange:m,className:g,...y}){let b=TC[n],h=DC[o],x=Cl.useMemo(()=>wC(e,t,s,l),[e,t,s,l]),L=Cl.useCallback(P=>{i||P<1||P>t||P===e||r(P);},[i,t,e,r]),C=e<=1,S=e>=t,v=p("inline-flex items-center justify-center select-none",b.button,h.base),R=(P,E,W,T)=>jsxRuntime.jsx("button",{type:"button",onClick:P,disabled:i||E,"aria-label":W,"aria-disabled":i||E,className:p(v,i||E?h.disabled:h.idle),children:T}),N=d!==void 0&&u?(e-1)*u+1:void 0,M=d!==void 0&&u?Math.min(e*u,d):void 0;return jsxRuntime.jsxs("nav",{"aria-label":"Pagination",className:p("flex items-center",b.gap,g),...y,children:[d!==void 0&&u&&jsxRuntime.jsxs("span",{className:p("mr-2 text-gray-600 dark:text-gray-400 whitespace-nowrap",b.text),children:[N,"\u2013",M," of ",d]}),f&&f.length>0&&m&&jsxRuntime.jsxs("div",{className:p("mr-2 flex items-center whitespace-nowrap",b.gap,b.text),children:[jsxRuntime.jsx("label",{htmlFor:"pagination-page-size",className:"text-gray-600 dark:text-gray-400",children:"Rows:"}),jsxRuntime.jsx("select",{id:"pagination-page-size",value:u,onChange:P=>m(Number(P.target.value)),disabled:i,className:p("rounded border border-gray-300 bg-white px-1.5 py-0.5 dark:border-gray-600 dark:bg-gray-800 dark:text-gray-200",b.text,i&&"cursor-not-allowed opacity-50"),children:f.map(P=>jsxRuntime.jsx("option",{value:P,children:P},P))})]}),jsxRuntime.jsxs("div",{className:p("flex items-center",b.gap),children:[a&&R(()=>L(1),C,c?.first??"Go to first page",jsxRuntime.jsx(RC,{className:b.icon})),R(()=>L(e-1),C,c?.previous??"Go to previous page",jsxRuntime.jsx(NC,{className:b.icon})),x.map((P,E)=>P==="ellipsis"?jsxRuntime.jsx("span",{className:p("inline-flex items-center justify-center select-none",b.button,"text-gray-400 dark:text-gray-500"),"aria-hidden":"true",children:"\u2026"},`ellipsis-${E}`):jsxRuntime.jsx("button",{type:"button",onClick:()=>L(P),disabled:i,"aria-current":P===e?"page":void 0,"aria-label":`Page ${P}`,className:p(v,P===e?h.active:i?h.disabled:h.idle),children:P},P)),R(()=>L(e+1),S,c?.next??"Go to next page",jsxRuntime.jsx(SC,{className:b.icon})),a&&R(()=>L(t),S,c?.last??"Go to last page",jsxRuntime.jsx(PC,{className:b.icon}))]})]})}var IC=.62,AC=2,zC=3,BC=.16,HC=64,WC=22,pc=6,Tm=false;function VC({width:e,height:t,slices:r,variant:n,innerRadius:o,showLabels:a,centerLabel:s,tooltip:l,patterns:i,patternBaseId:c,plotLabel:d,formatValue:u,onSliceClick:f}){let[m,g]=Cl.useState(null),y=Cl.useMemo(()=>{let N=a?HC:8,M=a?WC:8,P=Math.max(0,Math.min((e-N*2)/2,(t-M*2)/2));return {cx:e/2,cy:t/2,outerRadius:P,inner:n==="donut"?P*(o??IC):(o??0)*P,pad:P>0&&r.length>1?AC/P/2:0}},[e,t,n,o,a,r.length]),{cx:b,cy:h,outerRadius:x,inner:L,pad:C}=y,S=Cl.useCallback(N=>{let M=(N.startAngle+N.endAngle)/2,P=Math.sin(M)>=0,E={x:b+Math.sin(M)*(x+4),y:h-Math.cos(M)*(x+4)},W={x:b+Math.sin(M)*(x+14),y:h-Math.cos(M)*(x+14)},T={x:P?W.x+10:W.x-10,y:W.y};return {from:E,elbow:W,end:T,anchor:P?"start":"end"}},[b,h,x]),v=Cl.useCallback(N=>{if(r.length===0)return;let M=r.length-1,P=m??0,E=N.key==="ArrowRight"||N.key==="ArrowDown"?Math.min(M,P+1):N.key==="ArrowLeft"||N.key==="ArrowUp"?Math.max(0,P-1):N.key==="Home"?0:N.key==="End"?M:N.key==="Escape"?null:void 0;E!==void 0&&(N.preventDefault(),g(E));},[r.length,m]),R=m===null?null:r[m];return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsxs("svg",{width:e,height:t,role:"img","aria-label":d??r.map(N=>N.label).join(", "),tabIndex:0,className:"touch-none focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-blue-500",onPointerLeave:()=>g(null),onBlur:()=>g(null),onKeyDown:v,children:[i?jsxRuntime.jsx(co,{id:c,entries:r.map(N=>({slot:N.slot,color:N.color}))}):null,r.map((N,M)=>jsxRuntime.jsx("path",{d:Bd({cx:b,cy:h,innerRadius:L,outerRadius:x+(m===M?zC:0),startAngle:N.startAngle+C,endAngle:Math.max(N.startAngle+C,N.endAngle-C)}),fill:lo(i,c,N.slot,N.color),onPointerEnter:()=>l===false?void 0:g(M),onClick:()=>f?.({key:N.key,label:N.label,value:N.value,share:N.share})},N.key)),a?r.filter(N=>N.endAngle-N.startAngle>=BC).map(N=>{let{from:M,elbow:P,end:E,anchor:W}=S(N);return jsxRuntime.jsxs("g",{"aria-hidden":"true",children:[jsxRuntime.jsx("polyline",{points:`${M.x},${M.y} ${P.x},${P.y} ${E.x},${E.y}`,fill:"none",className:"stroke-gray-300 dark:stroke-gray-600",strokeWidth:1}),jsxRuntime.jsx("text",{x:W==="start"?E.x+3:E.x-3,y:E.y,textAnchor:W,dominantBaseline:"middle",className:"fill-gray-600 text-[10px] dark:fill-gray-300",children:N.label})]},`label-${N.key}`)}):null,n==="donut"&&s?jsxRuntime.jsxs("g",{"aria-hidden":"true",children:[jsxRuntime.jsx("text",{x:b,y:h-(s.label?2:0),textAnchor:"middle",dominantBaseline:"middle",className:"fill-gray-900 text-lg font-semibold dark:fill-gray-100",children:s.value}),s.label?jsxRuntime.jsx("text",{x:b,y:h+14,textAnchor:"middle",dominantBaseline:"middle",className:"fill-gray-500 text-[10px] dark:fill-gray-400",children:s.label}):null]}):null]}),R&&l!==false?jsxRuntime.jsx(vt,{x:b+Math.sin((R.startAngle+R.endAngle)/2)*(x*.7),y:h-Math.cos((R.startAngle+R.endAngle)/2)*(x*.7),containerWidth:e,children:typeof l=="function"?l({seriesKey:R.key,seriesLabel:R.label,color:R.color,value:R.value,formattedValue:u(R.value),datum:{},share:R.share}):jsxRuntime.jsx(Tr,{title:R.label,points:[{seriesKey:R.key,seriesLabel:Zt(R.share),color:R.color,value:R.value,formattedValue:u(R.value),datum:{}}]})}):null]})}function OC({data:e,x:t,value:r,variant:n="pie",innerRadius:o,maxSlices:a=pc,otherLabel:s,sort:l="desc",showLabels:i=true,centerLabel:c,patterns:d=false,height:u=260,width:f,size:m="md",legend:g,tooltip:y=true,tableView:b=false,title:h,description:x,loading:L=false,emptyState:C,error:S=false,errorState:v,onRetry:R,actions:N,locale:M,plotLabel:P,onSliceClick:E,className:W,...T}){let O=Ve(),H=Cl.useId(),k=Cl.useCallback(D=>pt(D,M),[M]),z=Cl.useCallback(D=>t.format?t.format(D,0):st(D,M),[t,M]),{slices:A,total:I,rows:X}=Cl.useMemo(()=>{let D=e.map((F,_)=>({key:String(gt(F,t.key,_)),label:z(gt(F,t.key,_)),value:Ae(F,r)??0,color:zr(_),slot:_,datum:F})),B=l==="none"?D:[...D].sort((F,_)=>l==="asc"?F.value-_.value:_.value-F.value),w=B.slice(0,a),G=B.slice(a);G.length>0&&w.push({key:"__other__",label:s??O.chartOther,value:G.reduce((F,_)=>F+_.value,0),color:Ar,slot:-1,datum:{}}),w.length>pc&&!Tm&&(Tm=true,console.warn(`[@synertech/ui] A PieChart is drawing ${w.length} slices. Past ${pc} the slices stop being tellable apart: lower \`maxSlices\`, or use a BarChart, which compares lengths rather than angles.`));let q=w.reduce((F,_)=>F+Math.max(0,_.value),0),j=0;return {slices:w.map(F=>{let _=q===0?0:Math.max(0,F.value)/q,J=j;return j+=_*Math.PI*2,{...F,share:_,startAngle:J,endAngle:j}}),total:q,rows:w.map(F=>({[t.key]:F.label,[r]:F.value}))}},[e,t.key,r,l,a,s,O.chartOther,z]),$=g===void 0?true:g!==false,K=typeof g=="string"?g:"bottom";return jsxRuntime.jsx(xt,{title:h,description:x,height:u,width:f,size:m,loading:L,empty:A.length===0||I===0,emptyState:C,error:S,errorState:v,onRetry:R,actions:N,tableView:b,legendPosition:K,legend:$?jsxRuntime.jsx(jt,{items:A.map(D=>({key:D.key,label:`${D.label} \xB7 ${Zt(D.share)}`,color:D.color,...d?{pattern:D.slot}:{}})),position:K,marker:"rect",size:m}):void 0,table:b?jsxRuntime.jsx(Ot,{data:X,series:[{key:r,label:t.label??r}],xKey:t.key,xLabel:t.label??t.key,formatValue:k,caption:typeof h=="string"?h:void 0}):void 0,className:W,...T,children:({width:D})=>jsxRuntime.jsx(VC,{width:D,height:u,slices:A,variant:n,innerRadius:o,showLabels:i,centerLabel:c,tooltip:y,patterns:d,patternBaseId:H,plotLabel:P,formatValue:k,onSliceClick:E})})}var $C={xs:"h-1",sm:"h-1.5",md:"h-2.5",lg:"h-4",xl:"h-6"},_C={default:"bg-gray-500 dark:bg-gray-400",primary:"bg-blue-600 dark:bg-blue-500",success:"bg-green-600 dark:bg-green-500",warning:"bg-yellow-500 dark:bg-yellow-400",error:"bg-red-600 dark:bg-red-500",info:"bg-cyan-600 dark:bg-cyan-500"},XC={default:"text-gray-700 dark:text-gray-300",primary:"text-blue-600 dark:text-blue-400",success:"text-green-600 dark:text-green-400",warning:"text-yellow-600 dark:text-yellow-400",error:"text-red-600 dark:text-red-400",info:"text-cyan-600 dark:text-cyan-400"},Em="bg-[repeating-linear-gradient(45deg,transparent,transparent_10px,rgba(255,255,255,0.2)_10px,rgba(255,255,255,0.2)_20px)]",GC={default:"bg-gradient-to-r from-gray-400 to-gray-600",primary:"bg-gradient-to-r from-blue-400 to-blue-700",success:"bg-gradient-to-r from-green-400 to-green-700",warning:"bg-gradient-to-r from-yellow-300 to-yellow-600",error:"bg-gradient-to-r from-red-400 to-red-700",info:"bg-gradient-to-r from-cyan-400 to-cyan-700"};function Mm({value:e=0,indeterminate:t=false,size:r="md",color:n="primary",variant:o="default",showValue:a=false,valueFormat:s,label:l,animated:i=true,className:c,...d}){let u=Math.min(100,Math.max(0,e)),f=o==="gradient"?GC[n]:_C[n],m=s?s(u):`${Math.round(u)}%`;return jsxRuntime.jsxs("div",{className:p("w-full",c),...d,children:[(l||a)&&jsxRuntime.jsxs("div",{className:"flex items-center justify-between mb-1",children:[l&&jsxRuntime.jsx("span",{className:"text-sm font-medium text-gray-700 dark:text-gray-300",children:l}),a&&!t&&jsxRuntime.jsx("span",{className:p("text-sm font-semibold",XC[n],!l&&"ml-auto"),children:m})]}),jsxRuntime.jsx("div",{role:"progressbar","aria-valuenow":t?void 0:u,"aria-valuemin":0,"aria-valuemax":100,"aria-label":l,className:p("relative w-full overflow-hidden rounded-full bg-gray-200 dark:bg-gray-700",$C[r]),children:t?jsxRuntime.jsx("div",{className:p("absolute h-full w-1/3 rounded-full",f,o==="striped"&&Em,"animate-[progress-indeterminate_1.5s_ease-in-out_infinite]")}):jsxRuntime.jsx("div",{className:p("h-full rounded-full",f,o==="striped"&&Em,i&&"transition-[width] duration-300 ease-out"),style:{width:`${u}%`}})})]})}Mm.displayName="ProgressBar";var jC=e=>({sm:"w-4 h-4",md:"w-5 h-5",lg:"w-6 h-6"})[e],qC=e=>({sm:"w-2 h-2",md:"w-2.5 h-2.5",lg:"w-3 h-3"})[e],ZC=(e,t,r,n,o,a,s,l)=>{if(t)return p("border-2",n?"":"border-red-500",r&&!o?"bg-red-500":"");switch(e){case "filled":return p("border-2",l?"":"border-gray-300 dark:border-gray-600",r?a?"":"bg-blue-600 border-blue-600 dark:bg-blue-500 dark:border-blue-500":s?"":"bg-gray-200 border-gray-200 dark:bg-gray-700 dark:border-gray-700");case "outlined":return p("border-[3px]",l?"":r?"border-blue-600 dark:border-blue-500":"border-gray-300 dark:border-gray-600","bg-white dark:bg-gray-800");default:return p("border-2",l?"":r?"border-blue-600 dark:border-blue-500":"border-gray-300 dark:border-gray-600","bg-white dark:bg-gray-800")}},QC={},Im=Cl.forwardRef(({label:e,description:t,value:r,checked:n,defaultChecked:o=false,onCheckedChange:a,size:s="md",variant:l="default",labelPosition:i="right",error:c=false,disabled:d=false,readOnly:u=false,required:f=false,checkedColor:m,uncheckedColor:g,borderColor:y,labelColor:b,errorColor:h,dotColor:x,hoverColor:L,focusRingColor:C,showFocusRing:S=true,className:v,containerClassName:R,...N},M)=>{let[P,E]=Cl.useState(o),W=n!==void 0,T=W?n:P,O=Cl.useId(),H=typeof c=="string"?c:void 0,k=!!c,z=q=>{if(d||u)return;let j=q.target.checked;W||E(j),a?.(j);},A=Cl.useMemo(()=>ZC(l,k,T,h,x,m,g,y),[l,k,T,h,x,m,g,y]),I=Cl.useMemo(()=>{let q={};return m&&T&&(q.backgroundColor=m,q.borderColor=m),g&&!T&&(q.backgroundColor=g),y&&(q.borderColor=y),q},[m,g,y,T]),X=Cl.useMemo(()=>x?{backgroundColor:x}:{},[x]),$=Cl.useMemo(()=>b?{color:b}:{},[b]),K=Cl.useMemo(()=>h?{color:h}:{},[h]),D=b?"":"text-gray-700 dark:text-gray-200",B=h?"":"text-red-500",w=L?"":"hover:border-blue-500 dark:hover:border-blue-400",G=C?"":"focus-visible:ring-blue-500";return jsxRuntime.jsxs("div",{className:p("inline-flex flex-col",R),style:QC,children:[jsxRuntime.jsxs("label",{className:p("inline-flex items-center cursor-pointer",d&&"opacity-50 cursor-not-allowed",u&&"cursor-default",i==="left"&&"flex-row-reverse"),htmlFor:O,children:[jsxRuntime.jsxs("div",{className:"relative inline-flex items-center",children:[jsxRuntime.jsx("input",{ref:M,type:"radio",id:O,value:r,checked:T,onChange:z,disabled:d,readOnly:u,required:f,"aria-invalid":k,"aria-describedby":H?`${O}-error`:void 0,className:"sr-only peer",tabIndex:u?-1:void 0,...N}),jsxRuntime.jsx("div",{className:p("rounded-full transition-all duration-200",jC(s),A,!d&&!u&&w,!d&&!u&&S&&"peer-focus-visible:ring-2 ring-offset-2",!d&&!u&&S&&G,v),style:I,children:T&&jsxRuntime.jsx("div",{className:p("rounded-full absolute inset-0 m-auto transition-all duration-200",qC(s),x?"":l==="outlined"||l==="default"?"bg-blue-600 dark:bg-blue-500":"bg-white"),style:X})})]}),e&&jsxRuntime.jsxs("span",{className:p("select-none",i==="left"?"mr-2":"ml-2",D,d&&"opacity-50"),style:$,children:[e,f&&jsxRuntime.jsx("span",{className:"text-red-500 ml-1",children:"*"})]})]}),t&&!k&&jsxRuntime.jsx("p",{className:p("text-sm text-gray-500 dark:text-gray-400 mt-1",i==="left"?"text-right":"ml-7"),children:t}),H&&jsxRuntime.jsx("p",{id:`${O}-error`,className:p("text-sm mt-1",i==="left"?"text-right":"ml-7",B),style:K,children:H})]})});Im.displayName="RadioButton";var fc=()=>{},n1=[],o1=jsxRuntime.jsx("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none","aria-hidden":"true",className:"shrink-0",children:jsxRuntime.jsx("path",{d:"M4 6L8 10L12 6",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})}),a1=jsxRuntime.jsx("svg",{width:"14",height:"14",viewBox:"0 0 14 14",fill:"none","aria-hidden":"true",className:"shrink-0",children:jsxRuntime.jsx("path",{d:"M10.5 3.5L3.5 10.5M3.5 3.5L10.5 10.5",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})}),s1=jsxRuntime.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none","aria-hidden":"true",className:"shrink-0 animate-spin",children:[jsxRuntime.jsx("circle",{cx:"8",cy:"8",r:"6",stroke:"currentColor",strokeWidth:"2",strokeOpacity:"0.25"}),jsxRuntime.jsx("path",{d:"M14 8a6 6 0 00-6-6",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round"})]}),i1=jsxRuntime.jsx("svg",{width:"14",height:"14",viewBox:"0 0 14 14",fill:"none","aria-hidden":"true",className:"shrink-0",children:jsxRuntime.jsx("path",{d:"M11.5 3.5L5.5 10.5L2.5 7.5",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})}),is={sm:{trigger:"h-8 px-2.5 text-xs gap-1.5",content:"text-xs",option:"px-2.5 py-1.5",searchInput:"px-2.5 py-1.5 text-xs"},md:{trigger:"h-10 px-3 text-sm gap-2",content:"text-sm",option:"px-3 py-2",searchInput:"px-3 py-2 text-sm"},lg:{trigger:"h-12 px-4 text-base gap-2.5",content:"text-base",option:"px-4 py-2.5",searchInput:"px-4 py-2.5 text-base"}},Am={default:{trigger:"border border-gray-300 bg-white dark:border-gray-600 dark:bg-gray-800",focus:"focus:ring-2 focus:ring-blue-500 focus:border-blue-500"},outlined:{trigger:"border-2 border-gray-300 bg-transparent dark:border-gray-600",focus:"focus:ring-2 focus:ring-blue-500 focus:border-blue-500"},filled:{trigger:"border border-transparent bg-gray-100 dark:bg-gray-700",focus:"focus:ring-2 focus:ring-blue-500 focus:border-blue-500"}};function Yn(...e){let t="";for(let r=0;r<e.length;r++){let n=e[r];n&&(t&&(t+=" "),t+=n);}return t}function l1(e,t){if(!t)return e;let r=t.toLowerCase();return e.filter(n=>{if(n.label.toLowerCase().includes(r)||n.value.toLowerCase().includes(r))return true;if(n.keywords){for(let o of n.keywords)if(o.toLowerCase().includes(r))return true}return false})}var c1=Cl.memo(Cl.forwardRef(function({option:t,isSelected:r,isHighlighted:n,isDisabled:o,sizeKey:a,optionId:s,onClick:l,onMouseEnter:i,index:c},d){let u=()=>{o||l(t.value);},f=()=>{o||i(c);};return jsxRuntime.jsxs("div",{ref:d,id:s,role:"option","aria-selected":r,"aria-disabled":o||void 0,"data-highlighted":n||void 0,className:Yn(is[a].option,"flex items-center gap-2 cursor-pointer select-none transition-colors",n&&!o&&"bg-blue-50 dark:bg-blue-900/30",r&&!n&&"bg-gray-50 dark:bg-gray-700/50",o&&"opacity-50 cursor-not-allowed"),onClick:u,onMouseEnter:f,children:[t.icon?jsxRuntime.jsx("span",{className:"flex shrink-0 items-center",children:t.icon}):null,jsxRuntime.jsxs("span",{className:"flex flex-col min-w-0 flex-1",children:[jsxRuntime.jsx("span",{className:"truncate",children:t.label}),t.description?jsxRuntime.jsx("span",{className:"text-xs text-gray-500 dark:text-gray-400 truncate",children:t.description}):null]}),r?jsxRuntime.jsx("span",{className:"ml-auto text-blue-600 dark:text-blue-400",children:i1}):null]})}));function d1({options:e=n1,value:t,defaultValue:r,onValueChange:n,searchable:o=false,clearable:a=false,disabled:s=false,readOnly:l=false,loading:i=false,size:c="md",variant:d="default",placeholder:u="Select...",label:f,description:m,helperText:g,error:y,required:b=false,noOptionsText:h="No options",onSearchChange:x,name:L,className:C,triggerClassName:S,contentClassName:v,maxHeight:R=256}){let N=Cl.useId(),M=`${N}-label`,P=`${N}-trigger`,E=`${N}-listbox`,W=Cl.useRef(null),T=Cl.useRef(null),O=Cl.useRef(null),H=Cl.useRef([]),k=t!==void 0,[z,A]=Cl.useState(r??""),I=k?t:z,[X,$]=Cl.useState(false),[K,D]=Cl.useState(""),[B,w]=Cl.useState(-1),[G,q]=Cl.useState(null),j=Cl.useMemo(()=>o?l1(e,K):e,[e,K,o]),U=Cl.useMemo(()=>e.find(re=>re.value===I)??null,[e,I]),F=Cl.useMemo(()=>{let re=new Set;for(let ce of e)ce.disabled&&re.add(ce.value);return re},[e]),_=Cl.useCallback(re=>{k||A(re),(n??fc)(re),$(false),D(""),w(-1),W.current?.focus();},[k,n]),J=Cl.useCallback(re=>{re.stopPropagation(),k||A(""),(n??fc)(""),D(""),W.current?.focus();},[k,n]),ne=Cl.useCallback(()=>{s||l||($(true),D(""),w(-1));},[s,l]),Y=Cl.useCallback(()=>{$(false),D(""),w(-1),W.current?.focus();},[]),ee=Cl.useCallback(()=>{X?Y():ne();},[X,Y,ne]),Z=Cl.useCallback((re,ce)=>{let De=j.length;if(De===0)return -1;let Ge=re;for(let be=0;be<De;be++)if(Ge=((Ge+ce)%De+De)%De,!F.has(j[Ge].value))return Ge;return -1},[j,F]),ie=Cl.useCallback(re=>{if(!(s||l)){if(X){switch(re.key){case "ArrowDown":{re.preventDefault();let ce=Z(B,1);ce!==-1&&w(ce);break}case "ArrowUp":{re.preventDefault();let ce=Z(B,-1);ce!==-1&&w(ce);break}case "Home":{re.preventDefault();let ce=Z(-1,1);ce!==-1&&w(ce);break}case "End":{re.preventDefault();let ce=Z(j.length,-1);ce!==-1&&w(ce);break}case "Enter":{if(re.preventDefault(),B>=0&&B<j.length){let ce=j[B];F.has(ce.value)||_(ce.value);}break}case " ":if(re.preventDefault(),B>=0&&B<j.length){let ce=j[B];F.has(ce.value)||_(ce.value);}else Y();break;case "Escape":re.preventDefault(),Y();break;case "Tab":Y();break}return}switch(re.key){case "ArrowDown":case "ArrowUp":re.preventDefault(),ne();break;case "Enter":case " ":re.preventDefault(),ne();break}}},[s,l,X,ne,Y,B,j,F,Z,_]),V=Cl.useCallback(re=>{switch(re.key){case "ArrowDown":{re.preventDefault();let ce=Z(B,1);ce!==-1&&w(ce);break}case "ArrowUp":{re.preventDefault();let ce=Z(B,-1);ce!==-1&&w(ce);break}case "Home":{re.preventDefault();let ce=Z(-1,1);ce!==-1&&w(ce);break}case "End":{re.preventDefault();let ce=Z(j.length,-1);ce!==-1&&w(ce);break}case "Enter":{if(re.preventDefault(),B>=0&&B<j.length){let ce=j[B];F.has(ce.value)||_(ce.value);}break}case "Escape":re.preventDefault(),Y();break;case "Tab":Y();break}},[B,j,F,Z,_,Y]),oe=Cl.useCallback(re=>{let ce=re.target.value;D(ce),w(-1),(x??fc)(ce);},[x]);Cl.useEffect(()=>{if(!X)return;let re=ce=>{let De=ce.target;W.current?.contains(De)||T.current?.contains(De)||Y();};return document.addEventListener("mousedown",re),document.addEventListener("touchstart",re,{passive:true}),()=>{document.removeEventListener("mousedown",re),document.removeEventListener("touchstart",re);}},[X,Y]),Cl.useEffect(()=>{if(!X||!W.current){q(null);return}let re=()=>{let ce=W.current;if(!ce)return;let De=ce.getBoundingClientRect(),Ge=window.innerHeight-De.bottom,be=De.top,Me=R+8,Re=Ge<Me&&be>Ge?"top":"bottom";q({top:Re==="bottom"?De.bottom+window.scrollY+4:De.top+window.scrollY-Me,left:De.left+window.scrollX,width:De.width,placement:Re});};return re(),window.addEventListener("scroll",re,true),window.addEventListener("resize",re),()=>{window.removeEventListener("scroll",re,true),window.removeEventListener("resize",re);}},[X,R]),Cl.useEffect(()=>{X&&o&&O.current?.focus();},[X,o]),Cl.useEffect(()=>{let re=T.current;if(!(!X||!re))return Pn(re,()=>W.current)},[X]),Cl.useEffect(()=>{if(B>=0){let re=H.current[B];re&&typeof re.scrollIntoView=="function"&&re.scrollIntoView({block:"nearest"});}},[B]);let pe=I!==""&&I!==void 0,Te=a&&pe&&!s&&!l&&!i,ze=!s&&!l,ae=Yn("w-full flex items-center justify-between rounded-md transition-colors","text-gray-900 dark:text-gray-100",is[c].trigger,Am[d].trigger,!y&&ze&&Am[d].focus,y&&"border-red-500 dark:border-red-400 focus:ring-2 focus:ring-red-500 focus:border-red-500",s&&"opacity-50 cursor-not-allowed bg-gray-50 dark:bg-gray-900",l&&"cursor-default",!s&&!l&&"cursor-pointer",S);return jsxRuntime.jsxs("div",{className:Yn("flex flex-col gap-1",C),children:[f?jsxRuntime.jsxs("label",{id:M,htmlFor:P,className:"text-sm font-medium text-gray-700 dark:text-gray-300",children:[f,b?jsxRuntime.jsx("span",{className:"text-red-500 ml-0.5","aria-hidden":"true",children:"*"}):null]}):null,m?jsxRuntime.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400",children:m}):null,jsxRuntime.jsxs("button",{ref:W,id:P,type:"button",role:"combobox","aria-expanded":X,"aria-haspopup":"listbox","aria-controls":X?E:void 0,"aria-labelledby":f?M:void 0,"aria-required":b||void 0,"aria-invalid":y?true:void 0,"aria-activedescendant":X&&B>=0?`${N}-option-${B}`:void 0,disabled:s,className:ae,onClick:ze?ee:void 0,onKeyDown:ie,children:[jsxRuntime.jsxs("span",{className:Yn("flex items-center gap-2 min-w-0 flex-1 truncate",!pe&&"text-gray-400 dark:text-gray-500"),children:[U?.icon?jsxRuntime.jsx("span",{className:"flex shrink-0 items-center",children:U.icon}):null,jsxRuntime.jsx("span",{className:"truncate",children:pe&&U?U.label:u})]}),jsxRuntime.jsxs("span",{className:"flex items-center gap-1 shrink-0",children:[i?jsxRuntime.jsx("span",{className:"text-gray-400",children:s1}):null,Te?jsxRuntime.jsx("span",{role:"button",tabIndex:-1,"aria-label":"Clear selection",className:"text-gray-400 hover:text-gray-600 dark:hover:text-gray-300 p-0.5 rounded transition-colors",onClick:J,onMouseDown:re=>re.preventDefault(),children:a1}):null,jsxRuntime.jsx("span",{className:Yn("text-gray-400 transition-transform duration-200",X&&"rotate-180"),children:o1})]})]}),y?jsxRuntime.jsx("p",{role:"alert",className:"text-xs text-red-500 dark:text-red-400",children:y}):g?jsxRuntime.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400",children:g}):null,L?jsxRuntime.jsx("input",{type:"hidden",name:L,value:I??""}):null,X&&G?reactDom.createPortal(jsxRuntime.jsxs("div",{ref:T,role:"listbox",id:E,"aria-labelledby":f?M:void 0,className:Yn("fixed z-50 bg-white dark:bg-gray-800 border border-gray-200 dark:border-gray-700","rounded-md shadow-lg overflow-hidden","animate-in fade-in-0 zoom-in-95",is[c].content,v),style:{top:G.top,left:G.left,width:G.width,position:"absolute"},onKeyDown:V,children:[o?jsxRuntime.jsx("div",{className:"border-b border-gray-200 dark:border-gray-700",children:jsxRuntime.jsx("input",{ref:O,type:"text",role:"searchbox","aria-label":"Search options",className:Yn(is[c].searchInput,"w-full outline-none bg-transparent text-gray-900 dark:text-gray-100","placeholder:text-gray-400 dark:placeholder:text-gray-500"),placeholder:"Search...",value:K,onChange:oe,onKeyDown:V})}):null,jsxRuntime.jsx("div",{className:"overflow-y-auto",style:{maxHeight:R},children:j.length===0?jsxRuntime.jsx("div",{className:Yn(is[c].option,"text-gray-500 dark:text-gray-400 text-center py-4"),children:h}):j.map((re,ce)=>jsxRuntime.jsx(c1,{option:re,isSelected:re.value===I,isHighlighted:ce===B,isDisabled:i||F.has(re.value),sizeKey:c,optionId:`${N}-option-${ce}`,onClick:_,onMouseEnter:w,index:ce,ref:De=>{H.current[ce]=De;}},re.value))})]}),document.body):null]})}var bc=Cl.createContext(null);function Io(){let e=Cl.useContext(bc);if(!e)throw new Error("Sidebar sub-components must be used within <Sidebar>");return e}function p1(){return Io()}var g1=({className:e})=>jsxRuntime.jsx("svg",{className:p("w-4 h-4",e),viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true",children:jsxRuntime.jsx("path",{fillRule:"evenodd",d:"M12.79 5.23a.75.75 0 01-.02 1.06L8.832 10l3.938 3.71a.75.75 0 11-1.04 1.08l-4.5-4.25a.75.75 0 010-1.08l4.5-4.25a.75.75 0 011.06.02z",clipRule:"evenodd"})}),f1=({className:e})=>jsxRuntime.jsx("svg",{className:p("w-4 h-4",e),viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true",children:jsxRuntime.jsx("path",{fillRule:"evenodd",d:"M5.23 7.21a.75.75 0 011.06.02L10 11.168l3.71-3.938a.75.75 0 111.08 1.04l-4.25 4.5a.75.75 0 01-1.08 0l-4.25-4.5a.75.75 0 01.02-1.06z",clipRule:"evenodd"})}),h1=({className:e})=>jsxRuntime.jsx("svg",{className:p("w-5 h-5",e),viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true",children:jsxRuntime.jsx("path",{d:"M6.28 5.22a.75.75 0 00-1.06 1.06L8.94 10l-3.72 3.72a.75.75 0 101.06 1.06L10 11.06l3.72 3.72a.75.75 0 101.06-1.06L11.06 10l3.72-3.72a.75.75 0 00-1.06-1.06L10 8.94 6.28 5.22z"})});function Hm({text:e,position:t,children:r}){let[n,o]=Cl.useState(false),[a,s]=Cl.useState({top:0,left:0}),l=Cl.useRef(null);return jsxRuntime.jsxs("div",{ref:l,onMouseEnter:()=>{if(l.current){let c=l.current.getBoundingClientRect();s({top:c.top+c.height/2,left:t==="left"?c.right+8:c.left-8});}o(true);},onMouseLeave:()=>o(false),className:"relative",children:[r,n&&jsxRuntime.jsx("div",{className:p("fixed z-[9999] px-2.5 py-1.5 text-xs font-medium text-white bg-gray-900 dark:bg-gray-700 rounded-md shadow-lg whitespace-nowrap pointer-events-none",t==="right"&&"-translate-x-full"),style:{top:a.top,left:a.left,transform:`translateY(-50%)${t==="right"?" translateX(-100%)":""}`},role:"tooltip",children:e})]})}function b1({collapsed:e,defaultCollapsed:t=false,onCollapsedChange:r,expandedWidth:n=260,collapsedWidth:o=64,position:a="left",variant:s="default",mobileBreakpoint:l=768,mobileOpen:i,onMobileOpenChange:c,className:d,"aria-label":u,closeLabel:f,trapFocus:m=true,initialFocus:g,returnFocus:y,lockScroll:b=true,children:h}){let x=Ve(),L=Cl.useRef(null),C=Cl.useRef(null),[S,v]=Cl.useState(t),[R,N]=Cl.useState(false),[M,P]=Cl.useState(false),E=e!==void 0,W=E?e:S,T=i!==void 0,O=T?i:R;Cl.useEffect(()=>{let D=window.matchMedia(`(max-width: ${l}px)`),B=w=>{P(w.matches),w.matches||(T||N(false),c?.(false));};return B(D),D.addEventListener("change",B),()=>D.removeEventListener("change",B)},[l,T,c]);let H=Cl.useCallback(()=>{if(M){let D=!O;T||N(D),c?.(D);}else {let D=!W;E||v(D),r?.(D);}},[M,O,W,T,E,c,r]),k=Cl.useCallback(()=>{T||N(false),c?.(false);},[T,c]);Cl.useEffect(()=>{let D=C.current;D&&(M&&!O?(D.setAttribute("inert",""),D.setAttribute("aria-hidden","true")):(D.removeAttribute("inert"),D.removeAttribute("aria-hidden")));},[M,O]);let{dialogRef:z,dialogProps:A}=So({open:M&&O,onClose:k,trapFocus:m,initialFocus:g,returnFocus:y,lockScroll:b,keepInteractive:[L]}),I={default:"bg-white dark:bg-gray-900",bordered:p("bg-white dark:bg-gray-900",a==="left"?"border-r border-gray-200 dark:border-gray-700":"border-l border-gray-200 dark:border-gray-700"),floating:"bg-white dark:bg-gray-900 m-3 rounded-xl shadow-xl border border-gray-200 dark:border-gray-700"},X=W&&!M?o:n,$=jsxRuntime.jsx("aside",{className:p("flex flex-col h-full overflow-hidden transition-[width] duration-200 ease-in-out",I[s],d),style:{width:M?n:X,minWidth:M?n:X},"data-testid":"sidebar","data-collapsed":W&&!M,"data-mobile":M,"data-position":a,children:h}),K={collapsed:W&&!M,isMobile:M,mobileOpen:O,position:a,variant:s,expandedWidth:n,collapsedWidth:o,toggle:H,closeMobile:k,closeLabel:f};return M?jsxRuntime.jsxs(bc.Provider,{value:K,children:[O&&jsxRuntime.jsx("div",{ref:L,className:"fixed inset-0 z-40 bg-black/50 transition-opacity",onClick:k,"aria-hidden":"true","data-testid":"sidebar-overlay"}),jsxRuntime.jsx("div",{ref:D=>{C.current=D,z.current=D;},...A,"aria-label":u??x.sidebar,className:p("fixed top-0 z-50 h-full transition-transform duration-200 ease-in-out focus:outline-none",a==="left"?"left-0":"right-0",O?"translate-x-0":a==="left"?"-translate-x-full":"translate-x-full"),children:$})]}):jsxRuntime.jsx(bc.Provider,{value:K,children:$})}function y1({className:e,children:t}){let r=Io(),n=Ve();return jsxRuntime.jsxs("div",{className:p("flex items-center shrink-0 px-4 h-14 overflow-hidden",r.collapsed&&"justify-center px-2",e),"data-testid":"sidebar-header",children:[t,r.isMobile&&r.mobileOpen&&jsxRuntime.jsx("button",{type:"button",onClick:r.closeMobile,className:"ml-auto p-1 rounded-md text-gray-400 hover:text-gray-600 dark:hover:text-gray-300 hover:bg-gray-100 dark:hover:bg-gray-800 cursor-pointer","aria-label":r.closeLabel??n.closeSidebar,children:jsxRuntime.jsx(h1,{})})]})}function x1({className:e,children:t}){return jsxRuntime.jsx("div",{className:p("flex-1 overflow-y-auto overflow-x-hidden py-2",e),"data-testid":"sidebar-content",children:t})}function v1({className:e,children:t}){let r=Io();return jsxRuntime.jsx("div",{className:p("shrink-0 border-t border-gray-200 dark:border-gray-700 px-4 py-3 overflow-hidden",r.collapsed&&"px-2 flex justify-center",e),"data-testid":"sidebar-footer",children:t})}function C1({label:e,className:t,children:r}){let n=Io();return jsxRuntime.jsxs("div",{className:p("py-2",t),"data-testid":"sidebar-group",children:[e&&!n.collapsed&&jsxRuntime.jsx("div",{className:"px-4 py-1.5 text-[11px] font-semibold uppercase tracking-wider text-gray-400 dark:text-gray-500",children:e}),e&&n.collapsed&&jsxRuntime.jsx("div",{className:"mx-auto my-1 w-6 border-t border-gray-200 dark:border-gray-700"}),jsxRuntime.jsx("div",{className:"space-y-0.5 px-2",children:r})]})}function k1({icon:e,label:t,badge:r,badgeColor:n="bg-blue-600 text-white",active:o=false,disabled:a=false,href:s,onClick:l,tooltip:i,className:c}){let d=Io(),u=d.collapsed,f=i??t,m=jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[e&&jsxRuntime.jsx("span",{className:p("shrink-0 w-5 h-5",u&&"w-5 h-5"),children:e}),!u&&jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("span",{className:"flex-1 truncate",children:t}),r!=null&&jsxRuntime.jsx("span",{className:p("shrink-0 inline-flex items-center justify-center rounded-full text-[10px] font-semibold min-w-[18px] h-[18px] px-1",n),children:r})]}),u&&r!==void 0&&r!==null&&jsxRuntime.jsx("span",{className:"absolute top-1 right-1 w-2 h-2 rounded-full bg-blue-600"})]}),g=p("relative flex items-center gap-3 rounded-md text-sm font-medium transition-colors w-full",u?"justify-center px-2 py-2.5":"px-3 py-2",o?"bg-blue-50 text-blue-700 dark:bg-blue-900/30 dark:text-blue-400":"text-gray-700 dark:text-gray-300 hover:bg-gray-100 dark:hover:bg-gray-800",a&&"opacity-50 pointer-events-none",!a&&"cursor-pointer",c),y=()=>{a||(l?.(),d.isMobile&&d.closeMobile());},b=s?jsxRuntime.jsx("a",{href:a?void 0:s,className:g,onClick:y,"aria-current":o?"page":void 0,"data-testid":"sidebar-item",children:m}):jsxRuntime.jsx("button",{type:"button",className:g,onClick:y,disabled:a,"aria-current":o?"page":void 0,"data-testid":"sidebar-item",children:m});return u?jsxRuntime.jsx(Hm,{text:f,position:d.position,children:b}):b}function w1({icon:e,label:t,badge:r,defaultOpen:n=false,className:o,children:a}){let s=Io(),[l,i]=Cl.useState(n),c=Cl.useRef(null),[d,u]=Cl.useState(n?void 0:0),f=Cl.useRef(true);return Cl.useEffect(()=>{if(f.current){f.current=false,u(l?void 0:0);return}if(l){let m=c.current;if(m){u(m.scrollHeight);let g=setTimeout(()=>u(void 0),200);return ()=>clearTimeout(g)}}else {let m=c.current;m&&(u(m.scrollHeight),requestAnimationFrame(()=>u(0)));}},[l]),s.collapsed?jsxRuntime.jsx(Hm,{text:t,position:s.position,children:jsxRuntime.jsxs("button",{type:"button",className:p("relative flex items-center justify-center gap-3 rounded-md text-sm font-medium transition-colors w-full px-2 py-2.5","text-gray-700 dark:text-gray-300 hover:bg-gray-100 dark:hover:bg-gray-800 cursor-pointer",o),onClick:()=>{s.toggle(),i(true);},"data-testid":"sidebar-submenu-trigger",children:[e&&jsxRuntime.jsx("span",{className:"shrink-0 w-5 h-5",children:e}),r!=null&&jsxRuntime.jsx("span",{className:"absolute top-1 right-1 w-2 h-2 rounded-full bg-blue-600"})]})}):jsxRuntime.jsxs("div",{className:o,"data-testid":"sidebar-submenu",children:[jsxRuntime.jsxs("button",{type:"button",className:p("flex items-center gap-3 rounded-md text-sm font-medium transition-colors w-full px-3 py-2","text-gray-700 dark:text-gray-300 hover:bg-gray-100 dark:hover:bg-gray-800 cursor-pointer"),onClick:()=>i(!l),"aria-expanded":l,"data-testid":"sidebar-submenu-trigger",children:[e&&jsxRuntime.jsx("span",{className:"shrink-0 w-5 h-5",children:e}),jsxRuntime.jsx("span",{className:"flex-1 truncate text-left",children:t}),r!=null&&jsxRuntime.jsx("span",{className:"shrink-0 inline-flex items-center justify-center rounded-full text-[10px] font-semibold min-w-[18px] h-[18px] px-1 bg-blue-600 text-white",children:r}),jsxRuntime.jsx(f1,{className:p("shrink-0 text-gray-400 transition-transform duration-200",l&&"rotate-180")})]}),jsxRuntime.jsx("div",{className:"overflow-hidden transition-[height] duration-200 ease-in-out",style:{height:d===void 0?"auto":d},children:jsxRuntime.jsx("div",{ref:c,className:"pl-4 py-0.5",children:a})})]})}function N1({className:e}){let t=Io(),r=Ve(),n=t.isMobile?t.mobileOpen?t.closeLabel??r.closeSidebar:r.openSidebar:t.collapsed?r.expandSidebar:r.collapseSidebar;return jsxRuntime.jsx("button",{type:"button",onClick:t.toggle,className:p("p-1.5 rounded-md text-gray-400 hover:text-gray-600 dark:hover:text-gray-300 hover:bg-gray-100 dark:hover:bg-gray-800 transition-colors cursor-pointer",e),"aria-label":n,"data-testid":"sidebar-toggle",children:jsxRuntime.jsx(g1,{className:p("transition-transform duration-200",t.collapsed&&"rotate-180",t.position==="right"&&!t.collapsed&&"rotate-180",t.position==="right"&&t.collapsed&&"rotate-0")})})}function xc({data:e,width:t=96,height:r=28,curve:n="monotone",color:o=Ts[0],strokeWidth:a=2,area:s=false,emphasizeLast:l=false,domain:i,ariaLabel:c,className:d,...u}){let f=Math.max(a/2,l?a+2.5:0),m=i??Qt(e)??[0,1],g=Ir([0,Math.max(1,e.length-1)],[f,t-f]),y=Ir(m,[r-f,f]),b=e.map((x,L)=>({x:g(L),y:x==null?Number.NaN:y(x),defined:x!=null&&Number.isFinite(x)})),h=[...b].reverse().find(x=>x.defined!==false);return jsxRuntime.jsxs("svg",{width:t,height:r,viewBox:`0 0 ${t} ${r}`,className:p("overflow-visible",d),role:c?"img":void 0,"aria-label":c,"aria-hidden":c?void 0:true,...u,children:[s?jsxRuntime.jsx("path",{d:Va(b,r-f,n),fill:o,fillOpacity:.12,stroke:"none"}):null,jsxRuntime.jsx("path",{d:nn(b,n),fill:"none",stroke:o,strokeWidth:a,strokeLinecap:"round",strokeLinejoin:"round",vectorEffect:"non-scaling-stroke"}),l&&h?jsxRuntime.jsx("circle",{cx:h.x,cy:h.y,r:a,fill:o,strokeWidth:2,className:"stroke-white dark:stroke-gray-800"}):null]})}var R1={sm:"p-3",md:"p-4",lg:"p-5"},P1={sm:"text-[11px]",md:"text-xs",lg:"text-sm"},T1={sm:"text-xl",md:"text-2xl",lg:"text-3xl"},Wm={sm:{width:72,height:22},md:{width:96,height:28},lg:{width:120,height:34}};function D1(e){return e.direction?e.direction:e.value>0?"up":e.value<0?"down":"flat"}function E1(e,t){return e==="flat"||t==="neutral"?"text-gray-500 dark:text-gray-400":e===t?"text-green-600 dark:text-green-400":"text-red-600 dark:text-red-400"}function L1({direction:e}){return e==="flat"?jsxRuntime.jsx("svg",{width:"10",height:"10",viewBox:"0 0 10 10",fill:"currentColor","aria-hidden":"true",children:jsxRuntime.jsx("rect",{x:"1",y:"4.25",width:"8",height:"1.5",rx:"0.75"})}):jsxRuntime.jsx("svg",{width:"10",height:"10",viewBox:"0 0 10 10",fill:"currentColor","aria-hidden":"true",children:jsxRuntime.jsx("path",{d:e==="up"?"M5 1 L9.5 8 L0.5 8 Z":"M5 9 L0.5 2 L9.5 2 Z"})})}function M1({label:e,value:t,format:r,delta:n,trend:o,trendColor:a,icon:s,size:l="md",loading:i=false,variant:c="card",footer:d,className:u,...f}){let m=typeof t=="number"?(r??pt)(t):t,g=n?D1(n):"flat",y=n?(n.format??(b=>Zt(b,{signed:true})))(n.value):null;return jsxRuntime.jsxs("div",{className:p("flex flex-col gap-2",c==="card"&&p("rounded-lg border border-gray-200 bg-white dark:border-gray-700 dark:bg-gray-800",R1[l]),u),...f,children:[jsxRuntime.jsxs("div",{className:"flex items-start justify-between gap-2",children:[jsxRuntime.jsx("span",{className:p("font-medium text-gray-500 dark:text-gray-400",P1[l]),children:e}),s?jsxRuntime.jsx("span",{className:"shrink-0 text-gray-400",children:s}):null]}),jsxRuntime.jsxs("div",{className:"flex items-end justify-between gap-3",children:[jsxRuntime.jsxs("div",{className:"flex min-w-0 flex-col gap-1",children:[i?jsxRuntime.jsx("div",{className:"flex items-center",style:{height:l==="lg"?30:24},"aria-busy":"true","aria-live":"polite",children:jsxRuntime.jsx(Wo,{indeterminate:true,size:l==="lg"?"sm":"xs",thickness:"thin","aria-hidden":"true"})}):jsxRuntime.jsx("span",{className:p("leading-none font-semibold text-gray-900 dark:text-gray-100",T1[l]),children:m}),n&&!i?jsxRuntime.jsxs("span",{className:p("flex items-center gap-1 text-xs font-medium",E1(g,n.goodWhen??"up")),children:[jsxRuntime.jsx(L1,{direction:g}),y,n.period?jsxRuntime.jsx("span",{className:"font-normal text-gray-500 dark:text-gray-400",children:n.period}):null]}):null]}),o&&o.length>0&&!i?jsxRuntime.jsx(xc,{data:o,color:a,emphasizeLast:true,area:true,width:Wm[l].width,height:Wm[l].height,className:"shrink-0"}):null]}),d?jsxRuntime.jsx("div",{className:"text-xs text-gray-500 dark:text-gray-400",children:d}):null]})}var I1={1:"sm:grid-cols-1",2:"sm:grid-cols-2",3:"sm:grid-cols-3",4:"sm:grid-cols-2 lg:grid-cols-4"};function A1({columns:e=4,className:t,children:r,...n}){return jsxRuntime.jsx("div",{className:p("grid grid-cols-1 gap-3",I1[e],t),...n,children:r})}var B1={text:"rounded h-4 w-full",circular:"rounded-full",rectangular:"rounded-none",rounded:"rounded-lg"},H1={pulse:"animate-pulse",wave:"animate-shimmer bg-gradient-to-r from-gray-200 via-gray-100 to-gray-200 dark:from-gray-700 dark:via-gray-600 dark:to-gray-700 bg-[length:200%_100%]",none:""},W1="bg-gray-200 dark:bg-gray-700";function Vm({variant:e="text",animation:t="pulse",width:r,height:n,count:o=1,className:a,style:s,...l}){let i={...r!==void 0&&{width:typeof r=="number"?`${r}px`:r},...n!==void 0&&{height:typeof n=="number"?`${n}px`:n},...s};e==="circular"&&r&&!n&&(i.height=i.width);let c=p(W1,B1[e],H1[t],a);return o===1?jsxRuntime.jsx("div",{className:c,style:i,"aria-busy":"true","aria-live":"polite",...l}):jsxRuntime.jsx("div",{className:"space-y-2",children:Array.from({length:o}).map((d,u)=>jsxRuntime.jsx("div",{className:c,style:i,"aria-busy":"true","aria-live":"polite",...l},u))})}Vm.displayName="Skeleton";var _1={sm:"h-1",md:"h-1.5",lg:"h-2"},X1={sm:"w-3.5 h-3.5",md:"w-4 h-4",lg:"w-5 h-5"},G1={sm:14,md:16,lg:20},U1="[&::-webkit-slider-thumb]:appearance-none [&::-webkit-slider-thumb]:rounded-full [&::-moz-range-thumb]:appearance-none [&::-moz-range-thumb]:rounded-full [&::-moz-range-thumb]:border-0",K1={sm:"[&::-webkit-slider-thumb]:h-3.5 [&::-webkit-slider-thumb]:w-3.5 [&::-moz-range-thumb]:h-3.5 [&::-moz-range-thumb]:w-3.5",md:"[&::-webkit-slider-thumb]:h-4 [&::-webkit-slider-thumb]:w-4 [&::-moz-range-thumb]:h-4 [&::-moz-range-thumb]:w-4",lg:"[&::-webkit-slider-thumb]:h-5 [&::-webkit-slider-thumb]:w-5 [&::-moz-range-thumb]:h-5 [&::-moz-range-thumb]:w-5"},Y1={sm:"h-4",md:"h-5",lg:"h-6"},j1={primary:"bg-blue-600 dark:bg-blue-500",success:"bg-green-600 dark:bg-green-500",warning:"bg-yellow-500 dark:bg-yellow-400",error:"bg-red-600 dark:bg-red-500",info:"bg-cyan-600 dark:bg-cyan-500",neutral:"bg-gray-600 dark:bg-gray-400"},q1={primary:"border-blue-600 dark:border-blue-500",success:"border-green-600 dark:border-green-500",warning:"border-yellow-500 dark:border-yellow-400",error:"border-red-600 dark:border-red-500",info:"border-cyan-600 dark:border-cyan-500",neutral:"border-gray-600 dark:border-gray-400"},Z1={primary:"peer-focus-visible:ring-blue-500",success:"peer-focus-visible:ring-green-500",warning:"peer-focus-visible:ring-yellow-500",error:"peer-focus-visible:ring-red-500",info:"peer-focus-visible:ring-cyan-500",neutral:"peer-focus-visible:ring-gray-500"},Q1={primary:"text-blue-600 dark:text-blue-400",success:"text-green-600 dark:text-green-400",warning:"text-yellow-600 dark:text-yellow-400",error:"text-red-600 dark:text-red-400",info:"text-cyan-600 dark:text-cyan-400",neutral:"text-gray-700 dark:text-gray-300"},Om=(e,t,r)=>Math.min(r,Math.max(t,e)),Cc=(e,t,r)=>r>t?(Om(e,t,r)-t)/(r-t)*100:0,wi=(e,t)=>{let r=(.5-e/100)*t,n=Math.round(Math.abs(r)*1e3)/1e3;return `calc(${e}% ${r<0?"-":"+"} ${n}px)`},J1=(e,t,r,n)=>{if(!e)return [];if(Array.isArray(e))return e;let o=n>0?n:1,a=Math.floor((r-t)/o);return a<=0||a>20?[{value:t},{value:r}]:Array.from({length:a+1},(s,l)=>({value:t+l*o}))},Fm=Cl.forwardRef(({value:e,defaultValue:t,onValueChange:r,min:n=0,max:o=100,step:a=1,size:s="md",color:l="primary",disabled:i=false,readOnly:c=false,label:d,description:u,error:f=false,showValue:m=false,showTooltip:g=false,valueFormat:y,marks:b,trackColor:h,fillColor:x,thumbColor:L,className:C,containerClassName:S,id:v,...R},N)=>{let[M,P]=Cl.useState(t??n),E=e!==void 0,T=Om(E?e:M,n,o),O=Cl.useId(),H=v??O,k=typeof f=="string"?f:void 0,z=!!f,A=!i&&!c,I=z?"error":l,X=Cc(T,n,o),$=G1[s],K=U=>{if(!A)return;let F=Number(U.target.value);E||P(F),r?.(F);},D=Cl.useMemo(()=>J1(b,n,o,a),[b,n,o,a]),B=D.some(U=>U.label!=null),w=y?y(T):`${T}`,G={width:wi(X,$)};x&&(G.backgroundColor=x);let q={left:wi(X,$)};L&&(q.backgroundColor=L,q.borderColor=L);let j=h?{backgroundColor:h}:{};return jsxRuntime.jsxs("div",{className:p("w-full",S),children:[(d||m)&&jsxRuntime.jsxs("div",{className:"flex items-center justify-between mb-1.5",children:[d?jsxRuntime.jsx("label",{htmlFor:H,className:p("text-sm font-medium text-gray-700 dark:text-gray-200",i&&"opacity-50"),children:d}):jsxRuntime.jsx("span",{}),m&&jsxRuntime.jsx("span",{className:p("text-sm font-semibold tabular-nums",Q1[I]),children:w})]}),jsxRuntime.jsxs("div",{className:p("relative flex items-center",Y1[s],i&&"opacity-50"),children:[jsxRuntime.jsx("input",{ref:N,type:"range",id:H,min:n,max:o,step:a,value:T,onChange:K,disabled:i,readOnly:c,"aria-invalid":z,"aria-readonly":c||void 0,"aria-describedby":k?`${H}-error`:void 0,tabIndex:A?void 0:-1,className:p("peer absolute inset-0 z-10 m-0 h-full w-full cursor-pointer appearance-none bg-transparent opacity-0",U1,K1[s],!A&&"pointer-events-none cursor-default",C),...R}),jsxRuntime.jsxs("div",{className:p("pointer-events-none relative w-full overflow-hidden rounded-full bg-gray-200 dark:bg-gray-700",_1[s]),style:j,children:[jsxRuntime.jsx("div",{className:p("absolute inset-y-0 left-0 rounded-full transition-[width] duration-150 ease-out",x?"":j1[I]),style:G}),D.map((U,F)=>{let _=Cc(U.value,n,o),J=U.value<=T;return jsxRuntime.jsx("span",{"data-slider-mark":"",className:p("absolute top-1/2 h-1 w-1 -translate-x-1/2 -translate-y-1/2 rounded-full",J?"bg-white/80":"bg-gray-400 dark:bg-gray-500"),style:{left:wi(_,$)}},`mark-${U.value}-${F}`)})]}),jsxRuntime.jsx("div",{"data-slider-thumb":"",className:p("pointer-events-none absolute top-1/2 -translate-x-1/2 -translate-y-1/2 rounded-full border-2 bg-white shadow transition-transform dark:bg-gray-100",X1[s],L?"":q1[I],A&&"peer-hover:scale-110 peer-active:scale-110","peer-focus-visible:scale-110 peer-focus-visible:ring-2 peer-focus-visible:ring-offset-2",Z1[I]),style:q,children:g&&jsxRuntime.jsx("span",{"data-slider-tooltip":"",className:p("pointer-events-none absolute bottom-full left-1/2 mb-2 -translate-x-1/2 rounded bg-gray-900 px-1.5 py-0.5 text-xs font-medium text-white opacity-0 transition-opacity dark:bg-gray-700","peer-hover:opacity-100 peer-focus-visible:opacity-100 peer-active:opacity-100"),children:w})})]}),B&&jsxRuntime.jsx("div",{className:"relative mt-1.5 h-4",children:D.map((U,F)=>U.label!=null?jsxRuntime.jsx("span",{className:"absolute -translate-x-1/2 whitespace-nowrap text-xs text-gray-500 dark:text-gray-400",style:{left:wi(Cc(U.value,n,o),$)},children:U.label},`mark-label-${U.value}-${F}`):null)}),u&&!k&&jsxRuntime.jsx("p",{className:"mt-1.5 text-sm text-gray-500 dark:text-gray-400",children:u}),k&&jsxRuntime.jsx("p",{id:`${H}-error`,className:"mt-1.5 text-sm text-red-500 dark:text-red-400",children:k})]})});Fm.displayName="Slider";var kc=Cl.createContext(null);function ha(){let e=Cl.useContext(kc);if(!e)throw new Error("Tabs components must be used within a Tabs provider");return e}function _m({children:e,defaultValue:t="",value:r,onValueChange:n,variant:o="underline",size:a="md",color:s="default",fullWidth:l=false,orientation:i="horizontal",className:c}){let[d,u]=Cl.useState(t),f=r!==void 0,m=f?r:d,g=Cl.useCallback(b=>{f||u(b),n?.(b);},[f,n]),y=Cl.useMemo(()=>({value:m,onValueChange:g,variant:o,size:a,color:s,orientation:i,fullWidth:l}),[m,g,o,a,s,i,l]);return jsxRuntime.jsx(kc.Provider,{value:y,children:jsxRuntime.jsx("div",{className:p("w-full",i==="vertical"&&"flex gap-4",c),"data-orientation":i,children:e})})}_m.displayName="Tabs";var ak={none:"gap-0",sm:"gap-1",md:"gap-2",lg:"gap-4"};function Xm({children:e,className:t,bgColor:r,gap:n="none"}){let{variant:o,orientation:a,fullWidth:s}=ha(),l=p("flex",a==="vertical"?"flex-col":"flex-row items-center",ak[n]),i={underline:"border-b border-gray-200 dark:border-gray-700",pills:p("p-1 rounded-lg",r||"bg-gray-100 dark:bg-gray-800"),enclosed:"border-b border-gray-200 dark:border-gray-700",soft:p("p-1 rounded-lg",r||"bg-gray-100/50 dark:bg-gray-800/50")};return jsxRuntime.jsx("div",{role:"tablist","aria-orientation":a,className:p(l,i[o],s&&"w-full",t),children:e})}Xm.displayName="TabsList";var ik={sm:"px-3 py-1.5 text-xs gap-1.5",md:"px-4 py-2 text-sm gap-2",lg:"px-5 py-2.5 text-base gap-2"},Gm={sm:"w-3.5 h-3.5",md:"w-4 h-4",lg:"w-5 h-5"},Um={default:{underline:{active:"text-gray-900 dark:text-white border-gray-900 dark:border-white",inactive:"text-gray-500 dark:text-gray-400 border-transparent hover:text-gray-700 dark:hover:text-gray-300"},pills:{active:"bg-white dark:bg-gray-700 text-gray-900 dark:text-white shadow-sm",inactive:"text-gray-600 dark:text-gray-400 hover:text-gray-900 dark:hover:text-white"},enclosed:{active:"bg-white dark:bg-gray-800 text-gray-900 dark:text-white border-gray-200 dark:border-gray-700 border-b-white dark:border-b-gray-800",inactive:"text-gray-500 dark:text-gray-400 hover:text-gray-700 dark:hover:text-gray-300 border-transparent"},soft:{active:"bg-gray-200 dark:bg-gray-700 text-gray-900 dark:text-white",inactive:"text-gray-600 dark:text-gray-400 hover:text-gray-900 dark:hover:text-white hover:bg-gray-100 dark:hover:bg-gray-700/50"}},primary:{underline:{active:"text-blue-600 dark:text-blue-400 border-blue-600 dark:border-blue-400",inactive:"text-gray-500 dark:text-gray-400 border-transparent hover:text-blue-600 dark:hover:text-blue-400"},pills:{active:"bg-blue-600 text-white",inactive:"text-gray-600 dark:text-gray-400 hover:text-blue-600 dark:hover:text-blue-400"},enclosed:{active:"bg-blue-50 dark:bg-blue-900/20 text-blue-600 dark:text-blue-400 border-blue-200 dark:border-blue-800 border-b-blue-50 dark:border-b-blue-900/20",inactive:"text-gray-500 dark:text-gray-400 hover:text-blue-600 dark:hover:text-blue-400 border-transparent"},soft:{active:"bg-blue-100 dark:bg-blue-900/50 text-blue-700 dark:text-blue-300",inactive:"text-gray-600 dark:text-gray-400 hover:text-blue-600 dark:hover:text-blue-400 hover:bg-blue-50 dark:hover:bg-blue-900/20"}},secondary:{underline:{active:"text-purple-600 dark:text-purple-400 border-purple-600 dark:border-purple-400",inactive:"text-gray-500 dark:text-gray-400 border-transparent hover:text-purple-600 dark:hover:text-purple-400"},pills:{active:"bg-purple-600 text-white",inactive:"text-gray-600 dark:text-gray-400 hover:text-purple-600 dark:hover:text-purple-400"},enclosed:{active:"bg-purple-50 dark:bg-purple-900/20 text-purple-600 dark:text-purple-400 border-purple-200 dark:border-purple-800 border-b-purple-50 dark:border-b-purple-900/20",inactive:"text-gray-500 dark:text-gray-400 hover:text-purple-600 dark:hover:text-purple-400 border-transparent"},soft:{active:"bg-purple-100 dark:bg-purple-900/50 text-purple-700 dark:text-purple-300",inactive:"text-gray-600 dark:text-gray-400 hover:text-purple-600 dark:hover:text-purple-400 hover:bg-purple-50 dark:hover:bg-purple-900/20"}},success:{underline:{active:"text-green-600 dark:text-green-400 border-green-600 dark:border-green-400",inactive:"text-gray-500 dark:text-gray-400 border-transparent hover:text-green-600 dark:hover:text-green-400"},pills:{active:"bg-green-600 text-white",inactive:"text-gray-600 dark:text-gray-400 hover:text-green-600 dark:hover:text-green-400"},enclosed:{active:"bg-green-50 dark:bg-green-900/20 text-green-600 dark:text-green-400 border-green-200 dark:border-green-800 border-b-green-50 dark:border-b-green-900/20",inactive:"text-gray-500 dark:text-gray-400 hover:text-green-600 dark:hover:text-green-400 border-transparent"},soft:{active:"bg-green-100 dark:bg-green-900/50 text-green-700 dark:text-green-300",inactive:"text-gray-600 dark:text-gray-400 hover:text-green-600 dark:hover:text-green-400 hover:bg-green-50 dark:hover:bg-green-900/20"}},warning:{underline:{active:"text-yellow-600 dark:text-yellow-400 border-yellow-600 dark:border-yellow-400",inactive:"text-gray-500 dark:text-gray-400 border-transparent hover:text-yellow-600 dark:hover:text-yellow-400"},pills:{active:"bg-yellow-500 text-white",inactive:"text-gray-600 dark:text-gray-400 hover:text-yellow-600 dark:hover:text-yellow-400"},enclosed:{active:"bg-yellow-50 dark:bg-yellow-900/20 text-yellow-600 dark:text-yellow-400 border-yellow-200 dark:border-yellow-800 border-b-yellow-50 dark:border-b-yellow-900/20",inactive:"text-gray-500 dark:text-gray-400 hover:text-yellow-600 dark:hover:text-yellow-400 border-transparent"},soft:{active:"bg-yellow-100 dark:bg-yellow-900/50 text-yellow-700 dark:text-yellow-300",inactive:"text-gray-600 dark:text-gray-400 hover:text-yellow-600 dark:hover:text-yellow-400 hover:bg-yellow-50 dark:hover:bg-yellow-900/20"}},error:{underline:{active:"text-red-600 dark:text-red-400 border-red-600 dark:border-red-400",inactive:"text-gray-500 dark:text-gray-400 border-transparent hover:text-red-600 dark:hover:text-red-400"},pills:{active:"bg-red-600 text-white",inactive:"text-gray-600 dark:text-gray-400 hover:text-red-600 dark:hover:text-red-400"},enclosed:{active:"bg-red-50 dark:bg-red-900/20 text-red-600 dark:text-red-400 border-red-200 dark:border-red-800 border-b-red-50 dark:border-b-red-900/20",inactive:"text-gray-500 dark:text-gray-400 hover:text-red-600 dark:hover:text-red-400 border-transparent"},soft:{active:"bg-red-100 dark:bg-red-900/50 text-red-700 dark:text-red-300",inactive:"text-gray-600 dark:text-gray-400 hover:text-red-600 dark:hover:text-red-400 hover:bg-red-50 dark:hover:bg-red-900/20"}}},lk={underline:"border-b-2 -mb-px",pills:"rounded-md",enclosed:"border border-b-0 rounded-t-md -mb-px",soft:"rounded-md"};function Km({value:e,children:t,disabled:r=false,icon:n,endIcon:o,className:a,activeClassName:s,inactiveClassName:l}){let{value:i,onValueChange:c,variant:d,size:u,color:f,fullWidth:m}=ha(),g=i===e,y=()=>{r||c(e);},b=C=>{(C.key==="Enter"||C.key===" ")&&(C.preventDefault(),y());},h=p("inline-flex items-center justify-center font-medium transition-all duration-200","focus:outline-none focus-visible:ring-2 focus-visible:ring-offset-2 focus-visible:ring-blue-500",ik[u],m&&"flex-1"),x=g?p(Um[f][d].active,s):p(Um[f][d].inactive,l),L=r?"opacity-50 cursor-not-allowed":"cursor-pointer";return jsxRuntime.jsxs("button",{type:"button",role:"tab","aria-selected":g,"aria-disabled":r,tabIndex:g?0:-1,onClick:y,onKeyDown:b,disabled:r,className:p(h,lk[d],x,L,a),children:[n&&jsxRuntime.jsx("span",{className:p("shrink-0",Gm[u]),children:n}),jsxRuntime.jsx("span",{children:t}),o&&jsxRuntime.jsx("span",{className:p("shrink-0",Gm[u]),children:o})]})}Km.displayName="TabsTrigger";function Ym({value:e,children:t,className:r,forceMount:n=false}){let{value:o}=ha(),a=o===e;return !a&&!n?null:jsxRuntime.jsx("div",{role:"tabpanel",hidden:!a,tabIndex:0,className:p("mt-4 focus:outline-none focus-visible:ring-2 focus-visible:ring-offset-2 focus-visible:ring-blue-500 rounded-md",!a&&"hidden",r),children:t})}Ym.displayName="TabsContent";function uk({className:e}){return jsxRuntime.jsx("svg",{className:e,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",children:jsxRuntime.jsx("path",{d:"M9 12L11 14L15 10M21 12C21 16.97 16.97 21 12 21C7.03 21 3 16.97 3 12C3 7.03 7.03 3 12 3C16.97 3 21 7.03 21 12Z",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})})}function mk({className:e}){return jsxRuntime.jsx("svg",{className:e,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",children:jsxRuntime.jsx("path",{d:"M12 8V12M12 16H12.01M21 12C21 16.97 16.97 21 12 21C7.03 21 3 16.97 3 12C3 7.03 7.03 3 12 3C16.97 3 21 7.03 21 12Z",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})})}function pk({className:e}){return jsxRuntime.jsx("svg",{className:e,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",children:jsxRuntime.jsx("path",{d:"M12 9V13M12 17H12.01M10.29 3.86L1.82 18C1.65 18.3 1.55 18.65 1.55 18.99C1.55 19.34 1.64 19.69 1.81 19.99C1.99 20.29 2.24 20.55 2.54 20.72C2.84 20.901 3.18 20.99 3.53 21H20.47C20.82 20.99 21.16 20.901 21.46 20.72C21.76 20.55 22.01 20.29 22.19 19.99C22.36 19.69 22.449 19.34 22.448 18.99C22.447 18.65 22.35 18.3 22.18 18L13.71 3.86C13.53 3.57 13.28 3.32 12.98 3.15C12.68 2.99 12.34 2.9 12 2.9C11.66 2.9 11.32 2.99 11.02 3.15C10.72 3.32 10.47 3.57 10.29 3.86Z",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})})}function jm({className:e}){return jsxRuntime.jsx("svg",{className:e,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",children:jsxRuntime.jsx("path",{d:"M13 16H12V12H11M12 8H12.01M21 12C21 16.97 16.97 21 12 21C7.03 21 3 16.97 3 12C3 7.03 7.03 3 12 3C16.97 3 21 7.03 21 12Z",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})})}function gk({className:e}){return jsxRuntime.jsx("svg",{className:e,viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",children:jsxRuntime.jsx("path",{d:"M4 4L12 12M12 4L4 12",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})})}var fk={success:uk,error:mk,warning:pk,info:jm,default:jm},hk={success:{solid:"bg-green-600 text-white border-green-600",outlined:"bg-white text-green-700 border-green-600 dark:bg-gray-900 dark:text-green-400",soft:"bg-green-50 text-green-700 border-green-200 dark:bg-green-900/20 dark:text-green-400 dark:border-green-800"},error:{solid:"bg-red-600 text-white border-red-600",outlined:"bg-white text-red-700 border-red-600 dark:bg-gray-900 dark:text-red-400",soft:"bg-red-50 text-red-700 border-red-200 dark:bg-red-900/20 dark:text-red-400 dark:border-red-800"},warning:{solid:"bg-yellow-500 text-white border-yellow-500",outlined:"bg-white text-yellow-700 border-yellow-500 dark:bg-gray-900 dark:text-yellow-400",soft:"bg-yellow-50 text-yellow-700 border-yellow-200 dark:bg-yellow-900/20 dark:text-yellow-400 dark:border-yellow-800"},info:{solid:"bg-blue-600 text-white border-blue-600",outlined:"bg-white text-blue-700 border-blue-600 dark:bg-gray-900 dark:text-blue-400",soft:"bg-blue-50 text-blue-700 border-blue-200 dark:bg-blue-900/20 dark:text-blue-400 dark:border-blue-800"},default:{solid:"bg-gray-700 text-white border-gray-700",outlined:"bg-white text-gray-700 border-gray-300 dark:bg-gray-900 dark:text-gray-300",soft:"bg-gray-50 text-gray-700 border-gray-200 dark:bg-gray-800 dark:text-gray-300 dark:border-gray-700"}},bk={success:"text-green-600 dark:text-green-400",error:"text-red-600 dark:text-red-400",warning:"text-yellow-600 dark:text-yellow-400",info:"text-blue-600 dark:text-blue-400",default:"text-gray-600 dark:text-gray-400"};function Zm({children:e,title:t,description:r,type:n="default",variant:o="soft",icon:a,action:s,onClose:l,closable:i=true,className:c,...d}){let u=fk[n],f=jsxRuntime.jsx(u,{className:"w-5 h-5"}),m=e??r;return jsxRuntime.jsxs("div",{role:"alert",className:p("flex items-start gap-3 p-4 rounded-lg border shadow-lg min-w-[320px] max-w-md","animate-in slide-in-from-top-2 fade-in duration-300",hk[n][o],c),...d,children:[jsxRuntime.jsx("div",{className:p("flex-shrink-0 mt-0.5",o==="solid"?"text-white":bk[n]),children:a??f}),jsxRuntime.jsxs("div",{className:"flex-1 min-w-0",children:[t&&jsxRuntime.jsx("div",{className:"font-semibold text-sm mb-1",children:t}),m&&jsxRuntime.jsx("div",{className:"text-sm opacity-90",children:m}),s&&jsxRuntime.jsx("div",{className:"mt-3",children:s})]}),i&&jsxRuntime.jsx("button",{type:"button",onClick:l,className:p("flex-shrink-0 rounded-md p-1 transition-colors hover:bg-black/10 dark:hover:bg-white/10","focus:outline-none focus-visible:ring-2 focus-visible:ring-offset-2 focus-visible:ring-current",o==="solid"?"text-white":""),"aria-label":"Close notification",children:jsxRuntime.jsx(gk,{className:"w-4 h-4"})})]})}Zm.displayName="Toast";var vk={default:"bg-gray-900 text-white dark:bg-gray-700",light:"bg-white text-gray-900 border border-gray-200 shadow-lg dark:bg-gray-800 dark:text-white dark:border-gray-600",error:"bg-red-600 text-white",success:"bg-green-600 text-white",warning:"bg-yellow-500 text-white",info:"bg-blue-600 text-white"},Ck={default:{top:"border-t-gray-900 dark:border-t-gray-700",bottom:"border-b-gray-900 dark:border-b-gray-700",left:"border-l-gray-900 dark:border-l-gray-700",right:"border-r-gray-900 dark:border-r-gray-700"},light:{top:"border-t-white dark:border-t-gray-800",bottom:"border-b-white dark:border-b-gray-800",left:"border-l-white dark:border-l-gray-800",right:"border-r-white dark:border-r-gray-800"},error:{top:"border-t-red-600",bottom:"border-b-red-600",left:"border-l-red-600",right:"border-r-red-600"},success:{top:"border-t-green-600",bottom:"border-b-green-600",left:"border-l-green-600",right:"border-r-green-600"},warning:{top:"border-t-yellow-500",bottom:"border-b-yellow-500",left:"border-l-yellow-500",right:"border-r-yellow-500"},info:{top:"border-t-blue-600",bottom:"border-b-blue-600",left:"border-l-blue-600",right:"border-r-blue-600"}},kk={sm:"px-2 py-1 text-xs",md:"px-3 py-1.5 text-sm",lg:"px-4 py-2 text-base"},wk={sm:"border-4",md:"border-[5px]",lg:"border-[6px]"},Nk={top:"bottom-full left-1/2 -translate-x-1/2 mb-2",bottom:"top-full left-1/2 -translate-x-1/2 mt-2",left:"right-full top-1/2 -translate-y-1/2 mr-2",right:"left-full top-1/2 -translate-y-1/2 ml-2"},Sk={top:"top-full left-1/2 -translate-x-1/2 border-l-transparent border-r-transparent border-b-transparent",bottom:"bottom-full left-1/2 -translate-x-1/2 border-l-transparent border-r-transparent border-t-transparent",left:"left-full top-1/2 -translate-y-1/2 border-t-transparent border-b-transparent border-r-transparent",right:"right-full top-1/2 -translate-y-1/2 border-t-transparent border-b-transparent border-l-transparent"};function $t({children:e,content:t,position:r="top",variant:n="default",size:o="md",trigger:a="hover",open:s,delay:l=0,showArrow:i=true,maxWidth:c="max-w-xs",className:d,contentClassName:u,disabled:f=false,...m}){let[g,y]=Cl.useState(false),b=Cl.useRef(null),h=Cl.useCallback(()=>{f||(l>0?b.current=setTimeout(()=>y(true),l):y(true));},[l,f]),x=Cl.useCallback(()=>{b.current&&(clearTimeout(b.current),b.current=null),y(false);},[]),L=Cl.useCallback(()=>{f||y(v=>!v);},[f]),C=a==="manual"?s:g,S={hover:{onMouseEnter:h,onMouseLeave:x,onFocus:h,onBlur:x},click:{onClick:L},manual:{}}[a];return jsxRuntime.jsxs("div",{className:p("relative inline-flex",d),...S,...m,children:[e,C&&!f&&jsxRuntime.jsxs("div",{role:"tooltip",className:p("absolute z-50 whitespace-normal wrap-break-word rounded-md","transition-opacity duration-150",Nk[r],vk[n],kk[o],c,u),children:[t,i&&jsxRuntime.jsx("span",{className:p("absolute w-0 h-0 border-solid",wk[o],Sk[r],Ck[n][r]),"aria-hidden":"true"})]})]})}$t.displayName="Tooltip";function Pk(e){switch(e){case "bordered":return "border-t border-gray-200 dark:border-gray-700 bg-white dark:bg-gray-900 text-gray-700 dark:text-gray-300";case "minimal":return "bg-transparent text-gray-600 dark:text-gray-400";case "dark":return "bg-gray-900 text-gray-300";default:return "bg-gray-100 dark:bg-gray-800 text-gray-700 dark:text-gray-300"}}function Tk(e){switch(e){case "sm":return "py-6";case "lg":return "py-16";default:return "py-10"}}function ep({variant:e="default",size:t="md",sticky:r=false,className:n,children:o,...a}){return jsxRuntime.jsx("footer",{className:p(Pk(e),Tk(t),r&&"sticky bottom-0 z-40",n),...a,children:jsxRuntime.jsx("div",{className:"container mx-auto px-4",children:o})})}ep.displayName="Footer";function Dk(e){switch(e){case 1:return "grid-cols-1";case 2:return "grid-cols-1 sm:grid-cols-2";case 3:return "grid-cols-1 sm:grid-cols-2 lg:grid-cols-3";case 4:return "grid-cols-1 sm:grid-cols-2 lg:grid-cols-4";case 5:return "grid-cols-1 sm:grid-cols-2 lg:grid-cols-5";case 6:return "grid-cols-2 sm:grid-cols-3 lg:grid-cols-6";default:return ""}}function tp({title:e,titleClassName:t,columns:r,className:n,children:o,...a}){return jsxRuntime.jsxs("div",{className:p(r&&"grid gap-8",Dk(r),n),...a,children:[e&&jsxRuntime.jsx("h3",{className:p("text-sm font-semibold uppercase tracking-wider text-gray-900 dark:text-white",r&&"col-span-full",t),children:e}),o]})}tp.displayName="FooterSection";function rp({title:e,titleClassName:t,className:r,children:n,...o}){return jsxRuntime.jsxs("div",{className:p("flex flex-col gap-3",r),...o,children:[e&&jsxRuntime.jsx("h4",{className:p("text-sm font-semibold uppercase tracking-wider text-gray-900 dark:text-white",t),children:e}),n]})}rp.displayName="FooterColumn";function np({external:e=false,className:t,children:r,...n}){return jsxRuntime.jsx("a",{className:p("text-sm text-gray-600 dark:text-gray-400 hover:text-gray-900 dark:hover:text-white transition-colors",t),target:e?"_blank":void 0,rel:e?"noopener noreferrer":void 0,...n,children:r})}np.displayName="FooterLink";function op({copyright:e,className:t,children:r,...n}){return jsxRuntime.jsxs("div",{className:p("mt-8 border-t border-gray-200 dark:border-gray-700 pt-6 flex flex-col sm:flex-row items-center justify-between gap-4",t),...n,children:[e&&jsxRuntime.jsx("p",{className:"text-sm text-gray-500 dark:text-gray-400",children:e}),r]})}op.displayName="FooterBottom";function ap({className:e,children:t,...r}){return jsxRuntime.jsx("div",{className:p("flex items-center gap-4",e),...r,children:t})}ap.displayName="FooterSocial";function sp({icon:e,label:t,className:r,...n}){return jsxRuntime.jsx("a",{className:p("text-gray-500 dark:text-gray-400 hover:text-gray-900 dark:hover:text-white transition-colors",r),target:"_blank",rel:"noopener noreferrer","aria-label":t,...n,children:e})}sp.displayName="FooterSocialLink";var Wk=4.5,Vk=48,lp=false,Ok=Cl.memo(function({points:t}){return jsxRuntime.jsx("g",{children:t.map(r=>jsxRuntime.jsx("circle",{cx:r.cx,cy:r.cy,r:r.r,fill:r.color,fillOpacity:.85,strokeWidth:2,className:"stroke-white dark:stroke-gray-800"},`${r.seriesKey}-${r.index}`))})});function Fk({width:e,height:t,data:r,resolvedSeries:n,x:o,y:a,grid:s,size:l,bubble:i,trendLine:c,quadrants:d,pointRadius:u,overlay:f,maxPoints:m,margin:g,tooltip:y,onPointClick:b,plotLabel:h,formatValue:x,formatX:L}){let[C,S]=Cl.useState(null),v=Cl.useMemo(()=>{let P=n.filter($=>!$.hidden),E=P.map($=>$.key),W=Jt({width:e,height:t,data:r,x:{...o,scale:o.scale==="time"?"time":"linear"},y:a,bounds:Qt(vr(r,E)),margin:g,formatValue:x,formatX:L}),T=i?vr(r,[i.key]):[],O=i?Qt(T):null,[H,k]=i?.range??[4,14],z=$=>{if(!i||!O)return u;let K=Ae($,i.key);if(K===null)return H;let[D,B]=O,w=B===D?1:(K-D)/(B-D);return Math.sqrt(H*H+w*(k*k-H*H))},A=[],I=[];P.forEach($=>{let K=[];r.forEach((D,B)=>{let w=Ae(D,$.key),G=W.categoryPositions[B];w===null||!Number.isFinite(G)||K.push({seriesKey:$.key,seriesLabel:Vt($),color:$.color,index:B,cx:G,cy:W.valueScale(w),r:z(D),xValue:Xr(W.xValues[B]),yValue:w});}),m||Yo("ScatterChart",K.length),I.push(...K),A.push(...m&&m>0?cl(K,m):K);});let X=null;if(c&&I.length>1){let $=I.length,K=I.reduce((q,j)=>q+j.xValue,0),D=I.reduce((q,j)=>q+j.yValue,0),B=I.reduce((q,j)=>q+j.xValue*j.yValue,0),w=I.reduce((q,j)=>q+j.xValue*j.xValue,0),G=$*w-K*K;if(G!==0){let q=($*B-K*D)/G,j=(D-q*K)/$,U=I.map(ne=>ne.xValue),[F,_]=[Math.min(...U),Math.max(...U)],J=I.map(ne=>ne.cx);X={x1:Math.min(...J),y1:W.valueScale(q*F+j),x2:Math.max(...J),y2:W.valueScale(q*_+j)};}}return {visible:P,points:A,plot:kn({geometry:W,width:e,height:t,data:r,series:P,formatValue:x,formatX:L}),trend:X,xTicks:W.categoryTicks,yTicks:W.valueTicks,valueScale:W.valueScale,positions:W.categoryPositions,innerWidth:W.innerWidth,innerHeight:W.innerHeight,margin:W.margin,xValues:W.xValues}},[r,n,o,a,e,t,g,i,c,u,m,x,L]),R=Cl.useCallback(P=>{if(y===false||v.points.length===0)return;let E=P.currentTarget.getBoundingClientRect(),W=P.clientX-E.left-v.margin.left,T=P.clientY-E.top-v.margin.top,O=null,H=Vk;for(let k of v.points){let z=Math.hypot(k.cx-W,k.cy-T);z<H&&(H=z,O=k);}S(O);},[y,v.points,v.margin]),N=Cl.useCallback(()=>{if(!b||!C)return;let P=r[C.index];P&&b({seriesKey:C.seriesKey,seriesLabel:C.seriesLabel,color:C.color,value:C.yValue,formattedValue:x(C.yValue),datum:P,index:C.index,x:v.xValues[C.index]});},[b,C,x,r,v.xValues]),M=wn(f);return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsxs("svg",{width:e,height:t,role:"img","aria-label":h??v.visible.map(P=>Vt(P)).join(", "),tabIndex:0,className:"touch-none focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-blue-500",onPointerMove:R,onPointerLeave:()=>S(null),onBlur:()=>S(null),onClick:N,children:[jsxRuntime.jsxs("g",{transform:`translate(${v.margin.left}, ${v.margin.top})`,children:[jsxRuntime.jsx(Yt,{width:v.innerWidth,height:v.innerHeight,horizontal:s==="y"||s==="both"?v.yTicks.map(P=>P.offset):void 0,vertical:s==="x"||s==="both"?v.xTicks.map(P=>P.offset):void 0}),d?.y!==void 0?jsxRuntime.jsx("line",{x1:0,y1:v.valueScale(d.y),x2:v.innerWidth,y2:v.valueScale(d.y),stroke:"var(--color-chart-muted)",strokeWidth:1,strokeDasharray:"4 4"}):null,M.under?.(v.plot),v.trend?jsxRuntime.jsx("line",{x1:v.trend.x1,y1:v.trend.y1,x2:v.trend.x2,y2:v.trend.y2,stroke:"var(--color-chart-muted)",strokeWidth:1.5,strokeDasharray:"4 4"}):null,jsxRuntime.jsx(Ok,{points:v.points}),M.over?.(v.plot),C?jsxRuntime.jsx("circle",{cx:C.cx,cy:C.cy,r:C.r+3,fill:"none",stroke:C.color,strokeWidth:2,"aria-hidden":"true"}):null]}),jsxRuntime.jsx("g",{transform:`translate(${v.margin.left}, ${v.margin.top+v.innerHeight})`,children:o.hidden?null:jsxRuntime.jsx(tt,{orientation:"bottom",ticks:v.xTicks,length:v.innerWidth,label:o.label,size:l})}),jsxRuntime.jsx("g",{transform:`translate(${v.margin.left}, ${v.margin.top})`,children:a?.hidden?null:jsxRuntime.jsx(tt,{orientation:"left",ticks:v.yTicks,length:v.innerHeight,showLine:false,label:a?.label,size:l})})]}),C&&r[C.index]&&y!==false?jsxRuntime.jsx(vt,{x:v.margin.left+C.cx,y:v.margin.top+C.cy,containerWidth:e,children:typeof y=="function"?y({x:v.xValues[C.index],xLabel:L(v.xValues[C.index],C.index),index:C.index,points:[{seriesKey:C.seriesKey,seriesLabel:C.seriesLabel,color:C.color,value:C.yValue,formattedValue:x(C.yValue),datum:r[C.index]}]}):jsxRuntime.jsx(Tr,{title:`${o.label??o.key} ${L(v.xValues[C.index],C.index)}`,points:[{seriesKey:C.seriesKey,seriesLabel:C.seriesLabel,color:C.color,value:C.yValue,formattedValue:x(C.yValue),datum:r[C.index]}]})}):null]})}function $k({data:e,series:t,x:r,y:n,height:o=280,width:a,size:s="md",grid:l="both",legend:i,tooltip:c=true,tableView:d=false,emphasis:u,title:f,description:m,loading:g=false,emptyState:y,error:b=false,errorState:h,onRetry:x,actions:L,onPointClick:C,bubble:S,trendLine:v=false,quadrants:R,pointRadius:N=Wk,overlay:M,legendToggle:P=true,maxPoints:E,margin:W,locale:T,plotLabel:O,className:H,...k}){let[z,A]=Cl.useState(()=>new Set);t.length>3&&!lp&&(lp=true,console.warn(`[@synertech/ui] A ScatterChart was given ${t.length} series. Any two marks can sit side by side here, and only the first ${3} palette slots stay tellable apart under that test: facet the chart instead.`));let I=Cl.useMemo(()=>t.map((G,q)=>({...G,hidden:G.hidden||z.has(G.key),color:Br(G,q,u)})),[t,z,u]),X=Cl.useMemo(()=>n?.format??(G=>pt(G,T)),[n?.format,T]),$=Cl.useMemo(()=>r.format??(G=>r.scale==="time"?st(G instanceof Date?G:new Date(Xr(G)),T):pt(Xr(G),T)),[r.format,r.scale,T]),K=Cl.useCallback(G=>{A(q=>{let j=new Set(q);return j.has(G)?j.delete(G):j.add(G),j});},[]),D=i===void 0?t.length>=2:i!==false,B=typeof i=="string"?i:"bottom",w=I.filter(G=>!G.hidden).length;return jsxRuntime.jsx(xt,{title:f,description:m,height:o,width:a,size:s,loading:g,empty:e.length===0||w===0,emptyState:y,error:b,errorState:h,onRetry:x,actions:L,tableView:d,legendPosition:B,legend:D?jsxRuntime.jsx(jt,{items:Gr(I,u),position:B,marker:"dot",size:s,onToggle:P?K:void 0}):void 0,table:d?jsxRuntime.jsx(Ot,{data:e,series:I,xKey:r.key,xLabel:r.label??r.key,formatX:$,formatValue:X,caption:typeof f=="string"?f:void 0}):void 0,className:H,...k,children:({width:G})=>jsxRuntime.jsx(Fk,{width:G,height:o,data:e,resolvedSeries:I,x:r,y:n,grid:l,size:s,bubble:S,trendLine:v,quadrants:R,pointRadius:N,overlay:M,maxPoints:E,margin:W,tooltip:c,onPointClick:C,plotLabel:O,formatValue:X,formatX:$})})}var dp="se-grid-pattern",up=Cl.memo(function({gridSize:t,zoom:r}){let n=t*r;return jsxRuntime.jsxs("svg",{className:"absolute inset-0 w-full h-full pointer-events-none","aria-hidden":"true",children:[jsxRuntime.jsx("defs",{children:jsxRuntime.jsx("pattern",{id:dp,width:n,height:n,patternUnits:"userSpaceOnUse",children:jsxRuntime.jsx("circle",{cx:1,cy:1,r:1,className:"fill-gray-300 dark:fill-gray-600"})})}),jsxRuntime.jsx("rect",{width:"100%",height:"100%",fill:`url(#${dp})`})]})});function jn(e,t){return e.collapsed?40:e.height?e.height:40+(e.notes?24:0)+e.fields.length*32+(t?36:0)}function ba(e,t){return 40+(t?24:0)+e*32+32/2}function mp(e,t,r){let n=e.fields.findIndex(i=>i.id===t);if(n===-1)return null;let o=e.width??260,a=!!e.notes,s=e.y+ba(n,a);return {x:r==="left"?e.x+0:e.x+o-0,y:s}}function Pc(e,t){return Math.round(e/t)*t}function ds(e,t,r){return Math.min(r,Math.max(t,e))}function us(e,t,r,n){return {x:(e-n.left-r.x)/r.zoom,y:(t-n.top-r.y)/r.zoom}}function Pi(e,t,r,n){let o=Math.abs(r-e),a=Math.max(50,o*.5),s=e+a,l=t,i=r-a;return `M ${e} ${t} C ${s} ${l}, ${i} ${n}, ${r} ${n}`}function pp(e,t,r,n,o=40){if(e.length===0)return {x:0,y:0,zoom:1};let a=1/0,s=1/0,l=-1/0,i=-1/0;for(let g of e){let y=g.width??260,b=jn(g,n);a=Math.min(a,g.x),s=Math.min(s,g.y),l=Math.max(l,g.x+y),i=Math.max(i,g.y+b);}let c=l-a+o*2,d=i-s+o*2,u=Math.min(t/c,r/d,1),f=(t-c*u)/2-(a-o)*u,m=(r-d*u)/2-(s-o)*u;return {x:f,y:m,zoom:u}}var ps=["text","varchar","char","int2","int4","int8","serial","bigserial","float4","float8","numeric","decimal","bool","date","time","timestamp","timestamptz","uuid","json","jsonb","bytea"];function gp(){return `table-${Date.now()}-${Math.random().toString(36).slice(2,8)}`}function ms(){return `field-${Date.now()}-${Math.random().toString(36).slice(2,8)}`}function Tc(){return `rel-${Date.now()}-${Math.random().toString(36).slice(2,8)}`}function Dc(e="new_field"){return {id:ms(),name:e,type:"text",nullable:true}}function Ec(e,t,r="new_table"){return {id:gp(),name:r,x:e,y:t,fields:[{id:ms(),name:"id",type:"serial",primaryKey:true},{id:ms(),name:"createdAt",type:"timestamp"},{id:ms(),name:"updatedAt",type:"timestamp"}]}}var Ti=()=>jsxRuntime.jsxs("svg",{className:"w-3.5 h-3.5 text-indigo-500 flex-shrink-0",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",children:[jsxRuntime.jsx("path",{d:"M10 1l2 2-5 5M8.5 4.5L11 7"}),jsxRuntime.jsx("circle",{cx:"4.5",cy:"11.5",r:"3"})]}),hp=()=>jsxRuntime.jsxs("svg",{className:"w-3.5 h-3.5 flex-shrink-0",viewBox:"0 0 16 16",fill:"currentColor",children:[jsxRuntime.jsx("circle",{cx:"8",cy:"8",r:"6",className:"fill-blue-500"}),jsxRuntime.jsx("path",{d:"M5 8h6M8 5l3 3-3 3",stroke:"white",strokeWidth:"1.5",fill:"none",strokeLinecap:"round",strokeLinejoin:"round"})]}),Kk=({collapsed:e})=>jsxRuntime.jsx("svg",{className:"w-3.5 h-3.5",viewBox:"0 0 16 16",fill:"currentColor",children:e?jsxRuntime.jsx("path",{d:"M6 3l5 5-5 5V3z"}):jsxRuntime.jsx("path",{d:"M3 6l5 5 5-5H3z"})}),bp=()=>jsxRuntime.jsx("svg",{className:"w-3.5 h-3.5 text-amber-500 flex-shrink-0",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",children:jsxRuntime.jsx("path",{d:"M3 2v12M7 4h6M7 8h4M7 12h5"})}),yp=()=>jsxRuntime.jsx("svg",{className:"w-3.5 h-3.5 text-purple-500 flex-shrink-0",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",children:jsxRuntime.jsx("path",{d:"M4 2v8a4 4 0 008 0V2"})}),Yk=()=>jsxRuntime.jsx("svg",{className:"w-3 h-3",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",children:jsxRuntime.jsx("path",{d:"M4 8h8"})}),jk=()=>jsxRuntime.jsxs("svg",{className:"w-3 h-3 text-gray-300",viewBox:"0 0 16 16",fill:"currentColor",children:[jsxRuntime.jsx("circle",{cx:"5",cy:"4",r:"1.5"}),jsxRuntime.jsx("circle",{cx:"11",cy:"4",r:"1.5"}),jsxRuntime.jsx("circle",{cx:"5",cy:"8",r:"1.5"}),jsxRuntime.jsx("circle",{cx:"11",cy:"8",r:"1.5"}),jsxRuntime.jsx("circle",{cx:"5",cy:"12",r:"1.5"}),jsxRuntime.jsx("circle",{cx:"11",cy:"12",r:"1.5"})]}),qk=Cl.memo(function({field:t,tableId:r,editable:n,readOnly:o,disabled:a,onFieldChange:s}){let[l,i]=Cl.useState(false),[c,d]=Cl.useState(t.defaultValue??""),u=n&&!o&&!a,f=()=>{i(false),s?.(r,t.id,{defaultValue:c||void 0});};return u?l?jsxRuntime.jsx("input",{className:"text-xs w-16 text-emerald-500 bg-transparent border-b border-emerald-300 outline-none focus:ring-0 p-0 flex-shrink-0","aria-label":`Default value for ${t.name}`,value:c,onChange:m=>d(m.target.value),onBlur:f,onKeyDown:m=>{m.key==="Enter"&&f(),m.key==="Escape"&&i(false);},onMouseDown:m=>m.stopPropagation(),autoFocus:true}):t.defaultValue?jsxRuntime.jsxs("button",{type:"button",className:"text-xs text-emerald-500 flex-shrink-0 truncate max-w-16 cursor-pointer",onClick:m=>{m.stopPropagation(),d(t.defaultValue??""),i(true);},onMouseDown:m=>m.stopPropagation(),title:`Default: ${t.defaultValue}`,children:["= ",t.defaultValue]}):jsxRuntime.jsx("button",{type:"button",className:"text-xs text-gray-300 flex-shrink-0 opacity-0 group-hover:opacity-30 hover:!opacity-100 cursor-pointer transition-opacity",onClick:m=>{m.stopPropagation(),d(""),i(true);},onMouseDown:m=>m.stopPropagation(),title:"Set default value",children:"= \u2205"}):t.defaultValue?jsxRuntime.jsxs("span",{className:"text-xs text-emerald-500 flex-shrink-0 truncate max-w-16",title:`Default: ${t.defaultValue}`,children:["= ",t.defaultValue]}):null}),vp=Cl.memo(function({table:t,selected:r,disabled:n,readOnly:o,editable:a,dropTarget:s,fieldTypes:l,onTableNameChange:i,onTableNotesChange:c,onToggleCollapse:d,onFieldChange:u,onFieldAdd:f,onFieldRemove:m,onFieldReorder:g,onResizeStart:y}){let b=t.width??260,h=t.collapsed??false,x=l.length>0?l:ps,[L,C]=Cl.useState(null),[S,v]=Cl.useState(null),R=Cl.useRef(null),N=Cl.useCallback(k=>{i?.(t.id,k.target.value);},[t.id,i]),M=Cl.useCallback((k,z)=>{u?.(t.id,k,{name:z});},[t.id,u]),P=Cl.useCallback((k,z)=>{u?.(t.id,k,{type:z});},[t.id,u]),E=Cl.useCallback((k,z)=>{u?.(t.id,k,{primaryKey:!z});},[t.id,u]),W=Cl.useCallback((k,z)=>{u?.(t.id,k,{nullable:!z});},[t.id,u]),T=Cl.useCallback((k,z)=>{u?.(t.id,k,{indexed:!z});},[t.id,u]),O=Cl.useCallback((k,z)=>{u?.(t.id,k,{unique:!z});},[t.id,u]),H=Cl.useCallback(()=>{f?.(t.id);},[t.id,f]);return jsxRuntime.jsxs("div",{"data-table-id":t.id,className:p("absolute bg-white dark:bg-gray-800 border-2 border-dashed rounded-lg shadow-sm cursor-grab active:cursor-grabbing",t.height?"flex flex-col":void 0,s?"border-green-400 shadow-green-100 dark:shadow-green-900/30 shadow-md":r?"border-blue-500 shadow-blue-100 dark:shadow-blue-900/30":"border-gray-300 dark:border-gray-600",n&&"opacity-60",t.locked&&"!cursor-default"),style:{left:t.x,top:t.y,width:b,height:t.height,userSelect:"none",overflow:t.height?"hidden":void 0},children:[jsxRuntime.jsxs("div",{className:p("flex items-center justify-between px-3 gap-2","bg-gray-50 dark:bg-gray-700 border-b border-gray-200 dark:border-gray-600"),style:{height:40},children:[a&&!o&&!n?jsxRuntime.jsx("input",{className:"flex-1 min-w-0 text-sm font-semibold text-gray-800 dark:text-gray-100 bg-transparent border-none outline-none focus:ring-0 p-0 truncate cursor-text","aria-label":"Table name",value:t.name,onChange:N,onMouseDown:k=>k.stopPropagation()}):jsxRuntime.jsx("span",{className:"flex-1 min-w-0 text-sm font-semibold text-gray-800 dark:text-gray-100 truncate",children:t.name}),jsxRuntime.jsx("button",{type:"button",className:"flex-shrink-0 p-1 rounded hover:bg-gray-200 dark:hover:bg-gray-600 text-gray-500 dark:text-gray-400",onClick:k=>{k.stopPropagation(),d?.(t.id);},onMouseDown:k=>k.stopPropagation(),"aria-label":h?"Expand table":"Collapse table",children:jsxRuntime.jsx(Kk,{collapsed:h})})]}),!h&&(a&&!o&&!n?jsxRuntime.jsx("div",{className:"px-3 border-b border-gray-100 dark:border-gray-700 flex items-center",style:{height:24},children:jsxRuntime.jsx("input",{className:"w-full text-xs italic text-gray-400 dark:text-gray-500 bg-transparent border-none outline-none focus:ring-0 p-0 placeholder-gray-400 dark:placeholder-gray-500","aria-label":"Table notes",placeholder:"Add notes...",value:t.notes??"",onChange:k=>c?.(t.id,k.target.value),onMouseDown:k=>k.stopPropagation()})}):t.notes?jsxRuntime.jsx("div",{className:"px-3 border-b border-gray-100 dark:border-gray-700 flex items-center",style:{height:24},children:jsxRuntime.jsx("span",{className:"text-xs italic text-gray-400 dark:text-gray-500 truncate",children:t.notes})}):null),!h&&jsxRuntime.jsxs("div",{className:t.height?"overflow-y-auto flex-1 min-h-0":void 0,children:[t.fields.map((k,z)=>jsxRuntime.jsxs("div",{"data-field-id":k.id,"data-table-id":t.id,className:p("flex items-center gap-1.5 pr-2 relative group",a&&!o&&!n?"pl-[18px]":"pl-2","border-b border-gray-100 dark:border-gray-700 last:border-b-0",s?"bg-blue-50/50 dark:bg-blue-900/10":"hover:bg-gray-50 dark:hover:bg-gray-750",L===z&&"opacity-40",S===z&&"!border-t-2 !border-t-blue-400"),style:{height:32},draggable:a&&!o&&!n,onDragStart:A=>{!a||o||n||(A.stopPropagation(),R.current=z,C(z),A.dataTransfer.effectAllowed="move",A.dataTransfer.setData("text/plain",String(z)));},onDragOver:A=>{R.current!==null&&(A.preventDefault(),A.stopPropagation(),v(z));},onDragLeave:()=>{S===z&&v(null);},onDrop:A=>{A.preventDefault(),A.stopPropagation(),R.current!==null&&R.current!==z&&g?.(t.id,R.current,z),R.current=null,C(null),v(null);},onDragEnd:()=>{R.current=null,C(null),v(null);},children:[jsxRuntime.jsx("div",{"data-connection-side":"left","data-field-id":k.id,"data-table-id":t.id,className:p("absolute -left-[5px] w-2.5 h-2.5 rounded-full border-2 border-white dark:border-gray-800 cursor-crosshair z-10 transition-all",s?"opacity-100 bg-green-400 scale-150 shadow-[0_0_6px_rgba(74,222,128,0.6)]":"opacity-0 group-hover:opacity-100 bg-blue-400"),style:{top:32/2-5}}),a&&!o&&!n&&jsxRuntime.jsx("span",{className:"absolute left-[3px] cursor-grab active:cursor-grabbing opacity-0 group-hover:opacity-100 transition-opacity z-10",style:{top:32/2-6},children:jsxRuntime.jsx(jk,{})}),a&&!o&&!n?jsxRuntime.jsx("button",{type:"button",className:p("w-4 text-xs font-bold flex-shrink-0 text-center cursor-pointer",k.nullable?"text-gray-400":"text-transparent"),onClick:A=>{A.stopPropagation(),W(k.id,k.nullable??false);},onMouseDown:A=>A.stopPropagation(),title:k.nullable?"Nullable":"Not nullable",children:"?"}):jsxRuntime.jsx("span",{className:p("w-4 text-xs font-bold flex-shrink-0 text-center",k.nullable?"text-gray-400":"text-transparent"),children:k.nullable?"?":""}),k.primaryKey&&k.foreignKey?jsxRuntime.jsxs("span",{className:"flex items-center gap-0.5 flex-shrink-0",children:[a&&!o&&!n?jsxRuntime.jsx("button",{type:"button",className:"flex-shrink-0 cursor-pointer",onClick:A=>{A.stopPropagation(),E(k.id,true);},onMouseDown:A=>A.stopPropagation(),title:"Primary Key (click to remove)",children:jsxRuntime.jsx(Ti,{})}):jsxRuntime.jsx(Ti,{}),jsxRuntime.jsx(hp,{})]}):k.primaryKey?a&&!o&&!n?jsxRuntime.jsx("button",{type:"button",className:"flex-shrink-0 cursor-pointer",onClick:A=>{A.stopPropagation(),E(k.id,true);},onMouseDown:A=>A.stopPropagation(),title:"Primary Key (click to remove)",children:jsxRuntime.jsx(Ti,{})}):jsxRuntime.jsx(Ti,{}):k.foreignKey?jsxRuntime.jsx(hp,{}):a&&!o&&!n?jsxRuntime.jsx("button",{type:"button",className:"w-3.5 h-3.5 flex-shrink-0 rounded text-gray-300 hover:text-indigo-400 transition-colors cursor-pointer",onClick:A=>{A.stopPropagation(),E(k.id,false);},onMouseDown:A=>A.stopPropagation(),title:"Set as Primary Key","aria-label":"Set as primary key",children:jsxRuntime.jsxs("svg",{className:"w-3.5 h-3.5",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",opacity:"0.3",children:[jsxRuntime.jsx("path",{d:"M10 1l2 2-5 5M8.5 4.5L11 7"}),jsxRuntime.jsx("circle",{cx:"4.5",cy:"11.5",r:"3"})]})}):jsxRuntime.jsx("span",{className:"w-3.5 flex-shrink-0"}),a&&!o&&!n?jsxRuntime.jsx("input",{className:p("flex-1 min-w-0 text-xs bg-transparent border-none outline-none focus:ring-0 p-0 truncate cursor-text",k.primaryKey?"text-blue-600 dark:text-blue-400 font-medium":"text-gray-700 dark:text-gray-300"),"aria-label":"Field name",value:k.name,onChange:A=>M(k.id,A.target.value),onMouseDown:A=>A.stopPropagation()}):jsxRuntime.jsx("span",{className:p("flex-1 min-w-0 text-xs truncate",k.primaryKey?"text-blue-600 dark:text-blue-400 font-medium":"text-gray-700 dark:text-gray-300"),children:k.name}),a&&!o&&!n?jsxRuntime.jsxs("select",{className:"text-xs text-gray-400 dark:text-gray-500 bg-transparent border-none outline-none focus:ring-0 p-0 cursor-pointer text-right",value:k.type,onChange:A=>P(k.id,A.target.value),onMouseDown:A=>A.stopPropagation(),children:[x.map(A=>jsxRuntime.jsx("option",{value:A,children:A},A)),!x.includes(k.type)&&jsxRuntime.jsx("option",{value:k.type,children:k.type})]}):jsxRuntime.jsx("span",{className:"text-xs text-gray-400 dark:text-gray-500 flex-shrink-0",children:k.type}),jsxRuntime.jsx(qk,{field:k,tableId:t.id,editable:a,readOnly:o,disabled:n,onFieldChange:u}),k.indexed&&jsxRuntime.jsx(bp,{}),k.unique&&jsxRuntime.jsx(yp,{}),a&&!o&&!n&&jsxRuntime.jsxs("div",{className:"absolute right-1 top-0 bottom-0 flex items-center gap-0.5 opacity-0 group-hover:opacity-100 transition-opacity bg-gradient-to-l from-white via-white to-transparent dark:from-gray-800 dark:via-gray-800 pl-4 pr-1 z-10",children:[jsxRuntime.jsx("button",{type:"button",className:p("cursor-pointer transition-opacity",k.indexed?"opacity-100":"opacity-30 hover:opacity-100"),onClick:A=>{A.stopPropagation(),T(k.id,k.indexed??false);},onMouseDown:A=>A.stopPropagation(),title:k.indexed?"Indexed (click to remove)":"Add index",children:jsxRuntime.jsx(bp,{})}),jsxRuntime.jsx("button",{type:"button",className:p("cursor-pointer transition-opacity",k.unique?"opacity-100":"opacity-30 hover:opacity-100"),onClick:A=>{A.stopPropagation(),O(k.id,k.unique??false);},onMouseDown:A=>A.stopPropagation(),title:k.unique?"Unique (click to remove)":"Add unique constraint",children:jsxRuntime.jsx(yp,{})}),jsxRuntime.jsx("button",{type:"button",className:"p-0.5 rounded text-gray-300 hover:text-red-500 hover:bg-red-50 dark:hover:bg-red-900/20 cursor-pointer",onClick:A=>{A.stopPropagation(),m?.(t.id,k.id);},onMouseDown:A=>A.stopPropagation(),title:"Remove field",children:jsxRuntime.jsx(Yk,{})})]}),jsxRuntime.jsx("div",{"data-connection-side":"right","data-field-id":k.id,"data-table-id":t.id,className:p("absolute -right-[5px] w-2.5 h-2.5 rounded-full border-2 border-white dark:border-gray-800 cursor-crosshair z-10 transition-all",s?"opacity-100 bg-green-400 scale-150 shadow-[0_0_6px_rgba(74,222,128,0.6)]":"opacity-0 group-hover:opacity-100 bg-green-400"),style:{top:32/2-5}})]},k.id)),a&&!o&&!n&&jsxRuntime.jsxs("button",{type:"button",className:"flex items-center justify-center w-full gap-1 text-xs text-gray-400 hover:text-blue-500 hover:bg-gray-50 dark:hover:bg-gray-750 transition-colors cursor-pointer",style:{height:36},onClick:k=>{k.stopPropagation(),H();},onMouseDown:k=>k.stopPropagation(),children:[jsxRuntime.jsx("svg",{className:"w-3 h-3",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",children:jsxRuntime.jsx("path",{d:"M8 4v8M4 8h8"})}),"Add field"]})]}),!n&&!o&&jsxRuntime.jsx("div",{"data-resize-handle":"corner",className:"absolute -bottom-[5px] -right-[5px] w-[14px] h-[14px] cursor-nwse-resize z-20 group/resize",onMouseDown:k=>{k.stopPropagation(),k.preventDefault();let z=t.height??jn(t,a);y?.(t.id,k.clientX,k.clientY,b,z);},children:jsxRuntime.jsxs("svg",{className:"w-full h-full text-gray-300 group-hover/resize:text-blue-400 transition-colors",viewBox:"0 0 14 14",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",children:[jsxRuntime.jsx("path",{d:"M12 2v10H2",opacity:"0"}),jsxRuntime.jsx("path",{d:"M6 12L12 6"}),jsxRuntime.jsx("path",{d:"M10 12L12 10"})]})})]})});function Qk(e,t){let r=t.find(g=>g.id===e.from.tableId),n=t.find(g=>g.id===e.to.tableId);if(!r||!n||r.collapsed||n.collapsed)return null;let o=r.fields.findIndex(g=>g.id===e.from.fieldId),a=n.fields.findIndex(g=>g.id===e.to.fieldId);if(o===-1||a===-1)return null;let s=r.width??260,l=n.width??260,i=r.x+s/2,c=n.x+l/2,d=r.y+ba(o,!!r.notes),u=n.y+ba(a,!!n.notes),f,m;return i<=c?(f=r.x+s,m=n.x):(f=r.x,m=n.x+l),{x1:f,y1:d,x2:m,y2:u,cardinality:e.cardinality??"1:n"}}var Ic=["1:1","1:n","n:1","n:n"];function Jk(e){let t=Ic.indexOf(e);return Ic[(t+1)%Ic.length]}var kp=Cl.memo(function({relations:t,tables:r,viewport:n,selectedRelationId:o,disabled:a,onRelationClick:s,onCardinalityChange:l}){return jsxRuntime.jsx("svg",{className:"absolute top-0 left-0 pointer-events-none",style:{width:"100%",height:"100%",overflow:"visible"},children:jsxRuntime.jsx("g",{transform:`translate(${n.x}, ${n.y}) scale(${n.zoom})`,children:t.map(i=>{let c=Qk(i,r);if(!c)return null;let{x1:d,y1:u,x2:f,y2:m,cardinality:g}=c,y=Pi(d,u,f,m),b=o===i.id,h=(d+f)/2,x=(u+m)/2;return jsxRuntime.jsxs("g",{children:[jsxRuntime.jsx("path",{d:y,fill:"none",stroke:"transparent",strokeWidth:16,className:"pointer-events-auto cursor-pointer",onClick:L=>{a||s?.(i.id,L);}}),jsxRuntime.jsx("path",{d:y,fill:"none",stroke:b?"#3b82f6":"#9ca3af",strokeWidth:b?2.5:1.5,className:"transition-colors"}),jsxRuntime.jsx("circle",{cx:d,cy:u,r:3,fill:b?"#3b82f6":"#9ca3af"}),jsxRuntime.jsx("circle",{cx:f,cy:m,r:3,fill:b?"#3b82f6":"#9ca3af"}),g&&jsxRuntime.jsxs("g",{className:a?void 0:"pointer-events-auto cursor-pointer",onClick:a?void 0:L=>{L.stopPropagation(),l?.(i.id,Jk(g));},children:[jsxRuntime.jsx("rect",{x:h-14,y:x-9,width:28,height:18,rx:4,fill:"white",stroke:b?"#3b82f6":"#d1d5db",strokeWidth:1}),jsxRuntime.jsx("text",{x:h,y:x+4,textAnchor:"middle",className:"text-[10px] font-mono",fill:b?"#3b82f6":"#6b7280",children:g})]})]},i.id)})})})});var tw=()=>jsxRuntime.jsx("svg",{className:"w-4 h-4",viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true",children:jsxRuntime.jsx("path",{fillRule:"evenodd",d:"M10 5a1 1 0 011 1v3h3a1 1 0 110 2h-3v3a1 1 0 11-2 0v-3H6a1 1 0 110-2h3V6a1 1 0 011-1z",clipRule:"evenodd"})}),rw=()=>jsxRuntime.jsx("svg",{className:"w-4 h-4",viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true",children:jsxRuntime.jsx("path",{fillRule:"evenodd",d:"M5 10a1 1 0 011-1h8a1 1 0 110 2H6a1 1 0 01-1-1z",clipRule:"evenodd"})}),nw=()=>jsxRuntime.jsx("svg",{className:"w-4 h-4",viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true",children:jsxRuntime.jsx("path",{fillRule:"evenodd",d:"M4 2a1 1 0 011 1v2.101a7.002 7.002 0 0111.601 2.566 1 1 0 11-1.885.666A5.002 5.002 0 005.999 7H9a1 1 0 010 2H4a1 1 0 01-1-1V3a1 1 0 011-1zm.008 9.057a1 1 0 011.276.61A5.002 5.002 0 0014.001 13H11a1 1 0 110-2h5a1 1 0 011 1v5a1 1 0 11-2 0v-2.101a7.002 7.002 0 01-11.601-2.566 1 1 0 01.61-1.276z",clipRule:"evenodd"})}),ow=()=>jsxRuntime.jsx("svg",{className:"w-4 h-4",viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true",children:jsxRuntime.jsx("path",{d:"M3 4a1 1 0 011-1h4a1 1 0 010 2H6.414l2.293 2.293a1 1 0 01-1.414 1.414L5 6.414V8a1 1 0 01-2 0V4zm9 1a1 1 0 010-2h4a1 1 0 011 1v4a1 1 0 01-2 0V6.414l-2.293 2.293a1 1 0 11-1.414-1.414L13.586 5H12zm-9 7a1 1 0 012 0v1.586l2.293-2.293a1 1 0 011.414 1.414L6.414 15H8a1 1 0 010 2H4a1 1 0 01-1-1v-4zm13 0a1 1 0 01-2 0v-1.586l-2.293 2.293a1 1 0 01-1.414-1.414L13.586 9H12a1 1 0 010-2h4a1 1 0 011 1v4z"})}),aw=()=>jsxRuntime.jsx("svg",{className:"w-4 h-4",viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true",children:jsxRuntime.jsx("path",{fillRule:"evenodd",d:"M6 2a2 2 0 00-2 2v12a2 2 0 002 2h8a2 2 0 002-2V4a2 2 0 00-2-2H6zm4 5a1 1 0 011 1v1h1a1 1 0 110 2h-1v1a1 1 0 11-2 0v-1H8a1 1 0 110-2h1V8a1 1 0 011-1z",clipRule:"evenodd"})}),sw=()=>jsxRuntime.jsx("svg",{className:"w-4 h-4",viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true",children:jsxRuntime.jsx("path",{fillRule:"evenodd",d:"M3 17a1 1 0 011-1h12a1 1 0 110 2H4a1 1 0 01-1-1zm3.293-7.707a1 1 0 011.414 0L9 10.586V3a1 1 0 112 0v7.586l1.293-1.293a1 1 0 111.414 1.414l-3 3a1 1 0 01-1.414 0l-3-3a1 1 0 010-1.414z",clipRule:"evenodd"})}),iw=()=>jsxRuntime.jsx("svg",{className:"w-4 h-4",viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true",children:jsxRuntime.jsx("path",{fillRule:"evenodd",d:"M3 17a1 1 0 011-1h12a1 1 0 110 2H4a1 1 0 01-1-1zM6.293 6.707a1 1 0 010-1.414l3-3a1 1 0 011.414 0l3 3a1 1 0 01-1.414 1.414L11 5.414V13a1 1 0 11-2 0V5.414L7.707 6.707a1 1 0 01-1.414 0z",clipRule:"evenodd"})}),lw=()=>jsxRuntime.jsx("svg",{className:"w-4 h-4",viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true",children:jsxRuntime.jsx("path",{fillRule:"evenodd",d:"M2 5a2 2 0 012-2h12a2 2 0 012 2v2a2 2 0 01-2 2H4a2 2 0 01-2-2V5zm14 1a1 1 0 11-2 0 1 1 0 012 0zM2 13a2 2 0 012-2h12a2 2 0 012 2v2a2 2 0 01-2 2H4a2 2 0 01-2-2v-2zm14 1a1 1 0 11-2 0 1 1 0 012 0z",clipRule:"evenodd"})}),cw=()=>jsxRuntime.jsx("svg",{className:"w-4 h-4",viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true",children:jsxRuntime.jsx("path",{fillRule:"evenodd",d:"M7.707 3.293a1 1 0 010 1.414L5.414 7H11a7 7 0 017 7v2a1 1 0 11-2 0v-2a5 5 0 00-5-5H5.414l2.293 2.293a1 1 0 11-1.414 1.414l-4-4a1 1 0 010-1.414l4-4a1 1 0 011.414 0z",clipRule:"evenodd"})}),dw=()=>jsxRuntime.jsx("svg",{className:"w-4 h-4",viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true",children:jsxRuntime.jsx("path",{fillRule:"evenodd",d:"M12.293 3.293a1 1 0 011.414 0l4 4a1 1 0 010 1.414l-4 4a1 1 0 01-1.414-1.414L14.586 9H9a5 5 0 00-5 5v2a1 1 0 11-2 0v-2a7 7 0 017-7h5.586l-2.293-2.293a1 1 0 010-1.414z",clipRule:"evenodd"})}),uw=()=>jsxRuntime.jsx("svg",{className:"w-4 h-4",viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true",children:jsxRuntime.jsx("path",{d:"M3 3h4v4H3V3zm0 10h4v4H3v-4zm10-10h4v4h-4V3zm0 10h4v4h-4v-4zM7 5h6v1H7V5zm0 8h6v1H7v-1zM5 7v6h1V7H5zm8 0v6h1V7h-1z"})}),wp=Cl.memo(function({zoom:t,onZoomIn:r,onZoomOut:n,onResetView:o,onFitToContent:a,onAddTable:s,onExportJSON:l,onImportJSON:i,onExportSQL:c,onUndo:d,onRedo:u,canUndo:f=false,canRedo:m=false,onAutoLayout:g,disabled:y,className:b}){let[h,x]=Cl.useState(false),[L,C]=Cl.useState(false),[S,v]=Cl.useState(false),[R,N]=Cl.useState(""),[M,P]=Cl.useState(""),[E,W]=Cl.useState(""),T=Cl.useCallback(()=>{N(l()),x(true);},[l]),O=Cl.useCallback(()=>{M.trim()&&(i(M.trim()),P(""),C(false));},[M,i]),H=Cl.useCallback(()=>{P(""),C(false);},[]),k=Cl.useCallback(()=>{x(false);},[]),z=Cl.useCallback(()=>{c&&(W(c()),v(true));},[c]),A=Cl.useCallback(()=>{v(false);},[]),I=Math.round(t*100);return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsxs("div",{className:p("absolute top-3 left-3 z-20 flex items-center gap-2 bg-white dark:bg-gray-800 rounded-lg shadow-md border border-gray-200 dark:border-gray-600 px-2 py-1.5",b),"data-testid":"schema-toolbar",onMouseDown:X=>X.stopPropagation(),children:[jsxRuntime.jsxs(ra,{size:"sm",children:[jsxRuntime.jsx($t,{content:"Zoom in",size:"sm",position:"bottom",children:jsxRuntime.jsx(Ft,{icon:jsxRuntime.jsx(tw,{}),size:"sm",bgColor:"bg-gray-100 hover:bg-gray-200 dark:bg-gray-700 dark:hover:bg-gray-600",textColor:"text-gray-700 dark:text-gray-200",onClick:r,disabled:y,"aria-label":"Zoom in"})}),jsxRuntime.jsx($t,{content:"Zoom out",size:"sm",position:"bottom",children:jsxRuntime.jsx(Ft,{icon:jsxRuntime.jsx(rw,{}),size:"sm",bgColor:"bg-gray-100 hover:bg-gray-200 dark:bg-gray-700 dark:hover:bg-gray-600",textColor:"text-gray-700 dark:text-gray-200",onClick:n,disabled:y,"aria-label":"Zoom out"})})]}),jsxRuntime.jsxs("span",{className:"text-xs font-mono text-gray-500 dark:text-gray-400 min-w-[3ch] text-center select-none",children:[I,"%"]}),jsxRuntime.jsx("div",{className:"w-px h-5 bg-gray-200 dark:bg-gray-600"}),jsxRuntime.jsx($t,{content:"Reset view",size:"sm",position:"bottom",children:jsxRuntime.jsx(Ft,{icon:jsxRuntime.jsx(nw,{}),size:"sm",bgColor:"bg-gray-100 hover:bg-gray-200 dark:bg-gray-700 dark:hover:bg-gray-600",textColor:"text-gray-700 dark:text-gray-200",onClick:o,disabled:y,"aria-label":"Reset view"})}),jsxRuntime.jsx($t,{content:"Fit to content",size:"sm",position:"bottom",children:jsxRuntime.jsx(Ft,{icon:jsxRuntime.jsx(ow,{}),size:"sm",bgColor:"bg-gray-100 hover:bg-gray-200 dark:bg-gray-700 dark:hover:bg-gray-600",textColor:"text-gray-700 dark:text-gray-200",onClick:a,disabled:y,"aria-label":"Fit to content"})}),jsxRuntime.jsx("div",{className:"w-px h-5 bg-gray-200 dark:bg-gray-600"}),jsxRuntime.jsx($t,{content:"Add table",size:"sm",position:"bottom",children:jsxRuntime.jsx(Ft,{icon:jsxRuntime.jsx(aw,{}),size:"sm",bgColor:"bg-gray-100 hover:bg-gray-200 dark:bg-gray-700 dark:hover:bg-gray-600",textColor:"text-gray-700 dark:text-gray-200",onClick:s,disabled:y,"aria-label":"Add table"})}),jsxRuntime.jsx("div",{className:"w-px h-5 bg-gray-200 dark:bg-gray-600"}),jsxRuntime.jsx($t,{content:"Export JSON",size:"sm",position:"bottom",children:jsxRuntime.jsx(Ft,{icon:jsxRuntime.jsx(sw,{}),size:"sm",bgColor:"bg-gray-100 hover:bg-gray-200 dark:bg-gray-700 dark:hover:bg-gray-600",textColor:"text-gray-700 dark:text-gray-200",onClick:T,disabled:y,"aria-label":"Export JSON"})}),jsxRuntime.jsx($t,{content:"Import JSON",size:"sm",position:"bottom",children:jsxRuntime.jsx(Ft,{icon:jsxRuntime.jsx(iw,{}),size:"sm",bgColor:"bg-gray-100 hover:bg-gray-200 dark:bg-gray-700 dark:hover:bg-gray-600",textColor:"text-gray-700 dark:text-gray-200",onClick:()=>C(true),disabled:y,"aria-label":"Import JSON"})}),c&&jsxRuntime.jsx($t,{content:"Export SQL",size:"sm",position:"bottom",children:jsxRuntime.jsx(Ft,{icon:jsxRuntime.jsx(lw,{}),size:"sm",bgColor:"bg-gray-100 hover:bg-gray-200 dark:bg-gray-700 dark:hover:bg-gray-600",textColor:"text-gray-700 dark:text-gray-200",onClick:z,disabled:y,"aria-label":"Export SQL"})}),(d||u)&&jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("div",{className:"w-px h-5 bg-gray-200 dark:bg-gray-600"}),jsxRuntime.jsxs(ra,{size:"sm",children:[jsxRuntime.jsx($t,{content:"Undo (Ctrl+Z)",size:"sm",position:"bottom",children:jsxRuntime.jsx(Ft,{icon:jsxRuntime.jsx(cw,{}),size:"sm",bgColor:"bg-gray-100 hover:bg-gray-200 dark:bg-gray-700 dark:hover:bg-gray-600",textColor:"text-gray-700 dark:text-gray-200",onClick:d,disabled:y||!f,"aria-label":"Undo"})}),jsxRuntime.jsx($t,{content:"Redo (Ctrl+Y)",size:"sm",position:"bottom",children:jsxRuntime.jsx(Ft,{icon:jsxRuntime.jsx(dw,{}),size:"sm",bgColor:"bg-gray-100 hover:bg-gray-200 dark:bg-gray-700 dark:hover:bg-gray-600",textColor:"text-gray-700 dark:text-gray-200",onClick:u,disabled:y||!m,"aria-label":"Redo"})})]})]}),g&&jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("div",{className:"w-px h-5 bg-gray-200 dark:bg-gray-600"}),jsxRuntime.jsx($t,{content:"Auto layout",size:"sm",position:"bottom",children:jsxRuntime.jsx(Ft,{icon:jsxRuntime.jsx(uw,{}),size:"sm",bgColor:"bg-gray-100 hover:bg-gray-200 dark:bg-gray-700 dark:hover:bg-gray-600",textColor:"text-gray-700 dark:text-gray-200",onClick:g,disabled:y,"aria-label":"Auto layout"})})]})]}),jsxRuntime.jsx(An,{isOpen:h,onClose:k,title:"Export Schema",description:"Copy the JSON below to save your schema.",size:"lg",showSubmit:false,showCancel:true,cancelLabel:"Close",children:jsxRuntime.jsx(dn,{label:"Schema JSON",multiline:true,rows:12,value:R,readOnly:true,size:"sm"})}),jsxRuntime.jsx(An,{isOpen:L,onClose:H,title:"Import Schema",description:"Paste schema JSON to load it into the editor.",size:"lg",showSubmit:true,submitLabel:"Import",onSubmitClick:O,showCancel:true,cancelLabel:"Cancel",children:jsxRuntime.jsx(dn,{label:"Schema JSON",multiline:true,rows:12,value:M,onChange:X=>P(X.target.value),placeholder:'{"tables": [], "relations": []}',size:"sm"})}),jsxRuntime.jsx(An,{isOpen:S,onClose:A,title:"Export SQL",description:"Generated PostgreSQL CREATE TABLE statements.",size:"lg",showSubmit:false,showCancel:true,cancelLabel:"Close",children:jsxRuntime.jsx(dn,{label:"SQL",multiline:true,rows:16,value:E,readOnly:true,size:"sm"})})]})});var pw=()=>jsxRuntime.jsxs("svg",{className:"w-3.5 h-3.5",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",children:[jsxRuntime.jsx("path",{d:"M10 1l2 2-5 5M8.5 4.5L11 7"}),jsxRuntime.jsx("circle",{cx:"4.5",cy:"11.5",r:"3"})]}),gw=()=>jsxRuntime.jsx("span",{className:"text-xs font-bold text-gray-500 w-3.5 text-center",children:"?"}),fw=()=>jsxRuntime.jsxs("svg",{className:"w-3.5 h-3.5",viewBox:"0 0 16 16",fill:"currentColor",children:[jsxRuntime.jsx("circle",{cx:"8",cy:"8",r:"6",className:"fill-blue-500"}),jsxRuntime.jsx("path",{d:"M5 8h6M8 5l3 3-3 3",stroke:"white",strokeWidth:"1.5",fill:"none",strokeLinecap:"round",strokeLinejoin:"round"})]}),hw=()=>jsxRuntime.jsx("svg",{className:"w-3.5 h-3.5 text-amber-500",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",children:jsxRuntime.jsx("path",{d:"M3 2v12M7 4h6M7 8h4M7 12h5"})}),bw=()=>jsxRuntime.jsx("svg",{className:"w-3.5 h-3.5 text-purple-500",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",children:jsxRuntime.jsx("path",{d:"M4 2v8a4 4 0 008 0V2"})}),Np=Cl.memo(function({className:t}){return jsxRuntime.jsxs("div",{className:p("absolute top-3 right-3 z-20 flex items-center gap-4 bg-white dark:bg-gray-800 rounded-lg shadow-md border border-gray-200 dark:border-gray-600 px-3 py-2",t),"data-testid":"schema-legend",children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-1.5",children:[jsxRuntime.jsx(pw,{}),jsxRuntime.jsx("span",{className:"text-xs text-gray-600 dark:text-gray-300",children:"Primary Key"})]}),jsxRuntime.jsxs("div",{className:"flex items-center gap-1.5",children:[jsxRuntime.jsx(gw,{}),jsxRuntime.jsx("span",{className:"text-xs text-gray-600 dark:text-gray-300",children:"Nullable"})]}),jsxRuntime.jsxs("div",{className:"flex items-center gap-1.5",children:[jsxRuntime.jsx(fw,{}),jsxRuntime.jsx("span",{className:"text-xs text-gray-600 dark:text-gray-300",children:"Foreign Key"})]}),jsxRuntime.jsxs("div",{className:"flex items-center gap-1.5",children:[jsxRuntime.jsx(hw,{}),jsxRuntime.jsx("span",{className:"text-xs text-gray-600 dark:text-gray-300",children:"Index"})]}),jsxRuntime.jsxs("div",{className:"flex items-center gap-1.5",children:[jsxRuntime.jsx(bw,{}),jsxRuntime.jsx("span",{className:"text-xs text-gray-600 dark:text-gray-300",children:"Unique"})]})]})});var Ei=180,Li=120,Ca=10,Sp=Cl.memo(function({tables:t,viewport:r,containerWidth:n,containerHeight:o,editable:a,onViewportChange:s,className:l}){let i=Cl.useRef(null),c=Cl.useMemo(()=>{if(t.length===0)return null;let S=1/0,v=1/0,R=-1/0,N=-1/0;for(let A of t){let I=A.width??260,X=jn(A,a);S=Math.min(S,A.x),v=Math.min(v,A.y),R=Math.max(R,A.x+I),N=Math.max(N,A.y+X);}let M=-r.x/r.zoom,P=-r.y/r.zoom,E=M+n/r.zoom,W=P+o/r.zoom;S=Math.min(S,M),v=Math.min(v,P),R=Math.max(R,E),N=Math.max(N,W);let T=R-S+Ca*2,O=N-v+Ca*2,H=Math.min((Ei-4)/T,(Li-4)/O),k=(Ei-T*H)/2,z=(Li-O*H)/2;return {minX:S,minY:v,scale:H,offsetX:k,offsetY:z,vpMinX:M,vpMinY:P}},[t,r,n,o,a]),d=Cl.useCallback(S=>{if(!c)return;let v=i.current?.getBoundingClientRect();if(!v)return;let R=S.clientX-v.left,N=S.clientY-v.top,M=(R-c.offsetX)/c.scale+c.minX-Ca,P=(N-c.offsetY)/c.scale+c.minY-Ca;s({...r,x:-(M-n/(2*r.zoom))*r.zoom,y:-(P-o/(2*r.zoom))*r.zoom});},[c,r,n,o,s]);if(!c)return null;let{minX:u,minY:f,scale:m,offsetX:g,offsetY:y,vpMinX:b,vpMinY:h}=c,x=(S,v)=>({x:(S-u+Ca)*m+g,y:(v-f+Ca)*m+y}),L=x(b,h),C={w:n/r.zoom*m,h:o/r.zoom*m};return jsxRuntime.jsx("div",{ref:i,className:p("absolute bottom-3 right-3 z-20 bg-white/90 dark:bg-gray-800/90 rounded-lg shadow-md border border-gray-200 dark:border-gray-600 cursor-pointer overflow-hidden",l),style:{width:Ei,height:Li},onClick:d,onMouseDown:S=>S.stopPropagation(),"data-testid":"schema-minimap",children:jsxRuntime.jsxs("svg",{width:Ei,height:Li,children:[t.map(S=>{let v=S.width??260,R=jn(S,a),N=x(S.x,S.y);return jsxRuntime.jsx("rect",{x:N.x,y:N.y,width:v*m,height:R*m,fill:S.color??"#e5e7eb",stroke:"#9ca3af",strokeWidth:.5,rx:1},S.id)}),jsxRuntime.jsx("rect",{x:L.x,y:L.y,width:C.w,height:C.h,fill:"rgba(59, 130, 246, 0.1)",stroke:"#3b82f6",strokeWidth:1,rx:1})]})})});function Wn(e){return `"${e.replace(/"/g,'""')}"`}function Rp(e){return {text:"TEXT",varchar:"VARCHAR(255)",char:"CHAR(1)",int2:"SMALLINT",int4:"INTEGER",int8:"BIGINT",serial:"SERIAL",bigserial:"BIGSERIAL",float4:"REAL",float8:"DOUBLE PRECISION",numeric:"NUMERIC",decimal:"DECIMAL",bool:"BOOLEAN",date:"DATE",time:"TIME",timestamp:"TIMESTAMP",timestamptz:"TIMESTAMP WITH TIME ZONE",uuid:"UUID",json:"JSON",jsonb:"JSONB",bytea:"BYTEA"}[e]??e.toUpperCase()}function ww(e){let t=[Wn(e.name)];return e.type==="serial"||e.type,t.push(Rp(e.type)),e.primaryKey&&t.push("PRIMARY KEY"),!e.nullable&&!e.primaryKey&&t.push("NOT NULL"),e.unique&&!e.primaryKey&&t.push("UNIQUE"),e.defaultValue&&t.push(`DEFAULT ${e.defaultValue}`)," "+t.join(" ")}function Nw(e,t,r){let n=[],o=[];for(let i of e.fields)n.push(ww(i));for(let i of e.fields)if(i.foreignKey){let c=r.find(u=>u.id===i.foreignKey.tableId),d=c?.fields.find(u=>u.id===i.foreignKey.fieldId);c&&d&&o.push(` CONSTRAINT ${Wn(`fk_${e.name}_${i.name}`)} FOREIGN KEY (${Wn(i.name)}) REFERENCES ${Wn(c.name)} (${Wn(d.name)})`);}let a=[];for(let i of e.fields)i.indexed&&!i.primaryKey&&!i.unique&&a.push(`CREATE INDEX ${Wn(`idx_${e.name}_${i.name}`)} ON ${Wn(e.name)} (${Wn(i.name)});`);let s=[...n,...o],l=`CREATE TABLE ${Wn(e.name)} (
24
25
  ${s.join(`,
25
26
  `)}
26
27
  );`;return a.length>0?l+`
27
28
 
28
29
  `+a.join(`
29
- `):l}function yi(e){let{tables:t,relations:r}=e;return t.length===0?"-- No tables defined":[...t].sort((a,s)=>{let l=a.fields.some(c=>c.foreignKey),i=s.fields.some(c=>c.foreignKey);return l&&!i?1:!l&&i?-1:0}).map(a=>Ak(a,r,t)).join(`
30
+ `):l}function Mi(e){let{tables:t,relations:r}=e;return t.length===0?"-- No tables defined":[...t].sort((a,s)=>{let l=a.fields.some(c=>c.foreignKey),i=s.fields.some(c=>c.foreignKey);return l&&!i?1:!l&&i?-1:0}).map(a=>Nw(a,r,t)).join(`
30
31
 
31
- `)}var zk=60,Wk=40;function gc(e,t){if(e.length===0)return e;let r=new Map;for(let p of e){let w=new Set;for(let v of p.fields)v.foreignKey&&w.add(v.foreignKey.tableId);r.set(p.id,w);}let n=new Map;for(let p of e)n.set(p.id,0);for(let[,p]of r)for(let w of p)n.has(w);for(let[p,w]of r)n.set(p,w.size);let o=[],a=[];for(let[p,w]of n)w===0&&a.push(p);for(;a.length>0;){let p=a.shift();o.push(p);for(let[w,v]of r)if(v.has(p)){let x=(n.get(w)??0)-1;n.set(w,x),x===0&&a.push(w);}}let s=new Set(o);for(let p of e)s.has(p.id)||(o.push(p.id),s.add(p.id));let l=new Map(e.map(p=>[p.id,p])),i=Math.max(1,Math.ceil(Math.sqrt(o.length))),c=0,d=0,u=0,f=0,m=[];for(let p of o){let w=l.get(p);if(!w)continue;let v=w.width??260,x=Xn(w,t);m.push({...w,x:c,y:d}),f=Math.max(f,x),u++,u>=i?(u=0,c=0,d+=f+Wk,f=0):c+=v+zk;}return m}var fc={x:0,y:0,zoom:1},hc=.1,Fk=.1,Ok=3,$k=20,_k=50;function Xk({value:e,defaultValue:t,onValueChange:r,fieldTypes:n=rs,onTableClick:o,onTableDoubleClick:a,onTableContextMenu:s,onFieldClick:l,onFieldDoubleClick:i,readOnly:c=false,disabled:d=false,draggableTables:u=true,panOnDrag:f=true,zoomOnWheel:m=true,editable:p=true,minZoom:w=Fk,maxZoom:v=Ok,snapToGrid:x=false,gridSize:h=$k,showGrid:I=true,toolbar:S=true,legend:L=true,autoFit:R=false,className:T},y){let M=e!==void 0,[k,z]=el.useState(()=>t??{tables:[],relations:[],viewport:{...fc}}),H=M?e:k,P=H.tables,B=H.relations,C=H.viewport??fc,b=el.useRef(null),E=el.useRef(null),[N,W]=el.useState(null),[F,K]=el.useState(null),[j,A]=el.useState(null),[D,V]=el.useState(null),[O,_]=el.useState({width:0,height:0}),X=el.useRef([]),G=el.useRef(-1),$=el.useRef(false),Y=el.useRef(C);Y.current=C;let se=el.useRef(P);se.current=P;let ae=el.useRef(B);ae.current=B;let U=el.useRef(x);U.current=x;let Q=el.useRef(h);Q.current=h;let le=el.useRef(p);le.current=p;let ye=el.useCallback(Z=>{if($.current)return;let oe=X.current,ie=G.current;X.current=oe.slice(0,ie+1),X.current.push(Z),X.current.length>_k&&X.current.shift(),G.current=X.current.length-1;},[]),te=el.useCallback(Z=>{if(M){let oe=Z(e);ye(oe),r?.(oe);}else z(oe=>{let ie=Z(oe);return ye(ie),r?.(ie),ie});},[M,e,r,ye]),Ce=el.useRef(te);Ce.current=te;let Pe=el.useCallback(Z=>{te(oe=>({...oe,viewport:Z}));},[te]),Se=el.useRef(Pe);Se.current=Pe,el.useEffect(()=>{function Z(ce){let pe=E.current;if(!pe)return;let Ke=b.current?.getBoundingClientRect();if(!Ke)return;let ot=Y.current;if(pe.type==="pan"){let Je=ce.clientX-pe.startX,Ve=ce.clientY-pe.startY;Se.current({...ot,x:pe.startVpX+Je,y:pe.startVpY+Ve});}if(pe.type==="table"){let Je=es(ce.clientX,ce.clientY,ot,Ke),Ve=Je.x-pe.offsetX,or=Je.y-pe.offsetY;U.current&&(Ve=oc(Ve,Q.current),or=oc(or,Q.current)),Ce.current(et=>({...et,tables:et.tables.map(It=>It.id===pe.tableId?{...It,x:Ve,y:or}:It)}));}if(pe.type==="relation"){let Je=es(ce.clientX,ce.clientY,ot,Ke);E.current={...pe,currentX:Je.x,currentY:Je.y},A({fromX:pe.fromX,fromY:pe.fromY,currentX:Je.x,currentY:Je.y});}if(pe.type==="resize"){let Je=(ce.clientX-pe.startX)/ot.zoom,Ve=(ce.clientY-pe.startY)/ot.zoom,or=180,et=80,It=Math.max(or,pe.startWidth+Je),$t=Math.max(et,pe.startHeight+Ve);Ce.current(Ct=>({...Ct,tables:Ct.tables.map(lr=>lr.id===pe.tableId?{...lr,width:It,height:$t}:lr)}));}}function oe(ce,pe,Ke,ot){let Je=Y.current,Ve=es(ce,pe,Je,Ke),or=1/0,et=null,It=null;for(let $t of ot){if($t.collapsed)continue;let Ct=$t.fields.length;if(Ct===0)continue;let lr=$t.width??260,qr=40+Ct*32+(le.current?36:0),jr=40;if(!(Ve.x<$t.x-jr||Ve.x>$t.x+lr+jr||Ve.y<$t.y-jr||Ve.y>$t.y+qr+jr))for(let kr=0;kr<$t.fields.length;kr++){let Si=$t.y+na(kr,!!$t.notes),ss=Math.abs(Ve.y-Si);ss<or&&(or=ss,et=$t.id,It=$t.fields[kr].id);}}return et&&It?{tableId:et,fieldId:It}:null}function ie(ce){let pe=E.current;if(pe){if(pe.type==="relation"){let Ke=b.current?.getBoundingClientRect();if(Ke){let ot=ae.current,Je=se.current,Ve=oe(ce.clientX,ce.clientY,Ke,Je);if(Ve&&Ve.tableId!==pe.fromTableId&&!ot.some(et=>et.from.tableId===pe.fromTableId&&et.from.fieldId===pe.fromFieldId&&et.to.tableId===Ve.tableId&&et.to.fieldId===Ve.fieldId)){let et=pe.fromTableId,It=pe.fromFieldId,$t=Ve.tableId,Ct=Ve.fieldId;Ce.current(lr=>({...lr,tables:lr.tables.map(qr=>qr.id===$t?{...qr,fields:qr.fields.map(jr=>jr.id===Ct?{...jr,foreignKey:{tableId:et,fieldId:It}}:jr)}:qr),relations:[...lr.relations,{id:ac(),from:{tableId:et,fieldId:It},to:{tableId:$t,fieldId:Ct},cardinality:"1:n"}]}));}}A(null),V(null);}E.current=null;}}return document.addEventListener("mousemove",Z),document.addEventListener("mouseup",ie),()=>{document.removeEventListener("mousemove",Z),document.removeEventListener("mouseup",ie);}},[]);let De=el.useCallback(Z=>{if(!m||d)return;Z.preventDefault();let oe=b.current?.getBoundingClientRect();if(!oe)return;let ie=Z.clientX-oe.left,ce=Z.clientY-oe.top,pe=Z.deltaY<0?1:-1,Ke=Ja(C.zoom+pe*hc,w,v),ot=Ke/C.zoom;Pe({x:ie-(ie-C.x)*ot,y:ce-(ce-C.y)*ot,zoom:Ke});},[m,d,C,w,v,Pe]),Ne=el.useCallback(Z=>{if(d)return;let oe=Z.target,ie=oe.tagName,ce=ie==="INPUT"||ie==="SELECT"||ie==="TEXTAREA"||ie==="BUTTON";if(oe.closest("[data-resize-handle]"))return;let pe=oe.closest("[data-connection-side]");if(pe&&!ce){if(c)return;Z.preventDefault();let ot=pe.getAttribute("data-table-id"),Je=pe.getAttribute("data-field-id");if(!ot||!Je)return;let Ve=P.find(It=>It.id===ot);if(!Ve)return;let or=pe.getAttribute("data-connection-side"),et=Fm(Ve,Je,or);if(!et)return;E.current={type:"relation",fromTableId:ot,fromFieldId:Je,fromX:et.x,fromY:et.y,currentX:et.x,currentY:et.y},A({fromX:et.x,fromY:et.y,currentX:et.x,currentY:et.y}),V(ot);return}let Ke=oe.closest("[data-table-id]");if(Ke){if(c)return;let ot=Ke.getAttribute("data-table-id");if(K(null),W(ot),ce)return;if(u){let Je=b.current?.getBoundingClientRect();if(!Je)return;let Ve=P.find(et=>et.id===ot);if(!Ve||Ve.locked)return;let or=es(Z.clientX,Z.clientY,C,Je);E.current={type:"table",tableId:ot,offsetX:or.x-Ve.x,offsetY:or.y-Ve.y};}return}W(null),K(null),f&&Z.button===0&&(E.current={type:"pan",startX:Z.clientX,startY:Z.clientY,startVpX:C.x,startVpY:C.y});},[d,c,u,f,C,P]),re=el.useCallback(Z=>{let oe=Z.target;if(oe.closest("[data-connection-side]"))return null;let ie=oe.closest("[data-table-id]");if(!ie)return null;let ce=ie.getAttribute("data-table-id");return P.find(pe=>pe.id===ce)??null},[P]),fe=el.useCallback(Z=>{if(d)return;let oe=re(Z);oe&&o&&o({table:oe,nativeEvent:Z.nativeEvent});},[o,d,re]),je=el.useCallback(Z=>{if(d)return;let oe=re(Z);oe&&a&&a({table:oe,nativeEvent:Z.nativeEvent});},[a,d,re]),Dt=el.useCallback(Z=>{if(d)return;let oe=re(Z);oe&&s&&(Z.preventDefault(),s({table:oe,nativeEvent:Z.nativeEvent}));},[s,d,re]),Ie=el.useCallback((Z,oe)=>{d||(oe.stopPropagation(),W(null),K(Z));},[d]),we=el.useCallback((Z,oe)=>{te(ie=>({...ie,relations:ie.relations.map(ce=>ce.id===Z?{...ce,cardinality:oe}:ce)}));},[te]),pt=G.current>0,Bt=G.current<X.current.length-1,yt=el.useCallback(()=>{if(G.current<=0)return;$.current=true,G.current--;let Z=X.current[G.current];M||z(Z),r?.(Z),$.current=false;},[M,r]),er=el.useCallback(()=>{if(G.current>=X.current.length-1)return;$.current=true,G.current++;let Z=X.current[G.current];M||z(Z),r?.(Z),$.current=false;},[M,r]),Mt=el.useCallback(()=>yi(H),[H]),Nt=el.useCallback(()=>{te(Z=>({...Z,tables:gc(Z.tables,p)}));},[te,p]),gr=el.useCallback((Z,oe,ie)=>{oe!==ie&&te(ce=>({...ce,tables:ce.tables.map(pe=>{if(pe.id!==Z)return pe;let Ke=[...pe.fields],[ot]=Ke.splice(oe,1);return Ke.splice(ie,0,ot),{...pe,fields:Ke}})}));},[te]);el.useEffect(()=>{let Z=b.current;if(!Z)return;let oe=new ResizeObserver(ie=>{for(let ce of ie)_({width:ce.contentRect.width,height:ce.contentRect.height});});return oe.observe(Z),()=>oe.disconnect()},[]);let pr=el.useRef(false);pr.current||(pr.current=true,X.current=[H],G.current=0);let vt=el.useCallback(Z=>{if(!(c||d)){if((Z.ctrlKey||Z.metaKey)&&Z.key==="z"&&!Z.shiftKey){Z.preventDefault(),yt();return}if((Z.ctrlKey||Z.metaKey)&&(Z.key==="y"||Z.key==="z"&&Z.shiftKey)){Z.preventDefault(),er();return}if(Z.key==="Delete"||Z.key==="Backspace"){let oe=Z.target;if(oe.tagName==="INPUT"||oe.tagName==="TEXTAREA"||oe.tagName==="SELECT")return;N&&(te(ie=>({...ie,tables:ie.tables.filter(ce=>ce.id!==N),relations:ie.relations.filter(ce=>ce.from.tableId!==N&&ce.to.tableId!==N)})),W(null)),F&&(te(ie=>{let ce=ie.relations.find(pe=>pe.id===F);return {...ie,tables:ce?ie.tables.map(pe=>pe.id===ce.to.tableId?{...pe,fields:pe.fields.map(Ke=>Ke.id===ce.to.fieldId?{...Ke,foreignKey:void 0}:Ke)}:pe):ie.tables,relations:ie.relations.filter(pe=>pe.id!==F)}}),K(null));}Z.key==="Escape"&&(W(null),K(null));}},[c,d,N,F,te,yt,er]),Cr=el.useCallback((Z,oe)=>{te(ie=>({...ie,tables:ie.tables.map(ce=>ce.id===Z?{...ce,name:oe}:ce)}));},[te]),he=el.useCallback((Z,oe)=>{te(ie=>({...ie,tables:ie.tables.map(ce=>ce.id===Z?{...ce,notes:oe}:ce)}));},[te]),ge=el.useCallback(Z=>{te(oe=>({...oe,tables:oe.tables.map(ie=>ie.id===Z?{...ie,collapsed:!ie.collapsed}:ie)}));},[te]),J=el.useCallback((Z,oe,ie)=>{te(ce=>({...ce,tables:ce.tables.map(pe=>pe.id===Z?{...pe,fields:pe.fields.map(Ke=>Ke.id===oe?{...Ke,...ie}:Ke)}:pe)}));},[te]),ne=el.useCallback(Z=>{te(oe=>({...oe,tables:oe.tables.map(ie=>ie.id===Z?{...ie,fields:[...ie.fields,sc()]}:ie)}));},[te]),be=el.useCallback((Z,oe)=>{te(ie=>({...ie,tables:ie.tables.map(ce=>ce.id===Z?{...ce,fields:ce.fields.filter(pe=>pe.id!==oe)}:ce),relations:ie.relations.filter(ce=>!(ce.from.tableId===Z&&ce.from.fieldId===oe)&&!(ce.to.tableId===Z&&ce.to.fieldId===oe))}));},[te]),me=el.useCallback((Z,oe,ie,ce,pe)=>{E.current={type:"resize",tableId:Z,startX:oe,startY:ie,startWidth:ce,startHeight:pe};},[]),Me=el.useCallback(()=>{let Z=Ja(C.zoom+hc,w,v);Pe({...C,zoom:Z});},[C,w,v,Pe]),ke=el.useCallback(()=>{let Z=Ja(C.zoom-hc,w,v);Pe({...C,zoom:Z});},[C,w,v,Pe]),Re=el.useCallback(()=>{Pe({...fc});},[Pe]),Be=el.useCallback(()=>{let Z=b.current?.getBoundingClientRect();if(!Z)return;let oe=Om(P,Z.width,Z.height,p),ie=Ja(oe.zoom,w,v);Pe({...oe,zoom:ie});},[P,p,w,v,Pe]),ze=el.useCallback(Z=>{te(oe=>({...oe,tables:[...oe.tables,Z]}));},[te]),st=el.useCallback(Z=>{te(oe=>({...oe,tables:oe.tables.filter(ie=>ie.id!==Z),relations:oe.relations.filter(ie=>ie.from.tableId!==Z&&ie.to.tableId!==Z)}));},[te]),qe=el.useCallback((Z,oe)=>{te(ie=>({...ie,tables:ie.tables.map(ce=>ce.id===Z?{...ce,fields:[...ce.fields,oe]}:ce)}));},[te]),Oe=el.useCallback((Z,oe)=>{be(Z,oe);},[be]),Ot=el.useCallback(Z=>{te(oe=>({...oe,tables:oe.tables.map(ie=>ie.id===Z.to.tableId?{...ie,fields:ie.fields.map(ce=>ce.id===Z.to.fieldId?{...ce,foreignKey:{tableId:Z.from.tableId,fieldId:Z.from.fieldId}}:ce)}:ie),relations:[...oe.relations,Z]}));},[te]),xt=el.useCallback(Z=>{te(oe=>{let ie=oe.relations.find(ce=>ce.id===Z);return {...oe,tables:ie?oe.tables.map(ce=>ce.id===ie.to.tableId?{...ce,fields:ce.fields.map(pe=>pe.id===ie.to.fieldId?{...pe,foreignKey:void 0}:pe)}:ce):oe.tables,relations:oe.relations.filter(ce=>ce.id!==Z)}});},[te]),Br=el.useCallback(()=>JSON.stringify(H,null,2),[H]),pn=el.useCallback(Z=>{try{let oe=JSON.parse(Z);oe&&Array.isArray(oe.tables)&&Array.isArray(oe.relations)&&te(()=>oe);}catch{}},[te]),jn=el.useCallback(()=>{let Z=b.current?.getBoundingClientRect(),oe=Y.current,ie=100,ce=100;Z&&(ie=(Z.width/2-oe.x)/oe.zoom-260/2,ce=(Z.height/2-oe.y)/oe.zoom-60),ze(ic(ie,ce));},[ze]),So=el.useCallback(()=>yi(H),[H]);el.useImperativeHandle(y,()=>({zoomIn:Me,zoomOut:ke,resetView:Re,fitToContent:Be,addTable:ze,removeTable:st,addField:qe,removeField:Oe,addRelation:Ot,removeRelation:xt,toJSON:Br,loadJSON:pn,toSQL:So}),[Me,ke,Re,Be,ze,st,qe,Oe,Ot,xt,Br,pn,So]);let Yr=el.useRef(false);el.useEffect(()=>{R&&!Yr.current&&b.current&&(Yr.current=true,Be());},[R,Be]);let Vr=el.useMemo(()=>({transform:`translate(${C.x}px, ${C.y}px) scale(${C.zoom})`,transformOrigin:"0 0"}),[C.x,C.y,C.zoom]);return jsxRuntime.jsxs("div",{ref:b,"data-testid":"schema-editor",className:g("relative w-full overflow-hidden bg-gray-50 dark:bg-gray-900 select-none",d&&"opacity-60 pointer-events-none",T),tabIndex:0,onWheel:De,onMouseDown:Ne,onClick:fe,onDoubleClick:je,onContextMenu:Dt,onKeyDown:vt,children:[I&&jsxRuntime.jsx(Vm,{gridSize:h,zoom:C.zoom}),S&&!c&&jsxRuntime.jsx(Zm,{zoom:C.zoom,onZoomIn:Me,onZoomOut:ke,onResetView:Re,onFitToContent:Be,onAddTable:jn,onExportJSON:Br,onImportJSON:pn,onExportSQL:Mt,onUndo:yt,onRedo:er,canUndo:pt,canRedo:Bt,onAutoLayout:Nt,disabled:d}),L&&jsxRuntime.jsx(Qm,{}),jsxRuntime.jsx(jm,{relations:B,tables:P,viewport:C,selectedRelationId:F,disabled:d||c,onRelationClick:Ie,onCardinalityChange:we}),jsxRuntime.jsx("div",{style:Vr,children:P.map(Z=>jsxRuntime.jsx(Ym,{table:Z,selected:N===Z.id,disabled:d||c,readOnly:c,editable:p,dropTarget:D!==null&&D!==Z.id&&!Z.collapsed,fieldTypes:n,onTableNameChange:Cr,onTableNotesChange:he,onToggleCollapse:ge,onFieldChange:J,onFieldAdd:ne,onFieldRemove:be,onFieldReorder:gr,onResizeStart:me},Z.id))}),j&&jsxRuntime.jsxs("svg",{"data-testid":"drag-relation-overlay",style:{position:"absolute",top:0,left:0,width:"100%",height:"100%",pointerEvents:"none",zIndex:1e3,overflow:"visible"},children:[jsxRuntime.jsx("path",{d:gi(j.fromX*C.zoom+C.x,j.fromY*C.zoom+C.y,j.currentX*C.zoom+C.x,j.currentY*C.zoom+C.y),fill:"none",stroke:"#3b82f6",strokeWidth:2.5,strokeDasharray:"8 4"}),jsxRuntime.jsx("circle",{cx:j.fromX*C.zoom+C.x,cy:j.fromY*C.zoom+C.y,r:5,fill:"#3b82f6"}),jsxRuntime.jsx("circle",{cx:j.currentX*C.zoom+C.x,cy:j.currentY*C.zoom+C.y,r:4,fill:"#3b82f6",opacity:.6})]}),L&&O.width>0&&jsxRuntime.jsx(Jm,{tables:P,viewport:C,containerWidth:O.width,containerHeight:O.height,editable:p,onViewportChange:Pe})]})}var rg=el.forwardRef(Xk);rg.displayName="SchemaEditor";var ng="wf-grid-pattern",og=el.memo(function({gridSize:t,zoom:r}){let n=t*r;return jsxRuntime.jsxs("svg",{className:"absolute inset-0 w-full h-full pointer-events-none","aria-hidden":"true",children:[jsxRuntime.jsx("defs",{children:jsxRuntime.jsx("pattern",{id:ng,width:n,height:n,patternUnits:"userSpaceOnUse",children:jsxRuntime.jsx("circle",{cx:1,cy:1,r:1,className:"fill-gray-300 dark:fill-gray-600"})})}),jsxRuntime.jsx("rect",{width:"100%",height:"100%",fill:`url(#${ng})`})]})});function bc(e,t){return Math.round(e/t)*t}function os(e,t,r){return Math.min(r,Math.max(t,e))}function ca(e,t,r,n){return {x:(e-n.left-r.x)/r.zoom,y:(t-n.top-r.y)/r.zoom}}function ns(e,t="horizontal"){return t==="vertical"?e==="in"?"top":"bottom":e==="in"?"left":"right"}function da(e,t,r,n="horizontal"){let o=e.width??180,a=e.height??60,s=t.side??ns(t.kind,n),l=r.filter(u=>(u.side??ns(u.kind,n))===s),i=l.findIndex(u=>u.id===t.id),c=l.length,d=c===1?.5:(i+1)/(c+1);switch(s){case "left":return {x:e.x-8,y:e.y+a*d};case "right":return {x:e.x+o+8,y:e.y+a*d};case "top":return {x:e.x+o*d,y:e.y-8};case "bottom":return {x:e.x+o*d,y:e.y+a+8}}}function vi(e,t,r,n,o="horizontal"){if(o==="vertical"){let u=Math.abs(n-t),f=Math.max(50,u*.5),m=e,p=t+f,w=r,v=n-f;return `M ${e} ${t} C ${m} ${p}, ${w} ${v}, ${r} ${n}`}let a=Math.abs(r-e),s=Math.max(50,a*.5),l=e+s,i=t,c=r-s;return `M ${e} ${t} C ${l} ${i}, ${c} ${n}, ${r} ${n}`}function ag(e,t,r,n=40){if(e.length===0)return {x:0,y:0,zoom:1};let o=1/0,a=1/0,s=-1/0,l=-1/0;for(let m of e){let p=m.width??180,w=m.height??60;o=Math.min(o,m.x),a=Math.min(a,m.y),s=Math.max(s,m.x+p),l=Math.max(l,m.y+w);}let i=s-o+n*2,c=l-a+n*2,d=Math.min(t/i,r/c,1),u=(t-i*d)/2-(o-n)*d,f=(r-c*d)/2-(a-n)*d;return {x:u,y:f,zoom:d}}var Yk=180,qk=60,Ci=12,ua=28,xc=24,jk=-8;function Zk(e,t,r,n,o="horizontal"){let a=e.side??ns(e.kind,o),s=t.filter(d=>(d.side??ns(d.kind,o))===a),l=s.findIndex(d=>d.id===e.id),i=s.length,c=i===1?.5:(l+1)/(i+1);switch(a){case "left":return {left:0,top:n*c};case "right":return {left:r,top:n*c};case "top":return {left:r*c,top:0};case "bottom":return {left:r*c,top:n}}}function Qk({port:e,allPorts:t,nodeId:r,nodeWidth:n,nodeHeight:o,disabled:a,direction:s,onMouseUp:l}){let i=Zk(e,t,n,o,s),c=a||e.disabled,d=el.useCallback(u=>{c||(u.stopPropagation(),l(r,e.id));},[c,r,e.id,l]);return jsxRuntime.jsx("div",{"data-testid":`port-${r}-${e.id}`,"data-port-id":e.id,"data-port-kind":e.kind,"data-node-id":r,className:"absolute",style:{left:i.left-ua/2,top:i.top-ua/2,width:ua,height:ua,zIndex:20},onMouseUp:d,title:e.label??e.id,children:jsxRuntime.jsx("div",{className:g("absolute rounded-full border-2 transition-colors",c?"bg-gray-300 border-gray-400 cursor-not-allowed":e.kind==="in"?"bg-blue-400 border-blue-600 hover:bg-blue-300 cursor-crosshair":"bg-green-400 border-green-600 hover:bg-green-300 cursor-crosshair"),style:{width:Ci,height:Ci,left:(ua-Ci)/2,top:(ua-Ci)/2}})})}function Jk(e,t,r){let n=e??"top-right",o=jk,a=t*(xc+4);switch(n){case "top-right":return {top:o,right:o-a};case "top-left":return {top:o,left:o+a};case "bottom-right":return {bottom:o,right:o-a};case "bottom-left":return {bottom:o,left:o+a}}}function ew({action:e,nodeId:t,index:r,nodeWidth:n,disabled:o,onActionClick:a}){let s=el.useCallback(c=>{c.stopPropagation(),c.preventDefault(),!o&&a(t,e.id,c.nativeEvent);},[o,t,e.id,a]),l=el.useCallback(c=>{c.stopPropagation();},[]),i=Jk(e.position,r);return jsxRuntime.jsx("button",{"data-testid":`action-${t}-${e.id}`,"data-action-id":e.id,"data-node-id":t,type:"button",className:g("absolute flex items-center justify-center rounded-full border shadow-sm transition-all","bg-white border-gray-300 text-gray-600","hover:bg-gray-50 hover:border-gray-400 hover:text-gray-800 hover:shadow-md","active:scale-95",o&&"opacity-50 cursor-not-allowed",!o&&"cursor-pointer",e.className),style:{...i,width:xc,height:xc,zIndex:30},onClick:s,onMouseDown:l,title:e.label,disabled:o,children:jsxRuntime.jsx("span",{className:"flex items-center justify-center w-3.5 h-3.5 [&>svg]:w-full [&>svg]:h-full",children:e.icon})})}var sg=el.memo(function({node:t,registry:r,ports:n,selected:o,disabled:a,draggable:s,direction:l,onPortMouseUp:i,onActionClick:c}){let d=t.width??Yk,u=t.height??qk,f=r.render({node:t,selected:o,disabled:a}),p=(typeof r.actions=="function"?r.actions(t):r.actions)?.filter(v=>typeof v.hidden=="function"?!v.hidden(t):!v.hidden),w=new Map;if(p)for(let v of p){let x=v.position??"top-right",h=w.get(x)??[];h.push(v),w.set(x,h);}return jsxRuntime.jsxs("div",{"data-testid":`workflow-node-${t.id}`,"data-node-id":t.id,className:g("absolute select-none group/node",s&&!t.locked&&"cursor-grab active:cursor-grabbing",t.locked&&"cursor-not-allowed opacity-75",o&&"ring-2 ring-blue-500 ring-offset-1 rounded-lg"),style:{left:t.x,top:t.y,width:d,height:u,overflow:"visible"},children:[f,n.map(v=>jsxRuntime.jsx(Qk,{port:v,allPorts:n,nodeId:t.id,nodeWidth:d,nodeHeight:u,disabled:a,direction:l,onMouseUp:i},v.id)),c&&w.size>0&&Array.from(w.entries()).map(([,v])=>v.map((x,h)=>jsxRuntime.jsx(ew,{action:x,nodeId:t.id,index:h,nodeWidth:d,disabled:a,onActionClick:c},x.id)))]})});function ig(e,t,r,n,o="horizontal"){let a=r.find(i=>i.id===e);if(!a)return null;let s=n(a),l=s.find(i=>i.id===t);return l?da(a,l,s,o):null}var nw=el.memo(function({edge:t,fromPos:r,toPos:n,selected:o,disabled:a,direction:s,onClick:l}){let i=vi(r.x,r.y,n.x,n.y,s),c=(r.x+n.x)/2,d=(r.y+n.y)/2,u=el.useCallback(f=>{f.stopPropagation(),l(t.id,f);},[t.id,l]);return jsxRuntime.jsxs("g",{"data-testid":`workflow-edge-${t.id}`,children:[jsxRuntime.jsx("path",{d:i,fill:"none",stroke:"transparent",strokeWidth:16,className:"cursor-pointer",onClick:u}),jsxRuntime.jsx("path",{d:i,fill:"none",className:g("transition-colors pointer-events-none",a||t.disabled?"stroke-gray-300":o?"stroke-blue-500":"stroke-gray-400"),strokeWidth:o?2.5:2,strokeDasharray:t.disabled?"6 3":void 0}),t.label&&jsxRuntime.jsx("text",{x:c,y:d-8,textAnchor:"middle",className:"fill-gray-600 dark:fill-gray-300 text-xs pointer-events-none select-none",fontSize:11,children:t.label})]})}),cg=el.memo(function({edges:t,nodes:r,selectedEdgeId:n,disabled:o,direction:a,onEdgeClick:s,getNodePorts:l}){return jsxRuntime.jsx("svg",{className:"absolute pointer-events-none",style:{top:0,left:0,width:1,height:1,overflow:"visible"},children:jsxRuntime.jsx("g",{className:"pointer-events-auto",children:t.map(i=>{let c=ig(i.from.nodeId,i.from.portId,r,l,a),d=ig(i.to.nodeId,i.to.portId,r,l,a);return !c||!d?null:jsxRuntime.jsx(nw,{edge:i,fromPos:c,toPos:d,selected:i.id===n,disabled:o,direction:a,onClick:s},i.id)})})})});var sw=()=>jsxRuntime.jsx("svg",{className:"w-4 h-4",viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true",children:jsxRuntime.jsx("path",{fillRule:"evenodd",d:"M10 5a1 1 0 011 1v3h3a1 1 0 110 2h-3v3a1 1 0 11-2 0v-3H6a1 1 0 110-2h3V6a1 1 0 011-1z",clipRule:"evenodd"})}),iw=()=>jsxRuntime.jsx("svg",{className:"w-4 h-4",viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true",children:jsxRuntime.jsx("path",{fillRule:"evenodd",d:"M5 10a1 1 0 011-1h8a1 1 0 110 2H6a1 1 0 01-1-1z",clipRule:"evenodd"})}),lw=()=>jsxRuntime.jsx("svg",{className:"w-4 h-4",viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true",children:jsxRuntime.jsx("path",{fillRule:"evenodd",d:"M4 2a1 1 0 011 1v2.101a7.002 7.002 0 0111.601 2.566 1 1 0 11-1.885.666A5.002 5.002 0 005.999 7H9a1 1 0 010 2H4a1 1 0 01-1-1V3a1 1 0 011-1zm.008 9.057a1 1 0 011.276.61A5.002 5.002 0 0014.001 13H11a1 1 0 110-2h5a1 1 0 011 1v5a1 1 0 11-2 0v-2.101a7.002 7.002 0 01-11.601-2.566 1 1 0 01.61-1.276z",clipRule:"evenodd"})}),cw=()=>jsxRuntime.jsx("svg",{className:"w-4 h-4",viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true",children:jsxRuntime.jsx("path",{d:"M3 4a1 1 0 011-1h4a1 1 0 010 2H6.414l2.293 2.293a1 1 0 01-1.414 1.414L5 6.414V8a1 1 0 01-2 0V4zm9 1a1 1 0 010-2h4a1 1 0 011 1v4a1 1 0 01-2 0V6.414l-2.293 2.293a1 1 0 11-1.414-1.414L13.586 5H12zm-9 7a1 1 0 012 0v1.586l2.293-2.293a1 1 0 011.414 1.414L6.414 15H8a1 1 0 010 2H4a1 1 0 01-1-1v-4zm13 0a1 1 0 01-2 0v-1.586l-2.293 2.293a1 1 0 01-1.414-1.414L13.586 9H12a1 1 0 010-2h4a1 1 0 011 1v4z"})}),dw=()=>jsxRuntime.jsx("svg",{className:"w-4 h-4",viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true",children:jsxRuntime.jsx("path",{fillRule:"evenodd",d:"M3 17a1 1 0 011-1h12a1 1 0 110 2H4a1 1 0 01-1-1zm3.293-7.707a1 1 0 011.414 0L9 10.586V3a1 1 0 112 0v7.586l1.293-1.293a1 1 0 111.414 1.414l-3 3a1 1 0 01-1.414 0l-3-3a1 1 0 010-1.414z",clipRule:"evenodd"})}),uw=()=>jsxRuntime.jsx("svg",{className:"w-4 h-4",viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true",children:jsxRuntime.jsx("path",{fillRule:"evenodd",d:"M3 17a1 1 0 011-1h12a1 1 0 110 2H4a1 1 0 01-1-1zM6.293 6.707a1 1 0 010-1.414l3-3a1 1 0 011.414 0l3 3a1 1 0 01-1.414 1.414L11 5.414V13a1 1 0 11-2 0V5.414L7.707 6.707a1 1 0 01-1.414 0z",clipRule:"evenodd"})}),mw=()=>jsxRuntime.jsx("svg",{className:"w-4 h-4",viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true",children:jsxRuntime.jsx("path",{fillRule:"evenodd",d:"M10.293 3.293a1 1 0 011.414 0l6 6a1 1 0 010 1.414l-6 6a1 1 0 01-1.414-1.414L14.586 11H3a1 1 0 110-2h11.586l-4.293-4.293a1 1 0 010-1.414z",clipRule:"evenodd"})}),gw=()=>jsxRuntime.jsx("svg",{className:"w-4 h-4",viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true",children:jsxRuntime.jsx("path",{fillRule:"evenodd",d:"M16.707 10.293a1 1 0 010 1.414l-6 6a1 1 0 01-1.414 0l-6-6a1 1 0 111.414-1.414L9 14.586V3a1 1 0 012 0v11.586l4.293-4.293a1 1 0 011.414 0z",clipRule:"evenodd"})}),ug=el.memo(function({zoom:t,direction:r,onDirectionChange:n,onZoomIn:o,onZoomOut:a,onResetView:s,onFitToContent:l,onExportJSON:i,onImportJSON:c,disabled:d,className:u}){let[f,m]=el.useState(false),[p,w]=el.useState(false),[v,x]=el.useState(""),[h,I]=el.useState(""),S=el.useCallback(()=>{x(i()),m(true);},[i]),L=el.useCallback(()=>{h.trim()&&(c(h.trim()),I(""),w(false));},[h,c]),R=el.useCallback(()=>{I(""),w(false);},[]),T=el.useCallback(()=>{m(false);},[]),y=Math.round(t*100);return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsxs("div",{className:g("absolute top-3 left-3 z-20 flex items-center gap-2 bg-white dark:bg-gray-800 rounded-lg shadow-md border border-gray-200 dark:border-gray-600 px-2 py-1.5",u),"data-testid":"workflow-toolbar",children:[jsxRuntime.jsxs(_o,{size:"sm",children:[jsxRuntime.jsx(Ht,{content:"Zoom in",size:"sm",position:"bottom",children:jsxRuntime.jsx(Wt,{icon:jsxRuntime.jsx(sw,{}),size:"sm",bgColor:"bg-gray-100 hover:bg-gray-200 dark:bg-gray-700 dark:hover:bg-gray-600",textColor:"text-gray-700 dark:text-gray-200",onClick:o,disabled:d,"aria-label":"Zoom in"})}),jsxRuntime.jsx(Ht,{content:"Zoom out",size:"sm",position:"bottom",children:jsxRuntime.jsx(Wt,{icon:jsxRuntime.jsx(iw,{}),size:"sm",bgColor:"bg-gray-100 hover:bg-gray-200 dark:bg-gray-700 dark:hover:bg-gray-600",textColor:"text-gray-700 dark:text-gray-200",onClick:a,disabled:d,"aria-label":"Zoom out"})})]}),jsxRuntime.jsxs("span",{className:"text-xs font-mono text-gray-500 dark:text-gray-400 min-w-[3ch] text-center select-none",children:[y,"%"]}),jsxRuntime.jsx("div",{className:"w-px h-5 bg-gray-200 dark:bg-gray-600"}),jsxRuntime.jsx(Ht,{content:"Reset view",size:"sm",position:"bottom",children:jsxRuntime.jsx(Wt,{icon:jsxRuntime.jsx(lw,{}),size:"sm",bgColor:"bg-gray-100 hover:bg-gray-200 dark:bg-gray-700 dark:hover:bg-gray-600",textColor:"text-gray-700 dark:text-gray-200",onClick:s,disabled:d,"aria-label":"Reset view"})}),jsxRuntime.jsx(Ht,{content:"Fit to content",size:"sm",position:"bottom",children:jsxRuntime.jsx(Wt,{icon:jsxRuntime.jsx(cw,{}),size:"sm",bgColor:"bg-gray-100 hover:bg-gray-200 dark:bg-gray-700 dark:hover:bg-gray-600",textColor:"text-gray-700 dark:text-gray-200",onClick:l,disabled:d,"aria-label":"Fit to content"})}),n&&jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("div",{className:"w-px h-5 bg-gray-200 dark:bg-gray-600"}),jsxRuntime.jsx(Ht,{content:r==="horizontal"?"Switch to vertical":"Switch to horizontal",size:"sm",position:"bottom",children:jsxRuntime.jsx(Wt,{icon:r==="horizontal"?jsxRuntime.jsx(mw,{}):jsxRuntime.jsx(gw,{}),size:"sm",bgColor:"bg-gray-100 hover:bg-gray-200 dark:bg-gray-700 dark:hover:bg-gray-600",textColor:"text-gray-700 dark:text-gray-200",onClick:()=>n(r==="horizontal"?"vertical":"horizontal"),disabled:d,"aria-label":r==="horizontal"?"Switch to vertical":"Switch to horizontal"})})]}),jsxRuntime.jsx("div",{className:"w-px h-5 bg-gray-200 dark:bg-gray-600"}),jsxRuntime.jsx(Ht,{content:"Export JSON",size:"sm",position:"bottom",children:jsxRuntime.jsx(Wt,{icon:jsxRuntime.jsx(dw,{}),size:"sm",bgColor:"bg-gray-100 hover:bg-gray-200 dark:bg-gray-700 dark:hover:bg-gray-600",textColor:"text-gray-700 dark:text-gray-200",onClick:S,disabled:d,"aria-label":"Export JSON"})}),jsxRuntime.jsx(Ht,{content:"Import JSON",size:"sm",position:"bottom",children:jsxRuntime.jsx(Wt,{icon:jsxRuntime.jsx(uw,{}),size:"sm",bgColor:"bg-gray-100 hover:bg-gray-200 dark:bg-gray-700 dark:hover:bg-gray-600",textColor:"text-gray-700 dark:text-gray-200",onClick:()=>w(true),disabled:d,"aria-label":"Import JSON"})})]}),jsxRuntime.jsx(Ln,{isOpen:f,onClose:T,title:"Export Workflow",description:"Copy the JSON below to save your workflow.",size:"lg",showSubmit:false,showCancel:true,cancelLabel:"Close",children:jsxRuntime.jsx(ln,{label:"Workflow JSON",multiline:true,rows:12,value:v,readOnly:true,size:"sm"})}),jsxRuntime.jsx(Ln,{isOpen:p,onClose:R,title:"Import Workflow",description:"Paste workflow JSON to load it into the editor.",size:"lg",showSubmit:true,submitLabel:"Import",onSubmitClick:L,showCancel:true,cancelLabel:"Cancel",children:jsxRuntime.jsx(ln,{label:"Workflow JSON",multiline:true,rows:12,value:h,onChange:M=>I(M.target.value),placeholder:'{"nodes": [], "edges": []}',size:"sm"})})]})});var vc={x:0,y:0,zoom:1},Cc=.1,hw=.1,bw=3,yw=20;function pg(){return `edge-${Date.now()}-${Math.random().toString(36).slice(2,8)}`}function xw({value:e,defaultValue:t,onValueChange:r,nodeRegistry:n,direction:o="horizontal",onDirectionChange:a,onNodeClick:s,onNodeDoubleClick:l,onNodeContextMenu:i,onNodeAction:c,readOnly:d=false,disabled:u=false,draggableNodes:f=true,connectable:m=true,selectable:p=true,multiSelect:w=false,panOnDrag:v=true,zoomOnWheel:x=true,minZoom:h=hw,maxZoom:I=bw,snapToGrid:S=false,gridSize:L=yw,showGrid:R=true,toolbar:T=true,autoFit:y=false,className:M},k){let z=e!==void 0,[H,P]=el.useState(()=>t??{nodes:[],edges:[],viewport:{...vc}}),B=z?e:H,C=B.nodes,b=B.edges,E=B.viewport??vc,N=el.useRef(null),W=el.useRef(null),[F,K]=el.useState(new Set),[j,A]=el.useState(null),[D,V]=el.useState(null),O=el.useRef(E);O.current=E;let _=el.useRef(C);_.current=C;let X=el.useRef(b);X.current=b;let G=el.useRef(S);G.current=S;let $=el.useRef(L);$.current=L;let Y=el.useRef(n);Y.current=n;let se=el.useRef(o);se.current=o;let ae=el.useCallback(J=>{z?r?.(J(e)):P(ne=>{let be=J(ne);return r?.(be),be});},[z,e,r]),U=el.useRef(ae);U.current=ae;let Q=el.useCallback(J=>{ae(ne=>({...ne,viewport:J}));},[ae]),le=el.useRef(Q);le.current=Q;let ye=el.useCallback(J=>{let ne=n[J.type];return ne?.getPorts?ne.getPorts(J):J.ports??[]},[n]),te=el.useRef(ye);te.current=ye;let Ce=el.useCallback((J,ne,be)=>{let me=_.current,Me=X.current,ke=me.find(xt=>xt.id===J.fromNodeId),Re=me.find(xt=>xt.id===ne);if(!ke||!Re)return;let Be=te.current(ke),ze=te.current(Re),st=Be.find(xt=>xt.id===J.fromPortId),qe=ze.find(xt=>xt.id===be);if(!st||!qe||qe.kind!=="in"||J.fromNodeId===ne)return;let Oe=Y.current[ke.type];if(Oe?.canConnect&&!Oe.canConnect({fromNode:ke,toNode:Re,fromPort:st,toPort:qe}))return;Me.some(xt=>xt.from.nodeId===J.fromNodeId&&xt.from.portId===J.fromPortId&&xt.to.nodeId===ne&&xt.to.portId===be)||U.current(xt=>({...xt,edges:[...xt.edges,{id:pg(),from:{nodeId:J.fromNodeId,portId:J.fromPortId},to:{nodeId:ne,portId:be}}]}));},[]);el.useEffect(()=>{function J(be){let me=W.current;if(!me)return;let Me=N.current?.getBoundingClientRect();if(!Me)return;let ke=O.current;if(me.type==="pan"){let Re=be.clientX-me.startX,Be=be.clientY-me.startY;le.current({...ke,x:me.startViewportX+Re,y:me.startViewportY+Be});}if(me.type==="node"){let Re=ca(be.clientX,be.clientY,ke,Me),Be=Re.x-me.offsetX,ze=Re.y-me.offsetY;G.current&&(Be=bc(Be,$.current),ze=bc(ze,$.current)),U.current(st=>({...st,nodes:st.nodes.map(qe=>qe.id===me.nodeId?{...qe,x:Be,y:ze}:qe)}));}if(me.type==="edge"){let Re=ca(be.clientX,be.clientY,ke,Me);W.current={...me,currentX:Re.x,currentY:Re.y},V({fromX:me.fromX,fromY:me.fromY,currentX:Re.x,currentY:Re.y});}}function ne(be){let me=W.current;if(me){if(me.type==="edge"){let Me=N.current?.getBoundingClientRect();if(Me){let ke=O.current,Re=ca(be.clientX,be.clientY,ke,Me),Be=25,ze=_.current,st=1/0,qe=null,Oe=null;for(let Ot of ze){let xt=te.current(Ot);for(let Br of xt){if(Br.kind!=="in")continue;let pn=da(Ot,Br,xt,se.current),jn=Math.sqrt((Re.x-pn.x)**2+(Re.y-pn.y)**2);jn<Be&&jn<st&&(st=jn,qe=Ot.id,Oe=Br.id);}}qe&&Oe&&Ce(me,qe,Oe);}V(null);}W.current=null;}}return document.addEventListener("mousemove",J),document.addEventListener("mouseup",ne),()=>{document.removeEventListener("mousemove",J),document.removeEventListener("mouseup",ne);}},[Ce]);let Pe=el.useCallback(J=>{if(!x||u)return;J.preventDefault();let ne=N.current?.getBoundingClientRect();if(!ne)return;let be=J.clientX-ne.left,me=J.clientY-ne.top,Me=J.deltaY<0?1:-1,ke=os(E.zoom+Me*Cc,h,I),Re=ke/E.zoom;Q({x:be-(be-E.x)*Re,y:me-(me-E.y)*Re,zoom:ke});},[x,u,E,h,I,Q]),Se=el.useCallback(J=>{if(u)return;let ne=J.target;if(ne.closest("[data-action-id]"))return;let me=ne.closest("[data-port-id]");if(me){if(!m||d)return;J.preventDefault();let ke=me.getAttribute("data-node-id"),Re=me.getAttribute("data-port-id"),Be=me.getAttribute("data-port-kind");if(!ke||!Re||Be!=="out")return;let ze=C.find(Ot=>Ot.id===ke);if(!ze)return;let st=ye(ze),qe=st.find(Ot=>Ot.id===Re);if(!qe)return;let Oe=da(ze,qe,st,se.current);W.current={type:"edge",fromNodeId:ke,fromPortId:Re,fromX:Oe.x,fromY:Oe.y,currentX:Oe.x,currentY:Oe.y},V({fromX:Oe.x,fromY:Oe.y,currentX:Oe.x,currentY:Oe.y});return}let Me=ne.closest("[data-node-id]");if(Me){if(d)return;let ke=Me.getAttribute("data-node-id");if(p&&(A(null),w&&J.shiftKey?K(Re=>{let Be=new Set(Re);return Be.has(ke)?Be.delete(ke):Be.add(ke),Be}):K(new Set([ke]))),f){let Re=N.current?.getBoundingClientRect();if(!Re)return;let Be=C.find(st=>st.id===ke);if(!Be||Be.locked)return;let ze=ca(J.clientX,J.clientY,E,Re);W.current={type:"node",nodeId:ke,startX:ze.x,startY:ze.y,offsetX:ze.x-Be.x,offsetY:ze.y-Be.y};}return}p&&(K(new Set),A(null)),v&&J.button===0&&(W.current={type:"pan",startX:J.clientX,startY:J.clientY,startViewportX:E.x,startViewportY:E.y});},[u,m,d,p,w,f,v,E,C,ye]),De=el.useCallback(J=>{let ne=W.current;if(!ne||ne.type!=="edge")return;let be=N.current?.getBoundingClientRect();if(be){let me=ca(J.clientX,J.clientY,E,be),Me=30,ke=1/0,Re=null,Be=null;for(let ze of C){let st=ye(ze);for(let qe of st){if(qe.kind!=="in")continue;let Oe=da(ze,qe,st,se.current),Ot=Math.sqrt((me.x-Oe.x)**2+(me.y-Oe.y)**2);Ot<Me&&Ot<ke&&(ke=Ot,Re=ze.id,Be=qe.id);}}if(Re&&Be){let ze=ne.fromNodeId,st=ne.fromPortId;ze!==Re&&(b.some(Oe=>Oe.from.nodeId===ze&&Oe.from.portId===st&&Oe.to.nodeId===Re&&Oe.to.portId===Be)||ae(Oe=>({...Oe,edges:[...Oe.edges,{id:pg(),from:{nodeId:ze,portId:st},to:{nodeId:Re,portId:Be}}]})));}}W.current=null,V(null);},[E,C,b,ye,ae]),Ne=el.useCallback((J,ne)=>{let be=W.current;!be||be.type!=="edge"||(Ce(be,J,ne),W.current=null,V(null));},[Ce]),re=el.useCallback(J=>{let ne=J.target;if(ne.closest("[data-port-id]")||ne.closest("[data-action-id]"))return null;let Me=ne.closest("[data-node-id]");if(!Me)return null;let ke=Me.getAttribute("data-node-id");return C.find(Re=>Re.id===ke)??null},[C]),fe=el.useCallback(J=>{if(!s||u)return;let ne=re(J);ne&&s({node:ne,nativeEvent:J.nativeEvent});},[s,u,re]),je=el.useCallback(J=>{if(!l||u)return;let ne=re(J);ne&&l({node:ne,nativeEvent:J.nativeEvent});},[l,u,re]),Dt=el.useCallback(J=>{if(!i||u)return;let ne=re(J);ne&&(J.preventDefault(),i({node:ne,nativeEvent:J.nativeEvent}));},[i,u,re]),Ie=el.useCallback((J,ne,be)=>{if(!c||u)return;let me=C.find(Me=>Me.id===J);me&&c({node:me,actionId:ne,nativeEvent:be});},[c,u,C]),we=el.useCallback((J,ne)=>{!p||u||(ne.stopPropagation(),K(new Set),A(J));},[p,u]),pt=el.useCallback(J=>{d||u||((J.key==="Delete"||J.key==="Backspace")&&(F.size>0&&(ae(ne=>({...ne,nodes:ne.nodes.filter(be=>!F.has(be.id)),edges:ne.edges.filter(be=>!F.has(be.from.nodeId)&&!F.has(be.to.nodeId))})),K(new Set)),j&&(ae(ne=>({...ne,edges:ne.edges.filter(be=>be.id!==j)})),A(null))),J.key==="Escape"&&(K(new Set),A(null)));},[d,u,F,j,ae]),Bt=el.useCallback(()=>{let J=os(E.zoom+Cc,h,I);Q({...E,zoom:J});},[E,h,I,Q]),yt=el.useCallback(()=>{let J=os(E.zoom-Cc,h,I);Q({...E,zoom:J});},[E,h,I,Q]),er=el.useCallback(()=>{Q({...vc});},[Q]),Mt=el.useCallback(()=>{let J=N.current?.getBoundingClientRect();if(!J)return;let ne=ag(C,J.width,J.height),be=os(ne.zoom,h,I);Q({...ne,zoom:be});},[C,h,I,Q]),Nt=el.useCallback(J=>{ae(ne=>({...ne,nodes:[...ne.nodes,J]}));},[ae]),gr=el.useCallback(J=>{ae(ne=>({...ne,nodes:ne.nodes.filter(be=>be.id!==J),edges:ne.edges.filter(be=>be.from.nodeId!==J&&be.to.nodeId!==J)}));},[ae]),pr=el.useCallback(()=>JSON.stringify(B,null,2),[B]),vt=el.useCallback(J=>{try{let ne=JSON.parse(J);ne&&Array.isArray(ne.nodes)&&Array.isArray(ne.edges)&&ae(()=>ne);}catch{}},[ae]);el.useImperativeHandle(k,()=>({zoomIn:Bt,zoomOut:yt,resetView:er,fitToContent:Mt,addNode:Nt,removeNode:gr,toJSON:pr,loadJSON:vt}),[Bt,yt,er,Mt,Nt,gr,pr,vt]);let Cr=el.useRef(false);el.useEffect(()=>{y&&!Cr.current&&N.current&&(Cr.current=true,Mt());},[y,Mt]);let he=el.useMemo(()=>{let J=new Map;for(let ne of C)J.set(ne.id,ye(ne));return J},[C,ye]),ge=el.useMemo(()=>({transform:`translate(${E.x}px, ${E.y}px) scale(${E.zoom})`,transformOrigin:"0 0"}),[E.x,E.y,E.zoom]);return jsxRuntime.jsxs("div",{ref:N,"data-testid":"workflow-editor",className:g("relative w-full overflow-hidden bg-gray-50 dark:bg-gray-900 select-none",u&&"opacity-60 pointer-events-none",M),tabIndex:0,onWheel:Pe,onMouseDown:Se,onMouseUp:De,onClick:fe,onDoubleClick:je,onContextMenu:Dt,onKeyDown:pt,children:[R&&jsxRuntime.jsx(og,{gridSize:L,zoom:E.zoom}),T&&!d&&jsxRuntime.jsx(ug,{zoom:E.zoom,direction:o,onDirectionChange:a,onZoomIn:Bt,onZoomOut:yt,onResetView:er,onFitToContent:Mt,onExportJSON:pr,onImportJSON:vt,disabled:u}),jsxRuntime.jsxs("div",{style:ge,children:[jsxRuntime.jsx(cg,{edges:b,nodes:C,selectedEdgeId:j,disabled:u||d,direction:o,onEdgeClick:we,getNodePorts:J=>he.get(J.id)??[]}),C.map(J=>{let ne=n[J.type];if(!ne)return null;let be=he.get(J.id)??[];return jsxRuntime.jsx(sg,{node:J,registry:ne,ports:be,selected:F.has(J.id),disabled:u||d,draggable:f&&!d,direction:o,onPortMouseUp:Ne,onActionClick:c?Ie:void 0},J.id)})]}),D&&jsxRuntime.jsxs("svg",{"data-testid":"drag-edge-overlay",style:{position:"absolute",top:0,left:0,width:"100%",height:"100%",pointerEvents:"none",zIndex:1e3,overflow:"visible"},children:[jsxRuntime.jsx("path",{d:vi(D.fromX*E.zoom+E.x,D.fromY*E.zoom+E.y,D.currentX*E.zoom+E.x,D.currentY*E.zoom+E.y,o),fill:"none",stroke:"#3b82f6",strokeWidth:2.5,strokeDasharray:"8 4"}),jsxRuntime.jsx("circle",{cx:D.fromX*E.zoom+E.x,cy:D.fromY*E.zoom+E.y,r:5,fill:"#3b82f6"}),jsxRuntime.jsx("circle",{cx:D.currentX*E.zoom+E.x,cy:D.currentY*E.zoom+E.y,r:4,fill:"#3b82f6",opacity:.6})]})]})}var fg=el.forwardRef(xw);fg.displayName="WorkflowEditor";var xg=el.createContext(null);function qn(){let e=el.useContext(xg);if(!e)throw new Error("useWizard and Wizard sub-components must be used within <Wizard>");return e}var wc=(e,t,r)=>Math.max(t,Math.min(e,r)),Nc={sm:{circle:"h-7 w-7 text-xs",dot:"h-2.5 w-2.5",icon:"h-3.5 w-3.5",title:"text-xs",desc:"text-[11px]",connector:"h-0.5"},md:{circle:"h-9 w-9 text-sm",dot:"h-3 w-3",icon:"h-4 w-4",title:"text-sm",desc:"text-xs",connector:"h-0.5"},lg:{circle:"h-11 w-11 text-base",dot:"h-3.5 w-3.5",icon:"h-5 w-5",title:"text-base",desc:"text-sm",connector:"h-1"}},gn={primary:{solid:"bg-blue-600 text-white",bg:"bg-blue-600",text:"text-blue-600 dark:text-blue-400",ring:"focus-visible:ring-blue-500",ringSoft:"ring-blue-500/20"},secondary:{solid:"bg-gray-700 text-white",bg:"bg-gray-700",text:"text-gray-700 dark:text-gray-300",ring:"focus-visible:ring-gray-500",ringSoft:"ring-gray-500/20"},success:{solid:"bg-green-600 text-white",bg:"bg-green-600",text:"text-green-600 dark:text-green-400",ring:"focus-visible:ring-green-500",ringSoft:"ring-green-500/20"},warning:{solid:"bg-amber-500 text-white",bg:"bg-amber-500",text:"text-amber-600 dark:text-amber-400",ring:"focus-visible:ring-amber-500",ringSoft:"ring-amber-500/20"},error:{solid:"bg-red-600 text-white",bg:"bg-red-600",text:"text-red-600 dark:text-red-400",ring:"focus-visible:ring-red-500",ringSoft:"ring-red-500/20"}};function kw({className:e}){return jsxRuntime.jsx("svg",{className:e,viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true",children:jsxRuntime.jsx("path",{fillRule:"evenodd",d:"M16.707 5.293a1 1 0 010 1.414l-8 8a1 1 0 01-1.414 0l-4-4a1 1 0 011.414-1.414L8 12.586l7.293-7.293a1 1 0 011.414 0z",clipRule:"evenodd"})})}function vg({steps:e,step:t,defaultStep:r=0,onStepChange:n,onComplete:o,orientation:a="horizontal",variant:s="default",size:l="md",color:i="primary",linear:c=true,className:d,children:u}){let f=e.length,m=Math.max(0,f-1),p=t!==void 0,[w,v]=el.useState(()=>wc(r,0,m)),x=wc(p?t:w,0,m),[h,I]=el.useState(x);h<x&&I(x);let S=x<=0,L=x>=m,R=el.useCallback((P,B)=>{let C=wc(P,0,m);C!==x&&(p||v(C),I(b=>Math.max(b,C)),n?.(C,{previous:x,direction:B}));},[x,p,m,n]),T=el.useCallback(P=>{let B=e[P];return !B||B.disabled?false:c?P<=h:true},[e,c,h]),y=el.useCallback(P=>{T(P)&&R(P,P>x?"jump":"backward");},[T,R,x]),M=el.useCallback(()=>{if(L){o?.();return}R(x+1,"forward");},[L,o,R,x]),k=el.useCallback(()=>{S||R(x-1,"backward");},[S,R,x]),z=el.useCallback(P=>e[P]?.error?"error":P===x?"active":P<x?"completed":"upcoming",[e,x]),H={steps:e,activeStep:x,totalSteps:f,isFirstStep:S,isLastStep:L,orientation:a,variant:s,size:l,color:i,linear:c,goToStep:y,goNext:M,goBack:k,getStepStatus:z,isStepAccessible:T};return jsxRuntime.jsx(xg.Provider,{value:H,children:jsxRuntime.jsx("div",{className:g("flex w-full flex-col gap-6",d),"data-testid":"wizard","data-orientation":a,children:u})})}function bg({index:e,status:t}){let{variant:r,size:n,color:o,steps:a}=qn(),s=Nc[n],l=a[e];if(r==="dots"){let d=t==="upcoming"?"bg-gray-300 dark:bg-gray-600":t==="error"?"bg-red-600":gn[o].bg;return jsxRuntime.jsx("span",{className:g("shrink-0 rounded-full transition-colors",s.dot,d),"aria-hidden":"true"})}let i=t==="completed"?g(gn[o].solid,"border-transparent"):t==="active"?g(gn[o].solid,"border-transparent ring-4",gn[o].ringSoft):t==="error"?"border-transparent bg-red-600 text-white":"border-2 border-gray-300 bg-white text-gray-500 dark:border-gray-600 dark:bg-gray-800 dark:text-gray-400",c=t==="completed"?jsxRuntime.jsx(kw,{className:s.icon}):t==="error"?jsxRuntime.jsx("span",{className:"font-semibold leading-none",children:"!"}):l.icon??jsxRuntime.jsx("span",{className:"font-medium leading-none",children:e+1});return jsxRuntime.jsx("span",{className:g("flex shrink-0 items-center justify-center rounded-full transition-all",s.circle,i),"aria-hidden":"true",children:c})}function yg({index:e,status:t}){let{steps:r,size:n,color:o,variant:a}=qn(),s=Nc[n],l=r[e],c=t==="active"?gn[o].text:t==="completed"?"text-gray-900 dark:text-gray-100":t==="error"?"text-red-600 dark:text-red-400":"text-gray-500 dark:text-gray-400";return jsxRuntime.jsxs("span",{className:"flex min-w-0 flex-col",children:[jsxRuntime.jsxs("span",{className:g("font-medium leading-tight",s.title,c),children:[a==="simple"&&jsxRuntime.jsxs("span",{className:"mr-1 tabular-nums",children:[e+1,"."]}),l.title,l.optional&&jsxRuntime.jsx("span",{className:"ml-1 text-xs font-normal text-gray-400 dark:text-gray-500",children:"(optional)"})]}),l.description&&jsxRuntime.jsx("span",{className:g("mt-0.5 text-gray-400 dark:text-gray-500",s.desc),children:l.description})]})}function Cg({className:e,hideConnector:t=false,hideLabels:r=false}){let n=qn(),{steps:o,orientation:a,size:s,variant:l,color:i,activeStep:c}=n,d=Nc[s],u=a==="vertical",f=l!=="simple";return jsxRuntime.jsx("ol",{className:g("flex w-full",u?"flex-col":"items-start",e),"data-testid":"wizard-steps","data-orientation":a,children:o.map((m,p)=>{let w=n.getStepStatus(p),v=p===c,x=n.isStepAccessible(p)&&!v,h=p===o.length-1,S=p<c?gn[i].bg:"bg-gray-200 dark:bg-gray-700";return u?jsxRuntime.jsx("li",{className:"flex","aria-current":v?"step":void 0,"data-status":w,"data-testid":"wizard-step",children:jsxRuntime.jsxs("button",{type:"button",disabled:!x,onClick:()=>n.goToStep(p),className:g("flex items-stretch gap-3 rounded-md text-left focus:outline-none focus-visible:ring-2 focus-visible:ring-offset-2",gn[i].ring,x?"cursor-pointer":"cursor-default"),children:[jsxRuntime.jsxs("span",{className:"flex flex-col items-center",children:[f&&jsxRuntime.jsx(bg,{index:p,status:w}),!t&&!h&&jsxRuntime.jsx("span",{className:g("my-1 w-0.5 flex-1 rounded",S),"aria-hidden":"true"})]}),!r&&jsxRuntime.jsx("span",{className:g(h?"pb-0":"pb-6"),children:jsxRuntime.jsx(yg,{index:p,status:w})})]})},m.id??p):jsxRuntime.jsxs("li",{className:g("flex items-center",!h&&"flex-1"),"aria-current":v?"step":void 0,"data-status":w,"data-testid":"wizard-step",children:[jsxRuntime.jsxs("button",{type:"button",disabled:!x,onClick:()=>n.goToStep(p),className:g("flex items-center gap-2.5 rounded-md focus:outline-none focus-visible:ring-2 focus-visible:ring-offset-2",gn[i].ring,x?"cursor-pointer":"cursor-default"),children:[f&&jsxRuntime.jsx(bg,{index:p,status:w}),!r&&jsxRuntime.jsx(yg,{index:p,status:w})]}),!t&&!h&&jsxRuntime.jsx("span",{className:g("mx-2 flex-1 rounded",d.connector,S),"aria-hidden":"true"})]},m.id??p)})})}function kg({index:e,keepMounted:t=false,className:r,children:n}){let{activeStep:o}=qn(),a=e===o;return !a&&!t?null:jsxRuntime.jsx("div",{role:"tabpanel",hidden:!a,"data-testid":"wizard-panel","data-active":a,"data-step":e,className:g("w-full",r),children:n})}function wg({className:e,children:t}){let r=qn();return jsxRuntime.jsx("div",{className:g("w-full",e),"data-testid":"wizard-content",children:typeof t=="function"?t(r):t})}var Ng="inline-flex cursor-pointer items-center justify-center gap-2 rounded-lg px-4 py-2 text-sm font-medium transition-colors focus:outline-none focus-visible:ring-2 focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50";function Sc({children:e,label:t="Previous",className:r,onClick:n,disabled:o,...a}){let{goBack:s,isFirstStep:l}=qn();return jsxRuntime.jsx("button",{type:"button",onClick:c=>{n?.(c),c.defaultPrevented||s();},disabled:o??l,"data-testid":"wizard-previous",className:g(Ng,"border border-gray-300 bg-white text-gray-700 hover:bg-gray-50 focus-visible:ring-gray-400 dark:border-gray-600 dark:bg-gray-800 dark:text-gray-200 dark:hover:bg-gray-700",r),...a,children:e??t})}function Rc({children:e,label:t="Next",finishLabel:r="Finish",className:n,onClick:o,...a}){let{goNext:s,isLastStep:l,color:i}=qn();return jsxRuntime.jsx("button",{type:"button",onClick:d=>{o?.(d),d.defaultPrevented||s();},"data-testid":"wizard-next",className:g(Ng,gn[i].solid,gn[i].ring,"hover:opacity-90",n),...a,children:e??(l?r:t)})}function Sg({className:e,children:t,align:r="between"}){let n={between:"justify-between",start:"justify-start",center:"justify-center",end:"justify-end"}[r];return jsxRuntime.jsx("div",{className:g("flex items-center gap-3",n,e),"data-testid":"wizard-actions",children:t??jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(Sc,{}),jsxRuntime.jsx(Rc,{})]})})}vg.displayName="Wizard";Cg.displayName="WizardSteps";kg.displayName="WizardPanel";wg.displayName="WizardContent";Sg.displayName="WizardActions";Sc.displayName="WizardPrevious";Rc.displayName="WizardNext";exports.Accordion=Ug;exports.AccordionContent=jg;exports.AccordionItem=Yg;exports.AccordionTrigger=qg;exports.AdvanceDetachable=Vc;exports.AreaChart=nf;exports.Avatar=lf;exports.Badge=dd;exports.Banner=hd;exports.BarChart=Rf;exports.BoxPlot=V0;exports.Breadcrumb=Bf;exports.BulletChart=Yf;exports.Button=Wt;exports.ButtonGroup=_o;exports.CHART_ALL_PAIRS_LIMIT=oo;exports.CHART_DIVERGING_COLORS=no;exports.CHART_DIVERGING_DARK_STOPS=Jc;exports.CHART_DIVERGING_NEUTRAL_INDEX=Zc;exports.CHART_DOWN_COLOR=Oi;exports.CHART_MAX_COLOR_CLASSES=ys;exports.CHART_MUTED_COLOR=Pr;exports.CHART_ORDINAL_COLORS=ya;exports.CHART_ORDINAL_DARK_STOPS=$i;exports.CHART_PALETTE_SIZE=_p;exports.CHART_PATTERNS=Hi;exports.CHART_SEQUENTIAL_COLORS=Vi;exports.CHART_SEQUENTIAL_DARK_STOPS=Qc;exports.CHART_SERIES_COLORS=bs;exports.CHART_SURFACE_COLOR=eo;exports.CHART_UP_COLOR=Fi;exports.Calendar=nl;exports.CandlestickChart=U0;exports.Card=wd;exports.CardBody=Rd;exports.CardDescription=Ld;exports.CardFooter=Td;exports.CardHeader=Sd;exports.CardImage=Pd;exports.CardTitle=Dd;exports.ChartAnnotationLayer=tn;exports.ChartAxis=Ue;exports.ChartContainer=lt;exports.ChartFacets=Z0;exports.ChartFilterBar=eh;exports.ChartGrid=_t;exports.ChartLegend=Xt;exports.ChartPatternDefs=ro;exports.ChartPeriodPicker=hh;exports.ChartScaleLegend=Ra;exports.ChartTableView=zt;exports.ChartTooltip=dt;exports.ChartTooltipContent=Nr;exports.Checkbox=Aa;exports.CheckboxGroup=Od;exports.CheckboxGroupItem=$d;exports.Chip=Gs;exports.CircularProgress=Po;exports.DEFAULT_CHART_PERIOD_PRESETS=gl;exports.DEFAULT_CHART_WIDTH=Xc;exports.DEFAULT_FIELD_TYPES=rs;exports.DataGrid=Pb;exports.Detachable=Kd;exports.DeviceMockup=iy;exports.Divider=Yd;exports.Drawer=au;exports.Dropdown=gu;exports.DropdownCheckboxItem=Tu;exports.DropdownContent=xu;exports.DropdownItem=Cu;exports.DropdownLabel=wu;exports.DropdownRadioGroup=Eu;exports.DropdownRadioItem=Mu;exports.DropdownSeparator=ku;exports.DropdownSubMenu=Bu;exports.DropdownSubMenuContent=Fu;exports.DropdownSubMenuTrigger=Vu;exports.DropdownTrigger=fu;exports.DumbbellChart=Sh;exports.FOCUSABLE_SELECTOR=Jd;exports.FileSelector=Dy;exports.Footer=Pm;exports.FooterBottom=Mm;exports.FooterColumn=Lm;exports.FooterLink=Em;exports.FooterSection=Dm;exports.FooterSocial=Im;exports.FooterSocialLink=Am;exports.FunnelChart=Ah;exports.GanttChart=$h;exports.Header=Ex;exports.Heatmap=bv;exports.HelpButton=Gu;exports.INERT_IGNORE_ATTRIBUTE=Md;exports.ImageUploader=Jx;exports.Indicator=Uu;exports.Input=ln;exports.Label=Zu;exports.LineChart=Sv;exports.MentionInput=Hl;exports.Modal=Ln;exports.NumberInput=Bl;exports.Pagination=Fv;exports.PieChart=jv;exports.ProgressBar=sm;exports.RadioButton=im;exports.ScatterChart=QC;exports.SchemaEditor=rg;exports.Select=v1;exports.Sidebar=T1;exports.SidebarContent=D1;exports.SidebarFooter=L1;exports.SidebarGroup=E1;exports.SidebarHeader=P1;exports.SidebarItem=M1;exports.SidebarSubMenu=I1;exports.SidebarToggle=A1;exports.Skeleton=gm;exports.Slider=fm;exports.Sparkline=jl;exports.StatCard=$1;exports.StatCardGroup=X1;exports.Table=fn;exports.TableBody=hn;exports.TableCell=Gt;exports.TableHeader=bn;exports.TableHeaderCell=St;exports.TableRow=yn;exports.Tabs=bm;exports.TabsContent=km;exports.TabsList=ym;exports.TabsTrigger=Cm;exports.Toast=Sm;exports.Tooltip=Ht;exports.UILabelsProvider=hp;exports.WaterfallChart=Qh;exports.WithHelpButton=Kx;exports.Wizard=vg;exports.WizardActions=Sg;exports.WizardContent=wg;exports.WizardNext=Rc;exports.WizardPanel=kg;exports.WizardPrevious=Sc;exports.WizardSteps=Cg;exports.WorkflowEditor=fg;exports.autoLayoutTables=gc;exports.binEdges=md;exports.binValues=Yi;exports.boxStats=ol;exports.cn=g;exports.createDefaultField=sc;exports.createDefaultTable=ic;exports.createDivergingScale=Mo;exports.createPeriod=Ea;exports.createSequentialScale=va;exports.defaultUILabels=Oc;exports.describeAnnotations=Jn;exports.endOfDay=Ms;exports.findOwnedLayers=Ls;exports.formatPeriodRange=pl;exports.formatTimeTick=Hs;exports.frenchUILabels=fp;exports.generateFieldId=ts;exports.generateRelationId=ac;exports.generateSQL=yi;exports.generateTableId=$m;exports.getFocusableElements=Us;exports.getOrdinalColor=Gp;exports.getPattern=hs;exports.getSeriesColor=Dr;exports.getSeriesLabel=Kt;exports.hideOthers=ml;exports.isElementVisible=eu;exports.isFocusable=tu;exports.niceTimeTicks=bl;exports.patternBackground=Bi;exports.patternFill=to;exports.patternId=fs;exports.quantile=M0;exports.quantileSorted=Pa;exports.rampColor=Eo;exports.registerFloatingLayer=wn;exports.resetBarChartWarnings=kf;exports.resetDumbbellWarnings=kh;exports.resetFacetWarnings=Q0;exports.resolvePeriodPreset=Id;exports.resolveSeriesColor=Lr;exports.samePeriod=uh;exports.startOfDay=Es;exports.sturgesBins=ud;exports.toLegendItems=$r;exports.toTimestamp=mo;exports.useChartSize=Wi;exports.useClickOutside=jo;exports.useDialogA11y=fo;exports.useDropdownContext=Sr;exports.useFocusItem=bu;exports.useKeyboardNavigation=js;exports.usePositioning=Bn;exports.useSidebar=w1;exports.useUILabels=We;exports.useWizard=qn;
32
+ `)}var Sw=60,Rw=40;function Bc(e,t){if(e.length===0)return e;let r=new Map;for(let g of e){let y=new Set;for(let b of g.fields)b.foreignKey&&y.add(b.foreignKey.tableId);r.set(g.id,y);}let n=new Map;for(let g of e)n.set(g.id,0);for(let[,g]of r)for(let y of g)n.has(y);for(let[g,y]of r)n.set(g,y.size);let o=[],a=[];for(let[g,y]of n)y===0&&a.push(g);for(;a.length>0;){let g=a.shift();o.push(g);for(let[y,b]of r)if(b.has(g)){let h=(n.get(y)??0)-1;n.set(y,h),h===0&&a.push(y);}}let s=new Set(o);for(let g of e)s.has(g.id)||(o.push(g.id),s.add(g.id));let l=new Map(e.map(g=>[g.id,g])),i=Math.max(1,Math.ceil(Math.sqrt(o.length))),c=0,d=0,u=0,f=0,m=[];for(let g of o){let y=l.get(g);if(!y)continue;let b=y.width??260,h=jn(y,t);m.push({...y,x:c,y:d}),f=Math.max(f,h),u++,u>=i?(u=0,c=0,d+=f+Rw,f=0):c+=b+Sw;}return m}var Wc={x:0,y:0,zoom:1},Vc=.1,Ew=.1,Lw=3,Mw=20,Iw=50;function Aw({value:e,defaultValue:t,onValueChange:r,fieldTypes:n=ps,onTableClick:o,onTableDoubleClick:a,onTableContextMenu:s,onFieldClick:l,onFieldDoubleClick:i,readOnly:c=false,disabled:d=false,draggableTables:u=true,panOnDrag:f=true,zoomOnWheel:m=true,editable:g=true,minZoom:y=Ew,maxZoom:b=Lw,snapToGrid:h=false,gridSize:x=Mw,showGrid:L=true,toolbar:C=true,legend:S=true,autoFit:v=false,className:R},N){let M=e!==void 0,[P,E]=Cl.useState(()=>t??{tables:[],relations:[],viewport:{...Wc}}),W=M?e:P,T=W.tables,O=W.relations,H=W.viewport??Wc,k=Cl.useRef(null),z=Cl.useRef(null),[A,I]=Cl.useState(null),[X,$]=Cl.useState(null),[K,D]=Cl.useState(null),[B,w]=Cl.useState(null),[G,q]=Cl.useState({width:0,height:0}),j=Cl.useRef([]),U=Cl.useRef(-1),F=Cl.useRef(false),_=Cl.useRef(H);_.current=H;let J=Cl.useRef(T);J.current=T;let ne=Cl.useRef(O);ne.current=O;let Y=Cl.useRef(h);Y.current=h;let ee=Cl.useRef(x);ee.current=x;let Z=Cl.useRef(g);Z.current=g;let ie=Cl.useCallback(te=>{if(F.current)return;let ue=j.current,me=U.current;j.current=ue.slice(0,me+1),j.current.push(te),j.current.length>Iw&&j.current.shift(),U.current=j.current.length-1;},[]),V=Cl.useCallback(te=>{if(M){let ue=te(e);ie(ue),r?.(ue);}else E(ue=>{let me=te(ue);return ie(me),r?.(me),me});},[M,e,r,ie]),oe=Cl.useRef(V);oe.current=V;let pe=Cl.useCallback(te=>{V(ue=>({...ue,viewport:te}));},[V]),Te=Cl.useRef(pe);Te.current=pe,Cl.useEffect(()=>{function te(ge){let xe=z.current;if(!xe)return;let Ye=k.current?.getBoundingClientRect();if(!Ye)return;let at=_.current;if(xe.type==="pan"){let et=ge.clientX-xe.startX,Fe=ge.clientY-xe.startY;Te.current({...at,x:xe.startVpX+et,y:xe.startVpY+Fe});}if(xe.type==="table"){let et=us(ge.clientX,ge.clientY,at,Ye),Fe=et.x-xe.offsetX,St=et.y-xe.offsetY;Y.current&&(Fe=Pc(Fe,ee.current),St=Pc(St,ee.current)),oe.current(je=>({...je,tables:je.tables.map(Mt=>Mt.id===xe.tableId?{...Mt,x:Fe,y:St}:Mt)}));}if(xe.type==="relation"){let et=us(ge.clientX,ge.clientY,at,Ye);z.current={...xe,currentX:et.x,currentY:et.y},D({fromX:xe.fromX,fromY:xe.fromY,currentX:et.x,currentY:et.y});}if(xe.type==="resize"){let et=(ge.clientX-xe.startX)/at.zoom,Fe=(ge.clientY-xe.startY)/at.zoom,St=180,je=80,Mt=Math.max(St,xe.startWidth+et),Gt=Math.max(je,xe.startHeight+Fe);oe.current(Tt=>({...Tt,tables:Tt.tables.map(gr=>gr.id===xe.tableId?{...gr,width:Mt,height:Gt}:gr)}));}}function ue(ge,xe,Ye,at){let et=_.current,Fe=us(ge,xe,et,Ye),St=1/0,je=null,Mt=null;for(let Gt of at){if(Gt.collapsed)continue;let Tt=Gt.fields.length;if(Tt===0)continue;let gr=Gt.width??260,qr=40+Tt*32+(Z.current?36:0),Zr=40;if(!(Fe.x<Gt.x-Zr||Fe.x>Gt.x+gr+Zr||Fe.y<Gt.y-Zr||Fe.y>Gt.y+qr+Zr))for(let Rr=0;Rr<Gt.fields.length;Rr++){let Vi=Gt.y+ba(Rr,!!Gt.notes),bs=Math.abs(Fe.y-Vi);bs<St&&(St=bs,je=Gt.id,Mt=Gt.fields[Rr].id);}}return je&&Mt?{tableId:je,fieldId:Mt}:null}function me(ge){let xe=z.current;if(xe){if(xe.type==="relation"){let Ye=k.current?.getBoundingClientRect();if(Ye){let at=ne.current,et=J.current,Fe=ue(ge.clientX,ge.clientY,Ye,et);if(Fe&&Fe.tableId!==xe.fromTableId&&!at.some(je=>je.from.tableId===xe.fromTableId&&je.from.fieldId===xe.fromFieldId&&je.to.tableId===Fe.tableId&&je.to.fieldId===Fe.fieldId)){let je=xe.fromTableId,Mt=xe.fromFieldId,Gt=Fe.tableId,Tt=Fe.fieldId;oe.current(gr=>({...gr,tables:gr.tables.map(qr=>qr.id===Gt?{...qr,fields:qr.fields.map(Zr=>Zr.id===Tt?{...Zr,foreignKey:{tableId:je,fieldId:Mt}}:Zr)}:qr),relations:[...gr.relations,{id:Tc(),from:{tableId:je,fieldId:Mt},to:{tableId:Gt,fieldId:Tt},cardinality:"1:n"}]}));}}D(null),w(null);}z.current=null;}}return document.addEventListener("mousemove",te),document.addEventListener("mouseup",me),()=>{document.removeEventListener("mousemove",te),document.removeEventListener("mouseup",me);}},[]);let ze=Cl.useCallback(te=>{if(!m||d)return;te.preventDefault();let ue=k.current?.getBoundingClientRect();if(!ue)return;let me=te.clientX-ue.left,ge=te.clientY-ue.top,xe=te.deltaY<0?1:-1,Ye=ds(H.zoom+xe*Vc,y,b),at=Ye/H.zoom;pe({x:me-(me-H.x)*at,y:ge-(ge-H.y)*at,zoom:Ye});},[m,d,H,y,b,pe]),ae=Cl.useCallback(te=>{if(d)return;let ue=te.target,me=ue.tagName,ge=me==="INPUT"||me==="SELECT"||me==="TEXTAREA"||me==="BUTTON";if(ue.closest("[data-resize-handle]"))return;let xe=ue.closest("[data-connection-side]");if(xe&&!ge){if(c)return;te.preventDefault();let at=xe.getAttribute("data-table-id"),et=xe.getAttribute("data-field-id");if(!at||!et)return;let Fe=T.find(Mt=>Mt.id===at);if(!Fe)return;let St=xe.getAttribute("data-connection-side"),je=mp(Fe,et,St);if(!je)return;z.current={type:"relation",fromTableId:at,fromFieldId:et,fromX:je.x,fromY:je.y,currentX:je.x,currentY:je.y},D({fromX:je.x,fromY:je.y,currentX:je.x,currentY:je.y}),w(at);return}let Ye=ue.closest("[data-table-id]");if(Ye){if(c)return;let at=Ye.getAttribute("data-table-id");if($(null),I(at),ge)return;if(u){let et=k.current?.getBoundingClientRect();if(!et)return;let Fe=T.find(je=>je.id===at);if(!Fe||Fe.locked)return;let St=us(te.clientX,te.clientY,H,et);z.current={type:"table",tableId:at,offsetX:St.x-Fe.x,offsetY:St.y-Fe.y};}return}I(null),$(null),f&&te.button===0&&(z.current={type:"pan",startX:te.clientX,startY:te.clientY,startVpX:H.x,startVpY:H.y});},[d,c,u,f,H,T]),re=Cl.useCallback(te=>{let ue=te.target;if(ue.closest("[data-connection-side]"))return null;let me=ue.closest("[data-table-id]");if(!me)return null;let ge=me.getAttribute("data-table-id");return T.find(xe=>xe.id===ge)??null},[T]),ce=Cl.useCallback(te=>{if(d)return;let ue=re(te);ue&&o&&o({table:ue,nativeEvent:te.nativeEvent});},[o,d,re]),De=Cl.useCallback(te=>{if(d)return;let ue=re(te);ue&&a&&a({table:ue,nativeEvent:te.nativeEvent});},[a,d,re]),Ge=Cl.useCallback(te=>{if(d)return;let ue=re(te);ue&&s&&(te.preventDefault(),s({table:ue,nativeEvent:te.nativeEvent}));},[s,d,re]),be=Cl.useCallback((te,ue)=>{d||(ue.stopPropagation(),I(null),$(te));},[d]),Me=Cl.useCallback((te,ue)=>{V(me=>({...me,relations:me.relations.map(ge=>ge.id===te?{...ge,cardinality:ue}:ge)}));},[V]),Re=U.current>0,He=U.current<j.current.length-1,Ee=Cl.useCallback(()=>{if(U.current<=0)return;F.current=true,U.current--;let te=j.current[U.current];M||E(te),r?.(te),F.current=false;},[M,r]),$e=Cl.useCallback(()=>{if(U.current>=j.current.length-1)return;F.current=true,U.current++;let te=j.current[U.current];M||E(te),r?.(te),F.current=false;},[M,r]),bt=Cl.useCallback(()=>Mi(W),[W]),Kt=Cl.useCallback(()=>{V(te=>({...te,tables:Bc(te.tables,g)}));},[V,g]),dr=Cl.useCallback((te,ue,me)=>{ue!==me&&V(ge=>({...ge,tables:ge.tables.map(xe=>{if(xe.id!==te)return xe;let Ye=[...xe.fields],[at]=Ye.splice(ue,1);return Ye.splice(me,0,at),{...xe,fields:Ye}})}));},[V]);Cl.useEffect(()=>{let te=k.current;if(!te)return;let ue=new ResizeObserver(me=>{for(let ge of me)q({width:ge.contentRect.width,height:ge.contentRect.height});});return ue.observe(te),()=>ue.disconnect()},[]);let _t=Cl.useRef(false);_t.current||(_t.current=true,j.current=[W],U.current=0);let Xt=Cl.useCallback(te=>{if(!(c||d)){if((te.ctrlKey||te.metaKey)&&te.key==="z"&&!te.shiftKey){te.preventDefault(),Ee();return}if((te.ctrlKey||te.metaKey)&&(te.key==="y"||te.key==="z"&&te.shiftKey)){te.preventDefault(),$e();return}if(te.key==="Delete"||te.key==="Backspace"){let ue=te.target;if(ue.tagName==="INPUT"||ue.tagName==="TEXTAREA"||ue.tagName==="SELECT")return;A&&(V(me=>({...me,tables:me.tables.filter(ge=>ge.id!==A),relations:me.relations.filter(ge=>ge.from.tableId!==A&&ge.to.tableId!==A)})),I(null)),X&&(V(me=>{let ge=me.relations.find(xe=>xe.id===X);return {...me,tables:ge?me.tables.map(xe=>xe.id===ge.to.tableId?{...xe,fields:xe.fields.map(Ye=>Ye.id===ge.to.fieldId?{...Ye,foreignKey:void 0}:Ye)}:xe):me.tables,relations:me.relations.filter(xe=>xe.id!==X)}}),$(null));}te.key==="Escape"&&(I(null),$(null));}},[c,d,A,X,V,Ee,$e]),Mr=Cl.useCallback((te,ue)=>{V(me=>({...me,tables:me.tables.map(ge=>ge.id===te?{...ge,name:ue}:ge)}));},[V]),Ce=Cl.useCallback((te,ue)=>{V(me=>({...me,tables:me.tables.map(ge=>ge.id===te?{...ge,notes:ue}:ge)}));},[V]),we=Cl.useCallback(te=>{V(ue=>({...ue,tables:ue.tables.map(me=>me.id===te?{...me,collapsed:!me.collapsed}:me)}));},[V]),se=Cl.useCallback((te,ue,me)=>{V(ge=>({...ge,tables:ge.tables.map(xe=>xe.id===te?{...xe,fields:xe.fields.map(Ye=>Ye.id===ue?{...Ye,...me}:Ye)}:xe)}));},[V]),de=Cl.useCallback(te=>{V(ue=>({...ue,tables:ue.tables.map(me=>me.id===te?{...me,fields:[...me.fields,Dc()]}:me)}));},[V]),ke=Cl.useCallback((te,ue)=>{V(me=>({...me,tables:me.tables.map(ge=>ge.id===te?{...ge,fields:ge.fields.filter(xe=>xe.id!==ue)}:ge),relations:me.relations.filter(ge=>!(ge.from.tableId===te&&ge.from.fieldId===ue)&&!(ge.to.tableId===te&&ge.to.fieldId===ue))}));},[V]),ve=Cl.useCallback((te,ue,me,ge,xe)=>{z.current={type:"resize",tableId:te,startX:ue,startY:me,startWidth:ge,startHeight:xe};},[]),Be=Cl.useCallback(()=>{let te=ds(H.zoom+Vc,y,b);pe({...H,zoom:te});},[H,y,b,pe]),Pe=Cl.useCallback(()=>{let te=ds(H.zoom-Vc,y,b);pe({...H,zoom:te});},[H,y,b,pe]),ye=Cl.useCallback(()=>{pe({...Wc});},[pe]),Xe=Cl.useCallback(()=>{let te=k.current?.getBoundingClientRect();if(!te)return;let ue=pp(T,te.width,te.height,g),me=ds(ue.zoom,y,b);pe({...ue,zoom:me});},[T,g,y,b,pe]),We=Cl.useCallback(te=>{V(ue=>({...ue,tables:[...ue.tables,te]}));},[V]),ut=Cl.useCallback(te=>{V(ue=>({...ue,tables:ue.tables.filter(me=>me.id!==te),relations:ue.relations.filter(me=>me.from.tableId!==te&&me.to.tableId!==te)}));},[V]),ot=Cl.useCallback((te,ue)=>{V(me=>({...me,tables:me.tables.map(ge=>ge.id===te?{...ge,fields:[...ge.fields,ue]}:ge)}));},[V]),Ke=Cl.useCallback((te,ue)=>{ke(te,ue);},[ke]),mt=Cl.useCallback(te=>{V(ue=>({...ue,tables:ue.tables.map(me=>me.id===te.to.tableId?{...me,fields:me.fields.map(ge=>ge.id===te.to.fieldId?{...ge,foreignKey:{tableId:te.from.tableId,fieldId:te.from.fieldId}}:ge)}:me),relations:[...ue.relations,te]}));},[V]),ct=Cl.useCallback(te=>{V(ue=>{let me=ue.relations.find(ge=>ge.id===te);return {...ue,tables:me?ue.tables.map(ge=>ge.id===me.to.tableId?{...ge,fields:ge.fields.map(xe=>xe.id===me.to.fieldId?{...xe,foreignKey:void 0}:xe)}:ge):ue.tables,relations:ue.relations.filter(ge=>ge.id!==te)}});},[V]),xr=Cl.useCallback(()=>JSON.stringify(W,null,2),[W]),Pt=Cl.useCallback(te=>{try{let ue=JSON.parse(te);ue&&Array.isArray(ue.tables)&&Array.isArray(ue.relations)&&V(()=>ue);}catch{}},[V]),jr=Cl.useCallback(()=>{let te=k.current?.getBoundingClientRect(),ue=_.current,me=100,ge=100;te&&(me=(te.width/2-ue.x)/ue.zoom-260/2,ge=(te.height/2-ue.y)/ue.zoom-60),We(Ec(me,ge));},[We]),hn=Cl.useCallback(()=>Mi(W),[W]);Cl.useImperativeHandle(N,()=>({zoomIn:Be,zoomOut:Pe,resetView:ye,fitToContent:Xe,addTable:We,removeTable:ut,addField:ot,removeField:Ke,addRelation:mt,removeRelation:ct,toJSON:xr,loadJSON:Pt,toSQL:hn}),[Be,Pe,ye,Xe,We,ut,ot,Ke,mt,ct,xr,Pt,hn]);let ar=Cl.useRef(false);Cl.useEffect(()=>{v&&!ar.current&&k.current&&(ar.current=true,Xe());},[v,Xe]);let sr=Cl.useMemo(()=>({transform:`translate(${H.x}px, ${H.y}px) scale(${H.zoom})`,transformOrigin:"0 0"}),[H.x,H.y,H.zoom]);return jsxRuntime.jsxs("div",{ref:k,"data-testid":"schema-editor",className:p("relative w-full overflow-hidden bg-gray-50 dark:bg-gray-900 select-none",d&&"opacity-60 pointer-events-none",R),tabIndex:0,onWheel:ze,onMouseDown:ae,onClick:ce,onDoubleClick:De,onContextMenu:Ge,onKeyDown:Xt,children:[L&&jsxRuntime.jsx(up,{gridSize:x,zoom:H.zoom}),C&&!c&&jsxRuntime.jsx(wp,{zoom:H.zoom,onZoomIn:Be,onZoomOut:Pe,onResetView:ye,onFitToContent:Xe,onAddTable:jr,onExportJSON:xr,onImportJSON:Pt,onExportSQL:bt,onUndo:Ee,onRedo:$e,canUndo:Re,canRedo:He,onAutoLayout:Kt,disabled:d}),S&&jsxRuntime.jsx(Np,{}),jsxRuntime.jsx(kp,{relations:O,tables:T,viewport:H,selectedRelationId:X,disabled:d||c,onRelationClick:be,onCardinalityChange:Me}),jsxRuntime.jsx("div",{style:sr,children:T.map(te=>jsxRuntime.jsx(vp,{table:te,selected:A===te.id,disabled:d||c,readOnly:c,editable:g,dropTarget:B!==null&&B!==te.id&&!te.collapsed,fieldTypes:n,onTableNameChange:Mr,onTableNotesChange:Ce,onToggleCollapse:we,onFieldChange:se,onFieldAdd:de,onFieldRemove:ke,onFieldReorder:dr,onResizeStart:ve},te.id))}),K&&jsxRuntime.jsxs("svg",{"data-testid":"drag-relation-overlay",style:{position:"absolute",top:0,left:0,width:"100%",height:"100%",pointerEvents:"none",zIndex:1e3,overflow:"visible"},children:[jsxRuntime.jsx("path",{d:Pi(K.fromX*H.zoom+H.x,K.fromY*H.zoom+H.y,K.currentX*H.zoom+H.x,K.currentY*H.zoom+H.y),fill:"none",stroke:"#3b82f6",strokeWidth:2.5,strokeDasharray:"8 4"}),jsxRuntime.jsx("circle",{cx:K.fromX*H.zoom+H.x,cy:K.fromY*H.zoom+H.y,r:5,fill:"#3b82f6"}),jsxRuntime.jsx("circle",{cx:K.currentX*H.zoom+H.x,cy:K.currentY*H.zoom+H.y,r:4,fill:"#3b82f6",opacity:.6})]}),S&&G.width>0&&jsxRuntime.jsx(Sp,{tables:T,viewport:H,containerWidth:G.width,containerHeight:G.height,editable:g,onViewportChange:pe})]})}var Tp=Cl.forwardRef(Aw);Tp.displayName="SchemaEditor";var Dp="wf-grid-pattern",Ep=Cl.memo(function({gridSize:t,zoom:r}){let n=t*r;return jsxRuntime.jsxs("svg",{className:"absolute inset-0 w-full h-full pointer-events-none","aria-hidden":"true",children:[jsxRuntime.jsx("defs",{children:jsxRuntime.jsx("pattern",{id:Dp,width:n,height:n,patternUnits:"userSpaceOnUse",children:jsxRuntime.jsx("circle",{cx:1,cy:1,r:1,className:"fill-gray-300 dark:fill-gray-600"})})}),jsxRuntime.jsx("rect",{width:"100%",height:"100%",fill:`url(#${Dp})`})]})});function Oc(e,t){return Math.round(e/t)*t}function fs(e,t,r){return Math.min(r,Math.max(t,e))}function wa(e,t,r,n){return {x:(e-n.left-r.x)/r.zoom,y:(t-n.top-r.y)/r.zoom}}function gs(e,t="horizontal"){return t==="vertical"?e==="in"?"top":"bottom":e==="in"?"left":"right"}function Na(e,t,r,n="horizontal"){let o=e.width??180,a=e.height??60,s=t.side??gs(t.kind,n),l=r.filter(u=>(u.side??gs(u.kind,n))===s),i=l.findIndex(u=>u.id===t.id),c=l.length,d=c===1?.5:(i+1)/(c+1);switch(s){case "left":return {x:e.x-8,y:e.y+a*d};case "right":return {x:e.x+o+8,y:e.y+a*d};case "top":return {x:e.x+o*d,y:e.y-8};case "bottom":return {x:e.x+o*d,y:e.y+a+8}}}function Ai(e,t,r,n,o="horizontal"){if(o==="vertical"){let u=Math.abs(n-t),f=Math.max(50,u*.5),m=e,g=t+f,y=r,b=n-f;return `M ${e} ${t} C ${m} ${g}, ${y} ${b}, ${r} ${n}`}let a=Math.abs(r-e),s=Math.max(50,a*.5),l=e+s,i=t,c=r-s;return `M ${e} ${t} C ${l} ${i}, ${c} ${n}, ${r} ${n}`}function Lp(e,t,r,n=40){if(e.length===0)return {x:0,y:0,zoom:1};let o=1/0,a=1/0,s=-1/0,l=-1/0;for(let m of e){let g=m.width??180,y=m.height??60;o=Math.min(o,m.x),a=Math.min(a,m.y),s=Math.max(s,m.x+g),l=Math.max(l,m.y+y);}let i=s-o+n*2,c=l-a+n*2,d=Math.min(t/i,r/c,1),u=(t-i*d)/2-(o-n)*d,f=(r-c*d)/2-(a-n)*d;return {x:u,y:f,zoom:d}}var Ww=180,Vw=60,zi=12,Sa=28,$c=24,Ow=-8;function Fw(e,t,r,n,o="horizontal"){let a=e.side??gs(e.kind,o),s=t.filter(d=>(d.side??gs(d.kind,o))===a),l=s.findIndex(d=>d.id===e.id),i=s.length,c=i===1?.5:(l+1)/(i+1);switch(a){case "left":return {left:0,top:n*c};case "right":return {left:r,top:n*c};case "top":return {left:r*c,top:0};case "bottom":return {left:r*c,top:n}}}function $w({port:e,allPorts:t,nodeId:r,nodeWidth:n,nodeHeight:o,disabled:a,direction:s,onMouseUp:l}){let i=Fw(e,t,n,o,s),c=a||e.disabled,d=Cl.useCallback(u=>{c||(u.stopPropagation(),l(r,e.id));},[c,r,e.id,l]);return jsxRuntime.jsx("div",{"data-testid":`port-${r}-${e.id}`,"data-port-id":e.id,"data-port-kind":e.kind,"data-node-id":r,className:"absolute",style:{left:i.left-Sa/2,top:i.top-Sa/2,width:Sa,height:Sa,zIndex:20},onMouseUp:d,title:e.label??e.id,children:jsxRuntime.jsx("div",{className:p("absolute rounded-full border-2 transition-colors",c?"bg-gray-300 border-gray-400 cursor-not-allowed":e.kind==="in"?"bg-blue-400 border-blue-600 hover:bg-blue-300 cursor-crosshair":"bg-green-400 border-green-600 hover:bg-green-300 cursor-crosshair"),style:{width:zi,height:zi,left:(Sa-zi)/2,top:(Sa-zi)/2}})})}function _w(e,t,r){let n=e??"top-right",o=Ow,a=t*($c+4);switch(n){case "top-right":return {top:o,right:o-a};case "top-left":return {top:o,left:o+a};case "bottom-right":return {bottom:o,right:o-a};case "bottom-left":return {bottom:o,left:o+a}}}function Xw({action:e,nodeId:t,index:r,nodeWidth:n,disabled:o,onActionClick:a}){let s=Cl.useCallback(c=>{c.stopPropagation(),c.preventDefault(),!o&&a(t,e.id,c.nativeEvent);},[o,t,e.id,a]),l=Cl.useCallback(c=>{c.stopPropagation();},[]),i=_w(e.position,r);return jsxRuntime.jsx("button",{"data-testid":`action-${t}-${e.id}`,"data-action-id":e.id,"data-node-id":t,type:"button",className:p("absolute flex items-center justify-center rounded-full border shadow-sm transition-all","bg-white border-gray-300 text-gray-600","hover:bg-gray-50 hover:border-gray-400 hover:text-gray-800 hover:shadow-md","active:scale-95",o&&"opacity-50 cursor-not-allowed",!o&&"cursor-pointer",e.className),style:{...i,width:$c,height:$c,zIndex:30},onClick:s,onMouseDown:l,title:e.label,disabled:o,children:jsxRuntime.jsx("span",{className:"flex items-center justify-center w-3.5 h-3.5 [&>svg]:w-full [&>svg]:h-full",children:e.icon})})}var Mp=Cl.memo(function({node:t,registry:r,ports:n,selected:o,disabled:a,draggable:s,direction:l,onPortMouseUp:i,onActionClick:c}){let d=t.width??Ww,u=t.height??Vw,f=r.render({node:t,selected:o,disabled:a}),g=(typeof r.actions=="function"?r.actions(t):r.actions)?.filter(b=>typeof b.hidden=="function"?!b.hidden(t):!b.hidden),y=new Map;if(g)for(let b of g){let h=b.position??"top-right",x=y.get(h)??[];x.push(b),y.set(h,x);}return jsxRuntime.jsxs("div",{"data-testid":`workflow-node-${t.id}`,"data-node-id":t.id,className:p("absolute select-none group/node",s&&!t.locked&&"cursor-grab active:cursor-grabbing",t.locked&&"cursor-not-allowed opacity-75",o&&"ring-2 ring-blue-500 ring-offset-1 rounded-lg"),style:{left:t.x,top:t.y,width:d,height:u,overflow:"visible"},children:[f,n.map(b=>jsxRuntime.jsx($w,{port:b,allPorts:n,nodeId:t.id,nodeWidth:d,nodeHeight:u,disabled:a,direction:l,onMouseUp:i},b.id)),c&&y.size>0&&Array.from(y.entries()).map(([,b])=>b.map((h,x)=>jsxRuntime.jsx(Xw,{action:h,nodeId:t.id,index:x,nodeWidth:d,disabled:a,onActionClick:c},h.id)))]})});function Ip(e,t,r,n,o="horizontal"){let a=r.find(i=>i.id===e);if(!a)return null;let s=n(a),l=s.find(i=>i.id===t);return l?Na(a,l,s,o):null}var Kw=Cl.memo(function({edge:t,fromPos:r,toPos:n,selected:o,disabled:a,direction:s,onClick:l}){let i=Ai(r.x,r.y,n.x,n.y,s),c=(r.x+n.x)/2,d=(r.y+n.y)/2,u=Cl.useCallback(f=>{f.stopPropagation(),l(t.id,f);},[t.id,l]);return jsxRuntime.jsxs("g",{"data-testid":`workflow-edge-${t.id}`,children:[jsxRuntime.jsx("path",{d:i,fill:"none",stroke:"transparent",strokeWidth:16,className:"cursor-pointer",onClick:u}),jsxRuntime.jsx("path",{d:i,fill:"none",className:p("transition-colors pointer-events-none",a||t.disabled?"stroke-gray-300":o?"stroke-blue-500":"stroke-gray-400"),strokeWidth:o?2.5:2,strokeDasharray:t.disabled?"6 3":void 0}),t.label&&jsxRuntime.jsx("text",{x:c,y:d-8,textAnchor:"middle",className:"fill-gray-600 dark:fill-gray-300 text-xs pointer-events-none select-none",fontSize:11,children:t.label})]})}),zp=Cl.memo(function({edges:t,nodes:r,selectedEdgeId:n,disabled:o,direction:a,onEdgeClick:s,getNodePorts:l}){return jsxRuntime.jsx("svg",{className:"absolute pointer-events-none",style:{top:0,left:0,width:1,height:1,overflow:"visible"},children:jsxRuntime.jsx("g",{className:"pointer-events-auto",children:t.map(i=>{let c=Ip(i.from.nodeId,i.from.portId,r,l,a),d=Ip(i.to.nodeId,i.to.portId,r,l,a);return !c||!d?null:jsxRuntime.jsx(Kw,{edge:i,fromPos:c,toPos:d,selected:i.id===n,disabled:o,direction:a,onClick:s},i.id)})})})});var qw=()=>jsxRuntime.jsx("svg",{className:"w-4 h-4",viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true",children:jsxRuntime.jsx("path",{fillRule:"evenodd",d:"M10 5a1 1 0 011 1v3h3a1 1 0 110 2h-3v3a1 1 0 11-2 0v-3H6a1 1 0 110-2h3V6a1 1 0 011-1z",clipRule:"evenodd"})}),Zw=()=>jsxRuntime.jsx("svg",{className:"w-4 h-4",viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true",children:jsxRuntime.jsx("path",{fillRule:"evenodd",d:"M5 10a1 1 0 011-1h8a1 1 0 110 2H6a1 1 0 01-1-1z",clipRule:"evenodd"})}),Qw=()=>jsxRuntime.jsx("svg",{className:"w-4 h-4",viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true",children:jsxRuntime.jsx("path",{fillRule:"evenodd",d:"M4 2a1 1 0 011 1v2.101a7.002 7.002 0 0111.601 2.566 1 1 0 11-1.885.666A5.002 5.002 0 005.999 7H9a1 1 0 010 2H4a1 1 0 01-1-1V3a1 1 0 011-1zm.008 9.057a1 1 0 011.276.61A5.002 5.002 0 0014.001 13H11a1 1 0 110-2h5a1 1 0 011 1v5a1 1 0 11-2 0v-2.101a7.002 7.002 0 01-11.601-2.566 1 1 0 01.61-1.276z",clipRule:"evenodd"})}),Jw=()=>jsxRuntime.jsx("svg",{className:"w-4 h-4",viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true",children:jsxRuntime.jsx("path",{d:"M3 4a1 1 0 011-1h4a1 1 0 010 2H6.414l2.293 2.293a1 1 0 01-1.414 1.414L5 6.414V8a1 1 0 01-2 0V4zm9 1a1 1 0 010-2h4a1 1 0 011 1v4a1 1 0 01-2 0V6.414l-2.293 2.293a1 1 0 11-1.414-1.414L13.586 5H12zm-9 7a1 1 0 012 0v1.586l2.293-2.293a1 1 0 011.414 1.414L6.414 15H8a1 1 0 010 2H4a1 1 0 01-1-1v-4zm13 0a1 1 0 01-2 0v-1.586l-2.293 2.293a1 1 0 01-1.414-1.414L13.586 9H12a1 1 0 010-2h4a1 1 0 011 1v4z"})}),e2=()=>jsxRuntime.jsx("svg",{className:"w-4 h-4",viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true",children:jsxRuntime.jsx("path",{fillRule:"evenodd",d:"M3 17a1 1 0 011-1h12a1 1 0 110 2H4a1 1 0 01-1-1zm3.293-7.707a1 1 0 011.414 0L9 10.586V3a1 1 0 112 0v7.586l1.293-1.293a1 1 0 111.414 1.414l-3 3a1 1 0 01-1.414 0l-3-3a1 1 0 010-1.414z",clipRule:"evenodd"})}),t2=()=>jsxRuntime.jsx("svg",{className:"w-4 h-4",viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true",children:jsxRuntime.jsx("path",{fillRule:"evenodd",d:"M3 17a1 1 0 011-1h12a1 1 0 110 2H4a1 1 0 01-1-1zM6.293 6.707a1 1 0 010-1.414l3-3a1 1 0 011.414 0l3 3a1 1 0 01-1.414 1.414L11 5.414V13a1 1 0 11-2 0V5.414L7.707 6.707a1 1 0 01-1.414 0z",clipRule:"evenodd"})}),r2=()=>jsxRuntime.jsx("svg",{className:"w-4 h-4",viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true",children:jsxRuntime.jsx("path",{fillRule:"evenodd",d:"M10.293 3.293a1 1 0 011.414 0l6 6a1 1 0 010 1.414l-6 6a1 1 0 01-1.414-1.414L14.586 11H3a1 1 0 110-2h11.586l-4.293-4.293a1 1 0 010-1.414z",clipRule:"evenodd"})}),n2=()=>jsxRuntime.jsx("svg",{className:"w-4 h-4",viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true",children:jsxRuntime.jsx("path",{fillRule:"evenodd",d:"M16.707 10.293a1 1 0 010 1.414l-6 6a1 1 0 01-1.414 0l-6-6a1 1 0 111.414-1.414L9 14.586V3a1 1 0 012 0v11.586l4.293-4.293a1 1 0 011.414 0z",clipRule:"evenodd"})}),Hp=Cl.memo(function({zoom:t,direction:r,onDirectionChange:n,onZoomIn:o,onZoomOut:a,onResetView:s,onFitToContent:l,onExportJSON:i,onImportJSON:c,disabled:d,className:u}){let[f,m]=Cl.useState(false),[g,y]=Cl.useState(false),[b,h]=Cl.useState(""),[x,L]=Cl.useState(""),C=Cl.useCallback(()=>{h(i()),m(true);},[i]),S=Cl.useCallback(()=>{x.trim()&&(c(x.trim()),L(""),y(false));},[x,c]),v=Cl.useCallback(()=>{L(""),y(false);},[]),R=Cl.useCallback(()=>{m(false);},[]),N=Math.round(t*100);return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsxs("div",{className:p("absolute top-3 left-3 z-20 flex items-center gap-2 bg-white dark:bg-gray-800 rounded-lg shadow-md border border-gray-200 dark:border-gray-600 px-2 py-1.5",u),"data-testid":"workflow-toolbar",children:[jsxRuntime.jsxs(ra,{size:"sm",children:[jsxRuntime.jsx($t,{content:"Zoom in",size:"sm",position:"bottom",children:jsxRuntime.jsx(Ft,{icon:jsxRuntime.jsx(qw,{}),size:"sm",bgColor:"bg-gray-100 hover:bg-gray-200 dark:bg-gray-700 dark:hover:bg-gray-600",textColor:"text-gray-700 dark:text-gray-200",onClick:o,disabled:d,"aria-label":"Zoom in"})}),jsxRuntime.jsx($t,{content:"Zoom out",size:"sm",position:"bottom",children:jsxRuntime.jsx(Ft,{icon:jsxRuntime.jsx(Zw,{}),size:"sm",bgColor:"bg-gray-100 hover:bg-gray-200 dark:bg-gray-700 dark:hover:bg-gray-600",textColor:"text-gray-700 dark:text-gray-200",onClick:a,disabled:d,"aria-label":"Zoom out"})})]}),jsxRuntime.jsxs("span",{className:"text-xs font-mono text-gray-500 dark:text-gray-400 min-w-[3ch] text-center select-none",children:[N,"%"]}),jsxRuntime.jsx("div",{className:"w-px h-5 bg-gray-200 dark:bg-gray-600"}),jsxRuntime.jsx($t,{content:"Reset view",size:"sm",position:"bottom",children:jsxRuntime.jsx(Ft,{icon:jsxRuntime.jsx(Qw,{}),size:"sm",bgColor:"bg-gray-100 hover:bg-gray-200 dark:bg-gray-700 dark:hover:bg-gray-600",textColor:"text-gray-700 dark:text-gray-200",onClick:s,disabled:d,"aria-label":"Reset view"})}),jsxRuntime.jsx($t,{content:"Fit to content",size:"sm",position:"bottom",children:jsxRuntime.jsx(Ft,{icon:jsxRuntime.jsx(Jw,{}),size:"sm",bgColor:"bg-gray-100 hover:bg-gray-200 dark:bg-gray-700 dark:hover:bg-gray-600",textColor:"text-gray-700 dark:text-gray-200",onClick:l,disabled:d,"aria-label":"Fit to content"})}),n&&jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("div",{className:"w-px h-5 bg-gray-200 dark:bg-gray-600"}),jsxRuntime.jsx($t,{content:r==="horizontal"?"Switch to vertical":"Switch to horizontal",size:"sm",position:"bottom",children:jsxRuntime.jsx(Ft,{icon:r==="horizontal"?jsxRuntime.jsx(r2,{}):jsxRuntime.jsx(n2,{}),size:"sm",bgColor:"bg-gray-100 hover:bg-gray-200 dark:bg-gray-700 dark:hover:bg-gray-600",textColor:"text-gray-700 dark:text-gray-200",onClick:()=>n(r==="horizontal"?"vertical":"horizontal"),disabled:d,"aria-label":r==="horizontal"?"Switch to vertical":"Switch to horizontal"})})]}),jsxRuntime.jsx("div",{className:"w-px h-5 bg-gray-200 dark:bg-gray-600"}),jsxRuntime.jsx($t,{content:"Export JSON",size:"sm",position:"bottom",children:jsxRuntime.jsx(Ft,{icon:jsxRuntime.jsx(e2,{}),size:"sm",bgColor:"bg-gray-100 hover:bg-gray-200 dark:bg-gray-700 dark:hover:bg-gray-600",textColor:"text-gray-700 dark:text-gray-200",onClick:C,disabled:d,"aria-label":"Export JSON"})}),jsxRuntime.jsx($t,{content:"Import JSON",size:"sm",position:"bottom",children:jsxRuntime.jsx(Ft,{icon:jsxRuntime.jsx(t2,{}),size:"sm",bgColor:"bg-gray-100 hover:bg-gray-200 dark:bg-gray-700 dark:hover:bg-gray-600",textColor:"text-gray-700 dark:text-gray-200",onClick:()=>y(true),disabled:d,"aria-label":"Import JSON"})})]}),jsxRuntime.jsx(An,{isOpen:f,onClose:R,title:"Export Workflow",description:"Copy the JSON below to save your workflow.",size:"lg",showSubmit:false,showCancel:true,cancelLabel:"Close",children:jsxRuntime.jsx(dn,{label:"Workflow JSON",multiline:true,rows:12,value:b,readOnly:true,size:"sm"})}),jsxRuntime.jsx(An,{isOpen:g,onClose:v,title:"Import Workflow",description:"Paste workflow JSON to load it into the editor.",size:"lg",showSubmit:true,submitLabel:"Import",onSubmitClick:S,showCancel:true,cancelLabel:"Cancel",children:jsxRuntime.jsx(dn,{label:"Workflow JSON",multiline:true,rows:12,value:x,onChange:M=>L(M.target.value),placeholder:'{"nodes": [], "edges": []}',size:"sm"})})]})});var _c={x:0,y:0,zoom:1},Xc=.1,s2=.1,i2=3,l2=20;function Op(){return `edge-${Date.now()}-${Math.random().toString(36).slice(2,8)}`}function c2({value:e,defaultValue:t,onValueChange:r,nodeRegistry:n,direction:o="horizontal",onDirectionChange:a,onNodeClick:s,onNodeDoubleClick:l,onNodeContextMenu:i,onNodeAction:c,readOnly:d=false,disabled:u=false,draggableNodes:f=true,connectable:m=true,selectable:g=true,multiSelect:y=false,panOnDrag:b=true,zoomOnWheel:h=true,minZoom:x=s2,maxZoom:L=i2,snapToGrid:C=false,gridSize:S=l2,showGrid:v=true,toolbar:R=true,autoFit:N=false,className:M},P){let E=e!==void 0,[W,T]=Cl.useState(()=>t??{nodes:[],edges:[],viewport:{..._c}}),O=E?e:W,H=O.nodes,k=O.edges,z=O.viewport??_c,A=Cl.useRef(null),I=Cl.useRef(null),[X,$]=Cl.useState(new Set),[K,D]=Cl.useState(null),[B,w]=Cl.useState(null),G=Cl.useRef(z);G.current=z;let q=Cl.useRef(H);q.current=H;let j=Cl.useRef(k);j.current=k;let U=Cl.useRef(C);U.current=C;let F=Cl.useRef(S);F.current=S;let _=Cl.useRef(n);_.current=n;let J=Cl.useRef(o);J.current=o;let ne=Cl.useCallback(se=>{E?r?.(se(e)):T(de=>{let ke=se(de);return r?.(ke),ke});},[E,e,r]),Y=Cl.useRef(ne);Y.current=ne;let ee=Cl.useCallback(se=>{ne(de=>({...de,viewport:se}));},[ne]),Z=Cl.useRef(ee);Z.current=ee;let ie=Cl.useCallback(se=>{let de=n[se.type];return de?.getPorts?de.getPorts(se):se.ports??[]},[n]),V=Cl.useRef(ie);V.current=ie;let oe=Cl.useCallback((se,de,ke)=>{let ve=q.current,Be=j.current,Pe=ve.find(ct=>ct.id===se.fromNodeId),ye=ve.find(ct=>ct.id===de);if(!Pe||!ye)return;let Xe=V.current(Pe),We=V.current(ye),ut=Xe.find(ct=>ct.id===se.fromPortId),ot=We.find(ct=>ct.id===ke);if(!ut||!ot||ot.kind!=="in"||se.fromNodeId===de)return;let Ke=_.current[Pe.type];if(Ke?.canConnect&&!Ke.canConnect({fromNode:Pe,toNode:ye,fromPort:ut,toPort:ot}))return;Be.some(ct=>ct.from.nodeId===se.fromNodeId&&ct.from.portId===se.fromPortId&&ct.to.nodeId===de&&ct.to.portId===ke)||Y.current(ct=>({...ct,edges:[...ct.edges,{id:Op(),from:{nodeId:se.fromNodeId,portId:se.fromPortId},to:{nodeId:de,portId:ke}}]}));},[]);Cl.useEffect(()=>{function se(ke){let ve=I.current;if(!ve)return;let Be=A.current?.getBoundingClientRect();if(!Be)return;let Pe=G.current;if(ve.type==="pan"){let ye=ke.clientX-ve.startX,Xe=ke.clientY-ve.startY;Z.current({...Pe,x:ve.startViewportX+ye,y:ve.startViewportY+Xe});}if(ve.type==="node"){let ye=wa(ke.clientX,ke.clientY,Pe,Be),Xe=ye.x-ve.offsetX,We=ye.y-ve.offsetY;U.current&&(Xe=Oc(Xe,F.current),We=Oc(We,F.current)),Y.current(ut=>({...ut,nodes:ut.nodes.map(ot=>ot.id===ve.nodeId?{...ot,x:Xe,y:We}:ot)}));}if(ve.type==="edge"){let ye=wa(ke.clientX,ke.clientY,Pe,Be);I.current={...ve,currentX:ye.x,currentY:ye.y},w({fromX:ve.fromX,fromY:ve.fromY,currentX:ye.x,currentY:ye.y});}}function de(ke){let ve=I.current;if(ve){if(ve.type==="edge"){let Be=A.current?.getBoundingClientRect();if(Be){let Pe=G.current,ye=wa(ke.clientX,ke.clientY,Pe,Be),Xe=25,We=q.current,ut=1/0,ot=null,Ke=null;for(let mt of We){let ct=V.current(mt);for(let xr of ct){if(xr.kind!=="in")continue;let Pt=Na(mt,xr,ct,J.current),jr=Math.sqrt((ye.x-Pt.x)**2+(ye.y-Pt.y)**2);jr<Xe&&jr<ut&&(ut=jr,ot=mt.id,Ke=xr.id);}}ot&&Ke&&oe(ve,ot,Ke);}w(null);}I.current=null;}}return document.addEventListener("mousemove",se),document.addEventListener("mouseup",de),()=>{document.removeEventListener("mousemove",se),document.removeEventListener("mouseup",de);}},[oe]);let pe=Cl.useCallback(se=>{if(!h||u)return;se.preventDefault();let de=A.current?.getBoundingClientRect();if(!de)return;let ke=se.clientX-de.left,ve=se.clientY-de.top,Be=se.deltaY<0?1:-1,Pe=fs(z.zoom+Be*Xc,x,L),ye=Pe/z.zoom;ee({x:ke-(ke-z.x)*ye,y:ve-(ve-z.y)*ye,zoom:Pe});},[h,u,z,x,L,ee]),Te=Cl.useCallback(se=>{if(u)return;let de=se.target;if(de.closest("[data-action-id]"))return;let ve=de.closest("[data-port-id]");if(ve){if(!m||d)return;se.preventDefault();let Pe=ve.getAttribute("data-node-id"),ye=ve.getAttribute("data-port-id"),Xe=ve.getAttribute("data-port-kind");if(!Pe||!ye||Xe!=="out")return;let We=H.find(mt=>mt.id===Pe);if(!We)return;let ut=ie(We),ot=ut.find(mt=>mt.id===ye);if(!ot)return;let Ke=Na(We,ot,ut,J.current);I.current={type:"edge",fromNodeId:Pe,fromPortId:ye,fromX:Ke.x,fromY:Ke.y,currentX:Ke.x,currentY:Ke.y},w({fromX:Ke.x,fromY:Ke.y,currentX:Ke.x,currentY:Ke.y});return}let Be=de.closest("[data-node-id]");if(Be){if(d)return;let Pe=Be.getAttribute("data-node-id");if(g&&(D(null),y&&se.shiftKey?$(ye=>{let Xe=new Set(ye);return Xe.has(Pe)?Xe.delete(Pe):Xe.add(Pe),Xe}):$(new Set([Pe]))),f){let ye=A.current?.getBoundingClientRect();if(!ye)return;let Xe=H.find(ut=>ut.id===Pe);if(!Xe||Xe.locked)return;let We=wa(se.clientX,se.clientY,z,ye);I.current={type:"node",nodeId:Pe,startX:We.x,startY:We.y,offsetX:We.x-Xe.x,offsetY:We.y-Xe.y};}return}g&&($(new Set),D(null)),b&&se.button===0&&(I.current={type:"pan",startX:se.clientX,startY:se.clientY,startViewportX:z.x,startViewportY:z.y});},[u,m,d,g,y,f,b,z,H,ie]),ze=Cl.useCallback(se=>{let de=I.current;if(!de||de.type!=="edge")return;let ke=A.current?.getBoundingClientRect();if(ke){let ve=wa(se.clientX,se.clientY,z,ke),Be=30,Pe=1/0,ye=null,Xe=null;for(let We of H){let ut=ie(We);for(let ot of ut){if(ot.kind!=="in")continue;let Ke=Na(We,ot,ut,J.current),mt=Math.sqrt((ve.x-Ke.x)**2+(ve.y-Ke.y)**2);mt<Be&&mt<Pe&&(Pe=mt,ye=We.id,Xe=ot.id);}}if(ye&&Xe){let We=de.fromNodeId,ut=de.fromPortId;We!==ye&&(k.some(Ke=>Ke.from.nodeId===We&&Ke.from.portId===ut&&Ke.to.nodeId===ye&&Ke.to.portId===Xe)||ne(Ke=>({...Ke,edges:[...Ke.edges,{id:Op(),from:{nodeId:We,portId:ut},to:{nodeId:ye,portId:Xe}}]})));}}I.current=null,w(null);},[z,H,k,ie,ne]),ae=Cl.useCallback((se,de)=>{let ke=I.current;!ke||ke.type!=="edge"||(oe(ke,se,de),I.current=null,w(null));},[oe]),re=Cl.useCallback(se=>{let de=se.target;if(de.closest("[data-port-id]")||de.closest("[data-action-id]"))return null;let Be=de.closest("[data-node-id]");if(!Be)return null;let Pe=Be.getAttribute("data-node-id");return H.find(ye=>ye.id===Pe)??null},[H]),ce=Cl.useCallback(se=>{if(!s||u)return;let de=re(se);de&&s({node:de,nativeEvent:se.nativeEvent});},[s,u,re]),De=Cl.useCallback(se=>{if(!l||u)return;let de=re(se);de&&l({node:de,nativeEvent:se.nativeEvent});},[l,u,re]),Ge=Cl.useCallback(se=>{if(!i||u)return;let de=re(se);de&&(se.preventDefault(),i({node:de,nativeEvent:se.nativeEvent}));},[i,u,re]),be=Cl.useCallback((se,de,ke)=>{if(!c||u)return;let ve=H.find(Be=>Be.id===se);ve&&c({node:ve,actionId:de,nativeEvent:ke});},[c,u,H]),Me=Cl.useCallback((se,de)=>{!g||u||(de.stopPropagation(),$(new Set),D(se));},[g,u]),Re=Cl.useCallback(se=>{d||u||((se.key==="Delete"||se.key==="Backspace")&&(X.size>0&&(ne(de=>({...de,nodes:de.nodes.filter(ke=>!X.has(ke.id)),edges:de.edges.filter(ke=>!X.has(ke.from.nodeId)&&!X.has(ke.to.nodeId))})),$(new Set)),K&&(ne(de=>({...de,edges:de.edges.filter(ke=>ke.id!==K)})),D(null))),se.key==="Escape"&&($(new Set),D(null)));},[d,u,X,K,ne]),He=Cl.useCallback(()=>{let se=fs(z.zoom+Xc,x,L);ee({...z,zoom:se});},[z,x,L,ee]),Ee=Cl.useCallback(()=>{let se=fs(z.zoom-Xc,x,L);ee({...z,zoom:se});},[z,x,L,ee]),$e=Cl.useCallback(()=>{ee({..._c});},[ee]),bt=Cl.useCallback(()=>{let se=A.current?.getBoundingClientRect();if(!se)return;let de=Lp(H,se.width,se.height),ke=fs(de.zoom,x,L);ee({...de,zoom:ke});},[H,x,L,ee]),Kt=Cl.useCallback(se=>{ne(de=>({...de,nodes:[...de.nodes,se]}));},[ne]),dr=Cl.useCallback(se=>{ne(de=>({...de,nodes:de.nodes.filter(ke=>ke.id!==se),edges:de.edges.filter(ke=>ke.from.nodeId!==se&&ke.to.nodeId!==se)}));},[ne]),_t=Cl.useCallback(()=>JSON.stringify(O,null,2),[O]),Xt=Cl.useCallback(se=>{try{let de=JSON.parse(se);de&&Array.isArray(de.nodes)&&Array.isArray(de.edges)&&ne(()=>de);}catch{}},[ne]);Cl.useImperativeHandle(P,()=>({zoomIn:He,zoomOut:Ee,resetView:$e,fitToContent:bt,addNode:Kt,removeNode:dr,toJSON:_t,loadJSON:Xt}),[He,Ee,$e,bt,Kt,dr,_t,Xt]);let Mr=Cl.useRef(false);Cl.useEffect(()=>{N&&!Mr.current&&A.current&&(Mr.current=true,bt());},[N,bt]);let Ce=Cl.useMemo(()=>{let se=new Map;for(let de of H)se.set(de.id,ie(de));return se},[H,ie]),we=Cl.useMemo(()=>({transform:`translate(${z.x}px, ${z.y}px) scale(${z.zoom})`,transformOrigin:"0 0"}),[z.x,z.y,z.zoom]);return jsxRuntime.jsxs("div",{ref:A,"data-testid":"workflow-editor",className:p("relative w-full overflow-hidden bg-gray-50 dark:bg-gray-900 select-none",u&&"opacity-60 pointer-events-none",M),tabIndex:0,onWheel:pe,onMouseDown:Te,onMouseUp:ze,onClick:ce,onDoubleClick:De,onContextMenu:Ge,onKeyDown:Re,children:[v&&jsxRuntime.jsx(Ep,{gridSize:S,zoom:z.zoom}),R&&!d&&jsxRuntime.jsx(Hp,{zoom:z.zoom,direction:o,onDirectionChange:a,onZoomIn:He,onZoomOut:Ee,onResetView:$e,onFitToContent:bt,onExportJSON:_t,onImportJSON:Xt,disabled:u}),jsxRuntime.jsxs("div",{style:we,children:[jsxRuntime.jsx(zp,{edges:k,nodes:H,selectedEdgeId:K,disabled:u||d,direction:o,onEdgeClick:Me,getNodePorts:se=>Ce.get(se.id)??[]}),H.map(se=>{let de=n[se.type];if(!de)return null;let ke=Ce.get(se.id)??[];return jsxRuntime.jsx(Mp,{node:se,registry:de,ports:ke,selected:X.has(se.id),disabled:u||d,draggable:f&&!d,direction:o,onPortMouseUp:ae,onActionClick:c?be:void 0},se.id)})]}),B&&jsxRuntime.jsxs("svg",{"data-testid":"drag-edge-overlay",style:{position:"absolute",top:0,left:0,width:"100%",height:"100%",pointerEvents:"none",zIndex:1e3,overflow:"visible"},children:[jsxRuntime.jsx("path",{d:Ai(B.fromX*z.zoom+z.x,B.fromY*z.zoom+z.y,B.currentX*z.zoom+z.x,B.currentY*z.zoom+z.y,o),fill:"none",stroke:"#3b82f6",strokeWidth:2.5,strokeDasharray:"8 4"}),jsxRuntime.jsx("circle",{cx:B.fromX*z.zoom+z.x,cy:B.fromY*z.zoom+z.y,r:5,fill:"#3b82f6"}),jsxRuntime.jsx("circle",{cx:B.currentX*z.zoom+z.x,cy:B.currentY*z.zoom+z.y,r:4,fill:"#3b82f6",opacity:.6})]})]})}var Fp=Cl.forwardRef(c2);Fp.displayName="WorkflowEditor";var Gp=Cl.createContext(null);function eo(){let e=Cl.useContext(Gp);if(!e)throw new Error("useWizard and Wizard sub-components must be used within <Wizard>");return e}var Uc=(e,t,r)=>Math.max(t,Math.min(e,r)),Kc={sm:{circle:"h-7 w-7 text-xs",dot:"h-2.5 w-2.5",icon:"h-3.5 w-3.5",title:"text-xs",desc:"text-[11px]",connector:"h-0.5"},md:{circle:"h-9 w-9 text-sm",dot:"h-3 w-3",icon:"h-4 w-4",title:"text-sm",desc:"text-xs",connector:"h-0.5"},lg:{circle:"h-11 w-11 text-base",dot:"h-3.5 w-3.5",icon:"h-5 w-5",title:"text-base",desc:"text-sm",connector:"h-1"}},fn={primary:{solid:"bg-blue-600 text-white",bg:"bg-blue-600",text:"text-blue-600 dark:text-blue-400",ring:"focus-visible:ring-blue-500",ringSoft:"ring-blue-500/20"},secondary:{solid:"bg-gray-700 text-white",bg:"bg-gray-700",text:"text-gray-700 dark:text-gray-300",ring:"focus-visible:ring-gray-500",ringSoft:"ring-gray-500/20"},success:{solid:"bg-green-600 text-white",bg:"bg-green-600",text:"text-green-600 dark:text-green-400",ring:"focus-visible:ring-green-500",ringSoft:"ring-green-500/20"},warning:{solid:"bg-amber-500 text-white",bg:"bg-amber-500",text:"text-amber-600 dark:text-amber-400",ring:"focus-visible:ring-amber-500",ringSoft:"ring-amber-500/20"},error:{solid:"bg-red-600 text-white",bg:"bg-red-600",text:"text-red-600 dark:text-red-400",ring:"focus-visible:ring-red-500",ringSoft:"ring-red-500/20"}};function m2({className:e}){return jsxRuntime.jsx("svg",{className:e,viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true",children:jsxRuntime.jsx("path",{fillRule:"evenodd",d:"M16.707 5.293a1 1 0 010 1.414l-8 8a1 1 0 01-1.414 0l-4-4a1 1 0 011.414-1.414L8 12.586l7.293-7.293a1 1 0 011.414 0z",clipRule:"evenodd"})})}function Up({steps:e,step:t,defaultStep:r=0,onStepChange:n,onComplete:o,orientation:a="horizontal",variant:s="default",size:l="md",color:i="primary",linear:c=true,className:d,children:u}){let f=e.length,m=Math.max(0,f-1),g=t!==void 0,[y,b]=Cl.useState(()=>Uc(r,0,m)),h=Uc(g?t:y,0,m),[x,L]=Cl.useState(h);x<h&&L(h);let C=h<=0,S=h>=m,v=Cl.useCallback((T,O)=>{let H=Uc(T,0,m);H!==h&&(g||b(H),L(k=>Math.max(k,H)),n?.(H,{previous:h,direction:O}));},[h,g,m,n]),R=Cl.useCallback(T=>{let O=e[T];return !O||O.disabled?false:c?T<=x:true},[e,c,x]),N=Cl.useCallback(T=>{R(T)&&v(T,T>h?"jump":"backward");},[R,v,h]),M=Cl.useCallback(()=>{if(S){o?.();return}v(h+1,"forward");},[S,o,v,h]),P=Cl.useCallback(()=>{C||v(h-1,"backward");},[C,v,h]),E=Cl.useCallback(T=>e[T]?.error?"error":T===h?"active":T<h?"completed":"upcoming",[e,h]),W={steps:e,activeStep:h,totalSteps:f,isFirstStep:C,isLastStep:S,orientation:a,variant:s,size:l,color:i,linear:c,goToStep:N,goNext:M,goBack:P,getStepStatus:E,isStepAccessible:R};return jsxRuntime.jsx(Gp.Provider,{value:W,children:jsxRuntime.jsx("div",{className:p("flex w-full flex-col gap-6",d),"data-testid":"wizard","data-orientation":a,children:u})})}function _p({index:e,status:t}){let{variant:r,size:n,color:o,steps:a}=eo(),s=Kc[n],l=a[e];if(r==="dots"){let d=t==="upcoming"?"bg-gray-300 dark:bg-gray-600":t==="error"?"bg-red-600":fn[o].bg;return jsxRuntime.jsx("span",{className:p("shrink-0 rounded-full transition-colors",s.dot,d),"aria-hidden":"true"})}let i=t==="completed"?p(fn[o].solid,"border-transparent"):t==="active"?p(fn[o].solid,"border-transparent ring-4",fn[o].ringSoft):t==="error"?"border-transparent bg-red-600 text-white":"border-2 border-gray-300 bg-white text-gray-500 dark:border-gray-600 dark:bg-gray-800 dark:text-gray-400",c=t==="completed"?jsxRuntime.jsx(m2,{className:s.icon}):t==="error"?jsxRuntime.jsx("span",{className:"font-semibold leading-none",children:"!"}):l.icon??jsxRuntime.jsx("span",{className:"font-medium leading-none",children:e+1});return jsxRuntime.jsx("span",{className:p("flex shrink-0 items-center justify-center rounded-full transition-all",s.circle,i),"aria-hidden":"true",children:c})}function Xp({index:e,status:t}){let{steps:r,size:n,color:o,variant:a}=eo(),s=Kc[n],l=r[e],c=t==="active"?fn[o].text:t==="completed"?"text-gray-900 dark:text-gray-100":t==="error"?"text-red-600 dark:text-red-400":"text-gray-500 dark:text-gray-400";return jsxRuntime.jsxs("span",{className:"flex min-w-0 flex-col",children:[jsxRuntime.jsxs("span",{className:p("font-medium leading-tight",s.title,c),children:[a==="simple"&&jsxRuntime.jsxs("span",{className:"mr-1 tabular-nums",children:[e+1,"."]}),l.title,l.optional&&jsxRuntime.jsx("span",{className:"ml-1 text-xs font-normal text-gray-400 dark:text-gray-500",children:"(optional)"})]}),l.description&&jsxRuntime.jsx("span",{className:p("mt-0.5 text-gray-400 dark:text-gray-500",s.desc),children:l.description})]})}function Kp({className:e,hideConnector:t=false,hideLabels:r=false}){let n=eo(),{steps:o,orientation:a,size:s,variant:l,color:i,activeStep:c}=n,d=Kc[s],u=a==="vertical",f=l!=="simple";return jsxRuntime.jsx("ol",{className:p("flex w-full",u?"flex-col":"items-start",e),"data-testid":"wizard-steps","data-orientation":a,children:o.map((m,g)=>{let y=n.getStepStatus(g),b=g===c,h=n.isStepAccessible(g)&&!b,x=g===o.length-1,C=g<c?fn[i].bg:"bg-gray-200 dark:bg-gray-700";return u?jsxRuntime.jsx("li",{className:"flex","aria-current":b?"step":void 0,"data-status":y,"data-testid":"wizard-step",children:jsxRuntime.jsxs("button",{type:"button",disabled:!h,onClick:()=>n.goToStep(g),className:p("flex items-stretch gap-3 rounded-md text-left focus:outline-none focus-visible:ring-2 focus-visible:ring-offset-2",fn[i].ring,h?"cursor-pointer":"cursor-default"),children:[jsxRuntime.jsxs("span",{className:"flex flex-col items-center",children:[f&&jsxRuntime.jsx(_p,{index:g,status:y}),!t&&!x&&jsxRuntime.jsx("span",{className:p("my-1 w-0.5 flex-1 rounded",C),"aria-hidden":"true"})]}),!r&&jsxRuntime.jsx("span",{className:p(x?"pb-0":"pb-6"),children:jsxRuntime.jsx(Xp,{index:g,status:y})})]})},m.id??g):jsxRuntime.jsxs("li",{className:p("flex items-center",!x&&"flex-1"),"aria-current":b?"step":void 0,"data-status":y,"data-testid":"wizard-step",children:[jsxRuntime.jsxs("button",{type:"button",disabled:!h,onClick:()=>n.goToStep(g),className:p("flex items-center gap-2.5 rounded-md focus:outline-none focus-visible:ring-2 focus-visible:ring-offset-2",fn[i].ring,h?"cursor-pointer":"cursor-default"),children:[f&&jsxRuntime.jsx(_p,{index:g,status:y}),!r&&jsxRuntime.jsx(Xp,{index:g,status:y})]}),!t&&!x&&jsxRuntime.jsx("span",{className:p("mx-2 flex-1 rounded",d.connector,C),"aria-hidden":"true"})]},m.id??g)})})}function Yp({index:e,keepMounted:t=false,className:r,children:n}){let{activeStep:o}=eo(),a=e===o;return !a&&!t?null:jsxRuntime.jsx("div",{role:"tabpanel",hidden:!a,"data-testid":"wizard-panel","data-active":a,"data-step":e,className:p("w-full",r),children:n})}function jp({className:e,children:t}){let r=eo();return jsxRuntime.jsx("div",{className:p("w-full",e),"data-testid":"wizard-content",children:typeof t=="function"?t(r):t})}var qp="inline-flex cursor-pointer items-center justify-center gap-2 rounded-lg px-4 py-2 text-sm font-medium transition-colors focus:outline-none focus-visible:ring-2 focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50";function Yc({children:e,label:t="Previous",className:r,onClick:n,disabled:o,...a}){let{goBack:s,isFirstStep:l}=eo();return jsxRuntime.jsx("button",{type:"button",onClick:c=>{n?.(c),c.defaultPrevented||s();},disabled:o??l,"data-testid":"wizard-previous",className:p(qp,"border border-gray-300 bg-white text-gray-700 hover:bg-gray-50 focus-visible:ring-gray-400 dark:border-gray-600 dark:bg-gray-800 dark:text-gray-200 dark:hover:bg-gray-700",r),...a,children:e??t})}function jc({children:e,label:t="Next",finishLabel:r="Finish",className:n,onClick:o,...a}){let{goNext:s,isLastStep:l,color:i}=eo();return jsxRuntime.jsx("button",{type:"button",onClick:d=>{o?.(d),d.defaultPrevented||s();},"data-testid":"wizard-next",className:p(qp,fn[i].solid,fn[i].ring,"hover:opacity-90",n),...a,children:e??(l?r:t)})}function Zp({className:e,children:t,align:r="between"}){let n={between:"justify-between",start:"justify-start",center:"justify-center",end:"justify-end"}[r];return jsxRuntime.jsx("div",{className:p("flex items-center gap-3",n,e),"data-testid":"wizard-actions",children:t??jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(Yc,{}),jsxRuntime.jsx(jc,{})]})})}Up.displayName="Wizard";Kp.displayName="WizardSteps";Yp.displayName="WizardPanel";jp.displayName="WizardContent";Zp.displayName="WizardActions";Yc.displayName="WizardPrevious";jc.displayName="WizardNext";exports.Accordion=xg;exports.AccordionContent=kg;exports.AccordionItem=vg;exports.AccordionTrigger=Cg;exports.AdvanceDetachable=ld;exports.AreaChart=Gf;exports.Avatar=jf;exports.Badge=Vd;exports.Banner=Xd;exports.BarChart=p0;exports.BoxPlot=Rh;exports.Breadcrumb=S0;exports.BulletChart=z0;exports.Button=Ft;exports.ButtonGroup=ra;exports.CHART_ALL_PAIRS_LIMIT=po;exports.CHART_DIVERGING_COLORS=mo;exports.CHART_DIVERGING_DARK_STOPS=Td;exports.CHART_DIVERGING_NEUTRAL_INDEX=Rd;exports.CHART_DOWN_COLOR=nl;exports.CHART_MAX_COLOR_CLASSES=Ds;exports.CHART_MUTED_COLOR=Ar;exports.CHART_ORDINAL_COLORS=Ia;exports.CHART_ORDINAL_DARK_STOPS=ol;exports.CHART_PALETTE_SIZE=Df;exports.CHART_PATTERNS=Zi;exports.CHART_POINT_BUDGET=zf;exports.CHART_SEQUENTIAL_COLORS=tl;exports.CHART_SEQUENTIAL_DARK_STOPS=Pd;exports.CHART_SERIES_COLORS=Ts;exports.CHART_SURFACE_COLOR=io;exports.CHART_UP_COLOR=rl;exports.Calendar=Nl;exports.CandlestickChart=Ah;exports.Card=Zd;exports.CardBody=eu;exports.CardDescription=ou;exports.CardFooter=tu;exports.CardHeader=Jd;exports.CardImage=ru;exports.CardTitle=nu;exports.ChartAnnotationLayer=rn;exports.ChartAxis=tt;exports.ChartBrushLayer=ao;exports.ChartContainer=xt;exports.ChartExportButton=fb;exports.ChartFacets=yb;exports.ChartFilterBar=Cb;exports.ChartGrid=Yt;exports.ChartLegend=jt;exports.ChartPatternDefs=co;exports.ChartPeriodPicker=Tb;exports.ChartScaleLegend=Oa;exports.ChartSyncProvider=Cf;exports.ChartTableView=Ot;exports.ChartTooltip=vt;exports.ChartTooltipContent=Tr;exports.Checkbox=Ka;exports.CheckboxGroup=Ru;exports.CheckboxGroupItem=Pu;exports.Chip=li;exports.CircularProgress=Wo;exports.DEFAULT_CHART_PERIOD_PRESETS=Ji;exports.DEFAULT_CHART_WIDTH=gd;exports.DEFAULT_FIELD_TYPES=ps;exports.DataGrid=Oy;exports.Detachable=Lu;exports.DeviceMockup=xx;exports.Divider=Iu;exports.Drawer=Xu;exports.Dropdown=$s;exports.DropdownCheckboxItem=em;exports.DropdownContent=Us;exports.DropdownItem=Ks;exports.DropdownLabel=qu;exports.DropdownRadioGroup=om;exports.DropdownRadioItem=am;exports.DropdownSeparator=ju;exports.DropdownSubMenu=um;exports.DropdownSubMenuContent=pm;exports.DropdownSubMenuTrigger=mm;exports.DropdownTrigger=js;exports.DumbbellChart=Hb;exports.FOCUSABLE_SELECTOR=Wu;exports.FileSelector=Fx;exports.Footer=ep;exports.FooterBottom=op;exports.FooterColumn=rp;exports.FooterLink=np;exports.FooterSection=tp;exports.FooterSocial=ap;exports.FooterSocialLink=sp;exports.FunnelChart=Ub;exports.GanttChart=ey;exports.Header=Cv;exports.Heatmap=iC;exports.HelpButton=ym;exports.INERT_IGNORE_ATTRIBUTE=du;exports.ImageUploader=_v;exports.Indicator=vm;exports.Input=dn;exports.Label=Nm;exports.LineChart=fC;exports.MentionInput=ac;exports.Modal=An;exports.NumberInput=sc;exports.Pagination=EC;exports.PieChart=OC;exports.ProgressBar=Mm;exports.RadioButton=Im;exports.ScatterChart=$k;exports.SchemaEditor=Tp;exports.Select=d1;exports.Sidebar=b1;exports.SidebarContent=x1;exports.SidebarFooter=v1;exports.SidebarGroup=C1;exports.SidebarHeader=y1;exports.SidebarItem=k1;exports.SidebarSubMenu=w1;exports.SidebarToggle=N1;exports.Skeleton=Vm;exports.Slider=Fm;exports.Sparkline=xc;exports.StatCard=M1;exports.StatCardGroup=A1;exports.Table=yn;exports.TableBody=xn;exports.TableCell=qt;exports.TableHeader=vn;exports.TableHeaderCell=It;exports.TableRow=Cn;exports.Tabs=_m;exports.TabsContent=Ym;exports.TabsList=Xm;exports.TabsTrigger=Km;exports.Toast=Zm;exports.Tooltip=$t;exports.UILabelsProvider=$g;exports.WaterfallChart=dy;exports.WithHelpButton=Bv;exports.Wizard=Up;exports.WizardActions=Zp;exports.WizardContent=jp;exports.WizardNext=jc;exports.WizardPanel=Yp;exports.WizardPrevious=Yc;exports.WizardSteps=Kp;exports.WorkflowEditor=Fp;exports.autoLayoutTables=Bc;exports.binEdges=Fd;exports.binValues=gl;exports.boxStats=Sl;exports.brushToPeriod=kf;exports.buildCartesianGeometry=Jt;exports.cn=p;exports.createCategoryLocator=On;exports.createDefaultField=Dc;exports.createDefaultTable=Ec;exports.createDivergingScale=Go;exports.createPeriod=Ma;exports.createPlotContext=kn;exports.createSequentialScale=za;exports.decimateIndices=Ls;exports.decimatePath=dl;exports.defaultUILabels=dd;exports.describeAnnotations=no;exports.downloadChartData=zl;exports.endOfDay=_o;exports.findOwnedLayers=Gs;exports.formatPeriodRange=el;exports.formatTimeTick=ei;exports.frenchUILabels=Fg;exports.generateFieldId=ms;exports.generateRelationId=Tc;exports.generateSQL=Mi;exports.generateTableId=gp;exports.getFocusableElements=di;exports.getOrdinalColor=Lf;exports.getPattern=Ps;exports.getSeriesColor=zr;exports.getSeriesLabel=Vt;exports.hideOthers=Ml;exports.isElementVisible=Vu;exports.isFocusable=Ou;exports.lttb=Id;exports.niceTimeTicks=Fl;exports.patternBackground=Qi;exports.patternFill=lo;exports.patternId=Rs;exports.quantile=xh;exports.quantileSorted=Fa;exports.rampColor=Xo;exports.registerFloatingLayer=Pn;exports.resetBarChartWarnings=c0;exports.resetDumbbellWarnings=Ab;exports.resetFacetWarnings=xb;exports.resetPointBudgetWarning=Bf;exports.resolvePeriodPreset=xd;exports.resolveSeriesColor=Br;exports.samePeriod=bf;exports.sampleEvenly=cl;exports.splitOverlay=wn;exports.startOfDay=$o;exports.sturgesBins=Od;exports.toChartCsv=fu;exports.toChartJson=hu;exports.toChartRows=Al;exports.toLegendItems=Gr;exports.toTimestamp=ko;exports.useChartBrush=so;exports.useChartSize=qi;exports.useChartSync=uo;exports.useClickOutside=sa;exports.useDialogA11y=So;exports.useDropdownContext=Dr;exports.useFocusItem=cu;exports.useKeyboardNavigation=_s;exports.usePositioning=_n;exports.useSidebar=p1;exports.useUILabels=Ve;exports.useWizard=eo;