@synertech/ui 0.40.1 → 0.42.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.js CHANGED
@@ -1,6 +1,6 @@
1
- import*as Ns from'react';import Ns__default,{createContext,forwardRef,memo,useId,useState,useRef,useEffect,useCallback,useImperativeHandle,useMemo,useContext,cloneElement,isValidElement,useLayoutEffect}from'react';import {jsx,jsxs,Fragment}from'react/jsx-runtime';import {createPortal}from'react-dom';import {createRoot}from'react-dom/client';import Gf from'dompurify';import Xf from'react-markdown';import Kf from'remark-gfm';function c(...e){return e.filter(Boolean).join(" ")}var Bi=createContext(null),Vi=createContext(null);function cs(){let e=useContext(Bi);if(!e)throw new Error("Accordion sub-components must be used within <Accordion>");return e}function Oi(){let e=useContext(Vi);if(!e)throw new Error("AccordionTrigger/AccordionContent must be used within <AccordionItem>");return e}var $i={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"}},Mu=({className:e})=>jsx("svg",{className:e,viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true",children: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"})}),Lu={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:""},Au={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 zu({type:e="single",value:t,defaultValue:r,onValueChange:o,collapsible:n=false,variant:a="default",size:s="md",disabled:l=false,iconPosition:i="right",icon:d,hideIcon:u=false,className:p,children:b}){let[m,f]=useState(()=>r?Array.isArray(r)?r:[r]:[]),h=t!==void 0,y=h?Array.isArray(t)?t:[t]:m,C=useCallback(E=>{let k;e==="single"?y.includes(E)?k=n?[]:[E]:k=[E]:k=y.includes(E)?y.filter(R=>R!==E):[...y,E],h||f(k),o?.(e==="single"?k[0]??"":k);},[e,y,n,h,o]),v=useMemo(()=>({openItems:y,toggle:C,variant:a,size:s,disabled:l,iconPosition:i,icon:d??null,hideIcon:u}),[y,C,a,s,l,i,d,u]);return jsx(Bi.Provider,{value:v,children:jsx("div",{className:c(Lu[a],p),"data-testid":"accordion",children:b})})}function Wu({value:e,disabled:t,className:r,children:o}){let n=cs(),a=n.openItems.includes(e),s=t??n.disabled,l=useId(),i=`accordion-trigger-${l}`,d=`accordion-content-${l}`,u=useMemo(()=>({value:e,isOpen:a,disabled:s,triggerId:i,contentId:d}),[e,a,s,i,d]);return jsx(Vi.Provider,{value:u,children:jsx("div",{className:c(Au[n.variant],r),"data-state":a?"open":"closed","data-testid":"accordion-item",children:o})})}function Hu({className:e,icon:t,children:r}){let o=cs(),n=Oi(),a=$i[o.size],s=()=>{n.disabled||o.toggle(n.value);},l=u=>{(u.key==="Enter"||u.key===" ")&&(u.preventDefault(),s());},i=t??o.icon??jsx(Mu,{className:a.icon}),d=!o.hideIcon&&jsx("span",{className:c("shrink-0 text-gray-500 dark:text-gray-400 transition-transform duration-200",n.isOpen&&"rotate-180"),"data-testid":"accordion-icon",children:i});return jsxs("button",{type:"button",id:n.triggerId,"aria-expanded":n.isOpen,"aria-controls":n.contentId,disabled:n.disabled,onClick:s,onKeyDown:l,className:c("flex items-center w-full text-left font-medium transition-colors cursor-pointer",a.trigger,a.text,"text-gray-900 dark:text-gray-100",!n.disabled&&"hover:bg-gray-50 dark:hover:bg-gray-800/50",n.disabled&&"opacity-50 cursor-not-allowed",e),"data-testid":"accordion-trigger",children:[o.iconPosition==="left"&&d,jsx("span",{className:"flex-1",children:r}),o.iconPosition==="right"&&d]})}function Fu({className:e,children:t}){let r=cs(),o=Oi(),n=$i[r.size],a=useRef(null),[s,l]=useState(o.isOpen?void 0:0),i=useRef(true);return useEffect(()=>{if(i.current){i.current=false,l(o.isOpen?void 0:0);return}if(o.isOpen){let d=a.current;if(d){l(d.scrollHeight);let u=setTimeout(()=>l(void 0),200);return ()=>clearTimeout(u)}}else {let d=a.current;d&&(l(d.scrollHeight),requestAnimationFrame(()=>l(0)));}},[o.isOpen]),jsx("div",{id:o.contentId,role:"region","aria-labelledby":o.triggerId,className:"overflow-hidden transition-[height] duration-200 ease-in-out",style:{height:s===void 0?"auto":s},"data-testid":"accordion-content","data-state":o.isOpen?"open":"closed",children:jsx("div",{ref:a,className:c(n.content,"text-gray-600 dark:text-gray-400",n.text==="text-lg"?"text-base":"text-sm",e),children:t})})}function _u(...e){return e.filter(Boolean).join(" ")}var Gu="@synertech/ui/AdvanceDetachable",Xu=300,Ku="width=800,height=600,menubar=no,toolbar=no,location=no,status=no,scrollbars=yes,resizable=yes",Uu=0;function Yu(){return `${Date.now()}-${++Uu}-${Math.random().toString(36).slice(2,8)}`}function _i(e){try{return JSON.stringify(e)}catch{return String(e)}}function Gi(e){try{return JSON.parse(e)}catch{return e}}function ju(e,t){e.querySelectorAll("style").forEach(r=>{let o=t.createElement("style");o.textContent=r.textContent,t.head.appendChild(o);}),e.querySelectorAll('link[rel="stylesheet"]').forEach(r=>{let o=r,n=t.createElement("link");n.rel="stylesheet",n.href=o.href,o.crossOrigin&&(n.crossOrigin=o.crossOrigin),t.head.appendChild(n);}),e.documentElement.className&&(t.documentElement.className=e.documentElement.className),e.body.className&&(t.body.className=e.body.className);}function qu(e,t){let r=new MutationObserver(o=>{for(let n of o)for(let a of Array.from(n.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 Zu(){return typeof BroadcastChannel<"u"}function Ju({mode:e,id:t,title:r="",children:o,value:n,defaultValue:a,onValueChange:s,isDetached:l,defaultDetached:i=false,onDetachedChange:d,features:u,target:p,autoFocus:b=true,className:m,detachedBodyClassName:f,disabled:h=false,readOnly:y=false,closeOnMainWindowUnload:C=true,name:v,serialize:E,deserialize:k},R){let g=l!==void 0,[P,T]=useState(i),D=g?l:P,W=n!==void 0,[V,_]=useState(a),M=W?n:V,[w,N]=useState(null),x=useRef(null),S=useRef(null),I=useRef(null),F=useRef(null),O=useRef(false),Z=useRef(null),U=useRef(null),H=useRef(null),[z]=useState(()=>`${Date.now().toString(36)}-${Math.random().toString(36).slice(2,8)}`),$=useRef({title:r,features:u,target:p,autoFocus:b,detachedBodyClassName:f,closeOnMainWindowUnload:C,disabled:h,readOnly:y,mode:e,id:t});$.current={title:r,features:u,target:p,autoFocus:b,detachedBodyClassName:f,closeOnMainWindowUnload:C,disabled:h,readOnly:y,mode:e,id:t};let K=useRef(E??_i);K.current=E??_i;let se=useRef(k??Gi);se.current=k??Gi;let X=useRef(s);X.current=s;let ee=useRef(d);ee.current=d;let L=useRef(D);L.current=D;let q=`${Gu}/${t}`,ge=useCallback(()=>{I.current&&(clearInterval(I.current),I.current=null),F.current&&(F.current.disconnect(),F.current=null),N(null);},[]),de=useCallback(()=>{S.current&&(S.current.close(),S.current=null),Z.current&&typeof window<"u"&&(window.removeEventListener("message",Z.current),Z.current=null);},[]),Y=useCallback(Re=>{if(!(!Re||Re.channel!==q)&&Re.instanceId!==z&&!$.current.readOnly&&Re.type==="value-sync"&&Re.payload!==void 0){U.current=Re.payload;let We=se.current(Re.payload);W||_(We),X.current?.(We);}},[q,z,W]),le=useCallback(()=>{if(de(),!(typeof window>"u"))if(Zu()){let Re=new BroadcastChannel(q),We=ft=>Y(ft.data);Re.addEventListener("message",We),S.current=Re;}else {let Re=We=>{We.data?.channel===q&&Y(We.data);};window.addEventListener("message",Re),Z.current=Re;}},[q,de,Y]),xe=useCallback(Re=>{if($.current.readOnly)return;let We=K.current(Re);if(We===H.current)return;if(We===U.current){U.current=null;return}H.current=We;let ft={channel:q,instanceId:z,messageId:Yu(),origin:"main",timestamp:Date.now(),type:"value-sync",payload:We};S.current?S.current.postMessage(ft):x.current&&!x.current.closed&&x.current.postMessage(ft,"*");},[q,z]),Se=useCallback(()=>{if(typeof window>"u"||$.current.disabled||O.current||x.current&&!x.current.closed)return;O.current=true;let Re=$.current,We=window.open("",Re.target||"",Re.features||Ku);if(!We){O.current=false;return}x.current=We,We.document.title=Re.title||document.title,Re.detachedBodyClassName&&(We.document.body.className=Re.detachedBodyClassName);let ft=We.document.createElement("div");We.document.body.appendChild(ft),N(ft),ju(document,We.document),F.current=qu(document,We.document),I.current=setInterval(()=>{We.closed&&(ge(),x.current=null,g||T(false),ee.current?.(false));},Xu),Re.autoFocus&&We.focus(),O.current=false;},[g,ge]),te=useCallback(()=>{x.current&&!x.current.closed&&x.current.close(),x.current=null,ge();},[ge]),Ne=useRef(Se);Ne.current=Se;let De=useRef(te);De.current=te;let Ve=useRef(xe);Ve.current=xe;let rt=useCallback(()=>{$.current.disabled||(g||T(true),ee.current?.(true));},[g]),dt=useCallback(()=>{g||T(false),ee.current?.(false);},[g]),re=useCallback(()=>{let Re=!L.current;Re&&$.current.disabled||(g||T(Re),ee.current?.(Re));},[g]);useImperativeHandle(R,()=>({open:rt,close:dt,toggle:re,get isDetached(){return L.current},get window(){return x.current}}),[rt,dt,re]),useEffect(()=>(le(),()=>de()),[le,de]),useEffect(()=>{if(D)return Ne.current(),()=>De.current();De.current();},[D]),useEffect(()=>{M!==void 0&&Ve.current(M);},[M]),useEffect(()=>{x.current&&!x.current.closed&&r&&(x.current.document.title=r);},[r]),useEffect(()=>{if(typeof window>"u")return;let Re=()=>{$.current.closeOnMainWindowUnload&&x.current&&!x.current.closed&&x.current.close();};return window.addEventListener("beforeunload",Re),()=>{window.removeEventListener("beforeunload",Re),x.current&&!x.current.closed&&x.current.close(),x.current=null;}},[]);let pe=typeof o=="function"?o({open:rt,close:dt,toggle:re,detached:D,windowRef:x.current}):o,Ue=e==="clone"||!D,yt=D&&w!==null;return jsxs(Fragment,{children:[v&&M!==void 0&&jsx("input",{type:"hidden",name:v,value:K.current(M)}),Ue&&jsx("div",{className:_u(m),children:pe}),yt&&createPortal(pe,w)]})}var Ki=forwardRef(Ju);Ki.displayName="AdvanceDetachable";function hn(e,t=11){return e.length*t*.6}function yn(e,t=11){let r=0;for(let o of e){let n=hn(o,t);n>r&&(r=n);}return r}function Ui(e,t,r,o=12){if(e<=1||t<=0)return 1;let n=r+o,a=Math.max(1,Math.floor(t/n));return Math.max(1,Math.ceil(e/a))}var t0=10,r0={sm:"text-[10px]",md:"text-[11px]",lg:"text-xs"};function Ut({orientation:e,ticks:t,length:r,showLine:o=true,tickSize:n=4,tickPadding:a=6,label:s,size:l="md",className:i,...d}){let u=e==="bottom";return jsxs("g",{className:c(r0[l],i),"aria-hidden":"true",...d,children:[o&&jsx("line",{x1:0,y1:0,x2:u?r:0,y2:u?0:r,className:"stroke-gray-300 dark:stroke-gray-600",strokeWidth:1,shapeRendering:"crispEdges"}),t.map(p=>{let b=u?p.offset:0,m=u?0:p.offset;return jsxs("g",{transform:`translate(${b}, ${m})`,children:[jsx("line",{x1:0,y1:0,x2:u?0:-n,y2:u?n:0,className:"stroke-gray-300 dark:stroke-gray-600",strokeWidth:1}),jsx("text",{x:u?0:-(n+a),y:u?n+a:0,textAnchor:u?"middle":"end",dominantBaseline:u?"hanging":"middle",className:"fill-gray-500 dark:fill-gray-400 [font-variant-numeric:tabular-nums]",children:p.label})]},`${p.label}-${p.offset}`)}),s?jsx("text",{x:u?r/2:0,y:u?n+a+16:0,textAnchor:"middle",dominantBaseline:u?"hanging":"middle",transform:u?void 0:`translate(${-(n+a+yn(t.map(p=>p.label))+t0)}, ${r/2}) rotate(-90)`,className:"fill-gray-600 dark:fill-gray-300 font-medium",children:s}):null]})}var qi={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"},a0={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"},us=createContext(qi);function s0({labels:e,children:t}){let r=useContext(us),o=useMemo(()=>({...r,...e}),[r,e]);return jsx(us.Provider,{value:o,children:t})}function Ft(){return useContext(us)}var l0={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"},d0={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"},c0={xs:24,sm:32,md:48,lg:64,xl:96},u0={xs:"text-[8px]",sm:"text-[10px]",md:"text-sm",lg:"text-base",xl:"text-xl"},p0={thin:2,normal:4,thick:8};function Ho({value:e=0,indeterminate:t=false,size:r="md",thickness:o="normal",color:n="primary",progressColor:a,trackColor:s,showValue:l=false,children:i,valueFormat:d,animated:u=true,className:p,...b}){let m=Math.min(100,Math.max(0,e)),f=c0[r],h=p0[o],y=(f-h)/2,C=2*Math.PI*y,v=f/2,E=C-m/100*C,k=a||l0[n],R=s||"stroke-gray-200 dark:stroke-gray-700",g=d0[n],P=i??(l&&!t?jsx("span",{className:c("font-semibold",u0[r],g),children:d?d(m):`${Math.round(m)}%`}):null);return jsxs("div",{className:c("relative inline-flex items-center justify-center",p),role:"progressbar","aria-valuenow":t?void 0:m,"aria-valuemin":0,"aria-valuemax":100,...b,children:[jsxs("svg",{width:f,height:f,viewBox:`0 0 ${f} ${f}`,className:c(t&&"animate-spin"),style:{transform:"rotate(-90deg)"},children:[jsx("circle",{cx:v,cy:v,r:y,fill:"none",strokeWidth:h,className:R}),jsx("circle",{cx:v,cy:v,r:y,fill:"none",strokeWidth:h,strokeLinecap:"round",strokeDasharray:C,strokeDashoffset:t?C*.75:E,className:c(k,u&&!t&&"transition-[stroke-dashoffset] duration-300 ease-out")})]}),P&&jsx("div",{className:"absolute inset-0 flex items-center justify-center",style:{transform:"rotate(0deg)"},children:P})]})}Ho.displayName="CircularProgress";var Ji=640;function ps(e={}){let{width:t,fallbackWidth:r=Ji}=e,o=useRef(null),[n,a]=useState(0);return useEffect(()=>{if(t!==void 0)return;let s=o.current;if(!s)return;let l=d=>{a(u=>Math.abs(u-d)<1?u:d);};if(l(s.getBoundingClientRect().width),typeof ResizeObserver>"u")return;let i=new ResizeObserver(d=>{for(let u of d)l(u.contentRect.width);});return i.observe(s),()=>i.disconnect()},[t]),t!==void 0?{ref:o,width:t,measured:true}:{ref:o,width:n>0?n:r,measured:n>0}}var y0={sm:"text-xs",md:"text-sm",lg:"text-base"};function lr({title:e,description:t,height:r=240,width:o,size:n="md",legend:a,legendPosition:s="bottom",actions:l,loading:i=false,empty:d=false,emptyState:u,table:p,tableView:b=false,showTableLabel:m,hideTableLabel:f,noDataLabel:h,loadingLabel:y,ariaLabel:C,children:v,className:E,...k}){let R=Ft(),[g,P]=useState(false),T=useId(),D=`${T}-table`,W=`${T}-title`,V=`${T}-description`,{ref:_,width:M,measured:w}=ps({width:o}),N=!!p&&b==="toggle",x=!!p&&(b===true||N&&g),F=jsx("div",{ref:_,className:"relative w-full",style:{height:r},"aria-busy":i||void 0,children:i&&d?jsx("div",{className:"flex h-full w-full items-center justify-center",children:jsx(Ho,{indeterminate:true,size:"md","aria-label":y??R.chartLoading})}):d&&!i?jsx("div",{className:"flex h-full w-full items-center justify-center text-sm text-gray-500 dark:text-gray-400",children:u??h??R.chartNoData}):jsx("div",{className:c("h-full w-full transition-opacity duration-200",i&&"opacity-60"),children:typeof v=="function"?v({width:M,height:r,measured:w}):v})});return jsxs("figure",{className:c("flex w-full flex-col gap-3",E),"aria-label":C,"aria-labelledby":!C&&e?W:void 0,"aria-describedby":t?V:void 0,...k,children:[e||t||l?jsxs("figcaption",{className:"flex items-start justify-between gap-3",children:[jsxs("div",{className:"flex flex-col gap-0.5",children:[e?jsx("span",{id:W,className:c("font-semibold text-gray-900 dark:text-gray-100",y0[n]),children:e}):null,t?jsx("span",{id:V,className:"text-xs text-gray-500 dark:text-gray-400",children:t}):null]}),l]}):null,a&&s==="top"?a:null,a&&s==="right"?jsxs("div",{className:"flex items-start gap-4",children:[jsx("div",{className:"min-w-0 grow",children:F}),a]}):F,a&&s==="bottom"?a:null,N&&jsx("div",{className:"flex",children:jsx("button",{type:"button",onClick:()=>P(O=>!O),"aria-expanded":g,"aria-controls":x?D: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:g?f??R.chartHideTable:m??R.chartShowTable})}),x&&jsx("div",{id:D,children:p})]})}var Qi=[];function Wr({width:e,height:t,horizontal:r=Qi,vertical:o=Qi,className:n,...a}){return jsxs("g",{className:c("stroke-gray-200 dark:stroke-gray-700",n),strokeWidth:1,shapeRendering:"crispEdges","aria-hidden":"true",...a,children:[r.map(s=>jsx("line",{x1:0,y1:s,x2:e,y2:s},`h-${s}`)),o.map(s=>jsx("line",{x1:s,y1:0,x2:s,y2:t},`v-${s}`))]})}var v0={line:"h-0.5 w-3 rounded-full",rect:"h-2.5 w-2.5 rounded-sm",dot:"h-2 w-2 rounded-full"},k0={sm:"text-[11px]",md:"text-xs",lg:"text-sm"};function dr({items:e,position:t="bottom",marker:r="line",onToggle:o,size:n="md",className:a,...s}){return e.length===0?null:jsx("ul",{className:c("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":"",k0[n],a),...s,children:e.map(l=>{let i=jsx("span",{className:c("shrink-0",v0[r]),style:{backgroundColor:l.color},"aria-hidden":"true"}),d=jsx("span",{className:c(l.hidden&&"line-through"),children:l.label}),u=jsxs(Fragment,{children:[i,d]}),p=c("flex items-center gap-1.5 text-gray-600 dark:text-gray-300",l.hidden&&"text-gray-400 dark:text-gray-500");return jsx("li",{children:o?jsx("button",{type:"button",onClick:()=>o(l.key),"aria-pressed":!l.hidden,className:c(p,"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}):jsx("span",{className:p,children:u})},l.key)})})}function gs({children:e,className:t,...r}){return jsx("table",{className:c("w-full text-sm text-left rtl:text-right text-gray-500 dark:text-gray-400",t),...r,children:e})}function ms({children:e,className:t,...r}){return jsx("tbody",{className:c(t),...r,children:e})}function na({children:e,onClick:t,hidden:r=false,className:o,...n}){return jsx("td",{className:c("px-6 py-4",o),onClick:t,hidden:r,...n,children:e})}function fs({children:e,className:t,...r}){return jsx("thead",{className:c("text-xs text-gray-700 uppercase bg-gray-50 dark:bg-gray-700 dark:text-gray-400",t),...r,children:jsx("tr",{children:e})})}function aa({children:e,onClick:t,hidden:r=false,className:o,sortable:n=false,...a}){return jsx("th",{scope:"col",className:c("px-6 py-3",n&&"cursor-pointer hover:bg-gray-100 dark:hover:bg-gray-600",o),onClick:t,hidden:r,...a,children:e})}function bs({children:e,onClick:t,clickable:r=true,className:o,...n}){return jsx("tr",{className:c("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",o),onClick:t,...n,children:e})}var E0=8,sa=["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)"],xn="var(--color-chart-muted)",ia=3,rl=false;function la(e,t){return t||(e<0||e>=8?(rl||(rl=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.')),xn):sa[e])}function Cr(e,t,r){return r&&e.key!==r?xn:la(t,e.color)}function Lt(e){return e.label??e.key}function Hr(e,t){return e.map((r,o)=>({key:r.key,label:Lt(r),color:Cr(r,o,t),hidden:r.hidden}))}function St(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 o=Number(r);return Number.isFinite(o)?o:null}return null}function bo(e,t,r){let o=e[t];return o instanceof Date||typeof o=="number"||typeof o=="string"?o:o==null?r:String(o)}function Fr(e,t){let r=[];for(let o of e)for(let n of t)r.push(St(o,n));return r}function vn(e,t={}){if(!Number.isFinite(e))return "\u2014";let{locale:r,compact:o,currency:n,unit:a,minimumFractionDigits:s,maximumFractionDigits:l}=t,i=new Intl.NumberFormat(r,{notation:o?"compact":"standard",...n?{style:"currency",currency:n}:{},...s!==void 0?{minimumFractionDigits:s}:{},...l!==void 0?{maximumFractionDigits:l}:o?{maximumFractionDigits:1}:{}}).format(e);return a?`${i}${a}`:i}function D0(e,t){return vn(e,{locale:t,compact:true})}function _t(e,t){return Number.isFinite(e)?Math.abs(e)<1e4?vn(e,{locale:t}):D0(e,t):"\u2014"}function Br(e,t={}){if(!Number.isFinite(e))return "\u2014";let{locale:r,maximumFractionDigits:o=1,alreadyScaled:n,signed:a}=t;return new Intl.NumberFormat(r,{style:"percent",maximumFractionDigits:o,...a?{signDisplay:"exceptZero"}:{}}).format(n?e/100:e)}function Gt(e,t){return e instanceof Date?new Intl.DateTimeFormat(t,{day:"2-digit",month:"short"}).format(e):typeof e=="number"?vn(e,{locale:t}):e}function cr({data:e,series:t,xKey:r,xLabel:o,formatX:n,formatValue:a,caption:s,emptyLabel:l,className:i,...d}){let u=t.filter(m=>!m.hidden);if(e.length===0||u.length===0)return jsx("div",{className:c("text-sm text-gray-500 dark:text-gray-400",i),...d,children:l});let p=(m,f)=>{let h=bo(m,r,f);return n?n(h,f):Gt(h)},b=m=>m===null?"\u2014":a?a(m):vn(m);return jsx("div",{className:c("w-full overflow-x-auto",i),...d,children:jsxs(gs,{children:[s?jsx("caption",{className:"sr-only",children:s}):null,jsxs(fs,{children:[jsx(aa,{children:o??r}),u.map(m=>jsx(aa,{className:"text-right",children:Lt(m)},m.key))]}),jsx(ms,{children:e.map((m,f)=>jsxs(bs,{clickable:false,children:[jsx(na,{className:"font-medium text-gray-900 dark:text-gray-100",children:p(m,f)}),u.map(h=>jsx(na,{className:"text-right [font-variant-numeric:tabular-nums]",children:b(St(m,h.key))},h.key))]},f))})]})})}function ur({x:e,y:t,visible:r=true,containerWidth:o,offset:n=12,className:a,style:s,children:l,...i}){if(!r)return null;let d=o!==void 0&&e>o*.6;return jsx("div",{role:"tooltip",className:c("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(${d?e-n:e+n}px, ${t}px) translate(${d?"-100%":"0"}, -50%)`,...s},...i,children:l})}function pr({title:e,points:t}){return jsxs("div",{className:"flex flex-col gap-1",children:[e!=null&&jsx("div",{className:"font-medium text-gray-900 dark:text-gray-100",children:e}),jsx("div",{className:"flex flex-col gap-0.5",children:t.map(r=>jsxs("div",{className:"flex items-center gap-2",children:[jsx("span",{className:"h-0.5 w-3 shrink-0 rounded-full",style:{backgroundColor:r.color},"aria-hidden":"true"}),jsx("span",{className:"grow text-gray-500 dark:text-gray-400",children:r.seriesLabel}),jsx("span",{className:"font-semibold text-gray-900 [font-variant-numeric:tabular-nums] dark:text-gray-100",children:r.formattedValue})]},r.seriesKey))})]})}function eo(e){return e instanceof Date?e.toISOString():String(e)}function Nr(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 ho(e,t){let[r,o]=e,[n,a]=t,s=o-r,l=s===0?0:(a-n)/s,i=(d=>Number.isFinite(d)?s===0?(n+a)/2:n+(d-r)*l:Number.NaN);return Object.defineProperties(i,{domain:{value:[r,o],enumerable:true},range:{value:[n,a],enumerable:true},invert:{value:d=>l===0?r:r+(d-n)/l,enumerable:true}}),i}function nl(e,t,r={}){let{paddingInner:o=.2,paddingOuter:n=o/2}=r,[a,s]=t,l=e.length,i=l===0?0:(s-a)/Math.max(1,l-o+n*2),d=i*(1-o),u=a+(s-a-i*(l-o))/2,p=new Map;e.forEach((f,h)=>{p.has(eo(f))||p.set(eo(f),h);});let b=f=>u+i*f,m=(f=>{let h=p.get(eo(f));return h===void 0?Number.NaN:b(h)});return Object.defineProperties(m,{bandwidth:{value:d,enumerable:true},step:{value:i,enumerable:true},domain:{value:e,enumerable:true},range:{value:[a,s],enumerable:true},center:{value:f=>{let h=p.get(eo(f));return h===void 0?Number.NaN:b(h)+d/2},enumerable:true},positions:{value:()=>e.map((f,h)=>b(h)),enumerable:true},indexOf:{value:f=>p.get(eo(f))??-1,enumerable:true}}),m}function Vo(e,t){if(e.length===0)return -1;let r=0,o=Number.POSITIVE_INFINITY;for(let n=0;n<e.length;n+=1){let a=Math.abs(e[n]-t);a<o&&(o=a,r=n);}return r}function kn(e){let t=Number(e.toPrecision(12));return Object.is(t,-0)?0:t}function al(e){if(!Number.isFinite(e)||e<=0)return 1;let t=Math.floor(Math.log10(e)),r=Math.pow(10,t),o=e/r,n=o<=1?1:o<=2?2:o<=5?5:10;return kn(n*r)}function I0(e,t,r=5){if(!Number.isFinite(e)||!Number.isFinite(t))return [0,1];if(e===t){if(e===0)return [0,1];let n=Math.abs(e)*.5;[e,t]=[e-n,e+n];}let o=al((t-e)/Math.max(1,r));return [kn(Math.floor(e/o)*o),kn(Math.ceil(t/o)*o)]}function ys(e,t,r=5){if(!Number.isFinite(e)||!Number.isFinite(t))return [];if(r<=0)return [];if(e===t)return [kn(e)];e>t&&([e,t]=[t,e]);let o=al((t-e)/r),n=Math.ceil(e/o),a=Math.floor(t/o),s=[];for(let l=n;l<=a&&s.length<=1e3;l+=1)s.push(kn(l*o));return s}function Xt(e){let t=Number.POSITIVE_INFINITY,r=Number.NEGATIVE_INFINITY,o=false;for(let n of e)n==null||!Number.isFinite(n)||(o=true,n<t&&(t=n),n>r&&(r=n));return o?[t,r]:null}function sl(e,t={}){let{domain:r,includeZero:o=true,ticks:n=5}=t;if(Array.isArray(r))return r;let a=Xt(e);if(!a)return [0,1];let[s,l]=a;return o&&(s=Math.min(s,0),l=Math.max(l,0)),I0(s,l,n)}var xs={top:10,right:16,bottom:28},il=16,L0=14,A0=32;function to({width:e,height:t,data:r,x:o,y:n,bounds:a,margin:s,orientation:l="vertical",placement:i="point",bandPaddingInner:d=.2,formatValue:u,formatX:p,extraTop:b=0,defaultIncludeZero:m=false}){let f=l==="vertical",h=r.map(($,K)=>bo($,o.key,K)),y=sl(a??[],{domain:n?.domain,includeZero:n?.includeZero??m,ticks:n?.ticks??5}),C=n?.hidden??false,v=o.hidden??false,E=C?[]:ys(y[0],y[1],n?.ticks??5),k=E.map(u),R=f&&(o.scale==="linear"||o.scale==="time"),g=h.map(($,K)=>p($,K)),P=f?C:v,T=f?k:g,D=f?n?.width:o.height,W=f?v:C,V=f?o.height:void 0,_=f?o.label:n?.label,M=f?n?.label:o.label,w=f&&!v&&i!=="band"?g:[],N=$=>$?hn($)/2+4:0,x={top:s?.top??xs.top+b,right:s?.right??Math.max(xs.right,N(w[w.length-1])),bottom:s?.bottom??(W?8:V??xs.bottom+(_?il:0)),left:s?.left??(P?8:D??Math.max(Math.max(A0,yn(T)+L0)+(M?il:0),N(w[0])))},S=Math.max(0,e-x.left-x.right),I=Math.max(0,t-x.top-x.bottom),F=f?ho(y,[I,0]):ho(y,[0,S]),O=f?S:I,Z,U=0,H;if(R){let $=h.map(Nr),K=Xt($)??[0,1],se=ho(K,[0,O]);Z=$.map(X=>se(X)),H=v?[]:ys(K[0],K[1],o.ticks??5).map(X=>({value:X,offset:se(X),label:p(o.scale==="time"?new Date(X):X,0)}));}else if(i==="band"){let $=nl(r.map((K,se)=>se),[0,O],{paddingInner:d});Z=r.map((K,se)=>$(se)),U=$.bandwidth,H=[];}else {let $=r.length>1?O/(r.length-1):0;Z=r.map((K,se)=>r.length>1?se*$:O/2),H=[];}let z=Z.map($=>$+U/2);if(!R&&!v){let $=f?yn(g):15,K=Ui(g.length,O,$);H=g.map((se,X)=>({value:h[X],offset:z[X],label:se})).filter((se,X)=>X%K===0);}return {margin:x,innerWidth:S,innerHeight:I,orientation:l,valueScale:F,domain:y,valueTicks:E.map($=>({value:$,offset:F($),label:u($)})),xValues:h,categoryPositions:Z,bandwidth:U,categoryCenters:z,categoryTicks:H,categoryLength:O}}function st(e){return Math.round(e*100)/100}function ll(e){return e.defined!==false&&Number.isFinite(e.x)&&Number.isFinite(e.y)}function dl(e,t=false){if(t){let n=e.filter(ll);return n.length>0?[n]:[]}let r=[],o=[];for(let n of e)ll(n)?o.push(n):o.length>0&&(r.push(o),o=[]);return o.length>0&&r.push(o),r}function z0(e){let t=e.length,r=[],o=[];for(let a=0;a<t-1;a+=1){let s=e[a+1].x-e[a].x;r.push(s),o.push(s===0?0:(e[a+1].y-e[a].y)/s);}let n=new Array(t);n[0]=o[0],n[t-1]=o[t-2];for(let a=1;a<t-1;a+=1){let s=o[a-1],l=o[a];if(s*l<=0)n[a]=0;else {let i=2*r[a]+r[a-1],d=r[a]+2*r[a-1];n[a]=(i+d)/(i/s+d/l);}}return n}function vs(e,t){if(e.length<2)return "";if(t==="monotone"&&e.length>2){let o=z0(e),n="";for(let a=0;a<e.length-1;a+=1){let s=e[a],l=e[a+1],i=(l.x-s.x)/3;n+=` C${st(s.x+i)},${st(s.y+o[a]*i)} ${st(l.x-i)},${st(l.y-o[a+1]*i)} ${st(l.x)},${st(l.y)}`;}return n}let r="";for(let o=1;o<e.length;o+=1){let n=e[o-1],a=e[o];if(t==="step"){let s=st((n.x+a.x)/2);r+=` L${s},${st(n.y)} L${s},${st(a.y)}`;}else t==="stepAfter"&&(r+=` L${st(a.x)},${st(n.y)}`);r+=` L${st(a.x)},${st(a.y)}`;}return r}function Vr(e,t="linear",r={}){return dl(e,r.connectNulls).map(o=>{let[n]=o;return `M${st(n.x)},${st(n.y)}${vs(o,t)}`}).join(" ")}function wn(e,t,r="linear",o={}){let n=dl(e,o.connectNulls);if(n.length===0)return "";let a=typeof t=="number"?null:new Map(t.map(s=>[st(s.x),s]));return n.map(s=>{let[l]=s,i=s[s.length-1],d=`M${st(l.x)},${st(l.y)}${vs(s,r)}`;if(a===null){let b=st(t);return `${d} L${st(i.x)},${b} L${st(l.x)},${b} Z`}let u=s.map(b=>a.get(st(b.x))).filter(b=>b!==void 0).reverse();if(u.length===0)return `${d} Z`;let[p]=u;return `${d} L${st(p.x)},${st(p.y)}${vs(u,r)} Z`}).join(" ")}function cl({x:e,y:t,width:r,height:o,radius:n=4,round:a="none"}){if(!(r>0)||!(o>0))return "";let s=Math.max(0,Math.min(n,r/2,o/2)),[l,i]=[Ae(e),Ae(t)],[d,u]=[Ae(e+r),Ae(t+o)];if(s===0||a==="none")return `M${l},${i} L${d},${i} L${d},${u} L${l},${u} Z`;switch(a){case "top":return `M${l},${u} L${l},${Ae(t+s)} Q${l},${i} ${Ae(e+s)},${i} L${Ae(e+r-s)},${i} Q${d},${i} ${d},${Ae(t+s)} L${d},${u} Z`;case "bottom":return `M${l},${i} L${d},${i} L${d},${Ae(t+o-s)} Q${d},${u} ${Ae(e+r-s)},${u} L${Ae(e+s)},${u} Q${l},${u} ${l},${Ae(t+o-s)} Z`;case "right":return `M${l},${i} L${Ae(e+r-s)},${i} Q${d},${i} ${d},${Ae(t+s)} L${d},${Ae(t+o-s)} Q${d},${u} ${Ae(e+r-s)},${u} L${l},${u} Z`;case "left":return `M${d},${i} L${Ae(e+s)},${i} Q${l},${i} ${l},${Ae(t+s)} L${l},${Ae(t+o-s)} Q${l},${u} ${Ae(e+s)},${u} L${d},${u} Z`;default:return `M${l},${i} L${d},${i} L${d},${u} L${l},${u} Z`}}function Ae(e){return Math.round(e*100)/100}function ro(e,t,r,o){return {x:Ae(e+r*Math.sin(o)),y:Ae(t-r*Math.cos(o))}}function ul({cx:e,cy:t,innerRadius:r,outerRadius:o,startAngle:n,endAngle:a}){let s=a-n;if(!(o>0)||!(s>0))return "";let l=s>=Math.PI*2-1e-9,i=Math.max(0,Math.min(r,o));if(l){let f=ro(e,t,o,0),h=ro(e,t,o,Math.PI),y=`M${f.x},${f.y} A${Ae(o)},${Ae(o)} 0 1 1 ${h.x},${h.y} A${Ae(o)},${Ae(o)} 0 1 1 ${f.x},${f.y} Z`;if(i===0)return y;let C=ro(e,t,i,0),v=ro(e,t,i,Math.PI);return `${y} M${C.x},${C.y} A${Ae(i)},${Ae(i)} 0 1 0 ${v.x},${v.y} A${Ae(i)},${Ae(i)} 0 1 0 ${C.x},${C.y} Z`}let d=s>Math.PI?1:0,u=ro(e,t,o,n),p=ro(e,t,o,a);if(i===0)return `M${Ae(e)},${Ae(t)} L${u.x},${u.y} A${Ae(o)},${Ae(o)} 0 ${d} 1 ${p.x},${p.y} Z`;let b=ro(e,t,i,a),m=ro(e,t,i,n);return `M${u.x},${u.y} A${Ae(o)},${Ae(o)} 0 ${d} 1 ${p.x},${p.y} L${b.x},${b.y} A${Ae(i)},${Ae(i)} 0 ${d} 0 ${m.x},${m.y} Z`}function da(e,t,r="none"){return e.map((o,n)=>{let a=t.map(u=>St(o,u)),s=a.reduce((u,p)=>u+(p===null?0:Math.abs(p)),0),l=0,i=0,d=t.map((u,p)=>{let b=a[p];if(r==="none")return {key:u,value:b,start:0,end:b??0};if(b===null)return {key:u,value:null,start:l,end:l};let m=r==="percent"?s===0?0:b/s*100:b;if(m>=0){let h=l;return l+=m,{key:u,value:b,start:h,end:l}}let f=i;return i+=m,{key:u,value:b,start:i,end:f}});return {index:n,datum:o,total:s,segments:d}})}function ca(e){let t=Number.POSITIVE_INFINITY,r=Number.NEGATIVE_INFINITY,o=false;for(let n of e)for(let a of n.segments)a.value!==null&&(o=true,t=Math.min(t,a.start,a.end),r=Math.max(r,a.start,a.end));return o?[t,r]:null}var H0=.12,F0=.9,B0=10,V0=memo(function({bands:t,stacked:r}){return jsx("g",{children:t.map(o=>jsxs("g",{children:[jsx("path",{d:o.area,fill:o.color,fillOpacity:r?F0:H0,stroke:"none"}),o.gap?jsx("path",{d:o.gap,fill:"none",strokeWidth:2,className:"stroke-white dark:stroke-gray-800"}):null,jsx("path",{d:o.edge,fill:"none",stroke:o.color,strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"})]},o.key))})});function O0({width:e,height:t,data:r,resolvedSeries:o,x:n,y:a,grid:s,size:l,curve:i,stack:d,baseline:u,connectNulls:p,referenceLines:b,margin:m,tooltip:f,onPointClick:h,plotLabel:y,formatValue:C,formatRaw:v,formatX:E}){let[k,R]=useState(null),g=useMemo(()=>{let w=o.filter(z=>!z.hidden),N=w.map(z=>z.key),x=d!=="none",S=da(r,N,d),I=x?ca(S):Xt([...Fr(r,N),u]),F=to({width:e,height:t,data:r,x:n,y:a,bounds:I,margin:m,placement:"point",formatValue:C,formatX:E,defaultIncludeZero:true}),O=F.categoryCenters,Z=F.valueScale,U=Z(x?0:u),H=w.map((z,$)=>{let K=r.map((ee,L)=>{let q=S[L].segments[$];return {x:O[L],y:q.value===null?Number.NaN:Z(q.end),defined:q.value!==null}}),se=r.map((ee,L)=>{let q=S[L].segments[$];return {x:O[L],y:q.value===null?Number.NaN:Z(x?q.start:u),defined:q.value!==null}}),X={connectNulls:p};return {key:z.key,color:z.color,area:x?wn(K,se,i,X):wn(K,U,i,X),edge:Vr(K,i,X),gap:x&&$>0?Vr(se,i,X):""}});return {visible:w,rows:S,stacked:x,xValues:F.xValues,positions:O,xTicks:F.categoryTicks,yTicks:F.valueTicks,valueScale:Z,innerWidth:F.innerWidth,innerHeight:F.innerHeight,margin:F.margin,bands:H}},[r,o,n,a,e,t,m,i,d,u,p,C,E]),P=useCallback(w=>g.visible.map((N,x)=>{let S=St(r[w],N.key),I=g.rows[w].segments[x],F=S===null?"\u2014":d==="percent"?`${v(S)} (${C(I.end-I.start)})`:C(S);return {seriesKey:N.key,seriesLabel:Lt(N),color:N.color,value:S,formattedValue:F,datum:r[w]}}),[r,g.visible,g.rows,d,C,v]),T=useCallback(w=>{if(f===false||r.length===0)return;let N=w.currentTarget.getBoundingClientRect(),x=w.clientX-N.left-g.margin.left,S=Vo(g.positions,x);R(S>=0?S:null);},[f,r.length,g.margin.left,g.positions]),D=useCallback(w=>{if(r.length===0)return;let N=r.length-1,x=k??0,S=w.key==="ArrowRight"?Math.min(N,x+1):w.key==="ArrowLeft"?Math.max(0,x-1):w.key==="Home"?0:w.key==="End"?N:w.key==="Escape"?null:void 0;S!==void 0&&(w.preventDefault(),R(S));},[r.length,k]),W=useCallback(()=>{if(!h||k===null)return;let[w]=P(k);w&&h({...w,index:k,x:g.xValues[k]});},[h,k,P,g.xValues]),V=k===null?null:P(k),_=k===null?[]:g.visible.map((w,N)=>{let x=g.rows[k].segments[N];return x.value===null?null:{key:w.key,color:w.color,y:g.valueScale(x.end)}}).filter(w=>w!==null),M=k===null||V===null?null:{x:g.xValues[k],xLabel:E(g.xValues[k],k),index:k,points:V};return jsxs(Fragment,{children:[jsxs("svg",{width:e,height:t,role:"img","aria-label":y??g.visible.map(w=>Lt(w)).join(", "),tabIndex:0,className:"touch-none focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-blue-500",onPointerMove:T,onPointerLeave:()=>R(null),onKeyDown:D,onBlur:()=>R(null),onClick:W,children:[jsxs("g",{transform:`translate(${g.margin.left}, ${g.margin.top})`,children:[jsx(Wr,{width:g.innerWidth,height:g.innerHeight,horizontal:s==="y"||s==="both"?g.yTicks.map(w=>w.offset):void 0,vertical:s==="x"||s==="both"?g.xTicks.map(w=>w.offset):void 0}),jsx(V0,{bands:g.bands,stacked:g.stacked}),b?.map(w=>{let N=g.valueScale(w.value),x=N<B0?N+12:N-4;return jsxs("g",{children:[jsx("line",{x1:0,y1:N,x2:g.innerWidth,y2:N,stroke:w.color??"var(--color-chart-muted)",strokeWidth:1,strokeDasharray:w.dashed===false?void 0:"4 4"}),w.label?jsx("text",{x:g.innerWidth,y:x,textAnchor:"end",className:"fill-gray-500 text-[10px] dark:fill-gray-400",children:w.label}):null]},`${w.value}-${w.label??""}`)}),k!==null?jsxs("g",{"aria-hidden":"true",children:[jsx("line",{x1:g.positions[k],y1:0,x2:g.positions[k],y2:g.innerHeight,className:"stroke-gray-400 dark:stroke-gray-500",strokeWidth:1}),_.map(w=>jsx("circle",{cx:g.positions[k],cy:w.y,r:4,fill:w.color,strokeWidth:2,className:"stroke-white dark:stroke-gray-800"},w.key))]}):null]}),jsx("g",{transform:`translate(${g.margin.left}, ${g.margin.top+g.innerHeight})`,children:n.hidden?null:jsx(Ut,{orientation:"bottom",ticks:g.xTicks,length:g.innerWidth,label:n.label,size:l})}),jsx("g",{transform:`translate(${g.margin.left}, ${g.margin.top})`,children:a?.hidden?null:jsx(Ut,{orientation:"left",ticks:g.yTicks,length:g.innerHeight,showLine:false,label:a?.label,size:l})})]}),M&&f!==false?jsx(ur,{x:g.margin.left+g.positions[M.index],y:g.margin.top+(_.length>0?Math.min(..._.map(w=>w.y)):g.innerHeight/2),containerWidth:e,children:typeof f=="function"?f(M):jsx(pr,{title:M.xLabel,points:M.points})}):null]})}function $0({data:e,series:t,x:r,y:o,height:n=240,width:a,size:s="md",grid:l="y",legend:i,tooltip:d=true,tableView:u=false,emphasis:p,title:b,description:m,loading:f=false,emptyState:h,onPointClick:y,curve:C="monotone",stack:v="none",baseline:E=0,connectNulls:k=false,referenceLines:R,legendToggle:g=true,margin:P,locale:T,plotLabel:D,className:W,...V}){let[_,M]=useState(()=>new Set),w=useMemo(()=>t.map((z,$)=>({...z,hidden:z.hidden||_.has(z.key),color:Cr(z,$,p)})),[t,_,p]),N=v==="percent",x=useMemo(()=>N?{domain:[0,100],...o}:o,[N,o]),S=useMemo(()=>o?.format??(N?z=>Br(z,{locale:T,alreadyScaled:true,maximumFractionDigits:0}):z=>_t(z,T)),[o?.format,N,T]),I=useMemo(()=>z=>_t(z,T),[T]),F=useMemo(()=>r.format??(z=>r.scale==="time"?Gt(z instanceof Date?z:new Date(Nr(z)),T):Gt(z,T)),[r.format,r.scale,T]),O=useCallback(z=>{M($=>{let K=new Set($);return K.has(z)?K.delete(z):K.add(z),K});},[]),Z=i===void 0?t.length>=2:i!==false,U=typeof i=="string"?i:"bottom",H=w.filter(z=>!z.hidden).length;return jsx(lr,{title:b,description:m,height:n,width:a,size:s,loading:f,empty:e.length===0||H===0,emptyState:h,tableView:u,legendPosition:U,legend:Z?jsx(dr,{items:Hr(w,p),position:U,marker:"rect",size:s,onToggle:g?O:void 0}):void 0,table:u?jsx(cr,{data:e,series:w,xKey:r.key,xLabel:r.label??r.key,formatX:F,formatValue:I,caption:typeof b=="string"?b:void 0}):void 0,className:W,...V,children:({width:z})=>jsx(O0,{width:z,height:n,data:e,resolvedSeries:w,x:r,y:x,grid:l,size:s,curve:C,stack:v,baseline:E,connectNulls:k,referenceLines:R,margin:P,tooltip:d,onPointClick:y,plotLabel:D,formatValue:S,formatRaw:I,formatX:F})})}var G0={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"},X0={circle:"rounded-full",square:"rounded-none",rounded:"rounded-md"};function K0({src:e,alt:t="Avatar",fallback:r,size:o="md",variant:n="circle",border:a=false,className:s,...l}){return jsx("div",{className:c("inline-flex items-center justify-center overflow-hidden bg-gray-200 font-medium text-gray-600 dark:bg-gray-700 dark:text-gray-300",G0[o],X0[n],a&&"ring-2 ring-white dark:ring-gray-900",s),...l,children:e?jsx("img",{src:e,alt:t,className:"h-full w-full object-cover"}):jsx("span",{children:r||t.charAt(0).toUpperCase()})})}var U0={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"}},Y0={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"},j0={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"},q0={sm:"w-1.5 h-1.5",md:"w-1.5 h-1.5",lg:"w-2 h-2"},Z0={sm:"w-2.5 h-2.5",md:"w-3 h-3",lg:"w-3.5 h-3.5"};function ml({children:e,color:t="default",size:r="md",variant:o="soft",dot:n=false,icon:a,pill:s=true,className:l,...i}){return jsxs("span",{className:c("inline-flex items-center font-medium",j0[r],s?"rounded-full":"rounded",U0[t][o],l),...i,children:[n&&jsx("span",{className:c("shrink-0 rounded-full",q0[r],Y0[t]),"aria-hidden":"true"}),a&&!n&&jsx("span",{className:c("shrink-0",Z0[r]),"aria-hidden":"true",children:a}),e]})}ml.displayName="Badge";var ep=24,yo=2,tp=4,ua=6,rp=10,op=memo(function({bars:t}){return jsx("g",{children:t.map((r,o)=>jsxs("g",{children:[jsx("path",{d:r.d,fill:r.color}),r.label?jsx("text",{x:r.label.x,y:r.label.y,textAnchor:r.label.anchor,dominantBaseline:"middle",className:"fill-gray-600 text-[10px] [font-variant-numeric:tabular-nums] dark:fill-gray-300",children:r.label.text}):null]},`${r.key}-${o}`))})});function np({width:e,height:t,data:r,resolvedSeries:o,x:n,y:a,grid:s,size:l,orientation:i,stack:d,barSize:u,showValues:p,referenceLines:b,margin:m,tooltip:f,onPointClick:h,plotLabel:y,formatValue:C,formatRaw:v,formatX:E}){let[k,R]=useState(null),g=useMemo(()=>{let w=i==="vertical",N=o.filter(ge=>!ge.hidden),x=N.map(ge=>ge.key),S=d!=="none",I=da(r,x,d),F=to({width:e,height:t,data:r,x:n,y:a,bounds:S?ca(I):Xt(Fr(r,x)),margin:m,orientation:i,placement:"band",formatValue:C,formatX:E,defaultIncludeZero:true}),{valueScale:O,bandwidth:Z,categoryPositions:U,innerWidth:H,innerHeight:z}=F,$=O(0),K=Math.max(1,N.length),se=S?Z:Z/K,X=Math.min(u??ep,Math.max(1,se-(S?0:yo))),ee=S?X:K*X+(K-1)*yo,L=(Z-ee)/2,q=[];return I.forEach((ge,de)=>{let Y=-1,le=-1;ge.segments.forEach((te,Ne)=>{te.value!==null&&(te.end>=te.start?Y=Ne:le=Ne);});let xe=0,Se=0;ge.segments.forEach((te,Ne)=>{if(te.value===null)return;let De=N[Ne],Ve=te.end>=te.start,rt=O(S?te.start:0),dt=O(te.end),re=Math.min(rt,dt),pe=Math.abs(dt-rt),Ue=Ve?xe===0:Se===0,yt=w?!Ve:Ve;S&&!Ue&&pe>yo&&(pe-=yo,yt&&(re+=yo)),Ve?xe+=1:Se+=1;let Re=U[de]+(S?L:L+Ne*(X+yo)),ft=Ne===(Ve?Y:le)?w?Ve?"top":"bottom":Ve?"right":"left":"none",rr=w?{x:Re,y:re,width:X,height:pe}:{x:re,y:Re,width:pe,height:X},ot=null;if(p&&!S){let Wt=v(te.value),Nt=hn(Wt,10);if(w){let Ht=Ve?re:re+pe,or=K>1?X+yo:Z;Nt<=or&&Ht-ua>8&&(ot={x:Re+X/2,y:(Ve?re:re+pe)-ua,anchor:"middle",text:Wt});}else {let Ht=Ve?re+pe:re;Ht+ua+Nt<=H&&(ot={x:Ht+ua,y:Re+X/2,anchor:"start",text:Wt});}}q.push({key:De.key,color:De.color,d:cl({...rr,radius:tp,round:ft}),label:ot});});}),{vertical:w,visible:N,rows:I,stacked:S,xValues:F.xValues,categoryPositions:U,categoryCenters:F.categoryCenters,bandwidth:Z,categoryTicks:F.categoryTicks,valueTicks:F.valueTicks,valueScale:O,baseline:$,innerWidth:H,innerHeight:z,margin:F.margin,bars:q}},[r,o,n,a,e,t,m,i,d,u,p,C,v,E]),P=useCallback(w=>g.visible.map((N,x)=>{let S=St(r[w],N.key),I=g.rows[w].segments[x],F=S===null?"\u2014":d==="percent"?`${v(S)} (${C(I.end-I.start)})`:C(S);return {seriesKey:N.key,seriesLabel:Lt(N),color:N.color,value:S,formattedValue:F,datum:r[w]}}),[r,g.visible,g.rows,d,C,v]),T=useCallback(w=>{if(f===false||r.length===0)return;let N=w.currentTarget.getBoundingClientRect(),x=g.vertical?w.clientX-N.left-g.margin.left:w.clientY-N.top-g.margin.top,S=Vo(g.categoryCenters,x);R(S>=0?S:null);},[f,r.length,g.vertical,g.margin,g.categoryCenters]),D=useCallback(w=>{if(r.length===0)return;let N=r.length-1,x=k??0,S=g.vertical?"ArrowRight":"ArrowDown",I=g.vertical?"ArrowLeft":"ArrowUp",F=w.key===S?Math.min(N,x+1):w.key===I?Math.max(0,x-1):w.key==="Home"?0:w.key==="End"?N:w.key==="Escape"?null:void 0;F!==void 0&&(w.preventDefault(),R(F));},[r.length,k,g.vertical]),W=useCallback(()=>{if(!h||k===null)return;let[w]=P(k);w&&h({...w,index:k,x:g.xValues[k]});},[h,k,P,g.xValues]),V=k===null?null:P(k),_=k===null||V===null?null:{x:g.xValues[k],xLabel:E(g.xValues[k],k),index:k,points:V},M=k===null?null:g.vertical?{x:g.margin.left+g.categoryCenters[k],y:g.margin.top+Math.min(...g.rows[k].segments.filter(w=>w.value!==null).map(w=>g.valueScale(w.end)),g.baseline)}:{x:g.margin.left+Math.max(...g.rows[k].segments.filter(w=>w.value!==null).map(w=>g.valueScale(w.end)),g.baseline),y:g.margin.top+g.categoryCenters[k]};return jsxs(Fragment,{children:[jsxs("svg",{width:e,height:t,role:"img","aria-label":y??g.visible.map(w=>Lt(w)).join(", "),tabIndex:0,className:"touch-none focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-blue-500",onPointerMove:T,onPointerLeave:()=>R(null),onKeyDown:D,onBlur:()=>R(null),onClick:W,children:[jsxs("g",{transform:`translate(${g.margin.left}, ${g.margin.top})`,children:[jsx(Wr,{width:g.innerWidth,height:g.innerHeight,horizontal:g.vertical&&(s==="y"||s==="both")?g.valueTicks.map(w=>w.offset):void 0,vertical:!g.vertical&&(s==="y"||s==="both")?g.valueTicks.map(w=>w.offset):void 0}),k!==null?jsx("rect",{x:g.vertical?g.categoryPositions[k]:0,y:g.vertical?0:g.categoryPositions[k],width:g.vertical?g.bandwidth:g.innerWidth,height:g.vertical?g.innerHeight:g.bandwidth,className:"fill-gray-400 dark:fill-gray-500",opacity:.12,"aria-hidden":"true"}):null,jsx(op,{bars:g.bars}),jsx("line",{x1:g.vertical?0:g.baseline,y1:g.vertical?g.baseline:0,x2:g.vertical?g.innerWidth:g.baseline,y2:g.vertical?g.baseline:g.innerHeight,className:"stroke-gray-300 dark:stroke-gray-600",strokeWidth:1,shapeRendering:"crispEdges"}),b?.map(w=>{let N=g.valueScale(w.value),x=N<rp?N+12:N-4;return jsxs("g",{children:[jsx("line",{x1:g.vertical?0:N,y1:g.vertical?N:0,x2:g.vertical?g.innerWidth:N,y2:g.vertical?N:g.innerHeight,stroke:w.color??"var(--color-chart-muted)",strokeWidth:1,strokeDasharray:w.dashed===false?void 0:"4 4"}),w.label?jsx("text",{x:g.vertical?g.innerWidth:N+4,y:g.vertical?x:8,textAnchor:g.vertical?"end":"start",className:"fill-gray-500 text-[10px] dark:fill-gray-400",children:w.label}):null]},`${w.value}-${w.label??""}`)})]}),jsx("g",{transform:`translate(${g.margin.left}, ${g.margin.top+g.innerHeight})`,children:(g.vertical?n.hidden:a?.hidden)?null:jsx(Ut,{orientation:"bottom",ticks:g.vertical?g.categoryTicks:g.valueTicks,length:g.innerWidth,label:g.vertical?n.label:a?.label,size:l})}),jsx("g",{transform:`translate(${g.margin.left}, ${g.margin.top})`,children:(g.vertical?a?.hidden:n.hidden)?null:jsx(Ut,{orientation:"left",ticks:g.vertical?g.valueTicks:g.categoryTicks,length:g.innerHeight,showLine:false,label:g.vertical?a?.label:n.label,size:l})})]}),_&&M&&f!==false?jsx(ur,{x:M.x,y:M.y,containerWidth:e,children:typeof f=="function"?f(_):jsx(pr,{title:_.xLabel,points:_.points})}):null]})}function ap({data:e,series:t,x:r,y:o,height:n=260,width:a,size:s="md",grid:l="y",legend:i,tooltip:d=true,tableView:u=false,emphasis:p,title:b,description:m,loading:f=false,emptyState:h,onPointClick:y,orientation:C="vertical",stack:v="none",barSize:E,sort:k="none",showValues:R=false,referenceLines:g,legendToggle:P=true,margin:T,locale:D,plotLabel:W,className:V,..._}){let[M,w]=useState(()=>new Set),N=useMemo(()=>t.map((K,se)=>({...K,hidden:K.hidden||M.has(K.key),color:Cr(K,se,p)})),[t,M,p]),x=useMemo(()=>{if(k==="none")return e;let K=N.filter(X=>!X.hidden).map(X=>X.key),se=X=>K.reduce((ee,L)=>ee+(St(X,L)??0),0);return [...e].sort((X,ee)=>k==="asc"?se(X)-se(ee):se(ee)-se(X))},[e,k,N]),S=v==="percent",I=useMemo(()=>S?{domain:[0,100],...o}:o,[S,o]),F=useMemo(()=>K=>_t(K,D),[D]),O=useMemo(()=>o?.format??(S?K=>Br(K,{locale:D,alreadyScaled:true,maximumFractionDigits:0}):F),[o?.format,S,D,F]),Z=useMemo(()=>r.format??(K=>Gt(K,D)),[r.format,D]),U=useCallback(K=>{w(se=>{let X=new Set(se);return X.has(K)?X.delete(K):X.add(K),X});},[]),H=i===void 0?t.length>=2:i!==false,z=typeof i=="string"?i:"bottom",$=N.filter(K=>!K.hidden).length;return jsx(lr,{title:b,description:m,height:n,width:a,size:s,loading:f,empty:e.length===0||$===0,emptyState:h,tableView:u,legendPosition:z,legend:H?jsx(dr,{items:Hr(N,p),position:z,marker:"rect",size:s,onToggle:P?U:void 0}):void 0,table:u?jsx(cr,{data:x,series:N,xKey:r.key,xLabel:r.label??r.key,formatX:Z,formatValue:F,caption:typeof b=="string"?b:void 0}):void 0,className:V,..._,children:({width:K})=>jsx(np,{width:K,height:n,data:x,resolvedSeries:N,x:r,y:I,grid:l,size:s,orientation:C,stack:v,barSize:E,showValues:R,referenceLines:g,margin:T,tooltip:d,onPointClick:y,plotLabel:W,formatValue:O,formatRaw:F,formatX:Z})})}function bl({className:e}){return jsx("svg",{className:e,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",children: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 ip({className:e}){return jsx("svg",{className:e,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",children: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 lp({className:e}){return jsx("svg",{className:e,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",children: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 dp({className:e}){return jsx("svg",{className:e,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",children: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 Cs({className:e}){return jsx("svg",{className:e,viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",children:jsx("path",{d:"M4 4L12 12M12 4L4 12",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})})}var cp={info:bl,success:ip,warning:lp,error:dp,default:bl},up={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"},pp={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 gp({type:e="default",title:t,description:r,children:o,icon:n,action:a,closable:s=false,onClose:l,fullWidth:i=false,className:d,...u}){let[p,b]=useState(true);if(!p)return null;let m=()=>{b(false),l?.();},f=cp[e],h=o??r;return jsxs("div",{role:"alert",className:c("flex items-start gap-3 border px-4 py-3",i?"w-full":"rounded-lg",up[e],d),...u,children:[jsx("div",{className:c("shrink-0 mt-0.5",pp[e]),children:n??jsx(f,{className:"w-5 h-5"})}),jsxs("div",{className:"flex-1 min-w-0",children:[t&&jsx("div",{className:"font-semibold text-sm",children:t}),h&&jsx("div",{className:c("text-sm",t?"mt-1 opacity-90":false),children:h}),a&&jsx("div",{className:"mt-3",children:a})]}),s&&jsx("button",{type:"button",onClick:m,className:c("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:jsx(Cs,{className:"w-4 h-4"})})]})}function mp({title:e,description:t,children:r,action:o,backgroundImage:n,closable:a=false,onClose:s,fullWidth:l=false,className:i,...d}){let[u,p]=useState(true);if(!u)return null;let b=()=>{p(false),s?.();},m=r??t;return jsxs("div",{className:c("relative overflow-hidden bg-gray-900 text-white",l?"w-full":"rounded-xl","py-12 px-6 sm:px-12",i),style:n?{backgroundImage:`url(${n})`,backgroundSize:"cover",backgroundPosition:"center"}:void 0,...d,children:[n&&jsx("div",{className:"absolute inset-0 bg-black/50","aria-hidden":"true"}),jsxs("div",{className:"relative z-10 max-w-3xl mx-auto text-center",children:[e&&jsx("h2",{className:"text-2xl sm:text-3xl lg:text-4xl font-bold tracking-tight",children:e}),m&&jsx("div",{className:c("text-base sm:text-lg opacity-90",e?"mt-4":false),children:m}),o&&jsx("div",{className:"mt-6",children:o})]}),a&&jsx("button",{type:"button",onClick:b,className:c("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:jsx(Cs,{className:"w-5 h-5"})})]})}function fp({title:e,description:t,children:r,icon:o,action:n,badge:a,closable:s=false,onClose:l,fullWidth:i=false,className:d,...u}){let[p,b]=useState(true);if(!p)return null;let m=()=>{b(false),l?.();},f=r??t;return jsxs("div",{className:c("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",d),...u,children:[o&&jsx("div",{className:"shrink-0",children:o}),a&&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}),jsxs("div",{className:"flex-1 min-w-0 flex flex-wrap items-center gap-x-4 gap-y-1",children:[e&&jsx("span",{className:"font-semibold text-sm",children:e}),f&&jsx("span",{className:"text-sm opacity-90",children:f})]}),n&&jsx("div",{className:"shrink-0",children:n}),s&&jsx("button",{type:"button",onClick:m,className:c("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:jsx(Cs,{className:"w-4 h-4"})})]})}function hl({variant:e="notification",...t}){switch(e){case "hero":return jsx(mp,{...t});case "promotion":return jsx(fp,{...t});default:return jsx(gp,{...t})}}hl.displayName="Banner";var bp={sm:"text-xs",md:"text-sm",lg:"text-base"};function hp({items:e,separator:t="/",size:r="md",maxItems:o,itemColor:n="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 d=e,u=false;if(o&&e.length>o){u=true;let p=e[0],b=e.slice(-(o-1));d=[p,...b];}return jsx("nav",{"aria-label":"Breadcrumb",className:c("inline-flex items-center",bp[r],l),...i,children:jsx("ol",{className:"inline-flex items-center space-x-1 md:space-x-2",children:d.map((p,b)=>{let m=b===d.length-1;return jsxs("li",{className:"inline-flex items-center",children:[u&&b===1&&jsxs(Fragment,{children:[jsx("span",{className:c("mx-1 select-none",s),children:"..."}),jsx("span",{className:c("mx-1 select-none",s),"aria-hidden":"true",children:t})]}),p.href||p.onClick?jsxs("a",{href:p.href,onClick:p.onClick,className:c("inline-flex items-center gap-1.5 transition-colors",m?a:n),"aria-current":m?"page":void 0,children:[p.icon&&jsx("span",{className:"inline-flex","aria-hidden":"true",children:p.icon}),jsx("span",{children:p.label})]}):jsxs("span",{className:c("inline-flex items-center gap-1.5",m?a:n),"aria-current":m?"page":void 0,children:[p.icon&&jsx("span",{className:"inline-flex","aria-hidden":"true",children:p.icon}),jsx("span",{children:p.label})]}),!m&&jsx("span",{className:c("mx-2 select-none",s),"aria-hidden":"true",children:t})]},p.href??p.label)})})})}function xp({className:e}){return jsxs("svg",{className:c("animate-spin",e),xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24","aria-hidden":"true",children:[jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),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 vp={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"},kp={sm:"p-1.5",md:"p-2",lg:"p-2.5",xl:"p-3"},ga={sm:"h-3.5 w-3.5",md:"h-4 w-4",lg:"h-5 w-5",xl:"h-6 w-6"},wp={none:"rounded-none",sm:"rounded-sm",md:"rounded-md",lg:"rounded-lg",full:"rounded-full"};function gt({label:e,children:t,onClick:r,disabled:o=false,className:n,type:a="button",size:s="md",loading:l=false,leftIcon:i,rightIcon:d,icon:u,fullWidth:p=false,rounded:b="lg",bgColor:m="bg-blue-600 hover:bg-blue-700",textColor:f="text-white",focusColor:h="focus:ring-blue-300",selected:y=false,value:C,showFocusOnClick:v=false,...E}){let k=o||l,R=u!==void 0&&!t&&!e,g=c("inline-flex items-center justify-center font-medium transition-colors focus:outline-none disabled:opacity-50 disabled:cursor-not-allowed",v?"focus:ring-4":"focus-visible:ring-4"),P=c(y?"bg-blue-700 text-white ring-2 ring-blue-500":m,!y&&f,h&&v&&`focus:ring-4 ${h}`,h&&!v&&`focus-visible:ring-4 ${h}`);return jsx("button",{type:a,onClick:r,disabled:k,"data-value":C,className:c(g,R?kp[s]:vp[s],wp[b],P,p&&"w-full",n),...E,children:l?jsx(xp,{className:ga[s]}):R?jsx("span",{className:ga[s],children:u}):jsxs(Fragment,{children:[i&&jsx("span",{className:ga[s],children:i}),t??e,d&&jsx("span",{className:ga[s],children:d})]})})}function Go({children:e,orientation:t="horizontal",size:r,fullWidth:o=false,selectedValue:n,onChange:a,className:s}){let i=Ns__default.Children.toArray(e).filter(u=>Ns__default.isValidElement(u)&&typeof u.type!="string"),d=(u,p)=>b=>{u!==void 0&&a&&a(u),p&&p(b);};return jsx("div",{className:c("inline-flex",t==="horizontal"?"flex-row":"flex-col",o&&"w-full",s),role:"group",children:i.map((u,p)=>{let b=p===0,m=p===i.length-1,f=!b&&!m,h=u.props.value,y=n!==void 0&&h===n,C=c(t==="horizontal"&&b&&"rounded-r-none",t==="horizontal"&&m&&"rounded-l-none",t==="horizontal"&&f&&"rounded-none",t==="horizontal"&&!b&&"-ml-px",t==="vertical"&&b&&"rounded-b-none",t==="vertical"&&m&&"rounded-t-none",t==="vertical"&&f&&"rounded-none",t==="vertical"&&!b&&"-mt-px",o&&"flex-1");return Ns__default.cloneElement(u,{...u.props,size:r??u.props.size,selected:y||u.props.selected,onClick:d(h,u.props.onClick),className:c(C,u.props.className)})})})}var Rp=10080*60*1e3;function kt(e){return new Date(e.getFullYear(),e.getMonth(),e.getDate())}function wo(e){return new Date(e.getFullYear(),e.getMonth(),1)}function $r(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 Rs(e){return new Date(e.getFullYear(),e.getMonth()+1,0).getDate()}function Sr(e,t){return !e||!t?false:e.getFullYear()===t.getFullYear()&&e.getMonth()===t.getMonth()&&e.getDate()===t.getDate()}function Ss(e,t){return e.getFullYear()===t.getFullYear()&&e.getMonth()===t.getMonth()}function oo(e,t){return e.getFullYear()*12+e.getMonth()-(t.getFullYear()*12+t.getMonth())}function fa(e){let t=`${e.getMonth()+1}`.padStart(2,"0"),r=`${e.getDate()}`.padStart(2,"0");return `${e.getFullYear()}-${t}-${r}`}function Tp(e){let t=kt(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())/Rp)}function vl(e,t,r){return t&&e<kt(t)?kt(t):r&&e>kt(r)?kt(r):e}function Pp(e,t,r){let o=wo(e),n=(o.getDay()-t+7)%7,a=$r(o,-n),s=r?6:Math.ceil((n+Rs(e))/7);return Array.from({length:s},(l,i)=>Array.from({length:7},(d,u)=>$r(a,i*7+u)))}function Ep({className:e}){return jsx("svg",{className:e,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24","aria-hidden":"true",children:jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M15 19l-7-7 7-7"})})}function Dp({className:e}){return jsx("svg",{className:e,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24","aria-hidden":"true",children:jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 5l7 7-7 7"})})}var Ip={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"}},Mp={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"},Lp={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"},Ap={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"},zp={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"},ko={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 ba(e,t){if(e==="multiple")return Array.isArray(t)?t.map(kt):[];if(e==="range"){let r=t??null;return {from:r?.from?kt(r.from):null,to:r?.to?kt(r.to):null}}return t instanceof Date?kt(t):null}function kl(e){return e?e instanceof Date?e:Array.isArray(e)?e[0]??null:e.from??e.to??null:null}function Wp(e){let{mode:t="single",value:r,defaultValue:o,onChange:n,max:a,month:s,defaultMonth:l,onMonthChange:i,numberOfMonths:d=1,weekStartsOn:u=0,locale:p,size:b="md",color:m="primary",minDate:f,maxDate:h,disabledDates:y,disabled:C=false,showOutsideDays:v=true,showWeekNumbers:E=false,fixedWeeks:k=false,captionLayout:R="label",fromYear:g,toYear:P,todayButton:T=false,clearButton:D=false,footer:W,bordered:V=true,renderDay:_,labels:M,className:w,...N}=e,x=Ip[b],S=Math.max(1,d),I=useMemo(()=>kt(new Date),[]),F=r!==void 0,[O,Z]=useState(()=>ba(t,o)),U=F?ba(t,r):O,H=s!==void 0,[z,$]=useState(()=>wo(l??kl(ba(t,o??r))??new Date)),K=H?wo(s):z,se=useCallback(fe=>{let he=wo(fe);H||$(he),i?.(he);},[H,i]),X=useRef(null),ee=useRef(false),[L,q]=useState(()=>{let fe=kl(ba(t,o??r)),he=wo(l??s??fe??new Date),j=fe&&Ss(fe,he)?fe:Ss(kt(new Date),he)?kt(new Date):he;return vl(j,f,h)}),ge=gr(K,S-1),Y=oo(L,K)>=0&&oo(L,ge)<=0?L:K;useEffect(()=>{if(!ee.current)return;ee.current=false,X.current?.querySelector(`[data-day="${fa(L)}"]:not([data-outside])`)?.focus();},[L,K]);let le=useCallback(fe=>{let he=vl(kt(fe),f,h);ee.current=true,q(he);let j=gr(K,S-1);oo(he,K)<0?se(he):oo(he,j)>0&&se(gr(he,-(S-1)));},[K,S,f,h,se]),xe=useCallback(fe=>C||f&&fe<kt(f)||h&&fe>kt(h)?true:typeof y=="function"?y(fe):Array.isArray(y)?y.some(he=>Sr(he,fe)):false,[C,f,h,y]),[Se,te]=useState(null),Ne=useCallback(fe=>{F||Z(fe),n?.(fe);},[F,n]),De=useCallback(fe=>{let he=kt(fe);if(xe(he))return;if(t==="multiple"){let J=U??[];if(J.some(ue=>Sr(ue,he))){Ne(J.filter(ue=>!Sr(ue,he)));return}if(a!==void 0&&J.length>=a)return;Ne([...J,he].sort((ue,Te)=>ue.getTime()-Te.getTime()));return}if(t==="range"){let J=U??{from:null,to:null};if(!J.from||J.to){Ne({from:he,to:null});return}Ne(he<J.from?{from:he,to:J.from}:{from:J.from,to:he});return}Ne(Sr(U,he)?null:he);},[t,U,a,Ne,xe]),Ve=useCallback(fe=>{De(fe),q(kt(fe)),oo(fe,K)<0?se(fe):oo(fe,gr(K,S-1))>0&&se(gr(fe,-(S-1)));},[De,K,S,se]),rt=!C&&(!f||oo(K,wo(f))>0),dt=!C&&(!h||oo(gr(K,S-1),wo(h))<0),re=useCallback(()=>{se(gr(K,-1));},[K,se]),pe=useCallback(()=>{se(gr(K,1));},[K,se]),Ue=useCallback(fe=>{if(C)return;let he=L;switch(fe.key){case "ArrowLeft":fe.preventDefault(),le($r(he,-1));break;case "ArrowRight":fe.preventDefault(),le($r(he,1));break;case "ArrowUp":fe.preventDefault(),le($r(he,-7));break;case "ArrowDown":fe.preventDefault(),le($r(he,7));break;case "Home":fe.preventDefault(),le($r(he,-((he.getDay()-u+7)%7)));break;case "End":fe.preventDefault(),le($r(he,6-(he.getDay()-u+7)%7));break;case "PageUp":{fe.preventDefault();let j=fe.shiftKey?-12:-1,J=gr(he,j),me=Math.min(he.getDate(),Rs(J));le(new Date(J.getFullYear(),J.getMonth(),me));break}case "PageDown":{fe.preventDefault();let j=fe.shiftKey?12:1,J=gr(he,j),me=Math.min(he.getDate(),Rs(J));le(new Date(J.getFullYear(),J.getMonth(),me));break}}},[C,L,le,u]),yt=useMemo(()=>{let fe=new Intl.DateTimeFormat(p,{weekday:"short"}),he=new Intl.DateTimeFormat(p,{weekday:"long"}),j=new Date(2024,0,7);return Array.from({length:7},(J,me)=>{let ue=$r(j,(u+me)%7);return {short:fe.format(ue),long:he.format(ue)}})},[p,u]),Re=useMemo(()=>{let fe=new Intl.DateTimeFormat(p,{month:"long"});return Array.from({length:12},(he,j)=>fe.format(new Date(2024,j,1)))},[p]),We=useMemo(()=>new Intl.DateTimeFormat(p,{month:"long",year:"numeric"}),[p]),ft=useMemo(()=>new Intl.DateTimeFormat(p,{dateStyle:"full"}),[p]),rr=useMemo(()=>{if(R!=="dropdown")return [];let fe=I.getFullYear(),he=g??f?.getFullYear()??fe-100,j=P??h?.getFullYear()??fe+10;return j<he?[he]:Array.from({length:j-he+1},(J,me)=>he+me)},[R,g,P,f,h,I]),ot=t==="range"?U:null,Wt=ot&&ot.from&&!ot.to&&Se&&Se>ot.from?Se:null,Nt=ot?.to??Wt,Ht=useCallback((fe,he)=>{let j=!Ss(fe,he),J=xe(fe),me=false,ue=false,Te=false,ve=false;return t==="multiple"?me=(U??[]).some(we=>Sr(we,fe)):t==="range"?(ue=Sr(ot?.from,fe),Te=Sr(Nt,fe),me=ue||Te,ve=!!(ot?.from&&Nt&&fe>ot.from&&fe<Nt)):me=Sr(U,fe),{selected:me,today:Sr(fe,I),outside:j,disabled:J,rangeStart:ue,rangeEnd:Te,inRange:ve}},[t,U,ot,Nt,xe,I]),or=fe=>{let he=gr(K,fe),j=Pp(he,u,k),J=fe===0,me=fe===S-1;return jsxs("div",{className:"flex flex-col",children:[jsxs("div",{className:"mb-2 flex items-center justify-between",children:[jsx("button",{type:"button",onClick:re,disabled:!rt,"aria-label":M?.previousMonth??"Previous month",className:c("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",ko[m],x.nav,!rt&&"cursor-not-allowed opacity-40 hover:bg-transparent dark:hover:bg-transparent",!J&&"invisible"),children:jsx(Ep,{className:x.icon})}),R==="dropdown"?jsxs("div",{className:"flex items-center gap-1",children:[jsx("select",{"aria-label":M?.monthSelect??"Month",value:he.getMonth(),disabled:C,onChange:ue=>se(new Date(he.getFullYear(),Number(ue.target.value)-fe,1)),className:c("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",ko[m],x.select,C&&"cursor-not-allowed opacity-50"),children:Re.map((ue,Te)=>jsx("option",{value:Te,children:ue},ue))}),jsx("select",{"aria-label":M?.yearSelect??"Year",value:he.getFullYear(),disabled:C,onChange:ue=>se(new Date(Number(ue.target.value),he.getMonth()-fe,1)),className:c("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",ko[m],x.select,C&&"cursor-not-allowed opacity-50"),children:rr.map(ue=>jsx("option",{value:ue,children:ue},ue))})]}):jsx("div",{"aria-live":"polite",className:c("font-semibold text-gray-900 dark:text-gray-100",x.caption),children:We.format(he)}),jsx("button",{type:"button",onClick:pe,disabled:!dt,"aria-label":M?.nextMonth??"Next month",className:c("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",ko[m],x.nav,!dt&&"cursor-not-allowed opacity-40 hover:bg-transparent dark:hover:bg-transparent",!me&&"invisible"),children:jsx(Dp,{className:x.icon})})]}),jsxs("table",{role:"grid","aria-label":We.format(he),className:"border-collapse",children:[jsx("thead",{children:jsxs("tr",{children:[E&&jsxs("th",{scope:"col",className:c("font-normal text-gray-400 dark:text-gray-500",x.head),children:[jsx("span",{className:"sr-only",children:M?.weekNumber??"Week number"}),jsx("span",{"aria-hidden":"true",children:"#"})]}),yt.map(ue=>jsx("th",{scope:"col",abbr:ue.long,className:c("font-medium uppercase text-gray-500 dark:text-gray-400",x.head),children:ue.short},ue.long))]})}),jsx("tbody",{children:j.map(ue=>jsxs("tr",{children:[E&&jsx("td",{className:c("text-center align-middle text-gray-400 dark:text-gray-500",x.head),children:Tp(ue[0])}),ue.map(Te=>{let ve=Ht(Te,he),we=fa(Te);if(ve.outside&&!v)return jsx("td",{className:"p-0"},we);let He=Sr(Te,Y)&&!ve.outside,Me=ve.inRange||ve.rangeStart&&!!Nt||ve.rangeEnd&&!!ot?.from;return jsx("td",{role:"presentation",className:c("p-0",Me&&Lp[m],Me&&ve.rangeStart&&"rounded-l-full",Me&&ve.rangeEnd&&"rounded-r-full"),children:jsx("button",{type:"button","data-day":we,"data-selected":ve.selected||void 0,"data-today":ve.today||void 0,"data-outside":ve.outside||void 0,role:"gridcell",tabIndex:He?0:-1,disabled:C,"aria-selected":ve.selected,"aria-disabled":ve.disabled||void 0,"aria-current":ve.today?"date":void 0,"aria-label":ft.format(Te),onClick:()=>{ve.disabled||Ve(Te);},onMouseEnter:()=>t==="range"&&te(kt(Te)),onMouseLeave:()=>t==="range"&&te(null),onFocus:()=>q(kt(Te)),className:c("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",ko[m],x.day,ve.selected?Mp[m]:ve.inRange?c(Ap[m],"hover:bg-gray-200/60 dark:hover:bg-gray-600/60"):ve.today?c(zp[m],"hover:bg-gray-100 dark:hover:bg-gray-700"):c("text-gray-900 dark:text-gray-100","hover:bg-gray-100 dark:hover:bg-gray-700"),ve.outside&&!ve.selected&&"text-gray-400 dark:text-gray-500",ve.disabled&&"cursor-not-allowed opacity-40 hover:bg-transparent dark:hover:bg-transparent"),children:_?_(Te,ve):Te.getDate()})},we)})]},fa(ue[0])))})]})]},fa(he))},Zt=useCallback(()=>{se(I),q(I),xe(I)||De(I);},[I,se,xe,De]),Ar=useCallback(()=>{Ne(t==="multiple"?[]:t==="range"?{from:null,to:null}:null);},[t,Ne]),br=!!W||T||D;return jsxs("div",{ref:X,onKeyDown:Ue,className:c("inline-block bg-white dark:bg-gray-900",V&&"rounded-lg border border-gray-200 shadow-sm dark:border-gray-700",x.padding,C&&"opacity-60",w),...N,children:[jsx("div",{className:c("flex flex-wrap",x.gap),children:Array.from({length:S},(fe,he)=>or(he))}),br&&jsxs("div",{className:c("mt-3 flex items-center justify-between gap-2 border-t border-gray-200 pt-3 dark:border-gray-700",x.footer),children:[jsx("div",{className:"text-gray-600 dark:text-gray-400",children:W}),(T||D)&&jsxs("div",{className:"flex items-center gap-2",children:[T&&jsx("button",{type:"button",onClick:Zt,disabled:C,className:c("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",ko[m],C&&"cursor-not-allowed opacity-50"),children:M?.today??"Today"}),D&&jsx("button",{type:"button",onClick:Ar,disabled:C,className:c("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",ko[m],C&&"cursor-not-allowed opacity-50"),children:M?.clear??"Clear"})]})]})]})}function Hp(e,t,r){let o=r||"bg-white dark:bg-gray-800",n=t||"border-gray-200 dark:border-gray-700";switch(e){case "outlined":return c("border-2 bg-transparent",n);case "elevated":return c("shadow-lg border-0",o);case "filled":return c(r||"bg-gray-100 dark:bg-gray-700","border-0");default:return c("border",n,o)}}function Fp(e){switch(e){case "sm":return "max-w-sm";case "lg":return "max-w-2xl";default:return "max-w-md"}}function Bp(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 Vp(e){switch(e){case "none":return "";case "sm":return "p-2";case "lg":return "p-6";default:return ""}}function wl({variant:e="default",size:t="md",rounded:r="lg",padding:o="none",bgColor:n,borderColor:a,shadowColor:s,hoverable:l=false,clickable:i=false,as:d="div",className:u,children:p,onClick:b,...m}){let f=d,h=l?"transition-all duration-200 hover:shadow-lg hover:-translate-y-0.5":"",y=i?"cursor-pointer active:scale-[0.98] transition-transform":"",C=s||"";return jsx(f,{className:c("overflow-hidden",Hp(e,a,n),Fp(t),Bp(r),Vp(o),h,y,C,u),onClick:i||b?b:void 0,...m,children:p})}wl.displayName="Card";function $p(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 Nl({actions:e,divider:t=false,padding:r="md",className:o,children:n,...a}){return jsxs("div",{className:c("flex items-center justify-between",$p(r),t&&"border-b border-gray-200 dark:border-gray-700",o),...a,children:[jsx("div",{className:"flex-1",children:n}),e&&jsx("div",{className:"flex items-center gap-2 ml-4",children:e})]})}Nl.displayName="CardHeader";function Gp(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 Sl({padding:e="md",className:t,children:r,...o}){return jsx("div",{className:c(Gp(e),t),...o,children:r})}Sl.displayName="CardBody";function Kp(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 Up(e){switch(e){case "center":return "justify-center";case "right":return "justify-end";case "between":return "justify-between";default:return "justify-start"}}function Rl({divider:e=false,align:t="left",padding:r="md",className:o,children:n,...a}){return jsx("div",{className:c("flex items-center gap-2",Kp(r),Up(t),e&&"border-t border-gray-200 dark:border-gray-700",o),...a,children:n})}Rl.displayName="CardFooter";function jp(e){switch(e){case "square":return "aspect-square";case "video":return "aspect-video";case "wide":return "aspect-[21/9]";default:return ""}}function qp(e){switch(e){case "contain":return "object-contain";case "fill":return "object-fill";case "none":return "object-none";default:return "object-cover"}}function Tl({position:e="top",aspectRatio:t="auto",objectFit:r="cover",src:o,alt:n,className:a,...s}){let l=e==="top"?"rounded-t-lg":"rounded-b-lg";return jsx("img",{src:o,alt:n,className:c("w-full",jp(t),qp(r),l,a),...s})}Tl.displayName="CardImage";function Jp(e){switch(e){case "sm":return "text-base font-medium";case "lg":return "text-2xl font-bold";default:return "text-xl font-semibold"}}function Pl({as:e="h3",size:t="md",className:r,children:o,...n}){return jsx(e,{className:c("text-gray-900 dark:text-white",Jp(t),r),...n,children:o})}Pl.displayName="CardTitle";function eg(e){switch(e){case "sm":return "text-xs";case "lg":return "text-base";default:return "text-sm"}}function El({size:e="md",className:t,children:r,...o}){return jsx("p",{className:c("text-gray-500 dark:text-gray-400",eg(e),t),...o,children:r})}El.displayName="CardDescription";var ig=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"}}},lg=e=>{switch(e){case "circle":return "rounded-full";case "rounded":return "rounded-md";default:return "rounded"}},dg=({className:e})=>jsx("svg",{className:e,viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:jsx("path",{d:"M13.5 4.5L6 12L2.5 8.5",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round"})}),cg=({className:e})=>jsx("svg",{className:e,viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:jsx("path",{d:"M3 8H13",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round"})}),Rn=forwardRef(({checked:e,defaultChecked:t=false,onChange:r,disabled:o=false,readOnly:n=false,required:a=false,name:s,value:l,id:i,label:d,description:u,error:p=false,size:b="md",labelPosition:m="right",checkedColor:f="bg-blue-600",uncheckedColor:h="bg-white dark:bg-gray-800",borderColor:y="border-gray-300 dark:border-gray-600",labelColor:C,errorColor:v="text-red-500",checkmarkColor:E="text-white",hoverColor:k,focusRingColor:R="ring-blue-500",indeterminate:g=false,icon:P,variant:T="default",shape:D="square",animation:W=true,showFocusRing:V=true,className:_,containerClassName:M,style:w,tabIndex:N,...x},S)=>{let I=useId(),F=i||I,O=`${F}-error`,Z=`${F}-description`,[U,H]=useState(t),z=e!==void 0,$=z?e:U,K=useRef(null);useEffect(()=>{K.current&&(K.current.indeterminate=g);},[g]);let se=de=>{if(o||n)return;let Y=de.target.checked;z||H(Y),r?.(Y,de);},X=ig(b),ee=lg(D),L=()=>{let de=c("relative flex items-center justify-center border-2 transition-all",X.checkbox,ee,W&&"duration-200 ease-in-out");return o?c(de,"opacity-50 cursor-not-allowed",$||g?f:h,y):T==="filled"?c(de,$||g?f:"bg-gray-100 dark:bg-gray-700",$||g?"border-transparent":y,k&&!n&&`hover:${k}`,"cursor-pointer"):T==="outlined"?c(de,h,$||g?`border-current ${f.replace("bg-","text-")}`:y,"border-2",k&&!n&&`hover:${k}`,"cursor-pointer"):c(de,$||g?f:h,$||g?"border-transparent":y,k&&!n&&`hover:${k}`,"cursor-pointer")},q=p!==false,ge=typeof p=="string"?p:void 0;return jsxs("div",{className:c("inline-flex flex-col",M),children:[jsxs("label",{htmlFor:F,className:c("inline-flex items-start gap-2",o?"cursor-not-allowed":"cursor-pointer",m==="left"&&"flex-row-reverse justify-end"),children:[jsx("input",{ref:de=>{K&&(K.current=de),typeof S=="function"?S(de):S&&(S.current=de);},type:"checkbox",id:F,name:s,value:l,checked:$,onChange:se,disabled:o,readOnly:n,required:a,tabIndex:n?-1:N,"aria-invalid":q,"aria-describedby":c(ge&&O,u&&Z),className:"sr-only peer",style:w,...x}),jsx("span",{className:c(L(),V&&`peer-focus-visible:ring-2 peer-focus-visible:ring-offset-2 peer-focus-visible:${R}`,W&&$&&"scale-100",q&&"border-red-500"),"aria-hidden":"true",children:($||g)&&jsx("span",{className:c(E,W&&"animate-in zoom-in-50 duration-200"),children:g?P||jsx(cg,{className:"w-full h-full"}):P||jsx(dg,{className:"w-full h-full"})})}),d&&jsxs("span",{className:"flex flex-col gap-1",children:[jsxs("span",{className:c(X.label,o&&"opacity-50",C,q&&v),children:[d,a&&jsx("span",{className:"text-red-500 ml-1",children:"*"})]}),u&&jsx("span",{id:Z,className:c(X.description,"text-gray-500 dark:text-gray-400",o&&"opacity-50"),children:u})]})]}),ge&&jsx("p",{id:O,className:c("mt-1 text-xs",v),children:ge})]})});Rn.displayName="Checkbox";var Dl=createContext(null),Il=({label:e,description:t,value:r,defaultValue:o=[],onChange:n,orientation:a="vertical",spacing:s="md",disabled:l=false,size:i="md",error:d=false,required:u=false,children:p,className:b,labelClassName:m,...f})=>{let[h,y]=Ns.useState(o),C=r!==void 0,v=C?r:h,E=Ns.useCallback(T=>{let D=v.includes(T)?v.filter(W=>W!==T):[...v,T];C||y(D),n?.(D);},[v,C,n]),k=Ns.useMemo(()=>({value:v,onChange:E,disabled:l,size:i}),[v,E,l,i]),R={sm:a==="vertical"?"gap-2":"gap-3",md:a==="vertical"?"gap-3":"gap-4",lg:a==="vertical"?"gap-4":"gap-6"},g=d!==false,P=typeof d=="string"?d:void 0;return jsxs("div",{className:c("flex flex-col gap-2",b),...f,children:[(e||t)&&jsxs("div",{className:"flex flex-col gap-1",children:[e&&jsxs("label",{className:c("text-sm font-medium text-gray-900 dark:text-gray-100",l&&"opacity-50",g&&"text-red-500",m),children:[e,u&&jsx("span",{className:"text-red-500 ml-1",children:"*"})]}),t&&jsx("p",{className:c("text-xs text-gray-500 dark:text-gray-400",l&&"opacity-50"),children:t})]}),jsx(Dl.Provider,{value:k,children:jsx("div",{className:c("flex",a==="vertical"?"flex-col":"flex-row flex-wrap",R[s]),role:"group",children:p})}),P&&jsx("p",{className:"text-xs text-red-500",children:P})]})};Il.displayName="CheckboxGroup";var Ml=({value:e,disabled:t,size:r,...o})=>{let n=useContext(Dl);if(!n)return console.warn("CheckboxGroupItem doit \xEAtre utilis\xE9 dans un CheckboxGroup"),jsx(Rn,{...o,disabled:t,size:r});let{value:a,onChange:s,disabled:l,size:i}=n,d=a.includes(e);return jsx(Rn,{...o,checked:d,onChange:()=>s(e),disabled:l||t,size:r||i})};Ml.displayName="CheckboxGroupItem";var At={compact:"px-3 py-1.5",default:"px-4 py-3",comfortable:"px-6 py-4"},xa={compact:"text-xs",default:"text-sm",comfortable:"text-base"},bg=()=>jsx("svg",{className:"w-3.5 h-3.5",viewBox:"0 0 16 16",fill:"currentColor",children:jsx("path",{d:"M8 3l4 5H4l4-5z"})}),hg=()=>jsx("svg",{className:"w-3.5 h-3.5",viewBox:"0 0 16 16",fill:"currentColor",children:jsx("path",{d:"M8 13l4-5H4l4 5z"})}),yg=()=>jsx("svg",{className:"w-3.5 h-3.5 opacity-30",viewBox:"0 0 16 16",fill:"currentColor",children:jsx("path",{d:"M8 3l3 4H5l3-4zM8 13l3-4H5l3 4z"})}),Ll=({className:e})=>jsx("svg",{className:c("w-4 h-4",e),viewBox:"0 0 20 20",fill:"currentColor",children: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"})}),xg=()=>jsx("svg",{className:"w-4 h-4 text-gray-400",viewBox:"0 0 20 20",fill:"currentColor",children: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"})}),vg=()=>jsx("svg",{className:"w-4 h-4 text-gray-400",viewBox:"0 0 20 20",fill:"currentColor",children: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"})}),kg=()=>jsx("svg",{className:"w-3.5 h-3.5",viewBox:"0 0 20 20",fill:"currentColor",children: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"})}),wg=()=>jsxs("svg",{className:"w-4 h-4",viewBox:"0 0 20 20",fill:"currentColor",children:[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"}),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"})]}),Cg=()=>jsx("svg",{className:"w-4 h-4",viewBox:"0 0 20 20",fill:"currentColor",children: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 ya(e,t,r){return typeof r=="function"?r(e,t):String(typeof r=="string"?e[r]:t)}function Tr(e,t){return e[t]}function Ng(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 Sg(e,t){let r=String(e??"").toLowerCase(),o=t.value.toLowerCase();switch(t.operator){case "contains":return r.includes(o);case "equals":return r===o;case "startsWith":return r.startsWith(o);case "endsWith":return r.endsWith(o);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 Al(e,t,r){let o=[];for(let n of e){let a=Number(Tr(n,t));isNaN(a)||o.push(a);}if(o.length===0)return 0;switch(r){case "sum":return o.reduce((n,a)=>n+a,0);case "avg":return o.reduce((n,a)=>n+a,0)/o.length;case "count":return o.length;case "min":return Math.min(...o);case "max":return Math.max(...o)}}function Rg({cols:e,density:t}){return jsx("tr",{className:"border-b border-gray-200 dark:border-gray-700",children:Array.from({length:e}).map((r,o)=>jsx("td",{className:At[t],children:jsx("div",{className:"h-4 bg-gray-200 dark:bg-gray-700 rounded animate-pulse"})},o))})}function Tg({column:e,value:t,onApply:r,onClear:o}){let[n,a]=useState(false),[s,l]=useState(t?.operator??"contains"),[i,d]=useState(t?.value??""),u=useRef(null),p=e.filterType??"text",b=p==="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 useEffect(()=>{let m=f=>{u.current&&!u.current.contains(f.target)&&a(false);};return n&&document.addEventListener("mousedown",m),()=>document.removeEventListener("mousedown",m)},[n]),jsxs("div",{className:"relative inline-block",ref:u,children:[jsx("button",{type:"button",onClick:m=>{m.stopPropagation(),a(!n);},className:c("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:jsx(kg,{})}),n&&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:p==="select"&&e.filterOptions?jsxs("div",{className:"flex flex-col gap-1.5",children:[e.filterOptions.map(m=>jsxs("label",{className:"flex items-center gap-2 text-sm cursor-pointer",children:[jsx("input",{type:"radio",name:`filter-${e.key}`,value:m,checked:i===m,onChange:()=>d(m),className:"cursor-pointer"}),jsx("span",{className:"text-gray-700 dark:text-gray-300",children:m})]},m)),jsxs("div",{className:"flex gap-2 mt-2",children:[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"}),jsx("button",{type:"button",onClick:()=>{d(""),o(),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"})]})]}):jsxs("div",{className:"flex flex-col gap-2",children:[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:b.map(m=>jsx("option",{value:m.value,children:m.label},m.value))}),s!=="isEmpty"&&s!=="isNotEmpty"&&jsx("input",{type:p==="number"?"number":p==="date"?"date":"text",value:i,onChange:m=>d(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`}),jsxs("div",{className:"flex gap-2",children:[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"}),jsx("button",{type:"button",onClick:()=>{d(""),o(),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 Pg({value:e,onSave:t,density:r}){let[o,n]=useState(false),[a,s]=useState(String(e??"")),l=useRef(null);if(useEffect(()=>{o&&l.current&&(l.current.focus(),l.current.select());},[o]),!o)return jsx("div",{onDoubleClick:()=>{s(String(e??"")),n(true);},className:"cursor-text min-h-[1.5em]",title:"Double-click to edit",children:String(e??"")});let i=()=>{n(false),a!==String(e??"")&&t(a);};return jsx("input",{ref:l,type:"text",value:a,onChange:d=>s(d.target.value),onBlur:i,"aria-label":"Edit cell value",onKeyDown:d=>{d.key==="Enter"&&i(),d.key==="Escape"&&n(false);},className:c("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",xa[r])})}function Eg(e,t){let{columns:r,data:o,rowKey:n,mode:a="client",sortable:s=false,multiSort:l=false,sort:i,defaultSort:d,onSort:u,pagination:p=false,page:b,onPageChange:m,onPageSizeChange:f,totalItems:h,selectable:y=false,selectionMode:C="multiple",selectedRows:v,onSelectionChange:E,searchable:k=false,searchPlaceholder:R="Search...",searchValue:g,onSearch:P,filters:T,onFilterChange:D,expandable:W=false,expandedContent:V,expandedRows:_,onExpandChange:M,editable:w=false,onCellEdit:N,reorderable:x=false,onReorder:S,columnReorderable:I=false,onColumnReorder:F,columnToggle:O=false,hiddenColumns:Z,onColumnVisibilityChange:U,groupBy:H,renderGroupHeader:z,exportable:$=false,exportFormats:K=["csv","json"],exportFilename:se="export",virtualized:X=false,rowHeight:ee=40,virtualHeight:L=400,density:q="default",striped:ge=false,bordered:de=false,borderless:Y=false,stickyHeader:le=false,maxHeight:xe,loading:Se=false,loadingRows:te=5,emptyState:Ne,showFooter:De=false,onRowClick:Ve,onRowDoubleClick:rt,onRowContextMenu:dt,className:re,rowClassName:pe,cellClassName:Ue,headerClassName:yt}=e,[Re,We]=useState(d??[]),[ft,rr]=useState(1),[ot,Wt]=useState(typeof p=="object"?p.pageSize??10:10),[Nt,Ht]=useState([]),[or,Zt]=useState(""),[Ar,br]=useState([]),[fe,he]=useState([]),[j,J]=useState(()=>r.flatMap(A=>A.hidden?[A.key]:[])),[me,ue]=useState({}),[Te,ve]=useState(()=>r.map(A=>A.key)),[we,He]=useState(null),[Me,tt]=useState(null),[je,$e]=useState(false),[Tt,nt]=useState(new Set),nr=useRef(null),[zr,mo]=useState(0),Ao=useRef(null),hr=i??Re,ar=b??ft,B=v??Nt,Q=g??or,oe=T??Ar,ne=_??fe,ce=Z??j,Fe=p?typeof p=="object"?p:{pageSize:10,pageSizeOptions:[10,25,50,100]}:null,Ye=Fe?.pageSize??ot,_e=useMemo(()=>{let A=new Map(r.map(Ce=>[Ce.key,Ce])),G=Te.flatMap(Ce=>{let Le=A.get(Ce);return Le?[Le]:[]}),ie=new Set(G.map(Ce=>Ce.key));for(let Ce of r)ie.has(Ce.key)||(G.push(Ce),ie.add(Ce.key));return G.filter(Ce=>!ce.includes(Ce.key))},[r,Te,ce]),Ie=useMemo(()=>{if(a==="server")return o;let A=[...o];if(Q){let G=Q.toLowerCase();A=A.filter(ie=>_e.some(Ce=>{let Le=Tr(ie,Ce.key);return String(Le??"").toLowerCase().includes(G)}));}if(oe.length>0&&(A=A.filter(G=>oe.every(ie=>Sg(Tr(G,ie.column),ie)))),hr.length>0){let G=new Map(r.map(ie=>[ie.key,ie]));A.sort((ie,Ce)=>{for(let Le of hr){if(!Le.direction)continue;let pt=G.get(Le.key),Ot=pt?.sortComparator?pt.sortComparator(ie,Ce):Ng(Tr(ie,Le.key),Tr(Ce,Le.key));if(Ot!==0)return Le.direction==="asc"?Ot:-Ot}return 0});}return A},[o,a,Q,oe,hr,_e,r]),Pt=useMemo(()=>{if(!H)return null;let A=Array.isArray(H)?H:[H],G=new Map;for(let ie of Ie){let Ce=A.map(pt=>String(Tr(ie,pt)??"")).join(" / "),Le=G.get(Ce)??[];Le.push(ie),G.set(Ce,Le);}return G},[Ie,H]),Ge=h??Ie.length,ut=Math.max(1,Math.ceil(Ge/Ye)),xt=useMemo(()=>{if(!Fe||a==="server")return Ie;let A=(ar-1)*Ye;return Ie.slice(A,A+Ye)},[Ie,Fe,ar,Ye,a]),at=Fe?xt:Ie,Mt=useMemo(()=>{if(!X)return {start:0,end:at.length};let A=Math.floor(zr/ee),G=Math.ceil(L/ee),ie=5;return {start:Math.max(0,A-ie),end:Math.min(at.length,A+G+ie)}},[X,zr,ee,L,at.length]),yr=useCallback(A=>{i||We(A),u?.(A);},[i,u]),xr=useCallback(A=>{let G=hr.find(Ce=>Ce.key===A),ie;if(!G||!G.direction?ie="asc":G.direction==="asc"?ie="desc":ie=null,l){let Ce=hr.filter(Le=>Le.key!==A);ie&&Ce.push({key:A,direction:ie}),yr(Ce);}else yr(ie?[{key:A,direction:ie}]:[]);},[hr,l,yr]),Kt=useCallback(A=>{let G=Math.max(1,Math.min(A,ut));b||rr(G),m?.(G);},[b,m,ut]),rs=useCallback(A=>{Wt(A),Kt(1),f?.(A);},[Kt,f]),Qn=useCallback(A=>{let G;C==="single"?G=B.includes(A)?[]:[A]:G=B.includes(A)?B.filter(ie=>ie!==A):[...B,A],v||Ht(G),E?.(G);},[C,B,v,E]),os=useCallback(()=>{let A=at.map((G,ie)=>ya(G,ie,n));v||Ht(A),E?.(A);},[at,n,v,E]),ns=useCallback(()=>{v||Ht([]),E?.([]);},[v,E]),as=at.length>0&&at.every((A,G)=>B.includes(ya(A,G,n))),mu=!as&&at.some((A,G)=>B.includes(ya(A,G,n))),fu=useCallback(A=>{let G=ne.includes(A)?ne.filter(ie=>ie!==A):[...ne,A];_||he(G),M?.(G);},[ne,_,M]),bu=useCallback(A=>{let G=A.target.value;g||Zt(G),P?.(G),Kt(1);},[g,P,Kt]),hu=useCallback(A=>{let G=[...oe.filter(ie=>ie.column!==A.column),A];T||br(G),D?.(G);},[oe,T,D]),yu=useCallback(A=>{let G=oe.filter(ie=>ie.column!==A);T||br(G),D?.(G);},[oe,T,D]),xu=useCallback(A=>{let G=ce.includes(A)?ce.filter(ie=>ie!==A):[...ce,A];Z||J(G),U?.(G);},[ce,Z,U]),vu=useCallback((A,G)=>{A.preventDefault(),A.stopPropagation();let ie=A.clientX,Ce=me[G]??A.currentTarget.parentElement?.getBoundingClientRect().width??100,Le=r.find($t=>$t.key===G),pt=Le?.minWidth??50,Ot=Le?.maxWidth??1/0,qe=$t=>{let fo=$t.clientX-ie,kr=Math.min(Ot,Math.max(pt,Ce+fo));ue(Wo=>({...Wo,[G]:kr}));},vr=()=>{document.removeEventListener("mousemove",qe),document.removeEventListener("mouseup",vr);};document.addEventListener("mousemove",qe),document.addEventListener("mouseup",vr);},[me,r]),ku=useCallback(A=>{x&&He(A);},[x]),wu=useCallback((A,G)=>{!x||we===null||A.preventDefault();},[x,we]),Cu=useCallback(A=>{!x||we===null||we===A||(S?.(we,A),He(null));},[x,we,S]),Nu=useCallback(A=>{I&&tt(A);},[I]),Su=useCallback(A=>{if(!I||!Me||Me===A)return;let G=[...Te],ie=G.indexOf(Me),Ce=G.indexOf(A);ie===-1||Ce===-1||(G.splice(ie,1),G.splice(Ce,0,Me),ve(G),F?.(Me,A),tt(null));},[I,Me,Te,F]),ss=useCallback(A=>{let G=_e.filter($t=>$t.type!=="actions"&&$t.type!=="selection"&&$t.type!=="expand"),ie=Ie,Ce,Le,pt;if(A==="csv"){let $t=G.map(kr=>String(kr.header)).join(","),fo=ie.map(kr=>G.map(Wo=>{let ds=String(Tr(kr,Wo.key)??"");return ds.includes(",")?`"${ds}"`:ds}).join(","));Ce=[$t,...fo].join(`
2
- `),Le="text/csv",pt="csv";}else {let $t=ie.map(fo=>{let kr={};for(let Wo of G)kr[Wo.key]=Tr(fo,Wo.key);return kr});Ce=JSON.stringify($t,null,2),Le="application/json",pt="json";}let Ot=new Blob([Ce],{type:Le}),qe=URL.createObjectURL(Ot),vr=document.createElement("a");vr.href=qe,vr.download=`${se}.${pt}`,vr.click(),URL.revokeObjectURL(qe);},[_e,Ie,se]);useEffect(()=>{if(!je)return;let A=G=>{Ao.current&&!Ao.current.contains(G.target)&&$e(false);};return document.addEventListener("mousedown",A),()=>document.removeEventListener("mousedown",A)},[je]),useImperativeHandle(t,()=>({getVisibleData:()=>at,resetFilters:()=>{T||br([]),g||Zt(""),D?.([]),P?.("");},resetSort:()=>{i||We([]),u?.([]);},selectAll:os,deselectAll:ns,exportData:ss,scrollToRow:A=>{nr.current&&X&&(nr.current.scrollTop=A*ee);}}),[at,T,g,i,D,P,u,os,ns,ss,X,ee]);let is=A=>{let G={},ie=me[A.key]??A.width;return ie&&(G.width=typeof ie=="number"?`${ie}px`:ie,G.minWidth=typeof ie=="number"?`${ie}px`:ie),A.sticky&&(G.position="sticky",G[A.sticky]=0,G.zIndex=10),G},zo=_e.length+(y?1:0)+(W?1:0)+(x?1:0),Ru=A=>{let G=s&&A.sortable!==false&&A.type!=="actions",ie=hr.find(Le=>Le.key===A.key),Ce=A.filterable&&(A.filterType||A.filterOptions);return jsxs("th",{className:c(At[q],xa[q],"font-semibold text-gray-700 dark:text-gray-300 whitespace-nowrap",A.align==="center"&&"text-center",A.align==="right"&&"text-right",G&&"cursor-pointer select-none hover:bg-gray-100 dark:hover:bg-gray-700",de&&"border border-gray-200 dark:border-gray-700",A.sticky&&"bg-gray-50 dark:bg-gray-800",A.headerClassName,yt),style:is(A),onClick:G?()=>xr(A.key):void 0,draggable:I,onDragStart:I?()=>Nu(A.key):void 0,onDragOver:I?Le=>Le.preventDefault():void 0,onDrop:I?()=>Su(A.key):void 0,"aria-sort":ie?.direction==="asc"?"ascending":ie?.direction==="desc"?"descending":void 0,children:[jsxs("div",{className:"flex items-center gap-1",children:[A.renderHeader?A.renderHeader(A):A.header,G&&jsx("span",{className:"inline-flex ml-1",children:ie?.direction==="asc"?jsx(bg,{}):ie?.direction==="desc"?jsx(hg,{}):jsx(yg,{})}),Ce&&jsx(Tg,{column:A,value:oe.find(Le=>Le.column===A.key),onApply:hu,onClear:()=>yu(A.key)})]}),A.resizable!==false&&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:Le=>vu(Le,A.key)})]},A.key)},ls=(A,G,ie)=>{let Ce=ya(A,ie,n),Le=B.includes(Ce),pt=ne.includes(Ce),Ot=typeof pe=="function"?pe(A,ie):pe;return jsxs(Ns__default.Fragment,{children:[jsxs("tr",{className:c("border-b border-gray-200 dark:border-gray-700 transition-colors",ge&&ie%2===1&&"bg-gray-50/50 dark:bg-gray-800/50",Le&&"bg-blue-50 dark:bg-blue-900/20",Ve&&"cursor-pointer hover:bg-gray-50 dark:hover:bg-gray-700/50",we===G&&"opacity-50",Ot),onClick:Ve?()=>Ve(A,ie):void 0,onDoubleClick:rt?()=>rt(A,ie):void 0,onContextMenu:dt?qe=>dt(A,ie,qe):void 0,draggable:x,onDragStart:x?()=>ku(G):void 0,onDragOver:x?qe=>wu(qe,G):void 0,onDrop:x?()=>Cu(G):void 0,"data-row-key":Ce,"aria-selected":y?Le:void 0,children:[x&&jsx("td",{className:c(At[q],"cursor-grab active:cursor-grabbing"),children:jsx(vg,{})}),y&&jsx("td",{className:c(At[q],"w-10"),children:jsx("input",{type:"checkbox",checked:Le,onChange:()=>Qn(Ce),onClick:qe=>qe.stopPropagation(),className:"rounded border-gray-300 dark:border-gray-600 cursor-pointer","aria-label":`Select row ${Ce}`})}),W&&jsx("td",{className:c(At[q],"w-10"),children:jsx("button",{type:"button",onClick:qe=>{qe.stopPropagation(),fu(Ce);},className:"p-0.5 rounded hover:bg-gray-200 dark:hover:bg-gray-600 cursor-pointer","aria-label":pt?"Collapse row":"Expand row","aria-expanded":pt,children:jsx(Ll,{className:c("transition-transform",pt&&"rotate-180")})})}),_e.map(qe=>{let vr=Tr(A,qe.key),$t=qe.colSpan?.(A,ie);if($t===0)return null;let fo=w&&qe.editable!==false&&qe.type!=="actions";return jsx("td",{className:c(At[q],xa[q],"text-gray-700 dark:text-gray-300",qe.align==="center"&&"text-center",qe.align==="right"&&"text-right",de&&"border border-gray-200 dark:border-gray-700",qe.sticky&&(Le?"bg-blue-50 dark:bg-blue-900/20":ge&&ie%2===1?"bg-gray-50/50 dark:bg-gray-800/50":"bg-white dark:bg-gray-900"),qe.cellClassName,Ue),style:is(qe),colSpan:$t,children:fo?jsx(Pg,{value:vr,onSave:kr=>N?.(Ce,qe.key,kr),density:q}):qe.render?qe.render(vr,A,ie):String(vr??"")},qe.key)})]}),W&&pt&&V&&jsx("tr",{className:"bg-gray-50 dark:bg-gray-800/70",children:jsx("td",{colSpan:zo,className:c(At[q]),children:V(A,ie)})})]},Ce)},Tu=()=>{if(Se)return Array.from({length:te}).map((A,G)=>jsx(Rg,{cols:zo,density:q},G));if(at.length===0)return jsx("tr",{children:jsx("td",{colSpan:zo,className:c("text-center text-gray-400 dark:text-gray-500",At[q]),children:Ne??"No data available"})});if(Pt){let A=[],G=0;for(let[ie,Ce]of Pt){let Le=Tt.has(ie);if(A.push(jsx("tr",{className:"bg-gray-100 dark:bg-gray-800 font-medium",children:jsx("td",{colSpan:zo,className:c(At[q],"cursor-pointer"),onClick:()=>{nt(pt=>{let Ot=new Set(pt);return Ot.has(ie)?Ot.delete(ie):Ot.add(ie),Ot});},children:jsxs("div",{className:"flex items-center gap-2",children:[jsx(Ll,{className:c("transition-transform",Le&&"-rotate-90")}),z?z(ie,Tr(Ce[0],Array.isArray(H)?H[0]:H),Ce):`${ie} (${Ce.length})`]})})},`group-${ie}`)),Le)G+=Ce.length;else for(let pt=0;pt<Ce.length;pt++)A.push(ls(Ce[pt],G,G)),G++;}return A}if(X){let A=[];for(let G=Mt.start;G<Mt.end;G++)A.push(ls(at[G],G,G));return jsxs(Fragment,{children:[Mt.start>0&&jsx("tr",{children:jsx("td",{colSpan:zo,style:{height:Mt.start*ee,padding:0}})}),A,Mt.end<at.length&&jsx("tr",{children:jsx("td",{colSpan:zo,style:{height:(at.length-Mt.end)*ee,padding:0}})})]})}return at.map((A,G)=>ls(A,G,G))},Pu=()=>!De||!_e.some(G=>G.aggregate)?null:jsx("tfoot",{children:jsxs("tr",{className:"bg-gray-50 dark:bg-gray-800 font-semibold border-t-2 border-gray-300 dark:border-gray-600",children:[x&&jsx("td",{className:At[q]}),y&&jsx("td",{className:At[q]}),W&&jsx("td",{className:At[q]}),_e.map(G=>jsx("td",{className:c(At[q],xa[q],"text-gray-700 dark:text-gray-300",G.align==="center"&&"text-center",G.align==="right"&&"text-right",de&&"border border-gray-200 dark:border-gray-700"),style:is(G),children:G.aggregate?G.renderAggregate?G.renderAggregate(Al(Ie,G.key,G.aggregate),Ie):`${G.aggregate==="count"?"":G.aggregate==="avg"?"Avg: ":G.aggregate==="sum"?"Total: ":G.aggregate==="min"?"Min: ":"Max: "}${Al(Ie,G.key,G.aggregate).toLocaleString()}`:""},G.key))]})});return jsxs("div",{className:c("flex flex-col gap-3",re),children:[(k||$||O)&&jsxs("div",{className:"flex items-center justify-between gap-3 flex-wrap",children:[jsxs("div",{className:"flex items-center gap-3 flex-1",children:[k&&jsxs("div",{className:"relative flex-1 max-w-xs",children:[jsx("div",{className:"absolute inset-y-0 left-0 flex items-center pl-3 pointer-events-none",children:jsx(xg,{})}),jsx("input",{type:"text",value:Q,onChange:bu,placeholder:R,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"})]}),B.length>0&&jsxs("span",{className:"text-sm text-gray-500 dark:text-gray-400",children:[B.length," selected"]})]}),jsxs("div",{className:"flex items-center gap-2",children:[O&&jsxs("div",{className:"relative",ref:Ao,children:[jsx("button",{type:"button",onClick:()=>$e(!je),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:jsx(Cg,{})}),je&&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(A=>A.type!=="selection"&&A.type!=="expand").map(A=>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:[jsx("input",{type:"checkbox",checked:!ce.includes(A.key),onChange:()=>xu(A.key),className:"rounded border-gray-300 dark:border-gray-600 cursor-pointer"}),jsx("span",{className:"text-gray-700 dark:text-gray-300",children:String(A.header)})]},A.key))})]}),$&&K.map(A=>jsxs("button",{type:"button",onClick:()=>ss(A),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 ${A.toUpperCase()}`,children:[jsx(wg,{}),A.toUpperCase()]},A))]})]}),jsx("div",{ref:nr,className:c("overflow-auto rounded-lg",!Y&&"border border-gray-200 dark:border-gray-700",le&&"relative"),style:xe?{maxHeight:typeof xe=="number"?`${xe}px`:xe}:X?{maxHeight:L,overflow:"auto"}:void 0,onScroll:X?A=>mo(A.target.scrollTop):void 0,children:jsxs("table",{className:"w-full text-left",children:[jsx("thead",{className:c("bg-gray-50 dark:bg-gray-800 text-xs uppercase",le&&"sticky top-0 z-20"),children:jsxs("tr",{children:[x&&jsx("th",{className:c(At[q],"w-10 font-semibold text-gray-700 dark:text-gray-300")}),y&&jsx("th",{className:c(At[q],"w-10"),children:C==="multiple"&&jsx("input",{type:"checkbox",checked:as,ref:A=>{A&&(A.indeterminate=mu);},onChange:as?ns:os,className:"rounded border-gray-300 dark:border-gray-600 cursor-pointer","aria-label":"Select all rows"})}),W&&jsx("th",{className:c(At[q],"w-10 font-semibold text-gray-700 dark:text-gray-300")}),_e.map(Ru)]})}),jsx("tbody",{children:Tu()}),Pu()]})}),Fe&&jsxs("div",{className:"flex items-center justify-between flex-wrap gap-3 text-sm text-gray-600 dark:text-gray-400",children:[jsxs("div",{className:"flex items-center gap-3",children:[Fe.showTotalItems!==false&&jsxs("span",{children:[Ge," item",Ge!==1?"s":""]}),Fe.showPageSizeSelector!==false&&Fe.pageSizeOptions&&jsxs("div",{className:"flex items-center gap-1.5",children:[jsx("span",{children:"Rows per page:"}),jsx("select",{value:Ye,onChange:A=>rs(Number(A.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:Fe.pageSizeOptions.map(A=>jsx("option",{value:A,children:A},A))})]})]}),jsxs("div",{className:"flex items-center gap-1",children:[jsxs("span",{className:"mr-2",children:["Page ",ar," of ",ut]}),jsx("button",{type:"button",onClick:()=>Kt(1),disabled:ar<=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"}),jsx("button",{type:"button",onClick:()=>Kt(ar-1),disabled:ar<=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"}),jsx("button",{type:"button",onClick:()=>Kt(ar+1),disabled:ar>=ut,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"}),jsx("button",{type:"button",onClick:()=>Kt(ut),disabled:ar>=ut,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 Dg=forwardRef(Eg);function Mg({className:e}){return jsx("svg",{className:e,viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",children:jsx("path",{d:"M4 4L12 12M12 4L4 12",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})})}var Lg={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"}},Ag={default:"bg-gray-500",primary:"bg-blue-600",success:"bg-green-600",warning:"bg-yellow-500",error:"bg-red-600",info:"bg-cyan-600"},zg={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"},Es={sm:"w-3 h-3",md:"w-3.5 h-3.5",lg:"w-4 h-4"},Wg={sm:"w-4 h-4 -ml-1",md:"w-5 h-5 -ml-1.5",lg:"w-6 h-6 -ml-1.5"},Hg={sm:"w-1.5 h-1.5",md:"w-2 h-2",lg:"w-2.5 h-2.5"},Fg={none:"rounded-none",sm:"rounded-sm",md:"rounded-md",lg:"rounded-lg",full:"rounded-full"};function ka({label:e,children:t,variant:r="solid",size:o="md",color:n="default",bgColor:a,textColor:s,borderColor:l,rounded:i="full",icon:d,endIcon:u,avatar:p,onClose:b,closable:m=false,clickable:f=false,selected:h=false,disabled:y=false,as:C="span",className:v,onClick:E,...k}){let R=C,g=c("inline-flex items-center justify-center font-medium transition-all",zg[o],Fg[i],r==="outlined"&&"border"),P=c(a||s||l?c(a,s,l):Lg[n][r]),T=h?"ring-2 ring-offset-1 ring-blue-500":"",D=f&&!y?"cursor-pointer hover:opacity-80 active:scale-95":"",W=y?"opacity-50 cursor-not-allowed":"",V=w=>{w.stopPropagation(),b?.();},_=w=>{y||E?.(w);},M=t??e;return jsxs(R,{className:c(g,P,T,D,W,v),onClick:_,"aria-disabled":y,...k,children:[r==="dot"&&jsx("span",{className:c("rounded-full shrink-0",Hg[o],Ag[n]),"aria-hidden":"true"}),p&&jsx("span",{className:c("rounded-full overflow-hidden shrink-0",Wg[o]),children:p}),d&&!p&&jsx("span",{className:c("shrink-0",Es[o]),children:d}),M&&jsx("span",{className:"truncate",children:M}),u&&!m&&jsx("span",{className:c("shrink-0",Es[o]),children:u}),m&&jsx("button",{type:"button",onClick:V,disabled:y,className:c("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",y&&"pointer-events-none"),"aria-label":"Remove",children:jsx(Mg,{className:Es[o]})})]})}ka.displayName="Chip";var _g=500,Gg=800,Xg=600;function Kg(e,t,r){let o=[`width=${e}`,`height=${t}`,"menubar=no","toolbar=no","location=no","status=no","scrollbars=yes","resizable=yes"];if(r.left!==void 0)o.push(`left=${r.left}`);else if(r.center!==false&&typeof window<"u"){let n=window.screenLeft??window.screenX,a=window.screenTop??window.screenY,s=window.outerWidth??screen.availWidth,l=window.outerHeight??screen.availHeight;o.push(`left=${n+(s-e)/2}`),o.push(`top=${a+(l-t)/2}`);}if(r.top!==void 0){let n=o.filter(a=>!a.startsWith("top="));return n.push(`top=${r.top}`),n.join(",")}return o.join(",")}function Ug(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 n=e.documentElement.className;n&&(t.documentElement.className=n);let a=e.body.className;a&&(t.body.className=a);}function Yg(e,t){let r=new MutationObserver(o=>{for(let n of o)for(let a of Array.from(n.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 Wl=forwardRef(function({children:t,detached:r,defaultDetached:o=false,onClose:n,onDetach:a,title:s="",width:l=Gg,height:i=Xg,left:d,top:u,center:p=true,copyStyles:b=true,closeOnParentUnmount:m=true,className:f,windowClassName:h,onPopupBlocked:y},C){let v=r!==void 0,[E,k]=useState(o),R=v?r:E,[g,P]=useState(null),T=useRef(null),D=useRef(null),W=useRef(null),V=useRef(false),_=useRef({width:l,height:i,left:d,top:u,center:p,shouldCopyStyles:b,title:s,windowClassName:h,closeOnParentUnmount:m});_.current={width:l,height:i,left:d,top:u,center:p,shouldCopyStyles:b,title:s,windowClassName:h,closeOnParentUnmount:m};let M=useCallback(()=>{D.current&&(clearInterval(D.current),D.current=null),W.current&&(W.current.disconnect(),W.current=null),P(null);},[]),w=useCallback(()=>{T.current&&!T.current.closed&&T.current.close(),T.current=null,M();},[M]),N=useCallback(()=>{if(typeof window>"u"||V.current||T.current&&!T.current.closed)return;V.current=true;let x=_.current,S=Kg(x.width,x.height,{center:x.center,left:x.left,top:x.top}),I=window.open("","",S);if(!I){V.current=false,y?.();return}T.current=I,I.document.title=x.title||document.title;let F=I.document.createElement("div");x.windowClassName&&(F.className=x.windowClassName),I.document.body.appendChild(F),P(F),x.shouldCopyStyles&&(Ug(document,I.document),W.current=Yg(document,I.document)),D.current=setInterval(()=>{I.closed&&(M(),T.current=null,v||k(false),n?.());},_g),V.current=false,a?.();},[v,n,a,y,M]);return useEffect(()=>{R?N():w();},[R,N,w]),useEffect(()=>{T.current&&!T.current.closed&&s&&(T.current.document.title=s);},[s]),useEffect(()=>()=>{_.current.closeOnParentUnmount&&T.current&&!T.current.closed&&T.current.close(),M(),T.current=null;},[M]),useImperativeHandle(C,()=>({detach:()=>{v||k(true);},attach:()=>{v||k(false);},get isDetached(){return v?!!r:E},get window(){return T.current}}),[v,r,E]),R&&g?createPortal(t,g):R?null:jsx("div",{className:c(f),children:t})});Wl.displayName="Detachable";var Zg={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}}},Jg=({className:e})=>jsxs("svg",{className:c("w-3 h-3",e),viewBox:"0 0 16 16",fill:"currentColor",children:[jsx("rect",{x:"1",y:"11",width:"2.5",height:"4",rx:"0.5"}),jsx("rect",{x:"5",y:"8",width:"2.5",height:"7",rx:"0.5"}),jsx("rect",{x:"9",y:"5",width:"2.5",height:"10",rx:"0.5"}),jsx("rect",{x:"13",y:"1",width:"2.5",height:"14",rx:"0.5"})]}),Qg=({className:e})=>jsxs("svg",{className:c("w-3 h-3",e),viewBox:"0 0 20 20",fill:"currentColor",children:[jsx("path",{d:"M10 14.5a1.5 1.5 0 100 3 1.5 1.5 0 000-3z"}),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"}),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"})]}),em=({className:e})=>jsxs("svg",{className:c("w-4 h-3",e),viewBox:"0 0 24 14",fill:"currentColor",children:[jsx("rect",{x:"0.5",y:"0.5",width:"20",height:"13",rx:"2",stroke:"currentColor",fill:"none",strokeWidth:"1"}),jsx("rect",{x:"22",y:"4",width:"2",height:"6",rx:"0.5"}),jsx("rect",{x:"2.5",y:"2.5",width:"14",height:"9",rx:"1"})]});function En({time:e="9:41",theme:t,device:r}){let o=r==="watch",n=t==="dark"?"text-white":"text-gray-900";return o?jsx("div",{className:c("flex items-center justify-center py-0.5",n),style:{fontSize:"8px"},children:jsx("span",{className:"font-medium",children:e})}):jsxs("div",{className:c("flex items-center justify-between px-4 py-1",t==="dark"?"bg-black/20":"bg-white/20",n),style:{fontSize:"10px"},"data-testid":"status-bar",children:[jsx("span",{className:"font-semibold",children:e}),jsxs("div",{className:"flex items-center gap-1",children:[jsx(Jg,{className:n}),jsx(Qg,{className:n}),jsx(em,{className:n})]})]})}function tm({theme:e}){let t=e==="dark";return jsxs("div",{className:c("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:[jsxs("div",{className:"flex items-center gap-1.5",children:[jsx("div",{className:"w-2.5 h-2.5 rounded-full bg-red-400"}),jsx("div",{className:"w-2.5 h-2.5 rounded-full bg-yellow-400"}),jsx("div",{className:"w-2.5 h-2.5 rounded-full bg-green-400"})]}),jsx("div",{className:c("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:jsxs("span",{className:"flex items-center justify-center gap-1",children:[jsx("svg",{className:"w-2.5 h-2.5",viewBox:"0 0 16 16",fill:"currentColor",children: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 rm({children:e,theme:t,screenW:r,screenH:o,showStatusBar:n,statusBarTime:a,frameColor:s,landscape:l=false}){let i=t==="dark",d=s??(i?"#1a1a1a":"#e5e7eb");if(l){let p=Math.round(o*.35);return jsxs("div",{className:"relative inline-flex flex-row items-center rounded-[2.5rem] shadow-xl",style:{backgroundColor:d,padding:"8px 12px",height:o+16},"data-testid":"device-frame","data-device":"phone",children:[jsx("div",{className:c("rounded-full mr-2",i?"bg-gray-600":"bg-gray-400"),style:{width:4,height:Math.round(o*.35)},"data-testid":"home-indicator"}),jsxs("div",{className:"rounded-[2rem] overflow-hidden bg-black relative",style:{width:r,height:o},children:[n&&jsx(En,{time:a,theme:t,device:"phone"}),e]}),jsx("div",{className:"absolute rounded-full bg-black z-10",style:{width:20,height:p,right:10,top:"50%",transform:"translateY(-50%)"},"data-testid":"phone-notch"})]})}let u=Math.round(r*.35);return jsxs("div",{className:"relative inline-flex flex-col items-center rounded-[2.5rem] shadow-xl",style:{backgroundColor:d,padding:"12px 8px",width:r+16},"data-testid":"device-frame","data-device":"phone",children:[jsx("div",{className:"absolute top-[10px] rounded-full bg-black z-10",style:{width:u,height:20,left:"50%",transform:"translateX(-50%)"},"data-testid":"phone-notch"}),jsxs("div",{className:"rounded-[2rem] overflow-hidden bg-black relative",style:{width:r,height:o},children:[n&&jsx(En,{time:a,theme:t,device:"phone"}),e]}),jsx("div",{className:c("rounded-full mt-2",i?"bg-gray-600":"bg-gray-400"),style:{width:Math.round(r*.35),height:4},"data-testid":"home-indicator"})]})}function om({children:e,theme:t,screenW:r,screenH:o,showStatusBar:n,statusBarTime:a,frameColor:s}){return 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:[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"}),jsxs("div",{className:"rounded-[1.5rem] overflow-hidden bg-black relative",style:{width:r,height:o},children:[n&&jsx(En,{time:a,theme:t,device:"android"}),e]})]})}function nm({children:e,theme:t,screenW:r,screenH:o,showStatusBar:n,statusBarTime:a,frameColor:s}){return 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:[jsx("div",{className:"absolute top-[8px] rounded-full bg-gray-700 z-10",style:{width:6,height:6,left:"50%",transform:"translateX(-50%)"}}),jsxs("div",{className:"rounded-lg overflow-hidden bg-black relative",style:{width:r,height:o},children:[n&&jsx(En,{time:a,theme:t,device:"tablet"}),e]})]})}function am({children:e,theme:t,screenW:r,screenH:o,frameColor:n}){let a=t==="dark",s=n??(a?"#1a1a1a":"#d1d5db"),l=r+60;return jsxs("div",{className:"inline-flex flex-col items-center","data-testid":"device-frame","data-device":"laptop",children:[jsxs("div",{className:"rounded-t-xl shadow-xl relative",style:{backgroundColor:s,padding:"8px 8px 0",width:r+16},children:[jsx("div",{className:"absolute top-[3px] rounded-full bg-gray-700 z-10",style:{width:4,height:4,left:"50%",transform:"translateX(-50%)"}}),jsx("div",{className:"rounded-t-sm overflow-hidden bg-black",style:{width:r,height:o},children:e})]}),jsx("div",{className:c(a?"bg-gray-800":"bg-gray-400"),style:{width:r+16,height:3}}),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 sm({children:e,theme:t,screenW:r,screenH:o,frameColor:n}){let a=t==="dark";return jsxs("div",{className:"inline-flex flex-col items-center","data-testid":"device-frame","data-device":"desktop",children:[jsx("div",{className:"rounded-lg shadow-xl",style:{backgroundColor:n??(a?"#1a1a1a":"#d1d5db"),padding:"8px 8px 20px",width:r+16},children:jsx("div",{className:"rounded-sm overflow-hidden bg-black",style:{width:r,height:o},children:e})}),jsx("div",{className:c(a?"bg-gray-800":"bg-gray-400"),style:{width:40,height:24},"data-testid":"monitor-stand"}),jsx("div",{className:c("rounded-t-sm",a?"bg-gray-800":"bg-gray-400"),style:{width:Math.round(r*.4),height:6,borderRadius:"2px 2px 4px 4px"}})]})}function im({children:e,theme:t,screenW:r,screenH:o,showStatusBar:n,statusBarTime:a,frameColor:s}){let l=t==="dark",i=s??(l?"#1a1a1a":"#d1d5db"),d=Math.round(r*.7);return jsxs("div",{className:"inline-flex flex-col items-center","data-testid":"device-frame","data-device":"watch",children:[jsx("div",{className:c("rounded-t-lg",l?"bg-gray-800":"bg-gray-400"),style:{width:d,height:30},"data-testid":"watch-band"}),jsxs("div",{className:"relative rounded-[1.2rem] shadow-xl",style:{backgroundColor:i,padding:"8px 6px",width:r+12},children:[jsx("div",{className:c("absolute rounded-sm",l?"bg-gray-600":"bg-gray-400"),style:{width:4,height:16,right:-4,top:"30%"},"data-testid":"watch-crown"}),jsxs("div",{className:"rounded-xl overflow-hidden bg-black",style:{width:r,height:o},children:[n&&jsx(En,{time:a,theme:t,device:"watch"}),e]})]}),jsx("div",{className:c("rounded-b-lg",l?"bg-gray-800":"bg-gray-400"),style:{width:d,height:30}})]})}function lm({children:e,theme:t,screenW:r,screenH:o,frameColor:n}){return jsxs("div",{className:"inline-flex flex-col rounded-lg shadow-xl overflow-hidden",style:{backgroundColor:n??(t==="dark"?"#1f2937":"#f3f4f6"),width:r},"data-testid":"device-frame","data-device":"browser",children:[jsx(tm,{theme:t}),jsx("div",{className:"overflow-hidden bg-white",style:{width:r,height:o},children:e})]})}function dm({device:e="phone",src:t,alt:r="Device screen content",children:o,orientation:n="portrait",theme:a="dark",size:s="md",showStatusBar:l=false,statusBarTime:i,animated:d=false,scrollSpeed:u=30,frameColor:p,className:b,contentClassName:m}){let f=useRef(null),h=useRef(null),y=Zg[e][s],C=n==="landscape"&&e!=="watch"&&e!=="browser",v=C?y.h:y.w,E=C?y.w:y.h;useEffect(()=>{if(!d||!f.current)return;let P=f.current,T=null,D=W=>{T===null&&(T=W);let V=(W-T)/1e3;T=W,P.scrollTop+=u*V,P.scrollTop>=P.scrollHeight-P.clientHeight&&(P.scrollTop=0),h.current=requestAnimationFrame(D);};return h.current=requestAnimationFrame(D),()=>{h.current!==null&&cancelAnimationFrame(h.current);}},[d,u]);let k=jsx("div",{ref:d?f:void 0,className:c("w-full h-full overflow-hidden",d&&"overflow-y-auto scrollbar-hide",m),style:d?{scrollBehavior:"auto"}:void 0,children:t?jsx("img",{src:t,alt:r,className:"w-full h-auto object-cover",draggable:false}):o}),R={showStatusBar:l,statusBarTime:i},g=()=>{switch(e){case "phone":return jsx(rm,{theme:a,screenW:v,screenH:E,frameColor:p,landscape:C,...R,children:k});case "android":return jsx(om,{theme:a,screenW:v,screenH:E,frameColor:p,...R,children:k});case "tablet":return jsx(nm,{theme:a,screenW:v,screenH:E,frameColor:p,...R,children:k});case "laptop":return jsx(am,{theme:a,screenW:v,screenH:E,frameColor:p,children:k});case "desktop":return jsx(sm,{theme:a,screenW:v,screenH:E,frameColor:p,children:k});case "watch":return jsx(im,{theme:a,screenW:v,screenH:E,frameColor:p,...R,children:k});case "browser":return jsx(lm,{theme:a,screenW:v,screenH:E,frameColor:p,children:k})}};return jsx("div",{className:c("inline-flex",b),"data-testid":"device-mockup","data-orientation":n,"data-theme":a,"data-size":s,children:g()})}var wa={solid:"border-solid",dashed:"border-dashed",dotted:"border-dotted"},cm={left:{before:"flex-[0.1]",after:"flex-1"},center:{before:"flex-1",after:"flex-1"},right:{before:"flex-1",after:"flex-[0.1]"}};function Fl({orientation:e="horizontal",variant:t="solid",label:r,textAlign:o="center",thickness:n=1,color:a="border-gray-300 dark:border-gray-700",spacing:s,className:l,...i}){if(e==="vertical")return jsx("hr",{"aria-orientation":"vertical",className:c("h-full border-l-0 border-r",wa[t],a,s||"mx-2",l),style:{borderRightWidth:`${n}px`},...i});if(r){let d=cm[o];return jsxs("div",{role:"separator","aria-orientation":"horizontal",className:c("flex items-center text-sm text-gray-500 dark:text-gray-400",s||"my-4",l),...i,children:[jsx("div",{className:c("border-t",wa[t],a,d.before),style:{borderTopWidth:`${n}px`}}),jsx("span",{className:"px-3 whitespace-nowrap",children:r}),jsx("div",{className:c("border-t",wa[t],a,d.after),style:{borderTopWidth:`${n}px`}})]})}return jsx("hr",{"aria-orientation":"horizontal",className:c("border-t-0 border-b",wa[t],a,s||"my-4",l),style:{borderBottomWidth:`${n}px`},...i})}Fl.displayName="Divider";var pm=new Set(["SCRIPT","STYLE","LINK","META","NOSCRIPT","TEMPLATE","BASE","TITLE"]),Bl="data-synertech-inert-ignore",In=new WeakMap,Ms=new WeakMap,Ls=new WeakMap;function gm(e){let t=In.get(e)??0;t===0&&(Ms.set(e,e.getAttribute("aria-hidden")),Ls.set(e,e.hasAttribute("inert")),e.setAttribute("aria-hidden","true"),e.setAttribute("inert","")),In.set(e,t+1);}function mm(e){let t=In.get(e)??0;if(t===0)return;if(t>1){In.set(e,t-1);return}In.delete(e);let r=Ms.get(e)??null;r===null?e.removeAttribute("aria-hidden"):e.setAttribute("aria-hidden",r),Ms.delete(e),Ls.get(e)||e.removeAttribute("inert"),Ls.delete(e);}var Ca=new Map;function No(e,t){return Ca.set(e,t),()=>{Ca.delete(e);}}function Na(e){if(Ca.size===0)return [];let t=[];for(let[r,o]of Ca){let n=o();n&&e.some(a=>a.contains(n))&&t.push(r);}return t}function fm(e){return !(pm.has(e.tagName)||e.hasAttribute(Bl))}function As(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 o=[...t,...Na(t).filter(i=>r.contains(i))],n=[],a=new Set,s=i=>o.some(d=>i===d||i.contains(d));for(let i of t){let d=i;for(;d&&d!==r;){let u=d.parentElement;if(!u)break;for(let p of Array.from(u.children))a.has(p)||s(p)||fm(p)&&(a.add(p),gm(p),n.push(p));d=u;}}let l=false;return ()=>{if(!l){l=true;for(let i of n)mm(i);}}}var no=[];function Vl(e){let t=no.indexOf(e);t!==-1&&no.splice(t,1),no.push(e);}function Ol(e){let t=no.indexOf(e);t!==-1&&no.splice(t,1);}function $l(e){return no.length>0&&no[no.length-1]===e}var Mn=0,zs=null;function _l(e=document){let t=e.body;if(!t)return ()=>{};Mn===0&&(zs=t.style.overflow,t.style.overflow="hidden"),Mn+=1;let r=false;return ()=>{r||(r=true,Mn=Math.max(0,Mn-1),Mn===0&&(t.style.overflow=zs??"",zs=null));}}var Gl=["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 bm(e){let t=e.ownerDocument?.defaultView;if(!t)return null;try{return t.getComputedStyle(e)}catch{return null}}function Xl(e){let t=e;for(;t;){if(t.hasAttribute("hidden")||t.hasAttribute("inert")||t.getAttribute("aria-hidden")==="true")return false;let r=bm(t);if(r&&(r.display==="none"||r.visibility==="hidden"||r.visibility==="collapse"))return false;t=t.parentElement;}return true}function Kl(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 Xl(e)}function Sa(e){return Array.from(e.querySelectorAll(Gl)).filter(Kl).sort((r,o)=>{let n=r.compareDocumentPosition(o);return n&Node.DOCUMENT_POSITION_FOLLOWING?-1:n&Node.DOCUMENT_POSITION_PRECEDING?1:0})}var hm={role:"dialog","aria-modal":true,tabIndex:-1};function ym(e,t){return t==="none"?null:t&&typeof t=="object"?t.current??e:t==="first"?Sa(e)[0]??e:e}function xm(e){return e?e.map(t=>t&&"current"in t?t.current:t).filter(t=>!!t):[]}function Uo(e){if(e)try{e.focus();}catch{}}function So(e){let{open:t}=e,r=useRef(null),o=useRef(e);return o.current=e,useEffect(()=>{if(!t)return;let n=r.current;if(!n)return;let a=n.ownerDocument,s=a.activeElement,{hideBackground:l,lockScroll:i,initialFocus:d,keepInteractive:u}=o.current;Vl(n);let p=l===false?void 0:As([n,...xm(u)]),b=i===false?void 0:_l(a);return Uo(ym(n,d)),()=>{p?.(),b?.(),Ol(n);let{returnFocus:m}=o.current;if(m===false)return;let f=a.activeElement;if(!(!f||f===a.body||n.contains(f)))return;let y=m&&typeof m=="object"?m.current:s;y&&a.contains(y)&&Uo(y);}},[t]),useEffect(()=>{if(!t)return;let n=r.current;if(!n)return;let a=n.ownerDocument,s=a.defaultView??a,l=d=>d?n.contains(d)?true:Na([n]).some(u=>u.contains(d)):false,i=d=>{if(d.defaultPrevented||!$l(n))return;let{closeOnEscape:u,trapFocus:p,onClose:b}=o.current;if(d.key==="Escape"){if(u===false)return;d.preventDefault(),b?.();return}if(d.key!=="Tab"||p===false)return;let m=a.activeElement;if(m&&!n.contains(m)&&l(m))return;let f=Sa(n);if(f.length===0){d.preventDefault(),Uo(n);return}let h=f[0],y=f[f.length-1];if(!m||!n.contains(m)){d.preventDefault(),Uo(d.shiftKey?y:h);return}if(d.shiftKey&&(m===h||m===n)){d.preventDefault(),Uo(y);return}!d.shiftKey&&m===y&&(d.preventDefault(),Uo(h));};return s.addEventListener("keydown",i),()=>s.removeEventListener("keydown",i)},[t]),{dialogRef:r,dialogProps:hm}}var Nm={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"}},Sm={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"},jl={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"}},Rm=jsx("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})});function ql({open:e,onClose:t,children:r,position:o="right",size:n="md",customWidth:a,customHeight:s,showOverlay:l=true,closeOnOverlayClick:i=true,closeOnEscape:d=true,title:u,footer:p,className:b,overlayClassName:m,closeLabel:f,"aria-label":h,trapFocus:y=true,initialFocus:C,returnFocus:v,lockScroll:E=true}){let k=!!(a||s),R=useRef(null),g=Ft(),T=`${useId()}-drawer-title`,{dialogRef:D,dialogProps:W}=So({open:e,onClose:t,closeOnEscape:d,trapFocus:y,initialFocus:C,returnFocus:v,lockScroll:E,keepInteractive:[R]}),V=useCallback(()=>{i&&t();},[i,t]);if(!e)return null;let _=jsxs(Fragment,{children:[l&&jsx("div",{ref:R,className:c("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:V,"aria-hidden":"true"}),jsxs("div",{ref:D,...W,"aria-labelledby":u?T:void 0,"aria-label":u?void 0:h,className:c("fixed z-50 bg-white dark:bg-gray-900","shadow-xl overflow-hidden","flex flex-col focus:outline-none",Sm[o],!k&&Nm[o][n],e?jl[o].enter:jl[o].exit,b),style:{...a?{width:a}:{},...s?{height:s}:{}},children:[u&&jsxs("div",{className:"flex items-center justify-between px-6 py-4 border-b border-gray-200 dark:border-gray-700",children:[jsx("h2",{id:T,className:"text-lg font-semibold text-gray-900 dark:text-white",children:u}),jsx("button",{type:"button",onClick:t,className:c("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":f??g.closeDrawer,children:Rm})]}),jsx("div",{className:"flex-1 overflow-y-auto px-6 py-4",children:r}),p&&jsx("div",{className:"px-6 py-4 border-t border-gray-200 dark:border-gray-700",children:p})]})]});return typeof document<"u"?createPortal(_,document.body):_}ql.displayName="Drawer";var Dm={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"}},ed=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]}`},Hs=e=>e.webkitRelativePath||e.name,Im=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: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"})}),Mm=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: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"})}),Lm=0;async function Am(e){let t=[],r=async o=>{if(o.isFile){let n=await new Promise((a,s)=>o.file(a,s));t.push(n);}else if(o.isDirectory){let n=o.createReader(),a=()=>new Promise((l,i)=>n.readEntries(l,i)),s=await a();for(;s.length>0;){for(let l of s)await r(l);s=await a();}}};for(let o of e)await r(o);return t}function zm({value:e,onChange:t,accept:r,multiple:o=false,maxSize:n=10*1024*1024,maxFiles:a,mode:s="file",variant:l="dropzone",size:i="md",disabled:d=false,readOnly:u=false,label:p,helperText:b,error:m,showFileList:f=true,placeholder:h,browseLabel:y,browseFolderLabel:C,icon:v,onReject:E,className:k}){let[R,g]=useState([]),[P,T]=useState(false),D=useRef(null),W=useRef(null),V=useId(),_=e!==void 0,M=_?e.map((Y,le)=>({file:Y,id:`ctrl-${le}`})):R,w=Dm[i];useEffect(()=>{s==="directory"&&D.current&&D.current.setAttribute("webkitdirectory",""),s==="both"&&W.current&&W.current.setAttribute("webkitdirectory","");},[s]);let N=useMemo(()=>ed(n),[n]),x=useMemo(()=>r?r.split(",").map(Y=>Y.trim()).map(Y=>Y.startsWith(".")?Y.toUpperCase():Y.endsWith("/*")?Y.replace("/*","").toUpperCase():Y).join(", "):"All files",[r]),S=s==="directory"?"Drag & drop a folder here, or":s==="both"?"Drag & drop files or folders here, or":o?"Drag & drop files here, or":"Drag & drop a file here, or",I=s==="directory"?"Browse folder":"Browse",F="Browse folder",O=useCallback(Y=>{if(Y.size>n)return `File exceeds maximum size of ${N}`;if(r){let le=r.split(",").map(te=>te.trim()),xe=`.${Y.name.split(".").pop()?.toLowerCase()}`;if(!le.some(te=>te.startsWith(".")?xe===te.toLowerCase():te.endsWith("/*")?Y.type.startsWith(te.replace("/*","/")):Y.type===te))return `File type not accepted. Expected: ${x}`}return null},[r,x,n,N]),Z=useCallback(Y=>{if(d||u)return;let le=Array.from(Y),xe=[];for(let Se of le){let te=O(Se);te?E?.(Se,te):xe.push(Se);}if(xe.length!==0)if(_)if(o){let te=[...e??[],...xe],Ne=a?te.slice(0,a):te;t?.(Ne);}else t?.([xe[0]]);else g(Se=>{let te=xe.map(Ne=>({file:Ne,id:`file-${++Lm}`}));if(o){let Ne=[...Se,...te],De=a?Ne.slice(0,a):Ne,Ve=De.map(rt=>rt.file);return t?.(Ve),De}return t?.([xe[0]]),[te[0]]});},[d,u,_,o,a,e,t,E,O]),U=useCallback(Y=>{if(!(d||u)){if(_){let le=(e??[]).filter((xe,Se)=>Se!==Y);t?.(le);}else g(le=>{let xe=le.filter((Se,te)=>te!==Y);return t?.(xe.map(Se=>Se.file)),xe});D.current&&(D.current.value="");}},[d,u,_,e,t]),H=useCallback(()=>{d||u||(_?t?.([]):(g([]),t?.([])),D.current&&(D.current.value=""));},[d,u,_,t]),z=useCallback(Y=>{Y.target.files&&Y.target.files.length>0&&Z(Y.target.files);},[Z]),$=useCallback(Y=>{Y.preventDefault(),Y.stopPropagation(),!d&&!u&&T(true);},[d,u]),K=useCallback(Y=>{Y.preventDefault(),Y.stopPropagation(),T(false);},[]),se=useCallback(Y=>{if(Y.preventDefault(),Y.stopPropagation(),T(false),d||u)return;let le=Y.dataTransfer.items;if(le&&le.length>0&&(s==="directory"||s==="both")){let xe=[];for(let te=0;te<le.length;te++){let Ne=le[te].webkitGetAsEntry?.();Ne&&xe.push(Ne);}if(xe.some(te=>te.isDirectory)){Am(xe).then(te=>{te.length>0&&Z(te);});return}}Y.dataTransfer.files&&Y.dataTransfer.files.length>0&&Z(Y.dataTransfer.files);},[d,u,s,Z]),X=useCallback(()=>{!d&&!u&&D.current?.click();},[d,u]),ee=useCallback(()=>{!d&&!u&&W.current?.click();},[d,u]),L=M.length>0,q=v||(s==="directory"?Mm:Im),ge=f&&L&&jsxs("div",{className:c("flex flex-col",w.gap),children:[M.map((Y,le)=>jsxs("div",{className:c("flex items-center justify-between rounded-md border border-gray-200 dark:border-gray-700 bg-gray-50 dark:bg-gray-800/50",w.fileItem),children:[jsxs("div",{className:"flex items-center gap-2 min-w-0 flex-1",children:[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: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"})}),jsx("span",{className:"truncate text-gray-700 dark:text-gray-300",children:Hs(Y.file)}),jsxs("span",{className:"shrink-0 text-gray-400 dark:text-gray-500",children:["(",ed(Y.file.size),")"]})]}),!d&&!u&&jsx("button",{type:"button",onClick:()=>U(le),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 ${Hs(Y.file)}`,children: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:jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M6 18L18 6M6 6l12 12"})})})]},Y.id)),o&&M.length>1&&!d&&!u&&jsx("button",{type:"button",onClick:H,className:c("self-start text-gray-400 hover:text-red-500 dark:text-gray-500 dark:hover:text-red-400 transition-colors cursor-pointer",w.subtext),children:"Remove all"})]}),de=c("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",w.button,m&&"border-red-300 dark:border-red-600");return jsxs("div",{className:c("flex flex-col",w.gap,k),children:[p&&jsx("label",{htmlFor:V,className:c("block font-medium text-gray-700 dark:text-gray-300",w.text),children:p}),jsx("input",{ref:D,id:V,type:"file",accept:s!=="directory"?r:void 0,multiple:o,onChange:z,className:"sr-only",disabled:d||u,"aria-describedby":m?`${V}-error`:b?`${V}-helper`:void 0,"aria-invalid":!!m}),s==="both"&&jsx("input",{ref:W,type:"file",onChange:z,className:"sr-only",disabled:d||u,tabIndex:-1,"aria-hidden":"true"}),l==="dropzone"?jsxs("div",{role:s==="both"?"group":"button",tabIndex:s==="both"?void 0:d||u?-1:0,onClick:s==="both"?void 0:X,onKeyDown:s==="both"?void 0:Y=>{(Y.key==="Enter"||Y.key===" ")&&(Y.preventDefault(),X());},onDragOver:$,onDragLeave:K,onDrop:se,className:c("flex flex-col items-center justify-center rounded-lg border-2 border-dashed transition-colors",w.dropzone,P&&!d&&!u?"border-blue-500 bg-blue-50 dark:bg-blue-900/20":"border-gray-300 dark:border-gray-600 bg-white dark:bg-gray-800",!d&&!u&&"hover:border-blue-400 dark:hover:border-blue-500 hover:bg-gray-50 dark:hover:bg-gray-800/70",s!=="both"&&!d&&!u&&"cursor-pointer",d&&"opacity-50 cursor-not-allowed",u&&"cursor-default",m&&"border-red-300 dark:border-red-600"),"aria-label":s==="both"?"File and folder drop zone":h||S,children:[jsx("div",{className:c("text-gray-400 dark:text-gray-500 mb-2",w.icon,P&&"text-blue-500 dark:text-blue-400"),children:q}),jsxs("p",{className:c("text-gray-600 dark:text-gray-400",w.text),children:[h||S," ",!d&&!u&&s!=="both"&&jsx("span",{className:"text-blue-600 dark:text-blue-400 font-medium",children:y||I})]}),s==="both"&&!d&&!u&&jsxs("div",{className:c("flex items-center gap-3 mt-1",w.text),children:[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:y||"Browse files"}),jsx("span",{className:"text-gray-300 dark:text-gray-600",children:"\xB7"}),jsx("button",{type:"button",onClick:ee,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:C||F})]}),jsxs("p",{className:c("text-gray-400 dark:text-gray-500 mt-1",w.subtext),children:[x," - Max ",N,o&&a&&` - Up to ${a} files`]})]}):jsxs("div",{className:"flex items-center gap-2",children:[s==="both"?jsxs(Fragment,{children:[jsx("button",{type:"button",onClick:X,disabled:d||u,className:de,children:y||(L?"Change files":"Choose files")}),jsx("button",{type:"button",onClick:ee,disabled:d||u,className:de,children:C||"Choose folder"})]}):jsx("button",{type:"button",onClick:X,disabled:d||u,className:de,children:y||(s==="directory"?L?"Change folder":"Choose folder":L?"Change file":"Choose file")}),!L&&jsx("span",{className:c("text-gray-400 dark:text-gray-500",w.text),children:s==="directory"?"No folder selected":s==="both"?"No file or folder selected":"No file selected"}),L&&!f&&jsx("span",{className:c("text-gray-600 dark:text-gray-400 truncate",w.text),children:M.length===1?Hs(M[0].file):`${M.length} files selected`})]}),ge,m&&jsx("p",{id:`${V}-error`,className:c("text-red-600 dark:text-red-400",w.subtext),role:"alert",children:m}),b&&!m&&jsx("p",{id:`${V}-helper`,className:c("text-gray-400 dark:text-gray-500",w.subtext),children:b})]})}var od=createContext(null);function Yt(){let e=useContext(od);if(!e)throw new Error("Dropdown compound components must be used within a Dropdown");return e}function nd({open:e,defaultOpen:t=false,onOpenChange:r,closeOnSelect:o=true,closeOnClickOutside:n=true,closeOnEscape:a=true,modal:s=false,children:l}){let[i,d]=useState(t),u=e!==void 0,p=u?e:i,b=useRef(null),m=useRef(null),f=useRef([]),[h,y]=useState(-1),C=useRef(0),v=useId(),E={triggerId:`dropdown-trigger-${v}`,contentId:`dropdown-content-${v}`},k=useCallback(T=>{u||d(T),r?.(T),T||y(-1);},[u,r]),R=useCallback((T,D)=>{f.current&&(f.current[T]=D);},[]),g=useCallback(()=>C.current++,[]),P={isOpen:p,setIsOpen:k,triggerRef:b,contentRef:m,closeOnSelect:o,closeOnClickOutside:n,closeOnEscape:a,modal:s,focusedIndex:h,setFocusedIndex:y,itemsRef:f,registerItem:R,getNextItemIndex:g,triggerId:E.triggerId,contentId:E.contentId};return jsx(od.Provider,{value:P,children:jsx("div",{className:"relative inline-block",children:l})})}nd.displayName="Dropdown";var ad=memo(({isOpen:e})=>jsx("span",{className:c("inline-block transition-transform",e&&"rotate-180"),children:jsx("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24","aria-hidden":"true",children:jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 9l-7 7-7-7"})})}));ad.displayName="ChevronIcon";function sd({asChild:e=false,disabled:t=false,children:r,className:o}){let{isOpen:n,setIsOpen:a,triggerRef:s,triggerId:l,contentId:i}=Yt(),p={ref:s,id:l,"aria-haspopup":"menu","aria-expanded":n,"aria-controls":n?i:void 0,disabled:t,onClick:()=>{t||a(!n);},onKeyDown:b=>{t||((b.key==="Enter"||b.key===" ")&&(b.preventDefault(),a(!n)),b.key==="ArrowDown"&&!n&&(b.preventDefault(),a(true)));}};return e&&isValidElement(r)?cloneElement(r,{...p,className:c(r.props.className,o)}):jsxs("button",{type:"button",...p,className:c("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",o),children:[r,jsx(ad,{isOpen:n})]})}sd.displayName="DropdownTrigger";function Yo(e){let t=useRef(e);return useLayoutEffect(()=>{t.current=e;}),t}function jo(e,t,r=true){let o=Yo(t);useEffect(()=>{if(!r)return;let n=a=>{let s=a.target;!e.current||e.current.contains(s)||o.current();};return document.addEventListener("mousedown",n),document.addEventListener("touchstart",n,{passive:true}),()=>{document.removeEventListener("mousedown",n),document.removeEventListener("touchstart",n);}},[r,o,e]);}function qo({triggerRef:e,contentRef:t,isOpen:r,side:o="bottom",align:n="start",sideOffset:a=4,alignOffset:s=0,avoidCollisions:l=true,collisionPadding:i=8}){let[d,u]=useState({top:0,left:0,actualSide:o,actualAlign:n,isReady:false}),p=useRef(false),b=useCallback(()=>{if(!e.current||!t.current)return;let m=e.current.getBoundingClientRect(),f=t.current.getBoundingClientRect();if(!(m.width>0&&m.height>0&&f.width>0&&f.height>0)){p.current=false;return}let y={width:window.innerWidth,height:window.innerHeight},C=o,v=n,E=g=>{switch(g){case "bottom":return {top:m.bottom+a,left:m.left};case "top":return {top:m.top-f.height-a,left:m.left};case "right":return {top:m.top,left:m.right+a};case "left":return {top:m.top,left:m.left-f.width-a}}},k=(g,P,T)=>{if(g==="top"||g==="bottom")switch(P){case "start":return {...T,left:m.left+s};case "center":return {...T,left:m.left+m.width/2-f.width/2+s};case "end":return {...T,left:m.right-f.width+s}}else switch(P){case "start":return {...T,top:m.top+s};case "center":return {...T,top:m.top+m.height/2-f.height/2+s};case "end":return {...T,top:m.bottom-f.height+s}}},R=E(C);if(R=k(C,v,R),l){let{top:g,left:P}=R,{height:T,width:D}=f,{height:W,width:V}=y,_=g+T>W-i,M=g<i,w=P+D>V-i,N=P<i;C==="bottom"&&_&&!M?(C="top",R=E(C),R=k(C,v,R)):C==="top"&&M&&!_&&(C="bottom",R=E(C),R=k(C,v,R)),C==="right"&&w&&!N?(C="left",R=E(C),R=k(C,v,R)):C==="left"&&N&&!w&&(C="right",R=E(C),R=k(C,v,R));let x=R.left+D>V-i,S=R.left<i,I=R.top+T>W-i,F=R.top<i;(C==="top"||C==="bottom")&&(x&&(R.left=V-D-i,v="end"),S&&(R.left=i,v="start")),(C==="left"||C==="right")&&(I&&(R.top=W-T-i,v="end"),F&&(R.top=i,v="start"));}p.current=true,u({top:R.top,left:R.left,actualSide:C,actualAlign:v,isReady:true});},[e,t,o,n,a,s,l,i]);return useLayoutEffect(()=>{let m=0;if(r){p.current=false;let h=()=>{b(),p.current||(m=requestAnimationFrame(h));};m=requestAnimationFrame(h);}let f=()=>b();return window.addEventListener("resize",f),window.addEventListener("scroll",f,{passive:true,capture:true}),()=>{m&&cancelAnimationFrame(m),window.removeEventListener("resize",f),window.removeEventListener("scroll",f,{capture:true});}},[b,r]),d}function Pa({isOpen:e,onClose:t,itemsCount:r,focusedIndex:o,setFocusedIndex:n,onSelect:a,loop:s=true}){let l=Yo(t),i=Yo(a),d=Yo(o),u=useCallback(p=>{if(!(!e||r===0))switch(p.key){case "ArrowDown":p.preventDefault(),n(s?b=>b<r-1?b+1:0:b=>Math.min(b+1,r-1));break;case "ArrowUp":p.preventDefault(),n(s?b=>b>0?b-1:r-1:b=>Math.max(b-1,0));break;case "Home":p.preventDefault(),n(0);break;case "End":p.preventDefault(),n(r-1);break;case "Enter":case " ":p.preventDefault(),i.current?.(d.current);break;case "Escape":p.preventDefault(),l.current();break;case "Tab":l.current();break}},[e,r,n,s,l,i,d]);return useEffect(()=>{if(e)return document.addEventListener("keydown",u),()=>document.removeEventListener("keydown",u)},[e,u]),{focusedIndex:o}}function ld(e,t,r){useEffect(()=>{r&&e.current&&e.current[t]&&e.current[t]?.focus();},[t,r,e]);}var rf={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 cd({side:e="bottom",align:t="start",sideOffset:r=4,alignOffset:o=0,avoidCollisions:n=true,collisionPadding:a=8,minWidth:s,maxWidth:l,maxHeight:i=300,animation:d="scale",portal:u=true,children:p,className:b}){let{isOpen:m,setIsOpen:f,triggerRef:h,contentRef:y,closeOnClickOutside:C,closeOnEscape:v,modal:E,contentId:k,focusedIndex:R,setFocusedIndex:g,itemsRef:P}=Yt(),[T,D]=useState(false),W=qo({triggerRef:h,contentRef:y,isOpen:m,side:e,align:t,sideOffset:r,alignOffset:o,avoidCollisions:n,collisionPadding:a});jo(y,()=>{C&&f(false);},m);let V=P.current?.filter(Boolean).length||0,_=useCallback(w=>{let N=P.current?.[w];N&&!N.hasAttribute("data-disabled")&&N.click();},[P]);Pa({isOpen:m,onClose:()=>{v&&(f(false),h.current?.focus());},itemsCount:V,focusedIndex:R,setFocusedIndex:g,onSelect:_}),useEffect(()=>{let w=y.current;if(w)return No(w,()=>h.current)},[y,h]),useEffect(()=>{if(m&&P.current&&P.current.length>0){let w=setTimeout(()=>{g(0),P.current?.[0]?.focus();},10);return ()=>clearTimeout(w)}},[m,P,g]),useLayoutEffect(()=>{let w=0;if(!m){D(false);return}let N=()=>{let x=h.current?.getBoundingClientRect(),S=y.current?.getBoundingClientRect();if(W.isReady&&!!x&&!!S&&x.width>0&&x.height>0&&S.width>0&&S.height>0){D(true);return}w=requestAnimationFrame(N);};return D(false),w=requestAnimationFrame(N),()=>{w&&cancelAnimationFrame(w);}},[m,W.isReady,h,y]);let M=jsxs(Fragment,{children:[E&&m&&jsx("div",{className:"fixed inset-0 z-40 bg-black/20",onClick:()=>f(false)}),jsx("div",{ref:y,id:k,role:"menu","aria-orientation":"vertical","aria-hidden":!m,tabIndex:-1,style:{position:"fixed",top:W.top,left:W.left,minWidth:s??h.current?.offsetWidth,maxWidth:l,maxHeight:i,visibility:m&&T?"visible":"hidden",opacity:m&&T?1:0,pointerEvents:m&&T?"auto":"none"},className:c("z-50 overflow-auto rounded-lg","border border-gray-200 bg-white shadow-lg","dark:border-gray-700 dark:bg-gray-800",m&&T&&rf[d],b),children:jsx("div",{className:"py-1",children:p})})]});return u&&typeof document<"u"?createPortal(M,document.body):M}cd.displayName="DropdownContent";var df={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 pd({children:e,icon:t,iconPosition:r="left",description:o,shortcut:n,variant:a="default",closeOnSelect:s,onSelect:l,disabled:i=false,className:d,onClick:u,index:p,...b}){let{setIsOpen:m,closeOnSelect:f,focusedIndex:h,setFocusedIndex:y,registerItem:C,getNextItemIndex:v}=Yt(),E=useRef(null),[k]=useState(()=>p??v());useEffect(()=>(C(k,E.current),()=>{C(k,null);}),[k,C]);let R=s??f,g=h===k;return jsxs("button",{ref:E,role:"menuitem",type:"button",tabIndex:g?0:-1,disabled:i,"data-disabled":i||void 0,"data-focused":g||void 0,onClick:D=>{i||(l?.(),u?.(D),R&&m(false));},onMouseEnter:()=>{i||y(k);},className:c("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",df[a],i&&"opacity-50 cursor-not-allowed hover:bg-transparent",g&&"bg-gray-100 dark:bg-gray-700",d),...b,children:[t&&r==="left"&&jsx("span",{className:"mr-2 shrink-0 w-5 h-5",children:t}),jsxs("span",{className:"flex-1 min-w-0",children:[jsx("span",{className:"block truncate",children:e}),o&&jsx("span",{className:"block text-xs text-gray-500 dark:text-gray-400 truncate",children:o})]}),t&&r==="right"&&jsx("span",{className:"ml-2 shrink-0 w-5 h-5",children:t}),n&&jsx("span",{className:"ml-auto pl-4 text-xs text-gray-400 dark:text-gray-500",children:n})]})}pd.displayName="DropdownItem";function gd({className:e}){return jsx("hr",{className:c("my-1 h-px border-0 bg-gray-200 dark:bg-gray-700",e)})}gd.displayName="DropdownSeparator";function md({children:e,className:t}){return jsx("div",{className:c("px-3 py-1.5 text-xs font-semibold text-gray-500 dark:text-gray-400",t),children:e})}md.displayName="DropdownLabel";function yd({checked:e,defaultChecked:t=false,onCheckedChange:r,children:o,icon:n,description:a,disabled:s=false,closeOnChange:l=false,className:i,index:d}){let{setIsOpen:u,focusedIndex:p,setFocusedIndex:b,registerItem:m,getNextItemIndex:f}=Yt(),h=useRef(null),[y]=useState(()=>d??f()),[C,v]=useState(t),E=e!==void 0,k=E?e:C;useEffect(()=>(m(y,h.current),()=>{m(y,null);}),[y,m]);let R=p===y;return jsxs("button",{ref:h,role:"menuitemcheckbox",type:"button",tabIndex:R?0:-1,"aria-checked":k,disabled:s,"data-disabled":s||void 0,"data-focused":R||void 0,onClick:()=>{if(s)return;let T=!k;E||v(T),r?.(T),l&&u(false);},onMouseEnter:()=>{s||b(y);},className:c("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",R&&"bg-gray-100 dark:bg-gray-700",i),children:[jsx("span",{className:"mr-2 shrink-0 w-4 h-4",children:n||jsx("span",{className:c("flex items-center justify-center w-4 h-4 rounded border-2 transition-colors",k?"bg-blue-600 border-blue-600":"border-gray-300 dark:border-gray-600"),children:k&&jsx("svg",{className:"w-3 h-3 text-white",viewBox:"0 0 16 16",fill:"none",children:jsx("path",{d:"M13.5 4.5L6 12L2.5 8.5",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round"})})})}),jsxs("span",{className:"flex-1 min-w-0",children:[jsx("span",{className:"block truncate",children:o}),a&&jsx("span",{className:"block text-xs text-gray-500 dark:text-gray-400 truncate",children:a})]})]})}yd.displayName="DropdownCheckboxItem";var kd=createContext(null);function yf(){let e=useContext(kd);if(!e)throw new Error("DropdownRadioItem must be used within a DropdownRadioGroup");return e}function wd({value:e,defaultValue:t="",onValueChange:r,children:o,className:n}){let[a,s]=useState(t),l=e!==void 0,i=l?e:a,d=useCallback(p=>{l||s(p),r?.(p);},[l,r]),u=useMemo(()=>({value:i,onValueChange:d}),[i,d]);return jsx(kd.Provider,{value:u,children:jsx("div",{role:"group",className:n,children:o})})}wd.displayName="DropdownRadioGroup";function Cd({value:e,children:t,icon:r,description:o,disabled:n=false,closeOnChange:a=true,className:s,index:l}){let{value:i,onValueChange:d}=yf(),{setIsOpen:u,focusedIndex:p,setFocusedIndex:b,registerItem:m,getNextItemIndex:f}=Yt(),h=useRef(null),[y]=useState(()=>l??f()),C=i===e;useEffect(()=>(m(y,h.current),()=>{m(y,null);}),[y,m]);let v=p===y;return jsxs("button",{ref:h,role:"menuitemradio",type:"button",tabIndex:v?0:-1,"aria-checked":C,disabled:n,"data-disabled":n||void 0,"data-focused":v||void 0,onClick:()=>{n||(d(e),a&&u(false));},onMouseEnter:()=>{n||b(y);},className:c("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",n&&"opacity-50 cursor-not-allowed hover:bg-transparent",v&&"bg-gray-100 dark:bg-gray-700",s),children:[jsx("span",{className:"mr-2 shrink-0 w-4 h-4",children:r||jsx("span",{className:c("flex items-center justify-center w-4 h-4 rounded-full border-2 transition-colors",C?"border-blue-600":"border-gray-300 dark:border-gray-600"),children:C&&jsx("span",{className:"w-2 h-2 rounded-full bg-blue-600"})})}),jsxs("span",{className:"flex-1 min-w-0",children:[jsx("span",{className:"block truncate",children:t}),o&&jsx("span",{className:"block text-xs text-gray-500 dark:text-gray-400 truncate",children:o})]}),C&&!r&&jsx("svg",{className:"ml-auto w-4 h-4 text-blue-600",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M5 13l4 4L19 7"})})]})}Cd.displayName="DropdownRadioItem";var Td=createContext(null);function Pd(){let e=useContext(Td);if(!e)throw new Error("DropdownSubMenu components must be used within a DropdownSubMenu");return e}function Ed({children:e}){let[t,r]=useState(false),o=useRef(null),n=useRef(null),a=useMemo(()=>({isOpen:t,setIsOpen:r,triggerRef:o,contentRef:n}),[t]);return jsx(Td.Provider,{value:a,children:jsx("div",{className:"relative",children:e})})}Ed.displayName="DropdownSubMenu";var Sd=0;function Dd({children:e,icon:t,disabled:r=false,className:o,index:n}){let{isOpen:a,setIsOpen:s,triggerRef:l}=Pd(),{focusedIndex:i,setFocusedIndex:d,registerItem:u}=Yt(),p=useRef(n??-1);useEffect(()=>(n===void 0&&(p.current=Sd++),u(p.current,l.current),()=>{u(p.current,null);}),[n,u,l]),useEffect(()=>()=>{Sd=0;},[]);let b=i===p.current;return jsxs("button",{ref:l,role:"menuitem",type:"button",tabIndex:b?0:-1,"aria-haspopup":"menu","aria-expanded":a,disabled:r,"data-disabled":r||void 0,"data-focused":b||void 0,onMouseEnter:()=>{r||(d(p.current),s(true));},onMouseLeave:()=>{setTimeout(()=>{s(false);},100);},onKeyDown:y=>{r||(y.key==="ArrowRight"||y.key==="Enter")&&(y.preventDefault(),s(true));},className:c("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",b&&"bg-gray-100 dark:bg-gray-700",o),children:[t&&jsx("span",{className:"mr-2 shrink-0 w-5 h-5",children:t}),jsx("span",{className:"flex-1",children:e}),jsx("svg",{className:"ml-auto w-4 h-4 text-gray-400",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 5l7 7-7 7"})})]})}Dd.displayName="DropdownSubMenuTrigger";function Id({children:e,sideOffset:t=0,className:r}){let{isOpen:o,setIsOpen:n,triggerRef:a,contentRef:s}=Pd(),[l,i]=useState(false),d=qo({triggerRef:a,contentRef:s,isOpen:o,side:"right",align:"start",sideOffset:t,avoidCollisions:true});jo(s,()=>n(false),o),useEffect(()=>{let f=s.current;if(f)return No(f,()=>a.current)},[s,a]);let u=useCallback(()=>{n(true);},[n]),p=useCallback(()=>{n(false);},[n]),b=f=>{(f.key==="ArrowLeft"||f.key==="Escape")&&(f.preventDefault(),n(false),a.current?.focus());};useLayoutEffect(()=>{let f=0;if(!o){i(false);return}let h=()=>{let y=a.current?.getBoundingClientRect(),C=s.current?.getBoundingClientRect();if(d.isReady&&!!y&&!!C&&y.width>0&&y.height>0&&C.width>0&&C.height>0){i(true);return}f=requestAnimationFrame(h);};return i(false),f=requestAnimationFrame(h),()=>{f&&cancelAnimationFrame(f);}},[o,d.isReady,a,s]);let m=jsx("div",{ref:s,role:"menu","aria-orientation":"vertical","aria-hidden":!o,tabIndex:-1,onMouseEnter:u,onMouseLeave:p,onKeyDown:b,style:{position:"fixed",top:d.top,left:d.left,visibility:o&&l?"visible":"hidden",opacity:o&&l?1:0,pointerEvents:o&&l?"auto":"none"},className:c("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",o&&l&&"animate-in fade-in-0 zoom-in-95 duration-150",r),children:jsx("div",{className:"py-1",children:e})});return typeof document<"u"?createPortal(m,document.body):m}Id.displayName="DropdownSubMenuContent";var Sf=(e="md")=>({sm:"text-xs p-1.5",md:"text-sm p-2.5",lg:"text-base p-3.5"})[e],Jo=({size:e="md",error:t,disabled:r,readOnly:o,icon:n,iconPosition:a})=>c("bg-gray-50 rounded-lg block w-full","border focus:outline-none focus:ring-0","dark:bg-gray-700 dark:placeholder-gray-400",Sf(e),n&&a==="left"?"pl-9":"",n&&a==="right"?"pr-9":"",r?"opacity-50 cursor-not-allowed":"",o?"bg-gray-100 dark:bg-gray-600 cursor-default":"",t?"border-red-500 dark:border-red-500":"border-gray-300 dark:border-gray-600"),Md=(e,t)=>c("text-sm font-medium",e?"min-w-[120px]":"block mb-2",!t&&"text-gray-900 dark:text-white"),Ld=e=>c("mt-1 text-xs",e?"text-red-500 dark:text-red-400":"text-gray-500 dark:text-gray-400"),To=e=>c("absolute inset-y-0 flex items-center pointer-events-none",e==="left"?"left-2.5":"right-2.5");var Qo=({label:e,hideLabel:t,labelColor:r,error:o,helperText:n,inline:a,children:s,htmlFor:l})=>jsxs("div",{className:a?"flex items-center gap-4":"flex flex-col",children:[e&&!t&&jsx("label",{htmlFor:l,className:Md(a||false,r),style:r?{color:r}:void 0,children:e}),jsx("div",{className:a?"flex-1":"w-full",children:s}),n&&jsx("p",{className:c(Ld(o),a&&"ml-34"),children:n})]});var Er=forwardRef(({label:e,inline:t=false,size:r="md",labelColor:o,borderColor:n,textColor:a,disabled:s=false,readOnly:l=false,error:i=false,helperText:d,hideLabel:u=false,icon:p,iconPosition:b="left",multiline:m=false,rows:f=3,focused:h=false,className:y,...C},v)=>{let E=useRef(null),k=W=>{E.current=W,typeof v=="function"?v(W):v&&(v.current=W);};useEffect(()=>{h&&E.current?.focus();},[h]);let R=useId(),g=c(Jo({size:r,error:i,disabled:s,readOnly:l,icon:p,iconPosition:b}),m&&"resize-vertical",y),P={...n&&{borderColor:n},...a&&{color:a}},T=n||a?P:void 0;return jsx(Qo,{label:e,hideLabel:u,labelColor:o,error:i,helperText:d,inline:t,htmlFor:R,children:jsxs("div",{className:"relative w-full",children:[p&&jsx("span",{className:To(b),children:p}),m?jsx("textarea",{ref:k,id:R,disabled:s,readOnly:l,rows:f,tabIndex:l||s?-1:void 0,className:g,style:T,...C}):jsx("input",{ref:k,id:R,disabled:s,readOnly:l,tabIndex:l||s?-1:void 0,className:g,style:T,...C})]})})});Er.displayName="Input";var Wf=e=>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&&jsx("img",{src:e.avatar,alt:e.label,className:"w-6 h-6 rounded-full"}),jsx("span",{className:"text-sm text-gray-900 dark:text-white",children:e.label})]}),Gs=forwardRef(({label:e,inline:t=false,size:r="md",labelColor:o,borderColor:n,textColor:a,disabled:s=false,readOnly:l=false,error:i=false,helperText:d,hideLabel:u=false,icon:p,iconPosition:b="left",mentionTrigger:m="@",suggestions:f=[],onMentionSearch:h,onMentionSelect:y,onMentionRemove:C,renderSuggestion:v,value:E,onChange:k,placeholder:R,loading:g=false,maxSuggestions:P=10,chipVariant:T="soft",chipColor:D="primary",chipSize:W="sm"},V)=>{let _=useId(),M=useRef(null),[w,N]=useState(false),[x,S]=useState(0),[I,F]=useState(""),O=c(Jo({size:r,error:i,disabled:s,readOnly:l,icon:p,iconPosition:b}),"min-h-[42px]","whitespace-pre-wrap","break-words"),Z={...n&&{borderColor:n},...a&&{color:a}},U=n||a?Z:void 0,H=useCallback(()=>{if(!M.current)return {text:"",mentions:[]};let L="",q=[],ge=0,de=Y=>{if(Y.nodeType===Node.TEXT_NODE)L+=Y.textContent||"",ge+=(Y.textContent||"").length;else if(Y.nodeType===Node.ELEMENT_NODE){let le=Y;if(le.hasAttribute("data-mention-id")){let xe=le.getAttribute("data-mention-id"),Se=le.getAttribute("data-mention-label")||"",te=le.getAttribute("data-mention-avatar")||void 0,Ne=`@${Se}`,De=ge;q.push({trigger:m,suggestion:{id:xe||"",label:Se,avatar:te},startIndex:De,endIndex:De+Ne.length}),L+=Ne,ge+=Ne.length;}else le.childNodes.forEach(de);}};return M.current.childNodes.forEach(de),{text:L,mentions:q}},[m]),z=useCallback((L,q)=>{let ge=document.createElement("span");return ge.contentEditable="false",ge.setAttribute("data-mention-id",L.id),ge.setAttribute("data-mention-label",L.label),L.avatar&&ge.setAttribute("data-mention-avatar",L.avatar),ge.className="inline-block align-middle mx-0.5",ge.style.userSelect="none",createRoot(ge).render(jsx(ka,{label:L.label,variant:T,color:D,size:W,closable:!s&&!l,onClose:q,disabled:s,avatar:L.avatar?jsx("img",{src:L.avatar,alt:L.label,className:"w-full h-full object-cover"}):void 0})),ge},[T,D,W,s,l]),$=useCallback(L=>{if(!M.current)return;let q=M.current.querySelector(`[data-mention-id="${L}"]`);if(q){q.remove();let ge=H();k?.(ge);let de=E?.mentions.find(Y=>Y.suggestion.id===L)?.suggestion;de&&C?.(de);}},[H,k,C,E?.mentions]),K=useCallback(()=>{if(!M.current)return;let L=window.getSelection();if(!L||L.rangeCount===0)return;let q=L.getRangeAt(0),ge="";q.startContainer.nodeType===Node.TEXT_NODE&&(ge=q.startContainer.textContent?.substring(0,q.startOffset)||"");let de=ge.match(new RegExp(`${m}(\\w*)$`));if(de){let le=de[1];F(le),N(true),S(0),h?.(le);}else N(false),F("");let Y=H();k?.(Y);},[m,h,k,H]),se=useCallback(L=>{if(!M.current)return;let q=window.getSelection();if(!q||q.rangeCount===0)return;let ge=q.getRangeAt(0);if(ge.startContainer.nodeType===Node.TEXT_NODE){let Y=ge.startContainer,le=Y.textContent||"",xe=ge.startOffset,te=le.substring(0,xe).lastIndexOf(m);if(te!==-1){let Ne=le.substring(0,te),De=le.substring(xe),Ve=z(L,()=>{$(L.id);});if(Ne?(Y.textContent=Ne,Y.parentNode?.insertBefore(Ve,Y.nextSibling)):(Y.parentNode?.insertBefore(Ve,Y),Y.textContent="",Y.textContent||Y.remove()),De){let re=document.createTextNode(De);Ve.parentNode?.insertBefore(re,Ve.nextSibling);}let rt=document.createTextNode(" ");Ve.parentNode?.insertBefore(rt,Ve.nextSibling);let dt=document.createRange();dt.setStartAfter(rt),dt.collapse(true),q.removeAllRanges(),q.addRange(dt);}}N(false),F("");let de=H();k?.(de),y?.(L),M.current.focus();},[m,z,$,H,k,y]),X=useCallback(L=>{let q=f.slice(0,P);if(w&&q.length>0)switch(L.key){case "ArrowDown":L.preventDefault(),S(ge=>ge<q.length-1?ge+1:0);return;case "ArrowUp":L.preventDefault(),S(ge=>ge>0?ge-1:q.length-1);return;case "Enter":case "Tab":L.preventDefault(),q[x]&&se(q[x]);return;case "Escape":L.preventDefault(),N(false);return}if(L.key==="Backspace"){let ge=window.getSelection();if(!ge||ge.rangeCount===0)return;let de=ge.getRangeAt(0);if(de.collapsed&&de.startOffset===0){let Y=de.startContainer.previousSibling;if(Y&&Y.nodeType===Node.ELEMENT_NODE){let le=Y;if(le.hasAttribute("data-mention-id")){L.preventDefault();let xe=le.getAttribute("data-mention-id");xe&&$(xe);return}}}if(de.collapsed&&de.startContainer.nodeType===Node.TEXT_NODE){let Y=de.startContainer;if(de.startOffset===0){let le=Y.previousSibling;if(le&&le.nodeType===Node.ELEMENT_NODE){let xe=le;if(xe.hasAttribute("data-mention-id")){L.preventDefault();let Se=xe.getAttribute("data-mention-id");Se&&$(Se);return}}}}}},[w,f,x,P,se,$]);return useEffect(()=>{M.current&&(!(M.current.textContent||M.current.querySelector("[data-mention-id]"))&&R?M.current.setAttribute("data-placeholder",R):M.current.removeAttribute("data-placeholder"));},[R,E]),useEffect(()=>{M.current&&E?.text===""&&E?.mentions.length===0&&M.current.innerHTML.trim()&&(M.current.innerHTML="");},[E?.text,E?.mentions.length]),jsx(Qo,{label:e,hideLabel:u,labelColor:o,error:i,helperText:d,inline:t,htmlFor:_,children:jsxs("div",{className:"relative w-full",children:[p&&jsx("span",{className:To(b),children:p}),jsx("div",{ref:L=>{typeof V=="function"?V(L):V&&(V.current=L),M.current=L;},id:_,contentEditable:!s&&!l,suppressContentEditableWarning:true,onInput:K,onKeyDown:X,className:c(O,"empty:before:content-[attr(data-placeholder)] empty:before:text-gray-400 empty:before:dark:text-gray-500"),style:U,role:"textbox","aria-label":e,"aria-multiline":"true",tabIndex:l||s?-1:0}),w&&f.length>0&&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:g?jsx("div",{className:"px-3 py-2 text-sm text-gray-500 dark:text-gray-400",children:"Loading..."}):f.slice(0,P).map((L,q)=>jsx("div",{onClick:()=>se(L),className:c(q===x&&"bg-gray-100 dark:bg-gray-600"),children:v?v(L):Wf(L)},L.id))})]})})});Gs.displayName="MentionInput";var Xs=forwardRef(({label:e,inline:t=false,size:r="md",labelColor:o,borderColor:n,textColor:a,disabled:s=false,readOnly:l=false,error:i=false,helperText:d,hideLabel:u=false,icon:p,iconPosition:b="left",className:m,value:f,onChange:h,format:y="number",currency:C="USD",locale:v="en-US",decimals:E,min:k,max:R,step:g=1,prefix:P,suffix:T,thousandSeparator:D=true,allowNegative:W=true,onBlur:V,onFocus:_,...M},w)=>{let N=useId(),[x,S]=useState(null),I=useMemo(()=>{let ee=y==="currency"?{style:"currency",currency:C,minimumFractionDigits:E??2,maximumFractionDigits:E??2}:y==="percentage"?{minimumFractionDigits:E??0,maximumFractionDigits:E??2}:{minimumFractionDigits:E??0,maximumFractionDigits:E??(y==="decimal"?2:0),useGrouping:D};try{return new Intl.NumberFormat(v,ee)}catch{return null}},[y,C,v,E,D]),F=ee=>{if(ee==null)return "";if(!I)return String(ee);let L=I.format(ee);return y==="percentage"?(L=P?`${P}${L}`:L,L=T||!L.includes("%")?`${L}%`:L,L):(P&&(L=`${P}${L}`),T&&(L=`${L}${T}`),L)},O=ee=>{if(!ee||ee.trim()==="")return null;let L=ee;if(P&&(L=L.replace(P,"")),T&&(L=L.replace(T,"")),L=L.replace(/[^\d.,-]/g,""),v.includes("fr")||v.includes("de")?L=L.replace(/\s/g,"").replace(",","."):L=L.replace(",",""),!L||L==="-"||L===".")return null;let q=parseFloat(L);return isNaN(q)?null:!W&&q<0?Math.abs(q):k!==void 0&&q<k?k:R!==void 0&&q>R?R:q},Z=x??F(f??null),U=ee=>{let L=v.includes("fr")||v.includes("de")?",":".";return new RegExp(`^-?[0-9${L===","?",":"\\."}]*$`).test(ee)},H=ee=>{let L=ee.target.value;if(L===""||U(L)){S(L);let q=O(L);h&&h(q);}},z=ee=>{let L=v.includes("fr")||v.includes("de")?",":".",q=["Backspace","Delete","Tab","Escape","Enter","ArrowLeft","ArrowRight","ArrowUp","ArrowDown","Home","End"],ge=/^[0-9]$/.test(ee.key),de=ee.key===L,Y=ee.key==="-"&&W&&Z.indexOf("-")===-1,le=ee.ctrlKey||ee.metaKey;!ge&&!de&&!Y&&!q.includes(ee.key)&&!le&&ee.preventDefault();},$=ee=>{let L=f!=null?String(f):"";S(L),_&&_(ee);},K=ee=>{let L=O(x??"");h&&L!==f&&h(L),S(null),V&&V(ee);},se=c(Jo({size:r,error:i,disabled:s,readOnly:l,icon:p,iconPosition:b}),n&&`border-[${n}]`,a&&`text-[${a}]`,m),X=jsxs("div",{className:"relative",children:[p&&b==="left"&&jsx("div",{className:To(b),children:p}),jsx("input",{ref:w,id:N,type:"text",inputMode:"decimal",className:se,style:{borderColor:n,color:a},disabled:s,readOnly:l,value:Z,onChange:H,onKeyDown:z,onFocus:$,onBlur:K,...M}),p&&b==="right"&&jsx("div",{className:To(b),children:p})]});return jsx(Qo,{label:e,hideLabel:u,labelColor:o,error:i,helperText:d,inline:t,htmlFor:N,children:X})});Xs.displayName="NumberInput";function $f({logo:e,logoHref:t="/",onLogoClick:r,navItems:o=[],actions:n,rightContent:a,variant:s="default",size:l="md",backgroundColor:i,textColor:d,hoverColor:u,navItemTextColor:p,navItemHoverColor:b,navItemBgHover:m,navItemActiveColor:f,sticky:h=false,fixed:y=false,showSearch:C=false,onSearch:v,searchPlaceholder:E="Search...",className:k,containerClassName:R}){let[g,P]=useState(false),[T,D]=useState(null),[W,V]=useState(""),_=()=>{P(!g);},M=H=>{D(T===H?null:H);},w=H=>{H.preventDefault(),v&&v(W);},N=c(h&&"sticky top-0 z-50",y&&"fixed top-0 left-0 right-0 z-50"),x=c(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"),S=c(l==="sm"&&"py-2",l==="md"&&"py-4",l==="lg"&&"py-6"),I=i||"",F=d||"",O=u||"",Z=c(N,x,S,I,F,k),U=(H,z,$=false)=>{let K=H.children&&H.children.length>0,se=T===z,X=c("px-4 py-2 transition-colors flex items-center gap-2",$?"block w-full text-left":"inline-flex",H.active&&"font-semibold border-b-2",H.active&&(f||"border-current"),p||(s==="default"||s==="transparent"?"text-gray-300":"text-gray-600 dark:text-gray-300"),b||O||(s==="default"||s==="transparent"?"hover:text-white":"hover:text-blue-600 dark:hover:text-blue-400"),m||"");if(K)return jsxs("div",{className:$?"w-full":"relative",children:[jsxs("button",{type:"button",onClick:()=>M(z),className:X,children:[H.icon&&jsx("span",{className:"w-5 h-5",children:H.icon}),jsx("span",{children:H.label}),H.badge&&jsx("span",{className:"bg-red-500 text-white text-xs px-2 py-0.5 rounded-full",children:H.badge}),jsx("svg",{className:c("w-4 h-4 transition-transform",se&&"rotate-180"),fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 9l-7 7-7-7"})})]}),se&&jsx("div",{className:c("bg-white shadow-lg rounded-lg overflow-hidden dark:bg-gray-800 dark:shadow-black/40",$?"mt-2 mb-2":"absolute top-full left-0 mt-1 min-w-[200px]"),children:H.children?.map(L=>jsx("a",{href:L.href,onClick:L.onClick,target:L.external?"_blank":void 0,rel:L.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:jsxs("div",{className:"flex items-center gap-2",children:[L.icon&&jsx("span",{className:"w-5 h-5",children:L.icon}),jsx("span",{children:L.label}),L.badge&&jsx("span",{className:"bg-red-500 text-white text-xs px-2 py-0.5 rounded-full ml-auto",children:L.badge}),L.external&&jsx("svg",{className:"w-4 h-4 ml-auto",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children: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"})})]})},L.href??L.label))})]},H.href??H.label);let ee=jsxs(Fragment,{children:[H.icon&&jsx("span",{className:"w-5 h-5",children:H.icon}),jsx("span",{children:H.label}),H.badge&&jsx("span",{className:"bg-red-500 text-white text-xs px-2 py-0.5 rounded-full",children:H.badge}),H.external&&jsx("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children: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 H.onClick?jsx("button",{type:"button",onClick:H.onClick,className:X,children:ee},H.href??H.label):jsx("a",{href:H.href,target:H.external?"_blank":void 0,rel:H.external?"noopener noreferrer":void 0,className:X,children:ee},H.href??H.label)};return jsxs("header",{className:Z,children:[jsxs("nav",{className:c("container mx-auto flex items-center justify-between px-4",R),children:[e&&jsx("div",{className:"flex items-center",children:t?jsx("a",{href:t,onClick:r,className:"flex items-center hover:opacity-80 transition-opacity",children:e}):jsx("div",{className:"flex items-center",children:e})}),C&&jsx("form",{onSubmit:w,className:"hidden md:flex flex-1 max-w-md mx-8",children:jsx("input",{type:"search","aria-label":E,value:W,onChange:H=>V(H.target.value),placeholder:E,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"})}),jsx("div",{className:"hidden md:flex items-center gap-2",children:o.map((H,z)=>U(H,z,false))}),(n||a)&&jsxs("div",{className:"hidden md:flex items-center gap-2 ml-4",children:[n,a]}),o.length>0&&jsx("div",{className:"md:hidden",children:jsx("button",{type:"button",className:c("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:_,"aria-label":"Toggle menu","aria-expanded":g,children: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:jsx("path",{stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",d:"M1 1h15M1 7h15M1 13h15"})})})})]}),g&&o.length>0&&jsx("div",{className:c("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:jsxs("div",{className:"flex flex-col py-2 px-4",children:[C&&jsx("form",{onSubmit:w,className:"mb-4",children:jsx("input",{type:"search","aria-label":E,value:W,onChange:H=>V(H.target.value),placeholder:E,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"})}),o.map((H,z)=>U(H,z,true)),(n||a)&&jsxs("div",{className:"flex flex-col gap-2 mt-4 pt-4 border-t border-gray-700",children:[n,a]})]})})]})}var Uf=jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[jsx("path",{d:"M11 4H4a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7"}),jsx("path",{d:"M18.5 2.5a2.121 2.121 0 0 1 3 3L12 15l-4 1 1-4 9.5-9.5z"})]}),Yf=jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[jsx("path",{d:"M19 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h11l5 5v11a2 2 0 0 1-2 2z"}),jsx("polyline",{points:"17 21 17 13 7 13 7 21"}),jsx("polyline",{points:"7 3 7 8 15 8"})]}),jf=jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]}),qf=jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[jsx("polyline",{points:"1 4 1 10 7 10"}),jsx("path",{d:"M3.51 15a9 9 0 1 0 2.13-9.36L1 10"})]}),Zf=jsxs("svg",{className:"animate-spin h-4 w-4",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10"}),jsx("path",{className:"opacity-75",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4z",fill:"currentColor"})]}),Jf={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"},Qf={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"},eb={sm:"w-56",md:"w-72",lg:"w-96",xl:"w-[32rem]"},tb=[Kf],rb={h1:({...e})=>jsx("h1",{className:"text-xl font-bold mb-2 text-gray-900 dark:text-gray-100",...e}),h2:({...e})=>jsx("h2",{className:"text-lg font-semibold mt-4 mb-2 text-gray-900 dark:text-gray-100",...e}),h3:({...e})=>jsx("h3",{className:"text-base font-semibold mt-3 mb-1 text-gray-900 dark:text-gray-100",...e}),p:({...e})=>jsx("p",{className:"my-1 text-gray-700 dark:text-gray-300",...e}),ul:({...e})=>jsx("ul",{className:"list-disc list-inside space-y-1 my-2 text-gray-700 dark:text-gray-300",...e}),ol:({...e})=>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-")?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}):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})=>jsx("pre",{className:"my-2",...e}),a:({...e})=>jsx("a",{className:"text-blue-600 dark:text-blue-400 hover:underline",...e}),strong:({...e})=>jsx("strong",{className:"font-semibold text-gray-900 dark:text-gray-100",...e}),em:({...e})=>jsx("em",{className:"italic",...e}),blockquote:({...e})=>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 Wd({content:e,markdown:t=false,position:r="bottom",size:o="sm",className:n="",visible:a=true,editable:s=false,onSave:l,onReset:i,width:d="md",title:u,markdownEditor:p,markdownEditorUnavailableLabel:b}){let m=Ft(),[f,h]=useState(false),[y,C]=useState(false),[v,E]=useState(""),[k,R]=useState(false),[g,P]=useState(null),T=useRef(null),D=useRef(null),W=useRef(null),V=useRef(null);useEffect(()=>{if(!f)return;let S=F=>{T.current&&!T.current.contains(F.target)&&D.current&&!D.current.contains(F.target)&&(y||h(false));},I=F=>{F.key==="Escape"&&(y?(C(false),E("")):h(false));};return document.addEventListener("mousedown",S),document.addEventListener("keydown",I),()=>{document.removeEventListener("mousedown",S),document.removeEventListener("keydown",I);}},[f,y]),useEffect(()=>{y&&W.current&&W.current.focus();},[y]),useEffect(()=>()=>{V.current&&clearTimeout(V.current);},[]);let _=useCallback(()=>{E(typeof e=="string"?e:""),C(true),P(null);},[e]),M=useCallback(()=>{C(false),E(""),P(null);},[]),w=useCallback(async()=>{if(!l){P({type:"error",text:"Aucune fonction de sauvegarde fournie"});return}R(true);try{await l(v)?(P({type:"success",text:"Sauvegard\xE9 avec succ\xE8s !"}),C(!1),V.current&&clearTimeout(V.current),V.current=setTimeout(()=>P(null),2e3)):P({type:"error",text:"Erreur lors de la sauvegarde"});}catch{P({type:"error",text:"Erreur lors de la sauvegarde"});}finally{R(false);}},[v,l]),N=useCallback(async()=>{if(i&&confirm("\xCAtes-vous s\xFBr de vouloir r\xE9initialiser ce contenu ?")){R(true);try{await i()?(P({type:"success",text:"R\xE9initialis\xE9 avec succ\xE8s !"}),C(!1),V.current&&clearTimeout(V.current),V.current=setTimeout(()=>P(null),2e3)):P({type:"error",text:"Erreur lors de la r\xE9initialisation"});}catch{P({type:"error",text:"Erreur lors de la r\xE9initialisation"});}finally{R(false);}}},[i]),x=e;return a?jsxs("div",{className:"relative inline-flex items-center",children:[jsx("button",{type:"button",ref:T,onClick:()=>h(!f),className:`
3
- ${Jf[o]}
1
+ import*as Ri from'react';import Ri__default,{createContext,forwardRef,memo,useId,useState,useRef,useEffect,useCallback,useImperativeHandle,useMemo,useContext,cloneElement,isValidElement,useLayoutEffect}from'react';import {jsx,jsxs,Fragment}from'react/jsx-runtime';import {createPortal}from'react-dom';import {createRoot}from'react-dom/client';import Vy from'dompurify';import By from'react-markdown';import Fy from'remark-gfm';function g(...e){return e.filter(Boolean).join(" ")}var ec=createContext(null),tc=createContext(null);function ci(){let e=useContext(ec);if(!e)throw new Error("Accordion sub-components must be used within <Accordion>");return e}function rc(){let e=useContext(tc);if(!e)throw new Error("AccordionTrigger/AccordionContent must be used within <AccordionItem>");return e}var nc={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"}},cg=({className:e})=>jsx("svg",{className:e,viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true",children: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"})}),dg={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:""},ug={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 mg({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:b}){let[m,p]=useState(()=>r?Array.isArray(r)?r:[r]:[]),C=t!==void 0,v=C?Array.isArray(t)?t:[t]:m,k=useCallback(z=>{let h;e==="single"?v.includes(z)?h=o?[]:[z]:h=[z]:h=v.includes(z)?v.filter(R=>R!==z):[...v,z],C||p(h),n?.(e==="single"?h[0]??"":h);},[e,v,o,C,n]),y=useMemo(()=>({openItems:v,toggle:k,variant:a,size:s,disabled:l,iconPosition:i,icon:c??null,hideIcon:d}),[v,k,a,s,l,i,c,d]);return jsx(ec.Provider,{value:y,children:jsx("div",{className:g(dg[a],u),"data-testid":"accordion",children:b})})}function gg({value:e,disabled:t,className:r,children:n}){let o=ci(),a=o.openItems.includes(e),s=t??o.disabled,l=useId(),i=`accordion-trigger-${l}`,c=`accordion-content-${l}`,d=useMemo(()=>({value:e,isOpen:a,disabled:s,triggerId:i,contentId:c}),[e,a,s,i,c]);return jsx(tc.Provider,{value:d,children:jsx("div",{className:g(ug[o.variant],r),"data-state":a?"open":"closed","data-testid":"accordion-item",children:n})})}function pg({className:e,icon:t,children:r}){let n=ci(),o=rc(),a=nc[n.size],s=()=>{o.disabled||n.toggle(o.value);},l=d=>{(d.key==="Enter"||d.key===" ")&&(d.preventDefault(),s());},i=t??n.icon??jsx(cg,{className:a.icon}),c=!n.hideIcon&&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 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,jsx("span",{className:"flex-1",children:r}),n.iconPosition==="right"&&c]})}function fg({className:e,children:t}){let r=ci(),n=rc(),o=nc[r.size],a=useRef(null),[s,l]=useState(n.isOpen?void 0:0),i=useRef(true);return 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]),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: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 vg(...e){return e.filter(Boolean).join(" ")}var kg="@synertech/ui/AdvanceDetachable",Cg=300,wg="width=800,height=600,menubar=no,toolbar=no,location=no,status=no,scrollbars=yes,resizable=yes",Ng=0;function Sg(){return `${Date.now()}-${++Ng}-${Math.random().toString(36).slice(2,8)}`}function oc(e){try{return JSON.stringify(e)}catch{return String(e)}}function ac(e){try{return JSON.parse(e)}catch{return e}}function Rg(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 Tg(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 Pg(){return typeof BroadcastChannel<"u"}function Eg({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:b=true,className:m,detachedBodyClassName:p,disabled:C=false,readOnly:v=false,closeOnMainWindowUnload:k=true,name:y,serialize:z,deserialize:h},R){let f=l!==void 0,[N,L]=useState(i),E=f?l:N,I=o!==void 0,[w,W]=useState(a),M=I?o:w,[T,P]=useState(null),x=useRef(null),D=useRef(null),S=useRef(null),B=useRef(null),H=useRef(false),$=useRef(null),_=useRef(null),F=useRef(null),[A]=useState(()=>`${Date.now().toString(36)}-${Math.random().toString(36).slice(2,8)}`),V=useRef({title:r,features:d,target:u,autoFocus:b,detachedBodyClassName:p,closeOnMainWindowUnload:k,disabled:C,readOnly:v,mode:e,id:t});V.current={title:r,features:d,target:u,autoFocus:b,detachedBodyClassName:p,closeOnMainWindowUnload:k,disabled:C,readOnly:v,mode:e,id:t};let Y=useRef(z??oc);Y.current=z??oc;let X=useRef(h??ac);X.current=h??ac;let G=useRef(s);G.current=s;let j=useRef(c);j.current=c;let O=useRef(E);O.current=E;let K=`${kg}/${t}`,se=useCallback(()=>{S.current&&(clearInterval(S.current),S.current=null),B.current&&(B.current.disconnect(),B.current=null),P(null);},[]),ae=useCallback(()=>{D.current&&(D.current.close(),D.current=null),$.current&&typeof window<"u"&&(window.removeEventListener("message",$.current),$.current=null);},[]),U=useCallback(Pe=>{if(!(!Pe||Pe.channel!==K)&&Pe.instanceId!==A&&!V.current.readOnly&&Pe.type==="value-sync"&&Pe.payload!==void 0){_.current=Pe.payload;let De=X.current(Pe.payload);I||W(De),G.current?.(De);}},[K,A,I]),J=useCallback(()=>{if(ae(),!(typeof window>"u"))if(Pg()){let Pe=new BroadcastChannel(K),De=it=>U(it.data);Pe.addEventListener("message",De),D.current=Pe;}else {let Pe=De=>{De.data?.channel===K&&U(De.data);};window.addEventListener("message",Pe),$.current=Pe;}},[K,ae,U]),te=useCallback(Pe=>{if(V.current.readOnly)return;let De=Y.current(Pe);if(De===F.current)return;if(De===_.current){_.current=null;return}F.current=De;let it={channel:K,instanceId:A,messageId:Sg(),origin:"main",timestamp:Date.now(),type:"value-sync",payload:De};D.current?D.current.postMessage(it):x.current&&!x.current.closed&&x.current.postMessage(it,"*");},[K,A]),ie=useCallback(()=>{if(typeof window>"u"||V.current.disabled||H.current||x.current&&!x.current.closed)return;H.current=true;let Pe=V.current,De=window.open("",Pe.target||"",Pe.features||wg);if(!De){H.current=false;return}x.current=De,De.document.title=Pe.title||document.title,Pe.detachedBodyClassName&&(De.document.body.className=Pe.detachedBodyClassName);let it=De.document.createElement("div");De.document.body.appendChild(it),P(it),Rg(document,De.document),B.current=Tg(document,De.document),S.current=setInterval(()=>{De.closed&&(se(),x.current=null,f||L(false),j.current?.(false));},Cg),Pe.autoFocus&&De.focus(),H.current=false;},[f,se]),Q=useCallback(()=>{x.current&&!x.current.closed&&x.current.close(),x.current=null,se();},[se]),ge=useRef(ie);ge.current=ie;let Re=useRef(Q);Re.current=Q;let Qe=useRef(te);Qe.current=te;let at=useCallback(()=>{V.current.disabled||(f||L(true),j.current?.(true));},[f]),et=useCallback(()=>{f||L(false),j.current?.(false);},[f]),me=useCallback(()=>{let Pe=!O.current;Pe&&V.current.disabled||(f||L(Pe),j.current?.(Pe));},[f]);useImperativeHandle(R,()=>({open:at,close:et,toggle:me,get isDetached(){return O.current},get window(){return x.current}}),[at,et,me]),useEffect(()=>(J(),()=>ae()),[J,ae]),useEffect(()=>{if(E)return ge.current(),()=>Re.current();Re.current();},[E]),useEffect(()=>{M!==void 0&&Qe.current(M);},[M]),useEffect(()=>{x.current&&!x.current.closed&&r&&(x.current.document.title=r);},[r]),useEffect(()=>{if(typeof window>"u")return;let Pe=()=>{V.current.closeOnMainWindowUnload&&x.current&&!x.current.closed&&x.current.close();};return window.addEventListener("beforeunload",Pe),()=>{window.removeEventListener("beforeunload",Pe),x.current&&!x.current.closed&&x.current.close(),x.current=null;}},[]);let ce=typeof n=="function"?n({open:at,close:et,toggle:me,detached:E,windowRef:x.current}):n,Oe=e==="clone"||!E,st=E&&T!==null;return jsxs(Fragment,{children:[y&&M!==void 0&&jsx("input",{type:"hidden",name:y,value:Y.current(M)}),Oe&&jsx("div",{className:vg(m),children:ce}),st&&createPortal(ce,T)]})}var ic=forwardRef(Eg);ic.displayName="AdvanceDetachable";function vr(e,t=11){return e.length*t*.6}function kr(e,t=11){let r=0;for(let n of e){let o=vr(n,t);o>r&&(r=o);}return r}function sa(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 Mg=10,Ig={sm:"text-[10px]",md:"text-[11px]",lg:"text-xs"};function _e({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 jsxs("g",{className:g(Ig[l],i),"aria-hidden":"true",...c,children:[n&&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 b=d?u.offset:0,m=d?0:u.offset;return jsxs("g",{transform:`translate(${b}, ${m})`,children:[o>0?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,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?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+kr(t.map(u=>u.label))+Mg)}, ${r/2}) rotate(-90)`,className:"fill-gray-600 dark:fill-gray-300 font-medium",children:s}):null]})}var dc={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"},Wg={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"},di=createContext(dc);function Hg({labels:e,children:t}){let r=useContext(di),n=useMemo(()=>({...r,...e}),[r,e]);return jsx(di.Provider,{value:n,children:t})}function Ge(){return useContext(di)}var Bg={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"},Fg={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"},Og={xs:24,sm:32,md:48,lg:64,xl:96},$g={xs:"text-[8px]",sm:"text-[10px]",md:"text-sm",lg:"text-base",xl:"text-xl"},_g={thin:2,normal:4,thick:8};function xo({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,...b}){let m=Math.min(100,Math.max(0,e)),p=Og[r],C=_g[n],v=(p-C)/2,k=2*Math.PI*v,y=p/2,z=k-m/100*k,h=a||Bg[o],R=s||"stroke-gray-200 dark:stroke-gray-700",f=Fg[o],N=i??(l&&!t?jsx("span",{className:g("font-semibold",$g[r],f),children:c?c(m):`${Math.round(m)}%`}):null);return 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,...b,children:[jsxs("svg",{width:p,height:p,viewBox:`0 0 ${p} ${p}`,className:g(t&&"animate-spin"),style:{transform:"rotate(-90deg)"},children:[jsx("circle",{cx:y,cy:y,r:v,fill:"none",strokeWidth:C,className:R}),jsx("circle",{cx:y,cy:y,r:v,fill:"none",strokeWidth:C,strokeLinecap:"round",strokeDasharray:k,strokeDashoffset:t?k*.75:z,className:g(h,d&&!t&&"transition-[stroke-dashoffset] duration-300 ease-out")})]}),N&&jsx("div",{className:"absolute inset-0 flex items-center justify-center",style:{transform:"rotate(0deg)"},children:N})]})}xo.displayName="CircularProgress";var mc=640;function ui(e={}){let{width:t,fallbackWidth:r=mc}=e,n=useRef(null),[o,a]=useState(0);return 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 qg={sm:"text-xs",md:"text-sm",lg:"text-base"};function ut({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:b=false,showTableLabel:m,hideTableLabel:p,noDataLabel:C,loadingLabel:v,ariaLabel:k,children:y,className:z,...h}){let R=Ge(),[f,N]=useState(false),L=useId(),E=`${L}-table`,I=`${L}-title`,w=`${L}-description`,{ref:W,width:M,measured:T}=ui({width:n}),P=!!u&&b==="toggle",x=!!u&&(b===true||P&&f),B=jsx("div",{ref:W,className:"relative w-full",style:{height:r},"aria-busy":i||void 0,children:i&&c?jsx("div",{className:"flex h-full w-full items-center justify-center",children:jsx(xo,{indeterminate:true,size:"md","aria-label":v??R.chartLoading})}):c&&!i?jsx("div",{className:"flex h-full w-full items-center justify-center text-sm text-gray-500 dark:text-gray-400",children:d??C??R.chartNoData}):jsx("div",{className:g("h-full w-full transition-opacity duration-200",i&&"opacity-60"),children:typeof y=="function"?y({width:M,height:r,measured:T}):y})});return jsxs("figure",{className:g("flex w-full flex-col gap-3",z),"aria-label":k,"aria-labelledby":!k&&e?I:void 0,"aria-describedby":t?w:void 0,...h,children:[e||t||l?jsxs("figcaption",{className:"flex items-start justify-between gap-3",children:[jsxs("div",{className:"flex flex-col gap-0.5",children:[e?jsx("span",{id:I,className:g("font-semibold text-gray-900 dark:text-gray-100",qg[o]),children:e}):null,t?jsx("span",{id:w,className:"text-xs text-gray-500 dark:text-gray-400",children:t}):null]}),l]}):null,a&&s==="top"?a:null,a&&s==="right"?jsxs("div",{className:"flex items-start gap-4",children:[jsx("div",{className:"min-w-0 grow",children:B}),a]}):B,a&&s==="bottom"?a:null,P&&jsx("div",{className:"flex",children:jsx("button",{type:"button",onClick:()=>N(H=>!H),"aria-expanded":f,"aria-controls":x?E: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:f?p??R.chartHideTable:m??R.chartShowTable})}),x&&jsx("div",{id:E,children:u})]})}var gc=[];function Ot({width:e,height:t,horizontal:r=gc,vertical:n=gc,className:o,...a}){return jsxs("g",{className:g("stroke-gray-200 dark:stroke-gray-700",o),strokeWidth:1,shapeRendering:"crispEdges","aria-hidden":"true",...a,children:[r.map(s=>jsx("line",{x1:0,y1:s,x2:e,y2:s},`h-${s}`)),n.map(s=>jsx("line",{x1:s,y1:0,x2:s,y2:t},`v-${s}`))]})}var Zg={line:"h-0.5 w-3 rounded-full",rect:"h-2.5 w-2.5 rounded-sm",dot:"h-2 w-2 rounded-full"},Qg={sm:"text-[11px]",md:"text-xs",lg:"text-sm"};function $t({items:e,position:t="bottom",marker:r="line",onToggle:n,size:o="md",className:a,...s}){return e.length===0?null: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":"",Qg[o],a),...s,children:e.map(l=>{let i=jsx("span",{className:g("shrink-0",Zg[l.marker??r]),style:{backgroundColor:l.color},"aria-hidden":"true"}),c=jsx("span",{className:g(l.hidden&&"line-through"),children:l.label}),d=jsxs(Fragment,{children:[i,c]}),u=g("flex items-center gap-1.5 text-gray-600 dark:text-gray-300",l.hidden&&"text-gray-400 dark:text-gray-500");return jsx("li",{children:n?jsx("button",{type:"button",onClick:()=>n(l.key),"aria-pressed":!l.hidden,className:g(u,"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:d}):jsx("span",{className:u,children:d})},l.key)})})}function gn({children:e,className:t,...r}){return 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 pn({children:e,className:t,...r}){return jsx("tbody",{className:g(t),...r,children:e})}function _t({children:e,onClick:t,hidden:r=false,className:n,...o}){return jsx("td",{className:g("px-6 py-4",n),onClick:t,hidden:r,...o,children:e})}function fn({children:e,className:t,...r}){return jsx("thead",{className:g("text-xs text-gray-700 uppercase bg-gray-50 dark:bg-gray-700 dark:text-gray-400",t),...r,children:jsx("tr",{children:e})})}function Nt({children:e,onClick:t,hidden:r=false,className:n,sortable:o=false,...a}){return 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 bn({children:e,onClick:t,clickable:r=true,className:n,...o}){return 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 sp=8,Ja=["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)"],Tr="var(--color-chart-muted)",gi="var(--color-chart-up)",pi="var(--color-chart-down)",qn=3,bc=false;function Pr(e,t){return t||(e<0||e>=8?(bc||(bc=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.')),Tr):Ja[e])}function Er(e,t,r){return r&&e.key!==r?Tr:Pr(t,e.color)}function Xt(e){return e.label??e.key}function Or(e,t){return e.map((r,n)=>({key:r.key,label:Xt(r),color:Er(r,n,t),hidden:r.hidden,...r.type==="line"?{marker:"line"}:{}}))}var mi=["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)"],Yn=["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)"],hc=3,yc=[false,false,false,false,true,true],fi=[false,false,true,true,true],xc=[true,false,false,false,false,false,true],es=7;function la(e){return Number.isFinite(e)?e<0?0:e>1?1:e:0}function ko(e,t){if(e.length===0)return Tr;if(e.length===1)return e[0];let r=la(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 ip(e,t){return t<=1?.5:Math.min(t-1,Math.floor(la(e)*t))/(t-1)}function vc(e,t,r,n,o){let a=l=>{let i=n(l);return r===null?i:ip(i,r)},s=(l=>Number.isFinite(l)?ko(t,a(l)):Tr);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 ca(e,t={}){let{steps:r,colors:n=mi,darkStops:o}=t,[a,s]=e,l=s-a;return vc(e,n,r??null,i=>l===0?0:(i-a)/l,o??(n===mi?yc:[]))}function Co(e,t={}){let{steps:r,colors:n=Yn,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===Yn?hc:(n.length-1)/2,d=n.length-1;return vc([l,i],n,r??null,u=>{if(u>=a){let p=i-a,C=p<=0?0:la((u-a)/p);return (c+C*(d-c))/d}let b=a-l,m=b<=0?0:la((a-u)/b);return (c-m*c)/d},o??(n===Yn?xc:[]))}function lp(e,t=ia.length,r=ia){return t<=1?r[r.length-1]??Tr:ko(r,la(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 mt(e,t,r){let n=e[t];return n instanceof Date||typeof n=="number"||typeof n=="string"?n:n==null?r:String(n)}function ur(e,t){let r=[];for(let n of e)for(let o of t)r.push(Ee(n,o));return r}function da(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 cp(e,t){return da(e,{locale:t,compact:true})}function rt(e,t){return Number.isFinite(e)?Math.abs(e)<1e4?da(e,{locale:t}):cp(e,t):"\u2014"}function Gt(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 Ke(e,t){return e instanceof Date?new Intl.DateTimeFormat(t,{day:"2-digit",month:"short"}).format(e):typeof e=="number"?da(e,{locale:t}):e}function It({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 jsx("div",{className:g("text-sm text-gray-500 dark:text-gray-400",i),...c,children:l});let u=(m,p)=>{let C=mt(m,r,p);return o?o(C,p):Ke(C)},b=m=>m===null?"\u2014":a?a(m):da(m);return jsx("div",{className:g("w-full overflow-x-auto",i),...c,children:jsxs(gn,{children:[s?jsx("caption",{className:"sr-only",children:s}):null,jsxs(fn,{children:[jsx(Nt,{children:n??r}),d.map(m=>jsx(Nt,{className:"text-right",children:Xt(m)},m.key))]}),jsx(pn,{children:e.map((m,p)=>jsxs(bn,{clickable:false,children:[jsx(_t,{className:"font-medium text-gray-900 dark:text-gray-100",children:u(m,p)}),d.map(C=>jsx(_t,{className:"text-right [font-variant-numeric:tabular-nums]",children:b(Ee(m,C.key))},C.key))]},p))})]})})}function gt({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 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 Cr({title:e,points:t}){return jsxs("div",{className:"flex flex-col gap-1",children:[e!=null&&jsx("div",{className:"font-medium text-gray-900 dark:text-gray-100",children:e}),jsx("div",{className:"flex flex-col gap-0.5",children:t.map(r=>jsxs("div",{className:"flex items-center gap-2",children:[jsx("span",{className:"h-0.5 w-3 shrink-0 rounded-full",style:{backgroundColor:r.color},"aria-hidden":"true"}),jsx("span",{className:"grow text-gray-500 dark:text-gray-400",children:r.seriesLabel}),jsx("span",{className:"font-semibold text-gray-900 [font-variant-numeric:tabular-nums] dark:text-gray-100",children:r.formattedValue})]},r.seriesKey))})]})}function St(e){return e instanceof Date?e.toISOString():String(e)}function Jr(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 Dr(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 hn(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,C)=>{u.has(St(p))||u.set(St(p),C);});let b=p=>d+i*p,m=(p=>{let C=u.get(St(p));return C===void 0?Number.NaN:b(C)});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 C=u.get(St(p));return C===void 0?Number.NaN:b(C)+c/2},enumerable:true},positions:{value:()=>e.map((p,C)=>b(C)),enumerable:true},indexOf:{value:p=>u.get(St(p))??-1,enumerable:true}}),m}function Wt(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 ua(e){let t=Number(e.toPrecision(12));return Object.is(t,-0)?0:t}function Cc(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 ua(o*r)}function ts(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=Cc((t-e)/Math.max(1,r));return [ua(Math.floor(e/n)*n),ua(Math.ceil(t/n)*n)]}function ma(e,t,r=5){if(!Number.isFinite(e)||!Number.isFinite(t))return [];if(r<=0)return [];if(e===t)return [ua(e)];e>t&&([e,t]=[t,e]);let n=Cc((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(ua(l*n));return s}function Kt(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 No(e,t={}){let{domain:r,includeZero:n=true,ticks:o=5}=t;if(Array.isArray(r))return r;let a=Kt(e);if(!a)return [0,1];let[s,l]=a;return n&&(s=Math.min(s,0),l=Math.max(l,0)),ts(s,l,o)}var hi={top:10,right:16,bottom:28},wc=16,dp=14,up=32;function Qt({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:b=0,defaultIncludeZero:m=false}){let p=l==="vertical",C=r.map((V,Y)=>mt(V,n.key,Y)),v=No(a??[],{domain:o?.domain,includeZero:o?.includeZero??m,ticks:o?.ticks??5}),k=o?.hidden??false,y=n.hidden??false,z=k?[]:ma(v[0],v[1],o?.ticks??5),h=z.map(d),R=p&&(n.scale==="linear"||n.scale==="time"),f=C.map((V,Y)=>u(V,Y)),N=p?k:y,L=p?h:f,E=p?o?.width:n.height,I=p?y:k,w=p?n.height:void 0,W=p?n.label:o?.label,M=p?o?.label:n.label,T=p&&!y&&i!=="band"?f:[],P=V=>V?vr(V)/2+4:0,x={top:s?.top??hi.top+b,right:s?.right??Math.max(hi.right,P(T[T.length-1])),bottom:s?.bottom??(I?8:w??hi.bottom+(W?wc:0)),left:s?.left??(N?8:E??Math.max(Math.max(up,kr(L)+dp)+(M?wc:0),P(T[0])))},D=Math.max(0,e-x.left-x.right),S=Math.max(0,t-x.top-x.bottom),B=p?Dr(v,[S,0]):Dr(v,[0,D]),H=p?D:S,$,_=0,F;if(R){let V=C.map(Jr),Y=Kt(V)??[0,1],X=Dr(Y,[0,H]);$=V.map(G=>X(G)),F=y?[]:ma(Y[0],Y[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 V=hn(r.map((Y,X)=>X),[0,H],{paddingInner:c});$=r.map((Y,X)=>V(X)),_=V.bandwidth,F=[];}else {let V=r.length>1?H/(r.length-1):0;$=r.map((Y,X)=>r.length>1?X*V:H/2),F=[];}let A=$.map(V=>V+_/2);if(!R&&!y){let V=p?kr(f):15,Y=sa(f.length,H,V);F=f.map((X,G)=>({value:C[G],offset:A[G],label:X})).filter((X,G)=>G%Y===0);}return {margin:x,innerWidth:D,innerHeight:S,orientation:l,valueScale:B,domain:v,valueTicks:z.map(V=>({value:V,offset:B(V),label:d(V)})),xValues:C,categoryPositions:$,bandwidth:_,categoryCenters:A,categoryTicks:F,categoryLength:H}}function Ct(e){return Math.round(e*100)/100}function Nc(e){return e.defined!==false&&Number.isFinite(e.x)&&Number.isFinite(e.y)}function Sc(e,t=false){if(t){let o=e.filter(Nc);return o.length>0?[o]:[]}let r=[],n=[];for(let o of e)Nc(o)?n.push(o):n.length>0&&(r.push(n),n=[]);return n.length>0&&r.push(n),r}function mp(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 xi(e,t){if(e.length<2)return "";if(t==="monotone"&&e.length>2){let n=mp(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${Ct(s.x+i)},${Ct(s.y+n[a]*i)} ${Ct(l.x-i)},${Ct(l.y-n[a+1]*i)} ${Ct(l.x)},${Ct(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=Ct((o.x+a.x)/2);r+=` L${s},${Ct(o.y)} L${s},${Ct(a.y)}`;}else t==="stepAfter"&&(r+=` L${Ct(a.x)},${Ct(o.y)}`);r+=` L${Ct(a.x)},${Ct(a.y)}`;}return r}function $r(e,t="linear",r={}){return Sc(e,r.connectNulls).map(n=>{let[o]=n;return `M${Ct(o.x)},${Ct(o.y)}${xi(n,t)}`}).join(" ")}function ga(e,t,r="linear",n={}){let o=Sc(e,n.connectNulls);if(o.length===0)return "";let a=typeof t=="number"?null:new Map(t.map(s=>[Ct(s.x),s]));return o.map(s=>{let[l]=s,i=s[s.length-1],c=`M${Ct(l.x)},${Ct(l.y)}${xi(s,r)}`;if(a===null){let b=Ct(t);return `${c} L${Ct(i.x)},${b} L${Ct(l.x)},${b} Z`}let d=s.map(b=>a.get(Ct(b.x))).filter(b=>b!==void 0).reverse();if(d.length===0)return `${c} Z`;let[u]=d;return `${c} L${Ct(u.x)},${Ct(u.y)}${xi(d,r)} Z`}).join(" ")}function ir({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]=[Ve(e),Ve(t)],[c,d]=[Ve(e+r),Ve(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},${Ve(t+s)} Q${l},${i} ${Ve(e+s)},${i} L${Ve(e+r-s)},${i} Q${c},${i} ${c},${Ve(t+s)} L${c},${d} Z`;case "bottom":return `M${l},${i} L${c},${i} L${c},${Ve(t+n-s)} Q${c},${d} ${Ve(e+r-s)},${d} L${Ve(e+s)},${d} Q${l},${d} ${l},${Ve(t+n-s)} Z`;case "right":return `M${l},${i} L${Ve(e+r-s)},${i} Q${c},${i} ${c},${Ve(t+s)} L${c},${Ve(t+n-s)} Q${c},${d} ${Ve(e+r-s)},${d} L${l},${d} Z`;case "left":return `M${c},${i} L${Ve(e+s)},${i} Q${l},${i} ${l},${Ve(t+s)} L${l},${Ve(t+n-s)} Q${l},${d} ${Ve(e+s)},${d} L${c},${d} Z`;default:return `M${l},${i} L${c},${i} L${c},${d} L${l},${d} Z`}}function Ve(e){return Math.round(e*100)/100}function In(e,t,r,n){return {x:Ve(e+r*Math.sin(n)),y:Ve(t-r*Math.cos(n))}}function Rc({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=In(e,t,n,0),C=In(e,t,n,Math.PI),v=`M${p.x},${p.y} A${Ve(n)},${Ve(n)} 0 1 1 ${C.x},${C.y} A${Ve(n)},${Ve(n)} 0 1 1 ${p.x},${p.y} Z`;if(i===0)return v;let k=In(e,t,i,0),y=In(e,t,i,Math.PI);return `${v} M${k.x},${k.y} A${Ve(i)},${Ve(i)} 0 1 0 ${y.x},${y.y} A${Ve(i)},${Ve(i)} 0 1 0 ${k.x},${k.y} Z`}let c=s>Math.PI?1:0,d=In(e,t,n,o),u=In(e,t,n,a);if(i===0)return `M${Ve(e)},${Ve(t)} L${d.x},${d.y} A${Ve(n)},${Ve(n)} 0 ${c} 1 ${u.x},${u.y} Z`;let b=In(e,t,i,a),m=In(e,t,i,o);return `M${d.x},${d.y} A${Ve(n)},${Ve(n)} 0 ${c} 1 ${u.x},${u.y} L${b.x},${b.y} A${Ve(i)},${Ve(i)} 0 ${c} 0 ${m.x},${m.y} Z`}function rs(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 b=a[u];if(r==="none")return {key:d,value:b,start:0,end:b??0};if(b===null)return {key:d,value:null,start:l,end:l};let m=r==="percent"?s===0?0:b/s*100:b;if(m>=0){let C=l;return l+=m,{key:d,value:b,start:C,end:l}}let p=i;return i+=m,{key:d,value:b,start:i,end:p}});return {index:o,datum:n,total:s,segments:c}})}function ns(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 Tc(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(k=>Ee(l,k)),d=c.reduce((k,y)=>k+(y===null?0:Math.abs(y)),0),u=c.map(k=>k===null?null:o?d===0?0:k/d*100:k),b=t.map(k=>({key:k,value:null,start:0,end:0,base:false,outer:false})),m=0;a>=0&&(m=(u[a]??0)/2,b[a]={key:t[a],value:c[a],start:m===0?0:-m,end:m,base:true,outer:false});let p=m===0?0:-m,C=-1;for(let k=s-1;k>=0;k-=1){let y=u[k];if(y===null){b[k]={...b[k],value:null,start:p,end:p};continue}let z=p-Math.abs(y);b[k]={key:t[k],value:c[k],start:p,end:z,base:a<0&&C===-1,outer:false},p=z,C=k;}C>=0&&(b[C].outer=true),p=m;let v=-1;for(let k=a>=0?a+1:s;k<t.length;k+=1){let y=u[k];if(y===null){b[k]={...b[k],value:null,start:p,end:p};continue}let z=p+Math.abs(y);b[k]={key:t[k],value:c[k],start:p,end:z,base:a<0&&v===-1,outer:false},p=z,v=k;}return v>=0?b[v].outer=true:a>=0&&(b[a].outer=true),{index:i,datum:l,total:d,segments:b}})}var pp=.12,fp=.9,bp=10,hp=memo(function({bands:t,stacked:r}){return jsx("g",{children:t.map(n=>jsxs("g",{children:[jsx("path",{d:n.area,fill:n.color,fillOpacity:r?fp:pp,stroke:"none"}),n.gap?jsx("path",{d:n.gap,fill:"none",strokeWidth:2,className:"stroke-white dark:stroke-gray-800"}):null,jsx("path",{d:n.edge,fill:"none",stroke:n.color,strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"})]},n.key))})});function yp({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:b,margin:m,tooltip:p,onPointClick:C,plotLabel:v,formatValue:k,formatRaw:y,formatX:z}){let[h,R]=useState(null),f=useMemo(()=>{let T=n.filter(A=>!A.hidden),P=T.map(A=>A.key),x=c!=="none",D=rs(r,P,c),S=x?ns(D):Kt([...ur(r,P),d]),B=Qt({width:e,height:t,data:r,x:o,y:a,bounds:S,margin:m,placement:"point",formatValue:k,formatX:z,defaultIncludeZero:true}),H=B.categoryCenters,$=B.valueScale,_=$(x?0:d),F=T.map((A,V)=>{let Y=r.map((j,O)=>{let K=D[O].segments[V];return {x:H[O],y:K.value===null?Number.NaN:$(K.end),defined:K.value!==null}}),X=r.map((j,O)=>{let K=D[O].segments[V];return {x:H[O],y:K.value===null?Number.NaN:$(x?K.start:d),defined:K.value!==null}}),G={connectNulls:u};return {key:A.key,color:A.color,area:x?ga(Y,X,i,G):ga(Y,_,i,G),edge:$r(Y,i,G),gap:x&&V>0?$r(X,i,G):""}});return {visible:T,rows:D,stacked:x,xValues:B.xValues,positions:H,xTicks:B.categoryTicks,yTicks:B.valueTicks,valueScale:$,innerWidth:B.innerWidth,innerHeight:B.innerHeight,margin:B.margin,bands:F}},[r,n,o,a,e,t,m,i,c,d,u,k,z]),N=useCallback(T=>f.visible.map((P,x)=>{let D=Ee(r[T],P.key),S=f.rows[T].segments[x],B=D===null?"\u2014":c==="percent"?`${y(D)} (${k(S.end-S.start)})`:k(D);return {seriesKey:P.key,seriesLabel:Xt(P),color:P.color,value:D,formattedValue:B,datum:r[T]}}),[r,f.visible,f.rows,c,k,y]),L=useCallback(T=>{if(p===false||r.length===0)return;let P=T.currentTarget.getBoundingClientRect(),x=T.clientX-P.left-f.margin.left,D=Wt(f.positions,x);R(D>=0?D:null);},[p,r.length,f.margin.left,f.positions]),E=useCallback(T=>{if(r.length===0)return;let P=r.length-1,x=h??0,D=T.key==="ArrowRight"?Math.min(P,x+1):T.key==="ArrowLeft"?Math.max(0,x-1):T.key==="Home"?0:T.key==="End"?P:T.key==="Escape"?null:void 0;D!==void 0&&(T.preventDefault(),R(D));},[r.length,h]),I=useCallback(()=>{if(!C||h===null)return;let[T]=N(h);T&&C({...T,index:h,x:f.xValues[h]});},[C,h,N,f.xValues]),w=h===null?null:N(h),W=h===null?[]:f.visible.map((T,P)=>{let x=f.rows[h].segments[P];return x.value===null?null:{key:T.key,color:T.color,y:f.valueScale(x.end)}}).filter(T=>T!==null),M=h===null||w===null?null:{x:f.xValues[h],xLabel:z(f.xValues[h],h),index:h,points:w};return jsxs(Fragment,{children:[jsxs("svg",{width:e,height:t,role:"img","aria-label":v??f.visible.map(T=>Xt(T)).join(", "),tabIndex:0,className:"touch-none focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-blue-500",onPointerMove:L,onPointerLeave:()=>R(null),onKeyDown:E,onBlur:()=>R(null),onClick:I,children:[jsxs("g",{transform:`translate(${f.margin.left}, ${f.margin.top})`,children:[jsx(Ot,{width:f.innerWidth,height:f.innerHeight,horizontal:s==="y"||s==="both"?f.yTicks.map(T=>T.offset):void 0,vertical:s==="x"||s==="both"?f.xTicks.map(T=>T.offset):void 0}),jsx(hp,{bands:f.bands,stacked:f.stacked}),b?.map(T=>{let P=f.valueScale(T.value),x=P<bp?P+12:P-4;return jsxs("g",{children:[jsx("line",{x1:0,y1:P,x2:f.innerWidth,y2:P,stroke:T.color??"var(--color-chart-muted)",strokeWidth:1,strokeDasharray:T.dashed===false?void 0:"4 4"}),T.label?jsx("text",{x:f.innerWidth,y:x,textAnchor:"end",className:"fill-gray-500 text-[10px] dark:fill-gray-400",children:T.label}):null]},`${T.value}-${T.label??""}`)}),h!==null?jsxs("g",{"aria-hidden":"true",children:[jsx("line",{x1:f.positions[h],y1:0,x2:f.positions[h],y2:f.innerHeight,className:"stroke-gray-400 dark:stroke-gray-500",strokeWidth:1}),W.map(T=>jsx("circle",{cx:f.positions[h],cy:T.y,r:4,fill:T.color,strokeWidth:2,className:"stroke-white dark:stroke-gray-800"},T.key))]}):null]}),jsx("g",{transform:`translate(${f.margin.left}, ${f.margin.top+f.innerHeight})`,children:o.hidden?null:jsx(_e,{orientation:"bottom",ticks:f.xTicks,length:f.innerWidth,label:o.label,size:l})}),jsx("g",{transform:`translate(${f.margin.left}, ${f.margin.top})`,children:a?.hidden?null:jsx(_e,{orientation:"left",ticks:f.yTicks,length:f.innerHeight,showLine:false,label:a?.label,size:l})})]}),M&&p!==false?jsx(gt,{x:f.margin.left+f.positions[M.index],y:f.margin.top+(W.length>0?Math.min(...W.map(T=>T.y)):f.innerHeight/2),containerWidth:e,children:typeof p=="function"?p(M):jsx(Cr,{title:M.xLabel,points:M.points})}):null]})}function xp({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:b,description:m,loading:p=false,emptyState:C,onPointClick:v,curve:k="monotone",stack:y="none",baseline:z=0,connectNulls:h=false,referenceLines:R,legendToggle:f=true,margin:N,locale:L,plotLabel:E,className:I,...w}){let[W,M]=useState(()=>new Set),T=useMemo(()=>t.map((A,V)=>({...A,hidden:A.hidden||W.has(A.key),color:Er(A,V,u)})),[t,W,u]),P=y==="percent",x=useMemo(()=>P?{domain:[0,100],...n}:n,[P,n]),D=useMemo(()=>n?.format??(P?A=>Gt(A,{locale:L,alreadyScaled:true,maximumFractionDigits:0}):A=>rt(A,L)),[n?.format,P,L]),S=useMemo(()=>A=>rt(A,L),[L]),B=useMemo(()=>r.format??(A=>r.scale==="time"?Ke(A instanceof Date?A:new Date(Jr(A)),L):Ke(A,L)),[r.format,r.scale,L]),H=useCallback(A=>{M(V=>{let Y=new Set(V);return Y.has(A)?Y.delete(A):Y.add(A),Y});},[]),$=i===void 0?t.length>=2:i!==false,_=typeof i=="string"?i:"bottom",F=T.filter(A=>!A.hidden).length;return jsx(ut,{title:b,description:m,height:o,width:a,size:s,loading:p,empty:e.length===0||F===0,emptyState:C,tableView:d,legendPosition:_,legend:$?jsx($t,{items:Or(T,u),position:_,marker:"rect",size:s,onToggle:f?H:void 0}):void 0,table:d?jsx(It,{data:e,series:T,xKey:r.key,xLabel:r.label??r.key,formatX:B,formatValue:S,caption:typeof b=="string"?b:void 0}):void 0,className:I,...w,children:({width:A})=>jsx(yp,{width:A,height:o,data:e,resolvedSeries:T,x:r,y:x,grid:l,size:s,curve:k,stack:y,baseline:z,connectNulls:h,referenceLines:R,margin:N,tooltip:c,onPointClick:v,plotLabel:E,formatValue:D,formatRaw:S,formatX:B})})}var kp={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"},Cp={circle:"rounded-full",square:"rounded-none",rounded:"rounded-md"};function wp({src:e,alt:t="Avatar",fallback:r,size:n="md",variant:o="circle",border:a=false,className:s,...l}){return 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",kp[n],Cp[o],a&&"ring-2 ring-white dark:ring-gray-900",s),...l,children:e?jsx("img",{src:e,alt:t,className:"h-full w-full object-cover"}):jsx("span",{children:r||t.charAt(0).toUpperCase()})})}var Np={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"}},Sp={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"},Rp={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"},Tp={sm:"w-1.5 h-1.5",md:"w-1.5 h-1.5",lg:"w-2 h-2"},Pp={sm:"w-2.5 h-2.5",md:"w-3 h-3",lg:"w-3.5 h-3.5"};function Dc({children:e,color:t="default",size:r="md",variant:n="soft",dot:o=false,icon:a,pill:s=true,className:l,...i}){return jsxs("span",{className:g("inline-flex items-center font-medium",Rp[r],s?"rounded-full":"rounded",Np[t][n],l),...i,children:[o&&jsx("span",{className:g("shrink-0 rounded-full",Tp[r],Sp[t]),"aria-hidden":"true"}),a&&!o&&jsx("span",{className:g("shrink-0",Pp[r]),"aria-hidden":"true",children:a}),e]})}Dc.displayName="Badge";var Dp={sm:"text-[10px]",md:"text-[11px]",lg:"text-xs"};function fa({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??(y=>rt(y,s)),b=e.steps,m=b!==null&&b>0,p=Math.max(2,Math.round(n)),C=m?Array.from({length:b+1},(y,z)=>z/b):Array.from({length:p},(y,z)=>z/(p-1)),v=y=>c+y*(d-c),k=m?jsx("div",{className:"flex h-full w-full overflow-hidden rounded-sm",children:Array.from({length:b},(y,z)=>jsx("span",{className:"h-full grow",style:{backgroundColor:e(v((z+.5)/b))}},z))}):jsx("div",{className:"h-full w-full rounded-sm",style:{backgroundImage:`linear-gradient(to right, ${e.colors.join(", ")})`}});return jsxs("div",{className:g("flex w-full max-w-80 flex-col gap-1",Dp[o],l),...i,children:[t?jsx("span",{className:"text-gray-600 dark:text-gray-300",children:t}):null,jsx("div",{style:{height:a},"aria-hidden":"true",children:k}),jsx("div",{className:"relative h-4 w-full",children:C.map((y,z)=>jsx("span",{className:"absolute top-0 whitespace-nowrap text-gray-500 [font-variant-numeric:tabular-nums] dark:text-gray-400",style:{left:`${y*100}%`,transform:`translateX(${z===0?"0":z===C.length-1?"-100%":"-50%"})`},children:u(v(y))},y))})]})}function Lc(e){return e<=1?1:Math.min(60,Math.max(1,Math.ceil(Math.log2(e))+1))}function Mp(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 Mc(e,t=true){if(Array.isArray(t)){let m=[...t].filter(p=>Number.isFinite(p)).sort((p,C)=>p-C);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:Lc(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 Mp(l)){let p=Math.floor(n/m)*m,C=Math.ceil(o/m)*m,v=Math.max(1,Math.round((C-p)/m));if(v>60)continue;let k=Math.abs(v-s);k<=d&&(d=k,i=m,c=v);}if(i===0)return [];let u=Math.floor(n/i)*i,b=[];for(let m=0;m<=c;m+=1)b.push(Number((u+m*i).toPrecision(12)));return b}function ki(e,t=true){let r=e.filter(a=>typeof a=="number"&&Number.isFinite(a)),n=Mc(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 Ip=24,Zn=2,Ap=4,To=6,zp=10,Ci=false;function Wp(){Ci=false;}var Hp=memo(function({bars:t}){return jsx("g",{children:t.map((r,n)=>jsxs("g",{children:[jsx("path",{d:r.d,fill:r.color}),r.label?jsx("text",{x:r.label.x,y:r.label.y,textAnchor:r.label.anchor,dominantBaseline:"middle",className:"fill-gray-600 text-[10px] [font-variant-numeric:tabular-nums] dark:fill-gray-300",children:r.label.text}):null]},`${r.key}-${n}`))})}),Vp=memo(function({lines:t}){return jsx("g",{children:t.map(r=>jsxs("g",{children:[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=>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 Bp({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:b,binned:m,curve:p,barSize:C,showValues:v,referenceLines:k,margin:y,tooltip:z,onPointClick:h,plotLabel:R,formatValue:f,formatRaw:N,formatX:L}){let[E,I]=useState(null),w=useMemo(()=>{let H=i==="vertical",$=n.filter(ce=>!ce.hidden),_=$.filter(ce=>ce.type!=="line"),F=$.filter(ce=>ce.type==="line"),A=_.map(ce=>ce.key),V=u!==null||c!=="none",Y=u!==null?Tc(r,A,{centerKey:u,percent:c==="percent"}):rs(r,A,c),X=V?ns(Y):Kt(ur(r,A)),G=Kt(ur(r,F.map(ce=>ce.key))),j=X===null?G:G===null?X:[Math.min(X[0],G[0]),Math.max(X[1],G[1])],O=Qt({width:e,height:t,data:r,x:o,y:a,bounds:j===null?null:[Math.min(j[0],d),Math.max(j[1],d)],margin:y,orientation:i,placement:"band",bandPaddingInner:m?0:void 0,formatValue:f,formatX:L,defaultIncludeZero:d===0}),{valueScale:K,bandwidth:se,categoryPositions:ae,innerWidth:U,innerHeight:J}=O,te=K(d),ie=Math.max(1,_.length),Q=V?se:se/ie,ge=Math.min(C??(m?Number.POSITIVE_INFINITY:Ip),Math.max(1,Q-(V&&!m?0:Zn))),Re=V?ge:ie*ge+(ie-1)*Zn,Qe=(se-Re)/2,at=[],et=ce=>V?ce.end>=ce.start:ce.end>=d;Y.forEach((ce,Oe)=>{let st=-1,Pe=-1;ce.segments.forEach((xt,lt)=>{xt.value!==null&&xt.outer!==false&&(et(xt)?st=lt:Pe=lt);});let De=0,it=0;ce.segments.forEach((xt,lt)=>{if(xt.value===null)return;let pr=_[lt],tt=et(xt),yr=K(V?xt.start:d),Wr=K(xt.end),Bt=Math.min(yr,Wr),ar=Math.abs(Wr-yr),Rr=xt.base??(tt?De===0:it===0),ye=H?!tt:tt;V&&!Rr&&ar>Zn&&(ar-=Zn,ye&&(Bt+=Zn)),tt?De+=1:it+=1;let xe=ae[Oe]+(V?Qe:Qe+lt*(ge+Zn)),ne=lt===(tt?st:Pe)?H?tt?"top":"bottom":tt?"right":"left":"none",he=H?{x:xe,y:Bt,width:ge,height:ar}:{x:Bt,y:xe,width:ar,height:ge},fe=null;if(v&&!V){let Te=N(xt.value),Ce=vr(Te,10);if(H){let we=tt?Bt:Bt+ar,Me=tt?we-To:we+To,Ae=ie>1?ge+Zn:se;Ce<=Ae&&(tt?Me>8:Me<J-4)&&(fe={x:xe+ge/2,y:Me,anchor:"middle",text:Te});}else {let we=tt?Bt+ar:Bt,Me=tt?U-we-To:we-To;Ce<=Me&&(fe={x:tt?we+To:we-To,y:xe+ge/2,anchor:tt?"start":"end",text:Te});}}at.push({key:pr.key,color:b&&xt.value!==null?b(xt.value):pr.color,d:ir({...he,radius:Ap,round:ne}),label:fe});});});let me=F.map(ce=>{let Oe=O.categoryCenters.map((st,Pe)=>{let De=Ee(r[Pe],ce.key),it=De===null?Number.NaN:K(De);return {x:H?st:it,y:H?it:st,defined:De!==null}});return {key:ce.key,color:ce.color,dashed:ce.dashed,d:$r(Oe,p),markers:Oe.filter(st=>st.defined!==false)}});return {vertical:H,visible:$,barSeries:_,rows:Y,stacked:V,xValues:O.xValues,categoryPositions:ae,categoryCenters:O.categoryCenters,bandwidth:se,categoryTicks:O.categoryTicks,valueTicks:O.valueTicks,valueScale:K,baseline:te,innerWidth:U,innerHeight:J,margin:O.margin,bars:at,lines:me}},[r,n,o,a,e,t,y,i,c,d,u,b,m,p,C,v,f,N,L]),W=useCallback(H=>w.visible.map($=>{let _=Ee(r[H],$.key),F=w.barSeries.indexOf($),A=F===-1?null:w.rows[H].segments[F],V=_===null?"\u2014":c==="percent"&&A!==null?`${N(_)} (${f(A.end-A.start)})`:f(_);return {seriesKey:$.key,seriesLabel:Xt($),color:$.color,value:_,formattedValue:V,datum:r[H]}}),[r,w.visible,w.barSeries,w.rows,c,f,N]),M=useCallback(H=>{if(z===false||r.length===0)return;let $=H.currentTarget.getBoundingClientRect(),_=w.vertical?H.clientX-$.left-w.margin.left:H.clientY-$.top-w.margin.top,F=Wt(w.categoryCenters,_);I(F>=0?F:null);},[z,r.length,w.vertical,w.margin,w.categoryCenters]),T=useCallback(H=>{if(r.length===0)return;let $=r.length-1,_=E??0,F=w.vertical?"ArrowRight":"ArrowDown",A=w.vertical?"ArrowLeft":"ArrowUp",V=H.key===F?Math.min($,_+1):H.key===A?Math.max(0,_-1):H.key==="Home"?0:H.key==="End"?$:H.key==="Escape"?null:void 0;V!==void 0&&(H.preventDefault(),I(V));},[r.length,E,w.vertical]),P=useCallback(()=>{if(!h||E===null)return;let[H]=W(E);H&&h({...H,index:E,x:w.xValues[E]});},[h,E,W,w.xValues]),x=E===null?null:W(E),D=E===null||x===null?null:{x:w.xValues[E],xLabel:L(w.xValues[E],E),index:E,points:x},S=H=>{let $=w.rows[H].segments.filter(_=>_.value!==null).map(_=>w.valueScale(_.end));for(let _ of w.lines){let F=Ee(r[H],_.key);F!==null&&$.push(w.valueScale(F));}return $},B=E===null?null:w.vertical?{x:w.margin.left+w.categoryCenters[E],y:w.margin.top+Math.min(...S(E),w.baseline)}:{x:w.margin.left+Math.max(...S(E),w.baseline),y:w.margin.top+w.categoryCenters[E]};return jsxs(Fragment,{children:[jsxs("svg",{width:e,height:t,role:"img","aria-label":R??w.visible.map(H=>Xt(H)).join(", "),tabIndex:0,className:"touch-none focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-blue-500",onPointerMove:M,onPointerLeave:()=>I(null),onKeyDown:T,onBlur:()=>I(null),onClick:P,children:[jsxs("g",{transform:`translate(${w.margin.left}, ${w.margin.top})`,children:[jsx(Ot,{width:w.innerWidth,height:w.innerHeight,horizontal:w.vertical&&(s==="y"||s==="both")?w.valueTicks.map(H=>H.offset):void 0,vertical:!w.vertical&&(s==="y"||s==="both")?w.valueTicks.map(H=>H.offset):void 0}),E!==null?jsx("rect",{x:w.vertical?w.categoryPositions[E]:0,y:w.vertical?0:w.categoryPositions[E],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,jsx(Hp,{bars:w.bars}),w.lines.length>0?jsx(Vp,{lines:w.lines}):null,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"}),k?.map(H=>{let $=w.valueScale(H.value),_=$<zp?$+12:$-4;return jsxs("g",{children:[jsx("line",{x1:w.vertical?0:$,y1:w.vertical?$:0,x2:w.vertical?w.innerWidth:$,y2:w.vertical?$:w.innerHeight,stroke:H.color??"var(--color-chart-muted)",strokeWidth:1,strokeDasharray:H.dashed===false?void 0:"4 4"}),H.label?jsx("text",{x:w.vertical?w.innerWidth:$+4,y:w.vertical?_:8,textAnchor:w.vertical?"end":"start",className:"fill-gray-500 text-[10px] dark:fill-gray-400",children:H.label}):null]},`${H.value}-${H.label??""}`)})]}),jsx("g",{transform:`translate(${w.margin.left}, ${w.margin.top+w.innerHeight})`,children:(w.vertical?o.hidden:a?.hidden)?null:jsx(_e,{orientation:"bottom",ticks:w.vertical?w.categoryTicks:w.valueTicks,length:w.innerWidth,label:w.vertical?o.label:a?.label,size:l})}),jsx("g",{transform:`translate(${w.margin.left}, ${w.margin.top})`,children:(w.vertical?a?.hidden:o.hidden)?null:jsx(_e,{orientation:"left",ticks:w.vertical?w.valueTicks:w.categoryTicks,length:w.innerHeight,showLine:false,label:w.vertical?a?.label:o.label,size:l})})]}),D&&B&&z!==false?jsx(gt,{x:B.x,y:B.y,containerWidth:e,children:typeof z=="function"?z(D):jsx(Cr,{title:D.xLabel,points:D.points})}):null]})}function Fp({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:b,description:m,loading:p=false,emptyState:C,onPointClick:v,orientation:k="vertical",stack:y="none",diverging:z,bins:h,curve:R="linear",barSize:f,sort:N="none",showValues:L=false,referenceLines:E,legendToggle:I=true,margin:w,locale:W,plotLabel:M,className:T,...P}){let[x,D]=useState(()=>new Set),S=h!==void 0&&h!==false,B=S||typeof z!="string"?null:z,H=!S&&typeof z=="number"?z:0,$=useMemo(()=>{let te=B===null?null:Co([0,Math.max(1,t.length-1)],{center:Math.max(0,t.findIndex(ie=>ie.key===B)),symmetric:false});return t.map((ie,Q)=>({...ie,hidden:ie.hidden||x.has(ie.key),color:te&&!ie.color&&!u?ie.key===B?Tr:te(Q):Er(ie,Q,u)}))},[t,x,u,B]),_=useMemo(()=>te=>rt(te,W),[W]),F=useMemo(()=>{if(!S)return null;t.length>1&&!Ci&&(Ci=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 te=t[0]?.key??"count",ie=r.format?ge=>r.format(ge,0):ge=>_(ge),Q=ki(e.map(ge=>Ee(ge,r.key)),h);return {rows:Q.map(ge=>({[r.key]:ge.from,[te]:ge.count})),labels:Q.map(ge=>`${ie(ge.from)}\u2013${ie(ge.to)}`)}},[S,h,e,r.key,r.format,t,_]),A=useMemo(()=>{if(F)return F.rows;if(N==="none")return e;let te=$.filter(Q=>!Q.hidden).map(Q=>Q.key),ie=Q=>te.reduce((ge,Re)=>ge+(Ee(Q,Re)??0),0);return [...e].sort((Q,ge)=>N==="asc"?ie(Q)-ie(ge):ie(ge)-ie(Q))},[F,e,N,$]),V=!S&&y==="percent",Y=useMemo(()=>V?{domain:B===null?[0,100]:[-100,100],...n}:n,[V,B,n]),X=useMemo(()=>{let te=n?.format??(V?ie=>Gt(ie,{locale:W,alreadyScaled:true,maximumFractionDigits:0}):_);return B===null?te:ie=>te(Math.abs(ie))},[n?.format,V,W,_,B]),G=useMemo(()=>F?(te,ie)=>F.labels[ie]??"":r.format??(te=>Ke(te,W)),[F,r.format,W]),j=useMemo(()=>F?{...r,scale:"category"}:r,[F,r]),O=useCallback(te=>{D(ie=>{let Q=new Set(ie);return Q.has(te)?Q.delete(te):Q.add(te),Q});},[]),K=i===void 0?t.length>=2:i!==false,se=typeof i=="string"?i:"bottom",ae=$.filter(te=>!te.hidden),U=ae.length,J=useMemo(()=>{if(S||z===void 0||z===false||B!==null||U!==1)return null;let te=ur(A,ae.map(Q=>Q.key)),ie=No([...te,H],{domain:n?.domain,includeZero:n?.includeZero??H===0,ticks:n?.ticks??5});return Co(ie,{center:H})},[S,z,B,U,ae,A,H,n]);return jsx(ut,{title:b,description:m,height:o,width:a,size:s,loading:p,empty:A.length===0||U===0,emptyState:C,tableView:d,legendPosition:se,legend:J?jsx(fa,{scale:J,label:n?.label,format:X,size:s,locale:W}):K?jsx($t,{items:Or($,u),position:se,marker:"rect",size:s,onToggle:I?O:void 0}):void 0,table:d?jsx(It,{data:A,series:$,xKey:j.key,xLabel:r.label??r.key,formatX:G,formatValue:_,caption:typeof b=="string"?b:void 0}):void 0,className:T,...P,children:({width:te})=>jsx(Bp,{width:te,height:o,data:A,resolvedSeries:$,x:j,y:Y,grid:l,size:s,orientation:k,stack:S?"none":y,center:H,centerKey:B,valueColors:J,binned:S,curve:R,barSize:f,showValues:L,referenceLines:E,margin:w,tooltip:c,onPointClick:v,plotLabel:M,formatValue:X,formatRaw:_,formatX:G})})}function zc({className:e}){return jsx("svg",{className:e,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",children: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 $p({className:e}){return jsx("svg",{className:e,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",children: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 _p({className:e}){return jsx("svg",{className:e,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",children: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 Xp({className:e}){return jsx("svg",{className:e,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",children: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 Ni({className:e}){return jsx("svg",{className:e,viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",children:jsx("path",{d:"M4 4L12 12M12 4L4 12",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})})}var Gp={info:zc,success:$p,warning:_p,error:Xp,default:zc},Kp={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"},Up={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 Yp({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,b]=useState(true);if(!u)return null;let m=()=>{b(false),l?.();},p=Gp[e],C=n??r;return jsxs("div",{role:"alert",className:g("flex items-start gap-3 border px-4 py-3",i?"w-full":"rounded-lg",Kp[e],c),...d,children:[jsx("div",{className:g("shrink-0 mt-0.5",Up[e]),children:o??jsx(p,{className:"w-5 h-5"})}),jsxs("div",{className:"flex-1 min-w-0",children:[t&&jsx("div",{className:"font-semibold text-sm",children:t}),C&&jsx("div",{className:g("text-sm",t?"mt-1 opacity-90":false),children:C}),a&&jsx("div",{className:"mt-3",children:a})]}),s&&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:jsx(Ni,{className:"w-4 h-4"})})]})}function qp({title:e,description:t,children:r,action:n,backgroundImage:o,closable:a=false,onClose:s,fullWidth:l=false,className:i,...c}){let[d,u]=useState(true);if(!d)return null;let b=()=>{u(false),s?.();},m=r??t;return 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&&jsx("div",{className:"absolute inset-0 bg-black/50","aria-hidden":"true"}),jsxs("div",{className:"relative z-10 max-w-3xl mx-auto text-center",children:[e&&jsx("h2",{className:"text-2xl sm:text-3xl lg:text-4xl font-bold tracking-tight",children:e}),m&&jsx("div",{className:g("text-base sm:text-lg opacity-90",e?"mt-4":false),children:m}),n&&jsx("div",{className:"mt-6",children:n})]}),a&&jsx("button",{type:"button",onClick:b,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:jsx(Ni,{className:"w-5 h-5"})})]})}function jp({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,b]=useState(true);if(!u)return null;let m=()=>{b(false),l?.();},p=r??t;return 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&&jsx("div",{className:"shrink-0",children:n}),a&&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}),jsxs("div",{className:"flex-1 min-w-0 flex flex-wrap items-center gap-x-4 gap-y-1",children:[e&&jsx("span",{className:"font-semibold text-sm",children:e}),p&&jsx("span",{className:"text-sm opacity-90",children:p})]}),o&&jsx("div",{className:"shrink-0",children:o}),s&&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:jsx(Ni,{className:"w-4 h-4"})})]})}function Wc({variant:e="notification",...t}){switch(e){case "hero":return jsx(qp,{...t});case "promotion":return jsx(jp,{...t});default:return jsx(Yp,{...t})}}Wc.displayName="Banner";var Zp={sm:"text-xs",md:"text-sm",lg:"text-base"};function Qp({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],b=e.slice(-(n-1));c=[u,...b];}return jsx("nav",{"aria-label":"Breadcrumb",className:g("inline-flex items-center",Zp[r],l),...i,children:jsx("ol",{className:"inline-flex items-center space-x-1 md:space-x-2",children:c.map((u,b)=>{let m=b===c.length-1;return jsxs("li",{className:"inline-flex items-center",children:[d&&b===1&&jsxs(Fragment,{children:[jsx("span",{className:g("mx-1 select-none",s),children:"..."}),jsx("span",{className:g("mx-1 select-none",s),"aria-hidden":"true",children:t})]}),u.href||u.onClick?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&&jsx("span",{className:"inline-flex","aria-hidden":"true",children:u.icon}),jsx("span",{children:u.label})]}):jsxs("span",{className:g("inline-flex items-center gap-1.5",m?a:o),"aria-current":m?"page":void 0,children:[u.icon&&jsx("span",{className:"inline-flex","aria-hidden":"true",children:u.icon}),jsx("span",{children:u.label})]}),!m&&jsx("span",{className:g("mx-2 select-none",s),"aria-hidden":"true",children:t})]},u.href??u.label)})})})}var r0=22,n0=.42,Hc=3,Vc=8,o0=12,a0=["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"],s0=memo(function({rows:t,color:r}){return jsx("g",{children:t.map(n=>jsxs("g",{children:[n.bands.map(o=>jsx("path",{d:o.d,className:o.className,fill:o.fill},o.key)),n.measure?jsx("path",{d:n.measure,fill:r}):null,n.target?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?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 i0({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:b,onRowClick:m}){let[p,C]=useState(null),v=useMemo(()=>{let R=r.map(S=>S.label),f=s?r.map(S=>S.formattedValue):[],N={top:6,right:s?kr(f)+Vc*2:8,bottom:a?26+(n.label?16:0):6,left:n.hidden?8:n.height??kr(R)+o0},L=Math.max(0,e-N.left-N.right),E=Math.max(0,t-N.top-N.bottom),I=hn(r.map((S,B)=>B),[0,E],{paddingInner:.34}),w=Math.min(l??r0,I.bandwidth),W=Math.max(3,w*n0),M=i??a0,T=i!==void 0,P=r.map((S,B)=>{let H=Math.max(0,S.value??0,S.target??0,...S.ranges.length>0?S.ranges:[0]),$=a??(S.ranges.length>0?[0,H]:ts(0,H,4)),_=Dr($,[0,L]),F=I(B)+(I.bandwidth-w)/2,A=F+w/2,V=S.ranges.length>0?[...S.ranges].sort((j,O)=>j-O):[$[1]],Y=$[0],X=V.map((j,O)=>{let K=_(Y),se=_(Math.max(Y,j));Y=j;let ae=M[Math.min(O,M.length-1)];return {key:`${B}-${O}`,d:ir({x:K,y:F,width:Math.max(0,se-K),height:w,radius:0}),className:T?void 0:ae,fill:T?ae:void 0}}),G=S.value===null?null:ir({x:_($[0]),y:A-W/2,width:Math.max(0,_(S.value)-_($[0])),height:W,radius:2,round:"right"});return {key:`${B}`,bands:X,measure:G,target:S.target===null?null:{x:_(S.target),y1:F-Hc,y2:F+w+Hc},label:s?{x:L+Vc,y:A,text:S.formattedValue}:null,top:I(B),height:I.bandwidth}}),x=n.hidden?[]:r.map((S,B)=>({value:S.x,offset:I.center(B),label:S.label})),D=a?ma(a[0],a[1],5).map(S=>({value:S,offset:Dr(a,[0,L])(S),label:b(S)})):[];return {margin:N,innerWidth:L,innerHeight:E,band:I,rendered:P,categoryTicks:x,valueTicks:D,centers:r.map((S,B)=>I.center(B))}},[r,n,e,t,a,s,l,i,b]),k=useCallback(R=>{if(d===false||r.length===0)return;let f=R.currentTarget.getBoundingClientRect(),N=R.clientY-f.top-v.margin.top;C(Wt(v.centers,N));},[d,r.length,v.margin.top,v.centers]),y=useCallback(R=>{if(r.length===0)return;let f=r.length-1,N=p??0,L=R.key==="ArrowDown"?Math.min(f,N+1):R.key==="ArrowUp"?Math.max(0,N-1):R.key==="Home"?0:R.key==="End"?f:R.key==="Escape"?null:void 0;L!==void 0&&(R.preventDefault(),C(L));},[r.length,p]),z=useCallback(()=>{!m||p===null||m(r[p]);},[m,p,r]),h=p===null?null:r[p];return jsxs(Fragment,{children:[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:k,onPointerLeave:()=>C(null),onKeyDown:y,onBlur:()=>C(null),onClick:z,children:[jsxs("g",{transform:`translate(${v.margin.left}, ${v.margin.top})`,children:[p!==null&&v.rendered[p]?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,jsx(s0,{rows:v.rendered,color:c})]}),jsx("g",{transform:`translate(${v.margin.left}, ${v.margin.top})`,children:n.hidden?null:jsx(_e,{orientation:"left",ticks:v.categoryTicks,length:v.innerHeight,showLine:false,tickSize:0,size:o})}),a?jsx("g",{transform:`translate(${v.margin.left}, ${v.margin.top+v.innerHeight})`,children:jsx(_e,{orientation:"bottom",ticks:v.valueTicks,length:v.innerWidth,label:n.label,size:o})}):null]}),h&&p!==null&&d!==false?jsx(gt,{x:v.margin.left+v.innerWidth/2,y:v.margin.top+v.centers[p],containerWidth:e,children:typeof d=="function"?d(h):jsxs("div",{className:"flex flex-col gap-1",children:[jsx("div",{className:"font-medium text-gray-900 dark:text-gray-100",children:h.label}),jsxs("div",{className:"flex items-center gap-2",children:[jsx("span",{className:"h-0.5 w-3 shrink-0 rounded-full",style:{backgroundColor:c},"aria-hidden":"true"}),jsx("span",{className:"font-semibold text-gray-900 [font-variant-numeric:tabular-nums] dark:text-gray-100",children:h.formattedValue}),h.attainment!==null?jsx("span",{className:"text-gray-500 [font-variant-numeric:tabular-nums] dark:text-gray-400",children:Gt(h.attainment)}):null]})]})}):null]})}function l0({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:b,size:m="md",tooltip:p=true,tableView:C=false,title:v,description:k,loading:y=false,emptyState:z,locale:h,plotLabel:R,valueLabel:f,targetLabel:N,format:L,onRowClick:E,className:I,...w}){let W=Ge(),M=useMemo(()=>L??(H=>rt(H,h)),[L,h]),T=useMemo(()=>t.format??(H=>Ke(H,h)),[t.format,h]),P=useMemo(()=>e.map((H,$)=>{let _=mt(H,t.key,$),F=Ee(H,r),A=n?Ee(H,n):null,V=o?H[o]:void 0,Y=Array.isArray(V)?V.map(X=>typeof X=="number"?X:Number(X)).filter(X=>Number.isFinite(X)):[];return {index:$,x:_,label:T(_,$),value:F,target:A,ranges:Y,formattedValue:F===null?"\u2014":M(F),formattedTarget:A===null?"\u2014":M(A),attainment:F===null||A===null||A===0?null:F/A,datum:H}}),[e,t.key,r,n,o,M,T]),x=useMemo(()=>{if(a)return a;if(s!=="shared")return null;let H=P.reduce(($,_)=>Math.max($,_.value??0,_.target??0,..._.ranges),0);return ts(0,H,5)},[a,s,P]),D=u??Math.max(72,P.length*34+(x?30:12)),S=useMemo(()=>[{key:r,label:f??W.chartValue},...n?[{key:n,label:N??W.chartTarget}]:[]],[r,n,f,N,W.chartValue,W.chartTarget]),B=d??Pr(0);return jsx(ut,{title:v,description:k,height:D,width:b,size:m,loading:y,empty:P.length===0,emptyState:z,tableView:C,table:C?jsx(It,{data:e,series:S,xKey:t.key,xLabel:t.label??t.key,formatX:T,formatValue:M,caption:typeof v=="string"?v:void 0}):void 0,className:I,...w,children:({width:H})=>jsx(i0,{width:H,height:D,rows:P,x:t,size:m,sharedDomain:x,showValues:l,trackSize:i,rangeColors:c,color:B,tooltip:p,plotLabel:R,formatValue:M,onRowClick:E})})}function d0({className:e}){return 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:[jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),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 u0={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"},m0={sm:"p-1.5",md:"p-2",lg:"p-2.5",xl:"p-3"},as={sm:"h-3.5 w-3.5",md:"h-4 w-4",lg:"h-5 w-5",xl:"h-6 w-6"},g0={none:"rounded-none",sm:"rounded-sm",md:"rounded-md",lg:"rounded-lg",full:"rounded-full"};function At({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:b="lg",bgColor:m="bg-blue-600 hover:bg-blue-700",textColor:p="text-white",focusColor:C="focus:ring-blue-300",selected:v=false,value:k,showFocusOnClick:y=false,...z}){let h=n||l,R=d!==void 0&&!t&&!e,f=g("inline-flex items-center justify-center font-medium transition-colors focus:outline-none disabled:opacity-50 disabled:cursor-not-allowed",y?"focus:ring-4":"focus-visible:ring-4"),N=g(v?"bg-blue-700 text-white ring-2 ring-blue-500":m,!v&&p,C&&y&&`focus:ring-4 ${C}`,C&&!y&&`focus-visible:ring-4 ${C}`);return jsx("button",{type:a,onClick:r,disabled:h,"data-value":k,className:g(f,R?m0[s]:u0[s],g0[b],N,u&&"w-full",o),...z,children:l?jsx(d0,{className:as[s]}):R?jsx("span",{className:as[s],children:d}):jsxs(Fragment,{children:[i&&jsx("span",{className:as[s],children:i}),t??e,c&&jsx("span",{className:as[s],children:c})]})})}function Mo({children:e,orientation:t="horizontal",size:r,fullWidth:n=false,selectedValue:o,onChange:a,className:s}){let i=Ri__default.Children.toArray(e).filter(d=>Ri__default.isValidElement(d)&&typeof d.type!="string"),c=(d,u)=>b=>{d!==void 0&&a&&a(d),u&&u(b);};return jsx("div",{className:g("inline-flex",t==="horizontal"?"flex-row":"flex-col",n&&"w-full",s),role:"group",children:i.map((d,u)=>{let b=u===0,m=u===i.length-1,p=!b&&!m,C=d.props.value,v=o!==void 0&&C===o,k=g(t==="horizontal"&&b&&"rounded-r-none",t==="horizontal"&&m&&"rounded-l-none",t==="horizontal"&&p&&"rounded-none",t==="horizontal"&&!b&&"-ml-px",t==="vertical"&&b&&"rounded-b-none",t==="vertical"&&m&&"rounded-t-none",t==="vertical"&&p&&"rounded-none",t==="vertical"&&!b&&"-mt-px",n&&"flex-1");return Ri__default.cloneElement(d,{...d.props,size:r??d.props.size,selected:v||d.props.selected,onClick:c(C,d.props.onClick),className:g(k,d.props.className)})})})}var h0=10080*60*1e3;function Yt(e){return new Date(e.getFullYear(),e.getMonth(),e.getDate())}function eo(e){return new Date(e.getFullYear(),e.getMonth(),1)}function xn(e,t){return new Date(e.getFullYear(),e.getMonth(),e.getDate()+t)}function _r(e,t){return new Date(e.getFullYear(),e.getMonth()+t,1)}function Pi(e){return new Date(e.getFullYear(),e.getMonth()+1,0).getDate()}function tn(e,t){return !e||!t?false:e.getFullYear()===t.getFullYear()&&e.getMonth()===t.getMonth()&&e.getDate()===t.getDate()}function Ti(e,t){return e.getFullYear()===t.getFullYear()&&e.getMonth()===t.getMonth()}function An(e,t){return e.getFullYear()*12+e.getMonth()-(t.getFullYear()*12+t.getMonth())}function is(e){let t=`${e.getMonth()+1}`.padStart(2,"0"),r=`${e.getDate()}`.padStart(2,"0");return `${e.getFullYear()}-${t}-${r}`}function y0(e){let t=Yt(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())/h0)}function Oc(e,t,r){return t&&e<Yt(t)?Yt(t):r&&e>Yt(r)?Yt(r):e}function x0(e,t,r){let n=eo(e),o=(n.getDay()-t+7)%7,a=xn(n,-o),s=r?6:Math.ceil((o+Pi(e))/7);return Array.from({length:s},(l,i)=>Array.from({length:7},(c,d)=>xn(a,i*7+d)))}function v0({className:e}){return jsx("svg",{className:e,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24","aria-hidden":"true",children:jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M15 19l-7-7 7-7"})})}function k0({className:e}){return jsx("svg",{className:e,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24","aria-hidden":"true",children:jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 5l7 7-7 7"})})}var C0={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"}},w0={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"},N0={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"},S0={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"},R0={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"},Jn={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 ls(e,t){if(e==="multiple")return Array.isArray(t)?t.map(Yt):[];if(e==="range"){let r=t??null;return {from:r?.from?Yt(r.from):null,to:r?.to?Yt(r.to):null}}return t instanceof Date?Yt(t):null}function $c(e){return e?e instanceof Date?e:Array.isArray(e)?e[0]??null:e.from??e.to??null:null}function T0(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:b="md",color:m="primary",minDate:p,maxDate:C,disabledDates:v,disabled:k=false,showOutsideDays:y=true,showWeekNumbers:z=false,fixedWeeks:h=false,captionLayout:R="label",fromYear:f,toYear:N,todayButton:L=false,clearButton:E=false,footer:I,bordered:w=true,renderDay:W,labels:M,className:T,...P}=e,x=C0[b],D=Math.max(1,c),S=useMemo(()=>Yt(new Date),[]),B=r!==void 0,[H,$]=useState(()=>ls(t,n)),_=B?ls(t,r):H,F=s!==void 0,[A,V]=useState(()=>eo(l??$c(ls(t,n??r))??new Date)),Y=F?eo(s):A,X=useCallback(ye=>{let xe=eo(ye);F||V(xe),i?.(xe);},[F,i]),G=useRef(null),j=useRef(false),[O,K]=useState(()=>{let ye=$c(ls(t,n??r)),xe=eo(l??s??ye??new Date),re=ye&&Ti(ye,xe)?ye:Ti(Yt(new Date),xe)?Yt(new Date):xe;return Oc(re,p,C)}),se=_r(Y,D-1),U=An(O,Y)>=0&&An(O,se)<=0?O:Y;useEffect(()=>{if(!j.current)return;j.current=false,G.current?.querySelector(`[data-day="${is(O)}"]:not([data-outside])`)?.focus();},[O,Y]);let J=useCallback(ye=>{let xe=Oc(Yt(ye),p,C);j.current=true,K(xe);let re=_r(Y,D-1);An(xe,Y)<0?X(xe):An(xe,re)>0&&X(_r(xe,-(D-1)));},[Y,D,p,C,X]),te=useCallback(ye=>k||p&&ye<Yt(p)||C&&ye>Yt(C)?true:typeof v=="function"?v(ye):Array.isArray(v)?v.some(xe=>tn(xe,ye)):false,[k,p,C,v]),[ie,Q]=useState(null),ge=useCallback(ye=>{B||$(ye),o?.(ye);},[B,o]),Re=useCallback(ye=>{let xe=Yt(ye);if(te(xe))return;if(t==="multiple"){let ne=_??[];if(ne.some(fe=>tn(fe,xe))){ge(ne.filter(fe=>!tn(fe,xe)));return}if(a!==void 0&&ne.length>=a)return;ge([...ne,xe].sort((fe,Te)=>fe.getTime()-Te.getTime()));return}if(t==="range"){let ne=_??{from:null,to:null};if(!ne.from||ne.to){ge({from:xe,to:null});return}ge(xe<ne.from?{from:xe,to:ne.from}:{from:ne.from,to:xe});return}ge(tn(_,xe)?null:xe);},[t,_,a,ge,te]),Qe=useCallback(ye=>{Re(ye),K(Yt(ye)),An(ye,Y)<0?X(ye):An(ye,_r(Y,D-1))>0&&X(_r(ye,-(D-1)));},[Re,Y,D,X]),at=!k&&(!p||An(Y,eo(p))>0),et=!k&&(!C||An(_r(Y,D-1),eo(C))<0),me=useCallback(()=>{X(_r(Y,-1));},[Y,X]),ce=useCallback(()=>{X(_r(Y,1));},[Y,X]),Oe=useCallback(ye=>{if(k)return;let xe=O;switch(ye.key){case "ArrowLeft":ye.preventDefault(),J(xn(xe,-1));break;case "ArrowRight":ye.preventDefault(),J(xn(xe,1));break;case "ArrowUp":ye.preventDefault(),J(xn(xe,-7));break;case "ArrowDown":ye.preventDefault(),J(xn(xe,7));break;case "Home":ye.preventDefault(),J(xn(xe,-((xe.getDay()-d+7)%7)));break;case "End":ye.preventDefault(),J(xn(xe,6-(xe.getDay()-d+7)%7));break;case "PageUp":{ye.preventDefault();let re=ye.shiftKey?-12:-1,ne=_r(xe,re),he=Math.min(xe.getDate(),Pi(ne));J(new Date(ne.getFullYear(),ne.getMonth(),he));break}case "PageDown":{ye.preventDefault();let re=ye.shiftKey?12:1,ne=_r(xe,re),he=Math.min(xe.getDate(),Pi(ne));J(new Date(ne.getFullYear(),ne.getMonth(),he));break}}},[k,O,J,d]),st=useMemo(()=>{let ye=new Intl.DateTimeFormat(u,{weekday:"short"}),xe=new Intl.DateTimeFormat(u,{weekday:"long"}),re=new Date(2024,0,7);return Array.from({length:7},(ne,he)=>{let fe=xn(re,(d+he)%7);return {short:ye.format(fe),long:xe.format(fe)}})},[u,d]),Pe=useMemo(()=>{let ye=new Intl.DateTimeFormat(u,{month:"long"});return Array.from({length:12},(xe,re)=>ye.format(new Date(2024,re,1)))},[u]),De=useMemo(()=>new Intl.DateTimeFormat(u,{month:"long",year:"numeric"}),[u]),it=useMemo(()=>new Intl.DateTimeFormat(u,{dateStyle:"full"}),[u]),xt=useMemo(()=>{if(R!=="dropdown")return [];let ye=S.getFullYear(),xe=f??p?.getFullYear()??ye-100,re=N??C?.getFullYear()??ye+10;return re<xe?[xe]:Array.from({length:re-xe+1},(ne,he)=>xe+he)},[R,f,N,p,C,S]),lt=t==="range"?_:null,pr=lt&&lt.from&&!lt.to&&ie&&ie>lt.from?ie:null,tt=lt?.to??pr,yr=useCallback((ye,xe)=>{let re=!Ti(ye,xe),ne=te(ye),he=false,fe=false,Te=false,Ce=false;return t==="multiple"?he=(_??[]).some(we=>tn(we,ye)):t==="range"?(fe=tn(lt?.from,ye),Te=tn(tt,ye),he=fe||Te,Ce=!!(lt?.from&&tt&&ye>lt.from&&ye<tt)):he=tn(_,ye),{selected:he,today:tn(ye,S),outside:re,disabled:ne,rangeStart:fe,rangeEnd:Te,inRange:Ce}},[t,_,lt,tt,te,S]),Wr=ye=>{let xe=_r(Y,ye),re=x0(xe,d,h),ne=ye===0,he=ye===D-1;return jsxs("div",{className:"flex flex-col",children:[jsxs("div",{className:"mb-2 flex items-center justify-between",children:[jsx("button",{type:"button",onClick:me,disabled:!at,"aria-label":M?.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",Jn[m],x.nav,!at&&"cursor-not-allowed opacity-40 hover:bg-transparent dark:hover:bg-transparent",!ne&&"invisible"),children:jsx(v0,{className:x.icon})}),R==="dropdown"?jsxs("div",{className:"flex items-center gap-1",children:[jsx("select",{"aria-label":M?.monthSelect??"Month",value:xe.getMonth(),disabled:k,onChange:fe=>X(new Date(xe.getFullYear(),Number(fe.target.value)-ye,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",Jn[m],x.select,k&&"cursor-not-allowed opacity-50"),children:Pe.map((fe,Te)=>jsx("option",{value:Te,children:fe},fe))}),jsx("select",{"aria-label":M?.yearSelect??"Year",value:xe.getFullYear(),disabled:k,onChange:fe=>X(new Date(Number(fe.target.value),xe.getMonth()-ye,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",Jn[m],x.select,k&&"cursor-not-allowed opacity-50"),children:xt.map(fe=>jsx("option",{value:fe,children:fe},fe))})]}):jsx("div",{"aria-live":"polite",className:g("font-semibold text-gray-900 dark:text-gray-100",x.caption),children:De.format(xe)}),jsx("button",{type:"button",onClick:ce,disabled:!et,"aria-label":M?.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",Jn[m],x.nav,!et&&"cursor-not-allowed opacity-40 hover:bg-transparent dark:hover:bg-transparent",!he&&"invisible"),children:jsx(k0,{className:x.icon})})]}),jsxs("table",{role:"grid","aria-label":De.format(xe),className:"border-collapse",children:[jsx("thead",{children:jsxs("tr",{children:[z&&jsxs("th",{scope:"col",className:g("font-normal text-gray-400 dark:text-gray-500",x.head),children:[jsx("span",{className:"sr-only",children:M?.weekNumber??"Week number"}),jsx("span",{"aria-hidden":"true",children:"#"})]}),st.map(fe=>jsx("th",{scope:"col",abbr:fe.long,className:g("font-medium uppercase text-gray-500 dark:text-gray-400",x.head),children:fe.short},fe.long))]})}),jsx("tbody",{children:re.map(fe=>jsxs("tr",{children:[z&&jsx("td",{className:g("text-center align-middle text-gray-400 dark:text-gray-500",x.head),children:y0(fe[0])}),fe.map(Te=>{let Ce=yr(Te,xe),we=is(Te);if(Ce.outside&&!y)return jsx("td",{className:"p-0"},we);let Me=tn(Te,U)&&!Ce.outside,Ae=Ce.inRange||Ce.rangeStart&&!!tt||Ce.rangeEnd&&!!lt?.from;return jsx("td",{role:"presentation",className:g("p-0",Ae&&N0[m],Ae&&Ce.rangeStart&&"rounded-l-full",Ae&&Ce.rangeEnd&&"rounded-r-full"),children:jsx("button",{type:"button","data-day":we,"data-selected":Ce.selected||void 0,"data-today":Ce.today||void 0,"data-outside":Ce.outside||void 0,role:"gridcell",tabIndex:Me?0:-1,disabled:k,"aria-selected":Ce.selected,"aria-disabled":Ce.disabled||void 0,"aria-current":Ce.today?"date":void 0,"aria-label":it.format(Te),onClick:()=>{Ce.disabled||Qe(Te);},onMouseEnter:()=>t==="range"&&Q(Yt(Te)),onMouseLeave:()=>t==="range"&&Q(null),onFocus:()=>K(Yt(Te)),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",Jn[m],x.day,Ce.selected?w0[m]:Ce.inRange?g(S0[m],"hover:bg-gray-200/60 dark:hover:bg-gray-600/60"):Ce.today?g(R0[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"),Ce.outside&&!Ce.selected&&"text-gray-400 dark:text-gray-500",Ce.disabled&&"cursor-not-allowed opacity-40 hover:bg-transparent dark:hover:bg-transparent"),children:W?W(Te,Ce):Te.getDate()})},we)})]},is(fe[0])))})]})]},is(xe))},Bt=useCallback(()=>{X(S),K(S),te(S)||Re(S);},[S,X,te,Re]),ar=useCallback(()=>{ge(t==="multiple"?[]:t==="range"?{from:null,to:null}:null);},[t,ge]),Rr=!!I||L||E;return jsxs("div",{ref:G,onKeyDown:Oe,className:g("inline-block bg-white dark:bg-gray-900",w&&"rounded-lg border border-gray-200 shadow-sm dark:border-gray-700",x.padding,k&&"opacity-60",T),...P,children:[jsx("div",{className:g("flex flex-wrap",x.gap),children:Array.from({length:D},(ye,xe)=>Wr(xe))}),Rr&&jsxs("div",{className:g("mt-3 flex items-center justify-between gap-2 border-t border-gray-200 pt-3 dark:border-gray-700",x.footer),children:[jsx("div",{className:"text-gray-600 dark:text-gray-400",children:I}),(L||E)&&jsxs("div",{className:"flex items-center gap-2",children:[L&&jsx("button",{type:"button",onClick:Bt,disabled:k,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",Jn[m],k&&"cursor-not-allowed opacity-50"),children:M?.today??"Today"}),E&&jsx("button",{type:"button",onClick:ar,disabled:k,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",Jn[m],k&&"cursor-not-allowed opacity-50"),children:M?.clear??"Clear"})]})]})]})}function P0(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 E0(e){switch(e){case "sm":return "max-w-sm";case "lg":return "max-w-2xl";default:return "max-w-md"}}function D0(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 L0(e){switch(e){case "none":return "";case "sm":return "p-2";case "lg":return "p-6";default:return ""}}function _c({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:b,...m}){let p=c,C=l?"transition-all duration-200 hover:shadow-lg hover:-translate-y-0.5":"",v=i?"cursor-pointer active:scale-[0.98] transition-transform":"",k=s||"";return jsx(p,{className:g("overflow-hidden",P0(e,a,o),E0(t),D0(r),L0(n),C,v,k,d),onClick:i||b?b:void 0,...m,children:u})}_c.displayName="Card";function I0(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 Gc({actions:e,divider:t=false,padding:r="md",className:n,children:o,...a}){return jsxs("div",{className:g("flex items-center justify-between",I0(r),t&&"border-b border-gray-200 dark:border-gray-700",n),...a,children:[jsx("div",{className:"flex-1",children:o}),e&&jsx("div",{className:"flex items-center gap-2 ml-4",children:e})]})}Gc.displayName="CardHeader";function z0(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 Kc({padding:e="md",className:t,children:r,...n}){return jsx("div",{className:g(z0(e),t),...n,children:r})}Kc.displayName="CardBody";function H0(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 V0(e){switch(e){case "center":return "justify-center";case "right":return "justify-end";case "between":return "justify-between";default:return "justify-start"}}function Uc({divider:e=false,align:t="left",padding:r="md",className:n,children:o,...a}){return jsx("div",{className:g("flex items-center gap-2",H0(r),V0(t),e&&"border-t border-gray-200 dark:border-gray-700",n),...a,children:o})}Uc.displayName="CardFooter";function F0(e){switch(e){case "square":return "aspect-square";case "video":return "aspect-video";case "wide":return "aspect-[21/9]";default:return ""}}function O0(e){switch(e){case "contain":return "object-contain";case "fill":return "object-fill";case "none":return "object-none";default:return "object-cover"}}function Yc({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 jsx("img",{src:n,alt:o,className:g("w-full",F0(t),O0(r),l,a),...s})}Yc.displayName="CardImage";function _0(e){switch(e){case "sm":return "text-base font-medium";case "lg":return "text-2xl font-bold";default:return "text-xl font-semibold"}}function qc({as:e="h3",size:t="md",className:r,children:n,...o}){return jsx(e,{className:g("text-gray-900 dark:text-white",_0(t),r),...o,children:n})}qc.displayName="CardTitle";function G0(e){switch(e){case "sm":return "text-xs";case "lg":return "text-base";default:return "text-sm"}}function jc({size:e="md",className:t,children:r,...n}){return jsx("p",{className:g("text-gray-500 dark:text-gray-400",G0(e),t),...n,children:r})}jc.displayName="CardDescription";function ha(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 U0(e,t){let r=e.filter(Number.isFinite).sort((n,o)=>n-o);return ha(r,t)}function Ei(e,t=1.5){let r=e.filter(b=>typeof b=="number"&&Number.isFinite(b)).sort((b,m)=>b-m);if(r.length===0)return null;let n=ha(r,.25),o=ha(r,.5),a=ha(r,.75),s=a-n,l=Math.max(0,t)*s,i=n-l,c=a+l,d=r.filter(b=>b>=i&&b<=c),u=r.filter(b=>b<i||b>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 j0=40,Z0=3,cs=4,Li="text-right [font-variant-numeric:tabular-nums]",Q0=memo(function({boxes:t,color:r}){return jsx("g",{children:t.map(n=>jsxs("g",{children:[jsx("g",{stroke:r,strokeWidth:1.5,strokeLinecap:"round",children:n.whiskers.map(o=>jsx("line",{x1:o.x1,y1:o.y1,x2:o.x2,y2:o.y2},o.key))}),n.body?jsx("path",{d:n.body,fill:r}):null,n.median?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?jsx("path",{d:`M${n.mean.cx},${n.mean.cy-cs} L${n.mean.cx+cs},${n.mean.cy} L${n.mean.cx},${n.mean.cy+cs} L${n.mean.cx-cs},${n.mean.cy} Z`,strokeWidth:1.5,stroke:r,className:"fill-white dark:fill-gray-800"}):null,n.outliers.map(o=>jsx("circle",{cx:o.cx,cy:o.cy,r:Z0,fill:r,strokeWidth:1.5,className:"stroke-white dark:stroke-gray-800"},o.key))]},n.key))})});function J0({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:b,referenceLines:m,margin:p,tooltip:C,plotLabel:v,formatValue:k,formatX:y,onBoxClick:z}){let[h,R]=useState(null),f=Ge(),N=useMemo(()=>{let M=i==="vertical",T=n.flatMap(V=>V.stats===null?[]:[V.stats.min,V.stats.max,...u&&V.mean!==null?[V.mean]:[]]),P=Qt({width:e,height:t,data:r,x:o,y:a,bounds:T.length===0?null:[Math.min(...T),Math.max(...T)],margin:p,orientation:i,placement:"band",formatValue:k,formatX:y,defaultIncludeZero:false}),{valueScale:x,bandwidth:D,categoryPositions:S,innerWidth:B,innerHeight:H}=P,$=Math.min(c??j0,D),_=$*.5,F=(V,Y)=>M?{x:V,y:Y}:{x:Y,y:V},A=n.map((V,Y)=>{let X=S[Y]+(D-$)/2,G=X+$/2;if(V.stats===null)return {key:`${Y}`,body:"",median:null,whiskers:[],outliers:[],mean:null,top:S[Y],height:D};let{q1:j,q3:O,median:K,lower:se,upper:ae,outliers:U}=V.stats,J=x(j),te=x(O),ie=Math.min(J,te),Q=Math.abs(te-J),ge=ir({...M?{x:X,y:ie,width:$,height:Math.max(1,Q)}:{x:ie,y:X,width:Math.max(1,Q),height:$},radius:2,round:"none"}),Re=x(K),Qe=M?{x1:X,y1:Re,x2:X+$,y2:Re}:{x1:Re,y1:X,x2:Re,y2:X+$},at=[];for(let[et,me,ce]of [["lower",se,j],["upper",ae,O]]){let Oe=x(me),st=x(ce),Pe=F(G,Oe),De=F(G,st);at.push({key:`${et}-stem`,x1:De.x,y1:De.y,x2:Pe.x,y2:Pe.y});let it=F(G-_/2,Oe),xt=F(G+_/2,Oe);at.push({key:`${et}-cap`,x1:it.x,y1:it.y,x2:xt.x,y2:xt.y});}return {key:`${Y}`,body:ge,median:Qe,whiskers:at,outliers:d?U.map((et,me)=>{let ce=F(G,x(et));return {key:`${me}`,cx:ce.x,cy:ce.y}}):[],mean:u&&V.mean!==null?(()=>{let et=F(G,x(V.mean));return {cx:et.x,cy:et.y}})():null,top:S[Y],height:D}});return {vertical:M,rendered:A,categoryPositions:S,categoryCenters:P.categoryCenters,bandwidth:D,categoryTicks:P.categoryTicks,valueTicks:P.valueTicks,valueScale:x,innerWidth:B,innerHeight:H,margin:P.margin}},[n,r,o,a,e,t,p,i,c,d,u,k,y]),L=useCallback(M=>{if(C===false||n.length===0)return;let T=M.currentTarget.getBoundingClientRect(),P=N.vertical?M.clientX-T.left-N.margin.left:M.clientY-T.top-N.margin.top;R(Wt(N.categoryCenters,P));},[C,n.length,N.vertical,N.margin,N.categoryCenters]),E=useCallback(M=>{if(n.length===0)return;let T=n.length-1,P=h??0,x=N.vertical?"ArrowRight":"ArrowDown",D=N.vertical?"ArrowLeft":"ArrowUp",S=M.key===x?Math.min(T,P+1):M.key===D?Math.max(0,P-1):M.key==="Home"?0:M.key==="End"?T:M.key==="Escape"?null:void 0;S!==void 0&&(M.preventDefault(),R(S));},[n.length,h,N.vertical]),I=useCallback(()=>{!z||h===null||z(n[h]);},[z,h,n]),w=h===null?null:n[h],W=h===null||w===null||w.stats===null?null:N.vertical?{x:N.margin.left+N.categoryCenters[h],y:N.margin.top+N.valueScale(w.stats.q3)}:{x:N.margin.left+N.valueScale(w.stats.q3),y:N.margin.top+N.categoryCenters[h]};return jsxs(Fragment,{children:[jsxs("svg",{width:e,height:t,role:"img","aria-label":v??n.map(M=>M.label).join(", "),tabIndex:0,className:"touch-none focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-blue-500",onPointerMove:L,onPointerLeave:()=>R(null),onKeyDown:E,onBlur:()=>R(null),onClick:I,children:[jsxs("g",{transform:`translate(${N.margin.left}, ${N.margin.top})`,children:[jsx(Ot,{width:N.innerWidth,height:N.innerHeight,horizontal:N.vertical&&(s==="y"||s==="both")?N.valueTicks.map(M=>M.offset):void 0,vertical:!N.vertical&&(s==="y"||s==="both")?N.valueTicks.map(M=>M.offset):void 0}),h!==null?jsx("rect",{x:N.vertical?N.categoryPositions[h]:0,y:N.vertical?0:N.categoryPositions[h],width:N.vertical?N.bandwidth:N.innerWidth,height:N.vertical?N.innerHeight:N.bandwidth,className:"fill-gray-400 dark:fill-gray-500",opacity:.12,"aria-hidden":"true"}):null,m?.map(M=>{let T=N.valueScale(M.value);return jsxs("g",{children:[jsx("line",{x1:N.vertical?0:T,y1:N.vertical?T:0,x2:N.vertical?N.innerWidth:T,y2:N.vertical?T:N.innerHeight,stroke:M.color??"var(--color-chart-muted)",strokeWidth:1,strokeDasharray:M.dashed===false?void 0:"4 4"}),M.label?jsx("text",{x:N.vertical?N.innerWidth:T+4,y:N.vertical?T-4:8,textAnchor:N.vertical?"end":"start",className:"fill-gray-500 text-[10px] dark:fill-gray-400",children:M.label}):null]},`${M.value}-${M.label??""}`)}),jsx(Q0,{boxes:N.rendered,color:b})]}),jsx("g",{transform:`translate(${N.margin.left}, ${N.margin.top+N.innerHeight})`,children:(N.vertical?o.hidden:a?.hidden)?null:jsx(_e,{orientation:"bottom",ticks:N.vertical?N.categoryTicks:N.valueTicks,length:N.innerWidth,label:N.vertical?o.label:a?.label,size:l})}),jsx("g",{transform:`translate(${N.margin.left}, ${N.margin.top})`,children:(N.vertical?a?.hidden:o.hidden)?null:jsx(_e,{orientation:"left",ticks:N.vertical?N.valueTicks:N.categoryTicks,length:N.innerHeight,showLine:false,label:N.vertical?a?.label:o.label,size:l})})]}),w&&w.stats&&W&&C!==false?jsx(gt,{x:W.x,y:W.y,containerWidth:e,children:typeof C=="function"?C(w):jsxs("div",{className:"flex flex-col gap-1",children:[jsx("div",{className:"font-medium text-gray-900 dark:text-gray-100",children:w.label}),jsxs("dl",{className:"grid grid-cols-[auto_auto] gap-x-3 gap-y-0.5",children:[[["Max",w.stats.max],["Q3",w.stats.q3],[f.chartMedian,w.stats.median],["Q1",w.stats.q1],["Min",w.stats.min]].map(([M,T])=>jsxs("div",{className:"contents",children:[jsx("dt",{className:"text-gray-500 dark:text-gray-400",children:M}),jsx("dd",{className:"justify-self-end font-medium text-gray-900 [font-variant-numeric:tabular-nums] dark:text-gray-100",children:k(T)})]},M)),jsxs("div",{className:"contents",children:[jsx("dt",{className:"text-gray-500 dark:text-gray-400",children:f.chartCount}),jsx("dd",{className:"justify-self-end font-medium text-gray-900 [font-variant-numeric:tabular-nums] dark:text-gray-100",children:w.stats.count})]})]})]})}):null]})}function ef({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:b=280,width:m,size:p="md",grid:C="y",tooltip:v=true,tableView:k=false,title:y,description:z,loading:h=false,emptyState:R,margin:f,locale:N,plotLabel:L,format:E,onBoxClick:I,className:w,...W}){let M=Ge(),T=useMemo(()=>r?.format??E??(S=>rt(S,N)),[r?.format,E,N]),P=useMemo(()=>t.format??(S=>Ke(S,N)),[t.format,N]),x=useMemo(()=>e.map((S,B)=>{let H=mt(S,t.key,B),$=n?(()=>{let A=S[n];return Array.isArray(A)?A.map(V=>typeof V=="number"?V:Number(V)).filter(V=>Number.isFinite(V)):null})():null,_=null,F=null;if($!==null)_=Ei($,a),F=$.length===0?null:$.reduce((A,V)=>A+V,0)/$.length;else if(o){let A=Ee(S,o.q1),V=Ee(S,o.median),Y=Ee(S,o.q3);if(A!==null&&V!==null&&Y!==null){let X=o.min?Ee(S,o.min)??A:A,G=o.max?Ee(S,o.max)??Y:Y;_={count:0,min:X,max:G,q1:A,median:V,q3:Y,iqr:Y-A,lower:X,upper:G,outliers:[]};}}return {index:B,x:H,label:P(H,B),stats:_,mean:F,datum:S}}),[e,t.key,n,o,a,P]),D=x.filter(S=>S.stats!==null);return jsx(ut,{title:y,description:z,height:b,width:m,size:p,loading:h,empty:D.length===0,emptyState:R,tableView:k,table:k?jsx("div",{className:"w-full overflow-x-auto",children:jsxs(gn,{children:[typeof y=="string"?jsx("caption",{className:"sr-only",children:y}):null,jsxs(fn,{children:[jsx(Nt,{children:t.label??t.key}),n?jsx(Nt,{className:"text-right",children:M.chartCount}):null,jsx(Nt,{className:"text-right",children:"Min"}),jsx(Nt,{className:"text-right",children:"Q1"}),jsx(Nt,{className:"text-right",children:M.chartMedian}),jsx(Nt,{className:"text-right",children:"Q3"}),jsx(Nt,{className:"text-right",children:"Max"}),n&&i?jsx(Nt,{className:"text-right",children:M.chartOutliers}):null]}),jsx(pn,{children:x.map(S=>jsxs(bn,{clickable:false,children:[jsx(_t,{className:"font-medium text-gray-900 dark:text-gray-100",children:S.label}),n?jsx(_t,{className:Li,children:S.stats?.count??"\u2014"}):null,["min","q1","median","q3","max"].map(B=>jsx(_t,{className:Li,children:S.stats===null?"\u2014":T(S.stats[B])},B)),n&&i?jsx(_t,{className:Li,children:S.stats===null||S.stats.outliers.length===0?"\u2014":S.stats.outliers.map(T).join(", ")}):null]},S.index))})]})}):void 0,className:w,...W,children:({width:S})=>jsx(J0,{width:S,height:b,data:e,boxes:x,x:t,y:r,grid:C,size:p,orientation:s,boxSize:l,showOutliers:i,showMean:c,color:d??Pr(0),referenceLines:u,margin:f,tooltip:v,plotLabel:L,formatValue:T,formatX:P,onBoxClick:I})})}var of=16,af=1.5,sf=memo(function({candles:t}){return jsx("g",{children:t.map(r=>jsxs("g",{children:[r.wick?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?jsx("path",{d:r.body,fill:r.hollow?"none":r.color,stroke:r.color,strokeWidth:r.hollow?1.5:0}):null]},r.key))})});function lf({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:b,tooltip:m,plotLabel:p,formatValue:C,formatX:v,onCandleClick:k}){let[y,z]=useState(null),h=Ge(),R=useMemo(()=>{let I=n.flatMap(B=>B.high===null||B.low===null?[]:[B.low,B.high]),w=Qt({width:e,height:t,data:r,x:o,y:a,bounds:I.length===0?null:[Math.min(...I),Math.max(...I)],margin:b,orientation:"vertical",placement:"band",formatValue:C,formatX:v,defaultIncludeZero:false}),{valueScale:W,bandwidth:M,categoryPositions:T,innerWidth:P,innerHeight:x}=w,D=Math.min(i??of,Math.max(1,M-2));return {rendered:n.map((B,H)=>{let $=T[H]+(M-D)/2,_=$+D/2,F=B.rising?d.up:d.down,A=B.high===null||B.low===null?null:{x:_,y1:W(B.high),y2:W(B.low)},V=null;if(B.open!==null&&B.close!==null){let Y=W(B.open),X=W(B.close);V=ir({x:$,y:Math.min(Y,X),width:D,height:Math.max(af,Math.abs(X-Y)),radius:0,round:"none"});}return {key:`${H}`,color:F,body:V,hollow:B.rising&&!c,wick:A,left:$,width:D}}),categoryPositions:T,categoryCenters:w.categoryCenters,bandwidth:M,categoryTicks:w.categoryTicks,valueTicks:w.valueTicks,valueScale:W,innerWidth:P,innerHeight:x,margin:w.margin}},[n,r,o,a,e,t,b,i,c,d,C,v]),f=useCallback(I=>{if(m===false||n.length===0)return;let w=I.currentTarget.getBoundingClientRect(),W=I.clientX-w.left-R.margin.left;z(Wt(R.categoryCenters,W));},[m,n.length,R.margin.left,R.categoryCenters]),N=useCallback(I=>{if(n.length===0)return;let w=n.length-1,W=y??0,M=I.key==="ArrowRight"?Math.min(w,W+1):I.key==="ArrowLeft"?Math.max(0,W-1):I.key==="Home"?0:I.key==="End"?w:I.key==="Escape"?null:void 0;M!==void 0&&(I.preventDefault(),z(M));},[n.length,y]),L=useCallback(()=>{!k||y===null||k(n[y]);},[k,y,n]),E=y===null?null:n[y];return jsxs(Fragment,{children:[jsxs("svg",{width:e,height:t,role:"img","aria-label":p??n.map(I=>I.label).join(", "),tabIndex:0,className:"touch-none focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-blue-500",onPointerMove:f,onPointerLeave:()=>z(null),onKeyDown:N,onBlur:()=>z(null),onClick:L,children:[jsxs("g",{transform:`translate(${R.margin.left}, ${R.margin.top})`,children:[jsx(Ot,{width:R.innerWidth,height:R.innerHeight,horizontal:s==="y"||s==="both"?R.valueTicks.map(I=>I.offset):void 0}),y!==null?jsx("rect",{x:R.categoryPositions[y],y:0,width:R.bandwidth,height:R.innerHeight,className:"fill-gray-400 dark:fill-gray-500",opacity:.12,"aria-hidden":"true"}):null,u?.map(I=>jsxs("g",{children:[jsx("line",{x1:0,y1:R.valueScale(I.value),x2:R.innerWidth,y2:R.valueScale(I.value),stroke:I.color??"var(--color-chart-muted)",strokeWidth:1,strokeDasharray:I.dashed===false?void 0:"4 4"}),I.label?jsx("text",{x:R.innerWidth,y:R.valueScale(I.value)-4,textAnchor:"end",className:"fill-gray-500 text-[10px] dark:fill-gray-400",children:I.label}):null]},`${I.value}-${I.label??""}`)),jsx(sf,{candles:R.rendered})]}),jsx("g",{transform:`translate(${R.margin.left}, ${R.margin.top+R.innerHeight})`,children:o.hidden?null:jsx(_e,{orientation:"bottom",ticks:R.categoryTicks,length:R.innerWidth,label:o.label,size:l})}),jsx("g",{transform:`translate(${R.margin.left}, ${R.margin.top})`,children:a?.hidden?null:jsx(_e,{orientation:"left",ticks:R.valueTicks,length:R.innerHeight,showLine:false,label:a?.label,size:l})})]}),E&&y!==null&&m!==false?jsx(gt,{x:R.margin.left+R.categoryCenters[y],y:R.margin.top+(E.high===null?R.innerHeight/2:R.valueScale(E.high)),containerWidth:e,children:typeof m=="function"?m(E):jsxs("div",{className:"flex flex-col gap-1",children:[jsx("div",{className:"font-medium text-gray-900 dark:text-gray-100",children:E.label}),jsx("dl",{className:"grid grid-cols-[auto_auto] gap-x-3 gap-y-0.5",children:[[h.chartOpen,E.open],[h.chartHigh,E.high],[h.chartLow,E.low],[h.chartClose,E.close]].map(([I,w])=>jsxs("div",{className:"contents",children:[jsx("dt",{className:"text-gray-500 dark:text-gray-400",children:I}),jsx("dd",{className:"justify-self-end font-medium text-gray-900 [font-variant-numeric:tabular-nums] dark:text-gray-100",children:w===null?"\u2014":C(w)})]},I))}),E.change===null?null:jsxs("div",{className:"flex items-center gap-2 border-t border-gray-200 pt-1 dark:border-gray-700",children:[jsx("span",{className:"text-gray-500 dark:text-gray-400",children:E.rising?h.chartRise:h.chartFall}),jsxs("span",{className:"[font-variant-numeric:tabular-nums] font-semibold text-gray-900 dark:text-gray-100",children:[E.change>0?"+":"",C(E.change)]})]})]})}):null]})}function cf({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:b,size:m="md",grid:p="y",legend:C,tooltip:v=true,tableView:k=false,title:y,description:z,loading:h=false,emptyState:R,margin:f,locale:N,plotLabel:L,openLabel:E,highLabel:I,lowLabel:w,closeLabel:W,riseLabel:M,fallLabel:T,format:P,onCandleClick:x,className:D,...S}){let B=Ge(),H=useMemo(()=>r?.format??P??(X=>rt(X,N)),[r?.format,P,N]),$=useMemo(()=>t.format??(X=>Ke(X,N)),[t.format,N]),_=useMemo(()=>e.map((X,G)=>{let j=mt(X,t.key,G),O=Ee(X,n),K=Ee(X,s);return {index:G,x:j,label:$(j,G),open:O,high:Ee(X,o),low:Ee(X,a),close:K,change:O===null||K===null?null:K-O,rising:O===null||K===null?true:K>=O,datum:X}}),[e,t.key,n,o,a,s,$]),F=useMemo(()=>({up:c?.up??gi,down:c?.down??pi}),[c]),A=useMemo(()=>[{key:"up",label:M??B.chartRise,color:F.up,marker:"rect"},{key:"down",label:T??B.chartFall,color:F.down,marker:"rect"}],[F,M,T,B.chartRise,B.chartFall]),V=C===void 0?true:C!==false,Y=typeof C=="string"?C:"bottom";return jsx(ut,{title:y,description:z,height:u,width:b,size:m,loading:h,empty:_.length===0,emptyState:R,tableView:k,legendPosition:Y,legend:V?jsx($t,{items:A,position:Y,marker:"rect",size:m}):void 0,table:k?jsx(It,{data:e,series:[{key:n,label:E??B.chartOpen},{key:o,label:I??B.chartHigh},{key:a,label:w??B.chartLow},{key:s,label:W??B.chartClose}],xKey:t.key,xLabel:t.label??t.key,formatX:$,formatValue:H,caption:typeof y=="string"?y:void 0}):void 0,className:D,...S,children:({width:X})=>jsx(lf,{width:X,height:u,data:e,candles:_,x:t,y:r,grid:p,size:m,candleSize:l,fillRising:i,palette:F,referenceLines:d,margin:f,tooltip:v,plotLabel:L,formatValue:H,formatX:$,onCandleClick:x})})}var Zc=12,Ai=false,uf={sm:"text-[11px]",md:"text-xs",lg:"text-sm"},mf={sm:"text-xs",md:"text-sm",lg:"text-base"};function gf({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:b,description:m,size:p="md",locale:C,emptyState:v,children:k,className:y,...z}){let h=d??(L=>Ke(L,C)),R=new Map;e.forEach((L,E)=>{let I=mt(L,t,E),w=St(I),W=R.get(w);W?W.rows.push(L):R.set(w,{value:I,rows:[L]});});let f=[...R.entries()];if(s)f=s.map(St).map(E=>f.find(([I])=>I===E)).filter(E=>E!==void 0);else if(l!=="none"){let L=E=>E.reduce((I,w)=>I+r.reduce((W,M)=>W+(Ee(w,M)??0),0),0);f=[...f].sort(([,E],[,I])=>l==="asc"?L(E.rows)-L(I.rows):L(I.rows)-L(E.rows));}let N=n??No(ur(e,r),{includeZero:o,ticks:a});return f.length>Zc&&!Ai&&(Ai=true,console.warn(`[@synertech/ui] ChartFacets was given ${f.length} panels. Past ${Zc} a facet grid stops being a comparison \u2014 filter the data down to the panels the reader is actually comparing.`)),f.length===0?jsx("div",{className:g("text-sm text-gray-500 dark:text-gray-400",y),...z,children:v}):jsxs("div",{className:g("flex w-full flex-col gap-3",y),...z,children:[b||m?jsxs("div",{className:"flex flex-col gap-0.5",children:[b?jsx("span",{className:g("font-semibold text-gray-900 dark:text-gray-100",mf[p]),children:b}):null,m?jsx("span",{className:"text-xs text-gray-500 dark:text-gray-400",children:m}):null]}):null,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:f.map(([L,E],I)=>{let w=h(E.value,I);return jsxs("div",{role:"group","aria-label":w,className:"flex min-w-0 flex-col gap-1",children:[u?jsx("span",{className:g("font-medium text-gray-700 dark:text-gray-200",uf[p]),children:w}):null,k({key:L,label:w,data:E.rows,domain:N,index:I,count:f.length})]},L)})})]})}function pf(){Ai=false;}var zi=[{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 ff(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 Qc(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 Wi(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=zi.find(i=>i.span>=o)??zi[zi.length-1],s=[],l=ff(new Date(e),a.unit,a.step);for(;l.getTime()<e;)l=Qc(l,a.unit,a.step);for(;l.getTime()<=t&&s.length<=500;)s.push(l.getTime()),l=Qc(l,a.unit,a.step);return {values:s,unit:a.unit,step:a.step}}function us(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 to(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 hf=5,yf=3,Jc=10,Hi=false;function xf(){Hi=false;}var vf=memo(function({rows:t,radius:r}){return jsx("g",{children:t.map(n=>jsxs("g",{children:[n.connector?jsx("line",{x1:n.connector.x1,y1:n.connector.y,x2:n.connector.x2,y2:n.connector.y,strokeWidth:yf,strokeLinecap:"round",className:"stroke-gray-300 dark:stroke-gray-600"}):null,n.dots.map(o=>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?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 kf({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:b,tooltip:m,plotLabel:p,formatValue:C,formatX:v,onRowClick:k}){let[y,z]=useState(null),h=useMemo(()=>{let I=o.filter(S=>!S.hidden).map(S=>S.key),w=Qt({width:e,height:t,data:r,x:a,y:s,bounds:Kt(ur(r,I)),margin:b,orientation:"horizontal",placement:"band",formatValue:C,formatX:v,defaultIncludeZero:false}),{valueScale:W,bandwidth:M,categoryPositions:T,innerWidth:P,innerHeight:x}=w;return {rendered:n.map((S,B)=>{let H=T[B]+M/2,$=S.points.map((A,V)=>({key:A.seriesKey,value:A.value,cx:A.value===null?Number.NaN:W(A.value),cy:H,color:A.color,order:V})).filter(A=>A.value!==null),_=S.from===null||S.to===null||$.length<2?null:{x1:W(S.from),x2:W(S.to),y:H},F=null;if(c&&S.to!==null){let A=C(S.to),V=W(S.to);vr(A,10)<=P-V-Jc&&(F={x:V+Jc,y:H,text:A});}return {key:`${B}`,connector:_,dots:$.map(A=>({key:A.key,cx:A.cx,cy:A.cy,color:A.color})),label:F,top:T[B],height:M}}),categoryPositions:T,categoryCenters:w.categoryCenters,bandwidth:M,categoryTicks:w.categoryTicks,valueTicks:w.valueTicks,valueScale:W,innerWidth:P,innerHeight:x,margin:w.margin}},[r,n,o,a,s,e,t,b,c,C,v]),R=useCallback(E=>{if(m===false||n.length===0)return;let I=E.currentTarget.getBoundingClientRect(),w=E.clientY-I.top-h.margin.top;z(Wt(h.categoryCenters,w));},[m,n.length,h.margin.top,h.categoryCenters]),f=useCallback(E=>{if(n.length===0)return;let I=n.length-1,w=y??0,W=E.key==="ArrowDown"?Math.min(I,w+1):E.key==="ArrowUp"?Math.max(0,w-1):E.key==="Home"?0:E.key==="End"?I:E.key==="Escape"?null:void 0;W!==void 0&&(E.preventDefault(),z(W));},[n.length,y]),N=useCallback(()=>{!k||y===null||k(n[y]);},[k,y,n]),L=y===null?null:n[y];return jsxs(Fragment,{children:[jsxs("svg",{width:e,height:t,role:"img","aria-label":p??o.map(E=>Xt(E)).join(", "),tabIndex:0,className:"touch-none focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-blue-500",onPointerMove:R,onPointerLeave:()=>z(null),onKeyDown:f,onBlur:()=>z(null),onClick:N,children:[jsxs("g",{transform:`translate(${h.margin.left}, ${h.margin.top})`,children:[jsx(Ot,{width:h.innerWidth,height:h.innerHeight,vertical:l==="y"||l==="both"?h.valueTicks.map(E=>E.offset):void 0}),y!==null?jsx("rect",{x:0,y:h.categoryPositions[y],width:h.innerWidth,height:h.bandwidth,className:"fill-gray-400 dark:fill-gray-500",opacity:.12,"aria-hidden":"true"}):null,u?.map(E=>jsxs("g",{children:[jsx("line",{x1:h.valueScale(E.value),y1:0,x2:h.valueScale(E.value),y2:h.innerHeight,stroke:E.color??"var(--color-chart-muted)",strokeWidth:1,strokeDasharray:E.dashed===false?void 0:"4 4"}),E.label?jsx("text",{x:h.valueScale(E.value)+4,y:8,className:"fill-gray-500 text-[10px] dark:fill-gray-400",children:E.label}):null]},`${E.value}-${E.label??""}`)),jsx(vf,{rows:h.rendered,radius:d})]}),jsx("g",{transform:`translate(${h.margin.left}, ${h.margin.top+h.innerHeight})`,children:s?.hidden?null:jsx(_e,{orientation:"bottom",ticks:h.valueTicks,length:h.innerWidth,label:s?.label,size:i})}),jsx("g",{transform:`translate(${h.margin.left}, ${h.margin.top})`,children:a.hidden?null:jsx(_e,{orientation:"left",ticks:h.categoryTicks,length:h.innerHeight,showLine:false,tickSize:0,label:a.label,size:i})})]}),L&&y!==null&&m!==false?jsx(gt,{x:h.margin.left+(L.to===null?h.innerWidth/2:h.valueScale(L.to)),y:h.margin.top+h.categoryCenters[y],containerWidth:e,children:typeof m=="function"?m(L):jsx(Cr,{title:L.label,points:L.points})}):null]})}function Cf({data:e,x:t,y:r,series:n,sort:o="none",sortBy:a,showValues:s=false,dotSize:l=hf,referenceLines:i,height:c,width:d,size:u="md",grid:b="y",legend:m,legendToggle:p=true,tooltip:C=true,tableView:v=false,showChange:k=true,title:y,description:z,loading:h=false,emptyState:R,margin:f,locale:N,plotLabel:L,changeLabel:E,format:I,onRowClick:w,className:W,...M}){let T=Ge(),[P,x]=useState(()=>new Set);n.length>3&&!Hi&&(Hi=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 D=useMemo(()=>n.map((G,j)=>({...G,hidden:G.hidden||P.has(G.key),color:Er(G,j)})),[n,P]),S=useMemo(()=>r?.format??I??(G=>rt(G,N)),[r?.format,I,N]),B=useMemo(()=>t.format??(G=>Ke(G,N)),[t.format,N]),H=useMemo(()=>D.filter(G=>!G.hidden),[D]),$=useMemo(()=>e.map((G,j)=>{let O=mt(G,t.key,j),K=H.map(J=>{let te=Ee(G,J.key);return {seriesKey:J.key,seriesLabel:Xt(J),color:J.color,value:te,formattedValue:te===null?"\u2014":S(te),datum:G}}),se=K.map(J=>J.value).filter(J=>J!==null),ae=K[0]?.value??null,U=K[K.length-1]?.value??null;return {index:j,x:O,label:B(O,j),points:K,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:G}}),[e,t.key,H,S,B]),_=useMemo(()=>{if(o==="none")return $;let G=a??H[H.length-1]?.key,j=K=>o==="gap"?Math.abs(K.change??0):K.points.find(se=>se.seriesKey===G)?.value??0,O=[...$].sort((K,se)=>j(K)-j(se));return o==="asc"?O:O.reverse()},[$,o,a,H]),F=useCallback(G=>{x(j=>{let O=new Set(j);return O.has(G)?O.delete(G):O.add(G),O});},[]),A=c??Math.max(96,_.length*30+44),V=useMemo(()=>_.map(G=>({...G.datum,__change:G.change})),[_]),Y=m===void 0?n.length>=2:m!==false,X=typeof m=="string"?m:"bottom";return jsx(ut,{title:y,description:z,height:A,width:d,size:u,loading:h,empty:_.length===0||H.length===0,emptyState:R,tableView:v,legendPosition:X,legend:Y?jsx($t,{items:Or(D),position:X,marker:"dot",size:u,onToggle:p?F:void 0}):void 0,table:v?jsx(It,{data:V,series:[...D,...k?[{key:"__change",label:E??T.chartChange}]:[]],xKey:t.key,xLabel:t.label??t.key,formatX:B,formatValue:S,caption:typeof y=="string"?y:void 0}):void 0,className:W,...M,children:({width:G})=>jsx(kf,{width:G,height:A,data:_.map(j=>j.datum),rows:_,resolvedSeries:D,x:t,y:r,grid:b,size:u,showValues:s,dotSize:l,referenceLines:i,margin:f,tooltip:C,plotLabel:L,formatValue:S,formatX:B,onRowClick:w})})}var Rf=8,Tf=12,Pf=44,Bi="text-right [font-variant-numeric:tabular-nums]",Ef=memo(function({stages:t}){return jsx("g",{children:t.map(r=>jsxs("g",{children:[jsx("path",{d:r.d,fill:r.color}),r.value?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?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 Df({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:b,onStageClick:m}){let[p,C]=useState(null),v=Ge(),k=useMemo(()=>{let f=r.map(x=>x.label),N={top:6,right:12,bottom:6,left:n.hidden?8:n.height??kr(f)+Tf},L=Math.max(0,e-N.left-N.right),E=Math.max(0,t-N.top-N.bottom),I=hn(r.map((x,D)=>D),[0,E],{paddingInner:s?.45:.28}),w=Math.min(i??Pf,I.bandwidth),W=Math.max(0,...r.map(x=>x.value??0)),M=Dr([0,W],[0,L]),T=r.map((x,D)=>{let S=x.value===null?0:Math.max(0,M(x.value)),B=a==="center"?(L-S)/2:0,H=I(D)+(I.bandwidth-w)/2,$=H+w/2,_=null;if(l&&x.value!==null){let V=x.formattedValue;_=vr(V,11)+16<=S?{x:B+S/2,y:$,anchor:"middle",text:V,inside:true,onDark:c.onDark(D)}:{x:B+S+Rf,y:$,anchor:"start",text:V,inside:false,onDark:false};}let F=I(D-1)+(I.bandwidth-w)/2+w,A=s&&x.conversion!==null&&D>0?{x:L/2,y:(F+H)/2,text:Gt(x.conversion,{locale:b,maximumFractionDigits:0})}:null;return {key:`${D}`,d:ir({x:B,y:H,width:S,height:w,radius:4,round:a==="center"?"none":"right"}),color:c(D),value:_,conversion:A,top:I(D),height:I.bandwidth}}),P=n.hidden?[]:r.map((x,D)=>({value:x.x,offset:I.center(D),label:x.label}));return {margin:N,innerWidth:L,innerHeight:E,rendered:T,stageTicks:P,centers:r.map((x,D)=>I.center(D))}},[r,n,e,t,a,s,l,i,c,b]),y=useCallback(f=>{if(d===false||r.length===0)return;let N=f.currentTarget.getBoundingClientRect(),L=f.clientY-N.top-k.margin.top;C(Wt(k.centers,L));},[d,r.length,k.margin.top,k.centers]),z=useCallback(f=>{if(r.length===0)return;let N=r.length-1,L=p??0,E=f.key==="ArrowDown"?Math.min(N,L+1):f.key==="ArrowUp"?Math.max(0,L-1):f.key==="Home"?0:f.key==="End"?N:f.key==="Escape"?null:void 0;E!==void 0&&(f.preventDefault(),C(E));},[r.length,p]),h=useCallback(()=>{!m||p===null||m(r[p]);},[m,p,r]),R=p===null?null:r[p];return jsxs(Fragment,{children:[jsxs("svg",{width:e,height:t,role:"img","aria-label":u??r.map(f=>f.label).join(", "),tabIndex:0,className:"touch-none focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-blue-500",onPointerMove:y,onPointerLeave:()=>C(null),onKeyDown:z,onBlur:()=>C(null),onClick:h,children:[jsxs("g",{transform:`translate(${k.margin.left}, ${k.margin.top})`,children:[p!==null&&k.rendered[p]?jsx("rect",{x:-4,y:k.rendered[p].top,width:k.innerWidth+8,height:k.rendered[p].height,rx:4,className:"fill-gray-400 dark:fill-gray-500",opacity:.12,"aria-hidden":"true"}):null,jsx(Ef,{stages:k.rendered})]}),jsx("g",{transform:`translate(${k.margin.left}, ${k.margin.top})`,children:n.hidden?null:jsx(_e,{orientation:"left",ticks:k.stageTicks,length:k.innerHeight,showLine:false,tickSize:0,size:o})})]}),R&&p!==null&&d!==false?jsx(gt,{x:k.margin.left+k.innerWidth/2,y:k.margin.top+k.centers[p],containerWidth:e,children:typeof d=="function"?d(R):jsxs("div",{className:"flex flex-col gap-1",children:[jsx("div",{className:"font-medium text-gray-900 dark:text-gray-100",children:R.label}),jsxs("div",{className:"flex items-center gap-2",children:[jsx("span",{className:"h-2.5 w-2.5 shrink-0 rounded-sm",style:{backgroundColor:k.rendered[p]?.color},"aria-hidden":"true"}),jsx("span",{className:"font-semibold text-gray-900 [font-variant-numeric:tabular-nums] dark:text-gray-100",children:R.formattedValue})]}),R.conversion!==null?jsxs("div",{className:"flex items-center gap-2 text-gray-500 dark:text-gray-400",children:[jsx("span",{children:v.chartConversion}),jsx("span",{className:"[font-variant-numeric:tabular-nums]",children:Gt(R.conversion,{locale:b,maximumFractionDigits:1})})]}):null,R.overall!==null?jsxs("div",{className:"flex items-center gap-2 text-gray-500 dark:text-gray-400",children:[jsx("span",{children:r[0]?.label}),jsx("span",{className:"[font-variant-numeric:tabular-nums]",children:Gt(R.overall,{locale:b,maximumFractionDigits:1})})]}):null]})}):null]})}function Lf({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:b=false,title:m,description:p,loading:C=false,emptyState:v,locale:k,plotLabel:y,valueLabel:z,conversionLabel:h,dropOffLabel:R,format:f,onStageClick:N,className:L,...E}){let I=Ge(),w=useMemo(()=>f??(x=>rt(x,k)),[f,k]),W=useMemo(()=>t.format??(x=>Ke(x,k)),[t.format,k]),M=useMemo(()=>{let x=Ee(e[0]??{},r);return e.map((D,S)=>{let B=mt(D,t.key,S),H=Ee(D,r),$=S===0?null:Ee(e[S-1],r);return {index:S,x:B,label:W(B,S),value:H,overall:S===0||x===null||x===0||H===null?null:H/x,conversion:$===null||$===0||H===null?null:H/$,dropOff:$===null||H===null?null:$-H,formattedValue:H===null?"\u2014":w(H),datum:D}})},[e,t.key,r,w,W]),T=useMemo(()=>ca([0,Math.max(1,M.length-1)],{colors:l??ia,...l?{}:{darkStops:fi}}),[M.length,l]),P=i??Math.max(96,M.length*(o?56:44)+12);return jsx(ut,{title:m,description:p,height:P,width:c,size:d,loading:C,empty:M.length===0,emptyState:v,tableView:b,table:b?jsx("div",{className:"w-full overflow-x-auto",children:jsxs(gn,{children:[typeof m=="string"?jsx("caption",{className:"sr-only",children:m}):null,jsxs(fn,{children:[jsx(Nt,{children:t.label??t.key}),jsx(Nt,{className:"text-right",children:z??I.chartValue}),jsx(Nt,{className:"text-right",children:h??I.chartConversion}),jsx(Nt,{className:"text-right",children:R??I.chartDropOff})]}),jsx(pn,{children:M.map(x=>jsxs(bn,{clickable:false,children:[jsx(_t,{className:"font-medium text-gray-900 dark:text-gray-100",children:x.label}),jsx(_t,{className:Bi,children:x.formattedValue}),jsx(_t,{className:Bi,children:x.conversion===null?"\u2014":Gt(x.conversion,{locale:k,maximumFractionDigits:1})}),jsx(_t,{className:Bi,children:x.dropOff===null?"\u2014":w(x.dropOff)})]},x.index))})]})}):void 0,className:L,...E,children:({width:x})=>jsx(Df,{width:x,height:P,stages:M,x:t,size:d,align:n,showConversion:o,showValues:a,stageSize:s,ramp:T,tooltip:u,plotLabel:y,locale:k,onStageClick:N})})}var zf=18,td=.5,Wf=.3,gs=7,rd=10,nd=.02,Fi="text-right [font-variant-numeric:tabular-nums]",Hf=memo(function({tasks:t,arrows:r}){return jsxs("g",{children:[jsx("g",{className:"fill-gray-400 stroke-gray-400 dark:fill-gray-500 dark:stroke-gray-500",children:r.map(n=>jsxs("g",{children:[jsx("path",{d:n.d,fill:"none",strokeWidth:1}),jsx("path",{d:n.head,strokeWidth:0})]},n.key))}),t.map(n=>jsxs("g",{children:[n.track?jsx("path",{d:n.track,fill:n.color,fillOpacity:n.trackOpacity}):null,n.progress?jsx("path",{d:n.progress,fill:n.color}):null,n.milestone?jsx("path",{d:n.milestone,fill:n.color,strokeWidth:2,className:"stroke-white dark:stroke-gray-800"}):null]},n.key))]})});function Vf({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:b,margin:m,tooltip:p,plotLabel:C,todayLabel:v,locale:k,formatDate:y,formatX:z,onTaskClick:h}){let[R,f]=useState(null),N=Ge(),L=useMemo(()=>{let M=Qt({width:e,height:t,data:r,x:o,y:{domain:a},bounds:a,margin:m,orientation:"horizontal",placement:"band",formatValue:A=>us(A,s,k),formatX:z}),{valueScale:T,bandwidth:P,categoryPositions:x,innerWidth:D,innerHeight:S}=M,B=Math.min(u??zf,P),H=new Map(n.map((A,V)=>[A.id,V])),$=n.map((A,V)=>{let Y=x[V]+(P-B)/2,X=Y+B/2,G=b(A);if(A.start===null)return {key:`${V}`,color:G,track:null,trackOpacity:1,progress:null,milestone:null,top:x[V],height:P};let j=T(A.start);if(A.milestone)return {key:`${V}`,color:G,track:null,trackOpacity:1,progress:null,milestone:`M${j},${X-gs} L${j+gs},${X} L${j},${X+gs} L${j-gs},${X} Z`,top:x[V],height:P};let O=T(A.end??A.start),K=Math.max(2,O-j);return {key:`${V}`,color:G,track:ir({x:j,y:Y,width:K,height:B,radius:3}),trackOpacity:A.progress===null?1:Wf,progress:A.progress===null?null:ir({x:j,y:X-B*td/2,width:Math.max(0,K*Math.min(1,Math.max(0,A.progress))),height:B*td,radius:2,round:"right"}),milestone:null,top:x[V],height:P}}),_=[];n.forEach((A,V)=>{if(A.start!==null)for(let Y of A.dependsOn){let X=H.get(Y);if(X===void 0||X===V)continue;let G=n[X];if(G.start===null)continue;let j=T(G.end??G.start),O=x[X]+P/2,K=T(A.start),se=x[V]+P/2,ae=Math.max(j+rd,K-rd);_.push({key:`${Y}-${A.id}`,d:`M${j},${O} L${ae},${O} L${ae},${se} L${K-5},${se}`,head:`M${K},${se} L${K-5},${se-3.5} L${K-5},${se+3.5} Z`});}});let F=l.map(A=>({value:A,offset:T(A),label:us(A,s,k)}));return {rendered:$,arrows:_,categoryPositions:x,categoryCenters:M.categoryCenters,bandwidth:P,categoryTicks:M.categoryTicks,valueTicks:F,valueScale:T,innerWidth:D,innerHeight:S,margin:M.margin}},[n,r,o,a,s,l,e,t,m,u,b,k,z]),E=useCallback(M=>{if(p===false||n.length===0)return;let T=M.currentTarget.getBoundingClientRect(),P=M.clientY-T.top-L.margin.top;f(Wt(L.categoryCenters,P));},[p,n.length,L.margin.top,L.categoryCenters]),I=useCallback(M=>{if(n.length===0)return;let T=n.length-1,P=R??0,x=M.key==="ArrowDown"?Math.min(T,P+1):M.key==="ArrowUp"?Math.max(0,P-1):M.key==="Home"?0:M.key==="End"?T:M.key==="Escape"?null:void 0;x!==void 0&&(M.preventDefault(),f(x));},[n.length,R]),w=useCallback(()=>{!h||R===null||h(n[R]);},[h,R,n]),W=R===null?null:n[R];return jsxs(Fragment,{children:[jsxs("svg",{width:e,height:t,role:"img","aria-label":C??n.map(M=>M.label).join(", "),tabIndex:0,className:"touch-none focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-blue-500",onPointerMove:E,onPointerLeave:()=>f(null),onKeyDown:I,onBlur:()=>f(null),onClick:w,children:[jsxs("g",{transform:`translate(${L.margin.left}, ${L.margin.top})`,children:[jsx(Ot,{width:L.innerWidth,height:L.innerHeight,vertical:c?L.valueTicks.map(M=>M.offset):void 0}),R!==null?jsx("rect",{x:0,y:L.categoryPositions[R],width:L.innerWidth,height:L.bandwidth,className:"fill-gray-400 dark:fill-gray-500",opacity:.12,"aria-hidden":"true"}):null,jsx(Hf,{tasks:L.rendered,arrows:L.arrows}),i!==null?jsxs("g",{children:[jsx("line",{x1:L.valueScale(i),y1:0,x2:L.valueScale(i),y2:L.innerHeight,className:"stroke-gray-900 dark:stroke-white",strokeWidth:1,strokeDasharray:"4 4"}),jsx("text",{x:L.valueScale(i)+4,y:8,className:"fill-gray-500 text-[10px] dark:fill-gray-400",children:v})]}):null]}),jsx("g",{transform:`translate(${L.margin.left}, ${L.margin.top+L.innerHeight})`,children:jsx(_e,{orientation:"bottom",ticks:L.valueTicks,length:L.innerWidth,size:d})}),jsx("g",{transform:`translate(${L.margin.left}, ${L.margin.top})`,children:o.hidden?null:jsx(_e,{orientation:"left",ticks:L.categoryTicks,length:L.innerHeight,showLine:false,tickSize:0,label:o.label,size:d})})]}),W&&R!==null&&p!==false?jsx(gt,{x:L.margin.left+(W.start===null?L.innerWidth/2:L.valueScale(W.start)),y:L.margin.top+L.categoryCenters[R],containerWidth:e,children:typeof p=="function"?p(W):jsxs("div",{className:"flex flex-col gap-1",children:[jsx("div",{className:"font-medium text-gray-900 dark:text-gray-100",children:W.label}),jsxs("div",{className:"flex items-center gap-2 text-gray-500 dark:text-gray-400",children:[jsx("span",{children:N.chartStart}),jsx("span",{className:"[font-variant-numeric:tabular-nums] text-gray-900 dark:text-gray-100",children:W.start===null?"\u2014":y(W.start)})]}),W.milestone?null:jsxs("div",{className:"flex items-center gap-2 text-gray-500 dark:text-gray-400",children:[jsx("span",{children:N.chartEnd}),jsx("span",{className:"[font-variant-numeric:tabular-nums] text-gray-900 dark:text-gray-100",children:W.end===null?"\u2014":y(W.end)})]}),W.progress===null?null:jsxs("div",{className:"flex items-center gap-2 text-gray-500 dark:text-gray-400",children:[jsx("span",{children:N.chartProgress}),jsx("span",{className:"[font-variant-numeric:tabular-nums] text-gray-900 dark:text-gray-100",children:Gt(W.progress,{locale:k,maximumFractionDigits:0})})]})]})}):null]})}function Bf({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:b,rowSize:m=30,color:p,height:C,width:v,size:k="md",grid:y=true,legend:z,tooltip:h=true,tableView:R=false,title:f,description:N,loading:L=false,emptyState:E,margin:I,locale:w,plotLabel:W,startLabel:M,endLabel:T,progressLabel:P,todayLabel:x,formatDate:D,onTaskClick:S,className:B,...H}){let $=Ge(),_=useMemo(()=>t.format??(U=>Ke(U,w)),[t.format,w]),F=useMemo(()=>e.map((U,J)=>{let te=mt(U,t.key,J),ie=to(U[r]),Q=n?to(U[n]):null,ge=s?!!U[s]:Q===null,Re=l?U[l]:void 0;return {index:J,id:String(o?U[o]??J:J),x:te,label:_(te,J),start:ie,end:ge?ie:Q??ie,progress:a?Ee(U,a):null,milestone:ge,dependsOn:Array.isArray(Re)?Re.map(Qe=>String(Qe)):[],group:i?U[i]??null:null,datum:U}}),[e,t.key,r,n,o,a,s,l,i,_]),A=useMemo(()=>{let U=[];for(let J of F)J.group!==null&&!U.includes(J.group)&&U.push(J.group);return U},[F]),V=useCallback(U=>U.group===null?p??Pr(0):Pr(A.indexOf(U.group)),[A,p]),Y=useMemo(()=>{if(c){let Q=to(c[0]),ge=to(c[1]);if(Q!==null&&ge!==null)return [Q,ge]}let U=F.flatMap(Q=>Q.start===null?[]:[Q.start,Q.end??Q.start]);if(U.length===0)return [0,1];let J=Math.min(...U),te=Math.max(...U),ie=te-J||864e5;return [J-ie*nd,te+ie*nd]},[c,F]),X=useMemo(()=>Wi(Y[0],Y[1],u),[Y,u]),G=useMemo(()=>D??(U=>new Intl.DateTimeFormat(w,{day:"numeric",month:"short",year:"numeric"}).format(new Date(U))),[D,w]),j=useMemo(()=>d===false?null:to(d??Date.now()),[d]),O=useMemo(()=>A.map((U,J)=>({key:U,label:U,color:Pr(J),marker:"rect"})),[A]),K=C??Math.max(120,F.length*m+48),se=z===void 0?A.length>=2:z!==false,ae=typeof z=="string"?z:"bottom";return jsx(ut,{title:f,description:N,height:K,width:v,size:k,loading:L,empty:F.length===0,emptyState:E,tableView:R,legendPosition:ae,legend:se&&O.length>0?jsx($t,{items:O,position:ae,marker:"rect",size:k}):void 0,table:R?jsx("div",{className:"w-full overflow-x-auto",children:jsxs(gn,{children:[typeof f=="string"?jsx("caption",{className:"sr-only",children:f}):null,jsxs(fn,{children:[jsx(Nt,{children:t.label??t.key}),jsx(Nt,{className:"text-right",children:M??$.chartStart}),jsx(Nt,{className:"text-right",children:T??$.chartEnd}),a?jsx(Nt,{className:"text-right",children:P??$.chartProgress}):null]}),jsx(pn,{children:F.map(U=>jsxs(bn,{clickable:false,children:[jsx(_t,{className:"font-medium text-gray-900 dark:text-gray-100",children:U.label}),jsx(_t,{className:Fi,children:U.start===null?"\u2014":G(U.start)}),jsx(_t,{className:Fi,children:U.milestone||U.end===null?"\u2014":G(U.end)}),a?jsx(_t,{className:Fi,children:U.progress===null?"\u2014":Gt(U.progress,{locale:w,maximumFractionDigits:0})}):null]},U.index))})]})}):void 0,className:B,...H,children:({width:U})=>jsx(Vf,{width:U,height:K,data:e,tasks:F,x:t,domain:Y,unit:X.unit,timeTicks:X.values,today:j,grid:y,size:k,barSize:b,colorOf:V,margin:I,tooltip:h,plotLabel:W,todayLabel:x??$.chartToday,locale:w,formatDate:G,formatX:_,onTaskClick:S})})}var _f=24,Xf=4,zo=6,Gf=ko(Yn,1),Kf=ko(Yn,0),Uf=memo(function({bars:t,connectors:r}){return jsxs("g",{children:[jsx("g",{className:"stroke-gray-300 dark:stroke-gray-600",strokeWidth:1,shapeRendering:"crispEdges","aria-hidden":"true",children:r.map(n=>jsx("line",{x1:n.x1,y1:n.y1,x2:n.x2,y2:n.y2},n.key))}),t.map(n=>jsxs("g",{children:[jsx("path",{d:n.d,fill:n.color}),n.label?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 Yf({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:b,margin:m,tooltip:p,plotLabel:C,totalLabel:v,formatValue:k,formatX:y,onStepClick:z}){let[h,R]=useState(null),f=useMemo(()=>{let W=i==="vertical",M=r.flatMap(A=>[A.start,A.end]),T=Qt({width:e,height:t,data:n,x:o,y:a,bounds:M.length===0?null:[Math.min(...M),Math.max(...M)],margin:m,orientation:i,placement:"band",formatValue:k,formatX:y,defaultIncludeZero:true}),{valueScale:P,bandwidth:x,categoryPositions:D,innerWidth:S,innerHeight:B}=T,H=P(0),$=Math.min(u??_f,x),_=[],F=[];return r.forEach((A,V)=>{let Y=D[V]+(x-$)/2,X=P(A.start),G=P(A.end),j=Math.min(X,G),O=Math.abs(G-X),K=A.end>=A.start,se=W?K?"top":"bottom":K?"right":"left",ae=W?{x:Y,y:j,width:$,height:O}:{x:j,y:Y,width:O,height:$},U=null;if(d&&A.value!==null){let te=A.kind==="total"?A.formattedEnd:A.formattedValue,ie=vr(te,10),Q=P(K?Math.max(A.start,A.end):Math.min(A.start,A.end));if(W){let ge=K?Q-zo:Q+zo;ie<=x&&ge>8&&ge<B-4&&(U={x:Y+$/2,y:ge,anchor:"middle",text:te});}else {let ge=K?S-Q-zo:Q-zo;ie<=ge&&(U={x:K?Q+zo:Q-zo,y:Y+$/2,anchor:K?"start":"end",text:te});}}_.push({key:`${V}`,color:b[A.kind],d:ir({...ae,radius:Xf,round:se}),label:U});let J=r[V+1];if(c&&J){let te=P(A.end),ie=D[V+1]+(x-$)/2;F.push(W?{key:`${V}`,x1:Y+$,y1:te,x2:ie,y2:te}:{key:`${V}`,x1:te,y1:Y+$,x2:te,y2:ie});}}),{vertical:W,bars:_,rules:F,baseline:H,bandwidth:x,categoryPositions:D,categoryCenters:T.categoryCenters,categoryTicks:T.categoryTicks,valueTicks:T.valueTicks,valueScale:P,innerWidth:S,innerHeight:B,margin:T.margin}},[r,n,o,a,e,t,m,i,c,d,u,b,k,y]),N=useCallback(W=>{if(p===false||r.length===0)return;let M=W.currentTarget.getBoundingClientRect(),T=f.vertical?W.clientX-M.left-f.margin.left:W.clientY-M.top-f.margin.top;R(Wt(f.categoryCenters,T));},[p,r.length,f.vertical,f.margin,f.categoryCenters]),L=useCallback(W=>{if(r.length===0)return;let M=r.length-1,T=h??0,P=f.vertical?"ArrowRight":"ArrowDown",x=f.vertical?"ArrowLeft":"ArrowUp",D=W.key===P?Math.min(M,T+1):W.key===x?Math.max(0,T-1):W.key==="Home"?0:W.key==="End"?M:W.key==="Escape"?null:void 0;D!==void 0&&(W.preventDefault(),R(D));},[r.length,h,f.vertical]),E=useCallback(()=>{!z||h===null||z(r[h]);},[z,h,r]),I=h===null?null:r[h],w=h===null||I===void 0||I===null?null:f.vertical?{x:f.margin.left+f.categoryCenters[h],y:f.margin.top+Math.min(f.valueScale(I.start),f.valueScale(I.end))}:{x:f.margin.left+Math.max(f.valueScale(I.start),f.valueScale(I.end)),y:f.margin.top+f.categoryCenters[h]};return jsxs(Fragment,{children:[jsxs("svg",{width:e,height:t,role:"img","aria-label":C??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:N,onPointerLeave:()=>R(null),onKeyDown:L,onBlur:()=>R(null),onClick:E,children:[jsxs("g",{transform:`translate(${f.margin.left}, ${f.margin.top})`,children:[jsx(Ot,{width:f.innerWidth,height:f.innerHeight,horizontal:f.vertical&&(s==="y"||s==="both")?f.valueTicks.map(W=>W.offset):void 0,vertical:!f.vertical&&(s==="y"||s==="both")?f.valueTicks.map(W=>W.offset):void 0}),h!==null?jsx("rect",{x:f.vertical?f.categoryPositions[h]:0,y:f.vertical?0:f.categoryPositions[h],width:f.vertical?f.bandwidth:f.innerWidth,height:f.vertical?f.innerHeight:f.bandwidth,className:"fill-gray-400 dark:fill-gray-500",opacity:.12,"aria-hidden":"true"}):null,jsx(Uf,{bars:f.bars,connectors:f.rules}),jsx("line",{x1:f.vertical?0:f.baseline,y1:f.vertical?f.baseline:0,x2:f.vertical?f.innerWidth:f.baseline,y2:f.vertical?f.baseline:f.innerHeight,className:"stroke-gray-300 dark:stroke-gray-600",strokeWidth:1,shapeRendering:"crispEdges"})]}),jsx("g",{transform:`translate(${f.margin.left}, ${f.margin.top+f.innerHeight})`,children:(f.vertical?o.hidden:a?.hidden)?null:jsx(_e,{orientation:"bottom",ticks:f.vertical?f.categoryTicks:f.valueTicks,length:f.innerWidth,label:f.vertical?o.label:a?.label,size:l})}),jsx("g",{transform:`translate(${f.margin.left}, ${f.margin.top})`,children:(f.vertical?a?.hidden:o.hidden)?null:jsx(_e,{orientation:"left",ticks:f.vertical?f.valueTicks:f.categoryTicks,length:f.innerHeight,showLine:false,label:f.vertical?a?.label:o.label,size:l})})]}),I&&w&&p!==false?jsx(gt,{x:w.x,y:w.y,containerWidth:e,children:typeof p=="function"?p(I):jsxs("div",{className:"flex flex-col gap-1",children:[jsx("div",{className:"font-medium text-gray-900 dark:text-gray-100",children:I.label}),jsxs("div",{className:"flex items-center gap-2",children:[jsx("span",{className:"h-2.5 w-2.5 shrink-0 rounded-sm",style:{backgroundColor:b[I.kind]},"aria-hidden":"true"}),jsx("span",{className:"font-semibold text-gray-900 [font-variant-numeric:tabular-nums] dark:text-gray-100",children:I.kind==="total"?I.formattedEnd:I.formattedValue})]}),I.kind==="total"?null:jsxs("div",{className:"flex items-center gap-2 text-gray-500 dark:text-gray-400",children:[jsx("span",{children:v}),jsx("span",{className:"[font-variant-numeric:tabular-nums]",children:I.formattedEnd})]})]})}):null]})}function qf({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:b,size:m="md",grid:p="y",legend:C,tooltip:v=true,tableView:k=false,title:y,description:z,loading:h=false,emptyState:R,margin:f,locale:N,plotLabel:L,valueLabel:E,totalLabel:I,increaseLabel:w,decreaseLabel:W,format:M,onStepClick:T,className:P,...x}){let D=Ge(),S=useMemo(()=>M??(X=>rt(X,N)),[M,N]),B=useMemo(()=>t.format??(X=>Ke(X,N)),[t.format,N]),H=useMemo(()=>{let X=a;return e.map((G,j)=>{let O=mt(G,t.key,j),K=Ee(G,n);if(o?!!G[o]:false){let J=K??X;return X=J,{index:j,x:O,label:B(O,j),value:J,start:0,end:J,kind:"total",formattedValue:S(J),formattedEnd:S(J),datum:G}}let ae=X,U=K===null?X:X+K;return X=U,{index:j,x:O,label:B(O,j),value:K,start:ae,end:U,kind:K!==null&&K<0?"decrease":"increase",formattedValue:K===null?"\u2014":`${K>0?"+":""}${S(K)}`,formattedEnd:S(U),datum:G}})},[e,t.key,n,o,a,S,B]),$=useMemo(()=>({increase:d?.increase??Gf,decrease:d?.decrease??Kf,total:d?.total??Tr}),[d]),_=I??D.chartRunningTotal,F=useMemo(()=>{let X=[{key:"increase",label:w??D.chartIncrease,color:$.increase,marker:"rect"},{key:"decrease",label:W??D.chartDecrease,color:$.decrease,marker:"rect"}];return H.some(G=>G.kind==="total")&&X.push({key:"total",label:_,color:$.total,marker:"rect"}),X},[$,H,w,W,_,D.chartIncrease,D.chartDecrease]),A=useMemo(()=>H.map(X=>({[t.key]:X.x,[n]:X.kind==="total"?null:X.value,__running:X.end})),[H,t.key,n]),V=C===void 0?true:C!==false,Y=typeof C=="string"?C:"bottom";return jsx(ut,{title:y,description:z,height:u,width:b,size:m,loading:h,empty:H.length===0,emptyState:R,tableView:k,legendPosition:Y,legend:V?jsx($t,{items:F,position:Y,marker:"rect",size:m}):void 0,table:k?jsx(It,{data:A,series:[{key:n,label:E??D.chartValue},{key:"__running",label:_}],xKey:t.key,xLabel:t.label??t.key,formatX:B,formatValue:S,caption:typeof y=="string"?y:void 0}):void 0,className:P,...x,children:({width:X})=>jsx(Yf,{width:X,height:u,steps:H,data:e,x:t,y:r,grid:p,size:m,orientation:s,connectors:l,showValues:i,barSize:c,palette:$,margin:f,tooltip:v,plotLabel:L,totalLabel:_,formatValue:S,formatX:B,onStepClick:T})})}var rb=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"}}},nb=e=>{switch(e){case "circle":return "rounded-full";case "rounded":return "rounded-md";default:return "rounded"}},ob=({className:e})=>jsx("svg",{className:e,viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:jsx("path",{d:"M13.5 4.5L6 12L2.5 8.5",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round"})}),ab=({className:e})=>jsx("svg",{className:e,viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:jsx("path",{d:"M3 8H13",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round"})}),ka=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:b="md",labelPosition:m="right",checkedColor:p="bg-blue-600",uncheckedColor:C="bg-white dark:bg-gray-800",borderColor:v="border-gray-300 dark:border-gray-600",labelColor:k,errorColor:y="text-red-500",checkmarkColor:z="text-white",hoverColor:h,focusRingColor:R="ring-blue-500",indeterminate:f=false,icon:N,variant:L="default",shape:E="square",animation:I=true,showFocusRing:w=true,className:W,containerClassName:M,style:T,tabIndex:P,...x},D)=>{let S=useId(),B=i||S,H=`${B}-error`,$=`${B}-description`,[_,F]=useState(t),A=e!==void 0,V=A?e:_,Y=useRef(null);useEffect(()=>{Y.current&&(Y.current.indeterminate=f);},[f]);let X=ae=>{if(n||o)return;let U=ae.target.checked;A||F(U),r?.(U,ae);},G=rb(b),j=nb(E),O=()=>{let ae=g("relative flex items-center justify-center border-2 transition-all",G.checkbox,j,I&&"duration-200 ease-in-out");return n?g(ae,"opacity-50 cursor-not-allowed",V||f?p:C,v):L==="filled"?g(ae,V||f?p:"bg-gray-100 dark:bg-gray-700",V||f?"border-transparent":v,h&&!o&&`hover:${h}`,"cursor-pointer"):L==="outlined"?g(ae,C,V||f?`border-current ${p.replace("bg-","text-")}`:v,"border-2",h&&!o&&`hover:${h}`,"cursor-pointer"):g(ae,V||f?p:C,V||f?"border-transparent":v,h&&!o&&`hover:${h}`,"cursor-pointer")},K=u!==false,se=typeof u=="string"?u:void 0;return jsxs("div",{className:g("inline-flex flex-col",M),children:[jsxs("label",{htmlFor:B,className:g("inline-flex items-start gap-2",n?"cursor-not-allowed":"cursor-pointer",m==="left"&&"flex-row-reverse justify-end"),children:[jsx("input",{ref:ae=>{Y&&(Y.current=ae),typeof D=="function"?D(ae):D&&(D.current=ae);},type:"checkbox",id:B,name:s,value:l,checked:V,onChange:X,disabled:n,readOnly:o,required:a,tabIndex:o?-1:P,"aria-invalid":K,"aria-describedby":g(se&&H,d&&$),className:"sr-only peer",style:T,...x}),jsx("span",{className:g(O(),w&&`peer-focus-visible:ring-2 peer-focus-visible:ring-offset-2 peer-focus-visible:${R}`,I&&V&&"scale-100",K&&"border-red-500"),"aria-hidden":"true",children:(V||f)&&jsx("span",{className:g(z,I&&"animate-in zoom-in-50 duration-200"),children:f?N||jsx(ab,{className:"w-full h-full"}):N||jsx(ob,{className:"w-full h-full"})})}),c&&jsxs("span",{className:"flex flex-col gap-1",children:[jsxs("span",{className:g(G.label,n&&"opacity-50",k,K&&y),children:[c,a&&jsx("span",{className:"text-red-500 ml-1",children:"*"})]}),d&&jsx("span",{id:$,className:g(G.description,"text-gray-500 dark:text-gray-400",n&&"opacity-50"),children:d})]})]}),se&&jsx("p",{id:H,className:g("mt-1 text-xs",y),children:se})]})});ka.displayName="Checkbox";var od=createContext(null),ad=({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:b,labelClassName:m,...p})=>{let[C,v]=Ri.useState(n),k=r!==void 0,y=k?r:C,z=Ri.useCallback(L=>{let E=y.includes(L)?y.filter(I=>I!==L):[...y,L];k||v(E),o?.(E);},[y,k,o]),h=Ri.useMemo(()=>({value:y,onChange:z,disabled:l,size:i}),[y,z,l,i]),R={sm:a==="vertical"?"gap-2":"gap-3",md:a==="vertical"?"gap-3":"gap-4",lg:a==="vertical"?"gap-4":"gap-6"},f=c!==false,N=typeof c=="string"?c:void 0;return jsxs("div",{className:g("flex flex-col gap-2",b),...p,children:[(e||t)&&jsxs("div",{className:"flex flex-col gap-1",children:[e&&jsxs("label",{className:g("text-sm font-medium text-gray-900 dark:text-gray-100",l&&"opacity-50",f&&"text-red-500",m),children:[e,d&&jsx("span",{className:"text-red-500 ml-1",children:"*"})]}),t&&jsx("p",{className:g("text-xs text-gray-500 dark:text-gray-400",l&&"opacity-50"),children:t})]}),jsx(od.Provider,{value:h,children:jsx("div",{className:g("flex",a==="vertical"?"flex-col":"flex-row flex-wrap",R[s]),role:"group",children:u})}),N&&jsx("p",{className:"text-xs text-red-500",children:N})]})};ad.displayName="CheckboxGroup";var sd=({value:e,disabled:t,size:r,...n})=>{let o=useContext(od);if(!o)return console.warn("CheckboxGroupItem doit \xEAtre utilis\xE9 dans un CheckboxGroup"),jsx(ka,{...n,disabled:t,size:r});let{value:a,onChange:s,disabled:l,size:i}=o,c=a.includes(e);return jsx(ka,{...n,checked:c,onChange:()=>s(e),disabled:l||t,size:r||i})};sd.displayName="CheckboxGroupItem";var lr={compact:"px-3 py-1.5",default:"px-4 py-3",comfortable:"px-6 py-4"},hs={compact:"text-xs",default:"text-sm",comfortable:"text-base"},ub=()=>jsx("svg",{className:"w-3.5 h-3.5",viewBox:"0 0 16 16",fill:"currentColor",children:jsx("path",{d:"M8 3l4 5H4l4-5z"})}),mb=()=>jsx("svg",{className:"w-3.5 h-3.5",viewBox:"0 0 16 16",fill:"currentColor",children:jsx("path",{d:"M8 13l4-5H4l4 5z"})}),gb=()=>jsx("svg",{className:"w-3.5 h-3.5 opacity-30",viewBox:"0 0 16 16",fill:"currentColor",children:jsx("path",{d:"M8 3l3 4H5l3-4zM8 13l3-4H5l3 4z"})}),id=({className:e})=>jsx("svg",{className:g("w-4 h-4",e),viewBox:"0 0 20 20",fill:"currentColor",children: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"})}),pb=()=>jsx("svg",{className:"w-4 h-4 text-gray-400",viewBox:"0 0 20 20",fill:"currentColor",children: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"})}),fb=()=>jsx("svg",{className:"w-4 h-4 text-gray-400",viewBox:"0 0 20 20",fill:"currentColor",children: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"})}),bb=()=>jsx("svg",{className:"w-3.5 h-3.5",viewBox:"0 0 20 20",fill:"currentColor",children: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"})}),hb=()=>jsxs("svg",{className:"w-4 h-4",viewBox:"0 0 20 20",fill:"currentColor",children:[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"}),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"})]}),yb=()=>jsx("svg",{className:"w-4 h-4",viewBox:"0 0 20 20",fill:"currentColor",children: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 bs(e,t,r){return typeof r=="function"?r(e,t):String(typeof r=="string"?e[r]:t)}function nn(e,t){return e[t]}function xb(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 vb(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 ld(e,t,r){let n=[];for(let o of e){let a=Number(nn(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 kb({cols:e,density:t}){return jsx("tr",{className:"border-b border-gray-200 dark:border-gray-700",children:Array.from({length:e}).map((r,n)=>jsx("td",{className:lr[t],children:jsx("div",{className:"h-4 bg-gray-200 dark:bg-gray-700 rounded animate-pulse"})},n))})}function Cb({column:e,value:t,onApply:r,onClear:n}){let[o,a]=useState(false),[s,l]=useState(t?.operator??"contains"),[i,c]=useState(t?.value??""),d=useRef(null),u=e.filterType??"text",b=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 useEffect(()=>{let m=p=>{d.current&&!d.current.contains(p.target)&&a(false);};return o&&document.addEventListener("mousedown",m),()=>document.removeEventListener("mousedown",m)},[o]),jsxs("div",{className:"relative inline-block",ref:d,children:[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:jsx(bb,{})}),o&&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?jsxs("div",{className:"flex flex-col gap-1.5",children:[e.filterOptions.map(m=>jsxs("label",{className:"flex items-center gap-2 text-sm cursor-pointer",children:[jsx("input",{type:"radio",name:`filter-${e.key}`,value:m,checked:i===m,onChange:()=>c(m),className:"cursor-pointer"}),jsx("span",{className:"text-gray-700 dark:text-gray-300",children:m})]},m)),jsxs("div",{className:"flex gap-2 mt-2",children:[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"}),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"})]})]}):jsxs("div",{className:"flex flex-col gap-2",children:[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:b.map(m=>jsx("option",{value:m.value,children:m.label},m.value))}),s!=="isEmpty"&&s!=="isNotEmpty"&&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`}),jsxs("div",{className:"flex gap-2",children:[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"}),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 wb({value:e,onSave:t,density:r}){let[n,o]=useState(false),[a,s]=useState(String(e??"")),l=useRef(null);if(useEffect(()=>{n&&l.current&&(l.current.focus(),l.current.select());},[n]),!n)return 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 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",hs[r])})}function Nb(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:b,onPageChange:m,onPageSizeChange:p,totalItems:C,selectable:v=false,selectionMode:k="multiple",selectedRows:y,onSelectionChange:z,searchable:h=false,searchPlaceholder:R="Search...",searchValue:f,onSearch:N,filters:L,onFilterChange:E,expandable:I=false,expandedContent:w,expandedRows:W,onExpandChange:M,editable:T=false,onCellEdit:P,reorderable:x=false,onReorder:D,columnReorderable:S=false,onColumnReorder:B,columnToggle:H=false,hiddenColumns:$,onColumnVisibilityChange:_,groupBy:F,renderGroupHeader:A,exportable:V=false,exportFormats:Y=["csv","json"],exportFilename:X="export",virtualized:G=false,rowHeight:j=40,virtualHeight:O=400,density:K="default",striped:se=false,bordered:ae=false,borderless:U=false,stickyHeader:J=false,maxHeight:te,loading:ie=false,loadingRows:Q=5,emptyState:ge,showFooter:Re=false,onRowClick:Qe,onRowDoubleClick:at,onRowContextMenu:et,className:me,rowClassName:ce,cellClassName:Oe,headerClassName:st}=e,[Pe,De]=useState(c??[]),[it,xt]=useState(1),[lt,pr]=useState(typeof u=="object"?u.pageSize??10:10),[tt,yr]=useState([]),[Wr,Bt]=useState(""),[ar,Rr]=useState([]),[ye,xe]=useState([]),[re,ne]=useState(()=>r.flatMap(q=>q.hidden?[q.key]:[])),[he,fe]=useState({}),[Te,Ce]=useState(()=>r.map(q=>q.key)),[we,Me]=useState(null),[Ae,bt]=useState(null),[ct,Ye]=useState(false),[er,vt]=useState(new Set),Hr=useRef(null),[mn,Kn]=useState(0),bo=useRef(null),Ur=i??Pe,Vr=b??it,Z=y??tt,oe=f??Wr,le=L??ar,de=W??ye,be=$??re,$e=u?typeof u=="object"?u:{pageSize:10,pageSizeOptions:[10,25,50,100]}:null,nt=$e?.pageSize??lt,qe=useMemo(()=>{let q=new Map(r.map(Se=>[Se.key,Se])),ee=Te.flatMap(Se=>{let He=q.get(Se);return He?[He]:[]}),pe=new Set(ee.map(Se=>Se.key));for(let Se of r)pe.has(Se.key)||(ee.push(Se),pe.add(Se.key));return ee.filter(Se=>!be.includes(Se.key))},[r,Te,be]),ze=useMemo(()=>{if(a==="server")return n;let q=[...n];if(oe){let ee=oe.toLowerCase();q=q.filter(pe=>qe.some(Se=>{let He=nn(pe,Se.key);return String(He??"").toLowerCase().includes(ee)}));}if(le.length>0&&(q=q.filter(ee=>le.every(pe=>vb(nn(ee,pe.column),pe)))),Ur.length>0){let ee=new Map(r.map(pe=>[pe.key,pe]));q.sort((pe,Se)=>{for(let He of Ur){if(!He.direction)continue;let Mt=ee.get(He.key),fr=Mt?.sortComparator?Mt.sortComparator(pe,Se):xb(nn(pe,He.key),nn(Se,He.key));if(fr!==0)return He.direction==="asc"?fr:-fr}return 0});}return q},[n,a,oe,le,Ur,qe,r]),tr=useMemo(()=>{if(!F)return null;let q=Array.isArray(F)?F:[F],ee=new Map;for(let pe of ze){let Se=q.map(Mt=>String(nn(pe,Mt)??"")).join(" / "),He=ee.get(Se)??[];He.push(pe),ee.set(Se,He);}return ee},[ze,F]),je=C??ze.length,Lt=Math.max(1,Math.ceil(je/nt)),Ft=useMemo(()=>{if(!$e||a==="server")return ze;let q=(Vr-1)*nt;return ze.slice(q,q+nt)},[ze,$e,Vr,nt,a]),kt=$e?Ft:ze,sr=useMemo(()=>{if(!G)return {start:0,end:kt.length};let q=Math.floor(mn/j),ee=Math.ceil(O/j),pe=5;return {start:Math.max(0,q-pe),end:Math.min(kt.length,q+ee+pe)}},[G,mn,j,O,kt.length]),Yr=useCallback(q=>{i||De(q),d?.(q);},[i,d]),qr=useCallback(q=>{let ee=Ur.find(Se=>Se.key===q),pe;if(!ee||!ee.direction?pe="asc":ee.direction==="asc"?pe="desc":pe=null,l){let Se=Ur.filter(He=>He.key!==q);pe&&Se.push({key:q,direction:pe}),Yr(Se);}else Yr(pe?[{key:q,direction:pe}]:[]);},[Ur,l,Yr]),xr=useCallback(q=>{let ee=Math.max(1,Math.min(q,Lt));b||xt(ee),m?.(ee);},[b,m,Lt]),ti=useCallback(q=>{pr(q),xr(1),p?.(q);},[xr,p]),Ya=useCallback(q=>{let ee;k==="single"?ee=Z.includes(q)?[]:[q]:ee=Z.includes(q)?Z.filter(pe=>pe!==q):[...Z,q],y||yr(ee),z?.(ee);},[k,Z,y,z]),ri=useCallback(()=>{let q=kt.map((ee,pe)=>bs(ee,pe,o));y||yr(q),z?.(q);},[kt,o,y,z]),ni=useCallback(()=>{y||yr([]),z?.([]);},[y,z]),oi=kt.length>0&&kt.every((q,ee)=>Z.includes(bs(q,ee,o))),Gm=!oi&&kt.some((q,ee)=>Z.includes(bs(q,ee,o))),Km=useCallback(q=>{let ee=de.includes(q)?de.filter(pe=>pe!==q):[...de,q];W||xe(ee),M?.(ee);},[de,W,M]),Um=useCallback(q=>{let ee=q.target.value;f||Bt(ee),N?.(ee),xr(1);},[f,N,xr]),Ym=useCallback(q=>{let ee=[...le.filter(pe=>pe.column!==q.column),q];L||Rr(ee),E?.(ee);},[le,L,E]),qm=useCallback(q=>{let ee=le.filter(pe=>pe.column!==q);L||Rr(ee),E?.(ee);},[le,L,E]),jm=useCallback(q=>{let ee=be.includes(q)?be.filter(pe=>pe!==q):[...be,q];$||ne(ee),_?.(ee);},[be,$,_]),Zm=useCallback((q,ee)=>{q.preventDefault(),q.stopPropagation();let pe=q.clientX,Se=he[ee]??q.currentTarget.parentElement?.getBoundingClientRect().width??100,He=r.find(br=>br.key===ee),Mt=He?.minWidth??50,fr=He?.maxWidth??1/0,dt=br=>{let Un=br.clientX-pe,Zr=Math.min(fr,Math.max(Mt,Se+Un));fe(yo=>({...yo,[ee]:Zr}));},jr=()=>{document.removeEventListener("mousemove",dt),document.removeEventListener("mouseup",jr);};document.addEventListener("mousemove",dt),document.addEventListener("mouseup",jr);},[he,r]),Qm=useCallback(q=>{x&&Me(q);},[x]),Jm=useCallback((q,ee)=>{!x||we===null||q.preventDefault();},[x,we]),eg=useCallback(q=>{!x||we===null||we===q||(D?.(we,q),Me(null));},[x,we,D]),tg=useCallback(q=>{S&&bt(q);},[S]),rg=useCallback(q=>{if(!S||!Ae||Ae===q)return;let ee=[...Te],pe=ee.indexOf(Ae),Se=ee.indexOf(q);pe===-1||Se===-1||(ee.splice(pe,1),ee.splice(Se,0,Ae),Ce(ee),B?.(Ae,q),bt(null));},[S,Ae,Te,B]),ai=useCallback(q=>{let ee=qe.filter(br=>br.type!=="actions"&&br.type!=="selection"&&br.type!=="expand"),pe=ze,Se,He,Mt;if(q==="csv"){let br=ee.map(Zr=>String(Zr.header)).join(","),Un=pe.map(Zr=>ee.map(yo=>{let li=String(nn(Zr,yo.key)??"");return li.includes(",")?`"${li}"`:li}).join(","));Se=[br,...Un].join(`
2
+ `),He="text/csv",Mt="csv";}else {let br=pe.map(Un=>{let Zr={};for(let yo of ee)Zr[yo.key]=nn(Un,yo.key);return Zr});Se=JSON.stringify(br,null,2),He="application/json",Mt="json";}let fr=new Blob([Se],{type:He}),dt=URL.createObjectURL(fr),jr=document.createElement("a");jr.href=dt,jr.download=`${X}.${Mt}`,jr.click(),URL.revokeObjectURL(dt);},[qe,ze,X]);useEffect(()=>{if(!ct)return;let q=ee=>{bo.current&&!bo.current.contains(ee.target)&&Ye(false);};return document.addEventListener("mousedown",q),()=>document.removeEventListener("mousedown",q)},[ct]),useImperativeHandle(t,()=>({getVisibleData:()=>kt,resetFilters:()=>{L||Rr([]),f||Bt(""),E?.([]),N?.("");},resetSort:()=>{i||De([]),d?.([]);},selectAll:ri,deselectAll:ni,exportData:ai,scrollToRow:q=>{Hr.current&&G&&(Hr.current.scrollTop=q*j);}}),[kt,L,f,i,E,N,d,ri,ni,ai,G,j]);let si=q=>{let ee={},pe=he[q.key]??q.width;return pe&&(ee.width=typeof pe=="number"?`${pe}px`:pe,ee.minWidth=typeof pe=="number"?`${pe}px`:pe),q.sticky&&(ee.position="sticky",ee[q.sticky]=0,ee.zIndex=10),ee},ho=qe.length+(v?1:0)+(I?1:0)+(x?1:0),ng=q=>{let ee=s&&q.sortable!==false&&q.type!=="actions",pe=Ur.find(He=>He.key===q.key),Se=q.filterable&&(q.filterType||q.filterOptions);return jsxs("th",{className:g(lr[K],hs[K],"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,st),style:si(q),onClick:ee?()=>qr(q.key):void 0,draggable:S,onDragStart:S?()=>tg(q.key):void 0,onDragOver:S?He=>He.preventDefault():void 0,onDrop:S?()=>rg(q.key):void 0,"aria-sort":pe?.direction==="asc"?"ascending":pe?.direction==="desc"?"descending":void 0,children:[jsxs("div",{className:"flex items-center gap-1",children:[q.renderHeader?q.renderHeader(q):q.header,ee&&jsx("span",{className:"inline-flex ml-1",children:pe?.direction==="asc"?jsx(ub,{}):pe?.direction==="desc"?jsx(mb,{}):jsx(gb,{})}),Se&&jsx(Cb,{column:q,value:le.find(He=>He.column===q.key),onApply:Ym,onClear:()=>qm(q.key)})]}),q.resizable!==false&&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:He=>Zm(He,q.key)})]},q.key)},ii=(q,ee,pe)=>{let Se=bs(q,pe,o),He=Z.includes(Se),Mt=de.includes(Se),fr=typeof ce=="function"?ce(q,pe):ce;return jsxs(Ri__default.Fragment,{children:[jsxs("tr",{className:g("border-b border-gray-200 dark:border-gray-700 transition-colors",se&&pe%2===1&&"bg-gray-50/50 dark:bg-gray-800/50",He&&"bg-blue-50 dark:bg-blue-900/20",Qe&&"cursor-pointer hover:bg-gray-50 dark:hover:bg-gray-700/50",we===ee&&"opacity-50",fr),onClick:Qe?()=>Qe(q,pe):void 0,onDoubleClick:at?()=>at(q,pe):void 0,onContextMenu:et?dt=>et(q,pe,dt):void 0,draggable:x,onDragStart:x?()=>Qm(ee):void 0,onDragOver:x?dt=>Jm(dt,ee):void 0,onDrop:x?()=>eg(ee):void 0,"data-row-key":Se,"aria-selected":v?He:void 0,children:[x&&jsx("td",{className:g(lr[K],"cursor-grab active:cursor-grabbing"),children:jsx(fb,{})}),v&&jsx("td",{className:g(lr[K],"w-10"),children:jsx("input",{type:"checkbox",checked:He,onChange:()=>Ya(Se),onClick:dt=>dt.stopPropagation(),className:"rounded border-gray-300 dark:border-gray-600 cursor-pointer","aria-label":`Select row ${Se}`})}),I&&jsx("td",{className:g(lr[K],"w-10"),children:jsx("button",{type:"button",onClick:dt=>{dt.stopPropagation(),Km(Se);},className:"p-0.5 rounded hover:bg-gray-200 dark:hover:bg-gray-600 cursor-pointer","aria-label":Mt?"Collapse row":"Expand row","aria-expanded":Mt,children:jsx(id,{className:g("transition-transform",Mt&&"rotate-180")})})}),qe.map(dt=>{let jr=nn(q,dt.key),br=dt.colSpan?.(q,pe);if(br===0)return null;let Un=T&&dt.editable!==false&&dt.type!=="actions";return jsx("td",{className:g(lr[K],hs[K],"text-gray-700 dark:text-gray-300",dt.align==="center"&&"text-center",dt.align==="right"&&"text-right",ae&&"border border-gray-200 dark:border-gray-700",dt.sticky&&(He?"bg-blue-50 dark:bg-blue-900/20":se&&pe%2===1?"bg-gray-50/50 dark:bg-gray-800/50":"bg-white dark:bg-gray-900"),dt.cellClassName,Oe),style:si(dt),colSpan:br,children:Un?jsx(wb,{value:jr,onSave:Zr=>P?.(Se,dt.key,Zr),density:K}):dt.render?dt.render(jr,q,pe):String(jr??"")},dt.key)})]}),I&&Mt&&w&&jsx("tr",{className:"bg-gray-50 dark:bg-gray-800/70",children:jsx("td",{colSpan:ho,className:g(lr[K]),children:w(q,pe)})})]},Se)},og=()=>{if(ie)return Array.from({length:Q}).map((q,ee)=>jsx(kb,{cols:ho,density:K},ee));if(kt.length===0)return jsx("tr",{children:jsx("td",{colSpan:ho,className:g("text-center text-gray-400 dark:text-gray-500",lr[K]),children:ge??"No data available"})});if(tr){let q=[],ee=0;for(let[pe,Se]of tr){let He=er.has(pe);if(q.push(jsx("tr",{className:"bg-gray-100 dark:bg-gray-800 font-medium",children:jsx("td",{colSpan:ho,className:g(lr[K],"cursor-pointer"),onClick:()=>{vt(Mt=>{let fr=new Set(Mt);return fr.has(pe)?fr.delete(pe):fr.add(pe),fr});},children:jsxs("div",{className:"flex items-center gap-2",children:[jsx(id,{className:g("transition-transform",He&&"-rotate-90")}),A?A(pe,nn(Se[0],Array.isArray(F)?F[0]:F),Se):`${pe} (${Se.length})`]})})},`group-${pe}`)),He)ee+=Se.length;else for(let Mt=0;Mt<Se.length;Mt++)q.push(ii(Se[Mt],ee,ee)),ee++;}return q}if(G){let q=[];for(let ee=sr.start;ee<sr.end;ee++)q.push(ii(kt[ee],ee,ee));return jsxs(Fragment,{children:[sr.start>0&&jsx("tr",{children:jsx("td",{colSpan:ho,style:{height:sr.start*j,padding:0}})}),q,sr.end<kt.length&&jsx("tr",{children:jsx("td",{colSpan:ho,style:{height:(kt.length-sr.end)*j,padding:0}})})]})}return kt.map((q,ee)=>ii(q,ee,ee))},ag=()=>!Re||!qe.some(ee=>ee.aggregate)?null:jsx("tfoot",{children:jsxs("tr",{className:"bg-gray-50 dark:bg-gray-800 font-semibold border-t-2 border-gray-300 dark:border-gray-600",children:[x&&jsx("td",{className:lr[K]}),v&&jsx("td",{className:lr[K]}),I&&jsx("td",{className:lr[K]}),qe.map(ee=>jsx("td",{className:g(lr[K],hs[K],"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:si(ee),children:ee.aggregate?ee.renderAggregate?ee.renderAggregate(ld(ze,ee.key,ee.aggregate),ze):`${ee.aggregate==="count"?"":ee.aggregate==="avg"?"Avg: ":ee.aggregate==="sum"?"Total: ":ee.aggregate==="min"?"Min: ":"Max: "}${ld(ze,ee.key,ee.aggregate).toLocaleString()}`:""},ee.key))]})});return jsxs("div",{className:g("flex flex-col gap-3",me),children:[(h||V||H)&&jsxs("div",{className:"flex items-center justify-between gap-3 flex-wrap",children:[jsxs("div",{className:"flex items-center gap-3 flex-1",children:[h&&jsxs("div",{className:"relative flex-1 max-w-xs",children:[jsx("div",{className:"absolute inset-y-0 left-0 flex items-center pl-3 pointer-events-none",children:jsx(pb,{})}),jsx("input",{type:"text",value:oe,onChange:Um,placeholder:R,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&&jsxs("span",{className:"text-sm text-gray-500 dark:text-gray-400",children:[Z.length," selected"]})]}),jsxs("div",{className:"flex items-center gap-2",children:[H&&jsxs("div",{className:"relative",ref:bo,children:[jsx("button",{type:"button",onClick:()=>Ye(!ct),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:jsx(yb,{})}),ct&&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=>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:[jsx("input",{type:"checkbox",checked:!be.includes(q.key),onChange:()=>jm(q.key),className:"rounded border-gray-300 dark:border-gray-600 cursor-pointer"}),jsx("span",{className:"text-gray-700 dark:text-gray-300",children:String(q.header)})]},q.key))})]}),V&&Y.map(q=>jsxs("button",{type:"button",onClick:()=>ai(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:[jsx(hb,{}),q.toUpperCase()]},q))]})]}),jsx("div",{ref:Hr,className:g("overflow-auto rounded-lg",!U&&"border border-gray-200 dark:border-gray-700",J&&"relative"),style:te?{maxHeight:typeof te=="number"?`${te}px`:te}:G?{maxHeight:O,overflow:"auto"}:void 0,onScroll:G?q=>Kn(q.target.scrollTop):void 0,children:jsxs("table",{className:"w-full text-left",children:[jsx("thead",{className:g("bg-gray-50 dark:bg-gray-800 text-xs uppercase",J&&"sticky top-0 z-20"),children:jsxs("tr",{children:[x&&jsx("th",{className:g(lr[K],"w-10 font-semibold text-gray-700 dark:text-gray-300")}),v&&jsx("th",{className:g(lr[K],"w-10"),children:k==="multiple"&&jsx("input",{type:"checkbox",checked:oi,ref:q=>{q&&(q.indeterminate=Gm);},onChange:oi?ni:ri,className:"rounded border-gray-300 dark:border-gray-600 cursor-pointer","aria-label":"Select all rows"})}),I&&jsx("th",{className:g(lr[K],"w-10 font-semibold text-gray-700 dark:text-gray-300")}),qe.map(ng)]})}),jsx("tbody",{children:og()}),ag()]})}),$e&&jsxs("div",{className:"flex items-center justify-between flex-wrap gap-3 text-sm text-gray-600 dark:text-gray-400",children:[jsxs("div",{className:"flex items-center gap-3",children:[$e.showTotalItems!==false&&jsxs("span",{children:[je," item",je!==1?"s":""]}),$e.showPageSizeSelector!==false&&$e.pageSizeOptions&&jsxs("div",{className:"flex items-center gap-1.5",children:[jsx("span",{children:"Rows per page:"}),jsx("select",{value:nt,onChange:q=>ti(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:$e.pageSizeOptions.map(q=>jsx("option",{value:q,children:q},q))})]})]}),jsxs("div",{className:"flex items-center gap-1",children:[jsxs("span",{className:"mr-2",children:["Page ",Vr," of ",Lt]}),jsx("button",{type:"button",onClick:()=>xr(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"}),jsx("button",{type:"button",onClick:()=>xr(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"}),jsx("button",{type:"button",onClick:()=>xr(Vr+1),disabled:Vr>=Lt,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"}),jsx("button",{type:"button",onClick:()=>xr(Lt),disabled:Vr>=Lt,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 Sb=forwardRef(Nb);function Tb({className:e}){return jsx("svg",{className:e,viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",children:jsx("path",{d:"M4 4L12 12M12 4L4 12",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})})}var Pb={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"}},Eb={default:"bg-gray-500",primary:"bg-blue-600",success:"bg-green-600",warning:"bg-yellow-500",error:"bg-red-600",info:"bg-cyan-600"},Db={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"},Xi={sm:"w-3 h-3",md:"w-3.5 h-3.5",lg:"w-4 h-4"},Lb={sm:"w-4 h-4 -ml-1",md:"w-5 h-5 -ml-1.5",lg:"w-6 h-6 -ml-1.5"},Mb={sm:"w-1.5 h-1.5",md:"w-2 h-2",lg:"w-2.5 h-2.5"},Ib={none:"rounded-none",sm:"rounded-sm",md:"rounded-md",lg:"rounded-lg",full:"rounded-full"};function xs({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:b,closable:m=false,clickable:p=false,selected:C=false,disabled:v=false,as:k="span",className:y,onClick:z,...h}){let R=k,f=g("inline-flex items-center justify-center font-medium transition-all",Db[n],Ib[i],r==="outlined"&&"border"),N=g(a||s||l?g(a,s,l):Pb[o][r]),L=C?"ring-2 ring-offset-1 ring-blue-500":"",E=p&&!v?"cursor-pointer hover:opacity-80 active:scale-95":"",I=v?"opacity-50 cursor-not-allowed":"",w=T=>{T.stopPropagation(),b?.();},W=T=>{v||z?.(T);},M=t??e;return jsxs(R,{className:g(f,N,L,E,I,y),onClick:W,"aria-disabled":v,...h,children:[r==="dot"&&jsx("span",{className:g("rounded-full shrink-0",Mb[n],Eb[o]),"aria-hidden":"true"}),u&&jsx("span",{className:g("rounded-full overflow-hidden shrink-0",Lb[n]),children:u}),c&&!u&&jsx("span",{className:g("shrink-0",Xi[n]),children:c}),M&&jsx("span",{className:"truncate",children:M}),d&&!m&&jsx("span",{className:g("shrink-0",Xi[n]),children:d}),m&&jsx("button",{type:"button",onClick:w,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:jsx(Tb,{className:Xi[n]})})]})}xs.displayName="Chip";var Vb=500,Bb=800,Fb=600;function Ob(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 $b(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 _b(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 dd=forwardRef(function({children:t,detached:r,defaultDetached:n=false,onClose:o,onDetach:a,title:s="",width:l=Bb,height:i=Fb,left:c,top:d,center:u=true,copyStyles:b=true,closeOnParentUnmount:m=true,className:p,windowClassName:C,onPopupBlocked:v},k){let y=r!==void 0,[z,h]=useState(n),R=y?r:z,[f,N]=useState(null),L=useRef(null),E=useRef(null),I=useRef(null),w=useRef(false),W=useRef({width:l,height:i,left:c,top:d,center:u,shouldCopyStyles:b,title:s,windowClassName:C,closeOnParentUnmount:m});W.current={width:l,height:i,left:c,top:d,center:u,shouldCopyStyles:b,title:s,windowClassName:C,closeOnParentUnmount:m};let M=useCallback(()=>{E.current&&(clearInterval(E.current),E.current=null),I.current&&(I.current.disconnect(),I.current=null),N(null);},[]),T=useCallback(()=>{L.current&&!L.current.closed&&L.current.close(),L.current=null,M();},[M]),P=useCallback(()=>{if(typeof window>"u"||w.current||L.current&&!L.current.closed)return;w.current=true;let x=W.current,D=Ob(x.width,x.height,{center:x.center,left:x.left,top:x.top}),S=window.open("","",D);if(!S){w.current=false,v?.();return}L.current=S,S.document.title=x.title||document.title;let B=S.document.createElement("div");x.windowClassName&&(B.className=x.windowClassName),S.document.body.appendChild(B),N(B),x.shouldCopyStyles&&($b(document,S.document),I.current=_b(document,S.document)),E.current=setInterval(()=>{S.closed&&(M(),L.current=null,y||h(false),o?.());},Vb),w.current=false,a?.();},[y,o,a,v,M]);return useEffect(()=>{R?P():T();},[R,P,T]),useEffect(()=>{L.current&&!L.current.closed&&s&&(L.current.document.title=s);},[s]),useEffect(()=>()=>{W.current.closeOnParentUnmount&&L.current&&!L.current.closed&&L.current.close(),M(),L.current=null;},[M]),useImperativeHandle(k,()=>({detach:()=>{y||h(true);},attach:()=>{y||h(false);},get isDetached(){return y?!!r:z},get window(){return L.current}}),[y,r,z]),R&&f?createPortal(t,f):R?null:jsx("div",{className:g(p),children:t})});dd.displayName="Detachable";var Kb={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}}},Ub=({className:e})=>jsxs("svg",{className:g("w-3 h-3",e),viewBox:"0 0 16 16",fill:"currentColor",children:[jsx("rect",{x:"1",y:"11",width:"2.5",height:"4",rx:"0.5"}),jsx("rect",{x:"5",y:"8",width:"2.5",height:"7",rx:"0.5"}),jsx("rect",{x:"9",y:"5",width:"2.5",height:"10",rx:"0.5"}),jsx("rect",{x:"13",y:"1",width:"2.5",height:"14",rx:"0.5"})]}),Yb=({className:e})=>jsxs("svg",{className:g("w-3 h-3",e),viewBox:"0 0 20 20",fill:"currentColor",children:[jsx("path",{d:"M10 14.5a1.5 1.5 0 100 3 1.5 1.5 0 000-3z"}),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"}),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})=>jsxs("svg",{className:g("w-4 h-3",e),viewBox:"0 0 24 14",fill:"currentColor",children:[jsx("rect",{x:"0.5",y:"0.5",width:"20",height:"13",rx:"2",stroke:"currentColor",fill:"none",strokeWidth:"1"}),jsx("rect",{x:"22",y:"4",width:"2",height:"6",rx:"0.5"}),jsx("rect",{x:"2.5",y:"2.5",width:"14",height:"9",rx:"1"})]});function Na({time:e="9:41",theme:t,device:r}){let n=r==="watch",o=t==="dark"?"text-white":"text-gray-900";return n?jsx("div",{className:g("flex items-center justify-center py-0.5",o),style:{fontSize:"8px"},children:jsx("span",{className:"font-medium",children:e})}):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:[jsx("span",{className:"font-semibold",children:e}),jsxs("div",{className:"flex items-center gap-1",children:[jsx(Ub,{className:o}),jsx(Yb,{className:o}),jsx(qb,{className:o})]})]})}function jb({theme:e}){let t=e==="dark";return 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:[jsxs("div",{className:"flex items-center gap-1.5",children:[jsx("div",{className:"w-2.5 h-2.5 rounded-full bg-red-400"}),jsx("div",{className:"w-2.5 h-2.5 rounded-full bg-yellow-400"}),jsx("div",{className:"w-2.5 h-2.5 rounded-full bg-green-400"})]}),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:jsxs("span",{className:"flex items-center justify-center gap-1",children:[jsx("svg",{className:"w-2.5 h-2.5",viewBox:"0 0 16 16",fill:"currentColor",children: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 Zb({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 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:[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"}),jsxs("div",{className:"rounded-[2rem] overflow-hidden bg-black relative",style:{width:r,height:n},children:[o&&jsx(Na,{time:a,theme:t,device:"phone"}),e]}),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 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:[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"}),jsxs("div",{className:"rounded-[2rem] overflow-hidden bg-black relative",style:{width:r,height:n},children:[o&&jsx(Na,{time:a,theme:t,device:"phone"}),e]}),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 Qb({children:e,theme:t,screenW:r,screenH:n,showStatusBar:o,statusBarTime:a,frameColor:s}){return 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:[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"}),jsxs("div",{className:"rounded-[1.5rem] overflow-hidden bg-black relative",style:{width:r,height:n},children:[o&&jsx(Na,{time:a,theme:t,device:"android"}),e]})]})}function Jb({children:e,theme:t,screenW:r,screenH:n,showStatusBar:o,statusBarTime:a,frameColor:s}){return 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:[jsx("div",{className:"absolute top-[8px] rounded-full bg-gray-700 z-10",style:{width:6,height:6,left:"50%",transform:"translateX(-50%)"}}),jsxs("div",{className:"rounded-lg overflow-hidden bg-black relative",style:{width:r,height:n},children:[o&&jsx(Na,{time:a,theme:t,device:"tablet"}),e]})]})}function eh({children:e,theme:t,screenW:r,screenH:n,frameColor:o}){let a=t==="dark",s=o??(a?"#1a1a1a":"#d1d5db"),l=r+60;return jsxs("div",{className:"inline-flex flex-col items-center","data-testid":"device-frame","data-device":"laptop",children:[jsxs("div",{className:"rounded-t-xl shadow-xl relative",style:{backgroundColor:s,padding:"8px 8px 0",width:r+16},children:[jsx("div",{className:"absolute top-[3px] rounded-full bg-gray-700 z-10",style:{width:4,height:4,left:"50%",transform:"translateX(-50%)"}}),jsx("div",{className:"rounded-t-sm overflow-hidden bg-black",style:{width:r,height:n},children:e})]}),jsx("div",{className:g(a?"bg-gray-800":"bg-gray-400"),style:{width:r+16,height:3}}),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 th({children:e,theme:t,screenW:r,screenH:n,frameColor:o}){let a=t==="dark";return jsxs("div",{className:"inline-flex flex-col items-center","data-testid":"device-frame","data-device":"desktop",children:[jsx("div",{className:"rounded-lg shadow-xl",style:{backgroundColor:o??(a?"#1a1a1a":"#d1d5db"),padding:"8px 8px 20px",width:r+16},children:jsx("div",{className:"rounded-sm overflow-hidden bg-black",style:{width:r,height:n},children:e})}),jsx("div",{className:g(a?"bg-gray-800":"bg-gray-400"),style:{width:40,height:24},"data-testid":"monitor-stand"}),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 rh({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 jsxs("div",{className:"inline-flex flex-col items-center","data-testid":"device-frame","data-device":"watch",children:[jsx("div",{className:g("rounded-t-lg",l?"bg-gray-800":"bg-gray-400"),style:{width:c,height:30},"data-testid":"watch-band"}),jsxs("div",{className:"relative rounded-[1.2rem] shadow-xl",style:{backgroundColor:i,padding:"8px 6px",width:r+12},children:[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"}),jsxs("div",{className:"rounded-xl overflow-hidden bg-black",style:{width:r,height:n},children:[o&&jsx(Na,{time:a,theme:t,device:"watch"}),e]})]}),jsx("div",{className:g("rounded-b-lg",l?"bg-gray-800":"bg-gray-400"),style:{width:c,height:30}})]})}function nh({children:e,theme:t,screenW:r,screenH:n,frameColor:o}){return 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:[jsx(jb,{theme:t}),jsx("div",{className:"overflow-hidden bg-white",style:{width:r,height:n},children:e})]})}function oh({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:b,contentClassName:m}){let p=useRef(null),C=useRef(null),v=Kb[e][s],k=o==="landscape"&&e!=="watch"&&e!=="browser",y=k?v.h:v.w,z=k?v.w:v.h;useEffect(()=>{if(!c||!p.current)return;let N=p.current,L=null,E=I=>{L===null&&(L=I);let w=(I-L)/1e3;L=I,N.scrollTop+=d*w,N.scrollTop>=N.scrollHeight-N.clientHeight&&(N.scrollTop=0),C.current=requestAnimationFrame(E);};return C.current=requestAnimationFrame(E),()=>{C.current!==null&&cancelAnimationFrame(C.current);}},[c,d]);let h=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?jsx("img",{src:t,alt:r,className:"w-full h-auto object-cover",draggable:false}):n}),R={showStatusBar:l,statusBarTime:i},f=()=>{switch(e){case "phone":return jsx(Zb,{theme:a,screenW:y,screenH:z,frameColor:u,landscape:k,...R,children:h});case "android":return jsx(Qb,{theme:a,screenW:y,screenH:z,frameColor:u,...R,children:h});case "tablet":return jsx(Jb,{theme:a,screenW:y,screenH:z,frameColor:u,...R,children:h});case "laptop":return jsx(eh,{theme:a,screenW:y,screenH:z,frameColor:u,children:h});case "desktop":return jsx(th,{theme:a,screenW:y,screenH:z,frameColor:u,children:h});case "watch":return jsx(rh,{theme:a,screenW:y,screenH:z,frameColor:u,...R,children:h});case "browser":return jsx(nh,{theme:a,screenW:y,screenH:z,frameColor:u,children:h})}};return jsx("div",{className:g("inline-flex",b),"data-testid":"device-mockup","data-orientation":o,"data-theme":a,"data-size":s,children:f()})}var vs={solid:"border-solid",dashed:"border-dashed",dotted:"border-dotted"},ah={left:{before:"flex-[0.1]",after:"flex-1"},center:{before:"flex-1",after:"flex-1"},right:{before:"flex-1",after:"flex-[0.1]"}};function md({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 jsx("hr",{"aria-orientation":"vertical",className:g("h-full border-l-0 border-r",vs[t],a,s||"mx-2",l),style:{borderRightWidth:`${o}px`},...i});if(r){let c=ah[n];return 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:[jsx("div",{className:g("border-t",vs[t],a,c.before),style:{borderTopWidth:`${o}px`}}),jsx("span",{className:"px-3 whitespace-nowrap",children:r}),jsx("div",{className:g("border-t",vs[t],a,c.after),style:{borderTopWidth:`${o}px`}})]})}return jsx("hr",{"aria-orientation":"horizontal",className:g("border-t-0 border-b",vs[t],a,s||"my-4",l),style:{borderBottomWidth:`${o}px`},...i})}md.displayName="Divider";var ih=new Set(["SCRIPT","STYLE","LINK","META","NOSCRIPT","TEMPLATE","BASE","TITLE"]),gd="data-synertech-inert-ignore",Ra=new WeakMap,Ui=new WeakMap,Yi=new WeakMap;function lh(e){let t=Ra.get(e)??0;t===0&&(Ui.set(e,e.getAttribute("aria-hidden")),Yi.set(e,e.hasAttribute("inert")),e.setAttribute("aria-hidden","true"),e.setAttribute("inert","")),Ra.set(e,t+1);}function ch(e){let t=Ra.get(e)??0;if(t===0)return;if(t>1){Ra.set(e,t-1);return}Ra.delete(e);let r=Ui.get(e)??null;r===null?e.removeAttribute("aria-hidden"):e.setAttribute("aria-hidden",r),Ui.delete(e),Yi.get(e)||e.removeAttribute("inert"),Yi.delete(e);}var ks=new Map;function oo(e,t){return ks.set(e,t),()=>{ks.delete(e);}}function Cs(e){if(ks.size===0)return [];let t=[];for(let[r,n]of ks){let o=n();o&&e.some(a=>a.contains(o))&&t.push(r);}return t}function dh(e){return !(ih.has(e.tagName)||e.hasAttribute(gd))}function qi(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,...Cs(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)||dh(u)&&(a.add(u),lh(u),o.push(u));c=d;}}let l=false;return ()=>{if(!l){l=true;for(let i of o)ch(i);}}}var Hn=[];function pd(e){let t=Hn.indexOf(e);t!==-1&&Hn.splice(t,1),Hn.push(e);}function fd(e){let t=Hn.indexOf(e);t!==-1&&Hn.splice(t,1);}function bd(e){return Hn.length>0&&Hn[Hn.length-1]===e}var Ta=0,ji=null;function hd(e=document){let t=e.body;if(!t)return ()=>{};Ta===0&&(ji=t.style.overflow,t.style.overflow="hidden"),Ta+=1;let r=false;return ()=>{r||(r=true,Ta=Math.max(0,Ta-1),Ta===0&&(t.style.overflow=ji??"",ji=null));}}var yd=["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 uh(e){let t=e.ownerDocument?.defaultView;if(!t)return null;try{return t.getComputedStyle(e)}catch{return null}}function xd(e){let t=e;for(;t;){if(t.hasAttribute("hidden")||t.hasAttribute("inert")||t.getAttribute("aria-hidden")==="true")return false;let r=uh(t);if(r&&(r.display==="none"||r.visibility==="hidden"||r.visibility==="collapse"))return false;t=t.parentElement;}return true}function vd(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 xd(e)}function ws(e){return Array.from(e.querySelectorAll(yd)).filter(vd).sort((r,n)=>{let o=r.compareDocumentPosition(n);return o&Node.DOCUMENT_POSITION_FOLLOWING?-1:o&Node.DOCUMENT_POSITION_PRECEDING?1:0})}var mh={role:"dialog","aria-modal":true,tabIndex:-1};function gh(e,t){return t==="none"?null:t&&typeof t=="object"?t.current??e:t==="first"?ws(e)[0]??e:e}function ph(e){return e?e.map(t=>t&&"current"in t?t.current:t).filter(t=>!!t):[]}function Ho(e){if(e)try{e.focus();}catch{}}function ao(e){let{open:t}=e,r=useRef(null),n=useRef(e);return n.current=e,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;pd(o);let u=l===false?void 0:qi([o,...ph(d)]),b=i===false?void 0:hd(a);return Ho(gh(o,c)),()=>{u?.(),b?.(),fd(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)&&Ho(v);}},[t]),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:Cs([o]).some(d=>d.contains(c)):false,i=c=>{if(c.defaultPrevented||!bd(o))return;let{closeOnEscape:d,trapFocus:u,onClose:b}=n.current;if(c.key==="Escape"){if(d===false)return;c.preventDefault(),b?.();return}if(c.key!=="Tab"||u===false)return;let m=a.activeElement;if(m&&!o.contains(m)&&l(m))return;let p=ws(o);if(p.length===0){c.preventDefault(),Ho(o);return}let C=p[0],v=p[p.length-1];if(!m||!o.contains(m)){c.preventDefault(),Ho(c.shiftKey?v:C);return}if(c.shiftKey&&(m===C||m===o)){c.preventDefault(),Ho(v);return}!c.shiftKey&&m===v&&(c.preventDefault(),Ho(C));};return s.addEventListener("keydown",i),()=>s.removeEventListener("keydown",i)},[t]),{dialogRef:r,dialogProps:mh}}var xh={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"}},vh={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"},wd={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"}},kh=jsx("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})});function Nd({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:b,overlayClassName:m,closeLabel:p,"aria-label":C,trapFocus:v=true,initialFocus:k,returnFocus:y,lockScroll:z=true}){let h=!!(a||s),R=useRef(null),f=Ge(),L=`${useId()}-drawer-title`,{dialogRef:E,dialogProps:I}=ao({open:e,onClose:t,closeOnEscape:c,trapFocus:v,initialFocus:k,returnFocus:y,lockScroll:z,keepInteractive:[R]}),w=useCallback(()=>{i&&t();},[i,t]);if(!e)return null;let W=jsxs(Fragment,{children:[l&&jsx("div",{ref:R,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:w,"aria-hidden":"true"}),jsxs("div",{ref:E,...I,"aria-labelledby":d?L:void 0,"aria-label":d?void 0:C,className:g("fixed z-50 bg-white dark:bg-gray-900","shadow-xl overflow-hidden","flex flex-col focus:outline-none",vh[n],!h&&xh[n][o],e?wd[n].enter:wd[n].exit,b),style:{...a?{width:a}:{},...s?{height:s}:{}},children:[d&&jsxs("div",{className:"flex items-center justify-between px-6 py-4 border-b border-gray-200 dark:border-gray-700",children:[jsx("h2",{id:L,className:"text-lg font-semibold text-gray-900 dark:text-white",children:d}),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??f.closeDrawer,children:kh})]}),jsx("div",{className:"flex-1 overflow-y-auto px-6 py-4",children:r}),u&&jsx("div",{className:"px-6 py-4 border-t border-gray-200 dark:border-gray-700",children:u})]})]});return typeof document<"u"?createPortal(W,document.body):W}Nd.displayName="Drawer";var Sh={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"}},Pd=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]}`},Qi=e=>e.webkitRelativePath||e.name,Rh=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: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"})}),Th=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: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"})}),Ph=0;async function Eh(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 Dh({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:b,error:m,showFileList:p=true,placeholder:C,browseLabel:v,browseFolderLabel:k,icon:y,onReject:z,className:h}){let[R,f]=useState([]),[N,L]=useState(false),E=useRef(null),I=useRef(null),w=useId(),W=e!==void 0,M=W?e.map((U,J)=>({file:U,id:`ctrl-${J}`})):R,T=Sh[i];useEffect(()=>{s==="directory"&&E.current&&E.current.setAttribute("webkitdirectory",""),s==="both"&&I.current&&I.current.setAttribute("webkitdirectory","");},[s]);let P=useMemo(()=>Pd(o),[o]),x=useMemo(()=>r?r.split(",").map(U=>U.trim()).map(U=>U.startsWith(".")?U.toUpperCase():U.endsWith("/*")?U.replace("/*","").toUpperCase():U).join(", "):"All files",[r]),D=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",S=s==="directory"?"Browse folder":"Browse",B="Browse folder",H=useCallback(U=>{if(U.size>o)return `File exceeds maximum size of ${P}`;if(r){let J=r.split(",").map(Q=>Q.trim()),te=`.${U.name.split(".").pop()?.toLowerCase()}`;if(!J.some(Q=>Q.startsWith(".")?te===Q.toLowerCase():Q.endsWith("/*")?U.type.startsWith(Q.replace("/*","/")):U.type===Q))return `File type not accepted. Expected: ${x}`}return null},[r,x,o,P]),$=useCallback(U=>{if(c||d)return;let J=Array.from(U),te=[];for(let ie of J){let Q=H(ie);Q?z?.(ie,Q):te.push(ie);}if(te.length!==0)if(W)if(n){let Q=[...e??[],...te],ge=a?Q.slice(0,a):Q;t?.(ge);}else t?.([te[0]]);else f(ie=>{let Q=te.map(ge=>({file:ge,id:`file-${++Ph}`}));if(n){let ge=[...ie,...Q],Re=a?ge.slice(0,a):ge,Qe=Re.map(at=>at.file);return t?.(Qe),Re}return t?.([te[0]]),[Q[0]]});},[c,d,W,n,a,e,t,z,H]),_=useCallback(U=>{if(!(c||d)){if(W){let J=(e??[]).filter((te,ie)=>ie!==U);t?.(J);}else f(J=>{let te=J.filter((ie,Q)=>Q!==U);return t?.(te.map(ie=>ie.file)),te});E.current&&(E.current.value="");}},[c,d,W,e,t]),F=useCallback(()=>{c||d||(W?t?.([]):(f([]),t?.([])),E.current&&(E.current.value=""));},[c,d,W,t]),A=useCallback(U=>{U.target.files&&U.target.files.length>0&&$(U.target.files);},[$]),V=useCallback(U=>{U.preventDefault(),U.stopPropagation(),!c&&!d&&L(true);},[c,d]),Y=useCallback(U=>{U.preventDefault(),U.stopPropagation(),L(false);},[]),X=useCallback(U=>{if(U.preventDefault(),U.stopPropagation(),L(false),c||d)return;let J=U.dataTransfer.items;if(J&&J.length>0&&(s==="directory"||s==="both")){let te=[];for(let Q=0;Q<J.length;Q++){let ge=J[Q].webkitGetAsEntry?.();ge&&te.push(ge);}if(te.some(Q=>Q.isDirectory)){Eh(te).then(Q=>{Q.length>0&&$(Q);});return}}U.dataTransfer.files&&U.dataTransfer.files.length>0&&$(U.dataTransfer.files);},[c,d,s,$]),G=useCallback(()=>{!c&&!d&&E.current?.click();},[c,d]),j=useCallback(()=>{!c&&!d&&I.current?.click();},[c,d]),O=M.length>0,K=y||(s==="directory"?Th:Rh),se=p&&O&&jsxs("div",{className:g("flex flex-col",T.gap),children:[M.map((U,J)=>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",T.fileItem),children:[jsxs("div",{className:"flex items-center gap-2 min-w-0 flex-1",children:[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: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"})}),jsx("span",{className:"truncate text-gray-700 dark:text-gray-300",children:Qi(U.file)}),jsxs("span",{className:"shrink-0 text-gray-400 dark:text-gray-500",children:["(",Pd(U.file.size),")"]})]}),!c&&!d&&jsx("button",{type:"button",onClick:()=>_(J),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 ${Qi(U.file)}`,children: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:jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M6 18L18 6M6 6l12 12"})})})]},U.id)),n&&M.length>1&&!c&&!d&&jsx("button",{type:"button",onClick:F,className:g("self-start text-gray-400 hover:text-red-500 dark:text-gray-500 dark:hover:text-red-400 transition-colors cursor-pointer",T.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",T.button,m&&"border-red-300 dark:border-red-600");return jsxs("div",{className:g("flex flex-col",T.gap,h),children:[u&&jsx("label",{htmlFor:w,className:g("block font-medium text-gray-700 dark:text-gray-300",T.text),children:u}),jsx("input",{ref:E,id:w,type:"file",accept:s!=="directory"?r:void 0,multiple:n,onChange:A,className:"sr-only",disabled:c||d,"aria-describedby":m?`${w}-error`:b?`${w}-helper`:void 0,"aria-invalid":!!m}),s==="both"&&jsx("input",{ref:I,type:"file",onChange:A,className:"sr-only",disabled:c||d,tabIndex:-1,"aria-hidden":"true"}),l==="dropzone"?jsxs("div",{role:s==="both"?"group":"button",tabIndex:s==="both"?void 0:c||d?-1:0,onClick:s==="both"?void 0:G,onKeyDown:s==="both"?void 0:U=>{(U.key==="Enter"||U.key===" ")&&(U.preventDefault(),G());},onDragOver:V,onDragLeave:Y,onDrop:X,className:g("flex flex-col items-center justify-center rounded-lg border-2 border-dashed transition-colors",T.dropzone,N&&!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":C||D,children:[jsx("div",{className:g("text-gray-400 dark:text-gray-500 mb-2",T.icon,N&&"text-blue-500 dark:text-blue-400"),children:K}),jsxs("p",{className:g("text-gray-600 dark:text-gray-400",T.text),children:[C||D," ",!c&&!d&&s!=="both"&&jsx("span",{className:"text-blue-600 dark:text-blue-400 font-medium",children:v||S})]}),s==="both"&&!c&&!d&&jsxs("div",{className:g("flex items-center gap-3 mt-1",T.text),children:[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:v||"Browse files"}),jsx("span",{className:"text-gray-300 dark:text-gray-600",children:"\xB7"}),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:k||B})]}),jsxs("p",{className:g("text-gray-400 dark:text-gray-500 mt-1",T.subtext),children:[x," - Max ",P,n&&a&&` - Up to ${a} files`]})]}):jsxs("div",{className:"flex items-center gap-2",children:[s==="both"?jsxs(Fragment,{children:[jsx("button",{type:"button",onClick:G,disabled:c||d,className:ae,children:v||(O?"Change files":"Choose files")}),jsx("button",{type:"button",onClick:j,disabled:c||d,className:ae,children:k||"Choose folder"})]}):jsx("button",{type:"button",onClick:G,disabled:c||d,className:ae,children:v||(s==="directory"?O?"Change folder":"Choose folder":O?"Change file":"Choose file")}),!O&&jsx("span",{className:g("text-gray-400 dark:text-gray-500",T.text),children:s==="directory"?"No folder selected":s==="both"?"No file or folder selected":"No file selected"}),O&&!p&&jsx("span",{className:g("text-gray-600 dark:text-gray-400 truncate",T.text),children:M.length===1?Qi(M[0].file):`${M.length} files selected`})]}),se,m&&jsx("p",{id:`${w}-error`,className:g("text-red-600 dark:text-red-400",T.subtext),role:"alert",children:m}),b&&!m&&jsx("p",{id:`${w}-helper`,className:g("text-gray-400 dark:text-gray-500",T.subtext),children:b})]})}var Ld=createContext(null);function wr(){let e=useContext(Ld);if(!e)throw new Error("Dropdown compound components must be used within a Dropdown");return e}function Md({open:e,defaultOpen:t=false,onOpenChange:r,closeOnSelect:n=true,closeOnClickOutside:o=true,closeOnEscape:a=true,modal:s=false,children:l}){let[i,c]=useState(t),d=e!==void 0,u=d?e:i,b=useRef(null),m=useRef(null),p=useRef([]),[C,v]=useState(-1),k=useRef(0),y=useId(),z={triggerId:`dropdown-trigger-${y}`,contentId:`dropdown-content-${y}`},h=useCallback(L=>{d||c(L),r?.(L),L||v(-1);},[d,r]),R=useCallback((L,E)=>{p.current&&(p.current[L]=E);},[]),f=useCallback(()=>k.current++,[]),N={isOpen:u,setIsOpen:h,triggerRef:b,contentRef:m,closeOnSelect:n,closeOnClickOutside:o,closeOnEscape:a,modal:s,focusedIndex:C,setFocusedIndex:v,itemsRef:p,registerItem:R,getNextItemIndex:f,triggerId:z.triggerId,contentId:z.contentId};return jsx(Ld.Provider,{value:N,children:jsx("div",{className:"relative inline-block",children:l})})}Md.displayName="Dropdown";var Id=memo(({isOpen:e})=>jsx("span",{className:g("inline-block transition-transform",e&&"rotate-180"),children:jsx("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24","aria-hidden":"true",children:jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 9l-7 7-7-7"})})}));Id.displayName="ChevronIcon";function Ad({asChild:e=false,disabled:t=false,children:r,className:n}){let{isOpen:o,setIsOpen:a,triggerRef:s,triggerId:l,contentId:i}=wr(),u={ref:s,id:l,"aria-haspopup":"menu","aria-expanded":o,"aria-controls":o?i:void 0,disabled:t,onClick:()=>{t||a(!o);},onKeyDown:b=>{t||((b.key==="Enter"||b.key===" ")&&(b.preventDefault(),a(!o)),b.key==="ArrowDown"&&!o&&(b.preventDefault(),a(true)));}};return e&&isValidElement(r)?cloneElement(r,{...u,className:g(r.props.className,n)}):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,jsx(Id,{isOpen:o})]})}Ad.displayName="DropdownTrigger";function Vo(e){let t=useRef(e);return useLayoutEffect(()=>{t.current=e;}),t}function Bo(e,t,r=true){let n=Vo(t);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 Fo({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]=useState({top:0,left:0,actualSide:n,actualAlign:o,isReady:false}),u=useRef(false),b=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},k=n,y=o,z=f=>{switch(f){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}}},h=(f,N,L)=>{if(f==="top"||f==="bottom")switch(N){case "start":return {...L,left:m.left+s};case "center":return {...L,left:m.left+m.width/2-p.width/2+s};case "end":return {...L,left:m.right-p.width+s}}else switch(N){case "start":return {...L,top:m.top+s};case "center":return {...L,top:m.top+m.height/2-p.height/2+s};case "end":return {...L,top:m.bottom-p.height+s}}},R=z(k);if(R=h(k,y,R),l){let{top:f,left:N}=R,{height:L,width:E}=p,{height:I,width:w}=v,W=f+L>I-i,M=f<i,T=N+E>w-i,P=N<i;k==="bottom"&&W&&!M?(k="top",R=z(k),R=h(k,y,R)):k==="top"&&M&&!W&&(k="bottom",R=z(k),R=h(k,y,R)),k==="right"&&T&&!P?(k="left",R=z(k),R=h(k,y,R)):k==="left"&&P&&!T&&(k="right",R=z(k),R=h(k,y,R));let x=R.left+E>w-i,D=R.left<i,S=R.top+L>I-i,B=R.top<i;(k==="top"||k==="bottom")&&(x&&(R.left=w-E-i,y="end"),D&&(R.left=i,y="start")),(k==="left"||k==="right")&&(S&&(R.top=I-L-i,y="end"),B&&(R.top=i,y="start"));}u.current=true,d({top:R.top,left:R.left,actualSide:k,actualAlign:y,isReady:true});},[e,t,n,o,a,s,l,i]);return useLayoutEffect(()=>{let m=0;if(r){u.current=false;let C=()=>{b(),u.current||(m=requestAnimationFrame(C));};m=requestAnimationFrame(C);}let p=()=>b();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});}},[b,r]),c}function Rs({isOpen:e,onClose:t,itemsCount:r,focusedIndex:n,setFocusedIndex:o,onSelect:a,loop:s=true}){let l=Vo(t),i=Vo(a),c=Vo(n),d=useCallback(u=>{if(!(!e||r===0))switch(u.key){case "ArrowDown":u.preventDefault(),o(s?b=>b<r-1?b+1:0:b=>Math.min(b+1,r-1));break;case "ArrowUp":u.preventDefault(),o(s?b=>b>0?b-1:r-1:b=>Math.max(b-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 useEffect(()=>{if(e)return document.addEventListener("keydown",d),()=>document.removeEventListener("keydown",d)},[e,d]),{focusedIndex:n}}function Wd(e,t,r){useEffect(()=>{r&&e.current&&e.current[t]&&e.current[t]?.focus();},[t,r,e]);}var Zh={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 Vd({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:b}){let{isOpen:m,setIsOpen:p,triggerRef:C,contentRef:v,closeOnClickOutside:k,closeOnEscape:y,modal:z,contentId:h,focusedIndex:R,setFocusedIndex:f,itemsRef:N}=wr(),[L,E]=useState(false),I=Fo({triggerRef:C,contentRef:v,isOpen:m,side:e,align:t,sideOffset:r,alignOffset:n,avoidCollisions:o,collisionPadding:a});Bo(v,()=>{k&&p(false);},m);let w=N.current?.filter(Boolean).length||0,W=useCallback(T=>{let P=N.current?.[T];P&&!P.hasAttribute("data-disabled")&&P.click();},[N]);Rs({isOpen:m,onClose:()=>{y&&(p(false),C.current?.focus());},itemsCount:w,focusedIndex:R,setFocusedIndex:f,onSelect:W}),useEffect(()=>{let T=v.current;if(T)return oo(T,()=>C.current)},[v,C]),useEffect(()=>{if(m&&N.current&&N.current.length>0){let T=setTimeout(()=>{f(0),N.current?.[0]?.focus();},10);return ()=>clearTimeout(T)}},[m,N,f]),useLayoutEffect(()=>{let T=0;if(!m){E(false);return}let P=()=>{let x=C.current?.getBoundingClientRect(),D=v.current?.getBoundingClientRect();if(I.isReady&&!!x&&!!D&&x.width>0&&x.height>0&&D.width>0&&D.height>0){E(true);return}T=requestAnimationFrame(P);};return E(false),T=requestAnimationFrame(P),()=>{T&&cancelAnimationFrame(T);}},[m,I.isReady,C,v]);let M=jsxs(Fragment,{children:[z&&m&&jsx("div",{className:"fixed inset-0 z-40 bg-black/20",onClick:()=>p(false)}),jsx("div",{ref:v,id:h,role:"menu","aria-orientation":"vertical","aria-hidden":!m,tabIndex:-1,style:{position:"fixed",top:I.top,left:I.left,minWidth:s??C.current?.offsetWidth,maxWidth:l,maxHeight:i,visibility:m&&L?"visible":"hidden",opacity:m&&L?1:0,pointerEvents:m&&L?"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&&L&&Zh[c],b),children:jsx("div",{className:"py-1",children:u})})]});return d&&typeof document<"u"?createPortal(M,document.body):M}Vd.displayName="DropdownContent";var ny={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 Fd({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,...b}){let{setIsOpen:m,closeOnSelect:p,focusedIndex:C,setFocusedIndex:v,registerItem:k,getNextItemIndex:y}=wr(),z=useRef(null),[h]=useState(()=>u??y());useEffect(()=>(k(h,z.current),()=>{k(h,null);}),[h,k]);let R=s??p,f=C===h;return jsxs("button",{ref:z,role:"menuitem",type:"button",tabIndex:f?0:-1,disabled:i,"data-disabled":i||void 0,"data-focused":f||void 0,onClick:E=>{i||(l?.(),d?.(E),R&&m(false));},onMouseEnter:()=>{i||v(h);},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",ny[a],i&&"opacity-50 cursor-not-allowed hover:bg-transparent",f&&"bg-gray-100 dark:bg-gray-700",c),...b,children:[t&&r==="left"&&jsx("span",{className:"mr-2 shrink-0 w-5 h-5",children:t}),jsxs("span",{className:"flex-1 min-w-0",children:[jsx("span",{className:"block truncate",children:e}),n&&jsx("span",{className:"block text-xs text-gray-500 dark:text-gray-400 truncate",children:n})]}),t&&r==="right"&&jsx("span",{className:"ml-2 shrink-0 w-5 h-5",children:t}),o&&jsx("span",{className:"ml-auto pl-4 text-xs text-gray-400 dark:text-gray-500",children:o})]})}Fd.displayName="DropdownItem";function Od({className:e}){return jsx("hr",{className:g("my-1 h-px border-0 bg-gray-200 dark:bg-gray-700",e)})}Od.displayName="DropdownSeparator";function $d({children:e,className:t}){return jsx("div",{className:g("px-3 py-1.5 text-xs font-semibold text-gray-500 dark:text-gray-400",t),children:e})}$d.displayName="DropdownLabel";function Kd({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:b,registerItem:m,getNextItemIndex:p}=wr(),C=useRef(null),[v]=useState(()=>c??p()),[k,y]=useState(t),z=e!==void 0,h=z?e:k;useEffect(()=>(m(v,C.current),()=>{m(v,null);}),[v,m]);let R=u===v;return jsxs("button",{ref:C,role:"menuitemcheckbox",type:"button",tabIndex:R?0:-1,"aria-checked":h,disabled:s,"data-disabled":s||void 0,"data-focused":R||void 0,onClick:()=>{if(s)return;let L=!h;z||y(L),r?.(L),l&&d(false);},onMouseEnter:()=>{s||b(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",R&&"bg-gray-100 dark:bg-gray-700",i),children:[jsx("span",{className:"mr-2 shrink-0 w-4 h-4",children:o||jsx("span",{className:g("flex items-center justify-center w-4 h-4 rounded border-2 transition-colors",h?"bg-blue-600 border-blue-600":"border-gray-300 dark:border-gray-600"),children:h&&jsx("svg",{className:"w-3 h-3 text-white",viewBox:"0 0 16 16",fill:"none",children:jsx("path",{d:"M13.5 4.5L6 12L2.5 8.5",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round"})})})}),jsxs("span",{className:"flex-1 min-w-0",children:[jsx("span",{className:"block truncate",children:n}),a&&jsx("span",{className:"block text-xs text-gray-500 dark:text-gray-400 truncate",children:a})]})]})}Kd.displayName="DropdownCheckboxItem";var qd=createContext(null);function my(){let e=useContext(qd);if(!e)throw new Error("DropdownRadioItem must be used within a DropdownRadioGroup");return e}function jd({value:e,defaultValue:t="",onValueChange:r,children:n,className:o}){let[a,s]=useState(t),l=e!==void 0,i=l?e:a,c=useCallback(u=>{l||s(u),r?.(u);},[l,r]),d=useMemo(()=>({value:i,onValueChange:c}),[i,c]);return jsx(qd.Provider,{value:d,children:jsx("div",{role:"group",className:o,children:n})})}jd.displayName="DropdownRadioGroup";function Zd({value:e,children:t,icon:r,description:n,disabled:o=false,closeOnChange:a=true,className:s,index:l}){let{value:i,onValueChange:c}=my(),{setIsOpen:d,focusedIndex:u,setFocusedIndex:b,registerItem:m,getNextItemIndex:p}=wr(),C=useRef(null),[v]=useState(()=>l??p()),k=i===e;useEffect(()=>(m(v,C.current),()=>{m(v,null);}),[v,m]);let y=u===v;return jsxs("button",{ref:C,role:"menuitemradio",type:"button",tabIndex:y?0:-1,"aria-checked":k,disabled:o,"data-disabled":o||void 0,"data-focused":y||void 0,onClick:()=>{o||(c(e),a&&d(false));},onMouseEnter:()=>{o||b(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",y&&"bg-gray-100 dark:bg-gray-700",s),children:[jsx("span",{className:"mr-2 shrink-0 w-4 h-4",children:r||jsx("span",{className:g("flex items-center justify-center w-4 h-4 rounded-full border-2 transition-colors",k?"border-blue-600":"border-gray-300 dark:border-gray-600"),children:k&&jsx("span",{className:"w-2 h-2 rounded-full bg-blue-600"})})}),jsxs("span",{className:"flex-1 min-w-0",children:[jsx("span",{className:"block truncate",children:t}),n&&jsx("span",{className:"block text-xs text-gray-500 dark:text-gray-400 truncate",children:n})]}),k&&!r&&jsx("svg",{className:"ml-auto w-4 h-4 text-blue-600",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M5 13l4 4L19 7"})})]})}Zd.displayName="DropdownRadioItem";var tu=createContext(null);function ru(){let e=useContext(tu);if(!e)throw new Error("DropdownSubMenu components must be used within a DropdownSubMenu");return e}function nu({children:e}){let[t,r]=useState(false),n=useRef(null),o=useRef(null),a=useMemo(()=>({isOpen:t,setIsOpen:r,triggerRef:n,contentRef:o}),[t]);return jsx(tu.Provider,{value:a,children:jsx("div",{className:"relative",children:e})})}nu.displayName="DropdownSubMenu";var Jd=0;function ou({children:e,icon:t,disabled:r=false,className:n,index:o}){let{isOpen:a,setIsOpen:s,triggerRef:l}=ru(),{focusedIndex:i,setFocusedIndex:c,registerItem:d}=wr(),u=useRef(o??-1);useEffect(()=>(o===void 0&&(u.current=Jd++),d(u.current,l.current),()=>{d(u.current,null);}),[o,d,l]),useEffect(()=>()=>{Jd=0;},[]);let b=i===u.current;return jsxs("button",{ref:l,role:"menuitem",type:"button",tabIndex:b?0:-1,"aria-haspopup":"menu","aria-expanded":a,disabled:r,"data-disabled":r||void 0,"data-focused":b||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",b&&"bg-gray-100 dark:bg-gray-700",n),children:[t&&jsx("span",{className:"mr-2 shrink-0 w-5 h-5",children:t}),jsx("span",{className:"flex-1",children:e}),jsx("svg",{className:"ml-auto w-4 h-4 text-gray-400",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 5l7 7-7 7"})})]})}ou.displayName="DropdownSubMenuTrigger";function au({children:e,sideOffset:t=0,className:r}){let{isOpen:n,setIsOpen:o,triggerRef:a,contentRef:s}=ru(),[l,i]=useState(false),c=Fo({triggerRef:a,contentRef:s,isOpen:n,side:"right",align:"start",sideOffset:t,avoidCollisions:true});Bo(s,()=>o(false),n),useEffect(()=>{let p=s.current;if(p)return oo(p,()=>a.current)},[s,a]);let d=useCallback(()=>{o(true);},[o]),u=useCallback(()=>{o(false);},[o]),b=p=>{(p.key==="ArrowLeft"||p.key==="Escape")&&(p.preventDefault(),o(false),a.current?.focus());};useLayoutEffect(()=>{let p=0;if(!n){i(false);return}let C=()=>{let v=a.current?.getBoundingClientRect(),k=s.current?.getBoundingClientRect();if(c.isReady&&!!v&&!!k&&v.width>0&&v.height>0&&k.width>0&&k.height>0){i(true);return}p=requestAnimationFrame(C);};return i(false),p=requestAnimationFrame(C),()=>{p&&cancelAnimationFrame(p);}},[n,c.isReady,a,s]);let m=jsx("div",{ref:s,role:"menu","aria-orientation":"vertical","aria-hidden":!n,tabIndex:-1,onMouseEnter:d,onMouseLeave:u,onKeyDown:b,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:jsx("div",{className:"py-1",children:e})});return typeof document<"u"?createPortal(m,document.body):m}au.displayName="DropdownSubMenuContent";var xy=(e="md")=>({sm:"text-xs p-1.5",md:"text-sm p-2.5",lg:"text-base p-3.5"})[e],$o=({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",xy(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"),su=(e,t)=>g("text-sm font-medium",e?"min-w-[120px]":"block mb-2",!t&&"text-gray-900 dark:text-white"),iu=e=>g("mt-1 text-xs",e?"text-red-500 dark:text-red-400":"text-gray-500 dark:text-gray-400"),io=e=>g("absolute inset-y-0 flex items-center pointer-events-none",e==="left"?"left-2.5":"right-2.5");var _o=({label:e,hideLabel:t,labelColor:r,error:n,helperText:o,inline:a,children:s,htmlFor:l})=>jsxs("div",{className:a?"flex items-center gap-4":"flex flex-col",children:[e&&!t&&jsx("label",{htmlFor:l,className:su(a||false,r),style:r?{color:r}:void 0,children:e}),jsx("div",{className:a?"flex-1":"w-full",children:s}),o&&jsx("p",{className:g(iu(n),a&&"ml-34"),children:o})]});var an=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:b="left",multiline:m=false,rows:p=3,focused:C=false,className:v,...k},y)=>{let z=useRef(null),h=I=>{z.current=I,typeof y=="function"?y(I):y&&(y.current=I);};useEffect(()=>{C&&z.current?.focus();},[C]);let R=useId(),f=g($o({size:r,error:i,disabled:s,readOnly:l,icon:u,iconPosition:b}),m&&"resize-vertical",v),N={...o&&{borderColor:o},...a&&{color:a}},L=o||a?N:void 0;return jsx(_o,{label:e,hideLabel:d,labelColor:n,error:i,helperText:c,inline:t,htmlFor:R,children:jsxs("div",{className:"relative w-full",children:[u&&jsx("span",{className:io(b),children:u}),m?jsx("textarea",{ref:h,id:R,disabled:s,readOnly:l,rows:p,tabIndex:l||s?-1:void 0,className:f,style:L,...k}):jsx("input",{ref:h,id:R,disabled:s,readOnly:l,tabIndex:l||s?-1:void 0,className:f,style:L,...k})]})})});an.displayName="Input";var Dy=e=>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&&jsx("img",{src:e.avatar,alt:e.label,className:"w-6 h-6 rounded-full"}),jsx("span",{className:"text-sm text-gray-900 dark:text-white",children:e.label})]}),al=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:b="left",mentionTrigger:m="@",suggestions:p=[],onMentionSearch:C,onMentionSelect:v,onMentionRemove:k,renderSuggestion:y,value:z,onChange:h,placeholder:R,loading:f=false,maxSuggestions:N=10,chipVariant:L="soft",chipColor:E="primary",chipSize:I="sm"},w)=>{let W=useId(),M=useRef(null),[T,P]=useState(false),[x,D]=useState(0),[S,B]=useState(""),H=g($o({size:r,error:i,disabled:s,readOnly:l,icon:u,iconPosition:b}),"min-h-[42px]","whitespace-pre-wrap","break-words"),$={...o&&{borderColor:o},...a&&{color:a}},_=o||a?$:void 0,F=useCallback(()=>{if(!M.current)return {text:"",mentions:[]};let O="",K=[],se=0,ae=U=>{if(U.nodeType===Node.TEXT_NODE)O+=U.textContent||"",se+=(U.textContent||"").length;else if(U.nodeType===Node.ELEMENT_NODE){let J=U;if(J.hasAttribute("data-mention-id")){let te=J.getAttribute("data-mention-id"),ie=J.getAttribute("data-mention-label")||"",Q=J.getAttribute("data-mention-avatar")||void 0,ge=`@${ie}`,Re=se;K.push({trigger:m,suggestion:{id:te||"",label:ie,avatar:Q},startIndex:Re,endIndex:Re+ge.length}),O+=ge,se+=ge.length;}else J.childNodes.forEach(ae);}};return M.current.childNodes.forEach(ae),{text:O,mentions:K}},[m]),A=useCallback((O,K)=>{let se=document.createElement("span");return se.contentEditable="false",se.setAttribute("data-mention-id",O.id),se.setAttribute("data-mention-label",O.label),O.avatar&&se.setAttribute("data-mention-avatar",O.avatar),se.className="inline-block align-middle mx-0.5",se.style.userSelect="none",createRoot(se).render(jsx(xs,{label:O.label,variant:L,color:E,size:I,closable:!s&&!l,onClose:K,disabled:s,avatar:O.avatar?jsx("img",{src:O.avatar,alt:O.label,className:"w-full h-full object-cover"}):void 0})),se},[L,E,I,s,l]),V=useCallback(O=>{if(!M.current)return;let K=M.current.querySelector(`[data-mention-id="${O}"]`);if(K){K.remove();let se=F();h?.(se);let ae=z?.mentions.find(U=>U.suggestion.id===O)?.suggestion;ae&&k?.(ae);}},[F,h,k,z?.mentions]),Y=useCallback(()=>{if(!M.current)return;let O=window.getSelection();if(!O||O.rangeCount===0)return;let K=O.getRangeAt(0),se="";K.startContainer.nodeType===Node.TEXT_NODE&&(se=K.startContainer.textContent?.substring(0,K.startOffset)||"");let ae=se.match(new RegExp(`${m}(\\w*)$`));if(ae){let J=ae[1];B(J),P(true),D(0),C?.(J);}else P(false),B("");let U=F();h?.(U);},[m,C,h,F]),X=useCallback(O=>{if(!M.current)return;let K=window.getSelection();if(!K||K.rangeCount===0)return;let se=K.getRangeAt(0);if(se.startContainer.nodeType===Node.TEXT_NODE){let U=se.startContainer,J=U.textContent||"",te=se.startOffset,Q=J.substring(0,te).lastIndexOf(m);if(Q!==-1){let ge=J.substring(0,Q),Re=J.substring(te),Qe=A(O,()=>{V(O.id);});if(ge?(U.textContent=ge,U.parentNode?.insertBefore(Qe,U.nextSibling)):(U.parentNode?.insertBefore(Qe,U),U.textContent="",U.textContent||U.remove()),Re){let me=document.createTextNode(Re);Qe.parentNode?.insertBefore(me,Qe.nextSibling);}let at=document.createTextNode(" ");Qe.parentNode?.insertBefore(at,Qe.nextSibling);let et=document.createRange();et.setStartAfter(at),et.collapse(true),K.removeAllRanges(),K.addRange(et);}}P(false),B("");let ae=F();h?.(ae),v?.(O),M.current.focus();},[m,A,V,F,h,v]),G=useCallback(O=>{let K=p.slice(0,N);if(T&&K.length>0)switch(O.key){case "ArrowDown":O.preventDefault(),D(se=>se<K.length-1?se+1:0);return;case "ArrowUp":O.preventDefault(),D(se=>se>0?se-1:K.length-1);return;case "Enter":case "Tab":O.preventDefault(),K[x]&&X(K[x]);return;case "Escape":O.preventDefault(),P(false);return}if(O.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 J=U;if(J.hasAttribute("data-mention-id")){O.preventDefault();let te=J.getAttribute("data-mention-id");te&&V(te);return}}}if(ae.collapsed&&ae.startContainer.nodeType===Node.TEXT_NODE){let U=ae.startContainer;if(ae.startOffset===0){let J=U.previousSibling;if(J&&J.nodeType===Node.ELEMENT_NODE){let te=J;if(te.hasAttribute("data-mention-id")){O.preventDefault();let ie=te.getAttribute("data-mention-id");ie&&V(ie);return}}}}}},[T,p,x,N,X,V]);return useEffect(()=>{M.current&&(!(M.current.textContent||M.current.querySelector("[data-mention-id]"))&&R?M.current.setAttribute("data-placeholder",R):M.current.removeAttribute("data-placeholder"));},[R,z]),useEffect(()=>{M.current&&z?.text===""&&z?.mentions.length===0&&M.current.innerHTML.trim()&&(M.current.innerHTML="");},[z?.text,z?.mentions.length]),jsx(_o,{label:e,hideLabel:d,labelColor:n,error:i,helperText:c,inline:t,htmlFor:W,children:jsxs("div",{className:"relative w-full",children:[u&&jsx("span",{className:io(b),children:u}),jsx("div",{ref:O=>{typeof w=="function"?w(O):w&&(w.current=O),M.current=O;},id:W,contentEditable:!s&&!l,suppressContentEditableWarning:true,onInput:Y,onKeyDown:G,className:g(H,"empty:before:content-[attr(data-placeholder)] empty:before:text-gray-400 empty:before:dark:text-gray-500"),style:_,role:"textbox","aria-label":e,"aria-multiline":"true",tabIndex:l||s?-1:0}),T&&p.length>0&&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:f?jsx("div",{className:"px-3 py-2 text-sm text-gray-500 dark:text-gray-400",children:"Loading..."}):p.slice(0,N).map((O,K)=>jsx("div",{onClick:()=>X(O),className:g(K===x&&"bg-gray-100 dark:bg-gray-600"),children:y?y(O):Dy(O)},O.id))})]})})});al.displayName="MentionInput";var sl=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:b="left",className:m,value:p,onChange:C,format:v="number",currency:k="USD",locale:y="en-US",decimals:z,min:h,max:R,step:f=1,prefix:N,suffix:L,thousandSeparator:E=true,allowNegative:I=true,onBlur:w,onFocus:W,...M},T)=>{let P=useId(),[x,D]=useState(null),S=useMemo(()=>{let j=v==="currency"?{style:"currency",currency:k,minimumFractionDigits:z??2,maximumFractionDigits:z??2}:v==="percentage"?{minimumFractionDigits:z??0,maximumFractionDigits:z??2}:{minimumFractionDigits:z??0,maximumFractionDigits:z??(v==="decimal"?2:0),useGrouping:E};try{return new Intl.NumberFormat(y,j)}catch{return null}},[v,k,y,z,E]),B=j=>{if(j==null)return "";if(!S)return String(j);let O=S.format(j);return v==="percentage"?(O=N?`${N}${O}`:O,O=L||!O.includes("%")?`${O}%`:O,O):(N&&(O=`${N}${O}`),L&&(O=`${O}${L}`),O)},H=j=>{if(!j||j.trim()==="")return null;let O=j;if(N&&(O=O.replace(N,"")),L&&(O=O.replace(L,"")),O=O.replace(/[^\d.,-]/g,""),y.includes("fr")||y.includes("de")?O=O.replace(/\s/g,"").replace(",","."):O=O.replace(",",""),!O||O==="-"||O===".")return null;let K=parseFloat(O);return isNaN(K)?null:!I&&K<0?Math.abs(K):h!==void 0&&K<h?h:R!==void 0&&K>R?R:K},$=x??B(p??null),_=j=>{let O=y.includes("fr")||y.includes("de")?",":".";return new RegExp(`^-?[0-9${O===","?",":"\\."}]*$`).test(j)},F=j=>{let O=j.target.value;if(O===""||_(O)){D(O);let K=H(O);C&&C(K);}},A=j=>{let O=y.includes("fr")||y.includes("de")?",":".",K=["Backspace","Delete","Tab","Escape","Enter","ArrowLeft","ArrowRight","ArrowUp","ArrowDown","Home","End"],se=/^[0-9]$/.test(j.key),ae=j.key===O,U=j.key==="-"&&I&&$.indexOf("-")===-1,J=j.ctrlKey||j.metaKey;!se&&!ae&&!U&&!K.includes(j.key)&&!J&&j.preventDefault();},V=j=>{let O=p!=null?String(p):"";D(O),W&&W(j);},Y=j=>{let O=H(x??"");C&&O!==p&&C(O),D(null),w&&w(j);},X=g($o({size:r,error:i,disabled:s,readOnly:l,icon:u,iconPosition:b}),o&&`border-[${o}]`,a&&`text-[${a}]`,m),G=jsxs("div",{className:"relative",children:[u&&b==="left"&&jsx("div",{className:io(b),children:u}),jsx("input",{ref:T,id:P,type:"text",inputMode:"decimal",className:X,style:{borderColor:o,color:a},disabled:s,readOnly:l,value:$,onChange:F,onKeyDown:A,onFocus:V,onBlur:Y,...M}),u&&b==="right"&&jsx("div",{className:io(b),children:u})]});return jsx(_o,{label:e,hideLabel:d,labelColor:n,error:i,helperText:c,inline:t,htmlFor:P,children:G})});sl.displayName="NumberInput";function Wy({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:b,navItemBgHover:m,navItemActiveColor:p,sticky:C=false,fixed:v=false,showSearch:k=false,onSearch:y,searchPlaceholder:z="Search...",className:h,containerClassName:R}){let[f,N]=useState(false),[L,E]=useState(null),[I,w]=useState(""),W=()=>{N(!f);},M=F=>{E(L===F?null:F);},T=F=>{F.preventDefault(),y&&y(I);},P=g(C&&"sticky top-0 z-50",v&&"fixed top-0 left-0 right-0 z-50"),x=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"),D=g(l==="sm"&&"py-2",l==="md"&&"py-4",l==="lg"&&"py-6"),S=i||"",B=c||"",H=d||"",$=g(P,x,D,S,B,h),_=(F,A,V=false)=>{let Y=F.children&&F.children.length>0,X=L===A,G=g("px-4 py-2 transition-colors flex items-center gap-2",V?"block w-full text-left":"inline-flex",F.active&&"font-semibold border-b-2",F.active&&(p||"border-current"),u||(s==="default"||s==="transparent"?"text-gray-300":"text-gray-600 dark:text-gray-300"),b||H||(s==="default"||s==="transparent"?"hover:text-white":"hover:text-blue-600 dark:hover:text-blue-400"),m||"");if(Y)return jsxs("div",{className:V?"w-full":"relative",children:[jsxs("button",{type:"button",onClick:()=>M(A),className:G,children:[F.icon&&jsx("span",{className:"w-5 h-5",children:F.icon}),jsx("span",{children:F.label}),F.badge&&jsx("span",{className:"bg-red-500 text-white text-xs px-2 py-0.5 rounded-full",children:F.badge}),jsx("svg",{className:g("w-4 h-4 transition-transform",X&&"rotate-180"),fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 9l-7 7-7-7"})})]}),X&&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:F.children?.map(O=>jsx("a",{href:O.href,onClick:O.onClick,target:O.external?"_blank":void 0,rel:O.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:jsxs("div",{className:"flex items-center gap-2",children:[O.icon&&jsx("span",{className:"w-5 h-5",children:O.icon}),jsx("span",{children:O.label}),O.badge&&jsx("span",{className:"bg-red-500 text-white text-xs px-2 py-0.5 rounded-full ml-auto",children:O.badge}),O.external&&jsx("svg",{className:"w-4 h-4 ml-auto",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children: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"})})]})},O.href??O.label))})]},F.href??F.label);let j=jsxs(Fragment,{children:[F.icon&&jsx("span",{className:"w-5 h-5",children:F.icon}),jsx("span",{children:F.label}),F.badge&&jsx("span",{className:"bg-red-500 text-white text-xs px-2 py-0.5 rounded-full",children:F.badge}),F.external&&jsx("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children: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 F.onClick?jsx("button",{type:"button",onClick:F.onClick,className:G,children:j},F.href??F.label):jsx("a",{href:F.href,target:F.external?"_blank":void 0,rel:F.external?"noopener noreferrer":void 0,className:G,children:j},F.href??F.label)};return jsxs("header",{className:$,children:[jsxs("nav",{className:g("container mx-auto flex items-center justify-between px-4",R),children:[e&&jsx("div",{className:"flex items-center",children:t?jsx("a",{href:t,onClick:r,className:"flex items-center hover:opacity-80 transition-opacity",children:e}):jsx("div",{className:"flex items-center",children:e})}),k&&jsx("form",{onSubmit:T,className:"hidden md:flex flex-1 max-w-md mx-8",children:jsx("input",{type:"search","aria-label":z,value:I,onChange:F=>w(F.target.value),placeholder:z,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"})}),jsx("div",{className:"hidden md:flex items-center gap-2",children:n.map((F,A)=>_(F,A,false))}),(o||a)&&jsxs("div",{className:"hidden md:flex items-center gap-2 ml-4",children:[o,a]}),n.length>0&&jsx("div",{className:"md:hidden",children: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:W,"aria-label":"Toggle menu","aria-expanded":f,children: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:jsx("path",{stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",d:"M1 1h15M1 7h15M1 13h15"})})})})]}),f&&n.length>0&&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:jsxs("div",{className:"flex flex-col py-2 px-4",children:[k&&jsx("form",{onSubmit:T,className:"mb-4",children:jsx("input",{type:"search","aria-label":z,value:I,onChange:F=>w(F.target.value),placeholder:z,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((F,A)=>_(F,A,true)),(o||a)&&jsxs("div",{className:"flex flex-col gap-2 mt-4 pt-4 border-t border-gray-700",children:[o,a]})]})})]})}var Oy=jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[jsx("path",{d:"M11 4H4a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7"}),jsx("path",{d:"M18.5 2.5a2.121 2.121 0 0 1 3 3L12 15l-4 1 1-4 9.5-9.5z"})]}),$y=jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[jsx("path",{d:"M19 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h11l5 5v11a2 2 0 0 1-2 2z"}),jsx("polyline",{points:"17 21 17 13 7 13 7 21"}),jsx("polyline",{points:"7 3 7 8 15 8"})]}),_y=jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]}),Xy=jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[jsx("polyline",{points:"1 4 1 10 7 10"}),jsx("path",{d:"M3.51 15a9 9 0 1 0 2.13-9.36L1 10"})]}),Gy=jsxs("svg",{className:"animate-spin h-4 w-4",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10"}),jsx("path",{className:"opacity-75",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4z",fill:"currentColor"})]}),Ky={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"},Uy={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"},Yy={sm:"w-56",md:"w-72",lg:"w-96",xl:"w-[32rem]"},qy=[Fy],jy={h1:({...e})=>jsx("h1",{className:"text-xl font-bold mb-2 text-gray-900 dark:text-gray-100",...e}),h2:({...e})=>jsx("h2",{className:"text-lg font-semibold mt-4 mb-2 text-gray-900 dark:text-gray-100",...e}),h3:({...e})=>jsx("h3",{className:"text-base font-semibold mt-3 mb-1 text-gray-900 dark:text-gray-100",...e}),p:({...e})=>jsx("p",{className:"my-1 text-gray-700 dark:text-gray-300",...e}),ul:({...e})=>jsx("ul",{className:"list-disc list-inside space-y-1 my-2 text-gray-700 dark:text-gray-300",...e}),ol:({...e})=>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-")?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}):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})=>jsx("pre",{className:"my-2",...e}),a:({...e})=>jsx("a",{className:"text-blue-600 dark:text-blue-400 hover:underline",...e}),strong:({...e})=>jsx("strong",{className:"font-semibold text-gray-900 dark:text-gray-100",...e}),em:({...e})=>jsx("em",{className:"italic",...e}),blockquote:({...e})=>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 du({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:b}){let m=Ge(),[p,C]=useState(false),[v,k]=useState(false),[y,z]=useState(""),[h,R]=useState(false),[f,N]=useState(null),L=useRef(null),E=useRef(null),I=useRef(null),w=useRef(null);useEffect(()=>{if(!p)return;let D=B=>{L.current&&!L.current.contains(B.target)&&E.current&&!E.current.contains(B.target)&&(v||C(false));},S=B=>{B.key==="Escape"&&(v?(k(false),z("")):C(false));};return document.addEventListener("mousedown",D),document.addEventListener("keydown",S),()=>{document.removeEventListener("mousedown",D),document.removeEventListener("keydown",S);}},[p,v]),useEffect(()=>{v&&I.current&&I.current.focus();},[v]),useEffect(()=>()=>{w.current&&clearTimeout(w.current);},[]);let W=useCallback(()=>{z(typeof e=="string"?e:""),k(true),N(null);},[e]),M=useCallback(()=>{k(false),z(""),N(null);},[]),T=useCallback(async()=>{if(!l){N({type:"error",text:"Aucune fonction de sauvegarde fournie"});return}R(true);try{await l(y)?(N({type:"success",text:"Sauvegard\xE9 avec succ\xE8s !"}),k(!1),w.current&&clearTimeout(w.current),w.current=setTimeout(()=>N(null),2e3)):N({type:"error",text:"Erreur lors de la sauvegarde"});}catch{N({type:"error",text:"Erreur lors de la sauvegarde"});}finally{R(false);}},[y,l]),P=useCallback(async()=>{if(i&&confirm("\xCAtes-vous s\xFBr de vouloir r\xE9initialiser ce contenu ?")){R(true);try{await i()?(N({type:"success",text:"R\xE9initialis\xE9 avec succ\xE8s !"}),k(!1),w.current&&clearTimeout(w.current),w.current=setTimeout(()=>N(null),2e3)):N({type:"error",text:"Erreur lors de la r\xE9initialisation"});}catch{N({type:"error",text:"Erreur lors de la r\xE9initialisation"});}finally{R(false);}}},[i]),x=e;return a?jsxs("div",{className:"relative inline-flex items-center",children:[jsx("button",{type:"button",ref:L,onClick:()=>C(!p),className:`
3
+ ${Ky[n]}
4
4
  inline-flex items-center justify-center
5
5
  rounded-full border border-gray-300 dark:border-gray-600
6
6
  bg-white dark:bg-gray-800
@@ -11,21 +11,21 @@ import*as Ns from'react';import Ns__default,{createContext,forwardRef,memo,useId
11
11
  hover:border-gray-400 dark:hover:border-gray-500
12
12
  transition-all duration-150
13
13
  focus:outline-none focus:ring-2 focus:ring-blue-500/50
14
- ${n}
15
- `,"aria-label":"Afficher l'aide","aria-expanded":f,children:jsx("span",{className:"font-medium",children:"?"})}),f&&jsxs("div",{ref:D,className:`
16
- absolute z-50 ${Qf[r]}
17
- ${eb[d]} max-h-[80vh] overflow-hidden flex flex-col
14
+ ${o}
15
+ `,"aria-label":"Afficher l'aide","aria-expanded":p,children:jsx("span",{className:"font-medium",children:"?"})}),p&&jsxs("div",{ref:E,className:`
16
+ absolute z-50 ${Uy[r]}
17
+ ${Yy[c]} max-h-[80vh] overflow-hidden flex flex-col
18
18
  bg-white dark:bg-gray-900
19
19
  border border-gray-200 dark:border-gray-700
20
20
  rounded-xl shadow-xl
21
21
  text-sm text-gray-700 dark:text-gray-300
22
22
  animate-in fade-in-0 zoom-in-95 duration-150
23
- `,role:"tooltip",children:[(u||s)&&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:[jsx("div",{className:"flex items-center gap-2",children:u&&jsx("h3",{className:"text-sm font-semibold",children:u})}),s&&jsx("div",{className:"flex items-center gap-1",children:y?jsxs(Fragment,{children:[jsx("button",{type:"button",onClick:w,disabled:k,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:k?Zf:Yf}),jsx("button",{type:"button",onClick:M,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:jf}),i&&jsx("button",{type:"button",onClick:N,disabled:k,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:qf})]}):jsx("button",{type:"button",onClick:_,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:Uf})})]}),g&&jsx("div",{className:`px-4 py-2 text-xs ${g.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:g.text}),jsx("div",{className:"flex-1 overflow-y-auto p-4",children:y?t?p?jsx(p,{value:v,onChange:E,placeholder:"\xC9crivez en Markdown..."}):jsx("p",{role:"alert",className:"p-3 text-sm text-gray-500 dark:text-gray-400",children:b??m.markdownEditorUnavailable}):jsx("div",{className:"space-y-2",children:jsx("textarea",{ref:W,"aria-label":"Contenu d'aide",value:v,onChange:S=>E(S.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 x=="string"?jsx("div",{className:"prose prose-sm dark:prose-invert max-w-none",children:t?jsx(Xf,{remarkPlugins:tb,components:rb,children:x}):jsx("div",{dangerouslySetInnerHTML:{__html:Gf.sanitize(x)}})}):x})]})]}):null}function ob({children:e,content:t,markdown:r=false,position:o="bottom",size:n="sm",visible:a=true,editable:s=false,onSave:l,onReset:i,width:d="md",title:u,className:p,markdownEditor:b,markdownEditorUnavailableLabel:m}){return jsxs("div",{className:"inline-flex items-center gap-2.5",children:[e,jsx(Wd,{content:t,markdown:r,position:o,size:n,visible:a,editable:s,onSave:l,onReset:i,width:d,title:u,className:p,markdownEditor:b,markdownEditorUnavailableLabel:m})]})}var lb={"16/9":"aspect-[16/9]","4/3":"aspect-[4/3]","1/1":"aspect-square",auto:""},db=e=>new Promise((t,r)=>{let o=new FileReader;o.onload=n=>{let a=n.target?.result;t(a);},o.onerror=()=>{r(new Error("Erreur lors de la lecture du fichier"));},o.readAsDataURL(e);});function cb({value:e,onChange:t,onUpload:r,label:o="Image",maxSize:n=5*1024*1024,accept:a="image/*",helpText:s,disabled:l=false,className:i="",showUrlInput:d=true,urlPlaceholder:u="https://example.com/image.jpg",aspectRatio:p="16/9"}){let[b,m]=useState(false),[f,h]=useState(null),y=useRef(null),C=useId(),v=useMemo(()=>(n/(1024*1024)).toFixed(0),[n]),E=`Formats accept\xE9s : ${a==="image/*"?"JPG, PNG, GIF, WebP":a} (max ${v}MB)`,k=useCallback(async D=>{let W=D.target.files?.[0];if(W){if(!W.type.startsWith("image/")){h("Le fichier doit \xEAtre une image");return}if(W.size>n){h(`Le fichier est trop volumineux (max ${v}MB)`);return}m(true),h(null);try{if(r){let V=await r(W);t(V);}else {let V=await db(W);t(V);}y.current&&(y.current.value="");}catch(V){console.error("Upload error:",V),h(V instanceof Error?V.message:"Erreur lors de l'upload");}finally{m(false);}}},[n,v,t,r]),R=useCallback(()=>{t(""),y.current&&(y.current.value=""),h(null);},[t]),g=useCallback(D=>{t(D),h(null);},[t]),P=useCallback(()=>{y.current?.click();},[]),T=useCallback(D=>{g(D.target.value);},[g]);return jsxs("div",{className:`space-y-2 ${i}`,children:[o&&jsx("label",{className:"block text-sm font-semibold text-gray-700 dark:text-gray-300",children:o}),e&&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:[jsx("div",{className:`relative ${lb[p]} ${p==="auto"?"max-h-64":""} flex items-center justify-center`,children:jsx("img",{src:e,alt:"Aper\xE7u",className:"w-full h-full object-contain"})}),jsx("button",{type:"button",onClick:R,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"})]}),jsxs("div",{className:"flex gap-2",children:[jsx("input",{ref:y,type:"file","aria-label":"Choisir une image",accept:a,onChange:k,className:"hidden",disabled:l||b}),jsx("button",{type:"button",onClick:P,disabled:l||b,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:b?"\u23F3 Upload...":e?"\u{1F4C1} Changer l'image":"\u{1F4C1} Choisir une image"})]}),d&&jsxs("div",{className:"space-y-1",children:[jsx("label",{htmlFor:C,className:"block text-xs text-gray-500 dark:text-gray-400",children:"Ou URL directe :"}),jsx("input",{id:C,type:"url",value:e||"",onChange:T,placeholder:u,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"})]}),f&&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 ",f]}),jsx("div",{className:"text-xs text-gray-500 dark:text-gray-400",children:s||E})]})}var La={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"},Ys={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"},ub={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"},js={"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"},qs={"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 pb(e,t){return e>t?`${t}+`:`${e}`}function gb({color:e="primary",size:t="md",placement:r="top-right",bordered:o=false,borderColor:n,pulse:a=false,offset:s=false,className:l,...i}){return jsx("span",{"data-testid":"indicator",className:c("absolute z-10 rounded-full",La[e],Ys[t],s?qs[r]:js[r],o&&c("ring-2 ring-white dark:ring-gray-900",n),a&&"animate-pulse",l),...i})}function mb({color:e="error",size:t="md",placement:r="top-right",count:o=0,maxCount:n=99,bordered:a=false,borderColor:s,pulse:l=false,offset:i=false,className:d,...u}){return jsx("span",{"data-testid":"indicator",className:c("absolute z-10 inline-flex items-center justify-center rounded-full font-semibold text-white",La[e],ub[t],i?qs[r]:js[r],a&&c("ring-2 ring-white dark:ring-gray-900",s),l&&"animate-pulse",d),...u,children:pb(o,n)})}function fb({color:e="success",size:t="md",placement:r="bottom-right",bordered:o=true,borderColor:n,pulse:a=false,offset:s=false,className:l,...i}){return jsx("span",{"data-testid":"indicator",className:c("absolute z-10 rounded-full",La[e],Ys[t],s?qs[r]:js[r],o&&c("ring-2 ring-white dark:ring-gray-900",n),a&&"animate-pulse",l),...i})}function bb({color:e="primary",size:t="sm",label:r,className:o,...n}){return jsxs("span",{"data-testid":"indicator",className:c("inline-flex items-center gap-2",o),...n,children:[jsx("span",{className:c("rounded-full shrink-0",La[e],Ys[t])}),r?jsx("span",{className:"text-sm text-gray-700 dark:text-gray-300",children:r}):null]})}function Fd({variant:e="dot",children:t,...r}){if(e==="legend")return jsx(bb,{...r});let o=(()=>{switch(e){case "count":return jsx(mb,{...r});case "status":return jsx(fb,{...r});default:return jsx(gb,{...r})}})();return t?jsxs("div",{className:"relative inline-flex",children:[t,o]}):o}Fd.displayName="Indicator";var hb={xs:"text-xs",sm:"text-sm",md:"text-sm",lg:"text-base",xl:"text-lg"},Vd={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"},yb={normal:"font-normal",medium:"font-medium",semibold:"font-semibold",bold:"font-bold"},xb={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 $d({children:e,size:t="md",color:r="default",variant:o="default",weight:n="medium",textColor:a,required:s=false,requiredIndicator:l="*",optional:i=false,optionalText:d="(optional)",tooltip:u,icon:p,endIcon:b,disabled:m=false,truncate:f=false,as:h="label",className:y,...C}){let v=h,E=c("inline-flex items-center gap-1.5 transition-colors",hb[t],yb[n]),k=a||xb[r][o];return jsxs(v,{className:c(E,k,m?"opacity-50 cursor-not-allowed":"cursor-default",y),title:u,"aria-disabled":m,...C,children:[p&&jsx("span",{className:c("shrink-0",Vd[t]),children:p}),jsxs("span",{className:c(f&&"truncate"),children:[e,s&&jsx("span",{className:"text-red-500 ml-0.5","aria-hidden":"true",children:l}),s&&jsx("span",{className:"sr-only",children:"(required)"})]}),i&&!s&&jsx("span",{className:"text-gray-400 dark:text-gray-500 font-normal",children:d}),b&&jsx("span",{className:c("shrink-0",Vd[t]),children:b})]})}$d.displayName="Label";var kb=24,wb=10,Cb=10,Nb=memo(function({lines:t,showMarkers:r}){return jsx("g",{children:t.map(o=>jsxs("g",{children:[o.solid?jsx("path",{d:o.solid,fill:"none",stroke:o.color,strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"}):null,o.dashed?jsx("path",{d:o.dashed,fill:"none",stroke:o.color,strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round",strokeDasharray:"5 4"}):null,r?o.markers.map(n=>jsx("circle",{cx:n.x,cy:n.y,r:3,fill:o.color,strokeWidth:2,className:"stroke-white dark:stroke-gray-800"},`${n.x}-${n.y}`)):null]},o.key))})});function Sb({width:e,height:t,data:r,resolvedSeries:o,x:n,y:a,grid:s,size:l,curve:i,forecastFrom:d,forecastLabel:u,markers:p,connectNulls:b,referenceLines:m,margin:f,tooltip:h,onPointClick:y,plotLabel:C,formatValue:v,formatX:E}){let[k,R]=useState(null),g=useMemo(()=>{let w=o.filter(Z=>!Z.hidden),N=to({width:e,height:t,data:r,x:n,y:a,bounds:Xt(Fr(r,w.map(Z=>Z.key))),margin:f,placement:"point",formatValue:v,formatX:E,extraTop:u?wb:0}),x=N.categoryCenters,S=N.valueScale,I=d===void 0?-1:N.xValues.findIndex(Z=>eo(Z)===eo(d)),F=w.map(Z=>{let U=r.map(($,K)=>{let se=St($,Z.key);return {x:x[K],y:se===null?Number.NaN:S(se),defined:se!==null}}),H={connectNulls:b},z=I>=0;return {key:Z.key,color:Z.color,solid:Z.dashed?"":Vr(z?U.slice(0,I+1):U,i,H),dashed:Z.dashed?Vr(U,i,H):z?Vr(U.slice(I),i,H):"",markers:U.filter($=>$.defined!==false)}}),O=r.length>1?N.innerWidth/(r.length-1):0;return {visible:w,xValues:N.xValues,xPositions:x,xTicks:N.categoryTicks,yTicks:N.valueTicks,yScale:S,innerWidth:N.innerWidth,innerHeight:N.innerHeight,margin:N.margin,lines:F,forecastIndex:I,showMarkers:p==="always"||p==="auto"&&O>=kb&&r.length>1}},[r,o,n,a,e,t,f,i,b,d,u,p,v,E]),P=useCallback(w=>g.visible.map(N=>{let x=St(r[w],N.key);return {seriesKey:N.key,seriesLabel:Lt(N),color:N.color,value:x,formattedValue:x===null?"\u2014":v(x),datum:r[w]}}),[r,g.visible,v]),T=useCallback(w=>{if(h===false||r.length===0)return;let N=w.currentTarget.getBoundingClientRect(),x=w.clientX-N.left-g.margin.left,S=Vo(g.xPositions,x);R(S>=0?S:null);},[h,r.length,g.margin.left,g.xPositions]),D=useCallback(w=>{if(r.length===0)return;let N=r.length-1,x=k??0,S=w.key==="ArrowRight"?Math.min(N,x+1):w.key==="ArrowLeft"?Math.max(0,x-1):w.key==="Home"?0:w.key==="End"?N:w.key==="Escape"?null:void 0;S!==void 0&&(w.preventDefault(),R(S));},[r.length,k]),W=useCallback(()=>{if(!y||k===null)return;let[w]=P(k);w&&y({...w,index:k,x:g.xValues[k]});},[y,k,P,g.xValues]),V=k===null?null:P(k),_=(V??[]).filter(w=>w.value!==null),M=k===null||V===null?null:{x:g.xValues[k],xLabel:E(g.xValues[k],k),index:k,points:V};return jsxs(Fragment,{children:[jsxs("svg",{width:e,height:t,role:"img","aria-label":C??g.visible.map(w=>Lt(w)).join(", "),tabIndex:0,className:"touch-none focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-blue-500",onPointerMove:T,onPointerLeave:()=>R(null),onKeyDown:D,onBlur:()=>R(null),onClick:W,children:[jsxs("g",{transform:`translate(${g.margin.left}, ${g.margin.top})`,children:[jsx(Wr,{width:g.innerWidth,height:g.innerHeight,horizontal:s==="y"||s==="both"?g.yTicks.map(w=>w.offset):void 0,vertical:s==="x"||s==="both"?g.xTicks.map(w=>w.offset):void 0}),m?.map(w=>{let N=g.yScale(w.value),x=N<Cb?N+12:N-4;return jsxs("g",{children:[jsx("line",{x1:0,y1:N,x2:g.innerWidth,y2:N,stroke:w.color??"var(--color-chart-muted)",strokeWidth:1,strokeDasharray:w.dashed===false?void 0:"4 4"}),w.label?jsx("text",{x:g.innerWidth,y:x,textAnchor:"end",className:"fill-gray-500 text-[10px] dark:fill-gray-400",children:w.label}):null]},`${w.value}-${w.label??""}`)}),g.forecastIndex>=0?jsxs("g",{children:[jsx("line",{x1:g.xPositions[g.forecastIndex],y1:0,x2:g.xPositions[g.forecastIndex],y2:g.innerHeight,className:"stroke-gray-300 dark:stroke-gray-600",strokeWidth:1,strokeDasharray:"3 3"}),u?jsx("text",{x:g.xPositions[g.forecastIndex]+4,y:-2,className:"fill-gray-500 text-[10px] dark:fill-gray-400",children:u}):null]}):null,jsx(Nb,{lines:g.lines,showMarkers:g.showMarkers}),k!==null?jsxs("g",{"aria-hidden":"true",children:[jsx("line",{x1:g.xPositions[k],y1:0,x2:g.xPositions[k],y2:g.innerHeight,className:"stroke-gray-400 dark:stroke-gray-500",strokeWidth:1}),_.map(w=>jsx("circle",{cx:g.xPositions[k],cy:g.yScale(w.value),r:4,fill:w.color,strokeWidth:2,className:"stroke-white dark:stroke-gray-800"},w.seriesKey))]}):null]}),jsx("g",{transform:`translate(${g.margin.left}, ${g.margin.top+g.innerHeight})`,children:n.hidden?null:jsx(Ut,{orientation:"bottom",ticks:g.xTicks,length:g.innerWidth,label:n.label,size:l})}),jsx("g",{transform:`translate(${g.margin.left}, ${g.margin.top})`,children:a?.hidden?null:jsx(Ut,{orientation:"left",ticks:g.yTicks,length:g.innerHeight,showLine:false,label:a?.label,size:l})})]}),M&&h!==false?jsx(ur,{x:g.margin.left+g.xPositions[M.index],y:g.margin.top+(_.length>0?Math.min(..._.map(w=>g.yScale(w.value))):g.innerHeight/2),containerWidth:e,children:typeof h=="function"?h(M):jsx(pr,{title:M.xLabel,points:M.points})}):null]})}function Rb({data:e,series:t,x:r,y:o,height:n=240,width:a,size:s="md",grid:l="y",legend:i,tooltip:d=true,tableView:u=false,emphasis:p,title:b,description:m,loading:f=false,emptyState:h,onPointClick:y,curve:C="monotone",forecastFrom:v,forecastLabel:E,markers:k="auto",connectNulls:R=false,referenceLines:g,legendToggle:P=true,margin:T,locale:D,plotLabel:W,className:V,..._}){let[M,w]=useState(()=>new Set),N=useMemo(()=>t.map((U,H)=>({...U,hidden:U.hidden||M.has(U.key),color:Cr(U,H,p)})),[t,M,p]),x=useMemo(()=>o?.format??(U=>_t(U,D)),[o?.format,D]),S=useMemo(()=>r.format??(U=>r.scale==="time"?Gt(U instanceof Date?U:new Date(Nr(U)),D):Gt(U,D)),[r.format,r.scale,D]),I=useCallback(U=>{w(H=>{let z=new Set(H);return z.has(U)?z.delete(U):z.add(U),z});},[]),F=i===void 0?t.length>=2:i!==false,O=typeof i=="string"?i:"bottom",Z=N.filter(U=>!U.hidden).length;return jsx(lr,{title:b,description:m,height:n,width:a,size:s,loading:f,empty:e.length===0||Z===0,emptyState:h,tableView:u,legendPosition:O,legend:F?jsx(dr,{items:Hr(N,p),position:O,marker:"line",size:s,onToggle:P?I:void 0}):void 0,table:u?jsx(cr,{data:e,series:N,xKey:r.key,xLabel:r.label??r.key,formatX:S,formatValue:x,caption:typeof b=="string"?b:void 0}):void 0,className:V,..._,children:({width:U})=>jsx(Sb,{width:U,height:n,data:e,resolvedSeries:N,x:r,y:o,grid:l,size:s,curve:C,forecastFrom:v,forecastLabel:E,markers:k,connectNulls:R,referenceLines:g,margin:T,tooltip:d,onPointClick:y,plotLabel:W,formatValue:x,formatX:S})})}var Ib={sm:"max-w-sm",md:"max-w-2xl",lg:"max-w-4xl",xl:"max-w-6xl",full:"max-w-full"},Yr=forwardRef(({isOpen:e,onClose:t,title:r="Modal Title",children:o,buttonLabel:n,onButtonClick:a,className:s,allowFullScreen:l=false,showSubmit:i=true,submitLabel:d,onSubmitClick:u,showCancel:p=false,cancelLabel:b,onCancelClick:m,buttonsPosition:f="right",showHeaderDivider:h=true,showFooterDivider:y=true,description:C,icon:v,size:E="md",reverseButtons:k=false,headerClassName:R,contentClassName:g,footerClassName:P,titleClassName:T,descriptionClassName:D,submitClassName:W,cancelClassName:V,closeLabel:_,enterFullScreenLabel:M,exitFullScreenLabel:w,"aria-label":N,closeOnEscape:x=true,trapFocus:S=true,initialFocus:I,returnFocus:F,lockScroll:O=true},Z)=>{let[U,H]=useState(false),z=Ft(),$=useId(),K=`${$}-title`,se=`${$}-description`,{dialogRef:X,dialogProps:ee}=So({open:e,onClose:t,closeOnEscape:x,trapFocus:S,initialFocus:I,returnFocus:F,lockScroll:O});if(!e)return null;let L=n??d??z.confirm,q=b??z.cancel,ge=_??z.closeModal,de=U?w??z.exitFullScreen:M??z.enterFullScreen,Y=a??u,le=async()=>{Y&&await Y(),t();},xe=async()=>{m&&await m(),t();};return jsx("div",{className:c("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:jsx("div",{className:c("relative p-4 w-full max-h-full transition-all duration-300",U?"max-w-full h-full p-0":Ib[E]),ref:Z,children:jsxs("div",{...ee,ref:X,"aria-labelledby":r?K:void 0,"aria-label":r?void 0:N,"aria-describedby":C?se:void 0,className:c("relative bg-white shadow dark:bg-gray-700 border-b-4 transition-all duration-300 focus:outline-none",U?"rounded-none h-full flex flex-col":"rounded-lg"),children:[jsxs("div",{className:c("flex items-center justify-between p-4 md:p-5 rounded-t",h&&"border-b border-gray-200 dark:border-gray-600",R),children:[jsxs("div",{className:"flex items-center gap-3",children:[v&&jsx("div",{className:"shrink-0 text-gray-500 dark:text-gray-400",children:v}),jsxs("div",{children:[jsx("h3",{id:K,className:c("text-xl font-semibold text-gray-900 dark:text-white",T),children:r}),C&&jsx("p",{id:se,className:c("mt-1 text-sm text-gray-500 dark:text-gray-400",D),children:C})]})]}),jsxs("div",{className:"flex items-center gap-1 ms-auto",children:[l&&jsx("button",{type:"button",onClick:()=>H(Se=>!Se),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":de,children:U?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:jsx("path",{stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",d:"M7 1H1v6m16 0V1h-6m0 16h6v-6M1 11v6h6"})}):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:jsx("path",{stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",d:"M11 1h6v6M1 11v6h6m0-12L1 1m16 16-6-6"})})}),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:[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:jsx("path",{stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",d:"m1 1 6 6m0 0 6 6M7 7l6-6M7 7l-6 6"})}),jsx("span",{className:"sr-only",children:ge})]})]})]}),jsx("div",{className:c("p-4 md:p-5 space-y-4",U&&"flex-1 overflow-y-auto",g),children:o}),(i||p)&&jsxs("div",{className:c("flex items-center gap-2 p-4 md:p-5 rounded-b",y&&"border-t border-gray-200 dark:border-gray-600",f==="right"?"justify-end":f==="center"?"justify-center":"justify-start",k&&"flex-row-reverse",P),children:[p&&jsx("button",{type:"button",onClick:xe,className:c("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",V),children:q}),i&&jsx("button",{type:"button",onClick:le,className:c("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",W),children:L})]})]})})})});Yr.displayName="Modal";function Ab(e,t,r,o){let n=r*2+1+o*2+2;if(t<=n)return Array.from({length:t},(b,m)=>m+1);let a=Array.from({length:o},(b,m)=>m+1).filter(b=>b<=t),s=Array.from({length:o},(b,m)=>t-o+1+m).filter(b=>b>=1),l=Math.max(e-r,o+1),i=Math.min(e+r,t-o),d=l>o+2,u=i<t-o-1,p=[];for(let b of a)p.push(b);if(d)p.push("ellipsis");else for(let b=o+1;b<l;b++)p.push(b);for(let b=l;b<=i;b++)p.push(b);if(u)p.push("ellipsis");else for(let b=i+1;b<=t-o;b++)p.push(b);for(let b of s)p.includes(b)||p.push(b);return p}function zb({className:e}){return jsx("svg",{className:e,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24","aria-hidden":"true",children:jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M15 19l-7-7 7-7"})})}function Wb({className:e}){return jsx("svg",{className:e,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24","aria-hidden":"true",children:jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 5l7 7-7 7"})})}function Hb({className:e}){return jsx("svg",{className:e,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24","aria-hidden":"true",children:jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M11 19l-7-7 7-7M18 19l-7-7 7-7"})})}function Fb({className:e}){return jsx("svg",{className:e,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24","aria-hidden":"true",children:jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M13 5l7 7-7 7M6 5l7 7-7 7"})})}var Bb={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"}},Vb={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 Ob({page:e,totalPages:t,onPageChange:r,size:o="md",variant:n="default",showFirstLast:a=false,siblings:s=1,boundaries:l=1,disabled:i=false,labels:d,totalItems:u,pageSize:p,pageSizeOptions:b,onPageSizeChange:m,className:f,...h}){let y=Bb[o],C=Vb[n],v=useMemo(()=>Ab(e,t,s,l),[e,t,s,l]),E=useCallback(W=>{i||W<1||W>t||W===e||r(W);},[i,t,e,r]),k=e<=1,R=e>=t,g=c("inline-flex items-center justify-center select-none",y.button,C.base),P=(W,V,_,M)=>jsx("button",{type:"button",onClick:W,disabled:i||V,"aria-label":_,"aria-disabled":i||V,className:c(g,i||V?C.disabled:C.idle),children:M}),T=u!==void 0&&p?(e-1)*p+1:void 0,D=u!==void 0&&p?Math.min(e*p,u):void 0;return jsxs("nav",{"aria-label":"Pagination",className:c("flex items-center",y.gap,f),...h,children:[u!==void 0&&p&&jsxs("span",{className:c("mr-2 text-gray-600 dark:text-gray-400 whitespace-nowrap",y.text),children:[T,"\u2013",D," of ",u]}),b&&b.length>0&&m&&jsxs("div",{className:c("mr-2 flex items-center whitespace-nowrap",y.gap,y.text),children:[jsx("label",{htmlFor:"pagination-page-size",className:"text-gray-600 dark:text-gray-400",children:"Rows:"}),jsx("select",{id:"pagination-page-size",value:p,onChange:W=>m(Number(W.target.value)),disabled:i,className:c("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",y.text,i&&"cursor-not-allowed opacity-50"),children:b.map(W=>jsx("option",{value:W,children:W},W))})]}),jsxs("div",{className:c("flex items-center",y.gap),children:[a&&P(()=>E(1),k,d?.first??"Go to first page",jsx(Hb,{className:y.icon})),P(()=>E(e-1),k,d?.previous??"Go to previous page",jsx(zb,{className:y.icon})),v.map((W,V)=>W==="ellipsis"?jsx("span",{className:c("inline-flex items-center justify-center select-none",y.button,"text-gray-400 dark:text-gray-500"),"aria-hidden":"true",children:"\u2026"},`ellipsis-${V}`):jsx("button",{type:"button",onClick:()=>E(W),disabled:i,"aria-current":W===e?"page":void 0,"aria-label":`Page ${W}`,className:c(g,W===e?C.active:i?C.disabled:C.idle),children:W},W)),P(()=>E(e+1),R,d?.next??"Go to next page",jsx(Wb,{className:y.icon})),a&&P(()=>E(t),R,d?.last??"Go to last page",jsx(Fb,{className:y.icon}))]})]})}var _b=.62,Gb=2,Xb=3,Kb=.16,Ub=64,Yb=22,Zs=6,Gd=false;function jb({width:e,height:t,slices:r,variant:o,innerRadius:n,showLabels:a,centerLabel:s,tooltip:l,plotLabel:i,formatValue:d,onSliceClick:u}){let[p,b]=useState(null),m=useMemo(()=>{let g=a?Ub:8,P=a?Yb:8,T=Math.max(0,Math.min((e-g*2)/2,(t-P*2)/2));return {cx:e/2,cy:t/2,outerRadius:T,inner:o==="donut"?T*(n??_b):(n??0)*T,pad:T>0&&r.length>1?Gb/T/2:0}},[e,t,o,n,a,r.length]),{cx:f,cy:h,outerRadius:y,inner:C,pad:v}=m,E=useCallback(g=>{let P=(g.startAngle+g.endAngle)/2,T=Math.sin(P)>=0,D={x:f+Math.sin(P)*(y+4),y:h-Math.cos(P)*(y+4)},W={x:f+Math.sin(P)*(y+14),y:h-Math.cos(P)*(y+14)},V={x:T?W.x+10:W.x-10,y:W.y};return {from:D,elbow:W,end:V,anchor:T?"start":"end"}},[f,h,y]),k=useCallback(g=>{if(r.length===0)return;let P=r.length-1,T=p??0,D=g.key==="ArrowRight"||g.key==="ArrowDown"?Math.min(P,T+1):g.key==="ArrowLeft"||g.key==="ArrowUp"?Math.max(0,T-1):g.key==="Home"?0:g.key==="End"?P:g.key==="Escape"?null:void 0;D!==void 0&&(g.preventDefault(),b(D));},[r.length,p]),R=p===null?null:r[p];return jsxs(Fragment,{children:[jsxs("svg",{width:e,height:t,role:"img","aria-label":i??r.map(g=>g.label).join(", "),tabIndex:0,className:"touch-none focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-blue-500",onPointerLeave:()=>b(null),onBlur:()=>b(null),onKeyDown:k,children:[r.map((g,P)=>jsx("path",{d:ul({cx:f,cy:h,innerRadius:C,outerRadius:y+(p===P?Xb:0),startAngle:g.startAngle+v,endAngle:Math.max(g.startAngle+v,g.endAngle-v)}),fill:g.color,onPointerEnter:()=>l===false?void 0:b(P),onClick:()=>u?.({key:g.key,label:g.label,value:g.value,share:g.share})},g.key)),a?r.filter(g=>g.endAngle-g.startAngle>=Kb).map(g=>{let{from:P,elbow:T,end:D,anchor:W}=E(g);return jsxs("g",{"aria-hidden":"true",children:[jsx("polyline",{points:`${P.x},${P.y} ${T.x},${T.y} ${D.x},${D.y}`,fill:"none",className:"stroke-gray-300 dark:stroke-gray-600",strokeWidth:1}),jsx("text",{x:W==="start"?D.x+3:D.x-3,y:D.y,textAnchor:W,dominantBaseline:"middle",className:"fill-gray-600 text-[10px] dark:fill-gray-300",children:g.label})]},`label-${g.key}`)}):null,o==="donut"&&s?jsxs("g",{"aria-hidden":"true",children:[jsx("text",{x:f,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?jsx("text",{x:f,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?jsx(ur,{x:f+Math.sin((R.startAngle+R.endAngle)/2)*(y*.7),y:h-Math.cos((R.startAngle+R.endAngle)/2)*(y*.7),containerWidth:e,children:typeof l=="function"?l({seriesKey:R.key,seriesLabel:R.label,color:R.color,value:R.value,formattedValue:d(R.value),datum:{},share:R.share}):jsx(pr,{title:R.label,points:[{seriesKey:R.key,seriesLabel:Br(R.share),color:R.color,value:R.value,formattedValue:d(R.value),datum:{}}]})}):null]})}function qb({data:e,x:t,value:r,variant:o="pie",innerRadius:n,maxSlices:a=Zs,otherLabel:s,sort:l="desc",showLabels:i=true,centerLabel:d,height:u=260,width:p,size:b="md",legend:m,tooltip:f=true,tableView:h=false,title:y,description:C,loading:v=false,emptyState:E,locale:k,plotLabel:R,onSliceClick:g,className:P,...T}){let D=Ft(),W=useCallback(S=>_t(S,k),[k]),V=useCallback(S=>t.format?t.format(S,0):Gt(S,k),[t,k]),{slices:_,total:M,rows:w}=useMemo(()=>{let S=e.map((z,$)=>({key:String(bo(z,t.key,$)),label:V(bo(z,t.key,$)),value:St(z,r)??0,color:la($),datum:z})),I=l==="none"?S:[...S].sort((z,$)=>l==="asc"?z.value-$.value:$.value-z.value),F=I.slice(0,a),O=I.slice(a);O.length>0&&F.push({key:"__other__",label:s??D.chartOther,value:O.reduce((z,$)=>z+$.value,0),color:xn,datum:{}}),F.length>Zs&&!Gd&&(Gd=true,console.warn(`[@synertech/ui] A PieChart is drawing ${F.length} slices. Past ${Zs} the slices stop being tellable apart: lower \`maxSlices\`, or use a BarChart, which compares lengths rather than angles.`));let Z=F.reduce((z,$)=>z+Math.max(0,$.value),0),U=0;return {slices:F.map(z=>{let $=Z===0?0:Math.max(0,z.value)/Z,K=U;return U+=$*Math.PI*2,{...z,share:$,startAngle:K,endAngle:U}}),total:Z,rows:F.map(z=>({[t.key]:z.label,[r]:z.value}))}},[e,t.key,r,l,a,s,D.chartOther,V]),N=m===void 0?true:m!==false,x=typeof m=="string"?m:"bottom";return jsx(lr,{title:y,description:C,height:u,width:p,size:b,loading:v,empty:_.length===0||M===0,emptyState:E,tableView:h,legendPosition:x,legend:N?jsx(dr,{items:_.map(S=>({key:S.key,label:`${S.label} \xB7 ${Br(S.share)}`,color:S.color})),position:x,marker:"rect",size:b}):void 0,table:h?jsx(cr,{data:w,series:[{key:r,label:t.label??r}],xKey:t.key,xLabel:t.label??t.key,formatValue:W,caption:typeof y=="string"?y:void 0}):void 0,className:P,...T,children:({width:S})=>jsx(jb,{width:S,height:u,slices:_,variant:o,innerRadius:n,showLabels:i,centerLabel:d,tooltip:f,plotLabel:R,formatValue:W,onSliceClick:g})})}var Jb={xs:"h-1",sm:"h-1.5",md:"h-2.5",lg:"h-4",xl:"h-6"},Qb={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"},eh={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"},Kd="bg-[repeating-linear-gradient(45deg,transparent,transparent_10px,rgba(255,255,255,0.2)_10px,rgba(255,255,255,0.2)_20px)]",th={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 Yd({value:e=0,indeterminate:t=false,size:r="md",color:o="primary",variant:n="default",showValue:a=false,valueFormat:s,label:l,animated:i=true,className:d,...u}){let p=Math.min(100,Math.max(0,e)),b=n==="gradient"?th[o]:Qb[o],m=s?s(p):`${Math.round(p)}%`;return jsxs("div",{className:c("w-full",d),...u,children:[(l||a)&&jsxs("div",{className:"flex items-center justify-between mb-1",children:[l&&jsx("span",{className:"text-sm font-medium text-gray-700 dark:text-gray-300",children:l}),a&&!t&&jsx("span",{className:c("text-sm font-semibold",eh[o],!l&&"ml-auto"),children:m})]}),jsx("div",{role:"progressbar","aria-valuenow":t?void 0:p,"aria-valuemin":0,"aria-valuemax":100,"aria-label":l,className:c("relative w-full overflow-hidden rounded-full bg-gray-200 dark:bg-gray-700",Jb[r]),children:t?jsx("div",{className:c("absolute h-full w-1/3 rounded-full",b,n==="striped"&&Kd,"animate-[progress-indeterminate_1.5s_ease-in-out_infinite]")}):jsx("div",{className:c("h-full rounded-full",b,n==="striped"&&Kd,i&&"transition-[width] duration-300 ease-out"),style:{width:`${p}%`}})})]})}Yd.displayName="ProgressBar";var ah=e=>({sm:"w-4 h-4",md:"w-5 h-5",lg:"w-6 h-6"})[e],sh=e=>({sm:"w-2 h-2",md:"w-2.5 h-2.5",lg:"w-3 h-3"})[e],ih=(e,t,r,o,n,a,s,l)=>{if(t)return c("border-2",o?"":"border-red-500",r&&!n?"bg-red-500":"");switch(e){case "filled":return c("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 c("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 c("border-2",l?"":r?"border-blue-600 dark:border-blue-500":"border-gray-300 dark:border-gray-600","bg-white dark:bg-gray-800")}},lh={},jd=forwardRef(({label:e,description:t,value:r,checked:o,defaultChecked:n=false,onCheckedChange:a,size:s="md",variant:l="default",labelPosition:i="right",error:d=false,disabled:u=false,readOnly:p=false,required:b=false,checkedColor:m,uncheckedColor:f,borderColor:h,labelColor:y,errorColor:C,dotColor:v,hoverColor:E,focusRingColor:k,showFocusRing:R=true,className:g,containerClassName:P,...T},D)=>{let[W,V]=useState(n),_=o!==void 0,M=_?o:W,w=useId(),N=typeof d=="string"?d:void 0,x=!!d,S=se=>{if(u||p)return;let X=se.target.checked;_||V(X),a?.(X);},I=useMemo(()=>ih(l,x,M,C,v,m,f,h),[l,x,M,C,v,m,f,h]),F=useMemo(()=>{let se={};return m&&M&&(se.backgroundColor=m,se.borderColor=m),f&&!M&&(se.backgroundColor=f),h&&(se.borderColor=h),se},[m,f,h,M]),O=useMemo(()=>v?{backgroundColor:v}:{},[v]),Z=useMemo(()=>y?{color:y}:{},[y]),U=useMemo(()=>C?{color:C}:{},[C]),H=y?"":"text-gray-700 dark:text-gray-200",z=C?"":"text-red-500",$=E?"":"hover:border-blue-500 dark:hover:border-blue-400",K=k?"":"focus-visible:ring-blue-500";return jsxs("div",{className:c("inline-flex flex-col",P),style:lh,children:[jsxs("label",{className:c("inline-flex items-center cursor-pointer",u&&"opacity-50 cursor-not-allowed",p&&"cursor-default",i==="left"&&"flex-row-reverse"),htmlFor:w,children:[jsxs("div",{className:"relative inline-flex items-center",children:[jsx("input",{ref:D,type:"radio",id:w,value:r,checked:M,onChange:S,disabled:u,readOnly:p,required:b,"aria-invalid":x,"aria-describedby":N?`${w}-error`:void 0,className:"sr-only peer",tabIndex:p?-1:void 0,...T}),jsx("div",{className:c("rounded-full transition-all duration-200",ah(s),I,!u&&!p&&$,!u&&!p&&R&&"peer-focus-visible:ring-2 ring-offset-2",!u&&!p&&R&&K,g),style:F,children:M&&jsx("div",{className:c("rounded-full absolute inset-0 m-auto transition-all duration-200",sh(s),v?"":l==="outlined"||l==="default"?"bg-blue-600 dark:bg-blue-500":"bg-white"),style:O})})]}),e&&jsxs("span",{className:c("select-none",i==="left"?"mr-2":"ml-2",H,u&&"opacity-50"),style:Z,children:[e,b&&jsx("span",{className:"text-red-500 ml-1",children:"*"})]})]}),t&&!x&&jsx("p",{className:c("text-sm text-gray-500 dark:text-gray-400 mt-1",i==="left"?"text-right":"ml-7"),children:t}),N&&jsx("p",{id:`${w}-error`,className:c("text-sm mt-1",i==="left"?"text-right":"ml-7",z),style:U,children:N})]})});jd.displayName="RadioButton";var Qs=()=>{},gh=[],mh=jsx("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none","aria-hidden":"true",className:"shrink-0",children:jsx("path",{d:"M4 6L8 10L12 6",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})}),fh=jsx("svg",{width:"14",height:"14",viewBox:"0 0 14 14",fill:"none","aria-hidden":"true",className:"shrink-0",children: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"})}),bh=jsxs("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none","aria-hidden":"true",className:"shrink-0 animate-spin",children:[jsx("circle",{cx:"8",cy:"8",r:"6",stroke:"currentColor",strokeWidth:"2",strokeOpacity:"0.25"}),jsx("path",{d:"M14 8a6 6 0 00-6-6",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round"})]}),hh=jsx("svg",{width:"14",height:"14",viewBox:"0 0 14 14",fill:"none","aria-hidden":"true",className:"shrink-0",children:jsx("path",{d:"M11.5 3.5L5.5 10.5L2.5 7.5",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})}),_n={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"}},qd={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 so(...e){let t="";for(let r=0;r<e.length;r++){let o=e[r];o&&(t&&(t+=" "),t+=o);}return t}function yh(e,t){if(!t)return e;let r=t.toLowerCase();return e.filter(o=>{if(o.label.toLowerCase().includes(r)||o.value.toLowerCase().includes(r))return true;if(o.keywords){for(let n of o.keywords)if(n.toLowerCase().includes(r))return true}return false})}var xh=memo(forwardRef(function({option:t,isSelected:r,isHighlighted:o,isDisabled:n,sizeKey:a,optionId:s,onClick:l,onMouseEnter:i,index:d},u){let p=()=>{n||l(t.value);},b=()=>{n||i(d);};return jsxs("div",{ref:u,id:s,role:"option","aria-selected":r,"aria-disabled":n||void 0,"data-highlighted":o||void 0,className:so(_n[a].option,"flex items-center gap-2 cursor-pointer select-none transition-colors",o&&!n&&"bg-blue-50 dark:bg-blue-900/30",r&&!o&&"bg-gray-50 dark:bg-gray-700/50",n&&"opacity-50 cursor-not-allowed"),onClick:p,onMouseEnter:b,children:[t.icon?jsx("span",{className:"flex shrink-0 items-center",children:t.icon}):null,jsxs("span",{className:"flex flex-col min-w-0 flex-1",children:[jsx("span",{className:"truncate",children:t.label}),t.description?jsx("span",{className:"text-xs text-gray-500 dark:text-gray-400 truncate",children:t.description}):null]}),r?jsx("span",{className:"ml-auto text-blue-600 dark:text-blue-400",children:hh}):null]})}));function vh({options:e=gh,value:t,defaultValue:r,onValueChange:o,searchable:n=false,clearable:a=false,disabled:s=false,readOnly:l=false,loading:i=false,size:d="md",variant:u="default",placeholder:p="Select...",label:b,description:m,helperText:f,error:h,required:y=false,noOptionsText:C="No options",onSearchChange:v,name:E,className:k,triggerClassName:R,contentClassName:g,maxHeight:P=256}){let T=useId(),D=`${T}-label`,W=`${T}-trigger`,V=`${T}-listbox`,_=useRef(null),M=useRef(null),w=useRef(null),N=useRef([]),x=t!==void 0,[S,I]=useState(r??""),F=x?t:S,[O,Z]=useState(false),[U,H]=useState(""),[z,$]=useState(-1),[K,se]=useState(null),X=useMemo(()=>n?yh(e,U):e,[e,U,n]),ee=useMemo(()=>e.find(re=>re.value===F)??null,[e,F]),L=useMemo(()=>{let re=new Set;for(let pe of e)pe.disabled&&re.add(pe.value);return re},[e]),q=useCallback(re=>{x||I(re),(o??Qs)(re),Z(false),H(""),$(-1),_.current?.focus();},[x,o]),ge=useCallback(re=>{re.stopPropagation(),x||I(""),(o??Qs)(""),H(""),_.current?.focus();},[x,o]),de=useCallback(()=>{s||l||(Z(true),H(""),$(-1));},[s,l]),Y=useCallback(()=>{Z(false),H(""),$(-1),_.current?.focus();},[]),le=useCallback(()=>{O?Y():de();},[O,Y,de]),xe=useCallback((re,pe)=>{let Ue=X.length;if(Ue===0)return -1;let yt=re;for(let Re=0;Re<Ue;Re++)if(yt=((yt+pe)%Ue+Ue)%Ue,!L.has(X[yt].value))return yt;return -1},[X,L]),Se=useCallback(re=>{if(!(s||l)){if(O){switch(re.key){case "ArrowDown":{re.preventDefault();let pe=xe(z,1);pe!==-1&&$(pe);break}case "ArrowUp":{re.preventDefault();let pe=xe(z,-1);pe!==-1&&$(pe);break}case "Home":{re.preventDefault();let pe=xe(-1,1);pe!==-1&&$(pe);break}case "End":{re.preventDefault();let pe=xe(X.length,-1);pe!==-1&&$(pe);break}case "Enter":{if(re.preventDefault(),z>=0&&z<X.length){let pe=X[z];L.has(pe.value)||q(pe.value);}break}case " ":if(re.preventDefault(),z>=0&&z<X.length){let pe=X[z];L.has(pe.value)||q(pe.value);}else Y();break;case "Escape":re.preventDefault(),Y();break;case "Tab":Y();break}return}switch(re.key){case "ArrowDown":case "ArrowUp":re.preventDefault(),de();break;case "Enter":case " ":re.preventDefault(),de();break}}},[s,l,O,de,Y,z,X,L,xe,q]),te=useCallback(re=>{switch(re.key){case "ArrowDown":{re.preventDefault();let pe=xe(z,1);pe!==-1&&$(pe);break}case "ArrowUp":{re.preventDefault();let pe=xe(z,-1);pe!==-1&&$(pe);break}case "Home":{re.preventDefault();let pe=xe(-1,1);pe!==-1&&$(pe);break}case "End":{re.preventDefault();let pe=xe(X.length,-1);pe!==-1&&$(pe);break}case "Enter":{if(re.preventDefault(),z>=0&&z<X.length){let pe=X[z];L.has(pe.value)||q(pe.value);}break}case "Escape":re.preventDefault(),Y();break;case "Tab":Y();break}},[z,X,L,xe,q,Y]),Ne=useCallback(re=>{let pe=re.target.value;H(pe),$(-1),(v??Qs)(pe);},[v]);useEffect(()=>{if(!O)return;let re=pe=>{let Ue=pe.target;_.current?.contains(Ue)||M.current?.contains(Ue)||Y();};return document.addEventListener("mousedown",re),document.addEventListener("touchstart",re,{passive:true}),()=>{document.removeEventListener("mousedown",re),document.removeEventListener("touchstart",re);}},[O,Y]),useEffect(()=>{if(!O||!_.current){se(null);return}let re=()=>{let pe=_.current;if(!pe)return;let Ue=pe.getBoundingClientRect(),yt=window.innerHeight-Ue.bottom,Re=Ue.top,We=P+8,ft=yt<We&&Re>yt?"top":"bottom";se({top:ft==="bottom"?Ue.bottom+window.scrollY+4:Ue.top+window.scrollY-We,left:Ue.left+window.scrollX,width:Ue.width,placement:ft});};return re(),window.addEventListener("scroll",re,true),window.addEventListener("resize",re),()=>{window.removeEventListener("scroll",re,true),window.removeEventListener("resize",re);}},[O,P]),useEffect(()=>{O&&n&&w.current?.focus();},[O,n]),useEffect(()=>{let re=M.current;if(!(!O||!re))return No(re,()=>_.current)},[O]),useEffect(()=>{if(z>=0){let re=N.current[z];re&&typeof re.scrollIntoView=="function"&&re.scrollIntoView({block:"nearest"});}},[z]);let De=F!==""&&F!==void 0,Ve=a&&De&&!s&&!l&&!i,rt=!s&&!l,dt=so("w-full flex items-center justify-between rounded-md transition-colors","text-gray-900 dark:text-gray-100",_n[d].trigger,qd[u].trigger,!h&&rt&&qd[u].focus,h&&"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",R);return jsxs("div",{className:so("flex flex-col gap-1",k),children:[b?jsxs("label",{id:D,htmlFor:W,className:"text-sm font-medium text-gray-700 dark:text-gray-300",children:[b,y?jsx("span",{className:"text-red-500 ml-0.5","aria-hidden":"true",children:"*"}):null]}):null,m?jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400",children:m}):null,jsxs("button",{ref:_,id:W,type:"button",role:"combobox","aria-expanded":O,"aria-haspopup":"listbox","aria-controls":O?V:void 0,"aria-labelledby":b?D:void 0,"aria-required":y||void 0,"aria-invalid":h?true:void 0,"aria-activedescendant":O&&z>=0?`${T}-option-${z}`:void 0,disabled:s,className:dt,onClick:rt?le:void 0,onKeyDown:Se,children:[jsxs("span",{className:so("flex items-center gap-2 min-w-0 flex-1 truncate",!De&&"text-gray-400 dark:text-gray-500"),children:[ee?.icon?jsx("span",{className:"flex shrink-0 items-center",children:ee.icon}):null,jsx("span",{className:"truncate",children:De&&ee?ee.label:p})]}),jsxs("span",{className:"flex items-center gap-1 shrink-0",children:[i?jsx("span",{className:"text-gray-400",children:bh}):null,Ve?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:ge,onMouseDown:re=>re.preventDefault(),children:fh}):null,jsx("span",{className:so("text-gray-400 transition-transform duration-200",O&&"rotate-180"),children:mh})]})]}),h?jsx("p",{role:"alert",className:"text-xs text-red-500 dark:text-red-400",children:h}):f?jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400",children:f}):null,E?jsx("input",{type:"hidden",name:E,value:F??""}):null,O&&K?createPortal(jsxs("div",{ref:M,role:"listbox",id:V,"aria-labelledby":b?D:void 0,className:so("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",_n[d].content,g),style:{top:K.top,left:K.left,width:K.width,position:"absolute"},onKeyDown:te,children:[n?jsx("div",{className:"border-b border-gray-200 dark:border-gray-700",children:jsx("input",{ref:w,type:"text",role:"searchbox","aria-label":"Search options",className:so(_n[d].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:U,onChange:Ne,onKeyDown:te})}):null,jsx("div",{className:"overflow-y-auto",style:{maxHeight:P},children:X.length===0?jsx("div",{className:so(_n[d].option,"text-gray-500 dark:text-gray-400 text-center py-4"),children:C}):X.map((re,pe)=>jsx(xh,{option:re,isSelected:re.value===F,isHighlighted:pe===z,isDisabled:i||L.has(re.value),sizeKey:d,optionId:`${T}-option-${pe}`,onClick:q,onMouseEnter:$,index:pe,ref:Ue=>{N.current[pe]=Ue;}},re.value))})]}),document.body):null]})}var ti=createContext(null);function Io(){let e=useContext(ti);if(!e)throw new Error("Sidebar sub-components must be used within <Sidebar>");return e}function Ch(){return Io()}var Nh=({className:e})=>jsx("svg",{className:c("w-4 h-4",e),viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true",children: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"})}),Sh=({className:e})=>jsx("svg",{className:c("w-4 h-4",e),viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true",children: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"})}),Rh=({className:e})=>jsx("svg",{className:c("w-5 h-5",e),viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true",children: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 Qd({text:e,position:t,children:r}){let[o,n]=useState(false),[a,s]=useState({top:0,left:0}),l=useRef(null);return jsxs("div",{ref:l,onMouseEnter:()=>{if(l.current){let d=l.current.getBoundingClientRect();s({top:d.top+d.height/2,left:t==="left"?d.right+8:d.left-8});}n(true);},onMouseLeave:()=>n(false),className:"relative",children:[r,o&&jsx("div",{className:c("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 Th({collapsed:e,defaultCollapsed:t=false,onCollapsedChange:r,expandedWidth:o=260,collapsedWidth:n=64,position:a="left",variant:s="default",mobileBreakpoint:l=768,mobileOpen:i,onMobileOpenChange:d,className:u,"aria-label":p,closeLabel:b,trapFocus:m=true,initialFocus:f,returnFocus:h,lockScroll:y=true,children:C}){let v=Ft(),E=useRef(null),k=useRef(null),[R,g]=useState(t),[P,T]=useState(false),[D,W]=useState(false),V=e!==void 0,_=V?e:R,M=i!==void 0,w=M?i:P;useEffect(()=>{let H=window.matchMedia(`(max-width: ${l}px)`),z=$=>{W($.matches),$.matches||(M||T(false),d?.(false));};return z(H),H.addEventListener("change",z),()=>H.removeEventListener("change",z)},[l,M,d]);let N=useCallback(()=>{if(D){let H=!w;M||T(H),d?.(H);}else {let H=!_;V||g(H),r?.(H);}},[D,w,_,M,V,d,r]),x=useCallback(()=>{M||T(false),d?.(false);},[M,d]);useEffect(()=>{let H=k.current;H&&(D&&!w?(H.setAttribute("inert",""),H.setAttribute("aria-hidden","true")):(H.removeAttribute("inert"),H.removeAttribute("aria-hidden")));},[D,w]);let{dialogRef:S,dialogProps:I}=So({open:D&&w,onClose:x,trapFocus:m,initialFocus:f,returnFocus:h,lockScroll:y,keepInteractive:[E]}),F={default:"bg-white dark:bg-gray-900",bordered:c("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"},O=_&&!D?n:o,Z=jsx("aside",{className:c("flex flex-col h-full overflow-hidden transition-[width] duration-200 ease-in-out",F[s],u),style:{width:D?o:O,minWidth:D?o:O},"data-testid":"sidebar","data-collapsed":_&&!D,"data-mobile":D,"data-position":a,children:C}),U={collapsed:_&&!D,isMobile:D,mobileOpen:w,position:a,variant:s,expandedWidth:o,collapsedWidth:n,toggle:N,closeMobile:x,closeLabel:b};return D?jsxs(ti.Provider,{value:U,children:[w&&jsx("div",{ref:E,className:"fixed inset-0 z-40 bg-black/50 transition-opacity",onClick:x,"aria-hidden":"true","data-testid":"sidebar-overlay"}),jsx("div",{ref:H=>{k.current=H,S.current=H;},...I,"aria-label":p??v.sidebar,className:c("fixed top-0 z-50 h-full transition-transform duration-200 ease-in-out focus:outline-none",a==="left"?"left-0":"right-0",w?"translate-x-0":a==="left"?"-translate-x-full":"translate-x-full"),children:Z})]}):jsx(ti.Provider,{value:U,children:Z})}function Ph({className:e,children:t}){let r=Io(),o=Ft();return jsxs("div",{className:c("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&&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??o.closeSidebar,children:jsx(Rh,{})})]})}function Eh({className:e,children:t}){return jsx("div",{className:c("flex-1 overflow-y-auto overflow-x-hidden py-2",e),"data-testid":"sidebar-content",children:t})}function Dh({className:e,children:t}){let r=Io();return jsx("div",{className:c("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 Ih({label:e,className:t,children:r}){let o=Io();return jsxs("div",{className:c("py-2",t),"data-testid":"sidebar-group",children:[e&&!o.collapsed&&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&&o.collapsed&&jsx("div",{className:"mx-auto my-1 w-6 border-t border-gray-200 dark:border-gray-700"}),jsx("div",{className:"space-y-0.5 px-2",children:r})]})}function Mh({icon:e,label:t,badge:r,badgeColor:o="bg-blue-600 text-white",active:n=false,disabled:a=false,href:s,onClick:l,tooltip:i,className:d}){let u=Io(),p=u.collapsed,b=i??t,m=jsxs(Fragment,{children:[e&&jsx("span",{className:c("shrink-0 w-5 h-5",p&&"w-5 h-5"),children:e}),!p&&jsxs(Fragment,{children:[jsx("span",{className:"flex-1 truncate",children:t}),r!=null&&jsx("span",{className:c("shrink-0 inline-flex items-center justify-center rounded-full text-[10px] font-semibold min-w-[18px] h-[18px] px-1",o),children:r})]}),p&&r!==void 0&&r!==null&&jsx("span",{className:"absolute top-1 right-1 w-2 h-2 rounded-full bg-blue-600"})]}),f=c("relative flex items-center gap-3 rounded-md text-sm font-medium transition-colors w-full",p?"justify-center px-2 py-2.5":"px-3 py-2",n?"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",d),h=()=>{a||(l?.(),u.isMobile&&u.closeMobile());},y=s?jsx("a",{href:a?void 0:s,className:f,onClick:h,"aria-current":n?"page":void 0,"data-testid":"sidebar-item",children:m}):jsx("button",{type:"button",className:f,onClick:h,disabled:a,"aria-current":n?"page":void 0,"data-testid":"sidebar-item",children:m});return p?jsx(Qd,{text:b,position:u.position,children:y}):y}function Lh({icon:e,label:t,badge:r,defaultOpen:o=false,className:n,children:a}){let s=Io(),[l,i]=useState(o),d=useRef(null),[u,p]=useState(o?void 0:0),b=useRef(true);return useEffect(()=>{if(b.current){b.current=false,p(l?void 0:0);return}if(l){let m=d.current;if(m){p(m.scrollHeight);let f=setTimeout(()=>p(void 0),200);return ()=>clearTimeout(f)}}else {let m=d.current;m&&(p(m.scrollHeight),requestAnimationFrame(()=>p(0)));}},[l]),s.collapsed?jsx(Qd,{text:t,position:s.position,children:jsxs("button",{type:"button",className:c("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",n),onClick:()=>{s.toggle(),i(true);},"data-testid":"sidebar-submenu-trigger",children:[e&&jsx("span",{className:"shrink-0 w-5 h-5",children:e}),r!=null&&jsx("span",{className:"absolute top-1 right-1 w-2 h-2 rounded-full bg-blue-600"})]})}):jsxs("div",{className:n,"data-testid":"sidebar-submenu",children:[jsxs("button",{type:"button",className:c("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&&jsx("span",{className:"shrink-0 w-5 h-5",children:e}),jsx("span",{className:"flex-1 truncate text-left",children:t}),r!=null&&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}),jsx(Sh,{className:c("shrink-0 text-gray-400 transition-transform duration-200",l&&"rotate-180")})]}),jsx("div",{className:"overflow-hidden transition-[height] duration-200 ease-in-out",style:{height:u===void 0?"auto":u},children:jsx("div",{ref:d,className:"pl-4 py-0.5",children:a})})]})}function Ah({className:e}){let t=Io(),r=Ft(),o=t.isMobile?t.mobileOpen?t.closeLabel??r.closeSidebar:r.openSidebar:t.collapsed?r.expandSidebar:r.collapseSidebar;return jsx("button",{type:"button",onClick:t.toggle,className:c("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":o,"data-testid":"sidebar-toggle",children:jsx(Nh,{className:c("transition-transform duration-200",t.collapsed&&"rotate-180",t.position==="right"&&!t.collapsed&&"rotate-180",t.position==="right"&&t.collapsed&&"rotate-0")})})}function oi({data:e,width:t=96,height:r=28,curve:o="monotone",color:n=sa[0],strokeWidth:a=2,area:s=false,emphasizeLast:l=false,domain:i,ariaLabel:d,className:u,...p}){let b=Math.max(a/2,l?a+2.5:0),m=i??Xt(e)??[0,1],f=ho([0,Math.max(1,e.length-1)],[b,t-b]),h=ho(m,[r-b,b]),y=e.map((v,E)=>({x:f(E),y:v==null?Number.NaN:h(v),defined:v!=null&&Number.isFinite(v)})),C=[...y].reverse().find(v=>v.defined!==false);return jsxs("svg",{width:t,height:r,viewBox:`0 0 ${t} ${r}`,className:c("overflow-visible",u),role:d?"img":void 0,"aria-label":d,"aria-hidden":d?void 0:true,...p,children:[s?jsx("path",{d:wn(y,r-b,o),fill:n,fillOpacity:.12,stroke:"none"}):null,jsx("path",{d:Vr(y,o),fill:"none",stroke:n,strokeWidth:a,strokeLinecap:"round",strokeLinejoin:"round",vectorEffect:"non-scaling-stroke"}),l&&C?jsx("circle",{cx:C.x,cy:C.y,r:a,fill:n,strokeWidth:2,className:"stroke-white dark:stroke-gray-800"}):null]})}var Wh={sm:"p-3",md:"p-4",lg:"p-5"},Hh={sm:"text-[11px]",md:"text-xs",lg:"text-sm"},Fh={sm:"text-xl",md:"text-2xl",lg:"text-3xl"},ec={sm:{width:72,height:22},md:{width:96,height:28},lg:{width:120,height:34}};function Bh(e){return e.direction?e.direction:e.value>0?"up":e.value<0?"down":"flat"}function Vh(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 Oh({direction:e}){return e==="flat"?jsx("svg",{width:"10",height:"10",viewBox:"0 0 10 10",fill:"currentColor","aria-hidden":"true",children:jsx("rect",{x:"1",y:"4.25",width:"8",height:"1.5",rx:"0.75"})}):jsx("svg",{width:"10",height:"10",viewBox:"0 0 10 10",fill:"currentColor","aria-hidden":"true",children:jsx("path",{d:e==="up"?"M5 1 L9.5 8 L0.5 8 Z":"M5 9 L0.5 2 L9.5 2 Z"})})}function $h({label:e,value:t,format:r,delta:o,trend:n,trendColor:a,icon:s,size:l="md",loading:i=false,variant:d="card",footer:u,className:p,...b}){let m=typeof t=="number"?(r??_t)(t):t,f=o?Bh(o):"flat",h=o?(o.format??(y=>Br(y,{signed:true})))(o.value):null;return jsxs("div",{className:c("flex flex-col gap-2",d==="card"&&c("rounded-lg border border-gray-200 bg-white dark:border-gray-700 dark:bg-gray-800",Wh[l]),p),...b,children:[jsxs("div",{className:"flex items-start justify-between gap-2",children:[jsx("span",{className:c("font-medium text-gray-500 dark:text-gray-400",Hh[l]),children:e}),s?jsx("span",{className:"shrink-0 text-gray-400",children:s}):null]}),jsxs("div",{className:"flex items-end justify-between gap-3",children:[jsxs("div",{className:"flex min-w-0 flex-col gap-1",children:[i?jsx("div",{className:"flex items-center",style:{height:l==="lg"?30:24},"aria-busy":"true","aria-live":"polite",children:jsx(Ho,{indeterminate:true,size:l==="lg"?"sm":"xs",thickness:"thin","aria-hidden":"true"})}):jsx("span",{className:c("leading-none font-semibold text-gray-900 dark:text-gray-100",Fh[l]),children:m}),o&&!i?jsxs("span",{className:c("flex items-center gap-1 text-xs font-medium",Vh(f,o.goodWhen??"up")),children:[jsx(Oh,{direction:f}),h,o.period?jsx("span",{className:"font-normal text-gray-500 dark:text-gray-400",children:o.period}):null]}):null]}),n&&n.length>0&&!i?jsx(oi,{data:n,color:a,emphasizeLast:true,area:true,width:ec[l].width,height:ec[l].height,className:"shrink-0"}):null]}),u?jsx("div",{className:"text-xs text-gray-500 dark:text-gray-400",children:u}):null]})}var _h={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 Gh({columns:e=4,className:t,children:r,...o}){return jsx("div",{className:c("grid grid-cols-1 gap-3",_h[e],t),...o,children:r})}var Kh={text:"rounded h-4 w-full",circular:"rounded-full",rectangular:"rounded-none",rounded:"rounded-lg"},Uh={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:""},Yh="bg-gray-200 dark:bg-gray-700";function tc({variant:e="text",animation:t="pulse",width:r,height:o,count:n=1,className:a,style:s,...l}){let i={...r!==void 0&&{width:typeof r=="number"?`${r}px`:r},...o!==void 0&&{height:typeof o=="number"?`${o}px`:o},...s};e==="circular"&&r&&!o&&(i.height=i.width);let d=c(Yh,Kh[e],Uh[t],a);return n===1?jsx("div",{className:d,style:i,"aria-busy":"true","aria-live":"polite",...l}):jsx("div",{className:"space-y-2",children:Array.from({length:n}).map((u,p)=>jsx("div",{className:d,style:i,"aria-busy":"true","aria-live":"polite",...l},p))})}tc.displayName="Skeleton";var Qh={sm:"h-1",md:"h-1.5",lg:"h-2"},ey={sm:"w-3.5 h-3.5",md:"w-4 h-4",lg:"w-5 h-5"},ty={sm:14,md:16,lg:20},ry="[&::-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",oy={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"},ny={sm:"h-4",md:"h-5",lg:"h-6"},ay={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"},sy={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"},iy={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"},ly={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"},rc=(e,t,r)=>Math.min(r,Math.max(t,e)),ai=(e,t,r)=>r>t?(rc(e,t,r)-t)/(r-t)*100:0,Va=(e,t)=>{let r=(.5-e/100)*t,o=Math.round(Math.abs(r)*1e3)/1e3;return `calc(${e}% ${r<0?"-":"+"} ${o}px)`},dy=(e,t,r,o)=>{if(!e)return [];if(Array.isArray(e))return e;let n=o>0?o:1,a=Math.floor((r-t)/n);return a<=0||a>20?[{value:t},{value:r}]:Array.from({length:a+1},(s,l)=>({value:t+l*n}))},oc=forwardRef(({value:e,defaultValue:t,onValueChange:r,min:o=0,max:n=100,step:a=1,size:s="md",color:l="primary",disabled:i=false,readOnly:d=false,label:u,description:p,error:b=false,showValue:m=false,showTooltip:f=false,valueFormat:h,marks:y,trackColor:C,fillColor:v,thumbColor:E,className:k,containerClassName:R,id:g,...P},T)=>{let[D,W]=useState(t??o),V=e!==void 0,M=rc(V?e:D,o,n),w=useId(),N=g??w,x=typeof b=="string"?b:void 0,S=!!b,I=!i&&!d,F=S?"error":l,O=ai(M,o,n),Z=ty[s],U=ee=>{if(!I)return;let L=Number(ee.target.value);V||W(L),r?.(L);},H=useMemo(()=>dy(y,o,n,a),[y,o,n,a]),z=H.some(ee=>ee.label!=null),$=h?h(M):`${M}`,K={width:Va(O,Z)};v&&(K.backgroundColor=v);let se={left:Va(O,Z)};E&&(se.backgroundColor=E,se.borderColor=E);let X=C?{backgroundColor:C}:{};return jsxs("div",{className:c("w-full",R),children:[(u||m)&&jsxs("div",{className:"flex items-center justify-between mb-1.5",children:[u?jsx("label",{htmlFor:N,className:c("text-sm font-medium text-gray-700 dark:text-gray-200",i&&"opacity-50"),children:u}):jsx("span",{}),m&&jsx("span",{className:c("text-sm font-semibold tabular-nums",ly[F]),children:$})]}),jsxs("div",{className:c("relative flex items-center",ny[s],i&&"opacity-50"),children:[jsx("input",{ref:T,type:"range",id:N,min:o,max:n,step:a,value:M,onChange:U,disabled:i,readOnly:d,"aria-invalid":S,"aria-readonly":d||void 0,"aria-describedby":x?`${N}-error`:void 0,tabIndex:I?void 0:-1,className:c("peer absolute inset-0 z-10 m-0 h-full w-full cursor-pointer appearance-none bg-transparent opacity-0",ry,oy[s],!I&&"pointer-events-none cursor-default",k),...P}),jsxs("div",{className:c("pointer-events-none relative w-full overflow-hidden rounded-full bg-gray-200 dark:bg-gray-700",Qh[s]),style:X,children:[jsx("div",{className:c("absolute inset-y-0 left-0 rounded-full transition-[width] duration-150 ease-out",v?"":ay[F]),style:K}),H.map((ee,L)=>{let q=ai(ee.value,o,n),ge=ee.value<=M;return jsx("span",{"data-slider-mark":"",className:c("absolute top-1/2 h-1 w-1 -translate-x-1/2 -translate-y-1/2 rounded-full",ge?"bg-white/80":"bg-gray-400 dark:bg-gray-500"),style:{left:Va(q,Z)}},`mark-${ee.value}-${L}`)})]}),jsx("div",{"data-slider-thumb":"",className:c("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",ey[s],E?"":sy[F],I&&"peer-hover:scale-110 peer-active:scale-110","peer-focus-visible:scale-110 peer-focus-visible:ring-2 peer-focus-visible:ring-offset-2",iy[F]),style:se,children:f&&jsx("span",{"data-slider-tooltip":"",className:c("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:$})})]}),z&&jsx("div",{className:"relative mt-1.5 h-4",children:H.map((ee,L)=>ee.label!=null?jsx("span",{className:"absolute -translate-x-1/2 whitespace-nowrap text-xs text-gray-500 dark:text-gray-400",style:{left:Va(ai(ee.value,o,n),Z)},children:ee.label},`mark-label-${ee.value}-${L}`):null)}),p&&!x&&jsx("p",{className:"mt-1.5 text-sm text-gray-500 dark:text-gray-400",children:p}),x&&jsx("p",{id:`${N}-error`,className:"mt-1.5 text-sm text-red-500 dark:text-red-400",children:x})]})});oc.displayName="Slider";var si=createContext(null);function rn(){let e=useContext(si);if(!e)throw new Error("Tabs components must be used within a Tabs provider");return e}function ac({children:e,defaultValue:t="",value:r,onValueChange:o,variant:n="underline",size:a="md",color:s="default",fullWidth:l=false,orientation:i="horizontal",className:d}){let[u,p]=useState(t),b=r!==void 0,m=b?r:u,f=useCallback(y=>{b||p(y),o?.(y);},[b,o]),h=useMemo(()=>({value:m,onValueChange:f,variant:n,size:a,color:s,orientation:i,fullWidth:l}),[m,f,n,a,s,i,l]);return jsx(si.Provider,{value:h,children:jsx("div",{className:c("w-full",i==="vertical"&&"flex gap-4",d),"data-orientation":i,children:e})})}ac.displayName="Tabs";var fy={none:"gap-0",sm:"gap-1",md:"gap-2",lg:"gap-4"};function sc({children:e,className:t,bgColor:r,gap:o="none"}){let{variant:n,orientation:a,fullWidth:s}=rn(),l=c("flex",a==="vertical"?"flex-col":"flex-row items-center",fy[o]),i={underline:"border-b border-gray-200 dark:border-gray-700",pills:c("p-1 rounded-lg",r||"bg-gray-100 dark:bg-gray-800"),enclosed:"border-b border-gray-200 dark:border-gray-700",soft:c("p-1 rounded-lg",r||"bg-gray-100/50 dark:bg-gray-800/50")};return jsx("div",{role:"tablist","aria-orientation":a,className:c(l,i[n],s&&"w-full",t),children:e})}sc.displayName="TabsList";var hy={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"},ic={sm:"w-3.5 h-3.5",md:"w-4 h-4",lg:"w-5 h-5"},lc={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"}}},yy={underline:"border-b-2 -mb-px",pills:"rounded-md",enclosed:"border border-b-0 rounded-t-md -mb-px",soft:"rounded-md"};function dc({value:e,children:t,disabled:r=false,icon:o,endIcon:n,className:a,activeClassName:s,inactiveClassName:l}){let{value:i,onValueChange:d,variant:u,size:p,color:b,fullWidth:m}=rn(),f=i===e,h=()=>{r||d(e);},y=k=>{(k.key==="Enter"||k.key===" ")&&(k.preventDefault(),h());},C=c("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",hy[p],m&&"flex-1"),v=f?c(lc[b][u].active,s):c(lc[b][u].inactive,l),E=r?"opacity-50 cursor-not-allowed":"cursor-pointer";return jsxs("button",{type:"button",role:"tab","aria-selected":f,"aria-disabled":r,tabIndex:f?0:-1,onClick:h,onKeyDown:y,disabled:r,className:c(C,yy[u],v,E,a),children:[o&&jsx("span",{className:c("shrink-0",ic[p]),children:o}),jsx("span",{children:t}),n&&jsx("span",{className:c("shrink-0",ic[p]),children:n})]})}dc.displayName="TabsTrigger";function cc({value:e,children:t,className:r,forceMount:o=false}){let{value:n}=rn(),a=n===e;return !a&&!o?null:jsx("div",{role:"tabpanel",hidden:!a,tabIndex:0,className:c("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})}cc.displayName="TabsContent";function ky({className:e}){return jsx("svg",{className:e,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",children: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 wy({className:e}){return jsx("svg",{className:e,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",children: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 Cy({className:e}){return jsx("svg",{className:e,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",children: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 uc({className:e}){return jsx("svg",{className:e,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",children: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 Ny({className:e}){return jsx("svg",{className:e,viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",children:jsx("path",{d:"M4 4L12 12M12 4L4 12",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})})}var Sy={success:ky,error:wy,warning:Cy,info:uc,default:uc},Ry={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"}},Ty={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 gc({children:e,title:t,description:r,type:o="default",variant:n="soft",icon:a,action:s,onClose:l,closable:i=true,className:d,...u}){let p=Sy[o],b=jsx(p,{className:"w-5 h-5"}),m=e??r;return jsxs("div",{role:"alert",className:c("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",Ry[o][n],d),...u,children:[jsx("div",{className:c("flex-shrink-0 mt-0.5",n==="solid"?"text-white":Ty[o]),children:a??b}),jsxs("div",{className:"flex-1 min-w-0",children:[t&&jsx("div",{className:"font-semibold text-sm mb-1",children:t}),m&&jsx("div",{className:"text-sm opacity-90",children:m}),s&&jsx("div",{className:"mt-3",children:s})]}),i&&jsx("button",{type:"button",onClick:l,className:c("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",n==="solid"?"text-white":""),"aria-label":"Close notification",children:jsx(Ny,{className:"w-4 h-4"})})]})}gc.displayName="Toast";var Dy={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"},Iy={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"}},My={sm:"px-2 py-1 text-xs",md:"px-3 py-1.5 text-sm",lg:"px-4 py-2 text-base"},Ly={sm:"border-4",md:"border-[5px]",lg:"border-[6px]"},Ay={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"},zy={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 mt({children:e,content:t,position:r="top",variant:o="default",size:n="md",trigger:a="hover",open:s,delay:l=0,showArrow:i=true,maxWidth:d="max-w-xs",className:u,contentClassName:p,disabled:b=false,...m}){let[f,h]=useState(false),y=useRef(null),C=useCallback(()=>{b||(l>0?y.current=setTimeout(()=>h(true),l):h(true));},[l,b]),v=useCallback(()=>{y.current&&(clearTimeout(y.current),y.current=null),h(false);},[]),E=useCallback(()=>{b||h(g=>!g);},[b]),k=a==="manual"?s:f,R={hover:{onMouseEnter:C,onMouseLeave:v,onFocus:C,onBlur:v},click:{onClick:E},manual:{}}[a];return jsxs("div",{className:c("relative inline-flex",u),...R,...m,children:[e,k&&!b&&jsxs("div",{role:"tooltip",className:c("absolute z-50 whitespace-normal wrap-break-word rounded-md","transition-opacity duration-150",Ay[r],Dy[o],My[n],d,p),children:[t,i&&jsx("span",{className:c("absolute w-0 h-0 border-solid",Ly[n],zy[r],Iy[o][r]),"aria-hidden":"true"})]})]})}mt.displayName="Tooltip";function Hy(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 Fy(e){switch(e){case "sm":return "py-6";case "lg":return "py-16";default:return "py-10"}}function bc({variant:e="default",size:t="md",sticky:r=false,className:o,children:n,...a}){return jsx("footer",{className:c(Hy(e),Fy(t),r&&"sticky bottom-0 z-40",o),...a,children:jsx("div",{className:"container mx-auto px-4",children:n})})}bc.displayName="Footer";function By(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 hc({title:e,titleClassName:t,columns:r,className:o,children:n,...a}){return jsxs("div",{className:c(r&&"grid gap-8",By(r),o),...a,children:[e&&jsx("h3",{className:c("text-sm font-semibold uppercase tracking-wider text-gray-900 dark:text-white",r&&"col-span-full",t),children:e}),n]})}hc.displayName="FooterSection";function yc({title:e,titleClassName:t,className:r,children:o,...n}){return jsxs("div",{className:c("flex flex-col gap-3",r),...n,children:[e&&jsx("h4",{className:c("text-sm font-semibold uppercase tracking-wider text-gray-900 dark:text-white",t),children:e}),o]})}yc.displayName="FooterColumn";function xc({external:e=false,className:t,children:r,...o}){return jsx("a",{className:c("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,...o,children:r})}xc.displayName="FooterLink";function vc({copyright:e,className:t,children:r,...o}){return jsxs("div",{className:c("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),...o,children:[e&&jsx("p",{className:"text-sm text-gray-500 dark:text-gray-400",children:e}),r]})}vc.displayName="FooterBottom";function kc({className:e,children:t,...r}){return jsx("div",{className:c("flex items-center gap-4",e),...r,children:t})}kc.displayName="FooterSocial";function wc({icon:e,label:t,className:r,...o}){return jsx("a",{className:c("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,...o,children:e})}wc.displayName="FooterSocialLink";var Yy=4.5,jy=48,Nc=false,qy=memo(function({points:t}){return jsx("g",{children:t.map(r=>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 Zy({width:e,height:t,data:r,resolvedSeries:o,x:n,y:a,grid:s,size:l,bubble:i,trendLine:d,quadrants:u,pointRadius:p,margin:b,tooltip:m,onPointClick:f,plotLabel:h,formatValue:y,formatX:C}){let[v,E]=useState(null),k=useMemo(()=>{let P=o.filter(S=>!S.hidden),T=P.map(S=>S.key),D=to({width:e,height:t,data:r,x:{...n,scale:n.scale==="time"?"time":"linear"},y:a,bounds:Xt(Fr(r,T)),margin:b,formatValue:y,formatX:C}),W=i?Fr(r,[i.key]):[],V=i?Xt(W):null,[_,M]=i?.range??[4,14],w=S=>{if(!i||!V)return p;let I=St(S,i.key);if(I===null)return _;let[F,O]=V,Z=O===F?1:(I-F)/(O-F);return Math.sqrt(_*_+Z*(M*M-_*_))},N=[];P.forEach(S=>{r.forEach((I,F)=>{let O=St(I,S.key),Z=D.categoryPositions[F];O===null||!Number.isFinite(Z)||N.push({seriesKey:S.key,seriesLabel:Lt(S),color:S.color,index:F,cx:Z,cy:D.valueScale(O),r:w(I),xValue:Nr(D.xValues[F]),yValue:O});});});let x=null;if(d&&N.length>1){let S=N.length,I=N.reduce((H,z)=>H+z.xValue,0),F=N.reduce((H,z)=>H+z.yValue,0),O=N.reduce((H,z)=>H+z.xValue*z.yValue,0),Z=N.reduce((H,z)=>H+z.xValue*z.xValue,0),U=S*Z-I*I;if(U!==0){let H=(S*O-I*F)/U,z=(F-H*I)/S,$=N.map(ee=>ee.xValue),[K,se]=[Math.min(...$),Math.max(...$)],X=N.map(ee=>ee.cx);x={x1:Math.min(...X),y1:D.valueScale(H*K+z),x2:Math.max(...X),y2:D.valueScale(H*se+z)};}}return {visible:P,points:N,trend:x,xTicks:D.categoryTicks,yTicks:D.valueTicks,valueScale:D.valueScale,positions:D.categoryPositions,innerWidth:D.innerWidth,innerHeight:D.innerHeight,margin:D.margin,xValues:D.xValues}},[r,o,n,a,e,t,b,i,d,p,y,C]),R=useCallback(P=>{if(m===false||k.points.length===0)return;let T=P.currentTarget.getBoundingClientRect(),D=P.clientX-T.left-k.margin.left,W=P.clientY-T.top-k.margin.top,V=null,_=jy;for(let M of k.points){let w=Math.hypot(M.cx-D,M.cy-W);w<_&&(_=w,V=M);}E(V);},[m,k.points,k.margin]),g=useCallback(()=>{!f||!v||f({seriesKey:v.seriesKey,seriesLabel:v.seriesLabel,color:v.color,value:v.yValue,formattedValue:y(v.yValue),datum:r[v.index],index:v.index,x:k.xValues[v.index]});},[f,v,y,r,k.xValues]);return jsxs(Fragment,{children:[jsxs("svg",{width:e,height:t,role:"img","aria-label":h??k.visible.map(P=>Lt(P)).join(", "),tabIndex:0,className:"touch-none focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-blue-500",onPointerMove:R,onPointerLeave:()=>E(null),onBlur:()=>E(null),onClick:g,children:[jsxs("g",{transform:`translate(${k.margin.left}, ${k.margin.top})`,children:[jsx(Wr,{width:k.innerWidth,height:k.innerHeight,horizontal:s==="y"||s==="both"?k.yTicks.map(P=>P.offset):void 0,vertical:s==="x"||s==="both"?k.xTicks.map(P=>P.offset):void 0}),u?.y!==void 0?jsx("line",{x1:0,y1:k.valueScale(u.y),x2:k.innerWidth,y2:k.valueScale(u.y),stroke:"var(--color-chart-muted)",strokeWidth:1,strokeDasharray:"4 4"}):null,k.trend?jsx("line",{x1:k.trend.x1,y1:k.trend.y1,x2:k.trend.x2,y2:k.trend.y2,stroke:"var(--color-chart-muted)",strokeWidth:1.5,strokeDasharray:"4 4"}):null,jsx(qy,{points:k.points}),v?jsx("circle",{cx:v.cx,cy:v.cy,r:v.r+3,fill:"none",stroke:v.color,strokeWidth:2,"aria-hidden":"true"}):null]}),jsx("g",{transform:`translate(${k.margin.left}, ${k.margin.top+k.innerHeight})`,children:n.hidden?null:jsx(Ut,{orientation:"bottom",ticks:k.xTicks,length:k.innerWidth,label:n.label,size:l})}),jsx("g",{transform:`translate(${k.margin.left}, ${k.margin.top})`,children:a?.hidden?null:jsx(Ut,{orientation:"left",ticks:k.yTicks,length:k.innerHeight,showLine:false,label:a?.label,size:l})})]}),v&&m!==false?jsx(ur,{x:k.margin.left+v.cx,y:k.margin.top+v.cy,containerWidth:e,children:typeof m=="function"?m({x:k.xValues[v.index],xLabel:C(k.xValues[v.index],v.index),index:v.index,points:[{seriesKey:v.seriesKey,seriesLabel:v.seriesLabel,color:v.color,value:v.yValue,formattedValue:y(v.yValue),datum:r[v.index]}]}):jsx(pr,{title:`${n.label??n.key} ${C(k.xValues[v.index],v.index)}`,points:[{seriesKey:v.seriesKey,seriesLabel:v.seriesLabel,color:v.color,value:v.yValue,formattedValue:y(v.yValue),datum:r[v.index]}]})}):null]})}function Jy({data:e,series:t,x:r,y:o,height:n=280,width:a,size:s="md",grid:l="both",legend:i,tooltip:d=true,tableView:u=false,emphasis:p,title:b,description:m,loading:f=false,emptyState:h,onPointClick:y,bubble:C,trendLine:v=false,quadrants:E,pointRadius:k=Yy,legendToggle:R=true,margin:g,locale:P,plotLabel:T,className:D,...W}){let[V,_]=useState(()=>new Set);t.length>3&&!Nc&&(Nc=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 M=useMemo(()=>t.map((O,Z)=>({...O,hidden:O.hidden||V.has(O.key),color:Cr(O,Z,p)})),[t,V,p]),w=useMemo(()=>o?.format??(O=>_t(O,P)),[o?.format,P]),N=useMemo(()=>r.format??(O=>r.scale==="time"?Gt(O instanceof Date?O:new Date(Nr(O)),P):_t(Nr(O),P)),[r.format,r.scale,P]),x=useCallback(O=>{_(Z=>{let U=new Set(Z);return U.has(O)?U.delete(O):U.add(O),U});},[]),S=i===void 0?t.length>=2:i!==false,I=typeof i=="string"?i:"bottom",F=M.filter(O=>!O.hidden).length;return jsx(lr,{title:b,description:m,height:n,width:a,size:s,loading:f,empty:e.length===0||F===0,emptyState:h,tableView:u,legendPosition:I,legend:S?jsx(dr,{items:Hr(M,p),position:I,marker:"dot",size:s,onToggle:R?x:void 0}):void 0,table:u?jsx(cr,{data:e,series:M,xKey:r.key,xLabel:r.label??r.key,formatX:N,formatValue:w,caption:typeof b=="string"?b:void 0}):void 0,className:D,...W,children:({width:O})=>jsx(Zy,{width:O,height:n,data:e,resolvedSeries:M,x:r,y:o,grid:l,size:s,bubble:C,trendLine:v,quadrants:E,pointRadius:k,margin:g,tooltip:d,onPointClick:y,plotLabel:T,formatValue:w,formatX:N})})}var Rc="se-grid-pattern",Tc=memo(function({gridSize:t,zoom:r}){let o=t*r;return jsxs("svg",{className:"absolute inset-0 w-full h-full pointer-events-none","aria-hidden":"true",children:[jsx("defs",{children:jsx("pattern",{id:Rc,width:o,height:o,patternUnits:"userSpaceOnUse",children:jsx("circle",{cx:1,cy:1,r:1,className:"fill-gray-300 dark:fill-gray-600"})})}),jsx("rect",{width:"100%",height:"100%",fill:`url(#${Rc})`})]})});function io(e,t){return e.collapsed?40:e.height?e.height:40+(e.notes?24:0)+e.fields.length*32+(t?36:0)}function on(e,t){return 40+(t?24:0)+e*32+32/2}function Pc(e,t,r){let o=e.fields.findIndex(i=>i.id===t);if(o===-1)return null;let n=e.width??260,a=!!e.notes,s=e.y+on(o,a);return {x:r==="left"?e.x+0:e.x+n-0,y:s}}function ui(e,t){return Math.round(e/t)*t}function Kn(e,t,r){return Math.min(r,Math.max(t,e))}function Un(e,t,r,o){return {x:(e-o.left-r.x)/r.zoom,y:(t-o.top-r.y)/r.zoom}}function Ga(e,t,r,o){let n=Math.abs(r-e),a=Math.max(50,n*.5),s=e+a,l=t,i=r-a;return `M ${e} ${t} C ${s} ${l}, ${i} ${o}, ${r} ${o}`}function Ec(e,t,r,o,n=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 f of e){let h=f.width??260,y=io(f,o);a=Math.min(a,f.x),s=Math.min(s,f.y),l=Math.max(l,f.x+h),i=Math.max(i,f.y+y);}let d=l-a+n*2,u=i-s+n*2,p=Math.min(t/d,r/u,1),b=(t-d*p)/2-(a-n)*p,m=(r-u*p)/2-(s-n)*p;return {x:b,y:m,zoom:p}}var jn=["text","varchar","char","int2","int4","int8","serial","bigserial","float4","float8","numeric","decimal","bool","date","time","timestamp","timestamptz","uuid","json","jsonb","bytea"];function Dc(){return `table-${Date.now()}-${Math.random().toString(36).slice(2,8)}`}function Yn(){return `field-${Date.now()}-${Math.random().toString(36).slice(2,8)}`}function pi(){return `rel-${Date.now()}-${Math.random().toString(36).slice(2,8)}`}function gi(e="new_field"){return {id:Yn(),name:e,type:"text",nullable:true}}function mi(e,t,r="new_table"){return {id:Dc(),name:r,x:e,y:t,fields:[{id:Yn(),name:"id",type:"serial",primaryKey:true},{id:Yn(),name:"createdAt",type:"timestamp"},{id:Yn(),name:"updatedAt",type:"timestamp"}]}}var Xa=()=>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:[jsx("path",{d:"M10 1l2 2-5 5M8.5 4.5L11 7"}),jsx("circle",{cx:"4.5",cy:"11.5",r:"3"})]}),Mc=()=>jsxs("svg",{className:"w-3.5 h-3.5 flex-shrink-0",viewBox:"0 0 16 16",fill:"currentColor",children:[jsx("circle",{cx:"8",cy:"8",r:"6",className:"fill-blue-500"}),jsx("path",{d:"M5 8h6M8 5l3 3-3 3",stroke:"white",strokeWidth:"1.5",fill:"none",strokeLinecap:"round",strokeLinejoin:"round"})]}),ox=({collapsed:e})=>jsx("svg",{className:"w-3.5 h-3.5",viewBox:"0 0 16 16",fill:"currentColor",children:e?jsx("path",{d:"M6 3l5 5-5 5V3z"}):jsx("path",{d:"M3 6l5 5 5-5H3z"})}),Lc=()=>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:jsx("path",{d:"M3 2v12M7 4h6M7 8h4M7 12h5"})}),Ac=()=>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:jsx("path",{d:"M4 2v8a4 4 0 008 0V2"})}),nx=()=>jsx("svg",{className:"w-3 h-3",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",children:jsx("path",{d:"M4 8h8"})}),ax=()=>jsxs("svg",{className:"w-3 h-3 text-gray-300",viewBox:"0 0 16 16",fill:"currentColor",children:[jsx("circle",{cx:"5",cy:"4",r:"1.5"}),jsx("circle",{cx:"11",cy:"4",r:"1.5"}),jsx("circle",{cx:"5",cy:"8",r:"1.5"}),jsx("circle",{cx:"11",cy:"8",r:"1.5"}),jsx("circle",{cx:"5",cy:"12",r:"1.5"}),jsx("circle",{cx:"11",cy:"12",r:"1.5"})]}),sx=memo(function({field:t,tableId:r,editable:o,readOnly:n,disabled:a,onFieldChange:s}){let[l,i]=useState(false),[d,u]=useState(t.defaultValue??""),p=o&&!n&&!a,b=()=>{i(false),s?.(r,t.id,{defaultValue:d||void 0});};return p?l?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:d,onChange:m=>u(m.target.value),onBlur:b,onKeyDown:m=>{m.key==="Enter"&&b(),m.key==="Escape"&&i(false);},onMouseDown:m=>m.stopPropagation(),autoFocus:true}):t.defaultValue?jsxs("button",{type:"button",className:"text-xs text-emerald-500 flex-shrink-0 truncate max-w-16 cursor-pointer",onClick:m=>{m.stopPropagation(),u(t.defaultValue??""),i(true);},onMouseDown:m=>m.stopPropagation(),title:`Default: ${t.defaultValue}`,children:["= ",t.defaultValue]}):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(),u(""),i(true);},onMouseDown:m=>m.stopPropagation(),title:"Set default value",children:"= \u2205"}):t.defaultValue?jsxs("span",{className:"text-xs text-emerald-500 flex-shrink-0 truncate max-w-16",title:`Default: ${t.defaultValue}`,children:["= ",t.defaultValue]}):null}),Wc=memo(function({table:t,selected:r,disabled:o,readOnly:n,editable:a,dropTarget:s,fieldTypes:l,onTableNameChange:i,onTableNotesChange:d,onToggleCollapse:u,onFieldChange:p,onFieldAdd:b,onFieldRemove:m,onFieldReorder:f,onResizeStart:h}){let y=t.width??260,C=t.collapsed??false,v=l.length>0?l:jn,[E,k]=useState(null),[R,g]=useState(null),P=useRef(null),T=useCallback(x=>{i?.(t.id,x.target.value);},[t.id,i]),D=useCallback((x,S)=>{p?.(t.id,x,{name:S});},[t.id,p]),W=useCallback((x,S)=>{p?.(t.id,x,{type:S});},[t.id,p]),V=useCallback((x,S)=>{p?.(t.id,x,{primaryKey:!S});},[t.id,p]),_=useCallback((x,S)=>{p?.(t.id,x,{nullable:!S});},[t.id,p]),M=useCallback((x,S)=>{p?.(t.id,x,{indexed:!S});},[t.id,p]),w=useCallback((x,S)=>{p?.(t.id,x,{unique:!S});},[t.id,p]),N=useCallback(()=>{b?.(t.id);},[t.id,b]);return jsxs("div",{"data-table-id":t.id,className:c("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",o&&"opacity-60",t.locked&&"!cursor-default"),style:{left:t.x,top:t.y,width:y,height:t.height,userSelect:"none",overflow:t.height?"hidden":void 0},children:[jsxs("div",{className:c("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&&!n&&!o?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:T,onMouseDown:x=>x.stopPropagation()}):jsx("span",{className:"flex-1 min-w-0 text-sm font-semibold text-gray-800 dark:text-gray-100 truncate",children:t.name}),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:x=>{x.stopPropagation(),u?.(t.id);},onMouseDown:x=>x.stopPropagation(),"aria-label":C?"Expand table":"Collapse table",children:jsx(ox,{collapsed:C})})]}),!C&&(a&&!n&&!o?jsx("div",{className:"px-3 border-b border-gray-100 dark:border-gray-700 flex items-center",style:{height:24},children: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:x=>d?.(t.id,x.target.value),onMouseDown:x=>x.stopPropagation()})}):t.notes?jsx("div",{className:"px-3 border-b border-gray-100 dark:border-gray-700 flex items-center",style:{height:24},children:jsx("span",{className:"text-xs italic text-gray-400 dark:text-gray-500 truncate",children:t.notes})}):null),!C&&jsxs("div",{className:t.height?"overflow-y-auto flex-1 min-h-0":void 0,children:[t.fields.map((x,S)=>jsxs("div",{"data-field-id":x.id,"data-table-id":t.id,className:c("flex items-center gap-1.5 pr-2 relative group",a&&!n&&!o?"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",E===S&&"opacity-40",R===S&&"!border-t-2 !border-t-blue-400"),style:{height:32},draggable:a&&!n&&!o,onDragStart:I=>{!a||n||o||(I.stopPropagation(),P.current=S,k(S),I.dataTransfer.effectAllowed="move",I.dataTransfer.setData("text/plain",String(S)));},onDragOver:I=>{P.current!==null&&(I.preventDefault(),I.stopPropagation(),g(S));},onDragLeave:()=>{R===S&&g(null);},onDrop:I=>{I.preventDefault(),I.stopPropagation(),P.current!==null&&P.current!==S&&f?.(t.id,P.current,S),P.current=null,k(null),g(null);},onDragEnd:()=>{P.current=null,k(null),g(null);},children:[jsx("div",{"data-connection-side":"left","data-field-id":x.id,"data-table-id":t.id,className:c("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&&!n&&!o&&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:jsx(ax,{})}),a&&!n&&!o?jsx("button",{type:"button",className:c("w-4 text-xs font-bold flex-shrink-0 text-center cursor-pointer",x.nullable?"text-gray-400":"text-transparent"),onClick:I=>{I.stopPropagation(),_(x.id,x.nullable??false);},onMouseDown:I=>I.stopPropagation(),title:x.nullable?"Nullable":"Not nullable",children:"?"}):jsx("span",{className:c("w-4 text-xs font-bold flex-shrink-0 text-center",x.nullable?"text-gray-400":"text-transparent"),children:x.nullable?"?":""}),x.primaryKey&&x.foreignKey?jsxs("span",{className:"flex items-center gap-0.5 flex-shrink-0",children:[a&&!n&&!o?jsx("button",{type:"button",className:"flex-shrink-0 cursor-pointer",onClick:I=>{I.stopPropagation(),V(x.id,true);},onMouseDown:I=>I.stopPropagation(),title:"Primary Key (click to remove)",children:jsx(Xa,{})}):jsx(Xa,{}),jsx(Mc,{})]}):x.primaryKey?a&&!n&&!o?jsx("button",{type:"button",className:"flex-shrink-0 cursor-pointer",onClick:I=>{I.stopPropagation(),V(x.id,true);},onMouseDown:I=>I.stopPropagation(),title:"Primary Key (click to remove)",children:jsx(Xa,{})}):jsx(Xa,{}):x.foreignKey?jsx(Mc,{}):a&&!n&&!o?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:I=>{I.stopPropagation(),V(x.id,false);},onMouseDown:I=>I.stopPropagation(),title:"Set as Primary Key","aria-label":"Set as primary key",children: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:[jsx("path",{d:"M10 1l2 2-5 5M8.5 4.5L11 7"}),jsx("circle",{cx:"4.5",cy:"11.5",r:"3"})]})}):jsx("span",{className:"w-3.5 flex-shrink-0"}),a&&!n&&!o?jsx("input",{className:c("flex-1 min-w-0 text-xs bg-transparent border-none outline-none focus:ring-0 p-0 truncate cursor-text",x.primaryKey?"text-blue-600 dark:text-blue-400 font-medium":"text-gray-700 dark:text-gray-300"),"aria-label":"Field name",value:x.name,onChange:I=>D(x.id,I.target.value),onMouseDown:I=>I.stopPropagation()}):jsx("span",{className:c("flex-1 min-w-0 text-xs truncate",x.primaryKey?"text-blue-600 dark:text-blue-400 font-medium":"text-gray-700 dark:text-gray-300"),children:x.name}),a&&!n&&!o?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:x.type,onChange:I=>W(x.id,I.target.value),onMouseDown:I=>I.stopPropagation(),children:[v.map(I=>jsx("option",{value:I,children:I},I)),!v.includes(x.type)&&jsx("option",{value:x.type,children:x.type})]}):jsx("span",{className:"text-xs text-gray-400 dark:text-gray-500 flex-shrink-0",children:x.type}),jsx(sx,{field:x,tableId:t.id,editable:a,readOnly:n,disabled:o,onFieldChange:p}),x.indexed&&jsx(Lc,{}),x.unique&&jsx(Ac,{}),a&&!n&&!o&&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:[jsx("button",{type:"button",className:c("cursor-pointer transition-opacity",x.indexed?"opacity-100":"opacity-30 hover:opacity-100"),onClick:I=>{I.stopPropagation(),M(x.id,x.indexed??false);},onMouseDown:I=>I.stopPropagation(),title:x.indexed?"Indexed (click to remove)":"Add index",children:jsx(Lc,{})}),jsx("button",{type:"button",className:c("cursor-pointer transition-opacity",x.unique?"opacity-100":"opacity-30 hover:opacity-100"),onClick:I=>{I.stopPropagation(),w(x.id,x.unique??false);},onMouseDown:I=>I.stopPropagation(),title:x.unique?"Unique (click to remove)":"Add unique constraint",children:jsx(Ac,{})}),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:I=>{I.stopPropagation(),m?.(t.id,x.id);},onMouseDown:I=>I.stopPropagation(),title:"Remove field",children:jsx(nx,{})})]}),jsx("div",{"data-connection-side":"right","data-field-id":x.id,"data-table-id":t.id,className:c("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}})]},x.id)),a&&!n&&!o&&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:x=>{x.stopPropagation(),N();},onMouseDown:x=>x.stopPropagation(),children:[jsx("svg",{className:"w-3 h-3",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",children:jsx("path",{d:"M8 4v8M4 8h8"})}),"Add field"]})]}),!o&&!n&&jsx("div",{"data-resize-handle":"corner",className:"absolute -bottom-[5px] -right-[5px] w-[14px] h-[14px] cursor-nwse-resize z-20 group/resize",onMouseDown:x=>{x.stopPropagation(),x.preventDefault();let S=t.height??io(t,a);h?.(t.id,x.clientX,x.clientY,y,S);},children: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:[jsx("path",{d:"M12 2v10H2",opacity:"0"}),jsx("path",{d:"M6 12L12 6"}),jsx("path",{d:"M10 12L12 10"})]})})]})});function lx(e,t){let r=t.find(f=>f.id===e.from.tableId),o=t.find(f=>f.id===e.to.tableId);if(!r||!o||r.collapsed||o.collapsed)return null;let n=r.fields.findIndex(f=>f.id===e.from.fieldId),a=o.fields.findIndex(f=>f.id===e.to.fieldId);if(n===-1||a===-1)return null;let s=r.width??260,l=o.width??260,i=r.x+s/2,d=o.x+l/2,u=r.y+on(n,!!r.notes),p=o.y+on(a,!!o.notes),b,m;return i<=d?(b=r.x+s,m=o.x):(b=r.x,m=o.x+l),{x1:b,y1:u,x2:m,y2:p,cardinality:e.cardinality??"1:n"}}var hi=["1:1","1:n","n:1","n:n"];function dx(e){let t=hi.indexOf(e);return hi[(t+1)%hi.length]}var Fc=memo(function({relations:t,tables:r,viewport:o,selectedRelationId:n,disabled:a,onRelationClick:s,onCardinalityChange:l}){return jsx("svg",{className:"absolute top-0 left-0 pointer-events-none",style:{width:"100%",height:"100%",overflow:"visible"},children:jsx("g",{transform:`translate(${o.x}, ${o.y}) scale(${o.zoom})`,children:t.map(i=>{let d=lx(i,r);if(!d)return null;let{x1:u,y1:p,x2:b,y2:m,cardinality:f}=d,h=Ga(u,p,b,m),y=n===i.id,C=(u+b)/2,v=(p+m)/2;return jsxs("g",{children:[jsx("path",{d:h,fill:"none",stroke:"transparent",strokeWidth:16,className:"pointer-events-auto cursor-pointer",onClick:E=>{a||s?.(i.id,E);}}),jsx("path",{d:h,fill:"none",stroke:y?"#3b82f6":"#9ca3af",strokeWidth:y?2.5:1.5,className:"transition-colors"}),jsx("circle",{cx:u,cy:p,r:3,fill:y?"#3b82f6":"#9ca3af"}),jsx("circle",{cx:b,cy:m,r:3,fill:y?"#3b82f6":"#9ca3af"}),f&&jsxs("g",{className:a?void 0:"pointer-events-auto cursor-pointer",onClick:a?void 0:E=>{E.stopPropagation(),l?.(i.id,dx(f));},children:[jsx("rect",{x:C-14,y:v-9,width:28,height:18,rx:4,fill:"white",stroke:y?"#3b82f6":"#d1d5db",strokeWidth:1}),jsx("text",{x:C,y:v+4,textAnchor:"middle",className:"text-[10px] font-mono",fill:y?"#3b82f6":"#6b7280",children:f})]})]},i.id)})})})});var ux=()=>jsx("svg",{className:"w-4 h-4",viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true",children: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"})}),px=()=>jsx("svg",{className:"w-4 h-4",viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true",children:jsx("path",{fillRule:"evenodd",d:"M5 10a1 1 0 011-1h8a1 1 0 110 2H6a1 1 0 01-1-1z",clipRule:"evenodd"})}),gx=()=>jsx("svg",{className:"w-4 h-4",viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true",children: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"})}),mx=()=>jsx("svg",{className:"w-4 h-4",viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true",children: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"})}),fx=()=>jsx("svg",{className:"w-4 h-4",viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true",children: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"})}),bx=()=>jsx("svg",{className:"w-4 h-4",viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true",children: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"})}),hx=()=>jsx("svg",{className:"w-4 h-4",viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true",children: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"})}),yx=()=>jsx("svg",{className:"w-4 h-4",viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true",children: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"})}),xx=()=>jsx("svg",{className:"w-4 h-4",viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true",children: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"})}),vx=()=>jsx("svg",{className:"w-4 h-4",viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true",children: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"})}),kx=()=>jsx("svg",{className:"w-4 h-4",viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true",children:jsx("path",{d:"M3 3h4v4H3V3zm0 10h4v4H3v-4zm10-10h4v4h-4V3zm0 10h4v4h-4v-4zM7 5h6v1H7V5zm0 8h6v1H7v-1zM5 7v6h1V7H5zm8 0v6h1V7h-1z"})}),Bc=memo(function({zoom:t,onZoomIn:r,onZoomOut:o,onResetView:n,onFitToContent:a,onAddTable:s,onExportJSON:l,onImportJSON:i,onExportSQL:d,onUndo:u,onRedo:p,canUndo:b=false,canRedo:m=false,onAutoLayout:f,disabled:h,className:y}){let[C,v]=useState(false),[E,k]=useState(false),[R,g]=useState(false),[P,T]=useState(""),[D,W]=useState(""),[V,_]=useState(""),M=useCallback(()=>{T(l()),v(true);},[l]),w=useCallback(()=>{D.trim()&&(i(D.trim()),W(""),k(false));},[D,i]),N=useCallback(()=>{W(""),k(false);},[]),x=useCallback(()=>{v(false);},[]),S=useCallback(()=>{d&&(_(d()),g(true));},[d]),I=useCallback(()=>{g(false);},[]),F=Math.round(t*100);return jsxs(Fragment,{children:[jsxs("div",{className:c("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",y),"data-testid":"schema-toolbar",onMouseDown:O=>O.stopPropagation(),children:[jsxs(Go,{size:"sm",children:[jsx(mt,{content:"Zoom in",size:"sm",position:"bottom",children:jsx(gt,{icon:jsx(ux,{}),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:h,"aria-label":"Zoom in"})}),jsx(mt,{content:"Zoom out",size:"sm",position:"bottom",children:jsx(gt,{icon:jsx(px,{}),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:h,"aria-label":"Zoom out"})})]}),jsxs("span",{className:"text-xs font-mono text-gray-500 dark:text-gray-400 min-w-[3ch] text-center select-none",children:[F,"%"]}),jsx("div",{className:"w-px h-5 bg-gray-200 dark:bg-gray-600"}),jsx(mt,{content:"Reset view",size:"sm",position:"bottom",children:jsx(gt,{icon:jsx(gx,{}),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:h,"aria-label":"Reset view"})}),jsx(mt,{content:"Fit to content",size:"sm",position:"bottom",children:jsx(gt,{icon:jsx(mx,{}),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:h,"aria-label":"Fit to content"})}),jsx("div",{className:"w-px h-5 bg-gray-200 dark:bg-gray-600"}),jsx(mt,{content:"Add table",size:"sm",position:"bottom",children:jsx(gt,{icon:jsx(fx,{}),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:h,"aria-label":"Add table"})}),jsx("div",{className:"w-px h-5 bg-gray-200 dark:bg-gray-600"}),jsx(mt,{content:"Export JSON",size:"sm",position:"bottom",children:jsx(gt,{icon:jsx(bx,{}),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:M,disabled:h,"aria-label":"Export JSON"})}),jsx(mt,{content:"Import JSON",size:"sm",position:"bottom",children:jsx(gt,{icon:jsx(hx,{}),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:()=>k(true),disabled:h,"aria-label":"Import JSON"})}),d&&jsx(mt,{content:"Export SQL",size:"sm",position:"bottom",children:jsx(gt,{icon:jsx(yx,{}),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:h,"aria-label":"Export SQL"})}),(u||p)&&jsxs(Fragment,{children:[jsx("div",{className:"w-px h-5 bg-gray-200 dark:bg-gray-600"}),jsxs(Go,{size:"sm",children:[jsx(mt,{content:"Undo (Ctrl+Z)",size:"sm",position:"bottom",children:jsx(gt,{icon:jsx(xx,{}),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:h||!b,"aria-label":"Undo"})}),jsx(mt,{content:"Redo (Ctrl+Y)",size:"sm",position:"bottom",children:jsx(gt,{icon:jsx(vx,{}),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:h||!m,"aria-label":"Redo"})})]})]}),f&&jsxs(Fragment,{children:[jsx("div",{className:"w-px h-5 bg-gray-200 dark:bg-gray-600"}),jsx(mt,{content:"Auto layout",size:"sm",position:"bottom",children:jsx(gt,{icon:jsx(kx,{}),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:f,disabled:h,"aria-label":"Auto layout"})})]})]}),jsx(Yr,{isOpen:C,onClose:x,title:"Export Schema",description:"Copy the JSON below to save your schema.",size:"lg",showSubmit:false,showCancel:true,cancelLabel:"Close",children:jsx(Er,{label:"Schema JSON",multiline:true,rows:12,value:P,readOnly:true,size:"sm"})}),jsx(Yr,{isOpen:E,onClose:N,title:"Import Schema",description:"Paste schema JSON to load it into the editor.",size:"lg",showSubmit:true,submitLabel:"Import",onSubmitClick:w,showCancel:true,cancelLabel:"Cancel",children:jsx(Er,{label:"Schema JSON",multiline:true,rows:12,value:D,onChange:O=>W(O.target.value),placeholder:'{"tables": [], "relations": []}',size:"sm"})}),jsx(Yr,{isOpen:R,onClose:I,title:"Export SQL",description:"Generated PostgreSQL CREATE TABLE statements.",size:"lg",showSubmit:false,showCancel:true,cancelLabel:"Close",children:jsx(Er,{label:"SQL",multiline:true,rows:16,value:V,readOnly:true,size:"sm"})})]})});var Cx=()=>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:[jsx("path",{d:"M10 1l2 2-5 5M8.5 4.5L11 7"}),jsx("circle",{cx:"4.5",cy:"11.5",r:"3"})]}),Nx=()=>jsx("span",{className:"text-xs font-bold text-gray-500 w-3.5 text-center",children:"?"}),Sx=()=>jsxs("svg",{className:"w-3.5 h-3.5",viewBox:"0 0 16 16",fill:"currentColor",children:[jsx("circle",{cx:"8",cy:"8",r:"6",className:"fill-blue-500"}),jsx("path",{d:"M5 8h6M8 5l3 3-3 3",stroke:"white",strokeWidth:"1.5",fill:"none",strokeLinecap:"round",strokeLinejoin:"round"})]}),Rx=()=>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:jsx("path",{d:"M3 2v12M7 4h6M7 8h4M7 12h5"})}),Tx=()=>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:jsx("path",{d:"M4 2v8a4 4 0 008 0V2"})}),Vc=memo(function({className:t}){return jsxs("div",{className:c("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:[jsxs("div",{className:"flex items-center gap-1.5",children:[jsx(Cx,{}),jsx("span",{className:"text-xs text-gray-600 dark:text-gray-300",children:"Primary Key"})]}),jsxs("div",{className:"flex items-center gap-1.5",children:[jsx(Nx,{}),jsx("span",{className:"text-xs text-gray-600 dark:text-gray-300",children:"Nullable"})]}),jsxs("div",{className:"flex items-center gap-1.5",children:[jsx(Sx,{}),jsx("span",{className:"text-xs text-gray-600 dark:text-gray-300",children:"Foreign Key"})]}),jsxs("div",{className:"flex items-center gap-1.5",children:[jsx(Rx,{}),jsx("span",{className:"text-xs text-gray-600 dark:text-gray-300",children:"Index"})]}),jsxs("div",{className:"flex items-center gap-1.5",children:[jsx(Tx,{}),jsx("span",{className:"text-xs text-gray-600 dark:text-gray-300",children:"Unique"})]})]})});var Ua=180,Ya=120,ln=10,Oc=memo(function({tables:t,viewport:r,containerWidth:o,containerHeight:n,editable:a,onViewportChange:s,className:l}){let i=useRef(null),d=useMemo(()=>{if(t.length===0)return null;let R=1/0,g=1/0,P=-1/0,T=-1/0;for(let I of t){let F=I.width??260,O=io(I,a);R=Math.min(R,I.x),g=Math.min(g,I.y),P=Math.max(P,I.x+F),T=Math.max(T,I.y+O);}let D=-r.x/r.zoom,W=-r.y/r.zoom,V=D+o/r.zoom,_=W+n/r.zoom;R=Math.min(R,D),g=Math.min(g,W),P=Math.max(P,V),T=Math.max(T,_);let M=P-R+ln*2,w=T-g+ln*2,N=Math.min((Ua-4)/M,(Ya-4)/w),x=(Ua-M*N)/2,S=(Ya-w*N)/2;return {minX:R,minY:g,scale:N,offsetX:x,offsetY:S,vpMinX:D,vpMinY:W}},[t,r,o,n,a]),u=useCallback(R=>{if(!d)return;let g=i.current?.getBoundingClientRect();if(!g)return;let P=R.clientX-g.left,T=R.clientY-g.top,D=(P-d.offsetX)/d.scale+d.minX-ln,W=(T-d.offsetY)/d.scale+d.minY-ln;s({...r,x:-(D-o/(2*r.zoom))*r.zoom,y:-(W-n/(2*r.zoom))*r.zoom});},[d,r,o,n,s]);if(!d)return null;let{minX:p,minY:b,scale:m,offsetX:f,offsetY:h,vpMinX:y,vpMinY:C}=d,v=(R,g)=>({x:(R-p+ln)*m+f,y:(g-b+ln)*m+h}),E=v(y,C),k={w:o/r.zoom*m,h:n/r.zoom*m};return jsx("div",{ref:i,className:c("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:Ua,height:Ya},onClick:u,onMouseDown:R=>R.stopPropagation(),"data-testid":"schema-minimap",children:jsxs("svg",{width:Ua,height:Ya,children:[t.map(R=>{let g=R.width??260,P=io(R,a),T=v(R.x,R.y);return jsx("rect",{x:T.x,y:T.y,width:g*m,height:P*m,fill:R.color??"#e5e7eb",stroke:"#9ca3af",strokeWidth:.5,rx:1},R.id)}),jsx("rect",{x:E.x,y:E.y,width:k.w,height:k.h,fill:"rgba(59, 130, 246, 0.1)",stroke:"#3b82f6",strokeWidth:1,rx:1})]})})});function Jr(e){return `"${e.replace(/"/g,'""')}"`}function $c(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 Lx(e){let t=[Jr(e.name)];return e.type==="serial"||e.type,t.push($c(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 Ax(e,t,r){let o=[],n=[];for(let i of e.fields)o.push(Lx(i));for(let i of e.fields)if(i.foreignKey){let d=r.find(p=>p.id===i.foreignKey.tableId),u=d?.fields.find(p=>p.id===i.foreignKey.fieldId);d&&u&&n.push(` CONSTRAINT ${Jr(`fk_${e.name}_${i.name}`)} FOREIGN KEY (${Jr(i.name)}) REFERENCES ${Jr(d.name)} (${Jr(u.name)})`);}let a=[];for(let i of e.fields)i.indexed&&!i.primaryKey&&!i.unique&&a.push(`CREATE INDEX ${Jr(`idx_${e.name}_${i.name}`)} ON ${Jr(e.name)} (${Jr(i.name)});`);let s=[...o,...n],l=`CREATE TABLE ${Jr(e.name)} (
23
+ `,role:"tooltip",children:[(d||s)&&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:[jsx("div",{className:"flex items-center gap-2",children:d&&jsx("h3",{className:"text-sm font-semibold",children:d})}),s&&jsx("div",{className:"flex items-center gap-1",children:v?jsxs(Fragment,{children:[jsx("button",{type:"button",onClick:T,disabled:h,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:h?Gy:$y}),jsx("button",{type:"button",onClick:M,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:_y}),i&&jsx("button",{type:"button",onClick:P,disabled:h,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:Xy})]}):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:Oy})})]}),f&&jsx("div",{className:`px-4 py-2 text-xs ${f.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:f.text}),jsx("div",{className:"flex-1 overflow-y-auto p-4",children:v?t?u?jsx(u,{value:y,onChange:z,placeholder:"\xC9crivez en Markdown..."}):jsx("p",{role:"alert",className:"p-3 text-sm text-gray-500 dark:text-gray-400",children:b??m.markdownEditorUnavailable}):jsx("div",{className:"space-y-2",children:jsx("textarea",{ref:I,"aria-label":"Contenu d'aide",value:y,onChange:D=>z(D.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 x=="string"?jsx("div",{className:"prose prose-sm dark:prose-invert max-w-none",children:t?jsx(By,{remarkPlugins:qy,components:jy,children:x}):jsx("div",{dangerouslySetInnerHTML:{__html:Vy.sanitize(x)}})}):x})]})]}):null}function Zy({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:b,markdownEditorUnavailableLabel:m}){return jsxs("div",{className:"inline-flex items-center gap-2.5",children:[e,jsx(du,{content:t,markdown:r,position:n,size:o,visible:a,editable:s,onSave:l,onReset:i,width:c,title:d,className:u,markdownEditor:b,markdownEditorUnavailableLabel:m})]})}var rx={"16/9":"aspect-[16/9]","4/3":"aspect-[4/3]","1/1":"aspect-square",auto:""},nx=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 ox({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[b,m]=useState(false),[p,C]=useState(null),v=useRef(null),k=useId(),y=useMemo(()=>(o/(1024*1024)).toFixed(0),[o]),z=`Formats accept\xE9s : ${a==="image/*"?"JPG, PNG, GIF, WebP":a} (max ${y}MB)`,h=useCallback(async E=>{let I=E.target.files?.[0];if(I){if(!I.type.startsWith("image/")){C("Le fichier doit \xEAtre une image");return}if(I.size>o){C(`Le fichier est trop volumineux (max ${y}MB)`);return}m(true),C(null);try{if(r){let w=await r(I);t(w);}else {let w=await nx(I);t(w);}v.current&&(v.current.value="");}catch(w){console.error("Upload error:",w),C(w instanceof Error?w.message:"Erreur lors de l'upload");}finally{m(false);}}},[o,y,t,r]),R=useCallback(()=>{t(""),v.current&&(v.current.value=""),C(null);},[t]),f=useCallback(E=>{t(E),C(null);},[t]),N=useCallback(()=>{v.current?.click();},[]),L=useCallback(E=>{f(E.target.value);},[f]);return jsxs("div",{className:`space-y-2 ${i}`,children:[n&&jsx("label",{className:"block text-sm font-semibold text-gray-700 dark:text-gray-300",children:n}),e&&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:[jsx("div",{className:`relative ${rx[u]} ${u==="auto"?"max-h-64":""} flex items-center justify-center`,children:jsx("img",{src:e,alt:"Aper\xE7u",className:"w-full h-full object-contain"})}),jsx("button",{type:"button",onClick:R,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"})]}),jsxs("div",{className:"flex gap-2",children:[jsx("input",{ref:v,type:"file","aria-label":"Choisir une image",accept:a,onChange:h,className:"hidden",disabled:l||b}),jsx("button",{type:"button",onClick:N,disabled:l||b,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:b?"\u23F3 Upload...":e?"\u{1F4C1} Changer l'image":"\u{1F4C1} Choisir une image"})]}),c&&jsxs("div",{className:"space-y-1",children:[jsx("label",{htmlFor:k,className:"block text-xs text-gray-500 dark:text-gray-400",children:"Ou URL directe :"}),jsx("input",{id:k,type:"url",value:e||"",onChange:L,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&&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]}),jsx("div",{className:"text-xs text-gray-500 dark:text-gray-400",children:s||z})]})}var Ls={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"},cl={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"},ax={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"},dl={"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"},ul={"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 sx(e,t){return e>t?`${t}+`:`${e}`}function ix({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 jsx("span",{"data-testid":"indicator",className:g("absolute z-10 rounded-full",Ls[e],cl[t],s?ul[r]:dl[r],n&&g("ring-2 ring-white dark:ring-gray-900",o),a&&"animate-pulse",l),...i})}function lx({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 jsx("span",{"data-testid":"indicator",className:g("absolute z-10 inline-flex items-center justify-center rounded-full font-semibold text-white",Ls[e],ax[t],i?ul[r]:dl[r],a&&g("ring-2 ring-white dark:ring-gray-900",s),l&&"animate-pulse",c),...d,children:sx(n,o)})}function cx({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 jsx("span",{"data-testid":"indicator",className:g("absolute z-10 rounded-full",Ls[e],cl[t],s?ul[r]:dl[r],n&&g("ring-2 ring-white dark:ring-gray-900",o),a&&"animate-pulse",l),...i})}function dx({color:e="primary",size:t="sm",label:r,className:n,...o}){return jsxs("span",{"data-testid":"indicator",className:g("inline-flex items-center gap-2",n),...o,children:[jsx("span",{className:g("rounded-full shrink-0",Ls[e],cl[t])}),r?jsx("span",{className:"text-sm text-gray-700 dark:text-gray-300",children:r}):null]})}function mu({variant:e="dot",children:t,...r}){if(e==="legend")return jsx(dx,{...r});let n=(()=>{switch(e){case "count":return jsx(lx,{...r});case "status":return jsx(cx,{...r});default:return jsx(ix,{...r})}})();return t?jsxs("div",{className:"relative inline-flex",children:[t,n]}):n}mu.displayName="Indicator";var ux={xs:"text-xs",sm:"text-sm",md:"text-sm",lg:"text-base",xl:"text-lg"},pu={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"},mx={normal:"font-normal",medium:"font-medium",semibold:"font-semibold",bold:"font-bold"},gx={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 bu({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:b,disabled:m=false,truncate:p=false,as:C="label",className:v,...k}){let y=C,z=g("inline-flex items-center gap-1.5 transition-colors",ux[t],mx[o]),h=a||gx[r][n];return jsxs(y,{className:g(z,h,m?"opacity-50 cursor-not-allowed":"cursor-default",v),title:d,"aria-disabled":m,...k,children:[u&&jsx("span",{className:g("shrink-0",pu[t]),children:u}),jsxs("span",{className:g(p&&"truncate"),children:[e,s&&jsx("span",{className:"text-red-500 ml-0.5","aria-hidden":"true",children:l}),s&&jsx("span",{className:"sr-only",children:"(required)"})]}),i&&!s&&jsx("span",{className:"text-gray-400 dark:text-gray-500 font-normal",children:c}),b&&jsx("span",{className:g("shrink-0",pu[t]),children:b})]})}bu.displayName="Label";var bx=2,hx=2,yx=12,xx=16,hu="cell:",yu=false,vx=memo(function({cells:t,radius:r}){return jsx("g",{children:t.map(n=>jsxs("g",{children:[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?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 kx({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:b,plotLabel:m,formatValue:p,formatX:C,formatY:v,onCellClick:k}){let[y,z]=useState(null),h=useMemo(()=>{let I=r.map((A,V)=>C(A,V)),w=n.map((A,V)=>v(A,V)),W={top:8,right:8,bottom:s.hidden?8:s.height??24+(s.label?16:0),left:l.hidden?8:l.height??kr(w)+yx+(l.label?16:0)},M=Math.max(0,e-W.left-W.right),T=Math.max(0,t-W.top-W.bottom),P=hn(r.map((A,V)=>V),[0,M],{paddingInner:0,paddingOuter:0}),x=hn(n.map((A,V)=>V),[0,T],{paddingInner:0,paddingOuter:0}),D=Math.max(0,P.bandwidth-c),S=Math.max(0,x.bandwidth-c),B=[];n.forEach((A,V)=>{r.forEach((Y,X)=>{let j=o.get(`${St(Y)}|${St(A)}`)?.value??null,O=null;if(u&&j!==null&&S>=xx){let K=p(j);vr(K,10)+6<=D&&(O=K);}B.push({key:`${X}-${V}`,column:X,row:V,x:P(X)+c/2,y:x(V)+c/2,width:D,height:S,color:j===null?"transparent":a(j),label:O,onDark:j!==null&&a.onDark(j),missing:j===null});});});let H=sa(I.length,M,kr(I)),$=sa(w.length,T,15),_=s.hidden?[]:I.map((A,V)=>({value:r[V],offset:P.center(V),label:A})).filter((A,V)=>V%H===0),F=l.hidden?[]:w.map((A,V)=>({value:n[V],offset:x.center(V),label:A})).filter((A,V)=>V%$===0);return {margin:W,innerWidth:M,innerHeight:T,columnScale:P,rowScale:x,cells:B,columnTicks:_,rowTicks:F}},[r,n,o,a,s,l,e,t,c,u,p,C,v]),R=useCallback((I,w)=>{let W=r[I],M=n[w],T=o.get(`${St(W)}|${St(M)}`),P=T?.value??null;return {x:W,y:M,xLabel:C(W,I),yLabel:v(M,w),value:P,formattedValue:P===null?"\u2014":p(P),color:P===null?"transparent":a(P),datum:T?.datum}},[r,n,o,a,p,C,v]),f=useCallback(I=>{if(b===false||r.length===0||n.length===0)return;let w=I.currentTarget.getBoundingClientRect(),W=I.clientX-w.left-h.margin.left,M=I.clientY-w.top-h.margin.top,T=Math.floor(W/(h.columnScale.step||1)),P=Math.floor(M/(h.rowScale.step||1));if(T<0||T>=r.length||P<0||P>=n.length){z(null);return}z(x=>x?.column===T&&x.row===P?x:{column:T,row:P});},[b,r.length,n.length,h.margin,h.columnScale,h.rowScale]),N=useCallback(I=>{if(r.length===0||n.length===0)return;let w=y??{column:0,row:0},W;switch(I.key){case "ArrowRight":W={...w,column:Math.min(r.length-1,w.column+1)};break;case "ArrowLeft":W={...w,column:Math.max(0,w.column-1)};break;case "ArrowDown":W={...w,row:Math.min(n.length-1,w.row+1)};break;case "ArrowUp":W={...w,row:Math.max(0,w.row-1)};break;case "Home":W={...w,column:0};break;case "End":W={...w,column:r.length-1};break;case "Escape":W=null;break;default:W=void 0;}W!==void 0&&(I.preventDefault(),z(W));},[r.length,n.length,y]),L=useCallback(()=>{!k||!y||k(R(y.column,y.row));},[k,y,R]),E=y?R(y.column,y.row):null;return jsxs(Fragment,{children:[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:f,onPointerLeave:()=>z(null),onKeyDown:N,onBlur:()=>z(null),onClick:L,children:[jsxs("g",{transform:`translate(${h.margin.left}, ${h.margin.top})`,children:[jsx(vx,{cells:h.cells,radius:d}),y?jsx("rect",{x:h.columnScale(y.column)+c/2,y:h.rowScale(y.row)+c/2,width:Math.max(0,h.columnScale.bandwidth-c),height:Math.max(0,h.rowScale.bandwidth-c),rx:d,fill:"none",strokeWidth:2,className:"stroke-gray-900 dark:stroke-white","aria-hidden":"true"}):null]}),jsx("g",{transform:`translate(${h.margin.left}, ${h.margin.top+h.innerHeight})`,children:s.hidden?null:jsx(_e,{orientation:"bottom",ticks:h.columnTicks,length:h.innerWidth,showLine:false,tickSize:0,label:s.label,size:i})}),jsx("g",{transform:`translate(${h.margin.left}, ${h.margin.top})`,children:l.hidden?null:jsx(_e,{orientation:"left",ticks:h.rowTicks,length:h.innerHeight,showLine:false,tickSize:0,label:l.label,size:i})})]}),y&&E&&b!==false?jsx(gt,{x:h.margin.left+h.columnScale.center(y.column),y:h.margin.top+h.rowScale.center(y.row),containerWidth:e,children:typeof b=="function"?b(E):jsxs("div",{className:"flex flex-col gap-1",children:[jsxs("div",{className:"font-medium text-gray-900 dark:text-gray-100",children:[E.yLabel," \xB7 ",E.xLabel]}),jsxs("div",{className:"flex items-center gap-2",children:[jsx("span",{className:"h-2.5 w-2.5 shrink-0 rounded-sm",style:{backgroundColor:E.color},"aria-hidden":"true"}),jsx("span",{className:"font-semibold text-gray-900 [font-variant-numeric:tabular-nums] dark:text-gray-100",children:E.formattedValue})]})]})}):null]})}function xu(e,t,r){if(r)return r;let n=new Map;return e.forEach((o,a)=>{let s=mt(o,t,a),l=St(s);n.has(l)||n.set(l,s);}),[...n.values()]}function Cx({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:b=bx,cellRadius:m=hx,showValues:p=false,height:C=280,width:v,size:k="md",legend:y=true,legendLabel:z,tooltip:h=true,tableView:R=false,title:f,description:N,loading:L=false,emptyState:E,locale:I,plotLabel:w,onCellClick:W,className:M,...T}){i!==void 0&&i>es&&!yu&&(yu=true,console.warn(`[@synertech/ui] A Heatmap was cut into ${i} colour classes. Past ${es} two neighbouring cells stop being tellable apart: leave \`steps\` unset and let the ramp stay continuous.`));let P=useMemo(()=>xu(e,t.key,d),[e,t.key,d]),x=useMemo(()=>xu(e,r.key,u),[e,r.key,u]),D=useMemo(()=>{let Y=new Map;return e.forEach((X,G)=>{let j=Ee(X,n);if(j===null)return;let O=mt(X,t.key,G),K=mt(X,r.key,G);Y.set(`${St(O)}|${St(K)}`,{value:j,datum:X});}),Y},[e,t.key,r.key,n]),S=useMemo(()=>o??(Y=>rt(Y,I)),[o,I]),B=useMemo(()=>t.format??(Y=>Ke(Y,I)),[t.format,I]),H=useMemo(()=>r.format??(Y=>Ke(Y,I)),[r.format,I]),$=useMemo(()=>{let Y=a??Kt([...D.values()].map(X=>X.value))??[0,1];return s==="diverging"?Co(Y,{center:l,steps:i,colors:c}):ca(Y,{steps:i,colors:c})},[a,D,s,l,i,c]),_=useMemo(()=>x.map(Y=>{let X={[r.key]:Y};return P.forEach(G=>{X[`${hu}${St(G)}`]=D.get(`${St(G)}|${St(Y)}`)?.value??null;}),X}),[x,P,D,r.key]),F=useMemo(()=>P.map((Y,X)=>({key:`${hu}${St(Y)}`,label:B(Y,X)})),[P,B]),A=y!==false,V=typeof y=="string"?y:"bottom";return jsx(ut,{title:f,description:N,height:C,width:v,size:k,loading:L,empty:D.size===0,emptyState:E,tableView:R,legendPosition:V,legend:A?jsx(fa,{scale:$,label:z,format:S,size:k,locale:I}):void 0,table:R?jsx(It,{data:_,series:F,xKey:r.key,xLabel:r.label??r.key,formatX:H,formatValue:S,caption:typeof f=="string"?f:void 0}):void 0,className:M,...T,children:({width:Y})=>jsx(kx,{width:Y,height:C,columns:P,rows:x,lookup:D,colorScale:$,x:t,y:r,size:k,cellGap:b,cellRadius:m,showValues:p,tooltip:h,plotLabel:w,formatValue:S,formatX:B,formatY:H,onCellClick:W})})}var Sx=24,Rx=10,Tx=10,Px=memo(function({lines:t,showMarkers:r}){return jsx("g",{children:t.map(n=>jsxs("g",{children:[n.solid?jsx("path",{d:n.solid,fill:"none",stroke:n.color,strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"}):null,n.dashed?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=>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 Ex({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:b,referenceLines:m,margin:p,tooltip:C,onPointClick:v,plotLabel:k,formatValue:y,formatX:z}){let[h,R]=useState(null),f=useMemo(()=>{let T=n.filter($=>!$.hidden),P=Qt({width:e,height:t,data:r,x:o,y:a,bounds:Kt(ur(r,T.map($=>$.key))),margin:p,placement:"point",formatValue:y,formatX:z,extraTop:d?Rx:0}),x=P.categoryCenters,D=P.valueScale,S=c===void 0?-1:P.xValues.findIndex($=>St($)===St(c)),B=T.map($=>{let _=r.map((V,Y)=>{let X=Ee(V,$.key);return {x:x[Y],y:X===null?Number.NaN:D(X),defined:X!==null}}),F={connectNulls:b},A=S>=0;return {key:$.key,color:$.color,solid:$.dashed?"":$r(A?_.slice(0,S+1):_,i,F),dashed:$.dashed?$r(_,i,F):A?$r(_.slice(S),i,F):"",markers:_.filter(V=>V.defined!==false)}}),H=r.length>1?P.innerWidth/(r.length-1):0;return {visible:T,xValues:P.xValues,xPositions:x,xTicks:P.categoryTicks,yTicks:P.valueTicks,yScale:D,innerWidth:P.innerWidth,innerHeight:P.innerHeight,margin:P.margin,lines:B,forecastIndex:S,showMarkers:u==="always"||u==="auto"&&H>=Sx&&r.length>1}},[r,n,o,a,e,t,p,i,b,c,d,u,y,z]),N=useCallback(T=>f.visible.map(P=>{let x=Ee(r[T],P.key);return {seriesKey:P.key,seriesLabel:Xt(P),color:P.color,value:x,formattedValue:x===null?"\u2014":y(x),datum:r[T]}}),[r,f.visible,y]),L=useCallback(T=>{if(C===false||r.length===0)return;let P=T.currentTarget.getBoundingClientRect(),x=T.clientX-P.left-f.margin.left,D=Wt(f.xPositions,x);R(D>=0?D:null);},[C,r.length,f.margin.left,f.xPositions]),E=useCallback(T=>{if(r.length===0)return;let P=r.length-1,x=h??0,D=T.key==="ArrowRight"?Math.min(P,x+1):T.key==="ArrowLeft"?Math.max(0,x-1):T.key==="Home"?0:T.key==="End"?P:T.key==="Escape"?null:void 0;D!==void 0&&(T.preventDefault(),R(D));},[r.length,h]),I=useCallback(()=>{if(!v||h===null)return;let[T]=N(h);T&&v({...T,index:h,x:f.xValues[h]});},[v,h,N,f.xValues]),w=h===null?null:N(h),W=(w??[]).filter(T=>T.value!==null),M=h===null||w===null?null:{x:f.xValues[h],xLabel:z(f.xValues[h],h),index:h,points:w};return jsxs(Fragment,{children:[jsxs("svg",{width:e,height:t,role:"img","aria-label":k??f.visible.map(T=>Xt(T)).join(", "),tabIndex:0,className:"touch-none focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-blue-500",onPointerMove:L,onPointerLeave:()=>R(null),onKeyDown:E,onBlur:()=>R(null),onClick:I,children:[jsxs("g",{transform:`translate(${f.margin.left}, ${f.margin.top})`,children:[jsx(Ot,{width:f.innerWidth,height:f.innerHeight,horizontal:s==="y"||s==="both"?f.yTicks.map(T=>T.offset):void 0,vertical:s==="x"||s==="both"?f.xTicks.map(T=>T.offset):void 0}),m?.map(T=>{let P=f.yScale(T.value),x=P<Tx?P+12:P-4;return jsxs("g",{children:[jsx("line",{x1:0,y1:P,x2:f.innerWidth,y2:P,stroke:T.color??"var(--color-chart-muted)",strokeWidth:1,strokeDasharray:T.dashed===false?void 0:"4 4"}),T.label?jsx("text",{x:f.innerWidth,y:x,textAnchor:"end",className:"fill-gray-500 text-[10px] dark:fill-gray-400",children:T.label}):null]},`${T.value}-${T.label??""}`)}),f.forecastIndex>=0?jsxs("g",{children:[jsx("line",{x1:f.xPositions[f.forecastIndex],y1:0,x2:f.xPositions[f.forecastIndex],y2:f.innerHeight,className:"stroke-gray-300 dark:stroke-gray-600",strokeWidth:1,strokeDasharray:"3 3"}),d?jsx("text",{x:f.xPositions[f.forecastIndex]+4,y:-2,className:"fill-gray-500 text-[10px] dark:fill-gray-400",children:d}):null]}):null,jsx(Px,{lines:f.lines,showMarkers:f.showMarkers}),h!==null?jsxs("g",{"aria-hidden":"true",children:[jsx("line",{x1:f.xPositions[h],y1:0,x2:f.xPositions[h],y2:f.innerHeight,className:"stroke-gray-400 dark:stroke-gray-500",strokeWidth:1}),W.map(T=>jsx("circle",{cx:f.xPositions[h],cy:f.yScale(T.value),r:4,fill:T.color,strokeWidth:2,className:"stroke-white dark:stroke-gray-800"},T.seriesKey))]}):null]}),jsx("g",{transform:`translate(${f.margin.left}, ${f.margin.top+f.innerHeight})`,children:o.hidden?null:jsx(_e,{orientation:"bottom",ticks:f.xTicks,length:f.innerWidth,label:o.label,size:l})}),jsx("g",{transform:`translate(${f.margin.left}, ${f.margin.top})`,children:a?.hidden?null:jsx(_e,{orientation:"left",ticks:f.yTicks,length:f.innerHeight,showLine:false,label:a?.label,size:l})})]}),M&&C!==false?jsx(gt,{x:f.margin.left+f.xPositions[M.index],y:f.margin.top+(W.length>0?Math.min(...W.map(T=>f.yScale(T.value))):f.innerHeight/2),containerWidth:e,children:typeof C=="function"?C(M):jsx(Cr,{title:M.xLabel,points:M.points})}):null]})}function Dx({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:b,description:m,loading:p=false,emptyState:C,onPointClick:v,curve:k="monotone",forecastFrom:y,forecastLabel:z,markers:h="auto",connectNulls:R=false,referenceLines:f,legendToggle:N=true,margin:L,locale:E,plotLabel:I,className:w,...W}){let[M,T]=useState(()=>new Set),P=useMemo(()=>t.map((_,F)=>({..._,hidden:_.hidden||M.has(_.key),color:Er(_,F,u)})),[t,M,u]),x=useMemo(()=>n?.format??(_=>rt(_,E)),[n?.format,E]),D=useMemo(()=>r.format??(_=>r.scale==="time"?Ke(_ instanceof Date?_:new Date(Jr(_)),E):Ke(_,E)),[r.format,r.scale,E]),S=useCallback(_=>{T(F=>{let A=new Set(F);return A.has(_)?A.delete(_):A.add(_),A});},[]),B=i===void 0?t.length>=2:i!==false,H=typeof i=="string"?i:"bottom",$=P.filter(_=>!_.hidden).length;return jsx(ut,{title:b,description:m,height:o,width:a,size:s,loading:p,empty:e.length===0||$===0,emptyState:C,tableView:d,legendPosition:H,legend:B?jsx($t,{items:Or(P,u),position:H,marker:"line",size:s,onToggle:N?S:void 0}):void 0,table:d?jsx(It,{data:e,series:P,xKey:r.key,xLabel:r.label??r.key,formatX:D,formatValue:x,caption:typeof b=="string"?b:void 0}):void 0,className:w,...W,children:({width:_})=>jsx(Ex,{width:_,height:o,data:e,resolvedSeries:P,x:r,y:n,grid:l,size:s,curve:k,forecastFrom:y,forecastLabel:z,markers:h,connectNulls:R,referenceLines:f,margin:L,tooltip:c,onPointClick:v,plotLabel:I,formatValue:x,formatX:D})})}var zx={sm:"max-w-sm",md:"max-w-2xl",lg:"max-w-4xl",xl:"max-w-6xl",full:"max-w-full"},Tn=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:b,onCancelClick:m,buttonsPosition:p="right",showHeaderDivider:C=true,showFooterDivider:v=true,description:k,icon:y,size:z="md",reverseButtons:h=false,headerClassName:R,contentClassName:f,footerClassName:N,titleClassName:L,descriptionClassName:E,submitClassName:I,cancelClassName:w,closeLabel:W,enterFullScreenLabel:M,exitFullScreenLabel:T,"aria-label":P,closeOnEscape:x=true,trapFocus:D=true,initialFocus:S,returnFocus:B,lockScroll:H=true},$)=>{let[_,F]=useState(false),A=Ge(),V=useId(),Y=`${V}-title`,X=`${V}-description`,{dialogRef:G,dialogProps:j}=ao({open:e,onClose:t,closeOnEscape:x,trapFocus:D,initialFocus:S,returnFocus:B,lockScroll:H});if(!e)return null;let O=o??c??A.confirm,K=b??A.cancel,se=W??A.closeModal,ae=_?T??A.exitFullScreen:M??A.enterFullScreen,U=a??d,J=async()=>{U&&await U(),t();},te=async()=>{m&&await m(),t();};return 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:jsx("div",{className:g("relative p-4 w-full max-h-full transition-all duration-300",_?"max-w-full h-full p-0":zx[z]),ref:$,children:jsxs("div",{...j,ref:G,"aria-labelledby":r?Y:void 0,"aria-label":r?void 0:P,"aria-describedby":k?X:void 0,className:g("relative bg-white shadow dark:bg-gray-700 border-b-4 transition-all duration-300 focus:outline-none",_?"rounded-none h-full flex flex-col":"rounded-lg"),children:[jsxs("div",{className:g("flex items-center justify-between p-4 md:p-5 rounded-t",C&&"border-b border-gray-200 dark:border-gray-600",R),children:[jsxs("div",{className:"flex items-center gap-3",children:[y&&jsx("div",{className:"shrink-0 text-gray-500 dark:text-gray-400",children:y}),jsxs("div",{children:[jsx("h3",{id:Y,className:g("text-xl font-semibold text-gray-900 dark:text-white",L),children:r}),k&&jsx("p",{id:X,className:g("mt-1 text-sm text-gray-500 dark:text-gray-400",E),children:k})]})]}),jsxs("div",{className:"flex items-center gap-1 ms-auto",children:[l&&jsx("button",{type:"button",onClick:()=>F(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":ae,children:_?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:jsx("path",{stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",d:"M7 1H1v6m16 0V1h-6m0 16h6v-6M1 11v6h6"})}):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:jsx("path",{stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",d:"M11 1h6v6M1 11v6h6m0-12L1 1m16 16-6-6"})})}),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:[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:jsx("path",{stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",d:"m1 1 6 6m0 0 6 6M7 7l6-6M7 7l-6 6"})}),jsx("span",{className:"sr-only",children:se})]})]})]}),jsx("div",{className:g("p-4 md:p-5 space-y-4",_&&"flex-1 overflow-y-auto",f),children:n}),(i||u)&&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",h&&"flex-row-reverse",N),children:[u&&jsx("button",{type:"button",onClick:te,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",w),children:K}),i&&jsx("button",{type:"button",onClick:J,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",I),children:O})]})]})})})});Tn.displayName="Modal";function Vx(e,t,r,n){let o=r*2+1+n*2+2;if(t<=o)return Array.from({length:t},(b,m)=>m+1);let a=Array.from({length:n},(b,m)=>m+1).filter(b=>b<=t),s=Array.from({length:n},(b,m)=>t-n+1+m).filter(b=>b>=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 b of a)u.push(b);if(c)u.push("ellipsis");else for(let b=n+1;b<l;b++)u.push(b);for(let b=l;b<=i;b++)u.push(b);if(d)u.push("ellipsis");else for(let b=i+1;b<=t-n;b++)u.push(b);for(let b of s)u.includes(b)||u.push(b);return u}function Bx({className:e}){return jsx("svg",{className:e,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24","aria-hidden":"true",children:jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M15 19l-7-7 7-7"})})}function Fx({className:e}){return jsx("svg",{className:e,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24","aria-hidden":"true",children:jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 5l7 7-7 7"})})}function Ox({className:e}){return jsx("svg",{className:e,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24","aria-hidden":"true",children:jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M11 19l-7-7 7-7M18 19l-7-7 7-7"})})}function $x({className:e}){return jsx("svg",{className:e,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24","aria-hidden":"true",children:jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M13 5l7 7-7 7M6 5l7 7-7 7"})})}var _x={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"}},Xx={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 Gx({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:b,onPageSizeChange:m,className:p,...C}){let v=_x[n],k=Xx[o],y=useMemo(()=>Vx(e,t,s,l),[e,t,s,l]),z=useCallback(I=>{i||I<1||I>t||I===e||r(I);},[i,t,e,r]),h=e<=1,R=e>=t,f=g("inline-flex items-center justify-center select-none",v.button,k.base),N=(I,w,W,M)=>jsx("button",{type:"button",onClick:I,disabled:i||w,"aria-label":W,"aria-disabled":i||w,className:g(f,i||w?k.disabled:k.idle),children:M}),L=d!==void 0&&u?(e-1)*u+1:void 0,E=d!==void 0&&u?Math.min(e*u,d):void 0;return jsxs("nav",{"aria-label":"Pagination",className:g("flex items-center",v.gap,p),...C,children:[d!==void 0&&u&&jsxs("span",{className:g("mr-2 text-gray-600 dark:text-gray-400 whitespace-nowrap",v.text),children:[L,"\u2013",E," of ",d]}),b&&b.length>0&&m&&jsxs("div",{className:g("mr-2 flex items-center whitespace-nowrap",v.gap,v.text),children:[jsx("label",{htmlFor:"pagination-page-size",className:"text-gray-600 dark:text-gray-400",children:"Rows:"}),jsx("select",{id:"pagination-page-size",value:u,onChange:I=>m(Number(I.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:b.map(I=>jsx("option",{value:I,children:I},I))})]}),jsxs("div",{className:g("flex items-center",v.gap),children:[a&&N(()=>z(1),h,c?.first??"Go to first page",jsx(Ox,{className:v.icon})),N(()=>z(e-1),h,c?.previous??"Go to previous page",jsx(Bx,{className:v.icon})),y.map((I,w)=>I==="ellipsis"?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-${w}`):jsx("button",{type:"button",onClick:()=>z(I),disabled:i,"aria-current":I===e?"page":void 0,"aria-label":`Page ${I}`,className:g(f,I===e?k.active:i?k.disabled:k.idle),children:I},I)),N(()=>z(e+1),R,c?.next??"Go to next page",jsx(Fx,{className:v.icon})),a&&N(()=>z(t),R,c?.last??"Go to last page",jsx($x,{className:v.icon}))]})]})}var Ux=.62,Yx=2,qx=3,jx=.16,Zx=64,Qx=22,ml=6,ku=false;function Jx({width:e,height:t,slices:r,variant:n,innerRadius:o,showLabels:a,centerLabel:s,tooltip:l,plotLabel:i,formatValue:c,onSliceClick:d}){let[u,b]=useState(null),m=useMemo(()=>{let f=a?Zx:8,N=a?Qx:8,L=Math.max(0,Math.min((e-f*2)/2,(t-N*2)/2));return {cx:e/2,cy:t/2,outerRadius:L,inner:n==="donut"?L*(o??Ux):(o??0)*L,pad:L>0&&r.length>1?Yx/L/2:0}},[e,t,n,o,a,r.length]),{cx:p,cy:C,outerRadius:v,inner:k,pad:y}=m,z=useCallback(f=>{let N=(f.startAngle+f.endAngle)/2,L=Math.sin(N)>=0,E={x:p+Math.sin(N)*(v+4),y:C-Math.cos(N)*(v+4)},I={x:p+Math.sin(N)*(v+14),y:C-Math.cos(N)*(v+14)},w={x:L?I.x+10:I.x-10,y:I.y};return {from:E,elbow:I,end:w,anchor:L?"start":"end"}},[p,C,v]),h=useCallback(f=>{if(r.length===0)return;let N=r.length-1,L=u??0,E=f.key==="ArrowRight"||f.key==="ArrowDown"?Math.min(N,L+1):f.key==="ArrowLeft"||f.key==="ArrowUp"?Math.max(0,L-1):f.key==="Home"?0:f.key==="End"?N:f.key==="Escape"?null:void 0;E!==void 0&&(f.preventDefault(),b(E));},[r.length,u]),R=u===null?null:r[u];return jsxs(Fragment,{children:[jsxs("svg",{width:e,height:t,role:"img","aria-label":i??r.map(f=>f.label).join(", "),tabIndex:0,className:"touch-none focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-blue-500",onPointerLeave:()=>b(null),onBlur:()=>b(null),onKeyDown:h,children:[r.map((f,N)=>jsx("path",{d:Rc({cx:p,cy:C,innerRadius:k,outerRadius:v+(u===N?qx:0),startAngle:f.startAngle+y,endAngle:Math.max(f.startAngle+y,f.endAngle-y)}),fill:f.color,onPointerEnter:()=>l===false?void 0:b(N),onClick:()=>d?.({key:f.key,label:f.label,value:f.value,share:f.share})},f.key)),a?r.filter(f=>f.endAngle-f.startAngle>=jx).map(f=>{let{from:N,elbow:L,end:E,anchor:I}=z(f);return jsxs("g",{"aria-hidden":"true",children:[jsx("polyline",{points:`${N.x},${N.y} ${L.x},${L.y} ${E.x},${E.y}`,fill:"none",className:"stroke-gray-300 dark:stroke-gray-600",strokeWidth:1}),jsx("text",{x:I==="start"?E.x+3:E.x-3,y:E.y,textAnchor:I,dominantBaseline:"middle",className:"fill-gray-600 text-[10px] dark:fill-gray-300",children:f.label})]},`label-${f.key}`)}):null,n==="donut"&&s?jsxs("g",{"aria-hidden":"true",children:[jsx("text",{x:p,y:C-(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?jsx("text",{x:p,y:C+14,textAnchor:"middle",dominantBaseline:"middle",className:"fill-gray-500 text-[10px] dark:fill-gray-400",children:s.label}):null]}):null]}),R&&l!==false?jsx(gt,{x:p+Math.sin((R.startAngle+R.endAngle)/2)*(v*.7),y:C-Math.cos((R.startAngle+R.endAngle)/2)*(v*.7),containerWidth:e,children:typeof l=="function"?l({seriesKey:R.key,seriesLabel:R.label,color:R.color,value:R.value,formattedValue:c(R.value),datum:{},share:R.share}):jsx(Cr,{title:R.label,points:[{seriesKey:R.key,seriesLabel:Gt(R.share),color:R.color,value:R.value,formattedValue:c(R.value),datum:{}}]})}):null]})}function ev({data:e,x:t,value:r,variant:n="pie",innerRadius:o,maxSlices:a=ml,otherLabel:s,sort:l="desc",showLabels:i=true,centerLabel:c,height:d=260,width:u,size:b="md",legend:m,tooltip:p=true,tableView:C=false,title:v,description:k,loading:y=false,emptyState:z,locale:h,plotLabel:R,onSliceClick:f,className:N,...L}){let E=Ge(),I=useCallback(D=>rt(D,h),[h]),w=useCallback(D=>t.format?t.format(D,0):Ke(D,h),[t,h]),{slices:W,total:M,rows:T}=useMemo(()=>{let D=e.map((A,V)=>({key:String(mt(A,t.key,V)),label:w(mt(A,t.key,V)),value:Ee(A,r)??0,color:Pr(V),datum:A})),S=l==="none"?D:[...D].sort((A,V)=>l==="asc"?A.value-V.value:V.value-A.value),B=S.slice(0,a),H=S.slice(a);H.length>0&&B.push({key:"__other__",label:s??E.chartOther,value:H.reduce((A,V)=>A+V.value,0),color:Tr,datum:{}}),B.length>ml&&!ku&&(ku=true,console.warn(`[@synertech/ui] A PieChart is drawing ${B.length} slices. Past ${ml} the slices stop being tellable apart: lower \`maxSlices\`, or use a BarChart, which compares lengths rather than angles.`));let $=B.reduce((A,V)=>A+Math.max(0,V.value),0),_=0;return {slices:B.map(A=>{let V=$===0?0:Math.max(0,A.value)/$,Y=_;return _+=V*Math.PI*2,{...A,share:V,startAngle:Y,endAngle:_}}),total:$,rows:B.map(A=>({[t.key]:A.label,[r]:A.value}))}},[e,t.key,r,l,a,s,E.chartOther,w]),P=m===void 0?true:m!==false,x=typeof m=="string"?m:"bottom";return jsx(ut,{title:v,description:k,height:d,width:u,size:b,loading:y,empty:W.length===0||M===0,emptyState:z,tableView:C,legendPosition:x,legend:P?jsx($t,{items:W.map(D=>({key:D.key,label:`${D.label} \xB7 ${Gt(D.share)}`,color:D.color})),position:x,marker:"rect",size:b}):void 0,table:C?jsx(It,{data:T,series:[{key:r,label:t.label??r}],xKey:t.key,xLabel:t.label??t.key,formatValue:I,caption:typeof v=="string"?v:void 0}):void 0,className:N,...L,children:({width:D})=>jsx(Jx,{width:D,height:d,slices:W,variant:n,innerRadius:o,showLabels:i,centerLabel:c,tooltip:p,plotLabel:R,formatValue:I,onSliceClick:f})})}var rv={xs:"h-1",sm:"h-1.5",md:"h-2.5",lg:"h-4",xl:"h-6"},nv={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"},ov={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"},wu="bg-[repeating-linear-gradient(45deg,transparent,transparent_10px,rgba(255,255,255,0.2)_10px,rgba(255,255,255,0.2)_20px)]",av={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 Su({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)),b=o==="gradient"?av[n]:nv[n],m=s?s(u):`${Math.round(u)}%`;return jsxs("div",{className:g("w-full",c),...d,children:[(l||a)&&jsxs("div",{className:"flex items-center justify-between mb-1",children:[l&&jsx("span",{className:"text-sm font-medium text-gray-700 dark:text-gray-300",children:l}),a&&!t&&jsx("span",{className:g("text-sm font-semibold",ov[n],!l&&"ml-auto"),children:m})]}),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",rv[r]),children:t?jsx("div",{className:g("absolute h-full w-1/3 rounded-full",b,o==="striped"&&wu,"animate-[progress-indeterminate_1.5s_ease-in-out_infinite]")}):jsx("div",{className:g("h-full rounded-full",b,o==="striped"&&wu,i&&"transition-[width] duration-300 ease-out"),style:{width:`${u}%`}})})]})}Su.displayName="ProgressBar";var cv=e=>({sm:"w-4 h-4",md:"w-5 h-5",lg:"w-6 h-6"})[e],dv=e=>({sm:"w-2 h-2",md:"w-2.5 h-2.5",lg:"w-3 h-3"})[e],uv=(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")}},mv={},Ru=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:b=false,checkedColor:m,uncheckedColor:p,borderColor:C,labelColor:v,errorColor:k,dotColor:y,hoverColor:z,focusRingColor:h,showFocusRing:R=true,className:f,containerClassName:N,...L},E)=>{let[I,w]=useState(o),W=n!==void 0,M=W?n:I,T=useId(),P=typeof c=="string"?c:void 0,x=!!c,D=X=>{if(d||u)return;let G=X.target.checked;W||w(G),a?.(G);},S=useMemo(()=>uv(l,x,M,k,y,m,p,C),[l,x,M,k,y,m,p,C]),B=useMemo(()=>{let X={};return m&&M&&(X.backgroundColor=m,X.borderColor=m),p&&!M&&(X.backgroundColor=p),C&&(X.borderColor=C),X},[m,p,C,M]),H=useMemo(()=>y?{backgroundColor:y}:{},[y]),$=useMemo(()=>v?{color:v}:{},[v]),_=useMemo(()=>k?{color:k}:{},[k]),F=v?"":"text-gray-700 dark:text-gray-200",A=k?"":"text-red-500",V=z?"":"hover:border-blue-500 dark:hover:border-blue-400",Y=h?"":"focus-visible:ring-blue-500";return jsxs("div",{className:g("inline-flex flex-col",N),style:mv,children:[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:T,children:[jsxs("div",{className:"relative inline-flex items-center",children:[jsx("input",{ref:E,type:"radio",id:T,value:r,checked:M,onChange:D,disabled:d,readOnly:u,required:b,"aria-invalid":x,"aria-describedby":P?`${T}-error`:void 0,className:"sr-only peer",tabIndex:u?-1:void 0,...L}),jsx("div",{className:g("rounded-full transition-all duration-200",cv(s),S,!d&&!u&&V,!d&&!u&&R&&"peer-focus-visible:ring-2 ring-offset-2",!d&&!u&&R&&Y,f),style:B,children:M&&jsx("div",{className:g("rounded-full absolute inset-0 m-auto transition-all duration-200",dv(s),y?"":l==="outlined"||l==="default"?"bg-blue-600 dark:bg-blue-500":"bg-white"),style:H})})]}),e&&jsxs("span",{className:g("select-none",i==="left"?"mr-2":"ml-2",F,d&&"opacity-50"),style:$,children:[e,b&&jsx("span",{className:"text-red-500 ml-1",children:"*"})]})]}),t&&!x&&jsx("p",{className:g("text-sm text-gray-500 dark:text-gray-400 mt-1",i==="left"?"text-right":"ml-7"),children:t}),P&&jsx("p",{id:`${T}-error`,className:g("text-sm mt-1",i==="left"?"text-right":"ml-7",A),style:_,children:P})]})});Ru.displayName="RadioButton";var pl=()=>{},hv=[],yv=jsx("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none","aria-hidden":"true",className:"shrink-0",children:jsx("path",{d:"M4 6L8 10L12 6",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})}),xv=jsx("svg",{width:"14",height:"14",viewBox:"0 0 14 14",fill:"none","aria-hidden":"true",className:"shrink-0",children: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"})}),vv=jsxs("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none","aria-hidden":"true",className:"shrink-0 animate-spin",children:[jsx("circle",{cx:"8",cy:"8",r:"6",stroke:"currentColor",strokeWidth:"2",strokeOpacity:"0.25"}),jsx("path",{d:"M14 8a6 6 0 00-6-6",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round"})]}),kv=jsx("svg",{width:"14",height:"14",viewBox:"0 0 14 14",fill:"none","aria-hidden":"true",className:"shrink-0",children:jsx("path",{d:"M11.5 3.5L5.5 10.5L2.5 7.5",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})}),Va={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"}},Tu={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 Bn(...e){let t="";for(let r=0;r<e.length;r++){let n=e[r];n&&(t&&(t+=" "),t+=n);}return t}function Cv(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 wv=memo(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);},b=()=>{o||i(c);};return jsxs("div",{ref:d,id:s,role:"option","aria-selected":r,"aria-disabled":o||void 0,"data-highlighted":n||void 0,className:Bn(Va[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:b,children:[t.icon?jsx("span",{className:"flex shrink-0 items-center",children:t.icon}):null,jsxs("span",{className:"flex flex-col min-w-0 flex-1",children:[jsx("span",{className:"truncate",children:t.label}),t.description?jsx("span",{className:"text-xs text-gray-500 dark:text-gray-400 truncate",children:t.description}):null]}),r?jsx("span",{className:"ml-auto text-blue-600 dark:text-blue-400",children:kv}):null]})}));function Nv({options:e=hv,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:b,description:m,helperText:p,error:C,required:v=false,noOptionsText:k="No options",onSearchChange:y,name:z,className:h,triggerClassName:R,contentClassName:f,maxHeight:N=256}){let L=useId(),E=`${L}-label`,I=`${L}-trigger`,w=`${L}-listbox`,W=useRef(null),M=useRef(null),T=useRef(null),P=useRef([]),x=t!==void 0,[D,S]=useState(r??""),B=x?t:D,[H,$]=useState(false),[_,F]=useState(""),[A,V]=useState(-1),[Y,X]=useState(null),G=useMemo(()=>o?Cv(e,_):e,[e,_,o]),j=useMemo(()=>e.find(me=>me.value===B)??null,[e,B]),O=useMemo(()=>{let me=new Set;for(let ce of e)ce.disabled&&me.add(ce.value);return me},[e]),K=useCallback(me=>{x||S(me),(n??pl)(me),$(false),F(""),V(-1),W.current?.focus();},[x,n]),se=useCallback(me=>{me.stopPropagation(),x||S(""),(n??pl)(""),F(""),W.current?.focus();},[x,n]),ae=useCallback(()=>{s||l||($(true),F(""),V(-1));},[s,l]),U=useCallback(()=>{$(false),F(""),V(-1),W.current?.focus();},[]),J=useCallback(()=>{H?U():ae();},[H,U,ae]),te=useCallback((me,ce)=>{let Oe=G.length;if(Oe===0)return -1;let st=me;for(let Pe=0;Pe<Oe;Pe++)if(st=((st+ce)%Oe+Oe)%Oe,!O.has(G[st].value))return st;return -1},[G,O]),ie=useCallback(me=>{if(!(s||l)){if(H){switch(me.key){case "ArrowDown":{me.preventDefault();let ce=te(A,1);ce!==-1&&V(ce);break}case "ArrowUp":{me.preventDefault();let ce=te(A,-1);ce!==-1&&V(ce);break}case "Home":{me.preventDefault();let ce=te(-1,1);ce!==-1&&V(ce);break}case "End":{me.preventDefault();let ce=te(G.length,-1);ce!==-1&&V(ce);break}case "Enter":{if(me.preventDefault(),A>=0&&A<G.length){let ce=G[A];O.has(ce.value)||K(ce.value);}break}case " ":if(me.preventDefault(),A>=0&&A<G.length){let ce=G[A];O.has(ce.value)||K(ce.value);}else U();break;case "Escape":me.preventDefault(),U();break;case "Tab":U();break}return}switch(me.key){case "ArrowDown":case "ArrowUp":me.preventDefault(),ae();break;case "Enter":case " ":me.preventDefault(),ae();break}}},[s,l,H,ae,U,A,G,O,te,K]),Q=useCallback(me=>{switch(me.key){case "ArrowDown":{me.preventDefault();let ce=te(A,1);ce!==-1&&V(ce);break}case "ArrowUp":{me.preventDefault();let ce=te(A,-1);ce!==-1&&V(ce);break}case "Home":{me.preventDefault();let ce=te(-1,1);ce!==-1&&V(ce);break}case "End":{me.preventDefault();let ce=te(G.length,-1);ce!==-1&&V(ce);break}case "Enter":{if(me.preventDefault(),A>=0&&A<G.length){let ce=G[A];O.has(ce.value)||K(ce.value);}break}case "Escape":me.preventDefault(),U();break;case "Tab":U();break}},[A,G,O,te,K,U]),ge=useCallback(me=>{let ce=me.target.value;F(ce),V(-1),(y??pl)(ce);},[y]);useEffect(()=>{if(!H)return;let me=ce=>{let Oe=ce.target;W.current?.contains(Oe)||M.current?.contains(Oe)||U();};return document.addEventListener("mousedown",me),document.addEventListener("touchstart",me,{passive:true}),()=>{document.removeEventListener("mousedown",me),document.removeEventListener("touchstart",me);}},[H,U]),useEffect(()=>{if(!H||!W.current){X(null);return}let me=()=>{let ce=W.current;if(!ce)return;let Oe=ce.getBoundingClientRect(),st=window.innerHeight-Oe.bottom,Pe=Oe.top,De=N+8,it=st<De&&Pe>st?"top":"bottom";X({top:it==="bottom"?Oe.bottom+window.scrollY+4:Oe.top+window.scrollY-De,left:Oe.left+window.scrollX,width:Oe.width,placement:it});};return me(),window.addEventListener("scroll",me,true),window.addEventListener("resize",me),()=>{window.removeEventListener("scroll",me,true),window.removeEventListener("resize",me);}},[H,N]),useEffect(()=>{H&&o&&T.current?.focus();},[H,o]),useEffect(()=>{let me=M.current;if(!(!H||!me))return oo(me,()=>W.current)},[H]),useEffect(()=>{if(A>=0){let me=P.current[A];me&&typeof me.scrollIntoView=="function"&&me.scrollIntoView({block:"nearest"});}},[A]);let Re=B!==""&&B!==void 0,Qe=a&&Re&&!s&&!l&&!i,at=!s&&!l,et=Bn("w-full flex items-center justify-between rounded-md transition-colors","text-gray-900 dark:text-gray-100",Va[c].trigger,Tu[d].trigger,!C&&at&&Tu[d].focus,C&&"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",R);return jsxs("div",{className:Bn("flex flex-col gap-1",h),children:[b?jsxs("label",{id:E,htmlFor:I,className:"text-sm font-medium text-gray-700 dark:text-gray-300",children:[b,v?jsx("span",{className:"text-red-500 ml-0.5","aria-hidden":"true",children:"*"}):null]}):null,m?jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400",children:m}):null,jsxs("button",{ref:W,id:I,type:"button",role:"combobox","aria-expanded":H,"aria-haspopup":"listbox","aria-controls":H?w:void 0,"aria-labelledby":b?E:void 0,"aria-required":v||void 0,"aria-invalid":C?true:void 0,"aria-activedescendant":H&&A>=0?`${L}-option-${A}`:void 0,disabled:s,className:et,onClick:at?J:void 0,onKeyDown:ie,children:[jsxs("span",{className:Bn("flex items-center gap-2 min-w-0 flex-1 truncate",!Re&&"text-gray-400 dark:text-gray-500"),children:[j?.icon?jsx("span",{className:"flex shrink-0 items-center",children:j.icon}):null,jsx("span",{className:"truncate",children:Re&&j?j.label:u})]}),jsxs("span",{className:"flex items-center gap-1 shrink-0",children:[i?jsx("span",{className:"text-gray-400",children:vv}):null,Qe?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:me=>me.preventDefault(),children:xv}):null,jsx("span",{className:Bn("text-gray-400 transition-transform duration-200",H&&"rotate-180"),children:yv})]})]}),C?jsx("p",{role:"alert",className:"text-xs text-red-500 dark:text-red-400",children:C}):p?jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400",children:p}):null,z?jsx("input",{type:"hidden",name:z,value:B??""}):null,H&&Y?createPortal(jsxs("div",{ref:M,role:"listbox",id:w,"aria-labelledby":b?E:void 0,className:Bn("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",Va[c].content,f),style:{top:Y.top,left:Y.left,width:Y.width,position:"absolute"},onKeyDown:Q,children:[o?jsx("div",{className:"border-b border-gray-200 dark:border-gray-700",children:jsx("input",{ref:T,type:"text",role:"searchbox","aria-label":"Search options",className:Bn(Va[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:_,onChange:ge,onKeyDown:Q})}):null,jsx("div",{className:"overflow-y-auto",style:{maxHeight:N},children:G.length===0?jsx("div",{className:Bn(Va[c].option,"text-gray-500 dark:text-gray-400 text-center py-4"),children:k}):G.map((me,ce)=>jsx(wv,{option:me,isSelected:me.value===B,isHighlighted:ce===A,isDisabled:i||O.has(me.value),sizeKey:c,optionId:`${L}-option-${ce}`,onClick:K,onMouseEnter:V,index:ce,ref:Oe=>{P.current[ce]=Oe;}},me.value))})]}),document.body):null]})}var bl=createContext(null);function go(){let e=useContext(bl);if(!e)throw new Error("Sidebar sub-components must be used within <Sidebar>");return e}function Tv(){return go()}var Pv=({className:e})=>jsx("svg",{className:g("w-4 h-4",e),viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true",children: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"})}),Ev=({className:e})=>jsx("svg",{className:g("w-4 h-4",e),viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true",children: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"})}),Dv=({className:e})=>jsx("svg",{className:g("w-5 h-5",e),viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true",children: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 Du({text:e,position:t,children:r}){let[n,o]=useState(false),[a,s]=useState({top:0,left:0}),l=useRef(null);return 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&&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 Lv({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:b,trapFocus:m=true,initialFocus:p,returnFocus:C,lockScroll:v=true,children:k}){let y=Ge(),z=useRef(null),h=useRef(null),[R,f]=useState(t),[N,L]=useState(false),[E,I]=useState(false),w=e!==void 0,W=w?e:R,M=i!==void 0,T=M?i:N;useEffect(()=>{let F=window.matchMedia(`(max-width: ${l}px)`),A=V=>{I(V.matches),V.matches||(M||L(false),c?.(false));};return A(F),F.addEventListener("change",A),()=>F.removeEventListener("change",A)},[l,M,c]);let P=useCallback(()=>{if(E){let F=!T;M||L(F),c?.(F);}else {let F=!W;w||f(F),r?.(F);}},[E,T,W,M,w,c,r]),x=useCallback(()=>{M||L(false),c?.(false);},[M,c]);useEffect(()=>{let F=h.current;F&&(E&&!T?(F.setAttribute("inert",""),F.setAttribute("aria-hidden","true")):(F.removeAttribute("inert"),F.removeAttribute("aria-hidden")));},[E,T]);let{dialogRef:D,dialogProps:S}=ao({open:E&&T,onClose:x,trapFocus:m,initialFocus:p,returnFocus:C,lockScroll:v,keepInteractive:[z]}),B={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"},H=W&&!E?o:n,$=jsx("aside",{className:g("flex flex-col h-full overflow-hidden transition-[width] duration-200 ease-in-out",B[s],d),style:{width:E?n:H,minWidth:E?n:H},"data-testid":"sidebar","data-collapsed":W&&!E,"data-mobile":E,"data-position":a,children:k}),_={collapsed:W&&!E,isMobile:E,mobileOpen:T,position:a,variant:s,expandedWidth:n,collapsedWidth:o,toggle:P,closeMobile:x,closeLabel:b};return E?jsxs(bl.Provider,{value:_,children:[T&&jsx("div",{ref:z,className:"fixed inset-0 z-40 bg-black/50 transition-opacity",onClick:x,"aria-hidden":"true","data-testid":"sidebar-overlay"}),jsx("div",{ref:F=>{h.current=F,D.current=F;},...S,"aria-label":u??y.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",T?"translate-x-0":a==="left"?"-translate-x-full":"translate-x-full"),children:$})]}):jsx(bl.Provider,{value:_,children:$})}function Mv({className:e,children:t}){let r=go(),n=Ge();return 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&&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:jsx(Dv,{})})]})}function Iv({className:e,children:t}){return jsx("div",{className:g("flex-1 overflow-y-auto overflow-x-hidden py-2",e),"data-testid":"sidebar-content",children:t})}function Av({className:e,children:t}){let r=go();return 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 zv({label:e,className:t,children:r}){let n=go();return jsxs("div",{className:g("py-2",t),"data-testid":"sidebar-group",children:[e&&!n.collapsed&&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&&jsx("div",{className:"mx-auto my-1 w-6 border-t border-gray-200 dark:border-gray-700"}),jsx("div",{className:"space-y-0.5 px-2",children:r})]})}function Wv({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=go(),u=d.collapsed,b=i??t,m=jsxs(Fragment,{children:[e&&jsx("span",{className:g("shrink-0 w-5 h-5",u&&"w-5 h-5"),children:e}),!u&&jsxs(Fragment,{children:[jsx("span",{className:"flex-1 truncate",children:t}),r!=null&&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&&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),C=()=>{a||(l?.(),d.isMobile&&d.closeMobile());},v=s?jsx("a",{href:a?void 0:s,className:p,onClick:C,"aria-current":o?"page":void 0,"data-testid":"sidebar-item",children:m}):jsx("button",{type:"button",className:p,onClick:C,disabled:a,"aria-current":o?"page":void 0,"data-testid":"sidebar-item",children:m});return u?jsx(Du,{text:b,position:d.position,children:v}):v}function Hv({icon:e,label:t,badge:r,defaultOpen:n=false,className:o,children:a}){let s=go(),[l,i]=useState(n),c=useRef(null),[d,u]=useState(n?void 0:0),b=useRef(true);return useEffect(()=>{if(b.current){b.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?jsx(Du,{text:t,position:s.position,children: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&&jsx("span",{className:"shrink-0 w-5 h-5",children:e}),r!=null&&jsx("span",{className:"absolute top-1 right-1 w-2 h-2 rounded-full bg-blue-600"})]})}):jsxs("div",{className:o,"data-testid":"sidebar-submenu",children:[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&&jsx("span",{className:"shrink-0 w-5 h-5",children:e}),jsx("span",{className:"flex-1 truncate text-left",children:t}),r!=null&&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}),jsx(Ev,{className:g("shrink-0 text-gray-400 transition-transform duration-200",l&&"rotate-180")})]}),jsx("div",{className:"overflow-hidden transition-[height] duration-200 ease-in-out",style:{height:d===void 0?"auto":d},children:jsx("div",{ref:c,className:"pl-4 py-0.5",children:a})})]})}function Vv({className:e}){let t=go(),r=Ge(),n=t.isMobile?t.mobileOpen?t.closeLabel??r.closeSidebar:r.openSidebar:t.collapsed?r.expandSidebar:r.collapseSidebar;return 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:jsx(Pv,{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 yl({data:e,width:t=96,height:r=28,curve:n="monotone",color:o=Ja[0],strokeWidth:a=2,area:s=false,emphasizeLast:l=false,domain:i,ariaLabel:c,className:d,...u}){let b=Math.max(a/2,l?a+2.5:0),m=i??Kt(e)??[0,1],p=Dr([0,Math.max(1,e.length-1)],[b,t-b]),C=Dr(m,[r-b,b]),v=e.map((y,z)=>({x:p(z),y:y==null?Number.NaN:C(y),defined:y!=null&&Number.isFinite(y)})),k=[...v].reverse().find(y=>y.defined!==false);return 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?jsx("path",{d:ga(v,r-b,n),fill:o,fillOpacity:.12,stroke:"none"}):null,jsx("path",{d:$r(v,n),fill:"none",stroke:o,strokeWidth:a,strokeLinecap:"round",strokeLinejoin:"round",vectorEffect:"non-scaling-stroke"}),l&&k?jsx("circle",{cx:k.x,cy:k.y,r:a,fill:o,strokeWidth:2,className:"stroke-white dark:stroke-gray-800"}):null]})}var Fv={sm:"p-3",md:"p-4",lg:"p-5"},Ov={sm:"text-[11px]",md:"text-xs",lg:"text-sm"},$v={sm:"text-xl",md:"text-2xl",lg:"text-3xl"},Lu={sm:{width:72,height:22},md:{width:96,height:28},lg:{width:120,height:34}};function _v(e){return e.direction?e.direction:e.value>0?"up":e.value<0?"down":"flat"}function Xv(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 Gv({direction:e}){return e==="flat"?jsx("svg",{width:"10",height:"10",viewBox:"0 0 10 10",fill:"currentColor","aria-hidden":"true",children:jsx("rect",{x:"1",y:"4.25",width:"8",height:"1.5",rx:"0.75"})}):jsx("svg",{width:"10",height:"10",viewBox:"0 0 10 10",fill:"currentColor","aria-hidden":"true",children:jsx("path",{d:e==="up"?"M5 1 L9.5 8 L0.5 8 Z":"M5 9 L0.5 2 L9.5 2 Z"})})}function Kv({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,...b}){let m=typeof t=="number"?(r??rt)(t):t,p=n?_v(n):"flat",C=n?(n.format??(v=>Gt(v,{signed:true})))(n.value):null;return 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",Fv[l]),u),...b,children:[jsxs("div",{className:"flex items-start justify-between gap-2",children:[jsx("span",{className:g("font-medium text-gray-500 dark:text-gray-400",Ov[l]),children:e}),s?jsx("span",{className:"shrink-0 text-gray-400",children:s}):null]}),jsxs("div",{className:"flex items-end justify-between gap-3",children:[jsxs("div",{className:"flex min-w-0 flex-col gap-1",children:[i?jsx("div",{className:"flex items-center",style:{height:l==="lg"?30:24},"aria-busy":"true","aria-live":"polite",children:jsx(xo,{indeterminate:true,size:l==="lg"?"sm":"xs",thickness:"thin","aria-hidden":"true"})}):jsx("span",{className:g("leading-none font-semibold text-gray-900 dark:text-gray-100",$v[l]),children:m}),n&&!i?jsxs("span",{className:g("flex items-center gap-1 text-xs font-medium",Xv(p,n.goodWhen??"up")),children:[jsx(Gv,{direction:p}),C,n.period?jsx("span",{className:"font-normal text-gray-500 dark:text-gray-400",children:n.period}):null]}):null]}),o&&o.length>0&&!i?jsx(yl,{data:o,color:a,emphasizeLast:true,area:true,width:Lu[l].width,height:Lu[l].height,className:"shrink-0"}):null]}),d?jsx("div",{className:"text-xs text-gray-500 dark:text-gray-400",children:d}):null]})}var Uv={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 Yv({columns:e=4,className:t,children:r,...n}){return jsx("div",{className:g("grid grid-cols-1 gap-3",Uv[e],t),...n,children:r})}var jv={text:"rounded h-4 w-full",circular:"rounded-full",rectangular:"rounded-none",rounded:"rounded-lg"},Zv={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:""},Qv="bg-gray-200 dark:bg-gray-700";function Mu({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(Qv,jv[e],Zv[t],a);return o===1?jsx("div",{className:c,style:i,"aria-busy":"true","aria-live":"polite",...l}):jsx("div",{className:"space-y-2",children:Array.from({length:o}).map((d,u)=>jsx("div",{className:c,style:i,"aria-busy":"true","aria-live":"polite",...l},u))})}Mu.displayName="Skeleton";var n1={sm:"h-1",md:"h-1.5",lg:"h-2"},o1={sm:"w-3.5 h-3.5",md:"w-4 h-4",lg:"w-5 h-5"},a1={sm:14,md:16,lg:20},s1="[&::-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",i1={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"},l1={sm:"h-4",md:"h-5",lg:"h-6"},c1={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"},d1={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"},u1={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"},m1={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"},Iu=(e,t,r)=>Math.min(r,Math.max(t,e)),vl=(e,t,r)=>r>t?(Iu(e,t,r)-t)/(r-t)*100:0,Bs=(e,t)=>{let r=(.5-e/100)*t,n=Math.round(Math.abs(r)*1e3)/1e3;return `calc(${e}% ${r<0?"-":"+"} ${n}px)`},g1=(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}))},Au=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:b=false,showValue:m=false,showTooltip:p=false,valueFormat:C,marks:v,trackColor:k,fillColor:y,thumbColor:z,className:h,containerClassName:R,id:f,...N},L)=>{let[E,I]=useState(t??n),w=e!==void 0,M=Iu(w?e:E,n,o),T=useId(),P=f??T,x=typeof b=="string"?b:void 0,D=!!b,S=!i&&!c,B=D?"error":l,H=vl(M,n,o),$=a1[s],_=j=>{if(!S)return;let O=Number(j.target.value);w||I(O),r?.(O);},F=useMemo(()=>g1(v,n,o,a),[v,n,o,a]),A=F.some(j=>j.label!=null),V=C?C(M):`${M}`,Y={width:Bs(H,$)};y&&(Y.backgroundColor=y);let X={left:Bs(H,$)};z&&(X.backgroundColor=z,X.borderColor=z);let G=k?{backgroundColor:k}:{};return jsxs("div",{className:g("w-full",R),children:[(d||m)&&jsxs("div",{className:"flex items-center justify-between mb-1.5",children:[d?jsx("label",{htmlFor:P,className:g("text-sm font-medium text-gray-700 dark:text-gray-200",i&&"opacity-50"),children:d}):jsx("span",{}),m&&jsx("span",{className:g("text-sm font-semibold tabular-nums",m1[B]),children:V})]}),jsxs("div",{className:g("relative flex items-center",l1[s],i&&"opacity-50"),children:[jsx("input",{ref:L,type:"range",id:P,min:n,max:o,step:a,value:M,onChange:_,disabled:i,readOnly:c,"aria-invalid":D,"aria-readonly":c||void 0,"aria-describedby":x?`${P}-error`:void 0,tabIndex:S?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",s1,i1[s],!S&&"pointer-events-none cursor-default",h),...N}),jsxs("div",{className:g("pointer-events-none relative w-full overflow-hidden rounded-full bg-gray-200 dark:bg-gray-700",n1[s]),style:G,children:[jsx("div",{className:g("absolute inset-y-0 left-0 rounded-full transition-[width] duration-150 ease-out",y?"":c1[B]),style:Y}),F.map((j,O)=>{let K=vl(j.value,n,o),se=j.value<=M;return 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:Bs(K,$)}},`mark-${j.value}-${O}`)})]}),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",o1[s],z?"":d1[B],S&&"peer-hover:scale-110 peer-active:scale-110","peer-focus-visible:scale-110 peer-focus-visible:ring-2 peer-focus-visible:ring-offset-2",u1[B]),style:X,children:p&&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})})]}),A&&jsx("div",{className:"relative mt-1.5 h-4",children:F.map((j,O)=>j.label!=null?jsx("span",{className:"absolute -translate-x-1/2 whitespace-nowrap text-xs text-gray-500 dark:text-gray-400",style:{left:Bs(vl(j.value,n,o),$)},children:j.label},`mark-label-${j.value}-${O}`):null)}),u&&!x&&jsx("p",{className:"mt-1.5 text-sm text-gray-500 dark:text-gray-400",children:u}),x&&jsx("p",{id:`${P}-error`,className:"mt-1.5 text-sm text-red-500 dark:text-red-400",children:x})]})});Au.displayName="Slider";var kl=createContext(null);function Ko(){let e=useContext(kl);if(!e)throw new Error("Tabs components must be used within a Tabs provider");return e}function Wu({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]=useState(t),b=r!==void 0,m=b?r:d,p=useCallback(v=>{b||u(v),n?.(v);},[b,n]),C=useMemo(()=>({value:m,onValueChange:p,variant:o,size:a,color:s,orientation:i,fullWidth:l}),[m,p,o,a,s,i,l]);return jsx(kl.Provider,{value:C,children:jsx("div",{className:g("w-full",i==="vertical"&&"flex gap-4",c),"data-orientation":i,children:e})})}Wu.displayName="Tabs";var x1={none:"gap-0",sm:"gap-1",md:"gap-2",lg:"gap-4"};function Hu({children:e,className:t,bgColor:r,gap:n="none"}){let{variant:o,orientation:a,fullWidth:s}=Ko(),l=g("flex",a==="vertical"?"flex-col":"flex-row items-center",x1[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 jsx("div",{role:"tablist","aria-orientation":a,className:g(l,i[o],s&&"w-full",t),children:e})}Hu.displayName="TabsList";var k1={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"},Vu={sm:"w-3.5 h-3.5",md:"w-4 h-4",lg:"w-5 h-5"},Bu={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"}}},C1={underline:"border-b-2 -mb-px",pills:"rounded-md",enclosed:"border border-b-0 rounded-t-md -mb-px",soft:"rounded-md"};function Fu({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:b,fullWidth:m}=Ko(),p=i===e,C=()=>{r||c(e);},v=h=>{(h.key==="Enter"||h.key===" ")&&(h.preventDefault(),C());},k=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",k1[u],m&&"flex-1"),y=p?g(Bu[b][d].active,s):g(Bu[b][d].inactive,l),z=r?"opacity-50 cursor-not-allowed":"cursor-pointer";return jsxs("button",{type:"button",role:"tab","aria-selected":p,"aria-disabled":r,tabIndex:p?0:-1,onClick:C,onKeyDown:v,disabled:r,className:g(k,C1[d],y,z,a),children:[n&&jsx("span",{className:g("shrink-0",Vu[u]),children:n}),jsx("span",{children:t}),o&&jsx("span",{className:g("shrink-0",Vu[u]),children:o})]})}Fu.displayName="TabsTrigger";function Ou({value:e,children:t,className:r,forceMount:n=false}){let{value:o}=Ko(),a=o===e;return !a&&!n?null: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})}Ou.displayName="TabsContent";function S1({className:e}){return jsx("svg",{className:e,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",children: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 R1({className:e}){return jsx("svg",{className:e,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",children: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 T1({className:e}){return jsx("svg",{className:e,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",children: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 $u({className:e}){return jsx("svg",{className:e,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",children: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 P1({className:e}){return jsx("svg",{className:e,viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",children:jsx("path",{d:"M4 4L12 12M12 4L4 12",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})})}var E1={success:S1,error:R1,warning:T1,info:$u,default:$u},D1={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"}},L1={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 Xu({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=E1[n],b=jsx(u,{className:"w-5 h-5"}),m=e??r;return 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",D1[n][o],c),...d,children:[jsx("div",{className:g("flex-shrink-0 mt-0.5",o==="solid"?"text-white":L1[n]),children:a??b}),jsxs("div",{className:"flex-1 min-w-0",children:[t&&jsx("div",{className:"font-semibold text-sm mb-1",children:t}),m&&jsx("div",{className:"text-sm opacity-90",children:m}),s&&jsx("div",{className:"mt-3",children:s})]}),i&&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:jsx(P1,{className:"w-4 h-4"})})]})}Xu.displayName="Toast";var A1={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"},z1={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"}},W1={sm:"px-2 py-1 text-xs",md:"px-3 py-1.5 text-sm",lg:"px-4 py-2 text-base"},H1={sm:"border-4",md:"border-[5px]",lg:"border-[6px]"},V1={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"},B1={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 zt({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:b=false,...m}){let[p,C]=useState(false),v=useRef(null),k=useCallback(()=>{b||(l>0?v.current=setTimeout(()=>C(true),l):C(true));},[l,b]),y=useCallback(()=>{v.current&&(clearTimeout(v.current),v.current=null),C(false);},[]),z=useCallback(()=>{b||C(f=>!f);},[b]),h=a==="manual"?s:p,R={hover:{onMouseEnter:k,onMouseLeave:y,onFocus:k,onBlur:y},click:{onClick:z},manual:{}}[a];return jsxs("div",{className:g("relative inline-flex",d),...R,...m,children:[e,h&&!b&&jsxs("div",{role:"tooltip",className:g("absolute z-50 whitespace-normal wrap-break-word rounded-md","transition-opacity duration-150",V1[r],A1[n],W1[o],c,u),children:[t,i&&jsx("span",{className:g("absolute w-0 h-0 border-solid",H1[o],B1[r],z1[n][r]),"aria-hidden":"true"})]})]})}zt.displayName="Tooltip";function O1(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 $1(e){switch(e){case "sm":return "py-6";case "lg":return "py-16";default:return "py-10"}}function Uu({variant:e="default",size:t="md",sticky:r=false,className:n,children:o,...a}){return jsx("footer",{className:g(O1(e),$1(t),r&&"sticky bottom-0 z-40",n),...a,children:jsx("div",{className:"container mx-auto px-4",children:o})})}Uu.displayName="Footer";function _1(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 Yu({title:e,titleClassName:t,columns:r,className:n,children:o,...a}){return jsxs("div",{className:g(r&&"grid gap-8",_1(r),n),...a,children:[e&&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]})}Yu.displayName="FooterSection";function qu({title:e,titleClassName:t,className:r,children:n,...o}){return jsxs("div",{className:g("flex flex-col gap-3",r),...o,children:[e&&jsx("h4",{className:g("text-sm font-semibold uppercase tracking-wider text-gray-900 dark:text-white",t),children:e}),n]})}qu.displayName="FooterColumn";function ju({external:e=false,className:t,children:r,...n}){return 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})}ju.displayName="FooterLink";function Zu({copyright:e,className:t,children:r,...n}){return 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&&jsx("p",{className:"text-sm text-gray-500 dark:text-gray-400",children:e}),r]})}Zu.displayName="FooterBottom";function Qu({className:e,children:t,...r}){return jsx("div",{className:g("flex items-center gap-4",e),...r,children:t})}Qu.displayName="FooterSocial";function Ju({icon:e,label:t,className:r,...n}){return 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})}Ju.displayName="FooterSocialLink";var Q1=4.5,J1=48,tm=false,ek=memo(function({points:t}){return jsx("g",{children:t.map(r=>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 tk({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:b,tooltip:m,onPointClick:p,plotLabel:C,formatValue:v,formatX:k}){let[y,z]=useState(null),h=useMemo(()=>{let N=n.filter(D=>!D.hidden),L=N.map(D=>D.key),E=Qt({width:e,height:t,data:r,x:{...o,scale:o.scale==="time"?"time":"linear"},y:a,bounds:Kt(ur(r,L)),margin:b,formatValue:v,formatX:k}),I=i?ur(r,[i.key]):[],w=i?Kt(I):null,[W,M]=i?.range??[4,14],T=D=>{if(!i||!w)return u;let S=Ee(D,i.key);if(S===null)return W;let[B,H]=w,$=H===B?1:(S-B)/(H-B);return Math.sqrt(W*W+$*(M*M-W*W))},P=[];N.forEach(D=>{r.forEach((S,B)=>{let H=Ee(S,D.key),$=E.categoryPositions[B];H===null||!Number.isFinite($)||P.push({seriesKey:D.key,seriesLabel:Xt(D),color:D.color,index:B,cx:$,cy:E.valueScale(H),r:T(S),xValue:Jr(E.xValues[B]),yValue:H});});});let x=null;if(c&&P.length>1){let D=P.length,S=P.reduce((F,A)=>F+A.xValue,0),B=P.reduce((F,A)=>F+A.yValue,0),H=P.reduce((F,A)=>F+A.xValue*A.yValue,0),$=P.reduce((F,A)=>F+A.xValue*A.xValue,0),_=D*$-S*S;if(_!==0){let F=(D*H-S*B)/_,A=(B-F*S)/D,V=P.map(j=>j.xValue),[Y,X]=[Math.min(...V),Math.max(...V)],G=P.map(j=>j.cx);x={x1:Math.min(...G),y1:E.valueScale(F*Y+A),x2:Math.max(...G),y2:E.valueScale(F*X+A)};}}return {visible:N,points:P,trend:x,xTicks:E.categoryTicks,yTicks:E.valueTicks,valueScale:E.valueScale,positions:E.categoryPositions,innerWidth:E.innerWidth,innerHeight:E.innerHeight,margin:E.margin,xValues:E.xValues}},[r,n,o,a,e,t,b,i,c,u,v,k]),R=useCallback(N=>{if(m===false||h.points.length===0)return;let L=N.currentTarget.getBoundingClientRect(),E=N.clientX-L.left-h.margin.left,I=N.clientY-L.top-h.margin.top,w=null,W=J1;for(let M of h.points){let T=Math.hypot(M.cx-E,M.cy-I);T<W&&(W=T,w=M);}z(w);},[m,h.points,h.margin]),f=useCallback(()=>{!p||!y||p({seriesKey:y.seriesKey,seriesLabel:y.seriesLabel,color:y.color,value:y.yValue,formattedValue:v(y.yValue),datum:r[y.index],index:y.index,x:h.xValues[y.index]});},[p,y,v,r,h.xValues]);return jsxs(Fragment,{children:[jsxs("svg",{width:e,height:t,role:"img","aria-label":C??h.visible.map(N=>Xt(N)).join(", "),tabIndex:0,className:"touch-none focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-blue-500",onPointerMove:R,onPointerLeave:()=>z(null),onBlur:()=>z(null),onClick:f,children:[jsxs("g",{transform:`translate(${h.margin.left}, ${h.margin.top})`,children:[jsx(Ot,{width:h.innerWidth,height:h.innerHeight,horizontal:s==="y"||s==="both"?h.yTicks.map(N=>N.offset):void 0,vertical:s==="x"||s==="both"?h.xTicks.map(N=>N.offset):void 0}),d?.y!==void 0?jsx("line",{x1:0,y1:h.valueScale(d.y),x2:h.innerWidth,y2:h.valueScale(d.y),stroke:"var(--color-chart-muted)",strokeWidth:1,strokeDasharray:"4 4"}):null,h.trend?jsx("line",{x1:h.trend.x1,y1:h.trend.y1,x2:h.trend.x2,y2:h.trend.y2,stroke:"var(--color-chart-muted)",strokeWidth:1.5,strokeDasharray:"4 4"}):null,jsx(ek,{points:h.points}),y?jsx("circle",{cx:y.cx,cy:y.cy,r:y.r+3,fill:"none",stroke:y.color,strokeWidth:2,"aria-hidden":"true"}):null]}),jsx("g",{transform:`translate(${h.margin.left}, ${h.margin.top+h.innerHeight})`,children:o.hidden?null:jsx(_e,{orientation:"bottom",ticks:h.xTicks,length:h.innerWidth,label:o.label,size:l})}),jsx("g",{transform:`translate(${h.margin.left}, ${h.margin.top})`,children:a?.hidden?null:jsx(_e,{orientation:"left",ticks:h.yTicks,length:h.innerHeight,showLine:false,label:a?.label,size:l})})]}),y&&m!==false?jsx(gt,{x:h.margin.left+y.cx,y:h.margin.top+y.cy,containerWidth:e,children:typeof m=="function"?m({x:h.xValues[y.index],xLabel:k(h.xValues[y.index],y.index),index:y.index,points:[{seriesKey:y.seriesKey,seriesLabel:y.seriesLabel,color:y.color,value:y.yValue,formattedValue:v(y.yValue),datum:r[y.index]}]}):jsx(Cr,{title:`${o.label??o.key} ${k(h.xValues[y.index],y.index)}`,points:[{seriesKey:y.seriesKey,seriesLabel:y.seriesLabel,color:y.color,value:y.yValue,formattedValue:v(y.yValue),datum:r[y.index]}]})}):null]})}function rk({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:b,description:m,loading:p=false,emptyState:C,onPointClick:v,bubble:k,trendLine:y=false,quadrants:z,pointRadius:h=Q1,legendToggle:R=true,margin:f,locale:N,plotLabel:L,className:E,...I}){let[w,W]=useState(()=>new Set);t.length>3&&!tm&&(tm=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 M=useMemo(()=>t.map((H,$)=>({...H,hidden:H.hidden||w.has(H.key),color:Er(H,$,u)})),[t,w,u]),T=useMemo(()=>n?.format??(H=>rt(H,N)),[n?.format,N]),P=useMemo(()=>r.format??(H=>r.scale==="time"?Ke(H instanceof Date?H:new Date(Jr(H)),N):rt(Jr(H),N)),[r.format,r.scale,N]),x=useCallback(H=>{W($=>{let _=new Set($);return _.has(H)?_.delete(H):_.add(H),_});},[]),D=i===void 0?t.length>=2:i!==false,S=typeof i=="string"?i:"bottom",B=M.filter(H=>!H.hidden).length;return jsx(ut,{title:b,description:m,height:o,width:a,size:s,loading:p,empty:e.length===0||B===0,emptyState:C,tableView:d,legendPosition:S,legend:D?jsx($t,{items:Or(M,u),position:S,marker:"dot",size:s,onToggle:R?x:void 0}):void 0,table:d?jsx(It,{data:e,series:M,xKey:r.key,xLabel:r.label??r.key,formatX:P,formatValue:T,caption:typeof b=="string"?b:void 0}):void 0,className:E,...I,children:({width:H})=>jsx(tk,{width:H,height:o,data:e,resolvedSeries:M,x:r,y:n,grid:l,size:s,bubble:k,trendLine:y,quadrants:z,pointRadius:h,margin:f,tooltip:c,onPointClick:v,plotLabel:L,formatValue:T,formatX:P})})}var nm="se-grid-pattern",om=memo(function({gridSize:t,zoom:r}){let n=t*r;return jsxs("svg",{className:"absolute inset-0 w-full h-full pointer-events-none","aria-hidden":"true",children:[jsx("defs",{children:jsx("pattern",{id:nm,width:n,height:n,patternUnits:"userSpaceOnUse",children:jsx("circle",{cx:1,cy:1,r:1,className:"fill-gray-300 dark:fill-gray-600"})})}),jsx("rect",{width:"100%",height:"100%",fill:`url(#${nm})`})]})});function Fn(e,t){return e.collapsed?40:e.height?e.height:40+(e.notes?24:0)+e.fields.length*32+(t?36:0)}function Uo(e,t){return 40+(t?24:0)+e*32+32/2}function am(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+Uo(n,a);return {x:r==="left"?e.x+0:e.x+o-0,y:s}}function Rl(e,t){return Math.round(e/t)*t}function Oa(e,t,r){return Math.min(r,Math.max(t,e))}function $a(e,t,r,n){return {x:(e-n.left-r.x)/r.zoom,y:(t-n.top-r.y)/r.zoom}}function _s(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 sm(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 C=p.width??260,v=Fn(p,n);a=Math.min(a,p.x),s=Math.min(s,p.y),l=Math.max(l,p.x+C),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),b=(t-c*u)/2-(a-o)*u,m=(r-d*u)/2-(s-o)*u;return {x:b,y:m,zoom:u}}var Xa=["text","varchar","char","int2","int4","int8","serial","bigserial","float4","float8","numeric","decimal","bool","date","time","timestamp","timestamptz","uuid","json","jsonb","bytea"];function im(){return `table-${Date.now()}-${Math.random().toString(36).slice(2,8)}`}function _a(){return `field-${Date.now()}-${Math.random().toString(36).slice(2,8)}`}function Tl(){return `rel-${Date.now()}-${Math.random().toString(36).slice(2,8)}`}function Pl(e="new_field"){return {id:_a(),name:e,type:"text",nullable:true}}function El(e,t,r="new_table"){return {id:im(),name:r,x:e,y:t,fields:[{id:_a(),name:"id",type:"serial",primaryKey:true},{id:_a(),name:"createdAt",type:"timestamp"},{id:_a(),name:"updatedAt",type:"timestamp"}]}}var Xs=()=>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:[jsx("path",{d:"M10 1l2 2-5 5M8.5 4.5L11 7"}),jsx("circle",{cx:"4.5",cy:"11.5",r:"3"})]}),cm=()=>jsxs("svg",{className:"w-3.5 h-3.5 flex-shrink-0",viewBox:"0 0 16 16",fill:"currentColor",children:[jsx("circle",{cx:"8",cy:"8",r:"6",className:"fill-blue-500"}),jsx("path",{d:"M5 8h6M8 5l3 3-3 3",stroke:"white",strokeWidth:"1.5",fill:"none",strokeLinecap:"round",strokeLinejoin:"round"})]}),ik=({collapsed:e})=>jsx("svg",{className:"w-3.5 h-3.5",viewBox:"0 0 16 16",fill:"currentColor",children:e?jsx("path",{d:"M6 3l5 5-5 5V3z"}):jsx("path",{d:"M3 6l5 5 5-5H3z"})}),dm=()=>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:jsx("path",{d:"M3 2v12M7 4h6M7 8h4M7 12h5"})}),um=()=>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:jsx("path",{d:"M4 2v8a4 4 0 008 0V2"})}),lk=()=>jsx("svg",{className:"w-3 h-3",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",children:jsx("path",{d:"M4 8h8"})}),ck=()=>jsxs("svg",{className:"w-3 h-3 text-gray-300",viewBox:"0 0 16 16",fill:"currentColor",children:[jsx("circle",{cx:"5",cy:"4",r:"1.5"}),jsx("circle",{cx:"11",cy:"4",r:"1.5"}),jsx("circle",{cx:"5",cy:"8",r:"1.5"}),jsx("circle",{cx:"11",cy:"8",r:"1.5"}),jsx("circle",{cx:"5",cy:"12",r:"1.5"}),jsx("circle",{cx:"11",cy:"12",r:"1.5"})]}),dk=memo(function({field:t,tableId:r,editable:n,readOnly:o,disabled:a,onFieldChange:s}){let[l,i]=useState(false),[c,d]=useState(t.defaultValue??""),u=n&&!o&&!a,b=()=>{i(false),s?.(r,t.id,{defaultValue:c||void 0});};return u?l?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:b,onKeyDown:m=>{m.key==="Enter"&&b(),m.key==="Escape"&&i(false);},onMouseDown:m=>m.stopPropagation(),autoFocus:true}):t.defaultValue?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]}):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?jsxs("span",{className:"text-xs text-emerald-500 flex-shrink-0 truncate max-w-16",title:`Default: ${t.defaultValue}`,children:["= ",t.defaultValue]}):null}),gm=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:b,onFieldRemove:m,onFieldReorder:p,onResizeStart:C}){let v=t.width??260,k=t.collapsed??false,y=l.length>0?l:Xa,[z,h]=useState(null),[R,f]=useState(null),N=useRef(null),L=useCallback(x=>{i?.(t.id,x.target.value);},[t.id,i]),E=useCallback((x,D)=>{u?.(t.id,x,{name:D});},[t.id,u]),I=useCallback((x,D)=>{u?.(t.id,x,{type:D});},[t.id,u]),w=useCallback((x,D)=>{u?.(t.id,x,{primaryKey:!D});},[t.id,u]),W=useCallback((x,D)=>{u?.(t.id,x,{nullable:!D});},[t.id,u]),M=useCallback((x,D)=>{u?.(t.id,x,{indexed:!D});},[t.id,u]),T=useCallback((x,D)=>{u?.(t.id,x,{unique:!D});},[t.id,u]),P=useCallback(()=>{b?.(t.id);},[t.id,b]);return 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:[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?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:L,onMouseDown:x=>x.stopPropagation()}):jsx("span",{className:"flex-1 min-w-0 text-sm font-semibold text-gray-800 dark:text-gray-100 truncate",children:t.name}),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:x=>{x.stopPropagation(),d?.(t.id);},onMouseDown:x=>x.stopPropagation(),"aria-label":k?"Expand table":"Collapse table",children:jsx(ik,{collapsed:k})})]}),!k&&(a&&!o&&!n?jsx("div",{className:"px-3 border-b border-gray-100 dark:border-gray-700 flex items-center",style:{height:24},children: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:x=>c?.(t.id,x.target.value),onMouseDown:x=>x.stopPropagation()})}):t.notes?jsx("div",{className:"px-3 border-b border-gray-100 dark:border-gray-700 flex items-center",style:{height:24},children:jsx("span",{className:"text-xs italic text-gray-400 dark:text-gray-500 truncate",children:t.notes})}):null),!k&&jsxs("div",{className:t.height?"overflow-y-auto flex-1 min-h-0":void 0,children:[t.fields.map((x,D)=>jsxs("div",{"data-field-id":x.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",z===D&&"opacity-40",R===D&&"!border-t-2 !border-t-blue-400"),style:{height:32},draggable:a&&!o&&!n,onDragStart:S=>{!a||o||n||(S.stopPropagation(),N.current=D,h(D),S.dataTransfer.effectAllowed="move",S.dataTransfer.setData("text/plain",String(D)));},onDragOver:S=>{N.current!==null&&(S.preventDefault(),S.stopPropagation(),f(D));},onDragLeave:()=>{R===D&&f(null);},onDrop:S=>{S.preventDefault(),S.stopPropagation(),N.current!==null&&N.current!==D&&p?.(t.id,N.current,D),N.current=null,h(null),f(null);},onDragEnd:()=>{N.current=null,h(null),f(null);},children:[jsx("div",{"data-connection-side":"left","data-field-id":x.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&&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:jsx(ck,{})}),a&&!o&&!n?jsx("button",{type:"button",className:g("w-4 text-xs font-bold flex-shrink-0 text-center cursor-pointer",x.nullable?"text-gray-400":"text-transparent"),onClick:S=>{S.stopPropagation(),W(x.id,x.nullable??false);},onMouseDown:S=>S.stopPropagation(),title:x.nullable?"Nullable":"Not nullable",children:"?"}):jsx("span",{className:g("w-4 text-xs font-bold flex-shrink-0 text-center",x.nullable?"text-gray-400":"text-transparent"),children:x.nullable?"?":""}),x.primaryKey&&x.foreignKey?jsxs("span",{className:"flex items-center gap-0.5 flex-shrink-0",children:[a&&!o&&!n?jsx("button",{type:"button",className:"flex-shrink-0 cursor-pointer",onClick:S=>{S.stopPropagation(),w(x.id,true);},onMouseDown:S=>S.stopPropagation(),title:"Primary Key (click to remove)",children:jsx(Xs,{})}):jsx(Xs,{}),jsx(cm,{})]}):x.primaryKey?a&&!o&&!n?jsx("button",{type:"button",className:"flex-shrink-0 cursor-pointer",onClick:S=>{S.stopPropagation(),w(x.id,true);},onMouseDown:S=>S.stopPropagation(),title:"Primary Key (click to remove)",children:jsx(Xs,{})}):jsx(Xs,{}):x.foreignKey?jsx(cm,{}):a&&!o&&!n?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:S=>{S.stopPropagation(),w(x.id,false);},onMouseDown:S=>S.stopPropagation(),title:"Set as Primary Key","aria-label":"Set as primary key",children: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:[jsx("path",{d:"M10 1l2 2-5 5M8.5 4.5L11 7"}),jsx("circle",{cx:"4.5",cy:"11.5",r:"3"})]})}):jsx("span",{className:"w-3.5 flex-shrink-0"}),a&&!o&&!n?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",x.primaryKey?"text-blue-600 dark:text-blue-400 font-medium":"text-gray-700 dark:text-gray-300"),"aria-label":"Field name",value:x.name,onChange:S=>E(x.id,S.target.value),onMouseDown:S=>S.stopPropagation()}):jsx("span",{className:g("flex-1 min-w-0 text-xs truncate",x.primaryKey?"text-blue-600 dark:text-blue-400 font-medium":"text-gray-700 dark:text-gray-300"),children:x.name}),a&&!o&&!n?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:x.type,onChange:S=>I(x.id,S.target.value),onMouseDown:S=>S.stopPropagation(),children:[y.map(S=>jsx("option",{value:S,children:S},S)),!y.includes(x.type)&&jsx("option",{value:x.type,children:x.type})]}):jsx("span",{className:"text-xs text-gray-400 dark:text-gray-500 flex-shrink-0",children:x.type}),jsx(dk,{field:x,tableId:t.id,editable:a,readOnly:o,disabled:n,onFieldChange:u}),x.indexed&&jsx(dm,{}),x.unique&&jsx(um,{}),a&&!o&&!n&&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:[jsx("button",{type:"button",className:g("cursor-pointer transition-opacity",x.indexed?"opacity-100":"opacity-30 hover:opacity-100"),onClick:S=>{S.stopPropagation(),M(x.id,x.indexed??false);},onMouseDown:S=>S.stopPropagation(),title:x.indexed?"Indexed (click to remove)":"Add index",children:jsx(dm,{})}),jsx("button",{type:"button",className:g("cursor-pointer transition-opacity",x.unique?"opacity-100":"opacity-30 hover:opacity-100"),onClick:S=>{S.stopPropagation(),T(x.id,x.unique??false);},onMouseDown:S=>S.stopPropagation(),title:x.unique?"Unique (click to remove)":"Add unique constraint",children:jsx(um,{})}),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:S=>{S.stopPropagation(),m?.(t.id,x.id);},onMouseDown:S=>S.stopPropagation(),title:"Remove field",children:jsx(lk,{})})]}),jsx("div",{"data-connection-side":"right","data-field-id":x.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}})]},x.id)),a&&!o&&!n&&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:x=>{x.stopPropagation(),P();},onMouseDown:x=>x.stopPropagation(),children:[jsx("svg",{className:"w-3 h-3",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",children:jsx("path",{d:"M8 4v8M4 8h8"})}),"Add field"]})]}),!n&&!o&&jsx("div",{"data-resize-handle":"corner",className:"absolute -bottom-[5px] -right-[5px] w-[14px] h-[14px] cursor-nwse-resize z-20 group/resize",onMouseDown:x=>{x.stopPropagation(),x.preventDefault();let D=t.height??Fn(t,a);C?.(t.id,x.clientX,x.clientY,v,D);},children: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:[jsx("path",{d:"M12 2v10H2",opacity:"0"}),jsx("path",{d:"M6 12L12 6"}),jsx("path",{d:"M10 12L12 10"})]})})]})});function mk(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+Uo(o,!!r.notes),u=n.y+Uo(a,!!n.notes),b,m;return i<=c?(b=r.x+s,m=n.x):(b=r.x,m=n.x+l),{x1:b,y1:d,x2:m,y2:u,cardinality:e.cardinality??"1:n"}}var Ml=["1:1","1:n","n:1","n:n"];function gk(e){let t=Ml.indexOf(e);return Ml[(t+1)%Ml.length]}var fm=memo(function({relations:t,tables:r,viewport:n,selectedRelationId:o,disabled:a,onRelationClick:s,onCardinalityChange:l}){return jsx("svg",{className:"absolute top-0 left-0 pointer-events-none",style:{width:"100%",height:"100%",overflow:"visible"},children:jsx("g",{transform:`translate(${n.x}, ${n.y}) scale(${n.zoom})`,children:t.map(i=>{let c=mk(i,r);if(!c)return null;let{x1:d,y1:u,x2:b,y2:m,cardinality:p}=c,C=_s(d,u,b,m),v=o===i.id,k=(d+b)/2,y=(u+m)/2;return jsxs("g",{children:[jsx("path",{d:C,fill:"none",stroke:"transparent",strokeWidth:16,className:"pointer-events-auto cursor-pointer",onClick:z=>{a||s?.(i.id,z);}}),jsx("path",{d:C,fill:"none",stroke:v?"#3b82f6":"#9ca3af",strokeWidth:v?2.5:1.5,className:"transition-colors"}),jsx("circle",{cx:d,cy:u,r:3,fill:v?"#3b82f6":"#9ca3af"}),jsx("circle",{cx:b,cy:m,r:3,fill:v?"#3b82f6":"#9ca3af"}),p&&jsxs("g",{className:a?void 0:"pointer-events-auto cursor-pointer",onClick:a?void 0:z=>{z.stopPropagation(),l?.(i.id,gk(p));},children:[jsx("rect",{x:k-14,y:y-9,width:28,height:18,rx:4,fill:"white",stroke:v?"#3b82f6":"#d1d5db",strokeWidth:1}),jsx("text",{x:k,y:y+4,textAnchor:"middle",className:"text-[10px] font-mono",fill:v?"#3b82f6":"#6b7280",children:p})]})]},i.id)})})})});var fk=()=>jsx("svg",{className:"w-4 h-4",viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true",children: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"})}),bk=()=>jsx("svg",{className:"w-4 h-4",viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true",children:jsx("path",{fillRule:"evenodd",d:"M5 10a1 1 0 011-1h8a1 1 0 110 2H6a1 1 0 01-1-1z",clipRule:"evenodd"})}),hk=()=>jsx("svg",{className:"w-4 h-4",viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true",children: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"})}),yk=()=>jsx("svg",{className:"w-4 h-4",viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true",children: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"})}),xk=()=>jsx("svg",{className:"w-4 h-4",viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true",children: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"})}),vk=()=>jsx("svg",{className:"w-4 h-4",viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true",children: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"})}),kk=()=>jsx("svg",{className:"w-4 h-4",viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true",children: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"})}),Ck=()=>jsx("svg",{className:"w-4 h-4",viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true",children: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"})}),wk=()=>jsx("svg",{className:"w-4 h-4",viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true",children: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"})}),Nk=()=>jsx("svg",{className:"w-4 h-4",viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true",children: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"})}),Sk=()=>jsx("svg",{className:"w-4 h-4",viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true",children:jsx("path",{d:"M3 3h4v4H3V3zm0 10h4v4H3v-4zm10-10h4v4h-4V3zm0 10h4v4h-4v-4zM7 5h6v1H7V5zm0 8h6v1H7v-1zM5 7v6h1V7H5zm8 0v6h1V7h-1z"})}),bm=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:b=false,canRedo:m=false,onAutoLayout:p,disabled:C,className:v}){let[k,y]=useState(false),[z,h]=useState(false),[R,f]=useState(false),[N,L]=useState(""),[E,I]=useState(""),[w,W]=useState(""),M=useCallback(()=>{L(l()),y(true);},[l]),T=useCallback(()=>{E.trim()&&(i(E.trim()),I(""),h(false));},[E,i]),P=useCallback(()=>{I(""),h(false);},[]),x=useCallback(()=>{y(false);},[]),D=useCallback(()=>{c&&(W(c()),f(true));},[c]),S=useCallback(()=>{f(false);},[]),B=Math.round(t*100);return jsxs(Fragment,{children:[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:H=>H.stopPropagation(),children:[jsxs(Mo,{size:"sm",children:[jsx(zt,{content:"Zoom in",size:"sm",position:"bottom",children:jsx(At,{icon: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:r,disabled:C,"aria-label":"Zoom in"})}),jsx(zt,{content:"Zoom out",size:"sm",position:"bottom",children:jsx(At,{icon: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:n,disabled:C,"aria-label":"Zoom out"})})]}),jsxs("span",{className:"text-xs font-mono text-gray-500 dark:text-gray-400 min-w-[3ch] text-center select-none",children:[B,"%"]}),jsx("div",{className:"w-px h-5 bg-gray-200 dark:bg-gray-600"}),jsx(zt,{content:"Reset view",size:"sm",position:"bottom",children:jsx(At,{icon: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:o,disabled:C,"aria-label":"Reset view"})}),jsx(zt,{content:"Fit to content",size:"sm",position:"bottom",children:jsx(At,{icon: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:a,disabled:C,"aria-label":"Fit to content"})}),jsx("div",{className:"w-px h-5 bg-gray-200 dark:bg-gray-600"}),jsx(zt,{content:"Add table",size:"sm",position:"bottom",children:jsx(At,{icon: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:s,disabled:C,"aria-label":"Add table"})}),jsx("div",{className:"w-px h-5 bg-gray-200 dark:bg-gray-600"}),jsx(zt,{content:"Export JSON",size:"sm",position:"bottom",children:jsx(At,{icon: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:M,disabled:C,"aria-label":"Export JSON"})}),jsx(zt,{content:"Import JSON",size:"sm",position:"bottom",children:jsx(At,{icon:jsx(kk,{}),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:()=>h(true),disabled:C,"aria-label":"Import JSON"})}),c&&jsx(zt,{content:"Export SQL",size:"sm",position:"bottom",children:jsx(At,{icon: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:D,disabled:C,"aria-label":"Export SQL"})}),(d||u)&&jsxs(Fragment,{children:[jsx("div",{className:"w-px h-5 bg-gray-200 dark:bg-gray-600"}),jsxs(Mo,{size:"sm",children:[jsx(zt,{content:"Undo (Ctrl+Z)",size:"sm",position:"bottom",children:jsx(At,{icon:jsx(wk,{}),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:C||!b,"aria-label":"Undo"})}),jsx(zt,{content:"Redo (Ctrl+Y)",size:"sm",position:"bottom",children:jsx(At,{icon:jsx(Nk,{}),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:C||!m,"aria-label":"Redo"})})]})]}),p&&jsxs(Fragment,{children:[jsx("div",{className:"w-px h-5 bg-gray-200 dark:bg-gray-600"}),jsx(zt,{content:"Auto layout",size:"sm",position:"bottom",children:jsx(At,{icon:jsx(Sk,{}),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:C,"aria-label":"Auto layout"})})]})]}),jsx(Tn,{isOpen:k,onClose:x,title:"Export Schema",description:"Copy the JSON below to save your schema.",size:"lg",showSubmit:false,showCancel:true,cancelLabel:"Close",children:jsx(an,{label:"Schema JSON",multiline:true,rows:12,value:N,readOnly:true,size:"sm"})}),jsx(Tn,{isOpen:z,onClose:P,title:"Import Schema",description:"Paste schema JSON to load it into the editor.",size:"lg",showSubmit:true,submitLabel:"Import",onSubmitClick:T,showCancel:true,cancelLabel:"Cancel",children:jsx(an,{label:"Schema JSON",multiline:true,rows:12,value:E,onChange:H=>I(H.target.value),placeholder:'{"tables": [], "relations": []}',size:"sm"})}),jsx(Tn,{isOpen:R,onClose:S,title:"Export SQL",description:"Generated PostgreSQL CREATE TABLE statements.",size:"lg",showSubmit:false,showCancel:true,cancelLabel:"Close",children:jsx(an,{label:"SQL",multiline:true,rows:16,value:w,readOnly:true,size:"sm"})})]})});var Tk=()=>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:[jsx("path",{d:"M10 1l2 2-5 5M8.5 4.5L11 7"}),jsx("circle",{cx:"4.5",cy:"11.5",r:"3"})]}),Pk=()=>jsx("span",{className:"text-xs font-bold text-gray-500 w-3.5 text-center",children:"?"}),Ek=()=>jsxs("svg",{className:"w-3.5 h-3.5",viewBox:"0 0 16 16",fill:"currentColor",children:[jsx("circle",{cx:"8",cy:"8",r:"6",className:"fill-blue-500"}),jsx("path",{d:"M5 8h6M8 5l3 3-3 3",stroke:"white",strokeWidth:"1.5",fill:"none",strokeLinecap:"round",strokeLinejoin:"round"})]}),Dk=()=>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:jsx("path",{d:"M3 2v12M7 4h6M7 8h4M7 12h5"})}),Lk=()=>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:jsx("path",{d:"M4 2v8a4 4 0 008 0V2"})}),hm=memo(function({className:t}){return 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:[jsxs("div",{className:"flex items-center gap-1.5",children:[jsx(Tk,{}),jsx("span",{className:"text-xs text-gray-600 dark:text-gray-300",children:"Primary Key"})]}),jsxs("div",{className:"flex items-center gap-1.5",children:[jsx(Pk,{}),jsx("span",{className:"text-xs text-gray-600 dark:text-gray-300",children:"Nullable"})]}),jsxs("div",{className:"flex items-center gap-1.5",children:[jsx(Ek,{}),jsx("span",{className:"text-xs text-gray-600 dark:text-gray-300",children:"Foreign Key"})]}),jsxs("div",{className:"flex items-center gap-1.5",children:[jsx(Dk,{}),jsx("span",{className:"text-xs text-gray-600 dark:text-gray-300",children:"Index"})]}),jsxs("div",{className:"flex items-center gap-1.5",children:[jsx(Lk,{}),jsx("span",{className:"text-xs text-gray-600 dark:text-gray-300",children:"Unique"})]})]})});var Ks=180,Us=120,Zo=10,ym=memo(function({tables:t,viewport:r,containerWidth:n,containerHeight:o,editable:a,onViewportChange:s,className:l}){let i=useRef(null),c=useMemo(()=>{if(t.length===0)return null;let R=1/0,f=1/0,N=-1/0,L=-1/0;for(let S of t){let B=S.width??260,H=Fn(S,a);R=Math.min(R,S.x),f=Math.min(f,S.y),N=Math.max(N,S.x+B),L=Math.max(L,S.y+H);}let E=-r.x/r.zoom,I=-r.y/r.zoom,w=E+n/r.zoom,W=I+o/r.zoom;R=Math.min(R,E),f=Math.min(f,I),N=Math.max(N,w),L=Math.max(L,W);let M=N-R+Zo*2,T=L-f+Zo*2,P=Math.min((Ks-4)/M,(Us-4)/T),x=(Ks-M*P)/2,D=(Us-T*P)/2;return {minX:R,minY:f,scale:P,offsetX:x,offsetY:D,vpMinX:E,vpMinY:I}},[t,r,n,o,a]),d=useCallback(R=>{if(!c)return;let f=i.current?.getBoundingClientRect();if(!f)return;let N=R.clientX-f.left,L=R.clientY-f.top,E=(N-c.offsetX)/c.scale+c.minX-Zo,I=(L-c.offsetY)/c.scale+c.minY-Zo;s({...r,x:-(E-n/(2*r.zoom))*r.zoom,y:-(I-o/(2*r.zoom))*r.zoom});},[c,r,n,o,s]);if(!c)return null;let{minX:u,minY:b,scale:m,offsetX:p,offsetY:C,vpMinX:v,vpMinY:k}=c,y=(R,f)=>({x:(R-u+Zo)*m+p,y:(f-b+Zo)*m+C}),z=y(v,k),h={w:n/r.zoom*m,h:o/r.zoom*m};return 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:Ks,height:Us},onClick:d,onMouseDown:R=>R.stopPropagation(),"data-testid":"schema-minimap",children:jsxs("svg",{width:Ks,height:Us,children:[t.map(R=>{let f=R.width??260,N=Fn(R,a),L=y(R.x,R.y);return jsx("rect",{x:L.x,y:L.y,width:f*m,height:N*m,fill:R.color??"#e5e7eb",stroke:"#9ca3af",strokeWidth:.5,rx:1},R.id)}),jsx("rect",{x:z.x,y:z.y,width:h.w,height:h.h,fill:"rgba(59, 130, 246, 0.1)",stroke:"#3b82f6",strokeWidth:1,rx:1})]})})});function Ln(e){return `"${e.replace(/"/g,'""')}"`}function xm(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 Hk(e){let t=[Ln(e.name)];return e.type==="serial"||e.type,t.push(xm(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 Vk(e,t,r){let n=[],o=[];for(let i of e.fields)n.push(Hk(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 ${Ln(`fk_${e.name}_${i.name}`)} FOREIGN KEY (${Ln(i.name)}) REFERENCES ${Ln(c.name)} (${Ln(d.name)})`);}let a=[];for(let i of e.fields)i.indexed&&!i.primaryKey&&!i.unique&&a.push(`CREATE INDEX ${Ln(`idx_${e.name}_${i.name}`)} ON ${Ln(e.name)} (${Ln(i.name)});`);let s=[...n,...o],l=`CREATE TABLE ${Ln(e.name)} (
24
24
  ${s.join(`,
25
25
  `)}
26
26
  );`;return a.length>0?l+`
27
27
 
28
28
  `+a.join(`
29
- `):l}function ja(e){let{tables:t,relations:r}=e;return t.length===0?"-- No tables defined":[...t].sort((a,s)=>{let l=a.fields.some(d=>d.foreignKey),i=s.fields.some(d=>d.foreignKey);return l&&!i?1:!l&&i?-1:0}).map(a=>Ax(a,r,t)).join(`
29
+ `):l}function Ys(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=>Vk(a,r,t)).join(`
30
30
 
31
- `)}var zx=60,Wx=40;function vi(e,t){if(e.length===0)return e;let r=new Map;for(let f of e){let h=new Set;for(let y of f.fields)y.foreignKey&&h.add(y.foreignKey.tableId);r.set(f.id,h);}let o=new Map;for(let f of e)o.set(f.id,0);for(let[,f]of r)for(let h of f)o.has(h);for(let[f,h]of r)o.set(f,h.size);let n=[],a=[];for(let[f,h]of o)h===0&&a.push(f);for(;a.length>0;){let f=a.shift();n.push(f);for(let[h,y]of r)if(y.has(f)){let C=(o.get(h)??0)-1;o.set(h,C),C===0&&a.push(h);}}let s=new Set(n);for(let f of e)s.has(f.id)||(n.push(f.id),s.add(f.id));let l=new Map(e.map(f=>[f.id,f])),i=Math.max(1,Math.ceil(Math.sqrt(n.length))),d=0,u=0,p=0,b=0,m=[];for(let f of n){let h=l.get(f);if(!h)continue;let y=h.width??260,C=io(h,t);m.push({...h,x:d,y:u}),b=Math.max(b,C),p++,p>=i?(p=0,d=0,u+=b+Wx,b=0):d+=y+zx;}return m}var wi={x:0,y:0,zoom:1},Ci=.1,Vx=.1,Ox=3,$x=20,_x=50;function Gx({value:e,defaultValue:t,onValueChange:r,fieldTypes:o=jn,onTableClick:n,onTableDoubleClick:a,onTableContextMenu:s,onFieldClick:l,onFieldDoubleClick:i,readOnly:d=false,disabled:u=false,draggableTables:p=true,panOnDrag:b=true,zoomOnWheel:m=true,editable:f=true,minZoom:h=Vx,maxZoom:y=Ox,snapToGrid:C=false,gridSize:v=$x,showGrid:E=true,toolbar:k=true,legend:R=true,autoFit:g=false,className:P},T){let D=e!==void 0,[W,V]=useState(()=>t??{tables:[],relations:[],viewport:{...wi}}),_=D?e:W,M=_.tables,w=_.relations,N=_.viewport??wi,x=useRef(null),S=useRef(null),[I,F]=useState(null),[O,Z]=useState(null),[U,H]=useState(null),[z,$]=useState(null),[K,se]=useState({width:0,height:0}),X=useRef([]),ee=useRef(-1),L=useRef(false),q=useRef(N);q.current=N;let ge=useRef(M);ge.current=M;let de=useRef(w);de.current=w;let Y=useRef(C);Y.current=C;let le=useRef(v);le.current=v;let xe=useRef(f);xe.current=f;let Se=useCallback(B=>{if(L.current)return;let Q=X.current,oe=ee.current;X.current=Q.slice(0,oe+1),X.current.push(B),X.current.length>_x&&X.current.shift(),ee.current=X.current.length-1;},[]),te=useCallback(B=>{if(D){let Q=B(e);Se(Q),r?.(Q);}else V(Q=>{let oe=B(Q);return Se(oe),r?.(oe),oe});},[D,e,r,Se]),Ne=useRef(te);Ne.current=te;let De=useCallback(B=>{te(Q=>({...Q,viewport:B}));},[te]),Ve=useRef(De);Ve.current=De,useEffect(()=>{function B(ne){let ce=S.current;if(!ce)return;let Fe=x.current?.getBoundingClientRect();if(!Fe)return;let Ye=q.current;if(ce.type==="pan"){let _e=ne.clientX-ce.startX,Ie=ne.clientY-ce.startY;Ve.current({...Ye,x:ce.startVpX+_e,y:ce.startVpY+Ie});}if(ce.type==="table"){let _e=Un(ne.clientX,ne.clientY,Ye,Fe),Ie=_e.x-ce.offsetX,Pt=_e.y-ce.offsetY;Y.current&&(Ie=ui(Ie,le.current),Pt=ui(Pt,le.current)),Ne.current(Ge=>({...Ge,tables:Ge.tables.map(ut=>ut.id===ce.tableId?{...ut,x:Ie,y:Pt}:ut)}));}if(ce.type==="relation"){let _e=Un(ne.clientX,ne.clientY,Ye,Fe);S.current={...ce,currentX:_e.x,currentY:_e.y},H({fromX:ce.fromX,fromY:ce.fromY,currentX:_e.x,currentY:_e.y});}if(ce.type==="resize"){let _e=(ne.clientX-ce.startX)/Ye.zoom,Ie=(ne.clientY-ce.startY)/Ye.zoom,Pt=180,Ge=80,ut=Math.max(Pt,ce.startWidth+_e),xt=Math.max(Ge,ce.startHeight+Ie);Ne.current(at=>({...at,tables:at.tables.map(Mt=>Mt.id===ce.tableId?{...Mt,width:ut,height:xt}:Mt)}));}}function Q(ne,ce,Fe,Ye){let _e=q.current,Ie=Un(ne,ce,_e,Fe),Pt=1/0,Ge=null,ut=null;for(let xt of Ye){if(xt.collapsed)continue;let at=xt.fields.length;if(at===0)continue;let Mt=xt.width??260,yr=40+at*32+(xe.current?36:0),xr=40;if(!(Ie.x<xt.x-xr||Ie.x>xt.x+Mt+xr||Ie.y<xt.y-xr||Ie.y>xt.y+yr+xr))for(let Kt=0;Kt<xt.fields.length;Kt++){let rs=xt.y+on(Kt,!!xt.notes),Qn=Math.abs(Ie.y-rs);Qn<Pt&&(Pt=Qn,Ge=xt.id,ut=xt.fields[Kt].id);}}return Ge&&ut?{tableId:Ge,fieldId:ut}:null}function oe(ne){let ce=S.current;if(ce){if(ce.type==="relation"){let Fe=x.current?.getBoundingClientRect();if(Fe){let Ye=de.current,_e=ge.current,Ie=Q(ne.clientX,ne.clientY,Fe,_e);if(Ie&&Ie.tableId!==ce.fromTableId&&!Ye.some(Ge=>Ge.from.tableId===ce.fromTableId&&Ge.from.fieldId===ce.fromFieldId&&Ge.to.tableId===Ie.tableId&&Ge.to.fieldId===Ie.fieldId)){let Ge=ce.fromTableId,ut=ce.fromFieldId,xt=Ie.tableId,at=Ie.fieldId;Ne.current(Mt=>({...Mt,tables:Mt.tables.map(yr=>yr.id===xt?{...yr,fields:yr.fields.map(xr=>xr.id===at?{...xr,foreignKey:{tableId:Ge,fieldId:ut}}:xr)}:yr),relations:[...Mt.relations,{id:pi(),from:{tableId:Ge,fieldId:ut},to:{tableId:xt,fieldId:at},cardinality:"1:n"}]}));}}H(null),$(null);}S.current=null;}}return document.addEventListener("mousemove",B),document.addEventListener("mouseup",oe),()=>{document.removeEventListener("mousemove",B),document.removeEventListener("mouseup",oe);}},[]);let rt=useCallback(B=>{if(!m||u)return;B.preventDefault();let Q=x.current?.getBoundingClientRect();if(!Q)return;let oe=B.clientX-Q.left,ne=B.clientY-Q.top,ce=B.deltaY<0?1:-1,Fe=Kn(N.zoom+ce*Ci,h,y),Ye=Fe/N.zoom;De({x:oe-(oe-N.x)*Ye,y:ne-(ne-N.y)*Ye,zoom:Fe});},[m,u,N,h,y,De]),dt=useCallback(B=>{if(u)return;let Q=B.target,oe=Q.tagName,ne=oe==="INPUT"||oe==="SELECT"||oe==="TEXTAREA"||oe==="BUTTON";if(Q.closest("[data-resize-handle]"))return;let ce=Q.closest("[data-connection-side]");if(ce&&!ne){if(d)return;B.preventDefault();let Ye=ce.getAttribute("data-table-id"),_e=ce.getAttribute("data-field-id");if(!Ye||!_e)return;let Ie=M.find(ut=>ut.id===Ye);if(!Ie)return;let Pt=ce.getAttribute("data-connection-side"),Ge=Pc(Ie,_e,Pt);if(!Ge)return;S.current={type:"relation",fromTableId:Ye,fromFieldId:_e,fromX:Ge.x,fromY:Ge.y,currentX:Ge.x,currentY:Ge.y},H({fromX:Ge.x,fromY:Ge.y,currentX:Ge.x,currentY:Ge.y}),$(Ye);return}let Fe=Q.closest("[data-table-id]");if(Fe){if(d)return;let Ye=Fe.getAttribute("data-table-id");if(Z(null),F(Ye),ne)return;if(p){let _e=x.current?.getBoundingClientRect();if(!_e)return;let Ie=M.find(Ge=>Ge.id===Ye);if(!Ie||Ie.locked)return;let Pt=Un(B.clientX,B.clientY,N,_e);S.current={type:"table",tableId:Ye,offsetX:Pt.x-Ie.x,offsetY:Pt.y-Ie.y};}return}F(null),Z(null),b&&B.button===0&&(S.current={type:"pan",startX:B.clientX,startY:B.clientY,startVpX:N.x,startVpY:N.y});},[u,d,p,b,N,M]),re=useCallback(B=>{let Q=B.target;if(Q.closest("[data-connection-side]"))return null;let oe=Q.closest("[data-table-id]");if(!oe)return null;let ne=oe.getAttribute("data-table-id");return M.find(ce=>ce.id===ne)??null},[M]),pe=useCallback(B=>{if(u)return;let Q=re(B);Q&&n&&n({table:Q,nativeEvent:B.nativeEvent});},[n,u,re]),Ue=useCallback(B=>{if(u)return;let Q=re(B);Q&&a&&a({table:Q,nativeEvent:B.nativeEvent});},[a,u,re]),yt=useCallback(B=>{if(u)return;let Q=re(B);Q&&s&&(B.preventDefault(),s({table:Q,nativeEvent:B.nativeEvent}));},[s,u,re]),Re=useCallback((B,Q)=>{u||(Q.stopPropagation(),F(null),Z(B));},[u]),We=useCallback((B,Q)=>{te(oe=>({...oe,relations:oe.relations.map(ne=>ne.id===B?{...ne,cardinality:Q}:ne)}));},[te]),ft=ee.current>0,rr=ee.current<X.current.length-1,ot=useCallback(()=>{if(ee.current<=0)return;L.current=true,ee.current--;let B=X.current[ee.current];D||V(B),r?.(B),L.current=false;},[D,r]),Wt=useCallback(()=>{if(ee.current>=X.current.length-1)return;L.current=true,ee.current++;let B=X.current[ee.current];D||V(B),r?.(B),L.current=false;},[D,r]),Nt=useCallback(()=>ja(_),[_]),Ht=useCallback(()=>{te(B=>({...B,tables:vi(B.tables,f)}));},[te,f]),or=useCallback((B,Q,oe)=>{Q!==oe&&te(ne=>({...ne,tables:ne.tables.map(ce=>{if(ce.id!==B)return ce;let Fe=[...ce.fields],[Ye]=Fe.splice(Q,1);return Fe.splice(oe,0,Ye),{...ce,fields:Fe}})}));},[te]);useEffect(()=>{let B=x.current;if(!B)return;let Q=new ResizeObserver(oe=>{for(let ne of oe)se({width:ne.contentRect.width,height:ne.contentRect.height});});return Q.observe(B),()=>Q.disconnect()},[]);let Zt=useRef(false);Zt.current||(Zt.current=true,X.current=[_],ee.current=0);let Ar=useCallback(B=>{if(!(d||u)){if((B.ctrlKey||B.metaKey)&&B.key==="z"&&!B.shiftKey){B.preventDefault(),ot();return}if((B.ctrlKey||B.metaKey)&&(B.key==="y"||B.key==="z"&&B.shiftKey)){B.preventDefault(),Wt();return}if(B.key==="Delete"||B.key==="Backspace"){let Q=B.target;if(Q.tagName==="INPUT"||Q.tagName==="TEXTAREA"||Q.tagName==="SELECT")return;I&&(te(oe=>({...oe,tables:oe.tables.filter(ne=>ne.id!==I),relations:oe.relations.filter(ne=>ne.from.tableId!==I&&ne.to.tableId!==I)})),F(null)),O&&(te(oe=>{let ne=oe.relations.find(ce=>ce.id===O);return {...oe,tables:ne?oe.tables.map(ce=>ce.id===ne.to.tableId?{...ce,fields:ce.fields.map(Fe=>Fe.id===ne.to.fieldId?{...Fe,foreignKey:void 0}:Fe)}:ce):oe.tables,relations:oe.relations.filter(ce=>ce.id!==O)}}),Z(null));}B.key==="Escape"&&(F(null),Z(null));}},[d,u,I,O,te,ot,Wt]),br=useCallback((B,Q)=>{te(oe=>({...oe,tables:oe.tables.map(ne=>ne.id===B?{...ne,name:Q}:ne)}));},[te]),fe=useCallback((B,Q)=>{te(oe=>({...oe,tables:oe.tables.map(ne=>ne.id===B?{...ne,notes:Q}:ne)}));},[te]),he=useCallback(B=>{te(Q=>({...Q,tables:Q.tables.map(oe=>oe.id===B?{...oe,collapsed:!oe.collapsed}:oe)}));},[te]),j=useCallback((B,Q,oe)=>{te(ne=>({...ne,tables:ne.tables.map(ce=>ce.id===B?{...ce,fields:ce.fields.map(Fe=>Fe.id===Q?{...Fe,...oe}:Fe)}:ce)}));},[te]),J=useCallback(B=>{te(Q=>({...Q,tables:Q.tables.map(oe=>oe.id===B?{...oe,fields:[...oe.fields,gi()]}:oe)}));},[te]),me=useCallback((B,Q)=>{te(oe=>({...oe,tables:oe.tables.map(ne=>ne.id===B?{...ne,fields:ne.fields.filter(ce=>ce.id!==Q)}:ne),relations:oe.relations.filter(ne=>!(ne.from.tableId===B&&ne.from.fieldId===Q)&&!(ne.to.tableId===B&&ne.to.fieldId===Q))}));},[te]),ue=useCallback((B,Q,oe,ne,ce)=>{S.current={type:"resize",tableId:B,startX:Q,startY:oe,startWidth:ne,startHeight:ce};},[]),Te=useCallback(()=>{let B=Kn(N.zoom+Ci,h,y);De({...N,zoom:B});},[N,h,y,De]),ve=useCallback(()=>{let B=Kn(N.zoom-Ci,h,y);De({...N,zoom:B});},[N,h,y,De]),we=useCallback(()=>{De({...wi});},[De]),He=useCallback(()=>{let B=x.current?.getBoundingClientRect();if(!B)return;let Q=Ec(M,B.width,B.height,f),oe=Kn(Q.zoom,h,y);De({...Q,zoom:oe});},[M,f,h,y,De]),Me=useCallback(B=>{te(Q=>({...Q,tables:[...Q.tables,B]}));},[te]),tt=useCallback(B=>{te(Q=>({...Q,tables:Q.tables.filter(oe=>oe.id!==B),relations:Q.relations.filter(oe=>oe.from.tableId!==B&&oe.to.tableId!==B)}));},[te]),je=useCallback((B,Q)=>{te(oe=>({...oe,tables:oe.tables.map(ne=>ne.id===B?{...ne,fields:[...ne.fields,Q]}:ne)}));},[te]),$e=useCallback((B,Q)=>{me(B,Q);},[me]),Tt=useCallback(B=>{te(Q=>({...Q,tables:Q.tables.map(oe=>oe.id===B.to.tableId?{...oe,fields:oe.fields.map(ne=>ne.id===B.to.fieldId?{...ne,foreignKey:{tableId:B.from.tableId,fieldId:B.from.fieldId}}:ne)}:oe),relations:[...Q.relations,B]}));},[te]),nt=useCallback(B=>{te(Q=>{let oe=Q.relations.find(ne=>ne.id===B);return {...Q,tables:oe?Q.tables.map(ne=>ne.id===oe.to.tableId?{...ne,fields:ne.fields.map(ce=>ce.id===oe.to.fieldId?{...ce,foreignKey:void 0}:ce)}:ne):Q.tables,relations:Q.relations.filter(ne=>ne.id!==B)}});},[te]),nr=useCallback(()=>JSON.stringify(_,null,2),[_]),zr=useCallback(B=>{try{let Q=JSON.parse(B);Q&&Array.isArray(Q.tables)&&Array.isArray(Q.relations)&&te(()=>Q);}catch{}},[te]),mo=useCallback(()=>{let B=x.current?.getBoundingClientRect(),Q=q.current,oe=100,ne=100;B&&(oe=(B.width/2-Q.x)/Q.zoom-260/2,ne=(B.height/2-Q.y)/Q.zoom-60),Me(mi(oe,ne));},[Me]),Ao=useCallback(()=>ja(_),[_]);useImperativeHandle(T,()=>({zoomIn:Te,zoomOut:ve,resetView:we,fitToContent:He,addTable:Me,removeTable:tt,addField:je,removeField:$e,addRelation:Tt,removeRelation:nt,toJSON:nr,loadJSON:zr,toSQL:Ao}),[Te,ve,we,He,Me,tt,je,$e,Tt,nt,nr,zr,Ao]);let hr=useRef(false);useEffect(()=>{g&&!hr.current&&x.current&&(hr.current=true,He());},[g,He]);let ar=useMemo(()=>({transform:`translate(${N.x}px, ${N.y}px) scale(${N.zoom})`,transformOrigin:"0 0"}),[N.x,N.y,N.zoom]);return jsxs("div",{ref:x,"data-testid":"schema-editor",className:c("relative w-full overflow-hidden bg-gray-50 dark:bg-gray-900 select-none",u&&"opacity-60 pointer-events-none",P),tabIndex:0,onWheel:rt,onMouseDown:dt,onClick:pe,onDoubleClick:Ue,onContextMenu:yt,onKeyDown:Ar,children:[E&&jsx(Tc,{gridSize:v,zoom:N.zoom}),k&&!d&&jsx(Bc,{zoom:N.zoom,onZoomIn:Te,onZoomOut:ve,onResetView:we,onFitToContent:He,onAddTable:mo,onExportJSON:nr,onImportJSON:zr,onExportSQL:Nt,onUndo:ot,onRedo:Wt,canUndo:ft,canRedo:rr,onAutoLayout:Ht,disabled:u}),R&&jsx(Vc,{}),jsx(Fc,{relations:w,tables:M,viewport:N,selectedRelationId:O,disabled:u||d,onRelationClick:Re,onCardinalityChange:We}),jsx("div",{style:ar,children:M.map(B=>jsx(Wc,{table:B,selected:I===B.id,disabled:u||d,readOnly:d,editable:f,dropTarget:z!==null&&z!==B.id&&!B.collapsed,fieldTypes:o,onTableNameChange:br,onTableNotesChange:fe,onToggleCollapse:he,onFieldChange:j,onFieldAdd:J,onFieldRemove:me,onFieldReorder:or,onResizeStart:ue},B.id))}),U&&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:[jsx("path",{d:Ga(U.fromX*N.zoom+N.x,U.fromY*N.zoom+N.y,U.currentX*N.zoom+N.x,U.currentY*N.zoom+N.y),fill:"none",stroke:"#3b82f6",strokeWidth:2.5,strokeDasharray:"8 4"}),jsx("circle",{cx:U.fromX*N.zoom+N.x,cy:U.fromY*N.zoom+N.y,r:5,fill:"#3b82f6"}),jsx("circle",{cx:U.currentX*N.zoom+N.x,cy:U.currentY*N.zoom+N.y,r:4,fill:"#3b82f6",opacity:.6})]}),R&&K.width>0&&jsx(Oc,{tables:M,viewport:N,containerWidth:K.width,containerHeight:K.height,editable:f,onViewportChange:De})]})}var Gc=forwardRef(Gx);Gc.displayName="SchemaEditor";var Xc="wf-grid-pattern",Kc=memo(function({gridSize:t,zoom:r}){let o=t*r;return jsxs("svg",{className:"absolute inset-0 w-full h-full pointer-events-none","aria-hidden":"true",children:[jsx("defs",{children:jsx("pattern",{id:Xc,width:o,height:o,patternUnits:"userSpaceOnUse",children:jsx("circle",{cx:1,cy:1,r:1,className:"fill-gray-300 dark:fill-gray-600"})})}),jsx("rect",{width:"100%",height:"100%",fill:`url(#${Xc})`})]})});function Ni(e,t){return Math.round(e/t)*t}function Zn(e,t,r){return Math.min(r,Math.max(t,e))}function cn(e,t,r,o){return {x:(e-o.left-r.x)/r.zoom,y:(t-o.top-r.y)/r.zoom}}function qn(e,t="horizontal"){return t==="vertical"?e==="in"?"top":"bottom":e==="in"?"left":"right"}function un(e,t,r,o="horizontal"){let n=e.width??180,a=e.height??60,s=t.side??qn(t.kind,o),l=r.filter(p=>(p.side??qn(p.kind,o))===s),i=l.findIndex(p=>p.id===t.id),d=l.length,u=d===1?.5:(i+1)/(d+1);switch(s){case "left":return {x:e.x-8,y:e.y+a*u};case "right":return {x:e.x+n+8,y:e.y+a*u};case "top":return {x:e.x+n*u,y:e.y-8};case "bottom":return {x:e.x+n*u,y:e.y+a+8}}}function Za(e,t,r,o,n="horizontal"){if(n==="vertical"){let p=Math.abs(o-t),b=Math.max(50,p*.5),m=e,f=t+b,h=r,y=o-b;return `M ${e} ${t} C ${m} ${f}, ${h} ${y}, ${r} ${o}`}let a=Math.abs(r-e),s=Math.max(50,a*.5),l=e+s,i=t,d=r-s;return `M ${e} ${t} C ${l} ${i}, ${d} ${o}, ${r} ${o}`}function Uc(e,t,r,o=40){if(e.length===0)return {x:0,y:0,zoom:1};let n=1/0,a=1/0,s=-1/0,l=-1/0;for(let m of e){let f=m.width??180,h=m.height??60;n=Math.min(n,m.x),a=Math.min(a,m.y),s=Math.max(s,m.x+f),l=Math.max(l,m.y+h);}let i=s-n+o*2,d=l-a+o*2,u=Math.min(t/i,r/d,1),p=(t-i*u)/2-(n-o)*u,b=(r-d*u)/2-(a-o)*u;return {x:p,y:b,zoom:u}}var Yx=180,jx=60,Ja=12,pn=28,Ri=24,qx=-8;function Zx(e,t,r,o,n="horizontal"){let a=e.side??qn(e.kind,n),s=t.filter(u=>(u.side??qn(u.kind,n))===a),l=s.findIndex(u=>u.id===e.id),i=s.length,d=i===1?.5:(l+1)/(i+1);switch(a){case "left":return {left:0,top:o*d};case "right":return {left:r,top:o*d};case "top":return {left:r*d,top:0};case "bottom":return {left:r*d,top:o}}}function Jx({port:e,allPorts:t,nodeId:r,nodeWidth:o,nodeHeight:n,disabled:a,direction:s,onMouseUp:l}){let i=Zx(e,t,o,n,s),d=a||e.disabled,u=useCallback(p=>{d||(p.stopPropagation(),l(r,e.id));},[d,r,e.id,l]);return 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-pn/2,top:i.top-pn/2,width:pn,height:pn,zIndex:20},onMouseUp:u,title:e.label??e.id,children:jsx("div",{className:c("absolute rounded-full border-2 transition-colors",d?"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:Ja,height:Ja,left:(pn-Ja)/2,top:(pn-Ja)/2}})})}function Qx(e,t,r){let o=e??"top-right",n=qx,a=t*(Ri+4);switch(o){case "top-right":return {top:n,right:n-a};case "top-left":return {top:n,left:n+a};case "bottom-right":return {bottom:n,right:n-a};case "bottom-left":return {bottom:n,left:n+a}}}function ev({action:e,nodeId:t,index:r,nodeWidth:o,disabled:n,onActionClick:a}){let s=useCallback(d=>{d.stopPropagation(),d.preventDefault(),!n&&a(t,e.id,d.nativeEvent);},[n,t,e.id,a]),l=useCallback(d=>{d.stopPropagation();},[]),i=Qx(e.position,r);return jsx("button",{"data-testid":`action-${t}-${e.id}`,"data-action-id":e.id,"data-node-id":t,type:"button",className:c("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",n&&"opacity-50 cursor-not-allowed",!n&&"cursor-pointer",e.className),style:{...i,width:Ri,height:Ri,zIndex:30},onClick:s,onMouseDown:l,title:e.label,disabled:n,children:jsx("span",{className:"flex items-center justify-center w-3.5 h-3.5 [&>svg]:w-full [&>svg]:h-full",children:e.icon})})}var Yc=memo(function({node:t,registry:r,ports:o,selected:n,disabled:a,draggable:s,direction:l,onPortMouseUp:i,onActionClick:d}){let u=t.width??Yx,p=t.height??jx,b=r.render({node:t,selected:n,disabled:a}),f=(typeof r.actions=="function"?r.actions(t):r.actions)?.filter(y=>typeof y.hidden=="function"?!y.hidden(t):!y.hidden),h=new Map;if(f)for(let y of f){let C=y.position??"top-right",v=h.get(C)??[];v.push(y),h.set(C,v);}return jsxs("div",{"data-testid":`workflow-node-${t.id}`,"data-node-id":t.id,className:c("absolute select-none group/node",s&&!t.locked&&"cursor-grab active:cursor-grabbing",t.locked&&"cursor-not-allowed opacity-75",n&&"ring-2 ring-blue-500 ring-offset-1 rounded-lg"),style:{left:t.x,top:t.y,width:u,height:p,overflow:"visible"},children:[b,o.map(y=>jsx(Jx,{port:y,allPorts:o,nodeId:t.id,nodeWidth:u,nodeHeight:p,disabled:a,direction:l,onMouseUp:i},y.id)),d&&h.size>0&&Array.from(h.entries()).map(([,y])=>y.map((C,v)=>jsx(ev,{action:C,nodeId:t.id,index:v,nodeWidth:u,disabled:a,onActionClick:d},C.id)))]})});function jc(e,t,r,o,n="horizontal"){let a=r.find(i=>i.id===e);if(!a)return null;let s=o(a),l=s.find(i=>i.id===t);return l?un(a,l,s,n):null}var ov=memo(function({edge:t,fromPos:r,toPos:o,selected:n,disabled:a,direction:s,onClick:l}){let i=Za(r.x,r.y,o.x,o.y,s),d=(r.x+o.x)/2,u=(r.y+o.y)/2,p=useCallback(b=>{b.stopPropagation(),l(t.id,b);},[t.id,l]);return jsxs("g",{"data-testid":`workflow-edge-${t.id}`,children:[jsx("path",{d:i,fill:"none",stroke:"transparent",strokeWidth:16,className:"cursor-pointer",onClick:p}),jsx("path",{d:i,fill:"none",className:c("transition-colors pointer-events-none",a||t.disabled?"stroke-gray-300":n?"stroke-blue-500":"stroke-gray-400"),strokeWidth:n?2.5:2,strokeDasharray:t.disabled?"6 3":void 0}),t.label&&jsx("text",{x:d,y:u-8,textAnchor:"middle",className:"fill-gray-600 dark:fill-gray-300 text-xs pointer-events-none select-none",fontSize:11,children:t.label})]})}),Zc=memo(function({edges:t,nodes:r,selectedEdgeId:o,disabled:n,direction:a,onEdgeClick:s,getNodePorts:l}){return jsx("svg",{className:"absolute pointer-events-none",style:{top:0,left:0,width:1,height:1,overflow:"visible"},children:jsx("g",{className:"pointer-events-auto",children:t.map(i=>{let d=jc(i.from.nodeId,i.from.portId,r,l,a),u=jc(i.to.nodeId,i.to.portId,r,l,a);return !d||!u?null:jsx(ov,{edge:i,fromPos:d,toPos:u,selected:i.id===o,disabled:n,direction:a,onClick:s},i.id)})})})});var sv=()=>jsx("svg",{className:"w-4 h-4",viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true",children: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"})}),iv=()=>jsx("svg",{className:"w-4 h-4",viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true",children:jsx("path",{fillRule:"evenodd",d:"M5 10a1 1 0 011-1h8a1 1 0 110 2H6a1 1 0 01-1-1z",clipRule:"evenodd"})}),lv=()=>jsx("svg",{className:"w-4 h-4",viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true",children: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"})}),dv=()=>jsx("svg",{className:"w-4 h-4",viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true",children: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"})}),cv=()=>jsx("svg",{className:"w-4 h-4",viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true",children: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"})}),uv=()=>jsx("svg",{className:"w-4 h-4",viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true",children: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"})}),pv=()=>jsx("svg",{className:"w-4 h-4",viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true",children: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"})}),gv=()=>jsx("svg",{className:"w-4 h-4",viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true",children: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"})}),Qc=memo(function({zoom:t,direction:r,onDirectionChange:o,onZoomIn:n,onZoomOut:a,onResetView:s,onFitToContent:l,onExportJSON:i,onImportJSON:d,disabled:u,className:p}){let[b,m]=useState(false),[f,h]=useState(false),[y,C]=useState(""),[v,E]=useState(""),k=useCallback(()=>{C(i()),m(true);},[i]),R=useCallback(()=>{v.trim()&&(d(v.trim()),E(""),h(false));},[v,d]),g=useCallback(()=>{E(""),h(false);},[]),P=useCallback(()=>{m(false);},[]),T=Math.round(t*100);return jsxs(Fragment,{children:[jsxs("div",{className:c("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",p),"data-testid":"workflow-toolbar",children:[jsxs(Go,{size:"sm",children:[jsx(mt,{content:"Zoom in",size:"sm",position:"bottom",children:jsx(gt,{icon:jsx(sv,{}),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:u,"aria-label":"Zoom in"})}),jsx(mt,{content:"Zoom out",size:"sm",position:"bottom",children:jsx(gt,{icon:jsx(iv,{}),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:u,"aria-label":"Zoom out"})})]}),jsxs("span",{className:"text-xs font-mono text-gray-500 dark:text-gray-400 min-w-[3ch] text-center select-none",children:[T,"%"]}),jsx("div",{className:"w-px h-5 bg-gray-200 dark:bg-gray-600"}),jsx(mt,{content:"Reset view",size:"sm",position:"bottom",children:jsx(gt,{icon:jsx(lv,{}),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:u,"aria-label":"Reset view"})}),jsx(mt,{content:"Fit to content",size:"sm",position:"bottom",children:jsx(gt,{icon:jsx(dv,{}),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:u,"aria-label":"Fit to content"})}),o&&jsxs(Fragment,{children:[jsx("div",{className:"w-px h-5 bg-gray-200 dark:bg-gray-600"}),jsx(mt,{content:r==="horizontal"?"Switch to vertical":"Switch to horizontal",size:"sm",position:"bottom",children:jsx(gt,{icon:r==="horizontal"?jsx(pv,{}):jsx(gv,{}),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(r==="horizontal"?"vertical":"horizontal"),disabled:u,"aria-label":r==="horizontal"?"Switch to vertical":"Switch to horizontal"})})]}),jsx("div",{className:"w-px h-5 bg-gray-200 dark:bg-gray-600"}),jsx(mt,{content:"Export JSON",size:"sm",position:"bottom",children:jsx(gt,{icon:jsx(cv,{}),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:k,disabled:u,"aria-label":"Export JSON"})}),jsx(mt,{content:"Import JSON",size:"sm",position:"bottom",children:jsx(gt,{icon:jsx(uv,{}),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:()=>h(true),disabled:u,"aria-label":"Import JSON"})})]}),jsx(Yr,{isOpen:b,onClose:P,title:"Export Workflow",description:"Copy the JSON below to save your workflow.",size:"lg",showSubmit:false,showCancel:true,cancelLabel:"Close",children:jsx(Er,{label:"Workflow JSON",multiline:true,rows:12,value:y,readOnly:true,size:"sm"})}),jsx(Yr,{isOpen:f,onClose:g,title:"Import Workflow",description:"Paste workflow JSON to load it into the editor.",size:"lg",showSubmit:true,submitLabel:"Import",onSubmitClick:R,showCancel:true,cancelLabel:"Cancel",children:jsx(Er,{label:"Workflow JSON",multiline:true,rows:12,value:v,onChange:D=>E(D.target.value),placeholder:'{"nodes": [], "edges": []}',size:"sm"})})]})});var Ti={x:0,y:0,zoom:1},Pi=.1,bv=.1,hv=3,yv=20;function ru(){return `edge-${Date.now()}-${Math.random().toString(36).slice(2,8)}`}function xv({value:e,defaultValue:t,onValueChange:r,nodeRegistry:o,direction:n="horizontal",onDirectionChange:a,onNodeClick:s,onNodeDoubleClick:l,onNodeContextMenu:i,onNodeAction:d,readOnly:u=false,disabled:p=false,draggableNodes:b=true,connectable:m=true,selectable:f=true,multiSelect:h=false,panOnDrag:y=true,zoomOnWheel:C=true,minZoom:v=bv,maxZoom:E=hv,snapToGrid:k=false,gridSize:R=yv,showGrid:g=true,toolbar:P=true,autoFit:T=false,className:D},W){let V=e!==void 0,[_,M]=useState(()=>t??{nodes:[],edges:[],viewport:{...Ti}}),w=V?e:_,N=w.nodes,x=w.edges,S=w.viewport??Ti,I=useRef(null),F=useRef(null),[O,Z]=useState(new Set),[U,H]=useState(null),[z,$]=useState(null),K=useRef(S);K.current=S;let se=useRef(N);se.current=N;let X=useRef(x);X.current=x;let ee=useRef(k);ee.current=k;let L=useRef(R);L.current=R;let q=useRef(o);q.current=o;let ge=useRef(n);ge.current=n;let de=useCallback(j=>{V?r?.(j(e)):M(J=>{let me=j(J);return r?.(me),me});},[V,e,r]),Y=useRef(de);Y.current=de;let le=useCallback(j=>{de(J=>({...J,viewport:j}));},[de]),xe=useRef(le);xe.current=le;let Se=useCallback(j=>{let J=o[j.type];return J?.getPorts?J.getPorts(j):j.ports??[]},[o]),te=useRef(Se);te.current=Se;let Ne=useCallback((j,J,me)=>{let ue=se.current,Te=X.current,ve=ue.find(nt=>nt.id===j.fromNodeId),we=ue.find(nt=>nt.id===J);if(!ve||!we)return;let He=te.current(ve),Me=te.current(we),tt=He.find(nt=>nt.id===j.fromPortId),je=Me.find(nt=>nt.id===me);if(!tt||!je||je.kind!=="in"||j.fromNodeId===J)return;let $e=q.current[ve.type];if($e?.canConnect&&!$e.canConnect({fromNode:ve,toNode:we,fromPort:tt,toPort:je}))return;Te.some(nt=>nt.from.nodeId===j.fromNodeId&&nt.from.portId===j.fromPortId&&nt.to.nodeId===J&&nt.to.portId===me)||Y.current(nt=>({...nt,edges:[...nt.edges,{id:ru(),from:{nodeId:j.fromNodeId,portId:j.fromPortId},to:{nodeId:J,portId:me}}]}));},[]);useEffect(()=>{function j(me){let ue=F.current;if(!ue)return;let Te=I.current?.getBoundingClientRect();if(!Te)return;let ve=K.current;if(ue.type==="pan"){let we=me.clientX-ue.startX,He=me.clientY-ue.startY;xe.current({...ve,x:ue.startViewportX+we,y:ue.startViewportY+He});}if(ue.type==="node"){let we=cn(me.clientX,me.clientY,ve,Te),He=we.x-ue.offsetX,Me=we.y-ue.offsetY;ee.current&&(He=Ni(He,L.current),Me=Ni(Me,L.current)),Y.current(tt=>({...tt,nodes:tt.nodes.map(je=>je.id===ue.nodeId?{...je,x:He,y:Me}:je)}));}if(ue.type==="edge"){let we=cn(me.clientX,me.clientY,ve,Te);F.current={...ue,currentX:we.x,currentY:we.y},$({fromX:ue.fromX,fromY:ue.fromY,currentX:we.x,currentY:we.y});}}function J(me){let ue=F.current;if(ue){if(ue.type==="edge"){let Te=I.current?.getBoundingClientRect();if(Te){let ve=K.current,we=cn(me.clientX,me.clientY,ve,Te),He=25,Me=se.current,tt=1/0,je=null,$e=null;for(let Tt of Me){let nt=te.current(Tt);for(let nr of nt){if(nr.kind!=="in")continue;let zr=un(Tt,nr,nt,ge.current),mo=Math.sqrt((we.x-zr.x)**2+(we.y-zr.y)**2);mo<He&&mo<tt&&(tt=mo,je=Tt.id,$e=nr.id);}}je&&$e&&Ne(ue,je,$e);}$(null);}F.current=null;}}return document.addEventListener("mousemove",j),document.addEventListener("mouseup",J),()=>{document.removeEventListener("mousemove",j),document.removeEventListener("mouseup",J);}},[Ne]);let De=useCallback(j=>{if(!C||p)return;j.preventDefault();let J=I.current?.getBoundingClientRect();if(!J)return;let me=j.clientX-J.left,ue=j.clientY-J.top,Te=j.deltaY<0?1:-1,ve=Zn(S.zoom+Te*Pi,v,E),we=ve/S.zoom;le({x:me-(me-S.x)*we,y:ue-(ue-S.y)*we,zoom:ve});},[C,p,S,v,E,le]),Ve=useCallback(j=>{if(p)return;let J=j.target;if(J.closest("[data-action-id]"))return;let ue=J.closest("[data-port-id]");if(ue){if(!m||u)return;j.preventDefault();let ve=ue.getAttribute("data-node-id"),we=ue.getAttribute("data-port-id"),He=ue.getAttribute("data-port-kind");if(!ve||!we||He!=="out")return;let Me=N.find(Tt=>Tt.id===ve);if(!Me)return;let tt=Se(Me),je=tt.find(Tt=>Tt.id===we);if(!je)return;let $e=un(Me,je,tt,ge.current);F.current={type:"edge",fromNodeId:ve,fromPortId:we,fromX:$e.x,fromY:$e.y,currentX:$e.x,currentY:$e.y},$({fromX:$e.x,fromY:$e.y,currentX:$e.x,currentY:$e.y});return}let Te=J.closest("[data-node-id]");if(Te){if(u)return;let ve=Te.getAttribute("data-node-id");if(f&&(H(null),h&&j.shiftKey?Z(we=>{let He=new Set(we);return He.has(ve)?He.delete(ve):He.add(ve),He}):Z(new Set([ve]))),b){let we=I.current?.getBoundingClientRect();if(!we)return;let He=N.find(tt=>tt.id===ve);if(!He||He.locked)return;let Me=cn(j.clientX,j.clientY,S,we);F.current={type:"node",nodeId:ve,startX:Me.x,startY:Me.y,offsetX:Me.x-He.x,offsetY:Me.y-He.y};}return}f&&(Z(new Set),H(null)),y&&j.button===0&&(F.current={type:"pan",startX:j.clientX,startY:j.clientY,startViewportX:S.x,startViewportY:S.y});},[p,m,u,f,h,b,y,S,N,Se]),rt=useCallback(j=>{let J=F.current;if(!J||J.type!=="edge")return;let me=I.current?.getBoundingClientRect();if(me){let ue=cn(j.clientX,j.clientY,S,me),Te=30,ve=1/0,we=null,He=null;for(let Me of N){let tt=Se(Me);for(let je of tt){if(je.kind!=="in")continue;let $e=un(Me,je,tt,ge.current),Tt=Math.sqrt((ue.x-$e.x)**2+(ue.y-$e.y)**2);Tt<Te&&Tt<ve&&(ve=Tt,we=Me.id,He=je.id);}}if(we&&He){let Me=J.fromNodeId,tt=J.fromPortId;Me!==we&&(x.some($e=>$e.from.nodeId===Me&&$e.from.portId===tt&&$e.to.nodeId===we&&$e.to.portId===He)||de($e=>({...$e,edges:[...$e.edges,{id:ru(),from:{nodeId:Me,portId:tt},to:{nodeId:we,portId:He}}]})));}}F.current=null,$(null);},[S,N,x,Se,de]),dt=useCallback((j,J)=>{let me=F.current;!me||me.type!=="edge"||(Ne(me,j,J),F.current=null,$(null));},[Ne]),re=useCallback(j=>{let J=j.target;if(J.closest("[data-port-id]")||J.closest("[data-action-id]"))return null;let Te=J.closest("[data-node-id]");if(!Te)return null;let ve=Te.getAttribute("data-node-id");return N.find(we=>we.id===ve)??null},[N]),pe=useCallback(j=>{if(!s||p)return;let J=re(j);J&&s({node:J,nativeEvent:j.nativeEvent});},[s,p,re]),Ue=useCallback(j=>{if(!l||p)return;let J=re(j);J&&l({node:J,nativeEvent:j.nativeEvent});},[l,p,re]),yt=useCallback(j=>{if(!i||p)return;let J=re(j);J&&(j.preventDefault(),i({node:J,nativeEvent:j.nativeEvent}));},[i,p,re]),Re=useCallback((j,J,me)=>{if(!d||p)return;let ue=N.find(Te=>Te.id===j);ue&&d({node:ue,actionId:J,nativeEvent:me});},[d,p,N]),We=useCallback((j,J)=>{!f||p||(J.stopPropagation(),Z(new Set),H(j));},[f,p]),ft=useCallback(j=>{u||p||((j.key==="Delete"||j.key==="Backspace")&&(O.size>0&&(de(J=>({...J,nodes:J.nodes.filter(me=>!O.has(me.id)),edges:J.edges.filter(me=>!O.has(me.from.nodeId)&&!O.has(me.to.nodeId))})),Z(new Set)),U&&(de(J=>({...J,edges:J.edges.filter(me=>me.id!==U)})),H(null))),j.key==="Escape"&&(Z(new Set),H(null)));},[u,p,O,U,de]),rr=useCallback(()=>{let j=Zn(S.zoom+Pi,v,E);le({...S,zoom:j});},[S,v,E,le]),ot=useCallback(()=>{let j=Zn(S.zoom-Pi,v,E);le({...S,zoom:j});},[S,v,E,le]),Wt=useCallback(()=>{le({...Ti});},[le]),Nt=useCallback(()=>{let j=I.current?.getBoundingClientRect();if(!j)return;let J=Uc(N,j.width,j.height),me=Zn(J.zoom,v,E);le({...J,zoom:me});},[N,v,E,le]),Ht=useCallback(j=>{de(J=>({...J,nodes:[...J.nodes,j]}));},[de]),or=useCallback(j=>{de(J=>({...J,nodes:J.nodes.filter(me=>me.id!==j),edges:J.edges.filter(me=>me.from.nodeId!==j&&me.to.nodeId!==j)}));},[de]),Zt=useCallback(()=>JSON.stringify(w,null,2),[w]),Ar=useCallback(j=>{try{let J=JSON.parse(j);J&&Array.isArray(J.nodes)&&Array.isArray(J.edges)&&de(()=>J);}catch{}},[de]);useImperativeHandle(W,()=>({zoomIn:rr,zoomOut:ot,resetView:Wt,fitToContent:Nt,addNode:Ht,removeNode:or,toJSON:Zt,loadJSON:Ar}),[rr,ot,Wt,Nt,Ht,or,Zt,Ar]);let br=useRef(false);useEffect(()=>{T&&!br.current&&I.current&&(br.current=true,Nt());},[T,Nt]);let fe=useMemo(()=>{let j=new Map;for(let J of N)j.set(J.id,Se(J));return j},[N,Se]),he=useMemo(()=>({transform:`translate(${S.x}px, ${S.y}px) scale(${S.zoom})`,transformOrigin:"0 0"}),[S.x,S.y,S.zoom]);return jsxs("div",{ref:I,"data-testid":"workflow-editor",className:c("relative w-full overflow-hidden bg-gray-50 dark:bg-gray-900 select-none",p&&"opacity-60 pointer-events-none",D),tabIndex:0,onWheel:De,onMouseDown:Ve,onMouseUp:rt,onClick:pe,onDoubleClick:Ue,onContextMenu:yt,onKeyDown:ft,children:[g&&jsx(Kc,{gridSize:R,zoom:S.zoom}),P&&!u&&jsx(Qc,{zoom:S.zoom,direction:n,onDirectionChange:a,onZoomIn:rr,onZoomOut:ot,onResetView:Wt,onFitToContent:Nt,onExportJSON:Zt,onImportJSON:Ar,disabled:p}),jsxs("div",{style:he,children:[jsx(Zc,{edges:x,nodes:N,selectedEdgeId:U,disabled:p||u,direction:n,onEdgeClick:We,getNodePorts:j=>fe.get(j.id)??[]}),N.map(j=>{let J=o[j.type];if(!J)return null;let me=fe.get(j.id)??[];return jsx(Yc,{node:j,registry:J,ports:me,selected:O.has(j.id),disabled:p||u,draggable:b&&!u,direction:n,onPortMouseUp:dt,onActionClick:d?Re:void 0},j.id)})]}),z&&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:[jsx("path",{d:Za(z.fromX*S.zoom+S.x,z.fromY*S.zoom+S.y,z.currentX*S.zoom+S.x,z.currentY*S.zoom+S.y,n),fill:"none",stroke:"#3b82f6",strokeWidth:2.5,strokeDasharray:"8 4"}),jsx("circle",{cx:z.fromX*S.zoom+S.x,cy:z.fromY*S.zoom+S.y,r:5,fill:"#3b82f6"}),jsx("circle",{cx:z.currentX*S.zoom+S.x,cy:z.currentY*S.zoom+S.y,r:4,fill:"#3b82f6",opacity:.6})]})]})}var ou=forwardRef(xv);ou.displayName="WorkflowEditor";var iu=createContext(null);function go(){let e=useContext(iu);if(!e)throw new Error("useWizard and Wizard sub-components must be used within <Wizard>");return e}var Di=(e,t,r)=>Math.max(t,Math.min(e,r)),Ii={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"}},Lr={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 wv({className:e}){return jsx("svg",{className:e,viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true",children: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 lu({steps:e,step:t,defaultStep:r=0,onStepChange:o,onComplete:n,orientation:a="horizontal",variant:s="default",size:l="md",color:i="primary",linear:d=true,className:u,children:p}){let b=e.length,m=Math.max(0,b-1),f=t!==void 0,[h,y]=useState(()=>Di(r,0,m)),C=Di(f?t:h,0,m),[v,E]=useState(C);v<C&&E(C);let k=C<=0,R=C>=m,g=useCallback((M,w)=>{let N=Di(M,0,m);N!==C&&(f||y(N),E(x=>Math.max(x,N)),o?.(N,{previous:C,direction:w}));},[C,f,m,o]),P=useCallback(M=>{let w=e[M];return !w||w.disabled?false:d?M<=v:true},[e,d,v]),T=useCallback(M=>{P(M)&&g(M,M>C?"jump":"backward");},[P,g,C]),D=useCallback(()=>{if(R){n?.();return}g(C+1,"forward");},[R,n,g,C]),W=useCallback(()=>{k||g(C-1,"backward");},[k,g,C]),V=useCallback(M=>e[M]?.error?"error":M===C?"active":M<C?"completed":"upcoming",[e,C]),_={steps:e,activeStep:C,totalSteps:b,isFirstStep:k,isLastStep:R,orientation:a,variant:s,size:l,color:i,linear:d,goToStep:T,goNext:D,goBack:W,getStepStatus:V,isStepAccessible:P};return jsx(iu.Provider,{value:_,children:jsx("div",{className:c("flex w-full flex-col gap-6",u),"data-testid":"wizard","data-orientation":a,children:p})})}function au({index:e,status:t}){let{variant:r,size:o,color:n,steps:a}=go(),s=Ii[o],l=a[e];if(r==="dots"){let u=t==="upcoming"?"bg-gray-300 dark:bg-gray-600":t==="error"?"bg-red-600":Lr[n].bg;return jsx("span",{className:c("shrink-0 rounded-full transition-colors",s.dot,u),"aria-hidden":"true"})}let i=t==="completed"?c(Lr[n].solid,"border-transparent"):t==="active"?c(Lr[n].solid,"border-transparent ring-4",Lr[n].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",d=t==="completed"?jsx(wv,{className:s.icon}):t==="error"?jsx("span",{className:"font-semibold leading-none",children:"!"}):l.icon??jsx("span",{className:"font-medium leading-none",children:e+1});return jsx("span",{className:c("flex shrink-0 items-center justify-center rounded-full transition-all",s.circle,i),"aria-hidden":"true",children:d})}function su({index:e,status:t}){let{steps:r,size:o,color:n,variant:a}=go(),s=Ii[o],l=r[e],d=t==="active"?Lr[n].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 jsxs("span",{className:"flex min-w-0 flex-col",children:[jsxs("span",{className:c("font-medium leading-tight",s.title,d),children:[a==="simple"&&jsxs("span",{className:"mr-1 tabular-nums",children:[e+1,"."]}),l.title,l.optional&&jsx("span",{className:"ml-1 text-xs font-normal text-gray-400 dark:text-gray-500",children:"(optional)"})]}),l.description&&jsx("span",{className:c("mt-0.5 text-gray-400 dark:text-gray-500",s.desc),children:l.description})]})}function du({className:e,hideConnector:t=false,hideLabels:r=false}){let o=go(),{steps:n,orientation:a,size:s,variant:l,color:i,activeStep:d}=o,u=Ii[s],p=a==="vertical",b=l!=="simple";return jsx("ol",{className:c("flex w-full",p?"flex-col":"items-start",e),"data-testid":"wizard-steps","data-orientation":a,children:n.map((m,f)=>{let h=o.getStepStatus(f),y=f===d,C=o.isStepAccessible(f)&&!y,v=f===n.length-1,k=f<d?Lr[i].bg:"bg-gray-200 dark:bg-gray-700";return p?jsx("li",{className:"flex","aria-current":y?"step":void 0,"data-status":h,"data-testid":"wizard-step",children:jsxs("button",{type:"button",disabled:!C,onClick:()=>o.goToStep(f),className:c("flex items-stretch gap-3 rounded-md text-left focus:outline-none focus-visible:ring-2 focus-visible:ring-offset-2",Lr[i].ring,C?"cursor-pointer":"cursor-default"),children:[jsxs("span",{className:"flex flex-col items-center",children:[b&&jsx(au,{index:f,status:h}),!t&&!v&&jsx("span",{className:c("my-1 w-0.5 flex-1 rounded",k),"aria-hidden":"true"})]}),!r&&jsx("span",{className:c(v?"pb-0":"pb-6"),children:jsx(su,{index:f,status:h})})]})},m.id??f):jsxs("li",{className:c("flex items-center",!v&&"flex-1"),"aria-current":y?"step":void 0,"data-status":h,"data-testid":"wizard-step",children:[jsxs("button",{type:"button",disabled:!C,onClick:()=>o.goToStep(f),className:c("flex items-center gap-2.5 rounded-md focus:outline-none focus-visible:ring-2 focus-visible:ring-offset-2",Lr[i].ring,C?"cursor-pointer":"cursor-default"),children:[b&&jsx(au,{index:f,status:h}),!r&&jsx(su,{index:f,status:h})]}),!t&&!v&&jsx("span",{className:c("mx-2 flex-1 rounded",u.connector,k),"aria-hidden":"true"})]},m.id??f)})})}function cu({index:e,keepMounted:t=false,className:r,children:o}){let{activeStep:n}=go(),a=e===n;return !a&&!t?null:jsx("div",{role:"tabpanel",hidden:!a,"data-testid":"wizard-panel","data-active":a,"data-step":e,className:c("w-full",r),children:o})}function uu({className:e,children:t}){let r=go();return jsx("div",{className:c("w-full",e),"data-testid":"wizard-content",children:typeof t=="function"?t(r):t})}var pu="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 Mi({children:e,label:t="Previous",className:r,onClick:o,disabled:n,...a}){let{goBack:s,isFirstStep:l}=go();return jsx("button",{type:"button",onClick:d=>{o?.(d),d.defaultPrevented||s();},disabled:n??l,"data-testid":"wizard-previous",className:c(pu,"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 Li({children:e,label:t="Next",finishLabel:r="Finish",className:o,onClick:n,...a}){let{goNext:s,isLastStep:l,color:i}=go();return jsx("button",{type:"button",onClick:u=>{n?.(u),u.defaultPrevented||s();},"data-testid":"wizard-next",className:c(pu,Lr[i].solid,Lr[i].ring,"hover:opacity-90",o),...a,children:e??(l?r:t)})}function gu({className:e,children:t,align:r="between"}){let o={between:"justify-between",start:"justify-start",center:"justify-center",end:"justify-end"}[r];return jsx("div",{className:c("flex items-center gap-3",o,e),"data-testid":"wizard-actions",children:t??jsxs(Fragment,{children:[jsx(Mi,{}),jsx(Li,{})]})})}lu.displayName="Wizard";du.displayName="WizardSteps";cu.displayName="WizardPanel";uu.displayName="WizardContent";gu.displayName="WizardActions";Mi.displayName="WizardPrevious";Li.displayName="WizardNext";export{zu as Accordion,Fu as AccordionContent,Wu as AccordionItem,Hu as AccordionTrigger,Ki as AdvanceDetachable,$0 as AreaChart,K0 as Avatar,ml as Badge,hl as Banner,ap as BarChart,hp as Breadcrumb,gt as Button,Go as ButtonGroup,ia as CHART_ALL_PAIRS_LIMIT,xn as CHART_MUTED_COLOR,E0 as CHART_PALETTE_SIZE,sa as CHART_SERIES_COLORS,Wp as Calendar,wl as Card,Sl as CardBody,El as CardDescription,Rl as CardFooter,Nl as CardHeader,Tl as CardImage,Pl as CardTitle,Ut as ChartAxis,lr as ChartContainer,Wr as ChartGrid,dr as ChartLegend,cr as ChartTableView,ur as ChartTooltip,pr as ChartTooltipContent,Rn as Checkbox,Il as CheckboxGroup,Ml as CheckboxGroupItem,ka as Chip,Ho as CircularProgress,Ji as DEFAULT_CHART_WIDTH,jn as DEFAULT_FIELD_TYPES,Dg as DataGrid,Wl as Detachable,dm as DeviceMockup,Fl as Divider,ql as Drawer,nd as Dropdown,yd as DropdownCheckboxItem,cd as DropdownContent,pd as DropdownItem,md as DropdownLabel,wd as DropdownRadioGroup,Cd as DropdownRadioItem,gd as DropdownSeparator,Ed as DropdownSubMenu,Id as DropdownSubMenuContent,Dd as DropdownSubMenuTrigger,sd as DropdownTrigger,Gl as FOCUSABLE_SELECTOR,zm as FileSelector,bc as Footer,vc as FooterBottom,yc as FooterColumn,xc as FooterLink,hc as FooterSection,kc as FooterSocial,wc as FooterSocialLink,$f as Header,Wd as HelpButton,Bl as INERT_IGNORE_ATTRIBUTE,cb as ImageUploader,Fd as Indicator,Er as Input,$d as Label,Rb as LineChart,Gs as MentionInput,Yr as Modal,Xs as NumberInput,Ob as Pagination,qb as PieChart,Yd as ProgressBar,jd as RadioButton,Jy as ScatterChart,Gc as SchemaEditor,vh as Select,Th as Sidebar,Eh as SidebarContent,Dh as SidebarFooter,Ih as SidebarGroup,Ph as SidebarHeader,Mh as SidebarItem,Lh as SidebarSubMenu,Ah as SidebarToggle,tc as Skeleton,oc as Slider,oi as Sparkline,$h as StatCard,Gh as StatCardGroup,gs as Table,ms as TableBody,na as TableCell,fs as TableHeader,aa as TableHeaderCell,bs as TableRow,ac as Tabs,cc as TabsContent,sc as TabsList,dc as TabsTrigger,gc as Toast,mt as Tooltip,s0 as UILabelsProvider,ob as WithHelpButton,lu as Wizard,gu as WizardActions,uu as WizardContent,Li as WizardNext,cu as WizardPanel,Mi as WizardPrevious,du as WizardSteps,ou as WorkflowEditor,vi as autoLayoutTables,c as cn,gi as createDefaultField,mi as createDefaultTable,qi as defaultUILabels,Na as findOwnedLayers,a0 as frenchUILabels,Yn as generateFieldId,pi as generateRelationId,ja as generateSQL,Dc as generateTableId,Sa as getFocusableElements,la as getSeriesColor,Lt as getSeriesLabel,As as hideOthers,Xl as isElementVisible,Kl as isFocusable,No as registerFloatingLayer,Cr as resolveSeriesColor,Hr as toLegendItems,ps as useChartSize,jo as useClickOutside,So as useDialogA11y,Yt as useDropdownContext,ld as useFocusItem,Pa as useKeyboardNavigation,qo as usePositioning,Ch as useSidebar,Ft as useUILabels,go as useWizard};
31
+ `)}var Bk=60,Fk=40;function zl(e,t){if(e.length===0)return e;let r=new Map;for(let p of e){let C=new Set;for(let v of p.fields)v.foreignKey&&C.add(v.foreignKey.tableId);r.set(p.id,C);}let n=new Map;for(let p of e)n.set(p.id,0);for(let[,p]of r)for(let C of p)n.has(C);for(let[p,C]of r)n.set(p,C.size);let o=[],a=[];for(let[p,C]of n)C===0&&a.push(p);for(;a.length>0;){let p=a.shift();o.push(p);for(let[C,v]of r)if(v.has(p)){let k=(n.get(C)??0)-1;n.set(C,k),k===0&&a.push(C);}}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,b=0,m=[];for(let p of o){let C=l.get(p);if(!C)continue;let v=C.width??260,k=Fn(C,t);m.push({...C,x:c,y:d}),b=Math.max(b,k),u++,u>=i?(u=0,c=0,d+=b+Fk,b=0):c+=v+Bk;}return m}var Hl={x:0,y:0,zoom:1},Vl=.1,Xk=.1,Gk=3,Kk=20,Uk=50;function Yk({value:e,defaultValue:t,onValueChange:r,fieldTypes:n=Xa,onTableClick:o,onTableDoubleClick:a,onTableContextMenu:s,onFieldClick:l,onFieldDoubleClick:i,readOnly:c=false,disabled:d=false,draggableTables:u=true,panOnDrag:b=true,zoomOnWheel:m=true,editable:p=true,minZoom:C=Xk,maxZoom:v=Gk,snapToGrid:k=false,gridSize:y=Kk,showGrid:z=true,toolbar:h=true,legend:R=true,autoFit:f=false,className:N},L){let E=e!==void 0,[I,w]=useState(()=>t??{tables:[],relations:[],viewport:{...Hl}}),W=E?e:I,M=W.tables,T=W.relations,P=W.viewport??Hl,x=useRef(null),D=useRef(null),[S,B]=useState(null),[H,$]=useState(null),[_,F]=useState(null),[A,V]=useState(null),[Y,X]=useState({width:0,height:0}),G=useRef([]),j=useRef(-1),O=useRef(false),K=useRef(P);K.current=P;let se=useRef(M);se.current=M;let ae=useRef(T);ae.current=T;let U=useRef(k);U.current=k;let J=useRef(y);J.current=y;let te=useRef(p);te.current=p;let ie=useCallback(Z=>{if(O.current)return;let oe=G.current,le=j.current;G.current=oe.slice(0,le+1),G.current.push(Z),G.current.length>Uk&&G.current.shift(),j.current=G.current.length-1;},[]),Q=useCallback(Z=>{if(E){let oe=Z(e);ie(oe),r?.(oe);}else w(oe=>{let le=Z(oe);return ie(le),r?.(le),le});},[E,e,r,ie]),ge=useRef(Q);ge.current=Q;let Re=useCallback(Z=>{Q(oe=>({...oe,viewport:Z}));},[Q]),Qe=useRef(Re);Qe.current=Re,useEffect(()=>{function Z(de){let be=D.current;if(!be)return;let $e=x.current?.getBoundingClientRect();if(!$e)return;let nt=K.current;if(be.type==="pan"){let qe=de.clientX-be.startX,ze=de.clientY-be.startY;Qe.current({...nt,x:be.startVpX+qe,y:be.startVpY+ze});}if(be.type==="table"){let qe=$a(de.clientX,de.clientY,nt,$e),ze=qe.x-be.offsetX,tr=qe.y-be.offsetY;U.current&&(ze=Rl(ze,J.current),tr=Rl(tr,J.current)),ge.current(je=>({...je,tables:je.tables.map(Lt=>Lt.id===be.tableId?{...Lt,x:ze,y:tr}:Lt)}));}if(be.type==="relation"){let qe=$a(de.clientX,de.clientY,nt,$e);D.current={...be,currentX:qe.x,currentY:qe.y},F({fromX:be.fromX,fromY:be.fromY,currentX:qe.x,currentY:qe.y});}if(be.type==="resize"){let qe=(de.clientX-be.startX)/nt.zoom,ze=(de.clientY-be.startY)/nt.zoom,tr=180,je=80,Lt=Math.max(tr,be.startWidth+qe),Ft=Math.max(je,be.startHeight+ze);ge.current(kt=>({...kt,tables:kt.tables.map(sr=>sr.id===be.tableId?{...sr,width:Lt,height:Ft}:sr)}));}}function oe(de,be,$e,nt){let qe=K.current,ze=$a(de,be,qe,$e),tr=1/0,je=null,Lt=null;for(let Ft of nt){if(Ft.collapsed)continue;let kt=Ft.fields.length;if(kt===0)continue;let sr=Ft.width??260,Yr=40+kt*32+(te.current?36:0),qr=40;if(!(ze.x<Ft.x-qr||ze.x>Ft.x+sr+qr||ze.y<Ft.y-qr||ze.y>Ft.y+Yr+qr))for(let xr=0;xr<Ft.fields.length;xr++){let ti=Ft.y+Uo(xr,!!Ft.notes),Ya=Math.abs(ze.y-ti);Ya<tr&&(tr=Ya,je=Ft.id,Lt=Ft.fields[xr].id);}}return je&&Lt?{tableId:je,fieldId:Lt}:null}function le(de){let be=D.current;if(be){if(be.type==="relation"){let $e=x.current?.getBoundingClientRect();if($e){let nt=ae.current,qe=se.current,ze=oe(de.clientX,de.clientY,$e,qe);if(ze&&ze.tableId!==be.fromTableId&&!nt.some(je=>je.from.tableId===be.fromTableId&&je.from.fieldId===be.fromFieldId&&je.to.tableId===ze.tableId&&je.to.fieldId===ze.fieldId)){let je=be.fromTableId,Lt=be.fromFieldId,Ft=ze.tableId,kt=ze.fieldId;ge.current(sr=>({...sr,tables:sr.tables.map(Yr=>Yr.id===Ft?{...Yr,fields:Yr.fields.map(qr=>qr.id===kt?{...qr,foreignKey:{tableId:je,fieldId:Lt}}:qr)}:Yr),relations:[...sr.relations,{id:Tl(),from:{tableId:je,fieldId:Lt},to:{tableId:Ft,fieldId:kt},cardinality:"1:n"}]}));}}F(null),V(null);}D.current=null;}}return document.addEventListener("mousemove",Z),document.addEventListener("mouseup",le),()=>{document.removeEventListener("mousemove",Z),document.removeEventListener("mouseup",le);}},[]);let at=useCallback(Z=>{if(!m||d)return;Z.preventDefault();let oe=x.current?.getBoundingClientRect();if(!oe)return;let le=Z.clientX-oe.left,de=Z.clientY-oe.top,be=Z.deltaY<0?1:-1,$e=Oa(P.zoom+be*Vl,C,v),nt=$e/P.zoom;Re({x:le-(le-P.x)*nt,y:de-(de-P.y)*nt,zoom:$e});},[m,d,P,C,v,Re]),et=useCallback(Z=>{if(d)return;let oe=Z.target,le=oe.tagName,de=le==="INPUT"||le==="SELECT"||le==="TEXTAREA"||le==="BUTTON";if(oe.closest("[data-resize-handle]"))return;let be=oe.closest("[data-connection-side]");if(be&&!de){if(c)return;Z.preventDefault();let nt=be.getAttribute("data-table-id"),qe=be.getAttribute("data-field-id");if(!nt||!qe)return;let ze=M.find(Lt=>Lt.id===nt);if(!ze)return;let tr=be.getAttribute("data-connection-side"),je=am(ze,qe,tr);if(!je)return;D.current={type:"relation",fromTableId:nt,fromFieldId:qe,fromX:je.x,fromY:je.y,currentX:je.x,currentY:je.y},F({fromX:je.x,fromY:je.y,currentX:je.x,currentY:je.y}),V(nt);return}let $e=oe.closest("[data-table-id]");if($e){if(c)return;let nt=$e.getAttribute("data-table-id");if($(null),B(nt),de)return;if(u){let qe=x.current?.getBoundingClientRect();if(!qe)return;let ze=M.find(je=>je.id===nt);if(!ze||ze.locked)return;let tr=$a(Z.clientX,Z.clientY,P,qe);D.current={type:"table",tableId:nt,offsetX:tr.x-ze.x,offsetY:tr.y-ze.y};}return}B(null),$(null),b&&Z.button===0&&(D.current={type:"pan",startX:Z.clientX,startY:Z.clientY,startVpX:P.x,startVpY:P.y});},[d,c,u,b,P,M]),me=useCallback(Z=>{let oe=Z.target;if(oe.closest("[data-connection-side]"))return null;let le=oe.closest("[data-table-id]");if(!le)return null;let de=le.getAttribute("data-table-id");return M.find(be=>be.id===de)??null},[M]),ce=useCallback(Z=>{if(d)return;let oe=me(Z);oe&&o&&o({table:oe,nativeEvent:Z.nativeEvent});},[o,d,me]),Oe=useCallback(Z=>{if(d)return;let oe=me(Z);oe&&a&&a({table:oe,nativeEvent:Z.nativeEvent});},[a,d,me]),st=useCallback(Z=>{if(d)return;let oe=me(Z);oe&&s&&(Z.preventDefault(),s({table:oe,nativeEvent:Z.nativeEvent}));},[s,d,me]),Pe=useCallback((Z,oe)=>{d||(oe.stopPropagation(),B(null),$(Z));},[d]),De=useCallback((Z,oe)=>{Q(le=>({...le,relations:le.relations.map(de=>de.id===Z?{...de,cardinality:oe}:de)}));},[Q]),it=j.current>0,xt=j.current<G.current.length-1,lt=useCallback(()=>{if(j.current<=0)return;O.current=true,j.current--;let Z=G.current[j.current];E||w(Z),r?.(Z),O.current=false;},[E,r]),pr=useCallback(()=>{if(j.current>=G.current.length-1)return;O.current=true,j.current++;let Z=G.current[j.current];E||w(Z),r?.(Z),O.current=false;},[E,r]),tt=useCallback(()=>Ys(W),[W]),yr=useCallback(()=>{Q(Z=>({...Z,tables:zl(Z.tables,p)}));},[Q,p]),Wr=useCallback((Z,oe,le)=>{oe!==le&&Q(de=>({...de,tables:de.tables.map(be=>{if(be.id!==Z)return be;let $e=[...be.fields],[nt]=$e.splice(oe,1);return $e.splice(le,0,nt),{...be,fields:$e}})}));},[Q]);useEffect(()=>{let Z=x.current;if(!Z)return;let oe=new ResizeObserver(le=>{for(let de of le)X({width:de.contentRect.width,height:de.contentRect.height});});return oe.observe(Z),()=>oe.disconnect()},[]);let Bt=useRef(false);Bt.current||(Bt.current=true,G.current=[W],j.current=0);let ar=useCallback(Z=>{if(!(c||d)){if((Z.ctrlKey||Z.metaKey)&&Z.key==="z"&&!Z.shiftKey){Z.preventDefault(),lt();return}if((Z.ctrlKey||Z.metaKey)&&(Z.key==="y"||Z.key==="z"&&Z.shiftKey)){Z.preventDefault(),pr();return}if(Z.key==="Delete"||Z.key==="Backspace"){let oe=Z.target;if(oe.tagName==="INPUT"||oe.tagName==="TEXTAREA"||oe.tagName==="SELECT")return;S&&(Q(le=>({...le,tables:le.tables.filter(de=>de.id!==S),relations:le.relations.filter(de=>de.from.tableId!==S&&de.to.tableId!==S)})),B(null)),H&&(Q(le=>{let de=le.relations.find(be=>be.id===H);return {...le,tables:de?le.tables.map(be=>be.id===de.to.tableId?{...be,fields:be.fields.map($e=>$e.id===de.to.fieldId?{...$e,foreignKey:void 0}:$e)}:be):le.tables,relations:le.relations.filter(be=>be.id!==H)}}),$(null));}Z.key==="Escape"&&(B(null),$(null));}},[c,d,S,H,Q,lt,pr]),Rr=useCallback((Z,oe)=>{Q(le=>({...le,tables:le.tables.map(de=>de.id===Z?{...de,name:oe}:de)}));},[Q]),ye=useCallback((Z,oe)=>{Q(le=>({...le,tables:le.tables.map(de=>de.id===Z?{...de,notes:oe}:de)}));},[Q]),xe=useCallback(Z=>{Q(oe=>({...oe,tables:oe.tables.map(le=>le.id===Z?{...le,collapsed:!le.collapsed}:le)}));},[Q]),re=useCallback((Z,oe,le)=>{Q(de=>({...de,tables:de.tables.map(be=>be.id===Z?{...be,fields:be.fields.map($e=>$e.id===oe?{...$e,...le}:$e)}:be)}));},[Q]),ne=useCallback(Z=>{Q(oe=>({...oe,tables:oe.tables.map(le=>le.id===Z?{...le,fields:[...le.fields,Pl()]}:le)}));},[Q]),he=useCallback((Z,oe)=>{Q(le=>({...le,tables:le.tables.map(de=>de.id===Z?{...de,fields:de.fields.filter(be=>be.id!==oe)}:de),relations:le.relations.filter(de=>!(de.from.tableId===Z&&de.from.fieldId===oe)&&!(de.to.tableId===Z&&de.to.fieldId===oe))}));},[Q]),fe=useCallback((Z,oe,le,de,be)=>{D.current={type:"resize",tableId:Z,startX:oe,startY:le,startWidth:de,startHeight:be};},[]),Te=useCallback(()=>{let Z=Oa(P.zoom+Vl,C,v);Re({...P,zoom:Z});},[P,C,v,Re]),Ce=useCallback(()=>{let Z=Oa(P.zoom-Vl,C,v);Re({...P,zoom:Z});},[P,C,v,Re]),we=useCallback(()=>{Re({...Hl});},[Re]),Me=useCallback(()=>{let Z=x.current?.getBoundingClientRect();if(!Z)return;let oe=sm(M,Z.width,Z.height,p),le=Oa(oe.zoom,C,v);Re({...oe,zoom:le});},[M,p,C,v,Re]),Ae=useCallback(Z=>{Q(oe=>({...oe,tables:[...oe.tables,Z]}));},[Q]),bt=useCallback(Z=>{Q(oe=>({...oe,tables:oe.tables.filter(le=>le.id!==Z),relations:oe.relations.filter(le=>le.from.tableId!==Z&&le.to.tableId!==Z)}));},[Q]),ct=useCallback((Z,oe)=>{Q(le=>({...le,tables:le.tables.map(de=>de.id===Z?{...de,fields:[...de.fields,oe]}:de)}));},[Q]),Ye=useCallback((Z,oe)=>{he(Z,oe);},[he]),er=useCallback(Z=>{Q(oe=>({...oe,tables:oe.tables.map(le=>le.id===Z.to.tableId?{...le,fields:le.fields.map(de=>de.id===Z.to.fieldId?{...de,foreignKey:{tableId:Z.from.tableId,fieldId:Z.from.fieldId}}:de)}:le),relations:[...oe.relations,Z]}));},[Q]),vt=useCallback(Z=>{Q(oe=>{let le=oe.relations.find(de=>de.id===Z);return {...oe,tables:le?oe.tables.map(de=>de.id===le.to.tableId?{...de,fields:de.fields.map(be=>be.id===le.to.fieldId?{...be,foreignKey:void 0}:be)}:de):oe.tables,relations:oe.relations.filter(de=>de.id!==Z)}});},[Q]),Hr=useCallback(()=>JSON.stringify(W,null,2),[W]),mn=useCallback(Z=>{try{let oe=JSON.parse(Z);oe&&Array.isArray(oe.tables)&&Array.isArray(oe.relations)&&Q(()=>oe);}catch{}},[Q]),Kn=useCallback(()=>{let Z=x.current?.getBoundingClientRect(),oe=K.current,le=100,de=100;Z&&(le=(Z.width/2-oe.x)/oe.zoom-260/2,de=(Z.height/2-oe.y)/oe.zoom-60),Ae(El(le,de));},[Ae]),bo=useCallback(()=>Ys(W),[W]);useImperativeHandle(L,()=>({zoomIn:Te,zoomOut:Ce,resetView:we,fitToContent:Me,addTable:Ae,removeTable:bt,addField:ct,removeField:Ye,addRelation:er,removeRelation:vt,toJSON:Hr,loadJSON:mn,toSQL:bo}),[Te,Ce,we,Me,Ae,bt,ct,Ye,er,vt,Hr,mn,bo]);let Ur=useRef(false);useEffect(()=>{f&&!Ur.current&&x.current&&(Ur.current=true,Me());},[f,Me]);let Vr=useMemo(()=>({transform:`translate(${P.x}px, ${P.y}px) scale(${P.zoom})`,transformOrigin:"0 0"}),[P.x,P.y,P.zoom]);return jsxs("div",{ref:x,"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",N),tabIndex:0,onWheel:at,onMouseDown:et,onClick:ce,onDoubleClick:Oe,onContextMenu:st,onKeyDown:ar,children:[z&&jsx(om,{gridSize:y,zoom:P.zoom}),h&&!c&&jsx(bm,{zoom:P.zoom,onZoomIn:Te,onZoomOut:Ce,onResetView:we,onFitToContent:Me,onAddTable:Kn,onExportJSON:Hr,onImportJSON:mn,onExportSQL:tt,onUndo:lt,onRedo:pr,canUndo:it,canRedo:xt,onAutoLayout:yr,disabled:d}),R&&jsx(hm,{}),jsx(fm,{relations:T,tables:M,viewport:P,selectedRelationId:H,disabled:d||c,onRelationClick:Pe,onCardinalityChange:De}),jsx("div",{style:Vr,children:M.map(Z=>jsx(gm,{table:Z,selected:S===Z.id,disabled:d||c,readOnly:c,editable:p,dropTarget:A!==null&&A!==Z.id&&!Z.collapsed,fieldTypes:n,onTableNameChange:Rr,onTableNotesChange:ye,onToggleCollapse:xe,onFieldChange:re,onFieldAdd:ne,onFieldRemove:he,onFieldReorder:Wr,onResizeStart:fe},Z.id))}),_&&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:[jsx("path",{d:_s(_.fromX*P.zoom+P.x,_.fromY*P.zoom+P.y,_.currentX*P.zoom+P.x,_.currentY*P.zoom+P.y),fill:"none",stroke:"#3b82f6",strokeWidth:2.5,strokeDasharray:"8 4"}),jsx("circle",{cx:_.fromX*P.zoom+P.x,cy:_.fromY*P.zoom+P.y,r:5,fill:"#3b82f6"}),jsx("circle",{cx:_.currentX*P.zoom+P.x,cy:_.currentY*P.zoom+P.y,r:4,fill:"#3b82f6",opacity:.6})]}),R&&Y.width>0&&jsx(ym,{tables:M,viewport:P,containerWidth:Y.width,containerHeight:Y.height,editable:p,onViewportChange:Re})]})}var km=forwardRef(Yk);km.displayName="SchemaEditor";var Cm="wf-grid-pattern",wm=memo(function({gridSize:t,zoom:r}){let n=t*r;return jsxs("svg",{className:"absolute inset-0 w-full h-full pointer-events-none","aria-hidden":"true",children:[jsx("defs",{children:jsx("pattern",{id:Cm,width:n,height:n,patternUnits:"userSpaceOnUse",children:jsx("circle",{cx:1,cy:1,r:1,className:"fill-gray-300 dark:fill-gray-600"})})}),jsx("rect",{width:"100%",height:"100%",fill:`url(#${Cm})`})]})});function Bl(e,t){return Math.round(e/t)*t}function Ka(e,t,r){return Math.min(r,Math.max(t,e))}function Jo(e,t,r,n){return {x:(e-n.left-r.x)/r.zoom,y:(t-n.top-r.y)/r.zoom}}function Ga(e,t="horizontal"){return t==="vertical"?e==="in"?"top":"bottom":e==="in"?"left":"right"}function ea(e,t,r,n="horizontal"){let o=e.width??180,a=e.height??60,s=t.side??Ga(t.kind,n),l=r.filter(u=>(u.side??Ga(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 js(e,t,r,n,o="horizontal"){if(o==="vertical"){let u=Math.abs(n-t),b=Math.max(50,u*.5),m=e,p=t+b,C=r,v=n-b;return `M ${e} ${t} C ${m} ${p}, ${C} ${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 Nm(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,C=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+C);}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,b=(r-c*d)/2-(a-n)*d;return {x:u,y:b,zoom:d}}var Qk=180,Jk=60,Zs=12,ta=28,Ol=24,eC=-8;function tC(e,t,r,n,o="horizontal"){let a=e.side??Ga(e.kind,o),s=t.filter(d=>(d.side??Ga(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 rC({port:e,allPorts:t,nodeId:r,nodeWidth:n,nodeHeight:o,disabled:a,direction:s,onMouseUp:l}){let i=tC(e,t,n,o,s),c=a||e.disabled,d=useCallback(u=>{c||(u.stopPropagation(),l(r,e.id));},[c,r,e.id,l]);return 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-ta/2,top:i.top-ta/2,width:ta,height:ta,zIndex:20},onMouseUp:d,title:e.label??e.id,children: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:Zs,height:Zs,left:(ta-Zs)/2,top:(ta-Zs)/2}})})}function nC(e,t,r){let n=e??"top-right",o=eC,a=t*(Ol+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 oC({action:e,nodeId:t,index:r,nodeWidth:n,disabled:o,onActionClick:a}){let s=useCallback(c=>{c.stopPropagation(),c.preventDefault(),!o&&a(t,e.id,c.nativeEvent);},[o,t,e.id,a]),l=useCallback(c=>{c.stopPropagation();},[]),i=nC(e.position,r);return 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:Ol,height:Ol,zIndex:30},onClick:s,onMouseDown:l,title:e.label,disabled:o,children:jsx("span",{className:"flex items-center justify-center w-3.5 h-3.5 [&>svg]:w-full [&>svg]:h-full",children:e.icon})})}var Sm=memo(function({node:t,registry:r,ports:n,selected:o,disabled:a,draggable:s,direction:l,onPortMouseUp:i,onActionClick:c}){let d=t.width??Qk,u=t.height??Jk,b=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),C=new Map;if(p)for(let v of p){let k=v.position??"top-right",y=C.get(k)??[];y.push(v),C.set(k,y);}return 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:[b,n.map(v=>jsx(rC,{port:v,allPorts:n,nodeId:t.id,nodeWidth:d,nodeHeight:u,disabled:a,direction:l,onMouseUp:i},v.id)),c&&C.size>0&&Array.from(C.entries()).map(([,v])=>v.map((k,y)=>jsx(oC,{action:k,nodeId:t.id,index:y,nodeWidth:d,disabled:a,onActionClick:c},k.id)))]})});function Rm(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?ea(a,l,s,o):null}var iC=memo(function({edge:t,fromPos:r,toPos:n,selected:o,disabled:a,direction:s,onClick:l}){let i=js(r.x,r.y,n.x,n.y,s),c=(r.x+n.x)/2,d=(r.y+n.y)/2,u=useCallback(b=>{b.stopPropagation(),l(t.id,b);},[t.id,l]);return jsxs("g",{"data-testid":`workflow-edge-${t.id}`,children:[jsx("path",{d:i,fill:"none",stroke:"transparent",strokeWidth:16,className:"cursor-pointer",onClick:u}),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&&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})]})}),Pm=memo(function({edges:t,nodes:r,selectedEdgeId:n,disabled:o,direction:a,onEdgeClick:s,getNodePorts:l}){return jsx("svg",{className:"absolute pointer-events-none",style:{top:0,left:0,width:1,height:1,overflow:"visible"},children:jsx("g",{className:"pointer-events-auto",children:t.map(i=>{let c=Rm(i.from.nodeId,i.from.portId,r,l,a),d=Rm(i.to.nodeId,i.to.portId,r,l,a);return !c||!d?null:jsx(iC,{edge:i,fromPos:c,toPos:d,selected:i.id===n,disabled:o,direction:a,onClick:s},i.id)})})})});var dC=()=>jsx("svg",{className:"w-4 h-4",viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true",children: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"})}),uC=()=>jsx("svg",{className:"w-4 h-4",viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true",children:jsx("path",{fillRule:"evenodd",d:"M5 10a1 1 0 011-1h8a1 1 0 110 2H6a1 1 0 01-1-1z",clipRule:"evenodd"})}),mC=()=>jsx("svg",{className:"w-4 h-4",viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true",children: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"})}),gC=()=>jsx("svg",{className:"w-4 h-4",viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true",children: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"})}),pC=()=>jsx("svg",{className:"w-4 h-4",viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true",children: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"})}),fC=()=>jsx("svg",{className:"w-4 h-4",viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true",children: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"})}),bC=()=>jsx("svg",{className:"w-4 h-4",viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true",children: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"})}),hC=()=>jsx("svg",{className:"w-4 h-4",viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true",children: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"})}),Dm=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[b,m]=useState(false),[p,C]=useState(false),[v,k]=useState(""),[y,z]=useState(""),h=useCallback(()=>{k(i()),m(true);},[i]),R=useCallback(()=>{y.trim()&&(c(y.trim()),z(""),C(false));},[y,c]),f=useCallback(()=>{z(""),C(false);},[]),N=useCallback(()=>{m(false);},[]),L=Math.round(t*100);return jsxs(Fragment,{children:[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:[jsxs(Mo,{size:"sm",children:[jsx(zt,{content:"Zoom in",size:"sm",position:"bottom",children:jsx(At,{icon:jsx(dC,{}),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"})}),jsx(zt,{content:"Zoom out",size:"sm",position:"bottom",children:jsx(At,{icon:jsx(uC,{}),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"})})]}),jsxs("span",{className:"text-xs font-mono text-gray-500 dark:text-gray-400 min-w-[3ch] text-center select-none",children:[L,"%"]}),jsx("div",{className:"w-px h-5 bg-gray-200 dark:bg-gray-600"}),jsx(zt,{content:"Reset view",size:"sm",position:"bottom",children:jsx(At,{icon:jsx(mC,{}),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"})}),jsx(zt,{content:"Fit to content",size:"sm",position:"bottom",children:jsx(At,{icon:jsx(gC,{}),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&&jsxs(Fragment,{children:[jsx("div",{className:"w-px h-5 bg-gray-200 dark:bg-gray-600"}),jsx(zt,{content:r==="horizontal"?"Switch to vertical":"Switch to horizontal",size:"sm",position:"bottom",children:jsx(At,{icon:r==="horizontal"?jsx(bC,{}):jsx(hC,{}),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"})})]}),jsx("div",{className:"w-px h-5 bg-gray-200 dark:bg-gray-600"}),jsx(zt,{content:"Export JSON",size:"sm",position:"bottom",children:jsx(At,{icon:jsx(pC,{}),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:h,disabled:d,"aria-label":"Export JSON"})}),jsx(zt,{content:"Import JSON",size:"sm",position:"bottom",children:jsx(At,{icon:jsx(fC,{}),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:d,"aria-label":"Import JSON"})})]}),jsx(Tn,{isOpen:b,onClose:N,title:"Export Workflow",description:"Copy the JSON below to save your workflow.",size:"lg",showSubmit:false,showCancel:true,cancelLabel:"Close",children:jsx(an,{label:"Workflow JSON",multiline:true,rows:12,value:v,readOnly:true,size:"sm"})}),jsx(Tn,{isOpen:p,onClose:f,title:"Import Workflow",description:"Paste workflow JSON to load it into the editor.",size:"lg",showSubmit:true,submitLabel:"Import",onSubmitClick:R,showCancel:true,cancelLabel:"Cancel",children:jsx(an,{label:"Workflow JSON",multiline:true,rows:12,value:y,onChange:E=>z(E.target.value),placeholder:'{"nodes": [], "edges": []}',size:"sm"})})]})});var $l={x:0,y:0,zoom:1},_l=.1,vC=.1,kC=3,CC=20;function Im(){return `edge-${Date.now()}-${Math.random().toString(36).slice(2,8)}`}function wC({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:b=true,connectable:m=true,selectable:p=true,multiSelect:C=false,panOnDrag:v=true,zoomOnWheel:k=true,minZoom:y=vC,maxZoom:z=kC,snapToGrid:h=false,gridSize:R=CC,showGrid:f=true,toolbar:N=true,autoFit:L=false,className:E},I){let w=e!==void 0,[W,M]=useState(()=>t??{nodes:[],edges:[],viewport:{...$l}}),T=w?e:W,P=T.nodes,x=T.edges,D=T.viewport??$l,S=useRef(null),B=useRef(null),[H,$]=useState(new Set),[_,F]=useState(null),[A,V]=useState(null),Y=useRef(D);Y.current=D;let X=useRef(P);X.current=P;let G=useRef(x);G.current=x;let j=useRef(h);j.current=h;let O=useRef(R);O.current=R;let K=useRef(n);K.current=n;let se=useRef(o);se.current=o;let ae=useCallback(re=>{w?r?.(re(e)):M(ne=>{let he=re(ne);return r?.(he),he});},[w,e,r]),U=useRef(ae);U.current=ae;let J=useCallback(re=>{ae(ne=>({...ne,viewport:re}));},[ae]),te=useRef(J);te.current=J;let ie=useCallback(re=>{let ne=n[re.type];return ne?.getPorts?ne.getPorts(re):re.ports??[]},[n]),Q=useRef(ie);Q.current=ie;let ge=useCallback((re,ne,he)=>{let fe=X.current,Te=G.current,Ce=fe.find(vt=>vt.id===re.fromNodeId),we=fe.find(vt=>vt.id===ne);if(!Ce||!we)return;let Me=Q.current(Ce),Ae=Q.current(we),bt=Me.find(vt=>vt.id===re.fromPortId),ct=Ae.find(vt=>vt.id===he);if(!bt||!ct||ct.kind!=="in"||re.fromNodeId===ne)return;let Ye=K.current[Ce.type];if(Ye?.canConnect&&!Ye.canConnect({fromNode:Ce,toNode:we,fromPort:bt,toPort:ct}))return;Te.some(vt=>vt.from.nodeId===re.fromNodeId&&vt.from.portId===re.fromPortId&&vt.to.nodeId===ne&&vt.to.portId===he)||U.current(vt=>({...vt,edges:[...vt.edges,{id:Im(),from:{nodeId:re.fromNodeId,portId:re.fromPortId},to:{nodeId:ne,portId:he}}]}));},[]);useEffect(()=>{function re(he){let fe=B.current;if(!fe)return;let Te=S.current?.getBoundingClientRect();if(!Te)return;let Ce=Y.current;if(fe.type==="pan"){let we=he.clientX-fe.startX,Me=he.clientY-fe.startY;te.current({...Ce,x:fe.startViewportX+we,y:fe.startViewportY+Me});}if(fe.type==="node"){let we=Jo(he.clientX,he.clientY,Ce,Te),Me=we.x-fe.offsetX,Ae=we.y-fe.offsetY;j.current&&(Me=Bl(Me,O.current),Ae=Bl(Ae,O.current)),U.current(bt=>({...bt,nodes:bt.nodes.map(ct=>ct.id===fe.nodeId?{...ct,x:Me,y:Ae}:ct)}));}if(fe.type==="edge"){let we=Jo(he.clientX,he.clientY,Ce,Te);B.current={...fe,currentX:we.x,currentY:we.y},V({fromX:fe.fromX,fromY:fe.fromY,currentX:we.x,currentY:we.y});}}function ne(he){let fe=B.current;if(fe){if(fe.type==="edge"){let Te=S.current?.getBoundingClientRect();if(Te){let Ce=Y.current,we=Jo(he.clientX,he.clientY,Ce,Te),Me=25,Ae=X.current,bt=1/0,ct=null,Ye=null;for(let er of Ae){let vt=Q.current(er);for(let Hr of vt){if(Hr.kind!=="in")continue;let mn=ea(er,Hr,vt,se.current),Kn=Math.sqrt((we.x-mn.x)**2+(we.y-mn.y)**2);Kn<Me&&Kn<bt&&(bt=Kn,ct=er.id,Ye=Hr.id);}}ct&&Ye&&ge(fe,ct,Ye);}V(null);}B.current=null;}}return document.addEventListener("mousemove",re),document.addEventListener("mouseup",ne),()=>{document.removeEventListener("mousemove",re),document.removeEventListener("mouseup",ne);}},[ge]);let Re=useCallback(re=>{if(!k||u)return;re.preventDefault();let ne=S.current?.getBoundingClientRect();if(!ne)return;let he=re.clientX-ne.left,fe=re.clientY-ne.top,Te=re.deltaY<0?1:-1,Ce=Ka(D.zoom+Te*_l,y,z),we=Ce/D.zoom;J({x:he-(he-D.x)*we,y:fe-(fe-D.y)*we,zoom:Ce});},[k,u,D,y,z,J]),Qe=useCallback(re=>{if(u)return;let ne=re.target;if(ne.closest("[data-action-id]"))return;let fe=ne.closest("[data-port-id]");if(fe){if(!m||d)return;re.preventDefault();let Ce=fe.getAttribute("data-node-id"),we=fe.getAttribute("data-port-id"),Me=fe.getAttribute("data-port-kind");if(!Ce||!we||Me!=="out")return;let Ae=P.find(er=>er.id===Ce);if(!Ae)return;let bt=ie(Ae),ct=bt.find(er=>er.id===we);if(!ct)return;let Ye=ea(Ae,ct,bt,se.current);B.current={type:"edge",fromNodeId:Ce,fromPortId:we,fromX:Ye.x,fromY:Ye.y,currentX:Ye.x,currentY:Ye.y},V({fromX:Ye.x,fromY:Ye.y,currentX:Ye.x,currentY:Ye.y});return}let Te=ne.closest("[data-node-id]");if(Te){if(d)return;let Ce=Te.getAttribute("data-node-id");if(p&&(F(null),C&&re.shiftKey?$(we=>{let Me=new Set(we);return Me.has(Ce)?Me.delete(Ce):Me.add(Ce),Me}):$(new Set([Ce]))),b){let we=S.current?.getBoundingClientRect();if(!we)return;let Me=P.find(bt=>bt.id===Ce);if(!Me||Me.locked)return;let Ae=Jo(re.clientX,re.clientY,D,we);B.current={type:"node",nodeId:Ce,startX:Ae.x,startY:Ae.y,offsetX:Ae.x-Me.x,offsetY:Ae.y-Me.y};}return}p&&($(new Set),F(null)),v&&re.button===0&&(B.current={type:"pan",startX:re.clientX,startY:re.clientY,startViewportX:D.x,startViewportY:D.y});},[u,m,d,p,C,b,v,D,P,ie]),at=useCallback(re=>{let ne=B.current;if(!ne||ne.type!=="edge")return;let he=S.current?.getBoundingClientRect();if(he){let fe=Jo(re.clientX,re.clientY,D,he),Te=30,Ce=1/0,we=null,Me=null;for(let Ae of P){let bt=ie(Ae);for(let ct of bt){if(ct.kind!=="in")continue;let Ye=ea(Ae,ct,bt,se.current),er=Math.sqrt((fe.x-Ye.x)**2+(fe.y-Ye.y)**2);er<Te&&er<Ce&&(Ce=er,we=Ae.id,Me=ct.id);}}if(we&&Me){let Ae=ne.fromNodeId,bt=ne.fromPortId;Ae!==we&&(x.some(Ye=>Ye.from.nodeId===Ae&&Ye.from.portId===bt&&Ye.to.nodeId===we&&Ye.to.portId===Me)||ae(Ye=>({...Ye,edges:[...Ye.edges,{id:Im(),from:{nodeId:Ae,portId:bt},to:{nodeId:we,portId:Me}}]})));}}B.current=null,V(null);},[D,P,x,ie,ae]),et=useCallback((re,ne)=>{let he=B.current;!he||he.type!=="edge"||(ge(he,re,ne),B.current=null,V(null));},[ge]),me=useCallback(re=>{let ne=re.target;if(ne.closest("[data-port-id]")||ne.closest("[data-action-id]"))return null;let Te=ne.closest("[data-node-id]");if(!Te)return null;let Ce=Te.getAttribute("data-node-id");return P.find(we=>we.id===Ce)??null},[P]),ce=useCallback(re=>{if(!s||u)return;let ne=me(re);ne&&s({node:ne,nativeEvent:re.nativeEvent});},[s,u,me]),Oe=useCallback(re=>{if(!l||u)return;let ne=me(re);ne&&l({node:ne,nativeEvent:re.nativeEvent});},[l,u,me]),st=useCallback(re=>{if(!i||u)return;let ne=me(re);ne&&(re.preventDefault(),i({node:ne,nativeEvent:re.nativeEvent}));},[i,u,me]),Pe=useCallback((re,ne,he)=>{if(!c||u)return;let fe=P.find(Te=>Te.id===re);fe&&c({node:fe,actionId:ne,nativeEvent:he});},[c,u,P]),De=useCallback((re,ne)=>{!p||u||(ne.stopPropagation(),$(new Set),F(re));},[p,u]),it=useCallback(re=>{d||u||((re.key==="Delete"||re.key==="Backspace")&&(H.size>0&&(ae(ne=>({...ne,nodes:ne.nodes.filter(he=>!H.has(he.id)),edges:ne.edges.filter(he=>!H.has(he.from.nodeId)&&!H.has(he.to.nodeId))})),$(new Set)),_&&(ae(ne=>({...ne,edges:ne.edges.filter(he=>he.id!==_)})),F(null))),re.key==="Escape"&&($(new Set),F(null)));},[d,u,H,_,ae]),xt=useCallback(()=>{let re=Ka(D.zoom+_l,y,z);J({...D,zoom:re});},[D,y,z,J]),lt=useCallback(()=>{let re=Ka(D.zoom-_l,y,z);J({...D,zoom:re});},[D,y,z,J]),pr=useCallback(()=>{J({...$l});},[J]),tt=useCallback(()=>{let re=S.current?.getBoundingClientRect();if(!re)return;let ne=Nm(P,re.width,re.height),he=Ka(ne.zoom,y,z);J({...ne,zoom:he});},[P,y,z,J]),yr=useCallback(re=>{ae(ne=>({...ne,nodes:[...ne.nodes,re]}));},[ae]),Wr=useCallback(re=>{ae(ne=>({...ne,nodes:ne.nodes.filter(he=>he.id!==re),edges:ne.edges.filter(he=>he.from.nodeId!==re&&he.to.nodeId!==re)}));},[ae]),Bt=useCallback(()=>JSON.stringify(T,null,2),[T]),ar=useCallback(re=>{try{let ne=JSON.parse(re);ne&&Array.isArray(ne.nodes)&&Array.isArray(ne.edges)&&ae(()=>ne);}catch{}},[ae]);useImperativeHandle(I,()=>({zoomIn:xt,zoomOut:lt,resetView:pr,fitToContent:tt,addNode:yr,removeNode:Wr,toJSON:Bt,loadJSON:ar}),[xt,lt,pr,tt,yr,Wr,Bt,ar]);let Rr=useRef(false);useEffect(()=>{L&&!Rr.current&&S.current&&(Rr.current=true,tt());},[L,tt]);let ye=useMemo(()=>{let re=new Map;for(let ne of P)re.set(ne.id,ie(ne));return re},[P,ie]),xe=useMemo(()=>({transform:`translate(${D.x}px, ${D.y}px) scale(${D.zoom})`,transformOrigin:"0 0"}),[D.x,D.y,D.zoom]);return jsxs("div",{ref:S,"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",E),tabIndex:0,onWheel:Re,onMouseDown:Qe,onMouseUp:at,onClick:ce,onDoubleClick:Oe,onContextMenu:st,onKeyDown:it,children:[f&&jsx(wm,{gridSize:R,zoom:D.zoom}),N&&!d&&jsx(Dm,{zoom:D.zoom,direction:o,onDirectionChange:a,onZoomIn:xt,onZoomOut:lt,onResetView:pr,onFitToContent:tt,onExportJSON:Bt,onImportJSON:ar,disabled:u}),jsxs("div",{style:xe,children:[jsx(Pm,{edges:x,nodes:P,selectedEdgeId:_,disabled:u||d,direction:o,onEdgeClick:De,getNodePorts:re=>ye.get(re.id)??[]}),P.map(re=>{let ne=n[re.type];if(!ne)return null;let he=ye.get(re.id)??[];return jsx(Sm,{node:re,registry:ne,ports:he,selected:H.has(re.id),disabled:u||d,draggable:b&&!d,direction:o,onPortMouseUp:et,onActionClick:c?Pe:void 0},re.id)})]}),A&&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:[jsx("path",{d:js(A.fromX*D.zoom+D.x,A.fromY*D.zoom+D.y,A.currentX*D.zoom+D.x,A.currentY*D.zoom+D.y,o),fill:"none",stroke:"#3b82f6",strokeWidth:2.5,strokeDasharray:"8 4"}),jsx("circle",{cx:A.fromX*D.zoom+D.x,cy:A.fromY*D.zoom+D.y,r:5,fill:"#3b82f6"}),jsx("circle",{cx:A.currentX*D.zoom+D.x,cy:A.currentY*D.zoom+D.y,r:4,fill:"#3b82f6",opacity:.6})]})]})}var Am=forwardRef(wC);Am.displayName="WorkflowEditor";var Vm=createContext(null);function Gn(){let e=useContext(Vm);if(!e)throw new Error("useWizard and Wizard sub-components must be used within <Wizard>");return e}var Gl=(e,t,r)=>Math.max(t,Math.min(e,r)),Kl={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"}},un={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 RC({className:e}){return jsx("svg",{className:e,viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true",children: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 Bm({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 b=e.length,m=Math.max(0,b-1),p=t!==void 0,[C,v]=useState(()=>Gl(r,0,m)),k=Gl(p?t:C,0,m),[y,z]=useState(k);y<k&&z(k);let h=k<=0,R=k>=m,f=useCallback((M,T)=>{let P=Gl(M,0,m);P!==k&&(p||v(P),z(x=>Math.max(x,P)),n?.(P,{previous:k,direction:T}));},[k,p,m,n]),N=useCallback(M=>{let T=e[M];return !T||T.disabled?false:c?M<=y:true},[e,c,y]),L=useCallback(M=>{N(M)&&f(M,M>k?"jump":"backward");},[N,f,k]),E=useCallback(()=>{if(R){o?.();return}f(k+1,"forward");},[R,o,f,k]),I=useCallback(()=>{h||f(k-1,"backward");},[h,f,k]),w=useCallback(M=>e[M]?.error?"error":M===k?"active":M<k?"completed":"upcoming",[e,k]),W={steps:e,activeStep:k,totalSteps:b,isFirstStep:h,isLastStep:R,orientation:a,variant:s,size:l,color:i,linear:c,goToStep:L,goNext:E,goBack:I,getStepStatus:w,isStepAccessible:N};return jsx(Vm.Provider,{value:W,children:jsx("div",{className:g("flex w-full flex-col gap-6",d),"data-testid":"wizard","data-orientation":a,children:u})})}function Wm({index:e,status:t}){let{variant:r,size:n,color:o,steps:a}=Gn(),s=Kl[n],l=a[e];if(r==="dots"){let d=t==="upcoming"?"bg-gray-300 dark:bg-gray-600":t==="error"?"bg-red-600":un[o].bg;return jsx("span",{className:g("shrink-0 rounded-full transition-colors",s.dot,d),"aria-hidden":"true"})}let i=t==="completed"?g(un[o].solid,"border-transparent"):t==="active"?g(un[o].solid,"border-transparent ring-4",un[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"?jsx(RC,{className:s.icon}):t==="error"?jsx("span",{className:"font-semibold leading-none",children:"!"}):l.icon??jsx("span",{className:"font-medium leading-none",children:e+1});return jsx("span",{className:g("flex shrink-0 items-center justify-center rounded-full transition-all",s.circle,i),"aria-hidden":"true",children:c})}function Hm({index:e,status:t}){let{steps:r,size:n,color:o,variant:a}=Gn(),s=Kl[n],l=r[e],c=t==="active"?un[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 jsxs("span",{className:"flex min-w-0 flex-col",children:[jsxs("span",{className:g("font-medium leading-tight",s.title,c),children:[a==="simple"&&jsxs("span",{className:"mr-1 tabular-nums",children:[e+1,"."]}),l.title,l.optional&&jsx("span",{className:"ml-1 text-xs font-normal text-gray-400 dark:text-gray-500",children:"(optional)"})]}),l.description&&jsx("span",{className:g("mt-0.5 text-gray-400 dark:text-gray-500",s.desc),children:l.description})]})}function Fm({className:e,hideConnector:t=false,hideLabels:r=false}){let n=Gn(),{steps:o,orientation:a,size:s,variant:l,color:i,activeStep:c}=n,d=Kl[s],u=a==="vertical",b=l!=="simple";return 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 C=n.getStepStatus(p),v=p===c,k=n.isStepAccessible(p)&&!v,y=p===o.length-1,h=p<c?un[i].bg:"bg-gray-200 dark:bg-gray-700";return u?jsx("li",{className:"flex","aria-current":v?"step":void 0,"data-status":C,"data-testid":"wizard-step",children:jsxs("button",{type:"button",disabled:!k,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",un[i].ring,k?"cursor-pointer":"cursor-default"),children:[jsxs("span",{className:"flex flex-col items-center",children:[b&&jsx(Wm,{index:p,status:C}),!t&&!y&&jsx("span",{className:g("my-1 w-0.5 flex-1 rounded",h),"aria-hidden":"true"})]}),!r&&jsx("span",{className:g(y?"pb-0":"pb-6"),children:jsx(Hm,{index:p,status:C})})]})},m.id??p):jsxs("li",{className:g("flex items-center",!y&&"flex-1"),"aria-current":v?"step":void 0,"data-status":C,"data-testid":"wizard-step",children:[jsxs("button",{type:"button",disabled:!k,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",un[i].ring,k?"cursor-pointer":"cursor-default"),children:[b&&jsx(Wm,{index:p,status:C}),!r&&jsx(Hm,{index:p,status:C})]}),!t&&!y&&jsx("span",{className:g("mx-2 flex-1 rounded",d.connector,h),"aria-hidden":"true"})]},m.id??p)})})}function Om({index:e,keepMounted:t=false,className:r,children:n}){let{activeStep:o}=Gn(),a=e===o;return !a&&!t?null:jsx("div",{role:"tabpanel",hidden:!a,"data-testid":"wizard-panel","data-active":a,"data-step":e,className:g("w-full",r),children:n})}function $m({className:e,children:t}){let r=Gn();return jsx("div",{className:g("w-full",e),"data-testid":"wizard-content",children:typeof t=="function"?t(r):t})}var _m="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 Ul({children:e,label:t="Previous",className:r,onClick:n,disabled:o,...a}){let{goBack:s,isFirstStep:l}=Gn();return jsx("button",{type:"button",onClick:c=>{n?.(c),c.defaultPrevented||s();},disabled:o??l,"data-testid":"wizard-previous",className:g(_m,"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 Yl({children:e,label:t="Next",finishLabel:r="Finish",className:n,onClick:o,...a}){let{goNext:s,isLastStep:l,color:i}=Gn();return jsx("button",{type:"button",onClick:d=>{o?.(d),d.defaultPrevented||s();},"data-testid":"wizard-next",className:g(_m,un[i].solid,un[i].ring,"hover:opacity-90",n),...a,children:e??(l?r:t)})}function Xm({className:e,children:t,align:r="between"}){let n={between:"justify-between",start:"justify-start",center:"justify-center",end:"justify-end"}[r];return jsx("div",{className:g("flex items-center gap-3",n,e),"data-testid":"wizard-actions",children:t??jsxs(Fragment,{children:[jsx(Ul,{}),jsx(Yl,{})]})})}Bm.displayName="Wizard";Fm.displayName="WizardSteps";Om.displayName="WizardPanel";$m.displayName="WizardContent";Xm.displayName="WizardActions";Ul.displayName="WizardPrevious";Yl.displayName="WizardNext";export{mg as Accordion,fg as AccordionContent,gg as AccordionItem,pg as AccordionTrigger,ic as AdvanceDetachable,xp as AreaChart,wp as Avatar,Dc as Badge,Wc as Banner,Fp as BarChart,ef as BoxPlot,Qp as Breadcrumb,l0 as BulletChart,At as Button,Mo as ButtonGroup,qn as CHART_ALL_PAIRS_LIMIT,Yn as CHART_DIVERGING_COLORS,xc as CHART_DIVERGING_DARK_STOPS,hc as CHART_DIVERGING_NEUTRAL_INDEX,pi as CHART_DOWN_COLOR,es as CHART_MAX_COLOR_CLASSES,Tr as CHART_MUTED_COLOR,ia as CHART_ORDINAL_COLORS,fi as CHART_ORDINAL_DARK_STOPS,sp as CHART_PALETTE_SIZE,mi as CHART_SEQUENTIAL_COLORS,yc as CHART_SEQUENTIAL_DARK_STOPS,Ja as CHART_SERIES_COLORS,gi as CHART_UP_COLOR,T0 as Calendar,cf as CandlestickChart,_c as Card,Kc as CardBody,jc as CardDescription,Uc as CardFooter,Gc as CardHeader,Yc as CardImage,qc as CardTitle,_e as ChartAxis,ut as ChartContainer,gf as ChartFacets,Ot as ChartGrid,$t as ChartLegend,fa as ChartScaleLegend,It as ChartTableView,gt as ChartTooltip,Cr as ChartTooltipContent,ka as Checkbox,ad as CheckboxGroup,sd as CheckboxGroupItem,xs as Chip,xo as CircularProgress,mc as DEFAULT_CHART_WIDTH,Xa as DEFAULT_FIELD_TYPES,Sb as DataGrid,dd as Detachable,oh as DeviceMockup,md as Divider,Nd as Drawer,Md as Dropdown,Kd as DropdownCheckboxItem,Vd as DropdownContent,Fd as DropdownItem,$d as DropdownLabel,jd as DropdownRadioGroup,Zd as DropdownRadioItem,Od as DropdownSeparator,nu as DropdownSubMenu,au as DropdownSubMenuContent,ou as DropdownSubMenuTrigger,Ad as DropdownTrigger,Cf as DumbbellChart,yd as FOCUSABLE_SELECTOR,Dh as FileSelector,Uu as Footer,Zu as FooterBottom,qu as FooterColumn,ju as FooterLink,Yu as FooterSection,Qu as FooterSocial,Ju as FooterSocialLink,Lf as FunnelChart,Bf as GanttChart,Wy as Header,Cx as Heatmap,du as HelpButton,gd as INERT_IGNORE_ATTRIBUTE,ox as ImageUploader,mu as Indicator,an as Input,bu as Label,Dx as LineChart,al as MentionInput,Tn as Modal,sl as NumberInput,Gx as Pagination,ev as PieChart,Su as ProgressBar,Ru as RadioButton,rk as ScatterChart,km as SchemaEditor,Nv as Select,Lv as Sidebar,Iv as SidebarContent,Av as SidebarFooter,zv as SidebarGroup,Mv as SidebarHeader,Wv as SidebarItem,Hv as SidebarSubMenu,Vv as SidebarToggle,Mu as Skeleton,Au as Slider,yl as Sparkline,Kv as StatCard,Yv as StatCardGroup,gn as Table,pn as TableBody,_t as TableCell,fn as TableHeader,Nt as TableHeaderCell,bn as TableRow,Wu as Tabs,Ou as TabsContent,Hu as TabsList,Fu as TabsTrigger,Xu as Toast,zt as Tooltip,Hg as UILabelsProvider,qf as WaterfallChart,Zy as WithHelpButton,Bm as Wizard,Xm as WizardActions,$m as WizardContent,Yl as WizardNext,Om as WizardPanel,Ul as WizardPrevious,Fm as WizardSteps,Am as WorkflowEditor,zl as autoLayoutTables,Mc as binEdges,ki as binValues,Ei as boxStats,g as cn,Pl as createDefaultField,El as createDefaultTable,Co as createDivergingScale,ca as createSequentialScale,dc as defaultUILabels,Cs as findOwnedLayers,us as formatTimeTick,Wg as frenchUILabels,_a as generateFieldId,Tl as generateRelationId,Ys as generateSQL,im as generateTableId,ws as getFocusableElements,lp as getOrdinalColor,Pr as getSeriesColor,Xt as getSeriesLabel,qi as hideOthers,xd as isElementVisible,vd as isFocusable,Wi as niceTimeTicks,U0 as quantile,ha as quantileSorted,ko as rampColor,oo as registerFloatingLayer,Wp as resetBarChartWarnings,xf as resetDumbbellWarnings,pf as resetFacetWarnings,Er as resolveSeriesColor,Lc as sturgesBins,Or as toLegendItems,to as toTimestamp,ui as useChartSize,Bo as useClickOutside,ao as useDialogA11y,wr as useDropdownContext,Wd as useFocusItem,Rs as useKeyboardNavigation,Fo as usePositioning,Tv as useSidebar,Ge as useUILabels,Gn as useWizard};