1try{!function(){var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},t=(new e.Error).stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="c5d7c2cf-8603-4154-9e40-6b0d74cad367",e._sentryDebugIdIdentifier="sentry-dbid-c5d7c2cf-8603-4154-9e40-6b0d74cad367")}()}catch(e){}(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[8953],{5267:(e,t,l)=>{"use strict";l.d(t,{A:()=>B});var n=l(37876),a=l(24973),r=l(40699),i=l(3838),o=l(30054),s=l(79686),c=l(35982),u=l(80722),d=l(89028),m=l(94211),p=l(52336),h=l(20104),g=l(49535),v=l(14232),x=l(51994),A=l(60113),b=l(19566);let j=e=>{let{open:t,title:l,onClose:r,recordsPluralTitleCase:o,fileTypeName:h,downloading:v,onPressDownload:A,isLoading:b,uploadLoadingText:j,onSelect:C,errorMessage:f,showDownloadStep:B,showUploadStep:k,disabled:w,hideHeader:S,children:I}=e,M="Excel"===h,P=o.toLowerCase();return(0,n.jsx)(c.A,{variant:"bottom-sheet",desktopVariant:"modal",title:l,open:t,buttonPosition:"none",onClose:r,modalSize:"large",hideHeader:S,children:(0,n.jsxs)(m.A,{column:!0,spacing:2,children:[B&&(0,n.jsxs)(m.A,{spacing:1,children:[(0,n.jsx)(x.A,{style:y.fixedWidth,children:(0,n.jsx)(g.A,{light:!0,variant:"body",children:"1."})}),(0,n.jsxs)(m.A,{column:!0,spacing:1,align:"flex-start",children:[(0,n.jsxs)(g.A,{variant:"body",children:["First, download our ",h," template and enter your"," ",P,"' data."]}),(0,n.jsxs)(s.A,{color:"brown",light:!0,disabled:v||b||w,startIcon:(0,n.jsx)(d.A,{path:a.Bxv}),onClick:A,children:["Download ",o," ",h," Template"]})]})]}),b?(0,n.jsxs)(m.A,{spacing:1,children:[(0,n.jsx)(p.A,{size:"small"}),(0,n.jsx)(g.A,{variant:"body",children:j})]}):k&&(0,n.jsxs)(m.A,{spacing:1,children:[(0,n.jsx)(x.A,{style:y.fixedWidth,children:(0,n.jsx)(g.A,{light:!0,variant:"body",children:"2."})}),(0,n.jsxs)(m.A,{column:!0,spacing:1,align:"flex-start",children:[(0,n.jsx)(g.A,{variant:"body",children:"Then, upload your completed template."}),(0,n.jsx)(u.A,{fileTypes:M?"excel":"csv",onFilesSelected:C,children:(0,n.jsxs)(s.A,{color:"green",disabled:b||w,startIcon:(0,n.jsx)(d.A,{path:a.sWc}),children:["Upload ",o," ",h]})})]})]}),!!f&&(0,n.jsx)(i.A,{color:"orange",message:f}),I]})})},C=e=>{var t,l,a;let{open:i,onClose:s,importTemplate:c,recordsSingular:u,recordsPluralTitleCase:d,useImportMutation:m,refetchQueries:p,getImportResponse:g,csvImportAttachmentType:x,getQueryVariables:A,onSuccess:C,showDownloadStep:f=!0,showUploadStep:y=!0,disabled:B=!1,hideHeader:k=!1,children:w}=e,S=d.toLowerCase(),[I,M]=(0,v.useState)(!1),P=c[1]&&"format"in c[1]&&c[1].format===b.AV.Excel,{downloading:N,onPressDownload:T}=(0,r.S)(...c),{queueSnackbar:E}=(0,h.xt)(),F=(0,v.useCallback)(()=>{M(!1)},[]),V=(0,v.useCallback)(()=>{s(),F()},[s,F]),[D,{data:z,called:Q,loading:R,reset:O,error:L}]=m({onCompleted:(0,v.useCallback)(e=>{let t=g(e);if(!t)return void E({color:"orange",message:"Import failed, please try again."});let{success:l,imported:n}=t;l&&(n&&n>0?E({message:"Imported ".concat(n," ").concat(n>1?S:u," successfully!")}):E({color:"orange",message:"No ".concat(S," imported.")}),V(),null==C||C())},[g,E,V,C,S,u]),refetchQueries:p}),W=(0,v.useCallback)(async e=>{await D({variables:{input:A(e)}})},[A,D]),{fileReferences:_,cancelUploads:U,onFilesSelected:Z}=(0,o.d)({attachmentType:x,onUploadComplete:e=>{W(e.attachmentId)}}),H=_.find(e=>e.error),G=null==H?void 0:H.error,X=(0,v.useCallback)(()=>{V(),O(),U()},[V,O,U]),Y=(0,v.useCallback)(e=>{M(!0),O(),Z({files:e})},[Z,O]),$=g(z),q="Something went wrong while importing your ".concat(S,". Please try again, and contact support if this continues."),K=null!=(l=null==$||null==(t=$.error)?void 0:t.message)?l:$&&!$.success?q:void 0,J=null!=(a=null!=G?G:K)?a:L?q:void 0;(0,v.useEffect)(()=>{J&&F()},[J,F]);let ee=P?"Excel":"CSV";return(0,n.jsx)(j,{title:"Import ".concat(d),open:i,onClose:X,recordsPluralTitleCase:d,fileTypeName:ee,downloading:N,onPressDownload:T,isLoading:I&&!G&&(!Q||R),uploadLoadingText:R||Q?"Processing ".concat(ee," file"):"Uploading ".concat(ee," file"),onSelect:Y,errorMessage:J,showDownloadStep:f,showUploadStep:y,disabled:B,hideHeader:k,children:w})},f=e=>{let{open:t,onClose:l,importTemplate:a,recordsPluralTitleCase:i,onLocalFilesSelected:o,showDownloadStep:s=!0,showUploadStep:c=!0,disabled:u=!1,hideHeader:d=!1,children:m}=e,[p,h]=(0,v.useState)(!1),[g,x]=(0,v.useState)(null),A=a[1]&&"format"in a[1]&&a[1].format===b.AV.Excel,{downloading:C,onPressDownload:f}=(0,r.S)(...a),y=(0,v.useCallback)(()=>{h(!1),x(null)},[]),B=(0,v.useCallback)(()=>{l(),y()},[l,y]),k=(0,v.useCallback)(async e=>{if(e.length){x(null),h(!0);try{await o(e)}catch(e){x((e=>e instanceof Error&&e.message?e.message:"Import failed, please try again.")(e))}finally{h(!1)}}},[o]),w=A?"Excel":"CSV";return(0,n.jsx)(j,{title:"Import ".concat(i),open:t,onClose:B,recordsPluralTitleCase:i,fileTypeName:w,downloading:C,onPressDownload:f,isLoading:p,uploadLoadingText:"Processing ".concat(w," file"),onSelect:e=>{k(e)},errorMessage:g,showDownloadStep:s,showUploadStep:c,disabled:u,hideHeader:d,children:m})},y=A.A.create({fixedWidth:{width:24}}),B=e=>"local"===e.mode?(0,n.jsx)(f,{...e}):(0,n.jsx)(C,{...e})},20483:(e,t,l)=>{"use strict";l.d(t,{A:()=>p});var n=l(37876),a=l(6448),r=l(72637),i=l(14811),o=l(94211),s=l(28304),c=l(2506),u=l(49535),d=l(14232),m=l(45495);let p=e=>{var t;let{id:l,filterBarID:p,options:h,searchable:g,searchPlaceholder:v,emptyLabel:x="No options available"}=e,{filterBarID:A}=(0,d.useContext)(m.Hi),[b,j]=(0,m.UO)({filterBarID:null!=p?p:A,id:l}),[C,f]=(0,d.useState)(""),y=new Set(null!=(t=b.value)?t:[]),B=(0,d.useMemo)(()=>{let e=C.trim().toLowerCase();return e?h.filter(t=>t.label.toLowerCase().includes(e)):h},[h,C]);return(0,n.jsxs)(s.A,{gutter:"responsive",column:!0,flex:1,spacing:1.5,children:[!!g&&(0,n.jsx)(o.A,{children:(0,n.jsx)(c.A,{fullWidth:!0,size:"medium",placeholder:null!=v?v:"Search",initialRefinement:C,refine:f})}),(0,n.jsx)(o.A,{column:!0,align:"stretch",children:0===B.length?(0,n.jsx)(u.A,{variant:"small",light:!0,children:x}):B.map(e=>(0,n.jsx)(i.A,{checked:y.has(e.value),onChange:(t,l)=>((e,t)=>{let l=new Set(y);t?l.add(e):l.delete(e);let n=Array.from(l);j({active:n.length>0,value:n.length>0?n:null})})(e.value,!!l),control:(0,n.jsx)(r.A,{}),label:e.subLabel?(0,n.jsx)(a.A,{spacing:0,label:e.subLabel,labelPosition:"bottom",labelProps:{variant:"mini"},children:e.label}):e.label},e.value))})]})}},24496:(e,t,l)=>
1{(window.__NEXT_P=window.__NEXT_P||[]).push(["/app/settings/contacts",function(){return l(38967)}])},38967:(e,t,l)=>{"use strict";l.r(t),l.d(t,{__N_SSP:()=>ti,default:()=>to});var n=l(37876),a=l(82077),r=l(28084),i=l(51104),o=l(56264),s=l(31231),c=l(94211),u=l(66618),d=l(98257),m=l(5267),p=l(55126),h=l(14232),g=l(19566),v=l(35982),x=l(47497),A=l(28304),b=l(51068),j=l(63599),C=l(60773),f=l(60338),y=l(57133),B=l(37507),k=l(17507);let w=()=>(0,n.jsx)(x.A,{first:!0,gutter:"none",children:(0,n.jsx)(A.A,{gutter:"responsive",column:!0,children:(0,n.jsx)(B.A,{count:2,renderSkeleton:()=>(0,n.jsxs)(c.A,{column:!0,spacing:.5,children:[(0,n.jsx)(k.A,{height:16,width:64}),(0,n.jsx)(k.A,{height:20,width:"60%"})]})})})});var S=l(1423),I=l(60471);let M=f.A.map(e=>{switch(e){case y.E.Customer:return{isCustomer:!0,isVendor:!1,label:"Customer"};case y.E.Vendor:return{isCustomer:!1,isVendor:!0,label:"Vendor"};case"both":return{isCustomer:!0,isVendor:!0,label:"Customer & Vendor"}}}),P=e=>{var t,l,a;let{contactId:r,dialogOpen:i,setDialogOpen:o,subContactIdx:s,selectType:c,onEditRefetchQueries:u}=e,d=(0,h.useCallback)(()=>o(!1),[o]),{form:m}=(0,S.Pz)({contactId:r,dialogOpen:i,editingMode:"edit",onClose:d,onEdit:()=>{},onEditRefetchQueries:u,selectType:c,subContactIdx:s}),{formState:p,editFormInitialized:g}=m,f=null!=(l=null==(t=M.find(e=>!!p.isCustomer===e.isCustomer&&!!p.isVendor===e.isVendor))?void 0:t.label)?l:"",y=p.name||I.A.getContactStringByContactType(c);return(0,n.jsx)(v.A,{variant:"bottom-sheet",desktopVariant:"drawer",stickyHeader:!0,gutter:"none",buttonPosition:"top",open:i,onClose:d,navigationStyle:"close",title:y,highlightedRowId:r,children:g?(0,n.jsx)(x.A,{first:!0,gutter:"none",children:(0,n.jsx)(A.A,{gutter:"responsive",column:!0,children:(0,n.jsxs)(j.A,{children:[(0,n.jsx)(b.A,{label:"Name",children:(0,n.jsx)(C.A,{value:null!=(a=p.name)?a:""})}),(0,n.jsx)(b.A,{label:"Type",children:(0,n.jsx)(C.A,{value:f})})]})})}):(0,n.jsx)(w,{})})};var N=l(17909),T=l(79686),E=l(93554),F=l(15066),V=l(13677),D=l(49535);let z=e=>{let{onClick:t}=e;return(0,n.jsxs)(E.A,{bgColor:F.Ay.brown[5],justify:"space-between",radius:"md",padding:0,flex:1,children:[(0,n.jsxs)(V.A,{column:!0,gutter:"small",top:1,bottom:1,justify:"space-between",align:"flex-start",spacing:2,flex:1,children:[(0,n.jsxs)(c.A,{column:!0,spacing:.5,children:[(0,n.jsx)(D.A,{variant:"body",bold:!0,children:"Start from Scratch"}),(0,n.jsx)(D.A,{variant:"small",light:!0,children:"Add your contacts one-by-one to work with them through Ambrook"})]}),(0,n.jsx)(T.A,{size:"small",variant:"contained",color:"green",fullWidth:!1,onClick:t,children:"Add Customer or Vendor"})]}),(0,n.jsx)(V.A,{align:"flex-end",top:4,bottom:2,right:"medium",column:!0,children:(0,n.jsx)(s.A,{src:"/img/graphics/contacts-portrait.png",alt:"A stylized contacts illustration",width:196,height:148})})]})};var Q=l(24973),R=l(73797),O=l(89028),L=l(35752),W=l(55361),_=l(99126),U=l(67407),Z=l(77269),H=l(45495),G=l(52244),X=l(29765),Y=l(66227),$=l(2350),q=l(49540),K=l(1806);let J=e=>{let{chips:t,onReset:l}=e,a=t.length>0,{commitFilters:r,filterBarID:i}=(0,h.useContext)(H.Hi),[,o]=(0,H.UO)({filterBarID:i,id:"netBalance"}),[,s]=(0,H.UO)({filterBarID:i,id:"apBalance"}),[,u]=(0,H.UO)({filterBarID:i,id:"arBalance"}),[,d]=(0,H.UO)({filterBarID:i,id:"is1099"}),m=(0,K.lZ)(q.A.activePanel(i)),p=(0,K.lZ)(q.A.popoverOpen(i)),g=(0,h.useCallback)(e=>{m(e),p(!0)},[m,p]),v=(0,h.useCallback)(e=>{switch(e){case"netBalance":o({active:!1,value:null});break;case"apBalance":s({active:!1,value:null});break;case"arBalance":u({active:!1,value:null});break;case"is1099":d({active:!1,value:null});break;default:(0,X.lg)(e)}r()},[r,s,u,d,o]);return a?(0,n.jsxs)(c.A,{align:"center",spacing:[.75,1],children:[t.map(e=>(0,n.jsxs)(c.A,{shrink:0,children:[(0,n.jsx)($.A,{title:"Edit filter",children:(0,n.jsx)(Y.A,{color:"brown",size:"small",label:e.label,onClick:()=>g(e.type),roundedCorners:"left"})}),(0,n.jsx)($.A,{title:"Remove filter",children:(0,n.jsx)(Y.A,{color:"brown",size:"small",endIcon:Q.hyP,onClick:()=>v(e.type),roundedCorners:"right"})})]},e.type)),(0,n.jsx)(V.A,{shrink:0,gutter:"none",right:"small",children:(0,n.jsx)(T.A,{onClick:l,color:"brown",light:!0,variant:"text",children:"Reset"})})]}):null};var ee=l(40699),et=l(10215),el=l(2506),en=l(39973),ea=l(22202),er=l(16172),ei=l(20483),eo=l(86389);
1let es="contacts-manager-filters",ec=["netBalance","apBalance","arBalance","is1099"],eu={apBalance:"AP Balance",arBalance:"AR Balance",is1099:"1099",netBalance:"Net Balance"},ed="is1099",em="not1099";var ep=function(e){return e.All="all",e.Vendors="vendors",e.Customers="customers",e}({});let eh={apBalance:null,arBalance:null,is1099:[],netBalance:null},eg=(e,t)=>!t||(null!==t.exactAmount?e===t.exactAmount:(null===t.atLeast||!(e<t.atLeast))&&(null===t.noMoreThan||!(e>t.noMoreThan))),ev=[{label:"1099 eligible",value:ed},{label:"Not 1099 eligible",value:em}],ex=e=>{let{filterBarID:t,committedFilterChips:l,onReset:a}=e,r=(0,K.vc)(H.IY.containerFilters(t)),i=(0,h.useMemo)(()=>{var e,t,l,a;return[{active:!!(null==(e=r.get("netBalance"))?void 0:e.active),icon:(0,n.jsx)(O.A,{path:Q.NfK}),id:"netBalance",label:"Net Balance"},{active:!!(null==(t=r.get("apBalance"))?void 0:t.active),icon:(0,n.jsx)(O.A,{path:Q.iUK}),id:"apBalance",label:"AP Balance"},{active:!!(null==(l=r.get("arBalance"))?void 0:l.active),icon:(0,n.jsx)(O.A,{path:Q.iUK}),id:"arBalance",label:"AR Balance"},{active:!!(null==(a=r.get("is1099"))?void 0:a.active),icon:(0,n.jsx)(O.A,{path:Q.Iik}),id:"is1099",label:"1099"}]},[r]),o=(0,h.useMemo)(()=>[(0,n.jsx)(er.A,{id:"netBalance",filterBarID:t,hideDirection:!0},"netBalance"),(0,n.jsx)(er.A,{id:"apBalance",filterBarID:t,hideDirection:!0},"apBalance"),(0,n.jsx)(er.A,{id:"arBalance",filterBarID:t,hideDirection:!0},"arBalance"),(0,n.jsx)(ei.A,{id:"is1099",filterBarID:t,options:ev},"is1099")],[t]);return(0,n.jsx)(eo.A,{activeFilters:l,filterBarID:t,id:t,onCustomReset:a,panels:i,children:o})};var eA=l(46503),eb=l(71763),ej=l(49772),eC=l(26705);let ef={apBalanceMax:null,apBalanceMin:null,arBalanceMax:null,arBalanceMin:null,is1099:null,netBalanceMax:null,netBalanceMin:null},ey="eligible",eB="not-eligible",ek=e=>{var t,l,n,a;return e?{max:null!=(l=null!=(t=e.exactAmount)?t:e.noMoreThan)?l:null,min:null!=(a=null!=(n=e.exactAmount)?n:e.atLeast)?a:null}:{max:null,min:null}},ew=e=>null===e?null:String((0,eC.s7)(e)),eS=e=>{if(null==e||""===e)return null;let t=parseFloat(e);return Number.isFinite(t)?(0,eC.ob)(t):null},eI=(e,t)=>null===e&&null===t?null:null!==e&&null!==t&&e===t?{atLeast:null,direction:a.Ztr.Any,exactAmount:e,noMoreThan:null}:{atLeast:e,direction:a.Ztr.Any,exactAmount:null,noMoreThan:t},eM=e=>{let t=ek(e.netBalance),l=ek(e.apBalance),n=ek(e.arBalance);return{apBalanceMax:ew(l.max),apBalanceMin:ew(l.min),arBalanceMax:ew(n.max),arBalanceMin:ew(n.min),is1099:(e=>0===e.length||2===e.length?null:e.includes(ed)?ey:eB)(e.is1099),netBalanceMax:ew(t.max),netBalanceMin:ew(t.min)}};eM(eh);var eP=l(23764);let eN=(e,t)=>{let l=e.get(t);return(null==l?void 0:l.active)&&l.value?l.value:null},eT=e=>{let t={apBalance:e.apBalance,arBalance:e.arBalance,netBalance:e.netBalance};return ec.flatMap(l=>{if("is1099"===l)return e.is1099.length>0?[{label:eF(e.is1099),type:l}]:[];let n=t[l];return n?[{label:eE(l,n),type:l}]:[]})},eE=(e,t)=>{var l,n,r,i;let o=null!=(n=null!=(l=t.exactAmount)?l:t.atLeast)?n:void 0,s=null!=(i=null!=(r=t.exactAmount)?r:t.noMoreThan)?i:void 0,c=(0,ej.e)(a.Ztr.Any,null!=o?o:void 0,null!=s?s:void 0);return"".concat(eu[e],": ").concat(c)},eF=e=>2===e.length?"".concat(eu.is1099,": All"):e.includes(ed)?"".concat(eu.is1099,": Eligible"):"".concat(eu.is1099,": Not eligible"),eV=(e,t)=>{var l,n,a,r,i,o;return[null==e?void 0:e.name,null==e?void 0:e.email,null==e||null==(l=e.phoneNumber)?void 0:l.replace("-",""),null==e||null==(n=e.address)?void 0:n.streetAddress,null==e||null==(a=e.address)?void 0:a.suiteOther,null==e||null==(r=e.address)?void 0:r.city,null==e||null==(i=e.address)?void 0:i.state,null==e||null==(o=e.address)?void 0:o.zip].some(e=>null==e?void 0:e.toLowerCase().includes(t))},eD=e=>{let{vm:t}=e,{onPressDownloadExcel:l,onPressDownloadCsv:a}=(0,ee.S)(g.ZV.ContactsTable);return(0,n.jsxs)(c.A,{flex:[0,1],spacing:[1,2],direction:["column","row"],children:[(0,n.jsx)(c.A,{children:(0,n.jsxs)(ea.A,{value:t.contactTypeFilter,onChange:e=>t.updateFilter(t.searchFilter,e),borderless:!0,gutterProps:{gutter:"none"},children:[(0,n.jsx)(en.A,{label:"All",value:ep.All}),(0,n.jsx)(en.A,{label:"Customers",value:ep.Customers}),(0,n.jsx)(en.A,{label:"Vendors",value:ep.Vendors})]})}),(0,n.jsxs)(c.A,{align:"center",spacing:[.75,1],flex:[0,1],children:[(0,n.jsx)(ex,{committedFilterChips:t.committedFilterChips,filterBarID:t.filterBarID,onReset:t.resetPopoverFilters}),(0,n.jsx)(el.A,{placeholder:"Search",size:"medium",fullWidth:!0,autoFocus:!0,initialRefinement:t.searchFilter,refine:e=>t.updateFilter(e,t.contactTypeFilter)},"contacts-search"),(0,n.jsx)(u.A,{children:(0,n.jsxs)(et.Ay,{MenuIcon:()=>(0,n.jsx)(O.A,{path:Q.Bxv}),tooltip:"Export contacts",children:[(0,n.jsx)(L.A,{icon:(0,n.jsx)(O.A,{path:Q.SZe,color:"brown"}),title:"Comma Separated Values (.csv)",onClick:a},"csv"),(0,n.jsx)(L.A,{icon:(0,n.jsx)(O.A,{path:Q.YUH,color:"brown"}),title:"Excel (.xlsx)",onClick:l},"excel")]})})]})]})},ez=e=>{let{vm:t}=e;return(0,n.jsx)(H.Ay,{id:t.filterBarID,refine:t.commitPopoverFilters,syncURL:"web"===G.A.OS,children:(0,n.jsxs)(c.A,{column:!0,flex:1,spacing:+(t.committedFilterChips.length>0),children:[(0,n.jsx)(eD,{vm:t}),t.committedFilterChips.length>0&&(0,n.jsx)(A.A,{gutter:"none",children:(0,n.jsx)(Z.A,{maskGradient:!0,remeasureDep:t.committedFilterChips,children:(0,n.jsx)(J,{chips:t.committedFilterChips,onReset:t.resetPopoverFilters})})})]})})};var eQ=l(64094);let eR=e=>{let{vm:t,onAddContactManually:l,onImportFromQuickbooks:r}=e,[i,o]=(0,h.useState)(!1),s=[(0,n.jsx)(L.A,{title:"Enter manually",icon:(0,n.jsx)(O.A,{path:Q.W58}),onClick:l},"manual"),(0,n.jsx)(L.A,{title:"Import XLSX spreadsheet",icon:(0,n.jsx)(O.A,{path:Q.f49}),onClick:()=>o(!0)},"import-csv"),(0,n.jsx)(L.A,{title:"Import from QuickBooks",icon:(0,n.jsx)(U.A,{fontSize:"medium"}),onClick:r},"import-qb")];return(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(W.A,{title:"Contacts",parentHref:"/app/sett
1ings",stickyProps:{withShadow:!1},endActions:(0,n.jsx)(c.A,{align:"center",spacing:1,children:(0,n.jsxs)(R.A,{menuItems:s,startIcon:(0,n.jsx)(O.A,{path:Q.biz}),size:"medium",onClick:l,children:["New",(0,n.jsx)(_.A,{children:" Contact"})]})}),bottom:(0,n.jsx)(ez,{vm:t})}),(0,n.jsx)(m.A,{recordsPluralTitleCase:"Contacts",recordsSingular:"contact",open:i,getQueryVariables:e=>({attachmentId:e}),onClose:()=>o(!1),importTemplate:[g.ZV.ContactImportTemplate,{format:g.AV.Excel}],refetchQueries:[a.czN.Query.GetContacts],csvImportAttachmentType:a.whx.ContactImportCsv,useImportMutation:eQ.V2,getImportResponse:e=>{var t;return null!=(t=null==e?void 0:e.importContactsFromCsv)?t:null}})]})},eO=e=>{let{onAddContactManually:t,onImportFromQuickbooks:l}=e,[r,i]=(0,h.useState)(!1),o=[(0,n.jsx)(L.A,{title:"Enter manually",icon:(0,n.jsx)(O.A,{path:Q.W58,color:"green"}),onClick:t},"manual"),(0,n.jsx)(L.A,{title:"Import spreadsheet",helperText:"Add with XLSX template",icon:(0,n.jsx)(O.A,{path:Q.f49,color:"green"}),onClick:()=>i(!0)},"import-csv"),(0,n.jsx)(L.A,{title:"Import from QuickBooks",icon:(0,n.jsx)(U.A,{fontSize:"medium"}),helperText:"Add contacts from QuickBooks",onClick:l},"import-qb")];return(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(W.A,{title:"Contacts",parentHref:"/app/settings",stickyProps:{withShadow:!1},endActions:(0,n.jsx)(c.A,{align:"center",spacing:1,children:(0,n.jsxs)(R.A,{menuItems:o,startIcon:(0,n.jsx)(O.A,{path:Q.biz}),size:"medium",onClick:t,children:["New",(0,n.jsx)(_.A,{children:" Contact"})]})})}),(0,n.jsx)(m.A,{recordsPluralTitleCase:"Contacts",recordsSingular:"contact",open:r,getQueryVariables:e=>({attachmentId:e}),onClose:()=>i(!1),importTemplate:[g.ZV.ContactImportTemplate,{format:g.AV.Excel}],refetchQueries:[a.czN.Query.GetContacts],csvImportAttachmentType:a.whx.ContactImportCsv,useImportMutation:eQ.V2,getImportResponse:e=>{var t;return null!=(t=null==e?void 0:e.importContactsFromCsv)?t:null}})]})};var eL=l(89042),eW=l(269),e_=l(24887),eU=l(46811),eZ=l(26730),eH=l(50869),eG=l(35306),eX=l(11355),eY=l(78332),e$=l(75965),eq=l(54192),eK=l(80733),eJ=l(46256),e0=l(49664),e1=l(34178),e9=l(27459),e2=l(32653),e5=l(52200),e4=l(23051),e6=l(71470),e7=l(57620);let e3=e=>{let{handleSortClick:t,sortDirection:l,currentSortColumn:r}=e;return(0,n.jsxs)(c.A,{column:!0,children:[(0,n.jsxs)(V.A,{top:1,bottom:1,gutter:"responsive",justify:"space-between",align:"center",flex:1,children:[(0,n.jsx)(e6.A,{onClick:()=>t(a.tvM.Name),children:(0,n.jsxs)(c.A,{align:"center",spacing:.5,shrink:1,children:[(0,n.jsx)(D.A,{variant:"mini",light:!0,medium:!0,overline:!0,children:"Name"}),r===a.tvM.Name&&(0,n.jsx)(e4.A,{fromIcon:Q.Ply,toIcon:Q.svT,swapped:"asc"!==l,size:"small",color:"brown"})]})}),(0,n.jsx)(e6.A,{onClick:()=>t(a.tvM.ContactNetBalance),children:(0,n.jsxs)(c.A,{align:"center",spacing:.5,justify:"flex-end",children:[(0,n.jsx)(D.A,{variant:"mini",light:!0,medium:!0,overline:!0,rightAligned:!0,fullWidth:!0,children:"Net Balance"}),r===a.tvM.ContactNetBalance&&(0,n.jsx)(e4.A,{fromIcon:Q.Ply,toIcon:Q.svT,swapped:"asc"!==l,size:"small",color:"brown"})]})})]}),(0,n.jsx)(e5.A,{})]})},e8=e=>{let t,{data:l,loading:a,handleSortClick:r,sortDirection:i,currentSortColumn:o}=e,s=(0,h.useMemo)(()=>[{cell:e=>(0,n.jsx)(D.A,{variant:"body",fullWidth:!0,children:e.cell.row.original.name}),id:"name"}],[]),[u,d]=(0,h.useState)({}),m=(0,h.useCallback)(e=>{var t;return null!=(t=null==e?void 0:e.subRows)?t:[]},[]),p=(0,e9.N4)({columns:s,data:a?(t=20,Array.from({length:20},()=>({}))):l,getCoreRowModel:(0,e2.HT)(),getExpandedRowModel:(0,e2.D0)(),getSubRows:m,onExpandedChange:d,state:{expanded:u}}).getRowModel().rows,g=(0,h.useCallback)(e=>e.name||e.email||e.phoneNumber||e.address,[]),v=(0,h.useCallback)(e=>{var t,l,r;let{item:i}=e;if(a)return(0,n.jsx)(V.A,{top:.5,bottom:.5,gutter:"responsive",children:(0,n.jsx)(k.A,{show:!0,width:"100%",height:24})});let o=(null!=(l=i.original.arBalance)?l:0)+(null!=(r=i.original.apBalance)?r:0),s=(0,n.jsxs)(V.A,{top:1,bottom:1,gutter:"responsive",justify:"space-between",left:"contact"===i.original.type?void 0:"medium",spacing:.5,children:[(0,n.jsxs)(c.A,{align:"center",spacing:1,flex:1,children:[(0,n.jsx)(eU.A,{isAmbrookPayEligible:i.original.isAmbrookPayEligible,isVendor:"vendor"===i.original.type,avatarProps:{name:i.original.n
1ame,sizePx:24}}),(0,n.jsxs)(c.A,{column:!0,flex:1,children:[(0,n.jsx)(D.A,{variant:"small",medium:"contact"===i.original.type,fullWidth:!0,truncate:!0,children:g(i.original)}),!!i.subRows.length&&(0,n.jsx)(D.A,{variant:"mini",light:!0,truncate:!0,children:null==(t=i.subRows)?void 0:t.map(e=>g(e.original)).join(", ")})]})]}),(0,n.jsx)(D.A,{variant:"small",children:(0,n.jsx)(eX.A,{value:o,isVector:!0,colorPositiveValues:!0,light:0===o||null===o,tabular:!0})})]});return(0,n.jsx)(e6.A,{onClick:()=>{var e;return(null==(e=i.original.rowClickBehavior)?void 0:e.onClick)&&i.original.rowClickBehavior.onClick(i.original)},children:s})},[a,g]);return(0,n.jsx)(e7.A,{data:p,renderItem:v,scrollEnabled:"web"!==G.A.OS,ListHeaderComponent:(0,n.jsx)(e3,{handleSortClick:r,sortDirection:i,currentSortColumn:o}),ItemSeparatorComponent:()=>(0,n.jsx)(e5.A,{})})};class te{static renderText(e,t,l){let{rollup:a=!1,medium:r=!1,light:i=!1,startAdornment:o,tabular:s=!1,copyable:u=!1}=l||{},d=!!e&&/^\d+ (emails|addresses|numbers)$/.test(e),m=(0,n.jsx)(D.A,{variant:"small",medium:r,light:d||i,truncate:!0,tabular:s,children:e||""}),p=u&&e&&!d?(0,n.jsx)(eZ.A,{children:(0,n.jsx)($.A,{title:"Copy ".concat(e),children:(0,n.jsx)(eG.A,{text:e,previewText:e,fullWidth:!0,children:m})})}):m;return(0,n.jsx)(eK.A,{gutterProps:{align:"center",gutter:(null==t?void 0:t.gutter)||"none",justify:null==t?void 0:t.justify},renderCellWithWrapper:a?null==t?void 0:t.renderCellWithWrapper:void 0,children:(0,n.jsxs)(c.A,{spacing:.75,align:"center",children:[o,(0,n.jsx)(c.A,{flex:1,shrink:1,children:p})]})})}static renderBalance(e,t){return(0,n.jsx)(eK.A,{gutterProps:{align:"center",gutter:(null==t?void 0:t.gutter)||"none",justify:"flex-end"},children:(0,n.jsx)(D.A,{variant:"small",family:"sans",children:(0,n.jsx)(eX.A,{value:e,isVector:!0,colorPositiveValues:!0,light:0===e||null===e})})})}static renderCheckbox(e,t,l,a){return(0,n.jsx)(eK.A,{gutterProps:{align:"center",gutter:(null==t?void 0:t.gutter)||"none",justify:null==t?void 0:t.justify},children:(0,n.jsx)(n.Fragment,{children:e?(0,n.jsx)(eH.A,{disablePointerEvents:!0,tooltip:l,children:(0,n.jsx)(O.A,{path:a,size:"small",color:"green"})}):null})})}}let tt=e=>{let{filteredContacts:t,loading:l,orgDefaultNetTermsDays:r,onEditContact:i}=e,[o,s]=(0,h.useState)("desc"),[u,d]=(0,h.useState)(a.tvM.Name),m=(0,h.useCallback)(e=>{e===u?s(e=>"desc"===e?"asc":"desc"):(d(e),s("desc"))},[u]),p=(0,h.useMemo)(()=>{let e=[{cellSpec:{basis:18,widthForPrinting:18},customizationSpec:{hidable:!1,sortable:!0},headerSpec:{onSortClick:()=>m(a.tvM.Name),sort:u===a.tvM.Name?o:void 0,sortLabel:u===a.tvM.Name?"Sorted alphabetically ".concat("desc"===o?"descending":"ascending"):void 0,title:"Name"},id:a.tvM.Name,renderCell:(e,t)=>te.renderText(e.name,t,{medium:"contact"===e.type,rollup:!0,startAdornment:(0,n.jsx)(eU.A,{isAmbrookPayEligible:e.isAmbrookPayEligible,isVendor:"vendor"===e.type,avatarProps:{name:e.name}})})},{cellSpec:{basis:8,justify:"flex-end",minWidth:1.5,widthForPrinting:8},customizationSpec:{hidable:!0,sortable:!0},headerSpec:{onSortClick:()=>m(a.tvM.ContactNetBalance),sort:u===a.tvM.ContactNetBalance?o:void 0,sortLabel:u===a.tvM.ContactNetBalance?"Sorted by balance ".concat("desc"===o?"descending":"ascending"):void 0,title:"Net Balance"},id:a.tvM.ContactNetBalance,renderCell:(e,t)=>{var l,a;let r=null!=(l=e.arBalance)?l:0,i=null!=(a=e.apBalance)?a:0,o=r+i;if(void 0===e.contactNetBalance||!e.name)return te.renderBalance(o,t);let s=(0,e1.CM)(r),u=(0,e1.CM)(i),d=r>0?"+".concat(s):s,m=i>0?"+".concat(u):u,p=0===o||null===o;return(0,n.jsx)(eK.A,{gutterProps:{align:"center",gutter:(null==t?void 0:t.gutter)||"none",justify:null==t?void 0:t.justify},children:(0,n.jsx)($.A,{title:["Net Balance = AR - AP","AR = ".concat(d),"AP = ".concat(m)],children:(0,n.jsxs)(c.A,{align:"center",spacing:.5,children:[(0,n.jsx)(eq.Nq,{align:"center",children:(0,n.jsx)(O.A,{path:Q.reH,size:"small",colorOverride:F.Ay.brown[30]})}),(0,n.jsx)(D.A,{variant:"small",family:"sans",medium:!0,children:(0,n.jsx)(eX.A,{value:o,isVector:!0,colorPositiveValues:!0,light:p})})]})})})}},{cellSpec:{basis:8,justify:"flex-end",minWidth:1.5,widthForPrinting:8},customizationSpec:{hidable:!0,sortable:!0},headerSpec:{onSortClick:()=>
1m(a.tvM.ApBalance),sort:u===a.tvM.ApBalance?o:void 0,sortLabel:"Sort by AP balance ".concat("desc"===o?"descending":"ascending"),title:"AP Balance"},id:a.tvM.ApBalance,renderCell:(e,t)=>{var l;return te.renderBalance(null!=(l=e.apBalance)?l:0,t)}},{cellSpec:{basis:8,justify:"flex-end",minWidth:1.5,widthForPrinting:8},customizationSpec:{hidable:!0,sortable:!0},headerSpec:{onSortClick:()=>m(a.tvM.ArBalance),sort:u===a.tvM.ArBalance?o:void 0,sortLabel:"Sort by AR balance ".concat("desc"===o?"descending":"ascending"),title:"AR Balance"},id:a.tvM.ArBalance,renderCell:(e,t)=>{var l;return te.renderBalance(null!=(l=e.arBalance)?l:0,t)}},{cellSpec:{basis:11,widthForPrinting:20},customizationSpec:{hidable:!0,sortable:!1},headerSpec:{title:"Email"},id:a.tvM.Email,renderCell:(e,t)=>te.renderText(e.email,t,{copyable:!0})},{cellSpec:{basis:5,maxWidth:12,widthForPrinting:10},customizationSpec:{hidable:!0,sortable:!1},headerSpec:{title:"Phone"},id:a.tvM.PhoneNumbers,renderCell:(e,t)=>te.renderText(e.phoneNumber,t,{copyable:!0,tabular:!0})},{cellSpec:{basis:16,widthForPrinting:30},customizationSpec:{hidable:!0,sortable:!1},headerSpec:{title:"Address"},id:a.tvM.Addresses,renderCell:(e,t)=>te.renderText(e.address,t,{copyable:!0})},{cellSpec:{basis:6,justify:"flex-end",widthForPrinting:15},customizationSpec:{hidable:!0,sortable:!1},headerSpec:{title:"Net Terms"},id:a.tvM.NetTerms,renderCell:(e,t)=>{var l,n;let a=!0===e.isCustomer,i=!0===e.hasExplicitNetTerms,o=a&&!i,s=o?eW.A.getNumDays(null!=r?r:e0._M):null!=(n=null==(l=e.netTerms)?void 0:l.toString())?n:"";return te.renderText(s,t,{light:o,tabular:!0})}},{cellSpec:{basis:3.5,justify:"center",minWidth:1.5,widthForPrinting:12},customizationSpec:{hidable:!0,sortable:!0},headerSpec:{sortLabel:"Sort by 1099 status",title:"1099"},id:a.tvM.Is1099,renderCell:(e,t)=>{var l;return te.renderCheckbox(null!=(l=e.is1099)&&l,t,"Tracking payments for 1099",Q.r6E)}},{cellSpec:{basis:4.5,justify:"center",maxWidth:4.5,widthForPrinting:12},customizationSpec:{hidable:!0,sortable:!0},headerSpec:{sortLabel:"Sort by bill pay confirmation",title:"Bill Pay Conf"},id:a.tvM.BillPayConfirmation,renderCell:(e,t)=>{var l;return te.renderCheckbox(null!=(l=e.billPayConfirmation)&&l,t,"Receives bill pay confirmation emails",Q.tjA)}}];return e.push({cellSpec:{basis:3,justify:"flex-end",maxWidth:3,minWidth:3,widthForPrinting:0},customizationSpec:{hidable:!1,sortable:!1},headerSpec:{title:""},id:a.tvM.Actions,renderCell:(e,t)=>(0,n.jsx)(eK.A,{gutterProps:{align:"center",gutter:(null==t?void 0:t.gutter)||"none",justify:null==t?void 0:t.justify},children:(0,n.jsx)(n.Fragment,{children:e.id?(0,n.jsx)(eZ.A,{children:(0,n.jsxs)(et.Ay,{children:[(0,n.jsx)(L.A,{title:"Edit contact",onClick:()=>i(e.id)}),(0,n.jsx)(L.A,{title:"View transactions",href:"/app/transactions?contactIds=".concat(e.id)})]})}):null})})}),e},[m,u,o,r,i]),g=(0,h.useCallback)(e=>{var t,l;if(e.balances)return(null!=(t=e.balances.arOpenBalance)?t:0)-(null!=(l=e.balances.apOpenBalance)?l:0)},[]),v=(0,h.useMemo)(()=>{let e=e=>{var t,l,n,r;switch(u){case a.tvM.ContactNetBalance:return(null!=(t=e.arBalance)?t:0)+(null!=(l=e.apBalance)?l:0);case a.tvM.ArBalance:return null!=(n=e.arBalance)?n:0;case a.tvM.ApBalance:return null!=(r=e.apBalance)?r:0;default:return 0}},l=t.map(e=>{var t,l,n,a,r,o,s,c,u,d,m,p;let{primaryContact:h,additionalContacts:v}=e,x=[h,...null!=v?v:[]],A=(null==v?void 0:v.length)?x.map((t,l)=>{var n,a,r;return{address:(null==t?void 0:t.address)?(0,e_.Aw)(t.address):void 0,email:null!=(n=null==t?void 0:t.email)?n:void 0,id:void 0,name:null!=(a=null==t?void 0:t.name)?a:void 0,netTerms:"",phoneNumber:null!=(r=null==t?void 0:t.phoneNumber)?r:void 0,rowClickBehavior:{onClick:()=>i(e.id,l-1)},subRows:[],type:"subcontact"}}):[],b=x.reduce((e,t)=>((null==t?void 0:t.email)&&e.emails.push(t.email),(null==t?void 0:t.phoneNumber)&&e.phoneNumbers.push(t.phoneNumber),(null==t?void 0:t.address)&&e.addresses.push((0,e_.Aw)(t.address)),e),{addresses:[],emails:[],phoneNumbers:[]}),j=(e,t)=>b[e].length>1?"".concat(b[e].length," ").concat(t):1==b[e].length?b[e][0]:"";return{address:j("addresses","addresses"),apBalance:null!=(o=null==(t=e.balances)?void 0:t.apOpenB
1alance)?o:void 0,arBalance:null!=(s=null==(l=e.balances)?void 0:l.arOpenBalance)?s:void 0,billPayConfirmation:null!=(c=null==(r=e.outboundPaymentNotifications)||null==(a=r.onPaymentSent)||null==(n=a.email)?void 0:n.enabled)?c:void 0,contactNetBalance:g(e),email:j("emails","emails"),hasExplicitNetTerms:null!=e.invoiceDefaultTermsDays,id:e.id,is1099:null!=(u=e.is1099)?u:void 0,isAmbrookPayEligible:null!=(d=e.isAmbrookPayEligible)?d:void 0,isCustomer:null!=(m=e.isCustomer)?m:void 0,isVendor:null!=(p=e.isVendor)?p:void 0,name:e.name,netTerms:eW.A.getNumDays(e.invoiceDefaultTermsDays),phoneNumber:j("phoneNumbers","numbers"),rowClickBehavior:{onClick:()=>i(e.id)},subRows:A,type:"contact"}});return u===a.tvM.Name?l.sort((e,t)=>{var l,n,a,r,i,s;return"desc"===o?null!=(r=null==(l=e.name)?void 0:l.localeCompare(null!=(a=t.name)?a:""))?r:0:null!=(s=null==(n=t.name)?void 0:n.localeCompare(null!=(i=e.name)?i:""))?s:0}):u===a.tvM.ContactNetBalance||u===a.tvM.ArBalance||u===a.tvM.ApBalance?l.sort((t,l)=>{let n=e(t),a=e(l)-n;return"desc"===o?a:-a}):l},[t,i,g,u,o]),x=(0,h.useCallback)(e=>{var t;return null!=(t=null==e?void 0:e.subRows)?t:[]},[]),A=(0,h.useCallback)(e=>null==e?void 0:e.rowClickBehavior,[]),b=(0,h.useMemo)(()=>({height:3}),[]),j=(0,eY.A)(),C=(0,h.useMemo)(()=>({title:"Contacts"}),[]);return j?(0,n.jsx)(e8,{data:v,loading:l,handleSortClick:m,sortDirection:o,currentSortColumn:u}):(0,n.jsx)(e$.Ay,{tableId:eJ.Dk,columns:p,data:v,loading:l,extractSubRows:x,getRowClickBehavior:A,styleSpec:b,enableRowExpansion:!0,defaultRowExpanded:!1,printableDocumentProps:C})},tl=e=>{let{contactType:t,deepLinkedContactId:l}=e,v=(e=>{var t,l,n;let a=(0,eb.A)(),r=(0,eP.TE)({variables:{includeBalances:!0,input:{includeBalances:!0},orgId:a}}),i=null==(t=r.data)?void 0:t.organization,o=(0,h.useMemo)(()=>{var e,t;return null!=(t=null==i||null==(e=i.organizationContactsV2)?void 0:e.contacts)?t:[]},[i]),s=null!=(n=null==i||null==(l=i.invoiceSettings)?void 0:l.invoiceDefaultTermsDays)?n:null,[c,u]=(0,h.useState)(""),d="vendors"==e?ep.Vendors:"customers"==e?ep.Customers:ep.All,[m,p]=(0,h.useState)(d),[g,v]=(0,eA.a)(ef,{behavior:"replace",skip:"web"!==G.A.OS}),x=(0,h.useMemo)(()=>(e=>({apBalance:eI(eS(e.apBalanceMin),eS(e.apBalanceMax)),arBalance:eI(eS(e.arBalanceMin),eS(e.arBalanceMax)),is1099:(e=>e===ey?[ed]:e===eB?[em]:[])(e.is1099),netBalance:eI(eS(e.netBalanceMin),eS(e.netBalanceMax))}))(null!=g?g:{}),[g]),[A,b]=(0,h.useState)(x),[j,C]=(0,h.useState)(()=>eT(x)),f=(0,K.lZ)(H.IY.filter("".concat(es,"/netBalance"))),y=(0,K.lZ)(H.IY.filter("".concat(es,"/apBalance"))),B=(0,K.lZ)(H.IY.filter("".concat(es,"/arBalance"))),k=(0,K.lZ)(H.IY.filter("".concat(es,"/is1099"))),w=(0,H.Oz)(es),[S,I]=(0,h.useState)(!1);(0,h.useEffect)(()=>{if(S||!(e=>null!==e.netBalance||null!==e.apBalance||null!==e.arBalance||e.is1099.length>0)(x))return void I(!0);x.netBalance&&f({active:!0,value:x.netBalance}),x.apBalance&&y({active:!0,value:x.apBalance}),x.arBalance&&B({active:!0,value:x.arBalance}),x.is1099.length>0&&k({active:!0,value:x.is1099}),b(x),C(eT(x)),I(!0)},[S,x,y,B,k,f]);let M=(0,h.useCallback)(e=>{if(!e)return;let t={apBalance:eN(e,"apBalance"),arBalance:eN(e,"arBalance"),is1099:(e=>{let t=e.get("is1099");return(null==t?void 0:t.active)&&t.value?t.value:[]})(e),netBalance:eN(e,"netBalance")};b(t),C(eT(t)),"web"===G.A.OS&&v(eM(t))},[v]),P=(0,h.useCallback)(()=>{w(),b(eh),C([]),"web"===G.A.OS&&v(null)},[w,v]),N=(0,h.useMemo)(()=>o.filter(e=>((e,t)=>{var l,n,a;let r=t.trim().toLowerCase();return 0===r.length||e.name.toLowerCase().includes(r)||eV(null!=(n=e.primaryContact)?n:null,r)||null!=(a=null==(l=e.additionalContacts)?void 0:l.some(e=>eV(e,r)))&&a})(e,c)&&((e,t)=>{var l,n,a,r;if(!((e,t)=>{switch(t){case"all":return!0;case"vendors":return!!e.isVendor;case"customers":return!!e.isCustomer;default:return(0,X.lg)(t),!0}})(e,t.contactType)||!((e,t)=>0===t.length||2===t.length||(t.includes(ed)?!!e:!e))(e.is1099,t.is1099))return!1;let i=null!=(a=null==(l=e.balances)?void 0:l.arOpenBalance)?a:0,o=null!=(r=null==(n=e.balances)?void 0:n.apOpenBalance)?r:0,s=Math.abs(o);return eg(i-o,t.netBalance)&&eg(s,t.apBalance)&&eg(i,t.arBalance)})(e,{...A,contactType:m})),[o,c,m,A]);return(0,h.useMemo)(()=>({commitPopoverFilters:M,committedFilterChips:j,committedPopoverFilters:A,contactTypeFilter:m,contacts:o,filterBarID:es,filteredContacts:N,loadingContacts:r.loading,orgDefaultNetTermsDays:s,orgId:a,resetPopoverFilters:P,searchFilter:c,updateFilter:(e,t)=>{u(e),p(t)}}),[M,j,A,m,o,N,r.loading,s,a,P,c])})(t),x=r.A.useIsContactDetailsDialogEnabled(),[A,b]=(0,h.useState)(!!l),[j,C]=(0,h.useState)(null!=l?l:void 0),[f,y]=(0,h.useState)(),B=(0,p.A)(),k=(0,h.useCallback)(()=>{let{contactId:e,...t}=B.query;void 0!==e&&B.replace({pathname:B.pathname,query:t},void 0,{shallow:!0})},[B]),[w,S]=(0,h.useState)(!1),[I,M]=(0,h.useState)(""),[T,E]=(0,h.useState)(!1);return(0,n.jsxs)(c.A,{column:!0,flex:1,children:[(0,n.jsx)(d.A,{children:(0,n.jsx)(i.T,{open:T,setOpen:E})}),v.loadingContacts||0!==v.contacts.length?(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(eR,{vm:v,onAddContactManually:()=>{C(void 0),b(!0),M(v.searchFilter)},onImportFromQuickbooks:()=>{E(!0)}}),(0,n.jsx)(tt,{filteredContacts:v.filteredContacts,loading:v.loadingContacts,orgDefaultNetTermsDays:v.orgDefaultNetTermsDays,onEditContact:(e,t)=>
1{C(e),y(t),b(!0)}})]}):(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(eO,{onAddContactManually:()=>{C(void 0),b(!0),M(v.searchFilter)},onImportFromQuickbooks:()=>{E(!0)}}),(0,n.jsx)(o.A,{heading:"Manage customers and vendors",description:"Organize contact and payment information for customers and vendors that link to invoices, bills, and transactions.",cta:(0,n.jsxs)(c.A,{column:!0,spacing:1.5,nativeStyle:{width:"100%"},children:[(0,n.jsx)(c.A,{spacing:1.5,children:(0,n.jsx)(z,{onClick:()=>{C(void 0),b(!0),M(v.searchFilter)}})}),(0,n.jsxs)(c.A,{spacing:1.5,children:[(0,n.jsx)(u.A,{children:(0,n.jsx)(eL._,{title:"Import from XLSX",description:"Bring in your contacts through a spreadsheet or CSV file",cta:"Import from XLSX",onClick:()=>{S(!0)},image:(0,n.jsx)(s.A,{src:"/img/graphics/ledger-grain.png",alt:"Import Category Data",width:103,height:73})})}),(0,n.jsx)(eL._,{title:"Import from QuickBooks",description:"Connect your QuickBooks account to import your contacts",cta:"Import from QuickBooks",onClick:()=>{E(!0)},image:(0,n.jsx)(s.A,{src:"/img/graphics/accounting-software-illustration.png",alt:"Import Category Data",width:103,height:73})})]})]})})]}),(0,n.jsx)(m.A,{recordsPluralTitleCase:"Contacts",recordsSingular:"contact",open:w,getQueryVariables:e=>({attachmentId:e}),onClose:()=>S(!1),importTemplate:[g.ZV.ContactImportTemplate,{format:g.AV.Excel}],refetchQueries:[a.czN.Query.GetContacts],csvImportAttachmentType:a.whx.ContactImportCsv,useImportMutation:eQ.V2,getImportResponse:e=>{var t;return null!=(t=null==e?void 0:e.importContactsFromCsv)?t:null}}),x&&j?(0,n.jsx)(P,{contactId:j,subContactIdx:f,dialogOpen:A,setDialogOpen:e=>{b(e),y(void 0),e||(C(void 0),k())},onEditRefetchQueries:[a.czN.Query.GetContacts]},j):(0,n.jsx)(N.A,{contactId:j,subContactIdx:f,editingMode:j?"edit":"create",dialogOpen:A,setDialogOpen:e=>{b(e),y(void 0),e||k()},onCreateRefetchQueries:[a.czN.Query.GetContacts],onEditRefetchQueries:[a.czN.Query.GetContacts],prefilledContactName:I})]})};var tn=l(2834),ta=l(90181),tr=l(62867),ti=!0;let to=e=>{let{contactType:t,contactId:l}=e;return(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(tr.bV,{title:"Contacts",description:"Manage your customers and vendors.",openGraph:{description:"Manage your customers and vendors."},noindex:!0}),(0,n.jsx)(ta.A,{active:"account",children:(0,n.jsx)(tn.A,{size:"stretch",children:(0,n.jsx)(tl,{contactType:t,deepLinkedContactId:l})})})]})}},51104:(e,t,l)=>{"use strict";l.d(t,{T:()=>I});var n=l(37876),a=l(82077),r=l(20104),i=l(28842),o=l(71763),s=l(14232),c=l(96427),u=l(27630),d=l(64177),m=l(27250);function p(){let e=(0,c._)(["\n mutation AuthenticateAndImportQuickbooksOnline($input: AuthenticateAndImportQuickbooksOnlineInput!) {\n authenticateAndImportQuickbooksOnline(input: $input) {\n createdCount\n userErrors {\n message\n code\n }\n }\n}\n "]);return p=function(){return e},e}function h(){let e=(0,c._)(["\n query GetQuickbooksAuthUrl($input: GetQuickbooksAuthUrlInput!) {\n getQuickbooksAuthUrl(input: $input) {\n authUrl\n }\n}\n "]);return h=function(){return e},e}let g={},v=(0,u.J1)(p()),x=(0,u.J1)(h()),A=()=>{var e;let t=(0,o.A)(),l=(0,i.A)(),{queueSnackbar:n}=(0,r.xt)(),{data:a,loading:c}=function(e){let t={...g,...e};return m.IT(x,t)}({variables:{input:{orgId:t}}}),u=null!=(e=null==a?void 0:a.getQuickbooksAuthUrl.authUrl)?e:null,[p,{called:h,loading:A}]=function(e){let t={...g,...void 0};return d.n(v,t)}(),b=(0,s.useCallback)(async e=>{try{return await p({...e,onCompleted:t=>{var a;let r=t.authenticateAndImportQuickbooksOnline;r.userErrors&&r.userErrors.length>0?n({color:"red",message:r.userErrors[0].message}):n({color:"green",cta:"Modify session",message:"Successfully imported contacts",onClick:()=>{l("/app/settings/import/contacts")}}),null==(a=e.onCompleted)||a.call(e,t)},onError:t=>{var l;n({color:"red",message:"Failed to import contacts. Please try again."}),null==(l=e.onError)||l.call(e,t)}})}catch(e){throw n({color:"red",message:"Failed to import contacts. Please try again."}),e}},[p,l,n]);return(0,s.useMemo)(()=>({authUrl:u,authenticateAndImportQuickbooksOnlineCalled:h,authenticateAndImportQuickbooksOnlineLoading:A,authenticateAndImportQuickbooksOnlineMutation:b,getAuthUrlLoading:c}),[u,b,A,h,c])};var b=l(24973),j=l(35982),C=l(89028),f=l(94211),y=l(52336),B=l(49535);let k=e=>{let{showProgressDialog:t}=e;return(0,n.jsx)(j.A,{open:t,variant:"modal",buttonPosition:"none",navigationStyle:"none",disableBackdropClick:!0,disableEscapeKeyClose:!0,disableScroll:!0,
1children:(0,n.jsxs)(f.A,{column:!0,spacing:3,align:"center",children:[(0,n.jsx)(y.A,{size:"large",icon:(0,n.jsx)(C.A,{path:b.QZ1,color:"brown"})}),(0,n.jsx)(B.A,{variant:"body",children:"Importing contacts"})]})})};var w=l(79686),S=l(46503);let I=e=>{let{open:t,setOpen:l}=e,{authUrl:r,getAuthUrlLoading:i}=A(),{authenticateAndImportQuickbooksOnlineMutation:c,authenticateAndImportQuickbooksOnlineLoading:u,authenticateAndImportQuickbooksOnlineCalled:d}=A(),[m,p]=(0,S.Z)("authCode"),[h,g]=(0,S.Z)("realmId"),[v,x]=(0,S.Z)("idempotencyKey"),b=(0,s.useRef)(!1),C=(0,o.A)();return(0,s.useEffect)(()=>{m&&h&&C&&v&&!d&&!b.current&&(b.current=!0,c({awaitRefetchQueries:!0,onCompleted:()=>{p(null),g(null),x(null)},refetchQueries:[a.czN.Query.GetContacts],variables:{input:{authCode:m,idempotencyKey:v,orgId:C,realmId:h}}}))},[v,m,h,C,d,c,p,g,x]),(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(j.A,{variant:"modal",open:t,onClose:()=>l(!1),title:"Connect your QuickBooks account",modalSize:"small",button:(0,n.jsx)(w.A,{href:null!=r?r:"",disabled:!r||i,targetBlank:!0,fullWidth:!0,children:"Connect with QuickBooks Online"}),children:(0,n.jsx)(B.A,{variant:"body",children:"You will be redirected to QuickBooks Online to log in and sync your contacts."})}),(0,n.jsx)(k,{showProgressDialog:u})]})}},64094:(e,t,l)=>{"use strict";l.d(t,{V2:()=>u});var n=l(96427),a=l(27630),r=l(95571),i=l(64177);function o(){let e=(0,n._)(["\n mutation ContactsCsvImport($input: ImportContactsFromCsvInput!) {\n importContactsFromCsv(input: $input) {\n ...StructuredCSVImportResults\n }\n}\n ",""]);return o=function(){return e},e}let s={},c=(0,a.J1)(o(),r.Z7);function u(e){let t={...s,...e};return i.n(c,t)}},89042:(e,t,l)=>{"use strict";l.d(t,{_:()=>u});var n=l(37876),a=l(79686),r=l(93554),i=l(15066),o=l(94211),s=l(13677),c=l(49535);let u=e=>{let{title:t,description:l,cta:u,onClick:d,image:m}=e;return(0,n.jsxs)(r.A,{bgColor:i.Ay.brown[5],justify:"space-between",radius:"md",padding:0,flex:1,children:[(0,n.jsxs)(s.A,{column:!0,align:"flex-start",justify:"space-between",gutter:"small",top:1,bottom:1,spacing:2,children:[(0,n.jsxs)(o.A,{column:!0,spacing:.5,children:[(0,n.jsx)(c.A,{variant:"body",bold:!0,children:t}),(0,n.jsx)(c.A,{variant:"small",light:!0,children:l})]}),(0,n.jsx)(a.A,{size:"small",color:"green",light:!0,transparentColor:!0,fullWidth:!1,onClick:d,children:u})]}),(0,n.jsx)(s.A,{align:"flex-end",top:4,bottom:1,right:"bottom-sheet",shrink:0,children:m})]})}}},e=>{e.O(0,[8992,16,4337,6247,8798,4285,6371,8185,3600,815,3246,6109,9117,7620,8681,9479,4212,1792,9973,551,4485,2260,2762,4241,404,4274,7588,9843,5519,2232,636,6593,8792],()=>e(e.s=24496)),_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.