PageSourceSearch

https://clients.onthebooks.com/assets/useClientPortalMessaging-DKecosJw.js

js onthebooks.com collected 2026-10-08 00:21:21 UTC 30,333 bytes, 6 lines download raw bytes

1
2!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="f5f5035f-9732-5c00-8a31-b5437ec76908")}catch(e){}}();
3import{o as e}from"./rolldown-runtime-C0FnF6B9.js";import{$u as t,Fa as n,G as r,Gi as i,Ji as a,K as o,Ki as s,Na as c,Wi as ee,Xi as l,ca as u,da as d,ia as f,la as p,n as m,oa as h,qi as te,ra as ne,sa as g,ta as _}from"./api-C_qz-3H-.js";import{i as re,t as v}from"./react-DjXLjDm_.js";import{s as y}from"./sentry-DKIEfPU-.js";import{t as b}from"./es-BHPBQXI6.js";import{dr as ie,yn as x}from"./antd-CSeLy0qZ.js";import{n as S}from"./QueryClientProvider-BmsvgAHE.js";import{_ as ae,f as C,h as w,t as oe}from"./useClient-hCvutf_a.js";import{n as se,t as ce}from"./axios-CRXK8B5w.js";import{t as T}from"./useAppSelector-aco8lS09.js";import{Zi as le}from"./userAction-Cd4w5LV_.js";import{Ht as ue,X as E,Y as D,Z as O,t as de}from"./client-DzHa481v.js";import{Ht as fe,dt as k,g as A,tt as j}from"./xero-V08HB2BB.js";import{u as pe}from"./attachable-CYuO6T4O.js";import{r as M}from"./useClientPortalContext-BnjM-ma7.js";import{t as N}from"./clientPortal.utils-6D5JPchP.js";var P=e(re(),1),F=e(ie(),1),I=(e,t)=>({type:`SET_ATTACHMENTS`,payload:{id:e,files:t}}),L=e=>({type:`SET_ATTACHMENT_COUNT`,payload:{count:e}}),me=e=>({type:`INCREMENT_ATTACHMENTS_COUNT`,payload:{quantityByAttachmentKey:e}}),he=(e,t)=>({type:`SET_ATTACHMENTS_BASE64`,payload:{fileKey:e,base64:t}}),ge=(e,t,n,r)=>({type:`UPDATE_TASK_ATTACHABLE`,payload:{attachableId:e,type:t,value:n,fileKey:r}}),_e=(e,t)=>({type:`REMOVE_TASK_ATTACHABLE`,payload:{attachableId:e,fileKey:t}}),ve=e=>({type:`SET_THUMBNAIL_ATTACHABLES`,payload:{thumbnails:e}}),R=async(e,t,n)=>{let r=`/messaging/client-portal-post/client/${e}`;return n&&(r=`/messaging/client-portal/client-portal-post/client/${e}/with-attachments`),m.get(r,{params:t})},ye=async(e,t)=>m.patch(`/messaging/client-portal-post/${e}`,t),be=async(e,t)=>m.post(`/messaging/client-portal-post/${e}/client-portal-message`,t),xe=(e,t)=>m.post(`/messaging/client-portal-post/bulk-add-client-portal-message`,{clientPortalPostIds:e,...t}),Se=(e,t,n)=>m.post(`/messaging/client-portal-post/${e}/bulk-add-bank-feed-questions`,{bankFeedTransactionsIds:t,...n}),Ce=async(e,t,n)=>m.patch(`/messaging/client-portal-post/${e}/client-portal-message/${t}`,n),we=async(e,t)=>m.delete(`/messaging/client-portal-post/${e}/client-portal-message/${t}`),z=async(e,t,n)=>m.patch(`/messaging/client-portal-post/${e}/metadata`,{metadata:t,assignedToContactIds:n}),Te=async e=>m.delete(`/messaging/client-portal-post/${e}`),Ee=async e=>m.post(`/messaging/client-portal-post`,e),De=async e=>m.get(`/messaging/client-portal-post/client/${e}/thumbnails`),Oe=async()=>m.get(`/messaging/client-portal/counts`),ke=async e=>m.get(`/messaging/client-portal/preview/counts/${e}`),Ae=async(e,t,n,r,i)=>m.post(`/messaging/client-portal/client/${e}/client-portal-post/${t}/attachment`,{attachments:n,description:r,withoutAddingNewMessage:i}),B=async(e,t)=>m.get(`/messaging/client-portal/client/${e}/client-portal-post/${t}/attachment`),V=async(e,t)=>m.post(`/messaging/client-portal/client/${e}/client-portal-post/attachment-count`,{clientPortalPostIds:t}),je=async(e,t,n)=>m.post(`/messaging/client-portal-post/${e}/bulk-add-transaction-questions`,{transactions:t,...n}),Me=async(e,t,n)=>m.post(`/messaging/client-portal-post/${e}/bulk-update-client-portal-posts`,{clientPortalPostIds:t,updateParams:n}),Ne=async(e,t)=>m.get(`/messaging/client-portal-post/${e}/client/${t}/timeline`),Pe=(e,t,n)=>m.post(`/client-portal/client/${e}/posts/${t}/tasks/${n}`),Fe=(e,t,n)=>m.post(`/client-portal/client/${e}/posts/${t}/non-closing-tasks/${n}`),Ie=(e,t,n)=>m.post(`/client-portal/client/${e}/posts/${t}/project-tasks/${n}`),Le=(e,t,n)=>m.delete(`/client-portal/client/${e}/posts/${t}/tasks/${n}`),Re=(e,t,n)=>m.delete(`/client-portal/client/${e}/posts/${t}/non-closing-tasks/${n}`),ze=(e,t,n)=>m.delete(`/client-portal/client/${e}/posts/${t}/project-tasks/${n}`),Be=(e,t)=>m.post(`/messaging/client-portal/client/${e}/client-portal-post/task-link-count`,{clientPortalPostIds:t}),Ve=e=>m.get(`/messaging/linked-tasks/closing`,{params:{endCloseId:e}}),He=e=>m.get(`/messaging/linked-tasks/non-closing`,{params:{clientId:e}}),Ue=()=>m.get(`/messaging/linked-tasks/firm`),We=e=>m.get(`/messaging/linked-tasks/project`,{params:{projectId:e}}),H=e=>e.reduce((e,t)=>
3t.id>e?t.id:e,-1);function Ge(e){if(!e)return``;let t=new Intl.DisplayNames([`en`],{type:`currency`}).of(e);return t&&t!==e?`${e} (${t})`:e}function Ke(e,t=`en`){try{return new Intl.NumberFormat(t,{style:`currency`,currencyDisplay:`symbol`,currency:e||w.USD}).format(0).replace(/\d/g,``).replace(`.`,``).trim()}catch{return`$`}}function U(e){return e==null}function qe(e,t){return!!(t&&e.currency_code&&t!==e.currency_code)}function Je(e){return U(e.currency_rate)?1:e.currency_rate}function Ye(e){return U(e.reporting_amount_value)?Number(e.amount_value)*Je(e):e.reporting_amount_value}function Xe(e){let t=Number(e.debit_value??0)!==0||Number(e.credit_value??0)!==0||Number(e.amount_value??0)!==0,n=Number(e.debit_home_value??0),r=Number(e.credit_home_value??0);return t||n===0&&r===0?e:{...e,debit_value:n,credit_value:r,amount_value:n===0?r:n,currency_rate:1}}var Ze=(e,t)=>{let{accountsById:n,vendorsById:r}=t,i=e.accountId?n[e.accountId]:null,a=e.vendorId?r[e.vendorId]:null;return{idx:0,date_value:e.date,name_id:a?.id??``,name_value:a?.name??``,account_id:i?.id??``,account_value:i?.name??``,amount_value:e.amount,memo_description_value:e.description,entity_value_id:e.id,transaction_type_id:e.id,transaction_type_value:e.type,transaction_type_value_id:`${e.type}-${e.id}`}},Qe=(e,t,n)=>{let{vendorsById:r,financialAccountsById:i}=n,a=t.toLowerCase(),o=e.vendorId?r[e.vendorId]:null,s=e.accountId?i[e.accountId]:null,c=(0,F.default)(e.date);return e.description.toLowerCase().includes(a)||o?.name.toLowerCase().includes(a)||s?.name.toLowerCase().includes(a)||e.amount.toString().includes(a)||c.format(`MM/DD/YYYY`).includes(a)||c.format(`MMM DD, YYYY`).toLowerCase().includes(a)},$e=e=>e?.transaction_type_id??e?.entity_value_id.split(`-`).slice(1).join(``),et=(e,t)=>e.filter(e=>e.clientId===t&&e.type===d.USER_TO_CONTACT_QUESTION),tt=(e,t)=>e.filter(e=>e.clientId===t&&e.type===d.CONTACT_TO_USER_QUESTION),nt=(e,t)=>e.filter(e=>e.clientId===t&&e.type===d.TRANSACTION_QUESTION),rt=(e,t)=>e.filter(e=>e.clientId===t&&e.type===d.BANK_FEED_TRANSACTION_QUESTION),it=(e,t)=>e.filter(e=>e.clientId===t&&e.type===d.RECEIPT_QUESTION),at=e=>e?.clientPortalMessages?.toSorted((e,t)=>e.sortOrder-t.sortOrder)??[],W=e=>at(e).at(0),G=e=>W(e)?.sentByContactId,ot=e=>e.type===d.CONTACT_TO_USER_QUESTION?G(e):e.clientPortalMessages.filter(e=>e.type===p.ANSWER).at(-1)?.sentByContactId,st=(e,t,n,r)=>{if(e.type===d.CONTACT_TO_USER_QUESTION){let t=e.assignees?.map(e=>e.id)??[],n=G(e),r=[...t];return n&&r.push(n),r.filter(Boolean)}if(e.type===d.USER_TO_CONTACT_QUESTION){let i=c(r).map(e=>e.id);if(n&&e.assignees)return[...new Set([...e.assignees.map(e=>e.id),...i])];let a=ot(e);return a?[...new Set([a,...i])]:[...new Set([...Object.values(t).map(e=>e.id),...i])]}return[]},ct=(e,t,n,r)=>{if(t){let e=c(r).map(e=>e.id);return n?[...new Set([...n,...e])]:e}return Object.values(e).map(e=>e.id)},lt=e=>e?.isClosed??!1,K=e=>e?!e.isClosed:!1,q=e=>e?.clientPortalMessages?.length>0&&[...e.clientPortalMessages??[]].sort((e,t)=>new Date(t.createdAt).getTime()-new Date(e.createdAt).getTime()).at(0)?.type===p.ANSWER,ut=e=>e.filter(e=>K(e)&&q(e)),dt=e=>e.filter(e=>K(e)&&!q(e)),ft=e=>e.filter(e=>lt(e)),pt=(e,t)=>new Date(t.createdAt).getTime()-new Date(e.createdAt).getTime(),mt=e=>e.clientPortalMessages.filter(e=>e.type===p.ANSWER).at(-1),ht=e=>{let t=e.clientPortalMessages.filter(e=>e.type===p.QUESTION).at(0);if(!t)throw Error(`Client Portal Post does not have a question: ID`+e.id);return t},gt=function(e){return e.WAITING_ON_CLIENT=`waitingOnClient`,e.RESPONDED=`responded`,e.RESOLVED=`resolved`,e}({}),_t=e=>e.isClosed?`resolved`:q(e)?`responded`:`waitingOnClient`,vt={responded:e=>K(e)&&q(e),waitingOnClient:e=>K(e)&&!q(e),resolved:e=>!K(e)},yt=e=>e?.clientPortalMessages?.filter(e=>e.type===p.QUESTION).at(-1),bt=e=>e.clientPortalMessages.toSorted((e,t)=>e.sortOrder-t.sortOrder).at(-1),J=e=>{switch(e.type){case d.RECEIPT_QUESTION:return xt(e.receiptPostMetadata);case d.BANK_FEED_TRANSACTION_QUESTION:return St(e.bankFeedTransactionPostMetadata);case d.TRANSACTION_QUESTION:default:return e.transactionPostMetadata?.transactionMetadata}},xt=e=>{if(e)return{account_id:e.accountId??``,account_value:e.accountName??``,amount_value:e.total??0,date_value:e.date??void 0,memo_description_value:e.description??``,name_id:e.vendorId??``,name_value:e.vend
3orName??``}},St=e=>{if(e)return{amount_value:e.amount??0,date_value:e.date??void 0,memo_description_value:e.description??``,name_id:e.vendorId??``}},Ct=(e,t)=>{let n=t.toLowerCase(),r=J(e);return r?.name_value?.toLowerCase().includes(n)||r?.memo_description_value?.toLowerCase().includes(n)||r?.account_value?.toLowerCase().includes(n)||r?.amount_value?.toString().includes(n)||e.clientPortalMessages.some(e=>e.message?.toLowerCase().includes(n))},wt=e=>e.clientPortalMessages.map(e=>e.type===p.QUESTION?`Q: ${e.message}`:e.type===p.ANSWER?`A: ${e.message}`:``).join(`
4`),Tt=(e,t,r,i)=>{let a=t.toLowerCase();return i&&Array.isArray(e.assignees)&&e.assignees.length>0&&e.assignees.some(e=>{let t=r[e.id];return t&&n(t).toLowerCase().includes(a)})?!0:e.clientPortalMessages.some(e=>e.message?.toLowerCase().includes(a))},Et=(e,t,r,i)=>{let a=t.toLowerCase();return r&&Array.isArray(e.assignees)&&e.assignees.length>0&&e.assignees.some(e=>{let t=i[e.id];return t&&n(t).toLowerCase().includes(a)})?!0:e.clientPortalMessages.some(e=>e.message?.toLowerCase().includes(a))},Dt=e=>e.type===d.USER_TO_CONTACT_QUESTION&&e.userToContactQuestionMetadata?.isW9Request,Ot=e=>{let t=Y(e);return t?!e.isClosed&&t.length===0:!1},kt=(e,t)=>{if(!e||!t)return!1;let n=Y(e);return n.length===t.length&&n.every(e=>t.includes(e))},Y=e=>{if(!e)return[];let t=e=>!e||!Array.isArray(e)?[]:e.map(e=>e.id).filter(e=>e!=null);if(e.type===d.CONTACT_TO_USER_QUESTION){let n=t(e.assignees),r=W(e)?.sentByContactId,i=[...n];return r!=null&&r!==-1&&!i.includes(r)&&i.push(r),i}return t(e.assignees)},At=(e,t)=>Y(e).includes(t),jt=(e,{isClientQuestionsAssignableOn:t,isClientPortal:n,hasClientAdminAccess:r,clientAdminFilter:i,contactId:a})=>!t||!n||r&&i!==u.ASSIGNED_TO_ME||At(e,a),Mt=e=>e?e.type===d.CONTACT_TO_USER_QUESTION?G(e)??null:e.assignees??[]:[],Nt=e=>{if(e.attachmentId.split(`-`).length>2){let[t,n]=e.attachmentId.split(/-(.*)/);return{transaction_type_value:t,transaction_type_id:n}}let t=e.attachmentId.split(`-`);return{transaction_type_value:t[0],transaction_type_id:t[1]}},Pt=e=>{let t=J(e),n=[`Invoice`,`Bill`,`Journal Entry`,`Sales Receipt`,`Transfer`];return[t?.name_value?t.name_value:e.type===d.BANK_FEED_TRANSACTION_QUESTION?``:t?.transaction_type_value===`Journal Entry`?`---`:`(No Payee Provided)`,(()=>{let e=t?.transaction_type_value;return!e||!n.includes(e)?``:`${e}${t?.num_value?` (${t.num_value})`:``}`})(),t?.memo_description_value||``].filter(e=>e.length>0).join(` - `)},Ft=function(e){return e.POSITIVE=`positive`,e.NEUTRAL=`neutral`,e.NEGATIVE=`negative`,e}({}),It=e=>{let t=J(e);return!t?.transaction_type_value&&t?.amount_value?t.amount_value>0?`positive`:t.amount_value<0?`negative`:`neutral`:t?.transaction_type_value===`Pledge`||t?.transaction_type_value===`Payment`||t?.transaction_type_value?.includes(`Receipt`)||t?.transaction_type_value===`Vendor Credit`||t?.transaction_type_value===`Credit Card Credit`||t?.transaction_type_value===`Sales Receipt`||t?.transaction_type_value===`Invoice`||t?.transaction_type_value===`Deposit`||t?.transaction_type_value===`Receive Money`||t?.transaction_type_value===`Accounts Payable Credit Note`||t?.transaction_type_value===`Invoice Payment`?`positive`:t?.transaction_type_value===`Inventory Qty Adjust`||t?.transaction_type_value===`Transfer`||t?.transaction_type_value===`Journal Entry`||t?.transaction_type_value===`Bank Transfer`||t?.transaction_type_value===`Manual Journal`?`neutral`:`negative`},Lt=e=>{let t=J(e);if(t?.account_value)return`From: ${t?.account_value}`;let n=e.bankFeedTransactionPostMetadata?.bankFeedAccount?.institutionName;return n&&n!==`Manual Import`?`From: ${n}`:null},Rt=(e,t)=>
4t===d.CONTACT_TO_USER_QUESTION?e.type===p.ANSWER:e.type===p.QUESTION,zt=(e,t)=>{let n=Math.max(...t.clientPortalMessages.map(e=>e.sortOrder));return e.sortOrder===n},Bt=e=>(0,F.default)(e.createdAt).format(`MMM D, YYYY h:mm A`),Vt=e=>{if(e.subject)return e.subject;try{let t=ht(e);return!t||typeof t.message!=`string`?null:t.message}catch{return null}},Ht=v(),X=(0,P.createContext)(()=>void 0);function Ut({children:e,onMutationSuccess:t}){return(0,Ht.jsx)(X.Provider,{value:t,children:e})}function Wt(){return(0,P.useContext)(X)}var Z={clientPortalPostTimeline:e=>[`clientPortalMessaging`,`clientPortalPostTimeline`,e],allClientPortalPostTimeline:()=>[`clientPortalMessaging`,`clientPortalPostTimeline`],allClientPortalPostTaskLinkCounts:e=>[`clientPortalMessaging`,`clientPortalPostTaskLinkCounts`,e],clientPortalPostTaskLinkCounts:(e,t)=>[`clientPortalMessaging`,`clientPortalPostTaskLinkCounts`,e,t],closingTasksClientPortalPostLinks:e=>[`clientPortalMessaging`,`closingTasksClientPortalPostLinks`,e],nonClosingTasksClientPortalPostLinks:e=>[`clientPortalMessaging`,`nonClosingTasksClientPortalPostLinks`,e],firmTasksClientPortalPostLinks:()=>[`clientPortalMessaging`,`firmTasksClientPortalPostLinks`],projectTasksClientPortalPostLinks:e=>[`clientPortalMessaging`,`projectTasksClientPortalPostLinks`,e],allProjectTasksClientPortalPostLinks:()=>[`clientPortalMessaging`,`projectTasksClientPortalPostLinks`],clientPortalPostAuthors:e=>[`clientPortalMessaging`,`clientPortalPostAuthors`,e]},Gt=()=>{let e=S(),t=(0,P.useCallback)(t=>{e.invalidateQueries({queryKey:Z.clientPortalPostTimeline(t)})},[e]),n=(0,P.useCallback)(t=>{e.invalidateQueries({predicate(e){return!e?.queryKey||!Array.isArray(e.queryKey)||e.queryKey.length<2?!1:t.includes(e?.queryKey?.[1])}})},[e]);
4return{invalidateClientPortalPostTimeline:t,invalidateAllClientPortalPostTimeline:(0,P.useCallback)(()=>e.invalidateQueries({queryKey:Z.allClientPortalPostTimeline()}),[e]),invalidateClientPortalPostTimelineByClientPortalPostIds:n}},Kt=()=>{let e=T(e=>e.vaultResults.contact),t=T(e=>e.userResults.userId),{contact:n,hasClientAdminAccess:r}=M();return $()?{sentByUserId:void 0,sentByContactId:(n??e)?.id,hasClientAdminAccess:r}:{sentByUserId:t,sentByContactId:void 0,hasClientAdminAccess:r}},qt=e=>{let{onGetClientPortalPostThumbnails:t}=on();(0,P.useEffect)(()=>{e&&t(e)},[e])},Jt=e=>T(t=>l(t,e)),Yt=e=>{let t=T(t=>_(t,e));return(0,P.useMemo)(()=>et(t,e),[t]).sort((e,t)=>e.sortOrder-t.sortOrder)},Xt=e=>{let t=T(t=>_(t,e));return(0,P.useMemo)(()=>tt(t,e),[t,e])},Zt=e=>{let t=T(t=>_(t,e));return(0,P.useMemo)(()=>it(t,e),[t])},Qt=e=>{let t=T(t=>_(t,e));return(0,P.useMemo)(()=>it(t,e).concat(nt(t,e)).concat(rt(t,e)),[t,e])},$t=e=>{let t=T(t=>_(t,e));return(0,P.useMemo)(()=>nt(t,e),[t])},Q=()=>{let e=T(e=>e.vaultResults?.token??``),t=$(),n=T(e=>e.userResults.token);return t?e:n},en=()=>{let e=oe(e=>e?.platform),t=T(e=>e.vaultResults?.platform),{platform:n}=M();return $()?t??n:e},$=()=>{let{isClientPortal:e,isPreview:t}=M();return e===null?N():e&&!t},tn=()=>{let e=ae(),t=T(e=>e.vaultResults?.selectedVaultClientId??e?.clientAuthResults?.auth?.clientId??null),n=$(),r=M()?.selectedClientId;return n?r||t:e},nn=e=>T(n=>n?.attachments?.[e]?.files??t),rn=e=>{let n=$(),r=(0,P.useMemo)(()=>{let t=[`${e.attachmentId}-client`,`${e.attachmentId}-qbo`];if(e.type===d.USER_TO_CONTACT_QUESTION&&e?.userToContactQuestionMetadata?.isW9Request&&t.push(`Vendor-${e.userToContactQuestionMetadata?.vendorId}-qbo`),(e.type===d.TRANSACTION_QUESTION||e.type===d.RECEIPT_QUESTION)&&!n){let n=e?.transactionPostMetadata?.transactionMetadata?.name_value?.includes(`deleted`)?null:e?.transactionPostMetadata?.transactionMetadata?.name_id;t.push(`Vendor-${n}-qbo`)}return t},[e,n]);return{count:T(e=>r.reduce((t,n)=>(t+=e?.attachments?.[n]?.count??0,t),0)),files:T(e=>r.reduce((n,r)=>(n.push(...e?.attachments?.[r]?.files??t),n),[])),thumbnailsFiles:T(e=>r.reduce((t,n)=>(e?.attachments?.[n]?.thumbnail&&t.push(e?.attachments?.[n]?.thumbnail),t),[]))}},an=()=>{let e=le(),t=Q(),n=tn(),r=en(),i=$(),a=T(e=>e.userResults.practiceId),o=(0,P.useCallback)((t,n)=>{e(I(n.attachmentId+`-client`,t))},[e]),s=(0,P.useCallback)((t,n)=>{e(_e(t,n))},[e]),c=(0,P.useCallback)((t,n)=>{e(I(n.attachmentId+`-qbo`,t))},[e]),ee=async(t,n)=>{try{let r=await O(t,``,{questionIds:n,withSuffix:!0});e(L(r))}catch(e){y(e),x.error({title:`Error`,description:`Error loading attachment counts. Please try again or contact support.`})}},l=async(t,r)=>{try{if(t?.length>0){let i=[];for(let e of t)e?.transactionPostMetadata?.transactionMetadata?.name_id&&i.push({transaction_type_value:`Vendor`,transaction_type_id:e?.transactionPostMetadata?.transactionMetadata?.name_id});let a=t.filter(e=>e.type===d.TRANSACTION_QUESTION);r.isXero||fe(r.clientId,i.concat(a.map(e=>({transaction_type_value:e?.transactionPostMetadata?.transactionMetadata?.transaction_type_value,transaction_type_id:e?.transactionPostMetadata?.transactionMetadata?.transaction_type_id})))).then(t=>{let n={};for(let e in t)n[`${e}-qbo`]=t[e];e(L(n))}),O(r.clientId,``,{transactionTypeValueIds:a.map(e=>({transactionTypeValue:e?.transactionPostMetadata?.transactionMetadata?.transaction_type_value,transactionTypeId:$e(e?.transactionPostMetadata?.transactionMetadata)})),withSuffix:!0}).then(t=>{e(L(t))});let o=[...new Set(i.map(e=>
4e.transaction_type_id))];O(r.clientId,``,{questionIds:o.map(e=>`${n}-vendor-${e}`)}).then(t=>{e(L(t))})}}catch{}},u=async t=>{try{let r=(await V(n,t.map(e=>e.id))).reduce((e,t)=>(e[`${t.attachmentId}-client`]=t.count,e),{});return e(L(r)),r}catch(e){y(e)}return{}},f=async e=>{try{let i=J(e),[a,s]=await Promise.all([B(n,e.id),r===C.qbo?j(t,n,[i?.entity_value_id].filter(Boolean)):Promise.resolve(null)]);if(o(a,e),s){let t=s[i?.entity_value_id]??[];c(t,e)}}catch(e){y(e),x.error({title:`Error loading client portal post attachments. Please try again or contact support.`})}},p=async s=>{if(s.type!==d.USER_TO_CONTACT_QUESTION)throw Error(`Invalid client portal post type`);if(!i){let i=[];if(i.push(async()=>{let e=await D(t,s.clientId,``,{questionId:s.attachmentId});o(e,s)}),s.userToContactQuestionMetadata?.isW9Request){let o=s.userToContactQuestionMetadata?.vendorId;o&&i.push(async()=>{let i=r===C.xero?await A(t,n,o):await k({token:t,uid:``,clientId:n,type:`vendor`,typeId:o,practiceId:a});e(I(`Vendor-${o}-qbo`,i))})}await Promise.all(i.map(e=>e()))}if(i){let e=await E(t,n,{questionId:s.attachmentId});o(e,s)}},m=async e=>{if(e.type!==d.CONTACT_TO_USER_QUESTION)throw Error(`Invalid client portal post type`);if(!i){let n=await D(t,e.clientId,``,{questionId:e.attachmentId});o(n,e)}if(i){let r=await E(t,n,{questionId:e.attachmentId});o(r,e)}},h=async e=>{if(e.type!==d.BANK_FEED_TRANSACTION_QUESTION)throw Error(`Invalid client portal post type`);if(!i){let n=await D(t,e.clientId,``,{questionId:e.attachmentId});o(n,e)}if(i){let r=await E(t,n,{questionId:e.attachmentId});o(r,e)}};return{setClientPortalAttachments:o,setTransactionAttachments:c,loadAttachmentCounts:ee,loadTransactionAttachmentCounts:l,getClientPortalPostTransactionOrReceiptAttachments:f,getClientPortalPostAttachmentCounts:u,getClientPortalPostAttachments:async e=>{if(e.type===d.TRANSACTION_QUESTION||e.type===d.RECEIPT_QUESTION)return f(e);if(e.type===d.USER_TO_CONTACT_QUESTION)return p(e);if(e.type===d.CONTACT_TO_USER_QUESTION)return m(e);if(e.type===d.BANK_FEED_TRANSACTION_QUESTION)return h(e)},removeClientPortalAttachments:s}};function on(){let e=le(),t=Wt(),n=Q(),c=$(),{setClientPortalAttachments:l,getClientPortalPostTransactionOrReceiptAttachments:u}=an(),{sentByContactId:m,sentByUserId:_,hasClientAdminAccess:re}=Kt(),{invalidateClientPortalPostTimeline:v,invalidateAllClientPortalPostTimeline:ie,invalidateClientPortalPostTimelineByClientPortalPostIds:S}=Gt(),ae=async(t,n)=>{try{window.changed=!0,e(s({sortOrders:n})),await ye(t,{sortOrders:n})}catch(e){y(e),x.error({title:`Error`,description:`Error sorting client portal post. Please try again or contact support.`})}finally{window.changed=!1}},C=async n=>{try{window.changed=!0;let r=await Ee({...n,initialClientPortalMessage:{...n.initialClientPortalMessage,sentByUserId:_,sentByContactId:m}});return(0,b.unstable_batchedUpdates)(()=>{e(ee(r)),e(i({clientPortalPostId:r.id}))}),t(),r}catch(e){throw y(e),e instanceof Error&&`response`in e&&typeof e.response==`object`&&e.response&&`status`in e.response&&e.response.status===412?x.error({title:`Error`,description:`Cannot add question to transaction that already has a question. Please reload the page.`}):(e=>se(e)&&e.response?.status===400&&e.response?.data?.[0]?.path&&e.response?.data?.[0]?.path.includes(`total`)&&e.response?.data?.[0]?.code===`too_small`)(e)?x.error({title:`Error`,description:`Error adding client portal post. Total cannot be negative.`}):x.error({title:`Error`,description:`Error adding client portal post. Please try again or contact support.`}),e}finally{window.changed=!1}},w=async(n,r)=>{try{window.changed=!0;let i=await be(n,{sentByContactId:m,sentByUserId:_,...r});return v(n),e(h({id:i.id,changes:i})),t(),i}catch(e){x.error({title:`Error`,description:`Error adding client portal message. Please try again or contact support.`}),y(e)}finally{window.changed=!1}},oe=async(t,n)=>{try{window.changed=!0;let r=await xe(t,{sentByContactId:m,sentByUserId:_,...n});e(g(r)),S(t)}catch(e){x.error({title:`Error`,description:`Error adding client portal message. Please try again or c
4ontact support.`}),y(e)}finally{window.changed=!1}},T=async(n,r,i)=>{try{window.changed=!0;let a=await Se(n,r,i);e(g(a)),S(a.map(e=>e.id)),t()}catch(e){x.error({title:`Error`,description:`Error adding bank feed questions. Please try again or contact support.`}),y(e)}finally{window.changed=!1}},E=async(n,r)=>{try{window.changed=!0;let i=await ye(n,r);e(g([i])),t()}catch(e){y(e),x.error({title:`Error`,description:`Error updating client portal post. Please try again or contact support.`})}finally{window.changed=!1}},D=async(n,r,i)=>{try{window.changed=!0;let a=await Ce(n,r,i);v(n),e(h({id:a.id,changes:a})),t()}catch(e){x.error({title:`Error`,description:`Error updating client portal message. Please try again or contact support.`}),y(e)}finally{window.changed=!1}},O=async(n,r)=>{try{window.changed=!0,await we(n,r),v(n),e(te({clientPortalPostId:n,clientPortalMessageId:r})),t()}catch(e){x.error({title:`Error`,description:`Error deleting client portal message. Please try again or contact support.`}),y(e)}finally{window.changed=!1}},fe=async(t,r,i)=>{try{let a=await pe(r.clientId,t);if(a.length===0)return!1;if(c){let{clientPortalPost:t,attachments:n}=await Ae(r.clientId,r.id,a,i?.message,i?.withoutAddingNewMessage);(0,b.unstable_batchedUpdates)(()=>{l(n,t),e(h({id:r.id,changes:t}))}),v(t.id);return}let o=await(async()=>{if(r.type===d.USER_TO_CONTACT_QUESTION||r.type===d.CONTACT_TO_USER_QUESTION||r.type===d.BANK_FEED_TRANSACTION_QUESTION){let e=i?.clientPortalMessageId??H((await w(r.id,{message:i?.message??``,type:r.type===d.USER_TO_CONTACT_QUESTION||r.type===d.BANK_FEED_TRANSACTION_QUESTION?p.QUESTION:p.ANSWER}))?.clientPortalMessages??[]);return{questionId:r.attachmentId,clientPortalMessageId:e}}if(r.type===d.TRANSACTION_QUESTION||r.type===d.RECEIPT_QUESTION){let e=J(r);return{transaction_type_value:e?.transaction_type_value,transaction_type_id:e?.transaction_type_id}}return{}})(),s=c?de.ClientPortalAttachable:de.CloseAttachable;if(!await ue(r.clientId,n,a,o,s)){x.error({title:`Error with uploading this file. Please try again and if the issue continues please contact us.`,duration:4});return}await u(r),v(r.id)}catch(e){if(e instanceof ce&&e?.response?.data?.[0]?.code===`too_small`&&e?.response?.data?.[0]?.path?.includes(`mime`)){x.error({title:`Error`,description:`Missing file extension. Add one and retry.`});return}x.error({title:`Error`,description:`Error uploading file. Please try again or contact support.`}),y(e)}},k=async({clientPortalPostId:t,updateParams:n,assignedToContactIds:r})=>{try{window.changed=!0;let i=await z(t,{userToContactQuestionMetadata:n},r);setTimeout(()=>{v(t)},500),e(h({id:i.id,changes:i}))}catch(e){throw y(e),x.error({title:`Error`,description:`Error updating user to contact metadata. Please try again or contact support.`}),e}finally{window.changed=!1}},A=async({clientPortalPostId:n,updateParams:r,assignedToContactIds:i})=>{try{window.changed=!0;let a=await z(n,{bankFeedTransactionPostMetadata:r},i);setTimeout(()=>{v(n)},500),e(h({id:a.id,changes:a})),t()}catch(e){throw y(e),x.error({title:`Error`,description:`Error updating user to contact metadata. Please try again or contact support.`}),e}finally{window.changed=!1}},j=async({clientPortalPostId:t,assignedToContactIds:n})=>{try{window.changed=!0;let r=await z(t,{},n);setTimeout(()=>{v(t)},500),e(h({id:r.id,changes:r}))}catch(e){throw y(e),x.error({title:`Error`,description:`Error updating transaction question assignee. Please try again or contact support.`}),e}finally{window.changed=!1}},M=async({clientPortalPostId:t,assignedToContactIds:n})=>{try{window.changed=!0;let r=await z(t,{},n);setTimeout(()=>{v(t)},500),e(h({id:r.id,changes:r}))}catch(e){throw y(e),x.error({title:`Error`,description:`Error updating question assignee. Please try again or contact support.`}),e}finally{window.changed=!1}},N=async({clientPortalPostId:t,assignedToContactIds:n})=>{try{window.changed=!0;let r=await z(t,{},n);setTimeout(()=>{v(t)},500),e(h({id:r.id,changes:r}))}catch(e){throw y(e),x.error({title:`Error`,description:`Error updating transaction question assignee. Please try again or c
4ontact support.`}),e}finally{window.changed=!1}},F=(0,P.useCallback)(t=>{e(ne(t))},[e]);return{onSortClientPortalPost:ae,onAddClientPortalMessage:w,onBulkAddClientPortalMessage:oe,onUpdateClientPortalMessage:D,onUploadClientPostFile:fe,onUpdateUserToContactQuestionMetadata:k,onUpdateTransactionQuestionMetadata:N,onUpdateReceiptQuestionMetadata:j,onUpdateClientPortalPost:E,onLoadClientPortalPosts:F,onDeleteClientPortalPost:async(n,r)=>{try{window.changed=!0,await Te(r),e(a(r)),t()}catch(e){y(e),x.error({title:`Error`,description:`Error deleting client portal post. Please try again or contact support.`})}finally{window.changed=!1}},onAddClientPortalPost:C,onGetClientPortalPostsByType:async(t,n,r)=>{try{let{clientPortalPosts:i,attachments:a}=await R(t,{type:n,clientAdminFilter:r},c);return(0,b.unstable_batchedUpdates)(()=>{e(f({clientId:t,type:n,posts:i})),Object.entries(a??{}).forEach(([e,t])=>{let n=i.find(t=>t.id===Number(e));n&&l(t,n)})}),i}catch(e){return y(e),x.error({title:`Error`,description:`Error loading client portal posts. Please try again or contact support.`}),[]}},onGetClientPortalPostThumbnails:async t=>{try{let n=await De(t);e(ve(n))}catch(e){y(e),x.error({title:`Error`,description:`Error loading client portal post thumbnails. Please try again or contact support.`})}},onGetClientPortalPosts:async e=>{try{let{clientPortalPosts:t,attachments:n}=await R(e,{},c);return(0,b.unstable_batchedUpdates)(()=>{F(t),Object.entries(n??{}).forEach(([e,n])=>{let r=t.find(t=>t.id===Number(e));r&&l(n,r)})}),t}catch(e){y(e),x.error({title:`Error`,description:`Error loading client portal posts. Please try again or contact support.`})}},onGetClientPortalPostCounts:async()=>{try{let t=await Oe(),n=t.map(({clientId:e,pendingOrganizersCount:t,...n})=>({clientId:e,...n})),i=t.map(({clientId:e,pendingOrganizersCount:t})=>({clientId:e,pendingOrganizersCount:t??0}));e(o({clientPortalPostCounts:n})),e(r({clientPortalOrganizerCounts:i}))}catch(e){y(e),x.error({title:`Error`,description:`Error loading client portal post counts. Please try again or contact support.`})}},onBulkAddTransactionQuestions:async(t,n,r)=>{try{window.changed=!0;let i=await je(t,n,r);return e(g(i)),ie(),i}catch(e){y(e),x.error({title:`Error`,description:`Error adding transaction questions. Please try again or contact support.`})}finally{window.changed=!1}},onBulkUpdateClientPortalPosts:async(t,n,r)=>{try{window.changed=!0;let i=await Me(t,n,r);return e(g(i)),S(n),i}catch(e){y(e),x.error({title:`Error`,description:`Error updating questions. Please try again or contact support.`})}finally{window.changed=!1}},onDeleteClientPortalMessage:O,onUpdateClientPortalPostAssignedToContactId:async(t,n)=>{try{window.changed=!0,t.type===d.CONTACT_TO_USER_QUESTION&&await M({clientPortalPostId:t.id,assignedToContactIds:n}),t.type===d.USER_TO_CONTACT_QUESTION&&await k({clientPortalPostId:t.id,assignedToContactIds:n}),t.type===d.TRANSACTION_QUESTION&&await N({clientPortalPostId:t.id,assignedToContactIds:n}),t.type===d.RECEIPT_QUESTION&&await j({clientPortalPostId:t.id,assignedToContactIds:n}),t.type===d.BANK_FEED_TRANSACTION_QUESTION&&await A({clientPortalPostId:t.id,assignedToContactIds:n});let r=t.type===d.CONTACT_TO_USER_QUESTION&&G(t)===m;c&&m&&!re&&!n.includes(m)&&!r&&e(a(t.id))}catch{}finally{window.changed=!1}},onUpdateBankFeedTransactionQuestionMetadata:A,onBulkAddBankFeedQuestions:T}}export{Dt as $,ht as A,me as At,mt as B,Tt as C,We as Ct,Y as D,Re as Dt,Mt as E,Pe as Et,Nt as F,ge as Ft,ft as G,yt as H,st as I,Rt as J,J as K,ct as L,It as M,L as Mt,Vt as N,I as Nt,Bt as O,ze as Ot,Pt as P,he as Pt,Ot as Q,G as R,Ct as S,ke as St,Et as T,Ie as Tt,ut as U,bt as V,wt as W,lt as X,q as Y,K as Z,Z as _,Ne as _t,rn as a,$e as at,Ft as b,Ue as bt,Xt as c,Ze as ct,Zt as d,Ke as dt,zt as et,Kt as f,H as ft,Gt as g,Be as gt,Yt as h,B as ht,on as i,Ye as it,Lt as j,_e as jt,_t as k,Le as kt,$ as l,Xe as lt,Qt as m,V as mt,an as n,pt as nt,Jt as o,Je as ot,$t as p,Oe as pt,dt as q,tn as r,Qe as rt,Q as s,qe as st,nn as t,jt as tt,qt as u,Ge as ut,Ut as v,R as vt,vt as w,Fe as wt,kt as x,He as xt,gt as y,Ve as yt,W as z};
5//# sourceMappingURL=useClientPortalMessaging-DKecosJw.js.map
6//# debugId=f5f5035f-9732-5c00-8a31-b5437ec76908

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.