@starasia/admin 14.0.0 → 14.0.2

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.js CHANGED
@@ -1,4 +1,4 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const ln=require("@starasia/alert"),Zt=require("@starasia/avatar"),it=require("@starasia/badges"),x=require("@starasia/box"),yt=require("@starasia/breadcrumb"),H=require("@starasia/button"),Er=require("@starasia/card"),ht=require("@starasia/date"),Pe=require("@starasia/dialog"),Gt=require("@starasia/drawer"),jt=require("@starasia/dropdown"),Ce=require("@starasia/hooks"),bt=require("@starasia/http"),dt=require("@starasia/input"),T=require("@starasia/menu"),Mt=require("@starasia/pagination"),Ft=require("@starasia/storage"),G=require("@starasia/table"),cn=require("@starasia/tabs"),Fr=require("@starasia/textarea"),pt=require("@starasia/theme"),an=require("@starasia/toast"),vt=require("@starasia/toggle"),Fe=require("@starasia/tooltip"),nt=require("@starasia/checkbox"),Mr=require("@starasia/radio"),v=require("@starasia/text"),E=require("@starasia/icon"),ce=require("@starasia/flex"),dn=require("@starasia/grid"),un=require("@starasia/progress"),xn=require("@starasia/stepper"),hn=require("@starasia/accordion"),fn=require("@starasia/story-record"),Ye=require("@starasia/skeleton"),mn=require("@starasia/progress-stepper"),e=require("react/jsx-runtime"),d=require("react"),Yt=require("react-dom"),is=require("react-easy-crop"),ls={menus:[],menuBottom:void 0,logo:"",appName:"Workspace",userData:null,setUserData:()=>{}},Wr=d.createContext(ls),zr=()=>d.useContext(Wr),Zn=t=>{const[r,n]=d.useState((t==null?void 0:t.initialUserData)||null);return{userData:r,setUserData:n}},Gn=d.createContext({badges:{},setBadge:()=>{},setBadges:()=>{},clearBadge:()=>{}}),Qn=({children:t})=>{const[r,n]=d.useState({}),s=d.useCallback(c=>{n(a=>typeof c=="function"?c(a):c)},[]),o=d.useCallback((c,a)=>{n(u=>{const f=typeof a=="function"?a(u[c]):a;return{...u,[c]:f}})},[]),i=d.useCallback(c=>{n(a=>{if(!(c in a))return a;const u={...a};return delete u[c],u})},[]),l=d.useMemo(()=>({badges:r,setBadge:o,setBadges:s,clearBadge:i}),[r,o,s,i]);return e.jsx(Gn.Provider,{value:l,children:t})},Un=()=>d.useContext(Gn),_t=(t,r)=>{const n=r!==void 0?r:t;return n==null?null:typeof n=="string"||typeof n=="number"?{value:n}:n},Hr=240,Pr=200,Vr=480,cs="sa-sidebar-width",Ir=(t,r,n)=>Math.min(Math.max(t,r),n),as=(t,r,n,s)=>{if(typeof window>"u")return r;try{const o=window.localStorage.getItem(t);if(!o)return r;const i=parseInt(o,10);return Number.isFinite(i)?Ir(i,n,s):r}catch{return r}},gn=(t,r)=>{if(!(typeof window>"u"))try{window.localStorage.setItem(t,String(r))}catch{}},Jn=d.createContext({collapsed:!1,setCollapsed:()=>{},toggle:()=>{},collapse:()=>{},expand:()=>{},width:Hr,setWidth:()=>{},resetWidth:()=>{},minWidth:Pr,maxWidth:Vr,mobileOpen:!1,setMobileOpen:()=>{},openMobile:()=>{},closeMobile:()=>{},toggleMobile:()=>{}}),Yn=({children:t,defaultCollapsed:r=!1,defaultWidth:n=Hr,minWidth:s=Pr,maxWidth:o=Vr,widthStorageKey:i=cs})=>{const[l,c]=d.useState(r),[a,u]=d.useState(!1),[f,g]=d.useState(()=>as(i,n,s,o)),m=d.useCallback(C=>{c(R=>typeof C=="function"?C(R):C)},[]),p=d.useCallback(()=>c(C=>!C),[]),S=d.useCallback(()=>c(!0),[]),b=d.useCallback(()=>c(!1),[]),I=d.useCallback(C=>{g(R=>{const L=typeof C=="function"?C(R):C,U=Ir(Math.round(L),s,o);return gn(i,U),U})},[s,o,i]),B=d.useCallback(()=>{const C=Ir(n,s,o);gn(i,C),g(C)},[n,s,o,i]),F=d.useCallback(C=>{u(R=>typeof C=="function"?C(R):C)},[]),w=d.useCallback(()=>u(!0),[]),D=d.useCallback(()=>u(!1),[]),A=d.useCallback(()=>u(C=>!C),[]),O=d.useMemo(()=>({collapsed:l,setCollapsed:m,toggle:p,collapse:S,expand:b,width:f,setWidth:I,resetWidth:B,minWidth:s,maxWidth:o,mobileOpen:a,setMobileOpen:F,openMobile:w,closeMobile:D,toggleMobile:A}),[l,m,p,S,b,f,I,B,s,o,a,F,w,D,A]);return e.jsx(Jn.Provider,{value:O,children:t})},Xn=()=>d.useContext(Jn),$n=d.createContext(null),Kn=({adapter:t,children:r})=>e.jsx($n.Provider,{value:t,children:r}),ot=()=>{const t=d.useContext($n);if(!t)throw new Error("[@starasia/admin] Router adapter belum dipasang. Bungkus aplikasi dengan <App routerAdapter={...} /> atau <StarasiaRouterProvider adapter={...}>. Import adapter dari '@starasia/admin/adapters/react-router' atau '@starasia/admin/adapters/tanstack'.");return t},eo=({router:t,routerAdapter:r,menus:n=[],menuBottom:s,logo:o,appName:i="Workspace",initialUserData:l,theme:c})=>{const a=Zn({initialUserData:l}),{theme:u}=pt.useTheme();return e.jsx(Kn,{adapter:r,children:e.jsx(Wr.Provider,{value:{logo:o,appName:i,menus:n,userData:a.userData,setUserData:a.setUserData,menuBottom:s},children:e.jsx(Qn,{children:e.jsx(Yn,{children:c?e.jsx(pt.ThemeProvider,{value:c,children:t}):u?e.jsx(pt.ThemeProvider,{value:u,children:t}):t})})})})},ds=d.memo(eo);function to({collapsed:t=!1,children:r}){if(!r)return null;const n=typeof r=="function",s=n?r({collapsed:t}):r;return s==null||s===!1?null:e.jsx("div",{style:{position:"sticky",top:"var(--app-header-height, 4rem)",zIndex:1,borderBottom:"1px solid var(--sa-border-subtle, #0b120e24)",paddingLeft:t?"calc((var(--app-header-height, 4rem) - 2rem) / 2)":"0.5rem",paddingRight:t?"calc((var(--app-header-height, 4rem) - 2rem) / 2)":"0.5rem",paddingTop:"0.5rem",paddingBottom:"0.5rem",boxSizing:"border-box"},children:n?s:e.jsx("div",{style:{opacity:t?0:1,transition:"opacity 0.3s",visibility:t?"hidden":"visible"},children:s})})}const Nr=d.createContext(null);function ro({children:t}){const[r,n]=d.useState(null),[s,o]=d.useState(null),[i,l]=d.useState(null),[c,a]=d.useState(0),u=d.useCallback(()=>(a(f=>f+1),()=>a(f=>f-1)),[]);return e.jsx(Nr.Provider,{value:{prependNode:r,appendNode:s,replaceNode:i,setPrependNode:n,setAppendNode:o,setReplaceNode:l,replaceCount:c,registerReplace:u},children:t})}function no({children:t}){const r=d.useContext(Nr);return r?e.jsxs(e.Fragment,{children:[e.jsx("div",{ref:r.setPrependNode,style:{display:"contents"}}),r.replaceCount>0?e.jsx("div",{ref:r.setReplaceNode,style:{display:"contents"}}):t,e.jsx("div",{ref:r.setAppendNode,style:{display:"contents"}})]}):e.jsx(e.Fragment,{children:t})}function us({children:t,mode:r="append"}){const n=d.useContext(Nr);if(d.useEffect(()=>{if(!(r!=="replace"||!n))return n.registerReplace()},[r,n]),!n)return process.env.NODE_ENV!=="production"&&console.warn("[HeaderLeftSlot] used outside AppLayout — content not rendered"),null;const s=r==="prepend"?n.prependNode:r==="replace"?n.replaceNode:n.appendNode;return s?Yt.createPortal(t,s):null}const _r=d.createContext(null);function oo({children:t}){const[r,n]=d.useState({}),[s,o]=d.useState({}),i=d.useCallback((a,u)=>{n(f=>f[a]===u?f:{...f,[a]:u})},[]),l=d.useCallback(a=>(o(u=>({...u,[a]:(u[a]??0)+1})),()=>o(u=>({...u,[a]:Math.max(0,(u[a]??0)-1)}))),[]),c=d.useMemo(()=>({outletNodes:r,setOutletNode:i,slotCounts:s,registerSlot:l}),[r,i,s,l]);return e.jsx(_r.Provider,{value:c,children:t})}function so({slotKey:t,fallback:r}){const n=d.useContext(_r),s=n?(n.slotCounts[t]??0)>0:!1,o=d.useRef(n==null?void 0:n.setOutletNode);o.current=n==null?void 0:n.setOutletNode;const i=d.useCallback(l=>{var c;return(c=o.current)==null?void 0:c.call(o,t,l)},[t]);return e.jsx(e.Fragment,{children:s?e.jsx("div",{ref:i,style:{display:"contents"}}):r})}function xs({slotKey:t,children:r}){const n=d.useContext(_r),s=d.useRef(n==null?void 0:n.registerSlot);if(s.current=n==null?void 0:n.registerSlot,d.useEffect(()=>{var i;return(i=s.current)==null?void 0:i.call(s,t)},[t]),!n)return process.env.NODE_ENV!=="production"&&console.warn("[SidebarGroupSlot] used outside AppLayout — content not rendered"),null;const o=n.outletNodes[t];return o?Yt.createPortal(r,o):null}const Qt="moduleSwitcherGroupId",Lr="sa-module-switcher-change";function yn(){if(typeof window>"u")return null;const t=window.localStorage.getItem(Qt);if(t===null)return null;const r=Number(t);return Number.isFinite(r)?r:null}function io(t){typeof window>"u"||(t===null?window.localStorage.removeItem(Qt):window.localStorage.setItem(Qt,String(t)),window.dispatchEvent(new CustomEvent(Lr,{detail:t})))}function hs(){io(null)}function qr(){const[t,r]=d.useState(()=>yn());return d.useEffect(()=>{const s=()=>{r(yn())},o=i=>{i.key===Qt&&s()};return window.addEventListener(Lr,s),window.addEventListener("storage",o),()=>{window.removeEventListener(Lr,s),window.removeEventListener("storage",o)}},[]),{selectedGroupId:t,setSelectedGroupId:s=>{io(s),r(s)}}}let Wt=0,xt=!1,pn=new Set;function fs(t){const[r,n]=d.useState(!1),s=d.useRef(null),o=d.useRef(null);return d.useLayoutEffect(()=>{const i=s.current;if(!i)return;let l=0;const c=()=>{l=0;const u=o.current;if(!u)return;const f=u.scrollWidth>i.clientWidth;n(g=>g===f?g:f)},a=new ResizeObserver(()=>{l||(l=requestAnimationFrame(c))});return a.observe(i),c(),()=>{l&&cancelAnimationFrame(l),a.disconnect()}},[t]),{containerRef:s,textRef:o,truncated:r}}function jn({text:t,textStyle:r}){const{containerRef:n,textRef:s,truncated:o}=fs(t),i=e.jsx(v.Text,{ref:s,as:"span",fontSize:"md",fontWeight:"medium",truncate:!0,style:{display:"block",...r},children:t});return e.jsx(x.Box,{ref:n,display:"block",style:{flex:1,minWidth:0},children:o?e.jsx(Fe.Tooltip,{fluid:!0,label:t,position:"top",children:i}):i})}const ms=200,Tr="var(--app-header-height, 4rem)",bn="44px",gr=`calc((${Tr} - 2rem) / 2)`,vn=16;function gs({children:t,headerLeftSlot:r,profile:n,isLoadingProfile:s,onLogout:o,isLoggingOut:i,loadingComponent:l,sidebarHeaderContent:c,headerActions:a,profileRole:u,profileMenuButtons:f,profileMenuItems:g,logoutButton:m,resizableSidebar:p=!0}){var at,ft;const{useSearchParams:S,useNavigate:b,useLocation:I,Outlet:B}=ot(),[F]=S(),w=F.get("embed")==="true",D=zr(),{badges:A}=Un(),O=b(),C=I(),L=!Ce.useMediaQuery("md"),[U,J]=d.useState(!1),{collapsed:N,setCollapsed:_,width:X,setWidth:te,resetWidth:V,minWidth:z,maxWidth:P,mobileOpen:se,setMobileOpen:ye}=Xn(),[Se,xe]=d.useState(!1),[pe,je]=d.useState(()=>new Set(pn)),[be,Te]=d.useState(null),{selectedGroupId:ke,setSelectedGroupId:He}=qr(),Y=N&&!L;d.useEffect(()=>{pn=pe},[pe]);const he=d.useRef(null),Oe=d.useRef(null),Ne=d.useRef(null),[ae,_e]=d.useState(!1),[tt,W]=d.useState(null),$=p&&!L&&!N,Q=k=>Math.min(Math.max(k,z),P),de=tt??X,ie=k=>{var De,Ee,We;if(!$)return;k.preventDefault();const q=k.clientX,K=((De=Ne.current)==null?void 0:De.getBoundingClientRect().width)??X;(We=(Ee=k.currentTarget).setPointerCapture)==null||We.call(Ee,k.pointerId),_e(!0),document.body.style.userSelect="none",document.body.style.cursor="col-resize";let ve=0,Ie=K;const Ue=wt=>{Ie=K+(wt.clientX-q),ve||(ve=requestAnimationFrame(()=>{ve=0,W(Q(Ie))}))},Ae=()=>{ve&&cancelAnimationFrame(ve),window.removeEventListener("pointermove",Ue),window.removeEventListener("pointerup",Ae),document.body.style.userSelect="",document.body.style.cursor="",W(null),_e(!1),Ie<ms?_(!0):te(Q(Ie))};window.addEventListener("pointermove",Ue),window.addEventListener("pointerup",Ae)},Be=k=>{$&&(k.key==="ArrowLeft"?(k.preventDefault(),te(q=>q-vn)):k.key==="ArrowRight"?(k.preventDefault(),te(q=>q+vn)):k.key==="Home"?(k.preventDefault(),te(z)):k.key==="End"&&(k.preventDefault(),te(P)))};d.useEffect(()=>{const k=he.current;if(!k)return;const q=()=>{xt||(Wt=k.scrollTop)};return k.addEventListener("scroll",q),()=>k.removeEventListener("scroll",q)},[]);const Re=()=>{const k=he.current;k&&Wt>0&&(xt=!0,k.scrollTop=Wt,requestAnimationFrame(()=>{xt=!1}))};d.useLayoutEffect(()=>{xt=!0,Re();const k=setTimeout(()=>{xt=!1},300);return()=>clearTimeout(k)},[]),d.useLayoutEffect(()=>{D.menus.length>0&&(Wt>0?Re():requestAnimationFrame(()=>{var q;const k=(q=he.current)==null?void 0:q.querySelector("[data-menu-active='true']");k&&k.scrollIntoView({block:"center",behavior:"instant"})}))},[D.menus]),d.useEffect(()=>{xt=!0,Re();const k=setTimeout(Re,0),q=setTimeout(Re,50),K=setTimeout(Re,100),ve=setTimeout(Re,200),Ie=setTimeout(()=>{xt=!1},300),Ue=setTimeout(()=>{const Ae=he.current,De=Ae==null?void 0:Ae.querySelector("[data-menu-active='true']");if(Ae&&De){const Ee=Ae.getBoundingClientRect(),We=De.getBoundingClientRect();We.top>=Ee.top&&We.bottom<=Ee.bottom||De.scrollIntoView({block:"center",behavior:"smooth"})}},250);return()=>{clearTimeout(k),clearTimeout(q),clearTimeout(K),clearTimeout(ve),clearTimeout(Ie),clearTimeout(Ue)}},[C.pathname]),d.useEffect(()=>{Oe.current&&(Oe.current.scrollTop=0)},[C.pathname]),d.useEffect(()=>{L&&ye(!1)},[C.pathname,L]),d.useEffect(()=>{L&&_(!0)},[L]),d.useEffect(()=>{const k=document.documentElement;return k.style.setProperty("--app-header-height",bn),()=>{k.style.removeProperty("--app-header-height")}},[]);const $e=()=>{J(!0)},qe=()=>{J(!1)},Me=()=>{J(!1),o()},Qe=k=>{const q=[k.to];return k.children&&q.push(...k.children.map(K=>K.to)),q},we=[...D.menus.flatMap(k=>k.items.flatMap(Qe)),...((at=D.menuBottom)==null?void 0:at.flatMap(Qe))??[]],Ze=k=>{if(!C.pathname.startsWith(k))return!1;const q=we.filter(K=>C.pathname.startsWith(K)).sort((K,ve)=>ve.length-K.length)[0];return k===q};d.useEffect(()=>{var q;const k=K=>{var ve;(ve=K.children)!=null&&ve.some(Ie=>C.pathname.startsWith(Ie.to))&&je(Ie=>{const Ue=new Set(Ie);return Ue.add(K.id),Ue})};D.menus.forEach(K=>{K.items.forEach(k)}),(q=D.menuBottom)==null||q.forEach(k)},[C.pathname,D.menus,D.menuBottom]);const rt=k=>{je(q=>{const K=new Set(q);return K.has(k)?K.delete(k):K.add(k),K})};d.useEffect(()=>{D.menus.length!==0&&ke!==null&&!D.menus.some(k=>k.id===ke)&&He(null)},[D.menus,ke,He]);const ut=d.useMemo(()=>{if(ke!==null)return D.menus.filter(K=>K.id===ke||K.parentGroupId===ke);const k=D.menus.filter(K=>K.parentGroupId===void 0),q=D.menus.filter(K=>K.parentGroupId!==void 0).flatMap(K=>K.items);return q.length===0?k:[...k,{id:18,name:"Pengaturan",items:q,parentGroupId:void 0}]},[D.menus,ke]);if(w)return e.jsx(x.Box,{as:"main",overflow:"overflow-y-auto",bg:"surface-inverse",style:{height:"100vh"},children:t||e.jsx(B,{})});const ct=k=>{const q=k.children&&k.children.length>0,K=pe.has(k.id),ve=q?k.children.some(Ae=>Ze(Ae.to)):Ze(k.to),Ie=_t(k.badge,A[k.id]),Ue=!!Ie&&N&&!L;return e.jsxs(x.Box,{display:"block","data-menu-active":ve||void 0,children:[e.jsxs(x.Box,{as:"button",onClick:Ae=>{if(q)if(N&&!L){const De=Ae.currentTarget.getBoundingClientRect();Te({item:k,top:De.top,left:De.right+8})}else rt(k.id);else O(k.to)},fullWidth:!0,direction:"row",align:"center",justify:N&&!L?"center":void 0,gap:"sm",paddingInline:N&&!L?void 0:"sm",paddingBlock:"xs",height:"height-32",borderRadius:ve?"rounded-sm":"rounded-md",borderWidth:"border",borderStyle:"border-solid",borderColor:ve?"border-base":void 0,bg:ve?"white":void 0,hover:ve?void 0:{bg:"neutral"},title:N&&!L?k.title:void 0,style:{textAlign:"left",color:"var(--sa-text-primary, #292a2e)",...ve?null:{borderColor:"transparent"}},children:[e.jsxs(x.Box,{position:"relative",display:"inline-flex",flexShrink:"0",style:{alignItems:"center"},children:[e.jsx(E.Icon,{name:k.icon,size:"sm",style:{flexShrink:0}}),Ue&&e.jsx(x.Box,{"aria-hidden":"true",position:"absolute",top:"top-n2",right:"right-n2",display:"inline-flex",borderRadius:"rounded-full",style:{boxShadow:"0 0 0 1px var(--sa-background-primary, #ffffff)"},children:e.jsx(it.BadgeDot,{tone:"error",variant:"solid",size:"xs"})})]}),(!N||L)&&e.jsxs(e.Fragment,{children:[e.jsx(jn,{text:k.title,textStyle:{transition:"opacity 0.3s"}}),Ie&&e.jsx(it.Badge,{text:String(Ie.value),variant:Ie.variant??"info",size:"xs",border:!0}),q&&e.jsx(E.Icon,{name:"ChevronDown",size:"sm",style:{flexShrink:0,transition:"transform 0.2s",transform:K?"rotate(180deg)":"rotate(0deg)"}})]})]}),q&&(!N||L)&&(()=>{const Ae=k.children.findIndex(De=>Ze(De.to));return e.jsxs(x.Box,{position:"relative",overflow:"overflow-hidden",style:{marginLeft:"1rem",paddingLeft:"0.75rem",transition:"all 0.3s ease-in-out",maxHeight:K?`${k.children.length*36}px`:"0px",opacity:K?1:0,marginTop:K?"0.25rem":"0px"},children:[e.jsx(x.Box,{"aria-hidden":"true",position:"absolute",left:"left-0",top:"top-0",fullHeight:!0,style:{width:"1.5px",backgroundColor:"var(--sa-border-subtle, #0b120e24)",pointerEvents:"none"}}),Ae>=0&&e.jsx(x.Box,{"aria-hidden":"true",position:"absolute",left:"left-0",height:"height-32",zIndex:"10",style:{top:`${Ae*32}px`,width:"1.5px",backgroundColor:"var(--sa-text-primary, #292a2e)",transition:"top 0.2s ease-in-out",pointerEvents:"none"}}),k.children.map(De=>{const Ee=_t(De.badge,A[De.id]),We=Ze(De.to);return e.jsxs(x.Box,{as:"button",onClick:()=>O(De.to),fullWidth:!0,direction:"row",align:"center",gap:"sm",paddingLeft:"sm",paddingRight:"sm",paddingBlock:"xs",height:"height-32",borderRadius:We?"rounded-sm":"rounded-md",borderWidth:"border",borderStyle:"border-solid",borderColor:We?"border-base":void 0,bg:We?"white":void 0,hover:We?void 0:{bg:"neutral"},style:{textAlign:"left",color:We?"var(--sa-text-primary, #292a2e)":"var(--sa-text-subtle, #505258)",...We?null:{borderColor:"transparent"}},children:[e.jsx(E.Icon,{name:De.icon,size:"sm",style:{flexShrink:0}}),e.jsx(jn,{text:De.title}),Ee&&e.jsx(it.Badge,{text:String(Ee.value),variant:Ee.variant??"info",size:"xs",border:!0})]},De.id)})]})})()]},k.id)};return e.jsx(oo,{children:e.jsxs(ro,{children:[e.jsxs(x.Box,{direction:"row",position:"relative",style:{height:"100vh","--app-header-height":bn,"--app-sidebar-width":L?"0px":N?Tr:`${de}px`,"--app-footer-zindex":L&&se?"40":"998"},children:[L&&e.jsx(x.Box,{position:"fixed",zIndex:"40",bg:"black-alpha-a50",style:{inset:0,opacity:se?.5:0,pointerEvents:se?"auto":"none",transition:"opacity 0.3s"},onClick:()=>ye(!1)}),e.jsxs(x.Box,{as:"aside",ref:Ne,bg:"surface-inverse",borderWidth:"border-r",borderStyle:"border-solid-r",borderColor:"border-base",flexShrink:L?void 0:"0",style:{width:L?"16.375rem":N?Tr:`${de}px`,position:L?"fixed":"relative",...L&&{inset:0,zIndex:50,transform:se?"translateX(0)":"translateX(-100%)"},transition:ae?"none":"all 0.3s ease-in-out",minWidth:0},children:[e.jsx(x.Box,{onMouseEnter:()=>xe(!0),onMouseLeave:()=>xe(!1),direction:"row",align:"center",justify:"space-between",paddingInline:Y?void 0:"lg",borderWidth:"border-b",borderStyle:"border-solid-b",borderColor:"border-base",position:"relative",style:{height:"var(--app-header-height, 4rem)",...Y?{paddingInline:gr}:null},children:(()=>{const k=!L&&N&&!se,q=k&&Se;return e.jsxs(e.Fragment,{children:[e.jsxs(x.Box,{direction:"row",align:"center",gap:"sm",flex:k?"1":void 0,justify:k?"center":void 0,style:{transition:"opacity 0.2s",opacity:q?0:1,pointerEvents:q?"none":"auto"},children:[e.jsx("img",{src:D.logo,alt:"Logo",style:{width:"1.5rem",height:"1.5rem",flexShrink:0}}),(!N||se)&&e.jsx(v.Text,{as:"span",fontSize:"md",fontWeight:"semibold",color:"primary",truncate:!0,style:{transition:"opacity 0.3s"},children:D.appName})]}),!L&&!N&&e.jsx(x.Box,{as:"button",onClick:()=>_(!0),"aria-label":"Collapse sidebar",display:"inline-flex",align:"center",justify:"center",flexShrink:"0",style:{color:"var(--sa-text-subtle, #8c8f97)"},children:e.jsx(E.Icon,{name:"LayoutLeft",size:"sm"})}),k&&e.jsx(x.Box,{as:"button",onClick:()=>_(!1),"aria-label":"Expand sidebar",position:"absolute",display:"inline-flex",align:"center",justify:"center",width:"width-32",height:"height-32",bg:"white",borderWidth:"border",borderStyle:"border-solid",borderColor:"border-base",borderRadius:"rounded-sm",style:{top:"50%",left:"50%",transform:"translate(-50%, -50%)",color:"var(--sa-text-primary, #292a2e)",opacity:q?1:0,pointerEvents:q?"auto":"none",transition:"opacity 0.2s"},children:e.jsx(E.Icon,{name:"LayoutLeft",size:"sm"})}),L&&e.jsx(x.Box,{as:"button",onClick:()=>ye(!1),"aria-label":"Close menu",align:"center",justify:"center",borderRadius:"rounded-md",style:{padding:"0.375rem",color:"var(--sa-text-subtle, #8c8f97)"},children:e.jsx(E.Icon,{name:"Cross",size:"md"})})]})})()}),c&&e.jsx(to,{collapsed:L?!1:N,children:c}),e.jsx(x.Box,{ref:he,flex:"1",overflow:"overflow-y-auto",paddingBlock:"lg",children:ut.map(k=>e.jsxs(x.Box,{marginBottom:"lg",children:[!N||L?k.name&&e.jsx(v.Text,{fontSize:"md",fontWeight:"normal",color:"subtlest",truncate:!0,style:{paddingLeft:"1.25rem",paddingRight:"0.75rem",paddingBottom:"0.25rem",transition:"opacity 0.3s"},children:k.name}):k.name&&e.jsx(x.Box,{"aria-label":k.name,direction:"row",align:"center",justify:"center",paddingBlock:"md",children:e.jsx(x.Box,{width:"width-16",style:{height:"2px",borderRadius:"1px",backgroundColor:k.color??"var(--sa-background-brand, #04254f)"}})}),e.jsx(x.Box,{paddingInline:Y?void 0:"md",gap:"xs",style:Y?{paddingInline:gr}:void 0,children:k.slotKey?e.jsx(so,{slotKey:k.slotKey,fallback:k.items.map(q=>ct(q))}):k.items.map(q=>ct(q))})]},k.id))}),D.menuBottom&&D.menuBottom.length>0&&e.jsx(x.Box,{borderWidth:"border-t",borderStyle:"border-solid-t",borderColor:"border-base",paddingBlock:"md",paddingInline:Y?void 0:"md",bg:"surface-inverse",gap:"xs",flexShrink:"0",style:Y?{paddingInline:gr}:void 0,children:D.menuBottom.map(k=>ct(k))}),$&&e.jsx(x.Box,{role:"separator","aria-orientation":"vertical","aria-label":"Resize sidebar","aria-valuenow":X,"aria-valuemin":z,"aria-valuemax":P,tabIndex:0,onPointerDown:ie,onKeyDown:Be,onDoubleClick:V,title:"Drag to resize · double-click to reset",position:"absolute",top:"top-0",right:"right-0",fullHeight:!0,style:{width:"6px",transform:"translateX(50%)",cursor:"col-resize",zIndex:5,touchAction:"none",background:ae?"var(--sa-background-brand, #04254f)":"transparent",transition:"background 0.15s"},onMouseEnter:k=>{ae||(k.currentTarget.style.background="var(--sa-border-bold, #0b120e40)")},onMouseLeave:k=>{ae||(k.currentTarget.style.background="transparent")}})]}),e.jsxs(x.Box,{flex:"1",overflow:"overflow-hidden",children:[e.jsxs(x.Box,{as:"header",bg:"white",borderWidth:"border-b",borderStyle:"border-solid-b",borderColor:"border-base",direction:"row",align:"center",justify:"space-between",paddingInline:"lg",flexShrink:"0",style:{height:"var(--app-header-height, 4rem)"},children:[e.jsxs(x.Box,{direction:"row",align:"center",gap:L?"lg":void 0,children:[L&&e.jsx(x.Box,{as:"button",onClick:()=>ye(!0),align:"center",justify:"center",borderRadius:"rounded-md",style:{padding:"0.375rem",color:"var(--sa-text-subtle, #8c8f97)"},children:e.jsx(E.Icon,{name:"MenuBurger",size:"lg"})}),e.jsx(no,{children:r})]}),e.jsxs(x.Box,{direction:"row",align:"center",gap:"md",children:[a,e.jsxs(T.Menu,{position:"bottom-right",children:[e.jsx(T.MenuButton,{children:e.jsxs(x.Box,{direction:"row",align:"center",gap:"sm",cursor:"pointer",children:[e.jsxs(x.Box,{display:"block",textAlign:"right",customMaxWidth:"12.5rem",children:[e.jsx(v.Text,{fontSize:"sm",fontWeight:"medium",color:"subtle",textAlign:"right",truncate:!0,lineHeight:"leading-none",children:s?"Loading...":(n==null?void 0:n.name)||"unknown"}),e.jsx(v.Text,{fontSize:"sm",color:"subtle",textAlign:"right",truncate:!0,children:s?"":(n==null?void 0:n.email)||"unknown"})]}),e.jsx(Zt.Avatar,{size:"sm",initials:((n==null?void 0:n.name)||"U")[0].toUpperCase(),bg:"var(--sa-background-brand, #04254f)",color:"var(--sa-background-primary, #ffffff)"}),e.jsx(E.Icon,{name:"ChevronDown",size:"xs",color:"subtle"})]})}),e.jsxs(T.MenuLists,{width:280,style:{paddingBlock:"12px",paddingInline:"12px",gap:"8px",marginTop:"16px"},children:[e.jsx(T.MenuHeading,{children:e.jsxs(x.Box,{align:"center",textAlign:"center",paddingBlock:"sm",fullWidth:!0,children:[e.jsx(Zt.Avatar,{customSize:64,initials:((n==null?void 0:n.name)||"U")[0].toUpperCase(),bg:"var(--sa-background-brand, #04254f)",color:"var(--sa-background-primary, #ffffff)",style:{fontSize:"1.25rem",marginBottom:"0.75rem",boxShadow:"var(--sa-shadow-sm, 0 1px 2px 0 #0000000d)"}}),e.jsx(v.Text,{fontSize:"md",fontWeight:"semibold",color:"primary",textAlign:"center",truncate:!0,style:{maxWidth:"100%"},children:(n==null?void 0:n.name)||"unknown"}),e.jsx(v.Text,{fontSize:"sm",color:"subtle",textAlign:"center",truncate:!0,style:{maxWidth:"100%"},children:(n==null?void 0:n.email)||"unknown"}),u&&e.jsx(v.Text,{fontSize:"sm",color:"subtle",textAlign:"center",truncate:!0,style:{maxWidth:"100%"},children:u})]})}),(f&&f.length>0||g)&&e.jsxs(T.MenuBody,{children:[f==null?void 0:f.map((k,q)=>e.jsx(T.MenuItem,{onClick:k.onClick,startIcon:e.jsx(E.Icon,{name:k.icon,size:"md"}),children:k.label},`${k.label}-${q}`)),g]}),m??e.jsx(T.MenuFooter,{children:e.jsx(T.MenuItem,{intent:"danger",onClick:$e,startIcon:e.jsx(E.Icon,{name:"Logout",size:"md"}),children:"Logout"})})]})]})]})]}),e.jsx(x.Box,{as:"main",ref:Oe,flex:"1",overflow:"overflow-y-auto",children:t||e.jsx(B,{})})]})]}),i&&l&&e.jsx(x.Box,{position:"fixed",align:"center",justify:"center",bg:"black-alpha-a70",style:{inset:0,zIndex:9999},children:l}),e.jsxs(Pe.Dialog,{isShow:U,onHide:qe,children:[e.jsx(Pe.DialogTitle,{children:"Confirmation Logout"}),e.jsx(Pe.DialogBody,{children:"Are you sure you want to end the session and exit the page?"}),e.jsx(Pe.DialogFooter,{children:e.jsx(x.Box,{direction:"column",display:"flex",align:"flex-end",justify:"center",children:e.jsxs(ce.Flex,{direction:"row",gap:"sm",align:"center",children:[e.jsx(x.Box,{direction:"column",children:e.jsx(H.Button,{secondary:!0,onClick:qe,children:"Cancel"})}),e.jsx(x.Box,{direction:"column",children:e.jsx(H.Button,{primary:!0,onClick:Me,children:"Yes, Sure"})})]})})})]}),be&&e.jsxs(e.Fragment,{children:[e.jsx(x.Box,{onClick:()=>Te(null),position:"fixed",style:{inset:0,zIndex:60}}),e.jsxs(x.Box,{role:"dialog","aria-label":be.item.title,position:"fixed",bg:"white",borderWidth:"border",borderStyle:"border-solid",borderColor:"border-base",borderRadius:"rounded-md",shadow:"shadow-lg",padding:"sm",gap:"spacing-2",style:{top:be.top,left:be.left,zIndex:61,minWidth:"13rem",maxWidth:"16rem"},children:[e.jsx(v.Text,{fontSize:"sm",fontWeight:"semibold",color:"gray-500",textTransform:"uppercase",style:{padding:"0.25rem 0.5rem 0.5rem",letterSpacing:"0.05em"},children:be.item.title}),(ft=be.item.children)==null?void 0:ft.map(k=>{const q=Ze(k.to),K=_t(k.badge,A[k.id]);return e.jsxs(x.Box,{as:"button",onClick:()=>{O(k.to),Te(null)},fullWidth:!0,direction:"row",align:"center",gap:"md",paddingBlock:"sm",paddingInline:"md",borderRadius:"rounded-md",borderWidth:"border",borderStyle:"border-solid",bg:q?"primary-inverse":void 0,hover:q?void 0:{bg:"primary-inverse"},style:{textAlign:"left",borderColor:"transparent",color:q?"var(--sa-text-primary, #292a2e)":"var(--sa-color-gray-800, #505258)"},children:[k.icon&&e.jsx(E.Icon,{name:k.icon,size:"sm",style:{flexShrink:0}}),e.jsx(v.Text,{as:"span",fontSize:"md",fontWeight:"medium",whiteSpace:"nowrap",style:{flex:1},children:k.title}),K&&e.jsx(it.Badge,{text:String(K.value),variant:K.variant??"info",size:"xs",border:!0})]},k.id)})]})]})]})})}const Lt=d.forwardRef(({children:t,...r},n)=>e.jsx(x.Box,{ref:n,role:"button",cursor:"pointer","aria-pressed":"true",display:"inline-block",tabIndex:0,...r,children:t})),Cn=({title:t,iconName:r,textColor:n,iconColor:s,hoverTextColor:o,hoverIconColor:i})=>{const[l,c]=d.useState(!1),a=s??"var(--sa-text-subtle, #8c8f97)",u=n??"var(--sa-text-subtle, #8c8f97)",f=i??"var(--sa-text-subtle, #8c8f97)",g=o??"var(--sa-text-primary, #292a2e)";return e.jsxs(x.Box,{direction:"row",gap:"xs",align:"center",onMouseEnter:()=>c(!0),onMouseLeave:()=>c(!1),style:{cursor:"pointer"},children:[e.jsx(E.Icon,{name:r||"ChevronLeft",size:"xs",style:{color:l?f:a,transition:"color 0.15s ease"}}),e.jsx(v.Text,{variant:"sub-h3",style:{color:l?g:u,transition:"color 0.15s ease"},children:t||"Back"})]})},ys=({items:t,separator:r="/",iconName:n,iconColor:s,hoverIconColor:o})=>{const{Link:i}=ot(),[l,c]=d.useState(!1),a=s??"var(--sa-text-subtle, #8c8f97)",u=o??"var(--sa-text-subtle, #8c8f97)",f=t.length>1?t[0]:void 0,g=!!(f!=null&&f.to||f!=null&&f.onClick),m=e.jsx(E.Icon,{name:n||"ChevronLeft",size:"xs",onMouseEnter:g?()=>c(!0):void 0,onMouseLeave:g?()=>c(!1):void 0,style:{color:g&&l?u:a,transition:"color 0.15s ease",cursor:g?"pointer":void 0}}),p=f!=null&&f.to?e.jsx(i,{to:f.to,replace:!0,style:{textDecoration:"none"},children:m}):f!=null&&f.onClick?e.jsx(Lt,{onClick:f.onClick,children:m}):m;return e.jsxs(x.Box,{direction:"row",gap:"xs",align:"center",children:[p,e.jsx(yt.Breadcrumb,{separator:r,size:"md",children:t.map((S,b)=>{const I=b===t.length-1;return S.to&&!I?e.jsx(yt.BreadcrumbItem,{children:e.jsx(i,{to:S.to,children:S.label})},b):e.jsx(yt.BreadcrumbItem,{currentPage:I,children:e.jsx(yt.BreadcrumbLink,{onClick:I?void 0:S.onClick,children:S.label})},b)})})]})},ps=t=>{const{Link:r}=ot(),{items:n,separator:s,onClick:o,navigateTo:i,...l}=t;return n&&n.length>0?e.jsx(ys,{items:n,separator:s,iconName:l.iconName,iconColor:l.iconColor,hoverIconColor:l.hoverIconColor}):i?e.jsx(x.Box,{direction:"row",children:e.jsx(r,{to:i,replace:!0,style:{textDecoration:"none"},children:e.jsx(Cn,{...l})})}):e.jsx(x.Box,{direction:"row",children:e.jsx(Lt,{onClick:o,children:e.jsx(Cn,{...l})})})},yr=[{icon:"var(--sa-color-brand-400, #3366b7)",activeBg:"var(--sa-color-brand-50, #e6edf6)",activeBorder:"var(--sa-color-brand-300, #668cc9)",activeShadow:"rgba(51, 102, 183, 0.25)"},{icon:"var(--sa-color-warning-400, #ed9f30)",activeBg:"var(--sa-color-warning-50, #fef2e6)",activeBorder:"var(--sa-color-warning-300, #f1b259)",activeShadow:"rgba(237, 159, 48, 0.25)"},{icon:"var(--sa-color-secondary-300, #5468e1)",activeBg:"var(--sa-color-secondary-50, #e6e9fb)",activeBorder:"var(--sa-color-secondary-200, #8a98ea)",activeShadow:"rgba(84, 104, 225, 0.25)"},{icon:"var(--sa-color-info-500, #00abeb)",activeBg:"var(--sa-color-info-50, #effaff)",activeBorder:"var(--sa-color-info-300, #75dbff)",activeShadow:"rgba(0, 171, 235, 0.25)"},{icon:"var(--sa-color-success-500, #30ce84)",activeBg:"var(--sa-color-success-50, #ecfff6)",activeBorder:"var(--sa-color-success-300, #75dead)",activeShadow:"rgba(48, 206, 132, 0.25)"},{icon:"var(--sa-color-error-400, #ff758f)",activeBg:"var(--sa-color-error-50, #fff0f3)",activeBorder:"var(--sa-color-error-300, #ff8fa3)",activeShadow:"rgba(255, 117, 143, 0.25)"}];function wn(t,r,n){return{display:"flex",alignItems:"center",justifyContent:"center",width:"64px",height:"64px",borderRadius:"var(--sa-radii-sm, 6px)",border:t?`2px solid ${n.activeBorder}`:"2px solid var(--sa-color-gray-200, #f0f1f2)",backgroundColor:t?n.activeBg:"var(--sa-color-gray-50, #ffffff)",boxShadow:t?r?`0 8px 20px ${n.activeShadow.replace("0.25","0.35")}`:`0 2px 8px ${n.activeShadow}`:r?"0 8px 20px rgba(0, 0, 0, 0.14)":"0 1px 4px rgba(0, 0, 0, 0.08)",transform:r?"translateY(-3px) scale(1.05)":"translateY(0) scale(1)",transition:"box-shadow 0.2s ease, transform 0.2s ease, background-color 0.15s ease, border-color 0.15s ease"}}const Dn={fontSize:"11px",fontWeight:500,textAlign:"center",overflowWrap:"normal",wordBreak:"normal",color:"var(--sa-background-primary, #ffffff)",lineHeight:"1.3",maxWidth:"80px"},Sn={display:"flex",flexDirection:"column",alignItems:"center",gap:"8px",background:"none",border:"none",cursor:"pointer",padding:0};function lo({isShow:t,onHide:r,menus:n,selectedGroupId:s,onSelect:o}){const[i,l]=d.useState(void 0),c=u=>{o(u),r()},a=yr[0];return e.jsx(Pe.Dialog,{isShow:t,onHide:r,style:{width:560,background:"transparent",boxShadow:"none",border:"none"},children:e.jsx(Pe.DialogBody,{children:e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(5, 1fr)",gap:"16px"},children:[e.jsxs("button",{onClick:()=>c(null),onMouseEnter:()=>l("all"),onMouseLeave:()=>l(void 0),style:Sn,children:[e.jsx("div",{style:wn(s===null,i==="all",a),children:e.jsx("div",{style:{color:a.icon,display:"flex",alignItems:"center",justifyContent:"center"},children:e.jsx(E.Icon,{name:"Grid",size:"lg",style:{width:32,height:32}})})}),e.jsx("span",{style:Dn,children:"Semua"})]}),n.map((u,f)=>{var b;const g=s===u.id,m=i===u.id,p=((b=u.items[0])==null?void 0:b.icon)??"Grid",S=yr[(f+1)%yr.length];return e.jsxs("button",{onClick:()=>c(u.id),onMouseEnter:()=>l(u.id),onMouseLeave:()=>l(void 0),style:Sn,children:[e.jsx("div",{style:wn(g,m,S),children:e.jsx("div",{style:{color:S.icon,display:"flex",alignItems:"center",justifyContent:"center"},children:e.jsx(E.Icon,{name:p,size:"lg",style:{width:32,height:32}})})}),e.jsx("span",{style:Dn,children:u.name})]},u.id)})]})})})}function js({onSelect:t,"aria-label":r="Pilih module"}={}){const n=zr(),{useNavigate:s}=ot(),o=s(),{selectedGroupId:i,setSelectedGroupId:l}=qr(),[c,a]=d.useState(!1),u=f=>{var g;if(l(f),f!==null){const m=n.menus.find(S=>S.id===f),p=(g=m==null?void 0:m.items[0])==null?void 0:g.to;p&&o(p)}t==null||t(f)};return e.jsxs(e.Fragment,{children:[e.jsxs("div",{style:{position:"relative"},children:[e.jsx("button",{onClick:()=>a(!0),style:{display:"inline-flex",alignItems:"center",justifyContent:"center",width:"2.25rem",height:"2.25rem",borderRadius:"var(--sa-radii-sm, 0.25rem)",border:"1px solid var(--sa-border-subtle, #0b120e24)",color:"var(--sa-text-subtle, #8c8f97)",backgroundColor:"transparent",cursor:"pointer"},"aria-label":r,onMouseEnter:f=>{f.currentTarget.style.backgroundColor="var(--sa-background-primary-inverse, #f8f8f8)"},onMouseLeave:f=>{f.currentTarget.style.backgroundColor="transparent"},children:e.jsx(E.Icon,{name:"GridApplication",size:"sm"})}),i!==null&&e.jsx("span",{style:{position:"absolute",top:"0.25rem",right:"0.25rem",width:"0.5rem",height:"0.5rem",borderRadius:"9999px",backgroundColor:"var(--sa-color-brand-500, #1a4fa0)"},"aria-hidden":"true"})]}),e.jsx(lo,{isShow:c,onHide:()=>a(!1),menus:n.menus.filter(f=>f.parentGroupId===void 0),selectedGroupId:i,onSelect:u})]})}const bs=(t,r)=>{const n=[];if(r===0)return n.push(t),n;for(let s=0;s<t.length;s+=r){const o=t.slice(s,s+r);n.push(o)}return n},vs=d.memo(({value:t,label:r,separator:n,labelWidth:s,lastIndex:o,labelAlign:i="top"})=>{const l=d.useMemo(()=>({padding:0,paddingBottom:o?0:12,verticalAlign:i}),[o,i]),c=d.useMemo(()=>({padding:0,paddingRight:12,paddingLeft:12,paddingBottom:o?0:12,verticalAlign:i}),[o,i]),a=()=>typeof r=="string"?e.jsx(v.Text,{fontWeight:"medium",color:"subtlest",children:r}):r,u=()=>typeof t=="string"||typeof t=="number"?e.jsx(v.Text,{color:"primary",fontWeight:"medium",children:t}):t,f=()=>typeof n=="string"||typeof n=="number"?e.jsx(v.Text,{fontWeight:"medium",color:"subtlest",children:n}):n;return e.jsxs(G.Tr,{children:[e.jsx(G.Td,{style:l,width:s,children:a()}),n?e.jsx(G.Td,{style:c,width:24,children:f()}):null,e.jsx(G.Td,{style:l,children:u()})]})}),Cs=d.memo(({fields:t,separator:r,labelWidth:n})=>e.jsx(G.Table,{withColumnBorder:!1,withRowBorder:!1,children:t.map((s,o)=>e.jsx(vs,{separator:r,labelWidth:n,lastIndex:o===t.length-1,...s},`field-group-field-${o}`))})),ws=d.memo(({maxRow:t=0,maxColumn:r=2,separator:n=":",fields:s=[],labelWidth:o=150,bordered:i=!1})=>{const l=d.useMemo(()=>bs(s,t),[s,t]),c=l.length>2,a=()=>{switch(r){case 1:return"width-full";case 2:return"width-1-2";case 3:return"width-1-3";case 4:return"width-1-4";default:return"width-1-2"}};return e.jsx(x.Box,{gap:c?void 0:"lg",direction:"row",flexWrap:"wrap",borderRadius:"rounded-sm",padding:"lg",paddingBottom:c?"xs":"lg",bg:"accent-dark-tertiary",borderWidth:i?"border":void 0,borderStyle:i?"border-solid":void 0,borderColor:i?"border-subtle":void 0,children:l.map((u,f)=>e.jsx(x.Box,{direction:"column",flex:c?void 0:"1",width:c?a():void 0,marginBottom:c?"lg":void 0,children:e.jsx(Cs,{labelWidth:o,fields:u,separator:n})},f))})}),Ds=({backButton:t})=>{const[r,n]=d.useState(!1),s=(t==null?void 0:t.iconColor)??"var(--sa-text-subtle, #8c8f97)",o=(t==null?void 0:t.textColor)??"var(--sa-text-subtle, #8c8f97)",i=(t==null?void 0:t.hoverIconColor)??"var(--sa-text-subtle, #8c8f97)",l=(t==null?void 0:t.hoverTextColor)??"var(--sa-text-primary, #292a2e)";return e.jsxs(x.Box,{direction:"row",gap:"xs",align:"center",onMouseEnter:()=>n(!0),onMouseLeave:()=>n(!1),style:{cursor:"pointer"},children:[e.jsx(E.Icon,{name:(t==null?void 0:t.iconName)||"ChevronLeft",size:"xs",style:{color:r?i:s,transition:"color 0.15s ease"}}),e.jsx(v.Text,{variant:"sub-h3",style:{color:r?l:o,textDecoration:r?"underline":"none",transition:"color 0.15s ease"},children:(t==null?void 0:t.title)||"Back"})]})},Ss=({backButton:t,title:r,titleIcon:n,titleTag:s,children:o,header:i=!0,headerBorder:l=!1,disableAnimation:c=!1,scrollable:a=!1,stickyHeader:u=!1,subHeaders:f,action:g,titleTagProps:m,containerProps:p,headerProps:S})=>{const b=Ce.useMediaQuery("md"),{Link:I,useNavigate:B,useLocation:F}=ot(),w=B(),D=F(),A=t==null?void 0:t.show,O=()=>{if(typeof(t==null?void 0:t.onClick)=="function"){t.onClick();return}w(-1,{replace:!0})},C=()=>{if(!g)return null;if(d.isValidElement(g))return g;const _=g.filter(X=>X&&(X.title||X.icon));return _.length===0?null:b?e.jsx(x.Box,{direction:"row",gap:"md",children:_.map(({title:X,icon:te,buttonProps:V,onClick:z},P)=>e.jsx(H.Button,{iconLeft:te?e.jsx(E.Icon,{name:te,size:"md"}):void 0,onClick:z,...V,children:X},`action-${P}`))}):e.jsxs(T.Menu,{position:"bottom-right",children:[e.jsx(T.MenuButton,{children:e.jsx(H.Button,{variant:"tertiary",size:"sm",iconLeft:e.jsx(E.Icon,{name:"MenuBurger"}),"aria-label":"Actions"})}),e.jsx(T.MenuLists,{children:e.jsx(T.MenuBody,{style:{minWidth:200},children:_.map(({title:X,icon:te,buttonProps:V,onClick:z},P)=>{const se=(V==null?void 0:V.tone)==="error"||(V==null?void 0:V.danger)===!0;return e.jsx(T.MenuItem,{intent:se?"danger":void 0,disabled:V==null?void 0:V.disabled,startIcon:te?e.jsx(E.Icon,{name:te}):void 0,onClick:z,children:X},`action-${P}`)})})})]})},R=()=>{const _=e.jsx(Ds,{backButton:t});return t!=null&&t.navigateTo?e.jsx(x.Box,{direction:"row",children:e.jsx(I,{to:t.navigateTo,replace:!0,style:{textDecoration:"none"},children:_})}):e.jsx(x.Box,{direction:"row",children:e.jsx(Lt,{onClick:O,children:_})})},L=()=>{const _=!!r,X=Array.isArray(g)&&g.length>0,te=d.isValidElement(g)?!0:X;if(!_&&!te&&!A)return null;const z=b||!b&&X;return e.jsxs(x.Box,{direction:"column",gap:"xs",paddingBlock:(S==null?void 0:S.paddingBlock)??"sm",paddingInline:(S==null?void 0:S.paddingInline)??"md",...S,style:{...l?{boxShadow:"inset 0 -1px 0 0 var(--sa-border-subtle, #0b120e24)"}:{},...S==null?void 0:S.style},children:[A&&R(),(_||te)&&e.jsxs(x.Box,{direction:z?"row":"column",gap:"sm",justify:"space-between",align:z?"center":"flex-start",children:[_?typeof r=="string"?e.jsxs(x.Box,{direction:"row",gap:"lg",align:"center",children:[e.jsxs(x.Box,{direction:"row",gap:"sm",align:"center",children:[n&&e.jsx(E.Icon,{name:n,size:"md",color:"primary"}),e.jsx(v.Text,{variant:"h3",fontWeight:"semibold",children:r})]}),s&&e.jsx(it.Badge,{border:!0,size:"lg",text:s,...m})]}):r:null,C()]})]})},U=()=>{if(!f||f.length===0)return null;const _=f.filter(V=>V.show!==!1);if(_.length===0)return null;let X=0,te=-1/0;return _.forEach((V,z)=>{const P=V.order??0;P>=te&&(te=P,X=z)}),_.map(({content:V,order:z,borderBottom:P=!0,keepBottomPadding:se=!1,paddingInline:ye=!0,paddingBlock:Se=!0},xe)=>e.jsx(x.Box,{direction:"column",paddingTop:Se?"sm":"spacing-0",paddingBottom:Se&&(P||se||xe===X)?"sm":"spacing-0",paddingInline:ye?"md":"spacing-0",style:{...P?{boxShadow:"inset 0 -1px 0 0 var(--sa-border-subtle, #0b120e24)"}:{},...z!==void 0?{order:z}:{}},children:V},`sub-header-${xe}`))},J=()=>{const _=i?L():null,X=U();return!_&&!X?null:e.jsxs(x.Box,{direction:"column",style:{...a?{position:"sticky",left:0,...u?{top:0}:{},zIndex:2,background:"var(--sa-background-primary, #ffffff)"}:{},marginBottom:X?"var(--sa-spacing-0)":"var(--sa-spacing-md)"},children:[_,X]})},N=()=>o;return e.jsxs(x.Box,{direction:"column",as:"main",...p,style:{...a?{height:"100%",minHeight:0,overflow:"auto"}:{},...(p==null?void 0:p.style)??{},...c?{}:{animation:"pageLayoutEnter 320ms cubic-bezier(0.16, 1, 0.3, 1) backwards"}},children:[J(),N()]},D.pathname)},ks=d.memo(Ss),Bs={icon:"Cross",title:""},Es=320,kn=16,Bn=4,Fs=8,co=d.forwardRef(({onHide:t,show:r,withBlur:n=!1,style:s,children:o,closeButton:i=Bs,paddingHorizontal:l=!0,width:c,minWidth:a,maxWidth:u,hideBackdrop:f=!1,title:g,headerAction:m,header:p=!0,widthPresets:S,resizable:b=!0,resizeMin:I=Es,resizeMax:B,onWidthChange:F},w)=>{const A=!Ce.useMediaQuery("md"),O=c??u??a??"357px",C=S??[],R=C.length>1,[L,U]=d.useState(()=>{const Y=C.indexOf(O);return Y>=0?Y:0}),[J,N]=d.useState(null),[_,X]=d.useState(!1),[te,V]=d.useState(!1),z=d.useRef(null),P=Y=>{z.current=Y,typeof w=="function"?w(Y):w&&(w.current=Y)},se=R?C[L]:O,ye=J!=null?`${J}px`:se,Se=b&&!A,xe=L===C.length-1,pe=()=>{const Y=(L+1)%C.length;N(null),U(Y),F==null||F(C[Y])},je=d.useCallback(Y=>{const he=B??window.innerWidth;return Math.min(Math.max(Y,I),he)},[I,B]),be=d.useRef(null),Te=Y=>{if(!Se)return;Y.preventDefault();const he=Y.currentTarget;he.setPointerCapture(Y.pointerId),X(!0);const Oe=document.body.style.cursor,Ne=document.body.style.userSelect;document.body.style.cursor="col-resize",document.body.style.userSelect="none";let ae=null;const _e=W=>{const $=je(window.innerWidth-W.clientX);be.current=$,ae==null&&(ae=window.requestAnimationFrame(()=>{ae=null,be.current!=null&&N(be.current)}))},tt=W=>{ae!=null&&window.cancelAnimationFrame(ae),be.current!=null&&N(be.current),he.releasePointerCapture(W.pointerId),he.removeEventListener("pointermove",_e),he.removeEventListener("pointerup",tt),he.removeEventListener("pointercancel",tt),document.body.style.cursor=Oe,document.body.style.userSelect=Ne,X(!1),be.current!=null&&(F==null||F(`${be.current}px`))};he.addEventListener("pointermove",_e),he.addEventListener("pointerup",tt),he.addEventListener("pointercancel",tt)},ke=Y=>{var ae;if(!Se||Y.key!=="ArrowLeft"&&Y.key!=="ArrowRight")return;Y.preventDefault();const he=Y.key==="ArrowLeft"?kn:-kn,Oe=J??((ae=z.current)==null?void 0:ae.offsetWidth)??I,Ne=je(Oe+he);N(Ne),F==null||F(`${Ne}px`)},He=()=>{Se&&(N(null),F==null||F(se))};return e.jsx(Gt.Drawer,{blur:n,isShow:r,position:"right",onHide:t,ref:P,size:ye,style:s,flush:!0,radius:"none",hideBackdrop:f,children:e.jsxs(x.Box,{direction:"column",height:"height-full",children:[Se?e.jsx("div",{role:"separator","aria-orientation":"vertical","aria-label":"Ubah lebar panel",tabIndex:0,onPointerDown:Te,onKeyDown:ke,onDoubleClick:He,title:"Tarik untuk mengubah lebar — klik dua kali untuk reset",onPointerEnter:()=>V(!0),onPointerLeave:()=>V(!1),style:{position:"absolute",left:0,top:0,bottom:0,width:Fs,cursor:"col-resize",zIndex:1,background:_||te?`linear-gradient(to right, var(--sa-border-brand, var(--sa-border-subtle)) 0 ${Bn}px, transparent ${Bn}px)`:"transparent",transition:"background 0.15s",touchAction:"none"}}):null,p?e.jsxs(x.Box,{direction:"row",align:"center",justify:"space-between",gap:"sm",paddingInline:"md",borderWidth:"border-b",borderStyle:"border-solid-b",borderColor:"border-base",customHeight:"var(--app-header-height, 44px)",flexShrink:"0",children:[e.jsx(x.Box,{direction:"row",align:"center",gap:"sm",overflow:"overflow-hidden",children:typeof g=="string"?e.jsx(v.Text,{fontSize:"md",fontWeight:"bold",children:g}):g}),e.jsxs(x.Box,{direction:"row",align:"center",gap:"sm",flexShrink:"0",children:[m,R?e.jsx(H.Button,{variant:"tertiary",tone:"neutral",size:"xs",onClick:pe,"aria-label":xe?"Kecilkan panel":"Lebarkan panel",iconRight:e.jsx(E.Icon,{name:xe?"ChevronRight":"ChevronLeft"})}):null,i?e.jsx(H.Button,{variant:"tertiary",tone:"neutral",size:"xs",onClick:t,"aria-label":i.title||"Tutup",iconRight:e.jsx(E.Icon,{name:i.icon}),children:i.title||void 0}):null]})]}):null,e.jsx(x.Box,{direction:"column",paddingBlock:"md",paddingInline:l?"md":"spacing-0",overflow:"overflow-y-auto",style:{flex:1,minHeight:0},children:o})]})})}),Zr=d.memo(({children:t,borderBottom:r=!0,padding:n=!0})=>{const s=Ce.useMediaQuery("lg");return e.jsx(x.Box,{direction:"column",padding:n?"md":"spacing-0",paddingLeft:n?"md":"spacing-0",paddingRight:n?"md":"spacing-0",style:r?{borderBottom:"1px solid var(--sa-border-subtle, #0b120e24)"}:void 0,children:t})}),Gr=d.memo(({children:t,borderTop:r=!0,padding:n=!0})=>{const s=Ce.useMediaQuery("lg");return e.jsx(x.Box,{direction:"column",padding:n?"md":"spacing-0",paddingLeft:n?"md":"spacing-0",paddingRight:n?"md":"spacing-0",style:r?{borderTop:"1px solid var(--sa-border-subtle, #0b120e24)"}:void 0,children:t})}),Ms=d.memo(({children:t,...r})=>e.jsx(x.Box,{direction:"column",padding:"md",paddingLeft:"md",paddingRight:"md",gap:"md",...r,children:t})),Is=d.memo(({children:t,title:r,titleTag:n,action:s,header:o,footer:i,actionContainer:l,containerProps:c,bodyProps:a,headerProps:u={borderBottom:!0},footerProps:f={borderTop:!0},variantTag:g="info"})=>{const m=Ce.useMediaQuery("lg"),p=()=>n?e.jsxs(x.Box,{direction:"row",gap:"sm",align:"center",children:[e.jsx(v.Text,{fontWeight:"medium",children:r}),e.jsx(it.Badges,{border:!0,text:n,variant:g})]}):e.jsx(v.Text,{fontWeight:"medium",children:r}),S=()=>o||e.jsxs(x.Box,{direction:"row",justify:"space-between",align:"flex-start",gap:"md",children:[e.jsx(x.Box,{direction:"column",children:r?p():null}),e.jsx(x.Box,{direction:"column",style:m?{width:"100%",maxWidth:"19.313rem"}:{flex:1},...l,children:s??null})]}),b=!!(o||r||s);return e.jsxs(x.Box,{direction:"column",bg:"white",borderRadius:"rounded-xs",as:"section",borderWidth:"border",borderStyle:"border-solid",borderColor:"border-base",...c,style:{backgroundColor:"var(--sa-background-primary, #ffffff)",...(c==null?void 0:c.style)??{}},children:[o!==null&&b?e.jsx(Zr,{...u,children:S()}):null,e.jsx(Ms,{...a,children:t}),i?e.jsx(Gr,{...f,children:i}):null]})}),Ls=t=>e.jsx(v.Text,{variant:"h1",children:t.children,...t.props}),Ts=t=>e.jsx(v.Text,{variant:"h2",children:t.children,...t.props}),Os=t=>e.jsx(v.Text,{variant:"h3",children:t.children,...t.props}),Rs=t=>e.jsx(v.Text,{variant:"h4",children:t.children,...t.props}),As=t=>e.jsx(v.Text,{variant:"h5",children:t.children,...t.props}),Ws=t=>e.jsx(v.Text,{variant:"h6",children:t.children,...t.props}),zs=t=>e.jsx(v.Text,{variant:"sub-h1",children:t.children,...t.props}),Hs=t=>e.jsx(v.Text,{variant:"sub-h2",children:t.children,...t.props}),Ps=t=>e.jsx(v.Text,{variant:"sub-h3",children:t.children,...t.props}),Vs=t=>e.jsx(v.Text,{variant:"body-1",children:t.children,...t.props}),Ns=t=>e.jsx(v.Text,{variant:"body-2",children:t.children,...t.props}),_s=t=>e.jsx(v.Text,{variant:"body-3",children:t.children,...t.props}),Xe={H1:Ls,H2:Ts,H3:Os,H4:Rs,H5:As,H6:Ws,SubH1:zs,SubH2:Hs,SubH3:Ps,Body1:Vs,Body2:Ns,Body3:_s},Ve=()=>{const{useSearchParams:t,useParams:r,useLocation:n}=ot(),[s,o]=t(),i=bt.searchParamsToObject(s.toString()),l=r(),c=n(),a=l.id;return{setSearchParams:o,searchParams:s,searchQueries:i,isHasQuery:(p,S)=>s.has(p)&&s.get(p)===S,getQueryParam:p=>s.get(p),getRouteParam:p=>l[p],params:l,location:c,id:a,hasId:!!a}},ao=t=>JSON.stringify(t),uo=t=>JSON.stringify(t),xo=t=>JSON.stringify(t),ho=t=>JSON.stringify(t),qs=t=>t,Zs=t=>JSON.stringify(t),It=({value:t,name:r,type:n,withSearchParam:s=!0,setSearchParams:o,searchQueries:i,dropdownSearchKey:l,filterKey:c="filter",pageKey:a="page"})=>{if(s){let u;switch(n){case"search":u=qs(t);break;case"dropdown":case"dropdown-multiple":u=ao(t);break;case"radio":u=uo(t);break;case"date-range":u=xo(t);break;case"advanced-date-range":u=Zs(t);break;case"date":u=ho(t);break;default:u=t;break}if(typeof u<"u"){const g={...i[c]&&typeof i[c]=="string"?JSON.parse(i[c]):void 0,[r]:u},m={...i};l&&typeof l=="string"&&delete m[l],delete m[a];const p={...m,[c]:JSON.stringify(g)},S=new URLSearchParams(i).toString(),b=new URLSearchParams(p).toString();if(S===b)return;o(p)}}},qt=({name:t,filterKey:r="filter",searchParams:n,get:s})=>{const o=n.get(r)||void 0,i=o&&typeof o=="string"?JSON.parse(o):void 0,l=i?i[t]:void 0;return s==="label"&&l?JSON.parse(l)[0].label:s==="value"&&l?JSON.parse(l)[0].value:l},fo=({name:t,filterKey:r="filter",searchParams:n,get:s})=>{const o=n.get(r)||void 0,i=o&&typeof o=="string"?JSON.parse(o):void 0,l=i?i[t]:void 0;return s==="label"&&l?JSON.parse(l).map(c=>c.label):s==="value"&&l?JSON.parse(l).map(c=>c.value):s==="array"&&l?JSON.parse(l):l},Gs=({name:t,filterKey:r="filter",searchParams:n,get:s})=>{const o=n.get(r)||void 0,i=o&&typeof o=="string"?JSON.parse(o):void 0,l=i?i[t]:void 0;return s==="id"&&l?JSON.parse(l).id:s==="label"&&l?JSON.parse(l).label:s==="value"&&l?JSON.parse(l).value:l},Xt=(t,r,n)=>{const s=r.get(n||"filter")||void 0,o=s&&typeof s=="string"?JSON.parse(s):void 0;return o?o[t]:void 0},Qs=({name:t,filterKey:r="filter",searchParams:n})=>{const s=n.get(r||"filter")||void 0,o=s&&typeof s=="string"?JSON.parse(s):void 0,i=o?o[t]:void 0;return{start:i?JSON.parse(i).from:void 0,end:i?JSON.parse(i).to:void 0}},mo=({name:t,filterKey:r="filter",searchParams:n})=>{const s=n.get(r||"filter")||void 0,o=s&&typeof s=="string"?JSON.parse(s):void 0,i=o?o[t]:void 0;return i?JSON.parse(i):void 0},Us=(t,{filterKey:r="filter",perPageKey:n="perPage",pageKey:s="page"})=>{const o=t.get(r)||void 0,i=t.get(n)||void 0,l=t.get(s)||void 0;return!!o||!!i||!!l},go=({isOpen:t,onClose:r,filterKey:n,pageKey:s,filters:o})=>{const{searchParams:i,setSearchParams:l,searchQueries:c}=Ve(),[a,u]=d.useState({}),f=()=>{i.delete(n||"filter"),l(i)},g=(m,p)=>{switch(m.type){case"radio":{const{show:S=!0}=m;return S&&e.jsx(x.Box,{direction:"column",children:e.jsx(x.Box,{direction:"column",children:m.title})},p)}case"dropdown":{const{show:S=!0}=m;return S&&e.jsx(x.Box,{direction:"column",children:e.jsx(x.Box,{direction:"column",children:m.title})},p)}case"date-range":return e.jsx(x.Box,{direction:"column",children:e.jsx(x.Box,{direction:"column",children:m.title})},p);case"date":return e.jsx(x.Box,{direction:"column",children:e.jsx(x.Box,{direction:"column",children:m.title})},p);case"dropdown-multiple":{const{show:S=!0}=m;return S&&e.jsx(x.Box,{direction:"column",children:e.jsx(x.Box,{direction:"column",children:m.title})},p)}default:return null}};return e.jsx(co,{onHide:r,show:t||!1,children:e.jsxs(x.Box,{direction:"column",gap:"md",children:[e.jsxs(ce.Flex,{direction:"row",justify:"space-between",align:"center",children:[e.jsx(x.Box,{direction:"column",children:"Filter"}),e.jsx(x.Box,{direction:"column",style:{cursor:"pointer"},onClick:f,children:"Reset"})]}),o==null?void 0:o.map((m,p)=>g(m,p))]})})},yo=({searchKey:t="q",statusKey:r="status",searchPlaceholder:n="Search",searchHighlightPlaceholder:s,extendedFilter:o,showSearchFilter:i=!0,showStatusFilter:l=!0,filterKey:c="filter",pageKey:a="page",customWidthSearch:u,handleOnReset:f,filterConfigs:g,buttonToggleProps:m,position:p="right",titleSearchLabel:S="Work Order",withTitleLabels:b=!1})=>{const B=(m==null?void 0:m.isShowLabel)??!0,[F,w]=d.useState(!1),[D,A]=d.useState(0),O=()=>{A(P=>P+1)},{searchParams:C,setSearchParams:R,getQueryParam:L}=Ve(),U=bt.searchParamsToObject(C.toString()),J=Xt(t,C,c)||"",[N,_]=d.useState(J),X=L(c),V=!!(X&&!(()=>{if(X)try{const P=JSON.parse(X);return Object.keys(P).length===1&&P[t]===""}catch(P){console.error("Filter parameter is not a valid JSON:",P)}return!1})()),z=Ce.useMediaQuery("md");return d.useEffect(()=>{_(J)},[J]),d.useEffect(()=>{if(N===J)return;const P=window.setTimeout(()=>{It({value:N,name:t,type:"search",searchQueries:U,setSearchParams:R,filterKey:c,pageKey:a})},350);return()=>{window.clearTimeout(P)}},[N,J,t,U,R,c,a]),e.jsxs(ce.Flex,{gap:"md",style:{flexDirection:z&&p==="left"?"row":z&&p==="right"?"row-reverse":"column"},align:"flex-end",children:[V&&e.jsx(x.Box,{direction:"column",justify:"flex-end",children:e.jsx(H.Button,{onClick:()=>{const P=new URLSearchParams(C);P.delete(c),R(P),_(""),O(),f&&f()},variant:"outline",tone:"neutral",children:e.jsx(v.Text,{color:"error",fontWeight:"semibold",children:"Reset"})})}),o==null?void 0:o.map(({minWidth:P,content:se,title:ye,onClickContainer:Se},xe)=>e.jsxs(x.Box,{direction:"column",gap:"sm",onClick:Se,style:{minWidth:P},children:[ye&&e.jsx(Xe.SubH3,{children:ye}),se]},`extended-filter-${xe}-${D}`)),!!(g!=null&&g.length)&&e.jsx(H.Button,{primary:V,secondary:!V,iconLeft:e.jsx(E.Icon,{size:"sm",name:(m==null?void 0:m.icon)||"FilterHorizontal",style:{color:X?"var(--sa-background-brand, #04254f)":"var(--sa-text-primary, #292a2e)"}}),fullWidth:!z,onClick:()=>w(!0),children:B?"Filter":void 0}),l&&e.jsxs(x.Box,{direction:"column",gap:"sm",style:{minWidth:"126px"},children:[b&&e.jsx(Xe.SubH3,{children:"Status"}),e.jsx(jt.Dropdown,{dropdownLists:[{label:"Active",value:"active"},{label:"InActive",value:"inactive"}],defaultValue:qt({get:"value",name:r,searchParams:C,filterKey:c})?[{label:qt({get:"value",name:r,searchParams:C,filterKey:c})==="active"?"Active":"InActive",value:qt({get:"value",name:r,searchParams:C,filterKey:c})}]:[],onChange:P=>It({value:P,name:r,type:"dropdown",searchQueries:U,setSearchParams:R,filterKey:c}),placeholder:b?"All":"All Status"},D)]}),i&&e.jsxs(x.Box,{direction:"column",gap:"sm",style:{width:u&&z?u:z?"310px":""},children:[b&&e.jsxs(Xe.SubH3,{children:["Search for ",S]}),e.jsx(dt.Input,{placeholder:n,leftIcon:e.jsx(E.Icon,{name:"Search",width:20,height:20}),onChange:P=>_(P.target.value),value:N,fullWidth:!0},D+1+c)]}),e.jsx(go,{isOpen:F,onClose:()=>w(!1),filterKey:c,filters:g,pageKey:a})]})},Js=t=>t==="checkbox-multiple"?"dropdown-multiple":t==="radio"?"dropdown":t==="date-compact"?"date":t;function Qr({configs:t,filterKey:r="filter",activeFilterKey:n="filters",pageKey:s="page",searchKey:o="q"}){const{searchParams:i,setSearchParams:l,searchQueries:c}=Ve(),a=d.useMemo(()=>Object.fromEntries(t.map(D=>[D.key,D])),[t]),u=d.useMemo(()=>{const D=(i.get(n)||"").split(",").map(O=>O.trim()).filter(Boolean);let A=[];try{const O=i.get(r);O&&(A=Object.keys(JSON.parse(O)).filter(C=>C!==o))}catch{}return t.map(O=>O.key).filter(O=>{const C=a[O];return(C==null?void 0:C.locked)||D.includes(O)||A.includes(O)})},[i,n,r,o,t,a]),f=d.useCallback(D=>{try{return D[r]?JSON.parse(D[r]):{}}catch{return{}}},[r]),g=d.useCallback(D=>{const A={...c};D.length?A[n]=D.join(","):delete A[n],l(A)},[c,n,l]),m=d.useCallback(D=>{u.includes(D)||g([...u,D])},[u,g]),p=d.useCallback(D=>{var R;if((R=a[D])!=null&&R.locked)return;const A={...c},O=u.filter(L=>L!==D);O.length?A[n]=O.join(","):delete A[n];const C=f(A);D in C&&(delete C[D],Object.keys(C).length?A[r]=JSON.stringify(C):delete A[r]),delete A[s],l(A)},[c,u,n,r,s,f,l,a]),S=d.useCallback(D=>u.includes(D)?p(D):m(D),[u,m,p]),b=d.useCallback(D=>{switch(D.type){case"dropdown":case"dropdown-multiple":case"checkbox-multiple":case"radio":return fo({name:D.key,get:"array",searchParams:i,filterKey:r})||[];case"date":{const A=mo({name:D.key,searchParams:i,filterKey:r});return A?new Date(A):void 0}case"date-compact":{const O=f(Object.fromEntries(i.entries()))[D.key];return O&&typeof O=="object"?O:void 0}default:return}},[i,r,f]),I=d.useCallback((D,A)=>{if(D.type==="date-compact"){const O={...c},C=f(O);A==null?delete C[D.key]:C[D.key]=A,Object.keys(C).length?O[r]=JSON.stringify(C):delete O[r],delete O[s],l(O);return}It({value:A,name:D.key,type:Js(D.type),searchQueries:c,setSearchParams:l,filterKey:r,pageKey:s})},[c,l,r,s,f]),B=d.useCallback(D=>{const A={...c},O=f(A);D in O&&(delete O[D],Object.keys(O).length?A[r]=JSON.stringify(O):delete A[r]),delete A[s],l(A)},[c,r,s,f,l]),F=d.useCallback(()=>{const D={...c};delete D[r],delete D[n],delete D[s],l(D)},[c,r,n,s,l]),w=u.length>0;return{activeKeys:u,configByKey:a,hasActiveFilter:w,addFilter:m,removeFilter:p,toggleFilter:S,getValue:b,setValue:I,clearValue:B,clearAll:F}}const Ur={get(t){return Ft.storage.get(t)??null},set(t,r){Ft.storage.save(t,r)},remove(t){Ft.storage.delete(t)}},Ct={columns:t=>`filterbar:colprefs:${t}`,savedViews:t=>`filterbar:views:${t}`,lastState:t=>`filterbar:last:${t}`,perPage:t=>`filterbar:perpage:${t}`,tableSort:t=>`tablelayout:sort:${t}`},zt=(t,r)=>{const n=new Set(r.map(i=>i.key)),s=t.order.filter(i=>n.has(i));for(const i of r)s.includes(i.key)||s.push(i.key);const o=t.hidden.filter(i=>n.has(i));return{order:s,hidden:o}};function Ys({columns:t,scopeId:r,storage:n,onColumnsChange:s,value:o}){const i=d.useMemo(()=>({order:t.map(C=>C.key),hidden:[]}),[t]),l=r?Ct.columns(r):void 0,c=(C,R)=>zt({order:C.order??R,hidden:C.hidden??[]},t),[a,u]=d.useState(()=>{if(o&&(o.order||o.hidden))return c(o,t.map(C=>C.key));if(l){const C=n.get(l);if(C&&Array.isArray(C.order))return zt(C,t)}return i}),f=t.map(C=>C.key).join("|");d.useEffect(()=>u(C=>zt(C,t)),[f]);const g=d.useRef(a);g.current=a;const m=o?`${(o.order??[]).join("|")}~${(o.hidden??[]).join("|")}`:null,p=d.useRef(m);d.useEffect(()=>{if(m==null||p.current===m)return;p.current=m;const C=g.current,R=c(o,C.order);R.order.join("|")===C.order.join("|")&&R.hidden.join("|")===C.hidden.join("|")||(u(R),l&&n.set(l,R))},[m,f]);const S=d.useRef(!1);d.useEffect(()=>{S.current||(S.current=!0,s==null||s(a))},[]);const b=d.useCallback(C=>{u(C),l&&n.set(l,C),s==null||s(C)},[l,n,s]),I=d.useMemo(()=>{const C=new Map(t.map(R=>[R.key,R]));return a.order.filter(R=>C.has(R)).map(R=>({...C.get(R),visible:!a.hidden.includes(R)}))},[a,t]),B=d.useCallback(C=>{const R=a.hidden.includes(C)?a.hidden.filter(L=>L!==C):[...a.hidden,C];b({...a,hidden:R})},[a,b]),F=d.useCallback((C,R)=>{if(C===R)return;const L=[...a.order],[U]=L.splice(C,1);L.splice(R,0,U),b({...a,order:L})},[a,b]),w=d.useCallback(C=>{b({...a,hidden:C?t.filter(R=>!R.locked).map(R=>R.key):[]})},[a,t,b]),D=d.useCallback(()=>b(i),[b,i]),A=d.useCallback(C=>b(zt(C,t)),[b,t]),O=a.hidden.length===0;return{state:a,orderedColumns:I,allVisible:O,toggleVisibility:B,reorder:F,setAllHidden:w,reset:D,applyState:A}}function Xs({scopeId:t,storage:r,snapshotKeys:n,pageKey:s="page",getColumns:o,applyColumns:i}){const{searchParams:l,setSearchParams:c}=Ve(),a=t?Ct.savedViews(t):void 0,[u,f]=d.useState(()=>a?r.get(a)||[]:[]),g=d.useCallback(b=>{f(b),a&&r.set(a,b)},[a]),m=d.useCallback(b=>{const I=b.trim();if(!I)return;const B={};n.forEach(w=>{const D=l.get(w);D!=null&&(B[w]=D)});const F={id:`${Date.now()}`,name:I,query:B,columns:o==null?void 0:o(),createdAt:Date.now()};g([...u,F])},[n,l,o,g,u]),p=d.useCallback(b=>g(u.filter(I=>I.id!==b)),[g,u]),S=d.useCallback(b=>{const I=Object.fromEntries(l.entries());n.forEach(B=>delete I[B]),Object.assign(I,b.query),delete I[s],c(I),b.columns&&(i==null||i(b.columns))},[l,n,s,c,i]);return{enabled:!!a,views:u,saveView:m,deleteView:p,applyView:S}}function $s(t,r){let n;try{n=JSON.parse(t)}catch{return t}return!n||typeof n!="object"?t:(delete n[r],Object.keys(n).length>0?JSON.stringify(n):void 0)}function En(t,r,n){const s=t[r];if(s==null)return;const o=$s(s,n);o===void 0?delete t[r]:t[r]=o}function Ks({scopeId:t,storage:r,snapshotKeys:n,enabled:s=!0,filterKey:o="filter",searchKey:i="q",persistSearch:l=!0}){const{searchParams:c}=Ve(),a=t&&s?Ct.lastState(t):void 0,u=d.useRef(a),f=d.useRef(!1);d.useEffect(()=>{if(!a){u.current=a;return}if(u.current!==a){u.current=a,f.current=!1;return}const p={};if(n.forEach(S=>{const b=c.get(S);b!=null&&(p[S]=b)}),l||En(p,o,i),Object.keys(p).length===0){f.current&&r.remove(a);return}f.current=!0,r.set(a,p)},[c,a,n,r,l,o,i]);const g=d.useCallback(()=>{if(!a)return null;const p=r.get(a);return!p||Object.keys(p).length===0||!l&&(En(p,o,i),Object.keys(p).length===0)?null:p},[a,r,l,o,i]),m=d.useCallback(()=>{a&&r.remove(a)},[a,r]);return{enabled:!!a,read:g,clear:m}}function ei({scopeId:t,storage:r,perPageKey:n,pageSizeOptions:s,enabled:o=!0}){const{searchParams:i}=Ve(),l=t&&o?Ct.perPage(t):void 0,c=i.toString(),a=d.useRef(l);d.useEffect(()=>{if(!l){a.current=l;return}if(a.current!==l){a.current=l;return}const g=i.get(n);if(!g)return;const m=Number(g);!Number.isFinite(m)||m<=0||r.set(l,m)},[c,l,n,r]);const u=d.useCallback(()=>{if(!l)return null;const g=r.get(l);if(g==null)return null;const m=Number(g);return!Number.isFinite(m)||m<=0||s&&!s.includes(m)?null:String(m)},[l,r,s]),f=d.useCallback(()=>{l&&r.remove(l)},[l,r]);return{enabled:!!l,read:u,clear:f}}let pr={},jr=!1,br=null;const ti=(t,r)=>{Object.assign(pr,t),br=r,!jr&&(jr=!0,queueMicrotask(()=>{const n=pr,s=br;pr={},jr=!1,br=null,!(!s||Object.keys(n).length===0)&&s(o=>{const i=new URLSearchParams(o);return Object.entries(n).forEach(([l,c])=>i.set(l,c)),i})}))};function ri({enabled:t,snapshotKeys:r,perPageKey:n,readSnapshot:s,readPerPage:o}){const{searchParams:i,setSearchParams:l,location:c}=Ve(),a=d.useRef(null);d.useEffect(()=>{if(!t||a.current===c.pathname)return;a.current=c.pathname;const u={};if(!i.has(n)){const f=o();f&&(u[n]=f)}if(!r.some(f=>i.has(f))){const f=s();f&&Object.assign(u,f)}Object.keys(u).length!==0&&ti(u,l)},[c.pathname,t])}const ni=({configs:t,activeKeys:r,onToggle:n,hasActiveFilter:s,onReset:o})=>t.length?e.jsxs(T.Menu,{position:"bottom-left",children:[e.jsx(T.MenuButton,{children:e.jsx(H.Button,{variant:s?"secondary":"outline",tone:"neutral",size:"sm",iconLeft:e.jsx(E.Icon,{name:"FilterHorizontal"}),"aria-label":"Add filter"})}),e.jsx(T.MenuLists,{children:e.jsx(T.MenuBody,{style:{minWidth:260},title:e.jsxs(x.Box,{display:"flex",direction:"row",align:"center",justify:"space-between",fullWidth:!0,children:[e.jsx(v.Text,{fontSize:"sm",fontWeight:"medium",color:"subtlest",children:"Add Filter"}),s&&o&&e.jsx(H.Button,{variant:"link",tone:"brand",size:"xs",onClick:o,children:"Reset"})]}),children:t.map(i=>e.jsx(T.MenuItem,{selected:i.locked||r.includes(i.key),disabled:i.locked,closeOnSelect:!1,startIcon:i.icon??void 0,onClick:()=>{i.locked||n(i.key)},children:i.label},i.key))})})]}):null,$t=({onClear:t,onRemove:r})=>e.jsxs(T.Menu,{position:"bottom-right",children:[e.jsx(T.MenuButton,{children:e.jsx(H.Button,{variant:"link",tone:"neutral",size:"xs",iconLeft:e.jsx(E.Icon,{name:"MenuHorizontal"}),"aria-label":"Filter actions"})}),e.jsx(T.MenuLists,{children:e.jsxs(T.MenuBody,{style:{width:180},children:[e.jsx(T.MenuItem,{startIcon:e.jsx(E.Icon,{name:"CrossCircle"}),onClick:t,children:"Clear value"}),r&&e.jsx(T.MenuItem,{intent:"danger",startIcon:e.jsx(E.Icon,{name:"Trash1"}),onClick:r,children:"Remove filter"})]})})]}),oi=t=>{const r=new Date(t);return r.setHours(0,0,0,0),r},Fn=(t,r,n)=>{const s=new Date(t);return n==="day"?s.setDate(s.getDate()+r):n==="week"?s.setDate(s.getDate()+r*7):n==="month"?s.setMonth(s.getMonth()+r):s.setFullYear(s.getFullYear()+r),s},po=t=>{const r=oi(new Date);if(t.direction==="this"){const s=new Date(r),o=new Date(r);return t.period==="week"?(s.setDate(r.getDate()-r.getDay()),o.setDate(s.getDate()+6)):t.period==="month"?(s.setDate(1),o.setMonth(o.getMonth()+1,0)):t.period==="year"&&(s.setMonth(0,1),o.setMonth(11,31)),{from:s,to:o}}const n=t.count??1;return t.direction==="past"?{from:Fn(r,-n,t.period),to:r}:{from:r,to:Fn(r,n,t.period)}},Mn=24,jo=t=>t.length>Mn?`${t.slice(0,Mn)}...`:t,bo=t=>t.toLocaleDateString(void 0,{day:"2-digit",month:"short",year:"numeric"}),vr=(t,r="days")=>r==="months"?t.toLocaleDateString(void 0,{month:"short",year:"numeric"}):r==="years"?String(t.getFullYear()):bo(t),Ut={is:"Is","is-before":"Is before","is-after":"Is after","is-on-or-before":"Is on or before","is-on-or-after":"Is on or after","is-between":"Is between","is-relative-to-today":"Is relative to today","is-empty":"Is empty","is-not-empty":"Is not empty"},si=["is","is-before","is-after","is-on-or-before","is-on-or-after","is-between","is-relative-to-today","is-empty","is-not-empty"],Or={past:"Past",next:"Next",this:"This"},ii=["day","week","month","year"],li=["past","next","this"],ci=t=>t.field.type==="date-compact"?e.jsx(ui,{field:t.field,value:t.value,onChange:t.onChange,onClear:t.onClear,onRemove:t.onRemove}):e.jsx(ai,{field:t.field,value:t.value,onChange:t.onChange,onClear:t.onClear,onRemove:t.onRemove}),ai=({field:t,value:r,onChange:n,onClear:s,onRemove:o})=>{const i=r?bo(new Date(r)):null,l=!!i,c=l?e.jsxs(e.Fragment,{children:[e.jsxs("span",{style:{fontWeight:500},children:[t.label,":"]})," ",e.jsx("span",{style:{fontWeight:400},children:jo(i)})]}):t.label;return e.jsxs(T.Menu,{position:"bottom-left",children:[e.jsx(T.MenuButton,{children:e.jsx(H.Button,{variant:l?"secondary":"outline",tone:"neutral",size:"sm",iconLeft:l?e.jsx(E.Icon,{name:"Calendar",size:"sm"}):void 0,iconRight:e.jsx(E.Icon,{name:"ChevronSmallDown"}),children:c})}),e.jsx(T.MenuLists,{children:e.jsx(T.MenuBody,{style:{width:260},title:e.jsxs(x.Box,{display:"flex",direction:"row",align:"center",justify:"space-between",fullWidth:!0,children:[e.jsx(v.Text,{fontSize:"sm",fontWeight:"medium",color:"subtlest",children:t.label}),e.jsx($t,{onClear:s,onRemove:o})]}),children:e.jsx(ht.StarasiaDate,{size:"sm",input:!1,clearable:!0,filter:t.mode,value:r,onChange:a=>a==null?s():n(a),withPadding:!1})})})]})},di=(t,r="days")=>{switch(t.op){case"is":case"is-before":case"is-after":case"is-on-or-before":case"is-on-or-after":return t.date?`${Ut[t.op]} ${vr(new Date(t.date),r)}`:null;case"is-between":return t.from&&t.to?`${vr(new Date(t.from),r)} - ${vr(new Date(t.to),r)}`:null;case"is-relative-to-today":{const n=t.relative;if(!n)return null;if(n.direction==="this")return`This ${n.period}`;const s=n.count??1,o=s===1?n.period:`${n.period}s`;return`${Or[n.direction]} ${s} ${o}`}case"is-empty":case"is-not-empty":return Ut[t.op];default:return null}},ui=({field:t,value:r,onChange:n,onClear:s,onRemove:o})=>{const i=t.ops&&t.ops.length>0?t.ops:si,l=t.defaultOp&&i.includes(t.defaultOp)?t.defaultOp:i[0],c=t.mode??"days",a=(r==null?void 0:r.op)??l,u=r?di(r,c):null,f=!!u,g=f?e.jsxs(e.Fragment,{children:[e.jsxs("span",{style:{fontWeight:500},children:[t.label,":"]})," ",e.jsx("span",{style:{fontWeight:400},children:jo(u)})]}):t.label,m=p=>{if(p!==a){if(p==="is-empty"||p==="is-not-empty"){n({op:p});return}if(p==="is-relative-to-today"){n({op:p,relative:(r==null?void 0:r.relative)??{direction:"past",count:1,period:"week"}});return}if(p==="is-between"){n({op:p,from:r==null?void 0:r.from,to:r==null?void 0:r.to});return}n({op:p,date:r==null?void 0:r.date})}};return e.jsxs(T.Menu,{position:"bottom-left",children:[e.jsx(T.MenuButton,{children:e.jsx(H.Button,{variant:f?"secondary":"outline",tone:"neutral",size:"sm",iconLeft:f?e.jsx(E.Icon,{name:"Calendar",size:"sm"}):void 0,iconRight:e.jsx(E.Icon,{name:"ChevronSmallDown"}),children:g})}),e.jsxs(T.MenuLists,{children:[e.jsx(T.MenuBody,{style:{width:320},title:e.jsxs(x.Box,{display:"flex",direction:"row",align:"center",justify:"space-between",gap:"xs",fullWidth:!0,children:[e.jsxs(x.Box,{display:"flex",direction:"row",align:"center",gap:"xs",style:{minWidth:0},children:[e.jsx(v.Text,{fontSize:"sm",fontWeight:"medium",color:"subtlest",children:t.label}),e.jsx(xi,{op:a,ops:i,onChange:m})]}),e.jsx($t,{onClear:s,onRemove:o})]}),children:e.jsx(hi,{value:r,op:a,mode:c,onChange:n})}),a==="is-relative-to-today"&&e.jsx(T.MenuFooter,{children:e.jsx(v.Text,{fontSize:"xs",color:"subtlest",children:"Filter will update with the current date"})})]})]})},xi=({op:t,ops:r,onChange:n})=>e.jsxs(T.Menu,{position:"bottom-left",children:[e.jsx(T.MenuButton,{children:e.jsx(H.Button,{variant:"link",tone:"neutral",size:"xs",iconRight:e.jsx(E.Icon,{name:"ChevronSmallDown"}),children:Ut[t]})}),e.jsx(T.MenuLists,{children:e.jsx(T.MenuBody,{style:{width:200},children:r.map(s=>e.jsx(T.MenuItem,{selected:t===s,onClick:()=>n(s),endIcon:t===s?e.jsx(E.Icon,{name:"Check"}):void 0,children:Ut[s]},s))})})]}),hi=({value:t,op:r,mode:n="days",onChange:s})=>{if(r==="is-empty"||r==="is-not-empty")return e.jsx(x.Box,{paddingBlock:"sm",paddingInline:"sm",children:e.jsx(v.Text,{fontSize:"xs",color:"subtlest",children:"No further input required."})});if(r==="is-between"){const o=t!=null&&t.from||t!=null&&t.to?{from:t!=null&&t.from?new Date(t.from):null,to:t!=null&&t.to?new Date(t.to):null}:void 0;return e.jsx(ht.StarasiaDate,{size:"sm",input:!1,clearable:!0,rangedDate:!0,filter:n,value:o,onChange:i=>{if(i==null){s({op:r});return}if(typeof i=="object"&&i!==null&&"from"in i&&"to"in i){let{from:l,to:c}=i;if(!l&&c&&(l=c,c=null),!l&&!c){s({op:r});return}s({op:r,from:l?l.toISOString():void 0,to:c?c.toISOString():void 0})}},withPadding:!1},`range-${n}`)}return r==="is-relative-to-today"?e.jsx(fi,{value:t==null?void 0:t.relative,onChange:o=>s({op:r,relative:o})}):e.jsx(ht.StarasiaDate,{size:"sm",input:!1,clearable:!0,filter:n,value:t!=null&&t.date?new Date(t.date):void 0,onChange:o=>{if(o==null){s({op:r});return}o instanceof Date&&s({op:r,date:o.toISOString()})},withPadding:!1},`single-${n}`)},fi=({value:t,onChange:r})=>{const n=(t==null?void 0:t.direction)??"past",s=(t==null?void 0:t.count)??1,o=(t==null?void 0:t.period)??"week",i=n!=="this",l=po({direction:n,count:s,period:o});return e.jsxs(x.Box,{direction:"column",display:"flex",gap:"sm",children:[e.jsxs(x.Box,{direction:"row",display:"flex",align:"center",gap:"xs",children:[e.jsxs(T.Menu,{position:"bottom-left",children:[e.jsx(T.MenuButton,{children:e.jsx(H.Button,{variant:"outline",tone:"neutral",size:"sm",iconRight:e.jsx(E.Icon,{name:"ChevronSmallDown"}),children:Or[n]})}),e.jsx(T.MenuLists,{children:e.jsx(T.MenuBody,{style:{width:140},children:li.map(c=>e.jsx(T.MenuItem,{selected:n===c,endIcon:n===c?e.jsx(E.Icon,{name:"Check"}):void 0,onClick:()=>r(c==="this"?{direction:c,period:o}:{direction:c,count:s,period:o}),children:Or[c]},c))})})]}),i&&e.jsx(dt.Input,{type:"number",size:"sm",min:1,clearable:!1,value:s,onChange:c=>{const a=Number(c.target.value);r({direction:n,count:Number.isFinite(a)&&a>0?a:1,period:o})},style:{width:72}}),e.jsxs(T.Menu,{position:"bottom-left",children:[e.jsx(T.MenuButton,{children:e.jsx(H.Button,{variant:"outline",tone:"neutral",size:"sm",iconRight:e.jsx(E.Icon,{name:"ChevronSmallDown"}),children:o})}),e.jsx(T.MenuLists,{children:e.jsx(T.MenuBody,{style:{width:140},children:ii.map(c=>e.jsx(T.MenuItem,{selected:o===c,endIcon:o===c?e.jsx(E.Icon,{name:"Check"}):void 0,onClick:()=>r(n==="this"?{direction:n,period:c}:{direction:n,count:s,period:c}),children:c},c))})})]})]}),e.jsx(ht.StarasiaDate,{size:"sm",input:!1,disabled:!0,rangedDate:!0,value:l,onChange:()=>{},withPadding:!1},"relative-preview")]})},In=18,mi=t=>t.length>In?`${t.slice(0,In)}...`:t,gi=({field:t,value:r,onChange:n,onClear:s,onRemove:o})=>{const i=t.type==="dropdown-multiple",l=r.length,c=t.searchable!==!1,[a,u]=d.useState(""),f=t.options,g=typeof t.onSearch=="function",m=(()=>{if(g)return f;const B=a.trim().toLowerCase();return B?f.filter(F=>F.label.toLowerCase().includes(B)):f})(),p=B=>r.some(F=>F.value===B.value),S=B=>{if(!i){n([{label:B.label,value:B.value}]),u("");return}n(p(B)?r.filter(F=>F.value!==B.value):[...r,{label:B.label,value:B.value}])},b=B=>{var F;u(B),(F=t.onSearch)==null||F.call(t,B)},I=l===0?t.label:e.jsxs(e.Fragment,{children:[e.jsxs("span",{style:{fontWeight:500},children:[t.label,":"]})," ",e.jsx("span",{style:{fontWeight:400},children:l===1?mi(r[0].label):`${l} Selected`})]});return e.jsxs(T.Menu,{position:"bottom-left",children:[e.jsx(T.MenuButton,{children:e.jsx(H.Button,{variant:l>0?"secondary":"outline",tone:"neutral",size:"sm",iconLeft:l>0?e.jsx(E.Icon,{name:"Tag",size:"sm"}):void 0,iconRight:e.jsx(E.Icon,{name:"ChevronSmallDown"}),children:I})}),e.jsx(T.MenuLists,{children:e.jsx(T.MenuBody,{style:{width:260},title:e.jsxs(x.Box,{display:"flex",direction:"row",align:"center",justify:"space-between",fullWidth:!0,children:[e.jsx(v.Text,{fontSize:"sm",fontWeight:"medium",color:"subtlest",children:t.label}),e.jsx($t,{onClear:s,onRemove:o})]}),children:e.jsxs(x.Box,{direction:"column",gap:"sm",children:[c&&e.jsx(jt.Dropdown,{size:"sm",triggerInput:!0,fullWidth:!0,hideChevronIcon:!0,clearable:!0,multiSelect:i,searchAble:!0,searchValue:a,onSearch:b,value:r,onChange:n,placeholder:`Search ${t.label.toLowerCase()}…`}),e.jsx(x.Box,{direction:"column",overflow:"overflow-y-auto",customMaxHeight:"240px",children:t.isLoading?e.jsx(x.Box,{paddingBlock:"sm",paddingInline:"sm",children:e.jsx(v.Text,{fontSize:"xs",color:"subtlest",children:"Loading…"})}):m.length===0?e.jsx(x.Box,{paddingBlock:"sm",paddingInline:"sm",children:e.jsx(v.Text,{fontSize:"xs",color:"subtlest",children:"No results"})}):m.map(B=>e.jsx(T.MenuItem,{closeOnSelect:!i,selected:p(B),startIcon:B.avatar,endIcon:p(B)?e.jsx(E.Icon,{name:"Check"}):void 0,description:B.description,onClick:()=>S(B),children:B.label},B.value))})]})})})]})},Ln=18,yi=t=>t.length>Ln?`${t.slice(0,Ln)}...`:t,Tn=({checked:t,indeterminate:r})=>e.jsx("span",{style:{pointerEvents:"none",display:"inline-flex"},children:e.jsx(nt.Checkbox,{size:"sm",checked:t,readOnly:!0,onChange:()=>{},variant:r?"indeterminate":"select"})}),pi=({field:t,value:r,onChange:n,onClear:s,onRemove:o})=>{const i=new Set(r.map(m=>m.value)),l=r.length,c=t.options.length>0&&t.options.every(m=>i.has(m.value)),a=l>0&&!c,u=m=>{n(i.has(m.value)?r.filter(p=>p.value!==m.value):[...r,{label:m.label,value:m.value}])},f=()=>{n(c?[]:t.options.map(m=>({label:m.label,value:m.value})))},g=l===0?t.label:e.jsxs(e.Fragment,{children:[e.jsxs(v.Text,{as:"span",fontWeight:"semibold",children:[t.label,":"]})," ",e.jsx(v.Text,{as:"span",children:l===1?yi(r[0].label):`${l} Selected`})]});return e.jsxs(T.Menu,{position:"bottom-left",children:[e.jsx(T.MenuButton,{children:e.jsx(H.Button,{variant:l>0?"secondary":"outline",tone:"neutral",size:"sm",iconLeft:l>0?e.jsx(E.Icon,{name:"Tag",size:"sm"}):void 0,iconRight:e.jsx(E.Icon,{name:"ChevronSmallDown"}),children:g})}),e.jsx(T.MenuLists,{children:e.jsxs(T.MenuBody,{style:{width:240},title:e.jsxs(x.Box,{display:"flex",direction:"row",align:"center",justify:"space-between",fullWidth:!0,children:[e.jsx(v.Text,{fontSize:"sm",fontWeight:"medium",color:"subtlest",children:t.label}),e.jsx($t,{onClear:s,onRemove:o})]}),children:[e.jsx(T.MenuItem,{closeOnSelect:!1,selected:c,onClick:f,startIcon:e.jsx(Tn,{checked:c||a,indeterminate:a}),children:"Select All"}),t.options.map(m=>e.jsx(T.MenuItem,{closeOnSelect:!1,selected:i.has(m.value),onClick:()=>u(m),startIcon:e.jsx(Tn,{checked:i.has(m.value)}),children:m.label},m.value))]})})]})},vo=({activeKeys:t,configByKey:r,getValue:n,setValue:s,clearValue:o,removeFilter:i})=>e.jsx(e.Fragment,{children:t.map(l=>{const c=r[l];if(!c)return null;const a=n(c),u=c.locked?void 0:()=>i(l);return c.type==="date"||c.type==="date-compact"?e.jsx(ci,{field:c,value:a,onChange:f=>s(c,f),onClear:()=>o(l),onRemove:u},l):c.type==="checkbox-multiple"?e.jsx(pi,{field:c,value:a||[],onChange:f=>s(c,f),onClear:()=>o(l),onRemove:u},l):e.jsx(gi,{field:c,value:a||[],onChange:f=>s(c,f),onClear:()=>o(l),onRemove:u},l)})}),On=t=>`${t} Rows`,ji=({pagination:t,pageKey:r="page",perPageKey:n="perPage",pageSizeOptions:s=[10,25,50,100],defaultPerPage:o=10,showResultCount:i=!0,showPageSize:l=!0,showPagination:c=!0})=>{var B;const{searchQueries:a,setSearchParams:u,searchParams:f}=Ve(),g=f.get(n),m=g?Number(g):o,p=F=>{u({...a,[r]:String(F)})},S=F=>{u({...a,[n]:F,[r]:"1"})},b=(t==null?void 0:t.rangeStart)??(((t==null?void 0:t.currentPage)||0)>1?(((t==null?void 0:t.currentPage)||0)-1)*((t==null?void 0:t.perPage)||0)+1:0),I=(t==null?void 0:t.rangeEnd)??((t==null?void 0:t.totalCurrentPage)!==(t==null?void 0:t.perPage)?t==null?void 0:t.totalData:((t==null?void 0:t.currentPage)||1)*((t==null?void 0:t.totalCurrentPage)||0));return e.jsxs(e.Fragment,{children:[i&&e.jsx(v.Text,{fontSize:"sm",fontWeight:"medium",color:"primary",truncate:!0,children:`${b}-${I} of ${((B=t==null?void 0:t.totalData)==null?void 0:B.toLocaleString())||0}`}),l&&e.jsxs(T.Menu,{position:"bottom-left",children:[e.jsx(T.MenuButton,{children:e.jsx(H.Button,{variant:"outline",tone:"neutral",size:"sm",iconRight:e.jsx(E.Icon,{name:"ChevronSmallDown"}),"aria-label":"Rows per page",children:On(m)})}),e.jsx(T.MenuLists,{children:e.jsx(T.MenuBody,{children:s.map(F=>e.jsx(T.MenuItem,{selected:F===m,onClick:()=>S(String(F)),children:On(F)},F))})})]}),c&&((t==null?void 0:t.totalPage)??0)>1&&e.jsx(x.Box,{direction:"column",display:"flex",align:"center",gap:"sm",paddingRight:"sm",style:{borderRight:"1px solid var(--sa-border-subtle, rgba(11, 18, 14, 0.14))"},children:e.jsx(Mt.Pagination,{size:"sm",variant:"neutral",siblingCount:0,currentPage:t!=null&&t.currentPage?Number(t.currentPage):1,totalPages:Number(t==null?void 0:t.totalPage),onPageChange:p})})]})};function bi(t,r,n=!0){d.useEffect(()=>{if(!n)return;const s=o=>{var c;if(o.metaKey||o.ctrlKey||o.altKey||o.key!==t||Pe.isOverlayOpen())return;const i=o.target,l=(c=i==null?void 0:i.tagName)==null?void 0:c.toLowerCase();l==="input"||l==="textarea"||i!=null&&i.isContentEditable||(o.preventDefault(),r())};return window.addEventListener("keydown",s),()=>window.removeEventListener("keydown",s)},[t,r,n])}const vi=240,Co=({searchKey:t="q",filterKey:r="filter",pageKey:n="page",placeholder:s="Search",shortcut:o="/",collapsible:i=!0})=>{const{searchParams:l,setSearchParams:c,searchQueries:a}=Ve(),u=Xt(t,l,r)||"",[f,g]=d.useState(!i||!!u),[m,p]=d.useState(i&&!u),[S,b]=d.useState(u),I=Ce.useDebounce(S,350),B=d.useRef(null);d.useEffect(()=>{b(u),u&&g(!0)},[u]),d.useEffect(()=>{f&&p(!1)},[f]),d.useEffect(()=>{I!==u&&It({value:I,name:t,type:"search",searchQueries:a,setSearchParams:c,filterKey:r,pageKey:n})},[I]);const F=d.useCallback(()=>{g(!0),requestAnimationFrame(()=>{var O;return(O=B.current)==null?void 0:O.focus()})},[]);bi(o,F);const w=()=>{i&&!S&&g(!1)},D=O=>{var C;i&&O.key==="Escape"&&!S&&(g(!1),(C=B.current)==null||C.blur())},A=()=>{f||p(!0)};return e.jsxs(x.Box,{display:"flex",direction:"row",align:"center",gap:"spacing-0",children:[m&&e.jsx(H.Button,{variant:"outline",tone:"neutral",size:"sm",iconLeft:e.jsx(E.Icon,{name:"Search",size:"sm"}),"aria-label":"Search","aria-expanded":!1,onClick:F}),e.jsxs(x.Box,{onTransitionEnd:A,style:{position:"relative",width:f?vi:0,overflow:"hidden",transition:"width 220ms ease"},children:[e.jsx(dt.Input,{ref:B,size:"sm",fullWidth:!0,value:S,placeholder:s,leftIcon:e.jsx(E.Icon,{name:"Search",width:16,height:16}),onChange:O=>b(O.target.value),onKeyDown:D,onBlur:w,tabIndex:f?0:-1}),f&&!S&&e.jsx(x.Box,{align:"center",justify:"center",borderColor:"border-subtle",borderWidth:"border",borderStyle:"border-solid",borderRadius:"rounded-xs",paddingInline:"spacing-1",customBackgroundColor:"var(--sa-background-surface-hover, #f1f2f4)",style:{position:"absolute",right:8,top:"50%",transform:"translateY(-50%)",pointerEvents:"none",minWidth:18,height:18,display:"inline-flex"},children:e.jsx(v.Text,{fontSize:"xs",color:"subtle",children:o})})]})]})},wo=({columns:t,allVisible:r,onToggle:n,onReorder:s,onSetAllHidden:o})=>{const[i,l]=d.useState(null),[c,a]=d.useState(null),u=()=>{i!==null&&c!==null&&i!==c&&s(i,c),l(null),a(null)},f=(g,m)=>{const p=g+m;p<0||p>=t.length||s(g,p)};return e.jsxs(T.Menu,{position:"bottom-right",children:[e.jsx(T.MenuButton,{children:e.jsx(H.Button,{variant:r?"outline":"secondary",tone:"neutral",size:"sm",iconLeft:e.jsx(E.Icon,{name:"Grid",size:"sm"}),"aria-label":"Customize columns"})}),e.jsx(T.MenuLists,{children:e.jsx(T.MenuBody,{children:e.jsxs(x.Box,{padding:"sm",direction:"column",customWidth:"296px",customMaxHeight:"60vh",overflow:"overflow-hidden",children:[e.jsx(v.Text,{fontWeight:"semibold",color:"primary",children:"Customize Column Table"}),e.jsxs(x.Box,{direction:"row",display:"flex",align:"center",justify:"space-between",paddingBlock:"md",children:[e.jsx(v.Text,{fontSize:"sm",fontWeight:"medium",color:"subtle",children:"Show in table"}),e.jsx(H.Button,{variant:"link",tone:"info",size:"xs",onClick:()=>o(r),children:r?"Hide All":"Show All"})]}),e.jsx(x.Box,{direction:"column",overflow:"overflow-y-auto",children:t.map((g,m)=>{const p=!g.locked,S=c===m&&i!==null&&i!==m;return e.jsxs(x.Box,{direction:"row",display:"flex",align:"center",gap:"sm",paddingBlock:"xs",draggable:p,onDragStart:()=>p&&l(m),onDragOver:b=>{b.preventDefault(),a(m)},onDrop:u,onDragEnd:u,style:{minHeight:32,boxShadow:S?"inset 0 2px 0 0 var(--sa-background-brand, #04254f)":void 0},children:[e.jsx(x.Box,{direction:"column",as:"div",align:"center",justify:"center",role:"button",tabIndex:p?0:-1,"aria-label":`Reorder ${g.title}`,"aria-disabled":!p||void 0,color:"icon-subtlest",onKeyDown:b=>{p&&(b.key==="ArrowUp"?(b.preventDefault(),f(m,-1)):b.key==="ArrowDown"&&(b.preventDefault(),f(m,1)))},style:{display:"inline-flex",cursor:p?"grab":"default",opacity:p?1:.4},children:e.jsx(E.Icon,{name:"DragVertical",width:16,height:16})}),g.icon&&e.jsx(x.Box,{direction:"column",align:"center",color:"icon-subtle",style:{display:"inline-flex"},children:g.icon}),e.jsx(v.Text,{fontSize:"sm",fontWeight:"medium",color:"primary",truncate:!0,children:g.title}),e.jsx(x.Box,{direction:"column",style:{marginLeft:"auto"},children:e.jsx(vt.Toggle,{size:"sm",checked:g.visible,disabled:g.locked,onChange:()=>n(g.key),"aria-label":`Toggle ${g.title} column`})})]},g.key)})})]})})})]})},Do=({views:t,onApply:r,onDelete:n,onSave:s})=>{const[o,i]=d.useState(""),l=()=>{const c=o.trim();c&&(s(c),i(""))};return e.jsxs(T.Menu,{position:"bottom-right",children:[e.jsx(T.MenuButton,{children:e.jsx(H.Button,{variant:t.length>0?"secondary":"outline",tone:(t.length>0,"neutral"),size:"sm",iconLeft:e.jsx(E.Icon,{name:"Bookmark",size:"sm"}),"aria-label":"Saved views"})}),e.jsxs(T.MenuLists,{style:{width:"260px"},children:[e.jsx(T.MenuBody,{children:e.jsxs(x.Box,{direction:"column",padding:"xs",gap:"sm",children:[e.jsx(v.Text,{fontWeight:"semibold",color:"primary",children:"Saved Views"}),e.jsx(x.Box,{direction:"column",overflow:"overflow-y-auto",children:t.length===0?e.jsx(x.Box,{direction:"column",paddingBlock:"sm",children:e.jsx(v.Text,{fontSize:"sm",color:"subtlest",children:"No saved views yet"})}):t.map(c=>e.jsx(T.MenuItem,{startIcon:e.jsx(E.Icon,{name:"Bookmark"}),onClick:()=>r(c),endIcon:e.jsx(H.Button,{variant:"link",tone:"error",size:"sm",iconLeft:e.jsx(E.Icon,{name:"Trash2"}),"aria-label":`Delete ${c.name}`,onClick:a=>{a.stopPropagation(),n(c.id)}}),children:c.name},c.id))})]})}),e.jsx(T.MenuFooter,{children:e.jsxs(x.Box,{direction:"row",gap:"xs",children:[e.jsx(x.Box,{direction:"column",style:{flex:"1 0 0",minWidth:0},children:e.jsx(dt.Input,{size:"sm",fullWidth:!0,placeholder:"Save current view as…",value:o,onChange:c=>i(c.target.value),onKeyDown:c=>{c.key==="Enter"&&l()}})}),e.jsx(H.Button,{variant:"primary",tone:"brand",size:"sm",disabled:!o.trim(),onClick:l,children:"Save"})]})})]})]})},Ci=({isOpen:t,onClose:r,configs:n,activeKeys:s,configByKey:o,hasActiveFilter:i,onToggle:l,onReset:c,getValue:a,setValue:u,clearValue:f,removeFilter:g})=>{const m=s.length;return e.jsx(Gt.Drawer,{position:"bottom",isShow:t,onHide:r,children:e.jsxs(x.Box,{direction:"column",customMaxHeight:"85vh",style:{minHeight:280},children:[e.jsxs(x.Box,{direction:"row",display:"flex",align:"center",justify:"space-between",paddingInline:"md",paddingBlock:"sm",style:{borderBottom:"1px solid var(--sa-border-subtle, rgba(11, 18, 14, 0.14))"},children:[e.jsxs(x.Box,{direction:"row",display:"flex",align:"center",gap:"xs",children:[e.jsx(v.Text,{fontWeight:"semibold",color:"primary",children:"Filter"}),m>0&&e.jsxs(v.Text,{fontSize:"sm",color:"subtle",children:["(",m,")"]})]}),e.jsx(H.Button,{variant:"link",tone:"neutral",size:"sm",iconLeft:e.jsx(E.Icon,{name:"Cross"}),"aria-label":"Close filter",onClick:r})]}),e.jsxs(x.Box,{direction:"column",gap:"lg",padding:"md",overflow:"overflow-y-auto",style:{flex:"1 1 auto",minHeight:0},children:[m>0&&e.jsxs(x.Box,{direction:"column",gap:"sm",children:[e.jsx(v.Text,{fontSize:"xs",fontWeight:"medium",color:"subtlest",children:"Filter aktif"}),e.jsx(x.Box,{direction:"row",display:"flex",wrap:"wrap",gap:"sm",align:"center",children:e.jsx(vo,{activeKeys:s,configByKey:o,getValue:a,setValue:u,clearValue:f,removeFilter:g})})]}),n.length>0&&e.jsxs(x.Box,{direction:"column",gap:"sm",children:[e.jsx(v.Text,{fontSize:"xs",fontWeight:"medium",color:"subtlest",children:"Tambah filter"}),e.jsx(x.Box,{direction:"column",children:n.map(p=>{const S=s.includes(p.key),b=!!p.locked;return e.jsxs(x.Box,{direction:"row",display:"flex",align:"center",justify:"space-between",gap:"sm",paddingBlock:"sm",style:{opacity:b?.5:1,borderTop:"1px solid var(--sa-border-subtle, rgba(11, 18, 14, 0.08))"},children:[e.jsxs(x.Box,{direction:"row",display:"flex",align:"center",gap:"sm",style:{minWidth:0},children:[p.icon&&e.jsx(x.Box,{direction:"column",align:"center",color:"icon-subtle",style:{display:"inline-flex"},children:p.icon}),e.jsx(v.Text,{fontSize:"sm",color:"primary",truncate:!0,children:p.label})]}),e.jsx(vt.Toggle,{size:"sm",checked:S||b,disabled:b,onChange:()=>l(p.key),"aria-label":`Toggle ${p.label}`})]},p.key)})})]})]}),e.jsxs(x.Box,{direction:"row",display:"flex",gap:"sm",paddingInline:"md",paddingBlock:"sm",style:{borderTop:"1px solid var(--sa-border-subtle, rgba(11, 18, 14, 0.14))"},children:[e.jsx(x.Box,{direction:"column",style:{flex:"1 1 0"},children:e.jsx(H.Button,{variant:"outline",tone:"neutral",size:"md",fullWidth:!0,disabled:!i,onClick:c,children:"Reset"})}),e.jsx(x.Box,{direction:"column",style:{flex:"1 1 0"},children:e.jsx(H.Button,{variant:"primary",tone:"brand",size:"md",fullWidth:!0,onClick:r,children:"Selesai"})})]})]})})},wi=t=>`${t} Rows`,Di=({perPageKey:t,pageKey:r,pageSizeOptions:n,defaultPerPage:s=10,showPageSize:o})=>{const{searchQueries:i,setSearchParams:l,searchParams:c}=Ve(),a=c.get(t),u=a?Number(a):s,f=g=>{l({...i,[t]:g,[r]:"1"})};return o?e.jsxs(T.Menu,{position:"bottom-right",children:[e.jsx(T.MenuButton,{children:e.jsx(H.Button,{variant:"outline",tone:"neutral",size:"sm",iconLeft:e.jsx(E.Icon,{name:"MenuVertical",size:"sm"}),"aria-label":"More options"})}),e.jsx(T.MenuLists,{children:e.jsxs(T.MenuBody,{style:{minWidth:200},children:[e.jsx(x.Box,{paddingInline:"sm",paddingBlock:"xs",children:e.jsx(v.Text,{fontSize:"xs",fontWeight:"medium",color:"subtlest",children:"Rows per page"})}),n.map(g=>e.jsx(T.MenuItem,{selected:g===u,endIcon:g===u?e.jsx(E.Icon,{name:"Check"}):void 0,onClick:()=>f(String(g)),children:wi(g)},g))]})})]}):null},Si=t=>{var Oe;const{withPadding:r,configs:n,activeKeys:s,configByKey:o,hasActiveFilter:i,toggleFilter:l,removeFilter:c,getValue:a,setValue:u,clearValue:f,onReset:g,searchable:m,searchKey:p,filterKey:S,pageKey:b,searchPlaceholder:I,searchShortcut:B,searchCollapsible:F,pagination:w,perPageKey:D,pageSizeOptions:A,defaultPerPage:O,showPagination:C,showResultCount:R,showPageSize:L,hasColumns:U,orderedColumns:J,allVisible:N,onToggleVisibility:_,onReorder:X,onSetAllHidden:te,showSavedViews:V,savedViews:z,onApplyView:P,onDeleteView:se,onSaveView:ye,leadingActions:Se}=t,[xe,pe]=d.useState(!1),{searchQueries:je,setSearchParams:be}=Ve(),Te=(w==null?void 0:w.rangeStart)??(((w==null?void 0:w.currentPage)||0)>1?(((w==null?void 0:w.currentPage)||0)-1)*((w==null?void 0:w.perPage)||0)+1:1),ke=(w==null?void 0:w.rangeEnd)??((w==null?void 0:w.totalCurrentPage)!==(w==null?void 0:w.perPage)?w==null?void 0:w.totalData:((w==null?void 0:w.currentPage)||1)*((w==null?void 0:w.totalCurrentPage)||0)),He=Ne=>{be({...je,[b]:String(Ne)})},Y=R||C&&!!(w!=null&&w.totalPage),he=()=>{g(),pe(!1)};return e.jsxs(x.Box,{direction:"column",gap:"sm",fullWidth:!0,paddingTop:r?"sm":void 0,paddingBottom:r?"sm":void 0,paddingLeft:r?"md":void 0,paddingRight:r?"md":void 0,role:"toolbar","aria-label":"Filter bar",children:[e.jsxs(x.Box,{direction:"row",display:"flex",align:"center",wrap:"wrap",gap:"sm",fullWidth:!0,overflow:"overflow-auto",children:[m&&e.jsx(Co,{searchKey:p,filterKey:S,pageKey:b,placeholder:I,shortcut:B,collapsible:F}),e.jsx(H.Button,{variant:i?"secondary":"outline",tone:"neutral",size:"sm",iconLeft:e.jsx(E.Icon,{name:"FilterHorizontal"}),onClick:()=>pe(!0),"aria-label":"Open filters",children:i?`Filter: ${s.length}`:null}),e.jsxs(x.Box,{direction:"row",display:"flex",align:"center",gap:"sm",style:{marginLeft:"auto"},children:[Se,V&&e.jsx(Do,{views:z,onApply:P,onDelete:se,onSave:ye}),U&&e.jsx(wo,{columns:J,allVisible:N,onToggle:_,onReorder:X,onSetAllHidden:te}),e.jsx(Di,{perPageKey:D,pageKey:b,pageSizeOptions:A,defaultPerPage:O,showPageSize:L})]})]}),Y&&e.jsxs(x.Box,{direction:"row",display:"flex",align:"center",justify:"space-between",gap:"sm",fullWidth:!0,children:[R?e.jsx(v.Text,{fontSize:"sm",fontWeight:"medium",color:"primary",truncate:!0,children:`${Te}-${ke} of ${((Oe=w==null?void 0:w.totalData)==null?void 0:Oe.toLocaleString())||0}`}):e.jsx(x.Box,{direction:"column"}),C&&!!(w!=null&&w.totalPage)&&e.jsx(Mt.Pagination,{size:"xs",variant:"neutral",siblingCount:0,currentPage:w!=null&&w.currentPage?Number(w.currentPage):1,totalPages:Number(w.totalPage),onPageChange:He})]}),e.jsx(Ci,{isOpen:xe,onClose:()=>pe(!1),configs:n,activeKeys:s,configByKey:o,hasActiveFilter:i,onToggle:l,onReset:he,getValue:a,setValue:u,clearValue:f,removeFilter:c})]})},ki=({withPadding:t=!1,filterConfigs:r=[],filterKey:n="filter",activeFilterKey:s="filters",pageKey:o="page",perPageKey:i="perPage",pageSizeOptions:l=[25,50,100],defaultPerPage:c,showPagination:a=!0,showResultCount:u=!0,showPageSize:f=!0,searchable:g=!1,searchKey:m="q",searchPlaceholder:p="Search",searchShortcut:S="/",searchPosition:b="right",searchCollapsible:I=!0,pagination:B,columns:F=[],onColumnsChange:w,columnsState:D,scopeId:A,savedViews:O,persistLastState:C=!0,persistSearch:R=!0,storage:L=Ur,onReset:U,leadingActions:J})=>{const N=A??(O==null?void 0:O.scopeId),{activeKeys:_,configByKey:X,hasActiveFilter:te,toggleFilter:V,removeFilter:z,getValue:P,setValue:se,clearValue:ye,clearAll:Se}=Qr({configs:r,filterKey:n,activeFilterKey:s,pageKey:o,searchKey:m}),xe=Ys({columns:F,scopeId:N,storage:L,onColumnsChange:w,value:D}),pe=Xs({scopeId:N,storage:L,snapshotKeys:[s,n,i],pageKey:o,getColumns:()=>xe.state,applyColumns:xe.applyState}),je=Ks({scopeId:N,storage:L,snapshotKeys:[s,n,o],enabled:C,filterKey:n,searchKey:m,persistSearch:R}),be=ei({scopeId:N,storage:L,perPageKey:i,pageSizeOptions:l,enabled:C});ri({enabled:C&&!!N,snapshotKeys:[s,n,o],perPageKey:i,readSnapshot:je.read,readPerPage:be.read});const Te=c??l[0]??25,ke=!!(O!=null&&O.enabled)&&pe.enabled,He=()=>{Se(),je.clear(),U==null||U()},Y=Ce.useMediaQuery("md"),he=g?e.jsx(Co,{searchKey:m,filterKey:n,pageKey:o,placeholder:p,shortcut:S,collapsible:I}):null;return Y?e.jsxs(x.Box,{display:"flex",direction:"row",align:"center",gap:"sm",wrap:"wrap",fullWidth:!0,paddingTop:t?"sm":void 0,paddingBottom:t?"sm":void 0,paddingLeft:t?"md":void 0,paddingRight:t?"md":void 0,role:"toolbar","aria-label":"Filter bar",children:[e.jsxs(x.Box,{direction:"row",display:"flex",align:"center",gap:"sm",style:{flex:"1 1 0",minWidth:0},children:[e.jsx(ni,{configs:r,activeKeys:_,onToggle:V,hasActiveFilter:te,onReset:He}),b==="left"&&he,e.jsxs(x.Box,{direction:"row",display:"flex",align:"center",gap:"sm",overflow:"overflow-x-auto",style:{flex:"1 1 0",minWidth:0},children:[e.jsx(vo,{activeKeys:_,configByKey:X,getValue:P,setValue:se,clearValue:ye,removeFilter:z}),te&&e.jsx(H.Button,{variant:"link",tone:"brand",size:"sm",onClick:He,children:"Reset"})]})]}),e.jsxs(x.Box,{direction:"row",display:"flex",align:"center",gap:"sm",children:[J,e.jsx(ji,{pagination:B,pageKey:o,perPageKey:i,pageSizeOptions:l,defaultPerPage:Te,showPagination:a,showResultCount:u,showPageSize:f}),b==="right"&&he,ke&&e.jsx(Do,{views:pe.views,onApply:pe.applyView,onDelete:pe.deleteView,onSave:pe.saveView}),F.length>0&&e.jsx(wo,{columns:xe.orderedColumns,allVisible:xe.allVisible,onToggle:xe.toggleVisibility,onReorder:xe.reorder,onSetAllHidden:xe.setAllHidden})]})]}):e.jsx(Si,{withPadding:t,configs:r,activeKeys:_,configByKey:X,hasActiveFilter:te,toggleFilter:V,removeFilter:z,getValue:P,setValue:se,clearValue:ye,onReset:He,searchable:g,searchKey:m,filterKey:n,pageKey:o,searchPlaceholder:p,searchShortcut:S,searchCollapsible:I,pagination:B,perPageKey:i,pageSizeOptions:l,defaultPerPage:Te,showPagination:a,showResultCount:u,showPageSize:f,hasColumns:F.length>0,orderedColumns:xe.orderedColumns,allVisible:xe.allVisible,onToggleVisibility:xe.toggleVisibility,onReorder:xe.reorder,onSetAllHidden:xe.setAllHidden,showSavedViews:ke,savedViews:pe.views,onApplyView:pe.applyView,onDeleteView:pe.deleteView,onSaveView:pe.saveView,leadingActions:J})},Bi=t=>{if(!Array.isArray(t)||t.length===0)return;const r=t[0];return(r==null?void 0:r.value)!=null?String(r.value):void 0},Ei=t=>{if(!Array.isArray(t)||t.length===0)return;const r=t.map(n=>(n==null?void 0:n.value)!=null?String(n.value):null).filter(n=>n!=null);return r.length?r:void 0},Fi=(t,r)=>{switch(t.type){case"dropdown":case"radio":return Bi(r);case"dropdown-multiple":case"checkbox-multiple":return Ei(r);case"date":return r instanceof Date?r.toISOString():void 0;case"date-compact":return r;default:return}},Rn=(t,r)=>{if(t==null||t==="")return r;const n=Number(t);return Number.isFinite(n)&&n>0?n:r},Mi=t=>{const{filterConfigs:r,filterKey:n="filter",activeFilterKey:s="filters",pageKey:o="page",perPageKey:i="perPage",searchKey:l="q",defaultPage:c=1,defaultPerPage:a=10,paramKeys:u,serialize:f}=t,{activeKeys:g,configByKey:m,hasActiveFilter:p,getValue:S}=Qr({configs:r,filterKey:n,activeFilterKey:s,pageKey:o,searchKey:l}),{searchParams:b}=Ve(),I=b.toString();return d.useMemo(()=>{const F={},w={},D=Rn(b.get(o),c),A=Rn(b.get(i),a);F[(u==null?void 0:u.page)??"page"]=D,F[(u==null?void 0:u.perPage)??"perPage"]=A;const O=Xt(l,b,n)||"";O&&(F[(u==null?void 0:u.search)??"search"]=O);let C=!1;for(const R of g){const L=m[R];if(!L)continue;const U=S(L);w[R]=U;const J=f==null?void 0:f[R],N=J?J(U):Fi(L,U);if(N==null||Array.isArray(N)&&N.length===0)continue;const _=(u==null?void 0:u[R])??R;F[_]=N,C=!0}return{params:F,raw:w,hasActiveFilter:p||!!O||C}},[I,g.join("|"),n,s,o,i,l,c,a,u,f,m])},Ii=["dropdown","dropdown-multiple","checkbox-multiple","radio"],Li=({filterConfigs:t,filterKey:r,activeFilterKey:n,pageKey:s,searchKey:o})=>{const{configByKey:i,getValue:l,setValue:c,removeFilter:a,clearAll:u,hasActiveFilter:f}=Qr({configs:t,filterKey:r,activeFilterKey:n,pageKey:s,searchKey:o}),g=(B,F)=>{var D;const w=B.options;return((D=w==null?void 0:w.find(A=>A.value===F))==null?void 0:D.label)??F},m=d.useCallback(B=>{const F=i[B];if(!F)return[];const w=l(F);return Array.isArray(w)?w.map(D=>String(D.value)):[]},[i,l]),p=d.useCallback((B,F)=>{const w=i[B];if(!w||!Ii.includes(w.type))return;const D=Array.isArray(F)?F:[F];if(D.length===0){a(B);return}c(w,D.map(A=>({label:g(w,A),value:A})))},[i,c,a]),S=d.useCallback((B,F)=>{const w=m(B);p(B,w.includes(F)?w.filter(D=>D!==F):[...w,F])},[m,p]),b=d.useCallback((B,F)=>m(B).includes(F),[m]),I=d.useCallback(B=>a(B),[a]);return{set:p,toggle:S,clear:I,clearAll:u,isActive:b,values:m,hasActiveFilter:f}},Ti=(t,r)=>{if(!t)return{};const{fromKey:n,toKey:s,opKey:o}=r,i={};switch(t.op){case"is":case"is-before":case"is-after":case"is-on-or-before":case"is-on-or-after":return t.date&&(i[n]=new Date(t.date).toISOString()),o&&(i[o]=t.op),i;case"is-between":return t.from&&(i[n]=new Date(t.from).toISOString()),t.to&&(i[s]=new Date(t.to).toISOString()),i;case"is-relative-to-today":{if(!t.relative)return i;const{from:l,to:c}=po(t.relative);return i[n]=l.toISOString(),i[s]=c.toISOString(),i}case"is-empty":case"is-not-empty":return o&&(i[o]=t.op==="is-empty"?"empty":"not-empty"),i;default:return i}},So=({children:t,borderRadius:r,height:n})=>{const s=d.useRef(null),[o,i]=d.useState("100vh");return d.useEffect(()=>{if(n)return;const l=()=>{if(s.current){const c=s.current.getBoundingClientRect().top;i(`calc(100vh - ${c}px)`)}};return l(),window.addEventListener("resize",l),()=>window.removeEventListener("resize",l)},[n]),e.jsx(x.Box,{ref:s,fullWidth:!0,borderStyle:"border-solid",borderWidth:"border",borderColor:"border-base",borderRadius:r||"rounded-xs",style:{height:n??o,display:"flex",flexDirection:"column"},children:t})},ko=({action:t,rightContent:r,leftContent:n,headerSlot:s,advanceFilter:o,showFilter:i=!0})=>{const l=Ce.useMediaQuery("md"),c=i?e.jsx(yo,{...o}):null,a=()=>t?d.isValidElement(t)?t:e.jsx(x.Box,{style:{display:"flex",flexDirection:l?"row":"column",gap:"8px",width:l?"auto":"100%",textWrap:"nowrap"},children:t.map(({title:u,icon:f,buttonProps:g,onClick:m},p)=>!u&&!f?null:e.jsx(H.Button,{fullWidth:!l,iconLeft:f?e.jsx(E.Icon,{name:f}):void 0,onClick:m,...g,children:u},`action-${p}`))}):null;return e.jsx(x.Box,{style:{display:"flex",width:"100%",justifyContent:"space-between",alignItems:"center",paddingLeft:"8px",paddingRight:"8px",paddingTop:"8px",paddingBottom:"8px",borderBottom:"1px solid var(--sa-border-subtle, #0b120e24)",flexShrink:0,position:"relative",zIndex:10,flexDirection:l?"row":"column-reverse",gap:"16px"},children:s?s({filter:c}):e.jsxs(e.Fragment,{children:[e.jsxs(x.Box,{style:{display:"flex",gap:"8px",flexDirection:"row",alignItems:"center",flex:1,minWidth:0},children:[c,n]}),e.jsxs(x.Box,{style:{display:"flex",gap:"8px",flexDirection:"row",alignItems:"center",flexShrink:0},children:[r,a()]})]})})},Oi=({totalData:t,withMarginBottom:r=!0,withMarginTop:n=!0})=>e.jsxs(x.Box,{style:{display:"flex",gap:"4px",flexDirection:"row",alignItems:"center",marginBottom:r?"16px":void 0,marginTop:n?"16px":void 0},children:[e.jsxs(Xe.Body1,{props:{color:"gray-500"},children:["Total data:"," "]}),e.jsx(Xe.Body1,{children:t||0})]}),Bo=({pagination:t,pageKey:r="page",perPageKey:n="perPage",defaultPerPage:s=10,showPagination:o=!0,totalData:i})=>{const{searchQueries:l,setSearchParams:c,searchParams:a}=Ve(),u=a.get(n),f=S=>{c({...l,[r]:String(S)})},g=S=>{c({...l,[n]:S,[r]:"1"})},m=(t==null?void 0:t.rangeStart)??(((t==null?void 0:t.currentPage)||0)>1?(((t==null?void 0:t.currentPage)||0)-1)*((t==null?void 0:t.perPage)||0)+1:1),p=(t==null?void 0:t.rangeEnd)??((t==null?void 0:t.totalCurrentPage)!==(t==null?void 0:t.perPage)?t==null?void 0:t.totalData:((t==null?void 0:t.currentPage)||1)*((t==null?void 0:t.totalCurrentPage)||0));return e.jsx(x.Box,{style:{display:"flex",width:"100%",flexDirection:"row",justifyContent:"space-between",alignItems:"center",paddingLeft:"16px",paddingRight:"16px",paddingTop:"8px",paddingBottom:"8px",borderTop:"1px solid var(--sa-border-subtle, #0b120e24)",flexShrink:0},children:o?e.jsxs(e.Fragment,{children:[e.jsxs(x.Box,{style:{display:"flex",flexDirection:"row",gap:"8px",alignItems:"center",textWrap:"nowrap"},children:[e.jsx(v.Text,{children:"Rows Per Page: "}),e.jsx(jt.Dropdown,{dropdownLists:[{label:"5",value:"5"},{label:"10",value:"10"},{label:"25",value:"25"},{label:"50",value:"50"},{label:"100",value:"100"}],onChange:S=>{g(S[0].value)},value:u?[{label:`${u} per row`,value:u}]:[{label:`${s} per row`,value:`${s}`}],defaultValue:u?[{label:`${u} per row`,value:u}]:[{label:`${s} per row`,value:`${s}`}]}),e.jsx(v.Text,{children:`${m}-${p} of ${(t==null?void 0:t.totalData)||0}`})]}),e.jsx(Mt.Pagination,{currentPage:t!=null&&t.currentPage?Number(t==null?void 0:t.currentPage):1,totalPages:t!=null&&t.totalPage?Number(t==null?void 0:t.totalPage):1,onPageChange:f})]}):e.jsx(Oi,{totalData:i,withMarginBottom:!1,withMarginTop:!1})})},Eo=({filter:t,columnTitle:r})=>{const[n,s]=d.useState(!1),o=d.useRef(null),i=d.useRef(null),l=d.useRef(null),[c,a]=d.useState(""),[u,f]=d.useState({top:0,left:0}),g=t.selectedValues,m=d.useMemo(()=>c?t.options.filter(b=>b.label.toLowerCase().includes(c.toLowerCase())):t.options,[t.options,c]);d.useEffect(()=>{if(n&&i.current){const b=i.current.getBoundingClientRect(),I=280,B={top:b.bottom+8};t.position==="left"||b.left+I>window.innerWidth?B.right=window.innerWidth-b.right:B.left=b.left,f(B)}},[n,t.position]),d.useEffect(()=>{n&&l.current?setTimeout(()=>{var b;return(b=l.current)==null?void 0:b.focus()},50):a("")},[n]),d.useEffect(()=>{const b=I=>{o.current&&!o.current.contains(I.target)&&i.current&&!i.current.contains(I.target)&&s(!1)};return n&&document.addEventListener("mousedown",b),()=>document.removeEventListener("mousedown",b)},[n]);const p=b=>{const I=g.includes(b)?g.filter(B=>B!==b):[...g,b];t.onFilterChange(I)},S=()=>t.onFilterChange([]);return e.jsxs(x.Box,{direction:"column",style:{position:"relative"},children:[e.jsx(x.Box,{ref:i,style:{display:"flex",flexDirection:"row",alignItems:"center",cursor:"pointer"},onClick:b=>{var I;b.stopPropagation(),n||(I=t.onOpen)==null||I.call(t),s(B=>!B)},children:e.jsx(E.Icon,{name:n?"ChevronUp":"ChevronDown",size:"sm",style:{color:g.length>0?"var(--sa-color-brand-500, #1a4fa0)":"var(--sa-text-subtle, #8c8f97)"}})}),n&&e.jsxs(x.Box,{ref:o,style:{position:"fixed",top:`${u.top}px`,...u.left!==void 0?{left:`${u.left}px`}:{right:`${u.right}px`},backgroundColor:"white",borderRadius:"4px",minWidth:"280px",maxHeight:"400px",display:"flex",flexDirection:"column",zIndex:9999,animation:"fadeInDropdown 0.15s ease-out",border:"1px solid var(--sa-border-subtle, #0b120e24)"},children:[e.jsxs(x.Box,{style:{display:"flex",flexDirection:"row",justifyContent:"space-between",alignItems:"center",paddingTop:"12px",paddingBottom:"12px",paddingLeft:"16px",paddingRight:"16px",borderBottom:"1px solid var(--sa-border-subtle, #0b120e24)"},children:[e.jsxs(v.Text,{fontSize:"sm",fontWeight:"semibold",color:"gray-700",children:["Filter ",r]}),g.length>0&&e.jsx(x.Box,{direction:"column",style:{cursor:"pointer"},children:e.jsx(v.Text,{fontSize:"xs",color:"primary",fontWeight:"semibold",onClick:b=>{b.stopPropagation(),S()},children:"CLEAR"})})]}),!t.hideSearch&&e.jsx(x.Box,{direction:"column",style:{paddingLeft:"16px",paddingRight:"16px",paddingTop:"8px",paddingBottom:"8px"},children:e.jsx(dt.Input,{ref:l,placeholder:`Search ${r.toLowerCase()}...`,leftIcon:e.jsx(E.Icon,{name:"Search",size:"sm"}),value:c,onChange:b=>a(b.target.value),style:{fontSize:"14px"}})}),e.jsx(x.Box,{direction:"column",className:"ts-filter-dropdown-options",style:{overflowY:"auto",maxHeight:"250px",paddingLeft:"8px",paddingRight:"8px"},children:t.isLoadingOptions?e.jsxs(x.Box,{style:{paddingTop:"40px",paddingBottom:"40px",display:"flex",alignItems:"center",justifyContent:"center",flexDirection:"column"},children:[e.jsx(E.Icon,{name:"Loading",size:"lg",style:{color:"var(--sa-background-brand, #04254f)",animation:"spin 1s linear infinite"}}),e.jsx(v.Text,{fontSize:"sm",color:"gray-500",style:{textAlign:"center",marginTop:"8px"},children:"Loading options..."})]}):m.length>0?e.jsx(x.Box,{direction:"column",style:{gap:"2px",paddingTop:"4px",paddingBottom:"4px"},children:m.map(b=>e.jsxs(x.Box,{style:{display:"flex",flexDirection:"row",alignItems:"center",gap:"8px",paddingTop:"8px",paddingBottom:"8px",paddingLeft:"8px",paddingRight:"8px",cursor:"pointer",borderRadius:"8px",transition:"all 0.2s ease",backgroundColor:g.includes(b.value)?"var(--sa-color-brand-50, #e6edf6)":"transparent"},onClick:I=>{I.stopPropagation(),p(b.value)},onMouseEnter:I=>{g.includes(b.value)||(I.currentTarget.style.backgroundColor="var(--sa-background-primary, #ffffff)"),I.currentTarget.style.transform="translateX(2px)"},onMouseLeave:I=>{I.currentTarget.style.backgroundColor=g.includes(b.value)?"var(--sa-color-brand-50, #e6edf6)":"transparent",I.currentTarget.style.transform="translateX(0)"},children:[e.jsx(nt.Checkbox,{checked:g.includes(b.value),onChange:()=>{}}),e.jsx(v.Text,{fontSize:"sm",fontWeight:g.includes(b.value)?"medium":"normal",color:g.includes(b.value)?"primary":"gray-700",children:b.label})]},b.value))}):e.jsxs(x.Box,{style:{paddingTop:"40px",paddingBottom:"40px",display:"flex",alignItems:"center",justifyContent:"center",flexDirection:"column"},children:[e.jsx(E.Icon,{name:"Search",size:"lg",style:{color:"var(--sa-text-subtle, #8c8f97)"}}),e.jsx(v.Text,{fontSize:"sm",color:"gray-500",style:{textAlign:"center",marginTop:"8px"},children:"No results found"})]})}),g.length>0&&e.jsx(x.Box,{direction:"column",style:{paddingTop:"8px",paddingBottom:"8px",paddingLeft:"16px",paddingRight:"16px",borderTop:"1px solid var(--sa-border-subtle, #0b120e24)",backgroundColor:"var(--sa-color-brand-50, #e6edf6)",marginTop:"auto"},children:e.jsxs(x.Box,{style:{display:"flex",flexDirection:"row",alignItems:"center",gap:"4px"},children:[e.jsx(x.Box,{direction:"column",style:{backgroundColor:"var(--sa-background-brand, #04254f)",borderRadius:"12px",padding:"2px 8px",fontSize:"11px",fontWeight:600,color:"white"},children:g.length}),e.jsxs(v.Text,{fontSize:"xs",color:"primary",fontWeight:"medium",children:["item",g.length>1?"s":""," selected"]})]})})]})]})},Ri=({direction:t})=>{const r="var(--sa-text-primary, #292a2e)",n="var(--sa-text-subtle, #8c8f97)",s=t==="asc"?r:n,o=t==="desc"?r:n,i=t==="asc"?1:.45,l=t==="desc"?1:.45;return e.jsxs("span",{style:{display:"inline-flex",flexDirection:"column",alignItems:"center",justifyContent:"center",flexShrink:0,lineHeight:0},"aria-hidden":!0,children:[e.jsx("svg",{width:"8",height:"5",viewBox:"0 0 8 5",style:{color:s,opacity:i,marginBottom:1},children:e.jsx("path",{d:"M4 0 L8 5 L0 5 Z",fill:"currentColor"})}),e.jsx("svg",{width:"8",height:"5",viewBox:"0 0 8 5",style:{color:o,opacity:l},children:e.jsx("path",{d:"M0 0 L8 0 L4 5 Z",fill:"currentColor"})})]})},Ai=({frozen:t})=>e.jsxs("svg",{width:"11",height:"11",viewBox:"0 0 24 24",fill:t?"currentColor":"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("rect",{x:"3",y:"11",width:"18",height:"11",rx:"2",ry:"2"}),e.jsx("path",{d:t?"M7 11V7a5 5 0 0 1 10 0v4":"M7 11V7a5 5 0 0 1 9.9-1"})]}),Cr="var(--sa-background-primary, #ffffff)",An="var(--sa-background-primary-inverse, #f8f8f8)",Fo=({columns:t,records:r,handleDetail:n,handleUpdate:s,handleDelete:o,isLoading:i,visibleHandleDelete:l,visibleHandleUpdate:c,visibleHandleDetail:a,showHeadBorder:u=!1,scrollParentRef:f,frozenCount:g=0,onFrozenCountChange:m,customActions:p,actionsOrder:S=["detail","update","delete","custom"],customEmptyState:b,enableColumnResize:I=!1,defaultColumnWidths:B,onColumnWidthsChange:F,defaultMinColumnWidth:w=60,sort:D,defaultSort:A,onSortChange:O,showActionDivider:C=!1})=>{const R=D!==void 0,[L,U]=d.useState(A??null),J=R?D??null:L,N=W=>{if(W.sortKey)return W.sortKey;if(typeof W.accessor=="string")return W.accessor},_=W=>{const $=N(W);if(!$)return;let Q;!J||J.key!==$?Q={key:$,direction:"asc"}:J.direction==="asc"?Q={key:$,direction:"desc"}:Q=null,R||U(Q),O==null||O(Q)},te=[n,s,o].filter(W=>W!==void 0).length,V=!!p,z=!!n||!!s||!!o||V,P="var(--sa-border-subtle, #0b120e24)",se=`1px solid ${P}`,ye=`inset 1px 0 0 ${P}`,Se=`inset -1px 0 0 ${P}`,xe=te===3?V?"178px":"140px":te===2?V?"140px":"102px":te===1?V?"112px":"74px":V?"74px":"",pe=(W,$)=>{if(!$)return W;if(typeof $=="function")return $(W);if(typeof $=="string")return W[$]},[je,be]=d.useState(!1);d.useEffect(()=>{if(!(f!=null&&f.current))return;const W=f.current;be(W.scrollHeight>W.clientHeight)},[r,f]);const Te=d.useRef(null),[ke,He]=d.useState([]),[Y,he]=d.useState(()=>B??{}),Oe=d.useRef(null);d.useLayoutEffect(()=>{if(!g||!Te.current){He([]);return}const W=Array.from(Te.current.querySelectorAll("thead tr th")),$=[];let Q=0;W.forEach((de,ie)=>{$[ie]=Q,ie<g&&(Q+=de.offsetWidth)}),He($)},[g,t,r,Y]);const Ne=W=>{m&&m(W<g?W:W+1)},ae=(W,$)=>{const Q=Y[W];if(Q!==void 0){const de=`${Q}px`;return{width:de,minWidth:de,maxWidth:de}}return $?{width:$}:{}},_e=W=>I&&(W.resizable??!0),tt=(W,$)=>{W.preventDefault(),W.stopPropagation();const Q=W.currentTarget.closest("th");if(!Q)return;const de=Math.round(Q.getBoundingClientRect().width);Oe.current={colIndex:$,startX:W.clientX,startWidth:de};const ie=document.body.style.userSelect,Be=document.body.style.cursor;document.body.style.userSelect="none",document.body.style.cursor="col-resize";const Re=qe=>{var Ze;const Me=Oe.current;if(!Me)return;const Qe=((Ze=t[Me.colIndex])==null?void 0:Ze.minWidth)??w,we=Math.max(Qe,Me.startWidth+(qe.clientX-Me.startX));he(rt=>rt[Me.colIndex]===we?rt:{...rt,[Me.colIndex]:we})},$e=()=>{document.removeEventListener("mousemove",Re),document.removeEventListener("mouseup",$e),document.body.style.userSelect=ie,document.body.style.cursor=Be,Oe.current=null,F&&he(qe=>(F(qe),qe))};document.addEventListener("mousemove",Re),document.addEventListener("mouseup",$e)};return e.jsx("div",{ref:Te,children:e.jsxs(G.Table,{fullWidth:!0,children:[e.jsx(G.Thead,{style:{height:"40px",whiteSpace:"nowrap"},children:e.jsxs(G.Tr,{children:[t.map((W,$)=>{var ut,ct;const Q=g>0&&$<g,de=ke[$]??0,ie=_e(W),Re=$===t.length-1&&z&&C,$e=N(W),qe=!!W.sortable&&!!$e,Me=qe&&(J==null?void 0:J.key)===$e?J.direction:null,Qe=W.title||((ut=W.accessor)==null?void 0:ut.toString())||"",we=(ct=W.headerTooltip)!=null&&ct.showIcon?e.jsx(E.Icon,{name:"InfoCircle",size:"xs",style:{flexShrink:0,color:"var(--sa-icon-subtle, #8c8f97)",opacity:.75}}):null,Ze=e.jsx("span",{style:{flex:1,minWidth:0,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:Qe}),rt=qe?e.jsxs("button",{type:"button",onClick:()=>_(W),title:Me==="asc"?"Sorted ascending — click to sort descending":Me==="desc"?"Sorted descending — click to clear":"Click to sort ascending",style:{flex:1,minWidth:0,display:"flex",alignItems:"center",gap:4,background:"none",border:"none",padding:0,margin:0,font:"inherit",color:"inherit",cursor:"pointer",textAlign:W.textAlign==="text-right"?"right":W.textAlign==="text-center"?"center":"left"},children:[Ze,we,e.jsx(Ri,{direction:Me})]}):e.jsxs("span",{style:{flex:1,minWidth:0,display:"flex",alignItems:"center",gap:4},children:[Ze,we]});return e.jsxs(G.Th,{style:{position:"sticky",top:0,left:Q?de:void 0,zIndex:Q?4:2,paddingLeft:$===0?"12px":"",borderRight:u&&!Re&&!Q?se:void 0,borderBottom:u?se:void 0,boxShadow:u&&Q?Se:void 0,backgroundColor:"var(--sa-background-primary-inverse, #f8f8f8)",textAlign:W.textAlign==="text-right"?"right":W.textAlign==="text-center"?"center":"left",...ae($,W.width)},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"4px",justifyContent:"space-between",minWidth:0},children:[W.headerTooltip?e.jsx(Fe.Tooltip,{label:W.headerTooltip.content,position:"bottom",children:rt}):rt,W.filter&&e.jsx(Eo,{filter:W.filter,columnTitle:W.title}),m&&e.jsx("button",{onClick:()=>Ne($),title:Q?"Unfreeze column":"Freeze column",style:{background:"none",border:"none",cursor:"pointer",padding:"2px",display:"flex",alignItems:"center",flexShrink:0,color:Q?"var(--sa-background-brand, #04254f)":"var(--sa-text-subtle, #8c8f97)",opacity:Q?1:.45,transition:"opacity 0.15s"},children:e.jsx(Ai,{frozen:Q})})]}),ie&&e.jsx("div",{onMouseDown:at=>tt(at,$),onClick:at=>at.stopPropagation(),role:"separator","aria-orientation":"vertical",title:"Drag to resize",style:{position:"absolute",top:0,right:-3,width:6,height:"100%",cursor:"col-resize",userSelect:"none",zIndex:5,touchAction:"none"}})]},`table-head-${$}`)}),z?e.jsx(G.Th,{style:{backgroundColor:"var(--sa-background-primary-inverse, #f8f8f8)",position:"sticky",top:0,right:0,zIndex:3,borderBottom:u?se:void 0,boxShadow:u&&C?ye:void 0}}):null]})}),e.jsx(G.Tbody,{children:i?e.jsx(G.Tr,{children:e.jsx(G.Td,{colSpan:t.length+1,children:e.jsxs(x.Box,{direction:"column",style:{gap:"16px"},children:[e.jsx(Ye.Skeleton,{variant:"list"}),e.jsx(Ye.Skeleton,{variant:"list"}),e.jsx(Ye.Skeleton,{variant:"list"}),e.jsx(Ye.Skeleton,{variant:"list"}),e.jsx(Ye.Skeleton,{variant:"list"})]})})}):!(r!=null&&r.length)&&b?e.jsx(G.Tr,{children:e.jsx(G.Td,{colSpan:t.length+1,children:b})}):r==null?void 0:r.map((W,$)=>e.jsxs(G.Tr,{style:{transition:"background-color 0.3s ease",padding:0,borderBottom:$===r.length-1&&je?void 0:"1px solid var(--sa-border-subtle, #0b120e24)"},onMouseEnter:Q=>{const de=Q.currentTarget;de.style.backgroundColor=An,Array.from(de.querySelectorAll("td")).forEach(ie=>{ie.style.position==="sticky"&&(ie.style.backgroundColor=An)})},onMouseLeave:Q=>{const de=Q.currentTarget;de.style.backgroundColor="",Array.from(de.querySelectorAll("td")).forEach(ie=>{ie.style.position==="sticky"&&(ie.style.backgroundColor=Cr)})},children:[t.map((Q,de)=>{const ie=Q.render?Q.render(W,$,r):pe(W,Q.accessor),Be=g>0&&de<g,Re=ke[de]??0,$e=Y[de]!==void 0,qe=Be&&de===g-1;return e.jsx(G.Td,{style:{position:Be?"sticky":void 0,left:Be?Re:void 0,zIndex:Be?1:void 0,backgroundColor:Be?Cr:void 0,transition:Be?"background-color 0.3s ease":void 0,paddingLeft:de===0?"12px":"",whiteSpace:"nowrap",overflow:$e?"hidden":void 0,borderLeft:Q.showBorderLeft?se:void 0,borderRight:Q.showBorderRight?se:void 0,boxShadow:qe?Se:void 0,textAlign:Q.textAlign==="text-right"?"right":Q.textAlign==="text-center"?"center":"left",...ae(de,Q.width)},children:typeof ie=="string"?e.jsx(v.Text,{style:{whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",textAlign:Q.textAlign==="text-right"?"right":Q.textAlign==="text-center"?"center":"left"},children:ie}):ie},`row-${$}-col-${de}`)}),z?e.jsx(G.Td,{style:{width:xe,position:"sticky",right:0,zIndex:1,backgroundColor:Cr,boxShadow:C?ye:void 0,transition:"background-color 0.3s ease"},children:e.jsx(ce.Flex,{direction:"row",align:"center",justify:"center",gap:"sm",children:S.map(Q=>{const de=$===r.length-1?"top":"bottom";return Q==="detail"&&n&&(a==null?void 0:a(W))!==!1?e.jsx(Fe.Tooltip,{label:"Detail",position:de,children:e.jsx(H.Button,{size:"xs",variant:"outline",tone:"neutral",onClick:()=>n(W.id,W),iconLeft:e.jsx(E.Icon,{name:"DocumentClean",size:"sm",style:{color:"var(--sa-text-subtle, #8c8f97)"}})})},"detail"):Q==="update"&&s&&(c==null?void 0:c(W))!==!1?e.jsx(Fe.Tooltip,{label:"Update",position:de,children:e.jsx(H.Button,{size:"xs",variant:"outline",tone:"neutral",onClick:()=>s(W),iconLeft:e.jsx(E.Icon,{name:"Edit1",size:"sm",style:{color:"var(--sa-text-subtle, #8c8f97)"}})})},"update"):Q==="delete"&&o&&(l==null?void 0:l(W))!==!1?e.jsx(Fe.Tooltip,{label:"Delete",position:de,children:e.jsx(H.Button,{size:"xs",variant:"outline",tone:"neutral",onClick:()=>o(W.id,W),iconLeft:e.jsx(E.Icon,{name:"Trash1",size:"sm",style:{color:"var(--sa-color-error-600, #c9184a)"}})})},"delete"):Q==="custom"?e.jsx(d.Fragment,{children:p==null?void 0:p(W)},"custom"):null})})}):null]},`${W}${$}`))})]})})};let Wn=!1;const Wi=({wrapperProps:t,dataTableProps:r,headerProps:n,footerProps:s})=>{var g;process.env.NODE_ENV!=="production"&&!Wn&&(Wn=!0,console.warn("[@starasia/admin] `TableSection` deprecated — pakai `<FilterBar>` + `<TableLayout>`. Lihat skill `starasia-list-page-pattern`. Akan dihapus di salah satu major berikutnya."));const o=d.useRef(null),[i,l]=d.useState((r==null?void 0:r.defaultFrozenCount)??0),c=(n==null?void 0:n.show)??!0,a=d.useRef(null),u=(g=r==null?void 0:r.pagination)==null?void 0:g.totalData;typeof u=="number"&&(a.current=u);const f=(s==null?void 0:s.showFooter)??(u===void 0?a.current!==0:u!==0);return e.jsxs(So,{...t,children:[c&&e.jsx(ko,{...n}),e.jsx(x.Box,{direction:"column",ref:o,style:{flex:1,overflowY:"auto",overflowX:"auto"},children:r?e.jsx(Fo,{...r,scrollParentRef:o,frozenCount:r!=null&&r.enableFreezeColumns?i:0,onFrozenCountChange:r!=null&&r.enableFreezeColumns?l:void 0}):null}),f&&e.jsx(Bo,{pagination:r==null?void 0:r.pagination,pageKey:r==null?void 0:r.pageKey,perPageKey:r==null?void 0:r.perPageKey,defaultPerPage:r==null?void 0:r.defaultPerPage,showPagination:r==null?void 0:r.showPagination,totalData:s==null?void 0:s.totalData})]})};function zi(t){return d.memo(t)}const Hi=zi(Wi),zn=200,wr="1px solid var(--sa-border-subtle, #0b120e24)",Pi=({sortDir:t,frozen:r})=>t==="asc"?e.jsx(E.Icon,{name:"ChevronSmallUp"}):t==="desc"?e.jsx(E.Icon,{name:"ChevronSmallDown"}):r?e.jsx(E.Icon,{name:"LockOn",size:"xs"}):e.jsx(E.Icon,{name:"Filter",size:"xs"}),Ht=({icon:t,label:r,active:n,danger:s,onClick:o})=>{const i=s?"var(--sa-text-error, #a4133c)":"var(--sa-text-primary, #292a2e)";return e.jsxs("button",{type:"button",onClick:o,style:{display:"flex",alignItems:"center",gap:12,width:"100%",padding:"8px 12px",background:n?"var(--sa-background-brand-subtlest, #e6edf6)":"none",border:"none",cursor:"pointer",font:"inherit",color:i,textAlign:"left"},onMouseEnter:l=>{n||(l.currentTarget.style.background="var(--sa-background-primary-inverse, #f8f8f8)")},onMouseLeave:l=>{l.currentTarget.style.background=n?"var(--sa-background-brand-subtlest, #e6edf6)":"none"},children:[e.jsx(E.Icon,{name:t,size:"sm",style:{color:i,flexShrink:0}}),e.jsx(v.Text,{as:"span",style:{color:i},children:r})]})},Mo=({active:t,canSort:r,canHide:n,sortDir:s,frozen:o,onSort:i,onClearSort:l,onToggleFreeze:c,onHide:a})=>{const[u,f]=d.useState(!1),g=d.useRef(null),m=d.useRef(null),[p,S]=d.useState({top:0,left:0});d.useEffect(()=>{if(u&&g.current){const I=g.current.getBoundingClientRect(),B=I.left+zn>window.innerWidth;S({top:I.bottom+6,...B?{right:window.innerWidth-I.right}:{left:I.left}})}},[u]),d.useEffect(()=>{if(!u)return;const I=B=>{m.current&&!m.current.contains(B.target)&&g.current&&!g.current.contains(B.target)&&f(!1)};return document.addEventListener("mousedown",I),()=>document.removeEventListener("mousedown",I)},[u]);const b=I=>{I(),f(!1)};return e.jsxs(e.Fragment,{children:[e.jsx("button",{ref:g,type:"button",className:"sa-tl-menu-trigger","data-active":t||u?"true":"false",onClick:I=>{I.stopPropagation(),f(B=>!B)},title:"Column options",style:{display:"inline-flex",alignItems:"center",justifyContent:"center",width:22,height:22,borderRadius:"var(--sa-radii-sm, 6px)",border:wr,background:"var(--sa-background-primary, #ffffff)",cursor:"pointer",color:"var(--sa-text-subtle, #8c8f97)",flexShrink:0},children:e.jsx(Pi,{sortDir:s,frozen:o})}),u&&e.jsxs(x.Box,{ref:m,onClick:I=>I.stopPropagation(),style:{position:"fixed",top:`${p.top}px`,...p.left!==void 0?{left:`${p.left}px`}:{right:`${p.right}px`},minWidth:zn,backgroundColor:"var(--sa-background-primary, #ffffff)",border:wr,borderRadius:"var(--sa-radii-sm, 6px)",boxShadow:"var(--sa-shadow-xl, 0 20px 25px -5px #0000001a, 0 8px 10px -6px #0000001a)",zIndex:9999,padding:"4px",display:"flex",flexDirection:"column"},children:[r&&e.jsxs(e.Fragment,{children:[e.jsx(Ht,{icon:"ChevronUp",label:"Ascending",active:s==="asc",onClick:()=>b(()=>s==="asc"?l():i("asc"))}),e.jsx(Ht,{icon:"ChevronDown",label:"Descending",active:s==="desc",onClick:()=>b(()=>s==="desc"?l():i("desc"))}),e.jsx("div",{style:{borderTop:wr,margin:"4px 0"}})]}),e.jsx(Ht,{icon:"Pin1",label:o?"Unfreeze":"Freeze",active:o,onClick:()=>b(c)}),n&&e.jsx(Ht,{icon:"EyeClosed",label:"Hide column",danger:!0,onClick:()=>b(a)})]})]})},kt="1px solid var(--sa-border-subtle, #0b120e24)",Vi="var(--sa-text-subtle, #8c8f97)",gt="var(--sa-background-neutral, #f0f1f2)",Hn="2px 0 4px -2px var(--sa-border-subtle, #0b120e24)",Bt=40,Dr="var(--sa-background-brand-subtlest)",Pt={display:"block",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},Pn="sa-table-layout-styles",Ni=()=>{if(typeof document>"u"||document.getElementById(Pn))return;const t=document.createElement("style");t.id=Pn,t.textContent=`
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const ln=require("@starasia/alert"),Zt=require("@starasia/avatar"),it=require("@starasia/badges"),x=require("@starasia/box"),yt=require("@starasia/breadcrumb"),H=require("@starasia/button"),Er=require("@starasia/card"),ht=require("@starasia/date"),Pe=require("@starasia/dialog"),Gt=require("@starasia/drawer"),jt=require("@starasia/dropdown"),Ce=require("@starasia/hooks"),bt=require("@starasia/http"),dt=require("@starasia/input"),T=require("@starasia/menu"),Mt=require("@starasia/pagination"),Ft=require("@starasia/storage"),G=require("@starasia/table"),cn=require("@starasia/tabs"),Fr=require("@starasia/textarea"),pt=require("@starasia/theme"),an=require("@starasia/toast"),vt=require("@starasia/toggle"),Fe=require("@starasia/tooltip"),nt=require("@starasia/checkbox"),Mr=require("@starasia/radio"),v=require("@starasia/text"),E=require("@starasia/icon"),ce=require("@starasia/flex"),dn=require("@starasia/grid"),un=require("@starasia/progress"),xn=require("@starasia/stepper"),hn=require("@starasia/accordion"),fn=require("@starasia/story-record"),Ye=require("@starasia/skeleton"),mn=require("@starasia/progress-stepper"),e=require("react/jsx-runtime"),d=require("react"),Yt=require("react-dom"),is=require("react-easy-crop"),ls={menus:[],menuBottom:void 0,logo:"",appName:"Workspace",userData:null,setUserData:()=>{}},Wr=d.createContext(ls),zr=()=>d.useContext(Wr),Zn=t=>{const[r,n]=d.useState((t==null?void 0:t.initialUserData)||null);return{userData:r,setUserData:n}},Gn=d.createContext({badges:{},setBadge:()=>{},setBadges:()=>{},clearBadge:()=>{}}),Qn=({children:t})=>{const[r,n]=d.useState({}),s=d.useCallback(c=>{n(a=>typeof c=="function"?c(a):c)},[]),o=d.useCallback((c,a)=>{n(u=>{const f=typeof a=="function"?a(u[c]):a;return{...u,[c]:f}})},[]),i=d.useCallback(c=>{n(a=>{if(!(c in a))return a;const u={...a};return delete u[c],u})},[]),l=d.useMemo(()=>({badges:r,setBadge:o,setBadges:s,clearBadge:i}),[r,o,s,i]);return e.jsx(Gn.Provider,{value:l,children:t})},Un=()=>d.useContext(Gn),_t=(t,r)=>{const n=r!==void 0?r:t;return n==null?null:typeof n=="string"||typeof n=="number"?{value:n}:n},Hr=240,Pr=200,Vr=480,cs="sa-sidebar-width",Ir=(t,r,n)=>Math.min(Math.max(t,r),n),as=(t,r,n,s)=>{if(typeof window>"u")return r;try{const o=window.localStorage.getItem(t);if(!o)return r;const i=parseInt(o,10);return Number.isFinite(i)?Ir(i,n,s):r}catch{return r}},gn=(t,r)=>{if(!(typeof window>"u"))try{window.localStorage.setItem(t,String(r))}catch{}},Jn=d.createContext({collapsed:!1,setCollapsed:()=>{},toggle:()=>{},collapse:()=>{},expand:()=>{},width:Hr,setWidth:()=>{},resetWidth:()=>{},minWidth:Pr,maxWidth:Vr,mobileOpen:!1,setMobileOpen:()=>{},openMobile:()=>{},closeMobile:()=>{},toggleMobile:()=>{}}),Yn=({children:t,defaultCollapsed:r=!1,defaultWidth:n=Hr,minWidth:s=Pr,maxWidth:o=Vr,widthStorageKey:i=cs})=>{const[l,c]=d.useState(r),[a,u]=d.useState(!1),[f,g]=d.useState(()=>as(i,n,s,o)),m=d.useCallback(C=>{c(R=>typeof C=="function"?C(R):C)},[]),p=d.useCallback(()=>c(C=>!C),[]),S=d.useCallback(()=>c(!0),[]),b=d.useCallback(()=>c(!1),[]),I=d.useCallback(C=>{g(R=>{const L=typeof C=="function"?C(R):C,U=Ir(Math.round(L),s,o);return gn(i,U),U})},[s,o,i]),B=d.useCallback(()=>{const C=Ir(n,s,o);gn(i,C),g(C)},[n,s,o,i]),F=d.useCallback(C=>{u(R=>typeof C=="function"?C(R):C)},[]),w=d.useCallback(()=>u(!0),[]),D=d.useCallback(()=>u(!1),[]),A=d.useCallback(()=>u(C=>!C),[]),O=d.useMemo(()=>({collapsed:l,setCollapsed:m,toggle:p,collapse:S,expand:b,width:f,setWidth:I,resetWidth:B,minWidth:s,maxWidth:o,mobileOpen:a,setMobileOpen:F,openMobile:w,closeMobile:D,toggleMobile:A}),[l,m,p,S,b,f,I,B,s,o,a,F,w,D,A]);return e.jsx(Jn.Provider,{value:O,children:t})},Xn=()=>d.useContext(Jn),$n=d.createContext(null),Kn=({adapter:t,children:r})=>e.jsx($n.Provider,{value:t,children:r}),ot=()=>{const t=d.useContext($n);if(!t)throw new Error("[@starasia/admin] Router adapter belum dipasang. Bungkus aplikasi dengan <App routerAdapter={...} /> atau <StarasiaRouterProvider adapter={...}>. Import adapter dari '@starasia/admin/adapters/react-router' atau '@starasia/admin/adapters/tanstack'.");return t},eo=({router:t,routerAdapter:r,menus:n=[],menuBottom:s,logo:o,appName:i="Workspace",initialUserData:l,theme:c})=>{const a=Zn({initialUserData:l}),{theme:u}=pt.useTheme();return e.jsx(Kn,{adapter:r,children:e.jsx(Wr.Provider,{value:{logo:o,appName:i,menus:n,userData:a.userData,setUserData:a.setUserData,menuBottom:s},children:e.jsx(Qn,{children:e.jsx(Yn,{children:c?e.jsx(pt.ThemeProvider,{value:c,children:t}):u?e.jsx(pt.ThemeProvider,{value:u,children:t}):t})})})})},ds=d.memo(eo);function to({collapsed:t=!1,children:r}){if(!r)return null;const n=typeof r=="function",s=n?r({collapsed:t}):r;return s==null||s===!1?null:e.jsx("div",{style:{position:"sticky",top:"var(--app-header-height, 4rem)",zIndex:1,borderBottom:"1px solid var(--sa-border-subtle, #0b120e24)",paddingLeft:t?"calc((var(--app-header-height, 4rem) - 2rem) / 2)":"0.5rem",paddingRight:t?"calc((var(--app-header-height, 4rem) - 2rem) / 2)":"0.5rem",paddingTop:"0.5rem",paddingBottom:"0.5rem",boxSizing:"border-box"},children:n?s:e.jsx("div",{style:{opacity:t?0:1,transition:"opacity 0.3s",visibility:t?"hidden":"visible"},children:s})})}const Nr=d.createContext(null);function ro({children:t}){const[r,n]=d.useState(null),[s,o]=d.useState(null),[i,l]=d.useState(null),[c,a]=d.useState(0),u=d.useCallback(()=>(a(f=>f+1),()=>a(f=>f-1)),[]);return e.jsx(Nr.Provider,{value:{prependNode:r,appendNode:s,replaceNode:i,setPrependNode:n,setAppendNode:o,setReplaceNode:l,replaceCount:c,registerReplace:u},children:t})}function no({children:t}){const r=d.useContext(Nr);return r?e.jsxs(e.Fragment,{children:[e.jsx("div",{ref:r.setPrependNode,style:{display:"contents"}}),r.replaceCount>0?e.jsx("div",{ref:r.setReplaceNode,style:{display:"contents"}}):t,e.jsx("div",{ref:r.setAppendNode,style:{display:"contents"}})]}):e.jsx(e.Fragment,{children:t})}function us({children:t,mode:r="append"}){const n=d.useContext(Nr);if(d.useEffect(()=>{if(!(r!=="replace"||!n))return n.registerReplace()},[r,n]),!n)return process.env.NODE_ENV!=="production"&&console.warn("[HeaderLeftSlot] used outside AppLayout — content not rendered"),null;const s=r==="prepend"?n.prependNode:r==="replace"?n.replaceNode:n.appendNode;return s?Yt.createPortal(t,s):null}const _r=d.createContext(null);function oo({children:t}){const[r,n]=d.useState({}),[s,o]=d.useState({}),i=d.useCallback((a,u)=>{n(f=>f[a]===u?f:{...f,[a]:u})},[]),l=d.useCallback(a=>(o(u=>({...u,[a]:(u[a]??0)+1})),()=>o(u=>({...u,[a]:Math.max(0,(u[a]??0)-1)}))),[]),c=d.useMemo(()=>({outletNodes:r,setOutletNode:i,slotCounts:s,registerSlot:l}),[r,i,s,l]);return e.jsx(_r.Provider,{value:c,children:t})}function so({slotKey:t,fallback:r}){const n=d.useContext(_r),s=n?(n.slotCounts[t]??0)>0:!1,o=d.useRef(n==null?void 0:n.setOutletNode);o.current=n==null?void 0:n.setOutletNode;const i=d.useCallback(l=>{var c;return(c=o.current)==null?void 0:c.call(o,t,l)},[t]);return e.jsx(e.Fragment,{children:s?e.jsx("div",{ref:i,style:{display:"contents"}}):r})}function xs({slotKey:t,children:r}){const n=d.useContext(_r),s=d.useRef(n==null?void 0:n.registerSlot);if(s.current=n==null?void 0:n.registerSlot,d.useEffect(()=>{var i;return(i=s.current)==null?void 0:i.call(s,t)},[t]),!n)return process.env.NODE_ENV!=="production"&&console.warn("[SidebarGroupSlot] used outside AppLayout — content not rendered"),null;const o=n.outletNodes[t];return o?Yt.createPortal(r,o):null}const Qt="moduleSwitcherGroupId",Lr="sa-module-switcher-change";function yn(){if(typeof window>"u")return null;const t=window.localStorage.getItem(Qt);if(t===null)return null;const r=Number(t);return Number.isFinite(r)?r:null}function io(t){typeof window>"u"||(t===null?window.localStorage.removeItem(Qt):window.localStorage.setItem(Qt,String(t)),window.dispatchEvent(new CustomEvent(Lr,{detail:t})))}function hs(){io(null)}function qr(){const[t,r]=d.useState(()=>yn());return d.useEffect(()=>{const s=()=>{r(yn())},o=i=>{i.key===Qt&&s()};return window.addEventListener(Lr,s),window.addEventListener("storage",o),()=>{window.removeEventListener(Lr,s),window.removeEventListener("storage",o)}},[]),{selectedGroupId:t,setSelectedGroupId:s=>{io(s),r(s)}}}let Wt=0,xt=!1,pn=new Set;function fs(t){const[r,n]=d.useState(!1),s=d.useRef(null),o=d.useRef(null);return d.useLayoutEffect(()=>{const i=s.current;if(!i)return;let l=0;const c=()=>{l=0;const u=o.current;if(!u)return;const f=u.scrollWidth>i.clientWidth;n(g=>g===f?g:f)},a=new ResizeObserver(()=>{l||(l=requestAnimationFrame(c))});return a.observe(i),c(),()=>{l&&cancelAnimationFrame(l),a.disconnect()}},[t]),{containerRef:s,textRef:o,truncated:r}}function jn({text:t,textStyle:r}){const{containerRef:n,textRef:s,truncated:o}=fs(t),i=e.jsx(v.Text,{ref:s,as:"span",fontSize:"md",fontWeight:"medium",truncate:!0,style:{display:"block",...r},children:t});return e.jsx(x.Box,{ref:n,display:"block",style:{flex:1,minWidth:0},children:o?e.jsx(Fe.Tooltip,{fluid:!0,label:t,position:"top",children:i}):i})}const ms=200,Tr="var(--app-header-height, 4rem)",bn="44px",gr=`calc((${Tr} - 2rem) / 2)`,vn=16;function gs({children:t,headerLeftSlot:r,profile:n,isLoadingProfile:s,onLogout:o,isLoggingOut:i,loadingComponent:l,sidebarHeaderContent:c,headerActions:a,profileRole:u,profileMenuButtons:f,profileMenuItems:g,logoutButton:m,resizableSidebar:p=!0}){var at,ft;const{useSearchParams:S,useNavigate:b,useLocation:I,Outlet:B}=ot(),[F]=S(),w=F.get("embed")==="true",D=zr(),{badges:A}=Un(),O=b(),C=I(),L=!Ce.useMediaQuery("md"),[U,J]=d.useState(!1),{collapsed:N,setCollapsed:_,width:X,setWidth:te,resetWidth:V,minWidth:z,maxWidth:P,mobileOpen:se,setMobileOpen:ye}=Xn(),[Se,xe]=d.useState(!1),[pe,je]=d.useState(()=>new Set(pn)),[be,Te]=d.useState(null),{selectedGroupId:ke,setSelectedGroupId:He}=qr(),Y=N&&!L;d.useEffect(()=>{pn=pe},[pe]);const he=d.useRef(null),Oe=d.useRef(null),Ne=d.useRef(null),[ae,_e]=d.useState(!1),[tt,W]=d.useState(null),$=p&&!L&&!N,Q=k=>Math.min(Math.max(k,z),P),de=tt??X,ie=k=>{var De,Ee,We;if(!$)return;k.preventDefault();const q=k.clientX,K=((De=Ne.current)==null?void 0:De.getBoundingClientRect().width)??X;(We=(Ee=k.currentTarget).setPointerCapture)==null||We.call(Ee,k.pointerId),_e(!0),document.body.style.userSelect="none",document.body.style.cursor="col-resize";let ve=0,Ie=K;const Ue=wt=>{Ie=K+(wt.clientX-q),ve||(ve=requestAnimationFrame(()=>{ve=0,W(Q(Ie))}))},Ae=()=>{ve&&cancelAnimationFrame(ve),window.removeEventListener("pointermove",Ue),window.removeEventListener("pointerup",Ae),document.body.style.userSelect="",document.body.style.cursor="",W(null),_e(!1),Ie<ms?_(!0):te(Q(Ie))};window.addEventListener("pointermove",Ue),window.addEventListener("pointerup",Ae)},Be=k=>{$&&(k.key==="ArrowLeft"?(k.preventDefault(),te(q=>q-vn)):k.key==="ArrowRight"?(k.preventDefault(),te(q=>q+vn)):k.key==="Home"?(k.preventDefault(),te(z)):k.key==="End"&&(k.preventDefault(),te(P)))};d.useEffect(()=>{const k=he.current;if(!k)return;const q=()=>{xt||(Wt=k.scrollTop)};return k.addEventListener("scroll",q),()=>k.removeEventListener("scroll",q)},[]);const Re=()=>{const k=he.current;k&&Wt>0&&(xt=!0,k.scrollTop=Wt,requestAnimationFrame(()=>{xt=!1}))};d.useLayoutEffect(()=>{xt=!0,Re();const k=setTimeout(()=>{xt=!1},300);return()=>clearTimeout(k)},[]),d.useLayoutEffect(()=>{D.menus.length>0&&(Wt>0?Re():requestAnimationFrame(()=>{var q;const k=(q=he.current)==null?void 0:q.querySelector("[data-menu-active='true']");k&&k.scrollIntoView({block:"center",behavior:"instant"})}))},[D.menus]),d.useEffect(()=>{xt=!0,Re();const k=setTimeout(Re,0),q=setTimeout(Re,50),K=setTimeout(Re,100),ve=setTimeout(Re,200),Ie=setTimeout(()=>{xt=!1},300),Ue=setTimeout(()=>{const Ae=he.current,De=Ae==null?void 0:Ae.querySelector("[data-menu-active='true']");if(Ae&&De){const Ee=Ae.getBoundingClientRect(),We=De.getBoundingClientRect();We.top>=Ee.top&&We.bottom<=Ee.bottom||De.scrollIntoView({block:"center",behavior:"smooth"})}},250);return()=>{clearTimeout(k),clearTimeout(q),clearTimeout(K),clearTimeout(ve),clearTimeout(Ie),clearTimeout(Ue)}},[C.pathname]),d.useEffect(()=>{Oe.current&&(Oe.current.scrollTop=0)},[C.pathname]),d.useEffect(()=>{L&&ye(!1)},[C.pathname,L]),d.useEffect(()=>{L&&_(!0)},[L]),d.useEffect(()=>{const k=document.documentElement;return k.style.setProperty("--app-header-height",bn),()=>{k.style.removeProperty("--app-header-height")}},[]);const $e=()=>{J(!0)},qe=()=>{J(!1)},Me=()=>{J(!1),o()},Qe=k=>{const q=[k.to];return k.children&&q.push(...k.children.map(K=>K.to)),q},we=[...D.menus.flatMap(k=>k.items.flatMap(Qe)),...((at=D.menuBottom)==null?void 0:at.flatMap(Qe))??[]],Ze=k=>{if(!C.pathname.startsWith(k))return!1;const q=we.filter(K=>C.pathname.startsWith(K)).sort((K,ve)=>ve.length-K.length)[0];return k===q};d.useEffect(()=>{var q;const k=K=>{var ve;(ve=K.children)!=null&&ve.some(Ie=>C.pathname.startsWith(Ie.to))&&je(Ie=>{const Ue=new Set(Ie);return Ue.add(K.id),Ue})};D.menus.forEach(K=>{K.items.forEach(k)}),(q=D.menuBottom)==null||q.forEach(k)},[C.pathname,D.menus,D.menuBottom]);const rt=k=>{je(q=>{const K=new Set(q);return K.has(k)?K.delete(k):K.add(k),K})};d.useEffect(()=>{D.menus.length!==0&&ke!==null&&!D.menus.some(k=>k.id===ke)&&He(null)},[D.menus,ke,He]);const ut=d.useMemo(()=>{if(ke!==null)return D.menus.filter(K=>K.id===ke||K.parentGroupId===ke);const k=D.menus.filter(K=>K.parentGroupId===void 0),q=D.menus.filter(K=>K.parentGroupId!==void 0).flatMap(K=>K.items);return q.length===0?k:[...k,{id:18,name:"Pengaturan",items:q,parentGroupId:void 0}]},[D.menus,ke]);if(w)return e.jsx(x.Box,{as:"main",overflow:"overflow-y-auto",bg:"surface-inverse",style:{height:"100vh"},children:t||e.jsx(B,{})});const ct=k=>{const q=k.children&&k.children.length>0,K=pe.has(k.id),ve=q?k.children.some(Ae=>Ze(Ae.to)):Ze(k.to),Ie=_t(k.badge,A[k.id]),Ue=!!Ie&&N&&!L;return e.jsxs(x.Box,{display:"block","data-menu-active":ve||void 0,children:[e.jsxs(x.Box,{as:"button",onClick:Ae=>{if(q)if(N&&!L){const De=Ae.currentTarget.getBoundingClientRect();Te({item:k,top:De.top,left:De.right+8})}else rt(k.id);else O(k.to)},fullWidth:!0,direction:"row",align:"center",justify:N&&!L?"center":void 0,gap:"sm",paddingInline:N&&!L?void 0:"sm",paddingBlock:"xs",height:"height-32",borderRadius:ve?"rounded-sm":"rounded-md",borderWidth:"border",borderStyle:"border-solid",borderColor:ve?"border-base":void 0,bg:ve?"white":void 0,hover:ve?void 0:{bg:"neutral"},title:N&&!L?k.title:void 0,style:{textAlign:"left",color:"var(--sa-text-primary, #292a2e)",...ve?null:{borderColor:"transparent"}},children:[e.jsxs(x.Box,{position:"relative",display:"inline-flex",flexShrink:"0",style:{alignItems:"center"},children:[e.jsx(E.Icon,{name:k.icon,size:"sm",style:{flexShrink:0}}),Ue&&e.jsx(x.Box,{"aria-hidden":"true",position:"absolute",top:"top-n2",right:"right-n2",display:"inline-flex",borderRadius:"rounded-full",style:{boxShadow:"0 0 0 1px var(--sa-background-primary, #ffffff)"},children:e.jsx(it.BadgeDot,{tone:"error",variant:"solid",size:"xs"})})]}),(!N||L)&&e.jsxs(e.Fragment,{children:[e.jsx(jn,{text:k.title,textStyle:{transition:"opacity 0.3s"}}),Ie&&e.jsx(it.Badge,{text:String(Ie.value),variant:Ie.variant??"info",size:"xs",border:!0}),q&&e.jsx(E.Icon,{name:"ChevronDown",size:"sm",style:{flexShrink:0,transition:"transform 0.2s",transform:K?"rotate(180deg)":"rotate(0deg)"}})]})]}),q&&(!N||L)&&(()=>{const Ae=k.children.findIndex(De=>Ze(De.to));return e.jsxs(x.Box,{position:"relative",overflow:"overflow-hidden",style:{marginLeft:"1rem",paddingLeft:"0.75rem",transition:"all 0.3s ease-in-out",maxHeight:K?`${k.children.length*36}px`:"0px",opacity:K?1:0,marginTop:K?"0.25rem":"0px"},children:[e.jsx(x.Box,{"aria-hidden":"true",position:"absolute",left:"left-0",top:"top-0",fullHeight:!0,style:{width:"1.5px",backgroundColor:"var(--sa-border-subtle, #0b120e24)",pointerEvents:"none"}}),Ae>=0&&e.jsx(x.Box,{"aria-hidden":"true",position:"absolute",left:"left-0",height:"height-32",zIndex:"10",style:{top:`${Ae*32}px`,width:"1.5px",backgroundColor:"var(--sa-text-primary, #292a2e)",transition:"top 0.2s ease-in-out",pointerEvents:"none"}}),k.children.map(De=>{const Ee=_t(De.badge,A[De.id]),We=Ze(De.to);return e.jsxs(x.Box,{as:"button",onClick:()=>O(De.to),fullWidth:!0,direction:"row",align:"center",gap:"sm",paddingLeft:"sm",paddingRight:"sm",paddingBlock:"xs",height:"height-32",borderRadius:We?"rounded-sm":"rounded-md",borderWidth:"border",borderStyle:"border-solid",borderColor:We?"border-base":void 0,bg:We?"white":void 0,hover:We?void 0:{bg:"neutral"},style:{textAlign:"left",color:We?"var(--sa-text-primary, #292a2e)":"var(--sa-text-subtle, #505258)",...We?null:{borderColor:"transparent"}},children:[e.jsx(E.Icon,{name:De.icon,size:"sm",style:{flexShrink:0}}),e.jsx(jn,{text:De.title}),Ee&&e.jsx(it.Badge,{text:String(Ee.value),variant:Ee.variant??"info",size:"xs",border:!0})]},De.id)})]})})()]},k.id)};return e.jsx(oo,{children:e.jsxs(ro,{children:[e.jsxs(x.Box,{direction:"row",position:"relative",style:{height:"100vh","--app-header-height":bn,"--app-sidebar-width":L?"0px":N?Tr:`${de}px`,"--app-footer-zindex":L&&se?"40":"998"},children:[L&&e.jsx(x.Box,{position:"fixed",zIndex:"40",bg:"black-alpha-a50",style:{inset:0,opacity:se?.5:0,pointerEvents:se?"auto":"none",transition:"opacity 0.3s"},onClick:()=>ye(!1)}),e.jsxs(x.Box,{as:"aside",ref:Ne,bg:"surface-inverse",borderWidth:"border-r",borderStyle:"border-solid-r",borderColor:"border-base",flexShrink:L?void 0:"0",style:{width:L?"16.375rem":N?Tr:`${de}px`,position:L?"fixed":"relative",...L&&{inset:0,zIndex:50,transform:se?"translateX(0)":"translateX(-100%)"},transition:ae?"none":"all 0.3s ease-in-out",minWidth:0},children:[e.jsx(x.Box,{onMouseEnter:()=>xe(!0),onMouseLeave:()=>xe(!1),direction:"row",align:"center",justify:"space-between",paddingInline:Y?void 0:"lg",borderWidth:"border-b",borderStyle:"border-solid-b",borderColor:"border-base",position:"relative",style:{height:"var(--app-header-height, 4rem)",...Y?{paddingInline:gr}:null},children:(()=>{const k=!L&&N&&!se,q=k&&Se;return e.jsxs(e.Fragment,{children:[e.jsxs(x.Box,{direction:"row",align:"center",gap:"sm",flex:k?"1":void 0,justify:k?"center":void 0,style:{transition:"opacity 0.2s",opacity:q?0:1,pointerEvents:q?"none":"auto"},children:[e.jsx("img",{src:D.logo,alt:"Logo",style:{width:"1.5rem",height:"1.5rem",flexShrink:0}}),(!N||se)&&e.jsx(v.Text,{as:"span",fontSize:"md",fontWeight:"semibold",color:"primary",truncate:!0,style:{transition:"opacity 0.3s"},children:D.appName})]}),!L&&!N&&e.jsx(x.Box,{as:"button",onClick:()=>_(!0),"aria-label":"Collapse sidebar",display:"inline-flex",align:"center",justify:"center",flexShrink:"0",style:{color:"var(--sa-text-subtle, #8c8f97)"},children:e.jsx(E.Icon,{name:"LayoutLeft",size:"sm"})}),k&&e.jsx(x.Box,{as:"button",onClick:()=>_(!1),"aria-label":"Expand sidebar",position:"absolute",display:"inline-flex",align:"center",justify:"center",width:"width-32",height:"height-32",bg:"white",borderWidth:"border",borderStyle:"border-solid",borderColor:"border-base",borderRadius:"rounded-sm",style:{top:"50%",left:"50%",transform:"translate(-50%, -50%)",color:"var(--sa-text-primary, #292a2e)",opacity:q?1:0,pointerEvents:q?"auto":"none",transition:"opacity 0.2s"},children:e.jsx(E.Icon,{name:"LayoutLeft",size:"sm"})}),L&&e.jsx(x.Box,{as:"button",onClick:()=>ye(!1),"aria-label":"Close menu",align:"center",justify:"center",borderRadius:"rounded-md",style:{padding:"0.375rem",color:"var(--sa-text-subtle, #8c8f97)"},children:e.jsx(E.Icon,{name:"Cross",size:"md"})})]})})()}),c&&e.jsx(to,{collapsed:L?!1:N,children:c}),e.jsx(x.Box,{ref:he,flex:"1",overflow:"overflow-y-auto",paddingBlock:"lg",children:ut.map(k=>e.jsxs(x.Box,{marginBottom:"lg",children:[!N||L?k.name&&e.jsx(v.Text,{fontSize:"md",fontWeight:"normal",color:"subtlest",truncate:!0,style:{paddingLeft:"1.25rem",paddingRight:"0.75rem",paddingBottom:"0.25rem",transition:"opacity 0.3s"},children:k.name}):k.name&&e.jsx(x.Box,{"aria-label":k.name,direction:"row",align:"center",justify:"center",paddingBlock:"md",children:e.jsx(x.Box,{width:"width-16",style:{height:"2px",borderRadius:"1px",backgroundColor:k.color??"var(--sa-background-brand, #04254f)"}})}),e.jsx(x.Box,{paddingInline:Y?void 0:"md",gap:"xs",style:Y?{paddingInline:gr}:void 0,children:k.slotKey?e.jsx(so,{slotKey:k.slotKey,fallback:k.items.map(q=>ct(q))}):k.items.map(q=>ct(q))})]},k.id))}),D.menuBottom&&D.menuBottom.length>0&&e.jsx(x.Box,{borderWidth:"border-t",borderStyle:"border-solid-t",borderColor:"border-base",paddingBlock:"md",paddingInline:Y?void 0:"md",bg:"surface-inverse",gap:"xs",flexShrink:"0",style:Y?{paddingInline:gr}:void 0,children:D.menuBottom.map(k=>ct(k))}),$&&e.jsx(x.Box,{role:"separator","aria-orientation":"vertical","aria-label":"Resize sidebar","aria-valuenow":X,"aria-valuemin":z,"aria-valuemax":P,tabIndex:0,onPointerDown:ie,onKeyDown:Be,onDoubleClick:V,title:"Drag to resize · double-click to reset",position:"absolute",top:"top-0",right:"right-0",fullHeight:!0,style:{width:"6px",transform:"translateX(50%)",cursor:"col-resize",zIndex:5,touchAction:"none",background:ae?"var(--sa-background-brand, #04254f)":"transparent",transition:"background 0.15s"},onMouseEnter:k=>{ae||(k.currentTarget.style.background="var(--sa-border-bold, #0b120e40)")},onMouseLeave:k=>{ae||(k.currentTarget.style.background="transparent")}})]}),e.jsxs(x.Box,{flex:"1",overflow:"overflow-hidden",children:[e.jsxs(x.Box,{as:"header",bg:"white",borderWidth:"border-b",borderStyle:"border-solid-b",borderColor:"border-base",direction:"row",align:"center",justify:"space-between",paddingInline:"lg",flexShrink:"0",style:{height:"var(--app-header-height, 4rem)"},children:[e.jsxs(x.Box,{direction:"row",align:"center",gap:L?"lg":void 0,children:[L&&e.jsx(x.Box,{as:"button",onClick:()=>ye(!0),align:"center",justify:"center",borderRadius:"rounded-md",style:{padding:"0.375rem",color:"var(--sa-text-subtle, #8c8f97)"},children:e.jsx(E.Icon,{name:"MenuBurger",size:"lg"})}),e.jsx(no,{children:r})]}),e.jsxs(x.Box,{direction:"row",align:"center",gap:"md",children:[a,e.jsxs(T.Menu,{position:"bottom-right",children:[e.jsx(T.MenuButton,{children:e.jsxs(x.Box,{direction:"row",align:"center",gap:"sm",cursor:"pointer",children:[e.jsxs(x.Box,{display:"block",textAlign:"right",customMaxWidth:"12.5rem",children:[e.jsx(v.Text,{fontSize:"sm",fontWeight:"medium",color:"subtle",textAlign:"right",truncate:!0,lineHeight:"leading-none",children:s?"Loading...":(n==null?void 0:n.name)||"unknown"}),e.jsx(v.Text,{fontSize:"sm",color:"subtle",textAlign:"right",truncate:!0,children:s?"":(n==null?void 0:n.email)||"unknown"})]}),e.jsx(Zt.Avatar,{size:"sm",initials:((n==null?void 0:n.name)||"U")[0].toUpperCase(),bg:"var(--sa-background-brand, #04254f)",color:"var(--sa-background-primary, #ffffff)"}),e.jsx(E.Icon,{name:"ChevronDown",size:"xs",color:"subtle"})]})}),e.jsxs(T.MenuLists,{width:280,style:{paddingBlock:"12px",paddingInline:"12px",gap:"8px",marginTop:"16px"},children:[e.jsx(T.MenuHeading,{children:e.jsxs(x.Box,{align:"center",textAlign:"center",paddingBlock:"sm",fullWidth:!0,children:[e.jsx(Zt.Avatar,{customSize:64,initials:((n==null?void 0:n.name)||"U")[0].toUpperCase(),bg:"var(--sa-background-brand, #04254f)",color:"var(--sa-background-primary, #ffffff)",style:{fontSize:"1.25rem",marginBottom:"0.75rem",boxShadow:"var(--sa-shadow-sm, 0 1px 2px 0 #0000000d)"}}),e.jsx(v.Text,{fontSize:"md",fontWeight:"semibold",color:"primary",textAlign:"center",truncate:!0,style:{maxWidth:"100%"},children:(n==null?void 0:n.name)||"unknown"}),e.jsx(v.Text,{fontSize:"sm",color:"subtle",textAlign:"center",truncate:!0,style:{maxWidth:"100%"},children:(n==null?void 0:n.email)||"unknown"}),u&&e.jsx(v.Text,{fontSize:"sm",color:"subtle",textAlign:"center",truncate:!0,style:{maxWidth:"100%"},children:u})]})}),(f&&f.length>0||g)&&e.jsxs(T.MenuBody,{children:[f==null?void 0:f.map((k,q)=>e.jsx(T.MenuItem,{onClick:k.onClick,startIcon:e.jsx(E.Icon,{name:k.icon,size:"md"}),children:k.label},`${k.label}-${q}`)),g]}),m??e.jsx(T.MenuFooter,{children:e.jsx(T.MenuItem,{intent:"danger",onClick:$e,startIcon:e.jsx(E.Icon,{name:"Logout",size:"md"}),children:"Logout"})})]})]})]})]}),e.jsx(x.Box,{as:"main",ref:Oe,flex:"1",overflow:"overflow-y-auto",children:t||e.jsx(B,{})})]})]}),i&&l&&e.jsx(x.Box,{position:"fixed",align:"center",justify:"center",bg:"black-alpha-a70",style:{inset:0,zIndex:9999},children:l}),e.jsxs(Pe.Dialog,{isShow:U,onHide:qe,children:[e.jsx(Pe.DialogTitle,{children:"Confirmation Logout"}),e.jsx(Pe.DialogBody,{children:"Are you sure you want to end the session and exit the page?"}),e.jsx(Pe.DialogFooter,{children:e.jsx(x.Box,{direction:"column",display:"flex",align:"flex-end",justify:"center",children:e.jsxs(ce.Flex,{direction:"row",gap:"sm",align:"center",children:[e.jsx(x.Box,{direction:"column",children:e.jsx(H.Button,{secondary:!0,onClick:qe,children:"Cancel"})}),e.jsx(x.Box,{direction:"column",children:e.jsx(H.Button,{primary:!0,onClick:Me,children:"Yes, Sure"})})]})})})]}),be&&e.jsxs(e.Fragment,{children:[e.jsx(x.Box,{onClick:()=>Te(null),position:"fixed",style:{inset:0,zIndex:60}}),e.jsxs(x.Box,{role:"dialog","aria-label":be.item.title,position:"fixed",bg:"white",borderWidth:"border",borderStyle:"border-solid",borderColor:"border-base",borderRadius:"rounded-md",shadow:"shadow-lg",padding:"sm",gap:"spacing-2",style:{top:be.top,left:be.left,zIndex:61,minWidth:"13rem",maxWidth:"16rem"},children:[e.jsx(v.Text,{fontSize:"sm",fontWeight:"semibold",color:"gray-500",textTransform:"uppercase",style:{padding:"0.25rem 0.5rem 0.5rem",letterSpacing:"0.05em"},children:be.item.title}),(ft=be.item.children)==null?void 0:ft.map(k=>{const q=Ze(k.to),K=_t(k.badge,A[k.id]);return e.jsxs(x.Box,{as:"button",onClick:()=>{O(k.to),Te(null)},fullWidth:!0,direction:"row",align:"center",gap:"md",paddingBlock:"sm",paddingInline:"md",borderRadius:"rounded-md",borderWidth:"border",borderStyle:"border-solid",bg:q?"primary-inverse":void 0,hover:q?void 0:{bg:"primary-inverse"},style:{textAlign:"left",borderColor:"transparent",color:q?"var(--sa-text-primary, #292a2e)":"var(--sa-color-gray-800, #505258)"},children:[k.icon&&e.jsx(E.Icon,{name:k.icon,size:"sm",style:{flexShrink:0}}),e.jsx(v.Text,{as:"span",fontSize:"md",fontWeight:"medium",whiteSpace:"nowrap",style:{flex:1},children:k.title}),K&&e.jsx(it.Badge,{text:String(K.value),variant:K.variant??"info",size:"xs",border:!0})]},k.id)})]})]})]})})}const Lt=d.forwardRef(({children:t,...r},n)=>e.jsx(x.Box,{ref:n,role:"button",cursor:"pointer","aria-pressed":"true",display:"inline-block",tabIndex:0,...r,children:t})),Cn=({title:t,iconName:r,textColor:n,iconColor:s,hoverTextColor:o,hoverIconColor:i})=>{const[l,c]=d.useState(!1),a=s??"var(--sa-text-subtle, #8c8f97)",u=n??"var(--sa-text-subtle, #8c8f97)",f=i??"var(--sa-text-subtle, #8c8f97)",g=o??"var(--sa-text-primary, #292a2e)";return e.jsxs(x.Box,{direction:"row",gap:"xs",align:"center",onMouseEnter:()=>c(!0),onMouseLeave:()=>c(!1),style:{cursor:"pointer"},children:[e.jsx(E.Icon,{name:r||"ChevronLeft",size:"xs",style:{color:l?f:a,transition:"color 0.15s ease"}}),e.jsx(v.Text,{variant:"sub-h3",style:{color:l?g:u,transition:"color 0.15s ease"},children:t||"Back"})]})},ys=({items:t,separator:r="/",iconName:n,iconColor:s,hoverIconColor:o})=>{const{Link:i}=ot(),[l,c]=d.useState(!1),a=s??"var(--sa-text-subtle, #8c8f97)",u=o??"var(--sa-text-subtle, #8c8f97)",f=t.length>1?t[0]:void 0,g=!!(f!=null&&f.to||f!=null&&f.onClick),m=e.jsx(E.Icon,{name:n||"ChevronLeft",size:"xs",onMouseEnter:g?()=>c(!0):void 0,onMouseLeave:g?()=>c(!1):void 0,style:{color:g&&l?u:a,transition:"color 0.15s ease",cursor:g?"pointer":void 0}}),p=f!=null&&f.to?e.jsx(i,{to:f.to,replace:!0,style:{textDecoration:"none"},children:m}):f!=null&&f.onClick?e.jsx(Lt,{onClick:f.onClick,children:m}):m;return e.jsxs(x.Box,{direction:"row",gap:"xs",align:"center",children:[p,e.jsx(yt.Breadcrumb,{separator:r,size:"md",children:t.map((S,b)=>{const I=b===t.length-1;return S.to&&!I?e.jsx(yt.BreadcrumbItem,{children:e.jsx(i,{to:S.to,children:S.label})},b):e.jsx(yt.BreadcrumbItem,{currentPage:I,children:e.jsx(yt.BreadcrumbLink,{onClick:I?void 0:S.onClick,children:S.label})},b)})})]})},ps=t=>{const{Link:r}=ot(),{items:n,separator:s,onClick:o,navigateTo:i,...l}=t;return n&&n.length>0?e.jsx(ys,{items:n,separator:s,iconName:l.iconName,iconColor:l.iconColor,hoverIconColor:l.hoverIconColor}):i?e.jsx(x.Box,{direction:"row",children:e.jsx(r,{to:i,replace:!0,style:{textDecoration:"none"},children:e.jsx(Cn,{...l})})}):e.jsx(x.Box,{direction:"row",children:e.jsx(Lt,{onClick:o,children:e.jsx(Cn,{...l})})})},yr=[{icon:"var(--sa-color-brand-400, #3366b7)",activeBg:"var(--sa-color-brand-50, #e6edf6)",activeBorder:"var(--sa-color-brand-300, #668cc9)",activeShadow:"rgba(51, 102, 183, 0.25)"},{icon:"var(--sa-color-warning-400, #ed9f30)",activeBg:"var(--sa-color-warning-50, #fef2e6)",activeBorder:"var(--sa-color-warning-300, #f1b259)",activeShadow:"rgba(237, 159, 48, 0.25)"},{icon:"var(--sa-color-secondary-300, #5468e1)",activeBg:"var(--sa-color-secondary-50, #e6e9fb)",activeBorder:"var(--sa-color-secondary-200, #8a98ea)",activeShadow:"rgba(84, 104, 225, 0.25)"},{icon:"var(--sa-color-info-500, #00abeb)",activeBg:"var(--sa-color-info-50, #effaff)",activeBorder:"var(--sa-color-info-300, #75dbff)",activeShadow:"rgba(0, 171, 235, 0.25)"},{icon:"var(--sa-color-success-500, #30ce84)",activeBg:"var(--sa-color-success-50, #ecfff6)",activeBorder:"var(--sa-color-success-300, #75dead)",activeShadow:"rgba(48, 206, 132, 0.25)"},{icon:"var(--sa-color-error-400, #ff758f)",activeBg:"var(--sa-color-error-50, #fff0f3)",activeBorder:"var(--sa-color-error-300, #ff8fa3)",activeShadow:"rgba(255, 117, 143, 0.25)"}];function wn(t,r,n){return{display:"flex",alignItems:"center",justifyContent:"center",width:"64px",height:"64px",borderRadius:"var(--sa-radii-sm, 6px)",border:t?`2px solid ${n.activeBorder}`:"2px solid var(--sa-color-gray-200, #f0f1f2)",backgroundColor:t?n.activeBg:"var(--sa-color-gray-50, #ffffff)",boxShadow:t?r?`0 8px 20px ${n.activeShadow.replace("0.25","0.35")}`:`0 2px 8px ${n.activeShadow}`:r?"0 8px 20px rgba(0, 0, 0, 0.14)":"0 1px 4px rgba(0, 0, 0, 0.08)",transform:r?"translateY(-3px) scale(1.05)":"translateY(0) scale(1)",transition:"box-shadow 0.2s ease, transform 0.2s ease, background-color 0.15s ease, border-color 0.15s ease"}}const Dn={fontSize:"11px",fontWeight:500,textAlign:"center",overflowWrap:"normal",wordBreak:"normal",color:"var(--sa-background-primary, #ffffff)",lineHeight:"1.3",maxWidth:"80px"},Sn={display:"flex",flexDirection:"column",alignItems:"center",gap:"8px",background:"none",border:"none",cursor:"pointer",padding:0};function lo({isShow:t,onHide:r,menus:n,selectedGroupId:s,onSelect:o}){const[i,l]=d.useState(void 0),c=u=>{o(u),r()},a=yr[0];return e.jsx(Pe.Dialog,{isShow:t,onHide:r,style:{width:560,background:"transparent",boxShadow:"none",border:"none"},children:e.jsx(Pe.DialogBody,{children:e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(5, 1fr)",gap:"16px"},children:[e.jsxs("button",{onClick:()=>c(null),onMouseEnter:()=>l("all"),onMouseLeave:()=>l(void 0),style:Sn,children:[e.jsx("div",{style:wn(s===null,i==="all",a),children:e.jsx("div",{style:{color:a.icon,display:"flex",alignItems:"center",justifyContent:"center"},children:e.jsx(E.Icon,{name:"Grid",size:"lg",style:{width:32,height:32}})})}),e.jsx("span",{style:Dn,children:"Semua"})]}),n.map((u,f)=>{var b;const g=s===u.id,m=i===u.id,p=((b=u.items[0])==null?void 0:b.icon)??"Grid",S=yr[(f+1)%yr.length];return e.jsxs("button",{onClick:()=>c(u.id),onMouseEnter:()=>l(u.id),onMouseLeave:()=>l(void 0),style:Sn,children:[e.jsx("div",{style:wn(g,m,S),children:e.jsx("div",{style:{color:S.icon,display:"flex",alignItems:"center",justifyContent:"center"},children:e.jsx(E.Icon,{name:p,size:"lg",style:{width:32,height:32}})})}),e.jsx("span",{style:Dn,children:u.name})]},u.id)})]})})})}function js({onSelect:t,"aria-label":r="Pilih module"}={}){const n=zr(),{useNavigate:s}=ot(),o=s(),{selectedGroupId:i,setSelectedGroupId:l}=qr(),[c,a]=d.useState(!1),u=f=>{var g;if(l(f),f!==null){const m=n.menus.find(S=>S.id===f),p=(g=m==null?void 0:m.items[0])==null?void 0:g.to;p&&o(p)}t==null||t(f)};return e.jsxs(e.Fragment,{children:[e.jsxs("div",{style:{position:"relative"},children:[e.jsx("button",{onClick:()=>a(!0),style:{display:"inline-flex",alignItems:"center",justifyContent:"center",width:"2.25rem",height:"2.25rem",borderRadius:"var(--sa-radii-sm, 0.25rem)",border:"1px solid var(--sa-border-subtle, #0b120e24)",color:"var(--sa-text-subtle, #8c8f97)",backgroundColor:"transparent",cursor:"pointer"},"aria-label":r,onMouseEnter:f=>{f.currentTarget.style.backgroundColor="var(--sa-background-primary-inverse, #f8f8f8)"},onMouseLeave:f=>{f.currentTarget.style.backgroundColor="transparent"},children:e.jsx(E.Icon,{name:"GridApplication",size:"sm"})}),i!==null&&e.jsx("span",{style:{position:"absolute",top:"0.25rem",right:"0.25rem",width:"0.5rem",height:"0.5rem",borderRadius:"9999px",backgroundColor:"var(--sa-color-brand-500, #1a4fa0)"},"aria-hidden":"true"})]}),e.jsx(lo,{isShow:c,onHide:()=>a(!1),menus:n.menus.filter(f=>f.parentGroupId===void 0),selectedGroupId:i,onSelect:u})]})}const bs=(t,r)=>{const n=[];if(r===0)return n.push(t),n;for(let s=0;s<t.length;s+=r){const o=t.slice(s,s+r);n.push(o)}return n},vs=d.memo(({value:t,label:r,separator:n,labelWidth:s,lastIndex:o,labelAlign:i="top"})=>{const l=d.useMemo(()=>({padding:0,paddingBottom:o?0:12,verticalAlign:i}),[o,i]),c=d.useMemo(()=>({padding:0,paddingRight:12,paddingLeft:12,paddingBottom:o?0:12,verticalAlign:i}),[o,i]),a=()=>typeof r=="string"?e.jsx(v.Text,{fontWeight:"medium",color:"subtlest",children:r}):r,u=()=>typeof t=="string"||typeof t=="number"?e.jsx(v.Text,{color:"primary",fontWeight:"medium",children:t}):t,f=()=>typeof n=="string"||typeof n=="number"?e.jsx(v.Text,{fontWeight:"medium",color:"subtlest",children:n}):n;return e.jsxs(G.Tr,{children:[e.jsx(G.Td,{style:l,width:s,children:a()}),n?e.jsx(G.Td,{style:c,width:24,children:f()}):null,e.jsx(G.Td,{style:l,children:u()})]})}),Cs=d.memo(({fields:t,separator:r,labelWidth:n})=>e.jsx(G.Table,{withColumnBorder:!1,withRowBorder:!1,children:t.map((s,o)=>e.jsx(vs,{separator:r,labelWidth:n,lastIndex:o===t.length-1,...s},`field-group-field-${o}`))})),ws=d.memo(({maxRow:t=0,maxColumn:r=2,separator:n=":",fields:s=[],labelWidth:o=150,bordered:i=!1})=>{const l=d.useMemo(()=>bs(s,t),[s,t]),c=l.length>2,a=()=>{switch(r){case 1:return"width-full";case 2:return"width-1-2";case 3:return"width-1-3";case 4:return"width-1-4";default:return"width-1-2"}};return e.jsx(x.Box,{gap:c?void 0:"lg",direction:"row",flexWrap:"wrap",borderRadius:"rounded-sm",padding:"lg",paddingBottom:c?"xs":"lg",bg:"accent-dark-tertiary",borderWidth:i?"border":void 0,borderStyle:i?"border-solid":void 0,borderColor:i?"border-subtle":void 0,children:l.map((u,f)=>e.jsx(x.Box,{direction:"column",flex:c?void 0:"1",width:c?a():void 0,marginBottom:c?"lg":void 0,children:e.jsx(Cs,{labelWidth:o,fields:u,separator:n})},f))})}),Ds=({backButton:t})=>{const[r,n]=d.useState(!1),s=(t==null?void 0:t.iconColor)??"var(--sa-text-subtle, #8c8f97)",o=(t==null?void 0:t.textColor)??"var(--sa-text-subtle, #8c8f97)",i=(t==null?void 0:t.hoverIconColor)??"var(--sa-text-subtle, #8c8f97)",l=(t==null?void 0:t.hoverTextColor)??"var(--sa-text-primary, #292a2e)";return e.jsxs(x.Box,{direction:"row",gap:"xs",align:"center",onMouseEnter:()=>n(!0),onMouseLeave:()=>n(!1),style:{cursor:"pointer"},children:[e.jsx(E.Icon,{name:(t==null?void 0:t.iconName)||"ChevronLeft",size:"xs",style:{color:r?i:s,transition:"color 0.15s ease"}}),e.jsx(v.Text,{variant:"sub-h3",style:{color:r?l:o,textDecoration:r?"underline":"none",transition:"color 0.15s ease"},children:(t==null?void 0:t.title)||"Back"})]})},Ss=({backButton:t,title:r,titleIcon:n,titleTag:s,children:o,header:i=!0,headerBorder:l=!1,disableAnimation:c=!1,scrollable:a=!1,stickyHeader:u=!1,subHeaders:f,action:g,titleTagProps:m,containerProps:p,headerProps:S})=>{const b=Ce.useMediaQuery("md"),{Link:I,useNavigate:B,useLocation:F}=ot(),w=B(),D=F(),A=t==null?void 0:t.show,O=()=>{if(typeof(t==null?void 0:t.onClick)=="function"){t.onClick();return}w(-1,{replace:!0})},C=()=>{if(!g)return null;if(d.isValidElement(g))return g;const _=g.filter(X=>X&&(X.title||X.icon));return _.length===0?null:b?e.jsx(x.Box,{direction:"row",gap:"md",children:_.map(({title:X,icon:te,buttonProps:V,onClick:z},P)=>e.jsx(H.Button,{iconLeft:te?e.jsx(E.Icon,{name:te,size:"md"}):void 0,onClick:z,...V,children:X},`action-${P}`))}):e.jsxs(T.Menu,{position:"bottom-right",children:[e.jsx(T.MenuButton,{children:e.jsx(H.Button,{variant:"tertiary",size:"sm",iconLeft:e.jsx(E.Icon,{name:"MenuBurger"}),"aria-label":"Actions"})}),e.jsx(T.MenuLists,{children:e.jsx(T.MenuBody,{style:{minWidth:200},children:_.map(({title:X,icon:te,buttonProps:V,onClick:z},P)=>{const se=(V==null?void 0:V.tone)==="error"||(V==null?void 0:V.danger)===!0;return e.jsx(T.MenuItem,{intent:se?"danger":void 0,disabled:V==null?void 0:V.disabled,startIcon:te?e.jsx(E.Icon,{name:te}):void 0,onClick:z,children:X},`action-${P}`)})})})]})},R=()=>{const _=e.jsx(Ds,{backButton:t});return t!=null&&t.navigateTo?e.jsx(x.Box,{direction:"row",children:e.jsx(I,{to:t.navigateTo,replace:!0,style:{textDecoration:"none"},children:_})}):e.jsx(x.Box,{direction:"row",children:e.jsx(Lt,{onClick:O,children:_})})},L=()=>{const _=!!r,X=Array.isArray(g)&&g.length>0,te=d.isValidElement(g)?!0:X;if(!_&&!te&&!A)return null;const z=b||!b&&X;return e.jsxs(x.Box,{direction:"column",gap:"xs",paddingBlock:(S==null?void 0:S.paddingBlock)??"sm",paddingInline:(S==null?void 0:S.paddingInline)??"md",...S,style:{...l?{boxShadow:"inset 0 -1px 0 0 var(--sa-border-subtle, #0b120e24)"}:{},...S==null?void 0:S.style},children:[A&&R(),(_||te)&&e.jsxs(x.Box,{direction:z?"row":"column",gap:"sm",justify:"space-between",align:z?"center":"flex-start",children:[_?typeof r=="string"?e.jsxs(x.Box,{direction:"row",gap:"lg",align:"center",children:[e.jsxs(x.Box,{direction:"row",gap:"sm",align:"center",children:[n&&e.jsx(E.Icon,{name:n,size:"md",color:"primary"}),e.jsx(v.Text,{variant:"h3",fontWeight:"semibold",children:r})]}),s&&e.jsx(it.Badge,{border:!0,size:"lg",text:s,...m})]}):r:null,C()]})]})},U=()=>{if(!f||f.length===0)return null;const _=f.filter(V=>V.show!==!1);if(_.length===0)return null;let X=0,te=-1/0;return _.forEach((V,z)=>{const P=V.order??0;P>=te&&(te=P,X=z)}),_.map(({content:V,order:z,borderBottom:P=!0,keepBottomPadding:se=!1,paddingInline:ye=!0,paddingBlock:Se=!0},xe)=>e.jsx(x.Box,{direction:"column",paddingTop:Se?"sm":"spacing-0",paddingBottom:Se&&(P||se||xe===X)?"sm":"spacing-0",paddingInline:ye?"md":"spacing-0",style:{...P?{boxShadow:"inset 0 -1px 0 0 var(--sa-border-subtle, #0b120e24)"}:{},...z!==void 0?{order:z}:{}},children:V},`sub-header-${xe}`))},J=()=>{const _=i?L():null,X=U();return!_&&!X?null:e.jsxs(x.Box,{direction:"column",style:{...a?{position:"sticky",left:0,...u?{top:0}:{},zIndex:2,background:"var(--sa-background-primary, #ffffff)"}:{},marginBottom:X?"var(--sa-spacing-0)":"var(--sa-spacing-md)"},children:[_,X]})},N=()=>o;return e.jsxs(x.Box,{direction:"column",as:"main",...p,style:{...a?{height:"100%",minHeight:0,overflow:"auto"}:{},...(p==null?void 0:p.style)??{},...c?{}:{animation:"pageLayoutEnter 320ms cubic-bezier(0.16, 1, 0.3, 1) backwards"}},children:[J(),N()]},D.pathname)},ks=d.memo(Ss),Bs={icon:"Cross",title:""},Es=320,kn=16,Bn=4,Fs=8,co=d.forwardRef(({onHide:t,show:r,withBlur:n=!1,style:s,children:o,closeButton:i=Bs,paddingHorizontal:l=!0,width:c,minWidth:a,maxWidth:u,hideBackdrop:f=!1,title:g,headerAction:m,header:p=!0,widthPresets:S,resizable:b=!0,resizeMin:I=Es,resizeMax:B,onWidthChange:F},w)=>{const A=!Ce.useMediaQuery("md"),O=c??u??a??"357px",C=S??[],R=C.length>1,[L,U]=d.useState(()=>{const Y=C.indexOf(O);return Y>=0?Y:0}),[J,N]=d.useState(null),[_,X]=d.useState(!1),[te,V]=d.useState(!1),z=d.useRef(null),P=Y=>{z.current=Y,typeof w=="function"?w(Y):w&&(w.current=Y)},se=R?C[L]:O,ye=J!=null?`${J}px`:se,Se=b&&!A,xe=L===C.length-1,pe=()=>{const Y=(L+1)%C.length;N(null),U(Y),F==null||F(C[Y])},je=d.useCallback(Y=>{const he=B??window.innerWidth;return Math.min(Math.max(Y,I),he)},[I,B]),be=d.useRef(null),Te=Y=>{if(!Se)return;Y.preventDefault();const he=Y.currentTarget;he.setPointerCapture(Y.pointerId),X(!0);const Oe=document.body.style.cursor,Ne=document.body.style.userSelect;document.body.style.cursor="col-resize",document.body.style.userSelect="none";let ae=null;const _e=W=>{const $=je(window.innerWidth-W.clientX);be.current=$,ae==null&&(ae=window.requestAnimationFrame(()=>{ae=null,be.current!=null&&N(be.current)}))},tt=W=>{ae!=null&&window.cancelAnimationFrame(ae),be.current!=null&&N(be.current),he.releasePointerCapture(W.pointerId),he.removeEventListener("pointermove",_e),he.removeEventListener("pointerup",tt),he.removeEventListener("pointercancel",tt),document.body.style.cursor=Oe,document.body.style.userSelect=Ne,X(!1),be.current!=null&&(F==null||F(`${be.current}px`))};he.addEventListener("pointermove",_e),he.addEventListener("pointerup",tt),he.addEventListener("pointercancel",tt)},ke=Y=>{var ae;if(!Se||Y.key!=="ArrowLeft"&&Y.key!=="ArrowRight")return;Y.preventDefault();const he=Y.key==="ArrowLeft"?kn:-kn,Oe=J??((ae=z.current)==null?void 0:ae.offsetWidth)??I,Ne=je(Oe+he);N(Ne),F==null||F(`${Ne}px`)},He=()=>{Se&&(N(null),F==null||F(se))};return e.jsx(Gt.Drawer,{blur:n,isShow:r,position:"right",onHide:t,ref:P,size:ye,style:s,flush:!0,radius:"none",hideBackdrop:f,children:e.jsxs(x.Box,{direction:"column",height:"height-full",children:[Se?e.jsx("div",{role:"separator","aria-orientation":"vertical","aria-label":"Ubah lebar panel",tabIndex:0,onPointerDown:Te,onKeyDown:ke,onDoubleClick:He,title:"Tarik untuk mengubah lebar — klik dua kali untuk reset",onPointerEnter:()=>V(!0),onPointerLeave:()=>V(!1),style:{position:"absolute",left:0,top:0,bottom:0,width:Fs,cursor:"col-resize",zIndex:1,background:_||te?`linear-gradient(to right, var(--sa-border-brand, var(--sa-border-subtle)) 0 ${Bn}px, transparent ${Bn}px)`:"transparent",transition:"background 0.15s",touchAction:"none"}}):null,p?e.jsxs(x.Box,{direction:"row",align:"center",justify:"space-between",gap:"sm",paddingInline:"md",borderWidth:"border-b",borderStyle:"border-solid-b",borderColor:"border-base",customHeight:"var(--app-header-height, 44px)",flexShrink:"0",children:[e.jsx(x.Box,{direction:"row",align:"center",gap:"sm",overflow:"overflow-hidden",children:typeof g=="string"?e.jsx(v.Text,{fontSize:"md",fontWeight:"bold",children:g}):g}),e.jsxs(x.Box,{direction:"row",align:"center",gap:"sm",flexShrink:"0",children:[m,R?e.jsx(H.Button,{variant:"tertiary",tone:"neutral",size:"xs",onClick:pe,"aria-label":xe?"Kecilkan panel":"Lebarkan panel",iconRight:e.jsx(E.Icon,{name:xe?"ChevronRight":"ChevronLeft"})}):null,i?e.jsx(H.Button,{variant:"tertiary",tone:"neutral",size:"xs",onClick:t,"aria-label":i.title||"Tutup",iconRight:e.jsx(E.Icon,{name:i.icon}),children:i.title||void 0}):null]})]}):null,e.jsx(x.Box,{direction:"column",paddingBlock:"md",paddingInline:l?"md":"spacing-0",overflow:"overflow-y-auto",style:{flex:1,minHeight:0},children:o})]})})}),Zr=d.memo(({children:t,borderBottom:r=!0,padding:n=!0})=>{const s=Ce.useMediaQuery("lg");return e.jsx(x.Box,{direction:"column",padding:n?"md":"spacing-0",paddingLeft:n?"md":"spacing-0",paddingRight:n?"md":"spacing-0",style:r?{borderBottom:"1px solid var(--sa-border-subtle, #0b120e24)"}:void 0,children:t})}),Gr=d.memo(({children:t,borderTop:r=!0,padding:n=!0})=>{const s=Ce.useMediaQuery("lg");return e.jsx(x.Box,{direction:"column",padding:n?"md":"spacing-0",paddingLeft:n?"md":"spacing-0",paddingRight:n?"md":"spacing-0",style:r?{borderTop:"1px solid var(--sa-border-subtle, #0b120e24)"}:void 0,children:t})}),Ms=d.memo(({children:t,...r})=>e.jsx(x.Box,{direction:"column",padding:"md",paddingLeft:"md",paddingRight:"md",gap:"md",...r,children:t})),Is=d.memo(({children:t,title:r,titleTag:n,action:s,header:o,footer:i,actionContainer:l,containerProps:c,bodyProps:a,headerProps:u={borderBottom:!0},footerProps:f={borderTop:!0},variantTag:g="info"})=>{const m=Ce.useMediaQuery("lg"),p=()=>n?e.jsxs(x.Box,{direction:"row",gap:"sm",align:"center",children:[e.jsx(v.Text,{fontWeight:"medium",children:r}),e.jsx(it.Badges,{border:!0,text:n,variant:g})]}):e.jsx(v.Text,{fontWeight:"medium",children:r}),S=()=>o||e.jsxs(x.Box,{direction:"row",justify:"space-between",align:"flex-start",gap:"md",children:[e.jsx(x.Box,{direction:"column",children:r?p():null}),e.jsx(x.Box,{direction:"column",style:m?{width:"100%",maxWidth:"19.313rem"}:{flex:1},...l,children:s??null})]}),b=!!(o||r||s);return e.jsxs(x.Box,{direction:"column",bg:"white",borderRadius:"rounded-xs",as:"section",borderWidth:"border",borderStyle:"border-solid",borderColor:"border-base",...c,style:{backgroundColor:"var(--sa-background-primary, #ffffff)",...(c==null?void 0:c.style)??{}},children:[o!==null&&b?e.jsx(Zr,{...u,children:S()}):null,e.jsx(Ms,{...a,children:t}),i?e.jsx(Gr,{...f,children:i}):null]})}),Ls=t=>e.jsx(v.Text,{variant:"h1",children:t.children,...t.props}),Ts=t=>e.jsx(v.Text,{variant:"h2",children:t.children,...t.props}),Os=t=>e.jsx(v.Text,{variant:"h3",children:t.children,...t.props}),Rs=t=>e.jsx(v.Text,{variant:"h4",children:t.children,...t.props}),As=t=>e.jsx(v.Text,{variant:"h5",children:t.children,...t.props}),Ws=t=>e.jsx(v.Text,{variant:"h6",children:t.children,...t.props}),zs=t=>e.jsx(v.Text,{variant:"sub-h1",children:t.children,...t.props}),Hs=t=>e.jsx(v.Text,{variant:"sub-h2",children:t.children,...t.props}),Ps=t=>e.jsx(v.Text,{variant:"sub-h3",children:t.children,...t.props}),Vs=t=>e.jsx(v.Text,{variant:"body-1",children:t.children,...t.props}),Ns=t=>e.jsx(v.Text,{variant:"body-2",children:t.children,...t.props}),_s=t=>e.jsx(v.Text,{variant:"body-3",children:t.children,...t.props}),Xe={H1:Ls,H2:Ts,H3:Os,H4:Rs,H5:As,H6:Ws,SubH1:zs,SubH2:Hs,SubH3:Ps,Body1:Vs,Body2:Ns,Body3:_s},Ve=()=>{const{useSearchParams:t,useParams:r,useLocation:n}=ot(),[s,o]=t(),i=bt.searchParamsToObject(s.toString()),l=r(),c=n(),a=l.id;return{setSearchParams:o,searchParams:s,searchQueries:i,isHasQuery:(p,S)=>s.has(p)&&s.get(p)===S,getQueryParam:p=>s.get(p),getRouteParam:p=>l[p],params:l,location:c,id:a,hasId:!!a}},ao=t=>JSON.stringify(t),uo=t=>JSON.stringify(t),xo=t=>JSON.stringify(t),ho=t=>JSON.stringify(t),qs=t=>t,Zs=t=>JSON.stringify(t),It=({value:t,name:r,type:n,withSearchParam:s=!0,setSearchParams:o,searchQueries:i,dropdownSearchKey:l,filterKey:c="filter",pageKey:a="page"})=>{if(s){let u;switch(n){case"search":u=qs(t);break;case"dropdown":case"dropdown-multiple":u=ao(t);break;case"radio":u=uo(t);break;case"date-range":u=xo(t);break;case"advanced-date-range":u=Zs(t);break;case"date":u=ho(t);break;default:u=t;break}if(typeof u<"u"){const g={...i[c]&&typeof i[c]=="string"?JSON.parse(i[c]):void 0,[r]:u},m={...i};l&&typeof l=="string"&&delete m[l],delete m[a];const p={...m,[c]:JSON.stringify(g)},S=new URLSearchParams(i).toString(),b=new URLSearchParams(p).toString();if(S===b)return;o(p)}}},qt=({name:t,filterKey:r="filter",searchParams:n,get:s})=>{const o=n.get(r)||void 0,i=o&&typeof o=="string"?JSON.parse(o):void 0,l=i?i[t]:void 0;return s==="label"&&l?JSON.parse(l)[0].label:s==="value"&&l?JSON.parse(l)[0].value:l},fo=({name:t,filterKey:r="filter",searchParams:n,get:s})=>{const o=n.get(r)||void 0,i=o&&typeof o=="string"?JSON.parse(o):void 0,l=i?i[t]:void 0;return s==="label"&&l?JSON.parse(l).map(c=>c.label):s==="value"&&l?JSON.parse(l).map(c=>c.value):s==="array"&&l?JSON.parse(l):l},Gs=({name:t,filterKey:r="filter",searchParams:n,get:s})=>{const o=n.get(r)||void 0,i=o&&typeof o=="string"?JSON.parse(o):void 0,l=i?i[t]:void 0;return s==="id"&&l?JSON.parse(l).id:s==="label"&&l?JSON.parse(l).label:s==="value"&&l?JSON.parse(l).value:l},Xt=(t,r,n)=>{const s=r.get(n||"filter")||void 0,o=s&&typeof s=="string"?JSON.parse(s):void 0;return o?o[t]:void 0},Qs=({name:t,filterKey:r="filter",searchParams:n})=>{const s=n.get(r||"filter")||void 0,o=s&&typeof s=="string"?JSON.parse(s):void 0,i=o?o[t]:void 0;return{start:i?JSON.parse(i).from:void 0,end:i?JSON.parse(i).to:void 0}},mo=({name:t,filterKey:r="filter",searchParams:n})=>{const s=n.get(r||"filter")||void 0,o=s&&typeof s=="string"?JSON.parse(s):void 0,i=o?o[t]:void 0;return i?JSON.parse(i):void 0},Us=(t,{filterKey:r="filter",perPageKey:n="perPage",pageKey:s="page"})=>{const o=t.get(r)||void 0,i=t.get(n)||void 0,l=t.get(s)||void 0;return!!o||!!i||!!l},go=({isOpen:t,onClose:r,filterKey:n,pageKey:s,filters:o})=>{const{searchParams:i,setSearchParams:l,searchQueries:c}=Ve(),[a,u]=d.useState({}),f=()=>{i.delete(n||"filter"),l(i)},g=(m,p)=>{switch(m.type){case"radio":{const{show:S=!0}=m;return S&&e.jsx(x.Box,{direction:"column",children:e.jsx(x.Box,{direction:"column",children:m.title})},p)}case"dropdown":{const{show:S=!0}=m;return S&&e.jsx(x.Box,{direction:"column",children:e.jsx(x.Box,{direction:"column",children:m.title})},p)}case"date-range":return e.jsx(x.Box,{direction:"column",children:e.jsx(x.Box,{direction:"column",children:m.title})},p);case"date":return e.jsx(x.Box,{direction:"column",children:e.jsx(x.Box,{direction:"column",children:m.title})},p);case"dropdown-multiple":{const{show:S=!0}=m;return S&&e.jsx(x.Box,{direction:"column",children:e.jsx(x.Box,{direction:"column",children:m.title})},p)}default:return null}};return e.jsx(co,{onHide:r,show:t||!1,children:e.jsxs(x.Box,{direction:"column",gap:"md",children:[e.jsxs(ce.Flex,{direction:"row",justify:"space-between",align:"center",children:[e.jsx(x.Box,{direction:"column",children:"Filter"}),e.jsx(x.Box,{direction:"column",style:{cursor:"pointer"},onClick:f,children:"Reset"})]}),o==null?void 0:o.map((m,p)=>g(m,p))]})})},yo=({searchKey:t="q",statusKey:r="status",searchPlaceholder:n="Search",searchHighlightPlaceholder:s,extendedFilter:o,showSearchFilter:i=!0,showStatusFilter:l=!0,filterKey:c="filter",pageKey:a="page",customWidthSearch:u,handleOnReset:f,filterConfigs:g,buttonToggleProps:m,position:p="right",titleSearchLabel:S="Work Order",withTitleLabels:b=!1})=>{const B=(m==null?void 0:m.isShowLabel)??!0,[F,w]=d.useState(!1),[D,A]=d.useState(0),O=()=>{A(P=>P+1)},{searchParams:C,setSearchParams:R,getQueryParam:L}=Ve(),U=bt.searchParamsToObject(C.toString()),J=Xt(t,C,c)||"",[N,_]=d.useState(J),X=L(c),V=!!(X&&!(()=>{if(X)try{const P=JSON.parse(X);return Object.keys(P).length===1&&P[t]===""}catch(P){console.error("Filter parameter is not a valid JSON:",P)}return!1})()),z=Ce.useMediaQuery("md");return d.useEffect(()=>{_(J)},[J]),d.useEffect(()=>{if(N===J)return;const P=window.setTimeout(()=>{It({value:N,name:t,type:"search",searchQueries:U,setSearchParams:R,filterKey:c,pageKey:a})},350);return()=>{window.clearTimeout(P)}},[N,J,t,U,R,c,a]),e.jsxs(ce.Flex,{gap:"md",style:{flexDirection:z&&p==="left"?"row":z&&p==="right"?"row-reverse":"column"},align:"flex-end",children:[V&&e.jsx(x.Box,{direction:"column",justify:"flex-end",children:e.jsx(H.Button,{onClick:()=>{const P=new URLSearchParams(C);P.delete(c),R(P),_(""),O(),f&&f()},variant:"outline",tone:"neutral",children:e.jsx(v.Text,{color:"error",fontWeight:"semibold",children:"Reset"})})}),o==null?void 0:o.map(({minWidth:P,content:se,title:ye,onClickContainer:Se},xe)=>e.jsxs(x.Box,{direction:"column",gap:"sm",onClick:Se,style:{minWidth:P},children:[ye&&e.jsx(Xe.SubH3,{children:ye}),se]},`extended-filter-${xe}-${D}`)),!!(g!=null&&g.length)&&e.jsx(H.Button,{primary:V,secondary:!V,iconLeft:e.jsx(E.Icon,{size:"sm",name:(m==null?void 0:m.icon)||"FilterHorizontal",style:{color:X?"var(--sa-background-brand, #04254f)":"var(--sa-text-primary, #292a2e)"}}),fullWidth:!z,onClick:()=>w(!0),children:B?"Filter":void 0}),l&&e.jsxs(x.Box,{direction:"column",gap:"sm",style:{minWidth:"126px"},children:[b&&e.jsx(Xe.SubH3,{children:"Status"}),e.jsx(jt.Dropdown,{dropdownLists:[{label:"Active",value:"active"},{label:"InActive",value:"inactive"}],defaultValue:qt({get:"value",name:r,searchParams:C,filterKey:c})?[{label:qt({get:"value",name:r,searchParams:C,filterKey:c})==="active"?"Active":"InActive",value:qt({get:"value",name:r,searchParams:C,filterKey:c})}]:[],onChange:P=>It({value:P,name:r,type:"dropdown",searchQueries:U,setSearchParams:R,filterKey:c}),placeholder:b?"All":"All Status"},D)]}),i&&e.jsxs(x.Box,{direction:"column",gap:"sm",style:{width:u&&z?u:z?"310px":""},children:[b&&e.jsxs(Xe.SubH3,{children:["Search for ",S]}),e.jsx(dt.Input,{placeholder:n,leftIcon:e.jsx(E.Icon,{name:"Search",width:20,height:20}),onChange:P=>_(P.target.value),value:N,fullWidth:!0},D+1+c)]}),e.jsx(go,{isOpen:F,onClose:()=>w(!1),filterKey:c,filters:g,pageKey:a})]})},Js=t=>t==="checkbox-multiple"?"dropdown-multiple":t==="radio"?"dropdown":t==="date-compact"?"date":t;function Qr({configs:t,filterKey:r="filter",activeFilterKey:n="filters",pageKey:s="page",searchKey:o="q"}){const{searchParams:i,setSearchParams:l,searchQueries:c}=Ve(),a=d.useMemo(()=>Object.fromEntries(t.map(D=>[D.key,D])),[t]),u=d.useMemo(()=>{const D=(i.get(n)||"").split(",").map(O=>O.trim()).filter(Boolean);let A=[];try{const O=i.get(r);O&&(A=Object.keys(JSON.parse(O)).filter(C=>C!==o))}catch{}return t.map(O=>O.key).filter(O=>{const C=a[O];return(C==null?void 0:C.locked)||D.includes(O)||A.includes(O)})},[i,n,r,o,t,a]),f=d.useCallback(D=>{try{return D[r]?JSON.parse(D[r]):{}}catch{return{}}},[r]),g=d.useCallback(D=>{const A={...c};D.length?A[n]=D.join(","):delete A[n],l(A)},[c,n,l]),m=d.useCallback(D=>{u.includes(D)||g([...u,D])},[u,g]),p=d.useCallback(D=>{var R;if((R=a[D])!=null&&R.locked)return;const A={...c},O=u.filter(L=>L!==D);O.length?A[n]=O.join(","):delete A[n];const C=f(A);D in C&&(delete C[D],Object.keys(C).length?A[r]=JSON.stringify(C):delete A[r]),delete A[s],l(A)},[c,u,n,r,s,f,l,a]),S=d.useCallback(D=>u.includes(D)?p(D):m(D),[u,m,p]),b=d.useCallback(D=>{switch(D.type){case"dropdown":case"dropdown-multiple":case"checkbox-multiple":case"radio":return fo({name:D.key,get:"array",searchParams:i,filterKey:r})||[];case"date":{const A=mo({name:D.key,searchParams:i,filterKey:r});return A?new Date(A):void 0}case"date-compact":{const O=f(Object.fromEntries(i.entries()))[D.key];return O&&typeof O=="object"?O:void 0}default:return}},[i,r,f]),I=d.useCallback((D,A)=>{if(D.type==="date-compact"){const O={...c},C=f(O);A==null?delete C[D.key]:C[D.key]=A,Object.keys(C).length?O[r]=JSON.stringify(C):delete O[r],delete O[s],l(O);return}It({value:A,name:D.key,type:Js(D.type),searchQueries:c,setSearchParams:l,filterKey:r,pageKey:s})},[c,l,r,s,f]),B=d.useCallback(D=>{const A={...c},O=f(A);D in O&&(delete O[D],Object.keys(O).length?A[r]=JSON.stringify(O):delete A[r]),delete A[s],l(A)},[c,r,s,f,l]),F=d.useCallback(()=>{const D={...c};delete D[r],delete D[n],delete D[s],l(D)},[c,r,n,s,l]),w=u.length>0;return{activeKeys:u,configByKey:a,hasActiveFilter:w,addFilter:m,removeFilter:p,toggleFilter:S,getValue:b,setValue:I,clearValue:B,clearAll:F}}const Ur={get(t){return Ft.storage.get(t)??null},set(t,r){Ft.storage.save(t,r)},remove(t){Ft.storage.delete(t)}},Ct={columns:t=>`filterbar:colprefs:${t}`,savedViews:t=>`filterbar:views:${t}`,lastState:t=>`filterbar:last:${t}`,perPage:t=>`filterbar:perpage:${t}`,tableSort:t=>`tablelayout:sort:${t}`},zt=(t,r)=>{const n=new Set(r.map(i=>i.key)),s=t.order.filter(i=>n.has(i));for(const i of r)s.includes(i.key)||s.push(i.key);const o=t.hidden.filter(i=>n.has(i));return{order:s,hidden:o}};function Ys({columns:t,scopeId:r,storage:n,onColumnsChange:s,value:o}){const i=d.useMemo(()=>({order:t.map(C=>C.key),hidden:[]}),[t]),l=r?Ct.columns(r):void 0,c=(C,R)=>zt({order:C.order??R,hidden:C.hidden??[]},t),[a,u]=d.useState(()=>{if(o&&(o.order||o.hidden))return c(o,t.map(C=>C.key));if(l){const C=n.get(l);if(C&&Array.isArray(C.order))return zt(C,t)}return i}),f=t.map(C=>C.key).join("|");d.useEffect(()=>u(C=>zt(C,t)),[f]);const g=d.useRef(a);g.current=a;const m=o?`${(o.order??[]).join("|")}~${(o.hidden??[]).join("|")}`:null,p=d.useRef(m);d.useEffect(()=>{if(m==null||p.current===m)return;p.current=m;const C=g.current,R=c(o,C.order);R.order.join("|")===C.order.join("|")&&R.hidden.join("|")===C.hidden.join("|")||(u(R),l&&n.set(l,R))},[m,f]);const S=d.useRef(!1);d.useEffect(()=>{S.current||(S.current=!0,s==null||s(a))},[]);const b=d.useCallback(C=>{u(C),l&&n.set(l,C),s==null||s(C)},[l,n,s]),I=d.useMemo(()=>{const C=new Map(t.map(R=>[R.key,R]));return a.order.filter(R=>C.has(R)).map(R=>({...C.get(R),visible:!a.hidden.includes(R)}))},[a,t]),B=d.useCallback(C=>{const R=a.hidden.includes(C)?a.hidden.filter(L=>L!==C):[...a.hidden,C];b({...a,hidden:R})},[a,b]),F=d.useCallback((C,R)=>{if(C===R)return;const L=[...a.order],[U]=L.splice(C,1);L.splice(R,0,U),b({...a,order:L})},[a,b]),w=d.useCallback(C=>{b({...a,hidden:C?t.filter(R=>!R.locked).map(R=>R.key):[]})},[a,t,b]),D=d.useCallback(()=>b(i),[b,i]),A=d.useCallback(C=>b(zt(C,t)),[b,t]),O=a.hidden.length===0;return{state:a,orderedColumns:I,allVisible:O,toggleVisibility:B,reorder:F,setAllHidden:w,reset:D,applyState:A}}function Xs({scopeId:t,storage:r,snapshotKeys:n,pageKey:s="page",getColumns:o,applyColumns:i}){const{searchParams:l,setSearchParams:c}=Ve(),a=t?Ct.savedViews(t):void 0,[u,f]=d.useState(()=>a?r.get(a)||[]:[]),g=d.useCallback(b=>{f(b),a&&r.set(a,b)},[a]),m=d.useCallback(b=>{const I=b.trim();if(!I)return;const B={};n.forEach(w=>{const D=l.get(w);D!=null&&(B[w]=D)});const F={id:`${Date.now()}`,name:I,query:B,columns:o==null?void 0:o(),createdAt:Date.now()};g([...u,F])},[n,l,o,g,u]),p=d.useCallback(b=>g(u.filter(I=>I.id!==b)),[g,u]),S=d.useCallback(b=>{const I=Object.fromEntries(l.entries());n.forEach(B=>delete I[B]),Object.assign(I,b.query),delete I[s],c(I),b.columns&&(i==null||i(b.columns))},[l,n,s,c,i]);return{enabled:!!a,views:u,saveView:m,deleteView:p,applyView:S}}function $s(t,r){let n;try{n=JSON.parse(t)}catch{return t}return!n||typeof n!="object"?t:(delete n[r],Object.keys(n).length>0?JSON.stringify(n):void 0)}function En(t,r,n){const s=t[r];if(s==null)return;const o=$s(s,n);o===void 0?delete t[r]:t[r]=o}function Ks({scopeId:t,storage:r,snapshotKeys:n,enabled:s=!0,filterKey:o="filter",searchKey:i="q",persistSearch:l=!0}){const{searchParams:c}=Ve(),a=t&&s?Ct.lastState(t):void 0,u=d.useRef(a),f=d.useRef(!1);d.useEffect(()=>{if(!a){u.current=a;return}if(u.current!==a){u.current=a,f.current=!1;return}const p={};if(n.forEach(S=>{const b=c.get(S);b!=null&&(p[S]=b)}),l||En(p,o,i),Object.keys(p).length===0){f.current&&r.remove(a);return}f.current=!0,r.set(a,p)},[c,a,n,r,l,o,i]);const g=d.useCallback(()=>{if(!a)return null;const p=r.get(a);return!p||Object.keys(p).length===0||!l&&(En(p,o,i),Object.keys(p).length===0)?null:p},[a,r,l,o,i]),m=d.useCallback(()=>{a&&r.remove(a)},[a,r]);return{enabled:!!a,read:g,clear:m}}function ei({scopeId:t,storage:r,perPageKey:n,pageSizeOptions:s,enabled:o=!0}){const{searchParams:i}=Ve(),l=t&&o?Ct.perPage(t):void 0,c=i.toString(),a=d.useRef(l);d.useEffect(()=>{if(!l){a.current=l;return}if(a.current!==l){a.current=l;return}const g=i.get(n);if(!g)return;const m=Number(g);!Number.isFinite(m)||m<=0||r.set(l,m)},[c,l,n,r]);const u=d.useCallback(()=>{if(!l)return null;const g=r.get(l);if(g==null)return null;const m=Number(g);return!Number.isFinite(m)||m<=0||s&&!s.includes(m)?null:String(m)},[l,r,s]),f=d.useCallback(()=>{l&&r.remove(l)},[l,r]);return{enabled:!!l,read:u,clear:f}}let pr={},jr=!1,br=null;const ti=(t,r)=>{Object.assign(pr,t),br=r,!jr&&(jr=!0,queueMicrotask(()=>{const n=pr,s=br;pr={},jr=!1,br=null,!(!s||Object.keys(n).length===0)&&s(o=>{const i=new URLSearchParams(o);return Object.entries(n).forEach(([l,c])=>i.set(l,c)),i},{replace:!0})}))};function ri({enabled:t,snapshotKeys:r,perPageKey:n,readSnapshot:s,readPerPage:o}){const{searchParams:i,setSearchParams:l,location:c}=Ve(),a=d.useRef(null);d.useEffect(()=>{if(!t||a.current===c.pathname)return;a.current=c.pathname;const u={};if(!i.has(n)){const f=o();f&&(u[n]=f)}if(!r.some(f=>i.has(f))){const f=s();f&&Object.assign(u,f)}Object.keys(u).length!==0&&ti(u,l)},[c.pathname,t])}const ni=({configs:t,activeKeys:r,onToggle:n,hasActiveFilter:s,onReset:o})=>t.length?e.jsxs(T.Menu,{position:"bottom-left",children:[e.jsx(T.MenuButton,{children:e.jsx(H.Button,{variant:s?"secondary":"outline",tone:"neutral",size:"sm",iconLeft:e.jsx(E.Icon,{name:"FilterHorizontal"}),"aria-label":"Add filter"})}),e.jsx(T.MenuLists,{children:e.jsx(T.MenuBody,{style:{minWidth:260},title:e.jsxs(x.Box,{display:"flex",direction:"row",align:"center",justify:"space-between",fullWidth:!0,children:[e.jsx(v.Text,{fontSize:"sm",fontWeight:"medium",color:"subtlest",children:"Add Filter"}),s&&o&&e.jsx(H.Button,{variant:"link",tone:"brand",size:"xs",onClick:o,children:"Reset"})]}),children:t.map(i=>e.jsx(T.MenuItem,{selected:i.locked||r.includes(i.key),disabled:i.locked,closeOnSelect:!1,startIcon:i.icon??void 0,onClick:()=>{i.locked||n(i.key)},children:i.label},i.key))})})]}):null,$t=({onClear:t,onRemove:r})=>e.jsxs(T.Menu,{position:"bottom-right",children:[e.jsx(T.MenuButton,{children:e.jsx(H.Button,{variant:"link",tone:"neutral",size:"xs",iconLeft:e.jsx(E.Icon,{name:"MenuHorizontal"}),"aria-label":"Filter actions"})}),e.jsx(T.MenuLists,{children:e.jsxs(T.MenuBody,{style:{width:180},children:[e.jsx(T.MenuItem,{startIcon:e.jsx(E.Icon,{name:"CrossCircle"}),onClick:t,children:"Clear value"}),r&&e.jsx(T.MenuItem,{intent:"danger",startIcon:e.jsx(E.Icon,{name:"Trash1"}),onClick:r,children:"Remove filter"})]})})]}),oi=t=>{const r=new Date(t);return r.setHours(0,0,0,0),r},Fn=(t,r,n)=>{const s=new Date(t);return n==="day"?s.setDate(s.getDate()+r):n==="week"?s.setDate(s.getDate()+r*7):n==="month"?s.setMonth(s.getMonth()+r):s.setFullYear(s.getFullYear()+r),s},po=t=>{const r=oi(new Date);if(t.direction==="this"){const s=new Date(r),o=new Date(r);return t.period==="week"?(s.setDate(r.getDate()-r.getDay()),o.setDate(s.getDate()+6)):t.period==="month"?(s.setDate(1),o.setMonth(o.getMonth()+1,0)):t.period==="year"&&(s.setMonth(0,1),o.setMonth(11,31)),{from:s,to:o}}const n=t.count??1;return t.direction==="past"?{from:Fn(r,-n,t.period),to:r}:{from:r,to:Fn(r,n,t.period)}},Mn=24,jo=t=>t.length>Mn?`${t.slice(0,Mn)}...`:t,bo=t=>t.toLocaleDateString(void 0,{day:"2-digit",month:"short",year:"numeric"}),vr=(t,r="days")=>r==="months"?t.toLocaleDateString(void 0,{month:"short",year:"numeric"}):r==="years"?String(t.getFullYear()):bo(t),Ut={is:"Is","is-before":"Is before","is-after":"Is after","is-on-or-before":"Is on or before","is-on-or-after":"Is on or after","is-between":"Is between","is-relative-to-today":"Is relative to today","is-empty":"Is empty","is-not-empty":"Is not empty"},si=["is","is-before","is-after","is-on-or-before","is-on-or-after","is-between","is-relative-to-today","is-empty","is-not-empty"],Or={past:"Past",next:"Next",this:"This"},ii=["day","week","month","year"],li=["past","next","this"],ci=t=>t.field.type==="date-compact"?e.jsx(ui,{field:t.field,value:t.value,onChange:t.onChange,onClear:t.onClear,onRemove:t.onRemove}):e.jsx(ai,{field:t.field,value:t.value,onChange:t.onChange,onClear:t.onClear,onRemove:t.onRemove}),ai=({field:t,value:r,onChange:n,onClear:s,onRemove:o})=>{const i=r?bo(new Date(r)):null,l=!!i,c=l?e.jsxs(e.Fragment,{children:[e.jsxs("span",{style:{fontWeight:500},children:[t.label,":"]})," ",e.jsx("span",{style:{fontWeight:400},children:jo(i)})]}):t.label;return e.jsxs(T.Menu,{position:"bottom-left",children:[e.jsx(T.MenuButton,{children:e.jsx(H.Button,{variant:l?"secondary":"outline",tone:"neutral",size:"sm",iconLeft:l?e.jsx(E.Icon,{name:"Calendar",size:"sm"}):void 0,iconRight:e.jsx(E.Icon,{name:"ChevronSmallDown"}),children:c})}),e.jsx(T.MenuLists,{children:e.jsx(T.MenuBody,{style:{width:260},title:e.jsxs(x.Box,{display:"flex",direction:"row",align:"center",justify:"space-between",fullWidth:!0,children:[e.jsx(v.Text,{fontSize:"sm",fontWeight:"medium",color:"subtlest",children:t.label}),e.jsx($t,{onClear:s,onRemove:o})]}),children:e.jsx(ht.StarasiaDate,{size:"sm",input:!1,clearable:!0,filter:t.mode,value:r,onChange:a=>a==null?s():n(a),withPadding:!1})})})]})},di=(t,r="days")=>{switch(t.op){case"is":case"is-before":case"is-after":case"is-on-or-before":case"is-on-or-after":return t.date?`${Ut[t.op]} ${vr(new Date(t.date),r)}`:null;case"is-between":return t.from&&t.to?`${vr(new Date(t.from),r)} - ${vr(new Date(t.to),r)}`:null;case"is-relative-to-today":{const n=t.relative;if(!n)return null;if(n.direction==="this")return`This ${n.period}`;const s=n.count??1,o=s===1?n.period:`${n.period}s`;return`${Or[n.direction]} ${s} ${o}`}case"is-empty":case"is-not-empty":return Ut[t.op];default:return null}},ui=({field:t,value:r,onChange:n,onClear:s,onRemove:o})=>{const i=t.ops&&t.ops.length>0?t.ops:si,l=t.defaultOp&&i.includes(t.defaultOp)?t.defaultOp:i[0],c=t.mode??"days",a=(r==null?void 0:r.op)??l,u=r?di(r,c):null,f=!!u,g=f?e.jsxs(e.Fragment,{children:[e.jsxs("span",{style:{fontWeight:500},children:[t.label,":"]})," ",e.jsx("span",{style:{fontWeight:400},children:jo(u)})]}):t.label,m=p=>{if(p!==a){if(p==="is-empty"||p==="is-not-empty"){n({op:p});return}if(p==="is-relative-to-today"){n({op:p,relative:(r==null?void 0:r.relative)??{direction:"past",count:1,period:"week"}});return}if(p==="is-between"){n({op:p,from:r==null?void 0:r.from,to:r==null?void 0:r.to});return}n({op:p,date:r==null?void 0:r.date})}};return e.jsxs(T.Menu,{position:"bottom-left",children:[e.jsx(T.MenuButton,{children:e.jsx(H.Button,{variant:f?"secondary":"outline",tone:"neutral",size:"sm",iconLeft:f?e.jsx(E.Icon,{name:"Calendar",size:"sm"}):void 0,iconRight:e.jsx(E.Icon,{name:"ChevronSmallDown"}),children:g})}),e.jsxs(T.MenuLists,{children:[e.jsx(T.MenuBody,{style:{width:320},title:e.jsxs(x.Box,{display:"flex",direction:"row",align:"center",justify:"space-between",gap:"xs",fullWidth:!0,children:[e.jsxs(x.Box,{display:"flex",direction:"row",align:"center",gap:"xs",style:{minWidth:0},children:[e.jsx(v.Text,{fontSize:"sm",fontWeight:"medium",color:"subtlest",children:t.label}),e.jsx(xi,{op:a,ops:i,onChange:m})]}),e.jsx($t,{onClear:s,onRemove:o})]}),children:e.jsx(hi,{value:r,op:a,mode:c,onChange:n})}),a==="is-relative-to-today"&&e.jsx(T.MenuFooter,{children:e.jsx(v.Text,{fontSize:"xs",color:"subtlest",children:"Filter will update with the current date"})})]})]})},xi=({op:t,ops:r,onChange:n})=>e.jsxs(T.Menu,{position:"bottom-left",children:[e.jsx(T.MenuButton,{children:e.jsx(H.Button,{variant:"link",tone:"neutral",size:"xs",iconRight:e.jsx(E.Icon,{name:"ChevronSmallDown"}),children:Ut[t]})}),e.jsx(T.MenuLists,{children:e.jsx(T.MenuBody,{style:{width:200},children:r.map(s=>e.jsx(T.MenuItem,{selected:t===s,onClick:()=>n(s),endIcon:t===s?e.jsx(E.Icon,{name:"Check"}):void 0,children:Ut[s]},s))})})]}),hi=({value:t,op:r,mode:n="days",onChange:s})=>{if(r==="is-empty"||r==="is-not-empty")return e.jsx(x.Box,{paddingBlock:"sm",paddingInline:"sm",children:e.jsx(v.Text,{fontSize:"xs",color:"subtlest",children:"No further input required."})});if(r==="is-between"){const o=t!=null&&t.from||t!=null&&t.to?{from:t!=null&&t.from?new Date(t.from):null,to:t!=null&&t.to?new Date(t.to):null}:void 0;return e.jsx(ht.StarasiaDate,{size:"sm",input:!1,clearable:!0,rangedDate:!0,filter:n,value:o,onChange:i=>{if(i==null){s({op:r});return}if(typeof i=="object"&&i!==null&&"from"in i&&"to"in i){let{from:l,to:c}=i;if(!l&&c&&(l=c,c=null),!l&&!c){s({op:r});return}s({op:r,from:l?l.toISOString():void 0,to:c?c.toISOString():void 0})}},withPadding:!1},`range-${n}`)}return r==="is-relative-to-today"?e.jsx(fi,{value:t==null?void 0:t.relative,onChange:o=>s({op:r,relative:o})}):e.jsx(ht.StarasiaDate,{size:"sm",input:!1,clearable:!0,filter:n,value:t!=null&&t.date?new Date(t.date):void 0,onChange:o=>{if(o==null){s({op:r});return}o instanceof Date&&s({op:r,date:o.toISOString()})},withPadding:!1},`single-${n}`)},fi=({value:t,onChange:r})=>{const n=(t==null?void 0:t.direction)??"past",s=(t==null?void 0:t.count)??1,o=(t==null?void 0:t.period)??"week",i=n!=="this",l=po({direction:n,count:s,period:o});return e.jsxs(x.Box,{direction:"column",display:"flex",gap:"sm",children:[e.jsxs(x.Box,{direction:"row",display:"flex",align:"center",gap:"xs",children:[e.jsxs(T.Menu,{position:"bottom-left",children:[e.jsx(T.MenuButton,{children:e.jsx(H.Button,{variant:"outline",tone:"neutral",size:"sm",iconRight:e.jsx(E.Icon,{name:"ChevronSmallDown"}),children:Or[n]})}),e.jsx(T.MenuLists,{children:e.jsx(T.MenuBody,{style:{width:140},children:li.map(c=>e.jsx(T.MenuItem,{selected:n===c,endIcon:n===c?e.jsx(E.Icon,{name:"Check"}):void 0,onClick:()=>r(c==="this"?{direction:c,period:o}:{direction:c,count:s,period:o}),children:Or[c]},c))})})]}),i&&e.jsx(dt.Input,{type:"number",size:"sm",min:1,clearable:!1,value:s,onChange:c=>{const a=Number(c.target.value);r({direction:n,count:Number.isFinite(a)&&a>0?a:1,period:o})},style:{width:72}}),e.jsxs(T.Menu,{position:"bottom-left",children:[e.jsx(T.MenuButton,{children:e.jsx(H.Button,{variant:"outline",tone:"neutral",size:"sm",iconRight:e.jsx(E.Icon,{name:"ChevronSmallDown"}),children:o})}),e.jsx(T.MenuLists,{children:e.jsx(T.MenuBody,{style:{width:140},children:ii.map(c=>e.jsx(T.MenuItem,{selected:o===c,endIcon:o===c?e.jsx(E.Icon,{name:"Check"}):void 0,onClick:()=>r(n==="this"?{direction:n,period:c}:{direction:n,count:s,period:c}),children:c},c))})})]})]}),e.jsx(ht.StarasiaDate,{size:"sm",input:!1,disabled:!0,rangedDate:!0,value:l,onChange:()=>{},withPadding:!1},"relative-preview")]})},In=18,mi=t=>t.length>In?`${t.slice(0,In)}...`:t,gi=({field:t,value:r,onChange:n,onClear:s,onRemove:o})=>{const i=t.type==="dropdown-multiple",l=r.length,c=t.searchable!==!1,[a,u]=d.useState(""),f=t.options,g=typeof t.onSearch=="function",m=(()=>{if(g)return f;const B=a.trim().toLowerCase();return B?f.filter(F=>F.label.toLowerCase().includes(B)):f})(),p=B=>r.some(F=>F.value===B.value),S=B=>{if(!i){n([{label:B.label,value:B.value}]),u("");return}n(p(B)?r.filter(F=>F.value!==B.value):[...r,{label:B.label,value:B.value}])},b=B=>{var F;u(B),(F=t.onSearch)==null||F.call(t,B)},I=l===0?t.label:e.jsxs(e.Fragment,{children:[e.jsxs("span",{style:{fontWeight:500},children:[t.label,":"]})," ",e.jsx("span",{style:{fontWeight:400},children:l===1?mi(r[0].label):`${l} Selected`})]});return e.jsxs(T.Menu,{position:"bottom-left",children:[e.jsx(T.MenuButton,{children:e.jsx(H.Button,{variant:l>0?"secondary":"outline",tone:"neutral",size:"sm",iconLeft:l>0?e.jsx(E.Icon,{name:"Tag",size:"sm"}):void 0,iconRight:e.jsx(E.Icon,{name:"ChevronSmallDown"}),children:I})}),e.jsx(T.MenuLists,{children:e.jsx(T.MenuBody,{style:{width:260},title:e.jsxs(x.Box,{display:"flex",direction:"row",align:"center",justify:"space-between",fullWidth:!0,children:[e.jsx(v.Text,{fontSize:"sm",fontWeight:"medium",color:"subtlest",children:t.label}),e.jsx($t,{onClear:s,onRemove:o})]}),children:e.jsxs(x.Box,{direction:"column",gap:"sm",children:[c&&e.jsx(jt.Dropdown,{size:"sm",triggerInput:!0,fullWidth:!0,hideChevronIcon:!0,clearable:!0,multiSelect:i,searchAble:!0,searchValue:a,onSearch:b,value:r,onChange:n,placeholder:`Search ${t.label.toLowerCase()}…`}),e.jsx(x.Box,{direction:"column",overflow:"overflow-y-auto",customMaxHeight:"240px",children:t.isLoading?e.jsx(x.Box,{paddingBlock:"sm",paddingInline:"sm",children:e.jsx(v.Text,{fontSize:"xs",color:"subtlest",children:"Loading…"})}):m.length===0?e.jsx(x.Box,{paddingBlock:"sm",paddingInline:"sm",children:e.jsx(v.Text,{fontSize:"xs",color:"subtlest",children:"No results"})}):m.map(B=>e.jsx(T.MenuItem,{closeOnSelect:!i,selected:p(B),startIcon:B.avatar,endIcon:p(B)?e.jsx(E.Icon,{name:"Check"}):void 0,description:B.description,onClick:()=>S(B),children:B.label},B.value))})]})})})]})},Ln=18,yi=t=>t.length>Ln?`${t.slice(0,Ln)}...`:t,Tn=({checked:t,indeterminate:r})=>e.jsx("span",{style:{pointerEvents:"none",display:"inline-flex"},children:e.jsx(nt.Checkbox,{size:"sm",checked:t,readOnly:!0,onChange:()=>{},variant:r?"indeterminate":"select"})}),pi=({field:t,value:r,onChange:n,onClear:s,onRemove:o})=>{const i=new Set(r.map(m=>m.value)),l=r.length,c=t.options.length>0&&t.options.every(m=>i.has(m.value)),a=l>0&&!c,u=m=>{n(i.has(m.value)?r.filter(p=>p.value!==m.value):[...r,{label:m.label,value:m.value}])},f=()=>{n(c?[]:t.options.map(m=>({label:m.label,value:m.value})))},g=l===0?t.label:e.jsxs(e.Fragment,{children:[e.jsxs(v.Text,{as:"span",fontWeight:"semibold",children:[t.label,":"]})," ",e.jsx(v.Text,{as:"span",children:l===1?yi(r[0].label):`${l} Selected`})]});return e.jsxs(T.Menu,{position:"bottom-left",children:[e.jsx(T.MenuButton,{children:e.jsx(H.Button,{variant:l>0?"secondary":"outline",tone:"neutral",size:"sm",iconLeft:l>0?e.jsx(E.Icon,{name:"Tag",size:"sm"}):void 0,iconRight:e.jsx(E.Icon,{name:"ChevronSmallDown"}),children:g})}),e.jsx(T.MenuLists,{children:e.jsxs(T.MenuBody,{style:{width:240},title:e.jsxs(x.Box,{display:"flex",direction:"row",align:"center",justify:"space-between",fullWidth:!0,children:[e.jsx(v.Text,{fontSize:"sm",fontWeight:"medium",color:"subtlest",children:t.label}),e.jsx($t,{onClear:s,onRemove:o})]}),children:[e.jsx(T.MenuItem,{closeOnSelect:!1,selected:c,onClick:f,startIcon:e.jsx(Tn,{checked:c||a,indeterminate:a}),children:"Select All"}),t.options.map(m=>e.jsx(T.MenuItem,{closeOnSelect:!1,selected:i.has(m.value),onClick:()=>u(m),startIcon:e.jsx(Tn,{checked:i.has(m.value)}),children:m.label},m.value))]})})]})},vo=({activeKeys:t,configByKey:r,getValue:n,setValue:s,clearValue:o,removeFilter:i})=>e.jsx(e.Fragment,{children:t.map(l=>{const c=r[l];if(!c)return null;const a=n(c),u=c.locked?void 0:()=>i(l);return c.type==="date"||c.type==="date-compact"?e.jsx(ci,{field:c,value:a,onChange:f=>s(c,f),onClear:()=>o(l),onRemove:u},l):c.type==="checkbox-multiple"?e.jsx(pi,{field:c,value:a||[],onChange:f=>s(c,f),onClear:()=>o(l),onRemove:u},l):e.jsx(gi,{field:c,value:a||[],onChange:f=>s(c,f),onClear:()=>o(l),onRemove:u},l)})}),On=t=>`${t} Rows`,ji=({pagination:t,pageKey:r="page",perPageKey:n="perPage",pageSizeOptions:s=[10,25,50,100],defaultPerPage:o=10,showResultCount:i=!0,showPageSize:l=!0,showPagination:c=!0})=>{var B;const{searchQueries:a,setSearchParams:u,searchParams:f}=Ve(),g=f.get(n),m=g?Number(g):o,p=F=>{u({...a,[r]:String(F)})},S=F=>{u({...a,[n]:F,[r]:"1"})},b=(t==null?void 0:t.rangeStart)??(((t==null?void 0:t.currentPage)||0)>1?(((t==null?void 0:t.currentPage)||0)-1)*((t==null?void 0:t.perPage)||0)+1:0),I=(t==null?void 0:t.rangeEnd)??((t==null?void 0:t.totalCurrentPage)!==(t==null?void 0:t.perPage)?t==null?void 0:t.totalData:((t==null?void 0:t.currentPage)||1)*((t==null?void 0:t.totalCurrentPage)||0));return e.jsxs(e.Fragment,{children:[i&&e.jsx(v.Text,{fontSize:"sm",fontWeight:"medium",color:"primary",truncate:!0,children:`${b}-${I} of ${((B=t==null?void 0:t.totalData)==null?void 0:B.toLocaleString())||0}`}),l&&e.jsxs(T.Menu,{position:"bottom-left",children:[e.jsx(T.MenuButton,{children:e.jsx(H.Button,{variant:"outline",tone:"neutral",size:"sm",iconRight:e.jsx(E.Icon,{name:"ChevronSmallDown"}),"aria-label":"Rows per page",children:On(m)})}),e.jsx(T.MenuLists,{children:e.jsx(T.MenuBody,{children:s.map(F=>e.jsx(T.MenuItem,{selected:F===m,onClick:()=>S(String(F)),children:On(F)},F))})})]}),c&&((t==null?void 0:t.totalPage)??0)>1&&e.jsx(x.Box,{direction:"column",display:"flex",align:"center",gap:"sm",paddingRight:"sm",style:{borderRight:"1px solid var(--sa-border-subtle, rgba(11, 18, 14, 0.14))"},children:e.jsx(Mt.Pagination,{size:"sm",variant:"neutral",siblingCount:0,currentPage:t!=null&&t.currentPage?Number(t.currentPage):1,totalPages:Number(t==null?void 0:t.totalPage),onPageChange:p})})]})};function bi(t,r,n=!0){d.useEffect(()=>{if(!n)return;const s=o=>{var c;if(o.metaKey||o.ctrlKey||o.altKey||o.key!==t||Pe.isOverlayOpen())return;const i=o.target,l=(c=i==null?void 0:i.tagName)==null?void 0:c.toLowerCase();l==="input"||l==="textarea"||i!=null&&i.isContentEditable||(o.preventDefault(),r())};return window.addEventListener("keydown",s),()=>window.removeEventListener("keydown",s)},[t,r,n])}const vi=240,Co=({searchKey:t="q",filterKey:r="filter",pageKey:n="page",placeholder:s="Search",shortcut:o="/",collapsible:i=!0})=>{const{searchParams:l,setSearchParams:c,searchQueries:a}=Ve(),u=Xt(t,l,r)||"",[f,g]=d.useState(!i||!!u),[m,p]=d.useState(i&&!u),[S,b]=d.useState(u),I=Ce.useDebounce(S,350),B=d.useRef(null);d.useEffect(()=>{b(u),u&&g(!0)},[u]),d.useEffect(()=>{f&&p(!1)},[f]),d.useEffect(()=>{I!==u&&It({value:I,name:t,type:"search",searchQueries:a,setSearchParams:c,filterKey:r,pageKey:n})},[I]);const F=d.useCallback(()=>{g(!0),requestAnimationFrame(()=>{var O;return(O=B.current)==null?void 0:O.focus()})},[]);bi(o,F);const w=()=>{i&&!S&&g(!1)},D=O=>{var C;i&&O.key==="Escape"&&!S&&(g(!1),(C=B.current)==null||C.blur())},A=()=>{f||p(!0)};return e.jsxs(x.Box,{display:"flex",direction:"row",align:"center",gap:"spacing-0",children:[m&&e.jsx(H.Button,{variant:"outline",tone:"neutral",size:"sm",iconLeft:e.jsx(E.Icon,{name:"Search",size:"sm"}),"aria-label":"Search","aria-expanded":!1,onClick:F}),e.jsxs(x.Box,{onTransitionEnd:A,style:{position:"relative",width:f?vi:0,overflow:"hidden",transition:"width 220ms ease"},children:[e.jsx(dt.Input,{ref:B,size:"sm",fullWidth:!0,value:S,placeholder:s,leftIcon:e.jsx(E.Icon,{name:"Search",width:16,height:16}),onChange:O=>b(O.target.value),onKeyDown:D,onBlur:w,tabIndex:f?0:-1}),f&&!S&&e.jsx(x.Box,{align:"center",justify:"center",borderColor:"border-subtle",borderWidth:"border",borderStyle:"border-solid",borderRadius:"rounded-xs",paddingInline:"spacing-1",customBackgroundColor:"var(--sa-background-surface-hover, #f1f2f4)",style:{position:"absolute",right:8,top:"50%",transform:"translateY(-50%)",pointerEvents:"none",minWidth:18,height:18,display:"inline-flex"},children:e.jsx(v.Text,{fontSize:"xs",color:"subtle",children:o})})]})]})},wo=({columns:t,allVisible:r,onToggle:n,onReorder:s,onSetAllHidden:o})=>{const[i,l]=d.useState(null),[c,a]=d.useState(null),u=()=>{i!==null&&c!==null&&i!==c&&s(i,c),l(null),a(null)},f=(g,m)=>{const p=g+m;p<0||p>=t.length||s(g,p)};return e.jsxs(T.Menu,{position:"bottom-right",children:[e.jsx(T.MenuButton,{children:e.jsx(H.Button,{variant:r?"outline":"secondary",tone:"neutral",size:"sm",iconLeft:e.jsx(E.Icon,{name:"Grid",size:"sm"}),"aria-label":"Customize columns"})}),e.jsx(T.MenuLists,{children:e.jsx(T.MenuBody,{children:e.jsxs(x.Box,{padding:"sm",direction:"column",customWidth:"296px",customMaxHeight:"60vh",overflow:"overflow-hidden",children:[e.jsx(v.Text,{fontWeight:"semibold",color:"primary",children:"Customize Column Table"}),e.jsxs(x.Box,{direction:"row",display:"flex",align:"center",justify:"space-between",paddingBlock:"md",children:[e.jsx(v.Text,{fontSize:"sm",fontWeight:"medium",color:"subtle",children:"Show in table"}),e.jsx(H.Button,{variant:"link",tone:"info",size:"xs",onClick:()=>o(r),children:r?"Hide All":"Show All"})]}),e.jsx(x.Box,{direction:"column",overflow:"overflow-y-auto",children:t.map((g,m)=>{const p=!g.locked,S=c===m&&i!==null&&i!==m;return e.jsxs(x.Box,{direction:"row",display:"flex",align:"center",gap:"sm",paddingBlock:"xs",draggable:p,onDragStart:()=>p&&l(m),onDragOver:b=>{b.preventDefault(),a(m)},onDrop:u,onDragEnd:u,style:{minHeight:32,boxShadow:S?"inset 0 2px 0 0 var(--sa-background-brand, #04254f)":void 0},children:[e.jsx(x.Box,{direction:"column",as:"div",align:"center",justify:"center",role:"button",tabIndex:p?0:-1,"aria-label":`Reorder ${g.title}`,"aria-disabled":!p||void 0,color:"icon-subtlest",onKeyDown:b=>{p&&(b.key==="ArrowUp"?(b.preventDefault(),f(m,-1)):b.key==="ArrowDown"&&(b.preventDefault(),f(m,1)))},style:{display:"inline-flex",cursor:p?"grab":"default",opacity:p?1:.4},children:e.jsx(E.Icon,{name:"DragVertical",width:16,height:16})}),g.icon&&e.jsx(x.Box,{direction:"column",align:"center",color:"icon-subtle",style:{display:"inline-flex"},children:g.icon}),e.jsx(v.Text,{fontSize:"sm",fontWeight:"medium",color:"primary",truncate:!0,children:g.title}),e.jsx(x.Box,{direction:"column",style:{marginLeft:"auto"},children:e.jsx(vt.Toggle,{size:"sm",checked:g.visible,disabled:g.locked,onChange:()=>n(g.key),"aria-label":`Toggle ${g.title} column`})})]},g.key)})})]})})})]})},Do=({views:t,onApply:r,onDelete:n,onSave:s})=>{const[o,i]=d.useState(""),l=()=>{const c=o.trim();c&&(s(c),i(""))};return e.jsxs(T.Menu,{position:"bottom-right",children:[e.jsx(T.MenuButton,{children:e.jsx(H.Button,{variant:t.length>0?"secondary":"outline",tone:(t.length>0,"neutral"),size:"sm",iconLeft:e.jsx(E.Icon,{name:"Bookmark",size:"sm"}),"aria-label":"Saved views"})}),e.jsxs(T.MenuLists,{style:{width:"260px"},children:[e.jsx(T.MenuBody,{children:e.jsxs(x.Box,{direction:"column",padding:"xs",gap:"sm",children:[e.jsx(v.Text,{fontWeight:"semibold",color:"primary",children:"Saved Views"}),e.jsx(x.Box,{direction:"column",overflow:"overflow-y-auto",children:t.length===0?e.jsx(x.Box,{direction:"column",paddingBlock:"sm",children:e.jsx(v.Text,{fontSize:"sm",color:"subtlest",children:"No saved views yet"})}):t.map(c=>e.jsx(T.MenuItem,{startIcon:e.jsx(E.Icon,{name:"Bookmark"}),onClick:()=>r(c),endIcon:e.jsx(H.Button,{variant:"link",tone:"error",size:"sm",iconLeft:e.jsx(E.Icon,{name:"Trash2"}),"aria-label":`Delete ${c.name}`,onClick:a=>{a.stopPropagation(),n(c.id)}}),children:c.name},c.id))})]})}),e.jsx(T.MenuFooter,{children:e.jsxs(x.Box,{direction:"row",gap:"xs",children:[e.jsx(x.Box,{direction:"column",style:{flex:"1 0 0",minWidth:0},children:e.jsx(dt.Input,{size:"sm",fullWidth:!0,placeholder:"Save current view as…",value:o,onChange:c=>i(c.target.value),onKeyDown:c=>{c.key==="Enter"&&l()}})}),e.jsx(H.Button,{variant:"primary",tone:"brand",size:"sm",disabled:!o.trim(),onClick:l,children:"Save"})]})})]})]})},Ci=({isOpen:t,onClose:r,configs:n,activeKeys:s,configByKey:o,hasActiveFilter:i,onToggle:l,onReset:c,getValue:a,setValue:u,clearValue:f,removeFilter:g})=>{const m=s.length;return e.jsx(Gt.Drawer,{position:"bottom",isShow:t,onHide:r,children:e.jsxs(x.Box,{direction:"column",customMaxHeight:"85vh",style:{minHeight:280},children:[e.jsxs(x.Box,{direction:"row",display:"flex",align:"center",justify:"space-between",paddingInline:"md",paddingBlock:"sm",style:{borderBottom:"1px solid var(--sa-border-subtle, rgba(11, 18, 14, 0.14))"},children:[e.jsxs(x.Box,{direction:"row",display:"flex",align:"center",gap:"xs",children:[e.jsx(v.Text,{fontWeight:"semibold",color:"primary",children:"Filter"}),m>0&&e.jsxs(v.Text,{fontSize:"sm",color:"subtle",children:["(",m,")"]})]}),e.jsx(H.Button,{variant:"link",tone:"neutral",size:"sm",iconLeft:e.jsx(E.Icon,{name:"Cross"}),"aria-label":"Close filter",onClick:r})]}),e.jsxs(x.Box,{direction:"column",gap:"lg",padding:"md",overflow:"overflow-y-auto",style:{flex:"1 1 auto",minHeight:0},children:[m>0&&e.jsxs(x.Box,{direction:"column",gap:"sm",children:[e.jsx(v.Text,{fontSize:"xs",fontWeight:"medium",color:"subtlest",children:"Filter aktif"}),e.jsx(x.Box,{direction:"row",display:"flex",wrap:"wrap",gap:"sm",align:"center",children:e.jsx(vo,{activeKeys:s,configByKey:o,getValue:a,setValue:u,clearValue:f,removeFilter:g})})]}),n.length>0&&e.jsxs(x.Box,{direction:"column",gap:"sm",children:[e.jsx(v.Text,{fontSize:"xs",fontWeight:"medium",color:"subtlest",children:"Tambah filter"}),e.jsx(x.Box,{direction:"column",children:n.map(p=>{const S=s.includes(p.key),b=!!p.locked;return e.jsxs(x.Box,{direction:"row",display:"flex",align:"center",justify:"space-between",gap:"sm",paddingBlock:"sm",style:{opacity:b?.5:1,borderTop:"1px solid var(--sa-border-subtle, rgba(11, 18, 14, 0.08))"},children:[e.jsxs(x.Box,{direction:"row",display:"flex",align:"center",gap:"sm",style:{minWidth:0},children:[p.icon&&e.jsx(x.Box,{direction:"column",align:"center",color:"icon-subtle",style:{display:"inline-flex"},children:p.icon}),e.jsx(v.Text,{fontSize:"sm",color:"primary",truncate:!0,children:p.label})]}),e.jsx(vt.Toggle,{size:"sm",checked:S||b,disabled:b,onChange:()=>l(p.key),"aria-label":`Toggle ${p.label}`})]},p.key)})})]})]}),e.jsxs(x.Box,{direction:"row",display:"flex",gap:"sm",paddingInline:"md",paddingBlock:"sm",style:{borderTop:"1px solid var(--sa-border-subtle, rgba(11, 18, 14, 0.14))"},children:[e.jsx(x.Box,{direction:"column",style:{flex:"1 1 0"},children:e.jsx(H.Button,{variant:"outline",tone:"neutral",size:"md",fullWidth:!0,disabled:!i,onClick:c,children:"Reset"})}),e.jsx(x.Box,{direction:"column",style:{flex:"1 1 0"},children:e.jsx(H.Button,{variant:"primary",tone:"brand",size:"md",fullWidth:!0,onClick:r,children:"Selesai"})})]})]})})},wi=t=>`${t} Rows`,Di=({perPageKey:t,pageKey:r,pageSizeOptions:n,defaultPerPage:s=10,showPageSize:o})=>{const{searchQueries:i,setSearchParams:l,searchParams:c}=Ve(),a=c.get(t),u=a?Number(a):s,f=g=>{l({...i,[t]:g,[r]:"1"})};return o?e.jsxs(T.Menu,{position:"bottom-right",children:[e.jsx(T.MenuButton,{children:e.jsx(H.Button,{variant:"outline",tone:"neutral",size:"sm",iconLeft:e.jsx(E.Icon,{name:"MenuVertical",size:"sm"}),"aria-label":"More options"})}),e.jsx(T.MenuLists,{children:e.jsxs(T.MenuBody,{style:{minWidth:200},children:[e.jsx(x.Box,{paddingInline:"sm",paddingBlock:"xs",children:e.jsx(v.Text,{fontSize:"xs",fontWeight:"medium",color:"subtlest",children:"Rows per page"})}),n.map(g=>e.jsx(T.MenuItem,{selected:g===u,endIcon:g===u?e.jsx(E.Icon,{name:"Check"}):void 0,onClick:()=>f(String(g)),children:wi(g)},g))]})})]}):null},Si=t=>{var Oe;const{withPadding:r,configs:n,activeKeys:s,configByKey:o,hasActiveFilter:i,toggleFilter:l,removeFilter:c,getValue:a,setValue:u,clearValue:f,onReset:g,searchable:m,searchKey:p,filterKey:S,pageKey:b,searchPlaceholder:I,searchShortcut:B,searchCollapsible:F,pagination:w,perPageKey:D,pageSizeOptions:A,defaultPerPage:O,showPagination:C,showResultCount:R,showPageSize:L,hasColumns:U,orderedColumns:J,allVisible:N,onToggleVisibility:_,onReorder:X,onSetAllHidden:te,showSavedViews:V,savedViews:z,onApplyView:P,onDeleteView:se,onSaveView:ye,leadingActions:Se}=t,[xe,pe]=d.useState(!1),{searchQueries:je,setSearchParams:be}=Ve(),Te=(w==null?void 0:w.rangeStart)??(((w==null?void 0:w.currentPage)||0)>1?(((w==null?void 0:w.currentPage)||0)-1)*((w==null?void 0:w.perPage)||0)+1:1),ke=(w==null?void 0:w.rangeEnd)??((w==null?void 0:w.totalCurrentPage)!==(w==null?void 0:w.perPage)?w==null?void 0:w.totalData:((w==null?void 0:w.currentPage)||1)*((w==null?void 0:w.totalCurrentPage)||0)),He=Ne=>{be({...je,[b]:String(Ne)})},Y=R||C&&!!(w!=null&&w.totalPage),he=()=>{g(),pe(!1)};return e.jsxs(x.Box,{direction:"column",gap:"sm",fullWidth:!0,paddingTop:r?"sm":void 0,paddingBottom:r?"sm":void 0,paddingLeft:r?"md":void 0,paddingRight:r?"md":void 0,role:"toolbar","aria-label":"Filter bar",children:[e.jsxs(x.Box,{direction:"row",display:"flex",align:"center",wrap:"wrap",gap:"sm",fullWidth:!0,overflow:"overflow-auto",children:[m&&e.jsx(Co,{searchKey:p,filterKey:S,pageKey:b,placeholder:I,shortcut:B,collapsible:F}),e.jsx(H.Button,{variant:i?"secondary":"outline",tone:"neutral",size:"sm",iconLeft:e.jsx(E.Icon,{name:"FilterHorizontal"}),onClick:()=>pe(!0),"aria-label":"Open filters",children:i?`Filter: ${s.length}`:null}),e.jsxs(x.Box,{direction:"row",display:"flex",align:"center",gap:"sm",style:{marginLeft:"auto"},children:[Se,V&&e.jsx(Do,{views:z,onApply:P,onDelete:se,onSave:ye}),U&&e.jsx(wo,{columns:J,allVisible:N,onToggle:_,onReorder:X,onSetAllHidden:te}),e.jsx(Di,{perPageKey:D,pageKey:b,pageSizeOptions:A,defaultPerPage:O,showPageSize:L})]})]}),Y&&e.jsxs(x.Box,{direction:"row",display:"flex",align:"center",justify:"space-between",gap:"sm",fullWidth:!0,children:[R?e.jsx(v.Text,{fontSize:"sm",fontWeight:"medium",color:"primary",truncate:!0,children:`${Te}-${ke} of ${((Oe=w==null?void 0:w.totalData)==null?void 0:Oe.toLocaleString())||0}`}):e.jsx(x.Box,{direction:"column"}),C&&!!(w!=null&&w.totalPage)&&e.jsx(Mt.Pagination,{size:"xs",variant:"neutral",siblingCount:0,currentPage:w!=null&&w.currentPage?Number(w.currentPage):1,totalPages:Number(w.totalPage),onPageChange:He})]}),e.jsx(Ci,{isOpen:xe,onClose:()=>pe(!1),configs:n,activeKeys:s,configByKey:o,hasActiveFilter:i,onToggle:l,onReset:he,getValue:a,setValue:u,clearValue:f,removeFilter:c})]})},ki=({withPadding:t=!1,filterConfigs:r=[],filterKey:n="filter",activeFilterKey:s="filters",pageKey:o="page",perPageKey:i="perPage",pageSizeOptions:l=[25,50,100],defaultPerPage:c,showPagination:a=!0,showResultCount:u=!0,showPageSize:f=!0,searchable:g=!1,searchKey:m="q",searchPlaceholder:p="Search",searchShortcut:S="/",searchPosition:b="right",searchCollapsible:I=!0,pagination:B,columns:F=[],onColumnsChange:w,columnsState:D,scopeId:A,savedViews:O,persistLastState:C=!0,persistSearch:R=!0,storage:L=Ur,onReset:U,leadingActions:J})=>{const N=A??(O==null?void 0:O.scopeId),{activeKeys:_,configByKey:X,hasActiveFilter:te,toggleFilter:V,removeFilter:z,getValue:P,setValue:se,clearValue:ye,clearAll:Se}=Qr({configs:r,filterKey:n,activeFilterKey:s,pageKey:o,searchKey:m}),xe=Ys({columns:F,scopeId:N,storage:L,onColumnsChange:w,value:D}),pe=Xs({scopeId:N,storage:L,snapshotKeys:[s,n,i],pageKey:o,getColumns:()=>xe.state,applyColumns:xe.applyState}),je=Ks({scopeId:N,storage:L,snapshotKeys:[s,n,o],enabled:C,filterKey:n,searchKey:m,persistSearch:R}),be=ei({scopeId:N,storage:L,perPageKey:i,pageSizeOptions:l,enabled:C});ri({enabled:C&&!!N,snapshotKeys:[s,n,o],perPageKey:i,readSnapshot:je.read,readPerPage:be.read});const Te=c??l[0]??25,ke=!!(O!=null&&O.enabled)&&pe.enabled,He=()=>{Se(),je.clear(),U==null||U()},Y=Ce.useMediaQuery("md"),he=g?e.jsx(Co,{searchKey:m,filterKey:n,pageKey:o,placeholder:p,shortcut:S,collapsible:I}):null;return Y?e.jsxs(x.Box,{display:"flex",direction:"row",align:"center",gap:"sm",wrap:"wrap",fullWidth:!0,paddingTop:t?"sm":void 0,paddingBottom:t?"sm":void 0,paddingLeft:t?"md":void 0,paddingRight:t?"md":void 0,role:"toolbar","aria-label":"Filter bar",children:[e.jsxs(x.Box,{direction:"row",display:"flex",align:"center",gap:"sm",style:{flex:"1 1 0",minWidth:0},children:[e.jsx(ni,{configs:r,activeKeys:_,onToggle:V,hasActiveFilter:te,onReset:He}),b==="left"&&he,e.jsxs(x.Box,{direction:"row",display:"flex",align:"center",gap:"sm",overflow:"overflow-x-auto",style:{flex:"1 1 0",minWidth:0},children:[e.jsx(vo,{activeKeys:_,configByKey:X,getValue:P,setValue:se,clearValue:ye,removeFilter:z}),te&&e.jsx(H.Button,{variant:"link",tone:"brand",size:"sm",onClick:He,children:"Reset"})]})]}),e.jsxs(x.Box,{direction:"row",display:"flex",align:"center",gap:"sm",children:[J,e.jsx(ji,{pagination:B,pageKey:o,perPageKey:i,pageSizeOptions:l,defaultPerPage:Te,showPagination:a,showResultCount:u,showPageSize:f}),b==="right"&&he,ke&&e.jsx(Do,{views:pe.views,onApply:pe.applyView,onDelete:pe.deleteView,onSave:pe.saveView}),F.length>0&&e.jsx(wo,{columns:xe.orderedColumns,allVisible:xe.allVisible,onToggle:xe.toggleVisibility,onReorder:xe.reorder,onSetAllHidden:xe.setAllHidden})]})]}):e.jsx(Si,{withPadding:t,configs:r,activeKeys:_,configByKey:X,hasActiveFilter:te,toggleFilter:V,removeFilter:z,getValue:P,setValue:se,clearValue:ye,onReset:He,searchable:g,searchKey:m,filterKey:n,pageKey:o,searchPlaceholder:p,searchShortcut:S,searchCollapsible:I,pagination:B,perPageKey:i,pageSizeOptions:l,defaultPerPage:Te,showPagination:a,showResultCount:u,showPageSize:f,hasColumns:F.length>0,orderedColumns:xe.orderedColumns,allVisible:xe.allVisible,onToggleVisibility:xe.toggleVisibility,onReorder:xe.reorder,onSetAllHidden:xe.setAllHidden,showSavedViews:ke,savedViews:pe.views,onApplyView:pe.applyView,onDeleteView:pe.deleteView,onSaveView:pe.saveView,leadingActions:J})},Bi=t=>{if(!Array.isArray(t)||t.length===0)return;const r=t[0];return(r==null?void 0:r.value)!=null?String(r.value):void 0},Ei=t=>{if(!Array.isArray(t)||t.length===0)return;const r=t.map(n=>(n==null?void 0:n.value)!=null?String(n.value):null).filter(n=>n!=null);return r.length?r:void 0},Fi=(t,r)=>{switch(t.type){case"dropdown":case"radio":return Bi(r);case"dropdown-multiple":case"checkbox-multiple":return Ei(r);case"date":return r instanceof Date?r.toISOString():void 0;case"date-compact":return r;default:return}},Rn=(t,r)=>{if(t==null||t==="")return r;const n=Number(t);return Number.isFinite(n)&&n>0?n:r},Mi=t=>{const{filterConfigs:r,filterKey:n="filter",activeFilterKey:s="filters",pageKey:o="page",perPageKey:i="perPage",searchKey:l="q",defaultPage:c=1,defaultPerPage:a=10,paramKeys:u,serialize:f}=t,{activeKeys:g,configByKey:m,hasActiveFilter:p,getValue:S}=Qr({configs:r,filterKey:n,activeFilterKey:s,pageKey:o,searchKey:l}),{searchParams:b}=Ve(),I=b.toString();return d.useMemo(()=>{const F={},w={},D=Rn(b.get(o),c),A=Rn(b.get(i),a);F[(u==null?void 0:u.page)??"page"]=D,F[(u==null?void 0:u.perPage)??"perPage"]=A;const O=Xt(l,b,n)||"";O&&(F[(u==null?void 0:u.search)??"search"]=O);let C=!1;for(const R of g){const L=m[R];if(!L)continue;const U=S(L);w[R]=U;const J=f==null?void 0:f[R],N=J?J(U):Fi(L,U);if(N==null||Array.isArray(N)&&N.length===0)continue;const _=(u==null?void 0:u[R])??R;F[_]=N,C=!0}return{params:F,raw:w,hasActiveFilter:p||!!O||C}},[I,g.join("|"),n,s,o,i,l,c,a,u,f,m])},Ii=["dropdown","dropdown-multiple","checkbox-multiple","radio"],Li=({filterConfigs:t,filterKey:r,activeFilterKey:n,pageKey:s,searchKey:o})=>{const{configByKey:i,getValue:l,setValue:c,removeFilter:a,clearAll:u,hasActiveFilter:f}=Qr({configs:t,filterKey:r,activeFilterKey:n,pageKey:s,searchKey:o}),g=(B,F)=>{var D;const w=B.options;return((D=w==null?void 0:w.find(A=>A.value===F))==null?void 0:D.label)??F},m=d.useCallback(B=>{const F=i[B];if(!F)return[];const w=l(F);return Array.isArray(w)?w.map(D=>String(D.value)):[]},[i,l]),p=d.useCallback((B,F)=>{const w=i[B];if(!w||!Ii.includes(w.type))return;const D=Array.isArray(F)?F:[F];if(D.length===0){a(B);return}c(w,D.map(A=>({label:g(w,A),value:A})))},[i,c,a]),S=d.useCallback((B,F)=>{const w=m(B);p(B,w.includes(F)?w.filter(D=>D!==F):[...w,F])},[m,p]),b=d.useCallback((B,F)=>m(B).includes(F),[m]),I=d.useCallback(B=>a(B),[a]);return{set:p,toggle:S,clear:I,clearAll:u,isActive:b,values:m,hasActiveFilter:f}},Ti=(t,r)=>{if(!t)return{};const{fromKey:n,toKey:s,opKey:o}=r,i={};switch(t.op){case"is":case"is-before":case"is-after":case"is-on-or-before":case"is-on-or-after":return t.date&&(i[n]=new Date(t.date).toISOString()),o&&(i[o]=t.op),i;case"is-between":return t.from&&(i[n]=new Date(t.from).toISOString()),t.to&&(i[s]=new Date(t.to).toISOString()),i;case"is-relative-to-today":{if(!t.relative)return i;const{from:l,to:c}=po(t.relative);return i[n]=l.toISOString(),i[s]=c.toISOString(),i}case"is-empty":case"is-not-empty":return o&&(i[o]=t.op==="is-empty"?"empty":"not-empty"),i;default:return i}},So=({children:t,borderRadius:r,height:n})=>{const s=d.useRef(null),[o,i]=d.useState("100vh");return d.useEffect(()=>{if(n)return;const l=()=>{if(s.current){const c=s.current.getBoundingClientRect().top;i(`calc(100vh - ${c}px)`)}};return l(),window.addEventListener("resize",l),()=>window.removeEventListener("resize",l)},[n]),e.jsx(x.Box,{ref:s,fullWidth:!0,borderStyle:"border-solid",borderWidth:"border",borderColor:"border-base",borderRadius:r||"rounded-xs",style:{height:n??o,display:"flex",flexDirection:"column"},children:t})},ko=({action:t,rightContent:r,leftContent:n,headerSlot:s,advanceFilter:o,showFilter:i=!0})=>{const l=Ce.useMediaQuery("md"),c=i?e.jsx(yo,{...o}):null,a=()=>t?d.isValidElement(t)?t:e.jsx(x.Box,{style:{display:"flex",flexDirection:l?"row":"column",gap:"8px",width:l?"auto":"100%",textWrap:"nowrap"},children:t.map(({title:u,icon:f,buttonProps:g,onClick:m},p)=>!u&&!f?null:e.jsx(H.Button,{fullWidth:!l,iconLeft:f?e.jsx(E.Icon,{name:f}):void 0,onClick:m,...g,children:u},`action-${p}`))}):null;return e.jsx(x.Box,{style:{display:"flex",width:"100%",justifyContent:"space-between",alignItems:"center",paddingLeft:"8px",paddingRight:"8px",paddingTop:"8px",paddingBottom:"8px",borderBottom:"1px solid var(--sa-border-subtle, #0b120e24)",flexShrink:0,position:"relative",zIndex:10,flexDirection:l?"row":"column-reverse",gap:"16px"},children:s?s({filter:c}):e.jsxs(e.Fragment,{children:[e.jsxs(x.Box,{style:{display:"flex",gap:"8px",flexDirection:"row",alignItems:"center",flex:1,minWidth:0},children:[c,n]}),e.jsxs(x.Box,{style:{display:"flex",gap:"8px",flexDirection:"row",alignItems:"center",flexShrink:0},children:[r,a()]})]})})},Oi=({totalData:t,withMarginBottom:r=!0,withMarginTop:n=!0})=>e.jsxs(x.Box,{style:{display:"flex",gap:"4px",flexDirection:"row",alignItems:"center",marginBottom:r?"16px":void 0,marginTop:n?"16px":void 0},children:[e.jsxs(Xe.Body1,{props:{color:"gray-500"},children:["Total data:"," "]}),e.jsx(Xe.Body1,{children:t||0})]}),Bo=({pagination:t,pageKey:r="page",perPageKey:n="perPage",defaultPerPage:s=10,showPagination:o=!0,totalData:i})=>{const{searchQueries:l,setSearchParams:c,searchParams:a}=Ve(),u=a.get(n),f=S=>{c({...l,[r]:String(S)})},g=S=>{c({...l,[n]:S,[r]:"1"})},m=(t==null?void 0:t.rangeStart)??(((t==null?void 0:t.currentPage)||0)>1?(((t==null?void 0:t.currentPage)||0)-1)*((t==null?void 0:t.perPage)||0)+1:1),p=(t==null?void 0:t.rangeEnd)??((t==null?void 0:t.totalCurrentPage)!==(t==null?void 0:t.perPage)?t==null?void 0:t.totalData:((t==null?void 0:t.currentPage)||1)*((t==null?void 0:t.totalCurrentPage)||0));return e.jsx(x.Box,{style:{display:"flex",width:"100%",flexDirection:"row",justifyContent:"space-between",alignItems:"center",paddingLeft:"16px",paddingRight:"16px",paddingTop:"8px",paddingBottom:"8px",borderTop:"1px solid var(--sa-border-subtle, #0b120e24)",flexShrink:0},children:o?e.jsxs(e.Fragment,{children:[e.jsxs(x.Box,{style:{display:"flex",flexDirection:"row",gap:"8px",alignItems:"center",textWrap:"nowrap"},children:[e.jsx(v.Text,{children:"Rows Per Page: "}),e.jsx(jt.Dropdown,{dropdownLists:[{label:"5",value:"5"},{label:"10",value:"10"},{label:"25",value:"25"},{label:"50",value:"50"},{label:"100",value:"100"}],onChange:S=>{g(S[0].value)},value:u?[{label:`${u} per row`,value:u}]:[{label:`${s} per row`,value:`${s}`}],defaultValue:u?[{label:`${u} per row`,value:u}]:[{label:`${s} per row`,value:`${s}`}]}),e.jsx(v.Text,{children:`${m}-${p} of ${(t==null?void 0:t.totalData)||0}`})]}),e.jsx(Mt.Pagination,{currentPage:t!=null&&t.currentPage?Number(t==null?void 0:t.currentPage):1,totalPages:t!=null&&t.totalPage?Number(t==null?void 0:t.totalPage):1,onPageChange:f})]}):e.jsx(Oi,{totalData:i,withMarginBottom:!1,withMarginTop:!1})})},Eo=({filter:t,columnTitle:r})=>{const[n,s]=d.useState(!1),o=d.useRef(null),i=d.useRef(null),l=d.useRef(null),[c,a]=d.useState(""),[u,f]=d.useState({top:0,left:0}),g=t.selectedValues,m=d.useMemo(()=>c?t.options.filter(b=>b.label.toLowerCase().includes(c.toLowerCase())):t.options,[t.options,c]);d.useEffect(()=>{if(n&&i.current){const b=i.current.getBoundingClientRect(),I=280,B={top:b.bottom+8};t.position==="left"||b.left+I>window.innerWidth?B.right=window.innerWidth-b.right:B.left=b.left,f(B)}},[n,t.position]),d.useEffect(()=>{n&&l.current?setTimeout(()=>{var b;return(b=l.current)==null?void 0:b.focus()},50):a("")},[n]),d.useEffect(()=>{const b=I=>{o.current&&!o.current.contains(I.target)&&i.current&&!i.current.contains(I.target)&&s(!1)};return n&&document.addEventListener("mousedown",b),()=>document.removeEventListener("mousedown",b)},[n]);const p=b=>{const I=g.includes(b)?g.filter(B=>B!==b):[...g,b];t.onFilterChange(I)},S=()=>t.onFilterChange([]);return e.jsxs(x.Box,{direction:"column",style:{position:"relative"},children:[e.jsx(x.Box,{ref:i,style:{display:"flex",flexDirection:"row",alignItems:"center",cursor:"pointer"},onClick:b=>{var I;b.stopPropagation(),n||(I=t.onOpen)==null||I.call(t),s(B=>!B)},children:e.jsx(E.Icon,{name:n?"ChevronUp":"ChevronDown",size:"sm",style:{color:g.length>0?"var(--sa-color-brand-500, #1a4fa0)":"var(--sa-text-subtle, #8c8f97)"}})}),n&&e.jsxs(x.Box,{ref:o,style:{position:"fixed",top:`${u.top}px`,...u.left!==void 0?{left:`${u.left}px`}:{right:`${u.right}px`},backgroundColor:"white",borderRadius:"4px",minWidth:"280px",maxHeight:"400px",display:"flex",flexDirection:"column",zIndex:9999,animation:"fadeInDropdown 0.15s ease-out",border:"1px solid var(--sa-border-subtle, #0b120e24)"},children:[e.jsxs(x.Box,{style:{display:"flex",flexDirection:"row",justifyContent:"space-between",alignItems:"center",paddingTop:"12px",paddingBottom:"12px",paddingLeft:"16px",paddingRight:"16px",borderBottom:"1px solid var(--sa-border-subtle, #0b120e24)"},children:[e.jsxs(v.Text,{fontSize:"sm",fontWeight:"semibold",color:"gray-700",children:["Filter ",r]}),g.length>0&&e.jsx(x.Box,{direction:"column",style:{cursor:"pointer"},children:e.jsx(v.Text,{fontSize:"xs",color:"primary",fontWeight:"semibold",onClick:b=>{b.stopPropagation(),S()},children:"CLEAR"})})]}),!t.hideSearch&&e.jsx(x.Box,{direction:"column",style:{paddingLeft:"16px",paddingRight:"16px",paddingTop:"8px",paddingBottom:"8px"},children:e.jsx(dt.Input,{ref:l,placeholder:`Search ${r.toLowerCase()}...`,leftIcon:e.jsx(E.Icon,{name:"Search",size:"sm"}),value:c,onChange:b=>a(b.target.value),style:{fontSize:"14px"}})}),e.jsx(x.Box,{direction:"column",className:"ts-filter-dropdown-options",style:{overflowY:"auto",maxHeight:"250px",paddingLeft:"8px",paddingRight:"8px"},children:t.isLoadingOptions?e.jsxs(x.Box,{style:{paddingTop:"40px",paddingBottom:"40px",display:"flex",alignItems:"center",justifyContent:"center",flexDirection:"column"},children:[e.jsx(E.Icon,{name:"Loading",size:"lg",style:{color:"var(--sa-background-brand, #04254f)",animation:"spin 1s linear infinite"}}),e.jsx(v.Text,{fontSize:"sm",color:"gray-500",style:{textAlign:"center",marginTop:"8px"},children:"Loading options..."})]}):m.length>0?e.jsx(x.Box,{direction:"column",style:{gap:"2px",paddingTop:"4px",paddingBottom:"4px"},children:m.map(b=>e.jsxs(x.Box,{style:{display:"flex",flexDirection:"row",alignItems:"center",gap:"8px",paddingTop:"8px",paddingBottom:"8px",paddingLeft:"8px",paddingRight:"8px",cursor:"pointer",borderRadius:"8px",transition:"all 0.2s ease",backgroundColor:g.includes(b.value)?"var(--sa-color-brand-50, #e6edf6)":"transparent"},onClick:I=>{I.stopPropagation(),p(b.value)},onMouseEnter:I=>{g.includes(b.value)||(I.currentTarget.style.backgroundColor="var(--sa-background-primary, #ffffff)"),I.currentTarget.style.transform="translateX(2px)"},onMouseLeave:I=>{I.currentTarget.style.backgroundColor=g.includes(b.value)?"var(--sa-color-brand-50, #e6edf6)":"transparent",I.currentTarget.style.transform="translateX(0)"},children:[e.jsx(nt.Checkbox,{checked:g.includes(b.value),onChange:()=>{}}),e.jsx(v.Text,{fontSize:"sm",fontWeight:g.includes(b.value)?"medium":"normal",color:g.includes(b.value)?"primary":"gray-700",children:b.label})]},b.value))}):e.jsxs(x.Box,{style:{paddingTop:"40px",paddingBottom:"40px",display:"flex",alignItems:"center",justifyContent:"center",flexDirection:"column"},children:[e.jsx(E.Icon,{name:"Search",size:"lg",style:{color:"var(--sa-text-subtle, #8c8f97)"}}),e.jsx(v.Text,{fontSize:"sm",color:"gray-500",style:{textAlign:"center",marginTop:"8px"},children:"No results found"})]})}),g.length>0&&e.jsx(x.Box,{direction:"column",style:{paddingTop:"8px",paddingBottom:"8px",paddingLeft:"16px",paddingRight:"16px",borderTop:"1px solid var(--sa-border-subtle, #0b120e24)",backgroundColor:"var(--sa-color-brand-50, #e6edf6)",marginTop:"auto"},children:e.jsxs(x.Box,{style:{display:"flex",flexDirection:"row",alignItems:"center",gap:"4px"},children:[e.jsx(x.Box,{direction:"column",style:{backgroundColor:"var(--sa-background-brand, #04254f)",borderRadius:"12px",padding:"2px 8px",fontSize:"11px",fontWeight:600,color:"white"},children:g.length}),e.jsxs(v.Text,{fontSize:"xs",color:"primary",fontWeight:"medium",children:["item",g.length>1?"s":""," selected"]})]})})]})]})},Ri=({direction:t})=>{const r="var(--sa-text-primary, #292a2e)",n="var(--sa-text-subtle, #8c8f97)",s=t==="asc"?r:n,o=t==="desc"?r:n,i=t==="asc"?1:.45,l=t==="desc"?1:.45;return e.jsxs("span",{style:{display:"inline-flex",flexDirection:"column",alignItems:"center",justifyContent:"center",flexShrink:0,lineHeight:0},"aria-hidden":!0,children:[e.jsx("svg",{width:"8",height:"5",viewBox:"0 0 8 5",style:{color:s,opacity:i,marginBottom:1},children:e.jsx("path",{d:"M4 0 L8 5 L0 5 Z",fill:"currentColor"})}),e.jsx("svg",{width:"8",height:"5",viewBox:"0 0 8 5",style:{color:o,opacity:l},children:e.jsx("path",{d:"M0 0 L8 0 L4 5 Z",fill:"currentColor"})})]})},Ai=({frozen:t})=>e.jsxs("svg",{width:"11",height:"11",viewBox:"0 0 24 24",fill:t?"currentColor":"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("rect",{x:"3",y:"11",width:"18",height:"11",rx:"2",ry:"2"}),e.jsx("path",{d:t?"M7 11V7a5 5 0 0 1 10 0v4":"M7 11V7a5 5 0 0 1 9.9-1"})]}),Cr="var(--sa-background-primary, #ffffff)",An="var(--sa-background-primary-inverse, #f8f8f8)",Fo=({columns:t,records:r,handleDetail:n,handleUpdate:s,handleDelete:o,isLoading:i,visibleHandleDelete:l,visibleHandleUpdate:c,visibleHandleDetail:a,showHeadBorder:u=!1,scrollParentRef:f,frozenCount:g=0,onFrozenCountChange:m,customActions:p,actionsOrder:S=["detail","update","delete","custom"],customEmptyState:b,enableColumnResize:I=!1,defaultColumnWidths:B,onColumnWidthsChange:F,defaultMinColumnWidth:w=60,sort:D,defaultSort:A,onSortChange:O,showActionDivider:C=!1})=>{const R=D!==void 0,[L,U]=d.useState(A??null),J=R?D??null:L,N=W=>{if(W.sortKey)return W.sortKey;if(typeof W.accessor=="string")return W.accessor},_=W=>{const $=N(W);if(!$)return;let Q;!J||J.key!==$?Q={key:$,direction:"asc"}:J.direction==="asc"?Q={key:$,direction:"desc"}:Q=null,R||U(Q),O==null||O(Q)},te=[n,s,o].filter(W=>W!==void 0).length,V=!!p,z=!!n||!!s||!!o||V,P="var(--sa-border-subtle, #0b120e24)",se=`1px solid ${P}`,ye=`inset 1px 0 0 ${P}`,Se=`inset -1px 0 0 ${P}`,xe=te===3?V?"178px":"140px":te===2?V?"140px":"102px":te===1?V?"112px":"74px":V?"74px":"",pe=(W,$)=>{if(!$)return W;if(typeof $=="function")return $(W);if(typeof $=="string")return W[$]},[je,be]=d.useState(!1);d.useEffect(()=>{if(!(f!=null&&f.current))return;const W=f.current;be(W.scrollHeight>W.clientHeight)},[r,f]);const Te=d.useRef(null),[ke,He]=d.useState([]),[Y,he]=d.useState(()=>B??{}),Oe=d.useRef(null);d.useLayoutEffect(()=>{if(!g||!Te.current){He([]);return}const W=Array.from(Te.current.querySelectorAll("thead tr th")),$=[];let Q=0;W.forEach((de,ie)=>{$[ie]=Q,ie<g&&(Q+=de.offsetWidth)}),He($)},[g,t,r,Y]);const Ne=W=>{m&&m(W<g?W:W+1)},ae=(W,$)=>{const Q=Y[W];if(Q!==void 0){const de=`${Q}px`;return{width:de,minWidth:de,maxWidth:de}}return $?{width:$}:{}},_e=W=>I&&(W.resizable??!0),tt=(W,$)=>{W.preventDefault(),W.stopPropagation();const Q=W.currentTarget.closest("th");if(!Q)return;const de=Math.round(Q.getBoundingClientRect().width);Oe.current={colIndex:$,startX:W.clientX,startWidth:de};const ie=document.body.style.userSelect,Be=document.body.style.cursor;document.body.style.userSelect="none",document.body.style.cursor="col-resize";const Re=qe=>{var Ze;const Me=Oe.current;if(!Me)return;const Qe=((Ze=t[Me.colIndex])==null?void 0:Ze.minWidth)??w,we=Math.max(Qe,Me.startWidth+(qe.clientX-Me.startX));he(rt=>rt[Me.colIndex]===we?rt:{...rt,[Me.colIndex]:we})},$e=()=>{document.removeEventListener("mousemove",Re),document.removeEventListener("mouseup",$e),document.body.style.userSelect=ie,document.body.style.cursor=Be,Oe.current=null,F&&he(qe=>(F(qe),qe))};document.addEventListener("mousemove",Re),document.addEventListener("mouseup",$e)};return e.jsx("div",{ref:Te,children:e.jsxs(G.Table,{fullWidth:!0,children:[e.jsx(G.Thead,{style:{height:"40px",whiteSpace:"nowrap"},children:e.jsxs(G.Tr,{children:[t.map((W,$)=>{var ut,ct;const Q=g>0&&$<g,de=ke[$]??0,ie=_e(W),Re=$===t.length-1&&z&&C,$e=N(W),qe=!!W.sortable&&!!$e,Me=qe&&(J==null?void 0:J.key)===$e?J.direction:null,Qe=W.title||((ut=W.accessor)==null?void 0:ut.toString())||"",we=(ct=W.headerTooltip)!=null&&ct.showIcon?e.jsx(E.Icon,{name:"InfoCircle",size:"xs",style:{flexShrink:0,color:"var(--sa-icon-subtle, #8c8f97)",opacity:.75}}):null,Ze=e.jsx("span",{style:{flex:1,minWidth:0,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:Qe}),rt=qe?e.jsxs("button",{type:"button",onClick:()=>_(W),title:Me==="asc"?"Sorted ascending — click to sort descending":Me==="desc"?"Sorted descending — click to clear":"Click to sort ascending",style:{flex:1,minWidth:0,display:"flex",alignItems:"center",gap:4,background:"none",border:"none",padding:0,margin:0,font:"inherit",color:"inherit",cursor:"pointer",textAlign:W.textAlign==="text-right"?"right":W.textAlign==="text-center"?"center":"left"},children:[Ze,we,e.jsx(Ri,{direction:Me})]}):e.jsxs("span",{style:{flex:1,minWidth:0,display:"flex",alignItems:"center",gap:4},children:[Ze,we]});return e.jsxs(G.Th,{style:{position:"sticky",top:0,left:Q?de:void 0,zIndex:Q?4:2,paddingLeft:$===0?"12px":"",borderRight:u&&!Re&&!Q?se:void 0,borderBottom:u?se:void 0,boxShadow:u&&Q?Se:void 0,backgroundColor:"var(--sa-background-primary-inverse, #f8f8f8)",textAlign:W.textAlign==="text-right"?"right":W.textAlign==="text-center"?"center":"left",...ae($,W.width)},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"4px",justifyContent:"space-between",minWidth:0},children:[W.headerTooltip?e.jsx(Fe.Tooltip,{label:W.headerTooltip.content,position:"bottom",children:rt}):rt,W.filter&&e.jsx(Eo,{filter:W.filter,columnTitle:W.title}),m&&e.jsx("button",{onClick:()=>Ne($),title:Q?"Unfreeze column":"Freeze column",style:{background:"none",border:"none",cursor:"pointer",padding:"2px",display:"flex",alignItems:"center",flexShrink:0,color:Q?"var(--sa-background-brand, #04254f)":"var(--sa-text-subtle, #8c8f97)",opacity:Q?1:.45,transition:"opacity 0.15s"},children:e.jsx(Ai,{frozen:Q})})]}),ie&&e.jsx("div",{onMouseDown:at=>tt(at,$),onClick:at=>at.stopPropagation(),role:"separator","aria-orientation":"vertical",title:"Drag to resize",style:{position:"absolute",top:0,right:-3,width:6,height:"100%",cursor:"col-resize",userSelect:"none",zIndex:5,touchAction:"none"}})]},`table-head-${$}`)}),z?e.jsx(G.Th,{style:{backgroundColor:"var(--sa-background-primary-inverse, #f8f8f8)",position:"sticky",top:0,right:0,zIndex:3,borderBottom:u?se:void 0,boxShadow:u&&C?ye:void 0}}):null]})}),e.jsx(G.Tbody,{children:i?e.jsx(G.Tr,{children:e.jsx(G.Td,{colSpan:t.length+1,children:e.jsxs(x.Box,{direction:"column",style:{gap:"16px"},children:[e.jsx(Ye.Skeleton,{variant:"list"}),e.jsx(Ye.Skeleton,{variant:"list"}),e.jsx(Ye.Skeleton,{variant:"list"}),e.jsx(Ye.Skeleton,{variant:"list"}),e.jsx(Ye.Skeleton,{variant:"list"})]})})}):!(r!=null&&r.length)&&b?e.jsx(G.Tr,{children:e.jsx(G.Td,{colSpan:t.length+1,children:b})}):r==null?void 0:r.map((W,$)=>e.jsxs(G.Tr,{style:{transition:"background-color 0.3s ease",padding:0,borderBottom:$===r.length-1&&je?void 0:"1px solid var(--sa-border-subtle, #0b120e24)"},onMouseEnter:Q=>{const de=Q.currentTarget;de.style.backgroundColor=An,Array.from(de.querySelectorAll("td")).forEach(ie=>{ie.style.position==="sticky"&&(ie.style.backgroundColor=An)})},onMouseLeave:Q=>{const de=Q.currentTarget;de.style.backgroundColor="",Array.from(de.querySelectorAll("td")).forEach(ie=>{ie.style.position==="sticky"&&(ie.style.backgroundColor=Cr)})},children:[t.map((Q,de)=>{const ie=Q.render?Q.render(W,$,r):pe(W,Q.accessor),Be=g>0&&de<g,Re=ke[de]??0,$e=Y[de]!==void 0,qe=Be&&de===g-1;return e.jsx(G.Td,{style:{position:Be?"sticky":void 0,left:Be?Re:void 0,zIndex:Be?1:void 0,backgroundColor:Be?Cr:void 0,transition:Be?"background-color 0.3s ease":void 0,paddingLeft:de===0?"12px":"",whiteSpace:"nowrap",overflow:$e?"hidden":void 0,borderLeft:Q.showBorderLeft?se:void 0,borderRight:Q.showBorderRight?se:void 0,boxShadow:qe?Se:void 0,textAlign:Q.textAlign==="text-right"?"right":Q.textAlign==="text-center"?"center":"left",...ae(de,Q.width)},children:typeof ie=="string"?e.jsx(v.Text,{style:{whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",textAlign:Q.textAlign==="text-right"?"right":Q.textAlign==="text-center"?"center":"left"},children:ie}):ie},`row-${$}-col-${de}`)}),z?e.jsx(G.Td,{style:{width:xe,position:"sticky",right:0,zIndex:1,backgroundColor:Cr,boxShadow:C?ye:void 0,transition:"background-color 0.3s ease"},children:e.jsx(ce.Flex,{direction:"row",align:"center",justify:"center",gap:"sm",children:S.map(Q=>{const de=$===r.length-1?"top":"bottom";return Q==="detail"&&n&&(a==null?void 0:a(W))!==!1?e.jsx(Fe.Tooltip,{label:"Detail",position:de,children:e.jsx(H.Button,{size:"xs",variant:"outline",tone:"neutral",onClick:()=>n(W.id,W),iconLeft:e.jsx(E.Icon,{name:"DocumentClean",size:"sm",style:{color:"var(--sa-text-subtle, #8c8f97)"}})})},"detail"):Q==="update"&&s&&(c==null?void 0:c(W))!==!1?e.jsx(Fe.Tooltip,{label:"Update",position:de,children:e.jsx(H.Button,{size:"xs",variant:"outline",tone:"neutral",onClick:()=>s(W),iconLeft:e.jsx(E.Icon,{name:"Edit1",size:"sm",style:{color:"var(--sa-text-subtle, #8c8f97)"}})})},"update"):Q==="delete"&&o&&(l==null?void 0:l(W))!==!1?e.jsx(Fe.Tooltip,{label:"Delete",position:de,children:e.jsx(H.Button,{size:"xs",variant:"outline",tone:"neutral",onClick:()=>o(W.id,W),iconLeft:e.jsx(E.Icon,{name:"Trash1",size:"sm",style:{color:"var(--sa-color-error-600, #c9184a)"}})})},"delete"):Q==="custom"?e.jsx(d.Fragment,{children:p==null?void 0:p(W)},"custom"):null})})}):null]},`${W}${$}`))})]})})};let Wn=!1;const Wi=({wrapperProps:t,dataTableProps:r,headerProps:n,footerProps:s})=>{var g;process.env.NODE_ENV!=="production"&&!Wn&&(Wn=!0,console.warn("[@starasia/admin] `TableSection` deprecated — pakai `<FilterBar>` + `<TableLayout>`. Lihat skill `starasia-list-page-pattern`. Akan dihapus di salah satu major berikutnya."));const o=d.useRef(null),[i,l]=d.useState((r==null?void 0:r.defaultFrozenCount)??0),c=(n==null?void 0:n.show)??!0,a=d.useRef(null),u=(g=r==null?void 0:r.pagination)==null?void 0:g.totalData;typeof u=="number"&&(a.current=u);const f=(s==null?void 0:s.showFooter)??(u===void 0?a.current!==0:u!==0);return e.jsxs(So,{...t,children:[c&&e.jsx(ko,{...n}),e.jsx(x.Box,{direction:"column",ref:o,style:{flex:1,overflowY:"auto",overflowX:"auto"},children:r?e.jsx(Fo,{...r,scrollParentRef:o,frozenCount:r!=null&&r.enableFreezeColumns?i:0,onFrozenCountChange:r!=null&&r.enableFreezeColumns?l:void 0}):null}),f&&e.jsx(Bo,{pagination:r==null?void 0:r.pagination,pageKey:r==null?void 0:r.pageKey,perPageKey:r==null?void 0:r.perPageKey,defaultPerPage:r==null?void 0:r.defaultPerPage,showPagination:r==null?void 0:r.showPagination,totalData:s==null?void 0:s.totalData})]})};function zi(t){return d.memo(t)}const Hi=zi(Wi),zn=200,wr="1px solid var(--sa-border-subtle, #0b120e24)",Pi=({sortDir:t,frozen:r})=>t==="asc"?e.jsx(E.Icon,{name:"ChevronSmallUp"}):t==="desc"?e.jsx(E.Icon,{name:"ChevronSmallDown"}):r?e.jsx(E.Icon,{name:"LockOn",size:"xs"}):e.jsx(E.Icon,{name:"Filter",size:"xs"}),Ht=({icon:t,label:r,active:n,danger:s,onClick:o})=>{const i=s?"var(--sa-text-error, #a4133c)":"var(--sa-text-primary, #292a2e)";return e.jsxs("button",{type:"button",onClick:o,style:{display:"flex",alignItems:"center",gap:12,width:"100%",padding:"8px 12px",background:n?"var(--sa-background-brand-subtlest, #e6edf6)":"none",border:"none",cursor:"pointer",font:"inherit",color:i,textAlign:"left"},onMouseEnter:l=>{n||(l.currentTarget.style.background="var(--sa-background-primary-inverse, #f8f8f8)")},onMouseLeave:l=>{l.currentTarget.style.background=n?"var(--sa-background-brand-subtlest, #e6edf6)":"none"},children:[e.jsx(E.Icon,{name:t,size:"sm",style:{color:i,flexShrink:0}}),e.jsx(v.Text,{as:"span",style:{color:i},children:r})]})},Mo=({active:t,canSort:r,canHide:n,sortDir:s,frozen:o,onSort:i,onClearSort:l,onToggleFreeze:c,onHide:a})=>{const[u,f]=d.useState(!1),g=d.useRef(null),m=d.useRef(null),[p,S]=d.useState({top:0,left:0});d.useEffect(()=>{if(u&&g.current){const I=g.current.getBoundingClientRect(),B=I.left+zn>window.innerWidth;S({top:I.bottom+6,...B?{right:window.innerWidth-I.right}:{left:I.left}})}},[u]),d.useEffect(()=>{if(!u)return;const I=B=>{m.current&&!m.current.contains(B.target)&&g.current&&!g.current.contains(B.target)&&f(!1)};return document.addEventListener("mousedown",I),()=>document.removeEventListener("mousedown",I)},[u]);const b=I=>{I(),f(!1)};return e.jsxs(e.Fragment,{children:[e.jsx("button",{ref:g,type:"button",className:"sa-tl-menu-trigger","data-active":t||u?"true":"false",onClick:I=>{I.stopPropagation(),f(B=>!B)},title:"Column options",style:{display:"inline-flex",alignItems:"center",justifyContent:"center",width:22,height:22,borderRadius:"var(--sa-radii-sm, 6px)",border:wr,background:"var(--sa-background-primary, #ffffff)",cursor:"pointer",color:"var(--sa-text-subtle, #8c8f97)",flexShrink:0},children:e.jsx(Pi,{sortDir:s,frozen:o})}),u&&e.jsxs(x.Box,{ref:m,onClick:I=>I.stopPropagation(),style:{position:"fixed",top:`${p.top}px`,...p.left!==void 0?{left:`${p.left}px`}:{right:`${p.right}px`},minWidth:zn,backgroundColor:"var(--sa-background-primary, #ffffff)",border:wr,borderRadius:"var(--sa-radii-sm, 6px)",boxShadow:"var(--sa-shadow-xl, 0 20px 25px -5px #0000001a, 0 8px 10px -6px #0000001a)",zIndex:9999,padding:"4px",display:"flex",flexDirection:"column"},children:[r&&e.jsxs(e.Fragment,{children:[e.jsx(Ht,{icon:"ChevronUp",label:"Ascending",active:s==="asc",onClick:()=>b(()=>s==="asc"?l():i("asc"))}),e.jsx(Ht,{icon:"ChevronDown",label:"Descending",active:s==="desc",onClick:()=>b(()=>s==="desc"?l():i("desc"))}),e.jsx("div",{style:{borderTop:wr,margin:"4px 0"}})]}),e.jsx(Ht,{icon:"Pin1",label:o?"Unfreeze":"Freeze",active:o,onClick:()=>b(c)}),n&&e.jsx(Ht,{icon:"EyeClosed",label:"Hide column",danger:!0,onClick:()=>b(a)})]})]})},kt="1px solid var(--sa-border-subtle, #0b120e24)",Vi="var(--sa-text-subtle, #8c8f97)",gt="var(--sa-background-neutral, #f0f1f2)",Hn="2px 0 4px -2px var(--sa-border-subtle, #0b120e24)",Bt=40,Dr="var(--sa-background-brand-subtlest)",Pt={display:"block",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},Pn="sa-table-layout-styles",Ni=()=>{if(typeof document>"u"||document.getElementById(Pn))return;const t=document.createElement("style");t.id=Pn,t.textContent=`
2
2
  .sa-table-layout tbody td {
3
3
  transition: background-color 0.15s ease;
4
4
  background-color: var(--sa-tl-bg, transparent);
@@ -54,7 +54,7 @@
54
54
  .sa-table-layout tfoot.sa-tl-sticky-foot > tr:first-child > th {
55
55
  box-shadow: 0 -2px 4px -2px var(--sa-border-subtle, #0b120e24);
56
56
  }
57
- `,document.head.appendChild(t)},Et=t=>t==="right"?"right":t==="center"?"center":"left",_i=/^(#|rgb|hsl|var\()/,Vt=t=>t?_i.test(t)?t:`var(--sa-background-${t})`:void 0,qi=(t,r)=>{if(r)return t[r]},Zi=(t,r)=>t==null&&r==null?0:t==null?-1:r==null?1:typeof t=="number"&&typeof r=="number"?t-r:String(t).localeCompare(String(r)),Gi=({columns:t,data:r,getRowKey:n,rowBg:s,size:o="md",resizable:i=!1,layout:l="auto",widthStorageKey:c,columnState:a,onColumnStateChange:u,columnMenu:f=!1,sort:g,defaultSort:m,onSortChange:p,height:S,mobileLayout:b="cards",mobileBreakpoint:I="md",groupSeparator:B,summary:F,footer:w,stickyFooter:D=!1,emptyState:A,loading:O=!1,loadingRows:C=8,rowActions:R,selectable:L=!1,selectedKeys:U,defaultSelectedKeys:J,onSelectionChange:N,isRowSelectable:_})=>{Ni();const te=!Ce.useMediaQuery(I)&&b!=="scroll",V=!!(R!=null&&R.length),[z,P]=d.useState(null);d.useEffect(()=>{if(!z)return;const y=()=>P(null),j=setTimeout(()=>document.addEventListener("click",y),0);return()=>{clearTimeout(j),document.removeEventListener("click",y)}},[z]);const[se,ye]=d.useState(()=>new Set),Se=a!==void 0,[xe,pe]=d.useState({}),je=a??xe,be=y=>{u==null||u(y),Se||pe(y)},Te=g!==void 0,[ke,He]=d.useState(m??null),Y=Te?g??null:ke,he=!p,Oe=y=>{p==null||p(y),Te||He(y)},{headerGroups:Ne,leafColumns:ae,hasGroups:_e}=d.useMemo(()=>{var le;const y=new Set(je.hidden??[]),j=(ne,me)=>ne.key??(typeof ne.accessor=="string"?ne.accessor:`col-${me}`),M=t.map((ne,me)=>{var Je;if((Je=ne.children)!=null&&Je.length){const Dt=ne.children.map((Ke,St)=>({col:Ke,key:j(Ke,`${me}-${St}`)})).filter(Ke=>!y.has(Ke.key));return{col:ne,key:ne.key??`group-${me}`,isGroup:!0,leaves:Dt}}const ge={col:ne,key:j(ne,`${me}`)};return{col:ne,key:ge.key,isGroup:!1,leaves:y.has(ge.key)?[]:[ge]}}).filter(ne=>ne.leaves.length>0),Z=M.some(ne=>ne.isGroup);let re=M.flatMap(ne=>ne.leaves);if(!Z&&((le=je.order)!=null&&le.length)){const ne=new Map(je.order.map((me,ge)=>[me,ge]));re=[...re].sort((me,ge)=>(ne.get(me.key)??1/0)-(ne.get(ge.key)??1/0))}return{headerGroups:M,leafColumns:re,hasGroups:Z}},[t,je]),tt=d.useMemo(()=>new Map(ae.map((y,j)=>[y.key,j])),[ae]),W=!_e&&ae.some(y=>(y.col.headerColSpan??1)>1),$=ae.map(y=>y.key).join("|"),Q=(y,j)=>{const M=y.sortKey??(typeof y.accessor=="string"?y.accessor:void 0);return M?j[M]:void 0},de=y=>y.sortable??(!!y.sortKey||typeof y.accessor=="string"),ie=d.useMemo(()=>{if(!he||!Y)return r;const y=ae.find(M=>M.key===Y.key);if(!y)return r;const j=Y.direction==="asc"?1:-1;return[...r].sort((M,Z)=>Zi(Q(y.col,M),Q(y.col,Z))*j)},[r,he,Y,ae]),Be=!_e&&!W,Re=!!c&&Be,[$e,qe]=G.useColumnWidths(c??""),Me=Re?$e:void 0,Qe=d.useRef(null),[we,Ze]=d.useState();d.useLayoutEffect(()=>{Ze(void 0)},[$]),d.useLayoutEffect(()=>{if(!Be||we||!Qe.current)return;const y=Qe.current.querySelectorAll("th.sa-tl-leaf");Ze(Array.from(y).map(j=>j.offsetWidth))},[we,Be]);const[rt,ut]=d.useState(),[ct,at]=d.useState(0);d.useLayoutEffect(()=>{if(!_e||!Qe.current)return;const y=Qe.current.querySelector(":scope > tr");y&&at(y.offsetHeight)},[_e,$]);const ft=(y,j)=>{if((Me==null?void 0:Me[j])!=null)return Me[j];if(y.width!=null)return y.width;if((we==null?void 0:we[j])!=null)return we[j]},k=(y,j)=>typeof y.width=="number"?y.width:we==null?void 0:we[j],q=je.frozenKey&&!_e&&!W?ae.findIndex(y=>y.key===je.frozenKey):-1,K=y=>y<=q,ve=L?Bt:0,Ie=y=>{const j=rt??we;if(!j)return ve;let M=ve;for(let Z=0;Z<y;Z++)M+=j[Z]??0;return M};d.useLayoutEffect(()=>{const y=Qe.current;if(!y||q<0){ut(void 0);return}let j=0;const M=()=>{j=0;const re=y.querySelectorAll("th.sa-tl-leaf"),le=Array.from(re).map(ne=>ne.getBoundingClientRect().width);ut(ne=>ne&&ne.length===le.length&&ne.every((me,ge)=>Math.abs(me-le[ge])<.5)?ne:le)},Z=new ResizeObserver(()=>{j||(j=requestAnimationFrame(M))});return Z.observe(y),y.querySelectorAll("th.sa-tl-leaf").forEach(re=>Z.observe(re)),M(),()=>{j&&cancelAnimationFrame(j),Z.disconnect()}},[$,q,L,we,Me]);const Ue=d.useRef(null),[Ae,De]=d.useState("100vh");d.useLayoutEffect(()=>{if(S!==void 0)return;const y=()=>{if(Ue.current){const j=Ue.current.getBoundingClientRect().top;De(`calc(100vh - ${j}px - var(--sa-floating-footer-height, 0px) + 12px)`)}};return y(),window.addEventListener("resize",y),()=>window.removeEventListener("resize",y)},[S]);const Ee=(y,j)=>n?n(y,j):j,We=U!==void 0,[wt,Vo]=d.useState(()=>new Set(J??[])),st=d.useMemo(()=>We?new Set(U):wt,[We,U,wt]);d.useEffect(()=>{L&&!n&&process.env.NODE_ENV!=="production"&&console.warn("[@starasia/admin] TableLayout: `selectable` tanpa `getRowKey` — key default (index) membuat seleksi menempel ke POSISI baris, bukan datanya. Beri `getRowKey` yang stabil (mis. r => r.id).")},[L,!n]);const Jr=y=>{if(We||Vo(y),N){const j=ie.filter((M,Z)=>y.has(Ee(M,Z)));N(Array.from(y),j)}},sr=(y,j)=>L&&(_?_(y,j):!0),ir=y=>{const j=new Set(st);j.has(y)?j.delete(y):j.add(y),Jr(j)},mt=d.useMemo(()=>L?ie.map((y,j)=>({row:y,i:j,key:Ee(y,j)})).filter(({row:y,i:j})=>_?_(y,j):!0).map(({key:y})=>y):[],[L,ie,_,n]),Yr=mt.filter(y=>st.has(y)),lr=mt.length>0&&Yr.length===mt.length,Xr=Yr.length>0&&!lr,No=()=>{const y=new Set(st);lr?mt.forEach(j=>y.delete(j)):mt.forEach(j=>y.add(j)),Jr(y)},cr=(y,j,M)=>y.render?y.render(j,M,ie):qi(j,y.accessor),ar=ae.length+(L?1:0)+(V?1:0),$r=["80%","55%","70%","45%","90%","60%"],_o=(y,j)=>$r[(y*7+j*3)%$r.length],qo=(y,j)=>e.jsx(Ye.Skeleton,{height:14,width:_o(y,j),borderRadius:"rounded-sm"}),Zo=Array.from({length:C},(y,j)=>e.jsxs(G.Tr,{children:[L&&e.jsx(G.Td,{style:{width:Bt,padding:0},children:e.jsx("div",{style:{display:"flex",justifyContent:"center"},children:e.jsx(Ye.Skeleton,{height:14,width:14,borderRadius:"rounded-sm"})})}),ae.map(({col:M,key:Z},re)=>e.jsx(G.Td,{style:{textAlign:Et(M.align)},children:qo(j,re)},`sa-tl-sk-${j}-${Z}`)),V&&e.jsx(G.Td,{style:{width:1,padding:0,border:"none"}})]},`sa-tl-sk-${j}`)),Go=(y,j)=>{j||be({...je,hidden:[...je.hidden??[],y]})},Qo=y=>be({...je,frozenKey:je.frozenKey===y?void 0:y}),Ot=y=>(R??[]).filter(j=>{var M;return!((M=j.hidden)!=null&&M.call(j,y))}),Kr={position:"absolute",right:0,top:0,bottom:0,display:"flex",alignItems:"center",gap:4,paddingRight:16,paddingLeft:40,background:"linear-gradient(to right, transparent, var(--sa-background-primary-inverse, #f8f8f8) 40px)"},Rt=(y,j,M,Z)=>{var Je;const re=(Je=y.disabled)==null?void 0:Je.call(y,j),le=(Z==null?void 0:Z.showLabel)??y.showLabel,ne=(Z==null?void 0:Z.size)??"xs",me=e.jsx(H.Button,{size:ne,variant:y.variant??"tertiary",tone:y.tone??"neutral",disabled:re,onClick:()=>y.onClick(j,M),iconLeft:y.icon?e.jsx(E.Icon,{name:y.icon,size:"sm"}):void 0,children:le&&y.label}),ge=y.tooltip;return ge?e.jsx(Fe.Tooltip,{label:ge,position:"top-end",children:me}):me},Uo=(y,j)=>{const M=Ot(y);if(!M.length)return null;if(M.length>5){const re=Ee(y,j),le=(z==null?void 0:z.rowKey)===re;return e.jsx("div",{className:"sa-tl-row-actions",style:Kr,onClick:ne=>ne.stopPropagation(),children:e.jsx(Fe.Tooltip,{label:"Aksi lainnya",position:"top",children:e.jsx(H.Button,{size:"xs",variant:"tertiary",onClick:ne=>{const me=ne.currentTarget.getBoundingClientRect();P(le?null:{rowKey:re,top:me.bottom+4,right:window.innerWidth-me.right})},children:e.jsx(E.Icon,{name:"MenuVertical",size:"sm"})})})})}return e.jsx("div",{className:"sa-tl-row-actions",style:Kr,children:M.map(re=>e.jsx(d.Fragment,{children:Rt(re,y,j)},re.key))})},Jo=(y,j)=>{const M=Ot(y);return M.length?e.jsx("div",{style:{display:"flex",gap:6,flexWrap:"wrap",paddingTop:8,marginTop:8,borderTop:kt},children:M.map(Z=>e.jsx(d.Fragment,{children:Rt(Z,y,j,{showLabel:!0,size:"sm"})},Z.key))}):null},Yo=(y,j)=>{const M=Ot(y);return M.length?e.jsx("div",{style:{display:"flex",gap:4,paddingRight:8,flexShrink:0},children:M.map(Z=>e.jsx(d.Fragment,{children:Rt(Z,y,j,{showLabel:!1})},Z.key))}):null},dr=(y,j)=>{const{col:M,key:Z}=y,re=tt.get(Z)??0,le=K(re),ne=le&&re===q,me=(Y==null?void 0:Y.key)===Z?Y.direction:null,ge=f&&!M.disableMenu?e.jsx(Mo,{active:!!me||le,canSort:de(M),canHide:!M.locked,sortDir:me,frozen:le,onSort:St=>Oe({key:Z,direction:St}),onClearSort:()=>Oe(null),onToggleFreeze:()=>Qo(Z),onHide:()=>Go(Z,M.locked)}):null,Je=M.align==="right",Dt=M.align==="right"?"flex-end":M.align==="center"?"center":"flex-start",Ke=e.jsxs("span",{style:{flex:1,minWidth:0,display:"flex",alignItems:"center",gap:6,justifyContent:Dt,overflow:"hidden"},children:[M.icon&&e.jsx(E.Icon,{name:M.icon,size:"sm",style:{flexShrink:0}}),e.jsx("span",{style:Pt,children:M.title})]});return e.jsx(G.Th,{className:`sa-tl-leaf${le?" sa-tl-frozen":""}`,rowSpan:j==null?void 0:j.rowSpan,colSpan:j==null?void 0:j.colSpan,minWidth:M.minWidth,resizable:Be?M.resizable:!1,defaultWidth:k(M,re),style:{textAlign:Et(M.align),width:ft(M,re),position:"sticky",top:(j==null?void 0:j.top)??0,left:le?Ie(re):void 0,zIndex:le?3:2,backgroundColor:gt,boxShadow:ne?Hn:void 0},children:e.jsx("div",{style:{display:"flex",alignItems:"center",gap:6,width:"100%"},children:Je?e.jsxs(e.Fragment,{children:[ge,Ke]}):e.jsxs(e.Fragment,{children:[Ke,ge]})})},`th-${Z}`)},Xo=()=>{const y=[];for(let j=0;j<ae.length;){const M=ae[j],Z=M.col.headerColSpan??1,re=Math.max(1,Math.min(Z,ae.length-j));y.push(dr(M,re>1?{colSpan:re}:void 0)),j+=re}return y},en=y=>e.jsx(G.Th,{rowSpan:y==null?void 0:y.rowSpan,style:{width:Bt,position:"sticky",top:0,left:0,zIndex:4,backgroundColor:gt,padding:0},children:e.jsx("div",{style:{display:"flex",alignItems:"center",justifyContent:"center"},onClick:j=>j.stopPropagation(),children:e.jsx(nt.Checkbox,{size:"sm",variant:Xr?"indeterminate":"select",checked:lr||Xr,disabled:mt.length===0,onChange:No,"aria-label":"Pilih semua baris di halaman ini"})})},"th-select"),$o=(y,j,M)=>{const Z=Ee(y,j);return e.jsx(G.Td,{className:"sa-tl-frozen",style:{width:Bt,padding:0,position:"sticky",left:0,zIndex:2,...M?{"--sa-tl-bg":M}:{}},children:sr(y,j)&&e.jsx("div",{style:{display:"flex",alignItems:"center",justifyContent:"center"},onClick:re=>re.stopPropagation(),children:e.jsx(nt.Checkbox,{size:"sm",checked:st.has(Z),onChange:()=>ir(Z),"aria-label":"Pilih baris"})})},`tl-select-${j}`)},ur=ae.filter(y=>!y.col.hideOnMobile),xr=ur.find(y=>y.col.primary)??ur[0],Ko=ur.filter(y=>y!==xr),es=y=>ye(j=>{const M=new Set(j);return M.has(y)?M.delete(y):M.add(y),M}),tn=(y,j)=>Ko.map(({col:M,key:Z})=>{const re=cr(M,y,j),le=typeof re=="string"||typeof re=="number"?e.jsx(v.Text,{style:{minWidth:0,overflow:"hidden",textOverflow:"ellipsis",textAlign:"right"},children:re}):e.jsx("div",{style:{minWidth:0,overflow:"hidden",textOverflow:"ellipsis",textAlign:"right"},children:re});return e.jsxs("div",{style:{display:"flex",gap:12,justifyContent:"space-between",alignItems:"baseline"},children:[typeof M.title=="string"?e.jsx(v.Text,{color:"subtle",fontWeight:"medium",style:{color:Vi,flexShrink:0},children:M.title}):e.jsx("div",{style:{flexShrink:0},children:M.title}),le]},Z)}),hr=(y,j)=>{const M=xr?cr(xr.col,y,j):null;return typeof M=="string"||typeof M=="number"?e.jsx(v.Text,{as:"span",style:Pt,children:M}):e.jsx("span",{style:Pt,children:M})},ts=e.jsx(x.Box,{style:{display:"flex",flexDirection:"column",gap:8,padding:8},children:Array.from({length:C},(y,j)=>e.jsxs(x.Box,{style:{border:kt,borderRadius:"var(--sa-radii-sm, 6px)",padding:12,display:"flex",flexDirection:"column",gap:8},children:[e.jsx(Ye.Skeleton,{height:16,width:"60%",borderRadius:"rounded-sm"}),e.jsx(Ye.Skeleton,{height:12,width:"85%",borderRadius:"rounded-sm"}),e.jsx(Ye.Skeleton,{height:12,width:"70%",borderRadius:"rounded-sm"})]},`sa-tl-sk-card-${j}`))}),rn=e.jsx(x.Box,{fullWidth:!0,style:{minHeight:(A==null?void 0:A.minHeight)??320,display:"flex",alignItems:"center",justifyContent:"center",padding:16},children:A==null?void 0:A.content}),rs=O?ts:ie.length===0?rn:b==="expand"?e.jsx(x.Box,{style:{display:"flex",flexDirection:"column"},children:ie.map((y,j)=>{const M=Ee(y,j),Z=se.has(M),le=L&&st.has(M)?Dr:Vt(s==null?void 0:s(y,j));return e.jsxs("div",{style:{borderBottom:kt,backgroundColor:le},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center"},children:[sr(y,j)&&e.jsx("div",{style:{display:"flex",alignItems:"center",paddingLeft:12,flexShrink:0},children:e.jsx(nt.Checkbox,{size:"sm",checked:st.has(M),onChange:()=>ir(M),"aria-label":"Pilih baris"})}),e.jsxs("button",{type:"button",onClick:()=>es(M),style:{flex:1,minWidth:0,display:"flex",alignItems:"center",justifyContent:"space-between",gap:12,padding:"10px 12px",background:"none",border:"none",font:"inherit",color:"inherit",cursor:"pointer",textAlign:"left"},children:[hr(y,j),e.jsx(E.Icon,{name:Z?"ChevronUp":"ChevronDown",size:"sm",style:{flexShrink:0}})]}),V&&Yo(y,j)]}),Z&&e.jsx("div",{style:{padding:"0 12px 12px",display:"flex",flexDirection:"column",gap:6},children:tn(y,j)})]},M)})}):e.jsx(x.Box,{style:{display:"flex",flexDirection:"column",gap:8,padding:8},children:ie.map((y,j)=>{const M=Ee(y,j),Z=L&&st.has(M);return e.jsxs(x.Box,{style:{border:kt,borderRadius:"var(--sa-radii-sm, 6px)",padding:12,display:"flex",flexDirection:"column",gap:6,backgroundColor:Z?Dr:Vt(s==null?void 0:s(y,j))},children:[sr(y,j)?e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[e.jsx(nt.Checkbox,{size:"sm",checked:st.has(M),onChange:()=>ir(M),"aria-label":"Pilih baris"}),e.jsx("div",{style:{flex:1,minWidth:0},children:hr(y,j)})]}):hr(y,j),tn(y,j),V&&Jo(y,j)]},M)})}),ns=i&&Be&&we!==void 0,nn=l==="fixed"&&!i&&(Be?we!==void 0:!0),os=nn&&!Be,At=w&&w.length>0?w.map((y,j)=>e.jsx(G.Tr,{children:y.cells.map((M,Z)=>e.jsx(G.Td,{colSpan:M.colSpan,rowSpan:M.rowSpan,style:{textAlign:Et(M.align)},children:M.content},`tl-foot-${j}-${Z}`))},`tl-foot-${j}`)):null,ss=e.jsxs(G.Table,{className:"sa-table-layout",fullWidth:!0,size:o,resizable:ns,style:nn?{tableLayout:"fixed"}:void 0,onWidthsChange:Re?qe:void 0,children:[os&&e.jsxs("colgroup",{children:[L&&e.jsx("col",{style:{width:Bt}}),ae.map(({col:y,key:j},M)=>e.jsx("col",{style:{width:ft(y,M)}},`col-${j}`)),V&&e.jsx("col",{style:{width:1}})]}),e.jsx(G.Thead,{ref:Qe,children:_e?e.jsxs(e.Fragment,{children:[e.jsxs(G.Tr,{children:[L&&en({rowSpan:2}),Ne.map(y=>y.isGroup?e.jsx(G.Th,{colSpan:y.leaves.length,style:{textAlign:"center",position:"sticky",top:0,zIndex:2,backgroundColor:gt},children:e.jsx("span",{style:Pt,children:y.col.title})},`grp-${y.key}`):dr(y.leaves[0],{rowSpan:2})),V&&e.jsx(G.Th,{rowSpan:2,style:{position:"sticky",top:0,right:0,zIndex:3,width:1,padding:0,border:"none",backgroundColor:gt}})]}),e.jsx(G.Tr,{children:Ne.flatMap(y=>y.isGroup?y.leaves.map(j=>dr(j,{top:ct})):[])})]}):e.jsxs(G.Tr,{children:[L&&en(),Xo(),V&&e.jsx(G.Th,{style:{position:"sticky",top:0,right:0,zIndex:3,width:1,padding:0,border:"none",backgroundColor:gt}})]})}),e.jsx(G.Tbody,{children:O?Zo:ie.length===0?e.jsx(G.Tr,{children:e.jsx(G.Td,{colSpan:ar,children:rn})}):e.jsxs(e.Fragment,{children:[ie.map((y,j)=>{const M=B==null?void 0:B(y,j,j>0?ie[j-1]:void 0),re=L&&st.has(Ee(y,j))?Dr:Vt(s==null?void 0:s(y,j));return e.jsxs(d.Fragment,{children:[M!=null&&M!==!1&&e.jsx(G.Tr,{children:e.jsx(G.Td,{colSpan:ar,style:{backgroundColor:gt},children:M})}),e.jsxs(G.Tr,{children:[L&&$o(y,j,re),ae.map(({col:le,key:ne},me)=>{var sn;const ge=(sn=le.cellProps)==null?void 0:sn.call(le,y,j,ie);if(ge!=null&&ge.hidden)return null;const Je=K(me),Dt=Je&&me===q,Ke=cr(le,y,j),St=typeof le.bg=="function"?le.bg(y,j,ie):le.bg,on=Vt(St)??re;return e.jsx(G.Td,{className:Je?"sa-tl-frozen":void 0,colSpan:ge==null?void 0:ge.colSpan,rowSpan:ge==null?void 0:ge.rowSpan,style:{textAlign:Et(le.align),width:ft(le,me),minWidth:le.minWidth,position:Je?"sticky":void 0,left:Je?Ie(me):void 0,zIndex:Je?1:void 0,boxShadow:Dt?Hn:void 0,...on?{"--sa-tl-bg":on}:{}},children:typeof Ke=="string"?e.jsx(v.Text,{style:{whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",textAlign:Et(le.align)},children:Ke}):Ke},`tl-cell-${j}-${ne}`)}),V&&e.jsx(G.Td,{style:{position:"sticky",right:0,width:1,padding:0,overflow:"visible",zIndex:2,border:"none"},children:Uo(y,j)})]})]},Ee(y,j))}),F!=null&&e.jsx(G.Tr,{children:e.jsx(G.Td,{colSpan:ar,children:F})})]})}),At&&e.jsx(G.Tfoot,{className:D?"sa-tl-sticky-foot":void 0,children:At})]}),fr=z?ie.findIndex((y,j)=>Ee(y,j)===z.rowKey):-1,mr=fr>=0?ie[fr]:null;return e.jsxs(e.Fragment,{children:[e.jsx(x.Box,{ref:Ue,fullWidth:!0,style:{overflow:"auto",height:S??Ae},children:te?e.jsxs(e.Fragment,{children:[rs,At&&!O&&ie.length>0&&e.jsx(x.Box,{style:{borderTop:kt},children:e.jsx(G.Table,{fullWidth:!0,size:o,className:"sa-table-layout",children:e.jsx(G.Tbody,{children:At})})})]}):ss}),z&&mr&&e.jsx("div",{className:"sa-tl-kebab-menu",style:{top:z.top,right:z.right},onClick:y=>y.stopPropagation(),children:Ot(mr).map(y=>e.jsx("div",{style:{padding:"2px 4px"},children:Rt(y,mr,fr,{showLabel:!0,size:"sm"})},y.key))})]})},Sr=t=>t==="asc"||t==="desc",Qi=(t={})=>{const{sortKeyParam:r="sortBy",sortOrderParam:n="sortOrder",pageKey:s="page",defaultSort:o=null,paramKeys:i,scopeId:l,storage:c=Ur}=t,{searchParams:a,setSearchParams:u,searchQueries:f}=Ve(),g=a.toString(),m=l?Ct.tableSort(l):void 0,p=d.useRef(!1);d.useEffect(()=>{if(p.current||(p.current=!0,!m)||a.has(r)||a.has(n))return;const w=c.get(m);!(w!=null&&w.key)||!Sr(w.direction)||u({...Object.fromEntries(a.entries()),[r]:w.key,[n]:w.direction})},[]);const S=d.useMemo(()=>{const w=a.get(r),D=a.get(n);return w&&Sr(D)?{key:w,direction:D}:o},[g,r,n,o]);d.useEffect(()=>{if(!m)return;const w=a.get(r),D=a.get(n);w&&Sr(D)?c.set(m,{key:w,direction:D}):c.remove(m)},[g,m,r,n,c]);const b=(i==null?void 0:i.sortBy)??"sortBy",I=(i==null?void 0:i.sortOrder)??"sortOrder",B=d.useMemo(()=>S?{[b]:S.key,[I]:S.direction}:{},[S,b,I]),F=d.useCallback(w=>{const D={...f};w?(D[r]=w.key,D[n]=w.direction):(delete D[r],delete D[n]),delete D[s],u(D)},[f,r,n,s,u]);return{sort:S,setSort:F,params:B}},Kt=({of:t,render:r})=>d.Children.toArray(t==null?void 0:t.map((n,s,o)=>r(n,s,o))),ue=({condition:t,fallback:r,children:n,loading:s,isLoading:o})=>e.jsx(e.Fragment,{children:o?s:t?n:r}),fe=t=>e.jsx(v.Text,{...t,fontSize:t.fontSize||"md",fontWeight:t.fontWeight||"medium",color:t.color||"gray-700",children:t.children}),lt=t=>e.jsx(v.Text,{color:"red-600",fontSize:"sm",children:t.message}),Ui=({size:t="md",direction:r="vertical",requiredTitle:n="(Required)",fullWidth:s=!1,...o})=>{var c,a,u;const i=o.hideMessageError||!1,l=r==="horizontal"?t==="sm"?342:t==="lg"?400:342:void 0;return e.jsxs(x.Box,{gap:r==="horizontal"?"spacing-96":"sm",direction:r==="horizontal"?"row":"column",...o.containerProps,children:[o.title&&e.jsx(ue,{condition:!!o.inputProps.required,fallback:e.jsxs(x.Box,{direction:"column",customMaxWidth:l,fullWidth:s,children:[e.jsx(fe,{children:o.title}),e.jsx(v.Text,{fontSize:t,color:"gray-500",children:o.description})]}),children:e.jsxs(x.Box,{direction:"column",customMaxWidth:l,fullWidth:s,children:[e.jsxs(ce.Flex,{direction:"row",gap:"xs",align:"center",children:[e.jsx(fe,{fontSize:t,children:o.title}),e.jsx(fe,{color:"error",fontSize:t,children:n}),e.jsx(ue,{condition:!!((c=o.tooltip)!=null&&c.label),children:e.jsx(Fe.Tooltip,{label:(a=o.tooltip)==null?void 0:a.label,arrowPosition:(u=o.tooltip)==null?void 0:u.arrowPosition,...o.tooltip,children:e.jsx(E.Icon,{name:"InfoCircle",size:t==="lg"?"sm":"xs",style:{color:"var(--sa-color-info-500, #00abeb)",marginTop:"6px"}})})})]}),e.jsx(ue,{condition:!!o.description,children:e.jsx(v.Text,{fontSize:t,color:"gray-500",children:o.description})})]})}),e.jsxs(x.Box,{direction:"column",gap:"xs",fullWidth:o.inputProps.fullWidth||!1,children:[e.jsx(dt.Input,{ref:o.inputRef,size:t,...o.inputProps,status:o.errorMessage?"error":"default",fullWidth:!0}),!i&&o.errorMessage&&e.jsx(lt,{message:o.errorMessage}),o.inputProps.extended&&o.inputProps.extended]})]})},Ji=({size:t="md",direction:r="vertical",requiredTitle:n="(Required)",fullWidth:s=!1,...o})=>{var c,a,u;const i=o.hideMessageError||!1,l=r==="horizontal"?t==="sm"?342:t==="lg"?400:342:void 0;return e.jsxs(x.Box,{gap:r==="horizontal"?"spacing-96":"sm",direction:r==="horizontal"?"row":"column",onClick:o.onClickContainer,children:[o.title&&e.jsx(ue,{condition:!!o.inputProps.required,fallback:e.jsxs(x.Box,{direction:"column",customMaxWidth:l,fullWidth:s,children:[e.jsx(fe,{children:o.title}),e.jsx(v.Text,{fontSize:t,color:"gray-500",children:o.description})]}),children:e.jsxs(x.Box,{direction:"column",customMaxWidth:l,fullWidth:s,children:[e.jsxs(ce.Flex,{direction:"row",gap:"xs",align:"center",children:[e.jsx(fe,{fontSize:t,children:o.title}),e.jsx(fe,{color:"error",fontSize:t,children:n}),e.jsx(ue,{condition:!!((c=o.tooltip)!=null&&c.label),children:e.jsx(Fe.Tooltip,{label:(a=o.tooltip)==null?void 0:a.label,arrowPosition:(u=o.tooltip)==null?void 0:u.arrowPosition,...o.tooltip,children:e.jsx(E.Icon,{name:"InfoCircle",size:t==="lg"?"sm":"xs",style:{color:"var(--sa-color-info-500, #00abeb)",marginTop:"6px"}})})})]}),e.jsx(ue,{condition:!!o.description,children:e.jsx(v.Text,{fontSize:t,color:"gray-500",children:o.description})})]})}),e.jsxs(x.Box,{direction:"column",gap:"xs",fullWidth:o.inputProps.fullWidth||!1,children:[e.jsx(x.Box,{direction:"column",style:{width:o.inputProps.fullWidth?"100%":r==="horizontal"&&o.customWidth?o.customWidth:r==="horizontal"?"343px":""},children:e.jsx(jt.Dropdown,{size:t,...o.inputProps,error:!!o.errorMessage})}),!i&&o.errorMessage&&e.jsx(lt,{message:o.errorMessage}),o.inputProps.extended&&o.inputProps.extended]})]})},Yi=(t,r)=>typeof t=="string"&&t||r==="error"?"var(--sa-border-danger)":"var(--sa-border-subtle)",Xi=t=>{var c;const[r,n]=d.useState(!1),s=a=>{a.preventDefault(),a.stopPropagation()},o=a=>{a.preventDefault(),a.stopPropagation(),a.dataTransfer&&t.handleOnFileChange(a.dataTransfer.files.item(0))},i=a=>{a.preventDefault(),n(!0)},l=a=>{a.preventDefault(),n(!1)};return e.jsxs(x.Box,{width:"width-full",paddingInline:"md",direction:"row",gap:"sm",align:"center",onClick:t.handleOnClick,onDragOver:s,onDrop:o,onDragEnter:i,onDragLeave:l,paddingBlock:"md",borderRadius:"rounded-md",style:{border:r?"1px solid var(--sa-border-info)":`1px solid ${Yi(t.errorMessage,t.status)}`},children:[e.jsx(E.Icon,{name:"Upload",size:"lg",style:{width:30,height:30}}),e.jsxs(ce.Flex,{direction:"column",gap:"xs",children:[e.jsxs(ce.Flex,{direction:"row",gap:"xs",children:[e.jsx(v.Text,{fontWeight:"medium",color:"gray-500",style:{textWrap:"nowrap"},fontSize:t.isDesktop?"md":"sm",children:"Click your upload"}),e.jsx(v.Text,{fontWeight:"medium",style:{textWrap:"nowrap"},fontSize:t.isDesktop?"md":"sm",children:"or Drag & Drop"})]}),e.jsx(v.Text,{fontSize:"sm",color:"gray-500",children:(c=t.fileSupports)==null?void 0:c.map(a=>a.toLocaleUpperCase()).join(", ")})]})]})};function $i(t){return t.split(" ").map(r=>r[0]).join("").slice(0,2).toUpperCase()}const Io=t=>{const r={day:"2-digit",month:"short",year:"numeric"};return t.toLocaleDateString("id-ID",r)},Ki=t=>{const r={Jan:0,Feb:1,Mar:2,Apr:3,Mei:4,Jun:5,Jul:6,Agu:7,Sep:8,Okt:9,Nov:10,Des:11},n=t.split(" ");if(n.length!==3)return null;const s=parseInt(n[0],10),o=r[n[1]],i=parseInt(n[2],10);return isNaN(s)||isNaN(o)||isNaN(i)?null:new Date(i,o,s)};function el(t,r=!0){if(!t)return"Rp 0";const n=typeof t=="number"?t.toString():t;if(isNaN(Number(n)))return"Rp 0";const s=n.split("."),o=s[0].replace(/\B(?=(\d{3})+(?!\d))/g,"."),i=s.length===2?o+"."+s[1]:o;return r?"Rp"+i:i}String.prototype.toTitleCase=function(){return this.toLowerCase().split(" ").map(t=>t.charAt(0).toUpperCase()+t.slice(1)).join(" ")};String.prototype.toNumber=function(){return Number(this)};const tl=t=>{const r=t.split(" ");let n=r[0].charAt(0);return r.length>1&&(n+=""+r[1].charAt(0)),n.toUpperCase()};function rl(t){const r=typeof t=="string"?new Date(t):t;if(isNaN(r.getTime()))throw new Error("Invalid date format");const n=r.getFullYear(),s=String(r.getMonth()+1).padStart(2,"0"),o=String(r.getDate()).padStart(2,"0");return`${n}-${s}-${o}`}const nl="sa-admin",et=t=>`var(--${nl}-${t})`,ol={base:{borderColor:et("base-border-color"),textColor:et("base-text-color"),iconColor:et("base-icon-color"),placeholderColor:et("base-placeholder-color")},document:{bgColor:et("document-bg-color")},sidebar:{bgColor:et("sidebar-bg-color"),borderColor:et("sidebar-border-color"),maxWidth:et("sidebar-max-width"),width:et("sidebar-width"),collapseWidth:et("sidebar-collapse-width"),collapseV2Width:et("sidebar-v2-collapse-width")}},sl=24*60*60*1e3,il=t=>{const r="14px poppins",s=document.createElement("canvas").getContext("2d");s.font=r;const o=s.measureText(t).width;return Number(Math.ceil(o))},ll=/^[^\s@]+@[^\s@]+\.[^\s@]+$/,cl=/--+/,al=/-$/;function dl(t,r){return JSON.stringify(t)!==JSON.stringify(r)}function ul(t){return/^(?:\+62|62|0)8[1-9][0-9]{7,10}$/.test(t)}function xl(t){return/^[A-Za-z\s]+$/.test(t)}const hl=t=>{const r=/^[0-9]$/,n=["ArrowLeft","ArrowRight","ArrowUp","ArrowDown","Backspace","Delete","Enter","Tab"];(t.ctrlKey||t.metaKey)&&(t.key==="a"||t.key==="c"||t.key==="v")||!r.test(t.key)&&!n.includes(t.key)&&t.preventDefault()},fl=t=>{const r=/^[0-9]$/,n=["ArrowLeft","ArrowRight","ArrowUp","ArrowDown","Backspace","Delete","Enter","Tab"];(t.ctrlKey||t.metaKey)&&t.key==="v"||r.test(t.key)&&!n.includes(t.key)&&t.preventDefault()},ml=t=>{const r=/^[0-9.]$/,n=["ArrowLeft","ArrowRight","ArrowUp","ArrowDown","Backspace","Delete","Enter","Tab"];(t.ctrlKey||t.metaKey)&&t.key==="v"||!r.test(t.key)&&!n.includes(t.key)&&t.preventDefault()},gl=t=>ll.test(t);function yl(t){return!(cl.test(t)||al.test(t))}const pl=t=>{const r=["ArrowLeft","ArrowRight","ArrowUp","ArrowDown","Backspace","Delete","Enter","Tab","Home","End"];if((t.ctrlKey||t.metaKey)&&["a","c","v","x"].includes(t.key.toLowerCase()))return;const n=t.currentTarget.value;/^[0-9]$/.test(t.key)||t.key==="."&&!n.includes(".")||t.key==="-"&&n.length===0&&!n.includes("-")||r.includes(t.key)||t.preventDefault()},jl=t=>{const r=document.getElementById(t);if(r){const n=r.getBoundingClientRect(),s=window.scrollY+n.top-80;window.scrollTo({top:s,behavior:"smooth"})}};function bl(t){const r=t.toLowerCase();if(["kb","mb","gb"].find(i=>r.endsWith(i)))return t;const o=Number(t);if(isNaN(o))throw new Error("Invalid size format");return o>=1e6?`${(o/1e6).toFixed(2)}MB`:o>=1e3?`${(o/1e3).toFixed(2)}KB`:`${o}B`}function vl(t){const r=t.split("/");return r[r.length-1]}const Cl=t=>{var r,n;return e.jsxs(x.Box,{width:"width-full",paddingInline:"md",height:"height-full",direction:"row",justify:"space-between",align:"center",onClick:t.handleOnClickFile,fullHeight:!0,paddingBlock:"md",id:"file-item",borderRadius:"rounded-md",style:{border:"1px solid var(--sa-border-subtle)",cursor:"pointer"},children:[e.jsxs(ce.Flex,{direction:"row",align:"center",gap:"sm",style:{flex:1,minWidth:0},children:[e.jsx(E.Icon,{name:"DocumentFilled",size:"lg",style:{color:"var(--sa-icon-brand)",width:30,height:30,flexShrink:0}}),e.jsxs(ce.Flex,{direction:"column",style:{minWidth:0,flex:1},children:[e.jsx(v.Text,{fontWeight:"bold",style:{textOverflow:"ellipsis",whiteSpace:"nowrap",overflow:"hidden"},children:t.defaultFile?vl(t.defaultFile.url):(r=t.fileSelected)==null?void 0:r.name}),t.defaultFile?(t.defaultFile.size||t.defaultFile.date)&&e.jsxs(ce.Flex,{direction:"row",gap:"xs",align:"center",children:[t.defaultFile.size&&e.jsx(v.Text,{fontSize:"sm",fontWeight:"medium",children:t.defaultFile.size}),t.defaultFile.size&&t.defaultFile.date&&e.jsx(E.Icon,{name:"Dot",size:"xs"}),t.defaultFile.date&&e.jsx(v.Text,{fontSize:"sm",fontWeight:"medium",style:{textWrap:"nowrap"},children:t.defaultFile.date})]}):e.jsxs(ce.Flex,{direction:"row",gap:"xs",align:"center",children:[e.jsx(v.Text,{fontSize:"sm",fontWeight:"medium",children:bl(((n=t.fileSelected)==null?void 0:n.size.toString())||"100000")}),e.jsx(E.Icon,{name:"Dot",size:"xs"}),e.jsx(v.Text,{fontSize:"sm",fontWeight:"medium",style:{textWrap:"nowrap"},children:Io(new Date)})]})]})]}),e.jsx(H.Button,{size:"xs",variant:"tertiary",tone:"error",type:"button",onClick:s=>{s.stopPropagation(),t.handleOnDeleteFile()},iconLeft:e.jsx(E.Icon,{name:"Trash1"})})]})},Lo=({status:t="default",labelPosition:r="outside-top",...n})=>{var m;const s=d.useRef(null),o=()=>{if(n.defaultFile){window.open(n.defaultFile.url);return}s.current&&s.current.click()},i=Ce.useMediaQuery("md"),l=t==="error"||typeof n.errorMessage=="string"&&!!n.errorMessage,c=n.label?e.jsxs(ce.Flex,{direction:"row",align:"center",gap:"xs",children:[e.jsx(v.Text,{style:{fontSize:"14px",fontWeight:500,color:"var(--sa-text-primary)"},children:n.label}),n.optional&&e.jsx("span",{style:{background:"var(--sa-background-neutral)",border:"1px solid var(--sa-border-subtle)",borderRadius:"4px",padding:"0 8px",fontSize:"10px",fontWeight:500,lineHeight:"18px",color:"var(--sa-text-primary)",display:"inline-flex",alignItems:"center"},children:"Optional"}),n.required&&e.jsx("span",{style:{fontSize:"14px",fontWeight:500,color:"var(--sa-text-error)"},children:"*"})]}):null,a=n.description?e.jsx(v.Text,{style:{fontSize:"12px",fontWeight:400,color:"var(--sa-text-subtlest, #6b6e76)",lineHeight:"18px"},children:n.description}):null,u=e.jsxs(e.Fragment,{children:[n.helperText&&e.jsx(v.Text,{style:{fontSize:"12px",fontWeight:400,color:"var(--sa-text-subtlest, #6b6e76)",lineHeight:"18px"},children:n.helperText}),n.errorText&&t==="error"&&e.jsx(v.Text,{style:{fontSize:"12px",fontWeight:400,color:"var(--sa-text-error, #a4133c)",lineHeight:"18px"},children:n.errorText}),n.errorMessage&&!n.errorText&&e.jsx(v.Text,{style:{fontSize:"12px",fontWeight:400,color:"var(--sa-text-error, #a4133c)",lineHeight:"18px"},children:n.errorMessage})]}),f=e.jsx("input",{type:"file",style:{display:"none"},ref:s,onChange:p=>{var S;return n.handleOnChangeFile(((S=p.target.files)==null?void 0:S.item(0))||null)},accept:(m=n.fileSupportOption)==null?void 0:m.map(p=>"."+(p==null?void 0:p.toLowerCase())).join(", ")}),g=e.jsxs(x.Box,{direction:"column",fullWidth:!0,style:{minHeight:"69px"},borderRadius:"rounded-md",display:"flex",justify:"center",align:"center",cursor:"pointer",gap:"md",...n.containerProps,children:[f,(n.fileSelected||n.defaultFile)&&e.jsx(Cl,{fileSelected:n.fileSelected,defaultFile:n.defaultFile,handleOnDeleteFile:n.handleOnDeleteFile,handleOnClickFile:o}),!n.fileSelected&&!n.defaultFile&&e.jsx(Xi,{fileSupports:n.fileSupportOption,isDesktop:i,errorMessage:l?n.errorText||n.errorMessage||" ":void 0,status:l?"error":"default",handleOnClick:o,handleOnFileChange:n.handleOnChangeFile})]});return r==="outside-left"?e.jsxs(ce.Flex,{direction:"row",align:"flex-start",gap:"sm",style:{width:"100%"},children:[e.jsxs(ce.Flex,{direction:"column",gap:"xs",style:{width:"40%",minWidth:"120px",paddingTop:"10px"},children:[c,a]}),e.jsxs(ce.Flex,{direction:"column",gap:"sm",style:{flex:1,minWidth:0},children:[g,u]})]}):e.jsxs(ce.Flex,{direction:"column",gap:"sm",style:{width:"100%"},children:[c,a,g,u]})},wl=({size:t="md",direction:r="vertical",requiredTitle:n="(Required)",fullWidth:s=!1,...o})=>{var c,a,u;const i=o.hideMessageError||!1,l=r==="horizontal"?t==="sm"?342:t==="lg"?400:342:void 0;return e.jsxs(x.Box,{gap:r==="horizontal"?"spacing-96":"sm",direction:r==="horizontal"?"row":"column",...o.containerProps,children:[o.title&&e.jsx(ue,{condition:!!o.inputProps.required,fallback:e.jsxs(x.Box,{direction:"column",customMaxWidth:l,fullWidth:s,children:[e.jsx(fe,{children:o.title}),e.jsx(v.Text,{fontSize:t,color:"gray-500",children:o.description})]}),children:e.jsxs(x.Box,{direction:"column",customMaxWidth:l,fullWidth:s,children:[e.jsxs(ce.Flex,{direction:"row",gap:"xs",align:"center",children:[e.jsx(fe,{fontSize:t,children:o.title}),e.jsx(fe,{color:"error",fontSize:t,children:n}),e.jsx(ue,{condition:!!((c=o.tooltip)!=null&&c.label),children:e.jsx(Fe.Tooltip,{label:(a=o.tooltip)==null?void 0:a.label,arrowPosition:(u=o.tooltip)==null?void 0:u.arrowPosition,...o.tooltip,children:e.jsx(E.Icon,{name:"InfoCircle",size:t==="lg"?"sm":"xs",style:{color:"var(--sa-color-info-500, #00abeb)",marginTop:"6px"}})})})]}),e.jsx(ue,{condition:!!o.description,children:e.jsx(v.Text,{fontSize:t,color:"gray-500",children:o.description})})]})}),e.jsxs(ce.Flex,{direction:"column",gap:"xs",children:[e.jsx(Lo,{...o.inputProps,status:o.errorMessage?"error":"default"}),!i&&o.errorMessage&&e.jsx(lt,{message:o.errorMessage})]})]})},Dl=({size:t="md",direction:r="vertical",requiredTitle:n="(Required)",fullWidth:s=!1,required:o=!1,...i})=>{var a,u,f,g;const l=i.hideMessageError||!1,c=r==="horizontal"?t==="sm"?342:t==="lg"?400:342:void 0;return e.jsxs(x.Box,{gap:r==="horizontal"||r==="horizontal-inline"?"spacing-96":"sm",direction:r==="horizontal"||r==="horizontal-inline"?"row":"column",...i.containerProps,children:[i.title&&e.jsx(ue,{condition:!!o,fallback:e.jsxs(x.Box,{direction:"column",customMaxWidth:c,fullWidth:s,children:[e.jsx(fe,{children:i.title}),e.jsx(Xe.Body3,{props:{color:"gray-500"},children:i.description})]}),children:e.jsxs(x.Box,{direction:"column",customMaxWidth:c,fullWidth:s,children:[e.jsxs(ce.Flex,{direction:"row",gap:"xs",align:"center",children:[e.jsx(fe,{fontSize:t,children:i.title}),e.jsx(fe,{color:"error",fontSize:t,children:n}),e.jsx(ue,{condition:!!((a=i.tooltip)!=null&&a.label),children:e.jsx(Fe.Tooltip,{label:(u=i.tooltip)==null?void 0:u.label,arrowPosition:(f=i.tooltip)==null?void 0:f.arrowPosition,...i.tooltip,children:e.jsx(E.Icon,{name:"InfoCircle",size:t==="lg"?"sm":"xs",style:{color:"var(--sa-color-info-500, #00abeb)",marginTop:"6px"}})})})]}),e.jsx(ue,{condition:!!i.description,children:e.jsx(v.Text,{fontSize:t,color:"gray-500",children:i.description})})]})}),e.jsx(x.Box,{gap:r==="horizontal-inline"?"xl":"md",direction:r==="horizontal-inline"?"row":"column",align:"flex-start",children:e.jsx(Kt,{of:(g=i.checkBoxesList)==null?void 0:g.map(m=>({...m,isChecked:i.checkBoxesAreChecked.includes(m.id)})),render:m=>m.renderBadge?e.jsxs(x.Box,{direction:"row",justify:"space-between",gap:"lg",...i.badgeContainerProps,children:[e.jsx(nt.Checkbox,{name:m.name,value:m.id,checked:m.isChecked,onChange:p=>i.onChecked(p.target.value,m),label:m.name,description:m.description}),m.renderBadge]}):e.jsx(nt.Checkbox,{name:m.name,value:m.id,checked:m.isChecked,onChange:p=>i.onChecked(p.target.value,m),label:m.name,description:m.description})})}),!l&&i.errorMessage&&e.jsx(lt,{message:i.errorMessage})]})},Sl=({position:t="vertical",size:r="md",fullWidth:n=!1,...s})=>{var i;const o=t==="horizontal-inline"||t==="horizontal-block"?r==="sm"?342:r==="lg"?400:342:void 0;return e.jsxs(x.Box,{gap:t==="horizontal-inline"||t==="horizontal-block"?"spacing-96":"sm",direction:t==="horizontal-inline"||t==="horizontal-block"?"row":"column",children:[e.jsx(ue,{condition:!!s.description||!!s.title,children:e.jsxs(x.Box,{direction:"column",customMaxWidth:o,fullWidth:n,children:[s.title&&e.jsx(fe,{children:s.title}),e.jsx(ue,{condition:!!s.description,children:e.jsx(v.Text,{color:"gray-500",children:s.description})})]})}),e.jsx(x.Box,{gap:"sm",direction:t==="horizontal"||t==="horizontal-inline"?"row":"column",align:"flex-start",flexWrap:"wrap",children:e.jsx(Kt,{of:(i=s.radioList)==null?void 0:i.map(l=>({...l,isChecked:s.radioIsChecked===l.id})),render:({value:l,id:c,isChecked:a,subInput:u,label:f,description:g})=>e.jsxs(x.Box,{direction:"column",gap:"xs",customMaxWidth:o,children:[e.jsx(Mr.Radio,{id:`${c.toString()}-${l}`,name:s.groupName||f,label:f,value:l,checked:a,onChange:m=>s.onChecked({id:c,label:m.target.name,value:m.target.value}),disabled:s.disableAll},c),g&&e.jsx(v.Text,{color:"gray-500",style:{marginLeft:28},children:g}),u]})})}),s.errorMessage&&e.jsx(lt,{message:s.errorMessage})]})},kl=({size:t="md",direction:r="vertical",requiredTitle:n="(Required)",fullWidth:s=!1,...o})=>{var c,a,u;const i=o.hideMessageError||!1,l=r==="horizontal"?t==="sm"?342:t==="lg"?400:342:void 0;return e.jsxs(x.Box,{gap:r==="horizontal"?"spacing-96":"sm",direction:r==="horizontal"?"row":"column",...o.containerProps,children:[o.title&&e.jsx(ue,{condition:!!o.inputProps.required,fallback:e.jsxs(x.Box,{direction:"column",customMaxWidth:l,fullWidth:s,children:[e.jsx(fe,{children:o.title}),e.jsx(v.Text,{fontSize:t,color:"gray-500",children:o.description})]}),children:e.jsxs(x.Box,{direction:"column",customMaxWidth:l,fullWidth:s,children:[e.jsxs(ce.Flex,{direction:"row",gap:"xs",align:"center",children:[e.jsx(fe,{fontSize:t,children:o.title}),e.jsx(fe,{color:"error",fontSize:t,children:n}),e.jsx(ue,{condition:!!((c=o.tooltip)!=null&&c.label),children:e.jsx(Fe.Tooltip,{label:(a=o.tooltip)==null?void 0:a.label,arrowPosition:(u=o.tooltip)==null?void 0:u.arrowPosition,...o.tooltip,children:e.jsx(E.Icon,{name:"InfoCircle",size:t==="lg"?"sm":"xs",style:{color:"var(--sa-color-info-500, #00abeb)",marginTop:"6px"}})})})]}),e.jsx(ue,{condition:!!o.description,children:e.jsx(v.Text,{fontSize:t,color:"gray-500",children:o.description})})]})}),e.jsxs(ce.Flex,{direction:"column",gap:"xs",children:[e.jsx(Fr.Textarea,{ref:o.inputRef,size:t,...o.inputProps,status:o.errorMessage?"error":"default"}),!i&&o.errorMessage&&e.jsx(lt,{message:o.errorMessage})]})]})},Bl=({size:t="md",direction:r="vertical",requiredTitle:n="(Required)",required:s=!1,fullWidth:o=!1,...i})=>{var c,a,u;const l=r==="horizontal"?t==="sm"?342:t==="lg"?400:342:void 0;return e.jsxs(x.Box,{gap:r==="horizontal"?"spacing-96":"sm",direction:r==="horizontal"?"row":"column",...i.containerProps,children:[i.title&&e.jsx(ue,{condition:s,fallback:e.jsxs(x.Box,{direction:"column",customMaxWidth:l,fullWidth:o,children:[e.jsx(fe,{children:i.title}),e.jsx(v.Text,{fontSize:t,color:"gray-500",children:i.titleDescription})]}),children:e.jsxs(x.Box,{direction:"column",customMaxWidth:l,fullWidth:o,children:[e.jsxs(ce.Flex,{direction:"row",gap:"xs",align:"center",children:[e.jsx(fe,{fontSize:t,children:i.title}),e.jsx(fe,{color:"error",fontSize:t,children:n}),e.jsx(ue,{condition:!!((c=i.tooltip)!=null&&c.label),children:e.jsx(Fe.Tooltip,{label:(a=i.tooltip)==null?void 0:a.label,arrowPosition:(u=i.tooltip)==null?void 0:u.arrowPosition,...i.tooltip,children:e.jsx(E.Icon,{name:"InfoCircle",size:t==="lg"?"sm":"xs",style:{color:"var(--sa-color-info-500, #00abeb)",marginTop:"6px"}})})})]}),e.jsx(ue,{condition:!!i.titleDescription,children:e.jsx(v.Text,{fontSize:t,color:"gray-500",children:i.titleDescription})})]})}),e.jsx(vt.Toggle,{checked:i.checked,onChange:i.onChange,label:i.label,description:i.description}),i.errorMessage&&e.jsx(lt,{message:i.errorMessage})]})},El=({variant:t="primary",size:r="md",...n})=>{const s=pt.useColor(),o=l=>{var a,u,f,g,m,p;if(!l)return;const c=n.disabled?"var(--sa-text-disable, #181a198f)":t==="secondary"?"var(--sa-text-subtle, #8c8f97)":t==="secondary-danger"?(u=(a=s==null?void 0:s.computed)==null?void 0:a.red)==null?void 0:u[600]:t==="secondary-primary"?(g=(f=s==null?void 0:s.computed)==null?void 0:f.blue)==null?void 0:g[700]:(p=(m=s==null?void 0:s.computed)==null?void 0:m.gray)==null?void 0:p[50];return e.jsx(E.Icon,{name:l,size:r,style:{color:c}})},i=()=>{var c,a,u,f;if(t!=="secondary-danger"&&t!=="secondary-primary")return n.title;const l={color:n.disabled?"var(--sa-text-disable, #181a198f)":t==="secondary-danger"?(a=(c=s==null?void 0:s.computed)==null?void 0:c.red)==null?void 0:a[600]:(f=(u=s==null?void 0:s.computed)==null?void 0:u.blue)==null?void 0:f[700]};switch(r){case"xs":return e.jsx(Xe.Body2,{props:{style:l},children:n.title});case"sm":case"md":return e.jsx(Xe.SubH3,{props:{style:l},children:n.title});case"lg":return e.jsx(Xe.SubH2,{props:{style:l},children:n.title});default:return n.title}};return e.jsx(H.Button,{fullWidth:!0,disabled:n.disabled,primary:t==="primary",secondary:t==="secondary"||t==="secondary-danger"||t==="secondary-primary",success:t==="success",onClick:n.onClick,type:n.type,iconLeft:o(n.iconLeft),iconRight:o(n.iconRight),size:r,children:i()})},Fl=t=>e.jsx(Xe.H5,{props:{...t},children:t.title}),Ml=({size:t="md",direction:r="vertical",requiredTitle:n="(Required)",fullWidth:s=!1,...o})=>{var c,a,u;const i=o.hideMessageError||!1,l=r==="horizontal"?t==="sm"?342:t==="lg"?400:342:void 0;return e.jsxs(x.Box,{gap:r==="horizontal"?"spacing-96":"sm",direction:r==="horizontal"?"row":"column",onClick:o.onClickContainer,children:[o.title&&e.jsx(ue,{condition:!!o.inputProps.required,fallback:e.jsxs(x.Box,{direction:"column",customMaxWidth:l,fullWidth:s,children:[e.jsx(fe,{children:o.title}),e.jsx(v.Text,{fontSize:t,color:"gray-500",children:o.description})]}),children:e.jsxs(x.Box,{direction:"column",customMaxWidth:l,fullWidth:s,children:[e.jsxs(ce.Flex,{direction:"row",gap:"xs",align:"center",children:[e.jsx(fe,{fontSize:t,children:o.title}),e.jsx(fe,{color:"error",fontSize:t,children:n}),e.jsx(ue,{condition:!!((c=o.tooltip)!=null&&c.label),children:e.jsx(Fe.Tooltip,{label:(a=o.tooltip)==null?void 0:a.label,arrowPosition:(u=o.tooltip)==null?void 0:u.arrowPosition,...o.tooltip,children:e.jsx(E.Icon,{name:"InfoCircle",size:t==="lg"?"sm":"xs",style:{color:"var(--sa-color-info-500, #00abeb)",marginTop:"6px"}})})})]}),e.jsx(ue,{condition:!!o.description,children:e.jsx(v.Text,{fontSize:t,color:"gray-500",children:o.description})})]})}),e.jsxs(ce.Flex,{direction:"column",gap:"xs",children:[e.jsx(x.Box,{direction:"column",style:{width:r==="horizontal"&&o.customWidth?o.customWidth:r==="horizontal"?"343px":""},children:e.jsx(ht.StarasiaDate,{size:t,...o.inputProps,status:o.errorMessage?"error":void 0})}),!i&&o.errorMessage&&e.jsx(lt,{message:o.errorMessage})]})]})};async function Il(t,r){const n=new Image;n.src=t,await new Promise((i,l)=>{n.onload=i,n.onerror=l});const s=document.createElement("canvas");s.width=r.width,s.height=r.height;const o=s.getContext("2d",{alpha:!0});if(!o)throw new Error("No 2D context");return o.drawImage(n,r.x,r.y,r.width,r.height,0,0,r.width,r.height),new Promise((i,l)=>{s.toBlob(c=>{if(!c)return l("Canvas is empty");const a=new File([c],"cropped.png",{type:"image/png"});i(a)},"image/png")})}const Vn={"1:1":1,"4:3":4/3,"16:9":16/9,"3:4":3/4,"9:16":9/16,"2:3":2/3,"3:2":3/2,"32:9":32/9},To=d.forwardRef(({handleUpload:t,urlImage:r,isUploading:n,croppedImage:s,setCroppedImage:o,size:i="96",aspect:l="1:1",containerProps:c,maxFileSize:a=2,onError:u},f)=>{const g=Ce.useMediaQuery("md"),[m,p]=d.useState(!1),[S,b]=d.useState(null),[I,B]=d.useState(!1),[F,w]=d.useState({x:0,y:0}),[D,A]=d.useState(1),[O,C]=d.useState(null);d.useEffect(()=>{r===null&&o(null)},[r]);const R=d.useCallback((z,P)=>{C(P)},[]),L=z=>{var ye;const P=(ye=z.target.files)==null?void 0:ye[0];if(!P)return;const se=new FileReader;se.onload=()=>{b(se.result),B(!0)},se.readAsDataURL(P)},U=async()=>{if(!(!S||!O))try{const z=await Il(S,O);if(a&&z.size>a*1024*1024){u==null||u(`Ukuran file maksimal ${a}MB`);return}t==null||t(z);const P=URL.createObjectURL(z);o(P,z),B(!1)}catch{u==null||u("Gagal memproses gambar")}},J=d.useRef(null),N=()=>{J.current&&J.current.click()};d.useImperativeHandle(f,()=>({openFileDialog:()=>{var z;(z=J.current)==null||z.click()}}));const _=parseInt(i,10),X=Vn[l];let te,V;return X>=1?(V=_,te=_*X):(te=_,V=_/X),e.jsxs(x.Box,{direction:"column",display:"flex",position:"relative",bg:(c==null?void 0:c.bg)||"gray-200",borderStyle:(c==null?void 0:c.borderStyle)||"border-none",borderColor:(c==null?void 0:c.borderColor)||"gray-200",borderWidth:(c==null?void 0:c.borderWidth)||"border-2",borderRadius:(c==null?void 0:c.borderRadius)||"rounded-md",overflow:"overflow-hidden",align:"center",justify:"center",style:{width:c!=null&&c.fullWidth?"100%":`${te}px`,height:c!=null&&c.fullWidth?"auto":`${V}px`,aspectRatio:X,flexShrink:0},onMouseEnter:()=>p(!0),onMouseLeave:()=>p(!1),children:[s||r?e.jsx("img",{src:s||r||void 0,alt:"Profile",style:{objectFit:"cover",width:"100%",height:"100%"}}):e.jsx(x.Box,{display:"flex",direction:"column",align:"center",justify:"center",padding:"spacing-4",children:e.jsx(E.Icon,{name:"Image",style:{color:"var(--sa-text-subtle, #8c8f97)",width:Number(i)/2<40?Number(i)/2:40,height:Number(i)/2<40?Number(i)/2:40}})}),e.jsxs(x.Box,{direction:"column",position:"absolute",display:"flex",align:"center",justify:"center",cursor:"pointer",style:{inset:0,backgroundColor:"var(--sa-color-black-alpha-a30, #080f214a)",opacity:m?1:0,transition:"opacity 0.3s ease-in-out"},onClick:N,children:[e.jsx("input",{ref:J,type:"file",accept:"image/*",onChange:L,disabled:n,style:{display:"none"}}),e.jsxs(x.Box,{display:"flex",align:"center",gap:"spacing-2",direction:"row",children:[e.jsx(E.Icon,{name:"Edit3",style:{color:"var(--sa-background-primary, #ffffff)"}}),e.jsx(ue,{condition:i.toNumber()>80,children:e.jsx(v.Text,{color:"gray-50",fontSize:i.toNumber()>80?"sm":"md",fontWeight:"medium",children:"Edit Image"})})]})]}),n&&e.jsx(x.Box,{direction:"column",position:"absolute",display:"flex",align:"center",justify:"center",style:{inset:0,zIndex:20,backgroundColor:"var(--sa-color-white-alpha-a80, #e5e9f640)"},children:e.jsx(x.Box,{direction:"column",borderRadius:"rounded-full",style:{animation:"spin 1s linear infinite",border:"2px solid transparent",height:"2rem",width:"2rem"},borderColor:"info-600"})}),I&&Yt.createPortal(e.jsx("div",{style:{position:"fixed",inset:0,zIndex:19999,display:"flex",alignItems:"center",justifyContent:"center",backgroundColor:"rgba(0,0,0,0.6)"},onClick:()=>B(!1),children:e.jsxs("div",{style:{backgroundColor:"var(--sa-background-primary)",borderRadius:"var(--sa-radii-md)",boxShadow:"0 20px 60px rgba(0,0,0,0.3)",overflow:"hidden",width:g?l==="1:1"?"min(90vw, 480px)":`min(90vw, ${te*2}px)`:"calc(100vw - 2rem)",display:"flex",flexDirection:"column"},onClick:z=>z.stopPropagation(),children:[e.jsx("div",{style:{position:"relative",width:"100%",height:"20rem",backgroundColor:"var(--sa-color-gray-100)"},children:S&&e.jsx(is,{image:S,crop:F,zoom:D,aspect:l?Vn[l]:void 0,onCropChange:w,onZoomChange:A,onCropComplete:R,objectFit:"contain",minZoom:.5,restrictPosition:!1})}),e.jsxs("div",{style:{display:"flex",justifyContent:"flex-end",gap:"0.5rem",padding:"0.75rem 1rem",borderTop:"1px solid var(--sa-border-subtle)"},children:[e.jsx(H.Button,{size:"sm",secondary:!0,onClick:()=>B(!1),children:"Cancel"}),e.jsx(H.Button,{size:"sm",primary:!0,onClick:U,children:"Crop"})]})]})}),document.body)]})}),Ll=({size:t="md",direction:r="vertical",requiredTitle:n="(Required)",fullWidth:s=!1,required:o=!1,...i})=>{var a,u,f;const l=i.hideMessageError||!1,c=r==="horizontal"?t==="sm"?342:t==="lg"?400:342:void 0;return e.jsxs(x.Box,{gap:r==="horizontal"?"spacing-96":"sm",direction:r==="horizontal"?"row":"column",...i.containerProps,children:[i.title&&e.jsx(ue,{condition:!!o,fallback:e.jsxs(x.Box,{direction:"column",customMaxWidth:c,fullWidth:s,children:[e.jsx(fe,{children:i.title}),e.jsx(v.Text,{fontSize:t,color:"gray-500",children:i.description})]}),children:e.jsxs(x.Box,{direction:"column",customMaxWidth:c,fullWidth:s,children:[e.jsxs(ce.Flex,{direction:"row",gap:"xs",align:"center",children:[e.jsx(fe,{fontSize:t,children:i.title}),e.jsx(fe,{color:"error",fontSize:t,children:n}),e.jsx(ue,{condition:!!((a=i.tooltip)!=null&&a.label),children:e.jsx(Fe.Tooltip,{label:(u=i.tooltip)==null?void 0:u.label,arrowPosition:(f=i.tooltip)==null?void 0:f.arrowPosition,...i.tooltip,children:e.jsx(E.Icon,{name:"InfoCircle",size:t==="lg"?"sm":"xs",style:{color:"var(--sa-color-info-500, #00abeb)",marginTop:"6px"}})})})]}),e.jsx(ue,{condition:!!i.description,children:e.jsx(v.Text,{fontSize:t,color:"gray-500",children:i.description})})]})}),e.jsxs(ce.Flex,{direction:"column",gap:"xs",children:[e.jsx(To,{...i.inputProps}),!l&&i.errorMessage&&e.jsx(lt,{message:i.errorMessage})]})]})},Tl=({size:t="md",direction:r="vertical",requiredTitle:n="(Required)",fullWidth:s=!1,...o})=>{var l,c,a;const i=r==="horizontal"?t==="sm"?342:t==="lg"?400:342:void 0;return e.jsxs(x.Box,{gap:r==="horizontal"?"spacing-96":"sm",direction:r==="horizontal"?"row":"column",...o.containerProps,children:[o.title&&e.jsx(ue,{condition:!!o.inputProps.required,fallback:e.jsxs(x.Box,{direction:"column",customMaxWidth:i,fullWidth:s,children:[e.jsx(fe,{children:o.title}),e.jsx(v.Text,{fontSize:t,color:"gray-500",children:o.description})]}),children:e.jsxs(x.Box,{direction:"column",customMaxWidth:i,fullWidth:s,children:[e.jsxs(ce.Flex,{direction:"row",gap:"xs",align:"center",children:[e.jsx(fe,{fontSize:t,children:o.title}),e.jsx(fe,{color:"error",fontSize:t,children:n}),e.jsx(ue,{condition:!!((l=o.tooltip)!=null&&l.label),children:e.jsx(Fe.Tooltip,{label:(c=o.tooltip)==null?void 0:c.label,arrowPosition:(a=o.tooltip)==null?void 0:a.arrowPosition,...o.tooltip,children:e.jsx(E.Icon,{name:"InfoCircle",size:t==="lg"?"sm":"xs",style:{color:"var(--sa-color-info-500, #00abeb)",marginTop:"6px"}})})})]}),e.jsx(ue,{condition:!!o.description,children:e.jsx(v.Text,{fontSize:t,color:"gray-500",children:o.description})})]})}),o.inputProps.extended&&o.inputProps.extended]})},Ol=({items:t,id:r,handleOnUpdate:n,width:s,toggleShow:o=!0,disabled:i=!1})=>{var f;const[l,c]=d.useState([]);d.useEffect(()=>{t&&c([...t.map(g=>({id:g.id,isActive:g.isActive}))])},[t]);const a=(f=l.find(g=>g.id===r))==null?void 0:f.isActive,u=d.useCallback(()=>{c(g=>g.map(m=>m.id===r?{...m,isActive:!m.isActive}:m)),n&&n(!a)},[r,n,a]);return e.jsx(x.Box,{direction:"row",gap:"md",style:{width:s},children:o&&e.jsx(vt.Toggle,{disabled:i,checked:a,onChange:u,label:a?"Active":"Inactive"})})},Rl={InputText:Ui,InputDropdown:Ji,InputSingleFile:wl,CheckBoxOptions:Dl,RadioOptions:Sl,InputTextArea:kl,ToggleForm:Bl,ActionButton:El,FormTitle:Fl,InputDate:Ml,InputImgFile:Ll,Custom:Tl},Oo=({customBottom:t})=>{const[r,n]=d.useState(!1),s=()=>{window.scrollY>window.screenY?n(!0):n(!1)},o=()=>{window.scrollTo({top:0,behavior:"smooth"})};return d.useEffect(()=>(window.addEventListener("scroll",s),()=>{window.removeEventListener("scroll",s)}),[]),e.jsx(x.Box,{direction:"column",style:{position:"fixed",bottom:0,right:0},children:e.jsx(x.Box,{direction:"column",position:"absolute",style:{bottom:t||"1.6rem",right:"2rem",transform:r?"scale(1)":"scale(0)",transition:"transform 0.2s ease-in-out"},children:e.jsx(H.Button,{secondary:!0,size:"xs",onClick:o,type:"button",iconLeft:e.jsx(E.Icon,{width:16,size:"xs",name:"ArrowPullUp",style:{color:"var(--sa-background-brand, #04254f)"}})})})})},Ge="sa-sidepanel-item",Nn="sa-sidepanel-item-styles",Al="inset 3.5px 0 0 0 var(--sa-border-focused, #1a4fa0)",Wl="inset -3.5px 0 0 0 var(--sa-border-focused, #1a4fa0)",zl=`
57
+ `,document.head.appendChild(t)},Et=t=>t==="right"?"right":t==="center"?"center":"left",_i=/^(#|rgb|hsl|var\()/,Vt=t=>t?_i.test(t)?t:`var(--sa-background-${t})`:void 0,qi=(t,r)=>{if(r)return t[r]},Zi=(t,r)=>t==null&&r==null?0:t==null?-1:r==null?1:typeof t=="number"&&typeof r=="number"?t-r:String(t).localeCompare(String(r)),Gi=({columns:t,data:r,getRowKey:n,rowBg:s,size:o="md",resizable:i=!1,layout:l="auto",widthStorageKey:c,columnState:a,onColumnStateChange:u,columnMenu:f=!1,sort:g,defaultSort:m,onSortChange:p,height:S,mobileLayout:b="cards",mobileBreakpoint:I="md",groupSeparator:B,summary:F,footer:w,stickyFooter:D=!1,emptyState:A,loading:O=!1,loadingRows:C=8,rowActions:R,selectable:L=!1,selectedKeys:U,defaultSelectedKeys:J,onSelectionChange:N,isRowSelectable:_})=>{Ni();const te=!Ce.useMediaQuery(I)&&b!=="scroll",V=!!(R!=null&&R.length),[z,P]=d.useState(null);d.useEffect(()=>{if(!z)return;const y=()=>P(null),j=setTimeout(()=>document.addEventListener("click",y),0);return()=>{clearTimeout(j),document.removeEventListener("click",y)}},[z]);const[se,ye]=d.useState(()=>new Set),Se=a!==void 0,[xe,pe]=d.useState({}),je=a??xe,be=y=>{u==null||u(y),Se||pe(y)},Te=g!==void 0,[ke,He]=d.useState(m??null),Y=Te?g??null:ke,he=!p,Oe=y=>{p==null||p(y),Te||He(y)},{headerGroups:Ne,leafColumns:ae,hasGroups:_e}=d.useMemo(()=>{var le;const y=new Set(je.hidden??[]),j=(ne,me)=>ne.key??(typeof ne.accessor=="string"?ne.accessor:`col-${me}`),M=t.map((ne,me)=>{var Je;if((Je=ne.children)!=null&&Je.length){const Dt=ne.children.map((Ke,St)=>({col:Ke,key:j(Ke,`${me}-${St}`)})).filter(Ke=>!y.has(Ke.key));return{col:ne,key:ne.key??`group-${me}`,isGroup:!0,leaves:Dt}}const ge={col:ne,key:j(ne,`${me}`)};return{col:ne,key:ge.key,isGroup:!1,leaves:y.has(ge.key)?[]:[ge]}}).filter(ne=>ne.leaves.length>0),Z=M.some(ne=>ne.isGroup);let re=M.flatMap(ne=>ne.leaves);if(!Z&&((le=je.order)!=null&&le.length)){const ne=new Map(je.order.map((me,ge)=>[me,ge]));re=[...re].sort((me,ge)=>(ne.get(me.key)??1/0)-(ne.get(ge.key)??1/0))}return{headerGroups:M,leafColumns:re,hasGroups:Z}},[t,je]),tt=d.useMemo(()=>new Map(ae.map((y,j)=>[y.key,j])),[ae]),W=!_e&&ae.some(y=>(y.col.headerColSpan??1)>1),$=ae.map(y=>y.key).join("|"),Q=(y,j)=>{const M=y.sortKey??(typeof y.accessor=="string"?y.accessor:void 0);return M?j[M]:void 0},de=y=>y.sortable??(!!y.sortKey||typeof y.accessor=="string"),ie=d.useMemo(()=>{if(!he||!Y)return r;const y=ae.find(M=>M.key===Y.key);if(!y)return r;const j=Y.direction==="asc"?1:-1;return[...r].sort((M,Z)=>Zi(Q(y.col,M),Q(y.col,Z))*j)},[r,he,Y,ae]),Be=!_e&&!W,Re=!!c&&Be,[$e,qe]=G.useColumnWidths(c??""),Me=Re?$e:void 0,Qe=d.useRef(null),[we,Ze]=d.useState();d.useLayoutEffect(()=>{Ze(void 0)},[$]),d.useLayoutEffect(()=>{if(!Be||we||!Qe.current)return;const y=Qe.current.querySelectorAll("th.sa-tl-leaf");Ze(Array.from(y).map(j=>j.offsetWidth))},[we,Be]);const[rt,ut]=d.useState(),[ct,at]=d.useState(0);d.useLayoutEffect(()=>{if(!_e||!Qe.current)return;const y=Qe.current.querySelector(":scope > tr");y&&at(y.offsetHeight)},[_e,$]);const ft=(y,j)=>{if((Me==null?void 0:Me[j])!=null)return Me[j];if(y.width!=null)return y.width;if((we==null?void 0:we[j])!=null)return we[j]},k=(y,j)=>typeof y.width=="number"?y.width:we==null?void 0:we[j],q=je.frozenKey&&!_e&&!W?ae.findIndex(y=>y.key===je.frozenKey):-1,K=y=>y<=q,ve=L?Bt:0,Ie=y=>{const j=rt??we;if(!j)return ve;let M=ve;for(let Z=0;Z<y;Z++)M+=j[Z]??0;return M};d.useLayoutEffect(()=>{const y=Qe.current;if(!y||q<0){ut(void 0);return}let j=0;const M=()=>{j=0;const re=y.querySelectorAll("th.sa-tl-leaf"),le=Array.from(re).map(ne=>ne.getBoundingClientRect().width);ut(ne=>ne&&ne.length===le.length&&ne.every((me,ge)=>Math.abs(me-le[ge])<.5)?ne:le)},Z=new ResizeObserver(()=>{j||(j=requestAnimationFrame(M))});return Z.observe(y),y.querySelectorAll("th.sa-tl-leaf").forEach(re=>Z.observe(re)),M(),()=>{j&&cancelAnimationFrame(j),Z.disconnect()}},[$,q,L,we,Me]);const Ue=d.useRef(null),[Ae,De]=d.useState("100vh");d.useLayoutEffect(()=>{if(S!==void 0)return;const y=()=>{if(Ue.current){const j=Ue.current.getBoundingClientRect().top;De(`calc(100vh - ${j}px - var(--sa-floating-footer-height, 0px) + 12px)`)}};return y(),window.addEventListener("resize",y),()=>window.removeEventListener("resize",y)},[S]);const Ee=(y,j)=>n?n(y,j):j,We=U!==void 0,[wt,Vo]=d.useState(()=>new Set(J??[])),st=d.useMemo(()=>We?new Set(U):wt,[We,U,wt]);d.useEffect(()=>{L&&!n&&process.env.NODE_ENV!=="production"&&console.warn("[@starasia/admin] TableLayout: `selectable` tanpa `getRowKey` — key default (index) membuat seleksi menempel ke POSISI baris, bukan datanya. Beri `getRowKey` yang stabil (mis. r => r.id).")},[L,!n]);const Jr=y=>{if(We||Vo(y),N){const j=ie.filter((M,Z)=>y.has(Ee(M,Z)));N(Array.from(y),j)}},sr=(y,j)=>L&&(_?_(y,j):!0),ir=y=>{const j=new Set(st);j.has(y)?j.delete(y):j.add(y),Jr(j)},mt=d.useMemo(()=>L?ie.map((y,j)=>({row:y,i:j,key:Ee(y,j)})).filter(({row:y,i:j})=>_?_(y,j):!0).map(({key:y})=>y):[],[L,ie,_,n]),Yr=mt.filter(y=>st.has(y)),lr=mt.length>0&&Yr.length===mt.length,Xr=Yr.length>0&&!lr,No=()=>{const y=new Set(st);lr?mt.forEach(j=>y.delete(j)):mt.forEach(j=>y.add(j)),Jr(y)},cr=(y,j,M)=>y.render?y.render(j,M,ie):qi(j,y.accessor),ar=ae.length+(L?1:0)+(V?1:0),$r=["80%","55%","70%","45%","90%","60%"],_o=(y,j)=>$r[(y*7+j*3)%$r.length],qo=(y,j)=>e.jsx(Ye.Skeleton,{height:14,width:_o(y,j),borderRadius:"rounded-sm"}),Zo=Array.from({length:C},(y,j)=>e.jsxs(G.Tr,{children:[L&&e.jsx(G.Td,{style:{width:Bt,padding:0},children:e.jsx("div",{style:{display:"flex",justifyContent:"center"},children:e.jsx(Ye.Skeleton,{height:14,width:14,borderRadius:"rounded-sm"})})}),ae.map(({col:M,key:Z},re)=>e.jsx(G.Td,{style:{textAlign:Et(M.align)},children:qo(j,re)},`sa-tl-sk-${j}-${Z}`)),V&&e.jsx(G.Td,{style:{width:1,padding:0,border:"none"}})]},`sa-tl-sk-${j}`)),Go=(y,j)=>{j||be({...je,hidden:[...je.hidden??[],y]})},Qo=y=>be({...je,frozenKey:je.frozenKey===y?void 0:y}),Ot=y=>(R??[]).filter(j=>{var M;return!((M=j.hidden)!=null&&M.call(j,y))}),Kr={position:"absolute",right:0,top:0,bottom:0,display:"flex",alignItems:"center",gap:4,paddingRight:16,paddingLeft:40,background:"linear-gradient(to right, transparent, var(--sa-background-primary-inverse, #f8f8f8) 40px)"},Rt=(y,j,M,Z)=>{var Je;const re=(Je=y.disabled)==null?void 0:Je.call(y,j),le=(Z==null?void 0:Z.showLabel)??y.showLabel,ne=(Z==null?void 0:Z.size)??"xs",me=e.jsx(H.Button,{size:ne,variant:y.variant??"tertiary",tone:y.tone??"neutral",disabled:re,onClick:()=>y.onClick(j,M),iconLeft:y.icon?e.jsx(E.Icon,{name:y.icon,size:"sm"}):void 0,children:le&&y.label}),ge=y.tooltip;return ge?e.jsx(Fe.Tooltip,{label:ge,position:"top-end",children:me}):me},Uo=(y,j)=>{const M=Ot(y);if(!M.length)return null;if(M.length>5){const re=Ee(y,j),le=(z==null?void 0:z.rowKey)===re;return e.jsx("div",{className:"sa-tl-row-actions",style:Kr,onClick:ne=>ne.stopPropagation(),children:e.jsx(Fe.Tooltip,{label:"Aksi lainnya",position:"top",children:e.jsx(H.Button,{size:"xs",variant:"tertiary",onClick:ne=>{const me=ne.currentTarget.getBoundingClientRect();P(le?null:{rowKey:re,top:me.bottom+4,right:window.innerWidth-me.right})},children:e.jsx(E.Icon,{name:"MenuVertical",size:"sm"})})})})}return e.jsx("div",{className:"sa-tl-row-actions",style:Kr,children:M.map(re=>e.jsx(d.Fragment,{children:Rt(re,y,j)},re.key))})},Jo=(y,j)=>{const M=Ot(y);return M.length?e.jsx("div",{style:{display:"flex",gap:6,flexWrap:"wrap",paddingTop:8,marginTop:8,borderTop:kt},children:M.map(Z=>e.jsx(d.Fragment,{children:Rt(Z,y,j,{showLabel:!0,size:"sm"})},Z.key))}):null},Yo=(y,j)=>{const M=Ot(y);return M.length?e.jsx("div",{style:{display:"flex",gap:4,paddingRight:8,flexShrink:0},children:M.map(Z=>e.jsx(d.Fragment,{children:Rt(Z,y,j,{showLabel:!1})},Z.key))}):null},dr=(y,j)=>{const{col:M,key:Z}=y,re=tt.get(Z)??0,le=K(re),ne=le&&re===q,me=(Y==null?void 0:Y.key)===Z?Y.direction:null,ge=f&&!M.disableMenu?e.jsx(Mo,{active:!!me||le,canSort:de(M),canHide:!M.locked,sortDir:me,frozen:le,onSort:St=>Oe({key:Z,direction:St}),onClearSort:()=>Oe(null),onToggleFreeze:()=>Qo(Z),onHide:()=>Go(Z,M.locked)}):null,Je=M.align==="right",Dt=M.align==="right"?"flex-end":M.align==="center"?"center":"flex-start",Ke=e.jsxs("span",{style:{flex:1,minWidth:0,display:"flex",alignItems:"center",gap:6,justifyContent:Dt,overflow:"hidden"},children:[M.icon&&e.jsx(E.Icon,{name:M.icon,size:"sm",style:{flexShrink:0}}),e.jsx("span",{style:Pt,children:M.title})]});return e.jsx(G.Th,{className:`sa-tl-leaf${le?" sa-tl-frozen":""}`,rowSpan:j==null?void 0:j.rowSpan,colSpan:j==null?void 0:j.colSpan,minWidth:M.minWidth,resizable:Be?M.resizable:!1,defaultWidth:k(M,re),style:{textAlign:Et(M.align),width:ft(M,re),position:"sticky",top:(j==null?void 0:j.top)??0,left:le?Ie(re):void 0,zIndex:le?3:2,backgroundColor:gt,boxShadow:ne?Hn:void 0},children:e.jsx("div",{style:{display:"flex",alignItems:"center",gap:6,width:"100%"},children:Je?e.jsxs(e.Fragment,{children:[ge,Ke]}):e.jsxs(e.Fragment,{children:[Ke,ge]})})},`th-${Z}`)},Xo=()=>{const y=[];for(let j=0;j<ae.length;){const M=ae[j],Z=M.col.headerColSpan??1,re=Math.max(1,Math.min(Z,ae.length-j));y.push(dr(M,re>1?{colSpan:re}:void 0)),j+=re}return y},en=y=>e.jsx(G.Th,{rowSpan:y==null?void 0:y.rowSpan,style:{width:Bt,position:"sticky",top:0,left:0,zIndex:4,backgroundColor:gt,padding:0},children:e.jsx("div",{style:{display:"flex",alignItems:"center",justifyContent:"center"},onClick:j=>j.stopPropagation(),children:e.jsx(nt.Checkbox,{size:"sm",variant:Xr?"indeterminate":"select",checked:lr||Xr,disabled:mt.length===0,onChange:No,"aria-label":"Pilih semua baris di halaman ini"})})},"th-select"),$o=(y,j,M)=>{const Z=Ee(y,j);return e.jsx(G.Td,{className:"sa-tl-frozen",style:{width:Bt,padding:0,position:"sticky",left:0,zIndex:2,...M?{"--sa-tl-bg":M}:{}},children:sr(y,j)&&e.jsx("div",{style:{display:"flex",alignItems:"center",justifyContent:"center"},onClick:re=>re.stopPropagation(),children:e.jsx(nt.Checkbox,{size:"sm",checked:st.has(Z),onChange:()=>ir(Z),"aria-label":"Pilih baris"})})},`tl-select-${j}`)},ur=ae.filter(y=>!y.col.hideOnMobile),xr=ur.find(y=>y.col.primary)??ur[0],Ko=ur.filter(y=>y!==xr),es=y=>ye(j=>{const M=new Set(j);return M.has(y)?M.delete(y):M.add(y),M}),tn=(y,j)=>Ko.map(({col:M,key:Z})=>{const re=cr(M,y,j),le=typeof re=="string"||typeof re=="number"?e.jsx(v.Text,{style:{minWidth:0,overflow:"hidden",textOverflow:"ellipsis",textAlign:"right"},children:re}):e.jsx("div",{style:{minWidth:0,overflow:"hidden",textOverflow:"ellipsis",textAlign:"right"},children:re});return e.jsxs("div",{style:{display:"flex",gap:12,justifyContent:"space-between",alignItems:"baseline"},children:[typeof M.title=="string"?e.jsx(v.Text,{color:"subtle",fontWeight:"medium",style:{color:Vi,flexShrink:0},children:M.title}):e.jsx("div",{style:{flexShrink:0},children:M.title}),le]},Z)}),hr=(y,j)=>{const M=xr?cr(xr.col,y,j):null;return typeof M=="string"||typeof M=="number"?e.jsx(v.Text,{as:"span",style:Pt,children:M}):e.jsx("span",{style:Pt,children:M})},ts=e.jsx(x.Box,{style:{display:"flex",flexDirection:"column",gap:8,padding:8},children:Array.from({length:C},(y,j)=>e.jsxs(x.Box,{style:{border:kt,borderRadius:"var(--sa-radii-sm, 6px)",padding:12,display:"flex",flexDirection:"column",gap:8},children:[e.jsx(Ye.Skeleton,{height:16,width:"60%",borderRadius:"rounded-sm"}),e.jsx(Ye.Skeleton,{height:12,width:"85%",borderRadius:"rounded-sm"}),e.jsx(Ye.Skeleton,{height:12,width:"70%",borderRadius:"rounded-sm"})]},`sa-tl-sk-card-${j}`))}),rn=e.jsx(x.Box,{fullWidth:!0,style:{minHeight:(A==null?void 0:A.minHeight)??320,display:"flex",alignItems:"center",justifyContent:"center",padding:16},children:A==null?void 0:A.content}),rs=O?ts:ie.length===0?rn:b==="expand"?e.jsx(x.Box,{style:{display:"flex",flexDirection:"column"},children:ie.map((y,j)=>{const M=Ee(y,j),Z=se.has(M),le=L&&st.has(M)?Dr:Vt(s==null?void 0:s(y,j));return e.jsxs("div",{style:{borderBottom:kt,backgroundColor:le},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center"},children:[sr(y,j)&&e.jsx("div",{style:{display:"flex",alignItems:"center",paddingLeft:12,flexShrink:0},children:e.jsx(nt.Checkbox,{size:"sm",checked:st.has(M),onChange:()=>ir(M),"aria-label":"Pilih baris"})}),e.jsxs("button",{type:"button",onClick:()=>es(M),style:{flex:1,minWidth:0,display:"flex",alignItems:"center",justifyContent:"space-between",gap:12,padding:"10px 12px",background:"none",border:"none",font:"inherit",color:"inherit",cursor:"pointer",textAlign:"left"},children:[hr(y,j),e.jsx(E.Icon,{name:Z?"ChevronUp":"ChevronDown",size:"sm",style:{flexShrink:0}})]}),V&&Yo(y,j)]}),Z&&e.jsx("div",{style:{padding:"0 12px 12px",display:"flex",flexDirection:"column",gap:6},children:tn(y,j)})]},M)})}):e.jsx(x.Box,{style:{display:"flex",flexDirection:"column",gap:8,padding:8},children:ie.map((y,j)=>{const M=Ee(y,j),Z=L&&st.has(M);return e.jsxs(x.Box,{style:{border:kt,borderRadius:"var(--sa-radii-sm, 6px)",padding:12,display:"flex",flexDirection:"column",gap:6,backgroundColor:Z?Dr:Vt(s==null?void 0:s(y,j))},children:[sr(y,j)?e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[e.jsx(nt.Checkbox,{size:"sm",checked:st.has(M),onChange:()=>ir(M),"aria-label":"Pilih baris"}),e.jsx("div",{style:{flex:1,minWidth:0},children:hr(y,j)})]}):hr(y,j),tn(y,j),V&&Jo(y,j)]},M)})}),ns=i&&Be&&we!==void 0,nn=l==="fixed"&&!i&&(Be?we!==void 0:!0),os=nn&&!Be,At=w&&w.length>0?w.map((y,j)=>e.jsx(G.Tr,{children:y.cells.map((M,Z)=>e.jsx(G.Td,{colSpan:M.colSpan,rowSpan:M.rowSpan,style:{textAlign:Et(M.align)},children:M.content},`tl-foot-${j}-${Z}`))},`tl-foot-${j}`)):null,ss=e.jsxs(G.Table,{className:"sa-table-layout",fullWidth:!0,size:o,resizable:ns,style:nn?{tableLayout:"fixed"}:void 0,onWidthsChange:Re?qe:void 0,children:[os&&e.jsxs("colgroup",{children:[L&&e.jsx("col",{style:{width:Bt}}),ae.map(({col:y,key:j},M)=>e.jsx("col",{style:{width:ft(y,M)}},`col-${j}`)),V&&e.jsx("col",{style:{width:1}})]}),e.jsx(G.Thead,{ref:Qe,children:_e?e.jsxs(e.Fragment,{children:[e.jsxs(G.Tr,{children:[L&&en({rowSpan:2}),Ne.map(y=>y.isGroup?e.jsx(G.Th,{colSpan:y.leaves.length,style:{textAlign:"center",position:"sticky",top:0,zIndex:2,backgroundColor:gt},children:e.jsx("span",{style:Pt,children:y.col.title})},`grp-${y.key}`):dr(y.leaves[0],{rowSpan:2})),V&&e.jsx(G.Th,{rowSpan:2,style:{position:"sticky",top:0,right:0,zIndex:3,width:1,padding:0,border:"none",backgroundColor:gt}})]}),e.jsx(G.Tr,{children:Ne.flatMap(y=>y.isGroup?y.leaves.map(j=>dr(j,{top:ct})):[])})]}):e.jsxs(G.Tr,{children:[L&&en(),Xo(),V&&e.jsx(G.Th,{style:{position:"sticky",top:0,right:0,zIndex:3,width:1,padding:0,border:"none",backgroundColor:gt}})]})}),e.jsx(G.Tbody,{children:O?Zo:ie.length===0?e.jsx(G.Tr,{children:e.jsx(G.Td,{colSpan:ar,children:rn})}):e.jsxs(e.Fragment,{children:[ie.map((y,j)=>{const M=B==null?void 0:B(y,j,j>0?ie[j-1]:void 0),re=L&&st.has(Ee(y,j))?Dr:Vt(s==null?void 0:s(y,j));return e.jsxs(d.Fragment,{children:[M!=null&&M!==!1&&e.jsx(G.Tr,{children:e.jsx(G.Td,{colSpan:ar,style:{backgroundColor:gt},children:M})}),e.jsxs(G.Tr,{children:[L&&$o(y,j,re),ae.map(({col:le,key:ne},me)=>{var sn;const ge=(sn=le.cellProps)==null?void 0:sn.call(le,y,j,ie);if(ge!=null&&ge.hidden)return null;const Je=K(me),Dt=Je&&me===q,Ke=cr(le,y,j),St=typeof le.bg=="function"?le.bg(y,j,ie):le.bg,on=Vt(St)??re;return e.jsx(G.Td,{className:Je?"sa-tl-frozen":void 0,colSpan:ge==null?void 0:ge.colSpan,rowSpan:ge==null?void 0:ge.rowSpan,style:{textAlign:Et(le.align),width:ft(le,me),minWidth:le.minWidth,position:Je?"sticky":void 0,left:Je?Ie(me):void 0,zIndex:Je?1:void 0,boxShadow:Dt?Hn:void 0,...on?{"--sa-tl-bg":on}:{}},children:typeof Ke=="string"?e.jsx(v.Text,{style:{whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",textAlign:Et(le.align)},children:Ke}):Ke},`tl-cell-${j}-${ne}`)}),V&&e.jsx(G.Td,{style:{position:"sticky",right:0,width:1,padding:0,overflow:"visible",zIndex:2,border:"none"},children:Uo(y,j)})]})]},Ee(y,j))}),F!=null&&e.jsx(G.Tr,{children:e.jsx(G.Td,{colSpan:ar,children:F})})]})}),At&&e.jsx(G.Tfoot,{className:D?"sa-tl-sticky-foot":void 0,children:At})]}),fr=z?ie.findIndex((y,j)=>Ee(y,j)===z.rowKey):-1,mr=fr>=0?ie[fr]:null;return e.jsxs(e.Fragment,{children:[e.jsx(x.Box,{ref:Ue,fullWidth:!0,style:{overflow:"auto",height:S??Ae},children:te?e.jsxs(e.Fragment,{children:[rs,At&&!O&&ie.length>0&&e.jsx(x.Box,{style:{borderTop:kt},children:e.jsx(G.Table,{fullWidth:!0,size:o,className:"sa-table-layout",children:e.jsx(G.Tbody,{children:At})})})]}):ss}),z&&mr&&e.jsx("div",{className:"sa-tl-kebab-menu",style:{top:z.top,right:z.right},onClick:y=>y.stopPropagation(),children:Ot(mr).map(y=>e.jsx("div",{style:{padding:"2px 4px"},children:Rt(y,mr,fr,{showLabel:!0,size:"sm"})},y.key))})]})},Sr=t=>t==="asc"||t==="desc",Qi=(t={})=>{const{sortKeyParam:r="sortBy",sortOrderParam:n="sortOrder",pageKey:s="page",defaultSort:o=null,paramKeys:i,scopeId:l,storage:c=Ur}=t,{searchParams:a,setSearchParams:u,searchQueries:f}=Ve(),g=a.toString(),m=l?Ct.tableSort(l):void 0,p=d.useRef(!1);d.useEffect(()=>{if(p.current||(p.current=!0,!m)||a.has(r)||a.has(n))return;const w=c.get(m);!(w!=null&&w.key)||!Sr(w.direction)||u({...Object.fromEntries(a.entries()),[r]:w.key,[n]:w.direction},{replace:!0})},[]);const S=d.useMemo(()=>{const w=a.get(r),D=a.get(n);return w&&Sr(D)?{key:w,direction:D}:o},[g,r,n,o]);d.useEffect(()=>{if(!m)return;const w=a.get(r),D=a.get(n);w&&Sr(D)?c.set(m,{key:w,direction:D}):c.remove(m)},[g,m,r,n,c]);const b=(i==null?void 0:i.sortBy)??"sortBy",I=(i==null?void 0:i.sortOrder)??"sortOrder",B=d.useMemo(()=>S?{[b]:S.key,[I]:S.direction}:{},[S,b,I]),F=d.useCallback(w=>{const D={...f};w?(D[r]=w.key,D[n]=w.direction):(delete D[r],delete D[n]),delete D[s],u(D)},[f,r,n,s,u]);return{sort:S,setSort:F,params:B}},Kt=({of:t,render:r})=>d.Children.toArray(t==null?void 0:t.map((n,s,o)=>r(n,s,o))),ue=({condition:t,fallback:r,children:n,loading:s,isLoading:o})=>e.jsx(e.Fragment,{children:o?s:t?n:r}),fe=t=>e.jsx(v.Text,{...t,fontSize:t.fontSize||"md",fontWeight:t.fontWeight||"medium",color:t.color||"gray-700",children:t.children}),lt=t=>e.jsx(v.Text,{color:"red-600",fontSize:"sm",children:t.message}),Ui=({size:t="md",direction:r="vertical",requiredTitle:n="(Required)",fullWidth:s=!1,...o})=>{var c,a,u;const i=o.hideMessageError||!1,l=r==="horizontal"?t==="sm"?342:t==="lg"?400:342:void 0;return e.jsxs(x.Box,{gap:r==="horizontal"?"spacing-96":"sm",direction:r==="horizontal"?"row":"column",...o.containerProps,children:[o.title&&e.jsx(ue,{condition:!!o.inputProps.required,fallback:e.jsxs(x.Box,{direction:"column",customMaxWidth:l,fullWidth:s,children:[e.jsx(fe,{children:o.title}),e.jsx(v.Text,{fontSize:t,color:"gray-500",children:o.description})]}),children:e.jsxs(x.Box,{direction:"column",customMaxWidth:l,fullWidth:s,children:[e.jsxs(ce.Flex,{direction:"row",gap:"xs",align:"center",children:[e.jsx(fe,{fontSize:t,children:o.title}),e.jsx(fe,{color:"error",fontSize:t,children:n}),e.jsx(ue,{condition:!!((c=o.tooltip)!=null&&c.label),children:e.jsx(Fe.Tooltip,{label:(a=o.tooltip)==null?void 0:a.label,arrowPosition:(u=o.tooltip)==null?void 0:u.arrowPosition,...o.tooltip,children:e.jsx(E.Icon,{name:"InfoCircle",size:t==="lg"?"sm":"xs",style:{color:"var(--sa-color-info-500, #00abeb)",marginTop:"6px"}})})})]}),e.jsx(ue,{condition:!!o.description,children:e.jsx(v.Text,{fontSize:t,color:"gray-500",children:o.description})})]})}),e.jsxs(x.Box,{direction:"column",gap:"xs",fullWidth:o.inputProps.fullWidth||!1,children:[e.jsx(dt.Input,{ref:o.inputRef,size:t,...o.inputProps,status:o.errorMessage?"error":"default",fullWidth:!0}),!i&&o.errorMessage&&e.jsx(lt,{message:o.errorMessage}),o.inputProps.extended&&o.inputProps.extended]})]})},Ji=({size:t="md",direction:r="vertical",requiredTitle:n="(Required)",fullWidth:s=!1,...o})=>{var c,a,u;const i=o.hideMessageError||!1,l=r==="horizontal"?t==="sm"?342:t==="lg"?400:342:void 0;return e.jsxs(x.Box,{gap:r==="horizontal"?"spacing-96":"sm",direction:r==="horizontal"?"row":"column",onClick:o.onClickContainer,children:[o.title&&e.jsx(ue,{condition:!!o.inputProps.required,fallback:e.jsxs(x.Box,{direction:"column",customMaxWidth:l,fullWidth:s,children:[e.jsx(fe,{children:o.title}),e.jsx(v.Text,{fontSize:t,color:"gray-500",children:o.description})]}),children:e.jsxs(x.Box,{direction:"column",customMaxWidth:l,fullWidth:s,children:[e.jsxs(ce.Flex,{direction:"row",gap:"xs",align:"center",children:[e.jsx(fe,{fontSize:t,children:o.title}),e.jsx(fe,{color:"error",fontSize:t,children:n}),e.jsx(ue,{condition:!!((c=o.tooltip)!=null&&c.label),children:e.jsx(Fe.Tooltip,{label:(a=o.tooltip)==null?void 0:a.label,arrowPosition:(u=o.tooltip)==null?void 0:u.arrowPosition,...o.tooltip,children:e.jsx(E.Icon,{name:"InfoCircle",size:t==="lg"?"sm":"xs",style:{color:"var(--sa-color-info-500, #00abeb)",marginTop:"6px"}})})})]}),e.jsx(ue,{condition:!!o.description,children:e.jsx(v.Text,{fontSize:t,color:"gray-500",children:o.description})})]})}),e.jsxs(x.Box,{direction:"column",gap:"xs",fullWidth:o.inputProps.fullWidth||!1,children:[e.jsx(x.Box,{direction:"column",style:{width:o.inputProps.fullWidth?"100%":r==="horizontal"&&o.customWidth?o.customWidth:r==="horizontal"?"343px":""},children:e.jsx(jt.Dropdown,{size:t,...o.inputProps,error:!!o.errorMessage})}),!i&&o.errorMessage&&e.jsx(lt,{message:o.errorMessage}),o.inputProps.extended&&o.inputProps.extended]})]})},Yi=(t,r)=>typeof t=="string"&&t||r==="error"?"var(--sa-border-danger)":"var(--sa-border-subtle)",Xi=t=>{var c;const[r,n]=d.useState(!1),s=a=>{a.preventDefault(),a.stopPropagation()},o=a=>{a.preventDefault(),a.stopPropagation(),a.dataTransfer&&t.handleOnFileChange(a.dataTransfer.files.item(0))},i=a=>{a.preventDefault(),n(!0)},l=a=>{a.preventDefault(),n(!1)};return e.jsxs(x.Box,{width:"width-full",paddingInline:"md",direction:"row",gap:"sm",align:"center",onClick:t.handleOnClick,onDragOver:s,onDrop:o,onDragEnter:i,onDragLeave:l,paddingBlock:"md",borderRadius:"rounded-md",style:{border:r?"1px solid var(--sa-border-info)":`1px solid ${Yi(t.errorMessage,t.status)}`},children:[e.jsx(E.Icon,{name:"Upload",size:"lg",style:{width:30,height:30}}),e.jsxs(ce.Flex,{direction:"column",gap:"xs",children:[e.jsxs(ce.Flex,{direction:"row",gap:"xs",children:[e.jsx(v.Text,{fontWeight:"medium",color:"gray-500",style:{textWrap:"nowrap"},fontSize:t.isDesktop?"md":"sm",children:"Click your upload"}),e.jsx(v.Text,{fontWeight:"medium",style:{textWrap:"nowrap"},fontSize:t.isDesktop?"md":"sm",children:"or Drag & Drop"})]}),e.jsx(v.Text,{fontSize:"sm",color:"gray-500",children:(c=t.fileSupports)==null?void 0:c.map(a=>a.toLocaleUpperCase()).join(", ")})]})]})};function $i(t){return t.split(" ").map(r=>r[0]).join("").slice(0,2).toUpperCase()}const Io=t=>{const r={day:"2-digit",month:"short",year:"numeric"};return t.toLocaleDateString("id-ID",r)},Ki=t=>{const r={Jan:0,Feb:1,Mar:2,Apr:3,Mei:4,Jun:5,Jul:6,Agu:7,Sep:8,Okt:9,Nov:10,Des:11},n=t.split(" ");if(n.length!==3)return null;const s=parseInt(n[0],10),o=r[n[1]],i=parseInt(n[2],10);return isNaN(s)||isNaN(o)||isNaN(i)?null:new Date(i,o,s)};function el(t,r=!0){if(!t)return"Rp 0";const n=typeof t=="number"?t.toString():t;if(isNaN(Number(n)))return"Rp 0";const s=n.split("."),o=s[0].replace(/\B(?=(\d{3})+(?!\d))/g,"."),i=s.length===2?o+"."+s[1]:o;return r?"Rp"+i:i}String.prototype.toTitleCase=function(){return this.toLowerCase().split(" ").map(t=>t.charAt(0).toUpperCase()+t.slice(1)).join(" ")};String.prototype.toNumber=function(){return Number(this)};const tl=t=>{const r=t.split(" ");let n=r[0].charAt(0);return r.length>1&&(n+=""+r[1].charAt(0)),n.toUpperCase()};function rl(t){const r=typeof t=="string"?new Date(t):t;if(isNaN(r.getTime()))throw new Error("Invalid date format");const n=r.getFullYear(),s=String(r.getMonth()+1).padStart(2,"0"),o=String(r.getDate()).padStart(2,"0");return`${n}-${s}-${o}`}const nl="sa-admin",et=t=>`var(--${nl}-${t})`,ol={base:{borderColor:et("base-border-color"),textColor:et("base-text-color"),iconColor:et("base-icon-color"),placeholderColor:et("base-placeholder-color")},document:{bgColor:et("document-bg-color")},sidebar:{bgColor:et("sidebar-bg-color"),borderColor:et("sidebar-border-color"),maxWidth:et("sidebar-max-width"),width:et("sidebar-width"),collapseWidth:et("sidebar-collapse-width"),collapseV2Width:et("sidebar-v2-collapse-width")}},sl=24*60*60*1e3,il=t=>{const r="14px poppins",s=document.createElement("canvas").getContext("2d");s.font=r;const o=s.measureText(t).width;return Number(Math.ceil(o))},ll=/^[^\s@]+@[^\s@]+\.[^\s@]+$/,cl=/--+/,al=/-$/;function dl(t,r){return JSON.stringify(t)!==JSON.stringify(r)}function ul(t){return/^(?:\+62|62|0)8[1-9][0-9]{7,10}$/.test(t)}function xl(t){return/^[A-Za-z\s]+$/.test(t)}const hl=t=>{const r=/^[0-9]$/,n=["ArrowLeft","ArrowRight","ArrowUp","ArrowDown","Backspace","Delete","Enter","Tab"];(t.ctrlKey||t.metaKey)&&(t.key==="a"||t.key==="c"||t.key==="v")||!r.test(t.key)&&!n.includes(t.key)&&t.preventDefault()},fl=t=>{const r=/^[0-9]$/,n=["ArrowLeft","ArrowRight","ArrowUp","ArrowDown","Backspace","Delete","Enter","Tab"];(t.ctrlKey||t.metaKey)&&t.key==="v"||r.test(t.key)&&!n.includes(t.key)&&t.preventDefault()},ml=t=>{const r=/^[0-9.]$/,n=["ArrowLeft","ArrowRight","ArrowUp","ArrowDown","Backspace","Delete","Enter","Tab"];(t.ctrlKey||t.metaKey)&&t.key==="v"||!r.test(t.key)&&!n.includes(t.key)&&t.preventDefault()},gl=t=>ll.test(t);function yl(t){return!(cl.test(t)||al.test(t))}const pl=t=>{const r=["ArrowLeft","ArrowRight","ArrowUp","ArrowDown","Backspace","Delete","Enter","Tab","Home","End"];if((t.ctrlKey||t.metaKey)&&["a","c","v","x"].includes(t.key.toLowerCase()))return;const n=t.currentTarget.value;/^[0-9]$/.test(t.key)||t.key==="."&&!n.includes(".")||t.key==="-"&&n.length===0&&!n.includes("-")||r.includes(t.key)||t.preventDefault()},jl=t=>{const r=document.getElementById(t);if(r){const n=r.getBoundingClientRect(),s=window.scrollY+n.top-80;window.scrollTo({top:s,behavior:"smooth"})}};function bl(t){const r=t.toLowerCase();if(["kb","mb","gb"].find(i=>r.endsWith(i)))return t;const o=Number(t);if(isNaN(o))throw new Error("Invalid size format");return o>=1e6?`${(o/1e6).toFixed(2)}MB`:o>=1e3?`${(o/1e3).toFixed(2)}KB`:`${o}B`}function vl(t){const r=t.split("/");return r[r.length-1]}const Cl=t=>{var r,n;return e.jsxs(x.Box,{width:"width-full",paddingInline:"md",height:"height-full",direction:"row",justify:"space-between",align:"center",onClick:t.handleOnClickFile,fullHeight:!0,paddingBlock:"md",id:"file-item",borderRadius:"rounded-md",style:{border:"1px solid var(--sa-border-subtle)",cursor:"pointer"},children:[e.jsxs(ce.Flex,{direction:"row",align:"center",gap:"sm",style:{flex:1,minWidth:0},children:[e.jsx(E.Icon,{name:"DocumentFilled",size:"lg",style:{color:"var(--sa-icon-brand)",width:30,height:30,flexShrink:0}}),e.jsxs(ce.Flex,{direction:"column",style:{minWidth:0,flex:1},children:[e.jsx(v.Text,{fontWeight:"bold",style:{textOverflow:"ellipsis",whiteSpace:"nowrap",overflow:"hidden"},children:t.defaultFile?vl(t.defaultFile.url):(r=t.fileSelected)==null?void 0:r.name}),t.defaultFile?(t.defaultFile.size||t.defaultFile.date)&&e.jsxs(ce.Flex,{direction:"row",gap:"xs",align:"center",children:[t.defaultFile.size&&e.jsx(v.Text,{fontSize:"sm",fontWeight:"medium",children:t.defaultFile.size}),t.defaultFile.size&&t.defaultFile.date&&e.jsx(E.Icon,{name:"Dot",size:"xs"}),t.defaultFile.date&&e.jsx(v.Text,{fontSize:"sm",fontWeight:"medium",style:{textWrap:"nowrap"},children:t.defaultFile.date})]}):e.jsxs(ce.Flex,{direction:"row",gap:"xs",align:"center",children:[e.jsx(v.Text,{fontSize:"sm",fontWeight:"medium",children:bl(((n=t.fileSelected)==null?void 0:n.size.toString())||"100000")}),e.jsx(E.Icon,{name:"Dot",size:"xs"}),e.jsx(v.Text,{fontSize:"sm",fontWeight:"medium",style:{textWrap:"nowrap"},children:Io(new Date)})]})]})]}),e.jsx(H.Button,{size:"xs",variant:"tertiary",tone:"error",type:"button",onClick:s=>{s.stopPropagation(),t.handleOnDeleteFile()},iconLeft:e.jsx(E.Icon,{name:"Trash1"})})]})},Lo=({status:t="default",labelPosition:r="outside-top",...n})=>{var m;const s=d.useRef(null),o=()=>{if(n.defaultFile){window.open(n.defaultFile.url);return}s.current&&s.current.click()},i=Ce.useMediaQuery("md"),l=t==="error"||typeof n.errorMessage=="string"&&!!n.errorMessage,c=n.label?e.jsxs(ce.Flex,{direction:"row",align:"center",gap:"xs",children:[e.jsx(v.Text,{style:{fontSize:"14px",fontWeight:500,color:"var(--sa-text-primary)"},children:n.label}),n.optional&&e.jsx("span",{style:{background:"var(--sa-background-neutral)",border:"1px solid var(--sa-border-subtle)",borderRadius:"4px",padding:"0 8px",fontSize:"10px",fontWeight:500,lineHeight:"18px",color:"var(--sa-text-primary)",display:"inline-flex",alignItems:"center"},children:"Optional"}),n.required&&e.jsx("span",{style:{fontSize:"14px",fontWeight:500,color:"var(--sa-text-error)"},children:"*"})]}):null,a=n.description?e.jsx(v.Text,{style:{fontSize:"12px",fontWeight:400,color:"var(--sa-text-subtlest, #6b6e76)",lineHeight:"18px"},children:n.description}):null,u=e.jsxs(e.Fragment,{children:[n.helperText&&e.jsx(v.Text,{style:{fontSize:"12px",fontWeight:400,color:"var(--sa-text-subtlest, #6b6e76)",lineHeight:"18px"},children:n.helperText}),n.errorText&&t==="error"&&e.jsx(v.Text,{style:{fontSize:"12px",fontWeight:400,color:"var(--sa-text-error, #a4133c)",lineHeight:"18px"},children:n.errorText}),n.errorMessage&&!n.errorText&&e.jsx(v.Text,{style:{fontSize:"12px",fontWeight:400,color:"var(--sa-text-error, #a4133c)",lineHeight:"18px"},children:n.errorMessage})]}),f=e.jsx("input",{type:"file",style:{display:"none"},ref:s,onChange:p=>{var S;return n.handleOnChangeFile(((S=p.target.files)==null?void 0:S.item(0))||null)},accept:(m=n.fileSupportOption)==null?void 0:m.map(p=>"."+(p==null?void 0:p.toLowerCase())).join(", ")}),g=e.jsxs(x.Box,{direction:"column",fullWidth:!0,style:{minHeight:"69px"},borderRadius:"rounded-md",display:"flex",justify:"center",align:"center",cursor:"pointer",gap:"md",...n.containerProps,children:[f,(n.fileSelected||n.defaultFile)&&e.jsx(Cl,{fileSelected:n.fileSelected,defaultFile:n.defaultFile,handleOnDeleteFile:n.handleOnDeleteFile,handleOnClickFile:o}),!n.fileSelected&&!n.defaultFile&&e.jsx(Xi,{fileSupports:n.fileSupportOption,isDesktop:i,errorMessage:l?n.errorText||n.errorMessage||" ":void 0,status:l?"error":"default",handleOnClick:o,handleOnFileChange:n.handleOnChangeFile})]});return r==="outside-left"?e.jsxs(ce.Flex,{direction:"row",align:"flex-start",gap:"sm",style:{width:"100%"},children:[e.jsxs(ce.Flex,{direction:"column",gap:"xs",style:{width:"40%",minWidth:"120px",paddingTop:"10px"},children:[c,a]}),e.jsxs(ce.Flex,{direction:"column",gap:"sm",style:{flex:1,minWidth:0},children:[g,u]})]}):e.jsxs(ce.Flex,{direction:"column",gap:"sm",style:{width:"100%"},children:[c,a,g,u]})},wl=({size:t="md",direction:r="vertical",requiredTitle:n="(Required)",fullWidth:s=!1,...o})=>{var c,a,u;const i=o.hideMessageError||!1,l=r==="horizontal"?t==="sm"?342:t==="lg"?400:342:void 0;return e.jsxs(x.Box,{gap:r==="horizontal"?"spacing-96":"sm",direction:r==="horizontal"?"row":"column",...o.containerProps,children:[o.title&&e.jsx(ue,{condition:!!o.inputProps.required,fallback:e.jsxs(x.Box,{direction:"column",customMaxWidth:l,fullWidth:s,children:[e.jsx(fe,{children:o.title}),e.jsx(v.Text,{fontSize:t,color:"gray-500",children:o.description})]}),children:e.jsxs(x.Box,{direction:"column",customMaxWidth:l,fullWidth:s,children:[e.jsxs(ce.Flex,{direction:"row",gap:"xs",align:"center",children:[e.jsx(fe,{fontSize:t,children:o.title}),e.jsx(fe,{color:"error",fontSize:t,children:n}),e.jsx(ue,{condition:!!((c=o.tooltip)!=null&&c.label),children:e.jsx(Fe.Tooltip,{label:(a=o.tooltip)==null?void 0:a.label,arrowPosition:(u=o.tooltip)==null?void 0:u.arrowPosition,...o.tooltip,children:e.jsx(E.Icon,{name:"InfoCircle",size:t==="lg"?"sm":"xs",style:{color:"var(--sa-color-info-500, #00abeb)",marginTop:"6px"}})})})]}),e.jsx(ue,{condition:!!o.description,children:e.jsx(v.Text,{fontSize:t,color:"gray-500",children:o.description})})]})}),e.jsxs(ce.Flex,{direction:"column",gap:"xs",children:[e.jsx(Lo,{...o.inputProps,status:o.errorMessage?"error":"default"}),!i&&o.errorMessage&&e.jsx(lt,{message:o.errorMessage})]})]})},Dl=({size:t="md",direction:r="vertical",requiredTitle:n="(Required)",fullWidth:s=!1,required:o=!1,...i})=>{var a,u,f,g;const l=i.hideMessageError||!1,c=r==="horizontal"?t==="sm"?342:t==="lg"?400:342:void 0;return e.jsxs(x.Box,{gap:r==="horizontal"||r==="horizontal-inline"?"spacing-96":"sm",direction:r==="horizontal"||r==="horizontal-inline"?"row":"column",...i.containerProps,children:[i.title&&e.jsx(ue,{condition:!!o,fallback:e.jsxs(x.Box,{direction:"column",customMaxWidth:c,fullWidth:s,children:[e.jsx(fe,{children:i.title}),e.jsx(Xe.Body3,{props:{color:"gray-500"},children:i.description})]}),children:e.jsxs(x.Box,{direction:"column",customMaxWidth:c,fullWidth:s,children:[e.jsxs(ce.Flex,{direction:"row",gap:"xs",align:"center",children:[e.jsx(fe,{fontSize:t,children:i.title}),e.jsx(fe,{color:"error",fontSize:t,children:n}),e.jsx(ue,{condition:!!((a=i.tooltip)!=null&&a.label),children:e.jsx(Fe.Tooltip,{label:(u=i.tooltip)==null?void 0:u.label,arrowPosition:(f=i.tooltip)==null?void 0:f.arrowPosition,...i.tooltip,children:e.jsx(E.Icon,{name:"InfoCircle",size:t==="lg"?"sm":"xs",style:{color:"var(--sa-color-info-500, #00abeb)",marginTop:"6px"}})})})]}),e.jsx(ue,{condition:!!i.description,children:e.jsx(v.Text,{fontSize:t,color:"gray-500",children:i.description})})]})}),e.jsx(x.Box,{gap:r==="horizontal-inline"?"xl":"md",direction:r==="horizontal-inline"?"row":"column",align:"flex-start",children:e.jsx(Kt,{of:(g=i.checkBoxesList)==null?void 0:g.map(m=>({...m,isChecked:i.checkBoxesAreChecked.includes(m.id)})),render:m=>m.renderBadge?e.jsxs(x.Box,{direction:"row",justify:"space-between",gap:"lg",...i.badgeContainerProps,children:[e.jsx(nt.Checkbox,{name:m.name,value:m.id,checked:m.isChecked,onChange:p=>i.onChecked(p.target.value,m),label:m.name,description:m.description}),m.renderBadge]}):e.jsx(nt.Checkbox,{name:m.name,value:m.id,checked:m.isChecked,onChange:p=>i.onChecked(p.target.value,m),label:m.name,description:m.description})})}),!l&&i.errorMessage&&e.jsx(lt,{message:i.errorMessage})]})},Sl=({position:t="vertical",size:r="md",fullWidth:n=!1,...s})=>{var i;const o=t==="horizontal-inline"||t==="horizontal-block"?r==="sm"?342:r==="lg"?400:342:void 0;return e.jsxs(x.Box,{gap:t==="horizontal-inline"||t==="horizontal-block"?"spacing-96":"sm",direction:t==="horizontal-inline"||t==="horizontal-block"?"row":"column",children:[e.jsx(ue,{condition:!!s.description||!!s.title,children:e.jsxs(x.Box,{direction:"column",customMaxWidth:o,fullWidth:n,children:[s.title&&e.jsx(fe,{children:s.title}),e.jsx(ue,{condition:!!s.description,children:e.jsx(v.Text,{color:"gray-500",children:s.description})})]})}),e.jsx(x.Box,{gap:"sm",direction:t==="horizontal"||t==="horizontal-inline"?"row":"column",align:"flex-start",flexWrap:"wrap",children:e.jsx(Kt,{of:(i=s.radioList)==null?void 0:i.map(l=>({...l,isChecked:s.radioIsChecked===l.id})),render:({value:l,id:c,isChecked:a,subInput:u,label:f,description:g})=>e.jsxs(x.Box,{direction:"column",gap:"xs",customMaxWidth:o,children:[e.jsx(Mr.Radio,{id:`${c.toString()}-${l}`,name:s.groupName||f,label:f,value:l,checked:a,onChange:m=>s.onChecked({id:c,label:m.target.name,value:m.target.value}),disabled:s.disableAll},c),g&&e.jsx(v.Text,{color:"gray-500",style:{marginLeft:28},children:g}),u]})})}),s.errorMessage&&e.jsx(lt,{message:s.errorMessage})]})},kl=({size:t="md",direction:r="vertical",requiredTitle:n="(Required)",fullWidth:s=!1,...o})=>{var c,a,u;const i=o.hideMessageError||!1,l=r==="horizontal"?t==="sm"?342:t==="lg"?400:342:void 0;return e.jsxs(x.Box,{gap:r==="horizontal"?"spacing-96":"sm",direction:r==="horizontal"?"row":"column",...o.containerProps,children:[o.title&&e.jsx(ue,{condition:!!o.inputProps.required,fallback:e.jsxs(x.Box,{direction:"column",customMaxWidth:l,fullWidth:s,children:[e.jsx(fe,{children:o.title}),e.jsx(v.Text,{fontSize:t,color:"gray-500",children:o.description})]}),children:e.jsxs(x.Box,{direction:"column",customMaxWidth:l,fullWidth:s,children:[e.jsxs(ce.Flex,{direction:"row",gap:"xs",align:"center",children:[e.jsx(fe,{fontSize:t,children:o.title}),e.jsx(fe,{color:"error",fontSize:t,children:n}),e.jsx(ue,{condition:!!((c=o.tooltip)!=null&&c.label),children:e.jsx(Fe.Tooltip,{label:(a=o.tooltip)==null?void 0:a.label,arrowPosition:(u=o.tooltip)==null?void 0:u.arrowPosition,...o.tooltip,children:e.jsx(E.Icon,{name:"InfoCircle",size:t==="lg"?"sm":"xs",style:{color:"var(--sa-color-info-500, #00abeb)",marginTop:"6px"}})})})]}),e.jsx(ue,{condition:!!o.description,children:e.jsx(v.Text,{fontSize:t,color:"gray-500",children:o.description})})]})}),e.jsxs(ce.Flex,{direction:"column",gap:"xs",children:[e.jsx(Fr.Textarea,{ref:o.inputRef,size:t,...o.inputProps,status:o.errorMessage?"error":"default"}),!i&&o.errorMessage&&e.jsx(lt,{message:o.errorMessage})]})]})},Bl=({size:t="md",direction:r="vertical",requiredTitle:n="(Required)",required:s=!1,fullWidth:o=!1,...i})=>{var c,a,u;const l=r==="horizontal"?t==="sm"?342:t==="lg"?400:342:void 0;return e.jsxs(x.Box,{gap:r==="horizontal"?"spacing-96":"sm",direction:r==="horizontal"?"row":"column",...i.containerProps,children:[i.title&&e.jsx(ue,{condition:s,fallback:e.jsxs(x.Box,{direction:"column",customMaxWidth:l,fullWidth:o,children:[e.jsx(fe,{children:i.title}),e.jsx(v.Text,{fontSize:t,color:"gray-500",children:i.titleDescription})]}),children:e.jsxs(x.Box,{direction:"column",customMaxWidth:l,fullWidth:o,children:[e.jsxs(ce.Flex,{direction:"row",gap:"xs",align:"center",children:[e.jsx(fe,{fontSize:t,children:i.title}),e.jsx(fe,{color:"error",fontSize:t,children:n}),e.jsx(ue,{condition:!!((c=i.tooltip)!=null&&c.label),children:e.jsx(Fe.Tooltip,{label:(a=i.tooltip)==null?void 0:a.label,arrowPosition:(u=i.tooltip)==null?void 0:u.arrowPosition,...i.tooltip,children:e.jsx(E.Icon,{name:"InfoCircle",size:t==="lg"?"sm":"xs",style:{color:"var(--sa-color-info-500, #00abeb)",marginTop:"6px"}})})})]}),e.jsx(ue,{condition:!!i.titleDescription,children:e.jsx(v.Text,{fontSize:t,color:"gray-500",children:i.titleDescription})})]})}),e.jsx(vt.Toggle,{checked:i.checked,onChange:i.onChange,label:i.label,description:i.description}),i.errorMessage&&e.jsx(lt,{message:i.errorMessage})]})},El=({variant:t="primary",size:r="md",...n})=>{const s=pt.useColor(),o=l=>{var a,u,f,g,m,p;if(!l)return;const c=n.disabled?"var(--sa-text-disable, #181a198f)":t==="secondary"?"var(--sa-text-subtle, #8c8f97)":t==="secondary-danger"?(u=(a=s==null?void 0:s.computed)==null?void 0:a.red)==null?void 0:u[600]:t==="secondary-primary"?(g=(f=s==null?void 0:s.computed)==null?void 0:f.blue)==null?void 0:g[700]:(p=(m=s==null?void 0:s.computed)==null?void 0:m.gray)==null?void 0:p[50];return e.jsx(E.Icon,{name:l,size:r,style:{color:c}})},i=()=>{var c,a,u,f;if(t!=="secondary-danger"&&t!=="secondary-primary")return n.title;const l={color:n.disabled?"var(--sa-text-disable, #181a198f)":t==="secondary-danger"?(a=(c=s==null?void 0:s.computed)==null?void 0:c.red)==null?void 0:a[600]:(f=(u=s==null?void 0:s.computed)==null?void 0:u.blue)==null?void 0:f[700]};switch(r){case"xs":return e.jsx(Xe.Body2,{props:{style:l},children:n.title});case"sm":case"md":return e.jsx(Xe.SubH3,{props:{style:l},children:n.title});case"lg":return e.jsx(Xe.SubH2,{props:{style:l},children:n.title});default:return n.title}};return e.jsx(H.Button,{fullWidth:!0,disabled:n.disabled,primary:t==="primary",secondary:t==="secondary"||t==="secondary-danger"||t==="secondary-primary",success:t==="success",onClick:n.onClick,type:n.type,iconLeft:o(n.iconLeft),iconRight:o(n.iconRight),size:r,children:i()})},Fl=t=>e.jsx(Xe.H5,{props:{...t},children:t.title}),Ml=({size:t="md",direction:r="vertical",requiredTitle:n="(Required)",fullWidth:s=!1,...o})=>{var c,a,u;const i=o.hideMessageError||!1,l=r==="horizontal"?t==="sm"?342:t==="lg"?400:342:void 0;return e.jsxs(x.Box,{gap:r==="horizontal"?"spacing-96":"sm",direction:r==="horizontal"?"row":"column",onClick:o.onClickContainer,children:[o.title&&e.jsx(ue,{condition:!!o.inputProps.required,fallback:e.jsxs(x.Box,{direction:"column",customMaxWidth:l,fullWidth:s,children:[e.jsx(fe,{children:o.title}),e.jsx(v.Text,{fontSize:t,color:"gray-500",children:o.description})]}),children:e.jsxs(x.Box,{direction:"column",customMaxWidth:l,fullWidth:s,children:[e.jsxs(ce.Flex,{direction:"row",gap:"xs",align:"center",children:[e.jsx(fe,{fontSize:t,children:o.title}),e.jsx(fe,{color:"error",fontSize:t,children:n}),e.jsx(ue,{condition:!!((c=o.tooltip)!=null&&c.label),children:e.jsx(Fe.Tooltip,{label:(a=o.tooltip)==null?void 0:a.label,arrowPosition:(u=o.tooltip)==null?void 0:u.arrowPosition,...o.tooltip,children:e.jsx(E.Icon,{name:"InfoCircle",size:t==="lg"?"sm":"xs",style:{color:"var(--sa-color-info-500, #00abeb)",marginTop:"6px"}})})})]}),e.jsx(ue,{condition:!!o.description,children:e.jsx(v.Text,{fontSize:t,color:"gray-500",children:o.description})})]})}),e.jsxs(ce.Flex,{direction:"column",gap:"xs",children:[e.jsx(x.Box,{direction:"column",style:{width:r==="horizontal"&&o.customWidth?o.customWidth:r==="horizontal"?"343px":""},children:e.jsx(ht.StarasiaDate,{size:t,...o.inputProps,status:o.errorMessage?"error":void 0})}),!i&&o.errorMessage&&e.jsx(lt,{message:o.errorMessage})]})]})};async function Il(t,r){const n=new Image;n.src=t,await new Promise((i,l)=>{n.onload=i,n.onerror=l});const s=document.createElement("canvas");s.width=r.width,s.height=r.height;const o=s.getContext("2d",{alpha:!0});if(!o)throw new Error("No 2D context");return o.drawImage(n,r.x,r.y,r.width,r.height,0,0,r.width,r.height),new Promise((i,l)=>{s.toBlob(c=>{if(!c)return l("Canvas is empty");const a=new File([c],"cropped.png",{type:"image/png"});i(a)},"image/png")})}const Vn={"1:1":1,"4:3":4/3,"16:9":16/9,"3:4":3/4,"9:16":9/16,"2:3":2/3,"3:2":3/2,"32:9":32/9},To=d.forwardRef(({handleUpload:t,urlImage:r,isUploading:n,croppedImage:s,setCroppedImage:o,size:i="96",aspect:l="1:1",containerProps:c,maxFileSize:a=2,onError:u},f)=>{const g=Ce.useMediaQuery("md"),[m,p]=d.useState(!1),[S,b]=d.useState(null),[I,B]=d.useState(!1),[F,w]=d.useState({x:0,y:0}),[D,A]=d.useState(1),[O,C]=d.useState(null);d.useEffect(()=>{r===null&&o(null)},[r]);const R=d.useCallback((z,P)=>{C(P)},[]),L=z=>{var ye;const P=(ye=z.target.files)==null?void 0:ye[0];if(!P)return;const se=new FileReader;se.onload=()=>{b(se.result),B(!0)},se.readAsDataURL(P)},U=async()=>{if(!(!S||!O))try{const z=await Il(S,O);if(a&&z.size>a*1024*1024){u==null||u(`Ukuran file maksimal ${a}MB`);return}t==null||t(z);const P=URL.createObjectURL(z);o(P,z),B(!1)}catch{u==null||u("Gagal memproses gambar")}},J=d.useRef(null),N=()=>{J.current&&J.current.click()};d.useImperativeHandle(f,()=>({openFileDialog:()=>{var z;(z=J.current)==null||z.click()}}));const _=parseInt(i,10),X=Vn[l];let te,V;return X>=1?(V=_,te=_*X):(te=_,V=_/X),e.jsxs(x.Box,{direction:"column",display:"flex",position:"relative",bg:(c==null?void 0:c.bg)||"gray-200",borderStyle:(c==null?void 0:c.borderStyle)||"border-none",borderColor:(c==null?void 0:c.borderColor)||"gray-200",borderWidth:(c==null?void 0:c.borderWidth)||"border-2",borderRadius:(c==null?void 0:c.borderRadius)||"rounded-md",overflow:"overflow-hidden",align:"center",justify:"center",style:{width:c!=null&&c.fullWidth?"100%":`${te}px`,height:c!=null&&c.fullWidth?"auto":`${V}px`,aspectRatio:X,flexShrink:0},onMouseEnter:()=>p(!0),onMouseLeave:()=>p(!1),children:[s||r?e.jsx("img",{src:s||r||void 0,alt:"Profile",style:{objectFit:"cover",width:"100%",height:"100%"}}):e.jsx(x.Box,{display:"flex",direction:"column",align:"center",justify:"center",padding:"spacing-4",children:e.jsx(E.Icon,{name:"Image",style:{color:"var(--sa-text-subtle, #8c8f97)",width:Number(i)/2<40?Number(i)/2:40,height:Number(i)/2<40?Number(i)/2:40}})}),e.jsxs(x.Box,{direction:"column",position:"absolute",display:"flex",align:"center",justify:"center",cursor:"pointer",style:{inset:0,backgroundColor:"var(--sa-color-black-alpha-a30, #080f214a)",opacity:m?1:0,transition:"opacity 0.3s ease-in-out"},onClick:N,children:[e.jsx("input",{ref:J,type:"file",accept:"image/*",onChange:L,disabled:n,style:{display:"none"}}),e.jsxs(x.Box,{display:"flex",align:"center",gap:"spacing-2",direction:"row",children:[e.jsx(E.Icon,{name:"Edit3",style:{color:"var(--sa-background-primary, #ffffff)"}}),e.jsx(ue,{condition:i.toNumber()>80,children:e.jsx(v.Text,{color:"gray-50",fontSize:i.toNumber()>80?"sm":"md",fontWeight:"medium",children:"Edit Image"})})]})]}),n&&e.jsx(x.Box,{direction:"column",position:"absolute",display:"flex",align:"center",justify:"center",style:{inset:0,zIndex:20,backgroundColor:"var(--sa-color-white-alpha-a80, #e5e9f640)"},children:e.jsx(x.Box,{direction:"column",borderRadius:"rounded-full",style:{animation:"spin 1s linear infinite",border:"2px solid transparent",height:"2rem",width:"2rem"},borderColor:"info-600"})}),I&&Yt.createPortal(e.jsx("div",{style:{position:"fixed",inset:0,zIndex:19999,display:"flex",alignItems:"center",justifyContent:"center",backgroundColor:"rgba(0,0,0,0.6)"},onClick:()=>B(!1),children:e.jsxs("div",{style:{backgroundColor:"var(--sa-background-primary)",borderRadius:"var(--sa-radii-md)",boxShadow:"0 20px 60px rgba(0,0,0,0.3)",overflow:"hidden",width:g?l==="1:1"?"min(90vw, 480px)":`min(90vw, ${te*2}px)`:"calc(100vw - 2rem)",display:"flex",flexDirection:"column"},onClick:z=>z.stopPropagation(),children:[e.jsx("div",{style:{position:"relative",width:"100%",height:"20rem",backgroundColor:"var(--sa-color-gray-100)"},children:S&&e.jsx(is,{image:S,crop:F,zoom:D,aspect:l?Vn[l]:void 0,onCropChange:w,onZoomChange:A,onCropComplete:R,objectFit:"contain",minZoom:.5,restrictPosition:!1})}),e.jsxs("div",{style:{display:"flex",justifyContent:"flex-end",gap:"0.5rem",padding:"0.75rem 1rem",borderTop:"1px solid var(--sa-border-subtle)"},children:[e.jsx(H.Button,{size:"sm",secondary:!0,onClick:()=>B(!1),children:"Cancel"}),e.jsx(H.Button,{size:"sm",primary:!0,onClick:U,children:"Crop"})]})]})}),document.body)]})}),Ll=({size:t="md",direction:r="vertical",requiredTitle:n="(Required)",fullWidth:s=!1,required:o=!1,...i})=>{var a,u,f;const l=i.hideMessageError||!1,c=r==="horizontal"?t==="sm"?342:t==="lg"?400:342:void 0;return e.jsxs(x.Box,{gap:r==="horizontal"?"spacing-96":"sm",direction:r==="horizontal"?"row":"column",...i.containerProps,children:[i.title&&e.jsx(ue,{condition:!!o,fallback:e.jsxs(x.Box,{direction:"column",customMaxWidth:c,fullWidth:s,children:[e.jsx(fe,{children:i.title}),e.jsx(v.Text,{fontSize:t,color:"gray-500",children:i.description})]}),children:e.jsxs(x.Box,{direction:"column",customMaxWidth:c,fullWidth:s,children:[e.jsxs(ce.Flex,{direction:"row",gap:"xs",align:"center",children:[e.jsx(fe,{fontSize:t,children:i.title}),e.jsx(fe,{color:"error",fontSize:t,children:n}),e.jsx(ue,{condition:!!((a=i.tooltip)!=null&&a.label),children:e.jsx(Fe.Tooltip,{label:(u=i.tooltip)==null?void 0:u.label,arrowPosition:(f=i.tooltip)==null?void 0:f.arrowPosition,...i.tooltip,children:e.jsx(E.Icon,{name:"InfoCircle",size:t==="lg"?"sm":"xs",style:{color:"var(--sa-color-info-500, #00abeb)",marginTop:"6px"}})})})]}),e.jsx(ue,{condition:!!i.description,children:e.jsx(v.Text,{fontSize:t,color:"gray-500",children:i.description})})]})}),e.jsxs(ce.Flex,{direction:"column",gap:"xs",children:[e.jsx(To,{...i.inputProps}),!l&&i.errorMessage&&e.jsx(lt,{message:i.errorMessage})]})]})},Tl=({size:t="md",direction:r="vertical",requiredTitle:n="(Required)",fullWidth:s=!1,...o})=>{var l,c,a;const i=r==="horizontal"?t==="sm"?342:t==="lg"?400:342:void 0;return e.jsxs(x.Box,{gap:r==="horizontal"?"spacing-96":"sm",direction:r==="horizontal"?"row":"column",...o.containerProps,children:[o.title&&e.jsx(ue,{condition:!!o.inputProps.required,fallback:e.jsxs(x.Box,{direction:"column",customMaxWidth:i,fullWidth:s,children:[e.jsx(fe,{children:o.title}),e.jsx(v.Text,{fontSize:t,color:"gray-500",children:o.description})]}),children:e.jsxs(x.Box,{direction:"column",customMaxWidth:i,fullWidth:s,children:[e.jsxs(ce.Flex,{direction:"row",gap:"xs",align:"center",children:[e.jsx(fe,{fontSize:t,children:o.title}),e.jsx(fe,{color:"error",fontSize:t,children:n}),e.jsx(ue,{condition:!!((l=o.tooltip)!=null&&l.label),children:e.jsx(Fe.Tooltip,{label:(c=o.tooltip)==null?void 0:c.label,arrowPosition:(a=o.tooltip)==null?void 0:a.arrowPosition,...o.tooltip,children:e.jsx(E.Icon,{name:"InfoCircle",size:t==="lg"?"sm":"xs",style:{color:"var(--sa-color-info-500, #00abeb)",marginTop:"6px"}})})})]}),e.jsx(ue,{condition:!!o.description,children:e.jsx(v.Text,{fontSize:t,color:"gray-500",children:o.description})})]})}),o.inputProps.extended&&o.inputProps.extended]})},Ol=({items:t,id:r,handleOnUpdate:n,width:s,toggleShow:o=!0,disabled:i=!1})=>{var f;const[l,c]=d.useState([]);d.useEffect(()=>{t&&c([...t.map(g=>({id:g.id,isActive:g.isActive}))])},[t]);const a=(f=l.find(g=>g.id===r))==null?void 0:f.isActive,u=d.useCallback(()=>{c(g=>g.map(m=>m.id===r?{...m,isActive:!m.isActive}:m)),n&&n(!a)},[r,n,a]);return e.jsx(x.Box,{direction:"row",gap:"md",style:{width:s},children:o&&e.jsx(vt.Toggle,{disabled:i,checked:a,onChange:u,label:a?"Active":"Inactive"})})},Rl={InputText:Ui,InputDropdown:Ji,InputSingleFile:wl,CheckBoxOptions:Dl,RadioOptions:Sl,InputTextArea:kl,ToggleForm:Bl,ActionButton:El,FormTitle:Fl,InputDate:Ml,InputImgFile:Ll,Custom:Tl},Oo=({customBottom:t})=>{const[r,n]=d.useState(!1),s=()=>{window.scrollY>window.screenY?n(!0):n(!1)},o=()=>{window.scrollTo({top:0,behavior:"smooth"})};return d.useEffect(()=>(window.addEventListener("scroll",s),()=>{window.removeEventListener("scroll",s)}),[]),e.jsx(x.Box,{direction:"column",style:{position:"fixed",bottom:0,right:0},children:e.jsx(x.Box,{direction:"column",position:"absolute",style:{bottom:t||"1.6rem",right:"2rem",transform:r?"scale(1)":"scale(0)",transition:"transform 0.2s ease-in-out"},children:e.jsx(H.Button,{secondary:!0,size:"xs",onClick:o,type:"button",iconLeft:e.jsx(E.Icon,{width:16,size:"xs",name:"ArrowPullUp",style:{color:"var(--sa-background-brand, #04254f)"}})})})})},Ge="sa-sidepanel-item",Nn="sa-sidepanel-item-styles",Al="inset 3.5px 0 0 0 var(--sa-border-focused, #1a4fa0)",Wl="inset -3.5px 0 0 0 var(--sa-border-focused, #1a4fa0)",zl=`
58
58
  .${Ge} {
59
59
  display: block;
60
60
  box-sizing: border-box;