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"./svelte/svelte_internal_flags_legacy.js";import{createEventDispatcher as W}from"./svelte/svelte_svelte.js";import{B as q,c as z,b as A,L as I,E as F}from"./IconButtonWrapper-Cljb5D-5.js";import{S as H}from"./StreamingBar-b2qVLPYU.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 J=e.from_html('<h2 data-testid="label-output-value"> </h2>'),K=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>'),N=e.from_html('<div class="container svelte-g2cwl3"><!> <!></div>');function O(w,i){e.push(i,!1);let s=e.prop(i,"value",12);const t=W();let d=e.prop(i,"color",12,void 0),u=e.prop(i,"selectable",12,!1),c=e.prop(i,"show_heading",12,!0);function k(a){return a.replace(/\s/g,"-")}var b={get value(){return s()},set value(a){s(a),e.flush()},get color(){return d()},set color(a){d(a),e.flush()},get selectable(){return u()},set selectable(a){u(a),e.flush()},get show_heading(){return c()},set show_heading(a){c(a),e.flush()}};e.init();var p=N(),h=e.child(p);{var x=a=>{var o=J();let g,l;var r=e.child(o,!0);e.reset(o),e.template_effect(()=>{g=e.set_class(o,1,"output-class svelte-g2cwl3",null,g,{"no-confidence":!("confidences"in s())}),l=e.set_style(o,"",l,{"background-color":d()||"transparent"}),e.set_text(r,(e.deep_read_state(s()),e.untrack(()=>s().label)))}),e.append(a,o)};e.if(h,a=>{e.deep_read_state(c()),e.deep_read_state(s()),e.untrack(()=>c()||!s().confidences)&&a(x)})}var _=e.sibling(h,2);{var $=a=>{var o=e.comment(),g=e.first_child(o);e.each(g,1,()=>(e.deep_read_state(s()),e.untrack(()=>s().confidences)),e.index,(l,r,m)=>{var n=K();let y;var B=e.child(n),v=e.child(B),L=e.sibling(v,2),f=e.child(L),G=e.child(f,!0);e.reset(f);var E=e.sibling(f,4),M=e.child(E);e.reset(E),e.reset(L),e.reset(B),e.reset(n),e.template_effect((P,S,j,C)=>{y=e.set_class(n,1,"confidence-set group svelte-g2cwl3",null,y,{selectable:u()}),e.set_attribute(n,"data-testid",(e.get(r),e.untrack(()=>`${e.get(r).label}-confidence-set`))),e.set_attribute(v,"aria-labelledby",P),e.set_attribute(v,"aria-label",(e.get(r),e.untrack(()=>e.get(r).label))),e.set_attribute(v,"aria-valuenow",S),e.set_value(v,(e.get(r),e.untrack(()=>e.get(r).confidence))),e.set_style(v,`width: ${e.get(r),e.untrack(()=>e.get(r).confidence*100)??""}%; background: var(--stat-background-fill);
						`),e.set_attribute(f,"id",j),e.set_text(G,(e.get(r),e.untrack(()=>e.get(r).label))),e.set_text(M,`${C??""}%`)},[()=>(e.get(r),e.untrack(()=>k(`meter-text-${e.get(r).label}`))),()=>(e.get(r),e.untrack(()=>Math.round(e.get(r).confidence*100))),()=>(e.get(r),e.untrack(()=>k(`meter-text-${e.get(r).label}`))),()=>(e.get(r),e.untrack(()=>Math.round(e.get(r).confidence*100)))]),e.event("click",n,()=>{t("select",{index:m,value:e.get(r).label})}),e.append(l,n)}),e.append(a,o)};e.if(_,a=>{e.deep_read_state(s()),e.untrack(()=>typeof s()=="object"&&s().confidences)&&a($)})}return e.reset(p),e.append(w,p),e.pop(b)}var Q=e.from_html("<!> <!> <!> <!>",1);function be(w,i){e.push(i,!0);const s=e.rest_props(i,["$$slots","$$events","$$legacy"]),t=new D(s);let d=e.state(e.proxy(t.props.value)),u=e.derived(()=>t.props.value.label);e.user_effect(()=>{e.get(d)!=t.props.value&&(e.set(d,t.props.value,!0),t.dispatch("change"))}),q(w,{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:(c,k)=>{var b=Q(),p=e.first_child(b);H(p,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 h=e.sibling(p,2);{var x=l=>{z(l,{get buttons(){return t.props.buttons},on_custom_button_click:r=>{t.dispatch("custom_button_click",{id:r})}})};e.if(h,l=>{t.shared.show_label&&t.props.buttons&&t.props.buttons.length>0&&l(x)})}var _=e.sibling(h,2);{var $=l=>{{let r=e.derived(()=>t.shared.label||t.i18n("label.label")),m=e.derived(()=>t.shared.container===!1),n=e.derived(()=>t.props.show_heading===!0);A(l,{get Icon(){return I},get label(){return e.get(r)},get disable(){return e.get(m)},get float(){return e.get(n)}})}};e.if(_,l=>{t.shared.show_label&&l($)})}var a=e.sibling(_,2);{var o=l=>{O(l,{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},$$events:{select:({detail:r})=>t.dispatch("select",r)}})},g=l=>{F(l,{unpadded_box:!0,children:(r,m)=>{I(r)},$$slots:{default:!0}})};e.if(a,l=>{e.get(u)!==void 0&&e.get(u)!==null?l(o):l(g,!1)})}e.append(c,b)},$$slots:{default:!0}}),e.pop()}export{O as BaseLabel,be as default};
