@synertech/ui 0.39.1 → 0.40.1

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 ta from'react';import ta__default,{createContext,forwardRef,useId,useState,useRef,useEffect,useCallback,useImperativeHandle,memo,useMemo,useContext,cloneElement,isValidElement,useLayoutEffect}from'react';import {jsxs,jsx,Fragment}from'react/jsx-runtime';import {createPortal}from'react-dom';import {createRoot}from'react-dom/client';import ig from'dompurify';import lg from'react-markdown';import dg from'remark-gfm';function s(...e){return e.filter(Boolean).join(" ")}var ps=createContext(null),gs=createContext(null);function Jn(){let e=useContext(ps);if(!e)throw new Error("Accordion sub-components must be used within <Accordion>");return e}function fs(){let e=useContext(gs);if(!e)throw new Error("AccordionTrigger/AccordionContent must be used within <AccordionItem>");return e}var ms={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"}},Fd=({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"})}),Hd={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:""},Bd={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 Od({type:e="single",value:t,defaultValue:r,onValueChange:o,collapsible:n=false,variant:a="default",size:i="md",disabled:c=false,iconPosition:d="right",icon:l,hideIcon:u=false,className:p,children:m}){let[g,f]=useState(()=>r?Array.isArray(r)?r:[r]:[]),h=t!==void 0,b=h?Array.isArray(t)?t:[t]:g,x=useCallback(k=>{let D;e==="single"?b.includes(k)?D=n?[]:[k]:D=[k]:D=b.includes(k)?b.filter(N=>N!==k):[...b,k],h||f(D),o?.(e==="single"?D[0]??"":D);},[e,b,n,h,o]),v=useMemo(()=>({openItems:b,toggle:x,variant:a,size:i,disabled:c,iconPosition:d,icon:l??null,hideIcon:u}),[b,x,a,i,c,d,l,u]);return jsx(ps.Provider,{value:v,children:jsx("div",{className:s(Hd[a],p),"data-testid":"accordion",children:m})})}function Vd({value:e,disabled:t,className:r,children:o}){let n=Jn(),a=n.openItems.includes(e),i=t??n.disabled,c=useId(),d=`accordion-trigger-${c}`,l=`accordion-content-${c}`,u=useMemo(()=>({value:e,isOpen:a,disabled:i,triggerId:d,contentId:l}),[e,a,i,d,l]);return jsx(gs.Provider,{value:u,children:jsx("div",{className:s(Bd[n.variant],r),"data-state":a?"open":"closed","data-testid":"accordion-item",children:o})})}function _d({className:e,icon:t,children:r}){let o=Jn(),n=fs(),a=ms[o.size],i=()=>{n.disabled||o.toggle(n.value);},c=u=>{(u.key==="Enter"||u.key===" ")&&(u.preventDefault(),i());},d=t??o.icon??jsx(Fd,{className:a.icon}),l=!o.hideIcon&&jsx("span",{className:s("shrink-0 text-gray-500 dark:text-gray-400 transition-transform duration-200",n.isOpen&&"rotate-180"),"data-testid":"accordion-icon",children:d});return jsxs("button",{type:"button",id:n.triggerId,"aria-expanded":n.isOpen,"aria-controls":n.contentId,disabled:n.disabled,onClick:i,onKeyDown:c,className:s("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"&&l,jsx("span",{className:"flex-1",children:r}),o.iconPosition==="right"&&l]})}function $d({className:e,children:t}){let r=Jn(),o=fs(),n=ms[r.size],a=useRef(null),[i,c]=useState(o.isOpen?void 0:0),d=useRef(true);return useEffect(()=>{if(d.current){d.current=false,c(o.isOpen?void 0:0);return}if(o.isOpen){let l=a.current;if(l){c(l.scrollHeight);let u=setTimeout(()=>c(void 0),200);return ()=>clearTimeout(u)}}else {let l=a.current;l&&(c(l.scrollHeight),requestAnimationFrame(()=>c(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:i===void 0?"auto":i},"data-testid":"accordion-content","data-state":o.isOpen?"open":"closed",children:jsx("div",{ref:a,className:s(n.content,"text-gray-600 dark:text-gray-400",n.text==="text-lg"?"text-base":"text-sm",e),children:t})})}function Xd(...e){return e.filter(Boolean).join(" ")}var jd="@synertech/ui/AdvanceDetachable",qd=300,Jd="width=800,height=600,menubar=no,toolbar=no,location=no,status=no,scrollbars=yes,resizable=yes",Zd=0;function Qd(){return `${Date.now()}-${++Zd}-${Math.random().toString(36).slice(2,8)}`}function bs(e){try{return JSON.stringify(e)}catch{return String(e)}}function hs(e){try{return JSON.parse(e)}catch{return e}}function ec(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 tc(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 i=t.createElement("style");i.textContent=a.textContent,t.head.appendChild(i);}else if(a instanceof HTMLLinkElement&&a.rel==="stylesheet"){let i=t.createElement("link");i.rel="stylesheet",i.href=a.href,t.head.appendChild(i);}});return r.observe(e.head,{childList:true}),r}function rc(){return typeof BroadcastChannel<"u"}function oc({mode:e,id:t,title:r="",children:o,value:n,defaultValue:a,onValueChange:i,isDetached:c,defaultDetached:d=false,onDetachedChange:l,features:u,target:p,autoFocus:m=true,className:g,detachedBodyClassName:f,disabled:h=false,readOnly:b=false,closeOnMainWindowUnload:x=true,name:v,serialize:k,deserialize:D},N){let E=c!==void 0,[M,R]=useState(d),P=E?c:M,A=n!==void 0,[$,q]=useState(a),L=A?n:$,[_,z]=useState(null),y=useRef(null),S=useRef(null),T=useRef(null),Q=useRef(null),ie=useRef(false),we=useRef(null),he=useRef(null),F=useRef(null),[ee]=useState(()=>`${Date.now().toString(36)}-${Math.random().toString(36).slice(2,8)}`),ae=useRef({title:r,features:u,target:p,autoFocus:m,detachedBodyClassName:f,closeOnMainWindowUnload:x,disabled:h,readOnly:b,mode:e,id:t});ae.current={title:r,features:u,target:p,autoFocus:m,detachedBodyClassName:f,closeOnMainWindowUnload:x,disabled:h,readOnly:b,mode:e,id:t};let ye=useRef(k??bs);ye.current=k??bs;let xe=useRef(D??hs);xe.current=D??hs;let le=useRef(i);le.current=i;let X=useRef(l);X.current=l;let C=useRef(P);C.current=P;let U=`${jd}/${t}`,ge=useCallback(()=>{T.current&&(clearInterval(T.current),T.current=null),Q.current&&(Q.current.disconnect(),Q.current=null),z(null);},[]),re=useCallback(()=>{S.current&&(S.current.close(),S.current=null),we.current&&typeof window<"u"&&(window.removeEventListener("message",we.current),we.current=null);},[]),B=useCallback(Ee=>{if(!(!Ee||Ee.channel!==U)&&Ee.instanceId!==ee&&!ae.current.readOnly&&Ee.type==="value-sync"&&Ee.payload!==void 0){he.current=Ee.payload;let We=xe.current(Ee.payload);A||q(We),le.current?.(We);}},[U,ee,A]),te=useCallback(()=>{if(re(),!(typeof window>"u"))if(rc()){let Ee=new BroadcastChannel(U),We=ht=>B(ht.data);Ee.addEventListener("message",We),S.current=Ee;}else {let Ee=We=>{We.data?.channel===U&&B(We.data);};window.addEventListener("message",Ee),we.current=Ee;}},[U,re,B]),me=useCallback(Ee=>{if(ae.current.readOnly)return;let We=ye.current(Ee);if(We===F.current)return;if(We===he.current){he.current=null;return}F.current=We;let ht={channel:U,instanceId:ee,messageId:Qd(),origin:"main",timestamp:Date.now(),type:"value-sync",payload:We};S.current?S.current.postMessage(ht):y.current&&!y.current.closed&&y.current.postMessage(ht,"*");},[U,ee]),Se=useCallback(()=>{if(typeof window>"u"||ae.current.disabled||ie.current||y.current&&!y.current.closed)return;ie.current=true;let Ee=ae.current,We=window.open("",Ee.target||"",Ee.features||Jd);if(!We){ie.current=false;return}y.current=We,We.document.title=Ee.title||document.title,Ee.detachedBodyClassName&&(We.document.body.className=Ee.detachedBodyClassName);let ht=We.document.createElement("div");We.document.body.appendChild(ht),z(ht),ec(document,We.document),Q.current=tc(document,We.document),T.current=setInterval(()=>{We.closed&&(ge(),y.current=null,E||R(false),X.current?.(false));},qd),Ee.autoFocus&&We.focus(),ie.current=false;},[E,ge]),j=useCallback(()=>{y.current&&!y.current.closed&&y.current.close(),y.current=null,ge();},[ge]),Te=useRef(Se);Te.current=Se;let Pe=useRef(j);Pe.current=j;let et=useRef(me);et.current=me;let at=useCallback(()=>{ae.current.disabled||(E||R(true),X.current?.(true));},[E]),pt=useCallback(()=>{E||R(false),X.current?.(false);},[E]),J=useCallback(()=>{let Ee=!C.current;Ee&&ae.current.disabled||(E||R(Ee),X.current?.(Ee));},[E]);useImperativeHandle(N,()=>({open:at,close:pt,toggle:J,get isDetached(){return C.current},get window(){return y.current}}),[at,pt,J]),useEffect(()=>(te(),()=>re()),[te,re]),useEffect(()=>{if(P)return Te.current(),()=>Pe.current();Pe.current();},[P]),useEffect(()=>{L!==void 0&&et.current(L);},[L]),useEffect(()=>{y.current&&!y.current.closed&&r&&(y.current.document.title=r);},[r]),useEffect(()=>{if(typeof window>"u")return;let Ee=()=>{ae.current.closeOnMainWindowUnload&&y.current&&!y.current.closed&&y.current.close();};return window.addEventListener("beforeunload",Ee),()=>{window.removeEventListener("beforeunload",Ee),y.current&&!y.current.closed&&y.current.close(),y.current=null;}},[]);let fe=typeof o=="function"?o({open:at,close:pt,toggle:J,detached:P,windowRef:y.current}):o,Ke=e==="clone"||!P,xt=P&&_!==null;return jsxs(Fragment,{children:[v&&L!==void 0&&jsx("input",{type:"hidden",name:v,value:ye.current(L)}),Ke&&jsx("div",{className:Xd(g),children:fe}),xt&&createPortal(fe,_)]})}var xs=forwardRef(oc);xs.displayName="AdvanceDetachable";var sc={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"},ic={circle:"rounded-full",square:"rounded-none",rounded:"rounded-md"};function lc({src:e,alt:t="Avatar",fallback:r,size:o="md",variant:n="circle",border:a=false,className:i,...c}){return jsx("div",{className:s("inline-flex items-center justify-center overflow-hidden bg-gray-200 font-medium text-gray-600 dark:bg-gray-700 dark:text-gray-300",sc[o],ic[n],a&&"ring-2 ring-white dark:ring-gray-900",i),...c,children:e?jsx("img",{src:e,alt:t,className:"h-full w-full object-cover"}):jsx("span",{children:r||t.charAt(0).toUpperCase()})})}var dc={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"}},cc={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"},uc={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"},pc={sm:"w-1.5 h-1.5",md:"w-1.5 h-1.5",lg:"w-2 h-2"},gc={sm:"w-2.5 h-2.5",md:"w-3 h-3",lg:"w-3.5 h-3.5"};function ws({children:e,color:t="default",size:r="md",variant:o="soft",dot:n=false,icon:a,pill:i=true,className:c,...d}){return jsxs("span",{className:s("inline-flex items-center font-medium",uc[r],i?"rounded-full":"rounded",dc[t][o],c),...d,children:[n&&jsx("span",{className:s("shrink-0 rounded-full",pc[r],cc[t]),"aria-hidden":"true"}),a&&!n&&jsx("span",{className:s("shrink-0",gc[r]),"aria-hidden":"true",children:a}),e]})}ws.displayName="Badge";function ks({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 mc({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 bc({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 hc({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 ea({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 yc={info:ks,success:mc,warning:bc,error:hc,default:ks},xc={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"},vc={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 wc({type:e="default",title:t,description:r,children:o,icon:n,action:a,closable:i=false,onClose:c,fullWidth:d=false,className:l,...u}){let[p,m]=useState(true);if(!p)return null;let g=()=>{m(false),c?.();},f=yc[e],h=o??r;return jsxs("div",{role:"alert",className:s("flex items-start gap-3 border px-4 py-3",d?"w-full":"rounded-lg",xc[e],l),...u,children:[jsx("div",{className:s("shrink-0 mt-0.5",vc[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:s("text-sm",t?"mt-1 opacity-90":false),children:h}),a&&jsx("div",{className:"mt-3",children:a})]}),i&&jsx("button",{type:"button",onClick:g,className:s("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(ea,{className:"w-4 h-4"})})]})}function kc({title:e,description:t,children:r,action:o,backgroundImage:n,closable:a=false,onClose:i,fullWidth:c=false,className:d,...l}){let[u,p]=useState(true);if(!u)return null;let m=()=>{p(false),i?.();},g=r??t;return jsxs("div",{className:s("relative overflow-hidden bg-gray-900 text-white",c?"w-full":"rounded-xl","py-12 px-6 sm:px-12",d),style:n?{backgroundImage:`url(${n})`,backgroundSize:"cover",backgroundPosition:"center"}:void 0,...l,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}),g&&jsx("div",{className:s("text-base sm:text-lg opacity-90",e?"mt-4":false),children:g}),o&&jsx("div",{className:"mt-6",children:o})]}),a&&jsx("button",{type:"button",onClick:m,className:s("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(ea,{className:"w-5 h-5"})})]})}function Cc({title:e,description:t,children:r,icon:o,action:n,badge:a,closable:i=false,onClose:c,fullWidth:d=false,className:l,...u}){let[p,m]=useState(true);if(!p)return null;let g=()=>{m(false),c?.();},f=r??t;return jsxs("div",{className:s("relative flex items-center gap-4 bg-linear-to-r from-indigo-600 to-purple-600 text-white px-4 py-3",d?"w-full":"rounded-lg",l),...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}),i&&jsx("button",{type:"button",onClick:g,className:s("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(ea,{className:"w-4 h-4"})})]})}function Cs({variant:e="notification",...t}){switch(e){case "hero":return jsx(kc,{...t});case "promotion":return jsx(Cc,{...t});default:return jsx(wc,{...t})}}Cs.displayName="Banner";var Nc={sm:"text-xs",md:"text-sm",lg:"text-base"};function Sc({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:i="text-gray-400 dark:text-gray-500",className:c,...d}){let l=e,u=false;if(o&&e.length>o){u=true;let p=e[0],m=e.slice(-(o-1));l=[p,...m];}return jsx("nav",{"aria-label":"Breadcrumb",className:s("inline-flex items-center",Nc[r],c),...d,children:jsx("ol",{className:"inline-flex items-center space-x-1 md:space-x-2",children:l.map((p,m)=>{let g=m===l.length-1;return jsxs("li",{className:"inline-flex items-center",children:[u&&m===1&&jsxs(Fragment,{children:[jsx("span",{className:s("mx-1 select-none",i),children:"..."}),jsx("span",{className:s("mx-1 select-none",i),"aria-hidden":"true",children:t})]}),p.href||p.onClick?jsxs("a",{href:p.href,onClick:p.onClick,className:s("inline-flex items-center gap-1.5 transition-colors",g?a:n),"aria-current":g?"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:s("inline-flex items-center gap-1.5",g?a:n),"aria-current":g?"page":void 0,children:[p.icon&&jsx("span",{className:"inline-flex","aria-hidden":"true",children:p.icon}),jsx("span",{children:p.label})]}),!g&&jsx("span",{className:s("mx-2 select-none",i),"aria-hidden":"true",children:t})]},p.href??p.label)})})})}function Tc({className:e}){return jsxs("svg",{className:s("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 Dc={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"},Ec={sm:"p-1.5",md:"p-2",lg:"p-2.5",xl:"p-3"},rn={sm:"h-3.5 w-3.5",md:"h-4 w-4",lg:"h-5 w-5",xl:"h-6 w-6"},Ic={none:"rounded-none",sm:"rounded-sm",md:"rounded-md",lg:"rounded-lg",full:"rounded-full"};function lt({label:e,children:t,onClick:r,disabled:o=false,className:n,type:a="button",size:i="md",loading:c=false,leftIcon:d,rightIcon:l,icon:u,fullWidth:p=false,rounded:m="lg",bgColor:g="bg-blue-600 hover:bg-blue-700",textColor:f="text-white",focusColor:h="focus:ring-blue-300",selected:b=false,value:x,showFocusOnClick:v=false,...k}){let D=o||c,N=u!==void 0&&!t&&!e,E=s("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"),M=s(b?"bg-blue-700 text-white ring-2 ring-blue-500":g,!b&&f,h&&v&&`focus:ring-4 ${h}`,h&&!v&&`focus-visible:ring-4 ${h}`);return jsx("button",{type:a,onClick:r,disabled:D,"data-value":x,className:s(E,N?Ec[i]:Dc[i],Ic[m],M,p&&"w-full",n),...k,children:c?jsx(Tc,{className:rn[i]}):N?jsx("span",{className:rn[i],children:u}):jsxs(Fragment,{children:[d&&jsx("span",{className:rn[i],children:d}),t??e,l&&jsx("span",{className:rn[i],children:l})]})})}function to({children:e,orientation:t="horizontal",size:r,fullWidth:o=false,selectedValue:n,onChange:a,className:i}){let d=ta__default.Children.toArray(e).filter(u=>ta__default.isValidElement(u)&&typeof u.type!="string"),l=(u,p)=>m=>{u!==void 0&&a&&a(u),p&&p(m);};return jsx("div",{className:s("inline-flex",t==="horizontal"?"flex-row":"flex-col",o&&"w-full",i),role:"group",children:d.map((u,p)=>{let m=p===0,g=p===d.length-1,f=!m&&!g,h=u.props.value,b=n!==void 0&&h===n,x=s(t==="horizontal"&&m&&"rounded-r-none",t==="horizontal"&&g&&"rounded-l-none",t==="horizontal"&&f&&"rounded-none",t==="horizontal"&&!m&&"-ml-px",t==="vertical"&&m&&"rounded-b-none",t==="vertical"&&g&&"rounded-t-none",t==="vertical"&&f&&"rounded-none",t==="vertical"&&!m&&"-mt-px",o&&"flex-1");return ta__default.cloneElement(u,{...u.props,size:r??u.props.size,selected:b||u.props.selected,onClick:l(h,u.props.onClick),className:s(x,u.props.className)})})})}var zc=10080*60*1e3;function ft(e){return new Date(e.getFullYear(),e.getMonth(),e.getDate())}function Or(e){return new Date(e.getFullYear(),e.getMonth(),1)}function fr(e,t){return new Date(e.getFullYear(),e.getMonth(),e.getDate()+t)}function Ut(e,t){return new Date(e.getFullYear(),e.getMonth()+t,1)}function oa(e){return new Date(e.getFullYear(),e.getMonth()+1,0).getDate()}function tr(e,t){return !e||!t?false:e.getFullYear()===t.getFullYear()&&e.getMonth()===t.getMonth()&&e.getDate()===t.getDate()}function ra(e,t){return e.getFullYear()===t.getFullYear()&&e.getMonth()===t.getMonth()}function Rr(e,t){return e.getFullYear()*12+e.getMonth()-(t.getFullYear()*12+t.getMonth())}function nn(e){let t=`${e.getMonth()+1}`.padStart(2,"0"),r=`${e.getDate()}`.padStart(2,"0");return `${e.getFullYear()}-${t}-${r}`}function Ac(e){let t=ft(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())/zc)}function Rs(e,t,r){return t&&e<ft(t)?ft(t):r&&e>ft(r)?ft(r):e}function Wc(e,t,r){let o=Or(e),n=(o.getDay()-t+7)%7,a=fr(o,-n),i=r?6:Math.ceil((n+oa(e))/7);return Array.from({length:i},(c,d)=>Array.from({length:7},(l,u)=>fr(a,d*7+u)))}function Fc({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 Hc({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 Bc={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"}},Oc={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"},Vc={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"},_c={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"},$c={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"},Br={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 an(e,t){if(e==="multiple")return Array.isArray(t)?t.map(ft):[];if(e==="range"){let r=t??null;return {from:r?.from?ft(r.from):null,to:r?.to?ft(r.to):null}}return t instanceof Date?ft(t):null}function Ts(e){return e?e instanceof Date?e:Array.isArray(e)?e[0]??null:e.from??e.to??null:null}function Uc(e){let{mode:t="single",value:r,defaultValue:o,onChange:n,max:a,month:i,defaultMonth:c,onMonthChange:d,numberOfMonths:l=1,weekStartsOn:u=0,locale:p,size:m="md",color:g="primary",minDate:f,maxDate:h,disabledDates:b,disabled:x=false,showOutsideDays:v=true,showWeekNumbers:k=false,fixedWeeks:D=false,captionLayout:N="label",fromYear:E,toYear:M,todayButton:R=false,clearButton:P=false,footer:A,bordered:$=true,renderDay:q,labels:L,className:_,...z}=e,y=Bc[m],S=Math.max(1,l),T=useMemo(()=>ft(new Date),[]),Q=r!==void 0,[ie,we]=useState(()=>an(t,o)),he=Q?an(t,r):ie,F=i!==void 0,[ee,ae]=useState(()=>Or(c??Ts(an(t,o??r))??new Date)),ye=F?Or(i):ee,xe=useCallback(de=>{let ue=Or(de);F||ae(ue),d?.(ue);},[F,d]),le=useRef(null),X=useRef(false),[C,U]=useState(()=>{let de=Ts(an(t,o??r)),ue=Or(c??i??de??new Date),H=de&&ra(de,ue)?de:ra(ft(new Date),ue)?ft(new Date):ue;return Rs(H,f,h)}),ge=Ut(ye,S-1),B=Rr(C,ye)>=0&&Rr(C,ge)<=0?C:ye;useEffect(()=>{if(!X.current)return;X.current=false,le.current?.querySelector(`[data-day="${nn(C)}"]:not([data-outside])`)?.focus();},[C,ye]);let te=useCallback(de=>{let ue=Rs(ft(de),f,h);X.current=true,U(ue);let H=Ut(ye,S-1);Rr(ue,ye)<0?xe(ue):Rr(ue,H)>0&&xe(Ut(ue,-(S-1)));},[ye,S,f,h,xe]),me=useCallback(de=>x||f&&de<ft(f)||h&&de>ft(h)?true:typeof b=="function"?b(de):Array.isArray(b)?b.some(ue=>tr(ue,de)):false,[x,f,h,b]),[Se,j]=useState(null),Te=useCallback(de=>{Q||we(de),n?.(de);},[Q,n]),Pe=useCallback(de=>{let ue=ft(de);if(me(ue))return;if(t==="multiple"){let O=he??[];if(O.some(ne=>tr(ne,ue))){Te(O.filter(ne=>!tr(ne,ue)));return}if(a!==void 0&&O.length>=a)return;Te([...O,ue].sort((ne,Ne)=>ne.getTime()-Ne.getTime()));return}if(t==="range"){let O=he??{from:null,to:null};if(!O.from||O.to){Te({from:ue,to:null});return}Te(ue<O.from?{from:ue,to:O.from}:{from:O.from,to:ue});return}Te(tr(he,ue)?null:ue);},[t,he,a,Te,me]),et=useCallback(de=>{Pe(de),U(ft(de)),Rr(de,ye)<0?xe(de):Rr(de,Ut(ye,S-1))>0&&xe(Ut(de,-(S-1)));},[Pe,ye,S,xe]),at=!x&&(!f||Rr(ye,Or(f))>0),pt=!x&&(!h||Rr(Ut(ye,S-1),Or(h))<0),J=useCallback(()=>{xe(Ut(ye,-1));},[ye,xe]),fe=useCallback(()=>{xe(Ut(ye,1));},[ye,xe]),Ke=useCallback(de=>{if(x)return;let ue=C;switch(de.key){case "ArrowLeft":de.preventDefault(),te(fr(ue,-1));break;case "ArrowRight":de.preventDefault(),te(fr(ue,1));break;case "ArrowUp":de.preventDefault(),te(fr(ue,-7));break;case "ArrowDown":de.preventDefault(),te(fr(ue,7));break;case "Home":de.preventDefault(),te(fr(ue,-((ue.getDay()-u+7)%7)));break;case "End":de.preventDefault(),te(fr(ue,6-(ue.getDay()-u+7)%7));break;case "PageUp":{de.preventDefault();let H=de.shiftKey?-12:-1,O=Ut(ue,H),se=Math.min(ue.getDate(),oa(O));te(new Date(O.getFullYear(),O.getMonth(),se));break}case "PageDown":{de.preventDefault();let H=de.shiftKey?12:1,O=Ut(ue,H),se=Math.min(ue.getDate(),oa(O));te(new Date(O.getFullYear(),O.getMonth(),se));break}}},[x,C,te,u]),xt=useMemo(()=>{let de=new Intl.DateTimeFormat(p,{weekday:"short"}),ue=new Intl.DateTimeFormat(p,{weekday:"long"}),H=new Date(2024,0,7);return Array.from({length:7},(O,se)=>{let ne=fr(H,(u+se)%7);return {short:de.format(ne),long:ue.format(ne)}})},[p,u]),Ee=useMemo(()=>{let de=new Intl.DateTimeFormat(p,{month:"long"});return Array.from({length:12},(ue,H)=>de.format(new Date(2024,H,1)))},[p]),We=useMemo(()=>new Intl.DateTimeFormat(p,{month:"long",year:"numeric"}),[p]),ht=useMemo(()=>new Intl.DateTimeFormat(p,{dateStyle:"full"}),[p]),cr=useMemo(()=>{if(N!=="dropdown")return [];let de=T.getFullYear(),ue=E??f?.getFullYear()??de-100,H=M??h?.getFullYear()??de+10;return H<ue?[ue]:Array.from({length:H-ue+1},(O,se)=>ue+se)},[N,E,M,f,h,T]),ct=t==="range"?he:null,Bt=ct&&ct.from&&!ct.to&&Se&&Se>ct.from?Se:null,Tt=ct?.to??Bt,Yt=useCallback((de,ue)=>{let H=!ra(de,ue),O=me(de),se=false,ne=false,Ne=false,be=false;return t==="multiple"?se=(he??[]).some(ke=>tr(ke,de)):t==="range"?(ne=tr(ct?.from,de),Ne=tr(Tt,de),se=ne||Ne,be=!!(ct?.from&&Tt&&de>ct.from&&de<Tt)):se=tr(he,de),{selected:se,today:tr(de,T),outside:H,disabled:O,rangeStart:ne,rangeEnd:Ne,inRange:be}},[t,he,ct,Tt,me,T]),Sr=de=>{let ue=Ut(ye,de),H=Wc(ue,u,D),O=de===0,se=de===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:J,disabled:!at,"aria-label":L?.previousMonth??"Previous month",className:s("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",Br[g],y.nav,!at&&"cursor-not-allowed opacity-40 hover:bg-transparent dark:hover:bg-transparent",!O&&"invisible"),children:jsx(Fc,{className:y.icon})}),N==="dropdown"?jsxs("div",{className:"flex items-center gap-1",children:[jsx("select",{"aria-label":L?.monthSelect??"Month",value:ue.getMonth(),disabled:x,onChange:ne=>xe(new Date(ue.getFullYear(),Number(ne.target.value)-de,1)),className:s("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",Br[g],y.select,x&&"cursor-not-allowed opacity-50"),children:Ee.map((ne,Ne)=>jsx("option",{value:Ne,children:ne},ne))}),jsx("select",{"aria-label":L?.yearSelect??"Year",value:ue.getFullYear(),disabled:x,onChange:ne=>xe(new Date(Number(ne.target.value),ue.getMonth()-de,1)),className:s("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",Br[g],y.select,x&&"cursor-not-allowed opacity-50"),children:cr.map(ne=>jsx("option",{value:ne,children:ne},ne))})]}):jsx("div",{"aria-live":"polite",className:s("font-semibold text-gray-900 dark:text-gray-100",y.caption),children:We.format(ue)}),jsx("button",{type:"button",onClick:fe,disabled:!pt,"aria-label":L?.nextMonth??"Next month",className:s("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",Br[g],y.nav,!pt&&"cursor-not-allowed opacity-40 hover:bg-transparent dark:hover:bg-transparent",!se&&"invisible"),children:jsx(Hc,{className:y.icon})})]}),jsxs("table",{role:"grid","aria-label":We.format(ue),className:"border-collapse",children:[jsx("thead",{children:jsxs("tr",{children:[k&&jsxs("th",{scope:"col",className:s("font-normal text-gray-400 dark:text-gray-500",y.head),children:[jsx("span",{className:"sr-only",children:L?.weekNumber??"Week number"}),jsx("span",{"aria-hidden":"true",children:"#"})]}),xt.map(ne=>jsx("th",{scope:"col",abbr:ne.long,className:s("font-medium uppercase text-gray-500 dark:text-gray-400",y.head),children:ne.short},ne.long))]})}),jsx("tbody",{children:H.map(ne=>jsxs("tr",{children:[k&&jsx("td",{className:s("text-center align-middle text-gray-400 dark:text-gray-500",y.head),children:Ac(ne[0])}),ne.map(Ne=>{let be=Yt(Ne,ue),ke=nn(Ne);if(be.outside&&!v)return jsx("td",{className:"p-0"},ke);let Ae=tr(Ne,B)&&!be.outside,Me=be.inRange||be.rangeStart&&!!Tt||be.rangeEnd&&!!ct?.from;return jsx("td",{role:"presentation",className:s("p-0",Me&&Vc[g],Me&&be.rangeStart&&"rounded-l-full",Me&&be.rangeEnd&&"rounded-r-full"),children:jsx("button",{type:"button","data-day":ke,"data-selected":be.selected||void 0,"data-today":be.today||void 0,"data-outside":be.outside||void 0,role:"gridcell",tabIndex:Ae?0:-1,disabled:x,"aria-selected":be.selected,"aria-disabled":be.disabled||void 0,"aria-current":be.today?"date":void 0,"aria-label":ht.format(Ne),onClick:()=>{be.disabled||et(Ne);},onMouseEnter:()=>t==="range"&&j(ft(Ne)),onMouseLeave:()=>t==="range"&&j(null),onFocus:()=>U(ft(Ne)),className:s("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",Br[g],y.day,be.selected?Oc[g]:be.inRange?s(_c[g],"hover:bg-gray-200/60 dark:hover:bg-gray-600/60"):be.today?s($c[g],"hover:bg-gray-100 dark:hover:bg-gray-700"):s("text-gray-900 dark:text-gray-100","hover:bg-gray-100 dark:hover:bg-gray-700"),be.outside&&!be.selected&&"text-gray-400 dark:text-gray-500",be.disabled&&"cursor-not-allowed opacity-40 hover:bg-transparent dark:hover:bg-transparent"),children:q?q(Ne,be):Ne.getDate()})},ke)})]},nn(ne[0])))})]})]},nn(ue))},Ot=useCallback(()=>{xe(T),U(T),me(T)||Pe(T);},[T,xe,me,Pe]),ur=useCallback(()=>{Te(t==="multiple"?[]:t==="range"?{from:null,to:null}:null);},[t,Te]),Xt=!!A||R||P;return jsxs("div",{ref:le,onKeyDown:Ke,className:s("inline-block bg-white dark:bg-gray-900",$&&"rounded-lg border border-gray-200 shadow-sm dark:border-gray-700",y.padding,x&&"opacity-60",_),...z,children:[jsx("div",{className:s("flex flex-wrap",y.gap),children:Array.from({length:S},(de,ue)=>Sr(ue))}),Xt&&jsxs("div",{className:s("mt-3 flex items-center justify-between gap-2 border-t border-gray-200 pt-3 dark:border-gray-700",y.footer),children:[jsx("div",{className:"text-gray-600 dark:text-gray-400",children:A}),(R||P)&&jsxs("div",{className:"flex items-center gap-2",children:[R&&jsx("button",{type:"button",onClick:Ot,disabled:x,className:s("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",Br[g],x&&"cursor-not-allowed opacity-50"),children:L?.today??"Today"}),P&&jsx("button",{type:"button",onClick:ur,disabled:x,className:s("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",Br[g],x&&"cursor-not-allowed opacity-50"),children:L?.clear??"Clear"})]})]})]})}function Gc(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 s("border-2 bg-transparent",n);case "elevated":return s("shadow-lg border-0",o);case "filled":return s(r||"bg-gray-100 dark:bg-gray-700","border-0");default:return s("border",n,o)}}function Kc(e){switch(e){case "sm":return "max-w-sm";case "lg":return "max-w-2xl";default:return "max-w-md"}}function Yc(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 Xc(e){switch(e){case "none":return "";case "sm":return "p-2";case "lg":return "p-6";default:return ""}}function Ds({variant:e="default",size:t="md",rounded:r="lg",padding:o="none",bgColor:n,borderColor:a,shadowColor:i,hoverable:c=false,clickable:d=false,as:l="div",className:u,children:p,onClick:m,...g}){let f=l,h=c?"transition-all duration-200 hover:shadow-lg hover:-translate-y-0.5":"",b=d?"cursor-pointer active:scale-[0.98] transition-transform":"",x=i||"";return jsx(f,{className:s("overflow-hidden",Gc(e,a,n),Kc(t),Yc(r),Xc(o),h,b,x,u),onClick:d||m?m:void 0,...g,children:p})}Ds.displayName="Card";function qc(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 Is({actions:e,divider:t=false,padding:r="md",className:o,children:n,...a}){return jsxs("div",{className:s("flex items-center justify-between",qc(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})]})}Is.displayName="CardHeader";function Zc(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 Ms({padding:e="md",className:t,children:r,...o}){return jsx("div",{className:s(Zc(e),t),...o,children:r})}Ms.displayName="CardBody";function eu(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 tu(e){switch(e){case "center":return "justify-center";case "right":return "justify-end";case "between":return "justify-between";default:return "justify-start"}}function Ps({divider:e=false,align:t="left",padding:r="md",className:o,children:n,...a}){return jsx("div",{className:s("flex items-center gap-2",eu(r),tu(t),e&&"border-t border-gray-200 dark:border-gray-700",o),...a,children:n})}Ps.displayName="CardFooter";function ou(e){switch(e){case "square":return "aspect-square";case "video":return "aspect-video";case "wide":return "aspect-[21/9]";default:return ""}}function nu(e){switch(e){case "contain":return "object-contain";case "fill":return "object-fill";case "none":return "object-none";default:return "object-cover"}}function Ls({position:e="top",aspectRatio:t="auto",objectFit:r="cover",src:o,alt:n,className:a,...i}){let c=e==="top"?"rounded-t-lg":"rounded-b-lg";return jsx("img",{src:o,alt:n,className:s("w-full",ou(t),nu(r),c,a),...i})}Ls.displayName="CardImage";function su(e){switch(e){case "sm":return "text-base font-medium";case "lg":return "text-2xl font-bold";default:return "text-xl font-semibold"}}function zs({as:e="h3",size:t="md",className:r,children:o,...n}){return jsx(e,{className:s("text-gray-900 dark:text-white",su(t),r),...n,children:o})}zs.displayName="CardTitle";function lu(e){switch(e){case "sm":return "text-xs";case "lg":return "text-base";default:return "text-sm"}}function As({size:e="md",className:t,children:r,...o}){return jsx("p",{className:s("text-gray-500 dark:text-gray-400",lu(e),t),...o,children:r})}As.displayName="CardDescription";var mu=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"}}},bu=e=>{switch(e){case "circle":return "rounded-full";case "rounded":return "rounded-md";default:return "rounded"}},hu=({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"})}),yu=({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"})}),Do=forwardRef(({checked:e,defaultChecked:t=false,onChange:r,disabled:o=false,readOnly:n=false,required:a=false,name:i,value:c,id:d,label:l,description:u,error:p=false,size:m="md",labelPosition:g="right",checkedColor:f="bg-blue-600",uncheckedColor:h="bg-white dark:bg-gray-800",borderColor:b="border-gray-300 dark:border-gray-600",labelColor:x,errorColor:v="text-red-500",checkmarkColor:k="text-white",hoverColor:D,focusRingColor:N="ring-blue-500",indeterminate:E=false,icon:M,variant:R="default",shape:P="square",animation:A=true,showFocusRing:$=true,className:q,containerClassName:L,style:_,tabIndex:z,...y},S)=>{let T=useId(),Q=d||T,ie=`${Q}-error`,we=`${Q}-description`,[he,F]=useState(t),ee=e!==void 0,ae=ee?e:he,ye=useRef(null);useEffect(()=>{ye.current&&(ye.current.indeterminate=E);},[E]);let xe=re=>{if(o||n)return;let B=re.target.checked;ee||F(B),r?.(B,re);},le=mu(m),X=bu(P),C=()=>{let re=s("relative flex items-center justify-center border-2 transition-all",le.checkbox,X,A&&"duration-200 ease-in-out");return o?s(re,"opacity-50 cursor-not-allowed",ae||E?f:h,b):R==="filled"?s(re,ae||E?f:"bg-gray-100 dark:bg-gray-700",ae||E?"border-transparent":b,D&&!n&&`hover:${D}`,"cursor-pointer"):R==="outlined"?s(re,h,ae||E?`border-current ${f.replace("bg-","text-")}`:b,"border-2",D&&!n&&`hover:${D}`,"cursor-pointer"):s(re,ae||E?f:h,ae||E?"border-transparent":b,D&&!n&&`hover:${D}`,"cursor-pointer")},U=p!==false,ge=typeof p=="string"?p:void 0;return jsxs("div",{className:s("inline-flex flex-col",L),children:[jsxs("label",{htmlFor:Q,className:s("inline-flex items-start gap-2",o?"cursor-not-allowed":"cursor-pointer",g==="left"&&"flex-row-reverse justify-end"),children:[jsx("input",{ref:re=>{ye&&(ye.current=re),typeof S=="function"?S(re):S&&(S.current=re);},type:"checkbox",id:Q,name:i,value:c,checked:ae,onChange:xe,disabled:o,readOnly:n,required:a,tabIndex:n?-1:z,"aria-invalid":U,"aria-describedby":s(ge&&ie,u&&we),className:"sr-only peer",style:_,...y}),jsx("span",{className:s(C(),$&&`peer-focus-visible:ring-2 peer-focus-visible:ring-offset-2 peer-focus-visible:${N}`,A&&ae&&"scale-100",U&&"border-red-500"),"aria-hidden":"true",children:(ae||E)&&jsx("span",{className:s(k,A&&"animate-in zoom-in-50 duration-200"),children:E?M||jsx(yu,{className:"w-full h-full"}):M||jsx(hu,{className:"w-full h-full"})})}),l&&jsxs("span",{className:"flex flex-col gap-1",children:[jsxs("span",{className:s(le.label,o&&"opacity-50",x,U&&v),children:[l,a&&jsx("span",{className:"text-red-500 ml-1",children:"*"})]}),u&&jsx("span",{id:we,className:s(le.description,"text-gray-500 dark:text-gray-400",o&&"opacity-50"),children:u})]})]}),ge&&jsx("p",{id:ie,className:s("mt-1 text-xs",v),children:ge})]})});Do.displayName="Checkbox";var Ws=createContext(null),Fs=({label:e,description:t,value:r,defaultValue:o=[],onChange:n,orientation:a="vertical",spacing:i="md",disabled:c=false,size:d="md",error:l=false,required:u=false,children:p,className:m,labelClassName:g,...f})=>{let[h,b]=ta.useState(o),x=r!==void 0,v=x?r:h,k=ta.useCallback(R=>{let P=v.includes(R)?v.filter(A=>A!==R):[...v,R];x||b(P),n?.(P);},[v,x,n]),D=ta.useMemo(()=>({value:v,onChange:k,disabled:c,size:d}),[v,k,c,d]),N={sm:a==="vertical"?"gap-2":"gap-3",md:a==="vertical"?"gap-3":"gap-4",lg:a==="vertical"?"gap-4":"gap-6"},E=l!==false,M=typeof l=="string"?l:void 0;return jsxs("div",{className:s("flex flex-col gap-2",m),...f,children:[(e||t)&&jsxs("div",{className:"flex flex-col gap-1",children:[e&&jsxs("label",{className:s("text-sm font-medium text-gray-900 dark:text-gray-100",c&&"opacity-50",E&&"text-red-500",g),children:[e,u&&jsx("span",{className:"text-red-500 ml-1",children:"*"})]}),t&&jsx("p",{className:s("text-xs text-gray-500 dark:text-gray-400",c&&"opacity-50"),children:t})]}),jsx(Ws.Provider,{value:D,children:jsx("div",{className:s("flex",a==="vertical"?"flex-col":"flex-row flex-wrap",N[i]),role:"group",children:p})}),M&&jsx("p",{className:"text-xs text-red-500",children:M})]})};Fs.displayName="CheckboxGroup";var Hs=({value:e,disabled:t,size:r,...o})=>{let n=useContext(Ws);if(!n)return console.warn("CheckboxGroupItem doit \xEAtre utilis\xE9 dans un CheckboxGroup"),jsx(Do,{...o,disabled:t,size:r});let{value:a,onChange:i,disabled:c,size:d}=n,l=a.includes(e);return jsx(Do,{...o,checked:l,onChange:()=>i(e),disabled:c||t,size:r||d})};Hs.displayName="CheckboxGroupItem";var St={compact:"px-3 py-1.5",default:"px-4 py-3",comfortable:"px-6 py-4"},dn={compact:"text-xs",default:"text-sm",comfortable:"text-base"},Nu=()=>jsx("svg",{className:"w-3.5 h-3.5",viewBox:"0 0 16 16",fill:"currentColor",children:jsx("path",{d:"M8 3l4 5H4l4-5z"})}),Su=()=>jsx("svg",{className:"w-3.5 h-3.5",viewBox:"0 0 16 16",fill:"currentColor",children:jsx("path",{d:"M8 13l4-5H4l4 5z"})}),Ru=()=>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"})}),Bs=({className:e})=>jsx("svg",{className:s("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"})}),Tu=()=>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"})}),Du=()=>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"})}),Eu=()=>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"})}),Iu=()=>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"})]}),Mu=()=>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 ln(e,t,r){return typeof r=="function"?r(e,t):String(typeof r=="string"?e[r]:t)}function or(e,t){return e[t]}function Pu(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 Lu(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 Os(e,t,r){let o=[];for(let n of e){let a=Number(or(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 zu({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:St[t],children:jsx("div",{className:"h-4 bg-gray-200 dark:bg-gray-700 rounded animate-pulse"})},o))})}function Au({column:e,value:t,onApply:r,onClear:o}){let[n,a]=useState(false),[i,c]=useState(t?.operator??"contains"),[d,l]=useState(t?.value??""),u=useRef(null),p=e.filterType??"text",m=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 g=f=>{u.current&&!u.current.contains(f.target)&&a(false);};return n&&document.addEventListener("mousedown",g),()=>document.removeEventListener("mousedown",g)},[n]),jsxs("div",{className:"relative inline-block",ref:u,children:[jsx("button",{type:"button",onClick:g=>{g.stopPropagation(),a(!n);},className:s("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(Eu,{})}),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(g=>jsxs("label",{className:"flex items-center gap-2 text-sm cursor-pointer",children:[jsx("input",{type:"radio",name:`filter-${e.key}`,value:g,checked:d===g,onChange:()=>l(g),className:"cursor-pointer"}),jsx("span",{className:"text-gray-700 dark:text-gray-300",children:g})]},g)),jsxs("div",{className:"flex gap-2 mt-2",children:[jsx("button",{type:"button",onClick:()=>{r({column:e.key,operator:"equals",value:d}),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:()=>{l(""),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:i,onChange:g=>c(g.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:m.map(g=>jsx("option",{value:g.value,children:g.label},g.value))}),i!=="isEmpty"&&i!=="isNotEmpty"&&jsx("input",{type:p==="number"?"number":p==="date"?"date":"text",value:d,onChange:g=>l(g.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:i,value:d}),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:()=>{l(""),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 Wu({value:e,onSave:t,density:r}){let[o,n]=useState(false),[a,i]=useState(String(e??"")),c=useRef(null);if(useEffect(()=>{o&&c.current&&(c.current.focus(),c.current.select());},[o]),!o)return jsx("div",{onDoubleClick:()=>{i(String(e??"")),n(true);},className:"cursor-text min-h-[1.5em]",title:"Double-click to edit",children:String(e??"")});let d=()=>{n(false),a!==String(e??"")&&t(a);};return jsx("input",{ref:c,type:"text",value:a,onChange:l=>i(l.target.value),onBlur:d,"aria-label":"Edit cell value",onKeyDown:l=>{l.key==="Enter"&&d(),l.key==="Escape"&&n(false);},className:s("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",dn[r])})}function Fu(e,t){let{columns:r,data:o,rowKey:n,mode:a="client",sortable:i=false,multiSort:c=false,sort:d,defaultSort:l,onSort:u,pagination:p=false,page:m,onPageChange:g,onPageSizeChange:f,totalItems:h,selectable:b=false,selectionMode:x="multiple",selectedRows:v,onSelectionChange:k,searchable:D=false,searchPlaceholder:N="Search...",searchValue:E,onSearch:M,filters:R,onFilterChange:P,expandable:A=false,expandedContent:$,expandedRows:q,onExpandChange:L,editable:_=false,onCellEdit:z,reorderable:y=false,onReorder:S,columnReorderable:T=false,onColumnReorder:Q,columnToggle:ie=false,hiddenColumns:we,onColumnVisibilityChange:he,groupBy:F,renderGroupHeader:ee,exportable:ae=false,exportFormats:ye=["csv","json"],exportFilename:xe="export",virtualized:le=false,rowHeight:X=40,virtualHeight:C=400,density:U="default",striped:ge=false,bordered:re=false,borderless:B=false,stickyHeader:te=false,maxHeight:me,loading:Se=false,loadingRows:j=5,emptyState:Te,showFooter:Pe=false,onRowClick:et,onRowDoubleClick:at,onRowContextMenu:pt,className:J,rowClassName:fe,cellClassName:Ke,headerClassName:xt}=e,[Ee,We]=useState(l??[]),[ht,cr]=useState(1),[ct,Bt]=useState(typeof p=="object"?p.pageSize??10:10),[Tt,Yt]=useState([]),[Sr,Ot]=useState(""),[ur,Xt]=useState([]),[de,ue]=useState([]),[H,O]=useState(()=>r.flatMap(w=>w.hidden?[w.key]:[])),[se,ne]=useState({}),[Ne,be]=useState(()=>r.map(w=>w.key)),[ke,Ae]=useState(null),[Me,Qe]=useState(null),[Ye,Oe]=useState(false),[vt,tt]=useState(new Set),Vt=useRef(null),[pr,Wr]=useState(0),Jr=useRef(null),jt=d??Ee,_t=m??ht,I=v??Tt,V=E??Sr,G=R??ur,K=q??de,oe=we??H,Fe=p?typeof p=="object"?p:{pageSize:10,pageSizeOptions:[10,25,50,100]}:null,Ge=Fe?.pageSize??ct,Ve=useMemo(()=>{let w=new Map(r.map(Ce=>[Ce.key,Ce])),W=Ne.flatMap(Ce=>{let Le=w.get(Ce);return Le?[Le]:[]}),Z=new Set(W.map(Ce=>Ce.key));for(let Ce of r)Z.has(Ce.key)||(W.push(Ce),Z.add(Ce.key));return W.filter(Ce=>!oe.includes(Ce.key))},[r,Ne,oe]),Ie=useMemo(()=>{if(a==="server")return o;let w=[...o];if(V){let W=V.toLowerCase();w=w.filter(Z=>Ve.some(Ce=>{let Le=or(Z,Ce.key);return String(Le??"").toLowerCase().includes(W)}));}if(G.length>0&&(w=w.filter(W=>G.every(Z=>Lu(or(W,Z.column),Z)))),jt.length>0){let W=new Map(r.map(Z=>[Z.key,Z]));w.sort((Z,Ce)=>{for(let Le of jt){if(!Le.direction)continue;let it=W.get(Le.key),It=it?.sortComparator?it.sortComparator(Z,Ce):Pu(or(Z,Le.key),or(Ce,Le.key));if(It!==0)return Le.direction==="asc"?It:-It}return 0});}return w},[o,a,V,G,jt,Ve,r]),wt=useMemo(()=>{if(!F)return null;let w=Array.isArray(F)?F:[F],W=new Map;for(let Z of Ie){let Ce=w.map(it=>String(or(Z,it)??"")).join(" / "),Le=W.get(Ce)??[];Le.push(Z),W.set(Ce,Le);}return W},[Ie,F]),_e=h??Ie.length,st=Math.max(1,Math.ceil(_e/Ge)),gt=useMemo(()=>{if(!Fe||a==="server")return Ie;let w=(_t-1)*Ge;return Ie.slice(w,w+Ge)},[Ie,Fe,_t,Ge,a]),rt=Fe?gt:Ie,Nt=useMemo(()=>{if(!le)return {start:0,end:rt.length};let w=Math.floor(pr/X),W=Math.ceil(C/X),Z=5;return {start:Math.max(0,w-Z),end:Math.min(rt.length,w+W+Z)}},[le,pr,X,C,rt.length]),qt=useCallback(w=>{d||We(w),u?.(w);},[d,u]),Jt=useCallback(w=>{let W=jt.find(Ce=>Ce.key===w),Z;if(!W||!W.direction?Z="asc":W.direction==="asc"?Z="desc":Z=null,c){let Ce=jt.filter(Le=>Le.key!==w);Z&&Ce.push({key:w,direction:Z}),qt(Ce);}else qt(Z?[{key:w,direction:Z}]:[]);},[jt,c,qt]),Pt=useCallback(w=>{let W=Math.max(1,Math.min(w,st));m||cr(W),g?.(W);},[m,g,st]),$n=useCallback(w=>{Bt(w),Pt(1),f?.(w);},[Pt,f]),Qo=useCallback(w=>{let W;x==="single"?W=I.includes(w)?[]:[w]:W=I.includes(w)?I.filter(Z=>Z!==w):[...I,w],v||Yt(W),k?.(W);},[x,I,v,k]),Un=useCallback(()=>{let w=rt.map((W,Z)=>ln(W,Z,n));v||Yt(w),k?.(w);},[rt,n,v,k]),Gn=useCallback(()=>{v||Yt([]),k?.([]);},[v,k]),Kn=rt.length>0&&rt.every((w,W)=>I.includes(ln(w,W,n))),xd=!Kn&&rt.some((w,W)=>I.includes(ln(w,W,n))),vd=useCallback(w=>{let W=K.includes(w)?K.filter(Z=>Z!==w):[...K,w];q||ue(W),L?.(W);},[K,q,L]),wd=useCallback(w=>{let W=w.target.value;E||Ot(W),M?.(W),Pt(1);},[E,M,Pt]),kd=useCallback(w=>{let W=[...G.filter(Z=>Z.column!==w.column),w];R||Xt(W),P?.(W);},[G,R,P]),Cd=useCallback(w=>{let W=G.filter(Z=>Z.column!==w);R||Xt(W),P?.(W);},[G,R,P]),Nd=useCallback(w=>{let W=oe.includes(w)?oe.filter(Z=>Z!==w):[...oe,w];we||O(W),he?.(W);},[oe,we,he]),Sd=useCallback((w,W)=>{w.preventDefault(),w.stopPropagation();let Z=w.clientX,Ce=se[W]??w.currentTarget.parentElement?.getBoundingClientRect().width??100,Le=r.find(Mt=>Mt.key===W),it=Le?.minWidth??50,It=Le?.maxWidth??1/0,Xe=Mt=>{let Fr=Mt.clientX-Z,Qt=Math.min(It,Math.max(it,Ce+Fr));ne(Qr=>({...Qr,[W]:Qt}));},Zt=()=>{document.removeEventListener("mousemove",Xe),document.removeEventListener("mouseup",Zt);};document.addEventListener("mousemove",Xe),document.addEventListener("mouseup",Zt);},[se,r]),Rd=useCallback(w=>{y&&Ae(w);},[y]),Td=useCallback((w,W)=>{!y||ke===null||w.preventDefault();},[y,ke]),Dd=useCallback(w=>{!y||ke===null||ke===w||(S?.(ke,w),Ae(null));},[y,ke,S]),Ed=useCallback(w=>{T&&Qe(w);},[T]),Id=useCallback(w=>{if(!T||!Me||Me===w)return;let W=[...Ne],Z=W.indexOf(Me),Ce=W.indexOf(w);Z===-1||Ce===-1||(W.splice(Z,1),W.splice(Ce,0,Me),be(W),Q?.(Me,w),Qe(null));},[T,Me,Ne,Q]),Yn=useCallback(w=>{let W=Ve.filter(Mt=>Mt.type!=="actions"&&Mt.type!=="selection"&&Mt.type!=="expand"),Z=Ie,Ce,Le,it;if(w==="csv"){let Mt=W.map(Qt=>String(Qt.header)).join(","),Fr=Z.map(Qt=>W.map(Qr=>{let qn=String(or(Qt,Qr.key)??"");return qn.includes(",")?`"${qn}"`:qn}).join(","));Ce=[Mt,...Fr].join(`
2
- `),Le="text/csv",it="csv";}else {let Mt=Z.map(Fr=>{let Qt={};for(let Qr of W)Qt[Qr.key]=or(Fr,Qr.key);return Qt});Ce=JSON.stringify(Mt,null,2),Le="application/json",it="json";}let It=new Blob([Ce],{type:Le}),Xe=URL.createObjectURL(It),Zt=document.createElement("a");Zt.href=Xe,Zt.download=`${xe}.${it}`,Zt.click(),URL.revokeObjectURL(Xe);},[Ve,Ie,xe]);useEffect(()=>{if(!Ye)return;let w=W=>{Jr.current&&!Jr.current.contains(W.target)&&Oe(false);};return document.addEventListener("mousedown",w),()=>document.removeEventListener("mousedown",w)},[Ye]),useImperativeHandle(t,()=>({getVisibleData:()=>rt,resetFilters:()=>{R||Xt([]),E||Ot(""),P?.([]),M?.("");},resetSort:()=>{d||We([]),u?.([]);},selectAll:Un,deselectAll:Gn,exportData:Yn,scrollToRow:w=>{Vt.current&&le&&(Vt.current.scrollTop=w*X);}}),[rt,R,E,d,P,M,u,Un,Gn,Yn,le,X]);let Xn=w=>{let W={},Z=se[w.key]??w.width;return Z&&(W.width=typeof Z=="number"?`${Z}px`:Z,W.minWidth=typeof Z=="number"?`${Z}px`:Z),w.sticky&&(W.position="sticky",W[w.sticky]=0,W.zIndex=10),W},Zr=Ve.length+(b?1:0)+(A?1:0)+(y?1:0),Md=w=>{let W=i&&w.sortable!==false&&w.type!=="actions",Z=jt.find(Le=>Le.key===w.key),Ce=w.filterable&&(w.filterType||w.filterOptions);return jsxs("th",{className:s(St[U],dn[U],"font-semibold text-gray-700 dark:text-gray-300 whitespace-nowrap",w.align==="center"&&"text-center",w.align==="right"&&"text-right",W&&"cursor-pointer select-none hover:bg-gray-100 dark:hover:bg-gray-700",re&&"border border-gray-200 dark:border-gray-700",w.sticky&&"bg-gray-50 dark:bg-gray-800",w.headerClassName,xt),style:Xn(w),onClick:W?()=>Jt(w.key):void 0,draggable:T,onDragStart:T?()=>Ed(w.key):void 0,onDragOver:T?Le=>Le.preventDefault():void 0,onDrop:T?()=>Id(w.key):void 0,"aria-sort":Z?.direction==="asc"?"ascending":Z?.direction==="desc"?"descending":void 0,children:[jsxs("div",{className:"flex items-center gap-1",children:[w.renderHeader?w.renderHeader(w):w.header,W&&jsx("span",{className:"inline-flex ml-1",children:Z?.direction==="asc"?jsx(Nu,{}):Z?.direction==="desc"?jsx(Su,{}):jsx(Ru,{})}),Ce&&jsx(Au,{column:w,value:G.find(Le=>Le.column===w.key),onApply:kd,onClear:()=>Cd(w.key)})]}),w.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=>Sd(Le,w.key)})]},w.key)},jn=(w,W,Z)=>{let Ce=ln(w,Z,n),Le=I.includes(Ce),it=K.includes(Ce),It=typeof fe=="function"?fe(w,Z):fe;return jsxs(ta__default.Fragment,{children:[jsxs("tr",{className:s("border-b border-gray-200 dark:border-gray-700 transition-colors",ge&&Z%2===1&&"bg-gray-50/50 dark:bg-gray-800/50",Le&&"bg-blue-50 dark:bg-blue-900/20",et&&"cursor-pointer hover:bg-gray-50 dark:hover:bg-gray-700/50",ke===W&&"opacity-50",It),onClick:et?()=>et(w,Z):void 0,onDoubleClick:at?()=>at(w,Z):void 0,onContextMenu:pt?Xe=>pt(w,Z,Xe):void 0,draggable:y,onDragStart:y?()=>Rd(W):void 0,onDragOver:y?Xe=>Td(Xe,W):void 0,onDrop:y?()=>Dd(W):void 0,"data-row-key":Ce,"aria-selected":b?Le:void 0,children:[y&&jsx("td",{className:s(St[U],"cursor-grab active:cursor-grabbing"),children:jsx(Du,{})}),b&&jsx("td",{className:s(St[U],"w-10"),children:jsx("input",{type:"checkbox",checked:Le,onChange:()=>Qo(Ce),onClick:Xe=>Xe.stopPropagation(),className:"rounded border-gray-300 dark:border-gray-600 cursor-pointer","aria-label":`Select row ${Ce}`})}),A&&jsx("td",{className:s(St[U],"w-10"),children:jsx("button",{type:"button",onClick:Xe=>{Xe.stopPropagation(),vd(Ce);},className:"p-0.5 rounded hover:bg-gray-200 dark:hover:bg-gray-600 cursor-pointer","aria-label":it?"Collapse row":"Expand row","aria-expanded":it,children:jsx(Bs,{className:s("transition-transform",it&&"rotate-180")})})}),Ve.map(Xe=>{let Zt=or(w,Xe.key),Mt=Xe.colSpan?.(w,Z);if(Mt===0)return null;let Fr=_&&Xe.editable!==false&&Xe.type!=="actions";return jsx("td",{className:s(St[U],dn[U],"text-gray-700 dark:text-gray-300",Xe.align==="center"&&"text-center",Xe.align==="right"&&"text-right",re&&"border border-gray-200 dark:border-gray-700",Xe.sticky&&(Le?"bg-blue-50 dark:bg-blue-900/20":ge&&Z%2===1?"bg-gray-50/50 dark:bg-gray-800/50":"bg-white dark:bg-gray-900"),Xe.cellClassName,Ke),style:Xn(Xe),colSpan:Mt,children:Fr?jsx(Wu,{value:Zt,onSave:Qt=>z?.(Ce,Xe.key,Qt),density:U}):Xe.render?Xe.render(Zt,w,Z):String(Zt??"")},Xe.key)})]}),A&&it&&$&&jsx("tr",{className:"bg-gray-50 dark:bg-gray-800/70",children:jsx("td",{colSpan:Zr,className:s(St[U]),children:$(w,Z)})})]},Ce)},Pd=()=>{if(Se)return Array.from({length:j}).map((w,W)=>jsx(zu,{cols:Zr,density:U},W));if(rt.length===0)return jsx("tr",{children:jsx("td",{colSpan:Zr,className:s("text-center text-gray-400 dark:text-gray-500",St[U]),children:Te??"No data available"})});if(wt){let w=[],W=0;for(let[Z,Ce]of wt){let Le=vt.has(Z);if(w.push(jsx("tr",{className:"bg-gray-100 dark:bg-gray-800 font-medium",children:jsx("td",{colSpan:Zr,className:s(St[U],"cursor-pointer"),onClick:()=>{tt(it=>{let It=new Set(it);return It.has(Z)?It.delete(Z):It.add(Z),It});},children:jsxs("div",{className:"flex items-center gap-2",children:[jsx(Bs,{className:s("transition-transform",Le&&"-rotate-90")}),ee?ee(Z,or(Ce[0],Array.isArray(F)?F[0]:F),Ce):`${Z} (${Ce.length})`]})})},`group-${Z}`)),Le)W+=Ce.length;else for(let it=0;it<Ce.length;it++)w.push(jn(Ce[it],W,W)),W++;}return w}if(le){let w=[];for(let W=Nt.start;W<Nt.end;W++)w.push(jn(rt[W],W,W));return jsxs(Fragment,{children:[Nt.start>0&&jsx("tr",{children:jsx("td",{colSpan:Zr,style:{height:Nt.start*X,padding:0}})}),w,Nt.end<rt.length&&jsx("tr",{children:jsx("td",{colSpan:Zr,style:{height:(rt.length-Nt.end)*X,padding:0}})})]})}return rt.map((w,W)=>jn(w,W,W))},Ld=()=>!Pe||!Ve.some(W=>W.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:[y&&jsx("td",{className:St[U]}),b&&jsx("td",{className:St[U]}),A&&jsx("td",{className:St[U]}),Ve.map(W=>jsx("td",{className:s(St[U],dn[U],"text-gray-700 dark:text-gray-300",W.align==="center"&&"text-center",W.align==="right"&&"text-right",re&&"border border-gray-200 dark:border-gray-700"),style:Xn(W),children:W.aggregate?W.renderAggregate?W.renderAggregate(Os(Ie,W.key,W.aggregate),Ie):`${W.aggregate==="count"?"":W.aggregate==="avg"?"Avg: ":W.aggregate==="sum"?"Total: ":W.aggregate==="min"?"Min: ":"Max: "}${Os(Ie,W.key,W.aggregate).toLocaleString()}`:""},W.key))]})});return jsxs("div",{className:s("flex flex-col gap-3",J),children:[(D||ae||ie)&&jsxs("div",{className:"flex items-center justify-between gap-3 flex-wrap",children:[jsxs("div",{className:"flex items-center gap-3 flex-1",children:[D&&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(Tu,{})}),jsx("input",{type:"text",value:V,onChange:wd,placeholder:N,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"})]}),I.length>0&&jsxs("span",{className:"text-sm text-gray-500 dark:text-gray-400",children:[I.length," selected"]})]}),jsxs("div",{className:"flex items-center gap-2",children:[ie&&jsxs("div",{className:"relative",ref:Jr,children:[jsx("button",{type:"button",onClick:()=>Oe(!Ye),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(Mu,{})}),Ye&&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(w=>w.type!=="selection"&&w.type!=="expand").map(w=>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:!oe.includes(w.key),onChange:()=>Nd(w.key),className:"rounded border-gray-300 dark:border-gray-600 cursor-pointer"}),jsx("span",{className:"text-gray-700 dark:text-gray-300",children:String(w.header)})]},w.key))})]}),ae&&ye.map(w=>jsxs("button",{type:"button",onClick:()=>Yn(w),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 ${w.toUpperCase()}`,children:[jsx(Iu,{}),w.toUpperCase()]},w))]})]}),jsx("div",{ref:Vt,className:s("overflow-auto rounded-lg",!B&&"border border-gray-200 dark:border-gray-700",te&&"relative"),style:me?{maxHeight:typeof me=="number"?`${me}px`:me}:le?{maxHeight:C,overflow:"auto"}:void 0,onScroll:le?w=>Wr(w.target.scrollTop):void 0,children:jsxs("table",{className:"w-full text-left",children:[jsx("thead",{className:s("bg-gray-50 dark:bg-gray-800 text-xs uppercase",te&&"sticky top-0 z-20"),children:jsxs("tr",{children:[y&&jsx("th",{className:s(St[U],"w-10 font-semibold text-gray-700 dark:text-gray-300")}),b&&jsx("th",{className:s(St[U],"w-10"),children:x==="multiple"&&jsx("input",{type:"checkbox",checked:Kn,ref:w=>{w&&(w.indeterminate=xd);},onChange:Kn?Gn:Un,className:"rounded border-gray-300 dark:border-gray-600 cursor-pointer","aria-label":"Select all rows"})}),A&&jsx("th",{className:s(St[U],"w-10 font-semibold text-gray-700 dark:text-gray-300")}),Ve.map(Md)]})}),jsx("tbody",{children:Pd()}),Ld()]})}),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:[_e," item",_e!==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:Ge,onChange:w=>$n(Number(w.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(w=>jsx("option",{value:w,children:w},w))})]})]}),jsxs("div",{className:"flex items-center gap-1",children:[jsxs("span",{className:"mr-2",children:["Page ",_t," of ",st]}),jsx("button",{type:"button",onClick:()=>Pt(1),disabled:_t<=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:()=>Pt(_t-1),disabled:_t<=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:()=>Pt(_t+1),disabled:_t>=st,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:()=>Pt(st),disabled:_t>=st,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 Hu=forwardRef(Fu);function Ou({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 Vu={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"}},_u={default:"bg-gray-500",primary:"bg-blue-600",success:"bg-green-600",warning:"bg-yellow-500",error:"bg-red-600",info:"bg-cyan-600"},$u={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"},sa={sm:"w-3 h-3",md:"w-3.5 h-3.5",lg:"w-4 h-4"},Uu={sm:"w-4 h-4 -ml-1",md:"w-5 h-5 -ml-1.5",lg:"w-6 h-6 -ml-1.5"},Gu={sm:"w-1.5 h-1.5",md:"w-2 h-2",lg:"w-2.5 h-2.5"},Ku={none:"rounded-none",sm:"rounded-sm",md:"rounded-md",lg:"rounded-lg",full:"rounded-full"};function un({label:e,children:t,variant:r="solid",size:o="md",color:n="default",bgColor:a,textColor:i,borderColor:c,rounded:d="full",icon:l,endIcon:u,avatar:p,onClose:m,closable:g=false,clickable:f=false,selected:h=false,disabled:b=false,as:x="span",className:v,onClick:k,...D}){let N=x,E=s("inline-flex items-center justify-center font-medium transition-all",$u[o],Ku[d],r==="outlined"&&"border"),M=s(a||i||c?s(a,i,c):Vu[n][r]),R=h?"ring-2 ring-offset-1 ring-blue-500":"",P=f&&!b?"cursor-pointer hover:opacity-80 active:scale-95":"",A=b?"opacity-50 cursor-not-allowed":"",$=_=>{_.stopPropagation(),m?.();},q=_=>{b||k?.(_);},L=t??e;return jsxs(N,{className:s(E,M,R,P,A,v),onClick:q,"aria-disabled":b,...D,children:[r==="dot"&&jsx("span",{className:s("rounded-full shrink-0",Gu[o],_u[n]),"aria-hidden":"true"}),p&&jsx("span",{className:s("rounded-full overflow-hidden shrink-0",Uu[o]),children:p}),l&&!p&&jsx("span",{className:s("shrink-0",sa[o]),children:l}),L&&jsx("span",{className:"truncate",children:L}),u&&!g&&jsx("span",{className:s("shrink-0",sa[o]),children:u}),g&&jsx("button",{type:"button",onClick:$,disabled:b,className:s("shrink-0 rounded-full hover:bg-black/10 dark:hover:bg-white/10 p-0.5 -mr-1 transition-colors","focus:outline-none focus-visible:ring-2 focus-visible:ring-offset-1 focus-visible:ring-current",b&&"pointer-events-none"),"aria-label":"Remove",children:jsx(Ou,{className:sa[o]})})]})}un.displayName="Chip";var Ju=500,Zu=800,Qu=600;function e0(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,i=window.outerWidth??screen.availWidth,c=window.outerHeight??screen.availHeight;o.push(`left=${n+(i-e)/2}`),o.push(`top=${a+(c-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 t0(e,t){e.querySelectorAll("style").forEach(i=>{let c=t.createElement("style");c.textContent=i.textContent,t.head.appendChild(c);}),e.querySelectorAll('link[rel="stylesheet"]').forEach(i=>{let c=t.createElement("link");c.rel="stylesheet",c.href=i.href,i.crossOrigin&&(c.crossOrigin=i.crossOrigin),t.head.appendChild(c);});let n=e.documentElement.className;n&&(t.documentElement.className=n);let a=e.body.className;a&&(t.body.className=a);}function r0(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 i=t.createElement("style");i.textContent=a.textContent,t.head.appendChild(i);}else if(a instanceof HTMLLinkElement&&a.rel==="stylesheet"){let i=t.createElement("link");i.rel="stylesheet",i.href=a.href,t.head.appendChild(i);}});return r.observe(e.head,{childList:true}),r}var _s=forwardRef(function({children:t,detached:r,defaultDetached:o=false,onClose:n,onDetach:a,title:i="",width:c=Zu,height:d=Qu,left:l,top:u,center:p=true,copyStyles:m=true,closeOnParentUnmount:g=true,className:f,windowClassName:h,onPopupBlocked:b},x){let v=r!==void 0,[k,D]=useState(o),N=v?r:k,[E,M]=useState(null),R=useRef(null),P=useRef(null),A=useRef(null),$=useRef(false),q=useRef({width:c,height:d,left:l,top:u,center:p,shouldCopyStyles:m,title:i,windowClassName:h,closeOnParentUnmount:g});q.current={width:c,height:d,left:l,top:u,center:p,shouldCopyStyles:m,title:i,windowClassName:h,closeOnParentUnmount:g};let L=useCallback(()=>{P.current&&(clearInterval(P.current),P.current=null),A.current&&(A.current.disconnect(),A.current=null),M(null);},[]),_=useCallback(()=>{R.current&&!R.current.closed&&R.current.close(),R.current=null,L();},[L]),z=useCallback(()=>{if(typeof window>"u"||$.current||R.current&&!R.current.closed)return;$.current=true;let y=q.current,S=e0(y.width,y.height,{center:y.center,left:y.left,top:y.top}),T=window.open("","",S);if(!T){$.current=false,b?.();return}R.current=T,T.document.title=y.title||document.title;let Q=T.document.createElement("div");y.windowClassName&&(Q.className=y.windowClassName),T.document.body.appendChild(Q),M(Q),y.shouldCopyStyles&&(t0(document,T.document),A.current=r0(document,T.document)),P.current=setInterval(()=>{T.closed&&(L(),R.current=null,v||D(false),n?.());},Ju),$.current=false,a?.();},[v,n,a,b,L]);return useEffect(()=>{N?z():_();},[N,z,_]),useEffect(()=>{R.current&&!R.current.closed&&i&&(R.current.document.title=i);},[i]),useEffect(()=>()=>{q.current.closeOnParentUnmount&&R.current&&!R.current.closed&&R.current.close(),L(),R.current=null;},[L]),useImperativeHandle(x,()=>({detach:()=>{v||D(true);},attach:()=>{v||D(false);},get isDetached(){return v?!!r:k},get window(){return R.current}}),[v,r,k]),N&&E?createPortal(t,E):N?null:jsx("div",{className:s(f),children:t})});_s.displayName="Detachable";var a0={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}}},s0=({className:e})=>jsxs("svg",{className:s("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"})]}),i0=({className:e})=>jsxs("svg",{className:s("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"})]}),l0=({className:e})=>jsxs("svg",{className:s("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 Mo({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:s("flex items-center justify-center py-0.5",n),style:{fontSize:"8px"},children:jsx("span",{className:"font-medium",children:e})}):jsxs("div",{className:s("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(s0,{className:n}),jsx(i0,{className:n}),jsx(l0,{className:n})]})]})}function d0({theme:e}){let t=e==="dark";return jsxs("div",{className:s("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:s("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 c0({children:e,theme:t,screenW:r,screenH:o,showStatusBar:n,statusBarTime:a,frameColor:i,landscape:c=false}){let d=t==="dark",l=i??(d?"#1a1a1a":"#e5e7eb");if(c){let p=Math.round(o*.35);return jsxs("div",{className:"relative inline-flex flex-row items-center rounded-[2.5rem] shadow-xl",style:{backgroundColor:l,padding:"8px 12px",height:o+16},"data-testid":"device-frame","data-device":"phone",children:[jsx("div",{className:s("rounded-full mr-2",d?"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(Mo,{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:l,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(Mo,{time:a,theme:t,device:"phone"}),e]}),jsx("div",{className:s("rounded-full mt-2",d?"bg-gray-600":"bg-gray-400"),style:{width:Math.round(r*.35),height:4},"data-testid":"home-indicator"})]})}function u0({children:e,theme:t,screenW:r,screenH:o,showStatusBar:n,statusBarTime:a,frameColor:i}){return jsxs("div",{className:"relative inline-flex flex-col items-center rounded-[2rem] shadow-xl",style:{backgroundColor:i??(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(Mo,{time:a,theme:t,device:"android"}),e]})]})}function p0({children:e,theme:t,screenW:r,screenH:o,showStatusBar:n,statusBarTime:a,frameColor:i}){return jsxs("div",{className:"relative inline-flex flex-col items-center rounded-[1.5rem] shadow-xl",style:{backgroundColor:i??(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(Mo,{time:a,theme:t,device:"tablet"}),e]})]})}function g0({children:e,theme:t,screenW:r,screenH:o,frameColor:n}){let a=t==="dark",i=n??(a?"#1a1a1a":"#d1d5db"),c=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:i,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:s(a?"bg-gray-800":"bg-gray-400"),style:{width:r+16,height:3}}),jsx("div",{className:"rounded-b-xl shadow-lg",style:{backgroundColor:i,width:c,height:12,clipPath:"polygon(3% 0%, 97% 0%, 100% 100%, 0% 100%)"},"data-testid":"laptop-base"})]})}function f0({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:s(a?"bg-gray-800":"bg-gray-400"),style:{width:40,height:24},"data-testid":"monitor-stand"}),jsx("div",{className:s("rounded-t-sm",a?"bg-gray-800":"bg-gray-400"),style:{width:Math.round(r*.4),height:6,borderRadius:"2px 2px 4px 4px"}})]})}function m0({children:e,theme:t,screenW:r,screenH:o,showStatusBar:n,statusBarTime:a,frameColor:i}){let c=t==="dark",d=i??(c?"#1a1a1a":"#d1d5db"),l=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:s("rounded-t-lg",c?"bg-gray-800":"bg-gray-400"),style:{width:l,height:30},"data-testid":"watch-band"}),jsxs("div",{className:"relative rounded-[1.2rem] shadow-xl",style:{backgroundColor:d,padding:"8px 6px",width:r+12},children:[jsx("div",{className:s("absolute rounded-sm",c?"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(Mo,{time:a,theme:t,device:"watch"}),e]})]}),jsx("div",{className:s("rounded-b-lg",c?"bg-gray-800":"bg-gray-400"),style:{width:l,height:30}})]})}function b0({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(d0,{theme:t}),jsx("div",{className:"overflow-hidden bg-white",style:{width:r,height:o},children:e})]})}function h0({device:e="phone",src:t,alt:r="Device screen content",children:o,orientation:n="portrait",theme:a="dark",size:i="md",showStatusBar:c=false,statusBarTime:d,animated:l=false,scrollSpeed:u=30,frameColor:p,className:m,contentClassName:g}){let f=useRef(null),h=useRef(null),b=a0[e][i],x=n==="landscape"&&e!=="watch"&&e!=="browser",v=x?b.h:b.w,k=x?b.w:b.h;useEffect(()=>{if(!l||!f.current)return;let M=f.current,R=null,P=A=>{R===null&&(R=A);let $=(A-R)/1e3;R=A,M.scrollTop+=u*$,M.scrollTop>=M.scrollHeight-M.clientHeight&&(M.scrollTop=0),h.current=requestAnimationFrame(P);};return h.current=requestAnimationFrame(P),()=>{h.current!==null&&cancelAnimationFrame(h.current);}},[l,u]);let D=jsx("div",{ref:l?f:void 0,className:s("w-full h-full overflow-hidden",l&&"overflow-y-auto scrollbar-hide",g),style:l?{scrollBehavior:"auto"}:void 0,children:t?jsx("img",{src:t,alt:r,className:"w-full h-auto object-cover",draggable:false}):o}),N={showStatusBar:c,statusBarTime:d},E=()=>{switch(e){case "phone":return jsx(c0,{theme:a,screenW:v,screenH:k,frameColor:p,landscape:x,...N,children:D});case "android":return jsx(u0,{theme:a,screenW:v,screenH:k,frameColor:p,...N,children:D});case "tablet":return jsx(p0,{theme:a,screenW:v,screenH:k,frameColor:p,...N,children:D});case "laptop":return jsx(g0,{theme:a,screenW:v,screenH:k,frameColor:p,children:D});case "desktop":return jsx(f0,{theme:a,screenW:v,screenH:k,frameColor:p,children:D});case "watch":return jsx(m0,{theme:a,screenW:v,screenH:k,frameColor:p,...N,children:D});case "browser":return jsx(b0,{theme:a,screenW:v,screenH:k,frameColor:p,children:D})}};return jsx("div",{className:s("inline-flex",m),"data-testid":"device-mockup","data-orientation":n,"data-theme":a,"data-size":i,children:E()})}var y0={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"},x0={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"},v0={xs:24,sm:32,md:48,lg:64,xl:96},w0={xs:"text-[8px]",sm:"text-[10px]",md:"text-sm",lg:"text-base",xl:"text-xl"},k0={thin:2,normal:4,thick:8};function Gs({value:e=0,indeterminate:t=false,size:r="md",thickness:o="normal",color:n="primary",progressColor:a,trackColor:i,showValue:c=false,children:d,valueFormat:l,animated:u=true,className:p,...m}){let g=Math.min(100,Math.max(0,e)),f=v0[r],h=k0[o],b=(f-h)/2,x=2*Math.PI*b,v=f/2,k=x-g/100*x,D=a||y0[n],N=i||"stroke-gray-200 dark:stroke-gray-700",E=x0[n],M=d??(c&&!t?jsx("span",{className:s("font-semibold",w0[r],E),children:l?l(g):`${Math.round(g)}%`}):null);return jsxs("div",{className:s("relative inline-flex items-center justify-center",p),role:"progressbar","aria-valuenow":t?void 0:g,"aria-valuemin":0,"aria-valuemax":100,...m,children:[jsxs("svg",{width:f,height:f,viewBox:`0 0 ${f} ${f}`,className:s(t&&"animate-spin"),style:{transform:"rotate(-90deg)"},children:[jsx("circle",{cx:v,cy:v,r:b,fill:"none",strokeWidth:h,className:N}),jsx("circle",{cx:v,cy:v,r:b,fill:"none",strokeWidth:h,strokeLinecap:"round",strokeDasharray:x,strokeDashoffset:t?x*.75:k,className:s(D,u&&!t&&"transition-[stroke-dashoffset] duration-300 ease-out")})]}),M&&jsx("div",{className:"absolute inset-0 flex items-center justify-center",style:{transform:"rotate(0deg)"},children:M})]})}Gs.displayName="CircularProgress";var gn={solid:"border-solid",dashed:"border-dashed",dotted:"border-dotted"},C0={left:{before:"flex-[0.1]",after:"flex-1"},center:{before:"flex-1",after:"flex-1"},right:{before:"flex-1",after:"flex-[0.1]"}};function Ks({orientation:e="horizontal",variant:t="solid",label:r,textAlign:o="center",thickness:n=1,color:a="border-gray-300 dark:border-gray-700",spacing:i,className:c,...d}){if(e==="vertical")return jsx("hr",{"aria-orientation":"vertical",className:s("h-full border-l-0 border-r",gn[t],a,i||"mx-2",c),style:{borderRightWidth:`${n}px`},...d});if(r){let l=C0[o];return jsxs("div",{role:"separator","aria-orientation":"horizontal",className:s("flex items-center text-sm text-gray-500 dark:text-gray-400",i||"my-4",c),...d,children:[jsx("div",{className:s("border-t",gn[t],a,l.before),style:{borderTopWidth:`${n}px`}}),jsx("span",{className:"px-3 whitespace-nowrap",children:r}),jsx("div",{className:s("border-t",gn[t],a,l.after),style:{borderTopWidth:`${n}px`}})]})}return jsx("hr",{"aria-orientation":"horizontal",className:s("border-t-0 border-b",gn[t],a,i||"my-4",c),style:{borderBottomWidth:`${n}px`},...d})}Ks.displayName="Divider";var S0=new Set(["SCRIPT","STYLE","LINK","META","NOSCRIPT","TEMPLATE","BASE","TITLE"]),Ys="data-synertech-inert-ignore",Lo=new WeakMap,da=new WeakMap,ca=new WeakMap;function R0(e){let t=Lo.get(e)??0;t===0&&(da.set(e,e.getAttribute("aria-hidden")),ca.set(e,e.hasAttribute("inert")),e.setAttribute("aria-hidden","true"),e.setAttribute("inert","")),Lo.set(e,t+1);}function T0(e){let t=Lo.get(e)??0;if(t===0)return;if(t>1){Lo.set(e,t-1);return}Lo.delete(e);let r=da.get(e)??null;r===null?e.removeAttribute("aria-hidden"):e.setAttribute("aria-hidden",r),da.delete(e),ca.get(e)||e.removeAttribute("inert"),ca.delete(e);}var fn=new Map;function _r(e,t){return fn.set(e,t),()=>{fn.delete(e);}}function mn(e){if(fn.size===0)return [];let t=[];for(let[r,o]of fn){let n=o();n&&e.some(a=>a.contains(n))&&t.push(r);}return t}function D0(e){return !(S0.has(e.tagName)||e.hasAttribute(Ys))}function ua(e){let t=(Array.isArray(e)?e:[e]).filter(Boolean),r=t[0]?.ownerDocument?.body;if(!r||!t.every(d=>r.contains(d)))return ()=>{};let o=[...t,...mn(t).filter(d=>r.contains(d))],n=[],a=new Set,i=d=>o.some(l=>d===l||d.contains(l));for(let d of t){let l=d;for(;l&&l!==r;){let u=l.parentElement;if(!u)break;for(let p of Array.from(u.children))a.has(p)||i(p)||D0(p)&&(a.add(p),R0(p),n.push(p));l=u;}}let c=false;return ()=>{if(!c){c=true;for(let d of n)T0(d);}}}var Tr=[];function Xs(e){let t=Tr.indexOf(e);t!==-1&&Tr.splice(t,1),Tr.push(e);}function js(e){let t=Tr.indexOf(e);t!==-1&&Tr.splice(t,1);}function qs(e){return Tr.length>0&&Tr[Tr.length-1]===e}var zo=0,pa=null;function Js(e=document){let t=e.body;if(!t)return ()=>{};zo===0&&(pa=t.style.overflow,t.style.overflow="hidden"),zo+=1;let r=false;return ()=>{r||(r=true,zo=Math.max(0,zo-1),zo===0&&(t.style.overflow=pa??"",pa=null));}}var Zs=["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 E0(e){let t=e.ownerDocument?.defaultView;if(!t)return null;try{return t.getComputedStyle(e)}catch{return null}}function Qs(e){let t=e;for(;t;){if(t.hasAttribute("hidden")||t.hasAttribute("inert")||t.getAttribute("aria-hidden")==="true")return false;let r=E0(t);if(r&&(r.display==="none"||r.visibility==="hidden"||r.visibility==="collapse"))return false;t=t.parentElement;}return true}function ei(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 Qs(e)}function bn(e){return Array.from(e.querySelectorAll(Zs)).filter(ei).sort((r,o)=>{let n=r.compareDocumentPosition(o);return n&Node.DOCUMENT_POSITION_FOLLOWING?-1:n&Node.DOCUMENT_POSITION_PRECEDING?1:0})}var I0={role:"dialog","aria-modal":true,tabIndex:-1};function M0(e,t){return t==="none"?null:t&&typeof t=="object"?t.current??e:t==="first"?bn(e)[0]??e:e}function P0(e){return e?e.map(t=>t&&"current"in t?t.current:t).filter(t=>!!t):[]}function no(e){if(e)try{e.focus();}catch{}}function $r(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,i=a.activeElement,{hideBackground:c,lockScroll:d,initialFocus:l,keepInteractive:u}=o.current;Xs(n);let p=c===false?void 0:ua([n,...P0(u)]),m=d===false?void 0:Js(a);return no(M0(n,l)),()=>{p?.(),m?.(),js(n);let{returnFocus:g}=o.current;if(g===false)return;let f=a.activeElement;if(!(!f||f===a.body||n.contains(f)))return;let b=g&&typeof g=="object"?g.current:i;b&&a.contains(b)&&no(b);}},[t]),useEffect(()=>{if(!t)return;let n=r.current;if(!n)return;let a=n.ownerDocument,i=a.defaultView??a,c=l=>l?n.contains(l)?true:mn([n]).some(u=>u.contains(l)):false,d=l=>{if(l.defaultPrevented||!qs(n))return;let{closeOnEscape:u,trapFocus:p,onClose:m}=o.current;if(l.key==="Escape"){if(u===false)return;l.preventDefault(),m?.();return}if(l.key!=="Tab"||p===false)return;let g=a.activeElement;if(g&&!n.contains(g)&&c(g))return;let f=bn(n);if(f.length===0){l.preventDefault(),no(n);return}let h=f[0],b=f[f.length-1];if(!g||!n.contains(g)){l.preventDefault(),no(l.shiftKey?b:h);return}if(l.shiftKey&&(g===h||g===n)){l.preventDefault(),no(b);return}!l.shiftKey&&g===b&&(l.preventDefault(),no(h));};return i.addEventListener("keydown",d),()=>i.removeEventListener("keydown",d)},[t]),{dialogRef:r,dialogProps:I0}}var ni={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."},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."},ga=createContext(ni);function W0({labels:e,children:t}){let r=useContext(ga),o=useMemo(()=>({...r,...e}),[r,e]);return jsx(ga.Provider,{value:o,children:t})}function Gt(){return useContext(ga)}var _0={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"}},$0={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"},ai={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"}},U0=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 si({open:e,onClose:t,children:r,position:o="right",size:n="md",customWidth:a,customHeight:i,showOverlay:c=true,closeOnOverlayClick:d=true,closeOnEscape:l=true,title:u,footer:p,className:m,overlayClassName:g,closeLabel:f,"aria-label":h,trapFocus:b=true,initialFocus:x,returnFocus:v,lockScroll:k=true}){let D=!!(a||i),N=useRef(null),E=Gt(),R=`${useId()}-drawer-title`,{dialogRef:P,dialogProps:A}=$r({open:e,onClose:t,closeOnEscape:l,trapFocus:b,initialFocus:x,returnFocus:v,lockScroll:k,keepInteractive:[N]}),$=useCallback(()=>{d&&t();},[d,t]);if(!e)return null;let q=jsxs(Fragment,{children:[c&&jsx("div",{ref:N,className:s("fixed inset-0 bg-black/50 z-40 transition-opacity",e?"animate-in fade-in duration-200":"animate-out fade-out duration-150",g),onClick:$,"aria-hidden":"true"}),jsxs("div",{ref:P,...A,"aria-labelledby":u?R:void 0,"aria-label":u?void 0:h,className:s("fixed z-50 bg-white dark:bg-gray-900","shadow-xl overflow-hidden","flex flex-col focus:outline-none",$0[o],!D&&_0[o][n],e?ai[o].enter:ai[o].exit,m),style:{...a?{width:a}:{},...i?{height:i}:{}},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:R,className:"text-lg font-semibold text-gray-900 dark:text-white",children:u}),jsx("button",{type:"button",onClick:t,className:s("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??E.closeDrawer,children:U0})]}),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(q,document.body):q}si.displayName="Drawer";var X0={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"}},ci=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]}`},ma=e=>e.webkitRelativePath||e.name,j0=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"})}),q0=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"})}),J0=0;async function Z0(e){let t=[],r=async o=>{if(o.isFile){let n=await new Promise((a,i)=>o.file(a,i));t.push(n);}else if(o.isDirectory){let n=o.createReader(),a=()=>new Promise((c,d)=>n.readEntries(c,d)),i=await a();for(;i.length>0;){for(let c of i)await r(c);i=await a();}}};for(let o of e)await r(o);return t}function Q0({value:e,onChange:t,accept:r,multiple:o=false,maxSize:n=10*1024*1024,maxFiles:a,mode:i="file",variant:c="dropzone",size:d="md",disabled:l=false,readOnly:u=false,label:p,helperText:m,error:g,showFileList:f=true,placeholder:h,browseLabel:b,browseFolderLabel:x,icon:v,onReject:k,className:D}){let[N,E]=useState([]),[M,R]=useState(false),P=useRef(null),A=useRef(null),$=useId(),q=e!==void 0,L=q?e.map((B,te)=>({file:B,id:`ctrl-${te}`})):N,_=X0[d];useEffect(()=>{i==="directory"&&P.current&&P.current.setAttribute("webkitdirectory",""),i==="both"&&A.current&&A.current.setAttribute("webkitdirectory","");},[i]);let z=useMemo(()=>ci(n),[n]),y=useMemo(()=>r?r.split(",").map(B=>B.trim()).map(B=>B.startsWith(".")?B.toUpperCase():B.endsWith("/*")?B.replace("/*","").toUpperCase():B).join(", "):"All files",[r]),S=i==="directory"?"Drag & drop a folder here, or":i==="both"?"Drag & drop files or folders here, or":o?"Drag & drop files here, or":"Drag & drop a file here, or",T=i==="directory"?"Browse folder":"Browse",Q="Browse folder",ie=useCallback(B=>{if(B.size>n)return `File exceeds maximum size of ${z}`;if(r){let te=r.split(",").map(j=>j.trim()),me=`.${B.name.split(".").pop()?.toLowerCase()}`;if(!te.some(j=>j.startsWith(".")?me===j.toLowerCase():j.endsWith("/*")?B.type.startsWith(j.replace("/*","/")):B.type===j))return `File type not accepted. Expected: ${y}`}return null},[r,y,n,z]),we=useCallback(B=>{if(l||u)return;let te=Array.from(B),me=[];for(let Se of te){let j=ie(Se);j?k?.(Se,j):me.push(Se);}if(me.length!==0)if(q)if(o){let j=[...e??[],...me],Te=a?j.slice(0,a):j;t?.(Te);}else t?.([me[0]]);else E(Se=>{let j=me.map(Te=>({file:Te,id:`file-${++J0}`}));if(o){let Te=[...Se,...j],Pe=a?Te.slice(0,a):Te,et=Pe.map(at=>at.file);return t?.(et),Pe}return t?.([me[0]]),[j[0]]});},[l,u,q,o,a,e,t,k,ie]),he=useCallback(B=>{if(!(l||u)){if(q){let te=(e??[]).filter((me,Se)=>Se!==B);t?.(te);}else E(te=>{let me=te.filter((Se,j)=>j!==B);return t?.(me.map(Se=>Se.file)),me});P.current&&(P.current.value="");}},[l,u,q,e,t]),F=useCallback(()=>{l||u||(q?t?.([]):(E([]),t?.([])),P.current&&(P.current.value=""));},[l,u,q,t]),ee=useCallback(B=>{B.target.files&&B.target.files.length>0&&we(B.target.files);},[we]),ae=useCallback(B=>{B.preventDefault(),B.stopPropagation(),!l&&!u&&R(true);},[l,u]),ye=useCallback(B=>{B.preventDefault(),B.stopPropagation(),R(false);},[]),xe=useCallback(B=>{if(B.preventDefault(),B.stopPropagation(),R(false),l||u)return;let te=B.dataTransfer.items;if(te&&te.length>0&&(i==="directory"||i==="both")){let me=[];for(let j=0;j<te.length;j++){let Te=te[j].webkitGetAsEntry?.();Te&&me.push(Te);}if(me.some(j=>j.isDirectory)){Z0(me).then(j=>{j.length>0&&we(j);});return}}B.dataTransfer.files&&B.dataTransfer.files.length>0&&we(B.dataTransfer.files);},[l,u,i,we]),le=useCallback(()=>{!l&&!u&&P.current?.click();},[l,u]),X=useCallback(()=>{!l&&!u&&A.current?.click();},[l,u]),C=L.length>0,U=v||(i==="directory"?q0:j0),ge=f&&C&&jsxs("div",{className:s("flex flex-col",_.gap),children:[L.map((B,te)=>jsxs("div",{className:s("flex items-center justify-between rounded-md border border-gray-200 dark:border-gray-700 bg-gray-50 dark:bg-gray-800/50",_.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:ma(B.file)}),jsxs("span",{className:"shrink-0 text-gray-400 dark:text-gray-500",children:["(",ci(B.file.size),")"]})]}),!l&&!u&&jsx("button",{type:"button",onClick:()=>he(te),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 ${ma(B.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"})})})]},B.id)),o&&L.length>1&&!l&&!u&&jsx("button",{type:"button",onClick:F,className:s("self-start text-gray-400 hover:text-red-500 dark:text-gray-500 dark:hover:text-red-400 transition-colors cursor-pointer",_.subtext),children:"Remove all"})]}),re=s("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",_.button,g&&"border-red-300 dark:border-red-600");return jsxs("div",{className:s("flex flex-col",_.gap,D),children:[p&&jsx("label",{htmlFor:$,className:s("block font-medium text-gray-700 dark:text-gray-300",_.text),children:p}),jsx("input",{ref:P,id:$,type:"file",accept:i!=="directory"?r:void 0,multiple:o,onChange:ee,className:"sr-only",disabled:l||u,"aria-describedby":g?`${$}-error`:m?`${$}-helper`:void 0,"aria-invalid":!!g}),i==="both"&&jsx("input",{ref:A,type:"file",onChange:ee,className:"sr-only",disabled:l||u,tabIndex:-1,"aria-hidden":"true"}),c==="dropzone"?jsxs("div",{role:i==="both"?"group":"button",tabIndex:i==="both"?void 0:l||u?-1:0,onClick:i==="both"?void 0:le,onKeyDown:i==="both"?void 0:B=>{(B.key==="Enter"||B.key===" ")&&(B.preventDefault(),le());},onDragOver:ae,onDragLeave:ye,onDrop:xe,className:s("flex flex-col items-center justify-center rounded-lg border-2 border-dashed transition-colors",_.dropzone,M&&!l&&!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",!l&&!u&&"hover:border-blue-400 dark:hover:border-blue-500 hover:bg-gray-50 dark:hover:bg-gray-800/70",i!=="both"&&!l&&!u&&"cursor-pointer",l&&"opacity-50 cursor-not-allowed",u&&"cursor-default",g&&"border-red-300 dark:border-red-600"),"aria-label":i==="both"?"File and folder drop zone":h||S,children:[jsx("div",{className:s("text-gray-400 dark:text-gray-500 mb-2",_.icon,M&&"text-blue-500 dark:text-blue-400"),children:U}),jsxs("p",{className:s("text-gray-600 dark:text-gray-400",_.text),children:[h||S," ",!l&&!u&&i!=="both"&&jsx("span",{className:"text-blue-600 dark:text-blue-400 font-medium",children:b||T})]}),i==="both"&&!l&&!u&&jsxs("div",{className:s("flex items-center gap-3 mt-1",_.text),children:[jsx("button",{type:"button",onClick:le,className:"text-blue-600 dark:text-blue-400 font-medium hover:underline cursor-pointer focus:outline-none focus:ring-2 focus:ring-blue-500 focus:ring-offset-1 rounded",children:b||"Browse files"}),jsx("span",{className:"text-gray-300 dark:text-gray-600",children:"\xB7"}),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:x||Q})]}),jsxs("p",{className:s("text-gray-400 dark:text-gray-500 mt-1",_.subtext),children:[y," - Max ",z,o&&a&&` - Up to ${a} files`]})]}):jsxs("div",{className:"flex items-center gap-2",children:[i==="both"?jsxs(Fragment,{children:[jsx("button",{type:"button",onClick:le,disabled:l||u,className:re,children:b||(C?"Change files":"Choose files")}),jsx("button",{type:"button",onClick:X,disabled:l||u,className:re,children:x||"Choose folder"})]}):jsx("button",{type:"button",onClick:le,disabled:l||u,className:re,children:b||(i==="directory"?C?"Change folder":"Choose folder":C?"Change file":"Choose file")}),!C&&jsx("span",{className:s("text-gray-400 dark:text-gray-500",_.text),children:i==="directory"?"No folder selected":i==="both"?"No file or folder selected":"No file selected"}),C&&!f&&jsx("span",{className:s("text-gray-600 dark:text-gray-400 truncate",_.text),children:L.length===1?ma(L[0].file):`${L.length} files selected`})]}),ge,g&&jsx("p",{id:`${$}-error`,className:s("text-red-600 dark:text-red-400",_.subtext),role:"alert",children:g}),m&&!g&&jsx("p",{id:`${$}-helper`,className:s("text-gray-400 dark:text-gray-500",_.subtext),children:m})]})}var gi=createContext(null);function Lt(){let e=useContext(gi);if(!e)throw new Error("Dropdown compound components must be used within a Dropdown");return e}function fi({open:e,defaultOpen:t=false,onOpenChange:r,closeOnSelect:o=true,closeOnClickOutside:n=true,closeOnEscape:a=true,modal:i=false,children:c}){let[d,l]=useState(t),u=e!==void 0,p=u?e:d,m=useRef(null),g=useRef(null),f=useRef([]),[h,b]=useState(-1),x=useRef(0),v=useId(),k={triggerId:`dropdown-trigger-${v}`,contentId:`dropdown-content-${v}`},D=useCallback(R=>{u||l(R),r?.(R),R||b(-1);},[u,r]),N=useCallback((R,P)=>{f.current&&(f.current[R]=P);},[]),E=useCallback(()=>x.current++,[]),M={isOpen:p,setIsOpen:D,triggerRef:m,contentRef:g,closeOnSelect:o,closeOnClickOutside:n,closeOnEscape:a,modal:i,focusedIndex:h,setFocusedIndex:b,itemsRef:f,registerItem:N,getNextItemIndex:E,triggerId:k.triggerId,contentId:k.contentId};return jsx(gi.Provider,{value:M,children:jsx("div",{className:"relative inline-block",children:c})})}fi.displayName="Dropdown";var mi=memo(({isOpen:e})=>jsx("span",{className:s("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"})})}));mi.displayName="ChevronIcon";function bi({asChild:e=false,disabled:t=false,children:r,className:o}){let{isOpen:n,setIsOpen:a,triggerRef:i,triggerId:c,contentId:d}=Lt(),p={ref:i,id:c,"aria-haspopup":"menu","aria-expanded":n,"aria-controls":n?d:void 0,disabled:t,onClick:()=>{t||a(!n);},onKeyDown:m=>{t||((m.key==="Enter"||m.key===" ")&&(m.preventDefault(),a(!n)),m.key==="ArrowDown"&&!n&&(m.preventDefault(),a(true)));}};return e&&isValidElement(r)?cloneElement(r,{...p,className:s(r.props.className,o)}):jsxs("button",{type:"button",...p,className:s("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(mi,{isOpen:n})]})}bi.displayName="DropdownTrigger";function ao(e){let t=useRef(e);return useLayoutEffect(()=>{t.current=e;}),t}function so(e,t,r=true){let o=ao(t);useEffect(()=>{if(!r)return;let n=a=>{let i=a.target;!e.current||e.current.contains(i)||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 io({triggerRef:e,contentRef:t,isOpen:r,side:o="bottom",align:n="start",sideOffset:a=4,alignOffset:i=0,avoidCollisions:c=true,collisionPadding:d=8}){let[l,u]=useState({top:0,left:0,actualSide:o,actualAlign:n,isReady:false}),p=useRef(false),m=useCallback(()=>{if(!e.current||!t.current)return;let g=e.current.getBoundingClientRect(),f=t.current.getBoundingClientRect();if(!(g.width>0&&g.height>0&&f.width>0&&f.height>0)){p.current=false;return}let b={width:window.innerWidth,height:window.innerHeight},x=o,v=n,k=E=>{switch(E){case "bottom":return {top:g.bottom+a,left:g.left};case "top":return {top:g.top-f.height-a,left:g.left};case "right":return {top:g.top,left:g.right+a};case "left":return {top:g.top,left:g.left-f.width-a}}},D=(E,M,R)=>{if(E==="top"||E==="bottom")switch(M){case "start":return {...R,left:g.left+i};case "center":return {...R,left:g.left+g.width/2-f.width/2+i};case "end":return {...R,left:g.right-f.width+i}}else switch(M){case "start":return {...R,top:g.top+i};case "center":return {...R,top:g.top+g.height/2-f.height/2+i};case "end":return {...R,top:g.bottom-f.height+i}}},N=k(x);if(N=D(x,v,N),c){let{top:E,left:M}=N,{height:R,width:P}=f,{height:A,width:$}=b,q=E+R>A-d,L=E<d,_=M+P>$-d,z=M<d;x==="bottom"&&q&&!L?(x="top",N=k(x),N=D(x,v,N)):x==="top"&&L&&!q&&(x="bottom",N=k(x),N=D(x,v,N)),x==="right"&&_&&!z?(x="left",N=k(x),N=D(x,v,N)):x==="left"&&z&&!_&&(x="right",N=k(x),N=D(x,v,N));let y=N.left+P>$-d,S=N.left<d,T=N.top+R>A-d,Q=N.top<d;(x==="top"||x==="bottom")&&(y&&(N.left=$-P-d,v="end"),S&&(N.left=d,v="start")),(x==="left"||x==="right")&&(T&&(N.top=A-R-d,v="end"),Q&&(N.top=d,v="start"));}p.current=true,u({top:N.top,left:N.left,actualSide:x,actualAlign:v,isReady:true});},[e,t,o,n,a,i,c,d]);return useLayoutEffect(()=>{let g=0;if(r){p.current=false;let h=()=>{m(),p.current||(g=requestAnimationFrame(h));};g=requestAnimationFrame(h);}let f=()=>m();return window.addEventListener("resize",f),window.addEventListener("scroll",f,{passive:true,capture:true}),()=>{g&&cancelAnimationFrame(g),window.removeEventListener("resize",f),window.removeEventListener("scroll",f,{capture:true});}},[m,r]),l}function xn({isOpen:e,onClose:t,itemsCount:r,focusedIndex:o,setFocusedIndex:n,onSelect:a,loop:i=true}){let c=ao(t),d=ao(a),l=ao(o),u=useCallback(p=>{if(!(!e||r===0))switch(p.key){case "ArrowDown":p.preventDefault(),n(i?m=>m<r-1?m+1:0:m=>Math.min(m+1,r-1));break;case "ArrowUp":p.preventDefault(),n(i?m=>m>0?m-1:r-1:m=>Math.max(m-1,0));break;case "Home":p.preventDefault(),n(0);break;case "End":p.preventDefault(),n(r-1);break;case "Enter":case " ":p.preventDefault(),d.current?.(l.current);break;case "Escape":p.preventDefault(),c.current();break;case "Tab":c.current();break}},[e,r,n,i,c,d,l]);return useEffect(()=>{if(e)return document.addEventListener("keydown",u),()=>document.removeEventListener("keydown",u)},[e,u]),{focusedIndex:o}}function yi(e,t,r){useEffect(()=>{r&&e.current&&e.current[t]&&e.current[t]?.focus();},[t,r,e]);}var vp={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 vi({side:e="bottom",align:t="start",sideOffset:r=4,alignOffset:o=0,avoidCollisions:n=true,collisionPadding:a=8,minWidth:i,maxWidth:c,maxHeight:d=300,animation:l="scale",portal:u=true,children:p,className:m}){let{isOpen:g,setIsOpen:f,triggerRef:h,contentRef:b,closeOnClickOutside:x,closeOnEscape:v,modal:k,contentId:D,focusedIndex:N,setFocusedIndex:E,itemsRef:M}=Lt(),[R,P]=useState(false),A=io({triggerRef:h,contentRef:b,isOpen:g,side:e,align:t,sideOffset:r,alignOffset:o,avoidCollisions:n,collisionPadding:a});so(b,()=>{x&&f(false);},g);let $=M.current?.filter(Boolean).length||0,q=useCallback(_=>{let z=M.current?.[_];z&&!z.hasAttribute("data-disabled")&&z.click();},[M]);xn({isOpen:g,onClose:()=>{v&&(f(false),h.current?.focus());},itemsCount:$,focusedIndex:N,setFocusedIndex:E,onSelect:q}),useEffect(()=>{let _=b.current;if(_)return _r(_,()=>h.current)},[b,h]),useEffect(()=>{if(g&&M.current&&M.current.length>0){let _=setTimeout(()=>{E(0),M.current?.[0]?.focus();},10);return ()=>clearTimeout(_)}},[g,M,E]),useLayoutEffect(()=>{let _=0;if(!g){P(false);return}let z=()=>{let y=h.current?.getBoundingClientRect(),S=b.current?.getBoundingClientRect();if(A.isReady&&!!y&&!!S&&y.width>0&&y.height>0&&S.width>0&&S.height>0){P(true);return}_=requestAnimationFrame(z);};return P(false),_=requestAnimationFrame(z),()=>{_&&cancelAnimationFrame(_);}},[g,A.isReady,h,b]);let L=jsxs(Fragment,{children:[k&&g&&jsx("div",{className:"fixed inset-0 z-40 bg-black/20",onClick:()=>f(false)}),jsx("div",{ref:b,id:D,role:"menu","aria-orientation":"vertical","aria-hidden":!g,tabIndex:-1,style:{position:"fixed",top:A.top,left:A.left,minWidth:i??h.current?.offsetWidth,maxWidth:c,maxHeight:d,visibility:g&&R?"visible":"hidden",opacity:g&&R?1:0,pointerEvents:g&&R?"auto":"none"},className:s("z-50 overflow-auto rounded-lg","border border-gray-200 bg-white shadow-lg","dark:border-gray-700 dark:bg-gray-800",g&&R&&vp[l],m),children:jsx("div",{className:"py-1",children:p})})]});return u&&typeof document<"u"?createPortal(L,document.body):L}vi.displayName="DropdownContent";var Rp={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 ki({children:e,icon:t,iconPosition:r="left",description:o,shortcut:n,variant:a="default",closeOnSelect:i,onSelect:c,disabled:d=false,className:l,onClick:u,index:p,...m}){let{setIsOpen:g,closeOnSelect:f,focusedIndex:h,setFocusedIndex:b,registerItem:x,getNextItemIndex:v}=Lt(),k=useRef(null),[D]=useState(()=>p??v());useEffect(()=>(x(D,k.current),()=>{x(D,null);}),[D,x]);let N=i??f,E=h===D;return jsxs("button",{ref:k,role:"menuitem",type:"button",tabIndex:E?0:-1,disabled:d,"data-disabled":d||void 0,"data-focused":E||void 0,onClick:P=>{d||(c?.(),u?.(P),N&&g(false));},onMouseEnter:()=>{d||b(D);},className:s("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",Rp[a],d&&"opacity-50 cursor-not-allowed hover:bg-transparent",E&&"bg-gray-100 dark:bg-gray-700",l),...m,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})]})}ki.displayName="DropdownItem";function Ci({className:e}){return jsx("hr",{className:s("my-1 h-px border-0 bg-gray-200 dark:bg-gray-700",e)})}Ci.displayName="DropdownSeparator";function Ni({children:e,className:t}){return jsx("div",{className:s("px-3 py-1.5 text-xs font-semibold text-gray-500 dark:text-gray-400",t),children:e})}Ni.displayName="DropdownLabel";function Di({checked:e,defaultChecked:t=false,onCheckedChange:r,children:o,icon:n,description:a,disabled:i=false,closeOnChange:c=false,className:d,index:l}){let{setIsOpen:u,focusedIndex:p,setFocusedIndex:m,registerItem:g,getNextItemIndex:f}=Lt(),h=useRef(null),[b]=useState(()=>l??f()),[x,v]=useState(t),k=e!==void 0,D=k?e:x;useEffect(()=>(g(b,h.current),()=>{g(b,null);}),[b,g]);let N=p===b;return jsxs("button",{ref:h,role:"menuitemcheckbox",type:"button",tabIndex:N?0:-1,"aria-checked":D,disabled:i,"data-disabled":i||void 0,"data-focused":N||void 0,onClick:()=>{if(i)return;let R=!D;k||v(R),r?.(R),c&&u(false);},onMouseEnter:()=>{i||m(b);},className:s("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",i&&"opacity-50 cursor-not-allowed hover:bg-transparent",N&&"bg-gray-100 dark:bg-gray-700",d),children:[jsx("span",{className:"mr-2 shrink-0 w-4 h-4",children:n||jsx("span",{className:s("flex items-center justify-center w-4 h-4 rounded border-2 transition-colors",D?"bg-blue-600 border-blue-600":"border-gray-300 dark:border-gray-600"),children:D&&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})]})]})}Di.displayName="DropdownCheckboxItem";var Mi=createContext(null);function Ap(){let e=useContext(Mi);if(!e)throw new Error("DropdownRadioItem must be used within a DropdownRadioGroup");return e}function Pi({value:e,defaultValue:t="",onValueChange:r,children:o,className:n}){let[a,i]=useState(t),c=e!==void 0,d=c?e:a,l=useCallback(p=>{c||i(p),r?.(p);},[c,r]),u=useMemo(()=>({value:d,onValueChange:l}),[d,l]);return jsx(Mi.Provider,{value:u,children:jsx("div",{role:"group",className:n,children:o})})}Pi.displayName="DropdownRadioGroup";function Li({value:e,children:t,icon:r,description:o,disabled:n=false,closeOnChange:a=true,className:i,index:c}){let{value:d,onValueChange:l}=Ap(),{setIsOpen:u,focusedIndex:p,setFocusedIndex:m,registerItem:g,getNextItemIndex:f}=Lt(),h=useRef(null),[b]=useState(()=>c??f()),x=d===e;useEffect(()=>(g(b,h.current),()=>{g(b,null);}),[b,g]);let v=p===b;return jsxs("button",{ref:h,role:"menuitemradio",type:"button",tabIndex:v?0:-1,"aria-checked":x,disabled:n,"data-disabled":n||void 0,"data-focused":v||void 0,onClick:()=>{n||(l(e),a&&u(false));},onMouseEnter:()=>{n||m(b);},className:s("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",i),children:[jsx("span",{className:"mr-2 shrink-0 w-4 h-4",children:r||jsx("span",{className:s("flex items-center justify-center w-4 h-4 rounded-full border-2 transition-colors",x?"border-blue-600":"border-gray-300 dark:border-gray-600"),children:x&&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})]}),x&&!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"})})]})}Li.displayName="DropdownRadioItem";var Fi=createContext(null);function Hi(){let e=useContext(Fi);if(!e)throw new Error("DropdownSubMenu components must be used within a DropdownSubMenu");return e}function Bi({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(Fi.Provider,{value:a,children:jsx("div",{className:"relative",children:e})})}Bi.displayName="DropdownSubMenu";var Ai=0;function Oi({children:e,icon:t,disabled:r=false,className:o,index:n}){let{isOpen:a,setIsOpen:i,triggerRef:c}=Hi(),{focusedIndex:d,setFocusedIndex:l,registerItem:u}=Lt(),p=useRef(n??-1);useEffect(()=>(n===void 0&&(p.current=Ai++),u(p.current,c.current),()=>{u(p.current,null);}),[n,u,c]),useEffect(()=>()=>{Ai=0;},[]);let m=d===p.current;return jsxs("button",{ref:c,role:"menuitem",type:"button",tabIndex:m?0:-1,"aria-haspopup":"menu","aria-expanded":a,disabled:r,"data-disabled":r||void 0,"data-focused":m||void 0,onMouseEnter:()=>{r||(l(p.current),i(true));},onMouseLeave:()=>{setTimeout(()=>{i(false);},100);},onKeyDown:b=>{r||(b.key==="ArrowRight"||b.key==="Enter")&&(b.preventDefault(),i(true));},className:s("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",m&&"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"})})]})}Oi.displayName="DropdownSubMenuTrigger";function Vi({children:e,sideOffset:t=0,className:r}){let{isOpen:o,setIsOpen:n,triggerRef:a,contentRef:i}=Hi(),[c,d]=useState(false),l=io({triggerRef:a,contentRef:i,isOpen:o,side:"right",align:"start",sideOffset:t,avoidCollisions:true});so(i,()=>n(false),o),useEffect(()=>{let f=i.current;if(f)return _r(f,()=>a.current)},[i,a]);let u=useCallback(()=>{n(true);},[n]),p=useCallback(()=>{n(false);},[n]),m=f=>{(f.key==="ArrowLeft"||f.key==="Escape")&&(f.preventDefault(),n(false),a.current?.focus());};useLayoutEffect(()=>{let f=0;if(!o){d(false);return}let h=()=>{let b=a.current?.getBoundingClientRect(),x=i.current?.getBoundingClientRect();if(l.isReady&&!!b&&!!x&&b.width>0&&b.height>0&&x.width>0&&x.height>0){d(true);return}f=requestAnimationFrame(h);};return d(false),f=requestAnimationFrame(h),()=>{f&&cancelAnimationFrame(f);}},[o,l.isReady,a,i]);let g=jsx("div",{ref:i,role:"menu","aria-orientation":"vertical","aria-hidden":!o,tabIndex:-1,onMouseEnter:u,onMouseLeave:p,onKeyDown:m,style:{position:"fixed",top:l.top,left:l.left,visibility:o&&c?"visible":"hidden",opacity:o&&c?1:0,pointerEvents:o&&c?"auto":"none"},className:s("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&&c&&"animate-in fade-in-0 zoom-in-95 duration-150",r),children:jsx("div",{className:"py-1",children:e})});return typeof document<"u"?createPortal(g,document.body):g}Vi.displayName="DropdownSubMenuContent";var _p=(e="md")=>({sm:"text-xs p-1.5",md:"text-sm p-2.5",lg:"text-base p-3.5"})[e],co=({size:e="md",error:t,disabled:r,readOnly:o,icon:n,iconPosition:a})=>s("bg-gray-50 rounded-lg block w-full","border focus:outline-none focus:ring-0","dark:bg-gray-700 dark:placeholder-gray-400",_p(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"),_i=(e,t)=>s("text-sm font-medium",e?"min-w-[120px]":"block mb-2",!t&&"text-gray-900 dark:text-white"),$i=e=>s("mt-1 text-xs",e?"text-red-500 dark:text-red-400":"text-gray-500 dark:text-gray-400"),Gr=e=>s("absolute inset-y-0 flex items-center pointer-events-none",e==="left"?"left-2.5":"right-2.5");var uo=({label:e,hideLabel:t,labelColor:r,error:o,helperText:n,inline:a,children:i,htmlFor:c})=>jsxs("div",{className:a?"flex items-center gap-4":"flex flex-col",children:[e&&!t&&jsx("label",{htmlFor:c,className:_i(a||false,r),style:r?{color:r}:void 0,children:e}),jsx("div",{className:a?"flex-1":"w-full",children:i}),n&&jsx("p",{className:s($i(o),a&&"ml-34"),children:n})]});var ar=forwardRef(({label:e,inline:t=false,size:r="md",labelColor:o,borderColor:n,textColor:a,disabled:i=false,readOnly:c=false,error:d=false,helperText:l,hideLabel:u=false,icon:p,iconPosition:m="left",multiline:g=false,rows:f=3,focused:h=false,className:b,...x},v)=>{let k=useRef(null),D=A=>{k.current=A,typeof v=="function"?v(A):v&&(v.current=A);};useEffect(()=>{h&&k.current?.focus();},[h]);let N=useId(),E=s(co({size:r,error:d,disabled:i,readOnly:c,icon:p,iconPosition:m}),g&&"resize-vertical",b),M={...n&&{borderColor:n},...a&&{color:a}},R=n||a?M:void 0;return jsx(uo,{label:e,hideLabel:u,labelColor:o,error:d,helperText:l,inline:t,htmlFor:N,children:jsxs("div",{className:"relative w-full",children:[p&&jsx("span",{className:Gr(m),children:p}),g?jsx("textarea",{ref:D,id:N,disabled:i,readOnly:c,rows:f,tabIndex:c||i?-1:void 0,className:E,style:R,...x}):jsx("input",{ref:D,id:N,disabled:i,readOnly:c,tabIndex:c||i?-1:void 0,className:E,style:R,...x})]})})});ar.displayName="Input";var Qp=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})]}),ka=forwardRef(({label:e,inline:t=false,size:r="md",labelColor:o,borderColor:n,textColor:a,disabled:i=false,readOnly:c=false,error:d=false,helperText:l,hideLabel:u=false,icon:p,iconPosition:m="left",mentionTrigger:g="@",suggestions:f=[],onMentionSearch:h,onMentionSelect:b,onMentionRemove:x,renderSuggestion:v,value:k,onChange:D,placeholder:N,loading:E=false,maxSuggestions:M=10,chipVariant:R="soft",chipColor:P="primary",chipSize:A="sm"},$)=>{let q=useId(),L=useRef(null),[_,z]=useState(false),[y,S]=useState(0),[T,Q]=useState(""),ie=s(co({size:r,error:d,disabled:i,readOnly:c,icon:p,iconPosition:m}),"min-h-[42px]","whitespace-pre-wrap","break-words"),we={...n&&{borderColor:n},...a&&{color:a}},he=n||a?we:void 0,F=useCallback(()=>{if(!L.current)return {text:"",mentions:[]};let C="",U=[],ge=0,re=B=>{if(B.nodeType===Node.TEXT_NODE)C+=B.textContent||"",ge+=(B.textContent||"").length;else if(B.nodeType===Node.ELEMENT_NODE){let te=B;if(te.hasAttribute("data-mention-id")){let me=te.getAttribute("data-mention-id"),Se=te.getAttribute("data-mention-label")||"",j=te.getAttribute("data-mention-avatar")||void 0,Te=`@${Se}`,Pe=ge;U.push({trigger:g,suggestion:{id:me||"",label:Se,avatar:j},startIndex:Pe,endIndex:Pe+Te.length}),C+=Te,ge+=Te.length;}else te.childNodes.forEach(re);}};return L.current.childNodes.forEach(re),{text:C,mentions:U}},[g]),ee=useCallback((C,U)=>{let ge=document.createElement("span");return ge.contentEditable="false",ge.setAttribute("data-mention-id",C.id),ge.setAttribute("data-mention-label",C.label),C.avatar&&ge.setAttribute("data-mention-avatar",C.avatar),ge.className="inline-block align-middle mx-0.5",ge.style.userSelect="none",createRoot(ge).render(jsx(un,{label:C.label,variant:R,color:P,size:A,closable:!i&&!c,onClose:U,disabled:i,avatar:C.avatar?jsx("img",{src:C.avatar,alt:C.label,className:"w-full h-full object-cover"}):void 0})),ge},[R,P,A,i,c]),ae=useCallback(C=>{if(!L.current)return;let U=L.current.querySelector(`[data-mention-id="${C}"]`);if(U){U.remove();let ge=F();D?.(ge);let re=k?.mentions.find(B=>B.suggestion.id===C)?.suggestion;re&&x?.(re);}},[F,D,x,k?.mentions]),ye=useCallback(()=>{if(!L.current)return;let C=window.getSelection();if(!C||C.rangeCount===0)return;let U=C.getRangeAt(0),ge="";U.startContainer.nodeType===Node.TEXT_NODE&&(ge=U.startContainer.textContent?.substring(0,U.startOffset)||"");let re=ge.match(new RegExp(`${g}(\\w*)$`));if(re){let te=re[1];Q(te),z(true),S(0),h?.(te);}else z(false),Q("");let B=F();D?.(B);},[g,h,D,F]),xe=useCallback(C=>{if(!L.current)return;let U=window.getSelection();if(!U||U.rangeCount===0)return;let ge=U.getRangeAt(0);if(ge.startContainer.nodeType===Node.TEXT_NODE){let B=ge.startContainer,te=B.textContent||"",me=ge.startOffset,j=te.substring(0,me).lastIndexOf(g);if(j!==-1){let Te=te.substring(0,j),Pe=te.substring(me),et=ee(C,()=>{ae(C.id);});if(Te?(B.textContent=Te,B.parentNode?.insertBefore(et,B.nextSibling)):(B.parentNode?.insertBefore(et,B),B.textContent="",B.textContent||B.remove()),Pe){let J=document.createTextNode(Pe);et.parentNode?.insertBefore(J,et.nextSibling);}let at=document.createTextNode(" ");et.parentNode?.insertBefore(at,et.nextSibling);let pt=document.createRange();pt.setStartAfter(at),pt.collapse(true),U.removeAllRanges(),U.addRange(pt);}}z(false),Q("");let re=F();D?.(re),b?.(C),L.current.focus();},[g,ee,ae,F,D,b]),le=useCallback(C=>{let U=f.slice(0,M);if(_&&U.length>0)switch(C.key){case "ArrowDown":C.preventDefault(),S(ge=>ge<U.length-1?ge+1:0);return;case "ArrowUp":C.preventDefault(),S(ge=>ge>0?ge-1:U.length-1);return;case "Enter":case "Tab":C.preventDefault(),U[y]&&xe(U[y]);return;case "Escape":C.preventDefault(),z(false);return}if(C.key==="Backspace"){let ge=window.getSelection();if(!ge||ge.rangeCount===0)return;let re=ge.getRangeAt(0);if(re.collapsed&&re.startOffset===0){let B=re.startContainer.previousSibling;if(B&&B.nodeType===Node.ELEMENT_NODE){let te=B;if(te.hasAttribute("data-mention-id")){C.preventDefault();let me=te.getAttribute("data-mention-id");me&&ae(me);return}}}if(re.collapsed&&re.startContainer.nodeType===Node.TEXT_NODE){let B=re.startContainer;if(re.startOffset===0){let te=B.previousSibling;if(te&&te.nodeType===Node.ELEMENT_NODE){let me=te;if(me.hasAttribute("data-mention-id")){C.preventDefault();let Se=me.getAttribute("data-mention-id");Se&&ae(Se);return}}}}}},[_,f,y,M,xe,ae]);return useEffect(()=>{L.current&&(!(L.current.textContent||L.current.querySelector("[data-mention-id]"))&&N?L.current.setAttribute("data-placeholder",N):L.current.removeAttribute("data-placeholder"));},[N,k]),useEffect(()=>{L.current&&k?.text===""&&k?.mentions.length===0&&L.current.innerHTML.trim()&&(L.current.innerHTML="");},[k?.text,k?.mentions.length]),jsx(uo,{label:e,hideLabel:u,labelColor:o,error:d,helperText:l,inline:t,htmlFor:q,children:jsxs("div",{className:"relative w-full",children:[p&&jsx("span",{className:Gr(m),children:p}),jsx("div",{ref:C=>{typeof $=="function"?$(C):$&&($.current=C),L.current=C;},id:q,contentEditable:!i&&!c,suppressContentEditableWarning:true,onInput:ye,onKeyDown:le,className:s(ie,"empty:before:content-[attr(data-placeholder)] empty:before:text-gray-400 empty:before:dark:text-gray-500"),style:he,role:"textbox","aria-label":e,"aria-multiline":"true",tabIndex:c||i?-1:0}),_&&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:E?jsx("div",{className:"px-3 py-2 text-sm text-gray-500 dark:text-gray-400",children:"Loading..."}):f.slice(0,M).map((C,U)=>jsx("div",{onClick:()=>xe(C),className:s(U===y&&"bg-gray-100 dark:bg-gray-600"),children:v?v(C):Qp(C)},C.id))})]})})});ka.displayName="MentionInput";var Ca=forwardRef(({label:e,inline:t=false,size:r="md",labelColor:o,borderColor:n,textColor:a,disabled:i=false,readOnly:c=false,error:d=false,helperText:l,hideLabel:u=false,icon:p,iconPosition:m="left",className:g,value:f,onChange:h,format:b="number",currency:x="USD",locale:v="en-US",decimals:k,min:D,max:N,step:E=1,prefix:M,suffix:R,thousandSeparator:P=true,allowNegative:A=true,onBlur:$,onFocus:q,...L},_)=>{let z=useId(),[y,S]=useState(null),T=useMemo(()=>{let X=b==="currency"?{style:"currency",currency:x,minimumFractionDigits:k??2,maximumFractionDigits:k??2}:b==="percentage"?{minimumFractionDigits:k??0,maximumFractionDigits:k??2}:{minimumFractionDigits:k??0,maximumFractionDigits:k??(b==="decimal"?2:0),useGrouping:P};try{return new Intl.NumberFormat(v,X)}catch{return null}},[b,x,v,k,P]),Q=X=>{if(X==null)return "";if(!T)return String(X);let C=T.format(X);return b==="percentage"?(C=M?`${M}${C}`:C,C=R||!C.includes("%")?`${C}%`:C,C):(M&&(C=`${M}${C}`),R&&(C=`${C}${R}`),C)},ie=X=>{if(!X||X.trim()==="")return null;let C=X;if(M&&(C=C.replace(M,"")),R&&(C=C.replace(R,"")),C=C.replace(/[^\d.,-]/g,""),v.includes("fr")||v.includes("de")?C=C.replace(/\s/g,"").replace(",","."):C=C.replace(",",""),!C||C==="-"||C===".")return null;let U=parseFloat(C);return isNaN(U)?null:!A&&U<0?Math.abs(U):D!==void 0&&U<D?D:N!==void 0&&U>N?N:U},we=y??Q(f??null),he=X=>{let C=v.includes("fr")||v.includes("de")?",":".";return new RegExp(`^-?[0-9${C===","?",":"\\."}]*$`).test(X)},F=X=>{let C=X.target.value;if(C===""||he(C)){S(C);let U=ie(C);h&&h(U);}},ee=X=>{let C=v.includes("fr")||v.includes("de")?",":".",U=["Backspace","Delete","Tab","Escape","Enter","ArrowLeft","ArrowRight","ArrowUp","ArrowDown","Home","End"],ge=/^[0-9]$/.test(X.key),re=X.key===C,B=X.key==="-"&&A&&we.indexOf("-")===-1,te=X.ctrlKey||X.metaKey;!ge&&!re&&!B&&!U.includes(X.key)&&!te&&X.preventDefault();},ae=X=>{let C=f!=null?String(f):"";S(C),q&&q(X);},ye=X=>{let C=ie(y??"");h&&C!==f&&h(C),S(null),$&&$(X);},xe=s(co({size:r,error:d,disabled:i,readOnly:c,icon:p,iconPosition:m}),n&&`border-[${n}]`,a&&`text-[${a}]`,g),le=jsxs("div",{className:"relative",children:[p&&m==="left"&&jsx("div",{className:Gr(m),children:p}),jsx("input",{ref:_,id:z,type:"text",inputMode:"decimal",className:xe,style:{borderColor:n,color:a},disabled:i,readOnly:c,value:we,onChange:F,onKeyDown:ee,onFocus:ae,onBlur:ye,...L}),p&&m==="right"&&jsx("div",{className:Gr(m),children:p})]});return jsx(uo,{label:e,hideLabel:u,labelColor:o,error:d,helperText:l,inline:t,htmlFor:z,children:le})});Ca.displayName="NumberInput";function ag({logo:e,logoHref:t="/",onLogoClick:r,navItems:o=[],actions:n,rightContent:a,variant:i="default",size:c="md",backgroundColor:d,textColor:l,hoverColor:u,navItemTextColor:p,navItemHoverColor:m,navItemBgHover:g,navItemActiveColor:f,sticky:h=false,fixed:b=false,showSearch:x=false,onSearch:v,searchPlaceholder:k="Search...",className:D,containerClassName:N}){let[E,M]=useState(false),[R,P]=useState(null),[A,$]=useState(""),q=()=>{M(!E);},L=F=>{P(R===F?null:F);},_=F=>{F.preventDefault(),v&&v(A);},z=s(h&&"sticky top-0 z-50",b&&"fixed top-0 left-0 right-0 z-50"),y=s(i==="default"&&!d&&"bg-neutral text-white",i==="transparent"&&!d&&"bg-transparent",i==="bordered"&&!d&&"bg-white border-b border-gray-200 text-gray-900 dark:bg-gray-900 dark:border-gray-800 dark:text-gray-100",i==="shadow"&&!d&&"bg-white shadow-md text-gray-900 dark:bg-gray-900 dark:text-gray-100"),S=s(c==="sm"&&"py-2",c==="md"&&"py-4",c==="lg"&&"py-6"),T=d||"",Q=l||"",ie=u||"",we=s(z,y,S,T,Q,D),he=(F,ee,ae=false)=>{let ye=F.children&&F.children.length>0,xe=R===ee,le=s("px-4 py-2 transition-colors flex items-center gap-2",ae?"block w-full text-left":"inline-flex",F.active&&"font-semibold border-b-2",F.active&&(f||"border-current"),p||(i==="default"||i==="transparent"?"text-gray-300":"text-gray-600 dark:text-gray-300"),m||ie||(i==="default"||i==="transparent"?"hover:text-white":"hover:text-blue-600 dark:hover:text-blue-400"),g||"");if(ye)return jsxs("div",{className:ae?"w-full":"relative",children:[jsxs("button",{type:"button",onClick:()=>L(ee),className:le,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:s("w-4 h-4 transition-transform",xe&&"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"})})]}),xe&&jsx("div",{className:s("bg-white shadow-lg rounded-lg overflow-hidden dark:bg-gray-800 dark:shadow-black/40",ae?"mt-2 mb-2":"absolute top-full left-0 mt-1 min-w-[200px]"),children:F.children?.map(C=>jsx("a",{href:C.href,onClick:C.onClick,target:C.external?"_blank":void 0,rel:C.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:[C.icon&&jsx("span",{className:"w-5 h-5",children:C.icon}),jsx("span",{children:C.label}),C.badge&&jsx("span",{className:"bg-red-500 text-white text-xs px-2 py-0.5 rounded-full ml-auto",children:C.badge}),C.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"})})]})},C.href??C.label))})]},F.href??F.label);let X=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:le,children:X},F.href??F.label):jsx("a",{href:F.href,target:F.external?"_blank":void 0,rel:F.external?"noopener noreferrer":void 0,className:le,children:X},F.href??F.label)};return jsxs("header",{className:we,children:[jsxs("nav",{className:s("container mx-auto flex items-center justify-between px-4",N),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})}),x&&jsx("form",{onSubmit:_,className:"hidden md:flex flex-1 max-w-md mx-8",children:jsx("input",{type:"search","aria-label":k,value:A,onChange:F=>$(F.target.value),placeholder:k,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((F,ee)=>he(F,ee,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:s("inline-flex rounded-lg border-2 p-2 w-10 h-10 justify-center transition-colors focus:outline-none",i==="default"||i==="transparent"?"text-gray-300 hover:text-white":"text-gray-600 hover:text-gray-900 dark:text-gray-300 dark:hover:text-gray-100"),onClick:q,"aria-label":"Toggle menu","aria-expanded":E,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"})})})})]}),E&&o.length>0&&jsx("div",{className:s("md:hidden border-t animate-in slide-in-from-top duration-300",i==="default"||i==="transparent"?"border-gray-700":"border-gray-200 dark:border-gray-800"),children:jsxs("div",{className:"flex flex-col py-2 px-4",children:[x&&jsx("form",{onSubmit:_,className:"mb-4",children:jsx("input",{type:"search","aria-label":k,value:A,onChange:F=>$(F.target.value),placeholder:k,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((F,ee)=>he(F,ee,true)),(n||a)&&jsxs("div",{className:"flex flex-col gap-2 mt-4 pt-4 border-t border-gray-700",children:[n,a]})]})})]})}var cg=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"})]}),ug=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"})]}),pg=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"})]}),gg=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"})]}),fg=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"})]}),mg={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"},bg={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"},hg={sm:"w-56",md:"w-72",lg:"w-96",xl:"w-[32rem]"},yg=[dg],xg={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 Ki({content:e,markdown:t=false,position:r="bottom",size:o="sm",className:n="",visible:a=true,editable:i=false,onSave:c,onReset:d,width:l="md",title:u,markdownEditor:p,markdownEditorUnavailableLabel:m}){let g=Gt(),[f,h]=useState(false),[b,x]=useState(false),[v,k]=useState(""),[D,N]=useState(false),[E,M]=useState(null),R=useRef(null),P=useRef(null),A=useRef(null),$=useRef(null);useEffect(()=>{if(!f)return;let S=Q=>{R.current&&!R.current.contains(Q.target)&&P.current&&!P.current.contains(Q.target)&&(b||h(false));},T=Q=>{Q.key==="Escape"&&(b?(x(false),k("")):h(false));};return document.addEventListener("mousedown",S),document.addEventListener("keydown",T),()=>{document.removeEventListener("mousedown",S),document.removeEventListener("keydown",T);}},[f,b]),useEffect(()=>{b&&A.current&&A.current.focus();},[b]),useEffect(()=>()=>{$.current&&clearTimeout($.current);},[]);let q=useCallback(()=>{k(typeof e=="string"?e:""),x(true),M(null);},[e]),L=useCallback(()=>{x(false),k(""),M(null);},[]),_=useCallback(async()=>{if(!c){M({type:"error",text:"Aucune fonction de sauvegarde fournie"});return}N(true);try{await c(v)?(M({type:"success",text:"Sauvegard\xE9 avec succ\xE8s !"}),x(!1),$.current&&clearTimeout($.current),$.current=setTimeout(()=>M(null),2e3)):M({type:"error",text:"Erreur lors de la sauvegarde"});}catch{M({type:"error",text:"Erreur lors de la sauvegarde"});}finally{N(false);}},[v,c]),z=useCallback(async()=>{if(d&&confirm("\xCAtes-vous s\xFBr de vouloir r\xE9initialiser ce contenu ?")){N(true);try{await d()?(M({type:"success",text:"R\xE9initialis\xE9 avec succ\xE8s !"}),x(!1),$.current&&clearTimeout($.current),$.current=setTimeout(()=>M(null),2e3)):M({type:"error",text:"Erreur lors de la r\xE9initialisation"});}catch{M({type:"error",text:"Erreur lors de la r\xE9initialisation"});}finally{N(false);}}},[d]),y=e;return a?jsxs("div",{className:"relative inline-flex items-center",children:[jsx("button",{type:"button",ref:R,onClick:()=>h(!f),className:`
3
- ${mg[o]}
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]}
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
@@ -12,20 +12,20 @@ import*as ta from'react';import ta__default,{createContext,forwardRef,useId,useS
12
12
  transition-all duration-150
13
13
  focus:outline-none focus:ring-2 focus:ring-blue-500/50
14
14
  ${n}
15
- `,"aria-label":"Afficher l'aide","aria-expanded":f,children:jsx("span",{className:"font-medium",children:"?"})}),f&&jsxs("div",{ref:P,className:`
16
- absolute z-50 ${bg[r]}
17
- ${hg[l]} max-h-[80vh] overflow-hidden flex flex-col
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
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||i)&&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})}),i&&jsx("div",{className:"flex items-center gap-1",children:b?jsxs(Fragment,{children:[jsx("button",{type:"button",onClick:_,disabled:D,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:D?fg:ug}),jsx("button",{type:"button",onClick:L,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:pg}),d&&jsx("button",{type:"button",onClick:z,disabled:D,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:gg})]}):jsx("button",{type:"button",onClick:q,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:cg})})]}),E&&jsx("div",{className:`px-4 py-2 text-xs ${E.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:E.text}),jsx("div",{className:"flex-1 overflow-y-auto p-4",children:b?t?p?jsx(p,{value:v,onChange:k,placeholder:"\xC9crivez en Markdown..."}):jsx("p",{role:"alert",className:"p-3 text-sm text-gray-500 dark:text-gray-400",children:m??g.markdownEditorUnavailable}):jsx("div",{className:"space-y-2",children:jsx("textarea",{ref:A,"aria-label":"Contenu d'aide",value:v,onChange:S=>k(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 y=="string"?jsx("div",{className:"prose prose-sm dark:prose-invert max-w-none",children:t?jsx(lg,{remarkPlugins:yg,components:xg,children:y}):jsx("div",{dangerouslySetInnerHTML:{__html:ig.sanitize(y)}})}):y})]})]}):null}function vg({children:e,content:t,markdown:r=false,position:o="bottom",size:n="sm",visible:a=true,editable:i=false,onSave:c,onReset:d,width:l="md",title:u,className:p,markdownEditor:m,markdownEditorUnavailableLabel:g}){return jsxs("div",{className:"inline-flex items-center gap-2.5",children:[e,jsx(Ki,{content:t,markdown:r,position:o,size:n,visible:a,editable:i,onSave:c,onReset:d,width:l,title:u,className:p,markdownEditor:m,markdownEditorUnavailableLabel:g})]})}var Sg={"16/9":"aspect-[16/9]","4/3":"aspect-[4/3]","1/1":"aspect-square",auto:""},Rg=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 Tg({value:e,onChange:t,onUpload:r,label:o="Image",maxSize:n=5*1024*1024,accept:a="image/*",helpText:i,disabled:c=false,className:d="",showUrlInput:l=true,urlPlaceholder:u="https://example.com/image.jpg",aspectRatio:p="16/9"}){let[m,g]=useState(false),[f,h]=useState(null),b=useRef(null),x=useId(),v=useMemo(()=>(n/(1024*1024)).toFixed(0),[n]),k=`Formats accept\xE9s : ${a==="image/*"?"JPG, PNG, GIF, WebP":a} (max ${v}MB)`,D=useCallback(async P=>{let A=P.target.files?.[0];if(A){if(!A.type.startsWith("image/")){h("Le fichier doit \xEAtre une image");return}if(A.size>n){h(`Le fichier est trop volumineux (max ${v}MB)`);return}g(true),h(null);try{if(r){let $=await r(A);t($);}else {let $=await Rg(A);t($);}b.current&&(b.current.value="");}catch($){console.error("Upload error:",$),h($ instanceof Error?$.message:"Erreur lors de l'upload");}finally{g(false);}}},[n,v,t,r]),N=useCallback(()=>{t(""),b.current&&(b.current.value=""),h(null);},[t]),E=useCallback(P=>{t(P),h(null);},[t]),M=useCallback(()=>{b.current?.click();},[]),R=useCallback(P=>{E(P.target.value);},[E]);return jsxs("div",{className:`space-y-2 ${d}`,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 ${Sg[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:N,disabled:c,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:b,type:"file","aria-label":"Choisir une image",accept:a,onChange:D,className:"hidden",disabled:c||m}),jsx("button",{type:"button",onClick:M,disabled:c||m,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:m?"\u23F3 Upload...":e?"\u{1F4C1} Changer l'image":"\u{1F4C1} Choisir une image"})]}),l&&jsxs("div",{className:"space-y-1",children:[jsx("label",{htmlFor:x,className:"block text-xs text-gray-500 dark:text-gray-400",children:"Ou URL directe :"}),jsx("input",{id:x,type:"url",value:e||"",onChange:R,placeholder:u,disabled:c,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:i||k})]})}var Nn={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"},Ra={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"},Dg={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"},Ta={"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"},Da={"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 Eg(e,t){return e>t?`${t}+`:`${e}`}function Ig({color:e="primary",size:t="md",placement:r="top-right",bordered:o=false,borderColor:n,pulse:a=false,offset:i=false,className:c,...d}){return jsx("span",{"data-testid":"indicator",className:s("absolute z-10 rounded-full",Nn[e],Ra[t],i?Da[r]:Ta[r],o&&s("ring-2 ring-white dark:ring-gray-900",n),a&&"animate-pulse",c),...d})}function Mg({color:e="error",size:t="md",placement:r="top-right",count:o=0,maxCount:n=99,bordered:a=false,borderColor:i,pulse:c=false,offset:d=false,className:l,...u}){return jsx("span",{"data-testid":"indicator",className:s("absolute z-10 inline-flex items-center justify-center rounded-full font-semibold text-white",Nn[e],Dg[t],d?Da[r]:Ta[r],a&&s("ring-2 ring-white dark:ring-gray-900",i),c&&"animate-pulse",l),...u,children:Eg(o,n)})}function Pg({color:e="success",size:t="md",placement:r="bottom-right",bordered:o=true,borderColor:n,pulse:a=false,offset:i=false,className:c,...d}){return jsx("span",{"data-testid":"indicator",className:s("absolute z-10 rounded-full",Nn[e],Ra[t],i?Da[r]:Ta[r],o&&s("ring-2 ring-white dark:ring-gray-900",n),a&&"animate-pulse",c),...d})}function Lg({color:e="primary",size:t="sm",label:r,className:o,...n}){return jsxs("span",{"data-testid":"indicator",className:s("inline-flex items-center gap-2",o),...n,children:[jsx("span",{className:s("rounded-full shrink-0",Nn[e],Ra[t])}),r?jsx("span",{className:"text-sm text-gray-700 dark:text-gray-300",children:r}):null]})}function Xi({variant:e="dot",children:t,...r}){if(e==="legend")return jsx(Lg,{...r});let o=(()=>{switch(e){case "count":return jsx(Mg,{...r});case "status":return jsx(Pg,{...r});default:return jsx(Ig,{...r})}})();return t?jsxs("div",{className:"relative inline-flex",children:[t,o]}):o}Xi.displayName="Indicator";var zg={xs:"text-xs",sm:"text-sm",md:"text-sm",lg:"text-base",xl:"text-lg"},qi={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"},Ag={normal:"font-normal",medium:"font-medium",semibold:"font-semibold",bold:"font-bold"},Wg={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 Zi({children:e,size:t="md",color:r="default",variant:o="default",weight:n="medium",textColor:a,required:i=false,requiredIndicator:c="*",optional:d=false,optionalText:l="(optional)",tooltip:u,icon:p,endIcon:m,disabled:g=false,truncate:f=false,as:h="label",className:b,...x}){let v=h,k=s("inline-flex items-center gap-1.5 transition-colors",zg[t],Ag[n]),D=a||Wg[r][o];return jsxs(v,{className:s(k,D,g?"opacity-50 cursor-not-allowed":"cursor-default",b),title:u,"aria-disabled":g,...x,children:[p&&jsx("span",{className:s("shrink-0",qi[t]),children:p}),jsxs("span",{className:s(f&&"truncate"),children:[e,i&&jsx("span",{className:"text-red-500 ml-0.5","aria-hidden":"true",children:c}),i&&jsx("span",{className:"sr-only",children:"(required)"})]}),d&&!i&&jsx("span",{className:"text-gray-400 dark:text-gray-500 font-normal",children:l}),m&&jsx("span",{className:s("shrink-0",qi[t]),children:m})]})}Zi.displayName="Label";var Og={sm:"max-w-sm",md:"max-w-2xl",lg:"max-w-4xl",xl:"max-w-6xl",full:"max-w-full"},vr=forwardRef(({isOpen:e,onClose:t,title:r="Modal Title",children:o,buttonLabel:n,onButtonClick:a,className:i,allowFullScreen:c=false,showSubmit:d=true,submitLabel:l,onSubmitClick:u,showCancel:p=false,cancelLabel:m,onCancelClick:g,buttonsPosition:f="right",showHeaderDivider:h=true,showFooterDivider:b=true,description:x,icon:v,size:k="md",reverseButtons:D=false,headerClassName:N,contentClassName:E,footerClassName:M,titleClassName:R,descriptionClassName:P,submitClassName:A,cancelClassName:$,closeLabel:q,enterFullScreenLabel:L,exitFullScreenLabel:_,"aria-label":z,closeOnEscape:y=true,trapFocus:S=true,initialFocus:T,returnFocus:Q,lockScroll:ie=true},we)=>{let[he,F]=useState(false),ee=Gt(),ae=useId(),ye=`${ae}-title`,xe=`${ae}-description`,{dialogRef:le,dialogProps:X}=$r({open:e,onClose:t,closeOnEscape:y,trapFocus:S,initialFocus:T,returnFocus:Q,lockScroll:ie});if(!e)return null;let C=n??l??ee.confirm,U=m??ee.cancel,ge=q??ee.closeModal,re=he?_??ee.exitFullScreen:L??ee.enterFullScreen,B=a??u,te=async()=>{B&&await B(),t();},me=async()=>{g&&await g(),t();};return jsx("div",{className:s("overflow-y-auto overflow-x-hidden fixed inset-0 z-50 flex items-center justify-center bg-black/30 backdrop-blur-sm",i),"aria-hidden":!e,children:jsx("div",{className:s("relative p-4 w-full max-h-full transition-all duration-300",he?"max-w-full h-full p-0":Og[k]),ref:we,children:jsxs("div",{...X,ref:le,"aria-labelledby":r?ye:void 0,"aria-label":r?void 0:z,"aria-describedby":x?xe:void 0,className:s("relative bg-white shadow dark:bg-gray-700 border-b-4 transition-all duration-300 focus:outline-none",he?"rounded-none h-full flex flex-col":"rounded-lg"),children:[jsxs("div",{className:s("flex items-center justify-between p-4 md:p-5 rounded-t",h&&"border-b border-gray-200 dark:border-gray-600",N),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:ye,className:s("text-xl font-semibold text-gray-900 dark:text-white",R),children:r}),x&&jsx("p",{id:xe,className:s("mt-1 text-sm text-gray-500 dark:text-gray-400",P),children:x})]})]}),jsxs("div",{className:"flex items-center gap-1 ms-auto",children:[c&&jsx("button",{type:"button",onClick:()=>F(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":re,children:he?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:s("p-4 md:p-5 space-y-4",he&&"flex-1 overflow-y-auto",E),children:o}),(d||p)&&jsxs("div",{className:s("flex items-center gap-2 p-4 md:p-5 rounded-b",b&&"border-t border-gray-200 dark:border-gray-600",f==="right"?"justify-end":f==="center"?"justify-center":"justify-start",D&&"flex-row-reverse",M),children:[p&&jsx("button",{type:"button",onClick:me,className:s("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",$),children:U}),d&&jsx("button",{type:"button",onClick:te,className:s("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",A),children:C})]})]})})})});vr.displayName="Modal";function $g(e,t,r,o){let n=r*2+1+o*2+2;if(t<=n)return Array.from({length:t},(m,g)=>g+1);let a=Array.from({length:o},(m,g)=>g+1).filter(m=>m<=t),i=Array.from({length:o},(m,g)=>t-o+1+g).filter(m=>m>=1),c=Math.max(e-r,o+1),d=Math.min(e+r,t-o),l=c>o+2,u=d<t-o-1,p=[];for(let m of a)p.push(m);if(l)p.push("ellipsis");else for(let m=o+1;m<c;m++)p.push(m);for(let m=c;m<=d;m++)p.push(m);if(u)p.push("ellipsis");else for(let m=d+1;m<=t-o;m++)p.push(m);for(let m of i)p.includes(m)||p.push(m);return p}function Ug({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 Gg({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 Kg({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 Yg({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 Xg={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"}},jg={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 qg({page:e,totalPages:t,onPageChange:r,size:o="md",variant:n="default",showFirstLast:a=false,siblings:i=1,boundaries:c=1,disabled:d=false,labels:l,totalItems:u,pageSize:p,pageSizeOptions:m,onPageSizeChange:g,className:f,...h}){let b=Xg[o],x=jg[n],v=useMemo(()=>$g(e,t,i,c),[e,t,i,c]),k=useCallback(A=>{d||A<1||A>t||A===e||r(A);},[d,t,e,r]),D=e<=1,N=e>=t,E=s("inline-flex items-center justify-center select-none",b.button,x.base),M=(A,$,q,L)=>jsx("button",{type:"button",onClick:A,disabled:d||$,"aria-label":q,"aria-disabled":d||$,className:s(E,d||$?x.disabled:x.idle),children:L}),R=u!==void 0&&p?(e-1)*p+1:void 0,P=u!==void 0&&p?Math.min(e*p,u):void 0;return jsxs("nav",{"aria-label":"Pagination",className:s("flex items-center",b.gap,f),...h,children:[u!==void 0&&p&&jsxs("span",{className:s("mr-2 text-gray-600 dark:text-gray-400 whitespace-nowrap",b.text),children:[R,"\u2013",P," of ",u]}),m&&m.length>0&&g&&jsxs("div",{className:s("mr-2 flex items-center whitespace-nowrap",b.gap,b.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:A=>g(Number(A.target.value)),disabled:d,className:s("rounded border border-gray-300 bg-white px-1.5 py-0.5 dark:border-gray-600 dark:bg-gray-800 dark:text-gray-200",b.text,d&&"cursor-not-allowed opacity-50"),children:m.map(A=>jsx("option",{value:A,children:A},A))})]}),jsxs("div",{className:s("flex items-center",b.gap),children:[a&&M(()=>k(1),D,l?.first??"Go to first page",jsx(Kg,{className:b.icon})),M(()=>k(e-1),D,l?.previous??"Go to previous page",jsx(Ug,{className:b.icon})),v.map((A,$)=>A==="ellipsis"?jsx("span",{className:s("inline-flex items-center justify-center select-none",b.button,"text-gray-400 dark:text-gray-500"),"aria-hidden":"true",children:"\u2026"},`ellipsis-${$}`):jsx("button",{type:"button",onClick:()=>k(A),disabled:d,"aria-current":A===e?"page":void 0,"aria-label":`Page ${A}`,className:s(E,A===e?x.active:d?x.disabled:x.idle),children:A},A)),M(()=>k(e+1),N,l?.next??"Go to next page",jsx(Gg,{className:b.icon})),a&&M(()=>k(t),N,l?.last??"Go to last page",jsx(Yg,{className:b.icon}))]})]})}var Jg={xs:"h-1",sm:"h-1.5",md:"h-2.5",lg:"h-4",xl:"h-6"},Zg={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"},Qg={default:"text-gray-700 dark:text-gray-300",primary:"text-blue-600 dark:text-blue-400",success:"text-green-600 dark:text-green-400",warning:"text-yellow-600 dark:text-yellow-400",error:"text-red-600 dark:text-red-400",info:"text-cyan-600 dark:text-cyan-400"},Qi="bg-[repeating-linear-gradient(45deg,transparent,transparent_10px,rgba(255,255,255,0.2)_10px,rgba(255,255,255,0.2)_20px)]",ef={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 tl({value:e=0,indeterminate:t=false,size:r="md",color:o="primary",variant:n="default",showValue:a=false,valueFormat:i,label:c,animated:d=true,className:l,...u}){let p=Math.min(100,Math.max(0,e)),m=n==="gradient"?ef[o]:Zg[o],g=i?i(p):`${Math.round(p)}%`;return jsxs("div",{className:s("w-full",l),...u,children:[(c||a)&&jsxs("div",{className:"flex items-center justify-between mb-1",children:[c&&jsx("span",{className:"text-sm font-medium text-gray-700 dark:text-gray-300",children:c}),a&&!t&&jsx("span",{className:s("text-sm font-semibold",Qg[o],!c&&"ml-auto"),children:g})]}),jsx("div",{role:"progressbar","aria-valuenow":t?void 0:p,"aria-valuemin":0,"aria-valuemax":100,"aria-label":c,className:s("relative w-full overflow-hidden rounded-full bg-gray-200 dark:bg-gray-700",Jg[r]),children:t?jsx("div",{className:s("absolute h-full w-1/3 rounded-full",m,n==="striped"&&Qi,"animate-[progress-indeterminate_1.5s_ease-in-out_infinite]")}):jsx("div",{className:s("h-full rounded-full",m,n==="striped"&&Qi,d&&"transition-[width] duration-300 ease-out"),style:{width:`${p}%`}})})]})}tl.displayName="ProgressBar";var nf=e=>({sm:"w-4 h-4",md:"w-5 h-5",lg:"w-6 h-6"})[e],af=e=>({sm:"w-2 h-2",md:"w-2.5 h-2.5",lg:"w-3 h-3"})[e],sf=(e,t,r,o,n,a,i,c)=>{if(t)return s("border-2",o?"":"border-red-500",r&&!n?"bg-red-500":"");switch(e){case "filled":return s("border-2",c?"":"border-gray-300 dark:border-gray-600",r?a?"":"bg-blue-600 border-blue-600 dark:bg-blue-500 dark:border-blue-500":i?"":"bg-gray-200 border-gray-200 dark:bg-gray-700 dark:border-gray-700");case "outlined":return s("border-[3px]",c?"":r?"border-blue-600 dark:border-blue-500":"border-gray-300 dark:border-gray-600","bg-white dark:bg-gray-800");default:return s("border-2",c?"":r?"border-blue-600 dark:border-blue-500":"border-gray-300 dark:border-gray-600","bg-white dark:bg-gray-800")}},lf={},rl=forwardRef(({label:e,description:t,value:r,checked:o,defaultChecked:n=false,onCheckedChange:a,size:i="md",variant:c="default",labelPosition:d="right",error:l=false,disabled:u=false,readOnly:p=false,required:m=false,checkedColor:g,uncheckedColor:f,borderColor:h,labelColor:b,errorColor:x,dotColor:v,hoverColor:k,focusRingColor:D,showFocusRing:N=true,className:E,containerClassName:M,...R},P)=>{let[A,$]=useState(n),q=o!==void 0,L=q?o:A,_=useId(),z=typeof l=="string"?l:void 0,y=!!l,S=xe=>{if(u||p)return;let le=xe.target.checked;q||$(le),a?.(le);},T=useMemo(()=>sf(c,y,L,x,v,g,f,h),[c,y,L,x,v,g,f,h]),Q=useMemo(()=>{let xe={};return g&&L&&(xe.backgroundColor=g,xe.borderColor=g),f&&!L&&(xe.backgroundColor=f),h&&(xe.borderColor=h),xe},[g,f,h,L]),ie=useMemo(()=>v?{backgroundColor:v}:{},[v]),we=useMemo(()=>b?{color:b}:{},[b]),he=useMemo(()=>x?{color:x}:{},[x]),F=b?"":"text-gray-700 dark:text-gray-200",ee=x?"":"text-red-500",ae=k?"":"hover:border-blue-500 dark:hover:border-blue-400",ye=D?"":"focus-visible:ring-blue-500";return jsxs("div",{className:s("inline-flex flex-col",M),style:lf,children:[jsxs("label",{className:s("inline-flex items-center cursor-pointer",u&&"opacity-50 cursor-not-allowed",p&&"cursor-default",d==="left"&&"flex-row-reverse"),htmlFor:_,children:[jsxs("div",{className:"relative inline-flex items-center",children:[jsx("input",{ref:P,type:"radio",id:_,value:r,checked:L,onChange:S,disabled:u,readOnly:p,required:m,"aria-invalid":y,"aria-describedby":z?`${_}-error`:void 0,className:"sr-only peer",tabIndex:p?-1:void 0,...R}),jsx("div",{className:s("rounded-full transition-all duration-200",nf(i),T,!u&&!p&&ae,!u&&!p&&N&&"peer-focus-visible:ring-2 ring-offset-2",!u&&!p&&N&&ye,E),style:Q,children:L&&jsx("div",{className:s("rounded-full absolute inset-0 m-auto transition-all duration-200",af(i),v?"":c==="outlined"||c==="default"?"bg-blue-600 dark:bg-blue-500":"bg-white"),style:ie})})]}),e&&jsxs("span",{className:s("select-none",d==="left"?"mr-2":"ml-2",F,u&&"opacity-50"),style:we,children:[e,m&&jsx("span",{className:"text-red-500 ml-1",children:"*"})]})]}),t&&!y&&jsx("p",{className:s("text-sm text-gray-500 dark:text-gray-400 mt-1",d==="left"?"text-right":"ml-7"),children:t}),z&&jsx("p",{id:`${_}-error`,className:s("text-sm mt-1",d==="left"?"text-right":"ml-7",ee),style:he,children:z})]})});rl.displayName="RadioButton";var Ia=()=>{},gf=[],ff=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"})}),mf=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"})}),bf=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"})]}),hf=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"})}),Uo={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"}},ol={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 Er(...e){let t="";for(let r=0;r<e.length;r++){let o=e[r];o&&(t&&(t+=" "),t+=o);}return t}function yf(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 xf=memo(forwardRef(function({option:t,isSelected:r,isHighlighted:o,isDisabled:n,sizeKey:a,optionId:i,onClick:c,onMouseEnter:d,index:l},u){let p=()=>{n||c(t.value);},m=()=>{n||d(l);};return jsxs("div",{ref:u,id:i,role:"option","aria-selected":r,"aria-disabled":n||void 0,"data-highlighted":o||void 0,className:Er(Uo[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:m,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:hf}):null]})}));function vf({options:e=gf,value:t,defaultValue:r,onValueChange:o,searchable:n=false,clearable:a=false,disabled:i=false,readOnly:c=false,loading:d=false,size:l="md",variant:u="default",placeholder:p="Select...",label:m,description:g,helperText:f,error:h,required:b=false,noOptionsText:x="No options",onSearchChange:v,name:k,className:D,triggerClassName:N,contentClassName:E,maxHeight:M=256}){let R=useId(),P=`${R}-label`,A=`${R}-trigger`,$=`${R}-listbox`,q=useRef(null),L=useRef(null),_=useRef(null),z=useRef([]),y=t!==void 0,[S,T]=useState(r??""),Q=y?t:S,[ie,we]=useState(false),[he,F]=useState(""),[ee,ae]=useState(-1),[ye,xe]=useState(null),le=useMemo(()=>n?yf(e,he):e,[e,he,n]),X=useMemo(()=>e.find(J=>J.value===Q)??null,[e,Q]),C=useMemo(()=>{let J=new Set;for(let fe of e)fe.disabled&&J.add(fe.value);return J},[e]),U=useCallback(J=>{y||T(J),(o??Ia)(J),we(false),F(""),ae(-1),q.current?.focus();},[y,o]),ge=useCallback(J=>{J.stopPropagation(),y||T(""),(o??Ia)(""),F(""),q.current?.focus();},[y,o]),re=useCallback(()=>{i||c||(we(true),F(""),ae(-1));},[i,c]),B=useCallback(()=>{we(false),F(""),ae(-1),q.current?.focus();},[]),te=useCallback(()=>{ie?B():re();},[ie,B,re]),me=useCallback((J,fe)=>{let Ke=le.length;if(Ke===0)return -1;let xt=J;for(let Ee=0;Ee<Ke;Ee++)if(xt=((xt+fe)%Ke+Ke)%Ke,!C.has(le[xt].value))return xt;return -1},[le,C]),Se=useCallback(J=>{if(!(i||c)){if(ie){switch(J.key){case "ArrowDown":{J.preventDefault();let fe=me(ee,1);fe!==-1&&ae(fe);break}case "ArrowUp":{J.preventDefault();let fe=me(ee,-1);fe!==-1&&ae(fe);break}case "Home":{J.preventDefault();let fe=me(-1,1);fe!==-1&&ae(fe);break}case "End":{J.preventDefault();let fe=me(le.length,-1);fe!==-1&&ae(fe);break}case "Enter":{if(J.preventDefault(),ee>=0&&ee<le.length){let fe=le[ee];C.has(fe.value)||U(fe.value);}break}case " ":if(J.preventDefault(),ee>=0&&ee<le.length){let fe=le[ee];C.has(fe.value)||U(fe.value);}else B();break;case "Escape":J.preventDefault(),B();break;case "Tab":B();break}return}switch(J.key){case "ArrowDown":case "ArrowUp":J.preventDefault(),re();break;case "Enter":case " ":J.preventDefault(),re();break}}},[i,c,ie,re,B,ee,le,C,me,U]),j=useCallback(J=>{switch(J.key){case "ArrowDown":{J.preventDefault();let fe=me(ee,1);fe!==-1&&ae(fe);break}case "ArrowUp":{J.preventDefault();let fe=me(ee,-1);fe!==-1&&ae(fe);break}case "Home":{J.preventDefault();let fe=me(-1,1);fe!==-1&&ae(fe);break}case "End":{J.preventDefault();let fe=me(le.length,-1);fe!==-1&&ae(fe);break}case "Enter":{if(J.preventDefault(),ee>=0&&ee<le.length){let fe=le[ee];C.has(fe.value)||U(fe.value);}break}case "Escape":J.preventDefault(),B();break;case "Tab":B();break}},[ee,le,C,me,U,B]),Te=useCallback(J=>{let fe=J.target.value;F(fe),ae(-1),(v??Ia)(fe);},[v]);useEffect(()=>{if(!ie)return;let J=fe=>{let Ke=fe.target;q.current?.contains(Ke)||L.current?.contains(Ke)||B();};return document.addEventListener("mousedown",J),document.addEventListener("touchstart",J,{passive:true}),()=>{document.removeEventListener("mousedown",J),document.removeEventListener("touchstart",J);}},[ie,B]),useEffect(()=>{if(!ie||!q.current){xe(null);return}let J=()=>{let fe=q.current;if(!fe)return;let Ke=fe.getBoundingClientRect(),xt=window.innerHeight-Ke.bottom,Ee=Ke.top,We=M+8,ht=xt<We&&Ee>xt?"top":"bottom";xe({top:ht==="bottom"?Ke.bottom+window.scrollY+4:Ke.top+window.scrollY-We,left:Ke.left+window.scrollX,width:Ke.width,placement:ht});};return J(),window.addEventListener("scroll",J,true),window.addEventListener("resize",J),()=>{window.removeEventListener("scroll",J,true),window.removeEventListener("resize",J);}},[ie,M]),useEffect(()=>{ie&&n&&_.current?.focus();},[ie,n]),useEffect(()=>{let J=L.current;if(!(!ie||!J))return _r(J,()=>q.current)},[ie]),useEffect(()=>{if(ee>=0){let J=z.current[ee];J&&typeof J.scrollIntoView=="function"&&J.scrollIntoView({block:"nearest"});}},[ee]);let Pe=Q!==""&&Q!==void 0,et=a&&Pe&&!i&&!c&&!d,at=!i&&!c,pt=Er("w-full flex items-center justify-between rounded-md transition-colors","text-gray-900 dark:text-gray-100",Uo[l].trigger,ol[u].trigger,!h&&at&&ol[u].focus,h&&"border-red-500 dark:border-red-400 focus:ring-2 focus:ring-red-500 focus:border-red-500",i&&"opacity-50 cursor-not-allowed bg-gray-50 dark:bg-gray-900",c&&"cursor-default",!i&&!c&&"cursor-pointer",N);return jsxs("div",{className:Er("flex flex-col gap-1",D),children:[m?jsxs("label",{id:P,htmlFor:A,className:"text-sm font-medium text-gray-700 dark:text-gray-300",children:[m,b?jsx("span",{className:"text-red-500 ml-0.5","aria-hidden":"true",children:"*"}):null]}):null,g?jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400",children:g}):null,jsxs("button",{ref:q,id:A,type:"button",role:"combobox","aria-expanded":ie,"aria-haspopup":"listbox","aria-controls":ie?$:void 0,"aria-labelledby":m?P:void 0,"aria-required":b||void 0,"aria-invalid":h?true:void 0,"aria-activedescendant":ie&&ee>=0?`${R}-option-${ee}`:void 0,disabled:i,className:pt,onClick:at?te:void 0,onKeyDown:Se,children:[jsxs("span",{className:Er("flex items-center gap-2 min-w-0 flex-1 truncate",!Pe&&"text-gray-400 dark:text-gray-500"),children:[X?.icon?jsx("span",{className:"flex shrink-0 items-center",children:X.icon}):null,jsx("span",{className:"truncate",children:Pe&&X?X.label:p})]}),jsxs("span",{className:"flex items-center gap-1 shrink-0",children:[d?jsx("span",{className:"text-gray-400",children:bf}):null,et?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:J=>J.preventDefault(),children:mf}):null,jsx("span",{className:Er("text-gray-400 transition-transform duration-200",ie&&"rotate-180"),children:ff})]})]}),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,k?jsx("input",{type:"hidden",name:k,value:Q??""}):null,ie&&ye?createPortal(jsxs("div",{ref:L,role:"listbox",id:$,"aria-labelledby":m?P:void 0,className:Er("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",Uo[l].content,E),style:{top:ye.top,left:ye.left,width:ye.width,position:"absolute"},onKeyDown:j,children:[n?jsx("div",{className:"border-b border-gray-200 dark:border-gray-700",children:jsx("input",{ref:_,type:"text",role:"searchbox","aria-label":"Search options",className:Er(Uo[l].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:he,onChange:Te,onKeyDown:j})}):null,jsx("div",{className:"overflow-y-auto",style:{maxHeight:M},children:le.length===0?jsx("div",{className:Er(Uo[l].option,"text-gray-500 dark:text-gray-400 text-center py-4"),children:x}):le.map((J,fe)=>jsx(xf,{option:J,isSelected:J.value===Q,isHighlighted:fe===ee,isDisabled:d||C.has(J.value),sizeKey:l,optionId:`${R}-option-${fe}`,onClick:U,onMouseEnter:ae,index:fe,ref:Ke=>{z.current[fe]=Ke;}},J.value))})]}),document.body):null]})}var Pa=createContext(null);function Xr(){let e=useContext(Pa);if(!e)throw new Error("Sidebar sub-components must be used within <Sidebar>");return e}function Cf(){return Xr()}var Nf=({className:e})=>jsx("svg",{className:s("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"})}),Sf=({className:e})=>jsx("svg",{className:s("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"})}),Rf=({className:e})=>jsx("svg",{className:s("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 sl({text:e,position:t,children:r}){let[o,n]=useState(false),[a,i]=useState({top:0,left:0}),c=useRef(null);return jsxs("div",{ref:c,onMouseEnter:()=>{if(c.current){let l=c.current.getBoundingClientRect();i({top:l.top+l.height/2,left:t==="left"?l.right+8:l.left-8});}n(true);},onMouseLeave:()=>n(false),className:"relative",children:[r,o&&jsx("div",{className:s("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 Tf({collapsed:e,defaultCollapsed:t=false,onCollapsedChange:r,expandedWidth:o=260,collapsedWidth:n=64,position:a="left",variant:i="default",mobileBreakpoint:c=768,mobileOpen:d,onMobileOpenChange:l,className:u,"aria-label":p,closeLabel:m,trapFocus:g=true,initialFocus:f,returnFocus:h,lockScroll:b=true,children:x}){let v=Gt(),k=useRef(null),D=useRef(null),[N,E]=useState(t),[M,R]=useState(false),[P,A]=useState(false),$=e!==void 0,q=$?e:N,L=d!==void 0,_=L?d:M;useEffect(()=>{let F=window.matchMedia(`(max-width: ${c}px)`),ee=ae=>{A(ae.matches),ae.matches||(L||R(false),l?.(false));};return ee(F),F.addEventListener("change",ee),()=>F.removeEventListener("change",ee)},[c,L,l]);let z=useCallback(()=>{if(P){let F=!_;L||R(F),l?.(F);}else {let F=!q;$||E(F),r?.(F);}},[P,_,q,L,$,l,r]),y=useCallback(()=>{L||R(false),l?.(false);},[L,l]);useEffect(()=>{let F=D.current;F&&(P&&!_?(F.setAttribute("inert",""),F.setAttribute("aria-hidden","true")):(F.removeAttribute("inert"),F.removeAttribute("aria-hidden")));},[P,_]);let{dialogRef:S,dialogProps:T}=$r({open:P&&_,onClose:y,trapFocus:g,initialFocus:f,returnFocus:h,lockScroll:b,keepInteractive:[k]}),Q={default:"bg-white dark:bg-gray-900",bordered:s("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"},ie=q&&!P?n:o,we=jsx("aside",{className:s("flex flex-col h-full overflow-hidden transition-[width] duration-200 ease-in-out",Q[i],u),style:{width:P?o:ie,minWidth:P?o:ie},"data-testid":"sidebar","data-collapsed":q&&!P,"data-mobile":P,"data-position":a,children:x}),he={collapsed:q&&!P,isMobile:P,mobileOpen:_,position:a,variant:i,expandedWidth:o,collapsedWidth:n,toggle:z,closeMobile:y,closeLabel:m};return P?jsxs(Pa.Provider,{value:he,children:[_&&jsx("div",{ref:k,className:"fixed inset-0 z-40 bg-black/50 transition-opacity",onClick:y,"aria-hidden":"true","data-testid":"sidebar-overlay"}),jsx("div",{ref:F=>{D.current=F,S.current=F;},...T,"aria-label":p??v.sidebar,className:s("fixed top-0 z-50 h-full transition-transform duration-200 ease-in-out focus:outline-none",a==="left"?"left-0":"right-0",_?"translate-x-0":a==="left"?"-translate-x-full":"translate-x-full"),children:we})]}):jsx(Pa.Provider,{value:he,children:we})}function Df({className:e,children:t}){let r=Xr(),o=Gt();return jsxs("div",{className:s("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(Rf,{})})]})}function Ef({className:e,children:t}){return jsx("div",{className:s("flex-1 overflow-y-auto overflow-x-hidden py-2",e),"data-testid":"sidebar-content",children:t})}function If({className:e,children:t}){let r=Xr();return jsx("div",{className:s("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 Mf({label:e,className:t,children:r}){let o=Xr();return jsxs("div",{className:s("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 Pf({icon:e,label:t,badge:r,badgeColor:o="bg-blue-600 text-white",active:n=false,disabled:a=false,href:i,onClick:c,tooltip:d,className:l}){let u=Xr(),p=u.collapsed,m=d??t,g=jsxs(Fragment,{children:[e&&jsx("span",{className:s("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:s("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=s("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",l),h=()=>{a||(c?.(),u.isMobile&&u.closeMobile());},b=i?jsx("a",{href:a?void 0:i,className:f,onClick:h,"aria-current":n?"page":void 0,"data-testid":"sidebar-item",children:g}):jsx("button",{type:"button",className:f,onClick:h,disabled:a,"aria-current":n?"page":void 0,"data-testid":"sidebar-item",children:g});return p?jsx(sl,{text:m,position:u.position,children:b}):b}function Lf({icon:e,label:t,badge:r,defaultOpen:o=false,className:n,children:a}){let i=Xr(),[c,d]=useState(o),l=useRef(null),[u,p]=useState(o?void 0:0),m=useRef(true);return useEffect(()=>{if(m.current){m.current=false,p(c?void 0:0);return}if(c){let g=l.current;if(g){p(g.scrollHeight);let f=setTimeout(()=>p(void 0),200);return ()=>clearTimeout(f)}}else {let g=l.current;g&&(p(g.scrollHeight),requestAnimationFrame(()=>p(0)));}},[c]),i.collapsed?jsx(sl,{text:t,position:i.position,children:jsxs("button",{type:"button",className:s("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:()=>{i.toggle(),d(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:s("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:()=>d(!c),"aria-expanded":c,"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(Sf,{className:s("shrink-0 text-gray-400 transition-transform duration-200",c&&"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:l,className:"pl-4 py-0.5",children:a})})]})}function zf({className:e}){let t=Xr(),r=Gt(),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:s("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(Nf,{className:s("transition-transform duration-200",t.collapsed&&"rotate-180",t.position==="right"&&!t.collapsed&&"rotate-180",t.position==="right"&&t.collapsed&&"rotate-0")})})}var Af={text:"rounded h-4 w-full",circular:"rounded-full",rectangular:"rounded-none",rounded:"rounded-lg"},Wf={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:""},Ff="bg-gray-200 dark:bg-gray-700";function il({variant:e="text",animation:t="pulse",width:r,height:o,count:n=1,className:a,style:i,...c}){let d={...r!==void 0&&{width:typeof r=="number"?`${r}px`:r},...o!==void 0&&{height:typeof o=="number"?`${o}px`:o},...i};e==="circular"&&r&&!o&&(d.height=d.width);let l=s(Ff,Af[e],Wf[t],a);return n===1?jsx("div",{className:l,style:d,"aria-busy":"true","aria-live":"polite",...c}):jsx("div",{className:"space-y-2",children:Array.from({length:n}).map((u,p)=>jsx("div",{className:l,style:d,"aria-busy":"true","aria-live":"polite",...c},p))})}il.displayName="Skeleton";var _f={sm:"h-1",md:"h-1.5",lg:"h-2"},$f={sm:"w-3.5 h-3.5",md:"w-4 h-4",lg:"w-5 h-5"},Uf={sm:14,md:16,lg:20},Gf="[&::-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",Kf={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"},Yf={sm:"h-4",md:"h-5",lg:"h-6"},Xf={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"},jf={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"},qf={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"},Jf={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"},ll=(e,t,r)=>Math.min(r,Math.max(t,e)),za=(e,t,r)=>r>t?(ll(e,t,r)-t)/(r-t)*100:0,Dn=(e,t)=>{let r=(.5-e/100)*t,o=Math.round(Math.abs(r)*1e3)/1e3;return `calc(${e}% ${r<0?"-":"+"} ${o}px)`},Zf=(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},(i,c)=>({value:t+c*n}))},dl=forwardRef(({value:e,defaultValue:t,onValueChange:r,min:o=0,max:n=100,step:a=1,size:i="md",color:c="primary",disabled:d=false,readOnly:l=false,label:u,description:p,error:m=false,showValue:g=false,showTooltip:f=false,valueFormat:h,marks:b,trackColor:x,fillColor:v,thumbColor:k,className:D,containerClassName:N,id:E,...M},R)=>{let[P,A]=useState(t??o),$=e!==void 0,L=ll($?e:P,o,n),_=useId(),z=E??_,y=typeof m=="string"?m:void 0,S=!!m,T=!d&&!l,Q=S?"error":c,ie=za(L,o,n),we=Uf[i],he=X=>{if(!T)return;let C=Number(X.target.value);$||A(C),r?.(C);},F=useMemo(()=>Zf(b,o,n,a),[b,o,n,a]),ee=F.some(X=>X.label!=null),ae=h?h(L):`${L}`,ye={width:Dn(ie,we)};v&&(ye.backgroundColor=v);let xe={left:Dn(ie,we)};k&&(xe.backgroundColor=k,xe.borderColor=k);let le=x?{backgroundColor:x}:{};return jsxs("div",{className:s("w-full",N),children:[(u||g)&&jsxs("div",{className:"flex items-center justify-between mb-1.5",children:[u?jsx("label",{htmlFor:z,className:s("text-sm font-medium text-gray-700 dark:text-gray-200",d&&"opacity-50"),children:u}):jsx("span",{}),g&&jsx("span",{className:s("text-sm font-semibold tabular-nums",Jf[Q]),children:ae})]}),jsxs("div",{className:s("relative flex items-center",Yf[i],d&&"opacity-50"),children:[jsx("input",{ref:R,type:"range",id:z,min:o,max:n,step:a,value:L,onChange:he,disabled:d,readOnly:l,"aria-invalid":S,"aria-readonly":l||void 0,"aria-describedby":y?`${z}-error`:void 0,tabIndex:T?void 0:-1,className:s("peer absolute inset-0 z-10 m-0 h-full w-full cursor-pointer appearance-none bg-transparent opacity-0",Gf,Kf[i],!T&&"pointer-events-none cursor-default",D),...M}),jsxs("div",{className:s("pointer-events-none relative w-full overflow-hidden rounded-full bg-gray-200 dark:bg-gray-700",_f[i]),style:le,children:[jsx("div",{className:s("absolute inset-y-0 left-0 rounded-full transition-[width] duration-150 ease-out",v?"":Xf[Q]),style:ye}),F.map((X,C)=>{let U=za(X.value,o,n),ge=X.value<=L;return jsx("span",{"data-slider-mark":"",className:s("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:Dn(U,we)}},`mark-${X.value}-${C}`)})]}),jsx("div",{"data-slider-thumb":"",className:s("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",$f[i],k?"":jf[Q],T&&"peer-hover:scale-110 peer-active:scale-110","peer-focus-visible:scale-110 peer-focus-visible:ring-2 peer-focus-visible:ring-offset-2",qf[Q]),style:xe,children:f&&jsx("span",{"data-slider-tooltip":"",className:s("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:ae})})]}),ee&&jsx("div",{className:"relative mt-1.5 h-4",children:F.map((X,C)=>X.label!=null?jsx("span",{className:"absolute -translate-x-1/2 whitespace-nowrap text-xs text-gray-500 dark:text-gray-400",style:{left:Dn(za(X.value,o,n),we)},children:X.label},`mark-label-${X.value}-${C}`):null)}),p&&!y&&jsx("p",{className:"mt-1.5 text-sm text-gray-500 dark:text-gray-400",children:p}),y&&jsx("p",{id:`${z}-error`,className:"mt-1.5 text-sm text-red-500 dark:text-red-400",children:y})]})});dl.displayName="Slider";function Qf({children:e,className:t,...r}){return jsx("table",{className:s("w-full text-sm text-left rtl:text-right text-gray-500 dark:text-gray-400",t),...r,children:e})}function tm({children:e,className:t,...r}){return jsx("thead",{className:s("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 rm({children:e,onClick:t,hidden:r=false,className:o,sortable:n=false,...a}){return jsx("th",{scope:"col",className:s("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 nm({children:e,className:t,...r}){return jsx("tbody",{className:s(t),...r,children:e})}function sm({children:e,onClick:t,clickable:r=true,className:o,...n}){return jsx("tr",{className:s("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})}function lm({children:e,onClick:t,hidden:r=false,className:o,...n}){return jsx("td",{className:s("px-6 py-4",o),onClick:t,hidden:r,...n,children:e})}var Aa=createContext(null);function fo(){let e=useContext(Aa);if(!e)throw new Error("Tabs components must be used within a Tabs provider");return e}function pl({children:e,defaultValue:t="",value:r,onValueChange:o,variant:n="underline",size:a="md",color:i="default",fullWidth:c=false,orientation:d="horizontal",className:l}){let[u,p]=useState(t),m=r!==void 0,g=m?r:u,f=useCallback(b=>{m||p(b),o?.(b);},[m,o]),h=useMemo(()=>({value:g,onValueChange:f,variant:n,size:a,color:i,orientation:d,fullWidth:c}),[g,f,n,a,i,d,c]);return jsx(Aa.Provider,{value:h,children:jsx("div",{className:s("w-full",d==="vertical"&&"flex gap-4",l),"data-orientation":d,children:e})})}pl.displayName="Tabs";var mm={none:"gap-0",sm:"gap-1",md:"gap-2",lg:"gap-4"};function gl({children:e,className:t,bgColor:r,gap:o="none"}){let{variant:n,orientation:a,fullWidth:i}=fo(),c=s("flex",a==="vertical"?"flex-col":"flex-row items-center",mm[o]),d={underline:"border-b border-gray-200 dark:border-gray-700",pills:s("p-1 rounded-lg",r||"bg-gray-100 dark:bg-gray-800"),enclosed:"border-b border-gray-200 dark:border-gray-700",soft:s("p-1 rounded-lg",r||"bg-gray-100/50 dark:bg-gray-800/50")};return jsx("div",{role:"tablist","aria-orientation":a,className:s(c,d[n],i&&"w-full",t),children:e})}gl.displayName="TabsList";var hm={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"},fl={sm:"w-3.5 h-3.5",md:"w-4 h-4",lg:"w-5 h-5"},ml={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"}}},ym={underline:"border-b-2 -mb-px",pills:"rounded-md",enclosed:"border border-b-0 rounded-t-md -mb-px",soft:"rounded-md"};function bl({value:e,children:t,disabled:r=false,icon:o,endIcon:n,className:a,activeClassName:i,inactiveClassName:c}){let{value:d,onValueChange:l,variant:u,size:p,color:m,fullWidth:g}=fo(),f=d===e,h=()=>{r||l(e);},b=D=>{(D.key==="Enter"||D.key===" ")&&(D.preventDefault(),h());},x=s("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",hm[p],g&&"flex-1"),v=f?s(ml[m][u].active,i):s(ml[m][u].inactive,c),k=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:b,disabled:r,className:s(x,ym[u],v,k,a),children:[o&&jsx("span",{className:s("shrink-0",fl[p]),children:o}),jsx("span",{children:t}),n&&jsx("span",{className:s("shrink-0",fl[p]),children:n})]})}bl.displayName="TabsTrigger";function hl({value:e,children:t,className:r,forceMount:o=false}){let{value:n}=fo(),a=n===e;return !a&&!o?null:jsx("div",{role:"tabpanel",hidden:!a,tabIndex:0,className:s("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})}hl.displayName="TabsContent";function wm({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 km({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 Cm({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 yl({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 Nm({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 Sm={success:wm,error:km,warning:Cm,info:yl,default:yl},Rm={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"}},Tm={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 vl({children:e,title:t,description:r,type:o="default",variant:n="soft",icon:a,action:i,onClose:c,closable:d=true,className:l,...u}){let p=Sm[o],m=jsx(p,{className:"w-5 h-5"}),g=e??r;return jsxs("div",{role:"alert",className:s("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",Rm[o][n],l),...u,children:[jsx("div",{className:s("flex-shrink-0 mt-0.5",n==="solid"?"text-white":Tm[o]),children:a??m}),jsxs("div",{className:"flex-1 min-w-0",children:[t&&jsx("div",{className:"font-semibold text-sm mb-1",children:t}),g&&jsx("div",{className:"text-sm opacity-90",children:g}),i&&jsx("div",{className:"mt-3",children:i})]}),d&&jsx("button",{type:"button",onClick:c,className:s("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(Nm,{className:"w-4 h-4"})})]})}vl.displayName="Toast";var Im={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"},Mm={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"}},Pm={sm:"px-2 py-1 text-xs",md:"px-3 py-1.5 text-sm",lg:"px-4 py-2 text-base"},Lm={sm:"border-4",md:"border-[5px]",lg:"border-[6px]"},zm={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"},Am={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 dt({children:e,content:t,position:r="top",variant:o="default",size:n="md",trigger:a="hover",open:i,delay:c=0,showArrow:d=true,maxWidth:l="max-w-xs",className:u,contentClassName:p,disabled:m=false,...g}){let[f,h]=useState(false),b=useRef(null),x=useCallback(()=>{m||(c>0?b.current=setTimeout(()=>h(true),c):h(true));},[c,m]),v=useCallback(()=>{b.current&&(clearTimeout(b.current),b.current=null),h(false);},[]),k=useCallback(()=>{m||h(E=>!E);},[m]),D=a==="manual"?i:f,N={hover:{onMouseEnter:x,onMouseLeave:v,onFocus:x,onBlur:v},click:{onClick:k},manual:{}}[a];return jsxs("div",{className:s("relative inline-flex",u),...N,...g,children:[e,D&&!m&&jsxs("div",{role:"tooltip",className:s("absolute z-50 whitespace-normal wrap-break-word rounded-md","transition-opacity duration-150",zm[r],Im[o],Pm[n],l,p),children:[t,d&&jsx("span",{className:s("absolute w-0 h-0 border-solid",Lm[n],Am[r],Mm[o][r]),"aria-hidden":"true"})]})]})}dt.displayName="Tooltip";function Fm(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 Hm(e){switch(e){case "sm":return "py-6";case "lg":return "py-16";default:return "py-10"}}function Cl({variant:e="default",size:t="md",sticky:r=false,className:o,children:n,...a}){return jsx("footer",{className:s(Fm(e),Hm(t),r&&"sticky bottom-0 z-40",o),...a,children:jsx("div",{className:"container mx-auto px-4",children:n})})}Cl.displayName="Footer";function Bm(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 Nl({title:e,titleClassName:t,columns:r,className:o,children:n,...a}){return jsxs("div",{className:s(r&&"grid gap-8",Bm(r),o),...a,children:[e&&jsx("h3",{className:s("text-sm font-semibold uppercase tracking-wider text-gray-900 dark:text-white",r&&"col-span-full",t),children:e}),n]})}Nl.displayName="FooterSection";function Sl({title:e,titleClassName:t,className:r,children:o,...n}){return jsxs("div",{className:s("flex flex-col gap-3",r),...n,children:[e&&jsx("h4",{className:s("text-sm font-semibold uppercase tracking-wider text-gray-900 dark:text-white",t),children:e}),o]})}Sl.displayName="FooterColumn";function Rl({external:e=false,className:t,children:r,...o}){return jsx("a",{className:s("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})}Rl.displayName="FooterLink";function Tl({copyright:e,className:t,children:r,...o}){return jsxs("div",{className:s("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]})}Tl.displayName="FooterBottom";function Dl({className:e,children:t,...r}){return jsx("div",{className:s("flex items-center gap-4",e),...r,children:t})}Dl.displayName="FooterSocial";function El({icon:e,label:t,className:r,...o}){return jsx("a",{className:s("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})}El.displayName="FooterSocialLink";var Ml="se-grid-pattern",Pl=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:Ml,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(#${Ml})`})]})});function Ir(e,t){return e.collapsed?40:e.height?e.height:40+(e.notes?24:0)+e.fields.length*32+(t?36:0)}function mo(e,t){return 40+(t?24:0)+e*32+32/2}function Ll(e,t,r){let o=e.fields.findIndex(d=>d.id===t);if(o===-1)return null;let n=e.width??260,a=!!e.notes,i=e.y+mo(o,a);return {x:r==="left"?e.x+0:e.x+n-0,y:i}}function Ha(e,t){return Math.round(e/t)*t}function Ko(e,t,r){return Math.min(r,Math.max(t,e))}function Yo(e,t,r,o){return {x:(e-o.left-r.x)/r.zoom,y:(t-o.top-r.y)/r.zoom}}function Mn(e,t,r,o){let n=Math.abs(r-e),a=Math.max(50,n*.5),i=e+a,c=t,d=r-a;return `M ${e} ${t} C ${i} ${c}, ${d} ${o}, ${r} ${o}`}function zl(e,t,r,o,n=40){if(e.length===0)return {x:0,y:0,zoom:1};let a=1/0,i=1/0,c=-1/0,d=-1/0;for(let f of e){let h=f.width??260,b=Ir(f,o);a=Math.min(a,f.x),i=Math.min(i,f.y),c=Math.max(c,f.x+h),d=Math.max(d,f.y+b);}let l=c-a+n*2,u=d-i+n*2,p=Math.min(t/l,r/u,1),m=(t-l*p)/2-(a-n)*p,g=(r-u*p)/2-(i-n)*p;return {x:m,y:g,zoom:p}}var jo=["text","varchar","char","int2","int4","int8","serial","bigserial","float4","float8","numeric","decimal","bool","date","time","timestamp","timestamptz","uuid","json","jsonb","bytea"];function Al(){return `table-${Date.now()}-${Math.random().toString(36).slice(2,8)}`}function Xo(){return `field-${Date.now()}-${Math.random().toString(36).slice(2,8)}`}function Ba(){return `rel-${Date.now()}-${Math.random().toString(36).slice(2,8)}`}function Oa(e="new_field"){return {id:Xo(),name:e,type:"text",nullable:true}}function Va(e,t,r="new_table"){return {id:Al(),name:r,x:e,y:t,fields:[{id:Xo(),name:"id",type:"serial",primaryKey:true},{id:Xo(),name:"createdAt",type:"timestamp"},{id:Xo(),name:"updatedAt",type:"timestamp"}]}}var Pn=()=>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"})]}),Fl=()=>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"})]}),qm=({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"})}),Hl=()=>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"})}),Bl=()=>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"})}),Jm=()=>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"})}),Zm=()=>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"})]}),Qm=memo(function({field:t,tableId:r,editable:o,readOnly:n,disabled:a,onFieldChange:i}){let[c,d]=useState(false),[l,u]=useState(t.defaultValue??""),p=o&&!n&&!a,m=()=>{d(false),i?.(r,t.id,{defaultValue:l||void 0});};return p?c?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:l,onChange:g=>u(g.target.value),onBlur:m,onKeyDown:g=>{g.key==="Enter"&&m(),g.key==="Escape"&&d(false);},onMouseDown:g=>g.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:g=>{g.stopPropagation(),u(t.defaultValue??""),d(true);},onMouseDown:g=>g.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:g=>{g.stopPropagation(),u(""),d(true);},onMouseDown:g=>g.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}),Vl=memo(function({table:t,selected:r,disabled:o,readOnly:n,editable:a,dropTarget:i,fieldTypes:c,onTableNameChange:d,onTableNotesChange:l,onToggleCollapse:u,onFieldChange:p,onFieldAdd:m,onFieldRemove:g,onFieldReorder:f,onResizeStart:h}){let b=t.width??260,x=t.collapsed??false,v=c.length>0?c:jo,[k,D]=useState(null),[N,E]=useState(null),M=useRef(null),R=useCallback(y=>{d?.(t.id,y.target.value);},[t.id,d]),P=useCallback((y,S)=>{p?.(t.id,y,{name:S});},[t.id,p]),A=useCallback((y,S)=>{p?.(t.id,y,{type:S});},[t.id,p]),$=useCallback((y,S)=>{p?.(t.id,y,{primaryKey:!S});},[t.id,p]),q=useCallback((y,S)=>{p?.(t.id,y,{nullable:!S});},[t.id,p]),L=useCallback((y,S)=>{p?.(t.id,y,{indexed:!S});},[t.id,p]),_=useCallback((y,S)=>{p?.(t.id,y,{unique:!S});},[t.id,p]),z=useCallback(()=>{m?.(t.id);},[t.id,m]);return jsxs("div",{"data-table-id":t.id,className:s("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,i?"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:b,height:t.height,userSelect:"none",overflow:t.height?"hidden":void 0},children:[jsxs("div",{className:s("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:R,onMouseDown:y=>y.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:y=>{y.stopPropagation(),u?.(t.id);},onMouseDown:y=>y.stopPropagation(),"aria-label":x?"Expand table":"Collapse table",children:jsx(qm,{collapsed:x})})]}),!x&&(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:y=>l?.(t.id,y.target.value),onMouseDown:y=>y.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),!x&&jsxs("div",{className:t.height?"overflow-y-auto flex-1 min-h-0":void 0,children:[t.fields.map((y,S)=>jsxs("div",{"data-field-id":y.id,"data-table-id":t.id,className:s("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",i?"bg-blue-50/50 dark:bg-blue-900/10":"hover:bg-gray-50 dark:hover:bg-gray-750",k===S&&"opacity-40",N===S&&"!border-t-2 !border-t-blue-400"),style:{height:32},draggable:a&&!n&&!o,onDragStart:T=>{!a||n||o||(T.stopPropagation(),M.current=S,D(S),T.dataTransfer.effectAllowed="move",T.dataTransfer.setData("text/plain",String(S)));},onDragOver:T=>{M.current!==null&&(T.preventDefault(),T.stopPropagation(),E(S));},onDragLeave:()=>{N===S&&E(null);},onDrop:T=>{T.preventDefault(),T.stopPropagation(),M.current!==null&&M.current!==S&&f?.(t.id,M.current,S),M.current=null,D(null),E(null);},onDragEnd:()=>{M.current=null,D(null),E(null);},children:[jsx("div",{"data-connection-side":"left","data-field-id":y.id,"data-table-id":t.id,className:s("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",i?"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(Zm,{})}),a&&!n&&!o?jsx("button",{type:"button",className:s("w-4 text-xs font-bold flex-shrink-0 text-center cursor-pointer",y.nullable?"text-gray-400":"text-transparent"),onClick:T=>{T.stopPropagation(),q(y.id,y.nullable??false);},onMouseDown:T=>T.stopPropagation(),title:y.nullable?"Nullable":"Not nullable",children:"?"}):jsx("span",{className:s("w-4 text-xs font-bold flex-shrink-0 text-center",y.nullable?"text-gray-400":"text-transparent"),children:y.nullable?"?":""}),y.primaryKey&&y.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:T=>{T.stopPropagation(),$(y.id,true);},onMouseDown:T=>T.stopPropagation(),title:"Primary Key (click to remove)",children:jsx(Pn,{})}):jsx(Pn,{}),jsx(Fl,{})]}):y.primaryKey?a&&!n&&!o?jsx("button",{type:"button",className:"flex-shrink-0 cursor-pointer",onClick:T=>{T.stopPropagation(),$(y.id,true);},onMouseDown:T=>T.stopPropagation(),title:"Primary Key (click to remove)",children:jsx(Pn,{})}):jsx(Pn,{}):y.foreignKey?jsx(Fl,{}):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:T=>{T.stopPropagation(),$(y.id,false);},onMouseDown:T=>T.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:s("flex-1 min-w-0 text-xs bg-transparent border-none outline-none focus:ring-0 p-0 truncate cursor-text",y.primaryKey?"text-blue-600 dark:text-blue-400 font-medium":"text-gray-700 dark:text-gray-300"),"aria-label":"Field name",value:y.name,onChange:T=>P(y.id,T.target.value),onMouseDown:T=>T.stopPropagation()}):jsx("span",{className:s("flex-1 min-w-0 text-xs truncate",y.primaryKey?"text-blue-600 dark:text-blue-400 font-medium":"text-gray-700 dark:text-gray-300"),children:y.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:y.type,onChange:T=>A(y.id,T.target.value),onMouseDown:T=>T.stopPropagation(),children:[v.map(T=>jsx("option",{value:T,children:T},T)),!v.includes(y.type)&&jsx("option",{value:y.type,children:y.type})]}):jsx("span",{className:"text-xs text-gray-400 dark:text-gray-500 flex-shrink-0",children:y.type}),jsx(Qm,{field:y,tableId:t.id,editable:a,readOnly:n,disabled:o,onFieldChange:p}),y.indexed&&jsx(Hl,{}),y.unique&&jsx(Bl,{}),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:s("cursor-pointer transition-opacity",y.indexed?"opacity-100":"opacity-30 hover:opacity-100"),onClick:T=>{T.stopPropagation(),L(y.id,y.indexed??false);},onMouseDown:T=>T.stopPropagation(),title:y.indexed?"Indexed (click to remove)":"Add index",children:jsx(Hl,{})}),jsx("button",{type:"button",className:s("cursor-pointer transition-opacity",y.unique?"opacity-100":"opacity-30 hover:opacity-100"),onClick:T=>{T.stopPropagation(),_(y.id,y.unique??false);},onMouseDown:T=>T.stopPropagation(),title:y.unique?"Unique (click to remove)":"Add unique constraint",children:jsx(Bl,{})}),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:T=>{T.stopPropagation(),g?.(t.id,y.id);},onMouseDown:T=>T.stopPropagation(),title:"Remove field",children:jsx(Jm,{})})]}),jsx("div",{"data-connection-side":"right","data-field-id":y.id,"data-table-id":t.id,className:s("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",i?"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}})]},y.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:y=>{y.stopPropagation(),z();},onMouseDown:y=>y.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:y=>{y.stopPropagation(),y.preventDefault();let S=t.height??Ir(t,a);h?.(t.id,y.clientX,y.clientY,b,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 tb(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 i=r.width??260,c=o.width??260,d=r.x+i/2,l=o.x+c/2,u=r.y+mo(n,!!r.notes),p=o.y+mo(a,!!o.notes),m,g;return d<=l?(m=r.x+i,g=o.x):(m=r.x,g=o.x+c),{x1:m,y1:u,x2:g,y2:p,cardinality:e.cardinality??"1:n"}}var Ua=["1:1","1:n","n:1","n:n"];function rb(e){let t=Ua.indexOf(e);return Ua[(t+1)%Ua.length]}var $l=memo(function({relations:t,tables:r,viewport:o,selectedRelationId:n,disabled:a,onRelationClick:i,onCardinalityChange:c}){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(d=>{let l=tb(d,r);if(!l)return null;let{x1:u,y1:p,x2:m,y2:g,cardinality:f}=l,h=Mn(u,p,m,g),b=n===d.id,x=(u+m)/2,v=(p+g)/2;return jsxs("g",{children:[jsx("path",{d:h,fill:"none",stroke:"transparent",strokeWidth:16,className:"pointer-events-auto cursor-pointer",onClick:k=>{a||i?.(d.id,k);}}),jsx("path",{d:h,fill:"none",stroke:b?"#3b82f6":"#9ca3af",strokeWidth:b?2.5:1.5,className:"transition-colors"}),jsx("circle",{cx:u,cy:p,r:3,fill:b?"#3b82f6":"#9ca3af"}),jsx("circle",{cx:m,cy:g,r:3,fill:b?"#3b82f6":"#9ca3af"}),f&&jsxs("g",{className:a?void 0:"pointer-events-auto cursor-pointer",onClick:a?void 0:k=>{k.stopPropagation(),c?.(d.id,rb(f));},children:[jsx("rect",{x:x-14,y:v-9,width:28,height:18,rx:4,fill:"white",stroke:b?"#3b82f6":"#d1d5db",strokeWidth:1}),jsx("text",{x,y:v+4,textAnchor:"middle",className:"text-[10px] font-mono",fill:b?"#3b82f6":"#6b7280",children:f})]})]},d.id)})})})});var nb=()=>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"})}),ab=()=>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"})}),sb=()=>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"})}),ib=()=>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"})}),lb=()=>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"})}),db=()=>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"})}),cb=()=>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"})}),ub=()=>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"})}),pb=()=>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"})}),gb=()=>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"})}),fb=()=>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"})}),Ul=memo(function({zoom:t,onZoomIn:r,onZoomOut:o,onResetView:n,onFitToContent:a,onAddTable:i,onExportJSON:c,onImportJSON:d,onExportSQL:l,onUndo:u,onRedo:p,canUndo:m=false,canRedo:g=false,onAutoLayout:f,disabled:h,className:b}){let[x,v]=useState(false),[k,D]=useState(false),[N,E]=useState(false),[M,R]=useState(""),[P,A]=useState(""),[$,q]=useState(""),L=useCallback(()=>{R(c()),v(true);},[c]),_=useCallback(()=>{P.trim()&&(d(P.trim()),A(""),D(false));},[P,d]),z=useCallback(()=>{A(""),D(false);},[]),y=useCallback(()=>{v(false);},[]),S=useCallback(()=>{l&&(q(l()),E(true));},[l]),T=useCallback(()=>{E(false);},[]),Q=Math.round(t*100);return jsxs(Fragment,{children:[jsxs("div",{className:s("absolute top-3 left-3 z-20 flex items-center gap-2 bg-white dark:bg-gray-800 rounded-lg shadow-md border border-gray-200 dark:border-gray-600 px-2 py-1.5",b),"data-testid":"schema-toolbar",onMouseDown:ie=>ie.stopPropagation(),children:[jsxs(to,{size:"sm",children:[jsx(dt,{content:"Zoom in",size:"sm",position:"bottom",children:jsx(lt,{icon:jsx(nb,{}),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(dt,{content:"Zoom out",size:"sm",position:"bottom",children:jsx(lt,{icon:jsx(ab,{}),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:[Q,"%"]}),jsx("div",{className:"w-px h-5 bg-gray-200 dark:bg-gray-600"}),jsx(dt,{content:"Reset view",size:"sm",position:"bottom",children:jsx(lt,{icon:jsx(sb,{}),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(dt,{content:"Fit to content",size:"sm",position:"bottom",children:jsx(lt,{icon:jsx(ib,{}),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(dt,{content:"Add table",size:"sm",position:"bottom",children:jsx(lt,{icon:jsx(lb,{}),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:i,disabled:h,"aria-label":"Add table"})}),jsx("div",{className:"w-px h-5 bg-gray-200 dark:bg-gray-600"}),jsx(dt,{content:"Export JSON",size:"sm",position:"bottom",children:jsx(lt,{icon:jsx(db,{}),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:h,"aria-label":"Export JSON"})}),jsx(dt,{content:"Import JSON",size:"sm",position:"bottom",children:jsx(lt,{icon:jsx(cb,{}),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(true),disabled:h,"aria-label":"Import JSON"})}),l&&jsx(dt,{content:"Export SQL",size:"sm",position:"bottom",children:jsx(lt,{icon:jsx(ub,{}),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(to,{size:"sm",children:[jsx(dt,{content:"Undo (Ctrl+Z)",size:"sm",position:"bottom",children:jsx(lt,{icon:jsx(pb,{}),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||!m,"aria-label":"Undo"})}),jsx(dt,{content:"Redo (Ctrl+Y)",size:"sm",position:"bottom",children:jsx(lt,{icon:jsx(gb,{}),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||!g,"aria-label":"Redo"})})]})]}),f&&jsxs(Fragment,{children:[jsx("div",{className:"w-px h-5 bg-gray-200 dark:bg-gray-600"}),jsx(dt,{content:"Auto layout",size:"sm",position:"bottom",children:jsx(lt,{icon:jsx(fb,{}),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(vr,{isOpen:x,onClose:y,title:"Export Schema",description:"Copy the JSON below to save your schema.",size:"lg",showSubmit:false,showCancel:true,cancelLabel:"Close",children:jsx(ar,{label:"Schema JSON",multiline:true,rows:12,value:M,readOnly:true,size:"sm"})}),jsx(vr,{isOpen:k,onClose:z,title:"Import Schema",description:"Paste schema JSON to load it into the editor.",size:"lg",showSubmit:true,submitLabel:"Import",onSubmitClick:_,showCancel:true,cancelLabel:"Cancel",children:jsx(ar,{label:"Schema JSON",multiline:true,rows:12,value:P,onChange:ie=>A(ie.target.value),placeholder:'{"tables": [], "relations": []}',size:"sm"})}),jsx(vr,{isOpen:N,onClose:T,title:"Export SQL",description:"Generated PostgreSQL CREATE TABLE statements.",size:"lg",showSubmit:false,showCancel:true,cancelLabel:"Close",children:jsx(ar,{label:"SQL",multiline:true,rows:16,value:$,readOnly:true,size:"sm"})})]})});var bb=()=>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"})]}),hb=()=>jsx("span",{className:"text-xs font-bold text-gray-500 w-3.5 text-center",children:"?"}),yb=()=>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"})]}),xb=()=>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"})}),vb=()=>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"})}),Gl=memo(function({className:t}){return jsxs("div",{className:s("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(bb,{}),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(hb,{}),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(yb,{}),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(xb,{}),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(vb,{}),jsx("span",{className:"text-xs text-gray-600 dark:text-gray-300",children:"Unique"})]})]})});var zn=180,An=120,xo=10,Kl=memo(function({tables:t,viewport:r,containerWidth:o,containerHeight:n,editable:a,onViewportChange:i,className:c}){let d=useRef(null),l=useMemo(()=>{if(t.length===0)return null;let N=1/0,E=1/0,M=-1/0,R=-1/0;for(let T of t){let Q=T.width??260,ie=Ir(T,a);N=Math.min(N,T.x),E=Math.min(E,T.y),M=Math.max(M,T.x+Q),R=Math.max(R,T.y+ie);}let P=-r.x/r.zoom,A=-r.y/r.zoom,$=P+o/r.zoom,q=A+n/r.zoom;N=Math.min(N,P),E=Math.min(E,A),M=Math.max(M,$),R=Math.max(R,q);let L=M-N+xo*2,_=R-E+xo*2,z=Math.min((zn-4)/L,(An-4)/_),y=(zn-L*z)/2,S=(An-_*z)/2;return {minX:N,minY:E,scale:z,offsetX:y,offsetY:S,vpMinX:P,vpMinY:A}},[t,r,o,n,a]),u=useCallback(N=>{if(!l)return;let E=d.current?.getBoundingClientRect();if(!E)return;let M=N.clientX-E.left,R=N.clientY-E.top,P=(M-l.offsetX)/l.scale+l.minX-xo,A=(R-l.offsetY)/l.scale+l.minY-xo;i({...r,x:-(P-o/(2*r.zoom))*r.zoom,y:-(A-n/(2*r.zoom))*r.zoom});},[l,r,o,n,i]);if(!l)return null;let{minX:p,minY:m,scale:g,offsetX:f,offsetY:h,vpMinX:b,vpMinY:x}=l,v=(N,E)=>({x:(N-p+xo)*g+f,y:(E-m+xo)*g+h}),k=v(b,x),D={w:o/r.zoom*g,h:n/r.zoom*g};return jsx("div",{ref:d,className:s("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",c),style:{width:zn,height:An},onClick:u,onMouseDown:N=>N.stopPropagation(),"data-testid":"schema-minimap",children:jsxs("svg",{width:zn,height:An,children:[t.map(N=>{let E=N.width??260,M=Ir(N,a),R=v(N.x,N.y);return jsx("rect",{x:R.x,y:R.y,width:E*g,height:M*g,fill:N.color??"#e5e7eb",stroke:"#9ca3af",strokeWidth:.5,rx:1},N.id)}),jsx("rect",{x:k.x,y:k.y,width:D.w,height:D.h,fill:"rgba(59, 130, 246, 0.1)",stroke:"#3b82f6",strokeWidth:1,rx:1})]})})});function Nr(e){return `"${e.replace(/"/g,'""')}"`}function Yl(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 Rb(e){let t=[Nr(e.name)];return e.type==="serial"||e.type,t.push(Yl(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 Tb(e,t,r){let o=[],n=[];for(let d of e.fields)o.push(Rb(d));for(let d of e.fields)if(d.foreignKey){let l=r.find(p=>p.id===d.foreignKey.tableId),u=l?.fields.find(p=>p.id===d.foreignKey.fieldId);l&&u&&n.push(` CONSTRAINT ${Nr(`fk_${e.name}_${d.name}`)} FOREIGN KEY (${Nr(d.name)}) REFERENCES ${Nr(l.name)} (${Nr(u.name)})`);}let a=[];for(let d of e.fields)d.indexed&&!d.primaryKey&&!d.unique&&a.push(`CREATE INDEX ${Nr(`idx_${e.name}_${d.name}`)} ON ${Nr(e.name)} (${Nr(d.name)});`);let i=[...o,...n],c=`CREATE TABLE ${Nr(e.name)} (
24
- ${i.join(`,
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)} (
24
+ ${s.join(`,
25
25
  `)}
26
- );`;return a.length>0?c+`
26
+ );`;return a.length>0?l+`
27
27
 
28
28
  `+a.join(`
29
- `):c}function Wn(e){let{tables:t,relations:r}=e;return t.length===0?"-- No tables defined":[...t].sort((a,i)=>{let c=a.fields.some(l=>l.foreignKey),d=i.fields.some(l=>l.foreignKey);return c&&!d?1:!c&&d?-1:0}).map(a=>Tb(a,r,t)).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(`
30
30
 
31
- `)}var Db=60,Eb=40;function Ya(e,t){if(e.length===0)return e;let r=new Map;for(let f of e){let h=new Set;for(let b of f.fields)b.foreignKey&&h.add(b.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,b]of r)if(b.has(f)){let x=(o.get(h)??0)-1;o.set(h,x),x===0&&a.push(h);}}let i=new Set(n);for(let f of e)i.has(f.id)||(n.push(f.id),i.add(f.id));let c=new Map(e.map(f=>[f.id,f])),d=Math.max(1,Math.ceil(Math.sqrt(n.length))),l=0,u=0,p=0,m=0,g=[];for(let f of n){let h=c.get(f);if(!h)continue;let b=h.width??260,x=Ir(h,t);g.push({...h,x:l,y:u}),m=Math.max(m,x),p++,p>=d?(p=0,l=0,u+=m+Eb,m=0):l+=b+Db;}return g}var ja={x:0,y:0,zoom:1},qa=.1,Lb=.1,zb=3,Ab=20,Wb=50;function Fb({value:e,defaultValue:t,onValueChange:r,fieldTypes:o=jo,onTableClick:n,onTableDoubleClick:a,onTableContextMenu:i,onFieldClick:c,onFieldDoubleClick:d,readOnly:l=false,disabled:u=false,draggableTables:p=true,panOnDrag:m=true,zoomOnWheel:g=true,editable:f=true,minZoom:h=Lb,maxZoom:b=zb,snapToGrid:x=false,gridSize:v=Ab,showGrid:k=true,toolbar:D=true,legend:N=true,autoFit:E=false,className:M},R){let P=e!==void 0,[A,$]=useState(()=>t??{tables:[],relations:[],viewport:{...ja}}),q=P?e:A,L=q.tables,_=q.relations,z=q.viewport??ja,y=useRef(null),S=useRef(null),[T,Q]=useState(null),[ie,we]=useState(null),[he,F]=useState(null),[ee,ae]=useState(null),[ye,xe]=useState({width:0,height:0}),le=useRef([]),X=useRef(-1),C=useRef(false),U=useRef(z);U.current=z;let ge=useRef(L);ge.current=L;let re=useRef(_);re.current=_;let B=useRef(x);B.current=x;let te=useRef(v);te.current=v;let me=useRef(f);me.current=f;let Se=useCallback(I=>{if(C.current)return;let V=le.current,G=X.current;le.current=V.slice(0,G+1),le.current.push(I),le.current.length>Wb&&le.current.shift(),X.current=le.current.length-1;},[]),j=useCallback(I=>{if(P){let V=I(e);Se(V),r?.(V);}else $(V=>{let G=I(V);return Se(G),r?.(G),G});},[P,e,r,Se]),Te=useRef(j);Te.current=j;let Pe=useCallback(I=>{j(V=>({...V,viewport:I}));},[j]),et=useRef(Pe);et.current=Pe,useEffect(()=>{function I(K){let oe=S.current;if(!oe)return;let Fe=y.current?.getBoundingClientRect();if(!Fe)return;let Ge=U.current;if(oe.type==="pan"){let Ve=K.clientX-oe.startX,Ie=K.clientY-oe.startY;et.current({...Ge,x:oe.startVpX+Ve,y:oe.startVpY+Ie});}if(oe.type==="table"){let Ve=Yo(K.clientX,K.clientY,Ge,Fe),Ie=Ve.x-oe.offsetX,wt=Ve.y-oe.offsetY;B.current&&(Ie=Ha(Ie,te.current),wt=Ha(wt,te.current)),Te.current(_e=>({..._e,tables:_e.tables.map(st=>st.id===oe.tableId?{...st,x:Ie,y:wt}:st)}));}if(oe.type==="relation"){let Ve=Yo(K.clientX,K.clientY,Ge,Fe);S.current={...oe,currentX:Ve.x,currentY:Ve.y},F({fromX:oe.fromX,fromY:oe.fromY,currentX:Ve.x,currentY:Ve.y});}if(oe.type==="resize"){let Ve=(K.clientX-oe.startX)/Ge.zoom,Ie=(K.clientY-oe.startY)/Ge.zoom,wt=180,_e=80,st=Math.max(wt,oe.startWidth+Ve),gt=Math.max(_e,oe.startHeight+Ie);Te.current(rt=>({...rt,tables:rt.tables.map(Nt=>Nt.id===oe.tableId?{...Nt,width:st,height:gt}:Nt)}));}}function V(K,oe,Fe,Ge){let Ve=U.current,Ie=Yo(K,oe,Ve,Fe),wt=1/0,_e=null,st=null;for(let gt of Ge){if(gt.collapsed)continue;let rt=gt.fields.length;if(rt===0)continue;let Nt=gt.width??260,qt=40+rt*32+(me.current?36:0),Jt=40;if(!(Ie.x<gt.x-Jt||Ie.x>gt.x+Nt+Jt||Ie.y<gt.y-Jt||Ie.y>gt.y+qt+Jt))for(let Pt=0;Pt<gt.fields.length;Pt++){let $n=gt.y+mo(Pt,!!gt.notes),Qo=Math.abs(Ie.y-$n);Qo<wt&&(wt=Qo,_e=gt.id,st=gt.fields[Pt].id);}}return _e&&st?{tableId:_e,fieldId:st}:null}function G(K){let oe=S.current;if(oe){if(oe.type==="relation"){let Fe=y.current?.getBoundingClientRect();if(Fe){let Ge=re.current,Ve=ge.current,Ie=V(K.clientX,K.clientY,Fe,Ve);if(Ie&&Ie.tableId!==oe.fromTableId&&!Ge.some(_e=>_e.from.tableId===oe.fromTableId&&_e.from.fieldId===oe.fromFieldId&&_e.to.tableId===Ie.tableId&&_e.to.fieldId===Ie.fieldId)){let _e=oe.fromTableId,st=oe.fromFieldId,gt=Ie.tableId,rt=Ie.fieldId;Te.current(Nt=>({...Nt,tables:Nt.tables.map(qt=>qt.id===gt?{...qt,fields:qt.fields.map(Jt=>Jt.id===rt?{...Jt,foreignKey:{tableId:_e,fieldId:st}}:Jt)}:qt),relations:[...Nt.relations,{id:Ba(),from:{tableId:_e,fieldId:st},to:{tableId:gt,fieldId:rt},cardinality:"1:n"}]}));}}F(null),ae(null);}S.current=null;}}return document.addEventListener("mousemove",I),document.addEventListener("mouseup",G),()=>{document.removeEventListener("mousemove",I),document.removeEventListener("mouseup",G);}},[]);let at=useCallback(I=>{if(!g||u)return;I.preventDefault();let V=y.current?.getBoundingClientRect();if(!V)return;let G=I.clientX-V.left,K=I.clientY-V.top,oe=I.deltaY<0?1:-1,Fe=Ko(z.zoom+oe*qa,h,b),Ge=Fe/z.zoom;Pe({x:G-(G-z.x)*Ge,y:K-(K-z.y)*Ge,zoom:Fe});},[g,u,z,h,b,Pe]),pt=useCallback(I=>{if(u)return;let V=I.target,G=V.tagName,K=G==="INPUT"||G==="SELECT"||G==="TEXTAREA"||G==="BUTTON";if(V.closest("[data-resize-handle]"))return;let oe=V.closest("[data-connection-side]");if(oe&&!K){if(l)return;I.preventDefault();let Ge=oe.getAttribute("data-table-id"),Ve=oe.getAttribute("data-field-id");if(!Ge||!Ve)return;let Ie=L.find(st=>st.id===Ge);if(!Ie)return;let wt=oe.getAttribute("data-connection-side"),_e=Ll(Ie,Ve,wt);if(!_e)return;S.current={type:"relation",fromTableId:Ge,fromFieldId:Ve,fromX:_e.x,fromY:_e.y,currentX:_e.x,currentY:_e.y},F({fromX:_e.x,fromY:_e.y,currentX:_e.x,currentY:_e.y}),ae(Ge);return}let Fe=V.closest("[data-table-id]");if(Fe){if(l)return;let Ge=Fe.getAttribute("data-table-id");if(we(null),Q(Ge),K)return;if(p){let Ve=y.current?.getBoundingClientRect();if(!Ve)return;let Ie=L.find(_e=>_e.id===Ge);if(!Ie||Ie.locked)return;let wt=Yo(I.clientX,I.clientY,z,Ve);S.current={type:"table",tableId:Ge,offsetX:wt.x-Ie.x,offsetY:wt.y-Ie.y};}return}Q(null),we(null),m&&I.button===0&&(S.current={type:"pan",startX:I.clientX,startY:I.clientY,startVpX:z.x,startVpY:z.y});},[u,l,p,m,z,L]),J=useCallback(I=>{let V=I.target;if(V.closest("[data-connection-side]"))return null;let G=V.closest("[data-table-id]");if(!G)return null;let K=G.getAttribute("data-table-id");return L.find(oe=>oe.id===K)??null},[L]),fe=useCallback(I=>{if(u)return;let V=J(I);V&&n&&n({table:V,nativeEvent:I.nativeEvent});},[n,u,J]),Ke=useCallback(I=>{if(u)return;let V=J(I);V&&a&&a({table:V,nativeEvent:I.nativeEvent});},[a,u,J]),xt=useCallback(I=>{if(u)return;let V=J(I);V&&i&&(I.preventDefault(),i({table:V,nativeEvent:I.nativeEvent}));},[i,u,J]),Ee=useCallback((I,V)=>{u||(V.stopPropagation(),Q(null),we(I));},[u]),We=useCallback((I,V)=>{j(G=>({...G,relations:G.relations.map(K=>K.id===I?{...K,cardinality:V}:K)}));},[j]),ht=X.current>0,cr=X.current<le.current.length-1,ct=useCallback(()=>{if(X.current<=0)return;C.current=true,X.current--;let I=le.current[X.current];P||$(I),r?.(I),C.current=false;},[P,r]),Bt=useCallback(()=>{if(X.current>=le.current.length-1)return;C.current=true,X.current++;let I=le.current[X.current];P||$(I),r?.(I),C.current=false;},[P,r]),Tt=useCallback(()=>Wn(q),[q]),Yt=useCallback(()=>{j(I=>({...I,tables:Ya(I.tables,f)}));},[j,f]),Sr=useCallback((I,V,G)=>{V!==G&&j(K=>({...K,tables:K.tables.map(oe=>{if(oe.id!==I)return oe;let Fe=[...oe.fields],[Ge]=Fe.splice(V,1);return Fe.splice(G,0,Ge),{...oe,fields:Fe}})}));},[j]);useEffect(()=>{let I=y.current;if(!I)return;let V=new ResizeObserver(G=>{for(let K of G)xe({width:K.contentRect.width,height:K.contentRect.height});});return V.observe(I),()=>V.disconnect()},[]);let Ot=useRef(false);Ot.current||(Ot.current=true,le.current=[q],X.current=0);let ur=useCallback(I=>{if(!(l||u)){if((I.ctrlKey||I.metaKey)&&I.key==="z"&&!I.shiftKey){I.preventDefault(),ct();return}if((I.ctrlKey||I.metaKey)&&(I.key==="y"||I.key==="z"&&I.shiftKey)){I.preventDefault(),Bt();return}if(I.key==="Delete"||I.key==="Backspace"){let V=I.target;if(V.tagName==="INPUT"||V.tagName==="TEXTAREA"||V.tagName==="SELECT")return;T&&(j(G=>({...G,tables:G.tables.filter(K=>K.id!==T),relations:G.relations.filter(K=>K.from.tableId!==T&&K.to.tableId!==T)})),Q(null)),ie&&(j(G=>{let K=G.relations.find(oe=>oe.id===ie);return {...G,tables:K?G.tables.map(oe=>oe.id===K.to.tableId?{...oe,fields:oe.fields.map(Fe=>Fe.id===K.to.fieldId?{...Fe,foreignKey:void 0}:Fe)}:oe):G.tables,relations:G.relations.filter(oe=>oe.id!==ie)}}),we(null));}I.key==="Escape"&&(Q(null),we(null));}},[l,u,T,ie,j,ct,Bt]),Xt=useCallback((I,V)=>{j(G=>({...G,tables:G.tables.map(K=>K.id===I?{...K,name:V}:K)}));},[j]),de=useCallback((I,V)=>{j(G=>({...G,tables:G.tables.map(K=>K.id===I?{...K,notes:V}:K)}));},[j]),ue=useCallback(I=>{j(V=>({...V,tables:V.tables.map(G=>G.id===I?{...G,collapsed:!G.collapsed}:G)}));},[j]),H=useCallback((I,V,G)=>{j(K=>({...K,tables:K.tables.map(oe=>oe.id===I?{...oe,fields:oe.fields.map(Fe=>Fe.id===V?{...Fe,...G}:Fe)}:oe)}));},[j]),O=useCallback(I=>{j(V=>({...V,tables:V.tables.map(G=>G.id===I?{...G,fields:[...G.fields,Oa()]}:G)}));},[j]),se=useCallback((I,V)=>{j(G=>({...G,tables:G.tables.map(K=>K.id===I?{...K,fields:K.fields.filter(oe=>oe.id!==V)}:K),relations:G.relations.filter(K=>!(K.from.tableId===I&&K.from.fieldId===V)&&!(K.to.tableId===I&&K.to.fieldId===V))}));},[j]),ne=useCallback((I,V,G,K,oe)=>{S.current={type:"resize",tableId:I,startX:V,startY:G,startWidth:K,startHeight:oe};},[]),Ne=useCallback(()=>{let I=Ko(z.zoom+qa,h,b);Pe({...z,zoom:I});},[z,h,b,Pe]),be=useCallback(()=>{let I=Ko(z.zoom-qa,h,b);Pe({...z,zoom:I});},[z,h,b,Pe]),ke=useCallback(()=>{Pe({...ja});},[Pe]),Ae=useCallback(()=>{let I=y.current?.getBoundingClientRect();if(!I)return;let V=zl(L,I.width,I.height,f),G=Ko(V.zoom,h,b);Pe({...V,zoom:G});},[L,f,h,b,Pe]),Me=useCallback(I=>{j(V=>({...V,tables:[...V.tables,I]}));},[j]),Qe=useCallback(I=>{j(V=>({...V,tables:V.tables.filter(G=>G.id!==I),relations:V.relations.filter(G=>G.from.tableId!==I&&G.to.tableId!==I)}));},[j]),Ye=useCallback((I,V)=>{j(G=>({...G,tables:G.tables.map(K=>K.id===I?{...K,fields:[...K.fields,V]}:K)}));},[j]),Oe=useCallback((I,V)=>{se(I,V);},[se]),vt=useCallback(I=>{j(V=>({...V,tables:V.tables.map(G=>G.id===I.to.tableId?{...G,fields:G.fields.map(K=>K.id===I.to.fieldId?{...K,foreignKey:{tableId:I.from.tableId,fieldId:I.from.fieldId}}:K)}:G),relations:[...V.relations,I]}));},[j]),tt=useCallback(I=>{j(V=>{let G=V.relations.find(K=>K.id===I);return {...V,tables:G?V.tables.map(K=>K.id===G.to.tableId?{...K,fields:K.fields.map(oe=>oe.id===G.to.fieldId?{...oe,foreignKey:void 0}:oe)}:K):V.tables,relations:V.relations.filter(K=>K.id!==I)}});},[j]),Vt=useCallback(()=>JSON.stringify(q,null,2),[q]),pr=useCallback(I=>{try{let V=JSON.parse(I);V&&Array.isArray(V.tables)&&Array.isArray(V.relations)&&j(()=>V);}catch{}},[j]),Wr=useCallback(()=>{let I=y.current?.getBoundingClientRect(),V=U.current,G=100,K=100;I&&(G=(I.width/2-V.x)/V.zoom-260/2,K=(I.height/2-V.y)/V.zoom-60),Me(Va(G,K));},[Me]),Jr=useCallback(()=>Wn(q),[q]);useImperativeHandle(R,()=>({zoomIn:Ne,zoomOut:be,resetView:ke,fitToContent:Ae,addTable:Me,removeTable:Qe,addField:Ye,removeField:Oe,addRelation:vt,removeRelation:tt,toJSON:Vt,loadJSON:pr,toSQL:Jr}),[Ne,be,ke,Ae,Me,Qe,Ye,Oe,vt,tt,Vt,pr,Jr]);let jt=useRef(false);useEffect(()=>{E&&!jt.current&&y.current&&(jt.current=true,Ae());},[E,Ae]);let _t=useMemo(()=>({transform:`translate(${z.x}px, ${z.y}px) scale(${z.zoom})`,transformOrigin:"0 0"}),[z.x,z.y,z.zoom]);return jsxs("div",{ref:y,"data-testid":"schema-editor",className:s("relative w-full overflow-hidden bg-gray-50 dark:bg-gray-900 select-none",u&&"opacity-60 pointer-events-none",M),tabIndex:0,onWheel:at,onMouseDown:pt,onClick:fe,onDoubleClick:Ke,onContextMenu:xt,onKeyDown:ur,children:[k&&jsx(Pl,{gridSize:v,zoom:z.zoom}),D&&!l&&jsx(Ul,{zoom:z.zoom,onZoomIn:Ne,onZoomOut:be,onResetView:ke,onFitToContent:Ae,onAddTable:Wr,onExportJSON:Vt,onImportJSON:pr,onExportSQL:Tt,onUndo:ct,onRedo:Bt,canUndo:ht,canRedo:cr,onAutoLayout:Yt,disabled:u}),N&&jsx(Gl,{}),jsx($l,{relations:_,tables:L,viewport:z,selectedRelationId:ie,disabled:u||l,onRelationClick:Ee,onCardinalityChange:We}),jsx("div",{style:_t,children:L.map(I=>jsx(Vl,{table:I,selected:T===I.id,disabled:u||l,readOnly:l,editable:f,dropTarget:ee!==null&&ee!==I.id&&!I.collapsed,fieldTypes:o,onTableNameChange:Xt,onTableNotesChange:de,onToggleCollapse:ue,onFieldChange:H,onFieldAdd:O,onFieldRemove:se,onFieldReorder:Sr,onResizeStart:ne},I.id))}),he&&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:Mn(he.fromX*z.zoom+z.x,he.fromY*z.zoom+z.y,he.currentX*z.zoom+z.x,he.currentY*z.zoom+z.y),fill:"none",stroke:"#3b82f6",strokeWidth:2.5,strokeDasharray:"8 4"}),jsx("circle",{cx:he.fromX*z.zoom+z.x,cy:he.fromY*z.zoom+z.y,r:5,fill:"#3b82f6"}),jsx("circle",{cx:he.currentX*z.zoom+z.x,cy:he.currentY*z.zoom+z.y,r:4,fill:"#3b82f6",opacity:.6})]}),N&&ye.width>0&&jsx(Kl,{tables:L,viewport:z,containerWidth:ye.width,containerHeight:ye.height,editable:f,onViewportChange:Pe})]})}var jl=forwardRef(Fb);jl.displayName="SchemaEditor";var ql="wf-grid-pattern",Jl=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:ql,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(#${ql})`})]})});function Ja(e,t){return Math.round(e/t)*t}function Jo(e,t,r){return Math.min(r,Math.max(t,e))}function wo(e,t,r,o){return {x:(e-o.left-r.x)/r.zoom,y:(t-o.top-r.y)/r.zoom}}function qo(e,t="horizontal"){return t==="vertical"?e==="in"?"top":"bottom":e==="in"?"left":"right"}function ko(e,t,r,o="horizontal"){let n=e.width??180,a=e.height??60,i=t.side??qo(t.kind,o),c=r.filter(p=>(p.side??qo(p.kind,o))===i),d=c.findIndex(p=>p.id===t.id),l=c.length,u=l===1?.5:(d+1)/(l+1);switch(i){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 Hn(e,t,r,o,n="horizontal"){if(n==="vertical"){let p=Math.abs(o-t),m=Math.max(50,p*.5),g=e,f=t+m,h=r,b=o-m;return `M ${e} ${t} C ${g} ${f}, ${h} ${b}, ${r} ${o}`}let a=Math.abs(r-e),i=Math.max(50,a*.5),c=e+i,d=t,l=r-i;return `M ${e} ${t} C ${c} ${d}, ${l} ${o}, ${r} ${o}`}function Zl(e,t,r,o=40){if(e.length===0)return {x:0,y:0,zoom:1};let n=1/0,a=1/0,i=-1/0,c=-1/0;for(let g of e){let f=g.width??180,h=g.height??60;n=Math.min(n,g.x),a=Math.min(a,g.y),i=Math.max(i,g.x+f),c=Math.max(c,g.y+h);}let d=i-n+o*2,l=c-a+o*2,u=Math.min(t/d,r/l,1),p=(t-d*u)/2-(n-o)*u,m=(r-l*u)/2-(a-o)*u;return {x:p,y:m,zoom:u}}var Vb=180,_b=60,Bn=12,Co=28,Qa=24,$b=-8;function Ub(e,t,r,o,n="horizontal"){let a=e.side??qo(e.kind,n),i=t.filter(u=>(u.side??qo(u.kind,n))===a),c=i.findIndex(u=>u.id===e.id),d=i.length,l=d===1?.5:(c+1)/(d+1);switch(a){case "left":return {left:0,top:o*l};case "right":return {left:r,top:o*l};case "top":return {left:r*l,top:0};case "bottom":return {left:r*l,top:o}}}function Gb({port:e,allPorts:t,nodeId:r,nodeWidth:o,nodeHeight:n,disabled:a,direction:i,onMouseUp:c}){let d=Ub(e,t,o,n,i),l=a||e.disabled,u=useCallback(p=>{l||(p.stopPropagation(),c(r,e.id));},[l,r,e.id,c]);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:d.left-Co/2,top:d.top-Co/2,width:Co,height:Co,zIndex:20},onMouseUp:u,title:e.label??e.id,children:jsx("div",{className:s("absolute rounded-full border-2 transition-colors",l?"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:Bn,height:Bn,left:(Co-Bn)/2,top:(Co-Bn)/2}})})}function Kb(e,t,r){let o=e??"top-right",n=$b,a=t*(Qa+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 Yb({action:e,nodeId:t,index:r,nodeWidth:o,disabled:n,onActionClick:a}){let i=useCallback(l=>{l.stopPropagation(),l.preventDefault(),!n&&a(t,e.id,l.nativeEvent);},[n,t,e.id,a]),c=useCallback(l=>{l.stopPropagation();},[]),d=Kb(e.position,r);return jsx("button",{"data-testid":`action-${t}-${e.id}`,"data-action-id":e.id,"data-node-id":t,type:"button",className:s("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:{...d,width:Qa,height:Qa,zIndex:30},onClick:i,onMouseDown:c,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 Ql=memo(function({node:t,registry:r,ports:o,selected:n,disabled:a,draggable:i,direction:c,onPortMouseUp:d,onActionClick:l}){let u=t.width??Vb,p=t.height??_b,m=r.render({node:t,selected:n,disabled:a}),f=(typeof r.actions=="function"?r.actions(t):r.actions)?.filter(b=>typeof b.hidden=="function"?!b.hidden(t):!b.hidden),h=new Map;if(f)for(let b of f){let x=b.position??"top-right",v=h.get(x)??[];v.push(b),h.set(x,v);}return jsxs("div",{"data-testid":`workflow-node-${t.id}`,"data-node-id":t.id,className:s("absolute select-none group/node",i&&!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:[m,o.map(b=>jsx(Gb,{port:b,allPorts:o,nodeId:t.id,nodeWidth:u,nodeHeight:p,disabled:a,direction:c,onMouseUp:d},b.id)),l&&h.size>0&&Array.from(h.entries()).map(([,b])=>b.map((x,v)=>jsx(Yb,{action:x,nodeId:t.id,index:v,nodeWidth:u,disabled:a,onActionClick:l},x.id)))]})});function ed(e,t,r,o,n="horizontal"){let a=r.find(d=>d.id===e);if(!a)return null;let i=o(a),c=i.find(d=>d.id===t);return c?ko(a,c,i,n):null}var qb=memo(function({edge:t,fromPos:r,toPos:o,selected:n,disabled:a,direction:i,onClick:c}){let d=Hn(r.x,r.y,o.x,o.y,i),l=(r.x+o.x)/2,u=(r.y+o.y)/2,p=useCallback(m=>{m.stopPropagation(),c(t.id,m);},[t.id,c]);return jsxs("g",{"data-testid":`workflow-edge-${t.id}`,children:[jsx("path",{d,fill:"none",stroke:"transparent",strokeWidth:16,className:"cursor-pointer",onClick:p}),jsx("path",{d,fill:"none",className:s("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:l,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})]})}),rd=memo(function({edges:t,nodes:r,selectedEdgeId:o,disabled:n,direction:a,onEdgeClick:i,getNodePorts:c}){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(d=>{let l=ed(d.from.nodeId,d.from.portId,r,c,a),u=ed(d.to.nodeId,d.to.portId,r,c,a);return !l||!u?null:jsx(qb,{edge:d,fromPos:l,toPos:u,selected:d.id===o,disabled:n,direction:a,onClick:i},d.id)})})})});var Qb=()=>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"})}),eh=()=>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"})}),th=()=>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"})}),rh=()=>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"})}),oh=()=>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"})}),nh=()=>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"})}),ah=()=>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"})}),sh=()=>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"})}),nd=memo(function({zoom:t,direction:r,onDirectionChange:o,onZoomIn:n,onZoomOut:a,onResetView:i,onFitToContent:c,onExportJSON:d,onImportJSON:l,disabled:u,className:p}){let[m,g]=useState(false),[f,h]=useState(false),[b,x]=useState(""),[v,k]=useState(""),D=useCallback(()=>{x(d()),g(true);},[d]),N=useCallback(()=>{v.trim()&&(l(v.trim()),k(""),h(false));},[v,l]),E=useCallback(()=>{k(""),h(false);},[]),M=useCallback(()=>{g(false);},[]),R=Math.round(t*100);return jsxs(Fragment,{children:[jsxs("div",{className:s("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(to,{size:"sm",children:[jsx(dt,{content:"Zoom in",size:"sm",position:"bottom",children:jsx(lt,{icon:jsx(Qb,{}),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(dt,{content:"Zoom out",size:"sm",position:"bottom",children:jsx(lt,{icon:jsx(eh,{}),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:[R,"%"]}),jsx("div",{className:"w-px h-5 bg-gray-200 dark:bg-gray-600"}),jsx(dt,{content:"Reset view",size:"sm",position:"bottom",children:jsx(lt,{icon:jsx(th,{}),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:i,disabled:u,"aria-label":"Reset view"})}),jsx(dt,{content:"Fit to content",size:"sm",position:"bottom",children:jsx(lt,{icon:jsx(rh,{}),size:"sm",bgColor:"bg-gray-100 hover:bg-gray-200 dark:bg-gray-700 dark:hover:bg-gray-600",textColor:"text-gray-700 dark:text-gray-200",onClick:c,disabled: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(dt,{content:r==="horizontal"?"Switch to vertical":"Switch to horizontal",size:"sm",position:"bottom",children:jsx(lt,{icon:r==="horizontal"?jsx(ah,{}):jsx(sh,{}),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(dt,{content:"Export JSON",size:"sm",position:"bottom",children:jsx(lt,{icon:jsx(oh,{}),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:u,"aria-label":"Export JSON"})}),jsx(dt,{content:"Import JSON",size:"sm",position:"bottom",children:jsx(lt,{icon:jsx(nh,{}),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(vr,{isOpen:m,onClose:M,title:"Export Workflow",description:"Copy the JSON below to save your workflow.",size:"lg",showSubmit:false,showCancel:true,cancelLabel:"Close",children:jsx(ar,{label:"Workflow JSON",multiline:true,rows:12,value:b,readOnly:true,size:"sm"})}),jsx(vr,{isOpen:f,onClose:E,title:"Import Workflow",description:"Paste workflow JSON to load it into the editor.",size:"lg",showSubmit:true,submitLabel:"Import",onSubmitClick:N,showCancel:true,cancelLabel:"Cancel",children:jsx(ar,{label:"Workflow JSON",multiline:true,rows:12,value:v,onChange:P=>k(P.target.value),placeholder:'{"nodes": [], "edges": []}',size:"sm"})})]})});var es={x:0,y:0,zoom:1},ts=.1,dh=.1,ch=3,uh=20;function id(){return `edge-${Date.now()}-${Math.random().toString(36).slice(2,8)}`}function ph({value:e,defaultValue:t,onValueChange:r,nodeRegistry:o,direction:n="horizontal",onDirectionChange:a,onNodeClick:i,onNodeDoubleClick:c,onNodeContextMenu:d,onNodeAction:l,readOnly:u=false,disabled:p=false,draggableNodes:m=true,connectable:g=true,selectable:f=true,multiSelect:h=false,panOnDrag:b=true,zoomOnWheel:x=true,minZoom:v=dh,maxZoom:k=ch,snapToGrid:D=false,gridSize:N=uh,showGrid:E=true,toolbar:M=true,autoFit:R=false,className:P},A){let $=e!==void 0,[q,L]=useState(()=>t??{nodes:[],edges:[],viewport:{...es}}),_=$?e:q,z=_.nodes,y=_.edges,S=_.viewport??es,T=useRef(null),Q=useRef(null),[ie,we]=useState(new Set),[he,F]=useState(null),[ee,ae]=useState(null),ye=useRef(S);ye.current=S;let xe=useRef(z);xe.current=z;let le=useRef(y);le.current=y;let X=useRef(D);X.current=D;let C=useRef(N);C.current=N;let U=useRef(o);U.current=o;let ge=useRef(n);ge.current=n;let re=useCallback(H=>{$?r?.(H(e)):L(O=>{let se=H(O);return r?.(se),se});},[$,e,r]),B=useRef(re);B.current=re;let te=useCallback(H=>{re(O=>({...O,viewport:H}));},[re]),me=useRef(te);me.current=te;let Se=useCallback(H=>{let O=o[H.type];return O?.getPorts?O.getPorts(H):H.ports??[]},[o]),j=useRef(Se);j.current=Se;let Te=useCallback((H,O,se)=>{let ne=xe.current,Ne=le.current,be=ne.find(tt=>tt.id===H.fromNodeId),ke=ne.find(tt=>tt.id===O);if(!be||!ke)return;let Ae=j.current(be),Me=j.current(ke),Qe=Ae.find(tt=>tt.id===H.fromPortId),Ye=Me.find(tt=>tt.id===se);if(!Qe||!Ye||Ye.kind!=="in"||H.fromNodeId===O)return;let Oe=U.current[be.type];if(Oe?.canConnect&&!Oe.canConnect({fromNode:be,toNode:ke,fromPort:Qe,toPort:Ye}))return;Ne.some(tt=>tt.from.nodeId===H.fromNodeId&&tt.from.portId===H.fromPortId&&tt.to.nodeId===O&&tt.to.portId===se)||B.current(tt=>({...tt,edges:[...tt.edges,{id:id(),from:{nodeId:H.fromNodeId,portId:H.fromPortId},to:{nodeId:O,portId:se}}]}));},[]);useEffect(()=>{function H(se){let ne=Q.current;if(!ne)return;let Ne=T.current?.getBoundingClientRect();if(!Ne)return;let be=ye.current;if(ne.type==="pan"){let ke=se.clientX-ne.startX,Ae=se.clientY-ne.startY;me.current({...be,x:ne.startViewportX+ke,y:ne.startViewportY+Ae});}if(ne.type==="node"){let ke=wo(se.clientX,se.clientY,be,Ne),Ae=ke.x-ne.offsetX,Me=ke.y-ne.offsetY;X.current&&(Ae=Ja(Ae,C.current),Me=Ja(Me,C.current)),B.current(Qe=>({...Qe,nodes:Qe.nodes.map(Ye=>Ye.id===ne.nodeId?{...Ye,x:Ae,y:Me}:Ye)}));}if(ne.type==="edge"){let ke=wo(se.clientX,se.clientY,be,Ne);Q.current={...ne,currentX:ke.x,currentY:ke.y},ae({fromX:ne.fromX,fromY:ne.fromY,currentX:ke.x,currentY:ke.y});}}function O(se){let ne=Q.current;if(ne){if(ne.type==="edge"){let Ne=T.current?.getBoundingClientRect();if(Ne){let be=ye.current,ke=wo(se.clientX,se.clientY,be,Ne),Ae=25,Me=xe.current,Qe=1/0,Ye=null,Oe=null;for(let vt of Me){let tt=j.current(vt);for(let Vt of tt){if(Vt.kind!=="in")continue;let pr=ko(vt,Vt,tt,ge.current),Wr=Math.sqrt((ke.x-pr.x)**2+(ke.y-pr.y)**2);Wr<Ae&&Wr<Qe&&(Qe=Wr,Ye=vt.id,Oe=Vt.id);}}Ye&&Oe&&Te(ne,Ye,Oe);}ae(null);}Q.current=null;}}return document.addEventListener("mousemove",H),document.addEventListener("mouseup",O),()=>{document.removeEventListener("mousemove",H),document.removeEventListener("mouseup",O);}},[Te]);let Pe=useCallback(H=>{if(!x||p)return;H.preventDefault();let O=T.current?.getBoundingClientRect();if(!O)return;let se=H.clientX-O.left,ne=H.clientY-O.top,Ne=H.deltaY<0?1:-1,be=Jo(S.zoom+Ne*ts,v,k),ke=be/S.zoom;te({x:se-(se-S.x)*ke,y:ne-(ne-S.y)*ke,zoom:be});},[x,p,S,v,k,te]),et=useCallback(H=>{if(p)return;let O=H.target;if(O.closest("[data-action-id]"))return;let ne=O.closest("[data-port-id]");if(ne){if(!g||u)return;H.preventDefault();let be=ne.getAttribute("data-node-id"),ke=ne.getAttribute("data-port-id"),Ae=ne.getAttribute("data-port-kind");if(!be||!ke||Ae!=="out")return;let Me=z.find(vt=>vt.id===be);if(!Me)return;let Qe=Se(Me),Ye=Qe.find(vt=>vt.id===ke);if(!Ye)return;let Oe=ko(Me,Ye,Qe,ge.current);Q.current={type:"edge",fromNodeId:be,fromPortId:ke,fromX:Oe.x,fromY:Oe.y,currentX:Oe.x,currentY:Oe.y},ae({fromX:Oe.x,fromY:Oe.y,currentX:Oe.x,currentY:Oe.y});return}let Ne=O.closest("[data-node-id]");if(Ne){if(u)return;let be=Ne.getAttribute("data-node-id");if(f&&(F(null),h&&H.shiftKey?we(ke=>{let Ae=new Set(ke);return Ae.has(be)?Ae.delete(be):Ae.add(be),Ae}):we(new Set([be]))),m){let ke=T.current?.getBoundingClientRect();if(!ke)return;let Ae=z.find(Qe=>Qe.id===be);if(!Ae||Ae.locked)return;let Me=wo(H.clientX,H.clientY,S,ke);Q.current={type:"node",nodeId:be,startX:Me.x,startY:Me.y,offsetX:Me.x-Ae.x,offsetY:Me.y-Ae.y};}return}f&&(we(new Set),F(null)),b&&H.button===0&&(Q.current={type:"pan",startX:H.clientX,startY:H.clientY,startViewportX:S.x,startViewportY:S.y});},[p,g,u,f,h,m,b,S,z,Se]),at=useCallback(H=>{let O=Q.current;if(!O||O.type!=="edge")return;let se=T.current?.getBoundingClientRect();if(se){let ne=wo(H.clientX,H.clientY,S,se),Ne=30,be=1/0,ke=null,Ae=null;for(let Me of z){let Qe=Se(Me);for(let Ye of Qe){if(Ye.kind!=="in")continue;let Oe=ko(Me,Ye,Qe,ge.current),vt=Math.sqrt((ne.x-Oe.x)**2+(ne.y-Oe.y)**2);vt<Ne&&vt<be&&(be=vt,ke=Me.id,Ae=Ye.id);}}if(ke&&Ae){let Me=O.fromNodeId,Qe=O.fromPortId;Me!==ke&&(y.some(Oe=>Oe.from.nodeId===Me&&Oe.from.portId===Qe&&Oe.to.nodeId===ke&&Oe.to.portId===Ae)||re(Oe=>({...Oe,edges:[...Oe.edges,{id:id(),from:{nodeId:Me,portId:Qe},to:{nodeId:ke,portId:Ae}}]})));}}Q.current=null,ae(null);},[S,z,y,Se,re]),pt=useCallback((H,O)=>{let se=Q.current;!se||se.type!=="edge"||(Te(se,H,O),Q.current=null,ae(null));},[Te]),J=useCallback(H=>{let O=H.target;if(O.closest("[data-port-id]")||O.closest("[data-action-id]"))return null;let Ne=O.closest("[data-node-id]");if(!Ne)return null;let be=Ne.getAttribute("data-node-id");return z.find(ke=>ke.id===be)??null},[z]),fe=useCallback(H=>{if(!i||p)return;let O=J(H);O&&i({node:O,nativeEvent:H.nativeEvent});},[i,p,J]),Ke=useCallback(H=>{if(!c||p)return;let O=J(H);O&&c({node:O,nativeEvent:H.nativeEvent});},[c,p,J]),xt=useCallback(H=>{if(!d||p)return;let O=J(H);O&&(H.preventDefault(),d({node:O,nativeEvent:H.nativeEvent}));},[d,p,J]),Ee=useCallback((H,O,se)=>{if(!l||p)return;let ne=z.find(Ne=>Ne.id===H);ne&&l({node:ne,actionId:O,nativeEvent:se});},[l,p,z]),We=useCallback((H,O)=>{!f||p||(O.stopPropagation(),we(new Set),F(H));},[f,p]),ht=useCallback(H=>{u||p||((H.key==="Delete"||H.key==="Backspace")&&(ie.size>0&&(re(O=>({...O,nodes:O.nodes.filter(se=>!ie.has(se.id)),edges:O.edges.filter(se=>!ie.has(se.from.nodeId)&&!ie.has(se.to.nodeId))})),we(new Set)),he&&(re(O=>({...O,edges:O.edges.filter(se=>se.id!==he)})),F(null))),H.key==="Escape"&&(we(new Set),F(null)));},[u,p,ie,he,re]),cr=useCallback(()=>{let H=Jo(S.zoom+ts,v,k);te({...S,zoom:H});},[S,v,k,te]),ct=useCallback(()=>{let H=Jo(S.zoom-ts,v,k);te({...S,zoom:H});},[S,v,k,te]),Bt=useCallback(()=>{te({...es});},[te]),Tt=useCallback(()=>{let H=T.current?.getBoundingClientRect();if(!H)return;let O=Zl(z,H.width,H.height),se=Jo(O.zoom,v,k);te({...O,zoom:se});},[z,v,k,te]),Yt=useCallback(H=>{re(O=>({...O,nodes:[...O.nodes,H]}));},[re]),Sr=useCallback(H=>{re(O=>({...O,nodes:O.nodes.filter(se=>se.id!==H),edges:O.edges.filter(se=>se.from.nodeId!==H&&se.to.nodeId!==H)}));},[re]),Ot=useCallback(()=>JSON.stringify(_,null,2),[_]),ur=useCallback(H=>{try{let O=JSON.parse(H);O&&Array.isArray(O.nodes)&&Array.isArray(O.edges)&&re(()=>O);}catch{}},[re]);useImperativeHandle(A,()=>({zoomIn:cr,zoomOut:ct,resetView:Bt,fitToContent:Tt,addNode:Yt,removeNode:Sr,toJSON:Ot,loadJSON:ur}),[cr,ct,Bt,Tt,Yt,Sr,Ot,ur]);let Xt=useRef(false);useEffect(()=>{R&&!Xt.current&&T.current&&(Xt.current=true,Tt());},[R,Tt]);let de=useMemo(()=>{let H=new Map;for(let O of z)H.set(O.id,Se(O));return H},[z,Se]),ue=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:T,"data-testid":"workflow-editor",className:s("relative w-full overflow-hidden bg-gray-50 dark:bg-gray-900 select-none",p&&"opacity-60 pointer-events-none",P),tabIndex:0,onWheel:Pe,onMouseDown:et,onMouseUp:at,onClick:fe,onDoubleClick:Ke,onContextMenu:xt,onKeyDown:ht,children:[E&&jsx(Jl,{gridSize:N,zoom:S.zoom}),M&&!u&&jsx(nd,{zoom:S.zoom,direction:n,onDirectionChange:a,onZoomIn:cr,onZoomOut:ct,onResetView:Bt,onFitToContent:Tt,onExportJSON:Ot,onImportJSON:ur,disabled:p}),jsxs("div",{style:ue,children:[jsx(rd,{edges:y,nodes:z,selectedEdgeId:he,disabled:p||u,direction:n,onEdgeClick:We,getNodePorts:H=>de.get(H.id)??[]}),z.map(H=>{let O=o[H.type];if(!O)return null;let se=de.get(H.id)??[];return jsx(Ql,{node:H,registry:O,ports:se,selected:ie.has(H.id),disabled:p||u,draggable:m&&!u,direction:n,onPortMouseUp:pt,onActionClick:l?Ee:void 0},H.id)})]}),ee&&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:Hn(ee.fromX*S.zoom+S.x,ee.fromY*S.zoom+S.y,ee.currentX*S.zoom+S.x,ee.currentY*S.zoom+S.y,n),fill:"none",stroke:"#3b82f6",strokeWidth:2.5,strokeDasharray:"8 4"}),jsx("circle",{cx:ee.fromX*S.zoom+S.x,cy:ee.fromY*S.zoom+S.y,r:5,fill:"#3b82f6"}),jsx("circle",{cx:ee.currentX*S.zoom+S.x,cy:ee.currentY*S.zoom+S.y,r:4,fill:"#3b82f6",opacity:.6})]})]})}var ld=forwardRef(ph);ld.displayName="WorkflowEditor";var pd=createContext(null);function Ar(){let e=useContext(pd);if(!e)throw new Error("useWizard and Wizard sub-components must be used within <Wizard>");return e}var os=(e,t,r)=>Math.max(t,Math.min(e,r)),ns={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"}},dr={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 mh({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 gd({steps:e,step:t,defaultStep:r=0,onStepChange:o,onComplete:n,orientation:a="horizontal",variant:i="default",size:c="md",color:d="primary",linear:l=true,className:u,children:p}){let m=e.length,g=Math.max(0,m-1),f=t!==void 0,[h,b]=useState(()=>os(r,0,g)),x=os(f?t:h,0,g),[v,k]=useState(x);v<x&&k(x);let D=x<=0,N=x>=g,E=useCallback((L,_)=>{let z=os(L,0,g);z!==x&&(f||b(z),k(y=>Math.max(y,z)),o?.(z,{previous:x,direction:_}));},[x,f,g,o]),M=useCallback(L=>{let _=e[L];return !_||_.disabled?false:l?L<=v:true},[e,l,v]),R=useCallback(L=>{M(L)&&E(L,L>x?"jump":"backward");},[M,E,x]),P=useCallback(()=>{if(N){n?.();return}E(x+1,"forward");},[N,n,E,x]),A=useCallback(()=>{D||E(x-1,"backward");},[D,E,x]),$=useCallback(L=>e[L]?.error?"error":L===x?"active":L<x?"completed":"upcoming",[e,x]),q={steps:e,activeStep:x,totalSteps:m,isFirstStep:D,isLastStep:N,orientation:a,variant:i,size:c,color:d,linear:l,goToStep:R,goNext:P,goBack:A,getStepStatus:$,isStepAccessible:M};return jsx(pd.Provider,{value:q,children:jsx("div",{className:s("flex w-full flex-col gap-6",u),"data-testid":"wizard","data-orientation":a,children:p})})}function cd({index:e,status:t}){let{variant:r,size:o,color:n,steps:a}=Ar(),i=ns[o],c=a[e];if(r==="dots"){let u=t==="upcoming"?"bg-gray-300 dark:bg-gray-600":t==="error"?"bg-red-600":dr[n].bg;return jsx("span",{className:s("shrink-0 rounded-full transition-colors",i.dot,u),"aria-hidden":"true"})}let d=t==="completed"?s(dr[n].solid,"border-transparent"):t==="active"?s(dr[n].solid,"border-transparent ring-4",dr[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",l=t==="completed"?jsx(mh,{className:i.icon}):t==="error"?jsx("span",{className:"font-semibold leading-none",children:"!"}):c.icon??jsx("span",{className:"font-medium leading-none",children:e+1});return jsx("span",{className:s("flex shrink-0 items-center justify-center rounded-full transition-all",i.circle,d),"aria-hidden":"true",children:l})}function ud({index:e,status:t}){let{steps:r,size:o,color:n,variant:a}=Ar(),i=ns[o],c=r[e],l=t==="active"?dr[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:s("font-medium leading-tight",i.title,l),children:[a==="simple"&&jsxs("span",{className:"mr-1 tabular-nums",children:[e+1,"."]}),c.title,c.optional&&jsx("span",{className:"ml-1 text-xs font-normal text-gray-400 dark:text-gray-500",children:"(optional)"})]}),c.description&&jsx("span",{className:s("mt-0.5 text-gray-400 dark:text-gray-500",i.desc),children:c.description})]})}function fd({className:e,hideConnector:t=false,hideLabels:r=false}){let o=Ar(),{steps:n,orientation:a,size:i,variant:c,color:d,activeStep:l}=o,u=ns[i],p=a==="vertical",m=c!=="simple";return jsx("ol",{className:s("flex w-full",p?"flex-col":"items-start",e),"data-testid":"wizard-steps","data-orientation":a,children:n.map((g,f)=>{let h=o.getStepStatus(f),b=f===l,x=o.isStepAccessible(f)&&!b,v=f===n.length-1,D=f<l?dr[d].bg:"bg-gray-200 dark:bg-gray-700";return p?jsx("li",{className:"flex","aria-current":b?"step":void 0,"data-status":h,"data-testid":"wizard-step",children:jsxs("button",{type:"button",disabled:!x,onClick:()=>o.goToStep(f),className:s("flex items-stretch gap-3 rounded-md text-left focus:outline-none focus-visible:ring-2 focus-visible:ring-offset-2",dr[d].ring,x?"cursor-pointer":"cursor-default"),children:[jsxs("span",{className:"flex flex-col items-center",children:[m&&jsx(cd,{index:f,status:h}),!t&&!v&&jsx("span",{className:s("my-1 w-0.5 flex-1 rounded",D),"aria-hidden":"true"})]}),!r&&jsx("span",{className:s(v?"pb-0":"pb-6"),children:jsx(ud,{index:f,status:h})})]})},g.id??f):jsxs("li",{className:s("flex items-center",!v&&"flex-1"),"aria-current":b?"step":void 0,"data-status":h,"data-testid":"wizard-step",children:[jsxs("button",{type:"button",disabled:!x,onClick:()=>o.goToStep(f),className:s("flex items-center gap-2.5 rounded-md focus:outline-none focus-visible:ring-2 focus-visible:ring-offset-2",dr[d].ring,x?"cursor-pointer":"cursor-default"),children:[m&&jsx(cd,{index:f,status:h}),!r&&jsx(ud,{index:f,status:h})]}),!t&&!v&&jsx("span",{className:s("mx-2 flex-1 rounded",u.connector,D),"aria-hidden":"true"})]},g.id??f)})})}function md({index:e,keepMounted:t=false,className:r,children:o}){let{activeStep:n}=Ar(),a=e===n;return !a&&!t?null:jsx("div",{role:"tabpanel",hidden:!a,"data-testid":"wizard-panel","data-active":a,"data-step":e,className:s("w-full",r),children:o})}function bd({className:e,children:t}){let r=Ar();return jsx("div",{className:s("w-full",e),"data-testid":"wizard-content",children:typeof t=="function"?t(r):t})}var hd="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 as({children:e,label:t="Previous",className:r,onClick:o,disabled:n,...a}){let{goBack:i,isFirstStep:c}=Ar();return jsx("button",{type:"button",onClick:l=>{o?.(l),l.defaultPrevented||i();},disabled:n??c,"data-testid":"wizard-previous",className:s(hd,"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 ss({children:e,label:t="Next",finishLabel:r="Finish",className:o,onClick:n,...a}){let{goNext:i,isLastStep:c,color:d}=Ar();return jsx("button",{type:"button",onClick:u=>{n?.(u),u.defaultPrevented||i();},"data-testid":"wizard-next",className:s(hd,dr[d].solid,dr[d].ring,"hover:opacity-90",o),...a,children:e??(c?r:t)})}function yd({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:s("flex items-center gap-3",o,e),"data-testid":"wizard-actions",children:t??jsxs(Fragment,{children:[jsx(as,{}),jsx(ss,{})]})})}gd.displayName="Wizard";fd.displayName="WizardSteps";md.displayName="WizardPanel";bd.displayName="WizardContent";yd.displayName="WizardActions";as.displayName="WizardPrevious";ss.displayName="WizardNext";export{Od as Accordion,$d as AccordionContent,Vd as AccordionItem,_d as AccordionTrigger,xs as AdvanceDetachable,lc as Avatar,ws as Badge,Cs as Banner,Sc as Breadcrumb,lt as Button,to as ButtonGroup,Uc as Calendar,Ds as Card,Ms as CardBody,As as CardDescription,Ps as CardFooter,Is as CardHeader,Ls as CardImage,zs as CardTitle,Do as Checkbox,Fs as CheckboxGroup,Hs as CheckboxGroupItem,un as Chip,Gs as CircularProgress,jo as DEFAULT_FIELD_TYPES,Hu as DataGrid,_s as Detachable,h0 as DeviceMockup,Ks as Divider,si as Drawer,fi as Dropdown,Di as DropdownCheckboxItem,vi as DropdownContent,ki as DropdownItem,Ni as DropdownLabel,Pi as DropdownRadioGroup,Li as DropdownRadioItem,Ci as DropdownSeparator,Bi as DropdownSubMenu,Vi as DropdownSubMenuContent,Oi as DropdownSubMenuTrigger,bi as DropdownTrigger,Zs as FOCUSABLE_SELECTOR,Q0 as FileSelector,Cl as Footer,Tl as FooterBottom,Sl as FooterColumn,Rl as FooterLink,Nl as FooterSection,Dl as FooterSocial,El as FooterSocialLink,ag as Header,Ki as HelpButton,Ys as INERT_IGNORE_ATTRIBUTE,Tg as ImageUploader,Xi as Indicator,ar as Input,Zi as Label,ka as MentionInput,vr as Modal,Ca as NumberInput,qg as Pagination,tl as ProgressBar,rl as RadioButton,jl as SchemaEditor,vf as Select,Tf as Sidebar,Ef as SidebarContent,If as SidebarFooter,Mf as SidebarGroup,Df as SidebarHeader,Pf as SidebarItem,Lf as SidebarSubMenu,zf as SidebarToggle,il as Skeleton,dl as Slider,Qf as Table,nm as TableBody,lm as TableCell,tm as TableHeader,rm as TableHeaderCell,sm as TableRow,pl as Tabs,hl as TabsContent,gl as TabsList,bl as TabsTrigger,vl as Toast,dt as Tooltip,W0 as UILabelsProvider,vg as WithHelpButton,gd as Wizard,yd as WizardActions,bd as WizardContent,ss as WizardNext,md as WizardPanel,as as WizardPrevious,fd as WizardSteps,ld as WorkflowEditor,Ya as autoLayoutTables,s as cn,Oa as createDefaultField,Va as createDefaultTable,ni as defaultUILabels,mn as findOwnedLayers,A0 as frenchUILabels,Xo as generateFieldId,Ba as generateRelationId,Wn as generateSQL,Al as generateTableId,bn as getFocusableElements,ua as hideOthers,Qs as isElementVisible,ei as isFocusable,_r as registerFloatingLayer,so as useClickOutside,$r as useDialogA11y,Lt as useDropdownContext,yi as useFocusItem,xn as useKeyboardNavigation,io as usePositioning,Cf as useSidebar,Gt as useUILabels,Ar as useWizard};
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};