import{r as l,j as t}from"./@radix-DP6vWzyx.js";import{S as v}from"./dots-horizontal-DK5Duzx4.js";import{S}from"./chevron-right-double-DoD8iXWM.js";import{aI as w,Q as j,I as C}from"./index-QQb7wQEC.js";import{o as b}from"./url-D5le3J4q.js";import{b as x,c as P}from"./@react-router-BMhZulnd.js";import{d as E}from"./index-BVJ8n2-j.js";const L=r=>l.createElement("svg",{viewBox:"0 0 24 24",fill:"black",xmlns:"http://www.w3.org/2000/svg",...r},l.createElement("g",{id:"chevron-left-double"},l.createElement("path",{id:"Icon (Stroke)",fillRule:"evenodd",clipRule:"evenodd",d:"M11.7071 6.29289C12.0976 6.68342 12.0976 7.31658 11.7071 7.70711L7.41421 12L11.7071 16.2929C12.0976 16.6834 12.0976 17.3166 11.7071 17.7071C11.3166 18.0976 10.6834 18.0976 10.2929 17.7071L5.29289 12.7071C4.90237 12.3166 4.90237 11.6834 5.29289 11.2929L10.2929 6.29289C10.6834 5.90237 11.3166 5.90237 11.7071 6.29289ZM18.7071 6.29289C19.0976 6.68342 19.0976 7.31658 18.7071 7.70711L14.4142 12L18.7071 16.2929C19.0976 16.6834 19.0976 17.3166 18.7071 17.7071C18.3166 18.0976 17.6834 18.0976 17.2929 17.7071L12.2929 12.7071C11.9024 12.3166 11.9024 11.6834 12.2929 11.2929L17.2929 6.29289C17.6834 5.90237 18.3166 5.90237 18.7071 6.29289Z"}))),N=r=>l.createElement("svg",{viewBox:"0 0 24 24",fill:"black",xmlns:"http://www.w3.org/2000/svg",...r},l.createElement("g",{id:"chevron-left"},l.createElement("path",{id:"Icon (Stroke)",fillRule:"evenodd",clipRule:"evenodd",d:"M15.7071 5.29289C16.0976 5.68342 16.0976 6.31658 15.7071 6.70711L10.4142 12L15.7071 17.2929C16.0976 17.6834 16.0976 18.3166 15.7071 18.7071C15.3166 19.0976 14.6834 19.0976 14.2929 18.7071L8.29289 12.7071C7.90237 12.3166 7.90237 11.6834 8.29289 11.2929L14.2929 5.29289C14.6834 4.90237 15.3166 4.90237 15.7071 5.29289Z"})));function q({paginate:r,searchParams:o}){const d=x(),{index:a,total_pages:c}=r;function u(n){const i=new URLSearchParams(b(o));i.set("page",n.toString()),d(`?${i.toString()}`,{preventScrollReset:!1})}const m=()=>{const n=[];let p=!1,g=!1;for(let e=1;e<=c;e++){const s=e>1&&e<c&&Math.abs(e-a)>1;(e===1||e===c||s||Math.abs(e-a)<=1)&&(s?e<a&&!p?(n.push(t.jsx(f,{},"ellipsis-left")),p=!0):e>a&&!g&&(n.push(t.jsx(f,{},"ellipsis-right")),g=!0):n.push(t.jsx(h,{"aria-label":`Go to page ${e}`,"aria-current":e===a,className:`${e===a?"!bg-primary-500 text-theme-text-negative":""}`,onClick:()=>u(e),disabled:e===a,children:e},e)))}return n};return t.jsx("nav",{role:"navigation","aria-label":"Pagination Navigation",children:t.jsxs("ul",{className:"flex gap-1",children:[t.jsx("li",{children:t.jsx(h,{disabled:a===1,onClick:()=>u(1),"aria-label":"Go to first page",children:t.jsx(L,{className:"h-4 w-4 group-disabled/button:fill-neutral-300"})})}),t.jsx("li",{children:t.jsx(h,{disabled:a===1,onClick:()=>u(a-1),"aria-label":"Go to previous page",children:t.jsx(N,{className:"h-4 w-4 group-disabled/button:fill-neutral-300"})})}),m().map((n,i)=>t.jsx("li",{children:n},i)),t.jsx("li",{children:t.jsx(h,{disabled:a===c,onClick:()=>u(a+1),"aria-label":"Go to next page",children:t.jsx(w,{className:"h-4 w-4 group-disabled/button:fill-neutral-300"})})}),t.jsx("li",{children:t.jsx(h,{disabled:a===c,onClick:()=>u(c),"aria-label":"Go to last page",children:t.jsx(S,{className:"h-4 w-4 group-disabled/button:fill-neutral-300"})})})]})})}function f(){return t.jsx("div",{className:"flex h-[36px] w-[36px] items-center justify-center rounded-sm border border-theme-border-moderate",children:t.jsx(v,{className:"h-4 w-4"})})}const h=l.forwardRef(({className:r,...o},d)=>t.jsx("button",{...o,ref:d,className:j("group/button flex h-[36px] w-[36px] items-center justify-center rounded-sm border border-neutral-300 hover:bg-neutral-200 active:border-neutral-400 active:bg-neutral-300 disabled:pointer-events-none disabled:bg-theme-surface-primary ",r)}));h.displayName="PaginationButton";const R=["equals:","contains:","startswith:","endswith:","gte:","gt:","lte:","lt:"];function y(r){const o=R.find(d=>r.startsWith(d));return o?r.slice(o.length):r}const k=l.forwardRef(({searchParams:r,searchContains:o=!0,...d},a)=>{const c=x(),[u]=P(),[m,n]=l.useState(y(r.name||"")||""),i=l.useMemo(()=>E(p,500),[]);l.useEffect(()=>()=>{i.cancel()},[i]);function p(e){const s=new URLSearchParams({...Object.fromEntries(u),...b(r)});s.delete("logical_operator"),e?(s.set("name",o?`contains:${e}`:`${e}`),s.set("operator","or"),s.set("page","1")):(s.delete("name"),s.delete("operator")),c(`?${s.toString()}`,{preventScrollReset:!0,replace:!0})}function g(e){const{value:s}=e.target;n(s),i(s)}return t.jsx(C,{...d,ref:a,value:m,onChange:g,placeholder:"Search...",inputSize:"md"})});k.displayName="SearchField";export{q as P,k as S};
