import"./svelte/svelte_internal_flags_async.js";import*as e from"./svelte/svelte_internal_client.js";import"./i18n-BldJSFLV.js";import{G as D}from"./utils.svelte-Ceck75cM.js";import{B as E,e as W,c as j}from"./IconButtonWrapper-Cljb5D-5.js";import"./svelte/svelte_internal_flags_legacy.js";import"./svelte/svelte_svelte.js";import{S as z}from"./StreamingBar-b2qVLPYU.js";import{d as C}from"./index-tFQomdd2.js";import"./svelte/svelte_store.js";import"./index-Ds2meNS5.js";import"./svelte/svelte_animate.js";import"./svelte/svelte_attachments.js";import"./svelte/svelte_easing.js";import"./svelte/svelte_internal_flags_tracing.js";import"./svelte/svelte_internal_server.js";import"./svelte/svelte_legacy.js";import"./svelte/svelte_motion.js";import"./svelte/svelte_reactivity.js";import"./svelte/svelte_reactivity_window.js";import"./svelte/svelte_server.js";import"./svelte/svelte_transition.js";import"./svelte/svelte_events.js";import"./MarkdownCode-C2b9iIxl.js";import"./prism-python-CpYAgONt.js";var F=e.from_html('<div class="select-all-container svelte-yb2gcx"><label class="select-all-label svelte-yb2gcx"><input class="select-all-checkbox svelte-yb2gcx" type="checkbox" title="Select/Deselect All"/></label> <button type="button" class="label-text svelte-yb2gcx"> </button></div>'),H=e.from_html('<label><input type="checkbox" class="svelte-yb2gcx"/> <span class="ml-2 svelte-yb2gcx"> </span></label>'),J=e.from_html('<!> <!> <!> <div class="wrap svelte-yb2gcx" data-testid="checkbox-group"></div>',1);function ue(I,b){e.push(b,!0);let P=e.rest_props(b,["$$slots","$$events","$$legacy"]),t=new D(P);function f(a){t.props.value.includes(a)?t.props.value=t.props.value.filter(c=>c!==a):t.props.value=[...t.props.value,a],t.dispatch("input")}function x(){const a=t.props.choices.map(([,c])=>c);t.props.value.length===a.length?t.props.value=[]:t.props.value=a.slice(),t.dispatch("input")}let k=e.derived(()=>{const a=t.props.choices.map(([,c])=>c);return t.props.value.length===0?"unchecked":t.props.value.length===a.length?"checked":"indeterminate"}),y=e.derived(()=>!t.shared.interactive),$=t.props.value;e.user_effect(()=>{t.props.value,!C($,t.props.value)&&($=t.props.value,t.dispatch("change",e.snapshot(t.props.value)))}),E(I,{get visible(){return t.shared.visible},get elem_id(){return t.shared.elem_id},get elem_classes(){return t.shared.elem_classes},type:"fieldset",get container(){return t.shared.container},get scale(){return t.shared.scale},get min_width(){return t.shared.min_width},children:(a,c)=>{var w=J(),S=e.first_child(w);z(S,e.spread_props({get autoscroll(){return t.shared.autoscroll},get i18n(){return t.i18n}},()=>t.shared.loading_status,{on_clear_status:()=>t.dispatch("clear_status",t.shared.loading_status)}));var B=e.sibling(S,2);{var T=n=>{j(n,{get buttons(){return t.props.buttons},on_custom_button_click:v=>{t.dispatch("custom_button_click",{id:v})}})};e.if(B,n=>{t.shared.show_label&&t.props.buttons&&t.props.buttons.length>0&&n(T)})}var A=e.sibling(B,2);{let n=e.derived(()=>t.shared.show_label||t.props.show_select_all&&t.shared.interactive);W(A,{get show_label(){return e.get(n)},get info(){return t.props.info},children:(v,h)=>{var _=e.comment(),m=e.first_child(_);{var s=i=>{var l=F(),o=e.child(l),p=e.child(o);e.remove_input_defaults(p),e.reset(o);var r=e.sibling(o,2),u=e.child(r,!0);e.reset(r),e.reset(l),e.template_effect(()=>{e.set_checked(p,e.get(k)==="checked"),p.indeterminate=e.get(k)==="indeterminate",e.set_text(u,t.shared.show_label?t.shared.label:"Select All")}),e.event("change",p,x),e.event("click",r,x),e.append(i,l)},d=i=>{var l=e.comment(),o=e.first_child(l);{var p=r=>{var u=e.text();e.template_effect(g=>e.set_text(u,g),[()=>t.shared.label||t.i18n("checkbox.checkbox_group")]),e.append(r,u)};e.if(o,r=>{t.shared.show_label&&r(p)},!0)}e.append(i,l)};e.if(m,i=>{t.props.show_select_all&&t.shared.interactive?i(s):i(d,!1)})}e.append(v,_)},$$slots:{default:!0}})}var G=e.sibling(A,2);e.each(G,21,()=>t.props.choices,e.index,(n,v,h)=>{var _=e.derived(()=>e.to_array(e.get(v),2));let m=()=>e.get(_)[0],s=()=>e.get(_)[1];var d=H();let i;var l=e.child(d);e.remove_input_defaults(l);var o=e.sibling(l,2),p=e.child(o,!0);e.reset(o),e.reset(d),e.template_effect((r,u,g,q)=>{i=e.set_class(d,1,"svelte-yb2gcx",null,i,r),l.disabled=e.get(y),e.set_checked(l,u),e.set_attribute(l,"name",g),e.set_attribute(l,"title",q),e.set_text(p,m())},[()=>({disabled:e.get(y),selected:t.props.value.includes(s())}),()=>t.props.value.includes(s()),()=>s()?.toString(),()=>s()?.toString()]),e.event("change",l,()=>f(s())),e.event("input",l,r=>t.dispatch("select",{index:h,value:s(),selected:r.currentTarget.checked})),e.event("keydown",l,r=>{r.key==="Enter"&&(f(s()),t.dispatch("select",{index:h,value:s(),selected:!t.props.value.includes(s())}))}),e.append(n,d)}),e.reset(G),e.append(a,w)},$$slots:{default:!0}}),e.pop()}export{ue as default};
