PageSourceSearch

https://app.snapto.ai/assets/SignInForFacebookLeadAds-Bbiy89zR.js

js snapto.ai collected 2026-10-05 15:07:06 UTC 2,776 bytes, 1 lines download raw bytes

1import{p as s,r as l,B,v as I,bc as S,N as f,y as _}from"./index-C9IH3k-2.js";import{s as x,u as j,f as F,W as v,d as P,M as m}from"./WhiteLabelFramedContent-BsGtRGOu.js";import{A as R}from"./Add3rdPartyScript-CynHdFNV.js";import{b as T}from"./HelperMethods-C-ewwU_x.js";import{W as C}from"./WhiteLabelFrame-BkraNf1a.js";const u="rl_facebookLeadAdsRes",W="Connect Fb Pages / Ads Account",$=({onSuccess:a,label:r})=>x()?s.jsx(C,{path:"facebookLeadAds",messageType:u,onSuccess:a,extraParams:r?{label:r}:{},title:"Facebook Lead Ads connect"}):s.jsx(M,{onSuccess:a,label:r}),M=({onSuccess:a,label:r})=>{const{isIFrame:c,frameParam:h,api:L,reportToParent:b,reportErrorToParent:w}=j(),A=r||h("label")||W,[d,g]=l.useState(!1),n=l.useRef(null),p=l.useRef([]),k=o=>c?L.post(`${m}/connect`,o):_(`${m}/connect`,o);l.useEffect(()=>{R("https://connect.facebook.net/en_US/sdk.js").then(()=>{if(window.FB&&typeof window.FB.init=="function")try{window.FB.init(F)}catch(e){console.warn("FB.init failed (already initialised?)",e)}else window.fbAsyncInit=function(){window.FB.init(F)}});const o=e=>{if(!e.origin.endsWith("facebook.com"))return;let t;try{t=typeof e.data=="string"?JSON.parse(e.data):e.data}catch{console.log("Lead Ads FB raw event (unparsed):",e.data,"Flow ID:",n.current);return}console.log("Lead Ads FB message event:",t,"Flow ID:",n.current),n.current&&p.current.push(t)};return window.addEventListener("message",o),()=>window.removeEventListener("message",o)},[]);const y=o=>{if(c){b(u,o);return}const e=o?.skippedPages||[];e.length?f.warning(e.map(t=>t.reason).join(" "),8):f.success("Facebook Lead Ads connected successfully."),typeof a=="function"&&a(o)},E=()=>{if(d){console.log("Lead ads connect: flow already active, ignoring");return}if(!window.FB||typeof window.FB.login!="function"){const e=new Error("Facebook SDK not loaded yet. Try again in a moment.");c?w(u,e):f.error(e.message);return}const o=T();n.current=o,p.current=[],g(!0),window.FB.login(function(e){const t=p.current.slice();if(console.log("Lead ads flow complete. Flow ID:",o),console.log("  FB.login response:",e),console.log(`  Collected ${t.length} FB postMessage event(s):`,t),!e||!e.authResponse||!e.authResponse.code){c||f.warning("Facebook Lead Ads connection cancelled or failed."),n.current=null,g(!1);return}k({code:e.authResponse.code,grantedScopes:["leads_retrieval","pages_show_list","pages_read_engagement"],allPagesGranted:!0}).then(i=>{console.log("  Backend /meta/connections/connect response:",i?.data),i?.status===200&&y(i.data)}).catch(i=>{c&&w(u,i)}).finally(()=>{n.current=null,g(!1)})},P)};return s.jsx(v,{children:s.jsx(B,{type:"primary",onClick:E,disabled:d,loading:d,style:{height:40},children:s.jsxs(I,{children:[s.jsx(S,{}),d?"Connecting...":A]})})})};export{$ 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.