1(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[6488],{8687:(e,t,a)=>{"use strict";a.r(t),a.d(t,{default:()=>R});var r=a(37876),l=a(14232),s=a(89099),n=a(48230),i=a.n(n),c=a(94246),d=a(35845),o=a(21483),u=a(35588),m=a(62125),h=a(28567),x=a(32764),g=a(78769),p=a(31452),f=a(69673),v=a(91256),y=a(67669),b=a(86854),j=a(32093),N=a(36365),w=a(68974),k=a(35765),S=a(28022);function A(e){if(!e)return"â";let t=new Date(e);return Number.isNaN(t.getTime())?"â":t.toLocaleString(void 0,{year:"numeric",month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"})}function C(e){return e.compositeId}function R(){let e=(0,s.useRouter)(),{user:t,loading:a}=(0,c.A)(),{can:n}=(0,d.A)(),R=n("canManageArchivedRecords"),E=n("canDeleteArchivedRecords"),[D,O]=(0,l.useState)([]),[P,T]=(0,l.useState)([]),[z,M]=(0,l.useState)([]),[$,L]=(0,l.useState)(0),[V,B]=(0,l.useState)(!0),[I,_]=(0,l.useState)(null),[q,F]=(0,l.useState)(null),[Z,U]=(0,l.useState)(""),[W,Y]=(0,l.useState)("all"),[G,J]=(0,l.useState)("all"),[X,H]=(0,l.useState)(""),[K,Q]=(0,l.useState)(""),[ee,et]=(0,l.useState)("archivedAt"),[ea,er]=(0,l.useState)("desc"),[el,es]=(0,l.useState)(1),[en,ei]=(0,l.useState)(1),[ec,ed]=(0,l.useState)(0),[eo,eu]=(0,l.useState)(20),[em,eh]=(0,l.useState)(null),[ex,eg]=(0,l.useState)(!1),[ep,ef]=(0,l.useState)(!1),[ev,ey]=(0,l.useState)(!1),[eb,ej]=(0,l.useState)(!1),eN=(0,l.useMemo)(()=>({search:{value:Z,set:U,defaultValue:"",debounce:!0},module:{value:W,set:Y,defaultValue:"all"},archivedBy:{value:G,set:J,defaultValue:"all"},startDate:{value:X,set:H,defaultValue:""},endDate:{value:K,set:Q,defaultValue:""},sortBy:{value:ee,set:et,defaultValue:"archivedAt"},sortOrder:{value:ea,set:er,defaultValue:"desc"},pageSize:{value:eo,set:eu,defaultValue:20},page:{value:el,set:es,defaultValue:1}}),[Z,W,G,X,K,ee,ea,eo,el]),{isInitialized:ew}=(0,o.A)(eN),{selectedIds:ek,toggleSelection:eS,toggleSelectAll:eA,clearSelection:eC,isAllSelected:eR,selectedCount:eE}=(0,j.A)(C),eD=(0,l.useCallback)(async function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:el;try{var t,a,r;B(!0),_(null);let l=new URLSearchParams({page:e.toString(),limit:eo.toString(),sortBy:ee,sortOrder:ea,includeMeta:"true",...Z&&{search:Z},..."all"!==W&&{module:W},..."all"!==G&&{archivedBy:G},...X&&{startDate:X},...K&&{endDate:K}}),s=await fetch("/api/archived-records?".concat(l)),n=await s.json();if(!s.ok)throw Error(n.error||"Failed to fetch archived records");O(n.records||[]),T(n.modules||[]),M(n.archivers||[]),L(n.totalArchived||0),ei((null==(t=n.pagination)?void 0:t.totalPages)||1),ed((null==(a=n.pagination)?void 0:a.totalItems)||0),es((null==(r=n.pagination)?void 0:r.currentPage)||e)}catch(e){_(e.message)}finally{B(!1)}},[el,eo,Z,W,G,X,K,ee,ea]);(0,l.useEffect)(()=>{if(!a&&t&&R&&ew){let e=setTimeout(()=>eD(el),400*!!Z);return()=>clearTimeout(e)}},[a,t,R,ew,el,eo,Z,W,G,X,K,ee,ea,eD]);let eO=async e=>{let t=await fetch("/api/archived-records/bulk",{method:"DELETE",headers:{"Content-Type":"application/json"},body:JSON.stringify({compositeIds:e})}),a=await t.json();if(!t.ok)throw Error(a.error||"Failed to delete records permanently");return a},eP=async e=>{let t=await fetch("/api/archived-records/bulk",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:"restore",compositeIds:e})}),a=await t.json();if(!t.ok)throw Error(a.error||"Failed to restore records");return a},eT=async e=>{try{ej(!0),_(null);let t=await eP([e.compositeId]);F(t.message||"Record restored"),eD(el)}catch(e){_(e.message)}finally{ej(!1)}},ez=async()=>{if(em)try{eg(!0),_(null);let e=await eO([em.compositeId]);eh(null),F(e.message||"Record permanently deleted"),eD(el)}catch(e){_(e.message)}finally{eg(!1)}},eM=async()=>{if(ek.length)try{ey(!0),_(null);let e=await eO(ek);ef(!1),eC(),F(e.message||"Records permanently deleted"),eD(el)}catch(e){_(e.message)}finally{ey(!1)}};return a?(0,r.jsx)(u.A,{children:(0,r.jsx)("div",{className:"flex items-center justify-center min-h-screen",children:(0,r.jsx)("div",{className:"animate-spin rounded-full h-32 w-32 border-b-2 border-violet-600"})})}):t?R?(0,r.jsx)(u.A,{children:(0,r.jsxs)("div",{className:"py-4 sm:py-6 min-w-0 overflow-x-hidden",children:[(0,r.jsx)("div",{className:"relative overflow-hidden rounded-2xl border border-gray-200 dark:border-gray-700 bg-white dark:bg-gray-800 shadow-sm mb-6 sm:mb-8",children:(0,r.jsxs)("div",{className:"relative p-4 sm:p-6 flex flex-col lg:flex-row lg:items-center lg:justify-between gap-4",children:[(0,r.jsxs)("div",{className:"flex items-center gap-3 sm:gap-4 min-w-0",children:[(0,r.jsx)("div",{className:"p-2.5 sm:p-3 rounded-xl bg-amber-100 dar
1k:bg-amber-900/30 shrink-0",children:(0,r.jsx)(N.A,{className:"h-7 w-7 sm:h-8 sm:w-8 text-amber-600"})}),(0,r.jsxs)("div",{className:"min-w-0",children:[(0,r.jsx)("h1",{className:"text-xl sm:text-3xl font-bold text-gray-900 dark:text-white",children:"Archived Records"}),(0,r.jsxs)("p",{className:"mt-1 text-sm sm:text-base text-gray-600 dark:text-gray-400",children:["Review soft-archived records from all CRM modules and permanently delete when needed.",$>0&&(0,r.jsxs)("span",{className:"ml-2 text-gray-500",children:["(",$.toLocaleString()," archived)"]})]})]})]}),(0,r.jsxs)(m.$,{variant:"outline",size:"sm",onClick:()=>eD(el),disabled:V,className:"w-full lg:w-auto justify-center",children:[(0,r.jsx)(w.A,{className:"h-4 w-4 mr-2 ".concat(V?"animate-spin":"")}),"Refresh"]})]})}),P.length>0&&(0,r.jsx)("div",{className:"grid grid-cols-2 sm:grid-cols-3 lg:grid-cols-4 xl:grid-cols-8 gap-3 mb-6",children:P.map(e=>(0,r.jsxs)("button",{type:"button",onClick:()=>{Y(t=>t===e.key?"all":e.key),es(1),eC()},className:"rounded-xl border p-3 text-left transition-colors ".concat(W===e.key?"border-violet-500 bg-violet-50 dark:bg-violet-900/20":"border-gray-200 dark:border-gray-700 bg-white dark:bg-gray-800 hover:border-gray-300"),children:[(0,r.jsx)("p",{className:"text-xs text-gray-500 dark:text-gray-400 truncate",children:e.label}),(0,r.jsx)("p",{className:"text-lg font-semibold text-gray-900 dark:text-white",children:e.count})]},e.key))}),I&&(0,r.jsx)(g.F,{variant:"danger",className:"mb-6",children:(0,r.jsx)("p",{className:"text-sm",children:I})}),q&&(0,r.jsx)(g.F,{variant:"success",className:"mb-6",children:(0,r.jsx)("p",{className:"text-sm",children:q})}),(0,r.jsx)(v.A,{searchTerm:Z,onSearchChange:U,searchPlaceholder:"Search title, notes, names, outcomes...",onSubmit:()=>{es(1),eC(),eD(1)},onClear:()=>{U(""),Y("all"),J("all"),H(""),Q(""),et("archivedAt"),er("desc"),es(1),eC(),F(null)},filters:[{key:"module",label:"Module",value:W,onChange:e=>{Y(e),es(1)},options:[{value:"all",label:"All Modules"},...P.map(e=>({value:e.key,label:"".concat(e.label," (").concat(e.count,")")}))]},{key:"archivedBy",label:"Archived by",value:G,onChange:e=>{J(e),es(1)},options:[{value:"all",label:"All users"},...z.map(e=>({value:e._id,label:e.name||e.email}))]},{key:"sortBy",label:"Sort by",value:ee,onChange:e=>{et(e),es(1)},options:[{value:"archivedAt",label:"Archived date"},{value:"sortDate",label:"Record date"},{value:"title",label:"Title"},{value:"moduleLabel",label:"Module"}]},{key:"sortOrder",label:"Order",value:ea,onChange:e=>{er(e),es(1)},options:[{value:"desc",label:"Newest first"},{value:"asc",label:"Oldest first"}]},{key:"startDate",label:"Archived from",type:"date",value:X,onChange:e=>{H(e),es(1)}},{key:"endDate",label:"Archived to",type:"date",value:K,onChange:e=>{Q(e),es(1)}}]}),(0,r.jsx)(b.A,{selectedCount:eE,itemLabel:"archived record",canDelete:E,deleteLabel:"Delete Permanently",onDelete:()=>ef(!0),onClear:eC}),(0,r.jsx)(h.Zp,{className:"min-w-0 overflow-hidden",children:V?(0,r.jsx)("div",{className:"flex justify-center py-16",children:(0,r.jsx)("div",{className:"animate-spin rounded-full h-10 w-10 border-b-2 border-violet-600"})}):0===D.length?(0,r.jsxs)("div",{className:"text-center py-16 text-gray-500",children:[(0,r.jsx)(N.A,{className:"h-12 w-12 mx-auto mb-3 opacity-40"}),(0,r.jsx)("p",{className:"font-medium",children:"No archived records found"}),(0,r.jsx)("p",{className:"text-sm mt-1",children:"Try adjusting your filters or archive records from their module pages."})]}):(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("div",{className:"hidden md:block overflow-x-auto",children:(0,r.jsxs)("table",{className:"w-full text-sm min-w-[960px]",children:[(0,r.jsx)("thead",{children:(0,r.jsxs)("tr",{className:"text-left text-gray-500 border-b border-gray-200 dark:border-gray-700",children:[(0,r.jsx)("th",{className:"p-4 font-medium w-10",children:E&&(0,r.jsx)("input",{type:"checkbox",checked:eR(D),onChange:()=>eA(D),"aria-label":"Select all on page"})}),(0,r.jsx)("th",{className:"p-4 font-medium",children:"Record"}),(0,r.jsx)("th",{className:"p-4 font-medium",children:"Module"}),(0,r.jsx)("th",{className:"p-4 font-medium",children:"Archived"}),(0,r.jsx)("th",{className:"p-4 font-medium",children:"Archived by"}),(0,r.jsx)("th",{className:"p-4 font-medium text-right",children:"Actions"})]})}),(0,r.jsx)("tbody",{children:D.map(e=>{var t,a;return(0,r.jsxs)("tr",{className:"border-b border-gray-100 dark:border-gray-800 hover:bg-gray-50 dark:hover:bg-gray-800/50",children:[(0,r.jsx)("td",{className:"p-4",children:E&&(0,r.jsx)("input",{type:"checkbox",checked:ek.includes(e.compositeId),onChange:()=>eS(e.compositeId),"aria-label":"Select ".concat(e.title)})}),(0,r.jsxs)("td",{className:"p-4",children:[(0,r.jsx)("div",{className:"font-medium text-gray-900 dark:text-white",children:e.title}),e.subtitle&&(0,r.jsx)("div",{className:"text-xs text-gray-500 mt-0.5 truncate max-w-md",children:e.subt
1itle})]}),(0,r.jsx)("td",{className:"p-4",children:(0,r.jsx)(x.E,{variant:"secondary",children:e.moduleLabel})}),(0,r.jsx)("td",{className:"p-4 text-gray-600 dark:text-gray-300 whitespace-nowrap",children:A(e.archivedAt)}),(0,r.jsx)("td",{className:"p-4 text-gray-600 dark:text-gray-300",children:(null==(t=e.archivedBy)?void 0:t.name)||(null==(a=e.archivedBy)?void 0:a.email)||"â"}),(0,r.jsx)("td",{className:"p-4",children:(0,r.jsxs)("div",{className:"flex justify-end gap-2",children:[(0,r.jsxs)(m.$,{variant:"outline",size:"sm",loading:eb,onClick:()=>eT(e),children:[(0,r.jsx)(w.A,{className:"h-4 w-4 mr-1"}),"Restore"]}),e.detailUrl&&(0,r.jsx)(i(),{href:e.detailUrl,children:(0,r.jsxs)(m.$,{variant:"ghost",size:"sm",children:[(0,r.jsx)(k.A,{className:"h-4 w-4 mr-1"}),"View"]})}),E&&(0,r.jsxs)(m.$,{variant:"danger",size:"sm",onClick:()=>eh(e),children:[(0,r.jsx)(S.A,{className:"h-4 w-4 mr-1"}),"Delete"]})]})})]},e.compositeId)})})]})}),(0,r.jsx)("div",{className:"md:hidden divide-y divide-gray-200 dark:divide-gray-700",children:D.map(e=>{var t;return(0,r.jsxs)("div",{className:"p-4 space-y-3",children:[(0,r.jsxs)("div",{className:"flex items-start gap-3",children:[E&&(0,r.jsx)("input",{type:"checkbox",checked:ek.includes(e.compositeId),onChange:()=>eS(e.compositeId),className:"mt-1","aria-label":"Select ".concat(e.title)}),(0,r.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,r.jsx)("div",{className:"font-medium text-gray-900 dark:text-white",children:e.title}),e.subtitle&&(0,r.jsx)("div",{className:"text-xs text-gray-500 mt-0.5",children:e.subt
1itle}),(0,r.jsxs)("div",{className:"flex flex-wrap gap-2 mt-2",children:[(0,r.jsx)(x.E,{variant:"secondary",children:e.moduleLabel}),(0,r.jsx)("span",{className:"text-xs text-gray-500",children:A(e.archivedAt)})]}),(null==(t=e.archivedBy)?void 0:t.name)&&(0,r.jsxs)("p",{className:"text-xs text-gray-500 mt-1",children:["By ",e.archivedBy.name]})]})]}),(0,r.jsxs)("div",{className:"flex flex-wrap gap-2",children:[(0,r.jsxs)(m.$,{variant:"outline",size:"sm",loading:eb,onClick:()=>eT(e),className:"flex-1 justify-center",children:[(0,r.jsx)(w.A,{className:"h-4 w-4 mr-1"}),"Restore"]}),e.detailUrl&&(0,r.jsx)(i(),{href:e.detailUrl,className:"flex-1",children:(0,r.jsxs)(m.$,{variant:"outline",size:"sm",className:"w-full justify-center",children:[(0,r.jsx)(k.A,{className:"h-4 w-4 mr-1"}),"View"]})}),E&&(0,r.jsxs)(m.$,{variant:"danger",size:"sm",className:"flex-1 justify-center",onClick:()=>eh(e),children:[(0,r.jsx)(S.A,{className:"h-4 w-4 mr-1"}),"Delete"]})]})]},e.compositeId)})}),(0,r.jsx)("div",{className:"p-4",children:(0,r.jsx)(y.A,{currentPage:el,totalPages:en,totalItems:ec,pageSize:eo,visibleCount:D.length,onPageChange:e=>{es(e),eC()},onPageSizeChange:e=>{eu(e),es(1),eC()},itemLabel:"archived records"})})]})}),(0,r.jsx)(f.A,{isOpen:!!em,onClose:()=>!ex&&eh(null),onConfirm:ez,title:"Permanently delete archived record?",message:em?'This will permanently delete "'.concat(em.title,'" from ').concat(em.moduleLabel,". This action cannot be undone."):"",confirmText:"Delete Permanently",type:"danger",loading:ex}),(0,r.jsx)(f.A,{isOpen:ep,onClose:()=>!ev&&ef(!1),onConfirm:eM,title:"Permanently delete selected records?",message:"You are about to permanently delete ".concat(eE," archived record(s). This action cannot be undone."),confirmText:"Delete Permanently",type:"danger",loading:ev})]})}):(0,r.jsx)(u.A,{children:(0,r.jsx)(p.A,{title:"Access Denied",message:"You don't have permission to view archived records.",requiredRoles:"Admin, Manager, or Super Admin",redirectPath:"/dashboard",redirectText:"Back to Dashboard"})}):(0,r.jsx)(u.A,{children:(0,r.jsx)("div",{className:"flex items-center justify-center min-h-screen",children:(0,r.jsx)(m.$,{onClick:()=>e.push("/auth/login"),children:"Go to Login"})})})}},21483:(e,t,a)=>{"use strict";a.d(t,{A:()=>n});var r=a(14232),l=a(89099);function s(e,t){if(null==e||""===e)return t;if("number"==typeof t){let a=parseInt(String(e),10);return Number.isNaN(a)?t:a}return"boolean"==typeof t?"true"===String(e):String(e)}function n(e){var t;let a=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},{debounceMs:n=400,resetPageOnFilterChange:i=!0,preserveKeys:c=[]}=a,d=(0,l.useRouter)(),{isReady:o,query:u}=d,[m,h]=(0,r.useState)(!1),x=(0,r.useRef)(e);x.current=e;let g=(0,r.useRef)(c);g.current=c;let p=(0,r.useRef)(!1),f=(0,r.useRef)(""),v=(0,r.useRef)(!0),y=(0,r.useCallback)(e=>{if(!d.isReady)return;let t={...d.query};Object.keys(e||{}).forEach(a=>{let r=e[a];null===r||""===r||void 0===r?delete t[a]:t[a]=String(r)}),(g.current||[]).forEach(a=>{Object.prototype.hasOwnProperty.call(e||{},a)||null==d.query[a]||null!=t[a]||(t[a]=d.query[a])}),!function(e,t){if(e===t)return!0;let a=Object.keys(e||{}),r=Object.keys(t||{});if(a.length!==r.length)return!1;for(let r of a)if(String(e[r])!==String(t[r]))return!1;return!0}(t,d.query)&&d.replace({pathname:d.pathname,query:t},void 0,{shallow:!0})},[d]),b=(0,r.useMemo)(()=>Object.entries(e||{}).filter(e=>{let[t]=e;return"page"!==t}).map(e=>{var t;let[a,r]=e;return"".concat(a,"=").concat(String(null!=(t=null==r?void 0:r.value)?t:""))}).join("&"),[e]),j=null==e||null==(t=e.page)?void 0:t.value;return(0,r.useEffect)(()=>{if(!o||p.current)return;let e=x.current||{};Object.entries(e).forEach(e=>{let[t,a]=e;if(!a||"function"!=typeof a.set||void 0===u[t])return;let r=s(u[t],a.defaultValue);a.set(r)}),f.current=Object.entries(e||{}).filter(e=>{let[t]=e;return"page"!==t}).map(e=>{let[t,a]=e,r=u&&void 0!==u[t]?s(u[t],a.defaultValue):a.value;return"".concat(t,"=").concat(String(null!=r?r:""))}).join("&"),v.current=!0,p.current=!0,h(!0)},[o,u]),(0,r.useEffect)(()=>{if(!m||!o)return;let e=x.current||{},t=Object.entries(e),a=setTimeout(()=>{let a={},r=!1;
1t.forEach(e=>{var t,l;let[s,n]=e;if(!n||"page"===s)return;let i=(t=n.value,l=n.defaultValue,null==t||""===t||t===l?null:String(t));i!==(void 0!==u[s]&&null!==u[s]?String(u[s]):null)&&(a[s]=i,r=!0)});let l=b!==f.current;if(f.current=b,v.current){v.current=!1,r&&y(a);return}if(i&&l&&e.page&&"function"==typeof e.page.set){var s;let t=null!=(s=e.page.defaultValue)?s:1;e.page.value!==t&&e.page.set(t),a.page=null}(r||Object.prototype.hasOwnProperty.call(a,"page"))&&y(a)},t.some(e=>{var t;let[,a]=e;return(null==a?void 0:a.debounce)&&""!==String(null!=(t=a.value)?t:"")})?n:0);return()=>clearTimeout(a)},[b,m,o,n,i,y,u]),(0,r.useEffect)(()=>{var e,t;if(!m||!o)return;let a=null==(e=x.current)?void 0:e.page;if(!a)return;let r=null!=(t=a.defaultValue)?t:1,l=u.page?parseInt(String(u.page),10):r,s=Number(a.value)||r;s!==l&&y({page:s>r?String(s):null})},[m,o,j,u.page,y]),{isReady:o,isInitialized:m,updateURLParams:y}}},31010:(e,t,a)=>{"use strict";a.d(t,{A:()=>l});var r=a(14232);let l=r.forwardRef(function(e,t){let{title:a,titleId:l,...s}=e;return r.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",strokeWidth:1.5,stroke:"currentColor","aria-hidden":"true","data-slot":"icon",ref:t,"aria-labelledby":l},s),a?r.createElement("title",{id:l},a):null,r.createElement("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M12 9v3.75m0-10.036A11.959 11.959 0 0 1 3.598 6 11.99 11.99 0 0 0 3 9.75c0 5.592 3.824 10.29 9 11.622 5.176-1.332 9-6.03 9-11.622 0-1.31-.21-2.57-.598-3.75h-.152c-3.196 0-6.1-1.25-8.25-3.286Zm0 13.036h.008v.008H12v-.008Z"}))})},31452:(e,t,a)=>{"use strict";a.d(t,{A:()=>d});var r=a(37876);a(14232);var l=a(89099),s=a(15807),n=a(62125),i=a(28567),c=a(31010);let d=e=>{let{title:t="Access Denied",message:a="You don't have permission to access this section.",description:d,requiredRoles:o,redirectPath:u="/dashboard",redirectText:m="Back to Dashboard",icon:h,variant:x="danger"}=e,g=(0,l.useRouter)(),{iconColor:p,icon:f}=(()=>{switch(x){case"warning":return{iconColor:"text-yellow-500",icon:h||c.A};case"info":return{iconColor:"text-blue-500",icon:h||c.A};default:return{iconColor:"text-red-500",icon:h||c.A}}})();return(0,r.jsx)(i.Zp,{children:(0,r.jsxs)(i.Wu,{className:"p-8 text-center",children:[(0,r.jsx)(f,{className:"h-16 w-16 ".concat(p," mx-auto mb-4")}),(0,r.jsx)("h3",{className:"text-xl font-semibold text-gray-900 dark:text-white mb-2",children:t}),(0,r.jsx)("p",{className:"text-gray-600 dark:text-gray-400 mb-4",children:a}),d&&(0,r.jsx)("p",{className:"text-sm text-gray-500 dark:text-gray-500 mb-4",children:d}),o&&(0,r.jsxs)("p",{className:"text-sm text-gray-500 dark:text-gray-500 mb-6",children:["Required role: ",o]}),(0,r.jsxs)("div",{className:"flex flex-col sm:flex-row gap-3 justify-center",children:[(0,r.jsx)(n.$,{variant:"outline",onClick:()=>g.push(u),className:"w-full sm:w-auto",children:m}),(0,r.jsx)(n.$,{variant:"ghost",onClick:()=>(0,s.Tl)(g),className:"w-full sm:w-auto",children:"Go Back"})]})]})})}},32093:(e,t,a)=>{"use strict";a.d(t,{A:()=>l});var r=a(14232);function l(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:e=>e._id,[t,a]=(0,r.useState)([]),l=(0,r.useCallback)(e=>{a(t=>t.includes(e)?t.filter(t=>t!==e):[...t,e])},[]),s=(0,r.useCallback)(r=>{if(!(null==r?void 0:r.length))return void a([]);let l=r.map(e);l.every(e=>t.includes(e))?a(e=>e.filter(e=>!l.includes(e))):a(e=>[...new Set([...e,...l])])},[e,t]),n=(0,r.useCallback)(()=>a([]),[]),i=(0,r.useCallback)(a=>!!(null==a?void 0:a.length)&&a.every(a=>t.includes(e(a))),[e,t]);return{selectedIds:t,setSelectedIds:a,toggleSelection:l,toggleSelectAll:s,clearSelection:n,isAllSelected:i,selectedCount:t.length}}},54306:(e,t,a)=>{"use strict";function r(e,t){let a=arguments.length>2&&void 0!==arguments[2]?arguments[2]:7,r=[];if(t<=a){for(let e=1;e<=t;e+=1)r.push(e);return r}r.push(1);let l=Math.max(2,e-2),s=Math.min(t-1,e+2);e<=3&&(s=5),e>=t-2&&(l=t-4),l>2&&r.push("...");for(let e=l;e<=s;e+=1)r.push(e);return s<t-1&&r.push("..."),r.push(t),r}function l(e,t,a,r){return 0===a?{from:0,to:0}:{from:(e-1)*t+1,to:Math.min(e*t,a)}}function s(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1,a=arguments.length>2&&void 0!==arguments[2]?arguments[2]:5,r=Array.isArray(e)?e:[],l=r.length,s=Math.max(1,Number(a)||5),n=Math.max(1,Math.ceil(l/s)||1),i=Math.min(Math.max(1,Number(t)||1),n),c=(i-1)*s;return{items:r.slice(c,c+s),pagination:{currentPage:i,pageSize:s,totalItems:l,totalPages:n}}}a.d(t,{Wg:()=>l,g7:()=>s,ml:()=>r})},57485:(e,t,a)=>{(window.__NEXT_P=window.__NEXT_P||[]).push(["/dashboard/archived-records",function(){return a(8687)}])},67669:(e,t,a)=>{"use strict";a.d(t,{A:()=>n});var r=a(37876),l=a(62125),s=a(54306);function n(e){let{currentPage:t,totalPages:a,totalItems:n,pageSize:i,visibleCount:c=0,onPageChange:d,onPageSizeChange:o,itemLabel:u="items",pageSizeOptions:m=[10,20,50,100],className:h=""}=e,{from:x,to:g}=(0,s.Wg)(t,i,n,c),p=(0,s.ml)(t,a);return 0===n?null:(0,r.jsxs)("div",{className:"flex flex-col lg:flex-row justify-between items-center gap-4 pt-4 border-t border-gray-200 dark:border-gray-700 ".concat(h),children:[(0,r.jsxs)("div",{className:"flex flex-col sm:flex-row sm:items-center gap-2 text-sm text-gray-600 dark:text-gray-400",children:[(0,r.jsxs)("span",{children:["Showing ",x," to ",g," of ",n.toLocaleStr
1ing()," ",u]}),o&&(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[(0,r.jsx)("span",{className:"text-gray-500",children:"Per page"}),(0,r.jsx)("select",{value:i,onChange:e=>o(parseInt(e.target.value,10)),className:"px-3 py-2 border border-gray-200 dark:border-gray-600 rounded-lg bg-white dark:bg-gray-700 text-gray-900 dark:text-white text-sm focus:ring-2 focus:ring-gray-900 dark:focus:ring-white focus:border-transparent",children:m.map(e=>(0,r.jsx)("option",{value:e,children:e},e))})]})]}),a>1&&(0,r.jsxs)("div",{className:"flex items-center gap-2 flex-wrap justify-center",children:[(0,r.jsx)(l.$,{variant:"outline",size:"sm",disabled:1===t,onClick:()=>d(1),className:"px-2 py-1",title:"First page",children:"\xab\xab"}),(0,r.jsx)(l.$,{variant:"outline",size:"sm",disabled:1===t,onClick:()=>d(t-1),children:"Previous"}),(0,r.jsx)("div",{className:"flex gap-1 flex-wrap justify-center",children:p.map((e,a)=>(0,r.jsx)("button",{type:"button",onClick:()=>"number"==typeof e&&d(e),disabled:"number"!=typeof e,className:"px-3 py-1 rounded-lg text-sm font-medium transition-colors ".concat("number"==typeof e?e===t?"bg-blue-600 text-white":"bg-white dark:bg-gray-700 text-gray-700 dark:text-gray-300 border border-gray-200 dark:border-gray-600 hover:bg-gray-50 dark:hover:bg-gray-600":"text-gray-400 dark:text-gray-500 cursor-default"),children:e},"".concat(e,"-").concat(a)))}),(0,r.jsx)(l.$,{variant:"outline",size:"sm",disabled:t===a,onClick:()=>d(t+1),children:"Next"}),(0,r.jsx)(l.$,{variant:"outline",size:"sm",disabled:t===a,onClick:()=>d(a),className:"px-2 py-1",title:"Last page",children:"\xbb\xbb"})]})]})}},86854:(e,t,a)=>{"use strict";a.d(t,{A:()=>i});var r=a(37876),l=a(62125),s=a(28567),n=a(28022);function i(e){let{selectedCount:t,itemLabel:a="item",onDelete:i,onClear:c,canDelete:d=!0,deleteLabel:o="Delete Selected"}=e;if(0===t)return null;let u=1===t?a:"".concat(a,"s");return(0,r.jsx)(s.Zp,{className:"mb-6 bg-gradient-to-r from-red-50 to-orange-50 dark:from-red-900/20 dark:to-orange-900/20 border-red-200 dark:border-red-800 shadow-lg",children:(0,r.jsx)("div",{className:"p-4",children:(0,r.jsxs)("div",{className:"flex flex-col sm:flex-row sm:items-center sm:justify-between gap-4",children:[(0,r.jsxs)("div",{className:"flex items-center space-x-3",children:[(0,r.jsx)("div",{className:"p-2 bg-red-100 dark:bg-red-900/40 rounded-lg",children:(0,r.jsx)(n.A,{className:"h-5 w-5 text-red-600 dark:text-red-400"})}),(0,r.jsxs)("div",{children:[(0,r.jsxs)("p",{className:"text-sm font-semibold text-red-800 dark:text-red-200",children:[t.toLocaleString()," ",u," selected"]}),(0,r.jsxs)("p",{className:"text-xs text-red-600 dark:text-red-300",children:["Choose an action to apply to selected ",u]})]})]}),(0,r.jsxs)("div",{className:"flex gap-2",children:[d&&i&&(0,r.jsxs)(l.$,{variant:"danger",size:"sm",onClick:i,children:[(0,r.jsx)(n.A,{className:"h-4 w-4 mr-1"}),o]}),c&&(0,r.jsx)(l.$,{variant:"ghost",size:"sm",onClick:c,children:"Clear Selection"})]})]})})})}},91256:(e,t,a)=>{"use strict";a.d(t,{A:()=>c});var r=a(37876),l=a(62125),s=a(28567),n=a(11659),i=a(47043);function c(e){let{searchTerm:t,onSearchChange:a,searchPlaceholder:c="Search...",filters:d=[],onSubmit:o,onClear:u,children:m}=e;return(0,r.jsx)(s.Zp,{className:"mb-6 min-w-0 overflow-hidden",children:(0,r.jsxs)("div",{className:"p-4 sm:p-6",children:[(0,r.jsxs)("form",{onSubmit:e=>{e.preventDefault(),null==o||o()},className:"space-y-4",children:[(0,r.jsxs)("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-4 gap-3",children:[(0,r.jsx)("div",{className:"sm:col-span-2 lg:col-span-2",children:(0,r.jsxs)("div",{className:"relative",children:[(0,r.jsx)(i.A,{className:"absolute left-4 top-1/2 -translate-y-1/2 h-5 w-5 text-gray-400"}),(0,r.jsx)(n.p,{type:"text",placeholder:c,value:t,onChange:e=>a(e.target.value),className:"pl-12 h-12"})]})}),d.map(e=>(0,r.jsx)("div",{children:"date"===e.type?(0,r.jsx)(n.p,{type:"date",value:e.value,onChange:t=>e.onChange(t.target.value),className:"h-12",title:e.label}):(0,r.jsx)("select",{value:e.value,onChange:t=>e.onChange(t.target.value),className:"px-4 py-3 border border-gray-200 dark:border-gray-600 rounded-xl bg-white dark:bg-gray-700 text-gray-900 dark:text-white focus:ring-2 focus:ring-gray-900 dark:focus:ring-white focus:border-transparent w-full h-12","aria-label":e.label,children:(e.options||[]).map(e=>{let t="string"==typeof e?e:e.value,a="string"==typeof e?e:e.label;return(0,r.jsx)("option",{value:t,children:a},t)})})},e.key))]}),(0,r.jsxs)("div",{className:"flex flex-col sm:flex-row gap-2 sm:justify-end",children:[(0,r.jsx)(l.$,{type:"submit",size:"sm",className:"w-full sm:w-auto",children:"Search"}),u&&(0,r.jsx)(l.$,{type:"button",variant:"ghost",size:"sm",onClick:u,className:"w-full sm:w-auto",children:"Clear Filters"})]})]}),m]})})}}},e=>{e.O(0,[7725,4429,6989,5885,5588,636,6593,8792],()=>e(e.s=57485)),_N_E=e.O()}]);
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.