import"./svelte/svelte_internal_flags_async.js";import*as e from"./svelte/svelte_internal_client.js";import"./i18n-CqG9A4Dp.js";import{G as j}from"./utils.svelte-kG009vb9.js";import{B as C,e as W,d as q,L,E as z}from"./ScrollFade-DGw40oqj.js";import"./svelte/svelte_internal_flags_legacy.js";import"./svelte/svelte_svelte.js";import{S as A}from"./StreamingBar-Hli-vaRZ.js";import"./svelte/svelte_store.js";import"./index-aMLoRFR_.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-VTUoaX6K.js";import"./prism-python-BRxZ6l4O.js";var D=e.from_html('<h2 data-testid="label-output-value"> </h2>'),F=e.from_html('<button><div class="inner-wrap svelte-g2cwl3"><meter aria-valuemin="0" aria-valuemax="100" class="bar svelte-g2cwl3" min="0" max="1"></meter> <dl class="label svelte-g2cwl3"><dt class="text svelte-g2cwl3"> </dt> <div class="line svelte-g2cwl3"></div> <dd class="confidence svelte-g2cwl3"> </dd></dl></div></button>'),H=e.from_html('<div class="container svelte-g2cwl3"><!> <!></div>');function J(f,l){e.push(l,!0);let w=e.prop(l,"color",3,void 0),t=e.prop(l,"selectable",3,!1),g=e.prop(l,"show_heading",3,!0);function u(s){return s.replace(/\s/g,"-")}var p=H(),x=e.child(p);{var _=s=>{var i=D();let d,c;var r=e.child(i,!0);e.reset(i),e.template_effect(()=>{d=e.set_class(i,1,"output-class svelte-g2cwl3",null,d,{"no-confidence":!("confidences"in l.value)}),c=e.set_style(i,"",c,{"background-color":w()||"transparent"}),e.set_text(r,l.value.label)}),e.append(s,i)};e.if(x,s=>{(g()||!l.value.confidences)&&s(_)})}var m=e.sibling(x,2);{var b=s=>{var i=e.comment(),d=e.first_child(i);e.each(d,17,()=>l.value.confidences,e.index,(c,r,k)=>{var a=F();let o;a.__click=()=>{l.onselect?.({index:k,value:e.get(r).label})};var v=e.child(a),n=e.child(v),y=e.sibling(n,2),h=e.child(y),I=e.child(h,!0);e.reset(h);var B=e.sibling(h,4),E=e.child(B);e.reset(B),e.reset(y),e.reset(v),e.reset(a),e.template_effect((G,M,P,S)=>{o=e.set_class(a,1,"confidence-set group svelte-g2cwl3",null,o,{selectable:t()}),e.set_attribute(a,"data-testid",`${e.get(r).label}-confidence-set`),e.set_attribute(n,"aria-labelledby",G),e.set_attribute(n,"aria-label",e.get(r).label),e.set_attribute(n,"aria-valuenow",M),e.set_value(n,e.get(r).confidence),e.set_style(n,`width: ${e.get(r).confidence*100}%; background: var(--stat-background-fill);
						`),e.set_attribute(h,"id",P),e.set_text(I,e.get(r).label),e.set_text(E,`${S??""}%`)},[()=>u(`meter-text-${e.get(r).label}`),()=>Math.round(e.get(r).confidence*100),()=>u(`meter-text-${e.get(r).label}`),()=>Math.round(e.get(r).confidence*100)]),e.append(c,a)}),e.append(s,i)};e.if(m,s=>{typeof l.value=="object"&&l.value.confidences&&s(b)})}e.reset(p),e.append(f,p),e.pop()}e.delegate(["click"]);var K=e.from_html("<!> <!> <!> <!>",1);function pe(f,l){e.push(l,!0);const w=e.rest_props(l,["$$slots","$$events","$$legacy"]),t=new j(w);let g=e.state(e.proxy(t.props.value)),u=e.derived(()=>t.props.value.label);e.user_effect(()=>{e.get(g)!=t.props.value&&(e.set(g,t.props.value,!0),t.dispatch("change"))}),C(f,{test_id:"label",get visible(){return t.shared.visible},get elem_id(){return t.shared.elem_id},get elem_classes(){return t.shared.elem_classes},get container(){return t.shared.container},get scale(){return t.shared.scale},get min_width(){return t.shared.min_width},padding:!1,children:(p,x)=>{var _=K(),m=e.first_child(_);A(m,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(m,2);{var s=a=>{W(a,{get buttons(){return t.props.buttons},on_custom_button_click:o=>{t.dispatch("custom_button_click",{id:o})}})};e.if(b,a=>{t.shared.show_label&&t.props.buttons&&t.props.buttons.length>0&&a(s)})}var i=e.sibling(b,2);{var d=a=>{{let o=e.derived(()=>t.shared.label||t.i18n("label.label")),v=e.derived(()=>t.shared.container===!1),n=e.derived(()=>t.props.show_heading===!0);q(a,{get Icon(){return L},get label(){return e.get(o)},get disable(){return e.get(v)},get float(){return e.get(n)}})}};e.if(i,a=>{t.shared.show_label&&a(d)})}var c=e.sibling(i,2);{var r=a=>{J(a,{onselect:o=>t.dispatch("select",o),get selectable(){return t.props._selectable},get value(){return t.props.value},get color(){return t.props.color},get show_heading(){return t.props.show_heading}})},k=a=>{z(a,{unpadded_box:!0,children:(o,v)=>{L(o)},$$slots:{default:!0}})};e.if(c,a=>{e.get(u)!==void 0&&e.get(u)!==null?a(r):a(k,!1)})}e.append(p,_)},$$slots:{default:!0}}),e.pop()}export{J as BaseLabel,pe as default};
