@starasia/admin 8.10.1 → 8.10.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 +1 -1
- package/dist/index.es.js +1 -1
- package/dist/index.umd.js +1 -1
- package/package.json +1 -1
package/dist/index.cjs.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const yr=require("@starasia/alert"),qe=require("@starasia/badges"),h=require("@starasia/box"),nt=require("@starasia/breadcrumb"),V=require("@starasia/button"),pr=require("@starasia/card"),Ke=require("@starasia/date"),Re=require("@starasia/dialog"),Ft=require("@starasia/drawer"),it=require("@starasia/dropdown"),he=require("@starasia/hooks"),st=require("@starasia/http"),Ze=require("@starasia/input"),I=require("@starasia/menu"),xt=require("@starasia/pagination"),ut=require("@starasia/storage"),U=require("@starasia/table"),jr=require("@starasia/tabs"),$t=require("@starasia/textarea"),ot=require("@starasia/theme"),br=require("@starasia/toast"),lt=require("@starasia/toggle"),ve=require("@starasia/tooltip"),ct=require("@starasia/checkbox"),er=require("@starasia/radio"),C=require("@starasia/text"),B=require("@starasia/icon"),oe=require("@starasia/flex"),vr=require("@starasia/grid"),Cr=require("@starasia/progress"),wr=require("@starasia/stepper"),Dr=require("@starasia/accordion"),Sr=require("@starasia/story-record"),Pe=require("@starasia/skeleton"),kr=require("@starasia/progress-stepper"),e=require("react/jsx-runtime"),u=require("react"),pe=require("react-router"),nr=require("react-dom"),Yn=require("react-easy-crop"),Xn={menus:[],menuBottom:void 0,logo:"",appName:"Workspace",userData:null,setUserData:()=>{}},or=u.createContext(Xn),ir=()=>u.useContext(or),Xr=t=>{const[r,n]=u.useState((t==null?void 0:t.initialUserData)||null);return{userData:r,setUserData:n}},Kr=u.createContext({badges:{},setBadge:()=>{},setBadges:()=>{},clearBadge:()=>{}}),$r=({children:t})=>{const[r,n]=u.useState({}),i=u.useCallback(l=>{n(d=>typeof l=="function"?l(d):l)},[]),o=u.useCallback((l,d)=>{n(a=>{const f=typeof d=="function"?d(a[l]):d;return{...a,[l]:f}})},[]),s=u.useCallback(l=>{n(d=>{if(!(l in d))return d;const a={...d};return delete a[l],a})},[]),c=u.useMemo(()=>({badges:r,setBadge:o,setBadges:i,clearBadge:s}),[r,o,i,s]);return e.jsx(Kr.Provider,{value:c,children:t})},en=()=>u.useContext(Kr),St=(t,r)=>{const n=r!==void 0?r:t;return n==null?null:typeof n=="string"||typeof n=="number"?{value:n}:n},tn=({router:t,menus:r=[],menuBottom:n,logo:i,appName:o="Workspace",initialUserData:s,theme:c})=>{const l=Xr({initialUserData:s}),{theme:d}=ot.useTheme();return e.jsx(or.Provider,{value:{logo:i,appName:o,menus:r,userData:l.userData,setUserData:l.setUserData,menuBottom:n},children:e.jsx($r,{children:c?e.jsx(ot.ThemeProvider,{value:c,children:t}):d?e.jsx(ot.ThemeProvider,{value:d,children:t}):t})})},Kn=u.memo(tn);function rn({collapsed:t=!1,children:r}){if(!r)return null;const n=typeof r=="function",i=n?r({collapsed:t}):r;return i==null||i===!1?null:e.jsx("div",{style:{position:"sticky",top:"4rem",zIndex:1,borderBottom:"1px solid var(--sa-border-subtle, #0b120e24)",paddingLeft:"0.5rem",paddingRight:"0.5rem",paddingTop:"0.5rem",paddingBottom:"0.5rem",boxSizing:"border-box"},children:n?i:e.jsx("div",{style:{opacity:t?0:1,transition:"opacity 0.3s",visibility:t?"hidden":"visible"},children:i})})}const sr=u.createContext(null);function nn({children:t}){const[r,n]=u.useState(null),[i,o]=u.useState(null),[s,c]=u.useState(null),[l,d]=u.useState(0),a=u.useCallback(()=>(d(f=>f+1),()=>d(f=>f-1)),[]);return e.jsx(sr.Provider,{value:{prependNode:r,appendNode:i,replaceNode:s,setPrependNode:n,setAppendNode:o,setReplaceNode:c,replaceCount:l,registerReplace:a},children:t})}function on({children:t}){const r=u.useContext(sr);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 $n({children:t,mode:r="append"}){const n=u.useContext(sr);if(u.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 i=r==="prepend"?n.prependNode:r==="replace"?n.replaceNode:n.appendNode;return i?nr.createPortal(t,i):null}const lr=u.createContext(null);function sn({children:t}){const[r,n]=u.useState({}),[i,o]=u.useState({}),s=u.useCallback((d,a)=>{n(f=>f[d]===a?f:{...f,[d]:a})},[]),c=u.useCallback(d=>(o(a=>({...a,[d]:(a[d]??0)+1})),()=>o(a=>({...a,[d]:Math.max(0,(a[d]??0)-1)}))),[]),l=u.useMemo(()=>({outletNodes:r,setOutletNode:s,slotCounts:i,registerSlot:c}),[r,s,i,c]);return e.jsx(lr.Provider,{value:l,children:t})}function ln({slotKey:t,fallback:r}){const n=u.useContext(lr),i=n?(n.slotCounts[t]??0)>0:!1,o=u.useRef(n==null?void 0:n.setOutletNode);o.current=n==null?void 0:n.setOutletNode;const s=u.useCallback(c=>{var l;return(l=o.current)==null?void 0:l.call(o,t,c)},[t]);return e.jsx(e.Fragment,{children:i?e.jsx("div",{ref:s,style:{display:"contents"}}):r})}function eo({slotKey:t,children:r}){const n=u.useContext(lr),i=u.useRef(n==null?void 0:n.registerSlot);if(i.current=n==null?void 0:n.registerSlot,u.useEffect(()=>{var s;return(s=i.current)==null?void 0:s.call(i,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?nr.createPortal(r,o):null}const Et="moduleSwitcherGroupId",tr="sa-module-switcher-change";function Br(){if(typeof window>"u")return null;const t=window.localStorage.getItem(Et);if(t===null)return null;const r=Number(t);return Number.isFinite(r)?r:null}function cn(t){typeof window>"u"||(t===null?window.localStorage.removeItem(Et):window.localStorage.setItem(Et,String(t)),window.dispatchEvent(new CustomEvent(tr,{detail:t})))}function to(){cn(null)}function cr(){const[t,r]=u.useState(()=>Br());return u.useEffect(()=>{const i=()=>{r(Br())},o=s=>{s.key===Et&&i()};return window.addEventListener(tr,i),window.addEventListener("storage",o),()=>{window.removeEventListener(tr,i),window.removeEventListener("storage",o)}},[]),{selectedGroupId:t,setSelectedGroupId:i=>{cn(i),r(i)}}}let pt=0,Xe=!1,Fr=new Set;const Er=()=>e.jsxs("svg",{width:"100%",height:"100%",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.25",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[e.jsx("rect",{x:"1.667",y:"1.667",width:"12.667",height:"12.667",rx:"2"}),e.jsx("line",{x1:"6",y1:"1.667",x2:"6",y2:"14.333"})]}),Mr={width:"100%",display:"flex",alignItems:"center",gap:"0.75rem",paddingLeft:"0.75rem",paddingRight:"0.75rem",paddingTop:"0.5rem",paddingBottom:"0.5rem",fontSize:"0.875rem",color:"var(--sa-text-subtle, #8c8f97)",background:"transparent",border:"none",borderRadius:"0.375rem",cursor:"pointer",textAlign:"left"};function ro({children:t,headerLeftSlot:r,profile:n,isLoadingProfile:i,onLogout:o,isLoggingOut:s,loadingComponent:c,sidebarHeaderContent:l,headerActions:d,profileRole:a,profileMenuButtons:f,profileMenuItems:m,logoutButton:g}){var Fe,Ge;const[j]=pe.useSearchParams(),M=j.get("embed")==="true",y=ir(),{badges:D}=en(),E=pe.useNavigate(),T=pe.useLocation(),v=!he.useMediaQuery("md"),[R,O]=u.useState(!1),[b,S]=u.useState(!1),[P,A]=u.useState(!1),[N,G]=u.useState(!1),[re,xe]=u.useState(()=>new Set(Fr)),[ne,se]=u.useState(null),{selectedGroupId:J,setSelectedGroupId:Q}=cr();u.useEffect(()=>{Fr=re},[re]);const ae=u.useRef(null),ee=u.useRef(null);u.useEffect(()=>{const k=ae.current;if(!k)return;const Z=()=>{Xe||(pt=k.scrollTop)};return k.addEventListener("scroll",Z),()=>k.removeEventListener("scroll",Z)},[]);const ce=()=>{const k=ae.current;k&&pt>0&&(Xe=!0,k.scrollTop=pt,requestAnimationFrame(()=>{Xe=!1}))};u.useLayoutEffect(()=>{Xe=!0,ce();const k=setTimeout(()=>{Xe=!1},300);return()=>clearTimeout(k)},[]),u.useLayoutEffect(()=>{y.menus.length>0&&(pt>0?ce():requestAnimationFrame(()=>{var Z;const k=(Z=ae.current)==null?void 0:Z.querySelector("[data-menu-active='true']");k&&k.scrollIntoView({block:"center",behavior:"instant"})}))},[y.menus]),u.useEffect(()=>{Xe=!0,ce();const k=setTimeout(ce,0),Z=setTimeout(ce,50),_=setTimeout(ce,100),L=setTimeout(ce,200),z=setTimeout(()=>{Xe=!1},300),H=setTimeout(()=>{const q=ae.current,K=q==null?void 0:q.querySelector("[data-menu-active='true']");if(q&&K){const je=q.getBoundingClientRect(),Se=K.getBoundingClientRect();Se.top>=je.top&&Se.bottom<=je.bottom||K.scrollIntoView({block:"center",behavior:"smooth"})}},250);return()=>{clearTimeout(k),clearTimeout(Z),clearTimeout(_),clearTimeout(L),clearTimeout(z),clearTimeout(H)}},[T.pathname]),u.useEffect(()=>{ee.current&&(ee.current.scrollTop=0)},[T.pathname]),u.useEffect(()=>{v&&A(!1)},[T.pathname,v]),u.useEffect(()=>{v&&S(!0)},[v]);const we=()=>{O(!0)},ze=()=>{O(!1)},fe=()=>{O(!1),o()},De=k=>{const Z=[k.to];return k.children&&Z.push(...k.children.map(_=>_.to)),Z},Me=[...y.menus.flatMap(k=>k.items.flatMap(De)),...((Fe=y.menuBottom)==null?void 0:Fe.flatMap(De))??[]],me=k=>{if(!T.pathname.startsWith(k))return!1;const Z=Me.filter(_=>T.pathname.startsWith(_)).sort((_,L)=>L.length-_.length)[0];return k===Z};u.useEffect(()=>{var Z;const k=_=>{var L;(L=_.children)!=null&&L.some(z=>T.pathname.startsWith(z.to))&&xe(z=>{const H=new Set(z);return H.add(_.id),H})};y.menus.forEach(_=>{_.items.forEach(k)}),(Z=y.menuBottom)==null||Z.forEach(k)},[T.pathname,y.menus,y.menuBottom]);const Ie=k=>{xe(Z=>{const _=new Set(Z);return _.has(k)?_.delete(k):_.add(k),_})};u.useEffect(()=>{y.menus.length!==0&&J!==null&&!y.menus.some(k=>k.id===J)&&Q(null)},[y.menus,J,Q]);const Ne=u.useMemo(()=>{if(J!==null)return y.menus.filter(_=>_.id===J||_.parentGroupId===J);const k=y.menus.filter(_=>_.parentGroupId===void 0),Z=y.menus.filter(_=>_.parentGroupId!==void 0).flatMap(_=>_.items);return Z.length===0?k:[...k,{id:18,name:"Pengaturan",items:Z,parentGroupId:void 0}]},[y.menus,J]);if(M)return e.jsx("main",{style:{height:"100vh",overflowY:"auto",backgroundColor:"var(--sa-background-primary-inverse, #f8f8f8)"},children:t||e.jsx(pe.Outlet,{})});const ge=k=>{const Z=k.children&&k.children.length>0,_=re.has(k.id),L=Z?k.children.some(q=>me(q.to)):me(k.to),z=St(k.badge,D[k.id]),H=!!z&&b&&!v;return e.jsxs("div",{"data-menu-active":L||void 0,children:[e.jsxs("button",{onClick:q=>{if(Z)if(b&&!v){const K=q.currentTarget.getBoundingClientRect();se({item:k,top:K.top,left:K.right+8})}else Ie(k.id);else E(k.to)},style:{width:"100%",display:"flex",alignItems:"center",justifyContent:b&&!v?"center":void 0,gap:"0.5rem",paddingLeft:b&&!v?"0":"0.5rem",paddingRight:b&&!v?"0":"0.5rem",paddingTop:"0.25rem",paddingBottom:"0.25rem",height:"2rem",borderRadius:L?"var(--sa-radii-sm, 0.375rem)":"var(--sa-radii-md, 0.5rem)",textAlign:"left",border:L?"1px solid var(--sa-border-subtle, #0b120e24)":"1px solid transparent",backgroundColor:L?"var(--sa-background-primary, #ffffff)":"transparent",color:"var(--sa-text-primary, #292a2e)",cursor:"pointer"},title:b&&!v?k.title:void 0,onMouseEnter:q=>{L||(q.currentTarget.style.backgroundColor="var(--sa-background-neutral, #f0f1f2)")},onMouseLeave:q=>{L||(q.currentTarget.style.backgroundColor="transparent")},children:[e.jsxs("span",{style:{position:"relative",display:"inline-flex",flexShrink:0},children:[e.jsx(B.Icon,{name:k.icon,size:"sm",style:{flexShrink:0}}),H&&e.jsx("span",{"aria-hidden":"true",style:{position:"absolute",top:"-2px",right:"-2px",width:"0.5rem",height:"0.5rem",borderRadius:"9999px",backgroundColor:"var(--sa-color-error-500, #ff4d6d)",border:"1px solid var(--sa-background-primary, #ffffff)"}})]}),(!b||v)&&e.jsxs(e.Fragment,{children:[e.jsx("span",{style:{fontSize:"0.875rem",fontWeight:"500",whiteSpace:"nowrap",transition:"opacity 0.3s",flex:1,minWidth:0,overflow:"hidden",textOverflow:"ellipsis"},children:k.title}),z&&e.jsx(qe.Badges,{text:String(z.value),variant:z.variant??"info",size:"xs",border:!0}),Z&&e.jsx("svg",{style:{width:"1rem",height:"1rem",flexShrink:0,transition:"transform 0.2s",transform:_?"rotate(180deg)":"rotate(0deg)"},fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 9l-7 7-7-7"})})]})]}),Z&&(!b||v)&&(()=>{const q=k.children.findIndex(K=>me(K.to));return e.jsxs("div",{style:{position:"relative",marginLeft:"0.9375rem",paddingLeft:"1.125rem",overflow:"hidden",transition:"all 0.3s ease-in-out",maxHeight:_?`${k.children.length*36}px`:"0px",opacity:_?1:0,marginTop:_?"0.25rem":"0px"},children:[e.jsx("span",{"aria-hidden":"true",style:{position:"absolute",left:0,top:0,width:"1.5px",height:"100%",backgroundColor:"var(--sa-border-subtle, #0b120e24)",pointerEvents:"none"}}),q>=0&&e.jsx("span",{"aria-hidden":"true",style:{position:"absolute",left:0,top:`${q*32}px`,width:"1.5px",height:"32px",backgroundColor:"var(--sa-text-primary, #292a2e)",transition:"top 0.2s ease-in-out",pointerEvents:"none",zIndex:1}}),k.children.map(K=>{const je=St(K.badge,D[K.id]);return e.jsxs("button",{onClick:()=>E(K.to),style:{width:"100%",display:"flex",alignItems:"center",gap:"0.5rem",paddingLeft:"0.75rem",paddingRight:"0.5rem",paddingTop:"0.25rem",paddingBottom:"0.25rem",height:"2rem",borderRadius:me(K.to)?"var(--sa-radii-sm, 0.375rem)":"var(--sa-radii-md, 0.5rem)",textAlign:"left",backgroundColor:me(K.to)?"var(--sa-background-primary, #ffffff)":"transparent",color:me(K.to)?"var(--sa-text-primary, #292a2e)":"var(--sa-text-subtle, #505258)",cursor:"pointer",border:me(K.to)?"1px solid var(--sa-border-subtle, #0b120e24)":"1px solid transparent"},onMouseEnter:Se=>{me(K.to)||(Se.currentTarget.style.backgroundColor="var(--sa-background-neutral, #f0f1f2)")},onMouseLeave:Se=>{me(K.to)||(Se.currentTarget.style.backgroundColor="transparent")},children:[e.jsx(B.Icon,{name:K.icon,size:"sm",style:{flexShrink:0}}),e.jsx("span",{style:{fontSize:"0.875rem",fontWeight:"500",whiteSpace:"nowrap",flex:1,minWidth:0,overflow:"hidden",textOverflow:"ellipsis"},children:K.title}),je&&e.jsx(qe.Badges,{text:String(je.value),variant:je.variant??"info",size:"xs",border:!0})]},K.id)})]})})()]},k.id)};return e.jsx(sn,{children:e.jsxs(nn,{children:[e.jsxs("div",{style:{display:"flex",height:"100vh",position:"relative","--app-sidebar-width":v?"0px":b?"4.375rem":"16.375rem","--app-footer-zindex":v&&P?"40":"999"},children:[v&&e.jsx("div",{style:{position:"fixed",inset:0,backgroundColor:"var(--sa-color-black-alpha-a50, #181a198f)",zIndex:40,opacity:P?.5:0,pointerEvents:P?"auto":"none",transition:"opacity 0.3s"},onClick:()=>A(!1)}),e.jsxs("aside",{style:{width:v?"16.375rem":b?"4.375rem":"16.375rem",position:v?"fixed":"relative",...v&&{inset:0,zIndex:50,transform:P?"translateX(0)":"translateX(-100%)"},backgroundColor:"var(--sa-background-primary-inverse, #f8f8f8)",borderRight:"1px solid var(--sa-border-subtle, #0b120e24)",display:"flex",flexDirection:"column",transition:"all 0.3s ease-in-out",flexShrink:v?void 0:0},children:[e.jsx("div",{onMouseEnter:()=>G(!0),onMouseLeave:()=>G(!1),style:{height:"4rem",display:"flex",alignItems:"center",justifyContent:"space-between",paddingLeft:"1rem",paddingRight:"1rem",borderBottom:"1px solid var(--sa-border-subtle, #0b120e24)",position:"relative"},children:(()=>{const k=!v&&b&&!P,Z=k&&N;return e.jsxs(e.Fragment,{children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"0.5rem",flex:k?1:void 0,justifyContent:k?"center":void 0,transition:"opacity 0.2s",opacity:Z?0:1,pointerEvents:Z?"none":"auto"},children:[e.jsx("img",{src:y.logo,alt:"Logo",style:{width:"2rem",height:"2rem",flexShrink:0}}),(!b||P)&&e.jsx("span",{style:{fontWeight:"600",color:"var(--sa-text-primary, #292a2e)",whiteSpace:"nowrap",transition:"opacity 0.3s"},children:y.appName})]}),!v&&!b&&e.jsx("button",{type:"button",onClick:()=>S(!0),"aria-label":"Collapse sidebar",style:{display:"inline-flex",alignItems:"center",justifyContent:"center",width:"1rem",height:"1rem",padding:0,background:"transparent",border:"none",color:"var(--sa-text-subtle, #8c8f97)",cursor:"pointer",flexShrink:0},children:e.jsx(Er,{})}),k&&e.jsx("button",{type:"button",onClick:()=>S(!1),"aria-label":"Expand sidebar",style:{position:"absolute",top:"50%",left:"50%",transform:"translate(-50%, -50%)",display:"inline-flex",alignItems:"center",justifyContent:"center",width:"2rem",height:"2rem",padding:0,background:"var(--sa-background-primary, #ffffff)",border:"1px solid var(--sa-border-subtle, #0b120e24)",borderRadius:"var(--sa-radii-sm, 0.375rem)",color:"var(--sa-text-primary, #292a2e)",cursor:"pointer",opacity:Z?1:0,pointerEvents:Z?"auto":"none",transition:"opacity 0.2s"},children:e.jsx("span",{style:{width:"1rem",height:"1rem",display:"inline-flex"},children:e.jsx(Er,{})})}),v&&e.jsx("button",{onClick:()=>A(!1),"aria-label":"Close menu",style:{padding:"0.375rem",borderRadius:"0.5rem",backgroundColor:"transparent",border:"none",color:"var(--sa-text-subtle, #8c8f97)",cursor:"pointer"},children:e.jsx("svg",{style:{width:"1.25rem",height:"1.25rem"},fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]})})()}),l&&e.jsx(rn,{collapsed:v?!1:b,children:l}),e.jsx("div",{ref:ae,style:{flex:1,overflowY:"auto",paddingTop:"1rem",paddingBottom:"1rem"},children:Ne.map(k=>e.jsxs("div",{style:{marginBottom:"1rem"},children:[!b||v?k.name&&e.jsx("div",{style:{paddingLeft:"1.5rem",paddingRight:"1rem",paddingTop:"0rem",paddingBottom:"0.25rem",fontSize:"0.875rem",fontWeight:"400",color:"var(--sa-text-subtlest, #6b6e76)",transition:"opacity 0.3s",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:k.name}):k.name&&e.jsx("div",{"aria-label":k.name,style:{display:"flex",alignItems:"center",justifyContent:"center",paddingTop:"0.75rem",paddingBottom:"0.75rem"},children:e.jsx("span",{style:{display:"block",width:"1rem",height:"2px",borderRadius:"1px",backgroundColor:k.color??"var(--sa-background-brand, #04254f)"}})}),e.jsx("div",{style:{paddingLeft:"1rem",paddingRight:"1rem",display:"flex",flexDirection:"column",gap:"var(--sa-spacing-xs, 0.25rem)"},children:k.slotKey?e.jsx(ln,{slotKey:k.slotKey,fallback:k.items.map(Z=>ge(Z))}):k.items.map(Z=>ge(Z))})]},k.id))}),y.menuBottom&&y.menuBottom.length>0&&e.jsx("div",{style:{borderTop:"1px solid var(--sa-border-subtle, #0b120e24)",paddingTop:"0.75rem",paddingBottom:"0.75rem",paddingLeft:"1rem",paddingRight:"1rem",backgroundColor:"var(--sa-background-primary-inverse, #f8f8f8)",display:"flex",flexDirection:"column",gap:"var(--sa-spacing-xs, 0.25rem)",flexShrink:0},children:y.menuBottom.map(k=>ge(k))})]}),e.jsxs("div",{style:{flex:1,display:"flex",flexDirection:"column",overflow:"hidden"},children:[e.jsxs("header",{style:{height:"4rem",backgroundColor:"var(--sa-background-primary, #ffffff)",borderBottom:"1px solid var(--sa-border-subtle, #0b120e24)",display:"flex",alignItems:"center",justifyContent:"space-between",paddingLeft:"1rem",paddingRight:"1rem",flexShrink:0},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"1rem"},children:[v&&e.jsx("button",{onClick:()=>A(!0),style:{padding:"0.375rem",borderRadius:"0.5rem",backgroundColor:"transparent",border:"none",color:"var(--sa-text-subtle, #8c8f97)",cursor:"pointer"},children:e.jsx("svg",{style:{width:"1.5rem",height:"1.5rem"},fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M4 6h16M4 12h16M4 18h16"})})}),e.jsx(on,{children:r})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"0.75rem"},children:[d,e.jsxs(I.Menu,{position:"bottom-right",children:[e.jsx(I.MenuButton,{children:e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"0.5rem",cursor:"pointer"},children:[e.jsxs("div",{style:{textAlign:"right",maxWidth:"12.5rem"},children:[e.jsx("p",{style:{margin:0,fontSize:"0.875rem",fontWeight:500,color:"var(--sa-text-subtle, #8c8f97)",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:i?"Loading...":(n==null?void 0:n.name)||"unknown"}),e.jsx("p",{style:{margin:0,fontSize:"0.75rem",color:"var(--sa-text-subtle, #8c8f97)",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:i?"":(n==null?void 0:n.email)||"unknown"})]}),e.jsx("div",{style:{width:"2.5rem",height:"2.5rem",borderRadius:"9999px",display:"flex",alignItems:"center",justifyContent:"center",color:"var(--sa-background-primary, #ffffff)",fontWeight:600,fontSize:"0.875rem",boxShadow:"var(--sa-shadow-sm, 0 1px 2px 0 #0000000d)",flexShrink:0,backgroundColor:"var(--sa-background-brand, #04254f)"},children:((n==null?void 0:n.name)||"U")[0].toUpperCase()}),e.jsx(B.Icon,{name:"ChevronDown",size:"sm",style:{color:"var(--sa-text-subtle, #8c8f97)"}})]})}),e.jsxs(I.MenuLists,{style:{width:"280px",paddingBlock:"12px",paddingInline:"12px",gap:"8px",marginTop:"16px"},children:[e.jsx(I.MenuHeading,{children:e.jsxs("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",textAlign:"center",paddingBlock:"0.5rem"},children:[e.jsx("div",{style:{width:"4rem",height:"4rem",borderRadius:"9999px",display:"flex",alignItems:"center",justifyContent:"center",color:"var(--sa-background-primary, #ffffff)",fontWeight:600,fontSize:"1.25rem",boxShadow:"var(--sa-shadow-sm, 0 1px 2px 0 #0000000d)",marginBottom:"0.75rem",backgroundColor:"var(--sa-background-brand, #04254f)"},children:((n==null?void 0:n.name)||"U")[0].toUpperCase()}),e.jsx("p",{style:{margin:0,fontSize:"0.875rem",fontWeight:600,color:"var(--sa-text-primary, #292a2e)",maxWidth:"100%",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:(n==null?void 0:n.name)||"unknown"}),e.jsx("p",{style:{margin:0,fontSize:"0.75rem",color:"var(--sa-text-subtle, #8c8f97)",maxWidth:"100%",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:(n==null?void 0:n.email)||"unknown"}),a&&e.jsx("p",{style:{margin:0,fontSize:"0.75rem",color:"var(--sa-text-subtle, #8c8f97)",maxWidth:"100%",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:a})]})}),(f&&f.length>0||m)&&e.jsxs(I.MenuBody,{children:[f==null?void 0:f.map((k,Z)=>e.jsx(I.MenuButton,{children:e.jsxs("button",{type:"button",onClick:k.onClick,style:Mr,onMouseEnter:_=>{_.currentTarget.style.backgroundColor="var(--sa-background-neutral, #f0f1f2)"},onMouseLeave:_=>{_.currentTarget.style.backgroundColor="transparent"},children:[e.jsx(B.Icon,{name:k.icon,size:"md"}),e.jsx("span",{children:k.label})]})},`${k.label}-${Z}`)),m]}),g??e.jsx(I.MenuFooter,{children:e.jsx(I.MenuButton,{children:e.jsxs("button",{type:"button",onClick:we,style:{...Mr,color:"var(--sa-background-error, #c9184a)",fontWeight:500},onMouseEnter:k=>{k.currentTarget.style.backgroundColor="var(--sa-color-error-50, #fff0f3)"},onMouseLeave:k=>{k.currentTarget.style.backgroundColor="transparent"},children:[e.jsx(B.Icon,{name:"Logout",size:"md",style:{color:"var(--sa-background-error, #c9184a)"}}),e.jsx("span",{children:"Logout"})]})})})]})]})]})]}),e.jsx("main",{ref:ee,style:{flex:1,overflowY:"auto"},children:t||e.jsx(pe.Outlet,{})})]})]}),s&&c&&e.jsx("div",{style:{position:"fixed",inset:0,background:"var(--sa-color-black-alpha-a70, #181a19b8)",display:"flex",alignItems:"center",justifyContent:"center",zIndex:9999},children:c}),e.jsxs(Re.Dialog,{isShow:R,onHide:ze,children:[e.jsx(Re.DialogTitle,{children:"Confirmation Logout"}),e.jsx(Re.DialogBody,{children:"Are you sure you want to end the session and exit the page?"}),e.jsx(Re.DialogFooter,{children:e.jsx(h.Box,{direction:"column",display:"flex",align:"flex-end",justify:"center",children:e.jsxs(oe.Flex,{direction:"row",gap:"sm",align:"center",children:[e.jsx(h.Box,{direction:"column",children:e.jsx(V.Button,{secondary:!0,onClick:ze,children:"Cancel"})}),e.jsx(h.Box,{direction:"column",children:e.jsx(V.Button,{primary:!0,onClick:fe,children:"Yes, Sure"})})]})})})]}),ne&&e.jsxs(e.Fragment,{children:[e.jsx("div",{onClick:()=>se(null),style:{position:"fixed",inset:0,zIndex:60,backgroundColor:"transparent"}}),e.jsxs("div",{role:"dialog","aria-label":ne.item.title,style:{position:"fixed",top:ne.top,left:ne.left,zIndex:61,minWidth:"13rem",maxWidth:"16rem",backgroundColor:"var(--sa-background-primary, #ffffff)",border:"1px solid var(--sa-border-subtle, #0b120e24)",borderRadius:"var(--sa-radii-md, 0.5rem)",boxShadow:"var(--sa-shadow-lg, 0 10px 15px -3px #0000001a, 0 4px 6px -4px #0000001a)",padding:"0.5rem",display:"flex",flexDirection:"column",gap:"0.125rem"},children:[e.jsx("div",{style:{fontSize:"0.75rem",fontWeight:600,color:"var(--sa-color-gray-500, #8c8f97)",padding:"0.25rem 0.5rem 0.5rem",textTransform:"uppercase",letterSpacing:"0.05em"},children:ne.item.title}),(Ge=ne.item.children)==null?void 0:Ge.map(k=>{const Z=me(k.to),_=St(k.badge,D[k.id]);return e.jsxs("button",{onClick:()=>{E(k.to),se(null)},style:{width:"100%",display:"flex",alignItems:"center",gap:"0.75rem",padding:"0.5rem 0.75rem",borderRadius:"var(--sa-radii-md, 0.5rem)",textAlign:"left",backgroundColor:Z?"var(--sa-color-gray-100, #f8f8f8)":"transparent",color:Z?"var(--sa-text-primary, #292a2e)":"var(--sa-color-gray-800, #505258)",border:"1px solid transparent",cursor:"pointer",fontSize:"0.875rem",fontWeight:500},onMouseEnter:L=>{Z||(L.currentTarget.style.backgroundColor="var(--sa-color-gray-100, #f8f8f8)")},onMouseLeave:L=>{Z||(L.currentTarget.style.backgroundColor="transparent")},children:[k.icon&&e.jsx(B.Icon,{name:k.icon,size:"sm",style:{flexShrink:0}}),e.jsx("span",{style:{flex:1,whiteSpace:"nowrap"},children:k.title}),_&&e.jsx(qe.Badges,{text:String(_.value),variant:_.variant??"info",size:"xs",border:!0})]},k.id)})]})]})]})})}const ft=u.forwardRef(({children:t,...r},n)=>e.jsx(h.Box,{ref:n,role:"button",cursor:"pointer","aria-pressed":"true",display:"inline-block",tabIndex:0,...r,children:t})),Lr=({title:t,iconName:r,textColor:n,iconColor:i,hoverTextColor:o,hoverIconColor:s})=>{const[c,l]=u.useState(!1),d=i??"var(--sa-text-subtle, #8c8f97)",a=n??"var(--sa-text-subtle, #8c8f97)",f=s??"var(--sa-text-subtle, #8c8f97)",m=o??"var(--sa-text-primary, #292a2e)";return e.jsxs(h.Box,{direction:"row",gap:"xs",align:"center",onMouseEnter:()=>l(!0),onMouseLeave:()=>l(!1),style:{cursor:"pointer"},children:[e.jsx(B.Icon,{name:r||"ChevronLeft",size:"xs",style:{color:c?f:d,transition:"color 0.15s ease"}}),e.jsx(C.Text,{variant:"sub-h3",style:{color:c?m:a,transition:"color 0.15s ease"},children:t||"Back"})]})},no=({items:t,separator:r="/",iconName:n,iconColor:i,hoverIconColor:o})=>{const[s,c]=u.useState(!1),l=i??"var(--sa-text-subtle, #8c8f97)",d=o??"var(--sa-text-subtle, #8c8f97)",a=t.length>1?t[0]:void 0,f=!!(a!=null&&a.to||a!=null&&a.onClick),m=e.jsx(B.Icon,{name:n||"ChevronLeft",size:"xs",onMouseEnter:f?()=>c(!0):void 0,onMouseLeave:f?()=>c(!1):void 0,style:{color:f&&s?d:l,transition:"color 0.15s ease",cursor:f?"pointer":void 0}}),g=a!=null&&a.to?e.jsx(pe.Link,{to:a.to,replace:!0,style:{textDecoration:"none"},children:m}):a!=null&&a.onClick?e.jsx(ft,{onClick:a.onClick,children:m}):m;return e.jsxs(h.Box,{direction:"row",gap:"xs",align:"center",children:[g,e.jsx(nt.Breadcrumb,{separator:r,size:"md",children:t.map((j,M)=>{const y=M===t.length-1;return j.to&&!y?e.jsx(nt.BreadcrumbItem,{children:e.jsx(pe.Link,{to:j.to,children:j.label})},M):e.jsx(nt.BreadcrumbItem,{currentPage:y,children:e.jsx(nt.BreadcrumbLink,{onClick:y?void 0:j.onClick,children:j.label})},M)})})]})},oo=t=>{const{items:r,separator:n,onClick:i,navigateTo:o,...s}=t;return r&&r.length>0?e.jsx(no,{items:r,separator:n,iconName:s.iconName,iconColor:s.iconColor,hoverIconColor:s.hoverIconColor}):o?e.jsx(h.Box,{direction:"row",children:e.jsx(pe.Link,{to:o,replace:!0,style:{textDecoration:"none"},children:e.jsx(Lr,{...s})})}):e.jsx(h.Box,{direction:"row",children:e.jsx(ft,{onClick:i,children:e.jsx(Lr,{...s})})})},qt=[{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 Ir(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 Tr={fontSize:"11px",fontWeight:500,textAlign:"center",overflowWrap:"normal",wordBreak:"normal",color:"var(--sa-background-primary, #ffffff)",lineHeight:"1.3",maxWidth:"80px"},Or={display:"flex",flexDirection:"column",alignItems:"center",gap:"8px",background:"none",border:"none",cursor:"pointer",padding:0};function an({isShow:t,onHide:r,menus:n,selectedGroupId:i,onSelect:o}){const[s,c]=u.useState(void 0),l=a=>{o(a),r()},d=qt[0];return e.jsx(Re.Dialog,{isShow:t,onHide:r,style:{width:560,background:"transparent",boxShadow:"none",border:"none"},children:e.jsx(Re.DialogBody,{children:e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(5, 1fr)",gap:"16px"},children:[e.jsxs("button",{onClick:()=>l(null),onMouseEnter:()=>c("all"),onMouseLeave:()=>c(void 0),style:Or,children:[e.jsx("div",{style:Ir(i===null,s==="all",d),children:e.jsx("div",{style:{color:d.icon,display:"flex",alignItems:"center",justifyContent:"center"},children:e.jsx(B.Icon,{name:"Grid",size:"lg",style:{width:32,height:32}})})}),e.jsx("span",{style:Tr,children:"Semua"})]}),n.map((a,f)=>{var y;const m=i===a.id,g=s===a.id,j=((y=a.items[0])==null?void 0:y.icon)??"Grid",M=qt[(f+1)%qt.length];return e.jsxs("button",{onClick:()=>l(a.id),onMouseEnter:()=>c(a.id),onMouseLeave:()=>c(void 0),style:Or,children:[e.jsx("div",{style:Ir(m,g,M),children:e.jsx("div",{style:{color:M.icon,display:"flex",alignItems:"center",justifyContent:"center"},children:e.jsx(B.Icon,{name:j,size:"lg",style:{width:32,height:32}})})}),e.jsx("span",{style:Tr,children:a.name})]},a.id)})]})})})}function io({onSelect:t,"aria-label":r="Pilih module"}={}){const n=ir(),i=pe.useNavigate(),{selectedGroupId:o,setSelectedGroupId:s}=cr(),[c,l]=u.useState(!1),d=a=>{var f;if(s(a),a!==null){const m=n.menus.find(j=>j.id===a),g=(f=m==null?void 0:m.items[0])==null?void 0:f.to;g&&i(g)}t==null||t(a)};return e.jsxs(e.Fragment,{children:[e.jsxs("div",{style:{position:"relative"},children:[e.jsx("button",{onClick:()=>l(!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:a=>{a.currentTarget.style.backgroundColor="var(--sa-background-primary-inverse, #f8f8f8)"},onMouseLeave:a=>{a.currentTarget.style.backgroundColor="transparent"},children:e.jsx(B.Icon,{name:"GridApplication",size:"sm"})}),o!==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(an,{isShow:c,onHide:()=>l(!1),menus:n.menus.filter(a=>a.parentGroupId===void 0),selectedGroupId:o,onSelect:d})]})}const so=(t,r)=>{const n=[];if(r===0)return n.push(t),n;for(let i=0;i<t.length;i+=r){const o=t.slice(i,i+r);n.push(o)}return n},lo=u.memo(({value:t,label:r,separator:n,labelWidth:i,lastIndex:o,labelAlign:s="top"})=>{const c=u.useMemo(()=>({padding:0,paddingBottom:o?0:12,verticalAlign:s}),[o,s]),l=u.useMemo(()=>({padding:0,paddingRight:12,paddingLeft:12,paddingBottom:o?0:12,verticalAlign:s}),[o,s]),d=()=>typeof r=="string"?e.jsx(C.Text,{fontWeight:"medium",color:"subtlest",children:r}):r,a=()=>typeof t=="string"||typeof t=="number"?e.jsx(C.Text,{color:"primary",fontWeight:"medium",children:t}):t,f=()=>typeof n=="string"||typeof n=="number"?e.jsx(C.Text,{fontWeight:"medium",color:"subtlest",children:n}):n;return e.jsxs(U.Tr,{children:[e.jsx(U.Td,{style:c,width:i,children:d()}),n?e.jsx(U.Td,{style:l,width:24,children:f()}):null,e.jsx(U.Td,{style:c,children:a()})]})}),co=u.memo(({fields:t,separator:r,labelWidth:n})=>e.jsx(U.Table,{withColumnBorder:!1,withRowBorder:!1,children:t.map((i,o)=>e.jsx(lo,{separator:r,labelWidth:n,lastIndex:o===t.length-1,...i},`field-group-field-${o}`))})),ao=u.memo(({maxRow:t=0,maxColumn:r=2,separator:n=":",fields:i=[],labelWidth:o=150,bordered:s=!1})=>{const c=u.useMemo(()=>so(i,t),[i,t]),l=c.length>2,d=()=>{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(h.Box,{gap:l?void 0:"lg",direction:"row",flexWrap:"wrap",borderRadius:"rounded-sm",padding:"lg",paddingBottom:l?"xs":"lg",bg:"accent-dark-tertiary",borderWidth:s?"border":void 0,borderStyle:s?"border-solid":void 0,borderColor:s?"border-subtle":void 0,children:c.map((a,f)=>e.jsx(h.Box,{direction:"column",flex:l?void 0:"1",width:l?d():void 0,marginBottom:l?"lg":void 0,children:e.jsx(co,{labelWidth:o,fields:a,separator:n})},f))})}),uo=({backButton:t})=>{const[r,n]=u.useState(!1),i=(t==null?void 0:t.iconColor)??"var(--sa-text-subtle, #8c8f97)",o=(t==null?void 0:t.textColor)??"var(--sa-text-subtle, #8c8f97)",s=(t==null?void 0:t.hoverIconColor)??"var(--sa-text-subtle, #8c8f97)",c=(t==null?void 0:t.hoverTextColor)??"var(--sa-text-primary, #292a2e)";return e.jsxs(h.Box,{direction:"row",gap:"xs",align:"center",onMouseEnter:()=>n(!0),onMouseLeave:()=>n(!1),style:{cursor:"pointer"},children:[e.jsx(B.Icon,{name:(t==null?void 0:t.iconName)||"ChevronLeft",size:"xs",style:{color:r?s:i,transition:"color 0.15s ease"}}),e.jsx(C.Text,{variant:"sub-h3",style:{color:r?c:o,textDecoration:r?"underline":"none",transition:"color 0.15s ease"},children:(t==null?void 0:t.title)||"Back"})]})},xo=({backButton:t,title:r,titleIcon:n,titleTag:i,children:o,header:s=!0,headerBorder:c=!1,subHeaders:l,action:d,titleTagProps:a,containerProps:f,headerProps:m})=>{const g=he.useMediaQuery("md"),j=pe.useNavigate(),M=pe.useLocation(),y=t==null?void 0:t.show,D=()=>{if(typeof(t==null?void 0:t.onClick)=="function"){t.onClick();return}j(-1,{replace:!0})},E=()=>{if(!d)return null;if(u.isValidElement(d))return d;const b=d.filter(S=>S&&(S.title||S.icon));return b.length===0?null:g?e.jsx(h.Box,{direction:"row",gap:"md",children:b.map(({title:S,icon:P,buttonProps:A,onClick:N},G)=>e.jsx(V.Button,{iconLeft:P?e.jsx(B.Icon,{name:P,size:"md"}):void 0,onClick:N,...A,children:S},`action-${G}`))}):e.jsxs(I.Menu,{position:"bottom-right",children:[e.jsx(I.MenuButton,{children:e.jsx(V.Button,{variant:"tertiary",size:"sm",iconLeft:e.jsx(B.Icon,{name:"MenuBurger"}),"aria-label":"Actions"})}),e.jsx(I.MenuLists,{children:e.jsx(I.MenuBody,{style:{minWidth:200},children:b.map(({title:S,icon:P,buttonProps:A,onClick:N},G)=>{const re=(A==null?void 0:A.tone)==="error"||(A==null?void 0:A.danger)===!0;return e.jsx(I.MenuItem,{intent:re?"danger":void 0,disabled:A==null?void 0:A.disabled,startIcon:P?e.jsx(B.Icon,{name:P}):void 0,onClick:N,children:S},`action-${G}`)})})})]})},T=()=>{const b=e.jsx(uo,{backButton:t});return t!=null&&t.navigateTo?e.jsx(h.Box,{direction:"row",children:e.jsx(pe.Link,{to:t.navigateTo,replace:!0,style:{textDecoration:"none"},children:b})}):e.jsx(h.Box,{direction:"row",children:e.jsx(ft,{onClick:D,children:b})})},w=()=>{const b=!!r,S=Array.isArray(d)&&d.length>0,P=u.isValidElement(d)?!0:S;if(!b&&!P&&!y)return null;const N=g||!g&&S;return e.jsxs(h.Box,{direction:"column",gap:"xs",paddingBlock:(m==null?void 0:m.paddingBlock)??"sm",paddingInline:(m==null?void 0:m.paddingInline)??"md",...m,style:{...c?{boxShadow:"inset 0 -1px 0 0 var(--sa-border-subtle, #0b120e24)"}:{},...m==null?void 0:m.style},children:[y&&T(),(b||P)&&e.jsxs(h.Box,{direction:N?"row":"column",gap:"sm",justify:"space-between",align:N?"center":"flex-start",children:[b?typeof r=="string"?e.jsxs(h.Box,{direction:"row",gap:"lg",align:"center",children:[e.jsxs(h.Box,{direction:"row",gap:"sm",align:"center",children:[n&&e.jsx(B.Icon,{name:n,size:"md",color:"primary"}),e.jsx(C.Text,{variant:"h3",fontWeight:"semibold",fontFamily:"Poppins",children:r})]}),i&&e.jsx(qe.Badge,{border:!0,size:"lg",text:i,...a})]}):r:null,E()]})]})},v=()=>{if(!l||l.length===0)return null;const b=l.filter(A=>A.show!==!1);if(b.length===0)return null;let S=0,P=-1/0;return b.forEach((A,N)=>{const G=A.order??0;G>=P&&(P=G,S=N)}),b.map(({content:A,order:N,borderBottom:G=!0},re)=>e.jsx(h.Box,{direction:"column",paddingTop:"sm",paddingBottom:G||re===S?"sm":"spacing-0",paddingInline:"md",style:{...G?{boxShadow:"inset 0 -1px 0 0 var(--sa-border-subtle, #0b120e24)"}:{},...N!==void 0?{order:N}:{}},children:A},`sub-header-${re}`))},R=()=>{const b=s?w():null,S=v();return!b&&!S?null:e.jsxs(h.Box,{direction:"column",style:{marginBottom:S?"var(--sa-spacing-0)":"var(--sa-spacing-md)"},children:[b,S]})},O=()=>o;return e.jsxs(h.Box,{direction:"column",as:"main",...f,style:{...(f==null?void 0:f.style)??{},animation:"pageLayoutEnter 320ms cubic-bezier(0.16, 1, 0.3, 1) backwards"},children:[R(),O()]},M.pathname)},ho=u.memo(xo),fo={icon:"Cross",title:""},mo="calc(100vw - 16px)",Wr=t=>t==null?void 0:`min(${typeof t=="number"?`${t}px`:t}, ${mo})`,dn=u.forwardRef(({onHide:t,show:r,withBlur:n=!1,style:i,children:o,closeButton:s=fo,width:c,minWidth:l="357px",maxWidth:d="357px"},a)=>{const f=Wr(c??l),m=Wr(c??d);return e.jsx(Ft.Drawer,{blur:n,isShow:r,position:"right",onHide:t,ref:a,style:{minWidth:f,maxWidth:m,...i},children:e.jsxs(h.Box,{direction:"column",padding:"lg",children:[s?e.jsxs(h.Box,{direction:"row",align:"center",gap:"sm",onClick:t,marginBottom:"lg",cursor:"pointer",children:[e.jsx(B.Icon,{name:s.icon,size:"md",color:"subtle",cursor:"pointer"}),s.title?e.jsx(C.Text,{fontFamily:"Poppins",fontSize:"md",color:"subtlest",children:s.title}):null]}):null,o]})})}),ar=u.memo(({children:t,borderBottom:r=!0,padding:n=!0})=>{const i=he.useMediaQuery("lg");return e.jsx(h.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})}),dr=u.memo(({children:t,borderTop:r=!0,padding:n=!0})=>{const i=he.useMediaQuery("lg");return e.jsx(h.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})}),go=u.memo(({children:t,...r})=>e.jsx(h.Box,{direction:"column",padding:"md",paddingLeft:"md",paddingRight:"md",gap:"md",...r,children:t})),yo=u.memo(({children:t,title:r,titleTag:n,action:i,header:o,footer:s,actionContainer:c,containerProps:l,bodyProps:d,headerProps:a={borderBottom:!0},footerProps:f={borderTop:!0},variantTag:m="info"})=>{const g=he.useMediaQuery("lg"),j=()=>n?e.jsxs(h.Box,{direction:"row",gap:"sm",align:"center",children:[e.jsx(C.Text,{fontWeight:"medium",children:r}),e.jsx(qe.Badges,{border:!0,text:n,variant:m})]}):e.jsx(C.Text,{fontWeight:"medium",children:r}),M=()=>o||e.jsxs(h.Box,{direction:"row",justify:"space-between",align:"flex-start",gap:"md",children:[e.jsx(h.Box,{direction:"column",children:r?j():null}),e.jsx(h.Box,{direction:"column",style:g?{width:"100%",maxWidth:"19.313rem"}:{flex:1},...c,children:i??null})]}),y=!!(o||r||i);return e.jsxs(h.Box,{direction:"column",bg:"white",borderRadius:"rounded-xs",as:"section",borderWidth:"border",borderStyle:"border-solid",borderColor:"border-base",...l,style:{backgroundColor:"var(--sa-background-primary, #ffffff)",...(l==null?void 0:l.style)??{}},children:[o!==null&&y?e.jsx(ar,{...a,children:M()}):null,e.jsx(go,{...d,children:t}),s?e.jsx(dr,{...f,children:s}):null]})}),po=t=>e.jsx(C.Text,{variant:"h1",children:t.children,...t.props}),jo=t=>e.jsx(C.Text,{variant:"h2",children:t.children,...t.props}),bo=t=>e.jsx(C.Text,{variant:"h3",children:t.children,...t.props}),vo=t=>e.jsx(C.Text,{variant:"h4",children:t.children,...t.props}),Co=t=>e.jsx(C.Text,{variant:"h5",children:t.children,...t.props}),wo=t=>e.jsx(C.Text,{variant:"h6",children:t.children,...t.props}),Do=t=>e.jsx(C.Text,{variant:"sub-h1",children:t.children,...t.props}),So=t=>e.jsx(C.Text,{variant:"sub-h2",children:t.children,...t.props}),ko=t=>e.jsx(C.Text,{variant:"sub-h3",children:t.children,...t.props}),Bo=t=>e.jsx(C.Text,{variant:"body-1",children:t.children,...t.props}),Fo=t=>e.jsx(C.Text,{variant:"body-2",children:t.children,...t.props}),Eo=t=>e.jsx(C.Text,{variant:"body-3",children:t.children,...t.props}),Ae={H1:po,H2:jo,H3:bo,H4:vo,H5:Co,H6:wo,SubH1:Do,SubH2:So,SubH3:ko,Body1:Bo,Body2:Fo,Body3:Eo},Be=()=>{const[t,r]=pe.useSearchParams(),n=st.searchParamsToObject(t.toString()),i=pe.useParams(),o=pe.useLocation(),s=i.id;return{setSearchParams:r,searchParams:t,searchQueries:n,isHasQuery:(f,m)=>t.has(f)&&t.get(f)===m,getQueryParam:f=>t.get(f),getRouteParam:f=>i[f],params:i,location:o,id:s,hasId:!!s}},un=t=>JSON.stringify(t),xn=t=>JSON.stringify(t),hn=t=>JSON.stringify(t),fn=t=>JSON.stringify(t),Mo=t=>t,Lo=t=>JSON.stringify(t),ht=({value:t,name:r,type:n,withSearchParam:i=!0,setSearchParams:o,searchQueries:s,dropdownSearchKey:c,filterKey:l="filter",pageKey:d="page"})=>{if(i){let a;switch(n){case"search":a=Mo(t);break;case"dropdown":case"dropdown-multiple":a=un(t);break;case"radio":a=xn(t);break;case"date-range":a=hn(t);break;case"advanced-date-range":a=Lo(t);break;case"date":a=fn(t);break;default:a=t;break}if(typeof a<"u"){const m={...s[l]&&typeof s[l]=="string"?JSON.parse(s[l]):void 0,[r]:a},g={...s};c&&typeof c=="string"&&delete g[c],delete g[d];const j={...g,[l]:JSON.stringify(m)},M=new URLSearchParams(s).toString(),y=new URLSearchParams(j).toString();if(M===y)return;o(j)}}},kt=({name:t,filterKey:r="filter",searchParams:n,get:i})=>{const o=n.get(r)||void 0,s=o&&typeof o=="string"?JSON.parse(o):void 0,c=s?s[t]:void 0;return i==="label"&&c?JSON.parse(c)[0].label:i==="value"&&c?JSON.parse(c)[0].value:c},mn=({name:t,filterKey:r="filter",searchParams:n,get:i})=>{const o=n.get(r)||void 0,s=o&&typeof o=="string"?JSON.parse(o):void 0,c=s?s[t]:void 0;return i==="label"&&c?JSON.parse(c).map(l=>l.label):i==="value"&&c?JSON.parse(c).map(l=>l.value):i==="array"&&c?JSON.parse(c):c},Io=({name:t,filterKey:r="filter",searchParams:n,get:i})=>{const o=n.get(r)||void 0,s=o&&typeof o=="string"?JSON.parse(o):void 0,c=s?s[t]:void 0;return i==="id"&&c?JSON.parse(c).id:i==="label"&&c?JSON.parse(c).label:i==="value"&&c?JSON.parse(c).value:c},Lt=(t,r,n)=>{const i=r.get(n||"filter")||void 0,o=i&&typeof i=="string"?JSON.parse(i):void 0;return o?o[t]:void 0},To=({name:t,filterKey:r="filter",searchParams:n})=>{const i=n.get(r||"filter")||void 0,o=i&&typeof i=="string"?JSON.parse(i):void 0,s=o?o[t]:void 0;return{start:s?JSON.parse(s).from:void 0,end:s?JSON.parse(s).to:void 0}},gn=({name:t,filterKey:r="filter",searchParams:n})=>{const i=n.get(r||"filter")||void 0,o=i&&typeof i=="string"?JSON.parse(i):void 0,s=o?o[t]:void 0;return s?JSON.parse(s):void 0},Oo=(t,{filterKey:r="filter",perPageKey:n="perPage",pageKey:i="page"})=>{const o=t.get(r)||void 0,s=t.get(n)||void 0,c=t.get(i)||void 0;return!!o||!!s||!!c},yn=({isOpen:t,onClose:r,filterKey:n,pageKey:i,filters:o})=>{const{searchParams:s,setSearchParams:c,searchQueries:l}=Be(),[d,a]=u.useState({}),f=()=>{s.delete(n||"filter"),c(s)},m=(g,j)=>{switch(g.type){case"radio":{const{show:M=!0}=g;return M&&e.jsx(h.Box,{direction:"column",children:e.jsx(h.Box,{direction:"column",children:g.title})},j)}case"dropdown":{const{show:M=!0}=g;return M&&e.jsx(h.Box,{direction:"column",children:e.jsx(h.Box,{direction:"column",children:g.title})},j)}case"date-range":return e.jsx(h.Box,{direction:"column",children:e.jsx(h.Box,{direction:"column",children:g.title})},j);case"date":return e.jsx(h.Box,{direction:"column",children:e.jsx(h.Box,{direction:"column",children:g.title})},j);case"dropdown-multiple":{const{show:M=!0}=g;return M&&e.jsx(h.Box,{direction:"column",children:e.jsx(h.Box,{direction:"column",children:g.title})},j)}default:return null}};return e.jsx(dn,{onHide:r,show:t||!1,children:e.jsxs(h.Box,{direction:"column",gap:"md",children:[e.jsxs(oe.Flex,{direction:"row",justify:"space-between",align:"center",children:[e.jsx(h.Box,{direction:"column",children:"Filter"}),e.jsx(h.Box,{direction:"column",style:{cursor:"pointer"},onClick:f,children:"Reset"})]}),o==null?void 0:o.map((g,j)=>m(g,j))]})})},pn=({searchKey:t="q",statusKey:r="status",searchPlaceholder:n="Search",searchHighlightPlaceholder:i,extendedFilter:o,showSearchFilter:s=!0,showStatusFilter:c=!0,filterKey:l="filter",pageKey:d="page",customWidthSearch:a,handleOnReset:f,filterConfigs:m,buttonToggleProps:g,position:j="right",titleSearchLabel:M="Work Order",withTitleLabels:y=!1})=>{const E=(g==null?void 0:g.isShowLabel)??!0,[T,w]=u.useState(!1),[v,R]=u.useState(0),O=()=>{R(Q=>Q+1)},{searchParams:b,setSearchParams:S,getQueryParam:P}=Be(),A=st.searchParamsToObject(b.toString()),N=Lt(t,b,l)||"",[G,re]=u.useState(N),xe=P(l),se=!!(xe&&!(()=>{if(xe)try{const Q=JSON.parse(xe);return Object.keys(Q).length===1&&Q[t]===""}catch(Q){console.error("Filter parameter is not a valid JSON:",Q)}return!1})()),J=he.useMediaQuery("md");return u.useEffect(()=>{re(N)},[N]),u.useEffect(()=>{if(G===N)return;const Q=window.setTimeout(()=>{ht({value:G,name:t,type:"search",searchQueries:A,setSearchParams:S,filterKey:l,pageKey:d})},350);return()=>{window.clearTimeout(Q)}},[G,N,t,A,S,l,d]),e.jsxs(oe.Flex,{gap:"md",style:{flexDirection:J&&j==="left"?"row":J&&j==="right"?"row-reverse":"column"},align:"flex-end",children:[se&&e.jsx(h.Box,{direction:"column",justify:"flex-end",children:e.jsx(V.Button,{onClick:()=>{const Q=new URLSearchParams(b);Q.delete(l),S(Q),re(""),O(),f&&f()},variant:"outline",tone:"neutral",children:e.jsx(C.Text,{color:"error",fontWeight:"semibold",children:"Reset"})})}),o==null?void 0:o.map(({minWidth:Q,content:ae,title:ee,onClickContainer:ce},we)=>e.jsxs(h.Box,{direction:"column",gap:"sm",onClick:ce,style:{minWidth:Q},children:[ee&&e.jsx(Ae.SubH3,{children:ee}),ae]},`extended-filter-${we}-${v}`)),!!(m!=null&&m.length)&&e.jsx(V.Button,{primary:se,secondary:!se,iconLeft:e.jsx(B.Icon,{size:"sm",name:(g==null?void 0:g.icon)||"FilterHorizontal",style:{color:xe?"var(--sa-background-brand, #04254f)":"var(--sa-text-primary, #292a2e)"}}),fullWidth:!J,onClick:()=>w(!0),children:E?"Filter":void 0}),c&&e.jsxs(h.Box,{direction:"column",gap:"sm",style:{minWidth:"126px"},children:[y&&e.jsx(Ae.SubH3,{children:"Status"}),e.jsx(it.Dropdown,{dropdownLists:[{label:"Active",value:"active"},{label:"InActive",value:"inactive"}],defaultValue:kt({get:"value",name:r,searchParams:b,filterKey:l})?[{label:kt({get:"value",name:r,searchParams:b,filterKey:l})==="active"?"Active":"InActive",value:kt({get:"value",name:r,searchParams:b,filterKey:l})}]:[],onChange:Q=>ht({value:Q,name:r,type:"dropdown",searchQueries:A,setSearchParams:S,filterKey:l}),placeholder:y?"All":"All Status"},v)]}),s&&e.jsxs(h.Box,{direction:"column",gap:"sm",style:{width:a&&J?a:J?"310px":""},children:[y&&e.jsxs(Ae.SubH3,{children:["Search for ",M]}),e.jsx(Ze.Input,{placeholder:n,leftIcon:e.jsx(B.Icon,{name:"Search",width:20,height:20}),onChange:Q=>re(Q.target.value),value:G,fullWidth:!0},v+1+l)]}),e.jsx(yn,{isOpen:T,onClose:()=>w(!1),filterKey:l,filters:m,pageKey:d})]})},Wo=t=>t==="checkbox-multiple"?"dropdown-multiple":t==="radio"?"dropdown":t==="date-compact"?"date":t;function ur({configs:t,filterKey:r="filter",activeFilterKey:n="filters",pageKey:i="page",searchKey:o="q"}){const{searchParams:s,setSearchParams:c,searchQueries:l}=Be(),d=u.useMemo(()=>Object.fromEntries(t.map(v=>[v.key,v])),[t]),a=u.useMemo(()=>{const v=(s.get(n)||"").split(",").map(O=>O.trim()).filter(Boolean);let R=[];try{const O=s.get(r);O&&(R=Object.keys(JSON.parse(O)).filter(b=>b!==o))}catch{}return t.map(O=>O.key).filter(O=>{const b=d[O];return(b==null?void 0:b.locked)||v.includes(O)||R.includes(O)})},[s,n,r,o,t,d]),f=u.useCallback(v=>{try{return v[r]?JSON.parse(v[r]):{}}catch{return{}}},[r]),m=u.useCallback(v=>{const R={...l};v.length?R[n]=v.join(","):delete R[n],c(R)},[l,n,c]),g=u.useCallback(v=>{a.includes(v)||m([...a,v])},[a,m]),j=u.useCallback(v=>{var S;if((S=d[v])!=null&&S.locked)return;const R={...l},O=a.filter(P=>P!==v);O.length?R[n]=O.join(","):delete R[n];const b=f(R);v in b&&(delete b[v],Object.keys(b).length?R[r]=JSON.stringify(b):delete R[r]),delete R[i],c(R)},[l,a,n,r,i,f,c,d]),M=u.useCallback(v=>a.includes(v)?j(v):g(v),[a,g,j]),y=u.useCallback(v=>{switch(v.type){case"dropdown":case"dropdown-multiple":case"checkbox-multiple":case"radio":return mn({name:v.key,get:"array",searchParams:s,filterKey:r})||[];case"date":{const R=gn({name:v.key,searchParams:s,filterKey:r});return R?new Date(R):void 0}case"date-compact":{const O=f(Object.fromEntries(s.entries()))[v.key];return O&&typeof O=="object"?O:void 0}default:return}},[s,r,f]),D=u.useCallback((v,R)=>{if(v.type==="date-compact"){const O={...l},b=f(O);R==null?delete b[v.key]:b[v.key]=R,Object.keys(b).length?O[r]=JSON.stringify(b):delete O[r],delete O[i],c(O);return}ht({value:R,name:v.key,type:Wo(v.type),searchQueries:l,setSearchParams:c,filterKey:r,pageKey:i})},[l,c,r,i,f]),E=u.useCallback(v=>{const R={...l},O=f(R);v in O&&(delete O[v],Object.keys(O).length?R[r]=JSON.stringify(O):delete R[r]),delete R[i],c(R)},[l,r,i,f,c]),T=u.useCallback(()=>{const v={...l};delete v[r],delete v[n],delete v[i],c(v)},[l,r,n,i,c]),w=a.length>0;return{activeKeys:a,configByKey:d,hasActiveFilter:w,addFilter:g,removeFilter:j,toggleFilter:M,getValue:y,setValue:D,clearValue:E,clearAll:T}}const xr={get(t){return ut.storage.get(t)??null},set(t,r){ut.storage.save(t,r)},remove(t){ut.storage.delete(t)}},at={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}`},jt=(t,r)=>{const n=new Set(r.map(s=>s.key)),i=t.order.filter(s=>n.has(s));for(const s of r)i.includes(s.key)||i.push(s.key);const o=t.hidden.filter(s=>n.has(s));return{order:i,hidden:o}};function Ro({columns:t,scopeId:r,storage:n,onColumnsChange:i,value:o}){const s=u.useMemo(()=>({order:t.map(b=>b.key),hidden:[]}),[t]),c=r?at.columns(r):void 0,l=(b,S)=>jt({order:b.order??S,hidden:b.hidden??[]},t),[d,a]=u.useState(()=>{if(o&&(o.order||o.hidden))return l(o,t.map(b=>b.key));if(c){const b=n.get(c);if(b&&Array.isArray(b.order))return jt(b,t)}return s}),f=t.map(b=>b.key).join("|");u.useEffect(()=>a(b=>jt(b,t)),[f]);const m=u.useRef(d);m.current=d;const g=o?`${(o.order??[]).join("|")}~${(o.hidden??[]).join("|")}`:null,j=u.useRef(g);u.useEffect(()=>{if(g==null||j.current===g)return;j.current=g;const b=m.current,S=l(o,b.order);S.order.join("|")===b.order.join("|")&&S.hidden.join("|")===b.hidden.join("|")||(a(S),c&&n.set(c,S))},[g,f]);const M=u.useRef(!1);u.useEffect(()=>{M.current||(M.current=!0,i==null||i(d))},[]);const y=u.useCallback(b=>{a(b),c&&n.set(c,b),i==null||i(b)},[c,n,i]),D=u.useMemo(()=>{const b=new Map(t.map(S=>[S.key,S]));return d.order.filter(S=>b.has(S)).map(S=>({...b.get(S),visible:!d.hidden.includes(S)}))},[d,t]),E=u.useCallback(b=>{const S=d.hidden.includes(b)?d.hidden.filter(P=>P!==b):[...d.hidden,b];y({...d,hidden:S})},[d,y]),T=u.useCallback((b,S)=>{if(b===S)return;const P=[...d.order],[A]=P.splice(b,1);P.splice(S,0,A),y({...d,order:P})},[d,y]),w=u.useCallback(b=>{y({...d,hidden:b?t.filter(S=>!S.locked).map(S=>S.key):[]})},[d,t,y]),v=u.useCallback(()=>y(s),[y,s]),R=u.useCallback(b=>y(jt(b,t)),[y,t]),O=d.hidden.length===0;return{state:d,orderedColumns:D,allVisible:O,toggleVisibility:E,reorder:T,setAllHidden:w,reset:v,applyState:R}}function Ao({scopeId:t,storage:r,snapshotKeys:n,pageKey:i="page",getColumns:o,applyColumns:s}){const{searchParams:c,setSearchParams:l}=Be(),d=t?at.savedViews(t):void 0,[a,f]=u.useState(()=>d?r.get(d)||[]:[]),m=u.useCallback(y=>{f(y),d&&r.set(d,y)},[d]),g=u.useCallback(y=>{const D=y.trim();if(!D)return;const E={};n.forEach(w=>{const v=c.get(w);v!=null&&(E[w]=v)});const T={id:`${Date.now()}`,name:D,query:E,columns:o==null?void 0:o(),createdAt:Date.now()};m([...a,T])},[n,c,o,m,a]),j=u.useCallback(y=>m(a.filter(D=>D.id!==y)),[m,a]),M=u.useCallback(y=>{const D=Object.fromEntries(c.entries());n.forEach(E=>delete D[E]),Object.assign(D,y.query),delete D[i],l(D),y.columns&&(s==null||s(y.columns))},[c,n,i,l,s]);return{enabled:!!d,views:a,saveView:g,deleteView:j,applyView:M}}function zo({scopeId:t,storage:r,snapshotKeys:n,enabled:i=!0}){const{searchParams:o}=Be(),s=t&&i?at.lastState(t):void 0,c=u.useRef(s);u.useEffect(()=>{if(!s){c.current=s;return}if(c.current!==s){c.current=s;return}const a={};n.forEach(f=>{const m=o.get(f);m!=null&&(a[f]=m)}),Object.keys(a).length!==0&&r.set(s,a)},[o,s,n,r]);const l=u.useCallback(()=>{if(!s)return null;const a=r.get(s);return a&&Object.keys(a).length>0?a:null},[s,r]),d=u.useCallback(()=>{s&&r.remove(s)},[s,r]);return{enabled:!!s,read:l,clear:d}}function Vo({scopeId:t,storage:r,perPageKey:n,pageSizeOptions:i,enabled:o=!0}){const{searchParams:s}=Be(),c=t&&o?at.perPage(t):void 0,l=s.toString(),d=u.useRef(c);u.useEffect(()=>{if(!c){d.current=c;return}if(d.current!==c){d.current=c;return}const m=s.get(n);if(!m)return;const g=Number(m);!Number.isFinite(g)||g<=0||r.set(c,g)},[l,c,n,r]);const a=u.useCallback(()=>{if(!c)return null;const m=r.get(c);if(m==null)return null;const g=Number(m);return!Number.isFinite(g)||g<=0||i&&!i.includes(g)?null:String(g)},[c,r,i]),f=u.useCallback(()=>{c&&r.remove(c)},[c,r]);return{enabled:!!c,read:a,clear:f}}let Zt={},Gt=!1,Qt=null;const Ho=(t,r)=>{Object.assign(Zt,t),Qt=r,!Gt&&(Gt=!0,queueMicrotask(()=>{const n=Zt,i=Qt;Zt={},Gt=!1,Qt=null,!(!i||Object.keys(n).length===0)&&i(o=>{const s=new URLSearchParams(o);return Object.entries(n).forEach(([c,l])=>s.set(c,l)),s})}))};function Po({enabled:t,snapshotKeys:r,perPageKey:n,readSnapshot:i,readPerPage:o}){const{searchParams:s,setSearchParams:c,location:l}=Be(),d=u.useRef(null);u.useEffect(()=>{if(!t||d.current===l.pathname)return;d.current=l.pathname;const a={};if(!s.has(n)){const f=o();f&&(a[n]=f)}if(!r.some(f=>s.has(f))){const f=i();f&&Object.assign(a,f)}Object.keys(a).length!==0&&Ho(a,c)},[l.pathname,t])}const No=({configs:t,activeKeys:r,onToggle:n,hasActiveFilter:i,onReset:o})=>t.length?e.jsxs(I.Menu,{position:"bottom-left",children:[e.jsx(I.MenuButton,{children:e.jsx(V.Button,{variant:i?"secondary":"outline",tone:"neutral",size:"sm",iconLeft:e.jsx(B.Icon,{name:"FilterHorizontal"}),"aria-label":"Add filter"})}),e.jsx(I.MenuLists,{children:e.jsx(I.MenuBody,{style:{minWidth:260},title:e.jsxs(h.Box,{display:"flex",direction:"row",align:"center",justify:"space-between",fullWidth:!0,children:[e.jsx(C.Text,{fontSize:"sm",fontWeight:"medium",color:"subtlest",children:"Add Filter"}),i&&o&&e.jsx(V.Button,{variant:"link",tone:"brand",size:"xs",onClick:o,children:"Reset"})]}),children:t.map(s=>e.jsx(I.MenuItem,{selected:s.locked||r.includes(s.key),disabled:s.locked,closeOnSelect:!1,startIcon:s.icon??void 0,onClick:()=>{s.locked||n(s.key)},children:s.label},s.key))})})]}):null,It=({onClear:t,onRemove:r})=>e.jsxs(I.Menu,{position:"bottom-right",children:[e.jsx(I.MenuButton,{children:e.jsx(V.Button,{variant:"link",tone:"neutral",size:"xs",iconLeft:e.jsx(B.Icon,{name:"MenuHorizontal"}),"aria-label":"Filter actions"})}),e.jsx(I.MenuLists,{children:e.jsxs(I.MenuBody,{style:{width:180},children:[e.jsx(I.MenuItem,{startIcon:e.jsx(B.Icon,{name:"CrossCircle"}),onClick:t,children:"Clear value"}),r&&e.jsx(I.MenuItem,{intent:"danger",startIcon:e.jsx(B.Icon,{name:"Trash1"}),onClick:r,children:"Remove filter"})]})})]}),_o=t=>{const r=new Date(t);return r.setHours(0,0,0,0),r},Rr=(t,r,n)=>{const i=new Date(t);return n==="day"?i.setDate(i.getDate()+r):n==="week"?i.setDate(i.getDate()+r*7):n==="month"?i.setMonth(i.getMonth()+r):i.setFullYear(i.getFullYear()+r),i},jn=t=>{const r=_o(new Date);if(t.direction==="this"){const i=new Date(r),o=new Date(r);return t.period==="week"?(i.setDate(r.getDate()-r.getDay()),o.setDate(i.getDate()+6)):t.period==="month"?(i.setDate(1),o.setMonth(o.getMonth()+1,0)):t.period==="year"&&(i.setMonth(0,1),o.setMonth(11,31)),{from:i,to:o}}const n=t.count??1;return t.direction==="past"?{from:Rr(r,-n,t.period),to:r}:{from:r,to:Rr(r,n,t.period)}},Ar=24,bn=t=>t.length>Ar?`${t.slice(0,Ar)}...`:t,Bt=t=>t.toLocaleDateString(void 0,{day:"2-digit",month:"short",year:"numeric"}),Mt={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"},qo=["is","is-before","is-after","is-on-or-before","is-on-or-after","is-between","is-relative-to-today","is-empty","is-not-empty"],rr={past:"Past",next:"Next",this:"This"},Zo=["day","week","month","year"],Go=["past","next","this"],Qo=t=>t.field.type==="date-compact"?e.jsx(Yo,{field:t.field,value:t.value,onChange:t.onChange,onClear:t.onClear,onRemove:t.onRemove}):e.jsx(Uo,{field:t.field,value:t.value,onChange:t.onChange,onClear:t.onClear,onRemove:t.onRemove}),Uo=({field:t,value:r,onChange:n,onClear:i,onRemove:o})=>{const s=r?Bt(new Date(r)):null,c=!!s,l=c?e.jsxs(e.Fragment,{children:[e.jsxs("span",{style:{fontWeight:500},children:[t.label,":"]})," ",e.jsx("span",{style:{fontWeight:400},children:bn(s)})]}):t.label;return e.jsxs(I.Menu,{position:"bottom-left",children:[e.jsx(I.MenuButton,{children:e.jsx(V.Button,{variant:c?"secondary":"outline",tone:"neutral",size:"sm",iconLeft:c?e.jsx(B.Icon,{name:"Calendar",size:"sm"}):void 0,iconRight:e.jsx(B.Icon,{name:"ChevronSmallDown"}),children:l})}),e.jsx(I.MenuLists,{children:e.jsx(I.MenuBody,{style:{width:260},title:e.jsxs(h.Box,{display:"flex",direction:"row",align:"center",justify:"space-between",fullWidth:!0,children:[e.jsx(C.Text,{fontSize:"sm",fontWeight:"medium",color:"subtlest",children:t.label}),e.jsx(It,{onClear:i,onRemove:o})]}),children:e.jsx(Ke.StarasiaDate,{size:"sm",input:!1,clearable:!0,filter:t.mode,value:r,onChange:d=>d==null?i():n(d),withPadding:!1})})})]})},Jo=t=>{switch(t.op){case"is":case"is-before":case"is-after":case"is-on-or-before":case"is-on-or-after":return t.date?`${Mt[t.op]} ${Bt(new Date(t.date))}`:null;case"is-between":return t.from&&t.to?`${Bt(new Date(t.from))} - ${Bt(new Date(t.to))}`:null;case"is-relative-to-today":{const r=t.relative;if(!r)return null;if(r.direction==="this")return`This ${r.period}`;const n=r.count??1,i=n===1?r.period:`${r.period}s`;return`${rr[r.direction]} ${n} ${i}`}case"is-empty":case"is-not-empty":return Mt[t.op];default:return null}},Yo=({field:t,value:r,onChange:n,onClear:i,onRemove:o})=>{const s=(r==null?void 0:r.op)??"is",c=r?Jo(r):null,l=!!c,d=l?e.jsxs(e.Fragment,{children:[e.jsxs("span",{style:{fontWeight:500},children:[t.label,":"]})," ",e.jsx("span",{style:{fontWeight:400},children:bn(c)})]}):t.label,a=f=>{if(f!==s){if(f==="is-empty"||f==="is-not-empty"){n({op:f});return}if(f==="is-relative-to-today"){n({op:f,relative:(r==null?void 0:r.relative)??{direction:"past",count:1,period:"week"}});return}if(f==="is-between"){n({op:f,from:r==null?void 0:r.from,to:r==null?void 0:r.to});return}n({op:f,date:r==null?void 0:r.date})}};return e.jsxs(I.Menu,{position:"bottom-left",children:[e.jsx(I.MenuButton,{children:e.jsx(V.Button,{variant:l?"secondary":"outline",tone:"neutral",size:"sm",iconLeft:l?e.jsx(B.Icon,{name:"Calendar",size:"sm"}):void 0,iconRight:e.jsx(B.Icon,{name:"ChevronSmallDown"}),children:d})}),e.jsxs(I.MenuLists,{children:[e.jsx(I.MenuBody,{style:{width:320},title:e.jsxs(h.Box,{display:"flex",direction:"row",align:"center",justify:"space-between",gap:"xs",fullWidth:!0,children:[e.jsxs(h.Box,{display:"flex",direction:"row",align:"center",gap:"xs",style:{minWidth:0},children:[e.jsx(C.Text,{fontSize:"sm",fontWeight:"medium",color:"subtlest",children:t.label}),e.jsx(Xo,{op:s,onChange:a})]}),e.jsx(It,{onClear:i,onRemove:o})]}),children:e.jsx(Ko,{value:r,op:s,onChange:n})}),s==="is-relative-to-today"&&e.jsx(I.MenuFooter,{children:e.jsx(C.Text,{fontSize:"xs",color:"subtlest",children:"Filter will update with the current date"})})]})]})},Xo=({op:t,onChange:r})=>e.jsxs(I.Menu,{position:"bottom-left",children:[e.jsx(I.MenuButton,{children:e.jsx(V.Button,{variant:"link",tone:"neutral",size:"xs",iconRight:e.jsx(B.Icon,{name:"ChevronSmallDown"}),children:Mt[t]})}),e.jsx(I.MenuLists,{children:e.jsx(I.MenuBody,{style:{width:200},children:qo.map(n=>e.jsx(I.MenuItem,{selected:t===n,onClick:()=>r(n),endIcon:t===n?e.jsx(B.Icon,{name:"Check"}):void 0,children:Mt[n]},n))})})]}),Ko=({value:t,op:r,onChange:n})=>{if(r==="is-empty"||r==="is-not-empty")return e.jsx(h.Box,{paddingBlock:"sm",paddingInline:"sm",children:e.jsx(C.Text,{fontSize:"xs",color:"subtlest",children:"No further input required."})});if(r==="is-between"){const i=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(Ke.StarasiaDate,{size:"sm",input:!1,clearable:!0,rangedDate:!0,value:i,onChange:o=>{if(o==null){n({op:r});return}if(typeof o=="object"&&o!==null&&"from"in o&&"to"in o){let{from:s,to:c}=o;if(!s&&c&&(s=c,c=null),!s&&!c){n({op:r});return}n({op:r,from:s?s.toISOString():void 0,to:c?c.toISOString():void 0})}},withPadding:!1},"range")}return r==="is-relative-to-today"?e.jsx($o,{value:t==null?void 0:t.relative,onChange:i=>n({op:r,relative:i})}):e.jsx(Ke.StarasiaDate,{size:"sm",input:!1,clearable:!0,value:t!=null&&t.date?new Date(t.date):void 0,onChange:i=>{if(i==null){n({op:r});return}i instanceof Date&&n({op:r,date:i.toISOString()})},withPadding:!1},"single")},$o=({value:t,onChange:r})=>{const n=(t==null?void 0:t.direction)??"past",i=(t==null?void 0:t.count)??1,o=(t==null?void 0:t.period)??"week",s=n!=="this",c=jn({direction:n,count:i,period:o});return e.jsxs(h.Box,{direction:"column",display:"flex",gap:"sm",children:[e.jsxs(h.Box,{direction:"row",display:"flex",align:"center",gap:"xs",children:[e.jsxs(I.Menu,{position:"bottom-left",children:[e.jsx(I.MenuButton,{children:e.jsx(V.Button,{variant:"outline",tone:"neutral",size:"sm",iconRight:e.jsx(B.Icon,{name:"ChevronSmallDown"}),children:rr[n]})}),e.jsx(I.MenuLists,{children:e.jsx(I.MenuBody,{style:{width:140},children:Go.map(l=>e.jsx(I.MenuItem,{selected:n===l,endIcon:n===l?e.jsx(B.Icon,{name:"Check"}):void 0,onClick:()=>r(l==="this"?{direction:l,period:o}:{direction:l,count:i,period:o}),children:rr[l]},l))})})]}),s&&e.jsx(Ze.Input,{type:"number",size:"sm",min:1,clearable:!1,value:i,onChange:l=>{const d=Number(l.target.value);r({direction:n,count:Number.isFinite(d)&&d>0?d:1,period:o})},style:{width:72}}),e.jsxs(I.Menu,{position:"bottom-left",children:[e.jsx(I.MenuButton,{children:e.jsx(V.Button,{variant:"outline",tone:"neutral",size:"sm",iconRight:e.jsx(B.Icon,{name:"ChevronSmallDown"}),children:o})}),e.jsx(I.MenuLists,{children:e.jsx(I.MenuBody,{style:{width:140},children:Zo.map(l=>e.jsx(I.MenuItem,{selected:o===l,endIcon:o===l?e.jsx(B.Icon,{name:"Check"}):void 0,onClick:()=>r(n==="this"?{direction:n,period:l}:{direction:n,count:i,period:l}),children:l},l))})})]})]}),e.jsx(Ke.StarasiaDate,{size:"sm",input:!1,disabled:!0,rangedDate:!0,value:c,onChange:()=>{},withPadding:!1},"relative-preview")]})},zr=18,ei=t=>t.length>zr?`${t.slice(0,zr)}...`:t,ti=({field:t,value:r,onChange:n,onClear:i,onRemove:o})=>{const s=t.type==="dropdown-multiple",c=r.length,[l,d]=u.useState(""),a=t.options,f=typeof t.onSearch=="function",m=(()=>{if(f)return a;const D=l.trim().toLowerCase();return D?a.filter(E=>E.label.toLowerCase().includes(D)):a})(),g=D=>r.some(E=>E.value===D.value),j=D=>{if(!s){n([{label:D.label,value:D.value}]),d("");return}n(g(D)?r.filter(E=>E.value!==D.value):[...r,{label:D.label,value:D.value}])},M=D=>{var E;d(D),(E=t.onSearch)==null||E.call(t,D)},y=c===0?t.label:e.jsxs(e.Fragment,{children:[e.jsxs("span",{style:{fontWeight:500},children:[t.label,":"]})," ",e.jsx("span",{style:{fontWeight:400},children:c===1?ei(r[0].label):`${c} Selected`})]});return e.jsxs(I.Menu,{position:"bottom-left",children:[e.jsx(I.MenuButton,{children:e.jsx(V.Button,{variant:c>0?"secondary":"outline",tone:"neutral",size:"sm",iconLeft:c>0?e.jsx(B.Icon,{name:"Tag",size:"sm"}):void 0,iconRight:e.jsx(B.Icon,{name:"ChevronSmallDown"}),children:y})}),e.jsx(I.MenuLists,{children:e.jsx(I.MenuBody,{style:{width:260},title:e.jsxs(h.Box,{display:"flex",direction:"row",align:"center",justify:"space-between",fullWidth:!0,children:[e.jsx(C.Text,{fontSize:"sm",fontWeight:"medium",color:"subtlest",children:t.label}),e.jsx(It,{onClear:i,onRemove:o})]}),children:e.jsxs(h.Box,{direction:"column",gap:"sm",children:[e.jsx(it.Dropdown,{size:"sm",triggerInput:!0,fullWidth:!0,hideChevronIcon:!0,clearable:!0,multiSelect:s,searchAble:!0,searchValue:l,onSearch:M,value:r,onChange:n,placeholder:`Search ${t.label.toLowerCase()}…`}),e.jsx(h.Box,{direction:"column",overflow:"overflow-y-auto",customMaxHeight:"240px",children:t.isLoading?e.jsx(h.Box,{paddingBlock:"sm",paddingInline:"sm",children:e.jsx(C.Text,{fontSize:"xs",color:"subtlest",children:"Loading…"})}):m.length===0?e.jsx(h.Box,{paddingBlock:"sm",paddingInline:"sm",children:e.jsx(C.Text,{fontSize:"xs",color:"subtlest",children:"No results"})}):m.map(D=>e.jsx(I.MenuItem,{closeOnSelect:!s,selected:g(D),startIcon:D.avatar,endIcon:g(D)?e.jsx(B.Icon,{name:"Check"}):void 0,description:D.description,onClick:()=>j(D),children:D.label},D.value))})]})})})]})},Vr=18,ri=t=>t.length>Vr?`${t.slice(0,Vr)}...`:t,Hr=({checked:t,indeterminate:r})=>e.jsx("span",{style:{pointerEvents:"none",display:"inline-flex"},children:e.jsx(ct.Checkbox,{size:"sm",checked:t,readOnly:!0,onChange:()=>{},variant:r?"indeterminate":"select"})}),ni=({field:t,value:r,onChange:n,onClear:i,onRemove:o})=>{const s=new Set(r.map(g=>g.value)),c=r.length,l=t.options.length>0&&t.options.every(g=>s.has(g.value)),d=c>0&&!l,a=g=>{n(s.has(g.value)?r.filter(j=>j.value!==g.value):[...r,{label:g.label,value:g.value}])},f=()=>{n(l?[]:t.options.map(g=>({label:g.label,value:g.value})))},m=c===0?t.label:e.jsxs(e.Fragment,{children:[e.jsxs(C.Text,{as:"span",fontWeight:"semibold",children:[t.label,":"]})," ",e.jsx(C.Text,{as:"span",children:c===1?ri(r[0].label):`${c} Selected`})]});return e.jsxs(I.Menu,{position:"bottom-left",children:[e.jsx(I.MenuButton,{children:e.jsx(V.Button,{variant:c>0?"secondary":"outline",tone:"neutral",size:"sm",iconLeft:c>0?e.jsx(B.Icon,{name:"Tag",size:"sm"}):void 0,iconRight:e.jsx(B.Icon,{name:"ChevronSmallDown"}),children:m})}),e.jsx(I.MenuLists,{children:e.jsxs(I.MenuBody,{style:{width:240},title:e.jsxs(h.Box,{display:"flex",direction:"row",align:"center",justify:"space-between",fullWidth:!0,children:[e.jsx(C.Text,{fontSize:"sm",fontWeight:"medium",color:"subtlest",children:t.label}),e.jsx(It,{onClear:i,onRemove:o})]}),children:[e.jsx(I.MenuItem,{closeOnSelect:!1,selected:l,onClick:f,startIcon:e.jsx(Hr,{checked:l||d,indeterminate:d}),children:"Select All"}),t.options.map(g=>e.jsx(I.MenuItem,{closeOnSelect:!1,selected:s.has(g.value),onClick:()=>a(g),startIcon:e.jsx(Hr,{checked:s.has(g.value)}),children:g.label},g.value))]})})]})},vn=({activeKeys:t,configByKey:r,getValue:n,setValue:i,clearValue:o,removeFilter:s})=>e.jsx(e.Fragment,{children:t.map(c=>{const l=r[c];if(!l)return null;const d=n(l),a=l.locked?void 0:()=>s(c);return l.type==="date"||l.type==="date-compact"?e.jsx(Qo,{field:l,value:d,onChange:f=>i(l,f),onClear:()=>o(c),onRemove:a},c):l.type==="checkbox-multiple"?e.jsx(ni,{field:l,value:d||[],onChange:f=>i(l,f),onClear:()=>o(c),onRemove:a},c):e.jsx(ti,{field:l,value:d||[],onChange:f=>i(l,f),onClear:()=>o(c),onRemove:a},c)})}),Pr=t=>`${t} Rows`,oi=({pagination:t,pageKey:r="page",perPageKey:n="perPage",pageSizeOptions:i=[10,25,50,100],defaultPerPage:o=10,showResultCount:s=!0,showPageSize:c=!0,showPagination:l=!0})=>{var E;const{searchQueries:d,setSearchParams:a,searchParams:f}=Be(),m=f.get(n),g=m?Number(m):o,j=T=>{a({...d,[r]:String(T)})},M=T=>{a({...d,[n]:T,[r]:"1"})},y=(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),D=(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:[s&&e.jsx(C.Text,{fontSize:"sm",fontWeight:"medium",color:"primary",truncate:!0,children:`${y}-${D} of ${((E=t==null?void 0:t.totalData)==null?void 0:E.toLocaleString())||0}`}),c&&e.jsxs(I.Menu,{position:"bottom-left",children:[e.jsx(I.MenuButton,{children:e.jsx(V.Button,{variant:"outline",tone:"neutral",size:"sm",iconRight:e.jsx(B.Icon,{name:"ChevronSmallDown"}),"aria-label":"Rows per page",children:Pr(g)})}),e.jsx(I.MenuLists,{children:e.jsx(I.MenuBody,{children:i.map(T=>e.jsx(I.MenuItem,{selected:T===g,onClick:()=>M(String(T)),children:Pr(T)},T))})})]}),l&&((t==null?void 0:t.totalPage)??0)>1&&e.jsx(h.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(xt.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:j})})]})};function ii(t,r,n=!0){u.useEffect(()=>{if(!n)return;const i=o=>{var l;if(o.metaKey||o.ctrlKey||o.altKey||o.key!==t)return;const s=o.target,c=(l=s==null?void 0:s.tagName)==null?void 0:l.toLowerCase();c==="input"||c==="textarea"||s!=null&&s.isContentEditable||(o.preventDefault(),r())};return window.addEventListener("keydown",i),()=>window.removeEventListener("keydown",i)},[t,r,n])}const si=240,Cn=({searchKey:t="q",filterKey:r="filter",pageKey:n="page",placeholder:i="Search",shortcut:o="/",collapsible:s=!0})=>{const{searchParams:c,setSearchParams:l,searchQueries:d}=Be(),a=Lt(t,c,r)||"",[f,m]=u.useState(!s||!!a),[g,j]=u.useState(s&&!a),[M,y]=u.useState(a),D=he.useDebounce(M,350),E=u.useRef(null);u.useEffect(()=>{y(a),a&&m(!0)},[a]),u.useEffect(()=>{f&&j(!1)},[f]),u.useEffect(()=>{D!==a&&ht({value:D,name:t,type:"search",searchQueries:d,setSearchParams:l,filterKey:r,pageKey:n})},[D]);const T=u.useCallback(()=>{m(!0),requestAnimationFrame(()=>{var O;return(O=E.current)==null?void 0:O.focus()})},[]);ii(o,T);const w=()=>{s&&!M&&m(!1)},v=O=>{var b;s&&O.key==="Escape"&&!M&&(m(!1),(b=E.current)==null||b.blur())},R=()=>{f||j(!0)};return e.jsxs(h.Box,{display:"flex",direction:"row",align:"center",gap:"spacing-0",children:[g&&e.jsx(V.Button,{variant:"outline",tone:"neutral",size:"sm",iconLeft:e.jsx(B.Icon,{name:"Search",size:"sm"}),"aria-label":"Search","aria-expanded":!1,onClick:T}),e.jsxs(h.Box,{onTransitionEnd:R,style:{position:"relative",width:f?si:0,overflow:"hidden",transition:"width 220ms ease"},children:[e.jsx(Ze.Input,{ref:E,size:"sm",fullWidth:!0,value:M,placeholder:i,leftIcon:e.jsx(B.Icon,{name:"Search",width:16,height:16}),onChange:O=>y(O.target.value),onKeyDown:v,onBlur:w,tabIndex:f?0:-1}),f&&!M&&e.jsx(h.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(C.Text,{fontSize:"xs",color:"subtle",children:o})})]})]})},wn=({columns:t,allVisible:r,onToggle:n,onReorder:i,onSetAllHidden:o})=>{const[s,c]=u.useState(null),[l,d]=u.useState(null),a=()=>{s!==null&&l!==null&&s!==l&&i(s,l),c(null),d(null)},f=(m,g)=>{const j=m+g;j<0||j>=t.length||i(m,j)};return e.jsxs(I.Menu,{position:"bottom-right",children:[e.jsx(I.MenuButton,{children:e.jsx(V.Button,{variant:r?"outline":"secondary",tone:"neutral",size:"sm",iconLeft:e.jsx(B.Icon,{name:"Grid",size:"sm"}),"aria-label":"Customize columns"})}),e.jsx(I.MenuLists,{children:e.jsx(I.MenuBody,{children:e.jsxs(h.Box,{padding:"sm",direction:"column",customWidth:"296px",customMaxHeight:"60vh",overflow:"overflow-hidden",children:[e.jsx(C.Text,{fontWeight:"semibold",color:"primary",children:"Customize Column Table"}),e.jsxs(h.Box,{direction:"row",display:"flex",align:"center",justify:"space-between",paddingBlock:"md",children:[e.jsx(C.Text,{fontSize:"sm",fontWeight:"medium",color:"subtle",children:"Show in table"}),e.jsx(V.Button,{variant:"link",tone:"info",size:"xs",onClick:()=>o(r),children:r?"Hide All":"Show All"})]}),e.jsx(h.Box,{direction:"column",overflow:"overflow-y-auto",children:t.map((m,g)=>{const j=!m.locked,M=l===g&&s!==null&&s!==g;return e.jsxs(h.Box,{direction:"row",display:"flex",align:"center",gap:"sm",paddingBlock:"xs",draggable:j,onDragStart:()=>j&&c(g),onDragOver:y=>{y.preventDefault(),d(g)},onDrop:a,onDragEnd:a,style:{minHeight:32,boxShadow:M?"inset 0 2px 0 0 var(--sa-background-brand, #04254f)":void 0},children:[e.jsx(h.Box,{direction:"column",as:"div",align:"center",justify:"center",role:"button",tabIndex:j?0:-1,"aria-label":`Reorder ${m.title}`,"aria-disabled":!j||void 0,color:"icon-subtlest",onKeyDown:y=>{j&&(y.key==="ArrowUp"?(y.preventDefault(),f(g,-1)):y.key==="ArrowDown"&&(y.preventDefault(),f(g,1)))},style:{display:"inline-flex",cursor:j?"grab":"default",opacity:j?1:.4},children:e.jsx(B.Icon,{name:"DragVertical",width:16,height:16})}),m.icon&&e.jsx(h.Box,{direction:"column",align:"center",color:"icon-subtle",style:{display:"inline-flex"},children:m.icon}),e.jsx(C.Text,{fontSize:"sm",fontWeight:"medium",color:"primary",truncate:!0,children:m.title}),e.jsx(h.Box,{direction:"column",style:{marginLeft:"auto"},children:e.jsx(lt.Toggle,{size:"sm",checked:m.visible,disabled:m.locked,onChange:()=>n(m.key),"aria-label":`Toggle ${m.title} column`})})]},m.key)})})]})})})]})},Dn=({views:t,onApply:r,onDelete:n,onSave:i})=>{const[o,s]=u.useState(""),c=()=>{const l=o.trim();l&&(i(l),s(""))};return e.jsxs(I.Menu,{position:"bottom-right",children:[e.jsx(I.MenuButton,{children:e.jsx(V.Button,{variant:t.length>0?"secondary":"outline",tone:(t.length>0,"neutral"),size:"sm",iconLeft:e.jsx(B.Icon,{name:"Bookmark",size:"sm"}),"aria-label":"Saved views"})}),e.jsxs(I.MenuLists,{style:{width:"260px"},children:[e.jsx(I.MenuBody,{children:e.jsxs(h.Box,{direction:"column",padding:"xs",gap:"sm",children:[e.jsx(C.Text,{fontWeight:"semibold",color:"primary",children:"Saved Views"}),e.jsx(h.Box,{direction:"column",overflow:"overflow-y-auto",children:t.length===0?e.jsx(h.Box,{direction:"column",paddingBlock:"sm",children:e.jsx(C.Text,{fontSize:"sm",color:"subtlest",children:"No saved views yet"})}):t.map(l=>e.jsx(I.MenuItem,{startIcon:e.jsx(B.Icon,{name:"Bookmark"}),onClick:()=>r(l),endIcon:e.jsx(V.Button,{variant:"link",tone:"error",size:"sm",iconLeft:e.jsx(B.Icon,{name:"Trash2"}),"aria-label":`Delete ${l.name}`,onClick:d=>{d.stopPropagation(),n(l.id)}}),children:l.name},l.id))})]})}),e.jsx(I.MenuFooter,{children:e.jsxs(h.Box,{direction:"row",gap:"xs",children:[e.jsx(h.Box,{direction:"column",style:{flex:"1 0 0",minWidth:0},children:e.jsx(Ze.Input,{size:"sm",fullWidth:!0,placeholder:"Save current view as…",value:o,onChange:l=>s(l.target.value),onKeyDown:l=>{l.key==="Enter"&&c()}})}),e.jsx(V.Button,{variant:"primary",tone:"brand",size:"sm",disabled:!o.trim(),onClick:c,children:"Save"})]})})]})]})},li=({isOpen:t,onClose:r,configs:n,activeKeys:i,configByKey:o,hasActiveFilter:s,onToggle:c,onReset:l,getValue:d,setValue:a,clearValue:f,removeFilter:m})=>{const g=i.length;return e.jsx(Ft.Drawer,{position:"bottom",isShow:t,onHide:r,children:e.jsxs(h.Box,{direction:"column",customMaxHeight:"85vh",style:{minHeight:280},children:[e.jsxs(h.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(h.Box,{direction:"row",display:"flex",align:"center",gap:"xs",children:[e.jsx(C.Text,{fontWeight:"semibold",color:"primary",children:"Filter"}),g>0&&e.jsxs(C.Text,{fontSize:"sm",color:"subtle",children:["(",g,")"]})]}),e.jsx(V.Button,{variant:"link",tone:"neutral",size:"sm",iconLeft:e.jsx(B.Icon,{name:"Cross"}),"aria-label":"Close filter",onClick:r})]}),e.jsxs(h.Box,{direction:"column",gap:"lg",padding:"md",overflow:"overflow-y-auto",style:{flex:"1 1 auto",minHeight:0},children:[g>0&&e.jsxs(h.Box,{direction:"column",gap:"sm",children:[e.jsx(C.Text,{fontSize:"xs",fontWeight:"medium",color:"subtlest",children:"Filter aktif"}),e.jsx(h.Box,{direction:"row",display:"flex",wrap:"wrap",gap:"sm",align:"center",children:e.jsx(vn,{activeKeys:i,configByKey:o,getValue:d,setValue:a,clearValue:f,removeFilter:m})})]}),n.length>0&&e.jsxs(h.Box,{direction:"column",gap:"sm",children:[e.jsx(C.Text,{fontSize:"xs",fontWeight:"medium",color:"subtlest",children:"Tambah filter"}),e.jsx(h.Box,{direction:"column",children:n.map(j=>{const M=i.includes(j.key),y=!!j.locked;return e.jsxs(h.Box,{direction:"row",display:"flex",align:"center",justify:"space-between",gap:"sm",paddingBlock:"sm",style:{opacity:y?.5:1,borderTop:"1px solid var(--sa-border-subtle, rgba(11, 18, 14, 0.08))"},children:[e.jsxs(h.Box,{direction:"row",display:"flex",align:"center",gap:"sm",style:{minWidth:0},children:[j.icon&&e.jsx(h.Box,{direction:"column",align:"center",color:"icon-subtle",style:{display:"inline-flex"},children:j.icon}),e.jsx(C.Text,{fontSize:"sm",color:"primary",truncate:!0,children:j.label})]}),e.jsx(lt.Toggle,{size:"sm",checked:M||y,disabled:y,onChange:()=>c(j.key),"aria-label":`Toggle ${j.label}`})]},j.key)})})]})]}),e.jsxs(h.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(h.Box,{direction:"column",style:{flex:"1 1 0"},children:e.jsx(V.Button,{variant:"outline",tone:"neutral",size:"md",fullWidth:!0,disabled:!s,onClick:l,children:"Reset"})}),e.jsx(h.Box,{direction:"column",style:{flex:"1 1 0"},children:e.jsx(V.Button,{variant:"primary",tone:"brand",size:"md",fullWidth:!0,onClick:r,children:"Selesai"})})]})]})})},ci=t=>`${t} Rows`,ai=({perPageKey:t,pageKey:r,pageSizeOptions:n,defaultPerPage:i=10,showPageSize:o})=>{const{searchQueries:s,setSearchParams:c,searchParams:l}=Be(),d=l.get(t),a=d?Number(d):i,f=m=>{c({...s,[t]:m,[r]:"1"})};return o?e.jsxs(I.Menu,{position:"bottom-right",children:[e.jsx(I.MenuButton,{children:e.jsx(V.Button,{variant:"outline",tone:"neutral",size:"sm",iconLeft:e.jsx(B.Icon,{name:"MenuVertical",size:"sm"}),"aria-label":"More options"})}),e.jsx(I.MenuLists,{children:e.jsxs(I.MenuBody,{style:{minWidth:200},children:[e.jsx(h.Box,{paddingInline:"sm",paddingBlock:"xs",children:e.jsx(C.Text,{fontSize:"xs",fontWeight:"medium",color:"subtlest",children:"Rows per page"})}),n.map(m=>e.jsx(I.MenuItem,{selected:m===a,endIcon:m===a?e.jsx(B.Icon,{name:"Check"}):void 0,onClick:()=>f(String(m)),children:ci(m)},m))]})})]}):null},di=t=>{var ge;const{withPadding:r,configs:n,activeKeys:i,configByKey:o,hasActiveFilter:s,toggleFilter:c,removeFilter:l,getValue:d,setValue:a,clearValue:f,onReset:m,searchable:g,searchKey:j,filterKey:M,pageKey:y,searchPlaceholder:D,searchShortcut:E,searchCollapsible:T,pagination:w,perPageKey:v,pageSizeOptions:R,defaultPerPage:O,showPagination:b,showResultCount:S,showPageSize:P,hasColumns:A,orderedColumns:N,allVisible:G,onToggleVisibility:re,onReorder:xe,onSetAllHidden:ne,showSavedViews:se,savedViews:J,onApplyView:Q,onDeleteView:ae,onSaveView:ee}=t,[ce,we]=u.useState(!1),{searchQueries:ze,setSearchParams:fe}=Be(),De=(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),Me=(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)),me=Fe=>{fe({...ze,[y]:String(Fe)})},Ie=S||b&&!!(w!=null&&w.totalPage),Ne=()=>{m(),we(!1)};return e.jsxs(h.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(h.Box,{direction:"row",display:"flex",align:"center",wrap:"wrap",gap:"sm",fullWidth:!0,overflow:"overflow-auto",children:[g&&e.jsx(Cn,{searchKey:j,filterKey:M,pageKey:y,placeholder:D,shortcut:E,collapsible:T}),e.jsx(V.Button,{variant:s?"secondary":"outline",tone:"neutral",size:"sm",iconLeft:e.jsx(B.Icon,{name:"FilterHorizontal"}),onClick:()=>we(!0),"aria-label":"Open filters",children:s?`Filter: ${i.length}`:null}),e.jsxs(h.Box,{direction:"row",display:"flex",align:"center",gap:"sm",style:{marginLeft:"auto"},children:[se&&e.jsx(Dn,{views:J,onApply:Q,onDelete:ae,onSave:ee}),A&&e.jsx(wn,{columns:N,allVisible:G,onToggle:re,onReorder:xe,onSetAllHidden:ne}),e.jsx(ai,{perPageKey:v,pageKey:y,pageSizeOptions:R,defaultPerPage:O,showPageSize:P})]})]}),Ie&&e.jsxs(h.Box,{direction:"row",display:"flex",align:"center",justify:"space-between",gap:"sm",fullWidth:!0,children:[S?e.jsx(C.Text,{fontSize:"sm",fontWeight:"medium",color:"primary",truncate:!0,children:`${De}-${Me} of ${((ge=w==null?void 0:w.totalData)==null?void 0:ge.toLocaleString())||0}`}):e.jsx(h.Box,{direction:"column"}),b&&!!(w!=null&&w.totalPage)&&e.jsx(xt.Pagination,{size:"xs",variant:"neutral",siblingCount:0,currentPage:w!=null&&w.currentPage?Number(w.currentPage):1,totalPages:Number(w.totalPage),onPageChange:me})]}),e.jsx(li,{isOpen:ce,onClose:()=>we(!1),configs:n,activeKeys:i,configByKey:o,hasActiveFilter:s,onToggle:c,onReset:Ne,getValue:d,setValue:a,clearValue:f,removeFilter:l})]})},ui=({withPadding:t=!1,filterConfigs:r=[],filterKey:n="filter",activeFilterKey:i="filters",pageKey:o="page",perPageKey:s="perPage",pageSizeOptions:c=[25,50,100],defaultPerPage:l,showPagination:d=!0,showResultCount:a=!0,showPageSize:f=!0,searchable:m=!1,searchKey:g="q",searchPlaceholder:j="Search",searchShortcut:M="/",searchPosition:y="right",searchCollapsible:D=!0,pagination:E,columns:T=[],onColumnsChange:w,columnsState:v,scopeId:R,savedViews:O,persistLastState:b=!0,storage:S=xr,onReset:P})=>{const A=R??(O==null?void 0:O.scopeId),{activeKeys:N,configByKey:G,hasActiveFilter:re,toggleFilter:xe,removeFilter:ne,getValue:se,setValue:J,clearValue:Q,clearAll:ae}=ur({configs:r,filterKey:n,activeFilterKey:i,pageKey:o,searchKey:g}),ee=Ro({columns:T,scopeId:A,storage:S,onColumnsChange:w,value:v}),ce=Ao({scopeId:A,storage:S,snapshotKeys:[i,n,s],pageKey:o,getColumns:()=>ee.state,applyColumns:ee.applyState}),we=zo({scopeId:A,storage:S,snapshotKeys:[i,n,o],enabled:b}),ze=Vo({scopeId:A,storage:S,perPageKey:s,pageSizeOptions:c,enabled:b});Po({enabled:b&&!!A,snapshotKeys:[i,n,o],perPageKey:s,readSnapshot:we.read,readPerPage:ze.read});const fe=l??c[0]??25,De=!!(O!=null&&O.enabled)&&ce.enabled,Me=()=>{ae(),we.clear(),P==null||P()},me=he.useMediaQuery("md"),Ie=m?e.jsx(Cn,{searchKey:g,filterKey:n,pageKey:o,placeholder:j,shortcut:M,collapsible:D}):null;return me?e.jsxs(h.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(h.Box,{direction:"row",display:"flex",align:"center",gap:"sm",style:{flex:"1 1 0",minWidth:0},children:[e.jsx(No,{configs:r,activeKeys:N,onToggle:xe,hasActiveFilter:re,onReset:Me}),y==="left"&&Ie,e.jsxs(h.Box,{direction:"row",display:"flex",align:"center",gap:"sm",overflow:"overflow-x-auto",style:{flex:"1 1 0",minWidth:0},children:[e.jsx(vn,{activeKeys:N,configByKey:G,getValue:se,setValue:J,clearValue:Q,removeFilter:ne}),re&&e.jsx(V.Button,{variant:"link",tone:"brand",size:"sm",onClick:Me,children:"Reset"})]})]}),e.jsxs(h.Box,{direction:"row",display:"flex",align:"center",gap:"sm",children:[e.jsx(oi,{pagination:E,pageKey:o,perPageKey:s,pageSizeOptions:c,defaultPerPage:fe,showPagination:d,showResultCount:a,showPageSize:f}),y==="right"&&Ie,De&&e.jsx(Dn,{views:ce.views,onApply:ce.applyView,onDelete:ce.deleteView,onSave:ce.saveView}),T.length>0&&e.jsx(wn,{columns:ee.orderedColumns,allVisible:ee.allVisible,onToggle:ee.toggleVisibility,onReorder:ee.reorder,onSetAllHidden:ee.setAllHidden})]})]}):e.jsx(di,{withPadding:t,configs:r,activeKeys:N,configByKey:G,hasActiveFilter:re,toggleFilter:xe,removeFilter:ne,getValue:se,setValue:J,clearValue:Q,onReset:Me,searchable:m,searchKey:g,filterKey:n,pageKey:o,searchPlaceholder:j,searchShortcut:M,searchCollapsible:D,pagination:E,perPageKey:s,pageSizeOptions:c,defaultPerPage:fe,showPagination:d,showResultCount:a,showPageSize:f,hasColumns:T.length>0,orderedColumns:ee.orderedColumns,allVisible:ee.allVisible,onToggleVisibility:ee.toggleVisibility,onReorder:ee.reorder,onSetAllHidden:ee.setAllHidden,showSavedViews:De,savedViews:ce.views,onApplyView:ce.applyView,onDeleteView:ce.deleteView,onSaveView:ce.saveView})},xi=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},hi=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 xi(r);case"dropdown-multiple":case"checkbox-multiple":return hi(r);case"date":return r instanceof Date?r.toISOString():void 0;case"date-compact":return r;default:return}},Nr=(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:i="filters",pageKey:o="page",perPageKey:s="perPage",searchKey:c="q",defaultPage:l=1,defaultPerPage:d=10,paramKeys:a,serialize:f}=t,{activeKeys:m,configByKey:g,hasActiveFilter:j,getValue:M}=ur({configs:r,filterKey:n,activeFilterKey:i,pageKey:o,searchKey:c}),{searchParams:y}=Be(),D=y.toString();return u.useMemo(()=>{const T={},w={},v=Nr(y.get(o),l),R=Nr(y.get(s),d);T[(a==null?void 0:a.page)??"page"]=v,T[(a==null?void 0:a.perPage)??"perPage"]=R;const O=Lt(c,y,n)||"";O&&(T[(a==null?void 0:a.search)??"search"]=O);let b=!1;for(const S of m){const P=g[S];if(!P)continue;const A=M(P);w[S]=A;const N=f==null?void 0:f[S],G=N?N(A):fi(P,A);if(G==null||Array.isArray(G)&&G.length===0)continue;const re=(a==null?void 0:a[S])??S;T[re]=G,b=!0}return{params:T,raw:w,hasActiveFilter:j||!!O||b}},[D,m.join("|"),n,i,o,s,c,l,d,a,f,g])},gi=["dropdown","dropdown-multiple","checkbox-multiple","radio"],yi=({filterConfigs:t,filterKey:r,activeFilterKey:n,pageKey:i,searchKey:o})=>{const{configByKey:s,getValue:c,setValue:l,removeFilter:d,clearAll:a,hasActiveFilter:f}=ur({configs:t,filterKey:r,activeFilterKey:n,pageKey:i,searchKey:o}),m=(E,T)=>{var v;const w=E.options;return((v=w==null?void 0:w.find(R=>R.value===T))==null?void 0:v.label)??T},g=u.useCallback(E=>{const T=s[E];if(!T)return[];const w=c(T);return Array.isArray(w)?w.map(v=>String(v.value)):[]},[s,c]),j=u.useCallback((E,T)=>{const w=s[E];if(!w||!gi.includes(w.type))return;const v=Array.isArray(T)?T:[T];if(v.length===0){d(E);return}l(w,v.map(R=>({label:m(w,R),value:R})))},[s,l,d]),M=u.useCallback((E,T)=>{const w=g(E);j(E,w.includes(T)?w.filter(v=>v!==T):[...w,T])},[g,j]),y=u.useCallback((E,T)=>g(E).includes(T),[g]),D=u.useCallback(E=>d(E),[d]);return{set:j,toggle:M,clear:D,clearAll:a,isActive:y,values:g,hasActiveFilter:f}},pi=(t,r)=>{if(!t)return{};const{fromKey:n,toKey:i,opKey:o}=r,s={};switch(t.op){case"is":case"is-before":case"is-after":case"is-on-or-before":case"is-on-or-after":return t.date&&(s[n]=new Date(t.date).toISOString()),o&&(s[o]=t.op),s;case"is-between":return t.from&&(s[n]=new Date(t.from).toISOString()),t.to&&(s[i]=new Date(t.to).toISOString()),s;case"is-relative-to-today":{if(!t.relative)return s;const{from:c,to:l}=jn(t.relative);return s[n]=c.toISOString(),s[i]=l.toISOString(),s}case"is-empty":case"is-not-empty":return o&&(s[o]=t.op==="is-empty"?"empty":"not-empty"),s;default:return s}},Sn=({children:t,borderRadius:r,height:n})=>{const i=u.useRef(null),[o,s]=u.useState("100vh");return u.useEffect(()=>{if(n)return;const c=()=>{if(i.current){const l=i.current.getBoundingClientRect().top;s(`calc(100vh - ${l}px)`)}};return c(),window.addEventListener("resize",c),()=>window.removeEventListener("resize",c)},[n]),e.jsx(h.Box,{ref:i,fullWidth:!0,borderStyle:"border-solid",borderWidth:"border",borderColor:"border-base",borderRadius:r||"rounded-xs",style:{height:n??o,display:"flex",flexDirection:"column"},children:t})},kn=({action:t,rightContent:r,leftContent:n,headerSlot:i,advanceFilter:o,showFilter:s=!0})=>{const c=he.useMediaQuery("md"),l=s?e.jsx(pn,{...o}):null,d=()=>t?u.isValidElement(t)?t:e.jsx(h.Box,{style:{display:"flex",flexDirection:c?"row":"column",gap:"8px",width:c?"auto":"100%",textWrap:"nowrap"},children:t.map(({title:a,icon:f,buttonProps:m,onClick:g},j)=>!a&&!f?null:e.jsx(V.Button,{fullWidth:!c,iconLeft:f?e.jsx(B.Icon,{name:f}):void 0,onClick:g,...m,children:a},`action-${j}`))}):null;return e.jsx(h.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:c?"row":"column-reverse",gap:"16px"},children:i?i({filter:l}):e.jsxs(e.Fragment,{children:[e.jsxs(h.Box,{style:{display:"flex",gap:"8px",flexDirection:"row",alignItems:"center",flex:1,minWidth:0},children:[l,n]}),e.jsxs(h.Box,{style:{display:"flex",gap:"8px",flexDirection:"row",alignItems:"center",flexShrink:0},children:[r,d()]})]})})},ji=({totalData:t,withMarginBottom:r=!0,withMarginTop:n=!0})=>e.jsxs(h.Box,{style:{display:"flex",gap:"4px",flexDirection:"row",alignItems:"center",marginBottom:r?"16px":void 0,marginTop:n?"16px":void 0},children:[e.jsxs(Ae.Body1,{props:{color:"gray-500"},children:["Total data:"," "]}),e.jsx(Ae.Body1,{children:t||0})]}),Bn=({pagination:t,pageKey:r="page",perPageKey:n="perPage",defaultPerPage:i=10,showPagination:o=!0,totalData:s})=>{const{searchQueries:c,setSearchParams:l,searchParams:d}=Be(),a=d.get(n),f=M=>{l({...c,[r]:String(M)})},m=M=>{l({...c,[n]:M,[r]:"1"})},g=(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),j=(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(h.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(h.Box,{style:{display:"flex",flexDirection:"row",gap:"8px",alignItems:"center",textWrap:"nowrap"},children:[e.jsx(C.Text,{children:"Rows Per Page: "}),e.jsx(it.Dropdown,{dropdownLists:[{label:"5",value:"5"},{label:"10",value:"10"},{label:"25",value:"25"},{label:"50",value:"50"},{label:"100",value:"100"}],onChange:M=>{m(M[0].value)},value:a?[{label:`${a} per row`,value:a}]:[{label:`${i} per row`,value:`${i}`}],defaultValue:a?[{label:`${a} per row`,value:a}]:[{label:`${i} per row`,value:`${i}`}]}),e.jsx(C.Text,{children:`${g}-${j} of ${(t==null?void 0:t.totalData)||0}`})]}),e.jsx(xt.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(ji,{totalData:s,withMarginBottom:!1,withMarginTop:!1})})},Fn=({filter:t,columnTitle:r})=>{const[n,i]=u.useState(!1),o=u.useRef(null),s=u.useRef(null),c=u.useRef(null),[l,d]=u.useState(""),[a,f]=u.useState({top:0,left:0}),m=t.selectedValues,g=u.useMemo(()=>l?t.options.filter(y=>y.label.toLowerCase().includes(l.toLowerCase())):t.options,[t.options,l]);u.useEffect(()=>{if(n&&s.current){const y=s.current.getBoundingClientRect(),D=280,E={top:y.bottom+8};t.position==="left"||y.left+D>window.innerWidth?E.right=window.innerWidth-y.right:E.left=y.left,f(E)}},[n,t.position]),u.useEffect(()=>{n&&c.current?setTimeout(()=>{var y;return(y=c.current)==null?void 0:y.focus()},50):d("")},[n]),u.useEffect(()=>{const y=D=>{o.current&&!o.current.contains(D.target)&&s.current&&!s.current.contains(D.target)&&i(!1)};return n&&document.addEventListener("mousedown",y),()=>document.removeEventListener("mousedown",y)},[n]);const j=y=>{const D=m.includes(y)?m.filter(E=>E!==y):[...m,y];t.onFilterChange(D)},M=()=>t.onFilterChange([]);return e.jsxs(h.Box,{direction:"column",style:{position:"relative"},children:[e.jsx(h.Box,{ref:s,style:{display:"flex",flexDirection:"row",alignItems:"center",cursor:"pointer"},onClick:y=>{var D;y.stopPropagation(),n||(D=t.onOpen)==null||D.call(t),i(E=>!E)},children:e.jsx(B.Icon,{name:n?"ChevronUp":"ChevronDown",size:"sm",style:{color:m.length>0?"var(--sa-color-brand-500, #1a4fa0)":"var(--sa-text-subtle, #8c8f97)"}})}),n&&e.jsxs(h.Box,{ref:o,style:{position:"fixed",top:`${a.top}px`,...a.left!==void 0?{left:`${a.left}px`}:{right:`${a.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(h.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(C.Text,{fontSize:"sm",fontWeight:"semibold",color:"gray-700",children:["Filter ",r]}),m.length>0&&e.jsx(h.Box,{direction:"column",style:{cursor:"pointer"},children:e.jsx(C.Text,{fontSize:"xs",color:"primary",fontWeight:"semibold",onClick:y=>{y.stopPropagation(),M()},children:"CLEAR"})})]}),!t.hideSearch&&e.jsx(h.Box,{direction:"column",style:{paddingLeft:"16px",paddingRight:"16px",paddingTop:"8px",paddingBottom:"8px"},children:e.jsx(Ze.Input,{ref:c,placeholder:`Search ${r.toLowerCase()}...`,leftIcon:e.jsx(B.Icon,{name:"Search",size:"sm"}),value:l,onChange:y=>d(y.target.value),style:{fontSize:"14px"}})}),e.jsx(h.Box,{direction:"column",className:"ts-filter-dropdown-options",style:{overflowY:"auto",maxHeight:"250px",paddingLeft:"8px",paddingRight:"8px"},children:t.isLoadingOptions?e.jsxs(h.Box,{style:{paddingTop:"40px",paddingBottom:"40px",display:"flex",alignItems:"center",justifyContent:"center",flexDirection:"column"},children:[e.jsx(B.Icon,{name:"Loading",size:"lg",style:{color:"var(--sa-background-brand, #04254f)",animation:"spin 1s linear infinite"}}),e.jsx(C.Text,{fontSize:"sm",color:"gray-500",style:{textAlign:"center",marginTop:"8px"},children:"Loading options..."})]}):g.length>0?e.jsx(h.Box,{direction:"column",style:{gap:"2px",paddingTop:"4px",paddingBottom:"4px"},children:g.map(y=>e.jsxs(h.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:m.includes(y.value)?"var(--sa-color-brand-50, #e6edf6)":"transparent"},onClick:D=>{D.stopPropagation(),j(y.value)},onMouseEnter:D=>{m.includes(y.value)||(D.currentTarget.style.backgroundColor="var(--sa-background-primary, #ffffff)"),D.currentTarget.style.transform="translateX(2px)"},onMouseLeave:D=>{D.currentTarget.style.backgroundColor=m.includes(y.value)?"var(--sa-color-brand-50, #e6edf6)":"transparent",D.currentTarget.style.transform="translateX(0)"},children:[e.jsx(ct.Checkbox,{checked:m.includes(y.value),onChange:()=>{}}),e.jsx(C.Text,{fontSize:"sm",fontWeight:m.includes(y.value)?"medium":"normal",color:m.includes(y.value)?"primary":"gray-700",children:y.label})]},y.value))}):e.jsxs(h.Box,{style:{paddingTop:"40px",paddingBottom:"40px",display:"flex",alignItems:"center",justifyContent:"center",flexDirection:"column"},children:[e.jsx(B.Icon,{name:"Search",size:"lg",style:{color:"var(--sa-text-subtle, #8c8f97)"}}),e.jsx(C.Text,{fontSize:"sm",color:"gray-500",style:{textAlign:"center",marginTop:"8px"},children:"No results found"})]})}),m.length>0&&e.jsx(h.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(h.Box,{style:{display:"flex",flexDirection:"row",alignItems:"center",gap:"4px"},children:[e.jsx(h.Box,{direction:"column",style:{backgroundColor:"var(--sa-background-brand, #04254f)",borderRadius:"12px",padding:"2px 8px",fontSize:"11px",fontWeight:600,color:"white"},children:m.length}),e.jsxs(C.Text,{fontSize:"xs",color:"primary",fontWeight:"medium",children:["item",m.length>1?"s":""," selected"]})]})})]})]})},bi=({direction:t})=>{const r="var(--sa-text-primary, #292a2e)",n="var(--sa-text-subtle, #8c8f97)",i=t==="asc"?r:n,o=t==="desc"?r:n,s=t==="asc"?1:.45,c=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:i,opacity:s,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:c},children:e.jsx("path",{d:"M0 0 L8 0 L4 5 Z",fill:"currentColor"})})]})},vi=({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"})]}),Ut="var(--sa-background-primary, #ffffff)",_r="var(--sa-background-primary-inverse, #f8f8f8)",En=({columns:t,records:r,handleDetail:n,handleUpdate:i,handleDelete:o,isLoading:s,visibleHandleDelete:c,visibleHandleUpdate:l,visibleHandleDetail:d,showHeadBorder:a=!1,scrollParentRef:f,frozenCount:m=0,onFrozenCountChange:g,customActions:j,actionsOrder:M=["detail","update","delete","custom"],customEmptyState:y,enableColumnResize:D=!1,defaultColumnWidths:E,onColumnWidthsChange:T,defaultMinColumnWidth:w=60,sort:v,defaultSort:R,onSortChange:O,showActionDivider:b=!1})=>{const S=v!==void 0,[P,A]=u.useState(R??null),N=S?v??null:P,G=L=>{if(L.sortKey)return L.sortKey;if(typeof L.accessor=="string")return L.accessor},re=L=>{const z=G(L);if(!z)return;let H;!N||N.key!==z?H={key:z,direction:"asc"}:N.direction==="asc"?H={key:z,direction:"desc"}:H=null,S||A(H),O==null||O(H)},ne=[n,i,o].filter(L=>L!==void 0).length,se=!!j,J=!!n||!!i||!!o||se,Q="var(--sa-border-subtle, #0b120e24)",ae=`1px solid ${Q}`,ee=`inset 1px 0 0 ${Q}`,ce=`inset -1px 0 0 ${Q}`,we=ne===3?se?"178px":"140px":ne===2?se?"140px":"102px":ne===1?se?"112px":"74px":se?"74px":"",ze=(L,z)=>{if(!z)return L;if(typeof z=="function")return z(L);if(typeof z=="string")return L[z]},[fe,De]=u.useState(!1);u.useEffect(()=>{if(!(f!=null&&f.current))return;const L=f.current;De(L.scrollHeight>L.clientHeight)},[r,f]);const Me=u.useRef(null),[me,Ie]=u.useState([]),[Ne,ge]=u.useState(()=>E??{}),Fe=u.useRef(null);u.useLayoutEffect(()=>{if(!m||!Me.current){Ie([]);return}const L=Array.from(Me.current.querySelectorAll("thead tr th")),z=[];let H=0;L.forEach((q,K)=>{z[K]=H,K<m&&(H+=q.offsetWidth)}),Ie(z)},[m,t,r,Ne]);const Ge=L=>{g&&g(L<m?L:L+1)},k=(L,z)=>{const H=Ne[L];if(H!==void 0){const q=`${H}px`;return{width:q,minWidth:q,maxWidth:q}}return z?{width:z}:{}},Z=L=>D&&(L.resizable??!0),_=(L,z)=>{L.preventDefault(),L.stopPropagation();const H=L.currentTarget.closest("th");if(!H)return;const q=Math.round(H.getBoundingClientRect().width);Fe.current={colIndex:z,startX:L.clientX,startWidth:q};const K=document.body.style.userSelect,je=document.body.style.cursor;document.body.style.userSelect="none",document.body.style.cursor="col-resize";const Se=Oe=>{var Je;const Le=Fe.current;if(!Le)return;const Qe=((Je=t[Le.colIndex])==null?void 0:Je.minWidth)??w,Ue=Math.max(Qe,Le.startWidth+(Oe.clientX-Le.startX));ge(We=>We[Le.colIndex]===Ue?We:{...We,[Le.colIndex]:Ue})},Te=()=>{document.removeEventListener("mousemove",Se),document.removeEventListener("mouseup",Te),document.body.style.userSelect=K,document.body.style.cursor=je,Fe.current=null,T&&ge(Oe=>(T(Oe),Oe))};document.addEventListener("mousemove",Se),document.addEventListener("mouseup",Te)};return e.jsx("div",{ref:Me,children:e.jsxs(U.Table,{fullWidth:!0,children:[e.jsx(U.Thead,{style:{height:"40px",whiteSpace:"nowrap"},children:e.jsxs(U.Tr,{children:[t.map((L,z)=>{var $e,et;const H=m>0&&z<m,q=me[z]??0,K=Z(L),Se=z===t.length-1&&J&&b,Te=G(L),Oe=!!L.sortable&&!!Te,Le=Oe&&(N==null?void 0:N.key)===Te?N.direction:null,Qe=L.title||(($e=L.accessor)==null?void 0:$e.toString())||"",Ue=(et=L.headerTooltip)!=null&&et.showIcon?e.jsx(B.Icon,{name:"InfoCircle",size:"xs",style:{flexShrink:0,color:"var(--sa-icon-subtle, #8c8f97)",opacity:.75}}):null,Je=e.jsx("span",{style:{flex:1,minWidth:0,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:Qe}),We=Oe?e.jsxs("button",{type:"button",onClick:()=>re(L),title:Le==="asc"?"Sorted ascending — click to sort descending":Le==="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:L.textAlign==="text-right"?"right":L.textAlign==="text-center"?"center":"left"},children:[Je,Ue,e.jsx(bi,{direction:Le})]}):e.jsxs("span",{style:{flex:1,minWidth:0,display:"flex",alignItems:"center",gap:4},children:[Je,Ue]});return e.jsxs(U.Th,{style:{position:"sticky",top:0,left:H?q:void 0,zIndex:H?4:2,paddingLeft:z===0?"12px":"",borderRight:a&&!Se&&!H?ae:void 0,borderBottom:a?ae:void 0,boxShadow:a&&H?ce:void 0,backgroundColor:"var(--sa-background-primary-inverse, #f8f8f8)",textAlign:L.textAlign==="text-right"?"right":L.textAlign==="text-center"?"center":"left",...k(z,L.width)},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"4px",justifyContent:"space-between",minWidth:0},children:[L.headerTooltip?e.jsx(ve.Tooltip,{label:L.headerTooltip.content,position:"bottom",children:We}):We,L.filter&&e.jsx(Fn,{filter:L.filter,columnTitle:L.title}),g&&e.jsx("button",{onClick:()=>Ge(z),title:H?"Unfreeze column":"Freeze column",style:{background:"none",border:"none",cursor:"pointer",padding:"2px",display:"flex",alignItems:"center",flexShrink:0,color:H?"var(--sa-background-brand, #04254f)":"var(--sa-text-subtle, #8c8f97)",opacity:H?1:.45,transition:"opacity 0.15s"},children:e.jsx(vi,{frozen:H})})]}),K&&e.jsx("div",{onMouseDown:tt=>_(tt,z),onClick:tt=>tt.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}`)}),J?e.jsx(U.Th,{style:{backgroundColor:"var(--sa-background-primary-inverse, #f8f8f8)",position:"sticky",top:0,right:0,zIndex:3,borderBottom:a?ae:void 0,boxShadow:a&&b?ee:void 0}}):null]})}),e.jsx(U.Tbody,{children:s?e.jsx(U.Tr,{children:e.jsx(U.Td,{colSpan:t.length+1,children:e.jsxs(h.Box,{direction:"column",style:{gap:"16px"},children:[e.jsx(Pe.Skeleton,{variant:"list"}),e.jsx(Pe.Skeleton,{variant:"list"}),e.jsx(Pe.Skeleton,{variant:"list"}),e.jsx(Pe.Skeleton,{variant:"list"}),e.jsx(Pe.Skeleton,{variant:"list"})]})})}):!(r!=null&&r.length)&&y?e.jsx(U.Tr,{children:e.jsx(U.Td,{colSpan:t.length+1,children:y})}):r==null?void 0:r.map((L,z)=>e.jsxs(U.Tr,{style:{transition:"background-color 0.3s ease",padding:0,borderBottom:z===r.length-1&&fe?void 0:"1px solid var(--sa-border-subtle, #0b120e24)"},onMouseEnter:H=>{const q=H.currentTarget;q.style.backgroundColor=_r,Array.from(q.querySelectorAll("td")).forEach(K=>{K.style.position==="sticky"&&(K.style.backgroundColor=_r)})},onMouseLeave:H=>{const q=H.currentTarget;q.style.backgroundColor="",Array.from(q.querySelectorAll("td")).forEach(K=>{K.style.position==="sticky"&&(K.style.backgroundColor=Ut)})},children:[t.map((H,q)=>{const K=H.render?H.render(L,z,r):ze(L,H.accessor),je=m>0&&q<m,Se=me[q]??0,Te=Ne[q]!==void 0,Oe=je&&q===m-1;return e.jsx(U.Td,{style:{position:je?"sticky":void 0,left:je?Se:void 0,zIndex:je?1:void 0,backgroundColor:je?Ut:void 0,transition:je?"background-color 0.3s ease":void 0,paddingLeft:q===0?"12px":"",whiteSpace:"nowrap",overflow:Te?"hidden":void 0,borderLeft:H.showBorderLeft?ae:void 0,borderRight:H.showBorderRight?ae:void 0,boxShadow:Oe?ce:void 0,textAlign:H.textAlign==="text-right"?"right":H.textAlign==="text-center"?"center":"left",...k(q,H.width)},children:typeof K=="string"?e.jsx(C.Text,{style:{whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",textAlign:H.textAlign==="text-right"?"right":H.textAlign==="text-center"?"center":"left"},children:K}):K},`row-${z}-col-${q}`)}),J?e.jsx(U.Td,{style:{width:we,position:"sticky",right:0,zIndex:1,backgroundColor:Ut,boxShadow:b?ee:void 0,transition:"background-color 0.3s ease"},children:e.jsx(oe.Flex,{direction:"row",align:"center",justify:"center",gap:"sm",children:M.map(H=>{const q=z===r.length-1?"top":"bottom";return H==="detail"&&n&&(d==null?void 0:d(L))!==!1?e.jsx(ve.Tooltip,{label:"Detail",position:q,children:e.jsx(V.Button,{size:"xs",variant:"outline",tone:"neutral",onClick:()=>n(L.id,L),iconLeft:e.jsx(B.Icon,{name:"DocumentClean",size:"sm",style:{color:"var(--sa-text-subtle, #8c8f97)"}})})},"detail"):H==="update"&&i&&(l==null?void 0:l(L))!==!1?e.jsx(ve.Tooltip,{label:"Update",position:q,children:e.jsx(V.Button,{size:"xs",variant:"outline",tone:"neutral",onClick:()=>i(L),iconLeft:e.jsx(B.Icon,{name:"Edit1",size:"sm",style:{color:"var(--sa-text-subtle, #8c8f97)"}})})},"update"):H==="delete"&&o&&(c==null?void 0:c(L))!==!1?e.jsx(ve.Tooltip,{label:"Delete",position:q,children:e.jsx(V.Button,{size:"xs",variant:"outline",tone:"neutral",onClick:()=>o(L.id,L),iconLeft:e.jsx(B.Icon,{name:"Trash1",size:"sm",style:{color:"var(--sa-color-error-600, #c9184a)"}})})},"delete"):H==="custom"?e.jsx(u.Fragment,{children:j==null?void 0:j(L)},"custom"):null})})}):null]},`${L}${z}`))})]})})},Ci=({wrapperProps:t,dataTableProps:r,headerProps:n,footerProps:i})=>{var m;const o=u.useRef(null),[s,c]=u.useState((r==null?void 0:r.defaultFrozenCount)??0),l=(n==null?void 0:n.show)??!0,d=u.useRef(null),a=(m=r==null?void 0:r.pagination)==null?void 0:m.totalData;typeof a=="number"&&(d.current=a);const f=(i==null?void 0:i.showFooter)??(a===void 0?d.current!==0:a!==0);return e.jsxs(Sn,{...t,children:[l&&e.jsx(kn,{...n}),e.jsx(h.Box,{direction:"column",ref:o,style:{flex:1,overflowY:"auto",overflowX:"auto"},children:r?e.jsx(En,{...r,scrollParentRef:o,frozenCount:r!=null&&r.enableFreezeColumns?s:0,onFrozenCountChange:r!=null&&r.enableFreezeColumns?c:void 0}):null}),f&&e.jsx(Bn,{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:i==null?void 0:i.totalData})]})};function wi(t){return u.memo(t)}const Di=wi(Ci),qr=200,Jt="1px solid var(--sa-border-subtle, #0b120e24)",Si=({sortDir:t,frozen:r})=>t==="asc"?e.jsx(B.Icon,{name:"ChevronSmallUp"}):t==="desc"?e.jsx(B.Icon,{name:"ChevronSmallDown"}):r?e.jsx(B.Icon,{name:"LockOn",size:"xs"}):e.jsx(B.Icon,{name:"Filter",size:"xs"}),bt=({icon:t,label:r,active:n,danger:i,onClick:o})=>{const s=i?"var(--sa-color-error-600, #c9184a)":"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:s,textAlign:"left"},onMouseEnter:c=>{n||(c.currentTarget.style.background="var(--sa-background-primary-inverse, #f8f8f8)")},onMouseLeave:c=>{c.currentTarget.style.background=n?"var(--sa-background-brand-subtlest, #e6edf6)":"none"},children:[e.jsx(B.Icon,{name:t,size:"sm",style:{color:s,flexShrink:0}}),e.jsx(C.Text,{as:"span",style:{color:s},children:r})]})},Mn=({active:t,canSort:r,canHide:n,sortDir:i,frozen:o,onSort:s,onClearSort:c,onToggleFreeze:l,onHide:d})=>{const[a,f]=u.useState(!1),m=u.useRef(null),g=u.useRef(null),[j,M]=u.useState({top:0,left:0});u.useEffect(()=>{if(a&&m.current){const D=m.current.getBoundingClientRect(),E=D.left+qr>window.innerWidth;M({top:D.bottom+6,...E?{right:window.innerWidth-D.right}:{left:D.left}})}},[a]),u.useEffect(()=>{if(!a)return;const D=E=>{g.current&&!g.current.contains(E.target)&&m.current&&!m.current.contains(E.target)&&f(!1)};return document.addEventListener("mousedown",D),()=>document.removeEventListener("mousedown",D)},[a]);const y=D=>{D(),f(!1)};return e.jsxs(e.Fragment,{children:[e.jsx("button",{ref:m,type:"button",className:"sa-tl-menu-trigger","data-active":t||a?"true":"false",onClick:D=>{D.stopPropagation(),f(E=>!E)},title:"Column options",style:{display:"inline-flex",alignItems:"center",justifyContent:"center",width:22,height:22,borderRadius:"var(--sa-radii-sm, 6px)",border:Jt,background:"var(--sa-background-primary, #ffffff)",cursor:"pointer",color:"var(--sa-text-subtle, #8c8f97)",flexShrink:0},children:e.jsx(Si,{sortDir:i,frozen:o})}),a&&e.jsxs(h.Box,{ref:g,onClick:D=>D.stopPropagation(),style:{position:"fixed",top:`${j.top}px`,...j.left!==void 0?{left:`${j.left}px`}:{right:`${j.right}px`},minWidth:qr,backgroundColor:"var(--sa-background-primary, #ffffff)",border:Jt,borderRadius:"var(--sa-radii-sm, 6px)",boxShadow:"0 6px 24px rgba(0,0,0,0.12)",zIndex:9999,padding:"4px",display:"flex",flexDirection:"column"},children:[r&&e.jsxs(e.Fragment,{children:[e.jsx(bt,{icon:"ChevronUp",label:"Ascending",active:i==="asc",onClick:()=>y(()=>i==="asc"?c():s("asc"))}),e.jsx(bt,{icon:"ChevronDown",label:"Descending",active:i==="desc",onClick:()=>y(()=>i==="desc"?c():s("desc"))}),e.jsx("div",{style:{borderTop:Jt,margin:"4px 0"}})]}),e.jsx(bt,{icon:"Pin1",label:o?"Unfreeze":"Freeze",active:o,onClick:()=>y(l)}),n&&e.jsx(bt,{icon:"EyeClosed",label:"Hide column",danger:!0,onClick:()=>y(d)})]})]})},vt="1px solid var(--sa-border-subtle, #0b120e24)",ki="var(--sa-text-subtle, #8c8f97)",dt="var(--sa-background-neutral, #f0f1f2)",Zr="2px 0 4px -2px rgba(0,0,0,0.15)",Ct={display:"block",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},Gr="sa-table-layout-styles",Bi=()=>{if(typeof document>"u"||document.getElementById(Gr))return;const t=document.createElement("style");t.id=Gr,t.textContent=`
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const yr=require("@starasia/alert"),qe=require("@starasia/badges"),h=require("@starasia/box"),nt=require("@starasia/breadcrumb"),V=require("@starasia/button"),pr=require("@starasia/card"),Ke=require("@starasia/date"),Re=require("@starasia/dialog"),Ft=require("@starasia/drawer"),it=require("@starasia/dropdown"),he=require("@starasia/hooks"),st=require("@starasia/http"),Ze=require("@starasia/input"),I=require("@starasia/menu"),xt=require("@starasia/pagination"),ut=require("@starasia/storage"),U=require("@starasia/table"),jr=require("@starasia/tabs"),$t=require("@starasia/textarea"),ot=require("@starasia/theme"),br=require("@starasia/toast"),lt=require("@starasia/toggle"),ve=require("@starasia/tooltip"),ct=require("@starasia/checkbox"),er=require("@starasia/radio"),C=require("@starasia/text"),B=require("@starasia/icon"),oe=require("@starasia/flex"),vr=require("@starasia/grid"),Cr=require("@starasia/progress"),wr=require("@starasia/stepper"),Dr=require("@starasia/accordion"),Sr=require("@starasia/story-record"),Pe=require("@starasia/skeleton"),kr=require("@starasia/progress-stepper"),e=require("react/jsx-runtime"),u=require("react"),pe=require("react-router"),nr=require("react-dom"),Yn=require("react-easy-crop"),Xn={menus:[],menuBottom:void 0,logo:"",appName:"Workspace",userData:null,setUserData:()=>{}},or=u.createContext(Xn),ir=()=>u.useContext(or),Xr=t=>{const[r,n]=u.useState((t==null?void 0:t.initialUserData)||null);return{userData:r,setUserData:n}},Kr=u.createContext({badges:{},setBadge:()=>{},setBadges:()=>{},clearBadge:()=>{}}),$r=({children:t})=>{const[r,n]=u.useState({}),i=u.useCallback(l=>{n(d=>typeof l=="function"?l(d):l)},[]),o=u.useCallback((l,d)=>{n(a=>{const f=typeof d=="function"?d(a[l]):d;return{...a,[l]:f}})},[]),s=u.useCallback(l=>{n(d=>{if(!(l in d))return d;const a={...d};return delete a[l],a})},[]),c=u.useMemo(()=>({badges:r,setBadge:o,setBadges:i,clearBadge:s}),[r,o,i,s]);return e.jsx(Kr.Provider,{value:c,children:t})},en=()=>u.useContext(Kr),St=(t,r)=>{const n=r!==void 0?r:t;return n==null?null:typeof n=="string"||typeof n=="number"?{value:n}:n},tn=({router:t,menus:r=[],menuBottom:n,logo:i,appName:o="Workspace",initialUserData:s,theme:c})=>{const l=Xr({initialUserData:s}),{theme:d}=ot.useTheme();return e.jsx(or.Provider,{value:{logo:i,appName:o,menus:r,userData:l.userData,setUserData:l.setUserData,menuBottom:n},children:e.jsx($r,{children:c?e.jsx(ot.ThemeProvider,{value:c,children:t}):d?e.jsx(ot.ThemeProvider,{value:d,children:t}):t})})},Kn=u.memo(tn);function rn({collapsed:t=!1,children:r}){if(!r)return null;const n=typeof r=="function",i=n?r({collapsed:t}):r;return i==null||i===!1?null:e.jsx("div",{style:{position:"sticky",top:"4rem",zIndex:1,borderBottom:"1px solid var(--sa-border-subtle, #0b120e24)",paddingLeft:"0.5rem",paddingRight:"0.5rem",paddingTop:"0.5rem",paddingBottom:"0.5rem",boxSizing:"border-box"},children:n?i:e.jsx("div",{style:{opacity:t?0:1,transition:"opacity 0.3s",visibility:t?"hidden":"visible"},children:i})})}const sr=u.createContext(null);function nn({children:t}){const[r,n]=u.useState(null),[i,o]=u.useState(null),[s,c]=u.useState(null),[l,d]=u.useState(0),a=u.useCallback(()=>(d(f=>f+1),()=>d(f=>f-1)),[]);return e.jsx(sr.Provider,{value:{prependNode:r,appendNode:i,replaceNode:s,setPrependNode:n,setAppendNode:o,setReplaceNode:c,replaceCount:l,registerReplace:a},children:t})}function on({children:t}){const r=u.useContext(sr);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 $n({children:t,mode:r="append"}){const n=u.useContext(sr);if(u.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 i=r==="prepend"?n.prependNode:r==="replace"?n.replaceNode:n.appendNode;return i?nr.createPortal(t,i):null}const lr=u.createContext(null);function sn({children:t}){const[r,n]=u.useState({}),[i,o]=u.useState({}),s=u.useCallback((d,a)=>{n(f=>f[d]===a?f:{...f,[d]:a})},[]),c=u.useCallback(d=>(o(a=>({...a,[d]:(a[d]??0)+1})),()=>o(a=>({...a,[d]:Math.max(0,(a[d]??0)-1)}))),[]),l=u.useMemo(()=>({outletNodes:r,setOutletNode:s,slotCounts:i,registerSlot:c}),[r,s,i,c]);return e.jsx(lr.Provider,{value:l,children:t})}function ln({slotKey:t,fallback:r}){const n=u.useContext(lr),i=n?(n.slotCounts[t]??0)>0:!1,o=u.useRef(n==null?void 0:n.setOutletNode);o.current=n==null?void 0:n.setOutletNode;const s=u.useCallback(c=>{var l;return(l=o.current)==null?void 0:l.call(o,t,c)},[t]);return e.jsx(e.Fragment,{children:i?e.jsx("div",{ref:s,style:{display:"contents"}}):r})}function eo({slotKey:t,children:r}){const n=u.useContext(lr),i=u.useRef(n==null?void 0:n.registerSlot);if(i.current=n==null?void 0:n.registerSlot,u.useEffect(()=>{var s;return(s=i.current)==null?void 0:s.call(i,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?nr.createPortal(r,o):null}const Et="moduleSwitcherGroupId",tr="sa-module-switcher-change";function Br(){if(typeof window>"u")return null;const t=window.localStorage.getItem(Et);if(t===null)return null;const r=Number(t);return Number.isFinite(r)?r:null}function cn(t){typeof window>"u"||(t===null?window.localStorage.removeItem(Et):window.localStorage.setItem(Et,String(t)),window.dispatchEvent(new CustomEvent(tr,{detail:t})))}function to(){cn(null)}function cr(){const[t,r]=u.useState(()=>Br());return u.useEffect(()=>{const i=()=>{r(Br())},o=s=>{s.key===Et&&i()};return window.addEventListener(tr,i),window.addEventListener("storage",o),()=>{window.removeEventListener(tr,i),window.removeEventListener("storage",o)}},[]),{selectedGroupId:t,setSelectedGroupId:i=>{cn(i),r(i)}}}let pt=0,Xe=!1,Fr=new Set;const Er=()=>e.jsxs("svg",{width:"100%",height:"100%",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.25",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[e.jsx("rect",{x:"1.667",y:"1.667",width:"12.667",height:"12.667",rx:"2"}),e.jsx("line",{x1:"6",y1:"1.667",x2:"6",y2:"14.333"})]}),Mr={width:"100%",display:"flex",alignItems:"center",gap:"0.75rem",paddingLeft:"0.75rem",paddingRight:"0.75rem",paddingTop:"0.5rem",paddingBottom:"0.5rem",fontSize:"0.875rem",color:"var(--sa-text-subtle, #8c8f97)",background:"transparent",border:"none",borderRadius:"0.375rem",cursor:"pointer",textAlign:"left"};function ro({children:t,headerLeftSlot:r,profile:n,isLoadingProfile:i,onLogout:o,isLoggingOut:s,loadingComponent:c,sidebarHeaderContent:l,headerActions:d,profileRole:a,profileMenuButtons:f,profileMenuItems:m,logoutButton:g}){var Fe,Ge;const[j]=pe.useSearchParams(),M=j.get("embed")==="true",y=ir(),{badges:D}=en(),E=pe.useNavigate(),T=pe.useLocation(),v=!he.useMediaQuery("md"),[R,O]=u.useState(!1),[b,S]=u.useState(!1),[P,A]=u.useState(!1),[N,G]=u.useState(!1),[re,xe]=u.useState(()=>new Set(Fr)),[ne,se]=u.useState(null),{selectedGroupId:J,setSelectedGroupId:Q}=cr();u.useEffect(()=>{Fr=re},[re]);const ae=u.useRef(null),ee=u.useRef(null);u.useEffect(()=>{const k=ae.current;if(!k)return;const Z=()=>{Xe||(pt=k.scrollTop)};return k.addEventListener("scroll",Z),()=>k.removeEventListener("scroll",Z)},[]);const ce=()=>{const k=ae.current;k&&pt>0&&(Xe=!0,k.scrollTop=pt,requestAnimationFrame(()=>{Xe=!1}))};u.useLayoutEffect(()=>{Xe=!0,ce();const k=setTimeout(()=>{Xe=!1},300);return()=>clearTimeout(k)},[]),u.useLayoutEffect(()=>{y.menus.length>0&&(pt>0?ce():requestAnimationFrame(()=>{var Z;const k=(Z=ae.current)==null?void 0:Z.querySelector("[data-menu-active='true']");k&&k.scrollIntoView({block:"center",behavior:"instant"})}))},[y.menus]),u.useEffect(()=>{Xe=!0,ce();const k=setTimeout(ce,0),Z=setTimeout(ce,50),_=setTimeout(ce,100),L=setTimeout(ce,200),z=setTimeout(()=>{Xe=!1},300),H=setTimeout(()=>{const q=ae.current,K=q==null?void 0:q.querySelector("[data-menu-active='true']");if(q&&K){const je=q.getBoundingClientRect(),Se=K.getBoundingClientRect();Se.top>=je.top&&Se.bottom<=je.bottom||K.scrollIntoView({block:"center",behavior:"smooth"})}},250);return()=>{clearTimeout(k),clearTimeout(Z),clearTimeout(_),clearTimeout(L),clearTimeout(z),clearTimeout(H)}},[T.pathname]),u.useEffect(()=>{ee.current&&(ee.current.scrollTop=0)},[T.pathname]),u.useEffect(()=>{v&&A(!1)},[T.pathname,v]),u.useEffect(()=>{v&&S(!0)},[v]);const we=()=>{O(!0)},ze=()=>{O(!1)},fe=()=>{O(!1),o()},De=k=>{const Z=[k.to];return k.children&&Z.push(...k.children.map(_=>_.to)),Z},Me=[...y.menus.flatMap(k=>k.items.flatMap(De)),...((Fe=y.menuBottom)==null?void 0:Fe.flatMap(De))??[]],me=k=>{if(!T.pathname.startsWith(k))return!1;const Z=Me.filter(_=>T.pathname.startsWith(_)).sort((_,L)=>L.length-_.length)[0];return k===Z};u.useEffect(()=>{var Z;const k=_=>{var L;(L=_.children)!=null&&L.some(z=>T.pathname.startsWith(z.to))&&xe(z=>{const H=new Set(z);return H.add(_.id),H})};y.menus.forEach(_=>{_.items.forEach(k)}),(Z=y.menuBottom)==null||Z.forEach(k)},[T.pathname,y.menus,y.menuBottom]);const Ie=k=>{xe(Z=>{const _=new Set(Z);return _.has(k)?_.delete(k):_.add(k),_})};u.useEffect(()=>{y.menus.length!==0&&J!==null&&!y.menus.some(k=>k.id===J)&&Q(null)},[y.menus,J,Q]);const Ne=u.useMemo(()=>{if(J!==null)return y.menus.filter(_=>_.id===J||_.parentGroupId===J);const k=y.menus.filter(_=>_.parentGroupId===void 0),Z=y.menus.filter(_=>_.parentGroupId!==void 0).flatMap(_=>_.items);return Z.length===0?k:[...k,{id:18,name:"Pengaturan",items:Z,parentGroupId:void 0}]},[y.menus,J]);if(M)return e.jsx("main",{style:{height:"100vh",overflowY:"auto",backgroundColor:"var(--sa-background-primary-inverse, #f8f8f8)"},children:t||e.jsx(pe.Outlet,{})});const ge=k=>{const Z=k.children&&k.children.length>0,_=re.has(k.id),L=Z?k.children.some(q=>me(q.to)):me(k.to),z=St(k.badge,D[k.id]),H=!!z&&b&&!v;return e.jsxs("div",{"data-menu-active":L||void 0,children:[e.jsxs("button",{onClick:q=>{if(Z)if(b&&!v){const K=q.currentTarget.getBoundingClientRect();se({item:k,top:K.top,left:K.right+8})}else Ie(k.id);else E(k.to)},style:{width:"100%",display:"flex",alignItems:"center",justifyContent:b&&!v?"center":void 0,gap:"0.5rem",paddingLeft:b&&!v?"0":"0.5rem",paddingRight:b&&!v?"0":"0.5rem",paddingTop:"0.25rem",paddingBottom:"0.25rem",height:"2rem",borderRadius:L?"var(--sa-radii-sm, 0.375rem)":"var(--sa-radii-md, 0.5rem)",textAlign:"left",border:L?"1px solid var(--sa-border-subtle, #0b120e24)":"1px solid transparent",backgroundColor:L?"var(--sa-background-primary, #ffffff)":"transparent",color:"var(--sa-text-primary, #292a2e)",cursor:"pointer"},title:b&&!v?k.title:void 0,onMouseEnter:q=>{L||(q.currentTarget.style.backgroundColor="var(--sa-background-neutral, #f0f1f2)")},onMouseLeave:q=>{L||(q.currentTarget.style.backgroundColor="transparent")},children:[e.jsxs("span",{style:{position:"relative",display:"inline-flex",flexShrink:0},children:[e.jsx(B.Icon,{name:k.icon,size:"sm",style:{flexShrink:0}}),H&&e.jsx("span",{"aria-hidden":"true",style:{position:"absolute",top:"-2px",right:"-2px",width:"0.5rem",height:"0.5rem",borderRadius:"9999px",backgroundColor:"var(--sa-color-error-500, #ff4d6d)",border:"1px solid var(--sa-background-primary, #ffffff)"}})]}),(!b||v)&&e.jsxs(e.Fragment,{children:[e.jsx("span",{style:{fontSize:"0.875rem",fontWeight:"500",whiteSpace:"nowrap",transition:"opacity 0.3s",flex:1,minWidth:0,overflow:"hidden",textOverflow:"ellipsis"},children:k.title}),z&&e.jsx(qe.Badges,{text:String(z.value),variant:z.variant??"info",size:"xs",border:!0}),Z&&e.jsx("svg",{style:{width:"1rem",height:"1rem",flexShrink:0,transition:"transform 0.2s",transform:_?"rotate(180deg)":"rotate(0deg)"},fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 9l-7 7-7-7"})})]})]}),Z&&(!b||v)&&(()=>{const q=k.children.findIndex(K=>me(K.to));return e.jsxs("div",{style:{position:"relative",marginLeft:"0.9375rem",paddingLeft:"1.125rem",overflow:"hidden",transition:"all 0.3s ease-in-out",maxHeight:_?`${k.children.length*36}px`:"0px",opacity:_?1:0,marginTop:_?"0.25rem":"0px"},children:[e.jsx("span",{"aria-hidden":"true",style:{position:"absolute",left:0,top:0,width:"1.5px",height:"100%",backgroundColor:"var(--sa-border-subtle, #0b120e24)",pointerEvents:"none"}}),q>=0&&e.jsx("span",{"aria-hidden":"true",style:{position:"absolute",left:0,top:`${q*32}px`,width:"1.5px",height:"32px",backgroundColor:"var(--sa-text-primary, #292a2e)",transition:"top 0.2s ease-in-out",pointerEvents:"none",zIndex:1}}),k.children.map(K=>{const je=St(K.badge,D[K.id]);return e.jsxs("button",{onClick:()=>E(K.to),style:{width:"100%",display:"flex",alignItems:"center",gap:"0.5rem",paddingLeft:"0.75rem",paddingRight:"0.5rem",paddingTop:"0.25rem",paddingBottom:"0.25rem",height:"2rem",borderRadius:me(K.to)?"var(--sa-radii-sm, 0.375rem)":"var(--sa-radii-md, 0.5rem)",textAlign:"left",backgroundColor:me(K.to)?"var(--sa-background-primary, #ffffff)":"transparent",color:me(K.to)?"var(--sa-text-primary, #292a2e)":"var(--sa-text-subtle, #505258)",cursor:"pointer",border:me(K.to)?"1px solid var(--sa-border-subtle, #0b120e24)":"1px solid transparent"},onMouseEnter:Se=>{me(K.to)||(Se.currentTarget.style.backgroundColor="var(--sa-background-neutral, #f0f1f2)")},onMouseLeave:Se=>{me(K.to)||(Se.currentTarget.style.backgroundColor="transparent")},children:[e.jsx(B.Icon,{name:K.icon,size:"sm",style:{flexShrink:0}}),e.jsx("span",{style:{fontSize:"0.875rem",fontWeight:"500",whiteSpace:"nowrap",flex:1,minWidth:0,overflow:"hidden",textOverflow:"ellipsis"},children:K.title}),je&&e.jsx(qe.Badges,{text:String(je.value),variant:je.variant??"info",size:"xs",border:!0})]},K.id)})]})})()]},k.id)};return e.jsx(sn,{children:e.jsxs(nn,{children:[e.jsxs("div",{style:{display:"flex",height:"100vh",position:"relative","--app-sidebar-width":v?"0px":b?"4.375rem":"16.375rem","--app-footer-zindex":v&&P?"40":"999"},children:[v&&e.jsx("div",{style:{position:"fixed",inset:0,backgroundColor:"var(--sa-color-black-alpha-a50, #181a198f)",zIndex:40,opacity:P?.5:0,pointerEvents:P?"auto":"none",transition:"opacity 0.3s"},onClick:()=>A(!1)}),e.jsxs("aside",{style:{width:v?"16.375rem":b?"4.375rem":"16.375rem",position:v?"fixed":"relative",...v&&{inset:0,zIndex:50,transform:P?"translateX(0)":"translateX(-100%)"},backgroundColor:"var(--sa-background-primary-inverse, #f8f8f8)",borderRight:"1px solid var(--sa-border-subtle, #0b120e24)",display:"flex",flexDirection:"column",transition:"all 0.3s ease-in-out",flexShrink:v?void 0:0},children:[e.jsx("div",{onMouseEnter:()=>G(!0),onMouseLeave:()=>G(!1),style:{height:"4rem",display:"flex",alignItems:"center",justifyContent:"space-between",paddingLeft:"1rem",paddingRight:"1rem",borderBottom:"1px solid var(--sa-border-subtle, #0b120e24)",position:"relative"},children:(()=>{const k=!v&&b&&!P,Z=k&&N;return e.jsxs(e.Fragment,{children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"0.5rem",flex:k?1:void 0,justifyContent:k?"center":void 0,transition:"opacity 0.2s",opacity:Z?0:1,pointerEvents:Z?"none":"auto"},children:[e.jsx("img",{src:y.logo,alt:"Logo",style:{width:"2rem",height:"2rem",flexShrink:0}}),(!b||P)&&e.jsx("span",{style:{fontWeight:"600",color:"var(--sa-text-primary, #292a2e)",whiteSpace:"nowrap",transition:"opacity 0.3s"},children:y.appName})]}),!v&&!b&&e.jsx("button",{type:"button",onClick:()=>S(!0),"aria-label":"Collapse sidebar",style:{display:"inline-flex",alignItems:"center",justifyContent:"center",width:"1rem",height:"1rem",padding:0,background:"transparent",border:"none",color:"var(--sa-text-subtle, #8c8f97)",cursor:"pointer",flexShrink:0},children:e.jsx(Er,{})}),k&&e.jsx("button",{type:"button",onClick:()=>S(!1),"aria-label":"Expand sidebar",style:{position:"absolute",top:"50%",left:"50%",transform:"translate(-50%, -50%)",display:"inline-flex",alignItems:"center",justifyContent:"center",width:"2rem",height:"2rem",padding:0,background:"var(--sa-background-primary, #ffffff)",border:"1px solid var(--sa-border-subtle, #0b120e24)",borderRadius:"var(--sa-radii-sm, 0.375rem)",color:"var(--sa-text-primary, #292a2e)",cursor:"pointer",opacity:Z?1:0,pointerEvents:Z?"auto":"none",transition:"opacity 0.2s"},children:e.jsx("span",{style:{width:"1rem",height:"1rem",display:"inline-flex"},children:e.jsx(Er,{})})}),v&&e.jsx("button",{onClick:()=>A(!1),"aria-label":"Close menu",style:{padding:"0.375rem",borderRadius:"0.5rem",backgroundColor:"transparent",border:"none",color:"var(--sa-text-subtle, #8c8f97)",cursor:"pointer"},children:e.jsx("svg",{style:{width:"1.25rem",height:"1.25rem"},fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]})})()}),l&&e.jsx(rn,{collapsed:v?!1:b,children:l}),e.jsx("div",{ref:ae,style:{flex:1,overflowY:"auto",paddingTop:"1rem",paddingBottom:"1rem"},children:Ne.map(k=>e.jsxs("div",{style:{marginBottom:"1rem"},children:[!b||v?k.name&&e.jsx("div",{style:{paddingLeft:"1.5rem",paddingRight:"1rem",paddingTop:"0rem",paddingBottom:"0.25rem",fontSize:"0.875rem",fontWeight:"400",color:"var(--sa-text-subtlest, #6b6e76)",transition:"opacity 0.3s",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:k.name}):k.name&&e.jsx("div",{"aria-label":k.name,style:{display:"flex",alignItems:"center",justifyContent:"center",paddingTop:"0.75rem",paddingBottom:"0.75rem"},children:e.jsx("span",{style:{display:"block",width:"1rem",height:"2px",borderRadius:"1px",backgroundColor:k.color??"var(--sa-background-brand, #04254f)"}})}),e.jsx("div",{style:{paddingLeft:"1rem",paddingRight:"1rem",display:"flex",flexDirection:"column",gap:"var(--sa-spacing-xs, 0.25rem)"},children:k.slotKey?e.jsx(ln,{slotKey:k.slotKey,fallback:k.items.map(Z=>ge(Z))}):k.items.map(Z=>ge(Z))})]},k.id))}),y.menuBottom&&y.menuBottom.length>0&&e.jsx("div",{style:{borderTop:"1px solid var(--sa-border-subtle, #0b120e24)",paddingTop:"0.75rem",paddingBottom:"0.75rem",paddingLeft:"1rem",paddingRight:"1rem",backgroundColor:"var(--sa-background-primary-inverse, #f8f8f8)",display:"flex",flexDirection:"column",gap:"var(--sa-spacing-xs, 0.25rem)",flexShrink:0},children:y.menuBottom.map(k=>ge(k))})]}),e.jsxs("div",{style:{flex:1,display:"flex",flexDirection:"column",overflow:"hidden"},children:[e.jsxs("header",{style:{height:"4rem",backgroundColor:"var(--sa-background-primary, #ffffff)",borderBottom:"1px solid var(--sa-border-subtle, #0b120e24)",display:"flex",alignItems:"center",justifyContent:"space-between",paddingLeft:"1rem",paddingRight:"1rem",flexShrink:0},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:v?"1rem":void 0},children:[v&&e.jsx("button",{onClick:()=>A(!0),style:{padding:"0.375rem",borderRadius:"0.5rem",backgroundColor:"transparent",border:"none",color:"var(--sa-text-subtle, #8c8f97)",cursor:"pointer"},children:e.jsx("svg",{style:{width:"1.5rem",height:"1.5rem"},fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M4 6h16M4 12h16M4 18h16"})})}),e.jsx(on,{children:r})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"0.75rem"},children:[d,e.jsxs(I.Menu,{position:"bottom-right",children:[e.jsx(I.MenuButton,{children:e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"0.5rem",cursor:"pointer"},children:[e.jsxs("div",{style:{textAlign:"right",maxWidth:"12.5rem"},children:[e.jsx("p",{style:{margin:0,fontSize:"0.875rem",fontWeight:500,color:"var(--sa-text-subtle, #8c8f97)",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:i?"Loading...":(n==null?void 0:n.name)||"unknown"}),e.jsx("p",{style:{margin:0,fontSize:"0.75rem",color:"var(--sa-text-subtle, #8c8f97)",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:i?"":(n==null?void 0:n.email)||"unknown"})]}),e.jsx("div",{style:{width:"2.5rem",height:"2.5rem",borderRadius:"9999px",display:"flex",alignItems:"center",justifyContent:"center",color:"var(--sa-background-primary, #ffffff)",fontWeight:600,fontSize:"0.875rem",boxShadow:"var(--sa-shadow-sm, 0 1px 2px 0 #0000000d)",flexShrink:0,backgroundColor:"var(--sa-background-brand, #04254f)"},children:((n==null?void 0:n.name)||"U")[0].toUpperCase()}),e.jsx(B.Icon,{name:"ChevronDown",size:"sm",style:{color:"var(--sa-text-subtle, #8c8f97)"}})]})}),e.jsxs(I.MenuLists,{style:{width:"280px",paddingBlock:"12px",paddingInline:"12px",gap:"8px",marginTop:"16px"},children:[e.jsx(I.MenuHeading,{children:e.jsxs("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",textAlign:"center",paddingBlock:"0.5rem"},children:[e.jsx("div",{style:{width:"4rem",height:"4rem",borderRadius:"9999px",display:"flex",alignItems:"center",justifyContent:"center",color:"var(--sa-background-primary, #ffffff)",fontWeight:600,fontSize:"1.25rem",boxShadow:"var(--sa-shadow-sm, 0 1px 2px 0 #0000000d)",marginBottom:"0.75rem",backgroundColor:"var(--sa-background-brand, #04254f)"},children:((n==null?void 0:n.name)||"U")[0].toUpperCase()}),e.jsx("p",{style:{margin:0,fontSize:"0.875rem",fontWeight:600,color:"var(--sa-text-primary, #292a2e)",maxWidth:"100%",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:(n==null?void 0:n.name)||"unknown"}),e.jsx("p",{style:{margin:0,fontSize:"0.75rem",color:"var(--sa-text-subtle, #8c8f97)",maxWidth:"100%",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:(n==null?void 0:n.email)||"unknown"}),a&&e.jsx("p",{style:{margin:0,fontSize:"0.75rem",color:"var(--sa-text-subtle, #8c8f97)",maxWidth:"100%",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:a})]})}),(f&&f.length>0||m)&&e.jsxs(I.MenuBody,{children:[f==null?void 0:f.map((k,Z)=>e.jsx(I.MenuButton,{children:e.jsxs("button",{type:"button",onClick:k.onClick,style:Mr,onMouseEnter:_=>{_.currentTarget.style.backgroundColor="var(--sa-background-neutral, #f0f1f2)"},onMouseLeave:_=>{_.currentTarget.style.backgroundColor="transparent"},children:[e.jsx(B.Icon,{name:k.icon,size:"md"}),e.jsx("span",{children:k.label})]})},`${k.label}-${Z}`)),m]}),g??e.jsx(I.MenuFooter,{children:e.jsx(I.MenuButton,{children:e.jsxs("button",{type:"button",onClick:we,style:{...Mr,color:"var(--sa-background-error, #c9184a)",fontWeight:500},onMouseEnter:k=>{k.currentTarget.style.backgroundColor="var(--sa-color-error-50, #fff0f3)"},onMouseLeave:k=>{k.currentTarget.style.backgroundColor="transparent"},children:[e.jsx(B.Icon,{name:"Logout",size:"md",style:{color:"var(--sa-background-error, #c9184a)"}}),e.jsx("span",{children:"Logout"})]})})})]})]})]})]}),e.jsx("main",{ref:ee,style:{flex:1,overflowY:"auto"},children:t||e.jsx(pe.Outlet,{})})]})]}),s&&c&&e.jsx("div",{style:{position:"fixed",inset:0,background:"var(--sa-color-black-alpha-a70, #181a19b8)",display:"flex",alignItems:"center",justifyContent:"center",zIndex:9999},children:c}),e.jsxs(Re.Dialog,{isShow:R,onHide:ze,children:[e.jsx(Re.DialogTitle,{children:"Confirmation Logout"}),e.jsx(Re.DialogBody,{children:"Are you sure you want to end the session and exit the page?"}),e.jsx(Re.DialogFooter,{children:e.jsx(h.Box,{direction:"column",display:"flex",align:"flex-end",justify:"center",children:e.jsxs(oe.Flex,{direction:"row",gap:"sm",align:"center",children:[e.jsx(h.Box,{direction:"column",children:e.jsx(V.Button,{secondary:!0,onClick:ze,children:"Cancel"})}),e.jsx(h.Box,{direction:"column",children:e.jsx(V.Button,{primary:!0,onClick:fe,children:"Yes, Sure"})})]})})})]}),ne&&e.jsxs(e.Fragment,{children:[e.jsx("div",{onClick:()=>se(null),style:{position:"fixed",inset:0,zIndex:60,backgroundColor:"transparent"}}),e.jsxs("div",{role:"dialog","aria-label":ne.item.title,style:{position:"fixed",top:ne.top,left:ne.left,zIndex:61,minWidth:"13rem",maxWidth:"16rem",backgroundColor:"var(--sa-background-primary, #ffffff)",border:"1px solid var(--sa-border-subtle, #0b120e24)",borderRadius:"var(--sa-radii-md, 0.5rem)",boxShadow:"var(--sa-shadow-lg, 0 10px 15px -3px #0000001a, 0 4px 6px -4px #0000001a)",padding:"0.5rem",display:"flex",flexDirection:"column",gap:"0.125rem"},children:[e.jsx("div",{style:{fontSize:"0.75rem",fontWeight:600,color:"var(--sa-color-gray-500, #8c8f97)",padding:"0.25rem 0.5rem 0.5rem",textTransform:"uppercase",letterSpacing:"0.05em"},children:ne.item.title}),(Ge=ne.item.children)==null?void 0:Ge.map(k=>{const Z=me(k.to),_=St(k.badge,D[k.id]);return e.jsxs("button",{onClick:()=>{E(k.to),se(null)},style:{width:"100%",display:"flex",alignItems:"center",gap:"0.75rem",padding:"0.5rem 0.75rem",borderRadius:"var(--sa-radii-md, 0.5rem)",textAlign:"left",backgroundColor:Z?"var(--sa-color-gray-100, #f8f8f8)":"transparent",color:Z?"var(--sa-text-primary, #292a2e)":"var(--sa-color-gray-800, #505258)",border:"1px solid transparent",cursor:"pointer",fontSize:"0.875rem",fontWeight:500},onMouseEnter:L=>{Z||(L.currentTarget.style.backgroundColor="var(--sa-color-gray-100, #f8f8f8)")},onMouseLeave:L=>{Z||(L.currentTarget.style.backgroundColor="transparent")},children:[k.icon&&e.jsx(B.Icon,{name:k.icon,size:"sm",style:{flexShrink:0}}),e.jsx("span",{style:{flex:1,whiteSpace:"nowrap"},children:k.title}),_&&e.jsx(qe.Badges,{text:String(_.value),variant:_.variant??"info",size:"xs",border:!0})]},k.id)})]})]})]})})}const ft=u.forwardRef(({children:t,...r},n)=>e.jsx(h.Box,{ref:n,role:"button",cursor:"pointer","aria-pressed":"true",display:"inline-block",tabIndex:0,...r,children:t})),Lr=({title:t,iconName:r,textColor:n,iconColor:i,hoverTextColor:o,hoverIconColor:s})=>{const[c,l]=u.useState(!1),d=i??"var(--sa-text-subtle, #8c8f97)",a=n??"var(--sa-text-subtle, #8c8f97)",f=s??"var(--sa-text-subtle, #8c8f97)",m=o??"var(--sa-text-primary, #292a2e)";return e.jsxs(h.Box,{direction:"row",gap:"xs",align:"center",onMouseEnter:()=>l(!0),onMouseLeave:()=>l(!1),style:{cursor:"pointer"},children:[e.jsx(B.Icon,{name:r||"ChevronLeft",size:"xs",style:{color:c?f:d,transition:"color 0.15s ease"}}),e.jsx(C.Text,{variant:"sub-h3",style:{color:c?m:a,transition:"color 0.15s ease"},children:t||"Back"})]})},no=({items:t,separator:r="/",iconName:n,iconColor:i,hoverIconColor:o})=>{const[s,c]=u.useState(!1),l=i??"var(--sa-text-subtle, #8c8f97)",d=o??"var(--sa-text-subtle, #8c8f97)",a=t.length>1?t[0]:void 0,f=!!(a!=null&&a.to||a!=null&&a.onClick),m=e.jsx(B.Icon,{name:n||"ChevronLeft",size:"xs",onMouseEnter:f?()=>c(!0):void 0,onMouseLeave:f?()=>c(!1):void 0,style:{color:f&&s?d:l,transition:"color 0.15s ease",cursor:f?"pointer":void 0}}),g=a!=null&&a.to?e.jsx(pe.Link,{to:a.to,replace:!0,style:{textDecoration:"none"},children:m}):a!=null&&a.onClick?e.jsx(ft,{onClick:a.onClick,children:m}):m;return e.jsxs(h.Box,{direction:"row",gap:"xs",align:"center",children:[g,e.jsx(nt.Breadcrumb,{separator:r,size:"md",children:t.map((j,M)=>{const y=M===t.length-1;return j.to&&!y?e.jsx(nt.BreadcrumbItem,{children:e.jsx(pe.Link,{to:j.to,children:j.label})},M):e.jsx(nt.BreadcrumbItem,{currentPage:y,children:e.jsx(nt.BreadcrumbLink,{onClick:y?void 0:j.onClick,children:j.label})},M)})})]})},oo=t=>{const{items:r,separator:n,onClick:i,navigateTo:o,...s}=t;return r&&r.length>0?e.jsx(no,{items:r,separator:n,iconName:s.iconName,iconColor:s.iconColor,hoverIconColor:s.hoverIconColor}):o?e.jsx(h.Box,{direction:"row",children:e.jsx(pe.Link,{to:o,replace:!0,style:{textDecoration:"none"},children:e.jsx(Lr,{...s})})}):e.jsx(h.Box,{direction:"row",children:e.jsx(ft,{onClick:i,children:e.jsx(Lr,{...s})})})},qt=[{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 Ir(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 Tr={fontSize:"11px",fontWeight:500,textAlign:"center",overflowWrap:"normal",wordBreak:"normal",color:"var(--sa-background-primary, #ffffff)",lineHeight:"1.3",maxWidth:"80px"},Or={display:"flex",flexDirection:"column",alignItems:"center",gap:"8px",background:"none",border:"none",cursor:"pointer",padding:0};function an({isShow:t,onHide:r,menus:n,selectedGroupId:i,onSelect:o}){const[s,c]=u.useState(void 0),l=a=>{o(a),r()},d=qt[0];return e.jsx(Re.Dialog,{isShow:t,onHide:r,style:{width:560,background:"transparent",boxShadow:"none",border:"none"},children:e.jsx(Re.DialogBody,{children:e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(5, 1fr)",gap:"16px"},children:[e.jsxs("button",{onClick:()=>l(null),onMouseEnter:()=>c("all"),onMouseLeave:()=>c(void 0),style:Or,children:[e.jsx("div",{style:Ir(i===null,s==="all",d),children:e.jsx("div",{style:{color:d.icon,display:"flex",alignItems:"center",justifyContent:"center"},children:e.jsx(B.Icon,{name:"Grid",size:"lg",style:{width:32,height:32}})})}),e.jsx("span",{style:Tr,children:"Semua"})]}),n.map((a,f)=>{var y;const m=i===a.id,g=s===a.id,j=((y=a.items[0])==null?void 0:y.icon)??"Grid",M=qt[(f+1)%qt.length];return e.jsxs("button",{onClick:()=>l(a.id),onMouseEnter:()=>c(a.id),onMouseLeave:()=>c(void 0),style:Or,children:[e.jsx("div",{style:Ir(m,g,M),children:e.jsx("div",{style:{color:M.icon,display:"flex",alignItems:"center",justifyContent:"center"},children:e.jsx(B.Icon,{name:j,size:"lg",style:{width:32,height:32}})})}),e.jsx("span",{style:Tr,children:a.name})]},a.id)})]})})})}function io({onSelect:t,"aria-label":r="Pilih module"}={}){const n=ir(),i=pe.useNavigate(),{selectedGroupId:o,setSelectedGroupId:s}=cr(),[c,l]=u.useState(!1),d=a=>{var f;if(s(a),a!==null){const m=n.menus.find(j=>j.id===a),g=(f=m==null?void 0:m.items[0])==null?void 0:f.to;g&&i(g)}t==null||t(a)};return e.jsxs(e.Fragment,{children:[e.jsxs("div",{style:{position:"relative"},children:[e.jsx("button",{onClick:()=>l(!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:a=>{a.currentTarget.style.backgroundColor="var(--sa-background-primary-inverse, #f8f8f8)"},onMouseLeave:a=>{a.currentTarget.style.backgroundColor="transparent"},children:e.jsx(B.Icon,{name:"GridApplication",size:"sm"})}),o!==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(an,{isShow:c,onHide:()=>l(!1),menus:n.menus.filter(a=>a.parentGroupId===void 0),selectedGroupId:o,onSelect:d})]})}const so=(t,r)=>{const n=[];if(r===0)return n.push(t),n;for(let i=0;i<t.length;i+=r){const o=t.slice(i,i+r);n.push(o)}return n},lo=u.memo(({value:t,label:r,separator:n,labelWidth:i,lastIndex:o,labelAlign:s="top"})=>{const c=u.useMemo(()=>({padding:0,paddingBottom:o?0:12,verticalAlign:s}),[o,s]),l=u.useMemo(()=>({padding:0,paddingRight:12,paddingLeft:12,paddingBottom:o?0:12,verticalAlign:s}),[o,s]),d=()=>typeof r=="string"?e.jsx(C.Text,{fontWeight:"medium",color:"subtlest",children:r}):r,a=()=>typeof t=="string"||typeof t=="number"?e.jsx(C.Text,{color:"primary",fontWeight:"medium",children:t}):t,f=()=>typeof n=="string"||typeof n=="number"?e.jsx(C.Text,{fontWeight:"medium",color:"subtlest",children:n}):n;return e.jsxs(U.Tr,{children:[e.jsx(U.Td,{style:c,width:i,children:d()}),n?e.jsx(U.Td,{style:l,width:24,children:f()}):null,e.jsx(U.Td,{style:c,children:a()})]})}),co=u.memo(({fields:t,separator:r,labelWidth:n})=>e.jsx(U.Table,{withColumnBorder:!1,withRowBorder:!1,children:t.map((i,o)=>e.jsx(lo,{separator:r,labelWidth:n,lastIndex:o===t.length-1,...i},`field-group-field-${o}`))})),ao=u.memo(({maxRow:t=0,maxColumn:r=2,separator:n=":",fields:i=[],labelWidth:o=150,bordered:s=!1})=>{const c=u.useMemo(()=>so(i,t),[i,t]),l=c.length>2,d=()=>{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(h.Box,{gap:l?void 0:"lg",direction:"row",flexWrap:"wrap",borderRadius:"rounded-sm",padding:"lg",paddingBottom:l?"xs":"lg",bg:"accent-dark-tertiary",borderWidth:s?"border":void 0,borderStyle:s?"border-solid":void 0,borderColor:s?"border-subtle":void 0,children:c.map((a,f)=>e.jsx(h.Box,{direction:"column",flex:l?void 0:"1",width:l?d():void 0,marginBottom:l?"lg":void 0,children:e.jsx(co,{labelWidth:o,fields:a,separator:n})},f))})}),uo=({backButton:t})=>{const[r,n]=u.useState(!1),i=(t==null?void 0:t.iconColor)??"var(--sa-text-subtle, #8c8f97)",o=(t==null?void 0:t.textColor)??"var(--sa-text-subtle, #8c8f97)",s=(t==null?void 0:t.hoverIconColor)??"var(--sa-text-subtle, #8c8f97)",c=(t==null?void 0:t.hoverTextColor)??"var(--sa-text-primary, #292a2e)";return e.jsxs(h.Box,{direction:"row",gap:"xs",align:"center",onMouseEnter:()=>n(!0),onMouseLeave:()=>n(!1),style:{cursor:"pointer"},children:[e.jsx(B.Icon,{name:(t==null?void 0:t.iconName)||"ChevronLeft",size:"xs",style:{color:r?s:i,transition:"color 0.15s ease"}}),e.jsx(C.Text,{variant:"sub-h3",style:{color:r?c:o,textDecoration:r?"underline":"none",transition:"color 0.15s ease"},children:(t==null?void 0:t.title)||"Back"})]})},xo=({backButton:t,title:r,titleIcon:n,titleTag:i,children:o,header:s=!0,headerBorder:c=!1,subHeaders:l,action:d,titleTagProps:a,containerProps:f,headerProps:m})=>{const g=he.useMediaQuery("md"),j=pe.useNavigate(),M=pe.useLocation(),y=t==null?void 0:t.show,D=()=>{if(typeof(t==null?void 0:t.onClick)=="function"){t.onClick();return}j(-1,{replace:!0})},E=()=>{if(!d)return null;if(u.isValidElement(d))return d;const b=d.filter(S=>S&&(S.title||S.icon));return b.length===0?null:g?e.jsx(h.Box,{direction:"row",gap:"md",children:b.map(({title:S,icon:P,buttonProps:A,onClick:N},G)=>e.jsx(V.Button,{iconLeft:P?e.jsx(B.Icon,{name:P,size:"md"}):void 0,onClick:N,...A,children:S},`action-${G}`))}):e.jsxs(I.Menu,{position:"bottom-right",children:[e.jsx(I.MenuButton,{children:e.jsx(V.Button,{variant:"tertiary",size:"sm",iconLeft:e.jsx(B.Icon,{name:"MenuBurger"}),"aria-label":"Actions"})}),e.jsx(I.MenuLists,{children:e.jsx(I.MenuBody,{style:{minWidth:200},children:b.map(({title:S,icon:P,buttonProps:A,onClick:N},G)=>{const re=(A==null?void 0:A.tone)==="error"||(A==null?void 0:A.danger)===!0;return e.jsx(I.MenuItem,{intent:re?"danger":void 0,disabled:A==null?void 0:A.disabled,startIcon:P?e.jsx(B.Icon,{name:P}):void 0,onClick:N,children:S},`action-${G}`)})})})]})},T=()=>{const b=e.jsx(uo,{backButton:t});return t!=null&&t.navigateTo?e.jsx(h.Box,{direction:"row",children:e.jsx(pe.Link,{to:t.navigateTo,replace:!0,style:{textDecoration:"none"},children:b})}):e.jsx(h.Box,{direction:"row",children:e.jsx(ft,{onClick:D,children:b})})},w=()=>{const b=!!r,S=Array.isArray(d)&&d.length>0,P=u.isValidElement(d)?!0:S;if(!b&&!P&&!y)return null;const N=g||!g&&S;return e.jsxs(h.Box,{direction:"column",gap:"xs",paddingBlock:(m==null?void 0:m.paddingBlock)??"sm",paddingInline:(m==null?void 0:m.paddingInline)??"md",...m,style:{...c?{boxShadow:"inset 0 -1px 0 0 var(--sa-border-subtle, #0b120e24)"}:{},...m==null?void 0:m.style},children:[y&&T(),(b||P)&&e.jsxs(h.Box,{direction:N?"row":"column",gap:"sm",justify:"space-between",align:N?"center":"flex-start",children:[b?typeof r=="string"?e.jsxs(h.Box,{direction:"row",gap:"lg",align:"center",children:[e.jsxs(h.Box,{direction:"row",gap:"sm",align:"center",children:[n&&e.jsx(B.Icon,{name:n,size:"md",color:"primary"}),e.jsx(C.Text,{variant:"h3",fontWeight:"semibold",fontFamily:"Poppins",children:r})]}),i&&e.jsx(qe.Badge,{border:!0,size:"lg",text:i,...a})]}):r:null,E()]})]})},v=()=>{if(!l||l.length===0)return null;const b=l.filter(A=>A.show!==!1);if(b.length===0)return null;let S=0,P=-1/0;return b.forEach((A,N)=>{const G=A.order??0;G>=P&&(P=G,S=N)}),b.map(({content:A,order:N,borderBottom:G=!0},re)=>e.jsx(h.Box,{direction:"column",paddingTop:"sm",paddingBottom:G||re===S?"sm":"spacing-0",paddingInline:"md",style:{...G?{boxShadow:"inset 0 -1px 0 0 var(--sa-border-subtle, #0b120e24)"}:{},...N!==void 0?{order:N}:{}},children:A},`sub-header-${re}`))},R=()=>{const b=s?w():null,S=v();return!b&&!S?null:e.jsxs(h.Box,{direction:"column",style:{marginBottom:S?"var(--sa-spacing-0)":"var(--sa-spacing-md)"},children:[b,S]})},O=()=>o;return e.jsxs(h.Box,{direction:"column",as:"main",...f,style:{...(f==null?void 0:f.style)??{},animation:"pageLayoutEnter 320ms cubic-bezier(0.16, 1, 0.3, 1) backwards"},children:[R(),O()]},M.pathname)},ho=u.memo(xo),fo={icon:"Cross",title:""},mo="calc(100vw - 16px)",Wr=t=>t==null?void 0:`min(${typeof t=="number"?`${t}px`:t}, ${mo})`,dn=u.forwardRef(({onHide:t,show:r,withBlur:n=!1,style:i,children:o,closeButton:s=fo,width:c,minWidth:l="357px",maxWidth:d="357px"},a)=>{const f=Wr(c??l),m=Wr(c??d);return e.jsx(Ft.Drawer,{blur:n,isShow:r,position:"right",onHide:t,ref:a,style:{minWidth:f,maxWidth:m,...i},children:e.jsxs(h.Box,{direction:"column",padding:"lg",children:[s?e.jsxs(h.Box,{direction:"row",align:"center",gap:"sm",onClick:t,marginBottom:"lg",cursor:"pointer",children:[e.jsx(B.Icon,{name:s.icon,size:"md",color:"subtle",cursor:"pointer"}),s.title?e.jsx(C.Text,{fontFamily:"Poppins",fontSize:"md",color:"subtlest",children:s.title}):null]}):null,o]})})}),ar=u.memo(({children:t,borderBottom:r=!0,padding:n=!0})=>{const i=he.useMediaQuery("lg");return e.jsx(h.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})}),dr=u.memo(({children:t,borderTop:r=!0,padding:n=!0})=>{const i=he.useMediaQuery("lg");return e.jsx(h.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})}),go=u.memo(({children:t,...r})=>e.jsx(h.Box,{direction:"column",padding:"md",paddingLeft:"md",paddingRight:"md",gap:"md",...r,children:t})),yo=u.memo(({children:t,title:r,titleTag:n,action:i,header:o,footer:s,actionContainer:c,containerProps:l,bodyProps:d,headerProps:a={borderBottom:!0},footerProps:f={borderTop:!0},variantTag:m="info"})=>{const g=he.useMediaQuery("lg"),j=()=>n?e.jsxs(h.Box,{direction:"row",gap:"sm",align:"center",children:[e.jsx(C.Text,{fontWeight:"medium",children:r}),e.jsx(qe.Badges,{border:!0,text:n,variant:m})]}):e.jsx(C.Text,{fontWeight:"medium",children:r}),M=()=>o||e.jsxs(h.Box,{direction:"row",justify:"space-between",align:"flex-start",gap:"md",children:[e.jsx(h.Box,{direction:"column",children:r?j():null}),e.jsx(h.Box,{direction:"column",style:g?{width:"100%",maxWidth:"19.313rem"}:{flex:1},...c,children:i??null})]}),y=!!(o||r||i);return e.jsxs(h.Box,{direction:"column",bg:"white",borderRadius:"rounded-xs",as:"section",borderWidth:"border",borderStyle:"border-solid",borderColor:"border-base",...l,style:{backgroundColor:"var(--sa-background-primary, #ffffff)",...(l==null?void 0:l.style)??{}},children:[o!==null&&y?e.jsx(ar,{...a,children:M()}):null,e.jsx(go,{...d,children:t}),s?e.jsx(dr,{...f,children:s}):null]})}),po=t=>e.jsx(C.Text,{variant:"h1",children:t.children,...t.props}),jo=t=>e.jsx(C.Text,{variant:"h2",children:t.children,...t.props}),bo=t=>e.jsx(C.Text,{variant:"h3",children:t.children,...t.props}),vo=t=>e.jsx(C.Text,{variant:"h4",children:t.children,...t.props}),Co=t=>e.jsx(C.Text,{variant:"h5",children:t.children,...t.props}),wo=t=>e.jsx(C.Text,{variant:"h6",children:t.children,...t.props}),Do=t=>e.jsx(C.Text,{variant:"sub-h1",children:t.children,...t.props}),So=t=>e.jsx(C.Text,{variant:"sub-h2",children:t.children,...t.props}),ko=t=>e.jsx(C.Text,{variant:"sub-h3",children:t.children,...t.props}),Bo=t=>e.jsx(C.Text,{variant:"body-1",children:t.children,...t.props}),Fo=t=>e.jsx(C.Text,{variant:"body-2",children:t.children,...t.props}),Eo=t=>e.jsx(C.Text,{variant:"body-3",children:t.children,...t.props}),Ae={H1:po,H2:jo,H3:bo,H4:vo,H5:Co,H6:wo,SubH1:Do,SubH2:So,SubH3:ko,Body1:Bo,Body2:Fo,Body3:Eo},Be=()=>{const[t,r]=pe.useSearchParams(),n=st.searchParamsToObject(t.toString()),i=pe.useParams(),o=pe.useLocation(),s=i.id;return{setSearchParams:r,searchParams:t,searchQueries:n,isHasQuery:(f,m)=>t.has(f)&&t.get(f)===m,getQueryParam:f=>t.get(f),getRouteParam:f=>i[f],params:i,location:o,id:s,hasId:!!s}},un=t=>JSON.stringify(t),xn=t=>JSON.stringify(t),hn=t=>JSON.stringify(t),fn=t=>JSON.stringify(t),Mo=t=>t,Lo=t=>JSON.stringify(t),ht=({value:t,name:r,type:n,withSearchParam:i=!0,setSearchParams:o,searchQueries:s,dropdownSearchKey:c,filterKey:l="filter",pageKey:d="page"})=>{if(i){let a;switch(n){case"search":a=Mo(t);break;case"dropdown":case"dropdown-multiple":a=un(t);break;case"radio":a=xn(t);break;case"date-range":a=hn(t);break;case"advanced-date-range":a=Lo(t);break;case"date":a=fn(t);break;default:a=t;break}if(typeof a<"u"){const m={...s[l]&&typeof s[l]=="string"?JSON.parse(s[l]):void 0,[r]:a},g={...s};c&&typeof c=="string"&&delete g[c],delete g[d];const j={...g,[l]:JSON.stringify(m)},M=new URLSearchParams(s).toString(),y=new URLSearchParams(j).toString();if(M===y)return;o(j)}}},kt=({name:t,filterKey:r="filter",searchParams:n,get:i})=>{const o=n.get(r)||void 0,s=o&&typeof o=="string"?JSON.parse(o):void 0,c=s?s[t]:void 0;return i==="label"&&c?JSON.parse(c)[0].label:i==="value"&&c?JSON.parse(c)[0].value:c},mn=({name:t,filterKey:r="filter",searchParams:n,get:i})=>{const o=n.get(r)||void 0,s=o&&typeof o=="string"?JSON.parse(o):void 0,c=s?s[t]:void 0;return i==="label"&&c?JSON.parse(c).map(l=>l.label):i==="value"&&c?JSON.parse(c).map(l=>l.value):i==="array"&&c?JSON.parse(c):c},Io=({name:t,filterKey:r="filter",searchParams:n,get:i})=>{const o=n.get(r)||void 0,s=o&&typeof o=="string"?JSON.parse(o):void 0,c=s?s[t]:void 0;return i==="id"&&c?JSON.parse(c).id:i==="label"&&c?JSON.parse(c).label:i==="value"&&c?JSON.parse(c).value:c},Lt=(t,r,n)=>{const i=r.get(n||"filter")||void 0,o=i&&typeof i=="string"?JSON.parse(i):void 0;return o?o[t]:void 0},To=({name:t,filterKey:r="filter",searchParams:n})=>{const i=n.get(r||"filter")||void 0,o=i&&typeof i=="string"?JSON.parse(i):void 0,s=o?o[t]:void 0;return{start:s?JSON.parse(s).from:void 0,end:s?JSON.parse(s).to:void 0}},gn=({name:t,filterKey:r="filter",searchParams:n})=>{const i=n.get(r||"filter")||void 0,o=i&&typeof i=="string"?JSON.parse(i):void 0,s=o?o[t]:void 0;return s?JSON.parse(s):void 0},Oo=(t,{filterKey:r="filter",perPageKey:n="perPage",pageKey:i="page"})=>{const o=t.get(r)||void 0,s=t.get(n)||void 0,c=t.get(i)||void 0;return!!o||!!s||!!c},yn=({isOpen:t,onClose:r,filterKey:n,pageKey:i,filters:o})=>{const{searchParams:s,setSearchParams:c,searchQueries:l}=Be(),[d,a]=u.useState({}),f=()=>{s.delete(n||"filter"),c(s)},m=(g,j)=>{switch(g.type){case"radio":{const{show:M=!0}=g;return M&&e.jsx(h.Box,{direction:"column",children:e.jsx(h.Box,{direction:"column",children:g.title})},j)}case"dropdown":{const{show:M=!0}=g;return M&&e.jsx(h.Box,{direction:"column",children:e.jsx(h.Box,{direction:"column",children:g.title})},j)}case"date-range":return e.jsx(h.Box,{direction:"column",children:e.jsx(h.Box,{direction:"column",children:g.title})},j);case"date":return e.jsx(h.Box,{direction:"column",children:e.jsx(h.Box,{direction:"column",children:g.title})},j);case"dropdown-multiple":{const{show:M=!0}=g;return M&&e.jsx(h.Box,{direction:"column",children:e.jsx(h.Box,{direction:"column",children:g.title})},j)}default:return null}};return e.jsx(dn,{onHide:r,show:t||!1,children:e.jsxs(h.Box,{direction:"column",gap:"md",children:[e.jsxs(oe.Flex,{direction:"row",justify:"space-between",align:"center",children:[e.jsx(h.Box,{direction:"column",children:"Filter"}),e.jsx(h.Box,{direction:"column",style:{cursor:"pointer"},onClick:f,children:"Reset"})]}),o==null?void 0:o.map((g,j)=>m(g,j))]})})},pn=({searchKey:t="q",statusKey:r="status",searchPlaceholder:n="Search",searchHighlightPlaceholder:i,extendedFilter:o,showSearchFilter:s=!0,showStatusFilter:c=!0,filterKey:l="filter",pageKey:d="page",customWidthSearch:a,handleOnReset:f,filterConfigs:m,buttonToggleProps:g,position:j="right",titleSearchLabel:M="Work Order",withTitleLabels:y=!1})=>{const E=(g==null?void 0:g.isShowLabel)??!0,[T,w]=u.useState(!1),[v,R]=u.useState(0),O=()=>{R(Q=>Q+1)},{searchParams:b,setSearchParams:S,getQueryParam:P}=Be(),A=st.searchParamsToObject(b.toString()),N=Lt(t,b,l)||"",[G,re]=u.useState(N),xe=P(l),se=!!(xe&&!(()=>{if(xe)try{const Q=JSON.parse(xe);return Object.keys(Q).length===1&&Q[t]===""}catch(Q){console.error("Filter parameter is not a valid JSON:",Q)}return!1})()),J=he.useMediaQuery("md");return u.useEffect(()=>{re(N)},[N]),u.useEffect(()=>{if(G===N)return;const Q=window.setTimeout(()=>{ht({value:G,name:t,type:"search",searchQueries:A,setSearchParams:S,filterKey:l,pageKey:d})},350);return()=>{window.clearTimeout(Q)}},[G,N,t,A,S,l,d]),e.jsxs(oe.Flex,{gap:"md",style:{flexDirection:J&&j==="left"?"row":J&&j==="right"?"row-reverse":"column"},align:"flex-end",children:[se&&e.jsx(h.Box,{direction:"column",justify:"flex-end",children:e.jsx(V.Button,{onClick:()=>{const Q=new URLSearchParams(b);Q.delete(l),S(Q),re(""),O(),f&&f()},variant:"outline",tone:"neutral",children:e.jsx(C.Text,{color:"error",fontWeight:"semibold",children:"Reset"})})}),o==null?void 0:o.map(({minWidth:Q,content:ae,title:ee,onClickContainer:ce},we)=>e.jsxs(h.Box,{direction:"column",gap:"sm",onClick:ce,style:{minWidth:Q},children:[ee&&e.jsx(Ae.SubH3,{children:ee}),ae]},`extended-filter-${we}-${v}`)),!!(m!=null&&m.length)&&e.jsx(V.Button,{primary:se,secondary:!se,iconLeft:e.jsx(B.Icon,{size:"sm",name:(g==null?void 0:g.icon)||"FilterHorizontal",style:{color:xe?"var(--sa-background-brand, #04254f)":"var(--sa-text-primary, #292a2e)"}}),fullWidth:!J,onClick:()=>w(!0),children:E?"Filter":void 0}),c&&e.jsxs(h.Box,{direction:"column",gap:"sm",style:{minWidth:"126px"},children:[y&&e.jsx(Ae.SubH3,{children:"Status"}),e.jsx(it.Dropdown,{dropdownLists:[{label:"Active",value:"active"},{label:"InActive",value:"inactive"}],defaultValue:kt({get:"value",name:r,searchParams:b,filterKey:l})?[{label:kt({get:"value",name:r,searchParams:b,filterKey:l})==="active"?"Active":"InActive",value:kt({get:"value",name:r,searchParams:b,filterKey:l})}]:[],onChange:Q=>ht({value:Q,name:r,type:"dropdown",searchQueries:A,setSearchParams:S,filterKey:l}),placeholder:y?"All":"All Status"},v)]}),s&&e.jsxs(h.Box,{direction:"column",gap:"sm",style:{width:a&&J?a:J?"310px":""},children:[y&&e.jsxs(Ae.SubH3,{children:["Search for ",M]}),e.jsx(Ze.Input,{placeholder:n,leftIcon:e.jsx(B.Icon,{name:"Search",width:20,height:20}),onChange:Q=>re(Q.target.value),value:G,fullWidth:!0},v+1+l)]}),e.jsx(yn,{isOpen:T,onClose:()=>w(!1),filterKey:l,filters:m,pageKey:d})]})},Wo=t=>t==="checkbox-multiple"?"dropdown-multiple":t==="radio"?"dropdown":t==="date-compact"?"date":t;function ur({configs:t,filterKey:r="filter",activeFilterKey:n="filters",pageKey:i="page",searchKey:o="q"}){const{searchParams:s,setSearchParams:c,searchQueries:l}=Be(),d=u.useMemo(()=>Object.fromEntries(t.map(v=>[v.key,v])),[t]),a=u.useMemo(()=>{const v=(s.get(n)||"").split(",").map(O=>O.trim()).filter(Boolean);let R=[];try{const O=s.get(r);O&&(R=Object.keys(JSON.parse(O)).filter(b=>b!==o))}catch{}return t.map(O=>O.key).filter(O=>{const b=d[O];return(b==null?void 0:b.locked)||v.includes(O)||R.includes(O)})},[s,n,r,o,t,d]),f=u.useCallback(v=>{try{return v[r]?JSON.parse(v[r]):{}}catch{return{}}},[r]),m=u.useCallback(v=>{const R={...l};v.length?R[n]=v.join(","):delete R[n],c(R)},[l,n,c]),g=u.useCallback(v=>{a.includes(v)||m([...a,v])},[a,m]),j=u.useCallback(v=>{var S;if((S=d[v])!=null&&S.locked)return;const R={...l},O=a.filter(P=>P!==v);O.length?R[n]=O.join(","):delete R[n];const b=f(R);v in b&&(delete b[v],Object.keys(b).length?R[r]=JSON.stringify(b):delete R[r]),delete R[i],c(R)},[l,a,n,r,i,f,c,d]),M=u.useCallback(v=>a.includes(v)?j(v):g(v),[a,g,j]),y=u.useCallback(v=>{switch(v.type){case"dropdown":case"dropdown-multiple":case"checkbox-multiple":case"radio":return mn({name:v.key,get:"array",searchParams:s,filterKey:r})||[];case"date":{const R=gn({name:v.key,searchParams:s,filterKey:r});return R?new Date(R):void 0}case"date-compact":{const O=f(Object.fromEntries(s.entries()))[v.key];return O&&typeof O=="object"?O:void 0}default:return}},[s,r,f]),D=u.useCallback((v,R)=>{if(v.type==="date-compact"){const O={...l},b=f(O);R==null?delete b[v.key]:b[v.key]=R,Object.keys(b).length?O[r]=JSON.stringify(b):delete O[r],delete O[i],c(O);return}ht({value:R,name:v.key,type:Wo(v.type),searchQueries:l,setSearchParams:c,filterKey:r,pageKey:i})},[l,c,r,i,f]),E=u.useCallback(v=>{const R={...l},O=f(R);v in O&&(delete O[v],Object.keys(O).length?R[r]=JSON.stringify(O):delete R[r]),delete R[i],c(R)},[l,r,i,f,c]),T=u.useCallback(()=>{const v={...l};delete v[r],delete v[n],delete v[i],c(v)},[l,r,n,i,c]),w=a.length>0;return{activeKeys:a,configByKey:d,hasActiveFilter:w,addFilter:g,removeFilter:j,toggleFilter:M,getValue:y,setValue:D,clearValue:E,clearAll:T}}const xr={get(t){return ut.storage.get(t)??null},set(t,r){ut.storage.save(t,r)},remove(t){ut.storage.delete(t)}},at={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}`},jt=(t,r)=>{const n=new Set(r.map(s=>s.key)),i=t.order.filter(s=>n.has(s));for(const s of r)i.includes(s.key)||i.push(s.key);const o=t.hidden.filter(s=>n.has(s));return{order:i,hidden:o}};function Ro({columns:t,scopeId:r,storage:n,onColumnsChange:i,value:o}){const s=u.useMemo(()=>({order:t.map(b=>b.key),hidden:[]}),[t]),c=r?at.columns(r):void 0,l=(b,S)=>jt({order:b.order??S,hidden:b.hidden??[]},t),[d,a]=u.useState(()=>{if(o&&(o.order||o.hidden))return l(o,t.map(b=>b.key));if(c){const b=n.get(c);if(b&&Array.isArray(b.order))return jt(b,t)}return s}),f=t.map(b=>b.key).join("|");u.useEffect(()=>a(b=>jt(b,t)),[f]);const m=u.useRef(d);m.current=d;const g=o?`${(o.order??[]).join("|")}~${(o.hidden??[]).join("|")}`:null,j=u.useRef(g);u.useEffect(()=>{if(g==null||j.current===g)return;j.current=g;const b=m.current,S=l(o,b.order);S.order.join("|")===b.order.join("|")&&S.hidden.join("|")===b.hidden.join("|")||(a(S),c&&n.set(c,S))},[g,f]);const M=u.useRef(!1);u.useEffect(()=>{M.current||(M.current=!0,i==null||i(d))},[]);const y=u.useCallback(b=>{a(b),c&&n.set(c,b),i==null||i(b)},[c,n,i]),D=u.useMemo(()=>{const b=new Map(t.map(S=>[S.key,S]));return d.order.filter(S=>b.has(S)).map(S=>({...b.get(S),visible:!d.hidden.includes(S)}))},[d,t]),E=u.useCallback(b=>{const S=d.hidden.includes(b)?d.hidden.filter(P=>P!==b):[...d.hidden,b];y({...d,hidden:S})},[d,y]),T=u.useCallback((b,S)=>{if(b===S)return;const P=[...d.order],[A]=P.splice(b,1);P.splice(S,0,A),y({...d,order:P})},[d,y]),w=u.useCallback(b=>{y({...d,hidden:b?t.filter(S=>!S.locked).map(S=>S.key):[]})},[d,t,y]),v=u.useCallback(()=>y(s),[y,s]),R=u.useCallback(b=>y(jt(b,t)),[y,t]),O=d.hidden.length===0;return{state:d,orderedColumns:D,allVisible:O,toggleVisibility:E,reorder:T,setAllHidden:w,reset:v,applyState:R}}function Ao({scopeId:t,storage:r,snapshotKeys:n,pageKey:i="page",getColumns:o,applyColumns:s}){const{searchParams:c,setSearchParams:l}=Be(),d=t?at.savedViews(t):void 0,[a,f]=u.useState(()=>d?r.get(d)||[]:[]),m=u.useCallback(y=>{f(y),d&&r.set(d,y)},[d]),g=u.useCallback(y=>{const D=y.trim();if(!D)return;const E={};n.forEach(w=>{const v=c.get(w);v!=null&&(E[w]=v)});const T={id:`${Date.now()}`,name:D,query:E,columns:o==null?void 0:o(),createdAt:Date.now()};m([...a,T])},[n,c,o,m,a]),j=u.useCallback(y=>m(a.filter(D=>D.id!==y)),[m,a]),M=u.useCallback(y=>{const D=Object.fromEntries(c.entries());n.forEach(E=>delete D[E]),Object.assign(D,y.query),delete D[i],l(D),y.columns&&(s==null||s(y.columns))},[c,n,i,l,s]);return{enabled:!!d,views:a,saveView:g,deleteView:j,applyView:M}}function zo({scopeId:t,storage:r,snapshotKeys:n,enabled:i=!0}){const{searchParams:o}=Be(),s=t&&i?at.lastState(t):void 0,c=u.useRef(s);u.useEffect(()=>{if(!s){c.current=s;return}if(c.current!==s){c.current=s;return}const a={};n.forEach(f=>{const m=o.get(f);m!=null&&(a[f]=m)}),Object.keys(a).length!==0&&r.set(s,a)},[o,s,n,r]);const l=u.useCallback(()=>{if(!s)return null;const a=r.get(s);return a&&Object.keys(a).length>0?a:null},[s,r]),d=u.useCallback(()=>{s&&r.remove(s)},[s,r]);return{enabled:!!s,read:l,clear:d}}function Vo({scopeId:t,storage:r,perPageKey:n,pageSizeOptions:i,enabled:o=!0}){const{searchParams:s}=Be(),c=t&&o?at.perPage(t):void 0,l=s.toString(),d=u.useRef(c);u.useEffect(()=>{if(!c){d.current=c;return}if(d.current!==c){d.current=c;return}const m=s.get(n);if(!m)return;const g=Number(m);!Number.isFinite(g)||g<=0||r.set(c,g)},[l,c,n,r]);const a=u.useCallback(()=>{if(!c)return null;const m=r.get(c);if(m==null)return null;const g=Number(m);return!Number.isFinite(g)||g<=0||i&&!i.includes(g)?null:String(g)},[c,r,i]),f=u.useCallback(()=>{c&&r.remove(c)},[c,r]);return{enabled:!!c,read:a,clear:f}}let Zt={},Gt=!1,Qt=null;const Ho=(t,r)=>{Object.assign(Zt,t),Qt=r,!Gt&&(Gt=!0,queueMicrotask(()=>{const n=Zt,i=Qt;Zt={},Gt=!1,Qt=null,!(!i||Object.keys(n).length===0)&&i(o=>{const s=new URLSearchParams(o);return Object.entries(n).forEach(([c,l])=>s.set(c,l)),s})}))};function Po({enabled:t,snapshotKeys:r,perPageKey:n,readSnapshot:i,readPerPage:o}){const{searchParams:s,setSearchParams:c,location:l}=Be(),d=u.useRef(null);u.useEffect(()=>{if(!t||d.current===l.pathname)return;d.current=l.pathname;const a={};if(!s.has(n)){const f=o();f&&(a[n]=f)}if(!r.some(f=>s.has(f))){const f=i();f&&Object.assign(a,f)}Object.keys(a).length!==0&&Ho(a,c)},[l.pathname,t])}const No=({configs:t,activeKeys:r,onToggle:n,hasActiveFilter:i,onReset:o})=>t.length?e.jsxs(I.Menu,{position:"bottom-left",children:[e.jsx(I.MenuButton,{children:e.jsx(V.Button,{variant:i?"secondary":"outline",tone:"neutral",size:"sm",iconLeft:e.jsx(B.Icon,{name:"FilterHorizontal"}),"aria-label":"Add filter"})}),e.jsx(I.MenuLists,{children:e.jsx(I.MenuBody,{style:{minWidth:260},title:e.jsxs(h.Box,{display:"flex",direction:"row",align:"center",justify:"space-between",fullWidth:!0,children:[e.jsx(C.Text,{fontSize:"sm",fontWeight:"medium",color:"subtlest",children:"Add Filter"}),i&&o&&e.jsx(V.Button,{variant:"link",tone:"brand",size:"xs",onClick:o,children:"Reset"})]}),children:t.map(s=>e.jsx(I.MenuItem,{selected:s.locked||r.includes(s.key),disabled:s.locked,closeOnSelect:!1,startIcon:s.icon??void 0,onClick:()=>{s.locked||n(s.key)},children:s.label},s.key))})})]}):null,It=({onClear:t,onRemove:r})=>e.jsxs(I.Menu,{position:"bottom-right",children:[e.jsx(I.MenuButton,{children:e.jsx(V.Button,{variant:"link",tone:"neutral",size:"xs",iconLeft:e.jsx(B.Icon,{name:"MenuHorizontal"}),"aria-label":"Filter actions"})}),e.jsx(I.MenuLists,{children:e.jsxs(I.MenuBody,{style:{width:180},children:[e.jsx(I.MenuItem,{startIcon:e.jsx(B.Icon,{name:"CrossCircle"}),onClick:t,children:"Clear value"}),r&&e.jsx(I.MenuItem,{intent:"danger",startIcon:e.jsx(B.Icon,{name:"Trash1"}),onClick:r,children:"Remove filter"})]})})]}),_o=t=>{const r=new Date(t);return r.setHours(0,0,0,0),r},Rr=(t,r,n)=>{const i=new Date(t);return n==="day"?i.setDate(i.getDate()+r):n==="week"?i.setDate(i.getDate()+r*7):n==="month"?i.setMonth(i.getMonth()+r):i.setFullYear(i.getFullYear()+r),i},jn=t=>{const r=_o(new Date);if(t.direction==="this"){const i=new Date(r),o=new Date(r);return t.period==="week"?(i.setDate(r.getDate()-r.getDay()),o.setDate(i.getDate()+6)):t.period==="month"?(i.setDate(1),o.setMonth(o.getMonth()+1,0)):t.period==="year"&&(i.setMonth(0,1),o.setMonth(11,31)),{from:i,to:o}}const n=t.count??1;return t.direction==="past"?{from:Rr(r,-n,t.period),to:r}:{from:r,to:Rr(r,n,t.period)}},Ar=24,bn=t=>t.length>Ar?`${t.slice(0,Ar)}...`:t,Bt=t=>t.toLocaleDateString(void 0,{day:"2-digit",month:"short",year:"numeric"}),Mt={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"},qo=["is","is-before","is-after","is-on-or-before","is-on-or-after","is-between","is-relative-to-today","is-empty","is-not-empty"],rr={past:"Past",next:"Next",this:"This"},Zo=["day","week","month","year"],Go=["past","next","this"],Qo=t=>t.field.type==="date-compact"?e.jsx(Yo,{field:t.field,value:t.value,onChange:t.onChange,onClear:t.onClear,onRemove:t.onRemove}):e.jsx(Uo,{field:t.field,value:t.value,onChange:t.onChange,onClear:t.onClear,onRemove:t.onRemove}),Uo=({field:t,value:r,onChange:n,onClear:i,onRemove:o})=>{const s=r?Bt(new Date(r)):null,c=!!s,l=c?e.jsxs(e.Fragment,{children:[e.jsxs("span",{style:{fontWeight:500},children:[t.label,":"]})," ",e.jsx("span",{style:{fontWeight:400},children:bn(s)})]}):t.label;return e.jsxs(I.Menu,{position:"bottom-left",children:[e.jsx(I.MenuButton,{children:e.jsx(V.Button,{variant:c?"secondary":"outline",tone:"neutral",size:"sm",iconLeft:c?e.jsx(B.Icon,{name:"Calendar",size:"sm"}):void 0,iconRight:e.jsx(B.Icon,{name:"ChevronSmallDown"}),children:l})}),e.jsx(I.MenuLists,{children:e.jsx(I.MenuBody,{style:{width:260},title:e.jsxs(h.Box,{display:"flex",direction:"row",align:"center",justify:"space-between",fullWidth:!0,children:[e.jsx(C.Text,{fontSize:"sm",fontWeight:"medium",color:"subtlest",children:t.label}),e.jsx(It,{onClear:i,onRemove:o})]}),children:e.jsx(Ke.StarasiaDate,{size:"sm",input:!1,clearable:!0,filter:t.mode,value:r,onChange:d=>d==null?i():n(d),withPadding:!1})})})]})},Jo=t=>{switch(t.op){case"is":case"is-before":case"is-after":case"is-on-or-before":case"is-on-or-after":return t.date?`${Mt[t.op]} ${Bt(new Date(t.date))}`:null;case"is-between":return t.from&&t.to?`${Bt(new Date(t.from))} - ${Bt(new Date(t.to))}`:null;case"is-relative-to-today":{const r=t.relative;if(!r)return null;if(r.direction==="this")return`This ${r.period}`;const n=r.count??1,i=n===1?r.period:`${r.period}s`;return`${rr[r.direction]} ${n} ${i}`}case"is-empty":case"is-not-empty":return Mt[t.op];default:return null}},Yo=({field:t,value:r,onChange:n,onClear:i,onRemove:o})=>{const s=(r==null?void 0:r.op)??"is",c=r?Jo(r):null,l=!!c,d=l?e.jsxs(e.Fragment,{children:[e.jsxs("span",{style:{fontWeight:500},children:[t.label,":"]})," ",e.jsx("span",{style:{fontWeight:400},children:bn(c)})]}):t.label,a=f=>{if(f!==s){if(f==="is-empty"||f==="is-not-empty"){n({op:f});return}if(f==="is-relative-to-today"){n({op:f,relative:(r==null?void 0:r.relative)??{direction:"past",count:1,period:"week"}});return}if(f==="is-between"){n({op:f,from:r==null?void 0:r.from,to:r==null?void 0:r.to});return}n({op:f,date:r==null?void 0:r.date})}};return e.jsxs(I.Menu,{position:"bottom-left",children:[e.jsx(I.MenuButton,{children:e.jsx(V.Button,{variant:l?"secondary":"outline",tone:"neutral",size:"sm",iconLeft:l?e.jsx(B.Icon,{name:"Calendar",size:"sm"}):void 0,iconRight:e.jsx(B.Icon,{name:"ChevronSmallDown"}),children:d})}),e.jsxs(I.MenuLists,{children:[e.jsx(I.MenuBody,{style:{width:320},title:e.jsxs(h.Box,{display:"flex",direction:"row",align:"center",justify:"space-between",gap:"xs",fullWidth:!0,children:[e.jsxs(h.Box,{display:"flex",direction:"row",align:"center",gap:"xs",style:{minWidth:0},children:[e.jsx(C.Text,{fontSize:"sm",fontWeight:"medium",color:"subtlest",children:t.label}),e.jsx(Xo,{op:s,onChange:a})]}),e.jsx(It,{onClear:i,onRemove:o})]}),children:e.jsx(Ko,{value:r,op:s,onChange:n})}),s==="is-relative-to-today"&&e.jsx(I.MenuFooter,{children:e.jsx(C.Text,{fontSize:"xs",color:"subtlest",children:"Filter will update with the current date"})})]})]})},Xo=({op:t,onChange:r})=>e.jsxs(I.Menu,{position:"bottom-left",children:[e.jsx(I.MenuButton,{children:e.jsx(V.Button,{variant:"link",tone:"neutral",size:"xs",iconRight:e.jsx(B.Icon,{name:"ChevronSmallDown"}),children:Mt[t]})}),e.jsx(I.MenuLists,{children:e.jsx(I.MenuBody,{style:{width:200},children:qo.map(n=>e.jsx(I.MenuItem,{selected:t===n,onClick:()=>r(n),endIcon:t===n?e.jsx(B.Icon,{name:"Check"}):void 0,children:Mt[n]},n))})})]}),Ko=({value:t,op:r,onChange:n})=>{if(r==="is-empty"||r==="is-not-empty")return e.jsx(h.Box,{paddingBlock:"sm",paddingInline:"sm",children:e.jsx(C.Text,{fontSize:"xs",color:"subtlest",children:"No further input required."})});if(r==="is-between"){const i=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(Ke.StarasiaDate,{size:"sm",input:!1,clearable:!0,rangedDate:!0,value:i,onChange:o=>{if(o==null){n({op:r});return}if(typeof o=="object"&&o!==null&&"from"in o&&"to"in o){let{from:s,to:c}=o;if(!s&&c&&(s=c,c=null),!s&&!c){n({op:r});return}n({op:r,from:s?s.toISOString():void 0,to:c?c.toISOString():void 0})}},withPadding:!1},"range")}return r==="is-relative-to-today"?e.jsx($o,{value:t==null?void 0:t.relative,onChange:i=>n({op:r,relative:i})}):e.jsx(Ke.StarasiaDate,{size:"sm",input:!1,clearable:!0,value:t!=null&&t.date?new Date(t.date):void 0,onChange:i=>{if(i==null){n({op:r});return}i instanceof Date&&n({op:r,date:i.toISOString()})},withPadding:!1},"single")},$o=({value:t,onChange:r})=>{const n=(t==null?void 0:t.direction)??"past",i=(t==null?void 0:t.count)??1,o=(t==null?void 0:t.period)??"week",s=n!=="this",c=jn({direction:n,count:i,period:o});return e.jsxs(h.Box,{direction:"column",display:"flex",gap:"sm",children:[e.jsxs(h.Box,{direction:"row",display:"flex",align:"center",gap:"xs",children:[e.jsxs(I.Menu,{position:"bottom-left",children:[e.jsx(I.MenuButton,{children:e.jsx(V.Button,{variant:"outline",tone:"neutral",size:"sm",iconRight:e.jsx(B.Icon,{name:"ChevronSmallDown"}),children:rr[n]})}),e.jsx(I.MenuLists,{children:e.jsx(I.MenuBody,{style:{width:140},children:Go.map(l=>e.jsx(I.MenuItem,{selected:n===l,endIcon:n===l?e.jsx(B.Icon,{name:"Check"}):void 0,onClick:()=>r(l==="this"?{direction:l,period:o}:{direction:l,count:i,period:o}),children:rr[l]},l))})})]}),s&&e.jsx(Ze.Input,{type:"number",size:"sm",min:1,clearable:!1,value:i,onChange:l=>{const d=Number(l.target.value);r({direction:n,count:Number.isFinite(d)&&d>0?d:1,period:o})},style:{width:72}}),e.jsxs(I.Menu,{position:"bottom-left",children:[e.jsx(I.MenuButton,{children:e.jsx(V.Button,{variant:"outline",tone:"neutral",size:"sm",iconRight:e.jsx(B.Icon,{name:"ChevronSmallDown"}),children:o})}),e.jsx(I.MenuLists,{children:e.jsx(I.MenuBody,{style:{width:140},children:Zo.map(l=>e.jsx(I.MenuItem,{selected:o===l,endIcon:o===l?e.jsx(B.Icon,{name:"Check"}):void 0,onClick:()=>r(n==="this"?{direction:n,period:l}:{direction:n,count:i,period:l}),children:l},l))})})]})]}),e.jsx(Ke.StarasiaDate,{size:"sm",input:!1,disabled:!0,rangedDate:!0,value:c,onChange:()=>{},withPadding:!1},"relative-preview")]})},zr=18,ei=t=>t.length>zr?`${t.slice(0,zr)}...`:t,ti=({field:t,value:r,onChange:n,onClear:i,onRemove:o})=>{const s=t.type==="dropdown-multiple",c=r.length,[l,d]=u.useState(""),a=t.options,f=typeof t.onSearch=="function",m=(()=>{if(f)return a;const D=l.trim().toLowerCase();return D?a.filter(E=>E.label.toLowerCase().includes(D)):a})(),g=D=>r.some(E=>E.value===D.value),j=D=>{if(!s){n([{label:D.label,value:D.value}]),d("");return}n(g(D)?r.filter(E=>E.value!==D.value):[...r,{label:D.label,value:D.value}])},M=D=>{var E;d(D),(E=t.onSearch)==null||E.call(t,D)},y=c===0?t.label:e.jsxs(e.Fragment,{children:[e.jsxs("span",{style:{fontWeight:500},children:[t.label,":"]})," ",e.jsx("span",{style:{fontWeight:400},children:c===1?ei(r[0].label):`${c} Selected`})]});return e.jsxs(I.Menu,{position:"bottom-left",children:[e.jsx(I.MenuButton,{children:e.jsx(V.Button,{variant:c>0?"secondary":"outline",tone:"neutral",size:"sm",iconLeft:c>0?e.jsx(B.Icon,{name:"Tag",size:"sm"}):void 0,iconRight:e.jsx(B.Icon,{name:"ChevronSmallDown"}),children:y})}),e.jsx(I.MenuLists,{children:e.jsx(I.MenuBody,{style:{width:260},title:e.jsxs(h.Box,{display:"flex",direction:"row",align:"center",justify:"space-between",fullWidth:!0,children:[e.jsx(C.Text,{fontSize:"sm",fontWeight:"medium",color:"subtlest",children:t.label}),e.jsx(It,{onClear:i,onRemove:o})]}),children:e.jsxs(h.Box,{direction:"column",gap:"sm",children:[e.jsx(it.Dropdown,{size:"sm",triggerInput:!0,fullWidth:!0,hideChevronIcon:!0,clearable:!0,multiSelect:s,searchAble:!0,searchValue:l,onSearch:M,value:r,onChange:n,placeholder:`Search ${t.label.toLowerCase()}…`}),e.jsx(h.Box,{direction:"column",overflow:"overflow-y-auto",customMaxHeight:"240px",children:t.isLoading?e.jsx(h.Box,{paddingBlock:"sm",paddingInline:"sm",children:e.jsx(C.Text,{fontSize:"xs",color:"subtlest",children:"Loading…"})}):m.length===0?e.jsx(h.Box,{paddingBlock:"sm",paddingInline:"sm",children:e.jsx(C.Text,{fontSize:"xs",color:"subtlest",children:"No results"})}):m.map(D=>e.jsx(I.MenuItem,{closeOnSelect:!s,selected:g(D),startIcon:D.avatar,endIcon:g(D)?e.jsx(B.Icon,{name:"Check"}):void 0,description:D.description,onClick:()=>j(D),children:D.label},D.value))})]})})})]})},Vr=18,ri=t=>t.length>Vr?`${t.slice(0,Vr)}...`:t,Hr=({checked:t,indeterminate:r})=>e.jsx("span",{style:{pointerEvents:"none",display:"inline-flex"},children:e.jsx(ct.Checkbox,{size:"sm",checked:t,readOnly:!0,onChange:()=>{},variant:r?"indeterminate":"select"})}),ni=({field:t,value:r,onChange:n,onClear:i,onRemove:o})=>{const s=new Set(r.map(g=>g.value)),c=r.length,l=t.options.length>0&&t.options.every(g=>s.has(g.value)),d=c>0&&!l,a=g=>{n(s.has(g.value)?r.filter(j=>j.value!==g.value):[...r,{label:g.label,value:g.value}])},f=()=>{n(l?[]:t.options.map(g=>({label:g.label,value:g.value})))},m=c===0?t.label:e.jsxs(e.Fragment,{children:[e.jsxs(C.Text,{as:"span",fontWeight:"semibold",children:[t.label,":"]})," ",e.jsx(C.Text,{as:"span",children:c===1?ri(r[0].label):`${c} Selected`})]});return e.jsxs(I.Menu,{position:"bottom-left",children:[e.jsx(I.MenuButton,{children:e.jsx(V.Button,{variant:c>0?"secondary":"outline",tone:"neutral",size:"sm",iconLeft:c>0?e.jsx(B.Icon,{name:"Tag",size:"sm"}):void 0,iconRight:e.jsx(B.Icon,{name:"ChevronSmallDown"}),children:m})}),e.jsx(I.MenuLists,{children:e.jsxs(I.MenuBody,{style:{width:240},title:e.jsxs(h.Box,{display:"flex",direction:"row",align:"center",justify:"space-between",fullWidth:!0,children:[e.jsx(C.Text,{fontSize:"sm",fontWeight:"medium",color:"subtlest",children:t.label}),e.jsx(It,{onClear:i,onRemove:o})]}),children:[e.jsx(I.MenuItem,{closeOnSelect:!1,selected:l,onClick:f,startIcon:e.jsx(Hr,{checked:l||d,indeterminate:d}),children:"Select All"}),t.options.map(g=>e.jsx(I.MenuItem,{closeOnSelect:!1,selected:s.has(g.value),onClick:()=>a(g),startIcon:e.jsx(Hr,{checked:s.has(g.value)}),children:g.label},g.value))]})})]})},vn=({activeKeys:t,configByKey:r,getValue:n,setValue:i,clearValue:o,removeFilter:s})=>e.jsx(e.Fragment,{children:t.map(c=>{const l=r[c];if(!l)return null;const d=n(l),a=l.locked?void 0:()=>s(c);return l.type==="date"||l.type==="date-compact"?e.jsx(Qo,{field:l,value:d,onChange:f=>i(l,f),onClear:()=>o(c),onRemove:a},c):l.type==="checkbox-multiple"?e.jsx(ni,{field:l,value:d||[],onChange:f=>i(l,f),onClear:()=>o(c),onRemove:a},c):e.jsx(ti,{field:l,value:d||[],onChange:f=>i(l,f),onClear:()=>o(c),onRemove:a},c)})}),Pr=t=>`${t} Rows`,oi=({pagination:t,pageKey:r="page",perPageKey:n="perPage",pageSizeOptions:i=[10,25,50,100],defaultPerPage:o=10,showResultCount:s=!0,showPageSize:c=!0,showPagination:l=!0})=>{var E;const{searchQueries:d,setSearchParams:a,searchParams:f}=Be(),m=f.get(n),g=m?Number(m):o,j=T=>{a({...d,[r]:String(T)})},M=T=>{a({...d,[n]:T,[r]:"1"})},y=(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),D=(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:[s&&e.jsx(C.Text,{fontSize:"sm",fontWeight:"medium",color:"primary",truncate:!0,children:`${y}-${D} of ${((E=t==null?void 0:t.totalData)==null?void 0:E.toLocaleString())||0}`}),c&&e.jsxs(I.Menu,{position:"bottom-left",children:[e.jsx(I.MenuButton,{children:e.jsx(V.Button,{variant:"outline",tone:"neutral",size:"sm",iconRight:e.jsx(B.Icon,{name:"ChevronSmallDown"}),"aria-label":"Rows per page",children:Pr(g)})}),e.jsx(I.MenuLists,{children:e.jsx(I.MenuBody,{children:i.map(T=>e.jsx(I.MenuItem,{selected:T===g,onClick:()=>M(String(T)),children:Pr(T)},T))})})]}),l&&((t==null?void 0:t.totalPage)??0)>1&&e.jsx(h.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(xt.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:j})})]})};function ii(t,r,n=!0){u.useEffect(()=>{if(!n)return;const i=o=>{var l;if(o.metaKey||o.ctrlKey||o.altKey||o.key!==t)return;const s=o.target,c=(l=s==null?void 0:s.tagName)==null?void 0:l.toLowerCase();c==="input"||c==="textarea"||s!=null&&s.isContentEditable||(o.preventDefault(),r())};return window.addEventListener("keydown",i),()=>window.removeEventListener("keydown",i)},[t,r,n])}const si=240,Cn=({searchKey:t="q",filterKey:r="filter",pageKey:n="page",placeholder:i="Search",shortcut:o="/",collapsible:s=!0})=>{const{searchParams:c,setSearchParams:l,searchQueries:d}=Be(),a=Lt(t,c,r)||"",[f,m]=u.useState(!s||!!a),[g,j]=u.useState(s&&!a),[M,y]=u.useState(a),D=he.useDebounce(M,350),E=u.useRef(null);u.useEffect(()=>{y(a),a&&m(!0)},[a]),u.useEffect(()=>{f&&j(!1)},[f]),u.useEffect(()=>{D!==a&&ht({value:D,name:t,type:"search",searchQueries:d,setSearchParams:l,filterKey:r,pageKey:n})},[D]);const T=u.useCallback(()=>{m(!0),requestAnimationFrame(()=>{var O;return(O=E.current)==null?void 0:O.focus()})},[]);ii(o,T);const w=()=>{s&&!M&&m(!1)},v=O=>{var b;s&&O.key==="Escape"&&!M&&(m(!1),(b=E.current)==null||b.blur())},R=()=>{f||j(!0)};return e.jsxs(h.Box,{display:"flex",direction:"row",align:"center",gap:"spacing-0",children:[g&&e.jsx(V.Button,{variant:"outline",tone:"neutral",size:"sm",iconLeft:e.jsx(B.Icon,{name:"Search",size:"sm"}),"aria-label":"Search","aria-expanded":!1,onClick:T}),e.jsxs(h.Box,{onTransitionEnd:R,style:{position:"relative",width:f?si:0,overflow:"hidden",transition:"width 220ms ease"},children:[e.jsx(Ze.Input,{ref:E,size:"sm",fullWidth:!0,value:M,placeholder:i,leftIcon:e.jsx(B.Icon,{name:"Search",width:16,height:16}),onChange:O=>y(O.target.value),onKeyDown:v,onBlur:w,tabIndex:f?0:-1}),f&&!M&&e.jsx(h.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(C.Text,{fontSize:"xs",color:"subtle",children:o})})]})]})},wn=({columns:t,allVisible:r,onToggle:n,onReorder:i,onSetAllHidden:o})=>{const[s,c]=u.useState(null),[l,d]=u.useState(null),a=()=>{s!==null&&l!==null&&s!==l&&i(s,l),c(null),d(null)},f=(m,g)=>{const j=m+g;j<0||j>=t.length||i(m,j)};return e.jsxs(I.Menu,{position:"bottom-right",children:[e.jsx(I.MenuButton,{children:e.jsx(V.Button,{variant:r?"outline":"secondary",tone:"neutral",size:"sm",iconLeft:e.jsx(B.Icon,{name:"Grid",size:"sm"}),"aria-label":"Customize columns"})}),e.jsx(I.MenuLists,{children:e.jsx(I.MenuBody,{children:e.jsxs(h.Box,{padding:"sm",direction:"column",customWidth:"296px",customMaxHeight:"60vh",overflow:"overflow-hidden",children:[e.jsx(C.Text,{fontWeight:"semibold",color:"primary",children:"Customize Column Table"}),e.jsxs(h.Box,{direction:"row",display:"flex",align:"center",justify:"space-between",paddingBlock:"md",children:[e.jsx(C.Text,{fontSize:"sm",fontWeight:"medium",color:"subtle",children:"Show in table"}),e.jsx(V.Button,{variant:"link",tone:"info",size:"xs",onClick:()=>o(r),children:r?"Hide All":"Show All"})]}),e.jsx(h.Box,{direction:"column",overflow:"overflow-y-auto",children:t.map((m,g)=>{const j=!m.locked,M=l===g&&s!==null&&s!==g;return e.jsxs(h.Box,{direction:"row",display:"flex",align:"center",gap:"sm",paddingBlock:"xs",draggable:j,onDragStart:()=>j&&c(g),onDragOver:y=>{y.preventDefault(),d(g)},onDrop:a,onDragEnd:a,style:{minHeight:32,boxShadow:M?"inset 0 2px 0 0 var(--sa-background-brand, #04254f)":void 0},children:[e.jsx(h.Box,{direction:"column",as:"div",align:"center",justify:"center",role:"button",tabIndex:j?0:-1,"aria-label":`Reorder ${m.title}`,"aria-disabled":!j||void 0,color:"icon-subtlest",onKeyDown:y=>{j&&(y.key==="ArrowUp"?(y.preventDefault(),f(g,-1)):y.key==="ArrowDown"&&(y.preventDefault(),f(g,1)))},style:{display:"inline-flex",cursor:j?"grab":"default",opacity:j?1:.4},children:e.jsx(B.Icon,{name:"DragVertical",width:16,height:16})}),m.icon&&e.jsx(h.Box,{direction:"column",align:"center",color:"icon-subtle",style:{display:"inline-flex"},children:m.icon}),e.jsx(C.Text,{fontSize:"sm",fontWeight:"medium",color:"primary",truncate:!0,children:m.title}),e.jsx(h.Box,{direction:"column",style:{marginLeft:"auto"},children:e.jsx(lt.Toggle,{size:"sm",checked:m.visible,disabled:m.locked,onChange:()=>n(m.key),"aria-label":`Toggle ${m.title} column`})})]},m.key)})})]})})})]})},Dn=({views:t,onApply:r,onDelete:n,onSave:i})=>{const[o,s]=u.useState(""),c=()=>{const l=o.trim();l&&(i(l),s(""))};return e.jsxs(I.Menu,{position:"bottom-right",children:[e.jsx(I.MenuButton,{children:e.jsx(V.Button,{variant:t.length>0?"secondary":"outline",tone:(t.length>0,"neutral"),size:"sm",iconLeft:e.jsx(B.Icon,{name:"Bookmark",size:"sm"}),"aria-label":"Saved views"})}),e.jsxs(I.MenuLists,{style:{width:"260px"},children:[e.jsx(I.MenuBody,{children:e.jsxs(h.Box,{direction:"column",padding:"xs",gap:"sm",children:[e.jsx(C.Text,{fontWeight:"semibold",color:"primary",children:"Saved Views"}),e.jsx(h.Box,{direction:"column",overflow:"overflow-y-auto",children:t.length===0?e.jsx(h.Box,{direction:"column",paddingBlock:"sm",children:e.jsx(C.Text,{fontSize:"sm",color:"subtlest",children:"No saved views yet"})}):t.map(l=>e.jsx(I.MenuItem,{startIcon:e.jsx(B.Icon,{name:"Bookmark"}),onClick:()=>r(l),endIcon:e.jsx(V.Button,{variant:"link",tone:"error",size:"sm",iconLeft:e.jsx(B.Icon,{name:"Trash2"}),"aria-label":`Delete ${l.name}`,onClick:d=>{d.stopPropagation(),n(l.id)}}),children:l.name},l.id))})]})}),e.jsx(I.MenuFooter,{children:e.jsxs(h.Box,{direction:"row",gap:"xs",children:[e.jsx(h.Box,{direction:"column",style:{flex:"1 0 0",minWidth:0},children:e.jsx(Ze.Input,{size:"sm",fullWidth:!0,placeholder:"Save current view as…",value:o,onChange:l=>s(l.target.value),onKeyDown:l=>{l.key==="Enter"&&c()}})}),e.jsx(V.Button,{variant:"primary",tone:"brand",size:"sm",disabled:!o.trim(),onClick:c,children:"Save"})]})})]})]})},li=({isOpen:t,onClose:r,configs:n,activeKeys:i,configByKey:o,hasActiveFilter:s,onToggle:c,onReset:l,getValue:d,setValue:a,clearValue:f,removeFilter:m})=>{const g=i.length;return e.jsx(Ft.Drawer,{position:"bottom",isShow:t,onHide:r,children:e.jsxs(h.Box,{direction:"column",customMaxHeight:"85vh",style:{minHeight:280},children:[e.jsxs(h.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(h.Box,{direction:"row",display:"flex",align:"center",gap:"xs",children:[e.jsx(C.Text,{fontWeight:"semibold",color:"primary",children:"Filter"}),g>0&&e.jsxs(C.Text,{fontSize:"sm",color:"subtle",children:["(",g,")"]})]}),e.jsx(V.Button,{variant:"link",tone:"neutral",size:"sm",iconLeft:e.jsx(B.Icon,{name:"Cross"}),"aria-label":"Close filter",onClick:r})]}),e.jsxs(h.Box,{direction:"column",gap:"lg",padding:"md",overflow:"overflow-y-auto",style:{flex:"1 1 auto",minHeight:0},children:[g>0&&e.jsxs(h.Box,{direction:"column",gap:"sm",children:[e.jsx(C.Text,{fontSize:"xs",fontWeight:"medium",color:"subtlest",children:"Filter aktif"}),e.jsx(h.Box,{direction:"row",display:"flex",wrap:"wrap",gap:"sm",align:"center",children:e.jsx(vn,{activeKeys:i,configByKey:o,getValue:d,setValue:a,clearValue:f,removeFilter:m})})]}),n.length>0&&e.jsxs(h.Box,{direction:"column",gap:"sm",children:[e.jsx(C.Text,{fontSize:"xs",fontWeight:"medium",color:"subtlest",children:"Tambah filter"}),e.jsx(h.Box,{direction:"column",children:n.map(j=>{const M=i.includes(j.key),y=!!j.locked;return e.jsxs(h.Box,{direction:"row",display:"flex",align:"center",justify:"space-between",gap:"sm",paddingBlock:"sm",style:{opacity:y?.5:1,borderTop:"1px solid var(--sa-border-subtle, rgba(11, 18, 14, 0.08))"},children:[e.jsxs(h.Box,{direction:"row",display:"flex",align:"center",gap:"sm",style:{minWidth:0},children:[j.icon&&e.jsx(h.Box,{direction:"column",align:"center",color:"icon-subtle",style:{display:"inline-flex"},children:j.icon}),e.jsx(C.Text,{fontSize:"sm",color:"primary",truncate:!0,children:j.label})]}),e.jsx(lt.Toggle,{size:"sm",checked:M||y,disabled:y,onChange:()=>c(j.key),"aria-label":`Toggle ${j.label}`})]},j.key)})})]})]}),e.jsxs(h.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(h.Box,{direction:"column",style:{flex:"1 1 0"},children:e.jsx(V.Button,{variant:"outline",tone:"neutral",size:"md",fullWidth:!0,disabled:!s,onClick:l,children:"Reset"})}),e.jsx(h.Box,{direction:"column",style:{flex:"1 1 0"},children:e.jsx(V.Button,{variant:"primary",tone:"brand",size:"md",fullWidth:!0,onClick:r,children:"Selesai"})})]})]})})},ci=t=>`${t} Rows`,ai=({perPageKey:t,pageKey:r,pageSizeOptions:n,defaultPerPage:i=10,showPageSize:o})=>{const{searchQueries:s,setSearchParams:c,searchParams:l}=Be(),d=l.get(t),a=d?Number(d):i,f=m=>{c({...s,[t]:m,[r]:"1"})};return o?e.jsxs(I.Menu,{position:"bottom-right",children:[e.jsx(I.MenuButton,{children:e.jsx(V.Button,{variant:"outline",tone:"neutral",size:"sm",iconLeft:e.jsx(B.Icon,{name:"MenuVertical",size:"sm"}),"aria-label":"More options"})}),e.jsx(I.MenuLists,{children:e.jsxs(I.MenuBody,{style:{minWidth:200},children:[e.jsx(h.Box,{paddingInline:"sm",paddingBlock:"xs",children:e.jsx(C.Text,{fontSize:"xs",fontWeight:"medium",color:"subtlest",children:"Rows per page"})}),n.map(m=>e.jsx(I.MenuItem,{selected:m===a,endIcon:m===a?e.jsx(B.Icon,{name:"Check"}):void 0,onClick:()=>f(String(m)),children:ci(m)},m))]})})]}):null},di=t=>{var ge;const{withPadding:r,configs:n,activeKeys:i,configByKey:o,hasActiveFilter:s,toggleFilter:c,removeFilter:l,getValue:d,setValue:a,clearValue:f,onReset:m,searchable:g,searchKey:j,filterKey:M,pageKey:y,searchPlaceholder:D,searchShortcut:E,searchCollapsible:T,pagination:w,perPageKey:v,pageSizeOptions:R,defaultPerPage:O,showPagination:b,showResultCount:S,showPageSize:P,hasColumns:A,orderedColumns:N,allVisible:G,onToggleVisibility:re,onReorder:xe,onSetAllHidden:ne,showSavedViews:se,savedViews:J,onApplyView:Q,onDeleteView:ae,onSaveView:ee}=t,[ce,we]=u.useState(!1),{searchQueries:ze,setSearchParams:fe}=Be(),De=(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),Me=(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)),me=Fe=>{fe({...ze,[y]:String(Fe)})},Ie=S||b&&!!(w!=null&&w.totalPage),Ne=()=>{m(),we(!1)};return e.jsxs(h.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(h.Box,{direction:"row",display:"flex",align:"center",wrap:"wrap",gap:"sm",fullWidth:!0,overflow:"overflow-auto",children:[g&&e.jsx(Cn,{searchKey:j,filterKey:M,pageKey:y,placeholder:D,shortcut:E,collapsible:T}),e.jsx(V.Button,{variant:s?"secondary":"outline",tone:"neutral",size:"sm",iconLeft:e.jsx(B.Icon,{name:"FilterHorizontal"}),onClick:()=>we(!0),"aria-label":"Open filters",children:s?`Filter: ${i.length}`:null}),e.jsxs(h.Box,{direction:"row",display:"flex",align:"center",gap:"sm",style:{marginLeft:"auto"},children:[se&&e.jsx(Dn,{views:J,onApply:Q,onDelete:ae,onSave:ee}),A&&e.jsx(wn,{columns:N,allVisible:G,onToggle:re,onReorder:xe,onSetAllHidden:ne}),e.jsx(ai,{perPageKey:v,pageKey:y,pageSizeOptions:R,defaultPerPage:O,showPageSize:P})]})]}),Ie&&e.jsxs(h.Box,{direction:"row",display:"flex",align:"center",justify:"space-between",gap:"sm",fullWidth:!0,children:[S?e.jsx(C.Text,{fontSize:"sm",fontWeight:"medium",color:"primary",truncate:!0,children:`${De}-${Me} of ${((ge=w==null?void 0:w.totalData)==null?void 0:ge.toLocaleString())||0}`}):e.jsx(h.Box,{direction:"column"}),b&&!!(w!=null&&w.totalPage)&&e.jsx(xt.Pagination,{size:"xs",variant:"neutral",siblingCount:0,currentPage:w!=null&&w.currentPage?Number(w.currentPage):1,totalPages:Number(w.totalPage),onPageChange:me})]}),e.jsx(li,{isOpen:ce,onClose:()=>we(!1),configs:n,activeKeys:i,configByKey:o,hasActiveFilter:s,onToggle:c,onReset:Ne,getValue:d,setValue:a,clearValue:f,removeFilter:l})]})},ui=({withPadding:t=!1,filterConfigs:r=[],filterKey:n="filter",activeFilterKey:i="filters",pageKey:o="page",perPageKey:s="perPage",pageSizeOptions:c=[25,50,100],defaultPerPage:l,showPagination:d=!0,showResultCount:a=!0,showPageSize:f=!0,searchable:m=!1,searchKey:g="q",searchPlaceholder:j="Search",searchShortcut:M="/",searchPosition:y="right",searchCollapsible:D=!0,pagination:E,columns:T=[],onColumnsChange:w,columnsState:v,scopeId:R,savedViews:O,persistLastState:b=!0,storage:S=xr,onReset:P})=>{const A=R??(O==null?void 0:O.scopeId),{activeKeys:N,configByKey:G,hasActiveFilter:re,toggleFilter:xe,removeFilter:ne,getValue:se,setValue:J,clearValue:Q,clearAll:ae}=ur({configs:r,filterKey:n,activeFilterKey:i,pageKey:o,searchKey:g}),ee=Ro({columns:T,scopeId:A,storage:S,onColumnsChange:w,value:v}),ce=Ao({scopeId:A,storage:S,snapshotKeys:[i,n,s],pageKey:o,getColumns:()=>ee.state,applyColumns:ee.applyState}),we=zo({scopeId:A,storage:S,snapshotKeys:[i,n,o],enabled:b}),ze=Vo({scopeId:A,storage:S,perPageKey:s,pageSizeOptions:c,enabled:b});Po({enabled:b&&!!A,snapshotKeys:[i,n,o],perPageKey:s,readSnapshot:we.read,readPerPage:ze.read});const fe=l??c[0]??25,De=!!(O!=null&&O.enabled)&&ce.enabled,Me=()=>{ae(),we.clear(),P==null||P()},me=he.useMediaQuery("md"),Ie=m?e.jsx(Cn,{searchKey:g,filterKey:n,pageKey:o,placeholder:j,shortcut:M,collapsible:D}):null;return me?e.jsxs(h.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(h.Box,{direction:"row",display:"flex",align:"center",gap:"sm",style:{flex:"1 1 0",minWidth:0},children:[e.jsx(No,{configs:r,activeKeys:N,onToggle:xe,hasActiveFilter:re,onReset:Me}),y==="left"&&Ie,e.jsxs(h.Box,{direction:"row",display:"flex",align:"center",gap:"sm",overflow:"overflow-x-auto",style:{flex:"1 1 0",minWidth:0},children:[e.jsx(vn,{activeKeys:N,configByKey:G,getValue:se,setValue:J,clearValue:Q,removeFilter:ne}),re&&e.jsx(V.Button,{variant:"link",tone:"brand",size:"sm",onClick:Me,children:"Reset"})]})]}),e.jsxs(h.Box,{direction:"row",display:"flex",align:"center",gap:"sm",children:[e.jsx(oi,{pagination:E,pageKey:o,perPageKey:s,pageSizeOptions:c,defaultPerPage:fe,showPagination:d,showResultCount:a,showPageSize:f}),y==="right"&&Ie,De&&e.jsx(Dn,{views:ce.views,onApply:ce.applyView,onDelete:ce.deleteView,onSave:ce.saveView}),T.length>0&&e.jsx(wn,{columns:ee.orderedColumns,allVisible:ee.allVisible,onToggle:ee.toggleVisibility,onReorder:ee.reorder,onSetAllHidden:ee.setAllHidden})]})]}):e.jsx(di,{withPadding:t,configs:r,activeKeys:N,configByKey:G,hasActiveFilter:re,toggleFilter:xe,removeFilter:ne,getValue:se,setValue:J,clearValue:Q,onReset:Me,searchable:m,searchKey:g,filterKey:n,pageKey:o,searchPlaceholder:j,searchShortcut:M,searchCollapsible:D,pagination:E,perPageKey:s,pageSizeOptions:c,defaultPerPage:fe,showPagination:d,showResultCount:a,showPageSize:f,hasColumns:T.length>0,orderedColumns:ee.orderedColumns,allVisible:ee.allVisible,onToggleVisibility:ee.toggleVisibility,onReorder:ee.reorder,onSetAllHidden:ee.setAllHidden,showSavedViews:De,savedViews:ce.views,onApplyView:ce.applyView,onDeleteView:ce.deleteView,onSaveView:ce.saveView})},xi=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},hi=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 xi(r);case"dropdown-multiple":case"checkbox-multiple":return hi(r);case"date":return r instanceof Date?r.toISOString():void 0;case"date-compact":return r;default:return}},Nr=(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:i="filters",pageKey:o="page",perPageKey:s="perPage",searchKey:c="q",defaultPage:l=1,defaultPerPage:d=10,paramKeys:a,serialize:f}=t,{activeKeys:m,configByKey:g,hasActiveFilter:j,getValue:M}=ur({configs:r,filterKey:n,activeFilterKey:i,pageKey:o,searchKey:c}),{searchParams:y}=Be(),D=y.toString();return u.useMemo(()=>{const T={},w={},v=Nr(y.get(o),l),R=Nr(y.get(s),d);T[(a==null?void 0:a.page)??"page"]=v,T[(a==null?void 0:a.perPage)??"perPage"]=R;const O=Lt(c,y,n)||"";O&&(T[(a==null?void 0:a.search)??"search"]=O);let b=!1;for(const S of m){const P=g[S];if(!P)continue;const A=M(P);w[S]=A;const N=f==null?void 0:f[S],G=N?N(A):fi(P,A);if(G==null||Array.isArray(G)&&G.length===0)continue;const re=(a==null?void 0:a[S])??S;T[re]=G,b=!0}return{params:T,raw:w,hasActiveFilter:j||!!O||b}},[D,m.join("|"),n,i,o,s,c,l,d,a,f,g])},gi=["dropdown","dropdown-multiple","checkbox-multiple","radio"],yi=({filterConfigs:t,filterKey:r,activeFilterKey:n,pageKey:i,searchKey:o})=>{const{configByKey:s,getValue:c,setValue:l,removeFilter:d,clearAll:a,hasActiveFilter:f}=ur({configs:t,filterKey:r,activeFilterKey:n,pageKey:i,searchKey:o}),m=(E,T)=>{var v;const w=E.options;return((v=w==null?void 0:w.find(R=>R.value===T))==null?void 0:v.label)??T},g=u.useCallback(E=>{const T=s[E];if(!T)return[];const w=c(T);return Array.isArray(w)?w.map(v=>String(v.value)):[]},[s,c]),j=u.useCallback((E,T)=>{const w=s[E];if(!w||!gi.includes(w.type))return;const v=Array.isArray(T)?T:[T];if(v.length===0){d(E);return}l(w,v.map(R=>({label:m(w,R),value:R})))},[s,l,d]),M=u.useCallback((E,T)=>{const w=g(E);j(E,w.includes(T)?w.filter(v=>v!==T):[...w,T])},[g,j]),y=u.useCallback((E,T)=>g(E).includes(T),[g]),D=u.useCallback(E=>d(E),[d]);return{set:j,toggle:M,clear:D,clearAll:a,isActive:y,values:g,hasActiveFilter:f}},pi=(t,r)=>{if(!t)return{};const{fromKey:n,toKey:i,opKey:o}=r,s={};switch(t.op){case"is":case"is-before":case"is-after":case"is-on-or-before":case"is-on-or-after":return t.date&&(s[n]=new Date(t.date).toISOString()),o&&(s[o]=t.op),s;case"is-between":return t.from&&(s[n]=new Date(t.from).toISOString()),t.to&&(s[i]=new Date(t.to).toISOString()),s;case"is-relative-to-today":{if(!t.relative)return s;const{from:c,to:l}=jn(t.relative);return s[n]=c.toISOString(),s[i]=l.toISOString(),s}case"is-empty":case"is-not-empty":return o&&(s[o]=t.op==="is-empty"?"empty":"not-empty"),s;default:return s}},Sn=({children:t,borderRadius:r,height:n})=>{const i=u.useRef(null),[o,s]=u.useState("100vh");return u.useEffect(()=>{if(n)return;const c=()=>{if(i.current){const l=i.current.getBoundingClientRect().top;s(`calc(100vh - ${l}px)`)}};return c(),window.addEventListener("resize",c),()=>window.removeEventListener("resize",c)},[n]),e.jsx(h.Box,{ref:i,fullWidth:!0,borderStyle:"border-solid",borderWidth:"border",borderColor:"border-base",borderRadius:r||"rounded-xs",style:{height:n??o,display:"flex",flexDirection:"column"},children:t})},kn=({action:t,rightContent:r,leftContent:n,headerSlot:i,advanceFilter:o,showFilter:s=!0})=>{const c=he.useMediaQuery("md"),l=s?e.jsx(pn,{...o}):null,d=()=>t?u.isValidElement(t)?t:e.jsx(h.Box,{style:{display:"flex",flexDirection:c?"row":"column",gap:"8px",width:c?"auto":"100%",textWrap:"nowrap"},children:t.map(({title:a,icon:f,buttonProps:m,onClick:g},j)=>!a&&!f?null:e.jsx(V.Button,{fullWidth:!c,iconLeft:f?e.jsx(B.Icon,{name:f}):void 0,onClick:g,...m,children:a},`action-${j}`))}):null;return e.jsx(h.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:c?"row":"column-reverse",gap:"16px"},children:i?i({filter:l}):e.jsxs(e.Fragment,{children:[e.jsxs(h.Box,{style:{display:"flex",gap:"8px",flexDirection:"row",alignItems:"center",flex:1,minWidth:0},children:[l,n]}),e.jsxs(h.Box,{style:{display:"flex",gap:"8px",flexDirection:"row",alignItems:"center",flexShrink:0},children:[r,d()]})]})})},ji=({totalData:t,withMarginBottom:r=!0,withMarginTop:n=!0})=>e.jsxs(h.Box,{style:{display:"flex",gap:"4px",flexDirection:"row",alignItems:"center",marginBottom:r?"16px":void 0,marginTop:n?"16px":void 0},children:[e.jsxs(Ae.Body1,{props:{color:"gray-500"},children:["Total data:"," "]}),e.jsx(Ae.Body1,{children:t||0})]}),Bn=({pagination:t,pageKey:r="page",perPageKey:n="perPage",defaultPerPage:i=10,showPagination:o=!0,totalData:s})=>{const{searchQueries:c,setSearchParams:l,searchParams:d}=Be(),a=d.get(n),f=M=>{l({...c,[r]:String(M)})},m=M=>{l({...c,[n]:M,[r]:"1"})},g=(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),j=(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(h.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(h.Box,{style:{display:"flex",flexDirection:"row",gap:"8px",alignItems:"center",textWrap:"nowrap"},children:[e.jsx(C.Text,{children:"Rows Per Page: "}),e.jsx(it.Dropdown,{dropdownLists:[{label:"5",value:"5"},{label:"10",value:"10"},{label:"25",value:"25"},{label:"50",value:"50"},{label:"100",value:"100"}],onChange:M=>{m(M[0].value)},value:a?[{label:`${a} per row`,value:a}]:[{label:`${i} per row`,value:`${i}`}],defaultValue:a?[{label:`${a} per row`,value:a}]:[{label:`${i} per row`,value:`${i}`}]}),e.jsx(C.Text,{children:`${g}-${j} of ${(t==null?void 0:t.totalData)||0}`})]}),e.jsx(xt.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(ji,{totalData:s,withMarginBottom:!1,withMarginTop:!1})})},Fn=({filter:t,columnTitle:r})=>{const[n,i]=u.useState(!1),o=u.useRef(null),s=u.useRef(null),c=u.useRef(null),[l,d]=u.useState(""),[a,f]=u.useState({top:0,left:0}),m=t.selectedValues,g=u.useMemo(()=>l?t.options.filter(y=>y.label.toLowerCase().includes(l.toLowerCase())):t.options,[t.options,l]);u.useEffect(()=>{if(n&&s.current){const y=s.current.getBoundingClientRect(),D=280,E={top:y.bottom+8};t.position==="left"||y.left+D>window.innerWidth?E.right=window.innerWidth-y.right:E.left=y.left,f(E)}},[n,t.position]),u.useEffect(()=>{n&&c.current?setTimeout(()=>{var y;return(y=c.current)==null?void 0:y.focus()},50):d("")},[n]),u.useEffect(()=>{const y=D=>{o.current&&!o.current.contains(D.target)&&s.current&&!s.current.contains(D.target)&&i(!1)};return n&&document.addEventListener("mousedown",y),()=>document.removeEventListener("mousedown",y)},[n]);const j=y=>{const D=m.includes(y)?m.filter(E=>E!==y):[...m,y];t.onFilterChange(D)},M=()=>t.onFilterChange([]);return e.jsxs(h.Box,{direction:"column",style:{position:"relative"},children:[e.jsx(h.Box,{ref:s,style:{display:"flex",flexDirection:"row",alignItems:"center",cursor:"pointer"},onClick:y=>{var D;y.stopPropagation(),n||(D=t.onOpen)==null||D.call(t),i(E=>!E)},children:e.jsx(B.Icon,{name:n?"ChevronUp":"ChevronDown",size:"sm",style:{color:m.length>0?"var(--sa-color-brand-500, #1a4fa0)":"var(--sa-text-subtle, #8c8f97)"}})}),n&&e.jsxs(h.Box,{ref:o,style:{position:"fixed",top:`${a.top}px`,...a.left!==void 0?{left:`${a.left}px`}:{right:`${a.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(h.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(C.Text,{fontSize:"sm",fontWeight:"semibold",color:"gray-700",children:["Filter ",r]}),m.length>0&&e.jsx(h.Box,{direction:"column",style:{cursor:"pointer"},children:e.jsx(C.Text,{fontSize:"xs",color:"primary",fontWeight:"semibold",onClick:y=>{y.stopPropagation(),M()},children:"CLEAR"})})]}),!t.hideSearch&&e.jsx(h.Box,{direction:"column",style:{paddingLeft:"16px",paddingRight:"16px",paddingTop:"8px",paddingBottom:"8px"},children:e.jsx(Ze.Input,{ref:c,placeholder:`Search ${r.toLowerCase()}...`,leftIcon:e.jsx(B.Icon,{name:"Search",size:"sm"}),value:l,onChange:y=>d(y.target.value),style:{fontSize:"14px"}})}),e.jsx(h.Box,{direction:"column",className:"ts-filter-dropdown-options",style:{overflowY:"auto",maxHeight:"250px",paddingLeft:"8px",paddingRight:"8px"},children:t.isLoadingOptions?e.jsxs(h.Box,{style:{paddingTop:"40px",paddingBottom:"40px",display:"flex",alignItems:"center",justifyContent:"center",flexDirection:"column"},children:[e.jsx(B.Icon,{name:"Loading",size:"lg",style:{color:"var(--sa-background-brand, #04254f)",animation:"spin 1s linear infinite"}}),e.jsx(C.Text,{fontSize:"sm",color:"gray-500",style:{textAlign:"center",marginTop:"8px"},children:"Loading options..."})]}):g.length>0?e.jsx(h.Box,{direction:"column",style:{gap:"2px",paddingTop:"4px",paddingBottom:"4px"},children:g.map(y=>e.jsxs(h.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:m.includes(y.value)?"var(--sa-color-brand-50, #e6edf6)":"transparent"},onClick:D=>{D.stopPropagation(),j(y.value)},onMouseEnter:D=>{m.includes(y.value)||(D.currentTarget.style.backgroundColor="var(--sa-background-primary, #ffffff)"),D.currentTarget.style.transform="translateX(2px)"},onMouseLeave:D=>{D.currentTarget.style.backgroundColor=m.includes(y.value)?"var(--sa-color-brand-50, #e6edf6)":"transparent",D.currentTarget.style.transform="translateX(0)"},children:[e.jsx(ct.Checkbox,{checked:m.includes(y.value),onChange:()=>{}}),e.jsx(C.Text,{fontSize:"sm",fontWeight:m.includes(y.value)?"medium":"normal",color:m.includes(y.value)?"primary":"gray-700",children:y.label})]},y.value))}):e.jsxs(h.Box,{style:{paddingTop:"40px",paddingBottom:"40px",display:"flex",alignItems:"center",justifyContent:"center",flexDirection:"column"},children:[e.jsx(B.Icon,{name:"Search",size:"lg",style:{color:"var(--sa-text-subtle, #8c8f97)"}}),e.jsx(C.Text,{fontSize:"sm",color:"gray-500",style:{textAlign:"center",marginTop:"8px"},children:"No results found"})]})}),m.length>0&&e.jsx(h.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(h.Box,{style:{display:"flex",flexDirection:"row",alignItems:"center",gap:"4px"},children:[e.jsx(h.Box,{direction:"column",style:{backgroundColor:"var(--sa-background-brand, #04254f)",borderRadius:"12px",padding:"2px 8px",fontSize:"11px",fontWeight:600,color:"white"},children:m.length}),e.jsxs(C.Text,{fontSize:"xs",color:"primary",fontWeight:"medium",children:["item",m.length>1?"s":""," selected"]})]})})]})]})},bi=({direction:t})=>{const r="var(--sa-text-primary, #292a2e)",n="var(--sa-text-subtle, #8c8f97)",i=t==="asc"?r:n,o=t==="desc"?r:n,s=t==="asc"?1:.45,c=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:i,opacity:s,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:c},children:e.jsx("path",{d:"M0 0 L8 0 L4 5 Z",fill:"currentColor"})})]})},vi=({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"})]}),Ut="var(--sa-background-primary, #ffffff)",_r="var(--sa-background-primary-inverse, #f8f8f8)",En=({columns:t,records:r,handleDetail:n,handleUpdate:i,handleDelete:o,isLoading:s,visibleHandleDelete:c,visibleHandleUpdate:l,visibleHandleDetail:d,showHeadBorder:a=!1,scrollParentRef:f,frozenCount:m=0,onFrozenCountChange:g,customActions:j,actionsOrder:M=["detail","update","delete","custom"],customEmptyState:y,enableColumnResize:D=!1,defaultColumnWidths:E,onColumnWidthsChange:T,defaultMinColumnWidth:w=60,sort:v,defaultSort:R,onSortChange:O,showActionDivider:b=!1})=>{const S=v!==void 0,[P,A]=u.useState(R??null),N=S?v??null:P,G=L=>{if(L.sortKey)return L.sortKey;if(typeof L.accessor=="string")return L.accessor},re=L=>{const z=G(L);if(!z)return;let H;!N||N.key!==z?H={key:z,direction:"asc"}:N.direction==="asc"?H={key:z,direction:"desc"}:H=null,S||A(H),O==null||O(H)},ne=[n,i,o].filter(L=>L!==void 0).length,se=!!j,J=!!n||!!i||!!o||se,Q="var(--sa-border-subtle, #0b120e24)",ae=`1px solid ${Q}`,ee=`inset 1px 0 0 ${Q}`,ce=`inset -1px 0 0 ${Q}`,we=ne===3?se?"178px":"140px":ne===2?se?"140px":"102px":ne===1?se?"112px":"74px":se?"74px":"",ze=(L,z)=>{if(!z)return L;if(typeof z=="function")return z(L);if(typeof z=="string")return L[z]},[fe,De]=u.useState(!1);u.useEffect(()=>{if(!(f!=null&&f.current))return;const L=f.current;De(L.scrollHeight>L.clientHeight)},[r,f]);const Me=u.useRef(null),[me,Ie]=u.useState([]),[Ne,ge]=u.useState(()=>E??{}),Fe=u.useRef(null);u.useLayoutEffect(()=>{if(!m||!Me.current){Ie([]);return}const L=Array.from(Me.current.querySelectorAll("thead tr th")),z=[];let H=0;L.forEach((q,K)=>{z[K]=H,K<m&&(H+=q.offsetWidth)}),Ie(z)},[m,t,r,Ne]);const Ge=L=>{g&&g(L<m?L:L+1)},k=(L,z)=>{const H=Ne[L];if(H!==void 0){const q=`${H}px`;return{width:q,minWidth:q,maxWidth:q}}return z?{width:z}:{}},Z=L=>D&&(L.resizable??!0),_=(L,z)=>{L.preventDefault(),L.stopPropagation();const H=L.currentTarget.closest("th");if(!H)return;const q=Math.round(H.getBoundingClientRect().width);Fe.current={colIndex:z,startX:L.clientX,startWidth:q};const K=document.body.style.userSelect,je=document.body.style.cursor;document.body.style.userSelect="none",document.body.style.cursor="col-resize";const Se=Oe=>{var Je;const Le=Fe.current;if(!Le)return;const Qe=((Je=t[Le.colIndex])==null?void 0:Je.minWidth)??w,Ue=Math.max(Qe,Le.startWidth+(Oe.clientX-Le.startX));ge(We=>We[Le.colIndex]===Ue?We:{...We,[Le.colIndex]:Ue})},Te=()=>{document.removeEventListener("mousemove",Se),document.removeEventListener("mouseup",Te),document.body.style.userSelect=K,document.body.style.cursor=je,Fe.current=null,T&&ge(Oe=>(T(Oe),Oe))};document.addEventListener("mousemove",Se),document.addEventListener("mouseup",Te)};return e.jsx("div",{ref:Me,children:e.jsxs(U.Table,{fullWidth:!0,children:[e.jsx(U.Thead,{style:{height:"40px",whiteSpace:"nowrap"},children:e.jsxs(U.Tr,{children:[t.map((L,z)=>{var $e,et;const H=m>0&&z<m,q=me[z]??0,K=Z(L),Se=z===t.length-1&&J&&b,Te=G(L),Oe=!!L.sortable&&!!Te,Le=Oe&&(N==null?void 0:N.key)===Te?N.direction:null,Qe=L.title||(($e=L.accessor)==null?void 0:$e.toString())||"",Ue=(et=L.headerTooltip)!=null&&et.showIcon?e.jsx(B.Icon,{name:"InfoCircle",size:"xs",style:{flexShrink:0,color:"var(--sa-icon-subtle, #8c8f97)",opacity:.75}}):null,Je=e.jsx("span",{style:{flex:1,minWidth:0,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:Qe}),We=Oe?e.jsxs("button",{type:"button",onClick:()=>re(L),title:Le==="asc"?"Sorted ascending — click to sort descending":Le==="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:L.textAlign==="text-right"?"right":L.textAlign==="text-center"?"center":"left"},children:[Je,Ue,e.jsx(bi,{direction:Le})]}):e.jsxs("span",{style:{flex:1,minWidth:0,display:"flex",alignItems:"center",gap:4},children:[Je,Ue]});return e.jsxs(U.Th,{style:{position:"sticky",top:0,left:H?q:void 0,zIndex:H?4:2,paddingLeft:z===0?"12px":"",borderRight:a&&!Se&&!H?ae:void 0,borderBottom:a?ae:void 0,boxShadow:a&&H?ce:void 0,backgroundColor:"var(--sa-background-primary-inverse, #f8f8f8)",textAlign:L.textAlign==="text-right"?"right":L.textAlign==="text-center"?"center":"left",...k(z,L.width)},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"4px",justifyContent:"space-between",minWidth:0},children:[L.headerTooltip?e.jsx(ve.Tooltip,{label:L.headerTooltip.content,position:"bottom",children:We}):We,L.filter&&e.jsx(Fn,{filter:L.filter,columnTitle:L.title}),g&&e.jsx("button",{onClick:()=>Ge(z),title:H?"Unfreeze column":"Freeze column",style:{background:"none",border:"none",cursor:"pointer",padding:"2px",display:"flex",alignItems:"center",flexShrink:0,color:H?"var(--sa-background-brand, #04254f)":"var(--sa-text-subtle, #8c8f97)",opacity:H?1:.45,transition:"opacity 0.15s"},children:e.jsx(vi,{frozen:H})})]}),K&&e.jsx("div",{onMouseDown:tt=>_(tt,z),onClick:tt=>tt.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}`)}),J?e.jsx(U.Th,{style:{backgroundColor:"var(--sa-background-primary-inverse, #f8f8f8)",position:"sticky",top:0,right:0,zIndex:3,borderBottom:a?ae:void 0,boxShadow:a&&b?ee:void 0}}):null]})}),e.jsx(U.Tbody,{children:s?e.jsx(U.Tr,{children:e.jsx(U.Td,{colSpan:t.length+1,children:e.jsxs(h.Box,{direction:"column",style:{gap:"16px"},children:[e.jsx(Pe.Skeleton,{variant:"list"}),e.jsx(Pe.Skeleton,{variant:"list"}),e.jsx(Pe.Skeleton,{variant:"list"}),e.jsx(Pe.Skeleton,{variant:"list"}),e.jsx(Pe.Skeleton,{variant:"list"})]})})}):!(r!=null&&r.length)&&y?e.jsx(U.Tr,{children:e.jsx(U.Td,{colSpan:t.length+1,children:y})}):r==null?void 0:r.map((L,z)=>e.jsxs(U.Tr,{style:{transition:"background-color 0.3s ease",padding:0,borderBottom:z===r.length-1&&fe?void 0:"1px solid var(--sa-border-subtle, #0b120e24)"},onMouseEnter:H=>{const q=H.currentTarget;q.style.backgroundColor=_r,Array.from(q.querySelectorAll("td")).forEach(K=>{K.style.position==="sticky"&&(K.style.backgroundColor=_r)})},onMouseLeave:H=>{const q=H.currentTarget;q.style.backgroundColor="",Array.from(q.querySelectorAll("td")).forEach(K=>{K.style.position==="sticky"&&(K.style.backgroundColor=Ut)})},children:[t.map((H,q)=>{const K=H.render?H.render(L,z,r):ze(L,H.accessor),je=m>0&&q<m,Se=me[q]??0,Te=Ne[q]!==void 0,Oe=je&&q===m-1;return e.jsx(U.Td,{style:{position:je?"sticky":void 0,left:je?Se:void 0,zIndex:je?1:void 0,backgroundColor:je?Ut:void 0,transition:je?"background-color 0.3s ease":void 0,paddingLeft:q===0?"12px":"",whiteSpace:"nowrap",overflow:Te?"hidden":void 0,borderLeft:H.showBorderLeft?ae:void 0,borderRight:H.showBorderRight?ae:void 0,boxShadow:Oe?ce:void 0,textAlign:H.textAlign==="text-right"?"right":H.textAlign==="text-center"?"center":"left",...k(q,H.width)},children:typeof K=="string"?e.jsx(C.Text,{style:{whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",textAlign:H.textAlign==="text-right"?"right":H.textAlign==="text-center"?"center":"left"},children:K}):K},`row-${z}-col-${q}`)}),J?e.jsx(U.Td,{style:{width:we,position:"sticky",right:0,zIndex:1,backgroundColor:Ut,boxShadow:b?ee:void 0,transition:"background-color 0.3s ease"},children:e.jsx(oe.Flex,{direction:"row",align:"center",justify:"center",gap:"sm",children:M.map(H=>{const q=z===r.length-1?"top":"bottom";return H==="detail"&&n&&(d==null?void 0:d(L))!==!1?e.jsx(ve.Tooltip,{label:"Detail",position:q,children:e.jsx(V.Button,{size:"xs",variant:"outline",tone:"neutral",onClick:()=>n(L.id,L),iconLeft:e.jsx(B.Icon,{name:"DocumentClean",size:"sm",style:{color:"var(--sa-text-subtle, #8c8f97)"}})})},"detail"):H==="update"&&i&&(l==null?void 0:l(L))!==!1?e.jsx(ve.Tooltip,{label:"Update",position:q,children:e.jsx(V.Button,{size:"xs",variant:"outline",tone:"neutral",onClick:()=>i(L),iconLeft:e.jsx(B.Icon,{name:"Edit1",size:"sm",style:{color:"var(--sa-text-subtle, #8c8f97)"}})})},"update"):H==="delete"&&o&&(c==null?void 0:c(L))!==!1?e.jsx(ve.Tooltip,{label:"Delete",position:q,children:e.jsx(V.Button,{size:"xs",variant:"outline",tone:"neutral",onClick:()=>o(L.id,L),iconLeft:e.jsx(B.Icon,{name:"Trash1",size:"sm",style:{color:"var(--sa-color-error-600, #c9184a)"}})})},"delete"):H==="custom"?e.jsx(u.Fragment,{children:j==null?void 0:j(L)},"custom"):null})})}):null]},`${L}${z}`))})]})})},Ci=({wrapperProps:t,dataTableProps:r,headerProps:n,footerProps:i})=>{var m;const o=u.useRef(null),[s,c]=u.useState((r==null?void 0:r.defaultFrozenCount)??0),l=(n==null?void 0:n.show)??!0,d=u.useRef(null),a=(m=r==null?void 0:r.pagination)==null?void 0:m.totalData;typeof a=="number"&&(d.current=a);const f=(i==null?void 0:i.showFooter)??(a===void 0?d.current!==0:a!==0);return e.jsxs(Sn,{...t,children:[l&&e.jsx(kn,{...n}),e.jsx(h.Box,{direction:"column",ref:o,style:{flex:1,overflowY:"auto",overflowX:"auto"},children:r?e.jsx(En,{...r,scrollParentRef:o,frozenCount:r!=null&&r.enableFreezeColumns?s:0,onFrozenCountChange:r!=null&&r.enableFreezeColumns?c:void 0}):null}),f&&e.jsx(Bn,{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:i==null?void 0:i.totalData})]})};function wi(t){return u.memo(t)}const Di=wi(Ci),qr=200,Jt="1px solid var(--sa-border-subtle, #0b120e24)",Si=({sortDir:t,frozen:r})=>t==="asc"?e.jsx(B.Icon,{name:"ChevronSmallUp"}):t==="desc"?e.jsx(B.Icon,{name:"ChevronSmallDown"}):r?e.jsx(B.Icon,{name:"LockOn",size:"xs"}):e.jsx(B.Icon,{name:"Filter",size:"xs"}),bt=({icon:t,label:r,active:n,danger:i,onClick:o})=>{const s=i?"var(--sa-color-error-600, #c9184a)":"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:s,textAlign:"left"},onMouseEnter:c=>{n||(c.currentTarget.style.background="var(--sa-background-primary-inverse, #f8f8f8)")},onMouseLeave:c=>{c.currentTarget.style.background=n?"var(--sa-background-brand-subtlest, #e6edf6)":"none"},children:[e.jsx(B.Icon,{name:t,size:"sm",style:{color:s,flexShrink:0}}),e.jsx(C.Text,{as:"span",style:{color:s},children:r})]})},Mn=({active:t,canSort:r,canHide:n,sortDir:i,frozen:o,onSort:s,onClearSort:c,onToggleFreeze:l,onHide:d})=>{const[a,f]=u.useState(!1),m=u.useRef(null),g=u.useRef(null),[j,M]=u.useState({top:0,left:0});u.useEffect(()=>{if(a&&m.current){const D=m.current.getBoundingClientRect(),E=D.left+qr>window.innerWidth;M({top:D.bottom+6,...E?{right:window.innerWidth-D.right}:{left:D.left}})}},[a]),u.useEffect(()=>{if(!a)return;const D=E=>{g.current&&!g.current.contains(E.target)&&m.current&&!m.current.contains(E.target)&&f(!1)};return document.addEventListener("mousedown",D),()=>document.removeEventListener("mousedown",D)},[a]);const y=D=>{D(),f(!1)};return e.jsxs(e.Fragment,{children:[e.jsx("button",{ref:m,type:"button",className:"sa-tl-menu-trigger","data-active":t||a?"true":"false",onClick:D=>{D.stopPropagation(),f(E=>!E)},title:"Column options",style:{display:"inline-flex",alignItems:"center",justifyContent:"center",width:22,height:22,borderRadius:"var(--sa-radii-sm, 6px)",border:Jt,background:"var(--sa-background-primary, #ffffff)",cursor:"pointer",color:"var(--sa-text-subtle, #8c8f97)",flexShrink:0},children:e.jsx(Si,{sortDir:i,frozen:o})}),a&&e.jsxs(h.Box,{ref:g,onClick:D=>D.stopPropagation(),style:{position:"fixed",top:`${j.top}px`,...j.left!==void 0?{left:`${j.left}px`}:{right:`${j.right}px`},minWidth:qr,backgroundColor:"var(--sa-background-primary, #ffffff)",border:Jt,borderRadius:"var(--sa-radii-sm, 6px)",boxShadow:"0 6px 24px rgba(0,0,0,0.12)",zIndex:9999,padding:"4px",display:"flex",flexDirection:"column"},children:[r&&e.jsxs(e.Fragment,{children:[e.jsx(bt,{icon:"ChevronUp",label:"Ascending",active:i==="asc",onClick:()=>y(()=>i==="asc"?c():s("asc"))}),e.jsx(bt,{icon:"ChevronDown",label:"Descending",active:i==="desc",onClick:()=>y(()=>i==="desc"?c():s("desc"))}),e.jsx("div",{style:{borderTop:Jt,margin:"4px 0"}})]}),e.jsx(bt,{icon:"Pin1",label:o?"Unfreeze":"Freeze",active:o,onClick:()=>y(l)}),n&&e.jsx(bt,{icon:"EyeClosed",label:"Hide column",danger:!0,onClick:()=>y(d)})]})]})},vt="1px solid var(--sa-border-subtle, #0b120e24)",ki="var(--sa-text-subtle, #8c8f97)",dt="var(--sa-background-neutral, #f0f1f2)",Zr="2px 0 4px -2px rgba(0,0,0,0.15)",Ct={display:"block",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},Gr="sa-table-layout-styles",Bi=()=>{if(typeof document>"u"||document.getElementById(Gr))return;const t=document.createElement("style");t.id=Gr,t.textContent=`
|
|
2
2
|
.sa-table-layout tbody td { transition: background-color 0.15s ease; }
|
|
3
3
|
.sa-table-layout tbody tr:hover td {
|
|
4
4
|
background-color: var(--sa-background-primary-inverse, #f8f8f8);
|