import{e as L}from"./app-core.c8323d51.js";import{aw as S,aq as g,f as _,Q as O,R as a,B as i,j as d,a0 as v,ae as b,U as f,i as B,M as C,T as y,P as k}from"./vendor-vue-ui.232c7c36.js";import{S as x}from"./Caret.aae02d8a.js";import{S as V}from"./Close.7fb523c8.js";import{_ as D}from"./_plugin-vue_export-helper.eefbdd86.js";import{_ as F}from"./vendor-other.39e59221.js";const E="all-in-one-seo-pack",T={emits:["open","close","update:modelValue"],components:{Multiselect:S,SvgCaret:x,SvgClose:V},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}},floatDropdown:{type:Boolean,default:!1}},data(){return{isLoading:!1,internalOptions:[],strings:{searchPlaceholder:F("Type to search...",E)}}},watch:{options(){this.resetFirstLastOption()}},computed:{effectiveOptions(){if(this.preserveOptions){const t=[...this.internalOptions];return this.options.forEach(o=>{t.some(e=>e.value===o.value)||t.push(o)}),t}return this.options}},methods:{addTag(t){t.split(",").forEach(o=>{const e={label:o,value:o};this.preserveOptions?this.internalOptions.some(l=>l.value===e.value)||this.internalOptions.push(e):this.options.some(l=>l.value===e.value)||this.options.push(e),this.modelValue.some(l=>l.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,L(()=>{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((o,e)=>{o.classList.remove("last"),o.classList.remove("first"),e===0&&o.classList.add("first"),e===t.length-1&&o.classList.add("last")})})},onOpen(){this.$emit("open"),this.floatDropdown&&(this.$nextTick(()=>this.positionFloatingDropdown()),window.addEventListener("scroll",this.positionFloatingDropdown,!0),window.addEventListener("resize",this.positionFloatingDropdown))},onClose(){this.$emit("close"),this.floatDropdown&&(window.removeEventListener("scroll",this.positionFloatingDropdown,!0),window.removeEventListener("resize",this.positionFloatingDropdown))},positionFloatingDropdown(){const t=this.$refs["aioseo-select"]?.$el;if(!t)return;const o=t.querySelector(".multiselect__content-wrapper"),e=t.querySelector(".multiselect__tags");if(!o||!e)return;const l=e.getBoundingClientRect(),r=window.innerHeight;o.style.transition="opacity 0.15s ease",o.style.position="fixed",o.style.bottom="auto",o.style.left=`${l.left}px`,o.style.width=`${l.width}px`,o.style.maxHeight="300px",o.style.zIndex="100000";const n=r-l.bottom,c=l.top,u=o.offsetHeight,p=u>n&&c>n,s=Math.max(120,Math.min(300,(p?c:n)-8));o.style.maxHeight=`${s}px`,o.style.top=p?`${l.top-Math.min(u,s)}px`:`${l.bottom}px`}},mounted(){this.resetFirstLastOption(),this.preserveOptions&&0t.$emit("update:modelValue",s)),options:n.effectiveOptions,multiple:e.multiple,taggable:e.taggable,placeholder:e.placeholder||r.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:r.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:n.searchChange,onTag:n.addTag,onOpen:n.onOpen,onClose:n.onClose,ref:"aioseo-select"},{singleLabel:a(({option:s})=>[i(t.$slots,"singleLabel",{option:s},()=>[b(f(s.label),1)])]),tag:a(({option:s,search:h,remove:m})=>[i(t.$slots,"tag",{option:s,search:h,remove:m},()=>[d("div",H,[d("div",z,f(s.label),1),d("div",{class:"multiselect__tag-remove",onClick:y(w=>m(s),["stop"])},[v(c,{onClick:y(w=>m(s),["stop"])},null,8,["onClick"])],8,A)])])]),option:a(({option:s,search:h})=>[i(t.$slots,"option",{option:s,search:h},()=>[b(f(s.$isLabel?s.$groupLabel:s.label)+" ",1),s.docLink?(_(),B("span",{key:0,class:"docLink",innerHTML:s.docLink},null,8,M)):C("",!0)])]),caret:a(({toggle:s})=>[i(t.$slots,"caret",{toggle:s},()=>[d("div",P,[v(u)])])]),noOptions:a(()=>[i(t.$slots,"noOptions")]),noResult:a(()=>[i(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","onOpen","onClose"])}const Q=D(T,[["render",$]]);export{Q as B};