import './async-D55cHugf.js';
import { f as attr_class, e as ensure_array_like, a as attr, c as spread_props } from './index-u8mz_F03.js';
import './2-BLdXJizP.js';
import { $ as $$1 } from './utils.svelte-B2py64Fz.js';
import { c } from './BlockTitle-BnJIYf6a.js';
import { F, G, S } from './Dropdown-D-In1KD6.js';
import { y } from './IconButtonWrapper-CjFRPb3y.js';
import { G as G$1 } from './Block-DZmzQwnI.js';
import { W as W$1 } from './index3-Df92vI-L.js';
export { default as BaseExample } from './Example4-wtFKJHsa.js';
import { e as escape_html } from './escaping-CBnpiEl5.js';
import './context-CBkBucIx.js';
import './index5-BoOEKc6P.js';
import './dev-fallback-Bc5Ork7Y.js';
import './index-Cg-Pg6j3.js';
import './clone-Yk88IHKV.js';
import './Info-DU6zbiUl.js';
import './html-CfyvkLET.js';
import './IconButton-BRnu7KaR.js';
import './Clear-D7Yjckqz.js';

function k(c){c.push('<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="100%" height="100%"><path d="M19 6.41L17.59 5 12 10.59 6.41 5 5 6.41 10.59 12 5 17.59 6.41 19 12 13.41 17.59 19 19 17.59 13.41 12z"></path></svg>');}function W(c,n){return c.reduce((e,m,f)=>((!n||m[0].toLowerCase().includes(n.toLowerCase()))&&e.push(f),e),[])}function j(c$1,n){c$1.component(e=>{const{$$slots:m,$$events:f,..._}=n,s=_.gradio;let h,u="",b=s.shared.label||"Multiselect",r=s.props.buttons,i=s.props.choices.map(t=>t[0]),l=s.props.choices.map(t=>t[1]),v=!s.shared.interactive,w=false,[B,g]=(()=>{const t=W(s.props.choices,u);return [t,t.length>0&&!s.props.allow_custom_value?t[0]:null]})();function D(){return s.props.value===void 0?[]:Array.isArray(s.props.value)?s.props.value.map(t=>{const o=l.indexOf(t);if(o!==-1)return o;if(s.props.allow_custom_value)return t}).filter(t=>t!==void 0):[]}let p=D();function x(t){p=p.filter(o=>o!==t),s.props.value=p.map(o=>typeof o=="number"?l[o]:o),s.dispatch("input"),s.dispatch("select",{index:typeof t=="number"?t:-1,value:typeof t=="number"?l[t]:t,selected:false});}function I(t){(s.props.max_choices==null||p.length<s.props.max_choices)&&(p.push(t),s.dispatch("select",{index:typeof t=="number"?t:-1,value:typeof t=="number"?l[t]:t,selected:true})),p.length===s.props.max_choices&&(w=false,g=null,h.blur()),s.props.value=p.map(o=>typeof o=="number"?l[o]:o);}function M(t){const o=parseInt(t);A(o);}function A(t){p.includes(t)?x(t):I(t),u="",g=null,s.dispatch("input");}s.props.value;function L(t){s.dispatch("custom_button_click",{id:t});}e.push(`<div${attr_class("svelte-1dv2vbb",void 0,{container:s.shared.container})}>`),s.shared.show_label&&r&&r.length>0?(e.push("<!--[-->"),y(e,{buttons:r,on_custom_button_click:L})):e.push("<!--[!-->"),e.push("<!--]--> "),c(e,{show_label:s.shared.show_label,info:s.props.info,children:t=>{t.push(`<!---->${escape_html(b)}`);},$$slots:{default:true}}),e.push(`<!----> <div class="wrap svelte-1dv2vbb"><div${attr_class("wrap-inner svelte-1dv2vbb",void 0,{show_options:w})}><!--[-->`);const y$1=ensure_array_like(p);for(let t=0,o=y$1.length;t<o;t++){let d=y$1[t];e.push('<div class="token svelte-1dv2vbb"><span class="svelte-1dv2vbb">'),typeof d=="number"?(e.push("<!--[-->"),e.push(`${escape_html(i[d])}`)):(e.push("<!--[!-->"),e.push(`${escape_html(d)}`)),e.push("<!--]--></span> "),v?e.push("<!--[!-->"):(e.push("<!--[-->"),e.push(`<div class="token-remove svelte-1dv2vbb" role="button" tabindex="0"${attr("title",s.i18n("common.remove")+" "+d)}>`),k(e),e.push("<!----></div>")),e.push("<!--]--></div>");}e.push(`<!--]--> <div class="secondary-wrap svelte-1dv2vbb"><input${attr_class("border-none svelte-1dv2vbb",void 0,{subdued:!i.includes(u)&&!s.props.allow_custom_value||p.length===s.props.max_choices})}${attr("disabled",v,true)} autocomplete="off"${attr("value",u)}${attr("readonly",!s.props.filterable,true)}/> `),v?e.push("<!--[!-->"):(e.push("<!--[-->"),p.length>0?(e.push("<!--[-->"),e.push(`<div role="button" tabindex="0" class="token-remove remove-all svelte-1dv2vbb"${attr("title",s.i18n("common.clear"))}>`),k(e),e.push("<!----></div>")):e.push("<!--[!-->"),e.push('<!--]--> <span class="icon-wrap svelte-1dv2vbb">'),F(e),e.push("<!----></span>")),e.push("<!--]--></div></div> "),G(e,{show_options:w,choices:s.props.choices,filtered_indices:B,disabled:v,selected_indices:p,active_index:g,remember_scroll:true,onchange:M}),e.push("<!----></div></div>");});}function $(c,n){c.component(e=>{let{$$slots:m,$$events:f,..._}=n;const s=new $$1(_);let h=true,u;function b(r){G$1(r,{visible:s.shared.visible,elem_id:s.shared.elem_id,elem_classes:s.shared.elem_classes,padding:s.shared.container,allow_overflow:false,scale:s.shared.scale,min_width:s.shared.min_width,children:i=>{W$1(i,spread_props([{autoscroll:s.shared.autoscroll,i18n:s.i18n},s.shared.loading_status,{on_clear_status:()=>s.dispatch("clear_status",loading_status)}])),i.push("<!----> "),s.props.multiselect?(i.push("<!--[-->"),j(i,{gradio:s})):(i.push("<!--[!-->"),S(i,{label:s.shared.label,info:s.props.info,choices:s.props.choices,interactive:s.shared.interactive,show_label:s.shared.show_label,container:s.shared.container,allow_custom_value:s.props.allow_custom_value,filterable:s.props.filterable,buttons:s.props.buttons,oncustom_button_click:l=>{s.dispatch("custom_button_click",{id:l});},on_change:()=>s.dispatch("change"),on_input:()=>s.dispatch("input"),on_select:l=>s.dispatch("select",l),on_focus:()=>s.dispatch("focus"),on_blur:()=>s.dispatch("blur"),on_key_up:l=>s.dispatch("key_up",l),get value(){return s.props.value},set value(l){s.props.value=l,h=false;}})),i.push("<!--]-->");},$$slots:{default:true}});}do h=true,u=e.copy(),b(u);while(!h);e.subsume(u);});}

export { S as BaseDropdown, G as BaseDropdownOptions, j as BaseMultiselect, $ as default };
//# sourceMappingURL=Index41-Cc8nrDFD.js.map
