import{p as i,e as te,i as p,d as re,b as ae}from"./i18n-Dnhn5Rxr.js";import{R as le,a4 as ne,S as L,w,a as B,T as oe,U as c,ad as P,G as s,z as g,X as k,W,V as D,Y as M,x as se,t as ue,Z as ie,a3 as ce}from"./index-DWyDLubb.js";import{b as T}from"./misc-vsnLZ-Y1.js";import{u as _e}from"./utils.svelte-CCyS_0CY.js";import{I as de}from"./ScrollFade.svelte_svelte_type_style_lang-DPHOQHBm.js";import{B as ge}from"./BlockLabel-CZd21Hkw.js";import{D as me}from"./DownloadLink-TGTaev7f.js";import{E as fe}from"./Empty-BIB2W5at.js";import{S as be}from"./ShareButton-wCSP7LoP.js";import{D as he}from"./Download-Di2PsS6O.js";import{I as O}from"./Image-DrPceByI.js";import{I as ve}from"./IconButtonWrapper-D0s9l4wW.js";import{F as pe}from"./FullscreenButton-sCrcy_OJ.js";import{I as we}from"./Image-CeW7PJs4.js";/* empty css                                                   */const ke=m=>{let t;if(m.currentTarget instanceof Element)t=m.currentTarget.querySelector("img");else return[NaN,NaN];const r=t.getBoundingClientRect(),_=t.naturalWidth/r.width,u=t.naturalHeight/r.height;if(_>u){const b=t.naturalHeight/_,n=(r.height-b)/2;var l=Math.round((m.clientX-r.left)*_),f=Math.round((m.clientY-r.top-n)*_)}else{const b=t.naturalWidth/u,n=(r.width-b)/2;var l=Math.round((m.clientX-r.left-n)*u),f=Math.round((m.clientY-r.top)*u)}return l<0||l>=t.naturalWidth||f<0||f>=t.naturalHeight?null:[l,f]};var ye=W("<!> <!> <!>",1),Ie=W('<div class="image-container svelte-12vrxzd"><!> <button class="svelte-12vrxzd"><div><!></div></button></div>'),xe=W("<!> <!>",1);function Se(m,t){le(t,!1);let r=i(t,"value",12),_=i(t,"label",12,void 0),u=i(t,"show_label",12),l=i(t,"buttons",28,()=>[]),f=i(t,"on_custom_button_click",12,null),b=i(t,"selectable",12,!1),n=i(t,"i18n",12),y=i(t,"display_icon_button_wrapper_top_corner",12,!1),v=i(t,"fullscreen",12,!1),I=i(t,"show_button_background",12,!0);const E=ne(),C=e=>{let d=ke(e);d&&E("select",{index:d,value:null})};let H=ce();var G={get value(){return r()},set value(e){r(e),c()},get label(){return _()},set label(e){_(e),c()},get show_label(){return u()},set show_label(e){u(e),c()},get buttons(){return l()},set buttons(e){l(e),c()},get on_custom_button_click(){return f()},set on_custom_button_click(e){f(e),c()},get selectable(){return b()},set selectable(e){b(e),c()},get i18n(){return n()},set i18n(e){n(e),c()},get display_icon_button_wrapper_top_corner(){return y()},set display_icon_button_wrapper_top_corner(e){y(e),c()},get fullscreen(){return v()},set fullscreen(e){v(e),c()},get show_button_background(){return I()},set show_button_background(e){I(e),c()}};te();var N=xe(),F=L(N);{let e=P(()=>(s(u()),s(_()),s(n()),g(()=>u()?_()||n()("image.image"):"")));ge(F,{get show_label(){return u()},get Icon(){return O},get label(){return w(e)}})}var U=k(F,2);{var V=e=>{fe(e,{unpadded_box:!0,size:"large",children:(d,x)=>{O(d)},$$slots:{default:!0}})},Z=e=>{var d=Ie(),x=D(d);ve(x,{get display_top_corner(){return y()},get show_background(){return I()},get buttons(){return l()},get on_custom_button_click(){return f()},children:(h,ze)=>{var X=ye(),Y=L(X);{var J=o=>{pe(o,{get fullscreen(){return v()},onclick:a=>{v(a),E("fullscreen",a)}})};p(Y,o=>{s(l()),g(()=>l().some(a=>typeof a=="string"&&a==="fullscreen"))&&o(J)})}var j=k(Y,2);{var K=o=>{{let a=P(()=>(s(r()),g(()=>r().orig_name||"image")));me(o,{get href(){return s(r()),g(()=>r().url)},get download(){return w(a)},children:(q,Be)=>{{let ee=P(()=>(s(n()),g(()=>n()("common.download"))));de(q,{get Icon(){return he},get label(){return w(ee)}})}},$$slots:{default:!0}})}};p(j,o=>{s(l()),g(()=>l().some(a=>typeof a=="string"&&a==="download"))&&o(K)})}var Q=k(j,2);{var $=o=>{be(o,{get i18n(){return n()},formatter:async a=>a?`<img src="${await _e(a)}" />`:"",get value(){return r()},$$events:{share(a){T.call(this,t,a)},error(a){T.call(this,t,a)}}})};p(Q,o=>{s(l()),g(()=>l().some(a=>typeof a=="string"&&a==="share"))&&o($)})}B(h,X)},$$slots:{default:!0}});var S=k(x,2),z=D(S);let R;var A=D(z);we(A,{get src(){return s(r()),g(()=>r().url)},restProps:{loading:"lazy",alt:""},$$events:{load(h){T.call(this,t,h)}}}),M(z),M(S),M(d),re(d,h=>se(H,h),()=>w(H)),ue(()=>R=ae(z,1,"image-frame svelte-12vrxzd",null,R,{selectable:b()})),ie("click",S,C),B(e,d)};p(U,e=>{s(r()),g(()=>r()==null||!r()?.url)?e(V):e(Z,!1)})}return B(m,N),oe(G)}const Oe=Object.freeze(Object.defineProperty({__proto__:null,default:Se},Symbol.toStringTag,{value:"Module"}));export{Se as I,Oe as a,ke as g};
