PageSourceSearch

https://app.swipey.co/static/js/AccountingSetting.058bc6bf.chunk.js

js swipey.co collected 2026-10-01 14:07:11 UTC 30,899 bytes, 1 lines download raw bytes

1"use strict";(self.webpackChunkfrontend=self.webpackChunkfrontend||[]).push([[2869],{72422:function(e,t,n){var r=n(37762),a=n(29439),s=n(67033),o=n(47313),i=n(46417);t.Z=function(e){var t=e.value,n=e.onChange,c=e.compact,l=(0,o.useRef)(null),d=(0,o.useState)(!0),u=(0,a.Z)(d,2),p=u[0],x=u[1];return(0,o.useEffect)((function(){var e=l.current;if(e){var t=new ResizeObserver((function(e){var t,n=(0,r.Z)(e);try{for(n.s();!(t=n.n()).done;){var a=t.value;x(a.contentRect.width>=120)}}catch(s){n.e(s)}finally{n.f()}}));return t.observe(e),function(){return t.disconnect()}}}),[]),(0,i.jsx)("div",{ref:l,children:(0,i.jsx)(s.Z,{type:"text",className:"!rounded-[50px] !text-xs !py-2 !pr-8",placeholder:p?"Search":"",value:t,onChange:n,icon:(0,i.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",strokeWidth:1.5,stroke:"currentColor",className:c?"w-3 h-3 xl:w-3.5 xl:h-3.5 text-color-secondary":"w-3.5 h-3.5 xl:w-4 xl:h-4 text-color-secondary",children:(0,i.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M21 21l-5.197-5.197m0 0A7.5 7.5 0 105.196 5.196a7.5 7.5 0 0010.607 10.607z"})})})})}},63882:function(e,t,n){var r=n(1413),a=(n(47313),n(46417));t.Z=function(e){return(0,a.jsxs)("svg",(0,r.Z)((0,r.Z)({width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round",xmlns:"http://www.w3.org/2000/svg"},e),{},{children:[(0,a.jsx)("path",{d:"M10 18v-7"}),(0,a.jsx)("path",{d:"M11.119 2.205a2 2 0 0 1 1.762 0l7.84 3.846A.5.5 0 0 1 20.5 7h-17a.5.5 0 0 1-.22-.949z"}),(0,a.jsx)("path",{d:"M14 18v-7"}),(0,a.jsx)("path",{d:"M18 18v-7"}),(0,a.jsx)("path",{d:"M3 22h18"}),(0,a.jsx)("path",{d:"M6 18v-7"})]}))}},20665:function(e,t,n){n.r(t),n.d(t,{default:function(){return fe}});var r=n(39010),a=n(47313),s=n(42008),o=n(1450),i=n(92946),c=n(74165),l=n(15861),d=n(29439);var u=a.forwardRef((function(e,t){return a.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",strokeWidth:2,stroke:"currentColor","aria-hidden":"true",ref:t},e),a.createElement("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M17 8l4 4m0 0l-4 4m4-4H3"}))})),p=n(57770),x=n(66632),f=n(67847),m=n(15253),h=n(21911),v=n(46417),g=function(e){var t=e.linked,n=e.loading;return t?(0,v.jsx)("div",{className:"px-2 bg-green-500 bg-opacity-10 rounded-2xl border border-green-500 justify-center items-center flex",children:(0,v.jsx)("div",{className:"text-center text-green-500 text-sm font-semibold font-poppins leading-snug",children:n?"Linking":"Linked"})}):(0,v.jsx)("div",{className:"px-2 bg-blue-600 bg-opacity-10 rounded-3xl border border-blue-600 justify-center items-center flex",children:(0,v.jsx)("div",{className:"text-center whitespace-nowrap text-blue-600 text-sm font-medium font-poppins leading-snug",children:n?"Linking":"Not Linked"})})},b=n(58020),y=function(){var e=(0,a.useState)(!1),t=(0,d.Z)(e,2),n=t[0],r=t[1],s=(0,x.Z)((function(e){return e})),i=s.isConnected,y=s.setIsConnected,j=(0,h.k6)(),w=(0,b.F)(),N=w.platform,k=w.platformName,Z=w.platformLogo,C=function(){var e=(0,l.Z)((0,c.Z)().mark((function e(){return(0,c.Z)().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r(!0),e.prev=1,e.next=4,(0,f.cO)();case 4:y(!1),j.replace(m.x.ACCOUNTING),e.next=11;break;case 8:e.prev=8,e.t0=e.catch(1),(0,o.bW)("Could not disconnect. Please try again.");case 11:r(!1);case 12:case"end":return e.stop()}}),e,null,[[1,8]])})));return function(){return e.apply(this,arguments)}}();return N||j.replace(m.x.ACCOUNTING),(0,v.jsxs)("div",{className:"p-6 bg-white rounded-[14px] border border-zinc-300 flex-col justify-start items-start gap-6 flex",children:[(0,v.jsxs)("div",{className:"self-stretch justify-between items-center inline-flex",children:[(0,v.jsx)("div",{className:"text-secondary text-lg font-semibold font-poppins",children:"Connection"}),(0,v.jsx)("button",{disabled:n,onClick:C,className:"px-4 py-2 rounded-lg border border-red-600 text-red-600 text-sm font-medium font-poppins",children:n?"Loading...":"Disconnect"})]}),(0,v.jsx)("div",{className:"self-stretch border-t border-zinc-100"}),(0,v.jsxs)("div",{className:"self-stretch items-center gap-3 inline-flex",children:[(0,v.jsx)("div",{className:"w-8 h-8 flex items-center justify-center shrink-0",children:(0,v.jsx)(p.x,{width:"32",height:"32",className:"text-primary"})}),(0,v.jsx)(u,{className:"w-5 h-5 text-gray-400 shrink-0"}),Z&&(0,v.jsx)("img",{src:Z,alt:k,className:"w-8 h-8 rounded-full object-contain shrink-0"}),(0,v.jsxs)("div",{className:"text-secondary text-sm font-normal font-poppins",children:["Swipey is successfully connected to"," ",(0,v.jsx)("span",{className:"font-semibold",children:k})]}),(0,v.jsx)(g,{linked:i})]})]})},j=n(19222),w=n(94146),N=n(67302),k=n(41691),Z=n(25773),C=function(e){var t=e.title;return(0,v.jsx)("div",{className:"text-secondary text-base font-semibold font-poppins",children:t})},_=function(e){var t=e.balance,n=e.accountName,r=e.platformName;return(0,v.jsxs)("div",{className:"text-gray-500 text-sm font-normal font-poppins",children:[(0,k.xG)(t),n&&(0,v.jsxs)(v.Fragment,{children:[" \xb7 Mapped to ",(0,v.jsx)("span",{className:"font-semibold text-secondary",children:n})," in ".concat(r)]})]})},S=function(e){var t=e.title,n=e.balance,r=e.selected,s=e.platformName,o=e.onChange,i=(0,a.useState)(!1),u=(0,d.Z)(i,2),p=u[0],x=u[1],f=(0,a.useState)(),m=(0,d.Z)(f,2),h=m[0],b=m[1],y=function(){var e=(0,l.Z)((0,c.Z)().mark((function e(t){return(0,c.Z)().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return x(!0),e.next=3,o(t);case 3:x(!1);case 4:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}();return(0,v.jsxs)("div",{className:"self-stretch justify-between items-center inline-flex w-full",children:[(0,v.jsxs)("div",{className:"flex-col justify-start items-start flex",children:[(0,v.jsx)(C,{title:t}),(0,v.jsx)(_,{balance:n,accountName:h,platformName:s})]}),(0,v.jsxs)("div",{className:"flex items-center gap-3",children:[(0,v.jsx)(Z.Z,{disabled:p,selected:r,onChange:y,onSelectedChange:function(e){return b(null===e||void 0===e?void 0:e.account_name)},accountTypes:[],contentAlign:"end",customTrigger:(0,v.jsx)("button",{type:"button",className:(0,w.Z)("text-gray-400 cursor-pointer",p?"opacity-50":"hover:text-secondary"),children:(0,v.jsx)(j.Z,{className:"w-5 h-5"})})}),(0,v.jsx)(g,{linked:!!r,loading:p})]})]})},O=function(){var e,t,n=(0,x.Z)((function(e){return e})),r=n.setConnectionDetail,a=n.connectionDetail,s=(0,N.Z)((function(e){return e})).companyDetail,i=(0,b.F)().platformName,d=function(){var e=(0,l.Z)((0,c.Z)().mark((function e(t){var n;return(0,c.Z)().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,e.next=3,(0,f.Vt)(t);case 3:null!==(n=e.sent).data.data.platform&&r(n.data.data),e.next=10;break;case 7:e.prev=7,e.t0=e.catch(0),(0,o.bW)("Could not save the mapping. Please try again.");case 10:case"end":return e.stop()}}),e,null,[[0,7]])})));return function(t){return e.apply(this,arguments)}}();return(0,v.jsxs)("div",{className:"p-6 bg-white rounded-[14px] border border-zinc-300 flex-col justify-start items-start gap-4 flex",children:[(0,v.jsxs)("div",{className:"self-stretch flex-col justify-start items-start gap-1 flex",children:[(0,v.jsx)("div",{className:"text-secondary text-lg font-semibold font-poppins",children:"Balance Tracking"}),(0,v.jsxs)("div",{className:"text-gray-500 text-sm font-normal font-poppins",children:["Link each Swipey balance to an account in your ",i," ledger."]})]}),(0,v.jsx)("div",{className:"self-stretch border-t border-zinc-100"}),(0,v.jsx)(S,{title:"Swipey Available Funds",balance:null!==(e=null===s||void 0===s?void 0:s.company.company_balance)&&void 0!==e?e:0,selected:null===a||void 0===a?void 0:a.master_account_id,platformName:i,onChange:function(e){return d({master_account_id:e.id})}}),(0,v.jsx)("div",{className:"self-stretch border-t border-zinc-100"}),(0,v.jsx)(S,{title:"Swipey Card Balance",balance:null!==(t=null===s||void 0===s?void 0:s.company.cards_balance)&&void 0!==t?t:0,selected:null===a||void 0===a?void 0:a.expense_credit_account_id,platformName:i,onChange:function(e){return d({expense_credit_account_id:e.id})}})]})},I=n(41374),A=n(4942),L=n(1413),M=n(45326),z=n(89674);var R=a.forwardRef((function(e,t){return a.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",strokeWidth:2,stroke:"currentColor","aria-hidden":"true",ref:t},e),a.createElement("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M3 10h18M7 15h1m4 0h1m-7 4h12a3 3 0 003-3V8a3 3 0 00-3-3H6a3 3 0 00-3 3v8a3 3 0 003 3z"}))})),E=n(20411),V=n(34764),F=n(63882),T=n(92122),B=n(45987),W=["className"],D=function(e){var t=e.className,n=(0,B.Z)(e,W);return(0,v.jsx)("svg",(0,L.Z)((0,L.Z)({xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"
1currentColor",className:(0,w.Z)(t)},n),{},{children:(0,v.jsx)("path",{d:"M12 0 L14 10 L24 12 L14 14 L12 24 L10 14 L0 12 L10 10 Z"})}))},G=[{className:"w-3.5 h-3.5 -top-1.5 -left-1.5",delay:"0s"},{className:"w-2.5 h-2.5 -top-1 -right-1.5",delay:"0.6s"},{className:"w-2 h-2 -bottom-1.5 left-3",delay:"1.2s"}],P=function(e){var t=e.onClick,n=e.loading,r=e.disabled;return(0,v.jsxs)("div",{className:"relative inline-block group",children:[(0,v.jsx)("button",{type:"button",onClick:t,disabled:n||r,className:(0,w.Z)("px-3 py-1.5 rounded-lg border border-violet-600 text-violet-600 text-sm font-semibold font-poppins disabled:opacity-60",{"animate-alfieGlow":!n&&!r}),children:n?"Suggesting\u2026":"Alfie Suggest"}),!n&&!r&&G.map((function(e){return(0,v.jsx)(D,{"aria-hidden":!0,style:{animationDelay:e.delay},className:(0,w.Z)("absolute text-violet-500 animate-twinkle pointer-events-none",e.className)},e.className)})),(0,v.jsxs)("div",{role:"tooltip",className:"absolute top-full right-0 mt-2 w-[300px] px-4 py-3.5 rounded-[10px] bg-[#241B45] font-poppins z-tooltip pointer-events-none opacity-0 invisible transition-opacity duration-150 group-hover:opacity-100 group-hover:visible",style:{boxShadow:"0px 8px 24px rgba(0, 0, 0, 0.24)"},children:[(0,v.jsx)("span",{className:"absolute -top-1 right-12 w-2.5 h-2.5 rotate-45 bg-[#241B45]"}),(0,v.jsxs)("div",{className:"relative flex items-center gap-2 mb-1",children:[(0,v.jsx)(D,{"aria-hidden":!0,className:"w-3.5 h-3.5 text-violet-300"}),(0,v.jsx)("span",{className:"text-white text-[13px] leading-5 font-semibold",children:"What is Alfie Suggest?"})]}),(0,v.jsxs)("p",{className:"relative text-white text-opacity-90 text-[13px] leading-5 font-normal",children:["Alfie studies your past record and recommends a"," ",(0,v.jsx)("span",{className:"font-bold",children:"contact and ledger"})," for each vendor, you just have to review and save."]})]})]})},H=n(77137),U=n(3070),q=n(22644),K=n(72422),Q=function(e){var t,n=e.selectedId,r=e.options,s=e.placeholder,o=e.emptyText,i=e.onChange,u=e.disabled,p=e.loadingText,x=e.createAction,f=(0,a.useState)(!1),m=(0,d.Z)(f,2),h=m[0],g=m[1],b=(0,a.useState)(""),y=(0,d.Z)(b,2),j=y[0],N=y[1],k=(0,a.useMemo)((function(){var e;return null!==(e=r.find((function(e){return e.id===n})))&&void 0!==e?e:null}),[r,n]),Z=(0,a.useMemo)((function(){var e=r.filter((function(e){return!1!==e.active})),t=j.trim().toLowerCase();return t?e.filter((function(e){return e.name.toLowerCase().includes(t)})):e}),[r,j]),C=null!=p,_=!C&&null!=k&&!1===k.active,S=function(){g(!1),N("")},O=function(){var e=(0,l.Z)((0,c.Z)().mark((function e(){return(0,c.Z)().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,null===x||void 0===x?void 0:x.onCreate();case 2:e.sent&&S();case 4:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}();return(0,v.jsxs)(q.fC,{open:h,onOpenChange:g,children:[(0,v.jsx)(q.xz,{asChild:!0,disabled:u,children:(0,v.jsxs)("button",{type:"button",className:(0,w.Z)("w-full flex items-center justify-between gap-2 px-3 py-2 rounded-lg border border-zinc-300 bg-white text-sm font-poppins text-left",u?"opacity-60 cursor-not-allowed":"hover:border-primary cursor-pointer"),children:[(0,v.jsxs)("span",{className:"flex items-center gap-1.5 min-w-0",children:[_&&(0,v.jsx)(z.Z,{className:"w-4 h-4 text-amber-500 flex-shrink-0","aria-label":"Inactive option"}),(0,v.jsxs)("span",{className:(0,w.Z)("truncate",k&&!C?"text-secondary":"text-gray-400"),children:[null!==(t=null!==p&&void 0!==p?p:null===k||void 0===k?void 0:k.name)&&void 0!==t?t:s,_&&" (inactive)"]})]}),(0,v.jsx)(H.Z,{className:"w-4 h-4 text-gray-400 flex-shrink-0"})]})}),(0,v.jsx)(q.h_,{children:(0,v.jsxs)(q.VY,{sideOffset:4,side:"bottom",align:"start",className:"bg-white p-3 rounded-lg z-popover outline-none max-h-72 flex flex-col overflow-hidden font-poppins",style:{boxShadow:"0px 4px 16px rgba(0, 0, 0, 0.24)",width:"var(--radix-popover-trigger-width)"},children:[(0,v.jsx)("div",{className:"flex-shrink-0",children:(0,v.jsx)(K.Z,{value:j,onChange:function(e){return N(e.target.value)}})}),(0,v.jsxs)("div",{className:"mt-2 flex-1 min-h-0 overflow-y-auto",children:[0===Z.length&&(0,v.jsx)("p",{className:"text-gray-400 text-xs py-3 text-center",children:o}),Z.map((function(e){return(0,v.jsx)("button",{type:"button",onClick:function(){return t=e.id,i(t),void S();var t},className:(0,w.Z)("block w-full text-left text-sm px-2 py-2 rounded truncate hover:bg-gray-100",e.id===n?"text-primary font-medium":"text-secondary"),children:e.name},e.id)}))]}),x&&(0,v.jsx)("div",{className:"mt-1 pt-2 flex-shrink-0 border-t border-zinc-100",children:(0,v.jsxs)("button",{type:"button",onClick:O,disabled:C,className:"w-full flex items-center gap-2 px-2 py-2 rounded text-sm font-semibold text-secondary hover:bg-gray-100 disabled:opacity-60 disabled:cursor-not-allowed",children:[(0,v.jsx)(U.Z,{className:"w-4 h-4 flex-shrink-0"}),(0,v.jsx)("span",{className:"truncate",children:C?p:x.label})]})})]})})]})},Y=n(30617),X=function(e){var t=e.contacts,n=e.accounts,r=[{count:t,label:"contact"},{count:n,label:"ledger"}].filter((function(e){return e.count>0})),s=t+n;return(0,v.jsxs)(v.Fragment,{children:[r.map((function(e,t){return(0,v.jsxs)(a.Fragment,{children:[t>0&&" and ",(0,v.jsxs)("span",{className:"font-bold",children:[e.count," ",1===e.count?e.label:"".concat(e.label,"s")]})]},e.label)}))," ",1===s?"mapping is":"mappings are"," not saved yet."]})},J=function(e){var t=e.isOpen,n=e.contacts,r=e.accounts,a=e.saving,s=e.onDiscard,o=e.onSave;return(0,v.jsx)(Y.Vq,{open:t,children:(0,v.jsxs)(Y.cZ,{className:"w-[calc(100%-40px)] md:w-[440px] p-6 font-poppins",children:[(0,v.jsx)("h4",{className:"text-secondary text-base font-semibold",children:"You have edited your vendor mapping"}),(0,v.jsxs)("p",{className:"mt-2 text-gray-500 text-sm",children:[(0,v.jsx)(X,{contacts:n,accounts:r})," Closing now drops the edits."]}),(0,v.jsxs)("div",{className:"mt-6 flex justify-end gap-3",children:[(0,v.jsx)("button",{type:"button",onClick:s,disabled:a,className:"px-4 py-2 rounded-lg border border-zinc-200 text-secondary text-sm font-medium disabled:opacity-60 disabled:cursor-not-allowed",children:"Discard edits"}),(0,v.jsx)("button",{type:"button",onClick:o,disabled:a,className:"px-4 py-2 rounded-lg bg-secondary text-white text-sm font-medium disabled:opacity-60 disabled:cursor-not-allowed",children:a?"Saving\u2026":"Save edits"})]})]})})},$=function(e){return"".concat(e.counterparty_group_type,":").concat(e.counterparty_group_id)},ee=function(e){var t;return{id:null!==(t=e.accounting_contact_id)&&void 0!==t?t:null,isVerified:!1!==e.accounting_contact_is_verified}},te=function(e){var t;return{id:null!==(t=e.accounting_account_id)&&void 0!==t?t:null,isVerified:!1!==e.accounting_account_is_verified}},ne=function(e,t){return e!==t.id||null!=e&&!t.isVerified},re=function(e,t,n){return ne(t,ee(e))||ne(n,te(e))},ae=function(e,t,n){var r={};return t.forEach((function(t){var a=$(t),s=function(e,t){var n;if(void 0===e)return null!==(n=t.id)&&void 0!==n?n:void 0;var r=null!=t.id&&!t.isVerified;return null===e&&r?t.id:e}(e[a],n(t));void 0!==s&&(r[a]=s)})),r},se=function(e){return"QUEUED"===e||"ONGOING"===e},oe=function(e){var t=e.label,n=e.disabled,r=e.onClick;return(0,v.jsx)("button",{type:"button","aria-label":t,onClick:r,disabled:n,className:"p-1 text-gray-400 hover:text-red-500 disabled:cursor-not-allowed disabled:hover:text-gray-400",children:(0,v.jsx)(M.Z,{className:"w-4 h-4"})})},ie=function(e){var t=e.counterparty,n=e.contacts,r=e.accounts,a=e.contactId,s=e.accountId,o=e.disabled,i=e.isCreating,c=e.onContactChange,l=e.onAccountChange,d=e.onCreateContact;return(0,v.jsxs)("div",{className:"grid grid-cols-3 gap-4 items-center px-4 py-3 border-b border-zinc-100",children:[(0,v.jsxs)("div",{className:"flex items-center gap-2 min-w-0",children:[(0,v.jsx)("div",{className:"w-4 flex-shrink-0 flex justify-center",children:re(t,a,s)&&(0,v.jsx)(z.Z,{className:"w-4 h-4 text-amber-500"})}),"CardMerchant"===t.counterparty_group_type?(0,v.jsx)(R,{className:"w-5 h-5 text-gray-400 flex-shrink-0"}):(0,v.jsx)(F.Z,{className:"w-5 h-5 text-gray-400 flex-shrink-0"}),(0,v.jsx)("span",{className:"text-secondary text-sm font-poppins truncate",children:t.name})]}),(0,v.jsxs)("div",{className:"flex items-center gap-2 min-w-0",children:[(0,v.jsx)("div",{className:"flex-1 min-w-0",children:(0,v.jsx)(Q,{selectedId:a,options:n,placeholder:"Select contact",emptyText:"No contacts found.",disabled:o,onChange:c,loadingText:i?"Creating\u2026":void 0,createAction:{label:"Create a vendor",onCreate:d}})}),(0,v.jsx)("div",{className:"w-6 flex-shrink-0 flex justify-center",children:null!=a&&(0,v.jsx)(oe,{label:"Remove c
1ontact mapping",disabled:o,onClick:function(){return c(null)}})})]}),(0,v.jsxs)("div",{className:"flex items-center gap-2 min-w-0",children:[(0,v.jsx)("div",{className:"flex-1 min-w-0",children:(0,v.jsx)(Q,{selectedId:s,options:r,placeholder:"Select account",emptyText:"No expense accounts found.",disabled:o,onChange:l})}),(0,v.jsx)("div",{className:"w-6 flex-shrink-0 flex justify-center",children:null!=s&&(0,v.jsx)(oe,{label:"Remove ledger mapping",disabled:o,onClick:function(){return l(null)}})})]})]})},ce=function(e){var t=e.contacts,n=e.accounts;return(0,v.jsxs)("div",{className:"mx-6 mb-4 px-4 py-3 rounded-lg border border-amber-300 bg-amber-50 flex items-start gap-2",children:[(0,v.jsx)(z.Z,{className:"w-5 h-5 text-amber-500 flex-shrink-0"}),(0,v.jsxs)("p",{className:"text-amber-800 text-sm font-poppins",children:[(0,v.jsx)(X,{contacts:t,accounts:n})," Save the mapping to apply them."]})]})},le=function(){return(0,v.jsxs)("div",{className:"mx-6 mb-4 px-4 py-3 rounded-lg border border-amber-300 bg-amber-50 flex items-start gap-2",children:[(0,v.jsx)(z.Z,{className:"w-5 h-5 text-amber-500 flex-shrink-0"}),(0,v.jsx)("p",{className:"text-amber-800 text-sm font-poppins",children:"Alfie is working hard to suggest your mapping from your accounting sync behaviour. This can take a while \u2014 you cannot edit the mapping until it is done. Please come back later."})]})},de=function(e){var t,n=e.isOpen,r=e.onClose,s=(0,b.F)().platformName,i=(0,T.ZP)(n?"counterparty-list":null,(function(){return(0,f.lF)()}),{revalidateOnFocus:!1}),u=i.data,p=i.mutate,x=(0,T.ZP)(n?"accounting-contact-list":null,f.hr,{revalidateOnFocus:!1}),m=x.data,h=x.mutate,g=(0,T.ZP)(n?"counterparty-expense-to-account-list":null,(function(){return(0,f.Qq)({is_expense:!0,is_from_account:!1})}),{revalidateOnFocus:!1}),y=g.data,j=g.mutate,N=(0,a.useMemo)((function(){var e;return null!==(e=null===u||void 0===u?void 0:u.data.data.results)&&void 0!==e?e:[]}),[u]),k=(null!==m&&void 0!==m?m:[]).map((function(e){return{id:e.id,name:e.vendor_name,active:e.active}})),Z=(null!==(t=null===y||void 0===y?void 0:y.data.data)&&void 0!==t?t:[]).map((function(e){return{id:e.id,name:e.account_name}})),C=function(e){var t=(0,a.useState)({}),n=(0,d.Z)(t,2),r=n[0],s=n[1],o=(0,a.useState)({}),i=(0,d.Z)(o,2),c=i[0],l=i[1];return(0,a.useEffect)((function(){s((function(t){return ae(t,e,ee)})),l((function(t){return ae(t,e,te)}))}),[e]),{contactIdOf:function(e){var t;return null!==(t=r[$(e)])&&void 0!==t?t:null},accountIdOf:function(e){var t;return null!==(t=c[$(e)])&&void 0!==t?t:null},setContactId:function(e,t){return s((function(n){return(0,L.Z)((0,L.Z)({},n),{},(0,A.Z)({},e,t))}))},setAccountId:function(e,t){return l((function(n){return(0,L.Z)((0,L.Z)({},n),{},(0,A.Z)({},e,t))}))},clearAll:function(){s({}),l({})}}}(N),_=function(e,t){var n,r=(0,a.useState)(!1),s=(0,d.Z)(r,2),i=s[0],u=s[1],p=(0,a.useState)(!1),x=(0,d.Z)(p,2),m=x[0],h=x[1],v=(0,a.useRef)(t),g=(0,a.useRef)(!1);(0,a.useEffect)((function(){v.current=t}));var b=(0,T.ZP)(e?"counterparty-auto-suggestion-status":null,f.sX,{revalidateOnFocus:!1,refreshInterval:i?5e3:0,onSuccess:function(e){se(e.data.data.status)&&v.current()}}),y=b.data,j=b.mutate,w=null!==(n=null===y||void 0===y?void 0:y.data.data.status)&&void 0!==n?n:null;(0,a.useEffect)((function(){if(!e)return g.current=!1,void u(!1);var t=se(w),n=g.current&&!t;g.current=t,u(t),n&&(v.current(),(0,o.xO)("Alfie finished suggesting. Review the mapping and save it."))}),[e,w]);var N=function(){var e=(0,l.Z)((0,c.Z)().mark((function e(t){return(0,c.Z)().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return h(!0),e.prev=1,e.next=4,(0,f.jM)(t);case 4:u(!0),g.current=!0,e.next=10;break;case 8:e.prev=8,e.t0=e.catch(1);case 10:return e.prev=10,e.prev=11,e.next=14,j();case 14:e.next=18;break;case 16:e.prev=16,e.t1=e.catch(11);case 18:return h(!1),e.finish(10);case 20:case"end":return e.stop()}}),e,null,[[1,8,10,20],[11,16]])})));return function(t){return e.apply(this,arguments)}}();return{isSuggesting:i||m,trigger:N}}(n,(function(){p()})),S=(0,a.useState)(!1),O=(0,d.Z)(S,2),I=O[0],M=O[1],z=(0,a.useState)(!1),R=(0,d.Z)(z,2),F=R[0],B=R[1],W=(0,a.useState)(!1),D=(0,d.Z)(W,2),G=D[0],H=D[1],U=(0,a.useState)(new Set),q=(0,d.Z)(U,2),K=q[0],Q=q[1],Y=_.isSuggesting,X=N.filter((function(e){return ne(C.contactIdOf(e),ee(e))})).length,oe=N.filter((function(e){return ne(C.accountIdOf(e),te(e))})).length,de=X+oe,ue=de>0?"Save mapping (".concat(de,")"):"Save mapping",pe=function(e){return{counterparty_group_type:e.counterparty_group_type,counterparty_group_id:e.counterparty_group_id,accounting_contact_id:C.contactIdOf(e),accounting_account_id:C.accountIdOf(e)}},xe=function(e,t){return Q((function(n){var r=new Set(n);return t?r.add(e):r.delete(e),r}))},fe=function(){var e=(0,l.Z)((0,c.Z)().mark((function e(t){var n,r,a;return(0,c.Z)().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(n=$(t),!K.has(n)){e.next=3;break}return e.abrupt("return",!1);case 3:return xe(n,!0),e.prev=4,e.next=7,(0,f._v)({counterparty_group_type:t.counterparty_group_type,counterparty_group_id:t.counterparty_group_id});case 7:if(r=e.sent,!(a=r.data.data).pending){e.next=12;break}return(0,o.KV)("".concat(s," is still creating the vendor. Refresh contacts later to map it.")),e.abrupt("return",!1);case 12:if(null!=a.accounting_contact_id){e.next=15;break}return(0,o.bW)("".concat(s," did not return a vendor to map.")),e.abrupt("return",!1);case 15:return e.next=17,h();case 17:return C.setContactId(n,a.accounting_contact_id),(0,o.xO)(a.already_existed?"".concat(t.name," already exists in ").concat(s,"."):"Created ".concat(t.name," in ").concat(s,".")),e.abrupt("return",!0);case 22:return e.prev=22,e.t0=e.catch(4),e.abrupt("return",!1);case 25:return e.prev=25,xe(n,!1),e.finish(25);case 28:case"end":return e.stop()}}),e,null,[[4,22,25,28]])})));return function(t){return e.apply(this,arguments)}}(),me=function(){var e=(0,l.Z)((0,c.Z)().mark((function e(){return(0,c.Z)().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(0!==N.length){e.next=3;break}
1return(0,o.KV)("No vendors to suggest for."),e.abrupt("return");case 3:return e.next=5,_.trigger(N.map(pe));case 5:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}(),he=function(){var e=(0,l.Z)((0,c.Z)().mark((function e(){return(0,c.Z)().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return H(!0),e.prev=1,e.next=4,Promise.all([(0,f.ky)(),(0,f.uq)()]);case 4:return e.next=6,Promise.all([h(),j()]);case 6:e.next=10;break;case 8:e.prev=8,e.t0=e.catch(1);case 10:H(!1);case 11:case"end":return e.stop()}}),e,null,[[1,8]])})));return function(){return e.apply(this,arguments)}}(),ve=function(){var e=(0,l.Z)((0,c.Z)().mark((function e(){var t,n,a;return(0,c.Z)().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=C.contactIdOf,n=C.accountIdOf,a=N.filter((function(e){return re(e,t(e),n(e))})).map(pe),M(!0),e.prev=3,e.next=6,(0,f.LZ)(a);case 6:return C.clearAll(),e.next=9,p();case 9:(0,o.xO)("Vendor mapping saved."),r(),e.next=15;break;case 13:e.prev=13,e.t0=e.catch(3);case 15:B(!1),M(!1);case 17:case"end":return e.stop()}}),e,null,[[3,13]])})));return function(){return e.apply(this,arguments)}}();return(0,v.jsxs)(V.Z,{isOpen:n,onClose:function(){de>0&&!Y?B(!0):r()},title:"Vendor Mapping",width:"w-full md:w-[860px]",headerActions:(0,v.jsxs)(v.Fragment,{children:[(0,v.jsx)(P,{onClick:me,loading:Y,disabled:Y||I}),(0,v.jsx)("button",{type:"button",onClick:he,disabled:G||Y,"aria-label":"Refresh contacts and ledgers",className:"p-1.5 rounded-lg text-gray-500 hover:text-secondary disabled:cursor-not-allowed disabled:hover:text-gray-500",children:(0,v.jsx)(E.Z,{className:(0,w.Z)("w-5 h-5",{"animate-spin":G})})})]}),children:[(0,v.jsxs)("div",{className:"flex flex-col h-full",children:[(0,v.jsx)("div",{className:"px-6 pt-5 pb-4",children:(0,v.jsxs)("p",{className:"text-gray-500 text-sm font-normal font-poppins",children:["Close your books faster \u2014 map each vendor once to its ",s," ","contact and expense ledger, and every new expense to the vendor is mapped automatically."]})}),Y&&(0,v.jsx)(le,{}),!Y&&de>0&&(0,v.jsx)(ce,{contacts:X,accounts:oe}),(0,v.jsxs)("div",{className:"flex-1 overflow-y-auto px-6",children:[(0,v.jsxs)("div",{className:"grid grid-cols-3 gap-4 px-4 py-3 bg-primary rounded-t-lg text-white text-sm font-semibold font-poppins sticky top-0 z-sticky-header",children:[(0,v.jsx)("span",{children:"Swipey Vendor"}),(0,v.jsxs)("span",{children:[s," Contact"]}),(0,v.jsxs)("span",{children:[s," Ledger"]})]}),(0,v.jsx)("div",{className:(0,w.Z)({"opacity-60 pointer-events-none select-none":Y}),children:N.map((function(e){var t=$(e);return(0,v.jsx)(ie,{counterparty:e,contacts:k,accounts:Z,contactId:C.contactIdOf(e),accountId:C.accountIdOf(e),disabled:Y,isCreating:K.has(t),onContactChange:function(e){return C.setContactId(t,e)},onAccountChange:function(e){return C.setAccountId(t,e)},onCreateContact:function(){return fe(e)}},t)}))}),0===N.length&&(0,v.jsx)("p",{className:"text-gray-400 text-sm py-8 text-center font-poppins",children:"No vendors to map."})]}),(0,v.jsxs)("div",{className:"px-6 py-4 border-t border-zinc-200 flex flex-col gap-3",children:[(0,v.jsx)("p",{className:"text-gray-400 text-xs font-poppins",children:"Vendors who remain unmapped will be sent to your accounting software as a default Swipey Vendor."}),(0,v.jsx)("button",{type:"button",onClick:ve,disabled:I||Y||0===de,className:"self-start px-5 py-2 rounded-lg bg-secondary text-white text-sm font-medium font-poppins disabled:opacity-60 disabled:cursor-not-allowed",children:I?"Saving\u2026":ue})]})]}),(0,v.jsx)(J,{isOpen:F,contacts:X,accounts:oe,saving:I,onDiscard:function(){C.clearAll(),B(!1),r()},onSave:ve})]})},ue=function(){var e=(0,I.Z)().enableAccountingContactMapping,t=(0,b.F)().platformName,n=(0,a.useState)(!1),r=(0,d.Z)(n,2),s=r[0],o=r[1];if(!e)return null;return(0,v.jsxs)("div",{className:"p-6 bg-white rounded-[14px] border border-zinc-300 justify-between items-center inline-flex",children:[(0,v.jsxs)("div",{className:"flex-col justify-start items-start gap-1 flex",children:[(0,v.jsxs)("div",{className:"items-center gap-2 inline-flex",children:[(0,v.jsx)("div",{className:"text-secondary text-lg font-semibold font-poppins",children:"Vendor Mapping"}),(0,v.jsx)("span",{className:"px-2 py-0.5 rounded-full bg-violet-100 text-violet-600 text-xs font-semibold font-poppins",children:"New"})]}),(0,v.jsxs)("div",{className:"text-gray-500 text-sm font-normal font-poppins",children:["Close your books faster \u2014 map each vend
1or once to its ",t," ","contact and expense ledger, and every new expense is mapped automatically."]})]}),(0,v.jsx)("button",{type:"button",onClick:function(){return o(!0)},className:"px-4 py-2 rounded-lg bg-secondary text-white text-sm font-medium font-poppins",children:"Manage"}),(0,v.jsx)(de,{isOpen:s,onClose:function(){return o(!1)}})]})},pe=function(){var e=(0,i.z)();return(0,a.useEffect)((function(){e&&"pending"===e.status&&(0,o.bW)("Hold on! Swipey is chatting with the Accounting Software to transfer your account information over. Check back in a couple of minutes!")}),[e]),(0,v.jsxs)(s.Z,{overrideContainerBackground:!0,containerClassName:"bg-white",customTitle:(0,v.jsx)("h1",{className:"text-title-large flex-1 font-bold text-secondary",children:"Settings"}),children:[(0,v.jsx)("p",{className:"text-gray-500 text-sm font-normal font-poppins -mt-2 mb-6",children:"Manage integrations, vendors and how Swipey books your spend."}),(0,v.jsxs)("div",{className:"flex flex-col gap-6",children:[(0,v.jsx)(y,{}),(0,v.jsx)(O,{}),(0,v.jsx)(ue,{})]})]})},xe=n(5928),fe=function(){var e=(0,I.Z)(),t=e.enableAccounting,n=e.enableAccountingIntegrationGuideWizard,a=(0,x.Z)((function(e){return e})),s=a.isConnected,o=a.pendingStatusConnection,i=a.isCompletedIntegration;return o?(0,v.jsx)(xe.Z,{}):s?n&&!i?(0,v.jsx)(h.l_,{to:m.x.ACCOUNTING}):(0,v.jsx)(r.Z,{flag:t,children:(0,v.jsx)(pe,{})}):(0,v.jsx)(h.l_,{to:m.x.ACCOUNTING})}},20411:function(e,t,n){var r=n(47313);var a=r.forwardRef((function(e,t){return r.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",strokeWidth:2,stroke:"currentColor","aria-hidden":"true",ref:t},e),r.createElement("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M4 4v5h.582m15.356 2A8.001 8.001 0 004.582 9m0 0H9m11 11v-5h-.581m0 0a8.003 8.003 0 01-15.357-2m15.357 2H15"}))}));t.Z=a},77137:function(e,t,n){var r=n(47313);var a=r.forwardRef((function(e,t){return r.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true",ref:t},e),r.createElement("path",{fillRule:"evenodd",d:"M5.293 7.293a1 1 0 011.414 0L10 10.586l3.293-3.293a1 1 0 111.414 1.414l-4 4a1 1 0 01-1.414 0l-4-4a1 1 0 010-1.414z",clipRule:"evenodd"}))}));t.Z=a},3070:function(e,t,n){var r=n(47313);var a=r.forwardRef((function(e,t){return r.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true",ref:t},e),r.createElement("path",{fillRule:"evenodd",d:"M10 3a1 1 0 011 1v5h5a1 1 0 110 2h-5v5a1 1 0 11-2 0v-5H4a1 1 0 110-2h5V4a1 1 0 011-1z",clipRule:"evenodd"}))}));t.Z=a}}]);

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.