(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[177],{250:(e,t,n)=>{Promise.resolve().then(n.t.bind(n,347,23)),Promise.resolve().then(n.bind(n,8491)),Promise.resolve().then(n.bind(n,3190)),Promise.resolve().then(n.bind(n,755)),Promise.resolve().then(n.bind(n,7384))},6046:(e,t,n)=>{"use strict";var s=n(6658);n.o(s,"usePathname")&&n.d(t,{usePathname:function(){return s.usePathname}}),n.o(s,"useRouter")&&n.d(t,{useRouter:function(){return s.useRouter}}),n.o(s,"useSearchParams")&&n.d(t,{useSearchParams:function(){return s.useSearchParams}})},8491:(e,t,n)=>{"use strict";n.d(t,{AuthGate:()=>o});var s=n(5155),r=n(2115),l=n(6046),a=n(6189);function o(e){let{children:t}=e,n=(0,l.usePathname)(),o=(0,l.useRouter)(),[i,u]=(0,r.useState)(!1),c="/login"===n||(null==n?void 0:n.startsWith("/login/"));return((0,r.useEffect)(()=>{if(c){u(!0);return}if(!(0,a.RK)()){let e=n&&"/"!==n?"?next=".concat(encodeURIComponent(n)):"";o.replace("/login".concat(e));return}u(!0)},[n,c,o]),c)?(0,s.jsx)(s.Fragment,{children:t}):i?(0,s.jsx)(s.Fragment,{children:t}):null}},3190:(e,t,n)=>{"use strict";n.d(t,{CollectionSessionProvider:()=>o,f:()=>i});var s=n(5155),r=n(2115);let l="collection-session-v1",a=(0,r.createContext)(null);function o(e){let{children:t}=e,[n,o]=(0,r.useState)([]);(0,r.useEffect)(()=>{try{let e=window.sessionStorage.getItem(l);e&&o(JSON.parse(e))}catch(e){}},[]),(0,r.useEffect)(()=>{try{window.sessionStorage.setItem(l,JSON.stringify(n))}catch(e){}},[n]);let i=(0,r.useCallback)(e=>{var t,n,s,r,l;let a={id:"ce-session-".concat(Date.now(),"-").concat(Math.random().toString(36).slice(2,7)),clientId:e.clientId,kind:e.kind,at:new Date().toISOString(),byUserId:e.byUserId,byUserName:e.byUserName,message:e.message,amount:null!==(t=e.amount)&&void 0!==t?t:null,scheduledAt:null!==(n=e.scheduledAt)&&void 0!==n?n:null,reason:null!==(s=e.reason)&&void 0!==s?s:null,relatedTaskId:null!==(r=e.relatedTaskId)&&void 0!==r?r:null,relatedPaymentId:null!==(l=e.relatedPaymentId)&&void 0!==l?l:null};return o(e=>[...e,a]),a},[]),u=(0,r.useCallback)((e,t)=>{let s=[...e,...n];return(t?s.filter(e=>e.clientId===t):s).sort((e,t)=>new Date(t.at).getTime()-new Date(e.at).getTime())},[n]),c=(0,r.useMemo)(()=>({sessionEvents:n,addEvent:i,mergeEvents:u}),[n,i,u]);return(0,s.jsx)(a.Provider,{value:c,children:t})}function i(){let e=(0,r.useContext)(a);if(!e)throw Error("useCollectionSessionStore must be used inside CollectionSessionProvider");return e}},755:(e,t,n)=>{"use strict";n.d(t,{C:()=>i,CreationSessionProvider:()=>o});var s=n(5155),r=n(2115);let l="creation-session-v1",a=(0,r.createContext)(null);function o(e){let{children:t}=e,[n,o]=(0,r.useState)([]),[i,u]=(0,r.useState)([]),[c,d]=(0,r.useState)([]),[m,v]=(0,r.useState)({}),[h,C]=(0,r.useState)({});(0,r.useEffect)(()=>{try{let a=window.sessionStorage.getItem(l);if(a){var e,t,n,s,r;let l=JSON.parse(a);o(null!==(e=l.clients)&&void 0!==e?e:[]),u(null!==(t=l.orders)&&void 0!==t?t:[]),d(null!==(n=l.leads)&&void 0!==n?n:[]),v(null!==(s=l.comments)&&void 0!==s?s:{}),C(null!==(r=l.orderComments)&&void 0!==r?r:{})}}catch(e){}},[]),(0,r.useEffect)(()=>{try{window.sessionStorage.setItem(l,JSON.stringify({clients:n,orders:i,leads:c,comments:m,orderComments:h}))}catch(e){}},[n,i,c,m,h]);let f=(0,r.useCallback)(e=>{o(t=>[...t,e])},[]),S=(0,r.useCallback)(e=>{u(t=>[...t,e])},[]),b=(0,r.useCallback)(e=>{d(t=>[...t,e])},[]),g=(0,r.useCallback)((e,t)=>{v(n=>{var s;return{...n,[e]:[...null!==(s=n[e])&&void 0!==s?s:[],t]}})},[]),w=(0,r.useCallback)((e,t)=>{C(n=>{var s;return{...n,[e]:[...null!==(s=n[e])&&void 0!==s?s:[],t]}})},[]),k=(0,r.useCallback)(e=>[...e,...n],[n]),P=(0,r.useCallback)(e=>[...e,...i],[i]),I=(0,r.useCallback)(e=>[...e,...c],[c]),y=(0,r.useCallback)((e,t)=>{var n;return[...t,...null!==(n=m[e])&&void 0!==n?n:[]].sort((e,t)=>new Date(t.createdAt).getTime()-new Date(e.createdAt).getTime())},[m]),E=(0,r.useCallback)((e,t)=>{var n;return[...t,...null!==(n=h[e])&&void 0!==n?n:[]].sort((e,t)=>new Date(t.createdAt).getTime()-new Date(e.createdAt).getTime())},[h]),x=(0,r.useMemo)(()=>({sessionClients:n,sessionOrders:i,sessionLeads:c,newClientComments:m,orderComments:h,addClient:f,addOrder:S,addLead:b,addClientComment:g,addOrderComment:w,mergeClients:k,mergeOrders:P,mergeLeads:I,getClientComments:y,getOrderComments:E}),[n,i,c,m,h,f,S,b,g,w,k,P,I,y,E]);return(0,s.jsx)(a.Provider,{value:x,children:t})}function i(){let e=(0,r.useContext)(a);if(!e)throw Error("useCreationSessionStore must be used inside CreationSessionProvider");return e}},347:()=>{}},e=>{var t=t=>e(e.s=t);e.O(0,[690,444,441,517,358],()=>t(250)),_N_E=e.O()}]);