import{e as S}from"./app-core.a6d808ce.js";import{aw as O,aq as d,f as h,Q as B,R as o,B as n,j as i,a0 as g,ae as f,U as p,i as k,M as V,T as b,P as C}from"./vendor-vue-ui.de3ab35f.js";import{S as T}from"./Caret.a017b70a.js";import{S as w}from"./Close.098d4b76.js";import{_ as A}from"./_plugin-vue_export-helper.eefbdd86.js";import{_ as E}from"./vendor-other.7b559694.js";const P="all-in-one-seo-pack",j={emits:["open","close","update:modelValue"],components:{Multiselect:O,SvgCaret:T,SvgClose:w},props:{options:{type:Array,required:!0},trackBy:{type:String,default(){return"value"}},multiple:Boolean,taggable:Boolean,filterable:Boolean,searchable:{type:Boolean,default(){return!0}},placeholder:{type:String,default(){return""}},customLabel:{type:Function,default:({label:t})=>t},name:String,modelValue:[String,Array,Number,Object],ajaxSearch:Function,noDataText:String,popperClass:String,loading:Boolean,disabled:Boolean,size:String,openDirection:{type:String,default(){return null}},groupValues:String,groupLabel:String,closeOnSelect:{type:Boolean,default(){return!0}},tagPlaceholder:String,allowEmpty:{type:Boolean,default(){return!1}},preserveOptions:{type:Boolean,default(){return!0}}},data(){return{isLoading:!1,internalOptions:[],strings:{searchPlaceholder:E("Type to search...",P)}}},watch:{options(){this.resetFirstLastOption()}},computed:{effectiveOptions(){if(this.preserveOptions){const t=[...this.internalOptions];return this.options.forEach(s=>{t.some(e=>e.value===s.value)||t.push(s)}),t}return this.options}},methods:{addTag(t){t.split(",").forEach(s=>{const e={label:s,value:s};this.preserveOptions?this.internalOptions.some(a=>a.value===e.value)||this.internalOptions.push(e):this.options.some(a=>a.value===e.value)||this.options.push(e),this.modelValue.some(a=>a.value===e.value)||this.modelValue.push(e)}),this.$emit("update:modelValue",this.modelValue),this.$refs["aioseo-select"].$el.focus()},searchChange(t){t&&this.ajaxSearch&&(this.isLoading=!0,S(()=>{this.ajaxSearch(t).then(()=>this.isLoading=!1)},500))},resetFirstLastOption(){this.$nextTick(()=>{if(!this.$refs["aioseo-select"])return;const t=this.$refs["aioseo-select"]?.$el?.querySelectorAll("li.multiselect__element")||[];t.forEach((s,e)=>{s.classList.remove("last"),s.classList.remove("first"),e===0&&s.classList.add("first"),e===t.length-1&&s.classList.add("last")})})}},mounted(){this.resetFirstLastOption(),this.preserveOptions&&0<this.options.length&&(this.internalOptions=[...this.options])}},F={class:"multiselect__tag"},M={class:"multiselect__tag-value"},N=["onClick"],z=["innerHTML"],D={class:"multiselect__select"};function R(t,s,e,a,m,r){const _=d("svg-close"),v=d("svg-caret"),y=d("multiselect");return h(),B(y,{class:C(["aioseo-select",[{[e.size]:e.size},{multiple:e.multiple}]]),modelValue:e.modelValue,"onUpdate:modelValue":s[0]||(s[0]=l=>t.$emit("update:modelValue",l)),options:r.effectiveOptions,multiple:e.multiple,taggable:e.taggable,placeholder:e.placeholder||m.strings.searchPlaceholder,"tag-placeholder":e.tagPlaceholder,"show-labels":!1,"track-by":e.trackBy,"custom-label":e.customLabel,"allow-empty":e.allowEmpty||!!e.multiple,filterable:e.filterable,"internal-search":!0,loading:m.isLoading,searchable:e.searchable,"open-direction":e.openDirection,"group-values":e.groupValues,"group-label":e.groupLabel,disabled:e.disabled,"close-on-select":e.closeOnSelect,onSearchChange:r.searchChange,onTag:r.addTag,onOpen:s[1]||(s[1]=l=>t.$emit("open")),onClose:s[2]||(s[2]=l=>t.$emit("close")),ref:"aioseo-select"},{singleLabel:o(({option:l})=>[n(t.$slots,"singleLabel",{option:l},()=>[f(p(l.label),1)])]),tag:o(({option:l,search:c,remove:u})=>[n(t.$slots,"tag",{option:l,search:c,remove:u},()=>[i("div",F,[i("div",M,p(l.label),1),i("div",{class:"multiselect__tag-remove",onClick:b(L=>u(l),["stop"])},[g(_,{onClick:b(L=>u(l),["stop"])},null,8,["onClick"])],8,N)])])]),option:o(({option:l,search:c})=>[n(t.$slots,"option",{option:l,search:c},()=>[f(p(l.$isLabel?l.$groupLabel:l.label)+" ",1),l.docLink?(h(),k("span",{key:0,class:"docLink",innerHTML:l.docLink},null,8,z)):V("",!0)])]),caret:o(({toggle:l})=>[n(t.$slots,"caret",{toggle:l},()=>[i("div",D,[g(v)])])]),noOptions:o(()=>[n(t.$slots,"noOptions")]),noResult:o(()=>[n(t.$slots,"noResult")]),_:3},8,["class","modelValue","options","multiple","taggable","placeholder","tag-placeholder","track-by","custom-label","allow-empty","filterable","loading","searchable","open-direction","group-values","group-label","disabled","close-on-select","onSearchChange","onTag"])}const G=A(j,[["render",R]]);export{G as B};
