(window.webpackJsonp=window.webpackJsonp||[]).push([[146],{1086:function(t,e,n){"use strict";n.r(e);n(15);var r=n(7),o=(n(29),n(17),n(33),n(8),n(34),n(122),n(147),n(40),{props:{value:String,disabled:Boolean,label:String,endpoint:String},data:function(){return{isFocused:!1,currentSearch:null,typingTimeout:null,textInput:null,searching:!1,items:[],selectedItemObject:null}},watch:{value:{immediate:!0,handler:function(t){this.textInput=t}}},computed:{input:{get:function(){return this.value||""},set:function(t){this.$emit("input",t)}}},methods:{isItemSelected:function(t){return!!this.input.toLowerCase()===t.name},search:function(){var t=this;return Object(r.a)(regeneratorRuntime.mark((function e(){var n;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!t.searching){e.next=2;break}return e.abrupt("return");case 2:return t.currentSearch=t.textInput,t.searching=!0,e.next=6,t.$axios.$gest("/api/".concat(t.endpoint,"?q=").concat(t.currentSearch,"&limit=15")).catch((function(t){return console.error("Failed to get search results",t),[]}));case 6:n=e.sent,t.items=n||[],t.searching=!1;case 9:case"end":return e.stop()}}),e)})))()},keydownInput:function(){var t=this;clearTimeout(this.typingTimeout),this.typingTimeout=setTimeout((function(){t.search()}),250)},inputFocus:function(){this.isFocused=!0},blur:function(){(this.isFocused=!1,this.inputName.toLowerCase()!==this.textInput.toLowerCase())&&((this.textInput?this.textInput.trim():null)&&this.submitForm());this.$refs.input&&this.$refs.input.blur()},inputBlur:function(){var t=this;this.isFocused&&setTimeout((function(){if(document.activeElement!==t.$refs.input&&(t.isFocused=!1,t.input!==t.textInput)){var e=t.textInput?t.textInput.trim():null;e&&t.setItem(e)}}),50)},submitForm:function(){var t=this.textInput?this.textInput.trim():null;t&&this.setItem(t)},setItem:function(t){if(this.items.find((function(i){return i.name.toLowerCase()!==val.toLowerCase()}))){var e=this.items.find((function(i){return i.name.toLowerCase()!==val.toLowerCase()}));this.$emit("selected",e),this.input=e.name}else{var n={id:"new-".concat(Date.now()),name:val};this.$emit("selected",n),this.input=val}this.currentSearch=null},clickedOption:function(t,e){this.textInput=e.name,this.currentSearch=null,this.input=e.name,this.selectedItemObject=e,this.$emit("selected",e),this.$refs.input&&this.$refs.input.blur()}},mounted:function(){}}),l=n(4),component=Object(l.a)(o,(function(){var t=this,e=t._self._c;return e("div",{staticClass:"w-full"},[e("p",{staticClass:"px-1 text-sm font-semibold",class:t.disabled?"text-gray-400":""},[t._v(t._s(t.label))]),t._v(" "),e("div",{ref:"wrapper",staticClass:"relative"},[e("form",{on:{submit:function(e){return e.preventDefault(),t.submitForm.apply(null,arguments)}}},[e("div",{ref:"inputWrapper",staticClass:"input-wrapper flex-wrap relative w-full shadow-xs flex items-center border border-gray-600 rounded-sm px-2 py-2",class:t.disabled?"pointer-events-none bg-black-300 text-gray-400":"bg-primary"},[e("input",{directives:[{name:"model",rawName:"v-model",value:t.textInput,expression:"textInput"}],ref:"input",staticClass:"h-full w-full bg-transparent focus:outline-hidden px-1",attrs:{disabled:t.disabled},domProps:{value:t.textInput},on:{keydown:t.keydownInput,focus:t.inputFocus,blur:t.inputBlur,input:function(e){e.target.composing||(t.textInput=e.target.value)}}})])]),t._v(" "),e("ul",{directives:[{name:"show",rawName:"v-show",value:t.isFocused&&t.currentSearch,expression:"isFocused && currentSearch"}],ref:"menu",staticClass:"absolute z-60 mt-0 w-full bg-bg border border-black-200 shadow-lg max-h-56 rounded-sm py-1 text-base ring-1 ring-black/5 overflow-auto focus:outline-hidden sm:text-sm",attrs:{role:"listbox","aria-labelledby":"listbox-label"}},[t._l(t.items,(function(n){return[e("li",{key:n.id,staticClass:"text-gray-50 select-none relative py-2 pr-3 cursor-pointer hover:bg-black-400",attrs:{role:"option"},on:{click:function(e){return t.clickedOption(e,n)},mouseup:function(t){t.stopPropagation(),t.preventDefault()},mousedown:function(t){t.preventDefault()}}},[e("div",{staticClass:"flex items-center"},[e("span",{staticClass:"font-normal ml-3 block truncate"},[t._v(t._s(n.name))])]),t._v(" "),t.isItemSelected(n)?e("span",{staticClass:"text-yellow-400 absolute inset-y-0 right-0 flex items-center pr-4"},[e("span",{staticClass:"material-symbols text-xl"},[t._v("check")])]):t._e()])]})),t._v(" "),t.items.length?t._e():e("li",{staticClass:"text-gray-50 select-none relative py-2 pr-9",attrs:{role:"option"}},[e("div",{staticClass:"flex items-center justify-center"},[e("span",{staticClass:"font-normal"},[t._v(t._s(t.$strings.MessageNoItems))])])])],2)])])}),[],!1,null,null,null);e.default=component.exports}}]);