@starasia/admin 8.20.0 → 8.20.1
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.
|
@@ -180,8 +180,9 @@ export interface TableLayoutProps<T> {
|
|
|
180
180
|
*/
|
|
181
181
|
onSelectionChange?: (keys: TableLayoutRowKey[], rows: T[]) => void;
|
|
182
182
|
/**
|
|
183
|
-
* Return `false` → baris tidak bisa dipilih: checkbox-nya
|
|
184
|
-
*
|
|
183
|
+
* Return `false` → baris tidak bisa dipilih: checkbox-nya TIDAK dirender
|
|
184
|
+
* (sel tetap ada agar kolom align) dan baris dikecualikan dari hitungan/aksi
|
|
185
|
+
* select-all. Default: semua baris bisa.
|
|
185
186
|
*/
|
|
186
187
|
isRowSelectable?: (row: T, index: number) => boolean;
|
|
187
188
|
/**
|
package/dist/index.cjs.js
CHANGED
|
@@ -43,7 +43,7 @@
|
|
|
43
43
|
box-shadow: 0 4px 12px rgba(0,0,0,0.12);
|
|
44
44
|
padding: 4px 0;
|
|
45
45
|
}
|
|
46
|
-
`,document.head.appendChild(t)},Ft=t=>t==="right"?"right":t==="center"?"center":"left",si=/^(#|rgb|hsl|var\()/,Et=t=>t?si.test(t)?t:`var(--sa-background-${t})`:void 0,ii=(t,r)=>{if(r)return t[r]},li=(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)),ci=({columns:t,data:r,getRowKey:n,rowBg:s,size:o="md",resizable:i=!1,layout:c="auto",widthStorageKey:l,columnState:a,onColumnStateChange:d,columnMenu:h=!1,sort:g,defaultSort:m,onSortChange:j,height:M,mobileLayout:p="cards",mobileBreakpoint:L="md",groupSeparator:S,summary:T,emptyState:w,loading:C=!1,loadingRows:z=8,rowActions:W,selectable:b=!1,selectedKeys:F,defaultSelectedKeys:N,onSelectionChange:A,isRowSelectable:H})=>{oi();const re=!je.useMediaQuery(L)&&p!=="scroll",ne=!!(W!=null&&W.length),[ee,ie]=u.useState(null);u.useEffect(()=>{if(!ee)return;const y=()=>ie(null),v=setTimeout(()=>document.addEventListener("click",y),0);return()=>{clearTimeout(v),document.removeEventListener("click",y)}},[ee]);const[K,Q]=u.useState(()=>new Set),ue=a!==void 0,[ce,xe]=u.useState({}),ge=a??ce,ze=y=>{d==null||d(y),ue||xe(y)},Ae=g!==void 0,[Ve,Ee]=u.useState(m??null),he=Ae?g??null:Ve,Te=!j,_e=y=>{j==null||j(y),Ae||Ee(y)},{headerGroups:Ie,leafColumns:fe,hasGroups:He}=u.useMemo(()=>{var ae;const y=new Set(ge.hidden??[]),v=(le,ye)=>le.key??(typeof le.accessor=="string"?le.accessor:`col-${ye}`),E=t.map((le,ye)=>{var Le;if((Le=le.children)!=null&&Le.length){const xt=le.children.map((Pe,ht)=>({col:Pe,key:v(Pe,`${ye}-${ht}`)})).filter(Pe=>!y.has(Pe.key));return{col:le,key:le.key??`group-${ye}`,isGroup:!0,leaves:xt}}const pe={col:le,key:v(le,`${ye}`)};return{col:le,key:pe.key,isGroup:!1,leaves:y.has(pe.key)?[]:[pe]}}).filter(le=>le.leaves.length>0),J=E.some(le=>le.isGroup);let te=E.flatMap(le=>le.leaves);if(!J&&((ae=ge.order)!=null&&ae.length)){const le=new Map(ge.order.map((ye,pe)=>[ye,pe]));te=[...te].sort((ye,pe)=>(le.get(ye.key)??1/0)-(le.get(pe.key)??1/0))}return{headerGroups:E,leafColumns:te,hasGroups:J}},[t,ge]),k=u.useMemo(()=>new Map(fe.map((y,v)=>[y.key,v])),[fe]),_=!He&&fe.some(y=>(y.col.headerColSpan??1)>1),G=fe.map(y=>y.key).join("|"),I=(y,v)=>{const E=y.sortKey??(typeof y.accessor=="string"?y.accessor:void 0);return E?v[E]:void 0},q=y=>y.sortable??(!!y.sortKey||typeof y.accessor=="string"),R=u.useMemo(()=>{if(!Te||!he)return r;const y=fe.find(E=>E.key===he.key);if(!y)return r;const v=he.direction==="asc"?1:-1;return[...r].sort((E,J)=>li(I(y.col,E),I(y.col,J))*v)},[r,Te,he,fe]),P=!He&&!_,Y=!!l&&P,[ve,Se]=Z.useColumnWidths(l??""),Me=Y?ve:void 0,ke=u.useRef(null),[me,tt]=u.useState();u.useLayoutEffect(()=>{tt(void 0)},[G]),u.useLayoutEffect(()=>{if(!P||me||!ke.current)return;const y=ke.current.querySelectorAll("th.sa-tl-leaf");tt(Array.from(y).map(v=>v.offsetWidth))},[me,P]);const[Xe,Ke]=u.useState(0);u.useLayoutEffect(()=>{if(!He||!ke.current)return;const y=ke.current.querySelector(":scope > tr");y&&Ke(y.offsetHeight)},[He,G]);const qe=(y,v)=>{if((Me==null?void 0:Me[v])!=null)return Me[v];if(y.width!=null)return y.width;if((me==null?void 0:me[v])!=null)return me[v]},bt=(y,v)=>typeof y.width=="number"?y.width:me==null?void 0:me[v],rt=ge.frozenKey&&!He&&!_?fe.findIndex(y=>y.key===ge.frozenKey):-1,nt=y=>y<=rt,Br=b?ft:0,Fr=y=>{if(!me)return Br;let v=Br;for(let E=0;E<y;E++)v+=me[E]??0;return v},qt=u.useRef(null),[io,lo]=u.useState("100vh");u.useLayoutEffect(()=>{if(M!==void 0)return;const y=()=>{if(qt.current){const v=qt.current.getBoundingClientRect().top;lo(`calc(100vh - ${v}px)`)}};return y(),window.addEventListener("resize",y),()=>window.removeEventListener("resize",y)},[M]);const Ge=(y,v)=>n?n(y,v):v,Zt=F!==void 0,[Er,co]=u.useState(()=>new Set(N??[])),Qe=u.useMemo(()=>Zt?new Set(F):Er,[Zt,F,Er]);u.useEffect(()=>{b&&!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).")},[b,!n]);const Mr=y=>{if(Zt||co(y),A){const v=R.filter((E,J)=>y.has(Ge(E,J)));A(Array.from(y),v)}},Gt=(y,v)=>b&&(H?H(y,v):!0),Qt=y=>{const v=new Set(Qe);v.has(y)?v.delete(y):v.add(y),Mr(v)},ot=u.useMemo(()=>b?R.map((y,v)=>({row:y,i:v,key:Ge(y,v)})).filter(({row:y,i:v})=>H?H(y,v):!0).map(({key:y})=>y):[],[b,R,H,n]),Lr=ot.filter(y=>Qe.has(y)),Ut=ot.length>0&&Lr.length===ot.length,Tr=Lr.length>0&&!Ut,ao=()=>{const y=new Set(Qe);Ut?ot.forEach(v=>y.delete(v)):ot.forEach(v=>y.add(v)),Mr(y)},Jt=(y,v,E)=>y.render?y.render(v,E,R):ii(v,y.accessor),Yt=fe.length+(b?1:0)+(ne?1:0),Ir=["80%","55%","70%","45%","90%","60%"],uo=(y,v)=>Ir[(y*7+v*3)%Ir.length],xo=(y,v)=>e.jsx(Oe.Skeleton,{height:14,width:uo(y,v),borderRadius:"rounded-sm"}),ho=Array.from({length:z},(y,v)=>e.jsxs(Z.Tr,{children:[b&&e.jsx(Z.Td,{style:{width:ft,padding:0},children:e.jsx("div",{style:{display:"flex",justifyContent:"center"},children:e.jsx(Oe.Skeleton,{height:14,width:14,borderRadius:"rounded-sm"})})}),fe.map(({col:E,key:J},te)=>e.jsx(Z.Td,{style:{textAlign:Ft(E.align)},children:xo(v,te)},`sa-tl-sk-${v}-${J}`)),ne&&e.jsx(Z.Td,{style:{width:1,padding:0,border:"none"}})]},`sa-tl-sk-${v}`)),fo=(y,v)=>{v||ze({...ge,hidden:[...ge.hidden??[],y]})},mo=y=>ze({...ge,frozenKey:ge.frozenKey===y?void 0:y}),vt=y=>(W??[]).filter(v=>{var E;return!((E=v.hidden)!=null&&E.call(v,y))}),Or={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)"},Ct=(y,v,E,J)=>{var Le;const te=(Le=y.disabled)==null?void 0:Le.call(y,v),ae=(J==null?void 0:J.showLabel)??y.showLabel,le=(J==null?void 0:J.size)??"xs",ye=e.jsx(V.Button,{size:le,variant:y.variant??"tertiary",tone:y.tone??"neutral",disabled:te,onClick:()=>y.onClick(v,E),iconLeft:y.icon?e.jsx(B.Icon,{name:y.icon,size:"sm"}):void 0,children:ae&&y.label}),pe=y.tooltip;return pe?e.jsx(we.Tooltip,{label:pe,position:"top-end",children:ye}):ye},go=(y,v)=>{const E=vt(y);if(!E.length)return null;if(E.length>5){const te=Ge(y,v),ae=(ee==null?void 0:ee.rowKey)===te;return e.jsx("div",{className:"sa-tl-row-actions",style:Or,onClick:le=>le.stopPropagation(),children:e.jsx(we.Tooltip,{label:"Aksi lainnya",position:"top",children:e.jsx(V.Button,{size:"xs",variant:"tertiary",onClick:le=>{const ye=le.currentTarget.getBoundingClientRect();ie(ae?null:{rowKey:te,top:ye.bottom+4,right:window.innerWidth-ye.right})},children:e.jsx(B.Icon,{name:"MenuVertical",size:"sm"})})})})}return e.jsx("div",{className:"sa-tl-row-actions",style:Or,children:E.map(te=>e.jsx(u.Fragment,{children:Ct(te,y,v)},te.key))})},yo=(y,v)=>{const E=vt(y);return E.length?e.jsx("div",{style:{display:"flex",gap:6,flexWrap:"wrap",paddingTop:8,marginTop:8,borderTop:kt},children:E.map(J=>e.jsx(u.Fragment,{children:Ct(J,y,v,{showLabel:!0,size:"sm"})},J.key))}):null},po=(y,v)=>{const E=vt(y);return E.length?e.jsx("div",{style:{display:"flex",gap:4,paddingRight:8,flexShrink:0},children:E.map(J=>e.jsx(u.Fragment,{children:Ct(J,y,v,{showLabel:!1})},J.key))}):null},Xt=(y,v)=>{const{col:E,key:J}=y,te=k.get(J)??0,ae=nt(te),le=ae&&te===rt,ye=(he==null?void 0:he.key)===J?he.direction:null,pe=h&&!E.disableMenu?e.jsx(eo,{active:!!ye||ae,canSort:q(E),canHide:!E.locked,sortDir:ye,frozen:ae,onSort:ht=>_e({key:J,direction:ht}),onClearSort:()=>_e(null),onToggleFreeze:()=>mo(J),onHide:()=>fo(J,E.locked)}):null,Le=E.align==="right",xt=E.align==="right"?"flex-end":E.align==="center"?"center":"flex-start",Pe=e.jsxs("span",{style:{flex:1,minWidth:0,display:"flex",alignItems:"center",gap:6,justifyContent:xt,overflow:"hidden"},children:[E.icon&&e.jsx(B.Icon,{name:E.icon,size:"sm",style:{flexShrink:0}}),e.jsx("span",{style:Bt,children:E.title})]});return e.jsx(Z.Th,{className:`sa-tl-leaf${ae?" sa-tl-frozen":""}`,rowSpan:v==null?void 0:v.rowSpan,colSpan:v==null?void 0:v.colSpan,minWidth:E.minWidth,resizable:P?E.resizable:!1,defaultWidth:bt(E,te),style:{textAlign:Ft(E.align),width:qe(E,te),position:"sticky",top:(v==null?void 0:v.top)??0,left:ae?Fr(te):void 0,zIndex:ae?3:2,backgroundColor:st,boxShadow:le?gn:void 0},children:e.jsx("div",{style:{display:"flex",alignItems:"center",gap:6,width:"100%"},children:Le?e.jsxs(e.Fragment,{children:[pe,Pe]}):e.jsxs(e.Fragment,{children:[Pe,pe]})})},`th-${J}`)},jo=()=>{const y=[];for(let v=0;v<fe.length;){const E=fe[v],J=E.col.headerColSpan??1,te=Math.max(1,Math.min(J,fe.length-v));y.push(Xt(E,te>1?{colSpan:te}:void 0)),v+=te}return y},Wr=y=>e.jsx(Z.Th,{rowSpan:y==null?void 0:y.rowSpan,style:{width:ft,position:"sticky",top:0,left:0,zIndex:4,backgroundColor:st,padding:0},children:e.jsx("div",{style:{display:"flex",alignItems:"center",justifyContent:"center"},onClick:v=>v.stopPropagation(),children:e.jsx(Ze.Checkbox,{size:"sm",variant:Tr?"indeterminate":"select",checked:Ut||Tr,disabled:ot.length===0,onChange:ao,"aria-label":"Pilih semua baris di halaman ini"})})},"th-select"),bo=(y,v,E)=>{const J=Ge(y,v);return e.jsx(Z.Td,{className:"sa-tl-frozen",style:{width:ft,padding:0,position:"sticky",left:0,zIndex:2,...E?{"--sa-tl-bg":E}:{}},children:e.jsx("div",{style:{display:"flex",alignItems:"center",justifyContent:"center"},onClick:te=>te.stopPropagation(),children:e.jsx(Ze.Checkbox,{size:"sm",checked:Qe.has(J),disabled:!Gt(y,v),onChange:()=>Qt(J),"aria-label":"Pilih baris"})})},`tl-select-${v}`)},Kt=fe.filter(y=>!y.col.hideOnMobile),$t=Kt.find(y=>y.col.primary)??Kt[0],vo=Kt.filter(y=>y!==$t),Co=y=>Q(v=>{const E=new Set(v);return E.has(y)?E.delete(y):E.add(y),E}),Rr=(y,v)=>vo.map(({col:E,key:J})=>{const te=Jt(E,y,v),ae=typeof te=="string"||typeof te=="number"?e.jsx(D.Text,{style:{minWidth:0,overflow:"hidden",textOverflow:"ellipsis",textAlign:"right"},children:te}):e.jsx("div",{style:{minWidth:0,overflow:"hidden",textOverflow:"ellipsis",textAlign:"right"},children:te});return e.jsxs("div",{style:{display:"flex",gap:12,justifyContent:"space-between",alignItems:"baseline"},children:[typeof E.title=="string"?e.jsx(D.Text,{color:"subtle",fontWeight:"medium",style:{color:ni,flexShrink:0},children:E.title}):e.jsx("div",{style:{flexShrink:0},children:E.title}),ae]},J)}),er=(y,v)=>{const E=$t?Jt($t.col,y,v):null;return typeof E=="string"||typeof E=="number"?e.jsx(D.Text,{as:"span",style:Bt,children:E}):e.jsx("span",{style:Bt,children:E})},wo=e.jsx(f.Box,{style:{display:"flex",flexDirection:"column",gap:8,padding:8},children:Array.from({length:z},(y,v)=>e.jsxs(f.Box,{style:{border:kt,borderRadius:"var(--sa-radii-sm, 6px)",padding:12,display:"flex",flexDirection:"column",gap:8},children:[e.jsx(Oe.Skeleton,{height:16,width:"60%",borderRadius:"rounded-sm"}),e.jsx(Oe.Skeleton,{height:12,width:"85%",borderRadius:"rounded-sm"}),e.jsx(Oe.Skeleton,{height:12,width:"70%",borderRadius:"rounded-sm"})]},`sa-tl-sk-card-${v}`))}),zr=e.jsx(f.Box,{fullWidth:!0,style:{minHeight:(w==null?void 0:w.minHeight)??320,display:"flex",alignItems:"center",justifyContent:"center",padding:16},children:w==null?void 0:w.content}),Do=C?wo:R.length===0?zr:p==="expand"?e.jsx(f.Box,{style:{display:"flex",flexDirection:"column"},children:R.map((y,v)=>{const E=Ge(y,v),J=K.has(E),ae=b&&Qe.has(E)?ar:Et(s==null?void 0:s(y,v));return e.jsxs("div",{style:{borderBottom:kt,backgroundColor:ae},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center"},children:[b&&e.jsx("div",{style:{display:"flex",alignItems:"center",paddingLeft:12,flexShrink:0},children:e.jsx(Ze.Checkbox,{size:"sm",checked:Qe.has(E),disabled:!Gt(y,v),onChange:()=>Qt(E),"aria-label":"Pilih baris"})}),e.jsxs("button",{type:"button",onClick:()=>Co(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:[er(y,v),e.jsx(B.Icon,{name:J?"ChevronUp":"ChevronDown",size:"sm",style:{flexShrink:0}})]}),ne&&po(y,v)]}),J&&e.jsx("div",{style:{padding:"0 12px 12px",display:"flex",flexDirection:"column",gap:6},children:Rr(y,v)})]},E)})}):e.jsx(f.Box,{style:{display:"flex",flexDirection:"column",gap:8,padding:8},children:R.map((y,v)=>{const E=Ge(y,v),J=b&&Qe.has(E);return e.jsxs(f.Box,{style:{border:kt,borderRadius:"var(--sa-radii-sm, 6px)",padding:12,display:"flex",flexDirection:"column",gap:6,backgroundColor:J?ar:Et(s==null?void 0:s(y,v))},children:[b?e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[e.jsx(Ze.Checkbox,{size:"sm",checked:Qe.has(E),disabled:!Gt(y,v),onChange:()=>Qt(E),"aria-label":"Pilih baris"}),e.jsx("div",{style:{flex:1,minWidth:0},children:er(y,v)})]}):er(y,v),Rr(y,v),ne&&yo(y,v)]},E)})}),So=i&&P&&me!==void 0,Ar=c==="fixed"&&!i&&(P?me!==void 0:!0),ko=Ar&&!P,Bo=e.jsxs(Z.Table,{className:"sa-table-layout",fullWidth:!0,size:o,resizable:So,style:Ar?{tableLayout:"fixed"}:void 0,onWidthsChange:Y?Se:void 0,children:[ko&&e.jsxs("colgroup",{children:[b&&e.jsx("col",{style:{width:ft}}),fe.map(({col:y,key:v},E)=>e.jsx("col",{style:{width:qe(y,E)}},`col-${v}`)),ne&&e.jsx("col",{style:{width:1}})]}),e.jsx(Z.Thead,{ref:ke,children:He?e.jsxs(e.Fragment,{children:[e.jsxs(Z.Tr,{children:[b&&Wr({rowSpan:2}),Ie.map(y=>y.isGroup?e.jsx(Z.Th,{colSpan:y.leaves.length,style:{textAlign:"center",position:"sticky",top:0,zIndex:2,backgroundColor:st},children:e.jsx("span",{style:Bt,children:y.col.title})},`grp-${y.key}`):Xt(y.leaves[0],{rowSpan:2})),ne&&e.jsx(Z.Th,{rowSpan:2,style:{position:"sticky",top:0,right:0,zIndex:3,width:1,padding:0,border:"none",backgroundColor:st}})]}),e.jsx(Z.Tr,{children:Ie.flatMap(y=>y.isGroup?y.leaves.map(v=>Xt(v,{top:Xe})):[])})]}):e.jsxs(Z.Tr,{children:[b&&Wr(),jo(),ne&&e.jsx(Z.Th,{style:{position:"sticky",top:0,right:0,zIndex:3,width:1,padding:0,border:"none",backgroundColor:st}})]})}),e.jsx(Z.Tbody,{children:C?ho:R.length===0?e.jsx(Z.Tr,{children:e.jsx(Z.Td,{colSpan:Yt,children:zr})}):e.jsxs(e.Fragment,{children:[R.map((y,v)=>{const E=S==null?void 0:S(y,v,v>0?R[v-1]:void 0),te=b&&Qe.has(Ge(y,v))?ar:Et(s==null?void 0:s(y,v));return e.jsxs(u.Fragment,{children:[E!=null&&E!==!1&&e.jsx(Z.Tr,{children:e.jsx(Z.Td,{colSpan:Yt,style:{backgroundColor:st},children:E})}),e.jsxs(Z.Tr,{children:[b&&bo(y,v,te),fe.map(({col:ae,key:le},ye)=>{var Hr;const pe=(Hr=ae.cellProps)==null?void 0:Hr.call(ae,y,v,R);if(pe!=null&&pe.hidden)return null;const Le=nt(ye),xt=Le&&ye===rt,Pe=Jt(ae,y,v),ht=typeof ae.bg=="function"?ae.bg(y,v,R):ae.bg,Vr=Et(ht)??te;return e.jsx(Z.Td,{className:Le?"sa-tl-frozen":void 0,colSpan:pe==null?void 0:pe.colSpan,rowSpan:pe==null?void 0:pe.rowSpan,style:{textAlign:Ft(ae.align),width:qe(ae,ye),minWidth:ae.minWidth,position:Le?"sticky":void 0,left:Le?Fr(ye):void 0,zIndex:Le?1:void 0,boxShadow:xt?gn:void 0,...Vr?{"--sa-tl-bg":Vr}:{}},children:typeof Pe=="string"?e.jsx(D.Text,{style:{whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",textAlign:Ft(ae.align)},children:Pe}):Pe},`tl-cell-${v}-${le}`)}),ne&&e.jsx(Z.Td,{style:{position:"sticky",right:0,width:1,padding:0,overflow:"visible",zIndex:2,border:"none"},children:go(y,v)})]})]},Ge(y,v))}),T!=null&&e.jsx(Z.Tr,{children:e.jsx(Z.Td,{colSpan:Yt,children:T})})]})})]}),tr=ee?R.findIndex((y,v)=>Ge(y,v)===ee.rowKey):-1,rr=tr>=0?R[tr]:null;return e.jsxs(e.Fragment,{children:[e.jsx(f.Box,{ref:qt,fullWidth:!0,style:{overflow:"auto",height:M??io},children:re?Do:Bo}),ee&&rr&&e.jsx("div",{className:"sa-tl-kebab-menu",style:{top:ee.top,right:ee.right},onClick:y=>y.stopPropagation(),children:vt(rr).map(y=>e.jsx("div",{style:{padding:"2px 4px"},children:Ct(y,rr,tr,{showLabel:!0,size:"sm"})},y.key))})]})},dr=t=>t==="asc"||t==="desc",ai=(t={})=>{const{sortKeyParam:r="sortBy",sortOrderParam:n="sortOrder",pageKey:s="page",defaultSort:o=null,paramKeys:i,scopeId:c,storage:l=kr}=t,{searchParams:a,setSearchParams:d,searchQueries:h}=Be(),g=a.toString(),m=c?ut.tableSort(c):void 0,j=u.useRef(!1);u.useEffect(()=>{if(j.current||(j.current=!0,!m)||a.has(r)||a.has(n))return;const w=l.get(m);!(w!=null&&w.key)||!dr(w.direction)||d({...Object.fromEntries(a.entries()),[r]:w.key,[n]:w.direction})},[]);const M=u.useMemo(()=>{const w=a.get(r),C=a.get(n);return w&&dr(C)?{key:w,direction:C}:o},[g,r,n,o]);u.useEffect(()=>{if(!m)return;const w=a.get(r),C=a.get(n);w&&dr(C)?l.set(m,{key:w,direction:C}):l.remove(m)},[g,m,r,n,l]);const p=(i==null?void 0:i.sortBy)??"sortBy",L=(i==null?void 0:i.sortOrder)??"sortOrder",S=u.useMemo(()=>M?{[p]:M.key,[L]:M.direction}:{},[M,p,L]),T=u.useCallback(w=>{const C={...h};w?(C[r]=w.key,C[n]=w.direction):(delete C[r],delete C[n]),delete C[s],d(C)},[h,r,n,s,d]);return{sort:M,setSort:T,params:S}},Vt=({of:t,render:r})=>u.Children.toArray(t==null?void 0:t.map((n,s,o)=>r(n,s,o))),se=({condition:t,fallback:r,children:n,loading:s,isLoading:o})=>e.jsx(e.Fragment,{children:o?s:t?n:r}),de=t=>e.jsx(D.Text,{...t,fontFamily:"Poppins",fontSize:t.fontSize||"md",fontWeight:t.fontWeight||"medium",color:t.color||"gray-700",children:t.children}),Ue=t=>e.jsx(D.Text,{color:"red-600",fontSize:"sm",children:t.message}),di=({size:t="md",direction:r="vertical",requiredTitle:n="(Required)",fullWidth:s=!1,...o})=>{var l,a,d;const i=o.hideMessageError||!1,c=r==="horizontal"?t==="sm"?342:t==="lg"?400:342:void 0;return e.jsxs(f.Box,{gap:r==="horizontal"?"spacing-96":"sm",direction:r==="horizontal"?"row":"column",...o.containerProps,children:[o.title&&e.jsx(se,{condition:!!o.inputProps.required,fallback:e.jsxs(f.Box,{direction:"column",customMaxWidth:c,fullWidth:s,children:[e.jsx(de,{children:o.title}),e.jsx(D.Text,{fontSize:t,color:"gray-500",children:o.description})]}),children:e.jsxs(f.Box,{direction:"column",customMaxWidth:c,fullWidth:s,children:[e.jsxs(oe.Flex,{direction:"row",gap:"xs",align:"center",children:[e.jsx(de,{fontSize:t,children:o.title}),e.jsx(de,{color:"error",fontSize:t,children:n}),e.jsx(se,{condition:!!((l=o.tooltip)!=null&&l.label),children:e.jsx(we.Tooltip,{label:(a=o.tooltip)==null?void 0:a.label,arrowPosition:(d=o.tooltip)==null?void 0:d.arrowPosition,...o.tooltip,children:e.jsx(B.Icon,{name:"InfoCircle",size:t==="lg"?"sm":"xs",style:{color:"var(--sa-color-info-500, #00abeb)",marginTop:"6px"}})})})]}),e.jsx(se,{condition:!!o.description,children:e.jsx(D.Text,{fontSize:t,color:"gray-500",children:o.description})})]})}),e.jsxs(f.Box,{direction:"column",gap:"xs",fullWidth:o.inputProps.fullWidth||!1,children:[e.jsx(Ye.Input,{ref:o.inputRef,size:t,...o.inputProps,status:o.errorMessage?"error":"default",fullWidth:!0}),!i&&o.errorMessage&&e.jsx(Ue,{message:o.errorMessage}),o.inputProps.extended&&o.inputProps.extended]})]})},ui=({size:t="md",direction:r="vertical",requiredTitle:n="(Required)",fullWidth:s=!1,...o})=>{var l,a,d;const i=o.hideMessageError||!1,c=r==="horizontal"?t==="sm"?342:t==="lg"?400:342:void 0;return e.jsxs(f.Box,{gap:r==="horizontal"?"spacing-96":"sm",direction:r==="horizontal"?"row":"column",onClick:o.onClickContainer,children:[o.title&&e.jsx(se,{condition:!!o.inputProps.required,fallback:e.jsxs(f.Box,{direction:"column",customMaxWidth:c,fullWidth:s,children:[e.jsx(de,{children:o.title}),e.jsx(D.Text,{fontSize:t,color:"gray-500",children:o.description})]}),children:e.jsxs(f.Box,{direction:"column",customMaxWidth:c,fullWidth:s,children:[e.jsxs(oe.Flex,{direction:"row",gap:"xs",align:"center",children:[e.jsx(de,{fontSize:t,children:o.title}),e.jsx(de,{color:"error",fontSize:t,children:n}),e.jsx(se,{condition:!!((l=o.tooltip)!=null&&l.label),children:e.jsx(we.Tooltip,{label:(a=o.tooltip)==null?void 0:a.label,arrowPosition:(d=o.tooltip)==null?void 0:d.arrowPosition,...o.tooltip,children:e.jsx(B.Icon,{name:"InfoCircle",size:t==="lg"?"sm":"xs",style:{color:"var(--sa-color-info-500, #00abeb)",marginTop:"6px"}})})})]}),e.jsx(se,{condition:!!o.description,children:e.jsx(D.Text,{fontSize:t,color:"gray-500",children:o.description})})]})}),e.jsxs(f.Box,{direction:"column",gap:"xs",fullWidth:o.inputProps.fullWidth||!1,children:[e.jsx(f.Box,{direction:"column",style:{width:o.inputProps.fullWidth?"100%":r==="horizontal"&&o.customWidth?o.customWidth:r==="horizontal"?"343px":""},children:e.jsx(ct.Dropdown,{size:t,...o.inputProps,error:!!o.errorMessage})}),!i&&o.errorMessage&&e.jsx(Ue,{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)",hi=t=>{var l;const[r,n]=u.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)},c=a=>{a.preventDefault(),n(!1)};return e.jsxs(f.Box,{width:"width-full",paddingInline:"md",direction:"row",gap:"sm",align:"center",onClick:t.handleOnClick,onDragOver:s,onDrop:o,onDragEnter:i,onDragLeave:c,paddingBlock:"md",borderRadius:"rounded-md",style:{border:r?"1px solid var(--sa-border-info)":`1px solid ${xi(t.errorMessage,t.status)}`},children:[e.jsx(B.Icon,{name:"Upload",size:"lg",style:{width:30,height:30}}),e.jsxs(oe.Flex,{direction:"column",gap:"xs",children:[e.jsxs(oe.Flex,{direction:"row",gap:"xs",children:[e.jsx(D.Text,{fontWeight:"medium",color:"gray-500",style:{textWrap:"nowrap"},fontSize:t.isDesktop?"md":"sm",children:"Click your upload"}),e.jsx(D.Text,{fontWeight:"medium",style:{textWrap:"nowrap"},fontSize:t.isDesktop?"md":"sm",children:"or Drag & Drop"})]}),e.jsx(D.Text,{fontSize:"sm",color:"gray-500",children:(l=t.fileSupports)==null?void 0:l.map(a=>a.toLocaleUpperCase()).join(", ")})]})]})};function fi(t){return t.split(" ").map(r=>r[0]).join("").slice(0,2).toUpperCase()}const to=t=>{const r={day:"2-digit",month:"short",year:"numeric"};return t.toLocaleDateString("id-ID",r)},mi=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 gi(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 yi=t=>{const r=t.split(" ");let n=r[0].charAt(0);return r.length>1&&(n+=""+r[1].charAt(0)),n.toUpperCase()};function pi(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 ji="sa-admin",Ne=t=>`var(--${ji}-${t})`,bi={base:{borderColor:Ne("base-border-color"),textColor:Ne("base-text-color"),iconColor:Ne("base-icon-color"),placeholderColor:Ne("base-placeholder-color")},document:{bgColor:Ne("document-bg-color")},sidebar:{bgColor:Ne("sidebar-bg-color"),borderColor:Ne("sidebar-border-color"),maxWidth:Ne("sidebar-max-width"),width:Ne("sidebar-width"),collapseWidth:Ne("sidebar-collapse-width"),collapseV2Width:Ne("sidebar-v2-collapse-width")}},vi=24*60*60*1e3,Ci=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))},wi=/^[^\s@]+@[^\s@]+\.[^\s@]+$/,Di=/--+/,Si=/-$/;function ki(t,r){return JSON.stringify(t)!==JSON.stringify(r)}function Bi(t){return/^(?:\+62|62|0)8[1-9][0-9]{7,10}$/.test(t)}function Fi(t){return/^[A-Za-z\s]+$/.test(t)}const Ei=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()},Mi=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()},Li=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()},Ti=t=>wi.test(t);function Ii(t){return!(Di.test(t)||Si.test(t))}const Oi=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()},Wi=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 Ri(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 zi(t){const r=t.split("/");return r[r.length-1]}const Ai=t=>{var r,n;return e.jsxs(f.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(oe.Flex,{direction:"row",align:"center",gap:"sm",style:{flex:1,minWidth:0},children:[e.jsx(B.Icon,{name:"DocumentFilled",size:"lg",style:{color:"var(--sa-icon-brand)",width:30,height:30,flexShrink:0}}),e.jsxs(oe.Flex,{direction:"column",style:{minWidth:0,flex:1},children:[e.jsx(D.Text,{fontWeight:"bold",style:{textOverflow:"ellipsis",whiteSpace:"nowrap",overflow:"hidden"},children:t.defaultFile?zi(t.defaultFile.url):(r=t.fileSelected)==null?void 0:r.name}),t.defaultFile?(t.defaultFile.size||t.defaultFile.date)&&e.jsxs(oe.Flex,{direction:"row",gap:"xs",align:"center",children:[t.defaultFile.size&&e.jsx(D.Text,{fontSize:"sm",fontWeight:"medium",children:t.defaultFile.size}),t.defaultFile.size&&t.defaultFile.date&&e.jsx(B.Icon,{name:"Dot",size:"xs"}),t.defaultFile.date&&e.jsx(D.Text,{fontSize:"sm",fontWeight:"medium",style:{textWrap:"nowrap"},children:t.defaultFile.date})]}):e.jsxs(oe.Flex,{direction:"row",gap:"xs",align:"center",children:[e.jsx(D.Text,{fontSize:"sm",fontWeight:"medium",children:Ri(((n=t.fileSelected)==null?void 0:n.size.toString())||"100000")}),e.jsx(B.Icon,{name:"Dot",size:"xs"}),e.jsx(D.Text,{fontSize:"sm",fontWeight:"medium",style:{textWrap:"nowrap"},children:to(new Date)})]})]})]}),e.jsx(V.Button,{size:"xs",variant:"tertiary",tone:"error",type:"button",onClick:s=>{s.stopPropagation(),t.handleOnDeleteFile()},iconLeft:e.jsx(B.Icon,{name:"Trash1"})})]})},ro=({status:t="default",labelPosition:r="outside-top",...n})=>{var m;const s=u.useRef(null),o=()=>{if(n.defaultFile){window.open(n.defaultFile.url);return}s.current&&s.current.click()},i=je.useMediaQuery("md"),c=t==="error"||typeof n.errorMessage=="string"&&!!n.errorMessage,l=n.label?e.jsxs(oe.Flex,{direction:"row",align:"center",gap:"xs",children:[e.jsx(D.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(D.Text,{style:{fontSize:"12px",fontWeight:400,color:"var(--sa-text-subtlest, #6b6e76)",lineHeight:"18px"},children:n.description}):null,d=e.jsxs(e.Fragment,{children:[n.helperText&&e.jsx(D.Text,{style:{fontSize:"12px",fontWeight:400,color:"var(--sa-text-subtlest, #6b6e76)",lineHeight:"18px"},children:n.helperText}),n.errorText&&t==="error"&&e.jsx(D.Text,{style:{fontSize:"12px",fontWeight:400,color:"var(--sa-text-error, #a4133c)",lineHeight:"18px"},children:n.errorText}),n.errorMessage&&!n.errorText&&e.jsx(D.Text,{style:{fontSize:"12px",fontWeight:400,color:"var(--sa-text-error, #a4133c)",lineHeight:"18px"},children:n.errorMessage})]}),h=e.jsx("input",{type:"file",style:{display:"none"},ref:s,onChange:j=>{var M;return n.handleOnChangeFile(((M=j.target.files)==null?void 0:M.item(0))||null)},accept:(m=n.fileSupportOption)==null?void 0:m.map(j=>"."+(j==null?void 0:j.toLowerCase())).join(", ")}),g=e.jsxs(f.Box,{direction:"column",fullWidth:!0,style:{minHeight:"69px"},borderRadius:"rounded-md",display:"flex",justify:"center",align:"center",cursor:"pointer",gap:"md",...n.containerProps,children:[h,(n.fileSelected||n.defaultFile)&&e.jsx(Ai,{fileSelected:n.fileSelected,defaultFile:n.defaultFile,handleOnDeleteFile:n.handleOnDeleteFile,handleOnClickFile:o}),!n.fileSelected&&!n.defaultFile&&e.jsx(hi,{fileSupports:n.fileSupportOption,isDesktop:i,errorMessage:c?n.errorText||n.errorMessage||" ":void 0,status:c?"error":"default",handleOnClick:o,handleOnFileChange:n.handleOnChangeFile})]});return r==="outside-left"?e.jsxs(oe.Flex,{direction:"row",align:"flex-start",gap:"sm",style:{width:"100%"},children:[e.jsxs(oe.Flex,{direction:"column",gap:"xs",style:{width:"40%",minWidth:"120px",paddingTop:"10px"},children:[l,a]}),e.jsxs(oe.Flex,{direction:"column",gap:"sm",style:{flex:1,minWidth:0},children:[g,d]})]}):e.jsxs(oe.Flex,{direction:"column",gap:"sm",style:{width:"100%"},children:[l,a,g,d]})},Vi=({size:t="md",direction:r="vertical",requiredTitle:n="(Required)",fullWidth:s=!1,...o})=>{var l,a,d;const i=o.hideMessageError||!1,c=r==="horizontal"?t==="sm"?342:t==="lg"?400:342:void 0;return e.jsxs(f.Box,{gap:r==="horizontal"?"spacing-96":"sm",direction:r==="horizontal"?"row":"column",...o.containerProps,children:[o.title&&e.jsx(se,{condition:!!o.inputProps.required,fallback:e.jsxs(f.Box,{direction:"column",customMaxWidth:c,fullWidth:s,children:[e.jsx(de,{children:o.title}),e.jsx(D.Text,{fontSize:t,color:"gray-500",children:o.description})]}),children:e.jsxs(f.Box,{direction:"column",customMaxWidth:c,fullWidth:s,children:[e.jsxs(oe.Flex,{direction:"row",gap:"xs",align:"center",children:[e.jsx(de,{fontSize:t,children:o.title}),e.jsx(de,{color:"error",fontSize:t,children:n}),e.jsx(se,{condition:!!((l=o.tooltip)!=null&&l.label),children:e.jsx(we.Tooltip,{label:(a=o.tooltip)==null?void 0:a.label,arrowPosition:(d=o.tooltip)==null?void 0:d.arrowPosition,...o.tooltip,children:e.jsx(B.Icon,{name:"InfoCircle",size:t==="lg"?"sm":"xs",style:{color:"var(--sa-color-info-500, #00abeb)",marginTop:"6px"}})})})]}),e.jsx(se,{condition:!!o.description,children:e.jsx(D.Text,{fontSize:t,color:"gray-500",children:o.description})})]})}),e.jsxs(oe.Flex,{direction:"column",gap:"xs",children:[e.jsx(ro,{...o.inputProps,status:o.errorMessage?"error":"default"}),!i&&o.errorMessage&&e.jsx(Ue,{message:o.errorMessage})]})]})},Hi=({size:t="md",direction:r="vertical",requiredTitle:n="(Required)",fullWidth:s=!1,required:o=!1,...i})=>{var a,d,h,g;const c=i.hideMessageError||!1,l=r==="horizontal"?t==="sm"?342:t==="lg"?400:342:void 0;return e.jsxs(f.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(se,{condition:!!o,fallback:e.jsxs(f.Box,{direction:"column",customMaxWidth:l,fullWidth:s,children:[e.jsx(de,{children:i.title}),e.jsx(Re.Body3,{props:{color:"gray-500"},children:i.description})]}),children:e.jsxs(f.Box,{direction:"column",customMaxWidth:l,fullWidth:s,children:[e.jsxs(oe.Flex,{direction:"row",gap:"xs",align:"center",children:[e.jsx(de,{fontSize:t,children:i.title}),e.jsx(de,{color:"error",fontSize:t,children:n}),e.jsx(se,{condition:!!((a=i.tooltip)!=null&&a.label),children:e.jsx(we.Tooltip,{label:(d=i.tooltip)==null?void 0:d.label,arrowPosition:(h=i.tooltip)==null?void 0:h.arrowPosition,...i.tooltip,children:e.jsx(B.Icon,{name:"InfoCircle",size:t==="lg"?"sm":"xs",style:{color:"var(--sa-color-info-500, #00abeb)",marginTop:"6px"}})})})]}),e.jsx(se,{condition:!!i.description,children:e.jsx(D.Text,{fontSize:t,color:"gray-500",children:i.description})})]})}),e.jsx(f.Box,{gap:r==="horizontal-inline"?"xl":"md",direction:r==="horizontal-inline"?"row":"column",align:"flex-start",children:e.jsx(Vt,{of:(g=i.checkBoxesList)==null?void 0:g.map(m=>({...m,isChecked:i.checkBoxesAreChecked.includes(m.id)})),render:m=>m.renderBadge?e.jsxs(f.Box,{direction:"row",justify:"space-between",gap:"lg",...i.badgeContainerProps,children:[e.jsx(Ze.Checkbox,{name:m.name,value:m.id,checked:m.isChecked,onChange:j=>i.onChecked(j.target.value,m),label:m.name,description:m.description}),m.renderBadge]}):e.jsx(Ze.Checkbox,{name:m.name,value:m.id,checked:m.isChecked,onChange:j=>i.onChecked(j.target.value,m),label:m.name,description:m.description})})}),!c&&i.errorMessage&&e.jsx(Ue,{message:i.errorMessage})]})},Pi=({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(f.Box,{gap:t==="horizontal-inline"||t==="horizontal-block"?"spacing-96":"sm",direction:t==="horizontal-inline"||t==="horizontal-block"?"row":"column",children:[e.jsx(se,{condition:!!s.description||!!s.title,children:e.jsxs(f.Box,{direction:"column",customMaxWidth:o,fullWidth:n,children:[s.title&&e.jsx(de,{children:s.title}),e.jsx(se,{condition:!!s.description,children:e.jsx(D.Text,{color:"gray-500",children:s.description})})]})}),e.jsx(f.Box,{gap:"sm",direction:t==="horizontal"||t==="horizontal-inline"?"row":"column",align:"flex-start",flexWrap:"wrap",children:e.jsx(Vt,{of:(i=s.radioList)==null?void 0:i.map(c=>({...c,isChecked:s.radioIsChecked===c.id})),render:({value:c,id:l,isChecked:a,subInput:d,label:h,description:g})=>e.jsxs(f.Box,{direction:"column",gap:"xs",customMaxWidth:o,children:[e.jsx(fr.Radio,{id:`${l.toString()}-${c}`,name:s.groupName||h,label:h,value:c,checked:a,onChange:m=>s.onChecked({id:l,label:m.target.name,value:m.target.value}),disabled:s.disableAll},l),g&&e.jsx(D.Text,{color:"gray-500",style:{marginLeft:28},children:g}),d]})})}),s.errorMessage&&e.jsx(Ue,{message:s.errorMessage})]})},Ni=({size:t="md",direction:r="vertical",requiredTitle:n="(Required)",fullWidth:s=!1,...o})=>{var l,a,d;const i=o.hideMessageError||!1,c=r==="horizontal"?t==="sm"?342:t==="lg"?400:342:void 0;return e.jsxs(f.Box,{gap:r==="horizontal"?"spacing-96":"sm",direction:r==="horizontal"?"row":"column",...o.containerProps,children:[o.title&&e.jsx(se,{condition:!!o.inputProps.required,fallback:e.jsxs(f.Box,{direction:"column",customMaxWidth:c,fullWidth:s,children:[e.jsx(de,{children:o.title}),e.jsx(D.Text,{fontSize:t,color:"gray-500",children:o.description})]}),children:e.jsxs(f.Box,{direction:"column",customMaxWidth:c,fullWidth:s,children:[e.jsxs(oe.Flex,{direction:"row",gap:"xs",align:"center",children:[e.jsx(de,{fontSize:t,children:o.title}),e.jsx(de,{color:"error",fontSize:t,children:n}),e.jsx(se,{condition:!!((l=o.tooltip)!=null&&l.label),children:e.jsx(we.Tooltip,{label:(a=o.tooltip)==null?void 0:a.label,arrowPosition:(d=o.tooltip)==null?void 0:d.arrowPosition,...o.tooltip,children:e.jsx(B.Icon,{name:"InfoCircle",size:t==="lg"?"sm":"xs",style:{color:"var(--sa-color-info-500, #00abeb)",marginTop:"6px"}})})})]}),e.jsx(se,{condition:!!o.description,children:e.jsx(D.Text,{fontSize:t,color:"gray-500",children:o.description})})]})}),e.jsxs(oe.Flex,{direction:"column",gap:"xs",children:[e.jsx(hr.Textarea,{ref:o.inputRef,size:t,...o.inputProps,status:o.errorMessage?"error":"default"}),!i&&o.errorMessage&&e.jsx(Ue,{message:o.errorMessage})]})]})},_i=({size:t="md",direction:r="vertical",requiredTitle:n="(Required)",required:s=!1,fullWidth:o=!1,...i})=>{var l,a,d;const c=r==="horizontal"?t==="sm"?342:t==="lg"?400:342:void 0;return e.jsxs(f.Box,{gap:r==="horizontal"?"spacing-96":"sm",direction:r==="horizontal"?"row":"column",...i.containerProps,children:[i.title&&e.jsx(se,{condition:s,fallback:e.jsxs(f.Box,{direction:"column",customMaxWidth:c,fullWidth:o,children:[e.jsx(de,{children:i.title}),e.jsx(D.Text,{fontSize:t,color:"gray-500",children:i.titleDescription})]}),children:e.jsxs(f.Box,{direction:"column",customMaxWidth:c,fullWidth:o,children:[e.jsxs(oe.Flex,{direction:"row",gap:"xs",align:"center",children:[e.jsx(de,{fontSize:t,children:i.title}),e.jsx(de,{color:"error",fontSize:t,children:n}),e.jsx(se,{condition:!!((l=i.tooltip)!=null&&l.label),children:e.jsx(we.Tooltip,{label:(a=i.tooltip)==null?void 0:a.label,arrowPosition:(d=i.tooltip)==null?void 0:d.arrowPosition,...i.tooltip,children:e.jsx(B.Icon,{name:"InfoCircle",size:t==="lg"?"sm":"xs",style:{color:"var(--sa-color-info-500, #00abeb)",marginTop:"6px"}})})})]}),e.jsx(se,{condition:!!i.titleDescription,children:e.jsx(D.Text,{fontSize:t,color:"gray-500",children:i.titleDescription})})]})}),e.jsx(dt.Toggle,{checked:i.checked,onChange:i.onChange,label:i.label,description:i.description}),i.errorMessage&&e.jsx(Ue,{message:i.errorMessage})]})},qi=({variant:t="primary",size:r="md",...n})=>{const s=lt.useColor(),o=c=>{var a,d,h,g,m,j;if(!c)return;const l=n.disabled?"var(--sa-text-disable, #181a198f)":t==="secondary"?"var(--sa-text-subtle, #8c8f97)":t==="secondary-danger"?(d=(a=s==null?void 0:s.computed)==null?void 0:a.red)==null?void 0:d[600]:t==="secondary-primary"?(g=(h=s==null?void 0:s.computed)==null?void 0:h.blue)==null?void 0:g[700]:(j=(m=s==null?void 0:s.computed)==null?void 0:m.gray)==null?void 0:j[50];return e.jsx(B.Icon,{name:c,size:r,style:{color:l}})},i=()=>{var l,a,d,h;if(t!=="secondary-danger"&&t!=="secondary-primary")return n.title;const c={color:n.disabled?"var(--sa-text-disable, #181a198f)":t==="secondary-danger"?(a=(l=s==null?void 0:s.computed)==null?void 0:l.red)==null?void 0:a[600]:(h=(d=s==null?void 0:s.computed)==null?void 0:d.blue)==null?void 0:h[700]};switch(r){case"xs":return e.jsx(Re.Body2,{props:{style:c},children:n.title});case"sm":case"md":return e.jsx(Re.SubH3,{props:{style:c},children:n.title});case"lg":return e.jsx(Re.SubH2,{props:{style:c},children:n.title});default:return n.title}};return e.jsx(V.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()})},Zi=t=>e.jsx(Re.H5,{props:{...t},children:t.title}),Gi=({size:t="md",direction:r="vertical",requiredTitle:n="(Required)",fullWidth:s=!1,...o})=>{var l,a,d;const i=o.hideMessageError||!1,c=r==="horizontal"?t==="sm"?342:t==="lg"?400:342:void 0;return e.jsxs(f.Box,{gap:r==="horizontal"?"spacing-96":"sm",direction:r==="horizontal"?"row":"column",onClick:o.onClickContainer,children:[o.title&&e.jsx(se,{condition:!!o.inputProps.required,fallback:e.jsxs(f.Box,{direction:"column",customMaxWidth:c,fullWidth:s,children:[e.jsx(de,{children:o.title}),e.jsx(D.Text,{fontSize:t,color:"gray-500",children:o.description})]}),children:e.jsxs(f.Box,{direction:"column",customMaxWidth:c,fullWidth:s,children:[e.jsxs(oe.Flex,{direction:"row",gap:"xs",align:"center",children:[e.jsx(de,{fontSize:t,children:o.title}),e.jsx(de,{color:"error",fontSize:t,children:n}),e.jsx(se,{condition:!!((l=o.tooltip)!=null&&l.label),children:e.jsx(we.Tooltip,{label:(a=o.tooltip)==null?void 0:a.label,arrowPosition:(d=o.tooltip)==null?void 0:d.arrowPosition,...o.tooltip,children:e.jsx(B.Icon,{name:"InfoCircle",size:t==="lg"?"sm":"xs",style:{color:"var(--sa-color-info-500, #00abeb)",marginTop:"6px"}})})})]}),e.jsx(se,{condition:!!o.description,children:e.jsx(D.Text,{fontSize:t,color:"gray-500",children:o.description})})]})}),e.jsxs(oe.Flex,{direction:"column",gap:"xs",children:[e.jsx(f.Box,{direction:"column",style:{width:r==="horizontal"&&o.customWidth?o.customWidth:r==="horizontal"?"343px":""},children:e.jsx(et.StarasiaDate,{size:t,...o.inputProps,status:o.errorMessage?"error":void 0})}),!i&&o.errorMessage&&e.jsx(Ue,{message:o.errorMessage})]})]})};async function Qi(t,r){const n=new Image;n.src=t,await new Promise((i,c)=>{n.onload=i,n.onerror=c});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,c)=>{s.toBlob(l=>{if(!l)return c("Canvas is empty");const a=new File([l],"cropped.png",{type:"image/png"});i(a)},"image/png")})}const pn={"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},no=u.forwardRef(({handleUpload:t,urlImage:r,isUploading:n,croppedImage:s,setCroppedImage:o,size:i="96",aspect:c="1:1",containerProps:l,maxFileSize:a=2,onError:d},h)=>{const g=je.useMediaQuery("md"),[m,j]=u.useState(!1),[M,p]=u.useState(null),[L,S]=u.useState(!1),[T,w]=u.useState({x:0,y:0}),[C,z]=u.useState(1),[W,b]=u.useState(null);u.useEffect(()=>{r===null&&o(null)},[r]);const F=u.useCallback((K,Q)=>{b(Q)},[]),N=K=>{var ce;const Q=(ce=K.target.files)==null?void 0:ce[0];if(!Q)return;const ue=new FileReader;ue.onload=()=>{p(ue.result),S(!0)},ue.readAsDataURL(Q)},A=async()=>{if(!(!M||!W))try{const K=await Qi(M,W);if(a&&K.size>a*1024*1024){d==null||d(`Ukuran file maksimal ${a}MB`);return}t==null||t(K);const Q=URL.createObjectURL(K);o(Q,K),S(!1)}catch{d==null||d("Gagal memproses gambar")}},H=u.useRef(null),U=()=>{H.current&&H.current.click()};u.useImperativeHandle(h,()=>({openFileDialog:()=>{var K;(K=H.current)==null||K.click()}}));const re=parseInt(i,10),ne=pn[c];let ee,ie;return ne>=1?(ie=re,ee=re*ne):(ee=re,ie=re/ne),e.jsxs(f.Box,{direction:"column",display:"flex",position:"relative",bg:(l==null?void 0:l.bg)||"gray-200",borderStyle:(l==null?void 0:l.borderStyle)||"border-none",borderColor:(l==null?void 0:l.borderColor)||"gray-200",borderWidth:(l==null?void 0:l.borderWidth)||"border-2",borderRadius:(l==null?void 0:l.borderRadius)||"rounded-md",overflow:"overflow-hidden",align:"center",justify:"center",style:{width:l!=null&&l.fullWidth?"100%":`${ee}px`,height:l!=null&&l.fullWidth?"auto":`${ie}px`,aspectRatio:ne,flexShrink:0},onMouseEnter:()=>j(!0),onMouseLeave:()=>j(!1),children:[s||r?e.jsx("img",{src:s||r||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(B.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(f.Box,{direction:"column",position:"absolute",display:"flex",align:"center",justify:"center",cursor:"pointer",style:{inset:0,backgroundColor:"var(--sa-color-black-alpha-a30, #080f214a)",opacity:m?1:0,transition:"opacity 0.3s ease-in-out"},onClick:U,children:[e.jsx("input",{ref:H,type:"file",accept:"image/*",onChange:N,disabled:n,style:{display:"none"}}),e.jsxs(f.Box,{display:"flex",align:"center",gap:"spacing-2",direction:"row",children:[e.jsx(B.Icon,{name:"Edit3",style:{color:"var(--sa-background-primary, #ffffff)"}}),e.jsx(se,{condition:i.toNumber()>80,children:e.jsx(D.Text,{color:"gray-50",fontSize:i.toNumber()>80?"sm":"md",fontWeight:"medium",children:"Edit Image"})})]})]}),n&&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, #e5e9f640)"},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&&yr.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:()=>S(!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?c==="1:1"?"min(90vw, 480px)":`min(90vw, ${ee*2}px)`:"calc(100vw - 2rem)",display:"flex",flexDirection:"column"},onClick:K=>K.stopPropagation(),children:[e.jsx("div",{style:{position:"relative",width:"100%",height:"20rem",backgroundColor:"var(--sa-color-gray-100)"},children:M&&e.jsx(Fo,{image:M,crop:T,zoom:C,aspect:c?pn[c]:void 0,onCropChange:w,onZoomChange:z,onCropComplete:F,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(V.Button,{size:"sm",secondary:!0,onClick:()=>S(!1),children:"Cancel"}),e.jsx(V.Button,{size:"sm",primary:!0,onClick:A,children:"Crop"})]})]})}),document.body)]})}),Ui=({size:t="md",direction:r="vertical",requiredTitle:n="(Required)",fullWidth:s=!1,required:o=!1,...i})=>{var a,d,h;const c=i.hideMessageError||!1,l=r==="horizontal"?t==="sm"?342:t==="lg"?400:342:void 0;return e.jsxs(f.Box,{gap:r==="horizontal"?"spacing-96":"sm",direction:r==="horizontal"?"row":"column",...i.containerProps,children:[i.title&&e.jsx(se,{condition:!!o,fallback:e.jsxs(f.Box,{direction:"column",customMaxWidth:l,fullWidth:s,children:[e.jsx(de,{children:i.title}),e.jsx(D.Text,{fontSize:t,color:"gray-500",children:i.description})]}),children:e.jsxs(f.Box,{direction:"column",customMaxWidth:l,fullWidth:s,children:[e.jsxs(oe.Flex,{direction:"row",gap:"xs",align:"center",children:[e.jsx(de,{fontSize:t,children:i.title}),e.jsx(de,{color:"error",fontSize:t,children:n}),e.jsx(se,{condition:!!((a=i.tooltip)!=null&&a.label),children:e.jsx(we.Tooltip,{label:(d=i.tooltip)==null?void 0:d.label,arrowPosition:(h=i.tooltip)==null?void 0:h.arrowPosition,...i.tooltip,children:e.jsx(B.Icon,{name:"InfoCircle",size:t==="lg"?"sm":"xs",style:{color:"var(--sa-color-info-500, #00abeb)",marginTop:"6px"}})})})]}),e.jsx(se,{condition:!!i.description,children:e.jsx(D.Text,{fontSize:t,color:"gray-500",children:i.description})})]})}),e.jsxs(oe.Flex,{direction:"column",gap:"xs",children:[e.jsx(no,{...i.inputProps}),!c&&i.errorMessage&&e.jsx(Ue,{message:i.errorMessage})]})]})},Ji=({size:t="md",direction:r="vertical",requiredTitle:n="(Required)",fullWidth:s=!1,...o})=>{var c,l,a;const i=r==="horizontal"?t==="sm"?342:t==="lg"?400:342:void 0;return e.jsxs(f.Box,{gap:r==="horizontal"?"spacing-96":"sm",direction:r==="horizontal"?"row":"column",...o.containerProps,children:[o.title&&e.jsx(se,{condition:!!o.inputProps.required,fallback:e.jsxs(f.Box,{direction:"column",customMaxWidth:i,fullWidth:s,children:[e.jsx(de,{children:o.title}),e.jsx(D.Text,{fontSize:t,color:"gray-500",children:o.description})]}),children:e.jsxs(f.Box,{direction:"column",customMaxWidth:i,fullWidth:s,children:[e.jsxs(oe.Flex,{direction:"row",gap:"xs",align:"center",children:[e.jsx(de,{fontSize:t,children:o.title}),e.jsx(de,{color:"error",fontSize:t,children:n}),e.jsx(se,{condition:!!((c=o.tooltip)!=null&&c.label),children:e.jsx(we.Tooltip,{label:(l=o.tooltip)==null?void 0:l.label,arrowPosition:(a=o.tooltip)==null?void 0:a.arrowPosition,...o.tooltip,children:e.jsx(B.Icon,{name:"InfoCircle",size:t==="lg"?"sm":"xs",style:{color:"var(--sa-color-info-500, #00abeb)",marginTop:"6px"}})})})]}),e.jsx(se,{condition:!!o.description,children:e.jsx(D.Text,{fontSize:t,color:"gray-500",children:o.description})})]})}),o.inputProps.extended&&o.inputProps.extended]})},Yi=({items:t,id:r,handleOnUpdate:n,width:s,toggleShow:o=!0,disabled:i=!1})=>{var h;const[c,l]=u.useState([]);u.useEffect(()=>{t&&l([...t.map(g=>({id:g.id,isActive:g.isActive}))])},[t]);const a=(h=c.find(g=>g.id===r))==null?void 0:h.isActive,d=u.useCallback(()=>{l(g=>g.map(m=>m.id===r?{...m,isActive:!m.isActive}:m)),n&&n(!a)},[r,n,a]);return e.jsx(f.Box,{direction:"row",gap:"md",style:{width:s},children:o&&e.jsx(dt.Toggle,{disabled:i,checked:a,onChange:d,label:a?"Active":"Inactive"})})},Xi={InputText:di,InputDropdown:ui,InputSingleFile:Vi,CheckBoxOptions:Hi,RadioOptions:Pi,InputTextArea:Ni,ToggleForm:_i,ActionButton:qi,FormTitle:Zi,InputDate:Gi,InputImgFile:Ui,Custom:Ji},oo=({customBottom:t})=>{const[r,n]=u.useState(!1),s=()=>{window.scrollY>window.screenY?n(!0):n(!1)},o=()=>{window.scrollTo({top:0,behavior:"smooth"})};return u.useEffect(()=>(window.addEventListener("scroll",s),()=>{window.removeEventListener("scroll",s)}),[]),e.jsx(f.Box,{direction:"column",style:{position:"fixed",bottom:0,right:0},children:e.jsx(f.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(V.Button,{secondary:!0,size:"xs",onClick:o,type:"button",iconLeft:e.jsx(B.Icon,{width:16,size:"xs",name:"ArrowPullUp",style:{color:"var(--sa-background-brand, #04254f)"}})})})})},Fe="sa-sidepanel-item",jn="sa-sidepanel-item-styles",Ki="inset 3.5px 0 0 0 var(--sa-border-focused, #1a4fa0)",$i="inset -3.5px 0 0 0 var(--sa-border-focused, #1a4fa0)",el=`
|
|
46
|
+
`,document.head.appendChild(t)},Ft=t=>t==="right"?"right":t==="center"?"center":"left",si=/^(#|rgb|hsl|var\()/,Et=t=>t?si.test(t)?t:`var(--sa-background-${t})`:void 0,ii=(t,r)=>{if(r)return t[r]},li=(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)),ci=({columns:t,data:r,getRowKey:n,rowBg:s,size:o="md",resizable:i=!1,layout:c="auto",widthStorageKey:l,columnState:a,onColumnStateChange:d,columnMenu:h=!1,sort:g,defaultSort:m,onSortChange:j,height:M,mobileLayout:p="cards",mobileBreakpoint:L="md",groupSeparator:S,summary:T,emptyState:w,loading:C=!1,loadingRows:z=8,rowActions:W,selectable:b=!1,selectedKeys:F,defaultSelectedKeys:N,onSelectionChange:A,isRowSelectable:H})=>{oi();const re=!je.useMediaQuery(L)&&p!=="scroll",ne=!!(W!=null&&W.length),[ee,ie]=u.useState(null);u.useEffect(()=>{if(!ee)return;const y=()=>ie(null),v=setTimeout(()=>document.addEventListener("click",y),0);return()=>{clearTimeout(v),document.removeEventListener("click",y)}},[ee]);const[K,Q]=u.useState(()=>new Set),ue=a!==void 0,[ce,xe]=u.useState({}),ge=a??ce,ze=y=>{d==null||d(y),ue||xe(y)},Ae=g!==void 0,[Ve,Ee]=u.useState(m??null),he=Ae?g??null:Ve,Te=!j,_e=y=>{j==null||j(y),Ae||Ee(y)},{headerGroups:Ie,leafColumns:fe,hasGroups:He}=u.useMemo(()=>{var ae;const y=new Set(ge.hidden??[]),v=(le,ye)=>le.key??(typeof le.accessor=="string"?le.accessor:`col-${ye}`),E=t.map((le,ye)=>{var Le;if((Le=le.children)!=null&&Le.length){const xt=le.children.map((Pe,ht)=>({col:Pe,key:v(Pe,`${ye}-${ht}`)})).filter(Pe=>!y.has(Pe.key));return{col:le,key:le.key??`group-${ye}`,isGroup:!0,leaves:xt}}const pe={col:le,key:v(le,`${ye}`)};return{col:le,key:pe.key,isGroup:!1,leaves:y.has(pe.key)?[]:[pe]}}).filter(le=>le.leaves.length>0),J=E.some(le=>le.isGroup);let te=E.flatMap(le=>le.leaves);if(!J&&((ae=ge.order)!=null&&ae.length)){const le=new Map(ge.order.map((ye,pe)=>[ye,pe]));te=[...te].sort((ye,pe)=>(le.get(ye.key)??1/0)-(le.get(pe.key)??1/0))}return{headerGroups:E,leafColumns:te,hasGroups:J}},[t,ge]),k=u.useMemo(()=>new Map(fe.map((y,v)=>[y.key,v])),[fe]),_=!He&&fe.some(y=>(y.col.headerColSpan??1)>1),G=fe.map(y=>y.key).join("|"),I=(y,v)=>{const E=y.sortKey??(typeof y.accessor=="string"?y.accessor:void 0);return E?v[E]:void 0},q=y=>y.sortable??(!!y.sortKey||typeof y.accessor=="string"),R=u.useMemo(()=>{if(!Te||!he)return r;const y=fe.find(E=>E.key===he.key);if(!y)return r;const v=he.direction==="asc"?1:-1;return[...r].sort((E,J)=>li(I(y.col,E),I(y.col,J))*v)},[r,Te,he,fe]),P=!He&&!_,Y=!!l&&P,[ve,Se]=Z.useColumnWidths(l??""),Me=Y?ve:void 0,ke=u.useRef(null),[me,tt]=u.useState();u.useLayoutEffect(()=>{tt(void 0)},[G]),u.useLayoutEffect(()=>{if(!P||me||!ke.current)return;const y=ke.current.querySelectorAll("th.sa-tl-leaf");tt(Array.from(y).map(v=>v.offsetWidth))},[me,P]);const[Xe,Ke]=u.useState(0);u.useLayoutEffect(()=>{if(!He||!ke.current)return;const y=ke.current.querySelector(":scope > tr");y&&Ke(y.offsetHeight)},[He,G]);const qe=(y,v)=>{if((Me==null?void 0:Me[v])!=null)return Me[v];if(y.width!=null)return y.width;if((me==null?void 0:me[v])!=null)return me[v]},bt=(y,v)=>typeof y.width=="number"?y.width:me==null?void 0:me[v],rt=ge.frozenKey&&!He&&!_?fe.findIndex(y=>y.key===ge.frozenKey):-1,nt=y=>y<=rt,Br=b?ft:0,Fr=y=>{if(!me)return Br;let v=Br;for(let E=0;E<y;E++)v+=me[E]??0;return v},qt=u.useRef(null),[io,lo]=u.useState("100vh");u.useLayoutEffect(()=>{if(M!==void 0)return;const y=()=>{if(qt.current){const v=qt.current.getBoundingClientRect().top;lo(`calc(100vh - ${v}px)`)}};return y(),window.addEventListener("resize",y),()=>window.removeEventListener("resize",y)},[M]);const Ge=(y,v)=>n?n(y,v):v,Zt=F!==void 0,[Er,co]=u.useState(()=>new Set(N??[])),Qe=u.useMemo(()=>Zt?new Set(F):Er,[Zt,F,Er]);u.useEffect(()=>{b&&!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).")},[b,!n]);const Mr=y=>{if(Zt||co(y),A){const v=R.filter((E,J)=>y.has(Ge(E,J)));A(Array.from(y),v)}},Gt=(y,v)=>b&&(H?H(y,v):!0),Qt=y=>{const v=new Set(Qe);v.has(y)?v.delete(y):v.add(y),Mr(v)},ot=u.useMemo(()=>b?R.map((y,v)=>({row:y,i:v,key:Ge(y,v)})).filter(({row:y,i:v})=>H?H(y,v):!0).map(({key:y})=>y):[],[b,R,H,n]),Lr=ot.filter(y=>Qe.has(y)),Ut=ot.length>0&&Lr.length===ot.length,Tr=Lr.length>0&&!Ut,ao=()=>{const y=new Set(Qe);Ut?ot.forEach(v=>y.delete(v)):ot.forEach(v=>y.add(v)),Mr(y)},Jt=(y,v,E)=>y.render?y.render(v,E,R):ii(v,y.accessor),Yt=fe.length+(b?1:0)+(ne?1:0),Ir=["80%","55%","70%","45%","90%","60%"],uo=(y,v)=>Ir[(y*7+v*3)%Ir.length],xo=(y,v)=>e.jsx(Oe.Skeleton,{height:14,width:uo(y,v),borderRadius:"rounded-sm"}),ho=Array.from({length:z},(y,v)=>e.jsxs(Z.Tr,{children:[b&&e.jsx(Z.Td,{style:{width:ft,padding:0},children:e.jsx("div",{style:{display:"flex",justifyContent:"center"},children:e.jsx(Oe.Skeleton,{height:14,width:14,borderRadius:"rounded-sm"})})}),fe.map(({col:E,key:J},te)=>e.jsx(Z.Td,{style:{textAlign:Ft(E.align)},children:xo(v,te)},`sa-tl-sk-${v}-${J}`)),ne&&e.jsx(Z.Td,{style:{width:1,padding:0,border:"none"}})]},`sa-tl-sk-${v}`)),fo=(y,v)=>{v||ze({...ge,hidden:[...ge.hidden??[],y]})},mo=y=>ze({...ge,frozenKey:ge.frozenKey===y?void 0:y}),vt=y=>(W??[]).filter(v=>{var E;return!((E=v.hidden)!=null&&E.call(v,y))}),Or={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)"},Ct=(y,v,E,J)=>{var Le;const te=(Le=y.disabled)==null?void 0:Le.call(y,v),ae=(J==null?void 0:J.showLabel)??y.showLabel,le=(J==null?void 0:J.size)??"xs",ye=e.jsx(V.Button,{size:le,variant:y.variant??"tertiary",tone:y.tone??"neutral",disabled:te,onClick:()=>y.onClick(v,E),iconLeft:y.icon?e.jsx(B.Icon,{name:y.icon,size:"sm"}):void 0,children:ae&&y.label}),pe=y.tooltip;return pe?e.jsx(we.Tooltip,{label:pe,position:"top-end",children:ye}):ye},go=(y,v)=>{const E=vt(y);if(!E.length)return null;if(E.length>5){const te=Ge(y,v),ae=(ee==null?void 0:ee.rowKey)===te;return e.jsx("div",{className:"sa-tl-row-actions",style:Or,onClick:le=>le.stopPropagation(),children:e.jsx(we.Tooltip,{label:"Aksi lainnya",position:"top",children:e.jsx(V.Button,{size:"xs",variant:"tertiary",onClick:le=>{const ye=le.currentTarget.getBoundingClientRect();ie(ae?null:{rowKey:te,top:ye.bottom+4,right:window.innerWidth-ye.right})},children:e.jsx(B.Icon,{name:"MenuVertical",size:"sm"})})})})}return e.jsx("div",{className:"sa-tl-row-actions",style:Or,children:E.map(te=>e.jsx(u.Fragment,{children:Ct(te,y,v)},te.key))})},yo=(y,v)=>{const E=vt(y);return E.length?e.jsx("div",{style:{display:"flex",gap:6,flexWrap:"wrap",paddingTop:8,marginTop:8,borderTop:kt},children:E.map(J=>e.jsx(u.Fragment,{children:Ct(J,y,v,{showLabel:!0,size:"sm"})},J.key))}):null},po=(y,v)=>{const E=vt(y);return E.length?e.jsx("div",{style:{display:"flex",gap:4,paddingRight:8,flexShrink:0},children:E.map(J=>e.jsx(u.Fragment,{children:Ct(J,y,v,{showLabel:!1})},J.key))}):null},Xt=(y,v)=>{const{col:E,key:J}=y,te=k.get(J)??0,ae=nt(te),le=ae&&te===rt,ye=(he==null?void 0:he.key)===J?he.direction:null,pe=h&&!E.disableMenu?e.jsx(eo,{active:!!ye||ae,canSort:q(E),canHide:!E.locked,sortDir:ye,frozen:ae,onSort:ht=>_e({key:J,direction:ht}),onClearSort:()=>_e(null),onToggleFreeze:()=>mo(J),onHide:()=>fo(J,E.locked)}):null,Le=E.align==="right",xt=E.align==="right"?"flex-end":E.align==="center"?"center":"flex-start",Pe=e.jsxs("span",{style:{flex:1,minWidth:0,display:"flex",alignItems:"center",gap:6,justifyContent:xt,overflow:"hidden"},children:[E.icon&&e.jsx(B.Icon,{name:E.icon,size:"sm",style:{flexShrink:0}}),e.jsx("span",{style:Bt,children:E.title})]});return e.jsx(Z.Th,{className:`sa-tl-leaf${ae?" sa-tl-frozen":""}`,rowSpan:v==null?void 0:v.rowSpan,colSpan:v==null?void 0:v.colSpan,minWidth:E.minWidth,resizable:P?E.resizable:!1,defaultWidth:bt(E,te),style:{textAlign:Ft(E.align),width:qe(E,te),position:"sticky",top:(v==null?void 0:v.top)??0,left:ae?Fr(te):void 0,zIndex:ae?3:2,backgroundColor:st,boxShadow:le?gn:void 0},children:e.jsx("div",{style:{display:"flex",alignItems:"center",gap:6,width:"100%"},children:Le?e.jsxs(e.Fragment,{children:[pe,Pe]}):e.jsxs(e.Fragment,{children:[Pe,pe]})})},`th-${J}`)},jo=()=>{const y=[];for(let v=0;v<fe.length;){const E=fe[v],J=E.col.headerColSpan??1,te=Math.max(1,Math.min(J,fe.length-v));y.push(Xt(E,te>1?{colSpan:te}:void 0)),v+=te}return y},Wr=y=>e.jsx(Z.Th,{rowSpan:y==null?void 0:y.rowSpan,style:{width:ft,position:"sticky",top:0,left:0,zIndex:4,backgroundColor:st,padding:0},children:e.jsx("div",{style:{display:"flex",alignItems:"center",justifyContent:"center"},onClick:v=>v.stopPropagation(),children:e.jsx(Ze.Checkbox,{size:"sm",variant:Tr?"indeterminate":"select",checked:Ut||Tr,disabled:ot.length===0,onChange:ao,"aria-label":"Pilih semua baris di halaman ini"})})},"th-select"),bo=(y,v,E)=>{const J=Ge(y,v);return e.jsx(Z.Td,{className:"sa-tl-frozen",style:{width:ft,padding:0,position:"sticky",left:0,zIndex:2,...E?{"--sa-tl-bg":E}:{}},children:Gt(y,v)&&e.jsx("div",{style:{display:"flex",alignItems:"center",justifyContent:"center"},onClick:te=>te.stopPropagation(),children:e.jsx(Ze.Checkbox,{size:"sm",checked:Qe.has(J),onChange:()=>Qt(J),"aria-label":"Pilih baris"})})},`tl-select-${v}`)},Kt=fe.filter(y=>!y.col.hideOnMobile),$t=Kt.find(y=>y.col.primary)??Kt[0],vo=Kt.filter(y=>y!==$t),Co=y=>Q(v=>{const E=new Set(v);return E.has(y)?E.delete(y):E.add(y),E}),Rr=(y,v)=>vo.map(({col:E,key:J})=>{const te=Jt(E,y,v),ae=typeof te=="string"||typeof te=="number"?e.jsx(D.Text,{style:{minWidth:0,overflow:"hidden",textOverflow:"ellipsis",textAlign:"right"},children:te}):e.jsx("div",{style:{minWidth:0,overflow:"hidden",textOverflow:"ellipsis",textAlign:"right"},children:te});return e.jsxs("div",{style:{display:"flex",gap:12,justifyContent:"space-between",alignItems:"baseline"},children:[typeof E.title=="string"?e.jsx(D.Text,{color:"subtle",fontWeight:"medium",style:{color:ni,flexShrink:0},children:E.title}):e.jsx("div",{style:{flexShrink:0},children:E.title}),ae]},J)}),er=(y,v)=>{const E=$t?Jt($t.col,y,v):null;return typeof E=="string"||typeof E=="number"?e.jsx(D.Text,{as:"span",style:Bt,children:E}):e.jsx("span",{style:Bt,children:E})},wo=e.jsx(f.Box,{style:{display:"flex",flexDirection:"column",gap:8,padding:8},children:Array.from({length:z},(y,v)=>e.jsxs(f.Box,{style:{border:kt,borderRadius:"var(--sa-radii-sm, 6px)",padding:12,display:"flex",flexDirection:"column",gap:8},children:[e.jsx(Oe.Skeleton,{height:16,width:"60%",borderRadius:"rounded-sm"}),e.jsx(Oe.Skeleton,{height:12,width:"85%",borderRadius:"rounded-sm"}),e.jsx(Oe.Skeleton,{height:12,width:"70%",borderRadius:"rounded-sm"})]},`sa-tl-sk-card-${v}`))}),zr=e.jsx(f.Box,{fullWidth:!0,style:{minHeight:(w==null?void 0:w.minHeight)??320,display:"flex",alignItems:"center",justifyContent:"center",padding:16},children:w==null?void 0:w.content}),Do=C?wo:R.length===0?zr:p==="expand"?e.jsx(f.Box,{style:{display:"flex",flexDirection:"column"},children:R.map((y,v)=>{const E=Ge(y,v),J=K.has(E),ae=b&&Qe.has(E)?ar:Et(s==null?void 0:s(y,v));return e.jsxs("div",{style:{borderBottom:kt,backgroundColor:ae},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center"},children:[Gt(y,v)&&e.jsx("div",{style:{display:"flex",alignItems:"center",paddingLeft:12,flexShrink:0},children:e.jsx(Ze.Checkbox,{size:"sm",checked:Qe.has(E),onChange:()=>Qt(E),"aria-label":"Pilih baris"})}),e.jsxs("button",{type:"button",onClick:()=>Co(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:[er(y,v),e.jsx(B.Icon,{name:J?"ChevronUp":"ChevronDown",size:"sm",style:{flexShrink:0}})]}),ne&&po(y,v)]}),J&&e.jsx("div",{style:{padding:"0 12px 12px",display:"flex",flexDirection:"column",gap:6},children:Rr(y,v)})]},E)})}):e.jsx(f.Box,{style:{display:"flex",flexDirection:"column",gap:8,padding:8},children:R.map((y,v)=>{const E=Ge(y,v),J=b&&Qe.has(E);return e.jsxs(f.Box,{style:{border:kt,borderRadius:"var(--sa-radii-sm, 6px)",padding:12,display:"flex",flexDirection:"column",gap:6,backgroundColor:J?ar:Et(s==null?void 0:s(y,v))},children:[Gt(y,v)?e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[e.jsx(Ze.Checkbox,{size:"sm",checked:Qe.has(E),onChange:()=>Qt(E),"aria-label":"Pilih baris"}),e.jsx("div",{style:{flex:1,minWidth:0},children:er(y,v)})]}):er(y,v),Rr(y,v),ne&&yo(y,v)]},E)})}),So=i&&P&&me!==void 0,Ar=c==="fixed"&&!i&&(P?me!==void 0:!0),ko=Ar&&!P,Bo=e.jsxs(Z.Table,{className:"sa-table-layout",fullWidth:!0,size:o,resizable:So,style:Ar?{tableLayout:"fixed"}:void 0,onWidthsChange:Y?Se:void 0,children:[ko&&e.jsxs("colgroup",{children:[b&&e.jsx("col",{style:{width:ft}}),fe.map(({col:y,key:v},E)=>e.jsx("col",{style:{width:qe(y,E)}},`col-${v}`)),ne&&e.jsx("col",{style:{width:1}})]}),e.jsx(Z.Thead,{ref:ke,children:He?e.jsxs(e.Fragment,{children:[e.jsxs(Z.Tr,{children:[b&&Wr({rowSpan:2}),Ie.map(y=>y.isGroup?e.jsx(Z.Th,{colSpan:y.leaves.length,style:{textAlign:"center",position:"sticky",top:0,zIndex:2,backgroundColor:st},children:e.jsx("span",{style:Bt,children:y.col.title})},`grp-${y.key}`):Xt(y.leaves[0],{rowSpan:2})),ne&&e.jsx(Z.Th,{rowSpan:2,style:{position:"sticky",top:0,right:0,zIndex:3,width:1,padding:0,border:"none",backgroundColor:st}})]}),e.jsx(Z.Tr,{children:Ie.flatMap(y=>y.isGroup?y.leaves.map(v=>Xt(v,{top:Xe})):[])})]}):e.jsxs(Z.Tr,{children:[b&&Wr(),jo(),ne&&e.jsx(Z.Th,{style:{position:"sticky",top:0,right:0,zIndex:3,width:1,padding:0,border:"none",backgroundColor:st}})]})}),e.jsx(Z.Tbody,{children:C?ho:R.length===0?e.jsx(Z.Tr,{children:e.jsx(Z.Td,{colSpan:Yt,children:zr})}):e.jsxs(e.Fragment,{children:[R.map((y,v)=>{const E=S==null?void 0:S(y,v,v>0?R[v-1]:void 0),te=b&&Qe.has(Ge(y,v))?ar:Et(s==null?void 0:s(y,v));return e.jsxs(u.Fragment,{children:[E!=null&&E!==!1&&e.jsx(Z.Tr,{children:e.jsx(Z.Td,{colSpan:Yt,style:{backgroundColor:st},children:E})}),e.jsxs(Z.Tr,{children:[b&&bo(y,v,te),fe.map(({col:ae,key:le},ye)=>{var Hr;const pe=(Hr=ae.cellProps)==null?void 0:Hr.call(ae,y,v,R);if(pe!=null&&pe.hidden)return null;const Le=nt(ye),xt=Le&&ye===rt,Pe=Jt(ae,y,v),ht=typeof ae.bg=="function"?ae.bg(y,v,R):ae.bg,Vr=Et(ht)??te;return e.jsx(Z.Td,{className:Le?"sa-tl-frozen":void 0,colSpan:pe==null?void 0:pe.colSpan,rowSpan:pe==null?void 0:pe.rowSpan,style:{textAlign:Ft(ae.align),width:qe(ae,ye),minWidth:ae.minWidth,position:Le?"sticky":void 0,left:Le?Fr(ye):void 0,zIndex:Le?1:void 0,boxShadow:xt?gn:void 0,...Vr?{"--sa-tl-bg":Vr}:{}},children:typeof Pe=="string"?e.jsx(D.Text,{style:{whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",textAlign:Ft(ae.align)},children:Pe}):Pe},`tl-cell-${v}-${le}`)}),ne&&e.jsx(Z.Td,{style:{position:"sticky",right:0,width:1,padding:0,overflow:"visible",zIndex:2,border:"none"},children:go(y,v)})]})]},Ge(y,v))}),T!=null&&e.jsx(Z.Tr,{children:e.jsx(Z.Td,{colSpan:Yt,children:T})})]})})]}),tr=ee?R.findIndex((y,v)=>Ge(y,v)===ee.rowKey):-1,rr=tr>=0?R[tr]:null;return e.jsxs(e.Fragment,{children:[e.jsx(f.Box,{ref:qt,fullWidth:!0,style:{overflow:"auto",height:M??io},children:re?Do:Bo}),ee&&rr&&e.jsx("div",{className:"sa-tl-kebab-menu",style:{top:ee.top,right:ee.right},onClick:y=>y.stopPropagation(),children:vt(rr).map(y=>e.jsx("div",{style:{padding:"2px 4px"},children:Ct(y,rr,tr,{showLabel:!0,size:"sm"})},y.key))})]})},dr=t=>t==="asc"||t==="desc",ai=(t={})=>{const{sortKeyParam:r="sortBy",sortOrderParam:n="sortOrder",pageKey:s="page",defaultSort:o=null,paramKeys:i,scopeId:c,storage:l=kr}=t,{searchParams:a,setSearchParams:d,searchQueries:h}=Be(),g=a.toString(),m=c?ut.tableSort(c):void 0,j=u.useRef(!1);u.useEffect(()=>{if(j.current||(j.current=!0,!m)||a.has(r)||a.has(n))return;const w=l.get(m);!(w!=null&&w.key)||!dr(w.direction)||d({...Object.fromEntries(a.entries()),[r]:w.key,[n]:w.direction})},[]);const M=u.useMemo(()=>{const w=a.get(r),C=a.get(n);return w&&dr(C)?{key:w,direction:C}:o},[g,r,n,o]);u.useEffect(()=>{if(!m)return;const w=a.get(r),C=a.get(n);w&&dr(C)?l.set(m,{key:w,direction:C}):l.remove(m)},[g,m,r,n,l]);const p=(i==null?void 0:i.sortBy)??"sortBy",L=(i==null?void 0:i.sortOrder)??"sortOrder",S=u.useMemo(()=>M?{[p]:M.key,[L]:M.direction}:{},[M,p,L]),T=u.useCallback(w=>{const C={...h};w?(C[r]=w.key,C[n]=w.direction):(delete C[r],delete C[n]),delete C[s],d(C)},[h,r,n,s,d]);return{sort:M,setSort:T,params:S}},Vt=({of:t,render:r})=>u.Children.toArray(t==null?void 0:t.map((n,s,o)=>r(n,s,o))),se=({condition:t,fallback:r,children:n,loading:s,isLoading:o})=>e.jsx(e.Fragment,{children:o?s:t?n:r}),de=t=>e.jsx(D.Text,{...t,fontFamily:"Poppins",fontSize:t.fontSize||"md",fontWeight:t.fontWeight||"medium",color:t.color||"gray-700",children:t.children}),Ue=t=>e.jsx(D.Text,{color:"red-600",fontSize:"sm",children:t.message}),di=({size:t="md",direction:r="vertical",requiredTitle:n="(Required)",fullWidth:s=!1,...o})=>{var l,a,d;const i=o.hideMessageError||!1,c=r==="horizontal"?t==="sm"?342:t==="lg"?400:342:void 0;return e.jsxs(f.Box,{gap:r==="horizontal"?"spacing-96":"sm",direction:r==="horizontal"?"row":"column",...o.containerProps,children:[o.title&&e.jsx(se,{condition:!!o.inputProps.required,fallback:e.jsxs(f.Box,{direction:"column",customMaxWidth:c,fullWidth:s,children:[e.jsx(de,{children:o.title}),e.jsx(D.Text,{fontSize:t,color:"gray-500",children:o.description})]}),children:e.jsxs(f.Box,{direction:"column",customMaxWidth:c,fullWidth:s,children:[e.jsxs(oe.Flex,{direction:"row",gap:"xs",align:"center",children:[e.jsx(de,{fontSize:t,children:o.title}),e.jsx(de,{color:"error",fontSize:t,children:n}),e.jsx(se,{condition:!!((l=o.tooltip)!=null&&l.label),children:e.jsx(we.Tooltip,{label:(a=o.tooltip)==null?void 0:a.label,arrowPosition:(d=o.tooltip)==null?void 0:d.arrowPosition,...o.tooltip,children:e.jsx(B.Icon,{name:"InfoCircle",size:t==="lg"?"sm":"xs",style:{color:"var(--sa-color-info-500, #00abeb)",marginTop:"6px"}})})})]}),e.jsx(se,{condition:!!o.description,children:e.jsx(D.Text,{fontSize:t,color:"gray-500",children:o.description})})]})}),e.jsxs(f.Box,{direction:"column",gap:"xs",fullWidth:o.inputProps.fullWidth||!1,children:[e.jsx(Ye.Input,{ref:o.inputRef,size:t,...o.inputProps,status:o.errorMessage?"error":"default",fullWidth:!0}),!i&&o.errorMessage&&e.jsx(Ue,{message:o.errorMessage}),o.inputProps.extended&&o.inputProps.extended]})]})},ui=({size:t="md",direction:r="vertical",requiredTitle:n="(Required)",fullWidth:s=!1,...o})=>{var l,a,d;const i=o.hideMessageError||!1,c=r==="horizontal"?t==="sm"?342:t==="lg"?400:342:void 0;return e.jsxs(f.Box,{gap:r==="horizontal"?"spacing-96":"sm",direction:r==="horizontal"?"row":"column",onClick:o.onClickContainer,children:[o.title&&e.jsx(se,{condition:!!o.inputProps.required,fallback:e.jsxs(f.Box,{direction:"column",customMaxWidth:c,fullWidth:s,children:[e.jsx(de,{children:o.title}),e.jsx(D.Text,{fontSize:t,color:"gray-500",children:o.description})]}),children:e.jsxs(f.Box,{direction:"column",customMaxWidth:c,fullWidth:s,children:[e.jsxs(oe.Flex,{direction:"row",gap:"xs",align:"center",children:[e.jsx(de,{fontSize:t,children:o.title}),e.jsx(de,{color:"error",fontSize:t,children:n}),e.jsx(se,{condition:!!((l=o.tooltip)!=null&&l.label),children:e.jsx(we.Tooltip,{label:(a=o.tooltip)==null?void 0:a.label,arrowPosition:(d=o.tooltip)==null?void 0:d.arrowPosition,...o.tooltip,children:e.jsx(B.Icon,{name:"InfoCircle",size:t==="lg"?"sm":"xs",style:{color:"var(--sa-color-info-500, #00abeb)",marginTop:"6px"}})})})]}),e.jsx(se,{condition:!!o.description,children:e.jsx(D.Text,{fontSize:t,color:"gray-500",children:o.description})})]})}),e.jsxs(f.Box,{direction:"column",gap:"xs",fullWidth:o.inputProps.fullWidth||!1,children:[e.jsx(f.Box,{direction:"column",style:{width:o.inputProps.fullWidth?"100%":r==="horizontal"&&o.customWidth?o.customWidth:r==="horizontal"?"343px":""},children:e.jsx(ct.Dropdown,{size:t,...o.inputProps,error:!!o.errorMessage})}),!i&&o.errorMessage&&e.jsx(Ue,{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)",hi=t=>{var l;const[r,n]=u.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)},c=a=>{a.preventDefault(),n(!1)};return e.jsxs(f.Box,{width:"width-full",paddingInline:"md",direction:"row",gap:"sm",align:"center",onClick:t.handleOnClick,onDragOver:s,onDrop:o,onDragEnter:i,onDragLeave:c,paddingBlock:"md",borderRadius:"rounded-md",style:{border:r?"1px solid var(--sa-border-info)":`1px solid ${xi(t.errorMessage,t.status)}`},children:[e.jsx(B.Icon,{name:"Upload",size:"lg",style:{width:30,height:30}}),e.jsxs(oe.Flex,{direction:"column",gap:"xs",children:[e.jsxs(oe.Flex,{direction:"row",gap:"xs",children:[e.jsx(D.Text,{fontWeight:"medium",color:"gray-500",style:{textWrap:"nowrap"},fontSize:t.isDesktop?"md":"sm",children:"Click your upload"}),e.jsx(D.Text,{fontWeight:"medium",style:{textWrap:"nowrap"},fontSize:t.isDesktop?"md":"sm",children:"or Drag & Drop"})]}),e.jsx(D.Text,{fontSize:"sm",color:"gray-500",children:(l=t.fileSupports)==null?void 0:l.map(a=>a.toLocaleUpperCase()).join(", ")})]})]})};function fi(t){return t.split(" ").map(r=>r[0]).join("").slice(0,2).toUpperCase()}const to=t=>{const r={day:"2-digit",month:"short",year:"numeric"};return t.toLocaleDateString("id-ID",r)},mi=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 gi(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 yi=t=>{const r=t.split(" ");let n=r[0].charAt(0);return r.length>1&&(n+=""+r[1].charAt(0)),n.toUpperCase()};function pi(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 ji="sa-admin",Ne=t=>`var(--${ji}-${t})`,bi={base:{borderColor:Ne("base-border-color"),textColor:Ne("base-text-color"),iconColor:Ne("base-icon-color"),placeholderColor:Ne("base-placeholder-color")},document:{bgColor:Ne("document-bg-color")},sidebar:{bgColor:Ne("sidebar-bg-color"),borderColor:Ne("sidebar-border-color"),maxWidth:Ne("sidebar-max-width"),width:Ne("sidebar-width"),collapseWidth:Ne("sidebar-collapse-width"),collapseV2Width:Ne("sidebar-v2-collapse-width")}},vi=24*60*60*1e3,Ci=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))},wi=/^[^\s@]+@[^\s@]+\.[^\s@]+$/,Di=/--+/,Si=/-$/;function ki(t,r){return JSON.stringify(t)!==JSON.stringify(r)}function Bi(t){return/^(?:\+62|62|0)8[1-9][0-9]{7,10}$/.test(t)}function Fi(t){return/^[A-Za-z\s]+$/.test(t)}const Ei=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()},Mi=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()},Li=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()},Ti=t=>wi.test(t);function Ii(t){return!(Di.test(t)||Si.test(t))}const Oi=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()},Wi=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 Ri(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 zi(t){const r=t.split("/");return r[r.length-1]}const Ai=t=>{var r,n;return e.jsxs(f.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(oe.Flex,{direction:"row",align:"center",gap:"sm",style:{flex:1,minWidth:0},children:[e.jsx(B.Icon,{name:"DocumentFilled",size:"lg",style:{color:"var(--sa-icon-brand)",width:30,height:30,flexShrink:0}}),e.jsxs(oe.Flex,{direction:"column",style:{minWidth:0,flex:1},children:[e.jsx(D.Text,{fontWeight:"bold",style:{textOverflow:"ellipsis",whiteSpace:"nowrap",overflow:"hidden"},children:t.defaultFile?zi(t.defaultFile.url):(r=t.fileSelected)==null?void 0:r.name}),t.defaultFile?(t.defaultFile.size||t.defaultFile.date)&&e.jsxs(oe.Flex,{direction:"row",gap:"xs",align:"center",children:[t.defaultFile.size&&e.jsx(D.Text,{fontSize:"sm",fontWeight:"medium",children:t.defaultFile.size}),t.defaultFile.size&&t.defaultFile.date&&e.jsx(B.Icon,{name:"Dot",size:"xs"}),t.defaultFile.date&&e.jsx(D.Text,{fontSize:"sm",fontWeight:"medium",style:{textWrap:"nowrap"},children:t.defaultFile.date})]}):e.jsxs(oe.Flex,{direction:"row",gap:"xs",align:"center",children:[e.jsx(D.Text,{fontSize:"sm",fontWeight:"medium",children:Ri(((n=t.fileSelected)==null?void 0:n.size.toString())||"100000")}),e.jsx(B.Icon,{name:"Dot",size:"xs"}),e.jsx(D.Text,{fontSize:"sm",fontWeight:"medium",style:{textWrap:"nowrap"},children:to(new Date)})]})]})]}),e.jsx(V.Button,{size:"xs",variant:"tertiary",tone:"error",type:"button",onClick:s=>{s.stopPropagation(),t.handleOnDeleteFile()},iconLeft:e.jsx(B.Icon,{name:"Trash1"})})]})},ro=({status:t="default",labelPosition:r="outside-top",...n})=>{var m;const s=u.useRef(null),o=()=>{if(n.defaultFile){window.open(n.defaultFile.url);return}s.current&&s.current.click()},i=je.useMediaQuery("md"),c=t==="error"||typeof n.errorMessage=="string"&&!!n.errorMessage,l=n.label?e.jsxs(oe.Flex,{direction:"row",align:"center",gap:"xs",children:[e.jsx(D.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(D.Text,{style:{fontSize:"12px",fontWeight:400,color:"var(--sa-text-subtlest, #6b6e76)",lineHeight:"18px"},children:n.description}):null,d=e.jsxs(e.Fragment,{children:[n.helperText&&e.jsx(D.Text,{style:{fontSize:"12px",fontWeight:400,color:"var(--sa-text-subtlest, #6b6e76)",lineHeight:"18px"},children:n.helperText}),n.errorText&&t==="error"&&e.jsx(D.Text,{style:{fontSize:"12px",fontWeight:400,color:"var(--sa-text-error, #a4133c)",lineHeight:"18px"},children:n.errorText}),n.errorMessage&&!n.errorText&&e.jsx(D.Text,{style:{fontSize:"12px",fontWeight:400,color:"var(--sa-text-error, #a4133c)",lineHeight:"18px"},children:n.errorMessage})]}),h=e.jsx("input",{type:"file",style:{display:"none"},ref:s,onChange:j=>{var M;return n.handleOnChangeFile(((M=j.target.files)==null?void 0:M.item(0))||null)},accept:(m=n.fileSupportOption)==null?void 0:m.map(j=>"."+(j==null?void 0:j.toLowerCase())).join(", ")}),g=e.jsxs(f.Box,{direction:"column",fullWidth:!0,style:{minHeight:"69px"},borderRadius:"rounded-md",display:"flex",justify:"center",align:"center",cursor:"pointer",gap:"md",...n.containerProps,children:[h,(n.fileSelected||n.defaultFile)&&e.jsx(Ai,{fileSelected:n.fileSelected,defaultFile:n.defaultFile,handleOnDeleteFile:n.handleOnDeleteFile,handleOnClickFile:o}),!n.fileSelected&&!n.defaultFile&&e.jsx(hi,{fileSupports:n.fileSupportOption,isDesktop:i,errorMessage:c?n.errorText||n.errorMessage||" ":void 0,status:c?"error":"default",handleOnClick:o,handleOnFileChange:n.handleOnChangeFile})]});return r==="outside-left"?e.jsxs(oe.Flex,{direction:"row",align:"flex-start",gap:"sm",style:{width:"100%"},children:[e.jsxs(oe.Flex,{direction:"column",gap:"xs",style:{width:"40%",minWidth:"120px",paddingTop:"10px"},children:[l,a]}),e.jsxs(oe.Flex,{direction:"column",gap:"sm",style:{flex:1,minWidth:0},children:[g,d]})]}):e.jsxs(oe.Flex,{direction:"column",gap:"sm",style:{width:"100%"},children:[l,a,g,d]})},Vi=({size:t="md",direction:r="vertical",requiredTitle:n="(Required)",fullWidth:s=!1,...o})=>{var l,a,d;const i=o.hideMessageError||!1,c=r==="horizontal"?t==="sm"?342:t==="lg"?400:342:void 0;return e.jsxs(f.Box,{gap:r==="horizontal"?"spacing-96":"sm",direction:r==="horizontal"?"row":"column",...o.containerProps,children:[o.title&&e.jsx(se,{condition:!!o.inputProps.required,fallback:e.jsxs(f.Box,{direction:"column",customMaxWidth:c,fullWidth:s,children:[e.jsx(de,{children:o.title}),e.jsx(D.Text,{fontSize:t,color:"gray-500",children:o.description})]}),children:e.jsxs(f.Box,{direction:"column",customMaxWidth:c,fullWidth:s,children:[e.jsxs(oe.Flex,{direction:"row",gap:"xs",align:"center",children:[e.jsx(de,{fontSize:t,children:o.title}),e.jsx(de,{color:"error",fontSize:t,children:n}),e.jsx(se,{condition:!!((l=o.tooltip)!=null&&l.label),children:e.jsx(we.Tooltip,{label:(a=o.tooltip)==null?void 0:a.label,arrowPosition:(d=o.tooltip)==null?void 0:d.arrowPosition,...o.tooltip,children:e.jsx(B.Icon,{name:"InfoCircle",size:t==="lg"?"sm":"xs",style:{color:"var(--sa-color-info-500, #00abeb)",marginTop:"6px"}})})})]}),e.jsx(se,{condition:!!o.description,children:e.jsx(D.Text,{fontSize:t,color:"gray-500",children:o.description})})]})}),e.jsxs(oe.Flex,{direction:"column",gap:"xs",children:[e.jsx(ro,{...o.inputProps,status:o.errorMessage?"error":"default"}),!i&&o.errorMessage&&e.jsx(Ue,{message:o.errorMessage})]})]})},Hi=({size:t="md",direction:r="vertical",requiredTitle:n="(Required)",fullWidth:s=!1,required:o=!1,...i})=>{var a,d,h,g;const c=i.hideMessageError||!1,l=r==="horizontal"?t==="sm"?342:t==="lg"?400:342:void 0;return e.jsxs(f.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(se,{condition:!!o,fallback:e.jsxs(f.Box,{direction:"column",customMaxWidth:l,fullWidth:s,children:[e.jsx(de,{children:i.title}),e.jsx(Re.Body3,{props:{color:"gray-500"},children:i.description})]}),children:e.jsxs(f.Box,{direction:"column",customMaxWidth:l,fullWidth:s,children:[e.jsxs(oe.Flex,{direction:"row",gap:"xs",align:"center",children:[e.jsx(de,{fontSize:t,children:i.title}),e.jsx(de,{color:"error",fontSize:t,children:n}),e.jsx(se,{condition:!!((a=i.tooltip)!=null&&a.label),children:e.jsx(we.Tooltip,{label:(d=i.tooltip)==null?void 0:d.label,arrowPosition:(h=i.tooltip)==null?void 0:h.arrowPosition,...i.tooltip,children:e.jsx(B.Icon,{name:"InfoCircle",size:t==="lg"?"sm":"xs",style:{color:"var(--sa-color-info-500, #00abeb)",marginTop:"6px"}})})})]}),e.jsx(se,{condition:!!i.description,children:e.jsx(D.Text,{fontSize:t,color:"gray-500",children:i.description})})]})}),e.jsx(f.Box,{gap:r==="horizontal-inline"?"xl":"md",direction:r==="horizontal-inline"?"row":"column",align:"flex-start",children:e.jsx(Vt,{of:(g=i.checkBoxesList)==null?void 0:g.map(m=>({...m,isChecked:i.checkBoxesAreChecked.includes(m.id)})),render:m=>m.renderBadge?e.jsxs(f.Box,{direction:"row",justify:"space-between",gap:"lg",...i.badgeContainerProps,children:[e.jsx(Ze.Checkbox,{name:m.name,value:m.id,checked:m.isChecked,onChange:j=>i.onChecked(j.target.value,m),label:m.name,description:m.description}),m.renderBadge]}):e.jsx(Ze.Checkbox,{name:m.name,value:m.id,checked:m.isChecked,onChange:j=>i.onChecked(j.target.value,m),label:m.name,description:m.description})})}),!c&&i.errorMessage&&e.jsx(Ue,{message:i.errorMessage})]})},Pi=({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(f.Box,{gap:t==="horizontal-inline"||t==="horizontal-block"?"spacing-96":"sm",direction:t==="horizontal-inline"||t==="horizontal-block"?"row":"column",children:[e.jsx(se,{condition:!!s.description||!!s.title,children:e.jsxs(f.Box,{direction:"column",customMaxWidth:o,fullWidth:n,children:[s.title&&e.jsx(de,{children:s.title}),e.jsx(se,{condition:!!s.description,children:e.jsx(D.Text,{color:"gray-500",children:s.description})})]})}),e.jsx(f.Box,{gap:"sm",direction:t==="horizontal"||t==="horizontal-inline"?"row":"column",align:"flex-start",flexWrap:"wrap",children:e.jsx(Vt,{of:(i=s.radioList)==null?void 0:i.map(c=>({...c,isChecked:s.radioIsChecked===c.id})),render:({value:c,id:l,isChecked:a,subInput:d,label:h,description:g})=>e.jsxs(f.Box,{direction:"column",gap:"xs",customMaxWidth:o,children:[e.jsx(fr.Radio,{id:`${l.toString()}-${c}`,name:s.groupName||h,label:h,value:c,checked:a,onChange:m=>s.onChecked({id:l,label:m.target.name,value:m.target.value}),disabled:s.disableAll},l),g&&e.jsx(D.Text,{color:"gray-500",style:{marginLeft:28},children:g}),d]})})}),s.errorMessage&&e.jsx(Ue,{message:s.errorMessage})]})},Ni=({size:t="md",direction:r="vertical",requiredTitle:n="(Required)",fullWidth:s=!1,...o})=>{var l,a,d;const i=o.hideMessageError||!1,c=r==="horizontal"?t==="sm"?342:t==="lg"?400:342:void 0;return e.jsxs(f.Box,{gap:r==="horizontal"?"spacing-96":"sm",direction:r==="horizontal"?"row":"column",...o.containerProps,children:[o.title&&e.jsx(se,{condition:!!o.inputProps.required,fallback:e.jsxs(f.Box,{direction:"column",customMaxWidth:c,fullWidth:s,children:[e.jsx(de,{children:o.title}),e.jsx(D.Text,{fontSize:t,color:"gray-500",children:o.description})]}),children:e.jsxs(f.Box,{direction:"column",customMaxWidth:c,fullWidth:s,children:[e.jsxs(oe.Flex,{direction:"row",gap:"xs",align:"center",children:[e.jsx(de,{fontSize:t,children:o.title}),e.jsx(de,{color:"error",fontSize:t,children:n}),e.jsx(se,{condition:!!((l=o.tooltip)!=null&&l.label),children:e.jsx(we.Tooltip,{label:(a=o.tooltip)==null?void 0:a.label,arrowPosition:(d=o.tooltip)==null?void 0:d.arrowPosition,...o.tooltip,children:e.jsx(B.Icon,{name:"InfoCircle",size:t==="lg"?"sm":"xs",style:{color:"var(--sa-color-info-500, #00abeb)",marginTop:"6px"}})})})]}),e.jsx(se,{condition:!!o.description,children:e.jsx(D.Text,{fontSize:t,color:"gray-500",children:o.description})})]})}),e.jsxs(oe.Flex,{direction:"column",gap:"xs",children:[e.jsx(hr.Textarea,{ref:o.inputRef,size:t,...o.inputProps,status:o.errorMessage?"error":"default"}),!i&&o.errorMessage&&e.jsx(Ue,{message:o.errorMessage})]})]})},_i=({size:t="md",direction:r="vertical",requiredTitle:n="(Required)",required:s=!1,fullWidth:o=!1,...i})=>{var l,a,d;const c=r==="horizontal"?t==="sm"?342:t==="lg"?400:342:void 0;return e.jsxs(f.Box,{gap:r==="horizontal"?"spacing-96":"sm",direction:r==="horizontal"?"row":"column",...i.containerProps,children:[i.title&&e.jsx(se,{condition:s,fallback:e.jsxs(f.Box,{direction:"column",customMaxWidth:c,fullWidth:o,children:[e.jsx(de,{children:i.title}),e.jsx(D.Text,{fontSize:t,color:"gray-500",children:i.titleDescription})]}),children:e.jsxs(f.Box,{direction:"column",customMaxWidth:c,fullWidth:o,children:[e.jsxs(oe.Flex,{direction:"row",gap:"xs",align:"center",children:[e.jsx(de,{fontSize:t,children:i.title}),e.jsx(de,{color:"error",fontSize:t,children:n}),e.jsx(se,{condition:!!((l=i.tooltip)!=null&&l.label),children:e.jsx(we.Tooltip,{label:(a=i.tooltip)==null?void 0:a.label,arrowPosition:(d=i.tooltip)==null?void 0:d.arrowPosition,...i.tooltip,children:e.jsx(B.Icon,{name:"InfoCircle",size:t==="lg"?"sm":"xs",style:{color:"var(--sa-color-info-500, #00abeb)",marginTop:"6px"}})})})]}),e.jsx(se,{condition:!!i.titleDescription,children:e.jsx(D.Text,{fontSize:t,color:"gray-500",children:i.titleDescription})})]})}),e.jsx(dt.Toggle,{checked:i.checked,onChange:i.onChange,label:i.label,description:i.description}),i.errorMessage&&e.jsx(Ue,{message:i.errorMessage})]})},qi=({variant:t="primary",size:r="md",...n})=>{const s=lt.useColor(),o=c=>{var a,d,h,g,m,j;if(!c)return;const l=n.disabled?"var(--sa-text-disable, #181a198f)":t==="secondary"?"var(--sa-text-subtle, #8c8f97)":t==="secondary-danger"?(d=(a=s==null?void 0:s.computed)==null?void 0:a.red)==null?void 0:d[600]:t==="secondary-primary"?(g=(h=s==null?void 0:s.computed)==null?void 0:h.blue)==null?void 0:g[700]:(j=(m=s==null?void 0:s.computed)==null?void 0:m.gray)==null?void 0:j[50];return e.jsx(B.Icon,{name:c,size:r,style:{color:l}})},i=()=>{var l,a,d,h;if(t!=="secondary-danger"&&t!=="secondary-primary")return n.title;const c={color:n.disabled?"var(--sa-text-disable, #181a198f)":t==="secondary-danger"?(a=(l=s==null?void 0:s.computed)==null?void 0:l.red)==null?void 0:a[600]:(h=(d=s==null?void 0:s.computed)==null?void 0:d.blue)==null?void 0:h[700]};switch(r){case"xs":return e.jsx(Re.Body2,{props:{style:c},children:n.title});case"sm":case"md":return e.jsx(Re.SubH3,{props:{style:c},children:n.title});case"lg":return e.jsx(Re.SubH2,{props:{style:c},children:n.title});default:return n.title}};return e.jsx(V.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()})},Zi=t=>e.jsx(Re.H5,{props:{...t},children:t.title}),Gi=({size:t="md",direction:r="vertical",requiredTitle:n="(Required)",fullWidth:s=!1,...o})=>{var l,a,d;const i=o.hideMessageError||!1,c=r==="horizontal"?t==="sm"?342:t==="lg"?400:342:void 0;return e.jsxs(f.Box,{gap:r==="horizontal"?"spacing-96":"sm",direction:r==="horizontal"?"row":"column",onClick:o.onClickContainer,children:[o.title&&e.jsx(se,{condition:!!o.inputProps.required,fallback:e.jsxs(f.Box,{direction:"column",customMaxWidth:c,fullWidth:s,children:[e.jsx(de,{children:o.title}),e.jsx(D.Text,{fontSize:t,color:"gray-500",children:o.description})]}),children:e.jsxs(f.Box,{direction:"column",customMaxWidth:c,fullWidth:s,children:[e.jsxs(oe.Flex,{direction:"row",gap:"xs",align:"center",children:[e.jsx(de,{fontSize:t,children:o.title}),e.jsx(de,{color:"error",fontSize:t,children:n}),e.jsx(se,{condition:!!((l=o.tooltip)!=null&&l.label),children:e.jsx(we.Tooltip,{label:(a=o.tooltip)==null?void 0:a.label,arrowPosition:(d=o.tooltip)==null?void 0:d.arrowPosition,...o.tooltip,children:e.jsx(B.Icon,{name:"InfoCircle",size:t==="lg"?"sm":"xs",style:{color:"var(--sa-color-info-500, #00abeb)",marginTop:"6px"}})})})]}),e.jsx(se,{condition:!!o.description,children:e.jsx(D.Text,{fontSize:t,color:"gray-500",children:o.description})})]})}),e.jsxs(oe.Flex,{direction:"column",gap:"xs",children:[e.jsx(f.Box,{direction:"column",style:{width:r==="horizontal"&&o.customWidth?o.customWidth:r==="horizontal"?"343px":""},children:e.jsx(et.StarasiaDate,{size:t,...o.inputProps,status:o.errorMessage?"error":void 0})}),!i&&o.errorMessage&&e.jsx(Ue,{message:o.errorMessage})]})]})};async function Qi(t,r){const n=new Image;n.src=t,await new Promise((i,c)=>{n.onload=i,n.onerror=c});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,c)=>{s.toBlob(l=>{if(!l)return c("Canvas is empty");const a=new File([l],"cropped.png",{type:"image/png"});i(a)},"image/png")})}const pn={"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},no=u.forwardRef(({handleUpload:t,urlImage:r,isUploading:n,croppedImage:s,setCroppedImage:o,size:i="96",aspect:c="1:1",containerProps:l,maxFileSize:a=2,onError:d},h)=>{const g=je.useMediaQuery("md"),[m,j]=u.useState(!1),[M,p]=u.useState(null),[L,S]=u.useState(!1),[T,w]=u.useState({x:0,y:0}),[C,z]=u.useState(1),[W,b]=u.useState(null);u.useEffect(()=>{r===null&&o(null)},[r]);const F=u.useCallback((K,Q)=>{b(Q)},[]),N=K=>{var ce;const Q=(ce=K.target.files)==null?void 0:ce[0];if(!Q)return;const ue=new FileReader;ue.onload=()=>{p(ue.result),S(!0)},ue.readAsDataURL(Q)},A=async()=>{if(!(!M||!W))try{const K=await Qi(M,W);if(a&&K.size>a*1024*1024){d==null||d(`Ukuran file maksimal ${a}MB`);return}t==null||t(K);const Q=URL.createObjectURL(K);o(Q,K),S(!1)}catch{d==null||d("Gagal memproses gambar")}},H=u.useRef(null),U=()=>{H.current&&H.current.click()};u.useImperativeHandle(h,()=>({openFileDialog:()=>{var K;(K=H.current)==null||K.click()}}));const re=parseInt(i,10),ne=pn[c];let ee,ie;return ne>=1?(ie=re,ee=re*ne):(ee=re,ie=re/ne),e.jsxs(f.Box,{direction:"column",display:"flex",position:"relative",bg:(l==null?void 0:l.bg)||"gray-200",borderStyle:(l==null?void 0:l.borderStyle)||"border-none",borderColor:(l==null?void 0:l.borderColor)||"gray-200",borderWidth:(l==null?void 0:l.borderWidth)||"border-2",borderRadius:(l==null?void 0:l.borderRadius)||"rounded-md",overflow:"overflow-hidden",align:"center",justify:"center",style:{width:l!=null&&l.fullWidth?"100%":`${ee}px`,height:l!=null&&l.fullWidth?"auto":`${ie}px`,aspectRatio:ne,flexShrink:0},onMouseEnter:()=>j(!0),onMouseLeave:()=>j(!1),children:[s||r?e.jsx("img",{src:s||r||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(B.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(f.Box,{direction:"column",position:"absolute",display:"flex",align:"center",justify:"center",cursor:"pointer",style:{inset:0,backgroundColor:"var(--sa-color-black-alpha-a30, #080f214a)",opacity:m?1:0,transition:"opacity 0.3s ease-in-out"},onClick:U,children:[e.jsx("input",{ref:H,type:"file",accept:"image/*",onChange:N,disabled:n,style:{display:"none"}}),e.jsxs(f.Box,{display:"flex",align:"center",gap:"spacing-2",direction:"row",children:[e.jsx(B.Icon,{name:"Edit3",style:{color:"var(--sa-background-primary, #ffffff)"}}),e.jsx(se,{condition:i.toNumber()>80,children:e.jsx(D.Text,{color:"gray-50",fontSize:i.toNumber()>80?"sm":"md",fontWeight:"medium",children:"Edit Image"})})]})]}),n&&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, #e5e9f640)"},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&&yr.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:()=>S(!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?c==="1:1"?"min(90vw, 480px)":`min(90vw, ${ee*2}px)`:"calc(100vw - 2rem)",display:"flex",flexDirection:"column"},onClick:K=>K.stopPropagation(),children:[e.jsx("div",{style:{position:"relative",width:"100%",height:"20rem",backgroundColor:"var(--sa-color-gray-100)"},children:M&&e.jsx(Fo,{image:M,crop:T,zoom:C,aspect:c?pn[c]:void 0,onCropChange:w,onZoomChange:z,onCropComplete:F,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(V.Button,{size:"sm",secondary:!0,onClick:()=>S(!1),children:"Cancel"}),e.jsx(V.Button,{size:"sm",primary:!0,onClick:A,children:"Crop"})]})]})}),document.body)]})}),Ui=({size:t="md",direction:r="vertical",requiredTitle:n="(Required)",fullWidth:s=!1,required:o=!1,...i})=>{var a,d,h;const c=i.hideMessageError||!1,l=r==="horizontal"?t==="sm"?342:t==="lg"?400:342:void 0;return e.jsxs(f.Box,{gap:r==="horizontal"?"spacing-96":"sm",direction:r==="horizontal"?"row":"column",...i.containerProps,children:[i.title&&e.jsx(se,{condition:!!o,fallback:e.jsxs(f.Box,{direction:"column",customMaxWidth:l,fullWidth:s,children:[e.jsx(de,{children:i.title}),e.jsx(D.Text,{fontSize:t,color:"gray-500",children:i.description})]}),children:e.jsxs(f.Box,{direction:"column",customMaxWidth:l,fullWidth:s,children:[e.jsxs(oe.Flex,{direction:"row",gap:"xs",align:"center",children:[e.jsx(de,{fontSize:t,children:i.title}),e.jsx(de,{color:"error",fontSize:t,children:n}),e.jsx(se,{condition:!!((a=i.tooltip)!=null&&a.label),children:e.jsx(we.Tooltip,{label:(d=i.tooltip)==null?void 0:d.label,arrowPosition:(h=i.tooltip)==null?void 0:h.arrowPosition,...i.tooltip,children:e.jsx(B.Icon,{name:"InfoCircle",size:t==="lg"?"sm":"xs",style:{color:"var(--sa-color-info-500, #00abeb)",marginTop:"6px"}})})})]}),e.jsx(se,{condition:!!i.description,children:e.jsx(D.Text,{fontSize:t,color:"gray-500",children:i.description})})]})}),e.jsxs(oe.Flex,{direction:"column",gap:"xs",children:[e.jsx(no,{...i.inputProps}),!c&&i.errorMessage&&e.jsx(Ue,{message:i.errorMessage})]})]})},Ji=({size:t="md",direction:r="vertical",requiredTitle:n="(Required)",fullWidth:s=!1,...o})=>{var c,l,a;const i=r==="horizontal"?t==="sm"?342:t==="lg"?400:342:void 0;return e.jsxs(f.Box,{gap:r==="horizontal"?"spacing-96":"sm",direction:r==="horizontal"?"row":"column",...o.containerProps,children:[o.title&&e.jsx(se,{condition:!!o.inputProps.required,fallback:e.jsxs(f.Box,{direction:"column",customMaxWidth:i,fullWidth:s,children:[e.jsx(de,{children:o.title}),e.jsx(D.Text,{fontSize:t,color:"gray-500",children:o.description})]}),children:e.jsxs(f.Box,{direction:"column",customMaxWidth:i,fullWidth:s,children:[e.jsxs(oe.Flex,{direction:"row",gap:"xs",align:"center",children:[e.jsx(de,{fontSize:t,children:o.title}),e.jsx(de,{color:"error",fontSize:t,children:n}),e.jsx(se,{condition:!!((c=o.tooltip)!=null&&c.label),children:e.jsx(we.Tooltip,{label:(l=o.tooltip)==null?void 0:l.label,arrowPosition:(a=o.tooltip)==null?void 0:a.arrowPosition,...o.tooltip,children:e.jsx(B.Icon,{name:"InfoCircle",size:t==="lg"?"sm":"xs",style:{color:"var(--sa-color-info-500, #00abeb)",marginTop:"6px"}})})})]}),e.jsx(se,{condition:!!o.description,children:e.jsx(D.Text,{fontSize:t,color:"gray-500",children:o.description})})]})}),o.inputProps.extended&&o.inputProps.extended]})},Yi=({items:t,id:r,handleOnUpdate:n,width:s,toggleShow:o=!0,disabled:i=!1})=>{var h;const[c,l]=u.useState([]);u.useEffect(()=>{t&&l([...t.map(g=>({id:g.id,isActive:g.isActive}))])},[t]);const a=(h=c.find(g=>g.id===r))==null?void 0:h.isActive,d=u.useCallback(()=>{l(g=>g.map(m=>m.id===r?{...m,isActive:!m.isActive}:m)),n&&n(!a)},[r,n,a]);return e.jsx(f.Box,{direction:"row",gap:"md",style:{width:s},children:o&&e.jsx(dt.Toggle,{disabled:i,checked:a,onChange:d,label:a?"Active":"Inactive"})})},Xi={InputText:di,InputDropdown:ui,InputSingleFile:Vi,CheckBoxOptions:Hi,RadioOptions:Pi,InputTextArea:Ni,ToggleForm:_i,ActionButton:qi,FormTitle:Zi,InputDate:Gi,InputImgFile:Ui,Custom:Ji},oo=({customBottom:t})=>{const[r,n]=u.useState(!1),s=()=>{window.scrollY>window.screenY?n(!0):n(!1)},o=()=>{window.scrollTo({top:0,behavior:"smooth"})};return u.useEffect(()=>(window.addEventListener("scroll",s),()=>{window.removeEventListener("scroll",s)}),[]),e.jsx(f.Box,{direction:"column",style:{position:"fixed",bottom:0,right:0},children:e.jsx(f.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(V.Button,{secondary:!0,size:"xs",onClick:o,type:"button",iconLeft:e.jsx(B.Icon,{width:16,size:"xs",name:"ArrowPullUp",style:{color:"var(--sa-background-brand, #04254f)"}})})})})},Fe="sa-sidepanel-item",jn="sa-sidepanel-item-styles",Ki="inset 3.5px 0 0 0 var(--sa-border-focused, #1a4fa0)",$i="inset -3.5px 0 0 0 var(--sa-border-focused, #1a4fa0)",el=`
|
|
47
47
|
.${Fe} {
|
|
48
48
|
display: block;
|
|
49
49
|
box-sizing: border-box;
|
package/dist/index.es.js
CHANGED
|
@@ -6540,7 +6540,7 @@ const Kc = al(sl), Cn = 200, pr = "1px solid var(--sa-border-subtle, #0b120e24)"
|
|
|
6540
6540
|
// di atas frozen body cells (1)
|
|
6541
6541
|
...M ? { "--sa-tl-bg": M } : {}
|
|
6542
6542
|
},
|
|
6543
|
-
children: /* @__PURE__ */ e(
|
|
6543
|
+
children: Yt(y, C) && /* @__PURE__ */ e(
|
|
6544
6544
|
"div",
|
|
6545
6545
|
{
|
|
6546
6546
|
style: {
|
|
@@ -6554,7 +6554,6 @@ const Kc = al(sl), Cn = 200, pr = "1px solid var(--sa-border-subtle, #0b120e24)"
|
|
|
6554
6554
|
{
|
|
6555
6555
|
size: "sm",
|
|
6556
6556
|
checked: rt.has(J),
|
|
6557
|
-
disabled: !Yt(y, C),
|
|
6558
6557
|
onChange: () => Xt(J),
|
|
6559
6558
|
"aria-label": "Pilih baris"
|
|
6560
6559
|
}
|
|
@@ -6663,7 +6662,8 @@ const Kc = al(sl), Cn = 200, pr = "1px solid var(--sa-border-subtle, #0b120e24)"
|
|
|
6663
6662
|
style: { borderBottom: Bt, backgroundColor: de },
|
|
6664
6663
|
children: [
|
|
6665
6664
|
/* @__PURE__ */ u("div", { style: { display: "flex", alignItems: "center" }, children: [
|
|
6666
|
-
|
|
6665
|
+
Yt(y, C) && // Sibling dari tombol expand — tap checkbox tidak memuai baris.
|
|
6666
|
+
// Baris non-selectable tidak merender checkbox sama sekali.
|
|
6667
6667
|
/* @__PURE__ */ e(
|
|
6668
6668
|
"div",
|
|
6669
6669
|
{
|
|
@@ -6678,7 +6678,6 @@ const Kc = al(sl), Cn = 200, pr = "1px solid var(--sa-border-subtle, #0b120e24)"
|
|
|
6678
6678
|
{
|
|
6679
6679
|
size: "sm",
|
|
6680
6680
|
checked: rt.has(M),
|
|
6681
|
-
disabled: !Yt(y, C),
|
|
6682
6681
|
onChange: () => Xt(M),
|
|
6683
6682
|
"aria-label": "Pilih baris"
|
|
6684
6683
|
}
|
|
@@ -6755,19 +6754,21 @@ const Kc = al(sl), Cn = 200, pr = "1px solid var(--sa-border-subtle, #0b120e24)"
|
|
|
6755
6754
|
backgroundColor: J ? yr : Rt(o == null ? void 0 : o(y, C))
|
|
6756
6755
|
},
|
|
6757
6756
|
children: [
|
|
6758
|
-
|
|
6757
|
+
Yt(y, C) ? /* @__PURE__ */ u("div", { style: { display: "flex", alignItems: "center", gap: 8 }, children: [
|
|
6759
6758
|
/* @__PURE__ */ e(
|
|
6760
6759
|
it,
|
|
6761
6760
|
{
|
|
6762
6761
|
size: "sm",
|
|
6763
6762
|
checked: rt.has(M),
|
|
6764
|
-
disabled: !Yt(y, C),
|
|
6765
6763
|
onChange: () => Xt(M),
|
|
6766
6764
|
"aria-label": "Pilih baris"
|
|
6767
6765
|
}
|
|
6768
6766
|
),
|
|
6769
6767
|
/* @__PURE__ */ e("div", { style: { flex: 1, minWidth: 0 }, children: or(y, C) })
|
|
6770
|
-
] }) :
|
|
6768
|
+
] }) : (
|
|
6769
|
+
// Baris non-selectable (atau selectable=false): tanpa checkbox.
|
|
6770
|
+
or(y, C)
|
|
6771
|
+
),
|
|
6771
6772
|
Jr(y, C),
|
|
6772
6773
|
oe && li(y, C)
|
|
6773
6774
|
]
|
package/dist/index.umd.js
CHANGED
|
@@ -43,7 +43,7 @@
|
|
|
43
43
|
box-shadow: 0 4px 12px rgba(0,0,0,0.12);
|
|
44
44
|
padding: 4px 0;
|
|
45
45
|
}
|
|
46
|
-
`,document.head.appendChild(r)},zr=r=>r==="right"?"right":r==="center"?"center":"left",Fn=/^(#|rgb|hsl|var\()/,Ar=r=>r?Fn.test(r)?r:`var(--sa-background-${r})`:void 0,En=(r,t)=>{if(t)return r[t]},Mn=(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)),Ln=({columns:r,data:t,getRowKey:l,rowBg:n,size:o="md",resizable:c=!1,layout:s="auto",widthStorageKey:i,columnState:a,onColumnStateChange:d,columnMenu:y=!1,sort:b,defaultSort:p,onSortChange:x,height:T,mobileLayout:v="cards",mobileBreakpoint:I="md",groupSeparator:m,summary:O,emptyState:k,loading:S=!1,loadingRows:V=8,rowActions:A,selectable:w=!1,selectedKeys:M,defaultSelectedKeys:q,onSelectionChange:j,isRowSelectable:N})=>{mn();const le=!xe.useMediaQuery(I)&&v!=="scroll",oe=!!(A!=null&&A.length),[re,ie]=h.useState(null);h.useEffect(()=>{if(!re)return;const C=()=>ie(null),D=setTimeout(()=>document.addEventListener("click",C),0);return()=>{clearTimeout(D),document.removeEventListener("click",C)}},[re]);const[R,J]=h.useState(()=>new Set),fe=a!==void 0,[ae,ge]=h.useState({}),be=a??ae,je=C=>{d==null||d(C),fe||ge(C)},Pe=b!==void 0,[Ne,Le]=h.useState(p??null),ue=Pe?b??null:Ne,Ae=!x,Ge=C=>{x==null||x(C),Pe||Le(C)},{headerGroups:He,leafColumns:ye,hasGroups:_e}=h.useMemo(()=>{var de;const C=new Set(be.hidden??[]),D=(se,Ce)=>se.key??(typeof se.accessor=="string"?se.accessor:`col-${Ce}`),L=r.map((se,Ce)=>{var Ie;if((Ie=se.children)!=null&&Ie.length){const xr=se.children.map((qe,wr)=>({col:qe,key:D(qe,`${Ce}-${wr}`)})).filter(qe=>!C.has(qe.key));return{col:se,key:se.key??`group-${Ce}`,isGroup:!0,leaves:xr}}const ve={col:se,key:D(se,`${Ce}`)};return{col:se,key:ve.key,isGroup:!1,leaves:C.has(ve.key)?[]:[ve]}}).filter(se=>se.leaves.length>0),X=L.some(se=>se.isGroup);let te=L.flatMap(se=>se.leaves);if(!X&&((de=be.order)!=null&&de.length)){const se=new Map(be.order.map((Ce,ve)=>[Ce,ve]));te=[...te].sort((Ce,ve)=>(se.get(Ce.key)??1/0)-(se.get(ve.key)??1/0))}return{headerGroups:L,leafColumns:te,hasGroups:X}},[r,be]),F=h.useMemo(()=>new Map(ye.map((C,D)=>[C.key,D])),[ye]),G=!_e&&ye.some(C=>(C.col.headerColSpan??1)>1),U=ye.map(C=>C.key).join("|"),W=(C,D)=>{const L=C.sortKey??(typeof C.accessor=="string"?C.accessor:void 0);return L?D[L]:void 0},Q=C=>C.sortable??(!!C.sortKey||typeof C.accessor=="string"),H=h.useMemo(()=>{if(!Ae||!ue)return t;const C=ye.find(L=>L.key===ue.key);if(!C)return t;const D=ue.direction==="asc"?1:-1;return[...t].sort((L,X)=>Mn(W(C.col,L),W(C.col,X))*D)},[t,Ae,ue,ye]),_=!_e&&!G,$=!!i&&_,[Se,Fe]=Z.useColumnWidths(i??""),Te=$?Se:void 0,Ee=h.useRef(null),[pe,dr]=h.useState();h.useLayoutEffect(()=>{dr(void 0)},[U]),h.useLayoutEffect(()=>{if(!_||pe||!Ee.current)return;const C=Ee.current.querySelectorAll("th.sa-tl-leaf");dr(Array.from(C).map(D=>D.offsetWidth))},[pe,_]);const[er,rr]=h.useState(0);h.useLayoutEffect(()=>{if(!_e||!Ee.current)return;const C=Ee.current.querySelector(":scope > tr");C&&rr(C.offsetHeight)},[_e,U]);const Qe=(C,D)=>{if((Te==null?void 0:Te[D])!=null)return Te[D];if(C.width!=null)return C.width;if((pe==null?void 0:pe[D])!=null)return pe[D]},qr=(C,D)=>typeof C.width=="number"?C.width:pe==null?void 0:pe[D],hr=be.frozenKey&&!_e&&!G?ye.findIndex(C=>C.key===be.frozenKey):-1,fr=C=>C<=hr,Ql=w?Cr:0,Ul=C=>{if(!pe)return Ql;let D=Ql;for(let L=0;L<C;L++)D+=pe[L]??0;return D},pt=h.useRef(null),[Kc,$c]=h.useState("100vh");h.useLayoutEffect(()=>{if(T!==void 0)return;const C=()=>{if(pt.current){const D=pt.current.getBoundingClientRect().top;$c(`calc(100vh - ${D}px)`)}};return C(),window.addEventListener("resize",C),()=>window.removeEventListener("resize",C)},[T]);const Je=(C,D)=>l?l(C,D):D,bt=M!==void 0,[Jl,Rc]=h.useState(()=>new Set(q??[])),Ye=h.useMemo(()=>bt?new Set(M):Jl,[bt,M,Jl]);h.useEffect(()=>{w&&!l&&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).")},[w,!l]);const Yl=C=>{if(bt||Rc(C),j){const D=H.filter((L,X)=>C.has(Je(L,X)));j(Array.from(C),D)}},Ct=(C,D)=>w&&(N?N(C,D):!0),vt=C=>{const D=new Set(Ye);D.has(C)?D.delete(C):D.add(C),Yl(D)},gr=h.useMemo(()=>w?H.map((C,D)=>({row:C,i:D,key:Je(C,D)})).filter(({row:C,i:D})=>N?N(C,D):!0).map(({key:C})=>C):[],[w,H,N,l]),Xl=gr.filter(C=>Ye.has(C)),xt=gr.length>0&&Xl.length===gr.length,Kl=Xl.length>0&&!xt,ei=()=>{const C=new Set(Ye);xt?gr.forEach(D=>C.delete(D)):gr.forEach(D=>C.add(D)),Yl(C)},wt=(C,D,L)=>C.render?C.render(D,L,H):En(D,C.accessor),Dt=ye.length+(w?1:0)+(oe?1:0),$l=["80%","55%","70%","45%","90%","60%"],ri=(C,D)=>$l[(C*7+D*3)%$l.length],ti=(C,D)=>e.jsx(We.Skeleton,{height:14,width:ri(C,D),borderRadius:"rounded-sm"}),li=Array.from({length:V},(C,D)=>e.jsxs(Z.Tr,{children:[w&&e.jsx(Z.Td,{style:{width:Cr,padding:0},children:e.jsx("div",{style:{display:"flex",justifyContent:"center"},children:e.jsx(We.Skeleton,{height:14,width:14,borderRadius:"rounded-sm"})})}),ye.map(({col:L,key:X},te)=>e.jsx(Z.Td,{style:{textAlign:zr(L.align)},children:ti(D,te)},`sa-tl-sk-${D}-${X}`)),oe&&e.jsx(Z.Td,{style:{width:1,padding:0,border:"none"}})]},`sa-tl-sk-${D}`)),oi=(C,D)=>{D||je({...be,hidden:[...be.hidden??[],C]})},ni=C=>je({...be,frozenKey:be.frozenKey===C?void 0:C}),Zr=C=>(A??[]).filter(D=>{var L;return!((L=D.hidden)!=null&&L.call(D,C))}),Rl={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)"},Gr=(C,D,L,X)=>{var Ie;const te=(Ie=C.disabled)==null?void 0:Ie.call(C,D),de=(X==null?void 0:X.showLabel)??C.showLabel,se=(X==null?void 0:X.size)??"xs",Ce=e.jsx(P.Button,{size:se,variant:C.variant??"tertiary",tone:C.tone??"neutral",disabled:te,onClick:()=>C.onClick(D,L),iconLeft:C.icon?e.jsx(E.Icon,{name:C.icon,size:"sm"}):void 0,children:de&&C.label}),ve=C.tooltip;return ve?e.jsx(ke.Tooltip,{label:ve,position:"top-end",children:Ce}):Ce},ci=(C,D)=>{const L=Zr(C);if(!L.length)return null;if(L.length>5){const te=Je(C,D),de=(re==null?void 0:re.rowKey)===te;return e.jsx("div",{className:"sa-tl-row-actions",style:Rl,onClick:se=>se.stopPropagation(),children:e.jsx(ke.Tooltip,{label:"Aksi lainnya",position:"top",children:e.jsx(P.Button,{size:"xs",variant:"tertiary",onClick:se=>{const Ce=se.currentTarget.getBoundingClientRect();ie(de?null:{rowKey:te,top:Ce.bottom+4,right:window.innerWidth-Ce.right})},children:e.jsx(E.Icon,{name:"MenuVertical",size:"sm"})})})})}return e.jsx("div",{className:"sa-tl-row-actions",style:Rl,children:L.map(te=>e.jsx(h.Fragment,{children:Gr(te,C,D)},te.key))})},ii=(C,D)=>{const L=Zr(C);return L.length?e.jsx("div",{style:{display:"flex",gap:6,flexWrap:"wrap",paddingTop:8,marginTop:8,borderTop:Or},children:L.map(X=>e.jsx(h.Fragment,{children:Gr(X,C,D,{showLabel:!0,size:"sm"})},X.key))}):null},si=(C,D)=>{const L=Zr(C);return L.length?e.jsx("div",{style:{display:"flex",gap:4,paddingRight:8,flexShrink:0},children:L.map(X=>e.jsx(h.Fragment,{children:Gr(X,C,D,{showLabel:!1})},X.key))}):null},St=(C,D)=>{const{col:L,key:X}=C,te=F.get(X)??0,de=fr(te),se=de&&te===hr,Ce=(ue==null?void 0:ue.key)===X?ue.direction:null,ve=y&&!L.disableMenu?e.jsx(Wl,{active:!!Ce||de,canSort:Q(L),canHide:!L.locked,sortDir:Ce,frozen:de,onSort:wr=>Ge({key:X,direction:wr}),onClearSort:()=>Ge(null),onToggleFreeze:()=>ni(X),onHide:()=>oi(X,L.locked)}):null,Ie=L.align==="right",xr=L.align==="right"?"flex-end":L.align==="center"?"center":"flex-start",qe=e.jsxs("span",{style:{flex:1,minWidth:0,display:"flex",alignItems:"center",gap:6,justifyContent:xr,overflow:"hidden"},children:[L.icon&&e.jsx(E.Icon,{name:L.icon,size:"sm",style:{flexShrink:0}}),e.jsx("span",{style:Wr,children:L.title})]});return e.jsx(Z.Th,{className:`sa-tl-leaf${de?" sa-tl-frozen":""}`,rowSpan:D==null?void 0:D.rowSpan,colSpan:D==null?void 0:D.colSpan,minWidth:L.minWidth,resizable:_?L.resizable:!1,defaultWidth:qr(L,te),style:{textAlign:zr(L.align),width:Qe(L,te),position:"sticky",top:(D==null?void 0:D.top)??0,left:de?Ul(te):void 0,zIndex:de?3:2,backgroundColor:ar,boxShadow:se?zl:void 0},children:e.jsx("div",{style:{display:"flex",alignItems:"center",gap:6,width:"100%"},children:Ie?e.jsxs(e.Fragment,{children:[ve,qe]}):e.jsxs(e.Fragment,{children:[qe,ve]})})},`th-${X}`)},ai=()=>{const C=[];for(let D=0;D<ye.length;){const L=ye[D],X=L.col.headerColSpan??1,te=Math.max(1,Math.min(X,ye.length-D));C.push(St(L,te>1?{colSpan:te}:void 0)),D+=te}return C},eo=C=>e.jsx(Z.Th,{rowSpan:C==null?void 0:C.rowSpan,style:{width:Cr,position:"sticky",top:0,left:0,zIndex:4,backgroundColor:ar,padding:0},children:e.jsx("div",{style:{display:"flex",alignItems:"center",justifyContent:"center"},onClick:D=>D.stopPropagation(),children:e.jsx(Ze.Checkbox,{size:"sm",variant:Kl?"indeterminate":"select",checked:xt||Kl,disabled:gr.length===0,onChange:ei,"aria-label":"Pilih semua baris di halaman ini"})})},"th-select"),di=(C,D,L)=>{const X=Je(C,D);return e.jsx(Z.Td,{className:"sa-tl-frozen",style:{width:Cr,padding:0,position:"sticky",left:0,zIndex:2,...L?{"--sa-tl-bg":L}:{}},children:e.jsx("div",{style:{display:"flex",alignItems:"center",justifyContent:"center"},onClick:te=>te.stopPropagation(),children:e.jsx(Ze.Checkbox,{size:"sm",checked:Ye.has(X),disabled:!Ct(C,D),onChange:()=>vt(X),"aria-label":"Pilih baris"})})},`tl-select-${D}`)},kt=ye.filter(C=>!C.col.hideOnMobile),Bt=kt.find(C=>C.col.primary)??kt[0],hi=kt.filter(C=>C!==Bt),fi=C=>J(D=>{const L=new Set(D);return L.has(C)?L.delete(C):L.add(C),L}),ro=(C,D)=>hi.map(({col:L,key:X})=>{const te=wt(L,C,D),de=typeof te=="string"||typeof te=="number"?e.jsx(B.Text,{style:{minWidth:0,overflow:"hidden",textOverflow:"ellipsis",textAlign:"right"},children:te}):e.jsx("div",{style:{minWidth:0,overflow:"hidden",textOverflow:"ellipsis",textAlign:"right"},children:te});return e.jsxs("div",{style:{display:"flex",gap:12,justifyContent:"space-between",alignItems:"baseline"},children:[typeof L.title=="string"?e.jsx(B.Text,{color:"subtle",fontWeight:"medium",style:{color:Bn,flexShrink:0},children:L.title}):e.jsx("div",{style:{flexShrink:0},children:L.title}),de]},X)}),mt=(C,D)=>{const L=Bt?wt(Bt.col,C,D):null;return typeof L=="string"||typeof L=="number"?e.jsx(B.Text,{as:"span",style:Wr,children:L}):e.jsx("span",{style:Wr,children:L})},gi=e.jsx(u.Box,{style:{display:"flex",flexDirection:"column",gap:8,padding:8},children:Array.from({length:V},(C,D)=>e.jsxs(u.Box,{style:{border:Or,borderRadius:"var(--sa-radii-sm, 6px)",padding:12,display:"flex",flexDirection:"column",gap:8},children:[e.jsx(We.Skeleton,{height:16,width:"60%",borderRadius:"rounded-sm"}),e.jsx(We.Skeleton,{height:12,width:"85%",borderRadius:"rounded-sm"}),e.jsx(We.Skeleton,{height:12,width:"70%",borderRadius:"rounded-sm"})]},`sa-tl-sk-card-${D}`))}),to=e.jsx(u.Box,{fullWidth:!0,style:{minHeight:(k==null?void 0:k.minHeight)??320,display:"flex",alignItems:"center",justifyContent:"center",padding:16},children:k==null?void 0:k.content}),ui=S?gi:H.length===0?to:v==="expand"?e.jsx(u.Box,{style:{display:"flex",flexDirection:"column"},children:H.map((C,D)=>{const L=Je(C,D),X=R.has(L),de=w&&Ye.has(L)?ft:Ar(n==null?void 0:n(C,D));return e.jsxs("div",{style:{borderBottom:Or,backgroundColor:de},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center"},children:[w&&e.jsx("div",{style:{display:"flex",alignItems:"center",paddingLeft:12,flexShrink:0},children:e.jsx(Ze.Checkbox,{size:"sm",checked:Ye.has(L),disabled:!Ct(C,D),onChange:()=>vt(L),"aria-label":"Pilih baris"})}),e.jsxs("button",{type:"button",onClick:()=>fi(L),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:[mt(C,D),e.jsx(E.Icon,{name:X?"ChevronUp":"ChevronDown",size:"sm",style:{flexShrink:0}})]}),oe&&si(C,D)]}),X&&e.jsx("div",{style:{padding:"0 12px 12px",display:"flex",flexDirection:"column",gap:6},children:ro(C,D)})]},L)})}):e.jsx(u.Box,{style:{display:"flex",flexDirection:"column",gap:8,padding:8},children:H.map((C,D)=>{const L=Je(C,D),X=w&&Ye.has(L);return e.jsxs(u.Box,{style:{border:Or,borderRadius:"var(--sa-radii-sm, 6px)",padding:12,display:"flex",flexDirection:"column",gap:6,backgroundColor:X?ft:Ar(n==null?void 0:n(C,D))},children:[w?e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[e.jsx(Ze.Checkbox,{size:"sm",checked:Ye.has(L),disabled:!Ct(C,D),onChange:()=>vt(L),"aria-label":"Pilih baris"}),e.jsx("div",{style:{flex:1,minWidth:0},children:mt(C,D)})]}):mt(C,D),ro(C,D),oe&&ii(C,D)]},L)})}),yi=c&&_&&pe!==void 0,lo=s==="fixed"&&!c&&(_?pe!==void 0:!0),pi=lo&&!_,bi=e.jsxs(Z.Table,{className:"sa-table-layout",fullWidth:!0,size:o,resizable:yi,style:lo?{tableLayout:"fixed"}:void 0,onWidthsChange:$?Fe:void 0,children:[pi&&e.jsxs("colgroup",{children:[w&&e.jsx("col",{style:{width:Cr}}),ye.map(({col:C,key:D},L)=>e.jsx("col",{style:{width:Qe(C,L)}},`col-${D}`)),oe&&e.jsx("col",{style:{width:1}})]}),e.jsx(Z.Thead,{ref:Ee,children:_e?e.jsxs(e.Fragment,{children:[e.jsxs(Z.Tr,{children:[w&&eo({rowSpan:2}),He.map(C=>C.isGroup?e.jsx(Z.Th,{colSpan:C.leaves.length,style:{textAlign:"center",position:"sticky",top:0,zIndex:2,backgroundColor:ar},children:e.jsx("span",{style:Wr,children:C.col.title})},`grp-${C.key}`):St(C.leaves[0],{rowSpan:2})),oe&&e.jsx(Z.Th,{rowSpan:2,style:{position:"sticky",top:0,right:0,zIndex:3,width:1,padding:0,border:"none",backgroundColor:ar}})]}),e.jsx(Z.Tr,{children:He.flatMap(C=>C.isGroup?C.leaves.map(D=>St(D,{top:er})):[])})]}):e.jsxs(Z.Tr,{children:[w&&eo(),ai(),oe&&e.jsx(Z.Th,{style:{position:"sticky",top:0,right:0,zIndex:3,width:1,padding:0,border:"none",backgroundColor:ar}})]})}),e.jsx(Z.Tbody,{children:S?li:H.length===0?e.jsx(Z.Tr,{children:e.jsx(Z.Td,{colSpan:Dt,children:to})}):e.jsxs(e.Fragment,{children:[H.map((C,D)=>{const L=m==null?void 0:m(C,D,D>0?H[D-1]:void 0),te=w&&Ye.has(Je(C,D))?ft:Ar(n==null?void 0:n(C,D));return e.jsxs(h.Fragment,{children:[L!=null&&L!==!1&&e.jsx(Z.Tr,{children:e.jsx(Z.Td,{colSpan:Dt,style:{backgroundColor:ar},children:L})}),e.jsxs(Z.Tr,{children:[w&&di(C,D,te),ye.map(({col:de,key:se},Ce)=>{var no;const ve=(no=de.cellProps)==null?void 0:no.call(de,C,D,H);if(ve!=null&&ve.hidden)return null;const Ie=fr(Ce),xr=Ie&&Ce===hr,qe=wt(de,C,D),wr=typeof de.bg=="function"?de.bg(C,D,H):de.bg,oo=Ar(wr)??te;return e.jsx(Z.Td,{className:Ie?"sa-tl-frozen":void 0,colSpan:ve==null?void 0:ve.colSpan,rowSpan:ve==null?void 0:ve.rowSpan,style:{textAlign:zr(de.align),width:Qe(de,Ce),minWidth:de.minWidth,position:Ie?"sticky":void 0,left:Ie?Ul(Ce):void 0,zIndex:Ie?1:void 0,boxShadow:xr?zl:void 0,...oo?{"--sa-tl-bg":oo}:{}},children:typeof qe=="string"?e.jsx(B.Text,{style:{whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",textAlign:zr(de.align)},children:qe}):qe},`tl-cell-${D}-${se}`)}),oe&&e.jsx(Z.Td,{style:{position:"sticky",right:0,width:1,padding:0,overflow:"visible",zIndex:2,border:"none"},children:ci(C,D)})]})]},Je(C,D))}),O!=null&&e.jsx(Z.Tr,{children:e.jsx(Z.Td,{colSpan:Dt,children:O})})]})})]}),Ft=re?H.findIndex((C,D)=>Je(C,D)===re.rowKey):-1,Et=Ft>=0?H[Ft]:null;return e.jsxs(e.Fragment,{children:[e.jsx(u.Box,{ref:pt,fullWidth:!0,style:{overflow:"auto",height:T??Kc},children:le?ui:bi}),re&&Et&&e.jsx("div",{className:"sa-tl-kebab-menu",style:{top:re.top,right:re.right},onClick:C=>C.stopPropagation(),children:Zr(Et).map(C=>e.jsx("div",{style:{padding:"2px 4px"},children:Gr(C,Et,Ft,{showLabel:!0,size:"sm"})},C.key))})]})},gt=r=>r==="asc"||r==="desc",Tn=(r={})=>{const{sortKeyParam:t="sortBy",sortOrderParam:l="sortOrder",pageKey:n="page",defaultSort:o=null,paramKeys:c,scopeId:s,storage:i=nt}=r,{searchParams:a,setSearchParams:d,searchQueries:y}=me(),b=a.toString(),p=s?sr.tableSort(s):void 0,x=h.useRef(!1);h.useEffect(()=>{if(x.current||(x.current=!0,!p)||a.has(t)||a.has(l))return;const k=i.get(p);!(k!=null&&k.key)||!gt(k.direction)||d({...Object.fromEntries(a.entries()),[t]:k.key,[l]:k.direction})},[]);const T=h.useMemo(()=>{const k=a.get(t),S=a.get(l);return k&>(S)?{key:k,direction:S}:o},[b,t,l,o]);h.useEffect(()=>{if(!p)return;const k=a.get(t),S=a.get(l);k&>(S)?i.set(p,{key:k,direction:S}):i.remove(p)},[b,p,t,l,i]);const v=(c==null?void 0:c.sortBy)??"sortBy",I=(c==null?void 0:c.sortOrder)??"sortOrder",m=h.useMemo(()=>T?{[v]:T.key,[I]:T.direction}:{},[T,v,I]),O=h.useCallback(k=>{const S={...y};k?(S[t]=k.key,S[l]=k.direction):(delete S[t],delete S[l]),delete S[n],d(S)},[y,t,l,n,d]);return{sort:T,setSort:O,params:m}},Hr=({of:r,render:t})=>h.Children.toArray(r==null?void 0:r.map((l,n,o)=>t(l,n,o))),ce=({condition:r,fallback:t,children:l,loading:n,isLoading:o})=>e.jsx(e.Fragment,{children:o?n:r?l:t}),he=r=>e.jsx(B.Text,{...r,fontFamily:"Poppins",fontSize:r.fontSize||"md",fontWeight:r.fontWeight||"medium",color:r.color||"gray-700",children:r.children}),Ue=r=>e.jsx(B.Text,{color:"red-600",fontSize:"sm",children:r.message}),In=({size:r="md",direction:t="vertical",requiredTitle:l="(Required)",fullWidth:n=!1,...o})=>{var i,a,d;const c=o.hideMessageError||!1,s=t==="horizontal"?r==="sm"?342:r==="lg"?400:342:void 0;return e.jsxs(u.Box,{gap:t==="horizontal"?"spacing-96":"sm",direction:t==="horizontal"?"row":"column",...o.containerProps,children:[o.title&&e.jsx(ce,{condition:!!o.inputProps.required,fallback:e.jsxs(u.Box,{direction:"column",customMaxWidth:s,fullWidth:n,children:[e.jsx(he,{children:o.title}),e.jsx(B.Text,{fontSize:r,color:"gray-500",children:o.description})]}),children:e.jsxs(u.Box,{direction:"column",customMaxWidth:s,fullWidth:n,children:[e.jsxs(ne.Flex,{direction:"row",gap:"xs",align:"center",children:[e.jsx(he,{fontSize:r,children:o.title}),e.jsx(he,{color:"error",fontSize:r,children:l}),e.jsx(ce,{condition:!!((i=o.tooltip)!=null&&i.label),children:e.jsx(ke.Tooltip,{label:(a=o.tooltip)==null?void 0:a.label,arrowPosition:(d=o.tooltip)==null?void 0:d.arrowPosition,...o.tooltip,children:e.jsx(E.Icon,{name:"InfoCircle",size:r==="lg"?"sm":"xs",style:{color:"var(--sa-color-info-500, #00abeb)",marginTop:"6px"}})})})]}),e.jsx(ce,{condition:!!o.description,children:e.jsx(B.Text,{fontSize:r,color:"gray-500",children:o.description})})]})}),e.jsxs(u.Box,{direction:"column",gap:"xs",fullWidth:o.inputProps.fullWidth||!1,children:[e.jsx(Ke.Input,{ref:o.inputRef,size:r,...o.inputProps,status:o.errorMessage?"error":"default",fullWidth:!0}),!c&&o.errorMessage&&e.jsx(Ue,{message:o.errorMessage}),o.inputProps.extended&&o.inputProps.extended]})]})},On=({size:r="md",direction:t="vertical",requiredTitle:l="(Required)",fullWidth:n=!1,...o})=>{var i,a,d;const c=o.hideMessageError||!1,s=t==="horizontal"?r==="sm"?342:r==="lg"?400:342:void 0;return e.jsxs(u.Box,{gap:t==="horizontal"?"spacing-96":"sm",direction:t==="horizontal"?"row":"column",onClick:o.onClickContainer,children:[o.title&&e.jsx(ce,{condition:!!o.inputProps.required,fallback:e.jsxs(u.Box,{direction:"column",customMaxWidth:s,fullWidth:n,children:[e.jsx(he,{children:o.title}),e.jsx(B.Text,{fontSize:r,color:"gray-500",children:o.description})]}),children:e.jsxs(u.Box,{direction:"column",customMaxWidth:s,fullWidth:n,children:[e.jsxs(ne.Flex,{direction:"row",gap:"xs",align:"center",children:[e.jsx(he,{fontSize:r,children:o.title}),e.jsx(he,{color:"error",fontSize:r,children:l}),e.jsx(ce,{condition:!!((i=o.tooltip)!=null&&i.label),children:e.jsx(ke.Tooltip,{label:(a=o.tooltip)==null?void 0:a.label,arrowPosition:(d=o.tooltip)==null?void 0:d.arrowPosition,...o.tooltip,children:e.jsx(E.Icon,{name:"InfoCircle",size:r==="lg"?"sm":"xs",style:{color:"var(--sa-color-info-500, #00abeb)",marginTop:"6px"}})})})]}),e.jsx(ce,{condition:!!o.description,children:e.jsx(B.Text,{fontSize:r,color:"gray-500",children:o.description})})]})}),e.jsxs(u.Box,{direction:"column",gap:"xs",fullWidth:o.inputProps.fullWidth||!1,children:[e.jsx(u.Box,{direction:"column",style:{width:o.inputProps.fullWidth?"100%":t==="horizontal"&&o.customWidth?o.customWidth:t==="horizontal"?"343px":""},children:e.jsx(or.Dropdown,{size:r,...o.inputProps,error:!!o.errorMessage})}),!c&&o.errorMessage&&e.jsx(Ue,{message:o.errorMessage}),o.inputProps.extended&&o.inputProps.extended]})]})},Wn=(r,t)=>typeof r=="string"&&r||t==="error"?"var(--sa-border-danger)":"var(--sa-border-subtle)",zn=r=>{var i;const[t,l]=h.useState(!1),n=a=>{a.preventDefault(),a.stopPropagation()},o=a=>{a.preventDefault(),a.stopPropagation(),a.dataTransfer&&r.handleOnFileChange(a.dataTransfer.files.item(0))},c=a=>{a.preventDefault(),l(!0)},s=a=>{a.preventDefault(),l(!1)};return e.jsxs(u.Box,{width:"width-full",paddingInline:"md",direction:"row",gap:"sm",align:"center",onClick:r.handleOnClick,onDragOver:n,onDrop:o,onDragEnter:c,onDragLeave:s,paddingBlock:"md",borderRadius:"rounded-md",style:{border:t?"1px solid var(--sa-border-info)":`1px solid ${Wn(r.errorMessage,r.status)}`},children:[e.jsx(E.Icon,{name:"Upload",size:"lg",style:{width:30,height:30}}),e.jsxs(ne.Flex,{direction:"column",gap:"xs",children:[e.jsxs(ne.Flex,{direction:"row",gap:"xs",children:[e.jsx(B.Text,{fontWeight:"medium",color:"gray-500",style:{textWrap:"nowrap"},fontSize:r.isDesktop?"md":"sm",children:"Click your upload"}),e.jsx(B.Text,{fontWeight:"medium",style:{textWrap:"nowrap"},fontSize:r.isDesktop?"md":"sm",children:"or Drag & Drop"})]}),e.jsx(B.Text,{fontSize:"sm",color:"gray-500",children:(i=r.fileSupports)==null?void 0:i.map(a=>a.toLocaleUpperCase()).join(", ")})]})]})};function An(r){return r.split(" ").map(t=>t[0]).join("").slice(0,2).toUpperCase()}const Hl=r=>{const t={day:"2-digit",month:"short",year:"numeric"};return r.toLocaleDateString("id-ID",t)},Hn=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},l=r.split(" ");if(l.length!==3)return null;const n=parseInt(l[0],10),o=t[l[1]],c=parseInt(l[2],10);return isNaN(n)||isNaN(o)||isNaN(c)?null:new Date(c,o,n)};function Vn(r,t=!0){if(!r)return"Rp 0";const l=typeof r=="number"?r.toString():r;if(isNaN(Number(l)))return"Rp 0";const n=l.split("."),o=n[0].replace(/\B(?=(\d{3})+(?!\d))/g,"."),c=n.length===2?o+"."+n[1]:o;return t?"Rp"+c:c}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 jn=r=>{const t=r.split(" ");let l=t[0].charAt(0);return t.length>1&&(l+=""+t[1].charAt(0)),l.toUpperCase()};function Pn(r){const t=typeof r=="string"?new Date(r):r;if(isNaN(t.getTime()))throw new Error("Invalid date format");const l=t.getFullYear(),n=String(t.getMonth()+1).padStart(2,"0"),o=String(t.getDate()).padStart(2,"0");return`${l}-${n}-${o}`}const Nn="sa-admin",Ve=r=>`var(--${Nn}-${r})`,_n={base:{borderColor:Ve("base-border-color"),textColor:Ve("base-text-color"),iconColor:Ve("base-icon-color"),placeholderColor:Ve("base-placeholder-color")},document:{bgColor:Ve("document-bg-color")},sidebar:{bgColor:Ve("sidebar-bg-color"),borderColor:Ve("sidebar-border-color"),maxWidth:Ve("sidebar-max-width"),width:Ve("sidebar-width"),collapseWidth:Ve("sidebar-collapse-width"),collapseV2Width:Ve("sidebar-v2-collapse-width")}},qn=24*60*60*1e3,Zn=r=>{const t="14px poppins",n=document.createElement("canvas").getContext("2d");n.font=t;const o=n.measureText(r).width;return Number(Math.ceil(o))},Gn=/^[^\s@]+@[^\s@]+\.[^\s@]+$/,Qn=/--+/,Un=/-$/;function Jn(r,t){return JSON.stringify(r)!==JSON.stringify(t)}function Yn(r){return/^(?:\+62|62|0)8[1-9][0-9]{7,10}$/.test(r)}function Xn(r){return/^[A-Za-z\s]+$/.test(r)}const Kn=r=>{const t=/^[0-9]$/,l=["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)&&!l.includes(r.key)&&r.preventDefault()},$n=r=>{const t=/^[0-9]$/,l=["ArrowLeft","ArrowRight","ArrowUp","ArrowDown","Backspace","Delete","Enter","Tab"];(r.ctrlKey||r.metaKey)&&r.key==="v"||t.test(r.key)&&!l.includes(r.key)&&r.preventDefault()},Rn=r=>{const t=/^[0-9.]$/,l=["ArrowLeft","ArrowRight","ArrowUp","ArrowDown","Backspace","Delete","Enter","Tab"];(r.ctrlKey||r.metaKey)&&r.key==="v"||!t.test(r.key)&&!l.includes(r.key)&&r.preventDefault()},ec=r=>Gn.test(r);function rc(r){return!(Qn.test(r)||Un.test(r))}const tc=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 l=r.currentTarget.value;/^[0-9]$/.test(r.key)||r.key==="."&&!l.includes(".")||r.key==="-"&&l.length===0&&!l.includes("-")||t.includes(r.key)||r.preventDefault()},lc=r=>{const t=document.getElementById(r);if(t){const l=t.getBoundingClientRect(),n=window.scrollY+l.top-80;window.scrollTo({top:n,behavior:"smooth"})}};function oc(r){const t=r.toLowerCase();if(["kb","mb","gb"].find(c=>t.endsWith(c)))return r;const o=Number(r);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 nc(r){const t=r.split("/");return t[t.length-1]}const cc=r=>{var t,l;return e.jsxs(u.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(ne.Flex,{direction:"row",align:"center",gap:"sm",style:{flex:1,minWidth:0},children:[e.jsx(E.Icon,{name:"DocumentFilled",size:"lg",style:{color:"var(--sa-icon-brand)",width:30,height:30,flexShrink:0}}),e.jsxs(ne.Flex,{direction:"column",style:{minWidth:0,flex:1},children:[e.jsx(B.Text,{fontWeight:"bold",style:{textOverflow:"ellipsis",whiteSpace:"nowrap",overflow:"hidden"},children:r.defaultFile?nc(r.defaultFile.url):(t=r.fileSelected)==null?void 0:t.name}),r.defaultFile?(r.defaultFile.size||r.defaultFile.date)&&e.jsxs(ne.Flex,{direction:"row",gap:"xs",align:"center",children:[r.defaultFile.size&&e.jsx(B.Text,{fontSize:"sm",fontWeight:"medium",children:r.defaultFile.size}),r.defaultFile.size&&r.defaultFile.date&&e.jsx(E.Icon,{name:"Dot",size:"xs"}),r.defaultFile.date&&e.jsx(B.Text,{fontSize:"sm",fontWeight:"medium",style:{textWrap:"nowrap"},children:r.defaultFile.date})]}):e.jsxs(ne.Flex,{direction:"row",gap:"xs",align:"center",children:[e.jsx(B.Text,{fontSize:"sm",fontWeight:"medium",children:oc(((l=r.fileSelected)==null?void 0:l.size.toString())||"100000")}),e.jsx(E.Icon,{name:"Dot",size:"xs"}),e.jsx(B.Text,{fontSize:"sm",fontWeight:"medium",style:{textWrap:"nowrap"},children:Hl(new Date)})]})]})]}),e.jsx(P.Button,{size:"xs",variant:"tertiary",tone:"error",type:"button",onClick:n=>{n.stopPropagation(),r.handleOnDeleteFile()},iconLeft:e.jsx(E.Icon,{name:"Trash1"})})]})},Vl=({status:r="default",labelPosition:t="outside-top",...l})=>{var p;const n=h.useRef(null),o=()=>{if(l.defaultFile){window.open(l.defaultFile.url);return}n.current&&n.current.click()},c=xe.useMediaQuery("md"),s=r==="error"||typeof l.errorMessage=="string"&&!!l.errorMessage,i=l.label?e.jsxs(ne.Flex,{direction:"row",align:"center",gap:"xs",children:[e.jsx(B.Text,{style:{fontSize:"14px",fontWeight:500,color:"var(--sa-text-primary)"},children:l.label}),l.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"}),l.required&&e.jsx("span",{style:{fontSize:"14px",fontWeight:500,color:"var(--sa-text-error)"},children:"*"})]}):null,a=l.description?e.jsx(B.Text,{style:{fontSize:"12px",fontWeight:400,color:"var(--sa-text-subtlest, #6b6e76)",lineHeight:"18px"},children:l.description}):null,d=e.jsxs(e.Fragment,{children:[l.helperText&&e.jsx(B.Text,{style:{fontSize:"12px",fontWeight:400,color:"var(--sa-text-subtlest, #6b6e76)",lineHeight:"18px"},children:l.helperText}),l.errorText&&r==="error"&&e.jsx(B.Text,{style:{fontSize:"12px",fontWeight:400,color:"var(--sa-text-error, #a4133c)",lineHeight:"18px"},children:l.errorText}),l.errorMessage&&!l.errorText&&e.jsx(B.Text,{style:{fontSize:"12px",fontWeight:400,color:"var(--sa-text-error, #a4133c)",lineHeight:"18px"},children:l.errorMessage})]}),y=e.jsx("input",{type:"file",style:{display:"none"},ref:n,onChange:x=>{var T;return l.handleOnChangeFile(((T=x.target.files)==null?void 0:T.item(0))||null)},accept:(p=l.fileSupportOption)==null?void 0:p.map(x=>"."+(x==null?void 0:x.toLowerCase())).join(", ")}),b=e.jsxs(u.Box,{direction:"column",fullWidth:!0,style:{minHeight:"69px"},borderRadius:"rounded-md",display:"flex",justify:"center",align:"center",cursor:"pointer",gap:"md",...l.containerProps,children:[y,(l.fileSelected||l.defaultFile)&&e.jsx(cc,{fileSelected:l.fileSelected,defaultFile:l.defaultFile,handleOnDeleteFile:l.handleOnDeleteFile,handleOnClickFile:o}),!l.fileSelected&&!l.defaultFile&&e.jsx(zn,{fileSupports:l.fileSupportOption,isDesktop:c,errorMessage:s?l.errorText||l.errorMessage||" ":void 0,status:s?"error":"default",handleOnClick:o,handleOnFileChange:l.handleOnChangeFile})]});return t==="outside-left"?e.jsxs(ne.Flex,{direction:"row",align:"flex-start",gap:"sm",style:{width:"100%"},children:[e.jsxs(ne.Flex,{direction:"column",gap:"xs",style:{width:"40%",minWidth:"120px",paddingTop:"10px"},children:[i,a]}),e.jsxs(ne.Flex,{direction:"column",gap:"sm",style:{flex:1,minWidth:0},children:[b,d]})]}):e.jsxs(ne.Flex,{direction:"column",gap:"sm",style:{width:"100%"},children:[i,a,b,d]})},ic=({size:r="md",direction:t="vertical",requiredTitle:l="(Required)",fullWidth:n=!1,...o})=>{var i,a,d;const c=o.hideMessageError||!1,s=t==="horizontal"?r==="sm"?342:r==="lg"?400:342:void 0;return e.jsxs(u.Box,{gap:t==="horizontal"?"spacing-96":"sm",direction:t==="horizontal"?"row":"column",...o.containerProps,children:[o.title&&e.jsx(ce,{condition:!!o.inputProps.required,fallback:e.jsxs(u.Box,{direction:"column",customMaxWidth:s,fullWidth:n,children:[e.jsx(he,{children:o.title}),e.jsx(B.Text,{fontSize:r,color:"gray-500",children:o.description})]}),children:e.jsxs(u.Box,{direction:"column",customMaxWidth:s,fullWidth:n,children:[e.jsxs(ne.Flex,{direction:"row",gap:"xs",align:"center",children:[e.jsx(he,{fontSize:r,children:o.title}),e.jsx(he,{color:"error",fontSize:r,children:l}),e.jsx(ce,{condition:!!((i=o.tooltip)!=null&&i.label),children:e.jsx(ke.Tooltip,{label:(a=o.tooltip)==null?void 0:a.label,arrowPosition:(d=o.tooltip)==null?void 0:d.arrowPosition,...o.tooltip,children:e.jsx(E.Icon,{name:"InfoCircle",size:r==="lg"?"sm":"xs",style:{color:"var(--sa-color-info-500, #00abeb)",marginTop:"6px"}})})})]}),e.jsx(ce,{condition:!!o.description,children:e.jsx(B.Text,{fontSize:r,color:"gray-500",children:o.description})})]})}),e.jsxs(ne.Flex,{direction:"column",gap:"xs",children:[e.jsx(Vl,{...o.inputProps,status:o.errorMessage?"error":"default"}),!c&&o.errorMessage&&e.jsx(Ue,{message:o.errorMessage})]})]})},sc=({size:r="md",direction:t="vertical",requiredTitle:l="(Required)",fullWidth:n=!1,required:o=!1,...c})=>{var a,d,y,b;const s=c.hideMessageError||!1,i=t==="horizontal"?r==="sm"?342:r==="lg"?400:342:void 0;return e.jsxs(u.Box,{gap:t==="horizontal"||t==="horizontal-inline"?"spacing-96":"sm",direction:t==="horizontal"||t==="horizontal-inline"?"row":"column",...c.containerProps,children:[c.title&&e.jsx(ce,{condition:!!o,fallback:e.jsxs(u.Box,{direction:"column",customMaxWidth:i,fullWidth:n,children:[e.jsx(he,{children:c.title}),e.jsx(ze.Body3,{props:{color:"gray-500"},children:c.description})]}),children:e.jsxs(u.Box,{direction:"column",customMaxWidth:i,fullWidth:n,children:[e.jsxs(ne.Flex,{direction:"row",gap:"xs",align:"center",children:[e.jsx(he,{fontSize:r,children:c.title}),e.jsx(he,{color:"error",fontSize:r,children:l}),e.jsx(ce,{condition:!!((a=c.tooltip)!=null&&a.label),children:e.jsx(ke.Tooltip,{label:(d=c.tooltip)==null?void 0:d.label,arrowPosition:(y=c.tooltip)==null?void 0:y.arrowPosition,...c.tooltip,children:e.jsx(E.Icon,{name:"InfoCircle",size:r==="lg"?"sm":"xs",style:{color:"var(--sa-color-info-500, #00abeb)",marginTop:"6px"}})})})]}),e.jsx(ce,{condition:!!c.description,children:e.jsx(B.Text,{fontSize:r,color:"gray-500",children:c.description})})]})}),e.jsx(u.Box,{gap:t==="horizontal-inline"?"xl":"md",direction:t==="horizontal-inline"?"row":"column",align:"flex-start",children:e.jsx(Hr,{of:(b=c.checkBoxesList)==null?void 0:b.map(p=>({...p,isChecked:c.checkBoxesAreChecked.includes(p.id)})),render:p=>p.renderBadge?e.jsxs(u.Box,{direction:"row",justify:"space-between",gap:"lg",...c.badgeContainerProps,children:[e.jsx(Ze.Checkbox,{name:p.name,value:p.id,checked:p.isChecked,onChange:x=>c.onChecked(x.target.value,p),label:p.name,description:p.description}),p.renderBadge]}):e.jsx(Ze.Checkbox,{name:p.name,value:p.id,checked:p.isChecked,onChange:x=>c.onChecked(x.target.value,p),label:p.name,description:p.description})})}),!s&&c.errorMessage&&e.jsx(Ue,{message:c.errorMessage})]})},ac=({position:r="vertical",size:t="md",fullWidth:l=!1,...n})=>{var c;const o=r==="horizontal-inline"||r==="horizontal-block"?t==="sm"?342:t==="lg"?400:342:void 0;return e.jsxs(u.Box,{gap:r==="horizontal-inline"||r==="horizontal-block"?"spacing-96":"sm",direction:r==="horizontal-inline"||r==="horizontal-block"?"row":"column",children:[e.jsx(ce,{condition:!!n.description||!!n.title,children:e.jsxs(u.Box,{direction:"column",customMaxWidth:o,fullWidth:l,children:[n.title&&e.jsx(he,{children:n.title}),e.jsx(ce,{condition:!!n.description,children:e.jsx(B.Text,{color:"gray-500",children:n.description})})]})}),e.jsx(u.Box,{gap:"sm",direction:r==="horizontal"||r==="horizontal-inline"?"row":"column",align:"flex-start",flexWrap:"wrap",children:e.jsx(Hr,{of:(c=n.radioList)==null?void 0:c.map(s=>({...s,isChecked:n.radioIsChecked===s.id})),render:({value:s,id:i,isChecked:a,subInput:d,label:y,description:b})=>e.jsxs(u.Box,{direction:"column",gap:"xs",customMaxWidth:o,children:[e.jsx(Ur.Radio,{id:`${i.toString()}-${s}`,name:n.groupName||y,label:y,value:s,checked:a,onChange:p=>n.onChecked({id:i,label:p.target.name,value:p.target.value}),disabled:n.disableAll},i),b&&e.jsx(B.Text,{color:"gray-500",style:{marginLeft:28},children:b}),d]})})}),n.errorMessage&&e.jsx(Ue,{message:n.errorMessage})]})},dc=({size:r="md",direction:t="vertical",requiredTitle:l="(Required)",fullWidth:n=!1,...o})=>{var i,a,d;const c=o.hideMessageError||!1,s=t==="horizontal"?r==="sm"?342:r==="lg"?400:342:void 0;return e.jsxs(u.Box,{gap:t==="horizontal"?"spacing-96":"sm",direction:t==="horizontal"?"row":"column",...o.containerProps,children:[o.title&&e.jsx(ce,{condition:!!o.inputProps.required,fallback:e.jsxs(u.Box,{direction:"column",customMaxWidth:s,fullWidth:n,children:[e.jsx(he,{children:o.title}),e.jsx(B.Text,{fontSize:r,color:"gray-500",children:o.description})]}),children:e.jsxs(u.Box,{direction:"column",customMaxWidth:s,fullWidth:n,children:[e.jsxs(ne.Flex,{direction:"row",gap:"xs",align:"center",children:[e.jsx(he,{fontSize:r,children:o.title}),e.jsx(he,{color:"error",fontSize:r,children:l}),e.jsx(ce,{condition:!!((i=o.tooltip)!=null&&i.label),children:e.jsx(ke.Tooltip,{label:(a=o.tooltip)==null?void 0:a.label,arrowPosition:(d=o.tooltip)==null?void 0:d.arrowPosition,...o.tooltip,children:e.jsx(E.Icon,{name:"InfoCircle",size:r==="lg"?"sm":"xs",style:{color:"var(--sa-color-info-500, #00abeb)",marginTop:"6px"}})})})]}),e.jsx(ce,{condition:!!o.description,children:e.jsx(B.Text,{fontSize:r,color:"gray-500",children:o.description})})]})}),e.jsxs(ne.Flex,{direction:"column",gap:"xs",children:[e.jsx(Qr.Textarea,{ref:o.inputRef,size:r,...o.inputProps,status:o.errorMessage?"error":"default"}),!c&&o.errorMessage&&e.jsx(Ue,{message:o.errorMessage})]})]})},hc=({size:r="md",direction:t="vertical",requiredTitle:l="(Required)",required:n=!1,fullWidth:o=!1,...c})=>{var i,a,d;const s=t==="horizontal"?r==="sm"?342:r==="lg"?400:342:void 0;return e.jsxs(u.Box,{gap:t==="horizontal"?"spacing-96":"sm",direction:t==="horizontal"?"row":"column",...c.containerProps,children:[c.title&&e.jsx(ce,{condition:n,fallback:e.jsxs(u.Box,{direction:"column",customMaxWidth:s,fullWidth:o,children:[e.jsx(he,{children:c.title}),e.jsx(B.Text,{fontSize:r,color:"gray-500",children:c.titleDescription})]}),children:e.jsxs(u.Box,{direction:"column",customMaxWidth:s,fullWidth:o,children:[e.jsxs(ne.Flex,{direction:"row",gap:"xs",align:"center",children:[e.jsx(he,{fontSize:r,children:c.title}),e.jsx(he,{color:"error",fontSize:r,children:l}),e.jsx(ce,{condition:!!((i=c.tooltip)!=null&&i.label),children:e.jsx(ke.Tooltip,{label:(a=c.tooltip)==null?void 0:a.label,arrowPosition:(d=c.tooltip)==null?void 0:d.arrowPosition,...c.tooltip,children:e.jsx(E.Icon,{name:"InfoCircle",size:r==="lg"?"sm":"xs",style:{color:"var(--sa-color-info-500, #00abeb)",marginTop:"6px"}})})})]}),e.jsx(ce,{condition:!!c.titleDescription,children:e.jsx(B.Text,{fontSize:r,color:"gray-500",children:c.titleDescription})})]})}),e.jsx(ir.Toggle,{checked:c.checked,onChange:c.onChange,label:c.label,description:c.description}),c.errorMessage&&e.jsx(Ue,{message:c.errorMessage})]})},fc=({variant:r="primary",size:t="md",...l})=>{const n=cr.useColor(),o=s=>{var a,d,y,b,p,x;if(!s)return;const i=l.disabled?"var(--sa-text-disable, #181a198f)":r==="secondary"?"var(--sa-text-subtle, #8c8f97)":r==="secondary-danger"?(d=(a=n==null?void 0:n.computed)==null?void 0:a.red)==null?void 0:d[600]:r==="secondary-primary"?(b=(y=n==null?void 0:n.computed)==null?void 0:y.blue)==null?void 0:b[700]:(x=(p=n==null?void 0:n.computed)==null?void 0:p.gray)==null?void 0:x[50];return e.jsx(E.Icon,{name:s,size:t,style:{color:i}})},c=()=>{var i,a,d,y;if(r!=="secondary-danger"&&r!=="secondary-primary")return l.title;const s={color:l.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=(d=n==null?void 0:n.computed)==null?void 0:d.blue)==null?void 0:y[700]};switch(t){case"xs":return e.jsx(ze.Body2,{props:{style:s},children:l.title});case"sm":case"md":return e.jsx(ze.SubH3,{props:{style:s},children:l.title});case"lg":return e.jsx(ze.SubH2,{props:{style:s},children:l.title});default:return l.title}};return e.jsx(P.Button,{fullWidth:!0,disabled:l.disabled,primary:r==="primary",secondary:r==="secondary"||r==="secondary-danger"||r==="secondary-primary",success:r==="success",onClick:l.onClick,type:l.type,iconLeft:o(l.iconLeft),iconRight:o(l.iconRight),size:t,children:c()})},gc=r=>e.jsx(ze.H5,{props:{...r},children:r.title}),uc=({size:r="md",direction:t="vertical",requiredTitle:l="(Required)",fullWidth:n=!1,...o})=>{var i,a,d;const c=o.hideMessageError||!1,s=t==="horizontal"?r==="sm"?342:r==="lg"?400:342:void 0;return e.jsxs(u.Box,{gap:t==="horizontal"?"spacing-96":"sm",direction:t==="horizontal"?"row":"column",onClick:o.onClickContainer,children:[o.title&&e.jsx(ce,{condition:!!o.inputProps.required,fallback:e.jsxs(u.Box,{direction:"column",customMaxWidth:s,fullWidth:n,children:[e.jsx(he,{children:o.title}),e.jsx(B.Text,{fontSize:r,color:"gray-500",children:o.description})]}),children:e.jsxs(u.Box,{direction:"column",customMaxWidth:s,fullWidth:n,children:[e.jsxs(ne.Flex,{direction:"row",gap:"xs",align:"center",children:[e.jsx(he,{fontSize:r,children:o.title}),e.jsx(he,{color:"error",fontSize:r,children:l}),e.jsx(ce,{condition:!!((i=o.tooltip)!=null&&i.label),children:e.jsx(ke.Tooltip,{label:(a=o.tooltip)==null?void 0:a.label,arrowPosition:(d=o.tooltip)==null?void 0:d.arrowPosition,...o.tooltip,children:e.jsx(E.Icon,{name:"InfoCircle",size:r==="lg"?"sm":"xs",style:{color:"var(--sa-color-info-500, #00abeb)",marginTop:"6px"}})})})]}),e.jsx(ce,{condition:!!o.description,children:e.jsx(B.Text,{fontSize:r,color:"gray-500",children:o.description})})]})}),e.jsxs(ne.Flex,{direction:"column",gap:"xs",children:[e.jsx(u.Box,{direction:"column",style:{width:t==="horizontal"&&o.customWidth?o.customWidth:t==="horizontal"?"343px":""},children:e.jsx($e.StarasiaDate,{size:r,...o.inputProps,status:o.errorMessage?"error":void 0})}),!c&&o.errorMessage&&e.jsx(Ue,{message:o.errorMessage})]})]})};async function yc(r,t){const l=new Image;l.src=r,await new Promise((c,s)=>{l.onload=c,l.onerror=s});const n=document.createElement("canvas");n.width=t.width,n.height=t.height;const o=n.getContext("2d",{alpha:!0});if(!o)throw new Error("No 2D context");return o.drawImage(l,t.x,t.y,t.width,t.height,0,0,t.width,t.height),new Promise((c,s)=>{n.toBlob(i=>{if(!i)return s("Canvas is empty");const a=new File([i],"cropped.png",{type:"image/png"});c(a)},"image/png")})}const jl={"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},Pl=h.forwardRef(({handleUpload:r,urlImage:t,isUploading:l,croppedImage:n,setCroppedImage:o,size:c="96",aspect:s="1:1",containerProps:i,maxFileSize:a=2,onError:d},y)=>{const b=xe.useMediaQuery("md"),[p,x]=h.useState(!1),[T,v]=h.useState(null),[I,m]=h.useState(!1),[O,k]=h.useState({x:0,y:0}),[S,V]=h.useState(1),[A,w]=h.useState(null);h.useEffect(()=>{t===null&&o(null)},[t]);const M=h.useCallback((R,J)=>{w(J)},[]),q=R=>{var ae;const J=(ae=R.target.files)==null?void 0:ae[0];if(!J)return;const fe=new FileReader;fe.onload=()=>{v(fe.result),m(!0)},fe.readAsDataURL(J)},j=async()=>{if(!(!T||!A))try{const R=await yc(T,A);if(a&&R.size>a*1024*1024){d==null||d(`Ukuran file maksimal ${a}MB`);return}r==null||r(R);const J=URL.createObjectURL(R);o(J,R),m(!1)}catch{d==null||d("Gagal memproses gambar")}},N=h.useRef(null),Y=()=>{N.current&&N.current.click()};h.useImperativeHandle(y,()=>({openFileDialog:()=>{var R;(R=N.current)==null||R.click()}}));const le=parseInt(c,10),oe=jl[s];let re,ie;return oe>=1?(ie=le,re=le*oe):(re=le,ie=le/oe),e.jsxs(u.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%":`${re}px`,height:i!=null&&i.fullWidth?"auto":`${ie}px`,aspectRatio:oe,flexShrink:0},onMouseEnter:()=>x(!0),onMouseLeave:()=>x(!1),children:[n||t?e.jsx("img",{src:n||t||void 0,alt:"Profile",style:{objectFit:"cover",width:"100%",height:"100%"}}):e.jsx(u.Box,{display:"flex",direction:"column",align:"center",justify:"center",padding:"spacing-4",children:e.jsx(E.Icon,{name:"Image",style:{color:"var(--sa-text-subtle, #8c8f97)",width:Number(c)/2<40?Number(c)/2:40,height:Number(c)/2<40?Number(c)/2:40}})}),e.jsxs(u.Box,{direction:"column",position:"absolute",display:"flex",align:"center",justify:"center",cursor:"pointer",style:{inset:0,backgroundColor:"var(--sa-color-black-alpha-a30, #080f214a)",opacity:p?1:0,transition:"opacity 0.3s ease-in-out"},onClick:Y,children:[e.jsx("input",{ref:N,type:"file",accept:"image/*",onChange:q,disabled:l,style:{display:"none"}}),e.jsxs(u.Box,{display:"flex",align:"center",gap:"spacing-2",direction:"row",children:[e.jsx(E.Icon,{name:"Edit3",style:{color:"var(--sa-background-primary, #ffffff)"}}),e.jsx(ce,{condition:c.toNumber()>80,children:e.jsx(B.Text,{color:"gray-50",fontSize:c.toNumber()>80?"sm":"md",fontWeight:"medium",children:"Edit Image"})})]})]}),l&&e.jsx(u.Box,{direction:"column",position:"absolute",display:"flex",align:"center",justify:"center",style:{inset:0,zIndex:20,backgroundColor:"var(--sa-color-white-alpha-a80, #e5e9f640)"},children:e.jsx(u.Box,{direction:"column",borderRadius:"rounded-full",style:{animation:"spin 1s linear infinite",border:"2px solid transparent",height:"2rem",width:"2rem"},borderColor:"info-600"})}),I&&Jr.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:()=>m(!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?s==="1:1"?"min(90vw, 480px)":`min(90vw, ${re*2}px)`:"calc(100vw - 2rem)",display:"flex",flexDirection:"column"},onClick:R=>R.stopPropagation(),children:[e.jsx("div",{style:{position:"relative",width:"100%",height:"20rem",backgroundColor:"var(--sa-color-gray-100)"},children:T&&e.jsx(co,{image:T,crop:O,zoom:S,aspect:s?jl[s]:void 0,onCropChange:k,onZoomChange:V,onCropComplete:M,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(P.Button,{size:"sm",secondary:!0,onClick:()=>m(!1),children:"Cancel"}),e.jsx(P.Button,{size:"sm",primary:!0,onClick:j,children:"Crop"})]})]})}),document.body)]})}),pc=({size:r="md",direction:t="vertical",requiredTitle:l="(Required)",fullWidth:n=!1,required:o=!1,...c})=>{var a,d,y;const s=c.hideMessageError||!1,i=t==="horizontal"?r==="sm"?342:r==="lg"?400:342:void 0;return e.jsxs(u.Box,{gap:t==="horizontal"?"spacing-96":"sm",direction:t==="horizontal"?"row":"column",...c.containerProps,children:[c.title&&e.jsx(ce,{condition:!!o,fallback:e.jsxs(u.Box,{direction:"column",customMaxWidth:i,fullWidth:n,children:[e.jsx(he,{children:c.title}),e.jsx(B.Text,{fontSize:r,color:"gray-500",children:c.description})]}),children:e.jsxs(u.Box,{direction:"column",customMaxWidth:i,fullWidth:n,children:[e.jsxs(ne.Flex,{direction:"row",gap:"xs",align:"center",children:[e.jsx(he,{fontSize:r,children:c.title}),e.jsx(he,{color:"error",fontSize:r,children:l}),e.jsx(ce,{condition:!!((a=c.tooltip)!=null&&a.label),children:e.jsx(ke.Tooltip,{label:(d=c.tooltip)==null?void 0:d.label,arrowPosition:(y=c.tooltip)==null?void 0:y.arrowPosition,...c.tooltip,children:e.jsx(E.Icon,{name:"InfoCircle",size:r==="lg"?"sm":"xs",style:{color:"var(--sa-color-info-500, #00abeb)",marginTop:"6px"}})})})]}),e.jsx(ce,{condition:!!c.description,children:e.jsx(B.Text,{fontSize:r,color:"gray-500",children:c.description})})]})}),e.jsxs(ne.Flex,{direction:"column",gap:"xs",children:[e.jsx(Pl,{...c.inputProps}),!s&&c.errorMessage&&e.jsx(Ue,{message:c.errorMessage})]})]})},bc=({size:r="md",direction:t="vertical",requiredTitle:l="(Required)",fullWidth:n=!1,...o})=>{var s,i,a;const c=t==="horizontal"?r==="sm"?342:r==="lg"?400:342:void 0;return e.jsxs(u.Box,{gap:t==="horizontal"?"spacing-96":"sm",direction:t==="horizontal"?"row":"column",...o.containerProps,children:[o.title&&e.jsx(ce,{condition:!!o.inputProps.required,fallback:e.jsxs(u.Box,{direction:"column",customMaxWidth:c,fullWidth:n,children:[e.jsx(he,{children:o.title}),e.jsx(B.Text,{fontSize:r,color:"gray-500",children:o.description})]}),children:e.jsxs(u.Box,{direction:"column",customMaxWidth:c,fullWidth:n,children:[e.jsxs(ne.Flex,{direction:"row",gap:"xs",align:"center",children:[e.jsx(he,{fontSize:r,children:o.title}),e.jsx(he,{color:"error",fontSize:r,children:l}),e.jsx(ce,{condition:!!((s=o.tooltip)!=null&&s.label),children:e.jsx(ke.Tooltip,{label:(i=o.tooltip)==null?void 0:i.label,arrowPosition:(a=o.tooltip)==null?void 0:a.arrowPosition,...o.tooltip,children:e.jsx(E.Icon,{name:"InfoCircle",size:r==="lg"?"sm":"xs",style:{color:"var(--sa-color-info-500, #00abeb)",marginTop:"6px"}})})})]}),e.jsx(ce,{condition:!!o.description,children:e.jsx(B.Text,{fontSize:r,color:"gray-500",children:o.description})})]})}),o.inputProps.extended&&o.inputProps.extended]})},Cc=({items:r,id:t,handleOnUpdate:l,width:n,toggleShow:o=!0,disabled:c=!1})=>{var y;const[s,i]=h.useState([]);h.useEffect(()=>{r&&i([...r.map(b=>({id:b.id,isActive:b.isActive}))])},[r]);const a=(y=s.find(b=>b.id===t))==null?void 0:y.isActive,d=h.useCallback(()=>{i(b=>b.map(p=>p.id===t?{...p,isActive:!p.isActive}:p)),l&&l(!a)},[t,l,a]);return e.jsx(u.Box,{direction:"row",gap:"md",style:{width:n},children:o&&e.jsx(ir.Toggle,{disabled:c,checked:a,onChange:d,label:a?"Active":"Inactive"})})},vc={InputText:In,InputDropdown:On,InputSingleFile:ic,CheckBoxOptions:sc,RadioOptions:ac,InputTextArea:dc,ToggleForm:hc,ActionButton:fc,FormTitle:gc,InputDate:uc,InputImgFile:pc,Custom:bc},Nl=({customBottom:r})=>{const[t,l]=h.useState(!1),n=()=>{window.scrollY>window.screenY?l(!0):l(!1)},o=()=>{window.scrollTo({top:0,behavior:"smooth"})};return h.useEffect(()=>(window.addEventListener("scroll",n),()=>{window.removeEventListener("scroll",n)}),[]),e.jsx(u.Box,{direction:"column",style:{position:"fixed",bottom:0,right:0},children:e.jsx(u.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(P.Button,{secondary:!0,size:"xs",onClick:o,type:"button",iconLeft:e.jsx(E.Icon,{width:16,size:"xs",name:"ArrowPullUp",style:{color:"var(--sa-background-brand, #04254f)"}})})})})},Me="sa-sidepanel-item",_l="sa-sidepanel-item-styles",xc=`
|
|
46
|
+
`,document.head.appendChild(r)},zr=r=>r==="right"?"right":r==="center"?"center":"left",Fn=/^(#|rgb|hsl|var\()/,Ar=r=>r?Fn.test(r)?r:`var(--sa-background-${r})`:void 0,En=(r,t)=>{if(t)return r[t]},Mn=(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)),Ln=({columns:r,data:t,getRowKey:l,rowBg:n,size:o="md",resizable:c=!1,layout:s="auto",widthStorageKey:i,columnState:a,onColumnStateChange:d,columnMenu:y=!1,sort:b,defaultSort:p,onSortChange:x,height:T,mobileLayout:v="cards",mobileBreakpoint:I="md",groupSeparator:m,summary:O,emptyState:k,loading:S=!1,loadingRows:V=8,rowActions:A,selectable:w=!1,selectedKeys:M,defaultSelectedKeys:q,onSelectionChange:j,isRowSelectable:N})=>{mn();const le=!xe.useMediaQuery(I)&&v!=="scroll",oe=!!(A!=null&&A.length),[re,ie]=h.useState(null);h.useEffect(()=>{if(!re)return;const C=()=>ie(null),D=setTimeout(()=>document.addEventListener("click",C),0);return()=>{clearTimeout(D),document.removeEventListener("click",C)}},[re]);const[R,J]=h.useState(()=>new Set),fe=a!==void 0,[ae,ge]=h.useState({}),be=a??ae,je=C=>{d==null||d(C),fe||ge(C)},Pe=b!==void 0,[Ne,Le]=h.useState(p??null),ue=Pe?b??null:Ne,Ae=!x,Ge=C=>{x==null||x(C),Pe||Le(C)},{headerGroups:He,leafColumns:ye,hasGroups:_e}=h.useMemo(()=>{var de;const C=new Set(be.hidden??[]),D=(se,Ce)=>se.key??(typeof se.accessor=="string"?se.accessor:`col-${Ce}`),L=r.map((se,Ce)=>{var Ie;if((Ie=se.children)!=null&&Ie.length){const xr=se.children.map((qe,wr)=>({col:qe,key:D(qe,`${Ce}-${wr}`)})).filter(qe=>!C.has(qe.key));return{col:se,key:se.key??`group-${Ce}`,isGroup:!0,leaves:xr}}const ve={col:se,key:D(se,`${Ce}`)};return{col:se,key:ve.key,isGroup:!1,leaves:C.has(ve.key)?[]:[ve]}}).filter(se=>se.leaves.length>0),X=L.some(se=>se.isGroup);let te=L.flatMap(se=>se.leaves);if(!X&&((de=be.order)!=null&&de.length)){const se=new Map(be.order.map((Ce,ve)=>[Ce,ve]));te=[...te].sort((Ce,ve)=>(se.get(Ce.key)??1/0)-(se.get(ve.key)??1/0))}return{headerGroups:L,leafColumns:te,hasGroups:X}},[r,be]),F=h.useMemo(()=>new Map(ye.map((C,D)=>[C.key,D])),[ye]),G=!_e&&ye.some(C=>(C.col.headerColSpan??1)>1),U=ye.map(C=>C.key).join("|"),W=(C,D)=>{const L=C.sortKey??(typeof C.accessor=="string"?C.accessor:void 0);return L?D[L]:void 0},Q=C=>C.sortable??(!!C.sortKey||typeof C.accessor=="string"),H=h.useMemo(()=>{if(!Ae||!ue)return t;const C=ye.find(L=>L.key===ue.key);if(!C)return t;const D=ue.direction==="asc"?1:-1;return[...t].sort((L,X)=>Mn(W(C.col,L),W(C.col,X))*D)},[t,Ae,ue,ye]),_=!_e&&!G,$=!!i&&_,[Se,Fe]=Z.useColumnWidths(i??""),Te=$?Se:void 0,Ee=h.useRef(null),[pe,dr]=h.useState();h.useLayoutEffect(()=>{dr(void 0)},[U]),h.useLayoutEffect(()=>{if(!_||pe||!Ee.current)return;const C=Ee.current.querySelectorAll("th.sa-tl-leaf");dr(Array.from(C).map(D=>D.offsetWidth))},[pe,_]);const[er,rr]=h.useState(0);h.useLayoutEffect(()=>{if(!_e||!Ee.current)return;const C=Ee.current.querySelector(":scope > tr");C&&rr(C.offsetHeight)},[_e,U]);const Qe=(C,D)=>{if((Te==null?void 0:Te[D])!=null)return Te[D];if(C.width!=null)return C.width;if((pe==null?void 0:pe[D])!=null)return pe[D]},qr=(C,D)=>typeof C.width=="number"?C.width:pe==null?void 0:pe[D],hr=be.frozenKey&&!_e&&!G?ye.findIndex(C=>C.key===be.frozenKey):-1,fr=C=>C<=hr,Ql=w?Cr:0,Ul=C=>{if(!pe)return Ql;let D=Ql;for(let L=0;L<C;L++)D+=pe[L]??0;return D},pt=h.useRef(null),[Kc,$c]=h.useState("100vh");h.useLayoutEffect(()=>{if(T!==void 0)return;const C=()=>{if(pt.current){const D=pt.current.getBoundingClientRect().top;$c(`calc(100vh - ${D}px)`)}};return C(),window.addEventListener("resize",C),()=>window.removeEventListener("resize",C)},[T]);const Je=(C,D)=>l?l(C,D):D,bt=M!==void 0,[Jl,Rc]=h.useState(()=>new Set(q??[])),Ye=h.useMemo(()=>bt?new Set(M):Jl,[bt,M,Jl]);h.useEffect(()=>{w&&!l&&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).")},[w,!l]);const Yl=C=>{if(bt||Rc(C),j){const D=H.filter((L,X)=>C.has(Je(L,X)));j(Array.from(C),D)}},Ct=(C,D)=>w&&(N?N(C,D):!0),vt=C=>{const D=new Set(Ye);D.has(C)?D.delete(C):D.add(C),Yl(D)},gr=h.useMemo(()=>w?H.map((C,D)=>({row:C,i:D,key:Je(C,D)})).filter(({row:C,i:D})=>N?N(C,D):!0).map(({key:C})=>C):[],[w,H,N,l]),Xl=gr.filter(C=>Ye.has(C)),xt=gr.length>0&&Xl.length===gr.length,Kl=Xl.length>0&&!xt,ei=()=>{const C=new Set(Ye);xt?gr.forEach(D=>C.delete(D)):gr.forEach(D=>C.add(D)),Yl(C)},wt=(C,D,L)=>C.render?C.render(D,L,H):En(D,C.accessor),Dt=ye.length+(w?1:0)+(oe?1:0),$l=["80%","55%","70%","45%","90%","60%"],ri=(C,D)=>$l[(C*7+D*3)%$l.length],ti=(C,D)=>e.jsx(We.Skeleton,{height:14,width:ri(C,D),borderRadius:"rounded-sm"}),li=Array.from({length:V},(C,D)=>e.jsxs(Z.Tr,{children:[w&&e.jsx(Z.Td,{style:{width:Cr,padding:0},children:e.jsx("div",{style:{display:"flex",justifyContent:"center"},children:e.jsx(We.Skeleton,{height:14,width:14,borderRadius:"rounded-sm"})})}),ye.map(({col:L,key:X},te)=>e.jsx(Z.Td,{style:{textAlign:zr(L.align)},children:ti(D,te)},`sa-tl-sk-${D}-${X}`)),oe&&e.jsx(Z.Td,{style:{width:1,padding:0,border:"none"}})]},`sa-tl-sk-${D}`)),oi=(C,D)=>{D||je({...be,hidden:[...be.hidden??[],C]})},ni=C=>je({...be,frozenKey:be.frozenKey===C?void 0:C}),Zr=C=>(A??[]).filter(D=>{var L;return!((L=D.hidden)!=null&&L.call(D,C))}),Rl={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)"},Gr=(C,D,L,X)=>{var Ie;const te=(Ie=C.disabled)==null?void 0:Ie.call(C,D),de=(X==null?void 0:X.showLabel)??C.showLabel,se=(X==null?void 0:X.size)??"xs",Ce=e.jsx(P.Button,{size:se,variant:C.variant??"tertiary",tone:C.tone??"neutral",disabled:te,onClick:()=>C.onClick(D,L),iconLeft:C.icon?e.jsx(E.Icon,{name:C.icon,size:"sm"}):void 0,children:de&&C.label}),ve=C.tooltip;return ve?e.jsx(ke.Tooltip,{label:ve,position:"top-end",children:Ce}):Ce},ci=(C,D)=>{const L=Zr(C);if(!L.length)return null;if(L.length>5){const te=Je(C,D),de=(re==null?void 0:re.rowKey)===te;return e.jsx("div",{className:"sa-tl-row-actions",style:Rl,onClick:se=>se.stopPropagation(),children:e.jsx(ke.Tooltip,{label:"Aksi lainnya",position:"top",children:e.jsx(P.Button,{size:"xs",variant:"tertiary",onClick:se=>{const Ce=se.currentTarget.getBoundingClientRect();ie(de?null:{rowKey:te,top:Ce.bottom+4,right:window.innerWidth-Ce.right})},children:e.jsx(E.Icon,{name:"MenuVertical",size:"sm"})})})})}return e.jsx("div",{className:"sa-tl-row-actions",style:Rl,children:L.map(te=>e.jsx(h.Fragment,{children:Gr(te,C,D)},te.key))})},ii=(C,D)=>{const L=Zr(C);return L.length?e.jsx("div",{style:{display:"flex",gap:6,flexWrap:"wrap",paddingTop:8,marginTop:8,borderTop:Or},children:L.map(X=>e.jsx(h.Fragment,{children:Gr(X,C,D,{showLabel:!0,size:"sm"})},X.key))}):null},si=(C,D)=>{const L=Zr(C);return L.length?e.jsx("div",{style:{display:"flex",gap:4,paddingRight:8,flexShrink:0},children:L.map(X=>e.jsx(h.Fragment,{children:Gr(X,C,D,{showLabel:!1})},X.key))}):null},St=(C,D)=>{const{col:L,key:X}=C,te=F.get(X)??0,de=fr(te),se=de&&te===hr,Ce=(ue==null?void 0:ue.key)===X?ue.direction:null,ve=y&&!L.disableMenu?e.jsx(Wl,{active:!!Ce||de,canSort:Q(L),canHide:!L.locked,sortDir:Ce,frozen:de,onSort:wr=>Ge({key:X,direction:wr}),onClearSort:()=>Ge(null),onToggleFreeze:()=>ni(X),onHide:()=>oi(X,L.locked)}):null,Ie=L.align==="right",xr=L.align==="right"?"flex-end":L.align==="center"?"center":"flex-start",qe=e.jsxs("span",{style:{flex:1,minWidth:0,display:"flex",alignItems:"center",gap:6,justifyContent:xr,overflow:"hidden"},children:[L.icon&&e.jsx(E.Icon,{name:L.icon,size:"sm",style:{flexShrink:0}}),e.jsx("span",{style:Wr,children:L.title})]});return e.jsx(Z.Th,{className:`sa-tl-leaf${de?" sa-tl-frozen":""}`,rowSpan:D==null?void 0:D.rowSpan,colSpan:D==null?void 0:D.colSpan,minWidth:L.minWidth,resizable:_?L.resizable:!1,defaultWidth:qr(L,te),style:{textAlign:zr(L.align),width:Qe(L,te),position:"sticky",top:(D==null?void 0:D.top)??0,left:de?Ul(te):void 0,zIndex:de?3:2,backgroundColor:ar,boxShadow:se?zl:void 0},children:e.jsx("div",{style:{display:"flex",alignItems:"center",gap:6,width:"100%"},children:Ie?e.jsxs(e.Fragment,{children:[ve,qe]}):e.jsxs(e.Fragment,{children:[qe,ve]})})},`th-${X}`)},ai=()=>{const C=[];for(let D=0;D<ye.length;){const L=ye[D],X=L.col.headerColSpan??1,te=Math.max(1,Math.min(X,ye.length-D));C.push(St(L,te>1?{colSpan:te}:void 0)),D+=te}return C},eo=C=>e.jsx(Z.Th,{rowSpan:C==null?void 0:C.rowSpan,style:{width:Cr,position:"sticky",top:0,left:0,zIndex:4,backgroundColor:ar,padding:0},children:e.jsx("div",{style:{display:"flex",alignItems:"center",justifyContent:"center"},onClick:D=>D.stopPropagation(),children:e.jsx(Ze.Checkbox,{size:"sm",variant:Kl?"indeterminate":"select",checked:xt||Kl,disabled:gr.length===0,onChange:ei,"aria-label":"Pilih semua baris di halaman ini"})})},"th-select"),di=(C,D,L)=>{const X=Je(C,D);return e.jsx(Z.Td,{className:"sa-tl-frozen",style:{width:Cr,padding:0,position:"sticky",left:0,zIndex:2,...L?{"--sa-tl-bg":L}:{}},children:Ct(C,D)&&e.jsx("div",{style:{display:"flex",alignItems:"center",justifyContent:"center"},onClick:te=>te.stopPropagation(),children:e.jsx(Ze.Checkbox,{size:"sm",checked:Ye.has(X),onChange:()=>vt(X),"aria-label":"Pilih baris"})})},`tl-select-${D}`)},kt=ye.filter(C=>!C.col.hideOnMobile),Bt=kt.find(C=>C.col.primary)??kt[0],hi=kt.filter(C=>C!==Bt),fi=C=>J(D=>{const L=new Set(D);return L.has(C)?L.delete(C):L.add(C),L}),ro=(C,D)=>hi.map(({col:L,key:X})=>{const te=wt(L,C,D),de=typeof te=="string"||typeof te=="number"?e.jsx(B.Text,{style:{minWidth:0,overflow:"hidden",textOverflow:"ellipsis",textAlign:"right"},children:te}):e.jsx("div",{style:{minWidth:0,overflow:"hidden",textOverflow:"ellipsis",textAlign:"right"},children:te});return e.jsxs("div",{style:{display:"flex",gap:12,justifyContent:"space-between",alignItems:"baseline"},children:[typeof L.title=="string"?e.jsx(B.Text,{color:"subtle",fontWeight:"medium",style:{color:Bn,flexShrink:0},children:L.title}):e.jsx("div",{style:{flexShrink:0},children:L.title}),de]},X)}),mt=(C,D)=>{const L=Bt?wt(Bt.col,C,D):null;return typeof L=="string"||typeof L=="number"?e.jsx(B.Text,{as:"span",style:Wr,children:L}):e.jsx("span",{style:Wr,children:L})},gi=e.jsx(u.Box,{style:{display:"flex",flexDirection:"column",gap:8,padding:8},children:Array.from({length:V},(C,D)=>e.jsxs(u.Box,{style:{border:Or,borderRadius:"var(--sa-radii-sm, 6px)",padding:12,display:"flex",flexDirection:"column",gap:8},children:[e.jsx(We.Skeleton,{height:16,width:"60%",borderRadius:"rounded-sm"}),e.jsx(We.Skeleton,{height:12,width:"85%",borderRadius:"rounded-sm"}),e.jsx(We.Skeleton,{height:12,width:"70%",borderRadius:"rounded-sm"})]},`sa-tl-sk-card-${D}`))}),to=e.jsx(u.Box,{fullWidth:!0,style:{minHeight:(k==null?void 0:k.minHeight)??320,display:"flex",alignItems:"center",justifyContent:"center",padding:16},children:k==null?void 0:k.content}),ui=S?gi:H.length===0?to:v==="expand"?e.jsx(u.Box,{style:{display:"flex",flexDirection:"column"},children:H.map((C,D)=>{const L=Je(C,D),X=R.has(L),de=w&&Ye.has(L)?ft:Ar(n==null?void 0:n(C,D));return e.jsxs("div",{style:{borderBottom:Or,backgroundColor:de},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center"},children:[Ct(C,D)&&e.jsx("div",{style:{display:"flex",alignItems:"center",paddingLeft:12,flexShrink:0},children:e.jsx(Ze.Checkbox,{size:"sm",checked:Ye.has(L),onChange:()=>vt(L),"aria-label":"Pilih baris"})}),e.jsxs("button",{type:"button",onClick:()=>fi(L),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:[mt(C,D),e.jsx(E.Icon,{name:X?"ChevronUp":"ChevronDown",size:"sm",style:{flexShrink:0}})]}),oe&&si(C,D)]}),X&&e.jsx("div",{style:{padding:"0 12px 12px",display:"flex",flexDirection:"column",gap:6},children:ro(C,D)})]},L)})}):e.jsx(u.Box,{style:{display:"flex",flexDirection:"column",gap:8,padding:8},children:H.map((C,D)=>{const L=Je(C,D),X=w&&Ye.has(L);return e.jsxs(u.Box,{style:{border:Or,borderRadius:"var(--sa-radii-sm, 6px)",padding:12,display:"flex",flexDirection:"column",gap:6,backgroundColor:X?ft:Ar(n==null?void 0:n(C,D))},children:[Ct(C,D)?e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[e.jsx(Ze.Checkbox,{size:"sm",checked:Ye.has(L),onChange:()=>vt(L),"aria-label":"Pilih baris"}),e.jsx("div",{style:{flex:1,minWidth:0},children:mt(C,D)})]}):mt(C,D),ro(C,D),oe&&ii(C,D)]},L)})}),yi=c&&_&&pe!==void 0,lo=s==="fixed"&&!c&&(_?pe!==void 0:!0),pi=lo&&!_,bi=e.jsxs(Z.Table,{className:"sa-table-layout",fullWidth:!0,size:o,resizable:yi,style:lo?{tableLayout:"fixed"}:void 0,onWidthsChange:$?Fe:void 0,children:[pi&&e.jsxs("colgroup",{children:[w&&e.jsx("col",{style:{width:Cr}}),ye.map(({col:C,key:D},L)=>e.jsx("col",{style:{width:Qe(C,L)}},`col-${D}`)),oe&&e.jsx("col",{style:{width:1}})]}),e.jsx(Z.Thead,{ref:Ee,children:_e?e.jsxs(e.Fragment,{children:[e.jsxs(Z.Tr,{children:[w&&eo({rowSpan:2}),He.map(C=>C.isGroup?e.jsx(Z.Th,{colSpan:C.leaves.length,style:{textAlign:"center",position:"sticky",top:0,zIndex:2,backgroundColor:ar},children:e.jsx("span",{style:Wr,children:C.col.title})},`grp-${C.key}`):St(C.leaves[0],{rowSpan:2})),oe&&e.jsx(Z.Th,{rowSpan:2,style:{position:"sticky",top:0,right:0,zIndex:3,width:1,padding:0,border:"none",backgroundColor:ar}})]}),e.jsx(Z.Tr,{children:He.flatMap(C=>C.isGroup?C.leaves.map(D=>St(D,{top:er})):[])})]}):e.jsxs(Z.Tr,{children:[w&&eo(),ai(),oe&&e.jsx(Z.Th,{style:{position:"sticky",top:0,right:0,zIndex:3,width:1,padding:0,border:"none",backgroundColor:ar}})]})}),e.jsx(Z.Tbody,{children:S?li:H.length===0?e.jsx(Z.Tr,{children:e.jsx(Z.Td,{colSpan:Dt,children:to})}):e.jsxs(e.Fragment,{children:[H.map((C,D)=>{const L=m==null?void 0:m(C,D,D>0?H[D-1]:void 0),te=w&&Ye.has(Je(C,D))?ft:Ar(n==null?void 0:n(C,D));return e.jsxs(h.Fragment,{children:[L!=null&&L!==!1&&e.jsx(Z.Tr,{children:e.jsx(Z.Td,{colSpan:Dt,style:{backgroundColor:ar},children:L})}),e.jsxs(Z.Tr,{children:[w&&di(C,D,te),ye.map(({col:de,key:se},Ce)=>{var no;const ve=(no=de.cellProps)==null?void 0:no.call(de,C,D,H);if(ve!=null&&ve.hidden)return null;const Ie=fr(Ce),xr=Ie&&Ce===hr,qe=wt(de,C,D),wr=typeof de.bg=="function"?de.bg(C,D,H):de.bg,oo=Ar(wr)??te;return e.jsx(Z.Td,{className:Ie?"sa-tl-frozen":void 0,colSpan:ve==null?void 0:ve.colSpan,rowSpan:ve==null?void 0:ve.rowSpan,style:{textAlign:zr(de.align),width:Qe(de,Ce),minWidth:de.minWidth,position:Ie?"sticky":void 0,left:Ie?Ul(Ce):void 0,zIndex:Ie?1:void 0,boxShadow:xr?zl:void 0,...oo?{"--sa-tl-bg":oo}:{}},children:typeof qe=="string"?e.jsx(B.Text,{style:{whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",textAlign:zr(de.align)},children:qe}):qe},`tl-cell-${D}-${se}`)}),oe&&e.jsx(Z.Td,{style:{position:"sticky",right:0,width:1,padding:0,overflow:"visible",zIndex:2,border:"none"},children:ci(C,D)})]})]},Je(C,D))}),O!=null&&e.jsx(Z.Tr,{children:e.jsx(Z.Td,{colSpan:Dt,children:O})})]})})]}),Ft=re?H.findIndex((C,D)=>Je(C,D)===re.rowKey):-1,Et=Ft>=0?H[Ft]:null;return e.jsxs(e.Fragment,{children:[e.jsx(u.Box,{ref:pt,fullWidth:!0,style:{overflow:"auto",height:T??Kc},children:le?ui:bi}),re&&Et&&e.jsx("div",{className:"sa-tl-kebab-menu",style:{top:re.top,right:re.right},onClick:C=>C.stopPropagation(),children:Zr(Et).map(C=>e.jsx("div",{style:{padding:"2px 4px"},children:Gr(C,Et,Ft,{showLabel:!0,size:"sm"})},C.key))})]})},gt=r=>r==="asc"||r==="desc",Tn=(r={})=>{const{sortKeyParam:t="sortBy",sortOrderParam:l="sortOrder",pageKey:n="page",defaultSort:o=null,paramKeys:c,scopeId:s,storage:i=nt}=r,{searchParams:a,setSearchParams:d,searchQueries:y}=me(),b=a.toString(),p=s?sr.tableSort(s):void 0,x=h.useRef(!1);h.useEffect(()=>{if(x.current||(x.current=!0,!p)||a.has(t)||a.has(l))return;const k=i.get(p);!(k!=null&&k.key)||!gt(k.direction)||d({...Object.fromEntries(a.entries()),[t]:k.key,[l]:k.direction})},[]);const T=h.useMemo(()=>{const k=a.get(t),S=a.get(l);return k&>(S)?{key:k,direction:S}:o},[b,t,l,o]);h.useEffect(()=>{if(!p)return;const k=a.get(t),S=a.get(l);k&>(S)?i.set(p,{key:k,direction:S}):i.remove(p)},[b,p,t,l,i]);const v=(c==null?void 0:c.sortBy)??"sortBy",I=(c==null?void 0:c.sortOrder)??"sortOrder",m=h.useMemo(()=>T?{[v]:T.key,[I]:T.direction}:{},[T,v,I]),O=h.useCallback(k=>{const S={...y};k?(S[t]=k.key,S[l]=k.direction):(delete S[t],delete S[l]),delete S[n],d(S)},[y,t,l,n,d]);return{sort:T,setSort:O,params:m}},Hr=({of:r,render:t})=>h.Children.toArray(r==null?void 0:r.map((l,n,o)=>t(l,n,o))),ce=({condition:r,fallback:t,children:l,loading:n,isLoading:o})=>e.jsx(e.Fragment,{children:o?n:r?l:t}),he=r=>e.jsx(B.Text,{...r,fontFamily:"Poppins",fontSize:r.fontSize||"md",fontWeight:r.fontWeight||"medium",color:r.color||"gray-700",children:r.children}),Ue=r=>e.jsx(B.Text,{color:"red-600",fontSize:"sm",children:r.message}),In=({size:r="md",direction:t="vertical",requiredTitle:l="(Required)",fullWidth:n=!1,...o})=>{var i,a,d;const c=o.hideMessageError||!1,s=t==="horizontal"?r==="sm"?342:r==="lg"?400:342:void 0;return e.jsxs(u.Box,{gap:t==="horizontal"?"spacing-96":"sm",direction:t==="horizontal"?"row":"column",...o.containerProps,children:[o.title&&e.jsx(ce,{condition:!!o.inputProps.required,fallback:e.jsxs(u.Box,{direction:"column",customMaxWidth:s,fullWidth:n,children:[e.jsx(he,{children:o.title}),e.jsx(B.Text,{fontSize:r,color:"gray-500",children:o.description})]}),children:e.jsxs(u.Box,{direction:"column",customMaxWidth:s,fullWidth:n,children:[e.jsxs(ne.Flex,{direction:"row",gap:"xs",align:"center",children:[e.jsx(he,{fontSize:r,children:o.title}),e.jsx(he,{color:"error",fontSize:r,children:l}),e.jsx(ce,{condition:!!((i=o.tooltip)!=null&&i.label),children:e.jsx(ke.Tooltip,{label:(a=o.tooltip)==null?void 0:a.label,arrowPosition:(d=o.tooltip)==null?void 0:d.arrowPosition,...o.tooltip,children:e.jsx(E.Icon,{name:"InfoCircle",size:r==="lg"?"sm":"xs",style:{color:"var(--sa-color-info-500, #00abeb)",marginTop:"6px"}})})})]}),e.jsx(ce,{condition:!!o.description,children:e.jsx(B.Text,{fontSize:r,color:"gray-500",children:o.description})})]})}),e.jsxs(u.Box,{direction:"column",gap:"xs",fullWidth:o.inputProps.fullWidth||!1,children:[e.jsx(Ke.Input,{ref:o.inputRef,size:r,...o.inputProps,status:o.errorMessage?"error":"default",fullWidth:!0}),!c&&o.errorMessage&&e.jsx(Ue,{message:o.errorMessage}),o.inputProps.extended&&o.inputProps.extended]})]})},On=({size:r="md",direction:t="vertical",requiredTitle:l="(Required)",fullWidth:n=!1,...o})=>{var i,a,d;const c=o.hideMessageError||!1,s=t==="horizontal"?r==="sm"?342:r==="lg"?400:342:void 0;return e.jsxs(u.Box,{gap:t==="horizontal"?"spacing-96":"sm",direction:t==="horizontal"?"row":"column",onClick:o.onClickContainer,children:[o.title&&e.jsx(ce,{condition:!!o.inputProps.required,fallback:e.jsxs(u.Box,{direction:"column",customMaxWidth:s,fullWidth:n,children:[e.jsx(he,{children:o.title}),e.jsx(B.Text,{fontSize:r,color:"gray-500",children:o.description})]}),children:e.jsxs(u.Box,{direction:"column",customMaxWidth:s,fullWidth:n,children:[e.jsxs(ne.Flex,{direction:"row",gap:"xs",align:"center",children:[e.jsx(he,{fontSize:r,children:o.title}),e.jsx(he,{color:"error",fontSize:r,children:l}),e.jsx(ce,{condition:!!((i=o.tooltip)!=null&&i.label),children:e.jsx(ke.Tooltip,{label:(a=o.tooltip)==null?void 0:a.label,arrowPosition:(d=o.tooltip)==null?void 0:d.arrowPosition,...o.tooltip,children:e.jsx(E.Icon,{name:"InfoCircle",size:r==="lg"?"sm":"xs",style:{color:"var(--sa-color-info-500, #00abeb)",marginTop:"6px"}})})})]}),e.jsx(ce,{condition:!!o.description,children:e.jsx(B.Text,{fontSize:r,color:"gray-500",children:o.description})})]})}),e.jsxs(u.Box,{direction:"column",gap:"xs",fullWidth:o.inputProps.fullWidth||!1,children:[e.jsx(u.Box,{direction:"column",style:{width:o.inputProps.fullWidth?"100%":t==="horizontal"&&o.customWidth?o.customWidth:t==="horizontal"?"343px":""},children:e.jsx(or.Dropdown,{size:r,...o.inputProps,error:!!o.errorMessage})}),!c&&o.errorMessage&&e.jsx(Ue,{message:o.errorMessage}),o.inputProps.extended&&o.inputProps.extended]})]})},Wn=(r,t)=>typeof r=="string"&&r||t==="error"?"var(--sa-border-danger)":"var(--sa-border-subtle)",zn=r=>{var i;const[t,l]=h.useState(!1),n=a=>{a.preventDefault(),a.stopPropagation()},o=a=>{a.preventDefault(),a.stopPropagation(),a.dataTransfer&&r.handleOnFileChange(a.dataTransfer.files.item(0))},c=a=>{a.preventDefault(),l(!0)},s=a=>{a.preventDefault(),l(!1)};return e.jsxs(u.Box,{width:"width-full",paddingInline:"md",direction:"row",gap:"sm",align:"center",onClick:r.handleOnClick,onDragOver:n,onDrop:o,onDragEnter:c,onDragLeave:s,paddingBlock:"md",borderRadius:"rounded-md",style:{border:t?"1px solid var(--sa-border-info)":`1px solid ${Wn(r.errorMessage,r.status)}`},children:[e.jsx(E.Icon,{name:"Upload",size:"lg",style:{width:30,height:30}}),e.jsxs(ne.Flex,{direction:"column",gap:"xs",children:[e.jsxs(ne.Flex,{direction:"row",gap:"xs",children:[e.jsx(B.Text,{fontWeight:"medium",color:"gray-500",style:{textWrap:"nowrap"},fontSize:r.isDesktop?"md":"sm",children:"Click your upload"}),e.jsx(B.Text,{fontWeight:"medium",style:{textWrap:"nowrap"},fontSize:r.isDesktop?"md":"sm",children:"or Drag & Drop"})]}),e.jsx(B.Text,{fontSize:"sm",color:"gray-500",children:(i=r.fileSupports)==null?void 0:i.map(a=>a.toLocaleUpperCase()).join(", ")})]})]})};function An(r){return r.split(" ").map(t=>t[0]).join("").slice(0,2).toUpperCase()}const Hl=r=>{const t={day:"2-digit",month:"short",year:"numeric"};return r.toLocaleDateString("id-ID",t)},Hn=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},l=r.split(" ");if(l.length!==3)return null;const n=parseInt(l[0],10),o=t[l[1]],c=parseInt(l[2],10);return isNaN(n)||isNaN(o)||isNaN(c)?null:new Date(c,o,n)};function Vn(r,t=!0){if(!r)return"Rp 0";const l=typeof r=="number"?r.toString():r;if(isNaN(Number(l)))return"Rp 0";const n=l.split("."),o=n[0].replace(/\B(?=(\d{3})+(?!\d))/g,"."),c=n.length===2?o+"."+n[1]:o;return t?"Rp"+c:c}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 jn=r=>{const t=r.split(" ");let l=t[0].charAt(0);return t.length>1&&(l+=""+t[1].charAt(0)),l.toUpperCase()};function Pn(r){const t=typeof r=="string"?new Date(r):r;if(isNaN(t.getTime()))throw new Error("Invalid date format");const l=t.getFullYear(),n=String(t.getMonth()+1).padStart(2,"0"),o=String(t.getDate()).padStart(2,"0");return`${l}-${n}-${o}`}const Nn="sa-admin",Ve=r=>`var(--${Nn}-${r})`,_n={base:{borderColor:Ve("base-border-color"),textColor:Ve("base-text-color"),iconColor:Ve("base-icon-color"),placeholderColor:Ve("base-placeholder-color")},document:{bgColor:Ve("document-bg-color")},sidebar:{bgColor:Ve("sidebar-bg-color"),borderColor:Ve("sidebar-border-color"),maxWidth:Ve("sidebar-max-width"),width:Ve("sidebar-width"),collapseWidth:Ve("sidebar-collapse-width"),collapseV2Width:Ve("sidebar-v2-collapse-width")}},qn=24*60*60*1e3,Zn=r=>{const t="14px poppins",n=document.createElement("canvas").getContext("2d");n.font=t;const o=n.measureText(r).width;return Number(Math.ceil(o))},Gn=/^[^\s@]+@[^\s@]+\.[^\s@]+$/,Qn=/--+/,Un=/-$/;function Jn(r,t){return JSON.stringify(r)!==JSON.stringify(t)}function Yn(r){return/^(?:\+62|62|0)8[1-9][0-9]{7,10}$/.test(r)}function Xn(r){return/^[A-Za-z\s]+$/.test(r)}const Kn=r=>{const t=/^[0-9]$/,l=["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)&&!l.includes(r.key)&&r.preventDefault()},$n=r=>{const t=/^[0-9]$/,l=["ArrowLeft","ArrowRight","ArrowUp","ArrowDown","Backspace","Delete","Enter","Tab"];(r.ctrlKey||r.metaKey)&&r.key==="v"||t.test(r.key)&&!l.includes(r.key)&&r.preventDefault()},Rn=r=>{const t=/^[0-9.]$/,l=["ArrowLeft","ArrowRight","ArrowUp","ArrowDown","Backspace","Delete","Enter","Tab"];(r.ctrlKey||r.metaKey)&&r.key==="v"||!t.test(r.key)&&!l.includes(r.key)&&r.preventDefault()},ec=r=>Gn.test(r);function rc(r){return!(Qn.test(r)||Un.test(r))}const tc=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 l=r.currentTarget.value;/^[0-9]$/.test(r.key)||r.key==="."&&!l.includes(".")||r.key==="-"&&l.length===0&&!l.includes("-")||t.includes(r.key)||r.preventDefault()},lc=r=>{const t=document.getElementById(r);if(t){const l=t.getBoundingClientRect(),n=window.scrollY+l.top-80;window.scrollTo({top:n,behavior:"smooth"})}};function oc(r){const t=r.toLowerCase();if(["kb","mb","gb"].find(c=>t.endsWith(c)))return r;const o=Number(r);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 nc(r){const t=r.split("/");return t[t.length-1]}const cc=r=>{var t,l;return e.jsxs(u.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(ne.Flex,{direction:"row",align:"center",gap:"sm",style:{flex:1,minWidth:0},children:[e.jsx(E.Icon,{name:"DocumentFilled",size:"lg",style:{color:"var(--sa-icon-brand)",width:30,height:30,flexShrink:0}}),e.jsxs(ne.Flex,{direction:"column",style:{minWidth:0,flex:1},children:[e.jsx(B.Text,{fontWeight:"bold",style:{textOverflow:"ellipsis",whiteSpace:"nowrap",overflow:"hidden"},children:r.defaultFile?nc(r.defaultFile.url):(t=r.fileSelected)==null?void 0:t.name}),r.defaultFile?(r.defaultFile.size||r.defaultFile.date)&&e.jsxs(ne.Flex,{direction:"row",gap:"xs",align:"center",children:[r.defaultFile.size&&e.jsx(B.Text,{fontSize:"sm",fontWeight:"medium",children:r.defaultFile.size}),r.defaultFile.size&&r.defaultFile.date&&e.jsx(E.Icon,{name:"Dot",size:"xs"}),r.defaultFile.date&&e.jsx(B.Text,{fontSize:"sm",fontWeight:"medium",style:{textWrap:"nowrap"},children:r.defaultFile.date})]}):e.jsxs(ne.Flex,{direction:"row",gap:"xs",align:"center",children:[e.jsx(B.Text,{fontSize:"sm",fontWeight:"medium",children:oc(((l=r.fileSelected)==null?void 0:l.size.toString())||"100000")}),e.jsx(E.Icon,{name:"Dot",size:"xs"}),e.jsx(B.Text,{fontSize:"sm",fontWeight:"medium",style:{textWrap:"nowrap"},children:Hl(new Date)})]})]})]}),e.jsx(P.Button,{size:"xs",variant:"tertiary",tone:"error",type:"button",onClick:n=>{n.stopPropagation(),r.handleOnDeleteFile()},iconLeft:e.jsx(E.Icon,{name:"Trash1"})})]})},Vl=({status:r="default",labelPosition:t="outside-top",...l})=>{var p;const n=h.useRef(null),o=()=>{if(l.defaultFile){window.open(l.defaultFile.url);return}n.current&&n.current.click()},c=xe.useMediaQuery("md"),s=r==="error"||typeof l.errorMessage=="string"&&!!l.errorMessage,i=l.label?e.jsxs(ne.Flex,{direction:"row",align:"center",gap:"xs",children:[e.jsx(B.Text,{style:{fontSize:"14px",fontWeight:500,color:"var(--sa-text-primary)"},children:l.label}),l.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"}),l.required&&e.jsx("span",{style:{fontSize:"14px",fontWeight:500,color:"var(--sa-text-error)"},children:"*"})]}):null,a=l.description?e.jsx(B.Text,{style:{fontSize:"12px",fontWeight:400,color:"var(--sa-text-subtlest, #6b6e76)",lineHeight:"18px"},children:l.description}):null,d=e.jsxs(e.Fragment,{children:[l.helperText&&e.jsx(B.Text,{style:{fontSize:"12px",fontWeight:400,color:"var(--sa-text-subtlest, #6b6e76)",lineHeight:"18px"},children:l.helperText}),l.errorText&&r==="error"&&e.jsx(B.Text,{style:{fontSize:"12px",fontWeight:400,color:"var(--sa-text-error, #a4133c)",lineHeight:"18px"},children:l.errorText}),l.errorMessage&&!l.errorText&&e.jsx(B.Text,{style:{fontSize:"12px",fontWeight:400,color:"var(--sa-text-error, #a4133c)",lineHeight:"18px"},children:l.errorMessage})]}),y=e.jsx("input",{type:"file",style:{display:"none"},ref:n,onChange:x=>{var T;return l.handleOnChangeFile(((T=x.target.files)==null?void 0:T.item(0))||null)},accept:(p=l.fileSupportOption)==null?void 0:p.map(x=>"."+(x==null?void 0:x.toLowerCase())).join(", ")}),b=e.jsxs(u.Box,{direction:"column",fullWidth:!0,style:{minHeight:"69px"},borderRadius:"rounded-md",display:"flex",justify:"center",align:"center",cursor:"pointer",gap:"md",...l.containerProps,children:[y,(l.fileSelected||l.defaultFile)&&e.jsx(cc,{fileSelected:l.fileSelected,defaultFile:l.defaultFile,handleOnDeleteFile:l.handleOnDeleteFile,handleOnClickFile:o}),!l.fileSelected&&!l.defaultFile&&e.jsx(zn,{fileSupports:l.fileSupportOption,isDesktop:c,errorMessage:s?l.errorText||l.errorMessage||" ":void 0,status:s?"error":"default",handleOnClick:o,handleOnFileChange:l.handleOnChangeFile})]});return t==="outside-left"?e.jsxs(ne.Flex,{direction:"row",align:"flex-start",gap:"sm",style:{width:"100%"},children:[e.jsxs(ne.Flex,{direction:"column",gap:"xs",style:{width:"40%",minWidth:"120px",paddingTop:"10px"},children:[i,a]}),e.jsxs(ne.Flex,{direction:"column",gap:"sm",style:{flex:1,minWidth:0},children:[b,d]})]}):e.jsxs(ne.Flex,{direction:"column",gap:"sm",style:{width:"100%"},children:[i,a,b,d]})},ic=({size:r="md",direction:t="vertical",requiredTitle:l="(Required)",fullWidth:n=!1,...o})=>{var i,a,d;const c=o.hideMessageError||!1,s=t==="horizontal"?r==="sm"?342:r==="lg"?400:342:void 0;return e.jsxs(u.Box,{gap:t==="horizontal"?"spacing-96":"sm",direction:t==="horizontal"?"row":"column",...o.containerProps,children:[o.title&&e.jsx(ce,{condition:!!o.inputProps.required,fallback:e.jsxs(u.Box,{direction:"column",customMaxWidth:s,fullWidth:n,children:[e.jsx(he,{children:o.title}),e.jsx(B.Text,{fontSize:r,color:"gray-500",children:o.description})]}),children:e.jsxs(u.Box,{direction:"column",customMaxWidth:s,fullWidth:n,children:[e.jsxs(ne.Flex,{direction:"row",gap:"xs",align:"center",children:[e.jsx(he,{fontSize:r,children:o.title}),e.jsx(he,{color:"error",fontSize:r,children:l}),e.jsx(ce,{condition:!!((i=o.tooltip)!=null&&i.label),children:e.jsx(ke.Tooltip,{label:(a=o.tooltip)==null?void 0:a.label,arrowPosition:(d=o.tooltip)==null?void 0:d.arrowPosition,...o.tooltip,children:e.jsx(E.Icon,{name:"InfoCircle",size:r==="lg"?"sm":"xs",style:{color:"var(--sa-color-info-500, #00abeb)",marginTop:"6px"}})})})]}),e.jsx(ce,{condition:!!o.description,children:e.jsx(B.Text,{fontSize:r,color:"gray-500",children:o.description})})]})}),e.jsxs(ne.Flex,{direction:"column",gap:"xs",children:[e.jsx(Vl,{...o.inputProps,status:o.errorMessage?"error":"default"}),!c&&o.errorMessage&&e.jsx(Ue,{message:o.errorMessage})]})]})},sc=({size:r="md",direction:t="vertical",requiredTitle:l="(Required)",fullWidth:n=!1,required:o=!1,...c})=>{var a,d,y,b;const s=c.hideMessageError||!1,i=t==="horizontal"?r==="sm"?342:r==="lg"?400:342:void 0;return e.jsxs(u.Box,{gap:t==="horizontal"||t==="horizontal-inline"?"spacing-96":"sm",direction:t==="horizontal"||t==="horizontal-inline"?"row":"column",...c.containerProps,children:[c.title&&e.jsx(ce,{condition:!!o,fallback:e.jsxs(u.Box,{direction:"column",customMaxWidth:i,fullWidth:n,children:[e.jsx(he,{children:c.title}),e.jsx(ze.Body3,{props:{color:"gray-500"},children:c.description})]}),children:e.jsxs(u.Box,{direction:"column",customMaxWidth:i,fullWidth:n,children:[e.jsxs(ne.Flex,{direction:"row",gap:"xs",align:"center",children:[e.jsx(he,{fontSize:r,children:c.title}),e.jsx(he,{color:"error",fontSize:r,children:l}),e.jsx(ce,{condition:!!((a=c.tooltip)!=null&&a.label),children:e.jsx(ke.Tooltip,{label:(d=c.tooltip)==null?void 0:d.label,arrowPosition:(y=c.tooltip)==null?void 0:y.arrowPosition,...c.tooltip,children:e.jsx(E.Icon,{name:"InfoCircle",size:r==="lg"?"sm":"xs",style:{color:"var(--sa-color-info-500, #00abeb)",marginTop:"6px"}})})})]}),e.jsx(ce,{condition:!!c.description,children:e.jsx(B.Text,{fontSize:r,color:"gray-500",children:c.description})})]})}),e.jsx(u.Box,{gap:t==="horizontal-inline"?"xl":"md",direction:t==="horizontal-inline"?"row":"column",align:"flex-start",children:e.jsx(Hr,{of:(b=c.checkBoxesList)==null?void 0:b.map(p=>({...p,isChecked:c.checkBoxesAreChecked.includes(p.id)})),render:p=>p.renderBadge?e.jsxs(u.Box,{direction:"row",justify:"space-between",gap:"lg",...c.badgeContainerProps,children:[e.jsx(Ze.Checkbox,{name:p.name,value:p.id,checked:p.isChecked,onChange:x=>c.onChecked(x.target.value,p),label:p.name,description:p.description}),p.renderBadge]}):e.jsx(Ze.Checkbox,{name:p.name,value:p.id,checked:p.isChecked,onChange:x=>c.onChecked(x.target.value,p),label:p.name,description:p.description})})}),!s&&c.errorMessage&&e.jsx(Ue,{message:c.errorMessage})]})},ac=({position:r="vertical",size:t="md",fullWidth:l=!1,...n})=>{var c;const o=r==="horizontal-inline"||r==="horizontal-block"?t==="sm"?342:t==="lg"?400:342:void 0;return e.jsxs(u.Box,{gap:r==="horizontal-inline"||r==="horizontal-block"?"spacing-96":"sm",direction:r==="horizontal-inline"||r==="horizontal-block"?"row":"column",children:[e.jsx(ce,{condition:!!n.description||!!n.title,children:e.jsxs(u.Box,{direction:"column",customMaxWidth:o,fullWidth:l,children:[n.title&&e.jsx(he,{children:n.title}),e.jsx(ce,{condition:!!n.description,children:e.jsx(B.Text,{color:"gray-500",children:n.description})})]})}),e.jsx(u.Box,{gap:"sm",direction:r==="horizontal"||r==="horizontal-inline"?"row":"column",align:"flex-start",flexWrap:"wrap",children:e.jsx(Hr,{of:(c=n.radioList)==null?void 0:c.map(s=>({...s,isChecked:n.radioIsChecked===s.id})),render:({value:s,id:i,isChecked:a,subInput:d,label:y,description:b})=>e.jsxs(u.Box,{direction:"column",gap:"xs",customMaxWidth:o,children:[e.jsx(Ur.Radio,{id:`${i.toString()}-${s}`,name:n.groupName||y,label:y,value:s,checked:a,onChange:p=>n.onChecked({id:i,label:p.target.name,value:p.target.value}),disabled:n.disableAll},i),b&&e.jsx(B.Text,{color:"gray-500",style:{marginLeft:28},children:b}),d]})})}),n.errorMessage&&e.jsx(Ue,{message:n.errorMessage})]})},dc=({size:r="md",direction:t="vertical",requiredTitle:l="(Required)",fullWidth:n=!1,...o})=>{var i,a,d;const c=o.hideMessageError||!1,s=t==="horizontal"?r==="sm"?342:r==="lg"?400:342:void 0;return e.jsxs(u.Box,{gap:t==="horizontal"?"spacing-96":"sm",direction:t==="horizontal"?"row":"column",...o.containerProps,children:[o.title&&e.jsx(ce,{condition:!!o.inputProps.required,fallback:e.jsxs(u.Box,{direction:"column",customMaxWidth:s,fullWidth:n,children:[e.jsx(he,{children:o.title}),e.jsx(B.Text,{fontSize:r,color:"gray-500",children:o.description})]}),children:e.jsxs(u.Box,{direction:"column",customMaxWidth:s,fullWidth:n,children:[e.jsxs(ne.Flex,{direction:"row",gap:"xs",align:"center",children:[e.jsx(he,{fontSize:r,children:o.title}),e.jsx(he,{color:"error",fontSize:r,children:l}),e.jsx(ce,{condition:!!((i=o.tooltip)!=null&&i.label),children:e.jsx(ke.Tooltip,{label:(a=o.tooltip)==null?void 0:a.label,arrowPosition:(d=o.tooltip)==null?void 0:d.arrowPosition,...o.tooltip,children:e.jsx(E.Icon,{name:"InfoCircle",size:r==="lg"?"sm":"xs",style:{color:"var(--sa-color-info-500, #00abeb)",marginTop:"6px"}})})})]}),e.jsx(ce,{condition:!!o.description,children:e.jsx(B.Text,{fontSize:r,color:"gray-500",children:o.description})})]})}),e.jsxs(ne.Flex,{direction:"column",gap:"xs",children:[e.jsx(Qr.Textarea,{ref:o.inputRef,size:r,...o.inputProps,status:o.errorMessage?"error":"default"}),!c&&o.errorMessage&&e.jsx(Ue,{message:o.errorMessage})]})]})},hc=({size:r="md",direction:t="vertical",requiredTitle:l="(Required)",required:n=!1,fullWidth:o=!1,...c})=>{var i,a,d;const s=t==="horizontal"?r==="sm"?342:r==="lg"?400:342:void 0;return e.jsxs(u.Box,{gap:t==="horizontal"?"spacing-96":"sm",direction:t==="horizontal"?"row":"column",...c.containerProps,children:[c.title&&e.jsx(ce,{condition:n,fallback:e.jsxs(u.Box,{direction:"column",customMaxWidth:s,fullWidth:o,children:[e.jsx(he,{children:c.title}),e.jsx(B.Text,{fontSize:r,color:"gray-500",children:c.titleDescription})]}),children:e.jsxs(u.Box,{direction:"column",customMaxWidth:s,fullWidth:o,children:[e.jsxs(ne.Flex,{direction:"row",gap:"xs",align:"center",children:[e.jsx(he,{fontSize:r,children:c.title}),e.jsx(he,{color:"error",fontSize:r,children:l}),e.jsx(ce,{condition:!!((i=c.tooltip)!=null&&i.label),children:e.jsx(ke.Tooltip,{label:(a=c.tooltip)==null?void 0:a.label,arrowPosition:(d=c.tooltip)==null?void 0:d.arrowPosition,...c.tooltip,children:e.jsx(E.Icon,{name:"InfoCircle",size:r==="lg"?"sm":"xs",style:{color:"var(--sa-color-info-500, #00abeb)",marginTop:"6px"}})})})]}),e.jsx(ce,{condition:!!c.titleDescription,children:e.jsx(B.Text,{fontSize:r,color:"gray-500",children:c.titleDescription})})]})}),e.jsx(ir.Toggle,{checked:c.checked,onChange:c.onChange,label:c.label,description:c.description}),c.errorMessage&&e.jsx(Ue,{message:c.errorMessage})]})},fc=({variant:r="primary",size:t="md",...l})=>{const n=cr.useColor(),o=s=>{var a,d,y,b,p,x;if(!s)return;const i=l.disabled?"var(--sa-text-disable, #181a198f)":r==="secondary"?"var(--sa-text-subtle, #8c8f97)":r==="secondary-danger"?(d=(a=n==null?void 0:n.computed)==null?void 0:a.red)==null?void 0:d[600]:r==="secondary-primary"?(b=(y=n==null?void 0:n.computed)==null?void 0:y.blue)==null?void 0:b[700]:(x=(p=n==null?void 0:n.computed)==null?void 0:p.gray)==null?void 0:x[50];return e.jsx(E.Icon,{name:s,size:t,style:{color:i}})},c=()=>{var i,a,d,y;if(r!=="secondary-danger"&&r!=="secondary-primary")return l.title;const s={color:l.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=(d=n==null?void 0:n.computed)==null?void 0:d.blue)==null?void 0:y[700]};switch(t){case"xs":return e.jsx(ze.Body2,{props:{style:s},children:l.title});case"sm":case"md":return e.jsx(ze.SubH3,{props:{style:s},children:l.title});case"lg":return e.jsx(ze.SubH2,{props:{style:s},children:l.title});default:return l.title}};return e.jsx(P.Button,{fullWidth:!0,disabled:l.disabled,primary:r==="primary",secondary:r==="secondary"||r==="secondary-danger"||r==="secondary-primary",success:r==="success",onClick:l.onClick,type:l.type,iconLeft:o(l.iconLeft),iconRight:o(l.iconRight),size:t,children:c()})},gc=r=>e.jsx(ze.H5,{props:{...r},children:r.title}),uc=({size:r="md",direction:t="vertical",requiredTitle:l="(Required)",fullWidth:n=!1,...o})=>{var i,a,d;const c=o.hideMessageError||!1,s=t==="horizontal"?r==="sm"?342:r==="lg"?400:342:void 0;return e.jsxs(u.Box,{gap:t==="horizontal"?"spacing-96":"sm",direction:t==="horizontal"?"row":"column",onClick:o.onClickContainer,children:[o.title&&e.jsx(ce,{condition:!!o.inputProps.required,fallback:e.jsxs(u.Box,{direction:"column",customMaxWidth:s,fullWidth:n,children:[e.jsx(he,{children:o.title}),e.jsx(B.Text,{fontSize:r,color:"gray-500",children:o.description})]}),children:e.jsxs(u.Box,{direction:"column",customMaxWidth:s,fullWidth:n,children:[e.jsxs(ne.Flex,{direction:"row",gap:"xs",align:"center",children:[e.jsx(he,{fontSize:r,children:o.title}),e.jsx(he,{color:"error",fontSize:r,children:l}),e.jsx(ce,{condition:!!((i=o.tooltip)!=null&&i.label),children:e.jsx(ke.Tooltip,{label:(a=o.tooltip)==null?void 0:a.label,arrowPosition:(d=o.tooltip)==null?void 0:d.arrowPosition,...o.tooltip,children:e.jsx(E.Icon,{name:"InfoCircle",size:r==="lg"?"sm":"xs",style:{color:"var(--sa-color-info-500, #00abeb)",marginTop:"6px"}})})})]}),e.jsx(ce,{condition:!!o.description,children:e.jsx(B.Text,{fontSize:r,color:"gray-500",children:o.description})})]})}),e.jsxs(ne.Flex,{direction:"column",gap:"xs",children:[e.jsx(u.Box,{direction:"column",style:{width:t==="horizontal"&&o.customWidth?o.customWidth:t==="horizontal"?"343px":""},children:e.jsx($e.StarasiaDate,{size:r,...o.inputProps,status:o.errorMessage?"error":void 0})}),!c&&o.errorMessage&&e.jsx(Ue,{message:o.errorMessage})]})]})};async function yc(r,t){const l=new Image;l.src=r,await new Promise((c,s)=>{l.onload=c,l.onerror=s});const n=document.createElement("canvas");n.width=t.width,n.height=t.height;const o=n.getContext("2d",{alpha:!0});if(!o)throw new Error("No 2D context");return o.drawImage(l,t.x,t.y,t.width,t.height,0,0,t.width,t.height),new Promise((c,s)=>{n.toBlob(i=>{if(!i)return s("Canvas is empty");const a=new File([i],"cropped.png",{type:"image/png"});c(a)},"image/png")})}const jl={"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},Pl=h.forwardRef(({handleUpload:r,urlImage:t,isUploading:l,croppedImage:n,setCroppedImage:o,size:c="96",aspect:s="1:1",containerProps:i,maxFileSize:a=2,onError:d},y)=>{const b=xe.useMediaQuery("md"),[p,x]=h.useState(!1),[T,v]=h.useState(null),[I,m]=h.useState(!1),[O,k]=h.useState({x:0,y:0}),[S,V]=h.useState(1),[A,w]=h.useState(null);h.useEffect(()=>{t===null&&o(null)},[t]);const M=h.useCallback((R,J)=>{w(J)},[]),q=R=>{var ae;const J=(ae=R.target.files)==null?void 0:ae[0];if(!J)return;const fe=new FileReader;fe.onload=()=>{v(fe.result),m(!0)},fe.readAsDataURL(J)},j=async()=>{if(!(!T||!A))try{const R=await yc(T,A);if(a&&R.size>a*1024*1024){d==null||d(`Ukuran file maksimal ${a}MB`);return}r==null||r(R);const J=URL.createObjectURL(R);o(J,R),m(!1)}catch{d==null||d("Gagal memproses gambar")}},N=h.useRef(null),Y=()=>{N.current&&N.current.click()};h.useImperativeHandle(y,()=>({openFileDialog:()=>{var R;(R=N.current)==null||R.click()}}));const le=parseInt(c,10),oe=jl[s];let re,ie;return oe>=1?(ie=le,re=le*oe):(re=le,ie=le/oe),e.jsxs(u.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%":`${re}px`,height:i!=null&&i.fullWidth?"auto":`${ie}px`,aspectRatio:oe,flexShrink:0},onMouseEnter:()=>x(!0),onMouseLeave:()=>x(!1),children:[n||t?e.jsx("img",{src:n||t||void 0,alt:"Profile",style:{objectFit:"cover",width:"100%",height:"100%"}}):e.jsx(u.Box,{display:"flex",direction:"column",align:"center",justify:"center",padding:"spacing-4",children:e.jsx(E.Icon,{name:"Image",style:{color:"var(--sa-text-subtle, #8c8f97)",width:Number(c)/2<40?Number(c)/2:40,height:Number(c)/2<40?Number(c)/2:40}})}),e.jsxs(u.Box,{direction:"column",position:"absolute",display:"flex",align:"center",justify:"center",cursor:"pointer",style:{inset:0,backgroundColor:"var(--sa-color-black-alpha-a30, #080f214a)",opacity:p?1:0,transition:"opacity 0.3s ease-in-out"},onClick:Y,children:[e.jsx("input",{ref:N,type:"file",accept:"image/*",onChange:q,disabled:l,style:{display:"none"}}),e.jsxs(u.Box,{display:"flex",align:"center",gap:"spacing-2",direction:"row",children:[e.jsx(E.Icon,{name:"Edit3",style:{color:"var(--sa-background-primary, #ffffff)"}}),e.jsx(ce,{condition:c.toNumber()>80,children:e.jsx(B.Text,{color:"gray-50",fontSize:c.toNumber()>80?"sm":"md",fontWeight:"medium",children:"Edit Image"})})]})]}),l&&e.jsx(u.Box,{direction:"column",position:"absolute",display:"flex",align:"center",justify:"center",style:{inset:0,zIndex:20,backgroundColor:"var(--sa-color-white-alpha-a80, #e5e9f640)"},children:e.jsx(u.Box,{direction:"column",borderRadius:"rounded-full",style:{animation:"spin 1s linear infinite",border:"2px solid transparent",height:"2rem",width:"2rem"},borderColor:"info-600"})}),I&&Jr.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:()=>m(!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?s==="1:1"?"min(90vw, 480px)":`min(90vw, ${re*2}px)`:"calc(100vw - 2rem)",display:"flex",flexDirection:"column"},onClick:R=>R.stopPropagation(),children:[e.jsx("div",{style:{position:"relative",width:"100%",height:"20rem",backgroundColor:"var(--sa-color-gray-100)"},children:T&&e.jsx(co,{image:T,crop:O,zoom:S,aspect:s?jl[s]:void 0,onCropChange:k,onZoomChange:V,onCropComplete:M,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(P.Button,{size:"sm",secondary:!0,onClick:()=>m(!1),children:"Cancel"}),e.jsx(P.Button,{size:"sm",primary:!0,onClick:j,children:"Crop"})]})]})}),document.body)]})}),pc=({size:r="md",direction:t="vertical",requiredTitle:l="(Required)",fullWidth:n=!1,required:o=!1,...c})=>{var a,d,y;const s=c.hideMessageError||!1,i=t==="horizontal"?r==="sm"?342:r==="lg"?400:342:void 0;return e.jsxs(u.Box,{gap:t==="horizontal"?"spacing-96":"sm",direction:t==="horizontal"?"row":"column",...c.containerProps,children:[c.title&&e.jsx(ce,{condition:!!o,fallback:e.jsxs(u.Box,{direction:"column",customMaxWidth:i,fullWidth:n,children:[e.jsx(he,{children:c.title}),e.jsx(B.Text,{fontSize:r,color:"gray-500",children:c.description})]}),children:e.jsxs(u.Box,{direction:"column",customMaxWidth:i,fullWidth:n,children:[e.jsxs(ne.Flex,{direction:"row",gap:"xs",align:"center",children:[e.jsx(he,{fontSize:r,children:c.title}),e.jsx(he,{color:"error",fontSize:r,children:l}),e.jsx(ce,{condition:!!((a=c.tooltip)!=null&&a.label),children:e.jsx(ke.Tooltip,{label:(d=c.tooltip)==null?void 0:d.label,arrowPosition:(y=c.tooltip)==null?void 0:y.arrowPosition,...c.tooltip,children:e.jsx(E.Icon,{name:"InfoCircle",size:r==="lg"?"sm":"xs",style:{color:"var(--sa-color-info-500, #00abeb)",marginTop:"6px"}})})})]}),e.jsx(ce,{condition:!!c.description,children:e.jsx(B.Text,{fontSize:r,color:"gray-500",children:c.description})})]})}),e.jsxs(ne.Flex,{direction:"column",gap:"xs",children:[e.jsx(Pl,{...c.inputProps}),!s&&c.errorMessage&&e.jsx(Ue,{message:c.errorMessage})]})]})},bc=({size:r="md",direction:t="vertical",requiredTitle:l="(Required)",fullWidth:n=!1,...o})=>{var s,i,a;const c=t==="horizontal"?r==="sm"?342:r==="lg"?400:342:void 0;return e.jsxs(u.Box,{gap:t==="horizontal"?"spacing-96":"sm",direction:t==="horizontal"?"row":"column",...o.containerProps,children:[o.title&&e.jsx(ce,{condition:!!o.inputProps.required,fallback:e.jsxs(u.Box,{direction:"column",customMaxWidth:c,fullWidth:n,children:[e.jsx(he,{children:o.title}),e.jsx(B.Text,{fontSize:r,color:"gray-500",children:o.description})]}),children:e.jsxs(u.Box,{direction:"column",customMaxWidth:c,fullWidth:n,children:[e.jsxs(ne.Flex,{direction:"row",gap:"xs",align:"center",children:[e.jsx(he,{fontSize:r,children:o.title}),e.jsx(he,{color:"error",fontSize:r,children:l}),e.jsx(ce,{condition:!!((s=o.tooltip)!=null&&s.label),children:e.jsx(ke.Tooltip,{label:(i=o.tooltip)==null?void 0:i.label,arrowPosition:(a=o.tooltip)==null?void 0:a.arrowPosition,...o.tooltip,children:e.jsx(E.Icon,{name:"InfoCircle",size:r==="lg"?"sm":"xs",style:{color:"var(--sa-color-info-500, #00abeb)",marginTop:"6px"}})})})]}),e.jsx(ce,{condition:!!o.description,children:e.jsx(B.Text,{fontSize:r,color:"gray-500",children:o.description})})]})}),o.inputProps.extended&&o.inputProps.extended]})},Cc=({items:r,id:t,handleOnUpdate:l,width:n,toggleShow:o=!0,disabled:c=!1})=>{var y;const[s,i]=h.useState([]);h.useEffect(()=>{r&&i([...r.map(b=>({id:b.id,isActive:b.isActive}))])},[r]);const a=(y=s.find(b=>b.id===t))==null?void 0:y.isActive,d=h.useCallback(()=>{i(b=>b.map(p=>p.id===t?{...p,isActive:!p.isActive}:p)),l&&l(!a)},[t,l,a]);return e.jsx(u.Box,{direction:"row",gap:"md",style:{width:n},children:o&&e.jsx(ir.Toggle,{disabled:c,checked:a,onChange:d,label:a?"Active":"Inactive"})})},vc={InputText:In,InputDropdown:On,InputSingleFile:ic,CheckBoxOptions:sc,RadioOptions:ac,InputTextArea:dc,ToggleForm:hc,ActionButton:fc,FormTitle:gc,InputDate:uc,InputImgFile:pc,Custom:bc},Nl=({customBottom:r})=>{const[t,l]=h.useState(!1),n=()=>{window.scrollY>window.screenY?l(!0):l(!1)},o=()=>{window.scrollTo({top:0,behavior:"smooth"})};return h.useEffect(()=>(window.addEventListener("scroll",n),()=>{window.removeEventListener("scroll",n)}),[]),e.jsx(u.Box,{direction:"column",style:{position:"fixed",bottom:0,right:0},children:e.jsx(u.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(P.Button,{secondary:!0,size:"xs",onClick:o,type:"button",iconLeft:e.jsx(E.Icon,{width:16,size:"xs",name:"ArrowPullUp",style:{color:"var(--sa-background-brand, #04254f)"}})})})})},Me="sa-sidepanel-item",_l="sa-sidepanel-item-styles",xc=`
|
|
47
47
|
.${Me} {
|
|
48
48
|
display: block;
|
|
49
49
|
box-sizing: border-box;
|