((r,a,i)=>{i={settings:null,is_mobile:/Mobile|Android|iPhone|iPad/i.test(navigator.userAgent),can_qr:r.QrCreator&&"function"==typeof QrCreator.render,...i},(r.joinchat_obj=i).send_event=function(s){if((s={event_category:"JoinChat",event_label:"",event_action:"",chat_channel:"whatsapp",chat_id:"--",is_mobile:this.is_mobile?"yes":"no",page_location:location.href,page_title:a.title||"no title",...s}).event_label=s.event_label||s.link||"",s.event_action=s.event_action||s.chat_channel+": "+s.chat_id,delete s.link,a.dispatchEvent(new CustomEvent("joinchat:event",{detail:s,cancelable:!0}))){let t=r[this.settings.data_layer]||r[r.gtm4wp_datalayer_name]||r.dataLayer;if("object"==typeof t){"undefined"==typeof gtag&&(r.gtag=function(){t.push(arguments)});let e=this.settings.ga_event||"generate_lead",n={transport_type:"beacon",...s},a=(Object.keys(n).forEach(t=>{"page_location"===t?n[t]=n[t].substring(0,1e3):"page_referrer"===t?n[t]=n[t].substring(0,420):"page_title"===t?n[t]=n[t].substring(0,300):"string"==typeof n[t]&&(n[t]=n[t].substring(0,100))}),[]),i=t=>{a.includes(t)||(t.startsWith("G-")||t.startsWith("GT-"))&&(a.push(t),gtag("event",e,{send_to:t,...n}))};if(r.google_tag_data&&google_tag_data.tidr&&google_tag_data.tidr.destination)for(var o in google_tag_data.tidr.destination)i(o);t.forEach(t=>{"config"===t[0]&&t[1]&&i(t[1])}),this.settings.gads&>ag("event","conversion",{send_to:this.settings.gads})}var e=s.event_category;delete s.event_category,"object"==typeof t&&t.push({event:e,...s}),"function"==typeof fbq&&fbq("trackCustom",e,s)}},i.get_wa_link=function(t,e,n){e=void 0!==e?e:this.settings.message_send||"",n=void 0!==n?n:this.settings.whatsapp_web&&!this.is_mobile;n=new URL((n?"https://web.whatsapp.com/send?phone=":"https://wa.me/")+(t||this.settings.telephone));return e&&n.searchParams.set("text",e),n.toString()},i.open_whatsapp=function(t,e){t=t||this.settings.telephone,e=void 0!==e?e:this.settings.message_send||"";t={link:this.get_wa_link(t,e),chat_channel:"whatsapp",chat_id:t,chat_message:e};a.dispatchEvent(new CustomEvent("joinchat:open",{detail:t,cancelable:!0}))&&(this.send_event(t),r.open(t.link,"joinchat","noopener"))},i.qr=function(t,e){var n=a.createElement("CANVAS");return QrCreator.render(Object.assign({text:t,radius:.4,background:"#FFF",size:200*(r.devicePixelRatio||1)},this.settings.qr||{},e||{}),n),n};var t=()=>{if(a.addEventListener("click",function(t){t.target.closest('.joinchat_open, .joinchat_app, a[href="#joinchat"], a[href="#whatsapp"]')&&(t.preventDefault(),i.open_whatsapp(t.target.dataset.phone,t.target.dataset.message))}),i.can_qr&&!i.is_mobile?a.querySelectorAll(".joinchat-button__qr").forEach(t=>t.appendChild(i.qr(i.get_wa_link(t.dataset.phone,t.dataset.message,!1)))):a.querySelectorAll(".wp-block-joinchat-button figure").forEach(t=>t.remove()),void 0!==i.settings.sku&&"function"==typeof jQuery){let n=i.settings.message_send;jQuery("form.variations_form").on("found_variation reset_data",function(t,e){e=e&&e.sku||i.settings.sku;i.settings.message_send=n.replace(/.*<\/jc-sku>/g,e)})}};"loading"!==a.readyState?t():a.addEventListener("DOMContentLoaded",t)})(window,document,window.joinchat_obj||{});