@starasia/admin 14.8.0 → 16.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs.js +1 -1
- package/dist/index.es.js +0 -9
- package/dist/index.umd.js +1 -1
- package/package.json +4 -4
package/dist/index.cjs.js
CHANGED
|
@@ -54,7 +54,7 @@
|
|
|
54
54
|
.sa-table-layout tfoot.sa-tl-sticky-foot > tr:first-child > th {
|
|
55
55
|
box-shadow: 0 -2px 4px -2px var(--sa-border-subtle, #0b120e24);
|
|
56
56
|
}
|
|
57
|
-
`,document.head.appendChild(t)},Et=t=>t==="right"?"right":t==="center"?"center":"left",qi=/^(#|rgb|hsl|var\()/,Nt=t=>t?qi.test(t)?t:`var(--sa-background-${t})`:void 0,Zi=(t,r)=>{if(r)return t[r]},Gi=(t,r)=>t==null&&r==null?0:t==null?-1:r==null?1:typeof t=="number"&&typeof r=="number"?t-r:String(t).localeCompare(String(r)),Qi=({columns:t,data:r,getRowKey:n,rowBg:s,size:o="md",resizable:i=!1,layout:l="auto",widthStorageKey:c,columnState:a,onColumnStateChange:u,columnMenu:f=!1,sort:g,defaultSort:m,onSortChange:p,height:S,mobileLayout:b="cards",mobileBreakpoint:I="md",groupSeparator:B,summary:M,footer:C,stickyFooter:D=!1,emptyState:A,loading:R=!1,loadingRows:w=8,rowActions:O,selectable:L=!1,selectedKeys:U,defaultSelectedKeys:J,onSelectionChange:N,isRowSelectable:_})=>{_i();const te=!Ce.useMediaQuery(I)&&b!=="scroll",V=!!(O!=null&&O.length),[z,P]=d.useState(null);d.useEffect(()=>{if(!z)return;const y=()=>P(null),j=setTimeout(()=>document.addEventListener("click",y),0);return()=>{clearTimeout(j),document.removeEventListener("click",y)}},[z]);const[se,ye]=d.useState(()=>new Set),Se=a!==void 0,[xe,pe]=d.useState({}),je=a??xe,be=y=>{u==null||u(y),Se||pe(y)},Te=g!==void 0,[ke,He]=d.useState(m??null),Y=Te?g??null:ke,he=!p,Oe=y=>{p==null||p(y),Te||He(y)},{headerGroups:Ne,leafColumns:ae,hasGroups:_e}=d.useMemo(()=>{var ie;const y=new Set(je.hidden??[]),j=(re,me)=>re.key??(typeof re.accessor=="string"?re.accessor:`col-${me}`),E=t.map((re,me)=>{var Je;if((Je=re.children)!=null&&Je.length){const Dt=re.children.map((Ke,St)=>({col:Ke,key:j(Ke,`${me}-${St}`)})).filter(Ke=>!y.has(Ke.key));return{col:re,key:re.key??`group-${me}`,isGroup:!0,leaves:Dt}}const ge={col:re,key:j(re,`${me}`)};return{col:re,key:ge.key,isGroup:!1,leaves:y.has(ge.key)?[]:[ge]}}).filter(re=>re.leaves.length>0),Z=E.some(re=>re.isGroup);let ne=E.flatMap(re=>re.leaves);if(!Z&&((ie=je.order)!=null&&ie.length)){const re=new Map(je.order.map((me,ge)=>[me,ge]));ne=[...ne].sort((me,ge)=>(re.get(me.key)??1/0)-(re.get(ge.key)??1/0))}return{headerGroups:E,leafColumns:ne,hasGroups:Z}},[t,je]),tt=d.useMemo(()=>new Map(ae.map((y,j)=>[y.key,j])),[ae]),W=!_e&&ae.some(y=>(y.col.headerColSpan??1)>1),$=ae.map(y=>y.key).join("|"),Q=(y,j)=>{const E=y.sortKey??(typeof y.accessor=="string"?y.accessor:void 0);return E?j[E]:void 0},de=y=>y.sortable??(!!y.sortKey||typeof y.accessor=="string"),le=d.useMemo(()=>{if(!he||!Y)return r;const y=ae.find(E=>E.key===Y.key);if(!y)return r;const j=Y.direction==="asc"?1:-1;return[...r].sort((E,Z)=>Gi(Q(y.col,E),Q(y.col,Z))*j)},[r,he,Y,ae]),Be=!_e&&!W,Re=!!c&&Be,[$e,qe]=G.useColumnWidths(c??""),Me=Re?$e:void 0,Qe=d.useRef(null),[we,Ze]=d.useState();d.useLayoutEffect(()=>{Ze(void 0)},[$]),d.useLayoutEffect(()=>{if(!Be||we||!Qe.current)return;const y=Qe.current.querySelectorAll("th.sa-tl-leaf");Ze(Array.from(y).map(j=>j.offsetWidth))},[we,Be]);const[rt,ut]=d.useState(),[ct,at]=d.useState(0);d.useLayoutEffect(()=>{if(!_e||!Qe.current)return;const y=Qe.current.querySelector(":scope > tr");y&&at(y.offsetHeight)},[_e,$]);const ft=(y,j)=>{if((Me==null?void 0:Me[j])!=null)return Me[j];if(y.width!=null)return y.width;if((we==null?void 0:we[j])!=null)return we[j]},k=(y,j)=>typeof y.width=="number"?y.width:we==null?void 0:we[j],q=je.frozenKey&&!_e&&!W?ae.findIndex(y=>y.key===je.frozenKey):-1,K=y=>y<=q,ve=L?Bt:0,Ie=y=>{const j=rt??we;if(!j)return ve;let E=ve;for(let Z=0;Z<y;Z++)E+=j[Z]??0;return E};d.useLayoutEffect(()=>{const y=Qe.current;if(!y||q<0){ut(void 0);return}let j=0;const E=()=>{j=0;const ne=y.querySelectorAll("th.sa-tl-leaf"),ie=Array.from(ne).map(re=>re.getBoundingClientRect().width);ut(re=>re&&re.length===ie.length&&re.every((me,ge)=>Math.abs(me-ie[ge])<.5)?re:ie)},Z=new ResizeObserver(()=>{j||(j=requestAnimationFrame(E))});return Z.observe(y),y.querySelectorAll("th.sa-tl-leaf").forEach(ne=>Z.observe(ne)),E(),()=>{j&&cancelAnimationFrame(j),Z.disconnect()}},[$,q,L,we,Me]);const Ue=d.useRef(null),[Ae,De]=d.useState("100vh");d.useLayoutEffect(()=>{if(S!==void 0)return;const y=()=>{if(Ue.current){const j=Ue.current.getBoundingClientRect().top;De(`calc(100vh - ${j}px - var(--sa-floating-footer-height, 0px) + 12px)`)}};return y(),window.addEventListener("resize",y),()=>window.removeEventListener("resize",y)},[S]);const Ee=(y,j)=>n?n(y,j):j,We=U!==void 0,[wt,No]=d.useState(()=>new Set(J??[])),st=d.useMemo(()=>We?new Set(U):wt,[We,U,wt]);d.useEffect(()=>{L&&!n&&process.env.NODE_ENV!=="production"&&console.warn("[@starasia/admin] TableLayout: `selectable` tanpa `getRowKey` — key default (index) membuat seleksi menempel ke POSISI baris, bukan datanya. Beri `getRowKey` yang stabil (mis. r => r.id).")},[L,!n]);const Yr=y=>{if(We||No(y),N){const j=le.filter((E,Z)=>y.has(Ee(E,Z)));N(Array.from(y),j)}},ir=(y,j)=>L&&(_?_(y,j):!0),lr=y=>{const j=new Set(st);j.has(y)?j.delete(y):j.add(y),Yr(j)},mt=d.useMemo(()=>L?le.map((y,j)=>({row:y,i:j,key:Ee(y,j)})).filter(({row:y,i:j})=>_?_(y,j):!0).map(({key:y})=>y):[],[L,le,_,n]),Xr=mt.filter(y=>st.has(y)),cr=mt.length>0&&Xr.length===mt.length,$r=Xr.length>0&&!cr,_o=()=>{const y=new Set(st);cr?mt.forEach(j=>y.delete(j)):mt.forEach(j=>y.add(j)),Yr(y)},ar=(y,j,E)=>y.render?y.render(j,E,le):Zi(j,y.accessor),dr=ae.length+(L?1:0)+(V?1:0),Kr=["80%","55%","70%","45%","90%","60%"],qo=(y,j)=>Kr[(y*7+j*3)%Kr.length],Zo=(y,j)=>e.jsx(Ye.Skeleton,{height:14,width:qo(y,j),borderRadius:"rounded-sm"}),Go=Array.from({length:w},(y,j)=>e.jsxs(G.Tr,{children:[L&&e.jsx(G.Td,{style:{width:Bt,padding:0},children:e.jsx("div",{style:{display:"flex",justifyContent:"center"},children:e.jsx(Ye.Skeleton,{height:14,width:14,borderRadius:"rounded-sm"})})}),ae.map(({col:E,key:Z},ne)=>e.jsx(G.Td,{style:{textAlign:Et(E.align)},children:Zo(j,ne)},`sa-tl-sk-${j}-${Z}`)),V&&e.jsx(G.Td,{style:{width:1,padding:0,border:"none"}})]},`sa-tl-sk-${j}`)),Qo=(y,j)=>{j||be({...je,hidden:[...je.hidden??[],y]})},Uo=y=>be({...je,frozenKey:je.frozenKey===y?void 0:y}),Rt=y=>(O??[]).filter(j=>{var E;return!((E=j.hidden)!=null&&E.call(j,y))}),en={position:"absolute",right:0,top:0,bottom:0,display:"flex",alignItems:"center",gap:4,paddingRight:16,paddingLeft:40,background:"linear-gradient(to right, transparent, var(--sa-background-primary-inverse, #f8f8f8) 40px)"},At=(y,j,E,Z)=>{var Je;const ne=(Je=y.disabled)==null?void 0:Je.call(y,j),ie=(Z==null?void 0:Z.showLabel)??y.showLabel,re=(Z==null?void 0:Z.size)??"xs",me=e.jsx(H.Button,{size:re,variant:y.variant??"tertiary",tone:y.tone??"neutral",disabled:ne,onClick:()=>y.onClick(j,E),iconLeft:y.icon?e.jsx(F.Icon,{name:y.icon,size:"sm"}):void 0,children:ie&&y.label}),ge=y.tooltip;return ge?e.jsx(Fe.Tooltip,{label:ge,position:"top-end",children:me}):me},Jo=(y,j)=>{const E=Rt(y);if(!E.length)return null;if(E.length>5){const ne=Ee(y,j),ie=(z==null?void 0:z.rowKey)===ne;return e.jsx("div",{className:"sa-tl-row-actions",style:en,onClick:re=>re.stopPropagation(),children:e.jsx(Fe.Tooltip,{label:"Aksi lainnya",position:"top",children:e.jsx(H.Button,{size:"xs",variant:"tertiary",onClick:re=>{const me=re.currentTarget.getBoundingClientRect();P(ie?null:{rowKey:ne,top:me.bottom+4,right:window.innerWidth-me.right})},children:e.jsx(F.Icon,{name:"MenuVertical",size:"sm"})})})})}return e.jsx("div",{className:"sa-tl-row-actions",style:en,children:E.map(ne=>e.jsx(d.Fragment,{children:At(ne,y,j)},ne.key))})},Yo=(y,j)=>{const E=Rt(y);return E.length?e.jsx("div",{style:{display:"flex",gap:6,flexWrap:"wrap",paddingTop:8,marginTop:8,borderTop:kt},children:E.map(Z=>e.jsx(d.Fragment,{children:At(Z,y,j,{showLabel:!0,size:"sm"})},Z.key))}):null},Xo=(y,j)=>{const E=Rt(y);return E.length?e.jsx("div",{style:{display:"flex",gap:4,paddingRight:8,flexShrink:0},children:E.map(Z=>e.jsx(d.Fragment,{children:At(Z,y,j,{showLabel:!1})},Z.key))}):null},ur=(y,j)=>{const{col:E,key:Z}=y,ne=tt.get(Z)??0,ie=K(ne),re=ie&&ne===q,me=(Y==null?void 0:Y.key)===Z?Y.direction:null,ge=f&&!E.disableMenu?e.jsx(Io,{active:!!me||ie,canSort:de(E),canHide:!E.locked,sortDir:me,frozen:ie,onSort:St=>Oe({key:Z,direction:St}),onClearSort:()=>Oe(null),onToggleFreeze:()=>Uo(Z),onHide:()=>Qo(Z,E.locked)}):null,Je=E.align==="right",Dt=E.align==="right"?"flex-end":E.align==="center"?"center":"flex-start",Ke=e.jsxs("span",{style:{flex:1,minWidth:0,display:"flex",alignItems:"center",gap:6,justifyContent:Dt,overflow:"hidden"},children:[E.icon&&e.jsx(F.Icon,{name:E.icon,size:"sm",style:{flexShrink:0}}),e.jsx("span",{style:Vt,children:E.title})]});return e.jsx(G.Th,{className:`sa-tl-leaf${ie?" sa-tl-frozen":""}`,rowSpan:j==null?void 0:j.rowSpan,colSpan:j==null?void 0:j.colSpan,minWidth:E.minWidth,numeric:E.numeric,resizable:Be?E.resizable:!1,defaultWidth:k(E,ne),style:{textAlign:Et(E.align),width:ft(E,ne),position:"sticky",top:(j==null?void 0:j.top)??0,left:ie?Ie(ne):void 0,zIndex:ie?3:2,backgroundColor:gt,boxShadow:re?Pn:void 0},children:e.jsx("div",{style:{display:"flex",alignItems:"center",gap:6,width:"100%"},children:Je?e.jsxs(e.Fragment,{children:[ge,Ke]}):e.jsxs(e.Fragment,{children:[Ke,ge]})})},`th-${Z}`)},$o=()=>{const y=[];for(let j=0;j<ae.length;){const E=ae[j],Z=E.col.headerColSpan??1,ne=Math.max(1,Math.min(Z,ae.length-j));y.push(ur(E,ne>1?{colSpan:ne}:void 0)),j+=ne}return y},tn=y=>e.jsx(G.Th,{rowSpan:y==null?void 0:y.rowSpan,style:{width:Bt,position:"sticky",top:0,left:0,zIndex:4,backgroundColor:gt,padding:0},children:e.jsx("div",{style:{display:"flex",alignItems:"center",justifyContent:"center"},onClick:j=>j.stopPropagation(),children:e.jsx(nt.Checkbox,{size:"sm",variant:$r?"indeterminate":"select",checked:cr||$r,disabled:mt.length===0,onChange:_o,"aria-label":"Pilih semua baris di halaman ini"})})},"th-select"),Ko=(y,j,E)=>{const Z=Ee(y,j);return e.jsx(G.Td,{className:"sa-tl-frozen",style:{width:Bt,padding:0,position:"sticky",left:0,zIndex:2,...E?{"--sa-tl-bg":E}:{}},children:ir(y,j)&&e.jsx("div",{style:{display:"flex",alignItems:"center",justifyContent:"center"},onClick:ne=>ne.stopPropagation(),children:e.jsx(nt.Checkbox,{size:"sm",checked:st.has(Z),onChange:()=>lr(Z),"aria-label":"Pilih baris"})})},`tl-select-${j}`)},xr=ae.filter(y=>!y.col.hideOnMobile),hr=xr.find(y=>y.col.primary)??xr[0],es=xr.filter(y=>y!==hr),ts=y=>ye(j=>{const E=new Set(j);return E.has(y)?E.delete(y):E.add(y),E}),rn=(y,j)=>es.map(({col:E,key:Z})=>{const ne=ar(E,y,j),ie={minWidth:0,overflow:"hidden",textOverflow:"ellipsis",textAlign:"right",...E.numeric?{fontVariantNumeric:"tabular-nums"}:{}},re=typeof ne=="string"||typeof ne=="number"?e.jsx(v.Text,{style:ie,children:ne}):e.jsx("div",{style:ie,children:ne});return e.jsxs("div",{style:{display:"flex",gap:12,justifyContent:"space-between",alignItems:"baseline"},children:[typeof E.title=="string"?e.jsx(v.Text,{color:"subtle",fontWeight:"medium",style:{color:Ni,flexShrink:0},children:E.title}):e.jsx("div",{style:{flexShrink:0},children:E.title}),re]},Z)}),fr=(y,j)=>{const E=hr?ar(hr.col,y,j):null;return typeof E=="string"||typeof E=="number"?e.jsx(v.Text,{as:"span",style:Vt,children:E}):e.jsx("span",{style:Vt,children:E})},rs=e.jsx(x.Box,{style:{display:"flex",flexDirection:"column",gap:8,padding:8},children:Array.from({length:w},(y,j)=>e.jsxs(x.Box,{style:{border:kt,borderRadius:"var(--sa-radii-sm, 6px)",padding:12,display:"flex",flexDirection:"column",gap:8},children:[e.jsx(Ye.Skeleton,{height:16,width:"60%",borderRadius:"rounded-sm"}),e.jsx(Ye.Skeleton,{height:12,width:"85%",borderRadius:"rounded-sm"}),e.jsx(Ye.Skeleton,{height:12,width:"70%",borderRadius:"rounded-sm"})]},`sa-tl-sk-card-${j}`))}),nn=e.jsx(x.Box,{fullWidth:!0,style:{minHeight:(A==null?void 0:A.minHeight)??320,display:"flex",alignItems:"center",justifyContent:"center",padding:16},children:A==null?void 0:A.content}),ns=R?rs:le.length===0?nn:b==="expand"?e.jsx(x.Box,{style:{display:"flex",flexDirection:"column"},children:le.map((y,j)=>{const E=Ee(y,j),Z=se.has(E),ie=L&&st.has(E)?Sr:Nt(s==null?void 0:s(y,j));return e.jsxs("div",{style:{borderBottom:kt,backgroundColor:ie},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center"},children:[ir(y,j)&&e.jsx("div",{style:{display:"flex",alignItems:"center",paddingLeft:12,flexShrink:0},children:e.jsx(nt.Checkbox,{size:"sm",checked:st.has(E),onChange:()=>lr(E),"aria-label":"Pilih baris"})}),e.jsxs("button",{type:"button",onClick:()=>ts(E),style:{flex:1,minWidth:0,display:"flex",alignItems:"center",justifyContent:"space-between",gap:12,padding:"10px 12px",background:"none",border:"none",font:"inherit",color:"inherit",cursor:"pointer",textAlign:"left"},children:[fr(y,j),e.jsx(F.Icon,{name:Z?"ChevronUp":"ChevronDown",size:"sm",style:{flexShrink:0}})]}),V&&Xo(y,j)]}),Z&&e.jsx("div",{style:{padding:"0 12px 12px",display:"flex",flexDirection:"column",gap:6},children:rn(y,j)})]},E)})}):e.jsx(x.Box,{style:{display:"flex",flexDirection:"column",gap:8,padding:8},children:le.map((y,j)=>{const E=Ee(y,j),Z=L&&st.has(E);return e.jsxs(x.Box,{style:{border:kt,borderRadius:"var(--sa-radii-sm, 6px)",padding:12,display:"flex",flexDirection:"column",gap:6,backgroundColor:Z?Sr:Nt(s==null?void 0:s(y,j))},children:[ir(y,j)?e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[e.jsx(nt.Checkbox,{size:"sm",checked:st.has(E),onChange:()=>lr(E),"aria-label":"Pilih baris"}),e.jsx("div",{style:{flex:1,minWidth:0},children:fr(y,j)})]}):fr(y,j),rn(y,j),V&&Yo(y,j)]},E)})}),os=i&&Be&&we!==void 0,on=l==="fixed"&&!i&&(Be?we!==void 0:!0),ss=on&&!Be,Wt=C&&C.length>0?C.map((y,j)=>e.jsx(G.Tr,{children:y.cells.map((E,Z)=>e.jsx(G.Td,{colSpan:E.colSpan,rowSpan:E.rowSpan,numeric:E.numeric,style:{textAlign:Et(E.align)},children:E.content},`tl-foot-${j}-${Z}`))},`tl-foot-${j}`)):null,is=e.jsxs(G.Table,{className:"sa-table-layout",fullWidth:!0,size:o,resizable:os,style:on?{tableLayout:"fixed"}:void 0,onWidthsChange:Re?qe:void 0,children:[ss&&e.jsxs("colgroup",{children:[L&&e.jsx("col",{style:{width:Bt}}),ae.map(({col:y,key:j},E)=>e.jsx("col",{style:{width:ft(y,E)}},`col-${j}`)),V&&e.jsx("col",{style:{width:1}})]}),e.jsx(G.Thead,{ref:Qe,children:_e?e.jsxs(e.Fragment,{children:[e.jsxs(G.Tr,{children:[L&&tn({rowSpan:2}),Ne.map(y=>y.isGroup?e.jsx(G.Th,{colSpan:y.leaves.length,style:{textAlign:"center",position:"sticky",top:0,zIndex:2,backgroundColor:gt},children:e.jsx("span",{style:Vt,children:y.col.title})},`grp-${y.key}`):ur(y.leaves[0],{rowSpan:2})),V&&e.jsx(G.Th,{rowSpan:2,style:{position:"sticky",top:0,right:0,zIndex:3,width:1,padding:0,border:"none",backgroundColor:gt}})]}),e.jsx(G.Tr,{children:Ne.flatMap(y=>y.isGroup?y.leaves.map(j=>ur(j,{top:ct})):[])})]}):e.jsxs(G.Tr,{children:[L&&tn(),$o(),V&&e.jsx(G.Th,{style:{position:"sticky",top:0,right:0,zIndex:3,width:1,padding:0,border:"none",backgroundColor:gt}})]})}),e.jsx(G.Tbody,{children:R?Go:le.length===0?e.jsx(G.Tr,{children:e.jsx(G.Td,{colSpan:dr,children:nn})}):e.jsxs(e.Fragment,{children:[le.map((y,j)=>{const E=B==null?void 0:B(y,j,j>0?le[j-1]:void 0),ne=L&&st.has(Ee(y,j))?Sr:Nt(s==null?void 0:s(y,j));return e.jsxs(d.Fragment,{children:[E!=null&&E!==!1&&e.jsx(G.Tr,{children:e.jsx(G.Td,{colSpan:dr,style:{backgroundColor:gt},children:E})}),e.jsxs(G.Tr,{children:[L&&Ko(y,j,ne),ae.map(({col:ie,key:re},me)=>{var ln;const ge=(ln=ie.cellProps)==null?void 0:ln.call(ie,y,j,le);if(ge!=null&&ge.hidden)return null;const Je=K(me),Dt=Je&&me===q,Ke=ar(ie,y,j),St=typeof ie.bg=="function"?ie.bg(y,j,le):ie.bg,sn=Nt(St)??ne;return e.jsx(G.Td,{className:Je?"sa-tl-frozen":void 0,colSpan:ge==null?void 0:ge.colSpan,rowSpan:ge==null?void 0:ge.rowSpan,numeric:ie.numeric,style:{textAlign:Et(ie.align),width:ft(ie,me),minWidth:ie.minWidth,position:Je?"sticky":void 0,left:Je?Ie(me):void 0,zIndex:Je?1:void 0,boxShadow:Dt?Pn:void 0,...sn?{"--sa-tl-bg":sn}:{}},children:typeof Ke=="string"?e.jsx(v.Text,{style:{whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",textAlign:Et(ie.align)},children:Ke}):Ke},`tl-cell-${j}-${re}`)}),V&&e.jsx(G.Td,{style:{position:"sticky",right:0,width:1,padding:0,overflow:"visible",zIndex:2,border:"none"},children:Jo(y,j)})]})]},Ee(y,j))}),M!=null&&e.jsx(G.Tr,{children:e.jsx(G.Td,{colSpan:dr,children:M})})]})}),Wt&&e.jsx(G.Tfoot,{className:D?"sa-tl-sticky-foot":void 0,children:Wt})]}),mr=z?le.findIndex((y,j)=>Ee(y,j)===z.rowKey):-1,gr=mr>=0?le[mr]:null;return e.jsxs(e.Fragment,{children:[e.jsx(x.Box,{ref:Ue,fullWidth:!0,style:{overflow:"auto",height:S??Ae},children:te?e.jsxs(e.Fragment,{children:[ns,Wt&&!R&&le.length>0&&e.jsx(x.Box,{style:{borderTop:kt},children:e.jsx(G.Table,{fullWidth:!0,size:o,className:"sa-table-layout",children:e.jsx(G.Tbody,{children:Wt})})})]}):is}),z&&gr&&e.jsx("div",{className:"sa-tl-kebab-menu",style:{top:z.top,right:z.right},onClick:y=>y.stopPropagation(),children:Rt(gr).map(y=>e.jsx("div",{style:{padding:"2px 4px"},children:At(y,gr,mr,{showLabel:!0,size:"sm"})},y.key))})]})},kr=t=>t==="asc"||t==="desc",Ui=(t={})=>{const{sortKeyParam:r="sortBy",sortOrderParam:n="sortOrder",pageKey:s="page",defaultSort:o=null,paramKeys:i,scopeId:l,storage:c=Jr}=t,{searchParams:a,setSearchParams:u,searchQueries:f}=Ve(),g=a.toString(),m=l?Ct.tableSort(l):void 0,p=d.useRef(!1);d.useEffect(()=>{if(p.current||(p.current=!0,!m)||a.has(r)||a.has(n))return;const C=c.get(m);!(C!=null&&C.key)||!kr(C.direction)||u({...Object.fromEntries(a.entries()),[r]:C.key,[n]:C.direction},{replace:!0})},[]);const S=d.useMemo(()=>{const C=a.get(r),D=a.get(n);return C&&kr(D)?{key:C,direction:D}:o},[g,r,n,o]);d.useEffect(()=>{if(!m)return;const C=a.get(r),D=a.get(n);C&&kr(D)?c.set(m,{key:C,direction:D}):c.remove(m)},[g,m,r,n,c]);const b=(i==null?void 0:i.sortBy)??"sortBy",I=(i==null?void 0:i.sortOrder)??"sortOrder",B=d.useMemo(()=>S?{[b]:S.key,[I]:S.direction}:{},[S,b,I]),M=d.useCallback(C=>{const D={...f};C?(D[r]=C.key,D[n]=C.direction):(delete D[r],delete D[n]),delete D[s],u(D)},[f,r,n,s,u]);return{sort:S,setSort:M,params:B}},er=({of:t,render:r})=>d.Children.toArray(t==null?void 0:t.map((n,s,o)=>r(n,s,o))),ue=({condition:t,fallback:r,children:n,loading:s,isLoading:o})=>e.jsx(e.Fragment,{children:o?s:t?n:r}),fe=t=>e.jsx(v.Text,{...t,fontSize:t.fontSize||"md",fontWeight:t.fontWeight||"medium",color:t.color||"gray-700",children:t.children}),lt=t=>e.jsx(v.Text,{color:"red-600",fontSize:"sm",children:t.message}),Ji=({size:t="md",direction:r="vertical",requiredTitle:n="(Required)",fullWidth:s=!1,...o})=>{var c,a,u;const i=o.hideMessageError||!1,l=r==="horizontal"?t==="sm"?342:t==="lg"?400:342:void 0;return e.jsxs(x.Box,{gap:r==="horizontal"?"spacing-96":"sm",direction:r==="horizontal"?"row":"column",...o.containerProps,children:[o.title&&e.jsx(ue,{condition:!!o.inputProps.required,fallback:e.jsxs(x.Box,{direction:"column",customMaxWidth:l,fullWidth:s,children:[e.jsx(fe,{children:o.title}),e.jsx(v.Text,{fontSize:t,color:"gray-500",children:o.description})]}),children:e.jsxs(x.Box,{direction:"column",customMaxWidth:l,fullWidth:s,children:[e.jsxs(ce.Flex,{direction:"row",gap:"xs",align:"center",children:[e.jsx(fe,{fontSize:t,children:o.title}),e.jsx(fe,{color:"error",fontSize:t,children:n}),e.jsx(ue,{condition:!!((c=o.tooltip)!=null&&c.label),children:e.jsx(Fe.Tooltip,{label:(a=o.tooltip)==null?void 0:a.label,arrowPosition:(u=o.tooltip)==null?void 0:u.arrowPosition,focusable:!0,...o.tooltip,children:e.jsx(F.Icon,{name:"InfoCircle",size:t==="lg"?"sm":"xs",style:{color:"var(--sa-color-info-500, #00abeb)",marginTop:"6px"}})})})]}),e.jsx(ue,{condition:!!o.description,children:e.jsx(v.Text,{fontSize:t,color:"gray-500",children:o.description})})]})}),e.jsxs(x.Box,{direction:"column",gap:"xs",fullWidth:o.inputProps.fullWidth||!1,children:[e.jsx(dt.Input,{ref:o.inputRef,size:t,...o.inputProps,status:o.errorMessage?"error":"default",fullWidth:!0}),!i&&o.errorMessage&&e.jsx(lt,{message:o.errorMessage}),o.inputProps.extended&&o.inputProps.extended]})]})},Yi=({size:t="md",direction:r="vertical",requiredTitle:n="(Required)",fullWidth:s=!1,...o})=>{var c,a,u;const i=o.hideMessageError||!1,l=r==="horizontal"?t==="sm"?342:t==="lg"?400:342:void 0;return e.jsxs(x.Box,{gap:r==="horizontal"?"spacing-96":"sm",direction:r==="horizontal"?"row":"column",onClick:o.onClickContainer,children:[o.title&&e.jsx(ue,{condition:!!o.inputProps.required,fallback:e.jsxs(x.Box,{direction:"column",customMaxWidth:l,fullWidth:s,children:[e.jsx(fe,{children:o.title}),e.jsx(v.Text,{fontSize:t,color:"gray-500",children:o.description})]}),children:e.jsxs(x.Box,{direction:"column",customMaxWidth:l,fullWidth:s,children:[e.jsxs(ce.Flex,{direction:"row",gap:"xs",align:"center",children:[e.jsx(fe,{fontSize:t,children:o.title}),e.jsx(fe,{color:"error",fontSize:t,children:n}),e.jsx(ue,{condition:!!((c=o.tooltip)!=null&&c.label),children:e.jsx(Fe.Tooltip,{label:(a=o.tooltip)==null?void 0:a.label,arrowPosition:(u=o.tooltip)==null?void 0:u.arrowPosition,focusable:!0,...o.tooltip,children:e.jsx(F.Icon,{name:"InfoCircle",size:t==="lg"?"sm":"xs",style:{color:"var(--sa-color-info-500, #00abeb)",marginTop:"6px"}})})})]}),e.jsx(ue,{condition:!!o.description,children:e.jsx(v.Text,{fontSize:t,color:"gray-500",children:o.description})})]})}),e.jsxs(x.Box,{direction:"column",gap:"xs",fullWidth:o.inputProps.fullWidth||!1,children:[e.jsx(x.Box,{direction:"column",style:{width:o.inputProps.fullWidth?"100%":r==="horizontal"&&o.customWidth?o.customWidth:r==="horizontal"?"343px":""},children:e.jsx(jt.Dropdown,{size:t,...o.inputProps,error:!!o.errorMessage})}),!i&&o.errorMessage&&e.jsx(lt,{message:o.errorMessage}),o.inputProps.extended&&o.inputProps.extended]})]})},Xi=(t,r)=>typeof t=="string"&&t||r==="error"?"var(--sa-border-danger)":"var(--sa-border-subtle)",$i=t=>{var c;const[r,n]=d.useState(!1),s=a=>{a.preventDefault(),a.stopPropagation()},o=a=>{a.preventDefault(),a.stopPropagation(),a.dataTransfer&&t.handleOnFileChange(a.dataTransfer.files.item(0))},i=a=>{a.preventDefault(),n(!0)},l=a=>{a.preventDefault(),n(!1)};return e.jsxs(x.Box,{width:"width-full",paddingInline:"md",direction:"row",gap:"sm",align:"center",onClick:t.handleOnClick,onDragOver:s,onDrop:o,onDragEnter:i,onDragLeave:l,paddingBlock:"md",borderRadius:"rounded-md",style:{border:r?"1px solid var(--sa-border-info)":`1px solid ${Xi(t.errorMessage,t.status)}`},children:[e.jsx(F.Icon,{name:"Upload",size:"lg",style:{width:30,height:30}}),e.jsxs(ce.Flex,{direction:"column",gap:"xs",children:[e.jsxs(ce.Flex,{direction:"row",gap:"xs",children:[e.jsx(v.Text,{fontWeight:"medium",color:"gray-500",style:{textWrap:"nowrap"},fontSize:t.isDesktop?"md":"sm",children:"Click your upload"}),e.jsx(v.Text,{fontWeight:"medium",style:{textWrap:"nowrap"},fontSize:t.isDesktop?"md":"sm",children:"or Drag & Drop"})]}),e.jsx(v.Text,{fontSize:"sm",color:"gray-500",children:(c=t.fileSupports)==null?void 0:c.map(a=>a.toLocaleUpperCase()).join(", ")})]})]})};function Ki(t){return t.split(" ").map(r=>r[0]).join("").slice(0,2).toUpperCase()}const Lo=t=>{const r={day:"2-digit",month:"short",year:"numeric"};return t.toLocaleDateString("id-ID",r)},el=t=>{const r={Jan:0,Feb:1,Mar:2,Apr:3,Mei:4,Jun:5,Jul:6,Agu:7,Sep:8,Okt:9,Nov:10,Des:11},n=t.split(" ");if(n.length!==3)return null;const s=parseInt(n[0],10),o=r[n[1]],i=parseInt(n[2],10);return isNaN(s)||isNaN(o)||isNaN(i)?null:new Date(i,o,s)};function tl(t,r=!0){if(!t)return"Rp 0";const n=typeof t=="number"?t.toString():t;if(isNaN(Number(n)))return"Rp 0";const s=n.split("."),o=s[0].replace(/\B(?=(\d{3})+(?!\d))/g,"."),i=s.length===2?o+"."+s[1]:o;return r?"Rp"+i:i}String.prototype.toTitleCase=function(){return this.toLowerCase().split(" ").map(t=>t.charAt(0).toUpperCase()+t.slice(1)).join(" ")};String.prototype.toNumber=function(){return Number(this)};const rl=t=>{const r=t.split(" ");let n=r[0].charAt(0);return r.length>1&&(n+=""+r[1].charAt(0)),n.toUpperCase()};function nl(t){const r=typeof t=="string"?new Date(t):t;if(isNaN(r.getTime()))throw new Error("Invalid date format");const n=r.getFullYear(),s=String(r.getMonth()+1).padStart(2,"0"),o=String(r.getDate()).padStart(2,"0");return`${n}-${s}-${o}`}const ol="sa-admin",et=t=>`var(--${ol}-${t})`,sl={base:{borderColor:et("base-border-color"),textColor:et("base-text-color"),iconColor:et("base-icon-color"),placeholderColor:et("base-placeholder-color")},document:{bgColor:et("document-bg-color")},sidebar:{bgColor:et("sidebar-bg-color"),borderColor:et("sidebar-border-color"),maxWidth:et("sidebar-max-width"),width:et("sidebar-width"),collapseWidth:et("sidebar-collapse-width"),collapseV2Width:et("sidebar-v2-collapse-width")}},il=24*60*60*1e3,ll=t=>{const r="14px poppins",s=document.createElement("canvas").getContext("2d");s.font=r;const o=s.measureText(t).width;return Number(Math.ceil(o))},cl=/^[^\s@]+@[^\s@]+\.[^\s@]+$/,al=/--+/,dl=/-$/;function ul(t,r){return JSON.stringify(t)!==JSON.stringify(r)}function xl(t){return/^(?:\+62|62|0)8[1-9][0-9]{7,10}$/.test(t)}function hl(t){return/^[A-Za-z\s]+$/.test(t)}const fl=t=>{const r=/^[0-9]$/,n=["ArrowLeft","ArrowRight","ArrowUp","ArrowDown","Backspace","Delete","Enter","Tab"];(t.ctrlKey||t.metaKey)&&(t.key==="a"||t.key==="c"||t.key==="v")||!r.test(t.key)&&!n.includes(t.key)&&t.preventDefault()},ml=t=>{const r=/^[0-9]$/,n=["ArrowLeft","ArrowRight","ArrowUp","ArrowDown","Backspace","Delete","Enter","Tab"];(t.ctrlKey||t.metaKey)&&t.key==="v"||r.test(t.key)&&!n.includes(t.key)&&t.preventDefault()},gl=t=>{const r=/^[0-9.]$/,n=["ArrowLeft","ArrowRight","ArrowUp","ArrowDown","Backspace","Delete","Enter","Tab"];(t.ctrlKey||t.metaKey)&&t.key==="v"||!r.test(t.key)&&!n.includes(t.key)&&t.preventDefault()},yl=t=>cl.test(t);function pl(t){return!(al.test(t)||dl.test(t))}const jl=t=>{const r=["ArrowLeft","ArrowRight","ArrowUp","ArrowDown","Backspace","Delete","Enter","Tab","Home","End"];if((t.ctrlKey||t.metaKey)&&["a","c","v","x"].includes(t.key.toLowerCase()))return;const n=t.currentTarget.value;/^[0-9]$/.test(t.key)||t.key==="."&&!n.includes(".")||t.key==="-"&&n.length===0&&!n.includes("-")||r.includes(t.key)||t.preventDefault()},bl=t=>{const r=document.getElementById(t);if(r){const n=r.getBoundingClientRect(),s=window.scrollY+n.top-80;window.scrollTo({top:s,behavior:"smooth"})}};function vl(t){const r=t.toLowerCase();if(["kb","mb","gb"].find(i=>r.endsWith(i)))return t;const o=Number(t);if(isNaN(o))throw new Error("Invalid size format");return o>=1e6?`${(o/1e6).toFixed(2)}MB`:o>=1e3?`${(o/1e3).toFixed(2)}KB`:`${o}B`}function Cl(t){const r=t.split("/");return r[r.length-1]}const wl=t=>{var r,n;return e.jsxs(x.Box,{width:"width-full",paddingInline:"md",height:"height-full",direction:"row",justify:"space-between",align:"center",onClick:t.handleOnClickFile,fullHeight:!0,paddingBlock:"md",id:"file-item",borderRadius:"rounded-md",style:{border:"1px solid var(--sa-border-subtle)",cursor:"pointer"},children:[e.jsxs(ce.Flex,{direction:"row",align:"center",gap:"sm",style:{flex:1,minWidth:0},children:[e.jsx(F.Icon,{name:"DocumentFilled",size:"lg",style:{color:"var(--sa-icon-brand)",width:30,height:30,flexShrink:0}}),e.jsxs(ce.Flex,{direction:"column",style:{minWidth:0,flex:1},children:[e.jsx(v.Text,{fontWeight:"bold",style:{textOverflow:"ellipsis",whiteSpace:"nowrap",overflow:"hidden"},children:t.defaultFile?Cl(t.defaultFile.url):(r=t.fileSelected)==null?void 0:r.name}),t.defaultFile?(t.defaultFile.size||t.defaultFile.date)&&e.jsxs(ce.Flex,{direction:"row",gap:"xs",align:"center",children:[t.defaultFile.size&&e.jsx(v.Text,{fontSize:"sm",fontWeight:"medium",children:t.defaultFile.size}),t.defaultFile.size&&t.defaultFile.date&&e.jsx(F.Icon,{name:"Dot",size:"xs"}),t.defaultFile.date&&e.jsx(v.Text,{fontSize:"sm",fontWeight:"medium",style:{textWrap:"nowrap"},children:t.defaultFile.date})]}):e.jsxs(ce.Flex,{direction:"row",gap:"xs",align:"center",children:[e.jsx(v.Text,{fontSize:"sm",fontWeight:"medium",children:vl(((n=t.fileSelected)==null?void 0:n.size.toString())||"100000")}),e.jsx(F.Icon,{name:"Dot",size:"xs"}),e.jsx(v.Text,{fontSize:"sm",fontWeight:"medium",style:{textWrap:"nowrap"},children:Lo(new Date)})]})]})]}),e.jsx(H.Button,{size:"xs",variant:"tertiary",tone:"error",type:"button",onClick:s=>{s.stopPropagation(),t.handleOnDeleteFile()},iconLeft:e.jsx(F.Icon,{name:"Trash1"})})]})},To=({status:t="default",labelPosition:r="outside-top",...n})=>{var m;const s=d.useRef(null),o=()=>{if(n.defaultFile){window.open(n.defaultFile.url);return}s.current&&s.current.click()},i=Ce.useMediaQuery("md"),l=t==="error"||typeof n.errorMessage=="string"&&!!n.errorMessage,c=n.label?e.jsxs(ce.Flex,{direction:"row",align:"center",gap:"xs",children:[e.jsx(v.Text,{style:{fontSize:"14px",fontWeight:500,color:"var(--sa-text-primary)"},children:n.label}),n.optional&&e.jsx("span",{style:{background:"var(--sa-background-neutral)",border:"1px solid var(--sa-border-subtle)",borderRadius:"4px",padding:"0 8px",fontSize:"10px",fontWeight:500,lineHeight:"18px",color:"var(--sa-text-primary)",display:"inline-flex",alignItems:"center"},children:"Optional"}),n.required&&e.jsx("span",{style:{fontSize:"14px",fontWeight:500,color:"var(--sa-text-error)"},children:"*"})]}):null,a=n.description?e.jsx(v.Text,{style:{fontSize:"12px",fontWeight:400,color:"var(--sa-text-subtlest, #6b6e76)",lineHeight:"18px"},children:n.description}):null,u=e.jsxs(e.Fragment,{children:[n.helperText&&e.jsx(v.Text,{style:{fontSize:"12px",fontWeight:400,color:"var(--sa-text-subtlest, #6b6e76)",lineHeight:"18px"},children:n.helperText}),n.errorText&&t==="error"&&e.jsx(v.Text,{style:{fontSize:"12px",fontWeight:400,color:"var(--sa-text-error, #a4133c)",lineHeight:"18px"},children:n.errorText}),n.errorMessage&&!n.errorText&&e.jsx(v.Text,{style:{fontSize:"12px",fontWeight:400,color:"var(--sa-text-error, #a4133c)",lineHeight:"18px"},children:n.errorMessage})]}),f=e.jsx("input",{type:"file",style:{display:"none"},ref:s,onChange:p=>{var S;return n.handleOnChangeFile(((S=p.target.files)==null?void 0:S.item(0))||null)},accept:(m=n.fileSupportOption)==null?void 0:m.map(p=>"."+(p==null?void 0:p.toLowerCase())).join(", ")}),g=e.jsxs(x.Box,{direction:"column",fullWidth:!0,style:{minHeight:"69px"},borderRadius:"rounded-md",display:"flex",justify:"center",align:"center",cursor:"pointer",gap:"md",...n.containerProps,children:[f,(n.fileSelected||n.defaultFile)&&e.jsx(wl,{fileSelected:n.fileSelected,defaultFile:n.defaultFile,handleOnDeleteFile:n.handleOnDeleteFile,handleOnClickFile:o}),!n.fileSelected&&!n.defaultFile&&e.jsx($i,{fileSupports:n.fileSupportOption,isDesktop:i,errorMessage:l?n.errorText||n.errorMessage||" ":void 0,status:l?"error":"default",handleOnClick:o,handleOnFileChange:n.handleOnChangeFile})]});return r==="outside-left"?e.jsxs(ce.Flex,{direction:"row",align:"flex-start",gap:"sm",style:{width:"100%"},children:[e.jsxs(ce.Flex,{direction:"column",gap:"xs",style:{width:"40%",minWidth:"120px",paddingTop:"10px"},children:[c,a]}),e.jsxs(ce.Flex,{direction:"column",gap:"sm",style:{flex:1,minWidth:0},children:[g,u]})]}):e.jsxs(ce.Flex,{direction:"column",gap:"sm",style:{width:"100%"},children:[c,a,g,u]})},Dl=({size:t="md",direction:r="vertical",requiredTitle:n="(Required)",fullWidth:s=!1,...o})=>{var c,a,u;const i=o.hideMessageError||!1,l=r==="horizontal"?t==="sm"?342:t==="lg"?400:342:void 0;return e.jsxs(x.Box,{gap:r==="horizontal"?"spacing-96":"sm",direction:r==="horizontal"?"row":"column",...o.containerProps,children:[o.title&&e.jsx(ue,{condition:!!o.inputProps.required,fallback:e.jsxs(x.Box,{direction:"column",customMaxWidth:l,fullWidth:s,children:[e.jsx(fe,{children:o.title}),e.jsx(v.Text,{fontSize:t,color:"gray-500",children:o.description})]}),children:e.jsxs(x.Box,{direction:"column",customMaxWidth:l,fullWidth:s,children:[e.jsxs(ce.Flex,{direction:"row",gap:"xs",align:"center",children:[e.jsx(fe,{fontSize:t,children:o.title}),e.jsx(fe,{color:"error",fontSize:t,children:n}),e.jsx(ue,{condition:!!((c=o.tooltip)!=null&&c.label),children:e.jsx(Fe.Tooltip,{label:(a=o.tooltip)==null?void 0:a.label,arrowPosition:(u=o.tooltip)==null?void 0:u.arrowPosition,focusable:!0,...o.tooltip,children:e.jsx(F.Icon,{name:"InfoCircle",size:t==="lg"?"sm":"xs",style:{color:"var(--sa-color-info-500, #00abeb)",marginTop:"6px"}})})})]}),e.jsx(ue,{condition:!!o.description,children:e.jsx(v.Text,{fontSize:t,color:"gray-500",children:o.description})})]})}),e.jsxs(ce.Flex,{direction:"column",gap:"xs",children:[e.jsx(To,{...o.inputProps,status:o.errorMessage?"error":"default"}),!i&&o.errorMessage&&e.jsx(lt,{message:o.errorMessage})]})]})},Sl=({size:t="md",direction:r="vertical",requiredTitle:n="(Required)",fullWidth:s=!1,required:o=!1,...i})=>{var a,u,f,g;const l=i.hideMessageError||!1,c=r==="horizontal"?t==="sm"?342:t==="lg"?400:342:void 0;return e.jsxs(x.Box,{gap:r==="horizontal"||r==="horizontal-inline"?"spacing-96":"sm",direction:r==="horizontal"||r==="horizontal-inline"?"row":"column",...i.containerProps,children:[i.title&&e.jsx(ue,{condition:!!o,fallback:e.jsxs(x.Box,{direction:"column",customMaxWidth:c,fullWidth:s,children:[e.jsx(fe,{children:i.title}),e.jsx(Xe.Body3,{props:{color:"gray-500"},children:i.description})]}),children:e.jsxs(x.Box,{direction:"column",customMaxWidth:c,fullWidth:s,children:[e.jsxs(ce.Flex,{direction:"row",gap:"xs",align:"center",children:[e.jsx(fe,{fontSize:t,children:i.title}),e.jsx(fe,{color:"error",fontSize:t,children:n}),e.jsx(ue,{condition:!!((a=i.tooltip)!=null&&a.label),children:e.jsx(Fe.Tooltip,{label:(u=i.tooltip)==null?void 0:u.label,arrowPosition:(f=i.tooltip)==null?void 0:f.arrowPosition,focusable:!0,...i.tooltip,children:e.jsx(F.Icon,{name:"InfoCircle",size:t==="lg"?"sm":"xs",style:{color:"var(--sa-color-info-500, #00abeb)",marginTop:"6px"}})})})]}),e.jsx(ue,{condition:!!i.description,children:e.jsx(v.Text,{fontSize:t,color:"gray-500",children:i.description})})]})}),e.jsx(x.Box,{gap:r==="horizontal-inline"?"xl":"md",direction:r==="horizontal-inline"?"row":"column",align:"flex-start",children:e.jsx(er,{of:(g=i.checkBoxesList)==null?void 0:g.map(m=>({...m,isChecked:i.checkBoxesAreChecked.includes(m.id)})),render:m=>m.renderBadge?e.jsxs(x.Box,{direction:"row",justify:"space-between",gap:"lg",...i.badgeContainerProps,children:[e.jsx(nt.Checkbox,{name:m.name,value:m.id,checked:m.isChecked,onChange:p=>i.onChecked(p.target.value,m),label:m.name,description:m.description}),m.renderBadge]}):e.jsx(nt.Checkbox,{name:m.name,value:m.id,checked:m.isChecked,onChange:p=>i.onChecked(p.target.value,m),label:m.name,description:m.description})})}),!l&&i.errorMessage&&e.jsx(lt,{message:i.errorMessage})]})},kl=({position:t="vertical",size:r="md",fullWidth:n=!1,...s})=>{var i;const o=t==="horizontal-inline"||t==="horizontal-block"?r==="sm"?342:r==="lg"?400:342:void 0;return e.jsxs(x.Box,{gap:t==="horizontal-inline"||t==="horizontal-block"?"spacing-96":"sm",direction:t==="horizontal-inline"||t==="horizontal-block"?"row":"column",children:[e.jsx(ue,{condition:!!s.description||!!s.title,children:e.jsxs(x.Box,{direction:"column",customMaxWidth:o,fullWidth:n,children:[s.title&&e.jsx(fe,{children:s.title}),e.jsx(ue,{condition:!!s.description,children:e.jsx(v.Text,{color:"gray-500",children:s.description})})]})}),e.jsx(x.Box,{gap:"sm",direction:t==="horizontal"||t==="horizontal-inline"?"row":"column",align:"flex-start",flexWrap:"wrap",children:e.jsx(er,{of:(i=s.radioList)==null?void 0:i.map(l=>({...l,isChecked:s.radioIsChecked===l.id})),render:({value:l,id:c,isChecked:a,subInput:u,label:f,description:g})=>e.jsxs(x.Box,{direction:"column",gap:"xs",customMaxWidth:o,children:[e.jsx(Ir.Radio,{id:`${c.toString()}-${l}`,name:s.groupName||f,label:f,value:l,checked:a,onChange:m=>s.onChecked({id:c,label:m.target.name,value:m.target.value}),disabled:s.disableAll},c),g&&e.jsx(v.Text,{color:"gray-500",style:{marginLeft:28},children:g}),u]})})}),s.errorMessage&&e.jsx(lt,{message:s.errorMessage})]})},Bl=({size:t="md",direction:r="vertical",requiredTitle:n="(Required)",fullWidth:s=!1,...o})=>{var c,a,u;const i=o.hideMessageError||!1,l=r==="horizontal"?t==="sm"?342:t==="lg"?400:342:void 0;return e.jsxs(x.Box,{gap:r==="horizontal"?"spacing-96":"sm",direction:r==="horizontal"?"row":"column",...o.containerProps,children:[o.title&&e.jsx(ue,{condition:!!o.inputProps.required,fallback:e.jsxs(x.Box,{direction:"column",customMaxWidth:l,fullWidth:s,children:[e.jsx(fe,{children:o.title}),e.jsx(v.Text,{fontSize:t,color:"gray-500",children:o.description})]}),children:e.jsxs(x.Box,{direction:"column",customMaxWidth:l,fullWidth:s,children:[e.jsxs(ce.Flex,{direction:"row",gap:"xs",align:"center",children:[e.jsx(fe,{fontSize:t,children:o.title}),e.jsx(fe,{color:"error",fontSize:t,children:n}),e.jsx(ue,{condition:!!((c=o.tooltip)!=null&&c.label),children:e.jsx(Fe.Tooltip,{label:(a=o.tooltip)==null?void 0:a.label,arrowPosition:(u=o.tooltip)==null?void 0:u.arrowPosition,focusable:!0,...o.tooltip,children:e.jsx(F.Icon,{name:"InfoCircle",size:t==="lg"?"sm":"xs",style:{color:"var(--sa-color-info-500, #00abeb)",marginTop:"6px"}})})})]}),e.jsx(ue,{condition:!!o.description,children:e.jsx(v.Text,{fontSize:t,color:"gray-500",children:o.description})})]})}),e.jsxs(ce.Flex,{direction:"column",gap:"xs",children:[e.jsx(Mr.Textarea,{ref:o.inputRef,size:t,...o.inputProps,status:o.errorMessage?"error":"default"}),!i&&o.errorMessage&&e.jsx(lt,{message:o.errorMessage})]})]})},El=({size:t="md",direction:r="vertical",requiredTitle:n="(Required)",required:s=!1,fullWidth:o=!1,...i})=>{var c,a,u;const l=r==="horizontal"?t==="sm"?342:t==="lg"?400:342:void 0;return e.jsxs(x.Box,{gap:r==="horizontal"?"spacing-96":"sm",direction:r==="horizontal"?"row":"column",...i.containerProps,children:[i.title&&e.jsx(ue,{condition:s,fallback:e.jsxs(x.Box,{direction:"column",customMaxWidth:l,fullWidth:o,children:[e.jsx(fe,{children:i.title}),e.jsx(v.Text,{fontSize:t,color:"gray-500",children:i.titleDescription})]}),children:e.jsxs(x.Box,{direction:"column",customMaxWidth:l,fullWidth:o,children:[e.jsxs(ce.Flex,{direction:"row",gap:"xs",align:"center",children:[e.jsx(fe,{fontSize:t,children:i.title}),e.jsx(fe,{color:"error",fontSize:t,children:n}),e.jsx(ue,{condition:!!((c=i.tooltip)!=null&&c.label),children:e.jsx(Fe.Tooltip,{label:(a=i.tooltip)==null?void 0:a.label,arrowPosition:(u=i.tooltip)==null?void 0:u.arrowPosition,focusable:!0,...i.tooltip,children:e.jsx(F.Icon,{name:"InfoCircle",size:t==="lg"?"sm":"xs",style:{color:"var(--sa-color-info-500, #00abeb)",marginTop:"6px"}})})})]}),e.jsx(ue,{condition:!!i.titleDescription,children:e.jsx(v.Text,{fontSize:t,color:"gray-500",children:i.titleDescription})})]})}),e.jsx(vt.Toggle,{checked:i.checked,onChange:i.onChange,label:i.label,description:i.description}),i.errorMessage&&e.jsx(lt,{message:i.errorMessage})]})},Fl=({variant:t="primary",size:r="md",...n})=>{const s=pt.useColor(),o=l=>{var a,u,f,g,m,p;if(!l)return;const c=n.disabled?"var(--sa-text-disable, #181a198f)":t==="secondary"?"var(--sa-text-subtle, #8c8f97)":t==="secondary-danger"?(u=(a=s==null?void 0:s.computed)==null?void 0:a.red)==null?void 0:u[600]:t==="secondary-primary"?(g=(f=s==null?void 0:s.computed)==null?void 0:f.blue)==null?void 0:g[700]:(p=(m=s==null?void 0:s.computed)==null?void 0:m.gray)==null?void 0:p[50];return e.jsx(F.Icon,{name:l,size:r,style:{color:c}})},i=()=>{var c,a,u,f;if(t!=="secondary-danger"&&t!=="secondary-primary")return n.title;const l={color:n.disabled?"var(--sa-text-disable, #181a198f)":t==="secondary-danger"?(a=(c=s==null?void 0:s.computed)==null?void 0:c.red)==null?void 0:a[600]:(f=(u=s==null?void 0:s.computed)==null?void 0:u.blue)==null?void 0:f[700]};switch(r){case"xs":return e.jsx(Xe.Body2,{props:{style:l},children:n.title});case"sm":case"md":return e.jsx(Xe.SubH3,{props:{style:l},children:n.title});case"lg":return e.jsx(Xe.SubH2,{props:{style:l},children:n.title});default:return n.title}};return e.jsx(H.Button,{fullWidth:!0,disabled:n.disabled,primary:t==="primary",secondary:t==="secondary"||t==="secondary-danger"||t==="secondary-primary",success:t==="success",onClick:n.onClick,type:n.type,iconLeft:o(n.iconLeft),iconRight:o(n.iconRight),size:r,children:i()})},Ml=t=>e.jsx(Xe.H5,{props:{...t},children:t.title}),Il=({size:t="md",direction:r="vertical",requiredTitle:n="(Required)",fullWidth:s=!1,...o})=>{var c,a,u;const i=o.hideMessageError||!1,l=r==="horizontal"?t==="sm"?342:t==="lg"?400:342:void 0;return e.jsxs(x.Box,{gap:r==="horizontal"?"spacing-96":"sm",direction:r==="horizontal"?"row":"column",onClick:o.onClickContainer,children:[o.title&&e.jsx(ue,{condition:!!o.inputProps.required,fallback:e.jsxs(x.Box,{direction:"column",customMaxWidth:l,fullWidth:s,children:[e.jsx(fe,{children:o.title}),e.jsx(v.Text,{fontSize:t,color:"gray-500",children:o.description})]}),children:e.jsxs(x.Box,{direction:"column",customMaxWidth:l,fullWidth:s,children:[e.jsxs(ce.Flex,{direction:"row",gap:"xs",align:"center",children:[e.jsx(fe,{fontSize:t,children:o.title}),e.jsx(fe,{color:"error",fontSize:t,children:n}),e.jsx(ue,{condition:!!((c=o.tooltip)!=null&&c.label),children:e.jsx(Fe.Tooltip,{label:(a=o.tooltip)==null?void 0:a.label,arrowPosition:(u=o.tooltip)==null?void 0:u.arrowPosition,focusable:!0,...o.tooltip,children:e.jsx(F.Icon,{name:"InfoCircle",size:t==="lg"?"sm":"xs",style:{color:"var(--sa-color-info-500, #00abeb)",marginTop:"6px"}})})})]}),e.jsx(ue,{condition:!!o.description,children:e.jsx(v.Text,{fontSize:t,color:"gray-500",children:o.description})})]})}),e.jsxs(ce.Flex,{direction:"column",gap:"xs",children:[e.jsx(x.Box,{direction:"column",style:{width:r==="horizontal"&&o.customWidth?o.customWidth:r==="horizontal"?"343px":""},children:e.jsx(ht.StarasiaDate,{size:t,...o.inputProps,status:o.errorMessage?"error":void 0})}),!i&&o.errorMessage&&e.jsx(lt,{message:o.errorMessage})]})]})};async function Ll(t,r){const n=new Image;n.src=t,await new Promise((i,l)=>{n.onload=i,n.onerror=l});const s=document.createElement("canvas");s.width=r.width,s.height=r.height;const o=s.getContext("2d",{alpha:!0});if(!o)throw new Error("No 2D context");return o.drawImage(n,r.x,r.y,r.width,r.height,0,0,r.width,r.height),new Promise((i,l)=>{s.toBlob(c=>{if(!c)return l("Canvas is empty");const a=new File([c],"cropped.png",{type:"image/png"});i(a)},"image/png")})}const Nn={"1:1":1,"4:3":4/3,"16:9":16/9,"3:4":3/4,"9:16":9/16,"2:3":2/3,"3:2":3/2,"32:9":32/9},Oo=d.forwardRef(({handleUpload:t,urlImage:r,isUploading:n,croppedImage:s,setCroppedImage:o,size:i="96",aspect:l="1:1",containerProps:c,maxFileSize:a=2,onError:u},f)=>{const g=Ce.useMediaQuery("md"),[m,p]=d.useState(!1),[S,b]=d.useState(null),[I,B]=d.useState(!1),[M,C]=d.useState({x:0,y:0}),[D,A]=d.useState(1),[R,w]=d.useState(null);d.useEffect(()=>{r===null&&o(null)},[r]);const O=d.useCallback((z,P)=>{w(P)},[]),L=z=>{var ye;const P=(ye=z.target.files)==null?void 0:ye[0];if(!P)return;const se=new FileReader;se.onload=()=>{b(se.result),B(!0)},se.readAsDataURL(P)},U=async()=>{if(!(!S||!R))try{const z=await Ll(S,R);if(a&&z.size>a*1024*1024){u==null||u(`Ukuran file maksimal ${a}MB`);return}t==null||t(z);const P=URL.createObjectURL(z);o(P,z),B(!1)}catch{u==null||u("Gagal memproses gambar")}},J=d.useRef(null),N=()=>{J.current&&J.current.click()};d.useImperativeHandle(f,()=>({openFileDialog:()=>{var z;(z=J.current)==null||z.click()}}));const _=parseInt(i,10),X=Nn[l];let te,V;return X>=1?(V=_,te=_*X):(te=_,V=_/X),e.jsxs(x.Box,{direction:"column",display:"flex",position:"relative",bg:(c==null?void 0:c.bg)||"gray-200",borderStyle:(c==null?void 0:c.borderStyle)||"border-none",borderColor:(c==null?void 0:c.borderColor)||"gray-200",borderWidth:(c==null?void 0:c.borderWidth)||"border-2",borderRadius:(c==null?void 0:c.borderRadius)||"rounded-md",overflow:"overflow-hidden",align:"center",justify:"center",style:{width:c!=null&&c.fullWidth?"100%":`${te}px`,height:c!=null&&c.fullWidth?"auto":`${V}px`,aspectRatio:X,flexShrink:0},onMouseEnter:()=>p(!0),onMouseLeave:()=>p(!1),children:[s||r?e.jsx("img",{src:s||r||void 0,alt:"Profile",style:{objectFit:"cover",width:"100%",height:"100%"}}):e.jsx(x.Box,{display:"flex",direction:"column",align:"center",justify:"center",padding:"spacing-4",children:e.jsx(F.Icon,{name:"Image",style:{color:"var(--sa-text-subtle, #8c8f97)",width:Number(i)/2<40?Number(i)/2:40,height:Number(i)/2<40?Number(i)/2:40}})}),e.jsxs(x.Box,{direction:"column",position:"absolute",display:"flex",align:"center",justify:"center",cursor:"pointer",style:{inset:0,backgroundColor:"var(--sa-color-black-alpha-a30, #080f214c)",opacity:m?1:0,transition:"opacity 0.3s ease-in-out"},onClick:N,children:[e.jsx("input",{ref:J,type:"file",accept:"image/*",onChange:L,disabled:n,style:{display:"none"}}),e.jsxs(x.Box,{display:"flex",align:"center",gap:"spacing-2",direction:"row",children:[e.jsx(F.Icon,{name:"Edit3",style:{color:"var(--sa-background-primary, #ffffff)"}}),e.jsx(ue,{condition:i.toNumber()>80,children:e.jsx(v.Text,{color:"gray-50",fontSize:i.toNumber()>80?"sm":"md",fontWeight:"medium",children:"Edit Image"})})]})]}),n&&e.jsx(x.Box,{direction:"column",position:"absolute",display:"flex",align:"center",justify:"center",style:{inset:0,zIndex:20,backgroundColor:"var(--sa-color-white-alpha-a80, #e5e9f6cc)"},children:e.jsx(x.Box,{direction:"column",borderRadius:"rounded-full",style:{animation:"spin 1s linear infinite",border:"2px solid transparent",height:"2rem",width:"2rem"},borderColor:"info-600"})}),I&&Xt.createPortal(e.jsx("div",{style:{position:"fixed",inset:0,zIndex:19999,display:"flex",alignItems:"center",justifyContent:"center",backgroundColor:"rgba(0,0,0,0.6)"},onClick:()=>B(!1),children:e.jsxs("div",{style:{backgroundColor:"var(--sa-background-primary)",borderRadius:"var(--sa-radii-md)",boxShadow:"0 20px 60px rgba(0,0,0,0.3)",overflow:"hidden",width:g?l==="1:1"?"min(90vw, 480px)":`min(90vw, ${te*2}px)`:"calc(100vw - 2rem)",display:"flex",flexDirection:"column"},onClick:z=>z.stopPropagation(),children:[e.jsx("div",{style:{position:"relative",width:"100%",height:"20rem",backgroundColor:"var(--sa-color-gray-100)"},children:S&&e.jsx(ls,{image:S,crop:M,zoom:D,aspect:l?Nn[l]:void 0,onCropChange:C,onZoomChange:A,onCropComplete:O,objectFit:"contain",minZoom:.5,restrictPosition:!1})}),e.jsxs("div",{style:{display:"flex",justifyContent:"flex-end",gap:"0.5rem",padding:"0.75rem 1rem",borderTop:"1px solid var(--sa-border-subtle)"},children:[e.jsx(H.Button,{size:"sm",secondary:!0,onClick:()=>B(!1),children:"Cancel"}),e.jsx(H.Button,{size:"sm",primary:!0,onClick:U,children:"Crop"})]})]})}),document.body)]})}),Tl=({size:t="md",direction:r="vertical",requiredTitle:n="(Required)",fullWidth:s=!1,required:o=!1,...i})=>{var a,u,f;const l=i.hideMessageError||!1,c=r==="horizontal"?t==="sm"?342:t==="lg"?400:342:void 0;return e.jsxs(x.Box,{gap:r==="horizontal"?"spacing-96":"sm",direction:r==="horizontal"?"row":"column",...i.containerProps,children:[i.title&&e.jsx(ue,{condition:!!o,fallback:e.jsxs(x.Box,{direction:"column",customMaxWidth:c,fullWidth:s,children:[e.jsx(fe,{children:i.title}),e.jsx(v.Text,{fontSize:t,color:"gray-500",children:i.description})]}),children:e.jsxs(x.Box,{direction:"column",customMaxWidth:c,fullWidth:s,children:[e.jsxs(ce.Flex,{direction:"row",gap:"xs",align:"center",children:[e.jsx(fe,{fontSize:t,children:i.title}),e.jsx(fe,{color:"error",fontSize:t,children:n}),e.jsx(ue,{condition:!!((a=i.tooltip)!=null&&a.label),children:e.jsx(Fe.Tooltip,{label:(u=i.tooltip)==null?void 0:u.label,arrowPosition:(f=i.tooltip)==null?void 0:f.arrowPosition,focusable:!0,...i.tooltip,children:e.jsx(F.Icon,{name:"InfoCircle",size:t==="lg"?"sm":"xs",style:{color:"var(--sa-color-info-500, #00abeb)",marginTop:"6px"}})})})]}),e.jsx(ue,{condition:!!i.description,children:e.jsx(v.Text,{fontSize:t,color:"gray-500",children:i.description})})]})}),e.jsxs(ce.Flex,{direction:"column",gap:"xs",children:[e.jsx(Oo,{...i.inputProps}),!l&&i.errorMessage&&e.jsx(lt,{message:i.errorMessage})]})]})},Ol=({size:t="md",direction:r="vertical",requiredTitle:n="(Required)",fullWidth:s=!1,...o})=>{var l,c,a;const i=r==="horizontal"?t==="sm"?342:t==="lg"?400:342:void 0;return e.jsxs(x.Box,{gap:r==="horizontal"?"spacing-96":"sm",direction:r==="horizontal"?"row":"column",...o.containerProps,children:[o.title&&e.jsx(ue,{condition:!!o.inputProps.required,fallback:e.jsxs(x.Box,{direction:"column",customMaxWidth:i,fullWidth:s,children:[e.jsx(fe,{children:o.title}),e.jsx(v.Text,{fontSize:t,color:"gray-500",children:o.description})]}),children:e.jsxs(x.Box,{direction:"column",customMaxWidth:i,fullWidth:s,children:[e.jsxs(ce.Flex,{direction:"row",gap:"xs",align:"center",children:[e.jsx(fe,{fontSize:t,children:o.title}),e.jsx(fe,{color:"error",fontSize:t,children:n}),e.jsx(ue,{condition:!!((l=o.tooltip)!=null&&l.label),children:e.jsx(Fe.Tooltip,{label:(c=o.tooltip)==null?void 0:c.label,arrowPosition:(a=o.tooltip)==null?void 0:a.arrowPosition,focusable:!0,...o.tooltip,children:e.jsx(F.Icon,{name:"InfoCircle",size:t==="lg"?"sm":"xs",style:{color:"var(--sa-color-info-500, #00abeb)",marginTop:"6px"}})})})]}),e.jsx(ue,{condition:!!o.description,children:e.jsx(v.Text,{fontSize:t,color:"gray-500",children:o.description})})]})}),o.inputProps.extended&&o.inputProps.extended]})},Rl=({items:t,id:r,handleOnUpdate:n,width:s,toggleShow:o=!0,disabled:i=!1})=>{var f;const[l,c]=d.useState([]);d.useEffect(()=>{t&&c([...t.map(g=>({id:g.id,isActive:g.isActive}))])},[t]);const a=(f=l.find(g=>g.id===r))==null?void 0:f.isActive,u=d.useCallback(()=>{c(g=>g.map(m=>m.id===r?{...m,isActive:!m.isActive}:m)),n&&n(!a)},[r,n,a]);return e.jsx(x.Box,{direction:"row",gap:"md",style:{width:s},children:o&&e.jsx(vt.Toggle,{disabled:i,checked:a,onChange:u,label:a?"Active":"Inactive"})})},Al={InputText:Ji,InputDropdown:Yi,InputSingleFile:Dl,CheckBoxOptions:Sl,RadioOptions:kl,InputTextArea:Bl,ToggleForm:El,ActionButton:Fl,FormTitle:Ml,InputDate:Il,InputImgFile:Tl,Custom:Ol},Ro=({customBottom:t})=>{const[r,n]=d.useState(!1),s=()=>{window.scrollY>window.screenY?n(!0):n(!1)},o=()=>{window.scrollTo({top:0,behavior:"smooth"})};return d.useEffect(()=>(window.addEventListener("scroll",s),()=>{window.removeEventListener("scroll",s)}),[]),e.jsx(x.Box,{direction:"column",style:{position:"fixed",bottom:0,right:0},children:e.jsx(x.Box,{direction:"column",position:"absolute",style:{bottom:t||"1.6rem",right:"2rem",transform:r?"scale(1)":"scale(0)",transition:"transform 0.2s ease-in-out"},children:e.jsx(H.Button,{secondary:!0,size:"xs",onClick:o,type:"button",iconLeft:e.jsx(F.Icon,{width:16,size:"xs",name:"ArrowPullUp",style:{color:"var(--sa-background-brand, #04254f)"}})})})})},Ge="sa-sidepanel-item",_n="sa-sidepanel-item-styles",Wl="inset 3.5px 0 0 0 var(--sa-border-focused, #1a4fa0)",zl="inset -3.5px 0 0 0 var(--sa-border-focused, #1a4fa0)",Hl=`
|
|
57
|
+
`,document.head.appendChild(t)},Et=t=>t==="right"?"right":t==="center"?"center":"left",qi=/^(#|rgb|hsl|var\()/,Nt=t=>t?qi.test(t)?t:`var(--sa-background-${t})`:void 0,Zi=(t,r)=>{if(r)return t[r]},Gi=(t,r)=>t==null&&r==null?0:t==null?-1:r==null?1:typeof t=="number"&&typeof r=="number"?t-r:String(t).localeCompare(String(r)),Qi=({columns:t,data:r,getRowKey:n,rowBg:s,size:o="md",resizable:i=!1,layout:l="auto",widthStorageKey:c,columnState:a,onColumnStateChange:u,columnMenu:f=!1,sort:g,defaultSort:m,onSortChange:p,height:S,mobileLayout:b="cards",mobileBreakpoint:I="md",groupSeparator:B,summary:M,footer:C,stickyFooter:D=!1,emptyState:A,loading:R=!1,loadingRows:w=8,rowActions:O,selectable:L=!1,selectedKeys:U,defaultSelectedKeys:J,onSelectionChange:N,isRowSelectable:_})=>{_i();const te=!Ce.useMediaQuery(I)&&b!=="scroll",V=!!(O!=null&&O.length),[z,P]=d.useState(null);d.useEffect(()=>{if(!z)return;const y=()=>P(null),j=setTimeout(()=>document.addEventListener("click",y),0);return()=>{clearTimeout(j),document.removeEventListener("click",y)}},[z]);const[se,ye]=d.useState(()=>new Set),Se=a!==void 0,[xe,pe]=d.useState({}),je=a??xe,be=y=>{u==null||u(y),Se||pe(y)},Te=g!==void 0,[ke,He]=d.useState(m??null),Y=Te?g??null:ke,he=!p,Oe=y=>{p==null||p(y),Te||He(y)},{headerGroups:Ne,leafColumns:ae,hasGroups:_e}=d.useMemo(()=>{var ie;const y=new Set(je.hidden??[]),j=(re,me)=>re.key??(typeof re.accessor=="string"?re.accessor:`col-${me}`),E=t.map((re,me)=>{var Je;if((Je=re.children)!=null&&Je.length){const Dt=re.children.map((Ke,St)=>({col:Ke,key:j(Ke,`${me}-${St}`)})).filter(Ke=>!y.has(Ke.key));return{col:re,key:re.key??`group-${me}`,isGroup:!0,leaves:Dt}}const ge={col:re,key:j(re,`${me}`)};return{col:re,key:ge.key,isGroup:!1,leaves:y.has(ge.key)?[]:[ge]}}).filter(re=>re.leaves.length>0),Z=E.some(re=>re.isGroup);let ne=E.flatMap(re=>re.leaves);if(!Z&&((ie=je.order)!=null&&ie.length)){const re=new Map(je.order.map((me,ge)=>[me,ge]));ne=[...ne].sort((me,ge)=>(re.get(me.key)??1/0)-(re.get(ge.key)??1/0))}return{headerGroups:E,leafColumns:ne,hasGroups:Z}},[t,je]),tt=d.useMemo(()=>new Map(ae.map((y,j)=>[y.key,j])),[ae]),W=!_e&&ae.some(y=>(y.col.headerColSpan??1)>1),$=ae.map(y=>y.key).join("|"),Q=(y,j)=>{const E=y.sortKey??(typeof y.accessor=="string"?y.accessor:void 0);return E?j[E]:void 0},de=y=>y.sortable??(!!y.sortKey||typeof y.accessor=="string"),le=d.useMemo(()=>{if(!he||!Y)return r;const y=ae.find(E=>E.key===Y.key);if(!y)return r;const j=Y.direction==="asc"?1:-1;return[...r].sort((E,Z)=>Gi(Q(y.col,E),Q(y.col,Z))*j)},[r,he,Y,ae]),Be=!_e&&!W,Re=!!c&&Be,[$e,qe]=G.useColumnWidths(c??""),Me=Re?$e:void 0,Qe=d.useRef(null),[we,Ze]=d.useState();d.useLayoutEffect(()=>{Ze(void 0)},[$]),d.useLayoutEffect(()=>{if(!Be||we||!Qe.current)return;const y=Qe.current.querySelectorAll("th.sa-tl-leaf");Ze(Array.from(y).map(j=>j.offsetWidth))},[we,Be]);const[rt,ut]=d.useState(),[ct,at]=d.useState(0);d.useLayoutEffect(()=>{if(!_e||!Qe.current)return;const y=Qe.current.querySelector(":scope > tr");y&&at(y.offsetHeight)},[_e,$]);const ft=(y,j)=>{if((Me==null?void 0:Me[j])!=null)return Me[j];if(y.width!=null)return y.width;if((we==null?void 0:we[j])!=null)return we[j]},k=(y,j)=>typeof y.width=="number"?y.width:we==null?void 0:we[j],q=je.frozenKey&&!_e&&!W?ae.findIndex(y=>y.key===je.frozenKey):-1,K=y=>y<=q,ve=L?Bt:0,Ie=y=>{const j=rt??we;if(!j)return ve;let E=ve;for(let Z=0;Z<y;Z++)E+=j[Z]??0;return E};d.useLayoutEffect(()=>{const y=Qe.current;if(!y||q<0){ut(void 0);return}let j=0;const E=()=>{j=0;const ne=y.querySelectorAll("th.sa-tl-leaf"),ie=Array.from(ne).map(re=>re.getBoundingClientRect().width);ut(re=>re&&re.length===ie.length&&re.every((me,ge)=>Math.abs(me-ie[ge])<.5)?re:ie)},Z=new ResizeObserver(()=>{j||(j=requestAnimationFrame(E))});return Z.observe(y),y.querySelectorAll("th.sa-tl-leaf").forEach(ne=>Z.observe(ne)),E(),()=>{j&&cancelAnimationFrame(j),Z.disconnect()}},[$,q,L,we,Me]);const Ue=d.useRef(null),[Ae,De]=d.useState("100vh");d.useLayoutEffect(()=>{if(S!==void 0)return;const y=()=>{if(Ue.current){const j=Ue.current.getBoundingClientRect().top;De(`calc(100vh - ${j}px - var(--sa-floating-footer-height, 0px) + 12px)`)}};return y(),window.addEventListener("resize",y),()=>window.removeEventListener("resize",y)},[S]);const Ee=(y,j)=>n?n(y,j):j,We=U!==void 0,[wt,No]=d.useState(()=>new Set(J??[])),st=d.useMemo(()=>We?new Set(U):wt,[We,U,wt]);d.useEffect(()=>{L&&!n&&process.env.NODE_ENV!=="production"&&console.warn("[@starasia/admin] TableLayout: `selectable` tanpa `getRowKey` — key default (index) membuat seleksi menempel ke POSISI baris, bukan datanya. Beri `getRowKey` yang stabil (mis. r => r.id).")},[L,!n]);const Yr=y=>{if(We||No(y),N){const j=le.filter((E,Z)=>y.has(Ee(E,Z)));N(Array.from(y),j)}},ir=(y,j)=>L&&(_?_(y,j):!0),lr=y=>{const j=new Set(st);j.has(y)?j.delete(y):j.add(y),Yr(j)},mt=d.useMemo(()=>L?le.map((y,j)=>({row:y,i:j,key:Ee(y,j)})).filter(({row:y,i:j})=>_?_(y,j):!0).map(({key:y})=>y):[],[L,le,_,n]),Xr=mt.filter(y=>st.has(y)),cr=mt.length>0&&Xr.length===mt.length,$r=Xr.length>0&&!cr,_o=()=>{const y=new Set(st);cr?mt.forEach(j=>y.delete(j)):mt.forEach(j=>y.add(j)),Yr(y)},ar=(y,j,E)=>y.render?y.render(j,E,le):Zi(j,y.accessor),dr=ae.length+(L?1:0)+(V?1:0),Kr=["80%","55%","70%","45%","90%","60%"],qo=(y,j)=>Kr[(y*7+j*3)%Kr.length],Zo=(y,j)=>e.jsx(Ye.Skeleton,{height:14,width:qo(y,j),borderRadius:"rounded-sm"}),Go=Array.from({length:w},(y,j)=>e.jsxs(G.Tr,{children:[L&&e.jsx(G.Td,{style:{width:Bt,padding:0},children:e.jsx("div",{style:{display:"flex",justifyContent:"center"},children:e.jsx(Ye.Skeleton,{height:14,width:14,borderRadius:"rounded-sm"})})}),ae.map(({col:E,key:Z},ne)=>e.jsx(G.Td,{style:{textAlign:Et(E.align)},children:Zo(j,ne)},`sa-tl-sk-${j}-${Z}`)),V&&e.jsx(G.Td,{style:{width:1,padding:0,border:"none"}})]},`sa-tl-sk-${j}`)),Qo=(y,j)=>{j||be({...je,hidden:[...je.hidden??[],y]})},Uo=y=>be({...je,frozenKey:je.frozenKey===y?void 0:y}),Rt=y=>(O??[]).filter(j=>{var E;return!((E=j.hidden)!=null&&E.call(j,y))}),en={position:"absolute",right:0,top:0,bottom:0,display:"flex",alignItems:"center",gap:4,paddingRight:16,paddingLeft:40,background:"linear-gradient(to right, transparent, var(--sa-background-primary-inverse, #f8f8f8) 40px)"},At=(y,j,E,Z)=>{var Je;const ne=(Je=y.disabled)==null?void 0:Je.call(y,j),ie=(Z==null?void 0:Z.showLabel)??y.showLabel,re=(Z==null?void 0:Z.size)??"xs",me=e.jsx(H.Button,{size:re,variant:y.variant??"tertiary",tone:y.tone??"neutral",disabled:ne,onClick:()=>y.onClick(j,E),iconLeft:y.icon?e.jsx(F.Icon,{name:y.icon,size:"sm"}):void 0,children:ie&&y.label}),ge=y.tooltip;return ge?e.jsx(Fe.Tooltip,{label:ge,position:"top-end",children:me}):me},Jo=(y,j)=>{const E=Rt(y);if(!E.length)return null;if(E.length>5){const ne=Ee(y,j),ie=(z==null?void 0:z.rowKey)===ne;return e.jsx("div",{className:"sa-tl-row-actions",style:en,onClick:re=>re.stopPropagation(),children:e.jsx(Fe.Tooltip,{label:"Aksi lainnya",position:"top",children:e.jsx(H.Button,{size:"xs",variant:"tertiary",onClick:re=>{const me=re.currentTarget.getBoundingClientRect();P(ie?null:{rowKey:ne,top:me.bottom+4,right:window.innerWidth-me.right})},children:e.jsx(F.Icon,{name:"MenuVertical",size:"sm"})})})})}return e.jsx("div",{className:"sa-tl-row-actions",style:en,children:E.map(ne=>e.jsx(d.Fragment,{children:At(ne,y,j)},ne.key))})},Yo=(y,j)=>{const E=Rt(y);return E.length?e.jsx("div",{style:{display:"flex",gap:6,flexWrap:"wrap",paddingTop:8,marginTop:8,borderTop:kt},children:E.map(Z=>e.jsx(d.Fragment,{children:At(Z,y,j,{showLabel:!0,size:"sm"})},Z.key))}):null},Xo=(y,j)=>{const E=Rt(y);return E.length?e.jsx("div",{style:{display:"flex",gap:4,paddingRight:8,flexShrink:0},children:E.map(Z=>e.jsx(d.Fragment,{children:At(Z,y,j,{showLabel:!1})},Z.key))}):null},ur=(y,j)=>{const{col:E,key:Z}=y,ne=tt.get(Z)??0,ie=K(ne),re=ie&&ne===q,me=(Y==null?void 0:Y.key)===Z?Y.direction:null,ge=f&&!E.disableMenu?e.jsx(Io,{active:!!me||ie,canSort:de(E),canHide:!E.locked,sortDir:me,frozen:ie,onSort:St=>Oe({key:Z,direction:St}),onClearSort:()=>Oe(null),onToggleFreeze:()=>Uo(Z),onHide:()=>Qo(Z,E.locked)}):null,Je=E.align==="right",Dt=E.align==="right"?"flex-end":E.align==="center"?"center":"flex-start",Ke=e.jsxs("span",{style:{flex:1,minWidth:0,display:"flex",alignItems:"center",gap:6,justifyContent:Dt,overflow:"hidden"},children:[E.icon&&e.jsx(F.Icon,{name:E.icon,size:"sm",style:{flexShrink:0}}),e.jsx("span",{style:Vt,children:E.title})]});return e.jsx(G.Th,{className:`sa-tl-leaf${ie?" sa-tl-frozen":""}`,rowSpan:j==null?void 0:j.rowSpan,colSpan:j==null?void 0:j.colSpan,minWidth:E.minWidth,numeric:E.numeric,resizable:Be?E.resizable:!1,defaultWidth:k(E,ne),style:{textAlign:Et(E.align),width:ft(E,ne),position:"sticky",top:(j==null?void 0:j.top)??0,left:ie?Ie(ne):void 0,zIndex:ie?3:2,backgroundColor:gt,boxShadow:re?Pn:void 0},children:e.jsx("div",{style:{display:"flex",alignItems:"center",gap:6,width:"100%"},children:Je?e.jsxs(e.Fragment,{children:[ge,Ke]}):e.jsxs(e.Fragment,{children:[Ke,ge]})})},`th-${Z}`)},$o=()=>{const y=[];for(let j=0;j<ae.length;){const E=ae[j],Z=E.col.headerColSpan??1,ne=Math.max(1,Math.min(Z,ae.length-j));y.push(ur(E,ne>1?{colSpan:ne}:void 0)),j+=ne}return y},tn=y=>e.jsx(G.Th,{rowSpan:y==null?void 0:y.rowSpan,style:{width:Bt,position:"sticky",top:0,left:0,zIndex:4,backgroundColor:gt,padding:0},children:e.jsx("div",{style:{display:"flex",alignItems:"center",justifyContent:"center"},onClick:j=>j.stopPropagation(),children:e.jsx(nt.Checkbox,{size:"sm",variant:$r?"indeterminate":"select",checked:cr||$r,disabled:mt.length===0,onChange:_o,"aria-label":"Pilih semua baris di halaman ini"})})},"th-select"),Ko=(y,j,E)=>{const Z=Ee(y,j);return e.jsx(G.Td,{className:"sa-tl-frozen",style:{width:Bt,padding:0,position:"sticky",left:0,zIndex:2,...E?{"--sa-tl-bg":E}:{}},children:ir(y,j)&&e.jsx("div",{style:{display:"flex",alignItems:"center",justifyContent:"center"},onClick:ne=>ne.stopPropagation(),children:e.jsx(nt.Checkbox,{size:"sm",checked:st.has(Z),onChange:()=>lr(Z),"aria-label":"Pilih baris"})})},`tl-select-${j}`)},xr=ae.filter(y=>!y.col.hideOnMobile),hr=xr.find(y=>y.col.primary)??xr[0],es=xr.filter(y=>y!==hr),ts=y=>ye(j=>{const E=new Set(j);return E.has(y)?E.delete(y):E.add(y),E}),rn=(y,j)=>es.map(({col:E,key:Z})=>{const ne=ar(E,y,j),ie={minWidth:0,overflow:"hidden",textOverflow:"ellipsis",textAlign:"right",...E.numeric?{fontVariantNumeric:"tabular-nums"}:{}},re=typeof ne=="string"||typeof ne=="number"?e.jsx(v.Text,{style:ie,children:ne}):e.jsx("div",{style:ie,children:ne});return e.jsxs("div",{style:{display:"flex",gap:12,justifyContent:"space-between",alignItems:"baseline"},children:[typeof E.title=="string"?e.jsx(v.Text,{color:"subtle",fontWeight:"medium",style:{color:Ni,flexShrink:0},children:E.title}):e.jsx("div",{style:{flexShrink:0},children:E.title}),re]},Z)}),fr=(y,j)=>{const E=hr?ar(hr.col,y,j):null;return typeof E=="string"||typeof E=="number"?e.jsx(v.Text,{as:"span",style:Vt,children:E}):e.jsx("span",{style:Vt,children:E})},rs=e.jsx(x.Box,{style:{display:"flex",flexDirection:"column",gap:8,padding:8},children:Array.from({length:w},(y,j)=>e.jsxs(x.Box,{style:{border:kt,borderRadius:"var(--sa-radii-sm, 6px)",padding:12,display:"flex",flexDirection:"column",gap:8},children:[e.jsx(Ye.Skeleton,{height:16,width:"60%",borderRadius:"rounded-sm"}),e.jsx(Ye.Skeleton,{height:12,width:"85%",borderRadius:"rounded-sm"}),e.jsx(Ye.Skeleton,{height:12,width:"70%",borderRadius:"rounded-sm"})]},`sa-tl-sk-card-${j}`))}),nn=e.jsx(x.Box,{fullWidth:!0,style:{minHeight:(A==null?void 0:A.minHeight)??320,display:"flex",alignItems:"center",justifyContent:"center",padding:16},children:A==null?void 0:A.content}),ns=R?rs:le.length===0?nn:b==="expand"?e.jsx(x.Box,{style:{display:"flex",flexDirection:"column"},children:le.map((y,j)=>{const E=Ee(y,j),Z=se.has(E),ie=L&&st.has(E)?Sr:Nt(s==null?void 0:s(y,j));return e.jsxs("div",{style:{borderBottom:kt,backgroundColor:ie},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center"},children:[ir(y,j)&&e.jsx("div",{style:{display:"flex",alignItems:"center",paddingLeft:12,flexShrink:0},children:e.jsx(nt.Checkbox,{size:"sm",checked:st.has(E),onChange:()=>lr(E),"aria-label":"Pilih baris"})}),e.jsxs("button",{type:"button",onClick:()=>ts(E),style:{flex:1,minWidth:0,display:"flex",alignItems:"center",justifyContent:"space-between",gap:12,padding:"10px 12px",background:"none",border:"none",font:"inherit",color:"inherit",cursor:"pointer",textAlign:"left"},children:[fr(y,j),e.jsx(F.Icon,{name:Z?"ChevronUp":"ChevronDown",size:"sm",style:{flexShrink:0}})]}),V&&Xo(y,j)]}),Z&&e.jsx("div",{style:{padding:"0 12px 12px",display:"flex",flexDirection:"column",gap:6},children:rn(y,j)})]},E)})}):e.jsx(x.Box,{style:{display:"flex",flexDirection:"column",gap:8,padding:8},children:le.map((y,j)=>{const E=Ee(y,j),Z=L&&st.has(E);return e.jsxs(x.Box,{style:{border:kt,borderRadius:"var(--sa-radii-sm, 6px)",padding:12,display:"flex",flexDirection:"column",gap:6,backgroundColor:Z?Sr:Nt(s==null?void 0:s(y,j))},children:[ir(y,j)?e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[e.jsx(nt.Checkbox,{size:"sm",checked:st.has(E),onChange:()=>lr(E),"aria-label":"Pilih baris"}),e.jsx("div",{style:{flex:1,minWidth:0},children:fr(y,j)})]}):fr(y,j),rn(y,j),V&&Yo(y,j)]},E)})}),os=i&&Be&&we!==void 0,on=l==="fixed"&&!i&&(Be?we!==void 0:!0),ss=on&&!Be,Wt=C&&C.length>0?C.map((y,j)=>e.jsx(G.Tr,{children:y.cells.map((E,Z)=>e.jsx(G.Td,{colSpan:E.colSpan,rowSpan:E.rowSpan,numeric:E.numeric,style:{textAlign:Et(E.align)},children:E.content},`tl-foot-${j}-${Z}`))},`tl-foot-${j}`)):null,is=e.jsxs(G.Table,{className:"sa-table-layout",fullWidth:!0,size:o,resizable:os,style:on?{tableLayout:"fixed"}:void 0,onWidthsChange:Re?qe:void 0,children:[ss&&e.jsxs("colgroup",{children:[L&&e.jsx("col",{style:{width:Bt}}),ae.map(({col:y,key:j},E)=>e.jsx("col",{style:{width:ft(y,E)}},`col-${j}`)),V&&e.jsx("col",{style:{width:1}})]}),e.jsx(G.Thead,{ref:Qe,children:_e?e.jsxs(e.Fragment,{children:[e.jsxs(G.Tr,{children:[L&&tn({rowSpan:2}),Ne.map(y=>y.isGroup?e.jsx(G.Th,{colSpan:y.leaves.length,style:{textAlign:"center",position:"sticky",top:0,zIndex:2,backgroundColor:gt},children:e.jsx("span",{style:Vt,children:y.col.title})},`grp-${y.key}`):ur(y.leaves[0],{rowSpan:2})),V&&e.jsx(G.Th,{rowSpan:2,style:{position:"sticky",top:0,right:0,zIndex:3,width:1,padding:0,border:"none",backgroundColor:gt}})]}),e.jsx(G.Tr,{children:Ne.flatMap(y=>y.isGroup?y.leaves.map(j=>ur(j,{top:ct})):[])})]}):e.jsxs(G.Tr,{children:[L&&tn(),$o(),V&&e.jsx(G.Th,{style:{position:"sticky",top:0,right:0,zIndex:3,width:1,padding:0,border:"none",backgroundColor:gt}})]})}),e.jsx(G.Tbody,{children:R?Go:le.length===0?e.jsx(G.Tr,{children:e.jsx(G.Td,{colSpan:dr,children:nn})}):e.jsxs(e.Fragment,{children:[le.map((y,j)=>{const E=B==null?void 0:B(y,j,j>0?le[j-1]:void 0),ne=L&&st.has(Ee(y,j))?Sr:Nt(s==null?void 0:s(y,j));return e.jsxs(d.Fragment,{children:[E!=null&&E!==!1&&e.jsx(G.Tr,{children:e.jsx(G.Td,{colSpan:dr,style:{backgroundColor:gt},children:E})}),e.jsxs(G.Tr,{children:[L&&Ko(y,j,ne),ae.map(({col:ie,key:re},me)=>{var ln;const ge=(ln=ie.cellProps)==null?void 0:ln.call(ie,y,j,le);if(ge!=null&&ge.hidden)return null;const Je=K(me),Dt=Je&&me===q,Ke=ar(ie,y,j),St=typeof ie.bg=="function"?ie.bg(y,j,le):ie.bg,sn=Nt(St)??ne;return e.jsx(G.Td,{className:Je?"sa-tl-frozen":void 0,colSpan:ge==null?void 0:ge.colSpan,rowSpan:ge==null?void 0:ge.rowSpan,numeric:ie.numeric,style:{textAlign:Et(ie.align),width:ft(ie,me),minWidth:ie.minWidth,position:Je?"sticky":void 0,left:Je?Ie(me):void 0,zIndex:Je?1:void 0,boxShadow:Dt?Pn:void 0,...sn?{"--sa-tl-bg":sn}:{}},children:typeof Ke=="string"?e.jsx(v.Text,{style:{whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",textAlign:Et(ie.align)},children:Ke}):Ke},`tl-cell-${j}-${re}`)}),V&&e.jsx(G.Td,{style:{position:"sticky",right:0,width:1,padding:0,overflow:"visible",zIndex:2,border:"none"},children:Jo(y,j)})]})]},Ee(y,j))}),M!=null&&e.jsx(G.Tr,{children:e.jsx(G.Td,{colSpan:dr,children:M})})]})}),Wt&&e.jsx(G.Tfoot,{className:D?"sa-tl-sticky-foot":void 0,children:Wt})]}),mr=z?le.findIndex((y,j)=>Ee(y,j)===z.rowKey):-1,gr=mr>=0?le[mr]:null;return e.jsxs(e.Fragment,{children:[e.jsx(x.Box,{ref:Ue,fullWidth:!0,style:{overflow:"auto",height:S??Ae},children:te?e.jsxs(e.Fragment,{children:[ns,Wt&&!R&&le.length>0&&e.jsx(x.Box,{style:{borderTop:kt},children:e.jsx(G.Table,{fullWidth:!0,size:o,className:"sa-table-layout",children:e.jsx(G.Tbody,{children:Wt})})})]}):is}),z&&gr&&e.jsx("div",{className:"sa-tl-kebab-menu",style:{top:z.top,right:z.right},onClick:y=>y.stopPropagation(),children:Rt(gr).map(y=>e.jsx("div",{style:{padding:"2px 4px"},children:At(y,gr,mr,{showLabel:!0,size:"sm"})},y.key))})]})},kr=t=>t==="asc"||t==="desc",Ui=(t={})=>{const{sortKeyParam:r="sortBy",sortOrderParam:n="sortOrder",pageKey:s="page",defaultSort:o=null,paramKeys:i,scopeId:l,storage:c=Jr}=t,{searchParams:a,setSearchParams:u,searchQueries:f}=Ve(),g=a.toString(),m=l?Ct.tableSort(l):void 0,p=d.useRef(!1);d.useEffect(()=>{if(p.current||(p.current=!0,!m)||a.has(r)||a.has(n))return;const C=c.get(m);!(C!=null&&C.key)||!kr(C.direction)||u({...Object.fromEntries(a.entries()),[r]:C.key,[n]:C.direction},{replace:!0})},[]);const S=d.useMemo(()=>{const C=a.get(r),D=a.get(n);return C&&kr(D)?{key:C,direction:D}:o},[g,r,n,o]);d.useEffect(()=>{if(!m)return;const C=a.get(r),D=a.get(n);C&&kr(D)?c.set(m,{key:C,direction:D}):c.remove(m)},[g,m,r,n,c]);const b=(i==null?void 0:i.sortBy)??"sortBy",I=(i==null?void 0:i.sortOrder)??"sortOrder",B=d.useMemo(()=>S?{[b]:S.key,[I]:S.direction}:{},[S,b,I]),M=d.useCallback(C=>{const D={...f};C?(D[r]=C.key,D[n]=C.direction):(delete D[r],delete D[n]),delete D[s],u(D)},[f,r,n,s,u]);return{sort:S,setSort:M,params:B}},er=({of:t,render:r})=>d.Children.toArray(t==null?void 0:t.map((n,s,o)=>r(n,s,o))),ue=({condition:t,fallback:r,children:n,loading:s,isLoading:o})=>e.jsx(e.Fragment,{children:o?s:t?n:r}),fe=t=>e.jsx(v.Text,{...t,fontSize:t.fontSize||"md",fontWeight:t.fontWeight||"medium",color:t.color||"gray-700",children:t.children}),lt=t=>e.jsx(v.Text,{color:"red-600",fontSize:"sm",children:t.message}),Ji=({size:t="md",direction:r="vertical",requiredTitle:n="(Required)",fullWidth:s=!1,...o})=>{var c,a,u;const i=o.hideMessageError||!1,l=r==="horizontal"?t==="sm"?342:t==="lg"?400:342:void 0;return e.jsxs(x.Box,{gap:r==="horizontal"?"spacing-96":"sm",direction:r==="horizontal"?"row":"column",...o.containerProps,children:[o.title&&e.jsx(ue,{condition:!!o.inputProps.required,fallback:e.jsxs(x.Box,{direction:"column",customMaxWidth:l,fullWidth:s,children:[e.jsx(fe,{children:o.title}),e.jsx(v.Text,{fontSize:t,color:"gray-500",children:o.description})]}),children:e.jsxs(x.Box,{direction:"column",customMaxWidth:l,fullWidth:s,children:[e.jsxs(ce.Flex,{direction:"row",gap:"xs",align:"center",children:[e.jsx(fe,{fontSize:t,children:o.title}),e.jsx(fe,{color:"error",fontSize:t,children:n}),e.jsx(ue,{condition:!!((c=o.tooltip)!=null&&c.label),children:e.jsx(Fe.Tooltip,{label:(a=o.tooltip)==null?void 0:a.label,arrowPosition:(u=o.tooltip)==null?void 0:u.arrowPosition,...o.tooltip,children:e.jsx(F.Icon,{name:"InfoCircle",size:t==="lg"?"sm":"xs",style:{color:"var(--sa-color-info-500, #00abeb)",marginTop:"6px"}})})})]}),e.jsx(ue,{condition:!!o.description,children:e.jsx(v.Text,{fontSize:t,color:"gray-500",children:o.description})})]})}),e.jsxs(x.Box,{direction:"column",gap:"xs",fullWidth:o.inputProps.fullWidth||!1,children:[e.jsx(dt.Input,{ref:o.inputRef,size:t,...o.inputProps,status:o.errorMessage?"error":"default",fullWidth:!0}),!i&&o.errorMessage&&e.jsx(lt,{message:o.errorMessage}),o.inputProps.extended&&o.inputProps.extended]})]})},Yi=({size:t="md",direction:r="vertical",requiredTitle:n="(Required)",fullWidth:s=!1,...o})=>{var c,a,u;const i=o.hideMessageError||!1,l=r==="horizontal"?t==="sm"?342:t==="lg"?400:342:void 0;return e.jsxs(x.Box,{gap:r==="horizontal"?"spacing-96":"sm",direction:r==="horizontal"?"row":"column",onClick:o.onClickContainer,children:[o.title&&e.jsx(ue,{condition:!!o.inputProps.required,fallback:e.jsxs(x.Box,{direction:"column",customMaxWidth:l,fullWidth:s,children:[e.jsx(fe,{children:o.title}),e.jsx(v.Text,{fontSize:t,color:"gray-500",children:o.description})]}),children:e.jsxs(x.Box,{direction:"column",customMaxWidth:l,fullWidth:s,children:[e.jsxs(ce.Flex,{direction:"row",gap:"xs",align:"center",children:[e.jsx(fe,{fontSize:t,children:o.title}),e.jsx(fe,{color:"error",fontSize:t,children:n}),e.jsx(ue,{condition:!!((c=o.tooltip)!=null&&c.label),children:e.jsx(Fe.Tooltip,{label:(a=o.tooltip)==null?void 0:a.label,arrowPosition:(u=o.tooltip)==null?void 0:u.arrowPosition,...o.tooltip,children:e.jsx(F.Icon,{name:"InfoCircle",size:t==="lg"?"sm":"xs",style:{color:"var(--sa-color-info-500, #00abeb)",marginTop:"6px"}})})})]}),e.jsx(ue,{condition:!!o.description,children:e.jsx(v.Text,{fontSize:t,color:"gray-500",children:o.description})})]})}),e.jsxs(x.Box,{direction:"column",gap:"xs",fullWidth:o.inputProps.fullWidth||!1,children:[e.jsx(x.Box,{direction:"column",style:{width:o.inputProps.fullWidth?"100%":r==="horizontal"&&o.customWidth?o.customWidth:r==="horizontal"?"343px":""},children:e.jsx(jt.Dropdown,{size:t,...o.inputProps,error:!!o.errorMessage})}),!i&&o.errorMessage&&e.jsx(lt,{message:o.errorMessage}),o.inputProps.extended&&o.inputProps.extended]})]})},Xi=(t,r)=>typeof t=="string"&&t||r==="error"?"var(--sa-border-danger)":"var(--sa-border-subtle)",$i=t=>{var c;const[r,n]=d.useState(!1),s=a=>{a.preventDefault(),a.stopPropagation()},o=a=>{a.preventDefault(),a.stopPropagation(),a.dataTransfer&&t.handleOnFileChange(a.dataTransfer.files.item(0))},i=a=>{a.preventDefault(),n(!0)},l=a=>{a.preventDefault(),n(!1)};return e.jsxs(x.Box,{width:"width-full",paddingInline:"md",direction:"row",gap:"sm",align:"center",onClick:t.handleOnClick,onDragOver:s,onDrop:o,onDragEnter:i,onDragLeave:l,paddingBlock:"md",borderRadius:"rounded-md",style:{border:r?"1px solid var(--sa-border-info)":`1px solid ${Xi(t.errorMessage,t.status)}`},children:[e.jsx(F.Icon,{name:"Upload",size:"lg",style:{width:30,height:30}}),e.jsxs(ce.Flex,{direction:"column",gap:"xs",children:[e.jsxs(ce.Flex,{direction:"row",gap:"xs",children:[e.jsx(v.Text,{fontWeight:"medium",color:"gray-500",style:{textWrap:"nowrap"},fontSize:t.isDesktop?"md":"sm",children:"Click your upload"}),e.jsx(v.Text,{fontWeight:"medium",style:{textWrap:"nowrap"},fontSize:t.isDesktop?"md":"sm",children:"or Drag & Drop"})]}),e.jsx(v.Text,{fontSize:"sm",color:"gray-500",children:(c=t.fileSupports)==null?void 0:c.map(a=>a.toLocaleUpperCase()).join(", ")})]})]})};function Ki(t){return t.split(" ").map(r=>r[0]).join("").slice(0,2).toUpperCase()}const Lo=t=>{const r={day:"2-digit",month:"short",year:"numeric"};return t.toLocaleDateString("id-ID",r)},el=t=>{const r={Jan:0,Feb:1,Mar:2,Apr:3,Mei:4,Jun:5,Jul:6,Agu:7,Sep:8,Okt:9,Nov:10,Des:11},n=t.split(" ");if(n.length!==3)return null;const s=parseInt(n[0],10),o=r[n[1]],i=parseInt(n[2],10);return isNaN(s)||isNaN(o)||isNaN(i)?null:new Date(i,o,s)};function tl(t,r=!0){if(!t)return"Rp 0";const n=typeof t=="number"?t.toString():t;if(isNaN(Number(n)))return"Rp 0";const s=n.split("."),o=s[0].replace(/\B(?=(\d{3})+(?!\d))/g,"."),i=s.length===2?o+"."+s[1]:o;return r?"Rp"+i:i}String.prototype.toTitleCase=function(){return this.toLowerCase().split(" ").map(t=>t.charAt(0).toUpperCase()+t.slice(1)).join(" ")};String.prototype.toNumber=function(){return Number(this)};const rl=t=>{const r=t.split(" ");let n=r[0].charAt(0);return r.length>1&&(n+=""+r[1].charAt(0)),n.toUpperCase()};function nl(t){const r=typeof t=="string"?new Date(t):t;if(isNaN(r.getTime()))throw new Error("Invalid date format");const n=r.getFullYear(),s=String(r.getMonth()+1).padStart(2,"0"),o=String(r.getDate()).padStart(2,"0");return`${n}-${s}-${o}`}const ol="sa-admin",et=t=>`var(--${ol}-${t})`,sl={base:{borderColor:et("base-border-color"),textColor:et("base-text-color"),iconColor:et("base-icon-color"),placeholderColor:et("base-placeholder-color")},document:{bgColor:et("document-bg-color")},sidebar:{bgColor:et("sidebar-bg-color"),borderColor:et("sidebar-border-color"),maxWidth:et("sidebar-max-width"),width:et("sidebar-width"),collapseWidth:et("sidebar-collapse-width"),collapseV2Width:et("sidebar-v2-collapse-width")}},il=24*60*60*1e3,ll=t=>{const r="14px poppins",s=document.createElement("canvas").getContext("2d");s.font=r;const o=s.measureText(t).width;return Number(Math.ceil(o))},cl=/^[^\s@]+@[^\s@]+\.[^\s@]+$/,al=/--+/,dl=/-$/;function ul(t,r){return JSON.stringify(t)!==JSON.stringify(r)}function xl(t){return/^(?:\+62|62|0)8[1-9][0-9]{7,10}$/.test(t)}function hl(t){return/^[A-Za-z\s]+$/.test(t)}const fl=t=>{const r=/^[0-9]$/,n=["ArrowLeft","ArrowRight","ArrowUp","ArrowDown","Backspace","Delete","Enter","Tab"];(t.ctrlKey||t.metaKey)&&(t.key==="a"||t.key==="c"||t.key==="v")||!r.test(t.key)&&!n.includes(t.key)&&t.preventDefault()},ml=t=>{const r=/^[0-9]$/,n=["ArrowLeft","ArrowRight","ArrowUp","ArrowDown","Backspace","Delete","Enter","Tab"];(t.ctrlKey||t.metaKey)&&t.key==="v"||r.test(t.key)&&!n.includes(t.key)&&t.preventDefault()},gl=t=>{const r=/^[0-9.]$/,n=["ArrowLeft","ArrowRight","ArrowUp","ArrowDown","Backspace","Delete","Enter","Tab"];(t.ctrlKey||t.metaKey)&&t.key==="v"||!r.test(t.key)&&!n.includes(t.key)&&t.preventDefault()},yl=t=>cl.test(t);function pl(t){return!(al.test(t)||dl.test(t))}const jl=t=>{const r=["ArrowLeft","ArrowRight","ArrowUp","ArrowDown","Backspace","Delete","Enter","Tab","Home","End"];if((t.ctrlKey||t.metaKey)&&["a","c","v","x"].includes(t.key.toLowerCase()))return;const n=t.currentTarget.value;/^[0-9]$/.test(t.key)||t.key==="."&&!n.includes(".")||t.key==="-"&&n.length===0&&!n.includes("-")||r.includes(t.key)||t.preventDefault()},bl=t=>{const r=document.getElementById(t);if(r){const n=r.getBoundingClientRect(),s=window.scrollY+n.top-80;window.scrollTo({top:s,behavior:"smooth"})}};function vl(t){const r=t.toLowerCase();if(["kb","mb","gb"].find(i=>r.endsWith(i)))return t;const o=Number(t);if(isNaN(o))throw new Error("Invalid size format");return o>=1e6?`${(o/1e6).toFixed(2)}MB`:o>=1e3?`${(o/1e3).toFixed(2)}KB`:`${o}B`}function Cl(t){const r=t.split("/");return r[r.length-1]}const wl=t=>{var r,n;return e.jsxs(x.Box,{width:"width-full",paddingInline:"md",height:"height-full",direction:"row",justify:"space-between",align:"center",onClick:t.handleOnClickFile,fullHeight:!0,paddingBlock:"md",id:"file-item",borderRadius:"rounded-md",style:{border:"1px solid var(--sa-border-subtle)",cursor:"pointer"},children:[e.jsxs(ce.Flex,{direction:"row",align:"center",gap:"sm",style:{flex:1,minWidth:0},children:[e.jsx(F.Icon,{name:"DocumentFilled",size:"lg",style:{color:"var(--sa-icon-brand)",width:30,height:30,flexShrink:0}}),e.jsxs(ce.Flex,{direction:"column",style:{minWidth:0,flex:1},children:[e.jsx(v.Text,{fontWeight:"bold",style:{textOverflow:"ellipsis",whiteSpace:"nowrap",overflow:"hidden"},children:t.defaultFile?Cl(t.defaultFile.url):(r=t.fileSelected)==null?void 0:r.name}),t.defaultFile?(t.defaultFile.size||t.defaultFile.date)&&e.jsxs(ce.Flex,{direction:"row",gap:"xs",align:"center",children:[t.defaultFile.size&&e.jsx(v.Text,{fontSize:"sm",fontWeight:"medium",children:t.defaultFile.size}),t.defaultFile.size&&t.defaultFile.date&&e.jsx(F.Icon,{name:"Dot",size:"xs"}),t.defaultFile.date&&e.jsx(v.Text,{fontSize:"sm",fontWeight:"medium",style:{textWrap:"nowrap"},children:t.defaultFile.date})]}):e.jsxs(ce.Flex,{direction:"row",gap:"xs",align:"center",children:[e.jsx(v.Text,{fontSize:"sm",fontWeight:"medium",children:vl(((n=t.fileSelected)==null?void 0:n.size.toString())||"100000")}),e.jsx(F.Icon,{name:"Dot",size:"xs"}),e.jsx(v.Text,{fontSize:"sm",fontWeight:"medium",style:{textWrap:"nowrap"},children:Lo(new Date)})]})]})]}),e.jsx(H.Button,{size:"xs",variant:"tertiary",tone:"error",type:"button",onClick:s=>{s.stopPropagation(),t.handleOnDeleteFile()},iconLeft:e.jsx(F.Icon,{name:"Trash1"})})]})},To=({status:t="default",labelPosition:r="outside-top",...n})=>{var m;const s=d.useRef(null),o=()=>{if(n.defaultFile){window.open(n.defaultFile.url);return}s.current&&s.current.click()},i=Ce.useMediaQuery("md"),l=t==="error"||typeof n.errorMessage=="string"&&!!n.errorMessage,c=n.label?e.jsxs(ce.Flex,{direction:"row",align:"center",gap:"xs",children:[e.jsx(v.Text,{style:{fontSize:"14px",fontWeight:500,color:"var(--sa-text-primary)"},children:n.label}),n.optional&&e.jsx("span",{style:{background:"var(--sa-background-neutral)",border:"1px solid var(--sa-border-subtle)",borderRadius:"4px",padding:"0 8px",fontSize:"10px",fontWeight:500,lineHeight:"18px",color:"var(--sa-text-primary)",display:"inline-flex",alignItems:"center"},children:"Optional"}),n.required&&e.jsx("span",{style:{fontSize:"14px",fontWeight:500,color:"var(--sa-text-error)"},children:"*"})]}):null,a=n.description?e.jsx(v.Text,{style:{fontSize:"12px",fontWeight:400,color:"var(--sa-text-subtlest, #6b6e76)",lineHeight:"18px"},children:n.description}):null,u=e.jsxs(e.Fragment,{children:[n.helperText&&e.jsx(v.Text,{style:{fontSize:"12px",fontWeight:400,color:"var(--sa-text-subtlest, #6b6e76)",lineHeight:"18px"},children:n.helperText}),n.errorText&&t==="error"&&e.jsx(v.Text,{style:{fontSize:"12px",fontWeight:400,color:"var(--sa-text-error, #a4133c)",lineHeight:"18px"},children:n.errorText}),n.errorMessage&&!n.errorText&&e.jsx(v.Text,{style:{fontSize:"12px",fontWeight:400,color:"var(--sa-text-error, #a4133c)",lineHeight:"18px"},children:n.errorMessage})]}),f=e.jsx("input",{type:"file",style:{display:"none"},ref:s,onChange:p=>{var S;return n.handleOnChangeFile(((S=p.target.files)==null?void 0:S.item(0))||null)},accept:(m=n.fileSupportOption)==null?void 0:m.map(p=>"."+(p==null?void 0:p.toLowerCase())).join(", ")}),g=e.jsxs(x.Box,{direction:"column",fullWidth:!0,style:{minHeight:"69px"},borderRadius:"rounded-md",display:"flex",justify:"center",align:"center",cursor:"pointer",gap:"md",...n.containerProps,children:[f,(n.fileSelected||n.defaultFile)&&e.jsx(wl,{fileSelected:n.fileSelected,defaultFile:n.defaultFile,handleOnDeleteFile:n.handleOnDeleteFile,handleOnClickFile:o}),!n.fileSelected&&!n.defaultFile&&e.jsx($i,{fileSupports:n.fileSupportOption,isDesktop:i,errorMessage:l?n.errorText||n.errorMessage||" ":void 0,status:l?"error":"default",handleOnClick:o,handleOnFileChange:n.handleOnChangeFile})]});return r==="outside-left"?e.jsxs(ce.Flex,{direction:"row",align:"flex-start",gap:"sm",style:{width:"100%"},children:[e.jsxs(ce.Flex,{direction:"column",gap:"xs",style:{width:"40%",minWidth:"120px",paddingTop:"10px"},children:[c,a]}),e.jsxs(ce.Flex,{direction:"column",gap:"sm",style:{flex:1,minWidth:0},children:[g,u]})]}):e.jsxs(ce.Flex,{direction:"column",gap:"sm",style:{width:"100%"},children:[c,a,g,u]})},Dl=({size:t="md",direction:r="vertical",requiredTitle:n="(Required)",fullWidth:s=!1,...o})=>{var c,a,u;const i=o.hideMessageError||!1,l=r==="horizontal"?t==="sm"?342:t==="lg"?400:342:void 0;return e.jsxs(x.Box,{gap:r==="horizontal"?"spacing-96":"sm",direction:r==="horizontal"?"row":"column",...o.containerProps,children:[o.title&&e.jsx(ue,{condition:!!o.inputProps.required,fallback:e.jsxs(x.Box,{direction:"column",customMaxWidth:l,fullWidth:s,children:[e.jsx(fe,{children:o.title}),e.jsx(v.Text,{fontSize:t,color:"gray-500",children:o.description})]}),children:e.jsxs(x.Box,{direction:"column",customMaxWidth:l,fullWidth:s,children:[e.jsxs(ce.Flex,{direction:"row",gap:"xs",align:"center",children:[e.jsx(fe,{fontSize:t,children:o.title}),e.jsx(fe,{color:"error",fontSize:t,children:n}),e.jsx(ue,{condition:!!((c=o.tooltip)!=null&&c.label),children:e.jsx(Fe.Tooltip,{label:(a=o.tooltip)==null?void 0:a.label,arrowPosition:(u=o.tooltip)==null?void 0:u.arrowPosition,...o.tooltip,children:e.jsx(F.Icon,{name:"InfoCircle",size:t==="lg"?"sm":"xs",style:{color:"var(--sa-color-info-500, #00abeb)",marginTop:"6px"}})})})]}),e.jsx(ue,{condition:!!o.description,children:e.jsx(v.Text,{fontSize:t,color:"gray-500",children:o.description})})]})}),e.jsxs(ce.Flex,{direction:"column",gap:"xs",children:[e.jsx(To,{...o.inputProps,status:o.errorMessage?"error":"default"}),!i&&o.errorMessage&&e.jsx(lt,{message:o.errorMessage})]})]})},Sl=({size:t="md",direction:r="vertical",requiredTitle:n="(Required)",fullWidth:s=!1,required:o=!1,...i})=>{var a,u,f,g;const l=i.hideMessageError||!1,c=r==="horizontal"?t==="sm"?342:t==="lg"?400:342:void 0;return e.jsxs(x.Box,{gap:r==="horizontal"||r==="horizontal-inline"?"spacing-96":"sm",direction:r==="horizontal"||r==="horizontal-inline"?"row":"column",...i.containerProps,children:[i.title&&e.jsx(ue,{condition:!!o,fallback:e.jsxs(x.Box,{direction:"column",customMaxWidth:c,fullWidth:s,children:[e.jsx(fe,{children:i.title}),e.jsx(Xe.Body3,{props:{color:"gray-500"},children:i.description})]}),children:e.jsxs(x.Box,{direction:"column",customMaxWidth:c,fullWidth:s,children:[e.jsxs(ce.Flex,{direction:"row",gap:"xs",align:"center",children:[e.jsx(fe,{fontSize:t,children:i.title}),e.jsx(fe,{color:"error",fontSize:t,children:n}),e.jsx(ue,{condition:!!((a=i.tooltip)!=null&&a.label),children:e.jsx(Fe.Tooltip,{label:(u=i.tooltip)==null?void 0:u.label,arrowPosition:(f=i.tooltip)==null?void 0:f.arrowPosition,...i.tooltip,children:e.jsx(F.Icon,{name:"InfoCircle",size:t==="lg"?"sm":"xs",style:{color:"var(--sa-color-info-500, #00abeb)",marginTop:"6px"}})})})]}),e.jsx(ue,{condition:!!i.description,children:e.jsx(v.Text,{fontSize:t,color:"gray-500",children:i.description})})]})}),e.jsx(x.Box,{gap:r==="horizontal-inline"?"xl":"md",direction:r==="horizontal-inline"?"row":"column",align:"flex-start",children:e.jsx(er,{of:(g=i.checkBoxesList)==null?void 0:g.map(m=>({...m,isChecked:i.checkBoxesAreChecked.includes(m.id)})),render:m=>m.renderBadge?e.jsxs(x.Box,{direction:"row",justify:"space-between",gap:"lg",...i.badgeContainerProps,children:[e.jsx(nt.Checkbox,{name:m.name,value:m.id,checked:m.isChecked,onChange:p=>i.onChecked(p.target.value,m),label:m.name,description:m.description}),m.renderBadge]}):e.jsx(nt.Checkbox,{name:m.name,value:m.id,checked:m.isChecked,onChange:p=>i.onChecked(p.target.value,m),label:m.name,description:m.description})})}),!l&&i.errorMessage&&e.jsx(lt,{message:i.errorMessage})]})},kl=({position:t="vertical",size:r="md",fullWidth:n=!1,...s})=>{var i;const o=t==="horizontal-inline"||t==="horizontal-block"?r==="sm"?342:r==="lg"?400:342:void 0;return e.jsxs(x.Box,{gap:t==="horizontal-inline"||t==="horizontal-block"?"spacing-96":"sm",direction:t==="horizontal-inline"||t==="horizontal-block"?"row":"column",children:[e.jsx(ue,{condition:!!s.description||!!s.title,children:e.jsxs(x.Box,{direction:"column",customMaxWidth:o,fullWidth:n,children:[s.title&&e.jsx(fe,{children:s.title}),e.jsx(ue,{condition:!!s.description,children:e.jsx(v.Text,{color:"gray-500",children:s.description})})]})}),e.jsx(x.Box,{gap:"sm",direction:t==="horizontal"||t==="horizontal-inline"?"row":"column",align:"flex-start",flexWrap:"wrap",children:e.jsx(er,{of:(i=s.radioList)==null?void 0:i.map(l=>({...l,isChecked:s.radioIsChecked===l.id})),render:({value:l,id:c,isChecked:a,subInput:u,label:f,description:g})=>e.jsxs(x.Box,{direction:"column",gap:"xs",customMaxWidth:o,children:[e.jsx(Ir.Radio,{id:`${c.toString()}-${l}`,name:s.groupName||f,label:f,value:l,checked:a,onChange:m=>s.onChecked({id:c,label:m.target.name,value:m.target.value}),disabled:s.disableAll},c),g&&e.jsx(v.Text,{color:"gray-500",style:{marginLeft:28},children:g}),u]})})}),s.errorMessage&&e.jsx(lt,{message:s.errorMessage})]})},Bl=({size:t="md",direction:r="vertical",requiredTitle:n="(Required)",fullWidth:s=!1,...o})=>{var c,a,u;const i=o.hideMessageError||!1,l=r==="horizontal"?t==="sm"?342:t==="lg"?400:342:void 0;return e.jsxs(x.Box,{gap:r==="horizontal"?"spacing-96":"sm",direction:r==="horizontal"?"row":"column",...o.containerProps,children:[o.title&&e.jsx(ue,{condition:!!o.inputProps.required,fallback:e.jsxs(x.Box,{direction:"column",customMaxWidth:l,fullWidth:s,children:[e.jsx(fe,{children:o.title}),e.jsx(v.Text,{fontSize:t,color:"gray-500",children:o.description})]}),children:e.jsxs(x.Box,{direction:"column",customMaxWidth:l,fullWidth:s,children:[e.jsxs(ce.Flex,{direction:"row",gap:"xs",align:"center",children:[e.jsx(fe,{fontSize:t,children:o.title}),e.jsx(fe,{color:"error",fontSize:t,children:n}),e.jsx(ue,{condition:!!((c=o.tooltip)!=null&&c.label),children:e.jsx(Fe.Tooltip,{label:(a=o.tooltip)==null?void 0:a.label,arrowPosition:(u=o.tooltip)==null?void 0:u.arrowPosition,...o.tooltip,children:e.jsx(F.Icon,{name:"InfoCircle",size:t==="lg"?"sm":"xs",style:{color:"var(--sa-color-info-500, #00abeb)",marginTop:"6px"}})})})]}),e.jsx(ue,{condition:!!o.description,children:e.jsx(v.Text,{fontSize:t,color:"gray-500",children:o.description})})]})}),e.jsxs(ce.Flex,{direction:"column",gap:"xs",children:[e.jsx(Mr.Textarea,{ref:o.inputRef,size:t,...o.inputProps,status:o.errorMessage?"error":"default"}),!i&&o.errorMessage&&e.jsx(lt,{message:o.errorMessage})]})]})},El=({size:t="md",direction:r="vertical",requiredTitle:n="(Required)",required:s=!1,fullWidth:o=!1,...i})=>{var c,a,u;const l=r==="horizontal"?t==="sm"?342:t==="lg"?400:342:void 0;return e.jsxs(x.Box,{gap:r==="horizontal"?"spacing-96":"sm",direction:r==="horizontal"?"row":"column",...i.containerProps,children:[i.title&&e.jsx(ue,{condition:s,fallback:e.jsxs(x.Box,{direction:"column",customMaxWidth:l,fullWidth:o,children:[e.jsx(fe,{children:i.title}),e.jsx(v.Text,{fontSize:t,color:"gray-500",children:i.titleDescription})]}),children:e.jsxs(x.Box,{direction:"column",customMaxWidth:l,fullWidth:o,children:[e.jsxs(ce.Flex,{direction:"row",gap:"xs",align:"center",children:[e.jsx(fe,{fontSize:t,children:i.title}),e.jsx(fe,{color:"error",fontSize:t,children:n}),e.jsx(ue,{condition:!!((c=i.tooltip)!=null&&c.label),children:e.jsx(Fe.Tooltip,{label:(a=i.tooltip)==null?void 0:a.label,arrowPosition:(u=i.tooltip)==null?void 0:u.arrowPosition,...i.tooltip,children:e.jsx(F.Icon,{name:"InfoCircle",size:t==="lg"?"sm":"xs",style:{color:"var(--sa-color-info-500, #00abeb)",marginTop:"6px"}})})})]}),e.jsx(ue,{condition:!!i.titleDescription,children:e.jsx(v.Text,{fontSize:t,color:"gray-500",children:i.titleDescription})})]})}),e.jsx(vt.Toggle,{checked:i.checked,onChange:i.onChange,label:i.label,description:i.description}),i.errorMessage&&e.jsx(lt,{message:i.errorMessage})]})},Fl=({variant:t="primary",size:r="md",...n})=>{const s=pt.useColor(),o=l=>{var a,u,f,g,m,p;if(!l)return;const c=n.disabled?"var(--sa-text-disable, #181a198f)":t==="secondary"?"var(--sa-text-subtle, #8c8f97)":t==="secondary-danger"?(u=(a=s==null?void 0:s.computed)==null?void 0:a.red)==null?void 0:u[600]:t==="secondary-primary"?(g=(f=s==null?void 0:s.computed)==null?void 0:f.blue)==null?void 0:g[700]:(p=(m=s==null?void 0:s.computed)==null?void 0:m.gray)==null?void 0:p[50];return e.jsx(F.Icon,{name:l,size:r,style:{color:c}})},i=()=>{var c,a,u,f;if(t!=="secondary-danger"&&t!=="secondary-primary")return n.title;const l={color:n.disabled?"var(--sa-text-disable, #181a198f)":t==="secondary-danger"?(a=(c=s==null?void 0:s.computed)==null?void 0:c.red)==null?void 0:a[600]:(f=(u=s==null?void 0:s.computed)==null?void 0:u.blue)==null?void 0:f[700]};switch(r){case"xs":return e.jsx(Xe.Body2,{props:{style:l},children:n.title});case"sm":case"md":return e.jsx(Xe.SubH3,{props:{style:l},children:n.title});case"lg":return e.jsx(Xe.SubH2,{props:{style:l},children:n.title});default:return n.title}};return e.jsx(H.Button,{fullWidth:!0,disabled:n.disabled,primary:t==="primary",secondary:t==="secondary"||t==="secondary-danger"||t==="secondary-primary",success:t==="success",onClick:n.onClick,type:n.type,iconLeft:o(n.iconLeft),iconRight:o(n.iconRight),size:r,children:i()})},Ml=t=>e.jsx(Xe.H5,{props:{...t},children:t.title}),Il=({size:t="md",direction:r="vertical",requiredTitle:n="(Required)",fullWidth:s=!1,...o})=>{var c,a,u;const i=o.hideMessageError||!1,l=r==="horizontal"?t==="sm"?342:t==="lg"?400:342:void 0;return e.jsxs(x.Box,{gap:r==="horizontal"?"spacing-96":"sm",direction:r==="horizontal"?"row":"column",onClick:o.onClickContainer,children:[o.title&&e.jsx(ue,{condition:!!o.inputProps.required,fallback:e.jsxs(x.Box,{direction:"column",customMaxWidth:l,fullWidth:s,children:[e.jsx(fe,{children:o.title}),e.jsx(v.Text,{fontSize:t,color:"gray-500",children:o.description})]}),children:e.jsxs(x.Box,{direction:"column",customMaxWidth:l,fullWidth:s,children:[e.jsxs(ce.Flex,{direction:"row",gap:"xs",align:"center",children:[e.jsx(fe,{fontSize:t,children:o.title}),e.jsx(fe,{color:"error",fontSize:t,children:n}),e.jsx(ue,{condition:!!((c=o.tooltip)!=null&&c.label),children:e.jsx(Fe.Tooltip,{label:(a=o.tooltip)==null?void 0:a.label,arrowPosition:(u=o.tooltip)==null?void 0:u.arrowPosition,...o.tooltip,children:e.jsx(F.Icon,{name:"InfoCircle",size:t==="lg"?"sm":"xs",style:{color:"var(--sa-color-info-500, #00abeb)",marginTop:"6px"}})})})]}),e.jsx(ue,{condition:!!o.description,children:e.jsx(v.Text,{fontSize:t,color:"gray-500",children:o.description})})]})}),e.jsxs(ce.Flex,{direction:"column",gap:"xs",children:[e.jsx(x.Box,{direction:"column",style:{width:r==="horizontal"&&o.customWidth?o.customWidth:r==="horizontal"?"343px":""},children:e.jsx(ht.StarasiaDate,{size:t,...o.inputProps,status:o.errorMessage?"error":void 0})}),!i&&o.errorMessage&&e.jsx(lt,{message:o.errorMessage})]})]})};async function Ll(t,r){const n=new Image;n.src=t,await new Promise((i,l)=>{n.onload=i,n.onerror=l});const s=document.createElement("canvas");s.width=r.width,s.height=r.height;const o=s.getContext("2d",{alpha:!0});if(!o)throw new Error("No 2D context");return o.drawImage(n,r.x,r.y,r.width,r.height,0,0,r.width,r.height),new Promise((i,l)=>{s.toBlob(c=>{if(!c)return l("Canvas is empty");const a=new File([c],"cropped.png",{type:"image/png"});i(a)},"image/png")})}const Nn={"1:1":1,"4:3":4/3,"16:9":16/9,"3:4":3/4,"9:16":9/16,"2:3":2/3,"3:2":3/2,"32:9":32/9},Oo=d.forwardRef(({handleUpload:t,urlImage:r,isUploading:n,croppedImage:s,setCroppedImage:o,size:i="96",aspect:l="1:1",containerProps:c,maxFileSize:a=2,onError:u},f)=>{const g=Ce.useMediaQuery("md"),[m,p]=d.useState(!1),[S,b]=d.useState(null),[I,B]=d.useState(!1),[M,C]=d.useState({x:0,y:0}),[D,A]=d.useState(1),[R,w]=d.useState(null);d.useEffect(()=>{r===null&&o(null)},[r]);const O=d.useCallback((z,P)=>{w(P)},[]),L=z=>{var ye;const P=(ye=z.target.files)==null?void 0:ye[0];if(!P)return;const se=new FileReader;se.onload=()=>{b(se.result),B(!0)},se.readAsDataURL(P)},U=async()=>{if(!(!S||!R))try{const z=await Ll(S,R);if(a&&z.size>a*1024*1024){u==null||u(`Ukuran file maksimal ${a}MB`);return}t==null||t(z);const P=URL.createObjectURL(z);o(P,z),B(!1)}catch{u==null||u("Gagal memproses gambar")}},J=d.useRef(null),N=()=>{J.current&&J.current.click()};d.useImperativeHandle(f,()=>({openFileDialog:()=>{var z;(z=J.current)==null||z.click()}}));const _=parseInt(i,10),X=Nn[l];let te,V;return X>=1?(V=_,te=_*X):(te=_,V=_/X),e.jsxs(x.Box,{direction:"column",display:"flex",position:"relative",bg:(c==null?void 0:c.bg)||"gray-200",borderStyle:(c==null?void 0:c.borderStyle)||"border-none",borderColor:(c==null?void 0:c.borderColor)||"gray-200",borderWidth:(c==null?void 0:c.borderWidth)||"border-2",borderRadius:(c==null?void 0:c.borderRadius)||"rounded-md",overflow:"overflow-hidden",align:"center",justify:"center",style:{width:c!=null&&c.fullWidth?"100%":`${te}px`,height:c!=null&&c.fullWidth?"auto":`${V}px`,aspectRatio:X,flexShrink:0},onMouseEnter:()=>p(!0),onMouseLeave:()=>p(!1),children:[s||r?e.jsx("img",{src:s||r||void 0,alt:"Profile",style:{objectFit:"cover",width:"100%",height:"100%"}}):e.jsx(x.Box,{display:"flex",direction:"column",align:"center",justify:"center",padding:"spacing-4",children:e.jsx(F.Icon,{name:"Image",style:{color:"var(--sa-text-subtle, #8c8f97)",width:Number(i)/2<40?Number(i)/2:40,height:Number(i)/2<40?Number(i)/2:40}})}),e.jsxs(x.Box,{direction:"column",position:"absolute",display:"flex",align:"center",justify:"center",cursor:"pointer",style:{inset:0,backgroundColor:"var(--sa-color-black-alpha-a30, #080f214c)",opacity:m?1:0,transition:"opacity 0.3s ease-in-out"},onClick:N,children:[e.jsx("input",{ref:J,type:"file",accept:"image/*",onChange:L,disabled:n,style:{display:"none"}}),e.jsxs(x.Box,{display:"flex",align:"center",gap:"spacing-2",direction:"row",children:[e.jsx(F.Icon,{name:"Edit3",style:{color:"var(--sa-background-primary, #ffffff)"}}),e.jsx(ue,{condition:i.toNumber()>80,children:e.jsx(v.Text,{color:"gray-50",fontSize:i.toNumber()>80?"sm":"md",fontWeight:"medium",children:"Edit Image"})})]})]}),n&&e.jsx(x.Box,{direction:"column",position:"absolute",display:"flex",align:"center",justify:"center",style:{inset:0,zIndex:20,backgroundColor:"var(--sa-color-white-alpha-a80, #e5e9f6cc)"},children:e.jsx(x.Box,{direction:"column",borderRadius:"rounded-full",style:{animation:"spin 1s linear infinite",border:"2px solid transparent",height:"2rem",width:"2rem"},borderColor:"info-600"})}),I&&Xt.createPortal(e.jsx("div",{style:{position:"fixed",inset:0,zIndex:19999,display:"flex",alignItems:"center",justifyContent:"center",backgroundColor:"rgba(0,0,0,0.6)"},onClick:()=>B(!1),children:e.jsxs("div",{style:{backgroundColor:"var(--sa-background-primary)",borderRadius:"var(--sa-radii-md)",boxShadow:"0 20px 60px rgba(0,0,0,0.3)",overflow:"hidden",width:g?l==="1:1"?"min(90vw, 480px)":`min(90vw, ${te*2}px)`:"calc(100vw - 2rem)",display:"flex",flexDirection:"column"},onClick:z=>z.stopPropagation(),children:[e.jsx("div",{style:{position:"relative",width:"100%",height:"20rem",backgroundColor:"var(--sa-color-gray-100)"},children:S&&e.jsx(ls,{image:S,crop:M,zoom:D,aspect:l?Nn[l]:void 0,onCropChange:C,onZoomChange:A,onCropComplete:O,objectFit:"contain",minZoom:.5,restrictPosition:!1})}),e.jsxs("div",{style:{display:"flex",justifyContent:"flex-end",gap:"0.5rem",padding:"0.75rem 1rem",borderTop:"1px solid var(--sa-border-subtle)"},children:[e.jsx(H.Button,{size:"sm",secondary:!0,onClick:()=>B(!1),children:"Cancel"}),e.jsx(H.Button,{size:"sm",primary:!0,onClick:U,children:"Crop"})]})]})}),document.body)]})}),Tl=({size:t="md",direction:r="vertical",requiredTitle:n="(Required)",fullWidth:s=!1,required:o=!1,...i})=>{var a,u,f;const l=i.hideMessageError||!1,c=r==="horizontal"?t==="sm"?342:t==="lg"?400:342:void 0;return e.jsxs(x.Box,{gap:r==="horizontal"?"spacing-96":"sm",direction:r==="horizontal"?"row":"column",...i.containerProps,children:[i.title&&e.jsx(ue,{condition:!!o,fallback:e.jsxs(x.Box,{direction:"column",customMaxWidth:c,fullWidth:s,children:[e.jsx(fe,{children:i.title}),e.jsx(v.Text,{fontSize:t,color:"gray-500",children:i.description})]}),children:e.jsxs(x.Box,{direction:"column",customMaxWidth:c,fullWidth:s,children:[e.jsxs(ce.Flex,{direction:"row",gap:"xs",align:"center",children:[e.jsx(fe,{fontSize:t,children:i.title}),e.jsx(fe,{color:"error",fontSize:t,children:n}),e.jsx(ue,{condition:!!((a=i.tooltip)!=null&&a.label),children:e.jsx(Fe.Tooltip,{label:(u=i.tooltip)==null?void 0:u.label,arrowPosition:(f=i.tooltip)==null?void 0:f.arrowPosition,...i.tooltip,children:e.jsx(F.Icon,{name:"InfoCircle",size:t==="lg"?"sm":"xs",style:{color:"var(--sa-color-info-500, #00abeb)",marginTop:"6px"}})})})]}),e.jsx(ue,{condition:!!i.description,children:e.jsx(v.Text,{fontSize:t,color:"gray-500",children:i.description})})]})}),e.jsxs(ce.Flex,{direction:"column",gap:"xs",children:[e.jsx(Oo,{...i.inputProps}),!l&&i.errorMessage&&e.jsx(lt,{message:i.errorMessage})]})]})},Ol=({size:t="md",direction:r="vertical",requiredTitle:n="(Required)",fullWidth:s=!1,...o})=>{var l,c,a;const i=r==="horizontal"?t==="sm"?342:t==="lg"?400:342:void 0;return e.jsxs(x.Box,{gap:r==="horizontal"?"spacing-96":"sm",direction:r==="horizontal"?"row":"column",...o.containerProps,children:[o.title&&e.jsx(ue,{condition:!!o.inputProps.required,fallback:e.jsxs(x.Box,{direction:"column",customMaxWidth:i,fullWidth:s,children:[e.jsx(fe,{children:o.title}),e.jsx(v.Text,{fontSize:t,color:"gray-500",children:o.description})]}),children:e.jsxs(x.Box,{direction:"column",customMaxWidth:i,fullWidth:s,children:[e.jsxs(ce.Flex,{direction:"row",gap:"xs",align:"center",children:[e.jsx(fe,{fontSize:t,children:o.title}),e.jsx(fe,{color:"error",fontSize:t,children:n}),e.jsx(ue,{condition:!!((l=o.tooltip)!=null&&l.label),children:e.jsx(Fe.Tooltip,{label:(c=o.tooltip)==null?void 0:c.label,arrowPosition:(a=o.tooltip)==null?void 0:a.arrowPosition,...o.tooltip,children:e.jsx(F.Icon,{name:"InfoCircle",size:t==="lg"?"sm":"xs",style:{color:"var(--sa-color-info-500, #00abeb)",marginTop:"6px"}})})})]}),e.jsx(ue,{condition:!!o.description,children:e.jsx(v.Text,{fontSize:t,color:"gray-500",children:o.description})})]})}),o.inputProps.extended&&o.inputProps.extended]})},Rl=({items:t,id:r,handleOnUpdate:n,width:s,toggleShow:o=!0,disabled:i=!1})=>{var f;const[l,c]=d.useState([]);d.useEffect(()=>{t&&c([...t.map(g=>({id:g.id,isActive:g.isActive}))])},[t]);const a=(f=l.find(g=>g.id===r))==null?void 0:f.isActive,u=d.useCallback(()=>{c(g=>g.map(m=>m.id===r?{...m,isActive:!m.isActive}:m)),n&&n(!a)},[r,n,a]);return e.jsx(x.Box,{direction:"row",gap:"md",style:{width:s},children:o&&e.jsx(vt.Toggle,{disabled:i,checked:a,onChange:u,label:a?"Active":"Inactive"})})},Al={InputText:Ji,InputDropdown:Yi,InputSingleFile:Dl,CheckBoxOptions:Sl,RadioOptions:kl,InputTextArea:Bl,ToggleForm:El,ActionButton:Fl,FormTitle:Ml,InputDate:Il,InputImgFile:Tl,Custom:Ol},Ro=({customBottom:t})=>{const[r,n]=d.useState(!1),s=()=>{window.scrollY>window.screenY?n(!0):n(!1)},o=()=>{window.scrollTo({top:0,behavior:"smooth"})};return d.useEffect(()=>(window.addEventListener("scroll",s),()=>{window.removeEventListener("scroll",s)}),[]),e.jsx(x.Box,{direction:"column",style:{position:"fixed",bottom:0,right:0},children:e.jsx(x.Box,{direction:"column",position:"absolute",style:{bottom:t||"1.6rem",right:"2rem",transform:r?"scale(1)":"scale(0)",transition:"transform 0.2s ease-in-out"},children:e.jsx(H.Button,{secondary:!0,size:"xs",onClick:o,type:"button",iconLeft:e.jsx(F.Icon,{width:16,size:"xs",name:"ArrowPullUp",style:{color:"var(--sa-background-brand, #04254f)"}})})})})},Ge="sa-sidepanel-item",_n="sa-sidepanel-item-styles",Wl="inset 3.5px 0 0 0 var(--sa-border-focused, #1a4fa0)",zl="inset -3.5px 0 0 0 var(--sa-border-focused, #1a4fa0)",Hl=`
|
|
58
58
|
.${Ge} {
|
|
59
59
|
display: block;
|
|
60
60
|
box-sizing: border-box;
|
package/dist/index.es.js
CHANGED
|
@@ -7382,7 +7382,6 @@ const Ps = Zl(jl), Tn = 200, Fr = "1px solid var(--sa-border-subtle, #0b120e24)"
|
|
|
7382
7382
|
{
|
|
7383
7383
|
label: (a = i.tooltip) == null ? void 0 : a.label,
|
|
7384
7384
|
arrowPosition: (u = i.tooltip) == null ? void 0 : u.arrowPosition,
|
|
7385
|
-
focusable: !0,
|
|
7386
7385
|
...i.tooltip,
|
|
7387
7386
|
children: /* @__PURE__ */ e(
|
|
7388
7387
|
M,
|
|
@@ -7468,7 +7467,6 @@ const Ps = Zl(jl), Tn = 200, Fr = "1px solid var(--sa-border-subtle, #0b120e24)"
|
|
|
7468
7467
|
{
|
|
7469
7468
|
label: (a = i.tooltip) == null ? void 0 : a.label,
|
|
7470
7469
|
arrowPosition: (u = i.tooltip) == null ? void 0 : u.arrowPosition,
|
|
7471
|
-
focusable: !0,
|
|
7472
7470
|
...i.tooltip,
|
|
7473
7471
|
children: /* @__PURE__ */ e(
|
|
7474
7472
|
M,
|
|
@@ -7971,7 +7969,6 @@ const dc = (t) => {
|
|
|
7971
7969
|
{
|
|
7972
7970
|
label: (a = i.tooltip) == null ? void 0 : a.label,
|
|
7973
7971
|
arrowPosition: (u = i.tooltip) == null ? void 0 : u.arrowPosition,
|
|
7974
|
-
focusable: !0,
|
|
7975
7972
|
...i.tooltip,
|
|
7976
7973
|
children: /* @__PURE__ */ e(
|
|
7977
7974
|
M,
|
|
@@ -8054,7 +8051,6 @@ const dc = (t) => {
|
|
|
8054
8051
|
{
|
|
8055
8052
|
label: (u = l.tooltip) == null ? void 0 : u.label,
|
|
8056
8053
|
arrowPosition: (m = l.tooltip) == null ? void 0 : m.arrowPosition,
|
|
8057
|
-
focusable: !0,
|
|
8058
8054
|
...l.tooltip,
|
|
8059
8055
|
children: /* @__PURE__ */ e(
|
|
8060
8056
|
M,
|
|
@@ -8255,7 +8251,6 @@ const dc = (t) => {
|
|
|
8255
8251
|
{
|
|
8256
8252
|
label: (a = i.tooltip) == null ? void 0 : a.label,
|
|
8257
8253
|
arrowPosition: (u = i.tooltip) == null ? void 0 : u.arrowPosition,
|
|
8258
|
-
focusable: !0,
|
|
8259
8254
|
...i.tooltip,
|
|
8260
8255
|
children: /* @__PURE__ */ e(
|
|
8261
8256
|
M,
|
|
@@ -8340,7 +8335,6 @@ const dc = (t) => {
|
|
|
8340
8335
|
{
|
|
8341
8336
|
label: (a = l.tooltip) == null ? void 0 : a.label,
|
|
8342
8337
|
arrowPosition: (u = l.tooltip) == null ? void 0 : u.arrowPosition,
|
|
8343
|
-
focusable: !0,
|
|
8344
8338
|
...l.tooltip,
|
|
8345
8339
|
children: /* @__PURE__ */ e(
|
|
8346
8340
|
M,
|
|
@@ -8475,7 +8469,6 @@ const dc = (t) => {
|
|
|
8475
8469
|
{
|
|
8476
8470
|
label: (a = i.tooltip) == null ? void 0 : a.label,
|
|
8477
8471
|
arrowPosition: (u = i.tooltip) == null ? void 0 : u.arrowPosition,
|
|
8478
|
-
focusable: !0,
|
|
8479
8472
|
...i.tooltip,
|
|
8480
8473
|
children: /* @__PURE__ */ e(
|
|
8481
8474
|
M,
|
|
@@ -8874,7 +8867,6 @@ const $n = {
|
|
|
8874
8867
|
{
|
|
8875
8868
|
label: (u = l.tooltip) == null ? void 0 : u.label,
|
|
8876
8869
|
arrowPosition: (m = l.tooltip) == null ? void 0 : m.arrowPosition,
|
|
8877
|
-
focusable: !0,
|
|
8878
8870
|
...l.tooltip,
|
|
8879
8871
|
children: /* @__PURE__ */ e(
|
|
8880
8872
|
M,
|
|
@@ -8950,7 +8942,6 @@ const $n = {
|
|
|
8950
8942
|
{
|
|
8951
8943
|
label: (s = i.tooltip) == null ? void 0 : s.label,
|
|
8952
8944
|
arrowPosition: (a = i.tooltip) == null ? void 0 : a.arrowPosition,
|
|
8953
|
-
focusable: !0,
|
|
8954
8945
|
...i.tooltip,
|
|
8955
8946
|
children: /* @__PURE__ */ e(
|
|
8956
8947
|
M,
|
package/dist/index.umd.js
CHANGED
|
@@ -54,7 +54,7 @@
|
|
|
54
54
|
.sa-table-layout tfoot.sa-tl-sticky-foot > tr:first-child > th {
|
|
55
55
|
box-shadow: 0 -2px 4px -2px var(--sa-border-subtle, #0b120e24);
|
|
56
56
|
}
|
|
57
|
-
`,document.head.appendChild(r)},Lr=r=>r==="right"?"right":r==="center"?"center":"left",gs=/^(#|rgb|hsl|var\()/,Xr=r=>r?gs.test(r)?r:`var(--sa-background-${r})`:void 0,ys=(r,t)=>{if(t)return r[t]},ps=(r,t)=>r==null&&t==null?0:r==null?-1:t==null?1:typeof r=="number"&&typeof t=="number"?r-t:String(r).localeCompare(String(t)),bs=({columns:r,data:t,getRowKey:o,rowBg:n,size:l="md",resizable:s=!1,layout:c="auto",widthStorageKey:i,columnState:a,onColumnStateChange:h,columnMenu:y=!1,sort:b,defaultSort:p,onSortChange:C,height:m,mobileLayout:w="cards",mobileBreakpoint:L="md",groupSeparator:F,summary:T,footer:S,stickyFooter:k=!1,emptyState:H,loading:z=!1,loadingRows:B=8,rowActions:W,selectable:O=!1,selectedKeys:Y,defaultSelectedKeys:X,onSelectionChange:q,isRowSelectable:Z})=>{us();const te=!Se.useMediaQuery(L)&&w!=="scroll",_=!!(W!=null&&W.length),[V,N]=d.useState(null);d.useEffect(()=>{if(!V)return;const v=()=>N(null),x=setTimeout(()=>document.addEventListener("click",v),0);return()=>{clearTimeout(x),document.removeEventListener("click",v)}},[V]);const[se,ve]=d.useState(()=>new Set),me=a!==void 0,[ue,Ce]=d.useState({}),xe=a??ue,we=v=>{h==null||h(v),me||Ce(v)},Ae=b!==void 0,[Fe,_e]=d.useState(p??null),$=Ae?b??null:Fe,ge=!C,We=v=>{C==null||C(v),Ae||_e(v)},{headerGroups:Ze,leafColumns:de,hasGroups:Ge}=d.useMemo(()=>{var ce;const v=new Set(xe.hidden??[]),x=(oe,pe)=>oe.key??(typeof oe.accessor=="string"?oe.accessor:`col-${pe}`),I=r.map((oe,pe)=>{var Xe;if((Xe=oe.children)!=null&&Xe.length){const Wr=oe.children.map((rr,zr)=>({col:rr,key:x(rr,`${pe}-${zr}`)})).filter(rr=>!v.has(rr.key));return{col:oe,key:oe.key??`group-${pe}`,isGroup:!0,leaves:Wr}}const be={col:oe,key:x(oe,`${pe}`)};return{col:oe,key:be.key,isGroup:!1,leaves:v.has(be.key)?[]:[be]}}).filter(oe=>oe.leaves.length>0),Q=I.some(oe=>oe.isGroup);let le=I.flatMap(oe=>oe.leaves);if(!Q&&((ce=xe.order)!=null&&ce.length)){const oe=new Map(xe.order.map((pe,be)=>[pe,be]));le=[...le].sort((pe,be)=>(oe.get(pe.key)??1/0)-(oe.get(be.key)??1/0))}return{headerGroups:I,leafColumns:le,hasGroups:Q}},[r,xe]),lr=d.useMemo(()=>new Map(de.map((v,x)=>[v.key,x])),[de]),P=!Ge&&de.some(v=>(v.col.headerColSpan??1)>1),R=de.map(v=>v.key).join("|"),J=(v,x)=>{const I=v.sortKey??(typeof v.accessor=="string"?v.accessor:void 0);return I?x[I]:void 0},he=v=>v.sortable??(!!v.sortKey||typeof v.accessor=="string"),ie=d.useMemo(()=>{if(!ge||!$)return t;const v=de.find(I=>I.key===$.key);if(!v)return t;const x=$.direction==="asc"?1:-1;return[...t].sort((I,Q)=>ps(J(v.col,I),J(v.col,Q))*x)},[t,ge,$,de]),Me=!Ge&&!P,ze=!!i&&Me,[er,Qe]=U.useColumnWidths(i??""),Le=ze?er:void 0,Je=d.useRef(null),[Be,Ue]=d.useState();d.useLayoutEffect(()=>{Ue(void 0)},[R]),d.useLayoutEffect(()=>{if(!Me||Be||!Je.current)return;const v=Je.current.querySelectorAll("th.sa-tl-leaf");Ue(Array.from(v).map(x=>x.offsetWidth))},[Be,Me]);const[nr,gr]=d.useState(),[dr,hr]=d.useState(0);d.useLayoutEffect(()=>{if(!Ge||!Je.current)return;const v=Je.current.querySelector(":scope > tr");v&&hr(v.offsetHeight)},[Ge,R]);const Sr=(v,x)=>{if((Le==null?void 0:Le[x])!=null)return Le[x];if(v.width!=null)return v.width;if((Be==null?void 0:Be[x])!=null)return Be[x]},E=(v,x)=>typeof v.width=="number"?v.width:Be==null?void 0:Be[x],G=xe.frozenKey&&!Ge&&!P?de.findIndex(v=>v.key===xe.frozenKey):-1,re=v=>v<=G,De=O?Tr:0,Oe=v=>{const x=nr??Be;if(!x)return De;let I=De;for(let Q=0;Q<v;Q++)I+=x[Q]??0;return I};d.useLayoutEffect(()=>{const v=Je.current;if(!v||G<0){gr(void 0);return}let x=0;const I=()=>{x=0;const le=v.querySelectorAll("th.sa-tl-leaf"),ce=Array.from(le).map(oe=>oe.getBoundingClientRect().width);gr(oe=>oe&&oe.length===ce.length&&oe.every((pe,be)=>Math.abs(pe-ce[be])<.5)?oe:ce)},Q=new ResizeObserver(()=>{x||(x=requestAnimationFrame(I))});return Q.observe(v),v.querySelectorAll("th.sa-tl-leaf").forEach(le=>Q.observe(le)),I(),()=>{x&&cancelAnimationFrame(x),Q.disconnect()}},[R,G,O,Be,Le]);const Ye=d.useRef(null),[He,ke]=d.useState("100vh");d.useLayoutEffect(()=>{if(m!==void 0)return;const v=()=>{if(Ye.current){const x=Ye.current.getBoundingClientRect().top;ke(`calc(100vh - ${x}px - var(--sa-floating-footer-height, 0px) + 12px)`)}};return v(),window.addEventListener("resize",v),()=>window.removeEventListener("resize",v)},[m]);const Ie=(v,x)=>o?o(v,x):x,Ve=Y!==void 0,[Ar,_c]=d.useState(()=>new Set(X??[])),ir=d.useMemo(()=>Ve?new Set(Y):Ar,[Ve,Y,Ar]);d.useEffect(()=>{O&&!o&&process.env.NODE_ENV!=="production"&&console.warn("[@starasia/admin] TableLayout: `selectable` tanpa `getRowKey` — key default (index) membuat seleksi menempel ke POSISI baris, bukan datanya. Beri `getRowKey` yang stabil (mis. r => r.id).")},[O,!o]);const Tl=v=>{if(Ve||_c(v),q){const x=ie.filter((I,Q)=>v.has(Ie(I,Q)));q(Array.from(v),x)}},Nt=(v,x)=>O&&(Z?Z(v,x):!0),_t=v=>{const x=new Set(ir);x.has(v)?x.delete(v):x.add(v),Tl(x)},Br=d.useMemo(()=>O?ie.map((v,x)=>({row:v,i:x,key:Ie(v,x)})).filter(({row:v,i:x})=>Z?Z(v,x):!0).map(({key:v})=>v):[],[O,ie,Z,o]),Ll=Br.filter(v=>ir.has(v)),qt=Br.length>0&&Ll.length===Br.length,Ol=Ll.length>0&&!qt,qc=()=>{const v=new Set(ir);qt?Br.forEach(x=>v.delete(x)):Br.forEach(x=>v.add(x)),Tl(v)},Zt=(v,x,I)=>v.render?v.render(x,I,ie):ys(x,v.accessor),Gt=de.length+(O?1:0)+(_?1:0),Al=["80%","55%","70%","45%","90%","60%"],Zc=(v,x)=>Al[(v*7+x*3)%Al.length],Gc=(v,x)=>e.jsx($e.Skeleton,{height:14,width:Zc(v,x),borderRadius:"rounded-sm"}),Qc=Array.from({length:B},(v,x)=>e.jsxs(U.Tr,{children:[O&&e.jsx(U.Td,{style:{width:Tr,padding:0},children:e.jsx("div",{style:{display:"flex",justifyContent:"center"},children:e.jsx($e.Skeleton,{height:14,width:14,borderRadius:"rounded-sm"})})}),de.map(({col:I,key:Q},le)=>e.jsx(U.Td,{style:{textAlign:Lr(I.align)},children:Gc(x,le)},`sa-tl-sk-${x}-${Q}`)),_&&e.jsx(U.Td,{style:{width:1,padding:0,border:"none"}})]},`sa-tl-sk-${x}`)),Uc=(v,x)=>{x||we({...xe,hidden:[...xe.hidden??[],v]})},Jc=v=>we({...xe,frozenKey:xe.frozenKey===v?void 0:v}),nt=v=>(W??[]).filter(x=>{var I;return!((I=x.hidden)!=null&&I.call(x,v))}),Wl={position:"absolute",right:0,top:0,bottom:0,display:"flex",alignItems:"center",gap:4,paddingRight:16,paddingLeft:40,background:"linear-gradient(to right, transparent, var(--sa-background-primary-inverse, #f8f8f8) 40px)"},st=(v,x,I,Q)=>{var Xe;const le=(Xe=v.disabled)==null?void 0:Xe.call(v,x),ce=(Q==null?void 0:Q.showLabel)??v.showLabel,oe=(Q==null?void 0:Q.size)??"xs",pe=e.jsx(j.Button,{size:oe,variant:v.variant??"tertiary",tone:v.tone??"neutral",disabled:le,onClick:()=>v.onClick(x,I),iconLeft:v.icon?e.jsx(M.Icon,{name:v.icon,size:"sm"}):void 0,children:ce&&v.label}),be=v.tooltip;return be?e.jsx(Ee.Tooltip,{label:be,position:"top-end",children:pe}):pe},Yc=(v,x)=>{const I=nt(v);if(!I.length)return null;if(I.length>5){const le=Ie(v,x),ce=(V==null?void 0:V.rowKey)===le;return e.jsx("div",{className:"sa-tl-row-actions",style:Wl,onClick:oe=>oe.stopPropagation(),children:e.jsx(Ee.Tooltip,{label:"Aksi lainnya",position:"top",children:e.jsx(j.Button,{size:"xs",variant:"tertiary",onClick:oe=>{const pe=oe.currentTarget.getBoundingClientRect();N(ce?null:{rowKey:le,top:pe.bottom+4,right:window.innerWidth-pe.right})},children:e.jsx(M.Icon,{name:"MenuVertical",size:"sm"})})})})}return e.jsx("div",{className:"sa-tl-row-actions",style:Wl,children:I.map(le=>e.jsx(d.Fragment,{children:st(le,v,x)},le.key))})},Xc=(v,x)=>{const I=nt(v);return I.length?e.jsx("div",{style:{display:"flex",gap:6,flexWrap:"wrap",paddingTop:8,marginTop:8,borderTop:Ir},children:I.map(Q=>e.jsx(d.Fragment,{children:st(Q,v,x,{showLabel:!0,size:"sm"})},Q.key))}):null},$c=(v,x)=>{const I=nt(v);return I.length?e.jsx("div",{style:{display:"flex",gap:4,paddingRight:8,flexShrink:0},children:I.map(Q=>e.jsx(d.Fragment,{children:st(Q,v,x,{showLabel:!1})},Q.key))}):null},Qt=(v,x)=>{const{col:I,key:Q}=v,le=lr.get(Q)??0,ce=re(le),oe=ce&&le===G,pe=($==null?void 0:$.key)===Q?$.direction:null,be=y&&!I.disableMenu?e.jsx(gl,{active:!!pe||ce,canSort:he(I),canHide:!I.locked,sortDir:pe,frozen:ce,onSort:zr=>We({key:Q,direction:zr}),onClearSort:()=>We(null),onToggleFreeze:()=>Jc(Q),onHide:()=>Uc(Q,I.locked)}):null,Xe=I.align==="right",Wr=I.align==="right"?"flex-end":I.align==="center"?"center":"flex-start",rr=e.jsxs("span",{style:{flex:1,minWidth:0,display:"flex",alignItems:"center",gap:6,justifyContent:Wr,overflow:"hidden"},children:[I.icon&&e.jsx(M.Icon,{name:I.icon,size:"sm",style:{flexShrink:0}}),e.jsx("span",{style:Yr,children:I.title})]});return e.jsx(U.Th,{className:`sa-tl-leaf${ce?" sa-tl-frozen":""}`,rowSpan:x==null?void 0:x.rowSpan,colSpan:x==null?void 0:x.colSpan,minWidth:I.minWidth,numeric:I.numeric,resizable:Me?I.resizable:!1,defaultWidth:E(I,le),style:{textAlign:Lr(I.align),width:Sr(I,le),position:"sticky",top:(x==null?void 0:x.top)??0,left:ce?Oe(le):void 0,zIndex:ce?3:2,backgroundColor:Dr,boxShadow:oe?yl:void 0},children:e.jsx("div",{style:{display:"flex",alignItems:"center",gap:6,width:"100%"},children:Xe?e.jsxs(e.Fragment,{children:[be,rr]}):e.jsxs(e.Fragment,{children:[rr,be]})})},`th-${Q}`)},Kc=()=>{const v=[];for(let x=0;x<de.length;){const I=de[x],Q=I.col.headerColSpan??1,le=Math.max(1,Math.min(Q,de.length-x));v.push(Qt(I,le>1?{colSpan:le}:void 0)),x+=le}return v},zl=v=>e.jsx(U.Th,{rowSpan:v==null?void 0:v.rowSpan,style:{width:Tr,position:"sticky",top:0,left:0,zIndex:4,backgroundColor:Dr,padding:0},children:e.jsx("div",{style:{display:"flex",alignItems:"center",justifyContent:"center"},onClick:x=>x.stopPropagation(),children:e.jsx(tr.Checkbox,{size:"sm",variant:Ol?"indeterminate":"select",checked:qt||Ol,disabled:Br.length===0,onChange:qc,"aria-label":"Pilih semua baris di halaman ini"})})},"th-select"),Rc=(v,x,I)=>{const Q=Ie(v,x);return e.jsx(U.Td,{className:"sa-tl-frozen",style:{width:Tr,padding:0,position:"sticky",left:0,zIndex:2,...I?{"--sa-tl-bg":I}:{}},children:Nt(v,x)&&e.jsx("div",{style:{display:"flex",alignItems:"center",justifyContent:"center"},onClick:le=>le.stopPropagation(),children:e.jsx(tr.Checkbox,{size:"sm",checked:ir.has(Q),onChange:()=>_t(Q),"aria-label":"Pilih baris"})})},`tl-select-${x}`)},Ut=de.filter(v=>!v.col.hideOnMobile),Jt=Ut.find(v=>v.col.primary)??Ut[0],ei=Ut.filter(v=>v!==Jt),ri=v=>ve(x=>{const I=new Set(x);return I.has(v)?I.delete(v):I.add(v),I}),Hl=(v,x)=>ei.map(({col:I,key:Q})=>{const le=Zt(I,v,x),ce={minWidth:0,overflow:"hidden",textOverflow:"ellipsis",textAlign:"right",...I.numeric?{fontVariantNumeric:"tabular-nums"}:{}},oe=typeof le=="string"||typeof le=="number"?e.jsx(D.Text,{style:ce,children:le}):e.jsx("div",{style:ce,children:le});return e.jsxs("div",{style:{display:"flex",gap:12,justifyContent:"space-between",alignItems:"baseline"},children:[typeof I.title=="string"?e.jsx(D.Text,{color:"subtle",fontWeight:"medium",style:{color:fs,flexShrink:0},children:I.title}):e.jsx("div",{style:{flexShrink:0},children:I.title}),oe]},Q)}),Yt=(v,x)=>{const I=Jt?Zt(Jt.col,v,x):null;return typeof I=="string"||typeof I=="number"?e.jsx(D.Text,{as:"span",style:Yr,children:I}):e.jsx("span",{style:Yr,children:I})},ti=e.jsx(f.Box,{style:{display:"flex",flexDirection:"column",gap:8,padding:8},children:Array.from({length:B},(v,x)=>e.jsxs(f.Box,{style:{border:Ir,borderRadius:"var(--sa-radii-sm, 6px)",padding:12,display:"flex",flexDirection:"column",gap:8},children:[e.jsx($e.Skeleton,{height:16,width:"60%",borderRadius:"rounded-sm"}),e.jsx($e.Skeleton,{height:12,width:"85%",borderRadius:"rounded-sm"}),e.jsx($e.Skeleton,{height:12,width:"70%",borderRadius:"rounded-sm"})]},`sa-tl-sk-card-${x}`))}),Pl=e.jsx(f.Box,{fullWidth:!0,style:{minHeight:(H==null?void 0:H.minHeight)??320,display:"flex",alignItems:"center",justifyContent:"center",padding:16},children:H==null?void 0:H.content}),oi=z?ti:ie.length===0?Pl:w==="expand"?e.jsx(f.Box,{style:{display:"flex",flexDirection:"column"},children:ie.map((v,x)=>{const I=Ie(v,x),Q=se.has(I),ce=O&&ir.has(I)?Wt:Xr(n==null?void 0:n(v,x));return e.jsxs("div",{style:{borderBottom:Ir,backgroundColor:ce},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center"},children:[Nt(v,x)&&e.jsx("div",{style:{display:"flex",alignItems:"center",paddingLeft:12,flexShrink:0},children:e.jsx(tr.Checkbox,{size:"sm",checked:ir.has(I),onChange:()=>_t(I),"aria-label":"Pilih baris"})}),e.jsxs("button",{type:"button",onClick:()=>ri(I),style:{flex:1,minWidth:0,display:"flex",alignItems:"center",justifyContent:"space-between",gap:12,padding:"10px 12px",background:"none",border:"none",font:"inherit",color:"inherit",cursor:"pointer",textAlign:"left"},children:[Yt(v,x),e.jsx(M.Icon,{name:Q?"ChevronUp":"ChevronDown",size:"sm",style:{flexShrink:0}})]}),_&&$c(v,x)]}),Q&&e.jsx("div",{style:{padding:"0 12px 12px",display:"flex",flexDirection:"column",gap:6},children:Hl(v,x)})]},I)})}):e.jsx(f.Box,{style:{display:"flex",flexDirection:"column",gap:8,padding:8},children:ie.map((v,x)=>{const I=Ie(v,x),Q=O&&ir.has(I);return e.jsxs(f.Box,{style:{border:Ir,borderRadius:"var(--sa-radii-sm, 6px)",padding:12,display:"flex",flexDirection:"column",gap:6,backgroundColor:Q?Wt:Xr(n==null?void 0:n(v,x))},children:[Nt(v,x)?e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[e.jsx(tr.Checkbox,{size:"sm",checked:ir.has(I),onChange:()=>_t(I),"aria-label":"Pilih baris"}),e.jsx("div",{style:{flex:1,minWidth:0},children:Yt(v,x)})]}):Yt(v,x),Hl(v,x),_&&Xc(v,x)]},I)})}),li=s&&Me&&Be!==void 0,Vl=c==="fixed"&&!s&&(Me?Be!==void 0:!0),ni=Vl&&!Me,ct=S&&S.length>0?S.map((v,x)=>e.jsx(U.Tr,{children:v.cells.map((I,Q)=>e.jsx(U.Td,{colSpan:I.colSpan,rowSpan:I.rowSpan,numeric:I.numeric,style:{textAlign:Lr(I.align)},children:I.content},`tl-foot-${x}-${Q}`))},`tl-foot-${x}`)):null,si=e.jsxs(U.Table,{className:"sa-table-layout",fullWidth:!0,size:l,resizable:li,style:Vl?{tableLayout:"fixed"}:void 0,onWidthsChange:ze?Qe:void 0,children:[ni&&e.jsxs("colgroup",{children:[O&&e.jsx("col",{style:{width:Tr}}),de.map(({col:v,key:x},I)=>e.jsx("col",{style:{width:Sr(v,I)}},`col-${x}`)),_&&e.jsx("col",{style:{width:1}})]}),e.jsx(U.Thead,{ref:Je,children:Ge?e.jsxs(e.Fragment,{children:[e.jsxs(U.Tr,{children:[O&&zl({rowSpan:2}),Ze.map(v=>v.isGroup?e.jsx(U.Th,{colSpan:v.leaves.length,style:{textAlign:"center",position:"sticky",top:0,zIndex:2,backgroundColor:Dr},children:e.jsx("span",{style:Yr,children:v.col.title})},`grp-${v.key}`):Qt(v.leaves[0],{rowSpan:2})),_&&e.jsx(U.Th,{rowSpan:2,style:{position:"sticky",top:0,right:0,zIndex:3,width:1,padding:0,border:"none",backgroundColor:Dr}})]}),e.jsx(U.Tr,{children:Ze.flatMap(v=>v.isGroup?v.leaves.map(x=>Qt(x,{top:dr})):[])})]}):e.jsxs(U.Tr,{children:[O&&zl(),Kc(),_&&e.jsx(U.Th,{style:{position:"sticky",top:0,right:0,zIndex:3,width:1,padding:0,border:"none",backgroundColor:Dr}})]})}),e.jsx(U.Tbody,{children:z?Qc:ie.length===0?e.jsx(U.Tr,{children:e.jsx(U.Td,{colSpan:Gt,children:Pl})}):e.jsxs(e.Fragment,{children:[ie.map((v,x)=>{const I=F==null?void 0:F(v,x,x>0?ie[x-1]:void 0),le=O&&ir.has(Ie(v,x))?Wt:Xr(n==null?void 0:n(v,x));return e.jsxs(d.Fragment,{children:[I!=null&&I!==!1&&e.jsx(U.Tr,{children:e.jsx(U.Td,{colSpan:Gt,style:{backgroundColor:Dr},children:I})}),e.jsxs(U.Tr,{children:[O&&Rc(v,x,le),de.map(({col:ce,key:oe},pe)=>{var Nl;const be=(Nl=ce.cellProps)==null?void 0:Nl.call(ce,v,x,ie);if(be!=null&&be.hidden)return null;const Xe=re(pe),Wr=Xe&&pe===G,rr=Zt(ce,v,x),zr=typeof ce.bg=="function"?ce.bg(v,x,ie):ce.bg,jl=Xr(zr)??le;return e.jsx(U.Td,{className:Xe?"sa-tl-frozen":void 0,colSpan:be==null?void 0:be.colSpan,rowSpan:be==null?void 0:be.rowSpan,numeric:ce.numeric,style:{textAlign:Lr(ce.align),width:Sr(ce,pe),minWidth:ce.minWidth,position:Xe?"sticky":void 0,left:Xe?Oe(pe):void 0,zIndex:Xe?1:void 0,boxShadow:Wr?yl:void 0,...jl?{"--sa-tl-bg":jl}:{}},children:typeof rr=="string"?e.jsx(D.Text,{style:{whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",textAlign:Lr(ce.align)},children:rr}):rr},`tl-cell-${x}-${oe}`)}),_&&e.jsx(U.Td,{style:{position:"sticky",right:0,width:1,padding:0,overflow:"visible",zIndex:2,border:"none"},children:Yc(v,x)})]})]},Ie(v,x))}),T!=null&&e.jsx(U.Tr,{children:e.jsx(U.Td,{colSpan:Gt,children:T})})]})}),ct&&e.jsx(U.Tfoot,{className:k?"sa-tl-sticky-foot":void 0,children:ct})]}),Xt=V?ie.findIndex((v,x)=>Ie(v,x)===V.rowKey):-1,$t=Xt>=0?ie[Xt]:null;return e.jsxs(e.Fragment,{children:[e.jsx(f.Box,{ref:Ye,fullWidth:!0,style:{overflow:"auto",height:m??He},children:te?e.jsxs(e.Fragment,{children:[oi,ct&&!z&&ie.length>0&&e.jsx(f.Box,{style:{borderTop:Ir},children:e.jsx(U.Table,{fullWidth:!0,size:l,className:"sa-table-layout",children:e.jsx(U.Tbody,{children:ct})})})]}):si}),V&&$t&&e.jsx("div",{className:"sa-tl-kebab-menu",style:{top:V.top,right:V.right},onClick:v=>v.stopPropagation(),children:nt($t).map(v=>e.jsx("div",{style:{padding:"2px 4px"},children:st(v,$t,Xt,{showLabel:!0,size:"sm"})},v.key))})]})},zt=r=>r==="asc"||r==="desc",vs=(r={})=>{const{sortKeyParam:t="sortBy",sortOrderParam:o="sortOrder",pageKey:n="page",defaultSort:l=null,paramKeys:s,scopeId:c,storage:i=Et}=r,{searchParams:a,setSearchParams:h,searchQueries:y}=Ne(),b=a.toString(),p=c?wr.tableSort(c):void 0,C=d.useRef(!1);d.useEffect(()=>{if(C.current||(C.current=!0,!p)||a.has(t)||a.has(o))return;const S=i.get(p);!(S!=null&&S.key)||!zt(S.direction)||h({...Object.fromEntries(a.entries()),[t]:S.key,[o]:S.direction},{replace:!0})},[]);const m=d.useMemo(()=>{const S=a.get(t),k=a.get(o);return S&&zt(k)?{key:S,direction:k}:l},[b,t,o,l]);d.useEffect(()=>{if(!p)return;const S=a.get(t),k=a.get(o);S&&zt(k)?i.set(p,{key:S,direction:k}):i.remove(p)},[b,p,t,o,i]);const w=(s==null?void 0:s.sortBy)??"sortBy",L=(s==null?void 0:s.sortOrder)??"sortOrder",F=d.useMemo(()=>m?{[w]:m.key,[L]:m.direction}:{},[m,w,L]),T=d.useCallback(S=>{const k={...y};S?(k[t]=S.key,k[o]=S.direction):(delete k[t],delete k[o]),delete k[n],h(k)},[y,t,o,n,h]);return{sort:m,setSort:T,params:F}},$r=({of:r,render:t})=>d.Children.toArray(r==null?void 0:r.map((o,n,l)=>t(o,n,l))),fe=({condition:r,fallback:t,children:o,loading:n,isLoading:l})=>e.jsx(e.Fragment,{children:l?n:r?o:t}),ye=r=>e.jsx(D.Text,{...r,fontSize:r.fontSize||"md",fontWeight:r.fontWeight||"medium",color:r.color||"gray-700",children:r.children}),cr=r=>e.jsx(D.Text,{color:"red-600",fontSize:"sm",children:r.message}),Cs=({size:r="md",direction:t="vertical",requiredTitle:o="(Required)",fullWidth:n=!1,...l})=>{var i,a,h;const s=l.hideMessageError||!1,c=t==="horizontal"?r==="sm"?342:r==="lg"?400:342:void 0;return e.jsxs(f.Box,{gap:t==="horizontal"?"spacing-96":"sm",direction:t==="horizontal"?"row":"column",...l.containerProps,children:[l.title&&e.jsx(fe,{condition:!!l.inputProps.required,fallback:e.jsxs(f.Box,{direction:"column",customMaxWidth:c,fullWidth:n,children:[e.jsx(ye,{children:l.title}),e.jsx(D.Text,{fontSize:r,color:"gray-500",children:l.description})]}),children:e.jsxs(f.Box,{direction:"column",customMaxWidth:c,fullWidth:n,children:[e.jsxs(ae.Flex,{direction:"row",gap:"xs",align:"center",children:[e.jsx(ye,{fontSize:r,children:l.title}),e.jsx(ye,{color:"error",fontSize:r,children:o}),e.jsx(fe,{condition:!!((i=l.tooltip)!=null&&i.label),children:e.jsx(Ee.Tooltip,{label:(a=l.tooltip)==null?void 0:a.label,arrowPosition:(h=l.tooltip)==null?void 0:h.arrowPosition,focusable:!0,...l.tooltip,children:e.jsx(M.Icon,{name:"InfoCircle",size:r==="lg"?"sm":"xs",style:{color:"var(--sa-color-info-500, #00abeb)",marginTop:"6px"}})})})]}),e.jsx(fe,{condition:!!l.description,children:e.jsx(D.Text,{fontSize:r,color:"gray-500",children:l.description})})]})}),e.jsxs(f.Box,{direction:"column",gap:"xs",fullWidth:l.inputProps.fullWidth||!1,children:[e.jsx(ar.Input,{ref:l.inputRef,size:r,...l.inputProps,status:l.errorMessage?"error":"default",fullWidth:!0}),!s&&l.errorMessage&&e.jsx(cr,{message:l.errorMessage}),l.inputProps.extended&&l.inputProps.extended]})]})},xs=({size:r="md",direction:t="vertical",requiredTitle:o="(Required)",fullWidth:n=!1,...l})=>{var i,a,h;const s=l.hideMessageError||!1,c=t==="horizontal"?r==="sm"?342:r==="lg"?400:342:void 0;return e.jsxs(f.Box,{gap:t==="horizontal"?"spacing-96":"sm",direction:t==="horizontal"?"row":"column",onClick:l.onClickContainer,children:[l.title&&e.jsx(fe,{condition:!!l.inputProps.required,fallback:e.jsxs(f.Box,{direction:"column",customMaxWidth:c,fullWidth:n,children:[e.jsx(ye,{children:l.title}),e.jsx(D.Text,{fontSize:r,color:"gray-500",children:l.description})]}),children:e.jsxs(f.Box,{direction:"column",customMaxWidth:c,fullWidth:n,children:[e.jsxs(ae.Flex,{direction:"row",gap:"xs",align:"center",children:[e.jsx(ye,{fontSize:r,children:l.title}),e.jsx(ye,{color:"error",fontSize:r,children:o}),e.jsx(fe,{condition:!!((i=l.tooltip)!=null&&i.label),children:e.jsx(Ee.Tooltip,{label:(a=l.tooltip)==null?void 0:a.label,arrowPosition:(h=l.tooltip)==null?void 0:h.arrowPosition,focusable:!0,...l.tooltip,children:e.jsx(M.Icon,{name:"InfoCircle",size:r==="lg"?"sm":"xs",style:{color:"var(--sa-color-info-500, #00abeb)",marginTop:"6px"}})})})]}),e.jsx(fe,{condition:!!l.description,children:e.jsx(D.Text,{fontSize:r,color:"gray-500",children:l.description})})]})}),e.jsxs(f.Box,{direction:"column",gap:"xs",fullWidth:l.inputProps.fullWidth||!1,children:[e.jsx(f.Box,{direction:"column",style:{width:l.inputProps.fullWidth?"100%":t==="horizontal"&&l.customWidth?l.customWidth:t==="horizontal"?"343px":""},children:e.jsx(br.Dropdown,{size:r,...l.inputProps,error:!!l.errorMessage})}),!s&&l.errorMessage&&e.jsx(cr,{message:l.errorMessage}),l.inputProps.extended&&l.inputProps.extended]})]})},ws=(r,t)=>typeof r=="string"&&r||t==="error"?"var(--sa-border-danger)":"var(--sa-border-subtle)",Ds=r=>{var i;const[t,o]=d.useState(!1),n=a=>{a.preventDefault(),a.stopPropagation()},l=a=>{a.preventDefault(),a.stopPropagation(),a.dataTransfer&&r.handleOnFileChange(a.dataTransfer.files.item(0))},s=a=>{a.preventDefault(),o(!0)},c=a=>{a.preventDefault(),o(!1)};return e.jsxs(f.Box,{width:"width-full",paddingInline:"md",direction:"row",gap:"sm",align:"center",onClick:r.handleOnClick,onDragOver:n,onDrop:l,onDragEnter:s,onDragLeave:c,paddingBlock:"md",borderRadius:"rounded-md",style:{border:t?"1px solid var(--sa-border-info)":`1px solid ${ws(r.errorMessage,r.status)}`},children:[e.jsx(M.Icon,{name:"Upload",size:"lg",style:{width:30,height:30}}),e.jsxs(ae.Flex,{direction:"column",gap:"xs",children:[e.jsxs(ae.Flex,{direction:"row",gap:"xs",children:[e.jsx(D.Text,{fontWeight:"medium",color:"gray-500",style:{textWrap:"nowrap"},fontSize:r.isDesktop?"md":"sm",children:"Click your upload"}),e.jsx(D.Text,{fontWeight:"medium",style:{textWrap:"nowrap"},fontSize:r.isDesktop?"md":"sm",children:"or Drag & Drop"})]}),e.jsx(D.Text,{fontSize:"sm",color:"gray-500",children:(i=r.fileSupports)==null?void 0:i.map(a=>a.toLocaleUpperCase()).join(", ")})]})]})};function Ss(r){return r.split(" ").map(t=>t[0]).join("").slice(0,2).toUpperCase()}const bl=r=>{const t={day:"2-digit",month:"short",year:"numeric"};return r.toLocaleDateString("id-ID",t)},Bs=r=>{const t={Jan:0,Feb:1,Mar:2,Apr:3,Mei:4,Jun:5,Jul:6,Agu:7,Sep:8,Okt:9,Nov:10,Des:11},o=r.split(" ");if(o.length!==3)return null;const n=parseInt(o[0],10),l=t[o[1]],s=parseInt(o[2],10);return isNaN(n)||isNaN(l)||isNaN(s)?null:new Date(s,l,n)};function ks(r,t=!0){if(!r)return"Rp 0";const o=typeof r=="number"?r.toString():r;if(isNaN(Number(o)))return"Rp 0";const n=o.split("."),l=n[0].replace(/\B(?=(\d{3})+(?!\d))/g,"."),s=n.length===2?l+"."+n[1]:l;return t?"Rp"+s:s}String.prototype.toTitleCase=function(){return this.toLowerCase().split(" ").map(r=>r.charAt(0).toUpperCase()+r.slice(1)).join(" ")},String.prototype.toNumber=function(){return Number(this)};const ms=r=>{const t=r.split(" ");let o=t[0].charAt(0);return t.length>1&&(o+=""+t[1].charAt(0)),o.toUpperCase()};function Es(r){const t=typeof r=="string"?new Date(r):r;if(isNaN(t.getTime()))throw new Error("Invalid date format");const o=t.getFullYear(),n=String(t.getMonth()+1).padStart(2,"0"),l=String(t.getDate()).padStart(2,"0");return`${o}-${n}-${l}`}const Fs="sa-admin",Re=r=>`var(--${Fs}-${r})`,Ms={base:{borderColor:Re("base-border-color"),textColor:Re("base-text-color"),iconColor:Re("base-icon-color"),placeholderColor:Re("base-placeholder-color")},document:{bgColor:Re("document-bg-color")},sidebar:{bgColor:Re("sidebar-bg-color"),borderColor:Re("sidebar-border-color"),maxWidth:Re("sidebar-max-width"),width:Re("sidebar-width"),collapseWidth:Re("sidebar-collapse-width"),collapseV2Width:Re("sidebar-v2-collapse-width")}},Is=24*60*60*1e3,Ts=r=>{const t="14px poppins",n=document.createElement("canvas").getContext("2d");n.font=t;const l=n.measureText(r).width;return Number(Math.ceil(l))},Ls=/^[^\s@]+@[^\s@]+\.[^\s@]+$/,Os=/--+/,As=/-$/;function Ws(r,t){return JSON.stringify(r)!==JSON.stringify(t)}function zs(r){return/^(?:\+62|62|0)8[1-9][0-9]{7,10}$/.test(r)}function Hs(r){return/^[A-Za-z\s]+$/.test(r)}const Ps=r=>{const t=/^[0-9]$/,o=["ArrowLeft","ArrowRight","ArrowUp","ArrowDown","Backspace","Delete","Enter","Tab"];(r.ctrlKey||r.metaKey)&&(r.key==="a"||r.key==="c"||r.key==="v")||!t.test(r.key)&&!o.includes(r.key)&&r.preventDefault()},Vs=r=>{const t=/^[0-9]$/,o=["ArrowLeft","ArrowRight","ArrowUp","ArrowDown","Backspace","Delete","Enter","Tab"];(r.ctrlKey||r.metaKey)&&r.key==="v"||t.test(r.key)&&!o.includes(r.key)&&r.preventDefault()},js=r=>{const t=/^[0-9.]$/,o=["ArrowLeft","ArrowRight","ArrowUp","ArrowDown","Backspace","Delete","Enter","Tab"];(r.ctrlKey||r.metaKey)&&r.key==="v"||!t.test(r.key)&&!o.includes(r.key)&&r.preventDefault()},Ns=r=>Ls.test(r);function _s(r){return!(Os.test(r)||As.test(r))}const qs=r=>{const t=["ArrowLeft","ArrowRight","ArrowUp","ArrowDown","Backspace","Delete","Enter","Tab","Home","End"];if((r.ctrlKey||r.metaKey)&&["a","c","v","x"].includes(r.key.toLowerCase()))return;const o=r.currentTarget.value;/^[0-9]$/.test(r.key)||r.key==="."&&!o.includes(".")||r.key==="-"&&o.length===0&&!o.includes("-")||t.includes(r.key)||r.preventDefault()},Zs=r=>{const t=document.getElementById(r);if(t){const o=t.getBoundingClientRect(),n=window.scrollY+o.top-80;window.scrollTo({top:n,behavior:"smooth"})}};function Gs(r){const t=r.toLowerCase();if(["kb","mb","gb"].find(s=>t.endsWith(s)))return r;const l=Number(r);if(isNaN(l))throw new Error("Invalid size format");return l>=1e6?`${(l/1e6).toFixed(2)}MB`:l>=1e3?`${(l/1e3).toFixed(2)}KB`:`${l}B`}function Qs(r){const t=r.split("/");return t[t.length-1]}const Us=r=>{var t,o;return e.jsxs(f.Box,{width:"width-full",paddingInline:"md",height:"height-full",direction:"row",justify:"space-between",align:"center",onClick:r.handleOnClickFile,fullHeight:!0,paddingBlock:"md",id:"file-item",borderRadius:"rounded-md",style:{border:"1px solid var(--sa-border-subtle)",cursor:"pointer"},children:[e.jsxs(ae.Flex,{direction:"row",align:"center",gap:"sm",style:{flex:1,minWidth:0},children:[e.jsx(M.Icon,{name:"DocumentFilled",size:"lg",style:{color:"var(--sa-icon-brand)",width:30,height:30,flexShrink:0}}),e.jsxs(ae.Flex,{direction:"column",style:{minWidth:0,flex:1},children:[e.jsx(D.Text,{fontWeight:"bold",style:{textOverflow:"ellipsis",whiteSpace:"nowrap",overflow:"hidden"},children:r.defaultFile?Qs(r.defaultFile.url):(t=r.fileSelected)==null?void 0:t.name}),r.defaultFile?(r.defaultFile.size||r.defaultFile.date)&&e.jsxs(ae.Flex,{direction:"row",gap:"xs",align:"center",children:[r.defaultFile.size&&e.jsx(D.Text,{fontSize:"sm",fontWeight:"medium",children:r.defaultFile.size}),r.defaultFile.size&&r.defaultFile.date&&e.jsx(M.Icon,{name:"Dot",size:"xs"}),r.defaultFile.date&&e.jsx(D.Text,{fontSize:"sm",fontWeight:"medium",style:{textWrap:"nowrap"},children:r.defaultFile.date})]}):e.jsxs(ae.Flex,{direction:"row",gap:"xs",align:"center",children:[e.jsx(D.Text,{fontSize:"sm",fontWeight:"medium",children:Gs(((o=r.fileSelected)==null?void 0:o.size.toString())||"100000")}),e.jsx(M.Icon,{name:"Dot",size:"xs"}),e.jsx(D.Text,{fontSize:"sm",fontWeight:"medium",style:{textWrap:"nowrap"},children:bl(new Date)})]})]})]}),e.jsx(j.Button,{size:"xs",variant:"tertiary",tone:"error",type:"button",onClick:n=>{n.stopPropagation(),r.handleOnDeleteFile()},iconLeft:e.jsx(M.Icon,{name:"Trash1"})})]})},vl=({status:r="default",labelPosition:t="outside-top",...o})=>{var p;const n=d.useRef(null),l=()=>{if(o.defaultFile){window.open(o.defaultFile.url);return}n.current&&n.current.click()},s=Se.useMediaQuery("md"),c=r==="error"||typeof o.errorMessage=="string"&&!!o.errorMessage,i=o.label?e.jsxs(ae.Flex,{direction:"row",align:"center",gap:"xs",children:[e.jsx(D.Text,{style:{fontSize:"14px",fontWeight:500,color:"var(--sa-text-primary)"},children:o.label}),o.optional&&e.jsx("span",{style:{background:"var(--sa-background-neutral)",border:"1px solid var(--sa-border-subtle)",borderRadius:"4px",padding:"0 8px",fontSize:"10px",fontWeight:500,lineHeight:"18px",color:"var(--sa-text-primary)",display:"inline-flex",alignItems:"center"},children:"Optional"}),o.required&&e.jsx("span",{style:{fontSize:"14px",fontWeight:500,color:"var(--sa-text-error)"},children:"*"})]}):null,a=o.description?e.jsx(D.Text,{style:{fontSize:"12px",fontWeight:400,color:"var(--sa-text-subtlest, #6b6e76)",lineHeight:"18px"},children:o.description}):null,h=e.jsxs(e.Fragment,{children:[o.helperText&&e.jsx(D.Text,{style:{fontSize:"12px",fontWeight:400,color:"var(--sa-text-subtlest, #6b6e76)",lineHeight:"18px"},children:o.helperText}),o.errorText&&r==="error"&&e.jsx(D.Text,{style:{fontSize:"12px",fontWeight:400,color:"var(--sa-text-error, #a4133c)",lineHeight:"18px"},children:o.errorText}),o.errorMessage&&!o.errorText&&e.jsx(D.Text,{style:{fontSize:"12px",fontWeight:400,color:"var(--sa-text-error, #a4133c)",lineHeight:"18px"},children:o.errorMessage})]}),y=e.jsx("input",{type:"file",style:{display:"none"},ref:n,onChange:C=>{var m;return o.handleOnChangeFile(((m=C.target.files)==null?void 0:m.item(0))||null)},accept:(p=o.fileSupportOption)==null?void 0:p.map(C=>"."+(C==null?void 0:C.toLowerCase())).join(", ")}),b=e.jsxs(f.Box,{direction:"column",fullWidth:!0,style:{minHeight:"69px"},borderRadius:"rounded-md",display:"flex",justify:"center",align:"center",cursor:"pointer",gap:"md",...o.containerProps,children:[y,(o.fileSelected||o.defaultFile)&&e.jsx(Us,{fileSelected:o.fileSelected,defaultFile:o.defaultFile,handleOnDeleteFile:o.handleOnDeleteFile,handleOnClickFile:l}),!o.fileSelected&&!o.defaultFile&&e.jsx(Ds,{fileSupports:o.fileSupportOption,isDesktop:s,errorMessage:c?o.errorText||o.errorMessage||" ":void 0,status:c?"error":"default",handleOnClick:l,handleOnFileChange:o.handleOnChangeFile})]});return t==="outside-left"?e.jsxs(ae.Flex,{direction:"row",align:"flex-start",gap:"sm",style:{width:"100%"},children:[e.jsxs(ae.Flex,{direction:"column",gap:"xs",style:{width:"40%",minWidth:"120px",paddingTop:"10px"},children:[i,a]}),e.jsxs(ae.Flex,{direction:"column",gap:"sm",style:{flex:1,minWidth:0},children:[b,h]})]}):e.jsxs(ae.Flex,{direction:"column",gap:"sm",style:{width:"100%"},children:[i,a,b,h]})},Js=({size:r="md",direction:t="vertical",requiredTitle:o="(Required)",fullWidth:n=!1,...l})=>{var i,a,h;const s=l.hideMessageError||!1,c=t==="horizontal"?r==="sm"?342:r==="lg"?400:342:void 0;return e.jsxs(f.Box,{gap:t==="horizontal"?"spacing-96":"sm",direction:t==="horizontal"?"row":"column",...l.containerProps,children:[l.title&&e.jsx(fe,{condition:!!l.inputProps.required,fallback:e.jsxs(f.Box,{direction:"column",customMaxWidth:c,fullWidth:n,children:[e.jsx(ye,{children:l.title}),e.jsx(D.Text,{fontSize:r,color:"gray-500",children:l.description})]}),children:e.jsxs(f.Box,{direction:"column",customMaxWidth:c,fullWidth:n,children:[e.jsxs(ae.Flex,{direction:"row",gap:"xs",align:"center",children:[e.jsx(ye,{fontSize:r,children:l.title}),e.jsx(ye,{color:"error",fontSize:r,children:o}),e.jsx(fe,{condition:!!((i=l.tooltip)!=null&&i.label),children:e.jsx(Ee.Tooltip,{label:(a=l.tooltip)==null?void 0:a.label,arrowPosition:(h=l.tooltip)==null?void 0:h.arrowPosition,focusable:!0,...l.tooltip,children:e.jsx(M.Icon,{name:"InfoCircle",size:r==="lg"?"sm":"xs",style:{color:"var(--sa-color-info-500, #00abeb)",marginTop:"6px"}})})})]}),e.jsx(fe,{condition:!!l.description,children:e.jsx(D.Text,{fontSize:r,color:"gray-500",children:l.description})})]})}),e.jsxs(ae.Flex,{direction:"column",gap:"xs",children:[e.jsx(vl,{...l.inputProps,status:l.errorMessage?"error":"default"}),!s&&l.errorMessage&&e.jsx(cr,{message:l.errorMessage})]})]})},Ys=({size:r="md",direction:t="vertical",requiredTitle:o="(Required)",fullWidth:n=!1,required:l=!1,...s})=>{var a,h,y,b;const c=s.hideMessageError||!1,i=t==="horizontal"?r==="sm"?342:r==="lg"?400:342:void 0;return e.jsxs(f.Box,{gap:t==="horizontal"||t==="horizontal-inline"?"spacing-96":"sm",direction:t==="horizontal"||t==="horizontal-inline"?"row":"column",...s.containerProps,children:[s.title&&e.jsx(fe,{condition:!!l,fallback:e.jsxs(f.Box,{direction:"column",customMaxWidth:i,fullWidth:n,children:[e.jsx(ye,{children:s.title}),e.jsx(Ke.Body3,{props:{color:"gray-500"},children:s.description})]}),children:e.jsxs(f.Box,{direction:"column",customMaxWidth:i,fullWidth:n,children:[e.jsxs(ae.Flex,{direction:"row",gap:"xs",align:"center",children:[e.jsx(ye,{fontSize:r,children:s.title}),e.jsx(ye,{color:"error",fontSize:r,children:o}),e.jsx(fe,{condition:!!((a=s.tooltip)!=null&&a.label),children:e.jsx(Ee.Tooltip,{label:(h=s.tooltip)==null?void 0:h.label,arrowPosition:(y=s.tooltip)==null?void 0:y.arrowPosition,focusable:!0,...s.tooltip,children:e.jsx(M.Icon,{name:"InfoCircle",size:r==="lg"?"sm":"xs",style:{color:"var(--sa-color-info-500, #00abeb)",marginTop:"6px"}})})})]}),e.jsx(fe,{condition:!!s.description,children:e.jsx(D.Text,{fontSize:r,color:"gray-500",children:s.description})})]})}),e.jsx(f.Box,{gap:t==="horizontal-inline"?"xl":"md",direction:t==="horizontal-inline"?"row":"column",align:"flex-start",children:e.jsx($r,{of:(b=s.checkBoxesList)==null?void 0:b.map(p=>({...p,isChecked:s.checkBoxesAreChecked.includes(p.id)})),render:p=>p.renderBadge?e.jsxs(f.Box,{direction:"row",justify:"space-between",gap:"lg",...s.badgeContainerProps,children:[e.jsx(tr.Checkbox,{name:p.name,value:p.id,checked:p.isChecked,onChange:C=>s.onChecked(C.target.value,p),label:p.name,description:p.description}),p.renderBadge]}):e.jsx(tr.Checkbox,{name:p.name,value:p.id,checked:p.isChecked,onChange:C=>s.onChecked(C.target.value,p),label:p.name,description:p.description})})}),!c&&s.errorMessage&&e.jsx(cr,{message:s.errorMessage})]})},Xs=({position:r="vertical",size:t="md",fullWidth:o=!1,...n})=>{var s;const l=r==="horizontal-inline"||r==="horizontal-block"?t==="sm"?342:t==="lg"?400:342:void 0;return e.jsxs(f.Box,{gap:r==="horizontal-inline"||r==="horizontal-block"?"spacing-96":"sm",direction:r==="horizontal-inline"||r==="horizontal-block"?"row":"column",children:[e.jsx(fe,{condition:!!n.description||!!n.title,children:e.jsxs(f.Box,{direction:"column",customMaxWidth:l,fullWidth:o,children:[n.title&&e.jsx(ye,{children:n.title}),e.jsx(fe,{condition:!!n.description,children:e.jsx(D.Text,{color:"gray-500",children:n.description})})]})}),e.jsx(f.Box,{gap:"sm",direction:r==="horizontal"||r==="horizontal-inline"?"row":"column",align:"flex-start",flexWrap:"wrap",children:e.jsx($r,{of:(s=n.radioList)==null?void 0:s.map(c=>({...c,isChecked:n.radioIsChecked===c.id})),render:({value:c,id:i,isChecked:a,subInput:h,label:y,description:b})=>e.jsxs(f.Box,{direction:"column",gap:"xs",customMaxWidth:l,children:[e.jsx(dt.Radio,{id:`${i.toString()}-${c}`,name:n.groupName||y,label:y,value:c,checked:a,onChange:p=>n.onChecked({id:i,label:p.target.name,value:p.target.value}),disabled:n.disableAll},i),b&&e.jsx(D.Text,{color:"gray-500",style:{marginLeft:28},children:b}),h]})})}),n.errorMessage&&e.jsx(cr,{message:n.errorMessage})]})},$s=({size:r="md",direction:t="vertical",requiredTitle:o="(Required)",fullWidth:n=!1,...l})=>{var i,a,h;const s=l.hideMessageError||!1,c=t==="horizontal"?r==="sm"?342:r==="lg"?400:342:void 0;return e.jsxs(f.Box,{gap:t==="horizontal"?"spacing-96":"sm",direction:t==="horizontal"?"row":"column",...l.containerProps,children:[l.title&&e.jsx(fe,{condition:!!l.inputProps.required,fallback:e.jsxs(f.Box,{direction:"column",customMaxWidth:c,fullWidth:n,children:[e.jsx(ye,{children:l.title}),e.jsx(D.Text,{fontSize:r,color:"gray-500",children:l.description})]}),children:e.jsxs(f.Box,{direction:"column",customMaxWidth:c,fullWidth:n,children:[e.jsxs(ae.Flex,{direction:"row",gap:"xs",align:"center",children:[e.jsx(ye,{fontSize:r,children:l.title}),e.jsx(ye,{color:"error",fontSize:r,children:o}),e.jsx(fe,{condition:!!((i=l.tooltip)!=null&&i.label),children:e.jsx(Ee.Tooltip,{label:(a=l.tooltip)==null?void 0:a.label,arrowPosition:(h=l.tooltip)==null?void 0:h.arrowPosition,focusable:!0,...l.tooltip,children:e.jsx(M.Icon,{name:"InfoCircle",size:r==="lg"?"sm":"xs",style:{color:"var(--sa-color-info-500, #00abeb)",marginTop:"6px"}})})})]}),e.jsx(fe,{condition:!!l.description,children:e.jsx(D.Text,{fontSize:r,color:"gray-500",children:l.description})})]})}),e.jsxs(ae.Flex,{direction:"column",gap:"xs",children:[e.jsx(at.Textarea,{ref:l.inputRef,size:r,...l.inputProps,status:l.errorMessage?"error":"default"}),!s&&l.errorMessage&&e.jsx(cr,{message:l.errorMessage})]})]})},Ks=({size:r="md",direction:t="vertical",requiredTitle:o="(Required)",required:n=!1,fullWidth:l=!1,...s})=>{var i,a,h;const c=t==="horizontal"?r==="sm"?342:r==="lg"?400:342:void 0;return e.jsxs(f.Box,{gap:t==="horizontal"?"spacing-96":"sm",direction:t==="horizontal"?"row":"column",...s.containerProps,children:[s.title&&e.jsx(fe,{condition:n,fallback:e.jsxs(f.Box,{direction:"column",customMaxWidth:c,fullWidth:l,children:[e.jsx(ye,{children:s.title}),e.jsx(D.Text,{fontSize:r,color:"gray-500",children:s.titleDescription})]}),children:e.jsxs(f.Box,{direction:"column",customMaxWidth:c,fullWidth:l,children:[e.jsxs(ae.Flex,{direction:"row",gap:"xs",align:"center",children:[e.jsx(ye,{fontSize:r,children:s.title}),e.jsx(ye,{color:"error",fontSize:r,children:o}),e.jsx(fe,{condition:!!((i=s.tooltip)!=null&&i.label),children:e.jsx(Ee.Tooltip,{label:(a=s.tooltip)==null?void 0:a.label,arrowPosition:(h=s.tooltip)==null?void 0:h.arrowPosition,focusable:!0,...s.tooltip,children:e.jsx(M.Icon,{name:"InfoCircle",size:r==="lg"?"sm":"xs",style:{color:"var(--sa-color-info-500, #00abeb)",marginTop:"6px"}})})})]}),e.jsx(fe,{condition:!!s.titleDescription,children:e.jsx(D.Text,{fontSize:r,color:"gray-500",children:s.titleDescription})})]})}),e.jsx(xr.Toggle,{checked:s.checked,onChange:s.onChange,label:s.label,description:s.description}),s.errorMessage&&e.jsx(cr,{message:s.errorMessage})]})},Rs=({variant:r="primary",size:t="md",...o})=>{const n=Cr.useColor(),l=c=>{var a,h,y,b,p,C;if(!c)return;const i=o.disabled?"var(--sa-text-disable, #181a198f)":r==="secondary"?"var(--sa-text-subtle, #8c8f97)":r==="secondary-danger"?(h=(a=n==null?void 0:n.computed)==null?void 0:a.red)==null?void 0:h[600]:r==="secondary-primary"?(b=(y=n==null?void 0:n.computed)==null?void 0:y.blue)==null?void 0:b[700]:(C=(p=n==null?void 0:n.computed)==null?void 0:p.gray)==null?void 0:C[50];return e.jsx(M.Icon,{name:c,size:t,style:{color:i}})},s=()=>{var i,a,h,y;if(r!=="secondary-danger"&&r!=="secondary-primary")return o.title;const c={color:o.disabled?"var(--sa-text-disable, #181a198f)":r==="secondary-danger"?(a=(i=n==null?void 0:n.computed)==null?void 0:i.red)==null?void 0:a[600]:(y=(h=n==null?void 0:n.computed)==null?void 0:h.blue)==null?void 0:y[700]};switch(t){case"xs":return e.jsx(Ke.Body2,{props:{style:c},children:o.title});case"sm":case"md":return e.jsx(Ke.SubH3,{props:{style:c},children:o.title});case"lg":return e.jsx(Ke.SubH2,{props:{style:c},children:o.title});default:return o.title}};return e.jsx(j.Button,{fullWidth:!0,disabled:o.disabled,primary:r==="primary",secondary:r==="secondary"||r==="secondary-danger"||r==="secondary-primary",success:r==="success",onClick:o.onClick,type:o.type,iconLeft:l(o.iconLeft),iconRight:l(o.iconRight),size:t,children:s()})},ec=r=>e.jsx(Ke.H5,{props:{...r},children:r.title}),rc=({size:r="md",direction:t="vertical",requiredTitle:o="(Required)",fullWidth:n=!1,...l})=>{var i,a,h;const s=l.hideMessageError||!1,c=t==="horizontal"?r==="sm"?342:r==="lg"?400:342:void 0;return e.jsxs(f.Box,{gap:t==="horizontal"?"spacing-96":"sm",direction:t==="horizontal"?"row":"column",onClick:l.onClickContainer,children:[l.title&&e.jsx(fe,{condition:!!l.inputProps.required,fallback:e.jsxs(f.Box,{direction:"column",customMaxWidth:c,fullWidth:n,children:[e.jsx(ye,{children:l.title}),e.jsx(D.Text,{fontSize:r,color:"gray-500",children:l.description})]}),children:e.jsxs(f.Box,{direction:"column",customMaxWidth:c,fullWidth:n,children:[e.jsxs(ae.Flex,{direction:"row",gap:"xs",align:"center",children:[e.jsx(ye,{fontSize:r,children:l.title}),e.jsx(ye,{color:"error",fontSize:r,children:o}),e.jsx(fe,{condition:!!((i=l.tooltip)!=null&&i.label),children:e.jsx(Ee.Tooltip,{label:(a=l.tooltip)==null?void 0:a.label,arrowPosition:(h=l.tooltip)==null?void 0:h.arrowPosition,focusable:!0,...l.tooltip,children:e.jsx(M.Icon,{name:"InfoCircle",size:r==="lg"?"sm":"xs",style:{color:"var(--sa-color-info-500, #00abeb)",marginTop:"6px"}})})})]}),e.jsx(fe,{condition:!!l.description,children:e.jsx(D.Text,{fontSize:r,color:"gray-500",children:l.description})})]})}),e.jsxs(ae.Flex,{direction:"column",gap:"xs",children:[e.jsx(f.Box,{direction:"column",style:{width:t==="horizontal"&&l.customWidth?l.customWidth:t==="horizontal"?"343px":""},children:e.jsx(fr.StarasiaDate,{size:r,...l.inputProps,status:l.errorMessage?"error":void 0})}),!s&&l.errorMessage&&e.jsx(cr,{message:l.errorMessage})]})]})};async function tc(r,t){const o=new Image;o.src=r,await new Promise((s,c)=>{o.onload=s,o.onerror=c});const n=document.createElement("canvas");n.width=t.width,n.height=t.height;const l=n.getContext("2d",{alpha:!0});if(!l)throw new Error("No 2D context");return l.drawImage(o,t.x,t.y,t.width,t.height,0,0,t.width,t.height),new Promise((s,c)=>{n.toBlob(i=>{if(!i)return c("Canvas is empty");const a=new File([i],"cropped.png",{type:"image/png"});s(a)},"image/png")})}const Cl={"1:1":1,"4:3":4/3,"16:9":16/9,"3:4":3/4,"9:16":9/16,"2:3":2/3,"3:2":3/2,"32:9":32/9},xl=d.forwardRef(({handleUpload:r,urlImage:t,isUploading:o,croppedImage:n,setCroppedImage:l,size:s="96",aspect:c="1:1",containerProps:i,maxFileSize:a=2,onError:h},y)=>{const b=Se.useMediaQuery("md"),[p,C]=d.useState(!1),[m,w]=d.useState(null),[L,F]=d.useState(!1),[T,S]=d.useState({x:0,y:0}),[k,H]=d.useState(1),[z,B]=d.useState(null);d.useEffect(()=>{t===null&&l(null)},[t]);const W=d.useCallback((V,N)=>{B(N)},[]),O=V=>{var ve;const N=(ve=V.target.files)==null?void 0:ve[0];if(!N)return;const se=new FileReader;se.onload=()=>{w(se.result),F(!0)},se.readAsDataURL(N)},Y=async()=>{if(!(!m||!z))try{const V=await tc(m,z);if(a&&V.size>a*1024*1024){h==null||h(`Ukuran file maksimal ${a}MB`);return}r==null||r(V);const N=URL.createObjectURL(V);l(N,V),F(!1)}catch{h==null||h("Gagal memproses gambar")}},X=d.useRef(null),q=()=>{X.current&&X.current.click()};d.useImperativeHandle(y,()=>({openFileDialog:()=>{var V;(V=X.current)==null||V.click()}}));const Z=parseInt(s,10),K=Cl[c];let te,_;return K>=1?(_=Z,te=Z*K):(te=Z,_=Z/K),e.jsxs(f.Box,{direction:"column",display:"flex",position:"relative",bg:(i==null?void 0:i.bg)||"gray-200",borderStyle:(i==null?void 0:i.borderStyle)||"border-none",borderColor:(i==null?void 0:i.borderColor)||"gray-200",borderWidth:(i==null?void 0:i.borderWidth)||"border-2",borderRadius:(i==null?void 0:i.borderRadius)||"rounded-md",overflow:"overflow-hidden",align:"center",justify:"center",style:{width:i!=null&&i.fullWidth?"100%":`${te}px`,height:i!=null&&i.fullWidth?"auto":`${_}px`,aspectRatio:K,flexShrink:0},onMouseEnter:()=>C(!0),onMouseLeave:()=>C(!1),children:[n||t?e.jsx("img",{src:n||t||void 0,alt:"Profile",style:{objectFit:"cover",width:"100%",height:"100%"}}):e.jsx(f.Box,{display:"flex",direction:"column",align:"center",justify:"center",padding:"spacing-4",children:e.jsx(M.Icon,{name:"Image",style:{color:"var(--sa-text-subtle, #8c8f97)",width:Number(s)/2<40?Number(s)/2:40,height:Number(s)/2<40?Number(s)/2:40}})}),e.jsxs(f.Box,{direction:"column",position:"absolute",display:"flex",align:"center",justify:"center",cursor:"pointer",style:{inset:0,backgroundColor:"var(--sa-color-black-alpha-a30, #080f214c)",opacity:p?1:0,transition:"opacity 0.3s ease-in-out"},onClick:q,children:[e.jsx("input",{ref:X,type:"file",accept:"image/*",onChange:O,disabled:o,style:{display:"none"}}),e.jsxs(f.Box,{display:"flex",align:"center",gap:"spacing-2",direction:"row",children:[e.jsx(M.Icon,{name:"Edit3",style:{color:"var(--sa-background-primary, #ffffff)"}}),e.jsx(fe,{condition:s.toNumber()>80,children:e.jsx(D.Text,{color:"gray-50",fontSize:s.toNumber()>80?"sm":"md",fontWeight:"medium",children:"Edit Image"})})]})]}),o&&e.jsx(f.Box,{direction:"column",position:"absolute",display:"flex",align:"center",justify:"center",style:{inset:0,zIndex:20,backgroundColor:"var(--sa-color-white-alpha-a80, #e5e9f6cc)"},children:e.jsx(f.Box,{direction:"column",borderRadius:"rounded-full",style:{animation:"spin 1s linear infinite",border:"2px solid transparent",height:"2rem",width:"2rem"},borderColor:"info-600"})}),L&&Vr.createPortal(e.jsx("div",{style:{position:"fixed",inset:0,zIndex:19999,display:"flex",alignItems:"center",justifyContent:"center",backgroundColor:"rgba(0,0,0,0.6)"},onClick:()=>F(!1),children:e.jsxs("div",{style:{backgroundColor:"var(--sa-background-primary)",borderRadius:"var(--sa-radii-md)",boxShadow:"0 20px 60px rgba(0,0,0,0.3)",overflow:"hidden",width:b?c==="1:1"?"min(90vw, 480px)":`min(90vw, ${te*2}px)`:"calc(100vw - 2rem)",display:"flex",flexDirection:"column"},onClick:V=>V.stopPropagation(),children:[e.jsx("div",{style:{position:"relative",width:"100%",height:"20rem",backgroundColor:"var(--sa-color-gray-100)"},children:m&&e.jsx(_l,{image:m,crop:T,zoom:k,aspect:c?Cl[c]:void 0,onCropChange:S,onZoomChange:H,onCropComplete:W,objectFit:"contain",minZoom:.5,restrictPosition:!1})}),e.jsxs("div",{style:{display:"flex",justifyContent:"flex-end",gap:"0.5rem",padding:"0.75rem 1rem",borderTop:"1px solid var(--sa-border-subtle)"},children:[e.jsx(j.Button,{size:"sm",secondary:!0,onClick:()=>F(!1),children:"Cancel"}),e.jsx(j.Button,{size:"sm",primary:!0,onClick:Y,children:"Crop"})]})]})}),document.body)]})}),oc=({size:r="md",direction:t="vertical",requiredTitle:o="(Required)",fullWidth:n=!1,required:l=!1,...s})=>{var a,h,y;const c=s.hideMessageError||!1,i=t==="horizontal"?r==="sm"?342:r==="lg"?400:342:void 0;return e.jsxs(f.Box,{gap:t==="horizontal"?"spacing-96":"sm",direction:t==="horizontal"?"row":"column",...s.containerProps,children:[s.title&&e.jsx(fe,{condition:!!l,fallback:e.jsxs(f.Box,{direction:"column",customMaxWidth:i,fullWidth:n,children:[e.jsx(ye,{children:s.title}),e.jsx(D.Text,{fontSize:r,color:"gray-500",children:s.description})]}),children:e.jsxs(f.Box,{direction:"column",customMaxWidth:i,fullWidth:n,children:[e.jsxs(ae.Flex,{direction:"row",gap:"xs",align:"center",children:[e.jsx(ye,{fontSize:r,children:s.title}),e.jsx(ye,{color:"error",fontSize:r,children:o}),e.jsx(fe,{condition:!!((a=s.tooltip)!=null&&a.label),children:e.jsx(Ee.Tooltip,{label:(h=s.tooltip)==null?void 0:h.label,arrowPosition:(y=s.tooltip)==null?void 0:y.arrowPosition,focusable:!0,...s.tooltip,children:e.jsx(M.Icon,{name:"InfoCircle",size:r==="lg"?"sm":"xs",style:{color:"var(--sa-color-info-500, #00abeb)",marginTop:"6px"}})})})]}),e.jsx(fe,{condition:!!s.description,children:e.jsx(D.Text,{fontSize:r,color:"gray-500",children:s.description})})]})}),e.jsxs(ae.Flex,{direction:"column",gap:"xs",children:[e.jsx(xl,{...s.inputProps}),!c&&s.errorMessage&&e.jsx(cr,{message:s.errorMessage})]})]})},lc=({size:r="md",direction:t="vertical",requiredTitle:o="(Required)",fullWidth:n=!1,...l})=>{var c,i,a;const s=t==="horizontal"?r==="sm"?342:r==="lg"?400:342:void 0;return e.jsxs(f.Box,{gap:t==="horizontal"?"spacing-96":"sm",direction:t==="horizontal"?"row":"column",...l.containerProps,children:[l.title&&e.jsx(fe,{condition:!!l.inputProps.required,fallback:e.jsxs(f.Box,{direction:"column",customMaxWidth:s,fullWidth:n,children:[e.jsx(ye,{children:l.title}),e.jsx(D.Text,{fontSize:r,color:"gray-500",children:l.description})]}),children:e.jsxs(f.Box,{direction:"column",customMaxWidth:s,fullWidth:n,children:[e.jsxs(ae.Flex,{direction:"row",gap:"xs",align:"center",children:[e.jsx(ye,{fontSize:r,children:l.title}),e.jsx(ye,{color:"error",fontSize:r,children:o}),e.jsx(fe,{condition:!!((c=l.tooltip)!=null&&c.label),children:e.jsx(Ee.Tooltip,{label:(i=l.tooltip)==null?void 0:i.label,arrowPosition:(a=l.tooltip)==null?void 0:a.arrowPosition,focusable:!0,...l.tooltip,children:e.jsx(M.Icon,{name:"InfoCircle",size:r==="lg"?"sm":"xs",style:{color:"var(--sa-color-info-500, #00abeb)",marginTop:"6px"}})})})]}),e.jsx(fe,{condition:!!l.description,children:e.jsx(D.Text,{fontSize:r,color:"gray-500",children:l.description})})]})}),l.inputProps.extended&&l.inputProps.extended]})},nc=({items:r,id:t,handleOnUpdate:o,width:n,toggleShow:l=!0,disabled:s=!1})=>{var y;const[c,i]=d.useState([]);d.useEffect(()=>{r&&i([...r.map(b=>({id:b.id,isActive:b.isActive}))])},[r]);const a=(y=c.find(b=>b.id===t))==null?void 0:y.isActive,h=d.useCallback(()=>{i(b=>b.map(p=>p.id===t?{...p,isActive:!p.isActive}:p)),o&&o(!a)},[t,o,a]);return e.jsx(f.Box,{direction:"row",gap:"md",style:{width:n},children:l&&e.jsx(xr.Toggle,{disabled:s,checked:a,onChange:h,label:a?"Active":"Inactive"})})},sc={InputText:Cs,InputDropdown:xs,InputSingleFile:Js,CheckBoxOptions:Ys,RadioOptions:Xs,InputTextArea:$s,ToggleForm:Ks,ActionButton:Rs,FormTitle:ec,InputDate:rc,InputImgFile:oc,Custom:lc},wl=({customBottom:r})=>{const[t,o]=d.useState(!1),n=()=>{window.scrollY>window.screenY?o(!0):o(!1)},l=()=>{window.scrollTo({top:0,behavior:"smooth"})};return d.useEffect(()=>(window.addEventListener("scroll",n),()=>{window.removeEventListener("scroll",n)}),[]),e.jsx(f.Box,{direction:"column",style:{position:"fixed",bottom:0,right:0},children:e.jsx(f.Box,{direction:"column",position:"absolute",style:{bottom:r||"1.6rem",right:"2rem",transform:t?"scale(1)":"scale(0)",transition:"transform 0.2s ease-in-out"},children:e.jsx(j.Button,{secondary:!0,size:"xs",onClick:l,type:"button",iconLeft:e.jsx(M.Icon,{width:16,size:"xs",name:"ArrowPullUp",style:{color:"var(--sa-background-brand, #04254f)"}})})})})},qe="sa-sidepanel-item",Dl="sa-sidepanel-item-styles",cc=`
|
|
57
|
+
`,document.head.appendChild(r)},Lr=r=>r==="right"?"right":r==="center"?"center":"left",gs=/^(#|rgb|hsl|var\()/,Xr=r=>r?gs.test(r)?r:`var(--sa-background-${r})`:void 0,ys=(r,t)=>{if(t)return r[t]},ps=(r,t)=>r==null&&t==null?0:r==null?-1:t==null?1:typeof r=="number"&&typeof t=="number"?r-t:String(r).localeCompare(String(t)),bs=({columns:r,data:t,getRowKey:o,rowBg:n,size:l="md",resizable:s=!1,layout:c="auto",widthStorageKey:i,columnState:a,onColumnStateChange:h,columnMenu:y=!1,sort:b,defaultSort:p,onSortChange:C,height:m,mobileLayout:w="cards",mobileBreakpoint:L="md",groupSeparator:F,summary:T,footer:S,stickyFooter:k=!1,emptyState:H,loading:z=!1,loadingRows:B=8,rowActions:W,selectable:O=!1,selectedKeys:Y,defaultSelectedKeys:X,onSelectionChange:q,isRowSelectable:Z})=>{us();const te=!Se.useMediaQuery(L)&&w!=="scroll",_=!!(W!=null&&W.length),[V,N]=d.useState(null);d.useEffect(()=>{if(!V)return;const v=()=>N(null),x=setTimeout(()=>document.addEventListener("click",v),0);return()=>{clearTimeout(x),document.removeEventListener("click",v)}},[V]);const[se,ve]=d.useState(()=>new Set),me=a!==void 0,[ue,Ce]=d.useState({}),xe=a??ue,we=v=>{h==null||h(v),me||Ce(v)},Ae=b!==void 0,[Fe,_e]=d.useState(p??null),$=Ae?b??null:Fe,ge=!C,We=v=>{C==null||C(v),Ae||_e(v)},{headerGroups:Ze,leafColumns:de,hasGroups:Ge}=d.useMemo(()=>{var ce;const v=new Set(xe.hidden??[]),x=(oe,pe)=>oe.key??(typeof oe.accessor=="string"?oe.accessor:`col-${pe}`),I=r.map((oe,pe)=>{var Xe;if((Xe=oe.children)!=null&&Xe.length){const Wr=oe.children.map((rr,zr)=>({col:rr,key:x(rr,`${pe}-${zr}`)})).filter(rr=>!v.has(rr.key));return{col:oe,key:oe.key??`group-${pe}`,isGroup:!0,leaves:Wr}}const be={col:oe,key:x(oe,`${pe}`)};return{col:oe,key:be.key,isGroup:!1,leaves:v.has(be.key)?[]:[be]}}).filter(oe=>oe.leaves.length>0),Q=I.some(oe=>oe.isGroup);let le=I.flatMap(oe=>oe.leaves);if(!Q&&((ce=xe.order)!=null&&ce.length)){const oe=new Map(xe.order.map((pe,be)=>[pe,be]));le=[...le].sort((pe,be)=>(oe.get(pe.key)??1/0)-(oe.get(be.key)??1/0))}return{headerGroups:I,leafColumns:le,hasGroups:Q}},[r,xe]),lr=d.useMemo(()=>new Map(de.map((v,x)=>[v.key,x])),[de]),P=!Ge&&de.some(v=>(v.col.headerColSpan??1)>1),R=de.map(v=>v.key).join("|"),J=(v,x)=>{const I=v.sortKey??(typeof v.accessor=="string"?v.accessor:void 0);return I?x[I]:void 0},he=v=>v.sortable??(!!v.sortKey||typeof v.accessor=="string"),ie=d.useMemo(()=>{if(!ge||!$)return t;const v=de.find(I=>I.key===$.key);if(!v)return t;const x=$.direction==="asc"?1:-1;return[...t].sort((I,Q)=>ps(J(v.col,I),J(v.col,Q))*x)},[t,ge,$,de]),Me=!Ge&&!P,ze=!!i&&Me,[er,Qe]=U.useColumnWidths(i??""),Le=ze?er:void 0,Je=d.useRef(null),[Be,Ue]=d.useState();d.useLayoutEffect(()=>{Ue(void 0)},[R]),d.useLayoutEffect(()=>{if(!Me||Be||!Je.current)return;const v=Je.current.querySelectorAll("th.sa-tl-leaf");Ue(Array.from(v).map(x=>x.offsetWidth))},[Be,Me]);const[nr,gr]=d.useState(),[dr,hr]=d.useState(0);d.useLayoutEffect(()=>{if(!Ge||!Je.current)return;const v=Je.current.querySelector(":scope > tr");v&&hr(v.offsetHeight)},[Ge,R]);const Sr=(v,x)=>{if((Le==null?void 0:Le[x])!=null)return Le[x];if(v.width!=null)return v.width;if((Be==null?void 0:Be[x])!=null)return Be[x]},E=(v,x)=>typeof v.width=="number"?v.width:Be==null?void 0:Be[x],G=xe.frozenKey&&!Ge&&!P?de.findIndex(v=>v.key===xe.frozenKey):-1,re=v=>v<=G,De=O?Tr:0,Oe=v=>{const x=nr??Be;if(!x)return De;let I=De;for(let Q=0;Q<v;Q++)I+=x[Q]??0;return I};d.useLayoutEffect(()=>{const v=Je.current;if(!v||G<0){gr(void 0);return}let x=0;const I=()=>{x=0;const le=v.querySelectorAll("th.sa-tl-leaf"),ce=Array.from(le).map(oe=>oe.getBoundingClientRect().width);gr(oe=>oe&&oe.length===ce.length&&oe.every((pe,be)=>Math.abs(pe-ce[be])<.5)?oe:ce)},Q=new ResizeObserver(()=>{x||(x=requestAnimationFrame(I))});return Q.observe(v),v.querySelectorAll("th.sa-tl-leaf").forEach(le=>Q.observe(le)),I(),()=>{x&&cancelAnimationFrame(x),Q.disconnect()}},[R,G,O,Be,Le]);const Ye=d.useRef(null),[He,ke]=d.useState("100vh");d.useLayoutEffect(()=>{if(m!==void 0)return;const v=()=>{if(Ye.current){const x=Ye.current.getBoundingClientRect().top;ke(`calc(100vh - ${x}px - var(--sa-floating-footer-height, 0px) + 12px)`)}};return v(),window.addEventListener("resize",v),()=>window.removeEventListener("resize",v)},[m]);const Ie=(v,x)=>o?o(v,x):x,Ve=Y!==void 0,[Ar,_c]=d.useState(()=>new Set(X??[])),ir=d.useMemo(()=>Ve?new Set(Y):Ar,[Ve,Y,Ar]);d.useEffect(()=>{O&&!o&&process.env.NODE_ENV!=="production"&&console.warn("[@starasia/admin] TableLayout: `selectable` tanpa `getRowKey` — key default (index) membuat seleksi menempel ke POSISI baris, bukan datanya. Beri `getRowKey` yang stabil (mis. r => r.id).")},[O,!o]);const Tl=v=>{if(Ve||_c(v),q){const x=ie.filter((I,Q)=>v.has(Ie(I,Q)));q(Array.from(v),x)}},Nt=(v,x)=>O&&(Z?Z(v,x):!0),_t=v=>{const x=new Set(ir);x.has(v)?x.delete(v):x.add(v),Tl(x)},Br=d.useMemo(()=>O?ie.map((v,x)=>({row:v,i:x,key:Ie(v,x)})).filter(({row:v,i:x})=>Z?Z(v,x):!0).map(({key:v})=>v):[],[O,ie,Z,o]),Ll=Br.filter(v=>ir.has(v)),qt=Br.length>0&&Ll.length===Br.length,Ol=Ll.length>0&&!qt,qc=()=>{const v=new Set(ir);qt?Br.forEach(x=>v.delete(x)):Br.forEach(x=>v.add(x)),Tl(v)},Zt=(v,x,I)=>v.render?v.render(x,I,ie):ys(x,v.accessor),Gt=de.length+(O?1:0)+(_?1:0),Al=["80%","55%","70%","45%","90%","60%"],Zc=(v,x)=>Al[(v*7+x*3)%Al.length],Gc=(v,x)=>e.jsx($e.Skeleton,{height:14,width:Zc(v,x),borderRadius:"rounded-sm"}),Qc=Array.from({length:B},(v,x)=>e.jsxs(U.Tr,{children:[O&&e.jsx(U.Td,{style:{width:Tr,padding:0},children:e.jsx("div",{style:{display:"flex",justifyContent:"center"},children:e.jsx($e.Skeleton,{height:14,width:14,borderRadius:"rounded-sm"})})}),de.map(({col:I,key:Q},le)=>e.jsx(U.Td,{style:{textAlign:Lr(I.align)},children:Gc(x,le)},`sa-tl-sk-${x}-${Q}`)),_&&e.jsx(U.Td,{style:{width:1,padding:0,border:"none"}})]},`sa-tl-sk-${x}`)),Uc=(v,x)=>{x||we({...xe,hidden:[...xe.hidden??[],v]})},Jc=v=>we({...xe,frozenKey:xe.frozenKey===v?void 0:v}),nt=v=>(W??[]).filter(x=>{var I;return!((I=x.hidden)!=null&&I.call(x,v))}),Wl={position:"absolute",right:0,top:0,bottom:0,display:"flex",alignItems:"center",gap:4,paddingRight:16,paddingLeft:40,background:"linear-gradient(to right, transparent, var(--sa-background-primary-inverse, #f8f8f8) 40px)"},st=(v,x,I,Q)=>{var Xe;const le=(Xe=v.disabled)==null?void 0:Xe.call(v,x),ce=(Q==null?void 0:Q.showLabel)??v.showLabel,oe=(Q==null?void 0:Q.size)??"xs",pe=e.jsx(j.Button,{size:oe,variant:v.variant??"tertiary",tone:v.tone??"neutral",disabled:le,onClick:()=>v.onClick(x,I),iconLeft:v.icon?e.jsx(M.Icon,{name:v.icon,size:"sm"}):void 0,children:ce&&v.label}),be=v.tooltip;return be?e.jsx(Ee.Tooltip,{label:be,position:"top-end",children:pe}):pe},Yc=(v,x)=>{const I=nt(v);if(!I.length)return null;if(I.length>5){const le=Ie(v,x),ce=(V==null?void 0:V.rowKey)===le;return e.jsx("div",{className:"sa-tl-row-actions",style:Wl,onClick:oe=>oe.stopPropagation(),children:e.jsx(Ee.Tooltip,{label:"Aksi lainnya",position:"top",children:e.jsx(j.Button,{size:"xs",variant:"tertiary",onClick:oe=>{const pe=oe.currentTarget.getBoundingClientRect();N(ce?null:{rowKey:le,top:pe.bottom+4,right:window.innerWidth-pe.right})},children:e.jsx(M.Icon,{name:"MenuVertical",size:"sm"})})})})}return e.jsx("div",{className:"sa-tl-row-actions",style:Wl,children:I.map(le=>e.jsx(d.Fragment,{children:st(le,v,x)},le.key))})},Xc=(v,x)=>{const I=nt(v);return I.length?e.jsx("div",{style:{display:"flex",gap:6,flexWrap:"wrap",paddingTop:8,marginTop:8,borderTop:Ir},children:I.map(Q=>e.jsx(d.Fragment,{children:st(Q,v,x,{showLabel:!0,size:"sm"})},Q.key))}):null},$c=(v,x)=>{const I=nt(v);return I.length?e.jsx("div",{style:{display:"flex",gap:4,paddingRight:8,flexShrink:0},children:I.map(Q=>e.jsx(d.Fragment,{children:st(Q,v,x,{showLabel:!1})},Q.key))}):null},Qt=(v,x)=>{const{col:I,key:Q}=v,le=lr.get(Q)??0,ce=re(le),oe=ce&&le===G,pe=($==null?void 0:$.key)===Q?$.direction:null,be=y&&!I.disableMenu?e.jsx(gl,{active:!!pe||ce,canSort:he(I),canHide:!I.locked,sortDir:pe,frozen:ce,onSort:zr=>We({key:Q,direction:zr}),onClearSort:()=>We(null),onToggleFreeze:()=>Jc(Q),onHide:()=>Uc(Q,I.locked)}):null,Xe=I.align==="right",Wr=I.align==="right"?"flex-end":I.align==="center"?"center":"flex-start",rr=e.jsxs("span",{style:{flex:1,minWidth:0,display:"flex",alignItems:"center",gap:6,justifyContent:Wr,overflow:"hidden"},children:[I.icon&&e.jsx(M.Icon,{name:I.icon,size:"sm",style:{flexShrink:0}}),e.jsx("span",{style:Yr,children:I.title})]});return e.jsx(U.Th,{className:`sa-tl-leaf${ce?" sa-tl-frozen":""}`,rowSpan:x==null?void 0:x.rowSpan,colSpan:x==null?void 0:x.colSpan,minWidth:I.minWidth,numeric:I.numeric,resizable:Me?I.resizable:!1,defaultWidth:E(I,le),style:{textAlign:Lr(I.align),width:Sr(I,le),position:"sticky",top:(x==null?void 0:x.top)??0,left:ce?Oe(le):void 0,zIndex:ce?3:2,backgroundColor:Dr,boxShadow:oe?yl:void 0},children:e.jsx("div",{style:{display:"flex",alignItems:"center",gap:6,width:"100%"},children:Xe?e.jsxs(e.Fragment,{children:[be,rr]}):e.jsxs(e.Fragment,{children:[rr,be]})})},`th-${Q}`)},Kc=()=>{const v=[];for(let x=0;x<de.length;){const I=de[x],Q=I.col.headerColSpan??1,le=Math.max(1,Math.min(Q,de.length-x));v.push(Qt(I,le>1?{colSpan:le}:void 0)),x+=le}return v},zl=v=>e.jsx(U.Th,{rowSpan:v==null?void 0:v.rowSpan,style:{width:Tr,position:"sticky",top:0,left:0,zIndex:4,backgroundColor:Dr,padding:0},children:e.jsx("div",{style:{display:"flex",alignItems:"center",justifyContent:"center"},onClick:x=>x.stopPropagation(),children:e.jsx(tr.Checkbox,{size:"sm",variant:Ol?"indeterminate":"select",checked:qt||Ol,disabled:Br.length===0,onChange:qc,"aria-label":"Pilih semua baris di halaman ini"})})},"th-select"),Rc=(v,x,I)=>{const Q=Ie(v,x);return e.jsx(U.Td,{className:"sa-tl-frozen",style:{width:Tr,padding:0,position:"sticky",left:0,zIndex:2,...I?{"--sa-tl-bg":I}:{}},children:Nt(v,x)&&e.jsx("div",{style:{display:"flex",alignItems:"center",justifyContent:"center"},onClick:le=>le.stopPropagation(),children:e.jsx(tr.Checkbox,{size:"sm",checked:ir.has(Q),onChange:()=>_t(Q),"aria-label":"Pilih baris"})})},`tl-select-${x}`)},Ut=de.filter(v=>!v.col.hideOnMobile),Jt=Ut.find(v=>v.col.primary)??Ut[0],ei=Ut.filter(v=>v!==Jt),ri=v=>ve(x=>{const I=new Set(x);return I.has(v)?I.delete(v):I.add(v),I}),Hl=(v,x)=>ei.map(({col:I,key:Q})=>{const le=Zt(I,v,x),ce={minWidth:0,overflow:"hidden",textOverflow:"ellipsis",textAlign:"right",...I.numeric?{fontVariantNumeric:"tabular-nums"}:{}},oe=typeof le=="string"||typeof le=="number"?e.jsx(D.Text,{style:ce,children:le}):e.jsx("div",{style:ce,children:le});return e.jsxs("div",{style:{display:"flex",gap:12,justifyContent:"space-between",alignItems:"baseline"},children:[typeof I.title=="string"?e.jsx(D.Text,{color:"subtle",fontWeight:"medium",style:{color:fs,flexShrink:0},children:I.title}):e.jsx("div",{style:{flexShrink:0},children:I.title}),oe]},Q)}),Yt=(v,x)=>{const I=Jt?Zt(Jt.col,v,x):null;return typeof I=="string"||typeof I=="number"?e.jsx(D.Text,{as:"span",style:Yr,children:I}):e.jsx("span",{style:Yr,children:I})},ti=e.jsx(f.Box,{style:{display:"flex",flexDirection:"column",gap:8,padding:8},children:Array.from({length:B},(v,x)=>e.jsxs(f.Box,{style:{border:Ir,borderRadius:"var(--sa-radii-sm, 6px)",padding:12,display:"flex",flexDirection:"column",gap:8},children:[e.jsx($e.Skeleton,{height:16,width:"60%",borderRadius:"rounded-sm"}),e.jsx($e.Skeleton,{height:12,width:"85%",borderRadius:"rounded-sm"}),e.jsx($e.Skeleton,{height:12,width:"70%",borderRadius:"rounded-sm"})]},`sa-tl-sk-card-${x}`))}),Pl=e.jsx(f.Box,{fullWidth:!0,style:{minHeight:(H==null?void 0:H.minHeight)??320,display:"flex",alignItems:"center",justifyContent:"center",padding:16},children:H==null?void 0:H.content}),oi=z?ti:ie.length===0?Pl:w==="expand"?e.jsx(f.Box,{style:{display:"flex",flexDirection:"column"},children:ie.map((v,x)=>{const I=Ie(v,x),Q=se.has(I),ce=O&&ir.has(I)?Wt:Xr(n==null?void 0:n(v,x));return e.jsxs("div",{style:{borderBottom:Ir,backgroundColor:ce},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center"},children:[Nt(v,x)&&e.jsx("div",{style:{display:"flex",alignItems:"center",paddingLeft:12,flexShrink:0},children:e.jsx(tr.Checkbox,{size:"sm",checked:ir.has(I),onChange:()=>_t(I),"aria-label":"Pilih baris"})}),e.jsxs("button",{type:"button",onClick:()=>ri(I),style:{flex:1,minWidth:0,display:"flex",alignItems:"center",justifyContent:"space-between",gap:12,padding:"10px 12px",background:"none",border:"none",font:"inherit",color:"inherit",cursor:"pointer",textAlign:"left"},children:[Yt(v,x),e.jsx(M.Icon,{name:Q?"ChevronUp":"ChevronDown",size:"sm",style:{flexShrink:0}})]}),_&&$c(v,x)]}),Q&&e.jsx("div",{style:{padding:"0 12px 12px",display:"flex",flexDirection:"column",gap:6},children:Hl(v,x)})]},I)})}):e.jsx(f.Box,{style:{display:"flex",flexDirection:"column",gap:8,padding:8},children:ie.map((v,x)=>{const I=Ie(v,x),Q=O&&ir.has(I);return e.jsxs(f.Box,{style:{border:Ir,borderRadius:"var(--sa-radii-sm, 6px)",padding:12,display:"flex",flexDirection:"column",gap:6,backgroundColor:Q?Wt:Xr(n==null?void 0:n(v,x))},children:[Nt(v,x)?e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[e.jsx(tr.Checkbox,{size:"sm",checked:ir.has(I),onChange:()=>_t(I),"aria-label":"Pilih baris"}),e.jsx("div",{style:{flex:1,minWidth:0},children:Yt(v,x)})]}):Yt(v,x),Hl(v,x),_&&Xc(v,x)]},I)})}),li=s&&Me&&Be!==void 0,Vl=c==="fixed"&&!s&&(Me?Be!==void 0:!0),ni=Vl&&!Me,ct=S&&S.length>0?S.map((v,x)=>e.jsx(U.Tr,{children:v.cells.map((I,Q)=>e.jsx(U.Td,{colSpan:I.colSpan,rowSpan:I.rowSpan,numeric:I.numeric,style:{textAlign:Lr(I.align)},children:I.content},`tl-foot-${x}-${Q}`))},`tl-foot-${x}`)):null,si=e.jsxs(U.Table,{className:"sa-table-layout",fullWidth:!0,size:l,resizable:li,style:Vl?{tableLayout:"fixed"}:void 0,onWidthsChange:ze?Qe:void 0,children:[ni&&e.jsxs("colgroup",{children:[O&&e.jsx("col",{style:{width:Tr}}),de.map(({col:v,key:x},I)=>e.jsx("col",{style:{width:Sr(v,I)}},`col-${x}`)),_&&e.jsx("col",{style:{width:1}})]}),e.jsx(U.Thead,{ref:Je,children:Ge?e.jsxs(e.Fragment,{children:[e.jsxs(U.Tr,{children:[O&&zl({rowSpan:2}),Ze.map(v=>v.isGroup?e.jsx(U.Th,{colSpan:v.leaves.length,style:{textAlign:"center",position:"sticky",top:0,zIndex:2,backgroundColor:Dr},children:e.jsx("span",{style:Yr,children:v.col.title})},`grp-${v.key}`):Qt(v.leaves[0],{rowSpan:2})),_&&e.jsx(U.Th,{rowSpan:2,style:{position:"sticky",top:0,right:0,zIndex:3,width:1,padding:0,border:"none",backgroundColor:Dr}})]}),e.jsx(U.Tr,{children:Ze.flatMap(v=>v.isGroup?v.leaves.map(x=>Qt(x,{top:dr})):[])})]}):e.jsxs(U.Tr,{children:[O&&zl(),Kc(),_&&e.jsx(U.Th,{style:{position:"sticky",top:0,right:0,zIndex:3,width:1,padding:0,border:"none",backgroundColor:Dr}})]})}),e.jsx(U.Tbody,{children:z?Qc:ie.length===0?e.jsx(U.Tr,{children:e.jsx(U.Td,{colSpan:Gt,children:Pl})}):e.jsxs(e.Fragment,{children:[ie.map((v,x)=>{const I=F==null?void 0:F(v,x,x>0?ie[x-1]:void 0),le=O&&ir.has(Ie(v,x))?Wt:Xr(n==null?void 0:n(v,x));return e.jsxs(d.Fragment,{children:[I!=null&&I!==!1&&e.jsx(U.Tr,{children:e.jsx(U.Td,{colSpan:Gt,style:{backgroundColor:Dr},children:I})}),e.jsxs(U.Tr,{children:[O&&Rc(v,x,le),de.map(({col:ce,key:oe},pe)=>{var Nl;const be=(Nl=ce.cellProps)==null?void 0:Nl.call(ce,v,x,ie);if(be!=null&&be.hidden)return null;const Xe=re(pe),Wr=Xe&&pe===G,rr=Zt(ce,v,x),zr=typeof ce.bg=="function"?ce.bg(v,x,ie):ce.bg,jl=Xr(zr)??le;return e.jsx(U.Td,{className:Xe?"sa-tl-frozen":void 0,colSpan:be==null?void 0:be.colSpan,rowSpan:be==null?void 0:be.rowSpan,numeric:ce.numeric,style:{textAlign:Lr(ce.align),width:Sr(ce,pe),minWidth:ce.minWidth,position:Xe?"sticky":void 0,left:Xe?Oe(pe):void 0,zIndex:Xe?1:void 0,boxShadow:Wr?yl:void 0,...jl?{"--sa-tl-bg":jl}:{}},children:typeof rr=="string"?e.jsx(D.Text,{style:{whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",textAlign:Lr(ce.align)},children:rr}):rr},`tl-cell-${x}-${oe}`)}),_&&e.jsx(U.Td,{style:{position:"sticky",right:0,width:1,padding:0,overflow:"visible",zIndex:2,border:"none"},children:Yc(v,x)})]})]},Ie(v,x))}),T!=null&&e.jsx(U.Tr,{children:e.jsx(U.Td,{colSpan:Gt,children:T})})]})}),ct&&e.jsx(U.Tfoot,{className:k?"sa-tl-sticky-foot":void 0,children:ct})]}),Xt=V?ie.findIndex((v,x)=>Ie(v,x)===V.rowKey):-1,$t=Xt>=0?ie[Xt]:null;return e.jsxs(e.Fragment,{children:[e.jsx(f.Box,{ref:Ye,fullWidth:!0,style:{overflow:"auto",height:m??He},children:te?e.jsxs(e.Fragment,{children:[oi,ct&&!z&&ie.length>0&&e.jsx(f.Box,{style:{borderTop:Ir},children:e.jsx(U.Table,{fullWidth:!0,size:l,className:"sa-table-layout",children:e.jsx(U.Tbody,{children:ct})})})]}):si}),V&&$t&&e.jsx("div",{className:"sa-tl-kebab-menu",style:{top:V.top,right:V.right},onClick:v=>v.stopPropagation(),children:nt($t).map(v=>e.jsx("div",{style:{padding:"2px 4px"},children:st(v,$t,Xt,{showLabel:!0,size:"sm"})},v.key))})]})},zt=r=>r==="asc"||r==="desc",vs=(r={})=>{const{sortKeyParam:t="sortBy",sortOrderParam:o="sortOrder",pageKey:n="page",defaultSort:l=null,paramKeys:s,scopeId:c,storage:i=Et}=r,{searchParams:a,setSearchParams:h,searchQueries:y}=Ne(),b=a.toString(),p=c?wr.tableSort(c):void 0,C=d.useRef(!1);d.useEffect(()=>{if(C.current||(C.current=!0,!p)||a.has(t)||a.has(o))return;const S=i.get(p);!(S!=null&&S.key)||!zt(S.direction)||h({...Object.fromEntries(a.entries()),[t]:S.key,[o]:S.direction},{replace:!0})},[]);const m=d.useMemo(()=>{const S=a.get(t),k=a.get(o);return S&&zt(k)?{key:S,direction:k}:l},[b,t,o,l]);d.useEffect(()=>{if(!p)return;const S=a.get(t),k=a.get(o);S&&zt(k)?i.set(p,{key:S,direction:k}):i.remove(p)},[b,p,t,o,i]);const w=(s==null?void 0:s.sortBy)??"sortBy",L=(s==null?void 0:s.sortOrder)??"sortOrder",F=d.useMemo(()=>m?{[w]:m.key,[L]:m.direction}:{},[m,w,L]),T=d.useCallback(S=>{const k={...y};S?(k[t]=S.key,k[o]=S.direction):(delete k[t],delete k[o]),delete k[n],h(k)},[y,t,o,n,h]);return{sort:m,setSort:T,params:F}},$r=({of:r,render:t})=>d.Children.toArray(r==null?void 0:r.map((o,n,l)=>t(o,n,l))),fe=({condition:r,fallback:t,children:o,loading:n,isLoading:l})=>e.jsx(e.Fragment,{children:l?n:r?o:t}),ye=r=>e.jsx(D.Text,{...r,fontSize:r.fontSize||"md",fontWeight:r.fontWeight||"medium",color:r.color||"gray-700",children:r.children}),cr=r=>e.jsx(D.Text,{color:"red-600",fontSize:"sm",children:r.message}),Cs=({size:r="md",direction:t="vertical",requiredTitle:o="(Required)",fullWidth:n=!1,...l})=>{var i,a,h;const s=l.hideMessageError||!1,c=t==="horizontal"?r==="sm"?342:r==="lg"?400:342:void 0;return e.jsxs(f.Box,{gap:t==="horizontal"?"spacing-96":"sm",direction:t==="horizontal"?"row":"column",...l.containerProps,children:[l.title&&e.jsx(fe,{condition:!!l.inputProps.required,fallback:e.jsxs(f.Box,{direction:"column",customMaxWidth:c,fullWidth:n,children:[e.jsx(ye,{children:l.title}),e.jsx(D.Text,{fontSize:r,color:"gray-500",children:l.description})]}),children:e.jsxs(f.Box,{direction:"column",customMaxWidth:c,fullWidth:n,children:[e.jsxs(ae.Flex,{direction:"row",gap:"xs",align:"center",children:[e.jsx(ye,{fontSize:r,children:l.title}),e.jsx(ye,{color:"error",fontSize:r,children:o}),e.jsx(fe,{condition:!!((i=l.tooltip)!=null&&i.label),children:e.jsx(Ee.Tooltip,{label:(a=l.tooltip)==null?void 0:a.label,arrowPosition:(h=l.tooltip)==null?void 0:h.arrowPosition,...l.tooltip,children:e.jsx(M.Icon,{name:"InfoCircle",size:r==="lg"?"sm":"xs",style:{color:"var(--sa-color-info-500, #00abeb)",marginTop:"6px"}})})})]}),e.jsx(fe,{condition:!!l.description,children:e.jsx(D.Text,{fontSize:r,color:"gray-500",children:l.description})})]})}),e.jsxs(f.Box,{direction:"column",gap:"xs",fullWidth:l.inputProps.fullWidth||!1,children:[e.jsx(ar.Input,{ref:l.inputRef,size:r,...l.inputProps,status:l.errorMessage?"error":"default",fullWidth:!0}),!s&&l.errorMessage&&e.jsx(cr,{message:l.errorMessage}),l.inputProps.extended&&l.inputProps.extended]})]})},xs=({size:r="md",direction:t="vertical",requiredTitle:o="(Required)",fullWidth:n=!1,...l})=>{var i,a,h;const s=l.hideMessageError||!1,c=t==="horizontal"?r==="sm"?342:r==="lg"?400:342:void 0;return e.jsxs(f.Box,{gap:t==="horizontal"?"spacing-96":"sm",direction:t==="horizontal"?"row":"column",onClick:l.onClickContainer,children:[l.title&&e.jsx(fe,{condition:!!l.inputProps.required,fallback:e.jsxs(f.Box,{direction:"column",customMaxWidth:c,fullWidth:n,children:[e.jsx(ye,{children:l.title}),e.jsx(D.Text,{fontSize:r,color:"gray-500",children:l.description})]}),children:e.jsxs(f.Box,{direction:"column",customMaxWidth:c,fullWidth:n,children:[e.jsxs(ae.Flex,{direction:"row",gap:"xs",align:"center",children:[e.jsx(ye,{fontSize:r,children:l.title}),e.jsx(ye,{color:"error",fontSize:r,children:o}),e.jsx(fe,{condition:!!((i=l.tooltip)!=null&&i.label),children:e.jsx(Ee.Tooltip,{label:(a=l.tooltip)==null?void 0:a.label,arrowPosition:(h=l.tooltip)==null?void 0:h.arrowPosition,...l.tooltip,children:e.jsx(M.Icon,{name:"InfoCircle",size:r==="lg"?"sm":"xs",style:{color:"var(--sa-color-info-500, #00abeb)",marginTop:"6px"}})})})]}),e.jsx(fe,{condition:!!l.description,children:e.jsx(D.Text,{fontSize:r,color:"gray-500",children:l.description})})]})}),e.jsxs(f.Box,{direction:"column",gap:"xs",fullWidth:l.inputProps.fullWidth||!1,children:[e.jsx(f.Box,{direction:"column",style:{width:l.inputProps.fullWidth?"100%":t==="horizontal"&&l.customWidth?l.customWidth:t==="horizontal"?"343px":""},children:e.jsx(br.Dropdown,{size:r,...l.inputProps,error:!!l.errorMessage})}),!s&&l.errorMessage&&e.jsx(cr,{message:l.errorMessage}),l.inputProps.extended&&l.inputProps.extended]})]})},ws=(r,t)=>typeof r=="string"&&r||t==="error"?"var(--sa-border-danger)":"var(--sa-border-subtle)",Ds=r=>{var i;const[t,o]=d.useState(!1),n=a=>{a.preventDefault(),a.stopPropagation()},l=a=>{a.preventDefault(),a.stopPropagation(),a.dataTransfer&&r.handleOnFileChange(a.dataTransfer.files.item(0))},s=a=>{a.preventDefault(),o(!0)},c=a=>{a.preventDefault(),o(!1)};return e.jsxs(f.Box,{width:"width-full",paddingInline:"md",direction:"row",gap:"sm",align:"center",onClick:r.handleOnClick,onDragOver:n,onDrop:l,onDragEnter:s,onDragLeave:c,paddingBlock:"md",borderRadius:"rounded-md",style:{border:t?"1px solid var(--sa-border-info)":`1px solid ${ws(r.errorMessage,r.status)}`},children:[e.jsx(M.Icon,{name:"Upload",size:"lg",style:{width:30,height:30}}),e.jsxs(ae.Flex,{direction:"column",gap:"xs",children:[e.jsxs(ae.Flex,{direction:"row",gap:"xs",children:[e.jsx(D.Text,{fontWeight:"medium",color:"gray-500",style:{textWrap:"nowrap"},fontSize:r.isDesktop?"md":"sm",children:"Click your upload"}),e.jsx(D.Text,{fontWeight:"medium",style:{textWrap:"nowrap"},fontSize:r.isDesktop?"md":"sm",children:"or Drag & Drop"})]}),e.jsx(D.Text,{fontSize:"sm",color:"gray-500",children:(i=r.fileSupports)==null?void 0:i.map(a=>a.toLocaleUpperCase()).join(", ")})]})]})};function Ss(r){return r.split(" ").map(t=>t[0]).join("").slice(0,2).toUpperCase()}const bl=r=>{const t={day:"2-digit",month:"short",year:"numeric"};return r.toLocaleDateString("id-ID",t)},Bs=r=>{const t={Jan:0,Feb:1,Mar:2,Apr:3,Mei:4,Jun:5,Jul:6,Agu:7,Sep:8,Okt:9,Nov:10,Des:11},o=r.split(" ");if(o.length!==3)return null;const n=parseInt(o[0],10),l=t[o[1]],s=parseInt(o[2],10);return isNaN(n)||isNaN(l)||isNaN(s)?null:new Date(s,l,n)};function ks(r,t=!0){if(!r)return"Rp 0";const o=typeof r=="number"?r.toString():r;if(isNaN(Number(o)))return"Rp 0";const n=o.split("."),l=n[0].replace(/\B(?=(\d{3})+(?!\d))/g,"."),s=n.length===2?l+"."+n[1]:l;return t?"Rp"+s:s}String.prototype.toTitleCase=function(){return this.toLowerCase().split(" ").map(r=>r.charAt(0).toUpperCase()+r.slice(1)).join(" ")},String.prototype.toNumber=function(){return Number(this)};const ms=r=>{const t=r.split(" ");let o=t[0].charAt(0);return t.length>1&&(o+=""+t[1].charAt(0)),o.toUpperCase()};function Es(r){const t=typeof r=="string"?new Date(r):r;if(isNaN(t.getTime()))throw new Error("Invalid date format");const o=t.getFullYear(),n=String(t.getMonth()+1).padStart(2,"0"),l=String(t.getDate()).padStart(2,"0");return`${o}-${n}-${l}`}const Fs="sa-admin",Re=r=>`var(--${Fs}-${r})`,Ms={base:{borderColor:Re("base-border-color"),textColor:Re("base-text-color"),iconColor:Re("base-icon-color"),placeholderColor:Re("base-placeholder-color")},document:{bgColor:Re("document-bg-color")},sidebar:{bgColor:Re("sidebar-bg-color"),borderColor:Re("sidebar-border-color"),maxWidth:Re("sidebar-max-width"),width:Re("sidebar-width"),collapseWidth:Re("sidebar-collapse-width"),collapseV2Width:Re("sidebar-v2-collapse-width")}},Is=24*60*60*1e3,Ts=r=>{const t="14px poppins",n=document.createElement("canvas").getContext("2d");n.font=t;const l=n.measureText(r).width;return Number(Math.ceil(l))},Ls=/^[^\s@]+@[^\s@]+\.[^\s@]+$/,Os=/--+/,As=/-$/;function Ws(r,t){return JSON.stringify(r)!==JSON.stringify(t)}function zs(r){return/^(?:\+62|62|0)8[1-9][0-9]{7,10}$/.test(r)}function Hs(r){return/^[A-Za-z\s]+$/.test(r)}const Ps=r=>{const t=/^[0-9]$/,o=["ArrowLeft","ArrowRight","ArrowUp","ArrowDown","Backspace","Delete","Enter","Tab"];(r.ctrlKey||r.metaKey)&&(r.key==="a"||r.key==="c"||r.key==="v")||!t.test(r.key)&&!o.includes(r.key)&&r.preventDefault()},Vs=r=>{const t=/^[0-9]$/,o=["ArrowLeft","ArrowRight","ArrowUp","ArrowDown","Backspace","Delete","Enter","Tab"];(r.ctrlKey||r.metaKey)&&r.key==="v"||t.test(r.key)&&!o.includes(r.key)&&r.preventDefault()},js=r=>{const t=/^[0-9.]$/,o=["ArrowLeft","ArrowRight","ArrowUp","ArrowDown","Backspace","Delete","Enter","Tab"];(r.ctrlKey||r.metaKey)&&r.key==="v"||!t.test(r.key)&&!o.includes(r.key)&&r.preventDefault()},Ns=r=>Ls.test(r);function _s(r){return!(Os.test(r)||As.test(r))}const qs=r=>{const t=["ArrowLeft","ArrowRight","ArrowUp","ArrowDown","Backspace","Delete","Enter","Tab","Home","End"];if((r.ctrlKey||r.metaKey)&&["a","c","v","x"].includes(r.key.toLowerCase()))return;const o=r.currentTarget.value;/^[0-9]$/.test(r.key)||r.key==="."&&!o.includes(".")||r.key==="-"&&o.length===0&&!o.includes("-")||t.includes(r.key)||r.preventDefault()},Zs=r=>{const t=document.getElementById(r);if(t){const o=t.getBoundingClientRect(),n=window.scrollY+o.top-80;window.scrollTo({top:n,behavior:"smooth"})}};function Gs(r){const t=r.toLowerCase();if(["kb","mb","gb"].find(s=>t.endsWith(s)))return r;const l=Number(r);if(isNaN(l))throw new Error("Invalid size format");return l>=1e6?`${(l/1e6).toFixed(2)}MB`:l>=1e3?`${(l/1e3).toFixed(2)}KB`:`${l}B`}function Qs(r){const t=r.split("/");return t[t.length-1]}const Us=r=>{var t,o;return e.jsxs(f.Box,{width:"width-full",paddingInline:"md",height:"height-full",direction:"row",justify:"space-between",align:"center",onClick:r.handleOnClickFile,fullHeight:!0,paddingBlock:"md",id:"file-item",borderRadius:"rounded-md",style:{border:"1px solid var(--sa-border-subtle)",cursor:"pointer"},children:[e.jsxs(ae.Flex,{direction:"row",align:"center",gap:"sm",style:{flex:1,minWidth:0},children:[e.jsx(M.Icon,{name:"DocumentFilled",size:"lg",style:{color:"var(--sa-icon-brand)",width:30,height:30,flexShrink:0}}),e.jsxs(ae.Flex,{direction:"column",style:{minWidth:0,flex:1},children:[e.jsx(D.Text,{fontWeight:"bold",style:{textOverflow:"ellipsis",whiteSpace:"nowrap",overflow:"hidden"},children:r.defaultFile?Qs(r.defaultFile.url):(t=r.fileSelected)==null?void 0:t.name}),r.defaultFile?(r.defaultFile.size||r.defaultFile.date)&&e.jsxs(ae.Flex,{direction:"row",gap:"xs",align:"center",children:[r.defaultFile.size&&e.jsx(D.Text,{fontSize:"sm",fontWeight:"medium",children:r.defaultFile.size}),r.defaultFile.size&&r.defaultFile.date&&e.jsx(M.Icon,{name:"Dot",size:"xs"}),r.defaultFile.date&&e.jsx(D.Text,{fontSize:"sm",fontWeight:"medium",style:{textWrap:"nowrap"},children:r.defaultFile.date})]}):e.jsxs(ae.Flex,{direction:"row",gap:"xs",align:"center",children:[e.jsx(D.Text,{fontSize:"sm",fontWeight:"medium",children:Gs(((o=r.fileSelected)==null?void 0:o.size.toString())||"100000")}),e.jsx(M.Icon,{name:"Dot",size:"xs"}),e.jsx(D.Text,{fontSize:"sm",fontWeight:"medium",style:{textWrap:"nowrap"},children:bl(new Date)})]})]})]}),e.jsx(j.Button,{size:"xs",variant:"tertiary",tone:"error",type:"button",onClick:n=>{n.stopPropagation(),r.handleOnDeleteFile()},iconLeft:e.jsx(M.Icon,{name:"Trash1"})})]})},vl=({status:r="default",labelPosition:t="outside-top",...o})=>{var p;const n=d.useRef(null),l=()=>{if(o.defaultFile){window.open(o.defaultFile.url);return}n.current&&n.current.click()},s=Se.useMediaQuery("md"),c=r==="error"||typeof o.errorMessage=="string"&&!!o.errorMessage,i=o.label?e.jsxs(ae.Flex,{direction:"row",align:"center",gap:"xs",children:[e.jsx(D.Text,{style:{fontSize:"14px",fontWeight:500,color:"var(--sa-text-primary)"},children:o.label}),o.optional&&e.jsx("span",{style:{background:"var(--sa-background-neutral)",border:"1px solid var(--sa-border-subtle)",borderRadius:"4px",padding:"0 8px",fontSize:"10px",fontWeight:500,lineHeight:"18px",color:"var(--sa-text-primary)",display:"inline-flex",alignItems:"center"},children:"Optional"}),o.required&&e.jsx("span",{style:{fontSize:"14px",fontWeight:500,color:"var(--sa-text-error)"},children:"*"})]}):null,a=o.description?e.jsx(D.Text,{style:{fontSize:"12px",fontWeight:400,color:"var(--sa-text-subtlest, #6b6e76)",lineHeight:"18px"},children:o.description}):null,h=e.jsxs(e.Fragment,{children:[o.helperText&&e.jsx(D.Text,{style:{fontSize:"12px",fontWeight:400,color:"var(--sa-text-subtlest, #6b6e76)",lineHeight:"18px"},children:o.helperText}),o.errorText&&r==="error"&&e.jsx(D.Text,{style:{fontSize:"12px",fontWeight:400,color:"var(--sa-text-error, #a4133c)",lineHeight:"18px"},children:o.errorText}),o.errorMessage&&!o.errorText&&e.jsx(D.Text,{style:{fontSize:"12px",fontWeight:400,color:"var(--sa-text-error, #a4133c)",lineHeight:"18px"},children:o.errorMessage})]}),y=e.jsx("input",{type:"file",style:{display:"none"},ref:n,onChange:C=>{var m;return o.handleOnChangeFile(((m=C.target.files)==null?void 0:m.item(0))||null)},accept:(p=o.fileSupportOption)==null?void 0:p.map(C=>"."+(C==null?void 0:C.toLowerCase())).join(", ")}),b=e.jsxs(f.Box,{direction:"column",fullWidth:!0,style:{minHeight:"69px"},borderRadius:"rounded-md",display:"flex",justify:"center",align:"center",cursor:"pointer",gap:"md",...o.containerProps,children:[y,(o.fileSelected||o.defaultFile)&&e.jsx(Us,{fileSelected:o.fileSelected,defaultFile:o.defaultFile,handleOnDeleteFile:o.handleOnDeleteFile,handleOnClickFile:l}),!o.fileSelected&&!o.defaultFile&&e.jsx(Ds,{fileSupports:o.fileSupportOption,isDesktop:s,errorMessage:c?o.errorText||o.errorMessage||" ":void 0,status:c?"error":"default",handleOnClick:l,handleOnFileChange:o.handleOnChangeFile})]});return t==="outside-left"?e.jsxs(ae.Flex,{direction:"row",align:"flex-start",gap:"sm",style:{width:"100%"},children:[e.jsxs(ae.Flex,{direction:"column",gap:"xs",style:{width:"40%",minWidth:"120px",paddingTop:"10px"},children:[i,a]}),e.jsxs(ae.Flex,{direction:"column",gap:"sm",style:{flex:1,minWidth:0},children:[b,h]})]}):e.jsxs(ae.Flex,{direction:"column",gap:"sm",style:{width:"100%"},children:[i,a,b,h]})},Js=({size:r="md",direction:t="vertical",requiredTitle:o="(Required)",fullWidth:n=!1,...l})=>{var i,a,h;const s=l.hideMessageError||!1,c=t==="horizontal"?r==="sm"?342:r==="lg"?400:342:void 0;return e.jsxs(f.Box,{gap:t==="horizontal"?"spacing-96":"sm",direction:t==="horizontal"?"row":"column",...l.containerProps,children:[l.title&&e.jsx(fe,{condition:!!l.inputProps.required,fallback:e.jsxs(f.Box,{direction:"column",customMaxWidth:c,fullWidth:n,children:[e.jsx(ye,{children:l.title}),e.jsx(D.Text,{fontSize:r,color:"gray-500",children:l.description})]}),children:e.jsxs(f.Box,{direction:"column",customMaxWidth:c,fullWidth:n,children:[e.jsxs(ae.Flex,{direction:"row",gap:"xs",align:"center",children:[e.jsx(ye,{fontSize:r,children:l.title}),e.jsx(ye,{color:"error",fontSize:r,children:o}),e.jsx(fe,{condition:!!((i=l.tooltip)!=null&&i.label),children:e.jsx(Ee.Tooltip,{label:(a=l.tooltip)==null?void 0:a.label,arrowPosition:(h=l.tooltip)==null?void 0:h.arrowPosition,...l.tooltip,children:e.jsx(M.Icon,{name:"InfoCircle",size:r==="lg"?"sm":"xs",style:{color:"var(--sa-color-info-500, #00abeb)",marginTop:"6px"}})})})]}),e.jsx(fe,{condition:!!l.description,children:e.jsx(D.Text,{fontSize:r,color:"gray-500",children:l.description})})]})}),e.jsxs(ae.Flex,{direction:"column",gap:"xs",children:[e.jsx(vl,{...l.inputProps,status:l.errorMessage?"error":"default"}),!s&&l.errorMessage&&e.jsx(cr,{message:l.errorMessage})]})]})},Ys=({size:r="md",direction:t="vertical",requiredTitle:o="(Required)",fullWidth:n=!1,required:l=!1,...s})=>{var a,h,y,b;const c=s.hideMessageError||!1,i=t==="horizontal"?r==="sm"?342:r==="lg"?400:342:void 0;return e.jsxs(f.Box,{gap:t==="horizontal"||t==="horizontal-inline"?"spacing-96":"sm",direction:t==="horizontal"||t==="horizontal-inline"?"row":"column",...s.containerProps,children:[s.title&&e.jsx(fe,{condition:!!l,fallback:e.jsxs(f.Box,{direction:"column",customMaxWidth:i,fullWidth:n,children:[e.jsx(ye,{children:s.title}),e.jsx(Ke.Body3,{props:{color:"gray-500"},children:s.description})]}),children:e.jsxs(f.Box,{direction:"column",customMaxWidth:i,fullWidth:n,children:[e.jsxs(ae.Flex,{direction:"row",gap:"xs",align:"center",children:[e.jsx(ye,{fontSize:r,children:s.title}),e.jsx(ye,{color:"error",fontSize:r,children:o}),e.jsx(fe,{condition:!!((a=s.tooltip)!=null&&a.label),children:e.jsx(Ee.Tooltip,{label:(h=s.tooltip)==null?void 0:h.label,arrowPosition:(y=s.tooltip)==null?void 0:y.arrowPosition,...s.tooltip,children:e.jsx(M.Icon,{name:"InfoCircle",size:r==="lg"?"sm":"xs",style:{color:"var(--sa-color-info-500, #00abeb)",marginTop:"6px"}})})})]}),e.jsx(fe,{condition:!!s.description,children:e.jsx(D.Text,{fontSize:r,color:"gray-500",children:s.description})})]})}),e.jsx(f.Box,{gap:t==="horizontal-inline"?"xl":"md",direction:t==="horizontal-inline"?"row":"column",align:"flex-start",children:e.jsx($r,{of:(b=s.checkBoxesList)==null?void 0:b.map(p=>({...p,isChecked:s.checkBoxesAreChecked.includes(p.id)})),render:p=>p.renderBadge?e.jsxs(f.Box,{direction:"row",justify:"space-between",gap:"lg",...s.badgeContainerProps,children:[e.jsx(tr.Checkbox,{name:p.name,value:p.id,checked:p.isChecked,onChange:C=>s.onChecked(C.target.value,p),label:p.name,description:p.description}),p.renderBadge]}):e.jsx(tr.Checkbox,{name:p.name,value:p.id,checked:p.isChecked,onChange:C=>s.onChecked(C.target.value,p),label:p.name,description:p.description})})}),!c&&s.errorMessage&&e.jsx(cr,{message:s.errorMessage})]})},Xs=({position:r="vertical",size:t="md",fullWidth:o=!1,...n})=>{var s;const l=r==="horizontal-inline"||r==="horizontal-block"?t==="sm"?342:t==="lg"?400:342:void 0;return e.jsxs(f.Box,{gap:r==="horizontal-inline"||r==="horizontal-block"?"spacing-96":"sm",direction:r==="horizontal-inline"||r==="horizontal-block"?"row":"column",children:[e.jsx(fe,{condition:!!n.description||!!n.title,children:e.jsxs(f.Box,{direction:"column",customMaxWidth:l,fullWidth:o,children:[n.title&&e.jsx(ye,{children:n.title}),e.jsx(fe,{condition:!!n.description,children:e.jsx(D.Text,{color:"gray-500",children:n.description})})]})}),e.jsx(f.Box,{gap:"sm",direction:r==="horizontal"||r==="horizontal-inline"?"row":"column",align:"flex-start",flexWrap:"wrap",children:e.jsx($r,{of:(s=n.radioList)==null?void 0:s.map(c=>({...c,isChecked:n.radioIsChecked===c.id})),render:({value:c,id:i,isChecked:a,subInput:h,label:y,description:b})=>e.jsxs(f.Box,{direction:"column",gap:"xs",customMaxWidth:l,children:[e.jsx(dt.Radio,{id:`${i.toString()}-${c}`,name:n.groupName||y,label:y,value:c,checked:a,onChange:p=>n.onChecked({id:i,label:p.target.name,value:p.target.value}),disabled:n.disableAll},i),b&&e.jsx(D.Text,{color:"gray-500",style:{marginLeft:28},children:b}),h]})})}),n.errorMessage&&e.jsx(cr,{message:n.errorMessage})]})},$s=({size:r="md",direction:t="vertical",requiredTitle:o="(Required)",fullWidth:n=!1,...l})=>{var i,a,h;const s=l.hideMessageError||!1,c=t==="horizontal"?r==="sm"?342:r==="lg"?400:342:void 0;return e.jsxs(f.Box,{gap:t==="horizontal"?"spacing-96":"sm",direction:t==="horizontal"?"row":"column",...l.containerProps,children:[l.title&&e.jsx(fe,{condition:!!l.inputProps.required,fallback:e.jsxs(f.Box,{direction:"column",customMaxWidth:c,fullWidth:n,children:[e.jsx(ye,{children:l.title}),e.jsx(D.Text,{fontSize:r,color:"gray-500",children:l.description})]}),children:e.jsxs(f.Box,{direction:"column",customMaxWidth:c,fullWidth:n,children:[e.jsxs(ae.Flex,{direction:"row",gap:"xs",align:"center",children:[e.jsx(ye,{fontSize:r,children:l.title}),e.jsx(ye,{color:"error",fontSize:r,children:o}),e.jsx(fe,{condition:!!((i=l.tooltip)!=null&&i.label),children:e.jsx(Ee.Tooltip,{label:(a=l.tooltip)==null?void 0:a.label,arrowPosition:(h=l.tooltip)==null?void 0:h.arrowPosition,...l.tooltip,children:e.jsx(M.Icon,{name:"InfoCircle",size:r==="lg"?"sm":"xs",style:{color:"var(--sa-color-info-500, #00abeb)",marginTop:"6px"}})})})]}),e.jsx(fe,{condition:!!l.description,children:e.jsx(D.Text,{fontSize:r,color:"gray-500",children:l.description})})]})}),e.jsxs(ae.Flex,{direction:"column",gap:"xs",children:[e.jsx(at.Textarea,{ref:l.inputRef,size:r,...l.inputProps,status:l.errorMessage?"error":"default"}),!s&&l.errorMessage&&e.jsx(cr,{message:l.errorMessage})]})]})},Ks=({size:r="md",direction:t="vertical",requiredTitle:o="(Required)",required:n=!1,fullWidth:l=!1,...s})=>{var i,a,h;const c=t==="horizontal"?r==="sm"?342:r==="lg"?400:342:void 0;return e.jsxs(f.Box,{gap:t==="horizontal"?"spacing-96":"sm",direction:t==="horizontal"?"row":"column",...s.containerProps,children:[s.title&&e.jsx(fe,{condition:n,fallback:e.jsxs(f.Box,{direction:"column",customMaxWidth:c,fullWidth:l,children:[e.jsx(ye,{children:s.title}),e.jsx(D.Text,{fontSize:r,color:"gray-500",children:s.titleDescription})]}),children:e.jsxs(f.Box,{direction:"column",customMaxWidth:c,fullWidth:l,children:[e.jsxs(ae.Flex,{direction:"row",gap:"xs",align:"center",children:[e.jsx(ye,{fontSize:r,children:s.title}),e.jsx(ye,{color:"error",fontSize:r,children:o}),e.jsx(fe,{condition:!!((i=s.tooltip)!=null&&i.label),children:e.jsx(Ee.Tooltip,{label:(a=s.tooltip)==null?void 0:a.label,arrowPosition:(h=s.tooltip)==null?void 0:h.arrowPosition,...s.tooltip,children:e.jsx(M.Icon,{name:"InfoCircle",size:r==="lg"?"sm":"xs",style:{color:"var(--sa-color-info-500, #00abeb)",marginTop:"6px"}})})})]}),e.jsx(fe,{condition:!!s.titleDescription,children:e.jsx(D.Text,{fontSize:r,color:"gray-500",children:s.titleDescription})})]})}),e.jsx(xr.Toggle,{checked:s.checked,onChange:s.onChange,label:s.label,description:s.description}),s.errorMessage&&e.jsx(cr,{message:s.errorMessage})]})},Rs=({variant:r="primary",size:t="md",...o})=>{const n=Cr.useColor(),l=c=>{var a,h,y,b,p,C;if(!c)return;const i=o.disabled?"var(--sa-text-disable, #181a198f)":r==="secondary"?"var(--sa-text-subtle, #8c8f97)":r==="secondary-danger"?(h=(a=n==null?void 0:n.computed)==null?void 0:a.red)==null?void 0:h[600]:r==="secondary-primary"?(b=(y=n==null?void 0:n.computed)==null?void 0:y.blue)==null?void 0:b[700]:(C=(p=n==null?void 0:n.computed)==null?void 0:p.gray)==null?void 0:C[50];return e.jsx(M.Icon,{name:c,size:t,style:{color:i}})},s=()=>{var i,a,h,y;if(r!=="secondary-danger"&&r!=="secondary-primary")return o.title;const c={color:o.disabled?"var(--sa-text-disable, #181a198f)":r==="secondary-danger"?(a=(i=n==null?void 0:n.computed)==null?void 0:i.red)==null?void 0:a[600]:(y=(h=n==null?void 0:n.computed)==null?void 0:h.blue)==null?void 0:y[700]};switch(t){case"xs":return e.jsx(Ke.Body2,{props:{style:c},children:o.title});case"sm":case"md":return e.jsx(Ke.SubH3,{props:{style:c},children:o.title});case"lg":return e.jsx(Ke.SubH2,{props:{style:c},children:o.title});default:return o.title}};return e.jsx(j.Button,{fullWidth:!0,disabled:o.disabled,primary:r==="primary",secondary:r==="secondary"||r==="secondary-danger"||r==="secondary-primary",success:r==="success",onClick:o.onClick,type:o.type,iconLeft:l(o.iconLeft),iconRight:l(o.iconRight),size:t,children:s()})},ec=r=>e.jsx(Ke.H5,{props:{...r},children:r.title}),rc=({size:r="md",direction:t="vertical",requiredTitle:o="(Required)",fullWidth:n=!1,...l})=>{var i,a,h;const s=l.hideMessageError||!1,c=t==="horizontal"?r==="sm"?342:r==="lg"?400:342:void 0;return e.jsxs(f.Box,{gap:t==="horizontal"?"spacing-96":"sm",direction:t==="horizontal"?"row":"column",onClick:l.onClickContainer,children:[l.title&&e.jsx(fe,{condition:!!l.inputProps.required,fallback:e.jsxs(f.Box,{direction:"column",customMaxWidth:c,fullWidth:n,children:[e.jsx(ye,{children:l.title}),e.jsx(D.Text,{fontSize:r,color:"gray-500",children:l.description})]}),children:e.jsxs(f.Box,{direction:"column",customMaxWidth:c,fullWidth:n,children:[e.jsxs(ae.Flex,{direction:"row",gap:"xs",align:"center",children:[e.jsx(ye,{fontSize:r,children:l.title}),e.jsx(ye,{color:"error",fontSize:r,children:o}),e.jsx(fe,{condition:!!((i=l.tooltip)!=null&&i.label),children:e.jsx(Ee.Tooltip,{label:(a=l.tooltip)==null?void 0:a.label,arrowPosition:(h=l.tooltip)==null?void 0:h.arrowPosition,...l.tooltip,children:e.jsx(M.Icon,{name:"InfoCircle",size:r==="lg"?"sm":"xs",style:{color:"var(--sa-color-info-500, #00abeb)",marginTop:"6px"}})})})]}),e.jsx(fe,{condition:!!l.description,children:e.jsx(D.Text,{fontSize:r,color:"gray-500",children:l.description})})]})}),e.jsxs(ae.Flex,{direction:"column",gap:"xs",children:[e.jsx(f.Box,{direction:"column",style:{width:t==="horizontal"&&l.customWidth?l.customWidth:t==="horizontal"?"343px":""},children:e.jsx(fr.StarasiaDate,{size:r,...l.inputProps,status:l.errorMessage?"error":void 0})}),!s&&l.errorMessage&&e.jsx(cr,{message:l.errorMessage})]})]})};async function tc(r,t){const o=new Image;o.src=r,await new Promise((s,c)=>{o.onload=s,o.onerror=c});const n=document.createElement("canvas");n.width=t.width,n.height=t.height;const l=n.getContext("2d",{alpha:!0});if(!l)throw new Error("No 2D context");return l.drawImage(o,t.x,t.y,t.width,t.height,0,0,t.width,t.height),new Promise((s,c)=>{n.toBlob(i=>{if(!i)return c("Canvas is empty");const a=new File([i],"cropped.png",{type:"image/png"});s(a)},"image/png")})}const Cl={"1:1":1,"4:3":4/3,"16:9":16/9,"3:4":3/4,"9:16":9/16,"2:3":2/3,"3:2":3/2,"32:9":32/9},xl=d.forwardRef(({handleUpload:r,urlImage:t,isUploading:o,croppedImage:n,setCroppedImage:l,size:s="96",aspect:c="1:1",containerProps:i,maxFileSize:a=2,onError:h},y)=>{const b=Se.useMediaQuery("md"),[p,C]=d.useState(!1),[m,w]=d.useState(null),[L,F]=d.useState(!1),[T,S]=d.useState({x:0,y:0}),[k,H]=d.useState(1),[z,B]=d.useState(null);d.useEffect(()=>{t===null&&l(null)},[t]);const W=d.useCallback((V,N)=>{B(N)},[]),O=V=>{var ve;const N=(ve=V.target.files)==null?void 0:ve[0];if(!N)return;const se=new FileReader;se.onload=()=>{w(se.result),F(!0)},se.readAsDataURL(N)},Y=async()=>{if(!(!m||!z))try{const V=await tc(m,z);if(a&&V.size>a*1024*1024){h==null||h(`Ukuran file maksimal ${a}MB`);return}r==null||r(V);const N=URL.createObjectURL(V);l(N,V),F(!1)}catch{h==null||h("Gagal memproses gambar")}},X=d.useRef(null),q=()=>{X.current&&X.current.click()};d.useImperativeHandle(y,()=>({openFileDialog:()=>{var V;(V=X.current)==null||V.click()}}));const Z=parseInt(s,10),K=Cl[c];let te,_;return K>=1?(_=Z,te=Z*K):(te=Z,_=Z/K),e.jsxs(f.Box,{direction:"column",display:"flex",position:"relative",bg:(i==null?void 0:i.bg)||"gray-200",borderStyle:(i==null?void 0:i.borderStyle)||"border-none",borderColor:(i==null?void 0:i.borderColor)||"gray-200",borderWidth:(i==null?void 0:i.borderWidth)||"border-2",borderRadius:(i==null?void 0:i.borderRadius)||"rounded-md",overflow:"overflow-hidden",align:"center",justify:"center",style:{width:i!=null&&i.fullWidth?"100%":`${te}px`,height:i!=null&&i.fullWidth?"auto":`${_}px`,aspectRatio:K,flexShrink:0},onMouseEnter:()=>C(!0),onMouseLeave:()=>C(!1),children:[n||t?e.jsx("img",{src:n||t||void 0,alt:"Profile",style:{objectFit:"cover",width:"100%",height:"100%"}}):e.jsx(f.Box,{display:"flex",direction:"column",align:"center",justify:"center",padding:"spacing-4",children:e.jsx(M.Icon,{name:"Image",style:{color:"var(--sa-text-subtle, #8c8f97)",width:Number(s)/2<40?Number(s)/2:40,height:Number(s)/2<40?Number(s)/2:40}})}),e.jsxs(f.Box,{direction:"column",position:"absolute",display:"flex",align:"center",justify:"center",cursor:"pointer",style:{inset:0,backgroundColor:"var(--sa-color-black-alpha-a30, #080f214c)",opacity:p?1:0,transition:"opacity 0.3s ease-in-out"},onClick:q,children:[e.jsx("input",{ref:X,type:"file",accept:"image/*",onChange:O,disabled:o,style:{display:"none"}}),e.jsxs(f.Box,{display:"flex",align:"center",gap:"spacing-2",direction:"row",children:[e.jsx(M.Icon,{name:"Edit3",style:{color:"var(--sa-background-primary, #ffffff)"}}),e.jsx(fe,{condition:s.toNumber()>80,children:e.jsx(D.Text,{color:"gray-50",fontSize:s.toNumber()>80?"sm":"md",fontWeight:"medium",children:"Edit Image"})})]})]}),o&&e.jsx(f.Box,{direction:"column",position:"absolute",display:"flex",align:"center",justify:"center",style:{inset:0,zIndex:20,backgroundColor:"var(--sa-color-white-alpha-a80, #e5e9f6cc)"},children:e.jsx(f.Box,{direction:"column",borderRadius:"rounded-full",style:{animation:"spin 1s linear infinite",border:"2px solid transparent",height:"2rem",width:"2rem"},borderColor:"info-600"})}),L&&Vr.createPortal(e.jsx("div",{style:{position:"fixed",inset:0,zIndex:19999,display:"flex",alignItems:"center",justifyContent:"center",backgroundColor:"rgba(0,0,0,0.6)"},onClick:()=>F(!1),children:e.jsxs("div",{style:{backgroundColor:"var(--sa-background-primary)",borderRadius:"var(--sa-radii-md)",boxShadow:"0 20px 60px rgba(0,0,0,0.3)",overflow:"hidden",width:b?c==="1:1"?"min(90vw, 480px)":`min(90vw, ${te*2}px)`:"calc(100vw - 2rem)",display:"flex",flexDirection:"column"},onClick:V=>V.stopPropagation(),children:[e.jsx("div",{style:{position:"relative",width:"100%",height:"20rem",backgroundColor:"var(--sa-color-gray-100)"},children:m&&e.jsx(_l,{image:m,crop:T,zoom:k,aspect:c?Cl[c]:void 0,onCropChange:S,onZoomChange:H,onCropComplete:W,objectFit:"contain",minZoom:.5,restrictPosition:!1})}),e.jsxs("div",{style:{display:"flex",justifyContent:"flex-end",gap:"0.5rem",padding:"0.75rem 1rem",borderTop:"1px solid var(--sa-border-subtle)"},children:[e.jsx(j.Button,{size:"sm",secondary:!0,onClick:()=>F(!1),children:"Cancel"}),e.jsx(j.Button,{size:"sm",primary:!0,onClick:Y,children:"Crop"})]})]})}),document.body)]})}),oc=({size:r="md",direction:t="vertical",requiredTitle:o="(Required)",fullWidth:n=!1,required:l=!1,...s})=>{var a,h,y;const c=s.hideMessageError||!1,i=t==="horizontal"?r==="sm"?342:r==="lg"?400:342:void 0;return e.jsxs(f.Box,{gap:t==="horizontal"?"spacing-96":"sm",direction:t==="horizontal"?"row":"column",...s.containerProps,children:[s.title&&e.jsx(fe,{condition:!!l,fallback:e.jsxs(f.Box,{direction:"column",customMaxWidth:i,fullWidth:n,children:[e.jsx(ye,{children:s.title}),e.jsx(D.Text,{fontSize:r,color:"gray-500",children:s.description})]}),children:e.jsxs(f.Box,{direction:"column",customMaxWidth:i,fullWidth:n,children:[e.jsxs(ae.Flex,{direction:"row",gap:"xs",align:"center",children:[e.jsx(ye,{fontSize:r,children:s.title}),e.jsx(ye,{color:"error",fontSize:r,children:o}),e.jsx(fe,{condition:!!((a=s.tooltip)!=null&&a.label),children:e.jsx(Ee.Tooltip,{label:(h=s.tooltip)==null?void 0:h.label,arrowPosition:(y=s.tooltip)==null?void 0:y.arrowPosition,...s.tooltip,children:e.jsx(M.Icon,{name:"InfoCircle",size:r==="lg"?"sm":"xs",style:{color:"var(--sa-color-info-500, #00abeb)",marginTop:"6px"}})})})]}),e.jsx(fe,{condition:!!s.description,children:e.jsx(D.Text,{fontSize:r,color:"gray-500",children:s.description})})]})}),e.jsxs(ae.Flex,{direction:"column",gap:"xs",children:[e.jsx(xl,{...s.inputProps}),!c&&s.errorMessage&&e.jsx(cr,{message:s.errorMessage})]})]})},lc=({size:r="md",direction:t="vertical",requiredTitle:o="(Required)",fullWidth:n=!1,...l})=>{var c,i,a;const s=t==="horizontal"?r==="sm"?342:r==="lg"?400:342:void 0;return e.jsxs(f.Box,{gap:t==="horizontal"?"spacing-96":"sm",direction:t==="horizontal"?"row":"column",...l.containerProps,children:[l.title&&e.jsx(fe,{condition:!!l.inputProps.required,fallback:e.jsxs(f.Box,{direction:"column",customMaxWidth:s,fullWidth:n,children:[e.jsx(ye,{children:l.title}),e.jsx(D.Text,{fontSize:r,color:"gray-500",children:l.description})]}),children:e.jsxs(f.Box,{direction:"column",customMaxWidth:s,fullWidth:n,children:[e.jsxs(ae.Flex,{direction:"row",gap:"xs",align:"center",children:[e.jsx(ye,{fontSize:r,children:l.title}),e.jsx(ye,{color:"error",fontSize:r,children:o}),e.jsx(fe,{condition:!!((c=l.tooltip)!=null&&c.label),children:e.jsx(Ee.Tooltip,{label:(i=l.tooltip)==null?void 0:i.label,arrowPosition:(a=l.tooltip)==null?void 0:a.arrowPosition,...l.tooltip,children:e.jsx(M.Icon,{name:"InfoCircle",size:r==="lg"?"sm":"xs",style:{color:"var(--sa-color-info-500, #00abeb)",marginTop:"6px"}})})})]}),e.jsx(fe,{condition:!!l.description,children:e.jsx(D.Text,{fontSize:r,color:"gray-500",children:l.description})})]})}),l.inputProps.extended&&l.inputProps.extended]})},nc=({items:r,id:t,handleOnUpdate:o,width:n,toggleShow:l=!0,disabled:s=!1})=>{var y;const[c,i]=d.useState([]);d.useEffect(()=>{r&&i([...r.map(b=>({id:b.id,isActive:b.isActive}))])},[r]);const a=(y=c.find(b=>b.id===t))==null?void 0:y.isActive,h=d.useCallback(()=>{i(b=>b.map(p=>p.id===t?{...p,isActive:!p.isActive}:p)),o&&o(!a)},[t,o,a]);return e.jsx(f.Box,{direction:"row",gap:"md",style:{width:n},children:l&&e.jsx(xr.Toggle,{disabled:s,checked:a,onChange:h,label:a?"Active":"Inactive"})})},sc={InputText:Cs,InputDropdown:xs,InputSingleFile:Js,CheckBoxOptions:Ys,RadioOptions:Xs,InputTextArea:$s,ToggleForm:Ks,ActionButton:Rs,FormTitle:ec,InputDate:rc,InputImgFile:oc,Custom:lc},wl=({customBottom:r})=>{const[t,o]=d.useState(!1),n=()=>{window.scrollY>window.screenY?o(!0):o(!1)},l=()=>{window.scrollTo({top:0,behavior:"smooth"})};return d.useEffect(()=>(window.addEventListener("scroll",n),()=>{window.removeEventListener("scroll",n)}),[]),e.jsx(f.Box,{direction:"column",style:{position:"fixed",bottom:0,right:0},children:e.jsx(f.Box,{direction:"column",position:"absolute",style:{bottom:r||"1.6rem",right:"2rem",transform:t?"scale(1)":"scale(0)",transition:"transform 0.2s ease-in-out"},children:e.jsx(j.Button,{secondary:!0,size:"xs",onClick:l,type:"button",iconLeft:e.jsx(M.Icon,{width:16,size:"xs",name:"ArrowPullUp",style:{color:"var(--sa-background-brand, #04254f)"}})})})})},qe="sa-sidepanel-item",Dl="sa-sidepanel-item-styles",cc=`
|
|
58
58
|
.${qe} {
|
|
59
59
|
display: block;
|
|
60
60
|
box-sizing: border-box;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@starasia/admin",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "16.0.0",
|
|
4
4
|
"description": "Core Admin Dashboard for starasia UI",
|
|
5
5
|
"author": "Rizki Izzul Haq",
|
|
6
6
|
"main": "dist/index.umd.js",
|
|
@@ -49,7 +49,7 @@
|
|
|
49
49
|
}
|
|
50
50
|
},
|
|
51
51
|
"dependencies": {
|
|
52
|
-
"@starasia/accordion": "3.2
|
|
52
|
+
"@starasia/accordion": "3.1.2",
|
|
53
53
|
"@starasia/alert": "5.0.2",
|
|
54
54
|
"@starasia/avatar": "1.0.0",
|
|
55
55
|
"@starasia/badges": "4.1.0",
|
|
@@ -60,7 +60,7 @@
|
|
|
60
60
|
"@starasia/checkbox": "5.0.0",
|
|
61
61
|
"@starasia/css": "5.3.0",
|
|
62
62
|
"@starasia/date": "7.0.0",
|
|
63
|
-
"@starasia/dialog": "5.
|
|
63
|
+
"@starasia/dialog": "5.0.0",
|
|
64
64
|
"@starasia/drawer": "3.3.1",
|
|
65
65
|
"@starasia/dropdown": "6.0.0",
|
|
66
66
|
"@starasia/flex": "4.2.0",
|
|
@@ -85,7 +85,7 @@
|
|
|
85
85
|
"@starasia/theme": "3.0.3",
|
|
86
86
|
"@starasia/toast": "4.0.0",
|
|
87
87
|
"@starasia/toggle": "5.0.1",
|
|
88
|
-
"@starasia/tooltip": "4.
|
|
88
|
+
"@starasia/tooltip": "4.0.0",
|
|
89
89
|
"react-easy-crop": "^5.5.6"
|
|
90
90
|
},
|
|
91
91
|
"devDependencies": {
|