@opencxh/ui-kit 3.94.0 → 3.98.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"),U=require("lucide-react"),d=require("react");function h(...t){return $e.clsx(t)}function De(t){return(n,s)=>t[n]?.[s]||""}function ze(t){return n=>t[n]||""}function Ae({tiles:t,pinned:n,className:s}){if(n)return e.jsxs("div",{className:h("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:n}),t.length>0&&e.jsx("div",{className:"flex md:flex-col gap-2 md:w-48 overflow-auto",children:t.map((l,o)=>e.jsx("div",{className:"min-w-[160px] md:min-w-0",children:l},o))})]});const r=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:h("grid gap-2 h-full",r,s),children:t.map((l,o)=>e.jsx("div",{children:l},o))})}function Ie({name:t,avatarUrl:n,muted:s,speaking:r,hasVideo:l,videoSlot:o,className:u,fill:b}){return e.jsxs("div",{className:h("relative rounded-lg overflow-hidden bg-gray-800 flex items-center justify-center",b?"h-full w-full":"aspect-video",r&&"ring-2 ring-emerald-400",u),children:[l&&o?e.jsx("div",{className:"absolute inset-0",children:o}):e.jsx("div",{className:"flex flex-col items-center gap-2 text-gray-300",children:n?e.jsx("img",{src:n,alt:t,className:"w-16 h-16 rounded-full object-cover"}):e.jsx("div",{className:"w-16 h-16 rounded-full bg-gray-700 flex items-center justify-center",children:l?e.jsx(U.VideoOff,{className:"w-8 h-8"}):e.jsx(U.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-black/50 text-white text-xs",children:[s?e.jsx(U.MicOff,{className:"w-3 h-3"}):e.jsx(U.Mic,{className:"w-3 h-3"}),e.jsx("span",{className:"truncate max-w-[140px]",children:t})]})]})}function Pe({attach:t,active:n=!0,mirrored:s=!1,className:r}){const l=d.useRef(null);return d.useEffect(()=>{if(!n||!l.current)return;const o=t(l.current);return()=>{typeof o=="function"&&o(),l.current&&(l.current.innerHTML="")}},[t,n]),e.jsx("div",{ref:l,className:h("w-full h-full bg-gray-900 overflow-hidden",s&&"[&>*]:scale-x-[-1]",r)})}const Be={primary:"btn o__primary",secondary:"btn o__secondary",outline:"btn o__secondary",ghost:"btn o__tertiary",destructive:"btn o__destructive"},Re={xs:"px-2 py-1 text-xs",sm:"px-3 py-1.5 text-sm",md:"px-4 py-2 text-sm",lg:"px-6 py-3 text-base",xl:"px-8 py-4 text-lg",full:"px-4 py-3 text-base"},_e={xs:"p-1",sm:"p-1.5",md:"p-2",lg:"p-3",xl:"p-4",full:"p-4"},Q=d.forwardRef(({variant:t="primary",size:n="md",fullWidth:s=!1,loading:r=!1,leftIcon:l,rightIcon:o,iconOnly:u=!1,className:b,children:p,disabled:g,...x},a)=>{const m=g||r;return e.jsxs("button",{ref:a,type:"button",className:h("inline-flex items-center justify-center transition-colors duration-200","disabled:opacity-50 disabled:cursor-not-allowed",Be[t],u?_e[n]:Re[n],s&&"w-full",r&&"cursor-wait",b),disabled:m,...x,children:[r&&e.jsxs("svg",{className:h("animate-spin",u?"h-4 w-4":"h-4 w-4 mr-2"),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"})]}),!r&&l&&e.jsx("span",{className:h("flex-shrink-0",!u&&"mr-2"),children:l}),!u&&p,!r&&o&&e.jsx("span",{className:h("flex-shrink-0",!u&&"ml-2"),children:o}),u&&!r&&!l&&!o&&p]})});Q.displayName="Button";const Fe=({children:t,size:n="md",orientation:s="horizontal",attached:r=!0,className:l})=>{const o=h("inline-flex",{"flex-row":s==="horizontal","flex-col":s==="vertical","[&>*:not(:first-child):not(:last-child)]:rounded-none":r,"[&>*:first-child]:rounded-r-none":r&&s==="horizontal","[&>*:last-child]:rounded-l-none":r&&s==="horizontal","[&>*:first-child]:rounded-b-none":r&&s==="vertical","[&>*:last-child]:rounded-t-none":r&&s==="vertical","[&>*:not(:first-child)]:-ml-px":r&&s==="horizontal","[&>*:not(:first-child)]:-mt-px":r&&s==="vertical","gap-1":!r&&n==="xs","gap-2":!r&&(n==="sm"||n==="md"),"gap-3":!r&&(n==="lg"||n==="xl")},l);return e.jsx("div",{className:o,role:"group",children:t})},Oe=({variant:t="default",size:n="md",color:s="primary",disabled:r=!1,external:l=!1,className:o,children:u,href:b,target:p,rel:g,...x})=>{const a=l||b&&(b.startsWith("http")||b.startsWith("mailto:")),m=h("inline-flex items-center gap-1 transition-colors duration-200 focus:outline-none focus:ring-2 focus:ring-offset-2",{"text-xs":n==="xs","text-sm":n==="sm","text-base":n==="md","text-lg":n==="lg","text-xl":n==="xl"},{"text-primary hover:text-primary/80 focus:ring-primary/20":s==="primary"&&!r,"text-secondary hover:text-secondary/80 focus:ring-secondary/20":s==="secondary"&&!r,"text-accent hover:text-accent/80 focus:ring-accent/20":s==="accent"&&!r,"text-success hover:text-success/80 focus:ring-success/20":s==="success"&&!r,"text-warning hover:text-warning/80 focus:ring-warning/20":s==="warning"&&!r,"text-error hover:text-error/80 focus:ring-error/20":s==="error"&&!r,"text-info hover:text-info/80 focus:ring-info/20":s==="info"&&!r,"text-neutral hover:text-neutral/80 focus:ring-neutral/20":s==="neutral"&&!r},{"":t==="default","text-opacity-70 hover:text-opacity-100":t==="subtle","underline underline-offset-2 decoration-1 hover:decoration-2":t==="underline","px-3 py-1.5 rounded-md bg-opacity-10 hover:bg-opacity-20":t==="button","bg-primary":t==="button"&&s==="primary","bg-secondary":t==="button"&&s==="secondary","bg-accent":t==="button"&&s==="accent","bg-success":t==="button"&&s==="success","bg-warning":t==="button"&&s==="warning","bg-error":t==="button"&&s==="error","bg-info":t==="button"&&s==="info","bg-neutral":t==="button"&&s==="neutral"},{"opacity-50 cursor-not-allowed pointer-events-none":r},o),f={...x,href:r?void 0:b,target:a?"_blank":p,rel:a?"noopener noreferrer":g};return e.jsxs("a",{className:m,...f,children:[u,a&&e.jsx("svg",{className:"w-3 h-3 ml-1",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24","aria-hidden":"true",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M10 6H6a2 2 0 00-2 2v10a2 2 0 002 2h10a2 2 0 002-2v-4M14 4h6m0 0v6m0-6L10 14"})})]})},ge={primary:"btn o__primary",secondary:"btn o__secondary",outline:"btn o__secondary"},Ve={sm:"px-3 py-1.5 text-sm",md:"px-4 py-2 text-sm"};function pe({label:t,onClick:n,variant:s="primary",size:r="md",icon:l,options:o,disabled:u=!1}){const[b,p]=d.useState(!1),g=d.useRef(null),x=d.useCallback(()=>{p(a=>!a)},[]);return d.useEffect(()=>{const a=m=>{g.current&&!g.current.contains(m.target)&&p(!1)};return document.addEventListener("mousedown",a),()=>document.removeEventListener("mousedown",a)},[]),e.jsxs("div",{ref:g,className:"relative inline-flex items-center gap-px",children:[e.jsxs("button",{type:"button",onClick:n,disabled:u,className:h("inline-flex items-center justify-center font-medium transition-colors duration-200","focus:outline-none focus:ring-1 focus:ring-offset-1","disabled:opacity-50 disabled:cursor-not-allowed",ge[s],Ve[r],"!rounded-r-none"),children:[l&&e.jsx("span",{className:"mr-2 flex-shrink-0",children:l}),t]}),e.jsx("button",{type:"button",onClick:x,disabled:u,className:h("inline-flex items-center justify-center font-medium transition-colors duration-200","focus:outline-none focus:ring-1 focus:ring-offset-1","disabled:opacity-50 disabled:cursor-not-allowed",ge[s],r==="sm"?"px-1.5 py-1.5":"px-2 py-2","!rounded-l-none"),children:e.jsx(U.ChevronDown,{className:"h-4 w-4"})}),b&&o.length>0&&e.jsx("div",{className:"absolute right-0 top-full mt-1 z-50 min-w-[160px] rounded-lg border border-gray-200 bg-white shadow-lg py-1",children:o.map(a=>e.jsx("button",{type:"button",onClick:()=>{a.onClick(),p(!1)},className:h("w-full text-left px-3 py-2 text-sm hover:bg-gray-50 transition-colors",a.variant==="destructive"?"text-red-600 hover:bg-red-50":"text-gray-700"),children:a.label},a.id))})]})}const We={sm:"h-4 w-4",md:"h-5 w-5",lg:"h-6 w-6",full:"h-6 w-6"},He={sm:"text-sm",md:"text-sm",lg:"text-base",full:"text-base"},ce=d.forwardRef(({label:t,helperText:n,error:s,size:r="md",indeterminate:l=!1,containerClassName:o,labelClassName:u,className:b,id:p,...g},x)=>{const a=p||`checkbox-${Math.random().toString(36).substr(2,9)}`,m=!!s;return d.useEffect(()=>{x&&typeof x=="object"&&x.current&&(x.current.indeterminate=l)},[l,x]),e.jsxs("div",{className:h("flex flex-col",o),children:[e.jsxs("div",{className:"flex items-start",children:[e.jsx("div",{className:"flex items-center h-5",children:e.jsx("input",{ref:x,id:a,type:"checkbox",className:h("rounded border transition-colors duration-200","focus:ring-2 focus:ring-offset-2 focus:outline-none","disabled:opacity-50 disabled:cursor-not-allowed",We[r],m?"border-error [&:not(:checked)]:bg-[var(--base-input)] text-error focus:border-error focus:ring-error":"border-neutral [&:not(:checked)]:bg-[var(--base-input)] text-[#1a1a1a] focus:border-primary focus:ring-primary",b),...g})}),t&&e.jsxs("div",{className:"ml-3 flex-1",children:[e.jsx("label",{htmlFor:a,className:h("font-medium cursor-pointer",m?"text-error":"text-default",He[r],u),children:t}),n&&!s&&e.jsx("p",{className:"mt-1 text-xs text-muted",children:n})]})]}),s&&e.jsx("p",{className:"mt-1 text-xs text-error",children:s})]})});ce.displayName="Checkbox";const qe=()=>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"})}),Ge=()=>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"})}),Ue=()=>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"})}),ie=d.forwardRef(({value:t,onChange:n,placeholder:s="Select date",disabled:r=!1,required:l=!1,size:o="md",className:u,minDate:b,maxDate:p,format:g="MM/dd/yyyy"},x)=>{const[a,m]=d.useState(!1),[f,N]=d.useState(()=>t||new Date),w=d.useRef(null);d.useEffect(()=>{const $=_=>{w.current&&!w.current.contains(_.target)&&m(!1)};return a&&document.addEventListener("mousedown",$),()=>{document.removeEventListener("mousedown",$)}},[a]);const v=$=>{if(!$)return"";const _=$.getDate().toString().padStart(2,"0"),O=($.getMonth()+1).toString().padStart(2,"0"),i=$.getFullYear();switch(g){case"dd/MM/yyyy":return`${_}/${O}/${i}`;case"yyyy-MM-dd":return`${i}-${O}-${_}`;case"MM/dd/yyyy":default:return`${O}/${_}/${i}`}},I=()=>{const $=f.getFullYear(),_=f.getMonth(),O=new Date($,_,1),i=new Date(O);i.setDate(i.getDate()-O.getDay());const y=[],E=new Date(i);for(let C=0;C<42;C++)y.push(new Date(E)),E.setDate(E.getDate()+1);return y},j=$=>{$.getMonth()===f.getMonth()&&(b&&$<b||p&&$>p||(n?.($),m(!1)))},H=()=>{N(new Date(f.getFullYear(),f.getMonth()-1,1))},B=()=>{N(new Date(f.getFullYear(),f.getMonth()+1,1))},q=()=>{n?.(null),m(!1)},F=h("w-full border border-neutral rounded-md transition-colors duration-200","bg-module text-default","placeholder:text-default dark:placeholder:text-muted","focus:outline-none focus:ring-2 focus:ring-primary/20 focus:border-primary","disabled:opacity-50 disabled:cursor-not-allowed disabled:bg-module-subtle",{"px-3 py-2 text-sm":o==="sm","px-3 py-2 text-base":o==="md","px-4 py-3 text-lg":o==="lg","px-4 py-3 text-base":o==="full"},u),z=I(),W=["January","February","March","April","May","June","July","August","September","October","November","December"];return e.jsxs("div",{ref:w,className:"relative",children:[e.jsxs("div",{className:"relative",children:[e.jsx("input",{ref:x,type:"text",value:v(t??null),placeholder:s,disabled:r,required:l,readOnly:!0,onClick:()=>!r&&m(!a),className:h(F,"pr-10 cursor-pointer")}),e.jsx("button",{type:"button",onClick:()=>!r&&m(!a),disabled:r,className:"absolute inset-y-0 right-0 flex items-center pr-3 text-muted hover:text-muted",children:e.jsx(qe,{})})]}),a&&e.jsxs("div",{className:"absolute z-50 mt-1 bg-module border border-neutral rounded-md shadow-lg p-4 min-w-[280px]",children:[e.jsxs("div",{className:"flex items-center justify-between mb-4",children:[e.jsx("button",{onClick:H,className:"p-1 hover:bg-neutral-container rounded",children:e.jsx(Ge,{})}),e.jsxs("h3",{className:"text-sm font-medium text-default",children:[W[f.getMonth()]," ",f.getFullYear()]}),e.jsx("button",{onClick:B,className:"p-1 hover:bg-neutral-container rounded",children:e.jsx(Ue,{})})]}),e.jsx("div",{className:"grid grid-cols-7 gap-1 mb-2",children:["Su","Mo","Tu","We","Th","Fr","Sa"].map($=>e.jsx("div",{className:"text-xs font-medium text-muted text-center py-1",children:$},$))}),e.jsx("div",{className:"grid grid-cols-7 gap-1",children:z.map(($,_)=>{const O=$.getMonth()===f.getMonth(),i=t&&$.toDateString()===t.toDateString(),y=$.toDateString()===new Date().toDateString(),E=!O||b&&$<b||p&&$>p;return e.jsx("button",{onClick:()=>!E&&j($),disabled:E,className:h("w-8 h-8 text-sm rounded transition-colors duration-200",{"text-default hover:bg-neutral-container":O&&!i&&!E,"bg-primary text-white":i,"bg-neutral-container text-default":y&&!i,"text-muted cursor-not-allowed":E}),children:$.getDate()},_)})}),e.jsxs("div",{className:"flex justify-between items-center mt-4 pt-3 border-t border-neutral",children:[e.jsx("button",{onClick:q,className:"text-sm text-muted hover:text-default",children:"Clear"}),e.jsx("button",{onClick:()=>m(!1),className:"text-sm text-primary hover:text-primary/80",children:"Close"})]})]})]})}),ae=(...t)=>t.filter(Boolean).join(" "),Ke=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"})}),Je=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"})}),Ye={sm:"px-3 py-1.5 text-sm",md:"px-3 py-2 text-sm",lg:"px-3 py-2 text-sm",full:"px-3 py-2 text-sm"},xe={sm:"h-4 w-4",md:"h-5 w-5",lg:"h-6 w-6",full:"h-6 w-6"},je=d.forwardRef(({label:t,helperText:n,error:s,size:r="md",fullWidth:l=!1,startIcon:o=e.jsx(Ke,{}),loading:u=!1,containerClassName:b,labelClassName:p,className:g,id:x,options:a,onRemoteSearch:m,onSelect:f,debounceTime:N=500,showAllOnOpen:w=!1,value:v,onChange:I,...j},H)=>{const B=x||`searchfield-${Math.random().toString(36).substr(2,9)}`,q=!!s,F=d.useRef(null),z=d.useRef(null),[W,$]=d.useState(v||""),[_,O]=d.useState(!1),[i,y]=d.useState(!1),[E,C]=d.useState(!1);d.useEffect(()=>{v!==void 0&&$(v)},[v]);const L=d.useMemo(()=>{if(w&&!E||!W)return a;const T=String(W).toLowerCase();return a.filter(D=>String(D.label).toLowerCase().includes(T))},[W,a,w,E]);d.useEffect(()=>{if(!m||!W){y(!1);return}const T=setTimeout(async()=>{y(!0);try{await m(String(W))}catch(D){console.error("Remote search failed:",D)}finally{y(!1)}},N);return()=>{clearTimeout(T),y(!1)}},[W,N,m]),d.useEffect(()=>{const T=D=>{F.current&&!F.current.contains(D.target)&&O(!1)};return document.addEventListener("mousedown",T),()=>document.removeEventListener("mousedown",T)},[]);const S=T=>{const D=T.target.value;$(D),O(!0),C(!0),I&&I(T)},Z=T=>{$(T.label),O(!1),C(!1),f&&f(T.value)},ee=()=>{(a.length>0||m)&&(O(!0),C(!1))},Y=u||i,M=_&&(L.length>0||Y),A=d.useMemo(()=>H||z,[H]);return e.jsxs("div",{className:ae("flex flex-col",l?"w-full":"",b||"","relative"),ref:F,children:[t&&e.jsx("label",{htmlFor:B,className:ae("block text-sm font-medium mb-1",q?"text-error":"text-default",p||""),children:t}),e.jsxs("div",{className:"relative",children:[o&&e.jsx("div",{className:"absolute left-0 pl-3 flex items-center pointer-events-none h-full",children:e.jsx("span",{className:ae("text-muted",xe[r]),children:o})}),e.jsx("input",{ref:A,id:B,value:W,onChange:S,onFocus:ee,className:ae("block w-full rounded-lg border transition-colors duration-200 bg-input","placeholder:text-[var(--text-muted)] focus:outline-none","disabled:opacity-50 disabled:cursor-not-allowed",Ye[r],o?"pl-10":"","pr-10",q?"border-red-500 text-error focus:border-red-500 focus:ring-red-500":"border-neutral text-default",g||""),...j}),e.jsx("div",{className:"absolute inset-y-0 right-0 pr-3 flex items-center",children:Y||u?e.jsxs("svg",{className:ae("animate-spin text-link",xe[r]),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(Je,{className:ae("text-muted cursor-pointer transition-transform",xe[r],_?"rotate-180":"rotate-0"),onClick:()=>{O(T=>(T||C(!1),!T))}})})]}),M&&e.jsx("ul",{className:"absolute z-10 mt-1 w-full bg-module border border-neutral rounded-lg shadow-lg max-h-60 overflow-auto top-full",role:"listbox",children:L.length>0?L.map(T=>e.jsx("li",{className:"px-4 py-2 cursor-pointer text-default hover:bg-accent-container hover:text-accent transition-colors",onClick:()=>Z(T),role:"option","aria-selected":W===T.label,children:T.label},T.value)):e.jsx("li",{className:"px-4 py-2 text-muted",children:Y||u?"Zoeken op afstand...":"Geen resultaten gevonden."})}),(s||n)&&e.jsx("p",{className:ae("mt-1 text-xs",q?"text-error":"text-muted"),children:s||n}),m&&e.jsxs("p",{className:"mt-2 text-xs text-success dark:text-success",children:["Huidige zoekterm (niet-gedebounced): ",String(W)]})]})});je.displayName="SearchableTextField";const Ze={sm:"px-3 py-1.5 text-sm",md:"px-3 py-2 text-sm",lg:"px-3 py-2 text-sm",full:"px-3 py-2 text-sm"},oe=t=>t.trim().toLowerCase(),le=d.forwardRef(({label:t,helperText:n,error:s,size:r="md",fullWidth:l=!1,options:o,placeholder:u,containerClassName:b,labelClassName:p,className:g,id:x,searchable:a,multiple:m,value:f,onChange:N,allowCreate:w,onCreateOption:v,...I},j)=>{const H=x||`select-${Math.random().toString(36).substr(2,9)}`,B=!!s,[q,F]=d.useState(!1),[z,W]=d.useState(""),$=d.useRef(null),[_,O]=d.useState(o);d.useImperativeHandle(j,()=>$.current),d.useEffect(()=>{const M=A=>{$.current&&!$.current.contains(A.target)&&F(!1)};return document.addEventListener("mousedown",M),()=>document.removeEventListener("mousedown",M)},[]);const i=d.useCallback((M,A)=>M.some(T=>oe(T.value)===oe(A)||oe(T.label)===oe(A)),[]),y=d.useCallback((M,A)=>{const T=[...M],D=X=>{const te=(X??"").trim();te&&(i(T,te)||T.push({value:te,label:te}))};return Array.isArray(A)?A.forEach(D):D(A),T},[i]);d.useEffect(()=>{O(M=>{const A=[...o];return M.forEach(T=>{!i(A,T.value)&&!i(A,T.label)&&A.push(T)}),y(A,f)})},[o,f,y,i]);const E=M=>{if(m){const A=Array.isArray(f)?f:[],T=A.includes(M)?A.filter(D=>D!==M):[...A,M];N?.(T)}else N?.(M),F(!1),W("")},C=m?null:_.find(M=>M.value===f),L=m?_.filter(M=>Array.isArray(f)&&f.includes(M.value)):[],S=a&&z?_.filter(M=>M.label.toLowerCase().includes(z.toLowerCase())):_,Z=!!w&&!!a&&!!z.trim()&&!i(_,z),ee=M=>{const A=M.trim();if(!A)return;const T=v?.(A)??{value:A,label:A};if(i(_,T.value)||i(_,T.label)){E(T.value),W(""),m||F(!1);return}O(D=>[...D,T]),E(T.value),W(""),m||F(!1)},Y=()=>m?L.length>0?L.map(M=>M.label).join(", "):u||"Select options":C?.label||u||"Select an option";return e.jsxs("div",{ref:$,className:h("relative flex flex-col",l&&"w-full",b),...I,children:[t&&e.jsx("label",{htmlFor:H,onClick:()=>F(!q),className:h("block text-sm font-medium mb-1",B?"text-error":"text-default",p),children:t}),e.jsxs("div",{className:"relative",children:[e.jsx("button",{type:"button",id:H,onClick:()=>F(!q),className:h("block w-full rounded-lg border transition-colors duration-200 text-left","focus:outline-none focus:ring-0 focus:ring-offset-0","disabled:opacity-50 disabled:cursor-not-allowed","bg-module",Ze[r],B?"border-error text-error focus:border-error focus:ring-error":"border-neutral text-default",g),children:e.jsx("span",{className:"block truncate",children:Y()})}),q&&e.jsxs("div",{className:"absolute z-10 mt-1 w-full rounded-md bg-module shadow-lg border border-neutral",children:[a&&e.jsx("div",{className:"p-2",children:e.jsx("input",{type:"text",placeholder:"Search...",value:z,onChange:M=>W(M.target.value),onKeyDown:M=>{M.key==="Enter"&&Z&&(M.preventDefault(),ee(z))},className:h("w-full px-3 py-2 text-sm rounded-md border","text-default border-neutral focus:outline-none focus:ring-0")})}),Z&&e.jsxs("div",{className:h("px-4 py-2 text-sm cursor-pointer","text-primary hover:bg-neutral-container"),onClick:()=>ee(z),children:["+: “",z.trim(),"”"]}),e.jsxs("ul",{className:"max-h-60 overflow-auto py-1",children:[u&&!m&&e.jsx("li",{className:"px-4 py-2 text-sm text-muted cursor-pointer hover:bg-neutral-container",onClick:()=>{N?.(""),F(!1)},children:u}),S.map(M=>{const A=m?Array.isArray(f)&&f.includes(M.value):f===M.value;return e.jsx("li",{onClick:()=>!M.disabled&&E(M.value),className:h("px-4 py-2 text-sm cursor-pointer","text-default",M.disabled?"opacity-50 cursor-not-allowed":"hover:bg-neutral-container",A&&"font-semibold"),children:e.jsxs("div",{className:"flex items-center",children:[m&&e.jsx("input",{type:"checkbox",checked:A,readOnly:!0,className:"mr-3 h-4 w-4 rounded border-neutral [&:not(:checked)]:bg-[var(--base-input)] text-[#1a1a1a] focus:ring-primary"}),e.jsx("span",{children:M.label})]})},M.value)})]})]})]}),(s||n)&&e.jsx("p",{className:h("mt-1 text-xs",B?"text-error":"text-muted"),children:s||n})]})});le.displayName="Select";const Xe={sm:"px-3 py-1.5 text-sm",md:"px-3 py-2 text-sm",lg:"px-4 py-3 text-base",full:"px-4 py-3 text-base"},de=d.forwardRef(({label:t,helperText:n,error:s,size:r="md",fullWidth:l=!1,loading:o=!1,containerClassName:u,labelClassName:b,className:p,id:g,rows:x=4,...a},m)=>{const f=g||`textarea-${Math.random().toString(36).substr(2,9)}`,N=!!s;return e.jsxs("div",{className:h("flex flex-col",l&&"w-full",u),children:[t&&e.jsx("label",{htmlFor:f,className:h("block text-sm font-medium mb-1",N?"text-error":"text-default",b),children:t}),e.jsxs("div",{className:"relative",children:[e.jsx("textarea",{ref:m,id:f,rows:x,className:h("block w-full rounded-lg border transition-colors duration-200 resize-vertical bg-input","placeholder:text-[var(--text-muted)] focus:outline-none focus:ring-0","disabled:opacity-50 disabled:cursor-not-allowed",Xe[r],N?"border-error text-error focus:border-error focus:ring-error":"border-neutral text-default",p),...a}),o&&e.jsx("div",{className:"absolute top-3 right-3",children:e.jsxs("svg",{className:"animate-spin h-4 w-4 text-muted",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"})]})})]}),(s||n)&&e.jsx("p",{className:h("mt-1 text-xs",N?"text-error":"text-muted"),children:s||n})]})});de.displayName="TextArea";const Qe={sm:"px-3 py-1.5 text-sm",md:"px-3 py-2 text-sm",lg:"px-3 py-2 text-sm",full:"px-3 py-2 text-sm"},fe={sm:"h-4 w-4",md:"h-5 w-5",lg:"h-6 w-6",full:"h-6 w-6"},ne=d.forwardRef(({label:t,helperText:n,error:s,size:r="md",fullWidth:l=!1,startIcon:o,endIcon:u,loading:b=!1,containerClassName:p,labelClassName:g,className:x,id:a,...m},f)=>{const N=a||`textfield-${Math.random().toString(36).substr(2,9)}`,w=!!s;return e.jsxs("div",{className:h("flex flex-col",l&&"w-full",p),children:[t&&e.jsx("label",{htmlFor:N,className:h("block text-sm font-medium mb-1",w?"text-error":"text-default",g),children:t}),e.jsxs("div",{className:"relative",children:[o&&e.jsx("div",{className:"absolute left-0 pl-3 flex items-center pointer-events-none h-full",children:e.jsx("span",{className:h("text-muted",fe[r]),children:o})}),e.jsx("input",{ref:f,id:N,className:h("block w-full rounded-lg border transition-colors duration-200 bg-input","placeholder:text-[var(--text-muted)] focus:outline-none focus:ring-1 focus:ring-offset-0","disabled:opacity-50 disabled:cursor-not-allowed",Qe[r],o&&"pl-10",u&&"pr-10",w?"border-error text-error focus:border-error focus:ring-error":"border-neutral text-default focus:border-primary focus:ring-primary",x),...m}),(u||b)&&e.jsx("div",{className:"absolute inset-y-0 right-0 pr-3 flex items-center",children:b?e.jsxs("svg",{className:h("animate-spin text-muted",fe[r]),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"})]}):u&&e.jsx("span",{className:h("text-muted",fe[r]),children:u})})]}),(s||n)&&e.jsx("p",{className:h("mt-1 text-xs",w?"text-error":"text-muted"),children:s||n})]})});ne.displayName="TextField";const re=({icon:t,size:n="md",color:s="current",clickable:r=!1,onClick:l,className:o,"aria-label":u,...b})=>{const p=typeof n=="number"?n:et(n),g=h("inline-block",{"text-primary":s==="primary","text-secondary":s==="secondary","text-accent":s==="accent","text-success":s==="success","text-warning":s==="warning","text-error":s==="error","text-info":s==="info","text-neutral":s==="neutral","text-current":s==="current"},{"cursor-pointer hover:opacity-80 transition-opacity duration-200":r,"focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-primary/20 rounded":r},o),x={size:p,className:g,onClick:r?l:void 0,"aria-label":u,role:r?"button":void 0,tabIndex:r?0:void 0,onKeyDown:r?a=>{(a.key==="Enter"||a.key===" ")&&(a.preventDefault(),l?.())}:void 0,...b};return e.jsx(t,{...x})};function et(t){return{xs:12,sm:16,md:20,lg:24,xl:32}[t]}function Ne({children:t,showTableSkeleton:n=!1,tableColumns:s=6,tableRows:r=8}){return t?e.jsx("main",{className:"flex-1 bg-module 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-module p-6",children:e.jsxs("div",{className:"w-full mx-auto space-y-6 animate-pulse",children:[!n&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"h-6 bg-neutral-container-emphasis rounded w-1/4"}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("div",{className:"h-4 bg-neutral-container-emphasis rounded w-3/4"}),e.jsx("div",{className:"h-4 bg-neutral-container-emphasis rounded w-1/2"})]})]}),n&&e.jsxs("div",{className:"rounded-lg overflow-hidden",children:[e.jsx("div",{className:`grid grid-cols-${s} gap-2 bg-neutral-container p-3`,children:Array.from({length:s}).map((l,o)=>e.jsx("div",{className:"h-4 bg-neutral-border-emphasis rounded w-2/3"},`header-${o}`))}),Array.from({length:r}).map((l,o)=>e.jsx("div",{className:`grid grid-cols-${s} gap-2 p-3 border-t border-neutral`,children:Array.from({length:s}).map((u,b)=>e.jsx("div",{className:"h-4 bg-neutral-container-emphasis rounded w-full"},`cell-${o}-${b}`))},`row-${o}`))]})]})})}const we=({trigger:t,options:n,value:s,onSelect:r,placement:l="bottom-start",disabled:o=!1,className:u,showCheck:b=!0,header:p})=>{const[g,x]=d.useState(!1),[a,m]=d.useState(null),[f,N]=d.useState({top:0,left:0}),[w,v]=d.useState({}),I=d.useRef(null),j=d.useRef(null),H=d.useRef(null),B=d.useRef(null);d.useEffect(()=>{const i=y=>{I.current&&(!I.current.contains(y.target)||H.current&&!H.current.contains(y.target))&&(x(!1),m(null),B.current&&(clearTimeout(B.current),B.current=null))};return g&&document.addEventListener("mousedown",i),()=>{document.removeEventListener("mousedown",i)}},[g]),d.useEffect(()=>{const i=y=>{y.key==="Escape"&&(x(!1),m(null),B.current&&(clearTimeout(B.current),B.current=null))};return g&&document.addEventListener("keydown",i),()=>{document.removeEventListener("keydown",i)}},[g]),d.useEffect(()=>{if(a&&I.current){const i=I.current.querySelector(`[data-option-value="${a}"]`);if(i){const y=i.getBoundingClientRect();N({top:y.top,left:y.right+8})}}},[a]),d.useEffect(()=>()=>{B.current&&clearTimeout(B.current)},[]);const q=i=>{if(i.stopPropagation(),!o){if(!g){const y=j.current?.getBoundingClientRect();if(y){const C={};l.startsWith("bottom")?C.top=y.bottom+6:C.bottom=window.innerHeight-y.top+6,l.endsWith("start")?C.left=y.left:C.right=window.innerWidth-y.right,v(C)}}x(!g),m(null),B.current&&(clearTimeout(B.current),B.current=null)}},F=(i,y,E)=>{i.stopPropagation(),!y.disabled&&!y.divider&&(!y.children||y.children.length===0)&&(r?.(y.value,E),x(!1),m(null))},z=i=>{B.current&&(clearTimeout(B.current),B.current=null),i.children&&i.children.length>0?m(i.value):m(null)},W=i=>{i.children&&i.children.length>0?B.current=setTimeout(()=>{m(null)},150):m(null)},$=(i,y,E)=>{i.stopPropagation(),!y.disabled&&!y.divider&&(r?.(y.value,E),x(!1),m(null))},_=h("fixed z-[60] min-w-[200px] bg-module rounded-md shadow-lg border border-neutral","max-h-60 overflow-auto"),O=h("fixed z-[60] min-w-[200px] bg-module rounded-md shadow-lg border border-neutral","max-h-60 overflow-auto");return e.jsxs("div",{ref:I,className:h("relative flex flex-row items-center justify-center rounded-lg hover:bg-neutral-container",u),children:[e.jsx("button",{ref:j,onClick:q,disabled:o,className:h("inline-flex items-center justify-center",{"opacity-50 cursor-not-allowed":o}),children:t}),g&&e.jsx("div",{className:_,style:w,children:e.jsxs("div",{className:"p-2",children:[p&&(typeof p=="string"?e.jsx("div",{className:"text-xs font-medium text-muted uppercase tracking-wider px-3 py-2",children:p}):p),n.map((i,y)=>{if(i.divider)return e.jsx("div",{className:"border-t border-neutral my-2"},`divider-${y}`);const E=i.children&&i.children.length>0,C=a===i.value;return e.jsxs("div",{className:"relative group",children:[e.jsxs("button",{"data-option-value":i.value,onClick:L=>F(L,i),onMouseEnter:()=>z(i),onMouseLeave:()=>W(i),disabled:i.disabled,className:h("w-full flex items-center justify-between px-3 py-2 text-sm text-default hover:bg-neutral-container rounded-md transition-colors",{"opacity-50 cursor-not-allowed":i.disabled,"bg-neutral-container":C&&E}),children:[e.jsxs("div",{className:"flex items-center space-x-2 min-w-0",children:[i.icon&&e.jsx("span",{className:"flex-shrink-0",children:i.icon}),e.jsxs("div",{className:"flex flex-col items-start min-w-0",children:[e.jsx("span",{className:"font-base truncate",children:i.label}),i.description&&e.jsx("span",{className:"text-xs text-muted",children:i.description})]})]}),e.jsxs("div",{className:"flex items-center space-x-2",children:[b&&s===i.value&&e.jsx("span",{className:"h-4 w-4 text-success flex-shrink-0 text-sm font-bold",children:"✓"}),E&&e.jsx("span",{className:"text-muted text-xs",children:"▶"})]})]}),E&&C&&e.jsx("div",{ref:H,className:O,style:{top:`${f.top}px`,left:`${f.left}px`},onMouseEnter:()=>{B.current&&(clearTimeout(B.current),B.current=null),m(i.value)},onMouseLeave:()=>{B.current=setTimeout(()=>{m(null)},150)},children:e.jsx("div",{className:"p-2",children:i.children.map((L,S)=>{if(L.divider)return e.jsx("div",{className:"border-t border-neutral my-2"},`divider-${S}`);const Z=typeof s=="object"&&s[i.value]&&s[i.value].includes(L.value)||s===L.value;return e.jsxs("button",{onClick:ee=>$(ee,L,i.value),disabled:L.disabled,className:h("w-full flex items-center justify-between px-3 py-2 text-sm text-default hover:bg-neutral-container rounded-md transition-colors",{"opacity-50 cursor-not-allowed":L.disabled}),children:[e.jsxs("div",{className:"flex items-center space-x-2 min-w-0",children:[L.icon&&e.jsx("span",{className:"flex-shrink-0",children:L.icon}),e.jsxs("div",{className:"flex flex-col items-start min-w-0",children:[e.jsx("span",{className:"font-base truncate",children:L.label}),L.description&&e.jsx("span",{className:"text-xs text-muted",children:L.description})]})]}),b&&Z&&e.jsx("span",{className:"h-4 w-4 text-success flex-shrink-0 text-sm font-bold",children:"✓"})]},L.value)})})})]},i.value)}),(()=>{const i=n.reduce((y,E)=>{if(E.divider)return y;const C=E.children?E.children.filter(L=>!L.divider).length:0;return y+1+C},0);return i>1&&e.jsx("div",{className:"border-t border-neutral mt-2 pt-2",children:e.jsxs("div",{className:"text-xs text-muted px-3 py-1",children:[i," options available"]})})})()]})})]})},tt=()=>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"})}),st=({active:t})=>e.jsx("svg",{className:h("h-3 w-3",t?"text-default":"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"})}),rt=({active:t})=>e.jsx("svg",{className:h("h-3 w-3",t?"text-default":"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"})}),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:"m15 18-6-6 6-6"})}),at=()=>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"})}),lt=()=>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"})}),ot=()=>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"})}),ke=()=>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"})}),ct=t=>{const n=r=>t.multiSelect&&Array.isArray(t.value)?t.value?.includes(r):t.value===r,s=r=>{t.multiSelect&&Array.isArray(t.value)?t.onChange(t.value.filter(l=>l!==r)):t.onChange(r)};return t.type==="date"?e.jsx("div",{className:"flex items-center space-x-1 max-w-[160px]",children:e.jsx(ie,{size:"sm",value:t.value,onChange:r=>t.onChange(r),placeholder:t.placeholder||`Select ${t.label.toLowerCase()}`,className:"min-w-[160px] btn btn o__secondary"})}):e.jsx("div",{className:"flex items-center space-x-1 max-w-[240px]",children:e.jsx("div",{className:"relative",children:e.jsxs("details",{className:"group",children:[e.jsxs("summary",{className:"flex items-center space-x-2 cursor-pointer rounded-full px-3 py-2 text-sm btn btn o__secondary",children:[e.jsx("span",{children:t.label}),e.jsx("span",{className:"text-default",children:t.multiSelect&&Array.isArray(t.value)?t.value?.map(r=>t.options?.find(l=>l.value===r)?.label).join(", "):t.options?.find(r=>r.value===t.value)?.label}),e.jsx("span",{className:"text-muted text-sm group-open:rotate-180 transition-transform",children:e.jsx(ke,{})})]}),e.jsxs("div",{className:"absolute z-10 left-0 mt-1 bg-module border border-neutral rounded-lg shadow-lvl-0 p-2 w-48",children:[t.options?.map(r=>e.jsx("button",{className:"w-full text-left px-3 py-2 rounded-md hover:bg-module-subtle text-sm text-default flex items-center space-x-2",onClick:()=>s(r.value),children:e.jsx("span",{className:h(n(r.value)&&"text-primary-500"),children:r.label})},r.value)),t.value&&e.jsx("button",{className:"w-full text-left px-3 py-2 rounded-md hover:bg-module-subtle text-sm text-default flex items-center space-x-2 mt-2",onClick:()=>s(null),children:e.jsx("span",{className:"text-muted",children:"Clear filter"})})]})]})})})},he=({data:t,columns:n,loading:s=!1,searchable:r=!1,searchPlaceholder:l="Search...",filters:o=[],paginated:u=!1,pageSizeOptions:b=[10,25,50,100],defaultPageSize:p=10,actions:g=[],onRowClick:x,selectable:a=!1,selectedRows:m=[],onSelectionChange:f,getRowKey:N=(q,F)=>F,emptyContent:w,hoverable:v=!0,bordered:I=!1,striped:j=!1,className:H,rowClassName:B})=>{const[q,F]=d.useState(""),[z,W]=d.useState({column:null,direction:null}),[$,_]=d.useState({page:0,pageSize:p}),O=d.useRef(null),i=d.useMemo(()=>{let c=t;if(r&&q.trim()){const k=n.filter(V=>V.searchable!==!1),R=q.toLowerCase();c=c.filter(V=>k.some(P=>{const J=typeof P.accessor=="function"?P.accessor(V):V[P.accessor];return String(J||"").toLowerCase().includes(R)}))}return o.forEach(k=>{k.value&&k.value!=="all"&&(c=c.filter(R=>{const V=n.find(J=>J.id===k.id);if(!V)return!0;const P=typeof V.accessor=="function"?V.accessor(R):R[V.accessor];return String(P||"")===k.value}))}),c},[t,q,n,r,o]),y=d.useMemo(()=>{if(!z.column||!z.direction)return i;const c=n.find(k=>k.id===z.column);return c?[...i].sort((k,R)=>{const V=typeof c.accessor=="function"?c.accessor(k):k[c.accessor],P=typeof c.accessor=="function"?c.accessor(R):R[c.accessor];let J=0;return V<P?J=-1:V>P&&(J=1),z.direction==="desc"?-J:J}):i},[i,z,n]),E=d.useMemo(()=>{if(!u)return y;const c=$.page*$.pageSize,k=c+$.pageSize;return y.slice(c,k)},[y,$,u]),C=d.useCallback(c=>{n.find(R=>R.id===c)?.sortable&&W(R=>R.column!==c?{column:c,direction:"asc"}:R.direction==="asc"?{column:c,direction:"desc"}:{column:null,direction:null})},[n]),L=d.useCallback(c=>{_(k=>({...k,page:c}))},[]),S=d.useCallback(c=>{_({page:0,pageSize:c})},[]),Z=d.useCallback((c,k)=>{if(!f)return;const R=N(c,0);m.map((V,P)=>N(V,P)),f(k?[...m,c]:m.filter((V,P)=>N(m[P],P)!==R))},[m,f,N]),ee=d.useCallback(c=>{f&&f(c?[...E]:[])},[E,f]);d.useEffect(()=>{_(c=>({...c,page:0}))},[q,z]),d.useEffect(()=>{_(c=>({...c,page:0}))},[o.map(c=>c.value).join(",")]);const Y=y.length,M=Math.ceil(Y/$.pageSize),A=$.page*$.pageSize+1,T=Math.min(A+$.pageSize-1,Y),D=E.length>0&&E.every(c=>{const k=N(c,0);return m.some((R,V)=>N(R,V)===k)}),X=E.some(c=>{const k=N(c,0);return m.some((R,V)=>N(R,V)===k)}),te=h("w-full text-sm leading-5 text-[var(--text-default)] border-collapse",H),G=h("bg-[var(--base-module)]"),se=h("text-[var(--text-default)] p-3 border-b border-[var(--neutral-border)]"),ue=h("h-12",{"hover:bg-[var(--neutral-container)] dark:hover:bg-[var(--neutral-container-emphasis)]":v,"cursor-pointer":x});return e.jsxs("div",{className:"space-y-4",children:[(r||o.length>0)&&e.jsx("div",{className:"pt-4 pb-2",children:e.jsxs("div",{className:"flex flex-wrap gap-4 items-start",children:[o.map(c=>e.jsx(ct,{...c},c.id)),e.jsx("div",{className:"w-full sm:w-auto sm:ml-auto min-w-[200px]",children:e.jsx(ne,{placeholder:l,value:q,onChange:c=>F(c.target.value),startIcon:e.jsx(tt,{}),className:"max-w-sm"})})]})}),e.jsxs("div",{className:"relative w-full overflow-x-auto min-h-[400px]",children:[s&&e.jsx("div",{className:"flex items-center justify-center z-10",children:e.jsx(Ne,{showTableSkeleton:!0,tableRows:10,tableColumns:n.length})}),e.jsxs("table",{ref:O,className:h(te,"min-w-full"),children:[e.jsx("thead",{className:G,children:e.jsxs("tr",{children:[a&&e.jsx("th",{className:h(se,"w-12"),children:e.jsx("input",{type:"checkbox",checked:D,ref:c=>{c&&(c.indeterminate=X&&!D)},onChange:c=>ee(c.target.checked),className:"rounded border-neutral [&:not(:checked)]:bg-[var(--base-input)] text-[#1a1a1a]"})}),!s&&n.map(c=>e.jsx("th",{className:h(se,"font-semibold text-xs text-[var(--text-muted)] dark:text-[var(--text-muted)] uppercase tracking-wider","group",{"text-left":c.align==="left"||!c.align,"text-center":c.align==="center","text-right":c.align==="right","cursor-pointer select-none":c.sortable,"sticky left-0 bg-module":c.sticky==="left","sticky right-0 bg-module":c.sticky==="right"}),style:{width:c.width},onClick:()=>c.sortable&&C(c.id),children:e.jsxs("div",{className:"flex items-center gap-2",children:[c.headerCell?c.headerCell():c.header,c.sortable&&e.jsxs("div",{className:h("flex flex-col opacity-0 group-hover:opacity-100 transition-opacity",z.column===c.id&&"opacity-100"),children:[e.jsx(st,{active:z.column===c.id&&z.direction==="asc"}),e.jsx(rt,{active:z.column===c.id&&z.direction==="desc"})]})]})},c.id)),g.length>0&&e.jsx("th",{className:h(se,"w-20"),children:e.jsx("span",{className:"sr-only",children:"Actions"})})]})}),e.jsx("tbody",{children:E.length===0||s?!s&&e.jsx("tr",{children:e.jsx("td",{colSpan:n.length+(a?1:0)+(g.length>0?1:0),className:h(se,"text-center py-8 text-muted"),children:w||"No data available"})}):E.map((c,k)=>{const R=N(c,k),V=m.some((P,J)=>N(P,J)===R);return e.jsxs("tr",{className:h(ue,{"bg-accent-container":V},B?.(c,k)),onClick:P=>{P.stopPropagation(),x?.(c,k)},children:[a&&e.jsx("td",{className:se,children:e.jsx("input",{type:"checkbox",checked:V,onChange:P=>{P.stopPropagation(),Z(c,P.target.checked)},className:"rounded border-neutral [&:not(:checked)]:bg-[var(--base-input)] text-[#1a1a1a]"})}),n.map(P=>{const J=typeof P.accessor=="function"?P.accessor(c):c[P.accessor];return e.jsx("td",{className:h(se,{"text-left":P.align==="left"||!P.align,"text-center":P.align==="center","text-right":P.align==="right","sticky left-0 bg-module":P.sticky==="left","sticky right-0 bg-module":P.sticky==="right"}),children:P.cell?P.cell(J,c,k):String(J||"")},P.id)}),g.length>0&&e.jsx("td",{className:se,children:e.jsx(we,{trigger:e.jsxs("div",{className:"inline-flex items-center gap-1 px-2 py-1 text-sm text-muted hover:text-default",children:[e.jsx("span",{children:"Options"}),e.jsx(ke,{})]}),options:g.map(P=>({value:P.id,label:P.label,icon:P.icon,disabled:P.disabled?.(c)})),onSelect:P=>{const J=g.find(me=>me.id===P);J&&J.onClick(c,k)},placement:"bottom-end"})})]},R)})})]})]}),u&&Y>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-muted",children:["Showing ",A," to ",T," of ",Y," results"]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-sm text-muted",children:"Rows per page:"}),e.jsx("select",{value:$.pageSize,onChange:c=>S(Number(c.target.value)),className:"border border-[var(--neutral-border)] text-[var(--text-default)] rounded-md px-2 py-1 text-sm bg-[var(--base-input)] w-16",children:b.map(c=>e.jsx("option",{value:c,children:c},c))})]})]}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(Q,{size:"sm",variant:"ghost",onClick:()=>L(0),disabled:$.page===0,iconOnly:!0,children:e.jsx(lt,{})}),e.jsx(Q,{size:"sm",variant:"ghost",onClick:()=>L($.page-1),disabled:$.page===0,iconOnly:!0,children:e.jsx(nt,{})}),e.jsxs("span",{className:"px-3 py-1 text-sm text-muted",children:["Page ",$.page+1," of ",M]}),e.jsx(Q,{size:"sm",variant:"ghost",onClick:()=>L($.page+1),disabled:$.page>=M-1,iconOnly:!0,children:e.jsx(at,{})}),e.jsx(Q,{size:"sm",variant:"ghost",onClick:()=>L(M-1),disabled:$.page>=M-1,iconOnly:!0,children:e.jsx(ot,{})})]})]})]})},it=d.createContext(null),dt=({items:t,activeTab:n,onTabChange:s,className:r})=>{const[l,o]=d.useState(t[0]?.id||""),u=n||l,b=p=>{s?s(p):o(p)};return e.jsx("div",{className:h("border-b border-neutral-200 dark:border-neutral-700",r),children:e.jsx("nav",{className:"-mb-px flex space-x-8",children:t.map(p=>e.jsx("button",{onClick:()=>!p.disabled&&b(p.id),disabled:p.disabled,className:h("border-b-2 py-2 px-1 text-sm font-medium transition-colors duration-200",{"border-primary text-primary":u===p.id,"border-transparent text-neutral-500 hover:text-neutral-700 dark:text-neutral-400 dark:hover:text-neutral-300":u!==p.id&&!p.disabled,"border-transparent text-neutral-300 cursor-not-allowed dark:text-neutral-600":p.disabled}),children:e.jsxs("span",{className:"flex items-center gap-2",children:[p.label,p.badge&&e.jsx("span",{className:h("inline-flex items-center px-2 py-0.5 rounded-full text-xs font-medium",u===p.id?"bg-primary/10 text-primary":"bg-neutral-100 text-neutral-600 dark:bg-neutral-800 dark:text-neutral-400"),children:p.badge})]})},p.id))})})},Ce=({items:t,defaultTab:n,activeTab:s,onTabChange:r,variant:l="default",size:o="md",className:u})=>{const[b,p]=d.useState(n||s||t[0]?.id||""),g=s||b,x=w=>{r?r(w):p(w)},a={activeTab:g,setActiveTab:x},m=t.find(w=>w.id===g),f=h("flex",{"border-b border-neutral-200 dark:border-neutral-700 px-2":l==="default"||l==="underline","bg-neutral-100 dark:bg-neutral-800 p-1 rounded-lg":l==="pills","space-x-1":l==="pills","space-x-8":l==="default"||l==="underline"},u),N=(w,v)=>{const I="transition-colors duration-200 font-medium",j={"text-xs px-2 py-1":o==="sm","text-sm px-3 py-2":o==="md","text-base px-4 py-3":o==="lg"},H={"border-b-2 -mb-px":l==="default","rounded-md":l==="pills","border-b-2 pb-2":l==="underline"},B={"opacity-50 cursor-not-allowed":w.disabled,"cursor-pointer":!w.disabled},q=v?{"border-primary text-primary":l==="default"||l==="underline","bg-white dark:bg-neutral-700 text-neutral-900 dark:text-neutral-100 shadow-sm":l==="pills"}:{},F=!v&&!w.disabled?{"border-transparent text-neutral-600 hover:text-neutral-900 dark:text-neutral-400 dark:hover:text-neutral-100":l==="default","text-neutral-600 hover:text-neutral-900 dark:text-neutral-400 dark:hover:text-neutral-100":l==="pills","border-transparent text-neutral-600 hover:text-neutral-900 hover:border-neutral-300 dark:text-neutral-400 dark:hover:text-neutral-100":l==="underline"}:{};return h(I,j,H,B,q,F)};return e.jsx(it.Provider,{value:a,children:e.jsxs("div",{children:[e.jsx("div",{className:f,role:"tablist",children:t.map(w=>e.jsx("button",{type:"button",role:"tab","aria-selected":g===w.id,"aria-controls":`tabpanel-${w.id}`,disabled:w.disabled,onClick:()=>!w.disabled&&x(w.id),className:N(w,g===w.id),children:e.jsxs("span",{className:"flex items-center gap-2",children:[w.label,w.badge&&e.jsx("span",{className:"inline-flex items-center px-2 py-0.5 rounded-full text-xs font-medium bg-neutral-200 text-neutral-700 dark:bg-neutral-700 dark:text-neutral-300",children:w.badge})]})},w.id))}),m?.content&&e.jsx("div",{role:"tabpanel",id:`tabpanel-${g}`,"aria-labelledby":`tab-${g}`,className:"mt-4",children:m.content})]})})},ut={sm:"max-w-md",md:"max-w-lg",lg:"max-w-2xl",xl:"max-w-4xl",full:"max-w-full mx-4"};function Se({open:t,onClose:n,title:s,size:r="md",closeOnBackdropClick:l=!0,closeOnEscape:o=!0,className:u,backdropClassName:b,children:p,footer:g,showCloseButton:x=!0}){const a=d.useRef(null),m=d.useRef(null);d.useEffect(()=>{if(!t||!o)return;const N=w=>{w.key==="Escape"&&n()};return document.addEventListener("keydown",N),()=>document.removeEventListener("keydown",N)},[t,o,n]),d.useEffect(()=>(t?(m.current=document.activeElement,a.current&&a.current.focus(),document.body.style.overflow="hidden"):(m.current&&m.current.focus(),document.body.style.overflow=""),()=>{document.body.style.overflow=""}),[t]);const f=N=>{l&&N.target===N.currentTarget&&n()};return t?e.jsx("div",{className:h("fixed inset-0 z-50 flex items-center justify-center p-4","bg-black/20",b),onClick:f,children:e.jsxs("div",{ref:a,className:h("relative w-full bg-module rounded-modal shadow-modal rounded-md","focus:outline-none",ut[r],u),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-default",children:s}),x&&e.jsx("button",{onClick:n,className:"p-1 text-muted hover:text-muted 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:p}),g&&e.jsx("div",{className:"px-6 py-4",children:g})]})}):null}const K=({variant:t="body",size:n="md",weight:s="normal",color:r="current",align:l="left",truncate:o=!1,italic:u=!1,underline:b=!1,lineHeight:p="normal",as:g,className:x,children:a,...m})=>{const f=g||mt(t),N=h("font-primary",{"leading-relaxed":t==="body","text-sm leading-tight":t==="caption","text-sm font-medium leading-none":t==="label","font-mono text-sm bg-neutral-100 dark:bg-neutral-800 px-1 py-0.5 rounded":t==="code"},t!=="code"&&{"text-xs":n==="xs","text-sm":n==="sm","text-base":n==="md","text-lg":n==="lg","text-xl":n==="xl"},t!=="label"&&{"font-light":s==="light","font-normal":s==="normal","font-medium":s==="medium","font-semibold":s==="semibold","font-bold":s==="bold"},{"text-primary":r==="primary","text-secondary":r==="secondary","text-[var(--text-accent)]":r==="accent","text-[var(--text-success)]":r==="success","text-warning":r==="warning","text-[var(--text-error)]":r==="error","text-info":r==="info","text-[var(--text-default)]":r==="neutral","text-current":r==="current","text-[var(--text-muted)]":r==="muted"},{"text-left":l==="left","text-center":l==="center","text-right":l==="right","text-justify":l==="justify"},t==="body"&&{"leading-tight":p==="tight","leading-normal":p==="normal","leading-relaxed":p==="relaxed"},{italic:u,underline:b,truncate:o},x),w=f;return e.jsx(w,{className:N,...m,children:a})};function mt(t){return{body:"p",caption:"span",label:"span",code:"code"}[t]||"p"}const Ee=({value:t,onChange:n,label:s,placeholder:r="Select or upload a file",error:l,disabled:o,accept:u,onListFiles:b,onListMounts:p,onUploadFile:g,onDownloadFile:x,onRegisterFile:a})=>{const[m,f]=d.useState(!1),[N,w]=d.useState([]),[v,I]=d.useState(null),[j,H]=d.useState("/"),[B,q]=d.useState([]),[F,z]=d.useState(!1),[W,$]=d.useState(""),[_,O]=d.useState(typeof t=="object"?t:null),[i,y]=d.useState(!1),[E,C]=d.useState(""),L=d.useRef(null);d.useEffect(()=>{m&&S()},[m]),d.useEffect(()=>{m&&v&&Z()},[m,v,j,W]);const S=async()=>{z(!0);try{const c=await p?.();c?.data&&w(c.data)}catch(c){console.error("Failed to load mounts",c)}finally{z(!1)}},Z=async()=>{if(v){z(!0);try{const c=await b?.({mountId:v.id,name:W,path:j});c?.data&&q(c.data)}catch(c){console.error("Failed to load files",c)}finally{z(!1)}}},ee=async c=>{const k=c.target.files?.[0];if(k){z(!0);try{const R=await k.arrayBuffer(),V=new Uint8Array(R),P={id:`local-${Date.now()}`,name:k.name,type:"file",path:"/",mimeType:k.type||"application/octet-stream",size:k.size,mountId:"local",providerKey:k.name,ownerId:"me"};O(P),n(P,V),f(!1)}catch(R){console.error("Local file selection failed",R)}finally{z(!1)}}},Y=async c=>{const k=c.target.files?.[0];if(!(!k||!v)){z(!0);try{const R=await k.arrayBuffer(),V=await g?.({file:new Uint8Array(R),filename:k.name,mimeType:k.type||"application/octet-stream",mountId:v.id,path:j});if(V?.data){const P=V.data;O(P),n(P,new Uint8Array(R)),f(!1)}}catch(R){console.error("Upload failed",R)}finally{z(!1)}}},M=async()=>{if(!(!E||!v)){z(!0);try{const c=`${j}${E}/`;a&&(await a({name:E,type:"folder",path:j,mimeType:"application/x-directory",size:0,mountId:v.id,providerKey:c,ownerId:"me"}),await Z()),y(!1),C("")}catch(c){console.error("Failed to create folder",c)}finally{z(!1)}}},A=async c=>{z(!0);try{const k=await x?.(c.id);O(c),n(c,k),f(!1)}catch(k){console.error("Failed to download file",k)}finally{z(!1)}},T=c=>{c.stopPropagation(),O(null),n(null)},D=d.useMemo(()=>{const c=new Set,k=[];return B.forEach(R=>{if(R.type==="folder"){R.path===j&&c.add(R.name);return}const V=R.providerKey||R.name,J=(j?V.substring(j.length):V).split("/").filter(me=>me!=="");J.length>1?c.add(J[0]):J.length===1&&k.push(R)}),{folders:Array.from(c).sort(),files:k.sort((R,V)=>R.name.localeCompare(V.name))}},[B,j]),X=c=>{H(k=>`${k}${c}/`)},te=()=>{const c=j.split("/").filter(k=>k!=="");c.pop(),c.length===0?H("/"):H(`${c.join("/")}/`)},G=d.useMemo(()=>{const c=D.folders.map(k=>({id:`folder-${k}`,name:k,type:"folder"}));return D.files.forEach(k=>{c.push({...k,type:"file"})}),c},[D]),se=[{id:"name",header:"Name",accessor:"name",cell:(c,k)=>e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(re,{icon:k.type==="folder"?U.Folder:U.FileText,size:"sm",color:k.type==="folder"?"warning":"secondary"}),e.jsx("span",{className:h(k.type==="folder"&&"font-medium"),children:c})]})},{id:"type",header:"Type",accessor:c=>c.type==="folder"?"Folder":c.mimeType},{id:"size",header:"Size",accessor:c=>c.type==="file"?`${(c.size/1024).toFixed(1)} KB`:"-"},{id:"actions",header:"",accessor:"id",align:"right",cell:(c,k)=>e.jsx(Q,{size:"sm",variant:"outline",onClick:R=>{R.stopPropagation(),k.type==="folder"?X(k.name):A(k)},loading:F&&k.type==="file"&&_?.id===k.id,children:k.type==="folder"?"Open":"Select"})}],ue=[{id:"name",header:"Mount Name",accessor:"name",cell:c=>e.jsxs("div",{className:"flex items-center gap-2 font-medium",children:[e.jsx(re,{icon:U.HardDrive,size:"sm",color:"primary"}),e.jsx("span",{children:c})]})},{id:"actions",header:"",accessor:"id",align:"right",cell:(c,k)=>e.jsx(Q,{size:"sm",variant:"outline",onClick:()=>I(k),children:"Open"})}];return e.jsxs("div",{className:"space-y-1",children:[s&&e.jsx(K,{variant:"label",size:"sm",weight:"medium",children:s}),e.jsxs("div",{onClick:()=>!o&&f(!0),className:h("flex items-center gap-3 px-3 py-2 border rounded-lg cursor-pointer transition-colors","hover:border-primary-400 bg-module",l?"border-error":"border-neutral",o&&"opacity-50 cursor-not-allowed bg-module-subtle"),children:[e.jsx("div",{className:"flex-shrink-0",children:e.jsx(re,{icon:_?U.FileText:U.HardDrive,color:_?"primary":"secondary"})}),e.jsx("div",{className:"flex-grow truncate",children:_?e.jsx("span",{className:"text-sm text-default font-medium",children:_.name}):e.jsx("span",{className:"text-sm text-muted",children:r})}),_&&!o&&e.jsx("button",{onClick:T,className:"p-1 hover:bg-neutral-container rounded",children:e.jsx(re,{icon:U.X,size:"xs"})})]}),l&&e.jsx(K,{variant:"body",size:"xs",className:"text-error",children:l}),e.jsx(Se,{open:m,onClose:()=>{f(!1),I(null),H("/"),y(!1)},title:v?`Explorer: ${v.name}`:"Select Storage Mount",size:"lg",children:e.jsx(Ce,{variant:"pills",items:[{id:"remote",label:"Platform Storage",content:e.jsx("div",{className:"space-y-4",children:v?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:()=>{j&&j!=="/"?te():I(null)},leftIcon:e.jsx(re,{icon:U.ArrowLeft,size:"xs"}),children:j?"Back":"Back to Mounts"}),e.jsx("div",{className:"flex items-center gap-1 text-xs text-muted overflow-hidden bg-neutral-container px-2 py-1 rounded",children:e.jsx("span",{className:"truncate",children:j})}),e.jsx("div",{className:"flex-grow min-w-[150px]",children:e.jsx(ne,{placeholder:"Search...",value:W,onChange:c=>$(c.target.value),startIcon:e.jsx(U.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:()=>y(!0),leftIcon:e.jsx(re,{icon:U.FolderPlus,size:"xs"}),children:"New Folder"}),e.jsx(Q,{variant:"primary",size:"sm",onClick:()=>L.current?.click(),leftIcon:e.jsx(re,{icon:U.Upload,size:"xs"}),loading:F,children:"Upload"}),e.jsx("input",{type:"file",className:"hidden",ref:L,onChange:Y,accept:u})]})]}),i&&e.jsxs("div",{className:"flex items-center gap-2 p-3 bg-module-subtle rounded-lg border border-neutral",children:[e.jsx(re,{icon:U.Folder,size:"sm",color:"warning"}),e.jsx(ne,{size:"sm",placeholder:"Folder name",value:E,onChange:c=>C(c.target.value),autoFocus:!0}),e.jsx(Q,{size:"sm",onClick:M,loading:F,children:"Create"}),e.jsx(Q,{size:"sm",variant:"ghost",onClick:()=>y(!1),children:"Cancel"})]}),e.jsx("div",{className:"max-h-[400px] overflow-auto rounded-lg border border-neutral",children:e.jsx(he,{data:G,columns:se,loading:F,emptyContent:"This folder is empty",onRowClick:c=>c.type==="folder"?X(c.name):A(c)})})]}):e.jsx("div",{className:"max-h-[400px] overflow-auto rounded-lg border border-neutral",children:e.jsx(he,{data:N,columns:ue,loading:F,emptyContent:"No storage mounts configured",onRowClick:c=>I(c)})})})},{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-neutral rounded-xl bg-module-subtle/50",children:[e.jsx("div",{className:"p-4 bg-primary/10 rounded-full mb-4",children:e.jsx(re,{icon:U.FileText,size:"xl",color:"primary"})}),e.jsx(K,{variant:"label",size:"lg",weight:"semibold",children:"Select a file from your computer"}),e.jsxs(K,{variant:"body",size:"sm",className:"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.jsxs("div",{className:h("inline-flex items-center justify-center font-medium rounded-lg transition-colors duration-200 px-6 py-3 text-base bg-primary text-white hover:bg-primary-600",F&&"opacity-50 cursor-wait"),children:[F&&e.jsxs("svg",{className:"animate-spin h-4 w-4 mr-2",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"})]}),"Browse Local File"]}),e.jsx("input",{type:"file",className:"hidden",onChange:ee,accept:u,disabled:F})]})]})})}]})})]})};function Le({value:t,onChange:n,onListFolders:s,disabled:r,size:l="md",placeholder:o,templatePlaceholder:u,showTemplate:b=!0}){const[p,g]=d.useState([]);d.useEffect(()=>{let a=!0;return Promise.resolve(s?.()).then(m=>{a&&m&&g(m.data??[])}).catch(()=>{}),()=>{a=!1}},[]);const x=t??{};return e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsx(le,{size:l,fullWidth:!0,value:x.folderId??"",options:p.map(a=>({value:a.id,label:a.name})),placeholder:o??"Select a folder",onChange:a=>n?.({...x,folderId:a})}),b&&e.jsx(ne,{size:l,disabled:r??!1,value:x.pathTemplate??"",placeholder:u??"Sub-path e.g. {yyyy}/{mm}/{dd} (optional)",onChange:a=>n?.({...x,pathTemplate:a.target.value})})]})}function ye(t,n){return n.split(".").reduce((s,r)=>s&&typeof s=="object"&&r in s?s[r]:void 0,t)}function xt(t,n,s){const r=n.split("."),l=Array.isArray(t)?[...t]:{...t};let o=l;for(let u=0;u<r.length-1;u++){const b=r[u],p=o[b];o[b]=p&&typeof p=="object"?Array.isArray(p)?[...p]:{...p}:{},o=o[b]}return o[r[r.length-1]]=s,l}function ft(t,n){const s=n.split("."),r=Array.isArray(t)?[...t]:{...t};let l=r;for(let o=0;o<s.length-1;o++){const u=s[o];if(!l[u]||typeof l[u]!="object")return r;l[u]=Array.isArray(l[u])?[...l[u]]:{...l[u]},l=l[u]}return delete l[s[s.length-1]],r}const ht=({groups:t,data:n,onSubmit:s,onCancel:r,onChange:l,transform:o,validate:u,submitButton:b={label:"Submit",variant:"primary"},cancelButton:p={label:"Cancel",variant:"outline"},showButtons:g=!0,layout:x="vertical",size:a="md",loading:m=!1,className:f,ref:N,sdk:w})=>{const[v,I]=d.useState(n||{}),[j,H]=d.useState({}),[B,q]=d.useState({});d.useEffect(()=>{n&&I({...n})},[n]);const F=d.useCallback((i,y,E)=>{const C=t.flatMap(L=>L.items).find(L=>L.name===i);if(!C)return null;if(C.required&&(y==null||y===""))return`${C.label} is required`;if(C.type==="array"){if(C.required&&(!y||y.length===0))return`${C.label} cannot be empty.`;if(y&&!Array.isArray(y))return`${C.label} must be an array.`;if(Array.isArray(y)&&C.arrayFields){const L=[];let S=!1;if(y.forEach((Z,ee)=>{const Y={};for(const M of C.arrayFields){const A=Z?.[M.name];if(M.required&&(A==null||A===""))Y[M.name]=`${M.label} is required`,S=!0;else if(M.validator){const T=M.validator(A,Z);T&&(Y[M.name]=T,S=!0)}}L[ee]=Y}),S)return JSON.stringify(L)}}return C.validator?C.validator(y,E):null},[t]),z=d.useCallback((i,y)=>{let E=xt(v,i,y);t.flatMap(S=>S.items).find(S=>S.name===i)?.removeIfEmpty&&(y==null||y==="")&&(E=ft(E,i)),I(E),q(S=>({...S,[i]:!0}));const L=F(i,y,E);H(S=>({...S,[i]:L||""})),l?.(E,i)},[v,t,F,l]),W=d.useCallback(async i=>{if(console.log("handleSubmit"),i.preventDefault(),m)return;const y={},E=t.flatMap(L=>L.items);for(const L of E){if(L.hidden||L.conditional&&!L.conditional(v))continue;const S=F(L.name,ye(v,L.name),v);S&&(y[L.name]=S)}if(u){const L=u(v);L&&Object.assign(y,L)}if(H(y),console.log("newErrors",y),Object.keys(y).some(L=>y[L]))return;const C=o?o(v):v;await s?.(v,C)},[v,t,F,u,o,s,m]),$=d.useCallback(i=>{const y=ye(v,i.name),E=B[i.name]?j[i.name]:void 0,C=i.disabled||m,L={value:y||"",disabled:C,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(ne,{...L,onChange:S=>z(i.name,S.target.value),type:i.textType||i.type,autoComplete:i.autocomplete,error:E,size:a});case"textarea":return e.jsx(de,{...L,onChange:S=>z(i.name,S.target.value),rows:4,error:E,size:a});case"select":return e.jsx(le,{...L,onChange:S=>z(i.name,S),options:(i.options||[]).map(S=>({...S,value:String(S.value)})),searchable:i.searchable,multiple:i.multiple,allowCreate:i.allowCreate,error:E,size:a});case"checkbox":return e.jsx(ce,{...L,checked:!!y,onChange:S=>z(i.name,S.target.checked),size:a});case"radio":return e.jsx("div",{className:"space-y-1",children:i.options?.map(S=>e.jsxs("label",{className:"flex items-center gap-2",children:[e.jsx("input",{type:"radio",name:i.name,value:S.value,checked:y===S.value,onChange:()=>z(i.name,S.value),disabled:C||S.disabled,className:"rounded-full border-neutral-100 dark:border-neutral-600"}),e.jsx(K,{variant:"label",size:"sm",children:S.label})]},S.value))});case"date":return e.jsx(ie,{...L,value:y?new Date(y):null,onChange:S=>z(i.name,S),size:a});case"file":return e.jsx(Ee,{...L,value:y,onChange:S=>z(i.name,S),error:E,onListFiles:S=>w?.http.invoke({method:"POST",action:"storage.file.list",body:S}),onListMounts:()=>w?.http.invoke({method:"GET",action:"storage.mount"}),onUploadFile:S=>w?.http.invoke({method:"POST",action:"storage.file.upload",body:S}),onDownloadFile:S=>w?.http.invoke({method:"GET",action:`storage.file.${S}.download`}),onRegisterFile:S=>w?.http.invoke({method:"POST",action:"storage.file.folder",body:S})});case"folder":return e.jsx(Le,{value:y||{},onChange:S=>z(i.name,S),onListFolders:()=>w?.http.invoke({method:"GET",action:"storage.mount"}),disabled:C,size:a,placeholder:i.placeholder});case"custom":return i.customComponent?.({value:y,onChange:S=>z(i.name,S),error:E,disabled:C});case"array":{const S=y||[];let Z=[];if(typeof E=="string"&&E.startsWith("["))try{Z=JSON.parse(E)}catch{}const ee=()=>{z(i.name,[...S,{}])},Y=A=>{z(i.name,S.filter((T,D)=>D!==A))},M=(A,T,D)=>{const X=[...S];X[A]={...X[A],[T]:D},z(i.name,X)};return e.jsxs("div",{className:"space-y-2",children:[S.map((A,T)=>e.jsxs("div",{className:"p-4 border rounded-md dark:border-neutral-700 space-y-2 relative",children:[e.jsx("div",{className:"absolute top-2 right-2",children:e.jsx(Q,{type:"button",variant:"ghost",size:"sm",onClick:()=>Y(T),disabled:C,children:"Remove"})}),e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:i.arrayFields?.map(D=>{const X=Z?.[T]?.[D.name];return e.jsxs("div",{className:"space-y-1",children:[e.jsx("label",{className:"block",children:e.jsxs(K,{variant:"label",size:"sm",className:"font-semibold text-neutral-700 dark:text-neutral-300",children:[D.label,D.required&&e.jsx("span",{className:"text-red-500 ml-1",children:"*"})]})}),(()=>{const te={value:A?.[D.name]||"",disabled:C,required:D.required,placeholder:D.placeholder,...D.fieldProps};switch(D.type){case"text":case"email":case"password":case"number":case"tel":case"url":return e.jsx(ne,{...te,onChange:G=>M(T,D.name,G.target.value),type:D.textType||D.type,autoComplete:D.autocomplete,error:X,size:a});case"textarea":return e.jsx(de,{...te,onChange:G=>M(T,D.name,G.target.value),rows:4,error:X,size:a});case"select":return e.jsx(le,{...te,onChange:G=>M(T,D.name,G),options:(D.options||[]).map(G=>({...G,value:String(G.value)})),searchable:D.searchable,multiple:D.multiple,allowCreate:D.allowCreate,error:X,size:a});case"checkbox":return e.jsx(ce,{...te,checked:!!A?.[D.name],onChange:G=>M(T,D.name,G.target.checked),size:a});case"radio":return e.jsx("div",{className:"space-y-1",children:D.options?.map(G=>e.jsxs("label",{className:"flex items-center gap-2",children:[e.jsx("input",{type:"radio",name:`${i.name}.${T}.${D.name}`,value:G.value,checked:A?.[D.name]===G.value,onChange:()=>M(T,D.name,G.value),disabled:C||G.disabled,className:"rounded-full border-neutral-100 dark:border-neutral-600"}),e.jsx(K,{variant:"label",size:"sm",children:G.label})]},G.value))});case"date":{const G=A?.[D.name];return e.jsx(ie,{...te,value:G?new Date(G):null,onChange:se=>M(T,D.name,se),size:a})}case"custom":return D.customComponent?.({value:A?.[D.name],onChange:G=>M(T,D.name,G),error:X,disabled:C});default:return e.jsxs("p",{children:["Unsupported field type in array:"," ",D.type]})}})(),X&&e.jsx(K,{variant:"body",size:"sm",className:"text-red-600 dark:text-red-400",children:X})]},D.name)})})]},T)),e.jsxs(Q,{type:"button",variant:"outline",size:"sm",onClick:ee,disabled:C,children:["Add ",i.label]})]})}default:return null}},[v,B,j,m,a,z]),_=d.useCallback(i=>{if(i.conditional&&!i.conditional(v))return null;const y=i.items.filter(C=>!(C.hidden||C.conditional&&!C.conditional(v)));if(y.length===0)return null;const E=h("space-y-2",{"grid gap-2":i.layout==="grid","flex flex-wrap gap-2":i.layout==="flex"},i.layout==="grid"&&{"grid-cols-1":!i.columns||i.columns===1,"grid-cols-2":i.columns===2,"grid-cols-3":i.columns===3,"grid-cols-4":i.columns===4},i.className);return e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-8 p-6 border border-neutral dark:border-neutral-700 rounded-xl",children:[e.jsxs("div",{className:"md:col-span-1",children:[e.jsx(K,{variant:"label",size:"lg",weight:"semibold",className:"text-neutral-900 dark:text-neutral-100",children:i.title}),i.description&&e.jsx(K,{variant:"body",size:"sm",className:"text-neutral-600 dark:text-neutral-400 mt-1",children:i.description})]}),e.jsx("div",{className:"md:col-span-2",children:e.jsx("div",{className:E,children:y.map(C=>(B[C.name]&&j[C.name],e.jsxs("div",{className:h("space-y-1",C.width&&typeof C.width=="string"&&`w-[${C.width}]`,C.width&&typeof C.width=="number"&&`col-span-${C.width}`),children:[C.type!=="custom"&&e.jsx("label",{className:"block",children:e.jsxs(K,{variant:"label",size:"sm",className:"font-medium text-neutral-700 dark:text-neutral-300",children:[C.label,C.required&&e.jsx("span",{className:"text-red-500 ml-1",children:"*"})]})}),$(C)]},C.name)))})})]},i.id)},[v,B,j,$]),O=h("space-y-6",{"max-w-md":a==="sm","max-w-2xl":a==="md","max-w-4xl":a==="lg","max-w-full":a==="full"},f);return e.jsxs("form",{ref:N,onSubmit:W,className:O,children:[e.jsx("div",{className:"space-y-8",children:t.map(_)}),g&&e.jsxs("div",{className:h("flex gap-3 justify-end pt-8"),children:[r&&e.jsx(Q,{type:"button",variant:p.variant,size:p.size||a,disabled:p.disabled||m,onClick:r,className:p.className,children:p.label}),e.jsx(Q,{type:"submit",variant:b.variant,size:b.size||a,disabled:b.disabled||m,loading:m,className:b.className,children:b.label})]})]})},pt=({trigger:t,children:n,placement:s="bottom-start",className:r,disabled:l=!1})=>{const[o,u]=d.useState(!1),[b,p]=d.useState({}),g=d.useRef(null),x=d.useRef(null);d.useEffect(()=>{if(!o)return;const f=w=>{g.current&&!g.current.contains(w.target)&&u(!1)},N=w=>{w.key==="Escape"&&u(!1)};return document.addEventListener("mousedown",f),document.addEventListener("keydown",N),()=>{document.removeEventListener("mousedown",f),document.removeEventListener("keydown",N)}},[o]);const a=f=>{if(f.stopPropagation(),!l){if(!o){const N=x.current?.getBoundingClientRect();if(N){const v={};s.startsWith("bottom")?v.top=N.bottom+6:v.bottom=window.innerHeight-N.top+6,s.endsWith("start")?v.left=N.left:v.right=window.innerWidth-N.right,p(v)}}u(N=>!N)}},m=()=>u(!1);return e.jsxs("div",{ref:g,className:"relative inline-flex",children:[e.jsx("button",{ref:x,type:"button",onClick:a,disabled:l,className:h("inline-flex items-center",l&&"opacity-50 cursor-not-allowed"),children:t}),o&&e.jsx("div",{className:h("fixed z-[60] bg-module rounded-lg shadow-lg border border-neutral",r),style:b,children:typeof n=="function"?n(m):n})]})},bt={default:"bg-neutral-container text-default",primary:"bg-accent-container text-accent",secondary:"bg-neutral-container text-muted",success:"bg-success-container text-success",warning:"bg-notice-container text-on-notice",error:"bg-error-container text-error",info:"bg-beta-container text-link"},gt={sm:"px-2 py-0.5 text-xs",md:"px-2.5 py-1 text-sm",lg:"px-3 py-1.5 text-base"},yt={default:"bg-neutral-fill",primary:"bg-accent-fill",secondary:"bg-neutral-fill",success:"bg-success-fill",warning:"bg-notice-fill",error:"bg-error-fill",info:"bg-beta-fill"};function vt({variant:t="default",size:n="md",dot:s=!1,icon:r,dismissible:l=!1,onDismiss:o,className:u,children:b,...p}){return e.jsxs("span",{className:h("inline-flex items-center font-medium rounded-full",bt[t],gt[n],u),...p,children:[s&&e.jsx("span",{className:h("w-2 h-2 rounded-full mr-1.5",yt[t])}),r&&e.jsx("span",{className:h("flex-shrink-0",b&&"mr-1"),children:r}),b,l&&o&&e.jsx("button",{onClick:o,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 jt={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"},Nt={primary:"text-primary",secondary:"text-secondary-600",white:"text-white",current:"text-current"},wt={xs:"text-xs",sm:"text-sm",md:"text-sm",lg:"text-base",xl:"text-lg"};function kt({size:t="md",variant:n="primary",label:s="Loading...",showLabel:r=!1,className:l,...o}){return e.jsxs("div",{className:h("inline-flex items-center",r?"flex-col space-y-2":"",l),...o,children:[e.jsxs("svg",{className:h("animate-spin",jt[t],Nt[n]),fill:"none",viewBox:"0 0 24 24","aria-hidden":!r,role:r?"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"})]}),r&&e.jsx("span",{className:h("text-secondary-600 dark:text-secondary-400",wt[t]),children:s}),!r&&e.jsx("span",{className:"sr-only",children:s})]})}const Ct={xs:"w-5 h-5 text-[10px]",sm:"w-6 h-6 text-xs",md:"w-7 h-7 text-[13px]",lg:"w-9 h-9 text-sm"};function St(t){if(!t)return"?";const n=t.trim().split(/[^\p{L}\p{N}]+/u).filter(Boolean);return n.length>=2?(n[0][0]+n[1][0]).toUpperCase():n.length===1?n[0].slice(0,2).toUpperCase():"?"}const Me=({name:t,src:n,size:s="sm",className:r,title:l})=>{const[o,u]=d.useState(!1),b=h("inline-flex items-center justify-center rounded-full overflow-hidden shrink-0 font-semibold select-none bg-neutral-border-emphasis text-default",Ct[s],r);return n&&!o?e.jsx("img",{src:n,alt:t??"",title:l??t,className:h(b,"object-cover"),onError:()=>u(!0)}):e.jsx("span",{className:b,title:l??t,"aria-label":t,children:St(t)})},ve="shadow-[0_0_0_2px_var(--base-module)]",Et="shadow-[0_0_0_2px_var(--base-module),0_0_0_3.5px_var(--accent-border)]",Lt=({people:t,max:n=4,size:s="sm",className:r})=>{if(t.length===0)return null;const l=t.slice(0,n),o=t.length-l.length;return e.jsxs("span",{className:h("inline-flex items-center",r),children:[l.map((u,b)=>e.jsx(Me,{name:u.name,src:u.src,size:s,title:u.name?u.seen===!1?`${u.name} — nog niet gelezen`:u.name:void 0,className:h(b>0&&"-ml-2",u.owner?Et:ve,u.seen===!1&&"opacity-40")},u.id??`${u.name}-${b}`)),o>0&&e.jsxs("span",{className:h("inline-flex items-center justify-center rounded-full shrink-0 -ml-2 font-semibold bg-neutral-container text-muted",s==="xs"?"w-5 h-5 text-[10px]":s==="md"?"w-7 h-7 text-[11px]":s==="lg"?"w-9 h-9 text-xs":"w-6 h-6 text-[10px]",ve),children:["+",o]})]})},Mt=({src:t,alt:n,size:s="md",aspectRatio:r="auto",radius:l="md",showLoading:o=!0,showError:u=!0,fallback:b,loadingContent:p,errorContent:g,className:x,onLoad:a,onError:m,...f})=>{const[N,w]=d.useState(!0),[v,I]=d.useState(!1),[j,H]=d.useState(t),B=O=>{w(!1),I(!1),a?.(O)},q=O=>{if(w(!1),I(!0),b&&j!==b){H(b),I(!1),w(!0);return}m?.(O)},F=h("relative overflow-hidden bg-neutral-100 dark:bg-neutral-800",{"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":r==="square","aspect-video":r==="video","aspect-[3/4]":r==="portrait","aspect-[4/3]":r==="landscape"},{"rounded-none":l==="none","rounded-sm":l==="sm","rounded-md":l==="md","rounded-lg":l==="lg","rounded-xl":l==="xl","rounded-full":l==="full"},x),z=h("w-full h-full object-cover transition-opacity duration-200",{"opacity-0":N||v,"opacity-100":!N&&!v}),W=h("absolute inset-0 flex items-center justify-center","text-neutral-400 dark:text-neutral-500"),$=e.jsx("div",{className:"animate-pulse",children:e.jsx("div",{className:"w-6 h-6 bg-neutral-300 dark:bg-neutral-600 rounded"})}),_=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:F,children:[e.jsx("img",{...f,src:j,alt:n,className:z,onLoad:B,onError:q}),N&&o&&e.jsx("div",{className:W,children:p||$}),v&&u&&e.jsx("div",{className:W,children:g||_})]})},Tt=({title:t,subtitle:n,actions:s=[],children:r,className:l,backLabel:o="Back",backClassName:u,onBack:b,editable:p=!1,onTitleChange:g})=>{const[x,a]=d.useState(!1),[m,f]=d.useState(t),N=d.useRef(null);d.useEffect(()=>{f(t)},[t]),d.useEffect(()=>{x&&N.current&&(N.current.focus(),N.current.select())},[x]);const w=()=>{p&&a(!0)},v=()=>{a(!1),m.trim()!==""&&m!==t&&g?g(m.trim()):f(t)},I=j=>{j.key==="Enter"?N.current?.blur():j.key==="Escape"&&(f(t),a(!1))};return e.jsxs("div",{className:h("p-5 pb-3 border-b border-neutral",l),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-default",children:[b&&e.jsx("button",{type:"button",onClick:b,className:h("flex items-center text-sm cursor-pointer transition",u),children:e.jsx(U.ArrowLeft,{size:16,color:"currentColor"})}),x?e.jsx("input",{ref:N,type:"text",value:m,onChange:j=>f(j.target.value),onBlur:v,onKeyDown:I,className:"text-1xl font-semibold bg-transparent border-b-1 border-neutral rounded-lg outline-none focus:border-none px-1 -mx-1 min-w-0 flex-1"}):e.jsxs("div",{className:"group flex items-center gap-1.5 min-w-0",children:[e.jsx("h2",{onClick:w,className:h("text-2xl font-semibold truncate",p&&"cursor-pointer"),title:p?"Klik om te bewerken":void 0,children:t}),p&&e.jsx(U.Pencil,{size:15,onClick:w,className:"shrink-0 cursor-pointer 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(j=>j.splitOptions&&j.splitOptions.length>0?e.jsx(pe,{label:j.label,onClick:j.onClick,icon:j.icon,variant:j.variant==="primary"?"primary":"secondary",options:j.splitOptions,disabled:j.disabled},j.id):e.jsxs("button",{type:"button",onClick:H=>{H.stopPropagation(),H.target.blur(),j.onClick()},disabled:j.disabled,className:h("btn",{o__primary:j.variant==="primary",o__secondary:j.variant==="secondary"||j.variant==="outline",o__ghost:j.variant==="ghost",o__destructive:j.variant==="destructive"}),children:[j.icon&&e.jsx("span",{className:"mr-2",children:j.icon}),j.label]},j.id))})]}),r&&e.jsx("div",{className:"mt-4",children:r})]})},$t=({actions:t=[],onBack:n,backLabel:s="Back",className:r,children:l})=>e.jsxs("div",{className:h("flex items-center gap-2 mb-3",r),children:[n&&e.jsxs("button",{type:"button",onClick:n,className:"flex items-center gap-1 text-sm text-neutral-700 dark:text-neutral-300 hover:text-neutral-900 dark:hover:text-neutral-100 cursor-pointer transition px-2 py-1 rounded",children:[e.jsx(U.ArrowLeft,{size:16}),e.jsx("span",{children:s})]}),l&&e.jsx("div",{className:"flex-1 min-w-0",children:l}),t.length>0&&e.jsx("div",{className:h("flex flex-wrap gap-2",!l&&"ml-auto"),children:t.map(o=>o.splitOptions&&o.splitOptions.length>0?e.jsx(pe,{label:o.label,onClick:o.onClick,icon:o.icon,variant:o.variant==="primary"?"primary":"secondary",options:o.splitOptions,disabled:o.disabled},o.id):e.jsxs("button",{type:"button",onClick:u=>{u.stopPropagation(),u.target.blur(),o.onClick()},disabled:o.disabled,className:h("btn",{o__primary:o.variant==="primary",o__secondary:o.variant==="secondary"||o.variant==="outline",o__ghost:o.variant==="ghost",o__destructive:o.variant==="destructive"}),children:[o.icon&&e.jsx("span",{className:"mr-2",children:o.icon}),o.label]},o.id))})]});function Dt(t,n){return n.split(".").reduce((s,r)=>s&&typeof s=="object"&&r in s?s[r]:void 0,t)}const zt=({groups:t,data:n,size:s="md",className:r})=>{const l=x=>{if(!x)return"-";try{return new Date(x).toLocaleDateString("nl-NL",{year:"numeric",month:"long",day:"numeric"})}catch{return String(x)}},o=x=>x?"Ja":"Nee",u=(x,a)=>{if(!a)return String(x||"-");const m=a.find(f=>f.value===x);return m?m.label:String(x||"-")},b=d.useCallback(x=>{const a=Dt(n,x.name);if(x.type==="array"){const f=a;return!f||f.length===0?e.jsx(K,{variant:"body",size:"sm",className:"text-neutral-500 dark:text-neutral-400",children:"Geen items"}):e.jsx("div",{className:"space-y-3",children:f.map((N,w)=>e.jsxs("div",{className:"p-4 border border-neutral-200 dark:border-neutral-700 rounded-lg space-y-3",children:[e.jsx("div",{className:"flex items-center justify-between",children:e.jsxs(K,{variant:"label",size:"sm",weight:"medium",className:"text-neutral-700 dark:text-neutral-300",children:[x.label," ",w+1]})}),e.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-3",children:x.arrayFields?.map(v=>{const I=N?.[v.name];let j="-";switch(v.type){case"text":case"email":case"number":case"tel":case"url":case"textarea":j=I||"-";break;case"select":case"radio":j=u(I,v.options);break;case"checkbox":j=o(I);break;case"date":j=l(I);break;case"custom":j=v.customComponent?.({value:I});break;default:j=String(I||"-")}return v.format&&(j=v.format(I,N)),e.jsxs("div",{className:"space-y-1",children:[e.jsx(K,{variant:"label",size:"xs",className:"text-neutral-600 dark:text-neutral-400",children:v.label}),e.jsx(K,{variant:"body",size:"sm",className:"text-neutral-900 dark:text-neutral-100",children:j})]},v.name)})})]},w))})}if(x.type==="custom"&&x.customComponent)return x.customComponent({value:a});if(x.format){const f=x.format(a,n);return e.jsx(K,{variant:"body",size:"sm",className:"text-neutral-900 dark:text-neutral-100",children:f})}let m="-";switch(x.type){case"text":case"email":case"password":case"number":case"tel":case"url":m=a?String(a):"-";break;case"textarea":m=a?e.jsx("div",{className:"whitespace-pre-wrap",children:String(a||"-")}):"-";break;case"select":case"radio":m=u(a,x.options);break;case"checkbox":m=o(a);break;case"date":m=l(a);break;default:m=a?String(a):"-"}return e.jsx(K,{variant:"body",size:"sm",className:"text-neutral-900 dark:text-neutral-100",children:m})},[n]),p=d.useCallback(x=>{if(x.conditional&&!x.conditional(n))return null;const a=x.items.filter(f=>!(f.hidden||f.conditional&&!f.conditional(n)));if(a.length===0)return null;const m=h("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-neutral dark:border-neutral-700 rounded-xl",children:[e.jsxs("div",{className:"md:col-span-1",children:[e.jsx(K,{variant:"label",size:"lg",weight:"semibold",className:"text-neutral-900 dark:text-neutral-100",children:x.title}),x.description&&e.jsx(K,{variant:"body",size:"sm",className:"text-neutral-600 dark:text-neutral-400 mt-1",children:x.description})]}),e.jsx("div",{className:"md:col-span-2",children:e.jsx("div",{className:m,children:a.map(f=>e.jsxs("div",{className:h("space-y-1",f.width&&typeof f.width=="string"&&`w-[${f.width}]`,f.width&&typeof f.width=="number"&&`col-span-${f.width}`),children:[f.type!=="custom"&&e.jsx(K,{variant:"label",size:"sm",className:"font-medium text-neutral-700 dark:text-neutral-300",children:f.label}),b(f)]},f.name))})})]},x.id)},[n,b]),g=h("space-y-6",{"max-w-md":s==="sm","max-w-2xl":s==="md","max-w-4xl":s==="lg","max-w-full":s==="full"},r);return e.jsx("div",{className:g,children:e.jsx("div",{className:"space-y-8",children:t.map(p)})})},Te=({item:t,isSelectedHandler:n,onClick:s,depth:r=0})=>{const[l,o]=d.useState(t.defaultCollapsed??!1),u=t.children&&t.children.length>0,b=u&&r===0,p=()=>{u&&o(!l)},g=n?n(t.path):!1;return e.jsxs("li",{children:[e.jsxs("div",{className:h("flex flex-row w-full py-1 rounded-lg items-center h-8 transition-colors cursor-pointer px-3 pr-1 no-underline text-sm",{"active-nav-item":g&&!u,"shadow-lvl-0":g&&!u,"font-semibold":g||b}),onClick:()=>{u?p():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}),u&&e.jsx("span",{className:`${l?"collapsed":""}`,children:e.jsx(U.ChevronDownIcon,{className:"w-4 h-4 text-muted"})})]}),u&&!l&&e.jsx("ul",{className:"sidebar-menu-nested-items mb-1",children:t.children?.map((x,a)=>e.jsx(Te,{item:x,isSelectedHandler:n,onClick:s,depth:r+1},a))})]})},At=({title:t,actionIcons:n,items:s,isSelectedHandler:r,onClick:l,preMenuItemsComponent:o})=>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-xl font-semibold text-default mb-2",children:t}),e.jsx("div",{className:"sidebar-menu-actions",children:n?.map((u,b)=>e.jsx("span",{className:"sidebar-menu-action-icon",children:u},b))})]}),o&&e.jsx("div",{className:"sidebar-menu-pre-items mb-4",children:o}),e.jsx("ul",{children:s.map((u,b)=>!u.path&&!u.label&&!u.children?e.jsx("span",{className:"flex w-full h-4"},b):e.jsx(Te,{item:u,isSelectedHandler:r,onClick:l},b))})]}),It=({level:t=1,size:n,weight:s="bold",color:r="current",align:l="left",truncate:o=!1,className:u,children:b,...p})=>{const g=n||Pt(t),x=h("font-primary",{"text-xs":g==="xs","text-sm":g==="sm","text-base":g==="md","text-lg":g==="lg","text-xl":g==="xl","text-2xl":g==="2xl","text-3xl":g==="3xl","text-4xl":g==="4xl"},{"font-light":s==="light","font-normal":s==="normal","font-medium":s==="medium","font-semibold":s==="semibold","font-bold":s==="bold"},{"text-primary":r==="primary","text-secondary":r==="secondary","text-[var(--text-accent)]":r==="accent","text-[var(--text-success)]":r==="success","text-warning":r==="warning","text-[var(--text-error)]":r==="error","text-info":r==="info","text-[var(--text-default)]":r==="neutral","text-current":r==="current"},{"text-left":l==="left","text-center":l==="center","text-right":l==="right"},{truncate:o},u),a=`h${t}`;return e.jsx(a,{className:x,...p,children:b})};function Pt(t){return{1:"4xl",2:"3xl",3:"2xl",4:"xl",5:"lg",6:"md"}[t]||"md"}const Bt=({items:t,type:n="unordered",variant:s="default",size:r="md",interactive:l=!1,className:o,itemClassName:u})=>{const b=h("space-y-1",{"":s==="default","space-y-0":s==="flush","border border-neutral-200 dark:border-neutral-700 rounded-lg overflow-hidden":s==="bordered","divide-y divide-neutral-200 dark:divide-neutral-700":s==="divided"},{"text-sm":r==="sm","text-base":r==="md","text-lg":r==="lg"},o),p=(a,m)=>h("transition-colors duration-200",{"py-1 px-2":r==="sm"&&(s==="bordered"||s==="divided"),"py-2 px-3":r==="md"&&(s==="bordered"||s==="divided"),"py-3 px-4":r==="lg"&&(s==="bordered"||s==="divided")},l&&!a.disabled&&{"cursor-pointer hover:bg-neutral-50 dark:hover:bg-neutral-800":!0,"focus:outline-none focus:bg-neutral-100 dark:focus:bg-neutral-700":!0},a.disabled&&{"opacity-50 cursor-not-allowed":!0},u),g=a=>{l&&!a.disabled&&a.onClick&&a.onClick()},x=(a,m)=>{l&&!m.disabled&&(a.key==="Enter"||a.key===" ")&&(a.preventDefault(),m.onClick?.())};return n==="ordered"?e.jsx("ol",{className:b,children:t.map((a,m)=>e.jsx("li",{className:p(a),onClick:()=>g(a),onKeyDown:f=>x(f,a),tabIndex:l&&!a.disabled?0:void 0,role:l?"button":void 0,children:a.content},a.id||m))}):n==="description"?e.jsx("dl",{className:b,children:t.map((a,m)=>e.jsx("div",{className:p(a),onClick:()=>g(a),onKeyDown:f=>x(f,a),tabIndex:l&&!a.disabled?0:void 0,role:l?"button":void 0,children:a.content},a.id||m))}):e.jsx("ul",{className:b,children:t.map((a,m)=>e.jsx("li",{className:p(a),onClick:()=>g(a),onKeyDown:f=>x(f,a),tabIndex:l&&!a.disabled?0:void 0,role:l?"button":void 0,children:a.content},a.id||m))})},Rt=({commands:t,isOpen:n,onClose:s,labels:r,initialCommandPath:l,initialActiveIndex:o})=>{const[u,b]=d.useState(""),[p,g]=d.useState(l||[]),[x,a]=d.useState(o||0),m=d.useRef(null),f=d.useRef(null),w=(p.length?t.find(v=>v.id===p[0])?.subCommands||[]:t).filter(v=>v.label.toLowerCase().includes(u.toLowerCase()));return d.useEffect(()=>{n||(b(""),g(l||[]),a(o||0))},[n]),d.useEffect(()=>{const v=I=>{if(n){if(I.key==="Escape")s();else if(I.key==="ArrowUp")a(j=>j>0?j-1:w.length-1);else if(I.key==="ArrowDown")a(j=>j<w.length-1?j+1:0);else if(I.key==="Enter"){const j=w[x];j&&(j.subCommands?(g([...p,j.id]),a(0)):j.action&&(j.action(),s()))}}};return document.addEventListener("keydown",v),()=>document.removeEventListener("keydown",v)},[n,s,w,x,p]),d.useEffect(()=>{const v=I=>{m.current&&!m.current.contains(I.target)&&s()};return n&&document.addEventListener("mousedown",v),()=>document.removeEventListener("mousedown",v)},[n,s]),d.useEffect(()=>{if(!n)return;f.current?.querySelector(`[data-index="${x}"]`)?.scrollIntoView({block:"nearest"})},[x,n]),n?e.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center shadow-lvl-0",children:e.jsxs("div",{className:"flex flex-col w-full max-w-lg max-h-[80vh] p-2 mx-auto rounded-xl border border-neutral shadow-lg bg-module",ref:m,children:[e.jsxs("div",{className:"flex items-center gap-2 px-3 flex-shrink-0",children:[e.jsx(U.Search,{className:"w-4 h-4 text-muted shrink-0"}),e.jsx("input",{type:"text",autoFocus:!0,placeholder:r?.searchPlaceholder||"Search commands...",value:u,onChange:v=>b(v.target.value),className:"w-full py-2 text-default border-0 focus:outline-none focus:ring-0 focus:border-0 focus:shadow-none bg-transparent"})]}),e.jsxs("div",{ref:f,className:"mt-2 pt-2 text-sm border-t border-neutral max-h-[50vh] overflow-y-auto",children:[w.length===0&&e.jsx("div",{className:"text-muted text-center text-sm",children:r?.noCommandsFound||"No commands found"}),w.map((v,I)=>e.jsxs("div",{"data-index":I,className:`flex items-center p-2 cursor-pointer rounded-md text-default ${I===x?"bg-neutral-container":""}`,onClick:()=>{v.subCommands?(g([...p,v.id]),a(0)):v.action&&(v.action(),s())},onMouseEnter:()=>a(I),children:[v.icon&&e.jsx("span",{className:"mr-3",children:v.icon}),e.jsx("span",{className:"flex-grow",children:v.label}),v.subCommands&&e.jsx("span",{className:"text-muted",children:e.jsx(U.ChevronRight,{className:"w-4 h-4"})})]},v.id))]}),e.jsxs("div",{className:"flex items-center gap-4 px-3 pt-2 mt-2 text-xs text-muted border-t border-neutral",children:[e.jsxs("span",{className:"flex items-center gap-1.5",children:[e.jsx("kbd",{className:"inline-flex items-center justify-center min-w-[1.25rem] px-1 py-0.5 rounded border border-neutral bg-module-subtle text-[10px] font-medium not-italic",children:"↑↓"}),r?.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-[1.25rem] px-1 py-0.5 rounded border border-neutral bg-module-subtle text-[10px] font-medium not-italic",children:"↵"}),r?.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-[1.25rem] px-1 py-0.5 rounded border border-neutral bg-module-subtle text-[10px] font-medium not-italic",children:"Esc"}),r?.close||"to close"]})]})]})}):null},_t={none:"p-0",xs:"p-1",sm:"p-2",md:"p-4",lg:"p-6",xl:"p-8","2xl":"p-12"},Ft={none:"m-0",xs:"m-1",sm:"m-2",md:"m-4",lg:"m-6",xl:"m-8","2xl":"m-12"},Ot={none:"",primary:"bg-primary",secondary:"bg-secondary",accent:"bg-accent",success:"bg-success",warning:"bg-warning",error:"bg-error",info:"bg-info",neutral:"bg-neutral",white:"bg-white",module:"bg-module","module-subtle":"bg-module-subtle",backdrop:"bg-backdrop",editor:"bg-editor",input:"bg-input"},Vt={none:"rounded-none",sm:"rounded-sm",md:"rounded-md",lg:"rounded-lg",xl:"rounded-xl",full:"rounded-full"},Wt={none:"shadow-none",sm:"shadow-sm shadow-lvl-0",md:"shadow-md shadow-lvl-0",lg:"shadow-lg shadow-lvl-0",xl:"shadow-xl shadow-lvl-0","2xl":"shadow-2xl shadow-lvl-0"},Ht={none:"border-0",sm:"border",md:"border-2",lg:"border-4"},qt={primary:"border-primary",secondary:"border-secondary",accent:"border-accent",success:"border-success",warning:"border-warning",error:"border-error",info:"border-info",neutral:"border-neutral",white:"border-white"},be=d.forwardRef(({padding:t,margin:n,background:s,radius:r,shadow:l,border:o,borderColor:u,className:b,children:p,...g},x)=>e.jsx("div",{ref:x,className:h(t&&_t[t],n&&Ft[n],s&&Ot[s],r&&Vt[r],l&&Wt[l],o&&Ht[o],u&&qt[u],b),...g,children:p}));be.displayName="Box";const Gt=({children:t,title:n,...s})=>e.jsxs(be,{background:"module",radius:"xl",shadow:"sm",...s,children:[n&&e.jsx("span",{className:"text-base font-medium text-default mb-2",children:n}),t]});function Ut({identifier:t,resourceLoader:n,framework:s="react",fallback:r,componentProps:l,className:o}){const u=d.useRef(null),[b,p]=d.useState(!0),[g,x]=d.useState(null),a=d.useRef(null);return d.useRef(null),d.useEffect(()=>{let m=!0;return(async()=>{p(!0);try{const N=await n();if(!m)return;const w=N.component||N.default||N;x(s==="react"?()=>w:()=>N)}catch(N){console.error(`[FederatedResource] Load failed: ${t}`,N)}finally{m&&p(!1)}})(),()=>{m=!1}},[t,n]),d.useEffect(()=>{if(b||!g||s==="react")return;const m=u.current;if(m){if(s==="svelte"){const f=g.default||g,N=new f({target:m,props:l||{}});return a.current=N,()=>N.$destroy()}if(g.mount){const f=g.mount({container:m,props:l||{}});return()=>{typeof f=="function"?f():g.unmount?.(m)}}}},[g,s,b]),d.useEffect(()=>{s==="svelte"&&a.current&&a.current.$set?.(l)},[l,s]),e.jsxs("div",{ref:u,className:o,style:{display:"contents"},children:[b&&r,s==="react"&&g&&e.jsx(g,{...l})]})}class Kt extends d.Component{constructor(){super(...arguments),this.state={hasError:!1,error:null}}static getDerivedStateFromError(n){return{hasError:!0,error:n}}componentDidCatch(n,s){console.error(`[ErrorBoundary] Error in ${this.props.name||"Component"}:`,n,s)}render(){return this.state.hasError?this.props.fallback?this.props.fallback:e.jsxs("div",{className:"p-4 m-4 border border-red-200 bg-red-50 rounded-lg",children:[e.jsx("h2",{className:"text-lg font-semibold text-red-800",children:"Something went wrong"}),e.jsx("p",{className:"text-sm text-red-600 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-red-100 text-red-800 rounded hover:bg-red-200 transition-colors text-sm",onClick:()=>this.setState({hasError:!1,error:null}),children:"Try again"})]}):this.props.children}}exports.Avatar=Me;exports.AvatarStack=Lt;exports.Badge=vt;exports.Box=be;exports.Button=Q;exports.ButtonGroup=Fe;exports.Card=Gt;exports.Checkbox=ce;exports.CommandPalette=Rt;exports.ContentLoading=Ne;exports.DatePicker=ie;exports.Dropdown=we;exports.ErrorBoundary=Kt;exports.FederatedResource=Ut;exports.FolderSelect=Le;exports.Form=ht;exports.Heading=It;exports.Icon=re;exports.Image=Mt;exports.Link=Oe;exports.List=Bt;exports.MeetingGrid=Ae;exports.Modal=Se;exports.PageHeader=Tt;exports.PageToolbar=$t;exports.ParticipantTile=Ie;exports.Popover=pt;exports.SearchableTextField=je;exports.Select=le;exports.SidebarMenu=At;exports.Spinner=kt;exports.SplitButton=pe;exports.StorageInput=Ee;exports.TabBar=dt;exports.Table=he;exports.Tabs=Ce;exports.Text=K;exports.TextArea=de;exports.TextField=ne;exports.VideoSurface=Pe;exports.View=zt;exports.cn=h;exports.createSizes=ze;exports.createVariants=De;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const $e=require("clsx"),e=require("react/jsx-runtime"),U=require("lucide-react"),u=require("react");function h(...t){return $e.clsx(t)}function De(t){return(n,s)=>t[n]?.[s]||""}function Ie(t){return n=>t[n]||""}function Ae({tiles:t,pinned:n,className:s}){if(n)return e.jsxs("div",{className:h("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:n}),t.length>0&&e.jsx("div",{className:"flex md:flex-col gap-2 md:w-48 overflow-auto",children:t.map((l,o)=>e.jsx("div",{className:"min-w-[160px] md:min-w-0",children:l},o))})]});const r=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:h("grid gap-2 h-full",r,s),children:t.map((l,o)=>e.jsx("div",{children:l},o))})}function ze({name:t,avatarUrl:n,muted:s,speaking:r,hasVideo:l,videoSlot:o,className:d,fill:p}){return e.jsxs("div",{className:h("relative rounded-lg overflow-hidden bg-gray-800 flex items-center justify-center",p?"h-full w-full":"aspect-video",r&&"ring-2 ring-emerald-400",d),children:[l&&o?e.jsx("div",{className:"absolute inset-0",children:o}):e.jsx("div",{className:"flex flex-col items-center gap-2 text-gray-300",children:n?e.jsx("img",{src:n,alt:t,className:"w-16 h-16 rounded-full object-cover"}):e.jsx("div",{className:"w-16 h-16 rounded-full bg-gray-700 flex items-center justify-center",children:l?e.jsx(U.VideoOff,{className:"w-8 h-8"}):e.jsx(U.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-black/50 text-white text-xs",children:[s?e.jsx(U.MicOff,{className:"w-3 h-3"}):e.jsx(U.Mic,{className:"w-3 h-3"}),e.jsx("span",{className:"truncate max-w-[140px]",children:t})]})]})}function Pe({attach:t,active:n=!0,mirrored:s=!1,className:r}){const l=u.useRef(null);return u.useEffect(()=>{if(!n||!l.current)return;const o=t(l.current);return()=>{typeof o=="function"&&o(),l.current&&(l.current.innerHTML="")}},[t,n]),e.jsx("div",{ref:l,className:h("w-full h-full bg-gray-900 overflow-hidden",s&&"[&>*]:scale-x-[-1]",r)})}const Be={primary:"btn o__primary",secondary:"btn o__secondary",outline:"btn o__secondary",ghost:"btn o__tertiary",destructive:"btn o__destructive"},Re={xs:"px-2 py-1 text-xs",sm:"px-3 py-1.5 text-sm",md:"px-4 py-2 text-sm",lg:"px-6 py-3 text-base",xl:"px-8 py-4 text-lg",full:"px-4 py-3 text-base"},_e={xs:"p-1",sm:"p-1.5",md:"p-2",lg:"p-3",xl:"p-4",full:"p-4"},Z=u.forwardRef(({variant:t="primary",size:n="md",fullWidth:s=!1,loading:r=!1,leftIcon:l,rightIcon:o,iconOnly:d=!1,className:p,children:b,disabled:g,...x},a)=>{const m=g||r;return e.jsxs("button",{ref:a,type:"button",className:h("inline-flex items-center justify-center transition-colors duration-200","disabled:opacity-50 disabled:cursor-not-allowed",Be[t],d?_e[n]:Re[n],s&&"w-full",r&&"cursor-wait",p),disabled:m,...x,children:[r&&e.jsxs("svg",{className:h("animate-spin",d?"h-4 w-4":"h-4 w-4 mr-2"),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"})]}),!r&&l&&e.jsx("span",{className:h("flex-shrink-0",!d&&"mr-2"),children:l}),!d&&b,!r&&o&&e.jsx("span",{className:h("flex-shrink-0",!d&&"ml-2"),children:o}),d&&!r&&!l&&!o&&b]})});Z.displayName="Button";const Fe=({children:t,size:n="md",orientation:s="horizontal",attached:r=!0,className:l})=>{const o=h("inline-flex",{"flex-row":s==="horizontal","flex-col":s==="vertical","[&>*:not(:first-child):not(:last-child)]:rounded-none":r,"[&>*:first-child]:rounded-r-none":r&&s==="horizontal","[&>*:last-child]:rounded-l-none":r&&s==="horizontal","[&>*:first-child]:rounded-b-none":r&&s==="vertical","[&>*:last-child]:rounded-t-none":r&&s==="vertical","[&>*:not(:first-child)]:-ml-px":r&&s==="horizontal","[&>*:not(:first-child)]:-mt-px":r&&s==="vertical","gap-1":!r&&n==="xs","gap-2":!r&&(n==="sm"||n==="md"),"gap-3":!r&&(n==="lg"||n==="xl")},l);return e.jsx("div",{className:o,role:"group",children:t})},Oe=({variant:t="default",size:n="md",color:s="primary",disabled:r=!1,external:l=!1,className:o,children:d,href:p,target:b,rel:g,...x})=>{const a=l||p&&(p.startsWith("http")||p.startsWith("mailto:")),m=h("inline-flex items-center gap-1 transition-colors duration-200 focus:outline-none focus:ring-2 focus:ring-offset-2",{"text-xs":n==="xs","text-sm":n==="sm","text-base":n==="md","text-lg":n==="lg","text-xl":n==="xl"},{"text-primary hover:text-primary/80 focus:ring-primary/20":s==="primary"&&!r,"text-secondary hover:text-secondary/80 focus:ring-secondary/20":s==="secondary"&&!r,"text-accent hover:text-accent/80 focus:ring-accent/20":s==="accent"&&!r,"text-success hover:text-success/80 focus:ring-success/20":s==="success"&&!r,"text-warning hover:text-warning/80 focus:ring-warning/20":s==="warning"&&!r,"text-error hover:text-error/80 focus:ring-error/20":s==="error"&&!r,"text-info hover:text-info/80 focus:ring-info/20":s==="info"&&!r,"text-neutral hover:text-neutral/80 focus:ring-neutral/20":s==="neutral"&&!r},{"":t==="default","text-opacity-70 hover:text-opacity-100":t==="subtle","underline underline-offset-2 decoration-1 hover:decoration-2":t==="underline","px-3 py-1.5 rounded-md bg-opacity-10 hover:bg-opacity-20":t==="button","bg-primary":t==="button"&&s==="primary","bg-secondary":t==="button"&&s==="secondary","bg-accent":t==="button"&&s==="accent","bg-success":t==="button"&&s==="success","bg-warning":t==="button"&&s==="warning","bg-error":t==="button"&&s==="error","bg-info":t==="button"&&s==="info","bg-neutral":t==="button"&&s==="neutral"},{"opacity-50 cursor-not-allowed pointer-events-none":r},o),f={...x,href:r?void 0:p,target:a?"_blank":b,rel:a?"noopener noreferrer":g};return e.jsxs("a",{className:m,...f,children:[d,a&&e.jsx("svg",{className:"w-3 h-3 ml-1",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24","aria-hidden":"true",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M10 6H6a2 2 0 00-2 2v10a2 2 0 002 2h10a2 2 0 002-2v-4M14 4h6m0 0v6m0-6L10 14"})})]})},ye=({trigger:t,children:n,placement:s="bottom-start",className:r,disabled:l=!1,triggerLabel:o})=>{const[d,p]=u.useState(!1),[b,g]=u.useState({}),x=u.useRef(null),a=u.useRef(null);u.useEffect(()=>{if(!d)return;const w=y=>{x.current&&!x.current.contains(y.target)&&p(!1)},N=y=>{y.key==="Escape"&&p(!1)};return document.addEventListener("mousedown",w),document.addEventListener("keydown",N),()=>{document.removeEventListener("mousedown",w),document.removeEventListener("keydown",N)}},[d]);const m=w=>{if(w.stopPropagation(),!l){if(!d){const N=a.current?.getBoundingClientRect();if(N){const A={};s.startsWith("bottom")?A.top=N.bottom+6:A.bottom=window.innerHeight-N.top+6,s.endsWith("start")?A.left=N.left:A.right=window.innerWidth-N.right,g(A)}}p(N=>!N)}},f=()=>p(!1);return e.jsxs("div",{ref:x,className:"relative inline-flex",children:[e.jsx("button",{ref:a,type:"button",onClick:m,disabled:l,"aria-label":o,"aria-expanded":d,className:h("inline-flex items-center",l&&"opacity-50 cursor-not-allowed"),children:t}),d&&e.jsx("div",{className:h("fixed z-[60] bg-module rounded-lg shadow-lg border border-neutral",r),style:b,children:typeof n=="function"?n(f):n})]})},Ve={primary:"btn o__primary",secondary:"btn o__secondary",outline:"btn o__secondary"};function pe({label:t,onClick:n,variant:s="primary",size:r="md",icon:l,options:o,disabled:d=!1,loading:p=!1,menuPlacement:b="bottom-end",menuLabel:g="More options"}){const x=d||p,a=o.length>0;return e.jsxs("div",{className:"inline-flex items-center gap-px",children:[e.jsx(Z,{variant:s,size:r,onClick:n,disabled:d,loading:p,leftIcon:l,className:h(a&&"!rounded-r-none"),children:t}),a&&e.jsx(ye,{placement:b,disabled:x,triggerLabel:g,className:"min-w-[200px] py-1",trigger:e.jsx("span",{"aria-hidden":"true",className:h("inline-flex items-center justify-center transition-colors duration-200",Ve[s],r==="sm"?"px-1.5 py-1.5":"px-2 py-2","!rounded-l-none"),children:e.jsx(U.ChevronDown,{className:"h-4 w-4"})}),children:m=>e.jsx(e.Fragment,{children:o.map(f=>e.jsxs("button",{type:"button",onClick:()=>{f.onClick(),m()},className:h("flex w-full items-center gap-2 px-3 py-2 text-left text-sm transition-colors",f.variant==="destructive"?"text-red-600 dark:text-red-400 hover:bg-red-50 dark:hover:bg-red-900":"text-default hover:bg-neutral-container"),children:[f.icon&&e.jsx("span",{className:"flex-shrink-0",children:f.icon}),f.label]},f.id))})})]})}const We={sm:"h-4 w-4",md:"h-5 w-5",lg:"h-6 w-6",full:"h-6 w-6"},He={sm:"text-sm",md:"text-sm",lg:"text-base",full:"text-base"},ce=u.forwardRef(({label:t,helperText:n,error:s,size:r="md",indeterminate:l=!1,containerClassName:o,labelClassName:d,className:p,id:b,...g},x)=>{const a=b||`checkbox-${Math.random().toString(36).substr(2,9)}`,m=!!s;return u.useEffect(()=>{x&&typeof x=="object"&&x.current&&(x.current.indeterminate=l)},[l,x]),e.jsxs("div",{className:h("flex flex-col",o),children:[e.jsxs("div",{className:"flex items-start",children:[e.jsx("div",{className:"flex items-center h-5",children:e.jsx("input",{ref:x,id:a,type:"checkbox",className:h("rounded border transition-colors duration-200","focus:ring-2 focus:ring-offset-2 focus:outline-none","disabled:opacity-50 disabled:cursor-not-allowed",We[r],m?"border-error [&:not(:checked)]:bg-[var(--base-input)] text-error focus:border-error focus:ring-error":"border-neutral [&:not(:checked)]:bg-[var(--base-input)] text-[#1a1a1a] focus:border-primary focus:ring-primary",p),...g})}),t&&e.jsxs("div",{className:"ml-3 flex-1",children:[e.jsx("label",{htmlFor:a,className:h("font-medium cursor-pointer",m?"text-error":"text-default",He[r],d),children:t}),n&&!s&&e.jsx("p",{className:"mt-1 text-xs text-muted",children:n})]})]}),s&&e.jsx("p",{className:"mt-1 text-xs text-error",children:s})]})});ce.displayName="Checkbox";const qe=()=>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"})}),Ge=()=>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"})}),Ue=()=>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"})}),ie=u.forwardRef(({value:t,onChange:n,placeholder:s="Select date",disabled:r=!1,required:l=!1,size:o="md",className:d,minDate:p,maxDate:b,format:g="MM/dd/yyyy"},x)=>{const[a,m]=u.useState(!1),[f,w]=u.useState(()=>t||new Date),N=u.useRef(null);u.useEffect(()=>{const $=_=>{N.current&&!N.current.contains(_.target)&&m(!1)};return a&&document.addEventListener("mousedown",$),()=>{document.removeEventListener("mousedown",$)}},[a]);const y=$=>{if(!$)return"";const _=$.getDate().toString().padStart(2,"0"),O=($.getMonth()+1).toString().padStart(2,"0"),i=$.getFullYear();switch(g){case"dd/MM/yyyy":return`${_}/${O}/${i}`;case"yyyy-MM-dd":return`${i}-${O}-${_}`;case"MM/dd/yyyy":default:return`${O}/${_}/${i}`}},A=()=>{const $=f.getFullYear(),_=f.getMonth(),O=new Date($,_,1),i=new Date(O);i.setDate(i.getDate()-O.getDay());const v=[],E=new Date(i);for(let C=0;C<42;C++)v.push(new Date(E)),E.setDate(E.getDate()+1);return v},j=$=>{$.getMonth()===f.getMonth()&&(p&&$<p||b&&$>b||(n?.($),m(!1)))},H=()=>{w(new Date(f.getFullYear(),f.getMonth()-1,1))},B=()=>{w(new Date(f.getFullYear(),f.getMonth()+1,1))},q=()=>{n?.(null),m(!1)},F=h("w-full border border-neutral rounded-md transition-colors duration-200","bg-module text-default","placeholder:text-default dark:placeholder:text-muted","focus:outline-none focus:ring-2 focus:ring-primary/20 focus:border-primary","disabled:opacity-50 disabled:cursor-not-allowed disabled:bg-module-subtle",{"px-3 py-2 text-sm":o==="sm","px-3 py-2 text-base":o==="md","px-4 py-3 text-lg":o==="lg","px-4 py-3 text-base":o==="full"},d),I=A(),W=["January","February","March","April","May","June","July","August","September","October","November","December"];return e.jsxs("div",{ref:N,className:"relative",children:[e.jsxs("div",{className:"relative",children:[e.jsx("input",{ref:x,type:"text",value:y(t??null),placeholder:s,disabled:r,required:l,readOnly:!0,onClick:()=>!r&&m(!a),className:h(F,"pr-10 cursor-pointer")}),e.jsx("button",{type:"button",onClick:()=>!r&&m(!a),disabled:r,className:"absolute inset-y-0 right-0 flex items-center pr-3 text-muted hover:text-muted",children:e.jsx(qe,{})})]}),a&&e.jsxs("div",{className:"absolute z-50 mt-1 bg-module border border-neutral rounded-md shadow-lg p-4 min-w-[280px]",children:[e.jsxs("div",{className:"flex items-center justify-between mb-4",children:[e.jsx("button",{onClick:H,className:"p-1 hover:bg-neutral-container rounded",children:e.jsx(Ge,{})}),e.jsxs("h3",{className:"text-sm font-medium text-default",children:[W[f.getMonth()]," ",f.getFullYear()]}),e.jsx("button",{onClick:B,className:"p-1 hover:bg-neutral-container rounded",children:e.jsx(Ue,{})})]}),e.jsx("div",{className:"grid grid-cols-7 gap-1 mb-2",children:["Su","Mo","Tu","We","Th","Fr","Sa"].map($=>e.jsx("div",{className:"text-xs font-medium text-muted text-center py-1",children:$},$))}),e.jsx("div",{className:"grid grid-cols-7 gap-1",children:I.map(($,_)=>{const O=$.getMonth()===f.getMonth(),i=t&&$.toDateString()===t.toDateString(),v=$.toDateString()===new Date().toDateString(),E=!O||p&&$<p||b&&$>b;return e.jsx("button",{onClick:()=>!E&&j($),disabled:E,className:h("w-8 h-8 text-sm rounded transition-colors duration-200",{"text-default hover:bg-neutral-container":O&&!i&&!E,"bg-primary text-white":i,"bg-neutral-container text-default":v&&!i,"text-muted cursor-not-allowed":E}),children:$.getDate()},_)})}),e.jsxs("div",{className:"flex justify-between items-center mt-4 pt-3 border-t border-neutral",children:[e.jsx("button",{onClick:q,className:"text-sm text-muted hover:text-default",children:"Clear"}),e.jsx("button",{onClick:()=>m(!1),className:"text-sm text-primary hover:text-primary/80",children:"Close"})]})]})]})}),ae=(...t)=>t.filter(Boolean).join(" "),Ke=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"})}),Je=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"})}),Ye={sm:"px-3 py-1.5 text-sm",md:"px-3 py-2 text-sm",lg:"px-3 py-2 text-sm",full:"px-3 py-2 text-sm"},xe={sm:"h-4 w-4",md:"h-5 w-5",lg:"h-6 w-6",full:"h-6 w-6"},je=u.forwardRef(({label:t,helperText:n,error:s,size:r="md",fullWidth:l=!1,startIcon:o=e.jsx(Ke,{}),loading:d=!1,containerClassName:p,labelClassName:b,className:g,id:x,options:a,onRemoteSearch:m,onSelect:f,debounceTime:w=500,showAllOnOpen:N=!1,value:y,onChange:A,...j},H)=>{const B=x||`searchfield-${Math.random().toString(36).substr(2,9)}`,q=!!s,F=u.useRef(null),I=u.useRef(null),[W,$]=u.useState(y||""),[_,O]=u.useState(!1),[i,v]=u.useState(!1),[E,C]=u.useState(!1);u.useEffect(()=>{y!==void 0&&$(y)},[y]);const L=u.useMemo(()=>{if(N&&!E||!W)return a;const T=String(W).toLowerCase();return a.filter(D=>String(D.label).toLowerCase().includes(T))},[W,a,N,E]);u.useEffect(()=>{if(!m||!W){v(!1);return}const T=setTimeout(async()=>{v(!0);try{await m(String(W))}catch(D){console.error("Remote search failed:",D)}finally{v(!1)}},w);return()=>{clearTimeout(T),v(!1)}},[W,w,m]),u.useEffect(()=>{const T=D=>{F.current&&!F.current.contains(D.target)&&O(!1)};return document.addEventListener("mousedown",T),()=>document.removeEventListener("mousedown",T)},[]);const S=T=>{const D=T.target.value;$(D),O(!0),C(!0),A&&A(T)},X=T=>{$(T.label),O(!1),C(!1),f&&f(T.value)},ee=()=>{(a.length>0||m)&&(O(!0),C(!1))},Y=d||i,M=_&&(L.length>0||Y),z=u.useMemo(()=>H||I,[H]);return e.jsxs("div",{className:ae("flex flex-col",l?"w-full":"",p||"","relative"),ref:F,children:[t&&e.jsx("label",{htmlFor:B,className:ae("block text-sm font-medium mb-1",q?"text-error":"text-default",b||""),children:t}),e.jsxs("div",{className:"relative",children:[o&&e.jsx("div",{className:"absolute left-0 pl-3 flex items-center pointer-events-none h-full",children:e.jsx("span",{className:ae("text-muted",xe[r]),children:o})}),e.jsx("input",{ref:z,id:B,value:W,onChange:S,onFocus:ee,className:ae("block w-full rounded-lg border transition-colors duration-200 bg-input","placeholder:text-[var(--text-muted)] focus:outline-none","disabled:opacity-50 disabled:cursor-not-allowed",Ye[r],o?"pl-10":"","pr-10",q?"border-red-500 text-error focus:border-red-500 focus:ring-red-500":"border-neutral text-default",g||""),...j}),e.jsx("div",{className:"absolute inset-y-0 right-0 pr-3 flex items-center",children:Y||d?e.jsxs("svg",{className:ae("animate-spin text-link",xe[r]),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(Je,{className:ae("text-muted cursor-pointer transition-transform",xe[r],_?"rotate-180":"rotate-0"),onClick:()=>{O(T=>(T||C(!1),!T))}})})]}),M&&e.jsx("ul",{className:"absolute z-10 mt-1 w-full bg-module border border-neutral rounded-lg shadow-lg max-h-60 overflow-auto top-full",role:"listbox",children:L.length>0?L.map(T=>e.jsx("li",{className:"px-4 py-2 cursor-pointer text-default hover:bg-accent-container hover:text-accent transition-colors",onClick:()=>X(T),role:"option","aria-selected":W===T.label,children:T.label},T.value)):e.jsx("li",{className:"px-4 py-2 text-muted",children:Y||d?"Zoeken op afstand...":"Geen resultaten gevonden."})}),(s||n)&&e.jsx("p",{className:ae("mt-1 text-xs",q?"text-error":"text-muted"),children:s||n}),m&&e.jsxs("p",{className:"mt-2 text-xs text-success dark:text-success",children:["Huidige zoekterm (niet-gedebounced): ",String(W)]})]})});je.displayName="SearchableTextField";const Ze={sm:"px-3 py-1.5 text-sm",md:"px-3 py-2 text-sm",lg:"px-3 py-2 text-sm",full:"px-3 py-2 text-sm"},oe=t=>t.trim().toLowerCase(),le=u.forwardRef(({label:t,helperText:n,error:s,size:r="md",fullWidth:l=!1,options:o,placeholder:d,containerClassName:p,labelClassName:b,className:g,id:x,searchable:a,multiple:m,value:f,onChange:w,allowCreate:N,onCreateOption:y,...A},j)=>{const H=x||`select-${Math.random().toString(36).substr(2,9)}`,B=!!s,[q,F]=u.useState(!1),[I,W]=u.useState(""),$=u.useRef(null),[_,O]=u.useState(o);u.useImperativeHandle(j,()=>$.current),u.useEffect(()=>{const M=z=>{$.current&&!$.current.contains(z.target)&&F(!1)};return document.addEventListener("mousedown",M),()=>document.removeEventListener("mousedown",M)},[]);const i=u.useCallback((M,z)=>M.some(T=>oe(T.value)===oe(z)||oe(T.label)===oe(z)),[]),v=u.useCallback((M,z)=>{const T=[...M],D=Q=>{const te=(Q??"").trim();te&&(i(T,te)||T.push({value:te,label:te}))};return Array.isArray(z)?z.forEach(D):D(z),T},[i]);u.useEffect(()=>{O(M=>{const z=[...o];return M.forEach(T=>{!i(z,T.value)&&!i(z,T.label)&&z.push(T)}),v(z,f)})},[o,f,v,i]);const E=M=>{if(m){const z=Array.isArray(f)?f:[],T=z.includes(M)?z.filter(D=>D!==M):[...z,M];w?.(T)}else w?.(M),F(!1),W("")},C=m?null:_.find(M=>M.value===f),L=m?_.filter(M=>Array.isArray(f)&&f.includes(M.value)):[],S=a&&I?_.filter(M=>M.label.toLowerCase().includes(I.toLowerCase())):_,X=!!N&&!!a&&!!I.trim()&&!i(_,I),ee=M=>{const z=M.trim();if(!z)return;const T=y?.(z)??{value:z,label:z};if(i(_,T.value)||i(_,T.label)){E(T.value),W(""),m||F(!1);return}O(D=>[...D,T]),E(T.value),W(""),m||F(!1)},Y=()=>m?L.length>0?L.map(M=>M.label).join(", "):d||"Select options":C?.label||d||"Select an option";return e.jsxs("div",{ref:$,className:h("relative flex flex-col",l&&"w-full",p),...A,children:[t&&e.jsx("label",{htmlFor:H,onClick:()=>F(!q),className:h("block text-sm font-medium mb-1",B?"text-error":"text-default",b),children:t}),e.jsxs("div",{className:"relative",children:[e.jsxs("button",{type:"button",id:H,onClick:()=>F(!q),className:h("flex w-full items-center justify-between gap-2 rounded-lg border transition-colors duration-200 text-left","focus:outline-none focus:ring-0 focus:ring-offset-0","disabled:opacity-50 disabled:cursor-not-allowed","bg-module",Ze[r],B?"border-error text-error focus:border-error focus:ring-error":"border-neutral text-default",g),children:[e.jsx("span",{className:"truncate flex-1 min-w-0",children:Y()}),e.jsx(U.ChevronDownIcon,{size:16,className:h("shrink-0 opacity-60 transition-transform duration-200",q&&"rotate-180")})]}),q&&e.jsxs("div",{className:"absolute z-10 mt-1 w-full rounded-md bg-module shadow-lg border border-neutral",children:[a&&e.jsx("div",{className:"p-2",children:e.jsx("input",{type:"text",placeholder:"Search...",value:I,onChange:M=>W(M.target.value),onKeyDown:M=>{M.key==="Enter"&&X&&(M.preventDefault(),ee(I))},className:h("w-full px-3 py-2 text-sm rounded-md border","text-default border-neutral focus:outline-none focus:ring-0")})}),X&&e.jsxs("div",{className:h("px-4 py-2 text-sm cursor-pointer","text-primary hover:bg-neutral-container"),onClick:()=>ee(I),children:["+: “",I.trim(),"”"]}),e.jsxs("ul",{className:"max-h-60 overflow-auto py-1",children:[d&&!m&&e.jsx("li",{className:"px-4 py-2 text-sm text-muted cursor-pointer hover:bg-neutral-container",onClick:()=>{w?.(""),F(!1)},children:d}),S.map(M=>{const z=m?Array.isArray(f)&&f.includes(M.value):f===M.value;return e.jsx("li",{onClick:()=>!M.disabled&&E(M.value),className:h("px-4 py-2 text-sm cursor-pointer","text-default",M.disabled?"opacity-50 cursor-not-allowed":"hover:bg-neutral-container",z&&"font-semibold"),children:e.jsxs("div",{className:"flex items-center",children:[m&&e.jsx("input",{type:"checkbox",checked:z,readOnly:!0,className:"mr-3 h-4 w-4 rounded border-neutral [&:not(:checked)]:bg-[var(--base-input)] text-[#1a1a1a] focus:ring-primary"}),e.jsx("span",{children:M.label})]})},M.value)})]})]})]}),(s||n)&&e.jsx("p",{className:h("mt-1 text-xs",B?"text-error":"text-muted"),children:s||n})]})});le.displayName="Select";const Xe={sm:"px-3 py-1.5 text-sm",md:"px-3 py-2 text-sm",lg:"px-4 py-3 text-base",full:"px-4 py-3 text-base"},de=u.forwardRef(({label:t,helperText:n,error:s,size:r="md",fullWidth:l=!1,loading:o=!1,containerClassName:d,labelClassName:p,className:b,id:g,rows:x=4,...a},m)=>{const f=g||`textarea-${Math.random().toString(36).substr(2,9)}`,w=!!s;return e.jsxs("div",{className:h("flex flex-col",l&&"w-full",d),children:[t&&e.jsx("label",{htmlFor:f,className:h("block text-sm font-medium mb-1",w?"text-error":"text-default",p),children:t}),e.jsxs("div",{className:"relative",children:[e.jsx("textarea",{ref:m,id:f,rows:x,className:h("block w-full rounded-lg border transition-colors duration-200 resize-vertical bg-input","placeholder:text-[var(--text-muted)] focus:outline-none focus:ring-0","disabled:opacity-50 disabled:cursor-not-allowed",Xe[r],w?"border-error text-error focus:border-error focus:ring-error":"border-neutral text-default",b),...a}),o&&e.jsx("div",{className:"absolute top-3 right-3",children:e.jsxs("svg",{className:"animate-spin h-4 w-4 text-muted",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"})]})})]}),(s||n)&&e.jsx("p",{className:h("mt-1 text-xs",w?"text-error":"text-muted"),children:s||n})]})});de.displayName="TextArea";const Qe={sm:"px-3 py-1.5 text-sm",md:"px-3 py-2 text-sm",lg:"px-3 py-2 text-sm",full:"px-3 py-2 text-sm"},fe={sm:"h-4 w-4",md:"h-5 w-5",lg:"h-6 w-6",full:"h-6 w-6"},ne=u.forwardRef(({label:t,helperText:n,error:s,size:r="md",fullWidth:l=!1,startIcon:o,endIcon:d,loading:p=!1,containerClassName:b,labelClassName:g,className:x,id:a,...m},f)=>{const w=a||`textfield-${Math.random().toString(36).substr(2,9)}`,N=!!s;return e.jsxs("div",{className:h("flex flex-col",l&&"w-full",b),children:[t&&e.jsx("label",{htmlFor:w,className:h("block text-sm font-medium mb-1",N?"text-error":"text-default",g),children:t}),e.jsxs("div",{className:"relative",children:[o&&e.jsx("div",{className:"absolute left-0 pl-3 flex items-center pointer-events-none h-full",children:e.jsx("span",{className:h("text-muted",fe[r]),children:o})}),e.jsx("input",{ref:f,id:w,className:h("block w-full rounded-lg border transition-colors duration-200 bg-input","placeholder:text-[var(--text-muted)] focus:outline-none focus:ring-1 focus:ring-offset-0","disabled:opacity-50 disabled:cursor-not-allowed",Qe[r],o&&"pl-10",d&&"pr-10",N?"border-error text-error focus:border-error focus:ring-error":"border-neutral text-default focus:border-primary focus:ring-primary",x),...m}),(d||p)&&e.jsx("div",{className:"absolute inset-y-0 right-0 pr-3 flex items-center",children:p?e.jsxs("svg",{className:h("animate-spin text-muted",fe[r]),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"})]}):d&&e.jsx("span",{className:h("text-muted",fe[r]),children:d})})]}),(s||n)&&e.jsx("p",{className:h("mt-1 text-xs",N?"text-error":"text-muted"),children:s||n})]})});ne.displayName="TextField";const re=({icon:t,size:n="md",color:s="current",clickable:r=!1,onClick:l,className:o,"aria-label":d,...p})=>{const b=typeof n=="number"?n:et(n),g=h("inline-block",{"text-primary":s==="primary","text-secondary":s==="secondary","text-accent":s==="accent","text-success":s==="success","text-warning":s==="warning","text-error":s==="error","text-info":s==="info","text-neutral":s==="neutral","text-current":s==="current"},{"cursor-pointer hover:opacity-80 transition-opacity duration-200":r,"focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-primary/20 rounded":r},o),x={size:b,className:g,onClick:r?l:void 0,"aria-label":d,role:r?"button":void 0,tabIndex:r?0:void 0,onKeyDown:r?a=>{(a.key==="Enter"||a.key===" ")&&(a.preventDefault(),l?.())}:void 0,...p};return e.jsx(t,{...x})};function et(t){return{xs:12,sm:16,md:20,lg:24,xl:32}[t]}function Ne({children:t,showTableSkeleton:n=!1,tableColumns:s=6,tableRows:r=8}){return t?e.jsx("main",{className:"flex-1 bg-module 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-module p-6",children:e.jsxs("div",{className:"w-full mx-auto space-y-6 animate-pulse",children:[!n&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"h-6 bg-neutral-container-emphasis rounded w-1/4"}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("div",{className:"h-4 bg-neutral-container-emphasis rounded w-3/4"}),e.jsx("div",{className:"h-4 bg-neutral-container-emphasis rounded w-1/2"})]})]}),n&&e.jsxs("div",{className:"rounded-lg overflow-hidden",children:[e.jsx("div",{className:`grid grid-cols-${s} gap-2 bg-neutral-container p-3`,children:Array.from({length:s}).map((l,o)=>e.jsx("div",{className:"h-4 bg-neutral-border-emphasis rounded w-2/3"},`header-${o}`))}),Array.from({length:r}).map((l,o)=>e.jsx("div",{className:`grid grid-cols-${s} gap-2 p-3 border-t border-neutral`,children:Array.from({length:s}).map((d,p)=>e.jsx("div",{className:"h-4 bg-neutral-container-emphasis rounded w-full"},`cell-${o}-${p}`))},`row-${o}`))]})]})})}const we=({trigger:t,options:n,value:s,onSelect:r,placement:l="bottom-start",disabled:o=!1,className:d,showCheck:p=!0,header:b})=>{const[g,x]=u.useState(!1),[a,m]=u.useState(null),[f,w]=u.useState({top:0,left:0}),[N,y]=u.useState({}),A=u.useRef(null),j=u.useRef(null),H=u.useRef(null),B=u.useRef(null);u.useEffect(()=>{const i=v=>{A.current&&(!A.current.contains(v.target)||H.current&&!H.current.contains(v.target))&&(x(!1),m(null),B.current&&(clearTimeout(B.current),B.current=null))};return g&&document.addEventListener("mousedown",i),()=>{document.removeEventListener("mousedown",i)}},[g]),u.useEffect(()=>{const i=v=>{v.key==="Escape"&&(x(!1),m(null),B.current&&(clearTimeout(B.current),B.current=null))};return g&&document.addEventListener("keydown",i),()=>{document.removeEventListener("keydown",i)}},[g]),u.useEffect(()=>{if(a&&A.current){const i=A.current.querySelector(`[data-option-value="${a}"]`);if(i){const v=i.getBoundingClientRect();w({top:v.top,left:v.right+8})}}},[a]),u.useEffect(()=>()=>{B.current&&clearTimeout(B.current)},[]);const q=i=>{if(i.stopPropagation(),!o){if(!g){const v=j.current?.getBoundingClientRect();if(v){const C={};l.startsWith("bottom")?C.top=v.bottom+6:C.bottom=window.innerHeight-v.top+6,l.endsWith("start")?C.left=v.left:C.right=window.innerWidth-v.right,y(C)}}x(!g),m(null),B.current&&(clearTimeout(B.current),B.current=null)}},F=(i,v,E)=>{i.stopPropagation(),!v.disabled&&!v.divider&&(!v.children||v.children.length===0)&&(r?.(v.value,E),x(!1),m(null))},I=i=>{B.current&&(clearTimeout(B.current),B.current=null),i.children&&i.children.length>0?m(i.value):m(null)},W=i=>{i.children&&i.children.length>0?B.current=setTimeout(()=>{m(null)},150):m(null)},$=(i,v,E)=>{i.stopPropagation(),!v.disabled&&!v.divider&&(r?.(v.value,E),x(!1),m(null))},_=h("fixed z-[60] min-w-[200px] bg-module rounded-md shadow-lg border border-neutral","max-h-60 overflow-auto"),O=h("fixed z-[60] min-w-[200px] bg-module rounded-md shadow-lg border border-neutral","max-h-60 overflow-auto");return e.jsxs("div",{ref:A,className:h("relative flex flex-row items-center justify-center rounded-lg hover:bg-neutral-container",d),children:[e.jsx("button",{ref:j,onClick:q,disabled:o,className:h("inline-flex items-center justify-center",{"opacity-50 cursor-not-allowed":o}),children:t}),g&&e.jsx("div",{className:_,style:N,children:e.jsxs("div",{className:"p-2",children:[b&&(typeof b=="string"?e.jsx("div",{className:"text-xs font-medium text-muted uppercase tracking-wider px-3 py-2",children:b}):b),n.map((i,v)=>{if(i.divider)return e.jsx("div",{className:"border-t border-neutral my-2"},`divider-${v}`);const E=i.children&&i.children.length>0,C=a===i.value;return e.jsxs("div",{className:"relative group",children:[e.jsxs("button",{"data-option-value":i.value,onClick:L=>F(L,i),onMouseEnter:()=>I(i),onMouseLeave:()=>W(i),disabled:i.disabled,className:h("w-full flex items-center justify-between px-3 py-2 text-sm text-default hover:bg-neutral-container rounded-md transition-colors",{"opacity-50 cursor-not-allowed":i.disabled,"bg-neutral-container":C&&E}),children:[e.jsxs("div",{className:"flex items-center space-x-2 min-w-0",children:[i.icon&&e.jsx("span",{className:"flex-shrink-0",children:i.icon}),e.jsxs("div",{className:"flex flex-col items-start min-w-0",children:[e.jsx("span",{className:"font-base truncate",children:i.label}),i.description&&e.jsx("span",{className:"text-xs text-muted",children:i.description})]})]}),e.jsxs("div",{className:"flex items-center space-x-2",children:[p&&s===i.value&&e.jsx("span",{className:"h-4 w-4 text-success flex-shrink-0 text-sm font-bold",children:"✓"}),E&&e.jsx("span",{className:"text-muted text-xs",children:"▶"})]})]}),E&&C&&e.jsx("div",{ref:H,className:O,style:{top:`${f.top}px`,left:`${f.left}px`},onMouseEnter:()=>{B.current&&(clearTimeout(B.current),B.current=null),m(i.value)},onMouseLeave:()=>{B.current=setTimeout(()=>{m(null)},150)},children:e.jsx("div",{className:"p-2",children:i.children.map((L,S)=>{if(L.divider)return e.jsx("div",{className:"border-t border-neutral my-2"},`divider-${S}`);const X=typeof s=="object"&&s[i.value]&&s[i.value].includes(L.value)||s===L.value;return e.jsxs("button",{onClick:ee=>$(ee,L,i.value),disabled:L.disabled,className:h("w-full flex items-center justify-between px-3 py-2 text-sm text-default hover:bg-neutral-container rounded-md transition-colors",{"opacity-50 cursor-not-allowed":L.disabled}),children:[e.jsxs("div",{className:"flex items-center space-x-2 min-w-0",children:[L.icon&&e.jsx("span",{className:"flex-shrink-0",children:L.icon}),e.jsxs("div",{className:"flex flex-col items-start min-w-0",children:[e.jsx("span",{className:"font-base truncate",children:L.label}),L.description&&e.jsx("span",{className:"text-xs text-muted",children:L.description})]})]}),p&&X&&e.jsx("span",{className:"h-4 w-4 text-success flex-shrink-0 text-sm font-bold",children:"✓"})]},L.value)})})})]},i.value)}),(()=>{const i=n.reduce((v,E)=>{if(E.divider)return v;const C=E.children?E.children.filter(L=>!L.divider).length:0;return v+1+C},0);return i>1&&e.jsx("div",{className:"border-t border-neutral mt-2 pt-2",children:e.jsxs("div",{className:"text-xs text-muted px-3 py-1",children:[i," options available"]})})})()]})})]})},tt=()=>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"})}),st=({active:t})=>e.jsx("svg",{className:h("h-3 w-3",t?"text-default":"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"})}),rt=({active:t})=>e.jsx("svg",{className:h("h-3 w-3",t?"text-default":"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"})}),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:"m15 18-6-6 6-6"})}),at=()=>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"})}),lt=()=>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"})}),ot=()=>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"})}),ke=()=>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"})}),ct=t=>{const n=r=>t.multiSelect&&Array.isArray(t.value)?t.value?.includes(r):t.value===r,s=r=>{t.multiSelect&&Array.isArray(t.value)?t.onChange(t.value.filter(l=>l!==r)):t.onChange(r)};return t.type==="date"?e.jsx("div",{className:"flex items-center space-x-1 max-w-[160px]",children:e.jsx(ie,{size:"sm",value:t.value,onChange:r=>t.onChange(r),placeholder:t.placeholder||`Select ${t.label.toLowerCase()}`,className:"min-w-[160px] btn btn o__secondary"})}):e.jsx("div",{className:"flex items-center space-x-1 max-w-[240px]",children:e.jsx("div",{className:"relative",children:e.jsxs("details",{className:"group",children:[e.jsxs("summary",{className:"flex items-center space-x-2 cursor-pointer rounded-full px-3 py-2 text-sm btn btn o__secondary",children:[e.jsx("span",{children:t.label}),e.jsx("span",{className:"text-default",children:t.multiSelect&&Array.isArray(t.value)?t.value?.map(r=>t.options?.find(l=>l.value===r)?.label).join(", "):t.options?.find(r=>r.value===t.value)?.label}),e.jsx("span",{className:"text-muted text-sm group-open:rotate-180 transition-transform",children:e.jsx(ke,{})})]}),e.jsxs("div",{className:"absolute z-10 left-0 mt-1 bg-module border border-neutral rounded-lg shadow-lvl-0 p-2 w-48",children:[t.options?.map(r=>e.jsx("button",{className:"w-full text-left px-3 py-2 rounded-md hover:bg-module-subtle text-sm text-default flex items-center space-x-2",onClick:()=>s(r.value),children:e.jsx("span",{className:h(n(r.value)&&"text-primary-500"),children:r.label})},r.value)),t.value&&e.jsx("button",{className:"w-full text-left px-3 py-2 rounded-md hover:bg-module-subtle text-sm text-default flex items-center space-x-2 mt-2",onClick:()=>s(null),children:e.jsx("span",{className:"text-muted",children:"Clear filter"})})]})]})})})},he=({data:t,columns:n,loading:s=!1,searchable:r=!1,searchPlaceholder:l="Search...",filters:o=[],paginated:d=!1,pageSizeOptions:p=[10,25,50,100],defaultPageSize:b=10,actions:g=[],onRowClick:x,selectable:a=!1,selectedRows:m=[],onSelectionChange:f,getRowKey:w=(q,F)=>F,emptyContent:N,hoverable:y=!0,bordered:A=!1,striped:j=!1,className:H,rowClassName:B})=>{const[q,F]=u.useState(""),[I,W]=u.useState({column:null,direction:null}),[$,_]=u.useState({page:0,pageSize:b}),O=u.useRef(null),i=u.useMemo(()=>{let c=t;if(r&&q.trim()){const k=n.filter(V=>V.searchable!==!1),R=q.toLowerCase();c=c.filter(V=>k.some(P=>{const J=typeof P.accessor=="function"?P.accessor(V):V[P.accessor];return String(J||"").toLowerCase().includes(R)}))}return o.forEach(k=>{k.value&&k.value!=="all"&&(c=c.filter(R=>{const V=n.find(J=>J.id===k.id);if(!V)return!0;const P=typeof V.accessor=="function"?V.accessor(R):R[V.accessor];return String(P||"")===k.value}))}),c},[t,q,n,r,o]),v=u.useMemo(()=>{if(!I.column||!I.direction)return i;const c=n.find(k=>k.id===I.column);return c?[...i].sort((k,R)=>{const V=typeof c.accessor=="function"?c.accessor(k):k[c.accessor],P=typeof c.accessor=="function"?c.accessor(R):R[c.accessor];let J=0;return V<P?J=-1:V>P&&(J=1),I.direction==="desc"?-J:J}):i},[i,I,n]),E=u.useMemo(()=>{if(!d)return v;const c=$.page*$.pageSize,k=c+$.pageSize;return v.slice(c,k)},[v,$,d]),C=u.useCallback(c=>{n.find(R=>R.id===c)?.sortable&&W(R=>R.column!==c?{column:c,direction:"asc"}:R.direction==="asc"?{column:c,direction:"desc"}:{column:null,direction:null})},[n]),L=u.useCallback(c=>{_(k=>({...k,page:c}))},[]),S=u.useCallback(c=>{_({page:0,pageSize:c})},[]),X=u.useCallback((c,k)=>{if(!f)return;const R=w(c,0);m.map((V,P)=>w(V,P)),f(k?[...m,c]:m.filter((V,P)=>w(m[P],P)!==R))},[m,f,w]),ee=u.useCallback(c=>{f&&f(c?[...E]:[])},[E,f]);u.useEffect(()=>{_(c=>({...c,page:0}))},[q,I]),u.useEffect(()=>{_(c=>({...c,page:0}))},[o.map(c=>c.value).join(",")]);const Y=v.length,M=Math.ceil(Y/$.pageSize),z=$.page*$.pageSize+1,T=Math.min(z+$.pageSize-1,Y),D=E.length>0&&E.every(c=>{const k=w(c,0);return m.some((R,V)=>w(R,V)===k)}),Q=E.some(c=>{const k=w(c,0);return m.some((R,V)=>w(R,V)===k)}),te=h("w-full text-sm leading-5 text-[var(--text-default)] border-collapse",H),G=h("bg-[var(--base-module)]"),se=h("text-[var(--text-default)] p-3 border-b border-[var(--neutral-border)]"),ue=h("h-12",{"hover:bg-[var(--neutral-container)] dark:hover:bg-[var(--neutral-container-emphasis)]":y,"cursor-pointer":x});return e.jsxs("div",{className:"space-y-4",children:[(r||o.length>0)&&e.jsx("div",{className:"pt-4 pb-2",children:e.jsxs("div",{className:"flex flex-wrap gap-4 items-start",children:[o.map(c=>e.jsx(ct,{...c},c.id)),e.jsx("div",{className:"w-full sm:w-auto sm:ml-auto min-w-[200px]",children:e.jsx(ne,{placeholder:l,value:q,onChange:c=>F(c.target.value),startIcon:e.jsx(tt,{}),className:"max-w-sm"})})]})}),e.jsxs("div",{className:"relative w-full overflow-x-auto min-h-[400px]",children:[s&&e.jsx("div",{className:"flex items-center justify-center z-10",children:e.jsx(Ne,{showTableSkeleton:!0,tableRows:10,tableColumns:n.length})}),e.jsxs("table",{ref:O,className:h(te,"min-w-full"),children:[e.jsx("thead",{className:G,children:e.jsxs("tr",{children:[a&&e.jsx("th",{className:h(se,"w-12"),children:e.jsx("input",{type:"checkbox",checked:D,ref:c=>{c&&(c.indeterminate=Q&&!D)},onChange:c=>ee(c.target.checked),className:"rounded border-neutral [&:not(:checked)]:bg-[var(--base-input)] text-[#1a1a1a]"})}),!s&&n.map(c=>e.jsx("th",{className:h(se,"font-semibold text-xs text-[var(--text-muted)] dark:text-[var(--text-muted)] uppercase tracking-wider","group",{"text-left":c.align==="left"||!c.align,"text-center":c.align==="center","text-right":c.align==="right","cursor-pointer select-none":c.sortable,"sticky left-0 bg-module":c.sticky==="left","sticky right-0 bg-module":c.sticky==="right"}),style:{width:c.width},onClick:()=>c.sortable&&C(c.id),children:e.jsxs("div",{className:"flex items-center gap-2",children:[c.headerCell?c.headerCell():c.header,c.sortable&&e.jsxs("div",{className:h("flex flex-col opacity-0 group-hover:opacity-100 transition-opacity",I.column===c.id&&"opacity-100"),children:[e.jsx(st,{active:I.column===c.id&&I.direction==="asc"}),e.jsx(rt,{active:I.column===c.id&&I.direction==="desc"})]})]})},c.id)),g.length>0&&e.jsx("th",{className:h(se,"w-20"),children:e.jsx("span",{className:"sr-only",children:"Actions"})})]})}),e.jsx("tbody",{children:E.length===0||s?!s&&e.jsx("tr",{children:e.jsx("td",{colSpan:n.length+(a?1:0)+(g.length>0?1:0),className:h(se,"text-center py-8 text-muted"),children:N||"No data available"})}):E.map((c,k)=>{const R=w(c,k),V=m.some((P,J)=>w(P,J)===R);return e.jsxs("tr",{className:h(ue,{"bg-accent-container":V},B?.(c,k)),onClick:P=>{P.stopPropagation(),x?.(c,k)},children:[a&&e.jsx("td",{className:se,children:e.jsx("input",{type:"checkbox",checked:V,onChange:P=>{P.stopPropagation(),X(c,P.target.checked)},className:"rounded border-neutral [&:not(:checked)]:bg-[var(--base-input)] text-[#1a1a1a]"})}),n.map(P=>{const J=typeof P.accessor=="function"?P.accessor(c):c[P.accessor];return e.jsx("td",{className:h(se,{"text-left":P.align==="left"||!P.align,"text-center":P.align==="center","text-right":P.align==="right","sticky left-0 bg-module":P.sticky==="left","sticky right-0 bg-module":P.sticky==="right"}),children:P.cell?P.cell(J,c,k):String(J||"")},P.id)}),g.length>0&&e.jsx("td",{className:se,children:e.jsx(we,{trigger:e.jsxs("div",{className:"inline-flex items-center gap-1 px-2 py-1 text-sm text-muted hover:text-default",children:[e.jsx("span",{children:"Options"}),e.jsx(ke,{})]}),options:g.map(P=>({value:P.id,label:P.label,icon:P.icon,disabled:P.disabled?.(c)})),onSelect:P=>{const J=g.find(me=>me.id===P);J&&J.onClick(c,k)},placement:"bottom-end"})})]},R)})})]})]}),d&&Y>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-muted",children:["Showing ",z," to ",T," of ",Y," results"]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-sm text-muted",children:"Rows per page:"}),e.jsx("select",{value:$.pageSize,onChange:c=>S(Number(c.target.value)),className:"border border-[var(--neutral-border)] text-[var(--text-default)] rounded-md px-2 py-1 text-sm bg-[var(--base-input)] w-16",children:p.map(c=>e.jsx("option",{value:c,children:c},c))})]})]}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(Z,{size:"sm",variant:"ghost",onClick:()=>L(0),disabled:$.page===0,iconOnly:!0,children:e.jsx(lt,{})}),e.jsx(Z,{size:"sm",variant:"ghost",onClick:()=>L($.page-1),disabled:$.page===0,iconOnly:!0,children:e.jsx(nt,{})}),e.jsxs("span",{className:"px-3 py-1 text-sm text-muted",children:["Page ",$.page+1," of ",M]}),e.jsx(Z,{size:"sm",variant:"ghost",onClick:()=>L($.page+1),disabled:$.page>=M-1,iconOnly:!0,children:e.jsx(at,{})}),e.jsx(Z,{size:"sm",variant:"ghost",onClick:()=>L(M-1),disabled:$.page>=M-1,iconOnly:!0,children:e.jsx(ot,{})})]})]})]})},it=u.createContext(null),dt=({items:t,activeTab:n,onTabChange:s,className:r})=>{const[l,o]=u.useState(t[0]?.id||""),d=n||l,p=b=>{s?s(b):o(b)};return e.jsx("div",{className:h("border-b border-neutral-200 dark:border-neutral-700",r),children:e.jsx("nav",{className:"-mb-px flex space-x-8",children:t.map(b=>e.jsx("button",{onClick:()=>!b.disabled&&p(b.id),disabled:b.disabled,className:h("border-b-2 py-2 px-1 text-sm font-medium transition-colors duration-200",{"border-primary text-primary":d===b.id,"border-transparent text-neutral-500 hover:text-neutral-700 dark:text-neutral-400 dark:hover:text-neutral-300":d!==b.id&&!b.disabled,"border-transparent text-neutral-300 cursor-not-allowed dark:text-neutral-600":b.disabled}),children:e.jsxs("span",{className:"flex items-center gap-2",children:[b.label,b.badge&&e.jsx("span",{className:h("inline-flex items-center px-2 py-0.5 rounded-full text-xs font-medium",d===b.id?"bg-primary/10 text-primary":"bg-neutral-100 text-neutral-600 dark:bg-neutral-800 dark:text-neutral-400"),children:b.badge})]})},b.id))})})},Ce=({items:t,defaultTab:n,activeTab:s,onTabChange:r,variant:l="default",size:o="md",className:d})=>{const[p,b]=u.useState(n||s||t[0]?.id||""),g=s||p,x=N=>{r?r(N):b(N)},a={activeTab:g,setActiveTab:x},m=t.find(N=>N.id===g),f=h("flex",{"border-b border-neutral-200 dark:border-neutral-700 px-2":l==="default"||l==="underline","bg-neutral-100 dark:bg-neutral-800 p-1 rounded-lg":l==="pills","space-x-1":l==="pills","space-x-8":l==="default"||l==="underline"},d),w=(N,y)=>{const A="transition-colors duration-200 font-medium",j={"text-xs px-2 py-1":o==="sm","text-sm px-3 py-2":o==="md","text-base px-4 py-3":o==="lg"},H={"border-b-2 -mb-px":l==="default","rounded-md":l==="pills","border-b-2 pb-2":l==="underline"},B={"opacity-50 cursor-not-allowed":N.disabled,"cursor-pointer":!N.disabled},q=y?{"border-primary text-primary":l==="default"||l==="underline","bg-white dark:bg-neutral-700 text-neutral-900 dark:text-neutral-100 shadow-sm":l==="pills"}:{},F=!y&&!N.disabled?{"border-transparent text-neutral-600 hover:text-neutral-900 dark:text-neutral-400 dark:hover:text-neutral-100":l==="default","text-neutral-600 hover:text-neutral-900 dark:text-neutral-400 dark:hover:text-neutral-100":l==="pills","border-transparent text-neutral-600 hover:text-neutral-900 hover:border-neutral-300 dark:text-neutral-400 dark:hover:text-neutral-100":l==="underline"}:{};return h(A,j,H,B,q,F)};return e.jsx(it.Provider,{value:a,children:e.jsxs("div",{children:[e.jsx("div",{className:f,role:"tablist",children:t.map(N=>e.jsx("button",{type:"button",role:"tab","aria-selected":g===N.id,"aria-controls":`tabpanel-${N.id}`,disabled:N.disabled,onClick:()=>!N.disabled&&x(N.id),className:w(N,g===N.id),children:e.jsxs("span",{className:"flex items-center gap-2",children:[N.label,N.badge&&e.jsx("span",{className:"inline-flex items-center px-2 py-0.5 rounded-full text-xs font-medium bg-neutral-200 text-neutral-700 dark:bg-neutral-700 dark:text-neutral-300",children:N.badge})]})},N.id))}),m?.content&&e.jsx("div",{role:"tabpanel",id:`tabpanel-${g}`,"aria-labelledby":`tab-${g}`,className:"mt-4",children:m.content})]})})},ut={sm:"max-w-md",md:"max-w-lg",lg:"max-w-2xl",xl:"max-w-4xl",full:"max-w-full mx-4"};function Se({open:t,onClose:n,title:s,size:r="md",closeOnBackdropClick:l=!0,closeOnEscape:o=!0,className:d,backdropClassName:p,children:b,footer:g,showCloseButton:x=!0}){const a=u.useRef(null),m=u.useRef(null);u.useEffect(()=>{if(!t||!o)return;const w=N=>{N.key==="Escape"&&n()};return document.addEventListener("keydown",w),()=>document.removeEventListener("keydown",w)},[t,o,n]),u.useEffect(()=>(t?(m.current=document.activeElement,a.current&&a.current.focus(),document.body.style.overflow="hidden"):(m.current&&m.current.focus(),document.body.style.overflow=""),()=>{document.body.style.overflow=""}),[t]);const f=w=>{l&&w.target===w.currentTarget&&n()};return t?e.jsx("div",{className:h("fixed inset-0 z-50 flex items-center justify-center p-4","bg-black/20",p),onClick:f,children:e.jsxs("div",{ref:a,className:h("relative w-full bg-module rounded-modal shadow-modal rounded-md","focus:outline-none",ut[r],d),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-default",children:s}),x&&e.jsx("button",{onClick:n,className:"p-1 text-muted hover:text-muted 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:b}),g&&e.jsx("div",{className:"px-6 py-4",children:g})]})}):null}const K=({variant:t="body",size:n="md",weight:s="normal",color:r="current",align:l="left",truncate:o=!1,italic:d=!1,underline:p=!1,lineHeight:b="normal",as:g,className:x,children:a,...m})=>{const f=g||mt(t),w=h("font-primary",{"leading-relaxed":t==="body","text-sm leading-tight":t==="caption","text-sm font-medium leading-none":t==="label","font-mono text-sm bg-neutral-100 dark:bg-neutral-800 px-1 py-0.5 rounded":t==="code"},t!=="code"&&{"text-xs":n==="xs","text-sm":n==="sm","text-base":n==="md","text-lg":n==="lg","text-xl":n==="xl"},t!=="label"&&{"font-light":s==="light","font-normal":s==="normal","font-medium":s==="medium","font-semibold":s==="semibold","font-bold":s==="bold"},{"text-primary":r==="primary","text-secondary":r==="secondary","text-[var(--text-accent)]":r==="accent","text-[var(--text-success)]":r==="success","text-warning":r==="warning","text-[var(--text-error)]":r==="error","text-info":r==="info","text-[var(--text-default)]":r==="neutral","text-current":r==="current","text-[var(--text-muted)]":r==="muted"},{"text-left":l==="left","text-center":l==="center","text-right":l==="right","text-justify":l==="justify"},t==="body"&&{"leading-tight":b==="tight","leading-normal":b==="normal","leading-relaxed":b==="relaxed"},{italic:d,underline:p,truncate:o},x),N=f;return e.jsx(N,{className:w,...m,children:a})};function mt(t){return{body:"p",caption:"span",label:"span",code:"code"}[t]||"p"}const Ee=({value:t,onChange:n,label:s,placeholder:r="Select or upload a file",error:l,disabled:o,accept:d,onListFiles:p,onListMounts:b,onUploadFile:g,onDownloadFile:x,onRegisterFile:a})=>{const[m,f]=u.useState(!1),[w,N]=u.useState([]),[y,A]=u.useState(null),[j,H]=u.useState("/"),[B,q]=u.useState([]),[F,I]=u.useState(!1),[W,$]=u.useState(""),[_,O]=u.useState(typeof t=="object"?t:null),[i,v]=u.useState(!1),[E,C]=u.useState(""),L=u.useRef(null);u.useEffect(()=>{m&&S()},[m]),u.useEffect(()=>{m&&y&&X()},[m,y,j,W]);const S=async()=>{I(!0);try{const c=await b?.();c?.data&&N(c.data)}catch(c){console.error("Failed to load mounts",c)}finally{I(!1)}},X=async()=>{if(y){I(!0);try{const c=await p?.({mountId:y.id,name:W,path:j});c?.data&&q(c.data)}catch(c){console.error("Failed to load files",c)}finally{I(!1)}}},ee=async c=>{const k=c.target.files?.[0];if(k){I(!0);try{const R=await k.arrayBuffer(),V=new Uint8Array(R),P={id:`local-${Date.now()}`,name:k.name,type:"file",path:"/",mimeType:k.type||"application/octet-stream",size:k.size,mountId:"local",providerKey:k.name,ownerId:"me"};O(P),n(P,V),f(!1)}catch(R){console.error("Local file selection failed",R)}finally{I(!1)}}},Y=async c=>{const k=c.target.files?.[0];if(!(!k||!y)){I(!0);try{const R=await k.arrayBuffer(),V=await g?.({file:new Uint8Array(R),filename:k.name,mimeType:k.type||"application/octet-stream",mountId:y.id,path:j});if(V?.data){const P=V.data;O(P),n(P,new Uint8Array(R)),f(!1)}}catch(R){console.error("Upload failed",R)}finally{I(!1)}}},M=async()=>{if(!(!E||!y)){I(!0);try{const c=`${j}${E}/`;a&&(await a({name:E,type:"folder",path:j,mimeType:"application/x-directory",size:0,mountId:y.id,providerKey:c,ownerId:"me"}),await X()),v(!1),C("")}catch(c){console.error("Failed to create folder",c)}finally{I(!1)}}},z=async c=>{I(!0);try{const k=await x?.(c.id);O(c),n(c,k),f(!1)}catch(k){console.error("Failed to download file",k)}finally{I(!1)}},T=c=>{c.stopPropagation(),O(null),n(null)},D=u.useMemo(()=>{const c=new Set,k=[];return B.forEach(R=>{if(R.type==="folder"){R.path===j&&c.add(R.name);return}const V=R.providerKey||R.name,J=(j?V.substring(j.length):V).split("/").filter(me=>me!=="");J.length>1?c.add(J[0]):J.length===1&&k.push(R)}),{folders:Array.from(c).sort(),files:k.sort((R,V)=>R.name.localeCompare(V.name))}},[B,j]),Q=c=>{H(k=>`${k}${c}/`)},te=()=>{const c=j.split("/").filter(k=>k!=="");c.pop(),c.length===0?H("/"):H(`${c.join("/")}/`)},G=u.useMemo(()=>{const c=D.folders.map(k=>({id:`folder-${k}`,name:k,type:"folder"}));return D.files.forEach(k=>{c.push({...k,type:"file"})}),c},[D]),se=[{id:"name",header:"Name",accessor:"name",cell:(c,k)=>e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(re,{icon:k.type==="folder"?U.Folder:U.FileText,size:"sm",color:k.type==="folder"?"warning":"secondary"}),e.jsx("span",{className:h(k.type==="folder"&&"font-medium"),children:c})]})},{id:"type",header:"Type",accessor:c=>c.type==="folder"?"Folder":c.mimeType},{id:"size",header:"Size",accessor:c=>c.type==="file"?`${(c.size/1024).toFixed(1)} KB`:"-"},{id:"actions",header:"",accessor:"id",align:"right",cell:(c,k)=>e.jsx(Z,{size:"sm",variant:"outline",onClick:R=>{R.stopPropagation(),k.type==="folder"?Q(k.name):z(k)},loading:F&&k.type==="file"&&_?.id===k.id,children:k.type==="folder"?"Open":"Select"})}],ue=[{id:"name",header:"Mount Name",accessor:"name",cell:c=>e.jsxs("div",{className:"flex items-center gap-2 font-medium",children:[e.jsx(re,{icon:U.HardDrive,size:"sm",color:"primary"}),e.jsx("span",{children:c})]})},{id:"actions",header:"",accessor:"id",align:"right",cell:(c,k)=>e.jsx(Z,{size:"sm",variant:"outline",onClick:()=>A(k),children:"Open"})}];return e.jsxs("div",{className:"space-y-1",children:[s&&e.jsx(K,{variant:"label",size:"sm",weight:"medium",children:s}),e.jsxs("div",{onClick:()=>!o&&f(!0),className:h("flex items-center gap-3 px-3 py-2 border rounded-lg cursor-pointer transition-colors","hover:border-primary-400 bg-module",l?"border-error":"border-neutral",o&&"opacity-50 cursor-not-allowed bg-module-subtle"),children:[e.jsx("div",{className:"flex-shrink-0",children:e.jsx(re,{icon:_?U.FileText:U.HardDrive,color:_?"primary":"secondary"})}),e.jsx("div",{className:"flex-grow truncate",children:_?e.jsx("span",{className:"text-sm text-default font-medium",children:_.name}):e.jsx("span",{className:"text-sm text-muted",children:r})}),_&&!o&&e.jsx("button",{onClick:T,className:"p-1 hover:bg-neutral-container rounded",children:e.jsx(re,{icon:U.X,size:"xs"})})]}),l&&e.jsx(K,{variant:"body",size:"xs",className:"text-error",children:l}),e.jsx(Se,{open:m,onClose:()=>{f(!1),A(null),H("/"),v(!1)},title:y?`Explorer: ${y.name}`:"Select Storage Mount",size:"lg",children:e.jsx(Ce,{variant:"pills",items:[{id:"remote",label:"Platform Storage",content:e.jsx("div",{className:"space-y-4",children:y?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:()=>{j&&j!=="/"?te():A(null)},leftIcon:e.jsx(re,{icon:U.ArrowLeft,size:"xs"}),children:j?"Back":"Back to Mounts"}),e.jsx("div",{className:"flex items-center gap-1 text-xs text-muted overflow-hidden bg-neutral-container px-2 py-1 rounded",children:e.jsx("span",{className:"truncate",children:j})}),e.jsx("div",{className:"flex-grow min-w-[150px]",children:e.jsx(ne,{placeholder:"Search...",value:W,onChange:c=>$(c.target.value),startIcon:e.jsx(U.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:()=>v(!0),leftIcon:e.jsx(re,{icon:U.FolderPlus,size:"xs"}),children:"New Folder"}),e.jsx(Z,{variant:"primary",size:"sm",onClick:()=>L.current?.click(),leftIcon:e.jsx(re,{icon:U.Upload,size:"xs"}),loading:F,children:"Upload"}),e.jsx("input",{type:"file",className:"hidden",ref:L,onChange:Y,accept:d})]})]}),i&&e.jsxs("div",{className:"flex items-center gap-2 p-3 bg-module-subtle rounded-lg border border-neutral",children:[e.jsx(re,{icon:U.Folder,size:"sm",color:"warning"}),e.jsx(ne,{size:"sm",placeholder:"Folder name",value:E,onChange:c=>C(c.target.value),autoFocus:!0}),e.jsx(Z,{size:"sm",onClick:M,loading:F,children:"Create"}),e.jsx(Z,{size:"sm",variant:"ghost",onClick:()=>v(!1),children:"Cancel"})]}),e.jsx("div",{className:"max-h-[400px] overflow-auto rounded-lg border border-neutral",children:e.jsx(he,{data:G,columns:se,loading:F,emptyContent:"This folder is empty",onRowClick:c=>c.type==="folder"?Q(c.name):z(c)})})]}):e.jsx("div",{className:"max-h-[400px] overflow-auto rounded-lg border border-neutral",children:e.jsx(he,{data:w,columns:ue,loading:F,emptyContent:"No storage mounts configured",onRowClick:c=>A(c)})})})},{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-neutral rounded-xl bg-module-subtle/50",children:[e.jsx("div",{className:"p-4 bg-primary/10 rounded-full mb-4",children:e.jsx(re,{icon:U.FileText,size:"xl",color:"primary"})}),e.jsx(K,{variant:"label",size:"lg",weight:"semibold",children:"Select a file from your computer"}),e.jsxs(K,{variant:"body",size:"sm",className:"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.jsxs("div",{className:h("inline-flex items-center justify-center font-medium rounded-lg transition-colors duration-200 px-6 py-3 text-base bg-primary text-white hover:bg-primary-600",F&&"opacity-50 cursor-wait"),children:[F&&e.jsxs("svg",{className:"animate-spin h-4 w-4 mr-2",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"})]}),"Browse Local File"]}),e.jsx("input",{type:"file",className:"hidden",onChange:ee,accept:d,disabled:F})]})]})})}]})})]})};function Le({value:t,onChange:n,onListFolders:s,disabled:r,size:l="md",placeholder:o,templatePlaceholder:d,showTemplate:p=!0}){const[b,g]=u.useState([]);u.useEffect(()=>{let a=!0;return Promise.resolve(s?.()).then(m=>{a&&m&&g(m.data??[])}).catch(()=>{}),()=>{a=!1}},[]);const x=t??{};return e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsx(le,{size:l,fullWidth:!0,value:x.folderId??"",options:b.map(a=>({value:a.id,label:a.name})),placeholder:o??"Select a folder",onChange:a=>n?.({...x,folderId:a})}),p&&e.jsx(ne,{size:l,disabled:r??!1,value:x.pathTemplate??"",placeholder:d??"Sub-path e.g. {yyyy}/{mm}/{dd} (optional)",onChange:a=>n?.({...x,pathTemplate:a.target.value})})]})}function ge(t,n){return n.split(".").reduce((s,r)=>s&&typeof s=="object"&&r in s?s[r]:void 0,t)}function xt(t,n,s){const r=n.split("."),l=Array.isArray(t)?[...t]:{...t};let o=l;for(let d=0;d<r.length-1;d++){const p=r[d],b=o[p];o[p]=b&&typeof b=="object"?Array.isArray(b)?[...b]:{...b}:{},o=o[p]}return o[r[r.length-1]]=s,l}function ft(t,n){const s=n.split("."),r=Array.isArray(t)?[...t]:{...t};let l=r;for(let o=0;o<s.length-1;o++){const d=s[o];if(!l[d]||typeof l[d]!="object")return r;l[d]=Array.isArray(l[d])?[...l[d]]:{...l[d]},l=l[d]}return delete l[s[s.length-1]],r}const ht=({groups:t,data:n,onSubmit:s,onCancel:r,onChange:l,transform:o,validate:d,submitButton:p={label:"Submit",variant:"primary"},cancelButton:b={label:"Cancel",variant:"outline"},showButtons:g=!0,layout:x="vertical",size:a="md",loading:m=!1,className:f,ref:w,sdk:N})=>{const[y,A]=u.useState(n||{}),[j,H]=u.useState({}),[B,q]=u.useState({});u.useEffect(()=>{n&&A({...n})},[n]);const F=u.useCallback((i,v,E)=>{const C=t.flatMap(L=>L.items).find(L=>L.name===i);if(!C)return null;if(C.required&&(v==null||v===""))return`${C.label} is required`;if(C.type==="array"){if(C.required&&(!v||v.length===0))return`${C.label} cannot be empty.`;if(v&&!Array.isArray(v))return`${C.label} must be an array.`;if(Array.isArray(v)&&C.arrayFields){const L=[];let S=!1;if(v.forEach((X,ee)=>{const Y={};for(const M of C.arrayFields){const z=X?.[M.name];if(M.required&&(z==null||z===""))Y[M.name]=`${M.label} is required`,S=!0;else if(M.validator){const T=M.validator(z,X);T&&(Y[M.name]=T,S=!0)}}L[ee]=Y}),S)return JSON.stringify(L)}}return C.validator?C.validator(v,E):null},[t]),I=u.useCallback((i,v)=>{let E=xt(y,i,v);t.flatMap(S=>S.items).find(S=>S.name===i)?.removeIfEmpty&&(v==null||v==="")&&(E=ft(E,i)),A(E),q(S=>({...S,[i]:!0}));const L=F(i,v,E);H(S=>({...S,[i]:L||""})),l?.(E,i)},[y,t,F,l]),W=u.useCallback(async i=>{if(console.log("handleSubmit"),i.preventDefault(),m)return;const v={},E=t.flatMap(L=>L.items);for(const L of E){if(L.hidden||L.conditional&&!L.conditional(y))continue;const S=F(L.name,ge(y,L.name),y);S&&(v[L.name]=S)}if(d){const L=d(y);L&&Object.assign(v,L)}if(H(v),console.log("newErrors",v),Object.keys(v).some(L=>v[L]))return;const C=o?o(y):y;await s?.(y,C)},[y,t,F,d,o,s,m]),$=u.useCallback(i=>{const v=ge(y,i.name),E=B[i.name]?j[i.name]:void 0,C=i.disabled||m,L={value:v||"",disabled:C,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(ne,{...L,onChange:S=>I(i.name,S.target.value),type:i.textType||i.type,autoComplete:i.autocomplete,error:E,size:a});case"textarea":return e.jsx(de,{...L,onChange:S=>I(i.name,S.target.value),rows:4,error:E,size:a});case"select":return e.jsx(le,{...L,onChange:S=>I(i.name,S),options:(i.options||[]).map(S=>({...S,value:String(S.value)})),searchable:i.searchable,multiple:i.multiple,allowCreate:i.allowCreate,error:E,size:a});case"checkbox":return e.jsx(ce,{...L,checked:!!v,onChange:S=>I(i.name,S.target.checked),size:a});case"radio":return e.jsx("div",{className:"space-y-1",children:i.options?.map(S=>e.jsxs("label",{className:"flex items-center gap-2",children:[e.jsx("input",{type:"radio",name:i.name,value:S.value,checked:v===S.value,onChange:()=>I(i.name,S.value),disabled:C||S.disabled,className:"rounded-full border-neutral-100 dark:border-neutral-600"}),e.jsx(K,{variant:"label",size:"sm",children:S.label})]},S.value))});case"date":return e.jsx(ie,{...L,value:v?new Date(v):null,onChange:S=>I(i.name,S),size:a});case"file":return e.jsx(Ee,{...L,value:v,onChange:S=>I(i.name,S),error:E,onListFiles:S=>N?.http.invoke({method:"POST",action:"storage.file.list",body:S}),onListMounts:()=>N?.http.invoke({method:"GET",action:"storage.mount"}),onUploadFile:S=>N?.http.invoke({method:"POST",action:"storage.file.upload",body:S}),onDownloadFile:S=>N?.http.invoke({method:"GET",action:`storage.file.${S}.download`}),onRegisterFile:S=>N?.http.invoke({method:"POST",action:"storage.file.folder",body:S})});case"folder":return e.jsx(Le,{value:v||{},onChange:S=>I(i.name,S),onListFolders:()=>N?.http.invoke({method:"GET",action:"storage.mount"}),disabled:C,size:a,placeholder:i.placeholder});case"custom":return i.customComponent?.({value:v,onChange:S=>I(i.name,S),error:E,disabled:C});case"array":{const S=v||[];let X=[];if(typeof E=="string"&&E.startsWith("["))try{X=JSON.parse(E)}catch{}const ee=()=>{I(i.name,[...S,{}])},Y=z=>{I(i.name,S.filter((T,D)=>D!==z))},M=(z,T,D)=>{const Q=[...S];Q[z]={...Q[z],[T]:D},I(i.name,Q)};return e.jsxs("div",{className:"space-y-2",children:[S.map((z,T)=>e.jsxs("div",{className:"p-4 border rounded-md dark:border-neutral-700 space-y-2 relative",children:[e.jsx("div",{className:"absolute top-2 right-2",children:e.jsx(Z,{type:"button",variant:"ghost",size:"sm",onClick:()=>Y(T),disabled:C,children:"Remove"})}),e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:i.arrayFields?.map(D=>{const Q=X?.[T]?.[D.name];return e.jsxs("div",{className:"space-y-1",children:[e.jsx("label",{className:"block",children:e.jsxs(K,{variant:"label",size:"sm",className:"font-semibold text-neutral-700 dark:text-neutral-300",children:[D.label,D.required&&e.jsx("span",{className:"text-red-500 ml-1",children:"*"})]})}),(()=>{const te={value:z?.[D.name]||"",disabled:C,required:D.required,placeholder:D.placeholder,...D.fieldProps};switch(D.type){case"text":case"email":case"password":case"number":case"tel":case"url":return e.jsx(ne,{...te,onChange:G=>M(T,D.name,G.target.value),type:D.textType||D.type,autoComplete:D.autocomplete,error:Q,size:a});case"textarea":return e.jsx(de,{...te,onChange:G=>M(T,D.name,G.target.value),rows:4,error:Q,size:a});case"select":return e.jsx(le,{...te,onChange:G=>M(T,D.name,G),options:(D.options||[]).map(G=>({...G,value:String(G.value)})),searchable:D.searchable,multiple:D.multiple,allowCreate:D.allowCreate,error:Q,size:a});case"checkbox":return e.jsx(ce,{...te,checked:!!z?.[D.name],onChange:G=>M(T,D.name,G.target.checked),size:a});case"radio":return e.jsx("div",{className:"space-y-1",children:D.options?.map(G=>e.jsxs("label",{className:"flex items-center gap-2",children:[e.jsx("input",{type:"radio",name:`${i.name}.${T}.${D.name}`,value:G.value,checked:z?.[D.name]===G.value,onChange:()=>M(T,D.name,G.value),disabled:C||G.disabled,className:"rounded-full border-neutral-100 dark:border-neutral-600"}),e.jsx(K,{variant:"label",size:"sm",children:G.label})]},G.value))});case"date":{const G=z?.[D.name];return e.jsx(ie,{...te,value:G?new Date(G):null,onChange:se=>M(T,D.name,se),size:a})}case"custom":return D.customComponent?.({value:z?.[D.name],onChange:G=>M(T,D.name,G),error:Q,disabled:C});default:return e.jsxs("p",{children:["Unsupported field type in array:"," ",D.type]})}})(),Q&&e.jsx(K,{variant:"body",size:"sm",className:"text-red-600 dark:text-red-400",children:Q})]},D.name)})})]},T)),e.jsxs(Z,{type:"button",variant:"outline",size:"sm",onClick:ee,disabled:C,children:["Add ",i.label]})]})}default:return null}},[y,B,j,m,a,I]),_=u.useCallback(i=>{if(i.conditional&&!i.conditional(y))return null;const v=i.items.filter(C=>!(C.hidden||C.conditional&&!C.conditional(y)));if(v.length===0)return null;const E=h("space-y-2",{"grid gap-2":i.layout==="grid","flex flex-wrap gap-2":i.layout==="flex"},i.layout==="grid"&&{"grid-cols-1":!i.columns||i.columns===1,"grid-cols-2":i.columns===2,"grid-cols-3":i.columns===3,"grid-cols-4":i.columns===4},i.className);return e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-8 p-6 border border-neutral dark:border-neutral-700 rounded-xl",children:[e.jsxs("div",{className:"md:col-span-1",children:[e.jsx(K,{variant:"label",size:"lg",weight:"semibold",className:"text-neutral-900 dark:text-neutral-100",children:i.title}),i.description&&e.jsx(K,{variant:"body",size:"sm",className:"text-neutral-600 dark:text-neutral-400 mt-1",children:i.description})]}),e.jsx("div",{className:"md:col-span-2",children:e.jsx("div",{className:E,children:v.map(C=>(B[C.name]&&j[C.name],e.jsxs("div",{className:h("space-y-1",C.width&&typeof C.width=="string"&&`w-[${C.width}]`,C.width&&typeof C.width=="number"&&`col-span-${C.width}`),children:[C.type!=="custom"&&e.jsx("label",{className:"block",children:e.jsxs(K,{variant:"label",size:"sm",className:"font-medium text-neutral-700 dark:text-neutral-300",children:[C.label,C.required&&e.jsx("span",{className:"text-red-500 ml-1",children:"*"})]})}),$(C)]},C.name)))})})]},i.id)},[y,B,j,$]),O=h("space-y-6",{"max-w-md":a==="sm","max-w-2xl":a==="md","max-w-4xl":a==="lg","max-w-full":a==="full"},f);return e.jsxs("form",{ref:w,onSubmit:W,className:O,children:[e.jsx("div",{className:"space-y-8",children:t.map(_)}),g&&e.jsxs("div",{className:h("flex gap-3 justify-end pt-8"),children:[r&&e.jsx(Z,{type:"button",variant:b.variant,size:b.size||a,disabled:b.disabled||m,onClick:r,className:b.className,children:b.label}),e.jsx(Z,{type:"submit",variant:p.variant,size:p.size||a,disabled:p.disabled||m,loading:m,className:p.className,children:p.label})]})]})},pt={default:"bg-neutral-container text-default",primary:"bg-accent-container text-accent",secondary:"bg-neutral-container text-muted",success:"bg-success-container text-success",warning:"bg-notice-container text-on-notice",error:"bg-error-container text-error",info:"bg-beta-container text-link"},bt={sm:"px-2 py-0.5 text-xs",md:"px-2.5 py-1 text-sm",lg:"px-3 py-1.5 text-base"},gt={default:"bg-neutral-fill",primary:"bg-accent-fill",secondary:"bg-neutral-fill",success:"bg-success-fill",warning:"bg-notice-fill",error:"bg-error-fill",info:"bg-beta-fill"};function vt({variant:t="default",size:n="md",dot:s=!1,icon:r,dismissible:l=!1,onDismiss:o,className:d,children:p,...b}){return e.jsxs("span",{className:h("inline-flex items-center font-medium rounded-full",pt[t],bt[n],d),...b,children:[s&&e.jsx("span",{className:h("w-2 h-2 rounded-full mr-1.5",gt[t])}),r&&e.jsx("span",{className:h("flex-shrink-0",p&&"mr-1"),children:r}),p,l&&o&&e.jsx("button",{onClick:o,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 yt={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"},jt={primary:"text-primary",secondary:"text-secondary-600",white:"text-white",current:"text-current"},Nt={xs:"text-xs",sm:"text-sm",md:"text-sm",lg:"text-base",xl:"text-lg"};function wt({size:t="md",variant:n="primary",label:s="Loading...",showLabel:r=!1,className:l,...o}){return e.jsxs("div",{className:h("inline-flex items-center",r?"flex-col space-y-2":"",l),...o,children:[e.jsxs("svg",{className:h("animate-spin",yt[t],jt[n]),fill:"none",viewBox:"0 0 24 24","aria-hidden":!r,role:r?"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"})]}),r&&e.jsx("span",{className:h("text-secondary-600 dark:text-secondary-400",Nt[t]),children:s}),!r&&e.jsx("span",{className:"sr-only",children:s})]})}const kt={xs:"w-5 h-5 text-[10px]",sm:"w-6 h-6 text-xs",md:"w-7 h-7 text-[13px]",lg:"w-9 h-9 text-sm"};function Ct(t){if(!t)return"?";const n=t.trim().split(/[^\p{L}\p{N}]+/u).filter(Boolean);return n.length>=2?(n[0][0]+n[1][0]).toUpperCase():n.length===1?n[0].slice(0,2).toUpperCase():"?"}const Me=({name:t,src:n,size:s="sm",className:r,title:l})=>{const[o,d]=u.useState(!1),p=h("inline-flex items-center justify-center rounded-full overflow-hidden shrink-0 font-semibold select-none bg-neutral-border-emphasis text-default",kt[s],r);return n&&!o?e.jsx("img",{src:n,alt:t??"",title:l??t,className:h(p,"object-cover"),onError:()=>d(!0)}):e.jsx("span",{className:p,title:l??t,"aria-label":t,children:Ct(t)})},ve="shadow-[0_0_0_2px_var(--base-module)]",St="shadow-[0_0_0_2px_var(--base-module),0_0_0_3.5px_var(--accent-border)]",Et=({people:t,max:n=4,size:s="sm",className:r})=>{if(t.length===0)return null;const l=t.slice(0,n),o=t.length-l.length;return e.jsxs("span",{className:h("inline-flex items-center",r),children:[l.map((d,p)=>e.jsx(Me,{name:d.name,src:d.src,size:s,title:d.name?d.seen===!1?`${d.name} — nog niet gelezen`:d.name:void 0,className:h(p>0&&"-ml-2",d.owner?St:ve,d.seen===!1&&"opacity-40")},d.id??`${d.name}-${p}`)),o>0&&e.jsxs("span",{className:h("inline-flex items-center justify-center rounded-full shrink-0 -ml-2 font-semibold bg-neutral-container text-muted",s==="xs"?"w-5 h-5 text-[10px]":s==="md"?"w-7 h-7 text-[11px]":s==="lg"?"w-9 h-9 text-xs":"w-6 h-6 text-[10px]",ve),children:["+",o]})]})},Lt=({src:t,alt:n,size:s="md",aspectRatio:r="auto",radius:l="md",showLoading:o=!0,showError:d=!0,fallback:p,loadingContent:b,errorContent:g,className:x,onLoad:a,onError:m,...f})=>{const[w,N]=u.useState(!0),[y,A]=u.useState(!1),[j,H]=u.useState(t),B=O=>{N(!1),A(!1),a?.(O)},q=O=>{if(N(!1),A(!0),p&&j!==p){H(p),A(!1),N(!0);return}m?.(O)},F=h("relative overflow-hidden bg-neutral-100 dark:bg-neutral-800",{"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":r==="square","aspect-video":r==="video","aspect-[3/4]":r==="portrait","aspect-[4/3]":r==="landscape"},{"rounded-none":l==="none","rounded-sm":l==="sm","rounded-md":l==="md","rounded-lg":l==="lg","rounded-xl":l==="xl","rounded-full":l==="full"},x),I=h("w-full h-full object-cover transition-opacity duration-200",{"opacity-0":w||y,"opacity-100":!w&&!y}),W=h("absolute inset-0 flex items-center justify-center","text-neutral-400 dark:text-neutral-500"),$=e.jsx("div",{className:"animate-pulse",children:e.jsx("div",{className:"w-6 h-6 bg-neutral-300 dark:bg-neutral-600 rounded"})}),_=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:F,children:[e.jsx("img",{...f,src:j,alt:n,className:I,onLoad:B,onError:q}),w&&o&&e.jsx("div",{className:W,children:b||$}),y&&d&&e.jsx("div",{className:W,children:g||_})]})},Mt=({title:t,subtitle:n,actions:s=[],children:r,className:l,backLabel:o="Back",backClassName:d,onBack:p,editable:b=!1,onTitleChange:g})=>{const[x,a]=u.useState(!1),[m,f]=u.useState(t),w=u.useRef(null);u.useEffect(()=>{f(t)},[t]),u.useEffect(()=>{x&&w.current&&(w.current.focus(),w.current.select())},[x]);const N=()=>{b&&a(!0)},y=()=>{a(!1),m.trim()!==""&&m!==t&&g?g(m.trim()):f(t)},A=j=>{j.key==="Enter"?w.current?.blur():j.key==="Escape"&&(f(t),a(!1))};return e.jsxs("div",{className:h("p-5 pb-3 border-b border-neutral",l),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-default",children:[p&&e.jsx("button",{type:"button",onClick:p,className:h("flex items-center text-sm cursor-pointer transition",d),children:e.jsx(U.ArrowLeft,{size:16,color:"currentColor"})}),x?e.jsx("input",{ref:w,type:"text",value:m,onChange:j=>f(j.target.value),onBlur:y,onKeyDown:A,className:"text-1xl font-semibold bg-transparent border-b-1 border-neutral rounded-lg outline-none focus:border-none px-1 -mx-1 min-w-0 flex-1"}):e.jsxs("div",{className:"group flex items-center gap-1.5 min-w-0",children:[e.jsx("h2",{onClick:N,className:h("text-2xl font-semibold truncate",b&&"cursor-pointer"),title:b?"Klik om te bewerken":void 0,children:t}),b&&e.jsx(U.Pencil,{size:15,onClick:N,className:"shrink-0 cursor-pointer 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(j=>j.splitOptions&&j.splitOptions.length>0?e.jsx(pe,{label:j.label,onClick:j.onClick,icon:j.icon,variant:j.variant==="primary"?"primary":"secondary",options:j.splitOptions,disabled:j.disabled},j.id):e.jsxs("button",{type:"button",onClick:H=>{H.stopPropagation(),H.target.blur(),j.onClick()},disabled:j.disabled,className:h("btn",{o__primary:j.variant==="primary",o__secondary:j.variant==="secondary"||j.variant==="outline",o__ghost:j.variant==="ghost",o__destructive:j.variant==="destructive"}),children:[j.icon&&e.jsx("span",{className:"mr-2",children:j.icon}),j.label]},j.id))})]}),r&&e.jsx("div",{className:"mt-4",children:r})]})},Tt=({actions:t=[],onBack:n,backLabel:s="Back",className:r,children:l})=>e.jsxs("div",{className:h("flex items-center gap-2 mb-3",r),children:[n&&e.jsxs("button",{type:"button",onClick:n,className:"flex items-center gap-1 text-sm text-neutral-700 dark:text-neutral-300 hover:text-neutral-900 dark:hover:text-neutral-100 cursor-pointer transition px-2 py-1 rounded",children:[e.jsx(U.ArrowLeft,{size:16}),e.jsx("span",{children:s})]}),l&&e.jsx("div",{className:"flex-1 min-w-0",children:l}),t.length>0&&e.jsx("div",{className:h("flex flex-wrap gap-2",!l&&"ml-auto"),children:t.map(o=>o.splitOptions&&o.splitOptions.length>0?e.jsx(pe,{label:o.label,onClick:o.onClick,icon:o.icon,variant:o.variant==="primary"?"primary":"secondary",options:o.splitOptions,disabled:o.disabled},o.id):e.jsxs("button",{type:"button",onClick:d=>{d.stopPropagation(),d.target.blur(),o.onClick()},disabled:o.disabled,className:h("btn",{o__primary:o.variant==="primary",o__secondary:o.variant==="secondary"||o.variant==="outline",o__ghost:o.variant==="ghost",o__destructive:o.variant==="destructive"}),children:[o.icon&&e.jsx("span",{className:"mr-2",children:o.icon}),o.label]},o.id))})]});function $t(t,n){return n.split(".").reduce((s,r)=>s&&typeof s=="object"&&r in s?s[r]:void 0,t)}const Dt=({groups:t,data:n,size:s="md",className:r})=>{const l=x=>{if(!x)return"-";try{return new Date(x).toLocaleDateString("nl-NL",{year:"numeric",month:"long",day:"numeric"})}catch{return String(x)}},o=x=>x?"Ja":"Nee",d=(x,a)=>{if(!a)return String(x||"-");const m=a.find(f=>f.value===x);return m?m.label:String(x||"-")},p=u.useCallback(x=>{const a=$t(n,x.name);if(x.type==="array"){const f=a;return!f||f.length===0?e.jsx(K,{variant:"body",size:"sm",className:"text-neutral-500 dark:text-neutral-400",children:"Geen items"}):e.jsx("div",{className:"space-y-3",children:f.map((w,N)=>e.jsxs("div",{className:"p-4 border border-neutral-200 dark:border-neutral-700 rounded-lg space-y-3",children:[e.jsx("div",{className:"flex items-center justify-between",children:e.jsxs(K,{variant:"label",size:"sm",weight:"medium",className:"text-neutral-700 dark:text-neutral-300",children:[x.label," ",N+1]})}),e.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-3",children:x.arrayFields?.map(y=>{const A=w?.[y.name];let j="-";switch(y.type){case"text":case"email":case"number":case"tel":case"url":case"textarea":j=A||"-";break;case"select":case"radio":j=d(A,y.options);break;case"checkbox":j=o(A);break;case"date":j=l(A);break;case"custom":j=y.customComponent?.({value:A});break;default:j=String(A||"-")}return y.format&&(j=y.format(A,w)),e.jsxs("div",{className:"space-y-1",children:[e.jsx(K,{variant:"label",size:"xs",className:"text-neutral-600 dark:text-neutral-400",children:y.label}),e.jsx(K,{variant:"body",size:"sm",className:"text-neutral-900 dark:text-neutral-100",children:j})]},y.name)})})]},N))})}if(x.type==="custom"&&x.customComponent)return x.customComponent({value:a});if(x.format){const f=x.format(a,n);return e.jsx(K,{variant:"body",size:"sm",className:"text-neutral-900 dark:text-neutral-100",children:f})}let m="-";switch(x.type){case"text":case"email":case"password":case"number":case"tel":case"url":m=a?String(a):"-";break;case"textarea":m=a?e.jsx("div",{className:"whitespace-pre-wrap",children:String(a||"-")}):"-";break;case"select":case"radio":m=d(a,x.options);break;case"checkbox":m=o(a);break;case"date":m=l(a);break;default:m=a?String(a):"-"}return e.jsx(K,{variant:"body",size:"sm",className:"text-neutral-900 dark:text-neutral-100",children:m})},[n]),b=u.useCallback(x=>{if(x.conditional&&!x.conditional(n))return null;const a=x.items.filter(f=>!(f.hidden||f.conditional&&!f.conditional(n)));if(a.length===0)return null;const m=h("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-neutral dark:border-neutral-700 rounded-xl",children:[e.jsxs("div",{className:"md:col-span-1",children:[e.jsx(K,{variant:"label",size:"lg",weight:"semibold",className:"text-neutral-900 dark:text-neutral-100",children:x.title}),x.description&&e.jsx(K,{variant:"body",size:"sm",className:"text-neutral-600 dark:text-neutral-400 mt-1",children:x.description})]}),e.jsx("div",{className:"md:col-span-2",children:e.jsx("div",{className:m,children:a.map(f=>e.jsxs("div",{className:h("space-y-1",f.width&&typeof f.width=="string"&&`w-[${f.width}]`,f.width&&typeof f.width=="number"&&`col-span-${f.width}`),children:[f.type!=="custom"&&e.jsx(K,{variant:"label",size:"sm",className:"font-medium text-neutral-700 dark:text-neutral-300",children:f.label}),p(f)]},f.name))})})]},x.id)},[n,p]),g=h("space-y-6",{"max-w-md":s==="sm","max-w-2xl":s==="md","max-w-4xl":s==="lg","max-w-full":s==="full"},r);return e.jsx("div",{className:g,children:e.jsx("div",{className:"space-y-8",children:t.map(b)})})},Te=({item:t,isSelectedHandler:n,onClick:s,depth:r=0})=>{const[l,o]=u.useState(t.defaultCollapsed??!1),d=t.children&&t.children.length>0,p=d&&r===0,b=()=>{d&&o(!l)},g=n?n(t.path):!1;return e.jsxs("li",{children:[e.jsxs("div",{className:h("flex flex-row w-full py-1 rounded-lg items-center h-8 transition-colors cursor-pointer px-3 pr-1 no-underline text-sm",{"active-nav-item":g&&!d,"shadow-lvl-0":g&&!d,"font-semibold":g||p}),onClick:()=>{d?b():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}),d&&e.jsx("span",{className:`${l?"collapsed":""}`,children:e.jsx(U.ChevronDownIcon,{className:"w-4 h-4 text-muted"})})]}),d&&!l&&e.jsx("ul",{className:"sidebar-menu-nested-items mb-1",children:t.children?.map((x,a)=>e.jsx(Te,{item:x,isSelectedHandler:n,onClick:s,depth:r+1},a))})]})},It=({title:t,actionIcons:n,items:s,isSelectedHandler:r,onClick:l,preMenuItemsComponent:o})=>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-xl font-semibold text-default mb-2",children:t}),e.jsx("div",{className:"sidebar-menu-actions",children:n?.map((d,p)=>e.jsx("span",{className:"sidebar-menu-action-icon",children:d},p))})]}),o&&e.jsx("div",{className:"sidebar-menu-pre-items mb-4",children:o}),e.jsx("ul",{children:s.map((d,p)=>!d.path&&!d.label&&!d.children?e.jsx("span",{className:"flex w-full h-4"},p):e.jsx(Te,{item:d,isSelectedHandler:r,onClick:l},p))})]}),At=({level:t=1,size:n,weight:s="bold",color:r="current",align:l="left",truncate:o=!1,className:d,children:p,...b})=>{const g=n||zt(t),x=h("font-primary",{"text-xs":g==="xs","text-sm":g==="sm","text-base":g==="md","text-lg":g==="lg","text-xl":g==="xl","text-2xl":g==="2xl","text-3xl":g==="3xl","text-4xl":g==="4xl"},{"font-light":s==="light","font-normal":s==="normal","font-medium":s==="medium","font-semibold":s==="semibold","font-bold":s==="bold"},{"text-primary":r==="primary","text-secondary":r==="secondary","text-[var(--text-accent)]":r==="accent","text-[var(--text-success)]":r==="success","text-warning":r==="warning","text-[var(--text-error)]":r==="error","text-info":r==="info","text-[var(--text-default)]":r==="neutral","text-current":r==="current"},{"text-left":l==="left","text-center":l==="center","text-right":l==="right"},{truncate:o},d),a=`h${t}`;return e.jsx(a,{className:x,...b,children:p})};function zt(t){return{1:"4xl",2:"3xl",3:"2xl",4:"xl",5:"lg",6:"md"}[t]||"md"}const Pt=({items:t,type:n="unordered",variant:s="default",size:r="md",interactive:l=!1,className:o,itemClassName:d})=>{const p=h("space-y-1",{"":s==="default","space-y-0":s==="flush","border border-neutral-200 dark:border-neutral-700 rounded-lg overflow-hidden":s==="bordered","divide-y divide-neutral-200 dark:divide-neutral-700":s==="divided"},{"text-sm":r==="sm","text-base":r==="md","text-lg":r==="lg"},o),b=(a,m)=>h("transition-colors duration-200",{"py-1 px-2":r==="sm"&&(s==="bordered"||s==="divided"),"py-2 px-3":r==="md"&&(s==="bordered"||s==="divided"),"py-3 px-4":r==="lg"&&(s==="bordered"||s==="divided")},l&&!a.disabled&&{"cursor-pointer hover:bg-neutral-50 dark:hover:bg-neutral-800":!0,"focus:outline-none focus:bg-neutral-100 dark:focus:bg-neutral-700":!0},a.disabled&&{"opacity-50 cursor-not-allowed":!0},d),g=a=>{l&&!a.disabled&&a.onClick&&a.onClick()},x=(a,m)=>{l&&!m.disabled&&(a.key==="Enter"||a.key===" ")&&(a.preventDefault(),m.onClick?.())};return n==="ordered"?e.jsx("ol",{className:p,children:t.map((a,m)=>e.jsx("li",{className:b(a),onClick:()=>g(a),onKeyDown:f=>x(f,a),tabIndex:l&&!a.disabled?0:void 0,role:l?"button":void 0,children:a.content},a.id||m))}):n==="description"?e.jsx("dl",{className:p,children:t.map((a,m)=>e.jsx("div",{className:b(a),onClick:()=>g(a),onKeyDown:f=>x(f,a),tabIndex:l&&!a.disabled?0:void 0,role:l?"button":void 0,children:a.content},a.id||m))}):e.jsx("ul",{className:p,children:t.map((a,m)=>e.jsx("li",{className:b(a),onClick:()=>g(a),onKeyDown:f=>x(f,a),tabIndex:l&&!a.disabled?0:void 0,role:l?"button":void 0,children:a.content},a.id||m))})},Bt=({commands:t,isOpen:n,onClose:s,labels:r,initialCommandPath:l,initialActiveIndex:o})=>{const[d,p]=u.useState(""),[b,g]=u.useState(l||[]),[x,a]=u.useState(o||0),m=u.useRef(null),f=u.useRef(null),N=(b.length?t.find(y=>y.id===b[0])?.subCommands||[]:t).filter(y=>y.label.toLowerCase().includes(d.toLowerCase()));return u.useEffect(()=>{n||(p(""),g(l||[]),a(o||0))},[n]),u.useEffect(()=>{const y=A=>{if(n){if(A.key==="Escape")s();else if(A.key==="ArrowUp")a(j=>j>0?j-1:N.length-1);else if(A.key==="ArrowDown")a(j=>j<N.length-1?j+1:0);else if(A.key==="Enter"){const j=N[x];j&&(j.subCommands?(g([...b,j.id]),a(0)):j.action&&(j.action(),s()))}}};return document.addEventListener("keydown",y),()=>document.removeEventListener("keydown",y)},[n,s,N,x,b]),u.useEffect(()=>{const y=A=>{m.current&&!m.current.contains(A.target)&&s()};return n&&document.addEventListener("mousedown",y),()=>document.removeEventListener("mousedown",y)},[n,s]),u.useEffect(()=>{if(!n)return;f.current?.querySelector(`[data-index="${x}"]`)?.scrollIntoView({block:"nearest"})},[x,n]),n?e.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center shadow-lvl-0",children:e.jsxs("div",{className:"flex flex-col w-full max-w-lg max-h-[80vh] p-2 mx-auto rounded-xl border border-neutral shadow-lg bg-module",ref:m,children:[e.jsxs("div",{className:"flex items-center gap-2 px-3 flex-shrink-0",children:[e.jsx(U.Search,{className:"w-4 h-4 text-muted shrink-0"}),e.jsx("input",{type:"text",autoFocus:!0,placeholder:r?.searchPlaceholder||"Search commands...",value:d,onChange:y=>p(y.target.value),className:"w-full py-2 text-default border-0 focus:outline-none focus:ring-0 focus:border-0 focus:shadow-none bg-transparent"})]}),e.jsxs("div",{ref:f,className:"mt-2 pt-2 text-sm border-t border-neutral max-h-[50vh] overflow-y-auto",children:[N.length===0&&e.jsx("div",{className:"text-muted text-center text-sm",children:r?.noCommandsFound||"No commands found"}),N.map((y,A)=>e.jsxs("div",{"data-index":A,className:`flex items-center p-2 cursor-pointer rounded-md text-default ${A===x?"bg-neutral-container":""}`,onClick:()=>{y.subCommands?(g([...b,y.id]),a(0)):y.action&&(y.action(),s())},onMouseEnter:()=>a(A),children:[y.icon&&e.jsx("span",{className:"mr-3",children:y.icon}),e.jsx("span",{className:"flex-grow",children:y.label}),y.subCommands&&e.jsx("span",{className:"text-muted",children:e.jsx(U.ChevronRight,{className:"w-4 h-4"})})]},y.id))]}),e.jsxs("div",{className:"flex items-center gap-4 px-3 pt-2 mt-2 text-xs text-muted border-t border-neutral",children:[e.jsxs("span",{className:"flex items-center gap-1.5",children:[e.jsx("kbd",{className:"inline-flex items-center justify-center min-w-[1.25rem] px-1 py-0.5 rounded border border-neutral bg-module-subtle text-[10px] font-medium not-italic",children:"↑↓"}),r?.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-[1.25rem] px-1 py-0.5 rounded border border-neutral bg-module-subtle text-[10px] font-medium not-italic",children:"↵"}),r?.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-[1.25rem] px-1 py-0.5 rounded border border-neutral bg-module-subtle text-[10px] font-medium not-italic",children:"Esc"}),r?.close||"to close"]})]})]})}):null},Rt={none:"p-0",xs:"p-1",sm:"p-2",md:"p-4",lg:"p-6",xl:"p-8","2xl":"p-12"},_t={none:"m-0",xs:"m-1",sm:"m-2",md:"m-4",lg:"m-6",xl:"m-8","2xl":"m-12"},Ft={none:"",primary:"bg-primary",secondary:"bg-secondary",accent:"bg-accent",success:"bg-success",warning:"bg-warning",error:"bg-error",info:"bg-info",neutral:"bg-neutral",white:"bg-white",module:"bg-module","module-subtle":"bg-module-subtle",backdrop:"bg-backdrop",editor:"bg-editor",input:"bg-input"},Ot={none:"rounded-none",sm:"rounded-sm",md:"rounded-md",lg:"rounded-lg",xl:"rounded-xl",full:"rounded-full"},Vt={none:"shadow-none",sm:"shadow-sm shadow-lvl-0",md:"shadow-md shadow-lvl-0",lg:"shadow-lg shadow-lvl-0",xl:"shadow-xl shadow-lvl-0","2xl":"shadow-2xl shadow-lvl-0"},Wt={none:"border-0",sm:"border",md:"border-2",lg:"border-4"},Ht={primary:"border-primary",secondary:"border-secondary",accent:"border-accent",success:"border-success",warning:"border-warning",error:"border-error",info:"border-info",neutral:"border-neutral",white:"border-white"},be=u.forwardRef(({padding:t,margin:n,background:s,radius:r,shadow:l,border:o,borderColor:d,className:p,children:b,...g},x)=>e.jsx("div",{ref:x,className:h(t&&Rt[t],n&&_t[n],s&&Ft[s],r&&Ot[r],l&&Vt[l],o&&Wt[o],d&&Ht[d],p),...g,children:b}));be.displayName="Box";const qt=({children:t,title:n,...s})=>e.jsxs(be,{background:"module",radius:"xl",shadow:"sm",...s,children:[n&&e.jsx("span",{className:"text-base font-medium text-default mb-2",children:n}),t]});function Gt({identifier:t,resourceLoader:n,framework:s="react",fallback:r,componentProps:l,className:o}){const d=u.useRef(null),[p,b]=u.useState(!0),[g,x]=u.useState(null),a=u.useRef(null);return u.useRef(null),u.useEffect(()=>{let m=!0;return(async()=>{b(!0);try{const w=await n();if(!m)return;const N=w.component||w.default||w;x(s==="react"?()=>N:()=>w)}catch(w){console.error(`[FederatedResource] Load failed: ${t}`,w)}finally{m&&b(!1)}})(),()=>{m=!1}},[t,n]),u.useEffect(()=>{if(p||!g||s==="react")return;const m=d.current;if(m){if(s==="svelte"){const f=g.default||g,w=new f({target:m,props:l||{}});return a.current=w,()=>w.$destroy()}if(g.mount){const f=g.mount({container:m,props:l||{}});return()=>{typeof f=="function"?f():g.unmount?.(m)}}}},[g,s,p]),u.useEffect(()=>{s==="svelte"&&a.current&&a.current.$set?.(l)},[l,s]),e.jsxs("div",{ref:d,className:o,style:{display:"contents"},children:[p&&r,s==="react"&&g&&e.jsx(g,{...l})]})}class Ut extends u.Component{constructor(){super(...arguments),this.state={hasError:!1,error:null}}static getDerivedStateFromError(n){return{hasError:!0,error:n}}componentDidCatch(n,s){console.error(`[ErrorBoundary] Error in ${this.props.name||"Component"}:`,n,s)}render(){return this.state.hasError?this.props.fallback?this.props.fallback:e.jsxs("div",{className:"p-4 m-4 border border-red-200 bg-red-50 rounded-lg",children:[e.jsx("h2",{className:"text-lg font-semibold text-red-800",children:"Something went wrong"}),e.jsx("p",{className:"text-sm text-red-600 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-red-100 text-red-800 rounded hover:bg-red-200 transition-colors text-sm",onClick:()=>this.setState({hasError:!1,error:null}),children:"Try again"})]}):this.props.children}}exports.Avatar=Me;exports.AvatarStack=Et;exports.Badge=vt;exports.Box=be;exports.Button=Z;exports.ButtonGroup=Fe;exports.Card=qt;exports.Checkbox=ce;exports.CommandPalette=Bt;exports.ContentLoading=Ne;exports.DatePicker=ie;exports.Dropdown=we;exports.ErrorBoundary=Ut;exports.FederatedResource=Gt;exports.FolderSelect=Le;exports.Form=ht;exports.Heading=At;exports.Icon=re;exports.Image=Lt;exports.Link=Oe;exports.List=Pt;exports.MeetingGrid=Ae;exports.Modal=Se;exports.PageHeader=Mt;exports.PageToolbar=Tt;exports.ParticipantTile=ze;exports.Popover=ye;exports.SearchableTextField=je;exports.Select=le;exports.SidebarMenu=It;exports.Spinner=wt;exports.SplitButton=pe;exports.StorageInput=Ee;exports.TabBar=dt;exports.Table=he;exports.Tabs=Ce;exports.Text=K;exports.TextArea=de;exports.TextField=ne;exports.VideoSurface=Pe;exports.View=Dt;exports.cn=h;exports.createSizes=Ie;exports.createVariants=De;
2
2
  //# sourceMappingURL=index.cjs.map