PageSourceSearch

https://xyrus.ai/_next/static/chunks/866-fb80366953c29443.js

js xyrus.ai collected 2026-10-05 15:08:55 UTC 28,329 bytes, 1 lines download raw bytes

1"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[866],{7823:(e,t,a)=>{a.d(t,{In:()=>r,Pm:()=>n,S2:()=>o});var o=function(e){return e.Active="active",e.Inactive="inactive",e}({}),r=function(e){return e.Active="active",e.Closed="closed",e}({}),n=function(e){return e.Primary="primary",e.Secondary="secondary",e}({})},30866:(e,t,a)=>{a.d(t,{a:()=>v});var o=a(12115),r=a(20063),n=a(7823),i=a(41180),l=a(75358),s=a(95621),c=a(99429),d=a(30590),u=a(18720),m=a(83098),p=a(60588),y=a(60919);let g=e=>({id:e.id,name:e.document_name,type:e.document_type,size:e.file_size?"".concat((e.file_size/1048576).toFixed(2)," MB"):"Unknown",uploadedAt:e.created_at,url:e.file_url}),f=e=>({id:e.id,name:"".concat(e.first_name," ").concat(e.last_name).trim(),title:e.designation,type:e.is_primary?n.Pm.Primary:n.Pm.Secondary,email:e.email,phone:(0,p.n4)(e.country_code,e.contact_no),avatar:"".concat(e.first_name[0]||"").concat(e.last_name[0]||"").toUpperCase(),clientMemberId:e.client_member_id||""}),h=e=>({id:e.id,name:"".concat(e.first_name," ").concat(e.last_name).trim(),title:e.designation,type:e.is_primary?n.Pm.Primary:n.Pm.Secondary,email:e.email,phone:e.phone||"",avatar:"".concat(e.first_name[0]||"").concat(e.last_name[0]||"").toUpperCase(),clientMemberId:e.client_member_id||""}),w=e=>({id:e.id,name:e.full_name,title:e.role,type:e.is_primary?n.Pm.Primary:n.Pm.Secondary,email:e.email,phone:e.phone||"",avatar:e.full_name.split(" ").map(e=>e[0]).join("").toUpperCase(),organizationMemberId:e.organization_member_id}),_=e=>({id:e.id,name:e.full_name,title:e.role,type:e.is_primary?n.Pm.Primary:n.Pm.Secondary,email:e.email,phone:e.phone||"",avatar:e.full_name.split(" ").map(e=>e[0]).join("").toUpperCase(),organizationMemberId:e.user_id}),C=e=>({id:e.id,name:e.full_name,title:"Member",type:n.Pm.Secondary,email:"".concat(e.full_name.toLowerCase().replace(/\s+/g,"."),"@xqtiv.com"),phone:"",avatar:e.full_name.split(" ").map(e=>e[0]).join("").toUpperCase()}),b=e=>{let t=new Date(e.created_at),a=Math.floor((new Date().getTime()-t.getTime())/864e5);return{id:e.id,title:e.title,location:e.location,recommendations:e.recommendations_count,daysOpen:a,startDate:e.created_at,status:"active"===e.status.toLowerCase()?n.In.Active:n.In.Closed,projectManager:e.xqtiv_poc_name}},E=e=>{var t;let a={id:e.id,clientName:e.name,activeEngagements:null!=(t=e.active_engagements_count)?t:0,clientPOC:e.client_poc_name||"N/A",xqtivPOC:e.xqtiv_poc_name||"N/A",status:n.S2.Active,createdAt:e.created_at};return e.website&&(a.website=e.website),e.linkedin_profile&&(a.linkedin=e.linkedin_profile),e.logo_url&&(a.logo=e.logo_url),e.location&&(a.location=e.location),e.description&&(a.description=e.description),e.industry&&(a.industry=e.industry),a};function v(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},{detailView:t=!1,clientId:a}=e,p=(0,r.useRouter)(),v=(0,r.useParams)(),S=a||(t?null==v?void 0:v.id:void 0),[k,P]=(0,o.useState)(""),[L,A]=(0,o.useState)({poc:[],activeEngagements:[]}),[T,I]=(0,o.useState)(1),[R,D]=(0,o.useState)(10),[F,M]=(0,o.useState)([]),[N,x]=(0,o.useState)(0),[O,j]=(0,o.useState)(!1),[Q,X]=(0,o.useState)(null),[z,U]=(0,o.useState)({status:[],location:[]}),[B,q]=(0,o.useState)({type:[],title:[]}),[V,Y]=(0,o.useState)(""),[K,G]=(0,o.useState)(!1),[H,J]=(0,o.useState)([]),[W,Z]=(0,o.useState)([]),[$,ee]=(0,o.useState)([]),[et,ea]=(0,o.useState)([]),[eo,er]=(0,o.useState)([]),[en,ei]=(0,o.useState)([]),[el,es]=(0,o.useState)("Rahul Sharma"),[ec,ed]=(0,o.useState)(""),[eu,em]=(0,o.useState)(!1),[ep,ey]=(0,o.useState)(1),[eg,ef]=(0,o.useState)(0),[eh,ew]=(0,o.useState)(!0),[e_,eC]=(0,o.useState)(!1),{isLoading:eb,error:eE,execute:ev}=(0,l.sO)(e=>{let t={skip:e.skip||0,limit:e.limit||10,search:e.search||k,sort_by:"created_at",sort_order:"desc"};return c.Sn.CLIENT.ADVANCED_CLIENT_ENDPOINT(t)}),{error:eS,execute:ek}=(0,l.sO)(e=>c.Sn.CLIENT.OVERVIEW(e)),eP=(0,l.L2)({method:"post"}),eL=(0,l.L2)({method:"put"}),eA=(0,l.L2)({method:"put"}),{isLoading:eT,error:eI,execute:eR}=(0,l.sO)(e=>c.Sn.CLIENT.DOCUMENTS(e)),eD=(0,l.L2)({method:"put"}),eF=(0,l.L2)({method:"delete"}),{isLoading:eM,error:eN,execute:ex}=(0,l.sO)(e=>
1c.Sn.CLIENT.CLIENT_MEMBERS(e)),eO=(0,l.L2)({method:"post"}),ej=(0,l.L2)({method:"put"}),eQ=(0,l.L2)({method:"delete"}),{isLoading:eX,error:ez,execute:eU}=(0,l.sO)(e=>c.Sn.CLIENT.XQTIV_CONTACTS(e)),{isLoading:eB,error:eq,execute:eV}=(0,l.sO)(e=>"".concat(c.Sn.PROJECT.BASE,"?").concat(d.uB.SKIP,"=0&").concat(d.uB.LIMIT,"=3&").concat(d.uB.SORT_BY,"=created_at&").concat(d.uB.SORT_ORDER2,"=desc&client_id=").concat(e)),[eY,eK]=(0,o.useState)(!1),[eG,eH]=(0,o.useState)(null),eJ=(0,l.L2)({method:"post"}),eW=(0,l.L2)({method:"delete"}),eZ=(0,l.L2)({method:"put"}),e$=(0,o.useCallback)(async()=>{if(t&&S)try{let e=await eR(S);if((null==e?void 0:e.status_code)===200){let t=e.data.map(g);J(t)}}catch(e){console.error("❌ Error fetching client documents:",e),u.oR.error("Failed to fetch client documents")}},[S,t,eR]),e0=(0,o.useCallback)(async()=>{if(t&&S)try{let e=await ex(S);if((null==e?void 0:e.status_code)===200){let t=e.data.map(f);Z(t)}}catch(e){console.error("❌ Error fetching client members:",e),u.oR.error("Failed to fetch client contacts")}},[S,t,ex]),e1=(0,o.useCallback)(async()=>{if(t&&S)try{let e=await eU(S);if((null==e?void 0:e.status_code)===200){let t=e.data.map(w);ee(t)}}catch(e){console.error("❌ Error fetching XQtiv contacts:",e),u.oR.error("Failed to fetch XQtiv contacts")}},[S,t,eU]),e2=(0,o.useCallback)(async function(){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];if(S){a?eC(!0):(eK(!0),eH(null));try{let o=(t-1)*10,r=new URLSearchParams;e&&r.append(d.uB.SEARCH,e),r.append(d.uB.SKIP,o.toString()),r.append(d.uB.LIMIT,"10");let n="".concat(c.Sn.CLIENT.XQTIV_CONTACTS_LIST(S),"?").concat(r.toString()),i=await (0,s.query)(n);if((null==i?void 0:i.status_code)===200){let e=i.data.map(C);a?ea(t=>[...t,...e]):ea(e),ef(i.total_count||0),ew(10===e.length),ey(t)}}catch(e){console.error("❌ Error fetching XQtiv contacts list:",e),a||(eH(e),u.oR.error("Failed to fetch XQtiv contacts list"))}finally{a?eC(!1):eK(!1)}}},[S]),e4=(0,o.useCallback)(async()=>{if(t&&S)try{let e=await eV(S);if((null==e?void 0:e.status_code)===0||(null==e?void 0:e.status_code)===200){let t=e.data.map(b);er(t)}}catch(e){console.error("❌ Error fetching client engagements:",e),u.oR.error("Failed to fetch client engagements")}},[S,t,eV]),e6=(0,o.useCallback)(async(e,t)=>{try{let a=await eJ.mutateAsync({url:c.Sn.CLIENT.CREATE_XQTIV_CONTACT(e),data:t});if((null==a?void 0:a.status_code)===200||(null==a?void 0:a.status_code)===201)return u.oR.success("XQtiv contact added successfully"),await Promise.all([e1(),tS.current()]),a;throw Error((null==a?void 0:a.message)||"Failed to add XQtiv contact")}catch(t){console.error("❌ Error creating XQtiv contact:",t),t&&"object"==typeof t&&"response"in t&&console.error("API Error Response:",t.response);let e=t instanceof Error||t&&"object"==typeof t&&"message"in t?t.message:"Failed to add XQtiv contact";throw u.oR.error(e),t}},[eJ,e1]),e8=(0,o.useCallback)(async(e,t)=>{try{let a=await eW.mutateAsync({url:c.Sn.CLIENT.DELETE_XQTIV_CONTACT(e,t)});if((null==a?void 0:a.status_code)===200||(null==a?void 0:a.status_code)===204)return u.oR.success("XQtiv contact removed successfully"),await Promise.all([e1(),tS.current()]),a;throw Error((null==a?void 0:a.message)||"Failed to remove XQtiv contact")}catch(t){console.error("❌ Error deleting XQtiv contact:",t),t&&"object"==typeof t&&"response"in t&&console.error("API Error Response:",t.response);let e=t instanceof Error||t&&"object"==typeof t&&"message"in t?t.message:"Failed to remove XQtiv contact";throw u.oR.error(e),t}},[eW,e1]),e3=(0,o.useCallback)(async(e,t)=>{try{let a=await eZ.mutateAsync({url:c.Sn.CLIENT.SET_PRIMARY_XQTIV_CONTACT(e),data:t});if((null==a?void 0:a.status_code)===200||(null==a?void 0:a.status_code)===201)return u.oR.success("Primary XQtiv contact updated successfully"),await e1(),a;throw Error((null==a?void 0:a.message)||"Failed to set primary XQtiv contact")}catch(t){console.error("❌ Error setting primary XQtiv contact:",t),t&&"object"==typeof t&&"response"in t&&console.error("API Error Response:",t.response);let e=t instanceof Error||t&&"object"==typeof t&&"message"in t?t.message:"Failed to set primary XQtiv contact";throw u.oR.error(e),t}},[eZ,e1]),e5=(0,o.useCallback)(async()=>
1{if(t&&S){j(!0);try{let e=await ek(S);if((null==e?void 0:e.status_code)===0||(null==e?void 0:e.status_code)===200){let{client:t,engagements:a,client_contacts:o,xqtiv_contacts:r,documents:i}=e.data,l={id:t.id,clientName:t.name,activeEngagements:0,clientPOC:"N/A",xqtivPOC:"N/A",status:n.S2.Active,createdAt:t.created_at,website:t.website,linkedin:t.linkedin_profile,logo:t.logo_url,location:t.location,description:t.description,industry:t.industry};console.log("client_contacts",o);let s=[];Object.entries(a).forEach(e=>{let[t,a]=e;a.forEach(e=>{s.push((e=>{let t=e.started_on?new Date(e.started_on):new Date,a=Math.floor((new Date().getTime()-t.getTime())/864e5);return{id:e.id,title:e.title,location:e.location,recommendations:e.recommendations_count,daysOpen:a,startDate:e.started_on||new Date().toISOString(),status:"active"===e.status.toLowerCase()?n.In.Active:n.In.Closed}})(e))})});let c=[];o.primary&&c.push(h(o.primary)),o.others&&o.others.length>0&&c.push(...o.others.map(h));let d=[];r.primary&&d.push(_(r.primary)),r.others&&r.others.length>0&&d.push(...r.others.map(_));let u=i.recent.map(e=>({id:e.id,name:e.document_name,type:e.document_type,size:e.file_size?"".concat((e.file_size/1048576).toFixed(2)," MB"):"Unknown",uploadedAt:e.created_at,url:e.file_url}));er(s),Z(c),ee(d),J(u);let m={...l,engagements:s,clientContacts:c,xqtivContacts:d,documents:u};X(m)}}catch(e){console.error("❌ Error fetching client overview:",e),u.oR.error("Failed to fetch client details")}finally{j(!1)}}},[S,t,ek]),e9=(0,o.useCallback)(()=>{M([]),I(0),x(0)},[]),e7=(0,o.useRef)(ev);e7.current=ev;let te=(0,o.useCallback)(async(e,t,a)=>{try{let o=await e7.current({skip:(e-1)*t,limit:t,search:a||k});if((null==o?void 0:o.status_code)===200){let e=o.data.map(E);M(e),x(o.total_count)}}catch(e){u.oR.error("Failed to load clients"),console.error("Error loading clients:",e)}},[k]),tt=(0,o.useCallback)(async(e,t,a)=>{try{let o=await e7.current({skip:t||0,limit:a||10,search:e||""});if((null==o?void 0:o.status_code)===200){let e=o.data.map(E);M(e),I(1),x(o.total_count)}}catch(e){u.oR.error("Failed to load clients"),console.error("Error loading clients:",e)}},[]),ta=(0,o.useRef)(tt);ta.current=tt;let to=(0,o.useRef)(te);to.current=te;let tr=(0,o.useCallback)(async e=>{try{P(e),I(1),M([]),x(0)}catch(e){u.oR.error("Failed to search clients"),console.error("Error searching clients:",e)}},[]),tn=(0,o.useCallback)(async e=>{try{let t=new FormData;t.append("client_name",e.clientName),t.append("client_linkedin",e.linkedin),e.website&&t.append("client_website",e.website),e.logo instanceof File&&t.append("client_logo",e.logo);let a=await eP.mutateAsync({url:c.Sn.CLIENT.CREATE,data:t,config:{headers:{"Content-Type":"multipart/form-data",accept:"application/json"}}});if((null==a?void 0:a.status_code)===200||(null==a?void 0:a.status_code)===201)return u.oR.success("Client created successfully"),e9(),tt(),a;throw Error((null==a?void 0:a.message)||"Failed to create client")}catch(e){var t,a;throw u.oR.error(e instanceof y.pe&&(null==(a=e.response)||null==(t=a.data)?void 0:t.detail)||"Failed to create client"),e}},[eP,e9,tt]),ti=(0,o.useCallback)(async(e,t)=>{try{let a=new FormData;a.append("client_logo",t);let o=await eL.mutateAsync({url:c.Sn.CLIENT.UPDATE_LOGO(e),data:a,config:{headers:{"Content-Type":"multipart/form-data"}}});if((null==o?void 0:o.status_code)===200)return u.oR.success("Client logo updated successfully"),o;throw Error((null==o?void 0:o.message)||"Failed to update client logo")}catch(e){throw console.error("Error updating client logo:",e),u.oR.error("Failed to update client logo"),e}},[eL]),tl=(0,o.useCallback)(async(e,t)=>{try{let a=await eA.mutateAsync({url:c.Sn.CLIENT.UPDATE_PROFILE(e),data:t});if((null==a?void 0:a.status_code)===200)return u.oR.success("Client profile updated successfully"),a;throw Error((null==a?void 0:a.message)||"Failed to update client profile")}catch(e){throw console.error("Error updating client profile:",e),u.oR.error("Failed to update client profile"),e}},[eA]),ts=(0,o.useCallback)(async(e,t)=>{try{if(!t.file||!(t.file instanceof File))throw Error("Invalid file: File is required and must be a valid File object");
1if(0===t.file.size)throw Error("Invalid file: File is empty");let a=new FormData;a.append("file",t.file);let o=await eD.mutateAsync({url:c.Sn.CLIENT.UPLOAD_DOCUMENT(e),data:a,config:{headers:{accept:"application/json"}}});if((null==o?void 0:o.status_code)===200||(null==o?void 0:o.status_code)===201)return u.oR.success("Document uploaded successfully"),await e$(),o;throw Error((null==o?void 0:o.message)||"Failed to upload document")}catch(t){console.error("❌ Error uploading client document:",t),t&&"object"==typeof t&&"response"in t&&console.error("API Error Response:",t.response);let e=t instanceof Error||t&&"object"==typeof t&&"message"in t?t.message:"Failed to upload document";throw u.oR.error(e),t}},[eD,e$]),tc=(0,o.useCallback)((e,t)=>{i.Lx.openDialog("confirmation",{title:"Delete Document",data:{message:"Are you sure you want to delete this document? This action cannot be undone.",confirmText:"Delete",cancelText:"Cancel",onConfirm:async()=>{try{let a=await eF.mutateAsync({url:c.Sn.CLIENT.DELETE_DOCUMENT(e,t.documentId)});if((null==a?void 0:a.status_code)===200)return u.oR.success("Document deleted successfully"),await e$(),a;throw Error((null==a?void 0:a.message)||"Failed to delete document")}catch(t){console.error("❌ Error deleting client document:",t),t&&"object"==typeof t&&"response"in t&&console.error("API Error Response:",t.response);let e=t instanceof Error||t&&"object"==typeof t&&"message"in t?t.message:"Failed to delete document";u.oR.error("Delete Failed",{description:e})}}}})},[eF,e$]),td=(0,o.useCallback)(async(e,t)=>{try{let a=await eO.mutateAsync({url:c.Sn.CLIENT.ADD_MEMBER(e),data:t.memberData});if((null==a?void 0:a.status_code)===200||(null==a?void 0:a.status_code)===201)return u.oR.success("Client contact added successfully"),await e0(),a;throw Error((null==a?void 0:a.message)||"Failed to add client contact")}catch(t){console.error("❌ Error adding client member:",t),t&&"object"==typeof t&&"response"in t&&console.error("API Error Response:",t.response);let e=t instanceof Error||t&&"object"==typeof t&&"message"in t?t.message:"Failed to add client contact";throw u.oR.error(e),t}},[eO,e0]),tu=(0,o.useCallback)(async(e,t)=>{try{let a=await eQ.mutateAsync({url:c.Sn.CLIENT.DELETE_MEMBER(e,t.memberId)});if((null==a?void 0:a.status_code)===200)return u.oR.success("Client contact deleted successfully"),await e0(),a;throw Error((null==a?void 0:a.message)||"Failed to delete client contact")}catch(t){console.error("❌ Error deleting client member:",t),t&&"object"==typeof t&&"response"in t&&console.error("API Error Response:",t.response);let e=t instanceof Error||t&&"object"==typeof t&&"message"in t?t.message:"Failed to delete client contact";throw u.oR.error(e),t}},[eQ,e0]),tm=(0,o.useCallback)(async(e,t,a)=>{try{let o=await ej.mutateAsync({url:c.Sn.CLIENT.UPDATE_MEMBER(e,t),data:a.memberData});if((null==o?void 0:o.status_code)===200||(null==o?void 0:o.status_code)===201)return u.oR.success("Client contact updated successfully"),await e0(),o;throw Error((null==o?void 0:o.message)||"Failed to update client contact")}catch(t){console.error("❌ Error updating client member:",t),t&&"object"==typeof t&&"response"in t&&console.error("API Error Response:",t.response);let e=t instanceof Error||t&&"object"==typeof t&&"message"in t?t.message:"Failed to update client contact";throw u.oR.error(e),t}},[ej,e0]),tp=(0,o.useCallback)(async(e,t)=>{try{let a=await ej.mutateAsync({url:c.Sn.CLIENT.UPDATE_MEMBER(e,t),data:{is_primary:!0}});if((null==a?void 0:a.status_code)===200||(null==a?void 0:a.status_code)===201)return u.oR.success("Contact set as primary successfully"),await e0(),a;throw Error((null==a?void 0:a.message)||"Failed to set contact as primary")}catch(t){console.error("❌ Error setting client member as primary:",t),t&&"object"==typeof t&&"response"in t&&console.error("API Error Response:",t.response);let e=t instanceof Error||t&&"object"==typeof t&&"message"in t?t.message:"Failed to set contact as primary";throw u.oR.error(e),t}},[ej,e0]),ty=(0,o.useCallback)(async e=>{try{let{id:a,originalData:o,...r}=e,n=!1,i=!1;if(o?(n=r.logo instanceof File,i=r.clientName!==o.clientName||r.website!==o.website||r.linkedin!==o.linkedin):(n=r.logo instanceof File,i=!0),!n&&!i)return void u.oR.info("No changes detected");if(n&&r.logo instanceof File&&await ti(a,r.logo),i){let e={name:r.clientName,linkedin_profile:r.linkedin,...r.website&&{website:r.website}};await tl(a,e)}return t?e5():(e9(),tt()),{logoChanged:n,profileChanged:i}}catch(e){throw console.error("Error updating client:",e),e}},[ti,tl,t,e5,e9,tt]),tg=(0,o.useRef)(e5);tg.current=e5;let tf=(0,o.useRef)(!0);(0,o.useEffect)(()=>{t?tg.current():tf.current&&(ta.current(),tf.current=!1)},[t,S]),(0,o.useEffect)(()=>{!t&&!tf.current&&T>0&&R>0&&to.current(T,R,k)},[T,R,t,k]),(0,o.useEffect)(()=>{S&&tS.current()},[S]);let th=(0,o.useMemo)(()=>
1{if(t)return[];let e=F;return L.activeEngagements.length>0&&"All"!==L.activeEngagements[0]&&(e=e.filter(e=>{let t=L.activeEngagements[0],a=e.activeEngagements;switch(t){case"1-3":return a>=1&&a<=3;case"4-6":return a>=4&&a<=6;case"6-10":return a>=6&&a<=10;case"10+":return a>10;default:return!0}})),e},[F,L,t]),tw=(0,o.useMemo)(()=>t?[]:th,[th,t]),t_=(0,o.useMemo)(()=>{if(!t)return[];let e=eo;return z.status.length>0&&(e=e.filter(e=>z.status.includes(e.status))),z.location.length>0&&(e=e.filter(e=>e.location&&z.location.includes(e.location))),V&&(e=e.filter(e=>e.title.toLowerCase().includes(V.toLowerCase())||e.projectManager&&e.projectManager.toLowerCase().includes(V.toLowerCase())||e.location&&e.location.toLowerCase().includes(V.toLowerCase()))),e=K?e.filter(e=>e.status===n.In.Closed):e.filter(e=>e.status===n.In.Active)},[eo,z,V,K,t]),tC=(0,o.useMemo)(()=>{if(!t)return[];let e=W;return B.type.length>0&&(e=e.filter(e=>B.type.includes(e.type))),B.title.length>0&&(e=e.filter(e=>B.title.includes(e.title))),e},[W,B,t]),tb=(0,o.useMemo)(()=>{if(!t)return[];let e=$;return B.type.length>0&&(e=e.filter(e=>B.type.includes(e.type))),B.title.length>0&&(e=e.filter(e=>B.title.includes(e.title))),e},[$,B,t]),tE=(0,o.useMemo)(()=>et.filter(e=>e.name.toLowerCase().includes(ec.toLowerCase())),[et,ec]),tv=(0,o.useRef)(tr);tv.current=tr;let tS=(0,o.useRef)(e2);tS.current=e2;let tk=(0,o.useMemo)(()=>(0,m.s)(e=>tv.current(e),400),[]),tP=(0,o.useCallback)(e=>{P(e),tk(e)},[tk]),tL=(0,o.useCallback)((e,t)=>{A(a=>({...a,[e]:t})),I(1)},[]),tA=(0,o.useCallback)(e=>{I(e)},[]),tT=(0,o.useCallback)(e=>{D(e),I(1)},[]),tI=(0,o.useCallback)(()=>{P(""),A({poc:[],activeEngagements:[]}),e9(),ta.current()},[e9]),tR=(0,o.useCallback)(()=>{i.Lx.openDialog("create-client",{title:"Add Client",size:"lg",data:{onSubmit:async e=>{try{await tn({clientName:e.clientName,...e.website&&{website:e.website},linkedin:e.linkedin,...e.logo&&{logo:e.logo}})}catch(e){console.error("Failed to create client:",e)}},isCreatingClient:eP.isPending}})},[tn,eP.isPending]),tD=(0,o.useCallback)(e=>{p.push("/clients/".concat(e.id))},[p]),tF=(0,o.useCallback)((e,t)=>{e.stopPropagation(),t.website&&window.open(t.website,"_blank")},[]),tM=(0,o.useCallback)((e,t)=>{e.stopPropagation(),t.linkedin&&window.open(t.linkedin,"_blank")},[]),tN=(0,o.useCallback)(()=>{Q&&i.Lx.openDrawer("create-client",{title:"Edit Client Profile",size:"lg",customContentStyle:{width:"400px"},anchor:"right",data:{mode:"edit",client:Q,onSubmit:async e=>{try{await ty({id:Q.id,clientName:e.clientName,...e.website&&{website:e.website},linkedin:e.linkedin,...e.logo&&{logo:e.logo},originalData:{clientName:Q.clientName,website:Q.website,linkedin:Q.linkedin||""}})}catch(e){console.error("Failed to update client profile:",e)}},isUpdatingClient:eL.isPending||eA.isPending}})},[Q,ty,eL.isPending,eA.isPending]),tx=(0,o.useCallback)(()=>{i.Lx.openDialog("add-document",{title:"Add Document",size:"md",data:{clientId:S,onSubmit:e=>{Q&&X({...Q,documents:[...Q.documents,e]})}}})},[S,Q]),tO=(0,o.useCallback)(async()=>{i.Lx.openDrawer("client-contact",{title:"Add Client Contact",size:"md",anchor:"right",customContentStyle:{width:"400px",height:"calc(100vh-100px)",overflowY:"auto"},data:{clientId:S,showAddButton:!0,contacts:W,isLoadingContacts:!0,fetchFreshData:async()=>{let e=W;if(S)try{let t=await ex(S);(null==t?void 0:t.status_code)===200&&(e=t.data.map(f),Z(e))}catch(e){console.error("❌ Error fetching client members with phone:",e)}return e},onSubmit:async e=>{if(S)try{await td(S,{memberData:{first_name:e.firstName,last_name:e.lastName,designation:e.designation,email:e.email,contact_no:e.phone,country_code:e.countryCode,is_primary:e.isPrimary}}),await e0(),i.Lx.closeAllModals()}catch(e){console.error("Failed to add client contact:",e)}},onEdit:async(e,t)=>{if(S)try{await tm(S,e,{memberData:{first_name:t.firstName,last_name:t.lastName,designation:t.designation,email:t.email,contact_no:t.phone,country_code:t.countryCode,is_primary:t.isPrimary}}),await e0(),i.Lx.closeAllModals()}catch(e){console.error("Failed to update client contact:",e)}},onDelete:async e=>{if(S)try{await tu(S,{memberId:e}),await e0(),i.Lx.closeAllModals()}catch(e){console.error("Failed to delete client contact:",e)}},onSetPrimary:async e=>{if(S)try{await tp(S,e),await e0(),i.Lx.closeAllModals()}catch(e){console.error("Failed to set primary contact:",e)}}}})},[S,ex,td,tm,tu,tp,e0,W]),tj=(0,o.useCallback)(()=>{i.Lx.openDrawer("xqtiv-contacts",{title:"XQtiv Contacts",size:"md",anchor:"right",customContentStyle:{width:"400px",height:"calc(100vh-100px)",overflowY:"auto"},data:{clientId:S,contacts:tE,selectedContacts:en,primaryContact:el,searchTerm:ec,showAddSection:eu,onContactSelect:tH,onContactSelectAll:tJ,onPrimaryChange:es,onSearchChange:tZ,onToggleAddSection:t$,onSubmit:async e=>{if(S)try{await e6(S,{organization_member_ids:e,is_primary:!1}),ei([]),em(!1),i.Lx.closeAllModals()}catch(e){console.error("Failed to add XQtiv contacts:",e)}},onSetPrimary:async e=>{if(S&&e.organizationMemberId)try{await e3(S,{set_primary:!0,contact_id:e.id,organization_member_id:e.organizationMemberId,is_primary:!0}),i.Lx.closeAllModals(),await e1()}catch(e){console.error("Failed to set primary XQtiv contact:",e)}},onDeleteContact:async e=>{if(S)try{await e8(S,e),await e1()}catch(e){console.error("Failed to delete XQtiv contact:",e)}}}})},[S,e6,e3,e8,e1,tE,en,el,ec,eu]),tQ=(0,o.useCallback)((e,t)=>{U(a=>({...a,[e]:t}))},[]),tX=(0,o.useCallback)((e,t)=>{q(a=>({...a,[e]:t}))},[]),tz=(0,o.useCallback)(e=>{Y(e)},[]),tU=(0,o.useCallback)(()=>{G(e=>!e)},[]),tB=(0,o.useCallback)(()=>{p.push("/projects")},[p]),tq=(0,o.useCallback)(()=>{},[]),tV=(0,o.useCallback)(()=>{},[]),tY=(0,o.useCallback)((e,t)=>{switch(e){case"email":t.email&&window.open("mailto:".concat(t.email),"_blank");break;case"phone":t.phone&&window.open("tel:".concat(t.phone),"_blank")}},[]),tK=(0,o.useCallback)(()=>{(null==Q?void 0:Q.website)&&window.open(Q.website,"_blank")},[Q]),tG=(0,o.useCallback)(()=>{(null==Q?void 0:Q.linkedin)&&window.open(Q.linkedin,"_blank")},[Q]),tH=(0,o.useCallback)(e=>{ei(t=>t.includes(e)?t.filter(t=>t!==e):[...t,e])},[]),tJ=(0,o.useCallback)(()=>{en.length===tE.length?ei([]):ei(tE.map(e=>e.name))},[en.length,tE]),tW=(0,o.useMemo)(()=>(0,m.s)(e=>{ey(1),ew(!0),e2(e,1,!1)},300),[e2]),tZ=(0,o.useCallback)(e=>{let t=e.target.value;ed(t),tW(t)},[tW]),t$=(0,o.useCallback)(()=>{em(!eu)},[eu]),t0=(0,o.useCallback)(()=>{em(!1),ei([]),ed(""),ey(1),ew(!0),e2("",1,!1)},[e2]),t1=(0,o.useCallback)(async()=>{eh&&!e_&&await e2(ec,ep+1,!0)},[eh,e_,ep,ec,e2]),t2=(0,o.useCallback)(async()=>{let e=H;if(S)try{let t=await eR(S);(null==t?void 0:t.status_code)===200&&(e=t.data.map(g),J(e))}catch(e){console.error("❌ Error fetching client documents:",e)}let t=e.map(e=>({id:e.id,name:e.name,url:e.url,uploadedAt:e.uploadedAt,fileType:e.type,documentType:"other"}));i.Lx.openDrawer("documents",{anchor:"right",width:400,size:"full",showCloseButton:!1,data:{documents:t,mode:"add",allowTypes:!1,uploadDocument:async e=>{S&&(await ts(S,{file:e.file}),await e$(),i.Lx.closeAllModals())},removeDocument:async e=>{S&&(await tc(S,{documentId:e.documentId}),await e$(),i.Lx.closeAllModals())},showLoading:(e,t)=>
1{i.Lx.setModalLoading("documents",e,t)}}})},[H,S,eR,ts,tc,e$]),t4=(0,o.useCallback)(async()=>{let e=H;if(S)try{let t=await eR(S);(null==t?void 0:t.status_code)===200&&(e=t.data.map(g),J(e))}catch(e){console.error("❌ Error fetching client documents:",e)}i.Lx.openDrawer("documents",{anchor:"right",width:400,size:"full",showCloseButton:!1,data:{documents:e.map(e=>({id:e.id,name:e.name,url:e.url,uploadedAt:e.uploadedAt,fileType:e.type,documentType:"other"})),mode:"list",allowTypes:!1,uploadDocument:async e=>{S&&(await ts(S,{file:e.file}),await e$(),i.Lx.closeAllModals())},removeDocument:async e=>{S&&(await tc(S,{documentId:e.documentId}),await e$(),i.Lx.closeAllModals())},showLoading:(e,t)=>{i.Lx.setModalLoading("documents",e,t)}}})},[H,S,eR,ts,tc,e$]);return{loading:t?O:eb,error:t?eS:eE,searchQuery:k,filters:L,paginatedClients:tw,filteredClients:th,pagination:{currentPage:T,totalPages:Math.ceil(N/R),totalItems:N,itemsPerPage:R},handleSearchChange:tP,handleFilterChange:tL,handlePageChange:tA,handlePageSizeChange:tT,handleReset:tI,handleCreate:tR,handleCreateClient:tn,handleUpdateClient:ty,handleUpdateClientLogo:ti,handleUpdateClientProfile:tl,isCreatingClient:eP.isPending,isUpdatingClient:eL.isPending||eA.isPending,handleRowClick:tD,handleGlobeClick:tF,handleLinkedInClick:tM,clientDetails:Q,filteredEngagements:t_,filteredClientContacts:tC,filteredXqtivContacts:tb,engagementFilters:z,contactFilters:B,engagementSearchQuery:V,showClosedEngagements:K,fetchClientDetails:e5,handleEditProfile:tN,handleAddDocument:tx,handleAddClientContact:tO,handleAddXqtivContact:tj,handleEngagementFilterChange:tQ,handleContactFilterChange:tX,handleEngagementSearchChange:tz,handleToggleEngagementStatus:tU,handleViewAllEngagements:tB,handleViewAllClientContacts:tq,handleViewAllXqtivContacts:tV,handleContactAction:tY,handleWebsiteClick:tK,handleLinkedInClickDetail:tG,selectedXQtivContacts:en,primaryXQtivContact:el,xqtivContactSearchTerm:ec,showAddXQtivSection:eu,filteredXQtivContactsPool:tE,xqtivContactsCurrentPage:ep,xqtivContactsTotalCount:eg,xqtivContactsHasMore:eh,isLoadingMoreXQtivContacts:e_,handleXQtivContactSelect:tH,handleXQtivContactSelectAll:tJ,setPrimaryXQtivContact:es,handleXQtivContactSearchChange:tZ,handleToggleXQtivAddSection:t$,handleXQtivContactCancel:t0,loadMoreXQtivContacts:t1,xqtivContactsPool:et,handleOpenClientDocuments:t2,handleViewAllDocuments:t4,clientDocuments:H,isLoadingDocuments:eT,documentsError:eI,fetchClientDocumentsData:e$,handleUploadClientDocument:ts,handleDeleteClientDocument:tc,isUploadingDocument:eD.isPending,isDeletingDocument:eF.isPending,clientContacts:W,isLoadingMembers:eM,membersError:eN,fetchClientMembersData:e0,handleAddClientMember:td,handleUpdateClientMember:tm,handleDeleteClientMember:tu,handleSetClientMemberPrimary:tp,isAddingMember:eO.isPending,isUpdatingMember:ej.isPending,isDeletingMember:eQ.isPending,xqtivContacts:$,isLoadingXQtivContacts:eX,xqtivContactsError:ez,fetchXQtivContactsData:e1,xqtivContactsList:et,isLoadingXQtivContactsList:eY,xqtivContactsListError:eG,fetchXQtivContactsListData:e2,handleCreateXQtivContact:e6,isCreatingXQtivContact:eJ.isPending,handleDeleteXQtivContact:e8,isDeletingXQtivContact:eW.isPending,handleSetPrimaryXQtivContact:e3,isSettingPrimaryXQtivContact:eZ.isPending,clientEngagements:eo,isLoadingEngagements:eB,engagementsError:eq,fetchClientEngagementsData:e4}}n.Pm.Primary,n.Pm.Secondary,n.Pm.Primary,n.Pm.Primary,n.Pm.Secondary,n.Pm.Secondary,n.Pm.Primary,n.Pm.Primary,n.Pm.Secondary,n.Pm.Primary,n.Pm.Primary}}]);

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.