!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define("Fred",[],t):"object"==typeof exports?exports.Fred=t():e.Fred=t()}(this,function(){return function(e){function t(r){if(n[r])return n[r].exports;var i=n[r]={exports:{},id:r,loaded:!1};return e[r].call(i.exports,i,i.exports,t),i.loaded=!0,i.exports}var n={};return t.m=e,t.c=n,t.p="",t(0)}([function(e,t,n){"use strict";function r(e){return e&&e.__esModule?e:{default:e}}function i(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(t,"__esModule",{value:!0});var A=function(){function e(e,t){for(var n=0;n0&&void 0!==arguments[0]?arguments[0]:{};i(this,e),B.default.jwt=n.jwt,delete n.jwt,B.default.permission=n.permission,delete n.permission,B.default.resource=n.resource,delete n.resource,B.default.config=n||{},B.default.fred=this,this.loading=null,this.wrapper=null,this.fingerprint="",this.libs=h.default,this.Finder=b.default,this.previewDocument=null,this.replaceScript=this.replaceScript.bind(this),this.scriptsToReplace=[];var r=this.loadLexicons();document.addEventListener("DOMContentLoaded",function(){var e=document.body.querySelectorAll("script-fred"),n=!0,i=!1,A=void 0;try{for(var o,a=e[Symbol.iterator]();!(n=(o=a.next()).done);n=!0){for(var s=o.value,l=document.createElement("script"),c=0;c"+B.default.lng("fred.fe.preview.tablet_portrait")+"",B.default.lng("fred.fe.preview.tablet_portrait"),"",["fred--tablet-portrait"],function(){e.iframe.style.width="768px",e.iframe.style.height="1024px"}),this.devices.appendChild(this.tabletP),this.tabletL=(0,w.a)(""+B.default.lng("fred.fe.preview.tablet_landscape")+"",B.default.lng("fred.fe.preview.tablet_landscape"),"",["fred--tablet-landscape"],function(){e.iframe.style.width="1024px",e.iframe.style.height="768px"}),this.devices.appendChild(this.tabletL),this.phoneP=(0,w.a)(""+B.default.lng("fred.fe.preview.phone_portrait")+"",B.default.lng("fred.fe.preview.phone_portrait"),"",["fred--smartphone-portrait"],function(){e.iframe.style.width="320px",e.iframe.style.height="480px"}),this.devices.appendChild(this.phoneP),this.phoneL=(0,w.a)(""+B.default.lng("fred.fe.preview.phone_landscape")+"",B.default.lng("fred.fe.preview.phone_landscape"),"",["fred--smartphone-landscape"],function(){e.iframe.style.width="480px",e.iframe.style.height="320px"}),this.devices.appendChild(this.phoneL),this.auto=(0,w.a)(""+B.default.lng("fred.fe.preview.auto")+"",B.default.lng("fred.fe.preview.auto"),"",["fred--auto"],function(){e.iframe.style.width="100%",e.iframe.style.height="100%"}),this.devices.appendChild(this.auto),this.controls.appendChild(this.devices),t.append(this.controls),t.appendChild(this.iframe),this.wrapper.insertBefore(t,this.wrapper.firstChild)}},{key:"previewContent",value:function(){var e=this;return this.previewDocument?this.getPreviewContent():(this.renderPreview(),this.iframe.src=B.default.resource.emptyUrl,(0,H.getPreview)().then(function(t){var n=new DOMParser;return e.previewDocument=n.parseFromString(t,"text/html"),e.getPreviewContent()}))}},{key:"getPreviewContent",value:function(){for(var e=this,t=[],n=function(n){t.push(e.getCleanDropZoneContent(e.dropzones[n],!0,!1).then(function(t){var r=e.previewDocument.querySelector('[data-fred-dropzone="'+e.dropzones[n].dataset.fredDropzone+'"]');r&&(r.innerHTML=t)}))},r=0;r1&&void 0!==arguments[1]&&arguments[1],n=!(arguments.length>2&&void 0!==arguments[2])||arguments[2],r="",i=[],A=!0,o=!1,a=void 0;try{for(var s,l=e.children[Symbol.iterator]();!(A=(s=l.next()).done);A=!0){var c=s.value;i.push(c.fredEl.cleanRender(t,n))}}catch(e){o=!0,a=e}finally{try{!A&&l.return&&l.return()}finally{if(o)throw a}}return Promise.all(i).then(function(e){return e.forEach(function(e){r+=e.innerHTML}),r})}},{key:"save",value:function(){var e=this;if(B.default.permission.save_document){a.default.emit("fred-loading",B.default.lng("fred.fe.saving_page"));for(var t={},n={},r=[],i=function(i){n[e.dropzones[i].dataset.fredDropzone]=e.getDataFromDropZone(e.dropzones[i]);var A=e.dropzones[i].querySelectorAll('[data-fred-target]:not([data-fred-target=""])'),o=!0,a=!1,s=void 0;try{for(var l,c=A[Symbol.iterator]();!(o=(l=c.next()).done);o=!0){var u=l.value;B.default.pageSettings.hasOwnProperty(u.dataset.fredTarget)?B.default.pageSettings[u.dataset.fredTarget]=S.default.getElValue(u):0!==u.dataset.fredTarget.indexOf("tv_")||""===u.dataset.fredTarget.substr(3)?t[u.dataset.fredTarget]=S.default.getElValue(u):B.default.pageSettings.tvs[u.dataset.fredTarget.substr(3)]=S.default.getElValue(u)}}catch(e){a=!0,s=e}finally{try{!o&&c.return&&c.return()}finally{if(a)throw s}}r.push(e.getCleanDropZoneContent(e.dropzones[i]).then(function(n){t[e.dropzones[i].dataset.fredDropzone]=n}))},A=0;A0&&(B.default.invalidElements=!0,e.invalidElementsWarning=(0,w.div)(["fred--alert-invalid"],"fred.fe.invalid_elements_warning"),e.wrapper.appendChild(e.invalidElementsWarning)),a.default.emit("fred-loading-hide")})})}},{key:"registerListeners",value:function(){var e=this;a.default.on("fred-save",function(){e.save()}),a.default.on("fred-wrapper-insert",function(t){e.wrapper.appendChild(t)}),a.default.on("fred-loading",function(t){null===e.loading&&(t=t||"",e.loading=(0,w.section)(["fred--modal-bg","fred--modal_loading"]),e.loading.innerHTML='
'+t+"
",e.wrapper.appendChild(e.loading))}),a.default.on("fred-loading-hide",function(){null!==e.loading&&(e.loading.remove(),e.loading=null)}),a.default.on("fred-page-setting-change",function(t,n,r){e.dropzones.forEach(function(e){var i=e.querySelectorAll('[data-fred-target="'+t+'"'),A=!0,o=!1,a=void 0;try{for(var s,l=i[Symbol.iterator]();!(A=(s=l.next()).done);A=!0){var c=s.value;c!==r&&c.fredEl.setElValue(c,n)}}catch(e){o=!0,a=e}finally{try{!A&&l.return&&l.return()}finally{if(o)throw a}}})}),a.default.on("fred-preview-on",function(){e.previewContent().then(function(e){document.body.classList.add("fred--fixed"),e.parentNode.style.opacity=null,e.parentNode.style.zIndex=null,e.parentNode.style.display="block"})}),a.default.on("fred-preview-off",function(){document.body.classList.remove("fred--fixed"),e.iframe.parentNode.style.opacity=null,e.iframe.parentNode.style.zIndex=null,e.iframe.parentNode.style.display="none"}),a.default.on("fred-logout-user",function(){e.logoutUser()}),a.default.on("fred-clear-invalid-elements-warning",function(){0===document.querySelectorAll(".fred--block-invalid").length&&(B.default.invalidElements=!1,e.invalidElementsWarning&&e.invalidElementsWarning.remove())})}},{key:"registerKeyboardShortcuts",value:function(){E.default.bindGlobal("mod+s",function(e){e.preventDefault?e.preventDefault():e.returnValue=!1,a.default.emit("fred-save")}),E.default.bind("up up down down left right left right b a enter",function(){!function(){function e(){var e=document.createElement("link");e.setAttribute("type","text/css"),e.setAttribute("rel","stylesheet"),e.setAttribute("href",b),e.setAttribute("class",C),document.body.appendChild(e)}function t(){for(var e=document.getElementsByClassName(C),t=0;tf&&t.heightp&&t.width=Q&&t<=E+Q}function l(){var e=document.createElement("audio");e.setAttribute("class",C),e.src=m,e.loop=!1,e.addEventListener("canplay",function(){setTimeout(function(){c(U)},500),setTimeout(function(){d(),n();for(var e=0;eIf you are reading this, it is because your browser does not support the audio element. We recommend that you get a new browser.

",document.body.appendChild(e),e.play()}function c(e){e.className+=" "+v+" "+B}function u(e){e.className+=" "+v+" "+w[Math.floor(Math.random()*w.length)]}function d(){for(var e=document.getElementsByClassName(v),t=new RegExp("\\b"+v+"\\b"),n=0;n0&&this._events[e].length>i&&(this._events[e].warned=!0,console.error("(node) warning: possible EventEmitter memory leak detected. %d listeners added. Use emitter.setMaxListeners() to increase limit.",this._events[e].length),"function"==typeof console.trace&&console.trace())),this},n.prototype.on=n.prototype.addListener,n.prototype.once=function(e,t){function n(){this.removeListener(e,n),i||(i=!0,t.apply(this,arguments))}if(!r(t))throw TypeError("listener must be a function");var i=!1;return n.listener=t,this.on(e,n),this},n.prototype.removeListener=function(e,t){var n,i,o,a;if(!r(t))throw TypeError("listener must be a function");if(!this._events||!this._events[e])return this;if(n=this._events[e],o=n.length,i=-1,n===t||r(n.listener)&&n.listener===t)delete this._events[e],this._events.removeListener&&this.emit("removeListener",e,t);else if(A(n)){for(a=o;a-- >0;)if(n[a]===t||n[a].listener&&n[a].listener===t){i=a;break}if(i<0)return this;1===n.length?(n.length=0,delete this._events[e]):n.splice(i,1),this._events.removeListener&&this.emit("removeListener",e,t)}return this},n.prototype.removeAllListeners=function(e){var t,n;if(!this._events)return this;if(!this._events.removeListener)return 0===arguments.length?this._events={}:this._events[e]&&delete this._events[e],this;if(0===arguments.length){for(t in this._events)"removeListener"!==t&&this.removeAllListeners(t);return this.removeAllListeners("removeListener"),this._events={},this}if(n=this._events[e],r(n))this.removeListener(e,n);else if(n)for(;n.length;)this.removeListener(e,n[n.length-1]);return delete this._events[e],this},n.prototype.listeners=function(e){var t;return t=this._events&&this._events[e]?r(this._events[e])?[this._events[e]]:this._events[e].slice():[]},n.prototype.listenerCount=function(e){if(this._events){var t=this._events[e];if(r(t))return 1;if(t)return t.length}return 0},n.listenerCount=function(e,t){return e.listenerCount(t)}},function(e,t,n){"use strict";function r(e){return e&&e.__esModule?e:{default:e}}function i(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(t,"__esModule",{value:!0});var A=function(){function e(e,t){for(var n=0;n0&&void 0!==arguments[0]&&arguments[0];e===!1&&(this.visible=!1),y.default.hide(),window.removeEventListener("click",this.globalHideSidebar)}},{key:"showSidebar",value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]&&arguments[0];t===!0&&this.visible===!1||(this.visible=!0,y.default.show(),setTimeout(function(){window.addEventListener("click",e.globalHideSidebar)},50))}},{key:"globalHideSidebar",value:function(e){null===e.target.parentElement||this.fredWrapper.contains(e.target)||this.components.forEach(function(e){e.collapse()})}}]),e}();t.default=E,e.exports=t.default},function(e,t,n){"use strict";function r(e){return e&&e.__esModule?e:{default:e}}function i(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function A(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function o(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}Object.defineProperty(t,"__esModule",{value:!0});var a=function(){function e(e,t){for(var n=0;n0){var A=(0,d.dl)(["fred--hidden"]);A.setAttribute("aria-disabled","true"),n.buildTree(e.children,A);var o=(0,d.button)("","fred.fe.pages.expand_page",["fred--btn-list","fred--btn-list_expand"],function(){return o.classList.contains("fred--btn-list_close")?(o.classList.remove("fred--btn-list_close"),A.classList.add("fred--hidden"),A.setAttribute("aria-disabled","true"),void o.setAttribute("title",h.default.lng("fred.fe.pages.collapse_page"))):(o.classList.add("fred--btn-list_close"),A.classList.remove("fred--hidden"),A.setAttribute("aria-disabled","false"),void o.setAttribute("title",h.default.lng("fred.fe.pages.collapse_page")))});r.insertBefore(o,r.firstChild),t.append(A)}})}},{key:"createMenu",value:function(e){var t=this,n=(0,d.div)(["fred--pages_menu"]),r=(0,d.h3)(e.pagetitle),i=(0,d.a)("fred.fe.pages.edit","fred.fe.pages.edit",e.url);if(n.appendChild(r),n.appendChild(i),h.default.permission.resource_duplicate){var A=(0,d.button)("fred.fe.pages.duplicate","fred.fe.pages.duplicate",[],function(){var t={title:"Duplicate of "+e.pagetitle,duplicate_children:!1,publishing_options:"preserve"},n=function(e,n){t[e]=n},r=[(0,f.text)({label:"fred.fe.pages.page_title",name:"pagetitle"},t.title,n)];e.children.length>0&&(t.duplicate_children=!0,r.push((0,f.toggle)({label:"Duplicate Children",name:"duplicate_children"},t.duplicate_children,n))),r.push((0,f.select)({label:"Publishing Options",name:"publishing_options",options:{unpublish:"Make All Unpublished",publish:"Make All Published",preserve:"Preserve Published Status"}},t.publishing_options,n));var i=new w.default("Duplicate Page",(0,d.div)([],r),function(){(0,g.duplicateResource)(t.title,t.duplicate_children,t.publishing_options,e.id).then(function(e){console.log(e)}).catch(function(e){})},{showCancelButton:!0});i.render()});n.appendChild(A)}var o=(0,d.button)("fred.fe.pages.publish","fred.fe.pages.publish",[],function(){u.default.emit("fred-loading",h.default.lng("fred.fe.pages.publishing_page")),(0,g.publishResource)(e.id).then(function(){o.replaceWith(a),u.default.emit("fred-loading-hide")}).catch(function(e){u.default.emit("fred-loading-hide")})}),a=(0,d.button)("fred.fe.pages.unpublish","fred.fe.pages.unpublish",[],function(){u.default.emit("fred-loading",h.default.lng("fred.fe.pages.unpublishing_page")),(0,g.unpublishResource)(e.id).then(function(){a.replaceWith(o),u.default.emit("fred-loading-hide")}).catch(function(e){u.default.emit("fred-loading-hide")})});if(e.published===!0?h.default.permission.unpublish_document&&n.appendChild(a):h.default.permission.publish_document&&n.appendChild(o),h.default.permission.new_document){var s=(0,d.button)("fred.fe.pages.create_child_page","fred.fe.pages.create_child_page",[],function(n){t.state.parent=e.id,t.parentInput.choices.setValueByChoice(""+e.id),t.templateInput.choices.setValueByChoice(""+e.template);var r=t.templateInput.choices.getValue();r.customProperties&&r.customProperties.theme&&(t.state.theme=r.customProperties.theme,t.blueprintInput.choices.clearStore(),t.blueprintInput.choices.ajax(function(e){(0,m.getBlueprints)(!0,t.state.theme).then(function(t){var n=[];t.forEach(function(e){var t=[];e.blueprints.forEach(function(e){t.push({label:e.name,value:""+e.id})}),n.push({label:e.category,disabled:!1,choices:t})}),e(n,"value","label")}).catch(function(e){u.default.emit("fred-loading",e.message)})})),t.openCreatePage(n)});n.appendChild(s)}var l=(0,d.button)("fred.fe.pages.delete","fred.fe.pages.delete",[],function(){u.default.emit("fred-loading",h.default.lng("fred.fe.pages.deleting_page")),(0,g.deleteResource)(e.id).then(function(){l.replaceWith(c),u.default.emit("fred-loading-hide")}).catch(function(e){u.default.emit("fred-loading-hide")})}),c=(0,d.button)("fred.fe.pages.undelete","fred.fe.pages.undelete",[],function(){u.default.emit("fred-loading",h.default.lng("fred.fe.pages.undeleting_page")),(0,g.undeleteResource)(e.id).then(function(){ c.replaceWith(l),u.default.emit("fred-loading-hide")}).catch(function(e){u.default.emit("fred-loading-hide")})});return e.deleted===!0?h.default.permission.undelete_document&&n.appendChild(c):h.default.permission.delete_document&&n.appendChild(l),n}}]),t}(l.default));y.title="fred.fe.pages",y.icon="fred--sidebar_pages",y.expandable=!0,t.default=y,e.exports=t.default},function(e,t,n){"use strict";function r(e){return e&&e.__esModule?e:{default:e}}function i(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(t,"__esModule",{value:!0});var A="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},o=function(){function e(e,t){for(var n=0;n1&&void 0!==arguments[1]&&arguments[1];n.titleEl=(0,u.dt)(e),n.constructor.icon&&n.titleEl.classList.add(n.constructor.icon),t===!1?n.titleEl.addEventListener("click",n.click):n.titleEl.addEventListener("click",function(){n.titleEl.classList.contains("active")?s.default.emit("fred-sidebar-collapse",n):s.default.emit("fred-sidebar-expand",n,e,n.click())}),n.contentEl=document.createElement("dd"),n.sidebarWrapper.appendChild(n.titleEl),n.sidebarWrapper.appendChild(n.contentEl)};this.init(),r(this.constructor.title,this.constructor.expandable)}return o(e,[{key:"init",value:function(){}},{key:"click",value:function(){}},{key:"expand",value:function(){this.titleEl.classList.add("active")}},{key:"collapse",value:function(){this.titleEl.classList.remove("active")}},{key:"setContent",value:function(e){return"object"===("undefined"==typeof e?"undefined":A(e))&&void 0!==e.outerHTML?(this.contentEl.innerHTML="",this.contentEl.appendChild((0,u.h3)(this.constructor.title)),void this.contentEl.appendChild(e)):(this.contentEl.appendChild((0,u.h3)(this.constructor.title)),void(this.contentEl.innerHTML=e))}},{key:"loading",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"";e=e||"Retrieving "+c.default.lng(this.constructor.title);var t=(0,u.div)("fred--loading_wrapper",[(0,u.span)("fred--loading"),e]);this.setContent(t)}},{key:"afterExpand",value:function(){}}]),e}();d.title="TITLE NOT SET",d.icon="",d.expandable=!1,t.default=d,e.exports=t.default},function(e,t,n){"use strict";function r(e){return e&&e.__esModule?e:{default:e}}function i(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(t,"__esModule",{value:!0});var A="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},o=function(){function e(e,t){for(var n=0;n1&&void 0!==arguments[1]?arguments[1]:"",r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:function(){},A=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{};i(this,e),this.wrapper=null,c.default.lngExists(t)&&(t=c.default.lng(t)),this.title=t,this.content=n,this.onSave=r,this.showCancelButton=A.showCancelButton||!1,this.cancelButtonText=A.cancelButtonText||"fred.fe.cancel",this.saveButtonText=A.saveButtonText||"fred.fe.save",this.cancelButton=null,this.saveButton=null}return A(e,[{key:"setTitle",value:function(e){this.title=e,null!==this.wrapper&&(this.titleEl.innerHTML=e)}},{key:"setContent",value:function(e){this.content=e,null!==this.wrapper&&("string"==typeof this.content?this.body.innerHTML=this.content:(this.body.innerHTML="",this.body.appendChild(this.content)))}},{key:"render",value:function(){var e=this;this.wrapper=(0,s.section)(["fred--modal-bg"]);var t=(0,s.div)(["fred--modal"]);t.setAttribute("aria-hidden","true");var n=(0,s.div)(["fred--modal-header"]),r=(0,s.button)('',"fred.fe.close",["button"],this.close.bind(this));this.titleEl=(0,s.h4)(this.title),this.body=(0,s.div)(["fred--modal-body"]),"string"==typeof this.content?this.body.innerHTML=this.content:this.body.appendChild(this.content);var i=(0,s.div)(["fred--modal-footer"]);return this.showCancelButton===!0&&(this.cancelButton=(0,s.button)(this.cancelButtonText,this.cancelButtonText,["fred--btn-small","fred--btn-danger"],function(){e.close()}),i.appendChild(this.cancelButton)),this.saveButton=(0,s.button)(this.saveButtonText,this.saveButtonText,["fred--btn-small"],function(){e.onSave(),e.close()}),i.appendChild(this.saveButton),n.appendChild(r),n.appendChild(this.titleEl),t.appendChild(n),t.appendChild(this.body),t.appendChild(i),this.wrapper.appendChild(t),a.default.emit("fred-wrapper-insert",this.wrapper),this.wrapper}},{key:"disableSave",value:function(){this.saveButton&&this.saveButton.setAttribute("disabled","disabled")}},{key:"enableSave",value:function(){this.saveButton&&this.saveButton.removeAttribute("disabled")}},{key:"close",value:function(){this.wrapper.remove()}}]),e}();t.default=u},function(e,t,n){"use strict";function r(e){return e&&e.__esModule?e:{default:e}}function i(e){if(Array.isArray(e)){for(var t=0,n=Array(e.length);t1&&void 0!==arguments[1]?arguments[1]:[],n=document.createElement(e);return l(n,t),n},u=t.div=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"",n=c("div",e);return s(n,t),n},d=t.span=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"",n=c("span",e);return s(n,t),n},f=t.dl=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],t=c("dl",e);return t.setAttribute("tabindex","0"),t.setAttribute("role","tablist"),t},p=t.dd=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],t=c("dd",e);return t.setAttribute("tabindex","0"),t.setAttribute("role","tablist"),t},h=t.dt=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"",t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[],n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null,r=c("dt",t);return r.setAttribute("tabindex","0"),r.setAttribute("role","tab"),s(r,e),"function"==typeof n&&r.addEventListener("click",function(e){e.preventDefault(),n(e,r)}),r},g=t.section=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];return c("section",e)},m=t.button=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"",t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"",n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:[],r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:null,i=c("button",n);return i.setAttribute("role","button"),s(i,e),t&&(a.default.lngExists(t)?i.setAttribute("title",a.default.lng(t)):i.setAttribute("title",t)),"function"==typeof r&&i.addEventListener("click",function(e){e.preventDefault(),r(e,i)}),i},v=t.h1=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[],n=c("h1",t);return s(n,e),n},B=t.h2=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[],n=c("h2",t);return s(n,e),n},w=t.h3=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[],n=c("h3",t);return s(n,e),n},y=t.h4=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[],n=c("h4",t);return s(n,e),n},b=t.img=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"",n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:[],r=c("img",n);return r.src=e,t&&r.setAttribute("alt",t),r},C=t.a=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"",n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"",r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:[],i=arguments.length>4&&void 0!==arguments[4]?arguments[4]:null,A=c("a",r);return s(A,e),t&&t&&(a.default.lngExists(t)?A.setAttribute("title",a.default.lng(t)):A.setAttribute("title",t)),n&&A.setAttribute("href",n),"function"==typeof i&&A.addEventListener("click",function(e){e.preventDefault(),i(e,A)}),A},E=t.i=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];return c("i",e)},Q=t.form=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];return c("form",e)},F=t.label=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[],n=c("label",t);return s(n,e),n},U=t.input=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"",t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"text",n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:[],r=c("input",n);return r.setAttribute("type",t),e&&("checkbox"===t?e===!0&&r.setAttribute("checked","checked"):r.value=e),r},_=t.select=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];return c("select",e)},H=t.textArea=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"",t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[],n=c("textarea",t);return n.innerHTML=e,n},T=t.fieldSet=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];return c("fieldset",e)},S=t.legend=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"",t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[],n=c("legend",t);return s(n,e),n},x=t.figure=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];return c("figure",e)},k=t.figCaption=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"",t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[],n=c("figcaption",t);return s(n,e),n},I=t.iFrame=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[],n=c("iframe",t);return n.src=e,n};t.default={div:u,span:d,dl:f,dd:p,dt:h,section:g,button:m,h1:v,h2:B,h3:w,h4:y,a:C,i:E,img:b,form:Q,label:F,input:U,select:_,textArea:H,fieldSet:T,legend:S,figure:x,figCaption:k,iFrame:I}},function(e,t,n){"use strict";function r(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(t,"__esModule",{value:!0});var i=n(11),A=r(i),o=n(13),a=r(o);t.default={els:A.default,ins:a.default},e.exports=t.default},function(e,t,n){"use strict";function r(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(t,"__esModule",{value:!0}),t.tagger=t.choices=t.file=t.image=t.page=t.slider=t.colorPicker=t.colorSwatch=t.dateTime=t.area=t.toggle=t.select=t.text=void 0;var i=Object.assign||function(e){for(var t=1;t1&&void 0!==arguments[1]?arguments[1]:"",n=arguments[2],r=arguments[3],i=(0,g.label)(e.label||e.name),A=(0,g.input)(t),o=null;return A.addEventListener("keyup",function(t){null!==o&&(o.remove(),A.removeAttribute("aria-invalid"),o=null),"function"==typeof n&&n(e.name,A.value,A,e)}),i.onError=function(e){A.setAttribute("aria-invalid","true"),null===o?(o=(0,g.div)("error",e),i.appendChild(o)):o.innerHTML=e},i.appendChild(A),"function"==typeof r&&r(e,i,A),i},Q=t.select=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"",n=arguments[2],r=arguments[3],i=(0,g.label)(e.label||e.name),A=(0,g.select)();if(e.options)for(var o in e.options)if(e.options.hasOwnProperty(o)){var a=document.createElement("option");a.innerHTML=e.options[o],a.value=o,o===t&&a.setAttribute("selected","selected"),A.appendChild(a)}return"function"==typeof n&&A.addEventListener("change",function(t){e.options[A.value]&&n(e.name,A.value,A,e)}),i.appendChild(A),"function"==typeof r&&r(e,i,A),i},F=t.toggle=function(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1],n=arguments[2],r=arguments[3],i=(0,g.label)(e.label||e.name,"fred--toggle"),A=(0,g.input)(t,"checkbox");i.inputEl=A,"function"==typeof n&&A.addEventListener("change",function(t){n(e.name,t.target.checked,A,e)});var o=(0,g.span)();return i.appendChild(A),i.appendChild(o),"function"==typeof r&&r(e,i,A,o),i},U=t.area=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"",n=arguments[2],r=arguments[3],i=(0,g.label)(e.label||e.name),A=(0,g.textArea)(t);return e.rows&&parseInt(e.rows)>0?A.setAttribute("rows",parseInt(e.rows)):A.setAttribute("rows",4),"function"==typeof n&&A.addEventListener("keyup",function(t){n(e.name,A.value,A,e)}),i.appendChild(A),"function"==typeof r&&r(e,i,A),i},_=t.dateTime=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,n=arguments[2],r=arguments[3];t=parseInt(t)||0;var i=(0,g.label)(e.label||e.name),A=(0,g.div)(["fred--input-group","fred--datetime"]),o=(0,g.input)(),s=(0,a.default)(o,{enableTime:!0,dateFormat:"Y-m-d H:i",appendTo:A,defaultDate:0===t?"":1e3*t,onChange:function(t){"function"==typeof n&&(0===t.length?n(e.name,0,s,e):n(e.name,t[0].getTime()/1e3,s,e))}});i.picker=s;var l=(0,g.a)("","fred.fe.clear","","fred--close-small",function(){s.clear()});return A.appendChild(o),A.appendChild(l),i.appendChild(A),"function"==typeof r&&r(e,i,o),i},H=t.colorSwatch=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"",n=arguments[2],r=arguments[3],i=(0,g.label)(e.label||e.name),o=(0,g.div)("fred--color_swatch"),a=(0,g.div)("fred--color_swatch-preview"),s=(0,g.div)(["fred--color_swatch-colors","fred--hidden"]);t&&(a.style.backgroundColor=t);var l=!1;a.addEventListener("click",function(e){e.preventDefault(),l===!1?(l=!0,s.classList.remove("fred--hidden")):(l=!1,s.classList.add("fred--hidden"))});var c=!1;return e.options&&e.options.forEach(function(r){if("object"===("undefined"==typeof r?"undefined":A(r))){var i=(0,g.div)("fred--color_swatch-color");i.style.background=r.color,r.width&&parseFloat(r.width)>1&&(i.style.width=30*parseFloat(r.width)+"px"),r.label&&""!==r.label.trim()&&i.setAttribute("data-tooltip",r.label),!c&&t&&r.value===t&&(c=!0,t&&(a.style.background=r.color)),i.addEventListener("click",function(t){t.preventDefault(),"function"==typeof n&&n(e.name,r.value,i,e),a.style.background=r.color}),s.appendChild(i)}else{var o=(0,g.div)("fred--color_swatch-color");o.style.backgroundColor=r,o.addEventListener("click",function(t){t.preventDefault(),"function"==typeof n&&n(e.name,r,o,e),a.style.background=r}),s.appendChild(o)}}),o.appendChild(a),o.appendChild(s),i.appendChild(o),"function"==typeof r&&r(e,i,o,a,s),i},T=t.colorPicker=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"",n=arguments[2],r=arguments[3],i=(0,g.label)(e.label||e.name),A=(0,g.div)("fred--color_picker"),o=(0,g.div)("fred--color_picker-preview"),a=!1,s=null;o.addEventListener("click",function(r){r.preventDefault(),a===!1?(a=!0,s=u.default.createPicker({attachTo:l,color:t,showAlpha:void 0===e.showAlpha||e.showAlpha,paletteEditable:!1,palette:e.options||null}),s.onchange=function(r){"function"==typeof n&&n(e.name,r.color,r,e),o.style.backgroundColor=r.color,t=r.color}):(null!==s&&(s.element.remove(),s=null),a=!1)}),t&&(o.style.backgroundColor=t);var l=(0,g.div)();return A.appendChild(o),A.appendChild(l),i.appendChild(A),"function"==typeof r&&r(e,i,A,o,l),i},S=t.slider=function e(t){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,r=arguments[2],i=arguments[3],A=(0,g.label)(t.label||t.name);if(!t.min&&!t.max)return console.error("Slider Input error. Parameters min and max are required"),A;var o=(0,g.div)(),a=!1,s=1;t.step?s=t.step:t.tooltipDecimals&&(s=Math.pow(10,-1*t.tooltipDecimals));var e=f.default.create(o,{start:n,connect:[!0,!1],tooltips:{to:function(e){var n=void 0===t.tooltipDecimals?0:t.tooltipDecimals;return 0===n?parseInt(e.toFixed()):parseFloat(e.toFixed(n))}},format:{to:function(e){var n=void 0===t.tooltipDecimals?0:t.tooltipDecimals;return 0===n?parseInt(e.toFixed()):parseFloat(e.toFixed(n))},from:function(e){var n=void 0===t.tooltipDecimals?0:t.tooltipDecimals;return 0===n?parseInt(e):parseFloat(e).toFixed(n)}},step:s,range:{min:t.min,max:t.max}});return o.querySelector(".noUi-handle").addEventListener("keydown",function(e){var t=Number(o.noUiSlider.get());37===e.which&&o.noUiSlider.set(t-s),39===e.which&&o.noUiSlider.set(t+s)}),"function"==typeof r&&e.on("update",function(n,i,A,o,s){a===!1?a=!0:r(t.name,n[0],e,t)}),A.appendChild(o),"function"==typeof i&&i(t,A,o),A},x=t.page=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{id:0,url:""},n=arguments[2],r=arguments[3],A=(0,g.div)(),o=(0,g.label)(e.label||e.name,"fred--label-choices"),a=(0,g.select)();A.appendChild(o),A.appendChild(a);var s=null,c={},u=[],d=new l.default(a,{shouldSort:!1,removeItemButton:e.clearButton||!1,searchResultLimit:0});(0,B.fixChoices)(d);var f={};e.parents&&(f.parents=e.parents),e.resources&&(f.resources=e.resources),e.depth&&(f.depth=e.depth),d.ajax(function(e){(0,b.getResources)(t.id,f).then(function(n){u=n.data.resources,e(n.data.resources,"value","pagetitle"),n.data.current&&(d.setChoices([n.data.current],"value","pagetitle",!1),d.setValueByChoice(""+t.id))}).catch(function(e){v.default.emit("fred-loading",e.message)})});var p=function(e){var t=[];d.currentState.items.forEach(function(e){e.active&&t.push(e.value)});var n=[];e.forEach(function(e){t.indexOf(e.id)===-1&&n.push(e)}),d.setChoices(n,"value","pagetitle",!0)},h=function(){var e=d.input.value;e in c?p(c[e]):(0,b.getResources)(null,i({query:e},f)).then(function(t){c[e]=t.data.resources,p(t.data.resources)}).catch(function(e){v.default.emit("fred-loading",e.message)})};return d.passedElement.addEventListener("search",function(e){clearTimeout(s),s=setTimeout(h,200)}),d.passedElement.addEventListener("choice",function(t){d.setChoices(u,"value","pagetitle",!0),"function"==typeof n&&n(e.name,{url:t.detail.choice.customProperties.url,id:t.detail.choice.value},d,e)}),d.passedElement.addEventListener("removeItem",function(t){d.getValue()||"function"==typeof n&&n(e.name,{url:"",id:""},d,e)}),"function"==typeof r&&r(e,o,a),A},k=t.image=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"",n=arguments[2],r=arguments[3],i=(0,g.label)(e.label||e.name);e.showPreview=void 0===e.showPreview||e.showPreview;var A=(0,g.div)(["fred--input-group","fred--browse"]),o=(0,g.input)(t),a=(0,g.a)("","fred.fe.browse","","fred--browse-small"),s=(0,g.img)(""),l=!1,c={};e.mediaSource&&""!==e.mediaSource&&(c.mediaSource=e.mediaSource),o.addEventListener("keyup",function(t){e.showPreview===!0&&o.value?(s.src=o.value,l||(i.appendChild(s),l=!0)):l&&(s.src="",s.remove(),l=!1),"function"==typeof n&&n(e.name,o.value,o,e)});var u=function(t){t.preventDefault();var r=new h.default(function(t,r){"function"==typeof n&&n(e.name,t.url,o,e),o.value=t.url,s.src=t.url,e.showPreview!==!0||l||(i.appendChild(s),l=!0)},"fred.fe.browse_images",c);r.render()};return a.addEventListener("click",u),s.addEventListener("click",u),A.appendChild(o),A.appendChild(a),i.appendChild(A),o.value&&(s.src=o.value),e.showPreview===!0&&s.src&&(i.appendChild(s),l=!0),i.setPreview=function(t){e.showPreview===!0&&(s.src=t,l===!1&&(i.appendChild(s),l=!0))},"function"==typeof r&&r(e,i,o),i},I=t.file=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"",n=arguments[2],r=arguments[3],i=(0,g.label)(e.label||e.name),A=(0,g.div)(["fred--input-group","fred--browse"]),o=(0,g.input)(t),a=(0,g.a)("","fred.fe.browse","","fred--browse-small"),s={};e.mediaSource&&""!==e.mediaSource&&(s.mediaSource=e.mediaSource),o.addEventListener("keyup",function(t){"function"==typeof n&&n(e.name,o.value,o,e)});var l=function(t){t.preventDefault();var r=new h.default(function(t,r){"function"==typeof n&&n(e.name,t.url,o,e),o.value=t.url},"fred.fe.browse_files",s);r.render()};return a.addEventListener("click",l),A.appendChild(o),A.appendChild(a),i.appendChild(A),"function"==typeof r&&r(e,i,o),i},N=t.choices=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"",n=arguments[2],r=arguments[3],i=(0,g.div)(),A=(0,g.label)(e.label||e.name),o=(0,g.select)(),a=null;i.appendChild(A),i.appendChild(o);var s=e.choices||{};s.searchResultLimit=0;var c=new l.default(o,s);return(0,B.fixChoices)(c),i.choices=c,"function"==typeof n&&c.passedElement.addEventListener("choice",function(t){null!==a&&(a.remove(),a=null),n(e.name,t.detail.choice,o,e,c)}),A.onError=function(e){null===a?(a=(0,g.div)("error",e),A.appendChild(a)):a.innerHTML=e},"function"==typeof r&&r(e,A,o,c,t),i},L=t.tagger=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"",n=arguments[2];arguments[3];e.limit=e.limit||0;var r=(0,g.div)();return(0,C.getGroups)(e.group,e.autoTag).then(function(i){var A=t.split(",").filter(function(e){return e}),o=new y.default({id:e.group,name:e.label||e.name,tag_limit:e.limit||0,field_type:"tagger-field-tags",hide_input:e.hideInput||!1,show_autotag:e.autoTag||!1,allow_new:!1,as_radio:!1,tags:i},A,function(t){n(e.name,t.join(","),a,e,o)}),a=o.render();r.replaceWith(a)}).catch(function(e){v.default.emit("fred-loading",e.message)}),r};t.default={text:E,select:Q,toggle:F,area:U,dateTime:_,colorSwatch:H,colorPicker:T,slider:S,page:x,image:k,file:I,choices:N,tagger:L}},function(e,t,n){/* flatpickr v4.5.2, @license MIT */ !function(t,n){e.exports=n()}(this,function(){"use strict";function e(e,t,n){void 0===n&&(n=!1);var r;return function(){var i=this,A=arguments;null!==r&&clearTimeout(r),r=window.setTimeout(function(){r=null,n||e.apply(i,A)},t),n&&!r&&e.apply(i,A)}}function t(e,t,n){return void 0===n&&(n=!0),n!==!1?new Date(e.getTime()).setHours(0,0,0,0)-new Date(t.getTime()).setHours(0,0,0,0):e.getTime()-t.getTime()}function n(e,t,n){return n===!0?e.classList.add(t):void e.classList.remove(t)}function r(e,t,n){var r=window.document.createElement(e);return t=t||"",n=n||"",r.className=t,void 0!==n&&(r.textContent=n),r}function i(e){for(;e.firstChild;)e.removeChild(e.firstChild)}function A(e,t){return t(e)?e:e.parentNode?A(e.parentNode,t):void 0}function o(e,t){var n=r("div","numInputWrapper"),i=r("input","numInput "+e),A=r("span","arrowUp"),o=r("span","arrowDown");if(i.type="text",i.pattern="\\d*",void 0!==t)for(var a in t)i.setAttribute(a,t[a]);return n.appendChild(i),n.appendChild(A),n.appendChild(o),n}function a(a,s){function d(){Me.utils={getDaysInMonth:function(e,t){return void 0===e&&(e=Me.currentMonth),void 0===t&&(t=Me.currentYear),1===e&&(t%4===0&&t%100!==0||t%400===0)?29:Me.l10n.daysInMonth[e]}}}function p(){Me.element=Me.input=a,Me.isOpen=!1,ge(),me(),Ue(),Fe(),d(),Me.isMobile||K(),O(),(Me.selectedDates.length||Me.config.noCalendar)&&(Me.config.enableTime&&T(Me.config.noCalendar?Me.latestSelectedDateObj||Me.config.minDate:void 0),Le(!1)),w(),Me.showTimeInput=Me.selectedDates.length>0||Me.config.noCalendar;var e=/^((?!chrome|android).)*safari/i.test(navigator.userAgent);!Me.isMobile&&e&&ve(),Te("onReady")}function g(e){return e.bind(Me)}function w(){var e=Me.config;e.weekNumbers===!1&&1===e.showMonths||e.noCalendar!==!0&&window.requestAnimationFrame(function(){if(Me.calendarContainer.style.visibility="hidden",Me.calendarContainer.style.display="block",void 0!==Me.daysContainer){var t=(Me.days.offsetWidth+1)*e.showMonths;Me.daysContainer.style.width=t+"px",Me.calendarContainer.style.width=t+(void 0!==Me.weekWrapper?Me.weekWrapper.offsetWidth:0)+"px",Me.calendarContainer.style.removeProperty("visibility"),Me.calendarContainer.style.removeProperty("display")}})}function E(e){if(0!==Me.selectedDates.length){void 0!==e&&"blur"!==e.type&&De(e);var t=Me._input.value;H(),Le(),Me._input.value!==t&&Me._debouncedChange()}}function U(e,t){return e%12+12*c(t===Me.l10n.amPM[1])}function _(e){switch(e%24){case 0:case 12:return 12;default:return e%12}}function H(){if(void 0!==Me.hourElement&&void 0!==Me.minuteElement){var e=(parseInt(Me.hourElement.value.slice(-2),10)||0)%24,n=(parseInt(Me.minuteElement.value,10)||0)%60,r=void 0!==Me.secondElement?(parseInt(Me.secondElement.value,10)||0)%60:0;void 0!==Me.amPM&&(e=U(e,Me.amPM.textContent));var i=void 0!==Me.config.minTime||Me.config.minDate&&Me.minDateHasTime&&Me.latestSelectedDateObj&&0===t(Me.latestSelectedDateObj,Me.config.minDate,!0),A=void 0!==Me.config.maxTime||Me.config.maxDate&&Me.maxDateHasTime&&Me.latestSelectedDateObj&&0===t(Me.latestSelectedDateObj,Me.config.maxDate,!0);if(A){var o=void 0!==Me.config.maxTime?Me.config.maxTime:Me.config.maxDate;e=Math.min(e,o.getHours()),e===o.getHours()&&(n=Math.min(n,o.getMinutes())),n===o.getMinutes()&&(r=Math.min(r,o.getSeconds()))}if(i){var a=void 0!==Me.config.minTime?Me.config.minTime:Me.config.minDate;e=Math.max(e,a.getHours()),e===a.getHours()&&(n=Math.max(n,a.getMinutes())),n===a.getMinutes()&&(r=Math.max(r,a.getSeconds()))}x(e,n,r)}}function T(e){var t=e||Me.latestSelectedDateObj;t&&x(t.getHours(),t.getMinutes(),t.getSeconds())}function S(){var e=Me.config.defaultHour,t=Me.config.defaultMinute,n=Me.config.defaultSeconds;if(void 0!==Me.config.minDate){var r=Me.config.minDate.getHours(),i=Me.config.minDate.getMinutes();e=Math.max(e,r),e===r&&(t=Math.max(i,t)),e===r&&t===i&&(n=Me.config.minDate.getSeconds())}if(void 0!==Me.config.maxDate){var A=Me.config.maxDate.getHours(),o=Me.config.maxDate.getMinutes();e=Math.min(e,A),e===A&&(t=Math.min(o,t)),e===A&&t===o&&(n=Me.config.maxDate.getSeconds())}x(e,t,n)}function x(e,t,n){void 0!==Me.latestSelectedDateObj&&Me.latestSelectedDateObj.setHours(e%24,t,n||0,0),Me.hourElement&&Me.minuteElement&&!Me.isMobile&&(Me.hourElement.value=l(Me.config.time_24hr?e:(12+e)%12+12*c(e%12===0)),Me.minuteElement.value=l(t),void 0!==Me.amPM&&(Me.amPM.textContent=Me.l10n.amPM[c(e>=12)]),void 0!==Me.secondElement&&(Me.secondElement.value=l(n)))}function k(e){var t=parseInt(e.target.value)+(e.delta||0);(t/1e3>1||"Enter"===e.key&&!/[^\d]/.test(t.toString()))&&se(t)}function I(e,t,n,r){return t instanceof Array?t.forEach(function(t){return I(e,t,n,r)}):e instanceof Array?e.forEach(function(e){return I(e,t,n,r)}):(e.addEventListener(t,n,r),void Me._handlers.push({element:e,event:t,handler:n,options:r}))}function N(e){return function(t){1===t.which&&e(t)}}function L(){Te("onChange")}function O(){if(Me.config.wrap&&["open","close","toggle","clear"].forEach(function(e){Array.prototype.forEach.call(Me.element.querySelectorAll("[data-"+e+"]"),function(t){return I(t,"click",Me[e])})}),Me.isMobile)return void _e();var t=e(fe,50);if(Me._debouncedChange=e(L,Q),Me.daysContainer&&!/iPhone|iPad|iPod/i.test(navigator.userAgent)&&I(Me.daysContainer,"mouseover",function(e){"range"===Me.config.mode&&de(e.target)}),I(window.document.body,"keydown",ue),Me.config.static||I(Me._input,"keydown",ue),Me.config.inline||Me.config.static||I(window,"resize",t),void 0!==window.ontouchstart?I(window.document,"click",ae):I(window.document,"mousedown",N(ae)),I(window.document,"focus",ae,{capture:!0}),Me.config.clickOpens===!0&&(I(Me._input,"focus",Me.open),I(Me._input,"mousedown",N(Me.open))),void 0!==Me.daysContainer&&(I(Me.monthNav,"mousedown",N(Oe)),I(Me.monthNav,["keyup","increment"],k),I(Me.daysContainer,"mousedown",N(ye))),void 0!==Me.timeContainer&&void 0!==Me.minuteElement&&void 0!==Me.hourElement){var n=function(e){return e.target.select()};I(Me.timeContainer,["increment"],E),I(Me.timeContainer,"blur",E,{capture:!0}),I(Me.timeContainer,"mousedown",N(M)),I([Me.hourElement,Me.minuteElement],["focus","click"],n),void 0!==Me.secondElement&&I(Me.secondElement,"focus",function(){return Me.secondElement&&Me.secondElement.select()}),void 0!==Me.amPM&&I(Me.amPM,"mousedown",N(function(e){E(e),L()}))}}function D(e){var t=void 0!==e?Me.parseDate(e):Me.latestSelectedDateObj||(Me.config.minDate&&Me.config.minDate>Me.now?Me.config.minDate:Me.config.maxDate&&Me.config.maxDate1),Me.calendarContainer.appendChild(e);var o=void 0!==Me.config.appendTo&&void 0!==Me.config.appendTo.nodeType;if((Me.config.inline||Me.config.static)&&(Me.calendarContainer.classList.add(Me.config.inline?"inline":"static"),Me.config.inline&&(!o&&Me.element.parentNode?Me.element.parentNode.insertBefore(Me.calendarContainer,Me._input.nextSibling):void 0!==Me.config.appendTo&&Me.config.appendTo.appendChild(Me.calendarContainer)),Me.config.static)){var a=r("div","flatpickr-wrapper");Me.element.parentNode&&Me.element.parentNode.insertBefore(a,Me.element),a.appendChild(Me.element),Me.altInput&&a.appendChild(Me.altInput),a.appendChild(Me.calendarContainer)}Me.config.static||Me.config.inline||(void 0!==Me.config.appendTo?Me.config.appendTo:window.document.body).appendChild(Me.calendarContainer)}function R(e,i,A,o){var a=le(i,!0),s=r("span","flatpickr-day "+e,i.getDate().toString());return s.dateObj=i,s.$i=o,s.setAttribute("aria-label",Me.formatDate(i,Me.config.ariaDateFormat)),e.indexOf("hidden")===-1&&0===t(i,Me.now)&&(Me.todayDateElem=s,s.classList.add("today"),s.setAttribute("aria-current","date")),a?(s.tabIndex=-1,xe(i)&&(s.classList.add("selected"),Me.selectedDateElem=s,"range"===Me.config.mode&&(n(s,"startRange",Me.selectedDates[0]&&0===t(i,Me.selectedDates[0],!0)),n(s,"endRange",Me.selectedDates[1]&&0===t(i,Me.selectedDates[1],!0)),"nextMonthDay"===e&&s.classList.add("inRange")))):s.classList.add("disabled"),"range"===Me.config.mode&&ke(i)&&!xe(i)&&s.classList.add("inRange"),Me.weekNumbers&&1===Me.config.showMonths&&"prevMonthDay"!==e&&A%7===1&&Me.weekNumbers.insertAdjacentHTML("beforeend",""+Me.config.getWeek(i)+""),Te("onDayCreate",s),s}function z(e){e.focus(),"range"===Me.config.mode&&de(e)}function j(e){for(var t=e>0?0:Me.config.showMonths-1,n=e>0?Me.config.showMonths:-1,r=t;r!=n;r+=e)for(var i=Me.daysContainer.children[r],A=e>0?0:i.children.length-1,o=e>0?i.children.length:-1,a=A;a!=o;a+=e){var s=i.children[a];if(s.className.indexOf("hidden")===-1&&le(s.dateObj))return s}}function V(e,t){for(var n=e.className.indexOf("Month")===-1?e.dateObj.getMonth():Me.currentMonth,r=t>0?Me.config.showMonths:-1,i=t>0?1:-1,A=n-Me.currentMonth;A!=r;A+=i)for(var o=Me.daysContainer.children[A],a=n-Me.currentMonth===A?e.$i+t:t<0?o.children.length-1:0,s=o.children.length,l=a;l>=0&&l0?s:-1);l+=i){var c=o.children[l];if(c.className.indexOf("hidden")===-1&&le(c.dateObj)&&Math.abs(e.$i-l)>=Math.abs(t))return z(c)}Me.changeMonth(i),X(j(i),0)}function X(e,t){var n=ce(document.activeElement||document.body),r=void 0!==e?e:n?document.activeElement:void 0!==Me.selectedDateElem&&ce(Me.selectedDateElem)?Me.selectedDateElem:void 0!==Me.todayDateElem&&ce(Me.todayDateElem)?Me.todayDateElem:j(t>0?1:-1);return void 0===r?Me._input.focus():n?void V(r,t):z(r)}function G(e,t){for(var n=(new Date(e,t,1).getDay()-Me.l10n.firstDayOfWeek+7)%7,i=Me.utils.getDaysInMonth((t-1+12)%12),A=Me.utils.getDaysInMonth(t),o=window.document.createDocumentFragment(),a=Me.config.showMonths>1,s=a?"prevMonthDay hidden":"prevMonthDay",l=a?"nextMonthDay hidden":"nextMonthDay",c=i+1-n,u=0;c<=i;c++,u++)o.appendChild(R(s,new Date(e,t-1,c),c,u));for(c=1;c<=A;c++,u++)o.appendChild(R("",new Date(e,t,c),c,u));for(var d=A+1;d<=42-n&&(1===Me.config.showMonths||u%7!==0);d++,u++)o.appendChild(R(l,new Date(e,t+1,d%A),d,u));var f=r("div","dayContainer");return f.appendChild(o),f}function Y(){if(void 0!==Me.daysContainer){i(Me.daysContainer),Me.weekNumbers&&i(Me.weekNumbers);for(var e=document.createDocumentFragment(),t=0;t11)]),Me.amPM.title=Me.l10n.toggleTitle,Me.amPM.tabIndex=-1,Me.timeContainer.appendChild(Me.amPM)),Me.timeContainer}function $(){Me.weekdayContainer?i(Me.weekdayContainer):Me.weekdayContainer=r("div","flatpickr-weekdays");for(var e=Me.config.showMonths;e--;){var t=r("div","flatpickr-weekdaycontainer");Me.weekdayContainer.appendChild(t)}return ee(),Me.weekdayContainer}function ee(){var e=Me.l10n.firstDayOfWeek,t=Me.l10n.weekdays.shorthand.concat();e>0&&e\n "+t.join("")+"\n \n "}function te(){Me.calendarContainer.classList.add("hasWeeks");var e=r("div","flatpickr-weekwrapper");e.appendChild(r("span","flatpickr-weekday",Me.l10n.weekAbbreviation));var t=r("div","flatpickr-weeks");return e.appendChild(t),{weekWrapper:e,weekNumbers:t}}function ne(e,t){void 0===t&&(t=!0);var n=t?e:e-Me.currentMonth;n<0&&Me._hidePrevMonthArrow===!0||n>0&&Me._hideNextMonthArrow===!0||(Me.currentMonth+=n,(Me.currentMonth<0||Me.currentMonth>11)&&(Me.currentYear+=Me.currentMonth>11?1:-1,Me.currentMonth=(Me.currentMonth+12)%12,Te("onYearChange")),Y(),Te("onMonthChange"),Ie())}function re(e){void 0===e&&(e=!0),Me.input.value="",void 0!==Me.altInput&&(Me.altInput.value=""),void 0!==Me.mobileInput&&(Me.mobileInput.value=""),Me.selectedDates=[],Me.latestSelectedDateObj=void 0,Me.showTimeInput=!1,Me.config.enableTime===!0&&S(),Me.redraw(),e&&Te("onChange")}function ie(){Me.isOpen=!1,Me.isMobile||(Me.calendarContainer.classList.remove("open"),Me._input.classList.remove("active")),Te("onClose")}function Ae(){void 0!==Me.config&&Te("onDestroy");for(var e=Me._handlers.length;e--;){var t=Me._handlers[e];t.element.removeEventListener(t.event,t.handler,t.options)}if(Me._handlers=[],Me.mobileInput)Me.mobileInput.parentNode&&Me.mobileInput.parentNode.removeChild(Me.mobileInput),Me.mobileInput=void 0;else if(Me.calendarContainer&&Me.calendarContainer.parentNode)if(Me.config.static&&Me.calendarContainer.parentNode){var n=Me.calendarContainer.parentNode;if(n.lastChild&&n.removeChild(n.lastChild),n.parentNode){for(;n.firstChild;)n.parentNode.insertBefore(n.firstChild,n);n.parentNode.removeChild(n)}}else Me.calendarContainer.parentNode.removeChild(Me.calendarContainer);Me.altInput&&(Me.input.type="text",Me.altInput.parentNode&&Me.altInput.parentNode.removeChild(Me.altInput),delete Me.altInput),Me.input&&(Me.input.type=Me.input._type,Me.input.classList.remove("flatpickr-input"),Me.input.removeAttribute("readonly"),Me.input.value=""),["_showTimeInput","latestSelectedDateObj","_hideNextMonthArrow","_hidePrevMonthArrow","__hideNextMonthArrow","__hidePrevMonthArrow","isMobile","isOpen","selectedDateElem","minDateHasTime","maxDateHasTime","days","daysContainer","_input","_positionElement","innerContainer","rContainer","monthNav","todayDateElem","calendarContainer","weekdayContainer","prevMonthNav","nextMonthNav","currentMonthElement","currentYearElement","navigationCurrentMonth","selectedDateElem","config"].forEach(function(e){try{delete Me[e]}catch(e){}})}function oe(e){return!(!Me.config.appendTo||!Me.config.appendTo.contains(e))||Me.calendarContainer.contains(e)}function ae(e){if(Me.isOpen&&!Me.config.inline){var t=oe(e.target),n=e.target===Me.input||e.target===Me.altInput||Me.element.contains(e.target)||e.path&&e.path.indexOf&&(~e.path.indexOf(Me.input)||~e.path.indexOf(Me.altInput)),r="blur"===e.type?n&&e.relatedTarget&&!oe(e.relatedTarget):!n&&!t,i=!Me.config.ignoredFocusElements.some(function(t){return t.contains(e.target)});r&&i&&(Me.close(),"range"===Me.config.mode&&1===Me.selectedDates.length&&(Me.clear(!1),Me.redraw()))}}function se(e){if(!(!e||Me.config.minDate&&eMe.config.maxDate.getFullYear())){var t=e,n=Me.currentYear!==t;Me.currentYear=t||Me.currentYear,Me.config.maxDate&&Me.currentYear===Me.config.maxDate.getFullYear()?Me.currentMonth=Math.min(Me.config.maxDate.getMonth(),Me.currentMonth):Me.config.minDate&&Me.currentYear===Me.config.minDate.getFullYear()&&(Me.currentMonth=Math.max(Me.config.minDate.getMonth(),Me.currentMonth)),n&&(Me.redraw(),Te("onYearChange"))}}function le(e,n){void 0===n&&(n=!0);var r=Me.parseDate(e,void 0,n);if(Me.config.minDate&&r&&t(r,Me.config.minDate,void 0!==n?n:!Me.minDateHasTime)<0||Me.config.maxDate&&r&&t(r,Me.config.maxDate,void 0!==n?n:!Me.maxDateHasTime)>0)return!1;if(0===Me.config.enable.length&&0===Me.config.disable.length)return!0;if(void 0===r)return!1;for(var i,A=Me.config.enable.length>0,o=A?Me.config.enable:Me.config.disable,a=0;a=i.from.getTime()&&r.getTime()<=i.to.getTime())return A}return!A}function ce(e){return void 0!==Me.daysContainer&&(e.className.indexOf("hidden")===-1&&Me.daysContainer.contains(e))}function ue(e){var t=e.target===Me._input,n=Me.config.allowInput,r=Me.isOpen&&(!n||!t),i=Me.config.inline&&t&&!n;if(13===e.keyCode&&t){if(n)return Me.setDate(Me._input.value,!0,e.target===Me.altInput?Me.config.altFormat:Me.config.dateFormat),e.target.blur();Me.open()}else if(oe(e.target)||r||i){var A=!!Me.timeContainer&&Me.timeContainer.contains(e.target);switch(e.keyCode){case 13:A?E():ye(e);break;case 27:e.preventDefault(),we();break;case 8:case 46:t&&!Me.config.allowInput&&(e.preventDefault(),Me.clear());break;case 37:case 39:if(A)Me.hourElement&&Me.hourElement.focus();else if(e.preventDefault(),void 0!==Me.daysContainer&&(n===!1||ce(document.activeElement))){var o=39===e.keyCode?1:-1;e.ctrlKey?(ne(o),X(j(1),0)):X(void 0,o)}break;case 38:case 40:e.preventDefault();var a=40===e.keyCode?1:-1;Me.daysContainer&&void 0!==e.target.$i?e.ctrlKey?(se(Me.currentYear-a),X(j(1),0)):A||X(void 0,7*a):Me.config.enableTime&&(!A&&Me.hourElement&&Me.hourElement.focus(),E(e),Me._debouncedChange());break;case 9:if(!A){Me.element.focus();break}var s=[Me.hourElement,Me.minuteElement,Me.secondElement,Me.amPM].filter(function(e){return e}),l=s.indexOf(e.target);if(l!==-1){var c=s[l+(e.shiftKey?-1:1)];void 0!==c?(e.preventDefault(),c.focus()):Me.element.focus()}}}if(void 0!==Me.amPM&&e.target===Me.amPM)switch(e.key){case Me.l10n.amPM[0].charAt(0):case Me.l10n.amPM[0].charAt(0).toLowerCase():Me.amPM.textContent=Me.l10n.amPM[0],H(),Le();break;case Me.l10n.amPM[1].charAt(0):case Me.l10n.amPM[1].charAt(0).toLowerCase():Me.amPM.textContent=Me.l10n.amPM[1],H(),Le()}Te("onKeyDown",e)}function de(e){if(1===Me.selectedDates.length&&(!e||e.classList.contains("flatpickr-day")&&!e.classList.contains("disabled"))){for(var t=e?e.dateObj.getTime():Me.days.firstElementChild.dateObj.getTime(),n=Me.parseDate(Me.selectedDates[0],void 0,!0).getTime(),r=Math.min(t,Me.selectedDates[0].getTime()),i=Math.max(t,Me.selectedDates[0].getTime()),A=Me.daysContainer.lastChild.lastChild.dateObj.getTime(),o=!1,a=0,s=0,l=r;lr&&la)?a=l:l>n&&(!s||l0&&f0&&f>s;return p?(A.classList.add("notAllowed"),["inRange","startRange","endRange"].forEach(function(e){A.classList.remove(e)}),"continue"):o&&!p?"continue":(["startRange","inRange","endRange","notAllowed"].forEach(function(e){A.classList.remove(e)}),void(void 0!==e&&(e.classList.add(t0&&d&&d.lastChild.dateObj.getTime()>=f||(nt&&f===n&&A.classList.add("endRange"),f>=a&&(0===s||f<=s)&&y(f,n,t)&&A.classList.add("inRange")))))},p=0,h=u.children.length;p0||n.getMinutes()>0||n.getSeconds()>0),Me.selectedDates&&(Me.selectedDates=Me.selectedDates.filter(function(e){return le(e)}),Me.selectedDates.length||"min"!==e||T(n),Le()),Me.daysContainer&&(Be(),void 0!==n?Me.currentYearElement[e]=n.getFullYear().toString():Me.currentYearElement.removeAttribute(e),Me.currentYearElement.disabled=!!r&&void 0!==n&&r.getFullYear()===n.getFullYear())}}function ge(){var e=["wrap","weekNumbers","allowInput","clickOpens","time_24hr","enableTime","noCalendar","altInput","shorthandCurrentMonth","inline","static","enableSeconds","disableMobile"],t=Object.assign({},s,JSON.parse(JSON.stringify(a.dataset||{}))),n={};Me.config.parseDate=t.parseDate,Me.config.formatDate=t.formatDate,Object.defineProperty(Me.config,"enable",{get:function(){return Me.config._enable},set:function(e){Me.config._enable=Qe(e)}}),Object.defineProperty(Me.config,"disable",{get:function(){return Me.config._disable},set:function(e){Me.config._disable=Qe(e)}});var r="time"===t.mode;t.dateFormat||!t.enableTime&&!r||(n.dateFormat=t.noCalendar||r?"H:i"+(t.enableSeconds?":S":""):F.defaultConfig.dateFormat+" H:i"+(t.enableSeconds?":S":"")),t.altInput&&(t.enableTime||r)&&!t.altFormat&&(n.altFormat=t.noCalendar||r?"h:i"+(t.enableSeconds?":S K":" K"):F.defaultConfig.altFormat+(" h:i"+(t.enableSeconds?":S":"")+" K")),Object.defineProperty(Me.config,"minDate",{get:function(){return Me.config._minDate},set:he("min")}),Object.defineProperty(Me.config,"maxDate",{get:function(){return Me.config._maxDate},set:he("max")});var i=function(e){return function(t){Me.config["min"===e?"_minTime":"_maxTime"]=Me.parseDate(t,"H:i")}};Object.defineProperty(Me.config,"minTime",{get:function(){return Me.config._minTime},set:i("min")}),Object.defineProperty(Me.config,"maxTime",{get:function(){return Me.config._maxTime},set:i("max")}),"time"===t.mode&&(Me.config.noCalendar=!0,Me.config.enableTime=!0),Object.assign(Me.config,n,t);for(var A=0;A-1?Me.config[c]=u(l[c]).map(g).concat(Me.config[c]):"undefined"==typeof t[c]&&(Me.config[c]=l[c])}Te("onParseConfig")}function me(){"object"!=typeof Me.config.locale&&"undefined"==typeof F.l10ns[Me.config.locale]&&Me.config.errorHandler(new Error("flatpickr: invalid locale "+Me.config.locale)),Me.l10n=Object.assign({},F.l10ns.default,"object"==typeof Me.config.locale?Me.config.locale:"default"!==Me.config.locale?F.l10ns[Me.config.locale]:void 0),h.K="("+Me.l10n.amPM[0]+"|"+Me.l10n.amPM[1]+"|"+Me.l10n.amPM[0].toLowerCase()+"|"+Me.l10n.amPM[1].toLowerCase()+")",Me.formatDate=v(Me),Me.parseDate=B({config:Me.config,l10n:Me.l10n})}function ve(e){if(void 0!==Me.calendarContainer){Te("onPreCalendarPosition");var t=e||Me._positionElement,r=Array.prototype.reduce.call(Me.calendarContainer.children,function(e,t){return e+t.offsetHeight},0),i=Me.calendarContainer.offsetWidth,A=Me.config.position.split(" "),o=A[0],a=A.length>1?A[1]:null,s=t.getBoundingClientRect(),l=window.innerHeight-s.bottom,c="above"===o||"below"!==o&&lr,u=window.pageYOffset+s.top+(c?-r-2:t.offsetHeight+2);if(n(Me.calendarContainer,"arrowTop",!c),n(Me.calendarContainer,"arrowBottom",c),!Me.config.inline){var d=window.pageXOffset+s.left-(null!=a&&"center"===a?(i-s.width)/2:0),f=window.document.body.offsetWidth-s.right,p=d+i>window.document.body.offsetWidth;n(Me.calendarContainer,"rightMost",p),Me.config.static||(Me.calendarContainer.style.top=u+"px",p?(Me.calendarContainer.style.left="auto",Me.calendarContainer.style.right=f+"px"):(Me.calendarContainer.style.left=d+"px",Me.calendarContainer.style.right="auto"))}}}function Be(){Me.config.noCalendar||Me.isMobile||(Ie(),Y())}function we(){Me._input.focus(),window.navigator.userAgent.indexOf("MSIE")!==-1||void 0!==navigator.msMaxTouchPoints?setTimeout(Me.close,0):Me.close()}function ye(e){e.preventDefault(),e.stopPropagation();var n=function(e){return e.classList&&e.classList.contains("flatpickr-day")&&!e.classList.contains("disabled")&&!e.classList.contains("notAllowed")},r=A(e.target,n);if(void 0!==r){var i=r,o=Me.latestSelectedDateObj=new Date(i.dateObj.getTime()),a=(o.getMonth()Me.currentMonth+Me.config.showMonths-1)&&"range"!==Me.config.mode;if(Me.selectedDateElem=i,"single"===Me.config.mode)Me.selectedDates=[o];else if("multiple"===Me.config.mode){var s=xe(o);s?Me.selectedDates.splice(parseInt(s),1):Me.selectedDates.push(o)}else"range"===Me.config.mode&&(2===Me.selectedDates.length&&Me.clear(!1),Me.selectedDates.push(o),0!==t(o,Me.selectedDates[0],!0)&&Me.selectedDates.sort(function(e,t){return e.getTime()-t.getTime()}));if(H(),a){var l=Me.currentYear!==o.getFullYear();Me.currentYear=o.getFullYear(),Me.currentMonth=o.getMonth(),l&&Te("onYearChange"),Te("onMonthChange")}if(Ie(),Y(),Le(),Me.config.enableTime&&setTimeout(function(){return Me.showTimeInput=!0},50),a||"range"===Me.config.mode||1!==Me.config.showMonths?Me.selectedDateElem&&Me.selectedDateElem.focus():z(i),void 0!==Me.hourElement&&setTimeout(function(){return void 0!==Me.hourElement&&Me.hourElement.select()},451),Me.config.closeOnSelect){var c="single"===Me.config.mode&&!Me.config.enableTime,u="range"===Me.config.mode&&2===Me.selectedDates.length&&!Me.config.enableTime;(c||u)&&we()}L()}}function be(e,t){null!==e&&"object"==typeof e?Object.assign(Me.config,e):(Me.config[e]=t,void 0!==Pe[e]?Pe[e].forEach(function(e){return e()}):C.indexOf(e)>-1&&(Me.config[e]=u(t))),Me.redraw(),D(),Le(!1)}function Ce(e,t){var n=[];if(e instanceof Array)n=e.map(function(e){return Me.parseDate(e,t)});else if(e instanceof Date||"number"==typeof e)n=[Me.parseDate(e,t)];else if("string"==typeof e)switch(Me.config.mode){case"single":case"time":n=[Me.parseDate(e,t)];break;case"multiple":n=e.split(Me.config.conjunction).map(function(e){return Me.parseDate(e,t)});break;case"range":n=e.split(Me.l10n.rangeSeparator).map(function(e){return Me.parseDate(e,t)})}else Me.config.errorHandler(new Error("Invalid date supplied: "+JSON.stringify(e)));Me.selectedDates=n.filter(function(e){return e instanceof Date&&le(e,!1)}),"range"===Me.config.mode&&Me.selectedDates.sort(function(e,t){return e.getTime()-t.getTime()})}function Ee(e,t,n){return void 0===t&&(t=!1),void 0===n&&(n=Me.config.dateFormat),0!==e&&!e||e instanceof Array&&0===e.length?Me.clear(t):(Ce(e,n),Me.showTimeInput=Me.selectedDates.length>0,Me.latestSelectedDateObj=Me.selectedDates[0],Me.redraw(),D(),T(),Le(t),void(t&&Te("onChange")))}function Qe(e){return e.slice().map(function(e){return"string"==typeof e||"number"==typeof e||e instanceof Date?Me.parseDate(e,void 0,!0):e&&"object"==typeof e&&e.from&&e.to?{from:Me.parseDate(e.from,void 0),to:Me.parseDate(e.to,void 0)}:e}).filter(function(e){return e})}function Fe(){Me.selectedDates=[],Me.now=Me.parseDate(Me.config.now)||new Date;var e=Me.config.defaultDate||("INPUT"!==Me.input.nodeName&&"TEXTAREA"!==Me.input.nodeName||!Me.input.placeholder||Me.input.value!==Me.input.placeholder?Me.input.value:null);e&&Ce(e,Me.config.dateFormat);var t=Me.selectedDates.length>0?Me.selectedDates[0]:Me.config.minDate&&Me.config.minDate.getTime()>Me.now.getTime()?Me.config.minDate:Me.config.maxDate&&Me.config.maxDate.getTime()0&&(Me.latestSelectedDateObj=Me.selectedDates[0]),void 0!==Me.config.minTime&&(Me.config.minTime=Me.parseDate(Me.config.minTime,"H:i")),void 0!==Me.config.maxTime&&(Me.config.maxTime=Me.parseDate(Me.config.maxTime,"H:i")),Me.minDateHasTime=!!Me.config.minDate&&(Me.config.minDate.getHours()>0||Me.config.minDate.getMinutes()>0||Me.config.minDate.getSeconds()>0),Me.maxDateHasTime=!!Me.config.maxDate&&(Me.config.maxDate.getHours()>0||Me.config.maxDate.getMinutes()>0||Me.config.maxDate.getSeconds()>0),Object.defineProperty(Me,"showTimeInput",{get:function(){return Me._showTimeInput},set:function(e){Me._showTimeInput=e,Me.calendarContainer&&n(Me.calendarContainer,"showTimeInput",e),Me.isOpen&&ve()}})}function Ue(){return Me.input=Me.config.wrap?a.querySelector("[data-input]"):a,Me.input?(Me.input._type=Me.input.type,Me.input.type="text",Me.input.classList.add("flatpickr-input"),Me._input=Me.input,Me.config.altInput&&(Me.altInput=r(Me.input.nodeName,Me.input.className+" "+Me.config.altInputClass),Me._input=Me.altInput,Me.altInput.placeholder=Me.input.placeholder,Me.altInput.disabled=Me.input.disabled,Me.altInput.required=Me.input.required,Me.altInput.tabIndex=Me.input.tabIndex,Me.altInput.type="text",Me.input.setAttribute("type","hidden"),!Me.config.static&&Me.input.parentNode&&Me.input.parentNode.insertBefore(Me.altInput,Me.input.nextSibling)),Me.config.allowInput||Me._input.setAttribute("readonly","readonly"),void(Me._positionElement=Me.config.positionElement||Me._input)):void Me.config.errorHandler(new Error("Invalid input element specified"))}function _e(){var e=Me.config.enableTime?Me.config.noCalendar?"time":"datetime-local":"date";Me.mobileInput=r("input",Me.input.className+" flatpickr-mobile"),Me.mobileInput.step=Me.input.getAttribute("step")||"any",Me.mobileInput.tabIndex=1,Me.mobileInput.type=e,Me.mobileInput.disabled=Me.input.disabled,Me.mobileInput.required=Me.input.required,Me.mobileInput.placeholder=Me.input.placeholder,Me.mobileFormatStr="datetime-local"===e?"Y-m-d\\TH:i:S":"date"===e?"Y-m-d":"H:i:S",Me.selectedDates.length>0&&(Me.mobileInput.defaultValue=Me.mobileInput.value=Me.formatDate(Me.selectedDates[0],Me.mobileFormatStr)),Me.config.minDate&&(Me.mobileInput.min=Me.formatDate(Me.config.minDate,"Y-m-d")),Me.config.maxDate&&(Me.mobileInput.max=Me.formatDate(Me.config.maxDate,"Y-m-d")),Me.input.type="hidden",void 0!==Me.altInput&&(Me.altInput.type="hidden");try{Me.input.parentNode&&Me.input.parentNode.insertBefore(Me.mobileInput,Me.input.nextSibling)}catch(e){}I(Me.mobileInput,"change",function(e){Me.setDate(e.target.value,!1,Me.mobileFormatStr),Te("onChange"),Te("onClose")})}function He(e){return Me.isOpen===!0?Me.close():void Me.open(e)}function Te(e,t){if(void 0!==Me.config){var n=Me.config[e];if(void 0!==n&&n.length>0)for(var r=0;n[r]&&r=0&&t(e,Me.selectedDates[1])<=0)}function Ie(){Me.config.noCalendar||Me.isMobile||!Me.monthNav||(Me.yearElements.forEach(function(e,t){var n=new Date(Me.currentYear,Me.currentMonth,1);n.setMonth(Me.currentMonth+t),Me.monthElements[t].textContent=f(n.getMonth(),Me.config.shorthandCurrentMonth,Me.l10n)+" ",e.value=n.getFullYear().toString()}),Me._hidePrevMonthArrow=void 0!==Me.config.minDate&&(Me.currentYear===Me.config.minDate.getFullYear()?Me.currentMonth<=Me.config.minDate.getMonth():Me.currentYearMe.config.maxDate.getMonth():Me.currentYear>Me.config.maxDate.getFullYear()))}function Ne(e){return Me.selectedDates.map(function(t){return Me.formatDate(t,e)}).filter(function(e,t,n){return"range"!==Me.config.mode||Me.config.enableTime||n.indexOf(e)===t}).join("range"!==Me.config.mode?Me.config.conjunction:Me.l10n.rangeSeparator)}function Le(e){return void 0===e&&(e=!0),0===Me.selectedDates.length?Me.clear(e):(void 0!==Me.mobileInput&&Me.mobileFormatStr&&(Me.mobileInput.value=void 0!==Me.latestSelectedDateObj?Me.formatDate(Me.latestSelectedDateObj,Me.mobileFormatStr):""),Me.input.value=Ne(Me.config.dateFormat),void 0!==Me.altInput&&(Me.altInput.value=Ne(Me.config.altFormat)),void(e!==!1&&Te("onValueUpdate")))}function Oe(e){e.preventDefault();var t=Me.prevMonthNav.contains(e.target),n=Me.nextMonthNav.contains(e.target);t||n?ne(t?-1:1):Me.yearElements.indexOf(e.target)>=0?e.target.select():e.target.classList.contains("arrowUp")?Me.changeYear(Me.currentYear+1):e.target.classList.contains("arrowDown")&&Me.changeYear(Me.currentYear-1)}function De(e){e.preventDefault();var t="keydown"===e.type,n=e.target;void 0!==Me.amPM&&e.target===Me.amPM&&(Me.amPM.textContent=Me.l10n.amPM[c(Me.amPM.textContent===Me.l10n.amPM[0])]);var r=parseFloat(n.getAttribute("data-min")),i=parseFloat(n.getAttribute("data-max")),A=parseFloat(n.getAttribute("data-step")),o=parseInt(n.value,10),a=e.delta||(t?38===e.which?1:-1:0),s=o+A*a;if("undefined"!=typeof n.value&&2===n.value.length){var u=n===Me.hourElement,d=n===Me.minuteElement;si&&(s=n===Me.hourElement?s-i-c(!Me.amPM):r,d&&P(void 0,1,Me.hourElement)),Me.amPM&&u&&(1===A?s+o===23:Math.abs(s-o)>A)&&(Me.amPM.textContent=Me.l10n.amPM[c(Me.amPM.textContent===Me.l10n.amPM[0])]),n.value=l(s)}}var Me={config:Object.assign({},F.defaultConfig),l10n:m};Me.parseDate=B({config:Me.config,l10n:Me.l10n}),Me._handlers=[],Me._bind=I,Me._setHoursFromDate=T,Me._positionCalendar=ve,Me.changeMonth=ne,Me.changeYear=se,Me.clear=re,Me.close=ie,Me._createElement=r,Me.destroy=Ae,Me.isEnabled=le,Me.jumpToDate=D,Me.open=pe,Me.redraw=Be,Me.set=be,Me.setDate=Ee,Me.toggle=He;var Pe={locale:[me,ee],showMonths:[W,w,$]};return p(),Me}function s(e,t){for(var n=Array.prototype.slice.call(e),r=[],i=0;i11)]},M:function(e,t){return f(e.getMonth(),!0,t)},S:function(e){return l(e.getSeconds())},U:function(e){return e.getTime()/1e3},W:function(e,t,n){return n.getWeek(e)},Y:function(e){return e.getFullYear()},d:function(e){return l(e.getDate())},h:function(e){return e.getHours()%12?e.getHours()%12:12},i:function(e){return l(e.getMinutes())},j:function(e){return e.getDate()},l:function(e,t){return t.weekdays.longhand[e.getDay()]},m:function(e){return l(e.getMonth()+1)},n:function(e){return e.getMonth()+1},s:function(e){return e.getSeconds()},w:function(e){return e.getDay()},y:function(e){return String(e.getFullYear()).substring(2)}},m={weekdays:{shorthand:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],longhand:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"]},months:{shorthand:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],longhand:["January","February","March","April","May","June","July","August","September","October","November","December"]},daysInMonth:[31,28,31,30,31,30,31,31,30,31,30,31],firstDayOfWeek:0,ordinal:function(e){var t=e%100;if(t>3&&t<21)return"th";switch(t%10){case 1:return"st";case 2:return"nd";case 3:return"rd";default:return"th"}},rangeSeparator:" to ",weekAbbreviation:"Wk",scrollTitle:"Scroll to increment",toggleTitle:"Click to toggle",amPM:["AM","PM"],yearAriaLabel:"Year"},v=function(e){var t=e.config,n=void 0===t?E:t,r=e.l10n,i=void 0===r?m:r;return function(e,t,r){var A=r||i;return void 0!==n.formatDate?n.formatDate(e,t,A):t.split("").map(function(t,r,i){return g[t]&&"\\"!==i[r-1]?g[t](e,A,n):"\\"!==t?t:""}).join("")}},B=function(e){var t=e.config,n=void 0===t?E:t,r=e.l10n,i=void 0===r?m:r;return function(e,t,r,A){if(0===e||e){var o,a=A||i,s=e;if(e instanceof Date)o=new Date(e.getTime());else if("string"!=typeof e&&void 0!==e.toFixed)o=new Date(e);else if("string"==typeof e){var l=t||(n||E).dateFormat,c=String(e).trim();if("today"===c)o=new Date,r=!0;else if(/Z$/.test(c)||/GMT$/.test(c))o=new Date(e);else if(n&&n.parseDate)o=n.parseDate(e,l);else{o=n&&n.noCalendar?new Date((new Date).setHours(0,0,0,0)):new Date((new Date).getFullYear(),0,1,0,0,0,0);for(var u,d=[],f=0,g=0,m="";fMath.min(t,n)&&e",noCalendar:!1,now:new Date,onChange:[],onClose:[],onDayCreate:[],onDestroy:[],onKeyDown:[],onMonthChange:[],onOpen:[],onParseConfig:[],onReady:[],onValueUpdate:[],onYearChange:[],onPreCalendarPosition:[],plugins:[],position:"auto",positionElement:void 0,prevArrow:"",shorthandCurrentMonth:!1,showMonths:1,static:!1,time_24hr:!1,weekNumbers:!1,wrap:!1};"function"!=typeof Object.assign&&(Object.assign=function(e){if(!e)throw TypeError("Cannot convert undefined or null to object");for(var t=arguments.length,n=new Array(t>1?t-1:0),r=1;r0&&void 0!==arguments[0]?arguments[0]:"[data-choice]",n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(o(this,e),(0,h.isType)("String",t)){var r=document.querySelectorAll(t);if(r.length>1)for(var i=1;i"'+(0,h.stripHTML)(e)+'"'},maxItemText:function(e){return"Only "+e+" values can be added."},itemComparer:function(e,t){return e===t},uniqueItemText:"Only unique values can be added.",classNames:{containerOuter:"choices",containerInner:"choices__inner",input:"choices__input",inputCloned:"choices__input--cloned",list:"choices__list",listItems:"choices__list--multiple",listSingle:"choices__list--single",listDropdown:"choices__list--dropdown",item:"choices__item",itemSelectable:"choices__item--selectable",itemDisabled:"choices__item--disabled",itemChoice:"choices__item--choice",placeholder:"choices__placeholder",group:"choices__group",groupHeading:"choices__heading",button:"choices__button",activeState:"is-active",focusState:"is-focused",openState:"is-open",disabledState:"is-disabled",highlightedState:"is-highlighted",hiddenState:"is-hidden",flippedState:"is-flipped",loadingState:"is-loading",noResults:"has-no-results",noChoices:"has-no-choices"},fuseOptions:{include:"score"},callbackOnInit:null,callbackOnCreateTemplates:null};if(this.idNames={itemChoice:"item-choice"},this.config=(0,h.extend)(a,n),"auto"!==this.config.renderSelectedChoices&&"always"!==this.config.renderSelectedChoices&&(this.config.silent||console.warn("renderSelectedChoices: Possible values are 'auto' and 'always'. Falling back to 'auto'."),this.config.renderSelectedChoices="auto"),this.store=new f.default(this.render),this.initialised=!1,this.currentState={},this.prevState={},this.currentValue="",this.element=t,this.passedElement=(0,h.isType)("String",t)?document.querySelector(t):t,!this.passedElement)return void(this.config.silent||console.error("Passed element not found"));this.isTextElement="text"===this.passedElement.type,this.isSelectOneElement="select-one"===this.passedElement.type,this.isSelectMultipleElement="select-multiple"===this.passedElement.type,this.isSelectElement=this.isSelectOneElement||this.isSelectMultipleElement,this.isValidElementType=this.isTextElement||this.isSelectElement,this.isIe11=!(!navigator.userAgent.match(/Trident/)||!navigator.userAgent.match(/rv[ :]11/)),this.isScrollingOnIe=!1,this.config.shouldSortItems===!0&&this.isSelectOneElement&&(this.config.silent||console.warn("shouldSortElements: Type of passed element is 'select-one', falling back to false.")),this.highlightPosition=0,this.canSearch=this.config.searchEnabled,this.placeholder=!1,this.isSelectOneElement||(this.placeholder=!!this.config.placeholder&&(this.config.placeholderValue||this.passedElement.getAttribute("placeholder"))),this.presetChoices=this.config.choices,this.presetItems=this.config.items,this.passedElement.value&&(this.presetItems=this.presetItems.concat(this.passedElement.value.split(this.config.delimiter))),this.baseId=(0,h.generateId)(this.passedElement,"choices-"),this.render=this.render.bind(this),this._onFocus=this._onFocus.bind(this),this._onBlur=this._onBlur.bind(this),this._onKeyUp=this._onKeyUp.bind(this),this._onKeyDown=this._onKeyDown.bind(this),this._onClick=this._onClick.bind(this),this._onTouchMove=this._onTouchMove.bind(this),this._onTouchEnd=this._onTouchEnd.bind(this),this._onMouseDown=this._onMouseDown.bind(this),this._onMouseOver=this._onMouseOver.bind(this),this._onPaste=this._onPaste.bind(this),this._onInput=this._onInput.bind(this),this.wasTap=!0;var s="classList"in document.documentElement;s||this.config.silent||console.error("Choices: Your browser doesn't support Choices");var l=(0,h.isElement)(this.passedElement)&&this.isValidElementType;if(l){if("active"===this.passedElement.getAttribute("data-choice"))return;this.init()}else this.config.silent||console.error("Incompatible input passed")}return a(e,[{key:"init",value:function(){if(this.initialised!==!0){var e=this.config.callbackOnInit;this.initialised=!0,this._createTemplates(),this._createInput(),this.store.subscribe(this.render),this.render(),this._addEventListeners(),e&&(0,h.isType)("Function",e)&&e.call(this)}}},{key:"destroy",value:function(){if(this.initialised!==!1){this._removeEventListeners(),this.passedElement.classList.remove(this.config.classNames.input,this.config.classNames.hiddenState),this.passedElement.removeAttribute("tabindex");var e=this.passedElement.getAttribute("data-choice-orig-style");Boolean(e)?(this.passedElement.removeAttribute("data-choice-orig-style"),this.passedElement.setAttribute("style",e)):this.passedElement.removeAttribute("style"),this.passedElement.removeAttribute("aria-hidden"),this.passedElement.removeAttribute("data-choice"),this.passedElement.value=this.passedElement.value,this.containerOuter.parentNode.insertBefore(this.passedElement,this.containerOuter),this.containerOuter.parentNode.removeChild(this.containerOuter),this.clearStore(),this.config.templates=null,this.initialised=!1}}},{key:"renderGroups",value:function(e,t,n){var r=this,i=n||document.createDocumentFragment(),A=this.config.sortFilter;return this.config.shouldSort&&e.sort(A),e.forEach(function(e){var n=t.filter(function(t){return r.isSelectOneElement?t.groupId===e.id:t.groupId===e.id&&!t.selected});if(n.length>=1){var A=r._getTemplate("choiceGroup",e);i.appendChild(A),r.renderChoices(n,i,!0)}}),i}},{key:"renderChoices",value:function(e,t){var n=this,r=arguments.length>2&&void 0!==arguments[2]&&arguments[2],i=t||document.createDocumentFragment(),o=this.config,a=o.renderSelectedChoices,s=o.searchResultLimit,l=o.renderChoiceLimit,c=this.isSearching?h.sortByScore:this.config.sortFilter,u=function(e){var t="auto"!==a||n.isSelectOneElement||!e.selected;if(t){var r=n._getTemplate("choice",e);i.appendChild(r)}},d=e;"auto"!==a||this.isSelectOneElement||(d=e.filter(function(e){return!e.selected}));var f=d.reduce(function(e,t){return t.placeholder?e.placeholderChoices.push(t):e.normalChoices.push(t),e},{placeholderChoices:[],normalChoices:[]}),p=f.placeholderChoices,g=f.normalChoices;(this.config.shouldSort||this.isSearching)&&g.sort(c);var m=d.length,v=[].concat(A(p),A(g));this.isSearching?m=s:l>0&&!r&&(m=l);for(var B=0;B1&&void 0!==arguments[1]?arguments[1]:null,r=n||document.createDocumentFragment();if(this.config.shouldSortItems&&!this.isSelectOneElement&&e.sort(this.config.sortFilter),this.isTextElement){var i=this.store.getItemsReducedToValues(e),A=i.join(this.config.delimiter);this.passedElement.setAttribute("value",A),this.passedElement.value=A}else{var o=document.createDocumentFragment();e.forEach(function(e){var n=t._getTemplate("option",e);o.appendChild(n)}),this.passedElement.innerHTML="",this.passedElement.appendChild(o)}return e.forEach(function(e){var n=t._getTemplate("item",e);r.appendChild(n)}),r}},{key:"render",value:function(){if(!this.store.isLoading()&&(this.currentState=this.store.getState(),this.currentState!==this.prevState)){if((this.currentState.choices!==this.prevState.choices||this.currentState.groups!==this.prevState.groups||this.currentState.items!==this.prevState.items)&&this.isSelectElement){var e=this.store.getGroupsFilteredByActive(),t=this.store.getChoicesFilteredByActive(),n=document.createDocumentFragment();this.choiceList.innerHTML="",this.config.resetScrollPosition&&(this.choiceList.scrollTop=0),e.length>=1&&this.isSearching!==!0?n=this.renderGroups(e,t,n):t.length>=1&&(n=this.renderChoices(t,n));var r=this.store.getItemsFilteredByActive(),i=this._canAddItem(r,this.input.value);if(n.childNodes&&n.childNodes.length>0)i.response?(this.choiceList.appendChild(n),this._highlightChoice()):this.choiceList.appendChild(this._getTemplate("notice",i.notice));else{var A=void 0,o=void 0;this.isSearching?(o=(0,h.isType)("Function",this.config.noResultsText)?this.config.noResultsText():this.config.noResultsText,A=this._getTemplate("notice",o,"no-results")):(o=(0,h.isType)("Function",this.config.noChoicesText)?this.config.noChoicesText():this.config.noChoicesText,A=this._getTemplate("notice",o,"no-choices")),this.choiceList.appendChild(A)}}if(this.currentState.items!==this.prevState.items){var a=this.store.getItemsFilteredByActive();if(this.itemList.innerHTML="",a&&a){var s=this.renderItems(a);s.childNodes&&this.itemList.appendChild(s)}}this.prevState=this.currentState}}},{key:"highlightItem",value:function(e){var t=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];if(!e)return this;var n=e.id,r=e.groupId,i=r>=0?this.store.getGroupById(r):null;return this.store.dispatch((0,p.highlightItem)(n,!0)),t&&(i&&i.value?(0,h.triggerEvent)(this.passedElement,"highlightItem",{id:n,value:e.value,label:e.label,groupValue:i.value}):(0,h.triggerEvent)(this.passedElement,"highlightItem",{id:n,value:e.value,label:e.label})),this}},{key:"unhighlightItem",value:function(e){if(!e)return this;var t=e.id,n=e.groupId,r=n>=0?this.store.getGroupById(n):null;return this.store.dispatch((0,p.highlightItem)(t,!1)),r&&r.value?(0,h.triggerEvent)(this.passedElement,"unhighlightItem",{id:t,value:e.value,label:e.label,groupValue:r.value}):(0,h.triggerEvent)(this.passedElement,"unhighlightItem",{id:t,value:e.value,label:e.label}),this}},{key:"highlightAll",value:function(){var e=this,t=this.store.getItems();return t.forEach(function(t){e.highlightItem(t)}),this}},{key:"unhighlightAll",value:function(){var e=this,t=this.store.getItems();return t.forEach(function(t){e.unhighlightItem(t)}),this}},{key:"removeItemsByValue",value:function(e){var t=this;if(!e||!(0,h.isType)("String",e))return this;var n=this.store.getItemsFilteredByActive();return n.forEach(function(n){n.value===e&&t._removeItem(n)}),this}},{key:"removeActiveItems",value:function(e){var t=this,n=this.store.getItemsFilteredByActive();return n.forEach(function(n){n.active&&e!==n.id&&t._removeItem(n)}),this}},{key:"removeHighlightedItems",value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]&&arguments[0],n=this.store.getItemsFilteredByActive();return n.forEach(function(n){n.highlighted&&n.active&&(e._removeItem(n),t&&e._triggerChange(n.value))}),this}},{key:"showDropdown",value:function(){var e=arguments.length>0&&void 0!==arguments[0]&&arguments[0],t=document.body,n=document.documentElement,r=Math.max(t.scrollHeight,t.offsetHeight,n.clientHeight,n.scrollHeight,n.offsetHeight);this.containerOuter.classList.add(this.config.classNames.openState),this.containerOuter.setAttribute("aria-expanded","true"),this.dropdown.classList.add(this.config.classNames.activeState),this.dropdown.setAttribute("aria-expanded","true");var i=this.dropdown.getBoundingClientRect(),A=Math.ceil(i.top+window.scrollY+this.dropdown.offsetHeight),o=!1;return"auto"===this.config.position?o=A>=r:"top"===this.config.position&&(o=!0),o&&this.containerOuter.classList.add(this.config.classNames.flippedState),e&&this.canSearch&&document.activeElement!==this.input&&this.input.focus(),(0,h.triggerEvent)(this.passedElement,"showDropdown",{}),this}},{key:"hideDropdown",value:function(){var e=arguments.length>0&&void 0!==arguments[0]&&arguments[0],t=this.containerOuter.classList.contains(this.config.classNames.flippedState);return this.containerOuter.classList.remove(this.config.classNames.openState),this.containerOuter.setAttribute("aria-expanded","false"),this.dropdown.classList.remove(this.config.classNames.activeState),this.dropdown.setAttribute("aria-expanded","false"),t&&this.containerOuter.classList.remove(this.config.classNames.flippedState),e&&this.canSearch&&document.activeElement===this.input&&this.input.blur(),(0,h.triggerEvent)(this.passedElement,"hideDropdown",{}),this}},{key:"toggleDropdown",value:function(){var e=this.dropdown.classList.contains(this.config.classNames.activeState);return e?this.hideDropdown():this.showDropdown(!0),this}},{key:"getValue",value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]&&arguments[0],n=this.store.getItemsFilteredByActive(),r=[];return n.forEach(function(n){e.isTextElement?r.push(t?n.value:n):n.active&&r.push(t?n.value:n)}),this.isSelectOneElement?r[0]:r}},{key:"setValue",value:function(e){var t=this;if(this.initialised===!0){var n=[].concat(A(e)),r=function(e){var n=(0,h.getType)(e);if("Object"===n){if(!e.value)return;t.isTextElement?t._addItem(e.value,e.label,e.id,void 0,e.customProperties,e.placeholder):t._addChoice(e.value,e.label,!0,!1,-1,e.customProperties,e.placeholder)}else"String"===n&&(t.isTextElement?t._addItem(e):t._addChoice(e,e,!0,!1,-1,null))};n.length>1?n.forEach(function(e){r(e)}):r(n[0])}return this}},{key:"setValueByChoice",value:function(e){var t=this;if(!this.isTextElement){var n=this.store.getChoices(),r=(0,h.isType)("Array",e)?e:[e];r.forEach(function(e){var r=n.find(function(n){return t.config.itemComparer(n.value,e)});r?r.selected?t.config.silent||console.warn("Attempting to select choice already selected"):t._addItem(r.value,r.label,r.id,r.groupId,r.customProperties,r.placeholder,r.keyCode):t.config.silent||console.warn("Attempting to select choice that does not exist")})}return this}},{key:"setChoices",value:function(e,t,n){var r=this,i=arguments.length>3&&void 0!==arguments[3]&&arguments[3];if(this.initialised===!0&&this.isSelectElement){if(!(0,h.isType)("Array",e)||!t)return this;i&&this._clearChoices(),this._setLoading(!0),e&&e.length&&(this.containerOuter.classList.remove(this.config.classNames.loadingState),e.forEach(function(e){e.choices?r._addGroup(e,e.id||null,t,n):r._addChoice(e[t],e[n],e.selected,e.disabled,void 0,e.customProperties,e.placeholder)})),this._setLoading(!1)}return this}},{key:"clearStore",value:function(){return this.store.dispatch((0,p.clearAll)()),this}},{key:"clearInput",value:function(){return this.input.value&&(this.input.value=""),this.isSelectOneElement||this._setInputWidth(),!this.isTextElement&&this.config.searchEnabled&&(this.isSearching=!1,this.store.dispatch((0,p.activateChoices)(!0))),this}},{key:"enable",value:function(){if(this.initialised){this.passedElement.disabled=!1;var e=this.containerOuter.classList.contains(this.config.classNames.disabledState);e&&(this._addEventListeners(),this.passedElement.removeAttribute("disabled"),this.input.removeAttribute("disabled"),this.containerOuter.classList.remove(this.config.classNames.disabledState),this.containerOuter.removeAttribute("aria-disabled"),this.isSelectOneElement&&this.containerOuter.setAttribute("tabindex","0"))}return this}},{key:"disable",value:function(){if(this.initialised){this.passedElement.disabled=!0;var e=!this.containerOuter.classList.contains(this.config.classNames.disabledState);e&&(this._removeEventListeners(),this.passedElement.setAttribute("disabled",""),this.input.setAttribute("disabled",""),this.containerOuter.classList.add(this.config.classNames.disabledState),this.containerOuter.setAttribute("aria-disabled","true"),this.isSelectOneElement&&this.containerOuter.setAttribute("tabindex","-1"))}return this}},{key:"ajax",value:function(e){var t=this;return this.initialised===!0&&this.isSelectElement&&(requestAnimationFrame(function(){t._handleLoadingState(!0)}),e(this._ajaxCallback())),this}},{key:"_triggerChange",value:function(e){e&&(0,h.triggerEvent)(this.passedElement,"change",{value:e})}},{key:"_handleButtonAction",value:function(e,t){if(e&&t&&this.config.removeItems&&this.config.removeItemButton){var n=t.parentNode.getAttribute("data-id"),r=e.find(function(e){return e.id===parseInt(n,10)});this._removeItem(r),this._triggerChange(r.value),this.isSelectOneElement&&this._selectPlaceholderChoice()}}},{key:"_selectPlaceholderChoice",value:function(){var e=this.store.getPlaceholderChoice();e&&(this._addItem(e.value,e.label,e.id,e.groupId,null,e.placeholder),this._triggerChange(e.value))}},{key:"_handleItemAction",value:function(e,t){var n=this,r=arguments.length>2&&void 0!==arguments[2]&&arguments[2];if(e&&t&&this.config.removeItems&&!this.isSelectOneElement){var i=t.getAttribute("data-id");e.forEach(function(e){e.id!==parseInt(i,10)||e.highlighted?r||e.highlighted&&n.unhighlightItem(e):n.highlightItem(e)}),document.activeElement!==this.input&&this.input.focus()}}},{key:"_handleChoiceAction",value:function(e,t){if(e&&t){var n=t.getAttribute("data-id"),r=this.store.getChoiceById(n),i=e[0]&&e[0].keyCode?e[0].keyCode:null,A=this.dropdown.classList.contains(this.config.classNames.activeState);if(r.keyCode=i,(0,h.triggerEvent)(this.passedElement,"choice",{choice:r}),r&&!r.selected&&!r.disabled){var o=this._canAddItem(e,r.value);o.response&&(this._addItem(r.value,r.label,r.id,r.groupId,r.customProperties,r.placeholder,r.keyCode),this._triggerChange(r.value))}this.clearInput(),A&&this.isSelectOneElement&&(this.hideDropdown(),this.containerOuter.focus())}}},{key:"_handleBackspace",value:function(e){if(this.config.removeItems&&e){var t=e[e.length-1],n=e.some(function(e){return e.highlighted});this.config.editItems&&!n&&t?(this.input.value=t.value,this._setInputWidth(),this._removeItem(t),this._triggerChange(t.value)):(n||this.highlightItem(t,!1),this.removeHighlightedItems(!0))}}},{key:"_canAddItem",value:function(e,t){var n=!0,r=(0,h.isType)("Function",this.config.addItemText)?this.config.addItemText(t):this.config.addItemText;(this.isSelectMultipleElement||this.isTextElement)&&this.config.maxItemCount>0&&this.config.maxItemCount<=e.length&&(n=!1,r=(0,h.isType)("Function",this.config.maxItemText)?this.config.maxItemText(this.config.maxItemCount):this.config.maxItemText),this.isTextElement&&this.config.addItems&&n&&this.config.regexFilter&&(n=this._regexFilter(t));var i=!e.some(function(e){return(0,h.isType)("String",t)?e.value===t.trim():e.value===t});return i||this.config.duplicateItems||this.isSelectOneElement||!n||(n=!1,r=(0,h.isType)("Function",this.config.uniqueItemText)?this.config.uniqueItemText(t):this.config.uniqueItemText),{response:n,notice:r}}},{key:"_handleLoadingState",value:function(){var e=!(arguments.length>0&&void 0!==arguments[0])||arguments[0],t=this.itemList.querySelector("."+this.config.classNames.placeholder);e?(this.containerOuter.classList.add(this.config.classNames.loadingState),this.containerOuter.setAttribute("aria-busy","true"),this.isSelectOneElement?t?t.innerHTML=this.config.loadingText:(t=this._getTemplate("placeholder",this.config.loadingText),this.itemList.appendChild(t)):this.input.placeholder=this.config.loadingText):(this.containerOuter.classList.remove(this.config.classNames.loadingState),this.isSelectOneElement?t.innerHTML=this.placeholder||"":this.input.placeholder=this.placeholder||"")}},{key:"_ajaxCallback",value:function(){var e=this;return function(t,n,r){if(t&&n){var i=(0,h.isType)("Object",t)?[t]:t;i&&(0,h.isType)("Array",i)&&i.length?(e._handleLoadingState(!1),e._setLoading(!0),i.forEach(function(t){if(t.choices){var i=t.id||null;e._addGroup(t,i,n,r)}else e._addChoice(t[n],t[r],t.selected,t.disabled,void 0,t.customProperties,t.placeholder)}),e._setLoading(!1),e.isSelectOneElement&&e._selectPlaceholderChoice()):e._handleLoadingState(!1),e.containerOuter.removeAttribute("aria-busy")}}}},{key:"_searchChoices",value:function(e){var t=(0,h.isType)("String",e)?e.trim():e,n=(0,h.isType)("String",this.currentValue)?this.currentValue.trim():this.currentValue;if(t.length>=1&&t!==n+" "){var r=this.store.getSearchableChoices(),i=t,A=(0,h.isType)("Array",this.config.searchFields)?this.config.searchFields:[this.config.searchFields],o=Object.assign(this.config.fuseOptions,{keys:A}),a=new l.default(r,o),s=a.search(i);return this.currentValue=t,this.highlightPosition=0,this.isSearching=!0,this.store.dispatch((0,p.filterChoices)(s)),s.length}return 0}},{key:"_handleSearch",value:function(e){if(e){var t=this.store.getChoices(),n=t.some(function(e){return!e.active});if(this.input===document.activeElement)if(e&&e.length>=this.config.searchFloor){var r=0;this.config.searchChoices&&(r=this._searchChoices(e)),(0,h.triggerEvent)(this.passedElement,"search",{value:e,resultCount:r})}else n&&(this.isSearching=!1,this.store.dispatch((0,p.activateChoices)(!0)))}}},{key:"_addEventListeners",value:function(){document.addEventListener("keyup",this._onKeyUp),document.addEventListener("keydown",this._onKeyDown),document.addEventListener("click",this._onClick),document.addEventListener("touchmove",this._onTouchMove),document.addEventListener("touchend",this._onTouchEnd),document.addEventListener("mousedown",this._onMouseDown),document.addEventListener("mouseover",this._onMouseOver),this.isSelectOneElement&&(this.containerOuter.addEventListener("focus",this._onFocus),this.containerOuter.addEventListener("blur",this._onBlur)),this.input.addEventListener("input",this._onInput),this.input.addEventListener("paste",this._onPaste),this.input.addEventListener("focus",this._onFocus),this.input.addEventListener("blur",this._onBlur)}},{key:"_removeEventListeners",value:function(){document.removeEventListener("keyup",this._onKeyUp),document.removeEventListener("keydown",this._onKeyDown),document.removeEventListener("click",this._onClick),document.removeEventListener("touchmove",this._onTouchMove),document.removeEventListener("touchend",this._onTouchEnd),document.removeEventListener("mousedown",this._onMouseDown),document.removeEventListener("mouseover",this._onMouseOver),this.isSelectOneElement&&(this.containerOuter.removeEventListener("focus",this._onFocus),this.containerOuter.removeEventListener("blur",this._onBlur)),this.input.removeEventListener("input",this._onInput),this.input.removeEventListener("paste",this._onPaste),this.input.removeEventListener("focus",this._onFocus),this.input.removeEventListener("blur",this._onBlur)}},{key:"_setInputWidth",value:function(){this.placeholder?this.input.value&&this.input.value.length>=this.placeholder.length/1.25&&(this.input.style.width=(0,h.getWidthOfInput)(this.input)):this.input.style.width=(0,h.getWidthOfInput)(this.input)}},{key:"_onKeyDown",value:function(e){var t,n=this;if(e.target===this.input||this.containerOuter.contains(e.target)){var r=e.target,A=this.store.getItemsFilteredByActive(),o=this.input===document.activeElement,a=this.dropdown.classList.contains(this.config.classNames.activeState),s=this.itemList&&this.itemList.children,l=String.fromCharCode(e.keyCode),c=46,u=8,d=13,f=65,p=27,g=38,m=40,v=33,B=34,w=e.ctrlKey||e.metaKey;this.isTextElement||!/[a-zA-Z0-9-_ ]/.test(l)||a||this.showDropdown(!0),this.canSearch=this.config.searchEnabled;var y=function(){w&&s&&(n.canSearch=!1,n.config.removeItems&&!n.input.value&&n.input===document.activeElement&&n.highlightAll())},b=function(){if(n.isTextElement&&r.value){var t=n.input.value,i=n._canAddItem(A,t);i.response&&(a&&n.hideDropdown(),n._addItem(t),n._triggerChange(t),n.clearInput())}if(r.hasAttribute("data-button")&&(n._handleButtonAction(A,r),e.preventDefault()),a){e.preventDefault();var o=n.dropdown.querySelector("."+n.config.classNames.highlightedState);o&&(A[0]&&(A[0].keyCode=d),n._handleChoiceAction(A,o))}else n.isSelectOneElement&&(a||(n.showDropdown(!0),e.preventDefault()))},C=function(){a&&(n.toggleDropdown(),n.containerOuter.focus())},E=function(){if(a||n.isSelectOneElement){a||n.showDropdown(!0),n.canSearch=!1;var t=e.keyCode===m||e.keyCode===B?1:-1,r=e.metaKey||e.keyCode===B||e.keyCode===v,i=void 0;if(r)i=t>0?Array.from(n.dropdown.querySelectorAll("[data-choice-selectable]")).pop():n.dropdown.querySelector("[data-choice-selectable]");else{var A=n.dropdown.querySelector("."+n.config.classNames.highlightedState);i=A?(0,h.getAdjacentEl)(A,"[data-choice-selectable]",t):n.dropdown.querySelector("[data-choice-selectable]")}i&&((0,h.isScrolledIntoView)(i,n.choiceList,t)||n._scrollToChoice(i,t),n._highlightChoice(i)),e.preventDefault()}},Q=function(){!o||e.target.value||n.isSelectOneElement||(n._handleBackspace(A),e.preventDefault())},F=(t={},i(t,f,y),i(t,d,b),i(t,p,C),i(t,g,E),i(t,v,E),i(t,m,E),i(t,B,E),i(t,u,Q),i(t,c,Q),t);F[e.keyCode]&&F[e.keyCode]()}}},{key:"_onKeyUp",value:function(e){if(e.target===this.input){var t=this.input.value,n=this.store.getItemsFilteredByActive(),r=this._canAddItem(n,t);if(this.isTextElement){var i=this.dropdown.classList.contains(this.config.classNames.activeState);if(t){if(r.notice){var A=this._getTemplate("notice",r.notice);this.dropdown.innerHTML=A.outerHTML}r.response===!0?i||this.showDropdown():!r.notice&&i&&this.hideDropdown()}else i&&this.hideDropdown()}else{var o=46,a=8;e.keyCode!==o&&e.keyCode!==a||e.target.value?this.canSearch&&r.response&&this._handleSearch(this.input.value):!this.isTextElement&&this.isSearching&&(this.isSearching=!1,this.store.dispatch((0,p.activateChoices)(!0)))}this.canSearch=this.config.searchEnabled}}},{key:"_onInput",value:function(){this.isSelectOneElement||this._setInputWidth()}},{key:"_onTouchMove",value:function(){this.wasTap===!0&&(this.wasTap=!1)}},{key:"_onTouchEnd",value:function(e){var t=e.target||e.touches[0].target,n=this.dropdown.classList.contains(this.config.classNames.activeState);this.wasTap===!0&&this.containerOuter.contains(t)&&(t!==this.containerOuter&&t!==this.containerInner||this.isSelectOneElement||(this.isTextElement?document.activeElement!==this.input&&this.input.focus():n||this.showDropdown(!0)),e.stopPropagation()),this.wasTap=!0}},{key:"_onMouseDown",value:function(e){var t=e.target;if(t===this.choiceList&&this.isIe11&&(this.isScrollingOnIe=!0),this.containerOuter.contains(t)&&t!==this.input){var n=void 0,r=this.store.getItemsFilteredByActive(),i=e.shiftKey;(n=(0,h.findAncestorByAttrName)(t,"data-button"))?this._handleButtonAction(r,n):(n=(0,h.findAncestorByAttrName)(t,"data-item"))?this._handleItemAction(r,n,i):(n=(0,h.findAncestorByAttrName)(t,"data-choice"))&&this._handleChoiceAction(r,n),e.preventDefault()}}},{key:"_onClick",value:function(e){var t=e.target,n=this.dropdown.classList.contains(this.config.classNames.activeState),r=this.store.getItemsFilteredByActive();if(this.containerOuter.contains(t))t.hasAttribute("data-button")&&this._handleButtonAction(r,t),n?this.isSelectOneElement&&t!==this.input&&!this.dropdown.contains(t)&&this.hideDropdown(!0):this.isTextElement?document.activeElement!==this.input&&this.input.focus():this.canSearch?this.showDropdown(!0):(this.showDropdown(),this.containerOuter.focus());else{var i=r.some(function(e){return e.highlighted});i&&this.unhighlightAll(),this.containerOuter.classList.remove(this.config.classNames.focusState),n&&this.hideDropdown()}}},{key:"_onMouseOver",value:function(e){(e.target===this.dropdown||this.dropdown.contains(e.target))&&e.target.hasAttribute("data-choice")&&this._highlightChoice(e.target)}},{key:"_onPaste",value:function(e){e.target!==this.input||this.config.paste||e.preventDefault()}},{key:"_onFocus",value:function(e){var t=this,n=e.target;if(this.containerOuter.contains(n)){var r=this.dropdown.classList.contains(this.config.classNames.activeState),i={text:function(){n===t.input&&t.containerOuter.classList.add(t.config.classNames.focusState)},"select-one":function(){t.containerOuter.classList.add(t.config.classNames.focusState),n===t.input&&(r||t.showDropdown())},"select-multiple":function(){n===t.input&&(t.containerOuter.classList.add(t.config.classNames.focusState),r||t.showDropdown(!0))}};i[this.passedElement.type]()}}},{key:"_onBlur",value:function(e){var t=this,n=e.target;if(this.containerOuter.contains(n)&&!this.isScrollingOnIe){var r=this.store.getItemsFilteredByActive(),i=this.dropdown.classList.contains(this.config.classNames.activeState),A=r.some(function(e){return e.highlighted}),o={text:function(){n===t.input&&(t.containerOuter.classList.remove(t.config.classNames.focusState),A&&t.unhighlightAll(),i&&t.hideDropdown())},"select-one":function(){t.containerOuter.classList.remove(t.config.classNames.focusState),n===t.containerOuter&&i&&!t.canSearch&&t.hideDropdown(),n===t.input&&i&&t.hideDropdown()},"select-multiple":function(){n===t.input&&(t.containerOuter.classList.remove(t.config.classNames.focusState),i&&t.hideDropdown(),A&&t.unhighlightAll())}};o[this.passedElement.type]()}else this.isScrollingOnIe=!1,this.input.focus()}},{key:"_regexFilter",value:function(e){if(!e)return!1;var t=this.config.regexFilter,n=new RegExp(t.source,"i");return n.test(e)}},{key:"_scrollToChoice",value:function(e,t){var n=this;if(e){var r=this.choiceList.offsetHeight,i=e.offsetHeight,A=e.offsetTop+i,o=this.choiceList.scrollTop+r,a=t>0?this.choiceList.scrollTop+A-o:e.offsetTop,s=function e(){var r=4,i=n.choiceList.scrollTop,A=!1,o=void 0,s=void 0;t>0?(o=(a-i)/r,s=o>1?o:1,n.choiceList.scrollTop=i+s,i1?o:1,n.choiceList.scrollTop=i-s,i>a&&(A=!0)),A&&requestAnimationFrame(function(n){e(n,a,t)})};requestAnimationFrame(function(e){s(e,a,t)})}}},{key:"_highlightChoice",value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null,n=Array.from(this.dropdown.querySelectorAll("[data-choice-selectable]")),r=t;if(n&&n.length){var i=Array.from(this.dropdown.querySelectorAll("."+this.config.classNames.highlightedState));i.forEach(function(t){t.classList.remove(e.config.classNames.highlightedState),t.setAttribute("aria-selected","false")}),r?this.highlightPosition=n.indexOf(r):(r=n.length>this.highlightPosition?n[this.highlightPosition]:n[n.length-1],r||(r=n[0])),r.classList.add(this.config.classNames.highlightedState),r.setAttribute("aria-selected","true"),this.containerOuter.setAttribute("aria-activedescendant",r.id)}}},{key:"_addItem",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:-1,r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:-1,i=arguments.length>4&&void 0!==arguments[4]?arguments[4]:null,A=arguments.length>5&&void 0!==arguments[5]&&arguments[5],o=arguments.length>6&&void 0!==arguments[6]?arguments[6]:null,a=(0,h.isType)("String",e)?e.trim():e,s=o,l=this.store.getItems(),c=t||a,u=parseInt(n,10)||-1,d=r>=0?this.store.getGroupById(r):null,f=l?l.length+1:1;return this.config.prependValue&&(a=this.config.prependValue+a.toString()),this.config.appendValue&&(a+=this.config.appendValue.toString()),this.store.dispatch((0,p.addItem)(a,c,f,u,r,i,A,s)),this.isSelectOneElement&&this.removeActiveItems(f),d&&d.value?(0,h.triggerEvent)(this.passedElement,"addItem",{ id:f,value:a,label:c,groupValue:d.value,keyCode:s}):(0,h.triggerEvent)(this.passedElement,"addItem",{id:f,value:a,label:c,keyCode:s}),this}},{key:"_removeItem",value:function(e){if(!e||!(0,h.isType)("Object",e))return this;var t=e.id,n=e.value,r=e.label,i=e.choiceId,A=e.groupId,o=A>=0?this.store.getGroupById(A):null;return this.store.dispatch((0,p.removeItem)(t,i)),o&&o.value?(0,h.triggerEvent)(this.passedElement,"removeItem",{id:t,value:n,label:r,groupValue:o.value}):(0,h.triggerEvent)(this.passedElement,"removeItem",{id:t,value:n,label:r}),this}},{key:"_addChoice",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,n=arguments.length>2&&void 0!==arguments[2]&&arguments[2],r=arguments.length>3&&void 0!==arguments[3]&&arguments[3],i=arguments.length>4&&void 0!==arguments[4]?arguments[4]:-1,A=arguments.length>5&&void 0!==arguments[5]?arguments[5]:null,o=arguments.length>6&&void 0!==arguments[6]&&arguments[6],a=arguments.length>7&&void 0!==arguments[7]?arguments[7]:null;if("undefined"!=typeof e&&null!==e){var s=this.store.getChoices(),l=t||e,c=s?s.length+1:1,u=this.baseId+"-"+this.idNames.itemChoice+"-"+c;this.store.dispatch((0,p.addChoice)(e,l,c,i,r,u,A,o,a)),n&&this._addItem(e,l,c,void 0,A,o,a)}}},{key:"_clearChoices",value:function(){this.store.dispatch((0,p.clearChoices)())}},{key:"_addGroup",value:function(e,t){var n=this,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"value",i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:"label",A=(0,h.isType)("Object",e)?e.choices:Array.from(e.getElementsByTagName("OPTION")),o=t?t:Math.floor((new Date).valueOf()*Math.random()),a=!!e.disabled&&e.disabled;A?(this.store.dispatch((0,p.addGroup)(e.label,o,!0,a)),A.forEach(function(e){var t=e.disabled||e.parentNode&&e.parentNode.disabled;n._addChoice(e[r],(0,h.isType)("Object",e)?e[i]:e.innerHTML,e.selected,t,o,e.customProperties,e.placeholder)})):this.store.dispatch((0,p.addGroup)(e.label,e.id,!1,e.disabled))}},{key:"_getTemplate",value:function(e){if(!e)return null;for(var t=this.config.templates,n=arguments.length,r=Array(n>1?n-1:0),i=1;i

\n ')},itemList:function(){var n,r=(0,u.default)(t.list,(n={},i(n,t.listSingle,e.isSelectOneElement),i(n,t.listItems,!e.isSelectOneElement),n));return(0,h.strToEl)('\n
\n ')},placeholder:function(e){return(0,h.strToEl)('\n
\n '+e+"\n
\n ")},item:function(n){var r,A=(0,u.default)(t.item,(r={},i(r,t.highlightedState,n.highlighted),i(r,t.itemSelectable,!n.highlighted),i(r,t.placeholder,n.placeholder),r));if(e.config.removeItemButton){var o;return A=(0,u.default)(t.item,(o={},i(o,t.highlightedState,n.highlighted),i(o,t.itemSelectable,!n.disabled),i(o,t.placeholder,n.placeholder),o)),(0,h.strToEl)('\n \n "+n.label+'\n Remove item\n \n \n ")}return(0,h.strToEl)('\n \n "+n.label+"\n \n ")},choiceList:function(){return(0,h.strToEl)('\n \n \n ")},choiceGroup:function(e){var n=(0,u.default)(t.group,i({},t.itemDisabled,e.disabled));return(0,h.strToEl)('\n \n
'+e.value+"
\n \n ")},choice:function(n){var r,A=(0,u.default)(t.item,t.itemChoice,(r={},i(r,t.itemDisabled,n.disabled),i(r,t.itemSelectable,!n.disabled),i(r,t.placeholder,n.placeholder),r));return(0,h.strToEl)('\n 0?'role="treeitem"':'role="option"')+"\n >\n "+n.label+"\n \n ")},input:function(){var e=(0,u.default)(t.input,t.inputCloned);return(0,h.strToEl)('\n \n ')},dropdown:function(){var e=(0,u.default)(t.list,t.listDropdown);return(0,h.strToEl)('\n