1import{d as ot,ad as at,c as p,c5 as nt,a_ as lt,am as it,w as D,o as s,a as g,z as y,b as m,j as A,ac as I,p as k,v as re,aJ as rt,k as se,S as st,bL as ut,n as q,c6 as Ve,m as W,c7 as ct,J as ue,q as dt,c8 as ft,c9 as vt,bN as G,bc as De,F as Ie,y as ht,Q as d,R as E,ca as pt,V as gt}from"./DvgxvNL0.js";import{O as wt}from"./BT-X2sQH.js";const bt={key:0,class:"relative w-full rounded-xl"},yt={class:"min-w-0 truncate"},mt={class:"flex min-w-0 items-center gap-2"},xt={key:1,class:"min-w-0 truncate font-semibold leading-tight text-inherit"},kt={key:2,class:"min-w-0 truncate text-secondary opacity-70 font-medium leading-tight"},St={class:"flex shrink-0 items-center gap-1"},Tt=["role"],Ot={key:0,class:"h-px bg-surface-5"},Ct={class:"flex w-full items-center justify-between gap-2"},Vt={class:"flex items-center gap-2"},Dt={class:"flex flex-col gap-1.5"},It={key:1,class:"p-4 text-center text-sm text-secondary"},J=8,Q=8,Lt=300,Rt=ot({__name:"Combobox",props:{modelValue:{},options:{},placeholder:{default:"Select an option"},disabled:{type:Boolean,default:!1},searchable:{type:Boolean,default:!1},clearable:{type:Boolean,default:!1},searchPlaceholder:{default:"Search..."},listbox:{type:Boolean,default:!0},showChevron:{type:Boolean,default:!0},showIconInSelected:{type:Boolean,default:!1},maxHeight:{default:Lt},displayValue:{},searchValue:{},triggerClass:{},triggerType:{default:"base"},triggerSize:{default:"md"},triggerInteraction:{default:"surface"},dropdownClass:{},outsideClickIgnore:{default:()=>[]},dropdownWidth:{},dropdownMinWidth:{},forceDirection:{},noOptionsMessage:{default:"No results found"},disableSearchFilter:{type:Boolean},minSearchLengthToOpen:{default:0},syncWithSelection:{type:Boolean,default:!0},selectSearchTextOnFocus:{type:Boolean,default:!1},showSearchIcon:{type:Boolean,default:!1},searchType:{default:"text"},searchName:{},searchInputmode:{},searchAutocomplete:{},searchAutocorrect:{},searchAutocapitalize:{},searchSpellcheck:{type:Boolean},searchInputAttrs:{},searchInputVariant:{default:"surface"}},emits:["update:modelValue","select","option-hover","open","close","searchInput","searchBlur"],setup(l,{emit:Le}){const Re=Object.freeze({overflow:{x:"hidden",y:"scroll"},scrollbars:{theme:"os-theme-modrinth",autoHide:"leave",autoHideSuspend:!0}});function N(e){return"value"in e}function S(e){return e.type==="divider"}const a=l,x=Le,X=at(),i=d(!1),f=d(""),L=d(!1),u=d(-1),Y=d(),ce=d(),Z=d(),R=d(),_=d(),F=d(),ee=d(),de=d([]),M=d(null),T=d(null),B=p(()=>a.searchable&&Z.value?Z.value.$el:ce.value?.element??void 0),Me=p(()=>[B,Y,...a.outsideClickIgnore]),P=d({top:"0px",left:"0px",width:"0px",minWidth:"0px"}),O=d("down"),Be=p(()=>
1O.value==="up"?"bottom center":"top center"),z=p(()=>a.options.find(e=>N(e)&&e.value===a.modelValue)),fe=p(()=>!(!a.searchable||!a.syncWithSelection||!z.value||!X["search-selection-affix"]||i.value||L.value)),ze=p(()=>{const e=[];return fe.value&&e.push("!text-transparent [caret-color:var(--color-text-primary)] selection:bg-transparent"),e.join(" ")}),ve=p(()=>a.displayValue!==void 0?a.displayValue:z.value?.label??""),He=p(()=>a.displayValue!==void 0?a.displayValue:a.placeholder),te=p(()=>!a.searchable||f.value.trim().length>=a.minSearchLengthToOpen),he=p(()=>a.options.map((e,t)=>({...e,key:S(e)?`divider-${t}`:`option-${e.value}`}))),v=p(()=>{if(!f.value||!a.searchable||a.disableSearchFilter||!L.value)return he.value;const e=f.value.toLowerCase();return he.value.filter(t=>S(t)?!1:!!(t.label.toLowerCase().includes(e)||t.searchTerms?.some(o=>o.toLowerCase().includes(e))))}),oe=p(()=>v.value.length>0||!!f.value||!!X["dropdown-footer"]),pe=p(()=>i.value&&oe.value);function Ae(e,t){const o=a.listbox&&e.value===a.modelValue;return[e.class,{"bg-surface-4 text-contrast hover:brightness-[115%] focus:brightness-[115%]":!o,"bg-highlight-green text-green hover:bg-highlight-green focus:bg-highlight-green":o,"cursor-not-allowed opacity-50 pointer-events-none":e.disabled}]}function We(e,t){de.value[t]=e}function Ee(){u.value=a.listbox?a.options.findIndex(e=>N(e)&&e.value===a.modelValue):-1,u.value>=0&&ge(u.value,"center")}function $e(){return T.value?.elements().viewport??F.value}function ge(e,t){const o=de.value[e],n=$e();if(!o||!n)return;const r=o.getBoundingClientRect(),c=n.getBoundingClientRect(),h=r.top-c.top+n.scrollTop,b=r.height,V=n.clientHeight,Ce=n.scrollTop;if(t==="center"){n.scrollTop=Math.max(0,h-(V-b)/2);return}h<Ce?n.scrollTop=h:h+b>Ce+V&&(n.scrollTop=h+b-V)}function Ne(){let n=0;if(v.value.length===0)f.value&&(n+=52);else{for(const r of v.value)S(r)?n+=1:n+=r.subLabel?68:44;n=Math.min(n,a.maxHeight)}return X["dropdown-footer"]&&(n+=48),n}function Fe(){if(a.forceDirection){O.value=a.forceDirection;return}if(!B.value)return;const e=ae(B.value),t=be();O.value=we(e,{width:e.width,height:Ne()},t)}function we(e,t,o){if(a.forceDirection)return a.forceDirection;const n=e.top+o.offsetTop,r=e.bottom+o.offsetTop,c=o.offsetTop,h=o.offsetTop+o.height,b=r+t.height+Q+J<=h,V=n-t.height-Q-J>c;return!b&&V?"up":"down"}function Pe(e,t,o,n){return(o==="up"?e.top-t.height-Q:e.bottom+Q)+n.offsetTop}function Ke(e,t,o){const n=o.offsetLeft+J,r=o.offsetLeft+o.width-J;let c=e.left+o.offsetLeft;return c+t.width>r&&(c=Math.max(n,r-t.width)),c}function be(){const e=window.visualViewport;return{width:e?.width??window.innerWidth,height:e?.height??window.innerHeight,offsetTop:e?.offsetTop??0,offsetLeft:e?.offsetLeft??0}}function ae(e){const t=e.getBoundingClientRect(),o=getComputedStyle(e).transform;if(!o||o==="none")return t;const n=new DOMMatrixReadOnly(o),r=Math.hypot(n.a,n.b)||1,c=Math.hypot(n.c,n.d)||1;if(Math.abs(r-1)<.001&&Math.abs(c-1)<.001)return t;const h=t.width/r,b=t.height/c;return new DOMRect(t.left+(t.width-h)/2,t.top+(t.height-b)/2,h,b)}function Ue(e){return a.dropdownWidth===void 0?`${e}px`:typeof a.dropdownWidth=="number"?`${a.dropdownWidth}px`:a.dropdownWidth}function je(e){if(e!==void 0)return typeof e=="number"?`${e}px`:e}async function $(){if(!B.value||!R.value)return;await E();const e=B.value;let t=ae(e);const o=Ue(t.width),n=je(a.dropdownMinWidth)??"0px";P.value={...P.value,width:o,minWidth:n},await E(),t=ae(e);const r={width:R.value.offsetWidth,height:R.value.offsetHeight},c=be(),h=we(t,r,c),b=Pe(t,r,h,c),V=Ke(t,r,c);P.value={top:`${b}px`,left:`${V}px`,width:o,minWidth:n},O.value=h}async function ne(){if(await E(),!i.value||v.value.length===0){K();return}if(!(!_.value||!F.value||!ee.value)){if(T.value){T.value.update(!0);return}T.value=wt({target:_.value,elements:{viewport:F.value,content:ee.value}},Re)}}function ye(){E(()=>{T.value?.update(!0)})}function K(){T.value?.destroy(),T.value=null}async function C(){a.disabled||i.value||!te.value||!oe.value||(pt(),Fe(),i.value=!0,x("open"),await E(),await $(),await ne(),tt(),Ee(),ie())}function w(){i.value&&(Te(),K(),i.value=!1,L.value=!1,u.value=-1,x("close"),a.searchable||E(()=>{B.value?.focus()}))}function qe(e){e.detail!==0&&(i.value?w():C())}function le(e,t){if(e.disabled||e.type==="divider")return;if(a.listbox&&e.value===a.modelValue){u.value=t,e.type!=="link"&&w();return}u.value=t,e.action&&e.action(),a.listbox&&e.value!==void 0&&x("update:modelValue",e.value),x("select",e),e.type!=="link"&&(
1a.searchable&&(f.value=a.syncWithSelection?e.label:""),w())}function Ge(e,t){e.disabled||(u.value=t,x("option-hover",e))}function me(e,t){const o=v.value.length;if(o===0)return-1;let n=e;for(let r=0;r<o;r++){n=t==="next"?(n+1)%o:(n-1+o)%o;const c=v.value[n];if(!S(c)&&!c.disabled)return n}return-1}function xe(e){if(e<0||e>=v.value.length)return;const t=v.value[e];S(t)||t.disabled||(u.value=e,ge(e,"nearest"))}function U(){const e=me(u.value,"next");xe(e)}function j(){const e=me(u.value,"previous");xe(e)}function Je(e){if(i.value){ke(e);return}switch(e.key){case"Enter":case" ":case"ArrowDown":case"ArrowUp":e.preventDefault(),C();break}}function ke(e){switch(e.key){case"Escape":e.preventDefault(),w();break;case"ArrowDown":e.preventDefault(),U();break;case"ArrowUp":e.preventDefault(),j();break;case"Enter":case" ":if(e.preventDefault(),u.value>=0){const t=v.value[u.value];S(t)||le(t,u.value)}break;case"Tab":e.preventDefault(),e.shiftKey?j():U();break}}function Qe(e){if(e.key==="Escape")e.preventDefault(),w();else if(e.key==="ArrowDown")e.preventDefault(),i.value||C(),U();else if(e.key==="ArrowUp")e.preventDefault(),i.value||C(),j();else if(e.key==="Enter"){if(e.preventDefault(),u.value>=0){const t=v.value[u.value];t&&!S(t)&&le(t,u.value)}}else e.key==="Tab"&&i.value&&(e.preventDefault(),e.shiftKey?j():U())}
1function Xe(){if(L.value=!0,x("searchInput",f.value),!te.value){w();return}i.value||C()}function Ye(){L.value=!0,x("searchInput",f.value),w()}function Ze(e){const t=e.target;a.selectSearchTextOnFocus&&t instanceof HTMLInputElement&&window.setTimeout(()=>{document.activeElement===t&&t.select()}),i.value||C()}function _e(e){const t=e.relatedTarget;t instanceof Node&&Y.value?.contains(t)||t instanceof Node&&R.value?.contains(t)||(x("searchBlur",f.value),a.searchValue!==void 0&&(f.value=a.searchValue),w())}function et(){i.value||C()}function Se(){i.value&&ie()}function ie(){M.value===null&&(M.value=requestAnimationFrame(()=>{M.value=null,$()}))}function H(){i.value&&ie()}function tt(){window.addEventListener("scroll",H,!0),window.visualViewport?.addEventListener("scroll",H),window.visualViewport?.addEventListener("resize",H)}function Te(){window.removeEventListener("scroll",H,!0),window.visualViewport?.removeEventListener("scroll",H),window.visualViewport?.removeEventListener("resize",H),M.value!==null&&(cancelAnimationFrame(M.value),M.value=null)}nt(R,()=>{w()},{ignore:Me});const Oe=d(!1);return lt(()=>{Oe.value=!0,window.addEventListener("resize",Se)}),it(()=>{window.removeEventListener("resize",Se),Te(),K()}),D(i,e=>{e&&$()}),D(pe,e=>{e&&($(),ne())}),D(v,()=>{i.value&&($(),v.value.length>0?ne():K())}),D(oe,e=>{!e&&i.value&&w()}),D(te,e=>{e||w()}),D([()=>a.modelValue,()=>a.options],([e])=>{if(a.searchable&&a.syncWithSelection&&!i.value&&!L.value){const t=a.options.find(o=>N(o)&&o.value===e);f.value=t&&N(t)?t.label:""}i.value&&ye()},{immediate:!0}),D(()=>a.maxHeight,()=>{i.value&&ye()}),(e,t)=>(s(),g("div",{ref_key:"containerRef",ref:Y,class:"relative inline-block w-full"},[l.searchable?(s(),g("div",bt,[fe.value?(s(),g("div",{key:0,class:y(["pointer-events-none absolute inset-y-0 left-0 right-0 z-[2] flex min-w-0 items-center gap-2 font-medium text-primary",[l.showSearchIcon?"pl-10":"pl-3",l.showChevron?"pr-10":"pr-3"]]),"aria-hidden":"true"},[m("span",yt,A(f.value),1),I(e.$slots,"search-selection-affix",{option:z.value},void 0,!0)],2)):k("",!0),re(rt,{ref_key:"searchTriggerRef",ref:Z,modelValue:f.value,"onUpdate:modelValue":t[0]||(t[0]=o=>f.value=o),icon:l.showSearchIcon?se(st):void 0,type:l.searchType,name:l.searchName,placeholder:l.searchPlaceholder||l.placeholder,disabled:l.disabled,clearable:l.clearable,autocomplete:l.searchAutocomplete,autocorrect:l.searchAutocorrect,autocapitalize:l.searchAutocapitalize,spellcheck:l.searchSpellcheck,inputmode:l.searchInputmode,"input-attrs":l.searchInputAttrs,appearance:l.searchInputVariant,"wrapper-class":"w-full","input-class":ze.value,class:"relative z-[1]",onInput:Xe,onKeydown:Qe,onFocusin:Ze,onFocusout:_e,onClick:et,onClear:Ye},ut({_:2},[l.showChevron?{name:"trailing",fn:q(()=>[re(se(Ve),{class:y(["pointer-events-none size-5 text-secondary transition-transform duration-150",i.value&&O.value==="down"?"rotate-90":"-rotate-90"])},null,8,["class"])]),key:"0"}:void 0]),1032,["modelValue","icon","type","name","placeholder","disabled","clearable","autocomplete","autocorrect","autocapitalize","spellcheck","inputmode","input-attrs","appearance","input-class"])])):(s(),W(ct,{key:1,ref_key:"triggerRef",ref:ce,as:"button","native-type":"button",type:l.triggerType,size:l.triggerSize,interaction:l.triggerInteraction,disabled:l.disabled,class:y(["min-w-full w-full !justify-between overflow-hidden text-left",a.triggerClass,{"z-[100005]":i.value}]),"aria-expanded":i.value,"aria-haspopup":l.listbox?"listbox":"menu","aria-disabled":l.disabled||void 0,onClick:t[1]||(t[1]=o=>qe(o)),onKeydown:Je},{default:q(()=>[m("div",mt,[I(e.$slots,"prefix",{},void 0,!0),l.showIconInSelected&&z.value?.icon?(s(),W(ue(z.value?.icon),{key:0,class:"h-5 w-5 shrink-0"})):k("",!0),z.value?(s(),g("span",xt,[I(e.$slots,"selected",{label:ve.value},()=>[dt(A(ve.value),1)],!0)])):(s(),g("span",kt,A(He.value),1))]),m("div",St,[I(e.$slots,"suffix",{},void 0,!0),l.showChevron?(s(),W(se(Ve),{key:0,class:y(["size-5 shrink-0 transition-transform duration-150",i.value&&O.value==="down"?"rotate-90":"-rotate-90"])},null,8,["class"])):k("",!0)])]),_:3},8,["type","size","interaction","disabled","class","aria-expanded","aria-haspopup","aria-disabled"])),Oe.value?(s(),W(ft,{key:2,to:"body"},[re(vt,{name:"floating-expand"},{default:q(()=>[pe.value?(s(),g("div",{key:0,ref_key:"dropdownRef",ref:R,class:y(["fixed z-[100005] flex flex-col overflow-hidden rounded-[14px] bg-surface-4 border border-solid border-surface-5",[a.dropdownClass,O.value==="up"?"shadow-[0_-25
1px_50px_-12px_rgb(0,0,0,0.25)]":"shadow-2xl"]]),style:De([P.value,{transformOrigin:Be.value}]),role:l.listbox?"listbox":"menu",onPointerdown:t[4]||(t[4]=G(()=>{},["stop"])),onMousedown:t[5]||(t[5]=G(()=>{},["stop"])),onKeydown:ke},[v.value.length>0?(s(),g("div",{key:0,ref_key:"optionsScrollbarRef",ref:_,class:"combobox-options-scrollbar bg-surface-4","data-overlayscrollbars-initialize":"",onMousedown:t[3]||(t[3]=G(()=>{},["prevent","stop"]))},[m("div",{ref_key:"optionsContainerRef",ref:F,class:"overflow-y-auto",style:De({maxHeight:`${l.maxHeight}px`}),"data-overlayscrollbars-viewport":""},[m("div",{ref_key:"optionsListRef",ref:ee,class:"flex flex-col"},[(s(!0),g(Ie,null,ht(v.value,(o,n)=>(s(),g(Ie,{key:o.key},[o.type==="divider"?(s(),g("div",Ot)):(s(),W(ue(o.type==="link"?"a":"span"),{key:1,ref_for:!0,ref:r=>We(r,n),href:o.type==="link"&&!o.disabled?o.href:void 0,target:o.type==="link"&&!o.disabled?o.target:void 0,role:l.listbox?"option":"menuitem","aria-selected":l.listbox&&o.value===l.modelValue,"aria-disabled":o.disabled||void 0,"data-focused":u.value===n,class:y(["group/option flex items-center gap-2.5 cursor-pointer px-4 py-3 text-left transition-all duration-150",Ae(o,n)]),tabindex:"-1",onMousedown:t[2]||(t[2]=G(()=>{},["prevent"])),onClick:r=>le(o,n),onMouseenter:r=>Ge(o,n)},{default:q(()=>[I(e.$slots,"option",{item:o,index:n,isSelected:!!(l.listbox&&o.value===l.modelValue)},()=>[m("div",Ct,[m("div",Vt,[o.icon?(s(),W(ue(o.icon),{key:0,class:y(["h-5 w-5",o.value===l.modelValue?"text-green":"text-primary"])},null,8,["class"])):k("",!0),m("div",Dt,[m("span",{class:y(["font-semibold leading-tight",o.value===l.modelValue?"text-green":"text-primary"])},A(o.label),3),o.subLabel?(s(),g("span",{key:0,class:y(["text-sm",o.value===l.modelValue?"text-green":"text-secondary"])},A(o.subLabel),3)):k("",!0)])]),I(e.$slots,"option-suffix",{item:o},void 0,!0)])],!0)]),_:2},1064,["href","target","role","aria-selected","aria-disabled","data-focused","class","onClick","onMouseenter"]))],64))),128))],512)],4)],544)):f.value?(s(),g("div",It,A(l.noOptionsMessage),1)):k("",!0),I(e.$slots,"dropdown-footer",{},void 0,!0)],46,Tt)):k("",!0)]),_:3})])):k("",!0)],512))}}),zt=gt(Rt,[["__scopeId","data-v-2707ad1a"]]);export{zt as C};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.