File: /mnt/drbd/www/edenhouse/wp-content/plugins/essential-blocks/blocks/toggle-content/frontend/index.js
(()=>{function e(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=Array(t);r<t;r++)n[r]=e[r];return n}document.addEventListener("DOMContentLoaded",(function(t){var r=document.querySelectorAll(".eb-toggle-wrapper");if(r){var n,o=function(t,r){var n="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!n){if(Array.isArray(t)||(n=function(t,r){if(t){if("string"==typeof t)return e(t,r);var n={}.toString.call(t).slice(8,-1);return"Object"===n&&t.constructor&&(n=t.constructor.name),"Map"===n||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?e(t,r):void 0}}(t))||r&&t&&"number"==typeof t.length){n&&(t=n);var o=0,a=function(){};return{s:a,n:function(){return o>=t.length?{done:!0}:{done:!1,value:t[o++]}},e:function(e){throw e},f:a}}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 l,c=!0,i=!1;return{s:function(){n=n.call(t)},n:function(){var e=n.next();return c=e.done,e},e:function(e){i=!0,l=e},f:function(){try{c||null==n.return||n.return()}finally{if(i)throw l}}}}(r);try{var a=function(){var e=n.value,t=e.querySelector(".eb-toggle-switch > input"),r=e.querySelector(".eb-toggle-primary-label"),o=e.querySelector(".eb-toggle-secondary-label"),a=e.querySelector(".eb-toggle-primary-label-text"),l=e.querySelector(".eb-toggle-secondary-label-text"),c=e.querySelector(".eb-toggle-slider"),i=e.querySelector(".eb-toggle-controller"),s=e.querySelector(".eb-toggle-content"),u=e.querySelector(".eb-toggle-seperator"),d=e.getAttribute("data-init-content"),y=e.getAttribute("data-size"),g=e.getAttribute("data-switch-style"),b=e.getAttribute("data-primary-color"),f=e.getAttribute("data-secondary-color"),h=e.getAttribute("data-active-color"),v=e.getAttribute("data-bg-color"),p=e.getAttribute("data-active-bg"),m="inherit",x="inherit",S=(window.getComputedStyle(s.children[0]).display,window.getComputedStyle(s.children[1]).display,function(){switch(y){case"s":return"translateX(22px)";case"m":return"translateX(26px)";case"l":return"translateX(36px)";case"xl":return"translateX(42px)"}}),A=e.querySelector(".eb-text-switch-label").getAttribute("for"),k=e.querySelector("#".concat(A));function w(){"toggle"!==g&&(r.style.background=p||x,o.style.background=v||m),q()}function L(){"toggle"!==g&&(o.style.background=p||x,r.style.background=v||m),E()}function q(){t.checked=!1,s.children[0].classList.add("active"),s.children[0].classList.remove("inactive"),s.children[1].classList.add("inactive"),s.children[1].classList.remove("active"),o.style.color=f,r.style.color=h||b,"toggle"===g&&(l.style.color=f,a.style.color=h||b),"text"!==g&&(i.style.transform="translateX(0px)")}function E(){t.checked=!0,s.children[0].classList.add("inactive"),s.children[0].classList.remove("active"),s.children[1].classList.add("active"),s.children[1].classList.remove("inactive"),r.style.color=b,o.style.color=h,"toggle"===g&&(a.style.color=b,l.style.color=h||f),"text"!==g&&(i.style.transform=S())}"primary"===d?q():(k.checked=!0,E()),k.addEventListener("change",(function(){this.checked?E():q()})),"text"===g&&(r.style.background=v||m,o.style.background=v||m,u.style.background=v||m),r.addEventListener("click",w),o.addEventListener("click",L),"text"===g&&("primary"===d?w():L()),"rounded"==g&&(c.style.borderRadius="21px",i.style.borderRadius=function(){switch(y){case"s":return"10px";case"m":return"13px";case"l":return"18px";case"xl":return"21px"}}()),"primary"===d?q():E(),t.addEventListener("change",(function(){this.checked?E():q()}))};for(o.s();!(n=o.n()).done;)a()}catch(e){o.e(e)}finally{o.f()}}}))})();