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