@synertech/ui 0.40.1 → 0.41.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.claude/skills/use-synertech-ui/SKILL.md +83 -0
- package/dist/index.cjs +10 -10
- package/dist/index.d.cts +427 -46
- package/dist/index.d.ts +427 -46
- package/dist/index.js +10 -10
- package/dist/styles.css +109 -0
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import*as Ns from'react';import Ns__default,{createContext,forwardRef,memo,useId,useState,useRef,useEffect,useCallback,useImperativeHandle,useMemo,useContext,cloneElement,isValidElement,useLayoutEffect}from'react';import {jsx,jsxs,Fragment}from'react/jsx-runtime';import {createPortal}from'react-dom';import {createRoot}from'react-dom/client';import Gf from'dompurify';import Xf from'react-markdown';import Kf from'remark-gfm';function c(...e){return e.filter(Boolean).join(" ")}var Bi=createContext(null),Vi=createContext(null);function cs(){let e=useContext(Bi);if(!e)throw new Error("Accordion sub-components must be used within <Accordion>");return e}function Oi(){let e=useContext(Vi);if(!e)throw new Error("AccordionTrigger/AccordionContent must be used within <AccordionItem>");return e}var $i={sm:{trigger:"px-3 py-2",content:"px-3 pb-2",text:"text-sm",icon:"w-3.5 h-3.5"},md:{trigger:"px-4 py-3",content:"px-4 pb-3",text:"text-base",icon:"w-4 h-4"},lg:{trigger:"px-5 py-4",content:"px-5 pb-4",text:"text-lg",icon:"w-5 h-5"}},Mu=({className:e})=>jsx("svg",{className:e,viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true",children:jsx("path",{fillRule:"evenodd",d:"M5.23 7.21a.75.75 0 011.06.02L10 11.168l3.71-3.938a.75.75 0 111.08 1.04l-4.25 4.5a.75.75 0 01-1.08 0l-4.25-4.5a.75.75 0 01.02-1.06z",clipRule:"evenodd"})}),Lu={default:"border border-gray-200 dark:border-gray-700 rounded-lg divide-y divide-gray-200 dark:divide-gray-700",bordered:"border-2 border-gray-300 dark:border-gray-600 rounded-lg divide-y divide-gray-300 dark:divide-gray-600",separated:"space-y-2",ghost:""},Au={default:"",bordered:"",separated:"border border-gray-200 dark:border-gray-700 rounded-lg overflow-hidden",ghost:"border-b border-gray-200 dark:border-gray-700 last:border-b-0"};function zu({type:e="single",value:t,defaultValue:r,onValueChange:o,collapsible:n=false,variant:a="default",size:s="md",disabled:l=false,iconPosition:i="right",icon:d,hideIcon:u=false,className:p,children:b}){let[m,f]=useState(()=>r?Array.isArray(r)?r:[r]:[]),h=t!==void 0,y=h?Array.isArray(t)?t:[t]:m,C=useCallback(E=>{let k;e==="single"?y.includes(E)?k=n?[]:[E]:k=[E]:k=y.includes(E)?y.filter(R=>R!==E):[...y,E],h||f(k),o?.(e==="single"?k[0]??"":k);},[e,y,n,h,o]),v=useMemo(()=>({openItems:y,toggle:C,variant:a,size:s,disabled:l,iconPosition:i,icon:d??null,hideIcon:u}),[y,C,a,s,l,i,d,u]);return jsx(Bi.Provider,{value:v,children:jsx("div",{className:c(Lu[a],p),"data-testid":"accordion",children:b})})}function Wu({value:e,disabled:t,className:r,children:o}){let n=cs(),a=n.openItems.includes(e),s=t??n.disabled,l=useId(),i=`accordion-trigger-${l}`,d=`accordion-content-${l}`,u=useMemo(()=>({value:e,isOpen:a,disabled:s,triggerId:i,contentId:d}),[e,a,s,i,d]);return jsx(Vi.Provider,{value:u,children:jsx("div",{className:c(Au[n.variant],r),"data-state":a?"open":"closed","data-testid":"accordion-item",children:o})})}function Hu({className:e,icon:t,children:r}){let o=cs(),n=Oi(),a=$i[o.size],s=()=>{n.disabled||o.toggle(n.value);},l=u=>{(u.key==="Enter"||u.key===" ")&&(u.preventDefault(),s());},i=t??o.icon??jsx(Mu,{className:a.icon}),d=!o.hideIcon&&jsx("span",{className:c("shrink-0 text-gray-500 dark:text-gray-400 transition-transform duration-200",n.isOpen&&"rotate-180"),"data-testid":"accordion-icon",children:i});return jsxs("button",{type:"button",id:n.triggerId,"aria-expanded":n.isOpen,"aria-controls":n.contentId,disabled:n.disabled,onClick:s,onKeyDown:l,className:c("flex items-center w-full text-left font-medium transition-colors cursor-pointer",a.trigger,a.text,"text-gray-900 dark:text-gray-100",!n.disabled&&"hover:bg-gray-50 dark:hover:bg-gray-800/50",n.disabled&&"opacity-50 cursor-not-allowed",e),"data-testid":"accordion-trigger",children:[o.iconPosition==="left"&&d,jsx("span",{className:"flex-1",children:r}),o.iconPosition==="right"&&d]})}function Fu({className:e,children:t}){let r=cs(),o=Oi(),n=$i[r.size],a=useRef(null),[s,l]=useState(o.isOpen?void 0:0),i=useRef(true);return useEffect(()=>{if(i.current){i.current=false,l(o.isOpen?void 0:0);return}if(o.isOpen){let d=a.current;if(d){l(d.scrollHeight);let u=setTimeout(()=>l(void 0),200);return ()=>clearTimeout(u)}}else {let d=a.current;d&&(l(d.scrollHeight),requestAnimationFrame(()=>l(0)));}},[o.isOpen]),jsx("div",{id:o.contentId,role:"region","aria-labelledby":o.triggerId,className:"overflow-hidden transition-[height] duration-200 ease-in-out",style:{height:s===void 0?"auto":s},"data-testid":"accordion-content","data-state":o.isOpen?"open":"closed",children:jsx("div",{ref:a,className:c(n.content,"text-gray-600 dark:text-gray-400",n.text==="text-lg"?"text-base":"text-sm",e),children:t})})}function _u(...e){return e.filter(Boolean).join(" ")}var Gu="@synertech/ui/AdvanceDetachable",Xu=300,Ku="width=800,height=600,menubar=no,toolbar=no,location=no,status=no,scrollbars=yes,resizable=yes",Uu=0;function Yu(){return `${Date.now()}-${++Uu}-${Math.random().toString(36).slice(2,8)}`}function _i(e){try{return JSON.stringify(e)}catch{return String(e)}}function Gi(e){try{return JSON.parse(e)}catch{return e}}function ju(e,t){e.querySelectorAll("style").forEach(r=>{let o=t.createElement("style");o.textContent=r.textContent,t.head.appendChild(o);}),e.querySelectorAll('link[rel="stylesheet"]').forEach(r=>{let o=r,n=t.createElement("link");n.rel="stylesheet",n.href=o.href,o.crossOrigin&&(n.crossOrigin=o.crossOrigin),t.head.appendChild(n);}),e.documentElement.className&&(t.documentElement.className=e.documentElement.className),e.body.className&&(t.body.className=e.body.className);}function qu(e,t){let r=new MutationObserver(o=>{for(let n of o)for(let a of Array.from(n.addedNodes))if(a instanceof HTMLStyleElement){let s=t.createElement("style");s.textContent=a.textContent,t.head.appendChild(s);}else if(a instanceof HTMLLinkElement&&a.rel==="stylesheet"){let s=t.createElement("link");s.rel="stylesheet",s.href=a.href,t.head.appendChild(s);}});return r.observe(e.head,{childList:true}),r}function Zu(){return typeof BroadcastChannel<"u"}function Ju({mode:e,id:t,title:r="",children:o,value:n,defaultValue:a,onValueChange:s,isDetached:l,defaultDetached:i=false,onDetachedChange:d,features:u,target:p,autoFocus:b=true,className:m,detachedBodyClassName:f,disabled:h=false,readOnly:y=false,closeOnMainWindowUnload:C=true,name:v,serialize:E,deserialize:k},R){let g=l!==void 0,[P,T]=useState(i),D=g?l:P,W=n!==void 0,[V,_]=useState(a),M=W?n:V,[w,N]=useState(null),x=useRef(null),S=useRef(null),I=useRef(null),F=useRef(null),O=useRef(false),Z=useRef(null),U=useRef(null),H=useRef(null),[z]=useState(()=>`${Date.now().toString(36)}-${Math.random().toString(36).slice(2,8)}`),$=useRef({title:r,features:u,target:p,autoFocus:b,detachedBodyClassName:f,closeOnMainWindowUnload:C,disabled:h,readOnly:y,mode:e,id:t});$.current={title:r,features:u,target:p,autoFocus:b,detachedBodyClassName:f,closeOnMainWindowUnload:C,disabled:h,readOnly:y,mode:e,id:t};let K=useRef(E??_i);K.current=E??_i;let se=useRef(k??Gi);se.current=k??Gi;let X=useRef(s);X.current=s;let ee=useRef(d);ee.current=d;let L=useRef(D);L.current=D;let q=`${Gu}/${t}`,ge=useCallback(()=>{I.current&&(clearInterval(I.current),I.current=null),F.current&&(F.current.disconnect(),F.current=null),N(null);},[]),de=useCallback(()=>{S.current&&(S.current.close(),S.current=null),Z.current&&typeof window<"u"&&(window.removeEventListener("message",Z.current),Z.current=null);},[]),Y=useCallback(Re=>{if(!(!Re||Re.channel!==q)&&Re.instanceId!==z&&!$.current.readOnly&&Re.type==="value-sync"&&Re.payload!==void 0){U.current=Re.payload;let We=se.current(Re.payload);W||_(We),X.current?.(We);}},[q,z,W]),le=useCallback(()=>{if(de(),!(typeof window>"u"))if(Zu()){let Re=new BroadcastChannel(q),We=ft=>Y(ft.data);Re.addEventListener("message",We),S.current=Re;}else {let Re=We=>{We.data?.channel===q&&Y(We.data);};window.addEventListener("message",Re),Z.current=Re;}},[q,de,Y]),xe=useCallback(Re=>{if($.current.readOnly)return;let We=K.current(Re);if(We===H.current)return;if(We===U.current){U.current=null;return}H.current=We;let ft={channel:q,instanceId:z,messageId:Yu(),origin:"main",timestamp:Date.now(),type:"value-sync",payload:We};S.current?S.current.postMessage(ft):x.current&&!x.current.closed&&x.current.postMessage(ft,"*");},[q,z]),Se=useCallback(()=>{if(typeof window>"u"||$.current.disabled||O.current||x.current&&!x.current.closed)return;O.current=true;let Re=$.current,We=window.open("",Re.target||"",Re.features||Ku);if(!We){O.current=false;return}x.current=We,We.document.title=Re.title||document.title,Re.detachedBodyClassName&&(We.document.body.className=Re.detachedBodyClassName);let ft=We.document.createElement("div");We.document.body.appendChild(ft),N(ft),ju(document,We.document),F.current=qu(document,We.document),I.current=setInterval(()=>{We.closed&&(ge(),x.current=null,g||T(false),ee.current?.(false));},Xu),Re.autoFocus&&We.focus(),O.current=false;},[g,ge]),te=useCallback(()=>{x.current&&!x.current.closed&&x.current.close(),x.current=null,ge();},[ge]),Ne=useRef(Se);Ne.current=Se;let De=useRef(te);De.current=te;let Ve=useRef(xe);Ve.current=xe;let rt=useCallback(()=>{$.current.disabled||(g||T(true),ee.current?.(true));},[g]),dt=useCallback(()=>{g||T(false),ee.current?.(false);},[g]),re=useCallback(()=>{let Re=!L.current;Re&&$.current.disabled||(g||T(Re),ee.current?.(Re));},[g]);useImperativeHandle(R,()=>({open:rt,close:dt,toggle:re,get isDetached(){return L.current},get window(){return x.current}}),[rt,dt,re]),useEffect(()=>(le(),()=>de()),[le,de]),useEffect(()=>{if(D)return Ne.current(),()=>De.current();De.current();},[D]),useEffect(()=>{M!==void 0&&Ve.current(M);},[M]),useEffect(()=>{x.current&&!x.current.closed&&r&&(x.current.document.title=r);},[r]),useEffect(()=>{if(typeof window>"u")return;let Re=()=>{$.current.closeOnMainWindowUnload&&x.current&&!x.current.closed&&x.current.close();};return window.addEventListener("beforeunload",Re),()=>{window.removeEventListener("beforeunload",Re),x.current&&!x.current.closed&&x.current.close(),x.current=null;}},[]);let pe=typeof o=="function"?o({open:rt,close:dt,toggle:re,detached:D,windowRef:x.current}):o,Ue=e==="clone"||!D,yt=D&&w!==null;return jsxs(Fragment,{children:[v&&M!==void 0&&jsx("input",{type:"hidden",name:v,value:K.current(M)}),Ue&&jsx("div",{className:_u(m),children:pe}),yt&&createPortal(pe,w)]})}var Ki=forwardRef(Ju);Ki.displayName="AdvanceDetachable";function hn(e,t=11){return e.length*t*.6}function yn(e,t=11){let r=0;for(let o of e){let n=hn(o,t);n>r&&(r=n);}return r}function Ui(e,t,r,o=12){if(e<=1||t<=0)return 1;let n=r+o,a=Math.max(1,Math.floor(t/n));return Math.max(1,Math.ceil(e/a))}var t0=10,r0={sm:"text-[10px]",md:"text-[11px]",lg:"text-xs"};function Ut({orientation:e,ticks:t,length:r,showLine:o=true,tickSize:n=4,tickPadding:a=6,label:s,size:l="md",className:i,...d}){let u=e==="bottom";return jsxs("g",{className:c(r0[l],i),"aria-hidden":"true",...d,children:[o&&jsx("line",{x1:0,y1:0,x2:u?r:0,y2:u?0:r,className:"stroke-gray-300 dark:stroke-gray-600",strokeWidth:1,shapeRendering:"crispEdges"}),t.map(p=>{let b=u?p.offset:0,m=u?0:p.offset;return jsxs("g",{transform:`translate(${b}, ${m})`,children:[jsx("line",{x1:0,y1:0,x2:u?0:-n,y2:u?n:0,className:"stroke-gray-300 dark:stroke-gray-600",strokeWidth:1}),jsx("text",{x:u?0:-(n+a),y:u?n+a:0,textAnchor:u?"middle":"end",dominantBaseline:u?"hanging":"middle",className:"fill-gray-500 dark:fill-gray-400 [font-variant-numeric:tabular-nums]",children:p.label})]},`${p.label}-${p.offset}`)}),s?jsx("text",{x:u?r/2:0,y:u?n+a+16:0,textAnchor:"middle",dominantBaseline:u?"hanging":"middle",transform:u?void 0:`translate(${-(n+a+yn(t.map(p=>p.label))+t0)}, ${r/2}) rotate(-90)`,className:"fill-gray-600 dark:fill-gray-300 font-medium",children:s}):null]})}var qi={closeModal:"Close modal",closeDrawer:"Close drawer",closeSidebar:"Close sidebar",openSidebar:"Open sidebar",expandSidebar:"Expand sidebar",collapseSidebar:"Collapse sidebar",sidebar:"Sidebar",enterFullScreen:"Enter full screen",exitFullScreen:"Exit full screen",confirm:"Confirm",cancel:"Cancel",markdownEditorUnavailable:"Markdown editor unavailable. Pass markdownEditor from @synertech/ui/markdown-editor.",chartShowTable:"Show data table",chartHideTable:"Hide data table",chartNoData:"No data",chartLoading:"Loading chart",chartOther:"Other"},a0={closeModal:"Fermer la fen\xEAtre",closeDrawer:"Fermer le panneau",closeSidebar:"Fermer le menu lat\xE9ral",openSidebar:"Ouvrir le menu lat\xE9ral",expandSidebar:"D\xE9plier le menu lat\xE9ral",collapseSidebar:"Replier le menu lat\xE9ral",sidebar:"Menu lat\xE9ral",enterFullScreen:"Passer en plein \xE9cran",exitFullScreen:"Quitter le plein \xE9cran",confirm:"Confirmer",cancel:"Annuler",markdownEditorUnavailable:"\xC9diteur Markdown indisponible. Passez markdownEditor depuis @synertech/ui/markdown-editor.",chartShowTable:"Afficher le tableau de donn\xE9es",chartHideTable:"Masquer le tableau de donn\xE9es",chartNoData:"Aucune donn\xE9e",chartLoading:"Chargement du graphique",chartOther:"Autres"},us=createContext(qi);function s0({labels:e,children:t}){let r=useContext(us),o=useMemo(()=>({...r,...e}),[r,e]);return jsx(us.Provider,{value:o,children:t})}function Ft(){return useContext(us)}var l0={default:"stroke-gray-500 dark:stroke-gray-400",primary:"stroke-blue-600 dark:stroke-blue-500",success:"stroke-green-600 dark:stroke-green-500",warning:"stroke-yellow-500 dark:stroke-yellow-400",error:"stroke-red-600 dark:stroke-red-500",info:"stroke-cyan-600 dark:stroke-cyan-500"},d0={default:"text-gray-700 dark:text-gray-300",primary:"text-blue-600 dark:text-blue-400",success:"text-green-600 dark:text-green-400",warning:"text-yellow-600 dark:text-yellow-400",error:"text-red-600 dark:text-red-400",info:"text-cyan-600 dark:text-cyan-400"},c0={xs:24,sm:32,md:48,lg:64,xl:96},u0={xs:"text-[8px]",sm:"text-[10px]",md:"text-sm",lg:"text-base",xl:"text-xl"},p0={thin:2,normal:4,thick:8};function Ho({value:e=0,indeterminate:t=false,size:r="md",thickness:o="normal",color:n="primary",progressColor:a,trackColor:s,showValue:l=false,children:i,valueFormat:d,animated:u=true,className:p,...b}){let m=Math.min(100,Math.max(0,e)),f=c0[r],h=p0[o],y=(f-h)/2,C=2*Math.PI*y,v=f/2,E=C-m/100*C,k=a||l0[n],R=s||"stroke-gray-200 dark:stroke-gray-700",g=d0[n],P=i??(l&&!t?jsx("span",{className:c("font-semibold",u0[r],g),children:d?d(m):`${Math.round(m)}%`}):null);return jsxs("div",{className:c("relative inline-flex items-center justify-center",p),role:"progressbar","aria-valuenow":t?void 0:m,"aria-valuemin":0,"aria-valuemax":100,...b,children:[jsxs("svg",{width:f,height:f,viewBox:`0 0 ${f} ${f}`,className:c(t&&"animate-spin"),style:{transform:"rotate(-90deg)"},children:[jsx("circle",{cx:v,cy:v,r:y,fill:"none",strokeWidth:h,className:R}),jsx("circle",{cx:v,cy:v,r:y,fill:"none",strokeWidth:h,strokeLinecap:"round",strokeDasharray:C,strokeDashoffset:t?C*.75:E,className:c(k,u&&!t&&"transition-[stroke-dashoffset] duration-300 ease-out")})]}),P&&jsx("div",{className:"absolute inset-0 flex items-center justify-center",style:{transform:"rotate(0deg)"},children:P})]})}Ho.displayName="CircularProgress";var Ji=640;function ps(e={}){let{width:t,fallbackWidth:r=Ji}=e,o=useRef(null),[n,a]=useState(0);return useEffect(()=>{if(t!==void 0)return;let s=o.current;if(!s)return;let l=d=>{a(u=>Math.abs(u-d)<1?u:d);};if(l(s.getBoundingClientRect().width),typeof ResizeObserver>"u")return;let i=new ResizeObserver(d=>{for(let u of d)l(u.contentRect.width);});return i.observe(s),()=>i.disconnect()},[t]),t!==void 0?{ref:o,width:t,measured:true}:{ref:o,width:n>0?n:r,measured:n>0}}var y0={sm:"text-xs",md:"text-sm",lg:"text-base"};function lr({title:e,description:t,height:r=240,width:o,size:n="md",legend:a,legendPosition:s="bottom",actions:l,loading:i=false,empty:d=false,emptyState:u,table:p,tableView:b=false,showTableLabel:m,hideTableLabel:f,noDataLabel:h,loadingLabel:y,ariaLabel:C,children:v,className:E,...k}){let R=Ft(),[g,P]=useState(false),T=useId(),D=`${T}-table`,W=`${T}-title`,V=`${T}-description`,{ref:_,width:M,measured:w}=ps({width:o}),N=!!p&&b==="toggle",x=!!p&&(b===true||N&&g),F=jsx("div",{ref:_,className:"relative w-full",style:{height:r},"aria-busy":i||void 0,children:i&&d?jsx("div",{className:"flex h-full w-full items-center justify-center",children:jsx(Ho,{indeterminate:true,size:"md","aria-label":y??R.chartLoading})}):d&&!i?jsx("div",{className:"flex h-full w-full items-center justify-center text-sm text-gray-500 dark:text-gray-400",children:u??h??R.chartNoData}):jsx("div",{className:c("h-full w-full transition-opacity duration-200",i&&"opacity-60"),children:typeof v=="function"?v({width:M,height:r,measured:w}):v})});return jsxs("figure",{className:c("flex w-full flex-col gap-3",E),"aria-label":C,"aria-labelledby":!C&&e?W:void 0,"aria-describedby":t?V:void 0,...k,children:[e||t||l?jsxs("figcaption",{className:"flex items-start justify-between gap-3",children:[jsxs("div",{className:"flex flex-col gap-0.5",children:[e?jsx("span",{id:W,className:c("font-semibold text-gray-900 dark:text-gray-100",y0[n]),children:e}):null,t?jsx("span",{id:V,className:"text-xs text-gray-500 dark:text-gray-400",children:t}):null]}),l]}):null,a&&s==="top"?a:null,a&&s==="right"?jsxs("div",{className:"flex items-start gap-4",children:[jsx("div",{className:"min-w-0 grow",children:F}),a]}):F,a&&s==="bottom"?a:null,N&&jsx("div",{className:"flex",children:jsx("button",{type:"button",onClick:()=>P(O=>!O),"aria-expanded":g,"aria-controls":x?D:void 0,className:"cursor-pointer rounded-sm text-xs font-medium text-gray-600 underline underline-offset-2 hover:text-gray-900 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-blue-500 dark:text-gray-400 dark:hover:text-white",children:g?f??R.chartHideTable:m??R.chartShowTable})}),x&&jsx("div",{id:D,children:p})]})}var Qi=[];function Wr({width:e,height:t,horizontal:r=Qi,vertical:o=Qi,className:n,...a}){return jsxs("g",{className:c("stroke-gray-200 dark:stroke-gray-700",n),strokeWidth:1,shapeRendering:"crispEdges","aria-hidden":"true",...a,children:[r.map(s=>jsx("line",{x1:0,y1:s,x2:e,y2:s},`h-${s}`)),o.map(s=>jsx("line",{x1:s,y1:0,x2:s,y2:t},`v-${s}`))]})}var v0={line:"h-0.5 w-3 rounded-full",rect:"h-2.5 w-2.5 rounded-sm",dot:"h-2 w-2 rounded-full"},k0={sm:"text-[11px]",md:"text-xs",lg:"text-sm"};function dr({items:e,position:t="bottom",marker:r="line",onToggle:o,size:n="md",className:a,...s}){return e.length===0?null:jsx("ul",{className:c("flex list-none flex-wrap gap-x-4 gap-y-1 p-0",t==="right"?"flex-col":"flex-row",t==="top"||t==="bottom"?"justify-center":"",k0[n],a),...s,children:e.map(l=>{let i=jsx("span",{className:c("shrink-0",v0[r]),style:{backgroundColor:l.color},"aria-hidden":"true"}),d=jsx("span",{className:c(l.hidden&&"line-through"),children:l.label}),u=jsxs(Fragment,{children:[i,d]}),p=c("flex items-center gap-1.5 text-gray-600 dark:text-gray-300",l.hidden&&"text-gray-400 dark:text-gray-500");return jsx("li",{children:o?jsx("button",{type:"button",onClick:()=>o(l.key),"aria-pressed":!l.hidden,className:c(p,"cursor-pointer rounded-sm hover:text-gray-900 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-blue-500 dark:hover:text-white"),children:u}):jsx("span",{className:p,children:u})},l.key)})})}function gs({children:e,className:t,...r}){return jsx("table",{className:c("w-full text-sm text-left rtl:text-right text-gray-500 dark:text-gray-400",t),...r,children:e})}function ms({children:e,className:t,...r}){return jsx("tbody",{className:c(t),...r,children:e})}function na({children:e,onClick:t,hidden:r=false,className:o,...n}){return jsx("td",{className:c("px-6 py-4",o),onClick:t,hidden:r,...n,children:e})}function fs({children:e,className:t,...r}){return jsx("thead",{className:c("text-xs text-gray-700 uppercase bg-gray-50 dark:bg-gray-700 dark:text-gray-400",t),...r,children:jsx("tr",{children:e})})}function aa({children:e,onClick:t,hidden:r=false,className:o,sortable:n=false,...a}){return jsx("th",{scope:"col",className:c("px-6 py-3",n&&"cursor-pointer hover:bg-gray-100 dark:hover:bg-gray-600",o),onClick:t,hidden:r,...a,children:e})}function bs({children:e,onClick:t,clickable:r=true,className:o,...n}){return jsx("tr",{className:c("bg-white border-b dark:bg-gray-800 dark:border-gray-700",r&&"hover:bg-gray-50 hover:cursor-pointer dark:hover:bg-gray-600",o),onClick:t,...n,children:e})}var E0=8,sa=["var(--color-chart-1)","var(--color-chart-2)","var(--color-chart-3)","var(--color-chart-4)","var(--color-chart-5)","var(--color-chart-6)","var(--color-chart-7)","var(--color-chart-8)"],xn="var(--color-chart-muted)",ia=3,rl=false;function la(e,t){return t||(e<0||e>=8?(rl||(rl=true,console.warn('[@synertech/ui] A chart was given more than 8 series. Extra series share the de-emphasis grey: fold the tail into an "Other" bucket, or split the chart, instead of relying on a ninth colour.')),xn):sa[e])}function Cr(e,t,r){return r&&e.key!==r?xn:la(t,e.color)}function Lt(e){return e.label??e.key}function Hr(e,t){return e.map((r,o)=>({key:r.key,label:Lt(r),color:Cr(r,o,t),hidden:r.hidden}))}function St(e,t){let r=e[t];if(r==null||r==="")return null;if(typeof r=="number")return Number.isFinite(r)?r:null;if(typeof r=="boolean")return r?1:0;if(typeof r=="string"){let o=Number(r);return Number.isFinite(o)?o:null}return null}function bo(e,t,r){let o=e[t];return o instanceof Date||typeof o=="number"||typeof o=="string"?o:o==null?r:String(o)}function Fr(e,t){let r=[];for(let o of e)for(let n of t)r.push(St(o,n));return r}function vn(e,t={}){if(!Number.isFinite(e))return "\u2014";let{locale:r,compact:o,currency:n,unit:a,minimumFractionDigits:s,maximumFractionDigits:l}=t,i=new Intl.NumberFormat(r,{notation:o?"compact":"standard",...n?{style:"currency",currency:n}:{},...s!==void 0?{minimumFractionDigits:s}:{},...l!==void 0?{maximumFractionDigits:l}:o?{maximumFractionDigits:1}:{}}).format(e);return a?`${i}${a}`:i}function D0(e,t){return vn(e,{locale:t,compact:true})}function _t(e,t){return Number.isFinite(e)?Math.abs(e)<1e4?vn(e,{locale:t}):D0(e,t):"\u2014"}function Br(e,t={}){if(!Number.isFinite(e))return "\u2014";let{locale:r,maximumFractionDigits:o=1,alreadyScaled:n,signed:a}=t;return new Intl.NumberFormat(r,{style:"percent",maximumFractionDigits:o,...a?{signDisplay:"exceptZero"}:{}}).format(n?e/100:e)}function Gt(e,t){return e instanceof Date?new Intl.DateTimeFormat(t,{day:"2-digit",month:"short"}).format(e):typeof e=="number"?vn(e,{locale:t}):e}function cr({data:e,series:t,xKey:r,xLabel:o,formatX:n,formatValue:a,caption:s,emptyLabel:l,className:i,...d}){let u=t.filter(m=>!m.hidden);if(e.length===0||u.length===0)return jsx("div",{className:c("text-sm text-gray-500 dark:text-gray-400",i),...d,children:l});let p=(m,f)=>{let h=bo(m,r,f);return n?n(h,f):Gt(h)},b=m=>m===null?"\u2014":a?a(m):vn(m);return jsx("div",{className:c("w-full overflow-x-auto",i),...d,children:jsxs(gs,{children:[s?jsx("caption",{className:"sr-only",children:s}):null,jsxs(fs,{children:[jsx(aa,{children:o??r}),u.map(m=>jsx(aa,{className:"text-right",children:Lt(m)},m.key))]}),jsx(ms,{children:e.map((m,f)=>jsxs(bs,{clickable:false,children:[jsx(na,{className:"font-medium text-gray-900 dark:text-gray-100",children:p(m,f)}),u.map(h=>jsx(na,{className:"text-right [font-variant-numeric:tabular-nums]",children:b(St(m,h.key))},h.key))]},f))})]})})}function ur({x:e,y:t,visible:r=true,containerWidth:o,offset:n=12,className:a,style:s,children:l,...i}){if(!r)return null;let d=o!==void 0&&e>o*.6;return jsx("div",{role:"tooltip",className:c("pointer-events-none absolute top-0 left-0 z-10 min-w-24 rounded-md border border-gray-200 bg-white px-2.5 py-2 text-xs shadow-lg dark:border-gray-700 dark:bg-gray-800",a),style:{transform:`translate(${d?e-n:e+n}px, ${t}px) translate(${d?"-100%":"0"}, -50%)`,...s},...i,children:l})}function pr({title:e,points:t}){return jsxs("div",{className:"flex flex-col gap-1",children:[e!=null&&jsx("div",{className:"font-medium text-gray-900 dark:text-gray-100",children:e}),jsx("div",{className:"flex flex-col gap-0.5",children:t.map(r=>jsxs("div",{className:"flex items-center gap-2",children:[jsx("span",{className:"h-0.5 w-3 shrink-0 rounded-full",style:{backgroundColor:r.color},"aria-hidden":"true"}),jsx("span",{className:"grow text-gray-500 dark:text-gray-400",children:r.seriesLabel}),jsx("span",{className:"font-semibold text-gray-900 [font-variant-numeric:tabular-nums] dark:text-gray-100",children:r.formattedValue})]},r.seriesKey))})]})}function eo(e){return e instanceof Date?e.toISOString():String(e)}function Nr(e){if(e instanceof Date)return e.getTime();if(typeof e=="number")return e;let t=Number(e);return Number.isFinite(t)?t:Number.NaN}function ho(e,t){let[r,o]=e,[n,a]=t,s=o-r,l=s===0?0:(a-n)/s,i=(d=>Number.isFinite(d)?s===0?(n+a)/2:n+(d-r)*l:Number.NaN);return Object.defineProperties(i,{domain:{value:[r,o],enumerable:true},range:{value:[n,a],enumerable:true},invert:{value:d=>l===0?r:r+(d-n)/l,enumerable:true}}),i}function nl(e,t,r={}){let{paddingInner:o=.2,paddingOuter:n=o/2}=r,[a,s]=t,l=e.length,i=l===0?0:(s-a)/Math.max(1,l-o+n*2),d=i*(1-o),u=a+(s-a-i*(l-o))/2,p=new Map;e.forEach((f,h)=>{p.has(eo(f))||p.set(eo(f),h);});let b=f=>u+i*f,m=(f=>{let h=p.get(eo(f));return h===void 0?Number.NaN:b(h)});return Object.defineProperties(m,{bandwidth:{value:d,enumerable:true},step:{value:i,enumerable:true},domain:{value:e,enumerable:true},range:{value:[a,s],enumerable:true},center:{value:f=>{let h=p.get(eo(f));return h===void 0?Number.NaN:b(h)+d/2},enumerable:true},positions:{value:()=>e.map((f,h)=>b(h)),enumerable:true},indexOf:{value:f=>p.get(eo(f))??-1,enumerable:true}}),m}function Vo(e,t){if(e.length===0)return -1;let r=0,o=Number.POSITIVE_INFINITY;for(let n=0;n<e.length;n+=1){let a=Math.abs(e[n]-t);a<o&&(o=a,r=n);}return r}function kn(e){let t=Number(e.toPrecision(12));return Object.is(t,-0)?0:t}function al(e){if(!Number.isFinite(e)||e<=0)return 1;let t=Math.floor(Math.log10(e)),r=Math.pow(10,t),o=e/r,n=o<=1?1:o<=2?2:o<=5?5:10;return kn(n*r)}function I0(e,t,r=5){if(!Number.isFinite(e)||!Number.isFinite(t))return [0,1];if(e===t){if(e===0)return [0,1];let n=Math.abs(e)*.5;[e,t]=[e-n,e+n];}let o=al((t-e)/Math.max(1,r));return [kn(Math.floor(e/o)*o),kn(Math.ceil(t/o)*o)]}function ys(e,t,r=5){if(!Number.isFinite(e)||!Number.isFinite(t))return [];if(r<=0)return [];if(e===t)return [kn(e)];e>t&&([e,t]=[t,e]);let o=al((t-e)/r),n=Math.ceil(e/o),a=Math.floor(t/o),s=[];for(let l=n;l<=a&&s.length<=1e3;l+=1)s.push(kn(l*o));return s}function Xt(e){let t=Number.POSITIVE_INFINITY,r=Number.NEGATIVE_INFINITY,o=false;for(let n of e)n==null||!Number.isFinite(n)||(o=true,n<t&&(t=n),n>r&&(r=n));return o?[t,r]:null}function sl(e,t={}){let{domain:r,includeZero:o=true,ticks:n=5}=t;if(Array.isArray(r))return r;let a=Xt(e);if(!a)return [0,1];let[s,l]=a;return o&&(s=Math.min(s,0),l=Math.max(l,0)),I0(s,l,n)}var xs={top:10,right:16,bottom:28},il=16,L0=14,A0=32;function to({width:e,height:t,data:r,x:o,y:n,bounds:a,margin:s,orientation:l="vertical",placement:i="point",bandPaddingInner:d=.2,formatValue:u,formatX:p,extraTop:b=0,defaultIncludeZero:m=false}){let f=l==="vertical",h=r.map(($,K)=>bo($,o.key,K)),y=sl(a??[],{domain:n?.domain,includeZero:n?.includeZero??m,ticks:n?.ticks??5}),C=n?.hidden??false,v=o.hidden??false,E=C?[]:ys(y[0],y[1],n?.ticks??5),k=E.map(u),R=f&&(o.scale==="linear"||o.scale==="time"),g=h.map(($,K)=>p($,K)),P=f?C:v,T=f?k:g,D=f?n?.width:o.height,W=f?v:C,V=f?o.height:void 0,_=f?o.label:n?.label,M=f?n?.label:o.label,w=f&&!v&&i!=="band"?g:[],N=$=>$?hn($)/2+4:0,x={top:s?.top??xs.top+b,right:s?.right??Math.max(xs.right,N(w[w.length-1])),bottom:s?.bottom??(W?8:V??xs.bottom+(_?il:0)),left:s?.left??(P?8:D??Math.max(Math.max(A0,yn(T)+L0)+(M?il:0),N(w[0])))},S=Math.max(0,e-x.left-x.right),I=Math.max(0,t-x.top-x.bottom),F=f?ho(y,[I,0]):ho(y,[0,S]),O=f?S:I,Z,U=0,H;if(R){let $=h.map(Nr),K=Xt($)??[0,1],se=ho(K,[0,O]);Z=$.map(X=>se(X)),H=v?[]:ys(K[0],K[1],o.ticks??5).map(X=>({value:X,offset:se(X),label:p(o.scale==="time"?new Date(X):X,0)}));}else if(i==="band"){let $=nl(r.map((K,se)=>se),[0,O],{paddingInner:d});Z=r.map((K,se)=>$(se)),U=$.bandwidth,H=[];}else {let $=r.length>1?O/(r.length-1):0;Z=r.map((K,se)=>r.length>1?se*$:O/2),H=[];}let z=Z.map($=>$+U/2);if(!R&&!v){let $=f?yn(g):15,K=Ui(g.length,O,$);H=g.map((se,X)=>({value:h[X],offset:z[X],label:se})).filter((se,X)=>X%K===0);}return {margin:x,innerWidth:S,innerHeight:I,orientation:l,valueScale:F,domain:y,valueTicks:E.map($=>({value:$,offset:F($),label:u($)})),xValues:h,categoryPositions:Z,bandwidth:U,categoryCenters:z,categoryTicks:H,categoryLength:O}}function st(e){return Math.round(e*100)/100}function ll(e){return e.defined!==false&&Number.isFinite(e.x)&&Number.isFinite(e.y)}function dl(e,t=false){if(t){let n=e.filter(ll);return n.length>0?[n]:[]}let r=[],o=[];for(let n of e)ll(n)?o.push(n):o.length>0&&(r.push(o),o=[]);return o.length>0&&r.push(o),r}function z0(e){let t=e.length,r=[],o=[];for(let a=0;a<t-1;a+=1){let s=e[a+1].x-e[a].x;r.push(s),o.push(s===0?0:(e[a+1].y-e[a].y)/s);}let n=new Array(t);n[0]=o[0],n[t-1]=o[t-2];for(let a=1;a<t-1;a+=1){let s=o[a-1],l=o[a];if(s*l<=0)n[a]=0;else {let i=2*r[a]+r[a-1],d=r[a]+2*r[a-1];n[a]=(i+d)/(i/s+d/l);}}return n}function vs(e,t){if(e.length<2)return "";if(t==="monotone"&&e.length>2){let o=z0(e),n="";for(let a=0;a<e.length-1;a+=1){let s=e[a],l=e[a+1],i=(l.x-s.x)/3;n+=` C${st(s.x+i)},${st(s.y+o[a]*i)} ${st(l.x-i)},${st(l.y-o[a+1]*i)} ${st(l.x)},${st(l.y)}`;}return n}let r="";for(let o=1;o<e.length;o+=1){let n=e[o-1],a=e[o];if(t==="step"){let s=st((n.x+a.x)/2);r+=` L${s},${st(n.y)} L${s},${st(a.y)}`;}else t==="stepAfter"&&(r+=` L${st(a.x)},${st(n.y)}`);r+=` L${st(a.x)},${st(a.y)}`;}return r}function Vr(e,t="linear",r={}){return dl(e,r.connectNulls).map(o=>{let[n]=o;return `M${st(n.x)},${st(n.y)}${vs(o,t)}`}).join(" ")}function wn(e,t,r="linear",o={}){let n=dl(e,o.connectNulls);if(n.length===0)return "";let a=typeof t=="number"?null:new Map(t.map(s=>[st(s.x),s]));return n.map(s=>{let[l]=s,i=s[s.length-1],d=`M${st(l.x)},${st(l.y)}${vs(s,r)}`;if(a===null){let b=st(t);return `${d} L${st(i.x)},${b} L${st(l.x)},${b} Z`}let u=s.map(b=>a.get(st(b.x))).filter(b=>b!==void 0).reverse();if(u.length===0)return `${d} Z`;let[p]=u;return `${d} L${st(p.x)},${st(p.y)}${vs(u,r)} Z`}).join(" ")}function cl({x:e,y:t,width:r,height:o,radius:n=4,round:a="none"}){if(!(r>0)||!(o>0))return "";let s=Math.max(0,Math.min(n,r/2,o/2)),[l,i]=[Ae(e),Ae(t)],[d,u]=[Ae(e+r),Ae(t+o)];if(s===0||a==="none")return `M${l},${i} L${d},${i} L${d},${u} L${l},${u} Z`;switch(a){case "top":return `M${l},${u} L${l},${Ae(t+s)} Q${l},${i} ${Ae(e+s)},${i} L${Ae(e+r-s)},${i} Q${d},${i} ${d},${Ae(t+s)} L${d},${u} Z`;case "bottom":return `M${l},${i} L${d},${i} L${d},${Ae(t+o-s)} Q${d},${u} ${Ae(e+r-s)},${u} L${Ae(e+s)},${u} Q${l},${u} ${l},${Ae(t+o-s)} Z`;case "right":return `M${l},${i} L${Ae(e+r-s)},${i} Q${d},${i} ${d},${Ae(t+s)} L${d},${Ae(t+o-s)} Q${d},${u} ${Ae(e+r-s)},${u} L${l},${u} Z`;case "left":return `M${d},${i} L${Ae(e+s)},${i} Q${l},${i} ${l},${Ae(t+s)} L${l},${Ae(t+o-s)} Q${l},${u} ${Ae(e+s)},${u} L${d},${u} Z`;default:return `M${l},${i} L${d},${i} L${d},${u} L${l},${u} Z`}}function Ae(e){return Math.round(e*100)/100}function ro(e,t,r,o){return {x:Ae(e+r*Math.sin(o)),y:Ae(t-r*Math.cos(o))}}function ul({cx:e,cy:t,innerRadius:r,outerRadius:o,startAngle:n,endAngle:a}){let s=a-n;if(!(o>0)||!(s>0))return "";let l=s>=Math.PI*2-1e-9,i=Math.max(0,Math.min(r,o));if(l){let f=ro(e,t,o,0),h=ro(e,t,o,Math.PI),y=`M${f.x},${f.y} A${Ae(o)},${Ae(o)} 0 1 1 ${h.x},${h.y} A${Ae(o)},${Ae(o)} 0 1 1 ${f.x},${f.y} Z`;if(i===0)return y;let C=ro(e,t,i,0),v=ro(e,t,i,Math.PI);return `${y} M${C.x},${C.y} A${Ae(i)},${Ae(i)} 0 1 0 ${v.x},${v.y} A${Ae(i)},${Ae(i)} 0 1 0 ${C.x},${C.y} Z`}let d=s>Math.PI?1:0,u=ro(e,t,o,n),p=ro(e,t,o,a);if(i===0)return `M${Ae(e)},${Ae(t)} L${u.x},${u.y} A${Ae(o)},${Ae(o)} 0 ${d} 1 ${p.x},${p.y} Z`;let b=ro(e,t,i,a),m=ro(e,t,i,n);return `M${u.x},${u.y} A${Ae(o)},${Ae(o)} 0 ${d} 1 ${p.x},${p.y} L${b.x},${b.y} A${Ae(i)},${Ae(i)} 0 ${d} 0 ${m.x},${m.y} Z`}function da(e,t,r="none"){return e.map((o,n)=>{let a=t.map(u=>St(o,u)),s=a.reduce((u,p)=>u+(p===null?0:Math.abs(p)),0),l=0,i=0,d=t.map((u,p)=>{let b=a[p];if(r==="none")return {key:u,value:b,start:0,end:b??0};if(b===null)return {key:u,value:null,start:l,end:l};let m=r==="percent"?s===0?0:b/s*100:b;if(m>=0){let h=l;return l+=m,{key:u,value:b,start:h,end:l}}let f=i;return i+=m,{key:u,value:b,start:i,end:f}});return {index:n,datum:o,total:s,segments:d}})}function ca(e){let t=Number.POSITIVE_INFINITY,r=Number.NEGATIVE_INFINITY,o=false;for(let n of e)for(let a of n.segments)a.value!==null&&(o=true,t=Math.min(t,a.start,a.end),r=Math.max(r,a.start,a.end));return o?[t,r]:null}var H0=.12,F0=.9,B0=10,V0=memo(function({bands:t,stacked:r}){return jsx("g",{children:t.map(o=>jsxs("g",{children:[jsx("path",{d:o.area,fill:o.color,fillOpacity:r?F0:H0,stroke:"none"}),o.gap?jsx("path",{d:o.gap,fill:"none",strokeWidth:2,className:"stroke-white dark:stroke-gray-800"}):null,jsx("path",{d:o.edge,fill:"none",stroke:o.color,strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"})]},o.key))})});function O0({width:e,height:t,data:r,resolvedSeries:o,x:n,y:a,grid:s,size:l,curve:i,stack:d,baseline:u,connectNulls:p,referenceLines:b,margin:m,tooltip:f,onPointClick:h,plotLabel:y,formatValue:C,formatRaw:v,formatX:E}){let[k,R]=useState(null),g=useMemo(()=>{let w=o.filter(z=>!z.hidden),N=w.map(z=>z.key),x=d!=="none",S=da(r,N,d),I=x?ca(S):Xt([...Fr(r,N),u]),F=to({width:e,height:t,data:r,x:n,y:a,bounds:I,margin:m,placement:"point",formatValue:C,formatX:E,defaultIncludeZero:true}),O=F.categoryCenters,Z=F.valueScale,U=Z(x?0:u),H=w.map((z,$)=>{let K=r.map((ee,L)=>{let q=S[L].segments[$];return {x:O[L],y:q.value===null?Number.NaN:Z(q.end),defined:q.value!==null}}),se=r.map((ee,L)=>{let q=S[L].segments[$];return {x:O[L],y:q.value===null?Number.NaN:Z(x?q.start:u),defined:q.value!==null}}),X={connectNulls:p};return {key:z.key,color:z.color,area:x?wn(K,se,i,X):wn(K,U,i,X),edge:Vr(K,i,X),gap:x&&$>0?Vr(se,i,X):""}});return {visible:w,rows:S,stacked:x,xValues:F.xValues,positions:O,xTicks:F.categoryTicks,yTicks:F.valueTicks,valueScale:Z,innerWidth:F.innerWidth,innerHeight:F.innerHeight,margin:F.margin,bands:H}},[r,o,n,a,e,t,m,i,d,u,p,C,E]),P=useCallback(w=>g.visible.map((N,x)=>{let S=St(r[w],N.key),I=g.rows[w].segments[x],F=S===null?"\u2014":d==="percent"?`${v(S)} (${C(I.end-I.start)})`:C(S);return {seriesKey:N.key,seriesLabel:Lt(N),color:N.color,value:S,formattedValue:F,datum:r[w]}}),[r,g.visible,g.rows,d,C,v]),T=useCallback(w=>{if(f===false||r.length===0)return;let N=w.currentTarget.getBoundingClientRect(),x=w.clientX-N.left-g.margin.left,S=Vo(g.positions,x);R(S>=0?S:null);},[f,r.length,g.margin.left,g.positions]),D=useCallback(w=>{if(r.length===0)return;let N=r.length-1,x=k??0,S=w.key==="ArrowRight"?Math.min(N,x+1):w.key==="ArrowLeft"?Math.max(0,x-1):w.key==="Home"?0:w.key==="End"?N:w.key==="Escape"?null:void 0;S!==void 0&&(w.preventDefault(),R(S));},[r.length,k]),W=useCallback(()=>{if(!h||k===null)return;let[w]=P(k);w&&h({...w,index:k,x:g.xValues[k]});},[h,k,P,g.xValues]),V=k===null?null:P(k),_=k===null?[]:g.visible.map((w,N)=>{let x=g.rows[k].segments[N];return x.value===null?null:{key:w.key,color:w.color,y:g.valueScale(x.end)}}).filter(w=>w!==null),M=k===null||V===null?null:{x:g.xValues[k],xLabel:E(g.xValues[k],k),index:k,points:V};return jsxs(Fragment,{children:[jsxs("svg",{width:e,height:t,role:"img","aria-label":y??g.visible.map(w=>Lt(w)).join(", "),tabIndex:0,className:"touch-none focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-blue-500",onPointerMove:T,onPointerLeave:()=>R(null),onKeyDown:D,onBlur:()=>R(null),onClick:W,children:[jsxs("g",{transform:`translate(${g.margin.left}, ${g.margin.top})`,children:[jsx(Wr,{width:g.innerWidth,height:g.innerHeight,horizontal:s==="y"||s==="both"?g.yTicks.map(w=>w.offset):void 0,vertical:s==="x"||s==="both"?g.xTicks.map(w=>w.offset):void 0}),jsx(V0,{bands:g.bands,stacked:g.stacked}),b?.map(w=>{let N=g.valueScale(w.value),x=N<B0?N+12:N-4;return jsxs("g",{children:[jsx("line",{x1:0,y1:N,x2:g.innerWidth,y2:N,stroke:w.color??"var(--color-chart-muted)",strokeWidth:1,strokeDasharray:w.dashed===false?void 0:"4 4"}),w.label?jsx("text",{x:g.innerWidth,y:x,textAnchor:"end",className:"fill-gray-500 text-[10px] dark:fill-gray-400",children:w.label}):null]},`${w.value}-${w.label??""}`)}),k!==null?jsxs("g",{"aria-hidden":"true",children:[jsx("line",{x1:g.positions[k],y1:0,x2:g.positions[k],y2:g.innerHeight,className:"stroke-gray-400 dark:stroke-gray-500",strokeWidth:1}),_.map(w=>jsx("circle",{cx:g.positions[k],cy:w.y,r:4,fill:w.color,strokeWidth:2,className:"stroke-white dark:stroke-gray-800"},w.key))]}):null]}),jsx("g",{transform:`translate(${g.margin.left}, ${g.margin.top+g.innerHeight})`,children:n.hidden?null:jsx(Ut,{orientation:"bottom",ticks:g.xTicks,length:g.innerWidth,label:n.label,size:l})}),jsx("g",{transform:`translate(${g.margin.left}, ${g.margin.top})`,children:a?.hidden?null:jsx(Ut,{orientation:"left",ticks:g.yTicks,length:g.innerHeight,showLine:false,label:a?.label,size:l})})]}),M&&f!==false?jsx(ur,{x:g.margin.left+g.positions[M.index],y:g.margin.top+(_.length>0?Math.min(..._.map(w=>w.y)):g.innerHeight/2),containerWidth:e,children:typeof f=="function"?f(M):jsx(pr,{title:M.xLabel,points:M.points})}):null]})}function $0({data:e,series:t,x:r,y:o,height:n=240,width:a,size:s="md",grid:l="y",legend:i,tooltip:d=true,tableView:u=false,emphasis:p,title:b,description:m,loading:f=false,emptyState:h,onPointClick:y,curve:C="monotone",stack:v="none",baseline:E=0,connectNulls:k=false,referenceLines:R,legendToggle:g=true,margin:P,locale:T,plotLabel:D,className:W,...V}){let[_,M]=useState(()=>new Set),w=useMemo(()=>t.map((z,$)=>({...z,hidden:z.hidden||_.has(z.key),color:Cr(z,$,p)})),[t,_,p]),N=v==="percent",x=useMemo(()=>N?{domain:[0,100],...o}:o,[N,o]),S=useMemo(()=>o?.format??(N?z=>Br(z,{locale:T,alreadyScaled:true,maximumFractionDigits:0}):z=>_t(z,T)),[o?.format,N,T]),I=useMemo(()=>z=>_t(z,T),[T]),F=useMemo(()=>r.format??(z=>r.scale==="time"?Gt(z instanceof Date?z:new Date(Nr(z)),T):Gt(z,T)),[r.format,r.scale,T]),O=useCallback(z=>{M($=>{let K=new Set($);return K.has(z)?K.delete(z):K.add(z),K});},[]),Z=i===void 0?t.length>=2:i!==false,U=typeof i=="string"?i:"bottom",H=w.filter(z=>!z.hidden).length;return jsx(lr,{title:b,description:m,height:n,width:a,size:s,loading:f,empty:e.length===0||H===0,emptyState:h,tableView:u,legendPosition:U,legend:Z?jsx(dr,{items:Hr(w,p),position:U,marker:"rect",size:s,onToggle:g?O:void 0}):void 0,table:u?jsx(cr,{data:e,series:w,xKey:r.key,xLabel:r.label??r.key,formatX:F,formatValue:I,caption:typeof b=="string"?b:void 0}):void 0,className:W,...V,children:({width:z})=>jsx(O0,{width:z,height:n,data:e,resolvedSeries:w,x:r,y:x,grid:l,size:s,curve:C,stack:v,baseline:E,connectNulls:k,referenceLines:R,margin:P,tooltip:d,onPointClick:y,plotLabel:D,formatValue:S,formatRaw:I,formatX:F})})}var G0={xs:"h-6 w-6 text-xs",sm:"h-8 w-8 text-sm",md:"h-10 w-10 text-base",lg:"h-12 w-12 text-lg",xl:"h-16 w-16 text-xl"},X0={circle:"rounded-full",square:"rounded-none",rounded:"rounded-md"};function K0({src:e,alt:t="Avatar",fallback:r,size:o="md",variant:n="circle",border:a=false,className:s,...l}){return jsx("div",{className:c("inline-flex items-center justify-center overflow-hidden bg-gray-200 font-medium text-gray-600 dark:bg-gray-700 dark:text-gray-300",G0[o],X0[n],a&&"ring-2 ring-white dark:ring-gray-900",s),...l,children:e?jsx("img",{src:e,alt:t,className:"h-full w-full object-cover"}):jsx("span",{children:r||t.charAt(0).toUpperCase()})})}var U0={default:{solid:"bg-gray-500 text-white",soft:"bg-gray-100 text-gray-700 dark:bg-gray-700 dark:text-gray-300",outlined:"border border-gray-300 text-gray-600 dark:border-gray-600 dark:text-gray-400",subtle:"bg-gray-50 text-gray-600 dark:bg-gray-800 dark:text-gray-400"},primary:{solid:"bg-blue-600 text-white",soft:"bg-blue-100 text-blue-700 dark:bg-blue-900/50 dark:text-blue-300",outlined:"border border-blue-500 text-blue-600 dark:border-blue-400 dark:text-blue-400",subtle:"bg-blue-50 text-blue-600 dark:bg-blue-900/30 dark:text-blue-400"},success:{solid:"bg-green-600 text-white",soft:"bg-green-100 text-green-700 dark:bg-green-900/50 dark:text-green-300",outlined:"border border-green-500 text-green-600 dark:border-green-400 dark:text-green-400",subtle:"bg-green-50 text-green-600 dark:bg-green-900/30 dark:text-green-400"},warning:{solid:"bg-yellow-500 text-white",soft:"bg-yellow-100 text-yellow-700 dark:bg-yellow-900/50 dark:text-yellow-300",outlined:"border border-yellow-400 text-yellow-600 dark:border-yellow-400 dark:text-yellow-400",subtle:"bg-yellow-50 text-yellow-600 dark:bg-yellow-900/30 dark:text-yellow-400"},error:{solid:"bg-red-600 text-white",soft:"bg-red-100 text-red-700 dark:bg-red-900/50 dark:text-red-300",outlined:"border border-red-500 text-red-600 dark:border-red-400 dark:text-red-400",subtle:"bg-red-50 text-red-600 dark:bg-red-900/30 dark:text-red-400"},info:{solid:"bg-cyan-600 text-white",soft:"bg-cyan-100 text-cyan-700 dark:bg-cyan-900/50 dark:text-cyan-300",outlined:"border border-cyan-500 text-cyan-600 dark:border-cyan-400 dark:text-cyan-400",subtle:"bg-cyan-50 text-cyan-600 dark:bg-cyan-900/30 dark:text-cyan-400"},purple:{solid:"bg-purple-600 text-white",soft:"bg-purple-100 text-purple-700 dark:bg-purple-900/50 dark:text-purple-300",outlined:"border border-purple-500 text-purple-600 dark:border-purple-400 dark:text-purple-400",subtle:"bg-purple-50 text-purple-600 dark:bg-purple-900/30 dark:text-purple-400"},indigo:{solid:"bg-indigo-600 text-white",soft:"bg-indigo-100 text-indigo-700 dark:bg-indigo-900/50 dark:text-indigo-300",outlined:"border border-indigo-500 text-indigo-600 dark:border-indigo-400 dark:text-indigo-400",subtle:"bg-indigo-50 text-indigo-600 dark:bg-indigo-900/30 dark:text-indigo-400"},teal:{solid:"bg-teal-600 text-white",soft:"bg-teal-100 text-teal-700 dark:bg-teal-900/50 dark:text-teal-300",outlined:"border border-teal-500 text-teal-600 dark:border-teal-400 dark:text-teal-400",subtle:"bg-teal-50 text-teal-600 dark:bg-teal-900/30 dark:text-teal-400"}},Y0={default:"bg-gray-500",primary:"bg-blue-500",success:"bg-green-500",warning:"bg-yellow-400",error:"bg-red-500",info:"bg-cyan-500",purple:"bg-purple-500",indigo:"bg-indigo-500",teal:"bg-teal-500"},j0={sm:"text-[10px] px-1.5 py-0.5 gap-1",md:"text-xs px-2 py-0.5 gap-1",lg:"text-sm px-2.5 py-1 gap-1.5"},q0={sm:"w-1.5 h-1.5",md:"w-1.5 h-1.5",lg:"w-2 h-2"},Z0={sm:"w-2.5 h-2.5",md:"w-3 h-3",lg:"w-3.5 h-3.5"};function ml({children:e,color:t="default",size:r="md",variant:o="soft",dot:n=false,icon:a,pill:s=true,className:l,...i}){return jsxs("span",{className:c("inline-flex items-center font-medium",j0[r],s?"rounded-full":"rounded",U0[t][o],l),...i,children:[n&&jsx("span",{className:c("shrink-0 rounded-full",q0[r],Y0[t]),"aria-hidden":"true"}),a&&!n&&jsx("span",{className:c("shrink-0",Z0[r]),"aria-hidden":"true",children:a}),e]})}ml.displayName="Badge";var ep=24,yo=2,tp=4,ua=6,rp=10,op=memo(function({bars:t}){return jsx("g",{children:t.map((r,o)=>jsxs("g",{children:[jsx("path",{d:r.d,fill:r.color}),r.label?jsx("text",{x:r.label.x,y:r.label.y,textAnchor:r.label.anchor,dominantBaseline:"middle",className:"fill-gray-600 text-[10px] [font-variant-numeric:tabular-nums] dark:fill-gray-300",children:r.label.text}):null]},`${r.key}-${o}`))})});function np({width:e,height:t,data:r,resolvedSeries:o,x:n,y:a,grid:s,size:l,orientation:i,stack:d,barSize:u,showValues:p,referenceLines:b,margin:m,tooltip:f,onPointClick:h,plotLabel:y,formatValue:C,formatRaw:v,formatX:E}){let[k,R]=useState(null),g=useMemo(()=>{let w=i==="vertical",N=o.filter(ge=>!ge.hidden),x=N.map(ge=>ge.key),S=d!=="none",I=da(r,x,d),F=to({width:e,height:t,data:r,x:n,y:a,bounds:S?ca(I):Xt(Fr(r,x)),margin:m,orientation:i,placement:"band",formatValue:C,formatX:E,defaultIncludeZero:true}),{valueScale:O,bandwidth:Z,categoryPositions:U,innerWidth:H,innerHeight:z}=F,$=O(0),K=Math.max(1,N.length),se=S?Z:Z/K,X=Math.min(u??ep,Math.max(1,se-(S?0:yo))),ee=S?X:K*X+(K-1)*yo,L=(Z-ee)/2,q=[];return I.forEach((ge,de)=>{let Y=-1,le=-1;ge.segments.forEach((te,Ne)=>{te.value!==null&&(te.end>=te.start?Y=Ne:le=Ne);});let xe=0,Se=0;ge.segments.forEach((te,Ne)=>{if(te.value===null)return;let De=N[Ne],Ve=te.end>=te.start,rt=O(S?te.start:0),dt=O(te.end),re=Math.min(rt,dt),pe=Math.abs(dt-rt),Ue=Ve?xe===0:Se===0,yt=w?!Ve:Ve;S&&!Ue&&pe>yo&&(pe-=yo,yt&&(re+=yo)),Ve?xe+=1:Se+=1;let Re=U[de]+(S?L:L+Ne*(X+yo)),ft=Ne===(Ve?Y:le)?w?Ve?"top":"bottom":Ve?"right":"left":"none",rr=w?{x:Re,y:re,width:X,height:pe}:{x:re,y:Re,width:pe,height:X},ot=null;if(p&&!S){let Wt=v(te.value),Nt=hn(Wt,10);if(w){let Ht=Ve?re:re+pe,or=K>1?X+yo:Z;Nt<=or&&Ht-ua>8&&(ot={x:Re+X/2,y:(Ve?re:re+pe)-ua,anchor:"middle",text:Wt});}else {let Ht=Ve?re+pe:re;Ht+ua+Nt<=H&&(ot={x:Ht+ua,y:Re+X/2,anchor:"start",text:Wt});}}q.push({key:De.key,color:De.color,d:cl({...rr,radius:tp,round:ft}),label:ot});});}),{vertical:w,visible:N,rows:I,stacked:S,xValues:F.xValues,categoryPositions:U,categoryCenters:F.categoryCenters,bandwidth:Z,categoryTicks:F.categoryTicks,valueTicks:F.valueTicks,valueScale:O,baseline:$,innerWidth:H,innerHeight:z,margin:F.margin,bars:q}},[r,o,n,a,e,t,m,i,d,u,p,C,v,E]),P=useCallback(w=>g.visible.map((N,x)=>{let S=St(r[w],N.key),I=g.rows[w].segments[x],F=S===null?"\u2014":d==="percent"?`${v(S)} (${C(I.end-I.start)})`:C(S);return {seriesKey:N.key,seriesLabel:Lt(N),color:N.color,value:S,formattedValue:F,datum:r[w]}}),[r,g.visible,g.rows,d,C,v]),T=useCallback(w=>{if(f===false||r.length===0)return;let N=w.currentTarget.getBoundingClientRect(),x=g.vertical?w.clientX-N.left-g.margin.left:w.clientY-N.top-g.margin.top,S=Vo(g.categoryCenters,x);R(S>=0?S:null);},[f,r.length,g.vertical,g.margin,g.categoryCenters]),D=useCallback(w=>{if(r.length===0)return;let N=r.length-1,x=k??0,S=g.vertical?"ArrowRight":"ArrowDown",I=g.vertical?"ArrowLeft":"ArrowUp",F=w.key===S?Math.min(N,x+1):w.key===I?Math.max(0,x-1):w.key==="Home"?0:w.key==="End"?N:w.key==="Escape"?null:void 0;F!==void 0&&(w.preventDefault(),R(F));},[r.length,k,g.vertical]),W=useCallback(()=>{if(!h||k===null)return;let[w]=P(k);w&&h({...w,index:k,x:g.xValues[k]});},[h,k,P,g.xValues]),V=k===null?null:P(k),_=k===null||V===null?null:{x:g.xValues[k],xLabel:E(g.xValues[k],k),index:k,points:V},M=k===null?null:g.vertical?{x:g.margin.left+g.categoryCenters[k],y:g.margin.top+Math.min(...g.rows[k].segments.filter(w=>w.value!==null).map(w=>g.valueScale(w.end)),g.baseline)}:{x:g.margin.left+Math.max(...g.rows[k].segments.filter(w=>w.value!==null).map(w=>g.valueScale(w.end)),g.baseline),y:g.margin.top+g.categoryCenters[k]};return jsxs(Fragment,{children:[jsxs("svg",{width:e,height:t,role:"img","aria-label":y??g.visible.map(w=>Lt(w)).join(", "),tabIndex:0,className:"touch-none focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-blue-500",onPointerMove:T,onPointerLeave:()=>R(null),onKeyDown:D,onBlur:()=>R(null),onClick:W,children:[jsxs("g",{transform:`translate(${g.margin.left}, ${g.margin.top})`,children:[jsx(Wr,{width:g.innerWidth,height:g.innerHeight,horizontal:g.vertical&&(s==="y"||s==="both")?g.valueTicks.map(w=>w.offset):void 0,vertical:!g.vertical&&(s==="y"||s==="both")?g.valueTicks.map(w=>w.offset):void 0}),k!==null?jsx("rect",{x:g.vertical?g.categoryPositions[k]:0,y:g.vertical?0:g.categoryPositions[k],width:g.vertical?g.bandwidth:g.innerWidth,height:g.vertical?g.innerHeight:g.bandwidth,className:"fill-gray-400 dark:fill-gray-500",opacity:.12,"aria-hidden":"true"}):null,jsx(op,{bars:g.bars}),jsx("line",{x1:g.vertical?0:g.baseline,y1:g.vertical?g.baseline:0,x2:g.vertical?g.innerWidth:g.baseline,y2:g.vertical?g.baseline:g.innerHeight,className:"stroke-gray-300 dark:stroke-gray-600",strokeWidth:1,shapeRendering:"crispEdges"}),b?.map(w=>{let N=g.valueScale(w.value),x=N<rp?N+12:N-4;return jsxs("g",{children:[jsx("line",{x1:g.vertical?0:N,y1:g.vertical?N:0,x2:g.vertical?g.innerWidth:N,y2:g.vertical?N:g.innerHeight,stroke:w.color??"var(--color-chart-muted)",strokeWidth:1,strokeDasharray:w.dashed===false?void 0:"4 4"}),w.label?jsx("text",{x:g.vertical?g.innerWidth:N+4,y:g.vertical?x:8,textAnchor:g.vertical?"end":"start",className:"fill-gray-500 text-[10px] dark:fill-gray-400",children:w.label}):null]},`${w.value}-${w.label??""}`)})]}),jsx("g",{transform:`translate(${g.margin.left}, ${g.margin.top+g.innerHeight})`,children:(g.vertical?n.hidden:a?.hidden)?null:jsx(Ut,{orientation:"bottom",ticks:g.vertical?g.categoryTicks:g.valueTicks,length:g.innerWidth,label:g.vertical?n.label:a?.label,size:l})}),jsx("g",{transform:`translate(${g.margin.left}, ${g.margin.top})`,children:(g.vertical?a?.hidden:n.hidden)?null:jsx(Ut,{orientation:"left",ticks:g.vertical?g.valueTicks:g.categoryTicks,length:g.innerHeight,showLine:false,label:g.vertical?a?.label:n.label,size:l})})]}),_&&M&&f!==false?jsx(ur,{x:M.x,y:M.y,containerWidth:e,children:typeof f=="function"?f(_):jsx(pr,{title:_.xLabel,points:_.points})}):null]})}function ap({data:e,series:t,x:r,y:o,height:n=260,width:a,size:s="md",grid:l="y",legend:i,tooltip:d=true,tableView:u=false,emphasis:p,title:b,description:m,loading:f=false,emptyState:h,onPointClick:y,orientation:C="vertical",stack:v="none",barSize:E,sort:k="none",showValues:R=false,referenceLines:g,legendToggle:P=true,margin:T,locale:D,plotLabel:W,className:V,..._}){let[M,w]=useState(()=>new Set),N=useMemo(()=>t.map((K,se)=>({...K,hidden:K.hidden||M.has(K.key),color:Cr(K,se,p)})),[t,M,p]),x=useMemo(()=>{if(k==="none")return e;let K=N.filter(X=>!X.hidden).map(X=>X.key),se=X=>K.reduce((ee,L)=>ee+(St(X,L)??0),0);return [...e].sort((X,ee)=>k==="asc"?se(X)-se(ee):se(ee)-se(X))},[e,k,N]),S=v==="percent",I=useMemo(()=>S?{domain:[0,100],...o}:o,[S,o]),F=useMemo(()=>K=>_t(K,D),[D]),O=useMemo(()=>o?.format??(S?K=>Br(K,{locale:D,alreadyScaled:true,maximumFractionDigits:0}):F),[o?.format,S,D,F]),Z=useMemo(()=>r.format??(K=>Gt(K,D)),[r.format,D]),U=useCallback(K=>{w(se=>{let X=new Set(se);return X.has(K)?X.delete(K):X.add(K),X});},[]),H=i===void 0?t.length>=2:i!==false,z=typeof i=="string"?i:"bottom",$=N.filter(K=>!K.hidden).length;return jsx(lr,{title:b,description:m,height:n,width:a,size:s,loading:f,empty:e.length===0||$===0,emptyState:h,tableView:u,legendPosition:z,legend:H?jsx(dr,{items:Hr(N,p),position:z,marker:"rect",size:s,onToggle:P?U:void 0}):void 0,table:u?jsx(cr,{data:x,series:N,xKey:r.key,xLabel:r.label??r.key,formatX:Z,formatValue:F,caption:typeof b=="string"?b:void 0}):void 0,className:V,..._,children:({width:K})=>jsx(np,{width:K,height:n,data:x,resolvedSeries:N,x:r,y:I,grid:l,size:s,orientation:C,stack:v,barSize:E,showValues:R,referenceLines:g,margin:T,tooltip:d,onPointClick:y,plotLabel:W,formatValue:O,formatRaw:F,formatX:Z})})}function bl({className:e}){return jsx("svg",{className:e,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",children:jsx("path",{d:"M13 16H12V12H11M12 8H12.01M21 12C21 16.97 16.97 21 12 21C7.03 21 3 16.97 3 12C3 7.03 7.03 3 12 3C16.97 3 21 7.03 21 12Z",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})})}function ip({className:e}){return jsx("svg",{className:e,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",children:jsx("path",{d:"M9 12L11 14L15 10M21 12C21 16.97 16.97 21 12 21C7.03 21 3 16.97 3 12C3 7.03 7.03 3 12 3C16.97 3 21 7.03 21 12Z",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})})}function lp({className:e}){return jsx("svg",{className:e,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",children:jsx("path",{d:"M12 9V13M12 17H12.01M10.29 3.86L1.82 18C1.65 18.3 1.55 18.65 1.55 18.99C1.55 19.34 1.64 19.69 1.81 19.99C1.99 20.29 2.24 20.55 2.54 20.72C2.84 20.901 3.18 20.99 3.53 21H20.47C20.82 20.99 21.16 20.901 21.46 20.72C21.76 20.55 22.01 20.29 22.19 19.99C22.36 19.69 22.449 19.34 22.448 18.99C22.447 18.65 22.35 18.3 22.18 18L13.71 3.86C13.53 3.57 13.28 3.32 12.98 3.15C12.68 2.99 12.34 2.9 12 2.9C11.66 2.9 11.32 2.99 11.02 3.15C10.72 3.32 10.47 3.57 10.29 3.86Z",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})})}function dp({className:e}){return jsx("svg",{className:e,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",children:jsx("path",{d:"M12 8V12M12 16H12.01M21 12C21 16.97 16.97 21 12 21C7.03 21 3 16.97 3 12C3 7.03 7.03 3 12 3C16.97 3 21 7.03 21 12Z",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})})}function Cs({className:e}){return jsx("svg",{className:e,viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",children:jsx("path",{d:"M4 4L12 12M12 4L4 12",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})})}var cp={info:bl,success:ip,warning:lp,error:dp,default:bl},up={info:"bg-blue-50 text-blue-800 border-blue-200 dark:bg-blue-900/20 dark:text-blue-300 dark:border-blue-800",success:"bg-green-50 text-green-800 border-green-200 dark:bg-green-900/20 dark:text-green-300 dark:border-green-800",warning:"bg-yellow-50 text-yellow-800 border-yellow-200 dark:bg-yellow-900/20 dark:text-yellow-300 dark:border-yellow-800",error:"bg-red-50 text-red-800 border-red-200 dark:bg-red-900/20 dark:text-red-300 dark:border-red-800",default:"bg-gray-50 text-gray-800 border-gray-200 dark:bg-gray-800 dark:text-gray-300 dark:border-gray-700"},pp={info:"text-blue-600 dark:text-blue-400",success:"text-green-600 dark:text-green-400",warning:"text-yellow-600 dark:text-yellow-400",error:"text-red-600 dark:text-red-400",default:"text-gray-600 dark:text-gray-400"};function gp({type:e="default",title:t,description:r,children:o,icon:n,action:a,closable:s=false,onClose:l,fullWidth:i=false,className:d,...u}){let[p,b]=useState(true);if(!p)return null;let m=()=>{b(false),l?.();},f=cp[e],h=o??r;return jsxs("div",{role:"alert",className:c("flex items-start gap-3 border px-4 py-3",i?"w-full":"rounded-lg",up[e],d),...u,children:[jsx("div",{className:c("shrink-0 mt-0.5",pp[e]),children:n??jsx(f,{className:"w-5 h-5"})}),jsxs("div",{className:"flex-1 min-w-0",children:[t&&jsx("div",{className:"font-semibold text-sm",children:t}),h&&jsx("div",{className:c("text-sm",t?"mt-1 opacity-90":false),children:h}),a&&jsx("div",{className:"mt-3",children:a})]}),s&&jsx("button",{type:"button",onClick:m,className:c("shrink-0 rounded-md p-1 transition-colors","hover:bg-black/10 dark:hover:bg-white/10","focus:outline-none focus-visible:ring-2 focus-visible:ring-offset-2 focus-visible:ring-current"),"aria-label":"Close banner",children:jsx(Cs,{className:"w-4 h-4"})})]})}function mp({title:e,description:t,children:r,action:o,backgroundImage:n,closable:a=false,onClose:s,fullWidth:l=false,className:i,...d}){let[u,p]=useState(true);if(!u)return null;let b=()=>{p(false),s?.();},m=r??t;return jsxs("div",{className:c("relative overflow-hidden bg-gray-900 text-white",l?"w-full":"rounded-xl","py-12 px-6 sm:px-12",i),style:n?{backgroundImage:`url(${n})`,backgroundSize:"cover",backgroundPosition:"center"}:void 0,...d,children:[n&&jsx("div",{className:"absolute inset-0 bg-black/50","aria-hidden":"true"}),jsxs("div",{className:"relative z-10 max-w-3xl mx-auto text-center",children:[e&&jsx("h2",{className:"text-2xl sm:text-3xl lg:text-4xl font-bold tracking-tight",children:e}),m&&jsx("div",{className:c("text-base sm:text-lg opacity-90",e?"mt-4":false),children:m}),o&&jsx("div",{className:"mt-6",children:o})]}),a&&jsx("button",{type:"button",onClick:b,className:c("absolute top-4 right-4 z-10 rounded-md p-1.5 text-white/80 transition-colors","hover:text-white hover:bg-white/10","focus:outline-none focus-visible:ring-2 focus-visible:ring-offset-2 focus-visible:ring-white"),"aria-label":"Close banner",children:jsx(Cs,{className:"w-5 h-5"})})]})}function fp({title:e,description:t,children:r,icon:o,action:n,badge:a,closable:s=false,onClose:l,fullWidth:i=false,className:d,...u}){let[p,b]=useState(true);if(!p)return null;let m=()=>{b(false),l?.();},f=r??t;return jsxs("div",{className:c("relative flex items-center gap-4 bg-linear-to-r from-indigo-600 to-purple-600 text-white px-4 py-3",i?"w-full":"rounded-lg",d),...u,children:[o&&jsx("div",{className:"shrink-0",children:o}),a&&jsx("span",{className:"shrink-0 inline-flex items-center rounded-full bg-white/20 px-2.5 py-0.5 text-xs font-semibold uppercase tracking-wide",children:a}),jsxs("div",{className:"flex-1 min-w-0 flex flex-wrap items-center gap-x-4 gap-y-1",children:[e&&jsx("span",{className:"font-semibold text-sm",children:e}),f&&jsx("span",{className:"text-sm opacity-90",children:f})]}),n&&jsx("div",{className:"shrink-0",children:n}),s&&jsx("button",{type:"button",onClick:m,className:c("shrink-0 rounded-md p-1 text-white/80 transition-colors","hover:text-white hover:bg-white/10","focus:outline-none focus-visible:ring-2 focus-visible:ring-offset-2 focus-visible:ring-white"),"aria-label":"Close banner",children:jsx(Cs,{className:"w-4 h-4"})})]})}function hl({variant:e="notification",...t}){switch(e){case "hero":return jsx(mp,{...t});case "promotion":return jsx(fp,{...t});default:return jsx(gp,{...t})}}hl.displayName="Banner";var bp={sm:"text-xs",md:"text-sm",lg:"text-base"};function hp({items:e,separator:t="/",size:r="md",maxItems:o,itemColor:n="text-gray-500 hover:text-gray-900 dark:text-gray-400 dark:hover:text-gray-100",activeColor:a="text-gray-700 font-medium dark:text-gray-200",separatorColor:s="text-gray-400 dark:text-gray-500",className:l,...i}){let d=e,u=false;if(o&&e.length>o){u=true;let p=e[0],b=e.slice(-(o-1));d=[p,...b];}return jsx("nav",{"aria-label":"Breadcrumb",className:c("inline-flex items-center",bp[r],l),...i,children:jsx("ol",{className:"inline-flex items-center space-x-1 md:space-x-2",children:d.map((p,b)=>{let m=b===d.length-1;return jsxs("li",{className:"inline-flex items-center",children:[u&&b===1&&jsxs(Fragment,{children:[jsx("span",{className:c("mx-1 select-none",s),children:"..."}),jsx("span",{className:c("mx-1 select-none",s),"aria-hidden":"true",children:t})]}),p.href||p.onClick?jsxs("a",{href:p.href,onClick:p.onClick,className:c("inline-flex items-center gap-1.5 transition-colors",m?a:n),"aria-current":m?"page":void 0,children:[p.icon&&jsx("span",{className:"inline-flex","aria-hidden":"true",children:p.icon}),jsx("span",{children:p.label})]}):jsxs("span",{className:c("inline-flex items-center gap-1.5",m?a:n),"aria-current":m?"page":void 0,children:[p.icon&&jsx("span",{className:"inline-flex","aria-hidden":"true",children:p.icon}),jsx("span",{children:p.label})]}),!m&&jsx("span",{className:c("mx-2 select-none",s),"aria-hidden":"true",children:t})]},p.href??p.label)})})})}function xp({className:e}){return jsxs("svg",{className:c("animate-spin",e),xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24","aria-hidden":"true",children:[jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),jsx("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"})]})}var vp={sm:"px-3 py-1.5 text-xs gap-1.5",md:"px-4 py-2 text-sm gap-2",lg:"px-5 py-2.5 text-base gap-2",xl:"px-6 py-3 text-lg gap-2.5"},kp={sm:"p-1.5",md:"p-2",lg:"p-2.5",xl:"p-3"},ga={sm:"h-3.5 w-3.5",md:"h-4 w-4",lg:"h-5 w-5",xl:"h-6 w-6"},wp={none:"rounded-none",sm:"rounded-sm",md:"rounded-md",lg:"rounded-lg",full:"rounded-full"};function gt({label:e,children:t,onClick:r,disabled:o=false,className:n,type:a="button",size:s="md",loading:l=false,leftIcon:i,rightIcon:d,icon:u,fullWidth:p=false,rounded:b="lg",bgColor:m="bg-blue-600 hover:bg-blue-700",textColor:f="text-white",focusColor:h="focus:ring-blue-300",selected:y=false,value:C,showFocusOnClick:v=false,...E}){let k=o||l,R=u!==void 0&&!t&&!e,g=c("inline-flex items-center justify-center font-medium transition-colors focus:outline-none disabled:opacity-50 disabled:cursor-not-allowed",v?"focus:ring-4":"focus-visible:ring-4"),P=c(y?"bg-blue-700 text-white ring-2 ring-blue-500":m,!y&&f,h&&v&&`focus:ring-4 ${h}`,h&&!v&&`focus-visible:ring-4 ${h}`);return jsx("button",{type:a,onClick:r,disabled:k,"data-value":C,className:c(g,R?kp[s]:vp[s],wp[b],P,p&&"w-full",n),...E,children:l?jsx(xp,{className:ga[s]}):R?jsx("span",{className:ga[s],children:u}):jsxs(Fragment,{children:[i&&jsx("span",{className:ga[s],children:i}),t??e,d&&jsx("span",{className:ga[s],children:d})]})})}function Go({children:e,orientation:t="horizontal",size:r,fullWidth:o=false,selectedValue:n,onChange:a,className:s}){let i=Ns__default.Children.toArray(e).filter(u=>Ns__default.isValidElement(u)&&typeof u.type!="string"),d=(u,p)=>b=>{u!==void 0&&a&&a(u),p&&p(b);};return jsx("div",{className:c("inline-flex",t==="horizontal"?"flex-row":"flex-col",o&&"w-full",s),role:"group",children:i.map((u,p)=>{let b=p===0,m=p===i.length-1,f=!b&&!m,h=u.props.value,y=n!==void 0&&h===n,C=c(t==="horizontal"&&b&&"rounded-r-none",t==="horizontal"&&m&&"rounded-l-none",t==="horizontal"&&f&&"rounded-none",t==="horizontal"&&!b&&"-ml-px",t==="vertical"&&b&&"rounded-b-none",t==="vertical"&&m&&"rounded-t-none",t==="vertical"&&f&&"rounded-none",t==="vertical"&&!b&&"-mt-px",o&&"flex-1");return Ns__default.cloneElement(u,{...u.props,size:r??u.props.size,selected:y||u.props.selected,onClick:d(h,u.props.onClick),className:c(C,u.props.className)})})})}var Rp=10080*60*1e3;function kt(e){return new Date(e.getFullYear(),e.getMonth(),e.getDate())}function wo(e){return new Date(e.getFullYear(),e.getMonth(),1)}function $r(e,t){return new Date(e.getFullYear(),e.getMonth(),e.getDate()+t)}function gr(e,t){return new Date(e.getFullYear(),e.getMonth()+t,1)}function Rs(e){return new Date(e.getFullYear(),e.getMonth()+1,0).getDate()}function Sr(e,t){return !e||!t?false:e.getFullYear()===t.getFullYear()&&e.getMonth()===t.getMonth()&&e.getDate()===t.getDate()}function Ss(e,t){return e.getFullYear()===t.getFullYear()&&e.getMonth()===t.getMonth()}function oo(e,t){return e.getFullYear()*12+e.getMonth()-(t.getFullYear()*12+t.getMonth())}function fa(e){let t=`${e.getMonth()+1}`.padStart(2,"0"),r=`${e.getDate()}`.padStart(2,"0");return `${e.getFullYear()}-${t}-${r}`}function Tp(e){let t=kt(e);t.setDate(t.getDate()-(t.getDay()+6)%7+3);let r=new Date(t.getFullYear(),0,4);return r.setDate(r.getDate()-(r.getDay()+6)%7+3),1+Math.round((t.getTime()-r.getTime())/Rp)}function vl(e,t,r){return t&&e<kt(t)?kt(t):r&&e>kt(r)?kt(r):e}function Pp(e,t,r){let o=wo(e),n=(o.getDay()-t+7)%7,a=$r(o,-n),s=r?6:Math.ceil((n+Rs(e))/7);return Array.from({length:s},(l,i)=>Array.from({length:7},(d,u)=>$r(a,i*7+u)))}function Ep({className:e}){return jsx("svg",{className:e,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24","aria-hidden":"true",children:jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M15 19l-7-7 7-7"})})}function Dp({className:e}){return jsx("svg",{className:e,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24","aria-hidden":"true",children:jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 5l7 7-7 7"})})}var Ip={sm:{day:"h-7 w-7 text-xs",head:"h-7 w-7 text-[10px]",caption:"text-xs",nav:"h-6 w-6",icon:"h-3 w-3",padding:"p-2",gap:"gap-3",footer:"text-xs",select:"text-xs py-0.5 pl-1 pr-5"},md:{day:"h-9 w-9 text-sm",head:"h-9 w-9 text-xs",caption:"text-sm",nav:"h-7 w-7",icon:"h-4 w-4",padding:"p-3",gap:"gap-4",footer:"text-sm",select:"text-sm py-1 pl-1.5 pr-6"},lg:{day:"h-11 w-11 text-base",head:"h-11 w-11 text-sm",caption:"text-base",nav:"h-9 w-9",icon:"h-5 w-5",padding:"p-4",gap:"gap-5",footer:"text-sm",select:"text-base py-1.5 pl-2 pr-7"}},Mp={primary:"bg-blue-600 text-white hover:bg-blue-700 dark:bg-blue-500 dark:hover:bg-blue-600",success:"bg-green-600 text-white hover:bg-green-700 dark:bg-green-500 dark:hover:bg-green-600",warning:"bg-yellow-500 text-white hover:bg-yellow-600 dark:bg-yellow-400 dark:text-gray-900 dark:hover:bg-yellow-500",error:"bg-red-600 text-white hover:bg-red-700 dark:bg-red-500 dark:hover:bg-red-600",info:"bg-cyan-600 text-white hover:bg-cyan-700 dark:bg-cyan-500 dark:hover:bg-cyan-600",neutral:"bg-gray-700 text-white hover:bg-gray-800 dark:bg-gray-500 dark:hover:bg-gray-400"},Lp={primary:"bg-blue-50 dark:bg-blue-900/30",success:"bg-green-50 dark:bg-green-900/30",warning:"bg-yellow-50 dark:bg-yellow-900/30",error:"bg-red-50 dark:bg-red-900/30",info:"bg-cyan-50 dark:bg-cyan-900/30",neutral:"bg-gray-100 dark:bg-gray-700/40"},Ap={primary:"text-blue-900 dark:text-blue-100",success:"text-green-900 dark:text-green-100",warning:"text-yellow-900 dark:text-yellow-100",error:"text-red-900 dark:text-red-100",info:"text-cyan-900 dark:text-cyan-100",neutral:"text-gray-900 dark:text-gray-100"},zp={primary:"font-semibold text-blue-600 dark:text-blue-400",success:"font-semibold text-green-600 dark:text-green-400",warning:"font-semibold text-yellow-600 dark:text-yellow-400",error:"font-semibold text-red-600 dark:text-red-400",info:"font-semibold text-cyan-600 dark:text-cyan-400",neutral:"font-semibold text-gray-900 dark:text-gray-100"},ko={primary:"focus-visible:ring-blue-500",success:"focus-visible:ring-green-500",warning:"focus-visible:ring-yellow-500",error:"focus-visible:ring-red-500",info:"focus-visible:ring-cyan-500",neutral:"focus-visible:ring-gray-500"};function ba(e,t){if(e==="multiple")return Array.isArray(t)?t.map(kt):[];if(e==="range"){let r=t??null;return {from:r?.from?kt(r.from):null,to:r?.to?kt(r.to):null}}return t instanceof Date?kt(t):null}function kl(e){return e?e instanceof Date?e:Array.isArray(e)?e[0]??null:e.from??e.to??null:null}function Wp(e){let{mode:t="single",value:r,defaultValue:o,onChange:n,max:a,month:s,defaultMonth:l,onMonthChange:i,numberOfMonths:d=1,weekStartsOn:u=0,locale:p,size:b="md",color:m="primary",minDate:f,maxDate:h,disabledDates:y,disabled:C=false,showOutsideDays:v=true,showWeekNumbers:E=false,fixedWeeks:k=false,captionLayout:R="label",fromYear:g,toYear:P,todayButton:T=false,clearButton:D=false,footer:W,bordered:V=true,renderDay:_,labels:M,className:w,...N}=e,x=Ip[b],S=Math.max(1,d),I=useMemo(()=>kt(new Date),[]),F=r!==void 0,[O,Z]=useState(()=>ba(t,o)),U=F?ba(t,r):O,H=s!==void 0,[z,$]=useState(()=>wo(l??kl(ba(t,o??r))??new Date)),K=H?wo(s):z,se=useCallback(fe=>{let he=wo(fe);H||$(he),i?.(he);},[H,i]),X=useRef(null),ee=useRef(false),[L,q]=useState(()=>{let fe=kl(ba(t,o??r)),he=wo(l??s??fe??new Date),j=fe&&Ss(fe,he)?fe:Ss(kt(new Date),he)?kt(new Date):he;return vl(j,f,h)}),ge=gr(K,S-1),Y=oo(L,K)>=0&&oo(L,ge)<=0?L:K;useEffect(()=>{if(!ee.current)return;ee.current=false,X.current?.querySelector(`[data-day="${fa(L)}"]:not([data-outside])`)?.focus();},[L,K]);let le=useCallback(fe=>{let he=vl(kt(fe),f,h);ee.current=true,q(he);let j=gr(K,S-1);oo(he,K)<0?se(he):oo(he,j)>0&&se(gr(he,-(S-1)));},[K,S,f,h,se]),xe=useCallback(fe=>C||f&&fe<kt(f)||h&&fe>kt(h)?true:typeof y=="function"?y(fe):Array.isArray(y)?y.some(he=>Sr(he,fe)):false,[C,f,h,y]),[Se,te]=useState(null),Ne=useCallback(fe=>{F||Z(fe),n?.(fe);},[F,n]),De=useCallback(fe=>{let he=kt(fe);if(xe(he))return;if(t==="multiple"){let J=U??[];if(J.some(ue=>Sr(ue,he))){Ne(J.filter(ue=>!Sr(ue,he)));return}if(a!==void 0&&J.length>=a)return;Ne([...J,he].sort((ue,Te)=>ue.getTime()-Te.getTime()));return}if(t==="range"){let J=U??{from:null,to:null};if(!J.from||J.to){Ne({from:he,to:null});return}Ne(he<J.from?{from:he,to:J.from}:{from:J.from,to:he});return}Ne(Sr(U,he)?null:he);},[t,U,a,Ne,xe]),Ve=useCallback(fe=>{De(fe),q(kt(fe)),oo(fe,K)<0?se(fe):oo(fe,gr(K,S-1))>0&&se(gr(fe,-(S-1)));},[De,K,S,se]),rt=!C&&(!f||oo(K,wo(f))>0),dt=!C&&(!h||oo(gr(K,S-1),wo(h))<0),re=useCallback(()=>{se(gr(K,-1));},[K,se]),pe=useCallback(()=>{se(gr(K,1));},[K,se]),Ue=useCallback(fe=>{if(C)return;let he=L;switch(fe.key){case "ArrowLeft":fe.preventDefault(),le($r(he,-1));break;case "ArrowRight":fe.preventDefault(),le($r(he,1));break;case "ArrowUp":fe.preventDefault(),le($r(he,-7));break;case "ArrowDown":fe.preventDefault(),le($r(he,7));break;case "Home":fe.preventDefault(),le($r(he,-((he.getDay()-u+7)%7)));break;case "End":fe.preventDefault(),le($r(he,6-(he.getDay()-u+7)%7));break;case "PageUp":{fe.preventDefault();let j=fe.shiftKey?-12:-1,J=gr(he,j),me=Math.min(he.getDate(),Rs(J));le(new Date(J.getFullYear(),J.getMonth(),me));break}case "PageDown":{fe.preventDefault();let j=fe.shiftKey?12:1,J=gr(he,j),me=Math.min(he.getDate(),Rs(J));le(new Date(J.getFullYear(),J.getMonth(),me));break}}},[C,L,le,u]),yt=useMemo(()=>{let fe=new Intl.DateTimeFormat(p,{weekday:"short"}),he=new Intl.DateTimeFormat(p,{weekday:"long"}),j=new Date(2024,0,7);return Array.from({length:7},(J,me)=>{let ue=$r(j,(u+me)%7);return {short:fe.format(ue),long:he.format(ue)}})},[p,u]),Re=useMemo(()=>{let fe=new Intl.DateTimeFormat(p,{month:"long"});return Array.from({length:12},(he,j)=>fe.format(new Date(2024,j,1)))},[p]),We=useMemo(()=>new Intl.DateTimeFormat(p,{month:"long",year:"numeric"}),[p]),ft=useMemo(()=>new Intl.DateTimeFormat(p,{dateStyle:"full"}),[p]),rr=useMemo(()=>{if(R!=="dropdown")return [];let fe=I.getFullYear(),he=g??f?.getFullYear()??fe-100,j=P??h?.getFullYear()??fe+10;return j<he?[he]:Array.from({length:j-he+1},(J,me)=>he+me)},[R,g,P,f,h,I]),ot=t==="range"?U:null,Wt=ot&&ot.from&&!ot.to&&Se&&Se>ot.from?Se:null,Nt=ot?.to??Wt,Ht=useCallback((fe,he)=>{let j=!Ss(fe,he),J=xe(fe),me=false,ue=false,Te=false,ve=false;return t==="multiple"?me=(U??[]).some(we=>Sr(we,fe)):t==="range"?(ue=Sr(ot?.from,fe),Te=Sr(Nt,fe),me=ue||Te,ve=!!(ot?.from&&Nt&&fe>ot.from&&fe<Nt)):me=Sr(U,fe),{selected:me,today:Sr(fe,I),outside:j,disabled:J,rangeStart:ue,rangeEnd:Te,inRange:ve}},[t,U,ot,Nt,xe,I]),or=fe=>{let he=gr(K,fe),j=Pp(he,u,k),J=fe===0,me=fe===S-1;return jsxs("div",{className:"flex flex-col",children:[jsxs("div",{className:"mb-2 flex items-center justify-between",children:[jsx("button",{type:"button",onClick:re,disabled:!rt,"aria-label":M?.previousMonth??"Previous month",className:c("inline-flex items-center justify-center rounded-md transition-colors","text-gray-600 hover:bg-gray-100 dark:text-gray-300 dark:hover:bg-gray-700","focus:outline-none focus-visible:ring-2 focus-visible:ring-offset-1 dark:focus-visible:ring-offset-gray-900",ko[m],x.nav,!rt&&"cursor-not-allowed opacity-40 hover:bg-transparent dark:hover:bg-transparent",!J&&"invisible"),children:jsx(Ep,{className:x.icon})}),R==="dropdown"?jsxs("div",{className:"flex items-center gap-1",children:[jsx("select",{"aria-label":M?.monthSelect??"Month",value:he.getMonth(),disabled:C,onChange:ue=>se(new Date(he.getFullYear(),Number(ue.target.value)-fe,1)),className:c("rounded-md border border-gray-300 bg-white font-medium text-gray-900","dark:border-gray-600 dark:bg-gray-800 dark:text-gray-100","focus:outline-none focus-visible:ring-2",ko[m],x.select,C&&"cursor-not-allowed opacity-50"),children:Re.map((ue,Te)=>jsx("option",{value:Te,children:ue},ue))}),jsx("select",{"aria-label":M?.yearSelect??"Year",value:he.getFullYear(),disabled:C,onChange:ue=>se(new Date(Number(ue.target.value),he.getMonth()-fe,1)),className:c("rounded-md border border-gray-300 bg-white font-medium text-gray-900","dark:border-gray-600 dark:bg-gray-800 dark:text-gray-100","focus:outline-none focus-visible:ring-2",ko[m],x.select,C&&"cursor-not-allowed opacity-50"),children:rr.map(ue=>jsx("option",{value:ue,children:ue},ue))})]}):jsx("div",{"aria-live":"polite",className:c("font-semibold text-gray-900 dark:text-gray-100",x.caption),children:We.format(he)}),jsx("button",{type:"button",onClick:pe,disabled:!dt,"aria-label":M?.nextMonth??"Next month",className:c("inline-flex items-center justify-center rounded-md transition-colors","text-gray-600 hover:bg-gray-100 dark:text-gray-300 dark:hover:bg-gray-700","focus:outline-none focus-visible:ring-2 focus-visible:ring-offset-1 dark:focus-visible:ring-offset-gray-900",ko[m],x.nav,!dt&&"cursor-not-allowed opacity-40 hover:bg-transparent dark:hover:bg-transparent",!me&&"invisible"),children:jsx(Dp,{className:x.icon})})]}),jsxs("table",{role:"grid","aria-label":We.format(he),className:"border-collapse",children:[jsx("thead",{children:jsxs("tr",{children:[E&&jsxs("th",{scope:"col",className:c("font-normal text-gray-400 dark:text-gray-500",x.head),children:[jsx("span",{className:"sr-only",children:M?.weekNumber??"Week number"}),jsx("span",{"aria-hidden":"true",children:"#"})]}),yt.map(ue=>jsx("th",{scope:"col",abbr:ue.long,className:c("font-medium uppercase text-gray-500 dark:text-gray-400",x.head),children:ue.short},ue.long))]})}),jsx("tbody",{children:j.map(ue=>jsxs("tr",{children:[E&&jsx("td",{className:c("text-center align-middle text-gray-400 dark:text-gray-500",x.head),children:Tp(ue[0])}),ue.map(Te=>{let ve=Ht(Te,he),we=fa(Te);if(ve.outside&&!v)return jsx("td",{className:"p-0"},we);let He=Sr(Te,Y)&&!ve.outside,Me=ve.inRange||ve.rangeStart&&!!Nt||ve.rangeEnd&&!!ot?.from;return jsx("td",{role:"presentation",className:c("p-0",Me&&Lp[m],Me&&ve.rangeStart&&"rounded-l-full",Me&&ve.rangeEnd&&"rounded-r-full"),children:jsx("button",{type:"button","data-day":we,"data-selected":ve.selected||void 0,"data-today":ve.today||void 0,"data-outside":ve.outside||void 0,role:"gridcell",tabIndex:He?0:-1,disabled:C,"aria-selected":ve.selected,"aria-disabled":ve.disabled||void 0,"aria-current":ve.today?"date":void 0,"aria-label":ft.format(Te),onClick:()=>{ve.disabled||Ve(Te);},onMouseEnter:()=>t==="range"&&te(kt(Te)),onMouseLeave:()=>t==="range"&&te(null),onFocus:()=>q(kt(Te)),className:c("inline-flex items-center justify-center rounded-full transition-colors","focus:outline-none focus-visible:ring-2 focus-visible:ring-offset-1 dark:focus-visible:ring-offset-gray-900",ko[m],x.day,ve.selected?Mp[m]:ve.inRange?c(Ap[m],"hover:bg-gray-200/60 dark:hover:bg-gray-600/60"):ve.today?c(zp[m],"hover:bg-gray-100 dark:hover:bg-gray-700"):c("text-gray-900 dark:text-gray-100","hover:bg-gray-100 dark:hover:bg-gray-700"),ve.outside&&!ve.selected&&"text-gray-400 dark:text-gray-500",ve.disabled&&"cursor-not-allowed opacity-40 hover:bg-transparent dark:hover:bg-transparent"),children:_?_(Te,ve):Te.getDate()})},we)})]},fa(ue[0])))})]})]},fa(he))},Zt=useCallback(()=>{se(I),q(I),xe(I)||De(I);},[I,se,xe,De]),Ar=useCallback(()=>{Ne(t==="multiple"?[]:t==="range"?{from:null,to:null}:null);},[t,Ne]),br=!!W||T||D;return jsxs("div",{ref:X,onKeyDown:Ue,className:c("inline-block bg-white dark:bg-gray-900",V&&"rounded-lg border border-gray-200 shadow-sm dark:border-gray-700",x.padding,C&&"opacity-60",w),...N,children:[jsx("div",{className:c("flex flex-wrap",x.gap),children:Array.from({length:S},(fe,he)=>or(he))}),br&&jsxs("div",{className:c("mt-3 flex items-center justify-between gap-2 border-t border-gray-200 pt-3 dark:border-gray-700",x.footer),children:[jsx("div",{className:"text-gray-600 dark:text-gray-400",children:W}),(T||D)&&jsxs("div",{className:"flex items-center gap-2",children:[T&&jsx("button",{type:"button",onClick:Zt,disabled:C,className:c("rounded-md px-2 py-1 font-medium transition-colors","text-gray-700 hover:bg-gray-100 dark:text-gray-300 dark:hover:bg-gray-700","focus:outline-none focus-visible:ring-2",ko[m],C&&"cursor-not-allowed opacity-50"),children:M?.today??"Today"}),D&&jsx("button",{type:"button",onClick:Ar,disabled:C,className:c("rounded-md px-2 py-1 font-medium transition-colors","text-gray-700 hover:bg-gray-100 dark:text-gray-300 dark:hover:bg-gray-700","focus:outline-none focus-visible:ring-2",ko[m],C&&"cursor-not-allowed opacity-50"),children:M?.clear??"Clear"})]})]})]})}function Hp(e,t,r){let o=r||"bg-white dark:bg-gray-800",n=t||"border-gray-200 dark:border-gray-700";switch(e){case "outlined":return c("border-2 bg-transparent",n);case "elevated":return c("shadow-lg border-0",o);case "filled":return c(r||"bg-gray-100 dark:bg-gray-700","border-0");default:return c("border",n,o)}}function Fp(e){switch(e){case "sm":return "max-w-sm";case "lg":return "max-w-2xl";default:return "max-w-md"}}function Bp(e){switch(e){case "none":return "rounded-none";case "sm":return "rounded-sm";case "md":return "rounded-md";case "xl":return "rounded-xl";case "full":return "rounded-3xl";default:return "rounded-lg"}}function Vp(e){switch(e){case "none":return "";case "sm":return "p-2";case "lg":return "p-6";default:return ""}}function wl({variant:e="default",size:t="md",rounded:r="lg",padding:o="none",bgColor:n,borderColor:a,shadowColor:s,hoverable:l=false,clickable:i=false,as:d="div",className:u,children:p,onClick:b,...m}){let f=d,h=l?"transition-all duration-200 hover:shadow-lg hover:-translate-y-0.5":"",y=i?"cursor-pointer active:scale-[0.98] transition-transform":"",C=s||"";return jsx(f,{className:c("overflow-hidden",Hp(e,a,n),Fp(t),Bp(r),Vp(o),h,y,C,u),onClick:i||b?b:void 0,...m,children:p})}wl.displayName="Card";function $p(e){switch(e){case "none":return "p-0";case "sm":return "px-3 py-2";case "lg":return "px-6 py-5";default:return "px-4 py-4"}}function Nl({actions:e,divider:t=false,padding:r="md",className:o,children:n,...a}){return jsxs("div",{className:c("flex items-center justify-between",$p(r),t&&"border-b border-gray-200 dark:border-gray-700",o),...a,children:[jsx("div",{className:"flex-1",children:n}),e&&jsx("div",{className:"flex items-center gap-2 ml-4",children:e})]})}Nl.displayName="CardHeader";function Gp(e){switch(e){case "none":return "p-0";case "sm":return "px-3 py-2";case "lg":return "px-6 py-5";default:return "px-4 py-4"}}function Sl({padding:e="md",className:t,children:r,...o}){return jsx("div",{className:c(Gp(e),t),...o,children:r})}Sl.displayName="CardBody";function Kp(e){switch(e){case "none":return "p-0";case "sm":return "px-3 py-2";case "lg":return "px-6 py-5";default:return "px-4 py-4"}}function Up(e){switch(e){case "center":return "justify-center";case "right":return "justify-end";case "between":return "justify-between";default:return "justify-start"}}function Rl({divider:e=false,align:t="left",padding:r="md",className:o,children:n,...a}){return jsx("div",{className:c("flex items-center gap-2",Kp(r),Up(t),e&&"border-t border-gray-200 dark:border-gray-700",o),...a,children:n})}Rl.displayName="CardFooter";function jp(e){switch(e){case "square":return "aspect-square";case "video":return "aspect-video";case "wide":return "aspect-[21/9]";default:return ""}}function qp(e){switch(e){case "contain":return "object-contain";case "fill":return "object-fill";case "none":return "object-none";default:return "object-cover"}}function Tl({position:e="top",aspectRatio:t="auto",objectFit:r="cover",src:o,alt:n,className:a,...s}){let l=e==="top"?"rounded-t-lg":"rounded-b-lg";return jsx("img",{src:o,alt:n,className:c("w-full",jp(t),qp(r),l,a),...s})}Tl.displayName="CardImage";function Jp(e){switch(e){case "sm":return "text-base font-medium";case "lg":return "text-2xl font-bold";default:return "text-xl font-semibold"}}function Pl({as:e="h3",size:t="md",className:r,children:o,...n}){return jsx(e,{className:c("text-gray-900 dark:text-white",Jp(t),r),...n,children:o})}Pl.displayName="CardTitle";function eg(e){switch(e){case "sm":return "text-xs";case "lg":return "text-base";default:return "text-sm"}}function El({size:e="md",className:t,children:r,...o}){return jsx("p",{className:c("text-gray-500 dark:text-gray-400",eg(e),t),...o,children:r})}El.displayName="CardDescription";var ig=e=>{switch(e){case "sm":return {checkbox:"w-4 h-4",label:"text-xs",description:"text-xs"};case "lg":return {checkbox:"w-6 h-6",label:"text-base",description:"text-sm"};default:return {checkbox:"w-5 h-5",label:"text-sm",description:"text-xs"}}},lg=e=>{switch(e){case "circle":return "rounded-full";case "rounded":return "rounded-md";default:return "rounded"}},dg=({className:e})=>jsx("svg",{className:e,viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:jsx("path",{d:"M13.5 4.5L6 12L2.5 8.5",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round"})}),cg=({className:e})=>jsx("svg",{className:e,viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:jsx("path",{d:"M3 8H13",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round"})}),Rn=forwardRef(({checked:e,defaultChecked:t=false,onChange:r,disabled:o=false,readOnly:n=false,required:a=false,name:s,value:l,id:i,label:d,description:u,error:p=false,size:b="md",labelPosition:m="right",checkedColor:f="bg-blue-600",uncheckedColor:h="bg-white dark:bg-gray-800",borderColor:y="border-gray-300 dark:border-gray-600",labelColor:C,errorColor:v="text-red-500",checkmarkColor:E="text-white",hoverColor:k,focusRingColor:R="ring-blue-500",indeterminate:g=false,icon:P,variant:T="default",shape:D="square",animation:W=true,showFocusRing:V=true,className:_,containerClassName:M,style:w,tabIndex:N,...x},S)=>{let I=useId(),F=i||I,O=`${F}-error`,Z=`${F}-description`,[U,H]=useState(t),z=e!==void 0,$=z?e:U,K=useRef(null);useEffect(()=>{K.current&&(K.current.indeterminate=g);},[g]);let se=de=>{if(o||n)return;let Y=de.target.checked;z||H(Y),r?.(Y,de);},X=ig(b),ee=lg(D),L=()=>{let de=c("relative flex items-center justify-center border-2 transition-all",X.checkbox,ee,W&&"duration-200 ease-in-out");return o?c(de,"opacity-50 cursor-not-allowed",$||g?f:h,y):T==="filled"?c(de,$||g?f:"bg-gray-100 dark:bg-gray-700",$||g?"border-transparent":y,k&&!n&&`hover:${k}`,"cursor-pointer"):T==="outlined"?c(de,h,$||g?`border-current ${f.replace("bg-","text-")}`:y,"border-2",k&&!n&&`hover:${k}`,"cursor-pointer"):c(de,$||g?f:h,$||g?"border-transparent":y,k&&!n&&`hover:${k}`,"cursor-pointer")},q=p!==false,ge=typeof p=="string"?p:void 0;return jsxs("div",{className:c("inline-flex flex-col",M),children:[jsxs("label",{htmlFor:F,className:c("inline-flex items-start gap-2",o?"cursor-not-allowed":"cursor-pointer",m==="left"&&"flex-row-reverse justify-end"),children:[jsx("input",{ref:de=>{K&&(K.current=de),typeof S=="function"?S(de):S&&(S.current=de);},type:"checkbox",id:F,name:s,value:l,checked:$,onChange:se,disabled:o,readOnly:n,required:a,tabIndex:n?-1:N,"aria-invalid":q,"aria-describedby":c(ge&&O,u&&Z),className:"sr-only peer",style:w,...x}),jsx("span",{className:c(L(),V&&`peer-focus-visible:ring-2 peer-focus-visible:ring-offset-2 peer-focus-visible:${R}`,W&&$&&"scale-100",q&&"border-red-500"),"aria-hidden":"true",children:($||g)&&jsx("span",{className:c(E,W&&"animate-in zoom-in-50 duration-200"),children:g?P||jsx(cg,{className:"w-full h-full"}):P||jsx(dg,{className:"w-full h-full"})})}),d&&jsxs("span",{className:"flex flex-col gap-1",children:[jsxs("span",{className:c(X.label,o&&"opacity-50",C,q&&v),children:[d,a&&jsx("span",{className:"text-red-500 ml-1",children:"*"})]}),u&&jsx("span",{id:Z,className:c(X.description,"text-gray-500 dark:text-gray-400",o&&"opacity-50"),children:u})]})]}),ge&&jsx("p",{id:O,className:c("mt-1 text-xs",v),children:ge})]})});Rn.displayName="Checkbox";var Dl=createContext(null),Il=({label:e,description:t,value:r,defaultValue:o=[],onChange:n,orientation:a="vertical",spacing:s="md",disabled:l=false,size:i="md",error:d=false,required:u=false,children:p,className:b,labelClassName:m,...f})=>{let[h,y]=Ns.useState(o),C=r!==void 0,v=C?r:h,E=Ns.useCallback(T=>{let D=v.includes(T)?v.filter(W=>W!==T):[...v,T];C||y(D),n?.(D);},[v,C,n]),k=Ns.useMemo(()=>({value:v,onChange:E,disabled:l,size:i}),[v,E,l,i]),R={sm:a==="vertical"?"gap-2":"gap-3",md:a==="vertical"?"gap-3":"gap-4",lg:a==="vertical"?"gap-4":"gap-6"},g=d!==false,P=typeof d=="string"?d:void 0;return jsxs("div",{className:c("flex flex-col gap-2",b),...f,children:[(e||t)&&jsxs("div",{className:"flex flex-col gap-1",children:[e&&jsxs("label",{className:c("text-sm font-medium text-gray-900 dark:text-gray-100",l&&"opacity-50",g&&"text-red-500",m),children:[e,u&&jsx("span",{className:"text-red-500 ml-1",children:"*"})]}),t&&jsx("p",{className:c("text-xs text-gray-500 dark:text-gray-400",l&&"opacity-50"),children:t})]}),jsx(Dl.Provider,{value:k,children:jsx("div",{className:c("flex",a==="vertical"?"flex-col":"flex-row flex-wrap",R[s]),role:"group",children:p})}),P&&jsx("p",{className:"text-xs text-red-500",children:P})]})};Il.displayName="CheckboxGroup";var Ml=({value:e,disabled:t,size:r,...o})=>{let n=useContext(Dl);if(!n)return console.warn("CheckboxGroupItem doit \xEAtre utilis\xE9 dans un CheckboxGroup"),jsx(Rn,{...o,disabled:t,size:r});let{value:a,onChange:s,disabled:l,size:i}=n,d=a.includes(e);return jsx(Rn,{...o,checked:d,onChange:()=>s(e),disabled:l||t,size:r||i})};Ml.displayName="CheckboxGroupItem";var At={compact:"px-3 py-1.5",default:"px-4 py-3",comfortable:"px-6 py-4"},xa={compact:"text-xs",default:"text-sm",comfortable:"text-base"},bg=()=>jsx("svg",{className:"w-3.5 h-3.5",viewBox:"0 0 16 16",fill:"currentColor",children:jsx("path",{d:"M8 3l4 5H4l4-5z"})}),hg=()=>jsx("svg",{className:"w-3.5 h-3.5",viewBox:"0 0 16 16",fill:"currentColor",children:jsx("path",{d:"M8 13l4-5H4l4 5z"})}),yg=()=>jsx("svg",{className:"w-3.5 h-3.5 opacity-30",viewBox:"0 0 16 16",fill:"currentColor",children:jsx("path",{d:"M8 3l3 4H5l3-4zM8 13l3-4H5l3 4z"})}),Ll=({className:e})=>jsx("svg",{className:c("w-4 h-4",e),viewBox:"0 0 20 20",fill:"currentColor",children:jsx("path",{fillRule:"evenodd",d:"M5.23 7.21a.75.75 0 011.06.02L10 11.168l3.71-3.938a.75.75 0 111.08 1.04l-4.25 4.5a.75.75 0 01-1.08 0l-4.25-4.5a.75.75 0 01.02-1.06z",clipRule:"evenodd"})}),xg=()=>jsx("svg",{className:"w-4 h-4 text-gray-400",viewBox:"0 0 20 20",fill:"currentColor",children:jsx("path",{fillRule:"evenodd",d:"M9 3.5a5.5 5.5 0 100 11 5.5 5.5 0 000-11zM2 9a7 7 0 1112.452 4.391l3.328 3.329a.75.75 0 11-1.06 1.06l-3.329-3.328A7 7 0 012 9z",clipRule:"evenodd"})}),vg=()=>jsx("svg",{className:"w-4 h-4 text-gray-400",viewBox:"0 0 20 20",fill:"currentColor",children:jsx("path",{d:"M7 4a1.5 1.5 0 110-3 1.5 1.5 0 010 3zm6 0a1.5 1.5 0 110-3 1.5 1.5 0 010 3zM7 10.5a1.5 1.5 0 110-3 1.5 1.5 0 010 3zm6 0a1.5 1.5 0 110-3 1.5 1.5 0 010 3zM7 17a1.5 1.5 0 110-3 1.5 1.5 0 010 3zm6 0a1.5 1.5 0 110-3 1.5 1.5 0 010 3z"})}),kg=()=>jsx("svg",{className:"w-3.5 h-3.5",viewBox:"0 0 20 20",fill:"currentColor",children:jsx("path",{fillRule:"evenodd",d:"M2.628 1.601C5.028 1.206 7.49 1 10 1s4.973.206 7.372.601a.75.75 0 01.628.74v2.288a2.25 2.25 0 01-.659 1.59l-4.682 4.683a2.25 2.25 0 00-.659 1.59v3.037c0 .684-.31 1.33-.844 1.757l-1.937 1.55A.75.75 0 018 18.25v-5.757a2.25 2.25 0 00-.659-1.591L2.659 6.22A2.25 2.25 0 012 4.629V2.34a.75.75 0 01.628-.74z",clipRule:"evenodd"})}),wg=()=>jsxs("svg",{className:"w-4 h-4",viewBox:"0 0 20 20",fill:"currentColor",children:[jsx("path",{d:"M10.75 2.75a.75.75 0 00-1.5 0v8.614L6.295 8.235a.75.75 0 10-1.09 1.03l4.25 4.5a.75.75 0 001.09 0l4.25-4.5a.75.75 0 00-1.09-1.03l-2.955 3.129V2.75z"}),jsx("path",{d:"M3.5 12.75a.75.75 0 00-1.5 0v2.5A2.75 2.75 0 004.75 18h10.5A2.75 2.75 0 0018 15.25v-2.5a.75.75 0 00-1.5 0v2.5c0 .69-.56 1.25-1.25 1.25H4.75c-.69 0-1.25-.56-1.25-1.25v-2.5z"})]}),Cg=()=>jsx("svg",{className:"w-4 h-4",viewBox:"0 0 20 20",fill:"currentColor",children:jsx("path",{fillRule:"evenodd",d:"M2.5 3A1.5 1.5 0 001 4.5v11A1.5 1.5 0 002.5 17h15a1.5 1.5 0 001.5-1.5v-11A1.5 1.5 0 0017.5 3h-15zM2.5 4.5h6v11h-6v-11zm7.5 0h7.5v11H10v-11z",clipRule:"evenodd"})});function ya(e,t,r){return typeof r=="function"?r(e,t):String(typeof r=="string"?e[r]:t)}function Tr(e,t){return e[t]}function Ng(e,t){return e==null&&t==null?0:e==null?-1:t==null?1:typeof e=="number"&&typeof t=="number"?e-t:String(e).localeCompare(String(t))}function Sg(e,t){let r=String(e??"").toLowerCase(),o=t.value.toLowerCase();switch(t.operator){case "contains":return r.includes(o);case "equals":return r===o;case "startsWith":return r.startsWith(o);case "endsWith":return r.endsWith(o);case "gt":return Number(e)>Number(t.value);case "gte":return Number(e)>=Number(t.value);case "lt":return Number(e)<Number(t.value);case "lte":return Number(e)<=Number(t.value);case "isEmpty":return r==="";case "isNotEmpty":return r!=="";default:return true}}function Al(e,t,r){let o=[];for(let n of e){let a=Number(Tr(n,t));isNaN(a)||o.push(a);}if(o.length===0)return 0;switch(r){case "sum":return o.reduce((n,a)=>n+a,0);case "avg":return o.reduce((n,a)=>n+a,0)/o.length;case "count":return o.length;case "min":return Math.min(...o);case "max":return Math.max(...o)}}function Rg({cols:e,density:t}){return jsx("tr",{className:"border-b border-gray-200 dark:border-gray-700",children:Array.from({length:e}).map((r,o)=>jsx("td",{className:At[t],children:jsx("div",{className:"h-4 bg-gray-200 dark:bg-gray-700 rounded animate-pulse"})},o))})}function Tg({column:e,value:t,onApply:r,onClear:o}){let[n,a]=useState(false),[s,l]=useState(t?.operator??"contains"),[i,d]=useState(t?.value??""),u=useRef(null),p=e.filterType??"text",b=p==="number"?[{value:"equals",label:"Equals"},{value:"gt",label:"Greater than"},{value:"gte",label:"Greater or equal"},{value:"lt",label:"Less than"},{value:"lte",label:"Less or equal"}]:[{value:"contains",label:"Contains"},{value:"equals",label:"Equals"},{value:"startsWith",label:"Starts with"},{value:"endsWith",label:"Ends with"},{value:"isEmpty",label:"Is empty"},{value:"isNotEmpty",label:"Is not empty"}];return useEffect(()=>{let m=f=>{u.current&&!u.current.contains(f.target)&&a(false);};return n&&document.addEventListener("mousedown",m),()=>document.removeEventListener("mousedown",m)},[n]),jsxs("div",{className:"relative inline-block",ref:u,children:[jsx("button",{type:"button",onClick:m=>{m.stopPropagation(),a(!n);},className:c("p-0.5 rounded hover:bg-gray-200 dark:hover:bg-gray-600 cursor-pointer",t&&"text-blue-600 dark:text-blue-400"),"aria-label":`Filter ${String(e.header)}`,children:jsx(kg,{})}),n&&jsx("div",{className:"absolute z-50 top-full left-0 mt-1 bg-white dark:bg-gray-800 border border-gray-200 dark:border-gray-700 rounded-lg shadow-lg p-3 min-w-[220px]",children:p==="select"&&e.filterOptions?jsxs("div",{className:"flex flex-col gap-1.5",children:[e.filterOptions.map(m=>jsxs("label",{className:"flex items-center gap-2 text-sm cursor-pointer",children:[jsx("input",{type:"radio",name:`filter-${e.key}`,value:m,checked:i===m,onChange:()=>d(m),className:"cursor-pointer"}),jsx("span",{className:"text-gray-700 dark:text-gray-300",children:m})]},m)),jsxs("div",{className:"flex gap-2 mt-2",children:[jsx("button",{type:"button",onClick:()=>{r({column:e.key,operator:"equals",value:i}),a(false);},className:"px-2 py-1 text-xs bg-blue-600 text-white rounded hover:bg-blue-700 cursor-pointer",children:"Apply"}),jsx("button",{type:"button",onClick:()=>{d(""),o(),a(false);},className:"px-2 py-1 text-xs text-gray-600 dark:text-gray-400 hover:text-gray-800 dark:hover:text-gray-200 cursor-pointer",children:"Clear"})]})]}):jsxs("div",{className:"flex flex-col gap-2",children:[jsx("select",{value:s,onChange:m=>l(m.target.value),className:"text-xs border border-gray-300 dark:border-gray-600 rounded px-2 py-1 bg-white dark:bg-gray-700 text-gray-700 dark:text-gray-200",children:b.map(m=>jsx("option",{value:m.value,children:m.label},m.value))}),s!=="isEmpty"&&s!=="isNotEmpty"&&jsx("input",{type:p==="number"?"number":p==="date"?"date":"text",value:i,onChange:m=>d(m.target.value),placeholder:"Filter value...",className:"text-xs border border-gray-300 dark:border-gray-600 rounded px-2 py-1 bg-white dark:bg-gray-700 text-gray-700 dark:text-gray-200",autoFocus:true,"aria-label":`Filter ${String(e.header)} value`}),jsxs("div",{className:"flex gap-2",children:[jsx("button",{type:"button",onClick:()=>{r({column:e.key,operator:s,value:i}),a(false);},className:"px-2 py-1 text-xs bg-blue-600 text-white rounded hover:bg-blue-700 cursor-pointer",children:"Apply"}),jsx("button",{type:"button",onClick:()=>{d(""),o(),a(false);},className:"px-2 py-1 text-xs text-gray-600 dark:text-gray-400 hover:text-gray-800 dark:hover:text-gray-200 cursor-pointer",children:"Clear"})]})]})})]})}function Pg({value:e,onSave:t,density:r}){let[o,n]=useState(false),[a,s]=useState(String(e??"")),l=useRef(null);if(useEffect(()=>{o&&l.current&&(l.current.focus(),l.current.select());},[o]),!o)return jsx("div",{onDoubleClick:()=>{s(String(e??"")),n(true);},className:"cursor-text min-h-[1.5em]",title:"Double-click to edit",children:String(e??"")});let i=()=>{n(false),a!==String(e??"")&&t(a);};return jsx("input",{ref:l,type:"text",value:a,onChange:d=>s(d.target.value),onBlur:i,"aria-label":"Edit cell value",onKeyDown:d=>{d.key==="Enter"&&i(),d.key==="Escape"&&n(false);},className:c("w-full border border-blue-500 rounded px-1 py-0.5 bg-white dark:bg-gray-700 text-gray-900 dark:text-gray-100 outline-none",xa[r])})}function Eg(e,t){let{columns:r,data:o,rowKey:n,mode:a="client",sortable:s=false,multiSort:l=false,sort:i,defaultSort:d,onSort:u,pagination:p=false,page:b,onPageChange:m,onPageSizeChange:f,totalItems:h,selectable:y=false,selectionMode:C="multiple",selectedRows:v,onSelectionChange:E,searchable:k=false,searchPlaceholder:R="Search...",searchValue:g,onSearch:P,filters:T,onFilterChange:D,expandable:W=false,expandedContent:V,expandedRows:_,onExpandChange:M,editable:w=false,onCellEdit:N,reorderable:x=false,onReorder:S,columnReorderable:I=false,onColumnReorder:F,columnToggle:O=false,hiddenColumns:Z,onColumnVisibilityChange:U,groupBy:H,renderGroupHeader:z,exportable:$=false,exportFormats:K=["csv","json"],exportFilename:se="export",virtualized:X=false,rowHeight:ee=40,virtualHeight:L=400,density:q="default",striped:ge=false,bordered:de=false,borderless:Y=false,stickyHeader:le=false,maxHeight:xe,loading:Se=false,loadingRows:te=5,emptyState:Ne,showFooter:De=false,onRowClick:Ve,onRowDoubleClick:rt,onRowContextMenu:dt,className:re,rowClassName:pe,cellClassName:Ue,headerClassName:yt}=e,[Re,We]=useState(d??[]),[ft,rr]=useState(1),[ot,Wt]=useState(typeof p=="object"?p.pageSize??10:10),[Nt,Ht]=useState([]),[or,Zt]=useState(""),[Ar,br]=useState([]),[fe,he]=useState([]),[j,J]=useState(()=>r.flatMap(A=>A.hidden?[A.key]:[])),[me,ue]=useState({}),[Te,ve]=useState(()=>r.map(A=>A.key)),[we,He]=useState(null),[Me,tt]=useState(null),[je,$e]=useState(false),[Tt,nt]=useState(new Set),nr=useRef(null),[zr,mo]=useState(0),Ao=useRef(null),hr=i??Re,ar=b??ft,B=v??Nt,Q=g??or,oe=T??Ar,ne=_??fe,ce=Z??j,Fe=p?typeof p=="object"?p:{pageSize:10,pageSizeOptions:[10,25,50,100]}:null,Ye=Fe?.pageSize??ot,_e=useMemo(()=>{let A=new Map(r.map(Ce=>[Ce.key,Ce])),G=Te.flatMap(Ce=>{let Le=A.get(Ce);return Le?[Le]:[]}),ie=new Set(G.map(Ce=>Ce.key));for(let Ce of r)ie.has(Ce.key)||(G.push(Ce),ie.add(Ce.key));return G.filter(Ce=>!ce.includes(Ce.key))},[r,Te,ce]),Ie=useMemo(()=>{if(a==="server")return o;let A=[...o];if(Q){let G=Q.toLowerCase();A=A.filter(ie=>_e.some(Ce=>{let Le=Tr(ie,Ce.key);return String(Le??"").toLowerCase().includes(G)}));}if(oe.length>0&&(A=A.filter(G=>oe.every(ie=>Sg(Tr(G,ie.column),ie)))),hr.length>0){let G=new Map(r.map(ie=>[ie.key,ie]));A.sort((ie,Ce)=>{for(let Le of hr){if(!Le.direction)continue;let pt=G.get(Le.key),Ot=pt?.sortComparator?pt.sortComparator(ie,Ce):Ng(Tr(ie,Le.key),Tr(Ce,Le.key));if(Ot!==0)return Le.direction==="asc"?Ot:-Ot}return 0});}return A},[o,a,Q,oe,hr,_e,r]),Pt=useMemo(()=>{if(!H)return null;let A=Array.isArray(H)?H:[H],G=new Map;for(let ie of Ie){let Ce=A.map(pt=>String(Tr(ie,pt)??"")).join(" / "),Le=G.get(Ce)??[];Le.push(ie),G.set(Ce,Le);}return G},[Ie,H]),Ge=h??Ie.length,ut=Math.max(1,Math.ceil(Ge/Ye)),xt=useMemo(()=>{if(!Fe||a==="server")return Ie;let A=(ar-1)*Ye;return Ie.slice(A,A+Ye)},[Ie,Fe,ar,Ye,a]),at=Fe?xt:Ie,Mt=useMemo(()=>{if(!X)return {start:0,end:at.length};let A=Math.floor(zr/ee),G=Math.ceil(L/ee),ie=5;return {start:Math.max(0,A-ie),end:Math.min(at.length,A+G+ie)}},[X,zr,ee,L,at.length]),yr=useCallback(A=>{i||We(A),u?.(A);},[i,u]),xr=useCallback(A=>{let G=hr.find(Ce=>Ce.key===A),ie;if(!G||!G.direction?ie="asc":G.direction==="asc"?ie="desc":ie=null,l){let Ce=hr.filter(Le=>Le.key!==A);ie&&Ce.push({key:A,direction:ie}),yr(Ce);}else yr(ie?[{key:A,direction:ie}]:[]);},[hr,l,yr]),Kt=useCallback(A=>{let G=Math.max(1,Math.min(A,ut));b||rr(G),m?.(G);},[b,m,ut]),rs=useCallback(A=>{Wt(A),Kt(1),f?.(A);},[Kt,f]),Qn=useCallback(A=>{let G;C==="single"?G=B.includes(A)?[]:[A]:G=B.includes(A)?B.filter(ie=>ie!==A):[...B,A],v||Ht(G),E?.(G);},[C,B,v,E]),os=useCallback(()=>{let A=at.map((G,ie)=>ya(G,ie,n));v||Ht(A),E?.(A);},[at,n,v,E]),ns=useCallback(()=>{v||Ht([]),E?.([]);},[v,E]),as=at.length>0&&at.every((A,G)=>B.includes(ya(A,G,n))),mu=!as&&at.some((A,G)=>B.includes(ya(A,G,n))),fu=useCallback(A=>{let G=ne.includes(A)?ne.filter(ie=>ie!==A):[...ne,A];_||he(G),M?.(G);},[ne,_,M]),bu=useCallback(A=>{let G=A.target.value;g||Zt(G),P?.(G),Kt(1);},[g,P,Kt]),hu=useCallback(A=>{let G=[...oe.filter(ie=>ie.column!==A.column),A];T||br(G),D?.(G);},[oe,T,D]),yu=useCallback(A=>{let G=oe.filter(ie=>ie.column!==A);T||br(G),D?.(G);},[oe,T,D]),xu=useCallback(A=>{let G=ce.includes(A)?ce.filter(ie=>ie!==A):[...ce,A];Z||J(G),U?.(G);},[ce,Z,U]),vu=useCallback((A,G)=>{A.preventDefault(),A.stopPropagation();let ie=A.clientX,Ce=me[G]??A.currentTarget.parentElement?.getBoundingClientRect().width??100,Le=r.find($t=>$t.key===G),pt=Le?.minWidth??50,Ot=Le?.maxWidth??1/0,qe=$t=>{let fo=$t.clientX-ie,kr=Math.min(Ot,Math.max(pt,Ce+fo));ue(Wo=>({...Wo,[G]:kr}));},vr=()=>{document.removeEventListener("mousemove",qe),document.removeEventListener("mouseup",vr);};document.addEventListener("mousemove",qe),document.addEventListener("mouseup",vr);},[me,r]),ku=useCallback(A=>{x&&He(A);},[x]),wu=useCallback((A,G)=>{!x||we===null||A.preventDefault();},[x,we]),Cu=useCallback(A=>{!x||we===null||we===A||(S?.(we,A),He(null));},[x,we,S]),Nu=useCallback(A=>{I&&tt(A);},[I]),Su=useCallback(A=>{if(!I||!Me||Me===A)return;let G=[...Te],ie=G.indexOf(Me),Ce=G.indexOf(A);ie===-1||Ce===-1||(G.splice(ie,1),G.splice(Ce,0,Me),ve(G),F?.(Me,A),tt(null));},[I,Me,Te,F]),ss=useCallback(A=>{let G=_e.filter($t=>$t.type!=="actions"&&$t.type!=="selection"&&$t.type!=="expand"),ie=Ie,Ce,Le,pt;if(A==="csv"){let $t=G.map(kr=>String(kr.header)).join(","),fo=ie.map(kr=>G.map(Wo=>{let ds=String(Tr(kr,Wo.key)??"");return ds.includes(",")?`"${ds}"`:ds}).join(","));Ce=[$t,...fo].join(`
|
|
2
|
-
`),Le="text/csv",pt="csv";}else {let $t=ie.map(fo=>{let kr={};for(let Wo of G)kr[Wo.key]=Tr(fo,Wo.key);return kr});Ce=JSON.stringify($t,null,2),Le="application/json",pt="json";}let Ot=new Blob([Ce],{type:Le}),qe=URL.createObjectURL(Ot),vr=document.createElement("a");vr.href=qe,vr.download=`${se}.${pt}`,vr.click(),URL.revokeObjectURL(qe);},[_e,Ie,se]);useEffect(()=>{if(!je)return;let A=G=>{Ao.current&&!Ao.current.contains(G.target)&&$e(false);};return document.addEventListener("mousedown",A),()=>document.removeEventListener("mousedown",A)},[je]),useImperativeHandle(t,()=>({getVisibleData:()=>at,resetFilters:()=>{T||br([]),g||Zt(""),D?.([]),P?.("");},resetSort:()=>{i||We([]),u?.([]);},selectAll:os,deselectAll:ns,exportData:ss,scrollToRow:A=>{nr.current&&X&&(nr.current.scrollTop=A*ee);}}),[at,T,g,i,D,P,u,os,ns,ss,X,ee]);let is=A=>{let G={},ie=me[A.key]??A.width;return ie&&(G.width=typeof ie=="number"?`${ie}px`:ie,G.minWidth=typeof ie=="number"?`${ie}px`:ie),A.sticky&&(G.position="sticky",G[A.sticky]=0,G.zIndex=10),G},zo=_e.length+(y?1:0)+(W?1:0)+(x?1:0),Ru=A=>{let G=s&&A.sortable!==false&&A.type!=="actions",ie=hr.find(Le=>Le.key===A.key),Ce=A.filterable&&(A.filterType||A.filterOptions);return jsxs("th",{className:c(At[q],xa[q],"font-semibold text-gray-700 dark:text-gray-300 whitespace-nowrap",A.align==="center"&&"text-center",A.align==="right"&&"text-right",G&&"cursor-pointer select-none hover:bg-gray-100 dark:hover:bg-gray-700",de&&"border border-gray-200 dark:border-gray-700",A.sticky&&"bg-gray-50 dark:bg-gray-800",A.headerClassName,yt),style:is(A),onClick:G?()=>xr(A.key):void 0,draggable:I,onDragStart:I?()=>Nu(A.key):void 0,onDragOver:I?Le=>Le.preventDefault():void 0,onDrop:I?()=>Su(A.key):void 0,"aria-sort":ie?.direction==="asc"?"ascending":ie?.direction==="desc"?"descending":void 0,children:[jsxs("div",{className:"flex items-center gap-1",children:[A.renderHeader?A.renderHeader(A):A.header,G&&jsx("span",{className:"inline-flex ml-1",children:ie?.direction==="asc"?jsx(bg,{}):ie?.direction==="desc"?jsx(hg,{}):jsx(yg,{})}),Ce&&jsx(Tg,{column:A,value:oe.find(Le=>Le.column===A.key),onApply:hu,onClear:()=>yu(A.key)})]}),A.resizable!==false&&jsx("div",{className:"absolute top-0 right-0 w-1 h-full cursor-col-resize hover:bg-blue-500 opacity-0 hover:opacity-100",onMouseDown:Le=>vu(Le,A.key)})]},A.key)},ls=(A,G,ie)=>{let Ce=ya(A,ie,n),Le=B.includes(Ce),pt=ne.includes(Ce),Ot=typeof pe=="function"?pe(A,ie):pe;return jsxs(Ns__default.Fragment,{children:[jsxs("tr",{className:c("border-b border-gray-200 dark:border-gray-700 transition-colors",ge&&ie%2===1&&"bg-gray-50/50 dark:bg-gray-800/50",Le&&"bg-blue-50 dark:bg-blue-900/20",Ve&&"cursor-pointer hover:bg-gray-50 dark:hover:bg-gray-700/50",we===G&&"opacity-50",Ot),onClick:Ve?()=>Ve(A,ie):void 0,onDoubleClick:rt?()=>rt(A,ie):void 0,onContextMenu:dt?qe=>dt(A,ie,qe):void 0,draggable:x,onDragStart:x?()=>ku(G):void 0,onDragOver:x?qe=>wu(qe,G):void 0,onDrop:x?()=>Cu(G):void 0,"data-row-key":Ce,"aria-selected":y?Le:void 0,children:[x&&jsx("td",{className:c(At[q],"cursor-grab active:cursor-grabbing"),children:jsx(vg,{})}),y&&jsx("td",{className:c(At[q],"w-10"),children:jsx("input",{type:"checkbox",checked:Le,onChange:()=>Qn(Ce),onClick:qe=>qe.stopPropagation(),className:"rounded border-gray-300 dark:border-gray-600 cursor-pointer","aria-label":`Select row ${Ce}`})}),W&&jsx("td",{className:c(At[q],"w-10"),children:jsx("button",{type:"button",onClick:qe=>{qe.stopPropagation(),fu(Ce);},className:"p-0.5 rounded hover:bg-gray-200 dark:hover:bg-gray-600 cursor-pointer","aria-label":pt?"Collapse row":"Expand row","aria-expanded":pt,children:jsx(Ll,{className:c("transition-transform",pt&&"rotate-180")})})}),_e.map(qe=>{let vr=Tr(A,qe.key),$t=qe.colSpan?.(A,ie);if($t===0)return null;let fo=w&&qe.editable!==false&&qe.type!=="actions";return jsx("td",{className:c(At[q],xa[q],"text-gray-700 dark:text-gray-300",qe.align==="center"&&"text-center",qe.align==="right"&&"text-right",de&&"border border-gray-200 dark:border-gray-700",qe.sticky&&(Le?"bg-blue-50 dark:bg-blue-900/20":ge&&ie%2===1?"bg-gray-50/50 dark:bg-gray-800/50":"bg-white dark:bg-gray-900"),qe.cellClassName,Ue),style:is(qe),colSpan:$t,children:fo?jsx(Pg,{value:vr,onSave:kr=>N?.(Ce,qe.key,kr),density:q}):qe.render?qe.render(vr,A,ie):String(vr??"")},qe.key)})]}),W&&pt&&V&&jsx("tr",{className:"bg-gray-50 dark:bg-gray-800/70",children:jsx("td",{colSpan:zo,className:c(At[q]),children:V(A,ie)})})]},Ce)},Tu=()=>{if(Se)return Array.from({length:te}).map((A,G)=>jsx(Rg,{cols:zo,density:q},G));if(at.length===0)return jsx("tr",{children:jsx("td",{colSpan:zo,className:c("text-center text-gray-400 dark:text-gray-500",At[q]),children:Ne??"No data available"})});if(Pt){let A=[],G=0;for(let[ie,Ce]of Pt){let Le=Tt.has(ie);if(A.push(jsx("tr",{className:"bg-gray-100 dark:bg-gray-800 font-medium",children:jsx("td",{colSpan:zo,className:c(At[q],"cursor-pointer"),onClick:()=>{nt(pt=>{let Ot=new Set(pt);return Ot.has(ie)?Ot.delete(ie):Ot.add(ie),Ot});},children:jsxs("div",{className:"flex items-center gap-2",children:[jsx(Ll,{className:c("transition-transform",Le&&"-rotate-90")}),z?z(ie,Tr(Ce[0],Array.isArray(H)?H[0]:H),Ce):`${ie} (${Ce.length})`]})})},`group-${ie}`)),Le)G+=Ce.length;else for(let pt=0;pt<Ce.length;pt++)A.push(ls(Ce[pt],G,G)),G++;}return A}if(X){let A=[];for(let G=Mt.start;G<Mt.end;G++)A.push(ls(at[G],G,G));return jsxs(Fragment,{children:[Mt.start>0&&jsx("tr",{children:jsx("td",{colSpan:zo,style:{height:Mt.start*ee,padding:0}})}),A,Mt.end<at.length&&jsx("tr",{children:jsx("td",{colSpan:zo,style:{height:(at.length-Mt.end)*ee,padding:0}})})]})}return at.map((A,G)=>ls(A,G,G))},Pu=()=>!De||!_e.some(G=>G.aggregate)?null:jsx("tfoot",{children:jsxs("tr",{className:"bg-gray-50 dark:bg-gray-800 font-semibold border-t-2 border-gray-300 dark:border-gray-600",children:[x&&jsx("td",{className:At[q]}),y&&jsx("td",{className:At[q]}),W&&jsx("td",{className:At[q]}),_e.map(G=>jsx("td",{className:c(At[q],xa[q],"text-gray-700 dark:text-gray-300",G.align==="center"&&"text-center",G.align==="right"&&"text-right",de&&"border border-gray-200 dark:border-gray-700"),style:is(G),children:G.aggregate?G.renderAggregate?G.renderAggregate(Al(Ie,G.key,G.aggregate),Ie):`${G.aggregate==="count"?"":G.aggregate==="avg"?"Avg: ":G.aggregate==="sum"?"Total: ":G.aggregate==="min"?"Min: ":"Max: "}${Al(Ie,G.key,G.aggregate).toLocaleString()}`:""},G.key))]})});return jsxs("div",{className:c("flex flex-col gap-3",re),children:[(k||$||O)&&jsxs("div",{className:"flex items-center justify-between gap-3 flex-wrap",children:[jsxs("div",{className:"flex items-center gap-3 flex-1",children:[k&&jsxs("div",{className:"relative flex-1 max-w-xs",children:[jsx("div",{className:"absolute inset-y-0 left-0 flex items-center pl-3 pointer-events-none",children:jsx(xg,{})}),jsx("input",{type:"text",value:Q,onChange:bu,placeholder:R,className:"w-full pl-9 pr-3 py-1.5 text-sm border border-gray-300 dark:border-gray-600 rounded-md bg-white dark:bg-gray-800 text-gray-700 dark:text-gray-200 focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-blue-500","aria-label":"Search table"})]}),B.length>0&&jsxs("span",{className:"text-sm text-gray-500 dark:text-gray-400",children:[B.length," selected"]})]}),jsxs("div",{className:"flex items-center gap-2",children:[O&&jsxs("div",{className:"relative",ref:Ao,children:[jsx("button",{type:"button",onClick:()=>$e(!je),className:"p-1.5 rounded-md border border-gray-300 dark:border-gray-600 text-gray-600 dark:text-gray-400 hover:bg-gray-100 dark:hover:bg-gray-700 cursor-pointer","aria-label":"Toggle columns",title:"Toggle columns",children:jsx(Cg,{})}),je&&jsx("div",{className:"absolute z-50 right-0 top-full mt-1 bg-white dark:bg-gray-800 border border-gray-200 dark:border-gray-700 rounded-lg shadow-lg p-2 min-w-[180px]",children:r.filter(A=>A.type!=="selection"&&A.type!=="expand").map(A=>jsxs("label",{className:"flex items-center gap-2 px-2 py-1.5 text-sm rounded hover:bg-gray-100 dark:hover:bg-gray-700 cursor-pointer",children:[jsx("input",{type:"checkbox",checked:!ce.includes(A.key),onChange:()=>xu(A.key),className:"rounded border-gray-300 dark:border-gray-600 cursor-pointer"}),jsx("span",{className:"text-gray-700 dark:text-gray-300",children:String(A.header)})]},A.key))})]}),$&&K.map(A=>jsxs("button",{type:"button",onClick:()=>ss(A),className:"inline-flex items-center gap-1.5 px-2.5 py-1.5 text-xs font-medium rounded-md border border-gray-300 dark:border-gray-600 text-gray-600 dark:text-gray-400 hover:bg-gray-100 dark:hover:bg-gray-700 cursor-pointer",title:`Export as ${A.toUpperCase()}`,children:[jsx(wg,{}),A.toUpperCase()]},A))]})]}),jsx("div",{ref:nr,className:c("overflow-auto rounded-lg",!Y&&"border border-gray-200 dark:border-gray-700",le&&"relative"),style:xe?{maxHeight:typeof xe=="number"?`${xe}px`:xe}:X?{maxHeight:L,overflow:"auto"}:void 0,onScroll:X?A=>mo(A.target.scrollTop):void 0,children:jsxs("table",{className:"w-full text-left",children:[jsx("thead",{className:c("bg-gray-50 dark:bg-gray-800 text-xs uppercase",le&&"sticky top-0 z-20"),children:jsxs("tr",{children:[x&&jsx("th",{className:c(At[q],"w-10 font-semibold text-gray-700 dark:text-gray-300")}),y&&jsx("th",{className:c(At[q],"w-10"),children:C==="multiple"&&jsx("input",{type:"checkbox",checked:as,ref:A=>{A&&(A.indeterminate=mu);},onChange:as?ns:os,className:"rounded border-gray-300 dark:border-gray-600 cursor-pointer","aria-label":"Select all rows"})}),W&&jsx("th",{className:c(At[q],"w-10 font-semibold text-gray-700 dark:text-gray-300")}),_e.map(Ru)]})}),jsx("tbody",{children:Tu()}),Pu()]})}),Fe&&jsxs("div",{className:"flex items-center justify-between flex-wrap gap-3 text-sm text-gray-600 dark:text-gray-400",children:[jsxs("div",{className:"flex items-center gap-3",children:[Fe.showTotalItems!==false&&jsxs("span",{children:[Ge," item",Ge!==1?"s":""]}),Fe.showPageSizeSelector!==false&&Fe.pageSizeOptions&&jsxs("div",{className:"flex items-center gap-1.5",children:[jsx("span",{children:"Rows per page:"}),jsx("select",{value:Ye,onChange:A=>rs(Number(A.target.value)),className:"border border-gray-300 dark:border-gray-600 rounded px-1.5 py-0.5 bg-white dark:bg-gray-800 text-gray-700 dark:text-gray-200 text-sm",children:Fe.pageSizeOptions.map(A=>jsx("option",{value:A,children:A},A))})]})]}),jsxs("div",{className:"flex items-center gap-1",children:[jsxs("span",{className:"mr-2",children:["Page ",ar," of ",ut]}),jsx("button",{type:"button",onClick:()=>Kt(1),disabled:ar<=1,className:"px-2 py-1 rounded border border-gray-300 dark:border-gray-600 disabled:opacity-50 disabled:cursor-not-allowed hover:bg-gray-100 dark:hover:bg-gray-700 cursor-pointer","aria-label":"First page",children:"\xAB\xAB"}),jsx("button",{type:"button",onClick:()=>Kt(ar-1),disabled:ar<=1,className:"px-2 py-1 rounded border border-gray-300 dark:border-gray-600 disabled:opacity-50 disabled:cursor-not-allowed hover:bg-gray-100 dark:hover:bg-gray-700 cursor-pointer","aria-label":"Previous page",children:"\xAB"}),jsx("button",{type:"button",onClick:()=>Kt(ar+1),disabled:ar>=ut,className:"px-2 py-1 rounded border border-gray-300 dark:border-gray-600 disabled:opacity-50 disabled:cursor-not-allowed hover:bg-gray-100 dark:hover:bg-gray-700 cursor-pointer","aria-label":"Next page",children:"\xBB"}),jsx("button",{type:"button",onClick:()=>Kt(ut),disabled:ar>=ut,className:"px-2 py-1 rounded border border-gray-300 dark:border-gray-600 disabled:opacity-50 disabled:cursor-not-allowed hover:bg-gray-100 dark:hover:bg-gray-700 cursor-pointer","aria-label":"Last page",children:"\xBB\xBB"})]})]})]})}var Dg=forwardRef(Eg);function Mg({className:e}){return jsx("svg",{className:e,viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",children:jsx("path",{d:"M4 4L12 12M12 4L4 12",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})})}var Lg={default:{solid:"bg-gray-500 text-white",outlined:"border-gray-300 text-gray-700 dark:border-gray-600 dark:text-gray-300 bg-transparent",soft:"bg-gray-100 text-gray-700 dark:bg-gray-700 dark:text-gray-300",dot:"bg-gray-100 text-gray-700 dark:bg-gray-800 dark:text-gray-300"},primary:{solid:"bg-blue-600 text-white",outlined:"border-blue-600 text-blue-600 dark:border-blue-400 dark:text-blue-400 bg-transparent",soft:"bg-blue-100 text-blue-700 dark:bg-blue-900/50 dark:text-blue-300",dot:"bg-blue-50 text-blue-700 dark:bg-blue-900/30 dark:text-blue-300"},success:{solid:"bg-green-600 text-white",outlined:"border-green-600 text-green-600 dark:border-green-400 dark:text-green-400 bg-transparent",soft:"bg-green-100 text-green-700 dark:bg-green-900/50 dark:text-green-300",dot:"bg-green-50 text-green-700 dark:bg-green-900/30 dark:text-green-300"},warning:{solid:"bg-yellow-500 text-white",outlined:"border-yellow-500 text-yellow-600 dark:border-yellow-400 dark:text-yellow-400 bg-transparent",soft:"bg-yellow-100 text-yellow-700 dark:bg-yellow-900/50 dark:text-yellow-300",dot:"bg-yellow-50 text-yellow-700 dark:bg-yellow-900/30 dark:text-yellow-300"},error:{solid:"bg-red-600 text-white",outlined:"border-red-600 text-red-600 dark:border-red-400 dark:text-red-400 bg-transparent",soft:"bg-red-100 text-red-700 dark:bg-red-900/50 dark:text-red-300",dot:"bg-red-50 text-red-700 dark:bg-red-900/30 dark:text-red-300"},info:{solid:"bg-cyan-600 text-white",outlined:"border-cyan-600 text-cyan-600 dark:border-cyan-400 dark:text-cyan-400 bg-transparent",soft:"bg-cyan-100 text-cyan-700 dark:bg-cyan-900/50 dark:text-cyan-300",dot:"bg-cyan-50 text-cyan-700 dark:bg-cyan-900/30 dark:text-cyan-300"}},Ag={default:"bg-gray-500",primary:"bg-blue-600",success:"bg-green-600",warning:"bg-yellow-500",error:"bg-red-600",info:"bg-cyan-600"},zg={sm:"h-5 text-xs px-2 gap-1",md:"h-6 text-sm px-2.5 gap-1.5",lg:"h-8 text-sm px-3 gap-2"},Es={sm:"w-3 h-3",md:"w-3.5 h-3.5",lg:"w-4 h-4"},Wg={sm:"w-4 h-4 -ml-1",md:"w-5 h-5 -ml-1.5",lg:"w-6 h-6 -ml-1.5"},Hg={sm:"w-1.5 h-1.5",md:"w-2 h-2",lg:"w-2.5 h-2.5"},Fg={none:"rounded-none",sm:"rounded-sm",md:"rounded-md",lg:"rounded-lg",full:"rounded-full"};function ka({label:e,children:t,variant:r="solid",size:o="md",color:n="default",bgColor:a,textColor:s,borderColor:l,rounded:i="full",icon:d,endIcon:u,avatar:p,onClose:b,closable:m=false,clickable:f=false,selected:h=false,disabled:y=false,as:C="span",className:v,onClick:E,...k}){let R=C,g=c("inline-flex items-center justify-center font-medium transition-all",zg[o],Fg[i],r==="outlined"&&"border"),P=c(a||s||l?c(a,s,l):Lg[n][r]),T=h?"ring-2 ring-offset-1 ring-blue-500":"",D=f&&!y?"cursor-pointer hover:opacity-80 active:scale-95":"",W=y?"opacity-50 cursor-not-allowed":"",V=w=>{w.stopPropagation(),b?.();},_=w=>{y||E?.(w);},M=t??e;return jsxs(R,{className:c(g,P,T,D,W,v),onClick:_,"aria-disabled":y,...k,children:[r==="dot"&&jsx("span",{className:c("rounded-full shrink-0",Hg[o],Ag[n]),"aria-hidden":"true"}),p&&jsx("span",{className:c("rounded-full overflow-hidden shrink-0",Wg[o]),children:p}),d&&!p&&jsx("span",{className:c("shrink-0",Es[o]),children:d}),M&&jsx("span",{className:"truncate",children:M}),u&&!m&&jsx("span",{className:c("shrink-0",Es[o]),children:u}),m&&jsx("button",{type:"button",onClick:V,disabled:y,className:c("shrink-0 rounded-full hover:bg-black/10 dark:hover:bg-white/10 p-0.5 -mr-1 transition-colors","focus:outline-none focus-visible:ring-2 focus-visible:ring-offset-1 focus-visible:ring-current",y&&"pointer-events-none"),"aria-label":"Remove",children:jsx(Mg,{className:Es[o]})})]})}ka.displayName="Chip";var _g=500,Gg=800,Xg=600;function Kg(e,t,r){let o=[`width=${e}`,`height=${t}`,"menubar=no","toolbar=no","location=no","status=no","scrollbars=yes","resizable=yes"];if(r.left!==void 0)o.push(`left=${r.left}`);else if(r.center!==false&&typeof window<"u"){let n=window.screenLeft??window.screenX,a=window.screenTop??window.screenY,s=window.outerWidth??screen.availWidth,l=window.outerHeight??screen.availHeight;o.push(`left=${n+(s-e)/2}`),o.push(`top=${a+(l-t)/2}`);}if(r.top!==void 0){let n=o.filter(a=>!a.startsWith("top="));return n.push(`top=${r.top}`),n.join(",")}return o.join(",")}function Ug(e,t){e.querySelectorAll("style").forEach(s=>{let l=t.createElement("style");l.textContent=s.textContent,t.head.appendChild(l);}),e.querySelectorAll('link[rel="stylesheet"]').forEach(s=>{let l=t.createElement("link");l.rel="stylesheet",l.href=s.href,s.crossOrigin&&(l.crossOrigin=s.crossOrigin),t.head.appendChild(l);});let n=e.documentElement.className;n&&(t.documentElement.className=n);let a=e.body.className;a&&(t.body.className=a);}function Yg(e,t){let r=new MutationObserver(o=>{for(let n of o)for(let a of Array.from(n.addedNodes))if(a instanceof HTMLStyleElement){let s=t.createElement("style");s.textContent=a.textContent,t.head.appendChild(s);}else if(a instanceof HTMLLinkElement&&a.rel==="stylesheet"){let s=t.createElement("link");s.rel="stylesheet",s.href=a.href,t.head.appendChild(s);}});return r.observe(e.head,{childList:true}),r}var Wl=forwardRef(function({children:t,detached:r,defaultDetached:o=false,onClose:n,onDetach:a,title:s="",width:l=Gg,height:i=Xg,left:d,top:u,center:p=true,copyStyles:b=true,closeOnParentUnmount:m=true,className:f,windowClassName:h,onPopupBlocked:y},C){let v=r!==void 0,[E,k]=useState(o),R=v?r:E,[g,P]=useState(null),T=useRef(null),D=useRef(null),W=useRef(null),V=useRef(false),_=useRef({width:l,height:i,left:d,top:u,center:p,shouldCopyStyles:b,title:s,windowClassName:h,closeOnParentUnmount:m});_.current={width:l,height:i,left:d,top:u,center:p,shouldCopyStyles:b,title:s,windowClassName:h,closeOnParentUnmount:m};let M=useCallback(()=>{D.current&&(clearInterval(D.current),D.current=null),W.current&&(W.current.disconnect(),W.current=null),P(null);},[]),w=useCallback(()=>{T.current&&!T.current.closed&&T.current.close(),T.current=null,M();},[M]),N=useCallback(()=>{if(typeof window>"u"||V.current||T.current&&!T.current.closed)return;V.current=true;let x=_.current,S=Kg(x.width,x.height,{center:x.center,left:x.left,top:x.top}),I=window.open("","",S);if(!I){V.current=false,y?.();return}T.current=I,I.document.title=x.title||document.title;let F=I.document.createElement("div");x.windowClassName&&(F.className=x.windowClassName),I.document.body.appendChild(F),P(F),x.shouldCopyStyles&&(Ug(document,I.document),W.current=Yg(document,I.document)),D.current=setInterval(()=>{I.closed&&(M(),T.current=null,v||k(false),n?.());},_g),V.current=false,a?.();},[v,n,a,y,M]);return useEffect(()=>{R?N():w();},[R,N,w]),useEffect(()=>{T.current&&!T.current.closed&&s&&(T.current.document.title=s);},[s]),useEffect(()=>()=>{_.current.closeOnParentUnmount&&T.current&&!T.current.closed&&T.current.close(),M(),T.current=null;},[M]),useImperativeHandle(C,()=>({detach:()=>{v||k(true);},attach:()=>{v||k(false);},get isDetached(){return v?!!r:E},get window(){return T.current}}),[v,r,E]),R&&g?createPortal(t,g):R?null:jsx("div",{className:c(f),children:t})});Wl.displayName="Detachable";var Zg={phone:{sm:{w:180,h:320},md:{w:240,h:480},lg:{w:300,h:600}},android:{sm:{w:180,h:320},md:{w:240,h:480},lg:{w:300,h:600}},tablet:{sm:{w:320,h:420},md:{w:420,h:560},lg:{w:540,h:720}},laptop:{sm:{w:400,h:250},md:{w:560,h:350},lg:{w:720,h:450}},desktop:{sm:{w:400,h:300},md:{w:560,h:400},lg:{w:720,h:520}},watch:{sm:{w:80,h:96},md:{w:120,h:144},lg:{w:160,h:192}},browser:{sm:{w:400,h:280},md:{w:560,h:380},lg:{w:720,h:480}}},Jg=({className:e})=>jsxs("svg",{className:c("w-3 h-3",e),viewBox:"0 0 16 16",fill:"currentColor",children:[jsx("rect",{x:"1",y:"11",width:"2.5",height:"4",rx:"0.5"}),jsx("rect",{x:"5",y:"8",width:"2.5",height:"7",rx:"0.5"}),jsx("rect",{x:"9",y:"5",width:"2.5",height:"10",rx:"0.5"}),jsx("rect",{x:"13",y:"1",width:"2.5",height:"14",rx:"0.5"})]}),Qg=({className:e})=>jsxs("svg",{className:c("w-3 h-3",e),viewBox:"0 0 20 20",fill:"currentColor",children:[jsx("path",{d:"M10 14.5a1.5 1.5 0 100 3 1.5 1.5 0 000-3z"}),jsx("path",{fillRule:"evenodd",d:"M6.05 11.95a5.5 5.5 0 017.9 0 .75.75 0 001.08-1.04 7 7 0 00-10.06 0 .75.75 0 001.08 1.04z",clipRule:"evenodd"}),jsx("path",{fillRule:"evenodd",d:"M2.81 8.72a10 10 0 0114.38 0 .75.75 0 001.06-1.06 11.5 11.5 0 00-16.5 0 .75.75 0 001.06 1.06z",clipRule:"evenodd"})]}),em=({className:e})=>jsxs("svg",{className:c("w-4 h-3",e),viewBox:"0 0 24 14",fill:"currentColor",children:[jsx("rect",{x:"0.5",y:"0.5",width:"20",height:"13",rx:"2",stroke:"currentColor",fill:"none",strokeWidth:"1"}),jsx("rect",{x:"22",y:"4",width:"2",height:"6",rx:"0.5"}),jsx("rect",{x:"2.5",y:"2.5",width:"14",height:"9",rx:"1"})]});function En({time:e="9:41",theme:t,device:r}){let o=r==="watch",n=t==="dark"?"text-white":"text-gray-900";return o?jsx("div",{className:c("flex items-center justify-center py-0.5",n),style:{fontSize:"8px"},children:jsx("span",{className:"font-medium",children:e})}):jsxs("div",{className:c("flex items-center justify-between px-4 py-1",t==="dark"?"bg-black/20":"bg-white/20",n),style:{fontSize:"10px"},"data-testid":"status-bar",children:[jsx("span",{className:"font-semibold",children:e}),jsxs("div",{className:"flex items-center gap-1",children:[jsx(Jg,{className:n}),jsx(Qg,{className:n}),jsx(em,{className:n})]})]})}function tm({theme:e}){let t=e==="dark";return jsxs("div",{className:c("flex items-center gap-2 px-3 py-2 border-b",t?"bg-gray-800 border-gray-700":"bg-gray-100 border-gray-200"),"data-testid":"browser-chrome",children:[jsxs("div",{className:"flex items-center gap-1.5",children:[jsx("div",{className:"w-2.5 h-2.5 rounded-full bg-red-400"}),jsx("div",{className:"w-2.5 h-2.5 rounded-full bg-yellow-400"}),jsx("div",{className:"w-2.5 h-2.5 rounded-full bg-green-400"})]}),jsx("div",{className:c("flex-1 rounded-md px-3 py-1 text-center",t?"bg-gray-700 text-gray-400":"bg-white text-gray-500 border border-gray-200"),style:{fontSize:"11px"},children:jsxs("span",{className:"flex items-center justify-center gap-1",children:[jsx("svg",{className:"w-2.5 h-2.5",viewBox:"0 0 16 16",fill:"currentColor",children:jsx("path",{fillRule:"evenodd",d:"M8 1a4 4 0 00-4 4v3.5H3a1 1 0 00-1 1V14a1 1 0 001 1h10a1 1 0 001-1V9.5a1 1 0 00-1-1h-1V5a4 4 0 00-4-4zm2.5 7.5V5a2.5 2.5 0 00-5 0v3.5h5z",clipRule:"evenodd"})}),"example.com"]})})]})}function rm({children:e,theme:t,screenW:r,screenH:o,showStatusBar:n,statusBarTime:a,frameColor:s,landscape:l=false}){let i=t==="dark",d=s??(i?"#1a1a1a":"#e5e7eb");if(l){let p=Math.round(o*.35);return jsxs("div",{className:"relative inline-flex flex-row items-center rounded-[2.5rem] shadow-xl",style:{backgroundColor:d,padding:"8px 12px",height:o+16},"data-testid":"device-frame","data-device":"phone",children:[jsx("div",{className:c("rounded-full mr-2",i?"bg-gray-600":"bg-gray-400"),style:{width:4,height:Math.round(o*.35)},"data-testid":"home-indicator"}),jsxs("div",{className:"rounded-[2rem] overflow-hidden bg-black relative",style:{width:r,height:o},children:[n&&jsx(En,{time:a,theme:t,device:"phone"}),e]}),jsx("div",{className:"absolute rounded-full bg-black z-10",style:{width:20,height:p,right:10,top:"50%",transform:"translateY(-50%)"},"data-testid":"phone-notch"})]})}let u=Math.round(r*.35);return jsxs("div",{className:"relative inline-flex flex-col items-center rounded-[2.5rem] shadow-xl",style:{backgroundColor:d,padding:"12px 8px",width:r+16},"data-testid":"device-frame","data-device":"phone",children:[jsx("div",{className:"absolute top-[10px] rounded-full bg-black z-10",style:{width:u,height:20,left:"50%",transform:"translateX(-50%)"},"data-testid":"phone-notch"}),jsxs("div",{className:"rounded-[2rem] overflow-hidden bg-black relative",style:{width:r,height:o},children:[n&&jsx(En,{time:a,theme:t,device:"phone"}),e]}),jsx("div",{className:c("rounded-full mt-2",i?"bg-gray-600":"bg-gray-400"),style:{width:Math.round(r*.35),height:4},"data-testid":"home-indicator"})]})}function om({children:e,theme:t,screenW:r,screenH:o,showStatusBar:n,statusBarTime:a,frameColor:s}){return jsxs("div",{className:"relative inline-flex flex-col items-center rounded-[2rem] shadow-xl",style:{backgroundColor:s??(t==="dark"?"#1a1a1a":"#e5e7eb"),padding:"10px 6px",width:r+12},"data-testid":"device-frame","data-device":"android",children:[jsx("div",{className:"absolute top-[6px] rounded-full bg-gray-800 z-10 border border-gray-700",style:{width:8,height:8,left:"50%",transform:"translateX(-50%)"},"data-testid":"camera-dot"}),jsxs("div",{className:"rounded-[1.5rem] overflow-hidden bg-black relative",style:{width:r,height:o},children:[n&&jsx(En,{time:a,theme:t,device:"android"}),e]})]})}function nm({children:e,theme:t,screenW:r,screenH:o,showStatusBar:n,statusBarTime:a,frameColor:s}){return jsxs("div",{className:"relative inline-flex flex-col items-center rounded-[1.5rem] shadow-xl",style:{backgroundColor:s??(t==="dark"?"#1a1a1a":"#e5e7eb"),padding:"16px 12px",width:r+24},"data-testid":"device-frame","data-device":"tablet",children:[jsx("div",{className:"absolute top-[8px] rounded-full bg-gray-700 z-10",style:{width:6,height:6,left:"50%",transform:"translateX(-50%)"}}),jsxs("div",{className:"rounded-lg overflow-hidden bg-black relative",style:{width:r,height:o},children:[n&&jsx(En,{time:a,theme:t,device:"tablet"}),e]})]})}function am({children:e,theme:t,screenW:r,screenH:o,frameColor:n}){let a=t==="dark",s=n??(a?"#1a1a1a":"#d1d5db"),l=r+60;return jsxs("div",{className:"inline-flex flex-col items-center","data-testid":"device-frame","data-device":"laptop",children:[jsxs("div",{className:"rounded-t-xl shadow-xl relative",style:{backgroundColor:s,padding:"8px 8px 0",width:r+16},children:[jsx("div",{className:"absolute top-[3px] rounded-full bg-gray-700 z-10",style:{width:4,height:4,left:"50%",transform:"translateX(-50%)"}}),jsx("div",{className:"rounded-t-sm overflow-hidden bg-black",style:{width:r,height:o},children:e})]}),jsx("div",{className:c(a?"bg-gray-800":"bg-gray-400"),style:{width:r+16,height:3}}),jsx("div",{className:"rounded-b-xl shadow-lg",style:{backgroundColor:s,width:l,height:12,clipPath:"polygon(3% 0%, 97% 0%, 100% 100%, 0% 100%)"},"data-testid":"laptop-base"})]})}function sm({children:e,theme:t,screenW:r,screenH:o,frameColor:n}){let a=t==="dark";return jsxs("div",{className:"inline-flex flex-col items-center","data-testid":"device-frame","data-device":"desktop",children:[jsx("div",{className:"rounded-lg shadow-xl",style:{backgroundColor:n??(a?"#1a1a1a":"#d1d5db"),padding:"8px 8px 20px",width:r+16},children:jsx("div",{className:"rounded-sm overflow-hidden bg-black",style:{width:r,height:o},children:e})}),jsx("div",{className:c(a?"bg-gray-800":"bg-gray-400"),style:{width:40,height:24},"data-testid":"monitor-stand"}),jsx("div",{className:c("rounded-t-sm",a?"bg-gray-800":"bg-gray-400"),style:{width:Math.round(r*.4),height:6,borderRadius:"2px 2px 4px 4px"}})]})}function im({children:e,theme:t,screenW:r,screenH:o,showStatusBar:n,statusBarTime:a,frameColor:s}){let l=t==="dark",i=s??(l?"#1a1a1a":"#d1d5db"),d=Math.round(r*.7);return jsxs("div",{className:"inline-flex flex-col items-center","data-testid":"device-frame","data-device":"watch",children:[jsx("div",{className:c("rounded-t-lg",l?"bg-gray-800":"bg-gray-400"),style:{width:d,height:30},"data-testid":"watch-band"}),jsxs("div",{className:"relative rounded-[1.2rem] shadow-xl",style:{backgroundColor:i,padding:"8px 6px",width:r+12},children:[jsx("div",{className:c("absolute rounded-sm",l?"bg-gray-600":"bg-gray-400"),style:{width:4,height:16,right:-4,top:"30%"},"data-testid":"watch-crown"}),jsxs("div",{className:"rounded-xl overflow-hidden bg-black",style:{width:r,height:o},children:[n&&jsx(En,{time:a,theme:t,device:"watch"}),e]})]}),jsx("div",{className:c("rounded-b-lg",l?"bg-gray-800":"bg-gray-400"),style:{width:d,height:30}})]})}function lm({children:e,theme:t,screenW:r,screenH:o,frameColor:n}){return jsxs("div",{className:"inline-flex flex-col rounded-lg shadow-xl overflow-hidden",style:{backgroundColor:n??(t==="dark"?"#1f2937":"#f3f4f6"),width:r},"data-testid":"device-frame","data-device":"browser",children:[jsx(tm,{theme:t}),jsx("div",{className:"overflow-hidden bg-white",style:{width:r,height:o},children:e})]})}function dm({device:e="phone",src:t,alt:r="Device screen content",children:o,orientation:n="portrait",theme:a="dark",size:s="md",showStatusBar:l=false,statusBarTime:i,animated:d=false,scrollSpeed:u=30,frameColor:p,className:b,contentClassName:m}){let f=useRef(null),h=useRef(null),y=Zg[e][s],C=n==="landscape"&&e!=="watch"&&e!=="browser",v=C?y.h:y.w,E=C?y.w:y.h;useEffect(()=>{if(!d||!f.current)return;let P=f.current,T=null,D=W=>{T===null&&(T=W);let V=(W-T)/1e3;T=W,P.scrollTop+=u*V,P.scrollTop>=P.scrollHeight-P.clientHeight&&(P.scrollTop=0),h.current=requestAnimationFrame(D);};return h.current=requestAnimationFrame(D),()=>{h.current!==null&&cancelAnimationFrame(h.current);}},[d,u]);let k=jsx("div",{ref:d?f:void 0,className:c("w-full h-full overflow-hidden",d&&"overflow-y-auto scrollbar-hide",m),style:d?{scrollBehavior:"auto"}:void 0,children:t?jsx("img",{src:t,alt:r,className:"w-full h-auto object-cover",draggable:false}):o}),R={showStatusBar:l,statusBarTime:i},g=()=>{switch(e){case "phone":return jsx(rm,{theme:a,screenW:v,screenH:E,frameColor:p,landscape:C,...R,children:k});case "android":return jsx(om,{theme:a,screenW:v,screenH:E,frameColor:p,...R,children:k});case "tablet":return jsx(nm,{theme:a,screenW:v,screenH:E,frameColor:p,...R,children:k});case "laptop":return jsx(am,{theme:a,screenW:v,screenH:E,frameColor:p,children:k});case "desktop":return jsx(sm,{theme:a,screenW:v,screenH:E,frameColor:p,children:k});case "watch":return jsx(im,{theme:a,screenW:v,screenH:E,frameColor:p,...R,children:k});case "browser":return jsx(lm,{theme:a,screenW:v,screenH:E,frameColor:p,children:k})}};return jsx("div",{className:c("inline-flex",b),"data-testid":"device-mockup","data-orientation":n,"data-theme":a,"data-size":s,children:g()})}var wa={solid:"border-solid",dashed:"border-dashed",dotted:"border-dotted"},cm={left:{before:"flex-[0.1]",after:"flex-1"},center:{before:"flex-1",after:"flex-1"},right:{before:"flex-1",after:"flex-[0.1]"}};function Fl({orientation:e="horizontal",variant:t="solid",label:r,textAlign:o="center",thickness:n=1,color:a="border-gray-300 dark:border-gray-700",spacing:s,className:l,...i}){if(e==="vertical")return jsx("hr",{"aria-orientation":"vertical",className:c("h-full border-l-0 border-r",wa[t],a,s||"mx-2",l),style:{borderRightWidth:`${n}px`},...i});if(r){let d=cm[o];return jsxs("div",{role:"separator","aria-orientation":"horizontal",className:c("flex items-center text-sm text-gray-500 dark:text-gray-400",s||"my-4",l),...i,children:[jsx("div",{className:c("border-t",wa[t],a,d.before),style:{borderTopWidth:`${n}px`}}),jsx("span",{className:"px-3 whitespace-nowrap",children:r}),jsx("div",{className:c("border-t",wa[t],a,d.after),style:{borderTopWidth:`${n}px`}})]})}return jsx("hr",{"aria-orientation":"horizontal",className:c("border-t-0 border-b",wa[t],a,s||"my-4",l),style:{borderBottomWidth:`${n}px`},...i})}Fl.displayName="Divider";var pm=new Set(["SCRIPT","STYLE","LINK","META","NOSCRIPT","TEMPLATE","BASE","TITLE"]),Bl="data-synertech-inert-ignore",In=new WeakMap,Ms=new WeakMap,Ls=new WeakMap;function gm(e){let t=In.get(e)??0;t===0&&(Ms.set(e,e.getAttribute("aria-hidden")),Ls.set(e,e.hasAttribute("inert")),e.setAttribute("aria-hidden","true"),e.setAttribute("inert","")),In.set(e,t+1);}function mm(e){let t=In.get(e)??0;if(t===0)return;if(t>1){In.set(e,t-1);return}In.delete(e);let r=Ms.get(e)??null;r===null?e.removeAttribute("aria-hidden"):e.setAttribute("aria-hidden",r),Ms.delete(e),Ls.get(e)||e.removeAttribute("inert"),Ls.delete(e);}var Ca=new Map;function No(e,t){return Ca.set(e,t),()=>{Ca.delete(e);}}function Na(e){if(Ca.size===0)return [];let t=[];for(let[r,o]of Ca){let n=o();n&&e.some(a=>a.contains(n))&&t.push(r);}return t}function fm(e){return !(pm.has(e.tagName)||e.hasAttribute(Bl))}function As(e){let t=(Array.isArray(e)?e:[e]).filter(Boolean),r=t[0]?.ownerDocument?.body;if(!r||!t.every(i=>r.contains(i)))return ()=>{};let o=[...t,...Na(t).filter(i=>r.contains(i))],n=[],a=new Set,s=i=>o.some(d=>i===d||i.contains(d));for(let i of t){let d=i;for(;d&&d!==r;){let u=d.parentElement;if(!u)break;for(let p of Array.from(u.children))a.has(p)||s(p)||fm(p)&&(a.add(p),gm(p),n.push(p));d=u;}}let l=false;return ()=>{if(!l){l=true;for(let i of n)mm(i);}}}var no=[];function Vl(e){let t=no.indexOf(e);t!==-1&&no.splice(t,1),no.push(e);}function Ol(e){let t=no.indexOf(e);t!==-1&&no.splice(t,1);}function $l(e){return no.length>0&&no[no.length-1]===e}var Mn=0,zs=null;function _l(e=document){let t=e.body;if(!t)return ()=>{};Mn===0&&(zs=t.style.overflow,t.style.overflow="hidden"),Mn+=1;let r=false;return ()=>{r||(r=true,Mn=Math.max(0,Mn-1),Mn===0&&(t.style.overflow=zs??"",zs=null));}}var Gl=["a[href]","area[href]","button","input","select","textarea","details > summary:first-of-type","iframe","object","embed","audio[controls]","video[controls]",'[contenteditable]:not([contenteditable="false"])',"[tabindex]"].join(",");function bm(e){let t=e.ownerDocument?.defaultView;if(!t)return null;try{return t.getComputedStyle(e)}catch{return null}}function Xl(e){let t=e;for(;t;){if(t.hasAttribute("hidden")||t.hasAttribute("inert")||t.getAttribute("aria-hidden")==="true")return false;let r=bm(t);if(r&&(r.display==="none"||r.visibility==="hidden"||r.visibility==="collapse"))return false;t=t.parentElement;}return true}function Kl(e){if(e.hasAttribute("disabled")||e.getAttribute("tabindex")==="-1")return false;let t=e.closest("fieldset[disabled]");if(t){let r=t.querySelector("legend");if(!r||!r.contains(e))return false}return Xl(e)}function Sa(e){return Array.from(e.querySelectorAll(Gl)).filter(Kl).sort((r,o)=>{let n=r.compareDocumentPosition(o);return n&Node.DOCUMENT_POSITION_FOLLOWING?-1:n&Node.DOCUMENT_POSITION_PRECEDING?1:0})}var hm={role:"dialog","aria-modal":true,tabIndex:-1};function ym(e,t){return t==="none"?null:t&&typeof t=="object"?t.current??e:t==="first"?Sa(e)[0]??e:e}function xm(e){return e?e.map(t=>t&&"current"in t?t.current:t).filter(t=>!!t):[]}function Uo(e){if(e)try{e.focus();}catch{}}function So(e){let{open:t}=e,r=useRef(null),o=useRef(e);return o.current=e,useEffect(()=>{if(!t)return;let n=r.current;if(!n)return;let a=n.ownerDocument,s=a.activeElement,{hideBackground:l,lockScroll:i,initialFocus:d,keepInteractive:u}=o.current;Vl(n);let p=l===false?void 0:As([n,...xm(u)]),b=i===false?void 0:_l(a);return Uo(ym(n,d)),()=>{p?.(),b?.(),Ol(n);let{returnFocus:m}=o.current;if(m===false)return;let f=a.activeElement;if(!(!f||f===a.body||n.contains(f)))return;let y=m&&typeof m=="object"?m.current:s;y&&a.contains(y)&&Uo(y);}},[t]),useEffect(()=>{if(!t)return;let n=r.current;if(!n)return;let a=n.ownerDocument,s=a.defaultView??a,l=d=>d?n.contains(d)?true:Na([n]).some(u=>u.contains(d)):false,i=d=>{if(d.defaultPrevented||!$l(n))return;let{closeOnEscape:u,trapFocus:p,onClose:b}=o.current;if(d.key==="Escape"){if(u===false)return;d.preventDefault(),b?.();return}if(d.key!=="Tab"||p===false)return;let m=a.activeElement;if(m&&!n.contains(m)&&l(m))return;let f=Sa(n);if(f.length===0){d.preventDefault(),Uo(n);return}let h=f[0],y=f[f.length-1];if(!m||!n.contains(m)){d.preventDefault(),Uo(d.shiftKey?y:h);return}if(d.shiftKey&&(m===h||m===n)){d.preventDefault(),Uo(y);return}!d.shiftKey&&m===y&&(d.preventDefault(),Uo(h));};return s.addEventListener("keydown",i),()=>s.removeEventListener("keydown",i)},[t]),{dialogRef:r,dialogProps:hm}}var Nm={left:{sm:"w-64",md:"w-80",lg:"w-96",xl:"w-[32rem]",full:"w-full",half:"w-1/2 h-full"},right:{sm:"w-64",md:"w-80",lg:"w-96",xl:"w-[32rem]",full:"w-full",half:"w-1/2 h-full"},top:{sm:"h-64",md:"h-80",lg:"h-96",xl:"h-[32rem]",full:"h-full",half:"w-1/2 h-full"},bottom:{sm:"h-64",md:"h-80",lg:"h-96",xl:"h-[32rem]",full:"h-full",half:"w-1/2 h-full"}},Sm={left:"left-0 top-0 bottom-0",right:"right-0 top-0 bottom-0",top:"top-0 left-0 right-0",bottom:"bottom-0 left-0 right-0"},jl={left:{enter:"animate-in slide-in-from-left duration-300",exit:"animate-out slide-out-to-left duration-200"},right:{enter:"animate-in slide-in-from-right duration-300",exit:"animate-out slide-out-to-right duration-200"},top:{enter:"animate-in slide-in-from-top duration-300",exit:"animate-out slide-out-to-top duration-200"},bottom:{enter:"animate-in slide-in-from-bottom duration-300",exit:"animate-out slide-out-to-bottom duration-200"}},Rm=jsx("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})});function ql({open:e,onClose:t,children:r,position:o="right",size:n="md",customWidth:a,customHeight:s,showOverlay:l=true,closeOnOverlayClick:i=true,closeOnEscape:d=true,title:u,footer:p,className:b,overlayClassName:m,closeLabel:f,"aria-label":h,trapFocus:y=true,initialFocus:C,returnFocus:v,lockScroll:E=true}){let k=!!(a||s),R=useRef(null),g=Ft(),T=`${useId()}-drawer-title`,{dialogRef:D,dialogProps:W}=So({open:e,onClose:t,closeOnEscape:d,trapFocus:y,initialFocus:C,returnFocus:v,lockScroll:E,keepInteractive:[R]}),V=useCallback(()=>{i&&t();},[i,t]);if(!e)return null;let _=jsxs(Fragment,{children:[l&&jsx("div",{ref:R,className:c("fixed inset-0 bg-black/50 z-40 transition-opacity",e?"animate-in fade-in duration-200":"animate-out fade-out duration-150",m),onClick:V,"aria-hidden":"true"}),jsxs("div",{ref:D,...W,"aria-labelledby":u?T:void 0,"aria-label":u?void 0:h,className:c("fixed z-50 bg-white dark:bg-gray-900","shadow-xl overflow-hidden","flex flex-col focus:outline-none",Sm[o],!k&&Nm[o][n],e?jl[o].enter:jl[o].exit,b),style:{...a?{width:a}:{},...s?{height:s}:{}},children:[u&&jsxs("div",{className:"flex items-center justify-between px-6 py-4 border-b border-gray-200 dark:border-gray-700",children:[jsx("h2",{id:T,className:"text-lg font-semibold text-gray-900 dark:text-white",children:u}),jsx("button",{type:"button",onClick:t,className:c("rounded-lg p-1.5 text-gray-400 hover:bg-gray-100 hover:text-gray-900","dark:hover:bg-gray-800 dark:hover:text-white","focus:outline-none focus:ring-2 focus:ring-gray-300 dark:focus:ring-gray-600"),"aria-label":f??g.closeDrawer,children:Rm})]}),jsx("div",{className:"flex-1 overflow-y-auto px-6 py-4",children:r}),p&&jsx("div",{className:"px-6 py-4 border-t border-gray-200 dark:border-gray-700",children:p})]})]});return typeof document<"u"?createPortal(_,document.body):_}ql.displayName="Drawer";var Dm={sm:{dropzone:"py-4 px-3",text:"text-xs",subtext:"text-[10px]",icon:"w-6 h-6",button:"px-2.5 py-1.5 text-xs",fileItem:"py-1 px-2 text-xs",gap:"gap-1"},md:{dropzone:"py-6 px-4",text:"text-sm",subtext:"text-xs",icon:"w-8 h-8",button:"px-3 py-2 text-sm",fileItem:"py-1.5 px-3 text-sm",gap:"gap-1.5"},lg:{dropzone:"py-8 px-6",text:"text-base",subtext:"text-sm",icon:"w-10 h-10",button:"px-4 py-2.5 text-base",fileItem:"py-2 px-4 text-base",gap:"gap-2"}},ed=e=>{if(e===0)return "0 B";let t=["B","KB","MB","GB"],r=Math.floor(Math.log(e)/Math.log(1024));return `${(e/Math.pow(1024,r)).toFixed(r===0?0:1)} ${t[r]}`},Hs=e=>e.webkitRelativePath||e.name,Im=jsx("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",strokeWidth:1.5,stroke:"currentColor",className:"w-full h-full",children:jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M3 16.5v2.25A2.25 2.25 0 005.25 21h13.5A2.25 2.25 0 0021 18.75V16.5m-13.5-9L12 3m0 0l4.5 4.5M12 3v13.5"})}),Mm=jsx("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",strokeWidth:1.5,stroke:"currentColor",className:"w-full h-full",children:jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M3.75 9.776c.112-.017.227-.026.344-.026h15.812c.117 0 .232.009.344.026m-16.5 0a2.25 2.25 0 00-1.883 2.542l.857 6a2.25 2.25 0 002.227 1.932H19.05a2.25 2.25 0 002.227-1.932l.857-6a2.25 2.25 0 00-1.883-2.542m-16.5 0V6A2.25 2.25 0 016 3.75h3.879a1.5 1.5 0 011.06.44l2.122 2.12a1.5 1.5 0 001.06.44H18A2.25 2.25 0 0120.25 9v.776"})}),Lm=0;async function Am(e){let t=[],r=async o=>{if(o.isFile){let n=await new Promise((a,s)=>o.file(a,s));t.push(n);}else if(o.isDirectory){let n=o.createReader(),a=()=>new Promise((l,i)=>n.readEntries(l,i)),s=await a();for(;s.length>0;){for(let l of s)await r(l);s=await a();}}};for(let o of e)await r(o);return t}function zm({value:e,onChange:t,accept:r,multiple:o=false,maxSize:n=10*1024*1024,maxFiles:a,mode:s="file",variant:l="dropzone",size:i="md",disabled:d=false,readOnly:u=false,label:p,helperText:b,error:m,showFileList:f=true,placeholder:h,browseLabel:y,browseFolderLabel:C,icon:v,onReject:E,className:k}){let[R,g]=useState([]),[P,T]=useState(false),D=useRef(null),W=useRef(null),V=useId(),_=e!==void 0,M=_?e.map((Y,le)=>({file:Y,id:`ctrl-${le}`})):R,w=Dm[i];useEffect(()=>{s==="directory"&&D.current&&D.current.setAttribute("webkitdirectory",""),s==="both"&&W.current&&W.current.setAttribute("webkitdirectory","");},[s]);let N=useMemo(()=>ed(n),[n]),x=useMemo(()=>r?r.split(",").map(Y=>Y.trim()).map(Y=>Y.startsWith(".")?Y.toUpperCase():Y.endsWith("/*")?Y.replace("/*","").toUpperCase():Y).join(", "):"All files",[r]),S=s==="directory"?"Drag & drop a folder here, or":s==="both"?"Drag & drop files or folders here, or":o?"Drag & drop files here, or":"Drag & drop a file here, or",I=s==="directory"?"Browse folder":"Browse",F="Browse folder",O=useCallback(Y=>{if(Y.size>n)return `File exceeds maximum size of ${N}`;if(r){let le=r.split(",").map(te=>te.trim()),xe=`.${Y.name.split(".").pop()?.toLowerCase()}`;if(!le.some(te=>te.startsWith(".")?xe===te.toLowerCase():te.endsWith("/*")?Y.type.startsWith(te.replace("/*","/")):Y.type===te))return `File type not accepted. Expected: ${x}`}return null},[r,x,n,N]),Z=useCallback(Y=>{if(d||u)return;let le=Array.from(Y),xe=[];for(let Se of le){let te=O(Se);te?E?.(Se,te):xe.push(Se);}if(xe.length!==0)if(_)if(o){let te=[...e??[],...xe],Ne=a?te.slice(0,a):te;t?.(Ne);}else t?.([xe[0]]);else g(Se=>{let te=xe.map(Ne=>({file:Ne,id:`file-${++Lm}`}));if(o){let Ne=[...Se,...te],De=a?Ne.slice(0,a):Ne,Ve=De.map(rt=>rt.file);return t?.(Ve),De}return t?.([xe[0]]),[te[0]]});},[d,u,_,o,a,e,t,E,O]),U=useCallback(Y=>{if(!(d||u)){if(_){let le=(e??[]).filter((xe,Se)=>Se!==Y);t?.(le);}else g(le=>{let xe=le.filter((Se,te)=>te!==Y);return t?.(xe.map(Se=>Se.file)),xe});D.current&&(D.current.value="");}},[d,u,_,e,t]),H=useCallback(()=>{d||u||(_?t?.([]):(g([]),t?.([])),D.current&&(D.current.value=""));},[d,u,_,t]),z=useCallback(Y=>{Y.target.files&&Y.target.files.length>0&&Z(Y.target.files);},[Z]),$=useCallback(Y=>{Y.preventDefault(),Y.stopPropagation(),!d&&!u&&T(true);},[d,u]),K=useCallback(Y=>{Y.preventDefault(),Y.stopPropagation(),T(false);},[]),se=useCallback(Y=>{if(Y.preventDefault(),Y.stopPropagation(),T(false),d||u)return;let le=Y.dataTransfer.items;if(le&&le.length>0&&(s==="directory"||s==="both")){let xe=[];for(let te=0;te<le.length;te++){let Ne=le[te].webkitGetAsEntry?.();Ne&&xe.push(Ne);}if(xe.some(te=>te.isDirectory)){Am(xe).then(te=>{te.length>0&&Z(te);});return}}Y.dataTransfer.files&&Y.dataTransfer.files.length>0&&Z(Y.dataTransfer.files);},[d,u,s,Z]),X=useCallback(()=>{!d&&!u&&D.current?.click();},[d,u]),ee=useCallback(()=>{!d&&!u&&W.current?.click();},[d,u]),L=M.length>0,q=v||(s==="directory"?Mm:Im),ge=f&&L&&jsxs("div",{className:c("flex flex-col",w.gap),children:[M.map((Y,le)=>jsxs("div",{className:c("flex items-center justify-between rounded-md border border-gray-200 dark:border-gray-700 bg-gray-50 dark:bg-gray-800/50",w.fileItem),children:[jsxs("div",{className:"flex items-center gap-2 min-w-0 flex-1",children:[jsx("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",strokeWidth:1.5,stroke:"currentColor",className:"w-4 h-4 shrink-0 text-gray-400 dark:text-gray-500",children:jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M19.5 14.25v-2.625a3.375 3.375 0 00-3.375-3.375h-1.5A1.125 1.125 0 0113.5 7.125v-1.5a3.375 3.375 0 00-3.375-3.375H8.25m2.25 0H5.625c-.621 0-1.125.504-1.125 1.125v17.25c0 .621.504 1.125 1.125 1.125h12.75c.621 0 1.125-.504 1.125-1.125V11.25a9 9 0 00-9-9z"})}),jsx("span",{className:"truncate text-gray-700 dark:text-gray-300",children:Hs(Y.file)}),jsxs("span",{className:"shrink-0 text-gray-400 dark:text-gray-500",children:["(",ed(Y.file.size),")"]})]}),!d&&!u&&jsx("button",{type:"button",onClick:()=>U(le),className:"shrink-0 ml-2 text-gray-400 hover:text-red-500 dark:text-gray-500 dark:hover:text-red-400 transition-colors cursor-pointer","aria-label":`Remove ${Hs(Y.file)}`,children:jsx("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",strokeWidth:1.5,stroke:"currentColor",className:"w-4 h-4",children:jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M6 18L18 6M6 6l12 12"})})})]},Y.id)),o&&M.length>1&&!d&&!u&&jsx("button",{type:"button",onClick:H,className:c("self-start text-gray-400 hover:text-red-500 dark:text-gray-500 dark:hover:text-red-400 transition-colors cursor-pointer",w.subtext),children:"Remove all"})]}),de=c("rounded-md border border-gray-300 dark:border-gray-600 bg-white dark:bg-gray-800 text-gray-700 dark:text-gray-200 font-medium transition-colors","hover:bg-gray-50 dark:hover:bg-gray-700","disabled:opacity-50 disabled:cursor-not-allowed cursor-pointer","focus:outline-none focus:ring-2 focus:ring-blue-500 focus:ring-offset-1",w.button,m&&"border-red-300 dark:border-red-600");return jsxs("div",{className:c("flex flex-col",w.gap,k),children:[p&&jsx("label",{htmlFor:V,className:c("block font-medium text-gray-700 dark:text-gray-300",w.text),children:p}),jsx("input",{ref:D,id:V,type:"file",accept:s!=="directory"?r:void 0,multiple:o,onChange:z,className:"sr-only",disabled:d||u,"aria-describedby":m?`${V}-error`:b?`${V}-helper`:void 0,"aria-invalid":!!m}),s==="both"&&jsx("input",{ref:W,type:"file",onChange:z,className:"sr-only",disabled:d||u,tabIndex:-1,"aria-hidden":"true"}),l==="dropzone"?jsxs("div",{role:s==="both"?"group":"button",tabIndex:s==="both"?void 0:d||u?-1:0,onClick:s==="both"?void 0:X,onKeyDown:s==="both"?void 0:Y=>{(Y.key==="Enter"||Y.key===" ")&&(Y.preventDefault(),X());},onDragOver:$,onDragLeave:K,onDrop:se,className:c("flex flex-col items-center justify-center rounded-lg border-2 border-dashed transition-colors",w.dropzone,P&&!d&&!u?"border-blue-500 bg-blue-50 dark:bg-blue-900/20":"border-gray-300 dark:border-gray-600 bg-white dark:bg-gray-800",!d&&!u&&"hover:border-blue-400 dark:hover:border-blue-500 hover:bg-gray-50 dark:hover:bg-gray-800/70",s!=="both"&&!d&&!u&&"cursor-pointer",d&&"opacity-50 cursor-not-allowed",u&&"cursor-default",m&&"border-red-300 dark:border-red-600"),"aria-label":s==="both"?"File and folder drop zone":h||S,children:[jsx("div",{className:c("text-gray-400 dark:text-gray-500 mb-2",w.icon,P&&"text-blue-500 dark:text-blue-400"),children:q}),jsxs("p",{className:c("text-gray-600 dark:text-gray-400",w.text),children:[h||S," ",!d&&!u&&s!=="both"&&jsx("span",{className:"text-blue-600 dark:text-blue-400 font-medium",children:y||I})]}),s==="both"&&!d&&!u&&jsxs("div",{className:c("flex items-center gap-3 mt-1",w.text),children:[jsx("button",{type:"button",onClick:X,className:"text-blue-600 dark:text-blue-400 font-medium hover:underline cursor-pointer focus:outline-none focus:ring-2 focus:ring-blue-500 focus:ring-offset-1 rounded",children:y||"Browse files"}),jsx("span",{className:"text-gray-300 dark:text-gray-600",children:"\xB7"}),jsx("button",{type:"button",onClick:ee,className:"text-blue-600 dark:text-blue-400 font-medium hover:underline cursor-pointer focus:outline-none focus:ring-2 focus:ring-blue-500 focus:ring-offset-1 rounded",children:C||F})]}),jsxs("p",{className:c("text-gray-400 dark:text-gray-500 mt-1",w.subtext),children:[x," - Max ",N,o&&a&&` - Up to ${a} files`]})]}):jsxs("div",{className:"flex items-center gap-2",children:[s==="both"?jsxs(Fragment,{children:[jsx("button",{type:"button",onClick:X,disabled:d||u,className:de,children:y||(L?"Change files":"Choose files")}),jsx("button",{type:"button",onClick:ee,disabled:d||u,className:de,children:C||"Choose folder"})]}):jsx("button",{type:"button",onClick:X,disabled:d||u,className:de,children:y||(s==="directory"?L?"Change folder":"Choose folder":L?"Change file":"Choose file")}),!L&&jsx("span",{className:c("text-gray-400 dark:text-gray-500",w.text),children:s==="directory"?"No folder selected":s==="both"?"No file or folder selected":"No file selected"}),L&&!f&&jsx("span",{className:c("text-gray-600 dark:text-gray-400 truncate",w.text),children:M.length===1?Hs(M[0].file):`${M.length} files selected`})]}),ge,m&&jsx("p",{id:`${V}-error`,className:c("text-red-600 dark:text-red-400",w.subtext),role:"alert",children:m}),b&&!m&&jsx("p",{id:`${V}-helper`,className:c("text-gray-400 dark:text-gray-500",w.subtext),children:b})]})}var od=createContext(null);function Yt(){let e=useContext(od);if(!e)throw new Error("Dropdown compound components must be used within a Dropdown");return e}function nd({open:e,defaultOpen:t=false,onOpenChange:r,closeOnSelect:o=true,closeOnClickOutside:n=true,closeOnEscape:a=true,modal:s=false,children:l}){let[i,d]=useState(t),u=e!==void 0,p=u?e:i,b=useRef(null),m=useRef(null),f=useRef([]),[h,y]=useState(-1),C=useRef(0),v=useId(),E={triggerId:`dropdown-trigger-${v}`,contentId:`dropdown-content-${v}`},k=useCallback(T=>{u||d(T),r?.(T),T||y(-1);},[u,r]),R=useCallback((T,D)=>{f.current&&(f.current[T]=D);},[]),g=useCallback(()=>C.current++,[]),P={isOpen:p,setIsOpen:k,triggerRef:b,contentRef:m,closeOnSelect:o,closeOnClickOutside:n,closeOnEscape:a,modal:s,focusedIndex:h,setFocusedIndex:y,itemsRef:f,registerItem:R,getNextItemIndex:g,triggerId:E.triggerId,contentId:E.contentId};return jsx(od.Provider,{value:P,children:jsx("div",{className:"relative inline-block",children:l})})}nd.displayName="Dropdown";var ad=memo(({isOpen:e})=>jsx("span",{className:c("inline-block transition-transform",e&&"rotate-180"),children:jsx("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24","aria-hidden":"true",children:jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 9l-7 7-7-7"})})}));ad.displayName="ChevronIcon";function sd({asChild:e=false,disabled:t=false,children:r,className:o}){let{isOpen:n,setIsOpen:a,triggerRef:s,triggerId:l,contentId:i}=Yt(),p={ref:s,id:l,"aria-haspopup":"menu","aria-expanded":n,"aria-controls":n?i:void 0,disabled:t,onClick:()=>{t||a(!n);},onKeyDown:b=>{t||((b.key==="Enter"||b.key===" ")&&(b.preventDefault(),a(!n)),b.key==="ArrowDown"&&!n&&(b.preventDefault(),a(true)));}};return e&&isValidElement(r)?cloneElement(r,{...p,className:c(r.props.className,o)}):jsxs("button",{type:"button",...p,className:c("inline-flex items-center justify-center gap-2","rounded-md px-4 py-2","bg-white border border-gray-300","text-sm font-medium text-gray-700","hover:bg-gray-50","focus:outline-none focus-visible:ring-2 focus-visible:ring-blue-500 focus-visible:ring-offset-2","disabled:opacity-50 disabled:cursor-not-allowed","transition-colors",o),children:[r,jsx(ad,{isOpen:n})]})}sd.displayName="DropdownTrigger";function Yo(e){let t=useRef(e);return useLayoutEffect(()=>{t.current=e;}),t}function jo(e,t,r=true){let o=Yo(t);useEffect(()=>{if(!r)return;let n=a=>{let s=a.target;!e.current||e.current.contains(s)||o.current();};return document.addEventListener("mousedown",n),document.addEventListener("touchstart",n,{passive:true}),()=>{document.removeEventListener("mousedown",n),document.removeEventListener("touchstart",n);}},[r,o,e]);}function qo({triggerRef:e,contentRef:t,isOpen:r,side:o="bottom",align:n="start",sideOffset:a=4,alignOffset:s=0,avoidCollisions:l=true,collisionPadding:i=8}){let[d,u]=useState({top:0,left:0,actualSide:o,actualAlign:n,isReady:false}),p=useRef(false),b=useCallback(()=>{if(!e.current||!t.current)return;let m=e.current.getBoundingClientRect(),f=t.current.getBoundingClientRect();if(!(m.width>0&&m.height>0&&f.width>0&&f.height>0)){p.current=false;return}let y={width:window.innerWidth,height:window.innerHeight},C=o,v=n,E=g=>{switch(g){case "bottom":return {top:m.bottom+a,left:m.left};case "top":return {top:m.top-f.height-a,left:m.left};case "right":return {top:m.top,left:m.right+a};case "left":return {top:m.top,left:m.left-f.width-a}}},k=(g,P,T)=>{if(g==="top"||g==="bottom")switch(P){case "start":return {...T,left:m.left+s};case "center":return {...T,left:m.left+m.width/2-f.width/2+s};case "end":return {...T,left:m.right-f.width+s}}else switch(P){case "start":return {...T,top:m.top+s};case "center":return {...T,top:m.top+m.height/2-f.height/2+s};case "end":return {...T,top:m.bottom-f.height+s}}},R=E(C);if(R=k(C,v,R),l){let{top:g,left:P}=R,{height:T,width:D}=f,{height:W,width:V}=y,_=g+T>W-i,M=g<i,w=P+D>V-i,N=P<i;C==="bottom"&&_&&!M?(C="top",R=E(C),R=k(C,v,R)):C==="top"&&M&&!_&&(C="bottom",R=E(C),R=k(C,v,R)),C==="right"&&w&&!N?(C="left",R=E(C),R=k(C,v,R)):C==="left"&&N&&!w&&(C="right",R=E(C),R=k(C,v,R));let x=R.left+D>V-i,S=R.left<i,I=R.top+T>W-i,F=R.top<i;(C==="top"||C==="bottom")&&(x&&(R.left=V-D-i,v="end"),S&&(R.left=i,v="start")),(C==="left"||C==="right")&&(I&&(R.top=W-T-i,v="end"),F&&(R.top=i,v="start"));}p.current=true,u({top:R.top,left:R.left,actualSide:C,actualAlign:v,isReady:true});},[e,t,o,n,a,s,l,i]);return useLayoutEffect(()=>{let m=0;if(r){p.current=false;let h=()=>{b(),p.current||(m=requestAnimationFrame(h));};m=requestAnimationFrame(h);}let f=()=>b();return window.addEventListener("resize",f),window.addEventListener("scroll",f,{passive:true,capture:true}),()=>{m&&cancelAnimationFrame(m),window.removeEventListener("resize",f),window.removeEventListener("scroll",f,{capture:true});}},[b,r]),d}function Pa({isOpen:e,onClose:t,itemsCount:r,focusedIndex:o,setFocusedIndex:n,onSelect:a,loop:s=true}){let l=Yo(t),i=Yo(a),d=Yo(o),u=useCallback(p=>{if(!(!e||r===0))switch(p.key){case "ArrowDown":p.preventDefault(),n(s?b=>b<r-1?b+1:0:b=>Math.min(b+1,r-1));break;case "ArrowUp":p.preventDefault(),n(s?b=>b>0?b-1:r-1:b=>Math.max(b-1,0));break;case "Home":p.preventDefault(),n(0);break;case "End":p.preventDefault(),n(r-1);break;case "Enter":case " ":p.preventDefault(),i.current?.(d.current);break;case "Escape":p.preventDefault(),l.current();break;case "Tab":l.current();break}},[e,r,n,s,l,i,d]);return useEffect(()=>{if(e)return document.addEventListener("keydown",u),()=>document.removeEventListener("keydown",u)},[e,u]),{focusedIndex:o}}function ld(e,t,r){useEffect(()=>{r&&e.current&&e.current[t]&&e.current[t]?.focus();},[t,r,e]);}var rf={fade:"animate-in fade-in-0 duration-200",scale:"animate-in fade-in-0 zoom-in-95 duration-200",slide:"animate-in fade-in-0 slide-in-from-top-2 duration-200",none:""};function cd({side:e="bottom",align:t="start",sideOffset:r=4,alignOffset:o=0,avoidCollisions:n=true,collisionPadding:a=8,minWidth:s,maxWidth:l,maxHeight:i=300,animation:d="scale",portal:u=true,children:p,className:b}){let{isOpen:m,setIsOpen:f,triggerRef:h,contentRef:y,closeOnClickOutside:C,closeOnEscape:v,modal:E,contentId:k,focusedIndex:R,setFocusedIndex:g,itemsRef:P}=Yt(),[T,D]=useState(false),W=qo({triggerRef:h,contentRef:y,isOpen:m,side:e,align:t,sideOffset:r,alignOffset:o,avoidCollisions:n,collisionPadding:a});jo(y,()=>{C&&f(false);},m);let V=P.current?.filter(Boolean).length||0,_=useCallback(w=>{let N=P.current?.[w];N&&!N.hasAttribute("data-disabled")&&N.click();},[P]);Pa({isOpen:m,onClose:()=>{v&&(f(false),h.current?.focus());},itemsCount:V,focusedIndex:R,setFocusedIndex:g,onSelect:_}),useEffect(()=>{let w=y.current;if(w)return No(w,()=>h.current)},[y,h]),useEffect(()=>{if(m&&P.current&&P.current.length>0){let w=setTimeout(()=>{g(0),P.current?.[0]?.focus();},10);return ()=>clearTimeout(w)}},[m,P,g]),useLayoutEffect(()=>{let w=0;if(!m){D(false);return}let N=()=>{let x=h.current?.getBoundingClientRect(),S=y.current?.getBoundingClientRect();if(W.isReady&&!!x&&!!S&&x.width>0&&x.height>0&&S.width>0&&S.height>0){D(true);return}w=requestAnimationFrame(N);};return D(false),w=requestAnimationFrame(N),()=>{w&&cancelAnimationFrame(w);}},[m,W.isReady,h,y]);let M=jsxs(Fragment,{children:[E&&m&&jsx("div",{className:"fixed inset-0 z-40 bg-black/20",onClick:()=>f(false)}),jsx("div",{ref:y,id:k,role:"menu","aria-orientation":"vertical","aria-hidden":!m,tabIndex:-1,style:{position:"fixed",top:W.top,left:W.left,minWidth:s??h.current?.offsetWidth,maxWidth:l,maxHeight:i,visibility:m&&T?"visible":"hidden",opacity:m&&T?1:0,pointerEvents:m&&T?"auto":"none"},className:c("z-50 overflow-auto rounded-lg","border border-gray-200 bg-white shadow-lg","dark:border-gray-700 dark:bg-gray-800",m&&T&&rf[d],b),children:jsx("div",{className:"py-1",children:p})})]});return u&&typeof document<"u"?createPortal(M,document.body):M}cd.displayName="DropdownContent";var df={default:"text-gray-700 dark:text-gray-200 hover:bg-gray-100 dark:hover:bg-gray-700",danger:"text-red-600 dark:text-red-400 hover:bg-red-50 dark:hover:bg-red-900/20",success:"text-green-600 dark:text-green-400 hover:bg-green-50 dark:hover:bg-green-900/20"};function pd({children:e,icon:t,iconPosition:r="left",description:o,shortcut:n,variant:a="default",closeOnSelect:s,onSelect:l,disabled:i=false,className:d,onClick:u,index:p,...b}){let{setIsOpen:m,closeOnSelect:f,focusedIndex:h,setFocusedIndex:y,registerItem:C,getNextItemIndex:v}=Yt(),E=useRef(null),[k]=useState(()=>p??v());useEffect(()=>(C(k,E.current),()=>{C(k,null);}),[k,C]);let R=s??f,g=h===k;return jsxs("button",{ref:E,role:"menuitem",type:"button",tabIndex:g?0:-1,disabled:i,"data-disabled":i||void 0,"data-focused":g||void 0,onClick:D=>{i||(l?.(),u?.(D),R&&m(false));},onMouseEnter:()=>{i||y(k);},className:c("relative flex w-full items-center px-3 py-2 text-left text-sm","outline-none transition-colors","focus:bg-gray-100 dark:focus:bg-gray-700",df[a],i&&"opacity-50 cursor-not-allowed hover:bg-transparent",g&&"bg-gray-100 dark:bg-gray-700",d),...b,children:[t&&r==="left"&&jsx("span",{className:"mr-2 shrink-0 w-5 h-5",children:t}),jsxs("span",{className:"flex-1 min-w-0",children:[jsx("span",{className:"block truncate",children:e}),o&&jsx("span",{className:"block text-xs text-gray-500 dark:text-gray-400 truncate",children:o})]}),t&&r==="right"&&jsx("span",{className:"ml-2 shrink-0 w-5 h-5",children:t}),n&&jsx("span",{className:"ml-auto pl-4 text-xs text-gray-400 dark:text-gray-500",children:n})]})}pd.displayName="DropdownItem";function gd({className:e}){return jsx("hr",{className:c("my-1 h-px border-0 bg-gray-200 dark:bg-gray-700",e)})}gd.displayName="DropdownSeparator";function md({children:e,className:t}){return jsx("div",{className:c("px-3 py-1.5 text-xs font-semibold text-gray-500 dark:text-gray-400",t),children:e})}md.displayName="DropdownLabel";function yd({checked:e,defaultChecked:t=false,onCheckedChange:r,children:o,icon:n,description:a,disabled:s=false,closeOnChange:l=false,className:i,index:d}){let{setIsOpen:u,focusedIndex:p,setFocusedIndex:b,registerItem:m,getNextItemIndex:f}=Yt(),h=useRef(null),[y]=useState(()=>d??f()),[C,v]=useState(t),E=e!==void 0,k=E?e:C;useEffect(()=>(m(y,h.current),()=>{m(y,null);}),[y,m]);let R=p===y;return jsxs("button",{ref:h,role:"menuitemcheckbox",type:"button",tabIndex:R?0:-1,"aria-checked":k,disabled:s,"data-disabled":s||void 0,"data-focused":R||void 0,onClick:()=>{if(s)return;let T=!k;E||v(T),r?.(T),l&&u(false);},onMouseEnter:()=>{s||b(y);},className:c("relative flex w-full items-center px-3 py-2 text-left text-sm","outline-none transition-colors","text-gray-700 dark:text-gray-200","hover:bg-gray-100 dark:hover:bg-gray-700","focus:bg-gray-100 dark:focus:bg-gray-700",s&&"opacity-50 cursor-not-allowed hover:bg-transparent",R&&"bg-gray-100 dark:bg-gray-700",i),children:[jsx("span",{className:"mr-2 shrink-0 w-4 h-4",children:n||jsx("span",{className:c("flex items-center justify-center w-4 h-4 rounded border-2 transition-colors",k?"bg-blue-600 border-blue-600":"border-gray-300 dark:border-gray-600"),children:k&&jsx("svg",{className:"w-3 h-3 text-white",viewBox:"0 0 16 16",fill:"none",children:jsx("path",{d:"M13.5 4.5L6 12L2.5 8.5",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round"})})})}),jsxs("span",{className:"flex-1 min-w-0",children:[jsx("span",{className:"block truncate",children:o}),a&&jsx("span",{className:"block text-xs text-gray-500 dark:text-gray-400 truncate",children:a})]})]})}yd.displayName="DropdownCheckboxItem";var kd=createContext(null);function yf(){let e=useContext(kd);if(!e)throw new Error("DropdownRadioItem must be used within a DropdownRadioGroup");return e}function wd({value:e,defaultValue:t="",onValueChange:r,children:o,className:n}){let[a,s]=useState(t),l=e!==void 0,i=l?e:a,d=useCallback(p=>{l||s(p),r?.(p);},[l,r]),u=useMemo(()=>({value:i,onValueChange:d}),[i,d]);return jsx(kd.Provider,{value:u,children:jsx("div",{role:"group",className:n,children:o})})}wd.displayName="DropdownRadioGroup";function Cd({value:e,children:t,icon:r,description:o,disabled:n=false,closeOnChange:a=true,className:s,index:l}){let{value:i,onValueChange:d}=yf(),{setIsOpen:u,focusedIndex:p,setFocusedIndex:b,registerItem:m,getNextItemIndex:f}=Yt(),h=useRef(null),[y]=useState(()=>l??f()),C=i===e;useEffect(()=>(m(y,h.current),()=>{m(y,null);}),[y,m]);let v=p===y;return jsxs("button",{ref:h,role:"menuitemradio",type:"button",tabIndex:v?0:-1,"aria-checked":C,disabled:n,"data-disabled":n||void 0,"data-focused":v||void 0,onClick:()=>{n||(d(e),a&&u(false));},onMouseEnter:()=>{n||b(y);},className:c("relative flex w-full items-center px-3 py-2 text-left text-sm","outline-none transition-colors","text-gray-700 dark:text-gray-200","hover:bg-gray-100 dark:hover:bg-gray-700","focus:bg-gray-100 dark:focus:bg-gray-700",n&&"opacity-50 cursor-not-allowed hover:bg-transparent",v&&"bg-gray-100 dark:bg-gray-700",s),children:[jsx("span",{className:"mr-2 shrink-0 w-4 h-4",children:r||jsx("span",{className:c("flex items-center justify-center w-4 h-4 rounded-full border-2 transition-colors",C?"border-blue-600":"border-gray-300 dark:border-gray-600"),children:C&&jsx("span",{className:"w-2 h-2 rounded-full bg-blue-600"})})}),jsxs("span",{className:"flex-1 min-w-0",children:[jsx("span",{className:"block truncate",children:t}),o&&jsx("span",{className:"block text-xs text-gray-500 dark:text-gray-400 truncate",children:o})]}),C&&!r&&jsx("svg",{className:"ml-auto w-4 h-4 text-blue-600",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M5 13l4 4L19 7"})})]})}Cd.displayName="DropdownRadioItem";var Td=createContext(null);function Pd(){let e=useContext(Td);if(!e)throw new Error("DropdownSubMenu components must be used within a DropdownSubMenu");return e}function Ed({children:e}){let[t,r]=useState(false),o=useRef(null),n=useRef(null),a=useMemo(()=>({isOpen:t,setIsOpen:r,triggerRef:o,contentRef:n}),[t]);return jsx(Td.Provider,{value:a,children:jsx("div",{className:"relative",children:e})})}Ed.displayName="DropdownSubMenu";var Sd=0;function Dd({children:e,icon:t,disabled:r=false,className:o,index:n}){let{isOpen:a,setIsOpen:s,triggerRef:l}=Pd(),{focusedIndex:i,setFocusedIndex:d,registerItem:u}=Yt(),p=useRef(n??-1);useEffect(()=>(n===void 0&&(p.current=Sd++),u(p.current,l.current),()=>{u(p.current,null);}),[n,u,l]),useEffect(()=>()=>{Sd=0;},[]);let b=i===p.current;return jsxs("button",{ref:l,role:"menuitem",type:"button",tabIndex:b?0:-1,"aria-haspopup":"menu","aria-expanded":a,disabled:r,"data-disabled":r||void 0,"data-focused":b||void 0,onMouseEnter:()=>{r||(d(p.current),s(true));},onMouseLeave:()=>{setTimeout(()=>{s(false);},100);},onKeyDown:y=>{r||(y.key==="ArrowRight"||y.key==="Enter")&&(y.preventDefault(),s(true));},className:c("relative flex w-full items-center px-3 py-2 text-left text-sm","outline-none transition-colors","text-gray-700 dark:text-gray-200","hover:bg-gray-100 dark:hover:bg-gray-700","focus:bg-gray-100 dark:focus:bg-gray-700",r&&"opacity-50 cursor-not-allowed hover:bg-transparent",b&&"bg-gray-100 dark:bg-gray-700",o),children:[t&&jsx("span",{className:"mr-2 shrink-0 w-5 h-5",children:t}),jsx("span",{className:"flex-1",children:e}),jsx("svg",{className:"ml-auto w-4 h-4 text-gray-400",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 5l7 7-7 7"})})]})}Dd.displayName="DropdownSubMenuTrigger";function Id({children:e,sideOffset:t=0,className:r}){let{isOpen:o,setIsOpen:n,triggerRef:a,contentRef:s}=Pd(),[l,i]=useState(false),d=qo({triggerRef:a,contentRef:s,isOpen:o,side:"right",align:"start",sideOffset:t,avoidCollisions:true});jo(s,()=>n(false),o),useEffect(()=>{let f=s.current;if(f)return No(f,()=>a.current)},[s,a]);let u=useCallback(()=>{n(true);},[n]),p=useCallback(()=>{n(false);},[n]),b=f=>{(f.key==="ArrowLeft"||f.key==="Escape")&&(f.preventDefault(),n(false),a.current?.focus());};useLayoutEffect(()=>{let f=0;if(!o){i(false);return}let h=()=>{let y=a.current?.getBoundingClientRect(),C=s.current?.getBoundingClientRect();if(d.isReady&&!!y&&!!C&&y.width>0&&y.height>0&&C.width>0&&C.height>0){i(true);return}f=requestAnimationFrame(h);};return i(false),f=requestAnimationFrame(h),()=>{f&&cancelAnimationFrame(f);}},[o,d.isReady,a,s]);let m=jsx("div",{ref:s,role:"menu","aria-orientation":"vertical","aria-hidden":!o,tabIndex:-1,onMouseEnter:u,onMouseLeave:p,onKeyDown:b,style:{position:"fixed",top:d.top,left:d.left,visibility:o&&l?"visible":"hidden",opacity:o&&l?1:0,pointerEvents:o&&l?"auto":"none"},className:c("z-50 min-w-40 overflow-hidden rounded-lg","border border-gray-200 bg-white shadow-lg","dark:border-gray-700 dark:bg-gray-800",o&&l&&"animate-in fade-in-0 zoom-in-95 duration-150",r),children:jsx("div",{className:"py-1",children:e})});return typeof document<"u"?createPortal(m,document.body):m}Id.displayName="DropdownSubMenuContent";var Sf=(e="md")=>({sm:"text-xs p-1.5",md:"text-sm p-2.5",lg:"text-base p-3.5"})[e],Jo=({size:e="md",error:t,disabled:r,readOnly:o,icon:n,iconPosition:a})=>c("bg-gray-50 rounded-lg block w-full","border focus:outline-none focus:ring-0","dark:bg-gray-700 dark:placeholder-gray-400",Sf(e),n&&a==="left"?"pl-9":"",n&&a==="right"?"pr-9":"",r?"opacity-50 cursor-not-allowed":"",o?"bg-gray-100 dark:bg-gray-600 cursor-default":"",t?"border-red-500 dark:border-red-500":"border-gray-300 dark:border-gray-600"),Md=(e,t)=>c("text-sm font-medium",e?"min-w-[120px]":"block mb-2",!t&&"text-gray-900 dark:text-white"),Ld=e=>c("mt-1 text-xs",e?"text-red-500 dark:text-red-400":"text-gray-500 dark:text-gray-400"),To=e=>c("absolute inset-y-0 flex items-center pointer-events-none",e==="left"?"left-2.5":"right-2.5");var Qo=({label:e,hideLabel:t,labelColor:r,error:o,helperText:n,inline:a,children:s,htmlFor:l})=>jsxs("div",{className:a?"flex items-center gap-4":"flex flex-col",children:[e&&!t&&jsx("label",{htmlFor:l,className:Md(a||false,r),style:r?{color:r}:void 0,children:e}),jsx("div",{className:a?"flex-1":"w-full",children:s}),n&&jsx("p",{className:c(Ld(o),a&&"ml-34"),children:n})]});var Er=forwardRef(({label:e,inline:t=false,size:r="md",labelColor:o,borderColor:n,textColor:a,disabled:s=false,readOnly:l=false,error:i=false,helperText:d,hideLabel:u=false,icon:p,iconPosition:b="left",multiline:m=false,rows:f=3,focused:h=false,className:y,...C},v)=>{let E=useRef(null),k=W=>{E.current=W,typeof v=="function"?v(W):v&&(v.current=W);};useEffect(()=>{h&&E.current?.focus();},[h]);let R=useId(),g=c(Jo({size:r,error:i,disabled:s,readOnly:l,icon:p,iconPosition:b}),m&&"resize-vertical",y),P={...n&&{borderColor:n},...a&&{color:a}},T=n||a?P:void 0;return jsx(Qo,{label:e,hideLabel:u,labelColor:o,error:i,helperText:d,inline:t,htmlFor:R,children:jsxs("div",{className:"relative w-full",children:[p&&jsx("span",{className:To(b),children:p}),m?jsx("textarea",{ref:k,id:R,disabled:s,readOnly:l,rows:f,tabIndex:l||s?-1:void 0,className:g,style:T,...C}):jsx("input",{ref:k,id:R,disabled:s,readOnly:l,tabIndex:l||s?-1:void 0,className:g,style:T,...C})]})})});Er.displayName="Input";var Wf=e=>jsxs("div",{className:"flex items-center gap-2 px-3 py-2 hover:bg-gray-100 dark:hover:bg-gray-700 cursor-pointer",children:[e.avatar&&jsx("img",{src:e.avatar,alt:e.label,className:"w-6 h-6 rounded-full"}),jsx("span",{className:"text-sm text-gray-900 dark:text-white",children:e.label})]}),Gs=forwardRef(({label:e,inline:t=false,size:r="md",labelColor:o,borderColor:n,textColor:a,disabled:s=false,readOnly:l=false,error:i=false,helperText:d,hideLabel:u=false,icon:p,iconPosition:b="left",mentionTrigger:m="@",suggestions:f=[],onMentionSearch:h,onMentionSelect:y,onMentionRemove:C,renderSuggestion:v,value:E,onChange:k,placeholder:R,loading:g=false,maxSuggestions:P=10,chipVariant:T="soft",chipColor:D="primary",chipSize:W="sm"},V)=>{let _=useId(),M=useRef(null),[w,N]=useState(false),[x,S]=useState(0),[I,F]=useState(""),O=c(Jo({size:r,error:i,disabled:s,readOnly:l,icon:p,iconPosition:b}),"min-h-[42px]","whitespace-pre-wrap","break-words"),Z={...n&&{borderColor:n},...a&&{color:a}},U=n||a?Z:void 0,H=useCallback(()=>{if(!M.current)return {text:"",mentions:[]};let L="",q=[],ge=0,de=Y=>{if(Y.nodeType===Node.TEXT_NODE)L+=Y.textContent||"",ge+=(Y.textContent||"").length;else if(Y.nodeType===Node.ELEMENT_NODE){let le=Y;if(le.hasAttribute("data-mention-id")){let xe=le.getAttribute("data-mention-id"),Se=le.getAttribute("data-mention-label")||"",te=le.getAttribute("data-mention-avatar")||void 0,Ne=`@${Se}`,De=ge;q.push({trigger:m,suggestion:{id:xe||"",label:Se,avatar:te},startIndex:De,endIndex:De+Ne.length}),L+=Ne,ge+=Ne.length;}else le.childNodes.forEach(de);}};return M.current.childNodes.forEach(de),{text:L,mentions:q}},[m]),z=useCallback((L,q)=>{let ge=document.createElement("span");return ge.contentEditable="false",ge.setAttribute("data-mention-id",L.id),ge.setAttribute("data-mention-label",L.label),L.avatar&&ge.setAttribute("data-mention-avatar",L.avatar),ge.className="inline-block align-middle mx-0.5",ge.style.userSelect="none",createRoot(ge).render(jsx(ka,{label:L.label,variant:T,color:D,size:W,closable:!s&&!l,onClose:q,disabled:s,avatar:L.avatar?jsx("img",{src:L.avatar,alt:L.label,className:"w-full h-full object-cover"}):void 0})),ge},[T,D,W,s,l]),$=useCallback(L=>{if(!M.current)return;let q=M.current.querySelector(`[data-mention-id="${L}"]`);if(q){q.remove();let ge=H();k?.(ge);let de=E?.mentions.find(Y=>Y.suggestion.id===L)?.suggestion;de&&C?.(de);}},[H,k,C,E?.mentions]),K=useCallback(()=>{if(!M.current)return;let L=window.getSelection();if(!L||L.rangeCount===0)return;let q=L.getRangeAt(0),ge="";q.startContainer.nodeType===Node.TEXT_NODE&&(ge=q.startContainer.textContent?.substring(0,q.startOffset)||"");let de=ge.match(new RegExp(`${m}(\\w*)$`));if(de){let le=de[1];F(le),N(true),S(0),h?.(le);}else N(false),F("");let Y=H();k?.(Y);},[m,h,k,H]),se=useCallback(L=>{if(!M.current)return;let q=window.getSelection();if(!q||q.rangeCount===0)return;let ge=q.getRangeAt(0);if(ge.startContainer.nodeType===Node.TEXT_NODE){let Y=ge.startContainer,le=Y.textContent||"",xe=ge.startOffset,te=le.substring(0,xe).lastIndexOf(m);if(te!==-1){let Ne=le.substring(0,te),De=le.substring(xe),Ve=z(L,()=>{$(L.id);});if(Ne?(Y.textContent=Ne,Y.parentNode?.insertBefore(Ve,Y.nextSibling)):(Y.parentNode?.insertBefore(Ve,Y),Y.textContent="",Y.textContent||Y.remove()),De){let re=document.createTextNode(De);Ve.parentNode?.insertBefore(re,Ve.nextSibling);}let rt=document.createTextNode(" ");Ve.parentNode?.insertBefore(rt,Ve.nextSibling);let dt=document.createRange();dt.setStartAfter(rt),dt.collapse(true),q.removeAllRanges(),q.addRange(dt);}}N(false),F("");let de=H();k?.(de),y?.(L),M.current.focus();},[m,z,$,H,k,y]),X=useCallback(L=>{let q=f.slice(0,P);if(w&&q.length>0)switch(L.key){case "ArrowDown":L.preventDefault(),S(ge=>ge<q.length-1?ge+1:0);return;case "ArrowUp":L.preventDefault(),S(ge=>ge>0?ge-1:q.length-1);return;case "Enter":case "Tab":L.preventDefault(),q[x]&&se(q[x]);return;case "Escape":L.preventDefault(),N(false);return}if(L.key==="Backspace"){let ge=window.getSelection();if(!ge||ge.rangeCount===0)return;let de=ge.getRangeAt(0);if(de.collapsed&&de.startOffset===0){let Y=de.startContainer.previousSibling;if(Y&&Y.nodeType===Node.ELEMENT_NODE){let le=Y;if(le.hasAttribute("data-mention-id")){L.preventDefault();let xe=le.getAttribute("data-mention-id");xe&&$(xe);return}}}if(de.collapsed&&de.startContainer.nodeType===Node.TEXT_NODE){let Y=de.startContainer;if(de.startOffset===0){let le=Y.previousSibling;if(le&&le.nodeType===Node.ELEMENT_NODE){let xe=le;if(xe.hasAttribute("data-mention-id")){L.preventDefault();let Se=xe.getAttribute("data-mention-id");Se&&$(Se);return}}}}}},[w,f,x,P,se,$]);return useEffect(()=>{M.current&&(!(M.current.textContent||M.current.querySelector("[data-mention-id]"))&&R?M.current.setAttribute("data-placeholder",R):M.current.removeAttribute("data-placeholder"));},[R,E]),useEffect(()=>{M.current&&E?.text===""&&E?.mentions.length===0&&M.current.innerHTML.trim()&&(M.current.innerHTML="");},[E?.text,E?.mentions.length]),jsx(Qo,{label:e,hideLabel:u,labelColor:o,error:i,helperText:d,inline:t,htmlFor:_,children:jsxs("div",{className:"relative w-full",children:[p&&jsx("span",{className:To(b),children:p}),jsx("div",{ref:L=>{typeof V=="function"?V(L):V&&(V.current=L),M.current=L;},id:_,contentEditable:!s&&!l,suppressContentEditableWarning:true,onInput:K,onKeyDown:X,className:c(O,"empty:before:content-[attr(data-placeholder)] empty:before:text-gray-400 empty:before:dark:text-gray-500"),style:U,role:"textbox","aria-label":e,"aria-multiline":"true",tabIndex:l||s?-1:0}),w&&f.length>0&&jsx("div",{className:"absolute z-10 mt-1 w-full max-h-60 overflow-auto rounded-lg border border-gray-300 bg-white dark:bg-gray-700 dark:border-gray-600 shadow-lg",children:g?jsx("div",{className:"px-3 py-2 text-sm text-gray-500 dark:text-gray-400",children:"Loading..."}):f.slice(0,P).map((L,q)=>jsx("div",{onClick:()=>se(L),className:c(q===x&&"bg-gray-100 dark:bg-gray-600"),children:v?v(L):Wf(L)},L.id))})]})})});Gs.displayName="MentionInput";var Xs=forwardRef(({label:e,inline:t=false,size:r="md",labelColor:o,borderColor:n,textColor:a,disabled:s=false,readOnly:l=false,error:i=false,helperText:d,hideLabel:u=false,icon:p,iconPosition:b="left",className:m,value:f,onChange:h,format:y="number",currency:C="USD",locale:v="en-US",decimals:E,min:k,max:R,step:g=1,prefix:P,suffix:T,thousandSeparator:D=true,allowNegative:W=true,onBlur:V,onFocus:_,...M},w)=>{let N=useId(),[x,S]=useState(null),I=useMemo(()=>{let ee=y==="currency"?{style:"currency",currency:C,minimumFractionDigits:E??2,maximumFractionDigits:E??2}:y==="percentage"?{minimumFractionDigits:E??0,maximumFractionDigits:E??2}:{minimumFractionDigits:E??0,maximumFractionDigits:E??(y==="decimal"?2:0),useGrouping:D};try{return new Intl.NumberFormat(v,ee)}catch{return null}},[y,C,v,E,D]),F=ee=>{if(ee==null)return "";if(!I)return String(ee);let L=I.format(ee);return y==="percentage"?(L=P?`${P}${L}`:L,L=T||!L.includes("%")?`${L}%`:L,L):(P&&(L=`${P}${L}`),T&&(L=`${L}${T}`),L)},O=ee=>{if(!ee||ee.trim()==="")return null;let L=ee;if(P&&(L=L.replace(P,"")),T&&(L=L.replace(T,"")),L=L.replace(/[^\d.,-]/g,""),v.includes("fr")||v.includes("de")?L=L.replace(/\s/g,"").replace(",","."):L=L.replace(",",""),!L||L==="-"||L===".")return null;let q=parseFloat(L);return isNaN(q)?null:!W&&q<0?Math.abs(q):k!==void 0&&q<k?k:R!==void 0&&q>R?R:q},Z=x??F(f??null),U=ee=>{let L=v.includes("fr")||v.includes("de")?",":".";return new RegExp(`^-?[0-9${L===","?",":"\\."}]*$`).test(ee)},H=ee=>{let L=ee.target.value;if(L===""||U(L)){S(L);let q=O(L);h&&h(q);}},z=ee=>{let L=v.includes("fr")||v.includes("de")?",":".",q=["Backspace","Delete","Tab","Escape","Enter","ArrowLeft","ArrowRight","ArrowUp","ArrowDown","Home","End"],ge=/^[0-9]$/.test(ee.key),de=ee.key===L,Y=ee.key==="-"&&W&&Z.indexOf("-")===-1,le=ee.ctrlKey||ee.metaKey;!ge&&!de&&!Y&&!q.includes(ee.key)&&!le&&ee.preventDefault();},$=ee=>{let L=f!=null?String(f):"";S(L),_&&_(ee);},K=ee=>{let L=O(x??"");h&&L!==f&&h(L),S(null),V&&V(ee);},se=c(Jo({size:r,error:i,disabled:s,readOnly:l,icon:p,iconPosition:b}),n&&`border-[${n}]`,a&&`text-[${a}]`,m),X=jsxs("div",{className:"relative",children:[p&&b==="left"&&jsx("div",{className:To(b),children:p}),jsx("input",{ref:w,id:N,type:"text",inputMode:"decimal",className:se,style:{borderColor:n,color:a},disabled:s,readOnly:l,value:Z,onChange:H,onKeyDown:z,onFocus:$,onBlur:K,...M}),p&&b==="right"&&jsx("div",{className:To(b),children:p})]});return jsx(Qo,{label:e,hideLabel:u,labelColor:o,error:i,helperText:d,inline:t,htmlFor:N,children:X})});Xs.displayName="NumberInput";function $f({logo:e,logoHref:t="/",onLogoClick:r,navItems:o=[],actions:n,rightContent:a,variant:s="default",size:l="md",backgroundColor:i,textColor:d,hoverColor:u,navItemTextColor:p,navItemHoverColor:b,navItemBgHover:m,navItemActiveColor:f,sticky:h=false,fixed:y=false,showSearch:C=false,onSearch:v,searchPlaceholder:E="Search...",className:k,containerClassName:R}){let[g,P]=useState(false),[T,D]=useState(null),[W,V]=useState(""),_=()=>{P(!g);},M=H=>{D(T===H?null:H);},w=H=>{H.preventDefault(),v&&v(W);},N=c(h&&"sticky top-0 z-50",y&&"fixed top-0 left-0 right-0 z-50"),x=c(s==="default"&&!i&&"bg-neutral text-white",s==="transparent"&&!i&&"bg-transparent",s==="bordered"&&!i&&"bg-white border-b border-gray-200 text-gray-900 dark:bg-gray-900 dark:border-gray-800 dark:text-gray-100",s==="shadow"&&!i&&"bg-white shadow-md text-gray-900 dark:bg-gray-900 dark:text-gray-100"),S=c(l==="sm"&&"py-2",l==="md"&&"py-4",l==="lg"&&"py-6"),I=i||"",F=d||"",O=u||"",Z=c(N,x,S,I,F,k),U=(H,z,$=false)=>{let K=H.children&&H.children.length>0,se=T===z,X=c("px-4 py-2 transition-colors flex items-center gap-2",$?"block w-full text-left":"inline-flex",H.active&&"font-semibold border-b-2",H.active&&(f||"border-current"),p||(s==="default"||s==="transparent"?"text-gray-300":"text-gray-600 dark:text-gray-300"),b||O||(s==="default"||s==="transparent"?"hover:text-white":"hover:text-blue-600 dark:hover:text-blue-400"),m||"");if(K)return jsxs("div",{className:$?"w-full":"relative",children:[jsxs("button",{type:"button",onClick:()=>M(z),className:X,children:[H.icon&&jsx("span",{className:"w-5 h-5",children:H.icon}),jsx("span",{children:H.label}),H.badge&&jsx("span",{className:"bg-red-500 text-white text-xs px-2 py-0.5 rounded-full",children:H.badge}),jsx("svg",{className:c("w-4 h-4 transition-transform",se&&"rotate-180"),fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 9l-7 7-7-7"})})]}),se&&jsx("div",{className:c("bg-white shadow-lg rounded-lg overflow-hidden dark:bg-gray-800 dark:shadow-black/40",$?"mt-2 mb-2":"absolute top-full left-0 mt-1 min-w-[200px]"),children:H.children?.map(L=>jsx("a",{href:L.href,onClick:L.onClick,target:L.external?"_blank":void 0,rel:L.external?"noopener noreferrer":void 0,className:"block px-4 py-2 text-gray-700 hover:bg-gray-100 transition-colors dark:text-gray-200 dark:hover:bg-gray-700",children:jsxs("div",{className:"flex items-center gap-2",children:[L.icon&&jsx("span",{className:"w-5 h-5",children:L.icon}),jsx("span",{children:L.label}),L.badge&&jsx("span",{className:"bg-red-500 text-white text-xs px-2 py-0.5 rounded-full ml-auto",children:L.badge}),L.external&&jsx("svg",{className:"w-4 h-4 ml-auto",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M10 6H6a2 2 0 00-2 2v10a2 2 0 002 2h10a2 2 0 002-2v-4M14 4h6m0 0v6m0-6L10 14"})})]})},L.href??L.label))})]},H.href??H.label);let ee=jsxs(Fragment,{children:[H.icon&&jsx("span",{className:"w-5 h-5",children:H.icon}),jsx("span",{children:H.label}),H.badge&&jsx("span",{className:"bg-red-500 text-white text-xs px-2 py-0.5 rounded-full",children:H.badge}),H.external&&jsx("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M10 6H6a2 2 0 00-2 2v10a2 2 0 002 2h10a2 2 0 002-2v-4M14 4h6m0 0v6m0-6L10 14"})})]});return H.onClick?jsx("button",{type:"button",onClick:H.onClick,className:X,children:ee},H.href??H.label):jsx("a",{href:H.href,target:H.external?"_blank":void 0,rel:H.external?"noopener noreferrer":void 0,className:X,children:ee},H.href??H.label)};return jsxs("header",{className:Z,children:[jsxs("nav",{className:c("container mx-auto flex items-center justify-between px-4",R),children:[e&&jsx("div",{className:"flex items-center",children:t?jsx("a",{href:t,onClick:r,className:"flex items-center hover:opacity-80 transition-opacity",children:e}):jsx("div",{className:"flex items-center",children:e})}),C&&jsx("form",{onSubmit:w,className:"hidden md:flex flex-1 max-w-md mx-8",children:jsx("input",{type:"search","aria-label":E,value:W,onChange:H=>V(H.target.value),placeholder:E,className:"w-full px-4 py-2 rounded-lg border border-gray-300 focus:outline-none focus:ring-2 focus:ring-blue-500 text-gray-900 dark:border-gray-700 dark:bg-gray-800 dark:text-gray-100 dark:placeholder-gray-500"})}),jsx("div",{className:"hidden md:flex items-center gap-2",children:o.map((H,z)=>U(H,z,false))}),(n||a)&&jsxs("div",{className:"hidden md:flex items-center gap-2 ml-4",children:[n,a]}),o.length>0&&jsx("div",{className:"md:hidden",children:jsx("button",{type:"button",className:c("inline-flex rounded-lg border-2 p-2 w-10 h-10 justify-center transition-colors focus:outline-none",s==="default"||s==="transparent"?"text-gray-300 hover:text-white":"text-gray-600 hover:text-gray-900 dark:text-gray-300 dark:hover:text-gray-100"),onClick:_,"aria-label":"Toggle menu","aria-expanded":g,children:jsx("svg",{className:"w-5 h-5","aria-hidden":"true",xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 17 14",children:jsx("path",{stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",d:"M1 1h15M1 7h15M1 13h15"})})})})]}),g&&o.length>0&&jsx("div",{className:c("md:hidden border-t animate-in slide-in-from-top duration-300",s==="default"||s==="transparent"?"border-gray-700":"border-gray-200 dark:border-gray-800"),children:jsxs("div",{className:"flex flex-col py-2 px-4",children:[C&&jsx("form",{onSubmit:w,className:"mb-4",children:jsx("input",{type:"search","aria-label":E,value:W,onChange:H=>V(H.target.value),placeholder:E,className:"w-full px-4 py-2 rounded-lg border border-gray-300 focus:outline-none focus:ring-2 focus:ring-blue-500 text-gray-900 dark:border-gray-700 dark:bg-gray-800 dark:text-gray-100 dark:placeholder-gray-500"})}),o.map((H,z)=>U(H,z,true)),(n||a)&&jsxs("div",{className:"flex flex-col gap-2 mt-4 pt-4 border-t border-gray-700",children:[n,a]})]})})]})}var Uf=jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[jsx("path",{d:"M11 4H4a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7"}),jsx("path",{d:"M18.5 2.5a2.121 2.121 0 0 1 3 3L12 15l-4 1 1-4 9.5-9.5z"})]}),Yf=jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[jsx("path",{d:"M19 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h11l5 5v11a2 2 0 0 1-2 2z"}),jsx("polyline",{points:"17 21 17 13 7 13 7 21"}),jsx("polyline",{points:"7 3 7 8 15 8"})]}),jf=jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]}),qf=jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[jsx("polyline",{points:"1 4 1 10 7 10"}),jsx("path",{d:"M3.51 15a9 9 0 1 0 2.13-9.36L1 10"})]}),Zf=jsxs("svg",{className:"animate-spin h-4 w-4",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10"}),jsx("path",{className:"opacity-75",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4z",fill:"currentColor"})]}),Jf={xs:"w-4 h-4 text-[10px]",sm:"w-5 h-5 text-xs",md:"w-6 h-6 text-sm",lg:"w-7 h-7 text-base"},Qf={top:"bottom-full left-1/2 -translate-x-1/2 mb-2",bottom:"top-full left-1/2 -translate-x-1/2 mt-2",left:"right-full top-1/2 -translate-y-1/2 mr-2",right:"left-full top-1/2 -translate-y-1/2 ml-2"},eb={sm:"w-56",md:"w-72",lg:"w-96",xl:"w-[32rem]"},tb=[Kf],rb={h1:({...e})=>jsx("h1",{className:"text-xl font-bold mb-2 text-gray-900 dark:text-gray-100",...e}),h2:({...e})=>jsx("h2",{className:"text-lg font-semibold mt-4 mb-2 text-gray-900 dark:text-gray-100",...e}),h3:({...e})=>jsx("h3",{className:"text-base font-semibold mt-3 mb-1 text-gray-900 dark:text-gray-100",...e}),p:({...e})=>jsx("p",{className:"my-1 text-gray-700 dark:text-gray-300",...e}),ul:({...e})=>jsx("ul",{className:"list-disc list-inside space-y-1 my-2 text-gray-700 dark:text-gray-300",...e}),ol:({...e})=>jsx("ol",{className:"list-decimal list-inside space-y-1 my-2 text-gray-700 dark:text-gray-300",...e}),code:({className:e,children:t,...r})=>!e?.includes("language-")?jsx("code",{className:"bg-gray-100 dark:bg-gray-800 px-1.5 py-0.5 rounded text-sm font-mono text-gray-900 dark:text-gray-100",...r,children:t}):jsx("code",{className:"block bg-gray-100 dark:bg-gray-800 rounded-lg p-3 my-2 overflow-x-auto text-sm font-mono text-gray-900 dark:text-gray-100",...r,children:t}),pre:({...e})=>jsx("pre",{className:"my-2",...e}),a:({...e})=>jsx("a",{className:"text-blue-600 dark:text-blue-400 hover:underline",...e}),strong:({...e})=>jsx("strong",{className:"font-semibold text-gray-900 dark:text-gray-100",...e}),em:({...e})=>jsx("em",{className:"italic",...e}),blockquote:({...e})=>jsx("blockquote",{className:"border-l-4 border-gray-300 dark:border-gray-600 pl-4 my-2 italic text-gray-600 dark:text-gray-400",...e})};function Wd({content:e,markdown:t=false,position:r="bottom",size:o="sm",className:n="",visible:a=true,editable:s=false,onSave:l,onReset:i,width:d="md",title:u,markdownEditor:p,markdownEditorUnavailableLabel:b}){let m=Ft(),[f,h]=useState(false),[y,C]=useState(false),[v,E]=useState(""),[k,R]=useState(false),[g,P]=useState(null),T=useRef(null),D=useRef(null),W=useRef(null),V=useRef(null);useEffect(()=>{if(!f)return;let S=F=>{T.current&&!T.current.contains(F.target)&&D.current&&!D.current.contains(F.target)&&(y||h(false));},I=F=>{F.key==="Escape"&&(y?(C(false),E("")):h(false));};return document.addEventListener("mousedown",S),document.addEventListener("keydown",I),()=>{document.removeEventListener("mousedown",S),document.removeEventListener("keydown",I);}},[f,y]),useEffect(()=>{y&&W.current&&W.current.focus();},[y]),useEffect(()=>()=>{V.current&&clearTimeout(V.current);},[]);let _=useCallback(()=>{E(typeof e=="string"?e:""),C(true),P(null);},[e]),M=useCallback(()=>{C(false),E(""),P(null);},[]),w=useCallback(async()=>{if(!l){P({type:"error",text:"Aucune fonction de sauvegarde fournie"});return}R(true);try{await l(v)?(P({type:"success",text:"Sauvegard\xE9 avec succ\xE8s !"}),C(!1),V.current&&clearTimeout(V.current),V.current=setTimeout(()=>P(null),2e3)):P({type:"error",text:"Erreur lors de la sauvegarde"});}catch{P({type:"error",text:"Erreur lors de la sauvegarde"});}finally{R(false);}},[v,l]),N=useCallback(async()=>{if(i&&confirm("\xCAtes-vous s\xFBr de vouloir r\xE9initialiser ce contenu ?")){R(true);try{await i()?(P({type:"success",text:"R\xE9initialis\xE9 avec succ\xE8s !"}),C(!1),V.current&&clearTimeout(V.current),V.current=setTimeout(()=>P(null),2e3)):P({type:"error",text:"Erreur lors de la r\xE9initialisation"});}catch{P({type:"error",text:"Erreur lors de la r\xE9initialisation"});}finally{R(false);}}},[i]),x=e;return a?jsxs("div",{className:"relative inline-flex items-center",children:[jsx("button",{type:"button",ref:T,onClick:()=>h(!f),className:`
|
|
3
|
-
${
|
|
1
|
+
import*as js from'react';import js__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 Ob from'dompurify';import $b from'react-markdown';import _b from'remark-gfm';function u(...e){return e.filter(Boolean).join(" ")}var pl=createContext(null),ml=createContext(null);function Ds(){let e=useContext(pl);if(!e)throw new Error("Accordion sub-components must be used within <Accordion>");return e}function gl(){let e=useContext(ml);if(!e)throw new Error("AccordionTrigger/AccordionContent must be used within <AccordionItem>");return e}var fl={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"}},p0=({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"})}),m0={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:""},g0={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 f0({type:e="single",value:t,defaultValue:r,onValueChange:n,collapsible:o=false,variant:a="default",size:s="md",disabled:l=false,iconPosition:i="right",icon:d,hideIcon:c=false,className:p,children:f}){let[m,g]=useState(()=>r?Array.isArray(r)?r:[r]:[]),x=t!==void 0,b=x?Array.isArray(t)?t:[t]:m,v=useCallback(M=>{let w;e==="single"?b.includes(M)?w=o?[]:[M]:w=[M]:w=b.includes(M)?b.filter(P=>P!==M):[...b,M],x||g(w),n?.(e==="single"?w[0]??"":w);},[e,b,o,x,n]),y=useMemo(()=>({openItems:b,toggle:v,variant:a,size:s,disabled:l,iconPosition:i,icon:d??null,hideIcon:c}),[b,v,a,s,l,i,d,c]);return jsx(pl.Provider,{value:y,children:jsx("div",{className:u(m0[a],p),"data-testid":"accordion",children:f})})}function b0({value:e,disabled:t,className:r,children:n}){let o=Ds(),a=o.openItems.includes(e),s=t??o.disabled,l=useId(),i=`accordion-trigger-${l}`,d=`accordion-content-${l}`,c=useMemo(()=>({value:e,isOpen:a,disabled:s,triggerId:i,contentId:d}),[e,a,s,i,d]);return jsx(ml.Provider,{value:c,children:jsx("div",{className:u(g0[o.variant],r),"data-state":a?"open":"closed","data-testid":"accordion-item",children:n})})}function h0({className:e,icon:t,children:r}){let n=Ds(),o=gl(),a=fl[n.size],s=()=>{o.disabled||n.toggle(o.value);},l=c=>{(c.key==="Enter"||c.key===" ")&&(c.preventDefault(),s());},i=t??n.icon??jsx(p0,{className:a.icon}),d=!n.hideIcon&&jsx("span",{className:u("shrink-0 text-gray-500 dark:text-gray-400 transition-transform duration-200",o.isOpen&&"rotate-180"),"data-testid":"accordion-icon",children:i});return jsxs("button",{type:"button",id:o.triggerId,"aria-expanded":o.isOpen,"aria-controls":o.contentId,disabled:o.disabled,onClick:s,onKeyDown:l,className:u("flex items-center w-full text-left font-medium transition-colors cursor-pointer",a.trigger,a.text,"text-gray-900 dark:text-gray-100",!o.disabled&&"hover:bg-gray-50 dark:hover:bg-gray-800/50",o.disabled&&"opacity-50 cursor-not-allowed",e),"data-testid":"accordion-trigger",children:[n.iconPosition==="left"&&d,jsx("span",{className:"flex-1",children:r}),n.iconPosition==="right"&&d]})}function y0({className:e,children:t}){let r=Ds(),n=gl(),o=fl[r.size],a=useRef(null),[s,l]=useState(n.isOpen?void 0:0),i=useRef(true);return useEffect(()=>{if(i.current){i.current=false,l(n.isOpen?void 0:0);return}if(n.isOpen){let d=a.current;if(d){l(d.scrollHeight);let c=setTimeout(()=>l(void 0),200);return ()=>clearTimeout(c)}}else {let d=a.current;d&&(l(d.scrollHeight),requestAnimationFrame(()=>l(0)));}},[n.isOpen]),jsx("div",{id:n.contentId,role:"region","aria-labelledby":n.triggerId,className:"overflow-hidden transition-[height] duration-200 ease-in-out",style:{height:s===void 0?"auto":s},"data-testid":"accordion-content","data-state":n.isOpen?"open":"closed",children:jsx("div",{ref:a,className:u(o.content,"text-gray-600 dark:text-gray-400",o.text==="text-lg"?"text-base":"text-sm",e),children:t})})}function w0(...e){return e.filter(Boolean).join(" ")}var N0="@synertech/ui/AdvanceDetachable",S0=300,R0="width=800,height=600,menubar=no,toolbar=no,location=no,status=no,scrollbars=yes,resizable=yes",T0=0;function P0(){return `${Date.now()}-${++T0}-${Math.random().toString(36).slice(2,8)}`}function bl(e){try{return JSON.stringify(e)}catch{return String(e)}}function hl(e){try{return JSON.parse(e)}catch{return e}}function E0(e,t){e.querySelectorAll("style").forEach(r=>{let n=t.createElement("style");n.textContent=r.textContent,t.head.appendChild(n);}),e.querySelectorAll('link[rel="stylesheet"]').forEach(r=>{let n=r,o=t.createElement("link");o.rel="stylesheet",o.href=n.href,n.crossOrigin&&(o.crossOrigin=n.crossOrigin),t.head.appendChild(o);}),e.documentElement.className&&(t.documentElement.className=e.documentElement.className),e.body.className&&(t.body.className=e.body.className);}function D0(e,t){let r=new MutationObserver(n=>{for(let o of n)for(let a of Array.from(o.addedNodes))if(a instanceof HTMLStyleElement){let s=t.createElement("style");s.textContent=a.textContent,t.head.appendChild(s);}else if(a instanceof HTMLLinkElement&&a.rel==="stylesheet"){let s=t.createElement("link");s.rel="stylesheet",s.href=a.href,t.head.appendChild(s);}});return r.observe(e.head,{childList:true}),r}function M0(){return typeof BroadcastChannel<"u"}function I0({mode:e,id:t,title:r="",children:n,value:o,defaultValue:a,onValueChange:s,isDetached:l,defaultDetached:i=false,onDetachedChange:d,features:c,target:p,autoFocus:f=true,className:m,detachedBodyClassName:g,disabled:x=false,readOnly:b=false,closeOnMainWindowUnload:v=true,name:y,serialize:M,deserialize:w},P){let h=l!==void 0,[E,D]=useState(i),k=h?l:E,I=o!==void 0,[W,O]=useState(a),L=I?o:W,[T,S]=useState(null),C=useRef(null),N=useRef(null),R=useRef(null),$=useRef(null),H=useRef(false),K=useRef(null),_=useRef(null),F=useRef(null),[A]=useState(()=>`${Date.now().toString(36)}-${Math.random().toString(36).slice(2,8)}`),B=useRef({title:r,features:c,target:p,autoFocus:f,detachedBodyClassName:g,closeOnMainWindowUnload:v,disabled:x,readOnly:b,mode:e,id:t});B.current={title:r,features:c,target:p,autoFocus:f,detachedBodyClassName:g,closeOnMainWindowUnload:v,disabled:x,readOnly:b,mode:e,id:t};let U=useRef(M??bl);U.current=M??bl;let Q=useRef(w??hl);Q.current=w??hl;let J=useRef(s);J.current=s;let Y=useRef(d);Y.current=d;let z=useRef(k);z.current=k;let X=`${N0}/${t}`,ne=useCallback(()=>{R.current&&(clearInterval(R.current),R.current=null),$.current&&($.current.disconnect(),$.current=null),S(null);},[]),re=useCallback(()=>{N.current&&(N.current.close(),N.current=null),K.current&&typeof window<"u"&&(window.removeEventListener("message",K.current),K.current=null);},[]),q=useCallback(Te=>{if(!(!Te||Te.channel!==X)&&Te.instanceId!==A&&!B.current.readOnly&&Te.type==="value-sync"&&Te.payload!==void 0){_.current=Te.payload;let Ee=Q.current(Te.payload);I||O(Ee),J.current?.(Ee);}},[X,A,I]),de=useCallback(()=>{if(re(),!(typeof window>"u"))if(M0()){let Te=new BroadcastChannel(X),Ee=nt=>q(nt.data);Te.addEventListener("message",Ee),N.current=Te;}else {let Te=Ee=>{Ee.data?.channel===X&&q(Ee.data);};window.addEventListener("message",Te),K.current=Te;}},[X,re,q]),xe=useCallback(Te=>{if(B.current.readOnly)return;let Ee=U.current(Te);if(Ee===F.current)return;if(Ee===_.current){_.current=null;return}F.current=Ee;let nt={channel:X,instanceId:A,messageId:P0(),origin:"main",timestamp:Date.now(),type:"value-sync",payload:Ee};N.current?N.current.postMessage(nt):C.current&&!C.current.closed&&C.current.postMessage(nt,"*");},[X,A]),ke=useCallback(()=>{if(typeof window>"u"||B.current.disabled||H.current||C.current&&!C.current.closed)return;H.current=true;let Te=B.current,Ee=window.open("",Te.target||"",Te.features||R0);if(!Ee){H.current=false;return}C.current=Ee,Ee.document.title=Te.title||document.title,Te.detachedBodyClassName&&(Ee.document.body.className=Te.detachedBodyClassName);let nt=Ee.document.createElement("div");Ee.document.body.appendChild(nt),S(nt),E0(document,Ee.document),$.current=D0(document,Ee.document),R.current=setInterval(()=>{Ee.closed&&(ne(),C.current=null,h||D(false),Y.current?.(false));},S0),Te.autoFocus&&Ee.focus(),H.current=false;},[h,ne]),le=useCallback(()=>{C.current&&!C.current.closed&&C.current.close(),C.current=null,ne();},[ne]),Se=useRef(ke);Se.current=ke;let Me=useRef(le);Me.current=le;let je=useRef(xe);je.current=xe;let at=useCallback(()=>{B.current.disabled||(h||D(true),Y.current?.(true));},[h]),$e=useCallback(()=>{h||D(false),Y.current?.(false);},[h]),ie=useCallback(()=>{let Te=!z.current;Te&&B.current.disabled||(h||D(Te),Y.current?.(Te));},[h]);useImperativeHandle(P,()=>({open:at,close:$e,toggle:ie,get isDetached(){return z.current},get window(){return C.current}}),[at,$e,ie]),useEffect(()=>(de(),()=>re()),[de,re]),useEffect(()=>{if(k)return Se.current(),()=>Me.current();Me.current();},[k]),useEffect(()=>{L!==void 0&&je.current(L);},[L]),useEffect(()=>{C.current&&!C.current.closed&&r&&(C.current.document.title=r);},[r]),useEffect(()=>{if(typeof window>"u")return;let Te=()=>{B.current.closeOnMainWindowUnload&&C.current&&!C.current.closed&&C.current.close();};return window.addEventListener("beforeunload",Te),()=>{window.removeEventListener("beforeunload",Te),C.current&&!C.current.closed&&C.current.close(),C.current=null;}},[]);let he=typeof n=="function"?n({open:at,close:$e,toggle:ie,detached:k,windowRef:C.current}):n,Ie=e==="clone"||!k,xt=k&&T!==null;return jsxs(Fragment,{children:[y&&L!==void 0&&jsx("input",{type:"hidden",name:y,value:U.current(L)}),Ie&&jsx("div",{className:w0(m),children:he}),xt&&createPortal(he,T)]})}var xl=forwardRef(I0);xl.displayName="AdvanceDetachable";function Sn(e,t=11){return e.length*t*.6}function br(e,t=11){let r=0;for(let n of e){let o=Sn(n,t);o>r&&(r=o);}return r}function Io(e,t,r,n=12){if(e<=1||t<=0)return 1;let o=r+n,a=Math.max(1,Math.floor(t/o));return Math.max(1,Math.ceil(e/a))}var z0=10,W0={sm:"text-[10px]",md:"text-[11px]",lg:"text-xs"};function St({orientation:e,ticks:t,length:r,showLine:n=true,tickSize:o=4,tickPadding:a=6,label:s,size:l="md",className:i,...d}){let c=e==="bottom";return jsxs("g",{className:u(W0[l],i),"aria-hidden":"true",...d,children:[n&&jsx("line",{x1:0,y1:0,x2:c?r:0,y2:c?0:r,className:"stroke-gray-300 dark:stroke-gray-600",strokeWidth:1,shapeRendering:"crispEdges"}),t.map(p=>{let f=c?p.offset:0,m=c?0:p.offset;return jsxs("g",{transform:`translate(${f}, ${m})`,children:[o>0?jsx("line",{x1:0,y1:0,x2:c?0:-o,y2:c?o:0,className:"stroke-gray-300 dark:stroke-gray-600",strokeWidth:1}):null,jsx("text",{x:c?0:-(o+a),y:c?o+a:0,textAnchor:c?"middle":"end",dominantBaseline:c?"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:c?r/2:0,y:c?o+a+16:0,textAnchor:"middle",dominantBaseline:c?"hanging":"middle",transform:c?void 0:`translate(${-(o+a+br(t.map(p=>p.label))+z0)}, ${r/2}) rotate(-90)`,className:"fill-gray-600 dark:fill-gray-300 font-medium",children:s}):null]})}var Cl={closeModal:"Close modal",closeDrawer:"Close drawer",closeSidebar:"Close sidebar",openSidebar:"Open sidebar",expandSidebar:"Expand sidebar",collapseSidebar:"Collapse sidebar",sidebar:"Sidebar",enterFullScreen:"Enter full screen",exitFullScreen:"Exit full screen",confirm:"Confirm",cancel:"Cancel",markdownEditorUnavailable:"Markdown editor unavailable. Pass markdownEditor from @synertech/ui/markdown-editor.",chartShowTable:"Show data table",chartHideTable:"Hide data table",chartNoData:"No data",chartLoading:"Loading chart",chartOther:"Other",chartValue:"Value",chartTarget:"Target"},V0={closeModal:"Fermer la fen\xEAtre",closeDrawer:"Fermer le panneau",closeSidebar:"Fermer le menu lat\xE9ral",openSidebar:"Ouvrir le menu lat\xE9ral",expandSidebar:"D\xE9plier le menu lat\xE9ral",collapseSidebar:"Replier le menu lat\xE9ral",sidebar:"Menu lat\xE9ral",enterFullScreen:"Passer en plein \xE9cran",exitFullScreen:"Quitter le plein \xE9cran",confirm:"Confirmer",cancel:"Annuler",markdownEditorUnavailable:"\xC9diteur Markdown indisponible. Passez markdownEditor depuis @synertech/ui/markdown-editor.",chartShowTable:"Afficher le tableau de donn\xE9es",chartHideTable:"Masquer le tableau de donn\xE9es",chartNoData:"Aucune donn\xE9e",chartLoading:"Chargement du graphique",chartOther:"Autres",chartValue:"Valeur",chartTarget:"Objectif"},Ms=createContext(Cl);function B0({labels:e,children:t}){let r=useContext(Ms),n=useMemo(()=>({...r,...e}),[r,e]);return jsx(Ms.Provider,{value:n,children:t})}function At(){return useContext(Ms)}var $0={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"},_0={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"},X0={xs:24,sm:32,md:48,lg:64,xl:96},G0={xs:"text-[8px]",sm:"text-[10px]",md:"text-sm",lg:"text-base",xl:"text-xl"},K0={thin:2,normal:4,thick:8};function Un({value:e=0,indeterminate:t=false,size:r="md",thickness:n="normal",color:o="primary",progressColor:a,trackColor:s,showValue:l=false,children:i,valueFormat:d,animated:c=true,className:p,...f}){let m=Math.min(100,Math.max(0,e)),g=X0[r],x=K0[n],b=(g-x)/2,v=2*Math.PI*b,y=g/2,M=v-m/100*v,w=a||$0[o],P=s||"stroke-gray-200 dark:stroke-gray-700",h=_0[o],E=i??(l&&!t?jsx("span",{className:u("font-semibold",G0[r],h),children:d?d(m):`${Math.round(m)}%`}):null);return jsxs("div",{className:u("relative inline-flex items-center justify-center",p),role:"progressbar","aria-valuenow":t?void 0:m,"aria-valuemin":0,"aria-valuemax":100,...f,children:[jsxs("svg",{width:g,height:g,viewBox:`0 0 ${g} ${g}`,className:u(t&&"animate-spin"),style:{transform:"rotate(-90deg)"},children:[jsx("circle",{cx:y,cy:y,r:b,fill:"none",strokeWidth:x,className:P}),jsx("circle",{cx:y,cy:y,r:b,fill:"none",strokeWidth:x,strokeLinecap:"round",strokeDasharray:v,strokeDashoffset:t?v*.75:M,className:u(w,c&&!t&&"transition-[stroke-dashoffset] duration-300 ease-out")})]}),E&&jsx("div",{className:"absolute inset-0 flex items-center justify-center",style:{transform:"rotate(0deg)"},children:E})]})}Un.displayName="CircularProgress";var Nl=640;function Is(e={}){let{width:t,fallbackWidth:r=Nl}=e,n=useRef(null),[o,a]=useState(0);return useEffect(()=>{if(t!==void 0)return;let s=n.current;if(!s)return;let l=d=>{a(c=>Math.abs(c-d)<1?c:d);};if(l(s.getBoundingClientRect().width),typeof ResizeObserver>"u")return;let i=new ResizeObserver(d=>{for(let c of d)l(c.contentRect.width);});return i.observe(s),()=>i.disconnect()},[t]),t!==void 0?{ref:n,width:t,measured:true}:{ref:n,width:o>0?o:r,measured:o>0}}var Q0={sm:"text-xs",md:"text-sm",lg:"text-base"};function Kt({title:e,description:t,height:r=240,width:n,size:o="md",legend:a,legendPosition:s="bottom",actions:l,loading:i=false,empty:d=false,emptyState:c,table:p,tableView:f=false,showTableLabel:m,hideTableLabel:g,noDataLabel:x,loadingLabel:b,ariaLabel:v,children:y,className:M,...w}){let P=At(),[h,E]=useState(false),D=useId(),k=`${D}-table`,I=`${D}-title`,W=`${D}-description`,{ref:O,width:L,measured:T}=Is({width:n}),S=!!p&&f==="toggle",C=!!p&&(f===true||S&&h),$=jsx("div",{ref:O,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(Un,{indeterminate:true,size:"md","aria-label":b??P.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:c??x??P.chartNoData}):jsx("div",{className:u("h-full w-full transition-opacity duration-200",i&&"opacity-60"),children:typeof y=="function"?y({width:L,height:r,measured:T}):y})});return jsxs("figure",{className:u("flex w-full flex-col gap-3",M),"aria-label":v,"aria-labelledby":!v&&e?I:void 0,"aria-describedby":t?W:void 0,...w,children:[e||t||l?jsxs("figcaption",{className:"flex items-start justify-between gap-3",children:[jsxs("div",{className:"flex flex-col gap-0.5",children:[e?jsx("span",{id:I,className:u("font-semibold text-gray-900 dark:text-gray-100",Q0[o]),children:e}):null,t?jsx("span",{id:W,className:"text-xs text-gray-500 dark:text-gray-400",children:t}):null]}),l]}):null,a&&s==="top"?a:null,a&&s==="right"?jsxs("div",{className:"flex items-start gap-4",children:[jsx("div",{className:"min-w-0 grow",children:$}),a]}):$,a&&s==="bottom"?a:null,S&&jsx("div",{className:"flex",children:jsx("button",{type:"button",onClick:()=>E(H=>!H),"aria-expanded":h,"aria-controls":C?k: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:h?g??P.chartHideTable:m??P.chartShowTable})}),C&&jsx("div",{id:k,children:p})]})}var Sl=[];function Kr({width:e,height:t,horizontal:r=Sl,vertical:n=Sl,className:o,...a}){return jsxs("g",{className:u("stroke-gray-200 dark:stroke-gray-700",o),strokeWidth:1,shapeRendering:"crispEdges","aria-hidden":"true",...a,children:[r.map(s=>jsx("line",{x1:0,y1:s,x2:e,y2:s},`h-${s}`)),n.map(s=>jsx("line",{x1:s,y1:0,x2:s,y2:t},`v-${s}`))]})}var ep={line:"h-0.5 w-3 rounded-full",rect:"h-2.5 w-2.5 rounded-sm",dot:"h-2 w-2 rounded-full"},tp={sm:"text-[11px]",md:"text-xs",lg:"text-sm"};function yr({items:e,position:t="bottom",marker:r="line",onToggle:n,size:o="md",className:a,...s}){return e.length===0?null:jsx("ul",{className:u("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":"",tp[o],a),...s,children:e.map(l=>{let i=jsx("span",{className:u("shrink-0",ep[r]),style:{backgroundColor:l.color},"aria-hidden":"true"}),d=jsx("span",{className:u(l.hidden&&"line-through"),children:l.label}),c=jsxs(Fragment,{children:[i,d]}),p=u("flex items-center gap-1.5 text-gray-600 dark:text-gray-300",l.hidden&&"text-gray-400 dark:text-gray-500");return jsx("li",{children:n?jsx("button",{type:"button",onClick:()=>n(l.key),"aria-pressed":!l.hidden,className:u(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:c}):jsx("span",{className:p,children:c})},l.key)})})}function Ls({children:e,className:t,...r}){return jsx("table",{className:u("w-full text-sm text-left rtl:text-right text-gray-500 dark:text-gray-400",t),...r,children:e})}function As({children:e,className:t,...r}){return jsx("tbody",{className:u(t),...r,children:e})}function Ca({children:e,onClick:t,hidden:r=false,className:n,...o}){return jsx("td",{className:u("px-6 py-4",n),onClick:t,hidden:r,...o,children:e})}function zs({children:e,className:t,...r}){return jsx("thead",{className:u("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 wa({children:e,onClick:t,hidden:r=false,className:n,sortable:o=false,...a}){return jsx("th",{scope:"col",className:u("px-6 py-3",o&&"cursor-pointer hover:bg-gray-100 dark:hover:bg-gray-600",n),onClick:t,hidden:r,...a,children:e})}function Ws({children:e,onClick:t,clickable:r=true,className:n,...o}){return jsx("tr",{className:u("bg-white border-b dark:bg-gray-800 dark:border-gray-700",r&&"hover:bg-gray-50 hover:cursor-pointer dark:hover:bg-gray-600",n),onClick:t,...o,children:e})}var dp=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)"],Mr="var(--color-chart-muted)",Ra=3,Pl=false;function jn(e,t){return t||(e<0||e>=8?(Pl||(Pl=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.')),Mr):Sa[e])}function Ir(e,t,r){return r&&e.key!==r?Mr:jn(t,e.color)}function Bt(e){return e.label??e.key}function Ur(e,t){return e.map((r,n)=>({key:r.key,label:Bt(r),color:Ir(r,n,t),hidden:r.hidden}))}var Hs=["var(--color-chart-seq-1)","var(--color-chart-seq-2)","var(--color-chart-seq-3)","var(--color-chart-seq-4)","var(--color-chart-seq-5)","var(--color-chart-seq-6)"],Fs=["var(--color-chart-ord-1)","var(--color-chart-ord-2)","var(--color-chart-ord-3)","var(--color-chart-ord-4)","var(--color-chart-ord-5)"],Na=["var(--color-chart-div-1)","var(--color-chart-div-2)","var(--color-chart-div-3)","var(--color-chart-div-4)","var(--color-chart-div-5)","var(--color-chart-div-6)","var(--color-chart-div-7)"],El=3,Dl=[false,false,false,false,true,true],cp=[false,false,true,true,true],Ml=[true,false,false,false,false,false,true],Ta=7;function Lo(e){return Number.isFinite(e)?e<0?0:e>1?1:e:0}function Vs(e,t){if(e.length===0)return Mr;if(e.length===1)return e[0];let r=Lo(t)*(e.length-1),n=Math.min(e.length-2,Math.floor(r)),o=r-n;if(o<=.005)return e[n];if(o>=.995)return e[n+1];let a=Math.round(o*1e3)/10;return `color-mix(in oklab, ${e[n+1]} ${a}%, ${e[n]})`}function up(e,t){return t<=1?.5:Math.min(t-1,Math.floor(Lo(e)*t))/(t-1)}function Il(e,t,r,n,o){let a=l=>{let i=n(l);return r===null?i:up(i,r)},s=(l=>Number.isFinite(l)?Vs(t,a(l)):Mr);return Object.defineProperties(s,{domain:{value:[e[0],e[1]],enumerable:true},colors:{value:t,enumerable:true},steps:{value:r,enumerable:true},position:{value:l=>Number.isFinite(l)?a(l):0,enumerable:true},onDark:{value:l=>{if(!Number.isFinite(l)||o.length===0)return false;let i=Math.round(a(l)*(o.length-1));return o[i]??false},enumerable:true}}),s}function Bs(e,t={}){let{steps:r,colors:n=Hs,darkStops:o}=t,[a,s]=e,l=s-a;return Il(e,n,r??null,i=>l===0?0:(i-a)/l,o??(n===Hs?Dl:[]))}function qn(e,t={}){let{steps:r,colors:n=Na,darkStops:o,center:a=0,symmetric:s=true}=t,[l,i]=e;if(s){let p=Math.max(Math.abs(i-a),Math.abs(a-l));l=a-p,i=a+p;}let d=n===Na?El:(n.length-1)/2,c=n.length-1;return Il([l,i],n,r??null,p=>{if(p>=a){let g=i-a,x=g<=0?0:Lo((p-a)/g);return (d+x*(c-d))/c}let f=a-l,m=f<=0?0:Lo((a-p)/f);return (d-m*d)/c},o??(n===Na?Ml:[]))}function pp(e,t=Fs.length,r=Fs){return t<=1?r[r.length-1]??Mr:Vs(r,Lo(e/(t-1)))}function et(e,t){let r=e[t];if(r==null||r==="")return null;if(typeof r=="number")return Number.isFinite(r)?r:null;if(typeof r=="boolean")return r?1:0;if(typeof r=="string"){let n=Number(r);return Number.isFinite(n)?n:null}return null}function Ut(e,t,r){let n=e[t];return n instanceof Date||typeof n=="number"||typeof n=="string"?n:n==null?r:String(n)}function ir(e,t){let r=[];for(let n of e)for(let o of t)r.push(et(n,o));return r}function Ao(e,t={}){if(!Number.isFinite(e))return "\u2014";let{locale:r,compact:n,currency:o,unit:a,minimumFractionDigits:s,maximumFractionDigits:l}=t,i=new Intl.NumberFormat(r,{notation:n?"compact":"standard",...o?{style:"currency",currency:o}:{},...s!==void 0?{minimumFractionDigits:s}:{},...l!==void 0?{maximumFractionDigits:l}:n?{maximumFractionDigits:1}:{}}).format(e);return a?`${i}${a}`:i}function mp(e,t){return Ao(e,{locale:t,compact:true})}function vt(e,t){return Number.isFinite(e)?Math.abs(e)<1e4?Ao(e,{locale:t}):mp(e,t):"\u2014"}function xr(e,t={}){if(!Number.isFinite(e))return "\u2014";let{locale:r,maximumFractionDigits:n=1,alreadyScaled:o,signed:a}=t;return new Intl.NumberFormat(r,{style:"percent",maximumFractionDigits:n,...a?{signDisplay:"exceptZero"}:{}}).format(o?e/100:e)}function bt(e,t){return e instanceof Date?new Intl.DateTimeFormat(t,{day:"2-digit",month:"short"}).format(e):typeof e=="number"?Ao(e,{locale:t}):e}function Yt({data:e,series:t,xKey:r,xLabel:n,formatX:o,formatValue:a,caption:s,emptyLabel:l,className:i,...d}){let c=t.filter(m=>!m.hidden);if(e.length===0||c.length===0)return jsx("div",{className:u("text-sm text-gray-500 dark:text-gray-400",i),...d,children:l});let p=(m,g)=>{let x=Ut(m,r,g);return o?o(x,g):bt(x)},f=m=>m===null?"\u2014":a?a(m):Ao(m);return jsx("div",{className:u("w-full overflow-x-auto",i),...d,children:jsxs(Ls,{children:[s?jsx("caption",{className:"sr-only",children:s}):null,jsxs(zs,{children:[jsx(wa,{children:n??r}),c.map(m=>jsx(wa,{className:"text-right",children:Bt(m)},m.key))]}),jsx(As,{children:e.map((m,g)=>jsxs(Ws,{clickable:false,children:[jsx(Ca,{className:"font-medium text-gray-900 dark:text-gray-100",children:p(m,g)}),c.map(x=>jsx(Ca,{className:"text-right [font-variant-numeric:tabular-nums]",children:f(et(m,x.key))},x.key))]},g))})]})})}function jt({x:e,y:t,visible:r=true,containerWidth:n,offset:o=12,className:a,style:s,children:l,...i}){if(!r)return null;let d=n!==void 0&&e>n*.6;return jsx("div",{role:"tooltip",className:u("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-o:e+o}px, ${t}px) translate(${d?"-100%":"0"}, -50%)`,...s},...i,children:l})}function vr({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 dt(e){return e instanceof Date?e.toISOString():String(e)}function Lr(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 Ar(e,t){let[r,n]=e,[o,a]=t,s=n-r,l=s===0?0:(a-o)/s,i=(d=>Number.isFinite(d)?s===0?(o+a)/2:o+(d-r)*l:Number.NaN);return Object.defineProperties(i,{domain:{value:[r,n],enumerable:true},range:{value:[o,a],enumerable:true},invert:{value:d=>l===0?r:r+(d-o)/l,enumerable:true}}),i}function Rn(e,t,r={}){let{paddingInner:n=.2,paddingOuter:o=n/2}=r,[a,s]=t,l=e.length,i=l===0?0:(s-a)/Math.max(1,l-n+o*2),d=i*(1-n),c=a+(s-a-i*(l-n))/2,p=new Map;e.forEach((g,x)=>{p.has(dt(g))||p.set(dt(g),x);});let f=g=>c+i*g,m=(g=>{let x=p.get(dt(g));return x===void 0?Number.NaN:f(x)});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:g=>{let x=p.get(dt(g));return x===void 0?Number.NaN:f(x)+d/2},enumerable:true},positions:{value:()=>e.map((g,x)=>f(x)),enumerable:true},indexOf:{value:g=>p.get(dt(g))??-1,enumerable:true}}),m}function dn(e,t){if(e.length===0)return -1;let r=0,n=Number.POSITIVE_INFINITY;for(let o=0;o<e.length;o+=1){let a=Math.abs(e[o]-t);a<n&&(n=a,r=o);}return r}function zo(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),n=e/r,o=n<=1?1:n<=2?2:n<=5?5:10;return zo(o*r)}function Pa(e,t,r=5){if(!Number.isFinite(e)||!Number.isFinite(t))return [0,1];if(e===t){if(e===0)return [0,1];let o=Math.abs(e)*.5;[e,t]=[e-o,e+o];}let n=Al((t-e)/Math.max(1,r));return [zo(Math.floor(e/n)*n),zo(Math.ceil(t/n)*n)]}function Wo(e,t,r=5){if(!Number.isFinite(e)||!Number.isFinite(t))return [];if(r<=0)return [];if(e===t)return [zo(e)];e>t&&([e,t]=[t,e]);let n=Al((t-e)/r),o=Math.ceil(e/n),a=Math.floor(t/n),s=[];for(let l=o;l<=a&&s.length<=1e3;l+=1)s.push(zo(l*n));return s}function Ot(e){let t=Number.POSITIVE_INFINITY,r=Number.NEGATIVE_INFINITY,n=false;for(let o of e)o==null||!Number.isFinite(o)||(n=true,o<t&&(t=o),o>r&&(r=o));return n?[t,r]:null}function Qn(e,t={}){let{domain:r,includeZero:n=true,ticks:o=5}=t;if(Array.isArray(r))return r;let a=Ot(e);if(!a)return [0,1];let[s,l]=a;return n&&(s=Math.min(s,0),l=Math.max(l,0)),Pa(s,l,o)}var $s={top:10,right:16,bottom:28},zl=16,gp=14,fp=32;function cn({width:e,height:t,data:r,x:n,y:o,bounds:a,margin:s,orientation:l="vertical",placement:i="point",bandPaddingInner:d=.2,formatValue:c,formatX:p,extraTop:f=0,defaultIncludeZero:m=false}){let g=l==="vertical",x=r.map((B,U)=>Ut(B,n.key,U)),b=Qn(a??[],{domain:o?.domain,includeZero:o?.includeZero??m,ticks:o?.ticks??5}),v=o?.hidden??false,y=n.hidden??false,M=v?[]:Wo(b[0],b[1],o?.ticks??5),w=M.map(c),P=g&&(n.scale==="linear"||n.scale==="time"),h=x.map((B,U)=>p(B,U)),E=g?v:y,D=g?w:h,k=g?o?.width:n.height,I=g?y:v,W=g?n.height:void 0,O=g?n.label:o?.label,L=g?o?.label:n.label,T=g&&!y&&i!=="band"?h:[],S=B=>B?Sn(B)/2+4:0,C={top:s?.top??$s.top+f,right:s?.right??Math.max($s.right,S(T[T.length-1])),bottom:s?.bottom??(I?8:W??$s.bottom+(O?zl:0)),left:s?.left??(E?8:k??Math.max(Math.max(fp,br(D)+gp)+(L?zl:0),S(T[0])))},N=Math.max(0,e-C.left-C.right),R=Math.max(0,t-C.top-C.bottom),$=g?Ar(b,[R,0]):Ar(b,[0,N]),H=g?N:R,K,_=0,F;if(P){let B=x.map(Lr),U=Ot(B)??[0,1],Q=Ar(U,[0,H]);K=B.map(J=>Q(J)),F=y?[]:Wo(U[0],U[1],n.ticks??5).map(J=>({value:J,offset:Q(J),label:p(n.scale==="time"?new Date(J):J,0)}));}else if(i==="band"){let B=Rn(r.map((U,Q)=>Q),[0,H],{paddingInner:d});K=r.map((U,Q)=>B(Q)),_=B.bandwidth,F=[];}else {let B=r.length>1?H/(r.length-1):0;K=r.map((U,Q)=>r.length>1?Q*B:H/2),F=[];}let A=K.map(B=>B+_/2);if(!P&&!y){let B=g?br(h):15,U=Io(h.length,H,B);F=h.map((Q,J)=>({value:x[J],offset:A[J],label:Q})).filter((Q,J)=>J%U===0);}return {margin:C,innerWidth:N,innerHeight:R,orientation:l,valueScale:$,domain:b,valueTicks:M.map(B=>({value:B,offset:$(B),label:c(B)})),xValues:x,categoryPositions:K,bandwidth:_,categoryCenters:A,categoryTicks:F,categoryLength:H}}function lt(e){return Math.round(e*100)/100}function Wl(e){return e.defined!==false&&Number.isFinite(e.x)&&Number.isFinite(e.y)}function Hl(e,t=false){if(t){let o=e.filter(Wl);return o.length>0?[o]:[]}let r=[],n=[];for(let o of e)Wl(o)?n.push(o):n.length>0&&(r.push(n),n=[]);return n.length>0&&r.push(n),r}function bp(e){let t=e.length,r=[],n=[];for(let a=0;a<t-1;a+=1){let s=e[a+1].x-e[a].x;r.push(s),n.push(s===0?0:(e[a+1].y-e[a].y)/s);}let o=new Array(t);o[0]=n[0],o[t-1]=n[t-2];for(let a=1;a<t-1;a+=1){let s=n[a-1],l=n[a];if(s*l<=0)o[a]=0;else {let i=2*r[a]+r[a-1],d=r[a]+2*r[a-1];o[a]=(i+d)/(i/s+d/l);}}return o}function Xs(e,t){if(e.length<2)return "";if(t==="monotone"&&e.length>2){let n=bp(e),o="";for(let a=0;a<e.length-1;a+=1){let s=e[a],l=e[a+1],i=(l.x-s.x)/3;o+=` C${lt(s.x+i)},${lt(s.y+n[a]*i)} ${lt(l.x-i)},${lt(l.y-n[a+1]*i)} ${lt(l.x)},${lt(l.y)}`;}return o}let r="";for(let n=1;n<e.length;n+=1){let o=e[n-1],a=e[n];if(t==="step"){let s=lt((o.x+a.x)/2);r+=` L${s},${lt(o.y)} L${s},${lt(a.y)}`;}else t==="stepAfter"&&(r+=` L${lt(a.x)},${lt(o.y)}`);r+=` L${lt(a.x)},${lt(a.y)}`;}return r}function Yr(e,t="linear",r={}){return Hl(e,r.connectNulls).map(n=>{let[o]=n;return `M${lt(o.x)},${lt(o.y)}${Xs(n,t)}`}).join(" ")}function Ho(e,t,r="linear",n={}){let o=Hl(e,n.connectNulls);if(o.length===0)return "";let a=typeof t=="number"?null:new Map(t.map(s=>[lt(s.x),s]));return o.map(s=>{let[l]=s,i=s[s.length-1],d=`M${lt(l.x)},${lt(l.y)}${Xs(s,r)}`;if(a===null){let f=lt(t);return `${d} L${lt(i.x)},${f} L${lt(l.x)},${f} Z`}let c=s.map(f=>a.get(lt(f.x))).filter(f=>f!==void 0).reverse();if(c.length===0)return `${d} Z`;let[p]=c;return `${d} L${lt(p.x)},${lt(p.y)}${Xs(c,r)} Z`}).join(" ")}function Fo({x:e,y:t,width:r,height:n,radius:o=4,round:a="none"}){if(!(r>0)||!(n>0))return "";let s=Math.max(0,Math.min(o,r/2,n/2)),[l,i]=[We(e),We(t)],[d,c]=[We(e+r),We(t+n)];if(s===0||a==="none")return `M${l},${i} L${d},${i} L${d},${c} L${l},${c} Z`;switch(a){case "top":return `M${l},${c} L${l},${We(t+s)} Q${l},${i} ${We(e+s)},${i} L${We(e+r-s)},${i} Q${d},${i} ${d},${We(t+s)} L${d},${c} Z`;case "bottom":return `M${l},${i} L${d},${i} L${d},${We(t+n-s)} Q${d},${c} ${We(e+r-s)},${c} L${We(e+s)},${c} Q${l},${c} ${l},${We(t+n-s)} Z`;case "right":return `M${l},${i} L${We(e+r-s)},${i} Q${d},${i} ${d},${We(t+s)} L${d},${We(t+n-s)} Q${d},${c} ${We(e+r-s)},${c} L${l},${c} Z`;case "left":return `M${d},${i} L${We(e+s)},${i} Q${l},${i} ${l},${We(t+s)} L${l},${We(t+n-s)} Q${l},${c} ${We(e+s)},${c} L${d},${c} Z`;default:return `M${l},${i} L${d},${i} L${d},${c} L${l},${c} Z`}}function We(e){return Math.round(e*100)/100}function un(e,t,r,n){return {x:We(e+r*Math.sin(n)),y:We(t-r*Math.cos(n))}}function Fl({cx:e,cy:t,innerRadius:r,outerRadius:n,startAngle:o,endAngle:a}){let s=a-o;if(!(n>0)||!(s>0))return "";let l=s>=Math.PI*2-1e-9,i=Math.max(0,Math.min(r,n));if(l){let g=un(e,t,n,0),x=un(e,t,n,Math.PI),b=`M${g.x},${g.y} A${We(n)},${We(n)} 0 1 1 ${x.x},${x.y} A${We(n)},${We(n)} 0 1 1 ${g.x},${g.y} Z`;if(i===0)return b;let v=un(e,t,i,0),y=un(e,t,i,Math.PI);return `${b} M${v.x},${v.y} A${We(i)},${We(i)} 0 1 0 ${y.x},${y.y} A${We(i)},${We(i)} 0 1 0 ${v.x},${v.y} Z`}let d=s>Math.PI?1:0,c=un(e,t,n,o),p=un(e,t,n,a);if(i===0)return `M${We(e)},${We(t)} L${c.x},${c.y} A${We(n)},${We(n)} 0 ${d} 1 ${p.x},${p.y} Z`;let f=un(e,t,i,a),m=un(e,t,i,o);return `M${c.x},${c.y} A${We(n)},${We(n)} 0 ${d} 1 ${p.x},${p.y} L${f.x},${f.y} A${We(i)},${We(i)} 0 ${d} 0 ${m.x},${m.y} Z`}function Ea(e,t,r="none"){return e.map((n,o)=>{let a=t.map(c=>et(n,c)),s=a.reduce((c,p)=>c+(p===null?0:Math.abs(p)),0),l=0,i=0,d=t.map((c,p)=>{let f=a[p];if(r==="none")return {key:c,value:f,start:0,end:f??0};if(f===null)return {key:c,value:null,start:l,end:l};let m=r==="percent"?s===0?0:f/s*100:f;if(m>=0){let x=l;return l+=m,{key:c,value:f,start:x,end:l}}let g=i;return i+=m,{key:c,value:f,start:i,end:g}});return {index:o,datum:n,total:s,segments:d}})}function Da(e){let t=Number.POSITIVE_INFINITY,r=Number.NEGATIVE_INFINITY,n=false;for(let o of e)for(let a of o.segments)a.value!==null&&(n=true,t=Math.min(t,a.start,a.end),r=Math.max(r,a.start,a.end));return n?[t,r]:null}function Vl(e,t,r={}){let{centerKey:n,percent:o=false}=r,a=n?t.indexOf(n):-1,s=a>=0?a:Math.max(0,Math.min(t.length,r.negativeCount??Math.floor(t.length/2)));return e.map((l,i)=>{let d=t.map(v=>et(l,v)),c=d.reduce((v,y)=>v+(y===null?0:Math.abs(y)),0),p=d.map(v=>v===null?null:o?c===0?0:v/c*100:v),f=t.map(v=>({key:v,value:null,start:0,end:0,base:false,outer:false})),m=0;a>=0&&(m=(p[a]??0)/2,f[a]={key:t[a],value:d[a],start:m===0?0:-m,end:m,base:true,outer:false});let g=m===0?0:-m,x=-1;for(let v=s-1;v>=0;v-=1){let y=p[v];if(y===null){f[v]={...f[v],value:null,start:g,end:g};continue}let M=g-Math.abs(y);f[v]={key:t[v],value:d[v],start:g,end:M,base:a<0&&x===-1,outer:false},g=M,x=v;}x>=0&&(f[x].outer=true),g=m;let b=-1;for(let v=a>=0?a+1:s;v<t.length;v+=1){let y=p[v];if(y===null){f[v]={...f[v],value:null,start:g,end:g};continue}let M=g+Math.abs(y);f[v]={key:t[v],value:d[v],start:g,end:M,base:a<0&&b===-1,outer:false},g=M,b=v;}return b>=0?f[b].outer=true:a>=0&&(f[a].outer=true),{index:i,datum:l,total:c,segments:f}})}var yp=.12,xp=.9,vp=10,kp=memo(function({bands:t,stacked:r}){return jsx("g",{children:t.map(n=>jsxs("g",{children:[jsx("path",{d:n.area,fill:n.color,fillOpacity:r?xp:yp,stroke:"none"}),n.gap?jsx("path",{d:n.gap,fill:"none",strokeWidth:2,className:"stroke-white dark:stroke-gray-800"}):null,jsx("path",{d:n.edge,fill:"none",stroke:n.color,strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"})]},n.key))})});function Cp({width:e,height:t,data:r,resolvedSeries:n,x:o,y:a,grid:s,size:l,curve:i,stack:d,baseline:c,connectNulls:p,referenceLines:f,margin:m,tooltip:g,onPointClick:x,plotLabel:b,formatValue:v,formatRaw:y,formatX:M}){let[w,P]=useState(null),h=useMemo(()=>{let T=n.filter(A=>!A.hidden),S=T.map(A=>A.key),C=d!=="none",N=Ea(r,S,d),R=C?Da(N):Ot([...ir(r,S),c]),$=cn({width:e,height:t,data:r,x:o,y:a,bounds:R,margin:m,placement:"point",formatValue:v,formatX:M,defaultIncludeZero:true}),H=$.categoryCenters,K=$.valueScale,_=K(C?0:c),F=T.map((A,B)=>{let U=r.map((Y,z)=>{let X=N[z].segments[B];return {x:H[z],y:X.value===null?Number.NaN:K(X.end),defined:X.value!==null}}),Q=r.map((Y,z)=>{let X=N[z].segments[B];return {x:H[z],y:X.value===null?Number.NaN:K(C?X.start:c),defined:X.value!==null}}),J={connectNulls:p};return {key:A.key,color:A.color,area:C?Ho(U,Q,i,J):Ho(U,_,i,J),edge:Yr(U,i,J),gap:C&&B>0?Yr(Q,i,J):""}});return {visible:T,rows:N,stacked:C,xValues:$.xValues,positions:H,xTicks:$.categoryTicks,yTicks:$.valueTicks,valueScale:K,innerWidth:$.innerWidth,innerHeight:$.innerHeight,margin:$.margin,bands:F}},[r,n,o,a,e,t,m,i,d,c,p,v,M]),E=useCallback(T=>h.visible.map((S,C)=>{let N=et(r[T],S.key),R=h.rows[T].segments[C],$=N===null?"\u2014":d==="percent"?`${y(N)} (${v(R.end-R.start)})`:v(N);return {seriesKey:S.key,seriesLabel:Bt(S),color:S.color,value:N,formattedValue:$,datum:r[T]}}),[r,h.visible,h.rows,d,v,y]),D=useCallback(T=>{if(g===false||r.length===0)return;let S=T.currentTarget.getBoundingClientRect(),C=T.clientX-S.left-h.margin.left,N=dn(h.positions,C);P(N>=0?N:null);},[g,r.length,h.margin.left,h.positions]),k=useCallback(T=>{if(r.length===0)return;let S=r.length-1,C=w??0,N=T.key==="ArrowRight"?Math.min(S,C+1):T.key==="ArrowLeft"?Math.max(0,C-1):T.key==="Home"?0:T.key==="End"?S:T.key==="Escape"?null:void 0;N!==void 0&&(T.preventDefault(),P(N));},[r.length,w]),I=useCallback(()=>{if(!x||w===null)return;let[T]=E(w);T&&x({...T,index:w,x:h.xValues[w]});},[x,w,E,h.xValues]),W=w===null?null:E(w),O=w===null?[]:h.visible.map((T,S)=>{let C=h.rows[w].segments[S];return C.value===null?null:{key:T.key,color:T.color,y:h.valueScale(C.end)}}).filter(T=>T!==null),L=w===null||W===null?null:{x:h.xValues[w],xLabel:M(h.xValues[w],w),index:w,points:W};return jsxs(Fragment,{children:[jsxs("svg",{width:e,height:t,role:"img","aria-label":b??h.visible.map(T=>Bt(T)).join(", "),tabIndex:0,className:"touch-none focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-blue-500",onPointerMove:D,onPointerLeave:()=>P(null),onKeyDown:k,onBlur:()=>P(null),onClick:I,children:[jsxs("g",{transform:`translate(${h.margin.left}, ${h.margin.top})`,children:[jsx(Kr,{width:h.innerWidth,height:h.innerHeight,horizontal:s==="y"||s==="both"?h.yTicks.map(T=>T.offset):void 0,vertical:s==="x"||s==="both"?h.xTicks.map(T=>T.offset):void 0}),jsx(kp,{bands:h.bands,stacked:h.stacked}),f?.map(T=>{let S=h.valueScale(T.value),C=S<vp?S+12:S-4;return jsxs("g",{children:[jsx("line",{x1:0,y1:S,x2:h.innerWidth,y2:S,stroke:T.color??"var(--color-chart-muted)",strokeWidth:1,strokeDasharray:T.dashed===false?void 0:"4 4"}),T.label?jsx("text",{x:h.innerWidth,y:C,textAnchor:"end",className:"fill-gray-500 text-[10px] dark:fill-gray-400",children:T.label}):null]},`${T.value}-${T.label??""}`)}),w!==null?jsxs("g",{"aria-hidden":"true",children:[jsx("line",{x1:h.positions[w],y1:0,x2:h.positions[w],y2:h.innerHeight,className:"stroke-gray-400 dark:stroke-gray-500",strokeWidth:1}),O.map(T=>jsx("circle",{cx:h.positions[w],cy:T.y,r:4,fill:T.color,strokeWidth:2,className:"stroke-white dark:stroke-gray-800"},T.key))]}):null]}),jsx("g",{transform:`translate(${h.margin.left}, ${h.margin.top+h.innerHeight})`,children:o.hidden?null:jsx(St,{orientation:"bottom",ticks:h.xTicks,length:h.innerWidth,label:o.label,size:l})}),jsx("g",{transform:`translate(${h.margin.left}, ${h.margin.top})`,children:a?.hidden?null:jsx(St,{orientation:"left",ticks:h.yTicks,length:h.innerHeight,showLine:false,label:a?.label,size:l})})]}),L&&g!==false?jsx(jt,{x:h.margin.left+h.positions[L.index],y:h.margin.top+(O.length>0?Math.min(...O.map(T=>T.y)):h.innerHeight/2),containerWidth:e,children:typeof g=="function"?g(L):jsx(vr,{title:L.xLabel,points:L.points})}):null]})}function wp({data:e,series:t,x:r,y:n,height:o=240,width:a,size:s="md",grid:l="y",legend:i,tooltip:d=true,tableView:c=false,emphasis:p,title:f,description:m,loading:g=false,emptyState:x,onPointClick:b,curve:v="monotone",stack:y="none",baseline:M=0,connectNulls:w=false,referenceLines:P,legendToggle:h=true,margin:E,locale:D,plotLabel:k,className:I,...W}){let[O,L]=useState(()=>new Set),T=useMemo(()=>t.map((A,B)=>({...A,hidden:A.hidden||O.has(A.key),color:Ir(A,B,p)})),[t,O,p]),S=y==="percent",C=useMemo(()=>S?{domain:[0,100],...n}:n,[S,n]),N=useMemo(()=>n?.format??(S?A=>xr(A,{locale:D,alreadyScaled:true,maximumFractionDigits:0}):A=>vt(A,D)),[n?.format,S,D]),R=useMemo(()=>A=>vt(A,D),[D]),$=useMemo(()=>r.format??(A=>r.scale==="time"?bt(A instanceof Date?A:new Date(Lr(A)),D):bt(A,D)),[r.format,r.scale,D]),H=useCallback(A=>{L(B=>{let U=new Set(B);return U.has(A)?U.delete(A):U.add(A),U});},[]),K=i===void 0?t.length>=2:i!==false,_=typeof i=="string"?i:"bottom",F=T.filter(A=>!A.hidden).length;return jsx(Kt,{title:f,description:m,height:o,width:a,size:s,loading:g,empty:e.length===0||F===0,emptyState:x,tableView:c,legendPosition:_,legend:K?jsx(yr,{items:Ur(T,p),position:_,marker:"rect",size:s,onToggle:h?H:void 0}):void 0,table:c?jsx(Yt,{data:e,series:T,xKey:r.key,xLabel:r.label??r.key,formatX:$,formatValue:R,caption:typeof f=="string"?f:void 0}):void 0,className:I,...W,children:({width:A})=>jsx(Cp,{width:A,height:o,data:e,resolvedSeries:T,x:r,y:C,grid:l,size:s,curve:v,stack:y,baseline:M,connectNulls:w,referenceLines:P,margin:E,tooltip:d,onPointClick:b,plotLabel:k,formatValue:N,formatRaw:R,formatX:$})})}var Sp={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"},Rp={circle:"rounded-full",square:"rounded-none",rounded:"rounded-md"};function Tp({src:e,alt:t="Avatar",fallback:r,size:n="md",variant:o="circle",border:a=false,className:s,...l}){return jsx("div",{className:u("inline-flex items-center justify-center overflow-hidden bg-gray-200 font-medium text-gray-600 dark:bg-gray-700 dark:text-gray-300",Sp[n],Rp[o],a&&"ring-2 ring-white dark:ring-gray-900",s),...l,children:e?jsx("img",{src:e,alt:t,className:"h-full w-full object-cover"}):jsx("span",{children:r||t.charAt(0).toUpperCase()})})}var Pp={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"}},Ep={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"},Dp={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"},Mp={sm:"w-1.5 h-1.5",md:"w-1.5 h-1.5",lg:"w-2 h-2"},Ip={sm:"w-2.5 h-2.5",md:"w-3 h-3",lg:"w-3.5 h-3.5"};function $l({children:e,color:t="default",size:r="md",variant:n="soft",dot:o=false,icon:a,pill:s=true,className:l,...i}){return jsxs("span",{className:u("inline-flex items-center font-medium",Dp[r],s?"rounded-full":"rounded",Pp[t][n],l),...i,children:[o&&jsx("span",{className:u("shrink-0 rounded-full",Mp[r],Ep[t]),"aria-hidden":"true"}),a&&!o&&jsx("span",{className:u("shrink-0",Ip[r]),"aria-hidden":"true",children:a}),e]})}$l.displayName="Badge";var Ap={sm:"text-[10px]",md:"text-[11px]",lg:"text-xs"};function Bo({scale:e,label:t,format:r,ticks:n=3,size:o="md",thickness:a=10,locale:s,className:l,...i}){let[d,c]=e.domain,p=r??(y=>vt(y,s)),f=e.steps,m=f!==null&&f>0,g=Math.max(2,Math.round(n)),x=m?Array.from({length:f+1},(y,M)=>M/f):Array.from({length:g},(y,M)=>M/(g-1)),b=y=>d+y*(c-d),v=m?jsx("div",{className:"flex h-full w-full overflow-hidden rounded-sm",children:Array.from({length:f},(y,M)=>jsx("span",{className:"h-full grow",style:{backgroundColor:e(b((M+.5)/f))}},M))}):jsx("div",{className:"h-full w-full rounded-sm",style:{backgroundImage:`linear-gradient(to right, ${e.colors.join(", ")})`}});return jsxs("div",{className:u("flex w-full max-w-80 flex-col gap-1",Ap[o],l),...i,children:[t?jsx("span",{className:"text-gray-600 dark:text-gray-300",children:t}):null,jsx("div",{style:{height:a},"aria-hidden":"true",children:v}),jsx("div",{className:"relative h-4 w-full",children:x.map((y,M)=>jsx("span",{className:"absolute top-0 whitespace-nowrap text-gray-500 [font-variant-numeric:tabular-nums] dark:text-gray-400",style:{left:`${y*100}%`,transform:`translateX(${M===0?"0":M===x.length-1?"-100%":"-50%"})`},children:p(b(y))},y))})]})}var Hp=24,Pn=2,Fp=4,to=6,Vp=10,Bp=memo(function({bars:t}){return jsx("g",{children:t.map((r,n)=>jsxs("g",{children:[jsx("path",{d:r.d,fill:r.color}),r.label?jsx("text",{x:r.label.x,y:r.label.y,textAnchor:r.label.anchor,dominantBaseline:"middle",className:"fill-gray-600 text-[10px] [font-variant-numeric:tabular-nums] dark:fill-gray-300",children:r.label.text}):null]},`${r.key}-${n}`))})});function Op({width:e,height:t,data:r,resolvedSeries:n,x:o,y:a,grid:s,size:l,orientation:i,stack:d,center:c,centerKey:p,valueColors:f,barSize:m,showValues:g,referenceLines:x,margin:b,tooltip:v,onPointClick:y,plotLabel:M,formatValue:w,formatRaw:P,formatX:h}){let[E,D]=useState(null),k=useMemo(()=>{let N=i==="vertical",R=n.filter(ke=>!ke.hidden),$=R.map(ke=>ke.key),H=p!==null||d!=="none",K=p!==null?Vl(r,$,{centerKey:p,percent:d==="percent"}):Ea(r,$,d),_=H?Da(K):Ot(ir(r,$)),F=cn({width:e,height:t,data:r,x:o,y:a,bounds:_===null?null:[Math.min(_[0],c),Math.max(_[1],c)],margin:b,orientation:i,placement:"band",formatValue:w,formatX:h,defaultIncludeZero:c===0}),{valueScale:A,bandwidth:B,categoryPositions:U,innerWidth:Q,innerHeight:J}=F,Y=A(c),z=Math.max(1,R.length),X=H?B:B/z,ne=Math.min(m??Hp,Math.max(1,X-(H?0:Pn))),re=H?ne:z*ne+(z-1)*Pn,q=(B-re)/2,de=[],xe=ke=>H?ke.end>=ke.start:ke.end>=c;return K.forEach((ke,le)=>{let Se=-1,Me=-1;ke.segments.forEach(($e,ie)=>{$e.value!==null&&$e.outer!==false&&(xe($e)?Se=ie:Me=ie);});let je=0,at=0;ke.segments.forEach(($e,ie)=>{if($e.value===null)return;let he=R[ie],Ie=xe($e),xt=A(H?$e.start:c),Te=A($e.end),Ee=Math.min(xt,Te),nt=Math.abs(Te-xt),pr=$e.base??(Ie?je===0:at===0),pt=N?!Ie:Ie;H&&!pr&&nt>Pn&&(nt-=Pn,pt&&(Ee+=Pn)),Ie?je+=1:at+=1;let Ht=U[le]+(H?q:q+ie*(ne+Pn)),sr=ie===(Ie?Se:Me)?N?Ie?"top":"bottom":Ie?"right":"left":"none",Nr=N?{x:Ht,y:Ee,width:ne,height:nt}:{x:Ee,y:Ht,width:nt,height:ne},Gt=null;if(g&&!H){let er=P($e.value),tr=Sn(er,10);if(N){let ue=Ie?Ee:Ee+nt,me=Ie?ue-to:ue+to,Z=z>1?ne+Pn:B;tr<=Z&&(Ie?me>8:me<J-4)&&(Gt={x:Ht+ne/2,y:me,anchor:"middle",text:er});}else {let ue=Ie?Ee+nt:Ee,me=Ie?Q-ue-to:ue-to;tr<=me&&(Gt={x:Ie?ue+to:ue-to,y:Ht+ne/2,anchor:Ie?"start":"end",text:er});}}de.push({key:he.key,color:f&&$e.value!==null?f($e.value):he.color,d:Fo({...Nr,radius:Fp,round:sr}),label:Gt});});}),{vertical:N,visible:R,rows:K,stacked:H,xValues:F.xValues,categoryPositions:U,categoryCenters:F.categoryCenters,bandwidth:B,categoryTicks:F.categoryTicks,valueTicks:F.valueTicks,valueScale:A,baseline:Y,innerWidth:Q,innerHeight:J,margin:F.margin,bars:de}},[r,n,o,a,e,t,b,i,d,c,p,f,m,g,w,P,h]),I=useCallback(N=>k.visible.map((R,$)=>{let H=et(r[N],R.key),K=k.rows[N].segments[$],_=H===null?"\u2014":d==="percent"?`${P(H)} (${w(K.end-K.start)})`:w(H);return {seriesKey:R.key,seriesLabel:Bt(R),color:R.color,value:H,formattedValue:_,datum:r[N]}}),[r,k.visible,k.rows,d,w,P]),W=useCallback(N=>{if(v===false||r.length===0)return;let R=N.currentTarget.getBoundingClientRect(),$=k.vertical?N.clientX-R.left-k.margin.left:N.clientY-R.top-k.margin.top,H=dn(k.categoryCenters,$);D(H>=0?H:null);},[v,r.length,k.vertical,k.margin,k.categoryCenters]),O=useCallback(N=>{if(r.length===0)return;let R=r.length-1,$=E??0,H=k.vertical?"ArrowRight":"ArrowDown",K=k.vertical?"ArrowLeft":"ArrowUp",_=N.key===H?Math.min(R,$+1):N.key===K?Math.max(0,$-1):N.key==="Home"?0:N.key==="End"?R:N.key==="Escape"?null:void 0;_!==void 0&&(N.preventDefault(),D(_));},[r.length,E,k.vertical]),L=useCallback(()=>{if(!y||E===null)return;let[N]=I(E);N&&y({...N,index:E,x:k.xValues[E]});},[y,E,I,k.xValues]),T=E===null?null:I(E),S=E===null||T===null?null:{x:k.xValues[E],xLabel:h(k.xValues[E],E),index:E,points:T},C=E===null?null:k.vertical?{x:k.margin.left+k.categoryCenters[E],y:k.margin.top+Math.min(...k.rows[E].segments.filter(N=>N.value!==null).map(N=>k.valueScale(N.end)),k.baseline)}:{x:k.margin.left+Math.max(...k.rows[E].segments.filter(N=>N.value!==null).map(N=>k.valueScale(N.end)),k.baseline),y:k.margin.top+k.categoryCenters[E]};return jsxs(Fragment,{children:[jsxs("svg",{width:e,height:t,role:"img","aria-label":M??k.visible.map(N=>Bt(N)).join(", "),tabIndex:0,className:"touch-none focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-blue-500",onPointerMove:W,onPointerLeave:()=>D(null),onKeyDown:O,onBlur:()=>D(null),onClick:L,children:[jsxs("g",{transform:`translate(${k.margin.left}, ${k.margin.top})`,children:[jsx(Kr,{width:k.innerWidth,height:k.innerHeight,horizontal:k.vertical&&(s==="y"||s==="both")?k.valueTicks.map(N=>N.offset):void 0,vertical:!k.vertical&&(s==="y"||s==="both")?k.valueTicks.map(N=>N.offset):void 0}),E!==null?jsx("rect",{x:k.vertical?k.categoryPositions[E]:0,y:k.vertical?0:k.categoryPositions[E],width:k.vertical?k.bandwidth:k.innerWidth,height:k.vertical?k.innerHeight:k.bandwidth,className:"fill-gray-400 dark:fill-gray-500",opacity:.12,"aria-hidden":"true"}):null,jsx(Bp,{bars:k.bars}),jsx("line",{x1:k.vertical?0:k.baseline,y1:k.vertical?k.baseline:0,x2:k.vertical?k.innerWidth:k.baseline,y2:k.vertical?k.baseline:k.innerHeight,className:"stroke-gray-300 dark:stroke-gray-600",strokeWidth:1,shapeRendering:"crispEdges"}),x?.map(N=>{let R=k.valueScale(N.value),$=R<Vp?R+12:R-4;return jsxs("g",{children:[jsx("line",{x1:k.vertical?0:R,y1:k.vertical?R:0,x2:k.vertical?k.innerWidth:R,y2:k.vertical?R:k.innerHeight,stroke:N.color??"var(--color-chart-muted)",strokeWidth:1,strokeDasharray:N.dashed===false?void 0:"4 4"}),N.label?jsx("text",{x:k.vertical?k.innerWidth:R+4,y:k.vertical?$:8,textAnchor:k.vertical?"end":"start",className:"fill-gray-500 text-[10px] dark:fill-gray-400",children:N.label}):null]},`${N.value}-${N.label??""}`)})]}),jsx("g",{transform:`translate(${k.margin.left}, ${k.margin.top+k.innerHeight})`,children:(k.vertical?o.hidden:a?.hidden)?null:jsx(St,{orientation:"bottom",ticks:k.vertical?k.categoryTicks:k.valueTicks,length:k.innerWidth,label:k.vertical?o.label:a?.label,size:l})}),jsx("g",{transform:`translate(${k.margin.left}, ${k.margin.top})`,children:(k.vertical?a?.hidden:o.hidden)?null:jsx(St,{orientation:"left",ticks:k.vertical?k.valueTicks:k.categoryTicks,length:k.innerHeight,showLine:false,label:k.vertical?a?.label:o.label,size:l})})]}),S&&C&&v!==false?jsx(jt,{x:C.x,y:C.y,containerWidth:e,children:typeof v=="function"?v(S):jsx(vr,{title:S.xLabel,points:S.points})}):null]})}function $p({data:e,series:t,x:r,y:n,height:o=260,width:a,size:s="md",grid:l="y",legend:i,tooltip:d=true,tableView:c=false,emphasis:p,title:f,description:m,loading:g=false,emptyState:x,onPointClick:b,orientation:v="vertical",stack:y="none",diverging:M,barSize:w,sort:P="none",showValues:h=false,referenceLines:E,legendToggle:D=true,margin:k,locale:I,plotLabel:W,className:O,...L}){let[T,S]=useState(()=>new Set),C=typeof M=="string"?M:null,N=typeof M=="number"?M:0,R=useMemo(()=>{let X=C===null?null:qn([0,Math.max(1,t.length-1)],{center:Math.max(0,t.findIndex(ne=>ne.key===C)),symmetric:false});return t.map((ne,re)=>({...ne,hidden:ne.hidden||T.has(ne.key),color:X&&!ne.color&&!p?ne.key===C?Mr:X(re):Ir(ne,re,p)}))},[t,T,p,C]),$=useMemo(()=>{if(P==="none")return e;let X=R.filter(re=>!re.hidden).map(re=>re.key),ne=re=>X.reduce((q,de)=>q+(et(re,de)??0),0);return [...e].sort((re,q)=>P==="asc"?ne(re)-ne(q):ne(q)-ne(re))},[e,P,R]),H=y==="percent",K=useMemo(()=>H?{domain:C===null?[0,100]:[-100,100],...n}:n,[H,C,n]),_=useMemo(()=>X=>vt(X,I),[I]),F=useMemo(()=>{let X=n?.format??(H?ne=>xr(ne,{locale:I,alreadyScaled:true,maximumFractionDigits:0}):_);return C===null?X:ne=>X(Math.abs(ne))},[n?.format,H,I,_,C]),A=useMemo(()=>r.format??(X=>bt(X,I)),[r.format,I]),B=useCallback(X=>{S(ne=>{let re=new Set(ne);return re.has(X)?re.delete(X):re.add(X),re});},[]),U=i===void 0?t.length>=2:i!==false,Q=typeof i=="string"?i:"bottom",J=R.filter(X=>!X.hidden),Y=J.length,z=useMemo(()=>{if(M===void 0||M===false||C!==null||Y!==1)return null;let X=ir($,J.map(re=>re.key)),ne=Qn([...X,N],{domain:n?.domain,includeZero:n?.includeZero??N===0,ticks:n?.ticks??5});return qn(ne,{center:N})},[M,C,Y,J,$,N,n]);return jsx(Kt,{title:f,description:m,height:o,width:a,size:s,loading:g,empty:e.length===0||Y===0,emptyState:x,tableView:c,legendPosition:Q,legend:z?jsx(Bo,{scale:z,label:n?.label,format:F,size:s,locale:I}):U?jsx(yr,{items:Ur(R,p),position:Q,marker:"rect",size:s,onToggle:D?B:void 0}):void 0,table:c?jsx(Yt,{data:$,series:R,xKey:r.key,xLabel:r.label??r.key,formatX:A,formatValue:_,caption:typeof f=="string"?f:void 0}):void 0,className:O,...L,children:({width:X})=>jsx(Op,{width:X,height:o,data:$,resolvedSeries:R,x:r,y:K,grid:l,size:s,orientation:v,stack:y,center:N,centerKey:C,valueColors:z,barSize:w,showValues:h,referenceLines:E,margin:k,tooltip:d,onPointClick:b,plotLabel:W,formatValue:F,formatRaw:_,formatX:A})})}function Xl({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 Xp({className:e}){return jsx("svg",{className:e,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",children:jsx("path",{d:"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 Gp({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 Kp({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 Us({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 Up={info:Xl,success:Xp,warning:Gp,error:Kp,default:Xl},Yp={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"},jp={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 qp({type:e="default",title:t,description:r,children:n,icon:o,action:a,closable:s=false,onClose:l,fullWidth:i=false,className:d,...c}){let[p,f]=useState(true);if(!p)return null;let m=()=>{f(false),l?.();},g=Up[e],x=n??r;return jsxs("div",{role:"alert",className:u("flex items-start gap-3 border px-4 py-3",i?"w-full":"rounded-lg",Yp[e],d),...c,children:[jsx("div",{className:u("shrink-0 mt-0.5",jp[e]),children:o??jsx(g,{className:"w-5 h-5"})}),jsxs("div",{className:"flex-1 min-w-0",children:[t&&jsx("div",{className:"font-semibold text-sm",children:t}),x&&jsx("div",{className:u("text-sm",t?"mt-1 opacity-90":false),children:x}),a&&jsx("div",{className:"mt-3",children:a})]}),s&&jsx("button",{type:"button",onClick:m,className:u("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(Us,{className:"w-4 h-4"})})]})}function Zp({title:e,description:t,children:r,action:n,backgroundImage:o,closable:a=false,onClose:s,fullWidth:l=false,className:i,...d}){let[c,p]=useState(true);if(!c)return null;let f=()=>{p(false),s?.();},m=r??t;return jsxs("div",{className:u("relative overflow-hidden bg-gray-900 text-white",l?"w-full":"rounded-xl","py-12 px-6 sm:px-12",i),style:o?{backgroundImage:`url(${o})`,backgroundSize:"cover",backgroundPosition:"center"}:void 0,...d,children:[o&&jsx("div",{className:"absolute inset-0 bg-black/50","aria-hidden":"true"}),jsxs("div",{className:"relative z-10 max-w-3xl mx-auto text-center",children:[e&&jsx("h2",{className:"text-2xl sm:text-3xl lg:text-4xl font-bold tracking-tight",children:e}),m&&jsx("div",{className:u("text-base sm:text-lg opacity-90",e?"mt-4":false),children:m}),n&&jsx("div",{className:"mt-6",children:n})]}),a&&jsx("button",{type:"button",onClick:f,className:u("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(Us,{className:"w-5 h-5"})})]})}function Qp({title:e,description:t,children:r,icon:n,action:o,badge:a,closable:s=false,onClose:l,fullWidth:i=false,className:d,...c}){let[p,f]=useState(true);if(!p)return null;let m=()=>{f(false),l?.();},g=r??t;return jsxs("div",{className:u("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),...c,children:[n&&jsx("div",{className:"shrink-0",children:n}),a&&jsx("span",{className:"shrink-0 inline-flex items-center rounded-full bg-white/20 px-2.5 py-0.5 text-xs font-semibold uppercase tracking-wide",children:a}),jsxs("div",{className:"flex-1 min-w-0 flex flex-wrap items-center gap-x-4 gap-y-1",children:[e&&jsx("span",{className:"font-semibold text-sm",children:e}),g&&jsx("span",{className:"text-sm opacity-90",children:g})]}),o&&jsx("div",{className:"shrink-0",children:o}),s&&jsx("button",{type:"button",onClick:m,className:u("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(Us,{className:"w-4 h-4"})})]})}function Gl({variant:e="notification",...t}){switch(e){case "hero":return jsx(Zp,{...t});case "promotion":return jsx(Qp,{...t});default:return jsx(qp,{...t})}}Gl.displayName="Banner";var Jp={sm:"text-xs",md:"text-sm",lg:"text-base"};function em({items:e,separator:t="/",size:r="md",maxItems:n,itemColor:o="text-gray-500 hover:text-gray-900 dark:text-gray-400 dark:hover:text-gray-100",activeColor:a="text-gray-700 font-medium dark:text-gray-200",separatorColor:s="text-gray-400 dark:text-gray-500",className:l,...i}){let d=e,c=false;if(n&&e.length>n){c=true;let p=e[0],f=e.slice(-(n-1));d=[p,...f];}return jsx("nav",{"aria-label":"Breadcrumb",className:u("inline-flex items-center",Jp[r],l),...i,children:jsx("ol",{className:"inline-flex items-center space-x-1 md:space-x-2",children:d.map((p,f)=>{let m=f===d.length-1;return jsxs("li",{className:"inline-flex items-center",children:[c&&f===1&&jsxs(Fragment,{children:[jsx("span",{className:u("mx-1 select-none",s),children:"..."}),jsx("span",{className:u("mx-1 select-none",s),"aria-hidden":"true",children:t})]}),p.href||p.onClick?jsxs("a",{href:p.href,onClick:p.onClick,className:u("inline-flex items-center gap-1.5 transition-colors",m?a:o),"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:u("inline-flex items-center gap-1.5",m?a:o),"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:u("mx-2 select-none",s),"aria-hidden":"true",children:t})]},p.href??p.label)})})})}var om=22,am=.42,Kl=3,Ul=8,sm=12,im=["fill-gray-300 dark:fill-gray-500","fill-gray-200 dark:fill-gray-600","fill-gray-100 dark:fill-gray-700","fill-gray-50 dark:fill-gray-800"],lm=memo(function({rows:t,color:r}){return jsx("g",{children:t.map(n=>jsxs("g",{children:[n.bands.map(o=>jsx("path",{d:o.d,className:o.className,fill:o.fill},o.key)),n.measure?jsx("path",{d:n.measure,fill:r}):null,n.target?jsx("line",{x1:n.target.x,y1:n.target.y1,x2:n.target.x,y2:n.target.y2,strokeWidth:2,strokeLinecap:"round",className:"stroke-gray-900 dark:stroke-white"}):null,n.label?jsx("text",{x:n.label.x,y:n.label.y,dominantBaseline:"middle",className:"fill-gray-700 text-[11px] font-medium [font-variant-numeric:tabular-nums] dark:fill-gray-200",children:n.label.text}):null]},n.key))})});function dm({width:e,height:t,rows:r,x:n,size:o,sharedDomain:a,showValues:s,trackSize:l,rangeColors:i,color:d,tooltip:c,plotLabel:p,formatValue:f,onRowClick:m}){let[g,x]=useState(null),b=useMemo(()=>{let P=r.map(R=>R.label),h=s?r.map(R=>R.formattedValue):[],E={top:6,right:s?br(h)+Ul*2:8,bottom:a?26+(n.label?16:0):6,left:n.hidden?8:n.height??br(P)+sm},D=Math.max(0,e-E.left-E.right),k=Math.max(0,t-E.top-E.bottom),I=Rn(r.map((R,$)=>$),[0,k],{paddingInner:.34}),W=Math.min(l??om,I.bandwidth),O=Math.max(3,W*am),L=i??im,T=i!==void 0,S=r.map((R,$)=>{let H=Math.max(0,R.value??0,R.target??0,...R.ranges.length>0?R.ranges:[0]),K=a??(R.ranges.length>0?[0,H]:Pa(0,H,4)),_=Ar(K,[0,D]),F=I($)+(I.bandwidth-W)/2,A=F+W/2,B=R.ranges.length>0?[...R.ranges].sort((Y,z)=>Y-z):[K[1]],U=K[0],Q=B.map((Y,z)=>{let X=_(U),ne=_(Math.max(U,Y));U=Y;let re=L[Math.min(z,L.length-1)];return {key:`${$}-${z}`,d:Fo({x:X,y:F,width:Math.max(0,ne-X),height:W,radius:0}),className:T?void 0:re,fill:T?re:void 0}}),J=R.value===null?null:Fo({x:_(K[0]),y:A-O/2,width:Math.max(0,_(R.value)-_(K[0])),height:O,radius:2,round:"right"});return {key:`${$}`,bands:Q,measure:J,target:R.target===null?null:{x:_(R.target),y1:F-Kl,y2:F+W+Kl},label:s?{x:D+Ul,y:A,text:R.formattedValue}:null,top:I($),height:I.bandwidth}}),C=n.hidden?[]:r.map((R,$)=>({value:R.x,offset:I.center($),label:R.label})),N=a?Wo(a[0],a[1],5).map(R=>({value:R,offset:Ar(a,[0,D])(R),label:f(R)})):[];return {margin:E,innerWidth:D,innerHeight:k,band:I,rendered:S,categoryTicks:C,valueTicks:N,centers:r.map((R,$)=>I.center($))}},[r,n,e,t,a,s,l,i,f]),v=useCallback(P=>{if(c===false||r.length===0)return;let h=P.currentTarget.getBoundingClientRect(),E=P.clientY-h.top-b.margin.top;x(dn(b.centers,E));},[c,r.length,b.margin.top,b.centers]),y=useCallback(P=>{if(r.length===0)return;let h=r.length-1,E=g??0,D=P.key==="ArrowDown"?Math.min(h,E+1):P.key==="ArrowUp"?Math.max(0,E-1):P.key==="Home"?0:P.key==="End"?h:P.key==="Escape"?null:void 0;D!==void 0&&(P.preventDefault(),x(D));},[r.length,g]),M=useCallback(()=>{!m||g===null||m(r[g]);},[m,g,r]),w=g===null?null:r[g];return jsxs(Fragment,{children:[jsxs("svg",{width:e,height:t,role:"img","aria-label":p??r.map(P=>P.label).join(", "),tabIndex:0,className:"touch-none focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-blue-500",onPointerMove:v,onPointerLeave:()=>x(null),onKeyDown:y,onBlur:()=>x(null),onClick:M,children:[jsxs("g",{transform:`translate(${b.margin.left}, ${b.margin.top})`,children:[g!==null&&b.rendered[g]?jsx("rect",{x:-4,y:b.rendered[g].top,width:b.innerWidth+8,height:b.rendered[g].height,rx:4,className:"fill-gray-400 dark:fill-gray-500",opacity:.12,"aria-hidden":"true"}):null,jsx(lm,{rows:b.rendered,color:d})]}),jsx("g",{transform:`translate(${b.margin.left}, ${b.margin.top})`,children:n.hidden?null:jsx(St,{orientation:"left",ticks:b.categoryTicks,length:b.innerHeight,showLine:false,tickSize:0,size:o})}),a?jsx("g",{transform:`translate(${b.margin.left}, ${b.margin.top+b.innerHeight})`,children:jsx(St,{orientation:"bottom",ticks:b.valueTicks,length:b.innerWidth,label:n.label,size:o})}):null]}),w&&g!==null&&c!==false?jsx(jt,{x:b.margin.left+b.innerWidth/2,y:b.margin.top+b.centers[g],containerWidth:e,children:typeof c=="function"?c(w):jsxs("div",{className:"flex flex-col gap-1",children:[jsx("div",{className:"font-medium text-gray-900 dark:text-gray-100",children:w.label}),jsxs("div",{className:"flex items-center gap-2",children:[jsx("span",{className:"h-0.5 w-3 shrink-0 rounded-full",style:{backgroundColor:d},"aria-hidden":"true"}),jsx("span",{className:"font-semibold text-gray-900 [font-variant-numeric:tabular-nums] dark:text-gray-100",children:w.formattedValue}),w.attainment!==null?jsx("span",{className:"text-gray-500 [font-variant-numeric:tabular-nums] dark:text-gray-400",children:xr(w.attainment)}):null]})]})}):null]})}function cm({data:e,x:t,value:r,target:n,ranges:o,domain:a,normalize:s="row",showValues:l=true,trackSize:i,rangeColors:d,color:c,height:p,width:f,size:m="md",tooltip:g=true,tableView:x=false,title:b,description:v,loading:y=false,emptyState:M,locale:w,plotLabel:P,valueLabel:h,targetLabel:E,format:D,onRowClick:k,className:I,...W}){let O=At(),L=useMemo(()=>D??(H=>vt(H,w)),[D,w]),T=useMemo(()=>t.format??(H=>bt(H,w)),[t.format,w]),S=useMemo(()=>e.map((H,K)=>{let _=Ut(H,t.key,K),F=et(H,r),A=n?et(H,n):null,B=o?H[o]:void 0,U=Array.isArray(B)?B.map(Q=>typeof Q=="number"?Q:Number(Q)).filter(Q=>Number.isFinite(Q)):[];return {index:K,x:_,label:T(_,K),value:F,target:A,ranges:U,formattedValue:F===null?"\u2014":L(F),formattedTarget:A===null?"\u2014":L(A),attainment:F===null||A===null||A===0?null:F/A,datum:H}}),[e,t.key,r,n,o,L,T]),C=useMemo(()=>{if(a)return a;if(s!=="shared")return null;let H=S.reduce((K,_)=>Math.max(K,_.value??0,_.target??0,..._.ranges),0);return Pa(0,H,5)},[a,s,S]),N=p??Math.max(72,S.length*34+(C?30:12)),R=useMemo(()=>[{key:r,label:h??O.chartValue},...n?[{key:n,label:E??O.chartTarget}]:[]],[r,n,h,E,O.chartValue,O.chartTarget]),$=c??jn(0);return jsx(Kt,{title:b,description:v,height:N,width:f,size:m,loading:y,empty:S.length===0,emptyState:M,tableView:x,table:x?jsx(Yt,{data:e,series:R,xKey:t.key,xLabel:t.label??t.key,formatX:T,formatValue:L,caption:typeof b=="string"?b:void 0}):void 0,className:I,...W,children:({width:H})=>jsx(dm,{width:H,height:N,rows:S,x:t,size:m,sharedDomain:C,showValues:l,trackSize:i,rangeColors:d,color:$,tooltip:g,plotLabel:P,formatValue:L,onRowClick:k})})}function pm({className:e}){return jsxs("svg",{className:u("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 mm={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"},gm={sm:"p-1.5",md:"p-2",lg:"p-2.5",xl:"p-3"},Ia={sm:"h-3.5 w-3.5",md:"h-4 w-4",lg:"h-5 w-5",xl:"h-6 w-6"},fm={none:"rounded-none",sm:"rounded-sm",md:"rounded-md",lg:"rounded-lg",full:"rounded-full"};function ht({label:e,children:t,onClick:r,disabled:n=false,className:o,type:a="button",size:s="md",loading:l=false,leftIcon:i,rightIcon:d,icon:c,fullWidth:p=false,rounded:f="lg",bgColor:m="bg-blue-600 hover:bg-blue-700",textColor:g="text-white",focusColor:x="focus:ring-blue-300",selected:b=false,value:v,showFocusOnClick:y=false,...M}){let w=n||l,P=c!==void 0&&!t&&!e,h=u("inline-flex items-center justify-center font-medium transition-colors focus:outline-none disabled:opacity-50 disabled:cursor-not-allowed",y?"focus:ring-4":"focus-visible:ring-4"),E=u(b?"bg-blue-700 text-white ring-2 ring-blue-500":m,!b&&g,x&&y&&`focus:ring-4 ${x}`,x&&!y&&`focus-visible:ring-4 ${x}`);return jsx("button",{type:a,onClick:r,disabled:w,"data-value":v,className:u(h,P?gm[s]:mm[s],fm[f],E,p&&"w-full",o),...M,children:l?jsx(pm,{className:Ia[s]}):P?jsx("span",{className:Ia[s],children:c}):jsxs(Fragment,{children:[i&&jsx("span",{className:Ia[s],children:i}),t??e,d&&jsx("span",{className:Ia[s],children:d})]})})}function ao({children:e,orientation:t="horizontal",size:r,fullWidth:n=false,selectedValue:o,onChange:a,className:s}){let i=js__default.Children.toArray(e).filter(c=>js__default.isValidElement(c)&&typeof c.type!="string"),d=(c,p)=>f=>{c!==void 0&&a&&a(c),p&&p(f);};return jsx("div",{className:u("inline-flex",t==="horizontal"?"flex-row":"flex-col",n&&"w-full",s),role:"group",children:i.map((c,p)=>{let f=p===0,m=p===i.length-1,g=!f&&!m,x=c.props.value,b=o!==void 0&&x===o,v=u(t==="horizontal"&&f&&"rounded-r-none",t==="horizontal"&&m&&"rounded-l-none",t==="horizontal"&&g&&"rounded-none",t==="horizontal"&&!f&&"-ml-px",t==="vertical"&&f&&"rounded-b-none",t==="vertical"&&m&&"rounded-t-none",t==="vertical"&&g&&"rounded-none",t==="vertical"&&!f&&"-mt-px",n&&"flex-1");return js__default.cloneElement(c,{...c.props,size:r??c.props.size,selected:b||c.props.selected,onClick:d(x,c.props.onClick),className:u(v,c.props.className)})})})}var xm=10080*60*1e3;function Tt(e){return new Date(e.getFullYear(),e.getMonth(),e.getDate())}function Mn(e){return new Date(e.getFullYear(),e.getMonth(),1)}function qr(e,t){return new Date(e.getFullYear(),e.getMonth(),e.getDate()+t)}function kr(e,t){return new Date(e.getFullYear(),e.getMonth()+t,1)}function Zs(e){return new Date(e.getFullYear(),e.getMonth()+1,0).getDate()}function zr(e,t){return !e||!t?false:e.getFullYear()===t.getFullYear()&&e.getMonth()===t.getMonth()&&e.getDate()===t.getDate()}function qs(e,t){return e.getFullYear()===t.getFullYear()&&e.getMonth()===t.getMonth()}function mn(e,t){return e.getFullYear()*12+e.getMonth()-(t.getFullYear()*12+t.getMonth())}function Aa(e){let t=`${e.getMonth()+1}`.padStart(2,"0"),r=`${e.getDate()}`.padStart(2,"0");return `${e.getFullYear()}-${t}-${r}`}function vm(e){let t=Tt(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())/xm)}function ql(e,t,r){return t&&e<Tt(t)?Tt(t):r&&e>Tt(r)?Tt(r):e}function km(e,t,r){let n=Mn(e),o=(n.getDay()-t+7)%7,a=qr(n,-o),s=r?6:Math.ceil((o+Zs(e))/7);return Array.from({length:s},(l,i)=>Array.from({length:7},(d,c)=>qr(a,i*7+c)))}function Cm({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 wm({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 Nm={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"}},Sm={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"},Rm={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"},Tm={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"},Pm={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"},Dn={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 za(e,t){if(e==="multiple")return Array.isArray(t)?t.map(Tt):[];if(e==="range"){let r=t??null;return {from:r?.from?Tt(r.from):null,to:r?.to?Tt(r.to):null}}return t instanceof Date?Tt(t):null}function Zl(e){return e?e instanceof Date?e:Array.isArray(e)?e[0]??null:e.from??e.to??null:null}function Em(e){let{mode:t="single",value:r,defaultValue:n,onChange:o,max:a,month:s,defaultMonth:l,onMonthChange:i,numberOfMonths:d=1,weekStartsOn:c=0,locale:p,size:f="md",color:m="primary",minDate:g,maxDate:x,disabledDates:b,disabled:v=false,showOutsideDays:y=true,showWeekNumbers:M=false,fixedWeeks:w=false,captionLayout:P="label",fromYear:h,toYear:E,todayButton:D=false,clearButton:k=false,footer:I,bordered:W=true,renderDay:O,labels:L,className:T,...S}=e,C=Nm[f],N=Math.max(1,d),R=useMemo(()=>Tt(new Date),[]),$=r!==void 0,[H,K]=useState(()=>za(t,n)),_=$?za(t,r):H,F=s!==void 0,[A,B]=useState(()=>Mn(l??Zl(za(t,n??r))??new Date)),U=F?Mn(s):A,Q=useCallback(ue=>{let me=Mn(ue);F||B(me),i?.(me);},[F,i]),J=useRef(null),Y=useRef(false),[z,X]=useState(()=>{let ue=Zl(za(t,n??r)),me=Mn(l??s??ue??new Date),Z=ue&&qs(ue,me)?ue:qs(Tt(new Date),me)?Tt(new Date):me;return ql(Z,g,x)}),ne=kr(U,N-1),q=mn(z,U)>=0&&mn(z,ne)<=0?z:U;useEffect(()=>{if(!Y.current)return;Y.current=false,J.current?.querySelector(`[data-day="${Aa(z)}"]:not([data-outside])`)?.focus();},[z,U]);let de=useCallback(ue=>{let me=ql(Tt(ue),g,x);Y.current=true,X(me);let Z=kr(U,N-1);mn(me,U)<0?Q(me):mn(me,Z)>0&&Q(kr(me,-(N-1)));},[U,N,g,x,Q]),xe=useCallback(ue=>v||g&&ue<Tt(g)||x&&ue>Tt(x)?true:typeof b=="function"?b(ue):Array.isArray(b)?b.some(me=>zr(me,ue)):false,[v,g,x,b]),[ke,le]=useState(null),Se=useCallback(ue=>{$||K(ue),o?.(ue);},[$,o]),Me=useCallback(ue=>{let me=Tt(ue);if(xe(me))return;if(t==="multiple"){let ee=_??[];if(ee.some(ge=>zr(ge,me))){Se(ee.filter(ge=>!zr(ge,me)));return}if(a!==void 0&&ee.length>=a)return;Se([...ee,me].sort((ge,Re)=>ge.getTime()-Re.getTime()));return}if(t==="range"){let ee=_??{from:null,to:null};if(!ee.from||ee.to){Se({from:me,to:null});return}Se(me<ee.from?{from:me,to:ee.from}:{from:ee.from,to:me});return}Se(zr(_,me)?null:me);},[t,_,a,Se,xe]),je=useCallback(ue=>{Me(ue),X(Tt(ue)),mn(ue,U)<0?Q(ue):mn(ue,kr(U,N-1))>0&&Q(kr(ue,-(N-1)));},[Me,U,N,Q]),at=!v&&(!g||mn(U,Mn(g))>0),$e=!v&&(!x||mn(kr(U,N-1),Mn(x))<0),ie=useCallback(()=>{Q(kr(U,-1));},[U,Q]),he=useCallback(()=>{Q(kr(U,1));},[U,Q]),Ie=useCallback(ue=>{if(v)return;let me=z;switch(ue.key){case "ArrowLeft":ue.preventDefault(),de(qr(me,-1));break;case "ArrowRight":ue.preventDefault(),de(qr(me,1));break;case "ArrowUp":ue.preventDefault(),de(qr(me,-7));break;case "ArrowDown":ue.preventDefault(),de(qr(me,7));break;case "Home":ue.preventDefault(),de(qr(me,-((me.getDay()-c+7)%7)));break;case "End":ue.preventDefault(),de(qr(me,6-(me.getDay()-c+7)%7));break;case "PageUp":{ue.preventDefault();let Z=ue.shiftKey?-12:-1,ee=kr(me,Z),fe=Math.min(me.getDate(),Zs(ee));de(new Date(ee.getFullYear(),ee.getMonth(),fe));break}case "PageDown":{ue.preventDefault();let Z=ue.shiftKey?12:1,ee=kr(me,Z),fe=Math.min(me.getDate(),Zs(ee));de(new Date(ee.getFullYear(),ee.getMonth(),fe));break}}},[v,z,de,c]),xt=useMemo(()=>{let ue=new Intl.DateTimeFormat(p,{weekday:"short"}),me=new Intl.DateTimeFormat(p,{weekday:"long"}),Z=new Date(2024,0,7);return Array.from({length:7},(ee,fe)=>{let ge=qr(Z,(c+fe)%7);return {short:ue.format(ge),long:me.format(ge)}})},[p,c]),Te=useMemo(()=>{let ue=new Intl.DateTimeFormat(p,{month:"long"});return Array.from({length:12},(me,Z)=>ue.format(new Date(2024,Z,1)))},[p]),Ee=useMemo(()=>new Intl.DateTimeFormat(p,{month:"long",year:"numeric"}),[p]),nt=useMemo(()=>new Intl.DateTimeFormat(p,{dateStyle:"full"}),[p]),pr=useMemo(()=>{if(P!=="dropdown")return [];let ue=R.getFullYear(),me=h??g?.getFullYear()??ue-100,Z=E??x?.getFullYear()??ue+10;return Z<me?[me]:Array.from({length:Z-me+1},(ee,fe)=>me+fe)},[P,h,E,g,x,R]),pt=t==="range"?_:null,Ht=pt&&pt.from&&!pt.to&&ke&&ke>pt.from?ke:null,Ft=pt?.to??Ht,sr=useCallback((ue,me)=>{let Z=!qs(ue,me),ee=xe(ue),fe=false,ge=false,Re=false,ve=false;return t==="multiple"?fe=(_??[]).some(we=>zr(we,ue)):t==="range"?(ge=zr(pt?.from,ue),Re=zr(Ft,ue),fe=ge||Re,ve=!!(pt?.from&&Ft&&ue>pt.from&&ue<Ft)):fe=zr(_,ue),{selected:fe,today:zr(ue,R),outside:Z,disabled:ee,rangeStart:ge,rangeEnd:Re,inRange:ve}},[t,_,pt,Ft,xe,R]),Nr=ue=>{let me=kr(U,ue),Z=km(me,c,w),ee=ue===0,fe=ue===N-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:ie,disabled:!at,"aria-label":L?.previousMonth??"Previous month",className:u("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",Dn[m],C.nav,!at&&"cursor-not-allowed opacity-40 hover:bg-transparent dark:hover:bg-transparent",!ee&&"invisible"),children:jsx(Cm,{className:C.icon})}),P==="dropdown"?jsxs("div",{className:"flex items-center gap-1",children:[jsx("select",{"aria-label":L?.monthSelect??"Month",value:me.getMonth(),disabled:v,onChange:ge=>Q(new Date(me.getFullYear(),Number(ge.target.value)-ue,1)),className:u("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",Dn[m],C.select,v&&"cursor-not-allowed opacity-50"),children:Te.map((ge,Re)=>jsx("option",{value:Re,children:ge},ge))}),jsx("select",{"aria-label":L?.yearSelect??"Year",value:me.getFullYear(),disabled:v,onChange:ge=>Q(new Date(Number(ge.target.value),me.getMonth()-ue,1)),className:u("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",Dn[m],C.select,v&&"cursor-not-allowed opacity-50"),children:pr.map(ge=>jsx("option",{value:ge,children:ge},ge))})]}):jsx("div",{"aria-live":"polite",className:u("font-semibold text-gray-900 dark:text-gray-100",C.caption),children:Ee.format(me)}),jsx("button",{type:"button",onClick:he,disabled:!$e,"aria-label":L?.nextMonth??"Next month",className:u("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",Dn[m],C.nav,!$e&&"cursor-not-allowed opacity-40 hover:bg-transparent dark:hover:bg-transparent",!fe&&"invisible"),children:jsx(wm,{className:C.icon})})]}),jsxs("table",{role:"grid","aria-label":Ee.format(me),className:"border-collapse",children:[jsx("thead",{children:jsxs("tr",{children:[M&&jsxs("th",{scope:"col",className:u("font-normal text-gray-400 dark:text-gray-500",C.head),children:[jsx("span",{className:"sr-only",children:L?.weekNumber??"Week number"}),jsx("span",{"aria-hidden":"true",children:"#"})]}),xt.map(ge=>jsx("th",{scope:"col",abbr:ge.long,className:u("font-medium uppercase text-gray-500 dark:text-gray-400",C.head),children:ge.short},ge.long))]})}),jsx("tbody",{children:Z.map(ge=>jsxs("tr",{children:[M&&jsx("td",{className:u("text-center align-middle text-gray-400 dark:text-gray-500",C.head),children:vm(ge[0])}),ge.map(Re=>{let ve=sr(Re,me),we=Aa(Re);if(ve.outside&&!y)return jsx("td",{className:"p-0"},we);let Fe=zr(Re,q)&&!ve.outside,Ae=ve.inRange||ve.rangeStart&&!!Ft||ve.rangeEnd&&!!pt?.from;return jsx("td",{role:"presentation",className:u("p-0",Ae&&Rm[m],Ae&&ve.rangeStart&&"rounded-l-full",Ae&&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:Fe?0:-1,disabled:v,"aria-selected":ve.selected,"aria-disabled":ve.disabled||void 0,"aria-current":ve.today?"date":void 0,"aria-label":nt.format(Re),onClick:()=>{ve.disabled||je(Re);},onMouseEnter:()=>t==="range"&&le(Tt(Re)),onMouseLeave:()=>t==="range"&&le(null),onFocus:()=>X(Tt(Re)),className:u("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",Dn[m],C.day,ve.selected?Sm[m]:ve.inRange?u(Tm[m],"hover:bg-gray-200/60 dark:hover:bg-gray-600/60"):ve.today?u(Pm[m],"hover:bg-gray-100 dark:hover:bg-gray-700"):u("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:O?O(Re,ve):Re.getDate()})},we)})]},Aa(ge[0])))})]})]},Aa(me))},Gt=useCallback(()=>{Q(R),X(R),xe(R)||Me(R);},[R,Q,xe,Me]),er=useCallback(()=>{Se(t==="multiple"?[]:t==="range"?{from:null,to:null}:null);},[t,Se]),tr=!!I||D||k;return jsxs("div",{ref:J,onKeyDown:Ie,className:u("inline-block bg-white dark:bg-gray-900",W&&"rounded-lg border border-gray-200 shadow-sm dark:border-gray-700",C.padding,v&&"opacity-60",T),...S,children:[jsx("div",{className:u("flex flex-wrap",C.gap),children:Array.from({length:N},(ue,me)=>Nr(me))}),tr&&jsxs("div",{className:u("mt-3 flex items-center justify-between gap-2 border-t border-gray-200 pt-3 dark:border-gray-700",C.footer),children:[jsx("div",{className:"text-gray-600 dark:text-gray-400",children:I}),(D||k)&&jsxs("div",{className:"flex items-center gap-2",children:[D&&jsx("button",{type:"button",onClick:Gt,disabled:v,className:u("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",Dn[m],v&&"cursor-not-allowed opacity-50"),children:L?.today??"Today"}),k&&jsx("button",{type:"button",onClick:er,disabled:v,className:u("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",Dn[m],v&&"cursor-not-allowed opacity-50"),children:L?.clear??"Clear"})]})]})]})}function Dm(e,t,r){let n=r||"bg-white dark:bg-gray-800",o=t||"border-gray-200 dark:border-gray-700";switch(e){case "outlined":return u("border-2 bg-transparent",o);case "elevated":return u("shadow-lg border-0",n);case "filled":return u(r||"bg-gray-100 dark:bg-gray-700","border-0");default:return u("border",o,n)}}function Mm(e){switch(e){case "sm":return "max-w-sm";case "lg":return "max-w-2xl";default:return "max-w-md"}}function Im(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 Lm(e){switch(e){case "none":return "";case "sm":return "p-2";case "lg":return "p-6";default:return ""}}function Ql({variant:e="default",size:t="md",rounded:r="lg",padding:n="none",bgColor:o,borderColor:a,shadowColor:s,hoverable:l=false,clickable:i=false,as:d="div",className:c,children:p,onClick:f,...m}){let g=d,x=l?"transition-all duration-200 hover:shadow-lg hover:-translate-y-0.5":"",b=i?"cursor-pointer active:scale-[0.98] transition-transform":"",v=s||"";return jsx(g,{className:u("overflow-hidden",Dm(e,a,o),Mm(t),Im(r),Lm(n),x,b,v,c),onClick:i||f?f:void 0,...m,children:p})}Ql.displayName="Card";function zm(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 ed({actions:e,divider:t=false,padding:r="md",className:n,children:o,...a}){return jsxs("div",{className:u("flex items-center justify-between",zm(r),t&&"border-b border-gray-200 dark:border-gray-700",n),...a,children:[jsx("div",{className:"flex-1",children:o}),e&&jsx("div",{className:"flex items-center gap-2 ml-4",children:e})]})}ed.displayName="CardHeader";function Hm(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 td({padding:e="md",className:t,children:r,...n}){return jsx("div",{className:u(Hm(e),t),...n,children:r})}td.displayName="CardBody";function Vm(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 Bm(e){switch(e){case "center":return "justify-center";case "right":return "justify-end";case "between":return "justify-between";default:return "justify-start"}}function rd({divider:e=false,align:t="left",padding:r="md",className:n,children:o,...a}){return jsx("div",{className:u("flex items-center gap-2",Vm(r),Bm(t),e&&"border-t border-gray-200 dark:border-gray-700",n),...a,children:o})}rd.displayName="CardFooter";function $m(e){switch(e){case "square":return "aspect-square";case "video":return "aspect-video";case "wide":return "aspect-[21/9]";default:return ""}}function _m(e){switch(e){case "contain":return "object-contain";case "fill":return "object-fill";case "none":return "object-none";default:return "object-cover"}}function nd({position:e="top",aspectRatio:t="auto",objectFit:r="cover",src:n,alt:o,className:a,...s}){let l=e==="top"?"rounded-t-lg":"rounded-b-lg";return jsx("img",{src:n,alt:o,className:u("w-full",$m(t),_m(r),l,a),...s})}nd.displayName="CardImage";function Gm(e){switch(e){case "sm":return "text-base font-medium";case "lg":return "text-2xl font-bold";default:return "text-xl font-semibold"}}function od({as:e="h3",size:t="md",className:r,children:n,...o}){return jsx(e,{className:u("text-gray-900 dark:text-white",Gm(t),r),...o,children:n})}od.displayName="CardTitle";function Um(e){switch(e){case "sm":return "text-xs";case "lg":return "text-base";default:return "text-sm"}}function ad({size:e="md",className:t,children:r,...n}){return jsx("p",{className:u("text-gray-500 dark:text-gray-400",Um(e),t),...n,children:r})}ad.displayName="CardDescription";var sd=12,Js=false,jm={sm:"text-[11px]",md:"text-xs",lg:"text-sm"},qm={sm:"text-xs",md:"text-sm",lg:"text-base"};function Zm({data:e,by:t,values:r,domain:n,includeZero:o=false,ticks:a=5,order:s,sort:l="none",columns:i,minPanelWidth:d=220,formatLabel:c,showLabels:p=true,title:f,description:m,size:g="md",locale:x,emptyState:b,children:v,className:y,...M}){let w=c??(D=>bt(D,x)),P=new Map;e.forEach((D,k)=>{let I=Ut(D,t,k),W=dt(I),O=P.get(W);O?O.rows.push(D):P.set(W,{value:I,rows:[D]});});let h=[...P.entries()];if(s)h=s.map(dt).map(k=>h.find(([I])=>I===k)).filter(k=>k!==void 0);else if(l!=="none"){let D=k=>k.reduce((I,W)=>I+r.reduce((O,L)=>O+(et(W,L)??0),0),0);h=[...h].sort(([,k],[,I])=>l==="asc"?D(k.rows)-D(I.rows):D(I.rows)-D(k.rows));}let E=n??Qn(ir(e,r),{includeZero:o,ticks:a});return h.length>sd&&!Js&&(Js=true,console.warn(`[@synertech/ui] ChartFacets was given ${h.length} panels. Past ${sd} a facet grid stops being a comparison \u2014 filter the data down to the panels the reader is actually comparing.`)),h.length===0?jsx("div",{className:u("text-sm text-gray-500 dark:text-gray-400",y),...M,children:b}):jsxs("div",{className:u("flex w-full flex-col gap-3",y),...M,children:[f||m?jsxs("div",{className:"flex flex-col gap-0.5",children:[f?jsx("span",{className:u("font-semibold text-gray-900 dark:text-gray-100",qm[g]),children:f}):null,m?jsx("span",{className:"text-xs text-gray-500 dark:text-gray-400",children:m}):null]}):null,jsx("div",{className:"grid gap-x-4 gap-y-3",style:{gridTemplateColumns:i?`repeat(${i}, minmax(0, 1fr))`:`repeat(auto-fit, minmax(${d}px, 1fr))`},children:h.map(([D,k],I)=>{let W=w(k.value,I);return jsxs("div",{role:"group","aria-label":W,className:"flex min-w-0 flex-col gap-1",children:[p?jsx("span",{className:u("font-medium text-gray-700 dark:text-gray-200",jm[g]),children:W}):null,v({key:D,label:W,data:k.rows,domain:E,index:I,count:h.length})]},D)})})]})}function Qm(){Js=false;}var og=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"}}},ag=e=>{switch(e){case "circle":return "rounded-full";case "rounded":return "rounded-md";default:return "rounded"}},sg=({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"})}),ig=({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"})}),Xo=forwardRef(({checked:e,defaultChecked:t=false,onChange:r,disabled:n=false,readOnly:o=false,required:a=false,name:s,value:l,id:i,label:d,description:c,error:p=false,size:f="md",labelPosition:m="right",checkedColor:g="bg-blue-600",uncheckedColor:x="bg-white dark:bg-gray-800",borderColor:b="border-gray-300 dark:border-gray-600",labelColor:v,errorColor:y="text-red-500",checkmarkColor:M="text-white",hoverColor:w,focusRingColor:P="ring-blue-500",indeterminate:h=false,icon:E,variant:D="default",shape:k="square",animation:I=true,showFocusRing:W=true,className:O,containerClassName:L,style:T,tabIndex:S,...C},N)=>{let R=useId(),$=i||R,H=`${$}-error`,K=`${$}-description`,[_,F]=useState(t),A=e!==void 0,B=A?e:_,U=useRef(null);useEffect(()=>{U.current&&(U.current.indeterminate=h);},[h]);let Q=re=>{if(n||o)return;let q=re.target.checked;A||F(q),r?.(q,re);},J=og(f),Y=ag(k),z=()=>{let re=u("relative flex items-center justify-center border-2 transition-all",J.checkbox,Y,I&&"duration-200 ease-in-out");return n?u(re,"opacity-50 cursor-not-allowed",B||h?g:x,b):D==="filled"?u(re,B||h?g:"bg-gray-100 dark:bg-gray-700",B||h?"border-transparent":b,w&&!o&&`hover:${w}`,"cursor-pointer"):D==="outlined"?u(re,x,B||h?`border-current ${g.replace("bg-","text-")}`:b,"border-2",w&&!o&&`hover:${w}`,"cursor-pointer"):u(re,B||h?g:x,B||h?"border-transparent":b,w&&!o&&`hover:${w}`,"cursor-pointer")},X=p!==false,ne=typeof p=="string"?p:void 0;return jsxs("div",{className:u("inline-flex flex-col",L),children:[jsxs("label",{htmlFor:$,className:u("inline-flex items-start gap-2",n?"cursor-not-allowed":"cursor-pointer",m==="left"&&"flex-row-reverse justify-end"),children:[jsx("input",{ref:re=>{U&&(U.current=re),typeof N=="function"?N(re):N&&(N.current=re);},type:"checkbox",id:$,name:s,value:l,checked:B,onChange:Q,disabled:n,readOnly:o,required:a,tabIndex:o?-1:S,"aria-invalid":X,"aria-describedby":u(ne&&H,c&&K),className:"sr-only peer",style:T,...C}),jsx("span",{className:u(z(),W&&`peer-focus-visible:ring-2 peer-focus-visible:ring-offset-2 peer-focus-visible:${P}`,I&&B&&"scale-100",X&&"border-red-500"),"aria-hidden":"true",children:(B||h)&&jsx("span",{className:u(M,I&&"animate-in zoom-in-50 duration-200"),children:h?E||jsx(ig,{className:"w-full h-full"}):E||jsx(sg,{className:"w-full h-full"})})}),d&&jsxs("span",{className:"flex flex-col gap-1",children:[jsxs("span",{className:u(J.label,n&&"opacity-50",v,X&&y),children:[d,a&&jsx("span",{className:"text-red-500 ml-1",children:"*"})]}),c&&jsx("span",{id:K,className:u(J.description,"text-gray-500 dark:text-gray-400",n&&"opacity-50"),children:c})]})]}),ne&&jsx("p",{id:H,className:u("mt-1 text-xs",y),children:ne})]})});Xo.displayName="Checkbox";var id=createContext(null),ld=({label:e,description:t,value:r,defaultValue:n=[],onChange:o,orientation:a="vertical",spacing:s="md",disabled:l=false,size:i="md",error:d=false,required:c=false,children:p,className:f,labelClassName:m,...g})=>{let[x,b]=js.useState(n),v=r!==void 0,y=v?r:x,M=js.useCallback(D=>{let k=y.includes(D)?y.filter(I=>I!==D):[...y,D];v||b(k),o?.(k);},[y,v,o]),w=js.useMemo(()=>({value:y,onChange:M,disabled:l,size:i}),[y,M,l,i]),P={sm:a==="vertical"?"gap-2":"gap-3",md:a==="vertical"?"gap-3":"gap-4",lg:a==="vertical"?"gap-4":"gap-6"},h=d!==false,E=typeof d=="string"?d:void 0;return jsxs("div",{className:u("flex flex-col gap-2",f),...g,children:[(e||t)&&jsxs("div",{className:"flex flex-col gap-1",children:[e&&jsxs("label",{className:u("text-sm font-medium text-gray-900 dark:text-gray-100",l&&"opacity-50",h&&"text-red-500",m),children:[e,c&&jsx("span",{className:"text-red-500 ml-1",children:"*"})]}),t&&jsx("p",{className:u("text-xs text-gray-500 dark:text-gray-400",l&&"opacity-50"),children:t})]}),jsx(id.Provider,{value:w,children:jsx("div",{className:u("flex",a==="vertical"?"flex-col":"flex-row flex-wrap",P[s]),role:"group",children:p})}),E&&jsx("p",{className:"text-xs text-red-500",children:E})]})};ld.displayName="CheckboxGroup";var dd=({value:e,disabled:t,size:r,...n})=>{let o=useContext(id);if(!o)return console.warn("CheckboxGroupItem doit \xEAtre utilis\xE9 dans un CheckboxGroup"),jsx(Xo,{...n,disabled:t,size:r});let{value:a,onChange:s,disabled:l,size:i}=o,d=a.includes(e);return jsx(Xo,{...n,checked:d,onChange:()=>s(e),disabled:l||t,size:r||i})};dd.displayName="CheckboxGroupItem";var $t={compact:"px-3 py-1.5",default:"px-4 py-3",comfortable:"px-6 py-4"},Fa={compact:"text-xs",default:"text-sm",comfortable:"text-base"},mg=()=>jsx("svg",{className:"w-3.5 h-3.5",viewBox:"0 0 16 16",fill:"currentColor",children:jsx("path",{d:"M8 3l4 5H4l4-5z"})}),gg=()=>jsx("svg",{className:"w-3.5 h-3.5",viewBox:"0 0 16 16",fill:"currentColor",children:jsx("path",{d:"M8 13l4-5H4l4 5z"})}),fg=()=>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"})}),cd=({className:e})=>jsx("svg",{className:u("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"})}),bg=()=>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"})}),hg=()=>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"})}),yg=()=>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"})}),xg=()=>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"})]}),vg=()=>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 Ha(e,t,r){return typeof r=="function"?r(e,t):String(typeof r=="string"?e[r]:t)}function Hr(e,t){return e[t]}function kg(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 Cg(e,t){let r=String(e??"").toLowerCase(),n=t.value.toLowerCase();switch(t.operator){case "contains":return r.includes(n);case "equals":return r===n;case "startsWith":return r.startsWith(n);case "endsWith":return r.endsWith(n);case "gt":return Number(e)>Number(t.value);case "gte":return Number(e)>=Number(t.value);case "lt":return Number(e)<Number(t.value);case "lte":return Number(e)<=Number(t.value);case "isEmpty":return r==="";case "isNotEmpty":return r!=="";default:return true}}function ud(e,t,r){let n=[];for(let o of e){let a=Number(Hr(o,t));isNaN(a)||n.push(a);}if(n.length===0)return 0;switch(r){case "sum":return n.reduce((o,a)=>o+a,0);case "avg":return n.reduce((o,a)=>o+a,0)/n.length;case "count":return n.length;case "min":return Math.min(...n);case "max":return Math.max(...n)}}function wg({cols:e,density:t}){return jsx("tr",{className:"border-b border-gray-200 dark:border-gray-700",children:Array.from({length:e}).map((r,n)=>jsx("td",{className:$t[t],children:jsx("div",{className:"h-4 bg-gray-200 dark:bg-gray-700 rounded animate-pulse"})},n))})}function Ng({column:e,value:t,onApply:r,onClear:n}){let[o,a]=useState(false),[s,l]=useState(t?.operator??"contains"),[i,d]=useState(t?.value??""),c=useRef(null),p=e.filterType??"text",f=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=g=>{c.current&&!c.current.contains(g.target)&&a(false);};return o&&document.addEventListener("mousedown",m),()=>document.removeEventListener("mousedown",m)},[o]),jsxs("div",{className:"relative inline-block",ref:c,children:[jsx("button",{type:"button",onClick:m=>{m.stopPropagation(),a(!o);},className:u("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(yg,{})}),o&&jsx("div",{className:"absolute z-50 top-full left-0 mt-1 bg-white dark:bg-gray-800 border border-gray-200 dark:border-gray-700 rounded-lg shadow-lg p-3 min-w-[220px]",children: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(""),n(),a(false);},className:"px-2 py-1 text-xs text-gray-600 dark:text-gray-400 hover:text-gray-800 dark:hover:text-gray-200 cursor-pointer",children:"Clear"})]})]}):jsxs("div",{className:"flex flex-col gap-2",children:[jsx("select",{value:s,onChange:m=>l(m.target.value),className:"text-xs border border-gray-300 dark:border-gray-600 rounded px-2 py-1 bg-white dark:bg-gray-700 text-gray-700 dark:text-gray-200",children:f.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(""),n(),a(false);},className:"px-2 py-1 text-xs text-gray-600 dark:text-gray-400 hover:text-gray-800 dark:hover:text-gray-200 cursor-pointer",children:"Clear"})]})]})})]})}function Sg({value:e,onSave:t,density:r}){let[n,o]=useState(false),[a,s]=useState(String(e??"")),l=useRef(null);if(useEffect(()=>{n&&l.current&&(l.current.focus(),l.current.select());},[n]),!n)return jsx("div",{onDoubleClick:()=>{s(String(e??"")),o(true);},className:"cursor-text min-h-[1.5em]",title:"Double-click to edit",children:String(e??"")});let i=()=>{o(false),a!==String(e??"")&&t(a);};return jsx("input",{ref:l,type:"text",value:a,onChange:d=>s(d.target.value),onBlur:i,"aria-label":"Edit cell value",onKeyDown:d=>{d.key==="Enter"&&i(),d.key==="Escape"&&o(false);},className:u("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",Fa[r])})}function Rg(e,t){let{columns:r,data:n,rowKey:o,mode:a="client",sortable:s=false,multiSort:l=false,sort:i,defaultSort:d,onSort:c,pagination:p=false,page:f,onPageChange:m,onPageSizeChange:g,totalItems:x,selectable:b=false,selectionMode:v="multiple",selectedRows:y,onSelectionChange:M,searchable:w=false,searchPlaceholder:P="Search...",searchValue:h,onSearch:E,filters:D,onFilterChange:k,expandable:I=false,expandedContent:W,expandedRows:O,onExpandChange:L,editable:T=false,onCellEdit:S,reorderable:C=false,onReorder:N,columnReorderable:R=false,onColumnReorder:$,columnToggle:H=false,hiddenColumns:K,onColumnVisibilityChange:_,groupBy:F,renderGroupHeader:A,exportable:B=false,exportFormats:U=["csv","json"],exportFilename:Q="export",virtualized:J=false,rowHeight:Y=40,virtualHeight:z=400,density:X="default",striped:ne=false,bordered:re=false,borderless:q=false,stickyHeader:de=false,maxHeight:xe,loading:ke=false,loadingRows:le=5,emptyState:Se,showFooter:Me=false,onRowClick:je,onRowDoubleClick:at,onRowContextMenu:$e,className:ie,rowClassName:he,cellClassName:Ie,headerClassName:xt}=e,[Te,Ee]=useState(d??[]),[nt,pr]=useState(1),[pt,Ht]=useState(typeof p=="object"?p.pageSize??10:10),[Ft,sr]=useState([]),[Nr,Gt]=useState(""),[er,tr]=useState([]),[ue,me]=useState([]),[Z,ee]=useState(()=>r.flatMap(V=>V.hidden?[V.key]:[])),[fe,ge]=useState({}),[Re,ve]=useState(()=>r.map(V=>V.key)),[we,Fe]=useState(null),[Ae,ot]=useState(null),[qe,_e]=useState(false),[Mt,st]=useState(new Set),mr=useRef(null),[Gr,wn]=useState(0),Xn=useRef(null),Sr=i??Te,gr=f??nt,G=y??Ft,te=h??Nr,oe=D??er,ae=O??ue,pe=K??Z,Ve=p?typeof p=="object"?p:{pageSize:10,pageSizeOptions:[10,25,50,100]}:null,Ye=Ve?.pageSize??pt,Xe=useMemo(()=>{let V=new Map(r.map(Ne=>[Ne.key,Ne])),j=Re.flatMap(Ne=>{let ze=V.get(Ne);return ze?[ze]:[]}),ce=new Set(j.map(Ne=>Ne.key));for(let Ne of r)ce.has(Ne.key)||(j.push(Ne),ce.add(Ne.key));return j.filter(Ne=>!pe.includes(Ne.key))},[r,Re,pe]),Le=useMemo(()=>{if(a==="server")return n;let V=[...n];if(te){let j=te.toLowerCase();V=V.filter(ce=>Xe.some(Ne=>{let ze=Hr(ce,Ne.key);return String(ze??"").toLowerCase().includes(j)}));}if(oe.length>0&&(V=V.filter(j=>oe.every(ce=>Cg(Hr(j,ce.column),ce)))),Sr.length>0){let j=new Map(r.map(ce=>[ce.key,ce]));V.sort((ce,Ne)=>{for(let ze of Sr){if(!ze.direction)continue;let ft=j.get(ze.key),Qt=ft?.sortComparator?ft.sortComparator(ce,Ne):kg(Hr(ce,ze.key),Hr(Ne,ze.key));if(Qt!==0)return ze.direction==="asc"?Qt:-Qt}return 0});}return V},[n,a,te,oe,Sr,Xe,r]),It=useMemo(()=>{if(!F)return null;let V=Array.isArray(F)?F:[F],j=new Map;for(let ce of Le){let Ne=V.map(ft=>String(Hr(ce,ft)??"")).join(" / "),ze=j.get(Ne)??[];ze.push(ce),j.set(Ne,ze);}return j},[Le,F]),Ge=x??Le.length,gt=Math.max(1,Math.ceil(Ge/Ye)),Nt=useMemo(()=>{if(!Ve||a==="server")return Le;let V=(gr-1)*Ye;return Le.slice(V,V+Ye)},[Le,Ve,gr,Ye,a]),it=Ve?Nt:Le,Vt=useMemo(()=>{if(!J)return {start:0,end:it.length};let V=Math.floor(Gr/Y),j=Math.ceil(z/Y),ce=5;return {start:Math.max(0,V-ce),end:Math.min(it.length,V+j+ce)}},[J,Gr,Y,z,it.length]),Rr=useCallback(V=>{i||Ee(V),c?.(V);},[i,c]),Tr=useCallback(V=>{let j=Sr.find(Ne=>Ne.key===V),ce;if(!j||!j.direction?ce="asc":j.direction==="asc"?ce="desc":ce=null,l){let Ne=Sr.filter(ze=>ze.key!==V);ce&&Ne.push({key:V,direction:ce}),Rr(Ne);}else Rr(ce?[{key:V,direction:ce}]:[]);},[Sr,l,Rr]),rr=useCallback(V=>{let j=Math.max(1,Math.min(V,gt));f||pr(j),m?.(j);},[f,m,gt]),Cs=useCallback(V=>{Ht(V),rr(1),g?.(V);},[rr,g]),ha=useCallback(V=>{let j;v==="single"?j=G.includes(V)?[]:[V]:j=G.includes(V)?G.filter(ce=>ce!==V):[...G,V],y||sr(j),M?.(j);},[v,G,y,M]),ws=useCallback(()=>{let V=it.map((j,ce)=>Ha(j,ce,o));y||sr(V),M?.(V);},[it,o,y,M]),Ns=useCallback(()=>{y||sr([]),M?.([]);},[y,M]),Ss=it.length>0&&it.every((V,j)=>G.includes(Ha(V,j,o))),Yu=!Ss&&it.some((V,j)=>G.includes(Ha(V,j,o))),ju=useCallback(V=>{let j=ae.includes(V)?ae.filter(ce=>ce!==V):[...ae,V];O||me(j),L?.(j);},[ae,O,L]),qu=useCallback(V=>{let j=V.target.value;h||Gt(j),E?.(j),rr(1);},[h,E,rr]),Zu=useCallback(V=>{let j=[...oe.filter(ce=>ce.column!==V.column),V];D||tr(j),k?.(j);},[oe,D,k]),Qu=useCallback(V=>{let j=oe.filter(ce=>ce.column!==V);D||tr(j),k?.(j);},[oe,D,k]),Ju=useCallback(V=>{let j=pe.includes(V)?pe.filter(ce=>ce!==V):[...pe,V];K||ee(j),_?.(j);},[pe,K,_]),e0=useCallback((V,j)=>{V.preventDefault(),V.stopPropagation();let ce=V.clientX,Ne=fe[j]??V.currentTarget.parentElement?.getBoundingClientRect().width??100,ze=r.find(Jt=>Jt.key===j),ft=ze?.minWidth??50,Qt=ze?.maxWidth??1/0,Ze=Jt=>{let Nn=Jt.clientX-ce,Er=Math.min(Qt,Math.max(ft,Ne+Nn));ge(Kn=>({...Kn,[j]:Er}));},Pr=()=>{document.removeEventListener("mousemove",Ze),document.removeEventListener("mouseup",Pr);};document.addEventListener("mousemove",Ze),document.addEventListener("mouseup",Pr);},[fe,r]),t0=useCallback(V=>{C&&Fe(V);},[C]),r0=useCallback((V,j)=>{!C||we===null||V.preventDefault();},[C,we]),n0=useCallback(V=>{!C||we===null||we===V||(N?.(we,V),Fe(null));},[C,we,N]),o0=useCallback(V=>{R&&ot(V);},[R]),a0=useCallback(V=>{if(!R||!Ae||Ae===V)return;let j=[...Re],ce=j.indexOf(Ae),Ne=j.indexOf(V);ce===-1||Ne===-1||(j.splice(ce,1),j.splice(Ne,0,Ae),ve(j),$?.(Ae,V),ot(null));},[R,Ae,Re,$]),Rs=useCallback(V=>{let j=Xe.filter(Jt=>Jt.type!=="actions"&&Jt.type!=="selection"&&Jt.type!=="expand"),ce=Le,Ne,ze,ft;if(V==="csv"){let Jt=j.map(Er=>String(Er.header)).join(","),Nn=ce.map(Er=>j.map(Kn=>{let Es=String(Hr(Er,Kn.key)??"");return Es.includes(",")?`"${Es}"`:Es}).join(","));Ne=[Jt,...Nn].join(`
|
|
2
|
+
`),ze="text/csv",ft="csv";}else {let Jt=ce.map(Nn=>{let Er={};for(let Kn of j)Er[Kn.key]=Hr(Nn,Kn.key);return Er});Ne=JSON.stringify(Jt,null,2),ze="application/json",ft="json";}let Qt=new Blob([Ne],{type:ze}),Ze=URL.createObjectURL(Qt),Pr=document.createElement("a");Pr.href=Ze,Pr.download=`${Q}.${ft}`,Pr.click(),URL.revokeObjectURL(Ze);},[Xe,Le,Q]);useEffect(()=>{if(!qe)return;let V=j=>{Xn.current&&!Xn.current.contains(j.target)&&_e(false);};return document.addEventListener("mousedown",V),()=>document.removeEventListener("mousedown",V)},[qe]),useImperativeHandle(t,()=>({getVisibleData:()=>it,resetFilters:()=>{D||tr([]),h||Gt(""),k?.([]),E?.("");},resetSort:()=>{i||Ee([]),c?.([]);},selectAll:ws,deselectAll:Ns,exportData:Rs,scrollToRow:V=>{mr.current&&J&&(mr.current.scrollTop=V*Y);}}),[it,D,h,i,k,E,c,ws,Ns,Rs,J,Y]);let Ts=V=>{let j={},ce=fe[V.key]??V.width;return ce&&(j.width=typeof ce=="number"?`${ce}px`:ce,j.minWidth=typeof ce=="number"?`${ce}px`:ce),V.sticky&&(j.position="sticky",j[V.sticky]=0,j.zIndex=10),j},Gn=Xe.length+(b?1:0)+(I?1:0)+(C?1:0),s0=V=>{let j=s&&V.sortable!==false&&V.type!=="actions",ce=Sr.find(ze=>ze.key===V.key),Ne=V.filterable&&(V.filterType||V.filterOptions);return jsxs("th",{className:u($t[X],Fa[X],"font-semibold text-gray-700 dark:text-gray-300 whitespace-nowrap",V.align==="center"&&"text-center",V.align==="right"&&"text-right",j&&"cursor-pointer select-none hover:bg-gray-100 dark:hover:bg-gray-700",re&&"border border-gray-200 dark:border-gray-700",V.sticky&&"bg-gray-50 dark:bg-gray-800",V.headerClassName,xt),style:Ts(V),onClick:j?()=>Tr(V.key):void 0,draggable:R,onDragStart:R?()=>o0(V.key):void 0,onDragOver:R?ze=>ze.preventDefault():void 0,onDrop:R?()=>a0(V.key):void 0,"aria-sort":ce?.direction==="asc"?"ascending":ce?.direction==="desc"?"descending":void 0,children:[jsxs("div",{className:"flex items-center gap-1",children:[V.renderHeader?V.renderHeader(V):V.header,j&&jsx("span",{className:"inline-flex ml-1",children:ce?.direction==="asc"?jsx(mg,{}):ce?.direction==="desc"?jsx(gg,{}):jsx(fg,{})}),Ne&&jsx(Ng,{column:V,value:oe.find(ze=>ze.column===V.key),onApply:Zu,onClear:()=>Qu(V.key)})]}),V.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:ze=>e0(ze,V.key)})]},V.key)},Ps=(V,j,ce)=>{let Ne=Ha(V,ce,o),ze=G.includes(Ne),ft=ae.includes(Ne),Qt=typeof he=="function"?he(V,ce):he;return jsxs(js__default.Fragment,{children:[jsxs("tr",{className:u("border-b border-gray-200 dark:border-gray-700 transition-colors",ne&&ce%2===1&&"bg-gray-50/50 dark:bg-gray-800/50",ze&&"bg-blue-50 dark:bg-blue-900/20",je&&"cursor-pointer hover:bg-gray-50 dark:hover:bg-gray-700/50",we===j&&"opacity-50",Qt),onClick:je?()=>je(V,ce):void 0,onDoubleClick:at?()=>at(V,ce):void 0,onContextMenu:$e?Ze=>$e(V,ce,Ze):void 0,draggable:C,onDragStart:C?()=>t0(j):void 0,onDragOver:C?Ze=>r0(Ze,j):void 0,onDrop:C?()=>n0(j):void 0,"data-row-key":Ne,"aria-selected":b?ze:void 0,children:[C&&jsx("td",{className:u($t[X],"cursor-grab active:cursor-grabbing"),children:jsx(hg,{})}),b&&jsx("td",{className:u($t[X],"w-10"),children:jsx("input",{type:"checkbox",checked:ze,onChange:()=>ha(Ne),onClick:Ze=>Ze.stopPropagation(),className:"rounded border-gray-300 dark:border-gray-600 cursor-pointer","aria-label":`Select row ${Ne}`})}),I&&jsx("td",{className:u($t[X],"w-10"),children:jsx("button",{type:"button",onClick:Ze=>{Ze.stopPropagation(),ju(Ne);},className:"p-0.5 rounded hover:bg-gray-200 dark:hover:bg-gray-600 cursor-pointer","aria-label":ft?"Collapse row":"Expand row","aria-expanded":ft,children:jsx(cd,{className:u("transition-transform",ft&&"rotate-180")})})}),Xe.map(Ze=>{let Pr=Hr(V,Ze.key),Jt=Ze.colSpan?.(V,ce);if(Jt===0)return null;let Nn=T&&Ze.editable!==false&&Ze.type!=="actions";return jsx("td",{className:u($t[X],Fa[X],"text-gray-700 dark:text-gray-300",Ze.align==="center"&&"text-center",Ze.align==="right"&&"text-right",re&&"border border-gray-200 dark:border-gray-700",Ze.sticky&&(ze?"bg-blue-50 dark:bg-blue-900/20":ne&&ce%2===1?"bg-gray-50/50 dark:bg-gray-800/50":"bg-white dark:bg-gray-900"),Ze.cellClassName,Ie),style:Ts(Ze),colSpan:Jt,children:Nn?jsx(Sg,{value:Pr,onSave:Er=>S?.(Ne,Ze.key,Er),density:X}):Ze.render?Ze.render(Pr,V,ce):String(Pr??"")},Ze.key)})]}),I&&ft&&W&&jsx("tr",{className:"bg-gray-50 dark:bg-gray-800/70",children:jsx("td",{colSpan:Gn,className:u($t[X]),children:W(V,ce)})})]},Ne)},i0=()=>{if(ke)return Array.from({length:le}).map((V,j)=>jsx(wg,{cols:Gn,density:X},j));if(it.length===0)return jsx("tr",{children:jsx("td",{colSpan:Gn,className:u("text-center text-gray-400 dark:text-gray-500",$t[X]),children:Se??"No data available"})});if(It){let V=[],j=0;for(let[ce,Ne]of It){let ze=Mt.has(ce);if(V.push(jsx("tr",{className:"bg-gray-100 dark:bg-gray-800 font-medium",children:jsx("td",{colSpan:Gn,className:u($t[X],"cursor-pointer"),onClick:()=>{st(ft=>{let Qt=new Set(ft);return Qt.has(ce)?Qt.delete(ce):Qt.add(ce),Qt});},children:jsxs("div",{className:"flex items-center gap-2",children:[jsx(cd,{className:u("transition-transform",ze&&"-rotate-90")}),A?A(ce,Hr(Ne[0],Array.isArray(F)?F[0]:F),Ne):`${ce} (${Ne.length})`]})})},`group-${ce}`)),ze)j+=Ne.length;else for(let ft=0;ft<Ne.length;ft++)V.push(Ps(Ne[ft],j,j)),j++;}return V}if(J){let V=[];for(let j=Vt.start;j<Vt.end;j++)V.push(Ps(it[j],j,j));return jsxs(Fragment,{children:[Vt.start>0&&jsx("tr",{children:jsx("td",{colSpan:Gn,style:{height:Vt.start*Y,padding:0}})}),V,Vt.end<it.length&&jsx("tr",{children:jsx("td",{colSpan:Gn,style:{height:(it.length-Vt.end)*Y,padding:0}})})]})}return it.map((V,j)=>Ps(V,j,j))},l0=()=>!Me||!Xe.some(j=>j.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:[C&&jsx("td",{className:$t[X]}),b&&jsx("td",{className:$t[X]}),I&&jsx("td",{className:$t[X]}),Xe.map(j=>jsx("td",{className:u($t[X],Fa[X],"text-gray-700 dark:text-gray-300",j.align==="center"&&"text-center",j.align==="right"&&"text-right",re&&"border border-gray-200 dark:border-gray-700"),style:Ts(j),children:j.aggregate?j.renderAggregate?j.renderAggregate(ud(Le,j.key,j.aggregate),Le):`${j.aggregate==="count"?"":j.aggregate==="avg"?"Avg: ":j.aggregate==="sum"?"Total: ":j.aggregate==="min"?"Min: ":"Max: "}${ud(Le,j.key,j.aggregate).toLocaleString()}`:""},j.key))]})});return jsxs("div",{className:u("flex flex-col gap-3",ie),children:[(w||B||H)&&jsxs("div",{className:"flex items-center justify-between gap-3 flex-wrap",children:[jsxs("div",{className:"flex items-center gap-3 flex-1",children:[w&&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(bg,{})}),jsx("input",{type:"text",value:te,onChange:qu,placeholder:P,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"})]}),G.length>0&&jsxs("span",{className:"text-sm text-gray-500 dark:text-gray-400",children:[G.length," selected"]})]}),jsxs("div",{className:"flex items-center gap-2",children:[H&&jsxs("div",{className:"relative",ref:Xn,children:[jsx("button",{type:"button",onClick:()=>_e(!qe),className:"p-1.5 rounded-md border border-gray-300 dark:border-gray-600 text-gray-600 dark:text-gray-400 hover:bg-gray-100 dark:hover:bg-gray-700 cursor-pointer","aria-label":"Toggle columns",title:"Toggle columns",children:jsx(vg,{})}),qe&&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(V=>V.type!=="selection"&&V.type!=="expand").map(V=>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:!pe.includes(V.key),onChange:()=>Ju(V.key),className:"rounded border-gray-300 dark:border-gray-600 cursor-pointer"}),jsx("span",{className:"text-gray-700 dark:text-gray-300",children:String(V.header)})]},V.key))})]}),B&&U.map(V=>jsxs("button",{type:"button",onClick:()=>Rs(V),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 ${V.toUpperCase()}`,children:[jsx(xg,{}),V.toUpperCase()]},V))]})]}),jsx("div",{ref:mr,className:u("overflow-auto rounded-lg",!q&&"border border-gray-200 dark:border-gray-700",de&&"relative"),style:xe?{maxHeight:typeof xe=="number"?`${xe}px`:xe}:J?{maxHeight:z,overflow:"auto"}:void 0,onScroll:J?V=>wn(V.target.scrollTop):void 0,children:jsxs("table",{className:"w-full text-left",children:[jsx("thead",{className:u("bg-gray-50 dark:bg-gray-800 text-xs uppercase",de&&"sticky top-0 z-20"),children:jsxs("tr",{children:[C&&jsx("th",{className:u($t[X],"w-10 font-semibold text-gray-700 dark:text-gray-300")}),b&&jsx("th",{className:u($t[X],"w-10"),children:v==="multiple"&&jsx("input",{type:"checkbox",checked:Ss,ref:V=>{V&&(V.indeterminate=Yu);},onChange:Ss?Ns:ws,className:"rounded border-gray-300 dark:border-gray-600 cursor-pointer","aria-label":"Select all rows"})}),I&&jsx("th",{className:u($t[X],"w-10 font-semibold text-gray-700 dark:text-gray-300")}),Xe.map(s0)]})}),jsx("tbody",{children:i0()}),l0()]})}),Ve&&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:[Ve.showTotalItems!==false&&jsxs("span",{children:[Ge," item",Ge!==1?"s":""]}),Ve.showPageSizeSelector!==false&&Ve.pageSizeOptions&&jsxs("div",{className:"flex items-center gap-1.5",children:[jsx("span",{children:"Rows per page:"}),jsx("select",{value:Ye,onChange:V=>Cs(Number(V.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:Ve.pageSizeOptions.map(V=>jsx("option",{value:V,children:V},V))})]})]}),jsxs("div",{className:"flex items-center gap-1",children:[jsxs("span",{className:"mr-2",children:["Page ",gr," of ",gt]}),jsx("button",{type:"button",onClick:()=>rr(1),disabled:gr<=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:()=>rr(gr-1),disabled:gr<=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:()=>rr(gr+1),disabled:gr>=gt,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:()=>rr(gt),disabled:gr>=gt,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 Tg=forwardRef(Rg);function Eg({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 Dg={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"}},Mg={default:"bg-gray-500",primary:"bg-blue-600",success:"bg-green-600",warning:"bg-yellow-500",error:"bg-red-600",info:"bg-cyan-600"},Ig={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"},ri={sm:"w-3 h-3",md:"w-3.5 h-3.5",lg:"w-4 h-4"},Lg={sm:"w-4 h-4 -ml-1",md:"w-5 h-5 -ml-1.5",lg:"w-6 h-6 -ml-1.5"},Ag={sm:"w-1.5 h-1.5",md:"w-2 h-2",lg:"w-2.5 h-2.5"},zg={none:"rounded-none",sm:"rounded-sm",md:"rounded-md",lg:"rounded-lg",full:"rounded-full"};function Ba({label:e,children:t,variant:r="solid",size:n="md",color:o="default",bgColor:a,textColor:s,borderColor:l,rounded:i="full",icon:d,endIcon:c,avatar:p,onClose:f,closable:m=false,clickable:g=false,selected:x=false,disabled:b=false,as:v="span",className:y,onClick:M,...w}){let P=v,h=u("inline-flex items-center justify-center font-medium transition-all",Ig[n],zg[i],r==="outlined"&&"border"),E=u(a||s||l?u(a,s,l):Dg[o][r]),D=x?"ring-2 ring-offset-1 ring-blue-500":"",k=g&&!b?"cursor-pointer hover:opacity-80 active:scale-95":"",I=b?"opacity-50 cursor-not-allowed":"",W=T=>{T.stopPropagation(),f?.();},O=T=>{b||M?.(T);},L=t??e;return jsxs(P,{className:u(h,E,D,k,I,y),onClick:O,"aria-disabled":b,...w,children:[r==="dot"&&jsx("span",{className:u("rounded-full shrink-0",Ag[n],Mg[o]),"aria-hidden":"true"}),p&&jsx("span",{className:u("rounded-full overflow-hidden shrink-0",Lg[n]),children:p}),d&&!p&&jsx("span",{className:u("shrink-0",ri[n]),children:d}),L&&jsx("span",{className:"truncate",children:L}),c&&!m&&jsx("span",{className:u("shrink-0",ri[n]),children:c}),m&&jsx("button",{type:"button",onClick:W,disabled:b,className:u("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(Eg,{className:ri[n]})})]})}Ba.displayName="Chip";var Bg=500,Og=800,$g=600;function _g(e,t,r){let n=[`width=${e}`,`height=${t}`,"menubar=no","toolbar=no","location=no","status=no","scrollbars=yes","resizable=yes"];if(r.left!==void 0)n.push(`left=${r.left}`);else if(r.center!==false&&typeof window<"u"){let o=window.screenLeft??window.screenX,a=window.screenTop??window.screenY,s=window.outerWidth??screen.availWidth,l=window.outerHeight??screen.availHeight;n.push(`left=${o+(s-e)/2}`),n.push(`top=${a+(l-t)/2}`);}if(r.top!==void 0){let o=n.filter(a=>!a.startsWith("top="));return o.push(`top=${r.top}`),o.join(",")}return n.join(",")}function Xg(e,t){e.querySelectorAll("style").forEach(s=>{let l=t.createElement("style");l.textContent=s.textContent,t.head.appendChild(l);}),e.querySelectorAll('link[rel="stylesheet"]').forEach(s=>{let l=t.createElement("link");l.rel="stylesheet",l.href=s.href,s.crossOrigin&&(l.crossOrigin=s.crossOrigin),t.head.appendChild(l);});let o=e.documentElement.className;o&&(t.documentElement.className=o);let a=e.body.className;a&&(t.body.className=a);}function Gg(e,t){let r=new MutationObserver(n=>{for(let o of n)for(let a of Array.from(o.addedNodes))if(a instanceof HTMLStyleElement){let s=t.createElement("style");s.textContent=a.textContent,t.head.appendChild(s);}else if(a instanceof HTMLLinkElement&&a.rel==="stylesheet"){let s=t.createElement("link");s.rel="stylesheet",s.href=a.href,t.head.appendChild(s);}});return r.observe(e.head,{childList:true}),r}var md=forwardRef(function({children:t,detached:r,defaultDetached:n=false,onClose:o,onDetach:a,title:s="",width:l=Og,height:i=$g,left:d,top:c,center:p=true,copyStyles:f=true,closeOnParentUnmount:m=true,className:g,windowClassName:x,onPopupBlocked:b},v){let y=r!==void 0,[M,w]=useState(n),P=y?r:M,[h,E]=useState(null),D=useRef(null),k=useRef(null),I=useRef(null),W=useRef(false),O=useRef({width:l,height:i,left:d,top:c,center:p,shouldCopyStyles:f,title:s,windowClassName:x,closeOnParentUnmount:m});O.current={width:l,height:i,left:d,top:c,center:p,shouldCopyStyles:f,title:s,windowClassName:x,closeOnParentUnmount:m};let L=useCallback(()=>{k.current&&(clearInterval(k.current),k.current=null),I.current&&(I.current.disconnect(),I.current=null),E(null);},[]),T=useCallback(()=>{D.current&&!D.current.closed&&D.current.close(),D.current=null,L();},[L]),S=useCallback(()=>{if(typeof window>"u"||W.current||D.current&&!D.current.closed)return;W.current=true;let C=O.current,N=_g(C.width,C.height,{center:C.center,left:C.left,top:C.top}),R=window.open("","",N);if(!R){W.current=false,b?.();return}D.current=R,R.document.title=C.title||document.title;let $=R.document.createElement("div");C.windowClassName&&($.className=C.windowClassName),R.document.body.appendChild($),E($),C.shouldCopyStyles&&(Xg(document,R.document),I.current=Gg(document,R.document)),k.current=setInterval(()=>{R.closed&&(L(),D.current=null,y||w(false),o?.());},Bg),W.current=false,a?.();},[y,o,a,b,L]);return useEffect(()=>{P?S():T();},[P,S,T]),useEffect(()=>{D.current&&!D.current.closed&&s&&(D.current.document.title=s);},[s]),useEffect(()=>()=>{O.current.closeOnParentUnmount&&D.current&&!D.current.closed&&D.current.close(),L(),D.current=null;},[L]),useImperativeHandle(v,()=>({detach:()=>{y||w(true);},attach:()=>{y||w(false);},get isDetached(){return y?!!r:M},get window(){return D.current}}),[y,r,M]),P&&h?createPortal(t,h):P?null:jsx("div",{className:u(g),children:t})});md.displayName="Detachable";var Yg={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:u("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:u("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"})]}),Zg=({className:e})=>jsxs("svg",{className:u("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 Uo({time:e="9:41",theme:t,device:r}){let n=r==="watch",o=t==="dark"?"text-white":"text-gray-900";return n?jsx("div",{className:u("flex items-center justify-center py-0.5",o),style:{fontSize:"8px"},children:jsx("span",{className:"font-medium",children:e})}):jsxs("div",{className:u("flex items-center justify-between px-4 py-1",t==="dark"?"bg-black/20":"bg-white/20",o),style:{fontSize:"10px"},"data-testid":"status-bar",children:[jsx("span",{className:"font-semibold",children:e}),jsxs("div",{className:"flex items-center gap-1",children:[jsx(jg,{className:o}),jsx(qg,{className:o}),jsx(Zg,{className:o})]})]})}function Qg({theme:e}){let t=e==="dark";return jsxs("div",{className:u("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:u("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 Jg({children:e,theme:t,screenW:r,screenH:n,showStatusBar:o,statusBarTime:a,frameColor:s,landscape:l=false}){let i=t==="dark",d=s??(i?"#1a1a1a":"#e5e7eb");if(l){let p=Math.round(n*.35);return jsxs("div",{className:"relative inline-flex flex-row items-center rounded-[2.5rem] shadow-xl",style:{backgroundColor:d,padding:"8px 12px",height:n+16},"data-testid":"device-frame","data-device":"phone",children:[jsx("div",{className:u("rounded-full mr-2",i?"bg-gray-600":"bg-gray-400"),style:{width:4,height:Math.round(n*.35)},"data-testid":"home-indicator"}),jsxs("div",{className:"rounded-[2rem] overflow-hidden bg-black relative",style:{width:r,height:n},children:[o&&jsx(Uo,{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 c=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:c,height:20,left:"50%",transform:"translateX(-50%)"},"data-testid":"phone-notch"}),jsxs("div",{className:"rounded-[2rem] overflow-hidden bg-black relative",style:{width:r,height:n},children:[o&&jsx(Uo,{time:a,theme:t,device:"phone"}),e]}),jsx("div",{className:u("rounded-full mt-2",i?"bg-gray-600":"bg-gray-400"),style:{width:Math.round(r*.35),height:4},"data-testid":"home-indicator"})]})}function ef({children:e,theme:t,screenW:r,screenH:n,showStatusBar:o,statusBarTime:a,frameColor:s}){return jsxs("div",{className:"relative inline-flex flex-col items-center rounded-[2rem] shadow-xl",style:{backgroundColor:s??(t==="dark"?"#1a1a1a":"#e5e7eb"),padding:"10px 6px",width:r+12},"data-testid":"device-frame","data-device":"android",children:[jsx("div",{className:"absolute top-[6px] rounded-full bg-gray-800 z-10 border border-gray-700",style:{width:8,height:8,left:"50%",transform:"translateX(-50%)"},"data-testid":"camera-dot"}),jsxs("div",{className:"rounded-[1.5rem] overflow-hidden bg-black relative",style:{width:r,height:n},children:[o&&jsx(Uo,{time:a,theme:t,device:"android"}),e]})]})}function tf({children:e,theme:t,screenW:r,screenH:n,showStatusBar:o,statusBarTime:a,frameColor:s}){return jsxs("div",{className:"relative inline-flex flex-col items-center rounded-[1.5rem] shadow-xl",style:{backgroundColor:s??(t==="dark"?"#1a1a1a":"#e5e7eb"),padding:"16px 12px",width:r+24},"data-testid":"device-frame","data-device":"tablet",children:[jsx("div",{className:"absolute top-[8px] rounded-full bg-gray-700 z-10",style:{width:6,height:6,left:"50%",transform:"translateX(-50%)"}}),jsxs("div",{className:"rounded-lg overflow-hidden bg-black relative",style:{width:r,height:n},children:[o&&jsx(Uo,{time:a,theme:t,device:"tablet"}),e]})]})}function rf({children:e,theme:t,screenW:r,screenH:n,frameColor:o}){let a=t==="dark",s=o??(a?"#1a1a1a":"#d1d5db"),l=r+60;return jsxs("div",{className:"inline-flex flex-col items-center","data-testid":"device-frame","data-device":"laptop",children:[jsxs("div",{className:"rounded-t-xl shadow-xl relative",style:{backgroundColor:s,padding:"8px 8px 0",width:r+16},children:[jsx("div",{className:"absolute top-[3px] rounded-full bg-gray-700 z-10",style:{width:4,height:4,left:"50%",transform:"translateX(-50%)"}}),jsx("div",{className:"rounded-t-sm overflow-hidden bg-black",style:{width:r,height:n},children:e})]}),jsx("div",{className:u(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 nf({children:e,theme:t,screenW:r,screenH:n,frameColor:o}){let a=t==="dark";return jsxs("div",{className:"inline-flex flex-col items-center","data-testid":"device-frame","data-device":"desktop",children:[jsx("div",{className:"rounded-lg shadow-xl",style:{backgroundColor:o??(a?"#1a1a1a":"#d1d5db"),padding:"8px 8px 20px",width:r+16},children:jsx("div",{className:"rounded-sm overflow-hidden bg-black",style:{width:r,height:n},children:e})}),jsx("div",{className:u(a?"bg-gray-800":"bg-gray-400"),style:{width:40,height:24},"data-testid":"monitor-stand"}),jsx("div",{className:u("rounded-t-sm",a?"bg-gray-800":"bg-gray-400"),style:{width:Math.round(r*.4),height:6,borderRadius:"2px 2px 4px 4px"}})]})}function of({children:e,theme:t,screenW:r,screenH:n,showStatusBar:o,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:u("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:u("absolute rounded-sm",l?"bg-gray-600":"bg-gray-400"),style:{width:4,height:16,right:-4,top:"30%"},"data-testid":"watch-crown"}),jsxs("div",{className:"rounded-xl overflow-hidden bg-black",style:{width:r,height:n},children:[o&&jsx(Uo,{time:a,theme:t,device:"watch"}),e]})]}),jsx("div",{className:u("rounded-b-lg",l?"bg-gray-800":"bg-gray-400"),style:{width:d,height:30}})]})}function af({children:e,theme:t,screenW:r,screenH:n,frameColor:o}){return jsxs("div",{className:"inline-flex flex-col rounded-lg shadow-xl overflow-hidden",style:{backgroundColor:o??(t==="dark"?"#1f2937":"#f3f4f6"),width:r},"data-testid":"device-frame","data-device":"browser",children:[jsx(Qg,{theme:t}),jsx("div",{className:"overflow-hidden bg-white",style:{width:r,height:n},children:e})]})}function sf({device:e="phone",src:t,alt:r="Device screen content",children:n,orientation:o="portrait",theme:a="dark",size:s="md",showStatusBar:l=false,statusBarTime:i,animated:d=false,scrollSpeed:c=30,frameColor:p,className:f,contentClassName:m}){let g=useRef(null),x=useRef(null),b=Yg[e][s],v=o==="landscape"&&e!=="watch"&&e!=="browser",y=v?b.h:b.w,M=v?b.w:b.h;useEffect(()=>{if(!d||!g.current)return;let E=g.current,D=null,k=I=>{D===null&&(D=I);let W=(I-D)/1e3;D=I,E.scrollTop+=c*W,E.scrollTop>=E.scrollHeight-E.clientHeight&&(E.scrollTop=0),x.current=requestAnimationFrame(k);};return x.current=requestAnimationFrame(k),()=>{x.current!==null&&cancelAnimationFrame(x.current);}},[d,c]);let w=jsx("div",{ref:d?g:void 0,className:u("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}):n}),P={showStatusBar:l,statusBarTime:i},h=()=>{switch(e){case "phone":return jsx(Jg,{theme:a,screenW:y,screenH:M,frameColor:p,landscape:v,...P,children:w});case "android":return jsx(ef,{theme:a,screenW:y,screenH:M,frameColor:p,...P,children:w});case "tablet":return jsx(tf,{theme:a,screenW:y,screenH:M,frameColor:p,...P,children:w});case "laptop":return jsx(rf,{theme:a,screenW:y,screenH:M,frameColor:p,children:w});case "desktop":return jsx(nf,{theme:a,screenW:y,screenH:M,frameColor:p,children:w});case "watch":return jsx(of,{theme:a,screenW:y,screenH:M,frameColor:p,...P,children:w});case "browser":return jsx(af,{theme:a,screenW:y,screenH:M,frameColor:p,children:w})}};return jsx("div",{className:u("inline-flex",f),"data-testid":"device-mockup","data-orientation":o,"data-theme":a,"data-size":s,children:h()})}var Oa={solid:"border-solid",dashed:"border-dashed",dotted:"border-dotted"},lf={left:{before:"flex-[0.1]",after:"flex-1"},center:{before:"flex-1",after:"flex-1"},right:{before:"flex-1",after:"flex-[0.1]"}};function fd({orientation:e="horizontal",variant:t="solid",label:r,textAlign:n="center",thickness:o=1,color:a="border-gray-300 dark:border-gray-700",spacing:s,className:l,...i}){if(e==="vertical")return jsx("hr",{"aria-orientation":"vertical",className:u("h-full border-l-0 border-r",Oa[t],a,s||"mx-2",l),style:{borderRightWidth:`${o}px`},...i});if(r){let d=lf[n];return jsxs("div",{role:"separator","aria-orientation":"horizontal",className:u("flex items-center text-sm text-gray-500 dark:text-gray-400",s||"my-4",l),...i,children:[jsx("div",{className:u("border-t",Oa[t],a,d.before),style:{borderTopWidth:`${o}px`}}),jsx("span",{className:"px-3 whitespace-nowrap",children:r}),jsx("div",{className:u("border-t",Oa[t],a,d.after),style:{borderTopWidth:`${o}px`}})]})}return jsx("hr",{"aria-orientation":"horizontal",className:u("border-t-0 border-b",Oa[t],a,s||"my-4",l),style:{borderBottomWidth:`${o}px`},...i})}fd.displayName="Divider";var cf=new Set(["SCRIPT","STYLE","LINK","META","NOSCRIPT","TEMPLATE","BASE","TITLE"]),bd="data-synertech-inert-ignore",jo=new WeakMap,ai=new WeakMap,si=new WeakMap;function uf(e){let t=jo.get(e)??0;t===0&&(ai.set(e,e.getAttribute("aria-hidden")),si.set(e,e.hasAttribute("inert")),e.setAttribute("aria-hidden","true"),e.setAttribute("inert","")),jo.set(e,t+1);}function pf(e){let t=jo.get(e)??0;if(t===0)return;if(t>1){jo.set(e,t-1);return}jo.delete(e);let r=ai.get(e)??null;r===null?e.removeAttribute("aria-hidden"):e.setAttribute("aria-hidden",r),ai.delete(e),si.get(e)||e.removeAttribute("inert"),si.delete(e);}var $a=new Map;function Ln(e,t){return $a.set(e,t),()=>{$a.delete(e);}}function _a(e){if($a.size===0)return [];let t=[];for(let[r,n]of $a){let o=n();o&&e.some(a=>a.contains(o))&&t.push(r);}return t}function mf(e){return !(cf.has(e.tagName)||e.hasAttribute(bd))}function ii(e){let t=(Array.isArray(e)?e:[e]).filter(Boolean),r=t[0]?.ownerDocument?.body;if(!r||!t.every(i=>r.contains(i)))return ()=>{};let n=[...t,..._a(t).filter(i=>r.contains(i))],o=[],a=new Set,s=i=>n.some(d=>i===d||i.contains(d));for(let i of t){let d=i;for(;d&&d!==r;){let c=d.parentElement;if(!c)break;for(let p of Array.from(c.children))a.has(p)||s(p)||mf(p)&&(a.add(p),uf(p),o.push(p));d=c;}}let l=false;return ()=>{if(!l){l=true;for(let i of o)pf(i);}}}var gn=[];function hd(e){let t=gn.indexOf(e);t!==-1&&gn.splice(t,1),gn.push(e);}function yd(e){let t=gn.indexOf(e);t!==-1&&gn.splice(t,1);}function xd(e){return gn.length>0&&gn[gn.length-1]===e}var qo=0,li=null;function vd(e=document){let t=e.body;if(!t)return ()=>{};qo===0&&(li=t.style.overflow,t.style.overflow="hidden"),qo+=1;let r=false;return ()=>{r||(r=true,qo=Math.max(0,qo-1),qo===0&&(t.style.overflow=li??"",li=null));}}var kd=["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 gf(e){let t=e.ownerDocument?.defaultView;if(!t)return null;try{return t.getComputedStyle(e)}catch{return null}}function Cd(e){let t=e;for(;t;){if(t.hasAttribute("hidden")||t.hasAttribute("inert")||t.getAttribute("aria-hidden")==="true")return false;let r=gf(t);if(r&&(r.display==="none"||r.visibility==="hidden"||r.visibility==="collapse"))return false;t=t.parentElement;}return true}function wd(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 Cd(e)}function Xa(e){return Array.from(e.querySelectorAll(kd)).filter(wd).sort((r,n)=>{let o=r.compareDocumentPosition(n);return o&Node.DOCUMENT_POSITION_FOLLOWING?-1:o&Node.DOCUMENT_POSITION_PRECEDING?1:0})}var ff={role:"dialog","aria-modal":true,tabIndex:-1};function bf(e,t){return t==="none"?null:t&&typeof t=="object"?t.current??e:t==="first"?Xa(e)[0]??e:e}function hf(e){return e?e.map(t=>t&&"current"in t?t.current:t).filter(t=>!!t):[]}function lo(e){if(e)try{e.focus();}catch{}}function An(e){let{open:t}=e,r=useRef(null),n=useRef(e);return n.current=e,useEffect(()=>{if(!t)return;let o=r.current;if(!o)return;let a=o.ownerDocument,s=a.activeElement,{hideBackground:l,lockScroll:i,initialFocus:d,keepInteractive:c}=n.current;hd(o);let p=l===false?void 0:ii([o,...hf(c)]),f=i===false?void 0:vd(a);return lo(bf(o,d)),()=>{p?.(),f?.(),yd(o);let{returnFocus:m}=n.current;if(m===false)return;let g=a.activeElement;if(!(!g||g===a.body||o.contains(g)))return;let b=m&&typeof m=="object"?m.current:s;b&&a.contains(b)&&lo(b);}},[t]),useEffect(()=>{if(!t)return;let o=r.current;if(!o)return;let a=o.ownerDocument,s=a.defaultView??a,l=d=>d?o.contains(d)?true:_a([o]).some(c=>c.contains(d)):false,i=d=>{if(d.defaultPrevented||!xd(o))return;let{closeOnEscape:c,trapFocus:p,onClose:f}=n.current;if(d.key==="Escape"){if(c===false)return;d.preventDefault(),f?.();return}if(d.key!=="Tab"||p===false)return;let m=a.activeElement;if(m&&!o.contains(m)&&l(m))return;let g=Xa(o);if(g.length===0){d.preventDefault(),lo(o);return}let x=g[0],b=g[g.length-1];if(!m||!o.contains(m)){d.preventDefault(),lo(d.shiftKey?b:x);return}if(d.shiftKey&&(m===x||m===o)){d.preventDefault(),lo(b);return}!d.shiftKey&&m===b&&(d.preventDefault(),lo(x));};return s.addEventListener("keydown",i),()=>s.removeEventListener("keydown",i)},[t]),{dialogRef:r,dialogProps:ff}}var Cf={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"}},wf={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"},Rd={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"}},Nf=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 Td({open:e,onClose:t,children:r,position:n="right",size:o="md",customWidth:a,customHeight:s,showOverlay:l=true,closeOnOverlayClick:i=true,closeOnEscape:d=true,title:c,footer:p,className:f,overlayClassName:m,closeLabel:g,"aria-label":x,trapFocus:b=true,initialFocus:v,returnFocus:y,lockScroll:M=true}){let w=!!(a||s),P=useRef(null),h=At(),D=`${useId()}-drawer-title`,{dialogRef:k,dialogProps:I}=An({open:e,onClose:t,closeOnEscape:d,trapFocus:b,initialFocus:v,returnFocus:y,lockScroll:M,keepInteractive:[P]}),W=useCallback(()=>{i&&t();},[i,t]);if(!e)return null;let O=jsxs(Fragment,{children:[l&&jsx("div",{ref:P,className:u("fixed inset-0 bg-black/50 z-40 transition-opacity",e?"animate-in fade-in duration-200":"animate-out fade-out duration-150",m),onClick:W,"aria-hidden":"true"}),jsxs("div",{ref:k,...I,"aria-labelledby":c?D:void 0,"aria-label":c?void 0:x,className:u("fixed z-50 bg-white dark:bg-gray-900","shadow-xl overflow-hidden","flex flex-col focus:outline-none",wf[n],!w&&Cf[n][o],e?Rd[n].enter:Rd[n].exit,f),style:{...a?{width:a}:{},...s?{height:s}:{}},children:[c&&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:D,className:"text-lg font-semibold text-gray-900 dark:text-white",children:c}),jsx("button",{type:"button",onClick:t,className:u("rounded-lg p-1.5 text-gray-400 hover:bg-gray-100 hover:text-gray-900","dark:hover:bg-gray-800 dark:hover:text-white","focus:outline-none focus:ring-2 focus:ring-gray-300 dark:focus:ring-gray-600"),"aria-label":g??h.closeDrawer,children:Nf})]}),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(O,document.body):O}Td.displayName="Drawer";var Pf={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"}},Md=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]}`},ci=e=>e.webkitRelativePath||e.name,Ef=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"})}),Df=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"})}),Mf=0;async function If(e){let t=[],r=async n=>{if(n.isFile){let o=await new Promise((a,s)=>n.file(a,s));t.push(o);}else if(n.isDirectory){let o=n.createReader(),a=()=>new Promise((l,i)=>o.readEntries(l,i)),s=await a();for(;s.length>0;){for(let l of s)await r(l);s=await a();}}};for(let n of e)await r(n);return t}function Lf({value:e,onChange:t,accept:r,multiple:n=false,maxSize:o=10*1024*1024,maxFiles:a,mode:s="file",variant:l="dropzone",size:i="md",disabled:d=false,readOnly:c=false,label:p,helperText:f,error:m,showFileList:g=true,placeholder:x,browseLabel:b,browseFolderLabel:v,icon:y,onReject:M,className:w}){let[P,h]=useState([]),[E,D]=useState(false),k=useRef(null),I=useRef(null),W=useId(),O=e!==void 0,L=O?e.map((q,de)=>({file:q,id:`ctrl-${de}`})):P,T=Pf[i];useEffect(()=>{s==="directory"&&k.current&&k.current.setAttribute("webkitdirectory",""),s==="both"&&I.current&&I.current.setAttribute("webkitdirectory","");},[s]);let S=useMemo(()=>Md(o),[o]),C=useMemo(()=>r?r.split(",").map(q=>q.trim()).map(q=>q.startsWith(".")?q.toUpperCase():q.endsWith("/*")?q.replace("/*","").toUpperCase():q).join(", "):"All files",[r]),N=s==="directory"?"Drag & drop a folder here, or":s==="both"?"Drag & drop files or folders here, or":n?"Drag & drop files here, or":"Drag & drop a file here, or",R=s==="directory"?"Browse folder":"Browse",$="Browse folder",H=useCallback(q=>{if(q.size>o)return `File exceeds maximum size of ${S}`;if(r){let de=r.split(",").map(le=>le.trim()),xe=`.${q.name.split(".").pop()?.toLowerCase()}`;if(!de.some(le=>le.startsWith(".")?xe===le.toLowerCase():le.endsWith("/*")?q.type.startsWith(le.replace("/*","/")):q.type===le))return `File type not accepted. Expected: ${C}`}return null},[r,C,o,S]),K=useCallback(q=>{if(d||c)return;let de=Array.from(q),xe=[];for(let ke of de){let le=H(ke);le?M?.(ke,le):xe.push(ke);}if(xe.length!==0)if(O)if(n){let le=[...e??[],...xe],Se=a?le.slice(0,a):le;t?.(Se);}else t?.([xe[0]]);else h(ke=>{let le=xe.map(Se=>({file:Se,id:`file-${++Mf}`}));if(n){let Se=[...ke,...le],Me=a?Se.slice(0,a):Se,je=Me.map(at=>at.file);return t?.(je),Me}return t?.([xe[0]]),[le[0]]});},[d,c,O,n,a,e,t,M,H]),_=useCallback(q=>{if(!(d||c)){if(O){let de=(e??[]).filter((xe,ke)=>ke!==q);t?.(de);}else h(de=>{let xe=de.filter((ke,le)=>le!==q);return t?.(xe.map(ke=>ke.file)),xe});k.current&&(k.current.value="");}},[d,c,O,e,t]),F=useCallback(()=>{d||c||(O?t?.([]):(h([]),t?.([])),k.current&&(k.current.value=""));},[d,c,O,t]),A=useCallback(q=>{q.target.files&&q.target.files.length>0&&K(q.target.files);},[K]),B=useCallback(q=>{q.preventDefault(),q.stopPropagation(),!d&&!c&&D(true);},[d,c]),U=useCallback(q=>{q.preventDefault(),q.stopPropagation(),D(false);},[]),Q=useCallback(q=>{if(q.preventDefault(),q.stopPropagation(),D(false),d||c)return;let de=q.dataTransfer.items;if(de&&de.length>0&&(s==="directory"||s==="both")){let xe=[];for(let le=0;le<de.length;le++){let Se=de[le].webkitGetAsEntry?.();Se&&xe.push(Se);}if(xe.some(le=>le.isDirectory)){If(xe).then(le=>{le.length>0&&K(le);});return}}q.dataTransfer.files&&q.dataTransfer.files.length>0&&K(q.dataTransfer.files);},[d,c,s,K]),J=useCallback(()=>{!d&&!c&&k.current?.click();},[d,c]),Y=useCallback(()=>{!d&&!c&&I.current?.click();},[d,c]),z=L.length>0,X=y||(s==="directory"?Df:Ef),ne=g&&z&&jsxs("div",{className:u("flex flex-col",T.gap),children:[L.map((q,de)=>jsxs("div",{className:u("flex items-center justify-between rounded-md border border-gray-200 dark:border-gray-700 bg-gray-50 dark:bg-gray-800/50",T.fileItem),children:[jsxs("div",{className:"flex items-center gap-2 min-w-0 flex-1",children:[jsx("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",strokeWidth:1.5,stroke:"currentColor",className:"w-4 h-4 shrink-0 text-gray-400 dark:text-gray-500",children:jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M19.5 14.25v-2.625a3.375 3.375 0 00-3.375-3.375h-1.5A1.125 1.125 0 0113.5 7.125v-1.5a3.375 3.375 0 00-3.375-3.375H8.25m2.25 0H5.625c-.621 0-1.125.504-1.125 1.125v17.25c0 .621.504 1.125 1.125 1.125h12.75c.621 0 1.125-.504 1.125-1.125V11.25a9 9 0 00-9-9z"})}),jsx("span",{className:"truncate text-gray-700 dark:text-gray-300",children:ci(q.file)}),jsxs("span",{className:"shrink-0 text-gray-400 dark:text-gray-500",children:["(",Md(q.file.size),")"]})]}),!d&&!c&&jsx("button",{type:"button",onClick:()=>_(de),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 ${ci(q.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"})})})]},q.id)),n&&L.length>1&&!d&&!c&&jsx("button",{type:"button",onClick:F,className:u("self-start text-gray-400 hover:text-red-500 dark:text-gray-500 dark:hover:text-red-400 transition-colors cursor-pointer",T.subtext),children:"Remove all"})]}),re=u("rounded-md border border-gray-300 dark:border-gray-600 bg-white dark:bg-gray-800 text-gray-700 dark:text-gray-200 font-medium transition-colors","hover:bg-gray-50 dark:hover:bg-gray-700","disabled:opacity-50 disabled:cursor-not-allowed cursor-pointer","focus:outline-none focus:ring-2 focus:ring-blue-500 focus:ring-offset-1",T.button,m&&"border-red-300 dark:border-red-600");return jsxs("div",{className:u("flex flex-col",T.gap,w),children:[p&&jsx("label",{htmlFor:W,className:u("block font-medium text-gray-700 dark:text-gray-300",T.text),children:p}),jsx("input",{ref:k,id:W,type:"file",accept:s!=="directory"?r:void 0,multiple:n,onChange:A,className:"sr-only",disabled:d||c,"aria-describedby":m?`${W}-error`:f?`${W}-helper`:void 0,"aria-invalid":!!m}),s==="both"&&jsx("input",{ref:I,type:"file",onChange:A,className:"sr-only",disabled:d||c,tabIndex:-1,"aria-hidden":"true"}),l==="dropzone"?jsxs("div",{role:s==="both"?"group":"button",tabIndex:s==="both"?void 0:d||c?-1:0,onClick:s==="both"?void 0:J,onKeyDown:s==="both"?void 0:q=>{(q.key==="Enter"||q.key===" ")&&(q.preventDefault(),J());},onDragOver:B,onDragLeave:U,onDrop:Q,className:u("flex flex-col items-center justify-center rounded-lg border-2 border-dashed transition-colors",T.dropzone,E&&!d&&!c?"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&&!c&&"hover:border-blue-400 dark:hover:border-blue-500 hover:bg-gray-50 dark:hover:bg-gray-800/70",s!=="both"&&!d&&!c&&"cursor-pointer",d&&"opacity-50 cursor-not-allowed",c&&"cursor-default",m&&"border-red-300 dark:border-red-600"),"aria-label":s==="both"?"File and folder drop zone":x||N,children:[jsx("div",{className:u("text-gray-400 dark:text-gray-500 mb-2",T.icon,E&&"text-blue-500 dark:text-blue-400"),children:X}),jsxs("p",{className:u("text-gray-600 dark:text-gray-400",T.text),children:[x||N," ",!d&&!c&&s!=="both"&&jsx("span",{className:"text-blue-600 dark:text-blue-400 font-medium",children:b||R})]}),s==="both"&&!d&&!c&&jsxs("div",{className:u("flex items-center gap-3 mt-1",T.text),children:[jsx("button",{type:"button",onClick:J,className:"text-blue-600 dark:text-blue-400 font-medium hover:underline cursor-pointer focus:outline-none focus:ring-2 focus:ring-blue-500 focus:ring-offset-1 rounded",children:b||"Browse files"}),jsx("span",{className:"text-gray-300 dark:text-gray-600",children:"\xB7"}),jsx("button",{type:"button",onClick:Y,className:"text-blue-600 dark:text-blue-400 font-medium hover:underline cursor-pointer focus:outline-none focus:ring-2 focus:ring-blue-500 focus:ring-offset-1 rounded",children:v||$})]}),jsxs("p",{className:u("text-gray-400 dark:text-gray-500 mt-1",T.subtext),children:[C," - Max ",S,n&&a&&` - Up to ${a} files`]})]}):jsxs("div",{className:"flex items-center gap-2",children:[s==="both"?jsxs(Fragment,{children:[jsx("button",{type:"button",onClick:J,disabled:d||c,className:re,children:b||(z?"Change files":"Choose files")}),jsx("button",{type:"button",onClick:Y,disabled:d||c,className:re,children:v||"Choose folder"})]}):jsx("button",{type:"button",onClick:J,disabled:d||c,className:re,children:b||(s==="directory"?z?"Change folder":"Choose folder":z?"Change file":"Choose file")}),!z&&jsx("span",{className:u("text-gray-400 dark:text-gray-500",T.text),children:s==="directory"?"No folder selected":s==="both"?"No file or folder selected":"No file selected"}),z&&!g&&jsx("span",{className:u("text-gray-600 dark:text-gray-400 truncate",T.text),children:L.length===1?ci(L[0].file):`${L.length} files selected`})]}),ne,m&&jsx("p",{id:`${W}-error`,className:u("text-red-600 dark:text-red-400",T.subtext),role:"alert",children:m}),f&&!m&&jsx("p",{id:`${W}-helper`,className:u("text-gray-400 dark:text-gray-500",T.subtext),children:f})]})}var Ad=createContext(null);function nr(){let e=useContext(Ad);if(!e)throw new Error("Dropdown compound components must be used within a Dropdown");return e}function zd({open:e,defaultOpen:t=false,onOpenChange:r,closeOnSelect:n=true,closeOnClickOutside:o=true,closeOnEscape:a=true,modal:s=false,children:l}){let[i,d]=useState(t),c=e!==void 0,p=c?e:i,f=useRef(null),m=useRef(null),g=useRef([]),[x,b]=useState(-1),v=useRef(0),y=useId(),M={triggerId:`dropdown-trigger-${y}`,contentId:`dropdown-content-${y}`},w=useCallback(D=>{c||d(D),r?.(D),D||b(-1);},[c,r]),P=useCallback((D,k)=>{g.current&&(g.current[D]=k);},[]),h=useCallback(()=>v.current++,[]),E={isOpen:p,setIsOpen:w,triggerRef:f,contentRef:m,closeOnSelect:n,closeOnClickOutside:o,closeOnEscape:a,modal:s,focusedIndex:x,setFocusedIndex:b,itemsRef:g,registerItem:P,getNextItemIndex:h,triggerId:M.triggerId,contentId:M.contentId};return jsx(Ad.Provider,{value:E,children:jsx("div",{className:"relative inline-block",children:l})})}zd.displayName="Dropdown";var Wd=memo(({isOpen:e})=>jsx("span",{className:u("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"})})}));Wd.displayName="ChevronIcon";function Hd({asChild:e=false,disabled:t=false,children:r,className:n}){let{isOpen:o,setIsOpen:a,triggerRef:s,triggerId:l,contentId:i}=nr(),p={ref:s,id:l,"aria-haspopup":"menu","aria-expanded":o,"aria-controls":o?i:void 0,disabled:t,onClick:()=>{t||a(!o);},onKeyDown:f=>{t||((f.key==="Enter"||f.key===" ")&&(f.preventDefault(),a(!o)),f.key==="ArrowDown"&&!o&&(f.preventDefault(),a(true)));}};return e&&isValidElement(r)?cloneElement(r,{...p,className:u(r.props.className,n)}):jsxs("button",{type:"button",...p,className:u("inline-flex items-center justify-center gap-2","rounded-md px-4 py-2","bg-white border border-gray-300","text-sm font-medium text-gray-700","hover:bg-gray-50","focus:outline-none focus-visible:ring-2 focus-visible:ring-blue-500 focus-visible:ring-offset-2","disabled:opacity-50 disabled:cursor-not-allowed","transition-colors",n),children:[r,jsx(Wd,{isOpen:o})]})}Hd.displayName="DropdownTrigger";function co(e){let t=useRef(e);return useLayoutEffect(()=>{t.current=e;}),t}function uo(e,t,r=true){let n=co(t);useEffect(()=>{if(!r)return;let o=a=>{let s=a.target;!e.current||e.current.contains(s)||n.current();};return document.addEventListener("mousedown",o),document.addEventListener("touchstart",o,{passive:true}),()=>{document.removeEventListener("mousedown",o),document.removeEventListener("touchstart",o);}},[r,n,e]);}function po({triggerRef:e,contentRef:t,isOpen:r,side:n="bottom",align:o="start",sideOffset:a=4,alignOffset:s=0,avoidCollisions:l=true,collisionPadding:i=8}){let[d,c]=useState({top:0,left:0,actualSide:n,actualAlign:o,isReady:false}),p=useRef(false),f=useCallback(()=>{if(!e.current||!t.current)return;let m=e.current.getBoundingClientRect(),g=t.current.getBoundingClientRect();if(!(m.width>0&&m.height>0&&g.width>0&&g.height>0)){p.current=false;return}let b={width:window.innerWidth,height:window.innerHeight},v=n,y=o,M=h=>{switch(h){case "bottom":return {top:m.bottom+a,left:m.left};case "top":return {top:m.top-g.height-a,left:m.left};case "right":return {top:m.top,left:m.right+a};case "left":return {top:m.top,left:m.left-g.width-a}}},w=(h,E,D)=>{if(h==="top"||h==="bottom")switch(E){case "start":return {...D,left:m.left+s};case "center":return {...D,left:m.left+m.width/2-g.width/2+s};case "end":return {...D,left:m.right-g.width+s}}else switch(E){case "start":return {...D,top:m.top+s};case "center":return {...D,top:m.top+m.height/2-g.height/2+s};case "end":return {...D,top:m.bottom-g.height+s}}},P=M(v);if(P=w(v,y,P),l){let{top:h,left:E}=P,{height:D,width:k}=g,{height:I,width:W}=b,O=h+D>I-i,L=h<i,T=E+k>W-i,S=E<i;v==="bottom"&&O&&!L?(v="top",P=M(v),P=w(v,y,P)):v==="top"&&L&&!O&&(v="bottom",P=M(v),P=w(v,y,P)),v==="right"&&T&&!S?(v="left",P=M(v),P=w(v,y,P)):v==="left"&&S&&!T&&(v="right",P=M(v),P=w(v,y,P));let C=P.left+k>W-i,N=P.left<i,R=P.top+D>I-i,$=P.top<i;(v==="top"||v==="bottom")&&(C&&(P.left=W-k-i,y="end"),N&&(P.left=i,y="start")),(v==="left"||v==="right")&&(R&&(P.top=I-D-i,y="end"),$&&(P.top=i,y="start"));}p.current=true,c({top:P.top,left:P.left,actualSide:v,actualAlign:y,isReady:true});},[e,t,n,o,a,s,l,i]);return useLayoutEffect(()=>{let m=0;if(r){p.current=false;let x=()=>{f(),p.current||(m=requestAnimationFrame(x));};m=requestAnimationFrame(x);}let g=()=>f();return window.addEventListener("resize",g),window.addEventListener("scroll",g,{passive:true,capture:true}),()=>{m&&cancelAnimationFrame(m),window.removeEventListener("resize",g),window.removeEventListener("scroll",g,{capture:true});}},[f,r]),d}function Ua({isOpen:e,onClose:t,itemsCount:r,focusedIndex:n,setFocusedIndex:o,onSelect:a,loop:s=true}){let l=co(t),i=co(a),d=co(n),c=useCallback(p=>{if(!(!e||r===0))switch(p.key){case "ArrowDown":p.preventDefault(),o(s?f=>f<r-1?f+1:0:f=>Math.min(f+1,r-1));break;case "ArrowUp":p.preventDefault(),o(s?f=>f>0?f-1:r-1:f=>Math.max(f-1,0));break;case "Home":p.preventDefault(),o(0);break;case "End":p.preventDefault(),o(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,o,s,l,i,d]);return useEffect(()=>{if(e)return document.addEventListener("keydown",c),()=>document.removeEventListener("keydown",c)},[e,c]),{focusedIndex:n}}function Vd(e,t,r){useEffect(()=>{r&&e.current&&e.current[t]&&e.current[t]?.focus();},[t,r,e]);}var eb={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 Od({side:e="bottom",align:t="start",sideOffset:r=4,alignOffset:n=0,avoidCollisions:o=true,collisionPadding:a=8,minWidth:s,maxWidth:l,maxHeight:i=300,animation:d="scale",portal:c=true,children:p,className:f}){let{isOpen:m,setIsOpen:g,triggerRef:x,contentRef:b,closeOnClickOutside:v,closeOnEscape:y,modal:M,contentId:w,focusedIndex:P,setFocusedIndex:h,itemsRef:E}=nr(),[D,k]=useState(false),I=po({triggerRef:x,contentRef:b,isOpen:m,side:e,align:t,sideOffset:r,alignOffset:n,avoidCollisions:o,collisionPadding:a});uo(b,()=>{v&&g(false);},m);let W=E.current?.filter(Boolean).length||0,O=useCallback(T=>{let S=E.current?.[T];S&&!S.hasAttribute("data-disabled")&&S.click();},[E]);Ua({isOpen:m,onClose:()=>{y&&(g(false),x.current?.focus());},itemsCount:W,focusedIndex:P,setFocusedIndex:h,onSelect:O}),useEffect(()=>{let T=b.current;if(T)return Ln(T,()=>x.current)},[b,x]),useEffect(()=>{if(m&&E.current&&E.current.length>0){let T=setTimeout(()=>{h(0),E.current?.[0]?.focus();},10);return ()=>clearTimeout(T)}},[m,E,h]),useLayoutEffect(()=>{let T=0;if(!m){k(false);return}let S=()=>{let C=x.current?.getBoundingClientRect(),N=b.current?.getBoundingClientRect();if(I.isReady&&!!C&&!!N&&C.width>0&&C.height>0&&N.width>0&&N.height>0){k(true);return}T=requestAnimationFrame(S);};return k(false),T=requestAnimationFrame(S),()=>{T&&cancelAnimationFrame(T);}},[m,I.isReady,x,b]);let L=jsxs(Fragment,{children:[M&&m&&jsx("div",{className:"fixed inset-0 z-40 bg-black/20",onClick:()=>g(false)}),jsx("div",{ref:b,id:w,role:"menu","aria-orientation":"vertical","aria-hidden":!m,tabIndex:-1,style:{position:"fixed",top:I.top,left:I.left,minWidth:s??x.current?.offsetWidth,maxWidth:l,maxHeight:i,visibility:m&&D?"visible":"hidden",opacity:m&&D?1:0,pointerEvents:m&&D?"auto":"none"},className:u("z-50 overflow-auto rounded-lg","border border-gray-200 bg-white shadow-lg","dark:border-gray-700 dark:bg-gray-800",m&&D&&eb[d],f),children:jsx("div",{className:"py-1",children:p})})]});return c&&typeof document<"u"?createPortal(L,document.body):L}Od.displayName="DropdownContent";var sb={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 _d({children:e,icon:t,iconPosition:r="left",description:n,shortcut:o,variant:a="default",closeOnSelect:s,onSelect:l,disabled:i=false,className:d,onClick:c,index:p,...f}){let{setIsOpen:m,closeOnSelect:g,focusedIndex:x,setFocusedIndex:b,registerItem:v,getNextItemIndex:y}=nr(),M=useRef(null),[w]=useState(()=>p??y());useEffect(()=>(v(w,M.current),()=>{v(w,null);}),[w,v]);let P=s??g,h=x===w;return jsxs("button",{ref:M,role:"menuitem",type:"button",tabIndex:h?0:-1,disabled:i,"data-disabled":i||void 0,"data-focused":h||void 0,onClick:k=>{i||(l?.(),c?.(k),P&&m(false));},onMouseEnter:()=>{i||b(w);},className:u("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",sb[a],i&&"opacity-50 cursor-not-allowed hover:bg-transparent",h&&"bg-gray-100 dark:bg-gray-700",d),...f,children:[t&&r==="left"&&jsx("span",{className:"mr-2 shrink-0 w-5 h-5",children:t}),jsxs("span",{className:"flex-1 min-w-0",children:[jsx("span",{className:"block truncate",children:e}),n&&jsx("span",{className:"block text-xs text-gray-500 dark:text-gray-400 truncate",children:n})]}),t&&r==="right"&&jsx("span",{className:"ml-2 shrink-0 w-5 h-5",children:t}),o&&jsx("span",{className:"ml-auto pl-4 text-xs text-gray-400 dark:text-gray-500",children:o})]})}_d.displayName="DropdownItem";function Xd({className:e}){return jsx("hr",{className:u("my-1 h-px border-0 bg-gray-200 dark:bg-gray-700",e)})}Xd.displayName="DropdownSeparator";function Gd({children:e,className:t}){return jsx("div",{className:u("px-3 py-1.5 text-xs font-semibold text-gray-500 dark:text-gray-400",t),children:e})}Gd.displayName="DropdownLabel";function jd({checked:e,defaultChecked:t=false,onCheckedChange:r,children:n,icon:o,description:a,disabled:s=false,closeOnChange:l=false,className:i,index:d}){let{setIsOpen:c,focusedIndex:p,setFocusedIndex:f,registerItem:m,getNextItemIndex:g}=nr(),x=useRef(null),[b]=useState(()=>d??g()),[v,y]=useState(t),M=e!==void 0,w=M?e:v;useEffect(()=>(m(b,x.current),()=>{m(b,null);}),[b,m]);let P=p===b;return jsxs("button",{ref:x,role:"menuitemcheckbox",type:"button",tabIndex:P?0:-1,"aria-checked":w,disabled:s,"data-disabled":s||void 0,"data-focused":P||void 0,onClick:()=>{if(s)return;let D=!w;M||y(D),r?.(D),l&&c(false);},onMouseEnter:()=>{s||f(b);},className:u("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",P&&"bg-gray-100 dark:bg-gray-700",i),children:[jsx("span",{className:"mr-2 shrink-0 w-4 h-4",children:o||jsx("span",{className:u("flex items-center justify-center w-4 h-4 rounded border-2 transition-colors",w?"bg-blue-600 border-blue-600":"border-gray-300 dark:border-gray-600"),children:w&&jsx("svg",{className:"w-3 h-3 text-white",viewBox:"0 0 16 16",fill:"none",children:jsx("path",{d:"M13.5 4.5L6 12L2.5 8.5",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round"})})})}),jsxs("span",{className:"flex-1 min-w-0",children:[jsx("span",{className:"block truncate",children:n}),a&&jsx("span",{className:"block text-xs text-gray-500 dark:text-gray-400 truncate",children:a})]})]})}jd.displayName="DropdownCheckboxItem";var Qd=createContext(null);function fb(){let e=useContext(Qd);if(!e)throw new Error("DropdownRadioItem must be used within a DropdownRadioGroup");return e}function Jd({value:e,defaultValue:t="",onValueChange:r,children:n,className:o}){let[a,s]=useState(t),l=e!==void 0,i=l?e:a,d=useCallback(p=>{l||s(p),r?.(p);},[l,r]),c=useMemo(()=>({value:i,onValueChange:d}),[i,d]);return jsx(Qd.Provider,{value:c,children:jsx("div",{role:"group",className:o,children:n})})}Jd.displayName="DropdownRadioGroup";function ec({value:e,children:t,icon:r,description:n,disabled:o=false,closeOnChange:a=true,className:s,index:l}){let{value:i,onValueChange:d}=fb(),{setIsOpen:c,focusedIndex:p,setFocusedIndex:f,registerItem:m,getNextItemIndex:g}=nr(),x=useRef(null),[b]=useState(()=>l??g()),v=i===e;useEffect(()=>(m(b,x.current),()=>{m(b,null);}),[b,m]);let y=p===b;return jsxs("button",{ref:x,role:"menuitemradio",type:"button",tabIndex:y?0:-1,"aria-checked":v,disabled:o,"data-disabled":o||void 0,"data-focused":y||void 0,onClick:()=>{o||(d(e),a&&c(false));},onMouseEnter:()=>{o||f(b);},className:u("relative flex w-full items-center px-3 py-2 text-left text-sm","outline-none transition-colors","text-gray-700 dark:text-gray-200","hover:bg-gray-100 dark:hover:bg-gray-700","focus:bg-gray-100 dark:focus:bg-gray-700",o&&"opacity-50 cursor-not-allowed hover:bg-transparent",y&&"bg-gray-100 dark:bg-gray-700",s),children:[jsx("span",{className:"mr-2 shrink-0 w-4 h-4",children:r||jsx("span",{className:u("flex items-center justify-center w-4 h-4 rounded-full border-2 transition-colors",v?"border-blue-600":"border-gray-300 dark:border-gray-600"),children:v&&jsx("span",{className:"w-2 h-2 rounded-full bg-blue-600"})})}),jsxs("span",{className:"flex-1 min-w-0",children:[jsx("span",{className:"block truncate",children:t}),n&&jsx("span",{className:"block text-xs text-gray-500 dark:text-gray-400 truncate",children:n})]}),v&&!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"})})]})}ec.displayName="DropdownRadioItem";var oc=createContext(null);function ac(){let e=useContext(oc);if(!e)throw new Error("DropdownSubMenu components must be used within a DropdownSubMenu");return e}function sc({children:e}){let[t,r]=useState(false),n=useRef(null),o=useRef(null),a=useMemo(()=>({isOpen:t,setIsOpen:r,triggerRef:n,contentRef:o}),[t]);return jsx(oc.Provider,{value:a,children:jsx("div",{className:"relative",children:e})})}sc.displayName="DropdownSubMenu";var rc=0;function ic({children:e,icon:t,disabled:r=false,className:n,index:o}){let{isOpen:a,setIsOpen:s,triggerRef:l}=ac(),{focusedIndex:i,setFocusedIndex:d,registerItem:c}=nr(),p=useRef(o??-1);useEffect(()=>(o===void 0&&(p.current=rc++),c(p.current,l.current),()=>{c(p.current,null);}),[o,c,l]),useEffect(()=>()=>{rc=0;},[]);let f=i===p.current;return jsxs("button",{ref:l,role:"menuitem",type:"button",tabIndex:f?0:-1,"aria-haspopup":"menu","aria-expanded":a,disabled:r,"data-disabled":r||void 0,"data-focused":f||void 0,onMouseEnter:()=>{r||(d(p.current),s(true));},onMouseLeave:()=>{setTimeout(()=>{s(false);},100);},onKeyDown:b=>{r||(b.key==="ArrowRight"||b.key==="Enter")&&(b.preventDefault(),s(true));},className:u("relative flex w-full items-center px-3 py-2 text-left text-sm","outline-none transition-colors","text-gray-700 dark:text-gray-200","hover:bg-gray-100 dark:hover:bg-gray-700","focus:bg-gray-100 dark:focus:bg-gray-700",r&&"opacity-50 cursor-not-allowed hover:bg-transparent",f&&"bg-gray-100 dark:bg-gray-700",n),children:[t&&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"})})]})}ic.displayName="DropdownSubMenuTrigger";function lc({children:e,sideOffset:t=0,className:r}){let{isOpen:n,setIsOpen:o,triggerRef:a,contentRef:s}=ac(),[l,i]=useState(false),d=po({triggerRef:a,contentRef:s,isOpen:n,side:"right",align:"start",sideOffset:t,avoidCollisions:true});uo(s,()=>o(false),n),useEffect(()=>{let g=s.current;if(g)return Ln(g,()=>a.current)},[s,a]);let c=useCallback(()=>{o(true);},[o]),p=useCallback(()=>{o(false);},[o]),f=g=>{(g.key==="ArrowLeft"||g.key==="Escape")&&(g.preventDefault(),o(false),a.current?.focus());};useLayoutEffect(()=>{let g=0;if(!n){i(false);return}let x=()=>{let b=a.current?.getBoundingClientRect(),v=s.current?.getBoundingClientRect();if(d.isReady&&!!b&&!!v&&b.width>0&&b.height>0&&v.width>0&&v.height>0){i(true);return}g=requestAnimationFrame(x);};return i(false),g=requestAnimationFrame(x),()=>{g&&cancelAnimationFrame(g);}},[n,d.isReady,a,s]);let m=jsx("div",{ref:s,role:"menu","aria-orientation":"vertical","aria-hidden":!n,tabIndex:-1,onMouseEnter:c,onMouseLeave:p,onKeyDown:f,style:{position:"fixed",top:d.top,left:d.left,visibility:n&&l?"visible":"hidden",opacity:n&&l?1:0,pointerEvents:n&&l?"auto":"none"},className:u("z-50 min-w-40 overflow-hidden rounded-lg","border border-gray-200 bg-white shadow-lg","dark:border-gray-700 dark:bg-gray-800",n&&l&&"animate-in fade-in-0 zoom-in-95 duration-150",r),children:jsx("div",{className:"py-1",children:e})});return typeof document<"u"?createPortal(m,document.body):m}lc.displayName="DropdownSubMenuContent";var Cb=(e="md")=>({sm:"text-xs p-1.5",md:"text-sm p-2.5",lg:"text-base p-3.5"})[e],go=({size:e="md",error:t,disabled:r,readOnly:n,icon:o,iconPosition:a})=>u("bg-gray-50 rounded-lg block w-full","border focus:outline-none focus:ring-0","dark:bg-gray-700 dark:placeholder-gray-400",Cb(e),o&&a==="left"?"pl-9":"",o&&a==="right"?"pr-9":"",r?"opacity-50 cursor-not-allowed":"",n?"bg-gray-100 dark:bg-gray-600 cursor-default":"",t?"border-red-500 dark:border-red-500":"border-gray-300 dark:border-gray-600"),dc=(e,t)=>u("text-sm font-medium",e?"min-w-[120px]":"block mb-2",!t&&"text-gray-900 dark:text-white"),cc=e=>u("mt-1 text-xs",e?"text-red-500 dark:text-red-400":"text-gray-500 dark:text-gray-400"),Wn=e=>u("absolute inset-y-0 flex items-center pointer-events-none",e==="left"?"left-2.5":"right-2.5");var fo=({label:e,hideLabel:t,labelColor:r,error:n,helperText:o,inline:a,children:s,htmlFor:l})=>jsxs("div",{className:a?"flex items-center gap-4":"flex flex-col",children:[e&&!t&&jsx("label",{htmlFor:l,className:dc(a||false,r),style:r?{color:r}:void 0,children:e}),jsx("div",{className:a?"flex-1":"w-full",children:s}),o&&jsx("p",{className:u(cc(n),a&&"ml-34"),children:o})]});var Vr=forwardRef(({label:e,inline:t=false,size:r="md",labelColor:n,borderColor:o,textColor:a,disabled:s=false,readOnly:l=false,error:i=false,helperText:d,hideLabel:c=false,icon:p,iconPosition:f="left",multiline:m=false,rows:g=3,focused:x=false,className:b,...v},y)=>{let M=useRef(null),w=I=>{M.current=I,typeof y=="function"?y(I):y&&(y.current=I);};useEffect(()=>{x&&M.current?.focus();},[x]);let P=useId(),h=u(go({size:r,error:i,disabled:s,readOnly:l,icon:p,iconPosition:f}),m&&"resize-vertical",b),E={...o&&{borderColor:o},...a&&{color:a}},D=o||a?E:void 0;return jsx(fo,{label:e,hideLabel:c,labelColor:n,error:i,helperText:d,inline:t,htmlFor:P,children:jsxs("div",{className:"relative w-full",children:[p&&jsx("span",{className:Wn(f),children:p}),m?jsx("textarea",{ref:w,id:P,disabled:s,readOnly:l,rows:g,tabIndex:l||s?-1:void 0,className:h,style:D,...v}):jsx("input",{ref:w,id:P,disabled:s,readOnly:l,tabIndex:l||s?-1:void 0,className:h,style:D,...v})]})})});Vr.displayName="Input";var Lb=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})]}),hi=forwardRef(({label:e,inline:t=false,size:r="md",labelColor:n,borderColor:o,textColor:a,disabled:s=false,readOnly:l=false,error:i=false,helperText:d,hideLabel:c=false,icon:p,iconPosition:f="left",mentionTrigger:m="@",suggestions:g=[],onMentionSearch:x,onMentionSelect:b,onMentionRemove:v,renderSuggestion:y,value:M,onChange:w,placeholder:P,loading:h=false,maxSuggestions:E=10,chipVariant:D="soft",chipColor:k="primary",chipSize:I="sm"},W)=>{let O=useId(),L=useRef(null),[T,S]=useState(false),[C,N]=useState(0),[R,$]=useState(""),H=u(go({size:r,error:i,disabled:s,readOnly:l,icon:p,iconPosition:f}),"min-h-[42px]","whitespace-pre-wrap","break-words"),K={...o&&{borderColor:o},...a&&{color:a}},_=o||a?K:void 0,F=useCallback(()=>{if(!L.current)return {text:"",mentions:[]};let z="",X=[],ne=0,re=q=>{if(q.nodeType===Node.TEXT_NODE)z+=q.textContent||"",ne+=(q.textContent||"").length;else if(q.nodeType===Node.ELEMENT_NODE){let de=q;if(de.hasAttribute("data-mention-id")){let xe=de.getAttribute("data-mention-id"),ke=de.getAttribute("data-mention-label")||"",le=de.getAttribute("data-mention-avatar")||void 0,Se=`@${ke}`,Me=ne;X.push({trigger:m,suggestion:{id:xe||"",label:ke,avatar:le},startIndex:Me,endIndex:Me+Se.length}),z+=Se,ne+=Se.length;}else de.childNodes.forEach(re);}};return L.current.childNodes.forEach(re),{text:z,mentions:X}},[m]),A=useCallback((z,X)=>{let ne=document.createElement("span");return ne.contentEditable="false",ne.setAttribute("data-mention-id",z.id),ne.setAttribute("data-mention-label",z.label),z.avatar&&ne.setAttribute("data-mention-avatar",z.avatar),ne.className="inline-block align-middle mx-0.5",ne.style.userSelect="none",createRoot(ne).render(jsx(Ba,{label:z.label,variant:D,color:k,size:I,closable:!s&&!l,onClose:X,disabled:s,avatar:z.avatar?jsx("img",{src:z.avatar,alt:z.label,className:"w-full h-full object-cover"}):void 0})),ne},[D,k,I,s,l]),B=useCallback(z=>{if(!L.current)return;let X=L.current.querySelector(`[data-mention-id="${z}"]`);if(X){X.remove();let ne=F();w?.(ne);let re=M?.mentions.find(q=>q.suggestion.id===z)?.suggestion;re&&v?.(re);}},[F,w,v,M?.mentions]),U=useCallback(()=>{if(!L.current)return;let z=window.getSelection();if(!z||z.rangeCount===0)return;let X=z.getRangeAt(0),ne="";X.startContainer.nodeType===Node.TEXT_NODE&&(ne=X.startContainer.textContent?.substring(0,X.startOffset)||"");let re=ne.match(new RegExp(`${m}(\\w*)$`));if(re){let de=re[1];$(de),S(true),N(0),x?.(de);}else S(false),$("");let q=F();w?.(q);},[m,x,w,F]),Q=useCallback(z=>{if(!L.current)return;let X=window.getSelection();if(!X||X.rangeCount===0)return;let ne=X.getRangeAt(0);if(ne.startContainer.nodeType===Node.TEXT_NODE){let q=ne.startContainer,de=q.textContent||"",xe=ne.startOffset,le=de.substring(0,xe).lastIndexOf(m);if(le!==-1){let Se=de.substring(0,le),Me=de.substring(xe),je=A(z,()=>{B(z.id);});if(Se?(q.textContent=Se,q.parentNode?.insertBefore(je,q.nextSibling)):(q.parentNode?.insertBefore(je,q),q.textContent="",q.textContent||q.remove()),Me){let ie=document.createTextNode(Me);je.parentNode?.insertBefore(ie,je.nextSibling);}let at=document.createTextNode(" ");je.parentNode?.insertBefore(at,je.nextSibling);let $e=document.createRange();$e.setStartAfter(at),$e.collapse(true),X.removeAllRanges(),X.addRange($e);}}S(false),$("");let re=F();w?.(re),b?.(z),L.current.focus();},[m,A,B,F,w,b]),J=useCallback(z=>{let X=g.slice(0,E);if(T&&X.length>0)switch(z.key){case "ArrowDown":z.preventDefault(),N(ne=>ne<X.length-1?ne+1:0);return;case "ArrowUp":z.preventDefault(),N(ne=>ne>0?ne-1:X.length-1);return;case "Enter":case "Tab":z.preventDefault(),X[C]&&Q(X[C]);return;case "Escape":z.preventDefault(),S(false);return}if(z.key==="Backspace"){let ne=window.getSelection();if(!ne||ne.rangeCount===0)return;let re=ne.getRangeAt(0);if(re.collapsed&&re.startOffset===0){let q=re.startContainer.previousSibling;if(q&&q.nodeType===Node.ELEMENT_NODE){let de=q;if(de.hasAttribute("data-mention-id")){z.preventDefault();let xe=de.getAttribute("data-mention-id");xe&&B(xe);return}}}if(re.collapsed&&re.startContainer.nodeType===Node.TEXT_NODE){let q=re.startContainer;if(re.startOffset===0){let de=q.previousSibling;if(de&&de.nodeType===Node.ELEMENT_NODE){let xe=de;if(xe.hasAttribute("data-mention-id")){z.preventDefault();let ke=xe.getAttribute("data-mention-id");ke&&B(ke);return}}}}}},[T,g,C,E,Q,B]);return useEffect(()=>{L.current&&(!(L.current.textContent||L.current.querySelector("[data-mention-id]"))&&P?L.current.setAttribute("data-placeholder",P):L.current.removeAttribute("data-placeholder"));},[P,M]),useEffect(()=>{L.current&&M?.text===""&&M?.mentions.length===0&&L.current.innerHTML.trim()&&(L.current.innerHTML="");},[M?.text,M?.mentions.length]),jsx(fo,{label:e,hideLabel:c,labelColor:n,error:i,helperText:d,inline:t,htmlFor:O,children:jsxs("div",{className:"relative w-full",children:[p&&jsx("span",{className:Wn(f),children:p}),jsx("div",{ref:z=>{typeof W=="function"?W(z):W&&(W.current=z),L.current=z;},id:O,contentEditable:!s&&!l,suppressContentEditableWarning:true,onInput:U,onKeyDown:J,className:u(H,"empty:before:content-[attr(data-placeholder)] empty:before:text-gray-400 empty:before:dark:text-gray-500"),style:_,role:"textbox","aria-label":e,"aria-multiline":"true",tabIndex:l||s?-1:0}),T&&g.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:h?jsx("div",{className:"px-3 py-2 text-sm text-gray-500 dark:text-gray-400",children:"Loading..."}):g.slice(0,E).map((z,X)=>jsx("div",{onClick:()=>Q(z),className:u(X===C&&"bg-gray-100 dark:bg-gray-600"),children:y?y(z):Lb(z)},z.id))})]})})});hi.displayName="MentionInput";var yi=forwardRef(({label:e,inline:t=false,size:r="md",labelColor:n,borderColor:o,textColor:a,disabled:s=false,readOnly:l=false,error:i=false,helperText:d,hideLabel:c=false,icon:p,iconPosition:f="left",className:m,value:g,onChange:x,format:b="number",currency:v="USD",locale:y="en-US",decimals:M,min:w,max:P,step:h=1,prefix:E,suffix:D,thousandSeparator:k=true,allowNegative:I=true,onBlur:W,onFocus:O,...L},T)=>{let S=useId(),[C,N]=useState(null),R=useMemo(()=>{let Y=b==="currency"?{style:"currency",currency:v,minimumFractionDigits:M??2,maximumFractionDigits:M??2}:b==="percentage"?{minimumFractionDigits:M??0,maximumFractionDigits:M??2}:{minimumFractionDigits:M??0,maximumFractionDigits:M??(b==="decimal"?2:0),useGrouping:k};try{return new Intl.NumberFormat(y,Y)}catch{return null}},[b,v,y,M,k]),$=Y=>{if(Y==null)return "";if(!R)return String(Y);let z=R.format(Y);return b==="percentage"?(z=E?`${E}${z}`:z,z=D||!z.includes("%")?`${z}%`:z,z):(E&&(z=`${E}${z}`),D&&(z=`${z}${D}`),z)},H=Y=>{if(!Y||Y.trim()==="")return null;let z=Y;if(E&&(z=z.replace(E,"")),D&&(z=z.replace(D,"")),z=z.replace(/[^\d.,-]/g,""),y.includes("fr")||y.includes("de")?z=z.replace(/\s/g,"").replace(",","."):z=z.replace(",",""),!z||z==="-"||z===".")return null;let X=parseFloat(z);return isNaN(X)?null:!I&&X<0?Math.abs(X):w!==void 0&&X<w?w:P!==void 0&&X>P?P:X},K=C??$(g??null),_=Y=>{let z=y.includes("fr")||y.includes("de")?",":".";return new RegExp(`^-?[0-9${z===","?",":"\\."}]*$`).test(Y)},F=Y=>{let z=Y.target.value;if(z===""||_(z)){N(z);let X=H(z);x&&x(X);}},A=Y=>{let z=y.includes("fr")||y.includes("de")?",":".",X=["Backspace","Delete","Tab","Escape","Enter","ArrowLeft","ArrowRight","ArrowUp","ArrowDown","Home","End"],ne=/^[0-9]$/.test(Y.key),re=Y.key===z,q=Y.key==="-"&&I&&K.indexOf("-")===-1,de=Y.ctrlKey||Y.metaKey;!ne&&!re&&!q&&!X.includes(Y.key)&&!de&&Y.preventDefault();},B=Y=>{let z=g!=null?String(g):"";N(z),O&&O(Y);},U=Y=>{let z=H(C??"");x&&z!==g&&x(z),N(null),W&&W(Y);},Q=u(go({size:r,error:i,disabled:s,readOnly:l,icon:p,iconPosition:f}),o&&`border-[${o}]`,a&&`text-[${a}]`,m),J=jsxs("div",{className:"relative",children:[p&&f==="left"&&jsx("div",{className:Wn(f),children:p}),jsx("input",{ref:T,id:S,type:"text",inputMode:"decimal",className:Q,style:{borderColor:o,color:a},disabled:s,readOnly:l,value:K,onChange:F,onKeyDown:A,onFocus:B,onBlur:U,...L}),p&&f==="right"&&jsx("div",{className:Wn(f),children:p})]});return jsx(fo,{label:e,hideLabel:c,labelColor:n,error:i,helperText:d,inline:t,htmlFor:S,children:J})});yi.displayName="NumberInput";function Vb({logo:e,logoHref:t="/",onLogoClick:r,navItems:n=[],actions:o,rightContent:a,variant:s="default",size:l="md",backgroundColor:i,textColor:d,hoverColor:c,navItemTextColor:p,navItemHoverColor:f,navItemBgHover:m,navItemActiveColor:g,sticky:x=false,fixed:b=false,showSearch:v=false,onSearch:y,searchPlaceholder:M="Search...",className:w,containerClassName:P}){let[h,E]=useState(false),[D,k]=useState(null),[I,W]=useState(""),O=()=>{E(!h);},L=F=>{k(D===F?null:F);},T=F=>{F.preventDefault(),y&&y(I);},S=u(x&&"sticky top-0 z-50",b&&"fixed top-0 left-0 right-0 z-50"),C=u(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"),N=u(l==="sm"&&"py-2",l==="md"&&"py-4",l==="lg"&&"py-6"),R=i||"",$=d||"",H=c||"",K=u(S,C,N,R,$,w),_=(F,A,B=false)=>{let U=F.children&&F.children.length>0,Q=D===A,J=u("px-4 py-2 transition-colors flex items-center gap-2",B?"block w-full text-left":"inline-flex",F.active&&"font-semibold border-b-2",F.active&&(g||"border-current"),p||(s==="default"||s==="transparent"?"text-gray-300":"text-gray-600 dark:text-gray-300"),f||H||(s==="default"||s==="transparent"?"hover:text-white":"hover:text-blue-600 dark:hover:text-blue-400"),m||"");if(U)return jsxs("div",{className:B?"w-full":"relative",children:[jsxs("button",{type:"button",onClick:()=>L(A),className:J,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:u("w-4 h-4 transition-transform",Q&&"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"})})]}),Q&&jsx("div",{className:u("bg-white shadow-lg rounded-lg overflow-hidden dark:bg-gray-800 dark:shadow-black/40",B?"mt-2 mb-2":"absolute top-full left-0 mt-1 min-w-[200px]"),children:F.children?.map(z=>jsx("a",{href:z.href,onClick:z.onClick,target:z.external?"_blank":void 0,rel:z.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:[z.icon&&jsx("span",{className:"w-5 h-5",children:z.icon}),jsx("span",{children:z.label}),z.badge&&jsx("span",{className:"bg-red-500 text-white text-xs px-2 py-0.5 rounded-full ml-auto",children:z.badge}),z.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"})})]})},z.href??z.label))})]},F.href??F.label);let Y=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:J,children:Y},F.href??F.label):jsx("a",{href:F.href,target:F.external?"_blank":void 0,rel:F.external?"noopener noreferrer":void 0,className:J,children:Y},F.href??F.label)};return jsxs("header",{className:K,children:[jsxs("nav",{className:u("container mx-auto flex items-center justify-between px-4",P),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})}),v&&jsx("form",{onSubmit:T,className:"hidden md:flex flex-1 max-w-md mx-8",children:jsx("input",{type:"search","aria-label":M,value:I,onChange:F=>W(F.target.value),placeholder:M,className:"w-full px-4 py-2 rounded-lg border border-gray-300 focus:outline-none focus:ring-2 focus:ring-blue-500 text-gray-900 dark:border-gray-700 dark:bg-gray-800 dark:text-gray-100 dark:placeholder-gray-500"})}),jsx("div",{className:"hidden md:flex items-center gap-2",children:n.map((F,A)=>_(F,A,false))}),(o||a)&&jsxs("div",{className:"hidden md:flex items-center gap-2 ml-4",children:[o,a]}),n.length>0&&jsx("div",{className:"md:hidden",children:jsx("button",{type:"button",className:u("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:O,"aria-label":"Toggle menu","aria-expanded":h,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"})})})})]}),h&&n.length>0&&jsx("div",{className:u("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:[v&&jsx("form",{onSubmit:T,className:"mb-4",children:jsx("input",{type:"search","aria-label":M,value:I,onChange:F=>W(F.target.value),placeholder:M,className:"w-full px-4 py-2 rounded-lg border border-gray-300 focus:outline-none focus:ring-2 focus:ring-blue-500 text-gray-900 dark:border-gray-700 dark:bg-gray-800 dark:text-gray-100 dark:placeholder-gray-500"})}),n.map((F,A)=>_(F,A,true)),(o||a)&&jsxs("div",{className:"flex flex-col gap-2 mt-4 pt-4 border-t border-gray-700",children:[o,a]})]})})]})}var Xb=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"})]}),Gb=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"})]}),Kb=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"})]}),Ub=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"})]}),Yb=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"})]}),jb={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"},qb={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"},Zb={sm:"w-56",md:"w-72",lg:"w-96",xl:"w-[32rem]"},Qb=[_b],Jb={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 mc({content:e,markdown:t=false,position:r="bottom",size:n="sm",className:o="",visible:a=true,editable:s=false,onSave:l,onReset:i,width:d="md",title:c,markdownEditor:p,markdownEditorUnavailableLabel:f}){let m=At(),[g,x]=useState(false),[b,v]=useState(false),[y,M]=useState(""),[w,P]=useState(false),[h,E]=useState(null),D=useRef(null),k=useRef(null),I=useRef(null),W=useRef(null);useEffect(()=>{if(!g)return;let N=$=>{D.current&&!D.current.contains($.target)&&k.current&&!k.current.contains($.target)&&(b||x(false));},R=$=>{$.key==="Escape"&&(b?(v(false),M("")):x(false));};return document.addEventListener("mousedown",N),document.addEventListener("keydown",R),()=>{document.removeEventListener("mousedown",N),document.removeEventListener("keydown",R);}},[g,b]),useEffect(()=>{b&&I.current&&I.current.focus();},[b]),useEffect(()=>()=>{W.current&&clearTimeout(W.current);},[]);let O=useCallback(()=>{M(typeof e=="string"?e:""),v(true),E(null);},[e]),L=useCallback(()=>{v(false),M(""),E(null);},[]),T=useCallback(async()=>{if(!l){E({type:"error",text:"Aucune fonction de sauvegarde fournie"});return}P(true);try{await l(y)?(E({type:"success",text:"Sauvegard\xE9 avec succ\xE8s !"}),v(!1),W.current&&clearTimeout(W.current),W.current=setTimeout(()=>E(null),2e3)):E({type:"error",text:"Erreur lors de la sauvegarde"});}catch{E({type:"error",text:"Erreur lors de la sauvegarde"});}finally{P(false);}},[y,l]),S=useCallback(async()=>{if(i&&confirm("\xCAtes-vous s\xFBr de vouloir r\xE9initialiser ce contenu ?")){P(true);try{await i()?(E({type:"success",text:"R\xE9initialis\xE9 avec succ\xE8s !"}),v(!1),W.current&&clearTimeout(W.current),W.current=setTimeout(()=>E(null),2e3)):E({type:"error",text:"Erreur lors de la r\xE9initialisation"});}catch{E({type:"error",text:"Erreur lors de la r\xE9initialisation"});}finally{P(false);}}},[i]),C=e;return a?jsxs("div",{className:"relative inline-flex items-center",children:[jsx("button",{type:"button",ref:D,onClick:()=>x(!g),className:`
|
|
3
|
+
${jb[n]}
|
|
4
4
|
inline-flex items-center justify-center
|
|
5
5
|
rounded-full border border-gray-300 dark:border-gray-600
|
|
6
6
|
bg-white dark:bg-gray-800
|
|
@@ -11,21 +11,21 @@ import*as Ns from'react';import Ns__default,{createContext,forwardRef,memo,useId
|
|
|
11
11
|
hover:border-gray-400 dark:hover:border-gray-500
|
|
12
12
|
transition-all duration-150
|
|
13
13
|
focus:outline-none focus:ring-2 focus:ring-blue-500/50
|
|
14
|
-
${
|
|
15
|
-
`,"aria-label":"Afficher l'aide","aria-expanded":
|
|
16
|
-
absolute z-50 ${
|
|
17
|
-
${
|
|
14
|
+
${o}
|
|
15
|
+
`,"aria-label":"Afficher l'aide","aria-expanded":g,children:jsx("span",{className:"font-medium",children:"?"})}),g&&jsxs("div",{ref:k,className:`
|
|
16
|
+
absolute z-50 ${qb[r]}
|
|
17
|
+
${Zb[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||s)&&jsxs("div",{className:"flex items-center justify-between px-4 py-2 border-b border-gray-200 dark:border-gray-700 bg-gray-50 dark:bg-gray-800/50",children:[jsx("div",{className:"flex items-center gap-2",children:u&&jsx("h3",{className:"text-sm font-semibold",children:u})}),s&&jsx("div",{className:"flex items-center gap-1",children:y?jsxs(Fragment,{children:[jsx("button",{type:"button",onClick:w,disabled:k,className:"p-1.5 rounded-md hover:bg-green-100 dark:hover:bg-green-900/30 text-green-600 dark:text-green-400 transition-colors disabled:opacity-50 cursor-pointer",title:"Sauvegarder",children:k?Zf:Yf}),jsx("button",{type:"button",onClick:M,className:"p-1.5 rounded-md hover:bg-gray-200 dark:hover:bg-gray-700 text-gray-500 hover:text-gray-700 dark:hover:text-gray-300 transition-colors cursor-pointer",title:"Annuler",children:jf}),i&&jsx("button",{type:"button",onClick:N,disabled:k,className:"p-1.5 rounded-md hover:bg-orange-100 dark:hover:bg-orange-900/30 text-orange-600 dark:text-orange-400 transition-colors disabled:opacity-50 cursor-pointer",title:"R\xE9initialiser",children:qf})]}):jsx("button",{type:"button",onClick:_,className:"p-1.5 rounded-md hover:bg-gray-200 dark:hover:bg-gray-700 text-gray-500 hover:text-gray-700 dark:hover:text-gray-300 transition-colors cursor-pointer",title:"Modifier",children:Uf})})]}),g&&jsx("div",{className:`px-4 py-2 text-xs ${g.type==="success"?"bg-green-50 dark:bg-green-900/20 text-green-600 dark:text-green-400":"bg-red-50 dark:bg-red-900/20 text-red-600 dark:text-red-400"}`,children:g.text}),jsx("div",{className:"flex-1 overflow-y-auto p-4",children:y?t?p?jsx(p,{value:v,onChange:E,placeholder:"\xC9crivez en Markdown..."}):jsx("p",{role:"alert",className:"p-3 text-sm text-gray-500 dark:text-gray-400",children:b??m.markdownEditorUnavailable}):jsx("div",{className:"space-y-2",children:jsx("textarea",{ref:W,"aria-label":"Contenu d'aide",value:v,onChange:S=>E(S.target.value),className:"w-full h-64 p-3 text-sm bg-gray-50 dark:bg-gray-800 border border-gray-200 dark:border-gray-700 rounded-lg resize-none focus:outline-none focus:ring-2 focus:ring-blue-500/50 text-gray-700 dark:text-gray-300 font-mono",placeholder:"\xC9crivez votre contenu d'aide..."})}):typeof x=="string"?jsx("div",{className:"prose prose-sm dark:prose-invert max-w-none",children:t?jsx(Xf,{remarkPlugins:tb,components:rb,children:x}):jsx("div",{dangerouslySetInnerHTML:{__html:Gf.sanitize(x)}})}):x})]})]}):null}function ob({children:e,content:t,markdown:r=false,position:o="bottom",size:n="sm",visible:a=true,editable:s=false,onSave:l,onReset:i,width:d="md",title:u,className:p,markdownEditor:b,markdownEditorUnavailableLabel:m}){return jsxs("div",{className:"inline-flex items-center gap-2.5",children:[e,jsx(Wd,{content:t,markdown:r,position:o,size:n,visible:a,editable:s,onSave:l,onReset:i,width:d,title:u,className:p,markdownEditor:b,markdownEditorUnavailableLabel:m})]})}var lb={"16/9":"aspect-[16/9]","4/3":"aspect-[4/3]","1/1":"aspect-square",auto:""},db=e=>new Promise((t,r)=>{let o=new FileReader;o.onload=n=>{let a=n.target?.result;t(a);},o.onerror=()=>{r(new Error("Erreur lors de la lecture du fichier"));},o.readAsDataURL(e);});function cb({value:e,onChange:t,onUpload:r,label:o="Image",maxSize:n=5*1024*1024,accept:a="image/*",helpText:s,disabled:l=false,className:i="",showUrlInput:d=true,urlPlaceholder:u="https://example.com/image.jpg",aspectRatio:p="16/9"}){let[b,m]=useState(false),[f,h]=useState(null),y=useRef(null),C=useId(),v=useMemo(()=>(n/(1024*1024)).toFixed(0),[n]),E=`Formats accept\xE9s : ${a==="image/*"?"JPG, PNG, GIF, WebP":a} (max ${v}MB)`,k=useCallback(async D=>{let W=D.target.files?.[0];if(W){if(!W.type.startsWith("image/")){h("Le fichier doit \xEAtre une image");return}if(W.size>n){h(`Le fichier est trop volumineux (max ${v}MB)`);return}m(true),h(null);try{if(r){let V=await r(W);t(V);}else {let V=await db(W);t(V);}y.current&&(y.current.value="");}catch(V){console.error("Upload error:",V),h(V instanceof Error?V.message:"Erreur lors de l'upload");}finally{m(false);}}},[n,v,t,r]),R=useCallback(()=>{t(""),y.current&&(y.current.value=""),h(null);},[t]),g=useCallback(D=>{t(D),h(null);},[t]),P=useCallback(()=>{y.current?.click();},[]),T=useCallback(D=>{g(D.target.value);},[g]);return jsxs("div",{className:`space-y-2 ${i}`,children:[o&&jsx("label",{className:"block text-sm font-semibold text-gray-700 dark:text-gray-300",children:o}),e&&jsxs("div",{className:"relative w-full overflow-hidden rounded-lg border border-gray-300 dark:border-gray-600 bg-gray-50 dark:bg-gray-800/50",children:[jsx("div",{className:`relative ${lb[p]} ${p==="auto"?"max-h-64":""} flex items-center justify-center`,children:jsx("img",{src:e,alt:"Aper\xE7u",className:"w-full h-full object-contain"})}),jsx("button",{type:"button",onClick:R,disabled:l,className:"absolute top-2 right-2 bg-red-500 text-white rounded-full w-6 h-6 flex items-center justify-center text-xs hover:bg-red-600 transition-colors cursor-pointer disabled:opacity-50 disabled:cursor-not-allowed",title:"Supprimer l'image",children:"\xD7"})]}),jsxs("div",{className:"flex gap-2",children:[jsx("input",{ref:y,type:"file","aria-label":"Choisir une image",accept:a,onChange:k,className:"hidden",disabled:l||b}),jsx("button",{type:"button",onClick:P,disabled:l||b,className:"px-3 py-2 text-sm border border-gray-300 dark:border-gray-600 rounded-md hover:bg-gray-50 dark:hover:bg-gray-700 disabled:opacity-50 disabled:cursor-not-allowed transition-colors cursor-pointer bg-white dark:bg-gray-800 text-gray-700 dark:text-gray-200",children:b?"\u23F3 Upload...":e?"\u{1F4C1} Changer l'image":"\u{1F4C1} Choisir une image"})]}),d&&jsxs("div",{className:"space-y-1",children:[jsx("label",{htmlFor:C,className:"block text-xs text-gray-500 dark:text-gray-400",children:"Ou URL directe :"}),jsx("input",{id:C,type:"url",value:e||"",onChange:T,placeholder:u,disabled:l,className:"w-full px-3 py-2 text-sm border border-gray-300 dark:border-gray-600 rounded-md focus:ring-2 focus:ring-blue-500 focus:border-blue-500 dark:bg-gray-800 dark:text-gray-200 disabled:opacity-50 disabled:cursor-not-allowed"})]}),f&&jsxs("div",{className:"text-red-600 dark:text-red-400 text-sm bg-red-50 dark:bg-red-900/20 p-2 rounded border border-red-200 dark:border-red-800",children:["\u274C ",f]}),jsx("div",{className:"text-xs text-gray-500 dark:text-gray-400",children:s||E})]})}var La={default:"bg-gray-400",primary:"bg-blue-600",success:"bg-green-500",warning:"bg-yellow-400",error:"bg-red-500",info:"bg-cyan-500",dark:"bg-gray-900 dark:bg-gray-700",purple:"bg-purple-600",indigo:"bg-indigo-600",teal:"bg-teal-500"},Ys={xs:"w-2 h-2",sm:"w-2.5 h-2.5",md:"w-3 h-3",lg:"w-3.5 h-3.5",xl:"w-4 h-4"},ub={xs:"min-w-4 h-4 text-[10px] px-1",sm:"min-w-5 h-5 text-xs px-1",md:"min-w-5 h-5 text-xs px-1.5",lg:"min-w-6 h-6 text-sm px-1.5",xl:"min-w-7 h-7 text-sm px-2"},js={"top-left":"top-0 left-0 -translate-x-1/2 -translate-y-1/2","top-center":"top-0 left-1/2 -translate-x-1/2 -translate-y-1/2","top-right":"top-0 right-0 translate-x-1/2 -translate-y-1/2","center-left":"top-1/2 left-0 -translate-x-1/2 -translate-y-1/2",center:"top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2","center-right":"top-1/2 right-0 translate-x-1/2 -translate-y-1/2","bottom-left":"bottom-0 left-0 -translate-x-1/2 translate-y-1/2","bottom-center":"bottom-0 left-1/2 -translate-x-1/2 translate-y-1/2","bottom-right":"bottom-0 right-0 translate-x-1/2 translate-y-1/2"},qs={"top-left":"top-0 left-0","top-center":"top-0 left-1/2 -translate-x-1/2","top-right":"top-0 right-0","center-left":"top-1/2 left-0 -translate-y-1/2",center:"top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2","center-right":"top-1/2 right-0 -translate-y-1/2","bottom-left":"bottom-0 left-0","bottom-center":"bottom-0 left-1/2 -translate-x-1/2","bottom-right":"bottom-0 right-0"};function pb(e,t){return e>t?`${t}+`:`${e}`}function gb({color:e="primary",size:t="md",placement:r="top-right",bordered:o=false,borderColor:n,pulse:a=false,offset:s=false,className:l,...i}){return jsx("span",{"data-testid":"indicator",className:c("absolute z-10 rounded-full",La[e],Ys[t],s?qs[r]:js[r],o&&c("ring-2 ring-white dark:ring-gray-900",n),a&&"animate-pulse",l),...i})}function mb({color:e="error",size:t="md",placement:r="top-right",count:o=0,maxCount:n=99,bordered:a=false,borderColor:s,pulse:l=false,offset:i=false,className:d,...u}){return jsx("span",{"data-testid":"indicator",className:c("absolute z-10 inline-flex items-center justify-center rounded-full font-semibold text-white",La[e],ub[t],i?qs[r]:js[r],a&&c("ring-2 ring-white dark:ring-gray-900",s),l&&"animate-pulse",d),...u,children:pb(o,n)})}function fb({color:e="success",size:t="md",placement:r="bottom-right",bordered:o=true,borderColor:n,pulse:a=false,offset:s=false,className:l,...i}){return jsx("span",{"data-testid":"indicator",className:c("absolute z-10 rounded-full",La[e],Ys[t],s?qs[r]:js[r],o&&c("ring-2 ring-white dark:ring-gray-900",n),a&&"animate-pulse",l),...i})}function bb({color:e="primary",size:t="sm",label:r,className:o,...n}){return jsxs("span",{"data-testid":"indicator",className:c("inline-flex items-center gap-2",o),...n,children:[jsx("span",{className:c("rounded-full shrink-0",La[e],Ys[t])}),r?jsx("span",{className:"text-sm text-gray-700 dark:text-gray-300",children:r}):null]})}function Fd({variant:e="dot",children:t,...r}){if(e==="legend")return jsx(bb,{...r});let o=(()=>{switch(e){case "count":return jsx(mb,{...r});case "status":return jsx(fb,{...r});default:return jsx(gb,{...r})}})();return t?jsxs("div",{className:"relative inline-flex",children:[t,o]}):o}Fd.displayName="Indicator";var hb={xs:"text-xs",sm:"text-sm",md:"text-sm",lg:"text-base",xl:"text-lg"},Vd={xs:"w-3 h-3",sm:"w-3.5 h-3.5",md:"w-4 h-4",lg:"w-4.5 h-4.5",xl:"w-5 h-5"},yb={normal:"font-normal",medium:"font-medium",semibold:"font-semibold",bold:"font-bold"},xb={default:{default:"text-gray-700 dark:text-gray-200",light:"text-gray-500 dark:text-gray-400",strong:"text-gray-900 dark:text-white"},primary:{default:"text-blue-600 dark:text-blue-400",light:"text-blue-400 dark:text-blue-300",strong:"text-blue-700 dark:text-blue-300"},secondary:{default:"text-purple-600 dark:text-purple-400",light:"text-purple-400 dark:text-purple-300",strong:"text-purple-700 dark:text-purple-300"},success:{default:"text-green-600 dark:text-green-400",light:"text-green-400 dark:text-green-300",strong:"text-green-700 dark:text-green-300"},warning:{default:"text-yellow-600 dark:text-yellow-400",light:"text-yellow-400 dark:text-yellow-300",strong:"text-yellow-700 dark:text-yellow-300"},error:{default:"text-red-600 dark:text-red-400",light:"text-red-400 dark:text-red-300",strong:"text-red-700 dark:text-red-300"},info:{default:"text-cyan-600 dark:text-cyan-400",light:"text-cyan-400 dark:text-cyan-300",strong:"text-cyan-700 dark:text-cyan-300"},muted:{default:"text-gray-500 dark:text-gray-400",light:"text-gray-400 dark:text-gray-500",strong:"text-gray-600 dark:text-gray-300"}};function $d({children:e,size:t="md",color:r="default",variant:o="default",weight:n="medium",textColor:a,required:s=false,requiredIndicator:l="*",optional:i=false,optionalText:d="(optional)",tooltip:u,icon:p,endIcon:b,disabled:m=false,truncate:f=false,as:h="label",className:y,...C}){let v=h,E=c("inline-flex items-center gap-1.5 transition-colors",hb[t],yb[n]),k=a||xb[r][o];return jsxs(v,{className:c(E,k,m?"opacity-50 cursor-not-allowed":"cursor-default",y),title:u,"aria-disabled":m,...C,children:[p&&jsx("span",{className:c("shrink-0",Vd[t]),children:p}),jsxs("span",{className:c(f&&"truncate"),children:[e,s&&jsx("span",{className:"text-red-500 ml-0.5","aria-hidden":"true",children:l}),s&&jsx("span",{className:"sr-only",children:"(required)"})]}),i&&!s&&jsx("span",{className:"text-gray-400 dark:text-gray-500 font-normal",children:d}),b&&jsx("span",{className:c("shrink-0",Vd[t]),children:b})]})}$d.displayName="Label";var kb=24,wb=10,Cb=10,Nb=memo(function({lines:t,showMarkers:r}){return jsx("g",{children:t.map(o=>jsxs("g",{children:[o.solid?jsx("path",{d:o.solid,fill:"none",stroke:o.color,strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"}):null,o.dashed?jsx("path",{d:o.dashed,fill:"none",stroke:o.color,strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round",strokeDasharray:"5 4"}):null,r?o.markers.map(n=>jsx("circle",{cx:n.x,cy:n.y,r:3,fill:o.color,strokeWidth:2,className:"stroke-white dark:stroke-gray-800"},`${n.x}-${n.y}`)):null]},o.key))})});function Sb({width:e,height:t,data:r,resolvedSeries:o,x:n,y:a,grid:s,size:l,curve:i,forecastFrom:d,forecastLabel:u,markers:p,connectNulls:b,referenceLines:m,margin:f,tooltip:h,onPointClick:y,plotLabel:C,formatValue:v,formatX:E}){let[k,R]=useState(null),g=useMemo(()=>{let w=o.filter(Z=>!Z.hidden),N=to({width:e,height:t,data:r,x:n,y:a,bounds:Xt(Fr(r,w.map(Z=>Z.key))),margin:f,placement:"point",formatValue:v,formatX:E,extraTop:u?wb:0}),x=N.categoryCenters,S=N.valueScale,I=d===void 0?-1:N.xValues.findIndex(Z=>eo(Z)===eo(d)),F=w.map(Z=>{let U=r.map(($,K)=>{let se=St($,Z.key);return {x:x[K],y:se===null?Number.NaN:S(se),defined:se!==null}}),H={connectNulls:b},z=I>=0;return {key:Z.key,color:Z.color,solid:Z.dashed?"":Vr(z?U.slice(0,I+1):U,i,H),dashed:Z.dashed?Vr(U,i,H):z?Vr(U.slice(I),i,H):"",markers:U.filter($=>$.defined!==false)}}),O=r.length>1?N.innerWidth/(r.length-1):0;return {visible:w,xValues:N.xValues,xPositions:x,xTicks:N.categoryTicks,yTicks:N.valueTicks,yScale:S,innerWidth:N.innerWidth,innerHeight:N.innerHeight,margin:N.margin,lines:F,forecastIndex:I,showMarkers:p==="always"||p==="auto"&&O>=kb&&r.length>1}},[r,o,n,a,e,t,f,i,b,d,u,p,v,E]),P=useCallback(w=>g.visible.map(N=>{let x=St(r[w],N.key);return {seriesKey:N.key,seriesLabel:Lt(N),color:N.color,value:x,formattedValue:x===null?"\u2014":v(x),datum:r[w]}}),[r,g.visible,v]),T=useCallback(w=>{if(h===false||r.length===0)return;let N=w.currentTarget.getBoundingClientRect(),x=w.clientX-N.left-g.margin.left,S=Vo(g.xPositions,x);R(S>=0?S:null);},[h,r.length,g.margin.left,g.xPositions]),D=useCallback(w=>{if(r.length===0)return;let N=r.length-1,x=k??0,S=w.key==="ArrowRight"?Math.min(N,x+1):w.key==="ArrowLeft"?Math.max(0,x-1):w.key==="Home"?0:w.key==="End"?N:w.key==="Escape"?null:void 0;S!==void 0&&(w.preventDefault(),R(S));},[r.length,k]),W=useCallback(()=>{if(!y||k===null)return;let[w]=P(k);w&&y({...w,index:k,x:g.xValues[k]});},[y,k,P,g.xValues]),V=k===null?null:P(k),_=(V??[]).filter(w=>w.value!==null),M=k===null||V===null?null:{x:g.xValues[k],xLabel:E(g.xValues[k],k),index:k,points:V};return jsxs(Fragment,{children:[jsxs("svg",{width:e,height:t,role:"img","aria-label":C??g.visible.map(w=>Lt(w)).join(", "),tabIndex:0,className:"touch-none focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-blue-500",onPointerMove:T,onPointerLeave:()=>R(null),onKeyDown:D,onBlur:()=>R(null),onClick:W,children:[jsxs("g",{transform:`translate(${g.margin.left}, ${g.margin.top})`,children:[jsx(Wr,{width:g.innerWidth,height:g.innerHeight,horizontal:s==="y"||s==="both"?g.yTicks.map(w=>w.offset):void 0,vertical:s==="x"||s==="both"?g.xTicks.map(w=>w.offset):void 0}),m?.map(w=>{let N=g.yScale(w.value),x=N<Cb?N+12:N-4;return jsxs("g",{children:[jsx("line",{x1:0,y1:N,x2:g.innerWidth,y2:N,stroke:w.color??"var(--color-chart-muted)",strokeWidth:1,strokeDasharray:w.dashed===false?void 0:"4 4"}),w.label?jsx("text",{x:g.innerWidth,y:x,textAnchor:"end",className:"fill-gray-500 text-[10px] dark:fill-gray-400",children:w.label}):null]},`${w.value}-${w.label??""}`)}),g.forecastIndex>=0?jsxs("g",{children:[jsx("line",{x1:g.xPositions[g.forecastIndex],y1:0,x2:g.xPositions[g.forecastIndex],y2:g.innerHeight,className:"stroke-gray-300 dark:stroke-gray-600",strokeWidth:1,strokeDasharray:"3 3"}),u?jsx("text",{x:g.xPositions[g.forecastIndex]+4,y:-2,className:"fill-gray-500 text-[10px] dark:fill-gray-400",children:u}):null]}):null,jsx(Nb,{lines:g.lines,showMarkers:g.showMarkers}),k!==null?jsxs("g",{"aria-hidden":"true",children:[jsx("line",{x1:g.xPositions[k],y1:0,x2:g.xPositions[k],y2:g.innerHeight,className:"stroke-gray-400 dark:stroke-gray-500",strokeWidth:1}),_.map(w=>jsx("circle",{cx:g.xPositions[k],cy:g.yScale(w.value),r:4,fill:w.color,strokeWidth:2,className:"stroke-white dark:stroke-gray-800"},w.seriesKey))]}):null]}),jsx("g",{transform:`translate(${g.margin.left}, ${g.margin.top+g.innerHeight})`,children:n.hidden?null:jsx(Ut,{orientation:"bottom",ticks:g.xTicks,length:g.innerWidth,label:n.label,size:l})}),jsx("g",{transform:`translate(${g.margin.left}, ${g.margin.top})`,children:a?.hidden?null:jsx(Ut,{orientation:"left",ticks:g.yTicks,length:g.innerHeight,showLine:false,label:a?.label,size:l})})]}),M&&h!==false?jsx(ur,{x:g.margin.left+g.xPositions[M.index],y:g.margin.top+(_.length>0?Math.min(..._.map(w=>g.yScale(w.value))):g.innerHeight/2),containerWidth:e,children:typeof h=="function"?h(M):jsx(pr,{title:M.xLabel,points:M.points})}):null]})}function Rb({data:e,series:t,x:r,y:o,height:n=240,width:a,size:s="md",grid:l="y",legend:i,tooltip:d=true,tableView:u=false,emphasis:p,title:b,description:m,loading:f=false,emptyState:h,onPointClick:y,curve:C="monotone",forecastFrom:v,forecastLabel:E,markers:k="auto",connectNulls:R=false,referenceLines:g,legendToggle:P=true,margin:T,locale:D,plotLabel:W,className:V,..._}){let[M,w]=useState(()=>new Set),N=useMemo(()=>t.map((U,H)=>({...U,hidden:U.hidden||M.has(U.key),color:Cr(U,H,p)})),[t,M,p]),x=useMemo(()=>o?.format??(U=>_t(U,D)),[o?.format,D]),S=useMemo(()=>r.format??(U=>r.scale==="time"?Gt(U instanceof Date?U:new Date(Nr(U)),D):Gt(U,D)),[r.format,r.scale,D]),I=useCallback(U=>{w(H=>{let z=new Set(H);return z.has(U)?z.delete(U):z.add(U),z});},[]),F=i===void 0?t.length>=2:i!==false,O=typeof i=="string"?i:"bottom",Z=N.filter(U=>!U.hidden).length;return jsx(lr,{title:b,description:m,height:n,width:a,size:s,loading:f,empty:e.length===0||Z===0,emptyState:h,tableView:u,legendPosition:O,legend:F?jsx(dr,{items:Hr(N,p),position:O,marker:"line",size:s,onToggle:P?I:void 0}):void 0,table:u?jsx(cr,{data:e,series:N,xKey:r.key,xLabel:r.label??r.key,formatX:S,formatValue:x,caption:typeof b=="string"?b:void 0}):void 0,className:V,..._,children:({width:U})=>jsx(Sb,{width:U,height:n,data:e,resolvedSeries:N,x:r,y:o,grid:l,size:s,curve:C,forecastFrom:v,forecastLabel:E,markers:k,connectNulls:R,referenceLines:g,margin:T,tooltip:d,onPointClick:y,plotLabel:W,formatValue:x,formatX:S})})}var Ib={sm:"max-w-sm",md:"max-w-2xl",lg:"max-w-4xl",xl:"max-w-6xl",full:"max-w-full"},Yr=forwardRef(({isOpen:e,onClose:t,title:r="Modal Title",children:o,buttonLabel:n,onButtonClick:a,className:s,allowFullScreen:l=false,showSubmit:i=true,submitLabel:d,onSubmitClick:u,showCancel:p=false,cancelLabel:b,onCancelClick:m,buttonsPosition:f="right",showHeaderDivider:h=true,showFooterDivider:y=true,description:C,icon:v,size:E="md",reverseButtons:k=false,headerClassName:R,contentClassName:g,footerClassName:P,titleClassName:T,descriptionClassName:D,submitClassName:W,cancelClassName:V,closeLabel:_,enterFullScreenLabel:M,exitFullScreenLabel:w,"aria-label":N,closeOnEscape:x=true,trapFocus:S=true,initialFocus:I,returnFocus:F,lockScroll:O=true},Z)=>{let[U,H]=useState(false),z=Ft(),$=useId(),K=`${$}-title`,se=`${$}-description`,{dialogRef:X,dialogProps:ee}=So({open:e,onClose:t,closeOnEscape:x,trapFocus:S,initialFocus:I,returnFocus:F,lockScroll:O});if(!e)return null;let L=n??d??z.confirm,q=b??z.cancel,ge=_??z.closeModal,de=U?w??z.exitFullScreen:M??z.enterFullScreen,Y=a??u,le=async()=>{Y&&await Y(),t();},xe=async()=>{m&&await m(),t();};return jsx("div",{className:c("overflow-y-auto overflow-x-hidden fixed inset-0 z-50 flex items-center justify-center bg-black/30 backdrop-blur-sm",s),"aria-hidden":!e,children:jsx("div",{className:c("relative p-4 w-full max-h-full transition-all duration-300",U?"max-w-full h-full p-0":Ib[E]),ref:Z,children:jsxs("div",{...ee,ref:X,"aria-labelledby":r?K:void 0,"aria-label":r?void 0:N,"aria-describedby":C?se:void 0,className:c("relative bg-white shadow dark:bg-gray-700 border-b-4 transition-all duration-300 focus:outline-none",U?"rounded-none h-full flex flex-col":"rounded-lg"),children:[jsxs("div",{className:c("flex items-center justify-between p-4 md:p-5 rounded-t",h&&"border-b border-gray-200 dark:border-gray-600",R),children:[jsxs("div",{className:"flex items-center gap-3",children:[v&&jsx("div",{className:"shrink-0 text-gray-500 dark:text-gray-400",children:v}),jsxs("div",{children:[jsx("h3",{id:K,className:c("text-xl font-semibold text-gray-900 dark:text-white",T),children:r}),C&&jsx("p",{id:se,className:c("mt-1 text-sm text-gray-500 dark:text-gray-400",D),children:C})]})]}),jsxs("div",{className:"flex items-center gap-1 ms-auto",children:[l&&jsx("button",{type:"button",onClick:()=>H(Se=>!Se),className:"text-gray-400 bg-transparent hover:bg-gray-200 hover:text-gray-900 rounded-lg text-sm w-8 h-8 inline-flex justify-center items-center dark:hover:bg-gray-600 dark:hover:text-white","aria-label":de,children:U?jsx("svg",{className:"w-3.5 h-3.5","aria-hidden":"true",xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 18 18",children:jsx("path",{stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",d:"M7 1H1v6m16 0V1h-6m0 16h6v-6M1 11v6h6"})}):jsx("svg",{className:"w-3.5 h-3.5","aria-hidden":"true",xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 18 18",children:jsx("path",{stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",d:"M11 1h6v6M1 11v6h6m0-12L1 1m16 16-6-6"})})}),jsxs("button",{type:"button",onClick:t,className:"text-gray-400 bg-transparent hover:bg-gray-200 hover:text-gray-900 rounded-lg text-sm w-8 h-8 inline-flex justify-center items-center dark:hover:bg-gray-600 dark:hover:text-white",children:[jsx("svg",{className:"w-3 h-3","aria-hidden":"true",xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 14 14",children:jsx("path",{stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",d:"m1 1 6 6m0 0 6 6M7 7l6-6M7 7l-6 6"})}),jsx("span",{className:"sr-only",children:ge})]})]})]}),jsx("div",{className:c("p-4 md:p-5 space-y-4",U&&"flex-1 overflow-y-auto",g),children:o}),(i||p)&&jsxs("div",{className:c("flex items-center gap-2 p-4 md:p-5 rounded-b",y&&"border-t border-gray-200 dark:border-gray-600",f==="right"?"justify-end":f==="center"?"justify-center":"justify-start",k&&"flex-row-reverse",P),children:[p&&jsx("button",{type:"button",onClick:xe,className:c("text-gray-500 bg-white hover:bg-gray-100 focus:ring-4 focus:outline-none focus:ring-gray-200 font-medium rounded-lg text-sm px-5 py-2.5 border border-gray-200 dark:bg-gray-700 dark:text-gray-300 dark:border-gray-500 dark:hover:bg-gray-600 dark:hover:text-white",V),children:q}),i&&jsx("button",{type:"button",onClick:le,className:c("text-white bg-blue-600 hover:bg-blue-700 focus:ring-4 focus:outline-none focus:ring-blue-300 font-medium rounded-lg text-sm px-5 py-2.5 text-center dark:bg-blue-500 dark:hover:bg-blue-600",W),children:L})]})]})})})});Yr.displayName="Modal";function Ab(e,t,r,o){let n=r*2+1+o*2+2;if(t<=n)return Array.from({length:t},(b,m)=>m+1);let a=Array.from({length:o},(b,m)=>m+1).filter(b=>b<=t),s=Array.from({length:o},(b,m)=>t-o+1+m).filter(b=>b>=1),l=Math.max(e-r,o+1),i=Math.min(e+r,t-o),d=l>o+2,u=i<t-o-1,p=[];for(let b of a)p.push(b);if(d)p.push("ellipsis");else for(let b=o+1;b<l;b++)p.push(b);for(let b=l;b<=i;b++)p.push(b);if(u)p.push("ellipsis");else for(let b=i+1;b<=t-o;b++)p.push(b);for(let b of s)p.includes(b)||p.push(b);return p}function zb({className:e}){return jsx("svg",{className:e,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24","aria-hidden":"true",children:jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M15 19l-7-7 7-7"})})}function Wb({className:e}){return jsx("svg",{className:e,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24","aria-hidden":"true",children:jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 5l7 7-7 7"})})}function Hb({className:e}){return jsx("svg",{className:e,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24","aria-hidden":"true",children:jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M11 19l-7-7 7-7M18 19l-7-7 7-7"})})}function Fb({className:e}){return jsx("svg",{className:e,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24","aria-hidden":"true",children:jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M13 5l7 7-7 7M6 5l7 7-7 7"})})}var Bb={sm:{button:"h-7 min-w-7 px-1.5 text-xs",icon:"h-3 w-3",gap:"gap-0.5",text:"text-xs"},md:{button:"h-9 min-w-9 px-2.5 text-sm",icon:"h-4 w-4",gap:"gap-1",text:"text-sm"},lg:{button:"h-11 min-w-11 px-3.5 text-base",icon:"h-5 w-5",gap:"gap-1.5",text:"text-base"}},Vb={default:{base:"rounded-md font-medium transition-colors",idle:"text-gray-700 hover:bg-gray-100 dark:text-gray-300 dark:hover:bg-gray-700",active:"bg-blue-600 text-white hover:bg-blue-700 dark:bg-blue-500 dark:hover:bg-blue-600",disabled:"text-gray-300 cursor-not-allowed dark:text-gray-600"},outlined:{base:"rounded-md border font-medium transition-colors",idle:"border-gray-300 text-gray-700 hover:bg-gray-50 dark:border-gray-600 dark:text-gray-300 dark:hover:bg-gray-800",active:"border-blue-600 bg-blue-50 text-blue-600 hover:bg-blue-100 dark:border-blue-400 dark:bg-blue-900/30 dark:text-blue-400 dark:hover:bg-blue-900/50",disabled:"border-gray-200 text-gray-300 cursor-not-allowed dark:border-gray-700 dark:text-gray-600"},minimal:{base:"rounded-md font-medium transition-colors",idle:"text-gray-600 hover:text-gray-900 dark:text-gray-400 dark:hover:text-gray-200",active:"text-blue-600 font-semibold hover:text-blue-700 dark:text-blue-400 dark:hover:text-blue-300",disabled:"text-gray-300 cursor-not-allowed dark:text-gray-600"}};function Ob({page:e,totalPages:t,onPageChange:r,size:o="md",variant:n="default",showFirstLast:a=false,siblings:s=1,boundaries:l=1,disabled:i=false,labels:d,totalItems:u,pageSize:p,pageSizeOptions:b,onPageSizeChange:m,className:f,...h}){let y=Bb[o],C=Vb[n],v=useMemo(()=>Ab(e,t,s,l),[e,t,s,l]),E=useCallback(W=>{i||W<1||W>t||W===e||r(W);},[i,t,e,r]),k=e<=1,R=e>=t,g=c("inline-flex items-center justify-center select-none",y.button,C.base),P=(W,V,_,M)=>jsx("button",{type:"button",onClick:W,disabled:i||V,"aria-label":_,"aria-disabled":i||V,className:c(g,i||V?C.disabled:C.idle),children:M}),T=u!==void 0&&p?(e-1)*p+1:void 0,D=u!==void 0&&p?Math.min(e*p,u):void 0;return jsxs("nav",{"aria-label":"Pagination",className:c("flex items-center",y.gap,f),...h,children:[u!==void 0&&p&&jsxs("span",{className:c("mr-2 text-gray-600 dark:text-gray-400 whitespace-nowrap",y.text),children:[T,"\u2013",D," of ",u]}),b&&b.length>0&&m&&jsxs("div",{className:c("mr-2 flex items-center whitespace-nowrap",y.gap,y.text),children:[jsx("label",{htmlFor:"pagination-page-size",className:"text-gray-600 dark:text-gray-400",children:"Rows:"}),jsx("select",{id:"pagination-page-size",value:p,onChange:W=>m(Number(W.target.value)),disabled:i,className:c("rounded border border-gray-300 bg-white px-1.5 py-0.5 dark:border-gray-600 dark:bg-gray-800 dark:text-gray-200",y.text,i&&"cursor-not-allowed opacity-50"),children:b.map(W=>jsx("option",{value:W,children:W},W))})]}),jsxs("div",{className:c("flex items-center",y.gap),children:[a&&P(()=>E(1),k,d?.first??"Go to first page",jsx(Hb,{className:y.icon})),P(()=>E(e-1),k,d?.previous??"Go to previous page",jsx(zb,{className:y.icon})),v.map((W,V)=>W==="ellipsis"?jsx("span",{className:c("inline-flex items-center justify-center select-none",y.button,"text-gray-400 dark:text-gray-500"),"aria-hidden":"true",children:"\u2026"},`ellipsis-${V}`):jsx("button",{type:"button",onClick:()=>E(W),disabled:i,"aria-current":W===e?"page":void 0,"aria-label":`Page ${W}`,className:c(g,W===e?C.active:i?C.disabled:C.idle),children:W},W)),P(()=>E(e+1),R,d?.next??"Go to next page",jsx(Wb,{className:y.icon})),a&&P(()=>E(t),R,d?.last??"Go to last page",jsx(Fb,{className:y.icon}))]})]})}var _b=.62,Gb=2,Xb=3,Kb=.16,Ub=64,Yb=22,Zs=6,Gd=false;function jb({width:e,height:t,slices:r,variant:o,innerRadius:n,showLabels:a,centerLabel:s,tooltip:l,plotLabel:i,formatValue:d,onSliceClick:u}){let[p,b]=useState(null),m=useMemo(()=>{let g=a?Ub:8,P=a?Yb:8,T=Math.max(0,Math.min((e-g*2)/2,(t-P*2)/2));return {cx:e/2,cy:t/2,outerRadius:T,inner:o==="donut"?T*(n??_b):(n??0)*T,pad:T>0&&r.length>1?Gb/T/2:0}},[e,t,o,n,a,r.length]),{cx:f,cy:h,outerRadius:y,inner:C,pad:v}=m,E=useCallback(g=>{let P=(g.startAngle+g.endAngle)/2,T=Math.sin(P)>=0,D={x:f+Math.sin(P)*(y+4),y:h-Math.cos(P)*(y+4)},W={x:f+Math.sin(P)*(y+14),y:h-Math.cos(P)*(y+14)},V={x:T?W.x+10:W.x-10,y:W.y};return {from:D,elbow:W,end:V,anchor:T?"start":"end"}},[f,h,y]),k=useCallback(g=>{if(r.length===0)return;let P=r.length-1,T=p??0,D=g.key==="ArrowRight"||g.key==="ArrowDown"?Math.min(P,T+1):g.key==="ArrowLeft"||g.key==="ArrowUp"?Math.max(0,T-1):g.key==="Home"?0:g.key==="End"?P:g.key==="Escape"?null:void 0;D!==void 0&&(g.preventDefault(),b(D));},[r.length,p]),R=p===null?null:r[p];return jsxs(Fragment,{children:[jsxs("svg",{width:e,height:t,role:"img","aria-label":i??r.map(g=>g.label).join(", "),tabIndex:0,className:"touch-none focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-blue-500",onPointerLeave:()=>b(null),onBlur:()=>b(null),onKeyDown:k,children:[r.map((g,P)=>jsx("path",{d:ul({cx:f,cy:h,innerRadius:C,outerRadius:y+(p===P?Xb:0),startAngle:g.startAngle+v,endAngle:Math.max(g.startAngle+v,g.endAngle-v)}),fill:g.color,onPointerEnter:()=>l===false?void 0:b(P),onClick:()=>u?.({key:g.key,label:g.label,value:g.value,share:g.share})},g.key)),a?r.filter(g=>g.endAngle-g.startAngle>=Kb).map(g=>{let{from:P,elbow:T,end:D,anchor:W}=E(g);return jsxs("g",{"aria-hidden":"true",children:[jsx("polyline",{points:`${P.x},${P.y} ${T.x},${T.y} ${D.x},${D.y}`,fill:"none",className:"stroke-gray-300 dark:stroke-gray-600",strokeWidth:1}),jsx("text",{x:W==="start"?D.x+3:D.x-3,y:D.y,textAnchor:W,dominantBaseline:"middle",className:"fill-gray-600 text-[10px] dark:fill-gray-300",children:g.label})]},`label-${g.key}`)}):null,o==="donut"&&s?jsxs("g",{"aria-hidden":"true",children:[jsx("text",{x:f,y:h-(s.label?2:0),textAnchor:"middle",dominantBaseline:"middle",className:"fill-gray-900 text-lg font-semibold dark:fill-gray-100",children:s.value}),s.label?jsx("text",{x:f,y:h+14,textAnchor:"middle",dominantBaseline:"middle",className:"fill-gray-500 text-[10px] dark:fill-gray-400",children:s.label}):null]}):null]}),R&&l!==false?jsx(ur,{x:f+Math.sin((R.startAngle+R.endAngle)/2)*(y*.7),y:h-Math.cos((R.startAngle+R.endAngle)/2)*(y*.7),containerWidth:e,children:typeof l=="function"?l({seriesKey:R.key,seriesLabel:R.label,color:R.color,value:R.value,formattedValue:d(R.value),datum:{},share:R.share}):jsx(pr,{title:R.label,points:[{seriesKey:R.key,seriesLabel:Br(R.share),color:R.color,value:R.value,formattedValue:d(R.value),datum:{}}]})}):null]})}function qb({data:e,x:t,value:r,variant:o="pie",innerRadius:n,maxSlices:a=Zs,otherLabel:s,sort:l="desc",showLabels:i=true,centerLabel:d,height:u=260,width:p,size:b="md",legend:m,tooltip:f=true,tableView:h=false,title:y,description:C,loading:v=false,emptyState:E,locale:k,plotLabel:R,onSliceClick:g,className:P,...T}){let D=Ft(),W=useCallback(S=>_t(S,k),[k]),V=useCallback(S=>t.format?t.format(S,0):Gt(S,k),[t,k]),{slices:_,total:M,rows:w}=useMemo(()=>{let S=e.map((z,$)=>({key:String(bo(z,t.key,$)),label:V(bo(z,t.key,$)),value:St(z,r)??0,color:la($),datum:z})),I=l==="none"?S:[...S].sort((z,$)=>l==="asc"?z.value-$.value:$.value-z.value),F=I.slice(0,a),O=I.slice(a);O.length>0&&F.push({key:"__other__",label:s??D.chartOther,value:O.reduce((z,$)=>z+$.value,0),color:xn,datum:{}}),F.length>Zs&&!Gd&&(Gd=true,console.warn(`[@synertech/ui] A PieChart is drawing ${F.length} slices. Past ${Zs} the slices stop being tellable apart: lower \`maxSlices\`, or use a BarChart, which compares lengths rather than angles.`));let Z=F.reduce((z,$)=>z+Math.max(0,$.value),0),U=0;return {slices:F.map(z=>{let $=Z===0?0:Math.max(0,z.value)/Z,K=U;return U+=$*Math.PI*2,{...z,share:$,startAngle:K,endAngle:U}}),total:Z,rows:F.map(z=>({[t.key]:z.label,[r]:z.value}))}},[e,t.key,r,l,a,s,D.chartOther,V]),N=m===void 0?true:m!==false,x=typeof m=="string"?m:"bottom";return jsx(lr,{title:y,description:C,height:u,width:p,size:b,loading:v,empty:_.length===0||M===0,emptyState:E,tableView:h,legendPosition:x,legend:N?jsx(dr,{items:_.map(S=>({key:S.key,label:`${S.label} \xB7 ${Br(S.share)}`,color:S.color})),position:x,marker:"rect",size:b}):void 0,table:h?jsx(cr,{data:w,series:[{key:r,label:t.label??r}],xKey:t.key,xLabel:t.label??t.key,formatValue:W,caption:typeof y=="string"?y:void 0}):void 0,className:P,...T,children:({width:S})=>jsx(jb,{width:S,height:u,slices:_,variant:o,innerRadius:n,showLabels:i,centerLabel:d,tooltip:f,plotLabel:R,formatValue:W,onSliceClick:g})})}var Jb={xs:"h-1",sm:"h-1.5",md:"h-2.5",lg:"h-4",xl:"h-6"},Qb={default:"bg-gray-500 dark:bg-gray-400",primary:"bg-blue-600 dark:bg-blue-500",success:"bg-green-600 dark:bg-green-500",warning:"bg-yellow-500 dark:bg-yellow-400",error:"bg-red-600 dark:bg-red-500",info:"bg-cyan-600 dark:bg-cyan-500"},eh={default:"text-gray-700 dark:text-gray-300",primary:"text-blue-600 dark:text-blue-400",success:"text-green-600 dark:text-green-400",warning:"text-yellow-600 dark:text-yellow-400",error:"text-red-600 dark:text-red-400",info:"text-cyan-600 dark:text-cyan-400"},Kd="bg-[repeating-linear-gradient(45deg,transparent,transparent_10px,rgba(255,255,255,0.2)_10px,rgba(255,255,255,0.2)_20px)]",th={default:"bg-gradient-to-r from-gray-400 to-gray-600",primary:"bg-gradient-to-r from-blue-400 to-blue-700",success:"bg-gradient-to-r from-green-400 to-green-700",warning:"bg-gradient-to-r from-yellow-300 to-yellow-600",error:"bg-gradient-to-r from-red-400 to-red-700",info:"bg-gradient-to-r from-cyan-400 to-cyan-700"};function Yd({value:e=0,indeterminate:t=false,size:r="md",color:o="primary",variant:n="default",showValue:a=false,valueFormat:s,label:l,animated:i=true,className:d,...u}){let p=Math.min(100,Math.max(0,e)),b=n==="gradient"?th[o]:Qb[o],m=s?s(p):`${Math.round(p)}%`;return jsxs("div",{className:c("w-full",d),...u,children:[(l||a)&&jsxs("div",{className:"flex items-center justify-between mb-1",children:[l&&jsx("span",{className:"text-sm font-medium text-gray-700 dark:text-gray-300",children:l}),a&&!t&&jsx("span",{className:c("text-sm font-semibold",eh[o],!l&&"ml-auto"),children:m})]}),jsx("div",{role:"progressbar","aria-valuenow":t?void 0:p,"aria-valuemin":0,"aria-valuemax":100,"aria-label":l,className:c("relative w-full overflow-hidden rounded-full bg-gray-200 dark:bg-gray-700",Jb[r]),children:t?jsx("div",{className:c("absolute h-full w-1/3 rounded-full",b,n==="striped"&&Kd,"animate-[progress-indeterminate_1.5s_ease-in-out_infinite]")}):jsx("div",{className:c("h-full rounded-full",b,n==="striped"&&Kd,i&&"transition-[width] duration-300 ease-out"),style:{width:`${p}%`}})})]})}Yd.displayName="ProgressBar";var ah=e=>({sm:"w-4 h-4",md:"w-5 h-5",lg:"w-6 h-6"})[e],sh=e=>({sm:"w-2 h-2",md:"w-2.5 h-2.5",lg:"w-3 h-3"})[e],ih=(e,t,r,o,n,a,s,l)=>{if(t)return c("border-2",o?"":"border-red-500",r&&!n?"bg-red-500":"");switch(e){case "filled":return c("border-2",l?"":"border-gray-300 dark:border-gray-600",r?a?"":"bg-blue-600 border-blue-600 dark:bg-blue-500 dark:border-blue-500":s?"":"bg-gray-200 border-gray-200 dark:bg-gray-700 dark:border-gray-700");case "outlined":return c("border-[3px]",l?"":r?"border-blue-600 dark:border-blue-500":"border-gray-300 dark:border-gray-600","bg-white dark:bg-gray-800");default:return c("border-2",l?"":r?"border-blue-600 dark:border-blue-500":"border-gray-300 dark:border-gray-600","bg-white dark:bg-gray-800")}},lh={},jd=forwardRef(({label:e,description:t,value:r,checked:o,defaultChecked:n=false,onCheckedChange:a,size:s="md",variant:l="default",labelPosition:i="right",error:d=false,disabled:u=false,readOnly:p=false,required:b=false,checkedColor:m,uncheckedColor:f,borderColor:h,labelColor:y,errorColor:C,dotColor:v,hoverColor:E,focusRingColor:k,showFocusRing:R=true,className:g,containerClassName:P,...T},D)=>{let[W,V]=useState(n),_=o!==void 0,M=_?o:W,w=useId(),N=typeof d=="string"?d:void 0,x=!!d,S=se=>{if(u||p)return;let X=se.target.checked;_||V(X),a?.(X);},I=useMemo(()=>ih(l,x,M,C,v,m,f,h),[l,x,M,C,v,m,f,h]),F=useMemo(()=>{let se={};return m&&M&&(se.backgroundColor=m,se.borderColor=m),f&&!M&&(se.backgroundColor=f),h&&(se.borderColor=h),se},[m,f,h,M]),O=useMemo(()=>v?{backgroundColor:v}:{},[v]),Z=useMemo(()=>y?{color:y}:{},[y]),U=useMemo(()=>C?{color:C}:{},[C]),H=y?"":"text-gray-700 dark:text-gray-200",z=C?"":"text-red-500",$=E?"":"hover:border-blue-500 dark:hover:border-blue-400",K=k?"":"focus-visible:ring-blue-500";return jsxs("div",{className:c("inline-flex flex-col",P),style:lh,children:[jsxs("label",{className:c("inline-flex items-center cursor-pointer",u&&"opacity-50 cursor-not-allowed",p&&"cursor-default",i==="left"&&"flex-row-reverse"),htmlFor:w,children:[jsxs("div",{className:"relative inline-flex items-center",children:[jsx("input",{ref:D,type:"radio",id:w,value:r,checked:M,onChange:S,disabled:u,readOnly:p,required:b,"aria-invalid":x,"aria-describedby":N?`${w}-error`:void 0,className:"sr-only peer",tabIndex:p?-1:void 0,...T}),jsx("div",{className:c("rounded-full transition-all duration-200",ah(s),I,!u&&!p&&$,!u&&!p&&R&&"peer-focus-visible:ring-2 ring-offset-2",!u&&!p&&R&&K,g),style:F,children:M&&jsx("div",{className:c("rounded-full absolute inset-0 m-auto transition-all duration-200",sh(s),v?"":l==="outlined"||l==="default"?"bg-blue-600 dark:bg-blue-500":"bg-white"),style:O})})]}),e&&jsxs("span",{className:c("select-none",i==="left"?"mr-2":"ml-2",H,u&&"opacity-50"),style:Z,children:[e,b&&jsx("span",{className:"text-red-500 ml-1",children:"*"})]})]}),t&&!x&&jsx("p",{className:c("text-sm text-gray-500 dark:text-gray-400 mt-1",i==="left"?"text-right":"ml-7"),children:t}),N&&jsx("p",{id:`${w}-error`,className:c("text-sm mt-1",i==="left"?"text-right":"ml-7",z),style:U,children:N})]})});jd.displayName="RadioButton";var Qs=()=>{},gh=[],mh=jsx("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none","aria-hidden":"true",className:"shrink-0",children:jsx("path",{d:"M4 6L8 10L12 6",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})}),fh=jsx("svg",{width:"14",height:"14",viewBox:"0 0 14 14",fill:"none","aria-hidden":"true",className:"shrink-0",children:jsx("path",{d:"M10.5 3.5L3.5 10.5M3.5 3.5L10.5 10.5",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})}),bh=jsxs("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none","aria-hidden":"true",className:"shrink-0 animate-spin",children:[jsx("circle",{cx:"8",cy:"8",r:"6",stroke:"currentColor",strokeWidth:"2",strokeOpacity:"0.25"}),jsx("path",{d:"M14 8a6 6 0 00-6-6",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round"})]}),hh=jsx("svg",{width:"14",height:"14",viewBox:"0 0 14 14",fill:"none","aria-hidden":"true",className:"shrink-0",children:jsx("path",{d:"M11.5 3.5L5.5 10.5L2.5 7.5",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})}),_n={sm:{trigger:"h-8 px-2.5 text-xs gap-1.5",content:"text-xs",option:"px-2.5 py-1.5",searchInput:"px-2.5 py-1.5 text-xs"},md:{trigger:"h-10 px-3 text-sm gap-2",content:"text-sm",option:"px-3 py-2",searchInput:"px-3 py-2 text-sm"},lg:{trigger:"h-12 px-4 text-base gap-2.5",content:"text-base",option:"px-4 py-2.5",searchInput:"px-4 py-2.5 text-base"}},qd={default:{trigger:"border border-gray-300 bg-white dark:border-gray-600 dark:bg-gray-800",focus:"focus:ring-2 focus:ring-blue-500 focus:border-blue-500"},outlined:{trigger:"border-2 border-gray-300 bg-transparent dark:border-gray-600",focus:"focus:ring-2 focus:ring-blue-500 focus:border-blue-500"},filled:{trigger:"border border-transparent bg-gray-100 dark:bg-gray-700",focus:"focus:ring-2 focus:ring-blue-500 focus:border-blue-500"}};function so(...e){let t="";for(let r=0;r<e.length;r++){let o=e[r];o&&(t&&(t+=" "),t+=o);}return t}function yh(e,t){if(!t)return e;let r=t.toLowerCase();return e.filter(o=>{if(o.label.toLowerCase().includes(r)||o.value.toLowerCase().includes(r))return true;if(o.keywords){for(let n of o.keywords)if(n.toLowerCase().includes(r))return true}return false})}var xh=memo(forwardRef(function({option:t,isSelected:r,isHighlighted:o,isDisabled:n,sizeKey:a,optionId:s,onClick:l,onMouseEnter:i,index:d},u){let p=()=>{n||l(t.value);},b=()=>{n||i(d);};return jsxs("div",{ref:u,id:s,role:"option","aria-selected":r,"aria-disabled":n||void 0,"data-highlighted":o||void 0,className:so(_n[a].option,"flex items-center gap-2 cursor-pointer select-none transition-colors",o&&!n&&"bg-blue-50 dark:bg-blue-900/30",r&&!o&&"bg-gray-50 dark:bg-gray-700/50",n&&"opacity-50 cursor-not-allowed"),onClick:p,onMouseEnter:b,children:[t.icon?jsx("span",{className:"flex shrink-0 items-center",children:t.icon}):null,jsxs("span",{className:"flex flex-col min-w-0 flex-1",children:[jsx("span",{className:"truncate",children:t.label}),t.description?jsx("span",{className:"text-xs text-gray-500 dark:text-gray-400 truncate",children:t.description}):null]}),r?jsx("span",{className:"ml-auto text-blue-600 dark:text-blue-400",children:hh}):null]})}));function vh({options:e=gh,value:t,defaultValue:r,onValueChange:o,searchable:n=false,clearable:a=false,disabled:s=false,readOnly:l=false,loading:i=false,size:d="md",variant:u="default",placeholder:p="Select...",label:b,description:m,helperText:f,error:h,required:y=false,noOptionsText:C="No options",onSearchChange:v,name:E,className:k,triggerClassName:R,contentClassName:g,maxHeight:P=256}){let T=useId(),D=`${T}-label`,W=`${T}-trigger`,V=`${T}-listbox`,_=useRef(null),M=useRef(null),w=useRef(null),N=useRef([]),x=t!==void 0,[S,I]=useState(r??""),F=x?t:S,[O,Z]=useState(false),[U,H]=useState(""),[z,$]=useState(-1),[K,se]=useState(null),X=useMemo(()=>n?yh(e,U):e,[e,U,n]),ee=useMemo(()=>e.find(re=>re.value===F)??null,[e,F]),L=useMemo(()=>{let re=new Set;for(let pe of e)pe.disabled&&re.add(pe.value);return re},[e]),q=useCallback(re=>{x||I(re),(o??Qs)(re),Z(false),H(""),$(-1),_.current?.focus();},[x,o]),ge=useCallback(re=>{re.stopPropagation(),x||I(""),(o??Qs)(""),H(""),_.current?.focus();},[x,o]),de=useCallback(()=>{s||l||(Z(true),H(""),$(-1));},[s,l]),Y=useCallback(()=>{Z(false),H(""),$(-1),_.current?.focus();},[]),le=useCallback(()=>{O?Y():de();},[O,Y,de]),xe=useCallback((re,pe)=>{let Ue=X.length;if(Ue===0)return -1;let yt=re;for(let Re=0;Re<Ue;Re++)if(yt=((yt+pe)%Ue+Ue)%Ue,!L.has(X[yt].value))return yt;return -1},[X,L]),Se=useCallback(re=>{if(!(s||l)){if(O){switch(re.key){case "ArrowDown":{re.preventDefault();let pe=xe(z,1);pe!==-1&&$(pe);break}case "ArrowUp":{re.preventDefault();let pe=xe(z,-1);pe!==-1&&$(pe);break}case "Home":{re.preventDefault();let pe=xe(-1,1);pe!==-1&&$(pe);break}case "End":{re.preventDefault();let pe=xe(X.length,-1);pe!==-1&&$(pe);break}case "Enter":{if(re.preventDefault(),z>=0&&z<X.length){let pe=X[z];L.has(pe.value)||q(pe.value);}break}case " ":if(re.preventDefault(),z>=0&&z<X.length){let pe=X[z];L.has(pe.value)||q(pe.value);}else Y();break;case "Escape":re.preventDefault(),Y();break;case "Tab":Y();break}return}switch(re.key){case "ArrowDown":case "ArrowUp":re.preventDefault(),de();break;case "Enter":case " ":re.preventDefault(),de();break}}},[s,l,O,de,Y,z,X,L,xe,q]),te=useCallback(re=>{switch(re.key){case "ArrowDown":{re.preventDefault();let pe=xe(z,1);pe!==-1&&$(pe);break}case "ArrowUp":{re.preventDefault();let pe=xe(z,-1);pe!==-1&&$(pe);break}case "Home":{re.preventDefault();let pe=xe(-1,1);pe!==-1&&$(pe);break}case "End":{re.preventDefault();let pe=xe(X.length,-1);pe!==-1&&$(pe);break}case "Enter":{if(re.preventDefault(),z>=0&&z<X.length){let pe=X[z];L.has(pe.value)||q(pe.value);}break}case "Escape":re.preventDefault(),Y();break;case "Tab":Y();break}},[z,X,L,xe,q,Y]),Ne=useCallback(re=>{let pe=re.target.value;H(pe),$(-1),(v??Qs)(pe);},[v]);useEffect(()=>{if(!O)return;let re=pe=>{let Ue=pe.target;_.current?.contains(Ue)||M.current?.contains(Ue)||Y();};return document.addEventListener("mousedown",re),document.addEventListener("touchstart",re,{passive:true}),()=>{document.removeEventListener("mousedown",re),document.removeEventListener("touchstart",re);}},[O,Y]),useEffect(()=>{if(!O||!_.current){se(null);return}let re=()=>{let pe=_.current;if(!pe)return;let Ue=pe.getBoundingClientRect(),yt=window.innerHeight-Ue.bottom,Re=Ue.top,We=P+8,ft=yt<We&&Re>yt?"top":"bottom";se({top:ft==="bottom"?Ue.bottom+window.scrollY+4:Ue.top+window.scrollY-We,left:Ue.left+window.scrollX,width:Ue.width,placement:ft});};return re(),window.addEventListener("scroll",re,true),window.addEventListener("resize",re),()=>{window.removeEventListener("scroll",re,true),window.removeEventListener("resize",re);}},[O,P]),useEffect(()=>{O&&n&&w.current?.focus();},[O,n]),useEffect(()=>{let re=M.current;if(!(!O||!re))return No(re,()=>_.current)},[O]),useEffect(()=>{if(z>=0){let re=N.current[z];re&&typeof re.scrollIntoView=="function"&&re.scrollIntoView({block:"nearest"});}},[z]);let De=F!==""&&F!==void 0,Ve=a&&De&&!s&&!l&&!i,rt=!s&&!l,dt=so("w-full flex items-center justify-between rounded-md transition-colors","text-gray-900 dark:text-gray-100",_n[d].trigger,qd[u].trigger,!h&&rt&&qd[u].focus,h&&"border-red-500 dark:border-red-400 focus:ring-2 focus:ring-red-500 focus:border-red-500",s&&"opacity-50 cursor-not-allowed bg-gray-50 dark:bg-gray-900",l&&"cursor-default",!s&&!l&&"cursor-pointer",R);return jsxs("div",{className:so("flex flex-col gap-1",k),children:[b?jsxs("label",{id:D,htmlFor:W,className:"text-sm font-medium text-gray-700 dark:text-gray-300",children:[b,y?jsx("span",{className:"text-red-500 ml-0.5","aria-hidden":"true",children:"*"}):null]}):null,m?jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400",children:m}):null,jsxs("button",{ref:_,id:W,type:"button",role:"combobox","aria-expanded":O,"aria-haspopup":"listbox","aria-controls":O?V:void 0,"aria-labelledby":b?D:void 0,"aria-required":y||void 0,"aria-invalid":h?true:void 0,"aria-activedescendant":O&&z>=0?`${T}-option-${z}`:void 0,disabled:s,className:dt,onClick:rt?le:void 0,onKeyDown:Se,children:[jsxs("span",{className:so("flex items-center gap-2 min-w-0 flex-1 truncate",!De&&"text-gray-400 dark:text-gray-500"),children:[ee?.icon?jsx("span",{className:"flex shrink-0 items-center",children:ee.icon}):null,jsx("span",{className:"truncate",children:De&&ee?ee.label:p})]}),jsxs("span",{className:"flex items-center gap-1 shrink-0",children:[i?jsx("span",{className:"text-gray-400",children:bh}):null,Ve?jsx("span",{role:"button",tabIndex:-1,"aria-label":"Clear selection",className:"text-gray-400 hover:text-gray-600 dark:hover:text-gray-300 p-0.5 rounded transition-colors",onClick:ge,onMouseDown:re=>re.preventDefault(),children:fh}):null,jsx("span",{className:so("text-gray-400 transition-transform duration-200",O&&"rotate-180"),children:mh})]})]}),h?jsx("p",{role:"alert",className:"text-xs text-red-500 dark:text-red-400",children:h}):f?jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400",children:f}):null,E?jsx("input",{type:"hidden",name:E,value:F??""}):null,O&&K?createPortal(jsxs("div",{ref:M,role:"listbox",id:V,"aria-labelledby":b?D:void 0,className:so("fixed z-50 bg-white dark:bg-gray-800 border border-gray-200 dark:border-gray-700","rounded-md shadow-lg overflow-hidden","animate-in fade-in-0 zoom-in-95",_n[d].content,g),style:{top:K.top,left:K.left,width:K.width,position:"absolute"},onKeyDown:te,children:[n?jsx("div",{className:"border-b border-gray-200 dark:border-gray-700",children:jsx("input",{ref:w,type:"text",role:"searchbox","aria-label":"Search options",className:so(_n[d].searchInput,"w-full outline-none bg-transparent text-gray-900 dark:text-gray-100","placeholder:text-gray-400 dark:placeholder:text-gray-500"),placeholder:"Search...",value:U,onChange:Ne,onKeyDown:te})}):null,jsx("div",{className:"overflow-y-auto",style:{maxHeight:P},children:X.length===0?jsx("div",{className:so(_n[d].option,"text-gray-500 dark:text-gray-400 text-center py-4"),children:C}):X.map((re,pe)=>jsx(xh,{option:re,isSelected:re.value===F,isHighlighted:pe===z,isDisabled:i||L.has(re.value),sizeKey:d,optionId:`${T}-option-${pe}`,onClick:q,onMouseEnter:$,index:pe,ref:Ue=>{N.current[pe]=Ue;}},re.value))})]}),document.body):null]})}var ti=createContext(null);function Io(){let e=useContext(ti);if(!e)throw new Error("Sidebar sub-components must be used within <Sidebar>");return e}function Ch(){return Io()}var Nh=({className:e})=>jsx("svg",{className:c("w-4 h-4",e),viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true",children:jsx("path",{fillRule:"evenodd",d:"M12.79 5.23a.75.75 0 01-.02 1.06L8.832 10l3.938 3.71a.75.75 0 11-1.04 1.08l-4.5-4.25a.75.75 0 010-1.08l4.5-4.25a.75.75 0 011.06.02z",clipRule:"evenodd"})}),Sh=({className:e})=>jsx("svg",{className:c("w-4 h-4",e),viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true",children:jsx("path",{fillRule:"evenodd",d:"M5.23 7.21a.75.75 0 011.06.02L10 11.168l3.71-3.938a.75.75 0 111.08 1.04l-4.25 4.5a.75.75 0 01-1.08 0l-4.25-4.5a.75.75 0 01.02-1.06z",clipRule:"evenodd"})}),Rh=({className:e})=>jsx("svg",{className:c("w-5 h-5",e),viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true",children:jsx("path",{d:"M6.28 5.22a.75.75 0 00-1.06 1.06L8.94 10l-3.72 3.72a.75.75 0 101.06 1.06L10 11.06l3.72 3.72a.75.75 0 101.06-1.06L11.06 10l3.72-3.72a.75.75 0 00-1.06-1.06L10 8.94 6.28 5.22z"})});function Qd({text:e,position:t,children:r}){let[o,n]=useState(false),[a,s]=useState({top:0,left:0}),l=useRef(null);return jsxs("div",{ref:l,onMouseEnter:()=>{if(l.current){let d=l.current.getBoundingClientRect();s({top:d.top+d.height/2,left:t==="left"?d.right+8:d.left-8});}n(true);},onMouseLeave:()=>n(false),className:"relative",children:[r,o&&jsx("div",{className:c("fixed z-[9999] px-2.5 py-1.5 text-xs font-medium text-white bg-gray-900 dark:bg-gray-700 rounded-md shadow-lg whitespace-nowrap pointer-events-none",t==="right"&&"-translate-x-full"),style:{top:a.top,left:a.left,transform:`translateY(-50%)${t==="right"?" translateX(-100%)":""}`},role:"tooltip",children:e})]})}function Th({collapsed:e,defaultCollapsed:t=false,onCollapsedChange:r,expandedWidth:o=260,collapsedWidth:n=64,position:a="left",variant:s="default",mobileBreakpoint:l=768,mobileOpen:i,onMobileOpenChange:d,className:u,"aria-label":p,closeLabel:b,trapFocus:m=true,initialFocus:f,returnFocus:h,lockScroll:y=true,children:C}){let v=Ft(),E=useRef(null),k=useRef(null),[R,g]=useState(t),[P,T]=useState(false),[D,W]=useState(false),V=e!==void 0,_=V?e:R,M=i!==void 0,w=M?i:P;useEffect(()=>{let H=window.matchMedia(`(max-width: ${l}px)`),z=$=>{W($.matches),$.matches||(M||T(false),d?.(false));};return z(H),H.addEventListener("change",z),()=>H.removeEventListener("change",z)},[l,M,d]);let N=useCallback(()=>{if(D){let H=!w;M||T(H),d?.(H);}else {let H=!_;V||g(H),r?.(H);}},[D,w,_,M,V,d,r]),x=useCallback(()=>{M||T(false),d?.(false);},[M,d]);useEffect(()=>{let H=k.current;H&&(D&&!w?(H.setAttribute("inert",""),H.setAttribute("aria-hidden","true")):(H.removeAttribute("inert"),H.removeAttribute("aria-hidden")));},[D,w]);let{dialogRef:S,dialogProps:I}=So({open:D&&w,onClose:x,trapFocus:m,initialFocus:f,returnFocus:h,lockScroll:y,keepInteractive:[E]}),F={default:"bg-white dark:bg-gray-900",bordered:c("bg-white dark:bg-gray-900",a==="left"?"border-r border-gray-200 dark:border-gray-700":"border-l border-gray-200 dark:border-gray-700"),floating:"bg-white dark:bg-gray-900 m-3 rounded-xl shadow-xl border border-gray-200 dark:border-gray-700"},O=_&&!D?n:o,Z=jsx("aside",{className:c("flex flex-col h-full overflow-hidden transition-[width] duration-200 ease-in-out",F[s],u),style:{width:D?o:O,minWidth:D?o:O},"data-testid":"sidebar","data-collapsed":_&&!D,"data-mobile":D,"data-position":a,children:C}),U={collapsed:_&&!D,isMobile:D,mobileOpen:w,position:a,variant:s,expandedWidth:o,collapsedWidth:n,toggle:N,closeMobile:x,closeLabel:b};return D?jsxs(ti.Provider,{value:U,children:[w&&jsx("div",{ref:E,className:"fixed inset-0 z-40 bg-black/50 transition-opacity",onClick:x,"aria-hidden":"true","data-testid":"sidebar-overlay"}),jsx("div",{ref:H=>{k.current=H,S.current=H;},...I,"aria-label":p??v.sidebar,className:c("fixed top-0 z-50 h-full transition-transform duration-200 ease-in-out focus:outline-none",a==="left"?"left-0":"right-0",w?"translate-x-0":a==="left"?"-translate-x-full":"translate-x-full"),children:Z})]}):jsx(ti.Provider,{value:U,children:Z})}function Ph({className:e,children:t}){let r=Io(),o=Ft();return jsxs("div",{className:c("flex items-center shrink-0 px-4 h-14 overflow-hidden",r.collapsed&&"justify-center px-2",e),"data-testid":"sidebar-header",children:[t,r.isMobile&&r.mobileOpen&&jsx("button",{type:"button",onClick:r.closeMobile,className:"ml-auto p-1 rounded-md text-gray-400 hover:text-gray-600 dark:hover:text-gray-300 hover:bg-gray-100 dark:hover:bg-gray-800 cursor-pointer","aria-label":r.closeLabel??o.closeSidebar,children:jsx(Rh,{})})]})}function Eh({className:e,children:t}){return jsx("div",{className:c("flex-1 overflow-y-auto overflow-x-hidden py-2",e),"data-testid":"sidebar-content",children:t})}function Dh({className:e,children:t}){let r=Io();return jsx("div",{className:c("shrink-0 border-t border-gray-200 dark:border-gray-700 px-4 py-3 overflow-hidden",r.collapsed&&"px-2 flex justify-center",e),"data-testid":"sidebar-footer",children:t})}function Ih({label:e,className:t,children:r}){let o=Io();return jsxs("div",{className:c("py-2",t),"data-testid":"sidebar-group",children:[e&&!o.collapsed&&jsx("div",{className:"px-4 py-1.5 text-[11px] font-semibold uppercase tracking-wider text-gray-400 dark:text-gray-500",children:e}),e&&o.collapsed&&jsx("div",{className:"mx-auto my-1 w-6 border-t border-gray-200 dark:border-gray-700"}),jsx("div",{className:"space-y-0.5 px-2",children:r})]})}function Mh({icon:e,label:t,badge:r,badgeColor:o="bg-blue-600 text-white",active:n=false,disabled:a=false,href:s,onClick:l,tooltip:i,className:d}){let u=Io(),p=u.collapsed,b=i??t,m=jsxs(Fragment,{children:[e&&jsx("span",{className:c("shrink-0 w-5 h-5",p&&"w-5 h-5"),children:e}),!p&&jsxs(Fragment,{children:[jsx("span",{className:"flex-1 truncate",children:t}),r!=null&&jsx("span",{className:c("shrink-0 inline-flex items-center justify-center rounded-full text-[10px] font-semibold min-w-[18px] h-[18px] px-1",o),children:r})]}),p&&r!==void 0&&r!==null&&jsx("span",{className:"absolute top-1 right-1 w-2 h-2 rounded-full bg-blue-600"})]}),f=c("relative flex items-center gap-3 rounded-md text-sm font-medium transition-colors w-full",p?"justify-center px-2 py-2.5":"px-3 py-2",n?"bg-blue-50 text-blue-700 dark:bg-blue-900/30 dark:text-blue-400":"text-gray-700 dark:text-gray-300 hover:bg-gray-100 dark:hover:bg-gray-800",a&&"opacity-50 pointer-events-none",!a&&"cursor-pointer",d),h=()=>{a||(l?.(),u.isMobile&&u.closeMobile());},y=s?jsx("a",{href:a?void 0:s,className:f,onClick:h,"aria-current":n?"page":void 0,"data-testid":"sidebar-item",children:m}):jsx("button",{type:"button",className:f,onClick:h,disabled:a,"aria-current":n?"page":void 0,"data-testid":"sidebar-item",children:m});return p?jsx(Qd,{text:b,position:u.position,children:y}):y}function Lh({icon:e,label:t,badge:r,defaultOpen:o=false,className:n,children:a}){let s=Io(),[l,i]=useState(o),d=useRef(null),[u,p]=useState(o?void 0:0),b=useRef(true);return useEffect(()=>{if(b.current){b.current=false,p(l?void 0:0);return}if(l){let m=d.current;if(m){p(m.scrollHeight);let f=setTimeout(()=>p(void 0),200);return ()=>clearTimeout(f)}}else {let m=d.current;m&&(p(m.scrollHeight),requestAnimationFrame(()=>p(0)));}},[l]),s.collapsed?jsx(Qd,{text:t,position:s.position,children:jsxs("button",{type:"button",className:c("relative flex items-center justify-center gap-3 rounded-md text-sm font-medium transition-colors w-full px-2 py-2.5","text-gray-700 dark:text-gray-300 hover:bg-gray-100 dark:hover:bg-gray-800 cursor-pointer",n),onClick:()=>{s.toggle(),i(true);},"data-testid":"sidebar-submenu-trigger",children:[e&&jsx("span",{className:"shrink-0 w-5 h-5",children:e}),r!=null&&jsx("span",{className:"absolute top-1 right-1 w-2 h-2 rounded-full bg-blue-600"})]})}):jsxs("div",{className:n,"data-testid":"sidebar-submenu",children:[jsxs("button",{type:"button",className:c("flex items-center gap-3 rounded-md text-sm font-medium transition-colors w-full px-3 py-2","text-gray-700 dark:text-gray-300 hover:bg-gray-100 dark:hover:bg-gray-800 cursor-pointer"),onClick:()=>i(!l),"aria-expanded":l,"data-testid":"sidebar-submenu-trigger",children:[e&&jsx("span",{className:"shrink-0 w-5 h-5",children:e}),jsx("span",{className:"flex-1 truncate text-left",children:t}),r!=null&&jsx("span",{className:"shrink-0 inline-flex items-center justify-center rounded-full text-[10px] font-semibold min-w-[18px] h-[18px] px-1 bg-blue-600 text-white",children:r}),jsx(Sh,{className:c("shrink-0 text-gray-400 transition-transform duration-200",l&&"rotate-180")})]}),jsx("div",{className:"overflow-hidden transition-[height] duration-200 ease-in-out",style:{height:u===void 0?"auto":u},children:jsx("div",{ref:d,className:"pl-4 py-0.5",children:a})})]})}function Ah({className:e}){let t=Io(),r=Ft(),o=t.isMobile?t.mobileOpen?t.closeLabel??r.closeSidebar:r.openSidebar:t.collapsed?r.expandSidebar:r.collapseSidebar;return jsx("button",{type:"button",onClick:t.toggle,className:c("p-1.5 rounded-md text-gray-400 hover:text-gray-600 dark:hover:text-gray-300 hover:bg-gray-100 dark:hover:bg-gray-800 transition-colors cursor-pointer",e),"aria-label":o,"data-testid":"sidebar-toggle",children:jsx(Nh,{className:c("transition-transform duration-200",t.collapsed&&"rotate-180",t.position==="right"&&!t.collapsed&&"rotate-180",t.position==="right"&&t.collapsed&&"rotate-0")})})}function oi({data:e,width:t=96,height:r=28,curve:o="monotone",color:n=sa[0],strokeWidth:a=2,area:s=false,emphasizeLast:l=false,domain:i,ariaLabel:d,className:u,...p}){let b=Math.max(a/2,l?a+2.5:0),m=i??Xt(e)??[0,1],f=ho([0,Math.max(1,e.length-1)],[b,t-b]),h=ho(m,[r-b,b]),y=e.map((v,E)=>({x:f(E),y:v==null?Number.NaN:h(v),defined:v!=null&&Number.isFinite(v)})),C=[...y].reverse().find(v=>v.defined!==false);return jsxs("svg",{width:t,height:r,viewBox:`0 0 ${t} ${r}`,className:c("overflow-visible",u),role:d?"img":void 0,"aria-label":d,"aria-hidden":d?void 0:true,...p,children:[s?jsx("path",{d:wn(y,r-b,o),fill:n,fillOpacity:.12,stroke:"none"}):null,jsx("path",{d:Vr(y,o),fill:"none",stroke:n,strokeWidth:a,strokeLinecap:"round",strokeLinejoin:"round",vectorEffect:"non-scaling-stroke"}),l&&C?jsx("circle",{cx:C.x,cy:C.y,r:a,fill:n,strokeWidth:2,className:"stroke-white dark:stroke-gray-800"}):null]})}var Wh={sm:"p-3",md:"p-4",lg:"p-5"},Hh={sm:"text-[11px]",md:"text-xs",lg:"text-sm"},Fh={sm:"text-xl",md:"text-2xl",lg:"text-3xl"},ec={sm:{width:72,height:22},md:{width:96,height:28},lg:{width:120,height:34}};function Bh(e){return e.direction?e.direction:e.value>0?"up":e.value<0?"down":"flat"}function Vh(e,t){return e==="flat"||t==="neutral"?"text-gray-500 dark:text-gray-400":e===t?"text-green-600 dark:text-green-400":"text-red-600 dark:text-red-400"}function Oh({direction:e}){return e==="flat"?jsx("svg",{width:"10",height:"10",viewBox:"0 0 10 10",fill:"currentColor","aria-hidden":"true",children:jsx("rect",{x:"1",y:"4.25",width:"8",height:"1.5",rx:"0.75"})}):jsx("svg",{width:"10",height:"10",viewBox:"0 0 10 10",fill:"currentColor","aria-hidden":"true",children:jsx("path",{d:e==="up"?"M5 1 L9.5 8 L0.5 8 Z":"M5 9 L0.5 2 L9.5 2 Z"})})}function $h({label:e,value:t,format:r,delta:o,trend:n,trendColor:a,icon:s,size:l="md",loading:i=false,variant:d="card",footer:u,className:p,...b}){let m=typeof t=="number"?(r??_t)(t):t,f=o?Bh(o):"flat",h=o?(o.format??(y=>Br(y,{signed:true})))(o.value):null;return jsxs("div",{className:c("flex flex-col gap-2",d==="card"&&c("rounded-lg border border-gray-200 bg-white dark:border-gray-700 dark:bg-gray-800",Wh[l]),p),...b,children:[jsxs("div",{className:"flex items-start justify-between gap-2",children:[jsx("span",{className:c("font-medium text-gray-500 dark:text-gray-400",Hh[l]),children:e}),s?jsx("span",{className:"shrink-0 text-gray-400",children:s}):null]}),jsxs("div",{className:"flex items-end justify-between gap-3",children:[jsxs("div",{className:"flex min-w-0 flex-col gap-1",children:[i?jsx("div",{className:"flex items-center",style:{height:l==="lg"?30:24},"aria-busy":"true","aria-live":"polite",children:jsx(Ho,{indeterminate:true,size:l==="lg"?"sm":"xs",thickness:"thin","aria-hidden":"true"})}):jsx("span",{className:c("leading-none font-semibold text-gray-900 dark:text-gray-100",Fh[l]),children:m}),o&&!i?jsxs("span",{className:c("flex items-center gap-1 text-xs font-medium",Vh(f,o.goodWhen??"up")),children:[jsx(Oh,{direction:f}),h,o.period?jsx("span",{className:"font-normal text-gray-500 dark:text-gray-400",children:o.period}):null]}):null]}),n&&n.length>0&&!i?jsx(oi,{data:n,color:a,emphasizeLast:true,area:true,width:ec[l].width,height:ec[l].height,className:"shrink-0"}):null]}),u?jsx("div",{className:"text-xs text-gray-500 dark:text-gray-400",children:u}):null]})}var _h={1:"sm:grid-cols-1",2:"sm:grid-cols-2",3:"sm:grid-cols-3",4:"sm:grid-cols-2 lg:grid-cols-4"};function Gh({columns:e=4,className:t,children:r,...o}){return jsx("div",{className:c("grid grid-cols-1 gap-3",_h[e],t),...o,children:r})}var Kh={text:"rounded h-4 w-full",circular:"rounded-full",rectangular:"rounded-none",rounded:"rounded-lg"},Uh={pulse:"animate-pulse",wave:"animate-shimmer bg-gradient-to-r from-gray-200 via-gray-100 to-gray-200 dark:from-gray-700 dark:via-gray-600 dark:to-gray-700 bg-[length:200%_100%]",none:""},Yh="bg-gray-200 dark:bg-gray-700";function tc({variant:e="text",animation:t="pulse",width:r,height:o,count:n=1,className:a,style:s,...l}){let i={...r!==void 0&&{width:typeof r=="number"?`${r}px`:r},...o!==void 0&&{height:typeof o=="number"?`${o}px`:o},...s};e==="circular"&&r&&!o&&(i.height=i.width);let d=c(Yh,Kh[e],Uh[t],a);return n===1?jsx("div",{className:d,style:i,"aria-busy":"true","aria-live":"polite",...l}):jsx("div",{className:"space-y-2",children:Array.from({length:n}).map((u,p)=>jsx("div",{className:d,style:i,"aria-busy":"true","aria-live":"polite",...l},p))})}tc.displayName="Skeleton";var Qh={sm:"h-1",md:"h-1.5",lg:"h-2"},ey={sm:"w-3.5 h-3.5",md:"w-4 h-4",lg:"w-5 h-5"},ty={sm:14,md:16,lg:20},ry="[&::-webkit-slider-thumb]:appearance-none [&::-webkit-slider-thumb]:rounded-full [&::-moz-range-thumb]:appearance-none [&::-moz-range-thumb]:rounded-full [&::-moz-range-thumb]:border-0",oy={sm:"[&::-webkit-slider-thumb]:h-3.5 [&::-webkit-slider-thumb]:w-3.5 [&::-moz-range-thumb]:h-3.5 [&::-moz-range-thumb]:w-3.5",md:"[&::-webkit-slider-thumb]:h-4 [&::-webkit-slider-thumb]:w-4 [&::-moz-range-thumb]:h-4 [&::-moz-range-thumb]:w-4",lg:"[&::-webkit-slider-thumb]:h-5 [&::-webkit-slider-thumb]:w-5 [&::-moz-range-thumb]:h-5 [&::-moz-range-thumb]:w-5"},ny={sm:"h-4",md:"h-5",lg:"h-6"},ay={primary:"bg-blue-600 dark:bg-blue-500",success:"bg-green-600 dark:bg-green-500",warning:"bg-yellow-500 dark:bg-yellow-400",error:"bg-red-600 dark:bg-red-500",info:"bg-cyan-600 dark:bg-cyan-500",neutral:"bg-gray-600 dark:bg-gray-400"},sy={primary:"border-blue-600 dark:border-blue-500",success:"border-green-600 dark:border-green-500",warning:"border-yellow-500 dark:border-yellow-400",error:"border-red-600 dark:border-red-500",info:"border-cyan-600 dark:border-cyan-500",neutral:"border-gray-600 dark:border-gray-400"},iy={primary:"peer-focus-visible:ring-blue-500",success:"peer-focus-visible:ring-green-500",warning:"peer-focus-visible:ring-yellow-500",error:"peer-focus-visible:ring-red-500",info:"peer-focus-visible:ring-cyan-500",neutral:"peer-focus-visible:ring-gray-500"},ly={primary:"text-blue-600 dark:text-blue-400",success:"text-green-600 dark:text-green-400",warning:"text-yellow-600 dark:text-yellow-400",error:"text-red-600 dark:text-red-400",info:"text-cyan-600 dark:text-cyan-400",neutral:"text-gray-700 dark:text-gray-300"},rc=(e,t,r)=>Math.min(r,Math.max(t,e)),ai=(e,t,r)=>r>t?(rc(e,t,r)-t)/(r-t)*100:0,Va=(e,t)=>{let r=(.5-e/100)*t,o=Math.round(Math.abs(r)*1e3)/1e3;return `calc(${e}% ${r<0?"-":"+"} ${o}px)`},dy=(e,t,r,o)=>{if(!e)return [];if(Array.isArray(e))return e;let n=o>0?o:1,a=Math.floor((r-t)/n);return a<=0||a>20?[{value:t},{value:r}]:Array.from({length:a+1},(s,l)=>({value:t+l*n}))},oc=forwardRef(({value:e,defaultValue:t,onValueChange:r,min:o=0,max:n=100,step:a=1,size:s="md",color:l="primary",disabled:i=false,readOnly:d=false,label:u,description:p,error:b=false,showValue:m=false,showTooltip:f=false,valueFormat:h,marks:y,trackColor:C,fillColor:v,thumbColor:E,className:k,containerClassName:R,id:g,...P},T)=>{let[D,W]=useState(t??o),V=e!==void 0,M=rc(V?e:D,o,n),w=useId(),N=g??w,x=typeof b=="string"?b:void 0,S=!!b,I=!i&&!d,F=S?"error":l,O=ai(M,o,n),Z=ty[s],U=ee=>{if(!I)return;let L=Number(ee.target.value);V||W(L),r?.(L);},H=useMemo(()=>dy(y,o,n,a),[y,o,n,a]),z=H.some(ee=>ee.label!=null),$=h?h(M):`${M}`,K={width:Va(O,Z)};v&&(K.backgroundColor=v);let se={left:Va(O,Z)};E&&(se.backgroundColor=E,se.borderColor=E);let X=C?{backgroundColor:C}:{};return jsxs("div",{className:c("w-full",R),children:[(u||m)&&jsxs("div",{className:"flex items-center justify-between mb-1.5",children:[u?jsx("label",{htmlFor:N,className:c("text-sm font-medium text-gray-700 dark:text-gray-200",i&&"opacity-50"),children:u}):jsx("span",{}),m&&jsx("span",{className:c("text-sm font-semibold tabular-nums",ly[F]),children:$})]}),jsxs("div",{className:c("relative flex items-center",ny[s],i&&"opacity-50"),children:[jsx("input",{ref:T,type:"range",id:N,min:o,max:n,step:a,value:M,onChange:U,disabled:i,readOnly:d,"aria-invalid":S,"aria-readonly":d||void 0,"aria-describedby":x?`${N}-error`:void 0,tabIndex:I?void 0:-1,className:c("peer absolute inset-0 z-10 m-0 h-full w-full cursor-pointer appearance-none bg-transparent opacity-0",ry,oy[s],!I&&"pointer-events-none cursor-default",k),...P}),jsxs("div",{className:c("pointer-events-none relative w-full overflow-hidden rounded-full bg-gray-200 dark:bg-gray-700",Qh[s]),style:X,children:[jsx("div",{className:c("absolute inset-y-0 left-0 rounded-full transition-[width] duration-150 ease-out",v?"":ay[F]),style:K}),H.map((ee,L)=>{let q=ai(ee.value,o,n),ge=ee.value<=M;return jsx("span",{"data-slider-mark":"",className:c("absolute top-1/2 h-1 w-1 -translate-x-1/2 -translate-y-1/2 rounded-full",ge?"bg-white/80":"bg-gray-400 dark:bg-gray-500"),style:{left:Va(q,Z)}},`mark-${ee.value}-${L}`)})]}),jsx("div",{"data-slider-thumb":"",className:c("pointer-events-none absolute top-1/2 -translate-x-1/2 -translate-y-1/2 rounded-full border-2 bg-white shadow transition-transform dark:bg-gray-100",ey[s],E?"":sy[F],I&&"peer-hover:scale-110 peer-active:scale-110","peer-focus-visible:scale-110 peer-focus-visible:ring-2 peer-focus-visible:ring-offset-2",iy[F]),style:se,children:f&&jsx("span",{"data-slider-tooltip":"",className:c("pointer-events-none absolute bottom-full left-1/2 mb-2 -translate-x-1/2 rounded bg-gray-900 px-1.5 py-0.5 text-xs font-medium text-white opacity-0 transition-opacity dark:bg-gray-700","peer-hover:opacity-100 peer-focus-visible:opacity-100 peer-active:opacity-100"),children:$})})]}),z&&jsx("div",{className:"relative mt-1.5 h-4",children:H.map((ee,L)=>ee.label!=null?jsx("span",{className:"absolute -translate-x-1/2 whitespace-nowrap text-xs text-gray-500 dark:text-gray-400",style:{left:Va(ai(ee.value,o,n),Z)},children:ee.label},`mark-label-${ee.value}-${L}`):null)}),p&&!x&&jsx("p",{className:"mt-1.5 text-sm text-gray-500 dark:text-gray-400",children:p}),x&&jsx("p",{id:`${N}-error`,className:"mt-1.5 text-sm text-red-500 dark:text-red-400",children:x})]})});oc.displayName="Slider";var si=createContext(null);function rn(){let e=useContext(si);if(!e)throw new Error("Tabs components must be used within a Tabs provider");return e}function ac({children:e,defaultValue:t="",value:r,onValueChange:o,variant:n="underline",size:a="md",color:s="default",fullWidth:l=false,orientation:i="horizontal",className:d}){let[u,p]=useState(t),b=r!==void 0,m=b?r:u,f=useCallback(y=>{b||p(y),o?.(y);},[b,o]),h=useMemo(()=>({value:m,onValueChange:f,variant:n,size:a,color:s,orientation:i,fullWidth:l}),[m,f,n,a,s,i,l]);return jsx(si.Provider,{value:h,children:jsx("div",{className:c("w-full",i==="vertical"&&"flex gap-4",d),"data-orientation":i,children:e})})}ac.displayName="Tabs";var fy={none:"gap-0",sm:"gap-1",md:"gap-2",lg:"gap-4"};function sc({children:e,className:t,bgColor:r,gap:o="none"}){let{variant:n,orientation:a,fullWidth:s}=rn(),l=c("flex",a==="vertical"?"flex-col":"flex-row items-center",fy[o]),i={underline:"border-b border-gray-200 dark:border-gray-700",pills:c("p-1 rounded-lg",r||"bg-gray-100 dark:bg-gray-800"),enclosed:"border-b border-gray-200 dark:border-gray-700",soft:c("p-1 rounded-lg",r||"bg-gray-100/50 dark:bg-gray-800/50")};return jsx("div",{role:"tablist","aria-orientation":a,className:c(l,i[n],s&&"w-full",t),children:e})}sc.displayName="TabsList";var hy={sm:"px-3 py-1.5 text-xs gap-1.5",md:"px-4 py-2 text-sm gap-2",lg:"px-5 py-2.5 text-base gap-2"},ic={sm:"w-3.5 h-3.5",md:"w-4 h-4",lg:"w-5 h-5"},lc={default:{underline:{active:"text-gray-900 dark:text-white border-gray-900 dark:border-white",inactive:"text-gray-500 dark:text-gray-400 border-transparent hover:text-gray-700 dark:hover:text-gray-300"},pills:{active:"bg-white dark:bg-gray-700 text-gray-900 dark:text-white shadow-sm",inactive:"text-gray-600 dark:text-gray-400 hover:text-gray-900 dark:hover:text-white"},enclosed:{active:"bg-white dark:bg-gray-800 text-gray-900 dark:text-white border-gray-200 dark:border-gray-700 border-b-white dark:border-b-gray-800",inactive:"text-gray-500 dark:text-gray-400 hover:text-gray-700 dark:hover:text-gray-300 border-transparent"},soft:{active:"bg-gray-200 dark:bg-gray-700 text-gray-900 dark:text-white",inactive:"text-gray-600 dark:text-gray-400 hover:text-gray-900 dark:hover:text-white hover:bg-gray-100 dark:hover:bg-gray-700/50"}},primary:{underline:{active:"text-blue-600 dark:text-blue-400 border-blue-600 dark:border-blue-400",inactive:"text-gray-500 dark:text-gray-400 border-transparent hover:text-blue-600 dark:hover:text-blue-400"},pills:{active:"bg-blue-600 text-white",inactive:"text-gray-600 dark:text-gray-400 hover:text-blue-600 dark:hover:text-blue-400"},enclosed:{active:"bg-blue-50 dark:bg-blue-900/20 text-blue-600 dark:text-blue-400 border-blue-200 dark:border-blue-800 border-b-blue-50 dark:border-b-blue-900/20",inactive:"text-gray-500 dark:text-gray-400 hover:text-blue-600 dark:hover:text-blue-400 border-transparent"},soft:{active:"bg-blue-100 dark:bg-blue-900/50 text-blue-700 dark:text-blue-300",inactive:"text-gray-600 dark:text-gray-400 hover:text-blue-600 dark:hover:text-blue-400 hover:bg-blue-50 dark:hover:bg-blue-900/20"}},secondary:{underline:{active:"text-purple-600 dark:text-purple-400 border-purple-600 dark:border-purple-400",inactive:"text-gray-500 dark:text-gray-400 border-transparent hover:text-purple-600 dark:hover:text-purple-400"},pills:{active:"bg-purple-600 text-white",inactive:"text-gray-600 dark:text-gray-400 hover:text-purple-600 dark:hover:text-purple-400"},enclosed:{active:"bg-purple-50 dark:bg-purple-900/20 text-purple-600 dark:text-purple-400 border-purple-200 dark:border-purple-800 border-b-purple-50 dark:border-b-purple-900/20",inactive:"text-gray-500 dark:text-gray-400 hover:text-purple-600 dark:hover:text-purple-400 border-transparent"},soft:{active:"bg-purple-100 dark:bg-purple-900/50 text-purple-700 dark:text-purple-300",inactive:"text-gray-600 dark:text-gray-400 hover:text-purple-600 dark:hover:text-purple-400 hover:bg-purple-50 dark:hover:bg-purple-900/20"}},success:{underline:{active:"text-green-600 dark:text-green-400 border-green-600 dark:border-green-400",inactive:"text-gray-500 dark:text-gray-400 border-transparent hover:text-green-600 dark:hover:text-green-400"},pills:{active:"bg-green-600 text-white",inactive:"text-gray-600 dark:text-gray-400 hover:text-green-600 dark:hover:text-green-400"},enclosed:{active:"bg-green-50 dark:bg-green-900/20 text-green-600 dark:text-green-400 border-green-200 dark:border-green-800 border-b-green-50 dark:border-b-green-900/20",inactive:"text-gray-500 dark:text-gray-400 hover:text-green-600 dark:hover:text-green-400 border-transparent"},soft:{active:"bg-green-100 dark:bg-green-900/50 text-green-700 dark:text-green-300",inactive:"text-gray-600 dark:text-gray-400 hover:text-green-600 dark:hover:text-green-400 hover:bg-green-50 dark:hover:bg-green-900/20"}},warning:{underline:{active:"text-yellow-600 dark:text-yellow-400 border-yellow-600 dark:border-yellow-400",inactive:"text-gray-500 dark:text-gray-400 border-transparent hover:text-yellow-600 dark:hover:text-yellow-400"},pills:{active:"bg-yellow-500 text-white",inactive:"text-gray-600 dark:text-gray-400 hover:text-yellow-600 dark:hover:text-yellow-400"},enclosed:{active:"bg-yellow-50 dark:bg-yellow-900/20 text-yellow-600 dark:text-yellow-400 border-yellow-200 dark:border-yellow-800 border-b-yellow-50 dark:border-b-yellow-900/20",inactive:"text-gray-500 dark:text-gray-400 hover:text-yellow-600 dark:hover:text-yellow-400 border-transparent"},soft:{active:"bg-yellow-100 dark:bg-yellow-900/50 text-yellow-700 dark:text-yellow-300",inactive:"text-gray-600 dark:text-gray-400 hover:text-yellow-600 dark:hover:text-yellow-400 hover:bg-yellow-50 dark:hover:bg-yellow-900/20"}},error:{underline:{active:"text-red-600 dark:text-red-400 border-red-600 dark:border-red-400",inactive:"text-gray-500 dark:text-gray-400 border-transparent hover:text-red-600 dark:hover:text-red-400"},pills:{active:"bg-red-600 text-white",inactive:"text-gray-600 dark:text-gray-400 hover:text-red-600 dark:hover:text-red-400"},enclosed:{active:"bg-red-50 dark:bg-red-900/20 text-red-600 dark:text-red-400 border-red-200 dark:border-red-800 border-b-red-50 dark:border-b-red-900/20",inactive:"text-gray-500 dark:text-gray-400 hover:text-red-600 dark:hover:text-red-400 border-transparent"},soft:{active:"bg-red-100 dark:bg-red-900/50 text-red-700 dark:text-red-300",inactive:"text-gray-600 dark:text-gray-400 hover:text-red-600 dark:hover:text-red-400 hover:bg-red-50 dark:hover:bg-red-900/20"}}},yy={underline:"border-b-2 -mb-px",pills:"rounded-md",enclosed:"border border-b-0 rounded-t-md -mb-px",soft:"rounded-md"};function dc({value:e,children:t,disabled:r=false,icon:o,endIcon:n,className:a,activeClassName:s,inactiveClassName:l}){let{value:i,onValueChange:d,variant:u,size:p,color:b,fullWidth:m}=rn(),f=i===e,h=()=>{r||d(e);},y=k=>{(k.key==="Enter"||k.key===" ")&&(k.preventDefault(),h());},C=c("inline-flex items-center justify-center font-medium transition-all duration-200","focus:outline-none focus-visible:ring-2 focus-visible:ring-offset-2 focus-visible:ring-blue-500",hy[p],m&&"flex-1"),v=f?c(lc[b][u].active,s):c(lc[b][u].inactive,l),E=r?"opacity-50 cursor-not-allowed":"cursor-pointer";return jsxs("button",{type:"button",role:"tab","aria-selected":f,"aria-disabled":r,tabIndex:f?0:-1,onClick:h,onKeyDown:y,disabled:r,className:c(C,yy[u],v,E,a),children:[o&&jsx("span",{className:c("shrink-0",ic[p]),children:o}),jsx("span",{children:t}),n&&jsx("span",{className:c("shrink-0",ic[p]),children:n})]})}dc.displayName="TabsTrigger";function cc({value:e,children:t,className:r,forceMount:o=false}){let{value:n}=rn(),a=n===e;return !a&&!o?null:jsx("div",{role:"tabpanel",hidden:!a,tabIndex:0,className:c("mt-4 focus:outline-none focus-visible:ring-2 focus-visible:ring-offset-2 focus-visible:ring-blue-500 rounded-md",!a&&"hidden",r),children:t})}cc.displayName="TabsContent";function ky({className:e}){return jsx("svg",{className:e,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",children:jsx("path",{d:"M9 12L11 14L15 10M21 12C21 16.97 16.97 21 12 21C7.03 21 3 16.97 3 12C3 7.03 7.03 3 12 3C16.97 3 21 7.03 21 12Z",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})})}function wy({className:e}){return jsx("svg",{className:e,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",children:jsx("path",{d:"M12 8V12M12 16H12.01M21 12C21 16.97 16.97 21 12 21C7.03 21 3 16.97 3 12C3 7.03 7.03 3 12 3C16.97 3 21 7.03 21 12Z",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})})}function Cy({className:e}){return jsx("svg",{className:e,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",children:jsx("path",{d:"M12 9V13M12 17H12.01M10.29 3.86L1.82 18C1.65 18.3 1.55 18.65 1.55 18.99C1.55 19.34 1.64 19.69 1.81 19.99C1.99 20.29 2.24 20.55 2.54 20.72C2.84 20.901 3.18 20.99 3.53 21H20.47C20.82 20.99 21.16 20.901 21.46 20.72C21.76 20.55 22.01 20.29 22.19 19.99C22.36 19.69 22.449 19.34 22.448 18.99C22.447 18.65 22.35 18.3 22.18 18L13.71 3.86C13.53 3.57 13.28 3.32 12.98 3.15C12.68 2.99 12.34 2.9 12 2.9C11.66 2.9 11.32 2.99 11.02 3.15C10.72 3.32 10.47 3.57 10.29 3.86Z",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})})}function uc({className:e}){return jsx("svg",{className:e,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",children:jsx("path",{d:"M13 16H12V12H11M12 8H12.01M21 12C21 16.97 16.97 21 12 21C7.03 21 3 16.97 3 12C3 7.03 7.03 3 12 3C16.97 3 21 7.03 21 12Z",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})})}function Ny({className:e}){return jsx("svg",{className:e,viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",children:jsx("path",{d:"M4 4L12 12M12 4L4 12",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})})}var Sy={success:ky,error:wy,warning:Cy,info:uc,default:uc},Ry={success:{solid:"bg-green-600 text-white border-green-600",outlined:"bg-white text-green-700 border-green-600 dark:bg-gray-900 dark:text-green-400",soft:"bg-green-50 text-green-700 border-green-200 dark:bg-green-900/20 dark:text-green-400 dark:border-green-800"},error:{solid:"bg-red-600 text-white border-red-600",outlined:"bg-white text-red-700 border-red-600 dark:bg-gray-900 dark:text-red-400",soft:"bg-red-50 text-red-700 border-red-200 dark:bg-red-900/20 dark:text-red-400 dark:border-red-800"},warning:{solid:"bg-yellow-500 text-white border-yellow-500",outlined:"bg-white text-yellow-700 border-yellow-500 dark:bg-gray-900 dark:text-yellow-400",soft:"bg-yellow-50 text-yellow-700 border-yellow-200 dark:bg-yellow-900/20 dark:text-yellow-400 dark:border-yellow-800"},info:{solid:"bg-blue-600 text-white border-blue-600",outlined:"bg-white text-blue-700 border-blue-600 dark:bg-gray-900 dark:text-blue-400",soft:"bg-blue-50 text-blue-700 border-blue-200 dark:bg-blue-900/20 dark:text-blue-400 dark:border-blue-800"},default:{solid:"bg-gray-700 text-white border-gray-700",outlined:"bg-white text-gray-700 border-gray-300 dark:bg-gray-900 dark:text-gray-300",soft:"bg-gray-50 text-gray-700 border-gray-200 dark:bg-gray-800 dark:text-gray-300 dark:border-gray-700"}},Ty={success:"text-green-600 dark:text-green-400",error:"text-red-600 dark:text-red-400",warning:"text-yellow-600 dark:text-yellow-400",info:"text-blue-600 dark:text-blue-400",default:"text-gray-600 dark:text-gray-400"};function gc({children:e,title:t,description:r,type:o="default",variant:n="soft",icon:a,action:s,onClose:l,closable:i=true,className:d,...u}){let p=Sy[o],b=jsx(p,{className:"w-5 h-5"}),m=e??r;return jsxs("div",{role:"alert",className:c("flex items-start gap-3 p-4 rounded-lg border shadow-lg min-w-[320px] max-w-md","animate-in slide-in-from-top-2 fade-in duration-300",Ry[o][n],d),...u,children:[jsx("div",{className:c("flex-shrink-0 mt-0.5",n==="solid"?"text-white":Ty[o]),children:a??b}),jsxs("div",{className:"flex-1 min-w-0",children:[t&&jsx("div",{className:"font-semibold text-sm mb-1",children:t}),m&&jsx("div",{className:"text-sm opacity-90",children:m}),s&&jsx("div",{className:"mt-3",children:s})]}),i&&jsx("button",{type:"button",onClick:l,className:c("flex-shrink-0 rounded-md p-1 transition-colors hover:bg-black/10 dark:hover:bg-white/10","focus:outline-none focus-visible:ring-2 focus-visible:ring-offset-2 focus-visible:ring-current",n==="solid"?"text-white":""),"aria-label":"Close notification",children:jsx(Ny,{className:"w-4 h-4"})})]})}gc.displayName="Toast";var Dy={default:"bg-gray-900 text-white dark:bg-gray-700",light:"bg-white text-gray-900 border border-gray-200 shadow-lg dark:bg-gray-800 dark:text-white dark:border-gray-600",error:"bg-red-600 text-white",success:"bg-green-600 text-white",warning:"bg-yellow-500 text-white",info:"bg-blue-600 text-white"},Iy={default:{top:"border-t-gray-900 dark:border-t-gray-700",bottom:"border-b-gray-900 dark:border-b-gray-700",left:"border-l-gray-900 dark:border-l-gray-700",right:"border-r-gray-900 dark:border-r-gray-700"},light:{top:"border-t-white dark:border-t-gray-800",bottom:"border-b-white dark:border-b-gray-800",left:"border-l-white dark:border-l-gray-800",right:"border-r-white dark:border-r-gray-800"},error:{top:"border-t-red-600",bottom:"border-b-red-600",left:"border-l-red-600",right:"border-r-red-600"},success:{top:"border-t-green-600",bottom:"border-b-green-600",left:"border-l-green-600",right:"border-r-green-600"},warning:{top:"border-t-yellow-500",bottom:"border-b-yellow-500",left:"border-l-yellow-500",right:"border-r-yellow-500"},info:{top:"border-t-blue-600",bottom:"border-b-blue-600",left:"border-l-blue-600",right:"border-r-blue-600"}},My={sm:"px-2 py-1 text-xs",md:"px-3 py-1.5 text-sm",lg:"px-4 py-2 text-base"},Ly={sm:"border-4",md:"border-[5px]",lg:"border-[6px]"},Ay={top:"bottom-full left-1/2 -translate-x-1/2 mb-2",bottom:"top-full left-1/2 -translate-x-1/2 mt-2",left:"right-full top-1/2 -translate-y-1/2 mr-2",right:"left-full top-1/2 -translate-y-1/2 ml-2"},zy={top:"top-full left-1/2 -translate-x-1/2 border-l-transparent border-r-transparent border-b-transparent",bottom:"bottom-full left-1/2 -translate-x-1/2 border-l-transparent border-r-transparent border-t-transparent",left:"left-full top-1/2 -translate-y-1/2 border-t-transparent border-b-transparent border-r-transparent",right:"right-full top-1/2 -translate-y-1/2 border-t-transparent border-b-transparent border-l-transparent"};function mt({children:e,content:t,position:r="top",variant:o="default",size:n="md",trigger:a="hover",open:s,delay:l=0,showArrow:i=true,maxWidth:d="max-w-xs",className:u,contentClassName:p,disabled:b=false,...m}){let[f,h]=useState(false),y=useRef(null),C=useCallback(()=>{b||(l>0?y.current=setTimeout(()=>h(true),l):h(true));},[l,b]),v=useCallback(()=>{y.current&&(clearTimeout(y.current),y.current=null),h(false);},[]),E=useCallback(()=>{b||h(g=>!g);},[b]),k=a==="manual"?s:f,R={hover:{onMouseEnter:C,onMouseLeave:v,onFocus:C,onBlur:v},click:{onClick:E},manual:{}}[a];return jsxs("div",{className:c("relative inline-flex",u),...R,...m,children:[e,k&&!b&&jsxs("div",{role:"tooltip",className:c("absolute z-50 whitespace-normal wrap-break-word rounded-md","transition-opacity duration-150",Ay[r],Dy[o],My[n],d,p),children:[t,i&&jsx("span",{className:c("absolute w-0 h-0 border-solid",Ly[n],zy[r],Iy[o][r]),"aria-hidden":"true"})]})]})}mt.displayName="Tooltip";function Hy(e){switch(e){case "bordered":return "border-t border-gray-200 dark:border-gray-700 bg-white dark:bg-gray-900 text-gray-700 dark:text-gray-300";case "minimal":return "bg-transparent text-gray-600 dark:text-gray-400";case "dark":return "bg-gray-900 text-gray-300";default:return "bg-gray-100 dark:bg-gray-800 text-gray-700 dark:text-gray-300"}}function Fy(e){switch(e){case "sm":return "py-6";case "lg":return "py-16";default:return "py-10"}}function bc({variant:e="default",size:t="md",sticky:r=false,className:o,children:n,...a}){return jsx("footer",{className:c(Hy(e),Fy(t),r&&"sticky bottom-0 z-40",o),...a,children:jsx("div",{className:"container mx-auto px-4",children:n})})}bc.displayName="Footer";function By(e){switch(e){case 1:return "grid-cols-1";case 2:return "grid-cols-1 sm:grid-cols-2";case 3:return "grid-cols-1 sm:grid-cols-2 lg:grid-cols-3";case 4:return "grid-cols-1 sm:grid-cols-2 lg:grid-cols-4";case 5:return "grid-cols-1 sm:grid-cols-2 lg:grid-cols-5";case 6:return "grid-cols-2 sm:grid-cols-3 lg:grid-cols-6";default:return ""}}function hc({title:e,titleClassName:t,columns:r,className:o,children:n,...a}){return jsxs("div",{className:c(r&&"grid gap-8",By(r),o),...a,children:[e&&jsx("h3",{className:c("text-sm font-semibold uppercase tracking-wider text-gray-900 dark:text-white",r&&"col-span-full",t),children:e}),n]})}hc.displayName="FooterSection";function yc({title:e,titleClassName:t,className:r,children:o,...n}){return jsxs("div",{className:c("flex flex-col gap-3",r),...n,children:[e&&jsx("h4",{className:c("text-sm font-semibold uppercase tracking-wider text-gray-900 dark:text-white",t),children:e}),o]})}yc.displayName="FooterColumn";function xc({external:e=false,className:t,children:r,...o}){return jsx("a",{className:c("text-sm text-gray-600 dark:text-gray-400 hover:text-gray-900 dark:hover:text-white transition-colors",t),target:e?"_blank":void 0,rel:e?"noopener noreferrer":void 0,...o,children:r})}xc.displayName="FooterLink";function vc({copyright:e,className:t,children:r,...o}){return jsxs("div",{className:c("mt-8 border-t border-gray-200 dark:border-gray-700 pt-6 flex flex-col sm:flex-row items-center justify-between gap-4",t),...o,children:[e&&jsx("p",{className:"text-sm text-gray-500 dark:text-gray-400",children:e}),r]})}vc.displayName="FooterBottom";function kc({className:e,children:t,...r}){return jsx("div",{className:c("flex items-center gap-4",e),...r,children:t})}kc.displayName="FooterSocial";function wc({icon:e,label:t,className:r,...o}){return jsx("a",{className:c("text-gray-500 dark:text-gray-400 hover:text-gray-900 dark:hover:text-white transition-colors",r),target:"_blank",rel:"noopener noreferrer","aria-label":t,...o,children:e})}wc.displayName="FooterSocialLink";var Yy=4.5,jy=48,Nc=false,qy=memo(function({points:t}){return jsx("g",{children:t.map(r=>jsx("circle",{cx:r.cx,cy:r.cy,r:r.r,fill:r.color,fillOpacity:.85,strokeWidth:2,className:"stroke-white dark:stroke-gray-800"},`${r.seriesKey}-${r.index}`))})});function Zy({width:e,height:t,data:r,resolvedSeries:o,x:n,y:a,grid:s,size:l,bubble:i,trendLine:d,quadrants:u,pointRadius:p,margin:b,tooltip:m,onPointClick:f,plotLabel:h,formatValue:y,formatX:C}){let[v,E]=useState(null),k=useMemo(()=>{let P=o.filter(S=>!S.hidden),T=P.map(S=>S.key),D=to({width:e,height:t,data:r,x:{...n,scale:n.scale==="time"?"time":"linear"},y:a,bounds:Xt(Fr(r,T)),margin:b,formatValue:y,formatX:C}),W=i?Fr(r,[i.key]):[],V=i?Xt(W):null,[_,M]=i?.range??[4,14],w=S=>{if(!i||!V)return p;let I=St(S,i.key);if(I===null)return _;let[F,O]=V,Z=O===F?1:(I-F)/(O-F);return Math.sqrt(_*_+Z*(M*M-_*_))},N=[];P.forEach(S=>{r.forEach((I,F)=>{let O=St(I,S.key),Z=D.categoryPositions[F];O===null||!Number.isFinite(Z)||N.push({seriesKey:S.key,seriesLabel:Lt(S),color:S.color,index:F,cx:Z,cy:D.valueScale(O),r:w(I),xValue:Nr(D.xValues[F]),yValue:O});});});let x=null;if(d&&N.length>1){let S=N.length,I=N.reduce((H,z)=>H+z.xValue,0),F=N.reduce((H,z)=>H+z.yValue,0),O=N.reduce((H,z)=>H+z.xValue*z.yValue,0),Z=N.reduce((H,z)=>H+z.xValue*z.xValue,0),U=S*Z-I*I;if(U!==0){let H=(S*O-I*F)/U,z=(F-H*I)/S,$=N.map(ee=>ee.xValue),[K,se]=[Math.min(...$),Math.max(...$)],X=N.map(ee=>ee.cx);x={x1:Math.min(...X),y1:D.valueScale(H*K+z),x2:Math.max(...X),y2:D.valueScale(H*se+z)};}}return {visible:P,points:N,trend:x,xTicks:D.categoryTicks,yTicks:D.valueTicks,valueScale:D.valueScale,positions:D.categoryPositions,innerWidth:D.innerWidth,innerHeight:D.innerHeight,margin:D.margin,xValues:D.xValues}},[r,o,n,a,e,t,b,i,d,p,y,C]),R=useCallback(P=>{if(m===false||k.points.length===0)return;let T=P.currentTarget.getBoundingClientRect(),D=P.clientX-T.left-k.margin.left,W=P.clientY-T.top-k.margin.top,V=null,_=jy;for(let M of k.points){let w=Math.hypot(M.cx-D,M.cy-W);w<_&&(_=w,V=M);}E(V);},[m,k.points,k.margin]),g=useCallback(()=>{!f||!v||f({seriesKey:v.seriesKey,seriesLabel:v.seriesLabel,color:v.color,value:v.yValue,formattedValue:y(v.yValue),datum:r[v.index],index:v.index,x:k.xValues[v.index]});},[f,v,y,r,k.xValues]);return jsxs(Fragment,{children:[jsxs("svg",{width:e,height:t,role:"img","aria-label":h??k.visible.map(P=>Lt(P)).join(", "),tabIndex:0,className:"touch-none focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-blue-500",onPointerMove:R,onPointerLeave:()=>E(null),onBlur:()=>E(null),onClick:g,children:[jsxs("g",{transform:`translate(${k.margin.left}, ${k.margin.top})`,children:[jsx(Wr,{width:k.innerWidth,height:k.innerHeight,horizontal:s==="y"||s==="both"?k.yTicks.map(P=>P.offset):void 0,vertical:s==="x"||s==="both"?k.xTicks.map(P=>P.offset):void 0}),u?.y!==void 0?jsx("line",{x1:0,y1:k.valueScale(u.y),x2:k.innerWidth,y2:k.valueScale(u.y),stroke:"var(--color-chart-muted)",strokeWidth:1,strokeDasharray:"4 4"}):null,k.trend?jsx("line",{x1:k.trend.x1,y1:k.trend.y1,x2:k.trend.x2,y2:k.trend.y2,stroke:"var(--color-chart-muted)",strokeWidth:1.5,strokeDasharray:"4 4"}):null,jsx(qy,{points:k.points}),v?jsx("circle",{cx:v.cx,cy:v.cy,r:v.r+3,fill:"none",stroke:v.color,strokeWidth:2,"aria-hidden":"true"}):null]}),jsx("g",{transform:`translate(${k.margin.left}, ${k.margin.top+k.innerHeight})`,children:n.hidden?null:jsx(Ut,{orientation:"bottom",ticks:k.xTicks,length:k.innerWidth,label:n.label,size:l})}),jsx("g",{transform:`translate(${k.margin.left}, ${k.margin.top})`,children:a?.hidden?null:jsx(Ut,{orientation:"left",ticks:k.yTicks,length:k.innerHeight,showLine:false,label:a?.label,size:l})})]}),v&&m!==false?jsx(ur,{x:k.margin.left+v.cx,y:k.margin.top+v.cy,containerWidth:e,children:typeof m=="function"?m({x:k.xValues[v.index],xLabel:C(k.xValues[v.index],v.index),index:v.index,points:[{seriesKey:v.seriesKey,seriesLabel:v.seriesLabel,color:v.color,value:v.yValue,formattedValue:y(v.yValue),datum:r[v.index]}]}):jsx(pr,{title:`${n.label??n.key} ${C(k.xValues[v.index],v.index)}`,points:[{seriesKey:v.seriesKey,seriesLabel:v.seriesLabel,color:v.color,value:v.yValue,formattedValue:y(v.yValue),datum:r[v.index]}]})}):null]})}function Jy({data:e,series:t,x:r,y:o,height:n=280,width:a,size:s="md",grid:l="both",legend:i,tooltip:d=true,tableView:u=false,emphasis:p,title:b,description:m,loading:f=false,emptyState:h,onPointClick:y,bubble:C,trendLine:v=false,quadrants:E,pointRadius:k=Yy,legendToggle:R=true,margin:g,locale:P,plotLabel:T,className:D,...W}){let[V,_]=useState(()=>new Set);t.length>3&&!Nc&&(Nc=true,console.warn(`[@synertech/ui] A ScatterChart was given ${t.length} series. Any two marks can sit side by side here, and only the first ${3} palette slots stay tellable apart under that test: facet the chart instead.`));let M=useMemo(()=>t.map((O,Z)=>({...O,hidden:O.hidden||V.has(O.key),color:Cr(O,Z,p)})),[t,V,p]),w=useMemo(()=>o?.format??(O=>_t(O,P)),[o?.format,P]),N=useMemo(()=>r.format??(O=>r.scale==="time"?Gt(O instanceof Date?O:new Date(Nr(O)),P):_t(Nr(O),P)),[r.format,r.scale,P]),x=useCallback(O=>{_(Z=>{let U=new Set(Z);return U.has(O)?U.delete(O):U.add(O),U});},[]),S=i===void 0?t.length>=2:i!==false,I=typeof i=="string"?i:"bottom",F=M.filter(O=>!O.hidden).length;return jsx(lr,{title:b,description:m,height:n,width:a,size:s,loading:f,empty:e.length===0||F===0,emptyState:h,tableView:u,legendPosition:I,legend:S?jsx(dr,{items:Hr(M,p),position:I,marker:"dot",size:s,onToggle:R?x:void 0}):void 0,table:u?jsx(cr,{data:e,series:M,xKey:r.key,xLabel:r.label??r.key,formatX:N,formatValue:w,caption:typeof b=="string"?b:void 0}):void 0,className:D,...W,children:({width:O})=>jsx(Zy,{width:O,height:n,data:e,resolvedSeries:M,x:r,y:o,grid:l,size:s,bubble:C,trendLine:v,quadrants:E,pointRadius:k,margin:g,tooltip:d,onPointClick:y,plotLabel:T,formatValue:w,formatX:N})})}var Rc="se-grid-pattern",Tc=memo(function({gridSize:t,zoom:r}){let o=t*r;return jsxs("svg",{className:"absolute inset-0 w-full h-full pointer-events-none","aria-hidden":"true",children:[jsx("defs",{children:jsx("pattern",{id:Rc,width:o,height:o,patternUnits:"userSpaceOnUse",children:jsx("circle",{cx:1,cy:1,r:1,className:"fill-gray-300 dark:fill-gray-600"})})}),jsx("rect",{width:"100%",height:"100%",fill:`url(#${Rc})`})]})});function io(e,t){return e.collapsed?40:e.height?e.height:40+(e.notes?24:0)+e.fields.length*32+(t?36:0)}function on(e,t){return 40+(t?24:0)+e*32+32/2}function Pc(e,t,r){let o=e.fields.findIndex(i=>i.id===t);if(o===-1)return null;let n=e.width??260,a=!!e.notes,s=e.y+on(o,a);return {x:r==="left"?e.x+0:e.x+n-0,y:s}}function ui(e,t){return Math.round(e/t)*t}function Kn(e,t,r){return Math.min(r,Math.max(t,e))}function Un(e,t,r,o){return {x:(e-o.left-r.x)/r.zoom,y:(t-o.top-r.y)/r.zoom}}function Ga(e,t,r,o){let n=Math.abs(r-e),a=Math.max(50,n*.5),s=e+a,l=t,i=r-a;return `M ${e} ${t} C ${s} ${l}, ${i} ${o}, ${r} ${o}`}function Ec(e,t,r,o,n=40){if(e.length===0)return {x:0,y:0,zoom:1};let a=1/0,s=1/0,l=-1/0,i=-1/0;for(let f of e){let h=f.width??260,y=io(f,o);a=Math.min(a,f.x),s=Math.min(s,f.y),l=Math.max(l,f.x+h),i=Math.max(i,f.y+y);}let d=l-a+n*2,u=i-s+n*2,p=Math.min(t/d,r/u,1),b=(t-d*p)/2-(a-n)*p,m=(r-u*p)/2-(s-n)*p;return {x:b,y:m,zoom:p}}var jn=["text","varchar","char","int2","int4","int8","serial","bigserial","float4","float8","numeric","decimal","bool","date","time","timestamp","timestamptz","uuid","json","jsonb","bytea"];function Dc(){return `table-${Date.now()}-${Math.random().toString(36).slice(2,8)}`}function Yn(){return `field-${Date.now()}-${Math.random().toString(36).slice(2,8)}`}function pi(){return `rel-${Date.now()}-${Math.random().toString(36).slice(2,8)}`}function gi(e="new_field"){return {id:Yn(),name:e,type:"text",nullable:true}}function mi(e,t,r="new_table"){return {id:Dc(),name:r,x:e,y:t,fields:[{id:Yn(),name:"id",type:"serial",primaryKey:true},{id:Yn(),name:"createdAt",type:"timestamp"},{id:Yn(),name:"updatedAt",type:"timestamp"}]}}var Xa=()=>jsxs("svg",{className:"w-3.5 h-3.5 text-indigo-500 flex-shrink-0",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",children:[jsx("path",{d:"M10 1l2 2-5 5M8.5 4.5L11 7"}),jsx("circle",{cx:"4.5",cy:"11.5",r:"3"})]}),Mc=()=>jsxs("svg",{className:"w-3.5 h-3.5 flex-shrink-0",viewBox:"0 0 16 16",fill:"currentColor",children:[jsx("circle",{cx:"8",cy:"8",r:"6",className:"fill-blue-500"}),jsx("path",{d:"M5 8h6M8 5l3 3-3 3",stroke:"white",strokeWidth:"1.5",fill:"none",strokeLinecap:"round",strokeLinejoin:"round"})]}),ox=({collapsed:e})=>jsx("svg",{className:"w-3.5 h-3.5",viewBox:"0 0 16 16",fill:"currentColor",children:e?jsx("path",{d:"M6 3l5 5-5 5V3z"}):jsx("path",{d:"M3 6l5 5 5-5H3z"})}),Lc=()=>jsx("svg",{className:"w-3.5 h-3.5 text-amber-500 flex-shrink-0",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",children:jsx("path",{d:"M3 2v12M7 4h6M7 8h4M7 12h5"})}),Ac=()=>jsx("svg",{className:"w-3.5 h-3.5 text-purple-500 flex-shrink-0",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",children:jsx("path",{d:"M4 2v8a4 4 0 008 0V2"})}),nx=()=>jsx("svg",{className:"w-3 h-3",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",children:jsx("path",{d:"M4 8h8"})}),ax=()=>jsxs("svg",{className:"w-3 h-3 text-gray-300",viewBox:"0 0 16 16",fill:"currentColor",children:[jsx("circle",{cx:"5",cy:"4",r:"1.5"}),jsx("circle",{cx:"11",cy:"4",r:"1.5"}),jsx("circle",{cx:"5",cy:"8",r:"1.5"}),jsx("circle",{cx:"11",cy:"8",r:"1.5"}),jsx("circle",{cx:"5",cy:"12",r:"1.5"}),jsx("circle",{cx:"11",cy:"12",r:"1.5"})]}),sx=memo(function({field:t,tableId:r,editable:o,readOnly:n,disabled:a,onFieldChange:s}){let[l,i]=useState(false),[d,u]=useState(t.defaultValue??""),p=o&&!n&&!a,b=()=>{i(false),s?.(r,t.id,{defaultValue:d||void 0});};return p?l?jsx("input",{className:"text-xs w-16 text-emerald-500 bg-transparent border-b border-emerald-300 outline-none focus:ring-0 p-0 flex-shrink-0","aria-label":`Default value for ${t.name}`,value:d,onChange:m=>u(m.target.value),onBlur:b,onKeyDown:m=>{m.key==="Enter"&&b(),m.key==="Escape"&&i(false);},onMouseDown:m=>m.stopPropagation(),autoFocus:true}):t.defaultValue?jsxs("button",{type:"button",className:"text-xs text-emerald-500 flex-shrink-0 truncate max-w-16 cursor-pointer",onClick:m=>{m.stopPropagation(),u(t.defaultValue??""),i(true);},onMouseDown:m=>m.stopPropagation(),title:`Default: ${t.defaultValue}`,children:["= ",t.defaultValue]}):jsx("button",{type:"button",className:"text-xs text-gray-300 flex-shrink-0 opacity-0 group-hover:opacity-30 hover:!opacity-100 cursor-pointer transition-opacity",onClick:m=>{m.stopPropagation(),u(""),i(true);},onMouseDown:m=>m.stopPropagation(),title:"Set default value",children:"= \u2205"}):t.defaultValue?jsxs("span",{className:"text-xs text-emerald-500 flex-shrink-0 truncate max-w-16",title:`Default: ${t.defaultValue}`,children:["= ",t.defaultValue]}):null}),Wc=memo(function({table:t,selected:r,disabled:o,readOnly:n,editable:a,dropTarget:s,fieldTypes:l,onTableNameChange:i,onTableNotesChange:d,onToggleCollapse:u,onFieldChange:p,onFieldAdd:b,onFieldRemove:m,onFieldReorder:f,onResizeStart:h}){let y=t.width??260,C=t.collapsed??false,v=l.length>0?l:jn,[E,k]=useState(null),[R,g]=useState(null),P=useRef(null),T=useCallback(x=>{i?.(t.id,x.target.value);},[t.id,i]),D=useCallback((x,S)=>{p?.(t.id,x,{name:S});},[t.id,p]),W=useCallback((x,S)=>{p?.(t.id,x,{type:S});},[t.id,p]),V=useCallback((x,S)=>{p?.(t.id,x,{primaryKey:!S});},[t.id,p]),_=useCallback((x,S)=>{p?.(t.id,x,{nullable:!S});},[t.id,p]),M=useCallback((x,S)=>{p?.(t.id,x,{indexed:!S});},[t.id,p]),w=useCallback((x,S)=>{p?.(t.id,x,{unique:!S});},[t.id,p]),N=useCallback(()=>{b?.(t.id);},[t.id,b]);return jsxs("div",{"data-table-id":t.id,className:c("absolute bg-white dark:bg-gray-800 border-2 border-dashed rounded-lg shadow-sm cursor-grab active:cursor-grabbing",t.height?"flex flex-col":void 0,s?"border-green-400 shadow-green-100 dark:shadow-green-900/30 shadow-md":r?"border-blue-500 shadow-blue-100 dark:shadow-blue-900/30":"border-gray-300 dark:border-gray-600",o&&"opacity-60",t.locked&&"!cursor-default"),style:{left:t.x,top:t.y,width:y,height:t.height,userSelect:"none",overflow:t.height?"hidden":void 0},children:[jsxs("div",{className:c("flex items-center justify-between px-3 gap-2","bg-gray-50 dark:bg-gray-700 border-b border-gray-200 dark:border-gray-600"),style:{height:40},children:[a&&!n&&!o?jsx("input",{className:"flex-1 min-w-0 text-sm font-semibold text-gray-800 dark:text-gray-100 bg-transparent border-none outline-none focus:ring-0 p-0 truncate cursor-text","aria-label":"Table name",value:t.name,onChange:T,onMouseDown:x=>x.stopPropagation()}):jsx("span",{className:"flex-1 min-w-0 text-sm font-semibold text-gray-800 dark:text-gray-100 truncate",children:t.name}),jsx("button",{type:"button",className:"flex-shrink-0 p-1 rounded hover:bg-gray-200 dark:hover:bg-gray-600 text-gray-500 dark:text-gray-400",onClick:x=>{x.stopPropagation(),u?.(t.id);},onMouseDown:x=>x.stopPropagation(),"aria-label":C?"Expand table":"Collapse table",children:jsx(ox,{collapsed:C})})]}),!C&&(a&&!n&&!o?jsx("div",{className:"px-3 border-b border-gray-100 dark:border-gray-700 flex items-center",style:{height:24},children:jsx("input",{className:"w-full text-xs italic text-gray-400 dark:text-gray-500 bg-transparent border-none outline-none focus:ring-0 p-0 placeholder-gray-400 dark:placeholder-gray-500","aria-label":"Table notes",placeholder:"Add notes...",value:t.notes??"",onChange:x=>d?.(t.id,x.target.value),onMouseDown:x=>x.stopPropagation()})}):t.notes?jsx("div",{className:"px-3 border-b border-gray-100 dark:border-gray-700 flex items-center",style:{height:24},children:jsx("span",{className:"text-xs italic text-gray-400 dark:text-gray-500 truncate",children:t.notes})}):null),!C&&jsxs("div",{className:t.height?"overflow-y-auto flex-1 min-h-0":void 0,children:[t.fields.map((x,S)=>jsxs("div",{"data-field-id":x.id,"data-table-id":t.id,className:c("flex items-center gap-1.5 pr-2 relative group",a&&!n&&!o?"pl-[18px]":"pl-2","border-b border-gray-100 dark:border-gray-700 last:border-b-0",s?"bg-blue-50/50 dark:bg-blue-900/10":"hover:bg-gray-50 dark:hover:bg-gray-750",E===S&&"opacity-40",R===S&&"!border-t-2 !border-t-blue-400"),style:{height:32},draggable:a&&!n&&!o,onDragStart:I=>{!a||n||o||(I.stopPropagation(),P.current=S,k(S),I.dataTransfer.effectAllowed="move",I.dataTransfer.setData("text/plain",String(S)));},onDragOver:I=>{P.current!==null&&(I.preventDefault(),I.stopPropagation(),g(S));},onDragLeave:()=>{R===S&&g(null);},onDrop:I=>{I.preventDefault(),I.stopPropagation(),P.current!==null&&P.current!==S&&f?.(t.id,P.current,S),P.current=null,k(null),g(null);},onDragEnd:()=>{P.current=null,k(null),g(null);},children:[jsx("div",{"data-connection-side":"left","data-field-id":x.id,"data-table-id":t.id,className:c("absolute -left-[5px] w-2.5 h-2.5 rounded-full border-2 border-white dark:border-gray-800 cursor-crosshair z-10 transition-all",s?"opacity-100 bg-green-400 scale-150 shadow-[0_0_6px_rgba(74,222,128,0.6)]":"opacity-0 group-hover:opacity-100 bg-blue-400"),style:{top:32/2-5}}),a&&!n&&!o&&jsx("span",{className:"absolute left-[3px] cursor-grab active:cursor-grabbing opacity-0 group-hover:opacity-100 transition-opacity z-10",style:{top:32/2-6},children:jsx(ax,{})}),a&&!n&&!o?jsx("button",{type:"button",className:c("w-4 text-xs font-bold flex-shrink-0 text-center cursor-pointer",x.nullable?"text-gray-400":"text-transparent"),onClick:I=>{I.stopPropagation(),_(x.id,x.nullable??false);},onMouseDown:I=>I.stopPropagation(),title:x.nullable?"Nullable":"Not nullable",children:"?"}):jsx("span",{className:c("w-4 text-xs font-bold flex-shrink-0 text-center",x.nullable?"text-gray-400":"text-transparent"),children:x.nullable?"?":""}),x.primaryKey&&x.foreignKey?jsxs("span",{className:"flex items-center gap-0.5 flex-shrink-0",children:[a&&!n&&!o?jsx("button",{type:"button",className:"flex-shrink-0 cursor-pointer",onClick:I=>{I.stopPropagation(),V(x.id,true);},onMouseDown:I=>I.stopPropagation(),title:"Primary Key (click to remove)",children:jsx(Xa,{})}):jsx(Xa,{}),jsx(Mc,{})]}):x.primaryKey?a&&!n&&!o?jsx("button",{type:"button",className:"flex-shrink-0 cursor-pointer",onClick:I=>{I.stopPropagation(),V(x.id,true);},onMouseDown:I=>I.stopPropagation(),title:"Primary Key (click to remove)",children:jsx(Xa,{})}):jsx(Xa,{}):x.foreignKey?jsx(Mc,{}):a&&!n&&!o?jsx("button",{type:"button",className:"w-3.5 h-3.5 flex-shrink-0 rounded text-gray-300 hover:text-indigo-400 transition-colors cursor-pointer",onClick:I=>{I.stopPropagation(),V(x.id,false);},onMouseDown:I=>I.stopPropagation(),title:"Set as Primary Key","aria-label":"Set as primary key",children:jsxs("svg",{className:"w-3.5 h-3.5",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",opacity:"0.3",children:[jsx("path",{d:"M10 1l2 2-5 5M8.5 4.5L11 7"}),jsx("circle",{cx:"4.5",cy:"11.5",r:"3"})]})}):jsx("span",{className:"w-3.5 flex-shrink-0"}),a&&!n&&!o?jsx("input",{className:c("flex-1 min-w-0 text-xs bg-transparent border-none outline-none focus:ring-0 p-0 truncate cursor-text",x.primaryKey?"text-blue-600 dark:text-blue-400 font-medium":"text-gray-700 dark:text-gray-300"),"aria-label":"Field name",value:x.name,onChange:I=>D(x.id,I.target.value),onMouseDown:I=>I.stopPropagation()}):jsx("span",{className:c("flex-1 min-w-0 text-xs truncate",x.primaryKey?"text-blue-600 dark:text-blue-400 font-medium":"text-gray-700 dark:text-gray-300"),children:x.name}),a&&!n&&!o?jsxs("select",{className:"text-xs text-gray-400 dark:text-gray-500 bg-transparent border-none outline-none focus:ring-0 p-0 cursor-pointer text-right",value:x.type,onChange:I=>W(x.id,I.target.value),onMouseDown:I=>I.stopPropagation(),children:[v.map(I=>jsx("option",{value:I,children:I},I)),!v.includes(x.type)&&jsx("option",{value:x.type,children:x.type})]}):jsx("span",{className:"text-xs text-gray-400 dark:text-gray-500 flex-shrink-0",children:x.type}),jsx(sx,{field:x,tableId:t.id,editable:a,readOnly:n,disabled:o,onFieldChange:p}),x.indexed&&jsx(Lc,{}),x.unique&&jsx(Ac,{}),a&&!n&&!o&&jsxs("div",{className:"absolute right-1 top-0 bottom-0 flex items-center gap-0.5 opacity-0 group-hover:opacity-100 transition-opacity bg-gradient-to-l from-white via-white to-transparent dark:from-gray-800 dark:via-gray-800 pl-4 pr-1 z-10",children:[jsx("button",{type:"button",className:c("cursor-pointer transition-opacity",x.indexed?"opacity-100":"opacity-30 hover:opacity-100"),onClick:I=>{I.stopPropagation(),M(x.id,x.indexed??false);},onMouseDown:I=>I.stopPropagation(),title:x.indexed?"Indexed (click to remove)":"Add index",children:jsx(Lc,{})}),jsx("button",{type:"button",className:c("cursor-pointer transition-opacity",x.unique?"opacity-100":"opacity-30 hover:opacity-100"),onClick:I=>{I.stopPropagation(),w(x.id,x.unique??false);},onMouseDown:I=>I.stopPropagation(),title:x.unique?"Unique (click to remove)":"Add unique constraint",children:jsx(Ac,{})}),jsx("button",{type:"button",className:"p-0.5 rounded text-gray-300 hover:text-red-500 hover:bg-red-50 dark:hover:bg-red-900/20 cursor-pointer",onClick:I=>{I.stopPropagation(),m?.(t.id,x.id);},onMouseDown:I=>I.stopPropagation(),title:"Remove field",children:jsx(nx,{})})]}),jsx("div",{"data-connection-side":"right","data-field-id":x.id,"data-table-id":t.id,className:c("absolute -right-[5px] w-2.5 h-2.5 rounded-full border-2 border-white dark:border-gray-800 cursor-crosshair z-10 transition-all",s?"opacity-100 bg-green-400 scale-150 shadow-[0_0_6px_rgba(74,222,128,0.6)]":"opacity-0 group-hover:opacity-100 bg-green-400"),style:{top:32/2-5}})]},x.id)),a&&!n&&!o&&jsxs("button",{type:"button",className:"flex items-center justify-center w-full gap-1 text-xs text-gray-400 hover:text-blue-500 hover:bg-gray-50 dark:hover:bg-gray-750 transition-colors cursor-pointer",style:{height:36},onClick:x=>{x.stopPropagation(),N();},onMouseDown:x=>x.stopPropagation(),children:[jsx("svg",{className:"w-3 h-3",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",children:jsx("path",{d:"M8 4v8M4 8h8"})}),"Add field"]})]}),!o&&!n&&jsx("div",{"data-resize-handle":"corner",className:"absolute -bottom-[5px] -right-[5px] w-[14px] h-[14px] cursor-nwse-resize z-20 group/resize",onMouseDown:x=>{x.stopPropagation(),x.preventDefault();let S=t.height??io(t,a);h?.(t.id,x.clientX,x.clientY,y,S);},children:jsxs("svg",{className:"w-full h-full text-gray-300 group-hover/resize:text-blue-400 transition-colors",viewBox:"0 0 14 14",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",children:[jsx("path",{d:"M12 2v10H2",opacity:"0"}),jsx("path",{d:"M6 12L12 6"}),jsx("path",{d:"M10 12L12 10"})]})})]})});function lx(e,t){let r=t.find(f=>f.id===e.from.tableId),o=t.find(f=>f.id===e.to.tableId);if(!r||!o||r.collapsed||o.collapsed)return null;let n=r.fields.findIndex(f=>f.id===e.from.fieldId),a=o.fields.findIndex(f=>f.id===e.to.fieldId);if(n===-1||a===-1)return null;let s=r.width??260,l=o.width??260,i=r.x+s/2,d=o.x+l/2,u=r.y+on(n,!!r.notes),p=o.y+on(a,!!o.notes),b,m;return i<=d?(b=r.x+s,m=o.x):(b=r.x,m=o.x+l),{x1:b,y1:u,x2:m,y2:p,cardinality:e.cardinality??"1:n"}}var hi=["1:1","1:n","n:1","n:n"];function dx(e){let t=hi.indexOf(e);return hi[(t+1)%hi.length]}var Fc=memo(function({relations:t,tables:r,viewport:o,selectedRelationId:n,disabled:a,onRelationClick:s,onCardinalityChange:l}){return jsx("svg",{className:"absolute top-0 left-0 pointer-events-none",style:{width:"100%",height:"100%",overflow:"visible"},children:jsx("g",{transform:`translate(${o.x}, ${o.y}) scale(${o.zoom})`,children:t.map(i=>{let d=lx(i,r);if(!d)return null;let{x1:u,y1:p,x2:b,y2:m,cardinality:f}=d,h=Ga(u,p,b,m),y=n===i.id,C=(u+b)/2,v=(p+m)/2;return jsxs("g",{children:[jsx("path",{d:h,fill:"none",stroke:"transparent",strokeWidth:16,className:"pointer-events-auto cursor-pointer",onClick:E=>{a||s?.(i.id,E);}}),jsx("path",{d:h,fill:"none",stroke:y?"#3b82f6":"#9ca3af",strokeWidth:y?2.5:1.5,className:"transition-colors"}),jsx("circle",{cx:u,cy:p,r:3,fill:y?"#3b82f6":"#9ca3af"}),jsx("circle",{cx:b,cy:m,r:3,fill:y?"#3b82f6":"#9ca3af"}),f&&jsxs("g",{className:a?void 0:"pointer-events-auto cursor-pointer",onClick:a?void 0:E=>{E.stopPropagation(),l?.(i.id,dx(f));},children:[jsx("rect",{x:C-14,y:v-9,width:28,height:18,rx:4,fill:"white",stroke:y?"#3b82f6":"#d1d5db",strokeWidth:1}),jsx("text",{x:C,y:v+4,textAnchor:"middle",className:"text-[10px] font-mono",fill:y?"#3b82f6":"#6b7280",children:f})]})]},i.id)})})})});var ux=()=>jsx("svg",{className:"w-4 h-4",viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true",children:jsx("path",{fillRule:"evenodd",d:"M10 5a1 1 0 011 1v3h3a1 1 0 110 2h-3v3a1 1 0 11-2 0v-3H6a1 1 0 110-2h3V6a1 1 0 011-1z",clipRule:"evenodd"})}),px=()=>jsx("svg",{className:"w-4 h-4",viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true",children:jsx("path",{fillRule:"evenodd",d:"M5 10a1 1 0 011-1h8a1 1 0 110 2H6a1 1 0 01-1-1z",clipRule:"evenodd"})}),gx=()=>jsx("svg",{className:"w-4 h-4",viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true",children:jsx("path",{fillRule:"evenodd",d:"M4 2a1 1 0 011 1v2.101a7.002 7.002 0 0111.601 2.566 1 1 0 11-1.885.666A5.002 5.002 0 005.999 7H9a1 1 0 010 2H4a1 1 0 01-1-1V3a1 1 0 011-1zm.008 9.057a1 1 0 011.276.61A5.002 5.002 0 0014.001 13H11a1 1 0 110-2h5a1 1 0 011 1v5a1 1 0 11-2 0v-2.101a7.002 7.002 0 01-11.601-2.566 1 1 0 01.61-1.276z",clipRule:"evenodd"})}),mx=()=>jsx("svg",{className:"w-4 h-4",viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true",children:jsx("path",{d:"M3 4a1 1 0 011-1h4a1 1 0 010 2H6.414l2.293 2.293a1 1 0 01-1.414 1.414L5 6.414V8a1 1 0 01-2 0V4zm9 1a1 1 0 010-2h4a1 1 0 011 1v4a1 1 0 01-2 0V6.414l-2.293 2.293a1 1 0 11-1.414-1.414L13.586 5H12zm-9 7a1 1 0 012 0v1.586l2.293-2.293a1 1 0 011.414 1.414L6.414 15H8a1 1 0 010 2H4a1 1 0 01-1-1v-4zm13 0a1 1 0 01-2 0v-1.586l-2.293 2.293a1 1 0 01-1.414-1.414L13.586 9H12a1 1 0 010-2h4a1 1 0 011 1v4z"})}),fx=()=>jsx("svg",{className:"w-4 h-4",viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true",children:jsx("path",{fillRule:"evenodd",d:"M6 2a2 2 0 00-2 2v12a2 2 0 002 2h8a2 2 0 002-2V4a2 2 0 00-2-2H6zm4 5a1 1 0 011 1v1h1a1 1 0 110 2h-1v1a1 1 0 11-2 0v-1H8a1 1 0 110-2h1V8a1 1 0 011-1z",clipRule:"evenodd"})}),bx=()=>jsx("svg",{className:"w-4 h-4",viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true",children:jsx("path",{fillRule:"evenodd",d:"M3 17a1 1 0 011-1h12a1 1 0 110 2H4a1 1 0 01-1-1zm3.293-7.707a1 1 0 011.414 0L9 10.586V3a1 1 0 112 0v7.586l1.293-1.293a1 1 0 111.414 1.414l-3 3a1 1 0 01-1.414 0l-3-3a1 1 0 010-1.414z",clipRule:"evenodd"})}),hx=()=>jsx("svg",{className:"w-4 h-4",viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true",children:jsx("path",{fillRule:"evenodd",d:"M3 17a1 1 0 011-1h12a1 1 0 110 2H4a1 1 0 01-1-1zM6.293 6.707a1 1 0 010-1.414l3-3a1 1 0 011.414 0l3 3a1 1 0 01-1.414 1.414L11 5.414V13a1 1 0 11-2 0V5.414L7.707 6.707a1 1 0 01-1.414 0z",clipRule:"evenodd"})}),yx=()=>jsx("svg",{className:"w-4 h-4",viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true",children:jsx("path",{fillRule:"evenodd",d:"M2 5a2 2 0 012-2h12a2 2 0 012 2v2a2 2 0 01-2 2H4a2 2 0 01-2-2V5zm14 1a1 1 0 11-2 0 1 1 0 012 0zM2 13a2 2 0 012-2h12a2 2 0 012 2v2a2 2 0 01-2 2H4a2 2 0 01-2-2v-2zm14 1a1 1 0 11-2 0 1 1 0 012 0z",clipRule:"evenodd"})}),xx=()=>jsx("svg",{className:"w-4 h-4",viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true",children:jsx("path",{fillRule:"evenodd",d:"M7.707 3.293a1 1 0 010 1.414L5.414 7H11a7 7 0 017 7v2a1 1 0 11-2 0v-2a5 5 0 00-5-5H5.414l2.293 2.293a1 1 0 11-1.414 1.414l-4-4a1 1 0 010-1.414l4-4a1 1 0 011.414 0z",clipRule:"evenodd"})}),vx=()=>jsx("svg",{className:"w-4 h-4",viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true",children:jsx("path",{fillRule:"evenodd",d:"M12.293 3.293a1 1 0 011.414 0l4 4a1 1 0 010 1.414l-4 4a1 1 0 01-1.414-1.414L14.586 9H9a5 5 0 00-5 5v2a1 1 0 11-2 0v-2a7 7 0 017-7h5.586l-2.293-2.293a1 1 0 010-1.414z",clipRule:"evenodd"})}),kx=()=>jsx("svg",{className:"w-4 h-4",viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true",children:jsx("path",{d:"M3 3h4v4H3V3zm0 10h4v4H3v-4zm10-10h4v4h-4V3zm0 10h4v4h-4v-4zM7 5h6v1H7V5zm0 8h6v1H7v-1zM5 7v6h1V7H5zm8 0v6h1V7h-1z"})}),Bc=memo(function({zoom:t,onZoomIn:r,onZoomOut:o,onResetView:n,onFitToContent:a,onAddTable:s,onExportJSON:l,onImportJSON:i,onExportSQL:d,onUndo:u,onRedo:p,canUndo:b=false,canRedo:m=false,onAutoLayout:f,disabled:h,className:y}){let[C,v]=useState(false),[E,k]=useState(false),[R,g]=useState(false),[P,T]=useState(""),[D,W]=useState(""),[V,_]=useState(""),M=useCallback(()=>{T(l()),v(true);},[l]),w=useCallback(()=>{D.trim()&&(i(D.trim()),W(""),k(false));},[D,i]),N=useCallback(()=>{W(""),k(false);},[]),x=useCallback(()=>{v(false);},[]),S=useCallback(()=>{d&&(_(d()),g(true));},[d]),I=useCallback(()=>{g(false);},[]),F=Math.round(t*100);return jsxs(Fragment,{children:[jsxs("div",{className:c("absolute top-3 left-3 z-20 flex items-center gap-2 bg-white dark:bg-gray-800 rounded-lg shadow-md border border-gray-200 dark:border-gray-600 px-2 py-1.5",y),"data-testid":"schema-toolbar",onMouseDown:O=>O.stopPropagation(),children:[jsxs(Go,{size:"sm",children:[jsx(mt,{content:"Zoom in",size:"sm",position:"bottom",children:jsx(gt,{icon:jsx(ux,{}),size:"sm",bgColor:"bg-gray-100 hover:bg-gray-200 dark:bg-gray-700 dark:hover:bg-gray-600",textColor:"text-gray-700 dark:text-gray-200",onClick:r,disabled:h,"aria-label":"Zoom in"})}),jsx(mt,{content:"Zoom out",size:"sm",position:"bottom",children:jsx(gt,{icon:jsx(px,{}),size:"sm",bgColor:"bg-gray-100 hover:bg-gray-200 dark:bg-gray-700 dark:hover:bg-gray-600",textColor:"text-gray-700 dark:text-gray-200",onClick:o,disabled:h,"aria-label":"Zoom out"})})]}),jsxs("span",{className:"text-xs font-mono text-gray-500 dark:text-gray-400 min-w-[3ch] text-center select-none",children:[F,"%"]}),jsx("div",{className:"w-px h-5 bg-gray-200 dark:bg-gray-600"}),jsx(mt,{content:"Reset view",size:"sm",position:"bottom",children:jsx(gt,{icon:jsx(gx,{}),size:"sm",bgColor:"bg-gray-100 hover:bg-gray-200 dark:bg-gray-700 dark:hover:bg-gray-600",textColor:"text-gray-700 dark:text-gray-200",onClick:n,disabled:h,"aria-label":"Reset view"})}),jsx(mt,{content:"Fit to content",size:"sm",position:"bottom",children:jsx(gt,{icon:jsx(mx,{}),size:"sm",bgColor:"bg-gray-100 hover:bg-gray-200 dark:bg-gray-700 dark:hover:bg-gray-600",textColor:"text-gray-700 dark:text-gray-200",onClick:a,disabled:h,"aria-label":"Fit to content"})}),jsx("div",{className:"w-px h-5 bg-gray-200 dark:bg-gray-600"}),jsx(mt,{content:"Add table",size:"sm",position:"bottom",children:jsx(gt,{icon:jsx(fx,{}),size:"sm",bgColor:"bg-gray-100 hover:bg-gray-200 dark:bg-gray-700 dark:hover:bg-gray-600",textColor:"text-gray-700 dark:text-gray-200",onClick:s,disabled:h,"aria-label":"Add table"})}),jsx("div",{className:"w-px h-5 bg-gray-200 dark:bg-gray-600"}),jsx(mt,{content:"Export JSON",size:"sm",position:"bottom",children:jsx(gt,{icon:jsx(bx,{}),size:"sm",bgColor:"bg-gray-100 hover:bg-gray-200 dark:bg-gray-700 dark:hover:bg-gray-600",textColor:"text-gray-700 dark:text-gray-200",onClick:M,disabled:h,"aria-label":"Export JSON"})}),jsx(mt,{content:"Import JSON",size:"sm",position:"bottom",children:jsx(gt,{icon:jsx(hx,{}),size:"sm",bgColor:"bg-gray-100 hover:bg-gray-200 dark:bg-gray-700 dark:hover:bg-gray-600",textColor:"text-gray-700 dark:text-gray-200",onClick:()=>k(true),disabled:h,"aria-label":"Import JSON"})}),d&&jsx(mt,{content:"Export SQL",size:"sm",position:"bottom",children:jsx(gt,{icon:jsx(yx,{}),size:"sm",bgColor:"bg-gray-100 hover:bg-gray-200 dark:bg-gray-700 dark:hover:bg-gray-600",textColor:"text-gray-700 dark:text-gray-200",onClick:S,disabled:h,"aria-label":"Export SQL"})}),(u||p)&&jsxs(Fragment,{children:[jsx("div",{className:"w-px h-5 bg-gray-200 dark:bg-gray-600"}),jsxs(Go,{size:"sm",children:[jsx(mt,{content:"Undo (Ctrl+Z)",size:"sm",position:"bottom",children:jsx(gt,{icon:jsx(xx,{}),size:"sm",bgColor:"bg-gray-100 hover:bg-gray-200 dark:bg-gray-700 dark:hover:bg-gray-600",textColor:"text-gray-700 dark:text-gray-200",onClick:u,disabled:h||!b,"aria-label":"Undo"})}),jsx(mt,{content:"Redo (Ctrl+Y)",size:"sm",position:"bottom",children:jsx(gt,{icon:jsx(vx,{}),size:"sm",bgColor:"bg-gray-100 hover:bg-gray-200 dark:bg-gray-700 dark:hover:bg-gray-600",textColor:"text-gray-700 dark:text-gray-200",onClick:p,disabled:h||!m,"aria-label":"Redo"})})]})]}),f&&jsxs(Fragment,{children:[jsx("div",{className:"w-px h-5 bg-gray-200 dark:bg-gray-600"}),jsx(mt,{content:"Auto layout",size:"sm",position:"bottom",children:jsx(gt,{icon:jsx(kx,{}),size:"sm",bgColor:"bg-gray-100 hover:bg-gray-200 dark:bg-gray-700 dark:hover:bg-gray-600",textColor:"text-gray-700 dark:text-gray-200",onClick:f,disabled:h,"aria-label":"Auto layout"})})]})]}),jsx(Yr,{isOpen:C,onClose:x,title:"Export Schema",description:"Copy the JSON below to save your schema.",size:"lg",showSubmit:false,showCancel:true,cancelLabel:"Close",children:jsx(Er,{label:"Schema JSON",multiline:true,rows:12,value:P,readOnly:true,size:"sm"})}),jsx(Yr,{isOpen:E,onClose:N,title:"Import Schema",description:"Paste schema JSON to load it into the editor.",size:"lg",showSubmit:true,submitLabel:"Import",onSubmitClick:w,showCancel:true,cancelLabel:"Cancel",children:jsx(Er,{label:"Schema JSON",multiline:true,rows:12,value:D,onChange:O=>W(O.target.value),placeholder:'{"tables": [], "relations": []}',size:"sm"})}),jsx(Yr,{isOpen:R,onClose:I,title:"Export SQL",description:"Generated PostgreSQL CREATE TABLE statements.",size:"lg",showSubmit:false,showCancel:true,cancelLabel:"Close",children:jsx(Er,{label:"SQL",multiline:true,rows:16,value:V,readOnly:true,size:"sm"})})]})});var Cx=()=>jsxs("svg",{className:"w-3.5 h-3.5",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",children:[jsx("path",{d:"M10 1l2 2-5 5M8.5 4.5L11 7"}),jsx("circle",{cx:"4.5",cy:"11.5",r:"3"})]}),Nx=()=>jsx("span",{className:"text-xs font-bold text-gray-500 w-3.5 text-center",children:"?"}),Sx=()=>jsxs("svg",{className:"w-3.5 h-3.5",viewBox:"0 0 16 16",fill:"currentColor",children:[jsx("circle",{cx:"8",cy:"8",r:"6",className:"fill-blue-500"}),jsx("path",{d:"M5 8h6M8 5l3 3-3 3",stroke:"white",strokeWidth:"1.5",fill:"none",strokeLinecap:"round",strokeLinejoin:"round"})]}),Rx=()=>jsx("svg",{className:"w-3.5 h-3.5 text-amber-500",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",children:jsx("path",{d:"M3 2v12M7 4h6M7 8h4M7 12h5"})}),Tx=()=>jsx("svg",{className:"w-3.5 h-3.5 text-purple-500",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",children:jsx("path",{d:"M4 2v8a4 4 0 008 0V2"})}),Vc=memo(function({className:t}){return jsxs("div",{className:c("absolute top-3 right-3 z-20 flex items-center gap-4 bg-white dark:bg-gray-800 rounded-lg shadow-md border border-gray-200 dark:border-gray-600 px-3 py-2",t),"data-testid":"schema-legend",children:[jsxs("div",{className:"flex items-center gap-1.5",children:[jsx(Cx,{}),jsx("span",{className:"text-xs text-gray-600 dark:text-gray-300",children:"Primary Key"})]}),jsxs("div",{className:"flex items-center gap-1.5",children:[jsx(Nx,{}),jsx("span",{className:"text-xs text-gray-600 dark:text-gray-300",children:"Nullable"})]}),jsxs("div",{className:"flex items-center gap-1.5",children:[jsx(Sx,{}),jsx("span",{className:"text-xs text-gray-600 dark:text-gray-300",children:"Foreign Key"})]}),jsxs("div",{className:"flex items-center gap-1.5",children:[jsx(Rx,{}),jsx("span",{className:"text-xs text-gray-600 dark:text-gray-300",children:"Index"})]}),jsxs("div",{className:"flex items-center gap-1.5",children:[jsx(Tx,{}),jsx("span",{className:"text-xs text-gray-600 dark:text-gray-300",children:"Unique"})]})]})});var Ua=180,Ya=120,ln=10,Oc=memo(function({tables:t,viewport:r,containerWidth:o,containerHeight:n,editable:a,onViewportChange:s,className:l}){let i=useRef(null),d=useMemo(()=>{if(t.length===0)return null;let R=1/0,g=1/0,P=-1/0,T=-1/0;for(let I of t){let F=I.width??260,O=io(I,a);R=Math.min(R,I.x),g=Math.min(g,I.y),P=Math.max(P,I.x+F),T=Math.max(T,I.y+O);}let D=-r.x/r.zoom,W=-r.y/r.zoom,V=D+o/r.zoom,_=W+n/r.zoom;R=Math.min(R,D),g=Math.min(g,W),P=Math.max(P,V),T=Math.max(T,_);let M=P-R+ln*2,w=T-g+ln*2,N=Math.min((Ua-4)/M,(Ya-4)/w),x=(Ua-M*N)/2,S=(Ya-w*N)/2;return {minX:R,minY:g,scale:N,offsetX:x,offsetY:S,vpMinX:D,vpMinY:W}},[t,r,o,n,a]),u=useCallback(R=>{if(!d)return;let g=i.current?.getBoundingClientRect();if(!g)return;let P=R.clientX-g.left,T=R.clientY-g.top,D=(P-d.offsetX)/d.scale+d.minX-ln,W=(T-d.offsetY)/d.scale+d.minY-ln;s({...r,x:-(D-o/(2*r.zoom))*r.zoom,y:-(W-n/(2*r.zoom))*r.zoom});},[d,r,o,n,s]);if(!d)return null;let{minX:p,minY:b,scale:m,offsetX:f,offsetY:h,vpMinX:y,vpMinY:C}=d,v=(R,g)=>({x:(R-p+ln)*m+f,y:(g-b+ln)*m+h}),E=v(y,C),k={w:o/r.zoom*m,h:n/r.zoom*m};return jsx("div",{ref:i,className:c("absolute bottom-3 right-3 z-20 bg-white/90 dark:bg-gray-800/90 rounded-lg shadow-md border border-gray-200 dark:border-gray-600 cursor-pointer overflow-hidden",l),style:{width:Ua,height:Ya},onClick:u,onMouseDown:R=>R.stopPropagation(),"data-testid":"schema-minimap",children:jsxs("svg",{width:Ua,height:Ya,children:[t.map(R=>{let g=R.width??260,P=io(R,a),T=v(R.x,R.y);return jsx("rect",{x:T.x,y:T.y,width:g*m,height:P*m,fill:R.color??"#e5e7eb",stroke:"#9ca3af",strokeWidth:.5,rx:1},R.id)}),jsx("rect",{x:E.x,y:E.y,width:k.w,height:k.h,fill:"rgba(59, 130, 246, 0.1)",stroke:"#3b82f6",strokeWidth:1,rx:1})]})})});function Jr(e){return `"${e.replace(/"/g,'""')}"`}function $c(e){return {text:"TEXT",varchar:"VARCHAR(255)",char:"CHAR(1)",int2:"SMALLINT",int4:"INTEGER",int8:"BIGINT",serial:"SERIAL",bigserial:"BIGSERIAL",float4:"REAL",float8:"DOUBLE PRECISION",numeric:"NUMERIC",decimal:"DECIMAL",bool:"BOOLEAN",date:"DATE",time:"TIME",timestamp:"TIMESTAMP",timestamptz:"TIMESTAMP WITH TIME ZONE",uuid:"UUID",json:"JSON",jsonb:"JSONB",bytea:"BYTEA"}[e]??e.toUpperCase()}function Lx(e){let t=[Jr(e.name)];return e.type==="serial"||e.type,t.push($c(e.type)),e.primaryKey&&t.push("PRIMARY KEY"),!e.nullable&&!e.primaryKey&&t.push("NOT NULL"),e.unique&&!e.primaryKey&&t.push("UNIQUE"),e.defaultValue&&t.push(`DEFAULT ${e.defaultValue}`)," "+t.join(" ")}function Ax(e,t,r){let o=[],n=[];for(let i of e.fields)o.push(Lx(i));for(let i of e.fields)if(i.foreignKey){let d=r.find(p=>p.id===i.foreignKey.tableId),u=d?.fields.find(p=>p.id===i.foreignKey.fieldId);d&&u&&n.push(` CONSTRAINT ${Jr(`fk_${e.name}_${i.name}`)} FOREIGN KEY (${Jr(i.name)}) REFERENCES ${Jr(d.name)} (${Jr(u.name)})`);}let a=[];for(let i of e.fields)i.indexed&&!i.primaryKey&&!i.unique&&a.push(`CREATE INDEX ${Jr(`idx_${e.name}_${i.name}`)} ON ${Jr(e.name)} (${Jr(i.name)});`);let s=[...o,...n],l=`CREATE TABLE ${Jr(e.name)} (
|
|
23
|
+
`,role:"tooltip",children:[(c||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:c&&jsx("h3",{className:"text-sm font-semibold",children:c})}),s&&jsx("div",{className:"flex items-center gap-1",children:b?jsxs(Fragment,{children:[jsx("button",{type:"button",onClick:T,disabled:w,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:w?Yb:Gb}),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:Kb}),i&&jsx("button",{type:"button",onClick:S,disabled:w,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:Ub})]}):jsx("button",{type:"button",onClick:O,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:Xb})})]}),h&&jsx("div",{className:`px-4 py-2 text-xs ${h.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:h.text}),jsx("div",{className:"flex-1 overflow-y-auto p-4",children:b?t?p?jsx(p,{value:y,onChange:M,placeholder:"\xC9crivez en Markdown..."}):jsx("p",{role:"alert",className:"p-3 text-sm text-gray-500 dark:text-gray-400",children:f??m.markdownEditorUnavailable}):jsx("div",{className:"space-y-2",children:jsx("textarea",{ref:I,"aria-label":"Contenu d'aide",value:y,onChange:N=>M(N.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 C=="string"?jsx("div",{className:"prose prose-sm dark:prose-invert max-w-none",children:t?jsx($b,{remarkPlugins:Qb,components:Jb,children:C}):jsx("div",{dangerouslySetInnerHTML:{__html:Ob.sanitize(C)}})}):C})]})]}):null}function eh({children:e,content:t,markdown:r=false,position:n="bottom",size:o="sm",visible:a=true,editable:s=false,onSave:l,onReset:i,width:d="md",title:c,className:p,markdownEditor:f,markdownEditorUnavailableLabel:m}){return jsxs("div",{className:"inline-flex items-center gap-2.5",children:[e,jsx(mc,{content:t,markdown:r,position:n,size:o,visible:a,editable:s,onSave:l,onReset:i,width:d,title:c,className:p,markdownEditor:f,markdownEditorUnavailableLabel:m})]})}var ah={"16/9":"aspect-[16/9]","4/3":"aspect-[4/3]","1/1":"aspect-square",auto:""},sh=e=>new Promise((t,r)=>{let n=new FileReader;n.onload=o=>{let a=o.target?.result;t(a);},n.onerror=()=>{r(new Error("Erreur lors de la lecture du fichier"));},n.readAsDataURL(e);});function ih({value:e,onChange:t,onUpload:r,label:n="Image",maxSize:o=5*1024*1024,accept:a="image/*",helpText:s,disabled:l=false,className:i="",showUrlInput:d=true,urlPlaceholder:c="https://example.com/image.jpg",aspectRatio:p="16/9"}){let[f,m]=useState(false),[g,x]=useState(null),b=useRef(null),v=useId(),y=useMemo(()=>(o/(1024*1024)).toFixed(0),[o]),M=`Formats accept\xE9s : ${a==="image/*"?"JPG, PNG, GIF, WebP":a} (max ${y}MB)`,w=useCallback(async k=>{let I=k.target.files?.[0];if(I){if(!I.type.startsWith("image/")){x("Le fichier doit \xEAtre une image");return}if(I.size>o){x(`Le fichier est trop volumineux (max ${y}MB)`);return}m(true),x(null);try{if(r){let W=await r(I);t(W);}else {let W=await sh(I);t(W);}b.current&&(b.current.value="");}catch(W){console.error("Upload error:",W),x(W instanceof Error?W.message:"Erreur lors de l'upload");}finally{m(false);}}},[o,y,t,r]),P=useCallback(()=>{t(""),b.current&&(b.current.value=""),x(null);},[t]),h=useCallback(k=>{t(k),x(null);},[t]),E=useCallback(()=>{b.current?.click();},[]),D=useCallback(k=>{h(k.target.value);},[h]);return jsxs("div",{className:`space-y-2 ${i}`,children:[n&&jsx("label",{className:"block text-sm font-semibold text-gray-700 dark:text-gray-300",children:n}),e&&jsxs("div",{className:"relative w-full overflow-hidden rounded-lg border border-gray-300 dark:border-gray-600 bg-gray-50 dark:bg-gray-800/50",children:[jsx("div",{className:`relative ${ah[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:P,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:b,type:"file","aria-label":"Choisir une image",accept:a,onChange:w,className:"hidden",disabled:l||f}),jsx("button",{type:"button",onClick:E,disabled:l||f,className:"px-3 py-2 text-sm border border-gray-300 dark:border-gray-600 rounded-md hover:bg-gray-50 dark:hover:bg-gray-700 disabled:opacity-50 disabled:cursor-not-allowed transition-colors cursor-pointer bg-white dark:bg-gray-800 text-gray-700 dark:text-gray-200",children:f?"\u23F3 Upload...":e?"\u{1F4C1} Changer l'image":"\u{1F4C1} Choisir une image"})]}),d&&jsxs("div",{className:"space-y-1",children:[jsx("label",{htmlFor:v,className:"block text-xs text-gray-500 dark:text-gray-400",children:"Ou URL directe :"}),jsx("input",{id:v,type:"url",value:e||"",onChange:D,placeholder:c,disabled:l,className:"w-full px-3 py-2 text-sm border border-gray-300 dark:border-gray-600 rounded-md focus:ring-2 focus:ring-blue-500 focus:border-blue-500 dark:bg-gray-800 dark:text-gray-200 disabled:opacity-50 disabled:cursor-not-allowed"})]}),g&&jsxs("div",{className:"text-red-600 dark:text-red-400 text-sm bg-red-50 dark:bg-red-900/20 p-2 rounded border border-red-200 dark:border-red-800",children:["\u274C ",g]}),jsx("div",{className:"text-xs text-gray-500 dark:text-gray-400",children:s||M})]})}var Qa={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"},ki={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"},lh={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"},Ci={"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"},wi={"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 dh(e,t){return e>t?`${t}+`:`${e}`}function ch({color:e="primary",size:t="md",placement:r="top-right",bordered:n=false,borderColor:o,pulse:a=false,offset:s=false,className:l,...i}){return jsx("span",{"data-testid":"indicator",className:u("absolute z-10 rounded-full",Qa[e],ki[t],s?wi[r]:Ci[r],n&&u("ring-2 ring-white dark:ring-gray-900",o),a&&"animate-pulse",l),...i})}function uh({color:e="error",size:t="md",placement:r="top-right",count:n=0,maxCount:o=99,bordered:a=false,borderColor:s,pulse:l=false,offset:i=false,className:d,...c}){return jsx("span",{"data-testid":"indicator",className:u("absolute z-10 inline-flex items-center justify-center rounded-full font-semibold text-white",Qa[e],lh[t],i?wi[r]:Ci[r],a&&u("ring-2 ring-white dark:ring-gray-900",s),l&&"animate-pulse",d),...c,children:dh(n,o)})}function ph({color:e="success",size:t="md",placement:r="bottom-right",bordered:n=true,borderColor:o,pulse:a=false,offset:s=false,className:l,...i}){return jsx("span",{"data-testid":"indicator",className:u("absolute z-10 rounded-full",Qa[e],ki[t],s?wi[r]:Ci[r],n&&u("ring-2 ring-white dark:ring-gray-900",o),a&&"animate-pulse",l),...i})}function mh({color:e="primary",size:t="sm",label:r,className:n,...o}){return jsxs("span",{"data-testid":"indicator",className:u("inline-flex items-center gap-2",n),...o,children:[jsx("span",{className:u("rounded-full shrink-0",Qa[e],ki[t])}),r?jsx("span",{className:"text-sm text-gray-700 dark:text-gray-300",children:r}):null]})}function fc({variant:e="dot",children:t,...r}){if(e==="legend")return jsx(mh,{...r});let n=(()=>{switch(e){case "count":return jsx(uh,{...r});case "status":return jsx(ph,{...r});default:return jsx(ch,{...r})}})();return t?jsxs("div",{className:"relative inline-flex",children:[t,n]}):n}fc.displayName="Indicator";var gh={xs:"text-xs",sm:"text-sm",md:"text-sm",lg:"text-base",xl:"text-lg"},hc={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"},fh={normal:"font-normal",medium:"font-medium",semibold:"font-semibold",bold:"font-bold"},bh={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 xc({children:e,size:t="md",color:r="default",variant:n="default",weight:o="medium",textColor:a,required:s=false,requiredIndicator:l="*",optional:i=false,optionalText:d="(optional)",tooltip:c,icon:p,endIcon:f,disabled:m=false,truncate:g=false,as:x="label",className:b,...v}){let y=x,M=u("inline-flex items-center gap-1.5 transition-colors",gh[t],fh[o]),w=a||bh[r][n];return jsxs(y,{className:u(M,w,m?"opacity-50 cursor-not-allowed":"cursor-default",b),title:c,"aria-disabled":m,...v,children:[p&&jsx("span",{className:u("shrink-0",hc[t]),children:p}),jsxs("span",{className:u(g&&"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}),f&&jsx("span",{className:u("shrink-0",hc[t]),children:f})]})}xc.displayName="Label";var xh=2,vh=2,kh=12,Ch=16,vc="cell:",kc=false,wh=memo(function({cells:t,radius:r}){return jsx("g",{children:t.map(n=>jsxs("g",{children:[jsx("rect",{x:n.x,y:n.y,width:n.width,height:n.height,rx:r,fill:n.missing?void 0:n.color,className:n.missing?"fill-gray-100 dark:fill-gray-800":void 0}),n.label?jsx("text",{x:n.x+n.width/2,y:n.y+n.height/2,textAnchor:"middle",dominantBaseline:"central",className:u("text-[10px] [font-variant-numeric:tabular-nums]",n.onDark?"fill-gray-50 dark:fill-gray-900":"fill-gray-900 dark:fill-gray-50"),children:n.label}):null]},n.key))})});function Nh({width:e,height:t,columns:r,rows:n,lookup:o,colorScale:a,x:s,y:l,size:i,cellGap:d,cellRadius:c,showValues:p,tooltip:f,plotLabel:m,formatValue:g,formatX:x,formatY:b,onCellClick:v}){let[y,M]=useState(null),w=useMemo(()=>{let I=r.map((A,B)=>x(A,B)),W=n.map((A,B)=>b(A,B)),O={top:8,right:8,bottom:s.hidden?8:s.height??24+(s.label?16:0),left:l.hidden?8:l.height??br(W)+kh+(l.label?16:0)},L=Math.max(0,e-O.left-O.right),T=Math.max(0,t-O.top-O.bottom),S=Rn(r.map((A,B)=>B),[0,L],{paddingInner:0,paddingOuter:0}),C=Rn(n.map((A,B)=>B),[0,T],{paddingInner:0,paddingOuter:0}),N=Math.max(0,S.bandwidth-d),R=Math.max(0,C.bandwidth-d),$=[];n.forEach((A,B)=>{r.forEach((U,Q)=>{let Y=o.get(`${dt(U)}|${dt(A)}`)?.value??null,z=null;if(p&&Y!==null&&R>=Ch){let X=g(Y);Sn(X,10)+6<=N&&(z=X);}$.push({key:`${Q}-${B}`,column:Q,row:B,x:S(Q)+d/2,y:C(B)+d/2,width:N,height:R,color:Y===null?"transparent":a(Y),label:z,onDark:Y!==null&&a.onDark(Y),missing:Y===null});});});let H=Io(I.length,L,br(I)),K=Io(W.length,T,15),_=s.hidden?[]:I.map((A,B)=>({value:r[B],offset:S.center(B),label:A})).filter((A,B)=>B%H===0),F=l.hidden?[]:W.map((A,B)=>({value:n[B],offset:C.center(B),label:A})).filter((A,B)=>B%K===0);return {margin:O,innerWidth:L,innerHeight:T,columnScale:S,rowScale:C,cells:$,columnTicks:_,rowTicks:F}},[r,n,o,a,s,l,e,t,d,p,g,x,b]),P=useCallback((I,W)=>{let O=r[I],L=n[W],T=o.get(`${dt(O)}|${dt(L)}`),S=T?.value??null;return {x:O,y:L,xLabel:x(O,I),yLabel:b(L,W),value:S,formattedValue:S===null?"\u2014":g(S),color:S===null?"transparent":a(S),datum:T?.datum}},[r,n,o,a,g,x,b]),h=useCallback(I=>{if(f===false||r.length===0||n.length===0)return;let W=I.currentTarget.getBoundingClientRect(),O=I.clientX-W.left-w.margin.left,L=I.clientY-W.top-w.margin.top,T=Math.floor(O/(w.columnScale.step||1)),S=Math.floor(L/(w.rowScale.step||1));if(T<0||T>=r.length||S<0||S>=n.length){M(null);return}M(C=>C?.column===T&&C.row===S?C:{column:T,row:S});},[f,r.length,n.length,w.margin,w.columnScale,w.rowScale]),E=useCallback(I=>{if(r.length===0||n.length===0)return;let W=y??{column:0,row:0},O;switch(I.key){case "ArrowRight":O={...W,column:Math.min(r.length-1,W.column+1)};break;case "ArrowLeft":O={...W,column:Math.max(0,W.column-1)};break;case "ArrowDown":O={...W,row:Math.min(n.length-1,W.row+1)};break;case "ArrowUp":O={...W,row:Math.max(0,W.row-1)};break;case "Home":O={...W,column:0};break;case "End":O={...W,column:r.length-1};break;case "Escape":O=null;break;default:O=void 0;}O!==void 0&&(I.preventDefault(),M(O));},[r.length,n.length,y]),D=useCallback(()=>{!v||!y||v(P(y.column,y.row));},[v,y,P]),k=y?P(y.column,y.row):null;return jsxs(Fragment,{children:[jsxs("svg",{width:e,height:t,role:"img","aria-label":m??`${s.label??s.key} / ${l.label??l.key}`,tabIndex:0,className:"touch-none focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-blue-500",onPointerMove:h,onPointerLeave:()=>M(null),onKeyDown:E,onBlur:()=>M(null),onClick:D,children:[jsxs("g",{transform:`translate(${w.margin.left}, ${w.margin.top})`,children:[jsx(wh,{cells:w.cells,radius:c}),y?jsx("rect",{x:w.columnScale(y.column)+d/2,y:w.rowScale(y.row)+d/2,width:Math.max(0,w.columnScale.bandwidth-d),height:Math.max(0,w.rowScale.bandwidth-d),rx:c,fill:"none",strokeWidth:2,className:"stroke-gray-900 dark:stroke-white","aria-hidden":"true"}):null]}),jsx("g",{transform:`translate(${w.margin.left}, ${w.margin.top+w.innerHeight})`,children:s.hidden?null:jsx(St,{orientation:"bottom",ticks:w.columnTicks,length:w.innerWidth,showLine:false,tickSize:0,label:s.label,size:i})}),jsx("g",{transform:`translate(${w.margin.left}, ${w.margin.top})`,children:l.hidden?null:jsx(St,{orientation:"left",ticks:w.rowTicks,length:w.innerHeight,showLine:false,tickSize:0,label:l.label,size:i})})]}),y&&k&&f!==false?jsx(jt,{x:w.margin.left+w.columnScale.center(y.column),y:w.margin.top+w.rowScale.center(y.row),containerWidth:e,children:typeof f=="function"?f(k):jsxs("div",{className:"flex flex-col gap-1",children:[jsxs("div",{className:"font-medium text-gray-900 dark:text-gray-100",children:[k.yLabel," \xB7 ",k.xLabel]}),jsxs("div",{className:"flex items-center gap-2",children:[jsx("span",{className:"h-2.5 w-2.5 shrink-0 rounded-sm",style:{backgroundColor:k.color},"aria-hidden":"true"}),jsx("span",{className:"font-semibold text-gray-900 [font-variant-numeric:tabular-nums] dark:text-gray-100",children:k.formattedValue})]})]})}):null]})}function Cc(e,t,r){if(r)return r;let n=new Map;return e.forEach((o,a)=>{let s=Ut(o,t,a),l=dt(s);n.has(l)||n.set(l,s);}),[...n.values()]}function Sh({data:e,x:t,y:r,value:n,format:o,domain:a,scale:s="sequential",center:l=0,steps:i,colors:d,xDomain:c,yDomain:p,cellGap:f=xh,cellRadius:m=vh,showValues:g=false,height:x=280,width:b,size:v="md",legend:y=true,legendLabel:M,tooltip:w=true,tableView:P=false,title:h,description:E,loading:D=false,emptyState:k,locale:I,plotLabel:W,onCellClick:O,className:L,...T}){i!==void 0&&i>Ta&&!kc&&(kc=true,console.warn(`[@synertech/ui] A Heatmap was cut into ${i} colour classes. Past ${Ta} two neighbouring cells stop being tellable apart: leave \`steps\` unset and let the ramp stay continuous.`));let S=useMemo(()=>Cc(e,t.key,c),[e,t.key,c]),C=useMemo(()=>Cc(e,r.key,p),[e,r.key,p]),N=useMemo(()=>{let U=new Map;return e.forEach((Q,J)=>{let Y=et(Q,n);if(Y===null)return;let z=Ut(Q,t.key,J),X=Ut(Q,r.key,J);U.set(`${dt(z)}|${dt(X)}`,{value:Y,datum:Q});}),U},[e,t.key,r.key,n]),R=useMemo(()=>o??(U=>vt(U,I)),[o,I]),$=useMemo(()=>t.format??(U=>bt(U,I)),[t.format,I]),H=useMemo(()=>r.format??(U=>bt(U,I)),[r.format,I]),K=useMemo(()=>{let U=a??Ot([...N.values()].map(Q=>Q.value))??[0,1];return s==="diverging"?qn(U,{center:l,steps:i,colors:d}):Bs(U,{steps:i,colors:d})},[a,N,s,l,i,d]),_=useMemo(()=>C.map(U=>{let Q={[r.key]:U};return S.forEach(J=>{Q[`${vc}${dt(J)}`]=N.get(`${dt(J)}|${dt(U)}`)?.value??null;}),Q}),[C,S,N,r.key]),F=useMemo(()=>S.map((U,Q)=>({key:`${vc}${dt(U)}`,label:$(U,Q)})),[S,$]),A=y!==false,B=typeof y=="string"?y:"bottom";return jsx(Kt,{title:h,description:E,height:x,width:b,size:v,loading:D,empty:N.size===0,emptyState:k,tableView:P,legendPosition:B,legend:A?jsx(Bo,{scale:K,label:M,format:R,size:v,locale:I}):void 0,table:P?jsx(Yt,{data:_,series:F,xKey:r.key,xLabel:r.label??r.key,formatX:H,formatValue:R,caption:typeof h=="string"?h:void 0}):void 0,className:L,...T,children:({width:U})=>jsx(Nh,{width:U,height:x,columns:S,rows:C,lookup:N,colorScale:K,x:t,y:r,size:v,cellGap:f,cellRadius:m,showValues:g,tooltip:w,plotLabel:W,formatValue:R,formatX:$,formatY:H,onCellClick:O})})}var Ph=24,Eh=10,Dh=10,Mh=memo(function({lines:t,showMarkers:r}){return jsx("g",{children:t.map(n=>jsxs("g",{children:[n.solid?jsx("path",{d:n.solid,fill:"none",stroke:n.color,strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"}):null,n.dashed?jsx("path",{d:n.dashed,fill:"none",stroke:n.color,strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round",strokeDasharray:"5 4"}):null,r?n.markers.map(o=>jsx("circle",{cx:o.x,cy:o.y,r:3,fill:n.color,strokeWidth:2,className:"stroke-white dark:stroke-gray-800"},`${o.x}-${o.y}`)):null]},n.key))})});function Ih({width:e,height:t,data:r,resolvedSeries:n,x:o,y:a,grid:s,size:l,curve:i,forecastFrom:d,forecastLabel:c,markers:p,connectNulls:f,referenceLines:m,margin:g,tooltip:x,onPointClick:b,plotLabel:v,formatValue:y,formatX:M}){let[w,P]=useState(null),h=useMemo(()=>{let T=n.filter(K=>!K.hidden),S=cn({width:e,height:t,data:r,x:o,y:a,bounds:Ot(ir(r,T.map(K=>K.key))),margin:g,placement:"point",formatValue:y,formatX:M,extraTop:c?Eh:0}),C=S.categoryCenters,N=S.valueScale,R=d===void 0?-1:S.xValues.findIndex(K=>dt(K)===dt(d)),$=T.map(K=>{let _=r.map((B,U)=>{let Q=et(B,K.key);return {x:C[U],y:Q===null?Number.NaN:N(Q),defined:Q!==null}}),F={connectNulls:f},A=R>=0;return {key:K.key,color:K.color,solid:K.dashed?"":Yr(A?_.slice(0,R+1):_,i,F),dashed:K.dashed?Yr(_,i,F):A?Yr(_.slice(R),i,F):"",markers:_.filter(B=>B.defined!==false)}}),H=r.length>1?S.innerWidth/(r.length-1):0;return {visible:T,xValues:S.xValues,xPositions:C,xTicks:S.categoryTicks,yTicks:S.valueTicks,yScale:N,innerWidth:S.innerWidth,innerHeight:S.innerHeight,margin:S.margin,lines:$,forecastIndex:R,showMarkers:p==="always"||p==="auto"&&H>=Ph&&r.length>1}},[r,n,o,a,e,t,g,i,f,d,c,p,y,M]),E=useCallback(T=>h.visible.map(S=>{let C=et(r[T],S.key);return {seriesKey:S.key,seriesLabel:Bt(S),color:S.color,value:C,formattedValue:C===null?"\u2014":y(C),datum:r[T]}}),[r,h.visible,y]),D=useCallback(T=>{if(x===false||r.length===0)return;let S=T.currentTarget.getBoundingClientRect(),C=T.clientX-S.left-h.margin.left,N=dn(h.xPositions,C);P(N>=0?N:null);},[x,r.length,h.margin.left,h.xPositions]),k=useCallback(T=>{if(r.length===0)return;let S=r.length-1,C=w??0,N=T.key==="ArrowRight"?Math.min(S,C+1):T.key==="ArrowLeft"?Math.max(0,C-1):T.key==="Home"?0:T.key==="End"?S:T.key==="Escape"?null:void 0;N!==void 0&&(T.preventDefault(),P(N));},[r.length,w]),I=useCallback(()=>{if(!b||w===null)return;let[T]=E(w);T&&b({...T,index:w,x:h.xValues[w]});},[b,w,E,h.xValues]),W=w===null?null:E(w),O=(W??[]).filter(T=>T.value!==null),L=w===null||W===null?null:{x:h.xValues[w],xLabel:M(h.xValues[w],w),index:w,points:W};return jsxs(Fragment,{children:[jsxs("svg",{width:e,height:t,role:"img","aria-label":v??h.visible.map(T=>Bt(T)).join(", "),tabIndex:0,className:"touch-none focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-blue-500",onPointerMove:D,onPointerLeave:()=>P(null),onKeyDown:k,onBlur:()=>P(null),onClick:I,children:[jsxs("g",{transform:`translate(${h.margin.left}, ${h.margin.top})`,children:[jsx(Kr,{width:h.innerWidth,height:h.innerHeight,horizontal:s==="y"||s==="both"?h.yTicks.map(T=>T.offset):void 0,vertical:s==="x"||s==="both"?h.xTicks.map(T=>T.offset):void 0}),m?.map(T=>{let S=h.yScale(T.value),C=S<Dh?S+12:S-4;return jsxs("g",{children:[jsx("line",{x1:0,y1:S,x2:h.innerWidth,y2:S,stroke:T.color??"var(--color-chart-muted)",strokeWidth:1,strokeDasharray:T.dashed===false?void 0:"4 4"}),T.label?jsx("text",{x:h.innerWidth,y:C,textAnchor:"end",className:"fill-gray-500 text-[10px] dark:fill-gray-400",children:T.label}):null]},`${T.value}-${T.label??""}`)}),h.forecastIndex>=0?jsxs("g",{children:[jsx("line",{x1:h.xPositions[h.forecastIndex],y1:0,x2:h.xPositions[h.forecastIndex],y2:h.innerHeight,className:"stroke-gray-300 dark:stroke-gray-600",strokeWidth:1,strokeDasharray:"3 3"}),c?jsx("text",{x:h.xPositions[h.forecastIndex]+4,y:-2,className:"fill-gray-500 text-[10px] dark:fill-gray-400",children:c}):null]}):null,jsx(Mh,{lines:h.lines,showMarkers:h.showMarkers}),w!==null?jsxs("g",{"aria-hidden":"true",children:[jsx("line",{x1:h.xPositions[w],y1:0,x2:h.xPositions[w],y2:h.innerHeight,className:"stroke-gray-400 dark:stroke-gray-500",strokeWidth:1}),O.map(T=>jsx("circle",{cx:h.xPositions[w],cy:h.yScale(T.value),r:4,fill:T.color,strokeWidth:2,className:"stroke-white dark:stroke-gray-800"},T.seriesKey))]}):null]}),jsx("g",{transform:`translate(${h.margin.left}, ${h.margin.top+h.innerHeight})`,children:o.hidden?null:jsx(St,{orientation:"bottom",ticks:h.xTicks,length:h.innerWidth,label:o.label,size:l})}),jsx("g",{transform:`translate(${h.margin.left}, ${h.margin.top})`,children:a?.hidden?null:jsx(St,{orientation:"left",ticks:h.yTicks,length:h.innerHeight,showLine:false,label:a?.label,size:l})})]}),L&&x!==false?jsx(jt,{x:h.margin.left+h.xPositions[L.index],y:h.margin.top+(O.length>0?Math.min(...O.map(T=>h.yScale(T.value))):h.innerHeight/2),containerWidth:e,children:typeof x=="function"?x(L):jsx(vr,{title:L.xLabel,points:L.points})}):null]})}function Lh({data:e,series:t,x:r,y:n,height:o=240,width:a,size:s="md",grid:l="y",legend:i,tooltip:d=true,tableView:c=false,emphasis:p,title:f,description:m,loading:g=false,emptyState:x,onPointClick:b,curve:v="monotone",forecastFrom:y,forecastLabel:M,markers:w="auto",connectNulls:P=false,referenceLines:h,legendToggle:E=true,margin:D,locale:k,plotLabel:I,className:W,...O}){let[L,T]=useState(()=>new Set),S=useMemo(()=>t.map((_,F)=>({..._,hidden:_.hidden||L.has(_.key),color:Ir(_,F,p)})),[t,L,p]),C=useMemo(()=>n?.format??(_=>vt(_,k)),[n?.format,k]),N=useMemo(()=>r.format??(_=>r.scale==="time"?bt(_ instanceof Date?_:new Date(Lr(_)),k):bt(_,k)),[r.format,r.scale,k]),R=useCallback(_=>{T(F=>{let A=new Set(F);return A.has(_)?A.delete(_):A.add(_),A});},[]),$=i===void 0?t.length>=2:i!==false,H=typeof i=="string"?i:"bottom",K=S.filter(_=>!_.hidden).length;return jsx(Kt,{title:f,description:m,height:o,width:a,size:s,loading:g,empty:e.length===0||K===0,emptyState:x,tableView:c,legendPosition:H,legend:$?jsx(yr,{items:Ur(S,p),position:H,marker:"line",size:s,onToggle:E?R:void 0}):void 0,table:c?jsx(Yt,{data:e,series:S,xKey:r.key,xLabel:r.label??r.key,formatX:N,formatValue:C,caption:typeof f=="string"?f:void 0}):void 0,className:W,...O,children:({width:_})=>jsx(Ih,{width:_,height:o,data:e,resolvedSeries:S,x:r,y:n,grid:l,size:s,curve:v,forecastFrom:y,forecastLabel:M,markers:w,connectNulls:P,referenceLines:h,margin:D,tooltip:d,onPointClick:b,plotLabel:I,formatValue:C,formatX:N})})}var Fh={sm:"max-w-sm",md:"max-w-2xl",lg:"max-w-4xl",xl:"max-w-6xl",full:"max-w-full"},rn=forwardRef(({isOpen:e,onClose:t,title:r="Modal Title",children:n,buttonLabel:o,onButtonClick:a,className:s,allowFullScreen:l=false,showSubmit:i=true,submitLabel:d,onSubmitClick:c,showCancel:p=false,cancelLabel:f,onCancelClick:m,buttonsPosition:g="right",showHeaderDivider:x=true,showFooterDivider:b=true,description:v,icon:y,size:M="md",reverseButtons:w=false,headerClassName:P,contentClassName:h,footerClassName:E,titleClassName:D,descriptionClassName:k,submitClassName:I,cancelClassName:W,closeLabel:O,enterFullScreenLabel:L,exitFullScreenLabel:T,"aria-label":S,closeOnEscape:C=true,trapFocus:N=true,initialFocus:R,returnFocus:$,lockScroll:H=true},K)=>{let[_,F]=useState(false),A=At(),B=useId(),U=`${B}-title`,Q=`${B}-description`,{dialogRef:J,dialogProps:Y}=An({open:e,onClose:t,closeOnEscape:C,trapFocus:N,initialFocus:R,returnFocus:$,lockScroll:H});if(!e)return null;let z=o??d??A.confirm,X=f??A.cancel,ne=O??A.closeModal,re=_?T??A.exitFullScreen:L??A.enterFullScreen,q=a??c,de=async()=>{q&&await q(),t();},xe=async()=>{m&&await m(),t();};return jsx("div",{className:u("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:u("relative p-4 w-full max-h-full transition-all duration-300",_?"max-w-full h-full p-0":Fh[M]),ref:K,children:jsxs("div",{...Y,ref:J,"aria-labelledby":r?U:void 0,"aria-label":r?void 0:S,"aria-describedby":v?Q:void 0,className:u("relative bg-white shadow dark:bg-gray-700 border-b-4 transition-all duration-300 focus:outline-none",_?"rounded-none h-full flex flex-col":"rounded-lg"),children:[jsxs("div",{className:u("flex items-center justify-between p-4 md:p-5 rounded-t",x&&"border-b border-gray-200 dark:border-gray-600",P),children:[jsxs("div",{className:"flex items-center gap-3",children:[y&&jsx("div",{className:"shrink-0 text-gray-500 dark:text-gray-400",children:y}),jsxs("div",{children:[jsx("h3",{id:U,className:u("text-xl font-semibold text-gray-900 dark:text-white",D),children:r}),v&&jsx("p",{id:Q,className:u("mt-1 text-sm text-gray-500 dark:text-gray-400",k),children:v})]})]}),jsxs("div",{className:"flex items-center gap-1 ms-auto",children:[l&&jsx("button",{type:"button",onClick:()=>F(ke=>!ke),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:_?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:ne})]})]})]}),jsx("div",{className:u("p-4 md:p-5 space-y-4",_&&"flex-1 overflow-y-auto",h),children:n}),(i||p)&&jsxs("div",{className:u("flex items-center gap-2 p-4 md:p-5 rounded-b",b&&"border-t border-gray-200 dark:border-gray-600",g==="right"?"justify-end":g==="center"?"justify-center":"justify-start",w&&"flex-row-reverse",E),children:[p&&jsx("button",{type:"button",onClick:xe,className:u("text-gray-500 bg-white hover:bg-gray-100 focus:ring-4 focus:outline-none focus:ring-gray-200 font-medium rounded-lg text-sm px-5 py-2.5 border border-gray-200 dark:bg-gray-700 dark:text-gray-300 dark:border-gray-500 dark:hover:bg-gray-600 dark:hover:text-white",W),children:X}),i&&jsx("button",{type:"button",onClick:de,className:u("text-white bg-blue-600 hover:bg-blue-700 focus:ring-4 focus:outline-none focus:ring-blue-300 font-medium rounded-lg text-sm px-5 py-2.5 text-center dark:bg-blue-500 dark:hover:bg-blue-600",I),children:z})]})]})})})});rn.displayName="Modal";function Oh(e,t,r,n){let o=r*2+1+n*2+2;if(t<=o)return Array.from({length:t},(f,m)=>m+1);let a=Array.from({length:n},(f,m)=>m+1).filter(f=>f<=t),s=Array.from({length:n},(f,m)=>t-n+1+m).filter(f=>f>=1),l=Math.max(e-r,n+1),i=Math.min(e+r,t-n),d=l>n+2,c=i<t-n-1,p=[];for(let f of a)p.push(f);if(d)p.push("ellipsis");else for(let f=n+1;f<l;f++)p.push(f);for(let f=l;f<=i;f++)p.push(f);if(c)p.push("ellipsis");else for(let f=i+1;f<=t-n;f++)p.push(f);for(let f of s)p.includes(f)||p.push(f);return p}function $h({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 _h({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 Xh({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 Gh({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 Kh={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"}},Uh={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 Yh({page:e,totalPages:t,onPageChange:r,size:n="md",variant:o="default",showFirstLast:a=false,siblings:s=1,boundaries:l=1,disabled:i=false,labels:d,totalItems:c,pageSize:p,pageSizeOptions:f,onPageSizeChange:m,className:g,...x}){let b=Kh[n],v=Uh[o],y=useMemo(()=>Oh(e,t,s,l),[e,t,s,l]),M=useCallback(I=>{i||I<1||I>t||I===e||r(I);},[i,t,e,r]),w=e<=1,P=e>=t,h=u("inline-flex items-center justify-center select-none",b.button,v.base),E=(I,W,O,L)=>jsx("button",{type:"button",onClick:I,disabled:i||W,"aria-label":O,"aria-disabled":i||W,className:u(h,i||W?v.disabled:v.idle),children:L}),D=c!==void 0&&p?(e-1)*p+1:void 0,k=c!==void 0&&p?Math.min(e*p,c):void 0;return jsxs("nav",{"aria-label":"Pagination",className:u("flex items-center",b.gap,g),...x,children:[c!==void 0&&p&&jsxs("span",{className:u("mr-2 text-gray-600 dark:text-gray-400 whitespace-nowrap",b.text),children:[D,"\u2013",k," of ",c]}),f&&f.length>0&&m&&jsxs("div",{className:u("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:I=>m(Number(I.target.value)),disabled:i,className:u("rounded border border-gray-300 bg-white px-1.5 py-0.5 dark:border-gray-600 dark:bg-gray-800 dark:text-gray-200",b.text,i&&"cursor-not-allowed opacity-50"),children:f.map(I=>jsx("option",{value:I,children:I},I))})]}),jsxs("div",{className:u("flex items-center",b.gap),children:[a&&E(()=>M(1),w,d?.first??"Go to first page",jsx(Xh,{className:b.icon})),E(()=>M(e-1),w,d?.previous??"Go to previous page",jsx($h,{className:b.icon})),y.map((I,W)=>I==="ellipsis"?jsx("span",{className:u("inline-flex items-center justify-center select-none",b.button,"text-gray-400 dark:text-gray-500"),"aria-hidden":"true",children:"\u2026"},`ellipsis-${W}`):jsx("button",{type:"button",onClick:()=>M(I),disabled:i,"aria-current":I===e?"page":void 0,"aria-label":`Page ${I}`,className:u(h,I===e?v.active:i?v.disabled:v.idle),children:I},I)),E(()=>M(e+1),P,d?.next??"Go to next page",jsx(_h,{className:b.icon})),a&&E(()=>M(t),P,d?.last??"Go to last page",jsx(Gh,{className:b.icon}))]})]})}var qh=.62,Zh=2,Qh=3,Jh=.16,ey=64,ty=22,Ni=6,Nc=false;function ry({width:e,height:t,slices:r,variant:n,innerRadius:o,showLabels:a,centerLabel:s,tooltip:l,plotLabel:i,formatValue:d,onSliceClick:c}){let[p,f]=useState(null),m=useMemo(()=>{let h=a?ey:8,E=a?ty:8,D=Math.max(0,Math.min((e-h*2)/2,(t-E*2)/2));return {cx:e/2,cy:t/2,outerRadius:D,inner:n==="donut"?D*(o??qh):(o??0)*D,pad:D>0&&r.length>1?Zh/D/2:0}},[e,t,n,o,a,r.length]),{cx:g,cy:x,outerRadius:b,inner:v,pad:y}=m,M=useCallback(h=>{let E=(h.startAngle+h.endAngle)/2,D=Math.sin(E)>=0,k={x:g+Math.sin(E)*(b+4),y:x-Math.cos(E)*(b+4)},I={x:g+Math.sin(E)*(b+14),y:x-Math.cos(E)*(b+14)},W={x:D?I.x+10:I.x-10,y:I.y};return {from:k,elbow:I,end:W,anchor:D?"start":"end"}},[g,x,b]),w=useCallback(h=>{if(r.length===0)return;let E=r.length-1,D=p??0,k=h.key==="ArrowRight"||h.key==="ArrowDown"?Math.min(E,D+1):h.key==="ArrowLeft"||h.key==="ArrowUp"?Math.max(0,D-1):h.key==="Home"?0:h.key==="End"?E:h.key==="Escape"?null:void 0;k!==void 0&&(h.preventDefault(),f(k));},[r.length,p]),P=p===null?null:r[p];return jsxs(Fragment,{children:[jsxs("svg",{width:e,height:t,role:"img","aria-label":i??r.map(h=>h.label).join(", "),tabIndex:0,className:"touch-none focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-blue-500",onPointerLeave:()=>f(null),onBlur:()=>f(null),onKeyDown:w,children:[r.map((h,E)=>jsx("path",{d:Fl({cx:g,cy:x,innerRadius:v,outerRadius:b+(p===E?Qh:0),startAngle:h.startAngle+y,endAngle:Math.max(h.startAngle+y,h.endAngle-y)}),fill:h.color,onPointerEnter:()=>l===false?void 0:f(E),onClick:()=>c?.({key:h.key,label:h.label,value:h.value,share:h.share})},h.key)),a?r.filter(h=>h.endAngle-h.startAngle>=Jh).map(h=>{let{from:E,elbow:D,end:k,anchor:I}=M(h);return jsxs("g",{"aria-hidden":"true",children:[jsx("polyline",{points:`${E.x},${E.y} ${D.x},${D.y} ${k.x},${k.y}`,fill:"none",className:"stroke-gray-300 dark:stroke-gray-600",strokeWidth:1}),jsx("text",{x:I==="start"?k.x+3:k.x-3,y:k.y,textAnchor:I,dominantBaseline:"middle",className:"fill-gray-600 text-[10px] dark:fill-gray-300",children:h.label})]},`label-${h.key}`)}):null,n==="donut"&&s?jsxs("g",{"aria-hidden":"true",children:[jsx("text",{x:g,y:x-(s.label?2:0),textAnchor:"middle",dominantBaseline:"middle",className:"fill-gray-900 text-lg font-semibold dark:fill-gray-100",children:s.value}),s.label?jsx("text",{x:g,y:x+14,textAnchor:"middle",dominantBaseline:"middle",className:"fill-gray-500 text-[10px] dark:fill-gray-400",children:s.label}):null]}):null]}),P&&l!==false?jsx(jt,{x:g+Math.sin((P.startAngle+P.endAngle)/2)*(b*.7),y:x-Math.cos((P.startAngle+P.endAngle)/2)*(b*.7),containerWidth:e,children:typeof l=="function"?l({seriesKey:P.key,seriesLabel:P.label,color:P.color,value:P.value,formattedValue:d(P.value),datum:{},share:P.share}):jsx(vr,{title:P.label,points:[{seriesKey:P.key,seriesLabel:xr(P.share),color:P.color,value:P.value,formattedValue:d(P.value),datum:{}}]})}):null]})}function ny({data:e,x:t,value:r,variant:n="pie",innerRadius:o,maxSlices:a=Ni,otherLabel:s,sort:l="desc",showLabels:i=true,centerLabel:d,height:c=260,width:p,size:f="md",legend:m,tooltip:g=true,tableView:x=false,title:b,description:v,loading:y=false,emptyState:M,locale:w,plotLabel:P,onSliceClick:h,className:E,...D}){let k=At(),I=useCallback(N=>vt(N,w),[w]),W=useCallback(N=>t.format?t.format(N,0):bt(N,w),[t,w]),{slices:O,total:L,rows:T}=useMemo(()=>{let N=e.map((A,B)=>({key:String(Ut(A,t.key,B)),label:W(Ut(A,t.key,B)),value:et(A,r)??0,color:jn(B),datum:A})),R=l==="none"?N:[...N].sort((A,B)=>l==="asc"?A.value-B.value:B.value-A.value),$=R.slice(0,a),H=R.slice(a);H.length>0&&$.push({key:"__other__",label:s??k.chartOther,value:H.reduce((A,B)=>A+B.value,0),color:Mr,datum:{}}),$.length>Ni&&!Nc&&(Nc=true,console.warn(`[@synertech/ui] A PieChart is drawing ${$.length} slices. Past ${Ni} the slices stop being tellable apart: lower \`maxSlices\`, or use a BarChart, which compares lengths rather than angles.`));let K=$.reduce((A,B)=>A+Math.max(0,B.value),0),_=0;return {slices:$.map(A=>{let B=K===0?0:Math.max(0,A.value)/K,U=_;return _+=B*Math.PI*2,{...A,share:B,startAngle:U,endAngle:_}}),total:K,rows:$.map(A=>({[t.key]:A.label,[r]:A.value}))}},[e,t.key,r,l,a,s,k.chartOther,W]),S=m===void 0?true:m!==false,C=typeof m=="string"?m:"bottom";return jsx(Kt,{title:b,description:v,height:c,width:p,size:f,loading:y,empty:O.length===0||L===0,emptyState:M,tableView:x,legendPosition:C,legend:S?jsx(yr,{items:O.map(N=>({key:N.key,label:`${N.label} \xB7 ${xr(N.share)}`,color:N.color})),position:C,marker:"rect",size:f}):void 0,table:x?jsx(Yt,{data:T,series:[{key:r,label:t.label??r}],xKey:t.key,xLabel:t.label??t.key,formatValue:I,caption:typeof b=="string"?b:void 0}):void 0,className:E,...D,children:({width:N})=>jsx(ry,{width:N,height:c,slices:O,variant:n,innerRadius:o,showLabels:i,centerLabel:d,tooltip:g,plotLabel:P,formatValue:I,onSliceClick:h})})}var ay={xs:"h-1",sm:"h-1.5",md:"h-2.5",lg:"h-4",xl:"h-6"},sy={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"},iy={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"},Rc="bg-[repeating-linear-gradient(45deg,transparent,transparent_10px,rgba(255,255,255,0.2)_10px,rgba(255,255,255,0.2)_20px)]",ly={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 Pc({value:e=0,indeterminate:t=false,size:r="md",color:n="primary",variant:o="default",showValue:a=false,valueFormat:s,label:l,animated:i=true,className:d,...c}){let p=Math.min(100,Math.max(0,e)),f=o==="gradient"?ly[n]:sy[n],m=s?s(p):`${Math.round(p)}%`;return jsxs("div",{className:u("w-full",d),...c,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:u("text-sm font-semibold",iy[n],!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:u("relative w-full overflow-hidden rounded-full bg-gray-200 dark:bg-gray-700",ay[r]),children:t?jsx("div",{className:u("absolute h-full w-1/3 rounded-full",f,o==="striped"&&Rc,"animate-[progress-indeterminate_1.5s_ease-in-out_infinite]")}):jsx("div",{className:u("h-full rounded-full",f,o==="striped"&&Rc,i&&"transition-[width] duration-300 ease-out"),style:{width:`${p}%`}})})]})}Pc.displayName="ProgressBar";var py=e=>({sm:"w-4 h-4",md:"w-5 h-5",lg:"w-6 h-6"})[e],my=e=>({sm:"w-2 h-2",md:"w-2.5 h-2.5",lg:"w-3 h-3"})[e],gy=(e,t,r,n,o,a,s,l)=>{if(t)return u("border-2",n?"":"border-red-500",r&&!o?"bg-red-500":"");switch(e){case "filled":return u("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 u("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 u("border-2",l?"":r?"border-blue-600 dark:border-blue-500":"border-gray-300 dark:border-gray-600","bg-white dark:bg-gray-800")}},fy={},Ec=forwardRef(({label:e,description:t,value:r,checked:n,defaultChecked:o=false,onCheckedChange:a,size:s="md",variant:l="default",labelPosition:i="right",error:d=false,disabled:c=false,readOnly:p=false,required:f=false,checkedColor:m,uncheckedColor:g,borderColor:x,labelColor:b,errorColor:v,dotColor:y,hoverColor:M,focusRingColor:w,showFocusRing:P=true,className:h,containerClassName:E,...D},k)=>{let[I,W]=useState(o),O=n!==void 0,L=O?n:I,T=useId(),S=typeof d=="string"?d:void 0,C=!!d,N=Q=>{if(c||p)return;let J=Q.target.checked;O||W(J),a?.(J);},R=useMemo(()=>gy(l,C,L,v,y,m,g,x),[l,C,L,v,y,m,g,x]),$=useMemo(()=>{let Q={};return m&&L&&(Q.backgroundColor=m,Q.borderColor=m),g&&!L&&(Q.backgroundColor=g),x&&(Q.borderColor=x),Q},[m,g,x,L]),H=useMemo(()=>y?{backgroundColor:y}:{},[y]),K=useMemo(()=>b?{color:b}:{},[b]),_=useMemo(()=>v?{color:v}:{},[v]),F=b?"":"text-gray-700 dark:text-gray-200",A=v?"":"text-red-500",B=M?"":"hover:border-blue-500 dark:hover:border-blue-400",U=w?"":"focus-visible:ring-blue-500";return jsxs("div",{className:u("inline-flex flex-col",E),style:fy,children:[jsxs("label",{className:u("inline-flex items-center cursor-pointer",c&&"opacity-50 cursor-not-allowed",p&&"cursor-default",i==="left"&&"flex-row-reverse"),htmlFor:T,children:[jsxs("div",{className:"relative inline-flex items-center",children:[jsx("input",{ref:k,type:"radio",id:T,value:r,checked:L,onChange:N,disabled:c,readOnly:p,required:f,"aria-invalid":C,"aria-describedby":S?`${T}-error`:void 0,className:"sr-only peer",tabIndex:p?-1:void 0,...D}),jsx("div",{className:u("rounded-full transition-all duration-200",py(s),R,!c&&!p&&B,!c&&!p&&P&&"peer-focus-visible:ring-2 ring-offset-2",!c&&!p&&P&&U,h),style:$,children:L&&jsx("div",{className:u("rounded-full absolute inset-0 m-auto transition-all duration-200",my(s),y?"":l==="outlined"||l==="default"?"bg-blue-600 dark:bg-blue-500":"bg-white"),style:H})})]}),e&&jsxs("span",{className:u("select-none",i==="left"?"mr-2":"ml-2",F,c&&"opacity-50"),style:K,children:[e,f&&jsx("span",{className:"text-red-500 ml-1",children:"*"})]})]}),t&&!C&&jsx("p",{className:u("text-sm text-gray-500 dark:text-gray-400 mt-1",i==="left"?"text-right":"ml-7"),children:t}),S&&jsx("p",{id:`${T}-error`,className:u("text-sm mt-1",i==="left"?"text-right":"ml-7",A),style:_,children:S})]})});Ec.displayName="RadioButton";var Ri=()=>{},vy=[],ky=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"})}),Cy=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"})}),wy=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"})]}),Ny=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"})}),ia={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"}},Dc={default:{trigger:"border border-gray-300 bg-white dark:border-gray-600 dark:bg-gray-800",focus:"focus:ring-2 focus:ring-blue-500 focus:border-blue-500"},outlined:{trigger:"border-2 border-gray-300 bg-transparent dark:border-gray-600",focus:"focus:ring-2 focus:ring-blue-500 focus:border-blue-500"},filled:{trigger:"border border-transparent bg-gray-100 dark:bg-gray-700",focus:"focus:ring-2 focus:ring-blue-500 focus:border-blue-500"}};function bn(...e){let t="";for(let r=0;r<e.length;r++){let n=e[r];n&&(t&&(t+=" "),t+=n);}return t}function Sy(e,t){if(!t)return e;let r=t.toLowerCase();return e.filter(n=>{if(n.label.toLowerCase().includes(r)||n.value.toLowerCase().includes(r))return true;if(n.keywords){for(let o of n.keywords)if(o.toLowerCase().includes(r))return true}return false})}var Ry=memo(forwardRef(function({option:t,isSelected:r,isHighlighted:n,isDisabled:o,sizeKey:a,optionId:s,onClick:l,onMouseEnter:i,index:d},c){let p=()=>{o||l(t.value);},f=()=>{o||i(d);};return jsxs("div",{ref:c,id:s,role:"option","aria-selected":r,"aria-disabled":o||void 0,"data-highlighted":n||void 0,className:bn(ia[a].option,"flex items-center gap-2 cursor-pointer select-none transition-colors",n&&!o&&"bg-blue-50 dark:bg-blue-900/30",r&&!n&&"bg-gray-50 dark:bg-gray-700/50",o&&"opacity-50 cursor-not-allowed"),onClick:p,onMouseEnter:f,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:Ny}):null]})}));function Ty({options:e=vy,value:t,defaultValue:r,onValueChange:n,searchable:o=false,clearable:a=false,disabled:s=false,readOnly:l=false,loading:i=false,size:d="md",variant:c="default",placeholder:p="Select...",label:f,description:m,helperText:g,error:x,required:b=false,noOptionsText:v="No options",onSearchChange:y,name:M,className:w,triggerClassName:P,contentClassName:h,maxHeight:E=256}){let D=useId(),k=`${D}-label`,I=`${D}-trigger`,W=`${D}-listbox`,O=useRef(null),L=useRef(null),T=useRef(null),S=useRef([]),C=t!==void 0,[N,R]=useState(r??""),$=C?t:N,[H,K]=useState(false),[_,F]=useState(""),[A,B]=useState(-1),[U,Q]=useState(null),J=useMemo(()=>o?Sy(e,_):e,[e,_,o]),Y=useMemo(()=>e.find(ie=>ie.value===$)??null,[e,$]),z=useMemo(()=>{let ie=new Set;for(let he of e)he.disabled&&ie.add(he.value);return ie},[e]),X=useCallback(ie=>{C||R(ie),(n??Ri)(ie),K(false),F(""),B(-1),O.current?.focus();},[C,n]),ne=useCallback(ie=>{ie.stopPropagation(),C||R(""),(n??Ri)(""),F(""),O.current?.focus();},[C,n]),re=useCallback(()=>{s||l||(K(true),F(""),B(-1));},[s,l]),q=useCallback(()=>{K(false),F(""),B(-1),O.current?.focus();},[]),de=useCallback(()=>{H?q():re();},[H,q,re]),xe=useCallback((ie,he)=>{let Ie=J.length;if(Ie===0)return -1;let xt=ie;for(let Te=0;Te<Ie;Te++)if(xt=((xt+he)%Ie+Ie)%Ie,!z.has(J[xt].value))return xt;return -1},[J,z]),ke=useCallback(ie=>{if(!(s||l)){if(H){switch(ie.key){case "ArrowDown":{ie.preventDefault();let he=xe(A,1);he!==-1&&B(he);break}case "ArrowUp":{ie.preventDefault();let he=xe(A,-1);he!==-1&&B(he);break}case "Home":{ie.preventDefault();let he=xe(-1,1);he!==-1&&B(he);break}case "End":{ie.preventDefault();let he=xe(J.length,-1);he!==-1&&B(he);break}case "Enter":{if(ie.preventDefault(),A>=0&&A<J.length){let he=J[A];z.has(he.value)||X(he.value);}break}case " ":if(ie.preventDefault(),A>=0&&A<J.length){let he=J[A];z.has(he.value)||X(he.value);}else q();break;case "Escape":ie.preventDefault(),q();break;case "Tab":q();break}return}switch(ie.key){case "ArrowDown":case "ArrowUp":ie.preventDefault(),re();break;case "Enter":case " ":ie.preventDefault(),re();break}}},[s,l,H,re,q,A,J,z,xe,X]),le=useCallback(ie=>{switch(ie.key){case "ArrowDown":{ie.preventDefault();let he=xe(A,1);he!==-1&&B(he);break}case "ArrowUp":{ie.preventDefault();let he=xe(A,-1);he!==-1&&B(he);break}case "Home":{ie.preventDefault();let he=xe(-1,1);he!==-1&&B(he);break}case "End":{ie.preventDefault();let he=xe(J.length,-1);he!==-1&&B(he);break}case "Enter":{if(ie.preventDefault(),A>=0&&A<J.length){let he=J[A];z.has(he.value)||X(he.value);}break}case "Escape":ie.preventDefault(),q();break;case "Tab":q();break}},[A,J,z,xe,X,q]),Se=useCallback(ie=>{let he=ie.target.value;F(he),B(-1),(y??Ri)(he);},[y]);useEffect(()=>{if(!H)return;let ie=he=>{let Ie=he.target;O.current?.contains(Ie)||L.current?.contains(Ie)||q();};return document.addEventListener("mousedown",ie),document.addEventListener("touchstart",ie,{passive:true}),()=>{document.removeEventListener("mousedown",ie),document.removeEventListener("touchstart",ie);}},[H,q]),useEffect(()=>{if(!H||!O.current){Q(null);return}let ie=()=>{let he=O.current;if(!he)return;let Ie=he.getBoundingClientRect(),xt=window.innerHeight-Ie.bottom,Te=Ie.top,Ee=E+8,nt=xt<Ee&&Te>xt?"top":"bottom";Q({top:nt==="bottom"?Ie.bottom+window.scrollY+4:Ie.top+window.scrollY-Ee,left:Ie.left+window.scrollX,width:Ie.width,placement:nt});};return ie(),window.addEventListener("scroll",ie,true),window.addEventListener("resize",ie),()=>{window.removeEventListener("scroll",ie,true),window.removeEventListener("resize",ie);}},[H,E]),useEffect(()=>{H&&o&&T.current?.focus();},[H,o]),useEffect(()=>{let ie=L.current;if(!(!H||!ie))return Ln(ie,()=>O.current)},[H]),useEffect(()=>{if(A>=0){let ie=S.current[A];ie&&typeof ie.scrollIntoView=="function"&&ie.scrollIntoView({block:"nearest"});}},[A]);let Me=$!==""&&$!==void 0,je=a&&Me&&!s&&!l&&!i,at=!s&&!l,$e=bn("w-full flex items-center justify-between rounded-md transition-colors","text-gray-900 dark:text-gray-100",ia[d].trigger,Dc[c].trigger,!x&&at&&Dc[c].focus,x&&"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",P);return jsxs("div",{className:bn("flex flex-col gap-1",w),children:[f?jsxs("label",{id:k,htmlFor:I,className:"text-sm font-medium text-gray-700 dark:text-gray-300",children:[f,b?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:O,id:I,type:"button",role:"combobox","aria-expanded":H,"aria-haspopup":"listbox","aria-controls":H?W:void 0,"aria-labelledby":f?k:void 0,"aria-required":b||void 0,"aria-invalid":x?true:void 0,"aria-activedescendant":H&&A>=0?`${D}-option-${A}`:void 0,disabled:s,className:$e,onClick:at?de:void 0,onKeyDown:ke,children:[jsxs("span",{className:bn("flex items-center gap-2 min-w-0 flex-1 truncate",!Me&&"text-gray-400 dark:text-gray-500"),children:[Y?.icon?jsx("span",{className:"flex shrink-0 items-center",children:Y.icon}):null,jsx("span",{className:"truncate",children:Me&&Y?Y.label:p})]}),jsxs("span",{className:"flex items-center gap-1 shrink-0",children:[i?jsx("span",{className:"text-gray-400",children:wy}):null,je?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:ne,onMouseDown:ie=>ie.preventDefault(),children:Cy}):null,jsx("span",{className:bn("text-gray-400 transition-transform duration-200",H&&"rotate-180"),children:ky})]})]}),x?jsx("p",{role:"alert",className:"text-xs text-red-500 dark:text-red-400",children:x}):g?jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400",children:g}):null,M?jsx("input",{type:"hidden",name:M,value:$??""}):null,H&&U?createPortal(jsxs("div",{ref:L,role:"listbox",id:W,"aria-labelledby":f?k:void 0,className:bn("fixed z-50 bg-white dark:bg-gray-800 border border-gray-200 dark:border-gray-700","rounded-md shadow-lg overflow-hidden","animate-in fade-in-0 zoom-in-95",ia[d].content,h),style:{top:U.top,left:U.left,width:U.width,position:"absolute"},onKeyDown:le,children:[o?jsx("div",{className:"border-b border-gray-200 dark:border-gray-700",children:jsx("input",{ref:T,type:"text",role:"searchbox","aria-label":"Search options",className:bn(ia[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:_,onChange:Se,onKeyDown:le})}):null,jsx("div",{className:"overflow-y-auto",style:{maxHeight:E},children:J.length===0?jsx("div",{className:bn(ia[d].option,"text-gray-500 dark:text-gray-400 text-center py-4"),children:v}):J.map((ie,he)=>jsx(Ry,{option:ie,isSelected:ie.value===$,isHighlighted:he===A,isDisabled:i||z.has(ie.value),sizeKey:d,optionId:`${D}-option-${he}`,onClick:X,onMouseEnter:B,index:he,ref:Ie=>{S.current[he]=Ie;}},ie.value))})]}),document.body):null]})}var Pi=createContext(null);function On(){let e=useContext(Pi);if(!e)throw new Error("Sidebar sub-components must be used within <Sidebar>");return e}function Dy(){return On()}var My=({className:e})=>jsx("svg",{className:u("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"})}),Iy=({className:e})=>jsx("svg",{className:u("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"})}),Ly=({className:e})=>jsx("svg",{className:u("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 Lc({text:e,position:t,children:r}){let[n,o]=useState(false),[a,s]=useState({top:0,left:0}),l=useRef(null);return jsxs("div",{ref:l,onMouseEnter:()=>{if(l.current){let d=l.current.getBoundingClientRect();s({top:d.top+d.height/2,left:t==="left"?d.right+8:d.left-8});}o(true);},onMouseLeave:()=>o(false),className:"relative",children:[r,n&&jsx("div",{className:u("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 Ay({collapsed:e,defaultCollapsed:t=false,onCollapsedChange:r,expandedWidth:n=260,collapsedWidth:o=64,position:a="left",variant:s="default",mobileBreakpoint:l=768,mobileOpen:i,onMobileOpenChange:d,className:c,"aria-label":p,closeLabel:f,trapFocus:m=true,initialFocus:g,returnFocus:x,lockScroll:b=true,children:v}){let y=At(),M=useRef(null),w=useRef(null),[P,h]=useState(t),[E,D]=useState(false),[k,I]=useState(false),W=e!==void 0,O=W?e:P,L=i!==void 0,T=L?i:E;useEffect(()=>{let F=window.matchMedia(`(max-width: ${l}px)`),A=B=>{I(B.matches),B.matches||(L||D(false),d?.(false));};return A(F),F.addEventListener("change",A),()=>F.removeEventListener("change",A)},[l,L,d]);let S=useCallback(()=>{if(k){let F=!T;L||D(F),d?.(F);}else {let F=!O;W||h(F),r?.(F);}},[k,T,O,L,W,d,r]),C=useCallback(()=>{L||D(false),d?.(false);},[L,d]);useEffect(()=>{let F=w.current;F&&(k&&!T?(F.setAttribute("inert",""),F.setAttribute("aria-hidden","true")):(F.removeAttribute("inert"),F.removeAttribute("aria-hidden")));},[k,T]);let{dialogRef:N,dialogProps:R}=An({open:k&&T,onClose:C,trapFocus:m,initialFocus:g,returnFocus:x,lockScroll:b,keepInteractive:[M]}),$={default:"bg-white dark:bg-gray-900",bordered:u("bg-white dark:bg-gray-900",a==="left"?"border-r border-gray-200 dark:border-gray-700":"border-l border-gray-200 dark:border-gray-700"),floating:"bg-white dark:bg-gray-900 m-3 rounded-xl shadow-xl border border-gray-200 dark:border-gray-700"},H=O&&!k?o:n,K=jsx("aside",{className:u("flex flex-col h-full overflow-hidden transition-[width] duration-200 ease-in-out",$[s],c),style:{width:k?n:H,minWidth:k?n:H},"data-testid":"sidebar","data-collapsed":O&&!k,"data-mobile":k,"data-position":a,children:v}),_={collapsed:O&&!k,isMobile:k,mobileOpen:T,position:a,variant:s,expandedWidth:n,collapsedWidth:o,toggle:S,closeMobile:C,closeLabel:f};return k?jsxs(Pi.Provider,{value:_,children:[T&&jsx("div",{ref:M,className:"fixed inset-0 z-40 bg-black/50 transition-opacity",onClick:C,"aria-hidden":"true","data-testid":"sidebar-overlay"}),jsx("div",{ref:F=>{w.current=F,N.current=F;},...R,"aria-label":p??y.sidebar,className:u("fixed top-0 z-50 h-full transition-transform duration-200 ease-in-out focus:outline-none",a==="left"?"left-0":"right-0",T?"translate-x-0":a==="left"?"-translate-x-full":"translate-x-full"),children:K})]}):jsx(Pi.Provider,{value:_,children:K})}function zy({className:e,children:t}){let r=On(),n=At();return jsxs("div",{className:u("flex items-center shrink-0 px-4 h-14 overflow-hidden",r.collapsed&&"justify-center px-2",e),"data-testid":"sidebar-header",children:[t,r.isMobile&&r.mobileOpen&&jsx("button",{type:"button",onClick:r.closeMobile,className:"ml-auto p-1 rounded-md text-gray-400 hover:text-gray-600 dark:hover:text-gray-300 hover:bg-gray-100 dark:hover:bg-gray-800 cursor-pointer","aria-label":r.closeLabel??n.closeSidebar,children:jsx(Ly,{})})]})}function Wy({className:e,children:t}){return jsx("div",{className:u("flex-1 overflow-y-auto overflow-x-hidden py-2",e),"data-testid":"sidebar-content",children:t})}function Hy({className:e,children:t}){let r=On();return jsx("div",{className:u("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 Fy({label:e,className:t,children:r}){let n=On();return jsxs("div",{className:u("py-2",t),"data-testid":"sidebar-group",children:[e&&!n.collapsed&&jsx("div",{className:"px-4 py-1.5 text-[11px] font-semibold uppercase tracking-wider text-gray-400 dark:text-gray-500",children:e}),e&&n.collapsed&&jsx("div",{className:"mx-auto my-1 w-6 border-t border-gray-200 dark:border-gray-700"}),jsx("div",{className:"space-y-0.5 px-2",children:r})]})}function Vy({icon:e,label:t,badge:r,badgeColor:n="bg-blue-600 text-white",active:o=false,disabled:a=false,href:s,onClick:l,tooltip:i,className:d}){let c=On(),p=c.collapsed,f=i??t,m=jsxs(Fragment,{children:[e&&jsx("span",{className:u("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:u("shrink-0 inline-flex items-center justify-center rounded-full text-[10px] font-semibold min-w-[18px] h-[18px] px-1",n),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"})]}),g=u("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",o?"bg-blue-50 text-blue-700 dark:bg-blue-900/30 dark:text-blue-400":"text-gray-700 dark:text-gray-300 hover:bg-gray-100 dark:hover:bg-gray-800",a&&"opacity-50 pointer-events-none",!a&&"cursor-pointer",d),x=()=>{a||(l?.(),c.isMobile&&c.closeMobile());},b=s?jsx("a",{href:a?void 0:s,className:g,onClick:x,"aria-current":o?"page":void 0,"data-testid":"sidebar-item",children:m}):jsx("button",{type:"button",className:g,onClick:x,disabled:a,"aria-current":o?"page":void 0,"data-testid":"sidebar-item",children:m});return p?jsx(Lc,{text:f,position:c.position,children:b}):b}function By({icon:e,label:t,badge:r,defaultOpen:n=false,className:o,children:a}){let s=On(),[l,i]=useState(n),d=useRef(null),[c,p]=useState(n?void 0:0),f=useRef(true);return useEffect(()=>{if(f.current){f.current=false,p(l?void 0:0);return}if(l){let m=d.current;if(m){p(m.scrollHeight);let g=setTimeout(()=>p(void 0),200);return ()=>clearTimeout(g)}}else {let m=d.current;m&&(p(m.scrollHeight),requestAnimationFrame(()=>p(0)));}},[l]),s.collapsed?jsx(Lc,{text:t,position:s.position,children:jsxs("button",{type:"button",className:u("relative flex items-center justify-center gap-3 rounded-md text-sm font-medium transition-colors w-full px-2 py-2.5","text-gray-700 dark:text-gray-300 hover:bg-gray-100 dark:hover:bg-gray-800 cursor-pointer",o),onClick:()=>{s.toggle(),i(true);},"data-testid":"sidebar-submenu-trigger",children:[e&&jsx("span",{className:"shrink-0 w-5 h-5",children:e}),r!=null&&jsx("span",{className:"absolute top-1 right-1 w-2 h-2 rounded-full bg-blue-600"})]})}):jsxs("div",{className:o,"data-testid":"sidebar-submenu",children:[jsxs("button",{type:"button",className:u("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(Iy,{className:u("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:c===void 0?"auto":c},children:jsx("div",{ref:d,className:"pl-4 py-0.5",children:a})})]})}function Oy({className:e}){let t=On(),r=At(),n=t.isMobile?t.mobileOpen?t.closeLabel??r.closeSidebar:r.openSidebar:t.collapsed?r.expandSidebar:r.collapseSidebar;return jsx("button",{type:"button",onClick:t.toggle,className:u("p-1.5 rounded-md text-gray-400 hover:text-gray-600 dark:hover:text-gray-300 hover:bg-gray-100 dark:hover:bg-gray-800 transition-colors cursor-pointer",e),"aria-label":n,"data-testid":"sidebar-toggle",children:jsx(My,{className:u("transition-transform duration-200",t.collapsed&&"rotate-180",t.position==="right"&&!t.collapsed&&"rotate-180",t.position==="right"&&t.collapsed&&"rotate-0")})})}function Di({data:e,width:t=96,height:r=28,curve:n="monotone",color:o=Sa[0],strokeWidth:a=2,area:s=false,emphasizeLast:l=false,domain:i,ariaLabel:d,className:c,...p}){let f=Math.max(a/2,l?a+2.5:0),m=i??Ot(e)??[0,1],g=Ar([0,Math.max(1,e.length-1)],[f,t-f]),x=Ar(m,[r-f,f]),b=e.map((y,M)=>({x:g(M),y:y==null?Number.NaN:x(y),defined:y!=null&&Number.isFinite(y)})),v=[...b].reverse().find(y=>y.defined!==false);return jsxs("svg",{width:t,height:r,viewBox:`0 0 ${t} ${r}`,className:u("overflow-visible",c),role:d?"img":void 0,"aria-label":d,"aria-hidden":d?void 0:true,...p,children:[s?jsx("path",{d:Ho(b,r-f,n),fill:o,fillOpacity:.12,stroke:"none"}):null,jsx("path",{d:Yr(b,n),fill:"none",stroke:o,strokeWidth:a,strokeLinecap:"round",strokeLinejoin:"round",vectorEffect:"non-scaling-stroke"}),l&&v?jsx("circle",{cx:v.x,cy:v.y,r:a,fill:o,strokeWidth:2,className:"stroke-white dark:stroke-gray-800"}):null]})}var _y={sm:"p-3",md:"p-4",lg:"p-5"},Xy={sm:"text-[11px]",md:"text-xs",lg:"text-sm"},Gy={sm:"text-xl",md:"text-2xl",lg:"text-3xl"},Ac={sm:{width:72,height:22},md:{width:96,height:28},lg:{width:120,height:34}};function Ky(e){return e.direction?e.direction:e.value>0?"up":e.value<0?"down":"flat"}function Uy(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 Yy({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 jy({label:e,value:t,format:r,delta:n,trend:o,trendColor:a,icon:s,size:l="md",loading:i=false,variant:d="card",footer:c,className:p,...f}){let m=typeof t=="number"?(r??vt)(t):t,g=n?Ky(n):"flat",x=n?(n.format??(b=>xr(b,{signed:true})))(n.value):null;return jsxs("div",{className:u("flex flex-col gap-2",d==="card"&&u("rounded-lg border border-gray-200 bg-white dark:border-gray-700 dark:bg-gray-800",_y[l]),p),...f,children:[jsxs("div",{className:"flex items-start justify-between gap-2",children:[jsx("span",{className:u("font-medium text-gray-500 dark:text-gray-400",Xy[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(Un,{indeterminate:true,size:l==="lg"?"sm":"xs",thickness:"thin","aria-hidden":"true"})}):jsx("span",{className:u("leading-none font-semibold text-gray-900 dark:text-gray-100",Gy[l]),children:m}),n&&!i?jsxs("span",{className:u("flex items-center gap-1 text-xs font-medium",Uy(g,n.goodWhen??"up")),children:[jsx(Yy,{direction:g}),x,n.period?jsx("span",{className:"font-normal text-gray-500 dark:text-gray-400",children:n.period}):null]}):null]}),o&&o.length>0&&!i?jsx(Di,{data:o,color:a,emphasizeLast:true,area:true,width:Ac[l].width,height:Ac[l].height,className:"shrink-0"}):null]}),c?jsx("div",{className:"text-xs text-gray-500 dark:text-gray-400",children:c}):null]})}var qy={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 Zy({columns:e=4,className:t,children:r,...n}){return jsx("div",{className:u("grid grid-cols-1 gap-3",qy[e],t),...n,children:r})}var Jy={text:"rounded h-4 w-full",circular:"rounded-full",rectangular:"rounded-none",rounded:"rounded-lg"},ex={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:""},tx="bg-gray-200 dark:bg-gray-700";function zc({variant:e="text",animation:t="pulse",width:r,height:n,count:o=1,className:a,style:s,...l}){let i={...r!==void 0&&{width:typeof r=="number"?`${r}px`:r},...n!==void 0&&{height:typeof n=="number"?`${n}px`:n},...s};e==="circular"&&r&&!n&&(i.height=i.width);let d=u(tx,Jy[e],ex[t],a);return o===1?jsx("div",{className:d,style:i,"aria-busy":"true","aria-live":"polite",...l}):jsx("div",{className:"space-y-2",children:Array.from({length:o}).map((c,p)=>jsx("div",{className:d,style:i,"aria-busy":"true","aria-live":"polite",...l},p))})}zc.displayName="Skeleton";var sx={sm:"h-1",md:"h-1.5",lg:"h-2"},ix={sm:"w-3.5 h-3.5",md:"w-4 h-4",lg:"w-5 h-5"},lx={sm:14,md:16,lg:20},dx="[&::-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",cx={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"},ux={sm:"h-4",md:"h-5",lg:"h-6"},px={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"},mx={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"},gx={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"},fx={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"},Wc=(e,t,r)=>Math.min(r,Math.max(t,e)),Ii=(e,t,r)=>r>t?(Wc(e,t,r)-t)/(r-t)*100:0,ss=(e,t)=>{let r=(.5-e/100)*t,n=Math.round(Math.abs(r)*1e3)/1e3;return `calc(${e}% ${r<0?"-":"+"} ${n}px)`},bx=(e,t,r,n)=>{if(!e)return [];if(Array.isArray(e))return e;let o=n>0?n:1,a=Math.floor((r-t)/o);return a<=0||a>20?[{value:t},{value:r}]:Array.from({length:a+1},(s,l)=>({value:t+l*o}))},Hc=forwardRef(({value:e,defaultValue:t,onValueChange:r,min:n=0,max:o=100,step:a=1,size:s="md",color:l="primary",disabled:i=false,readOnly:d=false,label:c,description:p,error:f=false,showValue:m=false,showTooltip:g=false,valueFormat:x,marks:b,trackColor:v,fillColor:y,thumbColor:M,className:w,containerClassName:P,id:h,...E},D)=>{let[k,I]=useState(t??n),W=e!==void 0,L=Wc(W?e:k,n,o),T=useId(),S=h??T,C=typeof f=="string"?f:void 0,N=!!f,R=!i&&!d,$=N?"error":l,H=Ii(L,n,o),K=lx[s],_=Y=>{if(!R)return;let z=Number(Y.target.value);W||I(z),r?.(z);},F=useMemo(()=>bx(b,n,o,a),[b,n,o,a]),A=F.some(Y=>Y.label!=null),B=x?x(L):`${L}`,U={width:ss(H,K)};y&&(U.backgroundColor=y);let Q={left:ss(H,K)};M&&(Q.backgroundColor=M,Q.borderColor=M);let J=v?{backgroundColor:v}:{};return jsxs("div",{className:u("w-full",P),children:[(c||m)&&jsxs("div",{className:"flex items-center justify-between mb-1.5",children:[c?jsx("label",{htmlFor:S,className:u("text-sm font-medium text-gray-700 dark:text-gray-200",i&&"opacity-50"),children:c}):jsx("span",{}),m&&jsx("span",{className:u("text-sm font-semibold tabular-nums",fx[$]),children:B})]}),jsxs("div",{className:u("relative flex items-center",ux[s],i&&"opacity-50"),children:[jsx("input",{ref:D,type:"range",id:S,min:n,max:o,step:a,value:L,onChange:_,disabled:i,readOnly:d,"aria-invalid":N,"aria-readonly":d||void 0,"aria-describedby":C?`${S}-error`:void 0,tabIndex:R?void 0:-1,className:u("peer absolute inset-0 z-10 m-0 h-full w-full cursor-pointer appearance-none bg-transparent opacity-0",dx,cx[s],!R&&"pointer-events-none cursor-default",w),...E}),jsxs("div",{className:u("pointer-events-none relative w-full overflow-hidden rounded-full bg-gray-200 dark:bg-gray-700",sx[s]),style:J,children:[jsx("div",{className:u("absolute inset-y-0 left-0 rounded-full transition-[width] duration-150 ease-out",y?"":px[$]),style:U}),F.map((Y,z)=>{let X=Ii(Y.value,n,o),ne=Y.value<=L;return jsx("span",{"data-slider-mark":"",className:u("absolute top-1/2 h-1 w-1 -translate-x-1/2 -translate-y-1/2 rounded-full",ne?"bg-white/80":"bg-gray-400 dark:bg-gray-500"),style:{left:ss(X,K)}},`mark-${Y.value}-${z}`)})]}),jsx("div",{"data-slider-thumb":"",className:u("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",ix[s],M?"":mx[$],R&&"peer-hover:scale-110 peer-active:scale-110","peer-focus-visible:scale-110 peer-focus-visible:ring-2 peer-focus-visible:ring-offset-2",gx[$]),style:Q,children:g&&jsx("span",{"data-slider-tooltip":"",className:u("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:B})})]}),A&&jsx("div",{className:"relative mt-1.5 h-4",children:F.map((Y,z)=>Y.label!=null?jsx("span",{className:"absolute -translate-x-1/2 whitespace-nowrap text-xs text-gray-500 dark:text-gray-400",style:{left:ss(Ii(Y.value,n,o),K)},children:Y.label},`mark-label-${Y.value}-${z}`):null)}),p&&!C&&jsx("p",{className:"mt-1.5 text-sm text-gray-500 dark:text-gray-400",children:p}),C&&jsx("p",{id:`${S}-error`,className:"mt-1.5 text-sm text-red-500 dark:text-red-400",children:C})]})});Hc.displayName="Slider";var Li=createContext(null);function yo(){let e=useContext(Li);if(!e)throw new Error("Tabs components must be used within a Tabs provider");return e}function Vc({children:e,defaultValue:t="",value:r,onValueChange:n,variant:o="underline",size:a="md",color:s="default",fullWidth:l=false,orientation:i="horizontal",className:d}){let[c,p]=useState(t),f=r!==void 0,m=f?r:c,g=useCallback(b=>{f||p(b),n?.(b);},[f,n]),x=useMemo(()=>({value:m,onValueChange:g,variant:o,size:a,color:s,orientation:i,fullWidth:l}),[m,g,o,a,s,i,l]);return jsx(Li.Provider,{value:x,children:jsx("div",{className:u("w-full",i==="vertical"&&"flex gap-4",d),"data-orientation":i,children:e})})}Vc.displayName="Tabs";var Cx={none:"gap-0",sm:"gap-1",md:"gap-2",lg:"gap-4"};function Bc({children:e,className:t,bgColor:r,gap:n="none"}){let{variant:o,orientation:a,fullWidth:s}=yo(),l=u("flex",a==="vertical"?"flex-col":"flex-row items-center",Cx[n]),i={underline:"border-b border-gray-200 dark:border-gray-700",pills:u("p-1 rounded-lg",r||"bg-gray-100 dark:bg-gray-800"),enclosed:"border-b border-gray-200 dark:border-gray-700",soft:u("p-1 rounded-lg",r||"bg-gray-100/50 dark:bg-gray-800/50")};return jsx("div",{role:"tablist","aria-orientation":a,className:u(l,i[o],s&&"w-full",t),children:e})}Bc.displayName="TabsList";var Nx={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"},Oc={sm:"w-3.5 h-3.5",md:"w-4 h-4",lg:"w-5 h-5"},$c={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"}}},Sx={underline:"border-b-2 -mb-px",pills:"rounded-md",enclosed:"border border-b-0 rounded-t-md -mb-px",soft:"rounded-md"};function _c({value:e,children:t,disabled:r=false,icon:n,endIcon:o,className:a,activeClassName:s,inactiveClassName:l}){let{value:i,onValueChange:d,variant:c,size:p,color:f,fullWidth:m}=yo(),g=i===e,x=()=>{r||d(e);},b=w=>{(w.key==="Enter"||w.key===" ")&&(w.preventDefault(),x());},v=u("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",Nx[p],m&&"flex-1"),y=g?u($c[f][c].active,s):u($c[f][c].inactive,l),M=r?"opacity-50 cursor-not-allowed":"cursor-pointer";return jsxs("button",{type:"button",role:"tab","aria-selected":g,"aria-disabled":r,tabIndex:g?0:-1,onClick:x,onKeyDown:b,disabled:r,className:u(v,Sx[c],y,M,a),children:[n&&jsx("span",{className:u("shrink-0",Oc[p]),children:n}),jsx("span",{children:t}),o&&jsx("span",{className:u("shrink-0",Oc[p]),children:o})]})}_c.displayName="TabsTrigger";function Xc({value:e,children:t,className:r,forceMount:n=false}){let{value:o}=yo(),a=o===e;return !a&&!n?null:jsx("div",{role:"tabpanel",hidden:!a,tabIndex:0,className:u("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})}Xc.displayName="TabsContent";function Px({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 Ex({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 Dx({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 Gc({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 Mx({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 Ix={success:Px,error:Ex,warning:Dx,info:Gc,default:Gc},Lx={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"}},Ax={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 Uc({children:e,title:t,description:r,type:n="default",variant:o="soft",icon:a,action:s,onClose:l,closable:i=true,className:d,...c}){let p=Ix[n],f=jsx(p,{className:"w-5 h-5"}),m=e??r;return jsxs("div",{role:"alert",className:u("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",Lx[n][o],d),...c,children:[jsx("div",{className:u("flex-shrink-0 mt-0.5",o==="solid"?"text-white":Ax[n]),children:a??f}),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:u("flex-shrink-0 rounded-md p-1 transition-colors hover:bg-black/10 dark:hover:bg-white/10","focus:outline-none focus-visible:ring-2 focus-visible:ring-offset-2 focus-visible:ring-current",o==="solid"?"text-white":""),"aria-label":"Close notification",children:jsx(Mx,{className:"w-4 h-4"})})]})}Uc.displayName="Toast";var Hx={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"},Fx={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"}},Vx={sm:"px-2 py-1 text-xs",md:"px-3 py-1.5 text-sm",lg:"px-4 py-2 text-base"},Bx={sm:"border-4",md:"border-[5px]",lg:"border-[6px]"},Ox={top:"bottom-full left-1/2 -translate-x-1/2 mb-2",bottom:"top-full left-1/2 -translate-x-1/2 mt-2",left:"right-full top-1/2 -translate-y-1/2 mr-2",right:"left-full top-1/2 -translate-y-1/2 ml-2"},$x={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 yt({children:e,content:t,position:r="top",variant:n="default",size:o="md",trigger:a="hover",open:s,delay:l=0,showArrow:i=true,maxWidth:d="max-w-xs",className:c,contentClassName:p,disabled:f=false,...m}){let[g,x]=useState(false),b=useRef(null),v=useCallback(()=>{f||(l>0?b.current=setTimeout(()=>x(true),l):x(true));},[l,f]),y=useCallback(()=>{b.current&&(clearTimeout(b.current),b.current=null),x(false);},[]),M=useCallback(()=>{f||x(h=>!h);},[f]),w=a==="manual"?s:g,P={hover:{onMouseEnter:v,onMouseLeave:y,onFocus:v,onBlur:y},click:{onClick:M},manual:{}}[a];return jsxs("div",{className:u("relative inline-flex",c),...P,...m,children:[e,w&&!f&&jsxs("div",{role:"tooltip",className:u("absolute z-50 whitespace-normal wrap-break-word rounded-md","transition-opacity duration-150",Ox[r],Hx[n],Vx[o],d,p),children:[t,i&&jsx("span",{className:u("absolute w-0 h-0 border-solid",Bx[o],$x[r],Fx[n][r]),"aria-hidden":"true"})]})]})}yt.displayName="Tooltip";function Xx(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 Gx(e){switch(e){case "sm":return "py-6";case "lg":return "py-16";default:return "py-10"}}function qc({variant:e="default",size:t="md",sticky:r=false,className:n,children:o,...a}){return jsx("footer",{className:u(Xx(e),Gx(t),r&&"sticky bottom-0 z-40",n),...a,children:jsx("div",{className:"container mx-auto px-4",children:o})})}qc.displayName="Footer";function Kx(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 Zc({title:e,titleClassName:t,columns:r,className:n,children:o,...a}){return jsxs("div",{className:u(r&&"grid gap-8",Kx(r),n),...a,children:[e&&jsx("h3",{className:u("text-sm font-semibold uppercase tracking-wider text-gray-900 dark:text-white",r&&"col-span-full",t),children:e}),o]})}Zc.displayName="FooterSection";function Qc({title:e,titleClassName:t,className:r,children:n,...o}){return jsxs("div",{className:u("flex flex-col gap-3",r),...o,children:[e&&jsx("h4",{className:u("text-sm font-semibold uppercase tracking-wider text-gray-900 dark:text-white",t),children:e}),n]})}Qc.displayName="FooterColumn";function Jc({external:e=false,className:t,children:r,...n}){return jsx("a",{className:u("text-sm text-gray-600 dark:text-gray-400 hover:text-gray-900 dark:hover:text-white transition-colors",t),target:e?"_blank":void 0,rel:e?"noopener noreferrer":void 0,...n,children:r})}Jc.displayName="FooterLink";function eu({copyright:e,className:t,children:r,...n}){return jsxs("div",{className:u("mt-8 border-t border-gray-200 dark:border-gray-700 pt-6 flex flex-col sm:flex-row items-center justify-between gap-4",t),...n,children:[e&&jsx("p",{className:"text-sm text-gray-500 dark:text-gray-400",children:e}),r]})}eu.displayName="FooterBottom";function tu({className:e,children:t,...r}){return jsx("div",{className:u("flex items-center gap-4",e),...r,children:t})}tu.displayName="FooterSocial";function ru({icon:e,label:t,className:r,...n}){return jsx("a",{className:u("text-gray-500 dark:text-gray-400 hover:text-gray-900 dark:hover:text-white transition-colors",r),target:"_blank",rel:"noopener noreferrer","aria-label":t,...n,children:e})}ru.displayName="FooterSocialLink";var tv=4.5,rv=48,ou=false,nv=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 ov({width:e,height:t,data:r,resolvedSeries:n,x:o,y:a,grid:s,size:l,bubble:i,trendLine:d,quadrants:c,pointRadius:p,margin:f,tooltip:m,onPointClick:g,plotLabel:x,formatValue:b,formatX:v}){let[y,M]=useState(null),w=useMemo(()=>{let E=n.filter(N=>!N.hidden),D=E.map(N=>N.key),k=cn({width:e,height:t,data:r,x:{...o,scale:o.scale==="time"?"time":"linear"},y:a,bounds:Ot(ir(r,D)),margin:f,formatValue:b,formatX:v}),I=i?ir(r,[i.key]):[],W=i?Ot(I):null,[O,L]=i?.range??[4,14],T=N=>{if(!i||!W)return p;let R=et(N,i.key);if(R===null)return O;let[$,H]=W,K=H===$?1:(R-$)/(H-$);return Math.sqrt(O*O+K*(L*L-O*O))},S=[];E.forEach(N=>{r.forEach((R,$)=>{let H=et(R,N.key),K=k.categoryPositions[$];H===null||!Number.isFinite(K)||S.push({seriesKey:N.key,seriesLabel:Bt(N),color:N.color,index:$,cx:K,cy:k.valueScale(H),r:T(R),xValue:Lr(k.xValues[$]),yValue:H});});});let C=null;if(d&&S.length>1){let N=S.length,R=S.reduce((F,A)=>F+A.xValue,0),$=S.reduce((F,A)=>F+A.yValue,0),H=S.reduce((F,A)=>F+A.xValue*A.yValue,0),K=S.reduce((F,A)=>F+A.xValue*A.xValue,0),_=N*K-R*R;if(_!==0){let F=(N*H-R*$)/_,A=($-F*R)/N,B=S.map(Y=>Y.xValue),[U,Q]=[Math.min(...B),Math.max(...B)],J=S.map(Y=>Y.cx);C={x1:Math.min(...J),y1:k.valueScale(F*U+A),x2:Math.max(...J),y2:k.valueScale(F*Q+A)};}}return {visible:E,points:S,trend:C,xTicks:k.categoryTicks,yTicks:k.valueTicks,valueScale:k.valueScale,positions:k.categoryPositions,innerWidth:k.innerWidth,innerHeight:k.innerHeight,margin:k.margin,xValues:k.xValues}},[r,n,o,a,e,t,f,i,d,p,b,v]),P=useCallback(E=>{if(m===false||w.points.length===0)return;let D=E.currentTarget.getBoundingClientRect(),k=E.clientX-D.left-w.margin.left,I=E.clientY-D.top-w.margin.top,W=null,O=rv;for(let L of w.points){let T=Math.hypot(L.cx-k,L.cy-I);T<O&&(O=T,W=L);}M(W);},[m,w.points,w.margin]),h=useCallback(()=>{!g||!y||g({seriesKey:y.seriesKey,seriesLabel:y.seriesLabel,color:y.color,value:y.yValue,formattedValue:b(y.yValue),datum:r[y.index],index:y.index,x:w.xValues[y.index]});},[g,y,b,r,w.xValues]);return jsxs(Fragment,{children:[jsxs("svg",{width:e,height:t,role:"img","aria-label":x??w.visible.map(E=>Bt(E)).join(", "),tabIndex:0,className:"touch-none focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-blue-500",onPointerMove:P,onPointerLeave:()=>M(null),onBlur:()=>M(null),onClick:h,children:[jsxs("g",{transform:`translate(${w.margin.left}, ${w.margin.top})`,children:[jsx(Kr,{width:w.innerWidth,height:w.innerHeight,horizontal:s==="y"||s==="both"?w.yTicks.map(E=>E.offset):void 0,vertical:s==="x"||s==="both"?w.xTicks.map(E=>E.offset):void 0}),c?.y!==void 0?jsx("line",{x1:0,y1:w.valueScale(c.y),x2:w.innerWidth,y2:w.valueScale(c.y),stroke:"var(--color-chart-muted)",strokeWidth:1,strokeDasharray:"4 4"}):null,w.trend?jsx("line",{x1:w.trend.x1,y1:w.trend.y1,x2:w.trend.x2,y2:w.trend.y2,stroke:"var(--color-chart-muted)",strokeWidth:1.5,strokeDasharray:"4 4"}):null,jsx(nv,{points:w.points}),y?jsx("circle",{cx:y.cx,cy:y.cy,r:y.r+3,fill:"none",stroke:y.color,strokeWidth:2,"aria-hidden":"true"}):null]}),jsx("g",{transform:`translate(${w.margin.left}, ${w.margin.top+w.innerHeight})`,children:o.hidden?null:jsx(St,{orientation:"bottom",ticks:w.xTicks,length:w.innerWidth,label:o.label,size:l})}),jsx("g",{transform:`translate(${w.margin.left}, ${w.margin.top})`,children:a?.hidden?null:jsx(St,{orientation:"left",ticks:w.yTicks,length:w.innerHeight,showLine:false,label:a?.label,size:l})})]}),y&&m!==false?jsx(jt,{x:w.margin.left+y.cx,y:w.margin.top+y.cy,containerWidth:e,children:typeof m=="function"?m({x:w.xValues[y.index],xLabel:v(w.xValues[y.index],y.index),index:y.index,points:[{seriesKey:y.seriesKey,seriesLabel:y.seriesLabel,color:y.color,value:y.yValue,formattedValue:b(y.yValue),datum:r[y.index]}]}):jsx(vr,{title:`${o.label??o.key} ${v(w.xValues[y.index],y.index)}`,points:[{seriesKey:y.seriesKey,seriesLabel:y.seriesLabel,color:y.color,value:y.yValue,formattedValue:b(y.yValue),datum:r[y.index]}]})}):null]})}function av({data:e,series:t,x:r,y:n,height:o=280,width:a,size:s="md",grid:l="both",legend:i,tooltip:d=true,tableView:c=false,emphasis:p,title:f,description:m,loading:g=false,emptyState:x,onPointClick:b,bubble:v,trendLine:y=false,quadrants:M,pointRadius:w=tv,legendToggle:P=true,margin:h,locale:E,plotLabel:D,className:k,...I}){let[W,O]=useState(()=>new Set);t.length>3&&!ou&&(ou=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 L=useMemo(()=>t.map((H,K)=>({...H,hidden:H.hidden||W.has(H.key),color:Ir(H,K,p)})),[t,W,p]),T=useMemo(()=>n?.format??(H=>vt(H,E)),[n?.format,E]),S=useMemo(()=>r.format??(H=>r.scale==="time"?bt(H instanceof Date?H:new Date(Lr(H)),E):vt(Lr(H),E)),[r.format,r.scale,E]),C=useCallback(H=>{O(K=>{let _=new Set(K);return _.has(H)?_.delete(H):_.add(H),_});},[]),N=i===void 0?t.length>=2:i!==false,R=typeof i=="string"?i:"bottom",$=L.filter(H=>!H.hidden).length;return jsx(Kt,{title:f,description:m,height:o,width:a,size:s,loading:g,empty:e.length===0||$===0,emptyState:x,tableView:c,legendPosition:R,legend:N?jsx(yr,{items:Ur(L,p),position:R,marker:"dot",size:s,onToggle:P?C:void 0}):void 0,table:c?jsx(Yt,{data:e,series:L,xKey:r.key,xLabel:r.label??r.key,formatX:S,formatValue:T,caption:typeof f=="string"?f:void 0}):void 0,className:k,...I,children:({width:H})=>jsx(ov,{width:H,height:o,data:e,resolvedSeries:L,x:r,y:n,grid:l,size:s,bubble:v,trendLine:y,quadrants:M,pointRadius:w,margin:h,tooltip:d,onPointClick:b,plotLabel:D,formatValue:T,formatX:S})})}var su="se-grid-pattern",iu=memo(function({gridSize:t,zoom:r}){let n=t*r;return jsxs("svg",{className:"absolute inset-0 w-full h-full pointer-events-none","aria-hidden":"true",children:[jsx("defs",{children:jsx("pattern",{id:su,width:n,height:n,patternUnits:"userSpaceOnUse",children:jsx("circle",{cx:1,cy:1,r:1,className:"fill-gray-300 dark:fill-gray-600"})})}),jsx("rect",{width:"100%",height:"100%",fill:`url(#${su})`})]})});function hn(e,t){return e.collapsed?40:e.height?e.height:40+(e.notes?24:0)+e.fields.length*32+(t?36:0)}function xo(e,t){return 40+(t?24:0)+e*32+32/2}function lu(e,t,r){let n=e.fields.findIndex(i=>i.id===t);if(n===-1)return null;let o=e.width??260,a=!!e.notes,s=e.y+xo(n,a);return {x:r==="left"?e.x+0:e.x+o-0,y:s}}function Fi(e,t){return Math.round(e/t)*t}function ca(e,t,r){return Math.min(r,Math.max(t,e))}function ua(e,t,r,n){return {x:(e-n.left-r.x)/r.zoom,y:(t-n.top-r.y)/r.zoom}}function cs(e,t,r,n){let o=Math.abs(r-e),a=Math.max(50,o*.5),s=e+a,l=t,i=r-a;return `M ${e} ${t} C ${s} ${l}, ${i} ${n}, ${r} ${n}`}function du(e,t,r,n,o=40){if(e.length===0)return {x:0,y:0,zoom:1};let a=1/0,s=1/0,l=-1/0,i=-1/0;for(let g of e){let x=g.width??260,b=hn(g,n);a=Math.min(a,g.x),s=Math.min(s,g.y),l=Math.max(l,g.x+x),i=Math.max(i,g.y+b);}let d=l-a+o*2,c=i-s+o*2,p=Math.min(t/d,r/c,1),f=(t-d*p)/2-(a-o)*p,m=(r-c*p)/2-(s-o)*p;return {x:f,y:m,zoom:p}}var ma=["text","varchar","char","int2","int4","int8","serial","bigserial","float4","float8","numeric","decimal","bool","date","time","timestamp","timestamptz","uuid","json","jsonb","bytea"];function cu(){return `table-${Date.now()}-${Math.random().toString(36).slice(2,8)}`}function pa(){return `field-${Date.now()}-${Math.random().toString(36).slice(2,8)}`}function Vi(){return `rel-${Date.now()}-${Math.random().toString(36).slice(2,8)}`}function Bi(e="new_field"){return {id:pa(),name:e,type:"text",nullable:true}}function Oi(e,t,r="new_table"){return {id:cu(),name:r,x:e,y:t,fields:[{id:pa(),name:"id",type:"serial",primaryKey:true},{id:pa(),name:"createdAt",type:"timestamp"},{id:pa(),name:"updatedAt",type:"timestamp"}]}}var us=()=>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"})]}),pu=()=>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"})]}),cv=({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"})}),mu=()=>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"})}),gu=()=>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"})}),uv=()=>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"})}),pv=()=>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"})]}),mv=memo(function({field:t,tableId:r,editable:n,readOnly:o,disabled:a,onFieldChange:s}){let[l,i]=useState(false),[d,c]=useState(t.defaultValue??""),p=n&&!o&&!a,f=()=>{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=>c(m.target.value),onBlur:f,onKeyDown:m=>{m.key==="Enter"&&f(),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(),c(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(),c(""),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}),bu=memo(function({table:t,selected:r,disabled:n,readOnly:o,editable:a,dropTarget:s,fieldTypes:l,onTableNameChange:i,onTableNotesChange:d,onToggleCollapse:c,onFieldChange:p,onFieldAdd:f,onFieldRemove:m,onFieldReorder:g,onResizeStart:x}){let b=t.width??260,v=t.collapsed??false,y=l.length>0?l:ma,[M,w]=useState(null),[P,h]=useState(null),E=useRef(null),D=useCallback(C=>{i?.(t.id,C.target.value);},[t.id,i]),k=useCallback((C,N)=>{p?.(t.id,C,{name:N});},[t.id,p]),I=useCallback((C,N)=>{p?.(t.id,C,{type:N});},[t.id,p]),W=useCallback((C,N)=>{p?.(t.id,C,{primaryKey:!N});},[t.id,p]),O=useCallback((C,N)=>{p?.(t.id,C,{nullable:!N});},[t.id,p]),L=useCallback((C,N)=>{p?.(t.id,C,{indexed:!N});},[t.id,p]),T=useCallback((C,N)=>{p?.(t.id,C,{unique:!N});},[t.id,p]),S=useCallback(()=>{f?.(t.id);},[t.id,f]);return jsxs("div",{"data-table-id":t.id,className:u("absolute bg-white dark:bg-gray-800 border-2 border-dashed rounded-lg shadow-sm cursor-grab active:cursor-grabbing",t.height?"flex flex-col":void 0,s?"border-green-400 shadow-green-100 dark:shadow-green-900/30 shadow-md":r?"border-blue-500 shadow-blue-100 dark:shadow-blue-900/30":"border-gray-300 dark:border-gray-600",n&&"opacity-60",t.locked&&"!cursor-default"),style:{left:t.x,top:t.y,width:b,height:t.height,userSelect:"none",overflow:t.height?"hidden":void 0},children:[jsxs("div",{className:u("flex items-center justify-between px-3 gap-2","bg-gray-50 dark:bg-gray-700 border-b border-gray-200 dark:border-gray-600"),style:{height:40},children:[a&&!o&&!n?jsx("input",{className:"flex-1 min-w-0 text-sm font-semibold text-gray-800 dark:text-gray-100 bg-transparent border-none outline-none focus:ring-0 p-0 truncate cursor-text","aria-label":"Table name",value:t.name,onChange:D,onMouseDown:C=>C.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:C=>{C.stopPropagation(),c?.(t.id);},onMouseDown:C=>C.stopPropagation(),"aria-label":v?"Expand table":"Collapse table",children:jsx(cv,{collapsed:v})})]}),!v&&(a&&!o&&!n?jsx("div",{className:"px-3 border-b border-gray-100 dark:border-gray-700 flex items-center",style:{height:24},children:jsx("input",{className:"w-full text-xs italic text-gray-400 dark:text-gray-500 bg-transparent border-none outline-none focus:ring-0 p-0 placeholder-gray-400 dark:placeholder-gray-500","aria-label":"Table notes",placeholder:"Add notes...",value:t.notes??"",onChange:C=>d?.(t.id,C.target.value),onMouseDown:C=>C.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),!v&&jsxs("div",{className:t.height?"overflow-y-auto flex-1 min-h-0":void 0,children:[t.fields.map((C,N)=>jsxs("div",{"data-field-id":C.id,"data-table-id":t.id,className:u("flex items-center gap-1.5 pr-2 relative group",a&&!o&&!n?"pl-[18px]":"pl-2","border-b border-gray-100 dark:border-gray-700 last:border-b-0",s?"bg-blue-50/50 dark:bg-blue-900/10":"hover:bg-gray-50 dark:hover:bg-gray-750",M===N&&"opacity-40",P===N&&"!border-t-2 !border-t-blue-400"),style:{height:32},draggable:a&&!o&&!n,onDragStart:R=>{!a||o||n||(R.stopPropagation(),E.current=N,w(N),R.dataTransfer.effectAllowed="move",R.dataTransfer.setData("text/plain",String(N)));},onDragOver:R=>{E.current!==null&&(R.preventDefault(),R.stopPropagation(),h(N));},onDragLeave:()=>{P===N&&h(null);},onDrop:R=>{R.preventDefault(),R.stopPropagation(),E.current!==null&&E.current!==N&&g?.(t.id,E.current,N),E.current=null,w(null),h(null);},onDragEnd:()=>{E.current=null,w(null),h(null);},children:[jsx("div",{"data-connection-side":"left","data-field-id":C.id,"data-table-id":t.id,className:u("absolute -left-[5px] w-2.5 h-2.5 rounded-full border-2 border-white dark:border-gray-800 cursor-crosshair z-10 transition-all",s?"opacity-100 bg-green-400 scale-150 shadow-[0_0_6px_rgba(74,222,128,0.6)]":"opacity-0 group-hover:opacity-100 bg-blue-400"),style:{top:32/2-5}}),a&&!o&&!n&&jsx("span",{className:"absolute left-[3px] cursor-grab active:cursor-grabbing opacity-0 group-hover:opacity-100 transition-opacity z-10",style:{top:32/2-6},children:jsx(pv,{})}),a&&!o&&!n?jsx("button",{type:"button",className:u("w-4 text-xs font-bold flex-shrink-0 text-center cursor-pointer",C.nullable?"text-gray-400":"text-transparent"),onClick:R=>{R.stopPropagation(),O(C.id,C.nullable??false);},onMouseDown:R=>R.stopPropagation(),title:C.nullable?"Nullable":"Not nullable",children:"?"}):jsx("span",{className:u("w-4 text-xs font-bold flex-shrink-0 text-center",C.nullable?"text-gray-400":"text-transparent"),children:C.nullable?"?":""}),C.primaryKey&&C.foreignKey?jsxs("span",{className:"flex items-center gap-0.5 flex-shrink-0",children:[a&&!o&&!n?jsx("button",{type:"button",className:"flex-shrink-0 cursor-pointer",onClick:R=>{R.stopPropagation(),W(C.id,true);},onMouseDown:R=>R.stopPropagation(),title:"Primary Key (click to remove)",children:jsx(us,{})}):jsx(us,{}),jsx(pu,{})]}):C.primaryKey?a&&!o&&!n?jsx("button",{type:"button",className:"flex-shrink-0 cursor-pointer",onClick:R=>{R.stopPropagation(),W(C.id,true);},onMouseDown:R=>R.stopPropagation(),title:"Primary Key (click to remove)",children:jsx(us,{})}):jsx(us,{}):C.foreignKey?jsx(pu,{}):a&&!o&&!n?jsx("button",{type:"button",className:"w-3.5 h-3.5 flex-shrink-0 rounded text-gray-300 hover:text-indigo-400 transition-colors cursor-pointer",onClick:R=>{R.stopPropagation(),W(C.id,false);},onMouseDown:R=>R.stopPropagation(),title:"Set as Primary Key","aria-label":"Set as primary key",children:jsxs("svg",{className:"w-3.5 h-3.5",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",opacity:"0.3",children:[jsx("path",{d:"M10 1l2 2-5 5M8.5 4.5L11 7"}),jsx("circle",{cx:"4.5",cy:"11.5",r:"3"})]})}):jsx("span",{className:"w-3.5 flex-shrink-0"}),a&&!o&&!n?jsx("input",{className:u("flex-1 min-w-0 text-xs bg-transparent border-none outline-none focus:ring-0 p-0 truncate cursor-text",C.primaryKey?"text-blue-600 dark:text-blue-400 font-medium":"text-gray-700 dark:text-gray-300"),"aria-label":"Field name",value:C.name,onChange:R=>k(C.id,R.target.value),onMouseDown:R=>R.stopPropagation()}):jsx("span",{className:u("flex-1 min-w-0 text-xs truncate",C.primaryKey?"text-blue-600 dark:text-blue-400 font-medium":"text-gray-700 dark:text-gray-300"),children:C.name}),a&&!o&&!n?jsxs("select",{className:"text-xs text-gray-400 dark:text-gray-500 bg-transparent border-none outline-none focus:ring-0 p-0 cursor-pointer text-right",value:C.type,onChange:R=>I(C.id,R.target.value),onMouseDown:R=>R.stopPropagation(),children:[y.map(R=>jsx("option",{value:R,children:R},R)),!y.includes(C.type)&&jsx("option",{value:C.type,children:C.type})]}):jsx("span",{className:"text-xs text-gray-400 dark:text-gray-500 flex-shrink-0",children:C.type}),jsx(mv,{field:C,tableId:t.id,editable:a,readOnly:o,disabled:n,onFieldChange:p}),C.indexed&&jsx(mu,{}),C.unique&&jsx(gu,{}),a&&!o&&!n&&jsxs("div",{className:"absolute right-1 top-0 bottom-0 flex items-center gap-0.5 opacity-0 group-hover:opacity-100 transition-opacity bg-gradient-to-l from-white via-white to-transparent dark:from-gray-800 dark:via-gray-800 pl-4 pr-1 z-10",children:[jsx("button",{type:"button",className:u("cursor-pointer transition-opacity",C.indexed?"opacity-100":"opacity-30 hover:opacity-100"),onClick:R=>{R.stopPropagation(),L(C.id,C.indexed??false);},onMouseDown:R=>R.stopPropagation(),title:C.indexed?"Indexed (click to remove)":"Add index",children:jsx(mu,{})}),jsx("button",{type:"button",className:u("cursor-pointer transition-opacity",C.unique?"opacity-100":"opacity-30 hover:opacity-100"),onClick:R=>{R.stopPropagation(),T(C.id,C.unique??false);},onMouseDown:R=>R.stopPropagation(),title:C.unique?"Unique (click to remove)":"Add unique constraint",children:jsx(gu,{})}),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:R=>{R.stopPropagation(),m?.(t.id,C.id);},onMouseDown:R=>R.stopPropagation(),title:"Remove field",children:jsx(uv,{})})]}),jsx("div",{"data-connection-side":"right","data-field-id":C.id,"data-table-id":t.id,className:u("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}})]},C.id)),a&&!o&&!n&&jsxs("button",{type:"button",className:"flex items-center justify-center w-full gap-1 text-xs text-gray-400 hover:text-blue-500 hover:bg-gray-50 dark:hover:bg-gray-750 transition-colors cursor-pointer",style:{height:36},onClick:C=>{C.stopPropagation(),S();},onMouseDown:C=>C.stopPropagation(),children:[jsx("svg",{className:"w-3 h-3",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",children:jsx("path",{d:"M8 4v8M4 8h8"})}),"Add field"]})]}),!n&&!o&&jsx("div",{"data-resize-handle":"corner",className:"absolute -bottom-[5px] -right-[5px] w-[14px] h-[14px] cursor-nwse-resize z-20 group/resize",onMouseDown:C=>{C.stopPropagation(),C.preventDefault();let N=t.height??hn(t,a);x?.(t.id,C.clientX,C.clientY,b,N);},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 fv(e,t){let r=t.find(g=>g.id===e.from.tableId),n=t.find(g=>g.id===e.to.tableId);if(!r||!n||r.collapsed||n.collapsed)return null;let o=r.fields.findIndex(g=>g.id===e.from.fieldId),a=n.fields.findIndex(g=>g.id===e.to.fieldId);if(o===-1||a===-1)return null;let s=r.width??260,l=n.width??260,i=r.x+s/2,d=n.x+l/2,c=r.y+xo(o,!!r.notes),p=n.y+xo(a,!!n.notes),f,m;return i<=d?(f=r.x+s,m=n.x):(f=r.x,m=n.x+l),{x1:f,y1:c,x2:m,y2:p,cardinality:e.cardinality??"1:n"}}var Xi=["1:1","1:n","n:1","n:n"];function bv(e){let t=Xi.indexOf(e);return Xi[(t+1)%Xi.length]}var yu=memo(function({relations:t,tables:r,viewport:n,selectedRelationId:o,disabled:a,onRelationClick:s,onCardinalityChange:l}){return jsx("svg",{className:"absolute top-0 left-0 pointer-events-none",style:{width:"100%",height:"100%",overflow:"visible"},children:jsx("g",{transform:`translate(${n.x}, ${n.y}) scale(${n.zoom})`,children:t.map(i=>{let d=fv(i,r);if(!d)return null;let{x1:c,y1:p,x2:f,y2:m,cardinality:g}=d,x=cs(c,p,f,m),b=o===i.id,v=(c+f)/2,y=(p+m)/2;return jsxs("g",{children:[jsx("path",{d:x,fill:"none",stroke:"transparent",strokeWidth:16,className:"pointer-events-auto cursor-pointer",onClick:M=>{a||s?.(i.id,M);}}),jsx("path",{d:x,fill:"none",stroke:b?"#3b82f6":"#9ca3af",strokeWidth:b?2.5:1.5,className:"transition-colors"}),jsx("circle",{cx:c,cy:p,r:3,fill:b?"#3b82f6":"#9ca3af"}),jsx("circle",{cx:f,cy:m,r:3,fill:b?"#3b82f6":"#9ca3af"}),g&&jsxs("g",{className:a?void 0:"pointer-events-auto cursor-pointer",onClick:a?void 0:M=>{M.stopPropagation(),l?.(i.id,bv(g));},children:[jsx("rect",{x:v-14,y:y-9,width:28,height:18,rx:4,fill:"white",stroke:b?"#3b82f6":"#d1d5db",strokeWidth:1}),jsx("text",{x:v,y:y+4,textAnchor:"middle",className:"text-[10px] font-mono",fill:b?"#3b82f6":"#6b7280",children:g})]})]},i.id)})})})});var yv=()=>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"})}),xv=()=>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"})}),vv=()=>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"})}),kv=()=>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:"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"})}),wv=()=>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"})}),Nv=()=>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"})}),Sv=()=>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"})}),Rv=()=>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"})}),Tv=()=>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"})}),Pv=()=>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"})}),xu=memo(function({zoom:t,onZoomIn:r,onZoomOut:n,onResetView:o,onFitToContent:a,onAddTable:s,onExportJSON:l,onImportJSON:i,onExportSQL:d,onUndo:c,onRedo:p,canUndo:f=false,canRedo:m=false,onAutoLayout:g,disabled:x,className:b}){let[v,y]=useState(false),[M,w]=useState(false),[P,h]=useState(false),[E,D]=useState(""),[k,I]=useState(""),[W,O]=useState(""),L=useCallback(()=>{D(l()),y(true);},[l]),T=useCallback(()=>{k.trim()&&(i(k.trim()),I(""),w(false));},[k,i]),S=useCallback(()=>{I(""),w(false);},[]),C=useCallback(()=>{y(false);},[]),N=useCallback(()=>{d&&(O(d()),h(true));},[d]),R=useCallback(()=>{h(false);},[]),$=Math.round(t*100);return jsxs(Fragment,{children:[jsxs("div",{className:u("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:H=>H.stopPropagation(),children:[jsxs(ao,{size:"sm",children:[jsx(yt,{content:"Zoom in",size:"sm",position:"bottom",children:jsx(ht,{icon:jsx(yv,{}),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:x,"aria-label":"Zoom in"})}),jsx(yt,{content:"Zoom out",size:"sm",position:"bottom",children:jsx(ht,{icon:jsx(xv,{}),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:x,"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:[$,"%"]}),jsx("div",{className:"w-px h-5 bg-gray-200 dark:bg-gray-600"}),jsx(yt,{content:"Reset view",size:"sm",position:"bottom",children:jsx(ht,{icon:jsx(vv,{}),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:x,"aria-label":"Reset view"})}),jsx(yt,{content:"Fit to content",size:"sm",position:"bottom",children:jsx(ht,{icon:jsx(kv,{}),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:x,"aria-label":"Fit to content"})}),jsx("div",{className:"w-px h-5 bg-gray-200 dark:bg-gray-600"}),jsx(yt,{content:"Add table",size:"sm",position:"bottom",children:jsx(ht,{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:s,disabled:x,"aria-label":"Add table"})}),jsx("div",{className:"w-px h-5 bg-gray-200 dark:bg-gray-600"}),jsx(yt,{content:"Export JSON",size:"sm",position:"bottom",children:jsx(ht,{icon:jsx(wv,{}),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:x,"aria-label":"Export JSON"})}),jsx(yt,{content:"Import JSON",size:"sm",position:"bottom",children:jsx(ht,{icon:jsx(Nv,{}),size:"sm",bgColor:"bg-gray-100 hover:bg-gray-200 dark:bg-gray-700 dark:hover:bg-gray-600",textColor:"text-gray-700 dark:text-gray-200",onClick:()=>w(true),disabled:x,"aria-label":"Import JSON"})}),d&&jsx(yt,{content:"Export SQL",size:"sm",position:"bottom",children:jsx(ht,{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:x,"aria-label":"Export SQL"})}),(c||p)&&jsxs(Fragment,{children:[jsx("div",{className:"w-px h-5 bg-gray-200 dark:bg-gray-600"}),jsxs(ao,{size:"sm",children:[jsx(yt,{content:"Undo (Ctrl+Z)",size:"sm",position:"bottom",children:jsx(ht,{icon:jsx(Rv,{}),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:x||!f,"aria-label":"Undo"})}),jsx(yt,{content:"Redo (Ctrl+Y)",size:"sm",position:"bottom",children:jsx(ht,{icon:jsx(Tv,{}),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:x||!m,"aria-label":"Redo"})})]})]}),g&&jsxs(Fragment,{children:[jsx("div",{className:"w-px h-5 bg-gray-200 dark:bg-gray-600"}),jsx(yt,{content:"Auto layout",size:"sm",position:"bottom",children:jsx(ht,{icon:jsx(Pv,{}),size:"sm",bgColor:"bg-gray-100 hover:bg-gray-200 dark:bg-gray-700 dark:hover:bg-gray-600",textColor:"text-gray-700 dark:text-gray-200",onClick:g,disabled:x,"aria-label":"Auto layout"})})]})]}),jsx(rn,{isOpen:v,onClose:C,title:"Export Schema",description:"Copy the JSON below to save your schema.",size:"lg",showSubmit:false,showCancel:true,cancelLabel:"Close",children:jsx(Vr,{label:"Schema JSON",multiline:true,rows:12,value:E,readOnly:true,size:"sm"})}),jsx(rn,{isOpen:M,onClose:S,title:"Import Schema",description:"Paste schema JSON to load it into the editor.",size:"lg",showSubmit:true,submitLabel:"Import",onSubmitClick:T,showCancel:true,cancelLabel:"Cancel",children:jsx(Vr,{label:"Schema JSON",multiline:true,rows:12,value:k,onChange:H=>I(H.target.value),placeholder:'{"tables": [], "relations": []}',size:"sm"})}),jsx(rn,{isOpen:P,onClose:R,title:"Export SQL",description:"Generated PostgreSQL CREATE TABLE statements.",size:"lg",showSubmit:false,showCancel:true,cancelLabel:"Close",children:jsx(Vr,{label:"SQL",multiline:true,rows:16,value:W,readOnly:true,size:"sm"})})]})});var Dv=()=>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"})]}),Mv=()=>jsx("span",{className:"text-xs font-bold text-gray-500 w-3.5 text-center",children:"?"}),Iv=()=>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"})]}),Lv=()=>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"})}),Av=()=>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"})}),vu=memo(function({className:t}){return jsxs("div",{className:u("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(Dv,{}),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(Mv,{}),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(Iv,{}),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(Lv,{}),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(Av,{}),jsx("span",{className:"text-xs text-gray-600 dark:text-gray-300",children:"Unique"})]})]})});var ms=180,gs=120,wo=10,ku=memo(function({tables:t,viewport:r,containerWidth:n,containerHeight:o,editable:a,onViewportChange:s,className:l}){let i=useRef(null),d=useMemo(()=>{if(t.length===0)return null;let P=1/0,h=1/0,E=-1/0,D=-1/0;for(let R of t){let $=R.width??260,H=hn(R,a);P=Math.min(P,R.x),h=Math.min(h,R.y),E=Math.max(E,R.x+$),D=Math.max(D,R.y+H);}let k=-r.x/r.zoom,I=-r.y/r.zoom,W=k+n/r.zoom,O=I+o/r.zoom;P=Math.min(P,k),h=Math.min(h,I),E=Math.max(E,W),D=Math.max(D,O);let L=E-P+wo*2,T=D-h+wo*2,S=Math.min((ms-4)/L,(gs-4)/T),C=(ms-L*S)/2,N=(gs-T*S)/2;return {minX:P,minY:h,scale:S,offsetX:C,offsetY:N,vpMinX:k,vpMinY:I}},[t,r,n,o,a]),c=useCallback(P=>{if(!d)return;let h=i.current?.getBoundingClientRect();if(!h)return;let E=P.clientX-h.left,D=P.clientY-h.top,k=(E-d.offsetX)/d.scale+d.minX-wo,I=(D-d.offsetY)/d.scale+d.minY-wo;s({...r,x:-(k-n/(2*r.zoom))*r.zoom,y:-(I-o/(2*r.zoom))*r.zoom});},[d,r,n,o,s]);if(!d)return null;let{minX:p,minY:f,scale:m,offsetX:g,offsetY:x,vpMinX:b,vpMinY:v}=d,y=(P,h)=>({x:(P-p+wo)*m+g,y:(h-f+wo)*m+x}),M=y(b,v),w={w:n/r.zoom*m,h:o/r.zoom*m};return jsx("div",{ref:i,className:u("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:ms,height:gs},onClick:c,onMouseDown:P=>P.stopPropagation(),"data-testid":"schema-minimap",children:jsxs("svg",{width:ms,height:gs,children:[t.map(P=>{let h=P.width??260,E=hn(P,a),D=y(P.x,P.y);return jsx("rect",{x:D.x,y:D.y,width:h*m,height:E*m,fill:P.color??"#e5e7eb",stroke:"#9ca3af",strokeWidth:.5,rx:1},P.id)}),jsx("rect",{x:M.x,y:M.y,width:w.w,height:w.h,fill:"rgba(59, 130, 246, 0.1)",stroke:"#3b82f6",strokeWidth:1,rx:1})]})})});function sn(e){return `"${e.replace(/"/g,'""')}"`}function Cu(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 Bv(e){let t=[sn(e.name)];return e.type==="serial"||e.type,t.push(Cu(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 Ov(e,t,r){let n=[],o=[];for(let i of e.fields)n.push(Bv(i));for(let i of e.fields)if(i.foreignKey){let d=r.find(p=>p.id===i.foreignKey.tableId),c=d?.fields.find(p=>p.id===i.foreignKey.fieldId);d&&c&&o.push(` CONSTRAINT ${sn(`fk_${e.name}_${i.name}`)} FOREIGN KEY (${sn(i.name)}) REFERENCES ${sn(d.name)} (${sn(c.name)})`);}let a=[];for(let i of e.fields)i.indexed&&!i.primaryKey&&!i.unique&&a.push(`CREATE INDEX ${sn(`idx_${e.name}_${i.name}`)} ON ${sn(e.name)} (${sn(i.name)});`);let s=[...n,...o],l=`CREATE TABLE ${sn(e.name)} (
|
|
24
24
|
${s.join(`,
|
|
25
25
|
`)}
|
|
26
26
|
);`;return a.length>0?l+`
|
|
27
27
|
|
|
28
28
|
`+a.join(`
|
|
29
|
-
`):l}function
|
|
29
|
+
`):l}function fs(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=>Ov(a,r,t)).join(`
|
|
30
30
|
|
|
31
|
-
`)}var zx=60,Wx=40;function vi(e,t){if(e.length===0)return e;let r=new Map;for(let f of e){let h=new Set;for(let y of f.fields)y.foreignKey&&h.add(y.foreignKey.tableId);r.set(f.id,h);}let o=new Map;for(let f of e)o.set(f.id,0);for(let[,f]of r)for(let h of f)o.has(h);for(let[f,h]of r)o.set(f,h.size);let n=[],a=[];for(let[f,h]of o)h===0&&a.push(f);for(;a.length>0;){let f=a.shift();n.push(f);for(let[h,y]of r)if(y.has(f)){let C=(o.get(h)??0)-1;o.set(h,C),C===0&&a.push(h);}}let s=new Set(n);for(let f of e)s.has(f.id)||(n.push(f.id),s.add(f.id));let l=new Map(e.map(f=>[f.id,f])),i=Math.max(1,Math.ceil(Math.sqrt(n.length))),d=0,u=0,p=0,b=0,m=[];for(let f of n){let h=l.get(f);if(!h)continue;let y=h.width??260,C=io(h,t);m.push({...h,x:d,y:u}),b=Math.max(b,C),p++,p>=i?(p=0,d=0,u+=b+Wx,b=0):d+=y+zx;}return m}var wi={x:0,y:0,zoom:1},Ci=.1,Vx=.1,Ox=3,$x=20,_x=50;function Gx({value:e,defaultValue:t,onValueChange:r,fieldTypes:o=jn,onTableClick:n,onTableDoubleClick:a,onTableContextMenu:s,onFieldClick:l,onFieldDoubleClick:i,readOnly:d=false,disabled:u=false,draggableTables:p=true,panOnDrag:b=true,zoomOnWheel:m=true,editable:f=true,minZoom:h=Vx,maxZoom:y=Ox,snapToGrid:C=false,gridSize:v=$x,showGrid:E=true,toolbar:k=true,legend:R=true,autoFit:g=false,className:P},T){let D=e!==void 0,[W,V]=useState(()=>t??{tables:[],relations:[],viewport:{...wi}}),_=D?e:W,M=_.tables,w=_.relations,N=_.viewport??wi,x=useRef(null),S=useRef(null),[I,F]=useState(null),[O,Z]=useState(null),[U,H]=useState(null),[z,$]=useState(null),[K,se]=useState({width:0,height:0}),X=useRef([]),ee=useRef(-1),L=useRef(false),q=useRef(N);q.current=N;let ge=useRef(M);ge.current=M;let de=useRef(w);de.current=w;let Y=useRef(C);Y.current=C;let le=useRef(v);le.current=v;let xe=useRef(f);xe.current=f;let Se=useCallback(B=>{if(L.current)return;let Q=X.current,oe=ee.current;X.current=Q.slice(0,oe+1),X.current.push(B),X.current.length>_x&&X.current.shift(),ee.current=X.current.length-1;},[]),te=useCallback(B=>{if(D){let Q=B(e);Se(Q),r?.(Q);}else V(Q=>{let oe=B(Q);return Se(oe),r?.(oe),oe});},[D,e,r,Se]),Ne=useRef(te);Ne.current=te;let De=useCallback(B=>{te(Q=>({...Q,viewport:B}));},[te]),Ve=useRef(De);Ve.current=De,useEffect(()=>{function B(ne){let ce=S.current;if(!ce)return;let Fe=x.current?.getBoundingClientRect();if(!Fe)return;let Ye=q.current;if(ce.type==="pan"){let _e=ne.clientX-ce.startX,Ie=ne.clientY-ce.startY;Ve.current({...Ye,x:ce.startVpX+_e,y:ce.startVpY+Ie});}if(ce.type==="table"){let _e=Un(ne.clientX,ne.clientY,Ye,Fe),Ie=_e.x-ce.offsetX,Pt=_e.y-ce.offsetY;Y.current&&(Ie=ui(Ie,le.current),Pt=ui(Pt,le.current)),Ne.current(Ge=>({...Ge,tables:Ge.tables.map(ut=>ut.id===ce.tableId?{...ut,x:Ie,y:Pt}:ut)}));}if(ce.type==="relation"){let _e=Un(ne.clientX,ne.clientY,Ye,Fe);S.current={...ce,currentX:_e.x,currentY:_e.y},H({fromX:ce.fromX,fromY:ce.fromY,currentX:_e.x,currentY:_e.y});}if(ce.type==="resize"){let _e=(ne.clientX-ce.startX)/Ye.zoom,Ie=(ne.clientY-ce.startY)/Ye.zoom,Pt=180,Ge=80,ut=Math.max(Pt,ce.startWidth+_e),xt=Math.max(Ge,ce.startHeight+Ie);Ne.current(at=>({...at,tables:at.tables.map(Mt=>Mt.id===ce.tableId?{...Mt,width:ut,height:xt}:Mt)}));}}function Q(ne,ce,Fe,Ye){let _e=q.current,Ie=Un(ne,ce,_e,Fe),Pt=1/0,Ge=null,ut=null;for(let xt of Ye){if(xt.collapsed)continue;let at=xt.fields.length;if(at===0)continue;let Mt=xt.width??260,yr=40+at*32+(xe.current?36:0),xr=40;if(!(Ie.x<xt.x-xr||Ie.x>xt.x+Mt+xr||Ie.y<xt.y-xr||Ie.y>xt.y+yr+xr))for(let Kt=0;Kt<xt.fields.length;Kt++){let rs=xt.y+on(Kt,!!xt.notes),Qn=Math.abs(Ie.y-rs);Qn<Pt&&(Pt=Qn,Ge=xt.id,ut=xt.fields[Kt].id);}}return Ge&&ut?{tableId:Ge,fieldId:ut}:null}function oe(ne){let ce=S.current;if(ce){if(ce.type==="relation"){let Fe=x.current?.getBoundingClientRect();if(Fe){let Ye=de.current,_e=ge.current,Ie=Q(ne.clientX,ne.clientY,Fe,_e);if(Ie&&Ie.tableId!==ce.fromTableId&&!Ye.some(Ge=>Ge.from.tableId===ce.fromTableId&&Ge.from.fieldId===ce.fromFieldId&&Ge.to.tableId===Ie.tableId&&Ge.to.fieldId===Ie.fieldId)){let Ge=ce.fromTableId,ut=ce.fromFieldId,xt=Ie.tableId,at=Ie.fieldId;Ne.current(Mt=>({...Mt,tables:Mt.tables.map(yr=>yr.id===xt?{...yr,fields:yr.fields.map(xr=>xr.id===at?{...xr,foreignKey:{tableId:Ge,fieldId:ut}}:xr)}:yr),relations:[...Mt.relations,{id:pi(),from:{tableId:Ge,fieldId:ut},to:{tableId:xt,fieldId:at},cardinality:"1:n"}]}));}}H(null),$(null);}S.current=null;}}return document.addEventListener("mousemove",B),document.addEventListener("mouseup",oe),()=>{document.removeEventListener("mousemove",B),document.removeEventListener("mouseup",oe);}},[]);let rt=useCallback(B=>{if(!m||u)return;B.preventDefault();let Q=x.current?.getBoundingClientRect();if(!Q)return;let oe=B.clientX-Q.left,ne=B.clientY-Q.top,ce=B.deltaY<0?1:-1,Fe=Kn(N.zoom+ce*Ci,h,y),Ye=Fe/N.zoom;De({x:oe-(oe-N.x)*Ye,y:ne-(ne-N.y)*Ye,zoom:Fe});},[m,u,N,h,y,De]),dt=useCallback(B=>{if(u)return;let Q=B.target,oe=Q.tagName,ne=oe==="INPUT"||oe==="SELECT"||oe==="TEXTAREA"||oe==="BUTTON";if(Q.closest("[data-resize-handle]"))return;let ce=Q.closest("[data-connection-side]");if(ce&&!ne){if(d)return;B.preventDefault();let Ye=ce.getAttribute("data-table-id"),_e=ce.getAttribute("data-field-id");if(!Ye||!_e)return;let Ie=M.find(ut=>ut.id===Ye);if(!Ie)return;let Pt=ce.getAttribute("data-connection-side"),Ge=Pc(Ie,_e,Pt);if(!Ge)return;S.current={type:"relation",fromTableId:Ye,fromFieldId:_e,fromX:Ge.x,fromY:Ge.y,currentX:Ge.x,currentY:Ge.y},H({fromX:Ge.x,fromY:Ge.y,currentX:Ge.x,currentY:Ge.y}),$(Ye);return}let Fe=Q.closest("[data-table-id]");if(Fe){if(d)return;let Ye=Fe.getAttribute("data-table-id");if(Z(null),F(Ye),ne)return;if(p){let _e=x.current?.getBoundingClientRect();if(!_e)return;let Ie=M.find(Ge=>Ge.id===Ye);if(!Ie||Ie.locked)return;let Pt=Un(B.clientX,B.clientY,N,_e);S.current={type:"table",tableId:Ye,offsetX:Pt.x-Ie.x,offsetY:Pt.y-Ie.y};}return}F(null),Z(null),b&&B.button===0&&(S.current={type:"pan",startX:B.clientX,startY:B.clientY,startVpX:N.x,startVpY:N.y});},[u,d,p,b,N,M]),re=useCallback(B=>{let Q=B.target;if(Q.closest("[data-connection-side]"))return null;let oe=Q.closest("[data-table-id]");if(!oe)return null;let ne=oe.getAttribute("data-table-id");return M.find(ce=>ce.id===ne)??null},[M]),pe=useCallback(B=>{if(u)return;let Q=re(B);Q&&n&&n({table:Q,nativeEvent:B.nativeEvent});},[n,u,re]),Ue=useCallback(B=>{if(u)return;let Q=re(B);Q&&a&&a({table:Q,nativeEvent:B.nativeEvent});},[a,u,re]),yt=useCallback(B=>{if(u)return;let Q=re(B);Q&&s&&(B.preventDefault(),s({table:Q,nativeEvent:B.nativeEvent}));},[s,u,re]),Re=useCallback((B,Q)=>{u||(Q.stopPropagation(),F(null),Z(B));},[u]),We=useCallback((B,Q)=>{te(oe=>({...oe,relations:oe.relations.map(ne=>ne.id===B?{...ne,cardinality:Q}:ne)}));},[te]),ft=ee.current>0,rr=ee.current<X.current.length-1,ot=useCallback(()=>{if(ee.current<=0)return;L.current=true,ee.current--;let B=X.current[ee.current];D||V(B),r?.(B),L.current=false;},[D,r]),Wt=useCallback(()=>{if(ee.current>=X.current.length-1)return;L.current=true,ee.current++;let B=X.current[ee.current];D||V(B),r?.(B),L.current=false;},[D,r]),Nt=useCallback(()=>ja(_),[_]),Ht=useCallback(()=>{te(B=>({...B,tables:vi(B.tables,f)}));},[te,f]),or=useCallback((B,Q,oe)=>{Q!==oe&&te(ne=>({...ne,tables:ne.tables.map(ce=>{if(ce.id!==B)return ce;let Fe=[...ce.fields],[Ye]=Fe.splice(Q,1);return Fe.splice(oe,0,Ye),{...ce,fields:Fe}})}));},[te]);useEffect(()=>{let B=x.current;if(!B)return;let Q=new ResizeObserver(oe=>{for(let ne of oe)se({width:ne.contentRect.width,height:ne.contentRect.height});});return Q.observe(B),()=>Q.disconnect()},[]);let Zt=useRef(false);Zt.current||(Zt.current=true,X.current=[_],ee.current=0);let Ar=useCallback(B=>{if(!(d||u)){if((B.ctrlKey||B.metaKey)&&B.key==="z"&&!B.shiftKey){B.preventDefault(),ot();return}if((B.ctrlKey||B.metaKey)&&(B.key==="y"||B.key==="z"&&B.shiftKey)){B.preventDefault(),Wt();return}if(B.key==="Delete"||B.key==="Backspace"){let Q=B.target;if(Q.tagName==="INPUT"||Q.tagName==="TEXTAREA"||Q.tagName==="SELECT")return;I&&(te(oe=>({...oe,tables:oe.tables.filter(ne=>ne.id!==I),relations:oe.relations.filter(ne=>ne.from.tableId!==I&&ne.to.tableId!==I)})),F(null)),O&&(te(oe=>{let ne=oe.relations.find(ce=>ce.id===O);return {...oe,tables:ne?oe.tables.map(ce=>ce.id===ne.to.tableId?{...ce,fields:ce.fields.map(Fe=>Fe.id===ne.to.fieldId?{...Fe,foreignKey:void 0}:Fe)}:ce):oe.tables,relations:oe.relations.filter(ce=>ce.id!==O)}}),Z(null));}B.key==="Escape"&&(F(null),Z(null));}},[d,u,I,O,te,ot,Wt]),br=useCallback((B,Q)=>{te(oe=>({...oe,tables:oe.tables.map(ne=>ne.id===B?{...ne,name:Q}:ne)}));},[te]),fe=useCallback((B,Q)=>{te(oe=>({...oe,tables:oe.tables.map(ne=>ne.id===B?{...ne,notes:Q}:ne)}));},[te]),he=useCallback(B=>{te(Q=>({...Q,tables:Q.tables.map(oe=>oe.id===B?{...oe,collapsed:!oe.collapsed}:oe)}));},[te]),j=useCallback((B,Q,oe)=>{te(ne=>({...ne,tables:ne.tables.map(ce=>ce.id===B?{...ce,fields:ce.fields.map(Fe=>Fe.id===Q?{...Fe,...oe}:Fe)}:ce)}));},[te]),J=useCallback(B=>{te(Q=>({...Q,tables:Q.tables.map(oe=>oe.id===B?{...oe,fields:[...oe.fields,gi()]}:oe)}));},[te]),me=useCallback((B,Q)=>{te(oe=>({...oe,tables:oe.tables.map(ne=>ne.id===B?{...ne,fields:ne.fields.filter(ce=>ce.id!==Q)}:ne),relations:oe.relations.filter(ne=>!(ne.from.tableId===B&&ne.from.fieldId===Q)&&!(ne.to.tableId===B&&ne.to.fieldId===Q))}));},[te]),ue=useCallback((B,Q,oe,ne,ce)=>{S.current={type:"resize",tableId:B,startX:Q,startY:oe,startWidth:ne,startHeight:ce};},[]),Te=useCallback(()=>{let B=Kn(N.zoom+Ci,h,y);De({...N,zoom:B});},[N,h,y,De]),ve=useCallback(()=>{let B=Kn(N.zoom-Ci,h,y);De({...N,zoom:B});},[N,h,y,De]),we=useCallback(()=>{De({...wi});},[De]),He=useCallback(()=>{let B=x.current?.getBoundingClientRect();if(!B)return;let Q=Ec(M,B.width,B.height,f),oe=Kn(Q.zoom,h,y);De({...Q,zoom:oe});},[M,f,h,y,De]),Me=useCallback(B=>{te(Q=>({...Q,tables:[...Q.tables,B]}));},[te]),tt=useCallback(B=>{te(Q=>({...Q,tables:Q.tables.filter(oe=>oe.id!==B),relations:Q.relations.filter(oe=>oe.from.tableId!==B&&oe.to.tableId!==B)}));},[te]),je=useCallback((B,Q)=>{te(oe=>({...oe,tables:oe.tables.map(ne=>ne.id===B?{...ne,fields:[...ne.fields,Q]}:ne)}));},[te]),$e=useCallback((B,Q)=>{me(B,Q);},[me]),Tt=useCallback(B=>{te(Q=>({...Q,tables:Q.tables.map(oe=>oe.id===B.to.tableId?{...oe,fields:oe.fields.map(ne=>ne.id===B.to.fieldId?{...ne,foreignKey:{tableId:B.from.tableId,fieldId:B.from.fieldId}}:ne)}:oe),relations:[...Q.relations,B]}));},[te]),nt=useCallback(B=>{te(Q=>{let oe=Q.relations.find(ne=>ne.id===B);return {...Q,tables:oe?Q.tables.map(ne=>ne.id===oe.to.tableId?{...ne,fields:ne.fields.map(ce=>ce.id===oe.to.fieldId?{...ce,foreignKey:void 0}:ce)}:ne):Q.tables,relations:Q.relations.filter(ne=>ne.id!==B)}});},[te]),nr=useCallback(()=>JSON.stringify(_,null,2),[_]),zr=useCallback(B=>{try{let Q=JSON.parse(B);Q&&Array.isArray(Q.tables)&&Array.isArray(Q.relations)&&te(()=>Q);}catch{}},[te]),mo=useCallback(()=>{let B=x.current?.getBoundingClientRect(),Q=q.current,oe=100,ne=100;B&&(oe=(B.width/2-Q.x)/Q.zoom-260/2,ne=(B.height/2-Q.y)/Q.zoom-60),Me(mi(oe,ne));},[Me]),Ao=useCallback(()=>ja(_),[_]);useImperativeHandle(T,()=>({zoomIn:Te,zoomOut:ve,resetView:we,fitToContent:He,addTable:Me,removeTable:tt,addField:je,removeField:$e,addRelation:Tt,removeRelation:nt,toJSON:nr,loadJSON:zr,toSQL:Ao}),[Te,ve,we,He,Me,tt,je,$e,Tt,nt,nr,zr,Ao]);let hr=useRef(false);useEffect(()=>{g&&!hr.current&&x.current&&(hr.current=true,He());},[g,He]);let ar=useMemo(()=>({transform:`translate(${N.x}px, ${N.y}px) scale(${N.zoom})`,transformOrigin:"0 0"}),[N.x,N.y,N.zoom]);return jsxs("div",{ref:x,"data-testid":"schema-editor",className:c("relative w-full overflow-hidden bg-gray-50 dark:bg-gray-900 select-none",u&&"opacity-60 pointer-events-none",P),tabIndex:0,onWheel:rt,onMouseDown:dt,onClick:pe,onDoubleClick:Ue,onContextMenu:yt,onKeyDown:Ar,children:[E&&jsx(Tc,{gridSize:v,zoom:N.zoom}),k&&!d&&jsx(Bc,{zoom:N.zoom,onZoomIn:Te,onZoomOut:ve,onResetView:we,onFitToContent:He,onAddTable:mo,onExportJSON:nr,onImportJSON:zr,onExportSQL:Nt,onUndo:ot,onRedo:Wt,canUndo:ft,canRedo:rr,onAutoLayout:Ht,disabled:u}),R&&jsx(Vc,{}),jsx(Fc,{relations:w,tables:M,viewport:N,selectedRelationId:O,disabled:u||d,onRelationClick:Re,onCardinalityChange:We}),jsx("div",{style:ar,children:M.map(B=>jsx(Wc,{table:B,selected:I===B.id,disabled:u||d,readOnly:d,editable:f,dropTarget:z!==null&&z!==B.id&&!B.collapsed,fieldTypes:o,onTableNameChange:br,onTableNotesChange:fe,onToggleCollapse:he,onFieldChange:j,onFieldAdd:J,onFieldRemove:me,onFieldReorder:or,onResizeStart:ue},B.id))}),U&&jsxs("svg",{"data-testid":"drag-relation-overlay",style:{position:"absolute",top:0,left:0,width:"100%",height:"100%",pointerEvents:"none",zIndex:1e3,overflow:"visible"},children:[jsx("path",{d:Ga(U.fromX*N.zoom+N.x,U.fromY*N.zoom+N.y,U.currentX*N.zoom+N.x,U.currentY*N.zoom+N.y),fill:"none",stroke:"#3b82f6",strokeWidth:2.5,strokeDasharray:"8 4"}),jsx("circle",{cx:U.fromX*N.zoom+N.x,cy:U.fromY*N.zoom+N.y,r:5,fill:"#3b82f6"}),jsx("circle",{cx:U.currentX*N.zoom+N.x,cy:U.currentY*N.zoom+N.y,r:4,fill:"#3b82f6",opacity:.6})]}),R&&K.width>0&&jsx(Oc,{tables:M,viewport:N,containerWidth:K.width,containerHeight:K.height,editable:f,onViewportChange:De})]})}var Gc=forwardRef(Gx);Gc.displayName="SchemaEditor";var Xc="wf-grid-pattern",Kc=memo(function({gridSize:t,zoom:r}){let o=t*r;return jsxs("svg",{className:"absolute inset-0 w-full h-full pointer-events-none","aria-hidden":"true",children:[jsx("defs",{children:jsx("pattern",{id:Xc,width:o,height:o,patternUnits:"userSpaceOnUse",children:jsx("circle",{cx:1,cy:1,r:1,className:"fill-gray-300 dark:fill-gray-600"})})}),jsx("rect",{width:"100%",height:"100%",fill:`url(#${Xc})`})]})});function Ni(e,t){return Math.round(e/t)*t}function Zn(e,t,r){return Math.min(r,Math.max(t,e))}function cn(e,t,r,o){return {x:(e-o.left-r.x)/r.zoom,y:(t-o.top-r.y)/r.zoom}}function qn(e,t="horizontal"){return t==="vertical"?e==="in"?"top":"bottom":e==="in"?"left":"right"}function un(e,t,r,o="horizontal"){let n=e.width??180,a=e.height??60,s=t.side??qn(t.kind,o),l=r.filter(p=>(p.side??qn(p.kind,o))===s),i=l.findIndex(p=>p.id===t.id),d=l.length,u=d===1?.5:(i+1)/(d+1);switch(s){case "left":return {x:e.x-8,y:e.y+a*u};case "right":return {x:e.x+n+8,y:e.y+a*u};case "top":return {x:e.x+n*u,y:e.y-8};case "bottom":return {x:e.x+n*u,y:e.y+a+8}}}function Za(e,t,r,o,n="horizontal"){if(n==="vertical"){let p=Math.abs(o-t),b=Math.max(50,p*.5),m=e,f=t+b,h=r,y=o-b;return `M ${e} ${t} C ${m} ${f}, ${h} ${y}, ${r} ${o}`}let a=Math.abs(r-e),s=Math.max(50,a*.5),l=e+s,i=t,d=r-s;return `M ${e} ${t} C ${l} ${i}, ${d} ${o}, ${r} ${o}`}function Uc(e,t,r,o=40){if(e.length===0)return {x:0,y:0,zoom:1};let n=1/0,a=1/0,s=-1/0,l=-1/0;for(let m of e){let f=m.width??180,h=m.height??60;n=Math.min(n,m.x),a=Math.min(a,m.y),s=Math.max(s,m.x+f),l=Math.max(l,m.y+h);}let i=s-n+o*2,d=l-a+o*2,u=Math.min(t/i,r/d,1),p=(t-i*u)/2-(n-o)*u,b=(r-d*u)/2-(a-o)*u;return {x:p,y:b,zoom:u}}var Yx=180,jx=60,Ja=12,pn=28,Ri=24,qx=-8;function Zx(e,t,r,o,n="horizontal"){let a=e.side??qn(e.kind,n),s=t.filter(u=>(u.side??qn(u.kind,n))===a),l=s.findIndex(u=>u.id===e.id),i=s.length,d=i===1?.5:(l+1)/(i+1);switch(a){case "left":return {left:0,top:o*d};case "right":return {left:r,top:o*d};case "top":return {left:r*d,top:0};case "bottom":return {left:r*d,top:o}}}function Jx({port:e,allPorts:t,nodeId:r,nodeWidth:o,nodeHeight:n,disabled:a,direction:s,onMouseUp:l}){let i=Zx(e,t,o,n,s),d=a||e.disabled,u=useCallback(p=>{d||(p.stopPropagation(),l(r,e.id));},[d,r,e.id,l]);return jsx("div",{"data-testid":`port-${r}-${e.id}`,"data-port-id":e.id,"data-port-kind":e.kind,"data-node-id":r,className:"absolute",style:{left:i.left-pn/2,top:i.top-pn/2,width:pn,height:pn,zIndex:20},onMouseUp:u,title:e.label??e.id,children:jsx("div",{className:c("absolute rounded-full border-2 transition-colors",d?"bg-gray-300 border-gray-400 cursor-not-allowed":e.kind==="in"?"bg-blue-400 border-blue-600 hover:bg-blue-300 cursor-crosshair":"bg-green-400 border-green-600 hover:bg-green-300 cursor-crosshair"),style:{width:Ja,height:Ja,left:(pn-Ja)/2,top:(pn-Ja)/2}})})}function Qx(e,t,r){let o=e??"top-right",n=qx,a=t*(Ri+4);switch(o){case "top-right":return {top:n,right:n-a};case "top-left":return {top:n,left:n+a};case "bottom-right":return {bottom:n,right:n-a};case "bottom-left":return {bottom:n,left:n+a}}}function ev({action:e,nodeId:t,index:r,nodeWidth:o,disabled:n,onActionClick:a}){let s=useCallback(d=>{d.stopPropagation(),d.preventDefault(),!n&&a(t,e.id,d.nativeEvent);},[n,t,e.id,a]),l=useCallback(d=>{d.stopPropagation();},[]),i=Qx(e.position,r);return jsx("button",{"data-testid":`action-${t}-${e.id}`,"data-action-id":e.id,"data-node-id":t,type:"button",className:c("absolute flex items-center justify-center rounded-full border shadow-sm transition-all","bg-white border-gray-300 text-gray-600","hover:bg-gray-50 hover:border-gray-400 hover:text-gray-800 hover:shadow-md","active:scale-95",n&&"opacity-50 cursor-not-allowed",!n&&"cursor-pointer",e.className),style:{...i,width:Ri,height:Ri,zIndex:30},onClick:s,onMouseDown:l,title:e.label,disabled:n,children:jsx("span",{className:"flex items-center justify-center w-3.5 h-3.5 [&>svg]:w-full [&>svg]:h-full",children:e.icon})})}var Yc=memo(function({node:t,registry:r,ports:o,selected:n,disabled:a,draggable:s,direction:l,onPortMouseUp:i,onActionClick:d}){let u=t.width??Yx,p=t.height??jx,b=r.render({node:t,selected:n,disabled:a}),f=(typeof r.actions=="function"?r.actions(t):r.actions)?.filter(y=>typeof y.hidden=="function"?!y.hidden(t):!y.hidden),h=new Map;if(f)for(let y of f){let C=y.position??"top-right",v=h.get(C)??[];v.push(y),h.set(C,v);}return jsxs("div",{"data-testid":`workflow-node-${t.id}`,"data-node-id":t.id,className:c("absolute select-none group/node",s&&!t.locked&&"cursor-grab active:cursor-grabbing",t.locked&&"cursor-not-allowed opacity-75",n&&"ring-2 ring-blue-500 ring-offset-1 rounded-lg"),style:{left:t.x,top:t.y,width:u,height:p,overflow:"visible"},children:[b,o.map(y=>jsx(Jx,{port:y,allPorts:o,nodeId:t.id,nodeWidth:u,nodeHeight:p,disabled:a,direction:l,onMouseUp:i},y.id)),d&&h.size>0&&Array.from(h.entries()).map(([,y])=>y.map((C,v)=>jsx(ev,{action:C,nodeId:t.id,index:v,nodeWidth:u,disabled:a,onActionClick:d},C.id)))]})});function jc(e,t,r,o,n="horizontal"){let a=r.find(i=>i.id===e);if(!a)return null;let s=o(a),l=s.find(i=>i.id===t);return l?un(a,l,s,n):null}var ov=memo(function({edge:t,fromPos:r,toPos:o,selected:n,disabled:a,direction:s,onClick:l}){let i=Za(r.x,r.y,o.x,o.y,s),d=(r.x+o.x)/2,u=(r.y+o.y)/2,p=useCallback(b=>{b.stopPropagation(),l(t.id,b);},[t.id,l]);return jsxs("g",{"data-testid":`workflow-edge-${t.id}`,children:[jsx("path",{d:i,fill:"none",stroke:"transparent",strokeWidth:16,className:"cursor-pointer",onClick:p}),jsx("path",{d:i,fill:"none",className:c("transition-colors pointer-events-none",a||t.disabled?"stroke-gray-300":n?"stroke-blue-500":"stroke-gray-400"),strokeWidth:n?2.5:2,strokeDasharray:t.disabled?"6 3":void 0}),t.label&&jsx("text",{x:d,y:u-8,textAnchor:"middle",className:"fill-gray-600 dark:fill-gray-300 text-xs pointer-events-none select-none",fontSize:11,children:t.label})]})}),Zc=memo(function({edges:t,nodes:r,selectedEdgeId:o,disabled:n,direction:a,onEdgeClick:s,getNodePorts:l}){return jsx("svg",{className:"absolute pointer-events-none",style:{top:0,left:0,width:1,height:1,overflow:"visible"},children:jsx("g",{className:"pointer-events-auto",children:t.map(i=>{let d=jc(i.from.nodeId,i.from.portId,r,l,a),u=jc(i.to.nodeId,i.to.portId,r,l,a);return !d||!u?null:jsx(ov,{edge:i,fromPos:d,toPos:u,selected:i.id===o,disabled:n,direction:a,onClick:s},i.id)})})})});var sv=()=>jsx("svg",{className:"w-4 h-4",viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true",children:jsx("path",{fillRule:"evenodd",d:"M10 5a1 1 0 011 1v3h3a1 1 0 110 2h-3v3a1 1 0 11-2 0v-3H6a1 1 0 110-2h3V6a1 1 0 011-1z",clipRule:"evenodd"})}),iv=()=>jsx("svg",{className:"w-4 h-4",viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true",children:jsx("path",{fillRule:"evenodd",d:"M5 10a1 1 0 011-1h8a1 1 0 110 2H6a1 1 0 01-1-1z",clipRule:"evenodd"})}),lv=()=>jsx("svg",{className:"w-4 h-4",viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true",children:jsx("path",{fillRule:"evenodd",d:"M4 2a1 1 0 011 1v2.101a7.002 7.002 0 0111.601 2.566 1 1 0 11-1.885.666A5.002 5.002 0 005.999 7H9a1 1 0 010 2H4a1 1 0 01-1-1V3a1 1 0 011-1zm.008 9.057a1 1 0 011.276.61A5.002 5.002 0 0014.001 13H11a1 1 0 110-2h5a1 1 0 011 1v5a1 1 0 11-2 0v-2.101a7.002 7.002 0 01-11.601-2.566 1 1 0 01.61-1.276z",clipRule:"evenodd"})}),dv=()=>jsx("svg",{className:"w-4 h-4",viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true",children:jsx("path",{d:"M3 4a1 1 0 011-1h4a1 1 0 010 2H6.414l2.293 2.293a1 1 0 01-1.414 1.414L5 6.414V8a1 1 0 01-2 0V4zm9 1a1 1 0 010-2h4a1 1 0 011 1v4a1 1 0 01-2 0V6.414l-2.293 2.293a1 1 0 11-1.414-1.414L13.586 5H12zm-9 7a1 1 0 012 0v1.586l2.293-2.293a1 1 0 011.414 1.414L6.414 15H8a1 1 0 010 2H4a1 1 0 01-1-1v-4zm13 0a1 1 0 01-2 0v-1.586l-2.293 2.293a1 1 0 01-1.414-1.414L13.586 9H12a1 1 0 010-2h4a1 1 0 011 1v4z"})}),cv=()=>jsx("svg",{className:"w-4 h-4",viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true",children:jsx("path",{fillRule:"evenodd",d:"M3 17a1 1 0 011-1h12a1 1 0 110 2H4a1 1 0 01-1-1zm3.293-7.707a1 1 0 011.414 0L9 10.586V3a1 1 0 112 0v7.586l1.293-1.293a1 1 0 111.414 1.414l-3 3a1 1 0 01-1.414 0l-3-3a1 1 0 010-1.414z",clipRule:"evenodd"})}),uv=()=>jsx("svg",{className:"w-4 h-4",viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true",children:jsx("path",{fillRule:"evenodd",d:"M3 17a1 1 0 011-1h12a1 1 0 110 2H4a1 1 0 01-1-1zM6.293 6.707a1 1 0 010-1.414l3-3a1 1 0 011.414 0l3 3a1 1 0 01-1.414 1.414L11 5.414V13a1 1 0 11-2 0V5.414L7.707 6.707a1 1 0 01-1.414 0z",clipRule:"evenodd"})}),pv=()=>jsx("svg",{className:"w-4 h-4",viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true",children:jsx("path",{fillRule:"evenodd",d:"M10.293 3.293a1 1 0 011.414 0l6 6a1 1 0 010 1.414l-6 6a1 1 0 01-1.414-1.414L14.586 11H3a1 1 0 110-2h11.586l-4.293-4.293a1 1 0 010-1.414z",clipRule:"evenodd"})}),gv=()=>jsx("svg",{className:"w-4 h-4",viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true",children:jsx("path",{fillRule:"evenodd",d:"M16.707 10.293a1 1 0 010 1.414l-6 6a1 1 0 01-1.414 0l-6-6a1 1 0 111.414-1.414L9 14.586V3a1 1 0 012 0v11.586l4.293-4.293a1 1 0 011.414 0z",clipRule:"evenodd"})}),Qc=memo(function({zoom:t,direction:r,onDirectionChange:o,onZoomIn:n,onZoomOut:a,onResetView:s,onFitToContent:l,onExportJSON:i,onImportJSON:d,disabled:u,className:p}){let[b,m]=useState(false),[f,h]=useState(false),[y,C]=useState(""),[v,E]=useState(""),k=useCallback(()=>{C(i()),m(true);},[i]),R=useCallback(()=>{v.trim()&&(d(v.trim()),E(""),h(false));},[v,d]),g=useCallback(()=>{E(""),h(false);},[]),P=useCallback(()=>{m(false);},[]),T=Math.round(t*100);return jsxs(Fragment,{children:[jsxs("div",{className:c("absolute top-3 left-3 z-20 flex items-center gap-2 bg-white dark:bg-gray-800 rounded-lg shadow-md border border-gray-200 dark:border-gray-600 px-2 py-1.5",p),"data-testid":"workflow-toolbar",children:[jsxs(Go,{size:"sm",children:[jsx(mt,{content:"Zoom in",size:"sm",position:"bottom",children:jsx(gt,{icon:jsx(sv,{}),size:"sm",bgColor:"bg-gray-100 hover:bg-gray-200 dark:bg-gray-700 dark:hover:bg-gray-600",textColor:"text-gray-700 dark:text-gray-200",onClick:n,disabled:u,"aria-label":"Zoom in"})}),jsx(mt,{content:"Zoom out",size:"sm",position:"bottom",children:jsx(gt,{icon:jsx(iv,{}),size:"sm",bgColor:"bg-gray-100 hover:bg-gray-200 dark:bg-gray-700 dark:hover:bg-gray-600",textColor:"text-gray-700 dark:text-gray-200",onClick:a,disabled:u,"aria-label":"Zoom out"})})]}),jsxs("span",{className:"text-xs font-mono text-gray-500 dark:text-gray-400 min-w-[3ch] text-center select-none",children:[T,"%"]}),jsx("div",{className:"w-px h-5 bg-gray-200 dark:bg-gray-600"}),jsx(mt,{content:"Reset view",size:"sm",position:"bottom",children:jsx(gt,{icon:jsx(lv,{}),size:"sm",bgColor:"bg-gray-100 hover:bg-gray-200 dark:bg-gray-700 dark:hover:bg-gray-600",textColor:"text-gray-700 dark:text-gray-200",onClick:s,disabled:u,"aria-label":"Reset view"})}),jsx(mt,{content:"Fit to content",size:"sm",position:"bottom",children:jsx(gt,{icon:jsx(dv,{}),size:"sm",bgColor:"bg-gray-100 hover:bg-gray-200 dark:bg-gray-700 dark:hover:bg-gray-600",textColor:"text-gray-700 dark:text-gray-200",onClick:l,disabled:u,"aria-label":"Fit to content"})}),o&&jsxs(Fragment,{children:[jsx("div",{className:"w-px h-5 bg-gray-200 dark:bg-gray-600"}),jsx(mt,{content:r==="horizontal"?"Switch to vertical":"Switch to horizontal",size:"sm",position:"bottom",children:jsx(gt,{icon:r==="horizontal"?jsx(pv,{}):jsx(gv,{}),size:"sm",bgColor:"bg-gray-100 hover:bg-gray-200 dark:bg-gray-700 dark:hover:bg-gray-600",textColor:"text-gray-700 dark:text-gray-200",onClick:()=>o(r==="horizontal"?"vertical":"horizontal"),disabled:u,"aria-label":r==="horizontal"?"Switch to vertical":"Switch to horizontal"})})]}),jsx("div",{className:"w-px h-5 bg-gray-200 dark:bg-gray-600"}),jsx(mt,{content:"Export JSON",size:"sm",position:"bottom",children:jsx(gt,{icon:jsx(cv,{}),size:"sm",bgColor:"bg-gray-100 hover:bg-gray-200 dark:bg-gray-700 dark:hover:bg-gray-600",textColor:"text-gray-700 dark:text-gray-200",onClick:k,disabled:u,"aria-label":"Export JSON"})}),jsx(mt,{content:"Import JSON",size:"sm",position:"bottom",children:jsx(gt,{icon:jsx(uv,{}),size:"sm",bgColor:"bg-gray-100 hover:bg-gray-200 dark:bg-gray-700 dark:hover:bg-gray-600",textColor:"text-gray-700 dark:text-gray-200",onClick:()=>h(true),disabled:u,"aria-label":"Import JSON"})})]}),jsx(Yr,{isOpen:b,onClose:P,title:"Export Workflow",description:"Copy the JSON below to save your workflow.",size:"lg",showSubmit:false,showCancel:true,cancelLabel:"Close",children:jsx(Er,{label:"Workflow JSON",multiline:true,rows:12,value:y,readOnly:true,size:"sm"})}),jsx(Yr,{isOpen:f,onClose:g,title:"Import Workflow",description:"Paste workflow JSON to load it into the editor.",size:"lg",showSubmit:true,submitLabel:"Import",onSubmitClick:R,showCancel:true,cancelLabel:"Cancel",children:jsx(Er,{label:"Workflow JSON",multiline:true,rows:12,value:v,onChange:D=>E(D.target.value),placeholder:'{"nodes": [], "edges": []}',size:"sm"})})]})});var Ti={x:0,y:0,zoom:1},Pi=.1,bv=.1,hv=3,yv=20;function ru(){return `edge-${Date.now()}-${Math.random().toString(36).slice(2,8)}`}function xv({value:e,defaultValue:t,onValueChange:r,nodeRegistry:o,direction:n="horizontal",onDirectionChange:a,onNodeClick:s,onNodeDoubleClick:l,onNodeContextMenu:i,onNodeAction:d,readOnly:u=false,disabled:p=false,draggableNodes:b=true,connectable:m=true,selectable:f=true,multiSelect:h=false,panOnDrag:y=true,zoomOnWheel:C=true,minZoom:v=bv,maxZoom:E=hv,snapToGrid:k=false,gridSize:R=yv,showGrid:g=true,toolbar:P=true,autoFit:T=false,className:D},W){let V=e!==void 0,[_,M]=useState(()=>t??{nodes:[],edges:[],viewport:{...Ti}}),w=V?e:_,N=w.nodes,x=w.edges,S=w.viewport??Ti,I=useRef(null),F=useRef(null),[O,Z]=useState(new Set),[U,H]=useState(null),[z,$]=useState(null),K=useRef(S);K.current=S;let se=useRef(N);se.current=N;let X=useRef(x);X.current=x;let ee=useRef(k);ee.current=k;let L=useRef(R);L.current=R;let q=useRef(o);q.current=o;let ge=useRef(n);ge.current=n;let de=useCallback(j=>{V?r?.(j(e)):M(J=>{let me=j(J);return r?.(me),me});},[V,e,r]),Y=useRef(de);Y.current=de;let le=useCallback(j=>{de(J=>({...J,viewport:j}));},[de]),xe=useRef(le);xe.current=le;let Se=useCallback(j=>{let J=o[j.type];return J?.getPorts?J.getPorts(j):j.ports??[]},[o]),te=useRef(Se);te.current=Se;let Ne=useCallback((j,J,me)=>{let ue=se.current,Te=X.current,ve=ue.find(nt=>nt.id===j.fromNodeId),we=ue.find(nt=>nt.id===J);if(!ve||!we)return;let He=te.current(ve),Me=te.current(we),tt=He.find(nt=>nt.id===j.fromPortId),je=Me.find(nt=>nt.id===me);if(!tt||!je||je.kind!=="in"||j.fromNodeId===J)return;let $e=q.current[ve.type];if($e?.canConnect&&!$e.canConnect({fromNode:ve,toNode:we,fromPort:tt,toPort:je}))return;Te.some(nt=>nt.from.nodeId===j.fromNodeId&&nt.from.portId===j.fromPortId&&nt.to.nodeId===J&&nt.to.portId===me)||Y.current(nt=>({...nt,edges:[...nt.edges,{id:ru(),from:{nodeId:j.fromNodeId,portId:j.fromPortId},to:{nodeId:J,portId:me}}]}));},[]);useEffect(()=>{function j(me){let ue=F.current;if(!ue)return;let Te=I.current?.getBoundingClientRect();if(!Te)return;let ve=K.current;if(ue.type==="pan"){let we=me.clientX-ue.startX,He=me.clientY-ue.startY;xe.current({...ve,x:ue.startViewportX+we,y:ue.startViewportY+He});}if(ue.type==="node"){let we=cn(me.clientX,me.clientY,ve,Te),He=we.x-ue.offsetX,Me=we.y-ue.offsetY;ee.current&&(He=Ni(He,L.current),Me=Ni(Me,L.current)),Y.current(tt=>({...tt,nodes:tt.nodes.map(je=>je.id===ue.nodeId?{...je,x:He,y:Me}:je)}));}if(ue.type==="edge"){let we=cn(me.clientX,me.clientY,ve,Te);F.current={...ue,currentX:we.x,currentY:we.y},$({fromX:ue.fromX,fromY:ue.fromY,currentX:we.x,currentY:we.y});}}function J(me){let ue=F.current;if(ue){if(ue.type==="edge"){let Te=I.current?.getBoundingClientRect();if(Te){let ve=K.current,we=cn(me.clientX,me.clientY,ve,Te),He=25,Me=se.current,tt=1/0,je=null,$e=null;for(let Tt of Me){let nt=te.current(Tt);for(let nr of nt){if(nr.kind!=="in")continue;let zr=un(Tt,nr,nt,ge.current),mo=Math.sqrt((we.x-zr.x)**2+(we.y-zr.y)**2);mo<He&&mo<tt&&(tt=mo,je=Tt.id,$e=nr.id);}}je&&$e&&Ne(ue,je,$e);}$(null);}F.current=null;}}return document.addEventListener("mousemove",j),document.addEventListener("mouseup",J),()=>{document.removeEventListener("mousemove",j),document.removeEventListener("mouseup",J);}},[Ne]);let De=useCallback(j=>{if(!C||p)return;j.preventDefault();let J=I.current?.getBoundingClientRect();if(!J)return;let me=j.clientX-J.left,ue=j.clientY-J.top,Te=j.deltaY<0?1:-1,ve=Zn(S.zoom+Te*Pi,v,E),we=ve/S.zoom;le({x:me-(me-S.x)*we,y:ue-(ue-S.y)*we,zoom:ve});},[C,p,S,v,E,le]),Ve=useCallback(j=>{if(p)return;let J=j.target;if(J.closest("[data-action-id]"))return;let ue=J.closest("[data-port-id]");if(ue){if(!m||u)return;j.preventDefault();let ve=ue.getAttribute("data-node-id"),we=ue.getAttribute("data-port-id"),He=ue.getAttribute("data-port-kind");if(!ve||!we||He!=="out")return;let Me=N.find(Tt=>Tt.id===ve);if(!Me)return;let tt=Se(Me),je=tt.find(Tt=>Tt.id===we);if(!je)return;let $e=un(Me,je,tt,ge.current);F.current={type:"edge",fromNodeId:ve,fromPortId:we,fromX:$e.x,fromY:$e.y,currentX:$e.x,currentY:$e.y},$({fromX:$e.x,fromY:$e.y,currentX:$e.x,currentY:$e.y});return}let Te=J.closest("[data-node-id]");if(Te){if(u)return;let ve=Te.getAttribute("data-node-id");if(f&&(H(null),h&&j.shiftKey?Z(we=>{let He=new Set(we);return He.has(ve)?He.delete(ve):He.add(ve),He}):Z(new Set([ve]))),b){let we=I.current?.getBoundingClientRect();if(!we)return;let He=N.find(tt=>tt.id===ve);if(!He||He.locked)return;let Me=cn(j.clientX,j.clientY,S,we);F.current={type:"node",nodeId:ve,startX:Me.x,startY:Me.y,offsetX:Me.x-He.x,offsetY:Me.y-He.y};}return}f&&(Z(new Set),H(null)),y&&j.button===0&&(F.current={type:"pan",startX:j.clientX,startY:j.clientY,startViewportX:S.x,startViewportY:S.y});},[p,m,u,f,h,b,y,S,N,Se]),rt=useCallback(j=>{let J=F.current;if(!J||J.type!=="edge")return;let me=I.current?.getBoundingClientRect();if(me){let ue=cn(j.clientX,j.clientY,S,me),Te=30,ve=1/0,we=null,He=null;for(let Me of N){let tt=Se(Me);for(let je of tt){if(je.kind!=="in")continue;let $e=un(Me,je,tt,ge.current),Tt=Math.sqrt((ue.x-$e.x)**2+(ue.y-$e.y)**2);Tt<Te&&Tt<ve&&(ve=Tt,we=Me.id,He=je.id);}}if(we&&He){let Me=J.fromNodeId,tt=J.fromPortId;Me!==we&&(x.some($e=>$e.from.nodeId===Me&&$e.from.portId===tt&&$e.to.nodeId===we&&$e.to.portId===He)||de($e=>({...$e,edges:[...$e.edges,{id:ru(),from:{nodeId:Me,portId:tt},to:{nodeId:we,portId:He}}]})));}}F.current=null,$(null);},[S,N,x,Se,de]),dt=useCallback((j,J)=>{let me=F.current;!me||me.type!=="edge"||(Ne(me,j,J),F.current=null,$(null));},[Ne]),re=useCallback(j=>{let J=j.target;if(J.closest("[data-port-id]")||J.closest("[data-action-id]"))return null;let Te=J.closest("[data-node-id]");if(!Te)return null;let ve=Te.getAttribute("data-node-id");return N.find(we=>we.id===ve)??null},[N]),pe=useCallback(j=>{if(!s||p)return;let J=re(j);J&&s({node:J,nativeEvent:j.nativeEvent});},[s,p,re]),Ue=useCallback(j=>{if(!l||p)return;let J=re(j);J&&l({node:J,nativeEvent:j.nativeEvent});},[l,p,re]),yt=useCallback(j=>{if(!i||p)return;let J=re(j);J&&(j.preventDefault(),i({node:J,nativeEvent:j.nativeEvent}));},[i,p,re]),Re=useCallback((j,J,me)=>{if(!d||p)return;let ue=N.find(Te=>Te.id===j);ue&&d({node:ue,actionId:J,nativeEvent:me});},[d,p,N]),We=useCallback((j,J)=>{!f||p||(J.stopPropagation(),Z(new Set),H(j));},[f,p]),ft=useCallback(j=>{u||p||((j.key==="Delete"||j.key==="Backspace")&&(O.size>0&&(de(J=>({...J,nodes:J.nodes.filter(me=>!O.has(me.id)),edges:J.edges.filter(me=>!O.has(me.from.nodeId)&&!O.has(me.to.nodeId))})),Z(new Set)),U&&(de(J=>({...J,edges:J.edges.filter(me=>me.id!==U)})),H(null))),j.key==="Escape"&&(Z(new Set),H(null)));},[u,p,O,U,de]),rr=useCallback(()=>{let j=Zn(S.zoom+Pi,v,E);le({...S,zoom:j});},[S,v,E,le]),ot=useCallback(()=>{let j=Zn(S.zoom-Pi,v,E);le({...S,zoom:j});},[S,v,E,le]),Wt=useCallback(()=>{le({...Ti});},[le]),Nt=useCallback(()=>{let j=I.current?.getBoundingClientRect();if(!j)return;let J=Uc(N,j.width,j.height),me=Zn(J.zoom,v,E);le({...J,zoom:me});},[N,v,E,le]),Ht=useCallback(j=>{de(J=>({...J,nodes:[...J.nodes,j]}));},[de]),or=useCallback(j=>{de(J=>({...J,nodes:J.nodes.filter(me=>me.id!==j),edges:J.edges.filter(me=>me.from.nodeId!==j&&me.to.nodeId!==j)}));},[de]),Zt=useCallback(()=>JSON.stringify(w,null,2),[w]),Ar=useCallback(j=>{try{let J=JSON.parse(j);J&&Array.isArray(J.nodes)&&Array.isArray(J.edges)&&de(()=>J);}catch{}},[de]);useImperativeHandle(W,()=>({zoomIn:rr,zoomOut:ot,resetView:Wt,fitToContent:Nt,addNode:Ht,removeNode:or,toJSON:Zt,loadJSON:Ar}),[rr,ot,Wt,Nt,Ht,or,Zt,Ar]);let br=useRef(false);useEffect(()=>{T&&!br.current&&I.current&&(br.current=true,Nt());},[T,Nt]);let fe=useMemo(()=>{let j=new Map;for(let J of N)j.set(J.id,Se(J));return j},[N,Se]),he=useMemo(()=>({transform:`translate(${S.x}px, ${S.y}px) scale(${S.zoom})`,transformOrigin:"0 0"}),[S.x,S.y,S.zoom]);return jsxs("div",{ref:I,"data-testid":"workflow-editor",className:c("relative w-full overflow-hidden bg-gray-50 dark:bg-gray-900 select-none",p&&"opacity-60 pointer-events-none",D),tabIndex:0,onWheel:De,onMouseDown:Ve,onMouseUp:rt,onClick:pe,onDoubleClick:Ue,onContextMenu:yt,onKeyDown:ft,children:[g&&jsx(Kc,{gridSize:R,zoom:S.zoom}),P&&!u&&jsx(Qc,{zoom:S.zoom,direction:n,onDirectionChange:a,onZoomIn:rr,onZoomOut:ot,onResetView:Wt,onFitToContent:Nt,onExportJSON:Zt,onImportJSON:Ar,disabled:p}),jsxs("div",{style:he,children:[jsx(Zc,{edges:x,nodes:N,selectedEdgeId:U,disabled:p||u,direction:n,onEdgeClick:We,getNodePorts:j=>fe.get(j.id)??[]}),N.map(j=>{let J=o[j.type];if(!J)return null;let me=fe.get(j.id)??[];return jsx(Yc,{node:j,registry:J,ports:me,selected:O.has(j.id),disabled:p||u,draggable:b&&!u,direction:n,onPortMouseUp:dt,onActionClick:d?Re:void 0},j.id)})]}),z&&jsxs("svg",{"data-testid":"drag-edge-overlay",style:{position:"absolute",top:0,left:0,width:"100%",height:"100%",pointerEvents:"none",zIndex:1e3,overflow:"visible"},children:[jsx("path",{d:Za(z.fromX*S.zoom+S.x,z.fromY*S.zoom+S.y,z.currentX*S.zoom+S.x,z.currentY*S.zoom+S.y,n),fill:"none",stroke:"#3b82f6",strokeWidth:2.5,strokeDasharray:"8 4"}),jsx("circle",{cx:z.fromX*S.zoom+S.x,cy:z.fromY*S.zoom+S.y,r:5,fill:"#3b82f6"}),jsx("circle",{cx:z.currentX*S.zoom+S.x,cy:z.currentY*S.zoom+S.y,r:4,fill:"#3b82f6",opacity:.6})]})]})}var ou=forwardRef(xv);ou.displayName="WorkflowEditor";var iu=createContext(null);function go(){let e=useContext(iu);if(!e)throw new Error("useWizard and Wizard sub-components must be used within <Wizard>");return e}var Di=(e,t,r)=>Math.max(t,Math.min(e,r)),Ii={sm:{circle:"h-7 w-7 text-xs",dot:"h-2.5 w-2.5",icon:"h-3.5 w-3.5",title:"text-xs",desc:"text-[11px]",connector:"h-0.5"},md:{circle:"h-9 w-9 text-sm",dot:"h-3 w-3",icon:"h-4 w-4",title:"text-sm",desc:"text-xs",connector:"h-0.5"},lg:{circle:"h-11 w-11 text-base",dot:"h-3.5 w-3.5",icon:"h-5 w-5",title:"text-base",desc:"text-sm",connector:"h-1"}},Lr={primary:{solid:"bg-blue-600 text-white",bg:"bg-blue-600",text:"text-blue-600 dark:text-blue-400",ring:"focus-visible:ring-blue-500",ringSoft:"ring-blue-500/20"},secondary:{solid:"bg-gray-700 text-white",bg:"bg-gray-700",text:"text-gray-700 dark:text-gray-300",ring:"focus-visible:ring-gray-500",ringSoft:"ring-gray-500/20"},success:{solid:"bg-green-600 text-white",bg:"bg-green-600",text:"text-green-600 dark:text-green-400",ring:"focus-visible:ring-green-500",ringSoft:"ring-green-500/20"},warning:{solid:"bg-amber-500 text-white",bg:"bg-amber-500",text:"text-amber-600 dark:text-amber-400",ring:"focus-visible:ring-amber-500",ringSoft:"ring-amber-500/20"},error:{solid:"bg-red-600 text-white",bg:"bg-red-600",text:"text-red-600 dark:text-red-400",ring:"focus-visible:ring-red-500",ringSoft:"ring-red-500/20"}};function wv({className:e}){return jsx("svg",{className:e,viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true",children:jsx("path",{fillRule:"evenodd",d:"M16.707 5.293a1 1 0 010 1.414l-8 8a1 1 0 01-1.414 0l-4-4a1 1 0 011.414-1.414L8 12.586l7.293-7.293a1 1 0 011.414 0z",clipRule:"evenodd"})})}function lu({steps:e,step:t,defaultStep:r=0,onStepChange:o,onComplete:n,orientation:a="horizontal",variant:s="default",size:l="md",color:i="primary",linear:d=true,className:u,children:p}){let b=e.length,m=Math.max(0,b-1),f=t!==void 0,[h,y]=useState(()=>Di(r,0,m)),C=Di(f?t:h,0,m),[v,E]=useState(C);v<C&&E(C);let k=C<=0,R=C>=m,g=useCallback((M,w)=>{let N=Di(M,0,m);N!==C&&(f||y(N),E(x=>Math.max(x,N)),o?.(N,{previous:C,direction:w}));},[C,f,m,o]),P=useCallback(M=>{let w=e[M];return !w||w.disabled?false:d?M<=v:true},[e,d,v]),T=useCallback(M=>{P(M)&&g(M,M>C?"jump":"backward");},[P,g,C]),D=useCallback(()=>{if(R){n?.();return}g(C+1,"forward");},[R,n,g,C]),W=useCallback(()=>{k||g(C-1,"backward");},[k,g,C]),V=useCallback(M=>e[M]?.error?"error":M===C?"active":M<C?"completed":"upcoming",[e,C]),_={steps:e,activeStep:C,totalSteps:b,isFirstStep:k,isLastStep:R,orientation:a,variant:s,size:l,color:i,linear:d,goToStep:T,goNext:D,goBack:W,getStepStatus:V,isStepAccessible:P};return jsx(iu.Provider,{value:_,children:jsx("div",{className:c("flex w-full flex-col gap-6",u),"data-testid":"wizard","data-orientation":a,children:p})})}function au({index:e,status:t}){let{variant:r,size:o,color:n,steps:a}=go(),s=Ii[o],l=a[e];if(r==="dots"){let u=t==="upcoming"?"bg-gray-300 dark:bg-gray-600":t==="error"?"bg-red-600":Lr[n].bg;return jsx("span",{className:c("shrink-0 rounded-full transition-colors",s.dot,u),"aria-hidden":"true"})}let i=t==="completed"?c(Lr[n].solid,"border-transparent"):t==="active"?c(Lr[n].solid,"border-transparent ring-4",Lr[n].ringSoft):t==="error"?"border-transparent bg-red-600 text-white":"border-2 border-gray-300 bg-white text-gray-500 dark:border-gray-600 dark:bg-gray-800 dark:text-gray-400",d=t==="completed"?jsx(wv,{className:s.icon}):t==="error"?jsx("span",{className:"font-semibold leading-none",children:"!"}):l.icon??jsx("span",{className:"font-medium leading-none",children:e+1});return jsx("span",{className:c("flex shrink-0 items-center justify-center rounded-full transition-all",s.circle,i),"aria-hidden":"true",children:d})}function su({index:e,status:t}){let{steps:r,size:o,color:n,variant:a}=go(),s=Ii[o],l=r[e],d=t==="active"?Lr[n].text:t==="completed"?"text-gray-900 dark:text-gray-100":t==="error"?"text-red-600 dark:text-red-400":"text-gray-500 dark:text-gray-400";return jsxs("span",{className:"flex min-w-0 flex-col",children:[jsxs("span",{className:c("font-medium leading-tight",s.title,d),children:[a==="simple"&&jsxs("span",{className:"mr-1 tabular-nums",children:[e+1,"."]}),l.title,l.optional&&jsx("span",{className:"ml-1 text-xs font-normal text-gray-400 dark:text-gray-500",children:"(optional)"})]}),l.description&&jsx("span",{className:c("mt-0.5 text-gray-400 dark:text-gray-500",s.desc),children:l.description})]})}function du({className:e,hideConnector:t=false,hideLabels:r=false}){let o=go(),{steps:n,orientation:a,size:s,variant:l,color:i,activeStep:d}=o,u=Ii[s],p=a==="vertical",b=l!=="simple";return jsx("ol",{className:c("flex w-full",p?"flex-col":"items-start",e),"data-testid":"wizard-steps","data-orientation":a,children:n.map((m,f)=>{let h=o.getStepStatus(f),y=f===d,C=o.isStepAccessible(f)&&!y,v=f===n.length-1,k=f<d?Lr[i].bg:"bg-gray-200 dark:bg-gray-700";return p?jsx("li",{className:"flex","aria-current":y?"step":void 0,"data-status":h,"data-testid":"wizard-step",children:jsxs("button",{type:"button",disabled:!C,onClick:()=>o.goToStep(f),className:c("flex items-stretch gap-3 rounded-md text-left focus:outline-none focus-visible:ring-2 focus-visible:ring-offset-2",Lr[i].ring,C?"cursor-pointer":"cursor-default"),children:[jsxs("span",{className:"flex flex-col items-center",children:[b&&jsx(au,{index:f,status:h}),!t&&!v&&jsx("span",{className:c("my-1 w-0.5 flex-1 rounded",k),"aria-hidden":"true"})]}),!r&&jsx("span",{className:c(v?"pb-0":"pb-6"),children:jsx(su,{index:f,status:h})})]})},m.id??f):jsxs("li",{className:c("flex items-center",!v&&"flex-1"),"aria-current":y?"step":void 0,"data-status":h,"data-testid":"wizard-step",children:[jsxs("button",{type:"button",disabled:!C,onClick:()=>o.goToStep(f),className:c("flex items-center gap-2.5 rounded-md focus:outline-none focus-visible:ring-2 focus-visible:ring-offset-2",Lr[i].ring,C?"cursor-pointer":"cursor-default"),children:[b&&jsx(au,{index:f,status:h}),!r&&jsx(su,{index:f,status:h})]}),!t&&!v&&jsx("span",{className:c("mx-2 flex-1 rounded",u.connector,k),"aria-hidden":"true"})]},m.id??f)})})}function cu({index:e,keepMounted:t=false,className:r,children:o}){let{activeStep:n}=go(),a=e===n;return !a&&!t?null:jsx("div",{role:"tabpanel",hidden:!a,"data-testid":"wizard-panel","data-active":a,"data-step":e,className:c("w-full",r),children:o})}function uu({className:e,children:t}){let r=go();return jsx("div",{className:c("w-full",e),"data-testid":"wizard-content",children:typeof t=="function"?t(r):t})}var pu="inline-flex cursor-pointer items-center justify-center gap-2 rounded-lg px-4 py-2 text-sm font-medium transition-colors focus:outline-none focus-visible:ring-2 focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50";function Mi({children:e,label:t="Previous",className:r,onClick:o,disabled:n,...a}){let{goBack:s,isFirstStep:l}=go();return jsx("button",{type:"button",onClick:d=>{o?.(d),d.defaultPrevented||s();},disabled:n??l,"data-testid":"wizard-previous",className:c(pu,"border border-gray-300 bg-white text-gray-700 hover:bg-gray-50 focus-visible:ring-gray-400 dark:border-gray-600 dark:bg-gray-800 dark:text-gray-200 dark:hover:bg-gray-700",r),...a,children:e??t})}function Li({children:e,label:t="Next",finishLabel:r="Finish",className:o,onClick:n,...a}){let{goNext:s,isLastStep:l,color:i}=go();return jsx("button",{type:"button",onClick:u=>{n?.(u),u.defaultPrevented||s();},"data-testid":"wizard-next",className:c(pu,Lr[i].solid,Lr[i].ring,"hover:opacity-90",o),...a,children:e??(l?r:t)})}function gu({className:e,children:t,align:r="between"}){let o={between:"justify-between",start:"justify-start",center:"justify-center",end:"justify-end"}[r];return jsx("div",{className:c("flex items-center gap-3",o,e),"data-testid":"wizard-actions",children:t??jsxs(Fragment,{children:[jsx(Mi,{}),jsx(Li,{})]})})}lu.displayName="Wizard";du.displayName="WizardSteps";cu.displayName="WizardPanel";uu.displayName="WizardContent";gu.displayName="WizardActions";Mi.displayName="WizardPrevious";Li.displayName="WizardNext";export{zu as Accordion,Fu as AccordionContent,Wu as AccordionItem,Hu as AccordionTrigger,Ki as AdvanceDetachable,$0 as AreaChart,K0 as Avatar,ml as Badge,hl as Banner,ap as BarChart,hp as Breadcrumb,gt as Button,Go as ButtonGroup,ia as CHART_ALL_PAIRS_LIMIT,xn as CHART_MUTED_COLOR,E0 as CHART_PALETTE_SIZE,sa as CHART_SERIES_COLORS,Wp as Calendar,wl as Card,Sl as CardBody,El as CardDescription,Rl as CardFooter,Nl as CardHeader,Tl as CardImage,Pl as CardTitle,Ut as ChartAxis,lr as ChartContainer,Wr as ChartGrid,dr as ChartLegend,cr as ChartTableView,ur as ChartTooltip,pr as ChartTooltipContent,Rn as Checkbox,Il as CheckboxGroup,Ml as CheckboxGroupItem,ka as Chip,Ho as CircularProgress,Ji as DEFAULT_CHART_WIDTH,jn as DEFAULT_FIELD_TYPES,Dg as DataGrid,Wl as Detachable,dm as DeviceMockup,Fl as Divider,ql as Drawer,nd as Dropdown,yd as DropdownCheckboxItem,cd as DropdownContent,pd as DropdownItem,md as DropdownLabel,wd as DropdownRadioGroup,Cd as DropdownRadioItem,gd as DropdownSeparator,Ed as DropdownSubMenu,Id as DropdownSubMenuContent,Dd as DropdownSubMenuTrigger,sd as DropdownTrigger,Gl as FOCUSABLE_SELECTOR,zm as FileSelector,bc as Footer,vc as FooterBottom,yc as FooterColumn,xc as FooterLink,hc as FooterSection,kc as FooterSocial,wc as FooterSocialLink,$f as Header,Wd as HelpButton,Bl as INERT_IGNORE_ATTRIBUTE,cb as ImageUploader,Fd as Indicator,Er as Input,$d as Label,Rb as LineChart,Gs as MentionInput,Yr as Modal,Xs as NumberInput,Ob as Pagination,qb as PieChart,Yd as ProgressBar,jd as RadioButton,Jy as ScatterChart,Gc as SchemaEditor,vh as Select,Th as Sidebar,Eh as SidebarContent,Dh as SidebarFooter,Ih as SidebarGroup,Ph as SidebarHeader,Mh as SidebarItem,Lh as SidebarSubMenu,Ah as SidebarToggle,tc as Skeleton,oc as Slider,oi as Sparkline,$h as StatCard,Gh as StatCardGroup,gs as Table,ms as TableBody,na as TableCell,fs as TableHeader,aa as TableHeaderCell,bs as TableRow,ac as Tabs,cc as TabsContent,sc as TabsList,dc as TabsTrigger,gc as Toast,mt as Tooltip,s0 as UILabelsProvider,ob as WithHelpButton,lu as Wizard,gu as WizardActions,uu as WizardContent,Li as WizardNext,cu as WizardPanel,Mi as WizardPrevious,du as WizardSteps,ou as WorkflowEditor,vi as autoLayoutTables,c as cn,gi as createDefaultField,mi as createDefaultTable,qi as defaultUILabels,Na as findOwnedLayers,a0 as frenchUILabels,Yn as generateFieldId,pi as generateRelationId,ja as generateSQL,Dc as generateTableId,Sa as getFocusableElements,la as getSeriesColor,Lt as getSeriesLabel,As as hideOthers,Xl as isElementVisible,Kl as isFocusable,No as registerFloatingLayer,Cr as resolveSeriesColor,Hr as toLegendItems,ps as useChartSize,jo as useClickOutside,So as useDialogA11y,Yt as useDropdownContext,ld as useFocusItem,Pa as useKeyboardNavigation,qo as usePositioning,Ch as useSidebar,Ft as useUILabels,go as useWizard};
|
|
31
|
+
`)}var $v=60,_v=40;function Ui(e,t){if(e.length===0)return e;let r=new Map;for(let g of e){let x=new Set;for(let b of g.fields)b.foreignKey&&x.add(b.foreignKey.tableId);r.set(g.id,x);}let n=new Map;for(let g of e)n.set(g.id,0);for(let[,g]of r)for(let x of g)n.has(x);for(let[g,x]of r)n.set(g,x.size);let o=[],a=[];for(let[g,x]of n)x===0&&a.push(g);for(;a.length>0;){let g=a.shift();o.push(g);for(let[x,b]of r)if(b.has(g)){let v=(n.get(x)??0)-1;n.set(x,v),v===0&&a.push(x);}}let s=new Set(o);for(let g of e)s.has(g.id)||(o.push(g.id),s.add(g.id));let l=new Map(e.map(g=>[g.id,g])),i=Math.max(1,Math.ceil(Math.sqrt(o.length))),d=0,c=0,p=0,f=0,m=[];for(let g of o){let x=l.get(g);if(!x)continue;let b=x.width??260,v=hn(x,t);m.push({...x,x:d,y:c}),f=Math.max(f,v),p++,p>=i?(p=0,d=0,c+=f+_v,f=0):d+=b+$v;}return m}var ji={x:0,y:0,zoom:1},qi=.1,Uv=.1,Yv=3,jv=20,qv=50;function Zv({value:e,defaultValue:t,onValueChange:r,fieldTypes:n=ma,onTableClick:o,onTableDoubleClick:a,onTableContextMenu:s,onFieldClick:l,onFieldDoubleClick:i,readOnly:d=false,disabled:c=false,draggableTables:p=true,panOnDrag:f=true,zoomOnWheel:m=true,editable:g=true,minZoom:x=Uv,maxZoom:b=Yv,snapToGrid:v=false,gridSize:y=jv,showGrid:M=true,toolbar:w=true,legend:P=true,autoFit:h=false,className:E},D){let k=e!==void 0,[I,W]=useState(()=>t??{tables:[],relations:[],viewport:{...ji}}),O=k?e:I,L=O.tables,T=O.relations,S=O.viewport??ji,C=useRef(null),N=useRef(null),[R,$]=useState(null),[H,K]=useState(null),[_,F]=useState(null),[A,B]=useState(null),[U,Q]=useState({width:0,height:0}),J=useRef([]),Y=useRef(-1),z=useRef(false),X=useRef(S);X.current=S;let ne=useRef(L);ne.current=L;let re=useRef(T);re.current=T;let q=useRef(v);q.current=v;let de=useRef(y);de.current=y;let xe=useRef(g);xe.current=g;let ke=useCallback(G=>{if(z.current)return;let te=J.current,oe=Y.current;J.current=te.slice(0,oe+1),J.current.push(G),J.current.length>qv&&J.current.shift(),Y.current=J.current.length-1;},[]),le=useCallback(G=>{if(k){let te=G(e);ke(te),r?.(te);}else W(te=>{let oe=G(te);return ke(oe),r?.(oe),oe});},[k,e,r,ke]),Se=useRef(le);Se.current=le;let Me=useCallback(G=>{le(te=>({...te,viewport:G}));},[le]),je=useRef(Me);je.current=Me,useEffect(()=>{function G(ae){let pe=N.current;if(!pe)return;let Ve=C.current?.getBoundingClientRect();if(!Ve)return;let Ye=X.current;if(pe.type==="pan"){let Xe=ae.clientX-pe.startX,Le=ae.clientY-pe.startY;je.current({...Ye,x:pe.startVpX+Xe,y:pe.startVpY+Le});}if(pe.type==="table"){let Xe=ua(ae.clientX,ae.clientY,Ye,Ve),Le=Xe.x-pe.offsetX,It=Xe.y-pe.offsetY;q.current&&(Le=Fi(Le,de.current),It=Fi(It,de.current)),Se.current(Ge=>({...Ge,tables:Ge.tables.map(gt=>gt.id===pe.tableId?{...gt,x:Le,y:It}:gt)}));}if(pe.type==="relation"){let Xe=ua(ae.clientX,ae.clientY,Ye,Ve);N.current={...pe,currentX:Xe.x,currentY:Xe.y},F({fromX:pe.fromX,fromY:pe.fromY,currentX:Xe.x,currentY:Xe.y});}if(pe.type==="resize"){let Xe=(ae.clientX-pe.startX)/Ye.zoom,Le=(ae.clientY-pe.startY)/Ye.zoom,It=180,Ge=80,gt=Math.max(It,pe.startWidth+Xe),Nt=Math.max(Ge,pe.startHeight+Le);Se.current(it=>({...it,tables:it.tables.map(Vt=>Vt.id===pe.tableId?{...Vt,width:gt,height:Nt}:Vt)}));}}function te(ae,pe,Ve,Ye){let Xe=X.current,Le=ua(ae,pe,Xe,Ve),It=1/0,Ge=null,gt=null;for(let Nt of Ye){if(Nt.collapsed)continue;let it=Nt.fields.length;if(it===0)continue;let Vt=Nt.width??260,Rr=40+it*32+(xe.current?36:0),Tr=40;if(!(Le.x<Nt.x-Tr||Le.x>Nt.x+Vt+Tr||Le.y<Nt.y-Tr||Le.y>Nt.y+Rr+Tr))for(let rr=0;rr<Nt.fields.length;rr++){let Cs=Nt.y+xo(rr,!!Nt.notes),ha=Math.abs(Le.y-Cs);ha<It&&(It=ha,Ge=Nt.id,gt=Nt.fields[rr].id);}}return Ge&>?{tableId:Ge,fieldId:gt}:null}function oe(ae){let pe=N.current;if(pe){if(pe.type==="relation"){let Ve=C.current?.getBoundingClientRect();if(Ve){let Ye=re.current,Xe=ne.current,Le=te(ae.clientX,ae.clientY,Ve,Xe);if(Le&&Le.tableId!==pe.fromTableId&&!Ye.some(Ge=>Ge.from.tableId===pe.fromTableId&&Ge.from.fieldId===pe.fromFieldId&&Ge.to.tableId===Le.tableId&&Ge.to.fieldId===Le.fieldId)){let Ge=pe.fromTableId,gt=pe.fromFieldId,Nt=Le.tableId,it=Le.fieldId;Se.current(Vt=>({...Vt,tables:Vt.tables.map(Rr=>Rr.id===Nt?{...Rr,fields:Rr.fields.map(Tr=>Tr.id===it?{...Tr,foreignKey:{tableId:Ge,fieldId:gt}}:Tr)}:Rr),relations:[...Vt.relations,{id:Vi(),from:{tableId:Ge,fieldId:gt},to:{tableId:Nt,fieldId:it},cardinality:"1:n"}]}));}}F(null),B(null);}N.current=null;}}return document.addEventListener("mousemove",G),document.addEventListener("mouseup",oe),()=>{document.removeEventListener("mousemove",G),document.removeEventListener("mouseup",oe);}},[]);let at=useCallback(G=>{if(!m||c)return;G.preventDefault();let te=C.current?.getBoundingClientRect();if(!te)return;let oe=G.clientX-te.left,ae=G.clientY-te.top,pe=G.deltaY<0?1:-1,Ve=ca(S.zoom+pe*qi,x,b),Ye=Ve/S.zoom;Me({x:oe-(oe-S.x)*Ye,y:ae-(ae-S.y)*Ye,zoom:Ve});},[m,c,S,x,b,Me]),$e=useCallback(G=>{if(c)return;let te=G.target,oe=te.tagName,ae=oe==="INPUT"||oe==="SELECT"||oe==="TEXTAREA"||oe==="BUTTON";if(te.closest("[data-resize-handle]"))return;let pe=te.closest("[data-connection-side]");if(pe&&!ae){if(d)return;G.preventDefault();let Ye=pe.getAttribute("data-table-id"),Xe=pe.getAttribute("data-field-id");if(!Ye||!Xe)return;let Le=L.find(gt=>gt.id===Ye);if(!Le)return;let It=pe.getAttribute("data-connection-side"),Ge=lu(Le,Xe,It);if(!Ge)return;N.current={type:"relation",fromTableId:Ye,fromFieldId:Xe,fromX:Ge.x,fromY:Ge.y,currentX:Ge.x,currentY:Ge.y},F({fromX:Ge.x,fromY:Ge.y,currentX:Ge.x,currentY:Ge.y}),B(Ye);return}let Ve=te.closest("[data-table-id]");if(Ve){if(d)return;let Ye=Ve.getAttribute("data-table-id");if(K(null),$(Ye),ae)return;if(p){let Xe=C.current?.getBoundingClientRect();if(!Xe)return;let Le=L.find(Ge=>Ge.id===Ye);if(!Le||Le.locked)return;let It=ua(G.clientX,G.clientY,S,Xe);N.current={type:"table",tableId:Ye,offsetX:It.x-Le.x,offsetY:It.y-Le.y};}return}$(null),K(null),f&&G.button===0&&(N.current={type:"pan",startX:G.clientX,startY:G.clientY,startVpX:S.x,startVpY:S.y});},[c,d,p,f,S,L]),ie=useCallback(G=>{let te=G.target;if(te.closest("[data-connection-side]"))return null;let oe=te.closest("[data-table-id]");if(!oe)return null;let ae=oe.getAttribute("data-table-id");return L.find(pe=>pe.id===ae)??null},[L]),he=useCallback(G=>{if(c)return;let te=ie(G);te&&o&&o({table:te,nativeEvent:G.nativeEvent});},[o,c,ie]),Ie=useCallback(G=>{if(c)return;let te=ie(G);te&&a&&a({table:te,nativeEvent:G.nativeEvent});},[a,c,ie]),xt=useCallback(G=>{if(c)return;let te=ie(G);te&&s&&(G.preventDefault(),s({table:te,nativeEvent:G.nativeEvent}));},[s,c,ie]),Te=useCallback((G,te)=>{c||(te.stopPropagation(),$(null),K(G));},[c]),Ee=useCallback((G,te)=>{le(oe=>({...oe,relations:oe.relations.map(ae=>ae.id===G?{...ae,cardinality:te}:ae)}));},[le]),nt=Y.current>0,pr=Y.current<J.current.length-1,pt=useCallback(()=>{if(Y.current<=0)return;z.current=true,Y.current--;let G=J.current[Y.current];k||W(G),r?.(G),z.current=false;},[k,r]),Ht=useCallback(()=>{if(Y.current>=J.current.length-1)return;z.current=true,Y.current++;let G=J.current[Y.current];k||W(G),r?.(G),z.current=false;},[k,r]),Ft=useCallback(()=>fs(O),[O]),sr=useCallback(()=>{le(G=>({...G,tables:Ui(G.tables,g)}));},[le,g]),Nr=useCallback((G,te,oe)=>{te!==oe&&le(ae=>({...ae,tables:ae.tables.map(pe=>{if(pe.id!==G)return pe;let Ve=[...pe.fields],[Ye]=Ve.splice(te,1);return Ve.splice(oe,0,Ye),{...pe,fields:Ve}})}));},[le]);useEffect(()=>{let G=C.current;if(!G)return;let te=new ResizeObserver(oe=>{for(let ae of oe)Q({width:ae.contentRect.width,height:ae.contentRect.height});});return te.observe(G),()=>te.disconnect()},[]);let Gt=useRef(false);Gt.current||(Gt.current=true,J.current=[O],Y.current=0);let er=useCallback(G=>{if(!(d||c)){if((G.ctrlKey||G.metaKey)&&G.key==="z"&&!G.shiftKey){G.preventDefault(),pt();return}if((G.ctrlKey||G.metaKey)&&(G.key==="y"||G.key==="z"&&G.shiftKey)){G.preventDefault(),Ht();return}if(G.key==="Delete"||G.key==="Backspace"){let te=G.target;if(te.tagName==="INPUT"||te.tagName==="TEXTAREA"||te.tagName==="SELECT")return;R&&(le(oe=>({...oe,tables:oe.tables.filter(ae=>ae.id!==R),relations:oe.relations.filter(ae=>ae.from.tableId!==R&&ae.to.tableId!==R)})),$(null)),H&&(le(oe=>{let ae=oe.relations.find(pe=>pe.id===H);return {...oe,tables:ae?oe.tables.map(pe=>pe.id===ae.to.tableId?{...pe,fields:pe.fields.map(Ve=>Ve.id===ae.to.fieldId?{...Ve,foreignKey:void 0}:Ve)}:pe):oe.tables,relations:oe.relations.filter(pe=>pe.id!==H)}}),K(null));}G.key==="Escape"&&($(null),K(null));}},[d,c,R,H,le,pt,Ht]),tr=useCallback((G,te)=>{le(oe=>({...oe,tables:oe.tables.map(ae=>ae.id===G?{...ae,name:te}:ae)}));},[le]),ue=useCallback((G,te)=>{le(oe=>({...oe,tables:oe.tables.map(ae=>ae.id===G?{...ae,notes:te}:ae)}));},[le]),me=useCallback(G=>{le(te=>({...te,tables:te.tables.map(oe=>oe.id===G?{...oe,collapsed:!oe.collapsed}:oe)}));},[le]),Z=useCallback((G,te,oe)=>{le(ae=>({...ae,tables:ae.tables.map(pe=>pe.id===G?{...pe,fields:pe.fields.map(Ve=>Ve.id===te?{...Ve,...oe}:Ve)}:pe)}));},[le]),ee=useCallback(G=>{le(te=>({...te,tables:te.tables.map(oe=>oe.id===G?{...oe,fields:[...oe.fields,Bi()]}:oe)}));},[le]),fe=useCallback((G,te)=>{le(oe=>({...oe,tables:oe.tables.map(ae=>ae.id===G?{...ae,fields:ae.fields.filter(pe=>pe.id!==te)}:ae),relations:oe.relations.filter(ae=>!(ae.from.tableId===G&&ae.from.fieldId===te)&&!(ae.to.tableId===G&&ae.to.fieldId===te))}));},[le]),ge=useCallback((G,te,oe,ae,pe)=>{N.current={type:"resize",tableId:G,startX:te,startY:oe,startWidth:ae,startHeight:pe};},[]),Re=useCallback(()=>{let G=ca(S.zoom+qi,x,b);Me({...S,zoom:G});},[S,x,b,Me]),ve=useCallback(()=>{let G=ca(S.zoom-qi,x,b);Me({...S,zoom:G});},[S,x,b,Me]),we=useCallback(()=>{Me({...ji});},[Me]),Fe=useCallback(()=>{let G=C.current?.getBoundingClientRect();if(!G)return;let te=du(L,G.width,G.height,g),oe=ca(te.zoom,x,b);Me({...te,zoom:oe});},[L,g,x,b,Me]),Ae=useCallback(G=>{le(te=>({...te,tables:[...te.tables,G]}));},[le]),ot=useCallback(G=>{le(te=>({...te,tables:te.tables.filter(oe=>oe.id!==G),relations:te.relations.filter(oe=>oe.from.tableId!==G&&oe.to.tableId!==G)}));},[le]),qe=useCallback((G,te)=>{le(oe=>({...oe,tables:oe.tables.map(ae=>ae.id===G?{...ae,fields:[...ae.fields,te]}:ae)}));},[le]),_e=useCallback((G,te)=>{fe(G,te);},[fe]),Mt=useCallback(G=>{le(te=>({...te,tables:te.tables.map(oe=>oe.id===G.to.tableId?{...oe,fields:oe.fields.map(ae=>ae.id===G.to.fieldId?{...ae,foreignKey:{tableId:G.from.tableId,fieldId:G.from.fieldId}}:ae)}:oe),relations:[...te.relations,G]}));},[le]),st=useCallback(G=>{le(te=>{let oe=te.relations.find(ae=>ae.id===G);return {...te,tables:oe?te.tables.map(ae=>ae.id===oe.to.tableId?{...ae,fields:ae.fields.map(pe=>pe.id===oe.to.fieldId?{...pe,foreignKey:void 0}:pe)}:ae):te.tables,relations:te.relations.filter(ae=>ae.id!==G)}});},[le]),mr=useCallback(()=>JSON.stringify(O,null,2),[O]),Gr=useCallback(G=>{try{let te=JSON.parse(G);te&&Array.isArray(te.tables)&&Array.isArray(te.relations)&&le(()=>te);}catch{}},[le]),wn=useCallback(()=>{let G=C.current?.getBoundingClientRect(),te=X.current,oe=100,ae=100;G&&(oe=(G.width/2-te.x)/te.zoom-260/2,ae=(G.height/2-te.y)/te.zoom-60),Ae(Oi(oe,ae));},[Ae]),Xn=useCallback(()=>fs(O),[O]);useImperativeHandle(D,()=>({zoomIn:Re,zoomOut:ve,resetView:we,fitToContent:Fe,addTable:Ae,removeTable:ot,addField:qe,removeField:_e,addRelation:Mt,removeRelation:st,toJSON:mr,loadJSON:Gr,toSQL:Xn}),[Re,ve,we,Fe,Ae,ot,qe,_e,Mt,st,mr,Gr,Xn]);let Sr=useRef(false);useEffect(()=>{h&&!Sr.current&&C.current&&(Sr.current=true,Fe());},[h,Fe]);let gr=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:C,"data-testid":"schema-editor",className:u("relative w-full overflow-hidden bg-gray-50 dark:bg-gray-900 select-none",c&&"opacity-60 pointer-events-none",E),tabIndex:0,onWheel:at,onMouseDown:$e,onClick:he,onDoubleClick:Ie,onContextMenu:xt,onKeyDown:er,children:[M&&jsx(iu,{gridSize:y,zoom:S.zoom}),w&&!d&&jsx(xu,{zoom:S.zoom,onZoomIn:Re,onZoomOut:ve,onResetView:we,onFitToContent:Fe,onAddTable:wn,onExportJSON:mr,onImportJSON:Gr,onExportSQL:Ft,onUndo:pt,onRedo:Ht,canUndo:nt,canRedo:pr,onAutoLayout:sr,disabled:c}),P&&jsx(vu,{}),jsx(yu,{relations:T,tables:L,viewport:S,selectedRelationId:H,disabled:c||d,onRelationClick:Te,onCardinalityChange:Ee}),jsx("div",{style:gr,children:L.map(G=>jsx(bu,{table:G,selected:R===G.id,disabled:c||d,readOnly:d,editable:g,dropTarget:A!==null&&A!==G.id&&!G.collapsed,fieldTypes:n,onTableNameChange:tr,onTableNotesChange:ue,onToggleCollapse:me,onFieldChange:Z,onFieldAdd:ee,onFieldRemove:fe,onFieldReorder:Nr,onResizeStart:ge},G.id))}),_&&jsxs("svg",{"data-testid":"drag-relation-overlay",style:{position:"absolute",top:0,left:0,width:"100%",height:"100%",pointerEvents:"none",zIndex:1e3,overflow:"visible"},children:[jsx("path",{d:cs(_.fromX*S.zoom+S.x,_.fromY*S.zoom+S.y,_.currentX*S.zoom+S.x,_.currentY*S.zoom+S.y),fill:"none",stroke:"#3b82f6",strokeWidth:2.5,strokeDasharray:"8 4"}),jsx("circle",{cx:_.fromX*S.zoom+S.x,cy:_.fromY*S.zoom+S.y,r:5,fill:"#3b82f6"}),jsx("circle",{cx:_.currentX*S.zoom+S.x,cy:_.currentY*S.zoom+S.y,r:4,fill:"#3b82f6",opacity:.6})]}),P&&U.width>0&&jsx(ku,{tables:L,viewport:S,containerWidth:U.width,containerHeight:U.height,editable:g,onViewportChange:Me})]})}var Nu=forwardRef(Zv);Nu.displayName="SchemaEditor";var Su="wf-grid-pattern",Ru=memo(function({gridSize:t,zoom:r}){let n=t*r;return jsxs("svg",{className:"absolute inset-0 w-full h-full pointer-events-none","aria-hidden":"true",children:[jsx("defs",{children:jsx("pattern",{id:Su,width:n,height:n,patternUnits:"userSpaceOnUse",children:jsx("circle",{cx:1,cy:1,r:1,className:"fill-gray-300 dark:fill-gray-600"})})}),jsx("rect",{width:"100%",height:"100%",fill:`url(#${Su})`})]})});function Zi(e,t){return Math.round(e/t)*t}function fa(e,t,r){return Math.min(r,Math.max(t,e))}function So(e,t,r,n){return {x:(e-n.left-r.x)/r.zoom,y:(t-n.top-r.y)/r.zoom}}function ga(e,t="horizontal"){return t==="vertical"?e==="in"?"top":"bottom":e==="in"?"left":"right"}function Ro(e,t,r,n="horizontal"){let o=e.width??180,a=e.height??60,s=t.side??ga(t.kind,n),l=r.filter(p=>(p.side??ga(p.kind,n))===s),i=l.findIndex(p=>p.id===t.id),d=l.length,c=d===1?.5:(i+1)/(d+1);switch(s){case "left":return {x:e.x-8,y:e.y+a*c};case "right":return {x:e.x+o+8,y:e.y+a*c};case "top":return {x:e.x+o*c,y:e.y-8};case "bottom":return {x:e.x+o*c,y:e.y+a+8}}}function hs(e,t,r,n,o="horizontal"){if(o==="vertical"){let p=Math.abs(n-t),f=Math.max(50,p*.5),m=e,g=t+f,x=r,b=n-f;return `M ${e} ${t} C ${m} ${g}, ${x} ${b}, ${r} ${n}`}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} ${n}, ${r} ${n}`}function Tu(e,t,r,n=40){if(e.length===0)return {x:0,y:0,zoom:1};let o=1/0,a=1/0,s=-1/0,l=-1/0;for(let m of e){let g=m.width??180,x=m.height??60;o=Math.min(o,m.x),a=Math.min(a,m.y),s=Math.max(s,m.x+g),l=Math.max(l,m.y+x);}let i=s-o+n*2,d=l-a+n*2,c=Math.min(t/i,r/d,1),p=(t-i*c)/2-(o-n)*c,f=(r-d*c)/2-(a-n)*c;return {x:p,y:f,zoom:c}}var t1=180,r1=60,ys=12,To=28,Ji=24,n1=-8;function o1(e,t,r,n,o="horizontal"){let a=e.side??ga(e.kind,o),s=t.filter(c=>(c.side??ga(c.kind,o))===a),l=s.findIndex(c=>c.id===e.id),i=s.length,d=i===1?.5:(l+1)/(i+1);switch(a){case "left":return {left:0,top:n*d};case "right":return {left:r,top:n*d};case "top":return {left:r*d,top:0};case "bottom":return {left:r*d,top:n}}}function a1({port:e,allPorts:t,nodeId:r,nodeWidth:n,nodeHeight:o,disabled:a,direction:s,onMouseUp:l}){let i=o1(e,t,n,o,s),d=a||e.disabled,c=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-To/2,top:i.top-To/2,width:To,height:To,zIndex:20},onMouseUp:c,title:e.label??e.id,children:jsx("div",{className:u("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:ys,height:ys,left:(To-ys)/2,top:(To-ys)/2}})})}function s1(e,t,r){let n=e??"top-right",o=n1,a=t*(Ji+4);switch(n){case "top-right":return {top:o,right:o-a};case "top-left":return {top:o,left:o+a};case "bottom-right":return {bottom:o,right:o-a};case "bottom-left":return {bottom:o,left:o+a}}}function i1({action:e,nodeId:t,index:r,nodeWidth:n,disabled:o,onActionClick:a}){let s=useCallback(d=>{d.stopPropagation(),d.preventDefault(),!o&&a(t,e.id,d.nativeEvent);},[o,t,e.id,a]),l=useCallback(d=>{d.stopPropagation();},[]),i=s1(e.position,r);return jsx("button",{"data-testid":`action-${t}-${e.id}`,"data-action-id":e.id,"data-node-id":t,type:"button",className:u("absolute flex items-center justify-center rounded-full border shadow-sm transition-all","bg-white border-gray-300 text-gray-600","hover:bg-gray-50 hover:border-gray-400 hover:text-gray-800 hover:shadow-md","active:scale-95",o&&"opacity-50 cursor-not-allowed",!o&&"cursor-pointer",e.className),style:{...i,width:Ji,height:Ji,zIndex:30},onClick:s,onMouseDown:l,title:e.label,disabled:o,children:jsx("span",{className:"flex items-center justify-center w-3.5 h-3.5 [&>svg]:w-full [&>svg]:h-full",children:e.icon})})}var Pu=memo(function({node:t,registry:r,ports:n,selected:o,disabled:a,draggable:s,direction:l,onPortMouseUp:i,onActionClick:d}){let c=t.width??t1,p=t.height??r1,f=r.render({node:t,selected:o,disabled:a}),g=(typeof r.actions=="function"?r.actions(t):r.actions)?.filter(b=>typeof b.hidden=="function"?!b.hidden(t):!b.hidden),x=new Map;if(g)for(let b of g){let v=b.position??"top-right",y=x.get(v)??[];y.push(b),x.set(v,y);}return jsxs("div",{"data-testid":`workflow-node-${t.id}`,"data-node-id":t.id,className:u("absolute select-none group/node",s&&!t.locked&&"cursor-grab active:cursor-grabbing",t.locked&&"cursor-not-allowed opacity-75",o&&"ring-2 ring-blue-500 ring-offset-1 rounded-lg"),style:{left:t.x,top:t.y,width:c,height:p,overflow:"visible"},children:[f,n.map(b=>jsx(a1,{port:b,allPorts:n,nodeId:t.id,nodeWidth:c,nodeHeight:p,disabled:a,direction:l,onMouseUp:i},b.id)),d&&x.size>0&&Array.from(x.entries()).map(([,b])=>b.map((v,y)=>jsx(i1,{action:v,nodeId:t.id,index:y,nodeWidth:c,disabled:a,onActionClick:d},v.id)))]})});function Eu(e,t,r,n,o="horizontal"){let a=r.find(i=>i.id===e);if(!a)return null;let s=n(a),l=s.find(i=>i.id===t);return l?Ro(a,l,s,o):null}var c1=memo(function({edge:t,fromPos:r,toPos:n,selected:o,disabled:a,direction:s,onClick:l}){let i=hs(r.x,r.y,n.x,n.y,s),d=(r.x+n.x)/2,c=(r.y+n.y)/2,p=useCallback(f=>{f.stopPropagation(),l(t.id,f);},[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:u("transition-colors pointer-events-none",a||t.disabled?"stroke-gray-300":o?"stroke-blue-500":"stroke-gray-400"),strokeWidth:o?2.5:2,strokeDasharray:t.disabled?"6 3":void 0}),t.label&&jsx("text",{x:d,y:c-8,textAnchor:"middle",className:"fill-gray-600 dark:fill-gray-300 text-xs pointer-events-none select-none",fontSize:11,children:t.label})]})}),Mu=memo(function({edges:t,nodes:r,selectedEdgeId:n,disabled:o,direction:a,onEdgeClick:s,getNodePorts:l}){return jsx("svg",{className:"absolute pointer-events-none",style:{top:0,left:0,width:1,height:1,overflow:"visible"},children:jsx("g",{className:"pointer-events-auto",children:t.map(i=>{let d=Eu(i.from.nodeId,i.from.portId,r,l,a),c=Eu(i.to.nodeId,i.to.portId,r,l,a);return !d||!c?null:jsx(c1,{edge:i,fromPos:d,toPos:c,selected:i.id===n,disabled:o,direction:a,onClick:s},i.id)})})})});var m1=()=>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"})}),g1=()=>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"})}),f1=()=>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"})}),b1=()=>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"})}),h1=()=>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"})}),y1=()=>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"})}),x1=()=>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"})}),v1=()=>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"})}),Lu=memo(function({zoom:t,direction:r,onDirectionChange:n,onZoomIn:o,onZoomOut:a,onResetView:s,onFitToContent:l,onExportJSON:i,onImportJSON:d,disabled:c,className:p}){let[f,m]=useState(false),[g,x]=useState(false),[b,v]=useState(""),[y,M]=useState(""),w=useCallback(()=>{v(i()),m(true);},[i]),P=useCallback(()=>{y.trim()&&(d(y.trim()),M(""),x(false));},[y,d]),h=useCallback(()=>{M(""),x(false);},[]),E=useCallback(()=>{m(false);},[]),D=Math.round(t*100);return jsxs(Fragment,{children:[jsxs("div",{className:u("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(ao,{size:"sm",children:[jsx(yt,{content:"Zoom in",size:"sm",position:"bottom",children:jsx(ht,{icon:jsx(m1,{}),size:"sm",bgColor:"bg-gray-100 hover:bg-gray-200 dark:bg-gray-700 dark:hover:bg-gray-600",textColor:"text-gray-700 dark:text-gray-200",onClick:o,disabled:c,"aria-label":"Zoom in"})}),jsx(yt,{content:"Zoom out",size:"sm",position:"bottom",children:jsx(ht,{icon:jsx(g1,{}),size:"sm",bgColor:"bg-gray-100 hover:bg-gray-200 dark:bg-gray-700 dark:hover:bg-gray-600",textColor:"text-gray-700 dark:text-gray-200",onClick:a,disabled:c,"aria-label":"Zoom out"})})]}),jsxs("span",{className:"text-xs font-mono text-gray-500 dark:text-gray-400 min-w-[3ch] text-center select-none",children:[D,"%"]}),jsx("div",{className:"w-px h-5 bg-gray-200 dark:bg-gray-600"}),jsx(yt,{content:"Reset view",size:"sm",position:"bottom",children:jsx(ht,{icon:jsx(f1,{}),size:"sm",bgColor:"bg-gray-100 hover:bg-gray-200 dark:bg-gray-700 dark:hover:bg-gray-600",textColor:"text-gray-700 dark:text-gray-200",onClick:s,disabled:c,"aria-label":"Reset view"})}),jsx(yt,{content:"Fit to content",size:"sm",position:"bottom",children:jsx(ht,{icon:jsx(b1,{}),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:c,"aria-label":"Fit to content"})}),n&&jsxs(Fragment,{children:[jsx("div",{className:"w-px h-5 bg-gray-200 dark:bg-gray-600"}),jsx(yt,{content:r==="horizontal"?"Switch to vertical":"Switch to horizontal",size:"sm",position:"bottom",children:jsx(ht,{icon:r==="horizontal"?jsx(x1,{}):jsx(v1,{}),size:"sm",bgColor:"bg-gray-100 hover:bg-gray-200 dark:bg-gray-700 dark:hover:bg-gray-600",textColor:"text-gray-700 dark:text-gray-200",onClick:()=>n(r==="horizontal"?"vertical":"horizontal"),disabled:c,"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(yt,{content:"Export JSON",size:"sm",position:"bottom",children:jsx(ht,{icon:jsx(h1,{}),size:"sm",bgColor:"bg-gray-100 hover:bg-gray-200 dark:bg-gray-700 dark:hover:bg-gray-600",textColor:"text-gray-700 dark:text-gray-200",onClick:w,disabled:c,"aria-label":"Export JSON"})}),jsx(yt,{content:"Import JSON",size:"sm",position:"bottom",children:jsx(ht,{icon:jsx(y1,{}),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:()=>x(true),disabled:c,"aria-label":"Import JSON"})})]}),jsx(rn,{isOpen:f,onClose:E,title:"Export Workflow",description:"Copy the JSON below to save your workflow.",size:"lg",showSubmit:false,showCancel:true,cancelLabel:"Close",children:jsx(Vr,{label:"Workflow JSON",multiline:true,rows:12,value:b,readOnly:true,size:"sm"})}),jsx(rn,{isOpen:g,onClose:h,title:"Import Workflow",description:"Paste workflow JSON to load it into the editor.",size:"lg",showSubmit:true,submitLabel:"Import",onSubmitClick:P,showCancel:true,cancelLabel:"Cancel",children:jsx(Vr,{label:"Workflow JSON",multiline:true,rows:12,value:y,onChange:k=>M(k.target.value),placeholder:'{"nodes": [], "edges": []}',size:"sm"})})]})});var el={x:0,y:0,zoom:1},tl=.1,w1=.1,N1=3,S1=20;function Wu(){return `edge-${Date.now()}-${Math.random().toString(36).slice(2,8)}`}function R1({value:e,defaultValue:t,onValueChange:r,nodeRegistry:n,direction:o="horizontal",onDirectionChange:a,onNodeClick:s,onNodeDoubleClick:l,onNodeContextMenu:i,onNodeAction:d,readOnly:c=false,disabled:p=false,draggableNodes:f=true,connectable:m=true,selectable:g=true,multiSelect:x=false,panOnDrag:b=true,zoomOnWheel:v=true,minZoom:y=w1,maxZoom:M=N1,snapToGrid:w=false,gridSize:P=S1,showGrid:h=true,toolbar:E=true,autoFit:D=false,className:k},I){let W=e!==void 0,[O,L]=useState(()=>t??{nodes:[],edges:[],viewport:{...el}}),T=W?e:O,S=T.nodes,C=T.edges,N=T.viewport??el,R=useRef(null),$=useRef(null),[H,K]=useState(new Set),[_,F]=useState(null),[A,B]=useState(null),U=useRef(N);U.current=N;let Q=useRef(S);Q.current=S;let J=useRef(C);J.current=C;let Y=useRef(w);Y.current=w;let z=useRef(P);z.current=P;let X=useRef(n);X.current=n;let ne=useRef(o);ne.current=o;let re=useCallback(Z=>{W?r?.(Z(e)):L(ee=>{let fe=Z(ee);return r?.(fe),fe});},[W,e,r]),q=useRef(re);q.current=re;let de=useCallback(Z=>{re(ee=>({...ee,viewport:Z}));},[re]),xe=useRef(de);xe.current=de;let ke=useCallback(Z=>{let ee=n[Z.type];return ee?.getPorts?ee.getPorts(Z):Z.ports??[]},[n]),le=useRef(ke);le.current=ke;let Se=useCallback((Z,ee,fe)=>{let ge=Q.current,Re=J.current,ve=ge.find(st=>st.id===Z.fromNodeId),we=ge.find(st=>st.id===ee);if(!ve||!we)return;let Fe=le.current(ve),Ae=le.current(we),ot=Fe.find(st=>st.id===Z.fromPortId),qe=Ae.find(st=>st.id===fe);if(!ot||!qe||qe.kind!=="in"||Z.fromNodeId===ee)return;let _e=X.current[ve.type];if(_e?.canConnect&&!_e.canConnect({fromNode:ve,toNode:we,fromPort:ot,toPort:qe}))return;Re.some(st=>st.from.nodeId===Z.fromNodeId&&st.from.portId===Z.fromPortId&&st.to.nodeId===ee&&st.to.portId===fe)||q.current(st=>({...st,edges:[...st.edges,{id:Wu(),from:{nodeId:Z.fromNodeId,portId:Z.fromPortId},to:{nodeId:ee,portId:fe}}]}));},[]);useEffect(()=>{function Z(fe){let ge=$.current;if(!ge)return;let Re=R.current?.getBoundingClientRect();if(!Re)return;let ve=U.current;if(ge.type==="pan"){let we=fe.clientX-ge.startX,Fe=fe.clientY-ge.startY;xe.current({...ve,x:ge.startViewportX+we,y:ge.startViewportY+Fe});}if(ge.type==="node"){let we=So(fe.clientX,fe.clientY,ve,Re),Fe=we.x-ge.offsetX,Ae=we.y-ge.offsetY;Y.current&&(Fe=Zi(Fe,z.current),Ae=Zi(Ae,z.current)),q.current(ot=>({...ot,nodes:ot.nodes.map(qe=>qe.id===ge.nodeId?{...qe,x:Fe,y:Ae}:qe)}));}if(ge.type==="edge"){let we=So(fe.clientX,fe.clientY,ve,Re);$.current={...ge,currentX:we.x,currentY:we.y},B({fromX:ge.fromX,fromY:ge.fromY,currentX:we.x,currentY:we.y});}}function ee(fe){let ge=$.current;if(ge){if(ge.type==="edge"){let Re=R.current?.getBoundingClientRect();if(Re){let ve=U.current,we=So(fe.clientX,fe.clientY,ve,Re),Fe=25,Ae=Q.current,ot=1/0,qe=null,_e=null;for(let Mt of Ae){let st=le.current(Mt);for(let mr of st){if(mr.kind!=="in")continue;let Gr=Ro(Mt,mr,st,ne.current),wn=Math.sqrt((we.x-Gr.x)**2+(we.y-Gr.y)**2);wn<Fe&&wn<ot&&(ot=wn,qe=Mt.id,_e=mr.id);}}qe&&_e&&Se(ge,qe,_e);}B(null);}$.current=null;}}return document.addEventListener("mousemove",Z),document.addEventListener("mouseup",ee),()=>{document.removeEventListener("mousemove",Z),document.removeEventListener("mouseup",ee);}},[Se]);let Me=useCallback(Z=>{if(!v||p)return;Z.preventDefault();let ee=R.current?.getBoundingClientRect();if(!ee)return;let fe=Z.clientX-ee.left,ge=Z.clientY-ee.top,Re=Z.deltaY<0?1:-1,ve=fa(N.zoom+Re*tl,y,M),we=ve/N.zoom;de({x:fe-(fe-N.x)*we,y:ge-(ge-N.y)*we,zoom:ve});},[v,p,N,y,M,de]),je=useCallback(Z=>{if(p)return;let ee=Z.target;if(ee.closest("[data-action-id]"))return;let ge=ee.closest("[data-port-id]");if(ge){if(!m||c)return;Z.preventDefault();let ve=ge.getAttribute("data-node-id"),we=ge.getAttribute("data-port-id"),Fe=ge.getAttribute("data-port-kind");if(!ve||!we||Fe!=="out")return;let Ae=S.find(Mt=>Mt.id===ve);if(!Ae)return;let ot=ke(Ae),qe=ot.find(Mt=>Mt.id===we);if(!qe)return;let _e=Ro(Ae,qe,ot,ne.current);$.current={type:"edge",fromNodeId:ve,fromPortId:we,fromX:_e.x,fromY:_e.y,currentX:_e.x,currentY:_e.y},B({fromX:_e.x,fromY:_e.y,currentX:_e.x,currentY:_e.y});return}let Re=ee.closest("[data-node-id]");if(Re){if(c)return;let ve=Re.getAttribute("data-node-id");if(g&&(F(null),x&&Z.shiftKey?K(we=>{let Fe=new Set(we);return Fe.has(ve)?Fe.delete(ve):Fe.add(ve),Fe}):K(new Set([ve]))),f){let we=R.current?.getBoundingClientRect();if(!we)return;let Fe=S.find(ot=>ot.id===ve);if(!Fe||Fe.locked)return;let Ae=So(Z.clientX,Z.clientY,N,we);$.current={type:"node",nodeId:ve,startX:Ae.x,startY:Ae.y,offsetX:Ae.x-Fe.x,offsetY:Ae.y-Fe.y};}return}g&&(K(new Set),F(null)),b&&Z.button===0&&($.current={type:"pan",startX:Z.clientX,startY:Z.clientY,startViewportX:N.x,startViewportY:N.y});},[p,m,c,g,x,f,b,N,S,ke]),at=useCallback(Z=>{let ee=$.current;if(!ee||ee.type!=="edge")return;let fe=R.current?.getBoundingClientRect();if(fe){let ge=So(Z.clientX,Z.clientY,N,fe),Re=30,ve=1/0,we=null,Fe=null;for(let Ae of S){let ot=ke(Ae);for(let qe of ot){if(qe.kind!=="in")continue;let _e=Ro(Ae,qe,ot,ne.current),Mt=Math.sqrt((ge.x-_e.x)**2+(ge.y-_e.y)**2);Mt<Re&&Mt<ve&&(ve=Mt,we=Ae.id,Fe=qe.id);}}if(we&&Fe){let Ae=ee.fromNodeId,ot=ee.fromPortId;Ae!==we&&(C.some(_e=>_e.from.nodeId===Ae&&_e.from.portId===ot&&_e.to.nodeId===we&&_e.to.portId===Fe)||re(_e=>({..._e,edges:[..._e.edges,{id:Wu(),from:{nodeId:Ae,portId:ot},to:{nodeId:we,portId:Fe}}]})));}}$.current=null,B(null);},[N,S,C,ke,re]),$e=useCallback((Z,ee)=>{let fe=$.current;!fe||fe.type!=="edge"||(Se(fe,Z,ee),$.current=null,B(null));},[Se]),ie=useCallback(Z=>{let ee=Z.target;if(ee.closest("[data-port-id]")||ee.closest("[data-action-id]"))return null;let Re=ee.closest("[data-node-id]");if(!Re)return null;let ve=Re.getAttribute("data-node-id");return S.find(we=>we.id===ve)??null},[S]),he=useCallback(Z=>{if(!s||p)return;let ee=ie(Z);ee&&s({node:ee,nativeEvent:Z.nativeEvent});},[s,p,ie]),Ie=useCallback(Z=>{if(!l||p)return;let ee=ie(Z);ee&&l({node:ee,nativeEvent:Z.nativeEvent});},[l,p,ie]),xt=useCallback(Z=>{if(!i||p)return;let ee=ie(Z);ee&&(Z.preventDefault(),i({node:ee,nativeEvent:Z.nativeEvent}));},[i,p,ie]),Te=useCallback((Z,ee,fe)=>{if(!d||p)return;let ge=S.find(Re=>Re.id===Z);ge&&d({node:ge,actionId:ee,nativeEvent:fe});},[d,p,S]),Ee=useCallback((Z,ee)=>{!g||p||(ee.stopPropagation(),K(new Set),F(Z));},[g,p]),nt=useCallback(Z=>{c||p||((Z.key==="Delete"||Z.key==="Backspace")&&(H.size>0&&(re(ee=>({...ee,nodes:ee.nodes.filter(fe=>!H.has(fe.id)),edges:ee.edges.filter(fe=>!H.has(fe.from.nodeId)&&!H.has(fe.to.nodeId))})),K(new Set)),_&&(re(ee=>({...ee,edges:ee.edges.filter(fe=>fe.id!==_)})),F(null))),Z.key==="Escape"&&(K(new Set),F(null)));},[c,p,H,_,re]),pr=useCallback(()=>{let Z=fa(N.zoom+tl,y,M);de({...N,zoom:Z});},[N,y,M,de]),pt=useCallback(()=>{let Z=fa(N.zoom-tl,y,M);de({...N,zoom:Z});},[N,y,M,de]),Ht=useCallback(()=>{de({...el});},[de]),Ft=useCallback(()=>{let Z=R.current?.getBoundingClientRect();if(!Z)return;let ee=Tu(S,Z.width,Z.height),fe=fa(ee.zoom,y,M);de({...ee,zoom:fe});},[S,y,M,de]),sr=useCallback(Z=>{re(ee=>({...ee,nodes:[...ee.nodes,Z]}));},[re]),Nr=useCallback(Z=>{re(ee=>({...ee,nodes:ee.nodes.filter(fe=>fe.id!==Z),edges:ee.edges.filter(fe=>fe.from.nodeId!==Z&&fe.to.nodeId!==Z)}));},[re]),Gt=useCallback(()=>JSON.stringify(T,null,2),[T]),er=useCallback(Z=>{try{let ee=JSON.parse(Z);ee&&Array.isArray(ee.nodes)&&Array.isArray(ee.edges)&&re(()=>ee);}catch{}},[re]);useImperativeHandle(I,()=>({zoomIn:pr,zoomOut:pt,resetView:Ht,fitToContent:Ft,addNode:sr,removeNode:Nr,toJSON:Gt,loadJSON:er}),[pr,pt,Ht,Ft,sr,Nr,Gt,er]);let tr=useRef(false);useEffect(()=>{D&&!tr.current&&R.current&&(tr.current=true,Ft());},[D,Ft]);let ue=useMemo(()=>{let Z=new Map;for(let ee of S)Z.set(ee.id,ke(ee));return Z},[S,ke]),me=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:R,"data-testid":"workflow-editor",className:u("relative w-full overflow-hidden bg-gray-50 dark:bg-gray-900 select-none",p&&"opacity-60 pointer-events-none",k),tabIndex:0,onWheel:Me,onMouseDown:je,onMouseUp:at,onClick:he,onDoubleClick:Ie,onContextMenu:xt,onKeyDown:nt,children:[h&&jsx(Ru,{gridSize:P,zoom:N.zoom}),E&&!c&&jsx(Lu,{zoom:N.zoom,direction:o,onDirectionChange:a,onZoomIn:pr,onZoomOut:pt,onResetView:Ht,onFitToContent:Ft,onExportJSON:Gt,onImportJSON:er,disabled:p}),jsxs("div",{style:me,children:[jsx(Mu,{edges:C,nodes:S,selectedEdgeId:_,disabled:p||c,direction:o,onEdgeClick:Ee,getNodePorts:Z=>ue.get(Z.id)??[]}),S.map(Z=>{let ee=n[Z.type];if(!ee)return null;let fe=ue.get(Z.id)??[];return jsx(Pu,{node:Z,registry:ee,ports:fe,selected:H.has(Z.id),disabled:p||c,draggable:f&&!c,direction:o,onPortMouseUp:$e,onActionClick:d?Te:void 0},Z.id)})]}),A&&jsxs("svg",{"data-testid":"drag-edge-overlay",style:{position:"absolute",top:0,left:0,width:"100%",height:"100%",pointerEvents:"none",zIndex:1e3,overflow:"visible"},children:[jsx("path",{d:hs(A.fromX*N.zoom+N.x,A.fromY*N.zoom+N.y,A.currentX*N.zoom+N.x,A.currentY*N.zoom+N.y,o),fill:"none",stroke:"#3b82f6",strokeWidth:2.5,strokeDasharray:"8 4"}),jsx("circle",{cx:A.fromX*N.zoom+N.x,cy:A.fromY*N.zoom+N.y,r:5,fill:"#3b82f6"}),jsx("circle",{cx:A.currentX*N.zoom+N.x,cy:A.currentY*N.zoom+N.y,r:4,fill:"#3b82f6",opacity:.6})]})]})}var Hu=forwardRef(R1);Hu.displayName="WorkflowEditor";var Ou=createContext(null);function Cn(){let e=useContext(Ou);if(!e)throw new Error("useWizard and Wizard sub-components must be used within <Wizard>");return e}var nl=(e,t,r)=>Math.max(t,Math.min(e,r)),ol={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"}},Xr={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 E1({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 $u({steps:e,step:t,defaultStep:r=0,onStepChange:n,onComplete:o,orientation:a="horizontal",variant:s="default",size:l="md",color:i="primary",linear:d=true,className:c,children:p}){let f=e.length,m=Math.max(0,f-1),g=t!==void 0,[x,b]=useState(()=>nl(r,0,m)),v=nl(g?t:x,0,m),[y,M]=useState(v);y<v&&M(v);let w=v<=0,P=v>=m,h=useCallback((L,T)=>{let S=nl(L,0,m);S!==v&&(g||b(S),M(C=>Math.max(C,S)),n?.(S,{previous:v,direction:T}));},[v,g,m,n]),E=useCallback(L=>{let T=e[L];return !T||T.disabled?false:d?L<=y:true},[e,d,y]),D=useCallback(L=>{E(L)&&h(L,L>v?"jump":"backward");},[E,h,v]),k=useCallback(()=>{if(P){o?.();return}h(v+1,"forward");},[P,o,h,v]),I=useCallback(()=>{w||h(v-1,"backward");},[w,h,v]),W=useCallback(L=>e[L]?.error?"error":L===v?"active":L<v?"completed":"upcoming",[e,v]),O={steps:e,activeStep:v,totalSteps:f,isFirstStep:w,isLastStep:P,orientation:a,variant:s,size:l,color:i,linear:d,goToStep:D,goNext:k,goBack:I,getStepStatus:W,isStepAccessible:E};return jsx(Ou.Provider,{value:O,children:jsx("div",{className:u("flex w-full flex-col gap-6",c),"data-testid":"wizard","data-orientation":a,children:p})})}function Vu({index:e,status:t}){let{variant:r,size:n,color:o,steps:a}=Cn(),s=ol[n],l=a[e];if(r==="dots"){let c=t==="upcoming"?"bg-gray-300 dark:bg-gray-600":t==="error"?"bg-red-600":Xr[o].bg;return jsx("span",{className:u("shrink-0 rounded-full transition-colors",s.dot,c),"aria-hidden":"true"})}let i=t==="completed"?u(Xr[o].solid,"border-transparent"):t==="active"?u(Xr[o].solid,"border-transparent ring-4",Xr[o].ringSoft):t==="error"?"border-transparent bg-red-600 text-white":"border-2 border-gray-300 bg-white text-gray-500 dark:border-gray-600 dark:bg-gray-800 dark:text-gray-400",d=t==="completed"?jsx(E1,{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:u("flex shrink-0 items-center justify-center rounded-full transition-all",s.circle,i),"aria-hidden":"true",children:d})}function Bu({index:e,status:t}){let{steps:r,size:n,color:o,variant:a}=Cn(),s=ol[n],l=r[e],d=t==="active"?Xr[o].text:t==="completed"?"text-gray-900 dark:text-gray-100":t==="error"?"text-red-600 dark:text-red-400":"text-gray-500 dark:text-gray-400";return jsxs("span",{className:"flex min-w-0 flex-col",children:[jsxs("span",{className:u("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:u("mt-0.5 text-gray-400 dark:text-gray-500",s.desc),children:l.description})]})}function _u({className:e,hideConnector:t=false,hideLabels:r=false}){let n=Cn(),{steps:o,orientation:a,size:s,variant:l,color:i,activeStep:d}=n,c=ol[s],p=a==="vertical",f=l!=="simple";return jsx("ol",{className:u("flex w-full",p?"flex-col":"items-start",e),"data-testid":"wizard-steps","data-orientation":a,children:o.map((m,g)=>{let x=n.getStepStatus(g),b=g===d,v=n.isStepAccessible(g)&&!b,y=g===o.length-1,w=g<d?Xr[i].bg:"bg-gray-200 dark:bg-gray-700";return p?jsx("li",{className:"flex","aria-current":b?"step":void 0,"data-status":x,"data-testid":"wizard-step",children:jsxs("button",{type:"button",disabled:!v,onClick:()=>n.goToStep(g),className:u("flex items-stretch gap-3 rounded-md text-left focus:outline-none focus-visible:ring-2 focus-visible:ring-offset-2",Xr[i].ring,v?"cursor-pointer":"cursor-default"),children:[jsxs("span",{className:"flex flex-col items-center",children:[f&&jsx(Vu,{index:g,status:x}),!t&&!y&&jsx("span",{className:u("my-1 w-0.5 flex-1 rounded",w),"aria-hidden":"true"})]}),!r&&jsx("span",{className:u(y?"pb-0":"pb-6"),children:jsx(Bu,{index:g,status:x})})]})},m.id??g):jsxs("li",{className:u("flex items-center",!y&&"flex-1"),"aria-current":b?"step":void 0,"data-status":x,"data-testid":"wizard-step",children:[jsxs("button",{type:"button",disabled:!v,onClick:()=>n.goToStep(g),className:u("flex items-center gap-2.5 rounded-md focus:outline-none focus-visible:ring-2 focus-visible:ring-offset-2",Xr[i].ring,v?"cursor-pointer":"cursor-default"),children:[f&&jsx(Vu,{index:g,status:x}),!r&&jsx(Bu,{index:g,status:x})]}),!t&&!y&&jsx("span",{className:u("mx-2 flex-1 rounded",c.connector,w),"aria-hidden":"true"})]},m.id??g)})})}function Xu({index:e,keepMounted:t=false,className:r,children:n}){let{activeStep:o}=Cn(),a=e===o;return !a&&!t?null:jsx("div",{role:"tabpanel",hidden:!a,"data-testid":"wizard-panel","data-active":a,"data-step":e,className:u("w-full",r),children:n})}function Gu({className:e,children:t}){let r=Cn();return jsx("div",{className:u("w-full",e),"data-testid":"wizard-content",children:typeof t=="function"?t(r):t})}var Ku="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 al({children:e,label:t="Previous",className:r,onClick:n,disabled:o,...a}){let{goBack:s,isFirstStep:l}=Cn();return jsx("button",{type:"button",onClick:d=>{n?.(d),d.defaultPrevented||s();},disabled:o??l,"data-testid":"wizard-previous",className:u(Ku,"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 sl({children:e,label:t="Next",finishLabel:r="Finish",className:n,onClick:o,...a}){let{goNext:s,isLastStep:l,color:i}=Cn();return jsx("button",{type:"button",onClick:c=>{o?.(c),c.defaultPrevented||s();},"data-testid":"wizard-next",className:u(Ku,Xr[i].solid,Xr[i].ring,"hover:opacity-90",n),...a,children:e??(l?r:t)})}function Uu({className:e,children:t,align:r="between"}){let n={between:"justify-between",start:"justify-start",center:"justify-center",end:"justify-end"}[r];return jsx("div",{className:u("flex items-center gap-3",n,e),"data-testid":"wizard-actions",children:t??jsxs(Fragment,{children:[jsx(al,{}),jsx(sl,{})]})})}$u.displayName="Wizard";_u.displayName="WizardSteps";Xu.displayName="WizardPanel";Gu.displayName="WizardContent";Uu.displayName="WizardActions";al.displayName="WizardPrevious";sl.displayName="WizardNext";export{f0 as Accordion,y0 as AccordionContent,b0 as AccordionItem,h0 as AccordionTrigger,xl as AdvanceDetachable,wp as AreaChart,Tp as Avatar,$l as Badge,Gl as Banner,$p as BarChart,em as Breadcrumb,cm as BulletChart,ht as Button,ao as ButtonGroup,Ra as CHART_ALL_PAIRS_LIMIT,Na as CHART_DIVERGING_COLORS,Ml as CHART_DIVERGING_DARK_STOPS,El as CHART_DIVERGING_NEUTRAL_INDEX,Ta as CHART_MAX_COLOR_CLASSES,Mr as CHART_MUTED_COLOR,Fs as CHART_ORDINAL_COLORS,cp as CHART_ORDINAL_DARK_STOPS,dp as CHART_PALETTE_SIZE,Hs as CHART_SEQUENTIAL_COLORS,Dl as CHART_SEQUENTIAL_DARK_STOPS,Sa as CHART_SERIES_COLORS,Em as Calendar,Ql as Card,td as CardBody,ad as CardDescription,rd as CardFooter,ed as CardHeader,nd as CardImage,od as CardTitle,St as ChartAxis,Kt as ChartContainer,Zm as ChartFacets,Kr as ChartGrid,yr as ChartLegend,Bo as ChartScaleLegend,Yt as ChartTableView,jt as ChartTooltip,vr as ChartTooltipContent,Xo as Checkbox,ld as CheckboxGroup,dd as CheckboxGroupItem,Ba as Chip,Un as CircularProgress,Nl as DEFAULT_CHART_WIDTH,ma as DEFAULT_FIELD_TYPES,Tg as DataGrid,md as Detachable,sf as DeviceMockup,fd as Divider,Td as Drawer,zd as Dropdown,jd as DropdownCheckboxItem,Od as DropdownContent,_d as DropdownItem,Gd as DropdownLabel,Jd as DropdownRadioGroup,ec as DropdownRadioItem,Xd as DropdownSeparator,sc as DropdownSubMenu,lc as DropdownSubMenuContent,ic as DropdownSubMenuTrigger,Hd as DropdownTrigger,kd as FOCUSABLE_SELECTOR,Lf as FileSelector,qc as Footer,eu as FooterBottom,Qc as FooterColumn,Jc as FooterLink,Zc as FooterSection,tu as FooterSocial,ru as FooterSocialLink,Vb as Header,Sh as Heatmap,mc as HelpButton,bd as INERT_IGNORE_ATTRIBUTE,ih as ImageUploader,fc as Indicator,Vr as Input,xc as Label,Lh as LineChart,hi as MentionInput,rn as Modal,yi as NumberInput,Yh as Pagination,ny as PieChart,Pc as ProgressBar,Ec as RadioButton,av as ScatterChart,Nu as SchemaEditor,Ty as Select,Ay as Sidebar,Wy as SidebarContent,Hy as SidebarFooter,Fy as SidebarGroup,zy as SidebarHeader,Vy as SidebarItem,By as SidebarSubMenu,Oy as SidebarToggle,zc as Skeleton,Hc as Slider,Di as Sparkline,jy as StatCard,Zy as StatCardGroup,Ls as Table,As as TableBody,Ca as TableCell,zs as TableHeader,wa as TableHeaderCell,Ws as TableRow,Vc as Tabs,Xc as TabsContent,Bc as TabsList,_c as TabsTrigger,Uc as Toast,yt as Tooltip,B0 as UILabelsProvider,eh as WithHelpButton,$u as Wizard,Uu as WizardActions,Gu as WizardContent,sl as WizardNext,Xu as WizardPanel,al as WizardPrevious,_u as WizardSteps,Hu as WorkflowEditor,Ui as autoLayoutTables,u as cn,Bi as createDefaultField,Oi as createDefaultTable,qn as createDivergingScale,Bs as createSequentialScale,Cl as defaultUILabels,_a as findOwnedLayers,V0 as frenchUILabels,pa as generateFieldId,Vi as generateRelationId,fs as generateSQL,cu as generateTableId,Xa as getFocusableElements,pp as getOrdinalColor,jn as getSeriesColor,Bt as getSeriesLabel,ii as hideOthers,Cd as isElementVisible,wd as isFocusable,Vs as rampColor,Ln as registerFloatingLayer,Qm as resetFacetWarnings,Ir as resolveSeriesColor,Ur as toLegendItems,Is as useChartSize,uo as useClickOutside,An as useDialogA11y,nr as useDropdownContext,Vd as useFocusItem,Ua as useKeyboardNavigation,po as usePositioning,Dy as useSidebar,At as useUILabels,Cn as useWizard};
|