@opencxh/ui-kit 3.137.6 → 3.137.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +63 -57
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const Je=require("clsx"),e=require("react/jsx-runtime"),R=require("lucide-react"),d=require("react"),Xe=require("dompurify"),Ye=require("react-markdown"),Ze=require("remark-gfm");function i(...t){return Je.clsx(t)}function Qe(t){return(s,r)=>t[s]?.[r]||""}function et(t){return s=>t[s]||""}const ze=["cat-1","cat-2","cat-3","cat-4","cat-5"];function tt(t){let s=0;for(let r=0;r<t.length;r++)s=s*31+t.charCodeAt(r)>>>0;return ze[s%ze.length]}function st({tiles:t,pinned:s,className:r}){if(s)return e.jsxs("div",{className:i("flex flex-col md:flex-row gap-2 h-full min-h-0",r),children:[e.jsx("div",{className:"flex-1 min-h-0",children:s}),t.length>0&&e.jsx("div",{className:"flex md:flex-col gap-2 md:w-48 overflow-auto",children:t.map((a,l)=>e.jsx("div",{className:"min-w-40 md:min-w-0",children:a},l))})]});const n=t.length<=1?"grid-cols-1":t.length<=4?"grid-cols-2":t.length<=9?"grid-cols-3":"grid-cols-4";return e.jsx("div",{className:i("grid gap-2 h-full",n,r),children:t.map((a,l)=>e.jsx("div",{children:a},l))})}function rt({name:t,avatarUrl:s,muted:r,speaking:n,hasVideo:a,videoSlot:l,className:o,fill:x}){return e.jsxs("div",{className:i("relative rounded-lg overflow-hidden bg-video-surface flex items-center justify-center",x?"h-full w-full":"aspect-video",n&&"ring-2 ring-speaking",o),children:[a&&l?e.jsx("div",{className:"absolute inset-0",children:l}):e.jsx("div",{className:"flex flex-col items-center gap-2 text-gray-300",children:s?e.jsx("img",{src:s,alt:t,className:"w-16 h-16 rounded-full object-cover"}):e.jsx("div",{className:"w-16 h-16 rounded-full bg-video-surface-strong flex items-center justify-center",children:a?e.jsx(R.VideoOff,{className:"w-8 h-8"}):e.jsx(R.User,{className:"w-8 h-8"})})}),e.jsxs("div",{className:"absolute bottom-2 left-2 flex items-center gap-1.5 px-2 py-1 rounded bg-video-overlay text-white text-xs",children:[r?e.jsx(R.MicOff,{className:"w-3 h-3"}):e.jsx(R.Mic,{className:"w-3 h-3"}),e.jsx("span",{className:"truncate max-w-35",children:t})]})]})}function nt({attach:t,active:s=!0,mirrored:r=!1,className:n}){const a=d.useRef(null);return d.useEffect(()=>{if(!s||!a.current)return;const l=t(a.current);return()=>{typeof l=="function"&&l(),a.current&&(a.current.innerHTML="")}},[t,s]),e.jsx("div",{ref:a,className:i("w-full h-full bg-video-surface-strong overflow-hidden",r&&"[&>*]:scale-x-[-1]",n)})}const at={primary:"bg-accent text-accent-fg hover:bg-accent-hover disabled:bg-surface-hover",secondary:"bg-surface-sunk text-text-strong hover:bg-surface-hover disabled:bg-surface-hover",outline:"border border-border text-text-strong hover:bg-surface-hover",ghost:"text-text-muted hover:bg-surface-hover hover:text-text",destructive:"border border-danger-border bg-danger-soft text-danger-fg hover:border-danger disabled:bg-surface-hover",success:"bg-success text-text-inverse hover:opacity-90 disabled:bg-surface-hover",warning:"bg-warning text-text-inverse hover:opacity-90 disabled:bg-surface-hover","danger-solid":"bg-danger text-text-inverse hover:opacity-90 disabled:bg-surface-hover"},lt={xs:"h-control-xs px-2 text-xs",sm:"h-control-sm px-3 text-sm",md:"h-control-md px-4 text-sm",lg:"h-control-lg px-4 text-sm",xl:"h-control-xl px-6 text-base","2xl":"h-control-2xl px-6 text-base",full:"h-control-md px-4 text-sm"},ot={xs:"h-control-xs w-6",sm:"h-control-sm w-7",md:"h-control-md w-8",lg:"h-control-lg w-9",xl:"h-control-xl w-10","2xl":"h-control-2xl w-12",full:"h-control-md w-8"},re=d.forwardRef(({variant:t="primary",size:s="md",fullWidth:r=!1,loading:n=!1,leftIcon:a,rightIcon:l,iconOnly:o=!1,shape:x="default",className:u,children:j,disabled:h,...m},b)=>{const v=h||n;return e.jsxs("button",{ref:b,type:"button",className:i("inline-flex shrink-0 items-center justify-center gap-2 cursor-pointer font-medium",x==="circle"?"rounded-full":"rounded-md","transition-colors duration-fast ease-out","focus-visible:outline-none focus-visible:focus-ring","disabled:cursor-not-allowed disabled:border-border-subtle","disabled:text-text-disabled",at[t],o?ot[s]:lt[s],(r||s==="full")&&"w-full",n&&"cursor-wait",u),disabled:v,"aria-busy":n||void 0,...m,children:[n&&e.jsx("span",{"aria-hidden":!0,className:"size-icon-md shrink-0 animate-spin rounded-full border-2 border-current border-t-transparent"}),!n&&a&&e.jsx("span",{className:"flex items-center justify-center shrink-0",children:a}),!o&&j,!n&&l&&e.jsx("span",{className:"flex items-center justify-center shrink-0",children:l}),o&&!n&&!a&&!l&&j]})});re.displayName="Button";const ct=({children:t,size:s="md",orientation:r="horizontal",attached:n=!0,className:a})=>{const l=i("inline-flex",{"flex-row":r==="horizontal","flex-col":r==="vertical","[&>*:not(:first-child):not(:last-child)]:rounded-none":n,"[&>*:first-child]:rounded-r-none":n&&r==="horizontal","[&>*:last-child]:rounded-l-none":n&&r==="horizontal","[&>*:first-child]:rounded-b-none":n&&r==="vertical","[&>*:last-child]:rounded-t-none":n&&r==="vertical","[&>*:not(:first-child)]:-ml-px":n&&r==="horizontal","[&>*:not(:first-child)]:-mt-px":n&&r==="vertical","gap-1":!n&&s==="xs","gap-2":!n&&(s==="sm"||s==="md"),"gap-3":!n&&(s==="lg"||s==="xl")},a);return e.jsx("div",{className:l,role:"group",children:t})},it={primary:"text-text",secondary:"text-text-muted",accent:"text-accent",success:"text-success-fg",warning:"text-warning-fg",error:"text-danger-fg",info:"text-info-fg",neutral:"text-text-subtle",current:"text-current"},Y=({icon:t,size:s="md",color:r="current",clickable:n=!1,onClick:a,className:l,"aria-label":o,...x})=>{const u=typeof s=="number"?s:dt(s),j=i("inline-block shrink-0",it[r],n&&["cursor-pointer rounded-sm transition-opacity duration-fast ease-out hover:opacity-80","focus-visible:outline-none focus-visible:focus-ring"],l),h={size:u,strokeWidth:2,className:j,onClick:n?a:void 0,"aria-label":o,"aria-hidden":o?void 0:!0,role:n?"button":void 0,tabIndex:n?0:void 0,onKeyDown:n?m=>{(m.key==="Enter"||m.key===" ")&&(m.preventDefault(),a?.())}:void 0,...x};return e.jsx(t,{...h})};function dt(t){return{xs:12,sm:14,md:16,lg:20,xl:24}[t]}function ve(t,s,{gap:r=6,matchWidth:n=!1,placement:a="bottom-start"}={}){const[l,o]=d.useState({});return d.useLayoutEffect(()=>{if(!t)return;const x=()=>{const u=s.current;if(!u)return;const j=u.getBoundingClientRect(),h=window.innerHeight-j.bottom,m=j.top,b=a.startsWith("top"),v=b?m<200&&h>m:h<200&&m>h,w=b!==v,g={position:"fixed"};w?(g.bottom=window.innerHeight-j.top+r,g.maxHeight=Math.max(120,m-r*2)):(g.top=j.bottom+r,g.maxHeight=Math.max(120,h-r*2)),a.endsWith("end")?g.right=window.innerWidth-j.right:g.left=j.left,n&&(g.width=j.width),o(g)};return x(),window.addEventListener("scroll",x,!0),window.addEventListener("resize",x),()=>{window.removeEventListener("scroll",x,!0),window.removeEventListener("resize",x)}},[t,s,r,n,a]),l}const we=({trigger:t,children:s,placement:r="bottom-start",className:n,rootClassName:a,triggerClassName:l,disabled:o=!1,triggerLabel:x})=>{const[u,j]=d.useState(!1),h=d.useRef(null),m=d.useRef(null),b=ve(u,m,{placement:r});d.useEffect(()=>{if(!u)return;const g=z=>{h.current&&!h.current.contains(z.target)&&j(!1)},f=z=>{z.key==="Escape"&&j(!1)};return document.addEventListener("mousedown",g),document.addEventListener("keydown",f),()=>{document.removeEventListener("mousedown",g),document.removeEventListener("keydown",f)}},[u]);const v=g=>{g.stopPropagation(),!o&&j(f=>!f)},w=()=>j(!1);return e.jsxs("div",{ref:h,className:i("relative inline-flex",a),children:[e.jsx("button",{ref:m,type:"button",onClick:v,disabled:o,"aria-label":x,"aria-expanded":u,className:i("inline-flex items-center",o&&"cursor-not-allowed opacity-50",l),children:t}),u&&e.jsx("div",{className:i("fixed z-overlay overflow-y-auto rounded-lg border border-border bg-surface shadow-overlay",n),style:b,children:typeof s=="function"?s(w):s})]})},ut={none:"hover:bg-surface-sunk hover:text-text",default:"bg-surface-sunk text-text-muted hover:text-text",muted:"bg-surface-sunk text-text-subtle hover:text-text",outline:"text-text-muted ring-1 ring-inset ring-border-strong hover:bg-surface-hover hover:text-text",warning:"bg-warning-soft text-warning-fg",danger:"bg-danger-soft text-danger-fg"},xt=t=>i("inline-flex cursor-pointer select-none items-center text-sm font-medium",t.size==="sm"?"h-control-sm":"h-control-md","transition-colors duration-fast ease-out",t.shape==="pill"?"rounded-full":"rounded-md",t.active?"bg-info-soft text-info-fg":ut[t.tone??"default"],t.className),ft=t=>i("inline-flex items-center gap-1.5 pl-3",t.shape==="pill"?"rounded-full":"rounded-md",t.withClear?"pr-1.5":"pr-3","focus-visible:outline-none focus-visible:focus-ring");function Ae({label:t,icon:s,tone:r="default",shape:n="rect",size:a="md",active:l=!1,caret:o=!1,menu:x,menuClassName:u,onClear:j,clearLabel:h="Filter wissen",onClick:m,title:b,className:v}){const w=l&&!!j,g=n==="pill"?"rounded-full":"rounded-md",f=xt({active:l,tone:r,shape:n,size:a,className:v}),z=e.jsxs(e.Fragment,{children:[s,t,o&&e.jsx(Y,{icon:R.ChevronDown,size:"xs"})]}),k=ft({shape:n,withClear:w}),V=w&&e.jsx("button",{type:"button","aria-label":h,onClick:j,className:i("inline-flex h-full items-center pr-3 focus-visible:outline-none focus-visible:focus-ring",g),children:e.jsx(Y,{icon:R.X,size:"xs"})});return x?e.jsxs("span",{className:f,title:b,children:[e.jsx(we,{trigger:z,rootClassName:"h-full",triggerClassName:i(k,"h-full"),className:i("min-w-menu p-1.5",u),children:x}),V]}):w?e.jsxs("span",{className:f,title:b,children:[e.jsx("button",{type:"button",onClick:m,className:k,children:z}),V]}):e.jsx("button",{type:"button",title:b,onClick:m,className:i(f,k),children:z})}const mt={xs:"text-xs",sm:"text-sm",md:"text-base",lg:"text-md",xl:"text-lg"},ht={primary:"text-text hover:text-info-fg hover:underline",info:"text-info-fg hover:underline",secondary:"text-text-muted hover:text-text",neutral:"text-text-muted hover:text-text",accent:"text-accent hover:underline",success:"text-success-fg hover:underline",warning:"text-warning-fg hover:underline",error:"text-danger-fg hover:underline"},bt={primary:"bg-accent-soft",accent:"bg-accent-soft",secondary:"bg-surface-hover",neutral:"bg-surface-hover",success:"bg-success-soft",warning:"bg-warning-soft",error:"bg-danger-soft",info:"bg-info-soft"},gt=({variant:t="default",size:s="md",color:r="primary",disabled:n=!1,external:a=!1,className:l,children:o,href:x,target:u,rel:j,...h})=>{const m=a||x&&(x.startsWith("http")||x.startsWith("mailto:")),b=i("inline-flex items-center gap-1 underline-offset-2","transition-colors duration-fast ease-out","focus-visible:outline-none focus-visible:focus-ring",mt[s],!n&&ht[r],t==="subtle"&&"no-underline opacity-70 hover:opacity-100",t==="underline"&&"underline decoration-1 hover:decoration-2",t==="button"&&["h-control-md rounded-md px-3 font-semibold no-underline hover:no-underline",bt[r]],n&&"pointer-events-none cursor-not-allowed text-text-disabled opacity-50",l),v={...h,href:n?void 0:x,target:m?"_blank":u,rel:m?"noopener noreferrer":j,"aria-disabled":n||void 0};return e.jsxs("a",{className:b,...v,children:[o,m&&e.jsx(R.ExternalLink,{className:"size-icon-sm shrink-0","aria-hidden":!0})]})},pt={sm:"h-control-sm px-3 text-sm",md:"h-control-md px-3 text-sm"};function _e({options:t,value:s,onChange:r,size:n="sm",tone:a="sunk",fullWidth:l=!1,className:o,"aria-label":x}){return e.jsx("div",{role:"tablist","aria-label":x,className:i("gap-0.5 rounded-md p-0.5",a==="track"?"bg-surface-track":"bg-surface-sunk",l?"flex w-full":"inline-flex",o),children:t.map(u=>{const j=u.value===s;return e.jsx("button",{role:"tab","aria-selected":j,type:"button",onClick:()=>r(u.value),className:i("inline-flex cursor-pointer items-center justify-center gap-1.5 rounded-sm","transition-colors duration-fast ease-out","focus-visible:outline-none focus-visible:focus-ring",l&&"min-w-0 flex-1",pt[n],j?"bg-surface text-text font-medium shadow-sm":"text-text-muted hover:text-text"),children:u.label},u.value)})})}const vt={primary:"bg-accent text-accent-fg hover:bg-accent-hover",secondary:"border border-border bg-surface text-text hover:bg-surface-hover",outline:"border border-accent-border text-accent hover:bg-accent-soft"},jt={sm:"h-control-sm w-7",md:"h-control-md w-8"};function ke({label:t,onClick:s,variant:r="primary",size:n="md",icon:a,options:l,disabled:o=!1,loading:x=!1,menuPlacement:u="bottom-end",menuLabel:j="More options"}){const h=o||x,m=l.length>0;return e.jsxs("div",{className:i("inline-flex items-center",r==="primary"&&"gap-0.5"),children:[e.jsx(re,{variant:r,size:n,onClick:s,disabled:o,loading:x,leftIcon:a,className:i(m&&"rounded-r-none"),children:t}),m&&e.jsx(we,{placement:u,disabled:h,triggerLabel:j,className:"min-w-menu py-1",trigger:e.jsx("span",{"aria-hidden":"true",className:i("inline-flex items-center justify-center rounded-md rounded-l-none","transition-colors duration-fast ease-out",vt[r],jt[n],h&&"cursor-not-allowed opacity-50"),children:e.jsx(R.ChevronDown,{className:"size-icon-md"})}),children:b=>e.jsx(e.Fragment,{children:l.map(v=>e.jsxs("button",{type:"button",onClick:()=>{v.onClick(),b()},className:i("flex w-full items-center gap-2 px-3 py-1.5 text-left text-sm","transition-colors duration-fast ease-out","focus-visible:outline-none focus-visible:focus-ring",v.variant==="destructive"?"text-danger-fg hover:bg-danger-soft":"text-text hover:bg-surface-hover"),children:[v.icon&&e.jsx("span",{className:"shrink-0",children:v.icon}),v.label]},v.id))})})]})}const yt={sm:"size-checkbox-sm",md:"size-checkbox",lg:"size-checkbox-lg",full:"size-checkbox"},Nt={sm:"min-h-control-sm",md:"min-h-control-md",lg:"min-h-control-lg",full:"min-h-control-md"},wt={sm:"text-sm",md:"text-base",lg:"text-md",full:"text-base"},xe=d.forwardRef(({label:t,helperText:s,error:r,size:n="md",indeterminate:a=!1,containerClassName:l,labelClassName:o,className:x,id:u,...j},h)=>{const m=d.useId(),b=u||`checkbox-${m}`,v=!!r,w=d.useRef(null),g=d.useCallback(f=>{w.current=f,typeof h=="function"?h(f):h&&typeof h=="object"&&(h.current=f)},[h]);return d.useEffect(()=>{w.current&&(w.current.indeterminate=a)},[a]),e.jsxs("div",{className:i("flex flex-col",l),children:[e.jsxs("div",{className:i("flex items-center gap-3",Nt[n]),children:[e.jsx("input",{ref:g,id:b,type:"checkbox","aria-invalid":v||void 0,className:i("shrink-0 rounded-xs border accent-accent","transition-colors duration-fast ease-out","focus-visible:outline-none focus-visible:focus-ring","disabled:cursor-not-allowed disabled:bg-surface-hover",yt[n],v?"border-danger-border":"border-border-strong",x),...j}),t&&e.jsxs("div",{className:"flex-1",children:[e.jsx("label",{htmlFor:b,className:i("cursor-pointer",v?"text-danger-fg":"text-text",wt[n],o),children:t}),s&&!r&&e.jsx("p",{className:"mt-0.5 text-xs text-text-subtle",children:s})]})]}),r&&e.jsx("p",{className:"mt-1 text-xs text-danger-fg",children:r})]})});xe.displayName="Checkbox";const kt=()=>e.jsx(Y,{icon:R.Calendar,size:"md",color:"current"}),Ct=()=>e.jsx(Y,{icon:R.ChevronLeft,size:"md",color:"current"}),St=()=>e.jsx(Y,{icon:R.ChevronRight,size:"md",color:"current"}),ge=d.forwardRef(({value:t,onChange:s,placeholder:r="Select date",disabled:n=!1,required:a=!1,size:l="md",className:o,minDate:x,maxDate:u,format:j="MM/dd/yyyy",withTime:h=!1},m)=>{const[b,v]=d.useState(!1),[w,g]=d.useState(()=>t||new Date),f=d.useRef(null),z=d.useRef(null),k=ve(b,z);d.useEffect(()=>{const c=C=>{f.current&&!f.current.contains(C.target)&&v(!1)};return b&&document.addEventListener("mousedown",c),()=>{document.removeEventListener("mousedown",c)}},[b]);const V=c=>{if(!c)return"";const C=c.getDate().toString().padStart(2,"0"),p=(c.getMonth()+1).toString().padStart(2,"0"),$=c.getFullYear(),y=j==="dd/MM/yyyy"?`${C}/${p}/${$}`:j==="yyyy-MM-dd"?`${$}-${p}-${C}`:`${p}/${C}/${$}`;return h?`${y} ${D(c)}`:y},D=c=>`${c.getHours().toString().padStart(2,"0")}:${c.getMinutes().toString().padStart(2,"0")}`,G=c=>{const[C,p]=c.split(":").map(Number);if(Number.isNaN(C)||Number.isNaN(p))return;const $=t?new Date(t):new Date;$.setHours(C,p,0,0),s?.($)},q=()=>{const c=w.getFullYear(),C=w.getMonth(),p=new Date(c,C,1),$=new Date(p);$.setDate($.getDate()-p.getDay());const y=[],U=new Date($);for(let te=0;te<42;te++)y.push(new Date(U)),U.setDate(U.getDate()+1);return y},L=c=>{if(c.getMonth()===w.getMonth()&&!(x&&c<x)&&!(u&&c>u)){if(h){const p=new Date(c);p.setHours(t?.getHours()??0,t?.getMinutes()??0,0,0),s?.(p);return}s?.(c),v(!1)}},H=()=>{g(new Date(w.getFullYear(),w.getMonth()-1,1))},ee=()=>{g(new Date(w.getFullYear(),w.getMonth()+1,1))},J=()=>{s?.(null),v(!1)},W=i("w-full border border-border-strong rounded-tile transition-colors duration-fast","bg-surface text-text","placeholder:text-text-muted","focus-visible:outline-none focus-visible:focus-ring","disabled:cursor-not-allowed disabled:bg-surface-hover disabled:text-text-disabled",{"h-control-sm px-3 text-sm":l==="sm","h-control-md px-3 text-base":l==="md","h-control-lg px-3 text-base":l==="lg","h-control-md w-full px-3 text-base":l==="full"},o),ae=q(),N=["January","February","March","April","May","June","July","August","September","October","November","December"];return e.jsxs("div",{ref:f,className:"relative",children:[e.jsxs("div",{ref:z,className:"relative",children:[e.jsx("input",{ref:m,type:"text",value:V(t??null),placeholder:r,disabled:n,required:a,readOnly:!0,onClick:()=>!n&&v(!b),className:i(W,"pr-10 cursor-pointer")}),e.jsx("button",{type:"button",onClick:()=>!n&&v(!b),disabled:n,className:"absolute inset-y-0 right-0 flex items-center pr-3 text-text-muted hover:text-text-muted",children:e.jsx(kt,{})})]}),b&&e.jsxs("div",{style:k,className:"fixed z-overlay overflow-auto rounded-lg border border-border bg-surface p-4 shadow-overlay min-w-panel",children:[e.jsxs("div",{className:"flex items-center justify-between mb-4",children:[e.jsx("button",{onClick:H,className:"p-1 hover:bg-surface-hover rounded",children:e.jsx(Ct,{})}),e.jsxs("h3",{className:"text-sm font-medium text-text",children:[N[w.getMonth()]," ",w.getFullYear()]}),e.jsx("button",{onClick:ee,className:"p-1 hover:bg-surface-hover rounded",children:e.jsx(St,{})})]}),e.jsx("div",{className:"grid grid-cols-7 gap-1 mb-2",children:["Su","Mo","Tu","We","Th","Fr","Sa"].map(c=>e.jsx("div",{className:"text-xs font-medium text-text-muted text-center py-1",children:c},c))}),e.jsx("div",{className:"grid grid-cols-7 gap-1",children:ae.map((c,C)=>{const p=c.getMonth()===w.getMonth(),$=t&&c.toDateString()===t.toDateString(),y=c.toDateString()===new Date().toDateString(),U=!p||x&&c<x||u&&c>u;return e.jsx("button",{onClick:()=>!U&&L(c),disabled:U,className:i("w-8 h-8 text-sm rounded transition-colors duration-fast",{"text-text hover:bg-surface-hover":p&&!$&&!U,"bg-accent text-accent-fg":$,"bg-surface-hover text-text":y&&!$,"text-text-muted cursor-not-allowed":U}),children:c.getDate()},C)})}),h&&e.jsxs("div",{className:"mt-3 flex items-center gap-2 border-t border-border pt-3",children:[e.jsx("label",{htmlFor:"datepicker-time",className:"text-sm text-text-muted",children:"Tijd"}),e.jsx("input",{id:"datepicker-time",type:"time",value:t?D(t):"",onChange:c=>G(c.target.value),className:"h-control-sm rounded-md border border-border bg-surface-input px-2 text-sm text-text focus-visible:outline-none focus-visible:focus-ring"})]}),e.jsxs("div",{className:"flex justify-between items-center mt-4 pt-3 border-t border-border",children:[e.jsx("button",{onClick:J,className:"text-sm text-text-muted hover:text-text",children:"Clear"}),e.jsx("button",{onClick:()=>v(!1),className:"text-sm text-info-fg hover:underline",children:"Close"})]})]})]})}),Et={sm:"h-control-sm px-3 text-sm",md:"h-control-md px-3 text-sm",lg:"h-control-lg px-3 text-base",full:"h-control-md w-full px-3 text-sm"},be=t=>t.trim().toLowerCase(),he=d.forwardRef(({label:t,helperText:s,error:r,size:n="md",fullWidth:a=!1,disabled:l=!1,options:o,placeholder:x,containerClassName:u,labelClassName:j,className:h,id:m,searchable:b,multiple:v,value:w,onChange:g,allowCreate:f,onCreateOption:z,...k},V)=>{const D=m||`select-${Math.random().toString(36).substr(2,9)}`,G=!!r,[q,L]=d.useState(!1),[H,ee]=d.useState(""),J=d.useRef(null),W=d.useRef(null),ae=ve(q,W,{matchWidth:!0}),[N,c]=d.useState(o);d.useImperativeHandle(V,()=>J.current),d.useEffect(()=>{const T=A=>{J.current&&!J.current.contains(A.target)&&L(!1)};return document.addEventListener("mousedown",T),()=>document.removeEventListener("mousedown",T)},[]);const C=d.useCallback((T,A)=>T.some(E=>be(E.value)===be(A)||be(E.label)===be(A)),[]),p=d.useCallback((T,A)=>{const E=[...T],I=F=>{const B=(F??"").trim();B&&(C(E,B)||E.push({value:B,label:B}))};return Array.isArray(A)?A.forEach(I):I(A),E},[C]);d.useEffect(()=>{c(T=>{const A=[...o];return T.forEach(E=>{!C(A,E.value)&&!C(A,E.label)&&A.push(E)}),p(A,w)})},[o,w,p,C]);const $=T=>{if(v){const A=Array.isArray(w)?w:[],E=A.includes(T)?A.filter(I=>I!==T):[...A,T];g?.(E)}else g?.(T),L(!1),ee("")},y=v?null:N.find(T=>T.value===w),U=v?N.filter(T=>Array.isArray(w)&&w.includes(T.value)):[],te=b&&H?N.filter(T=>T.label.toLowerCase().includes(H.toLowerCase())):N,Q=!!f&&!!b&&!!H.trim()&&!C(N,H),X=T=>{const A=T.trim();if(!A)return;const E=z?.(A)??{value:A,label:A};if(C(N,E.value)||C(N,E.label)){$(E.value),ee(""),v||L(!1);return}c(I=>[...I,E]),$(E.value),ee(""),v||L(!1)},P=()=>v?U.length>0?U.map(T=>T.label).join(", "):x||"Select options":y?.label||x||"Select an option";return e.jsxs("div",{ref:J,className:i("relative flex flex-col",a&&"w-full",u),...k,children:[t&&e.jsx("label",{htmlFor:D,onClick:()=>L(!q),className:i("block text-xs font-semibold uppercase tracking-label mb-1.5",G?"text-danger-fg":"text-text-muted",j),children:t}),e.jsxs("div",{className:"relative",children:[e.jsxs("button",{ref:W,type:"button",id:D,disabled:l,onClick:()=>L(!q),className:i("flex w-full items-center justify-between gap-2 rounded-tile border transition-colors duration-fast text-left","focus-visible:outline-none focus-visible:focus-ring","disabled:cursor-not-allowed disabled:bg-surface-hover disabled:text-text-disabled","bg-surface",Et[n],G?"border-danger-border text-danger-fg focus-visible:focus-ring":"border-border-strong text-text",h),children:[e.jsx("span",{className:"truncate flex-1 min-w-0",children:P()}),e.jsx(R.ChevronDownIcon,{size:16,className:i("shrink-0 opacity-60 transition-transform duration-fast",q&&"rotate-180")})]}),q&&e.jsxs("div",{style:ae,className:"fixed z-overlay flex flex-col overflow-hidden rounded-lg border border-border bg-surface shadow-overlay",children:[b&&e.jsx("div",{className:"p-2",children:e.jsx("input",{type:"text",placeholder:"Search...",value:H,onChange:T=>ee(T.target.value),onKeyDown:T=>{T.key==="Enter"&&Q&&(T.preventDefault(),X(H))},className:i("w-full px-3 py-2 text-sm rounded-md border","text-text border-border focus-visible:outline-none focus-visible:focus-ring")})}),Q&&e.jsxs("div",{className:i("cursor-pointer px-3 py-1.5 text-sm","text-info-fg hover:bg-surface-hover"),onClick:()=>X(H),children:["+: “",H.trim(),"”"]}),e.jsxs("ul",{className:"min-h-0 flex-1 overflow-auto py-1",children:[x&&!v&&e.jsx("li",{className:"cursor-pointer px-3 py-1.5 text-sm text-text-muted hover:bg-surface-hover",onClick:()=>{g?.(""),L(!1)},children:x}),te.map(T=>{const A=v?Array.isArray(w)&&w.includes(T.value):w===T.value;return e.jsx("li",{onClick:()=>!T.disabled&&$(T.value),className:i("cursor-pointer px-3 py-1.5 text-sm","text-text",T.disabled?"opacity-50 cursor-not-allowed":"hover:bg-surface-hover",A&&"bg-accent-soft text-accent font-semibold"),children:e.jsxs("div",{className:"flex items-center",children:[v&&e.jsx("input",{type:"checkbox",checked:A,readOnly:!0,className:"mr-3 h-4 w-4 rounded border-border [&:not(:checked)]:bg-surface-input text-accent "}),e.jsx("span",{children:T.label})]})},T.value)})]})]})]}),(r||s)&&e.jsx("p",{className:i("mt-1 text-xs",G?"text-danger-fg":"text-text-muted"),children:r||s})]})});he.displayName="Select";const Mt={sm:"h-control-sm px-3 text-sm",md:"h-control-md px-3 text-base",lg:"h-control-lg px-3 text-base",full:"h-control-md px-3 text-base"},Re="mb-1.5 block text-sm font-medium",Le="block w-full rounded-tile border bg-surface-input text-text transition-colors duration-fast ease-out placeholder:text-text-subtle focus-visible:outline-none focus-visible:focus-ring disabled:cursor-not-allowed disabled:bg-surface-hover disabled:text-text-disabled",Pe=t=>t?"border-danger-border bg-danger-soft":"border-border-strong",me=d.forwardRef(({label:t,helperText:s,error:r,size:n="md",fullWidth:a=!1,startIcon:l,endIcon:o,loading:x=!1,containerClassName:u,labelClassName:j,className:h,id:m,...b},v)=>{const w=d.useId(),g=m||`textfield-${w}`,f=!!r,z=r||s?`${g}-description`:void 0;return e.jsxs("div",{className:i("flex flex-col",a&&"w-full",u),children:[t&&e.jsx("label",{htmlFor:g,className:i(Re,f?"text-danger-fg":"text-text-muted",j),children:t}),e.jsxs("div",{className:"relative",children:[l&&e.jsx("span",{className:"pointer-events-none absolute inset-y-0 left-0 flex items-center pl-3 text-text-muted",children:l}),e.jsx("input",{ref:v,id:g,"aria-invalid":f||void 0,"aria-describedby":z,className:i(Le,Mt[n],l&&"pl-9",(o||x)&&"pr-9",Pe(f),h),...b}),(o||x)&&e.jsx("span",{className:"absolute inset-y-0 right-0 flex items-center pr-3 text-text-muted",children:x?e.jsx("span",{"aria-hidden":!0,className:"size-icon-md animate-spin rounded-full border-2 border-border border-t-transparent"}):o})]}),(r||s)&&e.jsx("p",{id:z,className:i("mt-1 text-xs",f?"text-danger-fg":"text-text-subtle"),children:r||s})]})});me.displayName="TextField";function Fe({value:t,onChange:s,onListFolders:r,disabled:n,size:a="md",placeholder:l,templatePlaceholder:o,showTemplate:x=!0}){const[u,j]=d.useState([]);d.useEffect(()=>{let m=!0;return Promise.resolve(r?.()).then(b=>{m&&b&&j(b.data??[])}).catch(()=>{}),()=>{m=!1}},[]);const h=t??{};return e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsx(he,{size:a,fullWidth:!0,value:h.folderId??"",options:u.map(m=>({value:m.id,label:m.name})),placeholder:l??"Select a folder",onChange:m=>s?.({...h,folderId:m})}),x&&e.jsx(me,{size:a,disabled:n??!1,value:h.pathTemplate??"",placeholder:o??"Sub-path e.g. {yyyy}/{mm}/{dd} (optional)",onChange:m=>s?.({...h,pathTemplate:m.target.value})})]})}const fe=(...t)=>t.filter(Boolean).join(" "),zt=t=>e.jsx(R.Search,{...t,strokeWidth:1.5,"aria-hidden":!0}),Tt=t=>e.jsx(R.ChevronDown,{...t,strokeWidth:1.5,"aria-hidden":!0}),Dt={sm:"h-control-sm px-3 text-sm",md:"h-control-md px-3 text-base",lg:"h-control-lg px-3 text-base",full:"h-control-md w-full px-3 text-base"},ye={sm:"h-4 w-4",md:"h-5 w-5",lg:"h-6 w-6",full:"h-6 w-6"},Ie=d.forwardRef(({label:t,helperText:s,error:r,size:n="md",fullWidth:a=!1,startIcon:l=e.jsx(zt,{}),loading:o=!1,containerClassName:x,labelClassName:u,className:j,id:h,options:m,onRemoteSearch:b,onSelect:v,debounceTime:w=500,showAllOnOpen:g=!1,value:f,onChange:z,...k},V)=>{const D=h||`searchfield-${Math.random().toString(36).substr(2,9)}`,G=!!r,q=d.useRef(null),L=d.useRef(null),[H,ee]=d.useState(f||""),[J,W]=d.useState(!1),[ae,N]=d.useState(!1),[c,C]=d.useState(!1);d.useEffect(()=>{f!==void 0&&ee(f)},[f]);const p=d.useMemo(()=>{if(g&&!c||!H)return m;const P=String(H).toLowerCase();return m.filter(T=>String(T.label).toLowerCase().includes(P))},[H,m,g,c]);d.useEffect(()=>{if(!b||!H){N(!1);return}const P=setTimeout(async()=>{N(!0);try{await b(String(H))}catch(T){console.error("Remote search failed:",T)}finally{N(!1)}},w);return()=>{clearTimeout(P),N(!1)}},[H,w,b]),d.useEffect(()=>{const P=T=>{q.current&&!q.current.contains(T.target)&&W(!1)};return document.addEventListener("mousedown",P),()=>document.removeEventListener("mousedown",P)},[]);const $=P=>{const T=P.target.value;ee(T),W(!0),C(!0),z&&z(P)},y=P=>{ee(P.label),W(!1),C(!1),v&&v(P.value)},U=()=>{(m.length>0||b)&&(W(!0),C(!1))},te=o||ae,Q=J&&(p.length>0||te),X=d.useMemo(()=>V||L,[V]);return e.jsxs("div",{className:fe("flex flex-col",a?"w-full":"",x||"","relative"),ref:q,children:[t&&e.jsx("label",{htmlFor:D,className:fe("block text-sm font-medium mb-1",G?"text-danger-fg":"text-text",u||""),children:t}),e.jsxs("div",{className:"relative",children:[l&&e.jsx("div",{className:"absolute left-0 pl-3 flex items-center pointer-events-none h-full",children:e.jsx("span",{className:fe("text-text-muted",ye[n]),children:l})}),e.jsx("input",{ref:X,id:D,value:H,onChange:$,onFocus:U,className:fe("block w-full rounded-tile border bg-surface-input transition-colors duration-fast ease-out","placeholder:text-text-subtle focus-visible:outline-none focus-visible:focus-ring","disabled:cursor-not-allowed disabled:bg-surface-hover disabled:text-text-disabled",Dt[n],l?"pl-10":"","pr-10",G?"border-danger-border text-danger-fg focus-visible:focus-ring":"border-border-strong text-text",j||""),...k}),e.jsx("div",{className:"absolute inset-y-0 right-0 pr-3 flex items-center",children:te||o?e.jsx(R.Loader2,{className:fe("animate-spin text-info-fg",ye[n]),"aria-hidden":!0}):e.jsx(Tt,{className:fe("text-text-muted cursor-pointer transition-transform",ye[n],J?"rotate-180":"rotate-0"),onClick:()=>{W(P=>(P||C(!1),!P))}})})]}),Q&&e.jsx("ul",{className:"absolute z-10 mt-1 w-full bg-surface border border-border rounded-lg shadow-lg max-h-60 overflow-auto top-full",role:"listbox",children:p.length>0?p.map(P=>e.jsx("li",{className:"px-4 py-2 cursor-pointer text-text hover:bg-accent-soft hover:text-accent transition-colors",onClick:()=>y(P),role:"option","aria-selected":H===P.label,children:P.label},P.value)):e.jsx("li",{className:"px-4 py-2 text-text-muted",children:te||o?"Zoeken op afstand...":"Geen resultaten gevonden."})}),(r||s)&&e.jsx("p",{className:fe("mt-1 text-xs",G?"text-danger-fg":"text-text-muted"),children:r||s}),b&&e.jsxs("p",{className:"mt-2 text-xs text-success-fg",children:["Huidige zoekterm (niet-gedebounced): ",String(H)]})]})});Ie.displayName="SearchableTextField";const Ce=d.forwardRef(({value:t,onValueChange:s,hint:r,size:n="md",clearLabel:a="Clear search",containerClassName:l,className:o,disabled:x,...u},j)=>e.jsxs("div",{className:i("flex items-center gap-2 rounded-md bg-surface-sunk px-2.5 text-text-muted","transition-colors duration-fast ease-out",n==="sm"?"h-control-sm":"h-control-md",x&&"opacity-60",l),children:[e.jsx(Y,{icon:R.Search,size:"md",color:"current",className:"shrink-0"}),e.jsx("input",{ref:j,type:"search",value:t,disabled:x,onChange:h=>s(h.target.value),className:i("min-w-0 flex-1 border-0 bg-transparent p-0 text-sm text-text shadow-none","placeholder:text-text-subtle","focus:border-0 focus:shadow-none focus:outline-none focus:ring-0","[&::-webkit-search-cancel-button]:appearance-none",o),...u}),t?e.jsx("button",{type:"button","aria-label":a,onClick:()=>s(""),className:"grid size-4 shrink-0 cursor-pointer place-items-center rounded-xs text-text-subtle transition-colors duration-fast ease-out hover:text-text focus-visible:outline-none focus-visible:focus-ring",children:e.jsx(Y,{icon:R.X,size:"sm",color:"current"})}):r&&e.jsx("span",{className:"shrink-0 text-xs text-text-subtle",children:r})]}));Ce.displayName="SearchField";const Be=d.forwardRef(({checked:t,onChange:s,label:r,disabled:n=!1,className:a,...l},o)=>{const x=e.jsx("span",{"aria-hidden":!0,className:i("relative inline-flex size-switch-track shrink-0 items-center rounded-full","transition-colors duration-fast ease-out",t?"bg-accent":"bg-surface-hover",n&&"opacity-50"),children:e.jsx("span",{className:i("absolute left-0.5 size-switch-knob rounded-full bg-surface shadow-overlay","transition-transform duration-fast ease-out",t&&"translate-switch")})});return e.jsxs("label",{className:i("inline-flex items-center gap-2",n?"cursor-not-allowed":"cursor-pointer",a),children:[e.jsx("input",{ref:o,type:"checkbox",role:"switch",checked:t,disabled:n,onChange:u=>s(u.target.checked),className:"peer sr-only",...l}),e.jsx("span",{className:"inline-flex rounded-full peer-focus-visible:focus-ring",children:x}),r&&e.jsx("span",{className:"text-sm text-text",children:r})]})});Be.displayName="Switch";function Oe({variant:t="page",children:s,showTableSkeleton:r=!1,tableColumns:n=6,tableRows:a=8}){const l=({children:o})=>t==="inline"?e.jsx(e.Fragment,{children:o}):e.jsx("main",{className:"flex-1 bg-surface p-6",children:o});return s?e.jsx(l,{children:e.jsx("div",{className:"w-full max-w-6xl mx-auto animate-pulse",children:s})}):e.jsx(l,{children:e.jsxs("div",{className:"w-full mx-auto space-y-6 animate-pulse",children:[!r&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"h-6 w-1/4 rounded-sm bg-surface-hover"}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("div",{className:"h-4 w-3/4 rounded-sm bg-surface-hover"}),e.jsx("div",{className:"h-4 w-1/2 rounded-sm bg-surface-hover"})]})]}),r&&e.jsxs("div",{className:"rounded-lg overflow-hidden",children:[e.jsx("div",{className:"grid gap-2 bg-surface-hover p-3",style:{gridTemplateColumns:`repeat(${n}, minmax(0, 1fr))`},children:Array.from({length:n}).map((o,x)=>e.jsx("div",{className:"h-4 w-2/3 rounded-sm bg-border-strong"},`header-${x}`))}),Array.from({length:a}).map((o,x)=>e.jsx("div",{className:"grid gap-2 border-t border-border-subtle p-3",style:{gridTemplateColumns:`repeat(${n}, minmax(0, 1fr))`},children:Array.from({length:n}).map((u,j)=>e.jsx("div",{className:"h-4 w-full rounded-sm bg-surface-hover"},`cell-${x}-${j}`))},`row-${x}`))]})]})})}const He=({trigger:t,options:s,value:r,onSelect:n,placement:a="bottom-start",disabled:l=!1,className:o,showCheck:x=!0,header:u})=>{const[j,h]=d.useState(!1),[m,b]=d.useState(null),[v,w]=d.useState({top:0,left:0}),g=d.useRef(null),f=d.useRef(null),z=d.useRef(null),k=d.useRef(null),V=ve(j,f,{placement:a}),D=d.useRef(null),G=()=>Array.from(k.current?.querySelectorAll("button[data-option-value]:not(:disabled)")??[]);d.useEffect(()=>{j&&G()[0]?.focus()},[j]);const q=c=>{if(!["ArrowDown","ArrowUp","Home","End"].includes(c.key))return;const p=G();if(p.length===0)return;c.preventDefault();const $=p.indexOf(document.activeElement),y=c.key==="Home"?0:c.key==="End"?p.length-1:c.key==="ArrowDown"?($+1)%p.length:($-1+p.length)%p.length;p[y]?.focus()};d.useEffect(()=>{const c=C=>{g.current&&(!g.current.contains(C.target)||z.current&&!z.current.contains(C.target))&&(h(!1),b(null),D.current&&(clearTimeout(D.current),D.current=null))};return j&&document.addEventListener("mousedown",c),()=>{document.removeEventListener("mousedown",c)}},[j]),d.useEffect(()=>{const c=C=>{C.key==="Escape"&&(h(!1),b(null),f.current?.focus(),D.current&&(clearTimeout(D.current),D.current=null))};return j&&document.addEventListener("keydown",c),()=>{document.removeEventListener("keydown",c)}},[j]),d.useEffect(()=>{if(m&&g.current){const c=g.current.querySelector(`[data-option-value="${m}"]`);if(c){const C=c.getBoundingClientRect();w({top:C.top,left:C.right+8})}}},[m]),d.useEffect(()=>()=>{D.current&&clearTimeout(D.current)},[]);const L=c=>{c.stopPropagation(),!l&&(h(!j),b(null),D.current&&(clearTimeout(D.current),D.current=null))},H=(c,C,p)=>{c.stopPropagation(),!C.disabled&&!C.divider&&(!C.children||C.children.length===0)&&(n?.(C.value,p),h(!1),b(null))},ee=c=>{D.current&&(clearTimeout(D.current),D.current=null),c.children&&c.children.length>0?b(c.value):b(null)},J=c=>{c.children&&c.children.length>0?D.current=setTimeout(()=>{b(null)},150):b(null)},W=(c,C,p)=>{c.stopPropagation(),!C.disabled&&!C.divider&&(n?.(C.value,p),h(!1),b(null))},ae=i("fixed z-overlay min-w-menu bg-surface rounded-lg shadow-overlay border border-border","max-h-60 overflow-auto"),N=i("fixed z-overlay min-w-menu bg-surface rounded-lg shadow-overlay border border-border","max-h-60 overflow-auto");return e.jsxs("div",{ref:g,className:i("relative flex flex-row items-center justify-center rounded-lg hover:bg-surface-hover",o),children:[e.jsx("button",{ref:f,onClick:L,disabled:l,"aria-haspopup":"menu","aria-expanded":j,className:i("inline-flex items-center justify-center",{"opacity-50 cursor-not-allowed":l}),children:t}),j&&e.jsx("div",{ref:k,className:ae,style:V,onKeyDown:q,children:e.jsxs("div",{className:"p-2",role:"menu",children:[u&&(typeof u=="string"?e.jsx("div",{className:"text-xs font-medium text-text-muted uppercase tracking-label px-3 py-2",children:u}):u),s.map((c,C)=>{if(c.divider)return e.jsx("div",{className:"border-t border-border my-2"},`divider-${C}`);const p=c.children&&c.children.length>0,$=m===c.value;return e.jsxs("div",{className:"relative group",children:[e.jsxs("button",{"data-option-value":c.value,role:"menuitem","aria-haspopup":p?"menu":void 0,onClick:y=>H(y,c),onMouseEnter:()=>ee(c),onMouseLeave:()=>J(c),disabled:c.disabled,className:i("flex w-full items-center justify-between rounded-md px-3 py-1.5 text-sm text-text transition-colors duration-fast ease-out hover:bg-surface-hover focus-visible:outline-none focus-visible:focus-ring",{"opacity-50 cursor-not-allowed":c.disabled,"bg-surface-hover":$&&p}),children:[e.jsxs("div",{className:"flex items-center space-x-2 min-w-0",children:[c.icon&&e.jsx("span",{className:"flex-shrink-0",children:c.icon}),e.jsxs("div",{className:"flex flex-col items-start min-w-0",children:[e.jsx("span",{className:"font-base truncate",children:c.label}),c.description&&e.jsx("span",{className:"text-xs text-text-muted",children:c.description})]})]}),e.jsxs("div",{className:"flex items-center space-x-2",children:[x&&r===c.value&&e.jsx(R.Check,{className:"size-icon-md shrink-0 text-success-fg","aria-hidden":!0}),p&&e.jsx("span",{className:"text-text-muted text-xs",children:"▶"})]})]}),p&&$&&e.jsx("div",{ref:z,className:N,style:{top:`${v.top}px`,left:`${v.left}px`},onMouseEnter:()=>{D.current&&(clearTimeout(D.current),D.current=null),b(c.value)},onMouseLeave:()=>{D.current=setTimeout(()=>{b(null)},150)},children:e.jsx("div",{className:"p-2",children:c.children.map((y,U)=>{if(y.divider)return e.jsx("div",{className:"border-t border-border my-2"},`divider-${U}`);const te=typeof r=="object"&&r[c.value]&&r[c.value].includes(y.value)||r===y.value;return e.jsxs("button",{onClick:Q=>W(Q,y,c.value),disabled:y.disabled,className:i("flex w-full items-center justify-between rounded-md px-3 py-1.5 text-sm text-text transition-colors duration-fast ease-out hover:bg-surface-hover",{"opacity-50 cursor-not-allowed":y.disabled}),children:[e.jsxs("div",{className:"flex items-center space-x-2 min-w-0",children:[y.icon&&e.jsx("span",{className:"flex-shrink-0",children:y.icon}),e.jsxs("div",{className:"flex flex-col items-start min-w-0",children:[e.jsx("span",{className:"font-base truncate",children:y.label}),y.description&&e.jsx("span",{className:"text-xs text-text-muted",children:y.description})]})]}),x&&te&&e.jsx(R.Check,{className:"size-icon-md shrink-0 text-success-fg","aria-hidden":!0})]},y.value)})})})]},c.value)}),(()=>{const c=s.reduce((C,p)=>{if(p.divider)return C;const $=p.children?p.children.filter(y=>!y.divider).length:0;return C+1+$},0);return c>1&&e.jsx("div",{className:"border-t border-border mt-2 pt-2",children:e.jsxs("div",{className:"text-xs text-text-muted px-3 py-1",children:[c," options available"]})})})()]})})]})},Se=({actions:t,defaultVariant:s="secondary",className:r})=>t.length===0?null:e.jsx("div",{className:i("flex flex-wrap items-center gap-2",r),children:t.map(n=>n.render?e.jsx(d.Fragment,{children:n.render()},n.id):n.splitOptions&&n.splitOptions.length>0?e.jsx(ke,{label:n.label,onClick:n.onClick,icon:n.icon,variant:n.variant==="primary"?"primary":"secondary",options:n.splitOptions,disabled:n.disabled},n.id):e.jsx(re,{variant:n.variant??s,onClick:a=>{a.stopPropagation(),a.target.blur(),n.onClick()},disabled:n.disabled,leftIcon:n.icon,children:n.label},n.id))}),$t={none:"p-0",sm:"p-2",md:"px-5 py-4",lg:"p-6"},At=({actions:t=[],onBack:s,backLabel:r="Back",className:n,padding:a="md",children:l})=>e.jsxs("div",{className:i("flex items-center gap-2",$t[a],n),children:[s&&e.jsx(re,{variant:"secondary",onClick:s,"aria-label":r,leftIcon:e.jsx(Y,{icon:R.ChevronLeft,size:"sm"}),iconOnly:!0}),l&&e.jsx("div",{className:"min-w-0 flex-1",children:l}),e.jsx(Se,{actions:t,className:i(!l&&"ml-auto")})]}),_t=t=>s=>t(s instanceof Date?s:null),Rt=t=>s=>t(typeof s=="string"?s:""),Lt={none:"px-0",sm:"px-2",md:"px-3.5",lg:"px-5"},Pt={sm:"h-row-lg",md:"h-row-xl",lg:"h-14"};function Ft(t,s){if(s<=7)return Array.from({length:s},(l,o)=>o);const n=[...new Set([0,s-1,t-1,t,t+1])].filter(l=>l>=0&&l<s).sort((l,o)=>l-o),a=[];return n.forEach((l,o)=>{o>0&&l-n[o-1]>1&&a.push("gap"),a.push(l)}),a}const It=t=>{const s=Array.isArray(t.value)?t.value:t.value!=null&&t.value!==""&&t.value!=="all"?[t.value]:[];if(t.type==="date"){const o=t.value instanceof Date;return e.jsx(ge,{value:t.value,onChange:x=>t.onChange(x),placeholder:t.placeholder||t.label,className:i("min-w-40",o&&"bg-info-soft text-info-fg")})}const r=o=>t.options?.find(x=>x.value===o)?.label??String(o),n=o=>Array.isArray(t.value)?t.value.includes(o):t.value===o,a=o=>{if(!t.multiSelect)return t.onChange(o);const x=Array.isArray(t.value)?t.value:[];t.onChange(x.includes(o)?x.filter(u=>u!==o):[...x,o])},l=s.length>0;return e.jsx(Ae,{tone:"outline",caret:!0,icon:t.icon,active:l,label:l?`${t.label}: ${s.map(r).join(", ")}`:t.label,title:t.label,onClear:()=>t.onChange(t.multiSelect?[]:"all"),menu:o=>e.jsx("div",{role:"listbox",className:"flex flex-col",children:t.options?.map(x=>e.jsx("button",{type:"button",role:"option","aria-selected":n(x.value),onClick:()=>{a(x.value),t.multiSelect||o()},className:i("flex cursor-pointer items-center gap-2 rounded-md px-2.5 py-1.5 text-left text-sm","transition-colors duration-fast ease-out hover:bg-surface-hover","focus-visible:outline-none focus-visible:focus-ring",n(x.value)?"font-medium text-text":"text-text-muted"),children:x.label},x.value))})})},Ne=({data:t,columns:s,loading:r=!1,searchable:n=!1,searchPlaceholder:a="Search...",searchValue:l,onSearchChange:o,filters:x=[],toolbarActions:u=[],paginated:j=!1,defaultPageSize:h=10,actions:m=[],onRowClick:b,selectable:v=!1,selectedRows:w=[],onSelectionChange:g,getRowKey:f=(ee,J)=>J,emptyContent:z,footerSummary:k,size:V="md",hoverable:D=!0,padding:G="md",className:q,rowClassName:L,headerBackground:H=!0})=>{const[ee,J]=d.useState(""),W=l!==void 0,ae=W?l:ee,N=o??J,[c,C]=d.useState({column:null,direction:null}),[p,$]=d.useState({page:0,pageSize:h}),y=d.useRef(null),U=d.useMemo(()=>{let S=t;if(n&&!W&&ae.trim()){const K=s.filter(le=>le.searchable!==!1),ne=ae.toLowerCase();S=S.filter(le=>K.some(O=>{const ce=typeof O.accessor=="function"?O.accessor(le):le[O.accessor];return String(ce||"").toLowerCase().includes(ne)}))}return x.forEach(K=>{K.value&&K.value!=="all"&&(S=S.filter(ne=>{const le=s.find(ce=>ce.id===K.id);if(!le)return!0;const O=typeof le.accessor=="function"?le.accessor(ne):ne[le.accessor];return String(O||"")===K.value}))}),S},[t,ae,W,s,n,x]),te=d.useMemo(()=>{if(!c.column||!c.direction)return U;const S=s.find(K=>K.id===c.column);return S?[...U].sort((K,ne)=>{const le=typeof S.accessor=="function"?S.accessor(K):K[S.accessor],O=typeof S.accessor=="function"?S.accessor(ne):ne[S.accessor];let ce=0;return le<O?ce=-1:le>O&&(ce=1),c.direction==="desc"?-ce:ce}):U},[U,c,s]),Q=d.useMemo(()=>{if(!j)return te;const S=p.page*p.pageSize,K=S+p.pageSize;return te.slice(S,K)},[te,p,j]),X=d.useCallback(S=>{s.find(ne=>ne.id===S)?.sortable&&C(ne=>ne.column!==S?{column:S,direction:"asc"}:ne.direction==="asc"?{column:S,direction:"desc"}:{column:null,direction:null})},[s]),P=d.useCallback(S=>{$(K=>({...K,page:S}))},[]),T=d.useCallback((S,K)=>{if(!g)return;const ne=f(S,0);g(K?[...w,S]:w.filter((le,O)=>f(w[O],O)!==ne))},[w,g,f]),A=d.useCallback(S=>{g&&g(S?[...Q]:[])},[Q,g]);d.useEffect(()=>{$(S=>({...S,page:0}))},[ae,c]),d.useEffect(()=>{$(S=>({...S,page:0}))},[x.map(S=>S.value).join(",")]);const E=te.length,I=Math.ceil(E/p.pageSize),F=p.page*p.pageSize+1,B=Math.min(F+p.pageSize-1,E),M=Q.length>0&&Q.every(S=>{const K=f(S,0);return w.some((ne,le)=>f(ne,le)===K)}),_=Q.some(S=>{const K=f(S,0);return w.some((ne,le)=>f(ne,le)===K)}),Z=Lt[G],se=H?"bg-surface-sunk":"bg-surface",oe=i("text-text",Z),ue=n||x.length>0||u.length>0,de=j&&E>0,je=de||k!==void 0;return e.jsxs("div",{className:i("flex min-w-0 flex-col",q),children:[ue&&e.jsxs("div",{className:"flex flex-wrap items-center gap-2 pb-3",children:[n&&e.jsx(Ce,{value:ae,onValueChange:N,placeholder:a,containerClassName:"w-full sm:w-66"}),x.map(S=>e.jsx(It,{...S},S.id)),u.length>0&&e.jsx(Se,{actions:u,className:"ml-auto"})]}),e.jsxs("div",{className:"relative w-full overflow-x-auto rounded-lg ring-1 ring-border",children:[r&&e.jsx("div",{className:"flex items-center justify-center",children:e.jsx(Oe,{showTableSkeleton:!0,tableRows:10,tableColumns:s.length})}),e.jsxs("table",{ref:y,className:"min-w-full border-collapse text-base text-text",children:[e.jsx("thead",{className:i(se,"h-control-lg"),children:e.jsxs("tr",{children:[v&&e.jsx("th",{className:i(oe,"w-10"),children:e.jsx(xe,{size:"sm",checked:M,indeterminate:_&&!M,onChange:S=>A(S.target.checked),"aria-label":"Select all rows"})}),!r&&s.map(S=>e.jsx("th",{className:i(oe,"text-xs font-semibold uppercase tracking-label text-text-muted","group",{"text-left":S.align==="left"||!S.align,"text-center":S.align==="center","text-right":S.align==="right","cursor-pointer select-none":S.sortable,[`sticky left-0 ${se}`]:S.sticky==="left",[`sticky right-0 ${se}`]:S.sticky==="right"}),style:{width:S.width},onClick:()=>S.sortable&&X(S.id),children:e.jsxs("div",{className:"flex items-center gap-1.5",children:[S.headerCell?S.headerCell():S.header,S.sortable&&e.jsx(Y,{icon:c.column===S.id&&c.direction==="desc"?R.ChevronDown:R.ChevronUp,size:"xs",className:i("transition-opacity duration-fast ease-out",c.column===S.id?"text-text opacity-100":"text-text-subtle opacity-0 group-hover:opacity-100")})]})},S.id)),m.length>0&&e.jsx("th",{className:i(oe,"w-10"),children:e.jsx("span",{className:"sr-only",children:"Actions"})})]})}),e.jsx("tbody",{children:Q.length===0||r?!r&&e.jsx("tr",{children:e.jsx("td",{colSpan:s.length+(v?1:0)+(m.length>0?1:0),className:i(oe,"border-t border-border-subtle py-10 text-center text-text-muted"),children:z||"No data available"})}):Q.map((S,K)=>{const ne=f(S,K),le=w.some((O,ce)=>f(O,ce)===ne);return e.jsxs("tr",{className:i(Pt[V],"border-t border-border-subtle",D&&"transition-colors duration-fast ease-out hover:bg-surface-hover",b&&"cursor-pointer",le&&"bg-accent-soft",L?.(S,K)),onClick:O=>{O.stopPropagation(),b?.(S,K)},children:[v&&e.jsx("td",{className:oe,children:e.jsx(xe,{size:"sm",checked:le,onClick:O=>O.stopPropagation(),onChange:O=>{O.stopPropagation(),T(S,O.target.checked)},"aria-label":"Select row"})}),s.map(O=>{const ce=typeof O.accessor=="function"?O.accessor(S):S[O.accessor];return e.jsx("td",{className:i(oe,{"text-left":O.align==="left"||!O.align,"text-center":O.align==="center","text-right":O.align==="right","sticky left-0 bg-surface":O.sticky==="left","sticky right-0 bg-surface":O.sticky==="right"}),children:O.cell?O.cell(ce,S,K):String(ce||"")},O.id)}),m.length>0&&e.jsx("td",{className:oe,children:e.jsx(He,{className:"rounded-md",trigger:e.jsx("span",{className:"grid size-7 place-items-center text-text-subtle",children:e.jsx(Y,{icon:R.Ellipsis,size:"md",color:"current"})}),options:m.map(O=>({value:O.id,label:O.label,icon:O.icon,disabled:O.disabled?.(S)})),onSelect:O=>{const ce=m.find(Ge=>Ge.id===O);ce&&ce.onClick(S,K)},placement:"bottom-end"})})]},ne)})})]})]}),je&&e.jsxs("div",{className:"flex flex-wrap items-center gap-3 px-1 pt-3 text-xs text-text-muted",children:[e.jsx("span",{className:"min-w-0 flex-1",children:k??`Showing ${F}–${B} of ${E}`}),de&&e.jsxs("div",{className:"flex items-center gap-0.5",children:[e.jsx(re,{size:"xs",variant:"ghost",iconOnly:!0,"aria-label":"Previous page",onClick:()=>P(p.page-1),disabled:p.page===0,children:e.jsx(Y,{icon:R.ChevronLeft,size:"md",color:"current"})}),Ft(p.page,I).map((S,K)=>S==="gap"?e.jsx("span",{className:"px-1 text-text-subtle",children:"…"},`gap-${K}`):e.jsx("button",{type:"button","aria-current":S===p.page?"page":void 0,onClick:()=>P(S),className:i("h-control-xs min-w-6 cursor-pointer rounded-sm px-1.5 tabular-nums","transition-colors duration-fast ease-out","focus-visible:outline-none focus-visible:focus-ring",S===p.page?"bg-surface-sunk font-semibold text-text":"text-text-muted hover:bg-surface-hover hover:text-text"),children:S+1},S)),e.jsx(re,{size:"xs",variant:"ghost",iconOnly:!0,"aria-label":"Next page",onClick:()=>P(p.page+1),disabled:p.page>=I-1,children:e.jsx(Y,{icon:R.ChevronRight,size:"md",color:"current"})})]})]})]})},Bt=d.createContext(null),Ot=({items:t,activeTab:s,onTabChange:r,className:n})=>{const[a,l]=d.useState(t[0]?.id||""),o=s||a,x=u=>{r?r(u):l(u)};return e.jsx("div",{className:i("border-b border-border",n),children:e.jsx("nav",{className:"-mb-px flex space-x-8",children:t.map(u=>e.jsx("button",{onClick:()=>!u.disabled&&x(u.id),disabled:u.disabled,className:i("border-b-2 py-2 px-1 text-sm font-medium transition-colors duration-fast",{"border-accent-border text-text":o===u.id,"border-transparent text-text-muted hover:text-text":o!==u.id&&!u.disabled,"border-transparent text-disabled cursor-not-allowed":u.disabled}),children:e.jsxs("span",{className:"flex items-center gap-2",children:[u.label,u.badge&&e.jsx("span",{className:i("inline-flex items-center px-2 py-0.5 rounded-full text-xs font-medium",o===u.id?"bg-accent-soft text-accent":"bg-surface-hover text-text-muted"),children:u.badge})]})},u.id))})})},qe=({items:t,defaultTab:s,activeTab:r,onTabChange:n,variant:a="default",size:l="md",className:o})=>{const[x,u]=d.useState(s||r||t[0]?.id||""),j=r||x,h=g=>{n?n(g):u(g)},m={activeTab:j,setActiveTab:h},b=t.find(g=>g.id===j),v=i("flex",{"border-b border-border px-2":a==="default"||a==="underline","bg-surface-hover p-1 rounded-lg":a==="pills","space-x-1":a==="pills","space-x-8":a==="default"||a==="underline"},o),w=(g,f)=>{const z="transition-colors duration-fast font-medium",k={"text-xs px-2 py-1":l==="sm","text-sm px-3 py-2":l==="md","text-base px-4 py-3":l==="lg"},V={"border-b-2 -mb-px":a==="default","rounded-md":a==="pills","border-b-2 pb-2":a==="underline"},D={"opacity-50 cursor-not-allowed":g.disabled,"cursor-pointer":!g.disabled},G=f?{"border-accent-border text-text":a==="default"||a==="underline","bg-surface text-text shadow-none":a==="pills"}:{},q=!f&&!g.disabled?{"border-transparent text-text-muted hover:text-text":a==="default","text-text-muted hover:text-text":a==="pills","border-transparent text-text-muted hover:text-text hover:border-border":a==="underline"}:{};return i(z,k,V,D,G,q)};return e.jsx(Bt.Provider,{value:m,children:e.jsxs("div",{children:[e.jsx("div",{className:v,role:"tablist",children:t.map(g=>e.jsx("button",{type:"button",role:"tab","aria-selected":j===g.id,"aria-controls":`tabpanel-${g.id}`,disabled:g.disabled,onClick:()=>!g.disabled&&h(g.id),className:w(g,j===g.id),children:e.jsxs("span",{className:"flex items-center gap-2",children:[g.label,g.badge&&e.jsx("span",{className:"inline-flex items-center px-2 py-0.5 rounded-full text-xs font-medium bg-surface-hover text-text-muted",children:g.badge})]})},g.id))}),b?.content&&e.jsx("div",{role:"tabpanel",id:`tabpanel-${j}`,"aria-labelledby":`tab-${j}`,className:"mt-4",children:b.content})]})})},Ht={sm:"max-w-md",md:"max-w-lg",lg:"max-w-2xl",xl:"max-w-4xl",full:"max-w-full mx-4"};function Ee({open:t,onClose:s,title:r,size:n="md",closeOnBackdropClick:a=!0,closeOnEscape:l=!0,className:o,backdropClassName:x,children:u,footer:j,showCloseButton:h=!0}){const m=d.useRef(null),b=d.useRef(null);d.useEffect(()=>{if(!t||!l)return;const w=g=>{g.key==="Escape"&&s()};return document.addEventListener("keydown",w),()=>document.removeEventListener("keydown",w)},[t,l,s]),d.useEffect(()=>(t?(b.current=document.activeElement,m.current&&m.current.focus(),document.body.style.overflow="hidden"):(b.current&&b.current.focus(),document.body.style.overflow=""),()=>{document.body.style.overflow=""}),[t]);const v=w=>{a&&w.target===w.currentTarget&&s()};return t?e.jsx("div",{className:i("fixed inset-0 z-modal flex items-center justify-center p-4","bg-scrim",x),onClick:v,children:e.jsxs("div",{ref:m,className:i("relative w-full bg-surface rounded-lg shadow-modal","focus:outline-none",Ht[n],o),role:"dialog","aria-modal":"true","aria-labelledby":r?"modal-title":void 0,tabIndex:-1,children:[(r||h)&&e.jsxs("div",{className:"flex items-center justify-between p-6 pb-0",children:[r&&e.jsx("span",{id:"modal-title",className:"text-lg font-semibold text-text",children:r}),h&&e.jsx("button",{onClick:s,className:"p-1 text-text-muted hover:text-text transition-colors","aria-label":"Close modal",children:e.jsx(Y,{icon:R.X,size:"lg",color:"current"})})]}),e.jsx("div",{className:"p-6",children:u}),j&&e.jsx("div",{className:"px-6 py-4",children:j})]})}):null}const qt={xs:"text-xs",sm:"text-sm",md:"text-base",lg:"text-md",xl:"text-lg"},Vt={light:"font-normal",normal:"font-normal",medium:"font-medium",semibold:"font-semibold",bold:"font-bold"},Ut={primary:"text-text",secondary:"text-text-muted",accent:"text-accent",success:"text-success-fg",warning:"text-warning-fg",error:"text-danger-fg",info:"text-info-fg",neutral:"text-text",current:"text-current",muted:"text-text-subtle"},Kt={left:"text-left",center:"text-center",right:"text-right",justify:"text-justify"},Wt={tight:"leading-tight",normal:"leading-normal",relaxed:"leading-relaxed"},ie=({variant:t="body",size:s="md",weight:r="normal",color:n="current",align:a="left",truncate:l=!1,italic:o=!1,underline:x=!1,lineHeight:u="normal",as:j,className:h,children:m,...b})=>{const v=j||Gt(t),w=t==="caption",g=t==="label",f=t==="code",z=i("font-sans",w&&"text-xs text-text-subtle",g&&"text-xs font-semibold uppercase tracking-label text-text-subtle",f&&"font-mono text-sm rounded-sm bg-surface-hover px-1 py-0.5",!w&&!g&&!f&&qt[s],!g&&Vt[r],Ut[n],Kt[a],t==="body"&&Wt[u],o&&"italic",x&&"underline",l&&"truncate",h);return e.jsx(v,{className:z,...b,children:m})};function Gt(t){return{body:"p",caption:"span",label:"span",code:"code"}[t]||"p"}const Ve=({value:t,onChange:s,label:r,placeholder:n="Select or upload a file",error:a,disabled:l,accept:o,onListFiles:x,onListMounts:u,onUploadFile:j,onDownloadFile:h,onRegisterFile:m})=>{const[b,v]=d.useState(!1),[w,g]=d.useState([]),[f,z]=d.useState(null),[k,V]=d.useState("/"),[D,G]=d.useState([]),[q,L]=d.useState(!1),[H,ee]=d.useState(""),[J,W]=d.useState(typeof t=="object"?t:null),[ae,N]=d.useState(!1),[c,C]=d.useState(""),p=d.useRef(null);d.useEffect(()=>{b&&$()},[b]),d.useEffect(()=>{b&&f&&y()},[b,f,k,H]);const $=async()=>{L(!0);try{const M=await u?.();M?.data&&g(M.data)}catch(M){console.error("Failed to load mounts",M)}finally{L(!1)}},y=async()=>{if(f){L(!0);try{const M=await x?.({mountId:f.id,name:H,path:k});M?.data&&G(M.data)}catch(M){console.error("Failed to load files",M)}finally{L(!1)}}},U=async M=>{const _=M.target.files?.[0];if(_){L(!0);try{const Z=await _.arrayBuffer(),se=new Uint8Array(Z),oe={id:`local-${Date.now()}`,name:_.name,type:"file",path:"/",mimeType:_.type||"application/octet-stream",size:_.size,mountId:"local",providerKey:_.name,ownerId:"me"};W(oe),s(oe,se),v(!1)}catch(Z){console.error("Local file selection failed",Z)}finally{L(!1)}}},te=async M=>{const _=M.target.files?.[0];if(!(!_||!f)){L(!0);try{const Z=await _.arrayBuffer(),se=await j?.({file:new Uint8Array(Z),filename:_.name,mimeType:_.type||"application/octet-stream",mountId:f.id,path:k});if(se?.data){const oe=se.data;W(oe),s(oe,new Uint8Array(Z)),v(!1)}}catch(Z){console.error("Upload failed",Z)}finally{L(!1)}}},Q=async()=>{if(!(!c||!f)){L(!0);try{const M=`${k}${c}/`;m&&(await m({name:c,type:"folder",path:k,mimeType:"application/x-directory",size:0,mountId:f.id,providerKey:M,ownerId:"me"}),await y()),N(!1),C("")}catch(M){console.error("Failed to create folder",M)}finally{L(!1)}}},X=async M=>{L(!0);try{const _=await h?.(M.id);W(M),s(M,_),v(!1)}catch(_){console.error("Failed to download file",_)}finally{L(!1)}},P=M=>{M.stopPropagation(),W(null),s(null)},T=d.useMemo(()=>{const M=new Set,_=[];return D.forEach(Z=>{if(Z.type==="folder"){Z.path===k&&M.add(Z.name);return}const se=Z.providerKey||Z.name,ue=(k?se.substring(k.length):se).split("/").filter(de=>de!=="");ue.length>1?M.add(ue[0]):ue.length===1&&_.push(Z)}),{folders:Array.from(M).sort(),files:_.sort((Z,se)=>Z.name.localeCompare(se.name))}},[D,k]),A=M=>{V(_=>`${_}${M}/`)},E=()=>{const M=k.split("/").filter(_=>_!=="");M.pop(),M.length===0?V("/"):V(`${M.join("/")}/`)},I=d.useMemo(()=>{const M=T.folders.map(_=>({id:`folder-${_}`,name:_,type:"folder"}));return T.files.forEach(_=>{M.push({..._,type:"file"})}),M},[T]),F=[{id:"name",header:"Name",accessor:"name",cell:(M,_)=>e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Y,{icon:_.type==="folder"?R.Folder:R.FileText,size:"sm",color:_.type==="folder"?"warning":"secondary"}),e.jsx("span",{className:i(_.type==="folder"&&"font-medium"),children:M})]})},{id:"type",header:"Type",accessor:M=>M.type==="folder"?"Folder":M.mimeType},{id:"size",header:"Size",accessor:M=>M.type==="file"?`${(M.size/1024).toFixed(1)} KB`:"-"},{id:"actions",header:"",accessor:"id",align:"right",cell:(M,_)=>e.jsx(re,{variant:"outline",onClick:Z=>{Z.stopPropagation(),_.type==="folder"?A(_.name):X(_)},loading:q&&_.type==="file"&&J?.id===_.id,children:_.type==="folder"?"Open":"Select"})}],B=[{id:"name",header:"Mount Name",accessor:"name",cell:M=>e.jsxs("div",{className:"flex items-center gap-2 font-medium",children:[e.jsx(Y,{icon:R.HardDrive,size:"sm",color:"primary"}),e.jsx("span",{children:M})]})},{id:"actions",header:"",accessor:"id",align:"right",cell:(M,_)=>e.jsx(re,{variant:"outline",onClick:()=>z(_),children:"Open"})}];return e.jsxs("div",{className:"space-y-1",children:[r&&e.jsx(ie,{variant:"label",size:"sm",weight:"medium",children:r}),e.jsxs("div",{onClick:()=>!l&&v(!0),className:i("flex items-center gap-3 px-3 py-2 border rounded-lg cursor-pointer transition-colors","hover:border-border-strong bg-surface",a?"border-danger-border":"border-border",l&&"opacity-50 cursor-not-allowed bg-surface-sunk"),children:[e.jsx("div",{className:"flex-shrink-0",children:e.jsx(Y,{icon:J?R.FileText:R.HardDrive,color:J?"primary":"secondary"})}),e.jsx("div",{className:"flex-grow truncate",children:J?e.jsx("span",{className:"text-sm text-text font-medium",children:J.name}):e.jsx("span",{className:"text-sm text-text-muted",children:n})}),J&&!l&&e.jsx("button",{onClick:P,className:"p-1 hover:bg-surface-hover rounded",children:e.jsx(Y,{icon:R.X,size:"xs"})})]}),a&&e.jsx(ie,{variant:"body",size:"xs",className:"text-danger-fg",children:a}),e.jsx(Ee,{open:b,onClose:()=>{v(!1),z(null),V("/"),N(!1)},title:f?`Explorer: ${f.name}`:"Select Storage Mount",size:"lg",children:e.jsx(qe,{variant:"pills",items:[{id:"remote",label:"Platform Storage",content:e.jsx("div",{className:"space-y-4",children:f?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx(re,{variant:"ghost",onClick:()=>{k&&k!=="/"?E():z(null)},leftIcon:e.jsx(Y,{icon:R.ArrowLeft,size:"xs"}),children:k?"Back":"Back to Mounts"}),e.jsx("div",{className:"flex items-center gap-1 text-xs text-text-muted overflow-hidden bg-surface-hover px-2 py-1 rounded",children:e.jsx("span",{className:"truncate",children:k})}),e.jsx("div",{className:"flex-grow min-w-40",children:e.jsx(me,{placeholder:"Search...",value:H,onChange:M=>ee(M.target.value),startIcon:e.jsx(R.Search,{size:14}),fullWidth:!0})}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(re,{variant:"outline",onClick:()=>N(!0),leftIcon:e.jsx(Y,{icon:R.FolderPlus,size:"xs"}),children:"New Folder"}),e.jsx(re,{variant:"primary",onClick:()=>p.current?.click(),leftIcon:e.jsx(Y,{icon:R.Upload,size:"xs"}),loading:q,children:"Upload"}),e.jsx("input",{type:"file",className:"hidden",ref:p,onChange:te,accept:o})]})]}),ae&&e.jsxs("div",{className:"flex items-center gap-2 p-3 bg-surface-sunk rounded-lg border border-border",children:[e.jsx(Y,{icon:R.Folder,size:"sm",color:"warning"}),e.jsx(me,{placeholder:"Folder name",value:c,onChange:M=>C(M.target.value),autoFocus:!0}),e.jsx(re,{onClick:Q,loading:q,children:"Create"}),e.jsx(re,{variant:"ghost",onClick:()=>N(!1),children:"Cancel"})]}),e.jsx("div",{className:"max-h-100 overflow-auto rounded-lg border border-border",children:e.jsx(Ne,{data:I,columns:F,loading:q,emptyContent:"This folder is empty",onRowClick:M=>M.type==="folder"?A(M.name):X(M)})})]}):e.jsx("div",{className:"max-h-100 overflow-auto rounded-lg border border-border",children:e.jsx(Ne,{data:w,columns:B,loading:q,emptyContent:"No storage mounts configured",onRowClick:M=>z(M)})})})},{id:"local",label:"Local File",content:e.jsx("div",{className:"space-y-6",children:e.jsxs("div",{className:"flex flex-col items-center justify-center py-12 border-2 border-dashed border-border rounded-xl bg-surface-sunk/50",children:[e.jsx("div",{className:"p-4 bg-accent-soft rounded-full mb-4",children:e.jsx(Y,{icon:R.FileText,size:"xl",color:"primary"})}),e.jsx(ie,{variant:"label",size:"lg",weight:"semibold",children:"Select a file from your computer"}),e.jsxs(ie,{variant:"body",size:"sm",className:"text-text-muted mt-1 mb-6 text-center max-w-xs",children:["This file will be used directly in the form and will ",e.jsx("strong",{children:"not"})," be uploaded to platform storage."]}),e.jsxs("label",{className:"cursor-pointer",children:[e.jsx(re,{variant:"primary",size:"lg",loading:q,className:"pointer-events-none",children:"Browse Local File"}),e.jsx("input",{type:"file",className:"hidden",onChange:U,accept:o,disabled:q})]})]})})}]})})]})},Jt={sm:"px-3 py-1.5 text-sm",md:"px-3 py-2 text-base",lg:"px-3 py-2 text-md",full:"px-3 py-2 text-md"},pe=d.forwardRef(({label:t,helperText:s,error:r,size:n="md",fullWidth:a=!1,loading:l=!1,containerClassName:o,labelClassName:x,className:u,id:j,rows:h=4,...m},b)=>{const v=d.useId(),w=j||`textarea-${v}`,g=!!r,f=r||s?`${w}-description`:void 0;return e.jsxs("div",{className:i("flex flex-col",a&&"w-full",o),children:[t&&e.jsx("label",{htmlFor:w,className:i(Re,g?"text-danger-fg":"text-text-muted",x),children:t}),e.jsxs("div",{className:"relative",children:[e.jsx("textarea",{ref:b,id:w,rows:h,"aria-invalid":g||void 0,"aria-describedby":f,className:i(Le,"resize-y leading-relaxed",Jt[n],Pe(g),u),...m}),l&&e.jsx("span",{"aria-hidden":!0,className:"absolute top-2 right-3 size-icon-md animate-spin rounded-full border-2 border-border border-t-transparent"})]}),(r||s)&&e.jsx("p",{id:f,className:i("mt-1 text-xs",g?"text-danger-fg":"text-text-subtle"),children:r||s})]})});pe.displayName="TextArea";function Te(t,s){return s.split(".").reduce((r,n)=>r&&typeof r=="object"&&n in r?r[n]:void 0,t)}function Xt(t,s,r){const n=s.split("."),a=Array.isArray(t)?[...t]:{...t};let l=a;for(let o=0;o<n.length-1;o++){const x=n[o],u=l[x];l[x]=u&&typeof u=="object"?Array.isArray(u)?[...u]:{...u}:{},l=l[x]}return l[n[n.length-1]]=r,a}function Yt(t,s){const r=s.split("."),n=Array.isArray(t)?[...t]:{...t};let a=n;for(let l=0;l<r.length-1;l++){const o=r[l];if(!a[o]||typeof a[o]!="object")return n;a[o]=Array.isArray(a[o])?[...a[o]]:{...a[o]},a=a[o]}return delete a[r[r.length-1]],n}function Ue({title:t,description:s,className:r,children:n}){return e.jsxs("div",{className:i("flex flex-col gap-4 py-6 sm:flex-row sm:gap-8",r),children:[e.jsxs("div",{className:"w-full shrink-0 sm:w-form-label",children:[t&&e.jsx("span",{className:"text-base font-semibold text-text",children:t}),s&&e.jsx("p",{className:"mt-1 text-sm leading-relaxed text-pretty text-text-subtle",children:s})]}),e.jsx("div",{className:"min-w-0 flex-1",children:n})]})}const Zt=({groups:t,data:s,onSubmit:r,onCancel:n,onChange:a,transform:l,validate:o,submitButton:x={label:"Submit",variant:"primary"},cancelButton:u={label:"Cancel",variant:"outline"},showButtons:j=!0,layout:h="vertical",size:m="md",loading:b=!1,className:v,ref:w,sdk:g})=>{const[f,z]=d.useState(s||{}),[k,V]=d.useState({}),[D,G]=d.useState({});d.useEffect(()=>{s&&z({...s})},[s]);const q=d.useCallback((N,c,C)=>{const p=t.flatMap($=>$.items).find($=>$.name===N);if(!p)return null;if(p.required&&(c==null||c===""))return`${p.label} is required`;if(p.type==="array"){if(p.required&&(!c||c.length===0))return`${p.label} cannot be empty.`;if(c&&!Array.isArray(c))return`${p.label} must be an array.`;if(Array.isArray(c)&&p.arrayFields){const $=[];let y=!1;if(c.forEach((U,te)=>{const Q={};for(const X of p.arrayFields){const P=U?.[X.name];if(X.required&&(P==null||P===""))Q[X.name]=`${X.label} is required`,y=!0;else if(X.validator){const T=X.validator(P,U);T&&(Q[X.name]=T,y=!0)}}$[te]=Q}),y)return JSON.stringify($)}}return p.validator?p.validator(c,C):null},[t]),L=d.useCallback((N,c)=>{let C=Xt(f,N,c);t.flatMap(y=>y.items).find(y=>y.name===N)?.removeIfEmpty&&(c==null||c==="")&&(C=Yt(C,N)),z(C),G(y=>({...y,[N]:!0}));const $=q(N,c,C);V(y=>({...y,[N]:$||""})),a?.(C,N)},[f,t,q,a]),H=d.useCallback(async N=>{if(N.preventDefault(),b)return;const c={},C=t.flatMap($=>$.items);for(const $ of C){if($.hidden||$.conditional&&!$.conditional(f))continue;const y=q($.name,Te(f,$.name),f);y&&(c[$.name]=y)}if(o){const $=o(f);$&&Object.assign(c,$)}if(V(c),Object.keys(c).some($=>c[$]))return;const p=l?l(f):f;await r?.(f,p)},[f,t,q,o,l,r,b]),ee=d.useCallback(N=>{const c=Te(f,N.name),C=D[N.name]?k[N.name]:void 0,p=N.disabled||b,$={value:c||"",disabled:p,required:N.required,placeholder:N.placeholder,...N.fieldProps};switch(N.type){case"text":case"email":case"password":case"number":case"tel":case"url":return e.jsx(me,{...$,onChange:y=>L(N.name,y.target.value),type:N.textType||N.type,autoComplete:N.autocomplete,error:C,size:m});case"textarea":return e.jsx(pe,{...$,onChange:y=>L(N.name,y.target.value),rows:4,error:C,size:m});case"select":return e.jsx(he,{...$,onChange:y=>L(N.name,y),options:(N.options||[]).map(y=>({...y,value:String(y.value)})),searchable:N.searchable,multiple:N.multiple,allowCreate:N.allowCreate,error:C,size:m});case"segmented":return e.jsx(_e,{"aria-label":N.label,value:c==null?"":String(c),onChange:y=>L(N.name,y),options:(N.options||[]).map(y=>({value:String(y.value),label:y.label})),size:m==="sm"?"sm":"md",className:N.disabled?"pointer-events-none opacity-50":void 0});case"checkbox":return e.jsx(xe,{...$,label:N.label,checked:!!c,onChange:y=>L(N.name,y.target.checked),size:m});case"radio":return e.jsx("div",{className:"flex flex-col gap-2",children:N.options?.map(y=>e.jsxs("label",{className:"flex cursor-pointer items-center gap-3 text-base text-text",children:[e.jsx("input",{type:"radio",name:N.name,value:y.value,checked:c===y.value,onChange:()=>L(N.name,y.value),disabled:p||y.disabled,className:"size-checkbox shrink-0 rounded-xs border border-border-strong bg-surface-input accent-accent focus-visible:outline-none focus-visible:focus-ring"}),y.label]},y.value))});case"date":return e.jsx(ge,{...$,value:c?new Date(c):null,onChange:y=>L(N.name,y),size:m});case"file":return e.jsx(Ve,{...$,value:c,onChange:y=>L(N.name,y),error:C,onListFiles:y=>g?.http.invoke({method:"POST",action:"storage.file.list",body:y}),onListMounts:()=>g?.http.invoke({method:"GET",action:"storage.mount"}),onUploadFile:y=>g?.http.invoke({method:"POST",action:"storage.file.upload",body:y}),onDownloadFile:y=>g?.http.invoke({method:"GET",action:`storage.file.${y}.download`}),onRegisterFile:y=>g?.http.invoke({method:"POST",action:"storage.file.folder",body:y})});case"folder":return e.jsx(Fe,{value:c||{},onChange:y=>L(N.name,y),onListFolders:()=>g?.http.invoke({method:"GET",action:"storage.mount"}),disabled:p,size:m,placeholder:N.placeholder});case"custom":return N.customComponent?.({value:c,onChange:y=>L(N.name,y),error:C,disabled:p});case"array":{const y=c||[];let U=[];if(typeof C=="string"&&C.startsWith("["))try{U=JSON.parse(C)}catch{}const te=()=>{L(N.name,[...y,{}])},Q=P=>{L(N.name,y.filter((T,A)=>A!==P))},X=(P,T,A)=>{const E=[...y];E[P]={...E[P],[T]:A},L(N.name,E)};return e.jsxs("div",{className:"flex flex-col gap-2",children:[y.map((P,T)=>e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsx("div",{className:"grid flex-1 gap-2 sm:grid-cols-2",children:N.arrayFields?.map(A=>{const E=U?.[T]?.[A.name];return e.jsxs("div",{className:"flex flex-col gap-1",children:[T===0&&e.jsxs("label",{className:"block text-xs font-semibold uppercase tracking-label text-text-subtle",children:[A.label,A.required&&e.jsx("span",{className:"ml-1 text-danger-fg",children:"*"})]}),(()=>{const I={value:P?.[A.name]||"",disabled:p,required:A.required,placeholder:A.placeholder,...A.fieldProps};switch(A.type){case"text":case"email":case"password":case"number":case"tel":case"url":return e.jsx(me,{...I,onChange:F=>X(T,A.name,F.target.value),type:A.textType||A.type,autoComplete:A.autocomplete,error:E,size:m});case"textarea":return e.jsx(pe,{...I,onChange:F=>X(T,A.name,F.target.value),rows:4,error:E,size:m});case"select":return e.jsx(he,{...I,onChange:F=>X(T,A.name,F),options:(A.options||[]).map(F=>({...F,value:String(F.value)})),searchable:A.searchable,multiple:A.multiple,allowCreate:A.allowCreate,error:E,size:m});case"checkbox":return e.jsx(xe,{...I,checked:!!P?.[A.name],onChange:F=>X(T,A.name,F.target.checked),size:m});case"radio":return e.jsx("div",{className:"flex flex-col gap-2",children:A.options?.map(F=>e.jsxs("label",{className:"flex cursor-pointer items-center gap-2 text-base text-text",children:[e.jsx("input",{type:"radio",name:`${N.name}.${T}.${A.name}`,value:F.value,checked:P?.[A.name]===F.value,onChange:()=>X(T,A.name,F.value),disabled:p||F.disabled,className:"size-checkbox shrink-0 rounded-xs border border-border-strong bg-surface-input accent-accent focus-visible:outline-none focus-visible:focus-ring"}),F.label]},F.value))});case"date":{const F=P?.[A.name];return e.jsx(ge,{...I,value:F?new Date(F):null,onChange:B=>X(T,A.name,B),size:m})}case"custom":return A.customComponent?.({value:P?.[A.name],onChange:F=>X(T,A.name,F),error:E,disabled:p});default:return e.jsxs("p",{children:["Unsupported field type in array:"," ",A.type]})}})(),E&&e.jsx("p",{className:"text-xs text-danger-fg",children:E})]},A.name)})}),e.jsx(re,{type:"button",iconOnly:!0,variant:"ghost",size:"md","aria-label":`${N.label} verwijderen`,onClick:()=>Q(T),disabled:p,className:i("shrink-0",T===0&&"mt-5"),children:e.jsx(R.Trash2,{className:"size-icon-md"})})]},T)),e.jsxs(re,{type:"button",variant:"secondary",leftIcon:e.jsx(R.Plus,{className:"size-icon-sm"}),onClick:te,disabled:p,children:[N.label," toevoegen"]})]})}default:return null}},[f,D,k,b,m,L]),J=d.useCallback(N=>{if(N.conditional&&!N.conditional(f))return null;const c=N.items.filter(p=>!(p.hidden||p.conditional&&!p.conditional(f)));if(c.length===0)return null;const C=i(N.layout==="flex"?"flex flex-wrap gap-3.5":"grid gap-3.5",N.layout!=="flex"&&{"grid-cols-1":!N.columns||N.columns===1,"grid-cols-2":N.columns===2,"grid-cols-3":N.columns===3,"grid-cols-4":N.columns===4},N.className);return e.jsx(Ue,{title:N.title,description:N.description,className:"not-last:border-b not-last:border-border-subtle",children:e.jsx("div",{children:e.jsx("div",{className:C,children:c.map(p=>{const $=D[p.name]?k[p.name]:void 0;return e.jsxs("div",{className:i("flex min-w-0 flex-col gap-1.5",p.type==="checkbox"&&"justify-center"),style:{width:typeof p.width=="string"?p.width:void 0,gridColumn:typeof p.width=="number"?`span ${p.width} / span ${p.width}`:void 0},children:[p.type!=="custom"&&p.type!=="checkbox"&&e.jsxs("label",{className:"block text-sm font-medium text-text-muted",children:[p.label,p.required&&e.jsx("span",{className:"ml-1 text-danger-fg",children:"*"})]}),ee(p),p.help&&!$&&e.jsx("p",{className:"text-xs leading-4 text-text-subtle",children:p.help})]},p.name)})})})},N.id)},[f,D,k,ee]),W=i({"max-w-settings":m==="sm","max-w-form":m==="md","max-w-6xl":m==="lg","max-w-full":m==="full"},v),ae=m==="full"?"md":m;return e.jsxs("form",{ref:w,onSubmit:H,className:W,children:[!j&&e.jsx("button",{type:"submit",className:"hidden",tabIndex:-1,"aria-hidden":!0}),e.jsx("div",{className:"flex flex-col",children:t.map(J)}),j&&e.jsx("div",{className:"flex items-center gap-2 border-t border-border-subtle py-4",children:e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"ml-auto"}),n&&e.jsx(re,{type:"button",variant:u.variant??"ghost",size:u.size||ae,disabled:u.disabled||b,onClick:n,className:u.className,children:u.label}),e.jsx(re,{type:"submit",variant:x.variant,size:x.size||ae,disabled:x.disabled||b,loading:b,className:x.className,children:x.label})]})})]})};function Qt({open:t,title:s,description:r,confirmLabel:n="Bevestigen",cancelLabel:a="Annuleren",tone:l="default",loading:o=!1,onConfirm:x,onCancel:u}){return e.jsx(Ee,{open:t,onClose:u,title:s,size:"sm",footer:e.jsxs("div",{className:"flex w-full items-center justify-end gap-2",children:[e.jsx(re,{variant:"ghost",onClick:u,disabled:o,children:a}),e.jsx(re,{variant:l==="danger"?"destructive":"primary",onClick:x,loading:o,children:n})]}),children:r&&e.jsx(ie,{color:"secondary",children:r})})}const es={default:"bg-surface-hover text-text",primary:"bg-accent-soft text-accent",secondary:"bg-surface-hover text-text-muted",success:"bg-success-soft text-success-fg",warning:"bg-warning-soft text-warning-fg",error:"bg-danger-soft text-danger-fg",info:"bg-info-soft text-info-fg",note:"bg-note-soft text-note"},ts={sm:"px-2 py-0.5 text-xs",md:"px-2.5 py-1 text-sm",lg:"px-3 py-1.5 text-base"},ss={default:"bg-surface-hover",primary:"bg-accent",secondary:"bg-surface-hover",success:"bg-success",warning:"bg-warning",error:"bg-danger",info:"bg-info",note:"bg-note"};function rs({variant:t="default",size:s="md",dot:r=!1,icon:n,dismissible:a=!1,onDismiss:l,className:o,children:x,...u}){return e.jsxs("span",{className:i("inline-flex items-center font-medium rounded-full",es[t],ts[s],o),...u,children:[r&&e.jsx("span",{className:i("w-2 h-2 rounded-full mr-1.5",ss[t])}),n&&e.jsx("span",{className:i("flex-shrink-0",x&&"mr-1"),children:n}),x,a&&l&&e.jsx("button",{onClick:l,className:"ml-1.5 flex-shrink-0 hover:opacity-70 transition-opacity","aria-label":"Remove badge",children:e.jsx(Y,{icon:R.X,size:"xs",color:"current"})})]})}const ns={neutral:"bg-surface-hover text-text-muted",success:"bg-success-soft text-success-fg"};function as({icon:t,tone:s="neutral",title:r,description:n,actions:a,card:l=!1,className:o,...x}){return e.jsxs("div",{className:i("flex flex-col items-center gap-2.5 text-center",l&&"rounded-lg border border-border bg-surface px-11 py-9 shadow-overlay",o),...x,children:[t!=null&&e.jsx("span",{className:i("flex size-disc items-center justify-center rounded-full text-2xl",ns[s]),children:t}),e.jsx("div",{className:"text-lg font-semibold text-text",children:r}),n&&e.jsx("div",{className:"max-w-sm text-sm leading-relaxed text-text-muted",children:n}),a&&e.jsx("div",{className:"flex gap-2 pt-1.5",children:a})]})}function ls({children:t,className:s,...r}){return e.jsx("kbd",{className:i("inline-flex items-center rounded border border-border px-1.5 py-px text-xs font-medium leading-none text-text-muted",s),...r,children:t})}const os={sm:"h-1",md:"h-1.5"},cs={accent:"bg-accent",success:"bg-success"};function is({value:t,variant:s="accent",size:r="md",className:n,...a}){const l=Math.max(0,Math.min(100,t));return e.jsx("div",{role:"progressbar","aria-valuenow":Math.round(l),"aria-valuemin":0,"aria-valuemax":100,className:i("w-full overflow-hidden rounded-full bg-surface-hover",os[r],n),...a,children:e.jsx("div",{className:i("h-full rounded-full transition-[width] duration-300 ease-out",cs[s]),style:{width:`${l}%`}})})}const ds={xs:"h-3 w-3",sm:"h-4 w-4",md:"h-6 w-6",lg:"h-8 w-8",xl:"h-12 w-12"},us={primary:"text-accent",secondary:"text-text-muted",white:"text-white",current:"text-current"},xs={xs:"text-xs",sm:"text-sm",md:"text-sm",lg:"text-base",xl:"text-lg"};function fs({size:t="md",variant:s="primary",label:r="Loading...",showLabel:n=!1,className:a,...l}){return e.jsxs("div",{className:i("inline-flex items-center",n?"flex-col space-y-2":"",a),...l,children:[e.jsxs("svg",{className:i("animate-spin",ds[t],us[s]),fill:"none",viewBox:"0 0 24 24","aria-hidden":!n,role:n?"status":void 0,children:[e.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),e.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"})]}),n&&e.jsx("span",{className:i("text-text-muted",xs[t]),children:r}),!n&&e.jsx("span",{className:"sr-only",children:r})]})}const ms={neutral:"bg-text-disabled",accent:"bg-accent",success:"bg-success",warning:"bg-warning",danger:"bg-danger",info:"bg-info",note:"bg-note","cat-1":"bg-cat-1","cat-2":"bg-cat-2","cat-3":"bg-cat-3","cat-4":"bg-cat-4","cat-5":"bg-cat-5"};function hs({tone:t="neutral",shape:s="round",pulse:r=!1,label:n,className:a}){return e.jsx("span",{role:n?"img":void 0,"aria-label":n,"aria-hidden":n?void 0:!0,className:i("inline-block size-dot shrink-0",s==="round"?"rounded-full":"rounded-sm",ms[t],r&&"animate-pulse",a)})}function bs({steps:t,current:s,variant:r="numbered",label:n,className:a}){const l=t.indexOf(s),o={role:n?"group":void 0,"aria-label":n,"aria-hidden":n?void 0:!0};return r==="dots"?e.jsx("div",{...o,className:i("flex items-center gap-1.5",a),children:t.map((x,u)=>e.jsx("span",{className:i("h-step-bar rounded-full transition-all duration-fast ease-out",u===l?"w-5 bg-accent":"w-3.5",u<l&&"bg-border-strong",u>l&&"bg-border")},x))}):e.jsx("div",{...o,className:i("flex items-center gap-2",a),children:t.map((x,u)=>e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{"aria-current":u===l?"step":void 0,className:i("flex size-tile-sm items-center justify-center rounded-full text-xs font-medium",u===l&&"bg-accent text-accent-fg",u<l&&"bg-accent-soft text-accent",u>l&&"bg-surface-hover text-text-muted"),children:u+1}),u<t.length-1&&e.jsx("span",{className:"h-px w-8 bg-border-strong"})]},x))})}function gs({title:t,icon:s=e.jsx(R.Sparkles,{className:"size-icon-md","aria-hidden":!0}),action:r,children:n,className:a,...l}){return e.jsxs("div",{className:i("flex flex-col gap-2 rounded-xl border p-4","border-assistant-border bg-assistant-soft",a),...l,children:[e.jsxs("div",{className:"flex items-center gap-2 text-assistant",children:[e.jsx("span",{"aria-hidden":!0,children:s}),e.jsx("span",{className:"text-sm font-semibold",children:t}),r&&e.jsx("span",{className:"ml-auto",children:r})]}),n&&e.jsx("div",{className:"text-sm leading-relaxed text-text",children:n})]})}const ps={default:"bg-avatar text-avatar-fg",in:"bg-avatar-in text-avatar-in-fg",out:"bg-accent text-accent-fg",note:"bg-avatar-note text-avatar-note-fg"},vs={xs:"w-5 h-5 text-xs",sm:"w-6 h-6 text-xs",md:"w-7 h-7 text-base",lg:"w-9 h-9 text-sm"};function js(t){if(!t)return"?";const s=t.trim().split(/[^\p{L}\p{N}]+/u).filter(Boolean);return s.length>=2?(s[0][0]+s[1][0]).toUpperCase():s.length===1?s[0].slice(0,2).toUpperCase():"?"}const Ke=({name:t,src:s,tone:r="default",size:n="sm",className:a,title:l})=>{const[o,x]=d.useState(!1),u=i("inline-flex items-center justify-center rounded-full overflow-hidden shrink-0 font-semibold select-none",ps[r],vs[n],a);return s&&!o?e.jsx("img",{src:s,alt:t??"",title:l??t,className:i(u,"object-cover"),onError:()=>x(!0)}):e.jsx("span",{className:u,title:l??t,"aria-label":t,children:js(t)})},De="ring-surface",ys="ring-surface-accent",Ns=({people:t,max:s=4,size:r="sm",className:n})=>{if(t.length===0)return null;const a=t.slice(0,s),l=t.length-a.length;return e.jsxs("span",{className:i("inline-flex items-center",n),children:[a.map((o,x)=>e.jsx(Ke,{name:o.name,src:o.src,size:r,title:o.name?o.seen===!1?`${o.name} — nog niet gelezen`:o.name:void 0,className:i(x>0&&"-ml-2",o.owner?ys:De,o.seen===!1&&"opacity-40")},o.id??`${o.name}-${x}`)),l>0&&e.jsxs("span",{className:i("inline-flex items-center justify-center rounded-full shrink-0 -ml-2 font-semibold bg-avatar text-avatar-fg",r==="xs"?"w-5 h-5 text-xs":r==="md"?"w-7 h-7 text-xs":r==="lg"?"w-9 h-9 text-xs":"w-6 h-6 text-xs",De),children:["+",l]})]})},$e={mail:{fg:"text-channel-mail-fg",bg:"bg-channel-mail-soft"},wa:{fg:"text-channel-whatsapp-fg",bg:"bg-channel-whatsapp-soft"},chat:{fg:"text-channel-chat-fg",bg:"bg-channel-chat-soft"},tel:{fg:"text-channel-phone-fg",bg:"bg-channel-phone-soft"},note:{fg:"text-channel-note-fg",bg:"bg-channel-note-soft"}},ws={sm:"size-avatar-xs rounded-sm text-xs",md:"size-avatar-sm rounded-md text-xs",lg:"size-avatar-lg rounded-md text-base"};function ks({channel:t,children:s,size:r="md",className:n,title:a}){const l=$e[t in $e?t:"note"];return e.jsx("span",{title:a,className:i("inline-flex shrink-0 items-center justify-center font-bold",ws[r],l.fg,l.bg,n),children:s})}const Cs=({src:t,alt:s,size:r="md",aspectRatio:n="auto",radius:a="md",showLoading:l=!0,showError:o=!0,fallback:x,loadingContent:u,errorContent:j,className:h,onLoad:m,onError:b,...v})=>{const[w,g]=d.useState(!0),[f,z]=d.useState(!1),[k,V]=d.useState(t),D=W=>{g(!1),z(!1),m?.(W)},G=W=>{if(g(!1),z(!0),x&&k!==x){V(x),z(!1),g(!0);return}b?.(W)},q=i("relative overflow-hidden bg-surface-hover",{"w-8 h-8":r==="xs","w-12 h-12":r==="sm","w-16 h-16":r==="md","w-24 h-24":r==="lg","w-32 h-32":r==="xl","w-full h-full":r==="full"},{"aspect-square":n==="square","aspect-video":n==="video","aspect-portrait":n==="portrait","aspect-landscape":n==="landscape"},{"rounded-none":a==="none","rounded-sm":a==="sm","rounded-md":a==="md","rounded-lg":a==="lg","rounded-xl":a==="xl","rounded-full":a==="full"},h),L=i("w-full h-full object-cover transition-opacity duration-fast",{"opacity-0":w||f,"opacity-100":!w&&!f}),H=i("absolute inset-0 flex items-center justify-center","text-text-muted"),ee=e.jsx("div",{className:"animate-pulse",children:e.jsx("div",{className:"w-6 h-6 bg-surface-hover rounded"})}),J=e.jsxs("div",{className:"text-center",children:[e.jsx(Y,{icon:R.ImageOff,size:"lg",className:"mx-auto mb-1"}),e.jsx("span",{className:"text-xs",children:"Failed to load"})]});return e.jsxs("div",{className:q,children:[e.jsx("img",{...v,src:k,alt:s,className:L,onLoad:D,onError:G}),w&&l&&e.jsx("div",{className:H,children:u||ee}),f&&o&&e.jsx("div",{className:H,children:j||J})]})};function Ss({icon:t,onClick:s,children:r}){return e.jsxs("button",{type:"button",onClick:s,className:i("inline-flex h-control-sm shrink-0 cursor-pointer items-center gap-1.5 rounded-md px-2.5","text-sm font-medium whitespace-nowrap","transition-colors duration-fast ease-out hover:bg-white/15","focus-visible:outline-none focus-visible:focus-ring"),children:[t,r]})}function Es({items:t,getRowKey:s,variant:r="divided",leading:n,renderItem:a,trailing:l,onSelect:o,onActiveIndexChange:x,isActive:u,unread:j,dimmed:h,groupBy:m,groups:b,renderGroupHeader:v,stickyGroupHeaders:w=!1,collapsibleGroups:g=!1,hideGroupCount:f=!1,selectable:z=!1,selectedItems:k=[],onSelectionChange:V,bulkActions:D,header:G,stickyHeader:q=!1,bordered:L=!1,emptyContent:H,loading:ee=!1,loadingRows:J=4,className:W,"aria-label":ae}){const[N,c]=d.useState(()=>Object.fromEntries((b??[]).filter(E=>E.defaultCollapsed).map(E=>[E.id,!0]))),C=d.useRef(null),p=E=>{if(!["ArrowDown","ArrowUp","Home","End"].includes(E.key))return;const F=Array.from(C.current?.querySelectorAll("li[data-list-row]")??[]);if(F.length===0)return;E.preventDefault();const B=F.indexOf(document.activeElement),M=E.key==="Home"?0:E.key==="End"?F.length-1:E.key==="ArrowDown"?(B+1)%F.length:(B-1+F.length)%F.length;F[M]?.focus()},$=(E,I)=>s?s(E,I):I,y=E=>k.includes(E),U=(E,I)=>{V&&V(I?[...k,E]:k.filter(F=>F!==E))},te=E=>V?.(E?[...t]:[]),Q=i("flex flex-col",z&&k.length>0&&"min-h-full",L&&"overflow-hidden rounded-lg border border-border-subtle",W);if(ee)return e.jsx("div",{className:Q,children:Array.from({length:J}).map((E,I)=>e.jsxs("div",{className:i("flex animate-pulse items-center gap-3 px-4 py-2",r==="divided"&&I>0&&"border-t border-border-subtle"),children:[e.jsx("span",{className:"size-tile-sm shrink-0 rounded-md bg-surface-hover"}),e.jsx("span",{className:"h-3 w-30 shrink-0 rounded-sm bg-surface-hover"}),e.jsx("span",{className:"h-3 flex-1 rounded-sm bg-surface-hover"}),e.jsx("span",{className:"h-3 w-8 shrink-0 rounded-sm bg-surface-hover"})]},`skeleton-${I}`))});if(t.length===0&&H)return e.jsx("div",{className:Q,children:H});const X=t.length>0&&k.length===t.length,P=k.length>0&&!X,T=(E,I,F)=>{const B=u?.(E,I)??!1,M=j?.(E,I)??!1,_=h?.(E,I)??!1,Z=z&&y(E);return e.jsxs("li",{...o?{role:"button",tabIndex:0,"data-list-row":"","aria-current":B||void 0,onClick:()=>o(E,I),onFocus:()=>x?.(I),onKeyDown:se=>{se.key!=="Enter"&&se.key!==" "||(se.preventDefault(),o(E,I))}}:{},className:i("flex items-center gap-3 text-base","transition-colors duration-fast ease-out",r==="inset"?"mx-2 rounded-lg px-3 py-2.5":"px-5 py-2.5",r==="divided"&&!F&&"border-t border-border-subtle",o&&"cursor-pointer focus-visible:outline-none focus-visible:focus-ring",B||Z?"bg-accent-soft text-text":M?i("bg-surface-unread",o&&"hover:bg-surface-unread-hover"):o&&"hover:bg-surface-hover",_&&"text-text-muted"),children:[z&&e.jsx("span",{onClick:se=>se.stopPropagation(),children:e.jsx(xe,{checked:y(E),onChange:se=>U(E,se.target.checked),"aria-label":"Rij selecteren"})}),r==="bulleted"&&e.jsx("span",{"aria-hidden":!0,className:"mt-2 size-1.5 shrink-0 self-start rounded-full bg-border-strong"}),n&&e.jsx("span",{className:"shrink-0",children:n(E,I)}),e.jsx("div",{className:"flex min-w-0 flex-1 items-center gap-2",children:a?a(E,I):String(E)}),l&&e.jsx("span",{className:"shrink-0 text-xs text-text-subtle",children:l(E,I)})]},$(E,I))},A=(()=>{if(!m)return t.map((B,M)=>T(B,M,M===0));const E=new Map;t.forEach((B,M)=>{const _=m(B,M);E.has(_)||E.set(_,[]),E.get(_).push({item:B,index:M})});const I=b??[];return[...I.filter(B=>E.has(B.id)),...[...E.keys()].filter(B=>!I.some(M=>M.id===B)).map(B=>({id:B}))].flatMap((B,M)=>{const _=E.get(B.id)??[],Z=g&&N[B.id],se=B.title??B.id,oe=B.count??_.length,ue=e.jsx("li",{onClick:g?()=>c(de=>({...de,[B.id]:!de[B.id]})):void 0,className:i("flex items-center gap-2.5 bg-surface px-5 pb-1.5 text-base font-semibold",M>0?"pt-5":"pt-3",B.tone==="danger"?"text-danger-fg":B.tone==="muted"?"text-text-subtle":"text-text",w&&"sticky z-10",g&&"cursor-pointer select-none"),"aria-expanded":g?!Z:void 0,style:w?{top:q?28:0}:void 0,children:v?v(B,_.map(de=>de.item)):e.jsxs(e.Fragment,{children:[g&&e.jsx(R.ChevronRight,{"aria-hidden":!0,className:i("size-icon-md shrink-0 text-text-subtle transition-transform duration-fast ease-out",!Z&&"rotate-90")}),e.jsx("span",{children:se}),!f&&e.jsx("span",{className:i("rounded-full px-2 text-xs font-normal tabular-nums",B.tone==="danger"?"bg-danger-soft text-danger-fg":"bg-surface-sunk text-text-subtle"),children:oe})]})},`group-${B.id}`);return Z?[ue]:[ue,..._.map(({item:de,index:je},S)=>T(de,je,S===0))]})})();return e.jsxs("div",{ref:C,className:Q,onKeyDown:o?p:void 0,children:[G&&e.jsxs("div",{className:i("flex h-row-sm items-end gap-3 border-b border-border bg-surface px-5 pb-2","text-xs font-semibold uppercase tracking-wider text-text-disabled",q&&"sticky top-0 z-20"),children:[z&&e.jsx("span",{className:"flex items-center",children:e.jsx(xe,{checked:X,indeterminate:P,onChange:E=>te(E.target.checked),"aria-label":"Alles selecteren"})}),G]}),e.jsx("ul",{"aria-label":ae,className:"flex flex-col",children:A}),z&&k.length>0&&e.jsx("div",{className:"pointer-events-none sticky bottom-0 z-10 flex justify-center px-5 pb-4",children:e.jsxs("div",{className:"pointer-events-auto flex items-center gap-1.5 rounded-lg bg-accent py-1.5 pl-3.5 pr-1.5 text-accent-fg shadow-overlay",children:[e.jsxs("span",{className:"text-sm font-medium",children:[k.length," geselecteerd"]}),e.jsx("span",{"aria-hidden":!0,className:"mx-1.5 h-4 w-px bg-current opacity-25"}),D,e.jsx("span",{"aria-hidden":!0,className:"mx-1.5 h-4 w-px bg-current opacity-25"}),e.jsx("button",{type:"button",onClick:()=>V?.([]),"aria-label":"Selectie wissen",className:"grid size-tile-md shrink-0 cursor-pointer place-items-center rounded-md transition-colors duration-fast ease-out hover:bg-white/15 focus-visible:outline-none focus-visible:focus-ring",children:e.jsx(R.X,{className:"size-icon-lg"})})]})})]})}function Ms({side:t,continued:s=!1,tone:r="default",className:n,children:a}){return e.jsx("div",{className:i("min-w-0 max-w-bubble md:max-w-bubble-md",t==="out"?"rounded-lg rounded-tr-sm":"rounded-lg rounded-tl-sm",r==="note"?"bg-note-soft":t==="out"?"bg-bubble-out-soft":"bg-surface-sunk",s&&"mt-1",n),children:a})}const zs={default:"text-text",urgent:"text-danger-fg",success:"text-success-fg"};function Ts({value:t,label:s,tone:r="default",className:n,...a}){return e.jsxs("div",{className:i("rounded-xl bg-editor px-4 py-3.5",n),...a,children:[e.jsx("div",{className:i("text-2xl font-semibold",zs[r]),children:t}),e.jsx("div",{className:"pt-0.5 text-xs text-text-muted",children:s})]})}const Ds=({surface:t=!1,title:s,subtitle:r,meta:n,actions:a=[],children:l,className:o,backLabel:x="Back",backClassName:u,onBack:j,editable:h=!1,onTitleChange:m})=>{const[b,v]=d.useState(!1),[w,g]=d.useState(s),f=d.useRef(null);d.useEffect(()=>{g(s)},[s]),d.useEffect(()=>{b&&f.current&&(f.current.focus(),f.current.select())},[b]);const z=()=>{h&&v(!0)},k=()=>{v(!1),w.trim()!==""&&w!==s&&m?m(w.trim()):g(s)},V=D=>{D.key==="Enter"?f.current?.blur():D.key==="Escape"&&(g(s),v(!1))};return e.jsxs("div",{className:i("px-5 pt-4 pb-2.5",t&&"border-b border-border",o),children:[e.jsxs("div",{className:"flex flex-row sm:items-start sm:justify-between items-center gap-4",children:[e.jsx("div",{className:"min-w-0 flex-1",children:e.jsxs("div",{className:"flex items-start gap-4 text-text",children:[j&&e.jsx(re,{variant:"ghost",onClick:j,leftIcon:e.jsx(Y,{icon:R.ChevronLeft,size:"md"}),iconOnly:!0}),e.jsxs("div",{className:"min-w-0 flex-1",children:[b?e.jsx("input",{ref:f,type:"text",value:w,onChange:D=>g(D.target.value),onBlur:k,onKeyDown:V,className:"text-1xl font-semibold bg-transparent border-b-1 border-border rounded-lg outline-none focus:border-none px-1 -mx-1 min-w-0 w-full"}):e.jsxs("div",{className:"group flex items-baseline gap-2.5 min-w-0",children:[e.jsx("h2",{onClick:z,className:i("text-lg font-semibold tracking-title truncate",h&&"cursor-pointer"),title:h?"Click to edit":void 0,children:s}),r&&e.jsx("span",{className:"shrink-0 text-base text-text-muted truncate",children:r}),h&&e.jsx(R.Pencil,{size:15,onClick:z,className:"shrink-0 cursor-pointer text-text-muted opacity-0 group-hover:opacity-100 transition-opacity"})]}),n&&e.jsx("div",{className:i("mt-1 min-w-0 text-sm text-text-subtle",typeof n=="string"&&"truncate"),children:n})]})]})}),a.length>0&&e.jsx("div",{className:"flex flex-wrap sm:flex-nowrap gap-2 sm:gap-3",children:a.map(D=>D.render?e.jsx(d.Fragment,{children:D.render()},D.id):D.splitOptions&&D.splitOptions.length>0?e.jsx(ke,{label:D.label,onClick:D.onClick,icon:D.icon,variant:D.variant==="primary"?"primary":"outline",options:D.splitOptions,disabled:D.disabled},D.id):e.jsx(re,{variant:D.variant??"secondary",onClick:G=>{G.stopPropagation(),G.target.blur(),D.onClick()},disabled:D.disabled,leftIcon:D.icon,children:D.label},D.id))})]}),l&&e.jsx("div",{className:"mt-4",children:l})]})},$s=/<[a-z][\s\S]*>/i,As=["[&_p]:my-1.5 [&_p:first-child]:mt-0 [&_p:last-child]:mb-0 [&_p]:leading-relaxed","[&_a]:text-accent [&_a]:underline [&_a]:underline-offset-2","[&_strong]:font-semibold [&_em]:italic","[&_ul]:my-1.5 [&_ul]:list-disc [&_ul]:pl-5 [&_ol]:my-1.5 [&_ol]:list-decimal [&_ol]:pl-5","[&_li]:leading-relaxed","[&_h1]:mb-1 [&_h1]:mt-2 [&_h1]:font-semibold [&_h2]:mb-1 [&_h2]:mt-2 [&_h2]:font-semibold [&_h3]:mb-1 [&_h3]:mt-2 [&_h3]:font-semibold","[&_blockquote]:my-1.5 [&_blockquote]:border-l-2 [&_blockquote]:border-border [&_blockquote]:pl-3 [&_blockquote]:text-text-muted","[&_hr]:my-2 [&_hr]:border-border","[&_pre]:my-1.5 [&_pre]:overflow-x-auto [&_pre]:rounded-md [&_pre]:bg-surface-sunk [&_pre]:p-2 [&_pre]:text-xs","[&_code]:rounded-sm [&_code]:bg-surface-sunk [&_code]:px-1 [&_code]:py-0.5 [&_code]:font-mono [&_code]:text-xs","[&_pre_code]:bg-transparent [&_pre_code]:p-0","[&_table]:my-1.5 [&_table]:w-full [&_table]:border-collapse [&_table]:text-xs","[&_th]:border [&_th]:border-border [&_th]:px-2 [&_th]:py-1 [&_th]:text-left [&_th]:font-semibold","[&_td]:border [&_td]:border-border [&_td]:px-2 [&_td]:py-1"].join(" "),_s={p:t=>e.jsx("p",{className:"my-1.5 leading-relaxed first:mt-0 last:mb-0",...t}),a:t=>e.jsx("a",{className:"text-accent underline underline-offset-2 hover:opacity-80",target:"_blank",rel:"noopener noreferrer",...t}),strong:t=>e.jsx("strong",{className:"font-semibold",...t}),em:t=>e.jsx("em",{className:"italic",...t}),ul:t=>e.jsx("ul",{className:"my-1.5 list-disc space-y-0.5 pl-5",...t}),ol:t=>e.jsx("ol",{className:"my-1.5 list-decimal space-y-0.5 pl-5",...t}),li:t=>e.jsx("li",{className:"leading-relaxed",...t}),h1:t=>e.jsx("h1",{className:"mb-1 mt-2 text-md font-semibold first:mt-0",...t}),h2:t=>e.jsx("h2",{className:"mb-1 mt-2 text-base font-semibold first:mt-0",...t}),h3:t=>e.jsx("h3",{className:"mb-1 mt-2 text-base font-semibold first:mt-0",...t}),blockquote:t=>e.jsx("blockquote",{className:"my-1.5 border-l-2 border-border pl-3 text-text-muted",...t}),hr:t=>e.jsx("hr",{className:"my-2 border-border",...t}),pre:t=>e.jsx("pre",{className:"my-1.5 overflow-x-auto rounded-md bg-surface-sunk p-2 text-xs",...t}),code:({className:t,children:s,...r})=>{const n=String(s??"");return/language-/.test(t??"")||n.includes(`
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const Je=require("clsx"),e=require("react/jsx-runtime"),R=require("lucide-react"),d=require("react"),Xe=require("dompurify"),Ye=require("react-markdown"),Ze=require("remark-gfm");function i(...t){return Je.clsx(t)}function Qe(t){return(s,r)=>t[s]?.[r]||""}function et(t){return s=>t[s]||""}const ze=["cat-1","cat-2","cat-3","cat-4","cat-5"];function tt(t){let s=0;for(let r=0;r<t.length;r++)s=s*31+t.charCodeAt(r)>>>0;return ze[s%ze.length]}function st({tiles:t,pinned:s,className:r}){if(s)return e.jsxs("div",{className:i("flex flex-col md:flex-row gap-2 h-full min-h-0",r),children:[e.jsx("div",{className:"flex-1 min-h-0",children:s}),t.length>0&&e.jsx("div",{className:"flex md:flex-col gap-2 md:w-48 overflow-auto",children:t.map((a,l)=>e.jsx("div",{className:"min-w-40 md:min-w-0",children:a},l))})]});const n=t.length<=1?"grid-cols-1":t.length<=4?"grid-cols-2":t.length<=9?"grid-cols-3":"grid-cols-4";return e.jsx("div",{className:i("grid gap-2 h-full",n,r),children:t.map((a,l)=>e.jsx("div",{children:a},l))})}function rt({name:t,avatarUrl:s,muted:r,speaking:n,hasVideo:a,videoSlot:l,className:o,fill:x}){return e.jsxs("div",{className:i("relative rounded-lg overflow-hidden bg-video-surface flex items-center justify-center",x?"h-full w-full":"aspect-video",n&&"ring-2 ring-speaking",o),children:[a&&l?e.jsx("div",{className:"absolute inset-0",children:l}):e.jsx("div",{className:"flex flex-col items-center gap-2 text-gray-300",children:s?e.jsx("img",{src:s,alt:t,className:"w-16 h-16 rounded-full object-cover"}):e.jsx("div",{className:"w-16 h-16 rounded-full bg-video-surface-strong flex items-center justify-center",children:a?e.jsx(R.VideoOff,{className:"w-8 h-8"}):e.jsx(R.User,{className:"w-8 h-8"})})}),e.jsxs("div",{className:"absolute bottom-2 left-2 flex items-center gap-1.5 px-2 py-1 rounded bg-video-overlay text-white text-xs",children:[r?e.jsx(R.MicOff,{className:"w-3 h-3"}):e.jsx(R.Mic,{className:"w-3 h-3"}),e.jsx("span",{className:"truncate max-w-35",children:t})]})]})}function nt({attach:t,active:s=!0,mirrored:r=!1,className:n}){const a=d.useRef(null);return d.useEffect(()=>{if(!s||!a.current)return;const l=t(a.current);return()=>{typeof l=="function"&&l(),a.current&&(a.current.innerHTML="")}},[t,s]),e.jsx("div",{ref:a,className:i("w-full h-full bg-video-surface-strong overflow-hidden",r&&"[&>*]:scale-x-[-1]",n)})}const at={primary:"bg-accent text-accent-fg hover:bg-accent-hover disabled:bg-surface-hover",secondary:"bg-surface-sunk text-text-strong hover:bg-surface-hover disabled:bg-surface-hover",outline:"border border-border text-text-strong hover:bg-surface-hover",ghost:"text-text-muted hover:bg-surface-hover hover:text-text",destructive:"border border-danger-border bg-danger-soft text-danger-fg hover:border-danger disabled:bg-surface-hover",success:"bg-success text-text-inverse hover:opacity-90 disabled:bg-surface-hover",warning:"bg-warning text-text-inverse hover:opacity-90 disabled:bg-surface-hover","danger-solid":"bg-danger text-text-inverse hover:opacity-90 disabled:bg-surface-hover"},lt={xs:"h-control-xs px-2 text-xs",sm:"h-control-sm px-3 text-sm",md:"h-control-md px-4 text-sm",lg:"h-control-lg px-4 text-sm",xl:"h-control-xl px-6 text-base","2xl":"h-control-2xl px-6 text-base",full:"h-control-md px-4 text-sm"},ot={xs:"h-control-xs w-6",sm:"h-control-sm w-7",md:"h-control-md w-8",lg:"h-control-lg w-9",xl:"h-control-xl w-10","2xl":"h-control-2xl w-12",full:"h-control-md w-8"},re=d.forwardRef(({variant:t="primary",size:s="md",fullWidth:r=!1,loading:n=!1,leftIcon:a,rightIcon:l,iconOnly:o=!1,shape:x="default",className:u,children:j,disabled:h,...m},b)=>{const v=h||n;return e.jsxs("button",{ref:b,type:"button",className:i("inline-flex shrink-0 items-center justify-center gap-2 cursor-pointer font-medium",x==="circle"?"rounded-full":"rounded-md","transition-colors duration-fast ease-out","focus-visible:outline-none focus-visible:focus-ring","disabled:cursor-not-allowed disabled:border-border-subtle","disabled:text-text-disabled",at[t],o?ot[s]:lt[s],(r||s==="full")&&"w-full",n&&"cursor-wait",u),disabled:v,"aria-busy":n||void 0,...m,children:[n&&e.jsx("span",{"aria-hidden":!0,className:"size-icon-md shrink-0 animate-spin rounded-full border-2 border-current border-t-transparent"}),!n&&a&&e.jsx("span",{className:"flex items-center justify-center shrink-0",children:a}),!o&&j,!n&&l&&e.jsx("span",{className:"flex items-center justify-center shrink-0",children:l}),o&&!n&&!a&&!l&&j]})});re.displayName="Button";const ct=({children:t,size:s="md",orientation:r="horizontal",attached:n=!0,className:a})=>{const l=i("inline-flex",{"flex-row":r==="horizontal","flex-col":r==="vertical","[&>*:not(:first-child):not(:last-child)]:rounded-none":n,"[&>*:first-child]:rounded-r-none":n&&r==="horizontal","[&>*:last-child]:rounded-l-none":n&&r==="horizontal","[&>*:first-child]:rounded-b-none":n&&r==="vertical","[&>*:last-child]:rounded-t-none":n&&r==="vertical","[&>*:not(:first-child)]:-ml-px":n&&r==="horizontal","[&>*:not(:first-child)]:-mt-px":n&&r==="vertical","gap-1":!n&&s==="xs","gap-2":!n&&(s==="sm"||s==="md"),"gap-3":!n&&(s==="lg"||s==="xl")},a);return e.jsx("div",{className:l,role:"group",children:t})},it={primary:"text-text",secondary:"text-text-muted",accent:"text-accent",success:"text-success-fg",warning:"text-warning-fg",error:"text-danger-fg",info:"text-info-fg",neutral:"text-text-subtle",current:"text-current"},Y=({icon:t,size:s="md",color:r="current",clickable:n=!1,onClick:a,className:l,"aria-label":o,...x})=>{const u=typeof s=="number"?s:dt(s),j=i("inline-block shrink-0",it[r],n&&["cursor-pointer rounded-sm transition-opacity duration-fast ease-out hover:opacity-80","focus-visible:outline-none focus-visible:focus-ring"],l),h={size:u,strokeWidth:2,className:j,onClick:n?a:void 0,"aria-label":o,"aria-hidden":o?void 0:!0,role:n?"button":void 0,tabIndex:n?0:void 0,onKeyDown:n?m=>{(m.key==="Enter"||m.key===" ")&&(m.preventDefault(),a?.())}:void 0,...x};return e.jsx(t,{...h})};function dt(t){return{xs:12,sm:14,md:16,lg:20,xl:24}[t]}function ve(t,s,{gap:r=6,matchWidth:n=!1,placement:a="bottom-start"}={}){const[l,o]=d.useState({});return d.useLayoutEffect(()=>{if(!t)return;const x=()=>{const u=s.current;if(!u)return;const j=u.getBoundingClientRect(),h=window.innerHeight-j.bottom,m=j.top,b=a.startsWith("top"),v=b?m<200&&h>m:h<200&&m>h,w=b!==v,g={position:"fixed"};w?(g.bottom=window.innerHeight-j.top+r,g.maxHeight=Math.max(120,m-r*2)):(g.top=j.bottom+r,g.maxHeight=Math.max(120,h-r*2)),a.endsWith("end")?g.right=window.innerWidth-j.right:g.left=j.left,n&&(g.width=j.width),o(g)};return x(),window.addEventListener("scroll",x,!0),window.addEventListener("resize",x),()=>{window.removeEventListener("scroll",x,!0),window.removeEventListener("resize",x)}},[t,s,r,n,a]),l}const we=({trigger:t,children:s,placement:r="bottom-start",className:n,rootClassName:a,triggerClassName:l,disabled:o=!1,triggerLabel:x})=>{const[u,j]=d.useState(!1),h=d.useRef(null),m=d.useRef(null),b=ve(u,m,{placement:r});d.useEffect(()=>{if(!u)return;const g=z=>{h.current&&!h.current.contains(z.target)&&j(!1)},f=z=>{z.key==="Escape"&&j(!1)};return document.addEventListener("mousedown",g),document.addEventListener("keydown",f),()=>{document.removeEventListener("mousedown",g),document.removeEventListener("keydown",f)}},[u]);const v=g=>{g.stopPropagation(),!o&&j(f=>!f)},w=()=>j(!1);return e.jsxs("div",{ref:h,className:i("relative inline-flex",a),children:[e.jsx("button",{ref:m,type:"button",onClick:v,disabled:o,"aria-label":x,"aria-expanded":u,className:i("inline-flex items-center",o&&"cursor-not-allowed opacity-50",l),children:t}),u&&e.jsx("div",{className:i("fixed z-overlay overflow-y-auto rounded-lg border border-border bg-surface shadow-overlay",n),style:b,children:typeof s=="function"?s(w):s})]})},ut={none:"hover:bg-surface-sunk hover:text-text",default:"bg-surface-sunk text-text-muted hover:text-text",muted:"bg-surface-sunk text-text-subtle hover:text-text",outline:"text-text-muted ring-1 ring-inset ring-border-strong hover:bg-surface-hover hover:text-text",warning:"bg-warning-soft text-warning-fg",danger:"bg-danger-soft text-danger-fg"},xt=t=>i("inline-flex cursor-pointer select-none items-center text-sm font-medium",t.size==="sm"?"h-control-sm":"h-control-md","transition-colors duration-fast ease-out",t.shape==="pill"?"rounded-full":"rounded-md",t.active?"bg-info-soft text-info-fg":ut[t.tone??"default"],t.className),ft=t=>i("inline-flex items-center gap-1.5 pl-3",t.shape==="pill"?"rounded-full":"rounded-md",t.withClear?"pr-1.5":"pr-3","focus-visible:outline-none focus-visible:focus-ring");function Ae({label:t,icon:s,tone:r="default",shape:n="rect",size:a="md",active:l=!1,caret:o=!1,menu:x,menuClassName:u,onClear:j,clearLabel:h="Filter wissen",onClick:m,title:b,className:v}){const w=l&&!!j,g=n==="pill"?"rounded-full":"rounded-md",f=xt({active:l,tone:r,shape:n,size:a,className:v}),z=e.jsxs(e.Fragment,{children:[s,t,o&&e.jsx(Y,{icon:R.ChevronDown,size:"xs"})]}),k=ft({shape:n,withClear:w}),V=w&&e.jsx("button",{type:"button","aria-label":h,onClick:j,className:i("inline-flex h-full items-center pr-3 focus-visible:outline-none focus-visible:focus-ring",g),children:e.jsx(Y,{icon:R.X,size:"xs"})});return x?e.jsxs("span",{className:f,title:b,children:[e.jsx(we,{trigger:z,rootClassName:"h-full",triggerClassName:i(k,"h-full"),className:i("min-w-menu p-1.5",u),children:x}),V]}):w?e.jsxs("span",{className:f,title:b,children:[e.jsx("button",{type:"button",onClick:m,className:k,children:z}),V]}):e.jsx("button",{type:"button",title:b,onClick:m,className:i(f,k),children:z})}const mt={xs:"text-xs",sm:"text-sm",md:"text-base",lg:"text-md",xl:"text-lg"},ht={primary:"text-text hover:text-info-fg hover:underline",info:"text-info-fg hover:underline",secondary:"text-text-muted hover:text-text",neutral:"text-text-muted hover:text-text",accent:"text-accent hover:underline",success:"text-success-fg hover:underline",warning:"text-warning-fg hover:underline",error:"text-danger-fg hover:underline"},bt={primary:"bg-accent-soft",accent:"bg-accent-soft",secondary:"bg-surface-hover",neutral:"bg-surface-hover",success:"bg-success-soft",warning:"bg-warning-soft",error:"bg-danger-soft",info:"bg-info-soft"},gt=({variant:t="default",size:s="md",color:r="primary",disabled:n=!1,external:a=!1,className:l,children:o,href:x,target:u,rel:j,...h})=>{const m=a||x&&(x.startsWith("http")||x.startsWith("mailto:")),b=i("inline-flex items-center gap-1 underline-offset-2","transition-colors duration-fast ease-out","focus-visible:outline-none focus-visible:focus-ring",mt[s],!n&&ht[r],t==="subtle"&&"no-underline opacity-70 hover:opacity-100",t==="underline"&&"underline decoration-1 hover:decoration-2",t==="button"&&["h-control-md rounded-md px-3 font-semibold no-underline hover:no-underline",bt[r]],n&&"pointer-events-none cursor-not-allowed text-text-disabled opacity-50",l),v={...h,href:n?void 0:x,target:m?"_blank":u,rel:m?"noopener noreferrer":j,"aria-disabled":n||void 0};return e.jsxs("a",{className:b,...v,children:[o,m&&e.jsx(R.ExternalLink,{className:"size-icon-sm shrink-0","aria-hidden":!0})]})},pt={sm:"h-control-sm px-3 text-sm",md:"h-control-md px-3 text-sm"};function _e({options:t,value:s,onChange:r,size:n="sm",tone:a="sunk",fullWidth:l=!1,className:o,"aria-label":x}){return e.jsx("div",{role:"tablist","aria-label":x,className:i("gap-0.5 rounded-md p-0.5",a==="track"?"bg-surface-track":"bg-surface-sunk",l?"flex w-full":"inline-flex",o),children:t.map(u=>{const j=u.value===s;return e.jsx("button",{role:"tab","aria-selected":j,type:"button",onClick:()=>r(u.value),className:i("inline-flex cursor-pointer items-center justify-center gap-1.5 rounded-sm","transition-colors duration-fast ease-out","focus-visible:outline-none focus-visible:focus-ring",l&&"min-w-0 flex-1",pt[n],j?"bg-surface text-text font-medium shadow-sm":"text-text-muted hover:text-text"),children:u.label},u.value)})})}const vt={primary:"bg-accent text-accent-fg hover:bg-accent-hover",secondary:"border border-border bg-surface text-text hover:bg-surface-hover",outline:"border border-accent-border text-accent hover:bg-accent-soft"},jt={sm:"h-control-sm w-7",md:"h-control-md w-8"};function ke({label:t,onClick:s,variant:r="primary",size:n="md",icon:a,options:l,disabled:o=!1,loading:x=!1,menuPlacement:u="bottom-end",menuLabel:j="More options"}){const h=o||x,m=l.length>0;return e.jsxs("div",{className:i("inline-flex items-center",r==="primary"&&"gap-px"),children:[e.jsx(re,{variant:r,size:n,onClick:s,disabled:o,loading:x,leftIcon:a,className:i(m&&"rounded-r-none"),children:t}),m&&e.jsx(we,{placement:u,disabled:h,triggerLabel:j,className:"min-w-menu py-1",trigger:e.jsx("span",{"aria-hidden":"true",className:i("inline-flex items-center justify-center rounded-md rounded-l-none","transition-colors duration-fast ease-out",vt[r],jt[n],h&&"cursor-not-allowed opacity-50"),children:e.jsx(R.ChevronDown,{className:"size-icon-md"})}),children:b=>e.jsx(e.Fragment,{children:l.map(v=>e.jsxs("button",{type:"button",onClick:()=>{v.onClick(),b()},className:i("flex w-full items-center gap-2 px-3 py-1.5 text-left text-sm","transition-colors duration-fast ease-out","focus-visible:outline-none focus-visible:focus-ring",v.variant==="destructive"?"text-danger-fg hover:bg-danger-soft":"text-text hover:bg-surface-hover"),children:[v.icon&&e.jsx("span",{className:"shrink-0",children:v.icon}),v.label]},v.id))})})]})}const yt={sm:"size-checkbox-sm",md:"size-checkbox",lg:"size-checkbox-lg",full:"size-checkbox"},Nt={sm:"min-h-control-sm",md:"min-h-control-md",lg:"min-h-control-lg",full:"min-h-control-md"},wt={sm:"text-sm",md:"text-base",lg:"text-md",full:"text-base"},xe=d.forwardRef(({label:t,helperText:s,error:r,size:n="md",indeterminate:a=!1,containerClassName:l,labelClassName:o,className:x,id:u,...j},h)=>{const m=d.useId(),b=u||`checkbox-${m}`,v=!!r,w=d.useRef(null),g=d.useCallback(f=>{w.current=f,typeof h=="function"?h(f):h&&typeof h=="object"&&(h.current=f)},[h]);return d.useEffect(()=>{w.current&&(w.current.indeterminate=a)},[a]),e.jsxs("div",{className:i("flex flex-col",l),children:[e.jsxs("div",{className:i("flex items-center gap-3",Nt[n]),children:[e.jsx("input",{ref:g,id:b,type:"checkbox","aria-invalid":v||void 0,className:i("shrink-0 rounded-xs border accent-accent","transition-colors duration-fast ease-out","focus-visible:outline-none focus-visible:focus-ring","disabled:cursor-not-allowed disabled:bg-surface-hover",yt[n],v?"border-danger-border":"border-border-strong",x),...j}),t&&e.jsxs("div",{className:"flex-1",children:[e.jsx("label",{htmlFor:b,className:i("cursor-pointer",v?"text-danger-fg":"text-text",wt[n],o),children:t}),s&&!r&&e.jsx("p",{className:"mt-0.5 text-xs text-text-subtle",children:s})]})]}),r&&e.jsx("p",{className:"mt-1 text-xs text-danger-fg",children:r})]})});xe.displayName="Checkbox";const kt=()=>e.jsx(Y,{icon:R.Calendar,size:"md",color:"current"}),Ct=()=>e.jsx(Y,{icon:R.ChevronLeft,size:"md",color:"current"}),St=()=>e.jsx(Y,{icon:R.ChevronRight,size:"md",color:"current"}),ge=d.forwardRef(({value:t,onChange:s,placeholder:r="Select date",disabled:n=!1,required:a=!1,size:l="md",className:o,minDate:x,maxDate:u,format:j="MM/dd/yyyy",withTime:h=!1},m)=>{const[b,v]=d.useState(!1),[w,g]=d.useState(()=>t||new Date),f=d.useRef(null),z=d.useRef(null),k=ve(b,z);d.useEffect(()=>{const c=C=>{f.current&&!f.current.contains(C.target)&&v(!1)};return b&&document.addEventListener("mousedown",c),()=>{document.removeEventListener("mousedown",c)}},[b]);const V=c=>{if(!c)return"";const C=c.getDate().toString().padStart(2,"0"),p=(c.getMonth()+1).toString().padStart(2,"0"),$=c.getFullYear(),y=j==="dd/MM/yyyy"?`${C}/${p}/${$}`:j==="yyyy-MM-dd"?`${$}-${p}-${C}`:`${p}/${C}/${$}`;return h?`${y} ${D(c)}`:y},D=c=>`${c.getHours().toString().padStart(2,"0")}:${c.getMinutes().toString().padStart(2,"0")}`,G=c=>{const[C,p]=c.split(":").map(Number);if(Number.isNaN(C)||Number.isNaN(p))return;const $=t?new Date(t):new Date;$.setHours(C,p,0,0),s?.($)},q=()=>{const c=w.getFullYear(),C=w.getMonth(),p=new Date(c,C,1),$=new Date(p);$.setDate($.getDate()-p.getDay());const y=[],U=new Date($);for(let te=0;te<42;te++)y.push(new Date(U)),U.setDate(U.getDate()+1);return y},L=c=>{if(c.getMonth()===w.getMonth()&&!(x&&c<x)&&!(u&&c>u)){if(h){const p=new Date(c);p.setHours(t?.getHours()??0,t?.getMinutes()??0,0,0),s?.(p);return}s?.(c),v(!1)}},H=()=>{g(new Date(w.getFullYear(),w.getMonth()-1,1))},ee=()=>{g(new Date(w.getFullYear(),w.getMonth()+1,1))},J=()=>{s?.(null),v(!1)},W=i("w-full border border-border-strong rounded-tile transition-colors duration-fast","bg-surface text-text","placeholder:text-text-muted","focus-visible:outline-none focus-visible:focus-ring","disabled:cursor-not-allowed disabled:bg-surface-hover disabled:text-text-disabled",{"h-control-sm px-3 text-sm":l==="sm","h-control-md px-3 text-base":l==="md","h-control-lg px-3 text-base":l==="lg","h-control-md w-full px-3 text-base":l==="full"},o),ae=q(),N=["January","February","March","April","May","June","July","August","September","October","November","December"];return e.jsxs("div",{ref:f,className:"relative",children:[e.jsxs("div",{ref:z,className:"relative",children:[e.jsx("input",{ref:m,type:"text",value:V(t??null),placeholder:r,disabled:n,required:a,readOnly:!0,onClick:()=>!n&&v(!b),className:i(W,"pr-10 cursor-pointer")}),e.jsx("button",{type:"button",onClick:()=>!n&&v(!b),disabled:n,className:"absolute inset-y-0 right-0 flex items-center pr-3 text-text-muted hover:text-text-muted",children:e.jsx(kt,{})})]}),b&&e.jsxs("div",{style:k,className:"fixed z-overlay overflow-auto rounded-lg border border-border bg-surface p-4 shadow-overlay min-w-panel",children:[e.jsxs("div",{className:"flex items-center justify-between mb-4",children:[e.jsx("button",{onClick:H,className:"p-1 hover:bg-surface-hover rounded",children:e.jsx(Ct,{})}),e.jsxs("h3",{className:"text-sm font-medium text-text",children:[N[w.getMonth()]," ",w.getFullYear()]}),e.jsx("button",{onClick:ee,className:"p-1 hover:bg-surface-hover rounded",children:e.jsx(St,{})})]}),e.jsx("div",{className:"grid grid-cols-7 gap-1 mb-2",children:["Su","Mo","Tu","We","Th","Fr","Sa"].map(c=>e.jsx("div",{className:"text-xs font-medium text-text-muted text-center py-1",children:c},c))}),e.jsx("div",{className:"grid grid-cols-7 gap-1",children:ae.map((c,C)=>{const p=c.getMonth()===w.getMonth(),$=t&&c.toDateString()===t.toDateString(),y=c.toDateString()===new Date().toDateString(),U=!p||x&&c<x||u&&c>u;return e.jsx("button",{onClick:()=>!U&&L(c),disabled:U,className:i("w-8 h-8 text-sm rounded transition-colors duration-fast",{"text-text hover:bg-surface-hover":p&&!$&&!U,"bg-accent text-accent-fg":$,"bg-surface-hover text-text":y&&!$,"text-text-muted cursor-not-allowed":U}),children:c.getDate()},C)})}),h&&e.jsxs("div",{className:"mt-3 flex items-center gap-2 border-t border-border pt-3",children:[e.jsx("label",{htmlFor:"datepicker-time",className:"text-sm text-text-muted",children:"Tijd"}),e.jsx("input",{id:"datepicker-time",type:"time",value:t?D(t):"",onChange:c=>G(c.target.value),className:"h-control-sm rounded-md border border-border bg-surface-input px-2 text-sm text-text focus-visible:outline-none focus-visible:focus-ring"})]}),e.jsxs("div",{className:"flex justify-between items-center mt-4 pt-3 border-t border-border",children:[e.jsx("button",{onClick:J,className:"text-sm text-text-muted hover:text-text",children:"Clear"}),e.jsx("button",{onClick:()=>v(!1),className:"text-sm text-info-fg hover:underline",children:"Close"})]})]})]})}),Et={sm:"h-control-sm px-3 text-sm",md:"h-control-md px-3 text-sm",lg:"h-control-lg px-3 text-base",full:"h-control-md w-full px-3 text-sm"},be=t=>t.trim().toLowerCase(),he=d.forwardRef(({label:t,helperText:s,error:r,size:n="md",fullWidth:a=!1,disabled:l=!1,options:o,placeholder:x,containerClassName:u,labelClassName:j,className:h,id:m,searchable:b,multiple:v,value:w,onChange:g,allowCreate:f,onCreateOption:z,...k},V)=>{const D=m||`select-${Math.random().toString(36).substr(2,9)}`,G=!!r,[q,L]=d.useState(!1),[H,ee]=d.useState(""),J=d.useRef(null),W=d.useRef(null),ae=ve(q,W,{matchWidth:!0}),[N,c]=d.useState(o);d.useImperativeHandle(V,()=>J.current),d.useEffect(()=>{const T=A=>{J.current&&!J.current.contains(A.target)&&L(!1)};return document.addEventListener("mousedown",T),()=>document.removeEventListener("mousedown",T)},[]);const C=d.useCallback((T,A)=>T.some(E=>be(E.value)===be(A)||be(E.label)===be(A)),[]),p=d.useCallback((T,A)=>{const E=[...T],I=F=>{const B=(F??"").trim();B&&(C(E,B)||E.push({value:B,label:B}))};return Array.isArray(A)?A.forEach(I):I(A),E},[C]);d.useEffect(()=>{c(T=>{const A=[...o];return T.forEach(E=>{!C(A,E.value)&&!C(A,E.label)&&A.push(E)}),p(A,w)})},[o,w,p,C]);const $=T=>{if(v){const A=Array.isArray(w)?w:[],E=A.includes(T)?A.filter(I=>I!==T):[...A,T];g?.(E)}else g?.(T),L(!1),ee("")},y=v?null:N.find(T=>T.value===w),U=v?N.filter(T=>Array.isArray(w)&&w.includes(T.value)):[],te=b&&H?N.filter(T=>T.label.toLowerCase().includes(H.toLowerCase())):N,Q=!!f&&!!b&&!!H.trim()&&!C(N,H),X=T=>{const A=T.trim();if(!A)return;const E=z?.(A)??{value:A,label:A};if(C(N,E.value)||C(N,E.label)){$(E.value),ee(""),v||L(!1);return}c(I=>[...I,E]),$(E.value),ee(""),v||L(!1)},P=()=>v?U.length>0?U.map(T=>T.label).join(", "):x||"Select options":y?.label||x||"Select an option";return e.jsxs("div",{ref:J,className:i("relative flex flex-col",a&&"w-full",u),...k,children:[t&&e.jsx("label",{htmlFor:D,onClick:()=>L(!q),className:i("block text-xs font-semibold uppercase tracking-label mb-1.5",G?"text-danger-fg":"text-text-muted",j),children:t}),e.jsxs("div",{className:"relative",children:[e.jsxs("button",{ref:W,type:"button",id:D,disabled:l,onClick:()=>L(!q),className:i("flex w-full items-center justify-between gap-2 rounded-tile border transition-colors duration-fast text-left","focus-visible:outline-none focus-visible:focus-ring","disabled:cursor-not-allowed disabled:bg-surface-hover disabled:text-text-disabled","bg-surface",Et[n],G?"border-danger-border text-danger-fg focus-visible:focus-ring":"border-border-strong text-text",h),children:[e.jsx("span",{className:"truncate flex-1 min-w-0",children:P()}),e.jsx(R.ChevronDownIcon,{size:16,className:i("shrink-0 opacity-60 transition-transform duration-fast",q&&"rotate-180")})]}),q&&e.jsxs("div",{style:ae,className:"fixed z-overlay flex flex-col overflow-hidden rounded-lg border border-border bg-surface shadow-overlay",children:[b&&e.jsx("div",{className:"p-2",children:e.jsx("input",{type:"text",placeholder:"Search...",value:H,onChange:T=>ee(T.target.value),onKeyDown:T=>{T.key==="Enter"&&Q&&(T.preventDefault(),X(H))},className:i("w-full px-3 py-2 text-sm rounded-md border","text-text border-border focus-visible:outline-none focus-visible:focus-ring")})}),Q&&e.jsxs("div",{className:i("cursor-pointer px-3 py-1.5 text-sm","text-info-fg hover:bg-surface-hover"),onClick:()=>X(H),children:["+: “",H.trim(),"”"]}),e.jsxs("ul",{className:"min-h-0 flex-1 overflow-auto py-1",children:[x&&!v&&e.jsx("li",{className:"cursor-pointer px-3 py-1.5 text-sm text-text-muted hover:bg-surface-hover",onClick:()=>{g?.(""),L(!1)},children:x}),te.map(T=>{const A=v?Array.isArray(w)&&w.includes(T.value):w===T.value;return e.jsx("li",{onClick:()=>!T.disabled&&$(T.value),className:i("cursor-pointer px-3 py-1.5 text-sm","text-text",T.disabled?"opacity-50 cursor-not-allowed":"hover:bg-surface-hover",A&&"bg-accent-soft text-accent font-semibold"),children:e.jsxs("div",{className:"flex items-center",children:[v&&e.jsx("input",{type:"checkbox",checked:A,readOnly:!0,className:"mr-3 h-4 w-4 rounded border-border [&:not(:checked)]:bg-surface-input text-accent "}),e.jsx("span",{children:T.label})]})},T.value)})]})]})]}),(r||s)&&e.jsx("p",{className:i("mt-1 text-xs",G?"text-danger-fg":"text-text-muted"),children:r||s})]})});he.displayName="Select";const Mt={sm:"h-control-sm px-3 text-sm",md:"h-control-md px-3 text-base",lg:"h-control-lg px-3 text-base",full:"h-control-md px-3 text-base"},Re="mb-1.5 block text-sm font-medium",Le="block w-full rounded-tile border bg-surface-input text-text transition-colors duration-fast ease-out placeholder:text-text-subtle focus-visible:outline-none focus-visible:focus-ring disabled:cursor-not-allowed disabled:bg-surface-hover disabled:text-text-disabled",Pe=t=>t?"border-danger-border bg-danger-soft":"border-border-strong",me=d.forwardRef(({label:t,helperText:s,error:r,size:n="md",fullWidth:a=!1,startIcon:l,endIcon:o,loading:x=!1,containerClassName:u,labelClassName:j,className:h,id:m,...b},v)=>{const w=d.useId(),g=m||`textfield-${w}`,f=!!r,z=r||s?`${g}-description`:void 0;return e.jsxs("div",{className:i("flex flex-col",a&&"w-full",u),children:[t&&e.jsx("label",{htmlFor:g,className:i(Re,f?"text-danger-fg":"text-text-muted",j),children:t}),e.jsxs("div",{className:"relative",children:[l&&e.jsx("span",{className:"pointer-events-none absolute inset-y-0 left-0 flex items-center pl-3 text-text-muted",children:l}),e.jsx("input",{ref:v,id:g,"aria-invalid":f||void 0,"aria-describedby":z,className:i(Le,Mt[n],l&&"pl-9",(o||x)&&"pr-9",Pe(f),h),...b}),(o||x)&&e.jsx("span",{className:"absolute inset-y-0 right-0 flex items-center pr-3 text-text-muted",children:x?e.jsx("span",{"aria-hidden":!0,className:"size-icon-md animate-spin rounded-full border-2 border-border border-t-transparent"}):o})]}),(r||s)&&e.jsx("p",{id:z,className:i("mt-1 text-xs",f?"text-danger-fg":"text-text-subtle"),children:r||s})]})});me.displayName="TextField";function Fe({value:t,onChange:s,onListFolders:r,disabled:n,size:a="md",placeholder:l,templatePlaceholder:o,showTemplate:x=!0}){const[u,j]=d.useState([]);d.useEffect(()=>{let m=!0;return Promise.resolve(r?.()).then(b=>{m&&b&&j(b.data??[])}).catch(()=>{}),()=>{m=!1}},[]);const h=t??{};return e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsx(he,{size:a,fullWidth:!0,value:h.folderId??"",options:u.map(m=>({value:m.id,label:m.name})),placeholder:l??"Select a folder",onChange:m=>s?.({...h,folderId:m})}),x&&e.jsx(me,{size:a,disabled:n??!1,value:h.pathTemplate??"",placeholder:o??"Sub-path e.g. {yyyy}/{mm}/{dd} (optional)",onChange:m=>s?.({...h,pathTemplate:m.target.value})})]})}const fe=(...t)=>t.filter(Boolean).join(" "),zt=t=>e.jsx(R.Search,{...t,strokeWidth:1.5,"aria-hidden":!0}),Tt=t=>e.jsx(R.ChevronDown,{...t,strokeWidth:1.5,"aria-hidden":!0}),Dt={sm:"h-control-sm px-3 text-sm",md:"h-control-md px-3 text-base",lg:"h-control-lg px-3 text-base",full:"h-control-md w-full px-3 text-base"},ye={sm:"h-4 w-4",md:"h-5 w-5",lg:"h-6 w-6",full:"h-6 w-6"},Ie=d.forwardRef(({label:t,helperText:s,error:r,size:n="md",fullWidth:a=!1,startIcon:l=e.jsx(zt,{}),loading:o=!1,containerClassName:x,labelClassName:u,className:j,id:h,options:m,onRemoteSearch:b,onSelect:v,debounceTime:w=500,showAllOnOpen:g=!1,value:f,onChange:z,...k},V)=>{const D=h||`searchfield-${Math.random().toString(36).substr(2,9)}`,G=!!r,q=d.useRef(null),L=d.useRef(null),[H,ee]=d.useState(f||""),[J,W]=d.useState(!1),[ae,N]=d.useState(!1),[c,C]=d.useState(!1);d.useEffect(()=>{f!==void 0&&ee(f)},[f]);const p=d.useMemo(()=>{if(g&&!c||!H)return m;const P=String(H).toLowerCase();return m.filter(T=>String(T.label).toLowerCase().includes(P))},[H,m,g,c]);d.useEffect(()=>{if(!b||!H){N(!1);return}const P=setTimeout(async()=>{N(!0);try{await b(String(H))}catch(T){console.error("Remote search failed:",T)}finally{N(!1)}},w);return()=>{clearTimeout(P),N(!1)}},[H,w,b]),d.useEffect(()=>{const P=T=>{q.current&&!q.current.contains(T.target)&&W(!1)};return document.addEventListener("mousedown",P),()=>document.removeEventListener("mousedown",P)},[]);const $=P=>{const T=P.target.value;ee(T),W(!0),C(!0),z&&z(P)},y=P=>{ee(P.label),W(!1),C(!1),v&&v(P.value)},U=()=>{(m.length>0||b)&&(W(!0),C(!1))},te=o||ae,Q=J&&(p.length>0||te),X=d.useMemo(()=>V||L,[V]);return e.jsxs("div",{className:fe("flex flex-col",a?"w-full":"",x||"","relative"),ref:q,children:[t&&e.jsx("label",{htmlFor:D,className:fe("block text-sm font-medium mb-1",G?"text-danger-fg":"text-text",u||""),children:t}),e.jsxs("div",{className:"relative",children:[l&&e.jsx("div",{className:"absolute left-0 pl-3 flex items-center pointer-events-none h-full",children:e.jsx("span",{className:fe("text-text-muted",ye[n]),children:l})}),e.jsx("input",{ref:X,id:D,value:H,onChange:$,onFocus:U,className:fe("block w-full rounded-tile border bg-surface-input transition-colors duration-fast ease-out","placeholder:text-text-subtle focus-visible:outline-none focus-visible:focus-ring","disabled:cursor-not-allowed disabled:bg-surface-hover disabled:text-text-disabled",Dt[n],l?"pl-10":"","pr-10",G?"border-danger-border text-danger-fg focus-visible:focus-ring":"border-border-strong text-text",j||""),...k}),e.jsx("div",{className:"absolute inset-y-0 right-0 pr-3 flex items-center",children:te||o?e.jsx(R.Loader2,{className:fe("animate-spin text-info-fg",ye[n]),"aria-hidden":!0}):e.jsx(Tt,{className:fe("text-text-muted cursor-pointer transition-transform",ye[n],J?"rotate-180":"rotate-0"),onClick:()=>{W(P=>(P||C(!1),!P))}})})]}),Q&&e.jsx("ul",{className:"absolute z-10 mt-1 w-full bg-surface border border-border rounded-lg shadow-lg max-h-60 overflow-auto top-full",role:"listbox",children:p.length>0?p.map(P=>e.jsx("li",{className:"px-4 py-2 cursor-pointer text-text hover:bg-accent-soft hover:text-accent transition-colors",onClick:()=>y(P),role:"option","aria-selected":H===P.label,children:P.label},P.value)):e.jsx("li",{className:"px-4 py-2 text-text-muted",children:te||o?"Zoeken op afstand...":"Geen resultaten gevonden."})}),(r||s)&&e.jsx("p",{className:fe("mt-1 text-xs",G?"text-danger-fg":"text-text-muted"),children:r||s}),b&&e.jsxs("p",{className:"mt-2 text-xs text-success-fg",children:["Huidige zoekterm (niet-gedebounced): ",String(H)]})]})});Ie.displayName="SearchableTextField";const Ce=d.forwardRef(({value:t,onValueChange:s,hint:r,size:n="md",clearLabel:a="Clear search",containerClassName:l,className:o,disabled:x,...u},j)=>e.jsxs("div",{className:i("flex items-center gap-2 rounded-md bg-surface-sunk px-2.5 text-text-muted","transition-colors duration-fast ease-out",n==="sm"?"h-control-sm":"h-control-md",x&&"opacity-60",l),children:[e.jsx(Y,{icon:R.Search,size:"md",color:"current",className:"shrink-0"}),e.jsx("input",{ref:j,type:"search",value:t,disabled:x,onChange:h=>s(h.target.value),className:i("min-w-0 flex-1 border-0 bg-transparent p-0 text-sm text-text shadow-none","placeholder:text-text-subtle","focus:border-0 focus:shadow-none focus:outline-none focus:ring-0","[&::-webkit-search-cancel-button]:appearance-none",o),...u}),t?e.jsx("button",{type:"button","aria-label":a,onClick:()=>s(""),className:"grid size-4 shrink-0 cursor-pointer place-items-center rounded-xs text-text-subtle transition-colors duration-fast ease-out hover:text-text focus-visible:outline-none focus-visible:focus-ring",children:e.jsx(Y,{icon:R.X,size:"sm",color:"current"})}):r&&e.jsx("span",{className:"shrink-0 text-xs text-text-subtle",children:r})]}));Ce.displayName="SearchField";const Be=d.forwardRef(({checked:t,onChange:s,label:r,disabled:n=!1,className:a,...l},o)=>{const x=e.jsx("span",{"aria-hidden":!0,className:i("relative inline-flex size-switch-track shrink-0 items-center rounded-full","transition-colors duration-fast ease-out",t?"bg-accent":"bg-surface-hover",n&&"opacity-50"),children:e.jsx("span",{className:i("absolute left-0.5 size-switch-knob rounded-full bg-surface shadow-overlay","transition-transform duration-fast ease-out",t&&"translate-switch")})});return e.jsxs("label",{className:i("inline-flex items-center gap-2",n?"cursor-not-allowed":"cursor-pointer",a),children:[e.jsx("input",{ref:o,type:"checkbox",role:"switch",checked:t,disabled:n,onChange:u=>s(u.target.checked),className:"peer sr-only",...l}),e.jsx("span",{className:"inline-flex rounded-full peer-focus-visible:focus-ring",children:x}),r&&e.jsx("span",{className:"text-sm text-text",children:r})]})});Be.displayName="Switch";function Oe({variant:t="page",children:s,showTableSkeleton:r=!1,tableColumns:n=6,tableRows:a=8}){const l=({children:o})=>t==="inline"?e.jsx(e.Fragment,{children:o}):e.jsx("main",{className:"flex-1 bg-surface p-6",children:o});return s?e.jsx(l,{children:e.jsx("div",{className:"w-full max-w-6xl mx-auto animate-pulse",children:s})}):e.jsx(l,{children:e.jsxs("div",{className:"w-full mx-auto space-y-6 animate-pulse",children:[!r&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"h-6 w-1/4 rounded-sm bg-surface-hover"}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("div",{className:"h-4 w-3/4 rounded-sm bg-surface-hover"}),e.jsx("div",{className:"h-4 w-1/2 rounded-sm bg-surface-hover"})]})]}),r&&e.jsxs("div",{className:"rounded-lg overflow-hidden",children:[e.jsx("div",{className:"grid gap-2 bg-surface-hover p-3",style:{gridTemplateColumns:`repeat(${n}, minmax(0, 1fr))`},children:Array.from({length:n}).map((o,x)=>e.jsx("div",{className:"h-4 w-2/3 rounded-sm bg-border-strong"},`header-${x}`))}),Array.from({length:a}).map((o,x)=>e.jsx("div",{className:"grid gap-2 border-t border-border-subtle p-3",style:{gridTemplateColumns:`repeat(${n}, minmax(0, 1fr))`},children:Array.from({length:n}).map((u,j)=>e.jsx("div",{className:"h-4 w-full rounded-sm bg-surface-hover"},`cell-${x}-${j}`))},`row-${x}`))]})]})})}const He=({trigger:t,options:s,value:r,onSelect:n,placement:a="bottom-start",disabled:l=!1,className:o,showCheck:x=!0,header:u})=>{const[j,h]=d.useState(!1),[m,b]=d.useState(null),[v,w]=d.useState({top:0,left:0}),g=d.useRef(null),f=d.useRef(null),z=d.useRef(null),k=d.useRef(null),V=ve(j,f,{placement:a}),D=d.useRef(null),G=()=>Array.from(k.current?.querySelectorAll("button[data-option-value]:not(:disabled)")??[]);d.useEffect(()=>{j&&G()[0]?.focus()},[j]);const q=c=>{if(!["ArrowDown","ArrowUp","Home","End"].includes(c.key))return;const p=G();if(p.length===0)return;c.preventDefault();const $=p.indexOf(document.activeElement),y=c.key==="Home"?0:c.key==="End"?p.length-1:c.key==="ArrowDown"?($+1)%p.length:($-1+p.length)%p.length;p[y]?.focus()};d.useEffect(()=>{const c=C=>{g.current&&(!g.current.contains(C.target)||z.current&&!z.current.contains(C.target))&&(h(!1),b(null),D.current&&(clearTimeout(D.current),D.current=null))};return j&&document.addEventListener("mousedown",c),()=>{document.removeEventListener("mousedown",c)}},[j]),d.useEffect(()=>{const c=C=>{C.key==="Escape"&&(h(!1),b(null),f.current?.focus(),D.current&&(clearTimeout(D.current),D.current=null))};return j&&document.addEventListener("keydown",c),()=>{document.removeEventListener("keydown",c)}},[j]),d.useEffect(()=>{if(m&&g.current){const c=g.current.querySelector(`[data-option-value="${m}"]`);if(c){const C=c.getBoundingClientRect();w({top:C.top,left:C.right+8})}}},[m]),d.useEffect(()=>()=>{D.current&&clearTimeout(D.current)},[]);const L=c=>{c.stopPropagation(),!l&&(h(!j),b(null),D.current&&(clearTimeout(D.current),D.current=null))},H=(c,C,p)=>{c.stopPropagation(),!C.disabled&&!C.divider&&(!C.children||C.children.length===0)&&(n?.(C.value,p),h(!1),b(null))},ee=c=>{D.current&&(clearTimeout(D.current),D.current=null),c.children&&c.children.length>0?b(c.value):b(null)},J=c=>{c.children&&c.children.length>0?D.current=setTimeout(()=>{b(null)},150):b(null)},W=(c,C,p)=>{c.stopPropagation(),!C.disabled&&!C.divider&&(n?.(C.value,p),h(!1),b(null))},ae=i("fixed z-overlay min-w-menu bg-surface rounded-lg shadow-overlay border border-border","max-h-60 overflow-auto"),N=i("fixed z-overlay min-w-menu bg-surface rounded-lg shadow-overlay border border-border","max-h-60 overflow-auto");return e.jsxs("div",{ref:g,className:i("relative flex flex-row items-center justify-center rounded-lg hover:bg-surface-hover",o),children:[e.jsx("button",{ref:f,onClick:L,disabled:l,"aria-haspopup":"menu","aria-expanded":j,className:i("inline-flex items-center justify-center",{"opacity-50 cursor-not-allowed":l}),children:t}),j&&e.jsx("div",{ref:k,className:ae,style:V,onKeyDown:q,children:e.jsxs("div",{className:"p-2",role:"menu",children:[u&&(typeof u=="string"?e.jsx("div",{className:"text-xs font-medium text-text-muted uppercase tracking-label px-3 py-2",children:u}):u),s.map((c,C)=>{if(c.divider)return e.jsx("div",{className:"border-t border-border my-2"},`divider-${C}`);const p=c.children&&c.children.length>0,$=m===c.value;return e.jsxs("div",{className:"relative group",children:[e.jsxs("button",{"data-option-value":c.value,role:"menuitem","aria-haspopup":p?"menu":void 0,onClick:y=>H(y,c),onMouseEnter:()=>ee(c),onMouseLeave:()=>J(c),disabled:c.disabled,className:i("flex w-full items-center justify-between rounded-md px-3 py-1.5 text-sm text-text transition-colors duration-fast ease-out hover:bg-surface-hover focus-visible:outline-none focus-visible:focus-ring",{"opacity-50 cursor-not-allowed":c.disabled,"bg-surface-hover":$&&p}),children:[e.jsxs("div",{className:"flex items-center space-x-2 min-w-0",children:[c.icon&&e.jsx("span",{className:"flex-shrink-0",children:c.icon}),e.jsxs("div",{className:"flex flex-col items-start min-w-0",children:[e.jsx("span",{className:"font-base truncate",children:c.label}),c.description&&e.jsx("span",{className:"text-xs text-text-muted",children:c.description})]})]}),e.jsxs("div",{className:"flex items-center space-x-2",children:[x&&r===c.value&&e.jsx(R.Check,{className:"size-icon-md shrink-0 text-success-fg","aria-hidden":!0}),p&&e.jsx("span",{className:"text-text-muted text-xs",children:"▶"})]})]}),p&&$&&e.jsx("div",{ref:z,className:N,style:{top:`${v.top}px`,left:`${v.left}px`},onMouseEnter:()=>{D.current&&(clearTimeout(D.current),D.current=null),b(c.value)},onMouseLeave:()=>{D.current=setTimeout(()=>{b(null)},150)},children:e.jsx("div",{className:"p-2",children:c.children.map((y,U)=>{if(y.divider)return e.jsx("div",{className:"border-t border-border my-2"},`divider-${U}`);const te=typeof r=="object"&&r[c.value]&&r[c.value].includes(y.value)||r===y.value;return e.jsxs("button",{onClick:Q=>W(Q,y,c.value),disabled:y.disabled,className:i("flex w-full items-center justify-between rounded-md px-3 py-1.5 text-sm text-text transition-colors duration-fast ease-out hover:bg-surface-hover",{"opacity-50 cursor-not-allowed":y.disabled}),children:[e.jsxs("div",{className:"flex items-center space-x-2 min-w-0",children:[y.icon&&e.jsx("span",{className:"flex-shrink-0",children:y.icon}),e.jsxs("div",{className:"flex flex-col items-start min-w-0",children:[e.jsx("span",{className:"font-base truncate",children:y.label}),y.description&&e.jsx("span",{className:"text-xs text-text-muted",children:y.description})]})]}),x&&te&&e.jsx(R.Check,{className:"size-icon-md shrink-0 text-success-fg","aria-hidden":!0})]},y.value)})})})]},c.value)}),(()=>{const c=s.reduce((C,p)=>{if(p.divider)return C;const $=p.children?p.children.filter(y=>!y.divider).length:0;return C+1+$},0);return c>1&&e.jsx("div",{className:"border-t border-border mt-2 pt-2",children:e.jsxs("div",{className:"text-xs text-text-muted px-3 py-1",children:[c," options available"]})})})()]})})]})},Se=({actions:t,defaultVariant:s="secondary",className:r})=>t.length===0?null:e.jsx("div",{className:i("flex flex-wrap items-center gap-2",r),children:t.map(n=>n.render?e.jsx(d.Fragment,{children:n.render()},n.id):n.splitOptions&&n.splitOptions.length>0?e.jsx(ke,{label:n.label,onClick:n.onClick,icon:n.icon,variant:n.variant==="primary"?"primary":"secondary",options:n.splitOptions,disabled:n.disabled},n.id):e.jsx(re,{variant:n.variant??s,onClick:a=>{a.stopPropagation(),a.target.blur(),n.onClick()},disabled:n.disabled,leftIcon:n.icon,children:n.label},n.id))}),$t={none:"p-0",sm:"p-2",md:"px-5 py-4",lg:"p-6"},At=({actions:t=[],onBack:s,backLabel:r="Back",className:n,padding:a="md",children:l})=>e.jsxs("div",{className:i("flex items-center gap-2",$t[a],n),children:[s&&e.jsx(re,{variant:"secondary",onClick:s,"aria-label":r,leftIcon:e.jsx(Y,{icon:R.ChevronLeft,size:"sm"}),iconOnly:!0}),l&&e.jsx("div",{className:"min-w-0 flex-1",children:l}),e.jsx(Se,{actions:t,className:i(!l&&"ml-auto")})]}),_t=t=>s=>t(s instanceof Date?s:null),Rt=t=>s=>t(typeof s=="string"?s:""),Lt={none:"px-0",sm:"px-2",md:"px-3.5",lg:"px-5"},Pt={sm:"h-row-lg",md:"h-row-xl",lg:"h-14"};function Ft(t,s){if(s<=7)return Array.from({length:s},(l,o)=>o);const n=[...new Set([0,s-1,t-1,t,t+1])].filter(l=>l>=0&&l<s).sort((l,o)=>l-o),a=[];return n.forEach((l,o)=>{o>0&&l-n[o-1]>1&&a.push("gap"),a.push(l)}),a}const It=t=>{const s=Array.isArray(t.value)?t.value:t.value!=null&&t.value!==""&&t.value!=="all"?[t.value]:[];if(t.type==="date"){const o=t.value instanceof Date;return e.jsx(ge,{value:t.value,onChange:x=>t.onChange(x),placeholder:t.placeholder||t.label,className:i("min-w-40",o&&"bg-info-soft text-info-fg")})}const r=o=>t.options?.find(x=>x.value===o)?.label??String(o),n=o=>Array.isArray(t.value)?t.value.includes(o):t.value===o,a=o=>{if(!t.multiSelect)return t.onChange(o);const x=Array.isArray(t.value)?t.value:[];t.onChange(x.includes(o)?x.filter(u=>u!==o):[...x,o])},l=s.length>0;return e.jsx(Ae,{tone:"outline",caret:!0,icon:t.icon,active:l,label:l?`${t.label}: ${s.map(r).join(", ")}`:t.label,title:t.label,onClear:()=>t.onChange(t.multiSelect?[]:"all"),menu:o=>e.jsx("div",{role:"listbox",className:"flex flex-col",children:t.options?.map(x=>e.jsx("button",{type:"button",role:"option","aria-selected":n(x.value),onClick:()=>{a(x.value),t.multiSelect||o()},className:i("flex cursor-pointer items-center gap-2 rounded-md px-2.5 py-1.5 text-left text-sm","transition-colors duration-fast ease-out hover:bg-surface-hover","focus-visible:outline-none focus-visible:focus-ring",n(x.value)?"font-medium text-text":"text-text-muted"),children:x.label},x.value))})})},Ne=({data:t,columns:s,loading:r=!1,searchable:n=!1,searchPlaceholder:a="Search...",searchValue:l,onSearchChange:o,filters:x=[],toolbarActions:u=[],paginated:j=!1,defaultPageSize:h=10,actions:m=[],onRowClick:b,selectable:v=!1,selectedRows:w=[],onSelectionChange:g,getRowKey:f=(ee,J)=>J,emptyContent:z,footerSummary:k,size:V="md",hoverable:D=!0,padding:G="md",className:q,rowClassName:L,headerBackground:H=!0})=>{const[ee,J]=d.useState(""),W=l!==void 0,ae=W?l:ee,N=o??J,[c,C]=d.useState({column:null,direction:null}),[p,$]=d.useState({page:0,pageSize:h}),y=d.useRef(null),U=d.useMemo(()=>{let S=t;if(n&&!W&&ae.trim()){const K=s.filter(le=>le.searchable!==!1),ne=ae.toLowerCase();S=S.filter(le=>K.some(O=>{const ce=typeof O.accessor=="function"?O.accessor(le):le[O.accessor];return String(ce||"").toLowerCase().includes(ne)}))}return x.forEach(K=>{K.value&&K.value!=="all"&&(S=S.filter(ne=>{const le=s.find(ce=>ce.id===K.id);if(!le)return!0;const O=typeof le.accessor=="function"?le.accessor(ne):ne[le.accessor];return String(O||"")===K.value}))}),S},[t,ae,W,s,n,x]),te=d.useMemo(()=>{if(!c.column||!c.direction)return U;const S=s.find(K=>K.id===c.column);return S?[...U].sort((K,ne)=>{const le=typeof S.accessor=="function"?S.accessor(K):K[S.accessor],O=typeof S.accessor=="function"?S.accessor(ne):ne[S.accessor];let ce=0;return le<O?ce=-1:le>O&&(ce=1),c.direction==="desc"?-ce:ce}):U},[U,c,s]),Q=d.useMemo(()=>{if(!j)return te;const S=p.page*p.pageSize,K=S+p.pageSize;return te.slice(S,K)},[te,p,j]),X=d.useCallback(S=>{s.find(ne=>ne.id===S)?.sortable&&C(ne=>ne.column!==S?{column:S,direction:"asc"}:ne.direction==="asc"?{column:S,direction:"desc"}:{column:null,direction:null})},[s]),P=d.useCallback(S=>{$(K=>({...K,page:S}))},[]),T=d.useCallback((S,K)=>{if(!g)return;const ne=f(S,0);g(K?[...w,S]:w.filter((le,O)=>f(w[O],O)!==ne))},[w,g,f]),A=d.useCallback(S=>{g&&g(S?[...Q]:[])},[Q,g]);d.useEffect(()=>{$(S=>({...S,page:0}))},[ae,c]),d.useEffect(()=>{$(S=>({...S,page:0}))},[x.map(S=>S.value).join(",")]);const E=te.length,I=Math.ceil(E/p.pageSize),F=p.page*p.pageSize+1,B=Math.min(F+p.pageSize-1,E),M=Q.length>0&&Q.every(S=>{const K=f(S,0);return w.some((ne,le)=>f(ne,le)===K)}),_=Q.some(S=>{const K=f(S,0);return w.some((ne,le)=>f(ne,le)===K)}),Z=Lt[G],se=H?"bg-surface-sunk":"bg-surface",oe=i("text-text",Z),ue=n||x.length>0||u.length>0,de=j&&E>0,je=de||k!==void 0;return e.jsxs("div",{className:i("flex min-w-0 flex-col",q),children:[ue&&e.jsxs("div",{className:"flex flex-wrap items-center gap-2 pb-3",children:[n&&e.jsx(Ce,{value:ae,onValueChange:N,placeholder:a,containerClassName:"w-full sm:w-66"}),x.map(S=>e.jsx(It,{...S},S.id)),u.length>0&&e.jsx(Se,{actions:u,className:"ml-auto"})]}),e.jsxs("div",{className:"relative w-full overflow-x-auto rounded-lg ring-1 ring-border",children:[r&&e.jsx("div",{className:"flex items-center justify-center",children:e.jsx(Oe,{showTableSkeleton:!0,tableRows:10,tableColumns:s.length})}),e.jsxs("table",{ref:y,className:"min-w-full border-collapse text-base text-text",children:[e.jsx("thead",{className:i(se,"h-control-lg"),children:e.jsxs("tr",{children:[v&&e.jsx("th",{className:i(oe,"w-10"),children:e.jsx(xe,{size:"sm",checked:M,indeterminate:_&&!M,onChange:S=>A(S.target.checked),"aria-label":"Select all rows"})}),!r&&s.map(S=>e.jsx("th",{className:i(oe,"text-xs font-semibold uppercase tracking-label text-text-muted","group",{"text-left":S.align==="left"||!S.align,"text-center":S.align==="center","text-right":S.align==="right","cursor-pointer select-none":S.sortable,[`sticky left-0 ${se}`]:S.sticky==="left",[`sticky right-0 ${se}`]:S.sticky==="right"}),style:{width:S.width},onClick:()=>S.sortable&&X(S.id),children:e.jsxs("div",{className:"flex items-center gap-1.5",children:[S.headerCell?S.headerCell():S.header,S.sortable&&e.jsx(Y,{icon:c.column===S.id&&c.direction==="desc"?R.ChevronDown:R.ChevronUp,size:"xs",className:i("transition-opacity duration-fast ease-out",c.column===S.id?"text-text opacity-100":"text-text-subtle opacity-0 group-hover:opacity-100")})]})},S.id)),m.length>0&&e.jsx("th",{className:i(oe,"w-10"),children:e.jsx("span",{className:"sr-only",children:"Actions"})})]})}),e.jsx("tbody",{children:Q.length===0||r?!r&&e.jsx("tr",{children:e.jsx("td",{colSpan:s.length+(v?1:0)+(m.length>0?1:0),className:i(oe,"border-t border-border-subtle py-10 text-center text-text-muted"),children:z||"No data available"})}):Q.map((S,K)=>{const ne=f(S,K),le=w.some((O,ce)=>f(O,ce)===ne);return e.jsxs("tr",{className:i(Pt[V],"border-t border-border-subtle",D&&"transition-colors duration-fast ease-out hover:bg-surface-hover",b&&"cursor-pointer",le&&"bg-accent-soft",L?.(S,K)),onClick:O=>{O.stopPropagation(),b?.(S,K)},children:[v&&e.jsx("td",{className:oe,children:e.jsx(xe,{size:"sm",checked:le,onClick:O=>O.stopPropagation(),onChange:O=>{O.stopPropagation(),T(S,O.target.checked)},"aria-label":"Select row"})}),s.map(O=>{const ce=typeof O.accessor=="function"?O.accessor(S):S[O.accessor];return e.jsx("td",{className:i(oe,{"text-left":O.align==="left"||!O.align,"text-center":O.align==="center","text-right":O.align==="right","sticky left-0 bg-surface":O.sticky==="left","sticky right-0 bg-surface":O.sticky==="right"}),children:O.cell?O.cell(ce,S,K):String(ce||"")},O.id)}),m.length>0&&e.jsx("td",{className:oe,children:e.jsx(He,{className:"rounded-md",trigger:e.jsx("span",{className:"grid size-7 place-items-center text-text-subtle",children:e.jsx(Y,{icon:R.Ellipsis,size:"md",color:"current"})}),options:m.map(O=>({value:O.id,label:O.label,icon:O.icon,disabled:O.disabled?.(S)})),onSelect:O=>{const ce=m.find(Ge=>Ge.id===O);ce&&ce.onClick(S,K)},placement:"bottom-end"})})]},ne)})})]})]}),je&&e.jsxs("div",{className:"flex flex-wrap items-center gap-3 px-1 pt-3 text-xs text-text-muted",children:[e.jsx("span",{className:"min-w-0 flex-1",children:k??`Showing ${F}–${B} of ${E}`}),de&&e.jsxs("div",{className:"flex items-center gap-0.5",children:[e.jsx(re,{size:"xs",variant:"ghost",iconOnly:!0,"aria-label":"Previous page",onClick:()=>P(p.page-1),disabled:p.page===0,children:e.jsx(Y,{icon:R.ChevronLeft,size:"md",color:"current"})}),Ft(p.page,I).map((S,K)=>S==="gap"?e.jsx("span",{className:"px-1 text-text-subtle",children:"…"},`gap-${K}`):e.jsx("button",{type:"button","aria-current":S===p.page?"page":void 0,onClick:()=>P(S),className:i("h-control-xs min-w-6 cursor-pointer rounded-sm px-1.5 tabular-nums","transition-colors duration-fast ease-out","focus-visible:outline-none focus-visible:focus-ring",S===p.page?"bg-surface-sunk font-semibold text-text":"text-text-muted hover:bg-surface-hover hover:text-text"),children:S+1},S)),e.jsx(re,{size:"xs",variant:"ghost",iconOnly:!0,"aria-label":"Next page",onClick:()=>P(p.page+1),disabled:p.page>=I-1,children:e.jsx(Y,{icon:R.ChevronRight,size:"md",color:"current"})})]})]})]})},Bt=d.createContext(null),Ot=({items:t,activeTab:s,onTabChange:r,className:n})=>{const[a,l]=d.useState(t[0]?.id||""),o=s||a,x=u=>{r?r(u):l(u)};return e.jsx("div",{className:i("border-b border-border",n),children:e.jsx("nav",{className:"-mb-px flex space-x-8",children:t.map(u=>e.jsx("button",{onClick:()=>!u.disabled&&x(u.id),disabled:u.disabled,className:i("border-b-2 py-2 px-1 text-sm font-medium transition-colors duration-fast",{"border-accent-border text-text":o===u.id,"border-transparent text-text-muted hover:text-text":o!==u.id&&!u.disabled,"border-transparent text-disabled cursor-not-allowed":u.disabled}),children:e.jsxs("span",{className:"flex items-center gap-2",children:[u.label,u.badge&&e.jsx("span",{className:i("inline-flex items-center px-2 py-0.5 rounded-full text-xs font-medium",o===u.id?"bg-accent-soft text-accent":"bg-surface-hover text-text-muted"),children:u.badge})]})},u.id))})})},qe=({items:t,defaultTab:s,activeTab:r,onTabChange:n,variant:a="default",size:l="md",className:o})=>{const[x,u]=d.useState(s||r||t[0]?.id||""),j=r||x,h=g=>{n?n(g):u(g)},m={activeTab:j,setActiveTab:h},b=t.find(g=>g.id===j),v=i("flex",{"border-b border-border px-2":a==="default"||a==="underline","bg-surface-hover p-1 rounded-lg":a==="pills","space-x-1":a==="pills","space-x-8":a==="default"||a==="underline"},o),w=(g,f)=>{const z="transition-colors duration-fast font-medium",k={"text-xs px-2 py-1":l==="sm","text-sm px-3 py-2":l==="md","text-base px-4 py-3":l==="lg"},V={"border-b-2 -mb-px":a==="default","rounded-md":a==="pills","border-b-2 pb-2":a==="underline"},D={"opacity-50 cursor-not-allowed":g.disabled,"cursor-pointer":!g.disabled},G=f?{"border-accent-border text-text":a==="default"||a==="underline","bg-surface text-text shadow-none":a==="pills"}:{},q=!f&&!g.disabled?{"border-transparent text-text-muted hover:text-text":a==="default","text-text-muted hover:text-text":a==="pills","border-transparent text-text-muted hover:text-text hover:border-border":a==="underline"}:{};return i(z,k,V,D,G,q)};return e.jsx(Bt.Provider,{value:m,children:e.jsxs("div",{children:[e.jsx("div",{className:v,role:"tablist",children:t.map(g=>e.jsx("button",{type:"button",role:"tab","aria-selected":j===g.id,"aria-controls":`tabpanel-${g.id}`,disabled:g.disabled,onClick:()=>!g.disabled&&h(g.id),className:w(g,j===g.id),children:e.jsxs("span",{className:"flex items-center gap-2",children:[g.label,g.badge&&e.jsx("span",{className:"inline-flex items-center px-2 py-0.5 rounded-full text-xs font-medium bg-surface-hover text-text-muted",children:g.badge})]})},g.id))}),b?.content&&e.jsx("div",{role:"tabpanel",id:`tabpanel-${j}`,"aria-labelledby":`tab-${j}`,className:"mt-4",children:b.content})]})})},Ht={sm:"max-w-md",md:"max-w-lg",lg:"max-w-2xl",xl:"max-w-4xl",full:"max-w-full mx-4"};function Ee({open:t,onClose:s,title:r,size:n="md",closeOnBackdropClick:a=!0,closeOnEscape:l=!0,className:o,backdropClassName:x,children:u,footer:j,showCloseButton:h=!0}){const m=d.useRef(null),b=d.useRef(null);d.useEffect(()=>{if(!t||!l)return;const w=g=>{g.key==="Escape"&&s()};return document.addEventListener("keydown",w),()=>document.removeEventListener("keydown",w)},[t,l,s]),d.useEffect(()=>(t?(b.current=document.activeElement,m.current&&m.current.focus(),document.body.style.overflow="hidden"):(b.current&&b.current.focus(),document.body.style.overflow=""),()=>{document.body.style.overflow=""}),[t]);const v=w=>{a&&w.target===w.currentTarget&&s()};return t?e.jsx("div",{className:i("fixed inset-0 z-modal flex items-center justify-center p-4","bg-scrim",x),onClick:v,children:e.jsxs("div",{ref:m,className:i("relative w-full bg-surface rounded-lg shadow-modal","focus:outline-none",Ht[n],o),role:"dialog","aria-modal":"true","aria-labelledby":r?"modal-title":void 0,tabIndex:-1,children:[(r||h)&&e.jsxs("div",{className:"flex items-center justify-between p-6 pb-0",children:[r&&e.jsx("span",{id:"modal-title",className:"text-lg font-semibold text-text",children:r}),h&&e.jsx("button",{onClick:s,className:"p-1 text-text-muted hover:text-text transition-colors","aria-label":"Close modal",children:e.jsx(Y,{icon:R.X,size:"lg",color:"current"})})]}),e.jsx("div",{className:"p-6",children:u}),j&&e.jsx("div",{className:"px-6 py-4",children:j})]})}):null}const qt={xs:"text-xs",sm:"text-sm",md:"text-base",lg:"text-md",xl:"text-lg"},Vt={light:"font-normal",normal:"font-normal",medium:"font-medium",semibold:"font-semibold",bold:"font-bold"},Ut={primary:"text-text",secondary:"text-text-muted",accent:"text-accent",success:"text-success-fg",warning:"text-warning-fg",error:"text-danger-fg",info:"text-info-fg",neutral:"text-text",current:"text-current",muted:"text-text-subtle"},Kt={left:"text-left",center:"text-center",right:"text-right",justify:"text-justify"},Wt={tight:"leading-tight",normal:"leading-normal",relaxed:"leading-relaxed"},ie=({variant:t="body",size:s="md",weight:r="normal",color:n="current",align:a="left",truncate:l=!1,italic:o=!1,underline:x=!1,lineHeight:u="normal",as:j,className:h,children:m,...b})=>{const v=j||Gt(t),w=t==="caption",g=t==="label",f=t==="code",z=i("font-sans",w&&"text-xs text-text-subtle",g&&"text-xs font-semibold uppercase tracking-label text-text-subtle",f&&"font-mono text-sm rounded-sm bg-surface-hover px-1 py-0.5",!w&&!g&&!f&&qt[s],!g&&Vt[r],Ut[n],Kt[a],t==="body"&&Wt[u],o&&"italic",x&&"underline",l&&"truncate",h);return e.jsx(v,{className:z,...b,children:m})};function Gt(t){return{body:"p",caption:"span",label:"span",code:"code"}[t]||"p"}const Ve=({value:t,onChange:s,label:r,placeholder:n="Select or upload a file",error:a,disabled:l,accept:o,onListFiles:x,onListMounts:u,onUploadFile:j,onDownloadFile:h,onRegisterFile:m})=>{const[b,v]=d.useState(!1),[w,g]=d.useState([]),[f,z]=d.useState(null),[k,V]=d.useState("/"),[D,G]=d.useState([]),[q,L]=d.useState(!1),[H,ee]=d.useState(""),[J,W]=d.useState(typeof t=="object"?t:null),[ae,N]=d.useState(!1),[c,C]=d.useState(""),p=d.useRef(null);d.useEffect(()=>{b&&$()},[b]),d.useEffect(()=>{b&&f&&y()},[b,f,k,H]);const $=async()=>{L(!0);try{const M=await u?.();M?.data&&g(M.data)}catch(M){console.error("Failed to load mounts",M)}finally{L(!1)}},y=async()=>{if(f){L(!0);try{const M=await x?.({mountId:f.id,name:H,path:k});M?.data&&G(M.data)}catch(M){console.error("Failed to load files",M)}finally{L(!1)}}},U=async M=>{const _=M.target.files?.[0];if(_){L(!0);try{const Z=await _.arrayBuffer(),se=new Uint8Array(Z),oe={id:`local-${Date.now()}`,name:_.name,type:"file",path:"/",mimeType:_.type||"application/octet-stream",size:_.size,mountId:"local",providerKey:_.name,ownerId:"me"};W(oe),s(oe,se),v(!1)}catch(Z){console.error("Local file selection failed",Z)}finally{L(!1)}}},te=async M=>{const _=M.target.files?.[0];if(!(!_||!f)){L(!0);try{const Z=await _.arrayBuffer(),se=await j?.({file:new Uint8Array(Z),filename:_.name,mimeType:_.type||"application/octet-stream",mountId:f.id,path:k});if(se?.data){const oe=se.data;W(oe),s(oe,new Uint8Array(Z)),v(!1)}}catch(Z){console.error("Upload failed",Z)}finally{L(!1)}}},Q=async()=>{if(!(!c||!f)){L(!0);try{const M=`${k}${c}/`;m&&(await m({name:c,type:"folder",path:k,mimeType:"application/x-directory",size:0,mountId:f.id,providerKey:M,ownerId:"me"}),await y()),N(!1),C("")}catch(M){console.error("Failed to create folder",M)}finally{L(!1)}}},X=async M=>{L(!0);try{const _=await h?.(M.id);W(M),s(M,_),v(!1)}catch(_){console.error("Failed to download file",_)}finally{L(!1)}},P=M=>{M.stopPropagation(),W(null),s(null)},T=d.useMemo(()=>{const M=new Set,_=[];return D.forEach(Z=>{if(Z.type==="folder"){Z.path===k&&M.add(Z.name);return}const se=Z.providerKey||Z.name,ue=(k?se.substring(k.length):se).split("/").filter(de=>de!=="");ue.length>1?M.add(ue[0]):ue.length===1&&_.push(Z)}),{folders:Array.from(M).sort(),files:_.sort((Z,se)=>Z.name.localeCompare(se.name))}},[D,k]),A=M=>{V(_=>`${_}${M}/`)},E=()=>{const M=k.split("/").filter(_=>_!=="");M.pop(),M.length===0?V("/"):V(`${M.join("/")}/`)},I=d.useMemo(()=>{const M=T.folders.map(_=>({id:`folder-${_}`,name:_,type:"folder"}));return T.files.forEach(_=>{M.push({..._,type:"file"})}),M},[T]),F=[{id:"name",header:"Name",accessor:"name",cell:(M,_)=>e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Y,{icon:_.type==="folder"?R.Folder:R.FileText,size:"sm",color:_.type==="folder"?"warning":"secondary"}),e.jsx("span",{className:i(_.type==="folder"&&"font-medium"),children:M})]})},{id:"type",header:"Type",accessor:M=>M.type==="folder"?"Folder":M.mimeType},{id:"size",header:"Size",accessor:M=>M.type==="file"?`${(M.size/1024).toFixed(1)} KB`:"-"},{id:"actions",header:"",accessor:"id",align:"right",cell:(M,_)=>e.jsx(re,{variant:"outline",onClick:Z=>{Z.stopPropagation(),_.type==="folder"?A(_.name):X(_)},loading:q&&_.type==="file"&&J?.id===_.id,children:_.type==="folder"?"Open":"Select"})}],B=[{id:"name",header:"Mount Name",accessor:"name",cell:M=>e.jsxs("div",{className:"flex items-center gap-2 font-medium",children:[e.jsx(Y,{icon:R.HardDrive,size:"sm",color:"primary"}),e.jsx("span",{children:M})]})},{id:"actions",header:"",accessor:"id",align:"right",cell:(M,_)=>e.jsx(re,{variant:"outline",onClick:()=>z(_),children:"Open"})}];return e.jsxs("div",{className:"space-y-1",children:[r&&e.jsx(ie,{variant:"label",size:"sm",weight:"medium",children:r}),e.jsxs("div",{onClick:()=>!l&&v(!0),className:i("flex items-center gap-3 px-3 py-2 border rounded-lg cursor-pointer transition-colors","hover:border-border-strong bg-surface",a?"border-danger-border":"border-border",l&&"opacity-50 cursor-not-allowed bg-surface-sunk"),children:[e.jsx("div",{className:"flex-shrink-0",children:e.jsx(Y,{icon:J?R.FileText:R.HardDrive,color:J?"primary":"secondary"})}),e.jsx("div",{className:"flex-grow truncate",children:J?e.jsx("span",{className:"text-sm text-text font-medium",children:J.name}):e.jsx("span",{className:"text-sm text-text-muted",children:n})}),J&&!l&&e.jsx("button",{onClick:P,className:"p-1 hover:bg-surface-hover rounded",children:e.jsx(Y,{icon:R.X,size:"xs"})})]}),a&&e.jsx(ie,{variant:"body",size:"xs",className:"text-danger-fg",children:a}),e.jsx(Ee,{open:b,onClose:()=>{v(!1),z(null),V("/"),N(!1)},title:f?`Explorer: ${f.name}`:"Select Storage Mount",size:"lg",children:e.jsx(qe,{variant:"pills",items:[{id:"remote",label:"Platform Storage",content:e.jsx("div",{className:"space-y-4",children:f?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx(re,{variant:"ghost",onClick:()=>{k&&k!=="/"?E():z(null)},leftIcon:e.jsx(Y,{icon:R.ArrowLeft,size:"xs"}),children:k?"Back":"Back to Mounts"}),e.jsx("div",{className:"flex items-center gap-1 text-xs text-text-muted overflow-hidden bg-surface-hover px-2 py-1 rounded",children:e.jsx("span",{className:"truncate",children:k})}),e.jsx("div",{className:"flex-grow min-w-40",children:e.jsx(me,{placeholder:"Search...",value:H,onChange:M=>ee(M.target.value),startIcon:e.jsx(R.Search,{size:14}),fullWidth:!0})}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(re,{variant:"outline",onClick:()=>N(!0),leftIcon:e.jsx(Y,{icon:R.FolderPlus,size:"xs"}),children:"New Folder"}),e.jsx(re,{variant:"primary",onClick:()=>p.current?.click(),leftIcon:e.jsx(Y,{icon:R.Upload,size:"xs"}),loading:q,children:"Upload"}),e.jsx("input",{type:"file",className:"hidden",ref:p,onChange:te,accept:o})]})]}),ae&&e.jsxs("div",{className:"flex items-center gap-2 p-3 bg-surface-sunk rounded-lg border border-border",children:[e.jsx(Y,{icon:R.Folder,size:"sm",color:"warning"}),e.jsx(me,{placeholder:"Folder name",value:c,onChange:M=>C(M.target.value),autoFocus:!0}),e.jsx(re,{onClick:Q,loading:q,children:"Create"}),e.jsx(re,{variant:"ghost",onClick:()=>N(!1),children:"Cancel"})]}),e.jsx("div",{className:"max-h-100 overflow-auto rounded-lg border border-border",children:e.jsx(Ne,{data:I,columns:F,loading:q,emptyContent:"This folder is empty",onRowClick:M=>M.type==="folder"?A(M.name):X(M)})})]}):e.jsx("div",{className:"max-h-100 overflow-auto rounded-lg border border-border",children:e.jsx(Ne,{data:w,columns:B,loading:q,emptyContent:"No storage mounts configured",onRowClick:M=>z(M)})})})},{id:"local",label:"Local File",content:e.jsx("div",{className:"space-y-6",children:e.jsxs("div",{className:"flex flex-col items-center justify-center py-12 border-2 border-dashed border-border rounded-xl bg-surface-sunk/50",children:[e.jsx("div",{className:"p-4 bg-accent-soft rounded-full mb-4",children:e.jsx(Y,{icon:R.FileText,size:"xl",color:"primary"})}),e.jsx(ie,{variant:"label",size:"lg",weight:"semibold",children:"Select a file from your computer"}),e.jsxs(ie,{variant:"body",size:"sm",className:"text-text-muted mt-1 mb-6 text-center max-w-xs",children:["This file will be used directly in the form and will ",e.jsx("strong",{children:"not"})," be uploaded to platform storage."]}),e.jsxs("label",{className:"cursor-pointer",children:[e.jsx(re,{variant:"primary",size:"lg",loading:q,className:"pointer-events-none",children:"Browse Local File"}),e.jsx("input",{type:"file",className:"hidden",onChange:U,accept:o,disabled:q})]})]})})}]})})]})},Jt={sm:"px-3 py-1.5 text-sm",md:"px-3 py-2 text-base",lg:"px-3 py-2 text-md",full:"px-3 py-2 text-md"},pe=d.forwardRef(({label:t,helperText:s,error:r,size:n="md",fullWidth:a=!1,loading:l=!1,containerClassName:o,labelClassName:x,className:u,id:j,rows:h=4,...m},b)=>{const v=d.useId(),w=j||`textarea-${v}`,g=!!r,f=r||s?`${w}-description`:void 0;return e.jsxs("div",{className:i("flex flex-col",a&&"w-full",o),children:[t&&e.jsx("label",{htmlFor:w,className:i(Re,g?"text-danger-fg":"text-text-muted",x),children:t}),e.jsxs("div",{className:"relative",children:[e.jsx("textarea",{ref:b,id:w,rows:h,"aria-invalid":g||void 0,"aria-describedby":f,className:i(Le,"resize-y leading-relaxed",Jt[n],Pe(g),u),...m}),l&&e.jsx("span",{"aria-hidden":!0,className:"absolute top-2 right-3 size-icon-md animate-spin rounded-full border-2 border-border border-t-transparent"})]}),(r||s)&&e.jsx("p",{id:f,className:i("mt-1 text-xs",g?"text-danger-fg":"text-text-subtle"),children:r||s})]})});pe.displayName="TextArea";function Te(t,s){return s.split(".").reduce((r,n)=>r&&typeof r=="object"&&n in r?r[n]:void 0,t)}function Xt(t,s,r){const n=s.split("."),a=Array.isArray(t)?[...t]:{...t};let l=a;for(let o=0;o<n.length-1;o++){const x=n[o],u=l[x];l[x]=u&&typeof u=="object"?Array.isArray(u)?[...u]:{...u}:{},l=l[x]}return l[n[n.length-1]]=r,a}function Yt(t,s){const r=s.split("."),n=Array.isArray(t)?[...t]:{...t};let a=n;for(let l=0;l<r.length-1;l++){const o=r[l];if(!a[o]||typeof a[o]!="object")return n;a[o]=Array.isArray(a[o])?[...a[o]]:{...a[o]},a=a[o]}return delete a[r[r.length-1]],n}function Ue({title:t,description:s,className:r,children:n}){return e.jsxs("div",{className:i("flex flex-col gap-4 py-6 sm:flex-row sm:gap-8",r),children:[e.jsxs("div",{className:"w-full shrink-0 sm:w-form-label",children:[t&&e.jsx("span",{className:"text-base font-semibold text-text",children:t}),s&&e.jsx("p",{className:"mt-1 text-sm leading-relaxed text-pretty text-text-subtle",children:s})]}),e.jsx("div",{className:"min-w-0 flex-1",children:n})]})}const Zt=({groups:t,data:s,onSubmit:r,onCancel:n,onChange:a,transform:l,validate:o,submitButton:x={label:"Submit",variant:"primary"},cancelButton:u={label:"Cancel",variant:"outline"},showButtons:j=!0,layout:h="vertical",size:m="md",loading:b=!1,className:v,ref:w,sdk:g})=>{const[f,z]=d.useState(s||{}),[k,V]=d.useState({}),[D,G]=d.useState({});d.useEffect(()=>{s&&z({...s})},[s]);const q=d.useCallback((N,c,C)=>{const p=t.flatMap($=>$.items).find($=>$.name===N);if(!p)return null;if(p.required&&(c==null||c===""))return`${p.label} is required`;if(p.type==="array"){if(p.required&&(!c||c.length===0))return`${p.label} cannot be empty.`;if(c&&!Array.isArray(c))return`${p.label} must be an array.`;if(Array.isArray(c)&&p.arrayFields){const $=[];let y=!1;if(c.forEach((U,te)=>{const Q={};for(const X of p.arrayFields){const P=U?.[X.name];if(X.required&&(P==null||P===""))Q[X.name]=`${X.label} is required`,y=!0;else if(X.validator){const T=X.validator(P,U);T&&(Q[X.name]=T,y=!0)}}$[te]=Q}),y)return JSON.stringify($)}}return p.validator?p.validator(c,C):null},[t]),L=d.useCallback((N,c)=>{let C=Xt(f,N,c);t.flatMap(y=>y.items).find(y=>y.name===N)?.removeIfEmpty&&(c==null||c==="")&&(C=Yt(C,N)),z(C),G(y=>({...y,[N]:!0}));const $=q(N,c,C);V(y=>({...y,[N]:$||""})),a?.(C,N)},[f,t,q,a]),H=d.useCallback(async N=>{if(N.preventDefault(),b)return;const c={},C=t.flatMap($=>$.items);for(const $ of C){if($.hidden||$.conditional&&!$.conditional(f))continue;const y=q($.name,Te(f,$.name),f);y&&(c[$.name]=y)}if(o){const $=o(f);$&&Object.assign(c,$)}if(V(c),Object.keys(c).some($=>c[$]))return;const p=l?l(f):f;await r?.(f,p)},[f,t,q,o,l,r,b]),ee=d.useCallback(N=>{const c=Te(f,N.name),C=D[N.name]?k[N.name]:void 0,p=N.disabled||b,$={value:c||"",disabled:p,required:N.required,placeholder:N.placeholder,...N.fieldProps};switch(N.type){case"text":case"email":case"password":case"number":case"tel":case"url":return e.jsx(me,{...$,onChange:y=>L(N.name,y.target.value),type:N.textType||N.type,autoComplete:N.autocomplete,error:C,size:m});case"textarea":return e.jsx(pe,{...$,onChange:y=>L(N.name,y.target.value),rows:4,error:C,size:m});case"select":return e.jsx(he,{...$,onChange:y=>L(N.name,y),options:(N.options||[]).map(y=>({...y,value:String(y.value)})),searchable:N.searchable,multiple:N.multiple,allowCreate:N.allowCreate,error:C,size:m});case"segmented":return e.jsx(_e,{"aria-label":N.label,value:c==null?"":String(c),onChange:y=>L(N.name,y),options:(N.options||[]).map(y=>({value:String(y.value),label:y.label})),size:m==="sm"?"sm":"md",className:N.disabled?"pointer-events-none opacity-50":void 0});case"checkbox":return e.jsx(xe,{...$,label:N.label,checked:!!c,onChange:y=>L(N.name,y.target.checked),size:m});case"radio":return e.jsx("div",{className:"flex flex-col gap-2",children:N.options?.map(y=>e.jsxs("label",{className:"flex cursor-pointer items-center gap-3 text-base text-text",children:[e.jsx("input",{type:"radio",name:N.name,value:y.value,checked:c===y.value,onChange:()=>L(N.name,y.value),disabled:p||y.disabled,className:"size-checkbox shrink-0 rounded-xs border border-border-strong bg-surface-input accent-accent focus-visible:outline-none focus-visible:focus-ring"}),y.label]},y.value))});case"date":return e.jsx(ge,{...$,value:c?new Date(c):null,onChange:y=>L(N.name,y),size:m});case"file":return e.jsx(Ve,{...$,value:c,onChange:y=>L(N.name,y),error:C,onListFiles:y=>g?.http.invoke({method:"POST",action:"storage.file.list",body:y}),onListMounts:()=>g?.http.invoke({method:"GET",action:"storage.mount"}),onUploadFile:y=>g?.http.invoke({method:"POST",action:"storage.file.upload",body:y}),onDownloadFile:y=>g?.http.invoke({method:"GET",action:`storage.file.${y}.download`}),onRegisterFile:y=>g?.http.invoke({method:"POST",action:"storage.file.folder",body:y})});case"folder":return e.jsx(Fe,{value:c||{},onChange:y=>L(N.name,y),onListFolders:()=>g?.http.invoke({method:"GET",action:"storage.mount"}),disabled:p,size:m,placeholder:N.placeholder});case"custom":return N.customComponent?.({value:c,onChange:y=>L(N.name,y),error:C,disabled:p});case"array":{const y=c||[];let U=[];if(typeof C=="string"&&C.startsWith("["))try{U=JSON.parse(C)}catch{}const te=()=>{L(N.name,[...y,{}])},Q=P=>{L(N.name,y.filter((T,A)=>A!==P))},X=(P,T,A)=>{const E=[...y];E[P]={...E[P],[T]:A},L(N.name,E)};return e.jsxs("div",{className:"flex flex-col gap-2",children:[y.map((P,T)=>e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsx("div",{className:"grid flex-1 gap-2 sm:grid-cols-2",children:N.arrayFields?.map(A=>{const E=U?.[T]?.[A.name];return e.jsxs("div",{className:"flex flex-col gap-1",children:[T===0&&e.jsxs("label",{className:"block text-xs font-semibold uppercase tracking-label text-text-subtle",children:[A.label,A.required&&e.jsx("span",{className:"ml-1 text-danger-fg",children:"*"})]}),(()=>{const I={value:P?.[A.name]||"",disabled:p,required:A.required,placeholder:A.placeholder,...A.fieldProps};switch(A.type){case"text":case"email":case"password":case"number":case"tel":case"url":return e.jsx(me,{...I,onChange:F=>X(T,A.name,F.target.value),type:A.textType||A.type,autoComplete:A.autocomplete,error:E,size:m});case"textarea":return e.jsx(pe,{...I,onChange:F=>X(T,A.name,F.target.value),rows:4,error:E,size:m});case"select":return e.jsx(he,{...I,onChange:F=>X(T,A.name,F),options:(A.options||[]).map(F=>({...F,value:String(F.value)})),searchable:A.searchable,multiple:A.multiple,allowCreate:A.allowCreate,error:E,size:m});case"checkbox":return e.jsx(xe,{...I,checked:!!P?.[A.name],onChange:F=>X(T,A.name,F.target.checked),size:m});case"radio":return e.jsx("div",{className:"flex flex-col gap-2",children:A.options?.map(F=>e.jsxs("label",{className:"flex cursor-pointer items-center gap-2 text-base text-text",children:[e.jsx("input",{type:"radio",name:`${N.name}.${T}.${A.name}`,value:F.value,checked:P?.[A.name]===F.value,onChange:()=>X(T,A.name,F.value),disabled:p||F.disabled,className:"size-checkbox shrink-0 rounded-xs border border-border-strong bg-surface-input accent-accent focus-visible:outline-none focus-visible:focus-ring"}),F.label]},F.value))});case"date":{const F=P?.[A.name];return e.jsx(ge,{...I,value:F?new Date(F):null,onChange:B=>X(T,A.name,B),size:m})}case"custom":return A.customComponent?.({value:P?.[A.name],onChange:F=>X(T,A.name,F),error:E,disabled:p});default:return e.jsxs("p",{children:["Unsupported field type in array:"," ",A.type]})}})(),E&&e.jsx("p",{className:"text-xs text-danger-fg",children:E})]},A.name)})}),e.jsx(re,{type:"button",iconOnly:!0,variant:"ghost",size:"md","aria-label":`${N.label} verwijderen`,onClick:()=>Q(T),disabled:p,className:i("shrink-0",T===0&&"mt-5"),children:e.jsx(R.Trash2,{className:"size-icon-md"})})]},T)),e.jsxs(re,{type:"button",variant:"secondary",leftIcon:e.jsx(R.Plus,{className:"size-icon-sm"}),onClick:te,disabled:p,children:[N.label," toevoegen"]})]})}default:return null}},[f,D,k,b,m,L]),J=d.useCallback(N=>{if(N.conditional&&!N.conditional(f))return null;const c=N.items.filter(p=>!(p.hidden||p.conditional&&!p.conditional(f)));if(c.length===0)return null;const C=i(N.layout==="flex"?"flex flex-wrap gap-3.5":"grid gap-3.5",N.layout!=="flex"&&{"grid-cols-1":!N.columns||N.columns===1,"grid-cols-2":N.columns===2,"grid-cols-3":N.columns===3,"grid-cols-4":N.columns===4},N.className);return e.jsx(Ue,{title:N.title,description:N.description,className:"not-last:border-b not-last:border-border-subtle",children:e.jsx("div",{children:e.jsx("div",{className:C,children:c.map(p=>{const $=D[p.name]?k[p.name]:void 0;return e.jsxs("div",{className:i("flex min-w-0 flex-col gap-1.5",p.type==="checkbox"&&"justify-center"),style:{width:typeof p.width=="string"?p.width:void 0,gridColumn:typeof p.width=="number"?`span ${p.width} / span ${p.width}`:void 0},children:[p.type!=="custom"&&p.type!=="checkbox"&&e.jsxs("label",{className:"block text-sm font-medium text-text-muted",children:[p.label,p.required&&e.jsx("span",{className:"ml-1 text-danger-fg",children:"*"})]}),ee(p),p.help&&!$&&e.jsx("p",{className:"text-xs leading-4 text-text-subtle",children:p.help})]},p.name)})})})},N.id)},[f,D,k,ee]),W=i({"max-w-settings":m==="sm","max-w-form":m==="md","max-w-6xl":m==="lg","max-w-full":m==="full"},v),ae=m==="full"?"md":m;return e.jsxs("form",{ref:w,onSubmit:H,className:W,children:[!j&&e.jsx("button",{type:"submit",className:"hidden",tabIndex:-1,"aria-hidden":!0}),e.jsx("div",{className:"flex flex-col",children:t.map(J)}),j&&e.jsx("div",{className:"flex items-center gap-2 border-t border-border-subtle py-4",children:e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"ml-auto"}),n&&e.jsx(re,{type:"button",variant:u.variant??"ghost",size:u.size||ae,disabled:u.disabled||b,onClick:n,className:u.className,children:u.label}),e.jsx(re,{type:"submit",variant:x.variant,size:x.size||ae,disabled:x.disabled||b,loading:b,className:x.className,children:x.label})]})})]})};function Qt({open:t,title:s,description:r,confirmLabel:n="Bevestigen",cancelLabel:a="Annuleren",tone:l="default",loading:o=!1,onConfirm:x,onCancel:u}){return e.jsx(Ee,{open:t,onClose:u,title:s,size:"sm",footer:e.jsxs("div",{className:"flex w-full items-center justify-end gap-2",children:[e.jsx(re,{variant:"ghost",onClick:u,disabled:o,children:a}),e.jsx(re,{variant:l==="danger"?"destructive":"primary",onClick:x,loading:o,children:n})]}),children:r&&e.jsx(ie,{color:"secondary",children:r})})}const es={default:"bg-surface-hover text-text",primary:"bg-accent-soft text-accent",secondary:"bg-surface-hover text-text-muted",success:"bg-success-soft text-success-fg",warning:"bg-warning-soft text-warning-fg",error:"bg-danger-soft text-danger-fg",info:"bg-info-soft text-info-fg",note:"bg-note-soft text-note"},ts={sm:"px-2 py-0.5 text-xs",md:"px-2.5 py-1 text-sm",lg:"px-3 py-1.5 text-base"},ss={default:"bg-surface-hover",primary:"bg-accent",secondary:"bg-surface-hover",success:"bg-success",warning:"bg-warning",error:"bg-danger",info:"bg-info",note:"bg-note"};function rs({variant:t="default",size:s="md",dot:r=!1,icon:n,dismissible:a=!1,onDismiss:l,className:o,children:x,...u}){return e.jsxs("span",{className:i("inline-flex items-center font-medium rounded-full",es[t],ts[s],o),...u,children:[r&&e.jsx("span",{className:i("w-2 h-2 rounded-full mr-1.5",ss[t])}),n&&e.jsx("span",{className:i("flex-shrink-0",x&&"mr-1"),children:n}),x,a&&l&&e.jsx("button",{onClick:l,className:"ml-1.5 flex-shrink-0 hover:opacity-70 transition-opacity","aria-label":"Remove badge",children:e.jsx(Y,{icon:R.X,size:"xs",color:"current"})})]})}const ns={neutral:"bg-surface-hover text-text-muted",success:"bg-success-soft text-success-fg"};function as({icon:t,tone:s="neutral",title:r,description:n,actions:a,card:l=!1,className:o,...x}){return e.jsxs("div",{className:i("flex flex-col items-center gap-2.5 text-center",l&&"rounded-lg border border-border bg-surface px-11 py-9 shadow-overlay",o),...x,children:[t!=null&&e.jsx("span",{className:i("flex size-disc items-center justify-center rounded-full text-2xl",ns[s]),children:t}),e.jsx("div",{className:"text-lg font-semibold text-text",children:r}),n&&e.jsx("div",{className:"max-w-sm text-sm leading-relaxed text-text-muted",children:n}),a&&e.jsx("div",{className:"flex gap-2 pt-1.5",children:a})]})}function ls({children:t,className:s,...r}){return e.jsx("kbd",{className:i("inline-flex items-center rounded border border-border px-1.5 py-px text-xs font-medium leading-none text-text-muted",s),...r,children:t})}const os={sm:"h-1",md:"h-1.5"},cs={accent:"bg-accent",success:"bg-success"};function is({value:t,variant:s="accent",size:r="md",className:n,...a}){const l=Math.max(0,Math.min(100,t));return e.jsx("div",{role:"progressbar","aria-valuenow":Math.round(l),"aria-valuemin":0,"aria-valuemax":100,className:i("w-full overflow-hidden rounded-full bg-surface-hover",os[r],n),...a,children:e.jsx("div",{className:i("h-full rounded-full transition-[width] duration-300 ease-out",cs[s]),style:{width:`${l}%`}})})}const ds={xs:"h-3 w-3",sm:"h-4 w-4",md:"h-6 w-6",lg:"h-8 w-8",xl:"h-12 w-12"},us={primary:"text-accent",secondary:"text-text-muted",white:"text-white",current:"text-current"},xs={xs:"text-xs",sm:"text-sm",md:"text-sm",lg:"text-base",xl:"text-lg"};function fs({size:t="md",variant:s="primary",label:r="Loading...",showLabel:n=!1,className:a,...l}){return e.jsxs("div",{className:i("inline-flex items-center",n?"flex-col space-y-2":"",a),...l,children:[e.jsxs("svg",{className:i("animate-spin",ds[t],us[s]),fill:"none",viewBox:"0 0 24 24","aria-hidden":!n,role:n?"status":void 0,children:[e.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),e.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"})]}),n&&e.jsx("span",{className:i("text-text-muted",xs[t]),children:r}),!n&&e.jsx("span",{className:"sr-only",children:r})]})}const ms={neutral:"bg-text-disabled",accent:"bg-accent",success:"bg-success",warning:"bg-warning",danger:"bg-danger",info:"bg-info",note:"bg-note","cat-1":"bg-cat-1","cat-2":"bg-cat-2","cat-3":"bg-cat-3","cat-4":"bg-cat-4","cat-5":"bg-cat-5"};function hs({tone:t="neutral",shape:s="round",pulse:r=!1,label:n,className:a}){return e.jsx("span",{role:n?"img":void 0,"aria-label":n,"aria-hidden":n?void 0:!0,className:i("inline-block size-dot shrink-0",s==="round"?"rounded-full":"rounded-sm",ms[t],r&&"animate-pulse",a)})}function bs({steps:t,current:s,variant:r="numbered",label:n,className:a}){const l=t.indexOf(s),o={role:n?"group":void 0,"aria-label":n,"aria-hidden":n?void 0:!0};return r==="dots"?e.jsx("div",{...o,className:i("flex items-center gap-1.5",a),children:t.map((x,u)=>e.jsx("span",{className:i("h-step-bar rounded-full transition-all duration-fast ease-out",u===l?"w-5 bg-accent":"w-3.5",u<l&&"bg-border-strong",u>l&&"bg-border")},x))}):e.jsx("div",{...o,className:i("flex items-center gap-2",a),children:t.map((x,u)=>e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{"aria-current":u===l?"step":void 0,className:i("flex size-tile-sm items-center justify-center rounded-full text-xs font-medium",u===l&&"bg-accent text-accent-fg",u<l&&"bg-accent-soft text-accent",u>l&&"bg-surface-hover text-text-muted"),children:u+1}),u<t.length-1&&e.jsx("span",{className:"h-px w-8 bg-border-strong"})]},x))})}function gs({title:t,icon:s=e.jsx(R.Sparkles,{className:"size-icon-md","aria-hidden":!0}),action:r,children:n,className:a,...l}){return e.jsxs("div",{className:i("flex flex-col gap-2 rounded-xl border p-4","border-assistant-border bg-assistant-soft",a),...l,children:[e.jsxs("div",{className:"flex items-center gap-2 text-assistant",children:[e.jsx("span",{"aria-hidden":!0,children:s}),e.jsx("span",{className:"text-sm font-semibold",children:t}),r&&e.jsx("span",{className:"ml-auto",children:r})]}),n&&e.jsx("div",{className:"text-sm leading-relaxed text-text",children:n})]})}const ps={default:"bg-avatar text-avatar-fg",in:"bg-avatar-in text-avatar-in-fg",out:"bg-accent text-accent-fg",note:"bg-avatar-note text-avatar-note-fg"},vs={xs:"w-5 h-5 text-xs",sm:"w-6 h-6 text-xs",md:"w-7 h-7 text-base",lg:"w-9 h-9 text-sm"};function js(t){if(!t)return"?";const s=t.trim().split(/[^\p{L}\p{N}]+/u).filter(Boolean);return s.length>=2?(s[0][0]+s[1][0]).toUpperCase():s.length===1?s[0].slice(0,2).toUpperCase():"?"}const Ke=({name:t,src:s,tone:r="default",size:n="sm",className:a,title:l})=>{const[o,x]=d.useState(!1),u=i("inline-flex items-center justify-center rounded-full overflow-hidden shrink-0 font-semibold select-none",ps[r],vs[n],a);return s&&!o?e.jsx("img",{src:s,alt:t??"",title:l??t,className:i(u,"object-cover"),onError:()=>x(!0)}):e.jsx("span",{className:u,title:l??t,"aria-label":t,children:js(t)})},De="ring-surface",ys="ring-surface-accent",Ns=({people:t,max:s=4,size:r="sm",className:n})=>{if(t.length===0)return null;const a=t.slice(0,s),l=t.length-a.length;return e.jsxs("span",{className:i("inline-flex items-center",n),children:[a.map((o,x)=>e.jsx(Ke,{name:o.name,src:o.src,size:r,title:o.name?o.seen===!1?`${o.name} — nog niet gelezen`:o.name:void 0,className:i(x>0&&"-ml-2",o.owner?ys:De,o.seen===!1&&"opacity-40")},o.id??`${o.name}-${x}`)),l>0&&e.jsxs("span",{className:i("inline-flex items-center justify-center rounded-full shrink-0 -ml-2 font-semibold bg-avatar text-avatar-fg",r==="xs"?"w-5 h-5 text-xs":r==="md"?"w-7 h-7 text-xs":r==="lg"?"w-9 h-9 text-xs":"w-6 h-6 text-xs",De),children:["+",l]})]})},$e={mail:{fg:"text-channel-mail-fg",bg:"bg-channel-mail-soft"},wa:{fg:"text-channel-whatsapp-fg",bg:"bg-channel-whatsapp-soft"},chat:{fg:"text-channel-chat-fg",bg:"bg-channel-chat-soft"},tel:{fg:"text-channel-phone-fg",bg:"bg-channel-phone-soft"},note:{fg:"text-channel-note-fg",bg:"bg-channel-note-soft"}},ws={sm:"size-avatar-xs rounded-sm text-xs",md:"size-avatar-sm rounded-md text-xs",lg:"size-avatar-lg rounded-md text-base"};function ks({channel:t,children:s,size:r="md",className:n,title:a}){const l=$e[t in $e?t:"note"];return e.jsx("span",{title:a,className:i("inline-flex shrink-0 items-center justify-center font-bold",ws[r],l.fg,l.bg,n),children:s})}const Cs=({src:t,alt:s,size:r="md",aspectRatio:n="auto",radius:a="md",showLoading:l=!0,showError:o=!0,fallback:x,loadingContent:u,errorContent:j,className:h,onLoad:m,onError:b,...v})=>{const[w,g]=d.useState(!0),[f,z]=d.useState(!1),[k,V]=d.useState(t),D=W=>{g(!1),z(!1),m?.(W)},G=W=>{if(g(!1),z(!0),x&&k!==x){V(x),z(!1),g(!0);return}b?.(W)},q=i("relative overflow-hidden bg-surface-hover",{"w-8 h-8":r==="xs","w-12 h-12":r==="sm","w-16 h-16":r==="md","w-24 h-24":r==="lg","w-32 h-32":r==="xl","w-full h-full":r==="full"},{"aspect-square":n==="square","aspect-video":n==="video","aspect-portrait":n==="portrait","aspect-landscape":n==="landscape"},{"rounded-none":a==="none","rounded-sm":a==="sm","rounded-md":a==="md","rounded-lg":a==="lg","rounded-xl":a==="xl","rounded-full":a==="full"},h),L=i("w-full h-full object-cover transition-opacity duration-fast",{"opacity-0":w||f,"opacity-100":!w&&!f}),H=i("absolute inset-0 flex items-center justify-center","text-text-muted"),ee=e.jsx("div",{className:"animate-pulse",children:e.jsx("div",{className:"w-6 h-6 bg-surface-hover rounded"})}),J=e.jsxs("div",{className:"text-center",children:[e.jsx(Y,{icon:R.ImageOff,size:"lg",className:"mx-auto mb-1"}),e.jsx("span",{className:"text-xs",children:"Failed to load"})]});return e.jsxs("div",{className:q,children:[e.jsx("img",{...v,src:k,alt:s,className:L,onLoad:D,onError:G}),w&&l&&e.jsx("div",{className:H,children:u||ee}),f&&o&&e.jsx("div",{className:H,children:j||J})]})};function Ss({icon:t,onClick:s,children:r}){return e.jsxs("button",{type:"button",onClick:s,className:i("inline-flex h-control-sm shrink-0 cursor-pointer items-center gap-1.5 rounded-md px-2.5","text-sm font-medium whitespace-nowrap","transition-colors duration-fast ease-out hover:bg-white/15","focus-visible:outline-none focus-visible:focus-ring"),children:[t,r]})}function Es({items:t,getRowKey:s,variant:r="divided",leading:n,renderItem:a,trailing:l,onSelect:o,onActiveIndexChange:x,isActive:u,unread:j,dimmed:h,groupBy:m,groups:b,renderGroupHeader:v,stickyGroupHeaders:w=!1,collapsibleGroups:g=!1,hideGroupCount:f=!1,selectable:z=!1,selectedItems:k=[],onSelectionChange:V,bulkActions:D,header:G,stickyHeader:q=!1,bordered:L=!1,emptyContent:H,loading:ee=!1,loadingRows:J=4,className:W,"aria-label":ae}){const[N,c]=d.useState(()=>Object.fromEntries((b??[]).filter(E=>E.defaultCollapsed).map(E=>[E.id,!0]))),C=d.useRef(null),p=E=>{if(!["ArrowDown","ArrowUp","Home","End"].includes(E.key))return;const F=Array.from(C.current?.querySelectorAll("li[data-list-row]")??[]);if(F.length===0)return;E.preventDefault();const B=F.indexOf(document.activeElement),M=E.key==="Home"?0:E.key==="End"?F.length-1:E.key==="ArrowDown"?(B+1)%F.length:(B-1+F.length)%F.length;F[M]?.focus()},$=(E,I)=>s?s(E,I):I,y=E=>k.includes(E),U=(E,I)=>{V&&V(I?[...k,E]:k.filter(F=>F!==E))},te=E=>V?.(E?[...t]:[]),Q=i("flex flex-col",z&&k.length>0&&"min-h-full",L&&"overflow-hidden rounded-lg border border-border-subtle",W);if(ee)return e.jsx("div",{className:Q,children:Array.from({length:J}).map((E,I)=>e.jsxs("div",{className:i("flex animate-pulse items-center gap-3 px-4 py-2",r==="divided"&&I>0&&"border-t border-border-subtle"),children:[e.jsx("span",{className:"size-tile-sm shrink-0 rounded-md bg-surface-hover"}),e.jsx("span",{className:"h-3 w-30 shrink-0 rounded-sm bg-surface-hover"}),e.jsx("span",{className:"h-3 flex-1 rounded-sm bg-surface-hover"}),e.jsx("span",{className:"h-3 w-8 shrink-0 rounded-sm bg-surface-hover"})]},`skeleton-${I}`))});if(t.length===0&&H)return e.jsx("div",{className:Q,children:H});const X=t.length>0&&k.length===t.length,P=k.length>0&&!X,T=(E,I,F)=>{const B=u?.(E,I)??!1,M=j?.(E,I)??!1,_=h?.(E,I)??!1,Z=z&&y(E);return e.jsxs("li",{...o?{role:"button",tabIndex:0,"data-list-row":"","aria-current":B||void 0,onClick:()=>o(E,I),onFocus:()=>x?.(I),onKeyDown:se=>{se.key!=="Enter"&&se.key!==" "||(se.preventDefault(),o(E,I))}}:{},className:i("flex items-center gap-3 text-base","transition-colors duration-fast ease-out",r==="inset"?"mx-2 rounded-lg px-3 py-2.5":"px-5 py-2.5",r==="divided"&&!F&&"border-t border-border-subtle",o&&"cursor-pointer focus-visible:outline-none focus-visible:focus-ring",B||Z?"bg-accent-soft text-text":M?i("bg-surface-unread",o&&"hover:bg-surface-unread-hover"):o&&"hover:bg-surface-hover",_&&"text-text-muted"),children:[z&&e.jsx("span",{onClick:se=>se.stopPropagation(),children:e.jsx(xe,{checked:y(E),onChange:se=>U(E,se.target.checked),"aria-label":"Rij selecteren"})}),r==="bulleted"&&e.jsx("span",{"aria-hidden":!0,className:"mt-2 size-1.5 shrink-0 self-start rounded-full bg-border-strong"}),n&&e.jsx("span",{className:"shrink-0",children:n(E,I)}),e.jsx("div",{className:"flex min-w-0 flex-1 items-center gap-2",children:a?a(E,I):String(E)}),l&&e.jsx("span",{className:"shrink-0 text-xs text-text-subtle",children:l(E,I)})]},$(E,I))},A=(()=>{if(!m)return t.map((B,M)=>T(B,M,M===0));const E=new Map;t.forEach((B,M)=>{const _=m(B,M);E.has(_)||E.set(_,[]),E.get(_).push({item:B,index:M})});const I=b??[];return[...I.filter(B=>E.has(B.id)),...[...E.keys()].filter(B=>!I.some(M=>M.id===B)).map(B=>({id:B}))].flatMap((B,M)=>{const _=E.get(B.id)??[],Z=g&&N[B.id],se=B.title??B.id,oe=B.count??_.length,ue=e.jsx("li",{onClick:g?()=>c(de=>({...de,[B.id]:!de[B.id]})):void 0,className:i("flex items-center gap-2.5 bg-surface px-5 pb-1.5 text-base font-semibold",M>0?"pt-5":"pt-3",B.tone==="danger"?"text-danger-fg":B.tone==="muted"?"text-text-subtle":"text-text",w&&"sticky z-10",g&&"cursor-pointer select-none"),"aria-expanded":g?!Z:void 0,style:w?{top:q?28:0}:void 0,children:v?v(B,_.map(de=>de.item)):e.jsxs(e.Fragment,{children:[g&&e.jsx(R.ChevronRight,{"aria-hidden":!0,className:i("size-icon-md shrink-0 text-text-subtle transition-transform duration-fast ease-out",!Z&&"rotate-90")}),e.jsx("span",{children:se}),!f&&e.jsx("span",{className:i("rounded-full px-2 text-xs font-normal tabular-nums",B.tone==="danger"?"bg-danger-soft text-danger-fg":"bg-surface-sunk text-text-subtle"),children:oe})]})},`group-${B.id}`);return Z?[ue]:[ue,..._.map(({item:de,index:je},S)=>T(de,je,S===0))]})})();return e.jsxs("div",{ref:C,className:Q,onKeyDown:o?p:void 0,children:[G&&e.jsxs("div",{className:i("flex h-row-sm items-end gap-3 border-b border-border bg-surface px-5 pb-2","text-xs font-semibold uppercase tracking-wider text-text-disabled",q&&"sticky top-0 z-20"),children:[z&&e.jsx("span",{className:"flex items-center",children:e.jsx(xe,{checked:X,indeterminate:P,onChange:E=>te(E.target.checked),"aria-label":"Alles selecteren"})}),G]}),e.jsx("ul",{"aria-label":ae,className:"flex flex-col",children:A}),z&&k.length>0&&e.jsx("div",{className:"pointer-events-none sticky bottom-0 z-10 flex justify-center px-5 pb-4",children:e.jsxs("div",{className:"pointer-events-auto flex items-center gap-1.5 rounded-lg bg-accent py-1.5 pl-3.5 pr-1.5 text-accent-fg shadow-overlay",children:[e.jsxs("span",{className:"text-sm font-medium",children:[k.length," geselecteerd"]}),e.jsx("span",{"aria-hidden":!0,className:"mx-1.5 h-4 w-px bg-current opacity-25"}),D,e.jsx("span",{"aria-hidden":!0,className:"mx-1.5 h-4 w-px bg-current opacity-25"}),e.jsx("button",{type:"button",onClick:()=>V?.([]),"aria-label":"Selectie wissen",className:"grid size-tile-md shrink-0 cursor-pointer place-items-center rounded-md transition-colors duration-fast ease-out hover:bg-white/15 focus-visible:outline-none focus-visible:focus-ring",children:e.jsx(R.X,{className:"size-icon-lg"})})]})})]})}function Ms({side:t,continued:s=!1,tone:r="default",className:n,children:a}){return e.jsx("div",{className:i("min-w-0 max-w-bubble md:max-w-bubble-md",t==="out"?"rounded-lg rounded-tr-sm":"rounded-lg rounded-tl-sm",r==="note"?"bg-note-soft":t==="out"?"bg-bubble-out-soft":"bg-surface-sunk",s&&"mt-1",n),children:a})}const zs={default:"text-text",urgent:"text-danger-fg",success:"text-success-fg"};function Ts({value:t,label:s,tone:r="default",className:n,...a}){return e.jsxs("div",{className:i("rounded-xl bg-editor px-4 py-3.5",n),...a,children:[e.jsx("div",{className:i("text-2xl font-semibold",zs[r]),children:t}),e.jsx("div",{className:"pt-0.5 text-xs text-text-muted",children:s})]})}const Ds=({surface:t=!1,title:s,subtitle:r,meta:n,actions:a=[],children:l,className:o,backLabel:x="Back",backClassName:u,onBack:j,editable:h=!1,onTitleChange:m})=>{const[b,v]=d.useState(!1),[w,g]=d.useState(s),f=d.useRef(null);d.useEffect(()=>{g(s)},[s]),d.useEffect(()=>{b&&f.current&&(f.current.focus(),f.current.select())},[b]);const z=()=>{h&&v(!0)},k=()=>{v(!1),w.trim()!==""&&w!==s&&m?m(w.trim()):g(s)},V=D=>{D.key==="Enter"?f.current?.blur():D.key==="Escape"&&(g(s),v(!1))};return e.jsxs("div",{className:i("px-5 pt-4 pb-2.5",t&&"border-b border-border",o),children:[e.jsxs("div",{className:"flex flex-row sm:items-start sm:justify-between items-center gap-4",children:[e.jsx("div",{className:"min-w-0 flex-1",children:e.jsxs("div",{className:"flex items-start gap-4 text-text",children:[j&&e.jsx(re,{variant:"ghost",onClick:j,leftIcon:e.jsx(Y,{icon:R.ChevronLeft,size:"md"}),iconOnly:!0}),e.jsxs("div",{className:"min-w-0 flex-1",children:[b?e.jsx("input",{ref:f,type:"text",value:w,onChange:D=>g(D.target.value),onBlur:k,onKeyDown:V,className:"text-1xl font-semibold bg-transparent border-b-1 border-border rounded-lg outline-none focus:border-none px-1 -mx-1 min-w-0 w-full"}):e.jsxs("div",{className:"group flex items-baseline gap-2.5 min-w-0",children:[e.jsx("h2",{onClick:z,className:i("text-lg font-semibold tracking-title truncate",h&&"cursor-pointer"),title:h?"Click to edit":void 0,children:s}),r&&e.jsx("span",{className:"shrink-0 text-base text-text-muted truncate",children:r}),h&&e.jsx(R.Pencil,{size:15,onClick:z,className:"shrink-0 cursor-pointer text-text-muted opacity-0 group-hover:opacity-100 transition-opacity"})]}),n&&e.jsx("div",{className:i("mt-1 min-w-0 text-sm text-text-subtle",typeof n=="string"&&"truncate"),children:n})]})]})}),a.length>0&&e.jsx("div",{className:"flex flex-wrap sm:flex-nowrap gap-2 sm:gap-3",children:a.map(D=>D.render?e.jsx(d.Fragment,{children:D.render()},D.id):D.splitOptions&&D.splitOptions.length>0?e.jsx(ke,{label:D.label,onClick:D.onClick,icon:D.icon,variant:D.variant==="primary"?"primary":"outline",options:D.splitOptions,disabled:D.disabled},D.id):e.jsx(re,{variant:D.variant??"secondary",onClick:G=>{G.stopPropagation(),G.target.blur(),D.onClick()},disabled:D.disabled,leftIcon:D.icon,children:D.label},D.id))})]}),l&&e.jsx("div",{className:"mt-4",children:l})]})},$s=/<[a-z][\s\S]*>/i,As=["[&_p]:my-1.5 [&_p:first-child]:mt-0 [&_p:last-child]:mb-0 [&_p]:leading-relaxed","[&_a]:text-accent [&_a]:underline [&_a]:underline-offset-2","[&_strong]:font-semibold [&_em]:italic","[&_ul]:my-1.5 [&_ul]:list-disc [&_ul]:pl-5 [&_ol]:my-1.5 [&_ol]:list-decimal [&_ol]:pl-5","[&_li]:leading-relaxed","[&_h1]:mb-1 [&_h1]:mt-2 [&_h1]:font-semibold [&_h2]:mb-1 [&_h2]:mt-2 [&_h2]:font-semibold [&_h3]:mb-1 [&_h3]:mt-2 [&_h3]:font-semibold","[&_blockquote]:my-1.5 [&_blockquote]:border-l-2 [&_blockquote]:border-border [&_blockquote]:pl-3 [&_blockquote]:text-text-muted","[&_hr]:my-2 [&_hr]:border-border","[&_pre]:my-1.5 [&_pre]:overflow-x-auto [&_pre]:rounded-md [&_pre]:bg-surface-sunk [&_pre]:p-2 [&_pre]:text-xs","[&_code]:rounded-sm [&_code]:bg-surface-sunk [&_code]:px-1 [&_code]:py-0.5 [&_code]:font-mono [&_code]:text-xs","[&_pre_code]:bg-transparent [&_pre_code]:p-0","[&_table]:my-1.5 [&_table]:w-full [&_table]:border-collapse [&_table]:text-xs","[&_th]:border [&_th]:border-border [&_th]:px-2 [&_th]:py-1 [&_th]:text-left [&_th]:font-semibold","[&_td]:border [&_td]:border-border [&_td]:px-2 [&_td]:py-1"].join(" "),_s={p:t=>e.jsx("p",{className:"my-1.5 leading-relaxed first:mt-0 last:mb-0",...t}),a:t=>e.jsx("a",{className:"text-accent underline underline-offset-2 hover:opacity-80",target:"_blank",rel:"noopener noreferrer",...t}),strong:t=>e.jsx("strong",{className:"font-semibold",...t}),em:t=>e.jsx("em",{className:"italic",...t}),ul:t=>e.jsx("ul",{className:"my-1.5 list-disc space-y-0.5 pl-5",...t}),ol:t=>e.jsx("ol",{className:"my-1.5 list-decimal space-y-0.5 pl-5",...t}),li:t=>e.jsx("li",{className:"leading-relaxed",...t}),h1:t=>e.jsx("h1",{className:"mb-1 mt-2 text-md font-semibold first:mt-0",...t}),h2:t=>e.jsx("h2",{className:"mb-1 mt-2 text-base font-semibold first:mt-0",...t}),h3:t=>e.jsx("h3",{className:"mb-1 mt-2 text-base font-semibold first:mt-0",...t}),blockquote:t=>e.jsx("blockquote",{className:"my-1.5 border-l-2 border-border pl-3 text-text-muted",...t}),hr:t=>e.jsx("hr",{className:"my-2 border-border",...t}),pre:t=>e.jsx("pre",{className:"my-1.5 overflow-x-auto rounded-md bg-surface-sunk p-2 text-xs",...t}),code:({className:t,children:s,...r})=>{const n=String(s??"");return/language-/.test(t??"")||n.includes(`
|
|
2
2
|
`)?e.jsx("code",{className:"font-mono text-xs",...r,children:s}):e.jsx("code",{className:"rounded-sm bg-surface-sunk px-1 py-0.5 font-mono text-xs",...r,children:s})},table:t=>e.jsx("div",{className:"my-1.5 overflow-x-auto",children:e.jsx("table",{className:"w-full border-collapse text-xs",...t})}),th:t=>e.jsx("th",{className:"border border-border px-2 py-1 text-left font-semibold",...t}),td:t=>e.jsx("td",{className:"border border-border px-2 py-1",...t})};function Rs({text:t,className:s,as:r}){const n=t??"";return(r?r==="html":$s.test(n))?e.jsx("div",{className:i("break-words",As,s),dangerouslySetInnerHTML:{__html:Xe.sanitize(n,{ADD_ATTR:["target","rel"]})}}):e.jsx("div",{className:i("break-words",s),children:e.jsx(Ye,{remarkPlugins:[Ze],components:_s,children:n})})}const Ls=({label:t,meta:s,action:r,className:n})=>e.jsxs("div",{className:i("flex items-center gap-2 px-1 pb-2 pt-7 first:pt-0",n),children:[e.jsx("span",{className:"shrink-0 text-2xs font-semibold uppercase tracking-label text-text-subtle",children:t}),s&&e.jsx("span",{className:"min-w-0 flex-1 truncate text-right text-xs tabular-nums text-text-subtle",children:s}),r&&e.jsx("span",{className:"ml-auto shrink-0",children:r})]});function Ps({label:t,trailing:s,align:r="center",className:n}){const a=e.jsx("span",{className:"h-px flex-1 bg-border-subtle","aria-hidden":!0});return!t&&!s?e.jsx("div",{className:i("flex items-center py-2",n),children:a}):e.jsxs("div",{className:i("flex items-center gap-3 py-2",n),children:[r==="center"&&a,e.jsx("span",{className:"shrink-0 text-xs font-medium text-text-muted",children:t}),a,s&&e.jsx("span",{className:"shrink-0",children:s})]})}function Fs({label:t,description:s,control:r,bordered:n=!1,disabled:a=!1,className:l}){return e.jsxs("div",{className:i("flex items-center justify-between gap-4 py-2",n&&"rounded-lg border border-border px-3",a&&"opacity-50",l),children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"text-sm text-text",children:t}),s&&e.jsx("div",{className:"text-xs text-text-muted",children:s})]}),e.jsx("div",{className:"shrink-0",children:r})]})}function Is({icon:t,title:s,description:r,actions:n,children:a,className:l}){return e.jsxs("section",{className:i("flex flex-col gap-2",l),children:[e.jsxs("div",{className:"flex items-start gap-2",children:[t&&e.jsx(Y,{icon:t,size:"md",color:"secondary",className:"mt-0.5"}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("h3",{className:"text-sm font-semibold text-text",children:s}),r&&e.jsx("p",{className:"text-xs text-text-muted",children:r})]}),n&&e.jsx("div",{className:"shrink-0",children:n})]}),e.jsx("div",{className:i("flex flex-col",t&&"pl-6"),children:a})]})}function Bs({label:t,dotColor:s,onClick:r,className:n}){return e.jsxs("button",{type:"button",onClick:r,className:i("inline-flex max-w-full items-center gap-1.5 rounded-full bg-surface-sunk px-2.5 py-1 text-xs text-text-muted transition-colors duration-fast ease-out hover:bg-surface-hover hover:text-text",n),children:[s&&e.jsx("span",{className:"h-1.5 w-1.5 shrink-0 rounded-full",style:{backgroundColor:s},"aria-hidden":!0}),e.jsx("span",{className:"min-w-0 truncate",children:t}),e.jsx(Y,{icon:R.ArrowUpRight,size:"xs",className:"opacity-70"})]})}function Os(t,s){return s.split(".").reduce((r,n)=>r&&typeof r=="object"&&n in r?r[n]:void 0,t)}const Hs=({groups:t,data:s,size:r="md",className:n})=>{const a=h=>{if(!h)return"-";try{return new Date(h).toLocaleDateString("nl-NL",{year:"numeric",month:"long",day:"numeric"})}catch{return String(h)}},l=h=>h?"Ja":"Nee",o=(h,m)=>{if(!m)return String(h||"-");const b=m.find(v=>v.value===h);return b?b.label:String(h||"-")},x=d.useCallback(h=>{const m=Os(s,h.name);if(h.type==="array"){const v=m;return!v||v.length===0?e.jsx(ie,{variant:"body",size:"sm",className:"text-text-muted",children:"Geen items"}):e.jsx("div",{className:"space-y-3",children:v.map((w,g)=>e.jsxs("div",{className:"p-4 border border-border rounded-xl space-y-3",children:[e.jsx("div",{className:"flex items-center justify-between",children:e.jsxs(ie,{variant:"label",size:"sm",weight:"medium",className:"text-text-muted",children:[h.label," ",g+1]})}),e.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-3",children:h.arrayFields?.map(f=>{const z=w?.[f.name];let k="-";switch(f.type){case"text":case"email":case"number":case"tel":case"url":case"textarea":k=z||"-";break;case"select":case"radio":k=o(z,f.options);break;case"checkbox":k=l(z);break;case"date":k=a(z);break;case"custom":k=f.customComponent?.({value:z});break;default:k=String(z||"-")}return f.format&&(k=f.format(z,w)),e.jsxs("div",{className:"space-y-1",children:[e.jsx(ie,{variant:"label",size:"xs",className:"text-text-muted",children:f.label}),e.jsx(ie,{variant:"body",size:"sm",className:"text-text",children:k})]},f.name)})})]},g))})}if(h.type==="custom"&&h.customComponent)return h.customComponent({value:m});if(h.format){const v=h.format(m,s);return e.jsx(ie,{variant:"body",size:"sm",className:"text-text",children:v})}let b="-";switch(h.type){case"text":case"email":case"password":case"number":case"tel":case"url":b=m?String(m):"-";break;case"textarea":b=m?e.jsx("div",{className:"whitespace-pre-wrap",children:String(m||"-")}):"-";break;case"select":case"radio":b=o(m,h.options);break;case"checkbox":b=l(m);break;case"date":b=a(m);break;default:b=m?String(m):"-"}return e.jsx(ie,{variant:"body",size:"sm",className:"text-text",children:b})},[s]),u=d.useCallback(h=>{if(h.conditional&&!h.conditional(s))return null;const m=h.items.filter(v=>!(v.hidden||v.conditional&&!v.conditional(s)));if(m.length===0)return null;const b=i("space-y-4",{"grid gap-4":h.layout==="grid","flex flex-wrap gap-4":h.layout==="flex"},h.layout==="grid"&&{"grid-cols-1":!h.columns||h.columns===1,"grid-cols-2":h.columns===2,"grid-cols-3":h.columns===3,"grid-cols-4":h.columns===4},h.className);return e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-8 p-6 border border-border rounded-xl",children:[e.jsxs("div",{className:"md:col-span-1",children:[e.jsx(ie,{variant:"label",size:"lg",weight:"semibold",className:"text-text",children:h.title}),h.description&&e.jsx(ie,{variant:"body",size:"sm",className:"text-text-muted mt-1",children:h.description})]}),e.jsx("div",{className:"md:col-span-2",children:e.jsx("div",{className:b,children:m.map(v=>e.jsxs("div",{className:"space-y-1",style:{width:typeof v.width=="string"?v.width:void 0,gridColumn:typeof v.width=="number"?`span ${v.width} / span ${v.width}`:void 0},children:[v.type!=="custom"&&e.jsx(ie,{variant:"label",size:"sm",className:"font-medium text-text-muted",children:v.label}),x(v)]},v.name))})})]},h.id)},[s,x]),j=i("space-y-6",{"max-w-md":r==="sm","max-w-2xl":r==="md","max-w-4xl":r==="lg","max-w-full":r==="full"},n);return e.jsx("div",{className:j,children:e.jsx("div",{className:"space-y-8",children:t.map(u)})})},qs=()=>e.jsxs("div",{className:"flex flex-col gap-px","aria-hidden":!0,children:[e.jsx("div",{className:"px-2.5 pb-2 pt-5",children:e.jsx("span",{className:"block h-2 w-16 rounded-xs bg-page-hover"})}),[0,1,2,3].map(t=>e.jsxs("div",{className:"flex h-row-md items-center gap-2.5 px-2.5",children:[e.jsx("span",{className:"size-4 shrink-0 rounded-xs bg-page-hover"}),e.jsx("span",{className:"h-2 rounded-xs bg-page-hover",style:{width:`${[62,44,74,52][t]}%`}})]},t))]}),We=({item:t,isSelectedHandler:s,onClick:r,depth:n=0})=>{const a=!!(t.children&&t.children.length>0),l=s?s(t.path):!1;if(a)return e.jsxs("li",{children:[e.jsxs("div",{className:i("flex items-center gap-2 px-2.5 pt-5 pb-2 text-2xs font-semibold uppercase tracking-label text-text-disabled"),children:[e.jsx("span",{className:"min-w-0 flex-1 truncate",children:t.label}),t.count!==void 0&&t.count>0&&e.jsx("span",{className:"font-normal tabular-nums",children:t.count})]}),e.jsx("ul",{className:"flex flex-col gap-px",children:t.children?.map((u,j)=>e.jsx(We,{item:u,isSelectedHandler:s,onClick:r,depth:n+1},j))})]});const o=t.action,x=o?.visibility!=="always";return e.jsx("li",{children:e.jsxs("div",{role:"button",tabIndex:0,onClick:()=>t.path&&r?.(t.path),onKeyDown:u=>{(u.key==="Enter"||u.key===" ")&&(u.preventDefault(),t.path&&r?.(t.path))},className:i("group/item flex h-row-md cursor-pointer items-center gap-2.5 rounded-md px-2.5 text-base no-underline","transition-colors duration-fast ease-out","focus-visible:outline-none focus-visible:focus-ring",l?"bg-surface-hover font-medium text-text shadow-sm":"text-text-muted hover:bg-page-hover hover:text-text"),children:[t.icon&&e.jsx("span",{className:i("flex w-5 shrink-0 items-center justify-center",l?"text-text-muted":"text-text-subtle"),children:t.icon}),e.jsx("span",{className:"min-w-0 flex-1 truncate",children:t.label}),t.count!==void 0&&t.count>0&&e.jsx("span",{className:i("shrink-0 text-xs tabular-nums",l?"rounded-full bg-accent px-1.5 font-semibold text-accent-fg":"text-text-subtle",o&&x&&"group-hover/item:hidden group-focus-within/item:hidden"),children:t.count}),o&&e.jsx("button",{type:"button","aria-label":o.label,title:o.label,onClick:u=>{u.stopPropagation(),o.onClick()},onKeyDown:u=>u.stopPropagation(),className:i("flex size-5 shrink-0 items-center justify-center rounded-sm","text-text-subtle transition-colors duration-fast ease-out","hover:bg-page-hover hover:text-text","focus-visible:outline-none focus-visible:focus-ring",x&&"opacity-0 group-hover/item:opacity-100 focus-visible:opacity-100"),children:o.icon})]})})},Vs=({items:t,isSelectedHandler:s,onClick:r,preMenuItemsComponent:n,loading:a=!1})=>a?e.jsxs("nav",{className:"flex h-full min-h-0 shrink-0 flex-col",children:[n&&e.jsx("div",{className:"pb-4",children:n}),e.jsx(qs,{})]}):e.jsxs("nav",{className:"flex h-full min-h-0 shrink-0 flex-col",children:[n&&e.jsx("div",{className:"pb-4",children:n}),e.jsx("ul",{className:"flex min-h-0 flex-1 flex-col gap-px overflow-y-auto",children:t.map((l,o)=>!l.path&&!l.label&&!l.children?e.jsx("li",{"aria-hidden":!0,className:"h-4"},o):e.jsx(We,{item:l,isSelectedHandler:s,onClick:r},o))})]}),Us={xs:"text-xs",sm:"text-sm",md:"text-base",lg:"text-lg",xl:"text-xl","2xl":"text-2xl","3xl":"text-3xl","4xl":"text-3xl"},Ks={light:"font-normal",normal:"font-normal",medium:"font-medium",semibold:"font-semibold",bold:"font-bold"},Ws={primary:"text-text",secondary:"text-text-muted",accent:"text-accent",success:"text-success-fg",warning:"text-warning-fg",error:"text-danger-fg",info:"text-info-fg",neutral:"text-text",current:"text-current"},Gs={left:"text-left",center:"text-center",right:"text-right"},Js=({level:t=1,size:s,weight:r="semibold",color:n="current",align:a="left",truncate:l=!1,className:o,children:x,...u})=>{const j=`h${t}`,h=i("font-sans text-pretty",Us[s||Xs(t)],Ks[r],Ws[n],Gs[a],l&&"truncate",o);return e.jsx(j,{className:h,...u,children:x})};function Xs(t){return{1:"2xl",2:"xl",3:"lg",4:"lg",5:"md",6:"md"}[t]||"md"}const Ys=({commands:t,isOpen:s,onClose:r,labels:n,initialCommandPath:a,initialActiveIndex:l})=>{const[o,x]=d.useState(""),[u,j]=d.useState(a||[]),[h,m]=d.useState(l||0),b=d.useRef(null),v=d.useRef(null),g=(u.length?t.find(f=>f.id===u[0])?.subCommands||[]:t).filter(f=>f.label.toLowerCase().includes(o.toLowerCase()));return d.useEffect(()=>{s||(x(""),j(a||[]),m(l||0))},[s]),d.useEffect(()=>{const f=z=>{if(s){if(z.key==="Escape")r();else if(z.key==="ArrowUp")m(k=>k>0?k-1:g.length-1);else if(z.key==="ArrowDown")m(k=>k<g.length-1?k+1:0);else if(z.key==="Enter"){const k=g[h];k&&(k.subCommands?(j([...u,k.id]),m(0)):k.action&&(k.action(),r()))}}};return document.addEventListener("keydown",f),()=>document.removeEventListener("keydown",f)},[s,r,g,h,u]),d.useEffect(()=>{const f=z=>{b.current&&!b.current.contains(z.target)&&r()};return s&&document.addEventListener("mousedown",f),()=>document.removeEventListener("mousedown",f)},[s,r]),d.useEffect(()=>{if(!s)return;v.current?.querySelector(`[data-index="${h}"]`)?.scrollIntoView({block:"nearest"})},[h,s]),s?e.jsx("div",{className:"fixed inset-0 z-modal flex items-center justify-center bg-scrim",children:e.jsxs("div",{className:"flex flex-col w-full max-w-lg max-h-dialog p-2 mx-auto rounded-lg border border-border shadow-modal bg-surface",ref:b,children:[e.jsxs("div",{className:"flex items-center gap-2 px-3 flex-shrink-0",children:[e.jsx(R.Search,{className:"w-4 h-4 text-text-muted shrink-0"}),e.jsx("input",{type:"text",autoFocus:!0,placeholder:n?.searchPlaceholder||"Search commands...",value:o,onChange:f=>x(f.target.value),className:"w-full border-0 bg-transparent py-2 text-text focus:outline-none"})]}),e.jsxs("div",{ref:v,className:"mt-2 pt-2 text-sm border-t border-border max-h-dialog-list overflow-y-auto",children:[g.length===0&&e.jsx("div",{className:"text-text-muted text-center text-sm",children:n?.noCommandsFound||"No commands found"}),g.map((f,z)=>e.jsxs("div",{"data-index":z,className:`flex items-center p-2 cursor-pointer rounded-md ${z===h?"bg-accent-soft text-accent":"text-text"}`,onClick:()=>{f.subCommands?(j([...u,f.id]),m(0)):f.action&&(f.action(),r())},onMouseEnter:()=>m(z),children:[f.icon&&e.jsx("span",{className:"mr-3",children:f.icon}),e.jsx("span",{className:"flex-grow",children:f.label}),f.subCommands&&e.jsx("span",{className:"text-text-muted",children:e.jsx(R.ChevronRight,{className:"w-4 h-4"})})]},f.id))]}),e.jsxs("div",{className:"flex items-center gap-4 px-3 pt-2 mt-2 text-xs text-text-muted border-t border-border",children:[e.jsxs("span",{className:"flex items-center gap-1.5",children:[e.jsx("kbd",{className:"inline-flex items-center justify-center min-w-5 px-1 py-0.5 rounded border border-border bg-surface-sunk text-xs font-medium not-italic",children:"↑↓"}),n?.navigate||"to navigate"]}),e.jsxs("span",{className:"flex items-center gap-1.5",children:[e.jsx("kbd",{className:"inline-flex items-center justify-center min-w-5 px-1 py-0.5 rounded border border-border bg-surface-sunk text-xs font-medium not-italic",children:"↵"}),n?.select||"to select"]}),e.jsxs("span",{className:"flex items-center gap-1.5",children:[e.jsx("kbd",{className:"inline-flex items-center justify-center min-w-5 px-1 py-0.5 rounded border border-border bg-surface-sunk text-xs font-medium not-italic",children:"Esc"}),n?.close||"to close"]})]})]})}):null},Zs={none:"p-0",xs:"p-1",sm:"p-2",md:"p-4",lg:"p-6",xl:"p-8","2xl":"p-12"},Qs={none:"m-0",xs:"m-1",sm:"m-2",md:"m-4",lg:"m-6",xl:"m-8","2xl":"m-12"},er={none:"",primary:"bg-accent text-accent-fg",secondary:"bg-surface-hover",accent:"bg-accent-soft",success:"bg-success-soft",warning:"bg-warning-soft",error:"bg-danger-soft",info:"bg-info-soft",neutral:"bg-surface-hover",white:"bg-surface",module:"bg-surface","module-subtle":"bg-surface-sunk",backdrop:"bg-page",editor:"bg-surface",input:"bg-surface-input"},tr={none:"rounded-none",sm:"rounded-sm",md:"rounded-md",lg:"rounded-lg",xl:"rounded-xl",full:"rounded-full"},sr={none:"shadow-none",sm:"shadow-none",md:"shadow-overlay",lg:"shadow-overlay",xl:"shadow-modal","2xl":"shadow-modal"},rr={none:"border-0",sm:"border",md:"border-2",lg:"border-4"},nr={primary:"border-accent-border",secondary:"border-border",accent:"border-accent-border",success:"border-success-border",warning:"border-warning-border",error:"border-danger-border",info:"border-info-border",neutral:"border-border-subtle",white:"border-border-subtle"},Me=d.forwardRef(({padding:t,margin:s,background:r,radius:n,shadow:a,border:l,borderColor:o,className:x,children:u,...j},h)=>e.jsx("div",{ref:h,className:i(t&&Zs[t],s&&Qs[s],r&&er[r],n&&tr[n],a&&sr[a],l&&rr[l],o&&nr[o],x),...j,children:u}));Me.displayName="Box";const ar=({children:t,title:s,...r})=>e.jsxs(Me,{background:"module",radius:"lg",shadow:"none",border:"sm",borderColor:"neutral",...r,children:[s&&e.jsx("span",{className:"mb-2 block text-sm font-semibold text-text",children:s}),t]});function lr({identifier:t,resourceLoader:s,framework:r="react",fallback:n,errorFallback:a,componentProps:l,className:o}){const x=d.useRef(null),[u,j]=d.useState(!0),[h,m]=d.useState(!1),[b,v]=d.useState(null),w=d.useRef(null);d.useRef(null);const g=d.useRef(s);return g.current=s,d.useEffect(()=>{let f=!0;return(async()=>{j(!0),m(!1),v(null);try{const k=await g.current();if(!f)return;const V=k.component||k.default||k;v(r==="react"?()=>V:()=>k)}catch(k){console.error(`[FederatedResource] Load failed: ${t}`,k),f&&m(!0)}finally{f&&j(!1)}})(),()=>{f=!1}},[t,r]),d.useEffect(()=>{if(u||!b||r==="react")return;const f=x.current;if(f){if(r==="svelte"){const z=b.default||b,k=new z({target:f,props:l||{}});return w.current=k,()=>k.$destroy()}if(b.mount){const z=b.mount({container:f,props:l||{}});return()=>{typeof z=="function"?z():b.unmount?.(f)}}}},[b,r,u]),d.useEffect(()=>{r==="svelte"&&w.current&&w.current.$set?.(l)},[l,r]),e.jsxs("div",{ref:x,className:o,style:{display:"contents"},children:[u&&n,!u&&h&&a,r==="react"&&!h&&b&&e.jsx(b,{...l})]})}class or extends d.Component{constructor(){super(...arguments),this.state={hasError:!1,error:null}}static getDerivedStateFromError(s){return{hasError:!0,error:s}}componentDidCatch(s,r){console.error(`[ErrorBoundary] Error in ${this.props.name||"Component"}:`,s,r)}render(){return this.state.hasError?this.props.fallback?this.props.fallback:e.jsxs("div",{className:"p-4 m-4 border border-danger-border bg-danger-soft rounded-lg",children:[e.jsx("h2",{className:"text-lg font-semibold text-danger-fg",children:"Something went wrong"}),e.jsx("p",{className:"text-sm text-danger-fg mt-1",children:this.props.name?`Error in ${this.props.name}`:"The component failed to render."}),e.jsx("button",{className:"mt-4 px-4 py-2 bg-danger text-on-error rounded hover:opacity-90 transition-opacity text-sm",onClick:()=>this.setState({hasError:!1,error:null}),children:"Try again"})]}):this.props.children}}exports.AssistantCard=gs;exports.Avatar=Ke;exports.AvatarStack=Ns;exports.Badge=rs;exports.Box=Me;exports.Button=re;exports.ButtonGroup=ct;exports.Card=ar;exports.ChannelBadge=ks;exports.Checkbox=xe;exports.CommandPalette=Ys;exports.ConfirmDialog=Qt;exports.ContentLoading=Oe;exports.DatePicker=ge;exports.Dropdown=He;exports.EmptyState=as;exports.ErrorBoundary=or;exports.FederatedResource=lr;exports.FilterChip=Ae;exports.FolderSelect=Fe;exports.Form=Zt;exports.FormSection=Ue;exports.Heading=Js;exports.Icon=Y;exports.Image=Cs;exports.Kbd=ls;exports.KpiCard=Ts;exports.Link=gt;exports.List=Es;exports.ListBulkAction=Ss;exports.MeetingGrid=st;exports.MessageBubble=Ms;exports.Modal=Ee;exports.PageHeader=Ds;exports.PageToolbar=At;exports.PageToolbarActions=Se;exports.ParticipantTile=rt;exports.Popover=we;exports.ProgressBar=is;exports.RichText=Rs;exports.SearchField=Ce;exports.SearchableTextField=Ie;exports.SectionCaption=Ls;exports.SectionDivider=Ps;exports.SegmentedToggle=_e;exports.Select=he;exports.SettingsRow=Fs;exports.SettingsSection=Is;exports.SidebarMenu=Vs;exports.SourceChip=Bs;exports.Spinner=fs;exports.SplitButton=ke;exports.StatusDot=hs;exports.StepIndicator=bs;exports.StorageInput=Ve;exports.Switch=Be;exports.TabBar=Ot;exports.Table=Ne;exports.Tabs=qe;exports.Text=ie;exports.TextArea=pe;exports.TextField=me;exports.VideoSurface=nt;exports.View=Hs;exports.catTone=tt;exports.cn=i;exports.createSizes=et;exports.createVariants=Qe;exports.dateFilterHandler=_t;exports.selectFilterHandler=Rt;
|
|
3
3
|
//# sourceMappingURL=index.cjs.map
|