1/*! Optin - Fri, 18 Sep 2026 16:25:45 GMT */ 2"use strict";(self.webpackChunkom_api_js=self.webpackChunkom_api_js||[]).push([[18],{1845:function(t,e,s){s.r(e),s.d(e,{default:function(){return h}});var i=s(1441),r=s(187),n=s(499),o=s(5728),a=s(3824);class h{constructor(t){this.C=t,this.sendTags=!0,this.submitting=!1,this.preview=this.C.preview,this.spam=!1,this.data={referrer:window.location.href,userAgent:(0,a.$t)(),previous:(0,a.SP)(),fields:{},tags:{},site:this.C.Sites.current().id,page:{title:document.title,url:window.location.href},dymprompted:null},this.ak=null}init(){if((0,a.hZ)(document,"Optin.init",{Optin:this,Campaign:this.C}),this.preview)return void r.A.warn("This is just a preview of the campaign and cannot be submitted.");if(this.submitting)return;if(this.C.Form.showLoad(),!this.C.Form.validate())return void this.C.Form.showValidateErrors();this.submitting=!0,this.C.options.gamified&&this.C.GamifiedWheel.spin();const t=["email","name","phone","user-segments","FieldsElement--privacyText-checkbox"],e={},s={};(0,a.HN)(this.C.Form.inputs,(i,r)=>{let n=r.getAttribute("name"),o=r.getAttribute("type"),a="";if(!n)return;n=n.replace(`${this.C.ns}-`,"");const h=t.includes(n)||this.C.Form.isHoneypotField(r)?e:s;switch(o){case"checkbox":case"radio":if(r.checked)if(a=r.value.trim(),h[n])if("user-segments"===n)if("object"==typeof h[n])h[n][i]=a;else{let t=h[n];h[n]={},h[n][i-1]=t,h[n][i]=a}else Array.isArray(h[n])||(h[n]=[h[n]]),h[n].push(a);else h[n]=a;break;default:h[n]=r.value.trim()}}),this.C.Dym.hasBeenPrompted()&&(this.data.dymprompted=!0),(0,a.Ie)(e)||(this.data.fields=e),(0,a.Ie)(s)||(this.data.fields.meta=s),this.C.Tags.fields({...e,...s}),n.A.get("_mkto_trk")&&(this.data.mkto=n.A.get("_mkto_trk")),n.A.get("hubspotutk")&&(this.data.hutk=n.A.get("hubspotutk")),n.A.get("__ss_tk")&&(this.data.sstk=n.A.get("__ss_tk"));const o=n.A.get(/^visitor_id\d{5,8}$/m);if(o&&(this.data.pvid=o),this.sendTags&&(this.data.tags=this.C.Dtr.getCustomVariables()),(0,a.hZ)(document,"Optin.init.submit",{Optin:this,Campaign:this.C}),this.completeSubmission=!0,(0,a.hZ)(document,"Optin.init.beforeSubmission",{Optin:this,Campaign:this.C}),this.completeSubmission){let t=window[i.LQ].scripts.recaptcha.object;if(this.C.Form.recaptcha()&&t)return t.ready(()=>{t.execute(this.C.Sites.current().settings.recaptchaSiteKey,{action:`om_optin_${this.C.id}`}).then(t=>{this.data.recaptcha=t}).then(()=>this.post()).catch(()=>{})});this.post()}}post=()=>{(0,a.hZ)(document,"Optin.post",{Optin:this,Campaign:this.C});const t=(new o.A).post((0,a.ID)(this.C.defaults,"optin",this.C.id),this.data);this.ak&&t.setHeader("X-OptinMonster-ApiKey",this.ak),t.send().then(t=>this.success(t)).catch(t=>this.error(t))};success=t=>{let e=JSON.parse(t.response);if(!e||(0,a.Ie)(e))return e={response:{error:"An unexpected error occurred, please try again later."}},this.error(e);if(e&&e.error)return this.error(t);e&&e.errors&&r.A.error(e.errors),203===t.status&&(this.spam=!0);const s=this.C.options.gamified?this.C.GamifiedWheel.initPromise():Promise.resolve();return this.submitting=!1,(0,a.hZ)(document,"Optin.success",{Optin:this,Campaign:this.C,response:e}),this.C.cleanup(),s.then(()=>{(0,a.hZ)(this.C.Form.submit,"submit")}).catch(()=>{})};error=t=>{const e=t.response?JSON.parse(t.response):null;let s=e?e.message||e.error:null;(0,a.hZ)(document,"Optin.error",{Optin:this,Campaign:this.C,response:s||t,responseObj:e}),this.C.Form.removeLoad(),this.C.options.gamified&&this.C.GamifiedWheel.initPromise(),this.submitting=!1,this.C.Dym.parseOptinResponse(e),this.data.dymprompted=null,this.C.Form.errors.optin=s||"An unexpected error occurred. Please try again later.",s||r.A.error(t),e&&e.errors&&r.A.error(e.errors),this.C.Form.showOptinErrors()}}}}]);
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.