
(()=>{var t={591:()=>{function t(e){return t="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},t(e)}function e(){"use strict";e=function(){return n};var r,n={},o=Object.prototype,i=o.hasOwnProperty,a=Object.defineProperty||function(t,e,r){t[e]=r.value},s="function"==typeof Symbol?Symbol:{},c=s.iterator||"@@iterator",l=s.asyncIterator||"@@asyncIterator",u=s.toStringTag||"@@toStringTag";function f(t,e,r){return Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}),t[e]}try{f({},"")}catch(r){f=function(t,e,r){return t[e]=r}}function h(t,e,r,n){var o=e&&e.prototype instanceof w?e:w,i=Object.create(o.prototype),s=new A(n||[]);return a(i,"_invoke",{value:P(t,r,s)}),i}function p(t,e,r){try{return{type:"normal",arg:t.call(e,r)}}catch(t){return{type:"throw",arg:t}}}n.wrap=h;var d="suspendedStart",y="suspendedYield",v="executing",m="completed",g={};function w(){}function b(){}function k(){}var E={};f(E,c,(function(){return this}));var L=Object.getPrototypeOf,x=L&&L(L(_([])));x&&x!==o&&i.call(x,c)&&(E=x);var S=k.prototype=w.prototype=Object.create(E);function O(t){["next","throw","return"].forEach((function(e){f(t,e,(function(t){return this._invoke(e,t)}))}))}function j(e,r){function n(o,a,s,c){var l=p(e[o],e,a);if("throw"!==l.type){var u=l.arg,f=u.value;return f&&"object"==t(f)&&i.call(f,"__await")?r.resolve(f.__await).then((function(t){n("next",t,s,c)}),(function(t){n("throw",t,s,c)})):r.resolve(f).then((function(t){u.value=t,s(u)}),(function(t){return n("throw",t,s,c)}))}c(l.arg)}var o;a(this,"_invoke",{value:function(t,e){function i(){return new r((function(r,o){n(t,e,r,o)}))}return o=o?o.then(i,i):i()}})}function P(t,e,n){var o=d;return function(i,a){if(o===v)throw Error("Generator is already running");if(o===m){if("throw"===i)throw a;return{value:r,done:!0}}for(n.method=i,n.arg=a;;){var s=n.delegate;if(s){var c=B(s,n);if(c){if(c===g)continue;return c}}if("next"===n.method)n.sent=n._sent=n.arg;else if("throw"===n.method){if(o===d)throw o=m,n.arg;n.dispatchException(n.arg)}else"return"===n.method&&n.abrupt("return",n.arg);o=v;var l=p(t,e,n);if("normal"===l.type){if(o=n.done?m:y,l.arg===g)continue;return{value:l.arg,done:n.done}}"throw"===l.type&&(o=m,n.method="throw",n.arg=l.arg)}}}function B(t,e){var n=e.method,o=t.iterator[n];if(o===r)return e.delegate=null,"throw"===n&&t.iterator.return&&(e.method="return",e.arg=r,B(t,e),"throw"===e.method)||"return"!==n&&(e.method="throw",e.arg=new TypeError("The iterator does not provide a '"+n+"' method")),g;var i=p(o,t.iterator,e.arg);if("throw"===i.type)return e.method="throw",e.arg=i.arg,e.delegate=null,g;var a=i.arg;return a?a.done?(e[t.resultName]=a.value,e.next=t.nextLoc,"return"!==e.method&&(e.method="next",e.arg=r),e.delegate=null,g):a:(e.method="throw",e.arg=new TypeError("iterator result is not an object"),e.delegate=null,g)}function C(t){var e={tryLoc:t[0]};1 in t&&(e.catchLoc=t[1]),2 in t&&(e.finallyLoc=t[2],e.afterLoc=t[3]),this.tryEntries.push(e)}function N(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function A(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(C,this),this.reset(!0)}function _(e){if(e||""===e){var n=e[c];if(n)return n.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var o=-1,a=function t(){for(;++o<e.length;)if(i.call(e,o))return t.value=e[o],t.done=!1,t;return t.value=r,t.done=!0,t};return a.next=a}}throw new TypeError(t(e)+" is not iterable")}return b.prototype=k,a(S,"constructor",{value:k,configurable:!0}),a(k,"constructor",{value:b,configurable:!0}),b.displayName=f(k,u,"GeneratorFunction"),n.isGeneratorFunction=function(t){var e="function"==typeof t&&t.constructor;return!!e&&(e===b||"GeneratorFunction"===(e.displayName||e.name))},n.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,k):(t.__proto__=k,f(t,u,"GeneratorFunction")),t.prototype=Object.create(S),t},n.awrap=function(t){return{__await:t}},O(j.prototype),f(j.prototype,l,(function(){return this})),n.AsyncIterator=j,n.async=function(t,e,r,o,i){void 0===i&&(i=Promise);var a=new j(h(t,e,r,o),i);return n.isGeneratorFunction(e)?a:a.next().then((function(t){return t.done?t.value:a.next()}))},O(S),f(S,u,"Generator"),f(S,c,(function(){return this})),f(S,"toString",(function(){return"[object Generator]"})),n.keys=function(t){var e=Object(t),r=[];for(var n in e)r.push(n);return r.reverse(),function t(){for(;r.length;){var n=r.pop();if(n in e)return t.value=n,t.done=!1,t}return t.done=!0,t}},n.values=_,A.prototype={constructor:A,reset:function(t){if(this.prev=0,this.next=0,this.sent=this._sent=r,this.done=!1,this.delegate=null,this.method="next",this.arg=r,this.tryEntries.forEach(N),!t)for(var e in this)"t"===e.charAt(0)&&i.call(this,e)&&!isNaN(+e.slice(1))&&(this[e]=r)},stop:function(){this.done=!0;var t=this.tryEntries[0].completion;if("throw"===t.type)throw t.arg;return this.rval},dispatchException:function(t){if(this.done)throw t;var e=this;function n(n,o){return s.type="throw",s.arg=t,e.next=n,o&&(e.method="next",e.arg=r),!!o}for(var o=this.tryEntries.length-1;o>=0;--o){var a=this.tryEntries[o],s=a.completion;if("root"===a.tryLoc)return n("end");if(a.tryLoc<=this.prev){var c=i.call(a,"catchLoc"),l=i.call(a,"finallyLoc");if(c&&l){if(this.prev<a.catchLoc)return n(a.catchLoc,!0);if(this.prev<a.finallyLoc)return n(a.finallyLoc)}else if(c){if(this.prev<a.catchLoc)return n(a.catchLoc,!0)}else{if(!l)throw Error("try statement without catch or finally");if(this.prev<a.finallyLoc)return n(a.finallyLoc)}}}},abrupt:function(t,e){for(var r=this.tryEntries.length-1;r>=0;--r){var n=this.tryEntries[r];if(n.tryLoc<=this.prev&&i.call(n,"finallyLoc")&&this.prev<n.finallyLoc){var o=n;break}}o&&("break"===t||"continue"===t)&&o.tryLoc<=e&&e<=o.finallyLoc&&(o=null);var a=o?o.completion:{};return a.type=t,a.arg=e,o?(this.method="next",this.next=o.finallyLoc,g):this.complete(a)},complete:function(t,e){if("throw"===t.type)throw t.arg;return"break"===t.type||"continue"===t.type?this.next=t.arg:"return"===t.type?(this.rval=this.arg=t.arg,this.method="return",this.next="end"):"normal"===t.type&&e&&(this.next=e),g},finish:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),N(r),g}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var o=n.arg;N(r)}return o}}throw Error("illegal catch attempt")},delegateYield:function(t,e,n){return this.delegate={iterator:_(t),resultName:e,nextLoc:n},"next"===this.method&&(this.arg=r),g}},n}function r(t,e,r,n,o,i,a){try{var s=t[i](a),c=s.value}catch(t){return void r(t)}s.done?e(c):Promise.resolve(c).then(n,o)}function n(t,e){var r="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!r){if(Array.isArray(t)||(r=function(t,e){if(t){if("string"==typeof t)return o(t,e);var r={}.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?o(t,e):void 0}}(t))||e&&t&&"number"==typeof t.length){r&&(t=r);var n=0,i=function(){};return{s:i,n:function(){return n>=t.length?{done:!0}:{done:!1,value:t[n++]}},e:function(t){throw t},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var a,s=!0,c=!1;return{s:function(){r=r.call(t)},n:function(){var t=r.next();return s=t.done,t},e:function(t){c=!0,a=t},f:function(){try{s||null==r.return||r.return()}finally{if(c)throw a}}}}function o(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=Array(e);r<e;r++)n[r]=t[r];return n}function i(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,s(n.key),n)}}function a(t,e,r){return(e=s(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function s(e){var r=function(e,r){if("object"!=t(e)||!e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var o=n.call(e,r||"default");if("object"!=t(o))return o;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===r?String:Number)(e)}(e,"string");return"symbol"==t(r)?r:r+""}var c=function(){return t=function t(e){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),a(this,"interactiveArticleId",null),a(this,"blocks",null),a(this,"blocksContentPieces",{}),a(this,"userAnswersData",[]),this.blocks=e,this.run()},o=[{key:"run",value:function(){this.blocks.length&&(this.hidePostContent(),this.showBlocksIfJSEnabled(),this.initBlocksAnswers(),this.initRecordRemote(),this.runBlock(this.blocks[0]))}},{key:"hidePostContent",value:function(){document.body.classList.add("seoaic-ia")}},{key:"showBlocksIfJSEnabled",value:function(){var t,e=n(this.blocks);try{for(e.s();!(t=e.n()).done;)t.value.classList.remove("seoaic-ia-hide-if-no-js")}catch(t){e.e(t)}finally{e.f()}}},{key:"initBlocksAnswers",value:function(){var t,e="seoaic-interactive-article-block",r={},o=[],i=n(document.body.getElementsByClassName(e)[0].parentElement.children);try{for(i.s();!(t=i.n()).done;){var a=t.value;a.classList.contains(e)?(r[this.getBlockID(a)]=o,o=[]):o.push(a)}}catch(t){i.e(t)}finally{i.f()}this.blocksContentPieces=r}},{key:"getBlockID",value:function(t){return t.getAttribute("id")}},{key:"showBlock",value:function(t){var e=document.getElementById(t);setTimeout((function(){e.classList.add("show-animate")}),1600)}},{key:"runBlock",value:function(t){var e=this,r=this,o=this.getBlockID(t),i=t.dataset.id,a=t.dataset.type,s=t.getElementsByClassName("seoaic-ia-block-question")[0],c=t.getElementsByClassName("seoaic-ia-block-content")[0].getElementsByTagName("button"),l={id:i,type:a,question:s.textContent,answers:[]};if(this.showBlock(o),c.length){this.showBlockContent(o);var u,f=n(c);try{for(f.s();!(u=f.n()).done;)u.value.addEventListener("click",(function(o){var i,s=o.currentTarget,u=s.dataset.stepId,f=n(c);try{for(f.s();!(i=f.n()).done;)i.value.disabled=!0}catch(t){f.e(t)}finally{f.f()}var h="";if("single"==a){var p=s.dataset.id;h=s.innerText,l.answers.push({id:p,text:h})}else if("multi"==a){var d,y=n(t.querySelectorAll('input[type="checkbox"]:checked'));try{for(y.s();!(d=y.n()).done;){var v=d.value,m=v.dataset.id;l.answers.push({id:m,text:v.value})}}catch(t){y.e(t)}finally{y.f()}}else if("textfield"==a){var g=t.getElementsByTagName("textarea");g[0].disabled=!0,h=g[0].value||"-/-",l.answers.push(h)}e.addUserAnswerData(l),"seoaic_ia_block_#finish#"==u||r.runBlock(r.blocks[u])}),{once:!0})}catch(t){f.e(t)}finally{f.f()}}}},{key:"showBlockContent",value:function(t){var e=this;return new Promise((function(r,o){var i,a=n(e.blocksContentPieces[t]);try{for(a.s();!(i=a.n()).done;)i.value.classList.add("show-animate")}catch(t){a.e(t)}finally{a.f()}}))}},{key:"addUserAnswerData",value:function(t){this.userAnswersData.push(t),this.updateRecordRemote()}},{key:"initRecordRemote",value:(c=e().mark((function t(){var r,n,o;return e().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=JSON.stringify({post_id:this.blocks[0].dataset.postId,blocks_count:this.blocks.length,data:this.userAnswersData}),t.next=3,fetch(wpApiSettings.root+"seoaic/v1/interactive-article-stats",{method:"POST",headers:{"X-WP-Nonce":wpApiSettings.nonce,"Content-Type":"application/json"},body:r});case 3:return n=t.sent,t.next=6,n.json();case 6:(o=t.sent).success&&o.data&&o.data.id&&(this.interactiveArticleId=o.data.id);case 8:case"end":return t.stop()}}),t,this)})),l=function(){var t=this,e=arguments;return new Promise((function(n,o){var i=c.apply(t,e);function a(t){r(i,n,o,a,s,"next",t)}function s(t){r(i,n,o,a,s,"throw",t)}a(void 0)}))},function(){return l.apply(this,arguments)})},{key:"updateRecordRemote",value:function(){this.interactiveArticleId?fetch(wpApiSettings.root+"seoaic/v1/interactive-article-stats/"+this.interactiveArticleId,{method:"PUT",headers:{"X-WP-Nonce":wpApiSettings.nonce,"Content-Type":"application/json"},body:JSON.stringify({data:this.userAnswersData})}):console.error("[InteractiveArticle] No ID found")}}],o&&i(t.prototype,o),s&&i(t,s),Object.defineProperty(t,"prototype",{writable:!1}),t;var t,o,s,c,l}();window.addEventListener("load",(function(){var t=document.getElementsByClassName("seoaic-interactive-article-block");console.log("interactiveArticleBlocks",t),t.length&&new c(t)}))},590:()=>{function t(){"use strict";t=function(){return n};var e,n={},o=Object.prototype,i=o.hasOwnProperty,a=Object.defineProperty||function(t,e,r){t[e]=r.value},s="function"==typeof Symbol?Symbol:{},c=s.iterator||"@@iterator",l=s.asyncIterator||"@@asyncIterator",u=s.toStringTag||"@@toStringTag";function f(t,e,r){return Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}),t[e]}try{f({},"")}catch(e){f=function(t,e,r){return t[e]=r}}function h(t,e,r,n){var o=e&&e.prototype instanceof w?e:w,i=Object.create(o.prototype),s=new A(n||[]);return a(i,"_invoke",{value:P(t,r,s)}),i}function p(t,e,r){try{return{type:"normal",arg:t.call(e,r)}}catch(t){return{type:"throw",arg:t}}}n.wrap=h;var d="suspendedStart",y="suspendedYield",v="executing",m="completed",g={};function w(){}function b(){}function k(){}var E={};f(E,c,(function(){return this}));var L=Object.getPrototypeOf,x=L&&L(L(_([])));x&&x!==o&&i.call(x,c)&&(E=x);var S=k.prototype=w.prototype=Object.create(E);function O(t){["next","throw","return"].forEach((function(e){f(t,e,(function(t){return this._invoke(e,t)}))}))}function j(t,e){function n(o,a,s,c){var l=p(t[o],t,a);if("throw"!==l.type){var u=l.arg,f=u.value;return f&&"object"==r(f)&&i.call(f,"__await")?e.resolve(f.__await).then((function(t){n("next",t,s,c)}),(function(t){n("throw",t,s,c)})):e.resolve(f).then((function(t){u.value=t,s(u)}),(function(t){return n("throw",t,s,c)}))}c(l.arg)}var o;a(this,"_invoke",{value:function(t,r){function i(){return new e((function(e,o){n(t,r,e,o)}))}return o=o?o.then(i,i):i()}})}function P(t,r,n){var o=d;return function(i,a){if(o===v)throw Error("Generator is already running");if(o===m){if("throw"===i)throw a;return{value:e,done:!0}}for(n.method=i,n.arg=a;;){var s=n.delegate;if(s){var c=B(s,n);if(c){if(c===g)continue;return c}}if("next"===n.method)n.sent=n._sent=n.arg;else if("throw"===n.method){if(o===d)throw o=m,n.arg;n.dispatchException(n.arg)}else"return"===n.method&&n.abrupt("return",n.arg);o=v;var l=p(t,r,n);if("normal"===l.type){if(o=n.done?m:y,l.arg===g)continue;return{value:l.arg,done:n.done}}"throw"===l.type&&(o=m,n.method="throw",n.arg=l.arg)}}}function B(t,r){var n=r.method,o=t.iterator[n];if(o===e)return r.delegate=null,"throw"===n&&t.iterator.return&&(r.method="return",r.arg=e,B(t,r),"throw"===r.method)||"return"!==n&&(r.method="throw",r.arg=new TypeError("The iterator does not provide a '"+n+"' method")),g;var i=p(o,t.iterator,r.arg);if("throw"===i.type)return r.method="throw",r.arg=i.arg,r.delegate=null,g;var a=i.arg;return a?a.done?(r[t.resultName]=a.value,r.next=t.nextLoc,"return"!==r.method&&(r.method="next",r.arg=e),r.delegate=null,g):a:(r.method="throw",r.arg=new TypeError("iterator result is not an object"),r.delegate=null,g)}function C(t){var e={tryLoc:t[0]};1 in t&&(e.catchLoc=t[1]),2 in t&&(e.finallyLoc=t[2],e.afterLoc=t[3]),this.tryEntries.push(e)}function N(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function A(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(C,this),this.reset(!0)}function _(t){if(t||""===t){var n=t[c];if(n)return n.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var o=-1,a=function r(){for(;++o<t.length;)if(i.call(t,o))return r.value=t[o],r.done=!1,r;return r.value=e,r.done=!0,r};return a.next=a}}throw new TypeError(r(t)+" is not iterable")}return b.prototype=k,a(S,"constructor",{value:k,configurable:!0}),a(k,"constructor",{value:b,configurable:!0}),b.displayName=f(k,u,"GeneratorFunction"),n.isGeneratorFunction=function(t){var e="function"==typeof t&&t.constructor;return!!e&&(e===b||"GeneratorFunction"===(e.displayName||e.name))},n.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,k):(t.__proto__=k,f(t,u,"GeneratorFunction")),t.prototype=Object.create(S),t},n.awrap=function(t){return{__await:t}},O(j.prototype),f(j.prototype,l,(function(){return this})),n.AsyncIterator=j,n.async=function(t,e,r,o,i){void 0===i&&(i=Promise);var a=new j(h(t,e,r,o),i);return n.isGeneratorFunction(e)?a:a.next().then((function(t){return t.done?t.value:a.next()}))},O(S),f(S,u,"Generator"),f(S,c,(function(){return this})),f(S,"toString",(function(){return"[object Generator]"})),n.keys=function(t){var e=Object(t),r=[];for(var n in e)r.push(n);return r.reverse(),function t(){for(;r.length;){var n=r.pop();if(n in e)return t.value=n,t.done=!1,t}return t.done=!0,t}},n.values=_,A.prototype={constructor:A,reset:function(t){if(this.prev=0,this.next=0,this.sent=this._sent=e,this.done=!1,this.delegate=null,this.method="next",this.arg=e,this.tryEntries.forEach(N),!t)for(var r in this)"t"===r.charAt(0)&&i.call(this,r)&&!isNaN(+r.slice(1))&&(this[r]=e)},stop:function(){this.done=!0;var t=this.tryEntries[0].completion;if("throw"===t.type)throw t.arg;return this.rval},dispatchException:function(t){if(this.done)throw t;var r=this;function n(n,o){return s.type="throw",s.arg=t,r.next=n,o&&(r.method="next",r.arg=e),!!o}for(var o=this.tryEntries.length-1;o>=0;--o){var a=this.tryEntries[o],s=a.completion;if("root"===a.tryLoc)return n("end");if(a.tryLoc<=this.prev){var c=i.call(a,"catchLoc"),l=i.call(a,"finallyLoc");if(c&&l){if(this.prev<a.catchLoc)return n(a.catchLoc,!0);if(this.prev<a.finallyLoc)return n(a.finallyLoc)}else if(c){if(this.prev<a.catchLoc)return n(a.catchLoc,!0)}else{if(!l)throw Error("try statement without catch or finally");if(this.prev<a.finallyLoc)return n(a.finallyLoc)}}}},abrupt:function(t,e){for(var r=this.tryEntries.length-1;r>=0;--r){var n=this.tryEntries[r];if(n.tryLoc<=this.prev&&i.call(n,"finallyLoc")&&this.prev<n.finallyLoc){var o=n;break}}o&&("break"===t||"continue"===t)&&o.tryLoc<=e&&e<=o.finallyLoc&&(o=null);var a=o?o.completion:{};return a.type=t,a.arg=e,o?(this.method="next",this.next=o.finallyLoc,g):this.complete(a)},complete:function(t,e){if("throw"===t.type)throw t.arg;return"break"===t.type||"continue"===t.type?this.next=t.arg:"return"===t.type?(this.rval=this.arg=t.arg,this.method="return",this.next="end"):"normal"===t.type&&e&&(this.next=e),g},finish:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),N(r),g}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var o=n.arg;N(r)}return o}}throw Error("illegal catch attempt")},delegateYield:function(t,r,n){return this.delegate={iterator:_(t),resultName:r,nextLoc:n},"next"===this.method&&(this.arg=e),g}},n}function e(t,e,r,n,o,i,a){try{var s=t[i](a),c=s.value}catch(t){return void r(t)}s.done?e(c):Promise.resolve(c).then(n,o)}function r(t){return r="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},r(t)}function n(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),r.push.apply(r,n)}return r}function o(t,e){var r="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!r){if(Array.isArray(t)||(r=function(t,e){if(t){if("string"==typeof t)return i(t,e);var r={}.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?i(t,e):void 0}}(t))||e&&t&&"number"==typeof t.length){r&&(t=r);var n=0,o=function(){};return{s:o,n:function(){return n>=t.length?{done:!0}:{done:!1,value:t[n++]}},e:function(t){throw t},f:o}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var a,s=!0,c=!1;return{s:function(){r=r.call(t)},n:function(){var t=r.next();return s=t.done,t},e:function(t){c=!0,a=t},f:function(){try{s||null==r.return||r.return()}finally{if(c)throw a}}}}function i(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=Array(e);r<e;r++)n[r]=t[r];return n}function a(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,c(n.key),n)}}function s(t,e,r){return(e=c(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function c(t){var e=function(t,e){if("object"!=r(t)||!t)return t;var n=t[Symbol.toPrimitive];if(void 0!==n){var o=n.call(t,e||"default");if("object"!=r(o))return o;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)}(t,"string");return"symbol"==r(e)?e:e+""}var l=function(){return i=function t(e){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),s(this,"leadID",null),s(this,"form",null),s(this,"closeBtn",null),s(this,"openBtns",[]),s(this,"closedMsgCloseBtn",null),s(this,"stepsWrapper",null),s(this,"progressBar",null),s(this,"stepsDOMElements",[]),s(this,"steps",{}),s(this,"currentStep",1),s(this,"leadData",[]),s(this,"redirectURL",""),s(this,"cookieNameClosed","seoai_lead_form_closed"),s(this,"cookieNameClosedMsg","seoai_lead_form_closed_msg_closed"),this.form=e,this.stepsWrapper=this.form.getElementsByClassName("seoaic-ms-steps")[0],this.closeBtn=this.form.getElementsByClassName("seoaic-ms-close")[0],this.openBtns=this.form.getElementsByClassName("seoaic-ms-open-click"),this.closedMsgCloseBtn=this.form.getElementsByClassName("seoaic-ms-closed-msg-close-icon"),this.stepsDOMElements=this.form.getElementsByClassName("seoaic-ms-step"),this.redirectURL=this.form.dataset.redirecturl,this.progressBar=this.form.getElementsByClassName("seoaic-multistep-progress")[0],this.progressBarPercentage=this.form.getElementsByClassName("seoaic-multistep-progress-percent")[0],this.initRecordRemote(),this.run()},c=[{key:"run",value:function(){if(this.stepsDOMElements.length){var t,e=this.getStepID(this.stepsDOMElements[0]),r=o(this.stepsDOMElements);try{for(r.s();!(t=r.n()).done;){var n=t.value;this.steps[this.getStepID(n)]=n}}catch(t){r.e(t)}finally{r.f()}this.initCloseOpen(),this.runStep(this.steps[e])}}},{key:"setCookie",value:function(t,e,r){var o=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{};o=function(t){for(var e=1;e<arguments.length;e++){var r=null!=arguments[e]?arguments[e]:{};e%2?n(Object(r),!0).forEach((function(e){s(t,e,r[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):n(Object(r)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(r,e))}))}return t}({path:r},o),o.expires instanceof Date&&(o.expires=o.expires.toUTCString());var i=encodeURIComponent(t)+"="+encodeURIComponent(e);for(var a in o){i+="; "+a;var c=o[a];!0!==c&&(i+="="+c)}document.cookie=i}},{key:"deleteCookie",value:function(t){this.setCookie(t,"",document.location.pathname,{"max-age":"-1s"})}},{key:"initCloseOpen",value:function(){var t=this;this.closeBtn.addEventListener("click",(function(e){t.form.classList.add("closed"),t.setCookie(t.cookieNameClosed,"1",document.location.pathname)}));for(var e=0;e<this.openBtns.length;e++)this.openBtns[e].addEventListener("click",(function(e){t.form.classList.remove("closed"),t.deleteCookie(t.cookieNameClosed)}));if(this.closedMsgCloseBtn)for(var r=0;r<this.closedMsgCloseBtn.length;r++)this.closedMsgCloseBtn[r].addEventListener("click",(function(e){e.stopPropagation(),t.setCookie(t.cookieNameClosedMsg,"1",document.location.pathname);var r=t.form.getElementsByClassName("seoaic-ms-closed-msg-container");r.length&&r[0].remove()}))}},{key:"getStepsIDs",value:function(){return Object.keys(this.steps)}},{key:"getStepID",value:function(t){return t.getAttribute("id")}},{key:"showStep",value:function(t){var e=this,r=document.getElementById(t),n=this.currentStep/this.stepsDOMElements.length*100;this.updateProgressBarTo(n),r.classList.remove("hide"),this.currentStep++,setTimeout((function(){e.stepsWrapper.scrollTo({top:e.stepsWrapper.scrollHeight,behavior:"smooth"})}),2e3)}},{key:"updateProgressBarTo",value:function(t){this.progressBar.style.width=t+"%";var e=Math.ceil(t);this.progressBarPercentage.style.setProperty("--num",e);var r=100==t?95:t;this.progressBarPercentage.style.left=r+"%"}},{key:"runStep",value:function(t){var e=this,r=this,n=t.dataset.type,i=t.dataset.autostep,a=t.getElementsByClassName("seoaic-ms-step-question")[0],s=t.getElementsByClassName("seoaic-ms-step-content")[0],c=t.getElementsByClassName("seoaic-ms-step-answers-wrapper")[0],l={type:n,question:a.dataset.origquestion,answer:""},u=s.getElementsByTagName("button");if(this.showStep(this.getStepID(t)),""!=i&&-1!=this.getStepsIDs().indexOf(i))setTimeout((function(){e.runStep(e.steps[i])}),2e3);else if(u.length){var f,h=o(u);try{for(h.s();!(f=h.n()).done;)f.value.addEventListener("click",(function(i){var a=i.currentTarget,u=a.dataset.stepId,f="";try{if("contact_fields"==n){var h,p=o(t.querySelectorAll("input, select"));try{for(p.s();!(h=p.n()).done;){var d=h.value;if(!d.validity.valid)throw d.reportValidity(),new Error("Required field")}}catch(t){p.e(t)}finally{p.f()}}e.hideStepContent(s).then((function(){var i=[],s="";if("single"==n)s=a.dataset.origtext,i.push(s);else if("multi"==n){var u,h=o(t.querySelectorAll('input[type="checkbox"]:checked'));try{for(h.s();!(u=h.n()).done;){var p=u.value;i.push(p.value)}}catch(t){h.e(t)}finally{h.f()}s=(i=i.length?i:["-/-"]).join("; ")}else if("textfield"==n)s=t.getElementsByTagName("textarea")[0].value||"-/-",i.push(s);else if("contact_fields"==n){var d,y=o(t.querySelectorAll("input, select"));try{for(y.s();!(d=y.n()).done;){var v=d.value,m=v.value||"-/-";i.push({field:v.dataset.label,value:m})}}catch(t){y.e(t)}finally{y.f()}s=i.length?i:"-/-",f="column"}return l.answer=s,e.addStepAnswerData(l),r.showStepAnswer(c,i,f)})).then((function(){-1!==u.indexOf("#finish#")?(e.updateRecordRemote("captured"),e.updateProgressBarTo(100),e.openRedirectURL()):r.runStep(r.steps[u])}))}catch(t){}}))}catch(t){h.e(t)}finally{h.f()}}else this.updateRecordRemote("captured"),this.updateProgressBarTo(100),this.openRedirectURL()}},{key:"openRedirectURL",value:function(){var t=this;this.redirectURL&&setTimeout((function(){window.open(t.redirectURL,"_blank")}),3e3)}},{key:"hideStepContent",value:function(t){return new Promise((function(e,r){t||r(),t.classList.add("hide-animate"),setTimeout((function(){e()}),500)}))}},{key:"showStepAnswer",value:function(t,e){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"row";return new Promise((function(i,a){t||a();var s,c=o(e);try{for(c.s();!(s=c.n()).done;){var l=s.value,u=document.createElement("div");if(u.classList.add("seoaic-ms-answer-item"),"string"==typeof l?u.innerText=l:"object"==r(l)&&(u.innerText=l.field+": "+l.value),"column"==n){var f=document.createElement("div");f.classList.add("seoaic-ms-answer-wrapper"),f.appendChild(u),t.appendChild(f)}else t.appendChild(u)}}catch(t){c.e(t)}finally{c.f()}"column"==n&&t.classList.add("seoaic-flex-column"),t.classList.add("show-animate"),setTimeout((function(){i()}),1300)}))}},{key:"addStepAnswerData",value:function(t){this.leadData.push(t),this.updateRecordRemote()}},{key:"initRecordRemote",value:(u=t().mark((function e(){var r,n;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,fetch(wpApiSettings.root+"seoaic/v1/lead",{method:"POST",headers:{"X-WP-Nonce":wpApiSettings.nonce,"Content-Type":"application/json"},body:JSON.stringify({lead_data:this.leadData,title:document.title,url:document.location.href})});case 2:return r=t.sent,t.next=5,r.json();case 5:(n=t.sent).success&&n.data&&n.data.id&&(this.leadID=n.data.id);case 7:case"end":return t.stop()}}),e,this)})),f=function(){var t=this,r=arguments;return new Promise((function(n,o){var i=u.apply(t,r);function a(t){e(i,n,o,a,s,"next",t)}function s(t){e(i,n,o,a,s,"throw",t)}a(void 0)}))},function(){return f.apply(this,arguments)})},{key:"updateRecordRemote",value:function(){var t=this,e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"initiated";this.leadID?fetch(wpApiSettings.root+"seoaic/v1/lead/"+this.leadID,{method:"PUT",headers:{"X-WP-Nonce":wpApiSettings.nonce,"Content-Type":"application/json"},body:JSON.stringify({status:e,lead_data:this.leadData})}).then((function(t){return t.json()})).then((function(r){"captured"==e&&200==r.statusCode&&"captured"==r.data.status&&t.pushGA()})):console.error("[Multistep] No ID found")}},{key:"pushGA",value:function(){window.dataLayer=window.dataLayer||[],dataLayer.push({event:"wpseoai-form-submission"})}}],c&&a(i.prototype,c),l&&a(i,l),Object.defineProperty(i,"prototype",{writable:!1}),i;var i,c,l,u,f}();window.addEventListener("load",(function(){var t=document.getElementsByClassName("seoaic-multistep-form");if(t.length)for(var e=0;e<t.length;e++)new l(t[e])}))}},e={};function r(n){var o=e[n];if(void 0!==o)return o.exports;var i=e[n]={exports:{}};return t[n](i,i.exports,r),i.exports}r.n=t=>{var e=t&&t.__esModule?()=>t.default:()=>t;return r.d(e,{a:e}),e},r.d=(t,e)=>{for(var n in e)r.o(e,n)&&!r.o(t,n)&&Object.defineProperty(t,n,{enumerable:!0,get:e[n]})},r.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),(()=>{"use strict";r(590),r(591)})()})();