import{g as ae,i as x,r as re,k as X,a as z,b as Y,f as Z,u as j,d as se}from"./i18n-Dnhn5Rxr.js";import{R as oe,S as B,w as t,a as d,x as $,X as _,T as le,u as q,a5 as A,W as h,V as I,a6 as ie,t as y,Y as k,a0 as ne,Z as g}from"./index-DWyDLubb.js";import{B as pe}from"./Block-J4oodUWp.js";import"./ScrollFade.svelte_svelte_type_style_lang-DPHOQHBm.js";import{B as ue}from"./BlockLabel-CZd21Hkw.js";import{E as de}from"./Empty-BIB2W5at.js";import{I as C}from"./Image-DrPceByI.js";import{G as ce}from"./utils.svelte-CCyS_0CY.js";import{I as me}from"./IconButtonWrapper-D0s9l4wW.js";import{F as ve}from"./FullscreenButton-sCrcy_OJ.js";import{S as _e}from"./index-CglBvmLb.js";import"./StreamingBar.svelte_svelte_type_style_lang-Y9omZ2gK.js";import"./snippet-BWgYNF9D.js";import"./clone-BkeCM4Nl.js";import"./Maximize-QH9NIRWs.js";import"./Clear-BF6j078A.js";import"./html-Ih_5QVTo.js";import"./index-B_pwUImq.js";var ge=h("<img/>"),he=h('<button class="legend-item svelte-1oizopk"> </button>'),fe=h('<div class="legend svelte-1oizopk"></div>'),be=h('<div class="image-container svelte-1oizopk"><!> <img alt="the base file that is annotated"/> <!></div> <!>',1),$e=h('<!> <!> <div class="container svelte-1oizopk"><!></div>',1);function Xe(D,P){oe(P,!0);const H=re(P,["$$slots","$$events","$$legacy"]),e=new ce(H);let c=q(null),S,n=q(!1),J=A(()=>e.shared.label||e.i18n("annotated_image.annotated_image"));e.watch_for_change();function E(l){$(c,l,!0)}function F(){$(c,null)}function K(l,G){e.dispatch("select",{value:G,index:l})}pe(D,{get visible(){return e.shared.visible},get elem_id(){return e.shared.elem_id},get elem_classes(){return e.shared.elem_classes},padding:!1,get height(){return e.props.height},get width(){return e.props.width},allow_overflow:!1,get container(){return e.shared.container},get scale(){return e.shared.scale},get min_width(){return e.shared.min_width},get fullscreen(){return t(n)},set fullscreen(l){$(n,l,!0)},children:(l,G)=>{var M=$e(),W=B(M);_e(W,ae({get autoscroll(){return e.shared.autoscroll},get i18n(){return e.i18n}},()=>e.shared.loading_status));var L=_(W,2);ue(L,{get show_label(){return e.shared.show_label},get Icon(){return C},get label(){return t(J)}});var R=_(L,2),N=I(R);{var O=p=>{de(p,{size:"large",unpadded_box:!0,children:(f,m)=>{C(f)},$$slots:{default:!0}})},Q=p=>{var f=be(),m=B(f),T=I(m);{let o=A(()=>e.props.buttons||[]);me(T,{get buttons(){return t(o)},on_custom_button_click:s=>{e.dispatch("custom_button_click",{id:s})},children:(s,b)=>{var a=ie(),i=B(a);{var r=v=>{ve(v,{get fullscreen(){return t(n)},$$events:{fullscreen:({detail:u})=>{$(n,u,!0)}}})};x(i,v=>{(e.props.buttons||[]).some(u=>typeof u=="string"&&u==="fullscreen")&&v(r)})}d(s,a)},$$slots:{default:!0}})}var w=_(T,2);let V;var U=_(w,2);X(U,17,()=>e.props.value?e.props.value.annotations:[],j,(o,s,b)=>{var a=ge();let i;y(r=>{z(a,"alt",`segmentation mask identifying ${e.shared.label??""} within the uploaded file`),i=Y(a,1,"mask fit-height svelte-1oizopk",null,i,{"fit-height":!t(n),active:t(c)==t(s).label,inactive:t(c)!=t(s).label&&t(c)!=null}),z(a,"src",t(s).image.url),Z(a,r)},[()=>e.props.color_map&&t(s).label in e.props.color_map?null:`filter: hue-rotate(${Math.round(b*360/(e.props.value?.annotations.length??1))}deg);`]),d(o,a)}),k(m),se(m,o=>S=o,()=>S);var ee=_(m,2);{var te=o=>{var s=fe();X(s,21,()=>e.props.value.annotations,j,(b,a,i)=>{var r=he(),v=I(r,!0);k(r),y(u=>{Z(r,`background-color: ${u??""}`),ne(v,t(a).label)},[()=>e.props.color_map&&t(a).label in e.props.color_map?e.props.color_map[t(a).label]+"88":`hsla(${Math.round(i*360/e.props.value.annotations.length)}, 100%, 50%, 0.3)`]),g("mouseover",r,()=>E(t(a).label)),g("focus",r,()=>E(t(a).label)),g("mouseout",r,()=>F()),g("blur",r,()=>F()),g("click",r,()=>K(i,t(a).label)),d(b,r)}),k(s),d(o,s)};x(ee,o=>{e.props.show_legend&&e.props.value&&o(te)})}y(()=>{V=Y(w,1,"base-image svelte-1oizopk",null,V,{"fit-height":e.props.height&&!t(n)}),z(w,"src",e.props.value?e.props.value.image.url:null)}),d(p,f)};x(N,p=>{e.props.value==null?p(O):p(Q,!1)})}k(R),d(l,M)},$$slots:{default:!0}}),le()}export{Xe as default};
