%PDF- %PDF-
Direktori : /var/www/projetos/romanian.ongrace.com/wp-content/plugins/otter-blocks/build/blocks/ |
Current File : /var/www/projetos/romanian.ongrace.com/wp-content/plugins/otter-blocks/build/blocks/form.js |
!function(){"use strict";const e=(e,l,o)=>{var i,n;const r=null==e?void 0:e.id,s={},{formFieldsData:a,elemsWithError:d}=(e=>{var t,l,o;const i=[],n=[{label:(null===(t=window)||void 0===t||null===(l=t.themeisleGutenbergForm)||void 0===l?void 0:l.messages["form-submission"])||"Form submission from",value:window.location.href}];return null===(o=[...null==e?void 0:e.querySelectorAll(".otter-form__container .wp-block-themeisle-blocks-form-input"),...null==e?void 0:e.querySelectorAll(".otter-form__container .wp-block-themeisle-blocks-form-textarea")])||void 0===o||o.forEach((e=>{var t,l;const o=null===(t=e.querySelector(".otter-form-input-label__label, .otter-form-textarea-label__label"))||void 0===t?void 0:t.innerHTML,r=e.querySelector(".otter-form-input, .otter-form-textarea-input"),s=null===(l=e.querySelector('.otter-form-input[type="checkbox"]'))||void 0===l?void 0:l.checked;null==r||!r.hasAttribute("required")||null!=r&&r.checkValidity()||i.push(r),o&&null!=r&&r.value&&n.push({label:o,value:null==r?void 0:r.value,type:null==r?void 0:r.type,checked:s})})),{formFieldsData:n,elemsWithError:i}})(e),c=2>(null==a?void 0:a.length),u=function(e){var t;const l=`.protection #${e.id||""}_nonce_field`;return null===(t=e.querySelector(l))||void 0===t?void 0:t.value}(e),m=null==e||null===(i=e.classList)||void 0===i?void 0:i.contains("has-captcha"),v=r&&(null===(n=window.themeisleGutenberg)||void 0===n?void 0:n.tokens[r].token),h=document.createElement("span");if(h.classList.add("spinner"),l.appendChild(h),c)return l.disabled=!1,void l.removeChild(h);if(d.forEach((e=>{null==e||e.reportValidity()})),m&&!v){const e=window.hasOwnProperty("grecaptcha")?"check-captcha":"captcha-not-loaded";o.pullMsg(e,"error").show()}if(0<d.length||m&&!v)l.disabled=!1,l.removeChild(h);else{var b,p,g,w,f,y,k,E,S,L,G,q;s.formInputsData=a,v&&(s.token=null===(E=window.themeisleGutenberg)||void 0===E||null===(S=E.tokens)||void 0===S?void 0:S[r].token),""!==(null==e||null===(b=e.dataset)||void 0===b?void 0:b.emailSubject)&&(s.emailSubject=null==e||null===(L=e.dataset)||void 0===L?void 0:L.emailSubject),null!=e&&null!==(p=e.dataset)&&void 0!==p&&p.optionName&&(s.formOption=null==e||null===(G=e.dataset)||void 0===G?void 0:G.optionName),null!=e&&e.id&&(s.formId=null==e?void 0:e.id),u&&(s.nonceValue=u),s.postUrl=window.location.href,e.classList.contains("can-submit-and-subscribe")&&(s.action="submit-subscribe",s.consent=(null===(q=e.querySelector(".otter-form-consent input"))||void 0===q?void 0:q.checked)||!1);const i=((null===(g=window)||void 0===g||null===(w=g.themeisleGutenbergForm)||void 0===w?void 0:w.root)||window.location.origin+"/wp-json/")+"otter/v1/form/frontend";null===(f=fetch(i,{method:"POST",headers:{"Content-Type":"application/json",Accept:"application/json, */*;q=0.1","X-WP-Nonce":null===(y=window)||void 0===y||null===(k=y.themeisleGutenbergForm)||void 0===k?void 0:k.nonce},credentials:"include",body:JSON.stringify({handler:"submit",payload:s})}).then((e=>e.json())).then((i=>{var n,s;const a=i;if(null!=a&&a.success){const l=null!=a&&a.submitMessage?a.submitMessage:"Success";o.setMsg(l).show(),t(e),setTimeout((()=>{var e;if(0<(null==a||null===(e=a.redirectLink)||void 0===e?void 0:e.length)){let e=document.createElement("a");e.target="_blank",e.href=a.redirectLink,e.click()}}),1e3)}else{var d,c,u,m;let e="";e=null!=a&&a.provider&&null!=a&&null!==(d=a.error)&&void 0!==d&&d.includes("invalid")||null!=a&&null!==(c=a.error)&&void 0!==c&&c.includes("fake")?"invalid-email":null!=a&&a.provider&&null!=a&&null!==(u=a.error)&&void 0!==u&&u.includes("duplicate")||null!=a&&null!==(m=a.error)&&void 0!==m&&m.includes("already")?"already-registered":"try-again",o.pullMsg(e,"error").show(),console.error(null==a?void 0:a.error,null==a?void 0:a.reasons)}var v,b;null!==(n=window.themeisleGutenberg)&&void 0!==n&&null!==(s=n.tokens)&&void 0!==s&&s[r].reset&&(null===(v=window.themeisleGutenberg)||void 0===v||null===(b=v.tokens)||void 0===b||b[r].reset()),l.disabled=!1,l.removeChild(h)})))||void 0===f||f.catch((e=>{var t,i,n,s;console.error(e),o.pullMsg("try-again","error").show(),null!==(t=window.themeisleGutenberg)&&void 0!==t&&null!==(i=t.tokens)&&void 0!==i&&i[r].reset&&(null===(n=window.themeisleGutenberg)||void 0===n||null===(s=n.tokens)||void 0===s||s[r].reset()),l.disabled=!1,l.removeChild(h)}))}},t=e=>{var t;null===(t=[...null==e?void 0:e.querySelectorAll(".otter-form__container .wp-block-themeisle-blocks-form-input"),...null==e?void 0:e.querySelectorAll(".otter-form__container .wp-block-themeisle-blocks-form-textarea")])||void 0===t||t.forEach((e=>{const t=e.querySelector(".otter-form-input, .otter-form-textarea-input");null!=t&&t.value&&(t.value=null)}))};var l;l=()=>{const t=document.querySelectorAll(".wp-block-themeisle-blocks-form");(e=>{var t,l;if(!window.hasOwnProperty("grecaptcha")&&null!==(t=window)&&void 0!==t&&null!==(l=t.themeisleGutenbergForm)&&void 0!==l&&l.reRecaptchaSitekey){const t=document.createElement("script");t.id="recaptcha",document.body.appendChild(t),t.addEventListener("load",(()=>{const t=setInterval((()=>{window.hasOwnProperty("grecaptcha")&&window.grecaptcha.hasOwnProperty("render")&&(e.forEach((e=>{var t;null!=e&&null!==(t=e.classList)&&void 0!==t&&t.contains("has-captcha")&&(e=>{var t,l,o;if(!window.hasOwnProperty("grecaptcha"))return;const{id:i}=e,n=document.createElement("div"),r=e.querySelector(".otter-form__container");null==r||r.insertBefore(n,r.lastChild);const s=null===(t=window.grecaptcha)||void 0===t?void 0:t.render(n,{sitekey:null===(l=window)||void 0===l||null===(o=l.themeisleGutenbergForm)||void 0===o?void 0:o.reRecaptchaSitekey,callback:e=>{var t;null!==(t=window.themeisleGutenberg)&&void 0!==t&&t.tokens||(window.themeisleGutenberg={},window.themeisleGutenberg.tokens={}),window.themeisleGutenberg.tokens[i]={token:e,reset:()=>{var e;return null===(e=window.grecaptcha)||void 0===e?void 0:e.reset(s)}}},"expired-callback":()=>{var e;null!==(e=window.themeisleGutenberg)&&void 0!==e&&e.tokens||(window.themeisleGutenberg={},window.themeisleGutenberg.tokens={}),window.themeisleGutenberg.tokens[i]={token:null,reset:()=>null}}})})(e)})),clearInterval(t))}),200)})),t.src="https://www.google.com/recaptcha/api.js"}})(t),t.forEach((t=>{t.classList.contains("can-submit-and-subscribe")&&(e=>{var t,l,o;const i=e.querySelector(".otter-form__container"),n=e.querySelector(".wp-block-button"),r=document.createElement("div");r.classList.add("otter-form-consent"),i.insertBefore(r,n);const s=document.createElement("input");s.type="checkbox",s.name="o-consent",s.id="o-consent";const a=document.createElement("label");a.innerHTML=(null===(t=window)||void 0===t||null===(l=t.themeisleGutenbergForm)||void 0===l||null===(o=l.messages)||void 0===o?void 0:o.privacy)||"I have read and agreed the privacy statement.",a.htmlFor="o-consent",r.appendChild(s),r.appendChild(a)})(t);const l=t.querySelector("button"),o=new class{constructor(e){var t;this.form=e,this.anchor=e.querySelector(".wp-block-button"),null===(t=this.anchor)||void 0===t||t.classList.add("has-submit-msg"),this.msgElem=document.createElement("div"),this.msgElem.classList.add("o-form-server-response"),this.anchor.appendChild(this.msgElem),this.isVisible=!1,this.visibilityTimeout=void 0,this.visibilityDuration=12e3}toggle(e){this.isVisible=void 0!==e?e:!this.isVisible,this.msgElem.style.display=this.isVisible?"block":"none"}pullMsg(e,t){var l,o;return this.setMsg((null===(l=window)||void 0===l||null===(o=l.themeisleGutenbergForm)||void 0===o?void 0:o.messages[e])||"Messages are missing!",t)}setMsg(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"";switch(this.msgElem.innerHTML=e,this.clean(),t){case"error":this.msgElem.classList.toggle("o-error",!0);break;case"warning":this.msgElem.classList.toggle("o-warning",!0);break;default:this.msgElem.classList.toggle("o-success",!0)}return this}show(e){clearTimeout(this.visibilityTimeout),this.toggle(!0),this.visibilityTimeout=setTimeout((()=>{this.toggle(!1)}),e||this.visibilityDuration)}clean(){this.msgElem.classList.toggle("o-error",!1),this.msgElem.classList.toggle("o-warning",!1),this.msgElem.classList.toggle("o-success",!1)}}(t);t.querySelector('button[type="submit"]')?null==t||t.addEventListener("submit",(i=>{i.preventDefault(),l.disabled||(l.disabled=!0,e(t,l,o))}),!1):null==l||l.addEventListener("click",(i=>{i.preventDefault(),l.disabled||(l.disabled=!0,e(t,l,o))}),!1)}))},"undefined"!=typeof document&&("complete"!==document.readyState&&"interactive"!==document.readyState?document.addEventListener("DOMContentLoaded",l):l())}();