1import{b,c as P}from"./chunk-3SVLDTFC.js";import{Na as F}from"./chunk-TM2QYP2N.js";import{Df as L,N as E,U as g,Y as n,Yc as _,Yd as w,j as o,rc as I,sc as l,tc as T,vc as y,w as S}from"./chunk-JOMSNJSF.js";import{a as u,b as h,k as v}from"./chunk-GKQDKUXP.js";v();v();var A="https://cdn.plaid.com/link/v2/stable/link-initialize.js";var d="linkToken",O="oauth_state_id",k="plaid-link-init";var W=(()=>{class s{constructor(){this.events=[],this.verificationTransactions={},this.environment=n(T),this.applicationService=n(L),this.httpService=n(_),this.datadogService=n(y),this.myndLaunchDarklyService=n(b),this.store=n(w)}initPlaidScript(){if(!document.getElementById(k)){let i=document.createElement("script");i.src=A,i.id=k,document.head.appendChild(i)}}finishVerificationTransaction(i,t=!1){if(!this.verificationTransactions[i])return;let e=`Plaid income verification${t?" failed":""}`;I.addAction(e,{duration:(performance.now()-this.verificationTransactions[i])*1e6,action_data:{token:i}}),delete this.verificationTransactions[i]}isEnabled(i=!1){return this.myndLaunchDarklyService.getFfValue(P.PlaidEnabled).pipe()}isBankLinkEnabled(){return this.myndLaunchDarklyService.getFfValue(P.BankLinkEnabled)}startVerificationTransaction(i){this.verificationTransactions[i]=performance.now()}trackManualPlaidEvent(i){this.trackPlaidEvent(i,null,!0)}verifyIncome(i,t,e,p,m){let c=localStorage.getItem(d);return o(c).pipe(E(f=>f?(this.createPlaidEnv(i,c,!0,e,p,m),o(c)):this.getPlaidToken(i,t).pipe(E(({result:r})=>{let a=r;return localStorage.setItem(d,a),this.createPlaidEnv(i,a,!1,e,p,m),o(r)}))))}createPlaidEnv(i,t,e,p,m,c){let f=window.Plaid.create({token:t,product:["income"],env:this.getPlaidEnvironment(),receivedRedirectUri:e?window.location.href:null,onLoad:()=>{f.open(),p()},onEvent:(r,a)=>{this.onPlaidEvent(t,r,a)},onSuccess:(r,a)=>{localStorage.removeItem(d),this.onPlaidSuccess(t,r,a).pipe(S(()=>(localStorage.removeItem(d),c(),o(null)))).subscribe(),m()}})}onPlaidEvent(i,t,e){t==="OPEN"&&this.store.dispatch(F()),t!=="HANDOFF"&&(this.accumulateEvent(t,h(u({},e),{token:i})),t==="EXIT"&&this.recordPlaidEvents())}onPlaidSuccess(i,t,e){return this.accumulateEvent("HANDOFF",{token:i,link_session_id:e.link_session_id,institution_id:e.institution&&e.institution.institution_id,institution_name:e.institution&&e.institution.name}),this.recordPlaidEvents(),this.startIncomeVerification(i,t)}accumulateEvent(i,t){this.datadogService.addAction("Plaid interaction",h(u({},t),{event_name:i})),t&&this.events.push(this.transformPlaidEvent(i,t))}getPlaidEnvironment(){switch(this.environment.env){case l.Local:case l.Dev:case l.Staging:return"sandbox";case l.Prod:return"production"}}getPlaidToken(i,t){return t?o({result:t}):this.applicationService.createPlaidToken(i)}recordPlaidEvents(){this.applicationService.trackPlaidEventBulk(this.events).subscribe(()=>this.events=[])}startIncomeVerification(i,t){return this.startVerificationTransaction(i),this.httpService.post("applicant/start-income-verification",{publicToken:t,incomeVerificationToken:i})}trackPlaidEvent(i,t,e){this.datadogService.addAction("Plaid interaction",h(u({},t),{event_name:i})),!e&&t&&this.applicationService.trackPlaidEvent(this.transformPlaidEvent(i,t)).subscribe()}transformPlaidEvent(i,t){return{eventName:i,sessionId:t.link_session_id,incomeVerificationToken:t.token,viewName:t.view_name,institutionId:t.institution_id,institutionName:t.institution_name,timestamp:t.timestamp}}static{this.\u0275fac=function(t){return new(t||s)}}static{this.\u0275prov=g({token:s,factory:s.\u0275fac,providedIn:"root"})}}return s})();export{d as a,O as b,W as c};
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.