import{g as L,i as $,k as M,r as N,u as O,v as Z,b as Q,a as j,t as z}from"./i18n-eTakDDhg.js";import{R as U,y as ee,S,a6 as C,a as v,w as c,X as b,a5 as x,T as te,W as T,t as B,a0 as I,Z as g,V as f,a7 as ae,at as se,Y as _}from"./index-BkylzejB.js";import{s as le}from"./clone-IGppQJ7B.js";import{G as re}from"./utils.svelte-DZ62NrTu.js";import{B as oe}from"./Block-Bl_3z_UU.js";import{B as ie}from"./BlockTitle-BP9HXeKy.js";import"./ScrollFade.svelte_svelte_type_style_lang-De9nUaYy.js";import{I as ce}from"./IconButtonWrapper-33oacT7w.js";import{S as ne}from"./index-C-r_2iGV.js";import"./StreamingBar.svelte_svelte_type_style_lang-CFNH9sqm.js";import{d as pe}from"./index-tFQomdd2.js";import"./Info-ElNnmNxB.js";import"./html-DvOIMrhY.js";import"./snippet-CC9u6I34.js";import"./Clear-Daql2pLY.js";import"./index-B_pwUImq.js";var ue=T('<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>'),de=T('<label><input type="checkbox" class="svelte-yb2gcx"/> <span class="ml-2 svelte-yb2gcx"> </span></label>'),ve=T('<!> <!> <!> <div class="wrap svelte-yb2gcx" data-testid="checkbox-group"></div>',1);function Ge(F,A){U(A,!0);let H=N(A,["$$slots","$$events","$$legacy"]),e=new re(H);function G(l){e.props.value.includes(l)?e.props.value=e.props.value.filter(p=>p!==l):e.props.value=[...e.props.value,l],e.dispatch("input")}function P(){const l=e.props.choices.map(([,p])=>p);e.props.value.length===l.length?e.props.value=[]:e.props.value=l.slice(),e.dispatch("input")}let W=x(()=>{const l=e.props.choices.map(([,p])=>p);return e.props.value.length===0?"unchecked":e.props.value.length===l.length?"checked":"indeterminate"}),q=x(()=>!e.shared.interactive),D=e.props.value;ee(()=>{e.props.value,!pe(D,e.props.value)&&(D=e.props.value,e.dispatch("change",le(e.props.value)))}),oe(F,{get visible(){return e.shared.visible},get elem_id(){return e.shared.elem_id},get elem_classes(){return e.shared.elem_classes},type:"fieldset",get container(){return e.shared.container},get scale(){return e.shared.scale},get min_width(){return e.shared.min_width},children:(l,p)=>{var E=ve(),R=S(E);ne(R,L({get autoscroll(){return e.shared.autoscroll},get i18n(){return e.i18n}},()=>e.shared.loading_status,{on_clear_status:()=>e.dispatch("clear_status",e.shared.loading_status)}));var V=b(R,2);{var J=n=>{ce(n,{get buttons(){return e.props.buttons},on_custom_button_click:h=>{e.dispatch("custom_button_click",{id:h})}})};$(V,n=>{e.shared.show_label&&e.props.buttons&&e.props.buttons.length>0&&n(J)})}var X=b(V,2);{let n=x(()=>e.shared.show_label||e.props.show_select_all&&e.shared.interactive);ie(X,{get show_label(){return c(n)},get info(){return e.props.info},children:(h,k)=>{var m=C(),y=S(m);{var s=r=>{var t=ue(),o=f(t),i=f(o);z(i),_(o);var a=b(o,2),d=f(a,!0);_(a),_(t),B(()=>{Z(i,c(W)==="checked"),i.indeterminate=c(W)==="indeterminate",I(d,e.shared.show_label?e.shared.label:"Select All")}),g("change",i,P),g("click",a,P),v(r,t)},u=r=>{var t=C(),o=S(t);{var i=a=>{var d=ae();B(w=>I(d,w),[()=>e.shared.label||e.i18n("checkbox.checkbox_group")]),v(a,d)};$(o,a=>{e.shared.show_label&&a(i)},!0)}v(r,t)};$(y,r=>{e.props.show_select_all&&e.shared.interactive?r(s):r(u,!1)})}v(h,m)},$$slots:{default:!0}})}var Y=b(X,2);M(Y,21,()=>e.props.choices,O,(n,h,k)=>{var m=x(()=>se(c(h),2));let y=()=>c(m)[0],s=()=>c(m)[1];var u=de();let r;var t=f(u);z(t);var o=b(t,2),i=f(o,!0);_(o),_(u),B((a,d,w,K)=>{r=Q(u,1,"svelte-yb2gcx",null,r,a),t.disabled=c(q),Z(t,d),j(t,"name",w),j(t,"title",K),I(i,y())},[()=>({disabled:c(q),selected:e.props.value.includes(s())}),()=>e.props.value.includes(s()),()=>s()?.toString(),()=>s()?.toString()]),g("change",t,()=>G(s())),g("input",t,a=>e.dispatch("select",{index:k,value:s(),selected:a.currentTarget.checked})),g("keydown",t,a=>{a.key==="Enter"&&(G(s()),e.dispatch("select",{index:k,value:s(),selected:!e.props.value.includes(s())}))}),v(n,u)}),_(Y),v(l,E)},$$slots:{default:!0}}),te()}export{Ge as default};
