import{dh as ve,aY as $,m as r,C as Z,Q as ge,D as we,bW as Je,bX as Ke,di as qe,L as W,J as L,cb as ne,aQ as Qe,O as eo,U as me,f as R,E as oo,aa as V,ad as D,aF as pe,G as xe,H as to,P as F,a4 as ro,bc as io,cf as no,bg as ae,ce as ao,aS as Y,F as le,ab as P,bh as lo,dj as so,ay as uo,aP as co,ai as fo,a0 as Ce,Y as ho,e as se,dk as X,Z as ue,dl as vo}from"./index.3c4f55c3.js";import{u as go}from"./Suffix.a0cffb13.js";function wo(e,s,l,d){var a=-1,m=e==null?0:e.length;for(d&&m&&(l=e[++a]);++a",[L("image-container","position: fixed;")]),L("image-preview-container",` position: fixed; left: 0; right: 0; top: 0; bottom: 0; display: flex; `),L("image-preview-overlay",` z-index: -1; position: absolute; left: 0; right: 0; top: 0; bottom: 0; background: rgba(0, 0, 0, .3); `,[ne()]),L("image-preview-toolbar",` z-index: 1; position: absolute; left: 50%; transform: translateX(-50%); border-radius: var(--n-toolbar-border-radius); height: 48px; bottom: 40px; padding: 0 12px; background: var(--n-toolbar-color); box-shadow: var(--n-toolbar-box-shadow); color: var(--n-toolbar-icon-color); transition: color .3s var(--n-bezier); display: flex; align-items: center; `,[L("base-icon",` padding: 0 8px; font-size: 28px; cursor: pointer; `),ne()]),L("image-preview-wrapper",` position: absolute; left: 0; right: 0; top: 0; bottom: 0; display: flex; pointer-events: none; `,[Qe()]),L("image-preview",` user-select: none; -webkit-user-select: none; pointer-events: all; margin: auto; max-height: calc(100vh - 32px); max-width: calc(100vw - 32px); transition: transform .3s var(--n-bezier); `),L("image",` display: inline-flex; max-height: 100%; max-width: 100%; `,[eo("preview-disabled",` cursor: pointer; `),W("img",` border-radius: inherit; `)])]);const H=32;var De=Z({name:"ImagePreview",props:Object.assign(Object.assign({},G),{onNext:Function,onPrev:Function,clsPrefix:{type:String,required:!0}}),setup(e){const s=ge("Image","-image",pt,vt,e,me(e,"clsPrefix"));let l=null;const d=R(null),a=R(null),m=R(void 0),C=R(!1),g=R(!1),{localeRef:h}=go("Image");function n(){const{value:o}=a;if(!l||!o)return;const{style:i}=o,t=l.getBoundingClientRect(),c=t.left+t.width/2,f=t.top+t.height/2;i.transformOrigin=`${c}px ${f}px`}function u(o){var i,t;switch(o.key){case" ":o.preventDefault();break;case"ArrowLeft":(i=e.onPrev)===null||i===void 0||i.call(e);break;case"ArrowRight":(t=e.onNext)===null||t===void 0||t.call(e);break;case"Escape":te();break}}oo(C,o=>{o?V("keydown",document,u):D("keydown",document,u)}),pe(()=>{D("keydown",document,u)});let v=0,E=0,M=0,y=0,_=0,j=0,J=0,K=0,B=!1;function q(o){const{clientX:i,clientY:t}=o;M=i-v,y=t-E,co(S)}function $e(o){const{mouseUpClientX:i,mouseUpClientY:t,mouseDownClientX:c,mouseDownClientY:f}=o,x=c-i,b=f-t,O=`vertical${b>0?"Top":"Bottom"}`,I=`horizontal${x>0?"Left":"Right"}`;return{moveVerticalDirection:O,moveHorizontalDirection:I,deltaHorizontal:x,deltaVertical:b}}function Q(o){const{value:i}=d;if(!i)return{offsetX:0,offsetY:0};const t=i.getBoundingClientRect(),{moveVerticalDirection:c,moveHorizontalDirection:f,deltaHorizontal:x,deltaVertical:b}=o||{};let O=0,I=0;return t.width<=window.innerWidth?O=0:t.left>0?O=(t.width-window.innerWidth)/2:t.right0?I=(t.height-window.innerHeight)/2:t.bottom.5){const o=p;k-=1,p=Math.max(.5,Math.pow(N,k));const i=o-p;S(!1);const t=Q();p+=i,S(!1),p-=i,M=t.offsetX,y=t.offsetY,S()}}function S(o=!0){var i;const{value:t}=d;if(!t)return;const{style:c}=t,f=so((i=w==null?void 0:w.previewedImgPropsRef.value)===null||i===void 0?void 0:i.style);let x="";if(typeof f=="string")x=f+";";else for(const O in f)x+=`${lt(O)}: ${f[O]};`;const b=`transform-origin: center; transform: translateX(${M}px) translateY(${y}px) rotate(${z}deg) scale(${p});`;B?c.cssText=x+"cursor: grabbing; transition: none;"+b:c.cssText=x+"cursor: grab;"+b+(o?"":"transition: none;"),o||t.offsetHeight}function te(){C.value=!C.value,g.value=!0}function Xe(){p=oe(),k=Math.ceil(Math.log(p)/Math.log(N)),M=0,y=0,S()}const Fe={setPreviewSrc:o=>{m.value=o},setThumbnailEl:o=>{l=o},toggleShow:te};function Ge(o,i){if(e.showToolbarTooltip){const{value:t}=s;return r(uo,{to:!1,theme:t.peers.Tooltip,themeOverrides:t.peerOverrides.Tooltip,keepAliveOnHover:!1},{default:()=>h.value[i],trigger:()=>o})}else return o}const re=to(()=>{const{common:{cubicBezierEaseInOut:o},self:{toolbarIconColor:i,toolbarBorderRadius:t,toolbarBoxShadow:c,toolbarColor:f}}=s.value;return{"--n-bezier":o,"--n-toolbar-icon-color":i,"--n-toolbar-color":f,"--n-toolbar-border-radius":t,"--n-toolbar-box-shadow":c}}),{inlineThemeDisabled:ie}=F(),T=ie?ro("image-preview",void 0,re,e):void 0;return Object.assign({previewRef:d,previewWrapperRef:a,previewSrc:m,show:C,appear:io(),displayed:g,previewedImgProps:w==null?void 0:w.previewedImgPropsRef,handleWheel(o){o.preventDefault()},handlePreviewMousedown:Ze,handlePreviewDblclick:_e,syncTransformOrigin:n,handleAfterLeave:()=>{U(),z=0,g.value=!1},handleDragStart:o=>{var i,t;(t=(i=w==null?void 0:w.previewedImgPropsRef.value)===null||i===void 0?void 0:i.onDragstart)===null||t===void 0||t.call(i,o),o.preventDefault()},zoomIn:Ve,zoomOut:Ye,rotateCounterclockwise:Ne,rotateClockwise:Ue,handleSwitchPrev:je,handleSwitchNext:Be,withTooltip:Ge,resizeToOrignalImageSize:Xe,cssVars:ie?void 0:re,themeClass:T==null?void 0:T.themeClass,onRender:T==null?void 0:T.onRender},Fe)},render(){var e,s;const{clsPrefix:l}=this;return r(le,null,(s=(e=this.$slots).default)===null||s===void 0?void 0:s.call(e),r(no,{show:this.show},{default:()=>{var d;return this.show||this.displayed?((d=this.onRender)===null||d===void 0||d.call(this),ae(r("div",{class:[`${l}-image-preview-container`,this.themeClass],style:this.cssVars,onWheel:this.handleWheel},r(Y,{name:"fade-in-transition",appear:this.appear},{default:()=>this.show?r("div",{class:`${l}-image-preview-overlay`,onClick:this.toggleShow}):null}),this.showToolbar?r(Y,{name:"fade-in-transition",appear:this.appear},{default:()=>{if(!this.show)return null;const{withTooltip:a}=this;return r("div",{class:`${l}-image-preview-toolbar`},this.onPrev?r(le,null,a(r(P,{clsPrefix:l,onClick:this.handleSwitchPrev},{default:()=>gt}),"tipPrevious"),a(r(P,{clsPrefix:l,onClick:this.handleSwitchNext},{default:()=>wt}),"tipNext")):null,a(r(P,{clsPrefix:l,onClick:this.rotateCounterclockwise},{default:()=>r(ut,null)}),"tipCounterclockwise"),a(r(P,{clsPrefix:l,onClick:this.rotateClockwise},{default:()=>r(st,null)}),"tipClockwise"),a(r(P,{clsPrefix:l,onClick:this.resizeToOrignalImageSize},{default:()=>r(ft,null)}),"tipOriginalSize"),a(r(P,{clsPrefix:l,onClick:this.zoomOut},{default:()=>r(ct,null)}),"tipZoomOut"),a(r(P,{clsPrefix:l,onClick:this.zoomIn},{default:()=>r(dt,null)}),"tipZoomIn"),a(r(P,{clsPrefix:l,onClick:this.toggleShow},{default:()=>mt}),"tipClose"))}}):null,r(Y,{name:"fade-in-scale-up-transition",onAfterLeave:this.handleAfterLeave,appear:this.appear,onEnter:this.syncTransformOrigin,onBeforeLeave:this.syncTransformOrigin},{default:()=>{const{previewedImgProps:a={}}=this;return ae(r("div",{class:`${l}-image-preview-wrapper`,ref:"previewWrapperRef"},r("img",Object.assign({},a,{draggable:!1,onMousedown:this.handlePreviewMousedown,onDblclick:this.handlePreviewDblclick,class:[`${l}-image-preview`,a.class],key:this.previewSrc,src:this.previewSrc,ref:"previewRef",onDragstart:this.handleDragStart}))),[[lo,this.show]])}})),[[ao,{enabled:this.show}]])):null}}))}});const He=we("n-image-group"),xt=G;var Ot=Z({name:"ImageGroup",props:xt,setup(e){let s;const{mergedClsPrefixRef:l}=F(e),d=`c${fo()}`,a=ho(),m=h=>{var n;s=h,(n=g.value)===null||n===void 0||n.setPreviewSrc(h)};function C(h){if(!(a!=null&&a.proxy))return;const u=a.proxy.$el.parentElement.querySelectorAll(`[data-group-id=${d}]:not([data-error=true])`);if(!u.length)return;const v=Array.from(u).findIndex(E=>E.dataset.previewSrc===s);~v?m(u[(v+h+u.length)%u.length].dataset.previewSrc):m(u[0].dataset.previewSrc)}Ce(He,{mergedClsPrefixRef:l,setPreviewSrc:m,setThumbnailEl:h=>{var n;(n=g.value)===null||n===void 0||n.setThumbnailEl(h)},toggleShow:()=>{var h;(h=g.value)===null||h===void 0||h.toggleShow()},groupId:d});const g=R(null);return{mergedClsPrefix:l,previewInstRef:g,next:()=>C(1),prev:()=>C(-1)}},render(){return r(De,{theme:this.theme,themeOverrides:this.themeOverrides,clsPrefix:this.mergedClsPrefix,ref:"previewInstRef",onPrev:this.prev,onNext:this.next,showToolbar:this.showToolbar,showToolbarTooltip:this.showToolbarTooltip},this.$slots)}});const Ct=Object.assign({alt:String,height:[String,Number],imgProps:Object,previewedImgProps:Object,lazy:Boolean,intersectionObserverOptions:Object,objectFit:{type:String,default:"fill"},previewSrc:String,fallbackSrc:String,width:[String,Number],src:String,previewDisabled:Boolean,loadDescription:String,onError:Function,onLoad:Function},G);var Rt=Z({name:"Image",props:Ct,inheritAttrs:!1,setup(e){const s=R(null),l=R(!1),d=R(null),a=xe(He,null),{mergedClsPrefixRef:m}=a||F(e),C={click:()=>{if(e.previewDisabled||l.value)return;const n=e.previewSrc||e.src;if(a){a.setPreviewSrc(n),a.setThumbnailEl(s.value),a.toggleShow();return}const{value:u}=d;!u||(u.setPreviewSrc(n),u.setThumbnailEl(s.value),u.toggleShow())}},g=R(!e.lazy);se(()=>{var n;(n=s.value)===null||n===void 0||n.setAttribute("data-group-id",(a==null?void 0:a.groupId)||"")}),se(()=>{if(X)return;let n;const u=ue(()=>{n==null||n(),n=void 0,e.lazy&&(n=vo(s.value,e.intersectionObserverOptions,g))});pe(()=>{u(),n==null||n()})}),ue(()=>{var n;e.src,(n=e.imgProps)===null||n===void 0||n.src,l.value=!1});const h=R(!1);return Ce(Ee,{previewedImgPropsRef:me(e,"previewedImgProps")}),Object.assign({mergedClsPrefix:m,groupId:a==null?void 0:a.groupId,previewInstRef:d,imageRef:s,showError:l,shouldStartLoading:g,loaded:h,mergedOnClick:n=>{var u,v;C.click(),(v=(u=e.imgProps)===null||u===void 0?void 0:u.onClick)===null||v===void 0||v.call(u,n)},mergedOnError:n=>{if(!g.value)return;l.value=!0;const{onError:u,imgProps:{onError:v}={}}=e;u==null||u(n),v==null||v(n)},mergedOnLoad:n=>{const{onLoad:u,imgProps:{onLoad:v}={}}=e;u==null||u(n),v==null||v(n),h.value=!0}},C)},render(){var e,s;const{mergedClsPrefix:l,imgProps:d={},loaded:a,$attrs:m,lazy:C}=this,g=(s=(e=this.$slots).placeholder)===null||s===void 0?void 0:s.call(e),h=this.src||d.src||"",n=r("img",Object.assign(Object.assign({},d),{ref:"imageRef",width:this.width||d.width,height:this.height||d.height,src:X?h:this.showError?this.fallbackSrc:this.shouldStartLoading?h:void 0,alt:this.alt||d.alt,"aria-label":this.alt||d.alt,onClick:this.mergedOnClick,onError:this.mergedOnError,onLoad:this.mergedOnLoad,loading:X&&C&&!this.intersectionObserverOptions?"lazy":"eager",style:[d.style||"",g&&!a?{height:"0",width:"0",visibility:"hidden"}:"",{objectFit:this.objectFit}],"data-error":this.showError,"data-preview-src":this.previewSrc||this.src}));return r("div",Object.assign({},m,{role:"none",class:[m.class,`${l}-image`,(this.previewDisabled||this.showError)&&`${l}-image--preview-disabled`]}),this.groupId?n:r(De,{theme:this.theme,themeOverrides:this.themeOverrides,clsPrefix:l,ref:"previewInstRef",showToolbar:this.showToolbar,showToolbarTooltip:this.showToolbarTooltip},{default:()=>n}),!a&&g)}});export{Rt as N,Ot as a};