(self.webpackChunkoptin_monster_wp_api=self.webpackChunkoptin_monster_wp_api||[]).push([[131],{79:function(t,e,n){var r=n(3702),o=n(80),i=n(4739),s=n(8655),a=n(1175);function u(t){var e=-1,n=null==t?0:t.length;for(this.clear();++e{this.campaignLoaded=!0,this.$element.find(".om-elementor-editor .om-errors").hide()}),this.on("otherCampaignLoaded",this.updateSelect.bind(this)),this.on("otherCampaignRemoved",this.updateSelect.bind(this)),this.on("campaignError",this.foundError.bind(this)),this.elements.$select.on("change",this.onSelect.bind(this)),this.elements.$links.on("click",this.onClickLinks.bind(this)),this.initCampaignPreview(),this.maybeTogglePanelSettings()}unbindEvents(){const t=this.getCampaign();t&&(s.push(t),t.off()),this.oldSlug&&(delete OMAPI._usedSlugs[this.oldSlug],window.OMAPI_Elementor.utils.events.trigger(document,"Plugin.Elementor.Instance.removed",{id:this.oldSlug}))}foundError(t){const e=this.campaignSlug();if(t.responseURL&&0>t.responseURL.indexOf(e))return;let n=t;t.response&&(n=JSON.parse(t.response).message||JSON.parse(t.response).error),t.message&&(n=t.message),this.$element.find(".om-elementor-editor .om-errors").show().find(".om-error-description").html(n)}onClickLinks(t){t.preventDefault(),window.open(t.target.href)}onSelect(t){t.preventDefault(),window.parent.jQuery('#elementor-controls .elementor-control-campaign_id select[data-setting="campaign_id"]').val(this.elements.$select.val()).trigger("change")}onElementChange(t,e,n){const r=e.$el.find('select[data-setting="campaign_id"]');r.length&&(a.$editorSelect=r),this.maybeTogglePanelSettings(),"campaign_id"===t&&this.initCampaignPreview()}initCampaignPreview(){this.initCampaign(),this.updateSelect()}initCampaign(){const t=this.campaignSlug();if(!t)return;this.oldSlug&&delete OMAPI._usedSlugs[this.oldSlug],this.oldSlug=t,OMAPI._usedSlugs[t]=!0,this.elements.$holder.html(`
`);let e=this.getCampaign();if(e)return;if(s.length&&(e=s.find(e=>t===e.id),e))return s.splice(s.indexOf(e),1),setTimeout(()=>e.reset(),200);if(e)return;const n={id:`om-${t}-js`,type:"text/javascript",src:OMAPI.apiUrl,async:!0,"data-user":OMAPI.omUserId,"data-campaign":t};OMAPI.omEnv&&(n["data-env"]=OMAPI.omEnv);const r=document.getElementsByTagName("head")[0]||document.documentElement,o=document.createElement("script");let i;for(i in n)o.setAttribute(i,n[i]);r.appendChild(o)}updateSelect(){this.updateSelectOptions(this.elements.$select)}updateSelectOptions(t){const e=this.campaignSlug(),n=document.createDocumentFragment();t.find("option").remove(),function(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;if((!(arguments.length>2&&void 0!==arguments[2])||arguments[2])&&!(OMAPI.site_ids&&OMAPI.site_ids.length>0))return[];const n=i()(OMAPI,`campaigns.${t}`,{});if(Object.keys(n).length<1||!OMAPI.omUserId)return[];let r=Object.keys(n).map(t=>{let r=i()(n,`${t}.title`,"");return i()(n,`${t}.pending`)&&(r+=" [Pending]"),{value:t,label:r,selected:null!==e&&e===t,disabled:null!==e&&i()(OMAPI,`_usedSlugs.${t}`)&&t!==e}});return r.length>0&&r.unshift({value:"",label:OMAPI.i18n.campaign_select}),r}("inline",e).forEach(t=>{const e=document.createElement("option");e.textContent=t.label,e.value=t.value,t.selected&&(e.selected=!0),t.disabled&&(e.disabled=!0),n.appendChild(e)}),t.append(n)}campaignSlug(){return this.getElementSettings("campaign_id").replace(/[^a-zA-Z0-9]/g,"")}getCampaign(){return function(){const t=`om${arguments.length>0&&void 0!==arguments[0]?arguments[0]:""}`;return window[t]?window[t]:null}(this.campaignSlug())}onEditSettingsChange(t){"panel"===t&&this.maybeTogglePanelSettings()}maybeTogglePanelSettings(){setTimeout(()=>{const t=elementor.getPanelView().getCurrentPageView(),e=this.campaignSlug();t.getControlViewByName&&["edit_campaign","followrules","campaign_id"].forEach(n=>{const r=t.getControlModel(n);if(!r)return;const o=t.getControlViewByModel(r);if(o){if("campaign_id"===n){const t=o.$el.find('[data-setting="campaign_id"]');t.length&&this.updateSelectOptions(t)}else o.$el[e?"show":"hide"]();if(e&&"edit_campaign"===n){const t=o.$el.find("a");t.length&&t.attr("href",OMAPI.editUrl.replace(/--CAMPAIGN_SLUG--/g,e))}}})},10)}}var u,c;u=a,(c=function(t){var e=function(t){if("object"!=r(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var n=e.call(t,"string");if("object"!=r(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==r(e)?e:e+""}(c="$editorSelect"))in u?Object.defineProperty(u,c,{value:null,enumerable:!0,configurable:!0,writable:!0}):u[c]=null;var l=a},7296:function(t,e,n){var r,o=n(5481),i=(r=/[^.]+$/.exec(o&&o.keys&&o.keys.IE_PROTO||""))?"Symbol(src)_1."+r:"";t.exports=function(t){return!!i&&i in t}},7422:function(t,e,n){var r=n(1769),o=n(7797);t.exports=function(t,e){for(var n=0,i=(e=r(e,t)).length;null!=t&&n-1}},9325:function(t,e,n){var r=n(4840),o="object"==typeof self&&self&&self.Object===Object&&self,i=r||o||Function("return this")();t.exports=i},9350:function(t){var e=Object.prototype.toString;t.exports=function(t){return e.call(t)}}}]);