!function(a){"use strict";var t={initialized:!1,modals:{},init:function(t,o){if(!this.initialized){var i=a("#"+t);if(i.length&&o&&o.privacyStatement&&""!==o.privacyStatement.trim()){var e=o.position||"below_checklist";if("hidden"!==e){var n=this.createFabButton(t,o),r=this.placeFabButton(n,e,i,o),s="botsauto-privacy-modal-"+t,l=this.createModal(s,o);a("body").append(l),this.modals[t]={fab:n,fabContainer:r,modal:l,container:i},this.bindEvents(t),this.setupFocusTrap(s),this.initialized=!0}else this.initialized=!0}}},createFabButton:function(t,o){var i=a("<button>",{class:"botsauto-privacy-fab",type:"button","aria-label":o.ariaLabel||"Privacy statement bekijken",role:"button",tabindex:"0",id:"botsauto-privacy-fab-"+t}),e=o.iconClass||"fas fa-shield-alt";return i.html('<i class="'+e+'" aria-hidden="true"></i>'),o.fabColor&&i.css("--ba-privacy-fab-bg",o.fabColor),o.iconColor&&i.css("--ba-privacy-fab-icon",o.iconColor),!1!==o.pulseOnLoad&&i.addClass("botsauto-privacy-fab-pulse"),i},createFabContainer:function(t,o,i){var e=o||{},n=a("<div>",{class:"botsauto-fab-container"});i&&n.addClass("botsauto-fab-container--inline");var r=parseInt(e.fabPadding,10);isNaN(r)&&(r=0),r=Math.max(0,r);var s=parseInt(e.fabMarginTop,10);isNaN(s)&&(s=0),s=Math.max(0,s);var l=parseInt(e.fabMarginBottom,10);return isNaN(l)&&(l=0),l=Math.max(0,l),n.css({padding:r+"px","margin-top":s+"px","margin-bottom":l+"px"}),n.append(t),n},applyInlineFabStyles:function(a,t){a.css("position","static"),t&&a.css("display","inline-flex")},placeFabButton:function(t,o,i,e){var n,r,s,l=!1,c=o||"below_checklist",d=i.attr("id"),p=e||{},b=this,u=function(a){return b.createFabContainer(t,p,a)};switch(c){case"under_password_section":if(d)if((s=a("#botsauto-privacy-anchor-under-password-"+d)).length)return this.applyInlineFabStyles(t,!1),(v=u(!1)).insertAfter(s),v;if((n=i.find(".botsauto-password-description").last()).length)return this.applyInlineFabStyles(t,!1),(v=u(!1)).insertAfter(n),v;break;case"right_of_title":if(d)if((s=a("#botsauto-privacy-anchor-right-of-title-"+d)).length)return l=!0,this.applyInlineFabStyles(t,!0),(v=u(!0)).insertAfter(s),v[0].previousSibling&&3===v[0].previousSibling.nodeType||v.before(" "),v;if((n=i.find(".botsauto-title").first()).length){l=!0,this.applyInlineFabStyles(t,l);var v=u(!0);return n.append(" "),v.appendTo(n),v}break;case"left_of_submit":if(d)if((s=a("#botsauto-privacy-anchor-left-of-submit-"+d)).length)return l=!0,this.applyInlineFabStyles(t,!0),(v=u(!0)).insertAfter(s),v[0].nextSibling&&3===v[0].nextSibling.nodeType||v.after(" "),v;if((n=i.find(".botsauto-submit-row").first()).length){l=!0,this.applyInlineFabStyles(t,l);v=u(!0);return(r=n.find('button[type="submit"], input[type="submit"]').first()).length?(v.insertBefore(r),v.after(" ")):n.prepend(v),v}break;default:return this.applyInlineFabStyles(t,!1),(v=u(!1)).insertAfter(i),v}this.applyInlineFabStyles(t,!1);var f=u(!1);return f.insertAfter(i),f},createModal:function(t,o){var i=a("<div>",{class:"botsauto-privacy-modal",id:t,role:"dialog","aria-modal":"true","aria-labelledby":t+"-title"}),e=a("<div>",{class:"botsauto-privacy-modal__overlay"}),n=a("<div>",{class:"botsauto-privacy-modal__dialog"}),r=a("<div>",{class:"botsauto-privacy-modal__header"}),s=o.iconClass||"fas fa-shield-alt",l=a("<h2>",{class:"botsauto-privacy-modal__title",id:t+"-title",html:'<i class="'+s+'" aria-hidden="true"></i> '+(o.modalTitle||"Privacy statement")}),c=a("<button>",{class:"botsauto-privacy-modal__close",type:"button","aria-label":"Sluiten",html:'<i class="fas fa-times" aria-hidden="true"></i>'});r.append(l).append(c);var d=a("<div>",{class:"botsauto-privacy-modal__body"}),p=a("<div>",{class:"botsauto-privacy-container"});p.html(o.privacyStatement);var b=parseInt(o.privacyPadding,10);isNaN(b)&&(b=16),b=Math.max(0,b);var u=parseInt(o.privacyMarginTop,10);isNaN(u)&&(u=24),u=Math.max(0,u);var v=parseInt(o.privacyMarginBottom,10);isNaN(v)&&(v=24),v=Math.max(0,v),p.css({padding:b+"px","margin-top":u+"px","margin-bottom":v+"px"}),d.append(p);var f=a("<div>",{class:"botsauto-privacy-modal__footer"}),y=a("<button>",{class:"botsauto-privacy-modal__close-btn",type:"button",text:o.closeButtonText||"Sluiten"});return f.append(y),n.append(r).append(d).append(f),i.append(e).append(n),o.fabColor&&i.css("--ba-privacy-fab-bg",o.fabColor),o.modalBgColor&&i.css("--ba-privacy-modal-bg",o.modalBgColor),o.textColor&&i.css("--ba-privacy-modal-text",o.textColor),o.modalButtonColor&&i.css("--ba-privacy-modal-btn-bg",o.modalButtonColor),o.modalButtonTextColor&&i.css("--ba-privacy-modal-btn-text",o.modalButtonTextColor),i},bindEvents:function(t){var o=this,i=this.modals[t];if(i){var e=i.fab,n=i.modal,r=n.attr("id");e.on("click",function(a){a.preventDefault(),a.stopPropagation(),o.openModal(r)}),e.on("keydown",function(a){"Enter"!==a.key&&" "!==a.key||(a.preventDefault(),a.stopPropagation(),o.openModal(r))});var s=n.find(".botsauto-privacy-modal__close"),l=n.find(".botsauto-privacy-modal__close-btn"),c=n.find(".botsauto-privacy-modal__overlay");s.add(l).on("click",function(a){a.preventDefault(),a.stopPropagation(),o.closeModal(r)}),c.on("click",function(a){a.target===this&&o.closeModal(r)}),a(document).on("keydown.botsauto-privacy",function(a){"Escape"===a.key&&n.hasClass("botsauto-privacy-modal-open")&&o.closeModal(r)})}},openModal:function(t){var o=a("#"+t);if(o.length){o.addClass("botsauto-privacy-modal-open"),a("body").css("overflow","hidden");var i=o.find('button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])').first();i.length&&setTimeout(function(){i.focus()},100)}},closeModal:function(t){var o=a("#"+t);if(o.length){o.removeClass("botsauto-privacy-modal-open"),a("body").css("overflow","");var i=t.replace("botsauto-privacy-modal-",""),e=this.modals[i];e&&e.fab&&setTimeout(function(){e.fab.focus()},100)}},setupFocusTrap:function(t){var o=a("#"+t);o.length&&o.on("keydown",function(a){if("Tab"===a.key&&o.hasClass("botsauto-privacy-modal-open")){var t=o.find('button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])');if(0!==t.length){var i=t.first(),e=t.last();a.shiftKey?document.activeElement===i[0]&&(a.preventDefault(),e.focus()):document.activeElement===e[0]&&(a.preventDefault(),i.focus())}}})},destroy:function(t){var o=this.modals[t];o&&(o.fabContainer?o.fabContainer.remove():o.fab&&o.fab.remove(),o.modal&&o.modal.remove(),delete this.modals[t]),a(document).off("keydown.botsauto-privacy")}};a(document).ready(function(){a("[data-botsauto-privacy-statement]").each(function(){var o=a(this),i=o.attr("id");if(i){var e=o.attr("data-botsauto-privacy-statement"),n="";if(e)try{n=atob(e)}catch(a){n=e}var r=o.data("botsauto-privacy-fab-color")||"",s=o.data("botsauto-privacy-icon-class")||"fas fa-shield-alt",l=o.data("botsauto-privacy-icon-color")||"",c=o.data("botsauto-privacy-text-color")||"",d=o.data("botsauto-privacy-modal-bg-color")||"",p=o.data("botsauto-privacy-modal-button-color")||"",b=o.data("botsauto-privacy-modal-button-text-color")||"",u=o.data("botsauto-privacy-modal-title")||"Privacy statement",v=o.data("botsauto-privacy-close-button-text")||"Sluiten",f=o.data("botsauto-privacy-aria-label")||"Privacy statement bekijken",y=!1!==o.data("botsauto-privacy-pulse"),m=o.data("botsauto-privacy-position")||"below_checklist",h=parseInt(o.data("botsauto-privacy-padding"),10);isNaN(h)&&(h=16);var g=parseInt(o.data("botsauto-privacy-margin-top"),10);isNaN(g)&&(g=24);var x=parseInt(o.data("botsauto-privacy-margin-bottom"),10);isNaN(x)&&(x=24);var C=parseInt(o.data("botsauto-privacy-fab-padding"),10);isNaN(C)&&(C=0);var _=parseInt(o.data("botsauto-privacy-fab-margin-top"),10);isNaN(_)&&(_=0);var N=parseInt(o.data("botsauto-privacy-fab-margin-bottom"),10);isNaN(N)&&(N=0),n&&""!==n.trim()&&t.init(i,{privacyStatement:n,fabColor:r,iconClass:s,iconColor:l,textColor:c,modalBgColor:d,modalButtonColor:p,modalButtonTextColor:b,modalTitle:u,closeButtonText:v,ariaLabel:f,pulseOnLoad:y,position:m,privacyPadding:h,privacyMarginTop:g,privacyMarginBottom:x,fabPadding:C,fabMarginTop:_,fabMarginBottom:N})}})}),window.BotsautoPrivacy=t}(jQuery);