import{rn as e}from"./DRAiiyBy.mjs";import{t}from"./DjJjf45a.mjs";import{c as n}from"./a-nh7acf.mjs";import{f as r}from"./C3A_u7bk.mjs";import{O as i}from"./BF6TA2-F.mjs";import{t as a}from"./CdephWkY.mjs";import{t as o}from"./5EcwwInY.mjs";import"./DOa9RD2F.mjs";import{S as s,o as c,t as l}from"./B6MjkaMU.mjs";var u=!1,d=()=>{window.dataLayer=window.dataLayer||[],window.dataLayer.some(e=>e?.event===`gtm.js`)||window.dataLayer.push({"gtm.start":Date.now(),event:`gtm.js`})},f=e=>Array.isArray(window.google_tags_first_party)&&window.google_tags_first_party.includes(e),p=e=>{let t=document.createElement(`script`);t.async=!0,t.src=`https://www.googletagmanager.com/gtm.js?id=${e}`,document.head.appendChild(t)},m=()=>{i&&!u&&(u=!0,d(),a(()=>{f(i)||p(i)}))},h=()=>{let i=new Set;return o.subscribe({initialize:()=>{m(),g({event:`initialize`})},firstUserResponse:({user:e,code:t})=>{g({userId:e.id,code:t,isAuthenticated:!0,flags:e?.flags?.map(({flag:e})=>e),hash:e?.intercomHash,username:e?.name})},authenticate:e=>{{let{user:t}=e.userAuthenticatedSession.session,n=s();e.subtype===`register`&&n&&!i.has(t.id)&&c.success(t.id)&&i.add(t.id),g({event:e.subtype,userId:t.id,signupCode:t?.signupCode?.code?.code,code:e?.code,isAuthenticated:!0,flags:t?.flags?.map(({flag:e})=>e),hash:t?.intercomHash,username:t?.name}),e.subtype===`register`&&!n&&g({event:l.Success,user_id:t.id})}},deposit:async({id:i,amount:a,currency:o})=>{{let{data:s}=await r({doc:t,variables:{}}),c=e(n),l=s?.user?.depositList?.length===1;g({event:`deposit`,id:i,amount:a,currency:o,value:c*a,ftd:l})}},logout:()=>{g({event:`logout`})}})};function g(e){try{window?.dataLayer?.push(e)}catch{return}}export{h as n,g as t};