@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.umd.js CHANGED
@@ -1,4 +1,4 @@
1
- (function(g,er){typeof exports=="object"&&typeof module<"u"?er(exports,require("@starasia/alert"),require("@starasia/badges"),require("@starasia/box"),require("@starasia/breadcrumb"),require("@starasia/button"),require("@starasia/card"),require("@starasia/date"),require("@starasia/dialog"),require("@starasia/drawer"),require("@starasia/dropdown"),require("@starasia/hooks"),require("@starasia/http"),require("@starasia/input"),require("@starasia/menu"),require("@starasia/pagination"),require("@starasia/storage"),require("@starasia/table"),require("@starasia/tabs"),require("@starasia/textarea"),require("@starasia/theme"),require("@starasia/toast"),require("@starasia/toggle"),require("@starasia/tooltip"),require("@starasia/checkbox"),require("@starasia/radio"),require("@starasia/text"),require("@starasia/icon"),require("@starasia/flex"),require("@starasia/grid"),require("@starasia/progress"),require("@starasia/stepper"),require("@starasia/accordion"),require("@starasia/story-record"),require("@starasia/skeleton"),require("@starasia/progress-stepper"),require("react/jsx-runtime"),require("react"),require("react-router"),require("react-dom"),require("react-easy-crop")):typeof define=="function"&&define.amd?define(["exports","@starasia/alert","@starasia/badges","@starasia/box","@starasia/breadcrumb","@starasia/button","@starasia/card","@starasia/date","@starasia/dialog","@starasia/drawer","@starasia/dropdown","@starasia/hooks","@starasia/http","@starasia/input","@starasia/menu","@starasia/pagination","@starasia/storage","@starasia/table","@starasia/tabs","@starasia/textarea","@starasia/theme","@starasia/toast","@starasia/toggle","@starasia/tooltip","@starasia/checkbox","@starasia/radio","@starasia/text","@starasia/icon","@starasia/flex","@starasia/grid","@starasia/progress","@starasia/stepper","@starasia/accordion","@starasia/story-record","@starasia/skeleton","@starasia/progress-stepper","react/jsx-runtime","react","react-router","react-dom","react-easy-crop"],er):(g=typeof globalThis<"u"?globalThis:g||self,er(g["@starasia/admin"]={},g.alert,g.badges,g.box,g.breadcrumb,g.button,g.card,g.date,g.dialog,g.drawer,g.dropdown,g.hooks,g.http,g.input,g.menu,g.pagination,g.storage,g.table,g.tabs,g.textarea,g.theme,g.toast,g.toggle,g.tooltip,g.checkbox,g.radio,g.text,g.icon,g.flex,g.grid,g.progress,g.stepper,g.accordion,g.storyRecord,g.skeleton,g.progressStepper,g.jsxRuntime,g.React,g.ReactRouter,g.ReactDOM,g.ReactEasyCrop))})(this,function(g,er,Ge,u,rr,P,yt,Ue,Oe,vr,tr,ue,lr,Qe,O,fr,gr,U,pt,Pr,or,bt,nr,De,cr,Nr,S,E,ne,vt,Ct,xt,wt,Dt,je,St,e,h,ye,_r,zl){"use strict";const Hl={menus:[],menuBottom:void 0,logo:"",appName:"Workspace",userData:null,setUserData:()=>{}},qr=h.createContext(Hl),Zr=()=>h.useContext(qr),kt=r=>{const[t,l]=h.useState((r==null?void 0:r.initialUserData)||null);return{userData:t,setUserData:l}},Bt=h.createContext({badges:{},setBadge:()=>{},setBadges:()=>{},clearBadge:()=>{}}),mt=({children:r})=>{const[t,l]=h.useState({}),n=h.useCallback(i=>{l(d=>typeof i=="function"?i(d):i)},[]),o=h.useCallback((i,d)=>{l(a=>{const y=typeof d=="function"?d(a[i]):d;return{...a,[i]:y}})},[]),c=h.useCallback(i=>{l(d=>{if(!(i in d))return d;const a={...d};return delete a[i],a})},[]),s=h.useMemo(()=>({badges:t,setBadge:o,setBadges:n,clearBadge:c}),[t,o,n,c]);return e.jsx(Bt.Provider,{value:s,children:r})},Ft=()=>h.useContext(Bt),Cr=(r,t)=>{const l=t!==void 0?t:r;return l==null?null:typeof l=="string"||typeof l=="number"?{value:l}:l},Et=({router:r,menus:t=[],menuBottom:l,logo:n,appName:o="Workspace",initialUserData:c,theme:s})=>{const i=kt({initialUserData:c}),{theme:d}=or.useTheme();return e.jsx(qr.Provider,{value:{logo:n,appName:o,menus:t,userData:i.userData,setUserData:i.setUserData,menuBottom:l},children:e.jsx(mt,{children:s?e.jsx(or.ThemeProvider,{value:s,children:r}):d?e.jsx(or.ThemeProvider,{value:d,children:r}):r})})},Vl=h.memo(Et);function Mt({collapsed:r=!1,children:t}){if(!t)return null;const l=typeof t=="function",n=l?t({collapsed:r}):t;return n==null||n===!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:l?n:e.jsx("div",{style:{opacity:r?0:1,transition:"opacity 0.3s",visibility:r?"hidden":"visible"},children:n})})}const Gr=h.createContext(null);function Lt({children:r}){const[t,l]=h.useState(null),[n,o]=h.useState(null),[c,s]=h.useState(null),[i,d]=h.useState(0),a=h.useCallback(()=>(d(y=>y+1),()=>d(y=>y-1)),[]);return e.jsx(Gr.Provider,{value:{prependNode:t,appendNode:n,replaceNode:c,setPrependNode:l,setAppendNode:o,setReplaceNode:s,replaceCount:i,registerReplace:a},children:r})}function Tt({children:r}){const t=h.useContext(Gr);return t?e.jsxs(e.Fragment,{children:[e.jsx("div",{ref:t.setPrependNode,style:{display:"contents"}}),t.replaceCount>0?e.jsx("div",{ref:t.setReplaceNode,style:{display:"contents"}}):r,e.jsx("div",{ref:t.setAppendNode,style:{display:"contents"}})]}):e.jsx(e.Fragment,{children:r})}function jl({children:r,mode:t="append"}){const l=h.useContext(Gr);if(h.useEffect(()=>{if(!(t!=="replace"||!l))return l.registerReplace()},[t,l]),!l)return process.env.NODE_ENV!=="production"&&console.warn("[HeaderLeftSlot] used outside AppLayout — content not rendered"),null;const n=t==="prepend"?l.prependNode:t==="replace"?l.replaceNode:l.appendNode;return n?_r.createPortal(r,n):null}const Qr=h.createContext(null);function It({children:r}){const[t,l]=h.useState({}),[n,o]=h.useState({}),c=h.useCallback((d,a)=>{l(y=>y[d]===a?y:{...y,[d]:a})},[]),s=h.useCallback(d=>(o(a=>({...a,[d]:(a[d]??0)+1})),()=>o(a=>({...a,[d]:Math.max(0,(a[d]??0)-1)}))),[]),i=h.useMemo(()=>({outletNodes:t,setOutletNode:c,slotCounts:n,registerSlot:s}),[t,c,n,s]);return e.jsx(Qr.Provider,{value:i,children:r})}function Ot({slotKey:r,fallback:t}){const l=h.useContext(Qr),n=l?(l.slotCounts[r]??0)>0:!1,o=h.useRef(l==null?void 0:l.setOutletNode);o.current=l==null?void 0:l.setOutletNode;const c=h.useCallback(s=>{var i;return(i=o.current)==null?void 0:i.call(o,r,s)},[r]);return e.jsx(e.Fragment,{children:n?e.jsx("div",{ref:c,style:{display:"contents"}}):t})}function Pl({slotKey:r,children:t}){const l=h.useContext(Qr),n=h.useRef(l==null?void 0:l.registerSlot);if(n.current=l==null?void 0:l.registerSlot,h.useEffect(()=>{var c;return(c=n.current)==null?void 0:c.call(n,r)},[r]),!l)return process.env.NODE_ENV!=="production"&&console.warn("[SidebarGroupSlot] used outside AppLayout — content not rendered"),null;const o=l.outletNodes[r];return o?_r.createPortal(t,o):null}const xr="moduleSwitcherGroupId",Ur="sa-module-switcher-change";function Wt(){if(typeof window>"u")return null;const r=window.localStorage.getItem(xr);if(r===null)return null;const t=Number(r);return Number.isFinite(t)?t:null}function At(r){typeof window>"u"||(r===null?window.localStorage.removeItem(xr):window.localStorage.setItem(xr,String(r)),window.dispatchEvent(new CustomEvent(Ur,{detail:r})))}function Nl(){At(null)}function Jr(){const[r,t]=h.useState(()=>Wt());return h.useEffect(()=>{const n=()=>{t(Wt())},o=c=>{c.key===xr&&n()};return window.addEventListener(Ur,n),window.addEventListener("storage",o),()=>{window.removeEventListener(Ur,n),window.removeEventListener("storage",o)}},[]),{selectedGroupId:r,setSelectedGroupId:n=>{At(n),t(n)}}}let wr=0,Je=!1,zt=new Set;const Ht=()=>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"})]}),Vt={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 _l({children:r,headerLeftSlot:t,profile:l,isLoadingProfile:n,onLogout:o,isLoggingOut:c,loadingComponent:s,sidebarHeaderContent:i,headerActions:d,profileRole:a,profileMenuButtons:y,profileMenuItems:p,logoutButton:b}){var Le,Ye;const[x]=ye.useSearchParams(),T=x.get("embed")==="true",v=Zr(),{badges:B}=Ft(),L=ye.useNavigate(),W=ye.useLocation(),D=!ue.useMediaQuery("md"),[H,A]=h.useState(!1),[w,m]=h.useState(!1),[_,V]=h.useState(!1),[q,J]=h.useState(!1),[le,ge]=h.useState(()=>new Set(zt)),[oe,ie]=h.useState(null),{selectedGroupId:K,setSelectedGroupId:Y}=Jr();h.useEffect(()=>{zt=le},[le]);const de=h.useRef(null),te=h.useRef(null);h.useEffect(()=>{const F=de.current;if(!F)return;const Q=()=>{Je||(wr=F.scrollTop)};return F.addEventListener("scroll",Q),()=>F.removeEventListener("scroll",Q)},[]);const ae=()=>{const F=de.current;F&&wr>0&&(Je=!0,F.scrollTop=wr,requestAnimationFrame(()=>{Je=!1}))};h.useLayoutEffect(()=>{Je=!0,ae();const F=setTimeout(()=>{Je=!1},300);return()=>clearTimeout(F)},[]),h.useLayoutEffect(()=>{v.menus.length>0&&(wr>0?ae():requestAnimationFrame(()=>{var Q;const F=(Q=de.current)==null?void 0:Q.querySelector("[data-menu-active='true']");F&&F.scrollIntoView({block:"center",behavior:"instant"})}))},[v.menus]),h.useEffect(()=>{Je=!0,ae();const F=setTimeout(ae,0),Q=setTimeout(ae,50),Z=setTimeout(ae,100),I=setTimeout(ae,200),j=setTimeout(()=>{Je=!1},300),N=setTimeout(()=>{const G=de.current,R=G==null?void 0:G.querySelector("[data-menu-active='true']");if(G&&R){const xe=G.getBoundingClientRect(),Fe=R.getBoundingClientRect();Fe.top>=xe.top&&Fe.bottom<=xe.bottom||R.scrollIntoView({block:"center",behavior:"smooth"})}},250);return()=>{clearTimeout(F),clearTimeout(Q),clearTimeout(Z),clearTimeout(I),clearTimeout(j),clearTimeout(N)}},[W.pathname]),h.useEffect(()=>{te.current&&(te.current.scrollTop=0)},[W.pathname]),h.useEffect(()=>{D&&V(!1)},[W.pathname,D]),h.useEffect(()=>{D&&m(!0)},[D]);const Be=()=>{A(!0)},Ne=()=>{A(!1)},pe=()=>{A(!1),o()},me=F=>{const Q=[F.to];return F.children&&Q.push(...F.children.map(Z=>Z.to)),Q},Te=[...v.menus.flatMap(F=>F.items.flatMap(me)),...((Le=v.menuBottom)==null?void 0:Le.flatMap(me))??[]],be=F=>{if(!W.pathname.startsWith(F))return!1;const Q=Te.filter(Z=>W.pathname.startsWith(Z)).sort((Z,I)=>I.length-Z.length)[0];return F===Q};h.useEffect(()=>{var Q;const F=Z=>{var I;(I=Z.children)!=null&&I.some(j=>W.pathname.startsWith(j.to))&&ge(j=>{const N=new Set(j);return N.add(Z.id),N})};v.menus.forEach(Z=>{Z.items.forEach(F)}),(Q=v.menuBottom)==null||Q.forEach(F)},[W.pathname,v.menus,v.menuBottom]);const Ae=F=>{ge(Q=>{const Z=new Set(Q);return Z.has(F)?Z.delete(F):Z.add(F),Z})};h.useEffect(()=>{v.menus.length!==0&&K!==null&&!v.menus.some(F=>F.id===K)&&Y(null)},[v.menus,K,Y]);const Ze=h.useMemo(()=>{if(K!==null)return v.menus.filter(Z=>Z.id===K||Z.parentGroupId===K);const F=v.menus.filter(Z=>Z.parentGroupId===void 0),Q=v.menus.filter(Z=>Z.parentGroupId!==void 0).flatMap(Z=>Z.items);return Q.length===0?F:[...F,{id:18,name:"Pengaturan",items:Q,parentGroupId:void 0}]},[v.menus,K]);if(T)return e.jsx("main",{style:{height:"100vh",overflowY:"auto",backgroundColor:"var(--sa-background-primary-inverse, #f8f8f8)"},children:r||e.jsx(ye.Outlet,{})});const ve=F=>{const Q=F.children&&F.children.length>0,Z=le.has(F.id),I=Q?F.children.some(G=>be(G.to)):be(F.to),j=Cr(F.badge,B[F.id]),N=!!j&&w&&!D;return e.jsxs("div",{"data-menu-active":I||void 0,children:[e.jsxs("button",{onClick:G=>{if(Q)if(w&&!D){const R=G.currentTarget.getBoundingClientRect();ie({item:F,top:R.top,left:R.right+8})}else Ae(F.id);else L(F.to)},style:{width:"100%",display:"flex",alignItems:"center",justifyContent:w&&!D?"center":void 0,gap:"0.5rem",paddingLeft:w&&!D?"0":"0.5rem",paddingRight:w&&!D?"0":"0.5rem",paddingTop:"0.25rem",paddingBottom:"0.25rem",height:"2rem",borderRadius:I?"var(--sa-radii-sm, 0.375rem)":"var(--sa-radii-md, 0.5rem)",textAlign:"left",border:I?"1px solid var(--sa-border-subtle, #0b120e24)":"1px solid transparent",backgroundColor:I?"var(--sa-background-primary, #ffffff)":"transparent",color:"var(--sa-text-primary, #292a2e)",cursor:"pointer"},title:w&&!D?F.title:void 0,onMouseEnter:G=>{I||(G.currentTarget.style.backgroundColor="var(--sa-background-neutral, #f0f1f2)")},onMouseLeave:G=>{I||(G.currentTarget.style.backgroundColor="transparent")},children:[e.jsxs("span",{style:{position:"relative",display:"inline-flex",flexShrink:0},children:[e.jsx(E.Icon,{name:F.icon,size:"sm",style:{flexShrink:0}}),N&&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)"}})]}),(!w||D)&&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:F.title}),j&&e.jsx(Ge.Badges,{text:String(j.value),variant:j.variant??"info",size:"xs",border:!0}),Q&&e.jsx("svg",{style:{width:"1rem",height:"1rem",flexShrink:0,transition:"transform 0.2s",transform:Z?"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"})})]})]}),Q&&(!w||D)&&(()=>{const G=F.children.findIndex(R=>be(R.to));return e.jsxs("div",{style:{position:"relative",marginLeft:"0.9375rem",paddingLeft:"1.125rem",overflow:"hidden",transition:"all 0.3s ease-in-out",maxHeight:Z?`${F.children.length*36}px`:"0px",opacity:Z?1:0,marginTop:Z?"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"}}),G>=0&&e.jsx("span",{"aria-hidden":"true",style:{position:"absolute",left:0,top:`${G*32}px`,width:"1.5px",height:"32px",backgroundColor:"var(--sa-text-primary, #292a2e)",transition:"top 0.2s ease-in-out",pointerEvents:"none",zIndex:1}}),F.children.map(R=>{const xe=Cr(R.badge,B[R.id]);return e.jsxs("button",{onClick:()=>L(R.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:be(R.to)?"var(--sa-radii-sm, 0.375rem)":"var(--sa-radii-md, 0.5rem)",textAlign:"left",backgroundColor:be(R.to)?"var(--sa-background-primary, #ffffff)":"transparent",color:be(R.to)?"var(--sa-text-primary, #292a2e)":"var(--sa-text-subtle, #505258)",cursor:"pointer",border:be(R.to)?"1px solid var(--sa-border-subtle, #0b120e24)":"1px solid transparent"},onMouseEnter:Fe=>{be(R.to)||(Fe.currentTarget.style.backgroundColor="var(--sa-background-neutral, #f0f1f2)")},onMouseLeave:Fe=>{be(R.to)||(Fe.currentTarget.style.backgroundColor="transparent")},children:[e.jsx(E.Icon,{name:R.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:R.title}),xe&&e.jsx(Ge.Badges,{text:String(xe.value),variant:xe.variant??"info",size:"xs",border:!0})]},R.id)})]})})()]},F.id)};return e.jsx(It,{children:e.jsxs(Lt,{children:[e.jsxs("div",{style:{display:"flex",height:"100vh",position:"relative","--app-sidebar-width":D?"0px":w?"4.375rem":"16.375rem","--app-footer-zindex":D&&_?"40":"999"},children:[D&&e.jsx("div",{style:{position:"fixed",inset:0,backgroundColor:"var(--sa-color-black-alpha-a50, #181a198f)",zIndex:40,opacity:_?.5:0,pointerEvents:_?"auto":"none",transition:"opacity 0.3s"},onClick:()=>V(!1)}),e.jsxs("aside",{style:{width:D?"16.375rem":w?"4.375rem":"16.375rem",position:D?"fixed":"relative",...D&&{inset:0,zIndex:50,transform:_?"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:D?void 0:0},children:[e.jsx("div",{onMouseEnter:()=>J(!0),onMouseLeave:()=>J(!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 F=!D&&w&&!_,Q=F&&q;return e.jsxs(e.Fragment,{children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"0.5rem",flex:F?1:void 0,justifyContent:F?"center":void 0,transition:"opacity 0.2s",opacity:Q?0:1,pointerEvents:Q?"none":"auto"},children:[e.jsx("img",{src:v.logo,alt:"Logo",style:{width:"2rem",height:"2rem",flexShrink:0}}),(!w||_)&&e.jsx("span",{style:{fontWeight:"600",color:"var(--sa-text-primary, #292a2e)",whiteSpace:"nowrap",transition:"opacity 0.3s"},children:v.appName})]}),!D&&!w&&e.jsx("button",{type:"button",onClick:()=>m(!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(Ht,{})}),F&&e.jsx("button",{type:"button",onClick:()=>m(!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:Q?1:0,pointerEvents:Q?"auto":"none",transition:"opacity 0.2s"},children:e.jsx("span",{style:{width:"1rem",height:"1rem",display:"inline-flex"},children:e.jsx(Ht,{})})}),D&&e.jsx("button",{onClick:()=>V(!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"})})})]})})()}),i&&e.jsx(Mt,{collapsed:D?!1:w,children:i}),e.jsx("div",{ref:de,style:{flex:1,overflowY:"auto",paddingTop:"1rem",paddingBottom:"1rem"},children:Ze.map(F=>e.jsxs("div",{style:{marginBottom:"1rem"},children:[!w||D?F.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:F.name}):F.name&&e.jsx("div",{"aria-label":F.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:F.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:F.slotKey?e.jsx(Ot,{slotKey:F.slotKey,fallback:F.items.map(Q=>ve(Q))}):F.items.map(Q=>ve(Q))})]},F.id))}),v.menuBottom&&v.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:v.menuBottom.map(F=>ve(F))})]}),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:[D&&e.jsx("button",{onClick:()=>V(!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(Tt,{children:t})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"0.75rem"},children:[d,e.jsxs(O.Menu,{position:"bottom-right",children:[e.jsx(O.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:n?"Loading...":(l==null?void 0:l.name)||"unknown"}),e.jsx("p",{style:{margin:0,fontSize:"0.75rem",color:"var(--sa-text-subtle, #8c8f97)",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:n?"":(l==null?void 0:l.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:((l==null?void 0:l.name)||"U")[0].toUpperCase()}),e.jsx(E.Icon,{name:"ChevronDown",size:"sm",style:{color:"var(--sa-text-subtle, #8c8f97)"}})]})}),e.jsxs(O.MenuLists,{style:{width:"280px",paddingBlock:"12px",paddingInline:"12px",gap:"8px",marginTop:"16px"},children:[e.jsx(O.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:((l==null?void 0:l.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:(l==null?void 0:l.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:(l==null?void 0:l.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})]})}),(y&&y.length>0||p)&&e.jsxs(O.MenuBody,{children:[y==null?void 0:y.map((F,Q)=>e.jsx(O.MenuButton,{children:e.jsxs("button",{type:"button",onClick:F.onClick,style:Vt,onMouseEnter:Z=>{Z.currentTarget.style.backgroundColor="var(--sa-background-neutral, #f0f1f2)"},onMouseLeave:Z=>{Z.currentTarget.style.backgroundColor="transparent"},children:[e.jsx(E.Icon,{name:F.icon,size:"md"}),e.jsx("span",{children:F.label})]})},`${F.label}-${Q}`)),p]}),b??e.jsx(O.MenuFooter,{children:e.jsx(O.MenuButton,{children:e.jsxs("button",{type:"button",onClick:Be,style:{...Vt,color:"var(--sa-background-error, #c9184a)",fontWeight:500},onMouseEnter:F=>{F.currentTarget.style.backgroundColor="var(--sa-color-error-50, #fff0f3)"},onMouseLeave:F=>{F.currentTarget.style.backgroundColor="transparent"},children:[e.jsx(E.Icon,{name:"Logout",size:"md",style:{color:"var(--sa-background-error, #c9184a)"}}),e.jsx("span",{children:"Logout"})]})})})]})]})]})]}),e.jsx("main",{ref:te,style:{flex:1,overflowY:"auto"},children:r||e.jsx(ye.Outlet,{})})]})]}),c&&s&&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:s}),e.jsxs(Oe.Dialog,{isShow:H,onHide:Ne,children:[e.jsx(Oe.DialogTitle,{children:"Confirmation Logout"}),e.jsx(Oe.DialogBody,{children:"Are you sure you want to end the session and exit the page?"}),e.jsx(Oe.DialogFooter,{children:e.jsx(u.Box,{direction:"column",display:"flex",align:"flex-end",justify:"center",children:e.jsxs(ne.Flex,{direction:"row",gap:"sm",align:"center",children:[e.jsx(u.Box,{direction:"column",children:e.jsx(P.Button,{secondary:!0,onClick:Ne,children:"Cancel"})}),e.jsx(u.Box,{direction:"column",children:e.jsx(P.Button,{primary:!0,onClick:pe,children:"Yes, Sure"})})]})})})]}),oe&&e.jsxs(e.Fragment,{children:[e.jsx("div",{onClick:()=>ie(null),style:{position:"fixed",inset:0,zIndex:60,backgroundColor:"transparent"}}),e.jsxs("div",{role:"dialog","aria-label":oe.item.title,style:{position:"fixed",top:oe.top,left:oe.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:oe.item.title}),(Ye=oe.item.children)==null?void 0:Ye.map(F=>{const Q=be(F.to),Z=Cr(F.badge,B[F.id]);return e.jsxs("button",{onClick:()=>{L(F.to),ie(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:Q?"var(--sa-color-gray-100, #f8f8f8)":"transparent",color:Q?"var(--sa-text-primary, #292a2e)":"var(--sa-color-gray-800, #505258)",border:"1px solid transparent",cursor:"pointer",fontSize:"0.875rem",fontWeight:500},onMouseEnter:I=>{Q||(I.currentTarget.style.backgroundColor="var(--sa-color-gray-100, #f8f8f8)")},onMouseLeave:I=>{Q||(I.currentTarget.style.backgroundColor="transparent")},children:[F.icon&&e.jsx(E.Icon,{name:F.icon,size:"sm",style:{flexShrink:0}}),e.jsx("span",{style:{flex:1,whiteSpace:"nowrap"},children:F.title}),Z&&e.jsx(Ge.Badges,{text:String(Z.value),variant:Z.variant??"info",size:"xs",border:!0})]},F.id)})]})]})]})})}const ur=h.forwardRef(({children:r,...t},l)=>e.jsx(u.Box,{ref:l,role:"button",cursor:"pointer","aria-pressed":"true",display:"inline-block",tabIndex:0,...t,children:r})),jt=({title:r,iconName:t,textColor:l,iconColor:n,hoverTextColor:o,hoverIconColor:c})=>{const[s,i]=h.useState(!1),d=n??"var(--sa-text-subtle, #8c8f97)",a=l??"var(--sa-text-subtle, #8c8f97)",y=c??"var(--sa-text-subtle, #8c8f97)",p=o??"var(--sa-text-primary, #292a2e)";return e.jsxs(u.Box,{direction:"row",gap:"xs",align:"center",onMouseEnter:()=>i(!0),onMouseLeave:()=>i(!1),style:{cursor:"pointer"},children:[e.jsx(E.Icon,{name:t||"ChevronLeft",size:"xs",style:{color:s?y:d,transition:"color 0.15s ease"}}),e.jsx(S.Text,{variant:"sub-h3",style:{color:s?p:a,transition:"color 0.15s ease"},children:r||"Back"})]})},ql=({items:r,separator:t="/",iconName:l,iconColor:n,hoverIconColor:o})=>{const[c,s]=h.useState(!1),i=n??"var(--sa-text-subtle, #8c8f97)",d=o??"var(--sa-text-subtle, #8c8f97)",a=r.length>1?r[0]:void 0,y=!!(a!=null&&a.to||a!=null&&a.onClick),p=e.jsx(E.Icon,{name:l||"ChevronLeft",size:"xs",onMouseEnter:y?()=>s(!0):void 0,onMouseLeave:y?()=>s(!1):void 0,style:{color:y&&c?d:i,transition:"color 0.15s ease",cursor:y?"pointer":void 0}}),b=a!=null&&a.to?e.jsx(ye.Link,{to:a.to,replace:!0,style:{textDecoration:"none"},children:p}):a!=null&&a.onClick?e.jsx(ur,{onClick:a.onClick,children:p}):p;return e.jsxs(u.Box,{direction:"row",gap:"xs",align:"center",children:[b,e.jsx(rr.Breadcrumb,{separator:t,size:"md",children:r.map((x,T)=>{const v=T===r.length-1;return x.to&&!v?e.jsx(rr.BreadcrumbItem,{children:e.jsx(ye.Link,{to:x.to,children:x.label})},T):e.jsx(rr.BreadcrumbItem,{currentPage:v,children:e.jsx(rr.BreadcrumbLink,{onClick:v?void 0:x.onClick,children:x.label})},T)})})]})},Zl=r=>{const{items:t,separator:l,onClick:n,navigateTo:o,...c}=r;return t&&t.length>0?e.jsx(ql,{items:t,separator:l,iconName:c.iconName,iconColor:c.iconColor,hoverIconColor:c.hoverIconColor}):o?e.jsx(u.Box,{direction:"row",children:e.jsx(ye.Link,{to:o,replace:!0,style:{textDecoration:"none"},children:e.jsx(jt,{...c})})}):e.jsx(u.Box,{direction:"row",children:e.jsx(ur,{onClick:n,children:e.jsx(jt,{...c})})})},Yr=[{icon:"var(--sa-color-brand-400, #3366b7)",activeBg:"var(--sa-color-brand-50, #e6edf6)",activeBorder:"var(--sa-color-brand-300, #668cc9)",activeShadow:"rgba(51, 102, 183, 0.25)"},{icon:"var(--sa-color-warning-400, #ed9f30)",activeBg:"var(--sa-color-warning-50, #fef2e6)",activeBorder:"var(--sa-color-warning-300, #f1b259)",activeShadow:"rgba(237, 159, 48, 0.25)"},{icon:"var(--sa-color-secondary-300, #5468e1)",activeBg:"var(--sa-color-secondary-50, #e6e9fb)",activeBorder:"var(--sa-color-secondary-200, #8a98ea)",activeShadow:"rgba(84, 104, 225, 0.25)"},{icon:"var(--sa-color-info-500, #00abeb)",activeBg:"var(--sa-color-info-50, #effaff)",activeBorder:"var(--sa-color-info-300, #75dbff)",activeShadow:"rgba(0, 171, 235, 0.25)"},{icon:"var(--sa-color-success-500, #30ce84)",activeBg:"var(--sa-color-success-50, #ecfff6)",activeBorder:"var(--sa-color-success-300, #75dead)",activeShadow:"rgba(48, 206, 132, 0.25)"},{icon:"var(--sa-color-error-400, #ff758f)",activeBg:"var(--sa-color-error-50, #fff0f3)",activeBorder:"var(--sa-color-error-300, #ff8fa3)",activeShadow:"rgba(255, 117, 143, 0.25)"}];function Pt(r,t,l){return{display:"flex",alignItems:"center",justifyContent:"center",width:"64px",height:"64px",borderRadius:"var(--sa-radii-sm, 6px)",border:r?`2px solid ${l.activeBorder}`:"2px solid var(--sa-color-gray-200, #f0f1f2)",backgroundColor:r?l.activeBg:"var(--sa-color-gray-50, #ffffff)",boxShadow:r?t?`0 8px 20px ${l.activeShadow.replace("0.25","0.35")}`:`0 2px 8px ${l.activeShadow}`:t?"0 8px 20px rgba(0, 0, 0, 0.14)":"0 1px 4px rgba(0, 0, 0, 0.08)",transform:t?"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 Nt={fontSize:"11px",fontWeight:500,textAlign:"center",overflowWrap:"normal",wordBreak:"normal",color:"var(--sa-background-primary, #ffffff)",lineHeight:"1.3",maxWidth:"80px"},_t={display:"flex",flexDirection:"column",alignItems:"center",gap:"8px",background:"none",border:"none",cursor:"pointer",padding:0};function qt({isShow:r,onHide:t,menus:l,selectedGroupId:n,onSelect:o}){const[c,s]=h.useState(void 0),i=a=>{o(a),t()},d=Yr[0];return e.jsx(Oe.Dialog,{isShow:r,onHide:t,style:{width:560,background:"transparent",boxShadow:"none",border:"none"},children:e.jsx(Oe.DialogBody,{children:e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(5, 1fr)",gap:"16px"},children:[e.jsxs("button",{onClick:()=>i(null),onMouseEnter:()=>s("all"),onMouseLeave:()=>s(void 0),style:_t,children:[e.jsx("div",{style:Pt(n===null,c==="all",d),children:e.jsx("div",{style:{color:d.icon,display:"flex",alignItems:"center",justifyContent:"center"},children:e.jsx(E.Icon,{name:"Grid",size:"lg",style:{width:32,height:32}})})}),e.jsx("span",{style:Nt,children:"Semua"})]}),l.map((a,y)=>{var v;const p=n===a.id,b=c===a.id,x=((v=a.items[0])==null?void 0:v.icon)??"Grid",T=Yr[(y+1)%Yr.length];return e.jsxs("button",{onClick:()=>i(a.id),onMouseEnter:()=>s(a.id),onMouseLeave:()=>s(void 0),style:_t,children:[e.jsx("div",{style:Pt(p,b,T),children:e.jsx("div",{style:{color:T.icon,display:"flex",alignItems:"center",justifyContent:"center"},children:e.jsx(E.Icon,{name:x,size:"lg",style:{width:32,height:32}})})}),e.jsx("span",{style:Nt,children:a.name})]},a.id)})]})})})}function Gl({onSelect:r,"aria-label":t="Pilih module"}={}){const l=Zr(),n=ye.useNavigate(),{selectedGroupId:o,setSelectedGroupId:c}=Jr(),[s,i]=h.useState(!1),d=a=>{var y;if(c(a),a!==null){const p=l.menus.find(x=>x.id===a),b=(y=p==null?void 0:p.items[0])==null?void 0:y.to;b&&n(b)}r==null||r(a)};return e.jsxs(e.Fragment,{children:[e.jsxs("div",{style:{position:"relative"},children:[e.jsx("button",{onClick:()=>i(!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":t,onMouseEnter:a=>{a.currentTarget.style.backgroundColor="var(--sa-background-primary-inverse, #f8f8f8)"},onMouseLeave:a=>{a.currentTarget.style.backgroundColor="transparent"},children:e.jsx(E.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(qt,{isShow:s,onHide:()=>i(!1),menus:l.menus.filter(a=>a.parentGroupId===void 0),selectedGroupId:o,onSelect:d})]})}const Ql=(r,t)=>{const l=[];if(t===0)return l.push(r),l;for(let n=0;n<r.length;n+=t){const o=r.slice(n,n+t);l.push(o)}return l},Ul=h.memo(({value:r,label:t,separator:l,labelWidth:n,lastIndex:o,labelAlign:c="top"})=>{const s=h.useMemo(()=>({padding:0,paddingBottom:o?0:12,verticalAlign:c}),[o,c]),i=h.useMemo(()=>({padding:0,paddingRight:12,paddingLeft:12,paddingBottom:o?0:12,verticalAlign:c}),[o,c]),d=()=>typeof t=="string"?e.jsx(S.Text,{fontWeight:"medium",color:"subtlest",children:t}):t,a=()=>typeof r=="string"||typeof r=="number"?e.jsx(S.Text,{color:"primary",fontWeight:"medium",children:r}):r,y=()=>typeof l=="string"||typeof l=="number"?e.jsx(S.Text,{fontWeight:"medium",color:"subtlest",children:l}):l;return e.jsxs(U.Tr,{children:[e.jsx(U.Td,{style:s,width:n,children:d()}),l?e.jsx(U.Td,{style:i,width:24,children:y()}):null,e.jsx(U.Td,{style:s,children:a()})]})}),Jl=h.memo(({fields:r,separator:t,labelWidth:l})=>e.jsx(U.Table,{withColumnBorder:!1,withRowBorder:!1,children:r.map((n,o)=>e.jsx(Ul,{separator:t,labelWidth:l,lastIndex:o===r.length-1,...n},`field-group-field-${o}`))})),Yl=h.memo(({maxRow:r=0,maxColumn:t=2,separator:l=":",fields:n=[],labelWidth:o=150,bordered:c=!1})=>{const s=h.useMemo(()=>Ql(n,r),[n,r]),i=s.length>2,d=()=>{switch(t){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(u.Box,{gap:i?void 0:"lg",direction:"row",flexWrap:"wrap",borderRadius:"rounded-sm",padding:"lg",paddingBottom:i?"xs":"lg",bg:"accent-dark-tertiary",borderWidth:c?"border":void 0,borderStyle:c?"border-solid":void 0,borderColor:c?"border-subtle":void 0,children:s.map((a,y)=>e.jsx(u.Box,{direction:"column",flex:i?void 0:"1",width:i?d():void 0,marginBottom:i?"lg":void 0,children:e.jsx(Jl,{labelWidth:o,fields:a,separator:l})},y))})}),Xl=({backButton:r})=>{const[t,l]=h.useState(!1),n=(r==null?void 0:r.iconColor)??"var(--sa-text-subtle, #8c8f97)",o=(r==null?void 0:r.textColor)??"var(--sa-text-subtle, #8c8f97)",c=(r==null?void 0:r.hoverIconColor)??"var(--sa-text-subtle, #8c8f97)",s=(r==null?void 0:r.hoverTextColor)??"var(--sa-text-primary, #292a2e)";return e.jsxs(u.Box,{direction:"row",gap:"xs",align:"center",onMouseEnter:()=>l(!0),onMouseLeave:()=>l(!1),style:{cursor:"pointer"},children:[e.jsx(E.Icon,{name:(r==null?void 0:r.iconName)||"ChevronLeft",size:"xs",style:{color:t?c:n,transition:"color 0.15s ease"}}),e.jsx(S.Text,{variant:"sub-h3",style:{color:t?s:o,textDecoration:t?"underline":"none",transition:"color 0.15s ease"},children:(r==null?void 0:r.title)||"Back"})]})},Kl=({backButton:r,title:t,titleIcon:l,titleTag:n,children:o,header:c=!0,headerBorder:s=!1,subHeaders:i,action:d,titleTagProps:a,containerProps:y,headerProps:p})=>{const b=ue.useMediaQuery("md"),x=ye.useNavigate(),T=ye.useLocation(),v=r==null?void 0:r.show,B=()=>{if(typeof(r==null?void 0:r.onClick)=="function"){r.onClick();return}x(-1,{replace:!0})},L=()=>{if(!d)return null;if(h.isValidElement(d))return d;const w=d.filter(m=>m&&(m.title||m.icon));return w.length===0?null:b?e.jsx(u.Box,{direction:"row",gap:"md",children:w.map(({title:m,icon:_,buttonProps:V,onClick:q},J)=>e.jsx(P.Button,{iconLeft:_?e.jsx(E.Icon,{name:_,size:"md"}):void 0,onClick:q,...V,children:m},`action-${J}`))}):e.jsxs(O.Menu,{position:"bottom-right",children:[e.jsx(O.MenuButton,{children:e.jsx(P.Button,{variant:"tertiary",size:"sm",iconLeft:e.jsx(E.Icon,{name:"MenuBurger"}),"aria-label":"Actions"})}),e.jsx(O.MenuLists,{children:e.jsx(O.MenuBody,{style:{minWidth:200},children:w.map(({title:m,icon:_,buttonProps:V,onClick:q},J)=>{const le=(V==null?void 0:V.tone)==="error"||(V==null?void 0:V.danger)===!0;return e.jsx(O.MenuItem,{intent:le?"danger":void 0,disabled:V==null?void 0:V.disabled,startIcon:_?e.jsx(E.Icon,{name:_}):void 0,onClick:q,children:m},`action-${J}`)})})})]})},W=()=>{const w=e.jsx(Xl,{backButton:r});return r!=null&&r.navigateTo?e.jsx(u.Box,{direction:"row",children:e.jsx(ye.Link,{to:r.navigateTo,replace:!0,style:{textDecoration:"none"},children:w})}):e.jsx(u.Box,{direction:"row",children:e.jsx(ur,{onClick:B,children:w})})},k=()=>{const w=!!t,m=Array.isArray(d)&&d.length>0,_=h.isValidElement(d)?!0:m;if(!w&&!_&&!v)return null;const q=b||!b&&m;return e.jsxs(u.Box,{direction:"column",gap:"xs",paddingBlock:(p==null?void 0:p.paddingBlock)??"sm",paddingInline:(p==null?void 0:p.paddingInline)??"md",...p,style:{...s?{boxShadow:"inset 0 -1px 0 0 var(--sa-border-subtle, #0b120e24)"}:{},...p==null?void 0:p.style},children:[v&&W(),(w||_)&&e.jsxs(u.Box,{direction:q?"row":"column",gap:"sm",justify:"space-between",align:q?"center":"flex-start",children:[w?typeof t=="string"?e.jsxs(u.Box,{direction:"row",gap:"lg",align:"center",children:[e.jsxs(u.Box,{direction:"row",gap:"sm",align:"center",children:[l&&e.jsx(E.Icon,{name:l,size:"md",color:"primary"}),e.jsx(S.Text,{variant:"h3",fontWeight:"semibold",fontFamily:"Poppins",children:t})]}),n&&e.jsx(Ge.Badge,{border:!0,size:"lg",text:n,...a})]}):t:null,L()]})]})},D=()=>{if(!i||i.length===0)return null;const w=i.filter(V=>V.show!==!1);if(w.length===0)return null;let m=0,_=-1/0;return w.forEach((V,q)=>{const J=V.order??0;J>=_&&(_=J,m=q)}),w.map(({content:V,order:q,borderBottom:J=!0},le)=>e.jsx(u.Box,{direction:"column",paddingTop:"sm",paddingBottom:J||le===m?"sm":"spacing-0",paddingInline:"md",style:{...J?{boxShadow:"inset 0 -1px 0 0 var(--sa-border-subtle, #0b120e24)"}:{},...q!==void 0?{order:q}:{}},children:V},`sub-header-${le}`))},H=()=>{const w=c?k():null,m=D();return!w&&!m?null:e.jsxs(u.Box,{direction:"column",style:{marginBottom:m?"var(--sa-spacing-0)":"var(--sa-spacing-md)"},children:[w,m]})},A=()=>o;return e.jsxs(u.Box,{direction:"column",as:"main",...y,style:{...(y==null?void 0:y.style)??{},animation:"pageLayoutEnter 320ms cubic-bezier(0.16, 1, 0.3, 1) backwards"},children:[H(),A()]},T.pathname)},$l=h.memo(Kl),Rl={icon:"Cross",title:""},eo="calc(100vw - 16px)",Zt=r=>r==null?void 0:`min(${typeof r=="number"?`${r}px`:r}, ${eo})`,Gt=h.forwardRef(({onHide:r,show:t,withBlur:l=!1,style:n,children:o,closeButton:c=Rl,width:s,minWidth:i="357px",maxWidth:d="357px"},a)=>{const y=Zt(s??i),p=Zt(s??d);return e.jsx(vr.Drawer,{blur:l,isShow:t,position:"right",onHide:r,ref:a,style:{minWidth:y,maxWidth:p,...n},children:e.jsxs(u.Box,{direction:"column",padding:"lg",children:[c?e.jsxs(u.Box,{direction:"row",align:"center",gap:"sm",onClick:r,marginBottom:"lg",cursor:"pointer",children:[e.jsx(E.Icon,{name:c.icon,size:"md",color:"subtle",cursor:"pointer"}),c.title?e.jsx(S.Text,{fontFamily:"Poppins",fontSize:"md",color:"subtlest",children:c.title}):null]}):null,o]})})}),Xr=h.memo(({children:r,borderBottom:t=!0,padding:l=!0})=>{const n=ue.useMediaQuery("lg");return e.jsx(u.Box,{direction:"column",padding:l?"md":"spacing-0",paddingLeft:l?"md":"spacing-0",paddingRight:l?"md":"spacing-0",style:t?{borderBottom:"1px solid var(--sa-border-subtle, #0b120e24)"}:void 0,children:r})}),Kr=h.memo(({children:r,borderTop:t=!0,padding:l=!0})=>{const n=ue.useMediaQuery("lg");return e.jsx(u.Box,{direction:"column",padding:l?"md":"spacing-0",paddingLeft:l?"md":"spacing-0",paddingRight:l?"md":"spacing-0",style:t?{borderTop:"1px solid var(--sa-border-subtle, #0b120e24)"}:void 0,children:r})}),ro=h.memo(({children:r,...t})=>e.jsx(u.Box,{direction:"column",padding:"md",paddingLeft:"md",paddingRight:"md",gap:"md",...t,children:r})),to=h.memo(({children:r,title:t,titleTag:l,action:n,header:o,footer:c,actionContainer:s,containerProps:i,bodyProps:d,headerProps:a={borderBottom:!0},footerProps:y={borderTop:!0},variantTag:p="info"})=>{const b=ue.useMediaQuery("lg"),x=()=>l?e.jsxs(u.Box,{direction:"row",gap:"sm",align:"center",children:[e.jsx(S.Text,{fontWeight:"medium",children:t}),e.jsx(Ge.Badges,{border:!0,text:l,variant:p})]}):e.jsx(S.Text,{fontWeight:"medium",children:t}),T=()=>o||e.jsxs(u.Box,{direction:"row",justify:"space-between",align:"flex-start",gap:"md",children:[e.jsx(u.Box,{direction:"column",children:t?x():null}),e.jsx(u.Box,{direction:"column",style:b?{width:"100%",maxWidth:"19.313rem"}:{flex:1},...s,children:n??null})]}),v=!!(o||t||n);return e.jsxs(u.Box,{direction:"column",bg:"white",borderRadius:"rounded-xs",as:"section",borderWidth:"border",borderStyle:"border-solid",borderColor:"border-base",...i,style:{backgroundColor:"var(--sa-background-primary, #ffffff)",...(i==null?void 0:i.style)??{}},children:[o!==null&&v?e.jsx(Xr,{...a,children:T()}):null,e.jsx(ro,{...d,children:r}),c?e.jsx(Kr,{...y,children:c}):null]})}),We={H1:r=>e.jsx(S.Text,{variant:"h1",children:r.children,...r.props}),H2:r=>e.jsx(S.Text,{variant:"h2",children:r.children,...r.props}),H3:r=>e.jsx(S.Text,{variant:"h3",children:r.children,...r.props}),H4:r=>e.jsx(S.Text,{variant:"h4",children:r.children,...r.props}),H5:r=>e.jsx(S.Text,{variant:"h5",children:r.children,...r.props}),H6:r=>e.jsx(S.Text,{variant:"h6",children:r.children,...r.props}),SubH1:r=>e.jsx(S.Text,{variant:"sub-h1",children:r.children,...r.props}),SubH2:r=>e.jsx(S.Text,{variant:"sub-h2",children:r.children,...r.props}),SubH3:r=>e.jsx(S.Text,{variant:"sub-h3",children:r.children,...r.props}),Body1:r=>e.jsx(S.Text,{variant:"body-1",children:r.children,...r.props}),Body2:r=>e.jsx(S.Text,{variant:"body-2",children:r.children,...r.props}),Body3:r=>e.jsx(S.Text,{variant:"body-3",children:r.children,...r.props})},ke=()=>{const[r,t]=ye.useSearchParams(),l=lr.searchParamsToObject(r.toString()),n=ye.useParams(),o=ye.useLocation(),c=n.id;return{setSearchParams:t,searchParams:r,searchQueries:l,isHasQuery:(y,p)=>r.has(y)&&r.get(y)===p,getQueryParam:y=>r.get(y),getRouteParam:y=>n[y],params:n,location:o,id:c,hasId:!!c}},Qt=r=>JSON.stringify(r),Ut=r=>JSON.stringify(r),Jt=r=>JSON.stringify(r),Yt=r=>JSON.stringify(r),lo=r=>r,oo=r=>JSON.stringify(r),yr=({value:r,name:t,type:l,withSearchParam:n=!0,setSearchParams:o,searchQueries:c,dropdownSearchKey:s,filterKey:i="filter",pageKey:d="page"})=>{if(n){let a;switch(l){case"search":a=lo(r);break;case"dropdown":case"dropdown-multiple":a=Qt(r);break;case"radio":a=Ut(r);break;case"date-range":a=Jt(r);break;case"advanced-date-range":a=oo(r);break;case"date":a=Yt(r);break;default:a=r;break}if(typeof a<"u"){const p={...c[i]&&typeof c[i]=="string"?JSON.parse(c[i]):void 0,[t]:a},b={...c};s&&typeof s=="string"&&delete b[s],delete b[d];const x={...b,[i]:JSON.stringify(p)},T=new URLSearchParams(c).toString(),v=new URLSearchParams(x).toString();if(T===v)return;o(x)}}},Dr=({name:r,filterKey:t="filter",searchParams:l,get:n})=>{const o=l.get(t)||void 0,c=o&&typeof o=="string"?JSON.parse(o):void 0,s=c?c[r]:void 0;return n==="label"&&s?JSON.parse(s)[0].label:n==="value"&&s?JSON.parse(s)[0].value:s},Xt=({name:r,filterKey:t="filter",searchParams:l,get:n})=>{const o=l.get(t)||void 0,c=o&&typeof o=="string"?JSON.parse(o):void 0,s=c?c[r]:void 0;return n==="label"&&s?JSON.parse(s).map(i=>i.label):n==="value"&&s?JSON.parse(s).map(i=>i.value):n==="array"&&s?JSON.parse(s):s},no=({name:r,filterKey:t="filter",searchParams:l,get:n})=>{const o=l.get(t)||void 0,c=o&&typeof o=="string"?JSON.parse(o):void 0,s=c?c[r]:void 0;return n==="id"&&s?JSON.parse(s).id:n==="label"&&s?JSON.parse(s).label:n==="value"&&s?JSON.parse(s).value:s},Sr=(r,t,l)=>{const n=t.get(l||"filter")||void 0,o=n&&typeof n=="string"?JSON.parse(n):void 0;return o?o[r]:void 0},co=({name:r,filterKey:t="filter",searchParams:l})=>{const n=l.get(t||"filter")||void 0,o=n&&typeof n=="string"?JSON.parse(n):void 0,c=o?o[r]:void 0;return{start:c?JSON.parse(c).from:void 0,end:c?JSON.parse(c).to:void 0}},Kt=({name:r,filterKey:t="filter",searchParams:l})=>{const n=l.get(t||"filter")||void 0,o=n&&typeof n=="string"?JSON.parse(n):void 0,c=o?o[r]:void 0;return c?JSON.parse(c):void 0},io=(r,{filterKey:t="filter",perPageKey:l="perPage",pageKey:n="page"})=>{const o=r.get(t)||void 0,c=r.get(l)||void 0,s=r.get(n)||void 0;return!!o||!!c||!!s},$t=({isOpen:r,onClose:t,filterKey:l,pageKey:n,filters:o})=>{const{searchParams:c,setSearchParams:s,searchQueries:i}=ke(),[d,a]=h.useState({}),y=()=>{c.delete(l||"filter"),s(c)},p=(b,x)=>{switch(b.type){case"radio":{const{show:T=!0}=b;return T&&e.jsx(u.Box,{direction:"column",children:e.jsx(u.Box,{direction:"column",children:b.title})},x)}case"dropdown":{const{show:T=!0}=b;return T&&e.jsx(u.Box,{direction:"column",children:e.jsx(u.Box,{direction:"column",children:b.title})},x)}case"date-range":return e.jsx(u.Box,{direction:"column",children:e.jsx(u.Box,{direction:"column",children:b.title})},x);case"date":return e.jsx(u.Box,{direction:"column",children:e.jsx(u.Box,{direction:"column",children:b.title})},x);case"dropdown-multiple":{const{show:T=!0}=b;return T&&e.jsx(u.Box,{direction:"column",children:e.jsx(u.Box,{direction:"column",children:b.title})},x)}default:return null}};return e.jsx(Gt,{onHide:t,show:r||!1,children:e.jsxs(u.Box,{direction:"column",gap:"md",children:[e.jsxs(ne.Flex,{direction:"row",justify:"space-between",align:"center",children:[e.jsx(u.Box,{direction:"column",children:"Filter"}),e.jsx(u.Box,{direction:"column",style:{cursor:"pointer"},onClick:y,children:"Reset"})]}),o==null?void 0:o.map((b,x)=>p(b,x))]})})},Rt=({searchKey:r="q",statusKey:t="status",searchPlaceholder:l="Search",searchHighlightPlaceholder:n,extendedFilter:o,showSearchFilter:c=!0,showStatusFilter:s=!0,filterKey:i="filter",pageKey:d="page",customWidthSearch:a,handleOnReset:y,filterConfigs:p,buttonToggleProps:b,position:x="right",titleSearchLabel:T="Work Order",withTitleLabels:v=!1})=>{const L=(b==null?void 0:b.isShowLabel)??!0,[W,k]=h.useState(!1),[D,H]=h.useState(0),A=()=>{H(Y=>Y+1)},{searchParams:w,setSearchParams:m,getQueryParam:_}=ke(),V=lr.searchParamsToObject(w.toString()),q=Sr(r,w,i)||"",[J,le]=h.useState(q),ge=_(i),ie=!!(ge&&!(()=>{if(ge)try{const Y=JSON.parse(ge);return Object.keys(Y).length===1&&Y[r]===""}catch(Y){console.error("Filter parameter is not a valid JSON:",Y)}return!1})()),K=ue.useMediaQuery("md");return h.useEffect(()=>{le(q)},[q]),h.useEffect(()=>{if(J===q)return;const Y=window.setTimeout(()=>{yr({value:J,name:r,type:"search",searchQueries:V,setSearchParams:m,filterKey:i,pageKey:d})},350);return()=>{window.clearTimeout(Y)}},[J,q,r,V,m,i,d]),e.jsxs(ne.Flex,{gap:"md",style:{flexDirection:K&&x==="left"?"row":K&&x==="right"?"row-reverse":"column"},align:"flex-end",children:[ie&&e.jsx(u.Box,{direction:"column",justify:"flex-end",children:e.jsx(P.Button,{onClick:()=>{const Y=new URLSearchParams(w);Y.delete(i),m(Y),le(""),A(),y&&y()},variant:"outline",tone:"neutral",children:e.jsx(S.Text,{color:"error",fontWeight:"semibold",children:"Reset"})})}),o==null?void 0:o.map(({minWidth:Y,content:de,title:te,onClickContainer:ae},Be)=>e.jsxs(u.Box,{direction:"column",gap:"sm",onClick:ae,style:{minWidth:Y},children:[te&&e.jsx(We.SubH3,{children:te}),de]},`extended-filter-${Be}-${D}`)),!!(p!=null&&p.length)&&e.jsx(P.Button,{primary:ie,secondary:!ie,iconLeft:e.jsx(E.Icon,{size:"sm",name:(b==null?void 0:b.icon)||"FilterHorizontal",style:{color:ge?"var(--sa-background-brand, #04254f)":"var(--sa-text-primary, #292a2e)"}}),fullWidth:!K,onClick:()=>k(!0),children:L?"Filter":void 0}),s&&e.jsxs(u.Box,{direction:"column",gap:"sm",style:{minWidth:"126px"},children:[v&&e.jsx(We.SubH3,{children:"Status"}),e.jsx(tr.Dropdown,{dropdownLists:[{label:"Active",value:"active"},{label:"InActive",value:"inactive"}],defaultValue:Dr({get:"value",name:t,searchParams:w,filterKey:i})?[{label:Dr({get:"value",name:t,searchParams:w,filterKey:i})==="active"?"Active":"InActive",value:Dr({get:"value",name:t,searchParams:w,filterKey:i})}]:[],onChange:Y=>yr({value:Y,name:t,type:"dropdown",searchQueries:V,setSearchParams:m,filterKey:i}),placeholder:v?"All":"All Status"},D)]}),c&&e.jsxs(u.Box,{direction:"column",gap:"sm",style:{width:a&&K?a:K?"310px":""},children:[v&&e.jsxs(We.SubH3,{children:["Search for ",T]}),e.jsx(Qe.Input,{placeholder:l,leftIcon:e.jsx(E.Icon,{name:"Search",width:20,height:20}),onChange:Y=>le(Y.target.value),value:J,fullWidth:!0},D+1+i)]}),e.jsx($t,{isOpen:W,onClose:()=>k(!1),filterKey:i,filters:p,pageKey:d})]})},so=r=>r==="checkbox-multiple"?"dropdown-multiple":r==="radio"?"dropdown":r==="date-compact"?"date":r;function $r({configs:r,filterKey:t="filter",activeFilterKey:l="filters",pageKey:n="page",searchKey:o="q"}){const{searchParams:c,setSearchParams:s,searchQueries:i}=ke(),d=h.useMemo(()=>Object.fromEntries(r.map(D=>[D.key,D])),[r]),a=h.useMemo(()=>{const D=(c.get(l)||"").split(",").map(A=>A.trim()).filter(Boolean);let H=[];try{const A=c.get(t);A&&(H=Object.keys(JSON.parse(A)).filter(w=>w!==o))}catch{}return r.map(A=>A.key).filter(A=>{const w=d[A];return(w==null?void 0:w.locked)||D.includes(A)||H.includes(A)})},[c,l,t,o,r,d]),y=h.useCallback(D=>{try{return D[t]?JSON.parse(D[t]):{}}catch{return{}}},[t]),p=h.useCallback(D=>{const H={...i};D.length?H[l]=D.join(","):delete H[l],s(H)},[i,l,s]),b=h.useCallback(D=>{a.includes(D)||p([...a,D])},[a,p]),x=h.useCallback(D=>{var m;if((m=d[D])!=null&&m.locked)return;const H={...i},A=a.filter(_=>_!==D);A.length?H[l]=A.join(","):delete H[l];const w=y(H);D in w&&(delete w[D],Object.keys(w).length?H[t]=JSON.stringify(w):delete H[t]),delete H[n],s(H)},[i,a,l,t,n,y,s,d]),T=h.useCallback(D=>a.includes(D)?x(D):b(D),[a,b,x]),v=h.useCallback(D=>{switch(D.type){case"dropdown":case"dropdown-multiple":case"checkbox-multiple":case"radio":return Xt({name:D.key,get:"array",searchParams:c,filterKey:t})||[];case"date":{const H=Kt({name:D.key,searchParams:c,filterKey:t});return H?new Date(H):void 0}case"date-compact":{const A=y(Object.fromEntries(c.entries()))[D.key];return A&&typeof A=="object"?A:void 0}default:return}},[c,t,y]),B=h.useCallback((D,H)=>{if(D.type==="date-compact"){const A={...i},w=y(A);H==null?delete w[D.key]:w[D.key]=H,Object.keys(w).length?A[t]=JSON.stringify(w):delete A[t],delete A[n],s(A);return}yr({value:H,name:D.key,type:so(D.type),searchQueries:i,setSearchParams:s,filterKey:t,pageKey:n})},[i,s,t,n,y]),L=h.useCallback(D=>{const H={...i},A=y(H);D in A&&(delete A[D],Object.keys(A).length?H[t]=JSON.stringify(A):delete H[t]),delete H[n],s(H)},[i,t,n,y,s]),W=h.useCallback(()=>{const D={...i};delete D[t],delete D[l],delete D[n],s(D)},[i,t,l,n,s]),k=a.length>0;return{activeKeys:a,configByKey:d,hasActiveFilter:k,addFilter:b,removeFilter:x,toggleFilter:T,getValue:v,setValue:B,clearValue:L,clearAll:W}}const Rr={get(r){return gr.storage.get(r)??null},set(r,t){gr.storage.save(r,t)},remove(r){gr.storage.delete(r)}},ir={columns:r=>`filterbar:colprefs:${r}`,savedViews:r=>`filterbar:views:${r}`,lastState:r=>`filterbar:last:${r}`,perPage:r=>`filterbar:perpage:${r}`,tableSort:r=>`tablelayout:sort:${r}`},kr=(r,t)=>{const l=new Set(t.map(c=>c.key)),n=r.order.filter(c=>l.has(c));for(const c of t)n.includes(c.key)||n.push(c.key);const o=r.hidden.filter(c=>l.has(c));return{order:n,hidden:o}};function ao({columns:r,scopeId:t,storage:l,onColumnsChange:n,value:o}){const c=h.useMemo(()=>({order:r.map(w=>w.key),hidden:[]}),[r]),s=t?ir.columns(t):void 0,i=(w,m)=>kr({order:w.order??m,hidden:w.hidden??[]},r),[d,a]=h.useState(()=>{if(o&&(o.order||o.hidden))return i(o,r.map(w=>w.key));if(s){const w=l.get(s);if(w&&Array.isArray(w.order))return kr(w,r)}return c}),y=r.map(w=>w.key).join("|");h.useEffect(()=>a(w=>kr(w,r)),[y]);const p=h.useRef(d);p.current=d;const b=o?`${(o.order??[]).join("|")}~${(o.hidden??[]).join("|")}`:null,x=h.useRef(b);h.useEffect(()=>{if(b==null||x.current===b)return;x.current=b;const w=p.current,m=i(o,w.order);m.order.join("|")===w.order.join("|")&&m.hidden.join("|")===w.hidden.join("|")||(a(m),s&&l.set(s,m))},[b,y]);const T=h.useRef(!1);h.useEffect(()=>{T.current||(T.current=!0,n==null||n(d))},[]);const v=h.useCallback(w=>{a(w),s&&l.set(s,w),n==null||n(w)},[s,l,n]),B=h.useMemo(()=>{const w=new Map(r.map(m=>[m.key,m]));return d.order.filter(m=>w.has(m)).map(m=>({...w.get(m),visible:!d.hidden.includes(m)}))},[d,r]),L=h.useCallback(w=>{const m=d.hidden.includes(w)?d.hidden.filter(_=>_!==w):[...d.hidden,w];v({...d,hidden:m})},[d,v]),W=h.useCallback((w,m)=>{if(w===m)return;const _=[...d.order],[V]=_.splice(w,1);_.splice(m,0,V),v({...d,order:_})},[d,v]),k=h.useCallback(w=>{v({...d,hidden:w?r.filter(m=>!m.locked).map(m=>m.key):[]})},[d,r,v]),D=h.useCallback(()=>v(c),[v,c]),H=h.useCallback(w=>v(kr(w,r)),[v,r]),A=d.hidden.length===0;return{state:d,orderedColumns:B,allVisible:A,toggleVisibility:L,reorder:W,setAllHidden:k,reset:D,applyState:H}}function ho({scopeId:r,storage:t,snapshotKeys:l,pageKey:n="page",getColumns:o,applyColumns:c}){const{searchParams:s,setSearchParams:i}=ke(),d=r?ir.savedViews(r):void 0,[a,y]=h.useState(()=>d?t.get(d)||[]:[]),p=h.useCallback(v=>{y(v),d&&t.set(d,v)},[d]),b=h.useCallback(v=>{const B=v.trim();if(!B)return;const L={};l.forEach(k=>{const D=s.get(k);D!=null&&(L[k]=D)});const W={id:`${Date.now()}`,name:B,query:L,columns:o==null?void 0:o(),createdAt:Date.now()};p([...a,W])},[l,s,o,p,a]),x=h.useCallback(v=>p(a.filter(B=>B.id!==v)),[p,a]),T=h.useCallback(v=>{const B=Object.fromEntries(s.entries());l.forEach(L=>delete B[L]),Object.assign(B,v.query),delete B[n],i(B),v.columns&&(c==null||c(v.columns))},[s,l,n,i,c]);return{enabled:!!d,views:a,saveView:b,deleteView:x,applyView:T}}function fo({scopeId:r,storage:t,snapshotKeys:l,enabled:n=!0}){const{searchParams:o}=ke(),c=r&&n?ir.lastState(r):void 0,s=h.useRef(c);h.useEffect(()=>{if(!c){s.current=c;return}if(s.current!==c){s.current=c;return}const a={};l.forEach(y=>{const p=o.get(y);p!=null&&(a[y]=p)}),Object.keys(a).length!==0&&t.set(c,a)},[o,c,l,t]);const i=h.useCallback(()=>{if(!c)return null;const a=t.get(c);return a&&Object.keys(a).length>0?a:null},[c,t]),d=h.useCallback(()=>{c&&t.remove(c)},[c,t]);return{enabled:!!c,read:i,clear:d}}function go({scopeId:r,storage:t,perPageKey:l,pageSizeOptions:n,enabled:o=!0}){const{searchParams:c}=ke(),s=r&&o?ir.perPage(r):void 0,i=c.toString(),d=h.useRef(s);h.useEffect(()=>{if(!s){d.current=s;return}if(d.current!==s){d.current=s;return}const p=c.get(l);if(!p)return;const b=Number(p);!Number.isFinite(b)||b<=0||t.set(s,b)},[i,s,l,t]);const a=h.useCallback(()=>{if(!s)return null;const p=t.get(s);if(p==null)return null;const b=Number(p);return!Number.isFinite(b)||b<=0||n&&!n.includes(b)?null:String(b)},[s,t,n]),y=h.useCallback(()=>{s&&t.remove(s)},[s,t]);return{enabled:!!s,read:a,clear:y}}let et={},rt=!1,tt=null;const uo=(r,t)=>{Object.assign(et,r),tt=t,!rt&&(rt=!0,queueMicrotask(()=>{const l=et,n=tt;et={},rt=!1,tt=null,!(!n||Object.keys(l).length===0)&&n(o=>{const c=new URLSearchParams(o);return Object.entries(l).forEach(([s,i])=>c.set(s,i)),c})}))};function yo({enabled:r,snapshotKeys:t,perPageKey:l,readSnapshot:n,readPerPage:o}){const{searchParams:c,setSearchParams:s,location:i}=ke(),d=h.useRef(null);h.useEffect(()=>{if(!r||d.current===i.pathname)return;d.current=i.pathname;const a={};if(!c.has(l)){const y=o();y&&(a[l]=y)}if(!t.some(y=>c.has(y))){const y=n();y&&Object.assign(a,y)}Object.keys(a).length!==0&&uo(a,s)},[i.pathname,r])}const po=({configs:r,activeKeys:t,onToggle:l,hasActiveFilter:n,onReset:o})=>r.length?e.jsxs(O.Menu,{position:"bottom-left",children:[e.jsx(O.MenuButton,{children:e.jsx(P.Button,{variant:n?"secondary":"outline",tone:"neutral",size:"sm",iconLeft:e.jsx(E.Icon,{name:"FilterHorizontal"}),"aria-label":"Add filter"})}),e.jsx(O.MenuLists,{children:e.jsx(O.MenuBody,{style:{minWidth:260},title:e.jsxs(u.Box,{display:"flex",direction:"row",align:"center",justify:"space-between",fullWidth:!0,children:[e.jsx(S.Text,{fontSize:"sm",fontWeight:"medium",color:"subtlest",children:"Add Filter"}),n&&o&&e.jsx(P.Button,{variant:"link",tone:"brand",size:"xs",onClick:o,children:"Reset"})]}),children:r.map(c=>e.jsx(O.MenuItem,{selected:c.locked||t.includes(c.key),disabled:c.locked,closeOnSelect:!1,startIcon:c.icon??void 0,onClick:()=>{c.locked||l(c.key)},children:c.label},c.key))})})]}):null,Br=({onClear:r,onRemove:t})=>e.jsxs(O.Menu,{position:"bottom-right",children:[e.jsx(O.MenuButton,{children:e.jsx(P.Button,{variant:"link",tone:"neutral",size:"xs",iconLeft:e.jsx(E.Icon,{name:"MenuHorizontal"}),"aria-label":"Filter actions"})}),e.jsx(O.MenuLists,{children:e.jsxs(O.MenuBody,{style:{width:180},children:[e.jsx(O.MenuItem,{startIcon:e.jsx(E.Icon,{name:"CrossCircle"}),onClick:r,children:"Clear value"}),t&&e.jsx(O.MenuItem,{intent:"danger",startIcon:e.jsx(E.Icon,{name:"Trash1"}),onClick:t,children:"Remove filter"})]})})]}),bo=r=>{const t=new Date(r);return t.setHours(0,0,0,0),t},el=(r,t,l)=>{const n=new Date(r);return l==="day"?n.setDate(n.getDate()+t):l==="week"?n.setDate(n.getDate()+t*7):l==="month"?n.setMonth(n.getMonth()+t):n.setFullYear(n.getFullYear()+t),n},rl=r=>{const t=bo(new Date);if(r.direction==="this"){const n=new Date(t),o=new Date(t);return r.period==="week"?(n.setDate(t.getDate()-t.getDay()),o.setDate(n.getDate()+6)):r.period==="month"?(n.setDate(1),o.setMonth(o.getMonth()+1,0)):r.period==="year"&&(n.setMonth(0,1),o.setMonth(11,31)),{from:n,to:o}}const l=r.count??1;return r.direction==="past"?{from:el(t,-l,r.period),to:t}:{from:t,to:el(t,l,r.period)}},tl=24,ll=r=>r.length>tl?`${r.slice(0,tl)}...`:r,mr=r=>r.toLocaleDateString(void 0,{day:"2-digit",month:"short",year:"numeric"}),Fr={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"},vo=["is","is-before","is-after","is-on-or-before","is-on-or-after","is-between","is-relative-to-today","is-empty","is-not-empty"],lt={past:"Past",next:"Next",this:"This"},Co=["day","week","month","year"],xo=["past","next","this"],wo=r=>r.field.type==="date-compact"?e.jsx(ko,{field:r.field,value:r.value,onChange:r.onChange,onClear:r.onClear,onRemove:r.onRemove}):e.jsx(Do,{field:r.field,value:r.value,onChange:r.onChange,onClear:r.onClear,onRemove:r.onRemove}),Do=({field:r,value:t,onChange:l,onClear:n,onRemove:o})=>{const c=t?mr(new Date(t)):null,s=!!c,i=s?e.jsxs(e.Fragment,{children:[e.jsxs("span",{style:{fontWeight:500},children:[r.label,":"]})," ",e.jsx("span",{style:{fontWeight:400},children:ll(c)})]}):r.label;return e.jsxs(O.Menu,{position:"bottom-left",children:[e.jsx(O.MenuButton,{children:e.jsx(P.Button,{variant:s?"secondary":"outline",tone:"neutral",size:"sm",iconLeft:s?e.jsx(E.Icon,{name:"Calendar",size:"sm"}):void 0,iconRight:e.jsx(E.Icon,{name:"ChevronSmallDown"}),children:i})}),e.jsx(O.MenuLists,{children:e.jsx(O.MenuBody,{style:{width:260},title:e.jsxs(u.Box,{display:"flex",direction:"row",align:"center",justify:"space-between",fullWidth:!0,children:[e.jsx(S.Text,{fontSize:"sm",fontWeight:"medium",color:"subtlest",children:r.label}),e.jsx(Br,{onClear:n,onRemove:o})]}),children:e.jsx(Ue.StarasiaDate,{size:"sm",input:!1,clearable:!0,filter:r.mode,value:t,onChange:d=>d==null?n():l(d),withPadding:!1})})})]})},So=r=>{switch(r.op){case"is":case"is-before":case"is-after":case"is-on-or-before":case"is-on-or-after":return r.date?`${Fr[r.op]} ${mr(new Date(r.date))}`:null;case"is-between":return r.from&&r.to?`${mr(new Date(r.from))} - ${mr(new Date(r.to))}`:null;case"is-relative-to-today":{const t=r.relative;if(!t)return null;if(t.direction==="this")return`This ${t.period}`;const l=t.count??1,n=l===1?t.period:`${t.period}s`;return`${lt[t.direction]} ${l} ${n}`}case"is-empty":case"is-not-empty":return Fr[r.op];default:return null}},ko=({field:r,value:t,onChange:l,onClear:n,onRemove:o})=>{const c=(t==null?void 0:t.op)??"is",s=t?So(t):null,i=!!s,d=i?e.jsxs(e.Fragment,{children:[e.jsxs("span",{style:{fontWeight:500},children:[r.label,":"]})," ",e.jsx("span",{style:{fontWeight:400},children:ll(s)})]}):r.label,a=y=>{if(y!==c){if(y==="is-empty"||y==="is-not-empty"){l({op:y});return}if(y==="is-relative-to-today"){l({op:y,relative:(t==null?void 0:t.relative)??{direction:"past",count:1,period:"week"}});return}if(y==="is-between"){l({op:y,from:t==null?void 0:t.from,to:t==null?void 0:t.to});return}l({op:y,date:t==null?void 0:t.date})}};return e.jsxs(O.Menu,{position:"bottom-left",children:[e.jsx(O.MenuButton,{children:e.jsx(P.Button,{variant:i?"secondary":"outline",tone:"neutral",size:"sm",iconLeft:i?e.jsx(E.Icon,{name:"Calendar",size:"sm"}):void 0,iconRight:e.jsx(E.Icon,{name:"ChevronSmallDown"}),children:d})}),e.jsxs(O.MenuLists,{children:[e.jsx(O.MenuBody,{style:{width:320},title:e.jsxs(u.Box,{display:"flex",direction:"row",align:"center",justify:"space-between",gap:"xs",fullWidth:!0,children:[e.jsxs(u.Box,{display:"flex",direction:"row",align:"center",gap:"xs",style:{minWidth:0},children:[e.jsx(S.Text,{fontSize:"sm",fontWeight:"medium",color:"subtlest",children:r.label}),e.jsx(Bo,{op:c,onChange:a})]}),e.jsx(Br,{onClear:n,onRemove:o})]}),children:e.jsx(mo,{value:t,op:c,onChange:l})}),c==="is-relative-to-today"&&e.jsx(O.MenuFooter,{children:e.jsx(S.Text,{fontSize:"xs",color:"subtlest",children:"Filter will update with the current date"})})]})]})},Bo=({op:r,onChange:t})=>e.jsxs(O.Menu,{position:"bottom-left",children:[e.jsx(O.MenuButton,{children:e.jsx(P.Button,{variant:"link",tone:"neutral",size:"xs",iconRight:e.jsx(E.Icon,{name:"ChevronSmallDown"}),children:Fr[r]})}),e.jsx(O.MenuLists,{children:e.jsx(O.MenuBody,{style:{width:200},children:vo.map(l=>e.jsx(O.MenuItem,{selected:r===l,onClick:()=>t(l),endIcon:r===l?e.jsx(E.Icon,{name:"Check"}):void 0,children:Fr[l]},l))})})]}),mo=({value:r,op:t,onChange:l})=>{if(t==="is-empty"||t==="is-not-empty")return e.jsx(u.Box,{paddingBlock:"sm",paddingInline:"sm",children:e.jsx(S.Text,{fontSize:"xs",color:"subtlest",children:"No further input required."})});if(t==="is-between"){const n=r!=null&&r.from||r!=null&&r.to?{from:r!=null&&r.from?new Date(r.from):null,to:r!=null&&r.to?new Date(r.to):null}:void 0;return e.jsx(Ue.StarasiaDate,{size:"sm",input:!1,clearable:!0,rangedDate:!0,value:n,onChange:o=>{if(o==null){l({op:t});return}if(typeof o=="object"&&o!==null&&"from"in o&&"to"in o){let{from:c,to:s}=o;if(!c&&s&&(c=s,s=null),!c&&!s){l({op:t});return}l({op:t,from:c?c.toISOString():void 0,to:s?s.toISOString():void 0})}},withPadding:!1},"range")}return t==="is-relative-to-today"?e.jsx(Fo,{value:r==null?void 0:r.relative,onChange:n=>l({op:t,relative:n})}):e.jsx(Ue.StarasiaDate,{size:"sm",input:!1,clearable:!0,value:r!=null&&r.date?new Date(r.date):void 0,onChange:n=>{if(n==null){l({op:t});return}n instanceof Date&&l({op:t,date:n.toISOString()})},withPadding:!1},"single")},Fo=({value:r,onChange:t})=>{const l=(r==null?void 0:r.direction)??"past",n=(r==null?void 0:r.count)??1,o=(r==null?void 0:r.period)??"week",c=l!=="this",s=rl({direction:l,count:n,period:o});return e.jsxs(u.Box,{direction:"column",display:"flex",gap:"sm",children:[e.jsxs(u.Box,{direction:"row",display:"flex",align:"center",gap:"xs",children:[e.jsxs(O.Menu,{position:"bottom-left",children:[e.jsx(O.MenuButton,{children:e.jsx(P.Button,{variant:"outline",tone:"neutral",size:"sm",iconRight:e.jsx(E.Icon,{name:"ChevronSmallDown"}),children:lt[l]})}),e.jsx(O.MenuLists,{children:e.jsx(O.MenuBody,{style:{width:140},children:xo.map(i=>e.jsx(O.MenuItem,{selected:l===i,endIcon:l===i?e.jsx(E.Icon,{name:"Check"}):void 0,onClick:()=>t(i==="this"?{direction:i,period:o}:{direction:i,count:n,period:o}),children:lt[i]},i))})})]}),c&&e.jsx(Qe.Input,{type:"number",size:"sm",min:1,clearable:!1,value:n,onChange:i=>{const d=Number(i.target.value);t({direction:l,count:Number.isFinite(d)&&d>0?d:1,period:o})},style:{width:72}}),e.jsxs(O.Menu,{position:"bottom-left",children:[e.jsx(O.MenuButton,{children:e.jsx(P.Button,{variant:"outline",tone:"neutral",size:"sm",iconRight:e.jsx(E.Icon,{name:"ChevronSmallDown"}),children:o})}),e.jsx(O.MenuLists,{children:e.jsx(O.MenuBody,{style:{width:140},children:Co.map(i=>e.jsx(O.MenuItem,{selected:o===i,endIcon:o===i?e.jsx(E.Icon,{name:"Check"}):void 0,onClick:()=>t(l==="this"?{direction:l,period:i}:{direction:l,count:n,period:i}),children:i},i))})})]})]}),e.jsx(Ue.StarasiaDate,{size:"sm",input:!1,disabled:!0,rangedDate:!0,value:s,onChange:()=>{},withPadding:!1},"relative-preview")]})},ol=18,Eo=r=>r.length>ol?`${r.slice(0,ol)}...`:r,Mo=({field:r,value:t,onChange:l,onClear:n,onRemove:o})=>{const c=r.type==="dropdown-multiple",s=t.length,[i,d]=h.useState(""),a=r.options,y=typeof r.onSearch=="function",p=(()=>{if(y)return a;const B=i.trim().toLowerCase();return B?a.filter(L=>L.label.toLowerCase().includes(B)):a})(),b=B=>t.some(L=>L.value===B.value),x=B=>{if(!c){l([{label:B.label,value:B.value}]),d("");return}l(b(B)?t.filter(L=>L.value!==B.value):[...t,{label:B.label,value:B.value}])},T=B=>{var L;d(B),(L=r.onSearch)==null||L.call(r,B)},v=s===0?r.label:e.jsxs(e.Fragment,{children:[e.jsxs("span",{style:{fontWeight:500},children:[r.label,":"]})," ",e.jsx("span",{style:{fontWeight:400},children:s===1?Eo(t[0].label):`${s} Selected`})]});return e.jsxs(O.Menu,{position:"bottom-left",children:[e.jsx(O.MenuButton,{children:e.jsx(P.Button,{variant:s>0?"secondary":"outline",tone:"neutral",size:"sm",iconLeft:s>0?e.jsx(E.Icon,{name:"Tag",size:"sm"}):void 0,iconRight:e.jsx(E.Icon,{name:"ChevronSmallDown"}),children:v})}),e.jsx(O.MenuLists,{children:e.jsx(O.MenuBody,{style:{width:260},title:e.jsxs(u.Box,{display:"flex",direction:"row",align:"center",justify:"space-between",fullWidth:!0,children:[e.jsx(S.Text,{fontSize:"sm",fontWeight:"medium",color:"subtlest",children:r.label}),e.jsx(Br,{onClear:n,onRemove:o})]}),children:e.jsxs(u.Box,{direction:"column",gap:"sm",children:[e.jsx(tr.Dropdown,{size:"sm",triggerInput:!0,fullWidth:!0,hideChevronIcon:!0,clearable:!0,multiSelect:c,searchAble:!0,searchValue:i,onSearch:T,value:t,onChange:l,placeholder:`Search ${r.label.toLowerCase()}…`}),e.jsx(u.Box,{direction:"column",overflow:"overflow-y-auto",customMaxHeight:"240px",children:r.isLoading?e.jsx(u.Box,{paddingBlock:"sm",paddingInline:"sm",children:e.jsx(S.Text,{fontSize:"xs",color:"subtlest",children:"Loading…"})}):p.length===0?e.jsx(u.Box,{paddingBlock:"sm",paddingInline:"sm",children:e.jsx(S.Text,{fontSize:"xs",color:"subtlest",children:"No results"})}):p.map(B=>e.jsx(O.MenuItem,{closeOnSelect:!c,selected:b(B),startIcon:B.avatar,endIcon:b(B)?e.jsx(E.Icon,{name:"Check"}):void 0,description:B.description,onClick:()=>x(B),children:B.label},B.value))})]})})})]})},nl=18,Lo=r=>r.length>nl?`${r.slice(0,nl)}...`:r,cl=({checked:r,indeterminate:t})=>e.jsx("span",{style:{pointerEvents:"none",display:"inline-flex"},children:e.jsx(cr.Checkbox,{size:"sm",checked:r,readOnly:!0,onChange:()=>{},variant:t?"indeterminate":"select"})}),To=({field:r,value:t,onChange:l,onClear:n,onRemove:o})=>{const c=new Set(t.map(b=>b.value)),s=t.length,i=r.options.length>0&&r.options.every(b=>c.has(b.value)),d=s>0&&!i,a=b=>{l(c.has(b.value)?t.filter(x=>x.value!==b.value):[...t,{label:b.label,value:b.value}])},y=()=>{l(i?[]:r.options.map(b=>({label:b.label,value:b.value})))},p=s===0?r.label:e.jsxs(e.Fragment,{children:[e.jsxs(S.Text,{as:"span",fontWeight:"semibold",children:[r.label,":"]})," ",e.jsx(S.Text,{as:"span",children:s===1?Lo(t[0].label):`${s} Selected`})]});return e.jsxs(O.Menu,{position:"bottom-left",children:[e.jsx(O.MenuButton,{children:e.jsx(P.Button,{variant:s>0?"secondary":"outline",tone:"neutral",size:"sm",iconLeft:s>0?e.jsx(E.Icon,{name:"Tag",size:"sm"}):void 0,iconRight:e.jsx(E.Icon,{name:"ChevronSmallDown"}),children:p})}),e.jsx(O.MenuLists,{children:e.jsxs(O.MenuBody,{style:{width:240},title:e.jsxs(u.Box,{display:"flex",direction:"row",align:"center",justify:"space-between",fullWidth:!0,children:[e.jsx(S.Text,{fontSize:"sm",fontWeight:"medium",color:"subtlest",children:r.label}),e.jsx(Br,{onClear:n,onRemove:o})]}),children:[e.jsx(O.MenuItem,{closeOnSelect:!1,selected:i,onClick:y,startIcon:e.jsx(cl,{checked:i||d,indeterminate:d}),children:"Select All"}),r.options.map(b=>e.jsx(O.MenuItem,{closeOnSelect:!1,selected:c.has(b.value),onClick:()=>a(b),startIcon:e.jsx(cl,{checked:c.has(b.value)}),children:b.label},b.value))]})})]})},il=({activeKeys:r,configByKey:t,getValue:l,setValue:n,clearValue:o,removeFilter:c})=>e.jsx(e.Fragment,{children:r.map(s=>{const i=t[s];if(!i)return null;const d=l(i),a=i.locked?void 0:()=>c(s);return i.type==="date"||i.type==="date-compact"?e.jsx(wo,{field:i,value:d,onChange:y=>n(i,y),onClear:()=>o(s),onRemove:a},s):i.type==="checkbox-multiple"?e.jsx(To,{field:i,value:d||[],onChange:y=>n(i,y),onClear:()=>o(s),onRemove:a},s):e.jsx(Mo,{field:i,value:d||[],onChange:y=>n(i,y),onClear:()=>o(s),onRemove:a},s)})}),sl=r=>`${r} Rows`,Io=({pagination:r,pageKey:t="page",perPageKey:l="perPage",pageSizeOptions:n=[10,25,50,100],defaultPerPage:o=10,showResultCount:c=!0,showPageSize:s=!0,showPagination:i=!0})=>{var L;const{searchQueries:d,setSearchParams:a,searchParams:y}=ke(),p=y.get(l),b=p?Number(p):o,x=W=>{a({...d,[t]:String(W)})},T=W=>{a({...d,[l]:W,[t]:"1"})},v=(r==null?void 0:r.rangeStart)??(((r==null?void 0:r.currentPage)||0)>1?(((r==null?void 0:r.currentPage)||0)-1)*((r==null?void 0:r.perPage)||0)+1:0),B=(r==null?void 0:r.rangeEnd)??((r==null?void 0:r.totalCurrentPage)!==(r==null?void 0:r.perPage)?r==null?void 0:r.totalData:((r==null?void 0:r.currentPage)||1)*((r==null?void 0:r.totalCurrentPage)||0));return e.jsxs(e.Fragment,{children:[c&&e.jsx(S.Text,{fontSize:"sm",fontWeight:"medium",color:"primary",truncate:!0,children:`${v}-${B} of ${((L=r==null?void 0:r.totalData)==null?void 0:L.toLocaleString())||0}`}),s&&e.jsxs(O.Menu,{position:"bottom-left",children:[e.jsx(O.MenuButton,{children:e.jsx(P.Button,{variant:"outline",tone:"neutral",size:"sm",iconRight:e.jsx(E.Icon,{name:"ChevronSmallDown"}),"aria-label":"Rows per page",children:sl(b)})}),e.jsx(O.MenuLists,{children:e.jsx(O.MenuBody,{children:n.map(W=>e.jsx(O.MenuItem,{selected:W===b,onClick:()=>T(String(W)),children:sl(W)},W))})})]}),i&&((r==null?void 0:r.totalPage)??0)>1&&e.jsx(u.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(fr.Pagination,{size:"sm",variant:"neutral",siblingCount:0,currentPage:r!=null&&r.currentPage?Number(r.currentPage):1,totalPages:Number(r==null?void 0:r.totalPage),onPageChange:x})})]})};function Oo(r,t,l=!0){h.useEffect(()=>{if(!l)return;const n=o=>{var i;if(o.metaKey||o.ctrlKey||o.altKey||o.key!==r)return;const c=o.target,s=(i=c==null?void 0:c.tagName)==null?void 0:i.toLowerCase();s==="input"||s==="textarea"||c!=null&&c.isContentEditable||(o.preventDefault(),t())};return window.addEventListener("keydown",n),()=>window.removeEventListener("keydown",n)},[r,t,l])}const Wo=240,al=({searchKey:r="q",filterKey:t="filter",pageKey:l="page",placeholder:n="Search",shortcut:o="/",collapsible:c=!0})=>{const{searchParams:s,setSearchParams:i,searchQueries:d}=ke(),a=Sr(r,s,t)||"",[y,p]=h.useState(!c||!!a),[b,x]=h.useState(c&&!a),[T,v]=h.useState(a),B=ue.useDebounce(T,350),L=h.useRef(null);h.useEffect(()=>{v(a),a&&p(!0)},[a]),h.useEffect(()=>{y&&x(!1)},[y]),h.useEffect(()=>{B!==a&&yr({value:B,name:r,type:"search",searchQueries:d,setSearchParams:i,filterKey:t,pageKey:l})},[B]);const W=h.useCallback(()=>{p(!0),requestAnimationFrame(()=>{var A;return(A=L.current)==null?void 0:A.focus()})},[]);Oo(o,W);const k=()=>{c&&!T&&p(!1)},D=A=>{var w;c&&A.key==="Escape"&&!T&&(p(!1),(w=L.current)==null||w.blur())},H=()=>{y||x(!0)};return e.jsxs(u.Box,{display:"flex",direction:"row",align:"center",gap:"spacing-0",children:[b&&e.jsx(P.Button,{variant:"outline",tone:"neutral",size:"sm",iconLeft:e.jsx(E.Icon,{name:"Search",size:"sm"}),"aria-label":"Search","aria-expanded":!1,onClick:W}),e.jsxs(u.Box,{onTransitionEnd:H,style:{position:"relative",width:y?Wo:0,overflow:"hidden",transition:"width 220ms ease"},children:[e.jsx(Qe.Input,{ref:L,size:"sm",fullWidth:!0,value:T,placeholder:n,leftIcon:e.jsx(E.Icon,{name:"Search",width:16,height:16}),onChange:A=>v(A.target.value),onKeyDown:D,onBlur:k,tabIndex:y?0:-1}),y&&!T&&e.jsx(u.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(S.Text,{fontSize:"xs",color:"subtle",children:o})})]})]})},dl=({columns:r,allVisible:t,onToggle:l,onReorder:n,onSetAllHidden:o})=>{const[c,s]=h.useState(null),[i,d]=h.useState(null),a=()=>{c!==null&&i!==null&&c!==i&&n(c,i),s(null),d(null)},y=(p,b)=>{const x=p+b;x<0||x>=r.length||n(p,x)};return e.jsxs(O.Menu,{position:"bottom-right",children:[e.jsx(O.MenuButton,{children:e.jsx(P.Button,{variant:t?"outline":"secondary",tone:"neutral",size:"sm",iconLeft:e.jsx(E.Icon,{name:"Grid",size:"sm"}),"aria-label":"Customize columns"})}),e.jsx(O.MenuLists,{children:e.jsx(O.MenuBody,{children:e.jsxs(u.Box,{padding:"sm",direction:"column",customWidth:"296px",customMaxHeight:"60vh",overflow:"overflow-hidden",children:[e.jsx(S.Text,{fontWeight:"semibold",color:"primary",children:"Customize Column Table"}),e.jsxs(u.Box,{direction:"row",display:"flex",align:"center",justify:"space-between",paddingBlock:"md",children:[e.jsx(S.Text,{fontSize:"sm",fontWeight:"medium",color:"subtle",children:"Show in table"}),e.jsx(P.Button,{variant:"link",tone:"info",size:"xs",onClick:()=>o(t),children:t?"Hide All":"Show All"})]}),e.jsx(u.Box,{direction:"column",overflow:"overflow-y-auto",children:r.map((p,b)=>{const x=!p.locked,T=i===b&&c!==null&&c!==b;return e.jsxs(u.Box,{direction:"row",display:"flex",align:"center",gap:"sm",paddingBlock:"xs",draggable:x,onDragStart:()=>x&&s(b),onDragOver:v=>{v.preventDefault(),d(b)},onDrop:a,onDragEnd:a,style:{minHeight:32,boxShadow:T?"inset 0 2px 0 0 var(--sa-background-brand, #04254f)":void 0},children:[e.jsx(u.Box,{direction:"column",as:"div",align:"center",justify:"center",role:"button",tabIndex:x?0:-1,"aria-label":`Reorder ${p.title}`,"aria-disabled":!x||void 0,color:"icon-subtlest",onKeyDown:v=>{x&&(v.key==="ArrowUp"?(v.preventDefault(),y(b,-1)):v.key==="ArrowDown"&&(v.preventDefault(),y(b,1)))},style:{display:"inline-flex",cursor:x?"grab":"default",opacity:x?1:.4},children:e.jsx(E.Icon,{name:"DragVertical",width:16,height:16})}),p.icon&&e.jsx(u.Box,{direction:"column",align:"center",color:"icon-subtle",style:{display:"inline-flex"},children:p.icon}),e.jsx(S.Text,{fontSize:"sm",fontWeight:"medium",color:"primary",truncate:!0,children:p.title}),e.jsx(u.Box,{direction:"column",style:{marginLeft:"auto"},children:e.jsx(nr.Toggle,{size:"sm",checked:p.visible,disabled:p.locked,onChange:()=>l(p.key),"aria-label":`Toggle ${p.title} column`})})]},p.key)})})]})})})]})},hl=({views:r,onApply:t,onDelete:l,onSave:n})=>{const[o,c]=h.useState(""),s=()=>{const i=o.trim();i&&(n(i),c(""))};return e.jsxs(O.Menu,{position:"bottom-right",children:[e.jsx(O.MenuButton,{children:e.jsx(P.Button,{variant:r.length>0?"secondary":"outline",tone:(r.length>0,"neutral"),size:"sm",iconLeft:e.jsx(E.Icon,{name:"Bookmark",size:"sm"}),"aria-label":"Saved views"})}),e.jsxs(O.MenuLists,{style:{width:"260px"},children:[e.jsx(O.MenuBody,{children:e.jsxs(u.Box,{direction:"column",padding:"xs",gap:"sm",children:[e.jsx(S.Text,{fontWeight:"semibold",color:"primary",children:"Saved Views"}),e.jsx(u.Box,{direction:"column",overflow:"overflow-y-auto",children:r.length===0?e.jsx(u.Box,{direction:"column",paddingBlock:"sm",children:e.jsx(S.Text,{fontSize:"sm",color:"subtlest",children:"No saved views yet"})}):r.map(i=>e.jsx(O.MenuItem,{startIcon:e.jsx(E.Icon,{name:"Bookmark"}),onClick:()=>t(i),endIcon:e.jsx(P.Button,{variant:"link",tone:"error",size:"sm",iconLeft:e.jsx(E.Icon,{name:"Trash2"}),"aria-label":`Delete ${i.name}`,onClick:d=>{d.stopPropagation(),l(i.id)}}),children:i.name},i.id))})]})}),e.jsx(O.MenuFooter,{children:e.jsxs(u.Box,{direction:"row",gap:"xs",children:[e.jsx(u.Box,{direction:"column",style:{flex:"1 0 0",minWidth:0},children:e.jsx(Qe.Input,{size:"sm",fullWidth:!0,placeholder:"Save current view as…",value:o,onChange:i=>c(i.target.value),onKeyDown:i=>{i.key==="Enter"&&s()}})}),e.jsx(P.Button,{variant:"primary",tone:"brand",size:"sm",disabled:!o.trim(),onClick:s,children:"Save"})]})})]})]})},Ao=({isOpen:r,onClose:t,configs:l,activeKeys:n,configByKey:o,hasActiveFilter:c,onToggle:s,onReset:i,getValue:d,setValue:a,clearValue:y,removeFilter:p})=>{const b=n.length;return e.jsx(vr.Drawer,{position:"bottom",isShow:r,onHide:t,children:e.jsxs(u.Box,{direction:"column",customMaxHeight:"85vh",style:{minHeight:280},children:[e.jsxs(u.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(u.Box,{direction:"row",display:"flex",align:"center",gap:"xs",children:[e.jsx(S.Text,{fontWeight:"semibold",color:"primary",children:"Filter"}),b>0&&e.jsxs(S.Text,{fontSize:"sm",color:"subtle",children:["(",b,")"]})]}),e.jsx(P.Button,{variant:"link",tone:"neutral",size:"sm",iconLeft:e.jsx(E.Icon,{name:"Cross"}),"aria-label":"Close filter",onClick:t})]}),e.jsxs(u.Box,{direction:"column",gap:"lg",padding:"md",overflow:"overflow-y-auto",style:{flex:"1 1 auto",minHeight:0},children:[b>0&&e.jsxs(u.Box,{direction:"column",gap:"sm",children:[e.jsx(S.Text,{fontSize:"xs",fontWeight:"medium",color:"subtlest",children:"Filter aktif"}),e.jsx(u.Box,{direction:"row",display:"flex",wrap:"wrap",gap:"sm",align:"center",children:e.jsx(il,{activeKeys:n,configByKey:o,getValue:d,setValue:a,clearValue:y,removeFilter:p})})]}),l.length>0&&e.jsxs(u.Box,{direction:"column",gap:"sm",children:[e.jsx(S.Text,{fontSize:"xs",fontWeight:"medium",color:"subtlest",children:"Tambah filter"}),e.jsx(u.Box,{direction:"column",children:l.map(x=>{const T=n.includes(x.key),v=!!x.locked;return e.jsxs(u.Box,{direction:"row",display:"flex",align:"center",justify:"space-between",gap:"sm",paddingBlock:"sm",style:{opacity:v?.5:1,borderTop:"1px solid var(--sa-border-subtle, rgba(11, 18, 14, 0.08))"},children:[e.jsxs(u.Box,{direction:"row",display:"flex",align:"center",gap:"sm",style:{minWidth:0},children:[x.icon&&e.jsx(u.Box,{direction:"column",align:"center",color:"icon-subtle",style:{display:"inline-flex"},children:x.icon}),e.jsx(S.Text,{fontSize:"sm",color:"primary",truncate:!0,children:x.label})]}),e.jsx(nr.Toggle,{size:"sm",checked:T||v,disabled:v,onChange:()=>s(x.key),"aria-label":`Toggle ${x.label}`})]},x.key)})})]})]}),e.jsxs(u.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(u.Box,{direction:"column",style:{flex:"1 1 0"},children:e.jsx(P.Button,{variant:"outline",tone:"neutral",size:"md",fullWidth:!0,disabled:!c,onClick:i,children:"Reset"})}),e.jsx(u.Box,{direction:"column",style:{flex:"1 1 0"},children:e.jsx(P.Button,{variant:"primary",tone:"brand",size:"md",fullWidth:!0,onClick:t,children:"Selesai"})})]})]})})},zo=r=>`${r} Rows`,Ho=({perPageKey:r,pageKey:t,pageSizeOptions:l,defaultPerPage:n=10,showPageSize:o})=>{const{searchQueries:c,setSearchParams:s,searchParams:i}=ke(),d=i.get(r),a=d?Number(d):n,y=p=>{s({...c,[r]:p,[t]:"1"})};return o?e.jsxs(O.Menu,{position:"bottom-right",children:[e.jsx(O.MenuButton,{children:e.jsx(P.Button,{variant:"outline",tone:"neutral",size:"sm",iconLeft:e.jsx(E.Icon,{name:"MenuVertical",size:"sm"}),"aria-label":"More options"})}),e.jsx(O.MenuLists,{children:e.jsxs(O.MenuBody,{style:{minWidth:200},children:[e.jsx(u.Box,{paddingInline:"sm",paddingBlock:"xs",children:e.jsx(S.Text,{fontSize:"xs",fontWeight:"medium",color:"subtlest",children:"Rows per page"})}),l.map(p=>e.jsx(O.MenuItem,{selected:p===a,endIcon:p===a?e.jsx(E.Icon,{name:"Check"}):void 0,onClick:()=>y(String(p)),children:zo(p)},p))]})})]}):null},Vo=r=>{var ve;const{withPadding:t,configs:l,activeKeys:n,configByKey:o,hasActiveFilter:c,toggleFilter:s,removeFilter:i,getValue:d,setValue:a,clearValue:y,onReset:p,searchable:b,searchKey:x,filterKey:T,pageKey:v,searchPlaceholder:B,searchShortcut:L,searchCollapsible:W,pagination:k,perPageKey:D,pageSizeOptions:H,defaultPerPage:A,showPagination:w,showResultCount:m,showPageSize:_,hasColumns:V,orderedColumns:q,allVisible:J,onToggleVisibility:le,onReorder:ge,onSetAllHidden:oe,showSavedViews:ie,savedViews:K,onApplyView:Y,onDeleteView:de,onSaveView:te}=r,[ae,Be]=h.useState(!1),{searchQueries:Ne,setSearchParams:pe}=ke(),me=(k==null?void 0:k.rangeStart)??(((k==null?void 0:k.currentPage)||0)>1?(((k==null?void 0:k.currentPage)||0)-1)*((k==null?void 0:k.perPage)||0)+1:1),Te=(k==null?void 0:k.rangeEnd)??((k==null?void 0:k.totalCurrentPage)!==(k==null?void 0:k.perPage)?k==null?void 0:k.totalData:((k==null?void 0:k.currentPage)||1)*((k==null?void 0:k.totalCurrentPage)||0)),be=Le=>{pe({...Ne,[v]:String(Le)})},Ae=m||w&&!!(k!=null&&k.totalPage),Ze=()=>{p(),Be(!1)};return e.jsxs(u.Box,{direction:"column",gap:"sm",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(u.Box,{direction:"row",display:"flex",align:"center",wrap:"wrap",gap:"sm",fullWidth:!0,overflow:"overflow-auto",children:[b&&e.jsx(al,{searchKey:x,filterKey:T,pageKey:v,placeholder:B,shortcut:L,collapsible:W}),e.jsx(P.Button,{variant:c?"secondary":"outline",tone:"neutral",size:"sm",iconLeft:e.jsx(E.Icon,{name:"FilterHorizontal"}),onClick:()=>Be(!0),"aria-label":"Open filters",children:c?`Filter: ${n.length}`:null}),e.jsxs(u.Box,{direction:"row",display:"flex",align:"center",gap:"sm",style:{marginLeft:"auto"},children:[ie&&e.jsx(hl,{views:K,onApply:Y,onDelete:de,onSave:te}),V&&e.jsx(dl,{columns:q,allVisible:J,onToggle:le,onReorder:ge,onSetAllHidden:oe}),e.jsx(Ho,{perPageKey:D,pageKey:v,pageSizeOptions:H,defaultPerPage:A,showPageSize:_})]})]}),Ae&&e.jsxs(u.Box,{direction:"row",display:"flex",align:"center",justify:"space-between",gap:"sm",fullWidth:!0,children:[m?e.jsx(S.Text,{fontSize:"sm",fontWeight:"medium",color:"primary",truncate:!0,children:`${me}-${Te} of ${((ve=k==null?void 0:k.totalData)==null?void 0:ve.toLocaleString())||0}`}):e.jsx(u.Box,{direction:"column"}),w&&!!(k!=null&&k.totalPage)&&e.jsx(fr.Pagination,{size:"xs",variant:"neutral",siblingCount:0,currentPage:k!=null&&k.currentPage?Number(k.currentPage):1,totalPages:Number(k.totalPage),onPageChange:be})]}),e.jsx(Ao,{isOpen:ae,onClose:()=>Be(!1),configs:l,activeKeys:n,configByKey:o,hasActiveFilter:c,onToggle:s,onReset:Ze,getValue:d,setValue:a,clearValue:y,removeFilter:i})]})},jo=({withPadding:r=!1,filterConfigs:t=[],filterKey:l="filter",activeFilterKey:n="filters",pageKey:o="page",perPageKey:c="perPage",pageSizeOptions:s=[25,50,100],defaultPerPage:i,showPagination:d=!0,showResultCount:a=!0,showPageSize:y=!0,searchable:p=!1,searchKey:b="q",searchPlaceholder:x="Search",searchShortcut:T="/",searchPosition:v="right",searchCollapsible:B=!0,pagination:L,columns:W=[],onColumnsChange:k,columnsState:D,scopeId:H,savedViews:A,persistLastState:w=!0,storage:m=Rr,onReset:_})=>{const V=H??(A==null?void 0:A.scopeId),{activeKeys:q,configByKey:J,hasActiveFilter:le,toggleFilter:ge,removeFilter:oe,getValue:ie,setValue:K,clearValue:Y,clearAll:de}=$r({configs:t,filterKey:l,activeFilterKey:n,pageKey:o,searchKey:b}),te=ao({columns:W,scopeId:V,storage:m,onColumnsChange:k,value:D}),ae=ho({scopeId:V,storage:m,snapshotKeys:[n,l,c],pageKey:o,getColumns:()=>te.state,applyColumns:te.applyState}),Be=fo({scopeId:V,storage:m,snapshotKeys:[n,l,o],enabled:w}),Ne=go({scopeId:V,storage:m,perPageKey:c,pageSizeOptions:s,enabled:w});yo({enabled:w&&!!V,snapshotKeys:[n,l,o],perPageKey:c,readSnapshot:Be.read,readPerPage:Ne.read});const pe=i??s[0]??25,me=!!(A!=null&&A.enabled)&&ae.enabled,Te=()=>{de(),Be.clear(),_==null||_()},be=ue.useMediaQuery("md"),Ae=p?e.jsx(al,{searchKey:b,filterKey:l,pageKey:o,placeholder:x,shortcut:T,collapsible:B}):null;return be?e.jsxs(u.Box,{display:"flex",direction:"row",align:"center",gap:"sm",wrap:"wrap",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(u.Box,{direction:"row",display:"flex",align:"center",gap:"sm",style:{flex:"1 1 0",minWidth:0},children:[e.jsx(po,{configs:t,activeKeys:q,onToggle:ge,hasActiveFilter:le,onReset:Te}),v==="left"&&Ae,e.jsxs(u.Box,{direction:"row",display:"flex",align:"center",gap:"sm",overflow:"overflow-x-auto",style:{flex:"1 1 0",minWidth:0},children:[e.jsx(il,{activeKeys:q,configByKey:J,getValue:ie,setValue:K,clearValue:Y,removeFilter:oe}),le&&e.jsx(P.Button,{variant:"link",tone:"brand",size:"sm",onClick:Te,children:"Reset"})]})]}),e.jsxs(u.Box,{direction:"row",display:"flex",align:"center",gap:"sm",children:[e.jsx(Io,{pagination:L,pageKey:o,perPageKey:c,pageSizeOptions:s,defaultPerPage:pe,showPagination:d,showResultCount:a,showPageSize:y}),v==="right"&&Ae,me&&e.jsx(hl,{views:ae.views,onApply:ae.applyView,onDelete:ae.deleteView,onSave:ae.saveView}),W.length>0&&e.jsx(dl,{columns:te.orderedColumns,allVisible:te.allVisible,onToggle:te.toggleVisibility,onReorder:te.reorder,onSetAllHidden:te.setAllHidden})]})]}):e.jsx(Vo,{withPadding:r,configs:t,activeKeys:q,configByKey:J,hasActiveFilter:le,toggleFilter:ge,removeFilter:oe,getValue:ie,setValue:K,clearValue:Y,onReset:Te,searchable:p,searchKey:b,filterKey:l,pageKey:o,searchPlaceholder:x,searchShortcut:T,searchCollapsible:B,pagination:L,perPageKey:c,pageSizeOptions:s,defaultPerPage:pe,showPagination:d,showResultCount:a,showPageSize:y,hasColumns:W.length>0,orderedColumns:te.orderedColumns,allVisible:te.allVisible,onToggleVisibility:te.toggleVisibility,onReorder:te.reorder,onSetAllHidden:te.setAllHidden,showSavedViews:me,savedViews:ae.views,onApplyView:ae.applyView,onDeleteView:ae.deleteView,onSaveView:ae.saveView})},Po=r=>{if(!Array.isArray(r)||r.length===0)return;const t=r[0];return(t==null?void 0:t.value)!=null?String(t.value):void 0},No=r=>{if(!Array.isArray(r)||r.length===0)return;const t=r.map(l=>(l==null?void 0:l.value)!=null?String(l.value):null).filter(l=>l!=null);return t.length?t:void 0},_o=(r,t)=>{switch(r.type){case"dropdown":case"radio":return Po(t);case"dropdown-multiple":case"checkbox-multiple":return No(t);case"date":return t instanceof Date?t.toISOString():void 0;case"date-compact":return t;default:return}},fl=(r,t)=>{if(r==null||r==="")return t;const l=Number(r);return Number.isFinite(l)&&l>0?l:t},qo=r=>{const{filterConfigs:t,filterKey:l="filter",activeFilterKey:n="filters",pageKey:o="page",perPageKey:c="perPage",searchKey:s="q",defaultPage:i=1,defaultPerPage:d=10,paramKeys:a,serialize:y}=r,{activeKeys:p,configByKey:b,hasActiveFilter:x,getValue:T}=$r({configs:t,filterKey:l,activeFilterKey:n,pageKey:o,searchKey:s}),{searchParams:v}=ke(),B=v.toString();return h.useMemo(()=>{const W={},k={},D=fl(v.get(o),i),H=fl(v.get(c),d);W[(a==null?void 0:a.page)??"page"]=D,W[(a==null?void 0:a.perPage)??"perPage"]=H;const A=Sr(s,v,l)||"";A&&(W[(a==null?void 0:a.search)??"search"]=A);let w=!1;for(const m of p){const _=b[m];if(!_)continue;const V=T(_);k[m]=V;const q=y==null?void 0:y[m],J=q?q(V):_o(_,V);if(J==null||Array.isArray(J)&&J.length===0)continue;const le=(a==null?void 0:a[m])??m;W[le]=J,w=!0}return{params:W,raw:k,hasActiveFilter:x||!!A||w}},[B,p.join("|"),l,n,o,c,s,i,d,a,y,b])},Zo=["dropdown","dropdown-multiple","checkbox-multiple","radio"],Go=({filterConfigs:r,filterKey:t,activeFilterKey:l,pageKey:n,searchKey:o})=>{const{configByKey:c,getValue:s,setValue:i,removeFilter:d,clearAll:a,hasActiveFilter:y}=$r({configs:r,filterKey:t,activeFilterKey:l,pageKey:n,searchKey:o}),p=(L,W)=>{var D;const k=L.options;return((D=k==null?void 0:k.find(H=>H.value===W))==null?void 0:D.label)??W},b=h.useCallback(L=>{const W=c[L];if(!W)return[];const k=s(W);return Array.isArray(k)?k.map(D=>String(D.value)):[]},[c,s]),x=h.useCallback((L,W)=>{const k=c[L];if(!k||!Zo.includes(k.type))return;const D=Array.isArray(W)?W:[W];if(D.length===0){d(L);return}i(k,D.map(H=>({label:p(k,H),value:H})))},[c,i,d]),T=h.useCallback((L,W)=>{const k=b(L);x(L,k.includes(W)?k.filter(D=>D!==W):[...k,W])},[b,x]),v=h.useCallback((L,W)=>b(L).includes(W),[b]),B=h.useCallback(L=>d(L),[d]);return{set:x,toggle:T,clear:B,clearAll:a,isActive:v,values:b,hasActiveFilter:y}},Qo=(r,t)=>{if(!r)return{};const{fromKey:l,toKey:n,opKey:o}=t,c={};switch(r.op){case"is":case"is-before":case"is-after":case"is-on-or-before":case"is-on-or-after":return r.date&&(c[l]=new Date(r.date).toISOString()),o&&(c[o]=r.op),c;case"is-between":return r.from&&(c[l]=new Date(r.from).toISOString()),r.to&&(c[n]=new Date(r.to).toISOString()),c;case"is-relative-to-today":{if(!r.relative)return c;const{from:s,to:i}=rl(r.relative);return c[l]=s.toISOString(),c[n]=i.toISOString(),c}case"is-empty":case"is-not-empty":return o&&(c[o]=r.op==="is-empty"?"empty":"not-empty"),c;default:return c}},gl=({children:r,borderRadius:t,height:l})=>{const n=h.useRef(null),[o,c]=h.useState("100vh");return h.useEffect(()=>{if(l)return;const s=()=>{if(n.current){const i=n.current.getBoundingClientRect().top;c(`calc(100vh - ${i}px)`)}};return s(),window.addEventListener("resize",s),()=>window.removeEventListener("resize",s)},[l]),e.jsx(u.Box,{ref:n,fullWidth:!0,borderStyle:"border-solid",borderWidth:"border",borderColor:"border-base",borderRadius:t||"rounded-xs",style:{height:l??o,display:"flex",flexDirection:"column"},children:r})},ul=({action:r,rightContent:t,leftContent:l,headerSlot:n,advanceFilter:o,showFilter:c=!0})=>{const s=ue.useMediaQuery("md"),i=c?e.jsx(Rt,{...o}):null,d=()=>r?h.isValidElement(r)?r:e.jsx(u.Box,{style:{display:"flex",flexDirection:s?"row":"column",gap:"8px",width:s?"auto":"100%",textWrap:"nowrap"},children:r.map(({title:a,icon:y,buttonProps:p,onClick:b},x)=>!a&&!y?null:e.jsx(P.Button,{fullWidth:!s,iconLeft:y?e.jsx(E.Icon,{name:y}):void 0,onClick:b,...p,children:a},`action-${x}`))}):null;return e.jsx(u.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:s?"row":"column-reverse",gap:"16px"},children:n?n({filter:i}):e.jsxs(e.Fragment,{children:[e.jsxs(u.Box,{style:{display:"flex",gap:"8px",flexDirection:"row",alignItems:"center",flex:1,minWidth:0},children:[i,l]}),e.jsxs(u.Box,{style:{display:"flex",gap:"8px",flexDirection:"row",alignItems:"center",flexShrink:0},children:[t,d()]})]})})},Uo=({totalData:r,withMarginBottom:t=!0,withMarginTop:l=!0})=>e.jsxs(u.Box,{style:{display:"flex",gap:"4px",flexDirection:"row",alignItems:"center",marginBottom:t?"16px":void 0,marginTop:l?"16px":void 0},children:[e.jsxs(We.Body1,{props:{color:"gray-500"},children:["Total data:"," "]}),e.jsx(We.Body1,{children:r||0})]}),yl=({pagination:r,pageKey:t="page",perPageKey:l="perPage",defaultPerPage:n=10,showPagination:o=!0,totalData:c})=>{const{searchQueries:s,setSearchParams:i,searchParams:d}=ke(),a=d.get(l),y=T=>{i({...s,[t]:String(T)})},p=T=>{i({...s,[l]:T,[t]:"1"})},b=(r==null?void 0:r.rangeStart)??(((r==null?void 0:r.currentPage)||0)>1?(((r==null?void 0:r.currentPage)||0)-1)*((r==null?void 0:r.perPage)||0)+1:1),x=(r==null?void 0:r.rangeEnd)??((r==null?void 0:r.totalCurrentPage)!==(r==null?void 0:r.perPage)?r==null?void 0:r.totalData:((r==null?void 0:r.currentPage)||1)*((r==null?void 0:r.totalCurrentPage)||0));return e.jsx(u.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(u.Box,{style:{display:"flex",flexDirection:"row",gap:"8px",alignItems:"center",textWrap:"nowrap"},children:[e.jsx(S.Text,{children:"Rows Per Page: "}),e.jsx(tr.Dropdown,{dropdownLists:[{label:"5",value:"5"},{label:"10",value:"10"},{label:"25",value:"25"},{label:"50",value:"50"},{label:"100",value:"100"}],onChange:T=>{p(T[0].value)},value:a?[{label:`${a} per row`,value:a}]:[{label:`${n} per row`,value:`${n}`}],defaultValue:a?[{label:`${a} per row`,value:a}]:[{label:`${n} per row`,value:`${n}`}]}),e.jsx(S.Text,{children:`${b}-${x} of ${(r==null?void 0:r.totalData)||0}`})]}),e.jsx(fr.Pagination,{currentPage:r!=null&&r.currentPage?Number(r==null?void 0:r.currentPage):1,totalPages:r!=null&&r.totalPage?Number(r==null?void 0:r.totalPage):1,onPageChange:y})]}):e.jsx(Uo,{totalData:c,withMarginBottom:!1,withMarginTop:!1})})},pl=({filter:r,columnTitle:t})=>{const[l,n]=h.useState(!1),o=h.useRef(null),c=h.useRef(null),s=h.useRef(null),[i,d]=h.useState(""),[a,y]=h.useState({top:0,left:0}),p=r.selectedValues,b=h.useMemo(()=>i?r.options.filter(v=>v.label.toLowerCase().includes(i.toLowerCase())):r.options,[r.options,i]);h.useEffect(()=>{if(l&&c.current){const v=c.current.getBoundingClientRect(),B=280,L={top:v.bottom+8};r.position==="left"||v.left+B>window.innerWidth?L.right=window.innerWidth-v.right:L.left=v.left,y(L)}},[l,r.position]),h.useEffect(()=>{l&&s.current?setTimeout(()=>{var v;return(v=s.current)==null?void 0:v.focus()},50):d("")},[l]),h.useEffect(()=>{const v=B=>{o.current&&!o.current.contains(B.target)&&c.current&&!c.current.contains(B.target)&&n(!1)};return l&&document.addEventListener("mousedown",v),()=>document.removeEventListener("mousedown",v)},[l]);const x=v=>{const B=p.includes(v)?p.filter(L=>L!==v):[...p,v];r.onFilterChange(B)},T=()=>r.onFilterChange([]);return e.jsxs(u.Box,{direction:"column",style:{position:"relative"},children:[e.jsx(u.Box,{ref:c,style:{display:"flex",flexDirection:"row",alignItems:"center",cursor:"pointer"},onClick:v=>{var B;v.stopPropagation(),l||(B=r.onOpen)==null||B.call(r),n(L=>!L)},children:e.jsx(E.Icon,{name:l?"ChevronUp":"ChevronDown",size:"sm",style:{color:p.length>0?"var(--sa-color-brand-500, #1a4fa0)":"var(--sa-text-subtle, #8c8f97)"}})}),l&&e.jsxs(u.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(u.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(S.Text,{fontSize:"sm",fontWeight:"semibold",color:"gray-700",children:["Filter ",t]}),p.length>0&&e.jsx(u.Box,{direction:"column",style:{cursor:"pointer"},children:e.jsx(S.Text,{fontSize:"xs",color:"primary",fontWeight:"semibold",onClick:v=>{v.stopPropagation(),T()},children:"CLEAR"})})]}),!r.hideSearch&&e.jsx(u.Box,{direction:"column",style:{paddingLeft:"16px",paddingRight:"16px",paddingTop:"8px",paddingBottom:"8px"},children:e.jsx(Qe.Input,{ref:s,placeholder:`Search ${t.toLowerCase()}...`,leftIcon:e.jsx(E.Icon,{name:"Search",size:"sm"}),value:i,onChange:v=>d(v.target.value),style:{fontSize:"14px"}})}),e.jsx(u.Box,{direction:"column",className:"ts-filter-dropdown-options",style:{overflowY:"auto",maxHeight:"250px",paddingLeft:"8px",paddingRight:"8px"},children:r.isLoadingOptions?e.jsxs(u.Box,{style:{paddingTop:"40px",paddingBottom:"40px",display:"flex",alignItems:"center",justifyContent:"center",flexDirection:"column"},children:[e.jsx(E.Icon,{name:"Loading",size:"lg",style:{color:"var(--sa-background-brand, #04254f)",animation:"spin 1s linear infinite"}}),e.jsx(S.Text,{fontSize:"sm",color:"gray-500",style:{textAlign:"center",marginTop:"8px"},children:"Loading options..."})]}):b.length>0?e.jsx(u.Box,{direction:"column",style:{gap:"2px",paddingTop:"4px",paddingBottom:"4px"},children:b.map(v=>e.jsxs(u.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:p.includes(v.value)?"var(--sa-color-brand-50, #e6edf6)":"transparent"},onClick:B=>{B.stopPropagation(),x(v.value)},onMouseEnter:B=>{p.includes(v.value)||(B.currentTarget.style.backgroundColor="var(--sa-background-primary, #ffffff)"),B.currentTarget.style.transform="translateX(2px)"},onMouseLeave:B=>{B.currentTarget.style.backgroundColor=p.includes(v.value)?"var(--sa-color-brand-50, #e6edf6)":"transparent",B.currentTarget.style.transform="translateX(0)"},children:[e.jsx(cr.Checkbox,{checked:p.includes(v.value),onChange:()=>{}}),e.jsx(S.Text,{fontSize:"sm",fontWeight:p.includes(v.value)?"medium":"normal",color:p.includes(v.value)?"primary":"gray-700",children:v.label})]},v.value))}):e.jsxs(u.Box,{style:{paddingTop:"40px",paddingBottom:"40px",display:"flex",alignItems:"center",justifyContent:"center",flexDirection:"column"},children:[e.jsx(E.Icon,{name:"Search",size:"lg",style:{color:"var(--sa-text-subtle, #8c8f97)"}}),e.jsx(S.Text,{fontSize:"sm",color:"gray-500",style:{textAlign:"center",marginTop:"8px"},children:"No results found"})]})}),p.length>0&&e.jsx(u.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(u.Box,{style:{display:"flex",flexDirection:"row",alignItems:"center",gap:"4px"},children:[e.jsx(u.Box,{direction:"column",style:{backgroundColor:"var(--sa-background-brand, #04254f)",borderRadius:"12px",padding:"2px 8px",fontSize:"11px",fontWeight:600,color:"white"},children:p.length}),e.jsxs(S.Text,{fontSize:"xs",color:"primary",fontWeight:"medium",children:["item",p.length>1?"s":""," selected"]})]})})]})]})},Jo=({direction:r})=>{const t="var(--sa-text-primary, #292a2e)",l="var(--sa-text-subtle, #8c8f97)",n=r==="asc"?t:l,o=r==="desc"?t:l,c=r==="asc"?1:.45,s=r==="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:n,opacity:c,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:s},children:e.jsx("path",{d:"M0 0 L8 0 L4 5 Z",fill:"currentColor"})})]})},Yo=({frozen:r})=>e.jsxs("svg",{width:"11",height:"11",viewBox:"0 0 24 24",fill:r?"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:r?"M7 11V7a5 5 0 0 1 10 0v4":"M7 11V7a5 5 0 0 1 9.9-1"})]}),ot="var(--sa-background-primary, #ffffff)",bl="var(--sa-background-primary-inverse, #f8f8f8)",vl=({columns:r,records:t,handleDetail:l,handleUpdate:n,handleDelete:o,isLoading:c,visibleHandleDelete:s,visibleHandleUpdate:i,visibleHandleDetail:d,showHeadBorder:a=!1,scrollParentRef:y,frozenCount:p=0,onFrozenCountChange:b,customActions:x,actionsOrder:T=["detail","update","delete","custom"],customEmptyState:v,enableColumnResize:B=!1,defaultColumnWidths:L,onColumnWidthsChange:W,defaultMinColumnWidth:k=60,sort:D,defaultSort:H,onSortChange:A,showActionDivider:w=!1})=>{const m=D!==void 0,[_,V]=h.useState(H??null),q=m?D??null:_,J=I=>{if(I.sortKey)return I.sortKey;if(typeof I.accessor=="string")return I.accessor},le=I=>{const j=J(I);if(!j)return;let N;!q||q.key!==j?N={key:j,direction:"asc"}:q.direction==="asc"?N={key:j,direction:"desc"}:N=null,m||V(N),A==null||A(N)},oe=[l,n,o].filter(I=>I!==void 0).length,ie=!!x,K=!!l||!!n||!!o||ie,Y="var(--sa-border-subtle, #0b120e24)",de=`1px solid ${Y}`,te=`inset 1px 0 0 ${Y}`,ae=`inset -1px 0 0 ${Y}`,Be=oe===3?ie?"178px":"140px":oe===2?ie?"140px":"102px":oe===1?ie?"112px":"74px":ie?"74px":"",Ne=(I,j)=>{if(!j)return I;if(typeof j=="function")return j(I);if(typeof j=="string")return I[j]},[pe,me]=h.useState(!1);h.useEffect(()=>{if(!(y!=null&&y.current))return;const I=y.current;me(I.scrollHeight>I.clientHeight)},[t,y]);const Te=h.useRef(null),[be,Ae]=h.useState([]),[Ze,ve]=h.useState(()=>L??{}),Le=h.useRef(null);h.useLayoutEffect(()=>{if(!p||!Te.current){Ae([]);return}const I=Array.from(Te.current.querySelectorAll("thead tr th")),j=[];let N=0;I.forEach((G,R)=>{j[R]=N,R<p&&(N+=G.offsetWidth)}),Ae(j)},[p,r,t,Ze]);const Ye=I=>{b&&b(I<p?I:I+1)},F=(I,j)=>{const N=Ze[I];if(N!==void 0){const G=`${N}px`;return{width:G,minWidth:G,maxWidth:G}}return j?{width:j}:{}},Q=I=>B&&(I.resizable??!0),Z=(I,j)=>{I.preventDefault(),I.stopPropagation();const N=I.currentTarget.closest("th");if(!N)return;const G=Math.round(N.getBoundingClientRect().width);Le.current={colIndex:j,startX:I.clientX,startWidth:G};const R=document.body.style.userSelect,xe=document.body.style.cursor;document.body.style.userSelect="none",document.body.style.cursor="col-resize";const Fe=He=>{var $e;const Ie=Le.current;if(!Ie)return;const Xe=(($e=r[Ie.colIndex])==null?void 0:$e.minWidth)??k,Ke=Math.max(Xe,Ie.startWidth+(He.clientX-Ie.startX));ve(Ve=>Ve[Ie.colIndex]===Ke?Ve:{...Ve,[Ie.colIndex]:Ke})},ze=()=>{document.removeEventListener("mousemove",Fe),document.removeEventListener("mouseup",ze),document.body.style.userSelect=R,document.body.style.cursor=xe,Le.current=null,W&&ve(He=>(W(He),He))};document.addEventListener("mousemove",Fe),document.addEventListener("mouseup",ze)};return e.jsx("div",{ref:Te,children:e.jsxs(U.Table,{fullWidth:!0,children:[e.jsx(U.Thead,{style:{height:"40px",whiteSpace:"nowrap"},children:e.jsxs(U.Tr,{children:[r.map((I,j)=>{var sr,ar;const N=p>0&&j<p,G=be[j]??0,R=Q(I),Fe=j===r.length-1&&K&&w,ze=J(I),He=!!I.sortable&&!!ze,Ie=He&&(q==null?void 0:q.key)===ze?q.direction:null,Xe=I.title||((sr=I.accessor)==null?void 0:sr.toString())||"",Ke=(ar=I.headerTooltip)!=null&&ar.showIcon?e.jsx(E.Icon,{name:"InfoCircle",size:"xs",style:{flexShrink:0,color:"var(--sa-icon-subtle, #8c8f97)",opacity:.75}}):null,$e=e.jsx("span",{style:{flex:1,minWidth:0,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:Xe}),Ve=He?e.jsxs("button",{type:"button",onClick:()=>le(I),title:Ie==="asc"?"Sorted ascending — click to sort descending":Ie==="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:I.textAlign==="text-right"?"right":I.textAlign==="text-center"?"center":"left"},children:[$e,Ke,e.jsx(Jo,{direction:Ie})]}):e.jsxs("span",{style:{flex:1,minWidth:0,display:"flex",alignItems:"center",gap:4},children:[$e,Ke]});return e.jsxs(U.Th,{style:{position:"sticky",top:0,left:N?G:void 0,zIndex:N?4:2,paddingLeft:j===0?"12px":"",borderRight:a&&!Fe&&!N?de:void 0,borderBottom:a?de:void 0,boxShadow:a&&N?ae:void 0,backgroundColor:"var(--sa-background-primary-inverse, #f8f8f8)",textAlign:I.textAlign==="text-right"?"right":I.textAlign==="text-center"?"center":"left",...F(j,I.width)},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"4px",justifyContent:"space-between",minWidth:0},children:[I.headerTooltip?e.jsx(De.Tooltip,{label:I.headerTooltip.content,position:"bottom",children:Ve}):Ve,I.filter&&e.jsx(pl,{filter:I.filter,columnTitle:I.title}),b&&e.jsx("button",{onClick:()=>Ye(j),title:N?"Unfreeze column":"Freeze column",style:{background:"none",border:"none",cursor:"pointer",padding:"2px",display:"flex",alignItems:"center",flexShrink:0,color:N?"var(--sa-background-brand, #04254f)":"var(--sa-text-subtle, #8c8f97)",opacity:N?1:.45,transition:"opacity 0.15s"},children:e.jsx(Yo,{frozen:N})})]}),R&&e.jsx("div",{onMouseDown:dr=>Z(dr,j),onClick:dr=>dr.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-${j}`)}),K?e.jsx(U.Th,{style:{backgroundColor:"var(--sa-background-primary-inverse, #f8f8f8)",position:"sticky",top:0,right:0,zIndex:3,borderBottom:a?de:void 0,boxShadow:a&&w?te:void 0}}):null]})}),e.jsx(U.Tbody,{children:c?e.jsx(U.Tr,{children:e.jsx(U.Td,{colSpan:r.length+1,children:e.jsxs(u.Box,{direction:"column",style:{gap:"16px"},children:[e.jsx(je.Skeleton,{variant:"list"}),e.jsx(je.Skeleton,{variant:"list"}),e.jsx(je.Skeleton,{variant:"list"}),e.jsx(je.Skeleton,{variant:"list"}),e.jsx(je.Skeleton,{variant:"list"})]})})}):!(t!=null&&t.length)&&v?e.jsx(U.Tr,{children:e.jsx(U.Td,{colSpan:r.length+1,children:v})}):t==null?void 0:t.map((I,j)=>e.jsxs(U.Tr,{style:{transition:"background-color 0.3s ease",padding:0,borderBottom:j===t.length-1&&pe?void 0:"1px solid var(--sa-border-subtle, #0b120e24)"},onMouseEnter:N=>{const G=N.currentTarget;G.style.backgroundColor=bl,Array.from(G.querySelectorAll("td")).forEach(R=>{R.style.position==="sticky"&&(R.style.backgroundColor=bl)})},onMouseLeave:N=>{const G=N.currentTarget;G.style.backgroundColor="",Array.from(G.querySelectorAll("td")).forEach(R=>{R.style.position==="sticky"&&(R.style.backgroundColor=ot)})},children:[r.map((N,G)=>{const R=N.render?N.render(I,j,t):Ne(I,N.accessor),xe=p>0&&G<p,Fe=be[G]??0,ze=Ze[G]!==void 0,He=xe&&G===p-1;return e.jsx(U.Td,{style:{position:xe?"sticky":void 0,left:xe?Fe:void 0,zIndex:xe?1:void 0,backgroundColor:xe?ot:void 0,transition:xe?"background-color 0.3s ease":void 0,paddingLeft:G===0?"12px":"",whiteSpace:"nowrap",overflow:ze?"hidden":void 0,borderLeft:N.showBorderLeft?de:void 0,borderRight:N.showBorderRight?de:void 0,boxShadow:He?ae:void 0,textAlign:N.textAlign==="text-right"?"right":N.textAlign==="text-center"?"center":"left",...F(G,N.width)},children:typeof R=="string"?e.jsx(S.Text,{style:{whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",textAlign:N.textAlign==="text-right"?"right":N.textAlign==="text-center"?"center":"left"},children:R}):R},`row-${j}-col-${G}`)}),K?e.jsx(U.Td,{style:{width:Be,position:"sticky",right:0,zIndex:1,backgroundColor:ot,boxShadow:w?te:void 0,transition:"background-color 0.3s ease"},children:e.jsx(ne.Flex,{direction:"row",align:"center",justify:"center",gap:"sm",children:T.map(N=>{const G=j===t.length-1?"top":"bottom";return N==="detail"&&l&&(d==null?void 0:d(I))!==!1?e.jsx(De.Tooltip,{label:"Detail",position:G,children:e.jsx(P.Button,{size:"xs",variant:"outline",tone:"neutral",onClick:()=>l(I.id,I),iconLeft:e.jsx(E.Icon,{name:"DocumentClean",size:"sm",style:{color:"var(--sa-text-subtle, #8c8f97)"}})})},"detail"):N==="update"&&n&&(i==null?void 0:i(I))!==!1?e.jsx(De.Tooltip,{label:"Update",position:G,children:e.jsx(P.Button,{size:"xs",variant:"outline",tone:"neutral",onClick:()=>n(I),iconLeft:e.jsx(E.Icon,{name:"Edit1",size:"sm",style:{color:"var(--sa-text-subtle, #8c8f97)"}})})},"update"):N==="delete"&&o&&(s==null?void 0:s(I))!==!1?e.jsx(De.Tooltip,{label:"Delete",position:G,children:e.jsx(P.Button,{size:"xs",variant:"outline",tone:"neutral",onClick:()=>o(I.id,I),iconLeft:e.jsx(E.Icon,{name:"Trash1",size:"sm",style:{color:"var(--sa-color-error-600, #c9184a)"}})})},"delete"):N==="custom"?e.jsx(h.Fragment,{children:x==null?void 0:x(I)},"custom"):null})})}):null]},`${I}${j}`))})]})})},Xo=({wrapperProps:r,dataTableProps:t,headerProps:l,footerProps:n})=>{var p;const o=h.useRef(null),[c,s]=h.useState((t==null?void 0:t.defaultFrozenCount)??0),i=(l==null?void 0:l.show)??!0,d=h.useRef(null),a=(p=t==null?void 0:t.pagination)==null?void 0:p.totalData;typeof a=="number"&&(d.current=a);const y=(n==null?void 0:n.showFooter)??(a===void 0?d.current!==0:a!==0);return e.jsxs(gl,{...r,children:[i&&e.jsx(ul,{...l}),e.jsx(u.Box,{direction:"column",ref:o,style:{flex:1,overflowY:"auto",overflowX:"auto"},children:t?e.jsx(vl,{...t,scrollParentRef:o,frozenCount:t!=null&&t.enableFreezeColumns?c:0,onFrozenCountChange:t!=null&&t.enableFreezeColumns?s:void 0}):null}),y&&e.jsx(yl,{pagination:t==null?void 0:t.pagination,pageKey:t==null?void 0:t.pageKey,perPageKey:t==null?void 0:t.perPageKey,defaultPerPage:t==null?void 0:t.defaultPerPage,showPagination:t==null?void 0:t.showPagination,totalData:n==null?void 0:n.totalData})]})};function Ko(r){return h.memo(r)}const $o=Ko(Xo),Cl=200,nt="1px solid var(--sa-border-subtle, #0b120e24)",Ro=({sortDir:r,frozen:t})=>r==="asc"?e.jsx(E.Icon,{name:"ChevronSmallUp"}):r==="desc"?e.jsx(E.Icon,{name:"ChevronSmallDown"}):t?e.jsx(E.Icon,{name:"LockOn",size:"xs"}):e.jsx(E.Icon,{name:"Filter",size:"xs"}),Er=({icon:r,label:t,active:l,danger:n,onClick:o})=>{const c=n?"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:l?"var(--sa-background-brand-subtlest, #e6edf6)":"none",border:"none",cursor:"pointer",font:"inherit",color:c,textAlign:"left"},onMouseEnter:s=>{l||(s.currentTarget.style.background="var(--sa-background-primary-inverse, #f8f8f8)")},onMouseLeave:s=>{s.currentTarget.style.background=l?"var(--sa-background-brand-subtlest, #e6edf6)":"none"},children:[e.jsx(E.Icon,{name:r,size:"sm",style:{color:c,flexShrink:0}}),e.jsx(S.Text,{as:"span",style:{color:c},children:t})]})},xl=({active:r,canSort:t,canHide:l,sortDir:n,frozen:o,onSort:c,onClearSort:s,onToggleFreeze:i,onHide:d})=>{const[a,y]=h.useState(!1),p=h.useRef(null),b=h.useRef(null),[x,T]=h.useState({top:0,left:0});h.useEffect(()=>{if(a&&p.current){const B=p.current.getBoundingClientRect(),L=B.left+Cl>window.innerWidth;T({top:B.bottom+6,...L?{right:window.innerWidth-B.right}:{left:B.left}})}},[a]),h.useEffect(()=>{if(!a)return;const B=L=>{b.current&&!b.current.contains(L.target)&&p.current&&!p.current.contains(L.target)&&y(!1)};return document.addEventListener("mousedown",B),()=>document.removeEventListener("mousedown",B)},[a]);const v=B=>{B(),y(!1)};return e.jsxs(e.Fragment,{children:[e.jsx("button",{ref:p,type:"button",className:"sa-tl-menu-trigger","data-active":r||a?"true":"false",onClick:B=>{B.stopPropagation(),y(L=>!L)},title:"Column options",style:{display:"inline-flex",alignItems:"center",justifyContent:"center",width:22,height:22,borderRadius:"var(--sa-radii-sm, 6px)",border:nt,background:"var(--sa-background-primary, #ffffff)",cursor:"pointer",color:"var(--sa-text-subtle, #8c8f97)",flexShrink:0},children:e.jsx(Ro,{sortDir:n,frozen:o})}),a&&e.jsxs(u.Box,{ref:b,onClick:B=>B.stopPropagation(),style:{position:"fixed",top:`${x.top}px`,...x.left!==void 0?{left:`${x.left}px`}:{right:`${x.right}px`},minWidth:Cl,backgroundColor:"var(--sa-background-primary, #ffffff)",border:nt,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:[t&&e.jsxs(e.Fragment,{children:[e.jsx(Er,{icon:"ChevronUp",label:"Ascending",active:n==="asc",onClick:()=>v(()=>n==="asc"?s():c("asc"))}),e.jsx(Er,{icon:"ChevronDown",label:"Descending",active:n==="desc",onClick:()=>v(()=>n==="desc"?s():c("desc"))}),e.jsx("div",{style:{borderTop:nt,margin:"4px 0"}})]}),e.jsx(Er,{icon:"Pin1",label:o?"Unfreeze":"Freeze",active:o,onClick:()=>v(i)}),l&&e.jsx(Er,{icon:"EyeClosed",label:"Hide column",danger:!0,onClick:()=>v(d)})]})]})},Mr="1px solid var(--sa-border-subtle, #0b120e24)",en="var(--sa-text-subtle, #8c8f97)",pr="var(--sa-background-neutral, #f0f1f2)",wl="2px 0 4px -2px rgba(0,0,0,0.15)",Lr={display:"block",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},Dl="sa-table-layout-styles",rn=()=>{if(typeof document>"u"||document.getElementById(Dl))return;const r=document.createElement("style");r.id=Dl,r.textContent=`
1
+ (function(g,er){typeof exports=="object"&&typeof module<"u"?er(exports,require("@starasia/alert"),require("@starasia/badges"),require("@starasia/box"),require("@starasia/breadcrumb"),require("@starasia/button"),require("@starasia/card"),require("@starasia/date"),require("@starasia/dialog"),require("@starasia/drawer"),require("@starasia/dropdown"),require("@starasia/hooks"),require("@starasia/http"),require("@starasia/input"),require("@starasia/menu"),require("@starasia/pagination"),require("@starasia/storage"),require("@starasia/table"),require("@starasia/tabs"),require("@starasia/textarea"),require("@starasia/theme"),require("@starasia/toast"),require("@starasia/toggle"),require("@starasia/tooltip"),require("@starasia/checkbox"),require("@starasia/radio"),require("@starasia/text"),require("@starasia/icon"),require("@starasia/flex"),require("@starasia/grid"),require("@starasia/progress"),require("@starasia/stepper"),require("@starasia/accordion"),require("@starasia/story-record"),require("@starasia/skeleton"),require("@starasia/progress-stepper"),require("react/jsx-runtime"),require("react"),require("react-router"),require("react-dom"),require("react-easy-crop")):typeof define=="function"&&define.amd?define(["exports","@starasia/alert","@starasia/badges","@starasia/box","@starasia/breadcrumb","@starasia/button","@starasia/card","@starasia/date","@starasia/dialog","@starasia/drawer","@starasia/dropdown","@starasia/hooks","@starasia/http","@starasia/input","@starasia/menu","@starasia/pagination","@starasia/storage","@starasia/table","@starasia/tabs","@starasia/textarea","@starasia/theme","@starasia/toast","@starasia/toggle","@starasia/tooltip","@starasia/checkbox","@starasia/radio","@starasia/text","@starasia/icon","@starasia/flex","@starasia/grid","@starasia/progress","@starasia/stepper","@starasia/accordion","@starasia/story-record","@starasia/skeleton","@starasia/progress-stepper","react/jsx-runtime","react","react-router","react-dom","react-easy-crop"],er):(g=typeof globalThis<"u"?globalThis:g||self,er(g["@starasia/admin"]={},g.alert,g.badges,g.box,g.breadcrumb,g.button,g.card,g.date,g.dialog,g.drawer,g.dropdown,g.hooks,g.http,g.input,g.menu,g.pagination,g.storage,g.table,g.tabs,g.textarea,g.theme,g.toast,g.toggle,g.tooltip,g.checkbox,g.radio,g.text,g.icon,g.flex,g.grid,g.progress,g.stepper,g.accordion,g.storyRecord,g.skeleton,g.progressStepper,g.jsxRuntime,g.React,g.ReactRouter,g.ReactDOM,g.ReactEasyCrop))})(this,function(g,er,Ge,u,rr,P,yt,Ue,Oe,vr,tr,ue,lr,Qe,O,fr,gr,U,pt,Pr,or,bt,nr,De,cr,Nr,S,E,ne,vt,Ct,xt,wt,Dt,je,St,e,h,ye,_r,zl){"use strict";const Hl={menus:[],menuBottom:void 0,logo:"",appName:"Workspace",userData:null,setUserData:()=>{}},qr=h.createContext(Hl),Zr=()=>h.useContext(qr),kt=r=>{const[t,l]=h.useState((r==null?void 0:r.initialUserData)||null);return{userData:t,setUserData:l}},Bt=h.createContext({badges:{},setBadge:()=>{},setBadges:()=>{},clearBadge:()=>{}}),mt=({children:r})=>{const[t,l]=h.useState({}),n=h.useCallback(i=>{l(d=>typeof i=="function"?i(d):i)},[]),o=h.useCallback((i,d)=>{l(a=>{const y=typeof d=="function"?d(a[i]):d;return{...a,[i]:y}})},[]),c=h.useCallback(i=>{l(d=>{if(!(i in d))return d;const a={...d};return delete a[i],a})},[]),s=h.useMemo(()=>({badges:t,setBadge:o,setBadges:n,clearBadge:c}),[t,o,n,c]);return e.jsx(Bt.Provider,{value:s,children:r})},Ft=()=>h.useContext(Bt),Cr=(r,t)=>{const l=t!==void 0?t:r;return l==null?null:typeof l=="string"||typeof l=="number"?{value:l}:l},Et=({router:r,menus:t=[],menuBottom:l,logo:n,appName:o="Workspace",initialUserData:c,theme:s})=>{const i=kt({initialUserData:c}),{theme:d}=or.useTheme();return e.jsx(qr.Provider,{value:{logo:n,appName:o,menus:t,userData:i.userData,setUserData:i.setUserData,menuBottom:l},children:e.jsx(mt,{children:s?e.jsx(or.ThemeProvider,{value:s,children:r}):d?e.jsx(or.ThemeProvider,{value:d,children:r}):r})})},Vl=h.memo(Et);function Mt({collapsed:r=!1,children:t}){if(!t)return null;const l=typeof t=="function",n=l?t({collapsed:r}):t;return n==null||n===!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:l?n:e.jsx("div",{style:{opacity:r?0:1,transition:"opacity 0.3s",visibility:r?"hidden":"visible"},children:n})})}const Gr=h.createContext(null);function Lt({children:r}){const[t,l]=h.useState(null),[n,o]=h.useState(null),[c,s]=h.useState(null),[i,d]=h.useState(0),a=h.useCallback(()=>(d(y=>y+1),()=>d(y=>y-1)),[]);return e.jsx(Gr.Provider,{value:{prependNode:t,appendNode:n,replaceNode:c,setPrependNode:l,setAppendNode:o,setReplaceNode:s,replaceCount:i,registerReplace:a},children:r})}function Tt({children:r}){const t=h.useContext(Gr);return t?e.jsxs(e.Fragment,{children:[e.jsx("div",{ref:t.setPrependNode,style:{display:"contents"}}),t.replaceCount>0?e.jsx("div",{ref:t.setReplaceNode,style:{display:"contents"}}):r,e.jsx("div",{ref:t.setAppendNode,style:{display:"contents"}})]}):e.jsx(e.Fragment,{children:r})}function jl({children:r,mode:t="append"}){const l=h.useContext(Gr);if(h.useEffect(()=>{if(!(t!=="replace"||!l))return l.registerReplace()},[t,l]),!l)return process.env.NODE_ENV!=="production"&&console.warn("[HeaderLeftSlot] used outside AppLayout — content not rendered"),null;const n=t==="prepend"?l.prependNode:t==="replace"?l.replaceNode:l.appendNode;return n?_r.createPortal(r,n):null}const Qr=h.createContext(null);function It({children:r}){const[t,l]=h.useState({}),[n,o]=h.useState({}),c=h.useCallback((d,a)=>{l(y=>y[d]===a?y:{...y,[d]:a})},[]),s=h.useCallback(d=>(o(a=>({...a,[d]:(a[d]??0)+1})),()=>o(a=>({...a,[d]:Math.max(0,(a[d]??0)-1)}))),[]),i=h.useMemo(()=>({outletNodes:t,setOutletNode:c,slotCounts:n,registerSlot:s}),[t,c,n,s]);return e.jsx(Qr.Provider,{value:i,children:r})}function Ot({slotKey:r,fallback:t}){const l=h.useContext(Qr),n=l?(l.slotCounts[r]??0)>0:!1,o=h.useRef(l==null?void 0:l.setOutletNode);o.current=l==null?void 0:l.setOutletNode;const c=h.useCallback(s=>{var i;return(i=o.current)==null?void 0:i.call(o,r,s)},[r]);return e.jsx(e.Fragment,{children:n?e.jsx("div",{ref:c,style:{display:"contents"}}):t})}function Pl({slotKey:r,children:t}){const l=h.useContext(Qr),n=h.useRef(l==null?void 0:l.registerSlot);if(n.current=l==null?void 0:l.registerSlot,h.useEffect(()=>{var c;return(c=n.current)==null?void 0:c.call(n,r)},[r]),!l)return process.env.NODE_ENV!=="production"&&console.warn("[SidebarGroupSlot] used outside AppLayout — content not rendered"),null;const o=l.outletNodes[r];return o?_r.createPortal(t,o):null}const xr="moduleSwitcherGroupId",Ur="sa-module-switcher-change";function Wt(){if(typeof window>"u")return null;const r=window.localStorage.getItem(xr);if(r===null)return null;const t=Number(r);return Number.isFinite(t)?t:null}function At(r){typeof window>"u"||(r===null?window.localStorage.removeItem(xr):window.localStorage.setItem(xr,String(r)),window.dispatchEvent(new CustomEvent(Ur,{detail:r})))}function Nl(){At(null)}function Jr(){const[r,t]=h.useState(()=>Wt());return h.useEffect(()=>{const n=()=>{t(Wt())},o=c=>{c.key===xr&&n()};return window.addEventListener(Ur,n),window.addEventListener("storage",o),()=>{window.removeEventListener(Ur,n),window.removeEventListener("storage",o)}},[]),{selectedGroupId:r,setSelectedGroupId:n=>{At(n),t(n)}}}let wr=0,Je=!1,zt=new Set;const Ht=()=>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"})]}),Vt={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 _l({children:r,headerLeftSlot:t,profile:l,isLoadingProfile:n,onLogout:o,isLoggingOut:c,loadingComponent:s,sidebarHeaderContent:i,headerActions:d,profileRole:a,profileMenuButtons:y,profileMenuItems:p,logoutButton:b}){var Le,Ye;const[x]=ye.useSearchParams(),T=x.get("embed")==="true",v=Zr(),{badges:B}=Ft(),L=ye.useNavigate(),W=ye.useLocation(),D=!ue.useMediaQuery("md"),[H,A]=h.useState(!1),[w,m]=h.useState(!1),[_,V]=h.useState(!1),[q,J]=h.useState(!1),[le,ge]=h.useState(()=>new Set(zt)),[oe,ie]=h.useState(null),{selectedGroupId:K,setSelectedGroupId:Y}=Jr();h.useEffect(()=>{zt=le},[le]);const de=h.useRef(null),te=h.useRef(null);h.useEffect(()=>{const F=de.current;if(!F)return;const Q=()=>{Je||(wr=F.scrollTop)};return F.addEventListener("scroll",Q),()=>F.removeEventListener("scroll",Q)},[]);const ae=()=>{const F=de.current;F&&wr>0&&(Je=!0,F.scrollTop=wr,requestAnimationFrame(()=>{Je=!1}))};h.useLayoutEffect(()=>{Je=!0,ae();const F=setTimeout(()=>{Je=!1},300);return()=>clearTimeout(F)},[]),h.useLayoutEffect(()=>{v.menus.length>0&&(wr>0?ae():requestAnimationFrame(()=>{var Q;const F=(Q=de.current)==null?void 0:Q.querySelector("[data-menu-active='true']");F&&F.scrollIntoView({block:"center",behavior:"instant"})}))},[v.menus]),h.useEffect(()=>{Je=!0,ae();const F=setTimeout(ae,0),Q=setTimeout(ae,50),Z=setTimeout(ae,100),I=setTimeout(ae,200),j=setTimeout(()=>{Je=!1},300),N=setTimeout(()=>{const G=de.current,R=G==null?void 0:G.querySelector("[data-menu-active='true']");if(G&&R){const xe=G.getBoundingClientRect(),Fe=R.getBoundingClientRect();Fe.top>=xe.top&&Fe.bottom<=xe.bottom||R.scrollIntoView({block:"center",behavior:"smooth"})}},250);return()=>{clearTimeout(F),clearTimeout(Q),clearTimeout(Z),clearTimeout(I),clearTimeout(j),clearTimeout(N)}},[W.pathname]),h.useEffect(()=>{te.current&&(te.current.scrollTop=0)},[W.pathname]),h.useEffect(()=>{D&&V(!1)},[W.pathname,D]),h.useEffect(()=>{D&&m(!0)},[D]);const Be=()=>{A(!0)},Ne=()=>{A(!1)},pe=()=>{A(!1),o()},me=F=>{const Q=[F.to];return F.children&&Q.push(...F.children.map(Z=>Z.to)),Q},Te=[...v.menus.flatMap(F=>F.items.flatMap(me)),...((Le=v.menuBottom)==null?void 0:Le.flatMap(me))??[]],be=F=>{if(!W.pathname.startsWith(F))return!1;const Q=Te.filter(Z=>W.pathname.startsWith(Z)).sort((Z,I)=>I.length-Z.length)[0];return F===Q};h.useEffect(()=>{var Q;const F=Z=>{var I;(I=Z.children)!=null&&I.some(j=>W.pathname.startsWith(j.to))&&ge(j=>{const N=new Set(j);return N.add(Z.id),N})};v.menus.forEach(Z=>{Z.items.forEach(F)}),(Q=v.menuBottom)==null||Q.forEach(F)},[W.pathname,v.menus,v.menuBottom]);const Ae=F=>{ge(Q=>{const Z=new Set(Q);return Z.has(F)?Z.delete(F):Z.add(F),Z})};h.useEffect(()=>{v.menus.length!==0&&K!==null&&!v.menus.some(F=>F.id===K)&&Y(null)},[v.menus,K,Y]);const Ze=h.useMemo(()=>{if(K!==null)return v.menus.filter(Z=>Z.id===K||Z.parentGroupId===K);const F=v.menus.filter(Z=>Z.parentGroupId===void 0),Q=v.menus.filter(Z=>Z.parentGroupId!==void 0).flatMap(Z=>Z.items);return Q.length===0?F:[...F,{id:18,name:"Pengaturan",items:Q,parentGroupId:void 0}]},[v.menus,K]);if(T)return e.jsx("main",{style:{height:"100vh",overflowY:"auto",backgroundColor:"var(--sa-background-primary-inverse, #f8f8f8)"},children:r||e.jsx(ye.Outlet,{})});const ve=F=>{const Q=F.children&&F.children.length>0,Z=le.has(F.id),I=Q?F.children.some(G=>be(G.to)):be(F.to),j=Cr(F.badge,B[F.id]),N=!!j&&w&&!D;return e.jsxs("div",{"data-menu-active":I||void 0,children:[e.jsxs("button",{onClick:G=>{if(Q)if(w&&!D){const R=G.currentTarget.getBoundingClientRect();ie({item:F,top:R.top,left:R.right+8})}else Ae(F.id);else L(F.to)},style:{width:"100%",display:"flex",alignItems:"center",justifyContent:w&&!D?"center":void 0,gap:"0.5rem",paddingLeft:w&&!D?"0":"0.5rem",paddingRight:w&&!D?"0":"0.5rem",paddingTop:"0.25rem",paddingBottom:"0.25rem",height:"2rem",borderRadius:I?"var(--sa-radii-sm, 0.375rem)":"var(--sa-radii-md, 0.5rem)",textAlign:"left",border:I?"1px solid var(--sa-border-subtle, #0b120e24)":"1px solid transparent",backgroundColor:I?"var(--sa-background-primary, #ffffff)":"transparent",color:"var(--sa-text-primary, #292a2e)",cursor:"pointer"},title:w&&!D?F.title:void 0,onMouseEnter:G=>{I||(G.currentTarget.style.backgroundColor="var(--sa-background-neutral, #f0f1f2)")},onMouseLeave:G=>{I||(G.currentTarget.style.backgroundColor="transparent")},children:[e.jsxs("span",{style:{position:"relative",display:"inline-flex",flexShrink:0},children:[e.jsx(E.Icon,{name:F.icon,size:"sm",style:{flexShrink:0}}),N&&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)"}})]}),(!w||D)&&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:F.title}),j&&e.jsx(Ge.Badges,{text:String(j.value),variant:j.variant??"info",size:"xs",border:!0}),Q&&e.jsx("svg",{style:{width:"1rem",height:"1rem",flexShrink:0,transition:"transform 0.2s",transform:Z?"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"})})]})]}),Q&&(!w||D)&&(()=>{const G=F.children.findIndex(R=>be(R.to));return e.jsxs("div",{style:{position:"relative",marginLeft:"0.9375rem",paddingLeft:"1.125rem",overflow:"hidden",transition:"all 0.3s ease-in-out",maxHeight:Z?`${F.children.length*36}px`:"0px",opacity:Z?1:0,marginTop:Z?"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"}}),G>=0&&e.jsx("span",{"aria-hidden":"true",style:{position:"absolute",left:0,top:`${G*32}px`,width:"1.5px",height:"32px",backgroundColor:"var(--sa-text-primary, #292a2e)",transition:"top 0.2s ease-in-out",pointerEvents:"none",zIndex:1}}),F.children.map(R=>{const xe=Cr(R.badge,B[R.id]);return e.jsxs("button",{onClick:()=>L(R.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:be(R.to)?"var(--sa-radii-sm, 0.375rem)":"var(--sa-radii-md, 0.5rem)",textAlign:"left",backgroundColor:be(R.to)?"var(--sa-background-primary, #ffffff)":"transparent",color:be(R.to)?"var(--sa-text-primary, #292a2e)":"var(--sa-text-subtle, #505258)",cursor:"pointer",border:be(R.to)?"1px solid var(--sa-border-subtle, #0b120e24)":"1px solid transparent"},onMouseEnter:Fe=>{be(R.to)||(Fe.currentTarget.style.backgroundColor="var(--sa-background-neutral, #f0f1f2)")},onMouseLeave:Fe=>{be(R.to)||(Fe.currentTarget.style.backgroundColor="transparent")},children:[e.jsx(E.Icon,{name:R.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:R.title}),xe&&e.jsx(Ge.Badges,{text:String(xe.value),variant:xe.variant??"info",size:"xs",border:!0})]},R.id)})]})})()]},F.id)};return e.jsx(It,{children:e.jsxs(Lt,{children:[e.jsxs("div",{style:{display:"flex",height:"100vh",position:"relative","--app-sidebar-width":D?"0px":w?"4.375rem":"16.375rem","--app-footer-zindex":D&&_?"40":"999"},children:[D&&e.jsx("div",{style:{position:"fixed",inset:0,backgroundColor:"var(--sa-color-black-alpha-a50, #181a198f)",zIndex:40,opacity:_?.5:0,pointerEvents:_?"auto":"none",transition:"opacity 0.3s"},onClick:()=>V(!1)}),e.jsxs("aside",{style:{width:D?"16.375rem":w?"4.375rem":"16.375rem",position:D?"fixed":"relative",...D&&{inset:0,zIndex:50,transform:_?"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:D?void 0:0},children:[e.jsx("div",{onMouseEnter:()=>J(!0),onMouseLeave:()=>J(!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 F=!D&&w&&!_,Q=F&&q;return e.jsxs(e.Fragment,{children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"0.5rem",flex:F?1:void 0,justifyContent:F?"center":void 0,transition:"opacity 0.2s",opacity:Q?0:1,pointerEvents:Q?"none":"auto"},children:[e.jsx("img",{src:v.logo,alt:"Logo",style:{width:"2rem",height:"2rem",flexShrink:0}}),(!w||_)&&e.jsx("span",{style:{fontWeight:"600",color:"var(--sa-text-primary, #292a2e)",whiteSpace:"nowrap",transition:"opacity 0.3s"},children:v.appName})]}),!D&&!w&&e.jsx("button",{type:"button",onClick:()=>m(!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(Ht,{})}),F&&e.jsx("button",{type:"button",onClick:()=>m(!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:Q?1:0,pointerEvents:Q?"auto":"none",transition:"opacity 0.2s"},children:e.jsx("span",{style:{width:"1rem",height:"1rem",display:"inline-flex"},children:e.jsx(Ht,{})})}),D&&e.jsx("button",{onClick:()=>V(!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"})})})]})})()}),i&&e.jsx(Mt,{collapsed:D?!1:w,children:i}),e.jsx("div",{ref:de,style:{flex:1,overflowY:"auto",paddingTop:"1rem",paddingBottom:"1rem"},children:Ze.map(F=>e.jsxs("div",{style:{marginBottom:"1rem"},children:[!w||D?F.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:F.name}):F.name&&e.jsx("div",{"aria-label":F.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:F.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:F.slotKey?e.jsx(Ot,{slotKey:F.slotKey,fallback:F.items.map(Q=>ve(Q))}):F.items.map(Q=>ve(Q))})]},F.id))}),v.menuBottom&&v.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:v.menuBottom.map(F=>ve(F))})]}),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:D?"1rem":void 0},children:[D&&e.jsx("button",{onClick:()=>V(!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(Tt,{children:t})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"0.75rem"},children:[d,e.jsxs(O.Menu,{position:"bottom-right",children:[e.jsx(O.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:n?"Loading...":(l==null?void 0:l.name)||"unknown"}),e.jsx("p",{style:{margin:0,fontSize:"0.75rem",color:"var(--sa-text-subtle, #8c8f97)",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:n?"":(l==null?void 0:l.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:((l==null?void 0:l.name)||"U")[0].toUpperCase()}),e.jsx(E.Icon,{name:"ChevronDown",size:"sm",style:{color:"var(--sa-text-subtle, #8c8f97)"}})]})}),e.jsxs(O.MenuLists,{style:{width:"280px",paddingBlock:"12px",paddingInline:"12px",gap:"8px",marginTop:"16px"},children:[e.jsx(O.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:((l==null?void 0:l.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:(l==null?void 0:l.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:(l==null?void 0:l.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})]})}),(y&&y.length>0||p)&&e.jsxs(O.MenuBody,{children:[y==null?void 0:y.map((F,Q)=>e.jsx(O.MenuButton,{children:e.jsxs("button",{type:"button",onClick:F.onClick,style:Vt,onMouseEnter:Z=>{Z.currentTarget.style.backgroundColor="var(--sa-background-neutral, #f0f1f2)"},onMouseLeave:Z=>{Z.currentTarget.style.backgroundColor="transparent"},children:[e.jsx(E.Icon,{name:F.icon,size:"md"}),e.jsx("span",{children:F.label})]})},`${F.label}-${Q}`)),p]}),b??e.jsx(O.MenuFooter,{children:e.jsx(O.MenuButton,{children:e.jsxs("button",{type:"button",onClick:Be,style:{...Vt,color:"var(--sa-background-error, #c9184a)",fontWeight:500},onMouseEnter:F=>{F.currentTarget.style.backgroundColor="var(--sa-color-error-50, #fff0f3)"},onMouseLeave:F=>{F.currentTarget.style.backgroundColor="transparent"},children:[e.jsx(E.Icon,{name:"Logout",size:"md",style:{color:"var(--sa-background-error, #c9184a)"}}),e.jsx("span",{children:"Logout"})]})})})]})]})]})]}),e.jsx("main",{ref:te,style:{flex:1,overflowY:"auto"},children:r||e.jsx(ye.Outlet,{})})]})]}),c&&s&&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:s}),e.jsxs(Oe.Dialog,{isShow:H,onHide:Ne,children:[e.jsx(Oe.DialogTitle,{children:"Confirmation Logout"}),e.jsx(Oe.DialogBody,{children:"Are you sure you want to end the session and exit the page?"}),e.jsx(Oe.DialogFooter,{children:e.jsx(u.Box,{direction:"column",display:"flex",align:"flex-end",justify:"center",children:e.jsxs(ne.Flex,{direction:"row",gap:"sm",align:"center",children:[e.jsx(u.Box,{direction:"column",children:e.jsx(P.Button,{secondary:!0,onClick:Ne,children:"Cancel"})}),e.jsx(u.Box,{direction:"column",children:e.jsx(P.Button,{primary:!0,onClick:pe,children:"Yes, Sure"})})]})})})]}),oe&&e.jsxs(e.Fragment,{children:[e.jsx("div",{onClick:()=>ie(null),style:{position:"fixed",inset:0,zIndex:60,backgroundColor:"transparent"}}),e.jsxs("div",{role:"dialog","aria-label":oe.item.title,style:{position:"fixed",top:oe.top,left:oe.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:oe.item.title}),(Ye=oe.item.children)==null?void 0:Ye.map(F=>{const Q=be(F.to),Z=Cr(F.badge,B[F.id]);return e.jsxs("button",{onClick:()=>{L(F.to),ie(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:Q?"var(--sa-color-gray-100, #f8f8f8)":"transparent",color:Q?"var(--sa-text-primary, #292a2e)":"var(--sa-color-gray-800, #505258)",border:"1px solid transparent",cursor:"pointer",fontSize:"0.875rem",fontWeight:500},onMouseEnter:I=>{Q||(I.currentTarget.style.backgroundColor="var(--sa-color-gray-100, #f8f8f8)")},onMouseLeave:I=>{Q||(I.currentTarget.style.backgroundColor="transparent")},children:[F.icon&&e.jsx(E.Icon,{name:F.icon,size:"sm",style:{flexShrink:0}}),e.jsx("span",{style:{flex:1,whiteSpace:"nowrap"},children:F.title}),Z&&e.jsx(Ge.Badges,{text:String(Z.value),variant:Z.variant??"info",size:"xs",border:!0})]},F.id)})]})]})]})})}const ur=h.forwardRef(({children:r,...t},l)=>e.jsx(u.Box,{ref:l,role:"button",cursor:"pointer","aria-pressed":"true",display:"inline-block",tabIndex:0,...t,children:r})),jt=({title:r,iconName:t,textColor:l,iconColor:n,hoverTextColor:o,hoverIconColor:c})=>{const[s,i]=h.useState(!1),d=n??"var(--sa-text-subtle, #8c8f97)",a=l??"var(--sa-text-subtle, #8c8f97)",y=c??"var(--sa-text-subtle, #8c8f97)",p=o??"var(--sa-text-primary, #292a2e)";return e.jsxs(u.Box,{direction:"row",gap:"xs",align:"center",onMouseEnter:()=>i(!0),onMouseLeave:()=>i(!1),style:{cursor:"pointer"},children:[e.jsx(E.Icon,{name:t||"ChevronLeft",size:"xs",style:{color:s?y:d,transition:"color 0.15s ease"}}),e.jsx(S.Text,{variant:"sub-h3",style:{color:s?p:a,transition:"color 0.15s ease"},children:r||"Back"})]})},ql=({items:r,separator:t="/",iconName:l,iconColor:n,hoverIconColor:o})=>{const[c,s]=h.useState(!1),i=n??"var(--sa-text-subtle, #8c8f97)",d=o??"var(--sa-text-subtle, #8c8f97)",a=r.length>1?r[0]:void 0,y=!!(a!=null&&a.to||a!=null&&a.onClick),p=e.jsx(E.Icon,{name:l||"ChevronLeft",size:"xs",onMouseEnter:y?()=>s(!0):void 0,onMouseLeave:y?()=>s(!1):void 0,style:{color:y&&c?d:i,transition:"color 0.15s ease",cursor:y?"pointer":void 0}}),b=a!=null&&a.to?e.jsx(ye.Link,{to:a.to,replace:!0,style:{textDecoration:"none"},children:p}):a!=null&&a.onClick?e.jsx(ur,{onClick:a.onClick,children:p}):p;return e.jsxs(u.Box,{direction:"row",gap:"xs",align:"center",children:[b,e.jsx(rr.Breadcrumb,{separator:t,size:"md",children:r.map((x,T)=>{const v=T===r.length-1;return x.to&&!v?e.jsx(rr.BreadcrumbItem,{children:e.jsx(ye.Link,{to:x.to,children:x.label})},T):e.jsx(rr.BreadcrumbItem,{currentPage:v,children:e.jsx(rr.BreadcrumbLink,{onClick:v?void 0:x.onClick,children:x.label})},T)})})]})},Zl=r=>{const{items:t,separator:l,onClick:n,navigateTo:o,...c}=r;return t&&t.length>0?e.jsx(ql,{items:t,separator:l,iconName:c.iconName,iconColor:c.iconColor,hoverIconColor:c.hoverIconColor}):o?e.jsx(u.Box,{direction:"row",children:e.jsx(ye.Link,{to:o,replace:!0,style:{textDecoration:"none"},children:e.jsx(jt,{...c})})}):e.jsx(u.Box,{direction:"row",children:e.jsx(ur,{onClick:n,children:e.jsx(jt,{...c})})})},Yr=[{icon:"var(--sa-color-brand-400, #3366b7)",activeBg:"var(--sa-color-brand-50, #e6edf6)",activeBorder:"var(--sa-color-brand-300, #668cc9)",activeShadow:"rgba(51, 102, 183, 0.25)"},{icon:"var(--sa-color-warning-400, #ed9f30)",activeBg:"var(--sa-color-warning-50, #fef2e6)",activeBorder:"var(--sa-color-warning-300, #f1b259)",activeShadow:"rgba(237, 159, 48, 0.25)"},{icon:"var(--sa-color-secondary-300, #5468e1)",activeBg:"var(--sa-color-secondary-50, #e6e9fb)",activeBorder:"var(--sa-color-secondary-200, #8a98ea)",activeShadow:"rgba(84, 104, 225, 0.25)"},{icon:"var(--sa-color-info-500, #00abeb)",activeBg:"var(--sa-color-info-50, #effaff)",activeBorder:"var(--sa-color-info-300, #75dbff)",activeShadow:"rgba(0, 171, 235, 0.25)"},{icon:"var(--sa-color-success-500, #30ce84)",activeBg:"var(--sa-color-success-50, #ecfff6)",activeBorder:"var(--sa-color-success-300, #75dead)",activeShadow:"rgba(48, 206, 132, 0.25)"},{icon:"var(--sa-color-error-400, #ff758f)",activeBg:"var(--sa-color-error-50, #fff0f3)",activeBorder:"var(--sa-color-error-300, #ff8fa3)",activeShadow:"rgba(255, 117, 143, 0.25)"}];function Pt(r,t,l){return{display:"flex",alignItems:"center",justifyContent:"center",width:"64px",height:"64px",borderRadius:"var(--sa-radii-sm, 6px)",border:r?`2px solid ${l.activeBorder}`:"2px solid var(--sa-color-gray-200, #f0f1f2)",backgroundColor:r?l.activeBg:"var(--sa-color-gray-50, #ffffff)",boxShadow:r?t?`0 8px 20px ${l.activeShadow.replace("0.25","0.35")}`:`0 2px 8px ${l.activeShadow}`:t?"0 8px 20px rgba(0, 0, 0, 0.14)":"0 1px 4px rgba(0, 0, 0, 0.08)",transform:t?"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 Nt={fontSize:"11px",fontWeight:500,textAlign:"center",overflowWrap:"normal",wordBreak:"normal",color:"var(--sa-background-primary, #ffffff)",lineHeight:"1.3",maxWidth:"80px"},_t={display:"flex",flexDirection:"column",alignItems:"center",gap:"8px",background:"none",border:"none",cursor:"pointer",padding:0};function qt({isShow:r,onHide:t,menus:l,selectedGroupId:n,onSelect:o}){const[c,s]=h.useState(void 0),i=a=>{o(a),t()},d=Yr[0];return e.jsx(Oe.Dialog,{isShow:r,onHide:t,style:{width:560,background:"transparent",boxShadow:"none",border:"none"},children:e.jsx(Oe.DialogBody,{children:e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(5, 1fr)",gap:"16px"},children:[e.jsxs("button",{onClick:()=>i(null),onMouseEnter:()=>s("all"),onMouseLeave:()=>s(void 0),style:_t,children:[e.jsx("div",{style:Pt(n===null,c==="all",d),children:e.jsx("div",{style:{color:d.icon,display:"flex",alignItems:"center",justifyContent:"center"},children:e.jsx(E.Icon,{name:"Grid",size:"lg",style:{width:32,height:32}})})}),e.jsx("span",{style:Nt,children:"Semua"})]}),l.map((a,y)=>{var v;const p=n===a.id,b=c===a.id,x=((v=a.items[0])==null?void 0:v.icon)??"Grid",T=Yr[(y+1)%Yr.length];return e.jsxs("button",{onClick:()=>i(a.id),onMouseEnter:()=>s(a.id),onMouseLeave:()=>s(void 0),style:_t,children:[e.jsx("div",{style:Pt(p,b,T),children:e.jsx("div",{style:{color:T.icon,display:"flex",alignItems:"center",justifyContent:"center"},children:e.jsx(E.Icon,{name:x,size:"lg",style:{width:32,height:32}})})}),e.jsx("span",{style:Nt,children:a.name})]},a.id)})]})})})}function Gl({onSelect:r,"aria-label":t="Pilih module"}={}){const l=Zr(),n=ye.useNavigate(),{selectedGroupId:o,setSelectedGroupId:c}=Jr(),[s,i]=h.useState(!1),d=a=>{var y;if(c(a),a!==null){const p=l.menus.find(x=>x.id===a),b=(y=p==null?void 0:p.items[0])==null?void 0:y.to;b&&n(b)}r==null||r(a)};return e.jsxs(e.Fragment,{children:[e.jsxs("div",{style:{position:"relative"},children:[e.jsx("button",{onClick:()=>i(!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":t,onMouseEnter:a=>{a.currentTarget.style.backgroundColor="var(--sa-background-primary-inverse, #f8f8f8)"},onMouseLeave:a=>{a.currentTarget.style.backgroundColor="transparent"},children:e.jsx(E.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(qt,{isShow:s,onHide:()=>i(!1),menus:l.menus.filter(a=>a.parentGroupId===void 0),selectedGroupId:o,onSelect:d})]})}const Ql=(r,t)=>{const l=[];if(t===0)return l.push(r),l;for(let n=0;n<r.length;n+=t){const o=r.slice(n,n+t);l.push(o)}return l},Ul=h.memo(({value:r,label:t,separator:l,labelWidth:n,lastIndex:o,labelAlign:c="top"})=>{const s=h.useMemo(()=>({padding:0,paddingBottom:o?0:12,verticalAlign:c}),[o,c]),i=h.useMemo(()=>({padding:0,paddingRight:12,paddingLeft:12,paddingBottom:o?0:12,verticalAlign:c}),[o,c]),d=()=>typeof t=="string"?e.jsx(S.Text,{fontWeight:"medium",color:"subtlest",children:t}):t,a=()=>typeof r=="string"||typeof r=="number"?e.jsx(S.Text,{color:"primary",fontWeight:"medium",children:r}):r,y=()=>typeof l=="string"||typeof l=="number"?e.jsx(S.Text,{fontWeight:"medium",color:"subtlest",children:l}):l;return e.jsxs(U.Tr,{children:[e.jsx(U.Td,{style:s,width:n,children:d()}),l?e.jsx(U.Td,{style:i,width:24,children:y()}):null,e.jsx(U.Td,{style:s,children:a()})]})}),Jl=h.memo(({fields:r,separator:t,labelWidth:l})=>e.jsx(U.Table,{withColumnBorder:!1,withRowBorder:!1,children:r.map((n,o)=>e.jsx(Ul,{separator:t,labelWidth:l,lastIndex:o===r.length-1,...n},`field-group-field-${o}`))})),Yl=h.memo(({maxRow:r=0,maxColumn:t=2,separator:l=":",fields:n=[],labelWidth:o=150,bordered:c=!1})=>{const s=h.useMemo(()=>Ql(n,r),[n,r]),i=s.length>2,d=()=>{switch(t){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(u.Box,{gap:i?void 0:"lg",direction:"row",flexWrap:"wrap",borderRadius:"rounded-sm",padding:"lg",paddingBottom:i?"xs":"lg",bg:"accent-dark-tertiary",borderWidth:c?"border":void 0,borderStyle:c?"border-solid":void 0,borderColor:c?"border-subtle":void 0,children:s.map((a,y)=>e.jsx(u.Box,{direction:"column",flex:i?void 0:"1",width:i?d():void 0,marginBottom:i?"lg":void 0,children:e.jsx(Jl,{labelWidth:o,fields:a,separator:l})},y))})}),Xl=({backButton:r})=>{const[t,l]=h.useState(!1),n=(r==null?void 0:r.iconColor)??"var(--sa-text-subtle, #8c8f97)",o=(r==null?void 0:r.textColor)??"var(--sa-text-subtle, #8c8f97)",c=(r==null?void 0:r.hoverIconColor)??"var(--sa-text-subtle, #8c8f97)",s=(r==null?void 0:r.hoverTextColor)??"var(--sa-text-primary, #292a2e)";return e.jsxs(u.Box,{direction:"row",gap:"xs",align:"center",onMouseEnter:()=>l(!0),onMouseLeave:()=>l(!1),style:{cursor:"pointer"},children:[e.jsx(E.Icon,{name:(r==null?void 0:r.iconName)||"ChevronLeft",size:"xs",style:{color:t?c:n,transition:"color 0.15s ease"}}),e.jsx(S.Text,{variant:"sub-h3",style:{color:t?s:o,textDecoration:t?"underline":"none",transition:"color 0.15s ease"},children:(r==null?void 0:r.title)||"Back"})]})},Kl=({backButton:r,title:t,titleIcon:l,titleTag:n,children:o,header:c=!0,headerBorder:s=!1,subHeaders:i,action:d,titleTagProps:a,containerProps:y,headerProps:p})=>{const b=ue.useMediaQuery("md"),x=ye.useNavigate(),T=ye.useLocation(),v=r==null?void 0:r.show,B=()=>{if(typeof(r==null?void 0:r.onClick)=="function"){r.onClick();return}x(-1,{replace:!0})},L=()=>{if(!d)return null;if(h.isValidElement(d))return d;const w=d.filter(m=>m&&(m.title||m.icon));return w.length===0?null:b?e.jsx(u.Box,{direction:"row",gap:"md",children:w.map(({title:m,icon:_,buttonProps:V,onClick:q},J)=>e.jsx(P.Button,{iconLeft:_?e.jsx(E.Icon,{name:_,size:"md"}):void 0,onClick:q,...V,children:m},`action-${J}`))}):e.jsxs(O.Menu,{position:"bottom-right",children:[e.jsx(O.MenuButton,{children:e.jsx(P.Button,{variant:"tertiary",size:"sm",iconLeft:e.jsx(E.Icon,{name:"MenuBurger"}),"aria-label":"Actions"})}),e.jsx(O.MenuLists,{children:e.jsx(O.MenuBody,{style:{minWidth:200},children:w.map(({title:m,icon:_,buttonProps:V,onClick:q},J)=>{const le=(V==null?void 0:V.tone)==="error"||(V==null?void 0:V.danger)===!0;return e.jsx(O.MenuItem,{intent:le?"danger":void 0,disabled:V==null?void 0:V.disabled,startIcon:_?e.jsx(E.Icon,{name:_}):void 0,onClick:q,children:m},`action-${J}`)})})})]})},W=()=>{const w=e.jsx(Xl,{backButton:r});return r!=null&&r.navigateTo?e.jsx(u.Box,{direction:"row",children:e.jsx(ye.Link,{to:r.navigateTo,replace:!0,style:{textDecoration:"none"},children:w})}):e.jsx(u.Box,{direction:"row",children:e.jsx(ur,{onClick:B,children:w})})},k=()=>{const w=!!t,m=Array.isArray(d)&&d.length>0,_=h.isValidElement(d)?!0:m;if(!w&&!_&&!v)return null;const q=b||!b&&m;return e.jsxs(u.Box,{direction:"column",gap:"xs",paddingBlock:(p==null?void 0:p.paddingBlock)??"sm",paddingInline:(p==null?void 0:p.paddingInline)??"md",...p,style:{...s?{boxShadow:"inset 0 -1px 0 0 var(--sa-border-subtle, #0b120e24)"}:{},...p==null?void 0:p.style},children:[v&&W(),(w||_)&&e.jsxs(u.Box,{direction:q?"row":"column",gap:"sm",justify:"space-between",align:q?"center":"flex-start",children:[w?typeof t=="string"?e.jsxs(u.Box,{direction:"row",gap:"lg",align:"center",children:[e.jsxs(u.Box,{direction:"row",gap:"sm",align:"center",children:[l&&e.jsx(E.Icon,{name:l,size:"md",color:"primary"}),e.jsx(S.Text,{variant:"h3",fontWeight:"semibold",fontFamily:"Poppins",children:t})]}),n&&e.jsx(Ge.Badge,{border:!0,size:"lg",text:n,...a})]}):t:null,L()]})]})},D=()=>{if(!i||i.length===0)return null;const w=i.filter(V=>V.show!==!1);if(w.length===0)return null;let m=0,_=-1/0;return w.forEach((V,q)=>{const J=V.order??0;J>=_&&(_=J,m=q)}),w.map(({content:V,order:q,borderBottom:J=!0},le)=>e.jsx(u.Box,{direction:"column",paddingTop:"sm",paddingBottom:J||le===m?"sm":"spacing-0",paddingInline:"md",style:{...J?{boxShadow:"inset 0 -1px 0 0 var(--sa-border-subtle, #0b120e24)"}:{},...q!==void 0?{order:q}:{}},children:V},`sub-header-${le}`))},H=()=>{const w=c?k():null,m=D();return!w&&!m?null:e.jsxs(u.Box,{direction:"column",style:{marginBottom:m?"var(--sa-spacing-0)":"var(--sa-spacing-md)"},children:[w,m]})},A=()=>o;return e.jsxs(u.Box,{direction:"column",as:"main",...y,style:{...(y==null?void 0:y.style)??{},animation:"pageLayoutEnter 320ms cubic-bezier(0.16, 1, 0.3, 1) backwards"},children:[H(),A()]},T.pathname)},$l=h.memo(Kl),Rl={icon:"Cross",title:""},eo="calc(100vw - 16px)",Zt=r=>r==null?void 0:`min(${typeof r=="number"?`${r}px`:r}, ${eo})`,Gt=h.forwardRef(({onHide:r,show:t,withBlur:l=!1,style:n,children:o,closeButton:c=Rl,width:s,minWidth:i="357px",maxWidth:d="357px"},a)=>{const y=Zt(s??i),p=Zt(s??d);return e.jsx(vr.Drawer,{blur:l,isShow:t,position:"right",onHide:r,ref:a,style:{minWidth:y,maxWidth:p,...n},children:e.jsxs(u.Box,{direction:"column",padding:"lg",children:[c?e.jsxs(u.Box,{direction:"row",align:"center",gap:"sm",onClick:r,marginBottom:"lg",cursor:"pointer",children:[e.jsx(E.Icon,{name:c.icon,size:"md",color:"subtle",cursor:"pointer"}),c.title?e.jsx(S.Text,{fontFamily:"Poppins",fontSize:"md",color:"subtlest",children:c.title}):null]}):null,o]})})}),Xr=h.memo(({children:r,borderBottom:t=!0,padding:l=!0})=>{const n=ue.useMediaQuery("lg");return e.jsx(u.Box,{direction:"column",padding:l?"md":"spacing-0",paddingLeft:l?"md":"spacing-0",paddingRight:l?"md":"spacing-0",style:t?{borderBottom:"1px solid var(--sa-border-subtle, #0b120e24)"}:void 0,children:r})}),Kr=h.memo(({children:r,borderTop:t=!0,padding:l=!0})=>{const n=ue.useMediaQuery("lg");return e.jsx(u.Box,{direction:"column",padding:l?"md":"spacing-0",paddingLeft:l?"md":"spacing-0",paddingRight:l?"md":"spacing-0",style:t?{borderTop:"1px solid var(--sa-border-subtle, #0b120e24)"}:void 0,children:r})}),ro=h.memo(({children:r,...t})=>e.jsx(u.Box,{direction:"column",padding:"md",paddingLeft:"md",paddingRight:"md",gap:"md",...t,children:r})),to=h.memo(({children:r,title:t,titleTag:l,action:n,header:o,footer:c,actionContainer:s,containerProps:i,bodyProps:d,headerProps:a={borderBottom:!0},footerProps:y={borderTop:!0},variantTag:p="info"})=>{const b=ue.useMediaQuery("lg"),x=()=>l?e.jsxs(u.Box,{direction:"row",gap:"sm",align:"center",children:[e.jsx(S.Text,{fontWeight:"medium",children:t}),e.jsx(Ge.Badges,{border:!0,text:l,variant:p})]}):e.jsx(S.Text,{fontWeight:"medium",children:t}),T=()=>o||e.jsxs(u.Box,{direction:"row",justify:"space-between",align:"flex-start",gap:"md",children:[e.jsx(u.Box,{direction:"column",children:t?x():null}),e.jsx(u.Box,{direction:"column",style:b?{width:"100%",maxWidth:"19.313rem"}:{flex:1},...s,children:n??null})]}),v=!!(o||t||n);return e.jsxs(u.Box,{direction:"column",bg:"white",borderRadius:"rounded-xs",as:"section",borderWidth:"border",borderStyle:"border-solid",borderColor:"border-base",...i,style:{backgroundColor:"var(--sa-background-primary, #ffffff)",...(i==null?void 0:i.style)??{}},children:[o!==null&&v?e.jsx(Xr,{...a,children:T()}):null,e.jsx(ro,{...d,children:r}),c?e.jsx(Kr,{...y,children:c}):null]})}),We={H1:r=>e.jsx(S.Text,{variant:"h1",children:r.children,...r.props}),H2:r=>e.jsx(S.Text,{variant:"h2",children:r.children,...r.props}),H3:r=>e.jsx(S.Text,{variant:"h3",children:r.children,...r.props}),H4:r=>e.jsx(S.Text,{variant:"h4",children:r.children,...r.props}),H5:r=>e.jsx(S.Text,{variant:"h5",children:r.children,...r.props}),H6:r=>e.jsx(S.Text,{variant:"h6",children:r.children,...r.props}),SubH1:r=>e.jsx(S.Text,{variant:"sub-h1",children:r.children,...r.props}),SubH2:r=>e.jsx(S.Text,{variant:"sub-h2",children:r.children,...r.props}),SubH3:r=>e.jsx(S.Text,{variant:"sub-h3",children:r.children,...r.props}),Body1:r=>e.jsx(S.Text,{variant:"body-1",children:r.children,...r.props}),Body2:r=>e.jsx(S.Text,{variant:"body-2",children:r.children,...r.props}),Body3:r=>e.jsx(S.Text,{variant:"body-3",children:r.children,...r.props})},ke=()=>{const[r,t]=ye.useSearchParams(),l=lr.searchParamsToObject(r.toString()),n=ye.useParams(),o=ye.useLocation(),c=n.id;return{setSearchParams:t,searchParams:r,searchQueries:l,isHasQuery:(y,p)=>r.has(y)&&r.get(y)===p,getQueryParam:y=>r.get(y),getRouteParam:y=>n[y],params:n,location:o,id:c,hasId:!!c}},Qt=r=>JSON.stringify(r),Ut=r=>JSON.stringify(r),Jt=r=>JSON.stringify(r),Yt=r=>JSON.stringify(r),lo=r=>r,oo=r=>JSON.stringify(r),yr=({value:r,name:t,type:l,withSearchParam:n=!0,setSearchParams:o,searchQueries:c,dropdownSearchKey:s,filterKey:i="filter",pageKey:d="page"})=>{if(n){let a;switch(l){case"search":a=lo(r);break;case"dropdown":case"dropdown-multiple":a=Qt(r);break;case"radio":a=Ut(r);break;case"date-range":a=Jt(r);break;case"advanced-date-range":a=oo(r);break;case"date":a=Yt(r);break;default:a=r;break}if(typeof a<"u"){const p={...c[i]&&typeof c[i]=="string"?JSON.parse(c[i]):void 0,[t]:a},b={...c};s&&typeof s=="string"&&delete b[s],delete b[d];const x={...b,[i]:JSON.stringify(p)},T=new URLSearchParams(c).toString(),v=new URLSearchParams(x).toString();if(T===v)return;o(x)}}},Dr=({name:r,filterKey:t="filter",searchParams:l,get:n})=>{const o=l.get(t)||void 0,c=o&&typeof o=="string"?JSON.parse(o):void 0,s=c?c[r]:void 0;return n==="label"&&s?JSON.parse(s)[0].label:n==="value"&&s?JSON.parse(s)[0].value:s},Xt=({name:r,filterKey:t="filter",searchParams:l,get:n})=>{const o=l.get(t)||void 0,c=o&&typeof o=="string"?JSON.parse(o):void 0,s=c?c[r]:void 0;return n==="label"&&s?JSON.parse(s).map(i=>i.label):n==="value"&&s?JSON.parse(s).map(i=>i.value):n==="array"&&s?JSON.parse(s):s},no=({name:r,filterKey:t="filter",searchParams:l,get:n})=>{const o=l.get(t)||void 0,c=o&&typeof o=="string"?JSON.parse(o):void 0,s=c?c[r]:void 0;return n==="id"&&s?JSON.parse(s).id:n==="label"&&s?JSON.parse(s).label:n==="value"&&s?JSON.parse(s).value:s},Sr=(r,t,l)=>{const n=t.get(l||"filter")||void 0,o=n&&typeof n=="string"?JSON.parse(n):void 0;return o?o[r]:void 0},co=({name:r,filterKey:t="filter",searchParams:l})=>{const n=l.get(t||"filter")||void 0,o=n&&typeof n=="string"?JSON.parse(n):void 0,c=o?o[r]:void 0;return{start:c?JSON.parse(c).from:void 0,end:c?JSON.parse(c).to:void 0}},Kt=({name:r,filterKey:t="filter",searchParams:l})=>{const n=l.get(t||"filter")||void 0,o=n&&typeof n=="string"?JSON.parse(n):void 0,c=o?o[r]:void 0;return c?JSON.parse(c):void 0},io=(r,{filterKey:t="filter",perPageKey:l="perPage",pageKey:n="page"})=>{const o=r.get(t)||void 0,c=r.get(l)||void 0,s=r.get(n)||void 0;return!!o||!!c||!!s},$t=({isOpen:r,onClose:t,filterKey:l,pageKey:n,filters:o})=>{const{searchParams:c,setSearchParams:s,searchQueries:i}=ke(),[d,a]=h.useState({}),y=()=>{c.delete(l||"filter"),s(c)},p=(b,x)=>{switch(b.type){case"radio":{const{show:T=!0}=b;return T&&e.jsx(u.Box,{direction:"column",children:e.jsx(u.Box,{direction:"column",children:b.title})},x)}case"dropdown":{const{show:T=!0}=b;return T&&e.jsx(u.Box,{direction:"column",children:e.jsx(u.Box,{direction:"column",children:b.title})},x)}case"date-range":return e.jsx(u.Box,{direction:"column",children:e.jsx(u.Box,{direction:"column",children:b.title})},x);case"date":return e.jsx(u.Box,{direction:"column",children:e.jsx(u.Box,{direction:"column",children:b.title})},x);case"dropdown-multiple":{const{show:T=!0}=b;return T&&e.jsx(u.Box,{direction:"column",children:e.jsx(u.Box,{direction:"column",children:b.title})},x)}default:return null}};return e.jsx(Gt,{onHide:t,show:r||!1,children:e.jsxs(u.Box,{direction:"column",gap:"md",children:[e.jsxs(ne.Flex,{direction:"row",justify:"space-between",align:"center",children:[e.jsx(u.Box,{direction:"column",children:"Filter"}),e.jsx(u.Box,{direction:"column",style:{cursor:"pointer"},onClick:y,children:"Reset"})]}),o==null?void 0:o.map((b,x)=>p(b,x))]})})},Rt=({searchKey:r="q",statusKey:t="status",searchPlaceholder:l="Search",searchHighlightPlaceholder:n,extendedFilter:o,showSearchFilter:c=!0,showStatusFilter:s=!0,filterKey:i="filter",pageKey:d="page",customWidthSearch:a,handleOnReset:y,filterConfigs:p,buttonToggleProps:b,position:x="right",titleSearchLabel:T="Work Order",withTitleLabels:v=!1})=>{const L=(b==null?void 0:b.isShowLabel)??!0,[W,k]=h.useState(!1),[D,H]=h.useState(0),A=()=>{H(Y=>Y+1)},{searchParams:w,setSearchParams:m,getQueryParam:_}=ke(),V=lr.searchParamsToObject(w.toString()),q=Sr(r,w,i)||"",[J,le]=h.useState(q),ge=_(i),ie=!!(ge&&!(()=>{if(ge)try{const Y=JSON.parse(ge);return Object.keys(Y).length===1&&Y[r]===""}catch(Y){console.error("Filter parameter is not a valid JSON:",Y)}return!1})()),K=ue.useMediaQuery("md");return h.useEffect(()=>{le(q)},[q]),h.useEffect(()=>{if(J===q)return;const Y=window.setTimeout(()=>{yr({value:J,name:r,type:"search",searchQueries:V,setSearchParams:m,filterKey:i,pageKey:d})},350);return()=>{window.clearTimeout(Y)}},[J,q,r,V,m,i,d]),e.jsxs(ne.Flex,{gap:"md",style:{flexDirection:K&&x==="left"?"row":K&&x==="right"?"row-reverse":"column"},align:"flex-end",children:[ie&&e.jsx(u.Box,{direction:"column",justify:"flex-end",children:e.jsx(P.Button,{onClick:()=>{const Y=new URLSearchParams(w);Y.delete(i),m(Y),le(""),A(),y&&y()},variant:"outline",tone:"neutral",children:e.jsx(S.Text,{color:"error",fontWeight:"semibold",children:"Reset"})})}),o==null?void 0:o.map(({minWidth:Y,content:de,title:te,onClickContainer:ae},Be)=>e.jsxs(u.Box,{direction:"column",gap:"sm",onClick:ae,style:{minWidth:Y},children:[te&&e.jsx(We.SubH3,{children:te}),de]},`extended-filter-${Be}-${D}`)),!!(p!=null&&p.length)&&e.jsx(P.Button,{primary:ie,secondary:!ie,iconLeft:e.jsx(E.Icon,{size:"sm",name:(b==null?void 0:b.icon)||"FilterHorizontal",style:{color:ge?"var(--sa-background-brand, #04254f)":"var(--sa-text-primary, #292a2e)"}}),fullWidth:!K,onClick:()=>k(!0),children:L?"Filter":void 0}),s&&e.jsxs(u.Box,{direction:"column",gap:"sm",style:{minWidth:"126px"},children:[v&&e.jsx(We.SubH3,{children:"Status"}),e.jsx(tr.Dropdown,{dropdownLists:[{label:"Active",value:"active"},{label:"InActive",value:"inactive"}],defaultValue:Dr({get:"value",name:t,searchParams:w,filterKey:i})?[{label:Dr({get:"value",name:t,searchParams:w,filterKey:i})==="active"?"Active":"InActive",value:Dr({get:"value",name:t,searchParams:w,filterKey:i})}]:[],onChange:Y=>yr({value:Y,name:t,type:"dropdown",searchQueries:V,setSearchParams:m,filterKey:i}),placeholder:v?"All":"All Status"},D)]}),c&&e.jsxs(u.Box,{direction:"column",gap:"sm",style:{width:a&&K?a:K?"310px":""},children:[v&&e.jsxs(We.SubH3,{children:["Search for ",T]}),e.jsx(Qe.Input,{placeholder:l,leftIcon:e.jsx(E.Icon,{name:"Search",width:20,height:20}),onChange:Y=>le(Y.target.value),value:J,fullWidth:!0},D+1+i)]}),e.jsx($t,{isOpen:W,onClose:()=>k(!1),filterKey:i,filters:p,pageKey:d})]})},so=r=>r==="checkbox-multiple"?"dropdown-multiple":r==="radio"?"dropdown":r==="date-compact"?"date":r;function $r({configs:r,filterKey:t="filter",activeFilterKey:l="filters",pageKey:n="page",searchKey:o="q"}){const{searchParams:c,setSearchParams:s,searchQueries:i}=ke(),d=h.useMemo(()=>Object.fromEntries(r.map(D=>[D.key,D])),[r]),a=h.useMemo(()=>{const D=(c.get(l)||"").split(",").map(A=>A.trim()).filter(Boolean);let H=[];try{const A=c.get(t);A&&(H=Object.keys(JSON.parse(A)).filter(w=>w!==o))}catch{}return r.map(A=>A.key).filter(A=>{const w=d[A];return(w==null?void 0:w.locked)||D.includes(A)||H.includes(A)})},[c,l,t,o,r,d]),y=h.useCallback(D=>{try{return D[t]?JSON.parse(D[t]):{}}catch{return{}}},[t]),p=h.useCallback(D=>{const H={...i};D.length?H[l]=D.join(","):delete H[l],s(H)},[i,l,s]),b=h.useCallback(D=>{a.includes(D)||p([...a,D])},[a,p]),x=h.useCallback(D=>{var m;if((m=d[D])!=null&&m.locked)return;const H={...i},A=a.filter(_=>_!==D);A.length?H[l]=A.join(","):delete H[l];const w=y(H);D in w&&(delete w[D],Object.keys(w).length?H[t]=JSON.stringify(w):delete H[t]),delete H[n],s(H)},[i,a,l,t,n,y,s,d]),T=h.useCallback(D=>a.includes(D)?x(D):b(D),[a,b,x]),v=h.useCallback(D=>{switch(D.type){case"dropdown":case"dropdown-multiple":case"checkbox-multiple":case"radio":return Xt({name:D.key,get:"array",searchParams:c,filterKey:t})||[];case"date":{const H=Kt({name:D.key,searchParams:c,filterKey:t});return H?new Date(H):void 0}case"date-compact":{const A=y(Object.fromEntries(c.entries()))[D.key];return A&&typeof A=="object"?A:void 0}default:return}},[c,t,y]),B=h.useCallback((D,H)=>{if(D.type==="date-compact"){const A={...i},w=y(A);H==null?delete w[D.key]:w[D.key]=H,Object.keys(w).length?A[t]=JSON.stringify(w):delete A[t],delete A[n],s(A);return}yr({value:H,name:D.key,type:so(D.type),searchQueries:i,setSearchParams:s,filterKey:t,pageKey:n})},[i,s,t,n,y]),L=h.useCallback(D=>{const H={...i},A=y(H);D in A&&(delete A[D],Object.keys(A).length?H[t]=JSON.stringify(A):delete H[t]),delete H[n],s(H)},[i,t,n,y,s]),W=h.useCallback(()=>{const D={...i};delete D[t],delete D[l],delete D[n],s(D)},[i,t,l,n,s]),k=a.length>0;return{activeKeys:a,configByKey:d,hasActiveFilter:k,addFilter:b,removeFilter:x,toggleFilter:T,getValue:v,setValue:B,clearValue:L,clearAll:W}}const Rr={get(r){return gr.storage.get(r)??null},set(r,t){gr.storage.save(r,t)},remove(r){gr.storage.delete(r)}},ir={columns:r=>`filterbar:colprefs:${r}`,savedViews:r=>`filterbar:views:${r}`,lastState:r=>`filterbar:last:${r}`,perPage:r=>`filterbar:perpage:${r}`,tableSort:r=>`tablelayout:sort:${r}`},kr=(r,t)=>{const l=new Set(t.map(c=>c.key)),n=r.order.filter(c=>l.has(c));for(const c of t)n.includes(c.key)||n.push(c.key);const o=r.hidden.filter(c=>l.has(c));return{order:n,hidden:o}};function ao({columns:r,scopeId:t,storage:l,onColumnsChange:n,value:o}){const c=h.useMemo(()=>({order:r.map(w=>w.key),hidden:[]}),[r]),s=t?ir.columns(t):void 0,i=(w,m)=>kr({order:w.order??m,hidden:w.hidden??[]},r),[d,a]=h.useState(()=>{if(o&&(o.order||o.hidden))return i(o,r.map(w=>w.key));if(s){const w=l.get(s);if(w&&Array.isArray(w.order))return kr(w,r)}return c}),y=r.map(w=>w.key).join("|");h.useEffect(()=>a(w=>kr(w,r)),[y]);const p=h.useRef(d);p.current=d;const b=o?`${(o.order??[]).join("|")}~${(o.hidden??[]).join("|")}`:null,x=h.useRef(b);h.useEffect(()=>{if(b==null||x.current===b)return;x.current=b;const w=p.current,m=i(o,w.order);m.order.join("|")===w.order.join("|")&&m.hidden.join("|")===w.hidden.join("|")||(a(m),s&&l.set(s,m))},[b,y]);const T=h.useRef(!1);h.useEffect(()=>{T.current||(T.current=!0,n==null||n(d))},[]);const v=h.useCallback(w=>{a(w),s&&l.set(s,w),n==null||n(w)},[s,l,n]),B=h.useMemo(()=>{const w=new Map(r.map(m=>[m.key,m]));return d.order.filter(m=>w.has(m)).map(m=>({...w.get(m),visible:!d.hidden.includes(m)}))},[d,r]),L=h.useCallback(w=>{const m=d.hidden.includes(w)?d.hidden.filter(_=>_!==w):[...d.hidden,w];v({...d,hidden:m})},[d,v]),W=h.useCallback((w,m)=>{if(w===m)return;const _=[...d.order],[V]=_.splice(w,1);_.splice(m,0,V),v({...d,order:_})},[d,v]),k=h.useCallback(w=>{v({...d,hidden:w?r.filter(m=>!m.locked).map(m=>m.key):[]})},[d,r,v]),D=h.useCallback(()=>v(c),[v,c]),H=h.useCallback(w=>v(kr(w,r)),[v,r]),A=d.hidden.length===0;return{state:d,orderedColumns:B,allVisible:A,toggleVisibility:L,reorder:W,setAllHidden:k,reset:D,applyState:H}}function ho({scopeId:r,storage:t,snapshotKeys:l,pageKey:n="page",getColumns:o,applyColumns:c}){const{searchParams:s,setSearchParams:i}=ke(),d=r?ir.savedViews(r):void 0,[a,y]=h.useState(()=>d?t.get(d)||[]:[]),p=h.useCallback(v=>{y(v),d&&t.set(d,v)},[d]),b=h.useCallback(v=>{const B=v.trim();if(!B)return;const L={};l.forEach(k=>{const D=s.get(k);D!=null&&(L[k]=D)});const W={id:`${Date.now()}`,name:B,query:L,columns:o==null?void 0:o(),createdAt:Date.now()};p([...a,W])},[l,s,o,p,a]),x=h.useCallback(v=>p(a.filter(B=>B.id!==v)),[p,a]),T=h.useCallback(v=>{const B=Object.fromEntries(s.entries());l.forEach(L=>delete B[L]),Object.assign(B,v.query),delete B[n],i(B),v.columns&&(c==null||c(v.columns))},[s,l,n,i,c]);return{enabled:!!d,views:a,saveView:b,deleteView:x,applyView:T}}function fo({scopeId:r,storage:t,snapshotKeys:l,enabled:n=!0}){const{searchParams:o}=ke(),c=r&&n?ir.lastState(r):void 0,s=h.useRef(c);h.useEffect(()=>{if(!c){s.current=c;return}if(s.current!==c){s.current=c;return}const a={};l.forEach(y=>{const p=o.get(y);p!=null&&(a[y]=p)}),Object.keys(a).length!==0&&t.set(c,a)},[o,c,l,t]);const i=h.useCallback(()=>{if(!c)return null;const a=t.get(c);return a&&Object.keys(a).length>0?a:null},[c,t]),d=h.useCallback(()=>{c&&t.remove(c)},[c,t]);return{enabled:!!c,read:i,clear:d}}function go({scopeId:r,storage:t,perPageKey:l,pageSizeOptions:n,enabled:o=!0}){const{searchParams:c}=ke(),s=r&&o?ir.perPage(r):void 0,i=c.toString(),d=h.useRef(s);h.useEffect(()=>{if(!s){d.current=s;return}if(d.current!==s){d.current=s;return}const p=c.get(l);if(!p)return;const b=Number(p);!Number.isFinite(b)||b<=0||t.set(s,b)},[i,s,l,t]);const a=h.useCallback(()=>{if(!s)return null;const p=t.get(s);if(p==null)return null;const b=Number(p);return!Number.isFinite(b)||b<=0||n&&!n.includes(b)?null:String(b)},[s,t,n]),y=h.useCallback(()=>{s&&t.remove(s)},[s,t]);return{enabled:!!s,read:a,clear:y}}let et={},rt=!1,tt=null;const uo=(r,t)=>{Object.assign(et,r),tt=t,!rt&&(rt=!0,queueMicrotask(()=>{const l=et,n=tt;et={},rt=!1,tt=null,!(!n||Object.keys(l).length===0)&&n(o=>{const c=new URLSearchParams(o);return Object.entries(l).forEach(([s,i])=>c.set(s,i)),c})}))};function yo({enabled:r,snapshotKeys:t,perPageKey:l,readSnapshot:n,readPerPage:o}){const{searchParams:c,setSearchParams:s,location:i}=ke(),d=h.useRef(null);h.useEffect(()=>{if(!r||d.current===i.pathname)return;d.current=i.pathname;const a={};if(!c.has(l)){const y=o();y&&(a[l]=y)}if(!t.some(y=>c.has(y))){const y=n();y&&Object.assign(a,y)}Object.keys(a).length!==0&&uo(a,s)},[i.pathname,r])}const po=({configs:r,activeKeys:t,onToggle:l,hasActiveFilter:n,onReset:o})=>r.length?e.jsxs(O.Menu,{position:"bottom-left",children:[e.jsx(O.MenuButton,{children:e.jsx(P.Button,{variant:n?"secondary":"outline",tone:"neutral",size:"sm",iconLeft:e.jsx(E.Icon,{name:"FilterHorizontal"}),"aria-label":"Add filter"})}),e.jsx(O.MenuLists,{children:e.jsx(O.MenuBody,{style:{minWidth:260},title:e.jsxs(u.Box,{display:"flex",direction:"row",align:"center",justify:"space-between",fullWidth:!0,children:[e.jsx(S.Text,{fontSize:"sm",fontWeight:"medium",color:"subtlest",children:"Add Filter"}),n&&o&&e.jsx(P.Button,{variant:"link",tone:"brand",size:"xs",onClick:o,children:"Reset"})]}),children:r.map(c=>e.jsx(O.MenuItem,{selected:c.locked||t.includes(c.key),disabled:c.locked,closeOnSelect:!1,startIcon:c.icon??void 0,onClick:()=>{c.locked||l(c.key)},children:c.label},c.key))})})]}):null,Br=({onClear:r,onRemove:t})=>e.jsxs(O.Menu,{position:"bottom-right",children:[e.jsx(O.MenuButton,{children:e.jsx(P.Button,{variant:"link",tone:"neutral",size:"xs",iconLeft:e.jsx(E.Icon,{name:"MenuHorizontal"}),"aria-label":"Filter actions"})}),e.jsx(O.MenuLists,{children:e.jsxs(O.MenuBody,{style:{width:180},children:[e.jsx(O.MenuItem,{startIcon:e.jsx(E.Icon,{name:"CrossCircle"}),onClick:r,children:"Clear value"}),t&&e.jsx(O.MenuItem,{intent:"danger",startIcon:e.jsx(E.Icon,{name:"Trash1"}),onClick:t,children:"Remove filter"})]})})]}),bo=r=>{const t=new Date(r);return t.setHours(0,0,0,0),t},el=(r,t,l)=>{const n=new Date(r);return l==="day"?n.setDate(n.getDate()+t):l==="week"?n.setDate(n.getDate()+t*7):l==="month"?n.setMonth(n.getMonth()+t):n.setFullYear(n.getFullYear()+t),n},rl=r=>{const t=bo(new Date);if(r.direction==="this"){const n=new Date(t),o=new Date(t);return r.period==="week"?(n.setDate(t.getDate()-t.getDay()),o.setDate(n.getDate()+6)):r.period==="month"?(n.setDate(1),o.setMonth(o.getMonth()+1,0)):r.period==="year"&&(n.setMonth(0,1),o.setMonth(11,31)),{from:n,to:o}}const l=r.count??1;return r.direction==="past"?{from:el(t,-l,r.period),to:t}:{from:t,to:el(t,l,r.period)}},tl=24,ll=r=>r.length>tl?`${r.slice(0,tl)}...`:r,mr=r=>r.toLocaleDateString(void 0,{day:"2-digit",month:"short",year:"numeric"}),Fr={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"},vo=["is","is-before","is-after","is-on-or-before","is-on-or-after","is-between","is-relative-to-today","is-empty","is-not-empty"],lt={past:"Past",next:"Next",this:"This"},Co=["day","week","month","year"],xo=["past","next","this"],wo=r=>r.field.type==="date-compact"?e.jsx(ko,{field:r.field,value:r.value,onChange:r.onChange,onClear:r.onClear,onRemove:r.onRemove}):e.jsx(Do,{field:r.field,value:r.value,onChange:r.onChange,onClear:r.onClear,onRemove:r.onRemove}),Do=({field:r,value:t,onChange:l,onClear:n,onRemove:o})=>{const c=t?mr(new Date(t)):null,s=!!c,i=s?e.jsxs(e.Fragment,{children:[e.jsxs("span",{style:{fontWeight:500},children:[r.label,":"]})," ",e.jsx("span",{style:{fontWeight:400},children:ll(c)})]}):r.label;return e.jsxs(O.Menu,{position:"bottom-left",children:[e.jsx(O.MenuButton,{children:e.jsx(P.Button,{variant:s?"secondary":"outline",tone:"neutral",size:"sm",iconLeft:s?e.jsx(E.Icon,{name:"Calendar",size:"sm"}):void 0,iconRight:e.jsx(E.Icon,{name:"ChevronSmallDown"}),children:i})}),e.jsx(O.MenuLists,{children:e.jsx(O.MenuBody,{style:{width:260},title:e.jsxs(u.Box,{display:"flex",direction:"row",align:"center",justify:"space-between",fullWidth:!0,children:[e.jsx(S.Text,{fontSize:"sm",fontWeight:"medium",color:"subtlest",children:r.label}),e.jsx(Br,{onClear:n,onRemove:o})]}),children:e.jsx(Ue.StarasiaDate,{size:"sm",input:!1,clearable:!0,filter:r.mode,value:t,onChange:d=>d==null?n():l(d),withPadding:!1})})})]})},So=r=>{switch(r.op){case"is":case"is-before":case"is-after":case"is-on-or-before":case"is-on-or-after":return r.date?`${Fr[r.op]} ${mr(new Date(r.date))}`:null;case"is-between":return r.from&&r.to?`${mr(new Date(r.from))} - ${mr(new Date(r.to))}`:null;case"is-relative-to-today":{const t=r.relative;if(!t)return null;if(t.direction==="this")return`This ${t.period}`;const l=t.count??1,n=l===1?t.period:`${t.period}s`;return`${lt[t.direction]} ${l} ${n}`}case"is-empty":case"is-not-empty":return Fr[r.op];default:return null}},ko=({field:r,value:t,onChange:l,onClear:n,onRemove:o})=>{const c=(t==null?void 0:t.op)??"is",s=t?So(t):null,i=!!s,d=i?e.jsxs(e.Fragment,{children:[e.jsxs("span",{style:{fontWeight:500},children:[r.label,":"]})," ",e.jsx("span",{style:{fontWeight:400},children:ll(s)})]}):r.label,a=y=>{if(y!==c){if(y==="is-empty"||y==="is-not-empty"){l({op:y});return}if(y==="is-relative-to-today"){l({op:y,relative:(t==null?void 0:t.relative)??{direction:"past",count:1,period:"week"}});return}if(y==="is-between"){l({op:y,from:t==null?void 0:t.from,to:t==null?void 0:t.to});return}l({op:y,date:t==null?void 0:t.date})}};return e.jsxs(O.Menu,{position:"bottom-left",children:[e.jsx(O.MenuButton,{children:e.jsx(P.Button,{variant:i?"secondary":"outline",tone:"neutral",size:"sm",iconLeft:i?e.jsx(E.Icon,{name:"Calendar",size:"sm"}):void 0,iconRight:e.jsx(E.Icon,{name:"ChevronSmallDown"}),children:d})}),e.jsxs(O.MenuLists,{children:[e.jsx(O.MenuBody,{style:{width:320},title:e.jsxs(u.Box,{display:"flex",direction:"row",align:"center",justify:"space-between",gap:"xs",fullWidth:!0,children:[e.jsxs(u.Box,{display:"flex",direction:"row",align:"center",gap:"xs",style:{minWidth:0},children:[e.jsx(S.Text,{fontSize:"sm",fontWeight:"medium",color:"subtlest",children:r.label}),e.jsx(Bo,{op:c,onChange:a})]}),e.jsx(Br,{onClear:n,onRemove:o})]}),children:e.jsx(mo,{value:t,op:c,onChange:l})}),c==="is-relative-to-today"&&e.jsx(O.MenuFooter,{children:e.jsx(S.Text,{fontSize:"xs",color:"subtlest",children:"Filter will update with the current date"})})]})]})},Bo=({op:r,onChange:t})=>e.jsxs(O.Menu,{position:"bottom-left",children:[e.jsx(O.MenuButton,{children:e.jsx(P.Button,{variant:"link",tone:"neutral",size:"xs",iconRight:e.jsx(E.Icon,{name:"ChevronSmallDown"}),children:Fr[r]})}),e.jsx(O.MenuLists,{children:e.jsx(O.MenuBody,{style:{width:200},children:vo.map(l=>e.jsx(O.MenuItem,{selected:r===l,onClick:()=>t(l),endIcon:r===l?e.jsx(E.Icon,{name:"Check"}):void 0,children:Fr[l]},l))})})]}),mo=({value:r,op:t,onChange:l})=>{if(t==="is-empty"||t==="is-not-empty")return e.jsx(u.Box,{paddingBlock:"sm",paddingInline:"sm",children:e.jsx(S.Text,{fontSize:"xs",color:"subtlest",children:"No further input required."})});if(t==="is-between"){const n=r!=null&&r.from||r!=null&&r.to?{from:r!=null&&r.from?new Date(r.from):null,to:r!=null&&r.to?new Date(r.to):null}:void 0;return e.jsx(Ue.StarasiaDate,{size:"sm",input:!1,clearable:!0,rangedDate:!0,value:n,onChange:o=>{if(o==null){l({op:t});return}if(typeof o=="object"&&o!==null&&"from"in o&&"to"in o){let{from:c,to:s}=o;if(!c&&s&&(c=s,s=null),!c&&!s){l({op:t});return}l({op:t,from:c?c.toISOString():void 0,to:s?s.toISOString():void 0})}},withPadding:!1},"range")}return t==="is-relative-to-today"?e.jsx(Fo,{value:r==null?void 0:r.relative,onChange:n=>l({op:t,relative:n})}):e.jsx(Ue.StarasiaDate,{size:"sm",input:!1,clearable:!0,value:r!=null&&r.date?new Date(r.date):void 0,onChange:n=>{if(n==null){l({op:t});return}n instanceof Date&&l({op:t,date:n.toISOString()})},withPadding:!1},"single")},Fo=({value:r,onChange:t})=>{const l=(r==null?void 0:r.direction)??"past",n=(r==null?void 0:r.count)??1,o=(r==null?void 0:r.period)??"week",c=l!=="this",s=rl({direction:l,count:n,period:o});return e.jsxs(u.Box,{direction:"column",display:"flex",gap:"sm",children:[e.jsxs(u.Box,{direction:"row",display:"flex",align:"center",gap:"xs",children:[e.jsxs(O.Menu,{position:"bottom-left",children:[e.jsx(O.MenuButton,{children:e.jsx(P.Button,{variant:"outline",tone:"neutral",size:"sm",iconRight:e.jsx(E.Icon,{name:"ChevronSmallDown"}),children:lt[l]})}),e.jsx(O.MenuLists,{children:e.jsx(O.MenuBody,{style:{width:140},children:xo.map(i=>e.jsx(O.MenuItem,{selected:l===i,endIcon:l===i?e.jsx(E.Icon,{name:"Check"}):void 0,onClick:()=>t(i==="this"?{direction:i,period:o}:{direction:i,count:n,period:o}),children:lt[i]},i))})})]}),c&&e.jsx(Qe.Input,{type:"number",size:"sm",min:1,clearable:!1,value:n,onChange:i=>{const d=Number(i.target.value);t({direction:l,count:Number.isFinite(d)&&d>0?d:1,period:o})},style:{width:72}}),e.jsxs(O.Menu,{position:"bottom-left",children:[e.jsx(O.MenuButton,{children:e.jsx(P.Button,{variant:"outline",tone:"neutral",size:"sm",iconRight:e.jsx(E.Icon,{name:"ChevronSmallDown"}),children:o})}),e.jsx(O.MenuLists,{children:e.jsx(O.MenuBody,{style:{width:140},children:Co.map(i=>e.jsx(O.MenuItem,{selected:o===i,endIcon:o===i?e.jsx(E.Icon,{name:"Check"}):void 0,onClick:()=>t(l==="this"?{direction:l,period:i}:{direction:l,count:n,period:i}),children:i},i))})})]})]}),e.jsx(Ue.StarasiaDate,{size:"sm",input:!1,disabled:!0,rangedDate:!0,value:s,onChange:()=>{},withPadding:!1},"relative-preview")]})},ol=18,Eo=r=>r.length>ol?`${r.slice(0,ol)}...`:r,Mo=({field:r,value:t,onChange:l,onClear:n,onRemove:o})=>{const c=r.type==="dropdown-multiple",s=t.length,[i,d]=h.useState(""),a=r.options,y=typeof r.onSearch=="function",p=(()=>{if(y)return a;const B=i.trim().toLowerCase();return B?a.filter(L=>L.label.toLowerCase().includes(B)):a})(),b=B=>t.some(L=>L.value===B.value),x=B=>{if(!c){l([{label:B.label,value:B.value}]),d("");return}l(b(B)?t.filter(L=>L.value!==B.value):[...t,{label:B.label,value:B.value}])},T=B=>{var L;d(B),(L=r.onSearch)==null||L.call(r,B)},v=s===0?r.label:e.jsxs(e.Fragment,{children:[e.jsxs("span",{style:{fontWeight:500},children:[r.label,":"]})," ",e.jsx("span",{style:{fontWeight:400},children:s===1?Eo(t[0].label):`${s} Selected`})]});return e.jsxs(O.Menu,{position:"bottom-left",children:[e.jsx(O.MenuButton,{children:e.jsx(P.Button,{variant:s>0?"secondary":"outline",tone:"neutral",size:"sm",iconLeft:s>0?e.jsx(E.Icon,{name:"Tag",size:"sm"}):void 0,iconRight:e.jsx(E.Icon,{name:"ChevronSmallDown"}),children:v})}),e.jsx(O.MenuLists,{children:e.jsx(O.MenuBody,{style:{width:260},title:e.jsxs(u.Box,{display:"flex",direction:"row",align:"center",justify:"space-between",fullWidth:!0,children:[e.jsx(S.Text,{fontSize:"sm",fontWeight:"medium",color:"subtlest",children:r.label}),e.jsx(Br,{onClear:n,onRemove:o})]}),children:e.jsxs(u.Box,{direction:"column",gap:"sm",children:[e.jsx(tr.Dropdown,{size:"sm",triggerInput:!0,fullWidth:!0,hideChevronIcon:!0,clearable:!0,multiSelect:c,searchAble:!0,searchValue:i,onSearch:T,value:t,onChange:l,placeholder:`Search ${r.label.toLowerCase()}…`}),e.jsx(u.Box,{direction:"column",overflow:"overflow-y-auto",customMaxHeight:"240px",children:r.isLoading?e.jsx(u.Box,{paddingBlock:"sm",paddingInline:"sm",children:e.jsx(S.Text,{fontSize:"xs",color:"subtlest",children:"Loading…"})}):p.length===0?e.jsx(u.Box,{paddingBlock:"sm",paddingInline:"sm",children:e.jsx(S.Text,{fontSize:"xs",color:"subtlest",children:"No results"})}):p.map(B=>e.jsx(O.MenuItem,{closeOnSelect:!c,selected:b(B),startIcon:B.avatar,endIcon:b(B)?e.jsx(E.Icon,{name:"Check"}):void 0,description:B.description,onClick:()=>x(B),children:B.label},B.value))})]})})})]})},nl=18,Lo=r=>r.length>nl?`${r.slice(0,nl)}...`:r,cl=({checked:r,indeterminate:t})=>e.jsx("span",{style:{pointerEvents:"none",display:"inline-flex"},children:e.jsx(cr.Checkbox,{size:"sm",checked:r,readOnly:!0,onChange:()=>{},variant:t?"indeterminate":"select"})}),To=({field:r,value:t,onChange:l,onClear:n,onRemove:o})=>{const c=new Set(t.map(b=>b.value)),s=t.length,i=r.options.length>0&&r.options.every(b=>c.has(b.value)),d=s>0&&!i,a=b=>{l(c.has(b.value)?t.filter(x=>x.value!==b.value):[...t,{label:b.label,value:b.value}])},y=()=>{l(i?[]:r.options.map(b=>({label:b.label,value:b.value})))},p=s===0?r.label:e.jsxs(e.Fragment,{children:[e.jsxs(S.Text,{as:"span",fontWeight:"semibold",children:[r.label,":"]})," ",e.jsx(S.Text,{as:"span",children:s===1?Lo(t[0].label):`${s} Selected`})]});return e.jsxs(O.Menu,{position:"bottom-left",children:[e.jsx(O.MenuButton,{children:e.jsx(P.Button,{variant:s>0?"secondary":"outline",tone:"neutral",size:"sm",iconLeft:s>0?e.jsx(E.Icon,{name:"Tag",size:"sm"}):void 0,iconRight:e.jsx(E.Icon,{name:"ChevronSmallDown"}),children:p})}),e.jsx(O.MenuLists,{children:e.jsxs(O.MenuBody,{style:{width:240},title:e.jsxs(u.Box,{display:"flex",direction:"row",align:"center",justify:"space-between",fullWidth:!0,children:[e.jsx(S.Text,{fontSize:"sm",fontWeight:"medium",color:"subtlest",children:r.label}),e.jsx(Br,{onClear:n,onRemove:o})]}),children:[e.jsx(O.MenuItem,{closeOnSelect:!1,selected:i,onClick:y,startIcon:e.jsx(cl,{checked:i||d,indeterminate:d}),children:"Select All"}),r.options.map(b=>e.jsx(O.MenuItem,{closeOnSelect:!1,selected:c.has(b.value),onClick:()=>a(b),startIcon:e.jsx(cl,{checked:c.has(b.value)}),children:b.label},b.value))]})})]})},il=({activeKeys:r,configByKey:t,getValue:l,setValue:n,clearValue:o,removeFilter:c})=>e.jsx(e.Fragment,{children:r.map(s=>{const i=t[s];if(!i)return null;const d=l(i),a=i.locked?void 0:()=>c(s);return i.type==="date"||i.type==="date-compact"?e.jsx(wo,{field:i,value:d,onChange:y=>n(i,y),onClear:()=>o(s),onRemove:a},s):i.type==="checkbox-multiple"?e.jsx(To,{field:i,value:d||[],onChange:y=>n(i,y),onClear:()=>o(s),onRemove:a},s):e.jsx(Mo,{field:i,value:d||[],onChange:y=>n(i,y),onClear:()=>o(s),onRemove:a},s)})}),sl=r=>`${r} Rows`,Io=({pagination:r,pageKey:t="page",perPageKey:l="perPage",pageSizeOptions:n=[10,25,50,100],defaultPerPage:o=10,showResultCount:c=!0,showPageSize:s=!0,showPagination:i=!0})=>{var L;const{searchQueries:d,setSearchParams:a,searchParams:y}=ke(),p=y.get(l),b=p?Number(p):o,x=W=>{a({...d,[t]:String(W)})},T=W=>{a({...d,[l]:W,[t]:"1"})},v=(r==null?void 0:r.rangeStart)??(((r==null?void 0:r.currentPage)||0)>1?(((r==null?void 0:r.currentPage)||0)-1)*((r==null?void 0:r.perPage)||0)+1:0),B=(r==null?void 0:r.rangeEnd)??((r==null?void 0:r.totalCurrentPage)!==(r==null?void 0:r.perPage)?r==null?void 0:r.totalData:((r==null?void 0:r.currentPage)||1)*((r==null?void 0:r.totalCurrentPage)||0));return e.jsxs(e.Fragment,{children:[c&&e.jsx(S.Text,{fontSize:"sm",fontWeight:"medium",color:"primary",truncate:!0,children:`${v}-${B} of ${((L=r==null?void 0:r.totalData)==null?void 0:L.toLocaleString())||0}`}),s&&e.jsxs(O.Menu,{position:"bottom-left",children:[e.jsx(O.MenuButton,{children:e.jsx(P.Button,{variant:"outline",tone:"neutral",size:"sm",iconRight:e.jsx(E.Icon,{name:"ChevronSmallDown"}),"aria-label":"Rows per page",children:sl(b)})}),e.jsx(O.MenuLists,{children:e.jsx(O.MenuBody,{children:n.map(W=>e.jsx(O.MenuItem,{selected:W===b,onClick:()=>T(String(W)),children:sl(W)},W))})})]}),i&&((r==null?void 0:r.totalPage)??0)>1&&e.jsx(u.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(fr.Pagination,{size:"sm",variant:"neutral",siblingCount:0,currentPage:r!=null&&r.currentPage?Number(r.currentPage):1,totalPages:Number(r==null?void 0:r.totalPage),onPageChange:x})})]})};function Oo(r,t,l=!0){h.useEffect(()=>{if(!l)return;const n=o=>{var i;if(o.metaKey||o.ctrlKey||o.altKey||o.key!==r)return;const c=o.target,s=(i=c==null?void 0:c.tagName)==null?void 0:i.toLowerCase();s==="input"||s==="textarea"||c!=null&&c.isContentEditable||(o.preventDefault(),t())};return window.addEventListener("keydown",n),()=>window.removeEventListener("keydown",n)},[r,t,l])}const Wo=240,al=({searchKey:r="q",filterKey:t="filter",pageKey:l="page",placeholder:n="Search",shortcut:o="/",collapsible:c=!0})=>{const{searchParams:s,setSearchParams:i,searchQueries:d}=ke(),a=Sr(r,s,t)||"",[y,p]=h.useState(!c||!!a),[b,x]=h.useState(c&&!a),[T,v]=h.useState(a),B=ue.useDebounce(T,350),L=h.useRef(null);h.useEffect(()=>{v(a),a&&p(!0)},[a]),h.useEffect(()=>{y&&x(!1)},[y]),h.useEffect(()=>{B!==a&&yr({value:B,name:r,type:"search",searchQueries:d,setSearchParams:i,filterKey:t,pageKey:l})},[B]);const W=h.useCallback(()=>{p(!0),requestAnimationFrame(()=>{var A;return(A=L.current)==null?void 0:A.focus()})},[]);Oo(o,W);const k=()=>{c&&!T&&p(!1)},D=A=>{var w;c&&A.key==="Escape"&&!T&&(p(!1),(w=L.current)==null||w.blur())},H=()=>{y||x(!0)};return e.jsxs(u.Box,{display:"flex",direction:"row",align:"center",gap:"spacing-0",children:[b&&e.jsx(P.Button,{variant:"outline",tone:"neutral",size:"sm",iconLeft:e.jsx(E.Icon,{name:"Search",size:"sm"}),"aria-label":"Search","aria-expanded":!1,onClick:W}),e.jsxs(u.Box,{onTransitionEnd:H,style:{position:"relative",width:y?Wo:0,overflow:"hidden",transition:"width 220ms ease"},children:[e.jsx(Qe.Input,{ref:L,size:"sm",fullWidth:!0,value:T,placeholder:n,leftIcon:e.jsx(E.Icon,{name:"Search",width:16,height:16}),onChange:A=>v(A.target.value),onKeyDown:D,onBlur:k,tabIndex:y?0:-1}),y&&!T&&e.jsx(u.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(S.Text,{fontSize:"xs",color:"subtle",children:o})})]})]})},dl=({columns:r,allVisible:t,onToggle:l,onReorder:n,onSetAllHidden:o})=>{const[c,s]=h.useState(null),[i,d]=h.useState(null),a=()=>{c!==null&&i!==null&&c!==i&&n(c,i),s(null),d(null)},y=(p,b)=>{const x=p+b;x<0||x>=r.length||n(p,x)};return e.jsxs(O.Menu,{position:"bottom-right",children:[e.jsx(O.MenuButton,{children:e.jsx(P.Button,{variant:t?"outline":"secondary",tone:"neutral",size:"sm",iconLeft:e.jsx(E.Icon,{name:"Grid",size:"sm"}),"aria-label":"Customize columns"})}),e.jsx(O.MenuLists,{children:e.jsx(O.MenuBody,{children:e.jsxs(u.Box,{padding:"sm",direction:"column",customWidth:"296px",customMaxHeight:"60vh",overflow:"overflow-hidden",children:[e.jsx(S.Text,{fontWeight:"semibold",color:"primary",children:"Customize Column Table"}),e.jsxs(u.Box,{direction:"row",display:"flex",align:"center",justify:"space-between",paddingBlock:"md",children:[e.jsx(S.Text,{fontSize:"sm",fontWeight:"medium",color:"subtle",children:"Show in table"}),e.jsx(P.Button,{variant:"link",tone:"info",size:"xs",onClick:()=>o(t),children:t?"Hide All":"Show All"})]}),e.jsx(u.Box,{direction:"column",overflow:"overflow-y-auto",children:r.map((p,b)=>{const x=!p.locked,T=i===b&&c!==null&&c!==b;return e.jsxs(u.Box,{direction:"row",display:"flex",align:"center",gap:"sm",paddingBlock:"xs",draggable:x,onDragStart:()=>x&&s(b),onDragOver:v=>{v.preventDefault(),d(b)},onDrop:a,onDragEnd:a,style:{minHeight:32,boxShadow:T?"inset 0 2px 0 0 var(--sa-background-brand, #04254f)":void 0},children:[e.jsx(u.Box,{direction:"column",as:"div",align:"center",justify:"center",role:"button",tabIndex:x?0:-1,"aria-label":`Reorder ${p.title}`,"aria-disabled":!x||void 0,color:"icon-subtlest",onKeyDown:v=>{x&&(v.key==="ArrowUp"?(v.preventDefault(),y(b,-1)):v.key==="ArrowDown"&&(v.preventDefault(),y(b,1)))},style:{display:"inline-flex",cursor:x?"grab":"default",opacity:x?1:.4},children:e.jsx(E.Icon,{name:"DragVertical",width:16,height:16})}),p.icon&&e.jsx(u.Box,{direction:"column",align:"center",color:"icon-subtle",style:{display:"inline-flex"},children:p.icon}),e.jsx(S.Text,{fontSize:"sm",fontWeight:"medium",color:"primary",truncate:!0,children:p.title}),e.jsx(u.Box,{direction:"column",style:{marginLeft:"auto"},children:e.jsx(nr.Toggle,{size:"sm",checked:p.visible,disabled:p.locked,onChange:()=>l(p.key),"aria-label":`Toggle ${p.title} column`})})]},p.key)})})]})})})]})},hl=({views:r,onApply:t,onDelete:l,onSave:n})=>{const[o,c]=h.useState(""),s=()=>{const i=o.trim();i&&(n(i),c(""))};return e.jsxs(O.Menu,{position:"bottom-right",children:[e.jsx(O.MenuButton,{children:e.jsx(P.Button,{variant:r.length>0?"secondary":"outline",tone:(r.length>0,"neutral"),size:"sm",iconLeft:e.jsx(E.Icon,{name:"Bookmark",size:"sm"}),"aria-label":"Saved views"})}),e.jsxs(O.MenuLists,{style:{width:"260px"},children:[e.jsx(O.MenuBody,{children:e.jsxs(u.Box,{direction:"column",padding:"xs",gap:"sm",children:[e.jsx(S.Text,{fontWeight:"semibold",color:"primary",children:"Saved Views"}),e.jsx(u.Box,{direction:"column",overflow:"overflow-y-auto",children:r.length===0?e.jsx(u.Box,{direction:"column",paddingBlock:"sm",children:e.jsx(S.Text,{fontSize:"sm",color:"subtlest",children:"No saved views yet"})}):r.map(i=>e.jsx(O.MenuItem,{startIcon:e.jsx(E.Icon,{name:"Bookmark"}),onClick:()=>t(i),endIcon:e.jsx(P.Button,{variant:"link",tone:"error",size:"sm",iconLeft:e.jsx(E.Icon,{name:"Trash2"}),"aria-label":`Delete ${i.name}`,onClick:d=>{d.stopPropagation(),l(i.id)}}),children:i.name},i.id))})]})}),e.jsx(O.MenuFooter,{children:e.jsxs(u.Box,{direction:"row",gap:"xs",children:[e.jsx(u.Box,{direction:"column",style:{flex:"1 0 0",minWidth:0},children:e.jsx(Qe.Input,{size:"sm",fullWidth:!0,placeholder:"Save current view as…",value:o,onChange:i=>c(i.target.value),onKeyDown:i=>{i.key==="Enter"&&s()}})}),e.jsx(P.Button,{variant:"primary",tone:"brand",size:"sm",disabled:!o.trim(),onClick:s,children:"Save"})]})})]})]})},Ao=({isOpen:r,onClose:t,configs:l,activeKeys:n,configByKey:o,hasActiveFilter:c,onToggle:s,onReset:i,getValue:d,setValue:a,clearValue:y,removeFilter:p})=>{const b=n.length;return e.jsx(vr.Drawer,{position:"bottom",isShow:r,onHide:t,children:e.jsxs(u.Box,{direction:"column",customMaxHeight:"85vh",style:{minHeight:280},children:[e.jsxs(u.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(u.Box,{direction:"row",display:"flex",align:"center",gap:"xs",children:[e.jsx(S.Text,{fontWeight:"semibold",color:"primary",children:"Filter"}),b>0&&e.jsxs(S.Text,{fontSize:"sm",color:"subtle",children:["(",b,")"]})]}),e.jsx(P.Button,{variant:"link",tone:"neutral",size:"sm",iconLeft:e.jsx(E.Icon,{name:"Cross"}),"aria-label":"Close filter",onClick:t})]}),e.jsxs(u.Box,{direction:"column",gap:"lg",padding:"md",overflow:"overflow-y-auto",style:{flex:"1 1 auto",minHeight:0},children:[b>0&&e.jsxs(u.Box,{direction:"column",gap:"sm",children:[e.jsx(S.Text,{fontSize:"xs",fontWeight:"medium",color:"subtlest",children:"Filter aktif"}),e.jsx(u.Box,{direction:"row",display:"flex",wrap:"wrap",gap:"sm",align:"center",children:e.jsx(il,{activeKeys:n,configByKey:o,getValue:d,setValue:a,clearValue:y,removeFilter:p})})]}),l.length>0&&e.jsxs(u.Box,{direction:"column",gap:"sm",children:[e.jsx(S.Text,{fontSize:"xs",fontWeight:"medium",color:"subtlest",children:"Tambah filter"}),e.jsx(u.Box,{direction:"column",children:l.map(x=>{const T=n.includes(x.key),v=!!x.locked;return e.jsxs(u.Box,{direction:"row",display:"flex",align:"center",justify:"space-between",gap:"sm",paddingBlock:"sm",style:{opacity:v?.5:1,borderTop:"1px solid var(--sa-border-subtle, rgba(11, 18, 14, 0.08))"},children:[e.jsxs(u.Box,{direction:"row",display:"flex",align:"center",gap:"sm",style:{minWidth:0},children:[x.icon&&e.jsx(u.Box,{direction:"column",align:"center",color:"icon-subtle",style:{display:"inline-flex"},children:x.icon}),e.jsx(S.Text,{fontSize:"sm",color:"primary",truncate:!0,children:x.label})]}),e.jsx(nr.Toggle,{size:"sm",checked:T||v,disabled:v,onChange:()=>s(x.key),"aria-label":`Toggle ${x.label}`})]},x.key)})})]})]}),e.jsxs(u.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(u.Box,{direction:"column",style:{flex:"1 1 0"},children:e.jsx(P.Button,{variant:"outline",tone:"neutral",size:"md",fullWidth:!0,disabled:!c,onClick:i,children:"Reset"})}),e.jsx(u.Box,{direction:"column",style:{flex:"1 1 0"},children:e.jsx(P.Button,{variant:"primary",tone:"brand",size:"md",fullWidth:!0,onClick:t,children:"Selesai"})})]})]})})},zo=r=>`${r} Rows`,Ho=({perPageKey:r,pageKey:t,pageSizeOptions:l,defaultPerPage:n=10,showPageSize:o})=>{const{searchQueries:c,setSearchParams:s,searchParams:i}=ke(),d=i.get(r),a=d?Number(d):n,y=p=>{s({...c,[r]:p,[t]:"1"})};return o?e.jsxs(O.Menu,{position:"bottom-right",children:[e.jsx(O.MenuButton,{children:e.jsx(P.Button,{variant:"outline",tone:"neutral",size:"sm",iconLeft:e.jsx(E.Icon,{name:"MenuVertical",size:"sm"}),"aria-label":"More options"})}),e.jsx(O.MenuLists,{children:e.jsxs(O.MenuBody,{style:{minWidth:200},children:[e.jsx(u.Box,{paddingInline:"sm",paddingBlock:"xs",children:e.jsx(S.Text,{fontSize:"xs",fontWeight:"medium",color:"subtlest",children:"Rows per page"})}),l.map(p=>e.jsx(O.MenuItem,{selected:p===a,endIcon:p===a?e.jsx(E.Icon,{name:"Check"}):void 0,onClick:()=>y(String(p)),children:zo(p)},p))]})})]}):null},Vo=r=>{var ve;const{withPadding:t,configs:l,activeKeys:n,configByKey:o,hasActiveFilter:c,toggleFilter:s,removeFilter:i,getValue:d,setValue:a,clearValue:y,onReset:p,searchable:b,searchKey:x,filterKey:T,pageKey:v,searchPlaceholder:B,searchShortcut:L,searchCollapsible:W,pagination:k,perPageKey:D,pageSizeOptions:H,defaultPerPage:A,showPagination:w,showResultCount:m,showPageSize:_,hasColumns:V,orderedColumns:q,allVisible:J,onToggleVisibility:le,onReorder:ge,onSetAllHidden:oe,showSavedViews:ie,savedViews:K,onApplyView:Y,onDeleteView:de,onSaveView:te}=r,[ae,Be]=h.useState(!1),{searchQueries:Ne,setSearchParams:pe}=ke(),me=(k==null?void 0:k.rangeStart)??(((k==null?void 0:k.currentPage)||0)>1?(((k==null?void 0:k.currentPage)||0)-1)*((k==null?void 0:k.perPage)||0)+1:1),Te=(k==null?void 0:k.rangeEnd)??((k==null?void 0:k.totalCurrentPage)!==(k==null?void 0:k.perPage)?k==null?void 0:k.totalData:((k==null?void 0:k.currentPage)||1)*((k==null?void 0:k.totalCurrentPage)||0)),be=Le=>{pe({...Ne,[v]:String(Le)})},Ae=m||w&&!!(k!=null&&k.totalPage),Ze=()=>{p(),Be(!1)};return e.jsxs(u.Box,{direction:"column",gap:"sm",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(u.Box,{direction:"row",display:"flex",align:"center",wrap:"wrap",gap:"sm",fullWidth:!0,overflow:"overflow-auto",children:[b&&e.jsx(al,{searchKey:x,filterKey:T,pageKey:v,placeholder:B,shortcut:L,collapsible:W}),e.jsx(P.Button,{variant:c?"secondary":"outline",tone:"neutral",size:"sm",iconLeft:e.jsx(E.Icon,{name:"FilterHorizontal"}),onClick:()=>Be(!0),"aria-label":"Open filters",children:c?`Filter: ${n.length}`:null}),e.jsxs(u.Box,{direction:"row",display:"flex",align:"center",gap:"sm",style:{marginLeft:"auto"},children:[ie&&e.jsx(hl,{views:K,onApply:Y,onDelete:de,onSave:te}),V&&e.jsx(dl,{columns:q,allVisible:J,onToggle:le,onReorder:ge,onSetAllHidden:oe}),e.jsx(Ho,{perPageKey:D,pageKey:v,pageSizeOptions:H,defaultPerPage:A,showPageSize:_})]})]}),Ae&&e.jsxs(u.Box,{direction:"row",display:"flex",align:"center",justify:"space-between",gap:"sm",fullWidth:!0,children:[m?e.jsx(S.Text,{fontSize:"sm",fontWeight:"medium",color:"primary",truncate:!0,children:`${me}-${Te} of ${((ve=k==null?void 0:k.totalData)==null?void 0:ve.toLocaleString())||0}`}):e.jsx(u.Box,{direction:"column"}),w&&!!(k!=null&&k.totalPage)&&e.jsx(fr.Pagination,{size:"xs",variant:"neutral",siblingCount:0,currentPage:k!=null&&k.currentPage?Number(k.currentPage):1,totalPages:Number(k.totalPage),onPageChange:be})]}),e.jsx(Ao,{isOpen:ae,onClose:()=>Be(!1),configs:l,activeKeys:n,configByKey:o,hasActiveFilter:c,onToggle:s,onReset:Ze,getValue:d,setValue:a,clearValue:y,removeFilter:i})]})},jo=({withPadding:r=!1,filterConfigs:t=[],filterKey:l="filter",activeFilterKey:n="filters",pageKey:o="page",perPageKey:c="perPage",pageSizeOptions:s=[25,50,100],defaultPerPage:i,showPagination:d=!0,showResultCount:a=!0,showPageSize:y=!0,searchable:p=!1,searchKey:b="q",searchPlaceholder:x="Search",searchShortcut:T="/",searchPosition:v="right",searchCollapsible:B=!0,pagination:L,columns:W=[],onColumnsChange:k,columnsState:D,scopeId:H,savedViews:A,persistLastState:w=!0,storage:m=Rr,onReset:_})=>{const V=H??(A==null?void 0:A.scopeId),{activeKeys:q,configByKey:J,hasActiveFilter:le,toggleFilter:ge,removeFilter:oe,getValue:ie,setValue:K,clearValue:Y,clearAll:de}=$r({configs:t,filterKey:l,activeFilterKey:n,pageKey:o,searchKey:b}),te=ao({columns:W,scopeId:V,storage:m,onColumnsChange:k,value:D}),ae=ho({scopeId:V,storage:m,snapshotKeys:[n,l,c],pageKey:o,getColumns:()=>te.state,applyColumns:te.applyState}),Be=fo({scopeId:V,storage:m,snapshotKeys:[n,l,o],enabled:w}),Ne=go({scopeId:V,storage:m,perPageKey:c,pageSizeOptions:s,enabled:w});yo({enabled:w&&!!V,snapshotKeys:[n,l,o],perPageKey:c,readSnapshot:Be.read,readPerPage:Ne.read});const pe=i??s[0]??25,me=!!(A!=null&&A.enabled)&&ae.enabled,Te=()=>{de(),Be.clear(),_==null||_()},be=ue.useMediaQuery("md"),Ae=p?e.jsx(al,{searchKey:b,filterKey:l,pageKey:o,placeholder:x,shortcut:T,collapsible:B}):null;return be?e.jsxs(u.Box,{display:"flex",direction:"row",align:"center",gap:"sm",wrap:"wrap",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(u.Box,{direction:"row",display:"flex",align:"center",gap:"sm",style:{flex:"1 1 0",minWidth:0},children:[e.jsx(po,{configs:t,activeKeys:q,onToggle:ge,hasActiveFilter:le,onReset:Te}),v==="left"&&Ae,e.jsxs(u.Box,{direction:"row",display:"flex",align:"center",gap:"sm",overflow:"overflow-x-auto",style:{flex:"1 1 0",minWidth:0},children:[e.jsx(il,{activeKeys:q,configByKey:J,getValue:ie,setValue:K,clearValue:Y,removeFilter:oe}),le&&e.jsx(P.Button,{variant:"link",tone:"brand",size:"sm",onClick:Te,children:"Reset"})]})]}),e.jsxs(u.Box,{direction:"row",display:"flex",align:"center",gap:"sm",children:[e.jsx(Io,{pagination:L,pageKey:o,perPageKey:c,pageSizeOptions:s,defaultPerPage:pe,showPagination:d,showResultCount:a,showPageSize:y}),v==="right"&&Ae,me&&e.jsx(hl,{views:ae.views,onApply:ae.applyView,onDelete:ae.deleteView,onSave:ae.saveView}),W.length>0&&e.jsx(dl,{columns:te.orderedColumns,allVisible:te.allVisible,onToggle:te.toggleVisibility,onReorder:te.reorder,onSetAllHidden:te.setAllHidden})]})]}):e.jsx(Vo,{withPadding:r,configs:t,activeKeys:q,configByKey:J,hasActiveFilter:le,toggleFilter:ge,removeFilter:oe,getValue:ie,setValue:K,clearValue:Y,onReset:Te,searchable:p,searchKey:b,filterKey:l,pageKey:o,searchPlaceholder:x,searchShortcut:T,searchCollapsible:B,pagination:L,perPageKey:c,pageSizeOptions:s,defaultPerPage:pe,showPagination:d,showResultCount:a,showPageSize:y,hasColumns:W.length>0,orderedColumns:te.orderedColumns,allVisible:te.allVisible,onToggleVisibility:te.toggleVisibility,onReorder:te.reorder,onSetAllHidden:te.setAllHidden,showSavedViews:me,savedViews:ae.views,onApplyView:ae.applyView,onDeleteView:ae.deleteView,onSaveView:ae.saveView})},Po=r=>{if(!Array.isArray(r)||r.length===0)return;const t=r[0];return(t==null?void 0:t.value)!=null?String(t.value):void 0},No=r=>{if(!Array.isArray(r)||r.length===0)return;const t=r.map(l=>(l==null?void 0:l.value)!=null?String(l.value):null).filter(l=>l!=null);return t.length?t:void 0},_o=(r,t)=>{switch(r.type){case"dropdown":case"radio":return Po(t);case"dropdown-multiple":case"checkbox-multiple":return No(t);case"date":return t instanceof Date?t.toISOString():void 0;case"date-compact":return t;default:return}},fl=(r,t)=>{if(r==null||r==="")return t;const l=Number(r);return Number.isFinite(l)&&l>0?l:t},qo=r=>{const{filterConfigs:t,filterKey:l="filter",activeFilterKey:n="filters",pageKey:o="page",perPageKey:c="perPage",searchKey:s="q",defaultPage:i=1,defaultPerPage:d=10,paramKeys:a,serialize:y}=r,{activeKeys:p,configByKey:b,hasActiveFilter:x,getValue:T}=$r({configs:t,filterKey:l,activeFilterKey:n,pageKey:o,searchKey:s}),{searchParams:v}=ke(),B=v.toString();return h.useMemo(()=>{const W={},k={},D=fl(v.get(o),i),H=fl(v.get(c),d);W[(a==null?void 0:a.page)??"page"]=D,W[(a==null?void 0:a.perPage)??"perPage"]=H;const A=Sr(s,v,l)||"";A&&(W[(a==null?void 0:a.search)??"search"]=A);let w=!1;for(const m of p){const _=b[m];if(!_)continue;const V=T(_);k[m]=V;const q=y==null?void 0:y[m],J=q?q(V):_o(_,V);if(J==null||Array.isArray(J)&&J.length===0)continue;const le=(a==null?void 0:a[m])??m;W[le]=J,w=!0}return{params:W,raw:k,hasActiveFilter:x||!!A||w}},[B,p.join("|"),l,n,o,c,s,i,d,a,y,b])},Zo=["dropdown","dropdown-multiple","checkbox-multiple","radio"],Go=({filterConfigs:r,filterKey:t,activeFilterKey:l,pageKey:n,searchKey:o})=>{const{configByKey:c,getValue:s,setValue:i,removeFilter:d,clearAll:a,hasActiveFilter:y}=$r({configs:r,filterKey:t,activeFilterKey:l,pageKey:n,searchKey:o}),p=(L,W)=>{var D;const k=L.options;return((D=k==null?void 0:k.find(H=>H.value===W))==null?void 0:D.label)??W},b=h.useCallback(L=>{const W=c[L];if(!W)return[];const k=s(W);return Array.isArray(k)?k.map(D=>String(D.value)):[]},[c,s]),x=h.useCallback((L,W)=>{const k=c[L];if(!k||!Zo.includes(k.type))return;const D=Array.isArray(W)?W:[W];if(D.length===0){d(L);return}i(k,D.map(H=>({label:p(k,H),value:H})))},[c,i,d]),T=h.useCallback((L,W)=>{const k=b(L);x(L,k.includes(W)?k.filter(D=>D!==W):[...k,W])},[b,x]),v=h.useCallback((L,W)=>b(L).includes(W),[b]),B=h.useCallback(L=>d(L),[d]);return{set:x,toggle:T,clear:B,clearAll:a,isActive:v,values:b,hasActiveFilter:y}},Qo=(r,t)=>{if(!r)return{};const{fromKey:l,toKey:n,opKey:o}=t,c={};switch(r.op){case"is":case"is-before":case"is-after":case"is-on-or-before":case"is-on-or-after":return r.date&&(c[l]=new Date(r.date).toISOString()),o&&(c[o]=r.op),c;case"is-between":return r.from&&(c[l]=new Date(r.from).toISOString()),r.to&&(c[n]=new Date(r.to).toISOString()),c;case"is-relative-to-today":{if(!r.relative)return c;const{from:s,to:i}=rl(r.relative);return c[l]=s.toISOString(),c[n]=i.toISOString(),c}case"is-empty":case"is-not-empty":return o&&(c[o]=r.op==="is-empty"?"empty":"not-empty"),c;default:return c}},gl=({children:r,borderRadius:t,height:l})=>{const n=h.useRef(null),[o,c]=h.useState("100vh");return h.useEffect(()=>{if(l)return;const s=()=>{if(n.current){const i=n.current.getBoundingClientRect().top;c(`calc(100vh - ${i}px)`)}};return s(),window.addEventListener("resize",s),()=>window.removeEventListener("resize",s)},[l]),e.jsx(u.Box,{ref:n,fullWidth:!0,borderStyle:"border-solid",borderWidth:"border",borderColor:"border-base",borderRadius:t||"rounded-xs",style:{height:l??o,display:"flex",flexDirection:"column"},children:r})},ul=({action:r,rightContent:t,leftContent:l,headerSlot:n,advanceFilter:o,showFilter:c=!0})=>{const s=ue.useMediaQuery("md"),i=c?e.jsx(Rt,{...o}):null,d=()=>r?h.isValidElement(r)?r:e.jsx(u.Box,{style:{display:"flex",flexDirection:s?"row":"column",gap:"8px",width:s?"auto":"100%",textWrap:"nowrap"},children:r.map(({title:a,icon:y,buttonProps:p,onClick:b},x)=>!a&&!y?null:e.jsx(P.Button,{fullWidth:!s,iconLeft:y?e.jsx(E.Icon,{name:y}):void 0,onClick:b,...p,children:a},`action-${x}`))}):null;return e.jsx(u.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:s?"row":"column-reverse",gap:"16px"},children:n?n({filter:i}):e.jsxs(e.Fragment,{children:[e.jsxs(u.Box,{style:{display:"flex",gap:"8px",flexDirection:"row",alignItems:"center",flex:1,minWidth:0},children:[i,l]}),e.jsxs(u.Box,{style:{display:"flex",gap:"8px",flexDirection:"row",alignItems:"center",flexShrink:0},children:[t,d()]})]})})},Uo=({totalData:r,withMarginBottom:t=!0,withMarginTop:l=!0})=>e.jsxs(u.Box,{style:{display:"flex",gap:"4px",flexDirection:"row",alignItems:"center",marginBottom:t?"16px":void 0,marginTop:l?"16px":void 0},children:[e.jsxs(We.Body1,{props:{color:"gray-500"},children:["Total data:"," "]}),e.jsx(We.Body1,{children:r||0})]}),yl=({pagination:r,pageKey:t="page",perPageKey:l="perPage",defaultPerPage:n=10,showPagination:o=!0,totalData:c})=>{const{searchQueries:s,setSearchParams:i,searchParams:d}=ke(),a=d.get(l),y=T=>{i({...s,[t]:String(T)})},p=T=>{i({...s,[l]:T,[t]:"1"})},b=(r==null?void 0:r.rangeStart)??(((r==null?void 0:r.currentPage)||0)>1?(((r==null?void 0:r.currentPage)||0)-1)*((r==null?void 0:r.perPage)||0)+1:1),x=(r==null?void 0:r.rangeEnd)??((r==null?void 0:r.totalCurrentPage)!==(r==null?void 0:r.perPage)?r==null?void 0:r.totalData:((r==null?void 0:r.currentPage)||1)*((r==null?void 0:r.totalCurrentPage)||0));return e.jsx(u.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(u.Box,{style:{display:"flex",flexDirection:"row",gap:"8px",alignItems:"center",textWrap:"nowrap"},children:[e.jsx(S.Text,{children:"Rows Per Page: "}),e.jsx(tr.Dropdown,{dropdownLists:[{label:"5",value:"5"},{label:"10",value:"10"},{label:"25",value:"25"},{label:"50",value:"50"},{label:"100",value:"100"}],onChange:T=>{p(T[0].value)},value:a?[{label:`${a} per row`,value:a}]:[{label:`${n} per row`,value:`${n}`}],defaultValue:a?[{label:`${a} per row`,value:a}]:[{label:`${n} per row`,value:`${n}`}]}),e.jsx(S.Text,{children:`${b}-${x} of ${(r==null?void 0:r.totalData)||0}`})]}),e.jsx(fr.Pagination,{currentPage:r!=null&&r.currentPage?Number(r==null?void 0:r.currentPage):1,totalPages:r!=null&&r.totalPage?Number(r==null?void 0:r.totalPage):1,onPageChange:y})]}):e.jsx(Uo,{totalData:c,withMarginBottom:!1,withMarginTop:!1})})},pl=({filter:r,columnTitle:t})=>{const[l,n]=h.useState(!1),o=h.useRef(null),c=h.useRef(null),s=h.useRef(null),[i,d]=h.useState(""),[a,y]=h.useState({top:0,left:0}),p=r.selectedValues,b=h.useMemo(()=>i?r.options.filter(v=>v.label.toLowerCase().includes(i.toLowerCase())):r.options,[r.options,i]);h.useEffect(()=>{if(l&&c.current){const v=c.current.getBoundingClientRect(),B=280,L={top:v.bottom+8};r.position==="left"||v.left+B>window.innerWidth?L.right=window.innerWidth-v.right:L.left=v.left,y(L)}},[l,r.position]),h.useEffect(()=>{l&&s.current?setTimeout(()=>{var v;return(v=s.current)==null?void 0:v.focus()},50):d("")},[l]),h.useEffect(()=>{const v=B=>{o.current&&!o.current.contains(B.target)&&c.current&&!c.current.contains(B.target)&&n(!1)};return l&&document.addEventListener("mousedown",v),()=>document.removeEventListener("mousedown",v)},[l]);const x=v=>{const B=p.includes(v)?p.filter(L=>L!==v):[...p,v];r.onFilterChange(B)},T=()=>r.onFilterChange([]);return e.jsxs(u.Box,{direction:"column",style:{position:"relative"},children:[e.jsx(u.Box,{ref:c,style:{display:"flex",flexDirection:"row",alignItems:"center",cursor:"pointer"},onClick:v=>{var B;v.stopPropagation(),l||(B=r.onOpen)==null||B.call(r),n(L=>!L)},children:e.jsx(E.Icon,{name:l?"ChevronUp":"ChevronDown",size:"sm",style:{color:p.length>0?"var(--sa-color-brand-500, #1a4fa0)":"var(--sa-text-subtle, #8c8f97)"}})}),l&&e.jsxs(u.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(u.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(S.Text,{fontSize:"sm",fontWeight:"semibold",color:"gray-700",children:["Filter ",t]}),p.length>0&&e.jsx(u.Box,{direction:"column",style:{cursor:"pointer"},children:e.jsx(S.Text,{fontSize:"xs",color:"primary",fontWeight:"semibold",onClick:v=>{v.stopPropagation(),T()},children:"CLEAR"})})]}),!r.hideSearch&&e.jsx(u.Box,{direction:"column",style:{paddingLeft:"16px",paddingRight:"16px",paddingTop:"8px",paddingBottom:"8px"},children:e.jsx(Qe.Input,{ref:s,placeholder:`Search ${t.toLowerCase()}...`,leftIcon:e.jsx(E.Icon,{name:"Search",size:"sm"}),value:i,onChange:v=>d(v.target.value),style:{fontSize:"14px"}})}),e.jsx(u.Box,{direction:"column",className:"ts-filter-dropdown-options",style:{overflowY:"auto",maxHeight:"250px",paddingLeft:"8px",paddingRight:"8px"},children:r.isLoadingOptions?e.jsxs(u.Box,{style:{paddingTop:"40px",paddingBottom:"40px",display:"flex",alignItems:"center",justifyContent:"center",flexDirection:"column"},children:[e.jsx(E.Icon,{name:"Loading",size:"lg",style:{color:"var(--sa-background-brand, #04254f)",animation:"spin 1s linear infinite"}}),e.jsx(S.Text,{fontSize:"sm",color:"gray-500",style:{textAlign:"center",marginTop:"8px"},children:"Loading options..."})]}):b.length>0?e.jsx(u.Box,{direction:"column",style:{gap:"2px",paddingTop:"4px",paddingBottom:"4px"},children:b.map(v=>e.jsxs(u.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:p.includes(v.value)?"var(--sa-color-brand-50, #e6edf6)":"transparent"},onClick:B=>{B.stopPropagation(),x(v.value)},onMouseEnter:B=>{p.includes(v.value)||(B.currentTarget.style.backgroundColor="var(--sa-background-primary, #ffffff)"),B.currentTarget.style.transform="translateX(2px)"},onMouseLeave:B=>{B.currentTarget.style.backgroundColor=p.includes(v.value)?"var(--sa-color-brand-50, #e6edf6)":"transparent",B.currentTarget.style.transform="translateX(0)"},children:[e.jsx(cr.Checkbox,{checked:p.includes(v.value),onChange:()=>{}}),e.jsx(S.Text,{fontSize:"sm",fontWeight:p.includes(v.value)?"medium":"normal",color:p.includes(v.value)?"primary":"gray-700",children:v.label})]},v.value))}):e.jsxs(u.Box,{style:{paddingTop:"40px",paddingBottom:"40px",display:"flex",alignItems:"center",justifyContent:"center",flexDirection:"column"},children:[e.jsx(E.Icon,{name:"Search",size:"lg",style:{color:"var(--sa-text-subtle, #8c8f97)"}}),e.jsx(S.Text,{fontSize:"sm",color:"gray-500",style:{textAlign:"center",marginTop:"8px"},children:"No results found"})]})}),p.length>0&&e.jsx(u.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(u.Box,{style:{display:"flex",flexDirection:"row",alignItems:"center",gap:"4px"},children:[e.jsx(u.Box,{direction:"column",style:{backgroundColor:"var(--sa-background-brand, #04254f)",borderRadius:"12px",padding:"2px 8px",fontSize:"11px",fontWeight:600,color:"white"},children:p.length}),e.jsxs(S.Text,{fontSize:"xs",color:"primary",fontWeight:"medium",children:["item",p.length>1?"s":""," selected"]})]})})]})]})},Jo=({direction:r})=>{const t="var(--sa-text-primary, #292a2e)",l="var(--sa-text-subtle, #8c8f97)",n=r==="asc"?t:l,o=r==="desc"?t:l,c=r==="asc"?1:.45,s=r==="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:n,opacity:c,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:s},children:e.jsx("path",{d:"M0 0 L8 0 L4 5 Z",fill:"currentColor"})})]})},Yo=({frozen:r})=>e.jsxs("svg",{width:"11",height:"11",viewBox:"0 0 24 24",fill:r?"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:r?"M7 11V7a5 5 0 0 1 10 0v4":"M7 11V7a5 5 0 0 1 9.9-1"})]}),ot="var(--sa-background-primary, #ffffff)",bl="var(--sa-background-primary-inverse, #f8f8f8)",vl=({columns:r,records:t,handleDetail:l,handleUpdate:n,handleDelete:o,isLoading:c,visibleHandleDelete:s,visibleHandleUpdate:i,visibleHandleDetail:d,showHeadBorder:a=!1,scrollParentRef:y,frozenCount:p=0,onFrozenCountChange:b,customActions:x,actionsOrder:T=["detail","update","delete","custom"],customEmptyState:v,enableColumnResize:B=!1,defaultColumnWidths:L,onColumnWidthsChange:W,defaultMinColumnWidth:k=60,sort:D,defaultSort:H,onSortChange:A,showActionDivider:w=!1})=>{const m=D!==void 0,[_,V]=h.useState(H??null),q=m?D??null:_,J=I=>{if(I.sortKey)return I.sortKey;if(typeof I.accessor=="string")return I.accessor},le=I=>{const j=J(I);if(!j)return;let N;!q||q.key!==j?N={key:j,direction:"asc"}:q.direction==="asc"?N={key:j,direction:"desc"}:N=null,m||V(N),A==null||A(N)},oe=[l,n,o].filter(I=>I!==void 0).length,ie=!!x,K=!!l||!!n||!!o||ie,Y="var(--sa-border-subtle, #0b120e24)",de=`1px solid ${Y}`,te=`inset 1px 0 0 ${Y}`,ae=`inset -1px 0 0 ${Y}`,Be=oe===3?ie?"178px":"140px":oe===2?ie?"140px":"102px":oe===1?ie?"112px":"74px":ie?"74px":"",Ne=(I,j)=>{if(!j)return I;if(typeof j=="function")return j(I);if(typeof j=="string")return I[j]},[pe,me]=h.useState(!1);h.useEffect(()=>{if(!(y!=null&&y.current))return;const I=y.current;me(I.scrollHeight>I.clientHeight)},[t,y]);const Te=h.useRef(null),[be,Ae]=h.useState([]),[Ze,ve]=h.useState(()=>L??{}),Le=h.useRef(null);h.useLayoutEffect(()=>{if(!p||!Te.current){Ae([]);return}const I=Array.from(Te.current.querySelectorAll("thead tr th")),j=[];let N=0;I.forEach((G,R)=>{j[R]=N,R<p&&(N+=G.offsetWidth)}),Ae(j)},[p,r,t,Ze]);const Ye=I=>{b&&b(I<p?I:I+1)},F=(I,j)=>{const N=Ze[I];if(N!==void 0){const G=`${N}px`;return{width:G,minWidth:G,maxWidth:G}}return j?{width:j}:{}},Q=I=>B&&(I.resizable??!0),Z=(I,j)=>{I.preventDefault(),I.stopPropagation();const N=I.currentTarget.closest("th");if(!N)return;const G=Math.round(N.getBoundingClientRect().width);Le.current={colIndex:j,startX:I.clientX,startWidth:G};const R=document.body.style.userSelect,xe=document.body.style.cursor;document.body.style.userSelect="none",document.body.style.cursor="col-resize";const Fe=He=>{var $e;const Ie=Le.current;if(!Ie)return;const Xe=(($e=r[Ie.colIndex])==null?void 0:$e.minWidth)??k,Ke=Math.max(Xe,Ie.startWidth+(He.clientX-Ie.startX));ve(Ve=>Ve[Ie.colIndex]===Ke?Ve:{...Ve,[Ie.colIndex]:Ke})},ze=()=>{document.removeEventListener("mousemove",Fe),document.removeEventListener("mouseup",ze),document.body.style.userSelect=R,document.body.style.cursor=xe,Le.current=null,W&&ve(He=>(W(He),He))};document.addEventListener("mousemove",Fe),document.addEventListener("mouseup",ze)};return e.jsx("div",{ref:Te,children:e.jsxs(U.Table,{fullWidth:!0,children:[e.jsx(U.Thead,{style:{height:"40px",whiteSpace:"nowrap"},children:e.jsxs(U.Tr,{children:[r.map((I,j)=>{var sr,ar;const N=p>0&&j<p,G=be[j]??0,R=Q(I),Fe=j===r.length-1&&K&&w,ze=J(I),He=!!I.sortable&&!!ze,Ie=He&&(q==null?void 0:q.key)===ze?q.direction:null,Xe=I.title||((sr=I.accessor)==null?void 0:sr.toString())||"",Ke=(ar=I.headerTooltip)!=null&&ar.showIcon?e.jsx(E.Icon,{name:"InfoCircle",size:"xs",style:{flexShrink:0,color:"var(--sa-icon-subtle, #8c8f97)",opacity:.75}}):null,$e=e.jsx("span",{style:{flex:1,minWidth:0,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:Xe}),Ve=He?e.jsxs("button",{type:"button",onClick:()=>le(I),title:Ie==="asc"?"Sorted ascending — click to sort descending":Ie==="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:I.textAlign==="text-right"?"right":I.textAlign==="text-center"?"center":"left"},children:[$e,Ke,e.jsx(Jo,{direction:Ie})]}):e.jsxs("span",{style:{flex:1,minWidth:0,display:"flex",alignItems:"center",gap:4},children:[$e,Ke]});return e.jsxs(U.Th,{style:{position:"sticky",top:0,left:N?G:void 0,zIndex:N?4:2,paddingLeft:j===0?"12px":"",borderRight:a&&!Fe&&!N?de:void 0,borderBottom:a?de:void 0,boxShadow:a&&N?ae:void 0,backgroundColor:"var(--sa-background-primary-inverse, #f8f8f8)",textAlign:I.textAlign==="text-right"?"right":I.textAlign==="text-center"?"center":"left",...F(j,I.width)},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"4px",justifyContent:"space-between",minWidth:0},children:[I.headerTooltip?e.jsx(De.Tooltip,{label:I.headerTooltip.content,position:"bottom",children:Ve}):Ve,I.filter&&e.jsx(pl,{filter:I.filter,columnTitle:I.title}),b&&e.jsx("button",{onClick:()=>Ye(j),title:N?"Unfreeze column":"Freeze column",style:{background:"none",border:"none",cursor:"pointer",padding:"2px",display:"flex",alignItems:"center",flexShrink:0,color:N?"var(--sa-background-brand, #04254f)":"var(--sa-text-subtle, #8c8f97)",opacity:N?1:.45,transition:"opacity 0.15s"},children:e.jsx(Yo,{frozen:N})})]}),R&&e.jsx("div",{onMouseDown:dr=>Z(dr,j),onClick:dr=>dr.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-${j}`)}),K?e.jsx(U.Th,{style:{backgroundColor:"var(--sa-background-primary-inverse, #f8f8f8)",position:"sticky",top:0,right:0,zIndex:3,borderBottom:a?de:void 0,boxShadow:a&&w?te:void 0}}):null]})}),e.jsx(U.Tbody,{children:c?e.jsx(U.Tr,{children:e.jsx(U.Td,{colSpan:r.length+1,children:e.jsxs(u.Box,{direction:"column",style:{gap:"16px"},children:[e.jsx(je.Skeleton,{variant:"list"}),e.jsx(je.Skeleton,{variant:"list"}),e.jsx(je.Skeleton,{variant:"list"}),e.jsx(je.Skeleton,{variant:"list"}),e.jsx(je.Skeleton,{variant:"list"})]})})}):!(t!=null&&t.length)&&v?e.jsx(U.Tr,{children:e.jsx(U.Td,{colSpan:r.length+1,children:v})}):t==null?void 0:t.map((I,j)=>e.jsxs(U.Tr,{style:{transition:"background-color 0.3s ease",padding:0,borderBottom:j===t.length-1&&pe?void 0:"1px solid var(--sa-border-subtle, #0b120e24)"},onMouseEnter:N=>{const G=N.currentTarget;G.style.backgroundColor=bl,Array.from(G.querySelectorAll("td")).forEach(R=>{R.style.position==="sticky"&&(R.style.backgroundColor=bl)})},onMouseLeave:N=>{const G=N.currentTarget;G.style.backgroundColor="",Array.from(G.querySelectorAll("td")).forEach(R=>{R.style.position==="sticky"&&(R.style.backgroundColor=ot)})},children:[r.map((N,G)=>{const R=N.render?N.render(I,j,t):Ne(I,N.accessor),xe=p>0&&G<p,Fe=be[G]??0,ze=Ze[G]!==void 0,He=xe&&G===p-1;return e.jsx(U.Td,{style:{position:xe?"sticky":void 0,left:xe?Fe:void 0,zIndex:xe?1:void 0,backgroundColor:xe?ot:void 0,transition:xe?"background-color 0.3s ease":void 0,paddingLeft:G===0?"12px":"",whiteSpace:"nowrap",overflow:ze?"hidden":void 0,borderLeft:N.showBorderLeft?de:void 0,borderRight:N.showBorderRight?de:void 0,boxShadow:He?ae:void 0,textAlign:N.textAlign==="text-right"?"right":N.textAlign==="text-center"?"center":"left",...F(G,N.width)},children:typeof R=="string"?e.jsx(S.Text,{style:{whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",textAlign:N.textAlign==="text-right"?"right":N.textAlign==="text-center"?"center":"left"},children:R}):R},`row-${j}-col-${G}`)}),K?e.jsx(U.Td,{style:{width:Be,position:"sticky",right:0,zIndex:1,backgroundColor:ot,boxShadow:w?te:void 0,transition:"background-color 0.3s ease"},children:e.jsx(ne.Flex,{direction:"row",align:"center",justify:"center",gap:"sm",children:T.map(N=>{const G=j===t.length-1?"top":"bottom";return N==="detail"&&l&&(d==null?void 0:d(I))!==!1?e.jsx(De.Tooltip,{label:"Detail",position:G,children:e.jsx(P.Button,{size:"xs",variant:"outline",tone:"neutral",onClick:()=>l(I.id,I),iconLeft:e.jsx(E.Icon,{name:"DocumentClean",size:"sm",style:{color:"var(--sa-text-subtle, #8c8f97)"}})})},"detail"):N==="update"&&n&&(i==null?void 0:i(I))!==!1?e.jsx(De.Tooltip,{label:"Update",position:G,children:e.jsx(P.Button,{size:"xs",variant:"outline",tone:"neutral",onClick:()=>n(I),iconLeft:e.jsx(E.Icon,{name:"Edit1",size:"sm",style:{color:"var(--sa-text-subtle, #8c8f97)"}})})},"update"):N==="delete"&&o&&(s==null?void 0:s(I))!==!1?e.jsx(De.Tooltip,{label:"Delete",position:G,children:e.jsx(P.Button,{size:"xs",variant:"outline",tone:"neutral",onClick:()=>o(I.id,I),iconLeft:e.jsx(E.Icon,{name:"Trash1",size:"sm",style:{color:"var(--sa-color-error-600, #c9184a)"}})})},"delete"):N==="custom"?e.jsx(h.Fragment,{children:x==null?void 0:x(I)},"custom"):null})})}):null]},`${I}${j}`))})]})})},Xo=({wrapperProps:r,dataTableProps:t,headerProps:l,footerProps:n})=>{var p;const o=h.useRef(null),[c,s]=h.useState((t==null?void 0:t.defaultFrozenCount)??0),i=(l==null?void 0:l.show)??!0,d=h.useRef(null),a=(p=t==null?void 0:t.pagination)==null?void 0:p.totalData;typeof a=="number"&&(d.current=a);const y=(n==null?void 0:n.showFooter)??(a===void 0?d.current!==0:a!==0);return e.jsxs(gl,{...r,children:[i&&e.jsx(ul,{...l}),e.jsx(u.Box,{direction:"column",ref:o,style:{flex:1,overflowY:"auto",overflowX:"auto"},children:t?e.jsx(vl,{...t,scrollParentRef:o,frozenCount:t!=null&&t.enableFreezeColumns?c:0,onFrozenCountChange:t!=null&&t.enableFreezeColumns?s:void 0}):null}),y&&e.jsx(yl,{pagination:t==null?void 0:t.pagination,pageKey:t==null?void 0:t.pageKey,perPageKey:t==null?void 0:t.perPageKey,defaultPerPage:t==null?void 0:t.defaultPerPage,showPagination:t==null?void 0:t.showPagination,totalData:n==null?void 0:n.totalData})]})};function Ko(r){return h.memo(r)}const $o=Ko(Xo),Cl=200,nt="1px solid var(--sa-border-subtle, #0b120e24)",Ro=({sortDir:r,frozen:t})=>r==="asc"?e.jsx(E.Icon,{name:"ChevronSmallUp"}):r==="desc"?e.jsx(E.Icon,{name:"ChevronSmallDown"}):t?e.jsx(E.Icon,{name:"LockOn",size:"xs"}):e.jsx(E.Icon,{name:"Filter",size:"xs"}),Er=({icon:r,label:t,active:l,danger:n,onClick:o})=>{const c=n?"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:l?"var(--sa-background-brand-subtlest, #e6edf6)":"none",border:"none",cursor:"pointer",font:"inherit",color:c,textAlign:"left"},onMouseEnter:s=>{l||(s.currentTarget.style.background="var(--sa-background-primary-inverse, #f8f8f8)")},onMouseLeave:s=>{s.currentTarget.style.background=l?"var(--sa-background-brand-subtlest, #e6edf6)":"none"},children:[e.jsx(E.Icon,{name:r,size:"sm",style:{color:c,flexShrink:0}}),e.jsx(S.Text,{as:"span",style:{color:c},children:t})]})},xl=({active:r,canSort:t,canHide:l,sortDir:n,frozen:o,onSort:c,onClearSort:s,onToggleFreeze:i,onHide:d})=>{const[a,y]=h.useState(!1),p=h.useRef(null),b=h.useRef(null),[x,T]=h.useState({top:0,left:0});h.useEffect(()=>{if(a&&p.current){const B=p.current.getBoundingClientRect(),L=B.left+Cl>window.innerWidth;T({top:B.bottom+6,...L?{right:window.innerWidth-B.right}:{left:B.left}})}},[a]),h.useEffect(()=>{if(!a)return;const B=L=>{b.current&&!b.current.contains(L.target)&&p.current&&!p.current.contains(L.target)&&y(!1)};return document.addEventListener("mousedown",B),()=>document.removeEventListener("mousedown",B)},[a]);const v=B=>{B(),y(!1)};return e.jsxs(e.Fragment,{children:[e.jsx("button",{ref:p,type:"button",className:"sa-tl-menu-trigger","data-active":r||a?"true":"false",onClick:B=>{B.stopPropagation(),y(L=>!L)},title:"Column options",style:{display:"inline-flex",alignItems:"center",justifyContent:"center",width:22,height:22,borderRadius:"var(--sa-radii-sm, 6px)",border:nt,background:"var(--sa-background-primary, #ffffff)",cursor:"pointer",color:"var(--sa-text-subtle, #8c8f97)",flexShrink:0},children:e.jsx(Ro,{sortDir:n,frozen:o})}),a&&e.jsxs(u.Box,{ref:b,onClick:B=>B.stopPropagation(),style:{position:"fixed",top:`${x.top}px`,...x.left!==void 0?{left:`${x.left}px`}:{right:`${x.right}px`},minWidth:Cl,backgroundColor:"var(--sa-background-primary, #ffffff)",border:nt,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:[t&&e.jsxs(e.Fragment,{children:[e.jsx(Er,{icon:"ChevronUp",label:"Ascending",active:n==="asc",onClick:()=>v(()=>n==="asc"?s():c("asc"))}),e.jsx(Er,{icon:"ChevronDown",label:"Descending",active:n==="desc",onClick:()=>v(()=>n==="desc"?s():c("desc"))}),e.jsx("div",{style:{borderTop:nt,margin:"4px 0"}})]}),e.jsx(Er,{icon:"Pin1",label:o?"Unfreeze":"Freeze",active:o,onClick:()=>v(i)}),l&&e.jsx(Er,{icon:"EyeClosed",label:"Hide column",danger:!0,onClick:()=>v(d)})]})]})},Mr="1px solid var(--sa-border-subtle, #0b120e24)",en="var(--sa-text-subtle, #8c8f97)",pr="var(--sa-background-neutral, #f0f1f2)",wl="2px 0 4px -2px rgba(0,0,0,0.15)",Lr={display:"block",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},Dl="sa-table-layout-styles",rn=()=>{if(typeof document>"u"||document.getElementById(Dl))return;const r=document.createElement("style");r.id=Dl,r.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);