text: !function(){"use strict";function s(e,t){for(var n=0;n<t.length;n++){var o=t[n];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(e,o.key,o)}}function r(e){return(r=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function a(e,t){return(a=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function c(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}var e;window.hasOwnProperty("AuthorBaseElement")||(console.error('[ERROR] <chassis-datalist> Required dependency "AuthorBaseElement" not found.'),console.info("AuthorBaseElement is available at https://github.com/author-elements/datalist")),0<(e=Array.from(new Set(["author-selected-options","author-options","author-option"])).filter(function(e){return!customElements.get(e)})).length&&(console.error("[ERROR] <chassis-datalist> Required dependenc".concat(1!==e.length?"ies":"y"," not found: ").concat(e.map(function(e){return"<".concat(e,">")}).join(", ").replace(", "+e[e.length-1]," and "+e[e.length-1]))),e.forEach(function(e,t){return console.info("".concat(t+1,". <").concat(e,"> is available at ").concat("https://github.com/author-elements/datalist".replace("chassis-datalist",e.replace("author-",""))))}));var t=function(e){function n(){var l,e,t;return function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,n),e=this,t=r(n).call(this,'<template><style>@charset "UTF-8"; :host{display:inline-flex;max-width:100%}:host *,:host :after,:host :before{box-sizing:border-box}:host ::slotted(author-options){height:0;overflow:hidden}:host([open]) ::slotted(author-options){height:auto}chassis-datalist{display:inline-flex;max-width:100%}chassis-datalist *,chassis-datalist :after,chassis-datalist :before{box-sizing:border-box}chassis-datalist author-options{height:0;overflow:hidden}chassis-datalist[open] author-options{height:auto}</style><slot name="afterbegin"></slot><slot name="beforeinput"></slot><slot name="input"></slot><slot name="afterinput"></slot><slot name="beforeselectedoptions"></slot><slot name="selectedoptions"></slot><slot name="afterselectedoptions"></slot><slot name="beforeoptions"></slot><slot name="options"></slot><slot name="afteroptions"></slot><slot name="beforeend"></slot></template>'),(l=!t||"object"!=typeof t&&"function"!=typeof t?c(e):t).clickCount=0,l.PRIVATE.addReadOnlyProperty("options"),l.PRIVATE.options=[],l.PRIVATE.find=function(o){return l.PRIVATE.options.filter(function(e){var t=l.hasAttribute("case-sensitive")?e.sourceElement.value:e.sourceElement.value.toLowerCase(),n=l.hasAttribute("case-sensitive")?e.sourceElement.text:e.sourceElement.text.toLowerCase();return o=l.hasAttribute("case-sensitive")?o:o.toLowerCase(),0<=t.indexOf(o)||0<=n.indexOf(o)})},l.PRIVATE.clear=function(){l.PRIVATE.options.forEach(function(e){return e.displayElement.style.display="none"})},l.PRIVATE.showAllOptions=function(){l.PRIVATE.options.forEach(function(e){return e.displayElement.style.display=""})},l.PRIVATE.clickHandler=function(e){l.clickCount++,2===l.clickCount&&(l.PRIVATE.showAllOptions(),l.open())},l.PRIVATE.keydownHandler=function(e){if(!l.isOpen)return l.PRIVATE.showAllOptions(),l.open();switch(e[l.keySource]){case 27:case"Escape":l.PRIVATE.clear(),l.close();break;case 38:case"ArrowUp":e.preventDefault(),console.log("select previous option");break;case 40:case"ArrowDown":e.preventDefault(),console.log("select next option");break;default:return}},l.PRIVATE.inputHandler=function(e){l.PRIVATE.clear();var t=l.PRIVATE.inputEl.value;if(t){var n=l.PRIVATE.find(t);if(n.length)return n.forEach(function(e){return e.displayElement.style.display=""}),void l.setAttribute("open","");l.hasAttribute("open")&&l.removeAttribute("open"),l.PRIVATE.clear()}},l.PRIVATE.bodyClickHandler=function(e){e.target===c(l)||l.contains(e.target)||l.removeAttribute("open")},l.PRIVATE.getOptionById=function(e){for(var t,n=l.PRIVATE.options,o=0;o<n.length;o++)if(n[o].id===e){t=n[o];break}return t},l.PRIVATE.generateOptionObject=function(e){if(customElements.get("chassis-option")){var t={id:l.PRIVATE.generateGuid("option"),attributes:{},sourceElement:e},n=!0,o=!1,i=void 0;try{for(var s,r=e.attributes[Symbol.iterator]();!(n=(s=r.next()).done);n=!0){var a=s.value;t.attributes[a.name]=a.value}}catch(e){o=!0,i=e}finally{try{n||null==r.return||r.return()}finally{if(o)throw i}}return t}console.error("chassis-datalist requires chassis-option. Please include it in this document's <head> element.")},l}var t,o,i;return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&a(e,t)}(n,AuthorElement(HTMLElement)),t=n,i=[{key:"observedAttributes",get:function(){return["autofocus","case-sensitive","disabled","name","open","tabindex"]}}],(o=[{key:"connectedCallback",value:function(){var t=this;this.PRIVATE.inputEl.addEventListener("focus",function(e){t.addEventListener("keydown",t.PRIVATE.keydownHandler)}),this.PRIVATE.inputEl.addEventListener("input",this.PRIVATE.inputHandler),this.PRIVATE.inputEl.addEventListener("click",this.PRIVATE.clickHandler),this.PRIVATE.inputEl.addEventListener("blur",function(e){t.clickCount=0,t.removeEventListener("keydown",t.PRIVATE.keydownHandler)}),setTimeout(function(){t.hasAttribute("tabindex")||t.setAttribute("tabindex",0),t.autofocus&&t.focus()},0)}},{key:"addChildren",value:function(e){var t=!0,n=!1,o=void 0;try{for(var i,s=e[Symbol.iterator]();!(t=(i=s.next()).done);t=!0){var r=i.value;this.addOption(r instanceof HTMLElement?this.PRIVATE.generateOptionObject(r):r)}}catch(e){n=!0,o=e}finally{try{t||null==s.return||s.return()}finally{if(n)throw o}}}},{key:"addOption",value:function(e,t){var n=this,o=2<arguments.length&&void 0!==arguments[2]?arguments[2]:this.PRIVATE.optionsEl;if(customElements.get("chassis-option")){if(e.hasOwnProperty("id")||(e.id=this.PRIVATE.generateGuid("option")),!(e.hasOwnProperty("sourceElement")&&e.sourceElement instanceof HTMLElement)){var i=document.createElement("option");e.hasOwnProperty("innerHTML")&&(i.innerHTML=e.innerHTML),e.hasOwnProperty("label")&&(i.innerHTML=e.label),e.hasOwnProperty("value")&&(i.value=e.value),e.hasOwnProperty("disabled")&&(i.disabled="boolean"==typeof e.disabled&&e.disabled),e.sourceElement=i}var s=e.sourceElement.getAttribute("label")||e.sourceElement.textContent.trim(),r=e.sourceElement.getAttribute("value"),a=e.sourceElement.disabled,l=document.createElement("chassis-option");if(l.style.display="none",l.key=e.id,l.innerHTML=e.sourceElement.innerHTML,o.appendChild(l),l.addEventListener("click",function(e){return n.select(l.key)}),e={attributes:{disabled:a,label:s,value:r},id:e.id,displayElement:l,sourceElement:e.sourceElement},t)return this["".concat(t)]=e.sourceElement,void this.PRIVATE.options.splice(t,0,e);this["".concat(this.PRIVATE.options.length)]=e.sourceElement,this.PRIVATE.options.push(e)}else console.error("chassis-datalist requires chassis-option. Please include it in this document's <head> element.")}},{key:"attributeChangedCallback",value:function(e,t,n){if(e=e.toLowerCase(),n!==t)switch(e){case"autofocus":case"disabled":case"name":console.log(e);break;case"open":this.isOpen?this.open():this.close()}}},{key:"close",value:function(){document.body.removeEventListener("click",this.PRIVATE.bodyClickHandler),document.body.removeEventListener("touchcancel",this.PRIVATE.bodyClickHandler),document.body.removeEventListener("touchend",this.PRIVATE.bodyClickHandler),this.isOpen&&(this.isOpen=!1)}},{key:"open",value:function(){document.body.addEventListener("click",this.PRIVATE.bodyClickHandler),document.body.addEventListener("touchcancel",this.PRIVATE.bodyClickHandler),document.body.addEventListener("touchend",this.PRIVATE.bodyClickHandler),this.isOpen||(this.isOpen=!0)}},{key:"inject",value:function(e,t,n){this.PRIVATE.sourceEl=t,this.PRIVATE.inputEl=e,this.PRIVATE.inputEl.slot="input",this.PRIVATE.inputEl.id=n,this.appendChild(this.PRIVATE.inputEl),this.PRIVATE.optionsEl=document.createElement("chassis-options"),this.PRIVATE.optionsEl.slot="options",this.appendChild(this.PRIVATE.optionsEl),this.addChildren(t.options)}},{key:"select",value:function(e){var t=this.PRIVATE.getOptionById(e);t&&(t.sourceElement.selected=!0,this.PRIVATE.inputEl.value=t.displayElement.innerHTML,this.PRIVATE.selectedOption=t,this.PRIVATE.options.forEach(function(e){return e.displayElement.removeAttribute("selected")}),t.displayElement.setAttribute("selected",""),this.dispatchEvent(new Event("input",{bubbles:!0})),this.close())}},{key:"isOpen",get:function(){return this.hasAttribute("open")},set:function(e){e?this.setAttribute("open",""):this.removeAttribute("open")}},{key:"value",get:function(){return this.PRIVATE.inputEl.value}}])&&s(t.prototype,o),i&&s(t,i),n}();customElements.define("chassis-datalist",t)}();
  //# sourceMappingURL=author-datalist.es5.min.js.map
  