1import{r,p as c,B as b,v as E,bc as v}from"./index-C9IH3k-2.js";import{u as P,f as p,W as y,c as B,a as I}from"./WhiteLabelFramedContent-BsGtRGOu.js";import{A as D}from"./Add3rdPartyScript-CynHdFNV.js";import{b as x}from"./HelperMethods-C-ewwU_x.js";const w="rl_wSignupFlowRes",W=g=>{const{onSuccess:l}=g,{isIFrame:u,api:f,reportToParent:m,reportErrorToParent:F}=P(),[a,d]=r.useState(!1),o=r.useRef(null),s=r.useRef(null),S=new URLSearchParams(window.location.search).get("postpaid")==="true"||window.location.pathname.toLowerCase()==="/connectedaccount/postpaid"?B:I,h=()=>{if(a){console.log("Flow already active, ignoring new request");return}const i=x();o.current=i,d(!0),window.FB.login(function(t){if(console.log("FB login response: ",t," Flow ID: ",i),t.authResponse){const n={...t,flowSessionId:i,embeddedSignupEventData:s.current};s.current=null,f.post("/api/v1/onboard/embeddedSignup",n).then(e=>{(e.status===200||e.status===207)&&(u?m(w,e.data):typeof l=="function"&&l(e.data))}).catch(e=>{console.error("Embedded signup POST error",e),u&&F(w,e)}).finally(()=>{o.current=null,d(!1)})}else s.current=null,o.current=null,d(!1)},S)};return r.useEffect(()=>{D("https://connect.facebook.net/en_US/sdk.js").then(()=>{if(window.FB&&typeof window.FB.init=="function")try{window.FB.init(p)}catch(t){console.warn("FB.init failed (already initialised?)",t)}else window.fbAsyncInit=function(){window.FB.init(p)}});const i=async t=>{if(t.origin.endsWith("facebook.com"))try{const n=JSON.parse(t.data);console.log("Parsed FB event data: ",n," Flow ID: ",o.current);const e={eventData:n,flowSessionId:o.current};console.log("FB message event: ",e),n.type==="WA_EMBEDDED_SIGNUP"&&(typeof n.event=="string"&&n.event.startsWith("FINISH")&&o.current&&(s.current=n.data??null),await f.post("/api/v1/onboard/saveEmbeddedFlowEvent",e))}catch{console.log("FB message event: ",t.data)}};return window.addEventListener("message",i),()=>window.removeEventListener("message",i)},[]),c.jsx(y,{children:c.jsx(b,{type:"primary",style:{height:"40px",width:"186px"},onClick:h,disabled:a,loading:a,children:c.jsxs(E,{children:[c.jsx(v,{}),a?"Flow in Progress...":"Login with Facebook"]})})})};export{w as EMBEDDED_SIGNUP_RESULT_MESSAGE_TYPE,W as default};
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.