@opencxh/ui-kit 3.106.0 → 3.108.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const $e=require("clsx"),e=require("react/jsx-runtime"),G=require("lucide-react"),i=require("react");function f(...t){return $e.clsx(t)}function De(t){return(r,s)=>t[r]?.[s]||""}function Ie(t){return r=>t[r]||""}function Pe({tiles:t,pinned:r,className:s}){if(r)return e.jsxs("div",{className:f("flex flex-col md:flex-row gap-2 h-full min-h-0",s),children:[e.jsx("div",{className:"flex-1 min-h-0",children:r}),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:f("grid gap-2 h-full",n,s),children:t.map((a,l)=>e.jsx("div",{children:a},l))})}function Ae({name:t,avatarUrl:r,muted:s,speaking:n,hasVideo:a,videoSlot:l,className:c,fill:b}){return e.jsxs("div",{className:f("relative rounded-lg overflow-hidden bg-video-surface flex items-center justify-center",b?"h-full w-full":"aspect-video",n&&"ring-2 ring-speaking",c),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:r?e.jsx("img",{src:r,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(G.VideoOff,{className:"w-8 h-8"}):e.jsx(G.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:[s?e.jsx(G.MicOff,{className:"w-3 h-3"}):e.jsx(G.Mic,{className:"w-3 h-3"}),e.jsx("span",{className:"truncate max-w-35",children:t})]})]})}function Be({attach:t,active:r=!0,mirrored:s=!1,className:n}){const a=i.useRef(null);return i.useEffect(()=>{if(!r||!a.current)return;const l=t(a.current);return()=>{typeof l=="function"&&l(),a.current&&(a.current.innerHTML="")}},[t,r]),e.jsx("div",{ref:a,className:f("w-full h-full bg-video-surface-strong overflow-hidden",s&&"[&>*]:scale-x-[-1]",n)})}const Re={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",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"},Fe={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",full:"h-control-md px-4 text-sm"},Oe={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",full:"h-control-md w-8"},Q=i.forwardRef(({variant:t="primary",size:r="md",fullWidth:s=!1,loading:n=!1,leftIcon:a,rightIcon:l,iconOnly:c=!1,className:b,children:g,disabled:y,...x},d)=>{const u=y||n;return e.jsxs("button",{ref:d,type:"button",className:f("inline-flex shrink-0 items-center justify-center gap-2 rounded-md font-semibold","transition-colors duration-fast ease-out","focus-visible:outline-none focus-visible:focus-ring","disabled:cursor-not-allowed disabled:border-border-subtle","disabled:bg-surface-hover disabled:text-text-disabled",Re[t],c?Oe[r]:Fe[r],(s||r==="full")&&"w-full",n&&"cursor-wait",b),disabled:u,"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:"shrink-0",children:a}),!c&&g,!n&&l&&e.jsx("span",{className:"shrink-0",children:l}),c&&!n&&!a&&!l&&g]})});Q.displayName="Button";const Ve=({children:t,size:r="md",orientation:s="horizontal",attached:n=!0,className:a})=>{const l=f("inline-flex",{"flex-row":s==="horizontal","flex-col":s==="vertical","[&>*:not(:first-child):not(:last-child)]:rounded-none":n,"[&>*:first-child]:rounded-r-none":n&&s==="horizontal","[&>*:last-child]:rounded-l-none":n&&s==="horizontal","[&>*:first-child]:rounded-b-none":n&&s==="vertical","[&>*:last-child]:rounded-t-none":n&&s==="vertical","[&>*:not(:first-child)]:-ml-px":n&&s==="horizontal","[&>*:not(:first-child)]:-mt-px":n&&s==="vertical","gap-1":!n&&r==="xs","gap-2":!n&&(r==="sm"||r==="md"),"gap-3":!n&&(r==="lg"||r==="xl")},a);return e.jsx("div",{className:l,role:"group",children:t})},We={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"},ne=({icon:t,size:r="md",color:s="current",clickable:n=!1,onClick:a,className:l,"aria-label":c,...b})=>{const g=typeof r=="number"?r:qe(r),y=f("inline-block shrink-0",We[s],n&&["cursor-pointer rounded-sm transition-opacity duration-fast ease-out hover:opacity-80","focus-visible:outline-none focus-visible:focus-ring"],l),x={size:g,strokeWidth:2,className:y,onClick:n?a:void 0,"aria-label":c,"aria-hidden":c?void 0:!0,role:n?"button":void 0,tabIndex:n?0:void 0,onKeyDown:n?d=>{(d.key==="Enter"||d.key===" ")&&(d.preventDefault(),a?.())}:void 0,...b};return e.jsx(t,{...x})};function qe(t){return{xs:12,sm:14,md:16,lg:20,xl:24}[t]}function He(){return e.jsx("svg",{className:"size-icon-sm",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,children:e.jsx("path",{d:"m6 9 6 6 6-6"})})}function Ue({label:t,active:r=!1,caret:s=!1,onClear:n,onClick:a,className:l}){return e.jsxs("span",{onClick:a,className:f("inline-flex h-control-sm cursor-pointer select-none items-center gap-1.5 rounded-full px-3 text-sm font-semibold","transition-colors duration-fast ease-out",r?"bg-accent text-accent-fg":"border border-border text-text-muted hover:bg-surface-hover hover:text-text",l),children:[t,s&&e.jsx(He,{}),r&&n&&e.jsx("button",{type:"button","aria-label":"Filter wissen",onClick:c=>{c.stopPropagation(),n()},className:"ml-0.5 inline-flex items-center rounded-full focus-visible:outline-none focus-visible:focus-ring",children:e.jsx(ne,{icon:G.X,size:"xs"})})]})}const _e={xs:"text-xs",sm:"text-sm",md:"text-base",lg:"text-md",xl:"text-lg"},Ge={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"},Ke={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"},Je=({variant:t="default",size:r="md",color:s="primary",disabled:n=!1,external:a=!1,className:l,children:c,href:b,target:g,rel:y,...x})=>{const d=a||b&&(b.startsWith("http")||b.startsWith("mailto:")),u=f("inline-flex items-center gap-1 underline-offset-2","transition-colors duration-fast ease-out","focus-visible:outline-none focus-visible:focus-ring",_e[r],!n&&Ge[s],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",Ke[s]],n&&"pointer-events-none cursor-not-allowed text-text-disabled opacity-50",l),h={...x,href:n?void 0:b,target:d?"_blank":g,rel:d?"noopener noreferrer":y,"aria-disabled":n||void 0};return e.jsxs("a",{className:u,...h,children:[c,d&&e.jsx(G.ExternalLink,{className:"size-icon-sm shrink-0","aria-hidden":!0})]})},Ye={sm:"h-control-sm px-3 text-sm",md:"h-control-md px-3 text-sm"};function Xe({options:t,value:r,onChange:s,size:n="sm",className:a,"aria-label":l}){return e.jsx("div",{role:"tablist","aria-label":l,className:f("inline-flex gap-0.5 rounded-md bg-surface-hover p-0.5",a),children:t.map(c=>{const b=c.value===r;return e.jsx("button",{role:"tab","aria-selected":b,type:"button",onClick:()=>s(c.value),className:f("inline-flex items-center justify-center rounded-sm font-semibold","transition-colors duration-fast ease-out","focus-visible:outline-none focus-visible:focus-ring",Ye[n],b?"bg-surface text-text":"text-text-muted hover:text-text"),children:c.label},c.value)})})}const je=({trigger:t,children:r,placement:s="bottom-start",className:n,disabled:a=!1,triggerLabel:l})=>{const[c,b]=i.useState(!1),[g,y]=i.useState({}),x=i.useRef(null),d=i.useRef(null);i.useEffect(()=>{if(!c)return;const N=p=>{x.current&&!x.current.contains(p.target)&&b(!1)},j=p=>{p.key==="Escape"&&b(!1)};return document.addEventListener("mousedown",N),document.addEventListener("keydown",j),()=>{document.removeEventListener("mousedown",N),document.removeEventListener("keydown",j)}},[c]);const u=N=>{if(N.stopPropagation(),!a){if(!c){const j=d.current?.getBoundingClientRect();if(j){const L={};s.startsWith("bottom")?L.top=j.bottom+6:L.bottom=window.innerHeight-j.top+6,s.endsWith("start")?L.left=j.left:L.right=window.innerWidth-j.right,y(L)}}b(j=>!j)}},h=()=>b(!1);return e.jsxs("div",{ref:x,className:"relative inline-flex",children:[e.jsx("button",{ref:d,type:"button",onClick:u,disabled:a,"aria-label":l,"aria-expanded":c,className:f("inline-flex items-center",a&&"cursor-not-allowed opacity-50"),children:t}),c&&e.jsx("div",{className:f("fixed z-overlay bg-surface rounded-lg shadow-overlay border border-border",n),style:g,children:typeof r=="function"?r(h):r})]})},Ze={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"},Qe={sm:"h-control-sm w-7",md:"h-control-md w-8"};function he({label:t,onClick:r,variant:s="primary",size:n="md",icon:a,options:l,disabled:c=!1,loading:b=!1,menuPlacement:g="bottom-end",menuLabel:y="More options"}){const x=c||b,d=l.length>0;return e.jsxs("div",{className:"inline-flex items-center gap-px",children:[e.jsx(Q,{variant:s,size:n,onClick:r,disabled:c,loading:b,leftIcon:a,className:f(d&&"rounded-r-none"),children:t}),d&&e.jsx(je,{placement:g,disabled:x,triggerLabel:y,className:"min-w-menu py-1",trigger:e.jsx("span",{"aria-hidden":"true",className:f("inline-flex items-center justify-center rounded-md rounded-l-none","transition-colors duration-fast ease-out",Ze[s],Qe[n],x&&"cursor-not-allowed opacity-50"),children:e.jsx(G.ChevronDown,{className:"size-icon-md"})}),children:u=>e.jsx(e.Fragment,{children:l.map(h=>e.jsxs("button",{type:"button",onClick:()=>{h.onClick(),u()},className:f("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",h.variant==="destructive"?"text-danger-fg hover:bg-danger-soft":"text-text hover:bg-surface-hover"),children:[h.icon&&e.jsx("span",{className:"shrink-0",children:h.icon}),h.label]},h.id))})})]})}const et={sm:"size-checkbox",md:"size-checkbox",lg:"size-checkbox",full:"size-checkbox"},tt={sm:"text-sm",md:"text-base",lg:"text-md",full:"text-md"},oe=i.forwardRef(({label:t,helperText:r,error:s,size:n="md",indeterminate:a=!1,containerClassName:l,labelClassName:c,className:b,id:g,...y},x)=>{const d=i.useId(),u=g||`checkbox-${d}`,h=!!s,N=i.useRef(null),j=i.useCallback(p=>{N.current=p,typeof x=="function"?x(p):x&&typeof x=="object"&&(x.current=p)},[x]);return i.useEffect(()=>{N.current&&(N.current.indeterminate=a)},[a]),e.jsxs("div",{className:f("flex flex-col",l),children:[e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx("input",{ref:j,id:u,type:"checkbox","aria-invalid":h||void 0,className:f("mt-0.5 shrink-0 rounded-sm border bg-surface-input 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],h?"border-danger-border":"border-border-strong",b),...y}),t&&e.jsxs("div",{className:"flex-1",children:[e.jsx("label",{htmlFor:u,className:f("cursor-pointer",h?"text-danger-fg":"text-text",tt[n],c),children:t}),r&&!s&&e.jsx("p",{className:"mt-0.5 text-xs text-text-subtle",children:r})]})]}),s&&e.jsx("p",{className:"mt-1 text-xs text-danger-fg",children:s})]})});oe.displayName="Checkbox";const st=()=>e.jsx("svg",{className:"h-4 w-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M8 7V3m8 4V3m-9 8h10M5 21h14a2 2 0 002-2V7a2 2 0 00-2-2H5a2 2 0 00-2 2v12a2 2 0 002 2z"})}),rt=()=>e.jsx("svg",{className:"h-4 w-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"m15 18-6-6 6-6"})}),nt=()=>e.jsx("svg",{className:"h-4 w-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"m9 18 6-6-6-6"})}),de=i.forwardRef(({value:t,onChange:r,placeholder:s="Select date",disabled:n=!1,required:a=!1,size:l="md",className:c,minDate:b,maxDate:g,format:y="MM/dd/yyyy"},x)=>{const[d,u]=i.useState(!1),[h,N]=i.useState(()=>t||new Date),j=i.useRef(null);i.useEffect(()=>{const z=W=>{j.current&&!j.current.contains(W.target)&&u(!1)};return d&&document.addEventListener("mousedown",z),()=>{document.removeEventListener("mousedown",z)}},[d]);const p=z=>{if(!z)return"";const W=z.getDate().toString().padStart(2,"0"),_=(z.getMonth()+1).toString().padStart(2,"0"),w=z.getFullYear();switch(y){case"dd/MM/yyyy":return`${W}/${_}/${w}`;case"yyyy-MM-dd":return`${w}-${_}-${W}`;case"MM/dd/yyyy":default:return`${_}/${W}/${w}`}},L=()=>{const z=h.getFullYear(),W=h.getMonth(),_=new Date(z,W,1),w=new Date(_);w.setDate(w.getDate()-_.getDay());const m=[],C=new Date(w);for(let P=0;P<42;P++)m.push(new Date(C)),C.setDate(C.getDate()+1);return m},k=z=>{z.getMonth()===h.getMonth()&&(b&&z<b||g&&z>g||(r?.(z),u(!1)))},K=()=>{N(new Date(h.getFullYear(),h.getMonth()-1,1))},R=()=>{N(new Date(h.getFullYear(),h.getMonth()+1,1))},Y=()=>{r?.(null),u(!1)},U=f("w-full border border-border rounded-md 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"},c),$=L(),J=["January","February","March","April","May","June","July","August","September","October","November","December"];return e.jsxs("div",{ref:j,className:"relative",children:[e.jsxs("div",{className:"relative",children:[e.jsx("input",{ref:x,type:"text",value:p(t??null),placeholder:s,disabled:n,required:a,readOnly:!0,onClick:()=>!n&&u(!d),className:f(U,"pr-10 cursor-pointer")}),e.jsx("button",{type:"button",onClick:()=>!n&&u(!d),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,{})})]}),d&&e.jsxs("div",{className:"absolute z-50 mt-1 bg-surface border border-border rounded-lg shadow-overlay p-4 min-w-panel",children:[e.jsxs("div",{className:"flex items-center justify-between mb-4",children:[e.jsx("button",{onClick:K,className:"p-1 hover:bg-surface-hover rounded",children:e.jsx(rt,{})}),e.jsxs("h3",{className:"text-sm font-medium text-text",children:[J[h.getMonth()]," ",h.getFullYear()]}),e.jsx("button",{onClick:R,className:"p-1 hover:bg-surface-hover rounded",children:e.jsx(nt,{})})]}),e.jsx("div",{className:"grid grid-cols-7 gap-1 mb-2",children:["Su","Mo","Tu","We","Th","Fr","Sa"].map(z=>e.jsx("div",{className:"text-xs font-medium text-text-muted text-center py-1",children:z},z))}),e.jsx("div",{className:"grid grid-cols-7 gap-1",children:$.map((z,W)=>{const _=z.getMonth()===h.getMonth(),w=t&&z.toDateString()===t.toDateString(),m=z.toDateString()===new Date().toDateString(),C=!_||b&&z<b||g&&z>g;return e.jsx("button",{onClick:()=>!C&&k(z),disabled:C,className:f("w-8 h-8 text-sm rounded transition-colors duration-fast",{"text-text hover:bg-surface-hover":_&&!w&&!C,"bg-accent text-accent-fg":w,"bg-surface-hover text-text":m&&!w,"text-text-muted cursor-not-allowed":C}),children:z.getDate()},W)})}),e.jsxs("div",{className:"flex justify-between items-center mt-4 pt-3 border-t border-border",children:[e.jsx("button",{onClick:Y,className:"text-sm text-text-muted hover:text-text",children:"Clear"}),e.jsx("button",{onClick:()=>u(!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"},ie=t=>t.trim().toLowerCase(),ce=i.forwardRef(({label:t,helperText:r,error:s,size:n="md",fullWidth:a=!1,options:l,placeholder:c,containerClassName:b,labelClassName:g,className:y,id:x,searchable:d,multiple:u,value:h,onChange:N,allowCreate:j,onCreateOption:p,...L},k)=>{const K=x||`select-${Math.random().toString(36).substr(2,9)}`,R=!!s,[Y,U]=i.useState(!1),[$,J]=i.useState(""),z=i.useRef(null),[W,_]=i.useState(l);i.useImperativeHandle(k,()=>z.current),i.useEffect(()=>{const D=I=>{z.current&&!z.current.contains(I.target)&&U(!1)};return document.addEventListener("mousedown",D),()=>document.removeEventListener("mousedown",D)},[]);const w=i.useCallback((D,I)=>D.some(v=>ie(v.value)===ie(I)||ie(v.label)===ie(I)),[]),m=i.useCallback((D,I)=>{const v=[...D],T=B=>{const O=(B??"").trim();O&&(w(v,O)||v.push({value:O,label:O}))};return Array.isArray(I)?I.forEach(T):T(I),v},[w]);i.useEffect(()=>{_(D=>{const I=[...l];return D.forEach(v=>{!w(I,v.value)&&!w(I,v.label)&&I.push(v)}),m(I,h)})},[l,h,m,w]);const C=D=>{if(u){const I=Array.isArray(h)?h:[],v=I.includes(D)?I.filter(T=>T!==D):[...I,D];N?.(v)}else N?.(D),U(!1),J("")},P=u?null:W.find(D=>D.value===h),S=u?W.filter(D=>Array.isArray(h)&&h.includes(D.value)):[],q=d&&$?W.filter(D=>D.label.toLowerCase().includes($.toLowerCase())):W,M=!!j&&!!d&&!!$.trim()&&!w(W,$),ee=D=>{const I=D.trim();if(!I)return;const v=p?.(I)??{value:I,label:I};if(w(W,v.value)||w(W,v.label)){C(v.value),J(""),u||U(!1);return}_(T=>[...T,v]),C(v.value),J(""),u||U(!1)},te=()=>u?S.length>0?S.map(D=>D.label).join(", "):c||"Select options":P?.label||c||"Select an option";return e.jsxs("div",{ref:z,className:f("relative flex flex-col",a&&"w-full",b),...L,children:[t&&e.jsx("label",{htmlFor:K,onClick:()=>U(!Y),className:f("block text-xs font-semibold uppercase tracking-label mb-1.5",R?"text-danger-fg":"text-text-muted",g),children:t}),e.jsxs("div",{className:"relative",children:[e.jsxs("button",{type:"button",id:K,onClick:()=>U(!Y),className:f("flex w-full items-center justify-between gap-2 rounded-md 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],R?"border-danger-border text-danger-fg focus-visible:focus-ring":"border-border text-text",y),children:[e.jsx("span",{className:"truncate flex-1 min-w-0",children:te()}),e.jsx(G.ChevronDownIcon,{size:16,className:f("shrink-0 opacity-60 transition-transform duration-fast",Y&&"rotate-180")})]}),Y&&e.jsxs("div",{className:"absolute z-10 mt-1 w-full rounded-lg bg-surface shadow-overlay border border-border",children:[d&&e.jsx("div",{className:"p-2",children:e.jsx("input",{type:"text",placeholder:"Search...",value:$,onChange:D=>J(D.target.value),onKeyDown:D=>{D.key==="Enter"&&M&&(D.preventDefault(),ee($))},className:f("w-full px-3 py-2 text-sm rounded-md border","text-text border-border focus-visible:outline-none focus-visible:focus-ring")})}),M&&e.jsxs("div",{className:f("cursor-pointer px-3 py-1.5 text-sm","text-info-fg hover:bg-surface-hover"),onClick:()=>ee($),children:["+: “",$.trim(),"”"]}),e.jsxs("ul",{className:"max-h-60 overflow-auto py-1",children:[c&&!u&&e.jsx("li",{className:"cursor-pointer px-3 py-1.5 text-sm text-text-muted hover:bg-surface-hover",onClick:()=>{N?.(""),U(!1)},children:c}),q.map(D=>{const I=u?Array.isArray(h)&&h.includes(D.value):h===D.value;return e.jsx("li",{onClick:()=>!D.disabled&&C(D.value),className:f("cursor-pointer px-3 py-1.5 text-sm","text-text",D.disabled?"opacity-50 cursor-not-allowed":"hover:bg-surface-hover",I&&"bg-accent-soft text-accent font-semibold"),children:e.jsxs("div",{className:"flex items-center",children:[u&&e.jsx("input",{type:"checkbox",checked:I,readOnly:!0,className:"mr-3 h-4 w-4 rounded border-border [&:not(:checked)]:bg-surface-input text-accent "}),e.jsx("span",{children:D.label})]})},D.value)})]})]})]}),(s||r)&&e.jsx("p",{className:f("mt-1 text-xs",R?"text-danger-fg":"text-text-muted"),children:s||r})]})});ce.displayName="Select";const lt={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"},ye="mb-1.5 block text-xs font-semibold uppercase tracking-label",ae=i.forwardRef(({label:t,helperText:r,error:s,size:n="md",fullWidth:a=!1,startIcon:l,endIcon:c,loading:b=!1,containerClassName:g,labelClassName:y,className:x,id:d,...u},h)=>{const N=i.useId(),j=d||`textfield-${N}`,p=!!s,L=s||r?`${j}-description`:void 0;return e.jsxs("div",{className:f("flex flex-col",a&&"w-full",g),children:[t&&e.jsx("label",{htmlFor:j,className:f(ye,p?"text-danger-fg":"text-text-subtle",y),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:h,id:j,"aria-invalid":p||void 0,"aria-describedby":L,className:f("block w-full rounded-md 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",lt[n],l&&"pl-9",(c||b)&&"pr-9",p?"border-danger-border bg-danger-soft":"border-border hover:border-border-strong",x),...u}),(c||b)&&e.jsx("span",{className:"absolute inset-y-0 right-0 flex items-center pr-3 text-text-muted",children:b?e.jsx("span",{"aria-hidden":!0,className:"size-icon-md animate-spin rounded-full border-2 border-border border-t-transparent"}):c})]}),(s||r)&&e.jsx("p",{id:L,className:f("mt-1 text-xs",p?"text-danger-fg":"text-text-subtle"),children:s||r})]})});ae.displayName="TextField";function Ne({value:t,onChange:r,onListFolders:s,disabled:n,size:a="md",placeholder:l,templatePlaceholder:c,showTemplate:b=!0}){const[g,y]=i.useState([]);i.useEffect(()=>{let d=!0;return Promise.resolve(s?.()).then(u=>{d&&u&&y(u.data??[])}).catch(()=>{}),()=>{d=!1}},[]);const x=t??{};return e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsx(ce,{size:a,fullWidth:!0,value:x.folderId??"",options:g.map(d=>({value:d.id,label:d.name})),placeholder:l??"Select a folder",onChange:d=>r?.({...x,folderId:d})}),b&&e.jsx(ae,{size:a,disabled:n??!1,value:x.pathTemplate??"",placeholder:c??"Sub-path e.g. {yyyy}/{mm}/{dd} (optional)",onChange:d=>r?.({...x,pathTemplate:d.target.value})})]})}const le=(...t)=>t.filter(Boolean).join(" "),ot=t=>e.jsx("svg",{...t,xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",strokeWidth:1.5,stroke:"currentColor",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"m21 21-5.197-5.197m0 0A7.5 7.5 0 1 0 5.197 5.197a7.5 7.5 0 0 0 10.606 10.606Z"})}),ct=t=>e.jsx("svg",{...t,xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",strokeWidth:1.5,stroke:"currentColor",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"m19.5 8.25-7.5 7.5-7.5-7.5"})}),it={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"},me={sm:"h-4 w-4",md:"h-5 w-5",lg:"h-6 w-6",full:"h-6 w-6"},we=i.forwardRef(({label:t,helperText:r,error:s,size:n="md",fullWidth:a=!1,startIcon:l=e.jsx(ot,{}),loading:c=!1,containerClassName:b,labelClassName:g,className:y,id:x,options:d,onRemoteSearch:u,onSelect:h,debounceTime:N=500,showAllOnOpen:j=!1,value:p,onChange:L,...k},K)=>{const R=x||`searchfield-${Math.random().toString(36).substr(2,9)}`,Y=!!s,U=i.useRef(null),$=i.useRef(null),[J,z]=i.useState(p||""),[W,_]=i.useState(!1),[w,m]=i.useState(!1),[C,P]=i.useState(!1);i.useEffect(()=>{p!==void 0&&z(p)},[p]);const S=i.useMemo(()=>{if(j&&!C||!J)return d;const v=String(J).toLowerCase();return d.filter(T=>String(T.label).toLowerCase().includes(v))},[J,d,j,C]);i.useEffect(()=>{if(!u||!J){m(!1);return}const v=setTimeout(async()=>{m(!0);try{await u(String(J))}catch(T){console.error("Remote search failed:",T)}finally{m(!1)}},N);return()=>{clearTimeout(v),m(!1)}},[J,N,u]),i.useEffect(()=>{const v=T=>{U.current&&!U.current.contains(T.target)&&_(!1)};return document.addEventListener("mousedown",v),()=>document.removeEventListener("mousedown",v)},[]);const q=v=>{const T=v.target.value;z(T),_(!0),P(!0),L&&L(v)},M=v=>{z(v.label),_(!1),P(!1),h&&h(v.value)},ee=()=>{(d.length>0||u)&&(_(!0),P(!1))},te=c||w,D=W&&(S.length>0||te),I=i.useMemo(()=>K||$,[K]);return e.jsxs("div",{className:le("flex flex-col",a?"w-full":"",b||"","relative"),ref:U,children:[t&&e.jsx("label",{htmlFor:R,className:le("block text-sm font-medium mb-1",Y?"text-danger-fg":"text-text",g||""),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:le("text-text-muted",me[n]),children:l})}),e.jsx("input",{ref:I,id:R,value:J,onChange:q,onFocus:ee,className:le("block w-full rounded-md 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",it[n],l?"pl-10":"","pr-10",Y?"border-danger-border text-danger-fg focus-visible:focus-ring":"border-border text-text",y||""),...k}),e.jsx("div",{className:"absolute inset-y-0 right-0 pr-3 flex items-center",children:te||c?e.jsxs("svg",{className:le("animate-spin text-info-fg",me[n]),xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",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"})]}):e.jsx(ct,{className:le("text-text-muted cursor-pointer transition-transform",me[n],W?"rotate-180":"rotate-0"),onClick:()=>{_(v=>(v||P(!1),!v))}})})]}),D&&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:S.length>0?S.map(v=>e.jsx("li",{className:"px-4 py-2 cursor-pointer text-text hover:bg-accent-soft hover:text-accent transition-colors",onClick:()=>M(v),role:"option","aria-selected":J===v.label,children:v.label},v.value)):e.jsx("li",{className:"px-4 py-2 text-text-muted",children:te||c?"Zoeken op afstand...":"Geen resultaten gevonden."})}),(s||r)&&e.jsx("p",{className:le("mt-1 text-xs",Y?"text-danger-fg":"text-text-muted"),children:s||r}),u&&e.jsxs("p",{className:"mt-2 text-xs text-success-fg",children:["Huidige zoekterm (niet-gedebounced): ",String(J)]})]})});we.displayName="SearchableTextField";function ke({children:t,showTableSkeleton:r=!1,tableColumns:s=6,tableRows:n=8}){return t?e.jsx("main",{className:"flex-1 bg-surface p-6",children:e.jsx("div",{className:"w-full max-w-6xl mx-auto animate-pulse",children:t})}):e.jsx("main",{className:"flex-1 bg-surface p-6",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(${s}, minmax(0, 1fr))`},children:Array.from({length:s}).map((a,l)=>e.jsx("div",{className:"h-4 w-2/3 rounded-sm bg-border-strong"},`header-${l}`))}),Array.from({length:n}).map((a,l)=>e.jsx("div",{className:"grid gap-2 border-t border-border-subtle p-3",style:{gridTemplateColumns:`repeat(${s}, minmax(0, 1fr))`},children:Array.from({length:s}).map((c,b)=>e.jsx("div",{className:"h-4 w-full rounded-sm bg-surface-hover"},`cell-${l}-${b}`))},`row-${l}`))]})]})})}const Ce=({trigger:t,options:r,value:s,onSelect:n,placement:a="bottom-start",disabled:l=!1,className:c,showCheck:b=!0,header:g})=>{const[y,x]=i.useState(!1),[d,u]=i.useState(null),[h,N]=i.useState({top:0,left:0}),[j,p]=i.useState({}),L=i.useRef(null),k=i.useRef(null),K=i.useRef(null),R=i.useRef(null);i.useEffect(()=>{const w=m=>{L.current&&(!L.current.contains(m.target)||K.current&&!K.current.contains(m.target))&&(x(!1),u(null),R.current&&(clearTimeout(R.current),R.current=null))};return y&&document.addEventListener("mousedown",w),()=>{document.removeEventListener("mousedown",w)}},[y]),i.useEffect(()=>{const w=m=>{m.key==="Escape"&&(x(!1),u(null),R.current&&(clearTimeout(R.current),R.current=null))};return y&&document.addEventListener("keydown",w),()=>{document.removeEventListener("keydown",w)}},[y]),i.useEffect(()=>{if(d&&L.current){const w=L.current.querySelector(`[data-option-value="${d}"]`);if(w){const m=w.getBoundingClientRect();N({top:m.top,left:m.right+8})}}},[d]),i.useEffect(()=>()=>{R.current&&clearTimeout(R.current)},[]);const Y=w=>{if(w.stopPropagation(),!l){if(!y){const m=k.current?.getBoundingClientRect();if(m){const P={};a.startsWith("bottom")?P.top=m.bottom+6:P.bottom=window.innerHeight-m.top+6,a.endsWith("start")?P.left=m.left:P.right=window.innerWidth-m.right,p(P)}}x(!y),u(null),R.current&&(clearTimeout(R.current),R.current=null)}},U=(w,m,C)=>{w.stopPropagation(),!m.disabled&&!m.divider&&(!m.children||m.children.length===0)&&(n?.(m.value,C),x(!1),u(null))},$=w=>{R.current&&(clearTimeout(R.current),R.current=null),w.children&&w.children.length>0?u(w.value):u(null)},J=w=>{w.children&&w.children.length>0?R.current=setTimeout(()=>{u(null)},150):u(null)},z=(w,m,C)=>{w.stopPropagation(),!m.disabled&&!m.divider&&(n?.(m.value,C),x(!1),u(null))},W=f("fixed z-overlay min-w-menu bg-surface rounded-lg shadow-overlay border border-border","max-h-60 overflow-auto"),_=f("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:L,className:f("relative flex flex-row items-center justify-center rounded-lg hover:bg-surface-hover",c),children:[e.jsx("button",{ref:k,onClick:Y,disabled:l,className:f("inline-flex items-center justify-center",{"opacity-50 cursor-not-allowed":l}),children:t}),y&&e.jsx("div",{className:W,style:j,children:e.jsxs("div",{className:"p-2",children:[g&&(typeof g=="string"?e.jsx("div",{className:"text-xs font-medium text-text-muted uppercase tracking-label px-3 py-2",children:g}):g),r.map((w,m)=>{if(w.divider)return e.jsx("div",{className:"border-t border-border my-2"},`divider-${m}`);const C=w.children&&w.children.length>0,P=d===w.value;return e.jsxs("div",{className:"relative group",children:[e.jsxs("button",{"data-option-value":w.value,onClick:S=>U(S,w),onMouseEnter:()=>$(w),onMouseLeave:()=>J(w),disabled:w.disabled,className:f("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":w.disabled,"bg-surface-hover":P&&C}),children:[e.jsxs("div",{className:"flex items-center space-x-2 min-w-0",children:[w.icon&&e.jsx("span",{className:"flex-shrink-0",children:w.icon}),e.jsxs("div",{className:"flex flex-col items-start min-w-0",children:[e.jsx("span",{className:"font-base truncate",children:w.label}),w.description&&e.jsx("span",{className:"text-xs text-text-muted",children:w.description})]})]}),e.jsxs("div",{className:"flex items-center space-x-2",children:[b&&s===w.value&&e.jsx(G.Check,{className:"size-icon-md shrink-0 text-success-fg","aria-hidden":!0}),C&&e.jsx("span",{className:"text-text-muted text-xs",children:"▶"})]})]}),C&&P&&e.jsx("div",{ref:K,className:_,style:{top:`${h.top}px`,left:`${h.left}px`},onMouseEnter:()=>{R.current&&(clearTimeout(R.current),R.current=null),u(w.value)},onMouseLeave:()=>{R.current=setTimeout(()=>{u(null)},150)},children:e.jsx("div",{className:"p-2",children:w.children.map((S,q)=>{if(S.divider)return e.jsx("div",{className:"border-t border-border my-2"},`divider-${q}`);const M=typeof s=="object"&&s[w.value]&&s[w.value].includes(S.value)||s===S.value;return e.jsxs("button",{onClick:ee=>z(ee,S,w.value),disabled:S.disabled,className:f("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":S.disabled}),children:[e.jsxs("div",{className:"flex items-center space-x-2 min-w-0",children:[S.icon&&e.jsx("span",{className:"flex-shrink-0",children:S.icon}),e.jsxs("div",{className:"flex flex-col items-start min-w-0",children:[e.jsx("span",{className:"font-base truncate",children:S.label}),S.description&&e.jsx("span",{className:"text-xs text-text-muted",children:S.description})]})]}),b&&M&&e.jsx(G.Check,{className:"size-icon-md shrink-0 text-success-fg","aria-hidden":!0})]},S.value)})})})]},w.value)}),(()=>{const w=r.reduce((m,C)=>{if(C.divider)return m;const P=C.children?C.children.filter(S=>!S.divider).length:0;return m+1+P},0);return w>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:[w," options available"]})})})()]})})]})},dt=()=>e.jsx("svg",{className:"h-4 w-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"m21 21-6-6m2-5a7 7 0 11-14 0 7 7 0 0114 0z"})}),ut=({active:t})=>e.jsx("svg",{className:f("h-3 w-3",t?"text-text":"text-text-muted"),fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"m18 15-6-6-6 6"})}),xt=({active:t})=>e.jsx("svg",{className:f("h-3 w-3",t?"text-text":"text-text-muted"),fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"m6 9 6 6 6-6"})}),mt=()=>e.jsx("svg",{className:"h-4 w-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"m15 18-6-6 6-6"})}),ft=()=>e.jsx("svg",{className:"h-4 w-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"m9 18 6-6-6-6"})}),ht=()=>e.jsx("svg",{className:"h-4 w-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"m11 17-5-5 5-5m6 10-5-5 5-5"})}),bt=()=>e.jsx("svg",{className:"h-4 w-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"m7 17 5-5-5-5m6 10 5-5-5-5"})}),Se=()=>e.jsx("svg",{className:"h-4 w-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"m6 9 6 6 6-6"})}),pt=t=>{const r=n=>t.multiSelect&&Array.isArray(t.value)?t.value?.includes(n):t.value===n,s=n=>{t.multiSelect&&Array.isArray(t.value)?t.onChange(t.value.filter(a=>a!==n)):t.onChange(n)};return t.type==="date"?e.jsx("div",{className:"flex items-center space-x-1 max-w-40",children:e.jsx(de,{size:"sm",value:t.value,onChange:n=>t.onChange(n),placeholder:t.placeholder||`Select ${t.label.toLowerCase()}`,className:"min-w-40 border border-border bg-surface text-text hover:bg-surface-hover"})}):e.jsx("div",{className:"flex items-center space-x-1 max-w-60",children:e.jsx("div",{className:"relative",children:e.jsxs("details",{className:"group",children:[e.jsxs("summary",{className:"flex h-control-md cursor-pointer items-center gap-2 rounded-full border border-border bg-surface px-3 text-sm font-semibold text-text hover:bg-surface-hover",children:[e.jsx("span",{children:t.label}),e.jsx("span",{className:"text-text",children:t.multiSelect&&Array.isArray(t.value)?t.value?.map(n=>t.options?.find(a=>a.value===n)?.label).join(", "):t.options?.find(n=>n.value===t.value)?.label}),e.jsx("span",{className:"text-text-muted text-sm group-open:rotate-180 transition-transform",children:e.jsx(Se,{})})]}),e.jsxs("div",{className:"absolute z-10 left-0 mt-1 bg-surface border border-border rounded-lg shadow-overlay p-2 w-48",children:[t.options?.map(n=>e.jsx("button",{className:"w-full text-left px-3 py-2 rounded-md hover:bg-surface-hover text-sm text-text flex items-center space-x-2",onClick:()=>s(n.value),children:e.jsx("span",{className:f(r(n.value)&&"text-accent"),children:n.label})},n.value)),t.value&&e.jsx("button",{className:"w-full text-left px-3 py-2 rounded-md hover:bg-surface-hover text-sm text-text flex items-center space-x-2 mt-2",onClick:()=>s(null),children:e.jsx("span",{className:"text-text-muted",children:"Clear filter"})})]})]})})})},fe=({data:t,columns:r,loading:s=!1,searchable:n=!1,searchPlaceholder:a="Search...",filters:l=[],paginated:c=!1,pageSizeOptions:b=[10,25,50,100],defaultPageSize:g=10,actions:y=[],onRowClick:x,selectable:d=!1,selectedRows:u=[],onSelectionChange:h,getRowKey:N=(Y,U)=>U,emptyContent:j,hoverable:p=!0,bordered:L=!1,striped:k=!1,className:K,rowClassName:R})=>{const[Y,U]=i.useState(""),[$,J]=i.useState({column:null,direction:null}),[z,W]=i.useState({page:0,pageSize:g}),_=i.useRef(null),w=i.useMemo(()=>{let o=t;if(n&&Y.trim()){const E=r.filter(H=>H.searchable!==!1),F=Y.toLowerCase();o=o.filter(H=>E.some(A=>{const Z=typeof A.accessor=="function"?A.accessor(H):H[A.accessor];return String(Z||"").toLowerCase().includes(F)}))}return l.forEach(E=>{E.value&&E.value!=="all"&&(o=o.filter(F=>{const H=r.find(Z=>Z.id===E.id);if(!H)return!0;const A=typeof H.accessor=="function"?H.accessor(F):F[H.accessor];return String(A||"")===E.value}))}),o},[t,Y,r,n,l]),m=i.useMemo(()=>{if(!$.column||!$.direction)return w;const o=r.find(E=>E.id===$.column);return o?[...w].sort((E,F)=>{const H=typeof o.accessor=="function"?o.accessor(E):E[o.accessor],A=typeof o.accessor=="function"?o.accessor(F):F[o.accessor];let Z=0;return H<A?Z=-1:H>A&&(Z=1),$.direction==="desc"?-Z:Z}):w},[w,$,r]),C=i.useMemo(()=>{if(!c)return m;const o=z.page*z.pageSize,E=o+z.pageSize;return m.slice(o,E)},[m,z,c]),P=i.useCallback(o=>{r.find(F=>F.id===o)?.sortable&&J(F=>F.column!==o?{column:o,direction:"asc"}:F.direction==="asc"?{column:o,direction:"desc"}:{column:null,direction:null})},[r]),S=i.useCallback(o=>{W(E=>({...E,page:o}))},[]),q=i.useCallback(o=>{W({page:0,pageSize:o})},[]),M=i.useCallback((o,E)=>{if(!h)return;const F=N(o,0);u.map((H,A)=>N(H,A)),h(E?[...u,o]:u.filter((H,A)=>N(u[A],A)!==F))},[u,h,N]),ee=i.useCallback(o=>{h&&h(o?[...C]:[])},[C,h]);i.useEffect(()=>{W(o=>({...o,page:0}))},[Y,$]),i.useEffect(()=>{W(o=>({...o,page:0}))},[l.map(o=>o.value).join(",")]);const te=m.length,D=Math.ceil(te/z.pageSize),I=z.page*z.pageSize+1,v=Math.min(I+z.pageSize-1,te),T=C.length>0&&C.every(o=>{const E=N(o,0);return u.some((F,H)=>N(F,H)===E)}),B=C.some(o=>{const E=N(o,0);return u.some((F,H)=>N(F,H)===E)}),O=f("w-full text-sm leading-5 text-text border-collapse",K),X=f("bg-surface"),V=f("text-text p-3 border-b border-border"),re=f("h-row-lg",{"hover:bg-surface-sunk":p,"cursor-pointer":x});return e.jsxs("div",{className:"space-y-4",children:[(n||l.length>0)&&e.jsx("div",{className:"pt-4 pb-2",children:e.jsxs("div",{className:"flex flex-wrap gap-4 items-start",children:[l.map(o=>e.jsx(pt,{...o},o.id)),e.jsx("div",{className:"w-full sm:w-auto sm:ml-auto min-w-menu",children:e.jsx(ae,{placeholder:a,value:Y,onChange:o=>U(o.target.value),startIcon:e.jsx(dt,{}),className:"max-w-sm"})})]})}),e.jsxs("div",{className:"relative w-full overflow-x-auto min-h-100",children:[s&&e.jsx("div",{className:"flex items-center justify-center z-10",children:e.jsx(ke,{showTableSkeleton:!0,tableRows:10,tableColumns:r.length})}),e.jsxs("table",{ref:_,className:f(O,"min-w-full"),children:[e.jsx("thead",{className:X,children:e.jsxs("tr",{children:[d&&e.jsx("th",{className:f(V,"w-12"),children:e.jsx("input",{type:"checkbox",checked:T,ref:o=>{o&&(o.indeterminate=B&&!T)},onChange:o=>ee(o.target.checked),className:"rounded border-border [&:not(:checked)]:bg-surface-input text-accent"})}),!s&&r.map(o=>e.jsx("th",{className:f(V,"font-semibold text-xs text-text-muted uppercase tracking-label","group",{"text-left":o.align==="left"||!o.align,"text-center":o.align==="center","text-right":o.align==="right","cursor-pointer select-none":o.sortable,"sticky left-0 bg-surface":o.sticky==="left","sticky right-0 bg-surface":o.sticky==="right"}),style:{width:o.width},onClick:()=>o.sortable&&P(o.id),children:e.jsxs("div",{className:"flex items-center gap-2",children:[o.headerCell?o.headerCell():o.header,o.sortable&&e.jsxs("div",{className:f("flex flex-col opacity-0 group-hover:opacity-100 transition-opacity",$.column===o.id&&"opacity-100"),children:[e.jsx(ut,{active:$.column===o.id&&$.direction==="asc"}),e.jsx(xt,{active:$.column===o.id&&$.direction==="desc"})]})]})},o.id)),y.length>0&&e.jsx("th",{className:f(V,"w-20"),children:e.jsx("span",{className:"sr-only",children:"Actions"})})]})}),e.jsx("tbody",{children:C.length===0||s?!s&&e.jsx("tr",{children:e.jsx("td",{colSpan:r.length+(d?1:0)+(y.length>0?1:0),className:f(V,"text-center py-8 text-text-muted"),children:j||"No data available"})}):C.map((o,E)=>{const F=N(o,E),H=u.some((A,Z)=>N(A,Z)===F);return e.jsxs("tr",{className:f(re,{"bg-accent-soft":H},R?.(o,E)),onClick:A=>{A.stopPropagation(),x?.(o,E)},children:[d&&e.jsx("td",{className:V,children:e.jsx("input",{type:"checkbox",checked:H,onChange:A=>{A.stopPropagation(),M(o,A.target.checked)},className:"rounded border-border [&:not(:checked)]:bg-surface-input text-accent"})}),r.map(A=>{const Z=typeof A.accessor=="function"?A.accessor(o):o[A.accessor];return e.jsx("td",{className:f(V,{"text-left":A.align==="left"||!A.align,"text-center":A.align==="center","text-right":A.align==="right","sticky left-0 bg-surface":A.sticky==="left","sticky right-0 bg-surface":A.sticky==="right"}),children:A.cell?A.cell(Z,o,E):String(Z||"")},A.id)}),y.length>0&&e.jsx("td",{className:V,children:e.jsx(Ce,{trigger:e.jsxs("div",{className:"inline-flex items-center gap-1 px-2 py-1 text-sm text-text-muted hover:text-text",children:[e.jsx("span",{children:"Options"}),e.jsx(Se,{})]}),options:y.map(A=>({value:A.id,label:A.label,icon:A.icon,disabled:A.disabled?.(o)})),onSelect:A=>{const Z=y.find(xe=>xe.id===A);Z&&Z.onClick(o,E)},placement:"bottom-end"})})]},F)})})]})]}),c&&te>0&&e.jsxs("div",{className:"flex items-center justify-between px-6",children:[e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsxs("span",{className:"text-sm text-text-muted",children:["Showing ",I," to ",v," of ",te," results"]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-sm text-text-muted",children:"Rows per page:"}),e.jsx("select",{value:z.pageSize,onChange:o=>q(Number(o.target.value)),className:"h-control-sm w-16 rounded-md border border-border bg-surface-input px-2 text-sm text-text",children:b.map(o=>e.jsx("option",{value:o,children:o},o))})]})]}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(Q,{size:"sm",variant:"ghost",onClick:()=>S(0),disabled:z.page===0,iconOnly:!0,children:e.jsx(ht,{})}),e.jsx(Q,{size:"sm",variant:"ghost",onClick:()=>S(z.page-1),disabled:z.page===0,iconOnly:!0,children:e.jsx(mt,{})}),e.jsxs("span",{className:"px-3 py-1 text-sm text-text-muted",children:["Page ",z.page+1," of ",D]}),e.jsx(Q,{size:"sm",variant:"ghost",onClick:()=>S(z.page+1),disabled:z.page>=D-1,iconOnly:!0,children:e.jsx(ft,{})}),e.jsx(Q,{size:"sm",variant:"ghost",onClick:()=>S(D-1),disabled:z.page>=D-1,iconOnly:!0,children:e.jsx(bt,{})})]})]})]})},gt=i.createContext(null),vt=({items:t,activeTab:r,onTabChange:s,className:n})=>{const[a,l]=i.useState(t[0]?.id||""),c=r||a,b=g=>{s?s(g):l(g)};return e.jsx("div",{className:f("border-b border-border",n),children:e.jsx("nav",{className:"-mb-px flex space-x-8",children:t.map(g=>e.jsx("button",{onClick:()=>!g.disabled&&b(g.id),disabled:g.disabled,className:f("border-b-2 py-2 px-1 text-sm font-medium transition-colors duration-fast",{"border-accent-border text-text":c===g.id,"border-transparent text-text-muted hover:text-text":c!==g.id&&!g.disabled,"border-transparent text-disabled cursor-not-allowed":g.disabled}),children:e.jsxs("span",{className:"flex items-center gap-2",children:[g.label,g.badge&&e.jsx("span",{className:f("inline-flex items-center px-2 py-0.5 rounded-full text-xs font-medium",c===g.id?"bg-accent-soft text-accent":"bg-surface-hover text-text-muted"),children:g.badge})]})},g.id))})})},Ee=({items:t,defaultTab:r,activeTab:s,onTabChange:n,variant:a="default",size:l="md",className:c})=>{const[b,g]=i.useState(r||s||t[0]?.id||""),y=s||b,x=j=>{n?n(j):g(j)},d={activeTab:y,setActiveTab:x},u=t.find(j=>j.id===y),h=f("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"},c),N=(j,p)=>{const L="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"},K={"border-b-2 -mb-px":a==="default","rounded-md":a==="pills","border-b-2 pb-2":a==="underline"},R={"opacity-50 cursor-not-allowed":j.disabled,"cursor-pointer":!j.disabled},Y=p?{"border-accent-border text-text":a==="default"||a==="underline","bg-surface text-text shadow-none":a==="pills"}:{},U=!p&&!j.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 f(L,k,K,R,Y,U)};return e.jsx(gt.Provider,{value:d,children:e.jsxs("div",{children:[e.jsx("div",{className:h,role:"tablist",children:t.map(j=>e.jsx("button",{type:"button",role:"tab","aria-selected":y===j.id,"aria-controls":`tabpanel-${j.id}`,disabled:j.disabled,onClick:()=>!j.disabled&&x(j.id),className:N(j,y===j.id),children:e.jsxs("span",{className:"flex items-center gap-2",children:[j.label,j.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:j.badge})]})},j.id))}),u?.content&&e.jsx("div",{role:"tabpanel",id:`tabpanel-${y}`,"aria-labelledby":`tab-${y}`,className:"mt-4",children:u.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 Me({open:t,onClose:r,title:s,size:n="md",closeOnBackdropClick:a=!0,closeOnEscape:l=!0,className:c,backdropClassName:b,children:g,footer:y,showCloseButton:x=!0}){const d=i.useRef(null),u=i.useRef(null);i.useEffect(()=>{if(!t||!l)return;const N=j=>{j.key==="Escape"&&r()};return document.addEventListener("keydown",N),()=>document.removeEventListener("keydown",N)},[t,l,r]),i.useEffect(()=>(t?(u.current=document.activeElement,d.current&&d.current.focus(),document.body.style.overflow="hidden"):(u.current&&u.current.focus(),document.body.style.overflow=""),()=>{document.body.style.overflow=""}),[t]);const h=N=>{a&&N.target===N.currentTarget&&r()};return t?e.jsx("div",{className:f("fixed inset-0 z-modal flex items-center justify-center p-4","bg-scrim",b),onClick:h,children:e.jsxs("div",{ref:d,className:f("relative w-full bg-surface rounded-lg shadow-modal","focus:outline-none",jt[n],c),role:"dialog","aria-modal":"true","aria-labelledby":s?"modal-title":void 0,tabIndex:-1,children:[(s||x)&&e.jsxs("div",{className:"flex items-center justify-between p-6 pb-0",children:[s&&e.jsx("span",{id:"modal-title",className:"text-lg font-semibold text-text",children:s}),x&&e.jsx("button",{onClick:r,className:"p-1 text-text-muted hover:text-text transition-colors","aria-label":"Close modal",children:e.jsx("svg",{className:"h-6 w-6",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]}),e.jsx("div",{className:"p-6",children:g}),y&&e.jsx("div",{className:"px-6 py-4",children:y})]})}):null}const yt={xs:"text-xs",sm:"text-sm",md:"text-base",lg:"text-md",xl:"text-lg"},Nt={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"},kt={left:"text-left",center:"text-center",right:"text-right",justify:"text-justify"},Ct={tight:"leading-tight",normal:"leading-normal",relaxed:"leading-relaxed"},se=({variant:t="body",size:r="md",weight:s="normal",color:n="current",align:a="left",truncate:l=!1,italic:c=!1,underline:b=!1,lineHeight:g="normal",as:y,className:x,children:d,...u})=>{const h=y||St(t),N=t==="caption",j=t==="label",p=t==="code",L=f("font-sans",N&&"text-xs text-text-subtle",j&&"text-xs font-semibold uppercase tracking-label text-text-subtle",p&&"font-mono text-sm rounded-sm bg-surface-hover px-1 py-0.5",!N&&!j&&!p&&yt[r],!j&&Nt[s],wt[n],kt[a],t==="body"&&Ct[g],c&&"italic",b&&"underline",l&&"truncate",x);return e.jsx(h,{className:L,...u,children:d})};function St(t){return{body:"p",caption:"span",label:"span",code:"code"}[t]||"p"}const Le=({value:t,onChange:r,label:s,placeholder:n="Select or upload a file",error:a,disabled:l,accept:c,onListFiles:b,onListMounts:g,onUploadFile:y,onDownloadFile:x,onRegisterFile:d})=>{const[u,h]=i.useState(!1),[N,j]=i.useState([]),[p,L]=i.useState(null),[k,K]=i.useState("/"),[R,Y]=i.useState([]),[U,$]=i.useState(!1),[J,z]=i.useState(""),[W,_]=i.useState(typeof t=="object"?t:null),[w,m]=i.useState(!1),[C,P]=i.useState(""),S=i.useRef(null);i.useEffect(()=>{u&&q()},[u]),i.useEffect(()=>{u&&p&&M()},[u,p,k,J]);const q=async()=>{$(!0);try{const o=await g?.();o?.data&&j(o.data)}catch(o){console.error("Failed to load mounts",o)}finally{$(!1)}},M=async()=>{if(p){$(!0);try{const o=await b?.({mountId:p.id,name:J,path:k});o?.data&&Y(o.data)}catch(o){console.error("Failed to load files",o)}finally{$(!1)}}},ee=async o=>{const E=o.target.files?.[0];if(E){$(!0);try{const F=await E.arrayBuffer(),H=new Uint8Array(F),A={id:`local-${Date.now()}`,name:E.name,type:"file",path:"/",mimeType:E.type||"application/octet-stream",size:E.size,mountId:"local",providerKey:E.name,ownerId:"me"};_(A),r(A,H),h(!1)}catch(F){console.error("Local file selection failed",F)}finally{$(!1)}}},te=async o=>{const E=o.target.files?.[0];if(!(!E||!p)){$(!0);try{const F=await E.arrayBuffer(),H=await y?.({file:new Uint8Array(F),filename:E.name,mimeType:E.type||"application/octet-stream",mountId:p.id,path:k});if(H?.data){const A=H.data;_(A),r(A,new Uint8Array(F)),h(!1)}}catch(F){console.error("Upload failed",F)}finally{$(!1)}}},D=async()=>{if(!(!C||!p)){$(!0);try{const o=`${k}${C}/`;d&&(await d({name:C,type:"folder",path:k,mimeType:"application/x-directory",size:0,mountId:p.id,providerKey:o,ownerId:"me"}),await M()),m(!1),P("")}catch(o){console.error("Failed to create folder",o)}finally{$(!1)}}},I=async o=>{$(!0);try{const E=await x?.(o.id);_(o),r(o,E),h(!1)}catch(E){console.error("Failed to download file",E)}finally{$(!1)}},v=o=>{o.stopPropagation(),_(null),r(null)},T=i.useMemo(()=>{const o=new Set,E=[];return R.forEach(F=>{if(F.type==="folder"){F.path===k&&o.add(F.name);return}const H=F.providerKey||F.name,Z=(k?H.substring(k.length):H).split("/").filter(xe=>xe!=="");Z.length>1?o.add(Z[0]):Z.length===1&&E.push(F)}),{folders:Array.from(o).sort(),files:E.sort((F,H)=>F.name.localeCompare(H.name))}},[R,k]),B=o=>{K(E=>`${E}${o}/`)},O=()=>{const o=k.split("/").filter(E=>E!=="");o.pop(),o.length===0?K("/"):K(`${o.join("/")}/`)},X=i.useMemo(()=>{const o=T.folders.map(E=>({id:`folder-${E}`,name:E,type:"folder"}));return T.files.forEach(E=>{o.push({...E,type:"file"})}),o},[T]),V=[{id:"name",header:"Name",accessor:"name",cell:(o,E)=>e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(ne,{icon:E.type==="folder"?G.Folder:G.FileText,size:"sm",color:E.type==="folder"?"warning":"secondary"}),e.jsx("span",{className:f(E.type==="folder"&&"font-medium"),children:o})]})},{id:"type",header:"Type",accessor:o=>o.type==="folder"?"Folder":o.mimeType},{id:"size",header:"Size",accessor:o=>o.type==="file"?`${(o.size/1024).toFixed(1)} KB`:"-"},{id:"actions",header:"",accessor:"id",align:"right",cell:(o,E)=>e.jsx(Q,{size:"sm",variant:"outline",onClick:F=>{F.stopPropagation(),E.type==="folder"?B(E.name):I(E)},loading:U&&E.type==="file"&&W?.id===E.id,children:E.type==="folder"?"Open":"Select"})}],re=[{id:"name",header:"Mount Name",accessor:"name",cell:o=>e.jsxs("div",{className:"flex items-center gap-2 font-medium",children:[e.jsx(ne,{icon:G.HardDrive,size:"sm",color:"primary"}),e.jsx("span",{children:o})]})},{id:"actions",header:"",accessor:"id",align:"right",cell:(o,E)=>e.jsx(Q,{size:"sm",variant:"outline",onClick:()=>L(E),children:"Open"})}];return e.jsxs("div",{className:"space-y-1",children:[s&&e.jsx(se,{variant:"label",size:"sm",weight:"medium",children:s}),e.jsxs("div",{onClick:()=>!l&&h(!0),className:f("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(ne,{icon:W?G.FileText:G.HardDrive,color:W?"primary":"secondary"})}),e.jsx("div",{className:"flex-grow truncate",children:W?e.jsx("span",{className:"text-sm text-text font-medium",children:W.name}):e.jsx("span",{className:"text-sm text-text-muted",children:n})}),W&&!l&&e.jsx("button",{onClick:v,className:"p-1 hover:bg-surface-hover rounded",children:e.jsx(ne,{icon:G.X,size:"xs"})})]}),a&&e.jsx(se,{variant:"body",size:"xs",className:"text-danger-fg",children:a}),e.jsx(Me,{open:u,onClose:()=>{h(!1),L(null),K("/"),m(!1)},title:p?`Explorer: ${p.name}`:"Select Storage Mount",size:"lg",children:e.jsx(Ee,{variant:"pills",items:[{id:"remote",label:"Platform Storage",content:e.jsx("div",{className:"space-y-4",children:p?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx(Q,{variant:"ghost",size:"sm",onClick:()=>{k&&k!=="/"?O():L(null)},leftIcon:e.jsx(ne,{icon:G.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(ae,{placeholder:"Search...",value:J,onChange:o=>z(o.target.value),startIcon:e.jsx(G.Search,{size:14}),fullWidth:!0,size:"sm"})}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(Q,{variant:"outline",size:"sm",onClick:()=>m(!0),leftIcon:e.jsx(ne,{icon:G.FolderPlus,size:"xs"}),children:"New Folder"}),e.jsx(Q,{variant:"primary",size:"sm",onClick:()=>S.current?.click(),leftIcon:e.jsx(ne,{icon:G.Upload,size:"xs"}),loading:U,children:"Upload"}),e.jsx("input",{type:"file",className:"hidden",ref:S,onChange:te,accept:c})]})]}),w&&e.jsxs("div",{className:"flex items-center gap-2 p-3 bg-surface-sunk rounded-lg border border-border",children:[e.jsx(ne,{icon:G.Folder,size:"sm",color:"warning"}),e.jsx(ae,{size:"sm",placeholder:"Folder name",value:C,onChange:o=>P(o.target.value),autoFocus:!0}),e.jsx(Q,{size:"sm",onClick:D,loading:U,children:"Create"}),e.jsx(Q,{size:"sm",variant:"ghost",onClick:()=>m(!1),children:"Cancel"})]}),e.jsx("div",{className:"max-h-100 overflow-auto rounded-lg border border-border",children:e.jsx(fe,{data:X,columns:V,loading:U,emptyContent:"This folder is empty",onRowClick:o=>o.type==="folder"?B(o.name):I(o)})})]}):e.jsx("div",{className:"max-h-100 overflow-auto rounded-lg border border-border",children:e.jsx(fe,{data:N,columns:re,loading:U,emptyContent:"No storage mounts configured",onRowClick:o=>L(o)})})})},{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(ne,{icon:G.FileText,size:"xl",color:"primary"})}),e.jsx(se,{variant:"label",size:"lg",weight:"semibold",children:"Select a file from your computer"}),e.jsxs(se,{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(Q,{variant:"primary",size:"lg",loading:U,className:"pointer-events-none",children:"Browse Local File"}),e.jsx("input",{type:"file",className:"hidden",onChange:ee,accept:c,disabled:U})]})]})})}]})})]})},Et={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"},ue=i.forwardRef(({label:t,helperText:r,error:s,size:n="md",fullWidth:a=!1,loading:l=!1,containerClassName:c,labelClassName:b,className:g,id:y,rows:x=4,...d},u)=>{const h=i.useId(),N=y||`textarea-${h}`,j=!!s,p=s||r?`${N}-description`:void 0;return e.jsxs("div",{className:f("flex flex-col",a&&"w-full",c),children:[t&&e.jsx("label",{htmlFor:N,className:f(ye,j?"text-danger-fg":"text-text-subtle",b),children:t}),e.jsxs("div",{className:"relative",children:[e.jsx("textarea",{ref:u,id:N,rows:x,"aria-invalid":j||void 0,"aria-describedby":p,className:f("block w-full resize-y rounded-md 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",Et[n],j?"border-danger-border bg-danger-soft":"border-border hover:border-border-strong",g),...d}),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"})]}),(s||r)&&e.jsx("p",{id:p,className:f("mt-1 text-xs",j?"text-danger-fg":"text-text-subtle"),children:s||r})]})});ue.displayName="TextArea";function pe(t,r){return r.split(".").reduce((s,n)=>s&&typeof s=="object"&&n in s?s[n]:void 0,t)}function Mt(t,r,s){const n=r.split("."),a=Array.isArray(t)?[...t]:{...t};let l=a;for(let c=0;c<n.length-1;c++){const b=n[c],g=l[b];l[b]=g&&typeof g=="object"?Array.isArray(g)?[...g]:{...g}:{},l=l[b]}return l[n[n.length-1]]=s,a}function Lt(t,r){const s=r.split("."),n=Array.isArray(t)?[...t]:{...t};let a=n;for(let l=0;l<s.length-1;l++){const c=s[l];if(!a[c]||typeof a[c]!="object")return n;a[c]=Array.isArray(a[c])?[...a[c]]:{...a[c]},a=a[c]}return delete a[s[s.length-1]],n}const zt=({groups:t,data:r,onSubmit:s,onCancel:n,onChange:a,transform:l,validate:c,submitButton:b={label:"Submit",variant:"primary"},cancelButton:g={label:"Cancel",variant:"outline"},showButtons:y=!0,layout:x="vertical",size:d="md",loading:u=!1,className:h,ref:N,sdk:j})=>{const[p,L]=i.useState(r||{}),[k,K]=i.useState({}),[R,Y]=i.useState({});i.useEffect(()=>{r&&L({...r})},[r]);const U=i.useCallback((m,C,P)=>{const S=t.flatMap(q=>q.items).find(q=>q.name===m);if(!S)return null;if(S.required&&(C==null||C===""))return`${S.label} is required`;if(S.type==="array"){if(S.required&&(!C||C.length===0))return`${S.label} cannot be empty.`;if(C&&!Array.isArray(C))return`${S.label} must be an array.`;if(Array.isArray(C)&&S.arrayFields){const q=[];let M=!1;if(C.forEach((ee,te)=>{const D={};for(const I of S.arrayFields){const v=ee?.[I.name];if(I.required&&(v==null||v===""))D[I.name]=`${I.label} is required`,M=!0;else if(I.validator){const T=I.validator(v,ee);T&&(D[I.name]=T,M=!0)}}q[te]=D}),M)return JSON.stringify(q)}}return S.validator?S.validator(C,P):null},[t]),$=i.useCallback((m,C)=>{let P=Mt(p,m,C);t.flatMap(M=>M.items).find(M=>M.name===m)?.removeIfEmpty&&(C==null||C==="")&&(P=Lt(P,m)),L(P),Y(M=>({...M,[m]:!0}));const q=U(m,C,P);K(M=>({...M,[m]:q||""})),a?.(P,m)},[p,t,U,a]),J=i.useCallback(async m=>{if(m.preventDefault(),u)return;const C={},P=t.flatMap(q=>q.items);for(const q of P){if(q.hidden||q.conditional&&!q.conditional(p))continue;const M=U(q.name,pe(p,q.name),p);M&&(C[q.name]=M)}if(c){const q=c(p);q&&Object.assign(C,q)}if(K(C),Object.keys(C).some(q=>C[q]))return;const S=l?l(p):p;await s?.(p,S)},[p,t,U,c,l,s,u]),z=i.useCallback(m=>{const C=pe(p,m.name),P=R[m.name]?k[m.name]:void 0,S=m.disabled||u,q={value:C||"",disabled:S,required:m.required,placeholder:m.placeholder,...m.fieldProps};switch(m.type){case"text":case"email":case"password":case"number":case"tel":case"url":return e.jsx(ae,{...q,onChange:M=>$(m.name,M.target.value),type:m.textType||m.type,autoComplete:m.autocomplete,error:P,size:d});case"textarea":return e.jsx(ue,{...q,onChange:M=>$(m.name,M.target.value),rows:4,error:P,size:d});case"select":return e.jsx(ce,{...q,onChange:M=>$(m.name,M),options:(m.options||[]).map(M=>({...M,value:String(M.value)})),searchable:m.searchable,multiple:m.multiple,allowCreate:m.allowCreate,error:P,size:d});case"checkbox":return e.jsx(oe,{...q,checked:!!C,onChange:M=>$(m.name,M.target.checked),size:d});case"radio":return e.jsx("div",{className:"flex flex-col gap-2",children:m.options?.map(M=>e.jsxs("label",{className:"flex cursor-pointer items-center gap-2 text-base text-text",children:[e.jsx("input",{type:"radio",name:m.name,value:M.value,checked:C===M.value,onChange:()=>$(m.name,M.value),disabled:S||M.disabled,className:"size-checkbox shrink-0 border border-border-strong bg-surface-input accent-accent focus-visible:outline-none focus-visible:focus-ring"}),M.label]},M.value))});case"date":return e.jsx(de,{...q,value:C?new Date(C):null,onChange:M=>$(m.name,M),size:d});case"file":return e.jsx(Le,{...q,value:C,onChange:M=>$(m.name,M),error:P,onListFiles:M=>j?.http.invoke({method:"POST",action:"storage.file.list",body:M}),onListMounts:()=>j?.http.invoke({method:"GET",action:"storage.mount"}),onUploadFile:M=>j?.http.invoke({method:"POST",action:"storage.file.upload",body:M}),onDownloadFile:M=>j?.http.invoke({method:"GET",action:`storage.file.${M}.download`}),onRegisterFile:M=>j?.http.invoke({method:"POST",action:"storage.file.folder",body:M})});case"folder":return e.jsx(Ne,{value:C||{},onChange:M=>$(m.name,M),onListFolders:()=>j?.http.invoke({method:"GET",action:"storage.mount"}),disabled:S,size:d,placeholder:m.placeholder});case"custom":return m.customComponent?.({value:C,onChange:M=>$(m.name,M),error:P,disabled:S});case"array":{const M=C||[];let ee=[];if(typeof P=="string"&&P.startsWith("["))try{ee=JSON.parse(P)}catch{}const te=()=>{$(m.name,[...M,{}])},D=v=>{$(m.name,M.filter((T,B)=>B!==v))},I=(v,T,B)=>{const O=[...M];O[v]={...O[v],[T]:B},$(m.name,O)};return e.jsxs("div",{className:"flex flex-col gap-2",children:[M.map((v,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:m.arrayFields?.map(B=>{const O=ee?.[T]?.[B.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:[B.label,B.required&&e.jsx("span",{className:"ml-1 text-danger-fg",children:"*"})]}),(()=>{const X={value:v?.[B.name]||"",disabled:S,required:B.required,placeholder:B.placeholder,...B.fieldProps};switch(B.type){case"text":case"email":case"password":case"number":case"tel":case"url":return e.jsx(ae,{...X,onChange:V=>I(T,B.name,V.target.value),type:B.textType||B.type,autoComplete:B.autocomplete,error:O,size:d});case"textarea":return e.jsx(ue,{...X,onChange:V=>I(T,B.name,V.target.value),rows:4,error:O,size:d});case"select":return e.jsx(ce,{...X,onChange:V=>I(T,B.name,V),options:(B.options||[]).map(V=>({...V,value:String(V.value)})),searchable:B.searchable,multiple:B.multiple,allowCreate:B.allowCreate,error:O,size:d});case"checkbox":return e.jsx(oe,{...X,checked:!!v?.[B.name],onChange:V=>I(T,B.name,V.target.checked),size:d});case"radio":return e.jsx("div",{className:"flex flex-col gap-2",children:B.options?.map(V=>e.jsxs("label",{className:"flex cursor-pointer items-center gap-2 text-base text-text",children:[e.jsx("input",{type:"radio",name:`${m.name}.${T}.${B.name}`,value:V.value,checked:v?.[B.name]===V.value,onChange:()=>I(T,B.name,V.value),disabled:S||V.disabled,className:"size-checkbox shrink-0 border border-border-strong bg-surface-input accent-accent focus-visible:outline-none focus-visible:focus-ring"}),V.label]},V.value))});case"date":{const V=v?.[B.name];return e.jsx(de,{...X,value:V?new Date(V):null,onChange:re=>I(T,B.name,re),size:d})}case"custom":return B.customComponent?.({value:v?.[B.name],onChange:V=>I(T,B.name,V),error:O,disabled:S});default:return e.jsxs("p",{children:["Unsupported field type in array:"," ",B.type]})}})(),O&&e.jsx("p",{className:"text-xs text-danger-fg",children:O})]},B.name)})}),e.jsx(Q,{type:"button",iconOnly:!0,variant:"ghost",size:"md","aria-label":`${m.label} verwijderen`,onClick:()=>D(T),disabled:S,className:f("shrink-0",T===0&&"mt-5"),children:e.jsx(G.Trash2,{className:"size-icon-md"})})]},T)),e.jsxs(Q,{type:"button",variant:"secondary",size:"sm",leftIcon:e.jsx(G.Plus,{className:"size-icon-sm"}),onClick:te,disabled:S,children:[m.label," toevoegen"]})]})}default:return null}},[p,R,k,u,d,$]),W=i.useCallback(m=>{if(m.conditional&&!m.conditional(p))return null;const C=m.items.filter(S=>!(S.hidden||S.conditional&&!S.conditional(p)));if(C.length===0)return null;const P=f(m.layout==="flex"?"flex flex-wrap gap-3":"grid gap-3",m.layout!=="flex"&&{"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:"flex flex-col gap-4 px-5 py-4 not-first:border-t not-first:border-border-subtle sm:flex-row sm:gap-5",children:[e.jsxs("div",{className:"w-full shrink-0 sm:w-form-label",children:[e.jsx("span",{className:"text-sm font-semibold text-text",children:m.title}),m.description&&e.jsx("p",{className:"mt-1 text-xs leading-4 text-text-subtle",children:m.description})]}),e.jsx("div",{className:"min-w-0 flex-1",children:e.jsx("div",{className:P,children:C.map(S=>(R[S.name]&&k[S.name],e.jsxs("div",{className:f("flex min-w-0 flex-col gap-1.5",S.type==="checkbox"&&"justify-center"),style:{width:typeof S.width=="string"?S.width:void 0,gridColumn:typeof S.width=="number"?`span ${S.width} / span ${S.width}`:void 0},children:[S.type!=="custom"&&S.type!=="checkbox"&&e.jsxs("label",{className:"block text-xs font-semibold uppercase tracking-label text-text-subtle",children:[S.label,S.required&&e.jsx("span",{className:"ml-1 text-danger-fg",children:"*"})]}),z(S)]},S.name)))})})]},m.id)},[p,R,k,z]),_=f("overflow-hidden rounded-lg border border-border bg-surface",{"max-w-md":d==="sm","max-w-2xl":d==="md","max-w-4xl":d==="lg","max-w-full":d==="full"},h),w=d==="full"?"md":d;return e.jsxs("form",{ref:N,onSubmit:J,className:_,children:[e.jsx("div",{className:"flex flex-col",children:t.map(W)}),e.jsx("div",{className:"flex items-center gap-2 border-t border-border-subtle bg-surface-sunk px-5 py-3",children:y&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"ml-auto"}),n&&e.jsx(Q,{type:"button",variant:g.variant??"ghost",size:g.size||w,disabled:g.disabled||u,onClick:n,className:g.className,children:g.label}),e.jsx(Q,{type:"submit",variant:b.variant,size:b.size||w,disabled:b.disabled||u,loading:u,className:b.className,children:b.label})]})})]})},Tt={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"},$t={sm:"px-2 py-0.5 text-xs",md:"px-2.5 py-1 text-sm",lg:"px-3 py-1.5 text-base"},Dt={default:"bg-surface-hover",primary:"bg-accent",secondary:"bg-surface-hover",success:"bg-success",warning:"bg-warning",error:"bg-danger",info:"bg-info"};function It({variant:t="default",size:r="md",dot:s=!1,icon:n,dismissible:a=!1,onDismiss:l,className:c,children:b,...g}){return e.jsxs("span",{className:f("inline-flex items-center font-medium rounded-full",Tt[t],$t[r],c),...g,children:[s&&e.jsx("span",{className:f("w-2 h-2 rounded-full mr-1.5",Dt[t])}),n&&e.jsx("span",{className:f("flex-shrink-0",b&&"mr-1"),children:n}),b,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("svg",{className:"h-3 w-3",fill:"currentColor",viewBox:"0 0 20 20",children:e.jsx("path",{fillRule:"evenodd",d:"M4.293 4.293a1 1 0 011.414 0L10 8.586l4.293-4.293a1 1 0 111.414 1.414L11.414 10l4.293 4.293a1 1 0 01-1.414 1.414L10 11.414l-4.293 4.293a1 1 0 01-1.414-1.414L8.586 10 4.293 5.707a1 1 0 010-1.414z",clipRule:"evenodd"})})})]})}const Pt={neutral:"bg-surface-hover text-text-muted",success:"bg-success-soft text-success-fg"};function At({icon:t,tone:r="neutral",title:s,description:n,actions:a,card:l=!1,className:c,...b}){return e.jsxs("div",{className:f("flex flex-col items-center gap-2.5 text-center",l&&"rounded-lg border border-border bg-surface px-11 py-9 shadow-overlay",c),...b,children:[t!=null&&e.jsx("span",{className:f("flex size-disc items-center justify-center rounded-full text-2xl",Pt[r]),children:t}),e.jsx("div",{className:"text-lg font-semibold text-text",children:s}),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 Bt({children:t,className:r,...s}){return e.jsx("kbd",{className:f("inline-flex items-center rounded border border-border px-1.5 py-px text-xs font-medium leading-none text-text-muted",r),...s,children:t})}const Rt={sm:"h-1",md:"h-1.5"},Ft={accent:"bg-accent",success:"bg-success"};function Ot({value:t,variant:r="accent",size:s="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:f("w-full overflow-hidden rounded-full bg-surface-hover",Rt[s],n),...a,children:e.jsx("div",{className:f("h-full rounded-full transition-[width] duration-300 ease-out",Ft[r]),style:{width:`${l}%`}})})}const Vt={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"},Wt={primary:"text-accent",secondary:"text-text-muted",white:"text-white",current:"text-current"},qt={xs:"text-xs",sm:"text-sm",md:"text-sm",lg:"text-base",xl:"text-lg"};function Ht({size:t="md",variant:r="primary",label:s="Loading...",showLabel:n=!1,className:a,...l}){return e.jsxs("div",{className:f("inline-flex items-center",n?"flex-col space-y-2":"",a),...l,children:[e.jsxs("svg",{className:f("animate-spin",Vt[t],Wt[r]),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:f("text-text-muted",qt[t]),children:s}),!n&&e.jsx("span",{className:"sr-only",children:s})]})}function Ut({title:t,icon:r=e.jsx(G.Sparkles,{className:"size-icon-md","aria-hidden":!0}),action:s,children:n,className:a,...l}){return e.jsxs("div",{className:f("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:r}),e.jsx("span",{className:"text-sm font-semibold",children:t}),s&&e.jsx("span",{className:"ml-auto",children:s})]}),n&&e.jsx("div",{className:"text-sm leading-relaxed text-text",children:n})]})}const _t={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 Gt(t){if(!t)return"?";const r=t.trim().split(/[^\p{L}\p{N}]+/u).filter(Boolean);return r.length>=2?(r[0][0]+r[1][0]).toUpperCase():r.length===1?r[0].slice(0,2).toUpperCase():"?"}const ze=({name:t,src:r,size:s="sm",className:n,title:a})=>{const[l,c]=i.useState(!1),b=f("inline-flex items-center justify-center rounded-full overflow-hidden shrink-0 font-semibold select-none bg-surface-hover-border-emphasis text-text",_t[s],n);return r&&!l?e.jsx("img",{src:r,alt:t??"",title:a??t,className:f(b,"object-cover"),onError:()=>c(!0)}):e.jsx("span",{className:b,title:a??t,"aria-label":t,children:Gt(t)})},ge="ring-surface",Kt="ring-surface-accent",Jt=({people:t,max:r=4,size:s="sm",className:n})=>{if(t.length===0)return null;const a=t.slice(0,r),l=t.length-a.length;return e.jsxs("span",{className:f("inline-flex items-center",n),children:[a.map((c,b)=>e.jsx(ze,{name:c.name,src:c.src,size:s,title:c.name?c.seen===!1?`${c.name} — nog niet gelezen`:c.name:void 0,className:f(b>0&&"-ml-2",c.owner?Kt:ge,c.seen===!1&&"opacity-40")},c.id??`${c.name}-${b}`)),l>0&&e.jsxs("span",{className:f("inline-flex items-center justify-center rounded-full shrink-0 -ml-2 font-semibold bg-surface-hover text-text-muted",s==="xs"?"w-5 h-5 text-xs":s==="md"?"w-7 h-7 text-xs":s==="lg"?"w-9 h-9 text-xs":"w-6 h-6 text-xs",ge),children:["+",l]})]})},ve={mail:{fg:"text-ch-mail",bg:"bg-ch-mail"},wa:{fg:"text-ch-wa",bg:"bg-ch-wa"},chat:{fg:"text-ch-chat",bg:"bg-ch-chat"},tel:{fg:"text-ch-tel",bg:"bg-ch-tel"},note:{fg:"text-ch-note",bg:"bg-ch-note"}},Yt={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 Xt({channel:t,children:r,size:s="md",className:n,title:a}){const l=ve[t in ve?t:"note"];return e.jsx("span",{title:a,className:f("inline-flex shrink-0 items-center justify-center font-bold",Yt[s],l.fg,l.bg,n),children:r})}const Zt=({src:t,alt:r,size:s="md",aspectRatio:n="auto",radius:a="md",showLoading:l=!0,showError:c=!0,fallback:b,loadingContent:g,errorContent:y,className:x,onLoad:d,onError:u,...h})=>{const[N,j]=i.useState(!0),[p,L]=i.useState(!1),[k,K]=i.useState(t),R=_=>{j(!1),L(!1),d?.(_)},Y=_=>{if(j(!1),L(!0),b&&k!==b){K(b),L(!1),j(!0);return}u?.(_)},U=f("relative overflow-hidden bg-surface-hover",{"w-8 h-8":s==="xs","w-12 h-12":s==="sm","w-16 h-16":s==="md","w-24 h-24":s==="lg","w-32 h-32":s==="xl","w-full h-full":s==="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"},x),$=f("w-full h-full object-cover transition-opacity duration-fast",{"opacity-0":N||p,"opacity-100":!N&&!p}),J=f("absolute inset-0 flex items-center justify-center","text-text-muted"),z=e.jsx("div",{className:"animate-pulse",children:e.jsx("div",{className:"w-6 h-6 bg-surface-hover rounded"})}),W=e.jsxs("div",{className:"text-center",children:[e.jsx("svg",{className:"w-6 h-6 mx-auto mb-1",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M4 16l4.586-4.586a2 2 0 012.828 0L16 16m-2-2l1.586-1.586a2 2 0 012.828 0L20 14m-6-6h.01M6 20h12a2 2 0 002-2V6a2 2 0 00-2-2H6a2 2 0 00-2 2v12a2 2 0 002 2z"})}),e.jsx("span",{className:"text-xs",children:"Failed to load"})]});return e.jsxs("div",{className:U,children:[e.jsx("img",{...h,src:k,alt:r,className:$,onLoad:R,onError:Y}),N&&l&&e.jsx("div",{className:J,children:g||z}),p&&c&&e.jsx("div",{className:J,children:y||W})]})};function Qt({items:t,getRowKey:r,variant:s="divided",leading:n,renderItem:a,trailing:l,onSelect:c,isActive:b,unread:g,dimmed:y,groupBy:x,groups:d,renderGroupHeader:u,stickyGroupHeaders:h=!1,collapsibleGroups:N=!1,hideGroupCount:j=!1,selectable:p=!1,selectedItems:L=[],onSelectionChange:k,bulkActions:K,header:R,stickyHeader:Y=!1,bordered:U=!1,emptyContent:$,loading:J=!1,loadingRows:z=4,className:W,"aria-label":_}){const[w,m]=i.useState(()=>Object.fromEntries((d??[]).filter(v=>v.defaultCollapsed).map(v=>[v.id,!0]))),C=(v,T)=>r?r(v,T):T,P=v=>L.includes(v),S=(v,T)=>{k&&k(T?[...L,v]:L.filter(B=>B!==v))},q=v=>k?.(v?[...t]:[]),M=f("flex flex-col",U&&"overflow-hidden rounded-lg border border-border-subtle",W);if(J)return e.jsx("div",{className:M,children:Array.from({length:z}).map((v,T)=>e.jsxs("div",{className:f("flex animate-pulse items-center gap-3 px-4 py-2.5",s==="divided"&&T>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-${T}`))});if(t.length===0&&$)return e.jsx("div",{className:M,children:$});const ee=t.length>0&&L.length===t.length,te=L.length>0&&!ee,D=(v,T,B)=>{const O=b?.(v,T)??!1,X=g?.(v,T)??!1,V=y?.(v,T)??!1,re=p&&P(v);return e.jsxs("li",{onClick:c?()=>c(v,T):void 0,className:f("flex items-center gap-3 px-4 py-2.5 text-base","transition-colors duration-fast ease-out",s==="divided"&&!B&&"border-t border-border-subtle",c&&"cursor-pointer",O||re?"bg-accent-soft text-text":c&&"hover:bg-surface-hover",X&&"font-bold",V&&"opacity-55"),children:[p&&e.jsx("span",{onClick:o=>o.stopPropagation(),children:e.jsx(oe,{checked:P(v),onChange:o=>S(v,o.target.checked),"aria-label":"Rij selecteren"})}),s==="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(v,T)}),X&&e.jsx("span",{"aria-hidden":!0,className:"size-1.5 shrink-0 rounded-full bg-accent",title:"Ongelezen"}),e.jsx("div",{className:"flex min-w-0 flex-1 items-center gap-2",children:a?a(v,T):String(v)}),l&&e.jsx("span",{className:"shrink-0 text-xs text-text-subtle",children:l(v,T)})]},C(v,T))},I=(()=>{if(!x)return t.map((O,X)=>D(O,X,X===0));const v=new Map;t.forEach((O,X)=>{const V=x(O,X);v.has(V)||v.set(V,[]),v.get(V).push({item:O,index:X})});const T=d??[];return[...T.filter(O=>v.has(O.id)),...[...v.keys()].filter(O=>!T.some(X=>X.id===O)).map(O=>({id:O}))].flatMap((O,X)=>{const V=v.get(O.id)??[],re=N&&w[O.id],o=O.title??O.id,E=O.count??V.length,F=e.jsx("li",{onClick:N?()=>m(H=>({...H,[O.id]:!H[O.id]})):void 0,className:f("flex items-center gap-2 bg-surface-sunk px-4 py-1.5","text-xs font-semibold uppercase tracking-label text-text-subtle","border-border-subtle",X>0&&"border-t","border-b",h&&"sticky z-10",N&&"cursor-pointer select-none hover:text-text"),"aria-expanded":N?!re:void 0,style:h?{top:Y?28:0}:void 0,children:u?u(O,V.map(H=>H.item)):e.jsxs(e.Fragment,{children:[N&&e.jsx(G.ChevronRight,{"aria-hidden":!0,className:f("size-icon-sm shrink-0 transition-transform duration-fast ease-out",!re&&"rotate-90")}),e.jsx("span",{children:o}),!j&&e.jsx("span",{className:"ml-auto font-normal tabular-nums",children:E})]})},`group-${O.id}`);return re?[F]:[F,...V.map(({item:H,index:A},Z)=>D(H,A,Z===0))]})})();return e.jsxs("div",{className:M,children:[p&&L.length>0&&e.jsxs("div",{className:"flex items-center gap-3 border-b border-border-subtle bg-surface-sunk px-4 py-2",children:[e.jsx(oe,{checked:ee,indeterminate:te,onChange:v=>q(v.target.checked),"aria-label":"Alles selecteren"}),e.jsxs("span",{className:"text-xs text-text-subtle",children:[L.length," geselecteerd"]}),K&&e.jsx("div",{className:"ml-auto flex gap-2",children:K})]}),R&&e.jsx("div",{className:f("flex items-center gap-3 border-b border-border-subtle bg-surface-sunk px-4 py-1.5","text-xs font-semibold uppercase tracking-label text-text-subtle",Y&&"sticky top-0 z-20"),children:R}),e.jsx("ul",{"aria-label":_,className:"flex flex-col",children:I})]})}const es={default:"text-text",urgent:"text-danger-fg",success:"text-success-fg"},ts={default:"border-border",urgent:"border-danger-border",success:"border-border"};function ss({value:t,label:r,tone:s="default",className:n,...a}){return e.jsxs("div",{className:f("rounded-xl border bg-surface px-4 py-3.5",ts[s],n),...a,children:[e.jsx("div",{className:f("text-2xl font-semibold",es[s]),children:t}),e.jsx("div",{className:"pt-0.5 text-xs text-text-muted",children:r})]})}const rs=({title:t,subtitle:r,actions:s=[],children:n,className:a,backLabel:l="Back",backClassName:c,onBack:b,editable:g=!1,onTitleChange:y})=>{const[x,d]=i.useState(!1),[u,h]=i.useState(t),N=i.useRef(null);i.useEffect(()=>{h(t)},[t]),i.useEffect(()=>{x&&N.current&&(N.current.focus(),N.current.select())},[x]);const j=()=>{g&&d(!0)},p=()=>{d(!1),u.trim()!==""&&u!==t&&y?y(u.trim()):h(t)},L=k=>{k.key==="Enter"?N.current?.blur():k.key==="Escape"&&(h(t),d(!1))};return e.jsxs("div",{className:f("p-5 pb-3 border-b border-border",a),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-center gap-2 text-text",children:[b&&e.jsx("button",{type:"button",onClick:b,className:f("flex items-center text-sm cursor-pointer transition",c),children:e.jsx(G.ArrowLeft,{size:16,color:"currentColor"})}),x?e.jsx("input",{ref:N,type:"text",value:u,onChange:k=>h(k.target.value),onBlur:p,onKeyDown:L,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 flex-1"}):e.jsxs("div",{className:"group flex items-baseline gap-2.5 min-w-0",children:[e.jsx("h2",{onClick:j,className:f("text-2xl font-semibold truncate",g&&"cursor-pointer"),title:g?"Klik om te bewerken":void 0,children:t}),r&&e.jsx("span",{className:"shrink-0 text-base text-text-muted truncate",children:r}),g&&e.jsx(G.Pencil,{size:15,onClick:j,className:"shrink-0 cursor-pointer text-text-muted opacity-0 group-hover:opacity-100 transition-opacity"})]})]})}),s.length>0&&e.jsx("div",{className:"flex flex-wrap sm:flex-nowrap gap-2 sm:gap-3",children:s.map(k=>k.splitOptions&&k.splitOptions.length>0?e.jsx(he,{label:k.label,onClick:k.onClick,icon:k.icon,variant:k.variant==="primary"?"primary":"secondary",options:k.splitOptions,disabled:k.disabled},k.id):e.jsx(Q,{variant:k.variant??"secondary",onClick:K=>{K.stopPropagation(),K.target.blur(),k.onClick()},disabled:k.disabled,leftIcon:k.icon,children:k.label},k.id))})]}),n&&e.jsx("div",{className:"mt-4",children:n})]})},ns=({actions:t=[],onBack:r,backLabel:s="Back",className:n,children:a})=>e.jsxs("div",{className:f("flex items-center gap-2 mb-3",n),children:[r&&e.jsx(Q,{variant:"ghost",size:"sm",onClick:r,leftIcon:e.jsx(G.ArrowLeft,{size:14}),children:s}),a&&e.jsx("div",{className:"flex-1 min-w-0",children:a}),t.length>0&&e.jsx("div",{className:f("flex flex-wrap gap-2",!a&&"ml-auto"),children:t.map(l=>l.splitOptions&&l.splitOptions.length>0?e.jsx(he,{label:l.label,onClick:l.onClick,icon:l.icon,variant:l.variant==="primary"?"primary":"secondary",options:l.splitOptions,disabled:l.disabled},l.id):e.jsx(Q,{variant:l.variant??"secondary",size:"sm",onClick:c=>{c.stopPropagation(),c.target.blur(),l.onClick()},disabled:l.disabled,leftIcon:l.icon,children:l.label},l.id))})]});function as({label:t,dotColor:r,onClick:s,className:n}){return e.jsxs("button",{type:"button",onClick:s,className:f("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:[r&&e.jsx("span",{className:"h-1.5 w-1.5 shrink-0 rounded-full",style:{backgroundColor:r},"aria-hidden":!0}),e.jsx("span",{className:"min-w-0 truncate",children:t}),e.jsx("span",{"aria-hidden":!0,className:"shrink-0 opacity-70",children:"↗"})]})}function ls(t,r){return r.split(".").reduce((s,n)=>s&&typeof s=="object"&&n in s?s[n]:void 0,t)}const os=({groups:t,data:r,size:s="md",className:n})=>{const a=x=>{if(!x)return"-";try{return new Date(x).toLocaleDateString("nl-NL",{year:"numeric",month:"long",day:"numeric"})}catch{return String(x)}},l=x=>x?"Ja":"Nee",c=(x,d)=>{if(!d)return String(x||"-");const u=d.find(h=>h.value===x);return u?u.label:String(x||"-")},b=i.useCallback(x=>{const d=ls(r,x.name);if(x.type==="array"){const h=d;return!h||h.length===0?e.jsx(se,{variant:"body",size:"sm",className:"text-text-muted",children:"Geen items"}):e.jsx("div",{className:"space-y-3",children:h.map((N,j)=>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(se,{variant:"label",size:"sm",weight:"medium",className:"text-text-muted",children:[x.label," ",j+1]})}),e.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-3",children:x.arrayFields?.map(p=>{const L=N?.[p.name];let k="-";switch(p.type){case"text":case"email":case"number":case"tel":case"url":case"textarea":k=L||"-";break;case"select":case"radio":k=c(L,p.options);break;case"checkbox":k=l(L);break;case"date":k=a(L);break;case"custom":k=p.customComponent?.({value:L});break;default:k=String(L||"-")}return p.format&&(k=p.format(L,N)),e.jsxs("div",{className:"space-y-1",children:[e.jsx(se,{variant:"label",size:"xs",className:"text-text-muted",children:p.label}),e.jsx(se,{variant:"body",size:"sm",className:"text-text",children:k})]},p.name)})})]},j))})}if(x.type==="custom"&&x.customComponent)return x.customComponent({value:d});if(x.format){const h=x.format(d,r);return e.jsx(se,{variant:"body",size:"sm",className:"text-text",children:h})}let u="-";switch(x.type){case"text":case"email":case"password":case"number":case"tel":case"url":u=d?String(d):"-";break;case"textarea":u=d?e.jsx("div",{className:"whitespace-pre-wrap",children:String(d||"-")}):"-";break;case"select":case"radio":u=c(d,x.options);break;case"checkbox":u=l(d);break;case"date":u=a(d);break;default:u=d?String(d):"-"}return e.jsx(se,{variant:"body",size:"sm",className:"text-text",children:u})},[r]),g=i.useCallback(x=>{if(x.conditional&&!x.conditional(r))return null;const d=x.items.filter(h=>!(h.hidden||h.conditional&&!h.conditional(r)));if(d.length===0)return null;const u=f("space-y-4",{"grid gap-4":x.layout==="grid","flex flex-wrap gap-4":x.layout==="flex"},x.layout==="grid"&&{"grid-cols-1":!x.columns||x.columns===1,"grid-cols-2":x.columns===2,"grid-cols-3":x.columns===3,"grid-cols-4":x.columns===4},x.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(se,{variant:"label",size:"lg",weight:"semibold",className:"text-text",children:x.title}),x.description&&e.jsx(se,{variant:"body",size:"sm",className:"text-text-muted mt-1",children:x.description})]}),e.jsx("div",{className:"md:col-span-2",children:e.jsx("div",{className:u,children:d.map(h=>e.jsxs("div",{className:f("space-y-1",h.width&&typeof h.width=="string"&&`w-[${h.width}]`,h.width&&typeof h.width=="number"&&`col-span-${h.width}`),children:[h.type!=="custom"&&e.jsx(se,{variant:"label",size:"sm",className:"font-medium text-text-muted",children:h.label}),b(h)]},h.name))})})]},x.id)},[r,b]),y=f("space-y-6",{"max-w-md":s==="sm","max-w-2xl":s==="md","max-w-4xl":s==="lg","max-w-full":s==="full"},n);return e.jsx("div",{className:y,children:e.jsx("div",{className:"space-y-8",children:t.map(g)})})},Te=({item:t,isSelectedHandler:r,onClick:s,depth:n=0})=>{const[a,l]=i.useState(t.defaultCollapsed??!1),c=t.children&&t.children.length>0,b=c&&n===0,g=()=>{c&&l(!a)},y=r?r(t.path):!1;return e.jsxs("li",{children:[e.jsxs("div",{className:f("flex flex-row w-full py-1 rounded-lg items-center h-8 transition-colors cursor-pointer px-2.5 pr-1 no-underline text-sm",{"bg-accent-soft text-accent":y&&!c,"hover:bg-surface-hover":!(y&&!c),"font-semibold":y||b}),onClick:()=>{c?g():t.path&&s?.(t.path)},children:[t.icon&&e.jsx("span",{className:"mr-2 shrink-0",children:t.icon}),e.jsx("span",{className:"flex-1 min-w-0 truncate",children:t.label}),t.count!==void 0&&t.count>0&&e.jsx("span",{className:"ml-2 mr-1.5",children:t.count}),c&&e.jsx("span",{className:`${a?"collapsed":""}`,children:e.jsx(G.ChevronDownIcon,{className:"w-4 h-4 text-text-muted"})})]}),c&&!a&&e.jsx("ul",{className:"sidebar-menu-nested-items mb-1",children:t.children?.map((x,d)=>e.jsx(Te,{item:x,isSelectedHandler:r,onClick:s,depth:n+1},d))})]})},cs=({title:t,actionIcons:r,items:s,isSelectedHandler:n,onClick:a,preMenuItemsComponent:l})=>e.jsxs("div",{className:"flex flex-col h-screen mb-6",children:[e.jsxs("div",{className:"sidebar-menu-header",children:[e.jsx("span",{className:"text-lg font-semibold text-text mb-2",children:t}),e.jsx("div",{className:"sidebar-menu-actions",children:r?.map((c,b)=>e.jsx("span",{className:"sidebar-menu-action-icon",children:c},b))})]}),l&&e.jsx("div",{className:"sidebar-menu-pre-items mb-4",children:l}),e.jsx("ul",{children:s.map((c,b)=>!c.path&&!c.label&&!c.children?e.jsx("span",{className:"flex w-full h-4"},b):e.jsx(Te,{item:c,isSelectedHandler:n,onClick:a},b))})]}),is={xs:"text-xs",sm:"text-sm",md:"text-base",lg:"text-lg",xl:"text-xl","2xl":"text-2xl","3xl":"text-3xl","4xl":"text-3xl"},ds={light:"font-normal",normal:"font-normal",medium:"font-medium",semibold:"font-semibold",bold:"font-bold"},us={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"},xs={left:"text-left",center:"text-center",right:"text-right"},ms=({level:t=1,size:r,weight:s="semibold",color:n="current",align:a="left",truncate:l=!1,className:c,children:b,...g})=>{const y=`h${t}`,x=f("font-sans text-pretty",is[r||fs(t)],ds[s],us[n],xs[a],l&&"truncate",c);return e.jsx(y,{className:x,...g,children:b})};function fs(t){return{1:"2xl",2:"xl",3:"lg",4:"lg",5:"md",6:"md"}[t]||"md"}const hs=({commands:t,isOpen:r,onClose:s,labels:n,initialCommandPath:a,initialActiveIndex:l})=>{const[c,b]=i.useState(""),[g,y]=i.useState(a||[]),[x,d]=i.useState(l||0),u=i.useRef(null),h=i.useRef(null),j=(g.length?t.find(p=>p.id===g[0])?.subCommands||[]:t).filter(p=>p.label.toLowerCase().includes(c.toLowerCase()));return i.useEffect(()=>{r||(b(""),y(a||[]),d(l||0))},[r]),i.useEffect(()=>{const p=L=>{if(r){if(L.key==="Escape")s();else if(L.key==="ArrowUp")d(k=>k>0?k-1:j.length-1);else if(L.key==="ArrowDown")d(k=>k<j.length-1?k+1:0);else if(L.key==="Enter"){const k=j[x];k&&(k.subCommands?(y([...g,k.id]),d(0)):k.action&&(k.action(),s()))}}};return document.addEventListener("keydown",p),()=>document.removeEventListener("keydown",p)},[r,s,j,x,g]),i.useEffect(()=>{const p=L=>{u.current&&!u.current.contains(L.target)&&s()};return r&&document.addEventListener("mousedown",p),()=>document.removeEventListener("mousedown",p)},[r,s]),i.useEffect(()=>{if(!r)return;h.current?.querySelector(`[data-index="${x}"]`)?.scrollIntoView({block:"nearest"})},[x,r]),r?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:u,children:[e.jsxs("div",{className:"flex items-center gap-2 px-3 flex-shrink-0",children:[e.jsx(G.Search,{className:"w-4 h-4 text-text-muted shrink-0"}),e.jsx("input",{type:"text",autoFocus:!0,placeholder:n?.searchPlaceholder||"Search commands...",value:c,onChange:p=>b(p.target.value),className:"w-full border-0 bg-transparent py-2 text-text focus:outline-none"})]}),e.jsxs("div",{ref:h,className:"mt-2 pt-2 text-sm border-t border-border max-h-dialog-list overflow-y-auto",children:[j.length===0&&e.jsx("div",{className:"text-text-muted text-center text-sm",children:n?.noCommandsFound||"No commands found"}),j.map((p,L)=>e.jsxs("div",{"data-index":L,className:`flex items-center p-2 cursor-pointer rounded-md ${L===x?"bg-accent-soft text-accent":"text-text"}`,onClick:()=>{p.subCommands?(y([...g,p.id]),d(0)):p.action&&(p.action(),s())},onMouseEnter:()=>d(L),children:[p.icon&&e.jsx("span",{className:"mr-3",children:p.icon}),e.jsx("span",{className:"flex-grow",children:p.label}),p.subCommands&&e.jsx("span",{className:"text-text-muted",children:e.jsx(G.ChevronRight,{className:"w-4 h-4"})})]},p.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},bs={none:"p-0",xs:"p-1",sm:"p-2",md:"p-4",lg:"p-6",xl:"p-8","2xl":"p-12"},ps={none:"m-0",xs:"m-1",sm:"m-2",md:"m-4",lg:"m-6",xl:"m-8","2xl":"m-12"},gs={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"},vs={none:"rounded-none",sm:"rounded-sm",md:"rounded-md",lg:"rounded-lg",xl:"rounded-xl",full:"rounded-full"},js={none:"shadow-none",sm:"shadow-none",md:"shadow-overlay",lg:"shadow-overlay",xl:"shadow-modal","2xl":"shadow-modal"},ys={none:"border-0",sm:"border",md:"border-2",lg:"border-4"},Ns={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"},be=i.forwardRef(({padding:t,margin:r,background:s,radius:n,shadow:a,border:l,borderColor:c,className:b,children:g,...y},x)=>e.jsx("div",{ref:x,className:f(t&&bs[t],r&&ps[r],s&&gs[s],n&&vs[n],a&&js[a],l&&ys[l],c&&Ns[c],b),...y,children:g}));be.displayName="Box";const ws=({children:t,title:r,...s})=>e.jsxs(be,{background:"module",radius:"lg",shadow:"none",border:"sm",borderColor:"neutral",...s,children:[r&&e.jsx("span",{className:"mb-2 block text-sm font-semibold text-text",children:r}),t]});function ks({identifier:t,resourceLoader:r,framework:s="react",fallback:n,componentProps:a,className:l}){const c=i.useRef(null),[b,g]=i.useState(!0),[y,x]=i.useState(null),d=i.useRef(null);return i.useRef(null),i.useEffect(()=>{let u=!0;return(async()=>{g(!0);try{const N=await r();if(!u)return;const j=N.component||N.default||N;x(s==="react"?()=>j:()=>N)}catch(N){console.error(`[FederatedResource] Load failed: ${t}`,N)}finally{u&&g(!1)}})(),()=>{u=!1}},[t,r]),i.useEffect(()=>{if(b||!y||s==="react")return;const u=c.current;if(u){if(s==="svelte"){const h=y.default||y,N=new h({target:u,props:a||{}});return d.current=N,()=>N.$destroy()}if(y.mount){const h=y.mount({container:u,props:a||{}});return()=>{typeof h=="function"?h():y.unmount?.(u)}}}},[y,s,b]),i.useEffect(()=>{s==="svelte"&&d.current&&d.current.$set?.(a)},[a,s]),e.jsxs("div",{ref:c,className:l,style:{display:"contents"},children:[b&&n,s==="react"&&y&&e.jsx(y,{...a})]})}class Cs extends i.Component{constructor(){super(...arguments),this.state={hasError:!1,error:null}}static getDerivedStateFromError(r){return{hasError:!0,error:r}}componentDidCatch(r,s){console.error(`[ErrorBoundary] Error in ${this.props.name||"Component"}:`,r,s)}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=Ut;exports.Avatar=ze;exports.AvatarStack=Jt;exports.Badge=It;exports.Box=be;exports.Button=Q;exports.ButtonGroup=Ve;exports.Card=ws;exports.ChannelBadge=Xt;exports.Checkbox=oe;exports.CommandPalette=hs;exports.ContentLoading=ke;exports.DatePicker=de;exports.Dropdown=Ce;exports.EmptyState=At;exports.ErrorBoundary=Cs;exports.FederatedResource=ks;exports.FilterChip=Ue;exports.FolderSelect=Ne;exports.Form=zt;exports.Heading=ms;exports.Icon=ne;exports.Image=Zt;exports.Kbd=Bt;exports.KpiCard=ss;exports.Link=Je;exports.List=Qt;exports.MeetingGrid=Pe;exports.Modal=Me;exports.PageHeader=rs;exports.PageToolbar=ns;exports.ParticipantTile=Ae;exports.Popover=je;exports.ProgressBar=Ot;exports.SearchableTextField=we;exports.SegmentedToggle=Xe;exports.Select=ce;exports.SidebarMenu=cs;exports.SourceChip=as;exports.Spinner=Ht;exports.SplitButton=he;exports.StorageInput=Le;exports.TabBar=vt;exports.Table=fe;exports.Tabs=Ee;exports.Text=se;exports.TextArea=ue;exports.TextField=ae;exports.VideoSurface=Be;exports.View=os;exports.cn=f;exports.createSizes=Ie;exports.createVariants=De;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const $e=require("clsx"),e=require("react/jsx-runtime"),J=require("lucide-react"),i=require("react");function x(...t){return $e.clsx(t)}function De(t){return(s,r)=>t[s]?.[r]||""}function Ae(t){return s=>t[s]||""}function Pe({tiles:t,pinned:s,className:r}){if(s)return e.jsxs("div",{className:x("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:x("grid gap-2 h-full",n,r),children:t.map((a,l)=>e.jsx("div",{children:a},l))})}function Be({name:t,avatarUrl:s,muted:r,speaking:n,hasVideo:a,videoSlot:l,className:c,fill:b}){return e.jsxs("div",{className:x("relative rounded-lg overflow-hidden bg-video-surface flex items-center justify-center",b?"h-full w-full":"aspect-video",n&&"ring-2 ring-speaking",c),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(J.VideoOff,{className:"w-8 h-8"}):e.jsx(J.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(J.MicOff,{className:"w-3 h-3"}):e.jsx(J.Mic,{className:"w-3 h-3"}),e.jsx("span",{className:"truncate max-w-35",children:t})]})]})}function Ie({attach:t,active:s=!0,mirrored:r=!1,className:n}){const a=i.useRef(null);return i.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:x("w-full h-full bg-video-surface-strong overflow-hidden",r&&"[&>*]:scale-x-[-1]",n)})}const Re={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",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"},Fe={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",full:"h-control-md px-4 text-sm"},Oe={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",full:"h-control-md w-8"},Z=i.forwardRef(({variant:t="primary",size:s="md",fullWidth:r=!1,loading:n=!1,leftIcon:a,rightIcon:l,iconOnly:c=!1,className:b,children:g,disabled:w,...m},d)=>{const u=w||n;return e.jsxs("button",{ref:d,type:"button",className:x("inline-flex shrink-0 items-center justify-center gap-2 rounded-md font-semibold","transition-colors duration-fast ease-out","focus-visible:outline-none focus-visible:focus-ring","disabled:cursor-not-allowed disabled:border-border-subtle","disabled:bg-surface-hover disabled:text-text-disabled",Re[t],c?Oe[s]:Fe[s],(r||s==="full")&&"w-full",n&&"cursor-wait",b),disabled:u,"aria-busy":n||void 0,...m,children:[n&&e.jsx("span",{"aria-hidden":!0,className:"size-icon-md shrink-0 animate-spin rounded-full border-2 border-current border-t-transparent"}),!n&&a&&e.jsx("span",{className:"shrink-0",children:a}),!c&&g,!n&&l&&e.jsx("span",{className:"shrink-0",children:l}),c&&!n&&!a&&!l&&g]})});Z.displayName="Button";const Ve=({children:t,size:s="md",orientation:r="horizontal",attached:n=!0,className:a})=>{const l=x("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})},We={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"},ne=({icon:t,size:s="md",color:r="current",clickable:n=!1,onClick:a,className:l,"aria-label":c,...b})=>{const g=typeof s=="number"?s:qe(s),w=x("inline-block shrink-0",We[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:g,strokeWidth:2,className:w,onClick:n?a:void 0,"aria-label":c,"aria-hidden":c?void 0:!0,role:n?"button":void 0,tabIndex:n?0:void 0,onKeyDown:n?d=>{(d.key==="Enter"||d.key===" ")&&(d.preventDefault(),a?.())}:void 0,...b};return e.jsx(t,{...m})};function qe(t){return{xs:12,sm:14,md:16,lg:20,xl:24}[t]}function He(){return e.jsx("svg",{className:"size-icon-sm",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,children:e.jsx("path",{d:"m6 9 6 6 6-6"})})}function Ue({label:t,active:s=!1,caret:r=!1,onClear:n,onClick:a,className:l}){return e.jsxs("span",{onClick:a,className:x("inline-flex h-control-sm cursor-pointer select-none items-center gap-1.5 rounded-full px-3 text-sm font-semibold","transition-colors duration-fast ease-out",s?"bg-accent text-accent-fg":"border border-border text-text-muted hover:bg-surface-hover hover:text-text",l),children:[t,r&&e.jsx(He,{}),s&&n&&e.jsx("button",{type:"button","aria-label":"Filter wissen",onClick:c=>{c.stopPropagation(),n()},className:"ml-0.5 inline-flex items-center rounded-full focus-visible:outline-none focus-visible:focus-ring",children:e.jsx(ne,{icon:J.X,size:"xs"})})]})}const _e={xs:"text-xs",sm:"text-sm",md:"text-base",lg:"text-md",xl:"text-lg"},Ke={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"},Ge={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"},Je=({variant:t="default",size:s="md",color:r="primary",disabled:n=!1,external:a=!1,className:l,children:c,href:b,target:g,rel:w,...m})=>{const d=a||b&&(b.startsWith("http")||b.startsWith("mailto:")),u=x("inline-flex items-center gap-1 underline-offset-2","transition-colors duration-fast ease-out","focus-visible:outline-none focus-visible:focus-ring",_e[s],!n&&Ke[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",Ge[r]],n&&"pointer-events-none cursor-not-allowed text-text-disabled opacity-50",l),h={...m,href:n?void 0:b,target:d?"_blank":g,rel:d?"noopener noreferrer":w,"aria-disabled":n||void 0};return e.jsxs("a",{className:u,...h,children:[c,d&&e.jsx(J.ExternalLink,{className:"size-icon-sm shrink-0","aria-hidden":!0})]})},Ye={sm:"h-control-sm px-3 text-sm",md:"h-control-md px-3 text-sm"};function Xe({options:t,value:s,onChange:r,size:n="sm",className:a,"aria-label":l}){return e.jsx("div",{role:"tablist","aria-label":l,className:x("inline-flex gap-0.5 rounded-md bg-surface-hover p-0.5",a),children:t.map(c=>{const b=c.value===s;return e.jsx("button",{role:"tab","aria-selected":b,type:"button",onClick:()=>r(c.value),className:x("inline-flex items-center justify-center rounded-sm font-semibold","transition-colors duration-fast ease-out","focus-visible:outline-none focus-visible:focus-ring",Ye[n],b?"bg-surface text-text":"text-text-muted hover:text-text"),children:c.label},c.value)})})}const je=({trigger:t,children:s,placement:r="bottom-start",className:n,disabled:a=!1,triggerLabel:l})=>{const[c,b]=i.useState(!1),[g,w]=i.useState({}),m=i.useRef(null),d=i.useRef(null);i.useEffect(()=>{if(!c)return;const y=p=>{m.current&&!m.current.contains(p.target)&&b(!1)},j=p=>{p.key==="Escape"&&b(!1)};return document.addEventListener("mousedown",y),document.addEventListener("keydown",j),()=>{document.removeEventListener("mousedown",y),document.removeEventListener("keydown",j)}},[c]);const u=y=>{if(y.stopPropagation(),!a){if(!c){const j=d.current?.getBoundingClientRect();if(j){const L={};r.startsWith("bottom")?L.top=j.bottom+6:L.bottom=window.innerHeight-j.top+6,r.endsWith("start")?L.left=j.left:L.right=window.innerWidth-j.right,w(L)}}b(j=>!j)}},h=()=>b(!1);return e.jsxs("div",{ref:m,className:"relative inline-flex",children:[e.jsx("button",{ref:d,type:"button",onClick:u,disabled:a,"aria-label":l,"aria-expanded":c,className:x("inline-flex items-center",a&&"cursor-not-allowed opacity-50"),children:t}),c&&e.jsx("div",{className:x("fixed z-overlay bg-surface rounded-lg shadow-overlay border border-border",n),style:g,children:typeof s=="function"?s(h):s})]})},Ze={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"},Qe={sm:"h-control-sm w-7",md:"h-control-md w-8"};function he({label:t,onClick:s,variant:r="primary",size:n="md",icon:a,options:l,disabled:c=!1,loading:b=!1,menuPlacement:g="bottom-end",menuLabel:w="More options"}){const m=c||b,d=l.length>0;return e.jsxs("div",{className:"inline-flex items-center gap-px",children:[e.jsx(Z,{variant:r,size:n,onClick:s,disabled:c,loading:b,leftIcon:a,className:x(d&&"rounded-r-none"),children:t}),d&&e.jsx(je,{placement:g,disabled:m,triggerLabel:w,className:"min-w-menu py-1",trigger:e.jsx("span",{"aria-hidden":"true",className:x("inline-flex items-center justify-center rounded-md rounded-l-none","transition-colors duration-fast ease-out",Ze[r],Qe[n],m&&"cursor-not-allowed opacity-50"),children:e.jsx(J.ChevronDown,{className:"size-icon-md"})}),children:u=>e.jsx(e.Fragment,{children:l.map(h=>e.jsxs("button",{type:"button",onClick:()=>{h.onClick(),u()},className:x("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",h.variant==="destructive"?"text-danger-fg hover:bg-danger-soft":"text-text hover:bg-surface-hover"),children:[h.icon&&e.jsx("span",{className:"shrink-0",children:h.icon}),h.label]},h.id))})})]})}const et={sm:"size-checkbox",md:"size-checkbox",lg:"size-checkbox",full:"size-checkbox"},tt={sm:"text-sm",md:"text-base",lg:"text-md",full:"text-md"},oe=i.forwardRef(({label:t,helperText:s,error:r,size:n="md",indeterminate:a=!1,containerClassName:l,labelClassName:c,className:b,id:g,...w},m)=>{const d=i.useId(),u=g||`checkbox-${d}`,h=!!r,y=i.useRef(null),j=i.useCallback(p=>{y.current=p,typeof m=="function"?m(p):m&&typeof m=="object"&&(m.current=p)},[m]);return i.useEffect(()=>{y.current&&(y.current.indeterminate=a)},[a]),e.jsxs("div",{className:x("flex flex-col",l),children:[e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx("input",{ref:j,id:u,type:"checkbox","aria-invalid":h||void 0,className:x("mt-0.5 shrink-0 rounded-sm border bg-surface-input 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],h?"border-danger-border":"border-border-strong",b),...w}),t&&e.jsxs("div",{className:"flex-1",children:[e.jsx("label",{htmlFor:u,className:x("cursor-pointer",h?"text-danger-fg":"text-text",tt[n],c),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})]})});oe.displayName="Checkbox";const st=()=>e.jsx("svg",{className:"h-4 w-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M8 7V3m8 4V3m-9 8h10M5 21h14a2 2 0 002-2V7a2 2 0 00-2-2H5a2 2 0 00-2 2v12a2 2 0 002 2z"})}),rt=()=>e.jsx("svg",{className:"h-4 w-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"m15 18-6-6 6-6"})}),nt=()=>e.jsx("svg",{className:"h-4 w-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"m9 18 6-6-6-6"})}),de=i.forwardRef(({value:t,onChange:s,placeholder:r="Select date",disabled:n=!1,required:a=!1,size:l="md",className:c,minDate:b,maxDate:g,format:w="MM/dd/yyyy"},m)=>{const[d,u]=i.useState(!1),[h,y]=i.useState(()=>t||new Date),j=i.useRef(null);i.useEffect(()=>{const z=W=>{j.current&&!j.current.contains(W.target)&&u(!1)};return d&&document.addEventListener("mousedown",z),()=>{document.removeEventListener("mousedown",z)}},[d]);const p=z=>{if(!z)return"";const W=z.getDate().toString().padStart(2,"0"),_=(z.getMonth()+1).toString().padStart(2,"0"),N=z.getFullYear();switch(w){case"dd/MM/yyyy":return`${W}/${_}/${N}`;case"yyyy-MM-dd":return`${N}-${_}-${W}`;case"MM/dd/yyyy":default:return`${_}/${W}/${N}`}},L=()=>{const z=h.getFullYear(),W=h.getMonth(),_=new Date(z,W,1),N=new Date(_);N.setDate(N.getDate()-_.getDay());const f=[],C=new Date(N);for(let P=0;P<42;P++)f.push(new Date(C)),C.setDate(C.getDate()+1);return f},k=z=>{z.getMonth()===h.getMonth()&&(b&&z<b||g&&z>g||(s?.(z),u(!1)))},K=()=>{y(new Date(h.getFullYear(),h.getMonth()-1,1))},R=()=>{y(new Date(h.getFullYear(),h.getMonth()+1,1))},Y=()=>{s?.(null),u(!1)},U=x("w-full border border-border rounded-md 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"},c),$=L(),G=["January","February","March","April","May","June","July","August","September","October","November","December"];return e.jsxs("div",{ref:j,className:"relative",children:[e.jsxs("div",{className:"relative",children:[e.jsx("input",{ref:m,type:"text",value:p(t??null),placeholder:r,disabled:n,required:a,readOnly:!0,onClick:()=>!n&&u(!d),className:x(U,"pr-10 cursor-pointer")}),e.jsx("button",{type:"button",onClick:()=>!n&&u(!d),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,{})})]}),d&&e.jsxs("div",{className:"absolute z-50 mt-1 bg-surface border border-border rounded-lg shadow-overlay p-4 min-w-panel",children:[e.jsxs("div",{className:"flex items-center justify-between mb-4",children:[e.jsx("button",{onClick:K,className:"p-1 hover:bg-surface-hover rounded",children:e.jsx(rt,{})}),e.jsxs("h3",{className:"text-sm font-medium text-text",children:[G[h.getMonth()]," ",h.getFullYear()]}),e.jsx("button",{onClick:R,className:"p-1 hover:bg-surface-hover rounded",children:e.jsx(nt,{})})]}),e.jsx("div",{className:"grid grid-cols-7 gap-1 mb-2",children:["Su","Mo","Tu","We","Th","Fr","Sa"].map(z=>e.jsx("div",{className:"text-xs font-medium text-text-muted text-center py-1",children:z},z))}),e.jsx("div",{className:"grid grid-cols-7 gap-1",children:$.map((z,W)=>{const _=z.getMonth()===h.getMonth(),N=t&&z.toDateString()===t.toDateString(),f=z.toDateString()===new Date().toDateString(),C=!_||b&&z<b||g&&z>g;return e.jsx("button",{onClick:()=>!C&&k(z),disabled:C,className:x("w-8 h-8 text-sm rounded transition-colors duration-fast",{"text-text hover:bg-surface-hover":_&&!N&&!C,"bg-accent text-accent-fg":N,"bg-surface-hover text-text":f&&!N,"text-text-muted cursor-not-allowed":C}),children:z.getDate()},W)})}),e.jsxs("div",{className:"flex justify-between items-center mt-4 pt-3 border-t border-border",children:[e.jsx("button",{onClick:Y,className:"text-sm text-text-muted hover:text-text",children:"Clear"}),e.jsx("button",{onClick:()=>u(!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"},ie=t=>t.trim().toLowerCase(),ce=i.forwardRef(({label:t,helperText:s,error:r,size:n="md",fullWidth:a=!1,options:l,placeholder:c,containerClassName:b,labelClassName:g,className:w,id:m,searchable:d,multiple:u,value:h,onChange:y,allowCreate:j,onCreateOption:p,...L},k)=>{const K=m||`select-${Math.random().toString(36).substr(2,9)}`,R=!!r,[Y,U]=i.useState(!1),[$,G]=i.useState(""),z=i.useRef(null),[W,_]=i.useState(l);i.useImperativeHandle(k,()=>z.current),i.useEffect(()=>{const D=A=>{z.current&&!z.current.contains(A.target)&&U(!1)};return document.addEventListener("mousedown",D),()=>document.removeEventListener("mousedown",D)},[]);const N=i.useCallback((D,A)=>D.some(v=>ie(v.value)===ie(A)||ie(v.label)===ie(A)),[]),f=i.useCallback((D,A)=>{const v=[...D],T=I=>{const O=(I??"").trim();O&&(N(v,O)||v.push({value:O,label:O}))};return Array.isArray(A)?A.forEach(T):T(A),v},[N]);i.useEffect(()=>{_(D=>{const A=[...l];return D.forEach(v=>{!N(A,v.value)&&!N(A,v.label)&&A.push(v)}),f(A,h)})},[l,h,f,N]);const C=D=>{if(u){const A=Array.isArray(h)?h:[],v=A.includes(D)?A.filter(T=>T!==D):[...A,D];y?.(v)}else y?.(D),U(!1),G("")},P=u?null:W.find(D=>D.value===h),S=u?W.filter(D=>Array.isArray(h)&&h.includes(D.value)):[],q=d&&$?W.filter(D=>D.label.toLowerCase().includes($.toLowerCase())):W,M=!!j&&!!d&&!!$.trim()&&!N(W,$),ee=D=>{const A=D.trim();if(!A)return;const v=p?.(A)??{value:A,label:A};if(N(W,v.value)||N(W,v.label)){C(v.value),G(""),u||U(!1);return}_(T=>[...T,v]),C(v.value),G(""),u||U(!1)},te=()=>u?S.length>0?S.map(D=>D.label).join(", "):c||"Select options":P?.label||c||"Select an option";return e.jsxs("div",{ref:z,className:x("relative flex flex-col",a&&"w-full",b),...L,children:[t&&e.jsx("label",{htmlFor:K,onClick:()=>U(!Y),className:x("block text-xs font-semibold uppercase tracking-label mb-1.5",R?"text-danger-fg":"text-text-muted",g),children:t}),e.jsxs("div",{className:"relative",children:[e.jsxs("button",{type:"button",id:K,onClick:()=>U(!Y),className:x("flex w-full items-center justify-between gap-2 rounded-md 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],R?"border-danger-border text-danger-fg focus-visible:focus-ring":"border-border text-text",w),children:[e.jsx("span",{className:"truncate flex-1 min-w-0",children:te()}),e.jsx(J.ChevronDownIcon,{size:16,className:x("shrink-0 opacity-60 transition-transform duration-fast",Y&&"rotate-180")})]}),Y&&e.jsxs("div",{className:"absolute z-10 mt-1 w-full rounded-lg bg-surface shadow-overlay border border-border",children:[d&&e.jsx("div",{className:"p-2",children:e.jsx("input",{type:"text",placeholder:"Search...",value:$,onChange:D=>G(D.target.value),onKeyDown:D=>{D.key==="Enter"&&M&&(D.preventDefault(),ee($))},className:x("w-full px-3 py-2 text-sm rounded-md border","text-text border-border focus-visible:outline-none focus-visible:focus-ring")})}),M&&e.jsxs("div",{className:x("cursor-pointer px-3 py-1.5 text-sm","text-info-fg hover:bg-surface-hover"),onClick:()=>ee($),children:["+: “",$.trim(),"”"]}),e.jsxs("ul",{className:"max-h-60 overflow-auto py-1",children:[c&&!u&&e.jsx("li",{className:"cursor-pointer px-3 py-1.5 text-sm text-text-muted hover:bg-surface-hover",onClick:()=>{y?.(""),U(!1)},children:c}),q.map(D=>{const A=u?Array.isArray(h)&&h.includes(D.value):h===D.value;return e.jsx("li",{onClick:()=>!D.disabled&&C(D.value),className:x("cursor-pointer px-3 py-1.5 text-sm","text-text",D.disabled?"opacity-50 cursor-not-allowed":"hover:bg-surface-hover",A&&"bg-accent-soft text-accent font-semibold"),children:e.jsxs("div",{className:"flex items-center",children:[u&&e.jsx("input",{type:"checkbox",checked:A,readOnly:!0,className:"mr-3 h-4 w-4 rounded border-border [&:not(:checked)]:bg-surface-input text-accent "}),e.jsx("span",{children:D.label})]})},D.value)})]})]})]}),(r||s)&&e.jsx("p",{className:x("mt-1 text-xs",R?"text-danger-fg":"text-text-muted"),children:r||s})]})});ce.displayName="Select";const lt={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"},ye="mb-1.5 block text-xs font-semibold uppercase tracking-label",ae=i.forwardRef(({label:t,helperText:s,error:r,size:n="md",fullWidth:a=!1,startIcon:l,endIcon:c,loading:b=!1,containerClassName:g,labelClassName:w,className:m,id:d,...u},h)=>{const y=i.useId(),j=d||`textfield-${y}`,p=!!r,L=r||s?`${j}-description`:void 0;return e.jsxs("div",{className:x("flex flex-col",a&&"w-full",g),children:[t&&e.jsx("label",{htmlFor:j,className:x(ye,p?"text-danger-fg":"text-text-subtle",w),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:h,id:j,"aria-invalid":p||void 0,"aria-describedby":L,className:x("block w-full rounded-md 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",lt[n],l&&"pl-9",(c||b)&&"pr-9",p?"border-danger-border bg-danger-soft":"border-border hover:border-border-strong",m),...u}),(c||b)&&e.jsx("span",{className:"absolute inset-y-0 right-0 flex items-center pr-3 text-text-muted",children:b?e.jsx("span",{"aria-hidden":!0,className:"size-icon-md animate-spin rounded-full border-2 border-border border-t-transparent"}):c})]}),(r||s)&&e.jsx("p",{id:L,className:x("mt-1 text-xs",p?"text-danger-fg":"text-text-subtle"),children:r||s})]})});ae.displayName="TextField";function Ne({value:t,onChange:s,onListFolders:r,disabled:n,size:a="md",placeholder:l,templatePlaceholder:c,showTemplate:b=!0}){const[g,w]=i.useState([]);i.useEffect(()=>{let d=!0;return Promise.resolve(r?.()).then(u=>{d&&u&&w(u.data??[])}).catch(()=>{}),()=>{d=!1}},[]);const m=t??{};return e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsx(ce,{size:a,fullWidth:!0,value:m.folderId??"",options:g.map(d=>({value:d.id,label:d.name})),placeholder:l??"Select a folder",onChange:d=>s?.({...m,folderId:d})}),b&&e.jsx(ae,{size:a,disabled:n??!1,value:m.pathTemplate??"",placeholder:c??"Sub-path e.g. {yyyy}/{mm}/{dd} (optional)",onChange:d=>s?.({...m,pathTemplate:d.target.value})})]})}const le=(...t)=>t.filter(Boolean).join(" "),ot=t=>e.jsx("svg",{...t,xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",strokeWidth:1.5,stroke:"currentColor",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"m21 21-5.197-5.197m0 0A7.5 7.5 0 1 0 5.197 5.197a7.5 7.5 0 0 0 10.606 10.606Z"})}),ct=t=>e.jsx("svg",{...t,xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",strokeWidth:1.5,stroke:"currentColor",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"m19.5 8.25-7.5 7.5-7.5-7.5"})}),it={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"},fe={sm:"h-4 w-4",md:"h-5 w-5",lg:"h-6 w-6",full:"h-6 w-6"},we=i.forwardRef(({label:t,helperText:s,error:r,size:n="md",fullWidth:a=!1,startIcon:l=e.jsx(ot,{}),loading:c=!1,containerClassName:b,labelClassName:g,className:w,id:m,options:d,onRemoteSearch:u,onSelect:h,debounceTime:y=500,showAllOnOpen:j=!1,value:p,onChange:L,...k},K)=>{const R=m||`searchfield-${Math.random().toString(36).substr(2,9)}`,Y=!!r,U=i.useRef(null),$=i.useRef(null),[G,z]=i.useState(p||""),[W,_]=i.useState(!1),[N,f]=i.useState(!1),[C,P]=i.useState(!1);i.useEffect(()=>{p!==void 0&&z(p)},[p]);const S=i.useMemo(()=>{if(j&&!C||!G)return d;const v=String(G).toLowerCase();return d.filter(T=>String(T.label).toLowerCase().includes(v))},[G,d,j,C]);i.useEffect(()=>{if(!u||!G){f(!1);return}const v=setTimeout(async()=>{f(!0);try{await u(String(G))}catch(T){console.error("Remote search failed:",T)}finally{f(!1)}},y);return()=>{clearTimeout(v),f(!1)}},[G,y,u]),i.useEffect(()=>{const v=T=>{U.current&&!U.current.contains(T.target)&&_(!1)};return document.addEventListener("mousedown",v),()=>document.removeEventListener("mousedown",v)},[]);const q=v=>{const T=v.target.value;z(T),_(!0),P(!0),L&&L(v)},M=v=>{z(v.label),_(!1),P(!1),h&&h(v.value)},ee=()=>{(d.length>0||u)&&(_(!0),P(!1))},te=c||N,D=W&&(S.length>0||te),A=i.useMemo(()=>K||$,[K]);return e.jsxs("div",{className:le("flex flex-col",a?"w-full":"",b||"","relative"),ref:U,children:[t&&e.jsx("label",{htmlFor:R,className:le("block text-sm font-medium mb-1",Y?"text-danger-fg":"text-text",g||""),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:le("text-text-muted",fe[n]),children:l})}),e.jsx("input",{ref:A,id:R,value:G,onChange:q,onFocus:ee,className:le("block w-full rounded-md 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",it[n],l?"pl-10":"","pr-10",Y?"border-danger-border text-danger-fg focus-visible:focus-ring":"border-border text-text",w||""),...k}),e.jsx("div",{className:"absolute inset-y-0 right-0 pr-3 flex items-center",children:te||c?e.jsxs("svg",{className:le("animate-spin text-info-fg",fe[n]),xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",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"})]}):e.jsx(ct,{className:le("text-text-muted cursor-pointer transition-transform",fe[n],W?"rotate-180":"rotate-0"),onClick:()=>{_(v=>(v||P(!1),!v))}})})]}),D&&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:S.length>0?S.map(v=>e.jsx("li",{className:"px-4 py-2 cursor-pointer text-text hover:bg-accent-soft hover:text-accent transition-colors",onClick:()=>M(v),role:"option","aria-selected":G===v.label,children:v.label},v.value)):e.jsx("li",{className:"px-4 py-2 text-text-muted",children:te||c?"Zoeken op afstand...":"Geen resultaten gevonden."})}),(r||s)&&e.jsx("p",{className:le("mt-1 text-xs",Y?"text-danger-fg":"text-text-muted"),children:r||s}),u&&e.jsxs("p",{className:"mt-2 text-xs text-success-fg",children:["Huidige zoekterm (niet-gedebounced): ",String(G)]})]})});we.displayName="SearchableTextField";function ke({children:t,showTableSkeleton:s=!1,tableColumns:r=6,tableRows:n=8}){return t?e.jsx("main",{className:"flex-1 bg-surface p-6",children:e.jsx("div",{className:"w-full max-w-6xl mx-auto animate-pulse",children:t})}):e.jsx("main",{className:"flex-1 bg-surface p-6",children:e.jsxs("div",{className:"w-full mx-auto space-y-6 animate-pulse",children:[!s&&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"})]})]}),s&&e.jsxs("div",{className:"rounded-lg overflow-hidden",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((a,l)=>e.jsx("div",{className:"h-4 w-2/3 rounded-sm bg-border-strong"},`header-${l}`))}),Array.from({length:n}).map((a,l)=>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((c,b)=>e.jsx("div",{className:"h-4 w-full rounded-sm bg-surface-hover"},`cell-${l}-${b}`))},`row-${l}`))]})]})})}const Ce=({trigger:t,options:s,value:r,onSelect:n,placement:a="bottom-start",disabled:l=!1,className:c,showCheck:b=!0,header:g})=>{const[w,m]=i.useState(!1),[d,u]=i.useState(null),[h,y]=i.useState({top:0,left:0}),[j,p]=i.useState({}),L=i.useRef(null),k=i.useRef(null),K=i.useRef(null),R=i.useRef(null);i.useEffect(()=>{const N=f=>{L.current&&(!L.current.contains(f.target)||K.current&&!K.current.contains(f.target))&&(m(!1),u(null),R.current&&(clearTimeout(R.current),R.current=null))};return w&&document.addEventListener("mousedown",N),()=>{document.removeEventListener("mousedown",N)}},[w]),i.useEffect(()=>{const N=f=>{f.key==="Escape"&&(m(!1),u(null),R.current&&(clearTimeout(R.current),R.current=null))};return w&&document.addEventListener("keydown",N),()=>{document.removeEventListener("keydown",N)}},[w]),i.useEffect(()=>{if(d&&L.current){const N=L.current.querySelector(`[data-option-value="${d}"]`);if(N){const f=N.getBoundingClientRect();y({top:f.top,left:f.right+8})}}},[d]),i.useEffect(()=>()=>{R.current&&clearTimeout(R.current)},[]);const Y=N=>{if(N.stopPropagation(),!l){if(!w){const f=k.current?.getBoundingClientRect();if(f){const P={};a.startsWith("bottom")?P.top=f.bottom+6:P.bottom=window.innerHeight-f.top+6,a.endsWith("start")?P.left=f.left:P.right=window.innerWidth-f.right,p(P)}}m(!w),u(null),R.current&&(clearTimeout(R.current),R.current=null)}},U=(N,f,C)=>{N.stopPropagation(),!f.disabled&&!f.divider&&(!f.children||f.children.length===0)&&(n?.(f.value,C),m(!1),u(null))},$=N=>{R.current&&(clearTimeout(R.current),R.current=null),N.children&&N.children.length>0?u(N.value):u(null)},G=N=>{N.children&&N.children.length>0?R.current=setTimeout(()=>{u(null)},150):u(null)},z=(N,f,C)=>{N.stopPropagation(),!f.disabled&&!f.divider&&(n?.(f.value,C),m(!1),u(null))},W=x("fixed z-overlay min-w-menu bg-surface rounded-lg shadow-overlay border border-border","max-h-60 overflow-auto"),_=x("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:L,className:x("relative flex flex-row items-center justify-center rounded-lg hover:bg-surface-hover",c),children:[e.jsx("button",{ref:k,onClick:Y,disabled:l,className:x("inline-flex items-center justify-center",{"opacity-50 cursor-not-allowed":l}),children:t}),w&&e.jsx("div",{className:W,style:j,children:e.jsxs("div",{className:"p-2",children:[g&&(typeof g=="string"?e.jsx("div",{className:"text-xs font-medium text-text-muted uppercase tracking-label px-3 py-2",children:g}):g),s.map((N,f)=>{if(N.divider)return e.jsx("div",{className:"border-t border-border my-2"},`divider-${f}`);const C=N.children&&N.children.length>0,P=d===N.value;return e.jsxs("div",{className:"relative group",children:[e.jsxs("button",{"data-option-value":N.value,onClick:S=>U(S,N),onMouseEnter:()=>$(N),onMouseLeave:()=>G(N),disabled:N.disabled,className:x("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":N.disabled,"bg-surface-hover":P&&C}),children:[e.jsxs("div",{className:"flex items-center space-x-2 min-w-0",children:[N.icon&&e.jsx("span",{className:"flex-shrink-0",children:N.icon}),e.jsxs("div",{className:"flex flex-col items-start min-w-0",children:[e.jsx("span",{className:"font-base truncate",children:N.label}),N.description&&e.jsx("span",{className:"text-xs text-text-muted",children:N.description})]})]}),e.jsxs("div",{className:"flex items-center space-x-2",children:[b&&r===N.value&&e.jsx(J.Check,{className:"size-icon-md shrink-0 text-success-fg","aria-hidden":!0}),C&&e.jsx("span",{className:"text-text-muted text-xs",children:"▶"})]})]}),C&&P&&e.jsx("div",{ref:K,className:_,style:{top:`${h.top}px`,left:`${h.left}px`},onMouseEnter:()=>{R.current&&(clearTimeout(R.current),R.current=null),u(N.value)},onMouseLeave:()=>{R.current=setTimeout(()=>{u(null)},150)},children:e.jsx("div",{className:"p-2",children:N.children.map((S,q)=>{if(S.divider)return e.jsx("div",{className:"border-t border-border my-2"},`divider-${q}`);const M=typeof r=="object"&&r[N.value]&&r[N.value].includes(S.value)||r===S.value;return e.jsxs("button",{onClick:ee=>z(ee,S,N.value),disabled:S.disabled,className:x("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":S.disabled}),children:[e.jsxs("div",{className:"flex items-center space-x-2 min-w-0",children:[S.icon&&e.jsx("span",{className:"flex-shrink-0",children:S.icon}),e.jsxs("div",{className:"flex flex-col items-start min-w-0",children:[e.jsx("span",{className:"font-base truncate",children:S.label}),S.description&&e.jsx("span",{className:"text-xs text-text-muted",children:S.description})]})]}),b&&M&&e.jsx(J.Check,{className:"size-icon-md shrink-0 text-success-fg","aria-hidden":!0})]},S.value)})})})]},N.value)}),(()=>{const N=s.reduce((f,C)=>{if(C.divider)return f;const P=C.children?C.children.filter(S=>!S.divider).length:0;return f+1+P},0);return N>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:[N," options available"]})})})()]})})]})},dt=()=>e.jsx("svg",{className:"h-4 w-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"m21 21-6-6m2-5a7 7 0 11-14 0 7 7 0 0114 0z"})}),ut=({active:t})=>e.jsx("svg",{className:x("h-3 w-3",t?"text-text":"text-text-muted"),fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"m18 15-6-6-6 6"})}),xt=({active:t})=>e.jsx("svg",{className:x("h-3 w-3",t?"text-text":"text-text-muted"),fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"m6 9 6 6 6-6"})}),ft=()=>e.jsx("svg",{className:"h-4 w-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"m15 18-6-6 6-6"})}),mt=()=>e.jsx("svg",{className:"h-4 w-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"m9 18 6-6-6-6"})}),ht=()=>e.jsx("svg",{className:"h-4 w-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"m11 17-5-5 5-5m6 10-5-5 5-5"})}),bt=()=>e.jsx("svg",{className:"h-4 w-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"m7 17 5-5-5-5m6 10 5-5-5-5"})}),Se=()=>e.jsx("svg",{className:"h-4 w-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"m6 9 6 6 6-6"})}),pt=t=>{const s=n=>t.multiSelect&&Array.isArray(t.value)?t.value?.includes(n):t.value===n,r=n=>{t.multiSelect&&Array.isArray(t.value)?t.onChange(t.value.filter(a=>a!==n)):t.onChange(n)};return t.type==="date"?e.jsx("div",{className:"flex items-center space-x-1 max-w-40",children:e.jsx(de,{size:"sm",value:t.value,onChange:n=>t.onChange(n),placeholder:t.placeholder||`Select ${t.label.toLowerCase()}`,className:"min-w-40 border border-border bg-surface text-text hover:bg-surface-hover"})}):e.jsx("div",{className:"flex items-center space-x-1 max-w-60",children:e.jsx("div",{className:"relative",children:e.jsxs("details",{className:"group",children:[e.jsxs("summary",{className:"flex h-control-md cursor-pointer items-center gap-2 rounded-full border border-border bg-surface px-3 text-sm font-semibold text-text hover:bg-surface-hover",children:[e.jsx("span",{children:t.label}),e.jsx("span",{className:"text-text",children:t.multiSelect&&Array.isArray(t.value)?t.value?.map(n=>t.options?.find(a=>a.value===n)?.label).join(", "):t.options?.find(n=>n.value===t.value)?.label}),e.jsx("span",{className:"text-text-muted text-sm group-open:rotate-180 transition-transform",children:e.jsx(Se,{})})]}),e.jsxs("div",{className:"absolute z-10 left-0 mt-1 bg-surface border border-border rounded-lg shadow-overlay p-2 w-48",children:[t.options?.map(n=>e.jsx("button",{className:"w-full text-left px-3 py-2 rounded-md hover:bg-surface-hover text-sm text-text flex items-center space-x-2",onClick:()=>r(n.value),children:e.jsx("span",{className:x(s(n.value)&&"text-accent"),children:n.label})},n.value)),t.value&&e.jsx("button",{className:"w-full text-left px-3 py-2 rounded-md hover:bg-surface-hover text-sm text-text flex items-center space-x-2 mt-2",onClick:()=>r(null),children:e.jsx("span",{className:"text-text-muted",children:"Clear filter"})})]})]})})})},me=({data:t,columns:s,loading:r=!1,searchable:n=!1,searchPlaceholder:a="Search...",filters:l=[],paginated:c=!1,pageSizeOptions:b=[10,25,50,100],defaultPageSize:g=10,actions:w=[],onRowClick:m,selectable:d=!1,selectedRows:u=[],onSelectionChange:h,getRowKey:y=(Y,U)=>U,emptyContent:j,hoverable:p=!0,bordered:L=!1,striped:k=!1,className:K,rowClassName:R})=>{const[Y,U]=i.useState(""),[$,G]=i.useState({column:null,direction:null}),[z,W]=i.useState({page:0,pageSize:g}),_=i.useRef(null),N=i.useMemo(()=>{let o=t;if(n&&Y.trim()){const E=s.filter(H=>H.searchable!==!1),F=Y.toLowerCase();o=o.filter(H=>E.some(B=>{const X=typeof B.accessor=="function"?B.accessor(H):H[B.accessor];return String(X||"").toLowerCase().includes(F)}))}return l.forEach(E=>{E.value&&E.value!=="all"&&(o=o.filter(F=>{const H=s.find(X=>X.id===E.id);if(!H)return!0;const B=typeof H.accessor=="function"?H.accessor(F):F[H.accessor];return String(B||"")===E.value}))}),o},[t,Y,s,n,l]),f=i.useMemo(()=>{if(!$.column||!$.direction)return N;const o=s.find(E=>E.id===$.column);return o?[...N].sort((E,F)=>{const H=typeof o.accessor=="function"?o.accessor(E):E[o.accessor],B=typeof o.accessor=="function"?o.accessor(F):F[o.accessor];let X=0;return H<B?X=-1:H>B&&(X=1),$.direction==="desc"?-X:X}):N},[N,$,s]),C=i.useMemo(()=>{if(!c)return f;const o=z.page*z.pageSize,E=o+z.pageSize;return f.slice(o,E)},[f,z,c]),P=i.useCallback(o=>{s.find(F=>F.id===o)?.sortable&&G(F=>F.column!==o?{column:o,direction:"asc"}:F.direction==="asc"?{column:o,direction:"desc"}:{column:null,direction:null})},[s]),S=i.useCallback(o=>{W(E=>({...E,page:o}))},[]),q=i.useCallback(o=>{W({page:0,pageSize:o})},[]),M=i.useCallback((o,E)=>{if(!h)return;const F=y(o,0);u.map((H,B)=>y(H,B)),h(E?[...u,o]:u.filter((H,B)=>y(u[B],B)!==F))},[u,h,y]),ee=i.useCallback(o=>{h&&h(o?[...C]:[])},[C,h]);i.useEffect(()=>{W(o=>({...o,page:0}))},[Y,$]),i.useEffect(()=>{W(o=>({...o,page:0}))},[l.map(o=>o.value).join(",")]);const te=f.length,D=Math.ceil(te/z.pageSize),A=z.page*z.pageSize+1,v=Math.min(A+z.pageSize-1,te),T=C.length>0&&C.every(o=>{const E=y(o,0);return u.some((F,H)=>y(F,H)===E)}),I=C.some(o=>{const E=y(o,0);return u.some((F,H)=>y(F,H)===E)}),O=x("w-full text-sm leading-5 text-text border-collapse",K),Q=x("bg-surface"),V=x("text-text p-3 border-b border-border"),re=x("h-row-lg",{"hover:bg-surface-sunk":p,"cursor-pointer":m});return e.jsxs("div",{className:"space-y-4",children:[(n||l.length>0)&&e.jsx("div",{className:"pt-4 pb-2",children:e.jsxs("div",{className:"flex flex-wrap gap-4 items-start",children:[l.map(o=>e.jsx(pt,{...o},o.id)),e.jsx("div",{className:"w-full sm:w-auto sm:ml-auto min-w-menu",children:e.jsx(ae,{placeholder:a,value:Y,onChange:o=>U(o.target.value),startIcon:e.jsx(dt,{}),className:"max-w-sm"})})]})}),e.jsxs("div",{className:"relative w-full overflow-x-auto min-h-100",children:[r&&e.jsx("div",{className:"flex items-center justify-center z-10",children:e.jsx(ke,{showTableSkeleton:!0,tableRows:10,tableColumns:s.length})}),e.jsxs("table",{ref:_,className:x(O,"min-w-full"),children:[e.jsx("thead",{className:Q,children:e.jsxs("tr",{children:[d&&e.jsx("th",{className:x(V,"w-12"),children:e.jsx("input",{type:"checkbox",checked:T,ref:o=>{o&&(o.indeterminate=I&&!T)},onChange:o=>ee(o.target.checked),className:"rounded border-border [&:not(:checked)]:bg-surface-input text-accent"})}),!r&&s.map(o=>e.jsx("th",{className:x(V,"font-semibold text-xs text-text-muted uppercase tracking-label","group",{"text-left":o.align==="left"||!o.align,"text-center":o.align==="center","text-right":o.align==="right","cursor-pointer select-none":o.sortable,"sticky left-0 bg-surface":o.sticky==="left","sticky right-0 bg-surface":o.sticky==="right"}),style:{width:o.width},onClick:()=>o.sortable&&P(o.id),children:e.jsxs("div",{className:"flex items-center gap-2",children:[o.headerCell?o.headerCell():o.header,o.sortable&&e.jsxs("div",{className:x("flex flex-col opacity-0 group-hover:opacity-100 transition-opacity",$.column===o.id&&"opacity-100"),children:[e.jsx(ut,{active:$.column===o.id&&$.direction==="asc"}),e.jsx(xt,{active:$.column===o.id&&$.direction==="desc"})]})]})},o.id)),w.length>0&&e.jsx("th",{className:x(V,"w-20"),children:e.jsx("span",{className:"sr-only",children:"Actions"})})]})}),e.jsx("tbody",{children:C.length===0||r?!r&&e.jsx("tr",{children:e.jsx("td",{colSpan:s.length+(d?1:0)+(w.length>0?1:0),className:x(V,"text-center py-8 text-text-muted"),children:j||"No data available"})}):C.map((o,E)=>{const F=y(o,E),H=u.some((B,X)=>y(B,X)===F);return e.jsxs("tr",{className:x(re,{"bg-accent-soft":H},R?.(o,E)),onClick:B=>{B.stopPropagation(),m?.(o,E)},children:[d&&e.jsx("td",{className:V,children:e.jsx("input",{type:"checkbox",checked:H,onChange:B=>{B.stopPropagation(),M(o,B.target.checked)},className:"rounded border-border [&:not(:checked)]:bg-surface-input text-accent"})}),s.map(B=>{const X=typeof B.accessor=="function"?B.accessor(o):o[B.accessor];return e.jsx("td",{className:x(V,{"text-left":B.align==="left"||!B.align,"text-center":B.align==="center","text-right":B.align==="right","sticky left-0 bg-surface":B.sticky==="left","sticky right-0 bg-surface":B.sticky==="right"}),children:B.cell?B.cell(X,o,E):String(X||"")},B.id)}),w.length>0&&e.jsx("td",{className:V,children:e.jsx(Ce,{trigger:e.jsxs("div",{className:"inline-flex items-center gap-1 px-2 py-1 text-sm text-text-muted hover:text-text",children:[e.jsx("span",{children:"Options"}),e.jsx(Se,{})]}),options:w.map(B=>({value:B.id,label:B.label,icon:B.icon,disabled:B.disabled?.(o)})),onSelect:B=>{const X=w.find(xe=>xe.id===B);X&&X.onClick(o,E)},placement:"bottom-end"})})]},F)})})]})]}),c&&te>0&&e.jsxs("div",{className:"flex items-center justify-between px-6",children:[e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsxs("span",{className:"text-sm text-text-muted",children:["Showing ",A," to ",v," of ",te," results"]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-sm text-text-muted",children:"Rows per page:"}),e.jsx("select",{value:z.pageSize,onChange:o=>q(Number(o.target.value)),className:"h-control-sm w-16 rounded-md border border-border bg-surface-input px-2 text-sm text-text",children:b.map(o=>e.jsx("option",{value:o,children:o},o))})]})]}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(Z,{size:"sm",variant:"ghost",onClick:()=>S(0),disabled:z.page===0,iconOnly:!0,children:e.jsx(ht,{})}),e.jsx(Z,{size:"sm",variant:"ghost",onClick:()=>S(z.page-1),disabled:z.page===0,iconOnly:!0,children:e.jsx(ft,{})}),e.jsxs("span",{className:"px-3 py-1 text-sm text-text-muted",children:["Page ",z.page+1," of ",D]}),e.jsx(Z,{size:"sm",variant:"ghost",onClick:()=>S(z.page+1),disabled:z.page>=D-1,iconOnly:!0,children:e.jsx(mt,{})}),e.jsx(Z,{size:"sm",variant:"ghost",onClick:()=>S(D-1),disabled:z.page>=D-1,iconOnly:!0,children:e.jsx(bt,{})})]})]})]})},gt=i.createContext(null),vt=({items:t,activeTab:s,onTabChange:r,className:n})=>{const[a,l]=i.useState(t[0]?.id||""),c=s||a,b=g=>{r?r(g):l(g)};return e.jsx("div",{className:x("border-b border-border",n),children:e.jsx("nav",{className:"-mb-px flex space-x-8",children:t.map(g=>e.jsx("button",{onClick:()=>!g.disabled&&b(g.id),disabled:g.disabled,className:x("border-b-2 py-2 px-1 text-sm font-medium transition-colors duration-fast",{"border-accent-border text-text":c===g.id,"border-transparent text-text-muted hover:text-text":c!==g.id&&!g.disabled,"border-transparent text-disabled cursor-not-allowed":g.disabled}),children:e.jsxs("span",{className:"flex items-center gap-2",children:[g.label,g.badge&&e.jsx("span",{className:x("inline-flex items-center px-2 py-0.5 rounded-full text-xs font-medium",c===g.id?"bg-accent-soft text-accent":"bg-surface-hover text-text-muted"),children:g.badge})]})},g.id))})})},Ee=({items:t,defaultTab:s,activeTab:r,onTabChange:n,variant:a="default",size:l="md",className:c})=>{const[b,g]=i.useState(s||r||t[0]?.id||""),w=r||b,m=j=>{n?n(j):g(j)},d={activeTab:w,setActiveTab:m},u=t.find(j=>j.id===w),h=x("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"},c),y=(j,p)=>{const L="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"},K={"border-b-2 -mb-px":a==="default","rounded-md":a==="pills","border-b-2 pb-2":a==="underline"},R={"opacity-50 cursor-not-allowed":j.disabled,"cursor-pointer":!j.disabled},Y=p?{"border-accent-border text-text":a==="default"||a==="underline","bg-surface text-text shadow-none":a==="pills"}:{},U=!p&&!j.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 x(L,k,K,R,Y,U)};return e.jsx(gt.Provider,{value:d,children:e.jsxs("div",{children:[e.jsx("div",{className:h,role:"tablist",children:t.map(j=>e.jsx("button",{type:"button",role:"tab","aria-selected":w===j.id,"aria-controls":`tabpanel-${j.id}`,disabled:j.disabled,onClick:()=>!j.disabled&&m(j.id),className:y(j,w===j.id),children:e.jsxs("span",{className:"flex items-center gap-2",children:[j.label,j.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:j.badge})]})},j.id))}),u?.content&&e.jsx("div",{role:"tabpanel",id:`tabpanel-${w}`,"aria-labelledby":`tab-${w}`,className:"mt-4",children:u.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 Me({open:t,onClose:s,title:r,size:n="md",closeOnBackdropClick:a=!0,closeOnEscape:l=!0,className:c,backdropClassName:b,children:g,footer:w,showCloseButton:m=!0}){const d=i.useRef(null),u=i.useRef(null);i.useEffect(()=>{if(!t||!l)return;const y=j=>{j.key==="Escape"&&s()};return document.addEventListener("keydown",y),()=>document.removeEventListener("keydown",y)},[t,l,s]),i.useEffect(()=>(t?(u.current=document.activeElement,d.current&&d.current.focus(),document.body.style.overflow="hidden"):(u.current&&u.current.focus(),document.body.style.overflow=""),()=>{document.body.style.overflow=""}),[t]);const h=y=>{a&&y.target===y.currentTarget&&s()};return t?e.jsx("div",{className:x("fixed inset-0 z-modal flex items-center justify-center p-4","bg-scrim",b),onClick:h,children:e.jsxs("div",{ref:d,className:x("relative w-full bg-surface rounded-lg shadow-modal","focus:outline-none",jt[n],c),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("svg",{className:"h-6 w-6",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]}),e.jsx("div",{className:"p-6",children:g}),w&&e.jsx("div",{className:"px-6 py-4",children:w})]})}):null}const yt={xs:"text-xs",sm:"text-sm",md:"text-base",lg:"text-md",xl:"text-lg"},Nt={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"},kt={left:"text-left",center:"text-center",right:"text-right",justify:"text-justify"},Ct={tight:"leading-tight",normal:"leading-normal",relaxed:"leading-relaxed"},se=({variant:t="body",size:s="md",weight:r="normal",color:n="current",align:a="left",truncate:l=!1,italic:c=!1,underline:b=!1,lineHeight:g="normal",as:w,className:m,children:d,...u})=>{const h=w||St(t),y=t==="caption",j=t==="label",p=t==="code",L=x("font-sans",y&&"text-xs text-text-subtle",j&&"text-xs font-semibold uppercase tracking-label text-text-subtle",p&&"font-mono text-sm rounded-sm bg-surface-hover px-1 py-0.5",!y&&!j&&!p&&yt[s],!j&&Nt[r],wt[n],kt[a],t==="body"&&Ct[g],c&&"italic",b&&"underline",l&&"truncate",m);return e.jsx(h,{className:L,...u,children:d})};function St(t){return{body:"p",caption:"span",label:"span",code:"code"}[t]||"p"}const Le=({value:t,onChange:s,label:r,placeholder:n="Select or upload a file",error:a,disabled:l,accept:c,onListFiles:b,onListMounts:g,onUploadFile:w,onDownloadFile:m,onRegisterFile:d})=>{const[u,h]=i.useState(!1),[y,j]=i.useState([]),[p,L]=i.useState(null),[k,K]=i.useState("/"),[R,Y]=i.useState([]),[U,$]=i.useState(!1),[G,z]=i.useState(""),[W,_]=i.useState(typeof t=="object"?t:null),[N,f]=i.useState(!1),[C,P]=i.useState(""),S=i.useRef(null);i.useEffect(()=>{u&&q()},[u]),i.useEffect(()=>{u&&p&&M()},[u,p,k,G]);const q=async()=>{$(!0);try{const o=await g?.();o?.data&&j(o.data)}catch(o){console.error("Failed to load mounts",o)}finally{$(!1)}},M=async()=>{if(p){$(!0);try{const o=await b?.({mountId:p.id,name:G,path:k});o?.data&&Y(o.data)}catch(o){console.error("Failed to load files",o)}finally{$(!1)}}},ee=async o=>{const E=o.target.files?.[0];if(E){$(!0);try{const F=await E.arrayBuffer(),H=new Uint8Array(F),B={id:`local-${Date.now()}`,name:E.name,type:"file",path:"/",mimeType:E.type||"application/octet-stream",size:E.size,mountId:"local",providerKey:E.name,ownerId:"me"};_(B),s(B,H),h(!1)}catch(F){console.error("Local file selection failed",F)}finally{$(!1)}}},te=async o=>{const E=o.target.files?.[0];if(!(!E||!p)){$(!0);try{const F=await E.arrayBuffer(),H=await w?.({file:new Uint8Array(F),filename:E.name,mimeType:E.type||"application/octet-stream",mountId:p.id,path:k});if(H?.data){const B=H.data;_(B),s(B,new Uint8Array(F)),h(!1)}}catch(F){console.error("Upload failed",F)}finally{$(!1)}}},D=async()=>{if(!(!C||!p)){$(!0);try{const o=`${k}${C}/`;d&&(await d({name:C,type:"folder",path:k,mimeType:"application/x-directory",size:0,mountId:p.id,providerKey:o,ownerId:"me"}),await M()),f(!1),P("")}catch(o){console.error("Failed to create folder",o)}finally{$(!1)}}},A=async o=>{$(!0);try{const E=await m?.(o.id);_(o),s(o,E),h(!1)}catch(E){console.error("Failed to download file",E)}finally{$(!1)}},v=o=>{o.stopPropagation(),_(null),s(null)},T=i.useMemo(()=>{const o=new Set,E=[];return R.forEach(F=>{if(F.type==="folder"){F.path===k&&o.add(F.name);return}const H=F.providerKey||F.name,X=(k?H.substring(k.length):H).split("/").filter(xe=>xe!=="");X.length>1?o.add(X[0]):X.length===1&&E.push(F)}),{folders:Array.from(o).sort(),files:E.sort((F,H)=>F.name.localeCompare(H.name))}},[R,k]),I=o=>{K(E=>`${E}${o}/`)},O=()=>{const o=k.split("/").filter(E=>E!=="");o.pop(),o.length===0?K("/"):K(`${o.join("/")}/`)},Q=i.useMemo(()=>{const o=T.folders.map(E=>({id:`folder-${E}`,name:E,type:"folder"}));return T.files.forEach(E=>{o.push({...E,type:"file"})}),o},[T]),V=[{id:"name",header:"Name",accessor:"name",cell:(o,E)=>e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(ne,{icon:E.type==="folder"?J.Folder:J.FileText,size:"sm",color:E.type==="folder"?"warning":"secondary"}),e.jsx("span",{className:x(E.type==="folder"&&"font-medium"),children:o})]})},{id:"type",header:"Type",accessor:o=>o.type==="folder"?"Folder":o.mimeType},{id:"size",header:"Size",accessor:o=>o.type==="file"?`${(o.size/1024).toFixed(1)} KB`:"-"},{id:"actions",header:"",accessor:"id",align:"right",cell:(o,E)=>e.jsx(Z,{size:"sm",variant:"outline",onClick:F=>{F.stopPropagation(),E.type==="folder"?I(E.name):A(E)},loading:U&&E.type==="file"&&W?.id===E.id,children:E.type==="folder"?"Open":"Select"})}],re=[{id:"name",header:"Mount Name",accessor:"name",cell:o=>e.jsxs("div",{className:"flex items-center gap-2 font-medium",children:[e.jsx(ne,{icon:J.HardDrive,size:"sm",color:"primary"}),e.jsx("span",{children:o})]})},{id:"actions",header:"",accessor:"id",align:"right",cell:(o,E)=>e.jsx(Z,{size:"sm",variant:"outline",onClick:()=>L(E),children:"Open"})}];return e.jsxs("div",{className:"space-y-1",children:[r&&e.jsx(se,{variant:"label",size:"sm",weight:"medium",children:r}),e.jsxs("div",{onClick:()=>!l&&h(!0),className:x("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(ne,{icon:W?J.FileText:J.HardDrive,color:W?"primary":"secondary"})}),e.jsx("div",{className:"flex-grow truncate",children:W?e.jsx("span",{className:"text-sm text-text font-medium",children:W.name}):e.jsx("span",{className:"text-sm text-text-muted",children:n})}),W&&!l&&e.jsx("button",{onClick:v,className:"p-1 hover:bg-surface-hover rounded",children:e.jsx(ne,{icon:J.X,size:"xs"})})]}),a&&e.jsx(se,{variant:"body",size:"xs",className:"text-danger-fg",children:a}),e.jsx(Me,{open:u,onClose:()=>{h(!1),L(null),K("/"),f(!1)},title:p?`Explorer: ${p.name}`:"Select Storage Mount",size:"lg",children:e.jsx(Ee,{variant:"pills",items:[{id:"remote",label:"Platform Storage",content:e.jsx("div",{className:"space-y-4",children:p?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx(Z,{variant:"ghost",size:"sm",onClick:()=>{k&&k!=="/"?O():L(null)},leftIcon:e.jsx(ne,{icon:J.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(ae,{placeholder:"Search...",value:G,onChange:o=>z(o.target.value),startIcon:e.jsx(J.Search,{size:14}),fullWidth:!0,size:"sm"})}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(Z,{variant:"outline",size:"sm",onClick:()=>f(!0),leftIcon:e.jsx(ne,{icon:J.FolderPlus,size:"xs"}),children:"New Folder"}),e.jsx(Z,{variant:"primary",size:"sm",onClick:()=>S.current?.click(),leftIcon:e.jsx(ne,{icon:J.Upload,size:"xs"}),loading:U,children:"Upload"}),e.jsx("input",{type:"file",className:"hidden",ref:S,onChange:te,accept:c})]})]}),N&&e.jsxs("div",{className:"flex items-center gap-2 p-3 bg-surface-sunk rounded-lg border border-border",children:[e.jsx(ne,{icon:J.Folder,size:"sm",color:"warning"}),e.jsx(ae,{size:"sm",placeholder:"Folder name",value:C,onChange:o=>P(o.target.value),autoFocus:!0}),e.jsx(Z,{size:"sm",onClick:D,loading:U,children:"Create"}),e.jsx(Z,{size:"sm",variant:"ghost",onClick:()=>f(!1),children:"Cancel"})]}),e.jsx("div",{className:"max-h-100 overflow-auto rounded-lg border border-border",children:e.jsx(me,{data:Q,columns:V,loading:U,emptyContent:"This folder is empty",onRowClick:o=>o.type==="folder"?I(o.name):A(o)})})]}):e.jsx("div",{className:"max-h-100 overflow-auto rounded-lg border border-border",children:e.jsx(me,{data:y,columns:re,loading:U,emptyContent:"No storage mounts configured",onRowClick:o=>L(o)})})})},{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(ne,{icon:J.FileText,size:"xl",color:"primary"})}),e.jsx(se,{variant:"label",size:"lg",weight:"semibold",children:"Select a file from your computer"}),e.jsxs(se,{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(Z,{variant:"primary",size:"lg",loading:U,className:"pointer-events-none",children:"Browse Local File"}),e.jsx("input",{type:"file",className:"hidden",onChange:ee,accept:c,disabled:U})]})]})})}]})})]})},Et={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"},ue=i.forwardRef(({label:t,helperText:s,error:r,size:n="md",fullWidth:a=!1,loading:l=!1,containerClassName:c,labelClassName:b,className:g,id:w,rows:m=4,...d},u)=>{const h=i.useId(),y=w||`textarea-${h}`,j=!!r,p=r||s?`${y}-description`:void 0;return e.jsxs("div",{className:x("flex flex-col",a&&"w-full",c),children:[t&&e.jsx("label",{htmlFor:y,className:x(ye,j?"text-danger-fg":"text-text-subtle",b),children:t}),e.jsxs("div",{className:"relative",children:[e.jsx("textarea",{ref:u,id:y,rows:m,"aria-invalid":j||void 0,"aria-describedby":p,className:x("block w-full resize-y rounded-md 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",Et[n],j?"border-danger-border bg-danger-soft":"border-border hover:border-border-strong",g),...d}),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:p,className:x("mt-1 text-xs",j?"text-danger-fg":"text-text-subtle"),children:r||s})]})});ue.displayName="TextArea";function pe(t,s){return s.split(".").reduce((r,n)=>r&&typeof r=="object"&&n in r?r[n]:void 0,t)}function Mt(t,s,r){const n=s.split("."),a=Array.isArray(t)?[...t]:{...t};let l=a;for(let c=0;c<n.length-1;c++){const b=n[c],g=l[b];l[b]=g&&typeof g=="object"?Array.isArray(g)?[...g]:{...g}:{},l=l[b]}return l[n[n.length-1]]=r,a}function Lt(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 c=r[l];if(!a[c]||typeof a[c]!="object")return n;a[c]=Array.isArray(a[c])?[...a[c]]:{...a[c]},a=a[c]}return delete a[r[r.length-1]],n}const zt=({groups:t,data:s,onSubmit:r,onCancel:n,onChange:a,transform:l,validate:c,submitButton:b={label:"Submit",variant:"primary"},cancelButton:g={label:"Cancel",variant:"outline"},showButtons:w=!0,layout:m="vertical",size:d="md",loading:u=!1,className:h,ref:y,sdk:j})=>{const[p,L]=i.useState(s||{}),[k,K]=i.useState({}),[R,Y]=i.useState({});i.useEffect(()=>{s&&L({...s})},[s]);const U=i.useCallback((f,C,P)=>{const S=t.flatMap(q=>q.items).find(q=>q.name===f);if(!S)return null;if(S.required&&(C==null||C===""))return`${S.label} is required`;if(S.type==="array"){if(S.required&&(!C||C.length===0))return`${S.label} cannot be empty.`;if(C&&!Array.isArray(C))return`${S.label} must be an array.`;if(Array.isArray(C)&&S.arrayFields){const q=[];let M=!1;if(C.forEach((ee,te)=>{const D={};for(const A of S.arrayFields){const v=ee?.[A.name];if(A.required&&(v==null||v===""))D[A.name]=`${A.label} is required`,M=!0;else if(A.validator){const T=A.validator(v,ee);T&&(D[A.name]=T,M=!0)}}q[te]=D}),M)return JSON.stringify(q)}}return S.validator?S.validator(C,P):null},[t]),$=i.useCallback((f,C)=>{let P=Mt(p,f,C);t.flatMap(M=>M.items).find(M=>M.name===f)?.removeIfEmpty&&(C==null||C==="")&&(P=Lt(P,f)),L(P),Y(M=>({...M,[f]:!0}));const q=U(f,C,P);K(M=>({...M,[f]:q||""})),a?.(P,f)},[p,t,U,a]),G=i.useCallback(async f=>{if(f.preventDefault(),u)return;const C={},P=t.flatMap(q=>q.items);for(const q of P){if(q.hidden||q.conditional&&!q.conditional(p))continue;const M=U(q.name,pe(p,q.name),p);M&&(C[q.name]=M)}if(c){const q=c(p);q&&Object.assign(C,q)}if(K(C),Object.keys(C).some(q=>C[q]))return;const S=l?l(p):p;await r?.(p,S)},[p,t,U,c,l,r,u]),z=i.useCallback(f=>{const C=pe(p,f.name),P=R[f.name]?k[f.name]:void 0,S=f.disabled||u,q={value:C||"",disabled:S,required:f.required,placeholder:f.placeholder,...f.fieldProps};switch(f.type){case"text":case"email":case"password":case"number":case"tel":case"url":return e.jsx(ae,{...q,onChange:M=>$(f.name,M.target.value),type:f.textType||f.type,autoComplete:f.autocomplete,error:P,size:d});case"textarea":return e.jsx(ue,{...q,onChange:M=>$(f.name,M.target.value),rows:4,error:P,size:d});case"select":return e.jsx(ce,{...q,onChange:M=>$(f.name,M),options:(f.options||[]).map(M=>({...M,value:String(M.value)})),searchable:f.searchable,multiple:f.multiple,allowCreate:f.allowCreate,error:P,size:d});case"checkbox":return e.jsx(oe,{...q,checked:!!C,onChange:M=>$(f.name,M.target.checked),size:d});case"radio":return e.jsx("div",{className:"flex flex-col gap-2",children:f.options?.map(M=>e.jsxs("label",{className:"flex cursor-pointer items-center gap-2 text-base text-text",children:[e.jsx("input",{type:"radio",name:f.name,value:M.value,checked:C===M.value,onChange:()=>$(f.name,M.value),disabled:S||M.disabled,className:"size-checkbox shrink-0 border border-border-strong bg-surface-input accent-accent focus-visible:outline-none focus-visible:focus-ring"}),M.label]},M.value))});case"date":return e.jsx(de,{...q,value:C?new Date(C):null,onChange:M=>$(f.name,M),size:d});case"file":return e.jsx(Le,{...q,value:C,onChange:M=>$(f.name,M),error:P,onListFiles:M=>j?.http.invoke({method:"POST",action:"storage.file.list",body:M}),onListMounts:()=>j?.http.invoke({method:"GET",action:"storage.mount"}),onUploadFile:M=>j?.http.invoke({method:"POST",action:"storage.file.upload",body:M}),onDownloadFile:M=>j?.http.invoke({method:"GET",action:`storage.file.${M}.download`}),onRegisterFile:M=>j?.http.invoke({method:"POST",action:"storage.file.folder",body:M})});case"folder":return e.jsx(Ne,{value:C||{},onChange:M=>$(f.name,M),onListFolders:()=>j?.http.invoke({method:"GET",action:"storage.mount"}),disabled:S,size:d,placeholder:f.placeholder});case"custom":return f.customComponent?.({value:C,onChange:M=>$(f.name,M),error:P,disabled:S});case"array":{const M=C||[];let ee=[];if(typeof P=="string"&&P.startsWith("["))try{ee=JSON.parse(P)}catch{}const te=()=>{$(f.name,[...M,{}])},D=v=>{$(f.name,M.filter((T,I)=>I!==v))},A=(v,T,I)=>{const O=[...M];O[v]={...O[v],[T]:I},$(f.name,O)};return e.jsxs("div",{className:"flex flex-col gap-2",children:[M.map((v,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:f.arrayFields?.map(I=>{const O=ee?.[T]?.[I.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:[I.label,I.required&&e.jsx("span",{className:"ml-1 text-danger-fg",children:"*"})]}),(()=>{const Q={value:v?.[I.name]||"",disabled:S,required:I.required,placeholder:I.placeholder,...I.fieldProps};switch(I.type){case"text":case"email":case"password":case"number":case"tel":case"url":return e.jsx(ae,{...Q,onChange:V=>A(T,I.name,V.target.value),type:I.textType||I.type,autoComplete:I.autocomplete,error:O,size:d});case"textarea":return e.jsx(ue,{...Q,onChange:V=>A(T,I.name,V.target.value),rows:4,error:O,size:d});case"select":return e.jsx(ce,{...Q,onChange:V=>A(T,I.name,V),options:(I.options||[]).map(V=>({...V,value:String(V.value)})),searchable:I.searchable,multiple:I.multiple,allowCreate:I.allowCreate,error:O,size:d});case"checkbox":return e.jsx(oe,{...Q,checked:!!v?.[I.name],onChange:V=>A(T,I.name,V.target.checked),size:d});case"radio":return e.jsx("div",{className:"flex flex-col gap-2",children:I.options?.map(V=>e.jsxs("label",{className:"flex cursor-pointer items-center gap-2 text-base text-text",children:[e.jsx("input",{type:"radio",name:`${f.name}.${T}.${I.name}`,value:V.value,checked:v?.[I.name]===V.value,onChange:()=>A(T,I.name,V.value),disabled:S||V.disabled,className:"size-checkbox shrink-0 border border-border-strong bg-surface-input accent-accent focus-visible:outline-none focus-visible:focus-ring"}),V.label]},V.value))});case"date":{const V=v?.[I.name];return e.jsx(de,{...Q,value:V?new Date(V):null,onChange:re=>A(T,I.name,re),size:d})}case"custom":return I.customComponent?.({value:v?.[I.name],onChange:V=>A(T,I.name,V),error:O,disabled:S});default:return e.jsxs("p",{children:["Unsupported field type in array:"," ",I.type]})}})(),O&&e.jsx("p",{className:"text-xs text-danger-fg",children:O})]},I.name)})}),e.jsx(Z,{type:"button",iconOnly:!0,variant:"ghost",size:"md","aria-label":`${f.label} verwijderen`,onClick:()=>D(T),disabled:S,className:x("shrink-0",T===0&&"mt-5"),children:e.jsx(J.Trash2,{className:"size-icon-md"})})]},T)),e.jsxs(Z,{type:"button",variant:"secondary",size:"sm",leftIcon:e.jsx(J.Plus,{className:"size-icon-sm"}),onClick:te,disabled:S,children:[f.label," toevoegen"]})]})}default:return null}},[p,R,k,u,d,$]),W=i.useCallback(f=>{if(f.conditional&&!f.conditional(p))return null;const C=f.items.filter(S=>!(S.hidden||S.conditional&&!S.conditional(p)));if(C.length===0)return null;const P=x(f.layout==="flex"?"flex flex-wrap gap-3":"grid gap-3",f.layout!=="flex"&&{"grid-cols-1":!f.columns||f.columns===1,"grid-cols-2":f.columns===2,"grid-cols-3":f.columns===3,"grid-cols-4":f.columns===4},f.className);return e.jsxs("div",{className:"flex flex-col gap-4 px-5 py-4 not-first:border-t not-first:border-border-subtle sm:flex-row sm:gap-5",children:[e.jsxs("div",{className:"w-full shrink-0 sm:w-form-label",children:[e.jsx("span",{className:"text-sm font-semibold text-text",children:f.title}),f.description&&e.jsx("p",{className:"mt-1 text-xs leading-4 text-text-subtle",children:f.description})]}),e.jsx("div",{className:"min-w-0 flex-1",children:e.jsx("div",{className:P,children:C.map(S=>(R[S.name]&&k[S.name],e.jsxs("div",{className:x("flex min-w-0 flex-col gap-1.5",S.type==="checkbox"&&"justify-center"),style:{width:typeof S.width=="string"?S.width:void 0,gridColumn:typeof S.width=="number"?`span ${S.width} / span ${S.width}`:void 0},children:[S.type!=="custom"&&S.type!=="checkbox"&&e.jsxs("label",{className:"block text-xs font-semibold uppercase tracking-label text-text-subtle",children:[S.label,S.required&&e.jsx("span",{className:"ml-1 text-danger-fg",children:"*"})]}),z(S)]},S.name)))})})]},f.id)},[p,R,k,z]),_=x("overflow-hidden rounded-lg border border-border bg-surface",{"max-w-md":d==="sm","max-w-2xl":d==="md","max-w-4xl":d==="lg","max-w-full":d==="full"},h),N=d==="full"?"md":d;return e.jsxs("form",{ref:y,onSubmit:G,className:_,children:[e.jsx("div",{className:"flex flex-col",children:t.map(W)}),e.jsx("div",{className:"flex items-center gap-2 border-t border-border-subtle bg-surface-sunk px-5 py-3",children:w&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"ml-auto"}),n&&e.jsx(Z,{type:"button",variant:g.variant??"ghost",size:g.size||N,disabled:g.disabled||u,onClick:n,className:g.className,children:g.label}),e.jsx(Z,{type:"submit",variant:b.variant,size:b.size||N,disabled:b.disabled||u,loading:u,className:b.className,children:b.label})]})})]})},Tt={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"},$t={sm:"px-2 py-0.5 text-xs",md:"px-2.5 py-1 text-sm",lg:"px-3 py-1.5 text-base"},Dt={default:"bg-surface-hover",primary:"bg-accent",secondary:"bg-surface-hover",success:"bg-success",warning:"bg-warning",error:"bg-danger",info:"bg-info"};function At({variant:t="default",size:s="md",dot:r=!1,icon:n,dismissible:a=!1,onDismiss:l,className:c,children:b,...g}){return e.jsxs("span",{className:x("inline-flex items-center font-medium rounded-full",Tt[t],$t[s],c),...g,children:[r&&e.jsx("span",{className:x("w-2 h-2 rounded-full mr-1.5",Dt[t])}),n&&e.jsx("span",{className:x("flex-shrink-0",b&&"mr-1"),children:n}),b,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("svg",{className:"h-3 w-3",fill:"currentColor",viewBox:"0 0 20 20",children:e.jsx("path",{fillRule:"evenodd",d:"M4.293 4.293a1 1 0 011.414 0L10 8.586l4.293-4.293a1 1 0 111.414 1.414L11.414 10l4.293 4.293a1 1 0 01-1.414 1.414L10 11.414l-4.293 4.293a1 1 0 01-1.414-1.414L8.586 10 4.293 5.707a1 1 0 010-1.414z",clipRule:"evenodd"})})})]})}const Pt={neutral:"bg-surface-hover text-text-muted",success:"bg-success-soft text-success-fg"};function Bt({icon:t,tone:s="neutral",title:r,description:n,actions:a,card:l=!1,className:c,...b}){return e.jsxs("div",{className:x("flex flex-col items-center gap-2.5 text-center",l&&"rounded-lg border border-border bg-surface px-11 py-9 shadow-overlay",c),...b,children:[t!=null&&e.jsx("span",{className:x("flex size-disc items-center justify-center rounded-full text-2xl",Pt[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 It({children:t,className:s,...r}){return e.jsx("kbd",{className:x("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 Rt={sm:"h-1",md:"h-1.5"},Ft={accent:"bg-accent",success:"bg-success"};function Ot({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:x("w-full overflow-hidden rounded-full bg-surface-hover",Rt[r],n),...a,children:e.jsx("div",{className:x("h-full rounded-full transition-[width] duration-300 ease-out",Ft[s]),style:{width:`${l}%`}})})}const Vt={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"},Wt={primary:"text-accent",secondary:"text-text-muted",white:"text-white",current:"text-current"},qt={xs:"text-xs",sm:"text-sm",md:"text-sm",lg:"text-base",xl:"text-lg"};function Ht({size:t="md",variant:s="primary",label:r="Loading...",showLabel:n=!1,className:a,...l}){return e.jsxs("div",{className:x("inline-flex items-center",n?"flex-col space-y-2":"",a),...l,children:[e.jsxs("svg",{className:x("animate-spin",Vt[t],Wt[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:x("text-text-muted",qt[t]),children:r}),!n&&e.jsx("span",{className:"sr-only",children:r})]})}function Ut({title:t,icon:s=e.jsx(J.Sparkles,{className:"size-icon-md","aria-hidden":!0}),action:r,children:n,className:a,...l}){return e.jsxs("div",{className:x("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 _t={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 Kt(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 ze=({name:t,src:s,size:r="sm",className:n,title:a})=>{const[l,c]=i.useState(!1),b=x("inline-flex items-center justify-center rounded-full overflow-hidden shrink-0 font-semibold select-none bg-surface-hover-border-emphasis text-text",_t[r],n);return s&&!l?e.jsx("img",{src:s,alt:t??"",title:a??t,className:x(b,"object-cover"),onError:()=>c(!0)}):e.jsx("span",{className:b,title:a??t,"aria-label":t,children:Kt(t)})},ge="ring-surface",Gt="ring-surface-accent",Jt=({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:x("inline-flex items-center",n),children:[a.map((c,b)=>e.jsx(ze,{name:c.name,src:c.src,size:r,title:c.name?c.seen===!1?`${c.name} — nog niet gelezen`:c.name:void 0,className:x(b>0&&"-ml-2",c.owner?Gt:ge,c.seen===!1&&"opacity-40")},c.id??`${c.name}-${b}`)),l>0&&e.jsxs("span",{className:x("inline-flex items-center justify-center rounded-full shrink-0 -ml-2 font-semibold bg-surface-hover text-text-muted",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",ge),children:["+",l]})]})},ve={mail:{fg:"text-ch-mail",bg:"bg-ch-mail"},wa:{fg:"text-ch-wa",bg:"bg-ch-wa"},chat:{fg:"text-ch-chat",bg:"bg-ch-chat"},tel:{fg:"text-ch-tel",bg:"bg-ch-tel"},note:{fg:"text-ch-note",bg:"bg-ch-note"}},Yt={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 Xt({channel:t,children:s,size:r="md",className:n,title:a}){const l=ve[t in ve?t:"note"];return e.jsx("span",{title:a,className:x("inline-flex shrink-0 items-center justify-center font-bold",Yt[r],l.fg,l.bg,n),children:s})}const Zt=({src:t,alt:s,size:r="md",aspectRatio:n="auto",radius:a="md",showLoading:l=!0,showError:c=!0,fallback:b,loadingContent:g,errorContent:w,className:m,onLoad:d,onError:u,...h})=>{const[y,j]=i.useState(!0),[p,L]=i.useState(!1),[k,K]=i.useState(t),R=_=>{j(!1),L(!1),d?.(_)},Y=_=>{if(j(!1),L(!0),b&&k!==b){K(b),L(!1),j(!0);return}u?.(_)},U=x("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),$=x("w-full h-full object-cover transition-opacity duration-fast",{"opacity-0":y||p,"opacity-100":!y&&!p}),G=x("absolute inset-0 flex items-center justify-center","text-text-muted"),z=e.jsx("div",{className:"animate-pulse",children:e.jsx("div",{className:"w-6 h-6 bg-surface-hover rounded"})}),W=e.jsxs("div",{className:"text-center",children:[e.jsx("svg",{className:"w-6 h-6 mx-auto mb-1",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M4 16l4.586-4.586a2 2 0 012.828 0L16 16m-2-2l1.586-1.586a2 2 0 012.828 0L20 14m-6-6h.01M6 20h12a2 2 0 002-2V6a2 2 0 00-2-2H6a2 2 0 00-2 2v12a2 2 0 002 2z"})}),e.jsx("span",{className:"text-xs",children:"Failed to load"})]});return e.jsxs("div",{className:U,children:[e.jsx("img",{...h,src:k,alt:s,className:$,onLoad:R,onError:Y}),y&&l&&e.jsx("div",{className:G,children:g||z}),p&&c&&e.jsx("div",{className:G,children:w||W})]})};function Qt({items:t,getRowKey:s,variant:r="divided",leading:n,renderItem:a,trailing:l,onSelect:c,isActive:b,unread:g,dimmed:w,groupBy:m,groups:d,renderGroupHeader:u,stickyGroupHeaders:h=!1,collapsibleGroups:y=!1,hideGroupCount:j=!1,selectable:p=!1,selectedItems:L=[],onSelectionChange:k,bulkActions:K,header:R,stickyHeader:Y=!1,bordered:U=!1,emptyContent:$,loading:G=!1,loadingRows:z=4,className:W,"aria-label":_}){const[N,f]=i.useState(()=>Object.fromEntries((d??[]).filter(v=>v.defaultCollapsed).map(v=>[v.id,!0]))),C=(v,T)=>s?s(v,T):T,P=v=>L.includes(v),S=(v,T)=>{k&&k(T?[...L,v]:L.filter(I=>I!==v))},q=v=>k?.(v?[...t]:[]),M=x("flex flex-col",U&&"overflow-hidden rounded-lg border border-border-subtle",W);if(G)return e.jsx("div",{className:M,children:Array.from({length:z}).map((v,T)=>e.jsxs("div",{className:x("flex animate-pulse items-center gap-3 px-4 py-2.5",r==="divided"&&T>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-${T}`))});if(t.length===0&&$)return e.jsx("div",{className:M,children:$});const ee=t.length>0&&L.length===t.length,te=L.length>0&&!ee,D=(v,T,I)=>{const O=b?.(v,T)??!1,Q=g?.(v,T)??!1,V=w?.(v,T)??!1,re=p&&P(v);return e.jsxs("li",{onClick:c?()=>c(v,T):void 0,className:x("flex items-center gap-3 px-4 py-2.5 text-base","transition-colors duration-fast ease-out",r==="divided"&&!I&&"border-t border-border-subtle",c&&"cursor-pointer",O||re?"bg-accent-soft text-text":c&&"hover:bg-surface-hover",Q&&"font-bold",V&&"opacity-55"),children:[p&&e.jsx("span",{onClick:o=>o.stopPropagation(),children:e.jsx(oe,{checked:P(v),onChange:o=>S(v,o.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(v,T)}),e.jsx("div",{className:"flex min-w-0 flex-1 items-center gap-2",children:a?a(v,T):String(v)}),l&&e.jsx("span",{className:"shrink-0 text-xs text-text-subtle",children:l(v,T)})]},C(v,T))},A=(()=>{if(!m)return t.map((O,Q)=>D(O,Q,Q===0));const v=new Map;t.forEach((O,Q)=>{const V=m(O,Q);v.has(V)||v.set(V,[]),v.get(V).push({item:O,index:Q})});const T=d??[];return[...T.filter(O=>v.has(O.id)),...[...v.keys()].filter(O=>!T.some(Q=>Q.id===O)).map(O=>({id:O}))].flatMap((O,Q)=>{const V=v.get(O.id)??[],re=y&&N[O.id],o=O.title??O.id,E=O.count??V.length,F=e.jsx("li",{onClick:y?()=>f(H=>({...H,[O.id]:!H[O.id]})):void 0,className:x("flex items-center gap-2 bg-surface-sunk px-4 py-1.5","text-xs font-semibold uppercase tracking-label text-text-subtle","border-border-subtle",Q>0&&"border-t","border-b",h&&"sticky z-10",y&&"cursor-pointer select-none hover:text-text"),"aria-expanded":y?!re:void 0,style:h?{top:Y?28:0}:void 0,children:u?u(O,V.map(H=>H.item)):e.jsxs(e.Fragment,{children:[y&&e.jsx(J.ChevronRight,{"aria-hidden":!0,className:x("size-icon-sm shrink-0 transition-transform duration-fast ease-out",!re&&"rotate-90")}),e.jsx("span",{children:o}),!j&&e.jsx("span",{className:"ml-auto font-normal tabular-nums",children:E})]})},`group-${O.id}`);return re?[F]:[F,...V.map(({item:H,index:B},X)=>D(H,B,X===0))]})})();return e.jsxs("div",{className:M,children:[p&&L.length>0&&e.jsxs("div",{className:"flex items-center gap-3 border-b border-border-subtle bg-surface-sunk px-4 py-2",children:[e.jsx(oe,{checked:ee,indeterminate:te,onChange:v=>q(v.target.checked),"aria-label":"Alles selecteren"}),e.jsxs("span",{className:"text-xs text-text-subtle",children:[L.length," geselecteerd"]}),K&&e.jsx("div",{className:"ml-auto flex gap-2",children:K})]}),R&&e.jsx("div",{className:x("flex items-center gap-3 border-b border-border-subtle px-4 py-1.5","text-xs font-semibold uppercase tracking-label text-text-subtle",Y&&"sticky top-0 z-20"),children:R}),e.jsx("ul",{"aria-label":_,className:"flex flex-col",children:A})]})}const es={default:"text-text",urgent:"text-danger-fg",success:"text-success-fg"},ts={default:"border-border",urgent:"border-danger-border",success:"border-border"};function ss({value:t,label:s,tone:r="default",className:n,...a}){return e.jsxs("div",{className:x("rounded-xl border bg-surface px-4 py-3.5",ts[r],n),...a,children:[e.jsx("div",{className:x("text-2xl font-semibold",es[r]),children:t}),e.jsx("div",{className:"pt-0.5 text-xs text-text-muted",children:s})]})}const rs=({title:t,subtitle:s,actions:r=[],children:n,className:a,backLabel:l="Back",backClassName:c,onBack:b,editable:g=!1,onTitleChange:w})=>{const[m,d]=i.useState(!1),[u,h]=i.useState(t),y=i.useRef(null);i.useEffect(()=>{h(t)},[t]),i.useEffect(()=>{m&&y.current&&(y.current.focus(),y.current.select())},[m]);const j=()=>{g&&d(!0)},p=()=>{d(!1),u.trim()!==""&&u!==t&&w?w(u.trim()):h(t)},L=k=>{k.key==="Enter"?y.current?.blur():k.key==="Escape"&&(h(t),d(!1))};return e.jsxs("div",{className:x("p-5 pb-3",a),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-center gap-2 text-text",children:[b&&e.jsx("button",{type:"button",onClick:b,className:x("flex items-center text-sm cursor-pointer transition",c),children:e.jsx(J.ArrowLeft,{size:16,color:"currentColor"})}),m?e.jsx("input",{ref:y,type:"text",value:u,onChange:k=>h(k.target.value),onBlur:p,onKeyDown:L,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 flex-1"}):e.jsxs("div",{className:"group flex items-baseline gap-2.5 min-w-0",children:[e.jsx("h2",{onClick:j,className:x("text-2xl font-semibold truncate",g&&"cursor-pointer"),title:g?"Klik om te bewerken":void 0,children:t}),s&&e.jsx("span",{className:"shrink-0 text-base text-text-muted truncate",children:s}),g&&e.jsx(J.Pencil,{size:15,onClick:j,className:"shrink-0 cursor-pointer text-text-muted opacity-0 group-hover:opacity-100 transition-opacity"})]})]})}),r.length>0&&e.jsx("div",{className:"flex flex-wrap sm:flex-nowrap gap-2 sm:gap-3",children:r.map(k=>k.splitOptions&&k.splitOptions.length>0?e.jsx(he,{label:k.label,onClick:k.onClick,icon:k.icon,variant:k.variant==="primary"?"primary":"secondary",options:k.splitOptions,disabled:k.disabled},k.id):e.jsx(Z,{variant:k.variant??"secondary",onClick:K=>{K.stopPropagation(),K.target.blur(),k.onClick()},disabled:k.disabled,leftIcon:k.icon,children:k.label},k.id))})]}),n&&e.jsx("div",{className:"mt-4",children:n})]})},ns=({actions:t=[],onBack:s,backLabel:r="Back",className:n,children:a})=>e.jsxs("div",{className:x("flex items-center gap-2 mb-3",n),children:[s&&e.jsx(Z,{variant:"ghost",size:"sm",onClick:s,leftIcon:e.jsx(J.ArrowLeft,{size:14}),children:r}),a&&e.jsx("div",{className:"flex-1 min-w-0",children:a}),t.length>0&&e.jsx("div",{className:x("flex flex-wrap gap-2",!a&&"ml-auto"),children:t.map(l=>l.splitOptions&&l.splitOptions.length>0?e.jsx(he,{label:l.label,onClick:l.onClick,icon:l.icon,variant:l.variant==="primary"?"primary":"secondary",options:l.splitOptions,disabled:l.disabled},l.id):e.jsx(Z,{variant:l.variant??"secondary",size:"sm",onClick:c=>{c.stopPropagation(),c.target.blur(),l.onClick()},disabled:l.disabled,leftIcon:l.icon,children:l.label},l.id))})]});function as({label:t,dotColor:s,onClick:r,className:n}){return e.jsxs("button",{type:"button",onClick:r,className:x("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("span",{"aria-hidden":!0,className:"shrink-0 opacity-70",children:"↗"})]})}function ls(t,s){return s.split(".").reduce((r,n)=>r&&typeof r=="object"&&n in r?r[n]:void 0,t)}const os=({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",c=(m,d)=>{if(!d)return String(m||"-");const u=d.find(h=>h.value===m);return u?u.label:String(m||"-")},b=i.useCallback(m=>{const d=ls(s,m.name);if(m.type==="array"){const h=d;return!h||h.length===0?e.jsx(se,{variant:"body",size:"sm",className:"text-text-muted",children:"Geen items"}):e.jsx("div",{className:"space-y-3",children:h.map((y,j)=>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(se,{variant:"label",size:"sm",weight:"medium",className:"text-text-muted",children:[m.label," ",j+1]})}),e.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-3",children:m.arrayFields?.map(p=>{const L=y?.[p.name];let k="-";switch(p.type){case"text":case"email":case"number":case"tel":case"url":case"textarea":k=L||"-";break;case"select":case"radio":k=c(L,p.options);break;case"checkbox":k=l(L);break;case"date":k=a(L);break;case"custom":k=p.customComponent?.({value:L});break;default:k=String(L||"-")}return p.format&&(k=p.format(L,y)),e.jsxs("div",{className:"space-y-1",children:[e.jsx(se,{variant:"label",size:"xs",className:"text-text-muted",children:p.label}),e.jsx(se,{variant:"body",size:"sm",className:"text-text",children:k})]},p.name)})})]},j))})}if(m.type==="custom"&&m.customComponent)return m.customComponent({value:d});if(m.format){const h=m.format(d,s);return e.jsx(se,{variant:"body",size:"sm",className:"text-text",children:h})}let u="-";switch(m.type){case"text":case"email":case"password":case"number":case"tel":case"url":u=d?String(d):"-";break;case"textarea":u=d?e.jsx("div",{className:"whitespace-pre-wrap",children:String(d||"-")}):"-";break;case"select":case"radio":u=c(d,m.options);break;case"checkbox":u=l(d);break;case"date":u=a(d);break;default:u=d?String(d):"-"}return e.jsx(se,{variant:"body",size:"sm",className:"text-text",children:u})},[s]),g=i.useCallback(m=>{if(m.conditional&&!m.conditional(s))return null;const d=m.items.filter(h=>!(h.hidden||h.conditional&&!h.conditional(s)));if(d.length===0)return null;const u=x("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(se,{variant:"label",size:"lg",weight:"semibold",className:"text-text",children:m.title}),m.description&&e.jsx(se,{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:u,children:d.map(h=>e.jsxs("div",{className:x("space-y-1",h.width&&typeof h.width=="string"&&`w-[${h.width}]`,h.width&&typeof h.width=="number"&&`col-span-${h.width}`),children:[h.type!=="custom"&&e.jsx(se,{variant:"label",size:"sm",className:"font-medium text-text-muted",children:h.label}),b(h)]},h.name))})})]},m.id)},[s,b]),w=x("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:w,children:e.jsx("div",{className:"space-y-8",children:t.map(g)})})},Te=({item:t,isSelectedHandler:s,onClick:r,depth:n=0})=>{const a=!!(t.children&&t.children.length>0),l=s?s(t.path):!1;return a?e.jsxs("li",{children:[e.jsxs("div",{className:x("flex items-center gap-2 px-2 pt-4 pb-1 text-xs font-semibold uppercase tracking-label text-text-subtle"),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-0.5",children:t.children?.map((c,b)=>e.jsx(Te,{item:c,isSelectedHandler:s,onClick:r,depth:n+1},b))})]}):e.jsx("li",{children:e.jsxs("div",{role:"button",tabIndex:0,onClick:()=>t.path&&r?.(t.path),onKeyDown:c=>{(c.key==="Enter"||c.key===" ")&&(c.preventDefault(),t.path&&r?.(t.path))},className:x("flex cursor-pointer items-center gap-2 rounded-md px-2 py-1.5 text-base no-underline","transition-colors duration-fast ease-out","focus-visible:outline-none focus-visible:focus-ring",l?"bg-accent-soft font-semibold text-accent":"text-text-muted hover:bg-surface-hover hover:text-text",n===0&&"font-ui-450"),children:[t.icon&&e.jsx("span",{className:"flex w-5 shrink-0 items-center justify-center",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:x("shrink-0 text-xs tabular-nums",l?"rounded-full bg-accent px-2 font-bold text-accent-fg":"text-text-subtle"),children:t.count})]})})},cs=({title:t,actionIcons:s,items:r,isSelectedHandler:n,onClick:a,preMenuItemsComponent:l})=>e.jsxs("nav",{className:"flex h-full shrink-0 flex-col bg-page p-3",children:[e.jsxs("div",{className:"flex items-center gap-2 px-2 pb-3",children:[e.jsx("span",{className:"min-w-0 flex-1 truncate text-lg font-semibold text-text",children:t}),s&&s.length>0&&e.jsx("div",{className:"flex shrink-0 items-center gap-1",children:s.map((c,b)=>e.jsx("span",{className:x("flex h-control-sm w-7 cursor-pointer items-center justify-center rounded-md text-text-muted","transition-colors duration-fast ease-out hover:bg-surface-hover hover:text-text","focus-visible:outline-none focus-visible:focus-ring"),children:c},b))})]}),l&&e.jsx("div",{className:"px-1 pb-3",children:l}),e.jsx("ul",{className:"flex min-h-0 flex-1 flex-col gap-0.5 overflow-y-auto",children:r.map((c,b)=>!c.path&&!c.label&&!c.children?e.jsx("li",{"aria-hidden":!0,className:"h-4"},b):e.jsx(Te,{item:c,isSelectedHandler:n,onClick:a},b))})]}),is={xs:"text-xs",sm:"text-sm",md:"text-base",lg:"text-lg",xl:"text-xl","2xl":"text-2xl","3xl":"text-3xl","4xl":"text-3xl"},ds={light:"font-normal",normal:"font-normal",medium:"font-medium",semibold:"font-semibold",bold:"font-bold"},us={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"},xs={left:"text-left",center:"text-center",right:"text-right"},fs=({level:t=1,size:s,weight:r="semibold",color:n="current",align:a="left",truncate:l=!1,className:c,children:b,...g})=>{const w=`h${t}`,m=x("font-sans text-pretty",is[s||ms(t)],ds[r],us[n],xs[a],l&&"truncate",c);return e.jsx(w,{className:m,...g,children:b})};function ms(t){return{1:"2xl",2:"xl",3:"lg",4:"lg",5:"md",6:"md"}[t]||"md"}const hs=({commands:t,isOpen:s,onClose:r,labels:n,initialCommandPath:a,initialActiveIndex:l})=>{const[c,b]=i.useState(""),[g,w]=i.useState(a||[]),[m,d]=i.useState(l||0),u=i.useRef(null),h=i.useRef(null),j=(g.length?t.find(p=>p.id===g[0])?.subCommands||[]:t).filter(p=>p.label.toLowerCase().includes(c.toLowerCase()));return i.useEffect(()=>{s||(b(""),w(a||[]),d(l||0))},[s]),i.useEffect(()=>{const p=L=>{if(s){if(L.key==="Escape")r();else if(L.key==="ArrowUp")d(k=>k>0?k-1:j.length-1);else if(L.key==="ArrowDown")d(k=>k<j.length-1?k+1:0);else if(L.key==="Enter"){const k=j[m];k&&(k.subCommands?(w([...g,k.id]),d(0)):k.action&&(k.action(),r()))}}};return document.addEventListener("keydown",p),()=>document.removeEventListener("keydown",p)},[s,r,j,m,g]),i.useEffect(()=>{const p=L=>{u.current&&!u.current.contains(L.target)&&r()};return s&&document.addEventListener("mousedown",p),()=>document.removeEventListener("mousedown",p)},[s,r]),i.useEffect(()=>{if(!s)return;h.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:u,children:[e.jsxs("div",{className:"flex items-center gap-2 px-3 flex-shrink-0",children:[e.jsx(J.Search,{className:"w-4 h-4 text-text-muted shrink-0"}),e.jsx("input",{type:"text",autoFocus:!0,placeholder:n?.searchPlaceholder||"Search commands...",value:c,onChange:p=>b(p.target.value),className:"w-full border-0 bg-transparent py-2 text-text focus:outline-none"})]}),e.jsxs("div",{ref:h,className:"mt-2 pt-2 text-sm border-t border-border max-h-dialog-list overflow-y-auto",children:[j.length===0&&e.jsx("div",{className:"text-text-muted text-center text-sm",children:n?.noCommandsFound||"No commands found"}),j.map((p,L)=>e.jsxs("div",{"data-index":L,className:`flex items-center p-2 cursor-pointer rounded-md ${L===m?"bg-accent-soft text-accent":"text-text"}`,onClick:()=>{p.subCommands?(w([...g,p.id]),d(0)):p.action&&(p.action(),r())},onMouseEnter:()=>d(L),children:[p.icon&&e.jsx("span",{className:"mr-3",children:p.icon}),e.jsx("span",{className:"flex-grow",children:p.label}),p.subCommands&&e.jsx("span",{className:"text-text-muted",children:e.jsx(J.ChevronRight,{className:"w-4 h-4"})})]},p.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},bs={none:"p-0",xs:"p-1",sm:"p-2",md:"p-4",lg:"p-6",xl:"p-8","2xl":"p-12"},ps={none:"m-0",xs:"m-1",sm:"m-2",md:"m-4",lg:"m-6",xl:"m-8","2xl":"m-12"},gs={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"},vs={none:"rounded-none",sm:"rounded-sm",md:"rounded-md",lg:"rounded-lg",xl:"rounded-xl",full:"rounded-full"},js={none:"shadow-none",sm:"shadow-none",md:"shadow-overlay",lg:"shadow-overlay",xl:"shadow-modal","2xl":"shadow-modal"},ys={none:"border-0",sm:"border",md:"border-2",lg:"border-4"},Ns={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"},be=i.forwardRef(({padding:t,margin:s,background:r,radius:n,shadow:a,border:l,borderColor:c,className:b,children:g,...w},m)=>e.jsx("div",{ref:m,className:x(t&&bs[t],s&&ps[s],r&&gs[r],n&&vs[n],a&&js[a],l&&ys[l],c&&Ns[c],b),...w,children:g}));be.displayName="Box";const ws=({children:t,title:s,...r})=>e.jsxs(be,{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 ks({identifier:t,resourceLoader:s,framework:r="react",fallback:n,componentProps:a,className:l}){const c=i.useRef(null),[b,g]=i.useState(!0),[w,m]=i.useState(null),d=i.useRef(null);return i.useRef(null),i.useEffect(()=>{let u=!0;return(async()=>{g(!0);try{const y=await s();if(!u)return;const j=y.component||y.default||y;m(r==="react"?()=>j:()=>y)}catch(y){console.error(`[FederatedResource] Load failed: ${t}`,y)}finally{u&&g(!1)}})(),()=>{u=!1}},[t,s]),i.useEffect(()=>{if(b||!w||r==="react")return;const u=c.current;if(u){if(r==="svelte"){const h=w.default||w,y=new h({target:u,props:a||{}});return d.current=y,()=>y.$destroy()}if(w.mount){const h=w.mount({container:u,props:a||{}});return()=>{typeof h=="function"?h():w.unmount?.(u)}}}},[w,r,b]),i.useEffect(()=>{r==="svelte"&&d.current&&d.current.$set?.(a)},[a,r]),e.jsxs("div",{ref:c,className:l,style:{display:"contents"},children:[b&&n,r==="react"&&w&&e.jsx(w,{...a})]})}class Cs extends i.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=Ut;exports.Avatar=ze;exports.AvatarStack=Jt;exports.Badge=At;exports.Box=be;exports.Button=Z;exports.ButtonGroup=Ve;exports.Card=ws;exports.ChannelBadge=Xt;exports.Checkbox=oe;exports.CommandPalette=hs;exports.ContentLoading=ke;exports.DatePicker=de;exports.Dropdown=Ce;exports.EmptyState=Bt;exports.ErrorBoundary=Cs;exports.FederatedResource=ks;exports.FilterChip=Ue;exports.FolderSelect=Ne;exports.Form=zt;exports.Heading=fs;exports.Icon=ne;exports.Image=Zt;exports.Kbd=It;exports.KpiCard=ss;exports.Link=Je;exports.List=Qt;exports.MeetingGrid=Pe;exports.Modal=Me;exports.PageHeader=rs;exports.PageToolbar=ns;exports.ParticipantTile=Be;exports.Popover=je;exports.ProgressBar=Ot;exports.SearchableTextField=we;exports.SegmentedToggle=Xe;exports.Select=ce;exports.SidebarMenu=cs;exports.SourceChip=as;exports.Spinner=Ht;exports.SplitButton=he;exports.StorageInput=Le;exports.TabBar=vt;exports.Table=me;exports.Tabs=Ee;exports.Text=se;exports.TextArea=ue;exports.TextField=ae;exports.VideoSurface=Ie;exports.View=os;exports.cn=x;exports.createSizes=Ae;exports.createVariants=De;
2
2
  //# sourceMappingURL=index.cjs.map