HEX
Server: Microsoft-IIS/8.5
System: Windows NT YDAWBH120 6.3 build 9600 (Windows Server 2012 R2 Standard Edition) AMD64
User: tentjecom_web (0)
PHP: 7.4.14
Disabled: NONE
Upload Files
File: D:/HostingSpaces/SBogers10/wingssprayer.komma.pro/vendor/komma/kms/public/js/core.js
function _toConsumableArray(e){return _arrayWithoutHoles(e)||_iterableToArray(e)||_nonIterableSpread()}function _nonIterableSpread(){throw new TypeError("Invalid attempt to spread non-iterable instance")}function _iterableToArray(e){if(Symbol.iterator in Object(e)||"[object Arguments]"===Object.prototype.toString.call(e))return Array.from(e)}function _arrayWithoutHoles(e){if(Array.isArray(e)){for(var t=0,n=new Array(e.length);t<e.length;t++)n[t]=e[t];return n}}function _classCallCheck(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function _defineProperties(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}function _createClass(e,t,n){return t&&_defineProperties(e.prototype,t),n&&_defineProperties(e,n),e}function _typeof(e){return(_typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function createNewEvent(e){var t;return"function"==typeof Event?t=new Event(e):(t=document.createEvent("Event")).initEvent(e,!0,!0),t}function dispatchEventForElement(e,t){document.createEvent?e.dispatchEvent(t):e.fireEvent("on"+t.eventType,t)}Number.isInteger=Number.isInteger||function(e){return"number"==typeof e&&isFinite(e)&&Math.floor(e)===e},function(e,t){"object"===("undefined"==typeof exports?"undefined":_typeof(exports))&&"undefined"!=typeof module?t():"function"==typeof define&&define.amd?define(t):t()}(0,function(){"use strict";function e(e){var t=this.constructor;return this.then(function(n){return t.resolve(e()).then(function(){return n})},function(n){return t.resolve(e()).then(function(){return t.reject(n)})})}var t=setTimeout;function n(){}function i(e){if(!(this instanceof i))throw new TypeError("Promises must be constructed via new");if("function"!=typeof e)throw new TypeError("not a function");this._state=0,this._handled=!1,this._value=void 0,this._deferreds=[],u(e,this)}function a(e,t){for(;3===e._state;)e=e._value;0!==e._state?(e._handled=!0,i._immediateFn(function(){var n=1===e._state?t.onFulfilled:t.onRejected;if(null!==n){var i;try{i=n(e._value)}catch(e){return void r(t.promise,e)}o(t.promise,i)}else(1===e._state?o:r)(t.promise,e._value)})):e._deferreds.push(t)}function o(e,t){try{if(t===e)throw new TypeError("A promise cannot be resolved with itself.");if(t&&("object"===_typeof(t)||"function"==typeof t)){var n=t.then;if(t instanceof i)return e._state=3,e._value=t,void s(e);if("function"==typeof n)return void u((a=n,o=t,function(){a.apply(o,arguments)}),e)}e._state=1,e._value=t,s(e)}catch(t){r(e,t)}var a,o}function r(e,t){e._state=2,e._value=t,s(e)}function s(e){2===e._state&&0===e._deferreds.length&&i._immediateFn(function(){e._handled||i._unhandledRejectionFn(e._value)});for(var t=0,n=e._deferreds.length;t<n;t++)a(e,e._deferreds[t]);e._deferreds=null}function l(e,t,n){this.onFulfilled="function"==typeof e?e:null,this.onRejected="function"==typeof t?t:null,this.promise=n}function u(e,t){var n=!1;try{e(function(e){n||(n=!0,o(t,e))},function(e){n||(n=!0,r(t,e))})}catch(e){if(n)return;n=!0,r(t,e)}}i.prototype.catch=function(e){return this.then(null,e)},i.prototype.then=function(e,t){var i=new this.constructor(n);return a(this,new l(e,t,i)),i},i.prototype.finally=e,i.all=function(e){return new i(function(t,n){if(!e||void 0===e.length)throw new TypeError("Promise.all accepts an array");var i=Array.prototype.slice.call(e);if(0===i.length)return t([]);var a=i.length;function o(e,r){try{if(r&&("object"===_typeof(r)||"function"==typeof r)){var s=r.then;if("function"==typeof s)return void s.call(r,function(t){o(e,t)},n)}i[e]=r,0==--a&&t(i)}catch(e){n(e)}}for(var r=0;r<i.length;r++)o(r,i[r])})},i.resolve=function(e){return e&&"object"===_typeof(e)&&e.constructor===i?e:new i(function(t){t(e)})},i.reject=function(e){return new i(function(t,n){n(e)})},i.race=function(e){return new i(function(t,n){for(var i=0,a=e.length;i<a;i++)e[i].then(t,n)})},i._immediateFn="function"==typeof setImmediate&&function(e){setImmediate(e)}||function(e){t(e,0)},i._unhandledRejectionFn=function(e){"undefined"!=typeof console&&console&&console.warn("Possible Unhandled Promise Rejection:",e)};var c=function(){if("undefined"!=typeof self)return self;if("undefined"!=typeof window)return window;if("undefined"!=typeof global)return global;throw new Error("unable to locate global object")}();"Promise"in c?c.Promise.prototype.finally||(c.Promise.prototype.finally=e):c.Promise=i});var isset=function(e){return null!=e},EasingFunctions={linear:function(e){return e},easeInQuad:function(e){return e*e},easeOutQuad:function(e){return e*(2-e)},easeInOutQuad:function(e){return e<.5?2*e*e:(4-2*e)*e-1},easeInCubic:function(e){return e*e*e},easeOutCubic:function(e){return--e*e*e+1},easeInOutCubic:function(e){return e<.5?4*e*e*e:(e-1)*(2*e-2)*(2*e-2)+1},easeInQuart:function(e){return e*e*e*e},easeOutQuart:function(e){return 1- --e*e*e*e},easeInOutQuart:function(e){return e<.5?8*e*e*e*e:1-8*--e*e*e*e},easeInQuint:function(e){return e*e*e*e*e},easeOutQuint:function(e){return 1+--e*e*e*e*e},easeInOutQuint:function(e){return e<.5?16*e*e*e*e*e:1+16*--e*e*e*e*e}},getScript=function(e,t){var n=document.createElement("script");n.async=1;var i=document.getElementsByTagName("script"),a=i[i.length-1];n.onload=n.onreadystatechange=function(e,i){(i||!n.readyState||/loaded|complete/.test(n.readyState))&&(n.onload=n.onreadystatechange=null,n=void 0,i||t&&t())},n.src=e,a.parentNode.insertBefore(n,a)},debounce=function(e,t,n){var i;return function(){var a=this,o=arguments,r=n&&!i;clearTimeout(i),i=setTimeout(function(){i=null,n||e.apply(a,o)},t),r&&e.apply(a,o)}},Cookie={set:function(e,t,n){var i,a,o,r,s;n?((o=new Date).setTime(o.getTime()+24*n*60*60*1e3),r="; expires="+o.toGMTString()):r="",1===(s=location.host).split(".").length?document.cookie=e+"="+t+r+"; path=/":((a=s.split(".")).shift(),i="."+a.join("."),document.cookie=e+"="+t+r+"; path=/; domain="+i,null!=Cookie.get(e)&&Cookie.get(e)==t||(i="."+s,document.cookie=e+"="+t+r+"; path=/; domain="+i))},get:function(e){for(var t=e+"=",n=document.cookie.split(";"),i=0;i<n.length;i++){for(var a=n[i];" "===a.charAt(0);)a=a.substring(1,a.length);if(0===a.indexOf(t))return a.substring(t.length,a.length)}return null},erase:function(e){Cookie.set(e,"",-1)}},number_format=function(e,t,n,i){e=(e+"").replace(/[^0-9+\-Ee.]/g,"");var a=isFinite(+e)?+e:0,o=isFinite(+t)?Math.abs(t):0,r=void 0===i?",":i,s=void 0===n?".":n,l="";return(l=(o?function(e,t){var n=Math.pow(10,t);return""+Math.round(e*n)/n}(a,o):""+Math.round(a)).split("."))[0].length>3&&(l[0]=l[0].replace(/\B(?=(?:\d{3})+(?!\d))/g,r)),(l[1]||"").length<o&&(l[1]=l[1]||"",l[1]+=new Array(o-l[1].length+1).join("0")),l.join(s)};Element.prototype.closest||(Element.prototype.matches||(Element.prototype.matches=Element.prototype.msMatchesSelector||Element.prototype.webkitMatchesSelector),Element.prototype.closest=function(e){var t=this;if(!document.documentElement.contains(this))return null;do{if(t.matches(e))return t;t=t.parentElement}while(null!==t);return null});var Ajax={get:function(e,t){var n=new XMLHttpRequest,i=document.querySelector('meta[name="csrf-token"]').content;n.open("get",e,!0),n.setRequestHeader("Content-Type","application/json"),n.setRequestHeader("X-CSRF-TOKEN",i),n.setRequestHeader("X-Requested-With","XMLHttpRequest"),n.onreadystatechange=function(){4===n.readyState&&t(n)},n.send()},post:function(e,t,n){var i=new XMLHttpRequest,a=document.querySelector('meta[name="csrf-token"]').content;i.open("post",e,!0),i.setRequestHeader("Content-Type","application/json"),i.setRequestHeader("X-CSRF-TOKEN",a),i.setRequestHeader("X-Requested-With","XMLHttpRequest"),i.onreadystatechange=function(){4===i.readyState&&n(i)},i.send(JSON.stringify(t))}},capitalizeFirstLetter=function(e){return e.charAt(0).toUpperCase()+e.slice(1)};function snakeToCamel(e){return e.replace(/(\-\w)/g,function(e){return e[1].toUpperCase()})}function indexInParent(e){for(var t=e.parentNode.childNodes,n=0,i=0;i<t.length;i++){if(t[i]==e)return n;1==t[i].nodeType&&n++}return-1}function copyToClipboard(e){if(e="string"==typeof e?document.querySelector(e):e,navigator.userAgent.match(/ipad|ipod|iphone/i)){var t=e.contentEditable,n=e.readOnly;e.contentEditable=!0,e.readOnly=!0;var i=document.createRange();i.selectNodeContents(e);var a=window.getSelection();a.removeAllRanges(),a.addRange(i),e.setSelectionRange(0,999999),e.contentEditable=t,e.readOnly=n}else e.select();document.execCommand("copy")}var SearchController=function(){function e(t,n,i,a,o){_classCallCheck(this,e),this.apiUrl="",this.data="",this.dataToLoad="",this.editEntitiesUrl="",this.initialized=!1,this.sectionId=t,this.selector=n,this.mainUlId=a,this.resultCounterId=o,this.disabled=!0,this.inputSelector=i,this.listItemClass="entities-list-item",this.visibleClass="active",this.invisibleClass="hide",this.section=document.getElementById(this.sectionId);var r=document.querySelector(this.selector);r||console.error('SearchController: Could not find the root ul by using the selector "'+this.selector+'"'),this.siteSlug=r.dataset.siteSlug,this.slug=r.dataset.slug,this.activeId=r.dataset.activeId,axios.defaults.headers.common["X-Requested-With"]="XMLHttpRequest"}return _createClass(e,[{key:"init",value:function(e,t){"string"==typeof e?this.apiUrl=e:this.dataToLoad=e,this.editEntitiesUrl=t,this.initialized=!0}},{key:"load",value:function(){if(!1!==this.initialized){var e=this;return new Promise(function(t,n){if(!1===e.initialized&&n("Please initialize the controller with the init method first."),""!==e.apiUrl&&""===e.dataToLoad)axios.get(e.apiUrl).then(function(i){if(i.data&&0!=i.data.length){for(var a=i.data.children.length,o=0;o<a;o++)for(var r=e.createHtmlElement(i.data.children[o]),s=r.length,l=0;l<s;l++)document.querySelector(e.selector).appendChild(r[l]);e.initializeSearch(),t(document.querySelector(e.selector))}else n("The searchable did not get any data from the api")}).catch(function(e){n(e)});else if(""===e.apiUrl&&""!==e.dataToLoad){for(var i=e.dataToLoad.data.children.length,a=0;a<i;a++)for(var o=e.createHtmlElement(e.dataToLoad.data.children[a]),r=o.length,s=0;s<r;s++)document.querySelector(e.selector).appendChild(o[s]);e.initializeSearch(),t(document.querySelector(e.selector))}})}console.error("Please initialize the controller with the init method first.")}},{key:"initializeSearch",value:function(){var e=this,t=this.section,n=document.querySelector(this.inputSelector),i=document.querySelector(this.selector),a=document.getElementById(this.resultCounterId);n.addEventListener("keyup",function(o){for(var r=document.getElementById(e.mainUlId),s=0,l=n.value.toLowerCase(),u=""==l,c=i.querySelectorAll("li"),d=c.length,h=0;h<d;h++){var p=c[h].dataset.title.toLowerCase(),m=JSON.parse(c[h].dataset.model),v=p.indexOf(l)>-1&&!1===u,f=!1;if(!v&&l.length>=3)for(var g in m)if(m.hasOwnProperty(g)&&-1!==String(m[g]).toLowerCase().indexOf(l.toLowerCase())){f=!0;break}v||f?(s++,c[h].classList.add(e.visibleClass),c[h].setAttribute("data-test","found_search_item")):(c[h].classList.remove(e.visibleClass),c[h].removeAttribute("data-test"))}a.innerHTML=s+"",u?(t.classList.remove(e.visibleClass),r.classList.remove(e.invisibleClass)):(t.classList.add(e.visibleClass),r.classList.add(e.invisibleClass))}),i.classList.remove(this.visibleClass)}},{key:"createHtmlElement",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[],n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"";if(!1!==this.initialized){var i=this.activeId,a=e.id,o=e.title,r=e.model,s=e.children,l=e.status,u=e.thumbnail,c=n,d=""!==n?n+" | "+o:o,h=[],p=!0,m=!1,v=void 0;try{for(var f,g=s[Symbol.iterator]();!(p=(f=g.next()).done);p=!0){var _=f.value;h.push(this.createHtmlElement(_,t,d))}}catch(e){m=!0,v=e}finally{try{p||null==g.return||g.return()}finally{if(m)throw v}}var y='\n            <span class="color-status" data-status-type="'.concat(l,'">\n                &nbsp;\n            </span>\n        '),b='\n            <div class="icon" '.concat(u?"style=\"background-image: url('".concat(u,"');\""):""," >\n                ").concat(u?"":"<span>".concat(o?o.substring(0,1):"","</span>"),"\n            </div>\n        "),C='\n            <li data-title="'.concat(o,"\" data-model='").concat(JSON.stringify(r)||JSON.stringify({}),"' class=\"").concat(this.listItemClass," ").concat(a==i?"active":"",'"> \n                <a href="').concat(this.editEntitiesUrl,"/").concat(a,'">                   \n                    ').concat(y,"\n                    ").concat(b,'\n                    <p data-breadcrumb="').concat(c,'">').concat(o,"</p>\n                </a>\n            </li> \n        "),k=(new DOMParser).parseFromString(C,"text/html");t.push(k.body.firstChild);var E=h.length;if(E>0)for(var S=0;S<E;S++){var I=h[S];t.push(I[0])}return t}console.error("Please initialize the controller with the init method first.")}}]),e}(),SortableController=function(){function e(t){_classCallCheck(this,e),t?(this._wrapper=t,this._list=this._wrapper.querySelector("ul"),this._list?"slug"in this._list.dataset?(this.slug=this._list.dataset.slug,this._apiUrl="/kms/api/"+this.slug,this._editEntitiesUrl="/kms/"+this.slug,this._disabled=!0,this._listItemClass="entities-list-item",this._enableSortButton=this._wrapper.querySelector(".entities-order .sortable-button.enable-sortable"),this._enableSortButton?(this._saveSortOrderButton=this._wrapper.querySelector(".entities-order .sortable-button.save-order"),this._saveSortOrderButton?(this._rootItem=null,this._activeId=this._list.dataset.activeId,axios.defaults.headers.common["X-Requested-With"]="XMLHttpRequest",this._updateVisibility(this._list),this.enableSortable=this.enableSortable.bind(this),this.disableSortable=this.disableSortable.bind(this),this._setSortButtonsEnabled(!0)):console.error("SortableController: The sort button could not be found inside the wrapper.",this._wrapper,'Selector: ".entities-order .sortable-button .save-order". Sortable controller stopped working')):console.error("SortableController: The sort button could not be found inside the wrapper.",this._wrapper,'Selector: ".entities-order .sortable-button .enable-sortable". Sortable controller stopped working')):console.error("Make sure that the wrapper contains the data-slug attribute that contains the slug. Sortable controller stopped working."):console.error("SortableController: Expected the wrapper to have an ul. But did not have any. Sortable controller stopped working")):console.error("SortableController: Expected a wrapper but did not get any. Sortable controller stopped working")}return _createClass(e,[{key:"_setSortButtonsEnabled",value:function(e){this._enableSortButton.removeEventListener("click",this.enableSortable),this._saveSortOrderButton.removeEventListener("click",this.disableSortable),e&&(this._enableSortButton.addEventListener("click",this.enableSortable),this._saveSortOrderButton.addEventListener("click",this.disableSortable))}},{key:"_updateVisibility",value:function(e){"UL"!==e.tagName&&console.error("sortableController: Could not update the unordered list diplay style state since the list is no <ul> tag");for(var t=e.querySelectorAll("li ul"),n=t.length,i=0;i<n;i++){var a=t[i];a.style.display="none"!==a.style.display?"none":"";for(var o=a.children.length,r=0;r<o;r++){var s=a.children[r];"UL"===s.tagName&&this._updateVisibility(s)}}}},{key:"_updateSortableJavascript",value:function(){$(".sortable").sortable({connectWith:".sortable",placeholder:"sortable-placeholder",disabled:this._disabled})}},{key:"enableSortable",value:function(){this._enableSortButton.classList.remove("show"),this._saveSortOrderButton.classList.add("show"),this._disabled=!1,$(this._wrapper).sortable({disabled:this._disabled}).addClass("sorting"),this._updateSortableJavascript()}},{key:"disableSortable",value:function(){this._enableSortButton.classList.add("show"),this._saveSortOrderButton.classList.remove("show"),this._disabled=!0,$(this._wrapper).sortable({disabled:this._disabled}).removeClass("sorting"),this._save()}},{key:"_save",value:function(){var e=this._itemsToJson(this._list);this._rootItem.children=e;var t={tree:e=JSON.stringify(this._rootItem)};axios.post(this._apiUrl,t).then(function(e){}).catch(function(e){console.error(e)})}},{key:"_itemsToJson",value:function(e){for(var t=[],n=!1,i=e.querySelectorAll("li."+this._listItemClass),a=i.length,o=0;o<a;o++){var r=i[o];if(r.parentElement===e){r.dataset.json||(console.error('One or more li HTMLElements with class "'+this._listItemClass+'" did not have data-json attribute set while it should.'),n=!0);var s=JSON.parse(r.dataset.json),l=r.querySelector("ul");l?(s.children=this._itemsToJson(l),s.children||(n=!0)):s.children=[],t.push(s)}}return n?null:t}},{key:"load",value:function(){return new Promise(function(e,t){var n=this;axios.get(this._apiUrl).then(function(i){if(i.data&&0!=i.data.length){n._rootItem=i.data;for(var a=i.data.children.length,o=0;o<a;o++){var r=i.data.children[o];n._list.appendChild(n._createHtmlElement(r))}n._updateSortableJavascript(),e(n._list)}else t("The sortable did not get any data from the api")}).catch(function(e){t(e)})}.bind(this))}},{key:"clearList",value:function(){for(;this._list.firstChild;)this._list.removeChild(this._list.firstChild)}},{key:"_createHtmlElement",value:function(e){self=this;var t=self._activeId,n=e.id,i=e.title||"-",a=e.thumbnail,o=e.children,r=e.status,s=e.routes,l={};for(var u in s)s.hasOwnProperty(u)&&(l[u]=s[u]);l=={}&&(l=[]);var c={id:e.id,title:e.title,thumbnail:e.thumbnail,routes:l,status:e.status};c=JSON.stringify(c);for(var d=[],h=o.length,p=0;p<h;p++){var m=o[p];d.push(this._createHtmlElement(m))}var v='\n            <span class="color-status" data-status-type="'.concat(r,'">\n                &nbsp;\n            </span>\n        '),f='\n            <div class="icon">\n                '.concat(a||"<span>".concat(i?i.substring(0,1):"","</span>"),"\n            </div>\n        "),g="\n            <li data-json='".concat(c,"' class=\"").concat(this._listItemClass," ").concat(n==t?"active":"",'"> \n                <a href="').concat(this._editEntitiesUrl,"/").concat(n,'">\n                    ').concat(v,"\n                    ").concat(f,"\n                    <p>").concat(i,"</p>\n                </a>\n            </li> \n        "),_=(new DOMParser).parseFromString(g,"text/html"),y=_.body.firstChild,b=d.length;if(b>0){var C=_.createElement("ul");C.className="sortable";for(var k=0;k<b;k++){var E=d[k];C.appendChild(E)}y.appendChild(C)}return y}}]),e}(),Checkboxes=function(){function e(t){_classCallCheck(this,e),this.attributeWrapper=t,this.attributeKey=this.attributeWrapper.dataset.key,this.input=document.getElementById(this.attributeKey),this.checkboxes=t.querySelectorAll('input[type="checkbox"]'),this.clicked=this.clicked.bind(this),this.updateRealInput=this.updateRealInput.bind(this),this.enableListeners=this.enableListeners.bind(this),this.init=this.init.bind(this),this.init(),this.updateRealInput(),this.enableListeners(!0)}return _createClass(e,[{key:"enableListeners",value:function(e){this.attributeWrapper.removeEventListener("click",this.clicked),e&&this.attributeWrapper.addEventListener("click",this.clicked)}},{key:"clicked",value:function(e){if("INPUT"===!e.target.tagName)return!1;this.updateRealInput()}},{key:"init",value:function(){var e=this.input.value.split(",");this.checkboxes.forEach(function(t){t.checked=-1!==e.indexOf(t.value)})}},{key:"updateRealInput",value:function(){var e=[];this.checkboxes.forEach(function(t){t.checked&&e.push(t.value)});var t=e.join(",");this.input.setAttribute("value",t);var n=document.createEvent("Event");n.initEvent("change",!1,!0),this.input.dispatchEvent(n)}}]),e}(),ComponentAreaCopier=function(){function e(){_classCallCheck(this,e);var t=this;this._componentAreaManagers=[],this._registerButtonClickListenersDebounced=this.debounce(function(){t._registerButtonClickListeners()},50)}return _createClass(e,[{key:"_copy",value:function(e,t){var n=e.getComponentAreaSaveState();t.addNewComponentsBasedOnComponentAreaSaveState(n)}},{key:"registerComponentAreaManager",value:function(e){e instanceof ComponentAreaManager?(this._componentAreaManagers.push(e),this._registerButtonClickListenersDebounced()):console.error("ComponentAreaCopier: Could not register a component area manager since that was not an instance of ComponentAreaManager. Was:",e)}},{key:"_registerButtonClickListeners",value:function(){var e=this;this._componentAreaManagers.forEach(function(t){var n=".js-component-area-button",i=t.getWrapperElement().querySelector(n);i?new ConfirmationController(i).setConfirmCallback(function(t){return function(){e._onClick(t)}}(t)):console.error('ComponentAreaCopier: Could not find the copy button in the following componentAreaManager using this selector "'+n+'": ',t)})}},{key:"_onClick",value:function(e){var t=".js-component-area-select",n=e.getWrapperElement().querySelector(t);if(n){var i=this._findComponentAreaManagerByWrapperId(n.value);if(i){this._copy(e,i);var a=n.children[n.selectedIndex];if(a&&"tab"in a.dataset){var o=a.dataset.tab;window.location.hash="#"+o}document.querySelectorAll(".js-component-area-confirmation").forEach(function(e){e.classList.remove("active")}),i.getWrapperElement().querySelector(".js-component-area-confirmation").classList.add("active")}else console.error("componentAreaCopier: could not copy the structure of "+e.getWrapperElement().id+" to "+n.value)}else console.error('ComponentAreaCopier: Could not find the select in the following componentAreaManager using this selector "'+t+'": ',e)}},{key:"_findComponentAreaManagerByWrapperId",value:function(e){for(var t=this._componentAreaManagers.length,n=0;n<t;n++){var i=this._componentAreaManagers[n];if(e===i.getWrapperElement().id)return i}return null}},{key:"debounce",value:function(e,t,n){var i;return function(){var a=this,o=arguments,r=n&&!i;clearTimeout(i),i=setTimeout(function(){i=null,n||e.apply(a,o)},t),r&&e.apply(a,o)}}}]),e}(),ComponentAreaManager=function(){function e(t,n){_classCallCheck(this,e),this._componentAreaWrapperElement=t,this._componentManagerApiController=n,void 0!==this._componentAreaWrapperElement&&"DIV"===this._componentAreaWrapperElement.tagName?void 0!==this._componentManagerApiController?(this._componentAreaAttributeKey=this._componentAreaWrapperElement.id,this._masterInput=this._componentAreaWrapperElement.querySelector('input[name="'+this._componentAreaAttributeKey+'"]'),this._masterInput?(this._componentAreaContainer=this._componentAreaWrapperElement.querySelector(".js-components"),this._componentAreaContainer?!1 in this._componentAreaWrapperElement.dataset?console.error("The wrapper element must, but did not have a componentAttributeFieldsRegex dataset value"):(this._componentAttributeFieldsRegex=this._componentAreaWrapperElement.dataset.componentAttributeFieldsRegex,this._saveVersion="0.9.1",this._addComponentButtonElements=[],this._eventMap={},this._loaded=!1,this._setAddComponentButtonElements(),this._loadComponentsUsingSaveStateData()):console.error("ComponentAreaManager:constructor the wrapper did not contain a div with class components.")):console.error('ComponentAreaManager:constructor Did not find an hidden input with name "'+this._componentAreaAttributeKey+'" inside of the wrapper.')):console.error("ComponentAreaManager:constructor Did not get the expected _componentManagerApiController."):console.error("ComponentAreaManager:constructor Did not get the expected div element that represents the components wrapper.")}return _createClass(e,[{key:"_setAddComponentButtonElements",value:function(){this._addComponentButtonElements=this._componentAreaWrapperElement.querySelectorAll(".js-add-component");for(var e=this._addComponentButtonElements.length,t=0;t<e;t++){this._addComponentButtonElements[t].addEventListener("click",this._addComponentButtonClicked.bind(this))}}},{key:"_addComponentButtonClicked",value:function(e){var t=this;e.preventDefault();var n=e.target;if(!1 in n.dataset)console.error("ComponentAreaManager: One of the add component buttons was missing the component dataset attribute. Please set it to the name of a valid component");else{var i=new ComponentSaveState;i.id=-1*parseInt(t._componentAreaWrapperElement.dataset.timesAddedComponent),i.componentTypeId=parseInt(n.dataset.componentType),i.sortOrder=0,this._componentManagerApiController.getComponentHtmlElement(i,this._componentAreaWrapperElement.id).then(function(e){t.incrementTimesComponentAddedCounter();var n=e.element;t._addComponent(n),t._updateMasterInput()})}}},{key:"addNewComponentsBasedOnComponentAreaSaveState",value:function(e){e instanceof ComponentAreaSaveState||console.error('ComponentAreaManager: The given "originalComponentAreaSaveState" parameter was not an instance of ComponentAreaSaveState. Not adding its components.');for(var t=this,n=[],i=e.componentsCount,a=0;a<i;a++){var o=e.getComponentSavestateAt(a);n.push(this._componentManagerApiController.getComponentHtmlElement(o,this._componentAreaWrapperElement.id))}Promise.all(n).then(function(e){for(var n=e.length,i=0;i<n;i++){var a=e[i];t.incrementTimesComponentAddedCounter();var o=a.element;t._addComponent(o),t._updateMasterInput()}})}},{key:"incrementTimesComponentAddedCounter",value:function(){return this._componentAreaWrapperElement.dataset.timesAddedComponent=(parseInt(this._componentAreaWrapperElement.dataset.timesAddedComponent)+1).toString()}},{key:"_addComponent",value:function(e){for(var t=this,n=this._findAttributeDataInputs(e),i=n.inputElements.length,a=0;a<i;a++){var o=n.inputElements[a],r=t._debounce(t._attributeInputChanged.bind(t),500);o.addEventListener("change",t._attributeInputChanged.bind(t)),o.addEventListener("blur",t._attributeInputChanged.bind(t)),o.addEventListener("keydown",r.bind(t))}for(var s=this._findComponentableInputs(e),l=n.inputElements.length,u=0;u<l;u++){var c=s.inputElements[u];if(c){var d=t._debounce(t._attributeInputChanged.bind(t),500);c.addEventListener("change",t._attributeInputChanged.bind(t)),c.addEventListener("blur",t._attributeInputChanged.bind(t)),c.addEventListener("keydown",d.bind(t))}}e.querySelector(".js-component-delete").addEventListener("click",function(n){n.preventDefault(),e.parentElement.removeChild(e),t._updateMasterInput()}),e.querySelector(".js-component-move-up").addEventListener("click",function(n){n.preventDefault(),e.previousSibling&&e.parentElement.insertBefore(e,e.previousSibling),t._updateMasterInput()}),e.querySelector(".js-component-move-down").addEventListener("click",function(n){n.preventDefault(),e.nextSibling&&e.nextSibling.nextSibling?e.parentElement.insertBefore(e,e.nextSibling.nextSibling):e.parentElement.appendChild(e),t._updateMasterInput()}),this._putComponentAttributesInTabs(e),this._componentAreaContainer.appendChild(e),this.triggerEvent("componentAdded",[e,this._loaded])}},{key:"_attributeInputChanged",value:function(e){this._updateMasterInput()}},{key:"_updateMasterInput",value:function(){var e=this.getComponentAreaSaveState();this._masterInput.value=JSON.stringify(e)}},{key:"_putComponentAttributesInTabs",value:function(e){var t=e.querySelector(".attributes");if(t){for(var n=t.children,i=n.length,a={},o=0;o<i;o++){var r=n[o];"tab"in r.dataset&&(a.hasOwnProperty(r.dataset.tab)||(a[r.dataset.tab]=[]),a[r.dataset.tab].push(r))}var s=Object.keys(a).length;if(s>0){var l=new DOMParser,u=l.parseFromString('<div class="component-tab">    <ul class="component-tab__list">    </ul>    <div class="component-tab__container">    </div></div>',"text/html"),c=u.body.firstChild;t.appendChild(c);var d=0,h=function(e){if(!a.hasOwnProperty(e))return"continue";var t=(u=l.parseFromString('<li class="component-tab__list-item">    <a class="component-tab__button" data-test="'+e+'">'+e+"</a></li>","text/html")).body.firstChild,n=c.getElementsByClassName("component-tab__list")[0];n.appendChild(t);var i=(u=l.parseFromString('<div class="component-tab__content"></div>',"text/html")).body.firstChild,o=c.getElementsByClassName("component-tab__container")[0];o.appendChild(i);for(var r=a[e].length,h=0;h<r;h++)i.appendChild(a[e][h]);0===d&&(t.classList.add("active"),i.classList.add("active")),t.addEventListener("click",function(e){e.preventDefault();for(var i=0,a=0;a<s;a++){var r=n.children[a];r.classList.remove("active"),r===t&&(r.classList.add("active"),i=a)}for(var l=0;l<s;l++){var u=o.children[l];u.classList.remove("active"),l===i&&u.classList.add("active")}}),d++};for(var p in a)h(p)}}else console.error('Expected to get a "componentElement" but did not. It did not contain a div with class "attributes" in it.')}},{key:"_findAttributeDataInputs",value:function(e){for(var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:void 0,n=[],i=e.getElementsByClassName("attributes")[0].querySelectorAll("input, textarea, select"),a=i.length,o=0;o<a;o++){var r=i[o];void 0!==r.name&&r.name.match(new RegExp(this._componentAttributeFieldsRegex))&&n.push(r)}var s=new FoundComponentInputsModel;return s.inputElements=n,s.componentElement=e,s.componentSaveState=t,s}},{key:"_findComponentableInputs",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:void 0,n=[],i=e.querySelector(".componentableSelectors");if(!i)return new FoundComponentInputsModel;for(var a=i.querySelectorAll("input, textarea, select"),o=a.length,r=0;r<o;r++){var s=a[r];void 0!==s.name&&s.name.match(new RegExp(this._componentAttributeFieldsRegex))&&n.push(s)}var l=new FoundComponentInputsModel;return l.inputElements=n,l.componentElement=e,l.componentSaveState=t,l}},{key:"getComponentElements",value:function(){return this._componentAreaContainer.querySelectorAll(".c-component")}},{key:"getWrapperElement",value:function(){return this._componentAreaWrapperElement}},{key:"getComponentAreaSaveState",value:function(){for(var e=new ComponentAreaSaveState,t=this.getComponentElements(),n=t.length,i=0;i<n;i++){for(var a=t[i],o=this._findAttributeDataInputs(a),r=this._findComponentableInputs(a),s={},l=o.inputElements.length,u=0;u<l;u++){var c=o.inputElements[u];"INPUT"===c.tagName&&"file"===c.type||(s[c.name]=c.value)}for(var d={},h=r.inputElements.length,p=0;p<h;p++){var m=r.inputElements[p];"INPUT"===m.tagName&&"file"===m.type||(d[m.name]=m.value)}var v=new ComponentSaveState;v.id=Number(o.componentElement.dataset.id),v.componentTypeId=Number(o.componentElement.dataset.componentTypeId),v.data=s,v.version=this._saveVersion,v.sortOrder=Number(i),v.componentableData=d,e.addComponentSaveState(v)}return e}},{key:"_loadComponentsUsingSaveStateData",value:function(){var e=this,t=this._masterInput.value;if(!t)return!1;var n=ComponentAreaSaveState.fromJsonString(t);if(!n)return!1;for(var i=[],a=n.componentsCount,o=0;o<a;o++){var r=n.getComponentSavestateAt(o);i.push(this._componentManagerApiController.getComponentHtmlElement(r,this._componentAreaWrapperElement.id))}Promise.all(i).then(function(t){for(var n=t.length,i=0;i<n;i++){var a=t[i].element;e._addComponent(a)}for(var o=0;o<n;o++){var r=t[o].componentSavestate,s=r.data;for(var l in s)if(s.hasOwnProperty(l)&&r.data.hasOwnProperty(l)){var u=e._componentAreaWrapperElement.querySelectorAll('[name="'+l+'"]'),c=u.length;if(c>0)for(var d=0;d<c;d++)u[d].value=s[l];else console.error("Could not load data for field: "+l+" since it could not be found. Skipping it")}var h=r.componentableData;for(var p in h)if(h.hasOwnProperty(p)&&r.componentableData.hasOwnProperty(p)){var m=e._componentAreaWrapperElement.querySelectorAll('[name="'+p+'"]'),v=m.length;if(v>0)for(var f=0;f<v;f++)m[f].value=h[p];else console.error("Could not load data for field: "+p+" since it could not be found. Skipping it")}}isset(sessionStorage.getItem("componentScrollPosition"))&&(e._componentAreaWrapperElement.parentElement.parentElement.parentElement.scrollTop=sessionStorage.getItem("componentScrollPosition")),e.loaded=!0})}},{key:"on",value:function(e,t){return this._eventMap.hasOwnProperty(e)||(this._eventMap[e]=[]),this._eventMap[e].push(t)}},{key:"triggerEvent",value:function(e,t){if(this._eventMap.hasOwnProperty(e))for(var n=this._eventMap[e].length,i=0;i<n;i++){var a=this._eventMap[e][i];t&&t.length>0?a.apply(this,t):a.call(this)}}},{key:"_debounce",value:function(e,t,n){var i;return function(){var a=this,o=arguments,r=n&&!i;clearTimeout(i),i=setTimeout(function(){i=null,n||e.apply(a,o)},t),r&&e.apply(a,o)}}}]),e}(),ComponentManagerApiController=function(){function e(){_classCallCheck(this,e),this.domParser=new DOMParser}return _createClass(e,[{key:"getComponentHtmlElement",value:function(e,t){var n=this;return new Promise(function(i,a){var o={componentAreaAttributeKey:t,componentSaveState:JSON.stringify(e)};axios.post("/api/dynamic/component/resolve",o).then(function(t){var a={element:n._stringToHtmlElement(t.data),componentSavestate:e};i(a)}).catch(function(e){console.error("ComponentManagerApiController:getComponentHtmlElement Could not get HTML of a component because of the following error:",e),a(e)})})}},{key:"getComponentAreaRegexForComponent",value:function(e){if(void 0!==e)return new Promise(function(t,n){axios.post("/api/dynamic/component/attribute_regex",{componentKey:e}).then(function(e){t(e.data)}).catch(function(e){console.error("ComponentManagerApiController:getComponentAreaRegexForComponent Could not get the regex to find inputs for a component because of the following error:",e),n(e)})});console.error("ComponentManagerApiController:getComponentAreaRegexForComponent Could not get the regex for an undefined componentKey. Please specify it.")}},{key:"getAllComponentTypeNames",value:function(){return new Promise(function(e,t){axios.get("/api/dynamic/component").then(function(e){return e.data}).catch(function(e){console.error("ComponentManagerApiController:getAllComponentTypeNames Could not the names of all available componentTypes because of an error:",e),t(e)})})}},{key:"_stringToHtmlElement",value:function(e){return this.domParser.parseFromString(e,"text/html").body.firstElementChild}}]),e}(),FoundComponentInputsModel=function(){function e(){_classCallCheck(this,e),this._inputElements=[],this._componentElement=null,this._componentSaveState=null}return _createClass(e,[{key:"inputElements",get:function(){return this._inputElements},set:function(e){"object"===_typeof(e)?this._inputElements=e:console.error("ComponentSaveState: Did not set inputElements since the parameter was not an array. Actual: ",e)}},{key:"componentElement",get:function(){return this._componentElement},set:function(e){!e instanceof HTMLDivElement?console.error("ComponentSaveState: Did not set componentElement since the parameter was not an HTMLDivElement."):this._componentElement=e}},{key:"componentSaveState",get:function(){return this._componentSaveState},set:function(e){!e instanceof ComponentSaveState?console.error("ComponentSaveState: Did not set componentSaveState since the parameter was not ComponentSaveState."):this._componentSaveState=e}}]),e}(),ComponentSaveState=function(){function e(){_classCallCheck(this,e),this._version="0.9.1",this._id=null,this._componentTypeId=null,this._data={},this._componentableData={},this._sortOrder=null,this.toJSON=this._toJson.bind(this)}return _createClass(e,[{key:"_toJson",value:function(){return{id:this._id,version:this._version,componentTypeId:this._componentTypeId,data:this._data,componentableData:this._componentableData,sortOrder:this._sortOrder}}},{key:"version",get:function(){return this._version},set:function(e){"string"==typeof e?this._version=e:console.error("ComponentSaveState: Did not set version since the parameter was not a string. Actual: ",e)}},{key:"id",get:function(){return this._id},set:function(e){""!==e&&"number"==typeof e?this._id=e:console.error("ComponentSaveState: Did not set the id since the parameter was not a number. Actual: ",_typeof(e),1)}},{key:"componentTypeId",get:function(){return this._componentTypeId},set:function(e){""!==e&&"number"==typeof e?this._componentTypeId=e:console.error("ComponentSaveState: Did not set componentTypeId since the parameter was not a number. Actual: ",_typeof(e),1)}},{key:"data",get:function(){return this._data},set:function(e){"object"===_typeof(e)?this._data=e:console.error("ComponentSaveState: Did not set data since the parameter was not an object. Actual: ",e)}},{key:"sortOrder",get:function(){return this._sortOrder},set:function(e){""!==e&&"number"==typeof e||console.error("ComponentSaveState: Did not set sortOrder since the parameter was not a number. Actual: ",e),this._sortOrder=e}},{key:"componentableData",get:function(){return this._componentableData},set:function(e){"object"===_typeof(e)?this._componentableData=e:console.error("ComponentSaveState: Did not set componentableData since the parameter was not an object. Actual: ",e)}}],[{key:"fromObject",value:function(e){if(e.hasOwnProperty("id")&&"number"==typeof e.id&&e.hasOwnProperty("componentTypeId")&&"number"==typeof e.componentTypeId&&e.hasOwnProperty("version")&&"string"==typeof e.version&&e.hasOwnProperty("sortOrder")&&"number"==typeof e.sortOrder&&e.hasOwnProperty("data")&&"object"===_typeof(e.data)&&e.hasOwnProperty("componentableData")&&"object"===_typeof(e.data)){var t=new this;return t.id=e.id,t.componentTypeId=e.componentTypeId,t.version=e.version,t.sortOrder=e.sortOrder,t.data=e.data,t.componentableData=e.componentableData,t}console.error("Could not create a ComponentSaveState instance from an object since that object did not contain all of the following properties of the correct types: id (number), componentTypeId (number), version (string), sortOrder (number), data (array object). Actual: ",e)}}]),e}(),ComponentAreaSaveState=function(){function e(){_classCallCheck(this,e),this.toJSON=this._toJson.bind(this),this._componentSaveStates=[]}return _createClass(e,[{key:"addComponentSaveState",value:function(e){!e instanceof ComponentSaveState?console.error('ComponentAreaSaveState: The passed "componentSaveState" was not an instance of ComponentSaveState. Actual: ',e):this._componentSaveStates.push(e)}},{key:"getComponentSavestateAt",value:function(e){return this._componentSaveStates[e]}},{key:"_toJson",value:function(){return this._componentSaveStates}},{key:"componentsCount",get:function(){return this._componentSaveStates.length}}],[{key:"fromJsonString",value:function(e){var t=null;try{t=JSON.parse(e)}catch(e){return void console.error("ComponentAreaSaveState: The given jsonString does not represent ComponentAreaSaveState since the json string was not a valid json")}for(var n=new this,i=t.length,a=0;a<i;a++){var o=t[a],r=ComponentSaveState.fromObject(o);n.addComponentSaveState(r)}return n}}]),e}(),CopyText=function(){function e(t){_classCallCheck(this,e),this.element=t,!1 in this.element.dataset&&console.error("CopyText: The given element must have a data-to-copy attribute with the value that you want to copy. But did not have that attribute.",t),this.addEventListeners()}return _createClass(e,[{key:"addEventListeners",value:function(){this.element.addEventListener("click",this.clickHandler.bind(this))}},{key:"clickHandler",value:function(e){e.preventDefault();var t=this.element.dataset.toCopy,n=document.createElement("input");document.body.appendChild(n),n.value=t,n.select(),document.execCommand("copy"),document.body.removeChild(n),n=null}}]),e}(),Currency=function(){function e(t){_classCallCheck(this,e),void 0!==t&&"DIV"===t.tagName?(this._wrapper=t,!1 in this._wrapper.dataset||"string"!=typeof this._wrapper.dataset.incVat?console.error("Currency:constructor the currency wrapper must have a dataset property called incVat that must have a boolean value."):(this._priceEnterdIncludingVat="1"===this._wrapper.dataset.incVat,this._realInput=this._wrapper.querySelector('input[type="hidden"]'),this._realInput?(this._regionContainer=this._wrapper.querySelector(".region"),this._incInput=this._wrapper.querySelector("input.inc_input"),this._incInput?(this._incInput=this._wrapper.querySelector("input.inc_input"),this._exInput=this._wrapper.querySelector("input.ex_input"),this._exInput?(this._exInput=this._wrapper.querySelector("input.ex_input"),this._incInputChanged=this._incInputChanged.bind(this),this._exInputChanged=this._exInputChanged.bind(this),this._vatCalculationResponseReceived=this._vatCalculationResponseReceived.bind(this),this._initialize(),this.controlEventListeners()):console.error("Currency:constructor Missing the expected ex vat input in the currency wrapper.")):console.error("Currency:constructor Missing the expected ex vat input in the currency wrapper.")):console.error("Currency:constructor Missing the expected hidden input in the currency wrapper."))):console.error("Currency:constructor Missing the expected div element that represents the Currency wrapper.")}return _createClass(e,[{key:"controlEventListeners",value:function(){var e=!(arguments.length>0&&void 0!==arguments[0])||arguments[0];this._incInput.removeEventListener("change",this._incInputChanged),this._exInput.removeEventListener("change",this._exInputChanged),e&&(this._incInput.addEventListener("change",this._incInputChanged),this._exInput.addEventListener("change",this._exInputChanged))}},{key:"_incInputChanged",value:function(e){var t=new VatCalculationRequest;t.isIncludingVat=!0,t.price=Math.round(100*this._incInput.value),Ajax.post("/kms/calculateVatAmount",t,this._vatCalculationResponseReceived)}},{key:"_exInputChanged",value:function(e){var t=new VatCalculationRequest;t.isIncludingVat=!1,t.price=Math.round(100*this._exInput.value),Ajax.post("/kms/calculateVatAmount",t,this._vatCalculationResponseReceived)}},{key:"_initialize",value:function(){var e=new VatCalculationRequest;e.isIncludingVat=this._priceEnterdIncludingVat,e.price=""===this._realInput.value?0:this._realInput.value,Ajax.post("/kms/calculateVatAmount",e,this._vatCalculationResponseReceived)}},{key:"_vatCalculationResponseReceived",value:function(e){if(VatCalculationResponse.is(e.response,!0)){var t=VatCalculationResponse.fromJsonString(e.response);this._incInput.value=t.priceIncVatForNumberInput,this._exInput.value=t.priceExVatForNumberInput,this._regionContainer.innerText=t.vatPercentage+"% - "+t.regionDisplayName,this._realInput.value=this._priceEnterdIncludingVat?t.priceIncVat:t.priceExVat}else console.error("Currency:_inputChanged The response was not a valid vatCalculationResponse: "+e.response)}}]),e}(),VatCalculationRequest=function(){function e(){_classCallCheck(this,e),this._price=0,this._isIncludingVat=!1,this.toJSON=this._toJSON.bind(this)}return _createClass(e,[{key:"_toJSON",value:function(){return{price:this._price,isIncludingVat:this._isIncludingVat}}},{key:"price",get:function(){return this._price},set:function(e){this._price=e}},{key:"isIncludingVat",get:function(){return this._isIncludingVat},set:function(e){this._isIncludingVat=e}}],[{key:"fromJsonString",value:function(e){if(!this.is(e))return null;var t=JSON.parse(e),n=new this;return n._price=t.price,n._isIncludingVat=t.isIncludingVat,n}},{key:"is",value:function(e){var t=!(arguments.length>1&&void 0!==arguments[1])||arguments[1],n=null;try{if(!(n=JSON.parse(e)))return t&&console.error("VatCalculationRequest: The given json does not represent a valid VatCalculationRequest since the json string was not a valid json"),!1}catch(e){return t&&console.error("VatCalculationRequest: The given json does not represent a valid VatCalculationRequest since the json string was not a valid json"),!1}return n.hasOwnProperty("price")&&"number"==typeof n.price?!(!n.hasOwnProperty("isIncludingVat")||"boolean"!=typeof n.isIncludingVat)||(t&&console.error("VatCalculationResponse: The object must have a isIncludingVat property that is a boolean. Object: ",n),!1):(t&&console.error("VatCalculationResponse: The object must have a price property that is a number. Object: ",n),!1)}}]),e}(),VatCalculationResponse=function(){function e(){_classCallCheck(this,e),this._priceExVat=0,this._priceExVatFormatted="",this._priceExVatForNumberInput=0,this._priceIncVat=0,this._priceIncVatFormatted="",this._priceIncVatForNumberInput=0,this._vatAmount=0,this._vatPercentage=0,this._vatAmountFormatted="",this._vatAmountForNumberInput=0,this._regionDisplayName=""}return _createClass(e,[{key:"priceExVat",get:function(){return this._priceExVat},set:function(e){this._priceExVat=e}},{key:"priceExVatFormatted",get:function(){return this._priceExVatFormatted},set:function(e){this._priceExVatFormatted=e}},{key:"priceExVatForNumberInput",get:function(){return this._priceExVatForNumberInput},set:function(e){this._priceExVatForNumberInput=e}},{key:"priceIncVat",get:function(){return this._priceIncVat},set:function(e){this._priceIncVat=e}},{key:"priceIncVatFormatted",get:function(){return this._priceIncVatFormatted},set:function(e){this._priceIncVatFormatted=e}},{key:"priceIncVatForNumberInput",get:function(){return this._priceIncVatForNumberInput},set:function(e){this._priceIncVatForNumberInput=e}},{key:"vatAmount",get:function(){return this._vatAmount},set:function(e){this._vatAmount=e}},{key:"vatAmountFormatted",get:function(){return this._vatAmountFormatted},set:function(e){this._vatAmountFormatted=e}},{key:"vatAmountForNumberInput",get:function(){return this._vatAmountForNumberInput},set:function(e){this._vatAmountForNumberInput=e}},{key:"regionDisplayName",get:function(){return this._regionDisplayName},set:function(e){this._regionDisplayName=e}},{key:"vatPercentage",get:function(){return this._vatPercentage},set:function(e){this._vatPercentage=e}}],[{key:"fromJsonString",value:function(e){if(!this.is(e))return null;var t=JSON.parse(e),n=new this;return n._priceExVat=t.priceExVat,n._priceExVatFormatted=t.priceExVatFormatted,n._priceExVatForNumberInput=t.priceExVatForNumberInput,n._priceIncVat=t.priceIncVat,n._priceIncVatFormatted=t.priceIncVatFormatted,n._priceIncVatForNumberInput=t.priceIncVatForNumberInput,n._vatAmount=t.vatAmount,n._vatPercentage=t.vatPercentage,n._vatAmountFormatted=t.vatAmountFormatted,n._vatAmountForNumberInput=t.vatAmountForNumberInput,n._regionDisplayName=t.regionDisplayName,n}},{key:"is",value:function(e){var t=!(arguments.length>1&&void 0!==arguments[1])||arguments[1],n=null;try{if(!(n=JSON.parse(e)))return t&&console.error("VatCalculationResponse: The given json does not represent a valid VatCalculationResponse since the json string was not a valid json"),!1}catch(e){return t&&console.error("VatCalculationResponse: The given json does not represent a valid VatCalculationResponse since the json string was not a valid json"),!1}return n.hasOwnProperty("priceExVat")&&"number"==typeof n.priceExVat?n.hasOwnProperty("priceExVatFormatted")&&"string"==typeof n.priceExVatFormatted?n.hasOwnProperty("priceExVatForNumberInput")&&"string"==typeof n.priceExVatForNumberInput?n.hasOwnProperty("priceIncVat")&&"number"==typeof n.priceIncVat?n.hasOwnProperty("priceIncVatFormatted")&&"string"==typeof n.priceIncVatFormatted?n.hasOwnProperty("priceIncVatForNumberInput")&&"string"==typeof n.priceIncVatForNumberInput?n.hasOwnProperty("vatAmount")&&"number"==typeof n.vatAmount?n.hasOwnProperty("vatAmountFormatted")&&"string"==typeof n.vatAmountFormatted?n.hasOwnProperty("vatAmountForNumberInput")&&"string"==typeof n.vatAmountForNumberInput?n.hasOwnProperty("regionDisplayName")&&"string"==typeof n.regionDisplayName?!(!n.hasOwnProperty("vatPercentage")||"number"!=typeof n.vatPercentage)||(t&&console.error("VatCalculationResponse: The response object must have a vatPercentage property that is a number. Object: ",n),!1):(t&&console.error("VatCalculationResponse: The response object must have a regionDisplayName property that is a string. Object: ",n),!1):(t&&console.error("VatCalculationResponse: The response object must have a vatAmountForNumberInput property that is a string. Object: ",n),!1):(t&&console.error("VatCalculationResponse: The response object must have a vatAmountFormatted property that is a string. Object: ",n),!1):(t&&console.error("VatCalculationResponse: The response object must have a vatAmount property that is a number. Object: ",n),!1):(t&&console.error("VatCalculationResponse: The response object must have a priceIncVatForNumberInput property that is a string. Object: ",n),!1):(t&&console.error("VatCalculationResponse: The response object must have a priceIncVatFormatted property that is a string. Object: ",n),!1):(t&&console.error("VatCalculationResponse: The response object must have a priceIncVat property that is a number. Object: ",n),!1):(t&&console.error("VatCalculationResponse: The response object must have a priceExVatForNumberInput property that is a string. Object: ",n),!1):(t&&console.error("VatCalculationResponse: The response object must have a priceExVatFormatted property that is a string. Object: ",n),!1):(t&&console.error("VatCalculationResponse: The response object must have a priceExVat property that is a number. Object: ",n),!1)}}]),e}(),DocumentManager=function(){function e(t,n,i){if(_classCallCheck(this,e),this.constructedSuccessFully=!1,this.wrapper=t,this.HTML5Uploader=n,this.illegalMoveCount=0,this.accept="documentsAccept"in t.dataset?t.dataset.documentsAccept:void 0,"documentsKey"in t.dataset){this.key=t.dataset.documentsKey,this.translations=JSON.parse(i),this.isSortable="documentsIsSortable"in t.dataset&&"1"===t.dataset.documentsIsSortable,this.extensionThumbsFolder="documentsExtensionThumbsFolder"in t.dataset?t.dataset.documentsExtensionThumbsFolder:"/img/kms/extension_thumbs/",this.availableExtensionThumbs="documentsAvailableExtensionThumbs"in t.dataset?t.dataset.documentsAvailableExtensionThumbs:["svg","pdf","zip","rar","csv","xlsx","mp3","mp4","docx","doc","png","jpg","jpeg","gif"],this.enablePreviewsIfPossible="documentsEnablePreviewsIfPossible"in t.dataset&&"1"===t.dataset.documentsEnablePreviewsIfPossible,this.maxDocuments="documentsMaxDocuments"in t.dataset?t.dataset.documentsMaxDocuments:void 0,this.imageProperties="imageProperties"in t.dataset?t.dataset.imageProperties:null,this.subFolder="subFolder"in t.dataset?t.dataset.subFolder:"documents",this.eventMap={};var a=document.getElementById("entity-form");if(a){var o=a.dataset.maxUploadSize;o&&(this.maxUploadSizeInBytes=o)}if(this.uploadSizeExceededMessage="You cannot upload more files right now. Please save these first before continuing. The limit is:",null!=t){var r=t.getElementsByClassName("files")[0],s=t.querySelector('input[name="'+this.key+'"]');if(r)if(this.documentList=r,s){this.dataInput=s,!1 in t.dataset&&console.error("DocumentManager: The wrapper must have a uploadedDocuments dataset attribute containing a json string representing the uploaded documents as an array of documents. Stopping DocumentManager construction"),""===this.dataInput.value&&(this.dataInput.value="{}");var l=JSON.parse(this.dataInput.value);this.constructedSuccessFully=!0,this._deleteDocumentButtonClicked=this._deleteDocumentButtonClicked.bind(this),this._modifiedDocument=this._modifiedDocument.bind(this),this._drag=this._drag.bind(this),this._drop=this._drop.bind(this),this._dragOver=this._dragOver.bind(this),this._dragLeave=this._dragLeave.bind(this),this._HTML5UploadStarted=this._HTML5UploadStarted.bind(this),this._HTML5UploadProgress=this._HTML5UploadProgress.bind(this),this._HTML5UploadedFile=this._HTML5UploadedFile.bind(this),this._HTML5UploadFailedOrCanceled=this._HTML5UploadFailedOrCanceled.bind(this),this._HTML5UploadFailedOrCanceled=this._HTML5UploadFailedOrCanceled.bind(this),this._initialize(l)}else console.error('DocumentManager: The document uploader needs an input element with name "'+this.key+'" in the given wrapper. It is used to keep track of the states of all documents. Stopping DocumentManager construction');else console.error('DocumentManager: The document uploader needs an ul element with class "files" in the given wrapper')}else console.error("DocumentManager: The wrapper was not a valid html element. Stopping DocumentManager construction")}else console.error("DocumentManager: Make sure that the wrapper contains the attributes key")}return _createClass(e,[{key:"_initialize",value:function(e){if(this.constructedSuccessFully){if(e){for(var t=e.length,n=0;n<t;n++){var i=e[n],a=DocumentModel.fromJson(i);a?this._addDocumentElement(a):(console.error("DocumentManager stumbled upon a document that is not valid upon initializing: "),console.error(i))}this._sortDocuments()}this._updateDataInput(),this._setupHtml5Uploader()}}},{key:"_setupHtml5Uploader",value:function(){this.HTML5Uploader.on("uploadStart",this._HTML5UploadStarted),this.HTML5Uploader.on("updateProgress",this._HTML5UploadProgress),this.HTML5Uploader.on("uploadComplete",this._HTML5UploadedFile),this.HTML5Uploader.on("uploadFailed",this._HTML5UploadFailedOrCanceled),this.HTML5Uploader.on("uploadCanceled",this._HTML5UploadFailedOrCanceled)}},{key:"_HTML5UploadFailedOrCanceled",value:function(e,t,n){var i=e.documentElement;i&&(this.documentList.removeChild(i),this._updateDataInput(),alert(this.translations.upload_failed))}},{key:"_HTML5UploadedFile",value:function(e,t){var n=e.documentElement;if(n){var i=JSON.parse(t),a=DocumentModel.fromJson(i);this._attachDocumentModelToDocumentElement(n,a),this._updateDocumentElementWithDocumentData(n,a),this._updateSortOrder(),n.querySelector(".thumb").classList.remove("is-uploading"),n.querySelector(".percentage").remove()}}},{key:"_HTML5UploadProgress",value:function(e,t){var n=e.documentElement;n&&(t&&100===t?t=99:t||(t=1),n.querySelector(".percentage").setAttribute("aria-valuenow",t))}},{key:"_HTML5UploadStarted",value:function(e){var t=this._createDocumentElement();this._attachDocumentModelToDocumentElement(t);var n=DocumentModel.fromJson(JSON.parse(t.dataset.json));n.state=DOCUMENT_STATE_NEW,n.name=e.name,n.file_url=e.name,t=this._updateDocumentElementWithDocumentData(t,n),this._attachDocumentModelToDocumentElement(t,n);t.querySelector(".thumb").insertAdjacentHTML("afterbegin",'<span class="percentage" role="progressbar" aria-valuemin="0" aria-valuemax="100"></span>'),this.documentList.appendChild(t),t.querySelector(".drag-icon").classList.add("is-hidden"),t.querySelector(".thumb").classList.add("is-uploading"),e.documentElement=t}},{key:"_deleteDocumentButtonClicked",value:function(e){var t=e.target.parentElement,n=JSON.parse(t.dataset.json);n.state!==DOCUMENT_STATE_DELETED&&(n.state!==DOCUMENT_STATE_NEW?(n.state=DOCUMENT_STATE_DELETED,t.classList.add(DOCUMENT_STATE_DELETED),t.dataset.json=JSON.stringify(n)):this.documentList.removeChild(t),this._updateDataInput(),this._updateSortOrder())}},{key:"_modifiedDocument",value:function(e){var t=e.target.parentElement.parentElement,n=JSON.parse(t.dataset.json);if(n.state!==DOCUMENT_STATE_DELETED){n.state!==DOCUMENT_STATE_NEW&&(n.state=DOCUMENT_STATE_MODIFIED);var i=t.getElementsByClassName("name")[0];n.name=i.value,t.dataset.json=JSON.stringify(n),t.classList.add(DOCUMENT_STATE_MODIFIED),this._updateDataInput()}}},{key:"_addDocumentElement",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:void 0,t=this._createDocumentElement();void 0!==e&&this._updateDocumentElementWithDocumentData(t,e),this._attachDocumentModelToDocumentElement(t,e),e&&(this._makeElementRespondToDragging(t,this.isSortable),this._makeElementRespondToDragOverAndLeave(t,this.isSortable),this._makeElementRespondToDrop(t,this.isSortable)),this.documentList.appendChild(t)}},{key:"_attachDocumentModelToDocumentElement",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:void 0;return void 0!==t?e.dataset.json=JSON.stringify(t):((t=new DocumentModel).sort_order=this.getCurrentDocumentsCount()+1,e.dataset.json=JSON.stringify(t)),e}},{key:"_updateDocumentElementWithDocumentData",value:function(e,t){var n=e.querySelector(".name"),i=e.querySelector(".path"),a=e.querySelector(".thumb");if(i&&(i.innerText=t.file_url),n&&n.setAttribute("value",t.name),a&&t.file_url){var o=this._getThumbUrlUsingDocumentModel(t),r=this._getExtensionFromFileName(t.file_url);a.setAttribute("data-filetype",r);var s=a.querySelector(".thumb__image");a&&(o&&"new"!==t.state?(s.style.backgroundImage="url('"+o+"')",a.classList.add("has-image")):-1!==this.availableExtensionThumbs.indexOf(r)&&(s.style.backgroundImage="url('"+this.extensionThumbsFolder+r+".svg')",a.classList.add("has-icon")))}return e}},{key:"_incrementIllegalMoveCount",value:function(){this.illegalMoveCount++,this.illegalMoveCount>=3&&(this.illegalMoveCount=0,this._say("Je kunt niet tussen 2 lijsten slepen."))}},{key:"_say",value:function(e){if(void 0!==SpeechSynthesisUtterance){var t=new SpeechSynthesisUtterance,n=window.speechSynthesis.getVoices();t.voice=n[10],t.voiceURI="native",t.volume=1,t.rate=1,t.pitch=.8,t.text=e,t.lang="nl-NL",speechSynthesis.speak(t)}}},{key:"_createDocumentElement",value:function(){var e=document.createElement("li");e.className="document";var t=document.createElement("input");t.setAttribute("class","name"),t.setAttribute("type","text"),t.addEventListener("change",this._modifiedDocument);var n=document.createElement("p");n.setAttribute("class","path");var i=document.createElement("div");i.setAttribute("class","content-wrapper"),i.appendChild(t),i.appendChild(n);var a=document.createElement("span");a.className="delete",a.addEventListener("click",this._deleteDocumentButtonClicked);var o=document.createElement("span");o.className="drag-icon";var r=document.createElement("div");r.className="thumb",r.setAttribute("draggable","false");var s=document.createElement("div");s.className="thumb__image",r.appendChild(s);var l=document.createElement("input");return l.setAttribute("type","file"),l.setAttribute("name",this.key+"-"+(this.getCurrentDocumentsCount()+1)),this.accept&&l.setAttribute("accept",this.accept),e.appendChild(l),l.style.display="none",e.appendChild(o),e.appendChild(r),e.appendChild(i),e.appendChild(a),e}},{key:"receiveFile",value:function(e){if(e){if(this.getCurrentDocumentsCount()<this.maxDocuments){var t=this._createDocumentElement();if(this._attachDocumentModelToDocumentElement(t),!1===this.HTML5Uploader.isSupported())t=this._giveDocumentElementAFile(t,e),this.documentList.appendChild(t),this._formSizeExceeded()&&t.parentElement.removeChild(t),this._updateSortOrder();else{var n={imageProperties:this.imageProperties,subFolder:this.subFolder};this.HTML5Uploader.upload(e,JSON.stringify(n))}}}else console.warn("DocumentManager:receiveFile: Expected to get a file but did not get one")}},{key:"getCurrentDocumentsCount",value:function(){var e=arguments.length>0&&void 0!==arguments[0]&&arguments[0],t=this.documentList.getElementsByClassName("document"),n=t.length,i=n;if(!e)for(var a=0;a<n;a++){var o=t[a];if("json"in o.dataset!=!1)JSON.parse(o.dataset.json).state===DOCUMENT_STATE_DELETED&&i--}return i}},{key:"_giveDocumentElementAFile",value:function(e,t){var n=t.name,i=this._getExtensionFromFileName(n),a=(this._previewThumbUrlIsImage(n),e.querySelector(".name")),o=e.querySelector(".thumb"),r=(e.querySelector(".content-wrapper"),e.querySelector(".delete"),e.querySelector(".drag-icon")),s=e.querySelector('input[type="file"]');if(r.style.display="none",s&&!s.files[0]&&(s.files=new FileList(t)),o.setAttribute("data-filetype",i),-1!==this.availableExtensionThumbs.indexOf(i)){var l=o.querySelector("thumb__image");l.style.backgroundImage="url('"+this.extensionThumbsFolder+i+".svg')",l.classList.add("has-icon")}return a.value=n,e}},{key:"_getThumbUrlUsingDocumentModel",value:function(e){if(e){var t=e.file_url;if(""!==e.thumb_image_url&&(t=e.thumb_image_url),this._previewThumbUrlIsImage(t))return t}return!1}},{key:"_previewThumbUrlIsImage",value:function(e){if(!this.enablePreviewsIfPossible)return!1;switch(this._getExtensionFromFileName(e)){case"png":case"jpg":case"jpeg":case"gif":return e;case"pdf":default:return!1}}},{key:"_getExtensionFromFileName",value:function(e){var t=e.split(/[.]+/).pop();return t===e?"":t.toLowerCase()}},{key:"_formSizeExceeded",value:function(){if(this.maxUploadSizeInBytes){var e=!1,t=0;if(this.documentList.querySelectorAll('input[type="file"]').forEach(function(e){if(1===e.files.length){var n=e.files[0];t+=n.size}}),console.log("max upload size in bytes: "+this.maxUploadSizeInBytes+" current upload size in bytes: "+t),t>this.maxUploadSizeInBytes){var n=this.maxUploadSizeInBytes/1048576;e=!0,alert(this.uploadSizeExceededMessage+" "+n+" MegaBytes")}return e}return!1}},{key:"_updateDataInput",value:function(){for(var e=[],t=this.documentList.children,n=t.length,i=0;i<n;i++){var a=t[i];"json"in a.dataset&&e.push(JSON.parse(a.dataset.json))}this.getCurrentDocumentsCount()>=this.maxDocuments?this.wrapper.querySelector(".drag-and-drop-area").classList.add("is-hidden"):this.wrapper.querySelector(".drag-and-drop-area").classList.remove("is-hidden"),this.dataInput.value=JSON.stringify(e);var o=createNewEvent("change");dispatchEventForElement(this.dataInput,o)}},{key:"_updateSortOrder",value:function(){for(var e=this.documentList.children,t=e.length,n=1,i=0;i<t;i++){var a=e[i];if("json"in a.dataset!=!1){var o=JSON.parse(a.dataset.json);o.state!==DOCUMENT_STATE_DELETED&&(o.sort_order=n,o.state!==DOCUMENT_STATE_NEW&&(o.state=DOCUMENT_STATE_MODIFIED),a.dataset.json=JSON.stringify(o),a.classList.add(DOCUMENT_STATE_MODIFIED),n++)}}this._updateDataInput()}},{key:"_sortDocuments",value:function(){var e=this.documentList.children;(e=Array.prototype.slice.call(e)).sort(function(e,t){var n=JSON.parse(e.dataset.json),i=JSON.parse(t.dataset.json);return n.sort_order<i.sort_order?-1:1});for(var t=e.length,n=1;n<t;n++)this.documentList.removeChild(e[n]),this.documentList.length>1?this.documentList.insertBefore(e[n],this.documentList.firstChild):this.documentList.appendChild(e[n])}},{key:"_makeElementRespondToDragging",value:function(e){var t=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];return e.setAttribute("draggable",t?"true":"false"),e.id=this.key+"_"+this.getCurrentDocumentsCount(),t?(e.removeEventListener("dragstart",this._drag),e.addEventListener("dragstart",this._drag)):e.removeEventListener("dragstart",this._drag),this}},{key:"_makeElementRespondToDrop",value:function(e){return!(arguments.length>1&&void 0!==arguments[1])||arguments[1]?(e.removeEventListener("drop",this._drop),e.addEventListener("drop",this._drop)):e.removeEventListener("drop",this._drop),this}},{key:"_makeElementRespondToDragOverAndLeave",value:function(e){!(arguments.length>1&&void 0!==arguments[1])||arguments[1]?(e.removeEventListener("dragover",this._dragOver),e.removeEventListener("dragleave",this._dragLeave),e.addEventListener("dragover",this._dragOver),e.addEventListener("dragleave",this._dragLeave)):(e.removeEventListener("dragover",this._dragOver),e.removeEventListener("dragleave",this._dragLeave))}},{key:"_drag",value:function(e){if(e.target.id){e.stopPropagation(),e.dataTransfer.setData("text",e.target.id);var t=document.getElementById(e.target.id);this._triggerEvent("drag",t)}}},{key:"_dragOver",value:function(e){if(e.preventDefault(),e.stopPropagation(),e.target.id){var t=e.dataTransfer.getData("text"),n=document.getElementById(t);this._enableOrDisablePointerEventsOnChildrenOfElement(e.target,!1),e.target.classList.add("isDropTarget"),this._triggerEvent("dragLeave",[n,e.target])}}},{key:"_dragLeave",value:function(e){if(e.target.id){e.stopPropagation();var t=e.dataTransfer.getData("text"),n=document.getElementById(t);this._enableOrDisablePointerEventsOnChildrenOfElement(e.target,!0),e.target.classList.remove("isDropTarget"),this._triggerEvent("dragLeave",[n,e.target])}}},{key:"_drop",value:function(e){if(e.preventDefault(),e.target.id){var t=e.dataTransfer.getData("text"),n=document.getElementById(t),i=e.target;if(i.classList.remove("isDropTarget"),i.parentElement===n.parentElement){var a=document.createElement("div");n.parentElement.insertBefore(a,n),n.parentElement.insertBefore(n,i),n.parentElement.insertBefore(i,a),a.parentElement.removeChild(a),this._triggerEvent("drop",[n,i]),this._enableOrDisablePointerEventsOnChildrenOfElement(i,!0),this._updateSortOrder()}else this._incrementIllegalMoveCount()}}},{key:"_enableOrDisablePointerEventsOnChildrenOfElement",value:function(e,t){for(var n=e.children.length,i=1;i<n;i++){e.children[i].style.pointerEvents=!1===t?"none":null;for(var a=e.children.children,o=1;o<a;o++)this._enableOrDisablePointerEventsOnChildrenOfElement(e.children.children[i],t)}}},{key:"on",value:function(e,t){return this.eventMap.hasOwnProperty(e)||(this.eventMap[e]=[]),this.eventMap[e].push(t)}},{key:"_triggerEvent",value:function(e,t){if(this.eventMap.hasOwnProperty(e))for(var n=this.eventMap[e].length,i=0;i<n;i++){var a=this.eventMap[e][i];t&&t.length>0?a.apply(this,t):a.call(this)}}}]),e}(),DocumentModel=function(){function e(){_classCallCheck(this,e),this.id=-1,this.file_url="",this.state=DOCUMENT_STATE_NEW,this.name="",this.sort_order=1,this.thumb_image_url="",this.small_image_url="",this.medium_image_url="",this.large_image_url="",this.documentable_id=-1,this.documentable_type="",this.created_at="",this.updated_at=""}return _createClass(e,null,[{key:"isValidDocumentJson",value:function(e){return e.hasOwnProperty("id")&&e.hasOwnProperty("file_url")&&e.hasOwnProperty("state")&&e.hasOwnProperty("name")&&e.hasOwnProperty("sort_order")&&e.hasOwnProperty("thumb_image_url")&&e.hasOwnProperty("small_image_url")&&e.hasOwnProperty("medium_image_url")&&e.hasOwnProperty("large_image_url")&&e.hasOwnProperty("documentable_id")&&e.hasOwnProperty("documentable_type")&&e.hasOwnProperty("created_at")&&e.hasOwnProperty("updated_at")}},{key:"fromJson",value:function(t){if(!e.isValidDocumentJson(t))return console.error("DocumentModel: Tried to create an instance of invalid json data: "),console.error(t),!1;var n=new e;return n.id=t.id,n.file_url=t.file_url,n.state=t.state,n.name=t.name,n.sort_order=t.sort_order,n.thumb_image_url=t.thumb_image_url,n.small_image_url=t.small_image_url,n.medium_image_url=t.medium_image_url,n.large_image_url=t.large_image_url,n.documentable_id=t.id,n.documentable_type=t.documentable_type,n.created_at=t.created_at,n.updated_at=t.updated_at,n}}]),e}(),DOCUMENT_STATE_NEW="new",DOCUMENT_STATE_PRISTINE="pristine",DOCUMENT_STATE_MODIFIED="modified",DOCUMENT_STATE_DELETED="deleted",FileList=function e(){for(var t,n=arguments.length,i=new Array(n),a=0;a<n;a++)i[a]=arguments[a];if(_classCallCheck(this,e),(i=(t=[]).concat.apply(t,_toConsumableArray(i))).length&&!i.every(function(e){return e instanceof File}))throw new TypeError("expected argument to FileList is File or array of File objects");var o=new ClipboardEvent("").clipboardData||new DataTransfer,r=!0,s=!1,l=void 0;try{for(var u,c=i[Symbol.iterator]();!(r=(u=c.next()).done);r=!0){var d=u.value;o.items.add(d)}}catch(e){s=!0,l=e}finally{try{r||null==c.return||c.return()}finally{if(s)throw l}}return o.files},FileDragAndDropHandler=function(){function e(t){_classCallCheck(this,e),this.hooks=[],this.selectButton=t.querySelector("button.select"),this.selectButton?(this.fileCatcherInput=t.querySelector('input[type="file"]'),this.fileCatcherInput?(this.makeElementRespondToDragOverAndLeave(t),this.makeElementRespondToDrop(t),this.makeElementRespondToClick(t),this.makeFileInputPassFilesToHooks()):console.log("FileDragAndDropHandler:constructor The document area must have file input. But did not have one. Not responding to drag and drop")):console.log("FileDragAndDropHandler:constructor The document area must have a button in it with class select. But did not have one. Not responding to drag and drop")}return _createClass(e,[{key:"makeFileInputPassFilesToHooks",value:function(){var e=this;this.fileCatcherInput.addEventListener("change",function(t){for(var n=t.target.files.length,i=0;i<n;i++){var a=t.target.files[i];e.createFileListForFileAndPassToHooks(a)}t.target.value=""})}},{key:"makeElementRespondToClick",value:function(e){var t=this;e.addEventListener("click",function(e){t.fileCatcherInput.click()})}},{key:"hookTo",value:function(e){"function"==typeof e.receiveFile?this.hooks.push(e):console.error('The given hookable does not have a required receiveFile method / function. Not hooking the given "hookable".')}},{key:"makeElementRespondToDrop",value:function(e){return!(arguments.length>1&&void 0!==arguments[1])||arguments[1]?(e.removeEventListener("drop",this.drop.bind(this)),e.addEventListener("drop",this.drop.bind(this))):e.removeEventListener("drop",this.drop.bind(this)),this}},{key:"makeElementRespondToDragOverAndLeave",value:function(e){!(arguments.length>1&&void 0!==arguments[1])||arguments[1]?(e.removeEventListener("dragover",this.dragOver.bind(this)),e.removeEventListener("dragleave",this.dragLeave.bind(this)),e.addEventListener("dragover",this.dragOver.bind(this)),e.addEventListener("dragleave",this.dragLeave.bind(this))):(e.removeEventListener("dragover",this.dragOver.bind(this)),e.removeEventListener("dragleave",this.dragLeave.bind(this)))}},{key:"dragOver",value:function(e){e.preventDefault(),e.stopPropagation(),e.target.id&&(this.enableOrDisablePointerEventsOnChildrenOfElement(e.target,!1),e.target.classList.add("isDropTarget"))}},{key:"dragLeave",value:function(e){e.target.id&&(e.stopPropagation(),this.enableOrDisablePointerEventsOnChildrenOfElement(e.target,!0),e.target.classList.remove("isDropTarget"))}},{key:"drop",value:function(e){e.preventDefault();var t=e.target;if(t.classList.remove("isDropTarget"),this.enableOrDisablePointerEventsOnChildrenOfElement(t,!0),e.preventDefault(),e.dataTransfer.items){for(var n=0;n<e.dataTransfer.items.length;n++)if("file"===e.dataTransfer.items[n].kind){var i=e.dataTransfer.items[n].getAsFile();this.createFileListForFileAndPassToHooks(i)}}else for(var a=0;a<e.dataTransfer.files.length;a++){var o=e.dataTransfer.files[a];this.createFileListForFileAndPassToHooks(o)}}},{key:"createFileListForFileAndPassToHooks",value:function(e){for(var t=this.hooks.length,n=0;n<t;n++)this.hooks[n].receiveFile(e)}},{key:"enableOrDisablePointerEventsOnChildrenOfElement",value:function(e,t){for(var n=e.children.length,i=1;i<n;i++){e.children[i].style.pointerEvents=!1===t?"none":null;for(var a=e.children.children,o=1;o<a;o++)this.enableOrDisablePointerEventsOnChildrenOfElement(e.children.children[i],t)}}}]),e}(),HTML5Uploader=function(){function e(t,n,i,a){_classCallCheck(this,e),this._constructedSuccessfully=!1,t||"string"==typeof t?(this._uploadUrl=t,n?(this._maxPostSize=n,i?(this._maxUploadSize=i,a?(this._translations=JSON.parse(a),this._eventMap={},this.isSupported()?(this.csrfTokenContainer=document.querySelector('meta[name="csrf-token"]'),this.csrfTokenContainer?this._constructedSuccessfully=!0:console.error('No csrf-token could be found in a meta tag with name "csrf-token". Not initializing Html5Uploader')):console.warn("HTML 5 file upload is not supported. Not initializing Html5Uploader")):console.error("Did not get the translations. Not initializing Html5Uploader")):console.error("Did not get the maximum upload size. Not initializing Html5Uploader")):console.error("Did not get the maximum post size. Not initializing Html5Uploader")):console.error("Did not get a valid upload url. Not initializing Html5Uploader")}return _createClass(e,[{key:"isSupported",value:function(){return void 0!==window.FormData}},{key:"receiveFile",value:function(e){this.isSupported()||console.error("HTML 5 file upload is not supported. Not uploading file.")}},{key:"upload",value:function(e,t){if(this._verifyFileSizeOrShowError(e)&&!1!==this._constructedSuccessfully){var n=this,i=new FormData;i.append(this.escapeFileNameForFormField(e.name),e),i.append("extraData",t);var a=new XMLHttpRequest;a.upload.addEventListener("progress",function(e,t){return function(i){n._updateProgress(e,i,t)}}(e,t)),a.addEventListener("loadstart",function(e,t){return function(i){n._uploadStart(e,t)}}(e,t)),a.addEventListener("error",function(e,t){return function(i){n._uploadFailed(e,"general error",t)}}(e,t)),a.addEventListener("abort",function(e,t){return function(i){n._uploadCanceled(e,t)}}(e,t)),a.onreadystatechange=function(e,t){return function(){4===a.readyState&&(200===a.status?n._uploadComplete(e,a.responseText,t):n._uploadFailed(e,a.responseText,t))}}(e,t),a.open("POST",this._uploadUrl),a.setRequestHeader("X-Requested-With","XMLHttpRequest"),a.setRequestHeader("X-CSRF-TOKEN",this.csrfTokenContainer.getAttribute("content")),a.send(i)}}},{key:"escapeFileNameForFormField",value:function(e){return e=e.replace(/\[/,"").replace(/]/,"")}},{key:"_verifyFileSizeOrShowError",value:function(e){if(e.size>this._maxPostSize||e.size>this._maxUploadSize){var t=e.size/1048576,n=(this._maxUploadSize>this._maxPostSize?this._maxPostSize:this._maxUploadSize)/1048576;t=Math.round(100*t)/100,n=Math.round(100*n)/100;var i=this._translations.file_to_big,a=this._translations.max_file_size_upload,o=this._translations.file_size_upload;return alert(i+"\n\n"+a+n+" MB\n"+o+t+" MB\n"),!1}return!0}},{key:"_updateProgress",value:function(e,t,n){if(t.lengthComputable){var i=Math.ceil(t.loaded/t.total*100);this._triggerEvent("updateProgress",[e,i,n])}else this._triggerEvent("updateProgress",[e,null,n])}},{key:"_uploadStart",value:function(e,t){this._triggerEvent("uploadStart",[e,t])}},{key:"_uploadComplete",value:function(e,t,n){this._triggerEvent("uploadComplete",[e,t,n])}},{key:"_uploadFailed",value:function(e,t){this._triggerEvent("uploadFailed",[e,t])}},{key:"_uploadCanceled",value:function(e,t){this._triggerEvent("uploadCanceled",[e,t])}},{key:"_deleteStart",value:function(e){}},{key:"_deleteComplete",value:function(e){this._triggerEvent("deleteComplete",e)}},{key:"_deleteFail",value:function(e){this._triggerEvent("deleteFail",e)}},{key:"on",value:function(e,t){if(!1!==this._constructedSuccessfully)return this._eventMap.hasOwnProperty(e)||(this._eventMap[e]=[]),this._eventMap[e].push(t)}},{key:"_triggerEvent",value:function(e,t){if(this._eventMap.hasOwnProperty(e))for(var n=this._eventMap[e].length,i=0;i<n;i++){var a=this._eventMap[e][i];t&&t.length>0?a.apply(this,t):a.call(this)}}}]),e}(),ImageController=function(){function e(t,n,i){_classCallCheck(this,e),this.key=t,this.currentImageListId="#image-list-"+t,this.fileCounter=0,this.maxImages=i,this.images=n,this.initialize(),this.checkNewButtonState()}return _createClass(e,[{key:"initialize",value:function(){var e=this;$(e.currentImageListId+" .image-thumb-li").click(function(){$(this).remove(),e.removeFromImages($("img",this).attr("data-image-id"))}),$(document).on("click",e.currentImageListId+" .new-image input",function(t){""!=e.maxImages&&e.countActiveImages()>=e.maxImages&&t.preventDefault()}),$(document).on("change",e.currentImageListId+" .new-image input",function(){if(!(""!=e.maxImages&&e.countActiveImages()>=e.maxImages)){var t=$("#"+e.key+"-"+e.fileCounter);$(e.currentImageListId+" .uploads").append(t),e.images.push({id:null,name:t.attr("id"),delete:!1}),e.updateImages(),t.unbind("change");for(var n=t.prop("files"),i=0;i<n.length;i++)e.insertImage(n[i],e.fileCounter,i);e.fileCounter++,$(e.currentImageListId+" .new-image").append('<input type="file" id="'+e.key+"-"+e.fileCounter+'" name="'+e.key+"-"+e.fileCounter+'" accept="image/*" />')}}),this.checkNewButtonState()}},{key:"insertImage",value:function(e,t,n){var i=this,a=new FileReader;a.onload=function(e){var a=e.target.result;$(i.currentImageListId+" .thumbs").append('<li id="image-thumb-'+this.key+"-"+t+"-"+n+'"><img src="'+a+'" /><div class="deleteImage">тип</div></li>');var o=$("#image-thumb-"+i.key+"-"+t+"-"+n);o.click(function(){i.removeFromImages(i.key+"-"+t),o.remove();var e=$("#"+i.key+"-"+t);e.val(""),e.remove()})},this.checkNewButtonState(),a.readAsDataURL(e)}},{key:"checkNewButtonState",value:function(){var e=$(self.currentImageListId+" .new-image");void 0!==this.maxImages&&this.countActiveImages()>=this.maxImages?e.hide():e.show()}},{key:"updateImages",value:function(){var e=JSON.stringify(this.images,null,2);$("#"+this.key).val(e),this.checkNewButtonState()}},{key:"countActiveImages",value:function(){for(var e=0,t=0;t<this.images.length;t++)this.images[t].delete||e++;return e}},{key:"removeFromImages",value:function(e){for(var t=0;t<this.images.length;t++){if(this.images[t].name==e)return this.images.splice(t,1),void this.updateImages();if(this.images[t].id==e)return this.images[t].delete=!0,void this.updateImages()}}}]),e}(),MultiSelect=function(){function e(t){if(_classCallCheck(this,e),this.attributeKey=t.dataset.key,this.value=t.querySelector('[name="'+this.attributeKey+'"]').value,this.uiWidget=t.querySelector(".ui-widget"),this.input=document.getElementById(this.attributeKey),this.openbutton=document.getElementById(this.attributeKey+"-open"),this.autoCompleteSelectField=document.getElementById(this.attributeKey+"-fake"),this.itemsWrapper=document.getElementById(this.attributeKey+"_items"),this.autoSaveUrl=t.dataset.autosaveUrl,this.maxItemsToSelect=t.dataset.maxItemsToSelect,this.selectOptions=e._buildSelectOptionsFromObject(JSON.parse(t.dataset.items)),this.dataSet=e._buildDataSetFromSelectOptions(this.selectOptions),this.sortable="true"===t.dataset.sortable,this.sortable){var n=this;Sortable.create(this.itemsWrapper,{group:this.attributeKey,sort:!0,animation:0,handle:".c-multi-select-item__drag-icon",ghostClass:"is-ghost",setData:function(e,t){e.setData("Text",t.textContent)},onUpdate:function(e){n._updateRealInput()},onSort:function(e){n._updateRealInput()},onRemove:function(e){n._updateRealInput()}})}this._makeMultiSelect(),this._addItems(),this._updateRealInput(),this._enableListeners(!0),this._enableOpenButton()}return _createClass(e,[{key:"_enableListeners",value:function(e){this.listenersEnabled=e;for(var t=this.itemsWrapper.children.length,n=0;n<t;n++){var i=this.itemsWrapper.children[n];i.dataset.id;i.classList.remove("readonly"),this.autoCompleteSelectField.classList.remove("hidden"),e||(i.classList.add("readonly"),this.autoCompleteSelectField.classList.add("hidden"),this.openbutton.classList.add("hidden"))}}},{key:"_addItems",value:function(){for(var e=this.value.split(","),t=this.dataSet.length,n=0;n<e.length;n++)for(var i=parseInt(e[n]),a=0;a<t;a++){var o=this.dataSet[a];if(o.id===i){this._addItem(o.id,o.value);break}}}},{key:"_makeMultiSelect",value:function(){var e=this,t=document.getElementById(this.attributeKey+"-fake");$(t).autocomplete({source:this.dataSet,minLength:0,focus:function(e,t){return!1},select:function(t,n){return $(this.autoCompleteSelectField).val(""),e._addItem(n.item.id,n.item.value),e._updateRealInput(),e._autosaveIfNeeded(),e._enableListeners(!0),!1}})}},{key:"_addItem",value:function(e,t){var n=this;if(!(this._itemsCount()>=n.maxItemsToSelect)){var i=document.createElement("p");i.classList.add("c-multi-select-item"),this.sortable&&(i.draggable=!0,t='<span class="c-multi-select-item__drag-icon"></span><span class="c-multi-select-item__value">'+t+"</span>"),i.innerHTML=t;var a,o=document.createElement("span");o.classList.add("c-multi-select-item__remove"),i.dataset.id=e,i.dataset.sort_order=this._itemsCount()+1,o.addEventListener("click",(a=e,function(){n.listenersEnabled&&n._removeItem(a)})),this.itemsWrapper.appendChild(i),i.appendChild(o),this._itemsCount()>=n.maxItemsToSelect&&(this.uiWidget.style.display="none")}}},{key:"_enableOpenButton",value:function(){var e=this;this.openbutton.addEventListener("click",function(t){$(e.autoCompleteSelectField).autocomplete("search","")})}},{key:"_itemsCount",value:function(){return this.itemsWrapper.childNodes.length-1}},{key:"_removeItem",value:function(e){for(var t=this.itemsWrapper.children,n=0;n<t.length;n++){var i=t[n];if(parseInt(i.dataset.id)===e){this.itemsWrapper.removeChild(i),this._itemsCount()<=this.maxItemsToSelect&&(this.uiWidget.style.display="block");break}}this._updateRealInput(),this._autosaveIfNeeded()}},{key:"_updateRealInput",value:function(){for(var e=[],t=this.itemsWrapper.children,n=this.itemsWrapper.children.length,i=0;i<n;i++){var a=t[i];e[e.length]=a.dataset.id}var o=e.join(",");this.input.setAttribute("value",o);var r=document.createEvent("Event");r.initEvent("change",!1,!0),this.input.dispatchEvent(r)}},{key:"_autosaveIfNeeded",value:function(){if(this.autoSaveUrl){var e=this.input.getAttribute("value"),t=this;$.ajax({type:"POST",url:this.autoSaveUrl,data:{itemIds:e},success:function(e,n,i){200===i.status?console.info("autosave successfull to url: "+t.autoSaveUrl):(console.error("autosave failure to url (no code 200): "+t.autoSaveUrl),console.error(e))},error:function(e){console.error("autosave failure to url: "+t.autoSaveUrl),console.error(e)},headers:{"X-CSRF-TOKEN":$('meta[name="csrf-token"]').attr("content")},dataType:"json"})}}}],[{key:"_buildSelectOptionsFromObject",value:function(e){for(var t=[],n=e.length,i=0;i<n;i++){var a=SelectOption.fromObject(e[i]);a&&t.push(a)}return t}},{key:"_buildDataSetFromSelectOptions",value:function(e){for(var t=[],n=e.length,i=0;i<n;i++)t.push({id:e[i].value,value:e[i].htmlContent.replace(/&nbsp;/gi,".")});return t}}]),e}(),SelectOption=function(){function e(){_classCallCheck(this,e),this._value="",this._content="",this._htmlContent="",this.toJSON=this._toJson.bind(this)}return _createClass(e,[{key:"_toJson",value:function(){return{value:this._value,content:this._content,htmlContent:this._htmlContent}}},{key:"value",get:function(){return this._value},set:function(e){"string"==typeof e?this._value=e:console.error("SelectOption::Value must be a string")}},{key:"content",get:function(){return this._content},set:function(e){"string"==typeof e?this._content=e:console.error("SelectOption::Content must be a string")}},{key:"htmlContent",get:function(){return this._htmlContent},set:function(e){"string"==typeof e?this._htmlContent=e:console.error("SelectOption::htmlContent must be a string")}}],[{key:"fromObject",value:function(e){if(this._objectRepresentsSelectOption(e)){var t=new this;return t._value=e.value,t._content=e.content,t._htmlContent=e.htmlContent,t}}},{key:"_objectRepresentsSelectOption",value:function(e){return!!("object"===_typeof(e)&&e.hasOwnProperty("value")&&e.hasOwnProperty("content")&&e.hasOwnProperty("htmlContent"))||(console.error("SelectOption::_objectRepresentsSelectOption: This does not represent an select option. It must be an object containing properties: value, content and htmlContent",e),!1)}}]),e}(),Numeric=function(){function e(t){_classCallCheck(this,e),t||(console.log(t),console.error('Please give the Numeric attdsadsdribute an attribute wrapper "{HTMLElement}"')),this.attributeWrapper=t,this.realInput=this.attributeWrapper.querySelector(".js-real-input"),this.wholeInput=this.attributeWrapper.querySelector(".js-whole"),this.wholeUpButton=this.attributeWrapper.querySelector(".js-whole-up"),this.wholeDownButton=this.attributeWrapper.querySelector(".js-whole-down"),this.fractionInput=this.attributeWrapper.querySelector(".js-fraction"),this.fractionUpButton=this.attributeWrapper.querySelector(".js-fraction-up"),this.fractionDownButton=this.attributeWrapper.querySelector(".js-fraction-down"),this.wholeMin=this.wholeInput.dataset.min?parseInt(this.wholeInput.dataset.min,10):null,this.wholeMax=this.wholeInput.dataset.max?parseInt(this.wholeInput.dataset.max,10):null,this.wholeStep=this.wholeInput.dataset.step?parseInt(this.wholeInput.dataset.step,10):null,this.fractionMin=this.fractionInput&&this.fractionInput.dataset.min?parseInt(this.fractionInput.dataset.min,10):null,this.fractionMax=this.fractionInput&&this.fractionInput.dataset.max?parseInt(this.fractionInput.dataset.max,10):null,this.fractionStep=this.fractionInput&&this.fractionInput.dataset.step?parseInt(this.fractionInput.dataset.step,10):null,this.fractionLength=this.attributeWrapper.dataset.fractionLength?parseInt(this.attributeWrapper.dataset.fractionLength,10):null,this.zeroPadFraction=!!this.attributeWrapper.dataset.zeroPadFraction&&this.attributeWrapper.dataset.zeroPadFraction,this.wholeInputChanged=this.wholeInputChanged.bind(this),this.wholeUpButtonClicked=this.wholeUpButtonClicked.bind(this),this.wholeDownButtonClicked=this.wholeDownButtonClicked.bind(this),this.fractionInputChanged=this.fractionInputChanged.bind(this),this.fractionUpButtonClicked=this.fractionUpButtonClicked.bind(this),this.fractionDownButtonClicked=this.fractionDownButtonClicked.bind(this),this.wholeInputKeyDown=this.wholeInputKeyDown.bind(this),this.fractionInputKeyDown=this.fractionInputKeyDown.bind(this),this.doZeroPadFraction=this.doZeroPadFraction.bind(this),this.init(),this.controlListeners(!0)}return _createClass(e,[{key:"controlListeners",value:function(e){e?(this.wholeInput.addEventListener("change",this.wholeInputChanged),this.wholeInput.addEventListener("keydown",this.wholeInputKeyDown),this.wholeUpButton.addEventListener("click",this.wholeUpButtonClicked),this.wholeDownButton.addEventListener("click",this.wholeDownButtonClicked),this.fractionInput&&this.fractionInput.addEventListener("change",this.fractionInputChanged),this.fractionInput&&this.fractionInput.addEventListener("keydown",this.fractionInputKeyDown),this.fractionInput&&this.fractionUpButton.addEventListener("click",this.fractionUpButtonClicked),this.fractionInput&&this.fractionDownButton.addEventListener("click",this.fractionDownButtonClicked)):(this.wholeInput.removeEventListener("change",this.wholeInputChanged),this.wholeInput.addEventListener("keydown",this.wholeInputKeyDown),this.wholeUpButton.removeEventListener("click",this.wholeUpButtonClicked),this.wholeDownButton.removeEventListener("click",this.wholeDownButtonClicked),this.fractionInput&&this.fractionInput.removeEventListener("change",this.fractionInputChanged),this.fractionInput&&this.fractionInput.addEventListener("keydown",this.fractionInputKeyDown),this.fractionInput&&this.fractionUpButton.removeEventListener("click",this.fractionUpButtonClicked),this.fractionInput&&this.fractionDownButton.removeEventListener("click",this.fractionDownButtonClicked))}},{key:"wholeInputKeyDown",value:function(e){"ArrowDown"===e.key?this.wholeDownButtonClicked(e):"ArrowUp"===e.key&&this.wholeUpButtonClicked(e)}},{key:"fractionInputKeyDown",value:function(e){"ArrowDown"===e.key?this.fractionDownButtonClicked(e):"ArrowUp"===e.key&&this.fractionUpButtonClicked(e)}},{key:"wholeInputChanged",value:function(e){this.onlyAllowEventWhenNumericKey(e),this.mustBeBetween(this.wholeInput,this.wholeMin,this.wholeMax),this.processInput()}},{key:"wholeUpButtonClicked",value:function(e){var t=parseInt(this.wholeInput.value?this.wholeInput.value:0);this.wholeMax&&t+this.wholeStep>this.wholeMax||(this.wholeInput.value=t+this.wholeStep,this.wholeInputChanged(e))}},{key:"wholeDownButtonClicked",value:function(e){var t=parseInt(this.wholeInput.value?this.wholeInput.value:0);t-this.wholeStep<this.wholeMin||(this.wholeInput.value=t-this.wholeStep,this.wholeInputChanged(e))}},{key:"fractionInputChanged",value:function(e){console.log("fraction changed"),this.onlyAllowEventWhenNumericKey(e),this.onlyAllowMaxLength(e,this.fractionLength),this.mustBeBetween(this.fractionInput,this.fractionMin,this.fractionMax),this.zeroPadFraction&&this.doZeroPadFraction(),this.processInput()}},{key:"doZeroPadFraction",value:function(){for(;this.fractionInput.value.length<this.fractionLength;)this.fractionInput.value="0"+this.fractionInput.value}},{key:"fractionUpButtonClicked",value:function(e){var t=parseInt(this.fractionInput.value?this.fractionInput.value:0)+this.fractionStep;this.fractionMax&&t>this.fractionMax||t.toString().length>this.fractionLength||(this.fractionInput.value=t,this.fractionInputChanged(e))}},{key:"fractionDownButtonClicked",value:function(e){var t=parseInt(this.fractionInput.value?this.fractionInput.value:0)-this.fractionStep;t<this.fractionMin||(this.fractionInput.value=t,this.fractionInputChanged(e))}},{key:"init",value:function(){var e,t="";this.realInput.value.length>this.fractionLength&&(t=this.realInput.value.slice(-this.fractionLength)),e=this.realInput.value.substring(0,this.realInput.value.length-this.fractionLength),this.wholeInput.value=parseInt(e,10),this.fractionInput&&(this.fractionInput.value=parseInt(t,10)),this.mustBeBetween(this.wholeInput,this.wholeMin,this.wholeMax),this.fractionInput&&this.mustBeBetween(this.fractionInput,this.fractionMin,this.fractionMax),this.zeroPadFraction&&this.doZeroPadFraction()}},{key:"onlyAllowMaxLength",value:function(e,t){this.eventCausedByAllowedModifier(e)||e.target.value.length>=t&&e.cancelable&&e.preventDefault()}},{key:"onlyAllowEventWhenNumericKey",value:function(e){e.key&&(this.isNumber(e.key)||this.eventCausedByAllowedModifier(e)||e.cancelable&&e.preventDefault())}},{key:"eventCausedByAllowedModifier",value:function(e){if(e.key)return"backspace"===e.key.toLowerCase()||"delete"===e.key.toLowerCase()||"arrowleft"===e.key.toLowerCase()||"arrowright"===e.key.toLowerCase()}},{key:"processInput",value:function(){this.realInput.value=this.fractionInput?this.wholeInput.value+""+this.fractionInput.value:this.wholeInput.value}},{key:"mustBeBetween",value:function(e,t,n){var i=parseInt(e.value,10);i?((t||0===t)&&i<t&&(e.value=t),n&&i>n&&(e.value=n)):isNaN(i)&&(e.value=(0).toString())}},{key:"isNumber",value:function(e){return!isNaN(parseFloat(e))&&isFinite(e)}}]),e}(),OnOff=function(){function e(t){if(_classCallCheck(this,e),void 0!==t&&"DIV"===t.tagName)if(this._onOffElementWrapper=t,"key"in t.dataset){var n=t.querySelector('input[type="checkbox"]');if(n){this._realCheckbox=n;var i=t.querySelector(".on-off-switch");i?(this._visibleCheckbox=i,this._visibleCheckbox.addEventListener("click",this.toggleOnOffSwitch.bind(this)),this.initialize()):console.error("OnOff:constructor Did not find a required div with class on-off-switch in the OnOff attribute wrapper.")}else console.error("OnOff:constructor Did not find a required input of type checkbox in the OnOff attribute wrapper.")}else console.error("OnOff:constructor Missing the key dataset property on the onOffElementWrapper");else console.error("OnOff:constructor Missing the expected div element that represents the OnOff attribute wrapper.")}return _createClass(e,[{key:"initialize",value:function(){this.updateOnOffState()}},{key:"updateOnOffState",value:function(){"1"===this._realCheckbox.value?(this._realCheckbox.value="1",this._visibleCheckbox.classList.add("on"),this._realCheckbox.setAttribute("checked","")):(this._realCheckbox.value="0",this._visibleCheckbox.classList.remove("on"),this._realCheckbox.removeAttribute("checked"))}},{key:"toggleOnOffSwitch",value:function(){this._realCheckbox.value="0"===this._realCheckbox.value?"1":"0",this.updateOnOffState();var e=document.createEvent("Event");e.initEvent("change",!1,!0),this._realCheckbox.dispatchEvent(e)}}]),e}(),PasswordController=function(){function e(t,n,i,a){var o=arguments.length>4&&void 0!==arguments[4]?arguments[4]:6,r=arguments.length>5&&void 0!==arguments[5]&&arguments[5];_classCallCheck(this,e),this.wrapperHasTitleAttributeAndErrorClass=r,this.wrapper=document.querySelector(n),this.saveButton=document.querySelector("#"+a),this.firstPasswordInput=this.wrapper.querySelector("input[name="+t+"-1]"),this.secondPasswordInput=this.wrapper.querySelector("input[name="+t+"-2]"),this.realPasswordInput=this.wrapper.querySelector("input[name="+t+"]"),this.validationMessageWrapperSelector=".validationHelper",this.validationMessageWrapper=this.wrapper.querySelector(this.validationMessageWrapperSelector),this.minPasswordLength=o,this.letter=this.validationMessageWrapper.querySelector(".letter"),this.capital=this.validationMessageWrapper.querySelector(".capital"),this.number=this.validationMessageWrapper.querySelector(".number"),this.length=this.validationMessageWrapper.querySelector(".length"),this.match=this.validationMessageWrapper.querySelector(".match"),this.activateListeners(!0)}return _createClass(e,[{key:"activateListeners",value:function(e){var t=this,n=this.validationMessageWrapper;e?(this.firstPasswordInput.addEventListener("keyup",t.debounce(function(){t.passwordChanged()},100)),this.secondPasswordInput.addEventListener("keyup",t.debounce(function(){t.passwordChanged()},100)),this.firstPasswordInput.addEventListener("focus",function(){n.classList.contains("active")||n.classList.add("active")}),this.secondPasswordInput.addEventListener("focus",function(){n.classList.contains("active")||n.classList.add("active")}),this.firstPasswordInput.addEventListener("blur",function(){n.classList.contains("active")&&n.classList.remove("active")}),this.secondPasswordInput.addEventListener("blur",function(){n.classList.contains("active")&&n.classList.remove("active")})):(this.firstPasswordInput.removeEventListener("keyup",t.debounce),this.secondPasswordInput.removeEventListener("keyup",t.debounce),this.firstPasswordInput.removeEventListener("focus"),this.secondPasswordInput.removeEventListener("focus"),this.firstPasswordInput.removeEventListener("blur"),this.secondPasswordInput.removeEventListener("blur"))}},{key:"passwordChanged",value:function(){console.log("password changed");var e=this.firstPasswordInput.value,t=this.secondPasswordInput.value,n=this.validate(e,t);console.log(n),this.realPasswordInput.value=n?t:"",this.enableValidMessage(n),this.enableSaveButton(n),""===e&&""===t&&this.enableSaveButton(!0),this.removeWrapperError()}},{key:"enableValidMessage",value:function(e){var t=this.validationMessageWrapper;e?t.classList.contains("valid")||t.classList.add("valid"):t.classList.contains("valid")&&t.classList.remove("valid")}},{key:"enableSaveButton",value:function(e){console.log(e),e?this.saveButton.classList.contains("disabled")&&this.saveButton.classList.remove("disabled"):this.saveButton.classList.contains("disabled")||this.saveButton.classList.add("disabled")}},{key:"removeWrapperError",value:function(){this.wrapperHasTitleAttributeAndErrorClass&&(this.wrapper.hasAttribute("title")&&this.wrapper.setAttribute("title",""),this.wrapper.classList.contains("error")&&this.wrapper.classList.remove("error"))}},{key:"validate",value:function(e,t){var n=!0;e.match(/[a-z]/g)?(this.letter.classList.remove("invalid"),this.letter.classList.add("valid")):(this.letter.classList.remove("valid"),this.letter.classList.add("invalid"),n=!1);e.match(/[A-Z]/g)?(this.capital.classList.remove("invalid"),this.capital.classList.add("valid")):(this.capital.classList.remove("valid"),this.capital.classList.add("invalid"),n=!1);return e.match(/[0-9]/g)?(this.number.classList.remove("invalid"),this.number.classList.add("valid")):(this.number.classList.remove("valid"),this.number.classList.add("invalid"),n=!1),e.length>=this.minPasswordLength?(this.length.classList.remove("invalid"),this.length.classList.add("valid")):(this.length.classList.remove("valid"),this.length.classList.add("invalid"),n=!1),e!==t||""===e&&""===t?(this.match.classList.remove("valid"),this.match.classList.add("invalid"),n=!1):(this.match.classList.remove("invalid"),this.match.classList.add("valid")),n}},{key:"debounce",value:function(e,t,n){var i;return function(){var a=this,o=arguments,r=n&&!i;clearTimeout(i),i=setTimeout(function(){i=null,n||e.apply(a,o)},t),r&&e.apply(a,o)}}}]),e}(),QuantityDiscount=function(){function e(t){if(_classCallCheck(this,e),void 0!==t&&"DIV"===t.tagName)if(!1 in t.dataset)console.error("QuantityDiscount:constructor The wrapper did not have a key dataset attribute");else{this._key=t.dataset.key;var n=t.querySelector('input[name="'+this._key+'"]');if(n){this._realInput=n;var i=t.querySelector('input[name="'+this._key+'_discount"]');if(i){this._quantityDiscountInput=i;var a=t.querySelector('input[name="'+this._key+'_quantity"]');i?(this._quantityAmountInput=a,this.initialize(),this.enableListeners(),console.log("quantityDiscount init ",this._realInput.value)):console.error('QuantityDiscount:constructor Did not find a required input with name "'+this._key+'_quantity" in the QuantityDiscount wrapper.')}else console.error('QuantityDiscount:constructor Did not find a required input with name "'+this._key+'_discount" in the QuantityDiscount wrapper.')}else console.error('QuantityDiscount:constructor Did not find a required hidden input with name "'+this._key+'" in the QuantityDiscount wrapper.')}else console.error("QuantityDiscount:constructor Missing the expected div element that represents the wrapper.")}return _createClass(e,[{key:"initialize",value:function(){var e=this._realInput.value.split("|"),t=e[0],n=e[1];""===this._realInput.value&&(this._realInput.value="|"),this._quantityAmountInput.value=t,this._quantityDiscountInput.value=n?parseInt(n)/100:""}},{key:"enableListeners",value:function(){this._quantityDiscountInput.addEventListener("change",this.updateRealInput.bind(this)),this._quantityAmountInput.addEventListener("change",this.updateRealInput.bind(this))}},{key:"updateRealInput",value:function(){var e=this._quantityAmountInput.value,t=100*this._quantityDiscountInput.value;t=Math.round(t),this._realInput.value=e+"|"+t}}]),e}(),Select=function(){function e(t){if(_classCallCheck(this,e),void 0!==t&&"DIV"===t.tagName)if(this._selectElementWrapper=t,"key"in t.dataset){var n=t.dataset.key,i=t.querySelector('select[name="'+n+'"]');i?(this._realInput=i,this.initialize(n)):console.error('SelectElement:constructor Did not find a required hidden select with name "'+n+'" in the VideoElementWrapper.')}else console.error("SelectElement:constructor Missing the key dataset property on the selectElementWrapper");else console.error("SelectElement:constructor Missing the expected div element that represents the selectElementWrapper.")}return _createClass(e,[{key:"initialize",value:function(e){var t=this,n=this._selectElementWrapper.querySelector(".select-menu"),i={width:"100%",create:function(e,t){var n=this.id+"-button";this.id;document.getElementById(n).setAttribute("data-test",this.id)},open:function(e,t){var n=document.getElementById(this.id+"-button"),i=document.getElementById(this.id+"-menu");i.style.width=n.offsetWidth+"px",i.parentNode.style.width=n.offsetWidth+"px",n.classList.add("dropdown-open")},change:function(e,n){var i=document.getElementById(this.id+"-button"),a=i.querySelector(".ui-selectmenu-text").innerHTML;i.querySelector(".ui-selectmenu-text").innerHTML=a.replace(/&nbsp;/gi,"");var o=document.createEvent("Event");o.initEvent("change",!1,!0),t._realInput.dispatchEvent(o)},close:function(e,t){document.getElementById(this.id+"-button").classList.remove("dropdown-open")}};$(n).selectmenu(i).data("ui-selectmenu")._renderItem=function(e,t){var i=$("<li>"),a=$("<div>",{title:t.element.attr("title")});return t.disabled&&this._addClass(i,null,"ui-state-disabled"),this._setText(a,t.label),$(i).attr("data-test",n.id+"-"+t.value),i.append(a).appendTo(e)}}}]),e}(),SendPasswordMailButton=function(){function e(t){_classCallCheck(this,e),this.wrapper=t,this.csrfTokenContainer=document.querySelector('meta[name="csrf-token"]'),this.csrfTokenContainer?(this.mailButtonWrapper=this.wrapper.querySelector(".js_password_mail"),this.mailButtonWrapper?(this.mailButton=this.mailButtonWrapper.querySelector("button"),this.mailButton&&"url"in this.mailButton.dataset&&"userId"in this.mailButton.dataset?(this.mailButtonUrl=this.mailButton.dataset.url,this.mailButtonUserId=this.mailButton.dataset.userId,this.mailConfirmation=this.mailButtonWrapper.querySelector("p.js_confirmation"),this.mailConfirmation?(this.mailFailMessage=this.mailButtonWrapper.querySelector("p.js_fail"),this.mailFailMessage?(this.mailButtonClicked=this.mailButtonClicked.bind(this),this.activateListeners(!0)):console.error("PasswordController: Could not find a paragraph with class js_fail. Password controller does not work.")):console.error("PasswordController: Could not find a paragraph with class js_confirmation. Password controller does not work.")):console.error("PasswordController: Could not find a button within the mail button wrapper, that has the data attributes url and user-id. Password controller does not work.")):console.error("PasswordController: could not find the wrapper that holds a button to mail the user instructions on how to set his password. Password controller does not work")):console.error("PasswordController: could not find the csrf token container. Password controller does not work")}return _createClass(e,[{key:"activateListeners",value:function(e){e?this.mailButton.addEventListener("click",this.mailButtonClicked):this.mailButton.removeEventListener("click",this.mailButtonClicked)}},{key:"mailButtonClicked",value:function(e){e.preventDefault();var t,n=new XMLHttpRequest;n.open("POST",this.mailButtonUrl,!0),n.setRequestHeader("Content-Type","application/x-www-form-urlencoded"),n.setRequestHeader("X-CSRF-TOKEN",this.csrfTokenContainer.getAttribute("content")),n.setRequestHeader("X-Requested-With","XMLHttpRequest"),n.onreadystatechange=(t=this,function(){this.readyState===XMLHttpRequest.DONE&&(200===this.status||204===this.status?t.mailSend():t.mailError())}),this.mailButton.classList.add("hidden"),n.send("user_id="+this.mailButtonUserId)}},{key:"mailError",value:function(){this.mailFailMessage.classList.remove("hidden")}},{key:"mailSend",value:function(){this.mailConfirmation.classList.remove("hidden")}}]),e}(),StyleClassController=function(){function e(t){_classCallCheck(this,e),this.constructedSuccessFully=!1,!t instanceof HTMLElement?console.error("StyleClassController: The given htmlElement must be, but was not a HTMLElement"):(this.htmlElement=t,this.classCounts={},this.constructedSuccessFully=!0)}return _createClass(e,[{key:"requestAddClass",value:function(e){return this.htmlElement.classList.contains(e)||this.htmlElement.classList.add(e),this.classCounts.hasOwnProperty(e)||(this.classCounts[e]=0),this.classCounts[e]++,!0}},{key:"requestRemoveClass",value:function(e){if(!this.htmlElement.classList.contains(e)||!this.classCounts.hasOwnProperty(e))return!1;this.classCounts[e]--,0===this.classCounts[e]&&(delete this.classCounts[e],this.htmlElement.classList.remove(e))}}]),e}(),Video=function(){function e(t){if(_classCallCheck(this,e),void 0!==t&&"DIV"===t.tagName)if(this._videoElementWrapper=t,"key"in t.dataset){var n=t.dataset.key,i=t.querySelector('input[name="'+n+'"]');if(i){this._realInput=i;var a=t.querySelector('input[name="'+n+'_autoplay"]');if(a){this._realCheckbox=a;var o=t.querySelector('input[name="'+n+'_video_id"]');o?(this._videoIdInput=o,this._videoIdUrlRegex=/(youtu\.be\/|youtube\.com\/(watch\?(.*&)?v=|(embed|v)\/))([^\?&"'>]+)/,this._videoIdRegex=/([^&?]+)/,this._videoWatchPath="https://www.youtube.com/watch?v={videoInputValue}",this._videoImgPath="https://img.youtube.com/vi/{videoInputValue}/0.jpg",this.initialize(),this.enableEventListeners()):console.error('VideoElement:constructor Did not find a required input of type text with name "'+n+'_video_id" in the VideoElementWrapper.')}else console.error('VideoElement:constructor Did not find a required checkbox input of type checkbox with name "'+n+'_autoplay" in the VideoElementWrapper.')}else console.error('VideoElement:constructor Did not find a required hidden input with name "'+n+'" in the VideoElementWrapper.')}else console.error("VideoElement:constructor Missing the key dataset property on the videoElementWrapper");else console.error("VideoElement:constructor Missing the expected div element that represents the VideoElementWrapper.")}return _createClass(e,[{key:"enableEventListeners",value:function(){this._videoIdInput.addEventListener("keyup",this.updateRealInput.bind(this)),this._realCheckbox.addEventListener("change",this.updateRealInput.bind(this))}},{key:"updateRealInput",value:function(e){var t=!0===this._realCheckbox.checked?"1":"0";this._videoIdInput.value=this.getVideoId(this._videoIdInput.value);var n=this._videoIdInput.value;this._realInput.value=t+","+n,this.updateThumbnail(n)}},{key:"getVideoId",value:function(e){var t=e.match(this._videoIdUrlRegex),n=e.match(this._videoIdRegex);return t&&t.length>=6?t[5]:n&&6===n.length?n[0]:e}},{key:"updateThumbnail",value:function(e){var t=this._videoElementWrapper.querySelector(".js-video-link"),n=this._videoElementWrapper.querySelector(".js-video-thumb");if(!isset(e)||""===e)return n.removeAttribute("src"),void t.removeAttribute("href");var i=this._getYoutubePath(e);n.setAttribute("src",i),t.setAttribute("href",this._getYoutubePath(e,"watch"))}},{key:"_getYoutubePath",value:function(e){switch(arguments.length>1&&void 0!==arguments[1]?arguments[1]:"thumbnail"){case"thumbnail":return this._videoImgPath.replace("{videoInputValue}",e);case"watch":return this._videoWatchPath.replace("{videoInputValue}",e);default:return console.alert("VideoElement:_getPath Type rule not defined"),""}}},{key:"initialize",value:function(){if(""!==this._realInput.value){var e=this._realInput.value.split(",");e.length<2&&console.error("VideoElement:initialize Could not initialize a video element because it received an invalid value: ",this._realInput.value);var t=e[0],n=e[1];this._videoIdInput.value=n,this.updateThumbnail(n),this._realCheckbox.checked="1"===t}}}]),e}(),ConfirmationController=function(){function e(t){_classCallCheck(this,e),!1!==this._validateElement(t)?(this._headerText=t.dataset.confirmHeader?t.dataset.confirmHeader:"",this._message=t.dataset.confirmMessage?t.dataset.confirmMessage:"",this._confirmText=t.dataset.confirmConfirmText?t.dataset.confirmConfirmText:"",this._cancelText=t.dataset.confirmCancelText?t.dataset.confirmCancelText:"",this._navigatableElement=t,this._onlyConfirmIfTrueCallback=null,this._confirmCallback=null,this._clickEventHandler=this._clickEventHandler.bind(this),this._confirmClicked=this._confirmClicked.bind(this),this._cancelClicked=this._cancelClicked.bind(this),this.enableListeners()):console.error("The navigatableElement isn't valid. Did not enable the confirmation functionality for that navigatableElement. You passed a \""+t.tagName+'"')}return _createClass(e,[{key:"enableListeners",value:function(){this.disableListeners(),this._navigatableElement.addEventListener("click",this._clickEventHandler)}},{key:"disableListeners",value:function(){this._navigatableElement.removeEventListener("click",this._clickEventHandler)}},{key:"_clickEventHandler",value:function(e){var t=!1;(this._onlyConfirmIfTrueCallback&&!0===this._onlyConfirmIfTrueCallback.call()||!this._onlyConfirmIfTrueCallback)&&(t=!0),t&&(e.preventDefault(),this._showConfirmationPrompt(!0,this._navigatableElement))}},{key:"setOnlyConfirmIfTrueCallback",value:function(e){this._onlyConfirmIfTrueCallback=e}},{key:"_addListenersToModalButtons",value:function(){var e=!(arguments.length>0&&void 0!==arguments[0])||arguments[0];arguments.length>1&&arguments[1];this.promptElement||console.error("First create the modal with the createPrompt method");var t=this.promptElement.querySelector("button.confirm"),n=this.promptElement.querySelector("button.cancel"),i=this.promptElement.querySelector("div.shader");t.removeEventListener("click",this._confirmClicked),n.removeEventListener("click",this._cancelClicked),i.removeEventListener("click",this._cancelClicked),e&&(t.addEventListener("click",this._confirmClicked),n.addEventListener("click",this._cancelClicked),i.addEventListener("click",this._cancelClicked))}},{key:"setConfirmCallback",value:function(e){return this._confirmCallback=e,this}},{key:"_confirmClicked",value:function(e){e.preventDefault(),this._confirmCallback?this._confirmCallback.call():(this._addNavigatableElementValueToForm(),this._submitNearestForm(!1)),this._showConfirmationPrompt(!1)}},{key:"_addNavigatableElementValueToForm",value:function(){if(this._navigatableElement.hasAttribute("value")&&this._navigatableElement.hasAttribute("name")){var e=this._findForm(this._navigatableElement);if(!e)return;var t=document.createElement("INPUT");t.setAttribute("type","hidden"),t.setAttribute("name",this._navigatableElement.getAttribute("name")),t.setAttribute("value",this._navigatableElement.getAttribute("value")),e.appendChild(t)}}},{key:"_submitNearestForm",value:function(){var e=this._findForm(this._navigatableElement);return e?(e.submit(),!0):(console.error("Could not submit the nearest form this navigatableElement should be in, because it isn't in a form."),!1)}},{key:"_cancelClicked",value:function(e){e.preventDefault(),this._showConfirmationPrompt(!1)}},{key:"_findForm",value:function(e){return!!e.parentNode&&("FORM"===e.parentNode.tagName?e.parentNode:this._findForm(e.parentNode))}},{key:"_createPrompt",value:function(){var e='<div class="modal"><div class="header"><h4>'+this._headerText+'</h4></div><div class="body"><p class="message">'+this._message+'</p><div class="navigatableElements buttons"><button class="confirm" data-test="confirmation_confirm">'+this._confirmText+'</button><button class="cancel" data-test="confirmation_cancel">'+this._cancelText+'</button></div></div></div></div><div class="shader"></div>',t=document.createElement("div");return t.setAttribute("id","confirmBox"),t.setAttribute("data-test","confirmBox"),t.innerHTML=e,t}},{key:"_showConfirmationPrompt",value:function(e,t){console.log(e?"show confirmation prompt":"hide confirmation prompt"),this.promptElement||(this.promptElement=this._createPrompt(),this._addListenersToModalButtons(!0,t)),e?(this.promptElement.classList.add("show"),document.body.appendChild(this.promptElement)):(this.promptElement.classList.remove("show"),this.promptElement.parentElement&&this.promptElement.parentElement.removeChild(this.promptElement),this.promptElement=null)}},{key:"_validateElement",value:function(e){return!!e&&(("BUTTON"===e.tagName||"INPUT"===e.tagName||"A"===e.tagName)&&("INPUT"!==e.tagName||"navigatableElement"===e.getAttribute("type").toLowerCase()||"submit"===e.getAttribute("type").toLowerCase()))}},{key:"setHeaderText",value:function(e){return this._headerText=e,this}},{key:"setMessage",value:function(e){return this._message=e,this}},{key:"setConfirmText",value:function(e){return this._confirmText=e,this}},{key:"setCancelText",value:function(e){return this._cancelText=e,this}}]),e}(),Initializer=function(){function e(t){_classCallCheck(this,e),this._bindings={},this._onceBindings={},this._booted=!1,this._observer=null,this._isObserving=!1,this._showDebugInformation=!1,this._observerConfiguration={subtree:!0,childList:!0},this._wrapper=document.querySelector(t),this._wrapper?this._boot():console.info('The selector "'+t+'" does not match any element. Could not monitor html elements and initialize them when needed.')}return _createClass(e,[{key:"_boot",value:function(){this._booted||(this._booted=!0,this._observer=new MutationObserver(this._mutationsObserved.bind(this)))}},{key:"startObserving",value:function(){return this._booted?(this._showDebugInformation&&console.log("Starting to observe"),this._observer.takeRecords(),this._observer.observe(this._wrapper,this._observerConfiguration),this._isObserving=!0,this):this}},{key:"stopObserving",value:function(){return this._booted?(this._showDebugInformation&&console.log("Stopped to observe"),this._observer.disconnect(),this._isObserving=!1,this):this}},{key:"_mutationsObserved",value:function(e){if(!this._booted)return this;var t=e.length;this._showDebugInformation&&console.info("Detected "+t+" changes");for(var n=0;n<t;n++)for(var i=e[n].addedNodes,a=i.length,o=0;o<a;o++){var r=i[o];this._triggerBoundCallbacksIfElementMatchesSelector(r)}}},{key:"_triggerBoundCallbacksIfElementMatchesSelector",value:function(e){if(e&&e instanceof HTMLElement)for(var t in this._bindings){var n=e.matches(t),i=e.querySelectorAll(t),a=i.length;if((n||a>0)&&(n&&(e.hasAttribute("initialized")&&!1!==this._onceBindings[t]||(this._showDebugInformation&&console.log('Calling callback for selector "'+t+'". HTMLElement',e),this._bindings[t](this,e),e.setAttribute("initialized",""))),a>0))for(var o=0;o<a;o++){var r=i[o];r.hasAttribute("initialized")&&!1!==this._onceBindings[t]||(this._showDebugInformation&&console.log('Calling callback for selector "'+t+'". HTMLElement',r),this._bindings[t](this,r),r.setAttribute("initialized",""))}}}},{key:"bindSelectorToCallback",value:function(e,t){var n=!(arguments.length>2&&void 0!==arguments[2])||arguments[2];if(!this._booted)return this;if("string"!=typeof e)return console.error("Initializer:bind The selector must be a string"),this;if("function"!=typeof t)return console.error("Initializer:bind The callback must be a function"),this;if("boolean"!=typeof n)return console.error("Initializer:bind The once variable must be a boolean"),this;this._bindings[e]=t,this._onceBindings[e]=n,this._showDebugInformation&&console.log('bound selector "'+e+'" to a callback');var i=this._isObserving;this._isObserving&&this.stopObserving();var a=this._wrapper.querySelectorAll(e);if(!a)return this;for(var o=a.length,r=0;r<o;r++)t(this,a[r]);return i&&this.startObserving(),this}}]),e}(),PreventNavigationController=function(){function e(t){_classCallCheck(this,e),this._inputs=[],this._wrapperElement=null,this._translation={headerText:"",message:"",confirmText:"",cancelText:""},this._anchorsAndConfirmationControllers=[],this._changed=!1,t?t.dataset.translation?(this._wrapperElement=t,this._inputChanged=this._inputChanged.bind(this),this._loadTranslation(),this.refresh()):console.error("PreventNavigationController: No translation present. Not preventing navigation when not all changes have been saved."):console.error("PreventNavigationController: No wrapper element given. Not preventing navigation.")}return _createClass(e,[{key:"_isTrackableElement",value:function(e){return"INPUT"===e.tagName||"SELECT"===e.tagName||"TEXTAREA"===e.tagName}},{key:"_setListenersOnInputs",value:function(e){for(var t=!(arguments.length>1&&void 0!==arguments[1])||arguments[1],n=e.length,i=0;i<n;i++)t?e[i].addEventListener("change",this._inputChanged):e[i].removeEventListener("change",this._inputChanged)}},{key:"_inputChanged",value:function(e){this._changed=!0}},{key:"_loadTranslation",value:function(){this._translation=JSON.parse(this._wrapperElement.dataset.translation)}},{key:"refresh",value:function(){this._inputs=this._findAllInputsIn(this._wrapperElement),this._interceptClicksOnAnchors(),this._setListenersOnInputs(this._inputs)}},{key:"_interceptClicksOnAnchors",value:function(){var e=this;this._clearAnchorsAndControllers();for(var t=document.getElementsByTagName("A"),n=t.length,i=function(n){var i=t[n],a=i.getAttribute("href");if(a&&"#"!==a.substr(0,1)){var o=new ConfirmationController(i);o.setHeaderText(e._translation.headerText).setMessage(e._translation.message).setConfirmText(e._translation.confirmText).setCancelText(e._translation.cancelText).setConfirmCallback(function(){window.location=a}).setOnlyConfirmIfTrueCallback(function(e){return function(){return e._hasChanged()}}(e)),e._anchorsAndConfirmationControllers.push({anchor:i,controller:o})}},a=0;a<n;a++)i(a)}},{key:"_clearAnchorsAndControllers",value:function(){for(var e;e=this._anchorsAndConfirmationControllers.pop();){var t=e.controller;t.disableListeners(),t=null}}},{key:"_hasChanged",value:function(){return this._changed}},{key:"_findAllInputsIn",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[],n=e.children.length;if(0===n)return t;for(var i=0;i<n;i++){var a=e.children[i];if(this._isTrackableElement(a)&&t.push(a),a.children.length>0){var o=this._findAllInputsIn(a,t);t.concat(o)}}return t}}]),e}(),TabsController=function(){function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"tab",n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:".tab-buttons",i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"active",a=arguments.length>3&&void 0!==arguments[3]&&arguments[3],o=arguments.length>4&&void 0!==arguments[4]?arguments[4]:void 0;_classCallCheck(this,e);document.querySelector(this.tabSlugInputId);this.tabButtonGroupSelector=n,this.tabContentDivsClassAndIdPrefix=t,this.tabSlugInputId=o,this.activeClass=i,this.reactToUrlHashChange=a,a&&this.addListenerForHashChange(a)}return _createClass(e,[{key:"openTab",value:function(e,t){(e=this.removeLeftHandSlashInSlug(e))&&(t&&sessionStorage.clear(),this.updateTabSlugInput(e),this.showTabContentForTabWithSlug(e),this.makeTabButtonActiveForSlug(e))}},{key:"removeLeftHandSlashInSlug",value:function(e){return e.replace(/^\/(.*)/,"$1")}},{key:"updateTabSlugInput",value:function(e){if(void 0!==this.tabSlugInputId){var t=document.querySelector(this.tabSlugInputId);t&&(t.value=e)}}},{key:"makeTabButtonActiveForSlug",value:function(e){for(var t=document.querySelectorAll(".entity-tabs > ul > li"),n=t.length,i=0;i<n;i++){t[i].classList.remove("active")}document.querySelector('.entity-tabs > ul > li a[href="#'+e+'"]').parentElement.classList.add("active")}},{key:"showTabContentForTabWithSlug",value:function(e){for(var t=document.querySelectorAll("."+this.tabContentDivsClassAndIdPrefix),n=t.length,i=0;i<n;i++){t[i].classList.remove(this.activeClass)}var a=document.querySelector("#"+this.tabContentDivsClassAndIdPrefix+"-"+e);a?(a.classList.add(this.activeClass),isset(sessionStorage.getItem("componentScrollPosition"))||(a.parentElement.scrollTop=0),a.parentElement.addEventListener("scroll",function(e){sessionStorage.componentScrollPosition=e.currentTarget.scrollTop})):console.error("TabsController: Could not make content tab active. It should have an ID with: #"+this.tabContentDivsClassAndIdPrefix+"-"+e)}},{key:"addListenerForHashChange",value:function(e){e?(window.addEventListener("hashchange",this.hashChanged.bind(this)),window.addEventListener("load",this.hashChanged.bind(this))):(window.removeEventListener("hashchange",this.hashChanged),window.removeEventListener("load",this.hashChanged))}},{key:"hashChanged",value:function(e){var t=window.location.hash.substring(1);if(t)this.openTab(t,!0);else{var n=document.querySelector(this.tabSlugInputId);n&&this.openTab(n.value,!1)}}}]),e}();document.addEventListener("DOMContentLoaded",function(){window.axios.defaults.headers.common={"X-Requested-With":"XMLHttpRequest","X-CSRF-TOKEN":document.querySelector('meta[name="csrf-token"]').getAttribute("content")};var e=document.querySelector("html"),t=e.getAttribute("lang")?e.getAttribute("lang"):"en";new TabsController("tab-content","entity-tabs","active",!0,'input[name="tabslug"]');var n=document.getElementById("entity-form"),i=n?n.dataset.globalTranslations:{},a=document.getElementById("save-button"),o=new StyleClassController(a);if(a){var r=document.querySelector('input[value="submit-cloaked"]');a.addEventListener("click",function(e){e.preventDefault(),n.checkValidity()&&o.requestAddClass("disabled"),r.click()})}var s=document.querySelector(".js-open-confirmation");s&&new ConfirmationController(s);var l=new Initializer("#entity-form"),u=new Initializer("#entities");if(n){var c=new ComponentAreaCopier;l.bindSelectorToCallback(".js-components-area",function(e,t){var n=new ComponentAreaManager(t,new ComponentManagerApiController);c.registerComponentAreaManager(n),n.on("componentAdded",function(e,t){t&&h&&h.refresh()})})}l.bindSelectorToCallback(".entity-attribute-documents",function(e,t){var a=n.dataset.uploadRoute,r=n.dataset.maxPostSize,s=n.dataset.maxUploadSize,l=new HTML5Uploader(a,r,s,i),u=new DocumentManager(t,l,i);new FileDragAndDropHandler(t.querySelector(".drag-and-drop-area")).hookTo(u),l.on("uploadStart",function(){o.requestAddClass("disabled")}),l.on("uploadComplete",function(){o.requestRemoveClass("disabled")}),l.on("uploadCanceled",function(){o.requestRemoveClass("disabled")}),l.on("uploadFailed",function(){o.requestRemoveClass("disabled")})}),l.bindSelectorToCallback(".entity-attribute-multiselect-combo-box",function(e,t){if("false"===t.dataset.readonly)new MultiSelect(t)}),l.bindSelectorToCallback(".entity-attribute-checkboxes",function(e,t){if("false"===t.dataset.readonly)new Checkboxes(t)}),l.bindSelectorToCallback(".entity-attribute-on-off",function(e,t){new OnOff(t)}),l.bindSelectorToCallback(".js-video",function(e,t){new Video(t)}),l.bindSelectorToCallback(".js-confirm",function(e,t){new ConfirmationController(t)}),l.bindSelectorToCallback(".entity-attribute-select",function(e,t){new Select(t)}),l.bindSelectorToCallback(".entity-attribute-currency",function(e,t){new Currency(t)}),l.bindSelectorToCallback(".entity-attribute-quantity-discount",function(e,t){new QuantityDiscount(t)}),l.bindSelectorToCallback(".entity-attribute-send-password-mail-button",function(e,t){new SendPasswordMailButton(t)}),l.bindSelectorToCallback("[data-to-copy]",function(e,t){console.log("found copy text element"),new CopyText(t)}),l.bindSelectorToCallback(".entity-attribute-numeric",function(e,t){new Numeric(t)}),u.bindSelectorToCallback(".js-sortable",function(e,t){new SortableController(t).load().then(function(e){h&&(console.log("Refreshing the prevent navigation controller since there may be more anchors."),h.refresh())}).catch(function(e){console.error(e)})}),l.bindSelectorToCallback("textarea.tiny-mce",function(e,n){n.id||(n.id=(new Date).getTime()+Math.random().toString(36).substring(7)),tinymce.remove("#"+n.id.replace(/\|/g,"\\|")),tinymce.init({target:n,menubar:!1,statusbar:!1,plugins:"code paste link lists directionality",toolbar:"styleselect | bold italic strikethrough | numlist bullist | link unlink | outdent indent | code ",height:"200",paste_as_text:!0,style_formats:[{title:"Paragraaf",block:"p"},{title:"Subtitel",block:"h3"},{title:"Titel",block:"h2"}],language:t,convert_urls:!1,setup:function(e){e.on("change",function(t){!function(e,t){e.save();var n=createNewEvent("change");dispatchEventForElement(t,n)}(e,n)})}})},!1),l.startObserving(),u.startObserving();var d=document.querySelector(".entity-attributes"),h=null;d&&(h=new PreventNavigationController(d))}),function(e){e(".entities-list-item .dropdown-icon").click(function(t){t.preventDefault(),e(this).parent().parent().hasClass("open")?e(this).parent().parent().removeClass("open"):e(this).parent().parent().addClass("open")});var t=!0;e(window).load(function(){e("#entity-form .lock").hasClass("open")&&(t=!1,e("#entity-form").find("input, textarea").attr("disabled",t));var n=e("#entities .entities-list:visible"),i=e(".active",n).first();if(0!=i.length){var a=i.position().top;n.scrollTop(a),e(".site-brand-name input").attr("placeholder",e("#global_name").val())}}),e("#global_name").change(function(){e(".site-brand-name input").attr("placeholder",e(this).val())}),e(".error-accordion .collapsible-ul").hide(),e(".error-accordion h3").click(function(){e(this).parent().find(".collapsible-ul").toggle()}),e("#selectYearAndMonthForm select").change(function(){var t="/kms/orders/voltooid?month="+e("#selectYearAndMonthForm select#orderMonthSelector").val()+"&year="+e("#selectYearAndMonthForm select#orderYearSelector").val();window.location=t}),e("#productCategorySelector").change(function(){window.location="/kms/products?category="+encodeURIComponent(this.value)});var n=function(){e("#flash-message").fadeOut()};e("#flash-message").click(function(){n()}),setTimeout(function(){n()},5e3),e("#entity-form .lock").click(function(){e(this).toggleClass("open"),t=!t,e(this).parents("#entity-form").find("input, textarea").attr("disabled",t)});var i=jQuery("#sort_order"),a=(jQuery("#autoSubmit"),jQuery("#message-box"),jQuery(".fieldGroupItems"));a.children("li").each(function(){var e=jQuery(this);e.data("id",e.attr("title")).attr("title","")}),a.sortable({opacity:.7,update:function(){}}),jQuery("#dd-form").bind("submit",function(e){var t,n;e&&e.preventDefault(),t=!0,n=[],a.children("li").each(function(){n.push(jQuery(this).data("id"))}),i.val(n.join(",")),console.log(i.val()),t&&request()})}(jQuery),document.addEventListener("DOMContentLoaded",function(){for(var e=document.getElementsByClassName("js-sidebar-item-with-submenu"),t=e.length,n=0;n<t;n++){e[n].querySelector(".js-toggle-list").addEventListener("click",function(){this.parentElement.querySelector(".js-sidebar-submenu").classList.toggle("is-open")})}});