import{a as e}from"./rolldown-runtime-CNC7AqOf.js";import{t}from"./react-Augu_vA3.js";import{K as n,Y as r,_t as i,ct as a,dt as o,ii as s,lt as c,mt as l,ni as u,zi as d}from"./forms-CL2ODv4X.js";import{t as f}from"./useTranslation-B_YCgyrR.js";import{t as p}from"./jsx-runtime-CTknu7_t.js";import{n as m,r as h,t as g}from"./useAdjustColorDarkness-Ba6EO9yY.js";import{t as _}from"./ChevronUp-DUPqfbQr.js";var v=e(p());function y({size:e=`1.2rem`,color:t=`#000`}){return(0,v.jsx)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,xmlnsXlink:`http://www.w3.org/1999/xlink`,x:`0px`,y:`0px`,style:{width:e,height:e},viewBox:`0 0 12 12`,children:(0,v.jsx)(`path`,{d:`m7.75,11c-.192,0-.384-.073-.53-.22L2.97,6.53c-.293-.293-.293-.768,0-1.061L7.22,1.22c.293-.293.768-.293,1.061,0s.293.768,0,1.061l-3.72,3.72,3.72,3.72c.293.293.293.768,0,1.061-.146.146-.338.22-.53.22Z`,strokeWidth:`0`,fill:t})})}function b({size:e=`1.2rem`,color:t=`#000`}){return(0,v.jsxs)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,xmlnsXlink:`http://www.w3.org/1999/xlink`,x:`0px`,y:`0px`,style:{width:e,height:e},viewBox:`0 0 12 12`,children:[(0,v.jsx)(`polyline`,{points:`5.75 2 1.75 6 5.75 10`,fill:`none`,stroke:t,strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:`1.5`}),(0,v.jsx)(`polyline`,{points:`10.25 2 6.25 6 10.25 10`,fill:`none`,stroke:t,strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:`1.5`,"data-color":`color-2`})]})}function x({size:e=`1.2rem`,color:t=`#000`}){return(0,v.jsx)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,xmlnsXlink:`http://www.w3.org/1999/xlink`,x:`0px`,y:`0px`,style:{width:e,height:e},viewBox:`0 0 12 12`,children:(0,v.jsx)(`path`,{d:`m4.25,11c-.192,0-.384-.073-.53-.22-.293-.293-.293-.768,0-1.061l3.72-3.72-3.72-3.72c-.293-.293-.293-.768,0-1.061s.768-.293,1.061,0l4.25,4.25c.293.293.293.768,0,1.061l-4.25,4.25c-.146.146-.338.22-.53.22Z`,strokeWidth:`0`,fill:t})})}function S({size:e=`1.2rem`,color:t=`#000`}){return(0,v.jsxs)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,xmlnsXlink:`http://www.w3.org/1999/xlink`,x:`0px`,y:`0px`,style:{width:e,height:e},viewBox:`0 0 12 12`,children:[(0,v.jsx)(`path`,{d:`m6.25,10.75c-.192,0-.384-.073-.53-.22-.293-.293-.293-.768,0-1.061l3.47-3.47-3.47-3.47c-.293-.293-.293-.768,0-1.061s.768-.293,1.061,0l4,4c.293.293.293.768,0,1.061l-4,4c-.146.146-.338.22-.53.22Z`,fill:t,strokeWidth:`0`,"data-color":`color-2`}),(0,v.jsx)(`path`,{d:`m1.75,10.75c-.192,0-.384-.073-.53-.22-.293-.293-.293-.768,0-1.061l3.47-3.47L1.22,2.53c-.293-.293-.293-.768,0-1.061s.768-.293,1.061,0l4,4c.293.293.293.768,0,1.061l-4,4c-.146.146-.338.22-.53.22Z`,strokeWidth:`0`,fill:t})]})}var C=typeof window<`u`?window.location.origin:`http://localhost`;function w(e){let t=e?.links;if(!t||Array.isArray(t)||typeof t!=`object`)return;let n=t.previous?.length?t.previous:void 0,r=t.next?.length?t.next:void 0;if(!(!n&&!r))return{previous:n,next:r}}function T(e){try{let t=Number(new URL(e,C).searchParams.get(`page`));return Number.isInteger(t)&&t>0?t:null}catch{return null}}function E(e,t){let{currentPage:n}=t,r=Math.max(t.totalPages,1);if(e===`previous`||e===`next`){let i=w(t.pagination),a=i?.[e];if(a){let e=T(a);if(e!==null)return e}else if(i)return null;let o=e===`next`?n+1:n-1;return o<1||o>r?null:o}let i=e===`first`?1:e===`last`?r:e;return!Number.isInteger(i)||i<1||i>r?null:i}function D(e){return{canPrevious:E(`previous`,e)!==null,canNext:E(`next`,e)!==null}}var O=e(t(),1),k=a.button` background-color: ${e=>e.theme.backgroundColor}; border-color: ${e=>e.theme.borderColor}; cursor: pointer; &:hover:not(:disabled) { background-color: ${e=>e.theme.hoverColor}; } &:disabled { opacity: 0.5; cursor: not-allowed; } `,A=a.input` field-sizing: content; min-width: 3ch; background-color: transparent; border-color: ${e=>e.theme.borderColor}; color: ${e=>e.theme.color}; &:focus { border-color: ${e=>e.theme.focusBorderColor}; } `,j={totalPages:1,currentPage:1,currentPerPage:`10`,onPageChange:e=>e,onRowsChange:e=>e,totalRecords:0};function M(e){e={...j,...e};let[t]=f(),r=i(),[a,o]=(0,O.useState)(String(e.currentPage));(0,O.useEffect)(()=>{o(String(e.currentPage))},[e.currentPage]);let s=t=>{let n=E(t,{currentPage:e.currentPage,totalPages:e.totalPages,pagination:e.pagination});return n!==null&&e.onPageChange(n),n},{canPrevious:c,canNext:l}=D({currentPage:e.currentPage,totalPages:e.totalPages,pagination:e.pagination});return(0,v.jsxs)(`div`,{className:`flex flex-col sm:flex-row sm:items-center sm:justify-between gap-4 mt-3 pb-2`,children:[typeof e.totalRecords==`number`&&(0,v.jsxs)(`span`,{className:`text-sm font-medium`,children:[t(`total_results`),`: `,e.totalRecords]}),(0,v.jsxs)(`div`,{className:`flex justify-center space-x-4 items-center`,style:{color:r.$3},children:[(0,v.jsxs)(`div`,{className:`flex items-center`,children:[(0,v.jsx)(k,{type:`button`,className:`p-2 sm:p-[0.725rem] border rounded-l-md shadow-sm`,theme:{hoverColor:r.$4,backgroundColor:r.$1,borderColor:r.$24},disabled:!c,"data-cy":`paginationFirstPage`,onClick:()=>s(`first`),children:(0,v.jsx)(b,{size:`0.9rem`,color:r.$3})}),(0,v.jsx)(k,{type:`button`,className:`p-2 sm:p-[0.725rem] border-b border-t border-r rounded-r-md shadow-sm`,theme:{hoverColor:r.$4,backgroundColor:r.$1,borderColor:r.$24},disabled:!c,"data-cy":`paginationPreviousPage`,onClick:()=>s(`previous`),children:(0,v.jsx)(y,{size:`0.9rem`,color:r.$3})})]}),(0,v.jsxs)(`div`,{className:`flex items-center space-x-1.5`,children:[(0,v.jsx)(A,{type:`text`,value:a,onChange:e=>{let t=e.target.value;if(t===``){o(``);return}let n=t.replace(/[^0-9]/g,``);o(n)},onBlur:()=>{let t=parseInt(a,10);(isNaN(t)?null:s(t))===null&&o(String(e.currentPage))},onKeyDown:e=>{e.key===`Enter`&&e.target.blur()},onFocus:e=>e.target.select(),theme:{borderColor:r.$24,focusBorderColor:r.$3,color:r.$3},className:`h-8 text-sm font-medium text-center rounded-md border focus:outline-none focus:ring-0`}),(0,v.jsxs)(`span`,{className:`text-sm font-medium`,children:[`/ `,e.totalPages]})]}),(0,v.jsxs)(`div`,{className:`flex`,children:[(0,v.jsx)(k,{type:`button`,className:`p-2 sm:p-[0.725rem] border-t border-b border-l rounded-l-md shadow-sm`,theme:{hoverColor:r.$4,backgroundColor:r.$1,borderColor:r.$24},disabled:!l,"data-cy":`paginationNextPage`,onClick:()=>s(`next`),children:(0,v.jsx)(x,{size:`0.9rem`,color:r.$3})}),(0,v.jsx)(k,{type:`button`,className:`p-2 sm:p-[0.725rem] border rounded-r-md shadow-sm`,theme:{hoverColor:r.$4,backgroundColor:r.$1,borderColor:r.$24},disabled:!l,"data-cy":`paginationLastPage`,onClick:()=>s(`last`),children:(0,v.jsx)(S,{size:`0.9rem`,color:r.$3})})]})]}),(0,v.jsxs)(`div`,{className:`flex items-center space-x-2`,children:[(0,v.jsxs)(`span`,{className:`text-sm font-medium`,style:{color:r.$3},children:[t(`rows`),`:`]}),(0,v.jsxs)(n,{className:`shadow-sm`,value:e.currentPerPage,onValueChange:t=>e.onRowsChange(t),customSelector:!0,dismissable:!1,searchable:!1,dropdownIndicatorClassName:`pl-0`,children:[(0,v.jsx)(`option`,{value:`10`,children:`10`}),(0,v.jsx)(`option`,{value:`50`,children:`50`}),(0,v.jsx)(`option`,{value:`100`,children:`100`})]})]})]})}var N=e(o(),1);function P(e){let t=i();return(0,v.jsx)(`div`,{className:(0,N.default)(`flex flex-col`,{"mt-2":!e.withoutPadding}),children:(0,v.jsx)(`div`,{className:(0,N.default)(`align-middle inline-block min-w-full`,{"py-1.5":!e.withoutPadding,"pb-0":e.withoutBottomPadding}),children:(0,v.jsx)(`div`,{className:(0,N.default)(`overflow-hidden border rounded-md border-b border-t`,{"border-b-0":e.withoutBottomBorder,"border-t-0":e.withoutTopBorder,"border-l-0":e.withoutLeftBorder,"border-r-0":e.withoutRightBorder,"rounded-b-none":e.withoutBottomRounding}),style:{backgroundColor:t.$1,color:t.$3,borderColor:t.$24},children:(0,v.jsx)(`div`,{className:`overflow-auto min-w-full rounded-md shadow-sm ${e.className}`,style:{...e.style,height:e.style?.height||`auto`},children:(0,v.jsx)(`table`,{className:(0,N.default)({"min-w-full table-auto":!e.resizable,"min-w-full table-fixed":e.resizable}),children:e.children})})})})})}function F(e){let[t]=f();return(0,v.jsxs)(`tbody`,{style:e.style,ref:e.innerRef,children:[!e.data&&e.showHelperPlaceholders&&(0,v.jsx)(q,{children:(0,v.jsx)(V,{colSpan:20,children:(0,v.jsx)(l,{})})}),e.data&&e.showHelperPlaceholders&&e.data.data.meta.pagination.total===0&&(0,v.jsx)(q,{children:(0,v.jsx)(V,{colSpan:20,children:(0,v.jsx)(`p`,{children:t(`empty_table`)})})}),e.children]})}var I=d(),L=u(`columnWidths`,{});function R(e){let t=(0,O.useRef)(null),[n,r]=(0,O.useState)(!1),[i,a]=(0,O.useState)(0),[o,c]=(0,O.useState)(0),[l,u]=s(L),d=(0,O.useCallback)(e=>{let n=t.current?.offsetWidth,r=e.clientX-t.current.getBoundingClientRect().left;return n&&r>n-10},[t]),f=(0,O.useMemo)(()=>e?(0,I.get)(l,e,-1):-1,[l,e]),p=(0,O.useCallback)(t=>{e&&u(n=>({...n,[e]:t}))},[e]),m=(0,O.useCallback)(n=>{if(!e||n.button!==0)return;let i=t.current?.offsetWidth,o=n.clientX-t.current.getBoundingClientRect().left;if(i&&o>i-15){r(!0),a(n.clientX),c(i);let e=t.current?.closest(`table`);e&&(e.style.userSelect=`none`)}},[e]),h=(0,O.useCallback)(r=>{if(document.body.style.cursor=d(r)&&e?`ew-resize`:``,!n||!t.current||f===null)return;let a=r.clientX-i,s=o+a-45;s>=1&&(p(s),t.current.style.width=`${s}px`)},[n,i,o,f,p]),g=(0,O.useCallback)(()=>{r(!1);let e=t.current?.closest(`table`);e&&(e.style.userSelect=``)},[]);return(0,O.useEffect)(()=>{n?(document.addEventListener(`mousemove`,h),document.addEventListener(`mouseup`,g)):(document.removeEventListener(`mousemove`,h),document.removeEventListener(`mouseup`,g));let r=t.current?.closest(`table`);return r&&(n?r.classList.add(`is-resizing`):r.classList.remove(`is-resizing`)),document.body.style.cursor=n&&e?`ew-resize`:``,()=>{document.removeEventListener(`mousemove`,h),document.removeEventListener(`mouseup`,g)}},[n,h,g]),{thRef:t,currentWidth:f,handleMouseDown:m,handleMouseMove:h,handleMouseUp:g,handleDoubleClick:(0,O.useCallback)(n=>{let r=t.current?.offsetWidth,i=n.clientX-t.current.getBoundingClientRect().left;e&&r&&i>r-30&&(p(-1),t.current&&(t.current.style.width=`auto`))},[e,p]),setCurrentWidth:p,isResizing:n,inResizeZone:d}}function z(e){let{customizeTextColor:t}=e,n=h(),r=i(),{red:a,green:o,blue:s,hex:l}=g(c()),u=m(a,o,s)?-220:220,d=t?n(l,u):r.$3;return(0,v.jsx)(B,{...e,color:d})}function B(e){let[t]=s(L),n=O.useRef(null);return(0,O.useEffect)(()=>{if(n.current){let r=t[e.resizable]??-1;n.current.style.maxWidth=`${r}px`}},[t]),(0,v.jsx)(`td`,{width:e.width,colSpan:e.colSpan,rowSpan:e.rowSpan,onClick:e.onClick,className:(0,N.default)(`text-sm break-words ${e.className} overflow-hidden whitespace-nowrap text-ellipsis`,{"px-2 lg:px-2.5 xl:px-4 py-2":!e.withoutPadding}),style:{color:e.color,...e.style},ref:n,children:e.children})}var V=O.memo(z),H={isCurrentlyUsed:!1},U=a.span` background-color: ${({theme:e})=>e.backgroundColor}; &:hover { background-color: ${({theme:e})=>e.hoverBackgroundColor}; } `;function W(e){e={...H,...e};let t=i(),{thRef:n,currentWidth:a,handleMouseDown:o,handleDoubleClick:s,handleMouseMove:c,isResizing:l}=R(e.resizable),[u,d]=(0,O.useState)(`desc`),f=(0,O.useCallback)(()=>{if(e.onColumnClick){let t=e.sortKey??e.id,n=u===`asc`?`desc`:`asc`;d(n),e.onColumnClick({sort:`${t}|${n}`,field:t})}},[u,e.onColumnClick,e.id,e.sortKey]);return(0,v.jsxs)(`th`,{ref:n,style:{color:e.textColor||t.$17,borderColor:t.$20,width:a,...e.style},onMouseDown:o,onDoubleClick:s,className:(0,N.default)(`text-left font-normal tracking-wider whitespace-nowrap ${e.className}`,{"border-r relative":e.resizable,"py-2.5":!e.withoutVerticalPadding,"text-xs":e.textSize===`extraSmall`,"text-sm":e.textSize===`small`||!e.textSize,"px-2 lg:px-2.5 xl:px-4":!e.withoutHorizontalPadding,"cursor-pointer":e.onClick}),onMouseMove:c,onClick:e.onClick,children:[(0,v.jsx)(`div`,{className:`flex items-center space-x-1 ${e.childrenClassName} select-none`,style:{overflow:`hidden`,textOverflow:`ellipsis`,whiteSpace:`nowrap`},children:e.onColumnClick?(0,v.jsxs)(`div`,{className:`flex items-center space-x-1 overflow-hidden whitespace-nowrap text-ellipsis cursor-pointer`,onClick:f,style:{width:a===-1?`auto`:a},children:[(0,v.jsx)(`span`,{className:`overflow-hidden whitespace-nowrap text-ellipsis`,children:e.children}),(0,v.jsx)(`div`,{className:(0,N.default)(`flex items-center bg-opacity-25`,{hidden:a!==-1&&a<50}),children:e.useOnlyCurrentSortDirectionIcon?(0,v.jsx)(v.Fragment,{children:e.isCurrentlyUsed&&(0,v.jsx)(v.Fragment,{children:u===`desc`?e.descIcon:e.ascIcon})}):(0,v.jsx)(v.Fragment,{children:e.isCurrentlyUsed?(0,v.jsxs)(`div`,{className:`flex flex-col items-center justify-center -space-y-1`,children:[(0,v.jsx)(`div`,{children:(0,v.jsx)(_,{size:`0.7rem`,strokeWidth:`3`,color:u===`asc`?t.$3:t.$17})}),(0,v.jsx)(`div`,{children:(0,v.jsx)(r,{size:`0.7rem`,strokeWidth:`3`,color:u===`desc`?t.$3:t.$17})})]}):(0,v.jsxs)(`div`,{className:`flex flex-col items-center justify-center -space-y-1`,children:[(0,v.jsx)(`div`,{children:(0,v.jsx)(_,{size:`0.7rem`,color:t.$17,strokeWidth:`3`})}),(0,v.jsx)(`div`,{children:(0,v.jsx)(r,{size:`0.7rem`,color:t.$17,strokeWidth:`3`})})]})})})]}):(0,v.jsx)(`span`,{children:e.children})}),e.resizable?(0,v.jsx)(U,{className:`column-resizer block absolute inset-y-0 right-0 m-0 w-1 h-full p-0 cursor-col-resize border border-transparent hover:transition duration-50`,theme:{backgroundColor:l?t.$3:`transparent`,hoverBackgroundColor:t.$3}}):null]})}var G=O.memo(W);function K(e){let{backgroundColor:t}=e,n=i();return(0,v.jsx)(`thead`,{className:`border-b`,style:{backgroundColor:t||n.$1,borderColor:n.$20,...e.style},children:(0,v.jsx)(`tr`,{children:e.children})})}function q(e){let{onClick:t,innerRef:n,backgroundColor:r,resource:a,withoutBackgroundColor:o=!1,memoValue:s,...c}=e,l=i();return(0,v.jsx)(`tr`,{style:{backgroundColor:o?void 0:r||l.$1,...e.style},onClick:t=>e.onClick&&t.target?.nodeName===`TD`?e.onClick():null,ref:n,...c,className:(0,N.default)(`${e.className}`,{"cursor-pointer":t}),tabIndex:e.tabIndex,children:e.children})}var J=(0,O.memo)(q,(e,t)=>(0,I.isEqual)(e.resource,t.resource)&&(0,I.isEqual)(e.memoValue,t.memoValue));export{V as a,P as c,x as d,b as f,G as i,M as l,q as n,L as o,y as p,K as r,F as s,J as t,S as u};