@starlly-labs/photo-viewer
Advanced tools
Comparing version 1.0.6 to 1.0.7
@@ -12,4 +12,5 @@ import React from 'react'; | ||
index: number; | ||
fullScreen: boolean; | ||
}; | ||
export default function PhotoProvider({ children, onIndexChange, onVisibleChange, sidebarLeftRender, sidebarRightRender, sidebarWidth, ...restProps }: PhotoProviderProps): React.JSX.Element; | ||
export {}; |
@@ -7,3 +7,5 @@ import React from 'react'; | ||
index?: number; | ||
fullScreen: boolean; | ||
onIndexChange?: (index: number) => void; | ||
onFullScreen: (status: boolean) => void; | ||
visible: boolean; | ||
@@ -10,0 +12,0 @@ onClose: (evt?: React.MouseEvent | React.TouchEvent) => void; |
@@ -1,2 +0,2 @@ | ||
var e=require("react"),t=require("react-dom");function n(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var r=/*#__PURE__*/n(e);function i(){return i=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)({}).hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},i.apply(null,arguments)}function o(e,t){if(null==e)return{};var n={};for(var r in e)if({}.hasOwnProperty.call(e,r)){if(t.includes(r))continue;n[r]=e[r]}return n}function a(t){var n=e.useRef({fn:t,curr:void 0}).current;if(n.fn=t,!n.curr){var r=Object.create(null);Object.keys(t).forEach(function(e){r[e]=function(){var t;return(t=n.fn[e]).call.apply(t,[n.fn].concat([].slice.call(arguments)))}}),n.curr=r}return n.curr}function u(t){return e.useReducer(function(e,t){return i({},e,"function"==typeof t?t(e):t)},t)}var l=e.createContext(void 0),c="cubic-bezier(0.25, 0.8, 0.25, 1)",d=20,s="undefined"!=typeof window&&"ontouchstart"in window,f=function(e,t,n){return Math.max(Math.min(e,n),t)},h=function(e,t,n){return void 0===t&&(t=0),void 0===n&&(n=0),f(e,1*(1-n),Math.max(6,t)*(1+n))},v="undefined"==typeof window||/ServerSideRendering/.test(navigator&&navigator.userAgent)?e.useEffect:e.useLayoutEffect;function m(t,n,r){var i=e.useRef(n);i.current=n,e.useEffect(function(){function e(e){i.current(e)}return t&&window.addEventListener(t,e,r),function(){t&&window.removeEventListener(t,e)}},[t])}var g=["container"];function p(e){var n=e.container,a=void 0===n?document.body:n,u=o(e,g);return t.createPortal(r.default.createElement("div",i({},u)),a)}function w(e){return r.default.createElement("svg",i({width:"44",height:"44",viewBox:"0 0 768 768"},e),r.default.createElement("path",{d:"M640.5 352.5v63h-390l178.5 180-45 45-256.5-256.5 256.5-256.5 45 45-178.5 180h390z"}))}function b(e){return r.default.createElement("svg",i({width:"44",height:"44",viewBox:"0 0 768 768"},e),r.default.createElement("path",{d:"M384 127.5l256.5 256.5-256.5 256.5-45-45 178.5-180h-390v-63h390l-178.5-180z"}))}function y(){return e.useEffect(function(){var e=document.body.style,t=e.overflow;return e.overflow="hidden",function(){e.overflow=t}},[]),null}function E(e){return r.default.createElement("svg",i({width:"44",height:"44",viewBox:"0 0 768 768"},e),r.default.createElement("path",{d:"M607.5 205.5l-178.5 178.5 178.5 178.5-45 45-178.5-178.5-178.5 178.5-45-45 178.5-178.5-178.5-178.5 45-45 178.5 178.5 178.5-178.5z"}))}function x(e){var t=e.toolbarRender,n=e.overlayParams,i=e.toolbarLeftRender,o=e.toolbarRightRender;return r.default.createElement(r.default.Fragment,null,e.bannerVisible&&r.default.createElement("div",{className:"PhotoView-Slider__BannerWrap"},r.default.createElement("div",{className:"PhotoView-Slider__Counter"},e.index+1," / ",e.imageLength),r.default.createElement("div",{className:"PhotoView-Slider__BannerRight"},t&&n&&t(n),r.default.createElement(E,{className:"PhotoView-Slider__toolbarIcon",onClick:close}))),i&&n&&r.default.createElement("div",{className:"PhotoView-Slider__Toolbar PhotoView-Slider__Toolbar--Left"},i(n)),o&&n&&r.default.createElement("div",{className:"PhotoView-Slider__Toolbar PhotoView-Slider__Toolbar--Right"},o(n)))}function C(e){var t=e.touches[0],n=t.clientX,r=t.clientY;if(e.touches.length>=2){var i=e.touches[1],o=i.clientX,a=i.clientY;return[(n+o)/2,(r+a)/2,Math.sqrt(Math.pow(o-n,2)+Math.pow(a-r,2))]}return[n,r,0]}var R=function(e,t,n,r){var i,o=n*t,a=(o-r)/2,u=e;return o<=r?(i=1,u=0):e>0&&a-e<=0?(i=2,u=a):e<0&&a+e<=0&&(i=3,u=-a),[i,u]};function P(e,t,n,r,i,o,a,u,l,c){void 0===a&&(a=innerWidth/2),void 0===u&&(u=innerHeight/2),void 0===l&&(l=0),void 0===c&&(c=0);var d=R(e,o,n,innerWidth)[0],s=R(t,o,r,innerHeight),f=innerWidth/2,h=innerHeight/2;return{x:a-o/i*(a-(f+e))-f+(r/n>=3&&n*o===innerWidth?0:d?l/2:l),y:u-o/i*(u-(h+t))-h+(s[0]?c/2:c),lastCX:a,lastCY:u}}function _(e,t,n){var r=e%180!=0;return r?[n,t,r]:[t,n,r]}function k(e,t,n){var r=_(n,innerWidth,innerHeight),i=r[0],o=r[1],a=0,u=i,l=o,c=e/t*o,d=t/e*i;return e<i&&t<o?(u=e,l=t):e<i&&t>=o?u=c:e>=i&&t<o||e/t>i/o?l=d:t/e>=3&&!r[2]?a=((l=d)-o)/2:u=c,{width:u,height:l,x:0,y:a,pause:!0}}function S(t,n){var r=n.leading,i=void 0!==r&&r,o=n.maxWait,a=n.wait,u=void 0===a?o||0:a,l=e.useRef(t);l.current=t;var c=e.useRef(0),d=e.useRef(),s=function(){return d.current&&clearTimeout(d.current)},f=e.useCallback(function(){var e=[].slice.call(arguments),t=Date.now();function n(){c.current=t,s(),l.current.apply(null,e)}var r=c.current,a=t-r;if(0===r&&(i&&n(),c.current=t),void 0!==o){if(a>o)return void n()}else a<u&&(c.current=t);s(),d.current=setTimeout(function(){n(),c.current=0},u)},[u,o,i]);return f.cancel=s,f}var M=function(e,t,n){return W(e,t,n,100,function(e){return e},function(){return W(t,e,n)})},V=function(e){return 1-Math.pow(1-e,4)};function W(e,t,n,r,i,o){void 0===r&&(r=400),void 0===i&&(i=V);var a=t-e;if(0!==a){var u=Date.now(),l=0,c=function(){var t=Math.min(1,(Date.now()-u)/r);n(e+i(t)*a)&&t<1?d():(cancelAnimationFrame(l),t>=1&&o&&o())};d()}function d(){l=requestAnimationFrame(c)}}var N={T:0,L:0,W:0,H:0,FIT:void 0},Y=function(){var t=e.useRef(!1);return e.useEffect(function(){return t.current=!0,function(){t.current=!1}},[]),t},X=["className"];function T(e){var t=e.className,n=void 0===t?"":t,a=o(e,X);return r.default.createElement("div",i({className:"PhotoView__Spinner "+n},a),r.default.createElement("svg",{viewBox:"0 0 32 32",width:"36",height:"36",fill:"white"},r.default.createElement("path",{opacity:".25",d:"M16 0 A16 16 0 0 0 16 32 A16 16 0 0 0 16 0 M16 4 A12 12 0 0 1 16 28 A12 12 0 0 1 16 4"}),r.default.createElement("path",{d:"M16 0 A16 16 0 0 1 32 16 L28 16 A12 12 0 0 0 16 4z"})))}var L=["src","loaded","broken","className","onPhotoLoad","loadingElement","brokenElement"];function I(e){var t=e.src,n=e.loaded,a=e.broken,u=e.className,l=e.onPhotoLoad,c=e.loadingElement,d=e.brokenElement,s=o(e,L),f=Y();return t&&!a?r.default.createElement(r.default.Fragment,null,r.default.createElement("img",i({className:"PhotoView__Photo"+(u?" "+u:""),src:t,onLoad:function(e){var t=e.target;f.current&&l({loaded:!0,naturalWidth:t.naturalWidth,naturalHeight:t.naturalHeight})},onError:function(){f.current&&l({broken:!0})},alt:""},s)),!n&&(r.default.createElement("span",{className:"PhotoView__icon"},c)||r.default.createElement(T,{className:"PhotoView__icon"}))):d?r.default.createElement("span",{className:"PhotoView__icon"},"function"==typeof d?d({src:t}):d):null}var A={naturalWidth:void 0,naturalHeight:void 0,width:void 0,height:void 0,loaded:void 0,broken:!1,x:0,y:0,touched:!1,maskTouched:!1,rotate:0,scale:1,CX:0,CY:0,lastX:0,lastY:0,lastCX:0,lastCY:0,lastScale:1,touchTime:0,touchLength:0,pause:!0,stopRaf:!0,reach:void 0};function D(t){var n=t.item,o=n.src,l=n.render,c=n.width,d=void 0===c?0:c,f=n.height,g=void 0===f?0:f,p=n.originRef,w=t.visible,b=t.speed,y=t.easing,E=t.wrapClassName,x=t.className,V=t.style,X=t.loadingElement,T=t.brokenElement,L=t.onPhotoTap,D=t.onMaskTap,F=t.onReachMove,H=t.onReachUp,O=t.onPhotoResize,B=t.isActive,j=t.expose,q=u(A),z=q[0],K=q[1],U=e.useRef(0),G=Y(),J=z.naturalWidth,Q=void 0===J?d:J,Z=z.naturalHeight,$=void 0===Z?g:Z,ee=z.width,te=void 0===ee?d:ee,ne=z.height,re=void 0===ne?g:ne,ie=z.loaded,oe=void 0===ie?!o:ie,ae=z.broken,ue=z.x,le=z.y,ce=z.touched,de=z.stopRaf,se=z.maskTouched,fe=z.rotate,he=z.scale,ve=z.CX,me=z.CY,ge=z.lastX,pe=z.lastY,we=z.lastCX,be=z.lastCY,ye=z.lastScale,Ee=z.touchTime,xe=z.touchLength,Ce=z.pause,Re=z.reach,Pe=a({onScale:function(e){return _e(h(e))},onRotate:function(e){fe!==e&&(j({rotate:e}),K(i({rotate:e},k(Q,$,e))))}});function _e(e,t,n){he!==e&&(j({scale:e}),K(i({scale:e},P(ue,le,te,re,he,e,t,n),e<=1&&{x:0,y:0})))}var ke=S(function(e,t,n){if(void 0===n&&(n=0),(ce||se)&&B){var r=_(fe,te,re),o=r[0],a=r[1];if(0===n&&0===U.current){var u=Math.abs(e-ve)<=20,l=Math.abs(t-me)<=20;if(u&&l)return void K({lastCX:e,lastCY:t});U.current=u?t>me?3:2:1}var c,d=e-we,s=t-be;if(0===n){var f=R(d+ge,he,o,innerWidth)[0],v=R(s+pe,he,a,innerHeight);c=function(e,t,n,r){return t&&1===e||"x"===r?"x":n&&e>1||"y"===r?"y":void 0}(U.current,f,v[0],Re),void 0!==c&&F(c,e,t,he)}if("x"===c||se)return void K({reach:"x"});var m=h(he+(n-xe)/100/2*he,Q/te,.2);j({scale:m}),K(i({touchLength:n,reach:c,scale:m},P(ue,le,te,re,he,m,e,t,d,s)))}},{maxWait:8});function Se(e){return!de&&!ce&&(G.current&&K(i({},e,{pause:w})),G.current)}var Me,Ve,We,Ne,Ye,Xe,Te,Le,Ie=(Ye=function(e){return Se({x:e})},Xe=function(e){return Se({y:e})},Te=function(e){return G.current&&(j({scale:e}),K({scale:e})),!ce&&G.current},Le=a({X:function(e){return Ye(e)},Y:function(e){return Xe(e)},S:function(e){return Te(e)}}),function(e,t,n,r,i,o,a,u,l,c,d){var s=_(c,i,o),f=s[0],h=s[1],v=R(e,u,f,innerWidth),m=v[0],g=v[1],p=R(t,u,h,innerHeight),w=p[0],b=p[1],y=Date.now()-d;if(y>=200||u!==a||Math.abs(l-a)>1){var E=P(e,t,i,o,a,u),x=E.x,C=E.y,k=m?g:x!==e?x:null,S=w?b:C!==t?C:null;return null!==k&&W(e,k,Le.X),null!==S&&W(t,S,Le.Y),void(u!==a&&W(a,u,Le.S))}var V=(e-n)/y,N=(t-r)/y,Y=Math.sqrt(Math.pow(V,2)+Math.pow(N,2)),X=!1,T=!1;!function(e,t){var n,r=e,i=0,o=0,a=function(o){n||(n=o);var a=o-n,c=Math.sign(e),d=-.001*c,s=Math.sign(-r)*Math.pow(r,2)*2e-4,f=r*a+(d+s)*Math.pow(a,2)/2;i+=f,n=o,c*(r+=(d+s)*a)<=0?l():t(i)?u():l()};function u(){o=requestAnimationFrame(a)}function l(){cancelAnimationFrame(o)}u()}(Y,function(n){var r=e+n*(V/Y),i=t+n*(N/Y),o=R(r,a,f,innerWidth),u=o[0],l=o[1],c=R(i,a,h,innerHeight),d=c[0],s=c[1];if(u&&!X&&(X=!0,m?W(r,l,Le.X):M(l,r+(r-l),Le.X)),d&&!T&&(T=!0,w?W(i,s,Le.Y):M(s,i+(i-s),Le.Y)),X&&T)return!1;var v=X||Le.X(l),g=T||Le.Y(s);return v&&g})}),Ae=(Me=L,Ve=function(e,t){Re||_e(1!==he?1:Math.max(2,Q/te),e,t)},We=e.useRef(0),Ne=S(function(){We.current=0,Me.apply(void 0,[].slice.call(arguments))},{wait:300}),function(){var e=[].slice.call(arguments);We.current+=1,Ne.apply(void 0,e),We.current>=2&&(Ne.cancel(),We.current=0,Ve.apply(void 0,e))});function De(e,t){if(U.current=0,(ce||se)&&B){K({touched:!1,maskTouched:!1,pause:!1,stopRaf:!1,reach:void 0});var n=h(he,Q/te);if(Ie(ue,le,ge,pe,te,re,he,n,ye,fe,Ee),H(e,t),ve===e&&me===t){if(ce)return void Ae(e,t);se&&D(e,t)}}}function Fe(e,t,n){void 0===n&&(n=0),K({touched:!0,CX:e,CY:t,lastCX:e,lastCY:t,lastX:ue,lastY:le,lastScale:he,touchLength:n,touchTime:Date.now()})}function He(e){K({maskTouched:!0,CX:e.clientX,CY:e.clientY,lastX:ue,lastY:le})}m(s?void 0:"mousemove",function(e){e.preventDefault(),ke(e.clientX,e.clientY)}),m(s?void 0:"mouseup",function(e){De(e.clientX,e.clientY)}),m(s?"touchmove":void 0,function(e){e.preventDefault();var t=C(e);ke.apply(void 0,t)},{passive:!1}),m(s?"touchend":void 0,function(e){var t=e.changedTouches[0];De(t.clientX,t.clientY)},{passive:!1}),m("resize",S(function(){oe&&!ce&&(K(k(Q,$,fe)),O())},{maxWait:8})),v(function(){B&&j(i({scale:he,rotate:fe},Pe))},[B]);var Oe=function(t,n,r,i,o,l,c,d,s,f){var h=function(t,n,r,i,o){var a=e.useRef(!1),l=u({lead:!0,scale:r}),c=l[0],d=c.lead,s=c.scale,f=l[1],h=S(function(e){try{return o(!0),f({lead:!1,scale:e}),Promise.resolve()}catch(e){return Promise.reject(e)}},{wait:i});return v(function(){a.current?(o(!1),f({lead:!0}),h(r)):a.current=!0},[r]),d?[t*s,n*s,r/s]:[t*r,n*r,1]}(l,c,d,s,f),m=h[0],g=h[1],p=h[2],w=function(t,n,r,i,o){var u=e.useState(N),l=u[0],c=u[1],d=e.useState(0),s=d[0],f=d[1],h=e.useRef(),v=a({OK:function(){return t&&f(4)}});function m(e){o(!1),f(e)}return e.useEffect(function(){if(h.current||(h.current=Date.now()),r){if(function(e,t){var n=e&&e.current;if(n&&1===n.nodeType){var r=n.getBoundingClientRect();t({T:r.top,L:r.left,W:r.width,H:r.height,FIT:"IMG"===n.tagName?getComputedStyle(n).objectFit:void 0})}}(n,c),t)return Date.now()-h.current<250?(f(1),requestAnimationFrame(function(){f(2),requestAnimationFrame(function(){return m(3)})}),void setTimeout(v.OK,i)):void f(4);m(5)}},[t,r]),[s,l]}(t,n,r,s,f),b=w[0],y=w[1],E=y.W,x=y.FIT,C=innerWidth/2,R=innerHeight/2,P=b<3||b>4;return[P?E?y.L:C:i+(C-l*d/2),P?E?y.T:R:o+(R-c*d/2),m,P&&x?m*(y.H/E):g,0===b?p:P?E/(l*d)||.01:p,P?x?1:0:1,b,x]}(w,p,oe,ue,le,te,re,he,b,function(e){return K({pause:e})}),Be=Oe[4],je=Oe[6],qe="transform "+b+"ms "+y,ze={className:x,onMouseDown:s?void 0:function(e){e.stopPropagation(),0===e.button&&Fe(e.clientX,e.clientY,0)},onTouchStart:s?function(e){e.stopPropagation(),Fe.apply(void 0,C(e))}:void 0,onWheel:function(e){if(!Re){var t=h(he-e.deltaY/100/2,Q/te);K({stopRaf:!0}),_e(t,e.clientX,e.clientY)}},style:{width:Oe[2]+"px",height:Oe[3]+"px",opacity:Oe[5],objectFit:4===je?void 0:Oe[7],transform:fe?"rotate("+fe+"deg)":void 0,transition:je>2?qe+", opacity "+b+"ms ease, height "+(je<4?b/2:je>4?b:0)+"ms "+y:void 0}};return r.default.createElement("div",{className:"PhotoView__PhotoWrap"+(E?" "+E:""),style:V,onMouseDown:!s&&B?He:void 0,onTouchStart:s&&B?function(e){return He(e.touches[0])}:void 0},r.default.createElement("div",{className:"PhotoView__PhotoBox",style:{transform:"matrix("+Be+", 0, 0, "+Be+", "+Oe[0]+", "+Oe[1]+")",transition:ce||Ce?void 0:qe,willChange:B?"transform":void 0}},o?r.default.createElement(I,i({src:o,loaded:oe,broken:ae},ze,{onPhotoLoad:function(e){K(i({},e,e.loaded&&k(e.naturalWidth||0,e.naturalHeight||0,fe)))},loadingElement:X,brokenElement:T})):l&&l({attrs:ze,scale:Be,rotate:fe})))}var F={x:0,touched:!1,pause:!1,lastCX:void 0,lastCY:void 0,bg:void 0,lastBg:void 0,overlay:!0,minimal:!0,scale:1,rotate:0};function H(t){var n=t.loop,i=void 0===n?3:n,o=t.speed,l=t.easing,h=t.photoClosable,g=t.maskClosable,E=void 0===g||g,C=t.maskOpacity,R=void 0===C?1:C,P=t.pullClosable,_=void 0===P||P,k=t.pullAction,S=t.bannerVisible,M=void 0===S||S,V=t.overlayRender,W=t.toolbarRender,N=t.showBackdropImage,Y=t.disableScroll,X=void 0===Y||Y,T=t.toolbarLeftRender,L=t.toolbarRightRender,I=t.sidebarWidth,A=t.sidebarLeftRender,H=t.sidebarRightRender,O=t.className,B=t.maskClassName,j=t.photoClassName,q=t.photoWrapClassName,z=t.loadingElement,K=t.brokenElement,U=t.images,G=t.index,J=void 0===G?0:G,Q=t.onIndexChange,Z=t.visible,$=t.onClose,ee=t.afterClose,te=t.portalContainer,ne=u(F),re=ne[0],ie=ne[1],oe=e.useState(0),ae=oe[0],ue=oe[1],le=re.x,ce=re.touched,de=re.pause,se=re.lastCX,fe=re.lastCY,he=re.bg,ve=void 0===he?R:he,me=re.lastBg,ge=re.overlay,pe=re.minimal,we=re.scale,be=re.rotate,ye=re.onScale,Ee=re.onRotate,xe=t.hasOwnProperty("index"),Ce=xe?J:ae,Re=xe?Q:ue,Pe=e.useRef(Ce),_e=U.length,ke=U[Ce],Se="boolean"==typeof i?i:_e>i,Me=function(t,n){var r=e.useReducer(function(e){return!e},!1)[1],i=e.useRef(0),o=function(n){var r=e.useRef(n);function o(e){r.current=e}return e.useMemo(function(){!function(e){t?(e(t),i.current=1):i.current=2}(o)},[n]),[r.current,o]}(t),a=o[1];return[o[0],i.current,function(){r(),2===i.current&&(a(!1),n&&n()),i.current=0}]}(Z,ee),Ve=Me[0],We=Me[1],Ne=Me[2];v(function(){if(Ve)return ie({pause:!0,x:Ce*-(innerWidth+d)}),void(Pe.current=Ce);ie(F)},[Ve]);var Ye=a({close:function(e){Ee&&Ee(0),ie({overlay:!0,lastBg:ve}),$(e)},changeIndex:function(e,t){void 0===t&&(t=!1);var n=Se?Pe.current+(e-Ce):e,r=_e-1,i=f(n,0,r),o=Se?n:i,a=innerWidth+d;ie({touched:!1,lastCX:void 0,lastCY:void 0,x:-a*o,pause:t}),Pe.current=o,Re&&Re(Se?e<0?r:e>r?0:e:i)}}),Xe=Ye.close,Te=Ye.changeIndex;function Le(e){return e?Xe():ie({overlay:!ge})}function Ie(){ie({x:-(innerWidth+d)*Ce,lastCX:void 0,lastCY:void 0,pause:!0}),Pe.current=Ce}function Ae(e,t,n,r){"x"===e?function(e){if(void 0!==se){var t=e-se,n=t;!Se&&(0===Ce&&t>0||Ce===_e-1&&t<0)&&(n=t/2),ie({touched:!0,lastCX:se,x:-(innerWidth+d)*Pe.current+n,pause:!1})}else ie({touched:!0,lastCX:e,x:le,pause:!1})}(t):"y"===e&&function(e,t){if(void 0!==fe){var n=null===R?null:f(R,.01,R-Math.abs(e-fe)/100/4);ie({touched:!0,lastCY:fe,bg:1===t?n:R,minimal:1===t})}else ie({touched:!0,lastCY:e,bg:ve,minimal:!0})}(n,r)}function De(e,t){var n=e-(null!=se?se:e),r=t-(null!=fe?fe:t),i=!1;if(n<-40)Te(Ce+1);else if(n>40)Te(Ce-1);else{var o=-(innerWidth+d)*Pe.current;Math.abs(r)>100&&pe&&_?(i=!0,Xe()):Math.abs(r)>100&&pe&&"function"==typeof k&&k({direction:r<0?"top":"bottom",offsetY:r}),ie({touched:!1,x:o,lastCX:void 0,lastCY:void 0,bg:R,overlay:!!i||ge})}}m("keydown",function(e){if(Z)switch(e.key){case"ArrowLeft":Te(Ce-1,!1);break;case"ArrowRight":Te(Ce+1,!1);break;case"Escape":Xe()}});var Fe=function(t,n,r){return e.useMemo(function(){var e=t.length;return r?t.concat(t).concat(t).slice(e+n-1,e+n+2):t.slice(Math.max(n-1,0),Math.min(n+2,e+1))},[t,n,r])}(U,Ce,Se);if(!Ve)return null;var He=ge&&!We,Oe=Z?ve:me,Be=ye&&Ee&&{images:U,index:Ce,visible:Z,onClose:Xe,onIndexChange:Te,overlayVisible:He,overlay:ke&&ke.overlay,scale:we,rotate:be,onScale:ye,onRotate:Ee},je=o?o(We):400,qe=l?l(We):c,ze=o?o(3):600,Ke=l?l(3):c,Ue="number"==typeof I?I+"px":I,Ge=innerWidth<=900;return r.default.createElement(p,{className:"PhotoView-Portal"+(He?"":" PhotoView-Slider__clean")+(Z?"":" PhotoView-Slider__willClose")+(O?" "+O:""),role:"dialog",onClick:function(e){return e.stopPropagation()},container:te},Z&&X&&r.default.createElement(y,null),r.default.createElement("div",{className:"PhotoView-Container"},A&&Be&&!Ge&&r.default.createElement("div",{className:"PhotoView-Sidebar PhotoView-Sidebar__Left "+(1===We?" PhotoView-Slider__fadeIn":2===We?" PhotoView-Slider__fadeOut":""),style:{width:Ue,transitionTimingFunction:qe,transitionDuration:(ce?0:je)+"ms",animationDuration:je+"ms"}},A(Be)),r.default.createElement("div",{className:"PhotoView-Viewer"},r.default.createElement("div",{className:"PhotoView-Slider__Backdrop"+(B?" "+B:"")+(1===We?" PhotoView-Slider__fadeIn":2===We?" PhotoView-Slider__fadeOut":"")+" "+(N?"with-backdrop-image":""),style:{background:N?"url("+ke.src+")":Oe?"rgba(0, 0, 0, "+Oe+")":void 0,transitionTimingFunction:qe,transitionDuration:(ce?0:je)+"ms",animationDuration:je+"ms"},onAnimationEnd:Ne}),r.default.createElement(x,{bannerVisible:M,index:Ce,imageLength:_e,overlayParams:Be,toolbarRender:W,toolbarLeftRender:T,toolbarRightRender:L}),Fe.map(function(e,t){var n=Se||0!==Ce?Pe.current-1+t:Ce+t;return r.default.createElement(D,{key:Se?e.key+"/"+e.src+"/"+n:e.key,item:e,speed:je,easing:qe,visible:Z,onReachMove:Ae,onReachUp:De,onPhotoTap:function(){return Le(h)},onMaskTap:function(){return Le(E)},wrapClassName:q,className:j,style:{left:(innerWidth+d)*n+"px",transform:"translate3d("+le+"px, 0px, 0)",transition:ce||de?void 0:"transform "+ze+"ms "+Ke},loadingElement:z,brokenElement:K,onPhotoResize:Ie,isActive:Pe.current===n,expose:ie})}),!s&&M&&r.default.createElement(r.default.Fragment,null,(Se||0!==Ce)&&r.default.createElement("div",{className:"PhotoView-Slider__ArrowLeft",onClick:function(){return Te(Ce-1,!0)}},r.default.createElement(w,null)),(Se||Ce+1<_e)&&r.default.createElement("div",{className:"PhotoView-Slider__ArrowRight",onClick:function(){return Te(Ce+1,!0)}},r.default.createElement(b,null))),V&&Be&&r.default.createElement("div",{className:"PhotoView-Slider__Overlay"},V(Be))),H&&Be&&!Ge&&r.default.createElement("div",{className:"PhotoView-Sidebar PhotoView-Sidebar__Right "+(1===We?" PhotoView-Slider__fadeIn":2===We?" PhotoView-Slider__fadeOut":""),style:{width:Ue,transitionTimingFunction:qe,transitionDuration:(ce?0:je)+"ms",animationDuration:je+"ms"}},H(Be))))}var O=["children","onIndexChange","onVisibleChange","sidebarLeftRender","sidebarRightRender","sidebarWidth"],B={images:[],visible:!1,index:0};exports.PhotoProvider=function(t){var n=t.children,c=t.onIndexChange,d=t.onVisibleChange,s=t.sidebarLeftRender,f=t.sidebarRightRender,h=t.sidebarWidth,v=void 0===h?400:h,m=o(t,O),g=u(B),p=g[0],w=g[1],b=e.useRef(0),y=p.images,E=p.visible,x=p.index;e.useEffect(function(){if(s||f){var e=Object.getOwnPropertyDescriptor(window,"innerWidth");!e||e.configurable?Object.defineProperty(window,"innerWidth",{get:function(){return window.outerWidth<=900?window.outerWidth:window.outerWidth-v},configurable:!0,enumerable:!0}):console.warn("innerWidth is already defined and is not configurable")}},[]);var C=a({nextId:function(){return b.current+=1},update:function(e){var t=y.findIndex(function(t){return t.key===e.key});if(t>-1){var n=y.slice();return n.splice(t,1,e),void w({images:n})}w(function(t){return{images:t.images.concat(e)}})},remove:function(e){w(function(t){var n=t.images.filter(function(t){return t.key!==e});return{images:n,index:Math.min(n.length-1,x)}})},show:function(e){var t=y.findIndex(function(t){return t.key===e});w({visible:!0,index:t}),d&&d(!0,t,p)}}),R=a({close:function(){w({visible:!1}),d&&d(!1,x,p)},changeIndex:function(e){w({index:e}),c&&c(e,p)}}),P=e.useMemo(function(){return i({},p,C)},[p,C]);return r.default.createElement(l.Provider,{value:P},n,r.default.createElement(H,i({images:y,visible:E,index:x,onIndexChange:R.changeIndex,onClose:R.close,sidebarWidth:v,sidebarLeftRender:s,sidebarRightRender:f},m)))},exports.PhotoSlider=H,exports.PhotoView=function(t){var n,r,o=t.src,u=t.render,c=t.overlay,d=t.width,s=t.height,f=t.triggers,h=void 0===f?["onClick"]:f,v=t.children,m=e.useContext(l),g=(n=function(){return m.nextId()},(r=e.useRef({sign:!1,fn:void 0}).current).sign||(r.sign=!0,r.fn=n()),r.fn),p=e.useRef(null);e.useImperativeHandle(null==v?void 0:v.ref,function(){return p.current}),e.useEffect(function(){return function(){m.remove(g)}},[]);var w=a({render:function(e){return u&&u(e)},show:function(e,t){m.show(g),function(e,t){if(v){var n=v.props[e];n&&n(t)}}(e,t)}}),b=e.useMemo(function(){var e={};return h.forEach(function(t){e[t]=w.show.bind(null,t)}),e},[]);return e.useEffect(function(){m.update({key:g,src:o,originRef:p,render:w.render,overlay:c,width:d,height:s})},[o]),v?e.Children.only(e.cloneElement(v,i({},b,{ref:p}))):null}; | ||
var e=require("react"),n=require("react-dom");function t(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var r=/*#__PURE__*/t(e);function i(){return i=Object.assign?Object.assign.bind():function(e){for(var n=1;n<arguments.length;n++){var t=arguments[n];for(var r in t)({}).hasOwnProperty.call(t,r)&&(e[r]=t[r])}return e},i.apply(null,arguments)}function o(e,n){if(null==e)return{};var t={};for(var r in e)if({}.hasOwnProperty.call(e,r)){if(n.includes(r))continue;t[r]=e[r]}return t}function a(n){var t=e.useRef({fn:n,curr:void 0}).current;if(t.fn=n,!t.curr){var r=Object.create(null);Object.keys(n).forEach(function(e){r[e]=function(){var n;return(n=t.fn[e]).call.apply(n,[t.fn].concat([].slice.call(arguments)))}}),t.curr=r}return t.curr}function u(n){return e.useReducer(function(e,n){return i({},e,"function"==typeof n?n(e):n)},n)}var l=e.createContext(void 0),c="cubic-bezier(0.25, 0.8, 0.25, 1)",d=20,s="undefined"!=typeof window&&"ontouchstart"in window,f=function(e,n,t){return Math.max(Math.min(e,t),n)},h=function(e,n,t){return void 0===n&&(n=0),void 0===t&&(t=0),f(e,1*(1-t),Math.max(6,n)*(1+t))},v="undefined"==typeof window||/ServerSideRendering/.test(navigator&&navigator.userAgent)?e.useEffect:e.useLayoutEffect;function m(n,t,r){var i=e.useRef(t);i.current=t,e.useEffect(function(){function e(e){i.current(e)}return n&&window.addEventListener(n,e,r),function(){n&&window.removeEventListener(n,e)}},[n])}var g=["container"];function p(e){var t=e.container,a=void 0===t?document.body:t,u=o(e,g);return n.createPortal(r.default.createElement("div",i({},u)),a)}function w(e){return r.default.createElement("svg",i({width:"44",height:"44",viewBox:"0 0 768 768"},e),r.default.createElement("path",{d:"M640.5 352.5v63h-390l178.5 180-45 45-256.5-256.5 256.5-256.5 45 45-178.5 180h390z"}))}function b(e){return r.default.createElement("svg",i({width:"44",height:"44",viewBox:"0 0 768 768"},e),r.default.createElement("path",{d:"M384 127.5l256.5 256.5-256.5 256.5-45-45 178.5-180h-390v-63h390l-178.5-180z"}))}function E(){return e.useEffect(function(){var e=document.body.style,n=e.overflow;return e.overflow="hidden",function(){e.overflow=n}},[]),null}function y(e){return r.default.createElement("svg",i({width:"44",height:"44",viewBox:"0 0 768 768"},e),r.default.createElement("path",{d:"M607.5 205.5l-178.5 178.5 178.5 178.5-45 45-178.5-178.5-178.5 178.5-45-45 178.5-178.5-178.5-178.5 45-45 178.5 178.5 178.5-178.5z"}))}function x(e){var n=e.toolbarRender,t=e.overlayParams,i=e.toolbarLeftRender,o=e.toolbarRightRender;return r.default.createElement(r.default.Fragment,null,e.bannerVisible&&r.default.createElement("div",{className:"PhotoView-Slider__BannerWrap"},r.default.createElement("div",{className:"PhotoView-Slider__Counter"},e.index+1," / ",e.imageLength),r.default.createElement("div",{className:"PhotoView-Slider__BannerRight"},n&&t&&n(t),r.default.createElement(y,{className:"PhotoView-Slider__toolbarIcon",onClick:close}))),i&&t&&r.default.createElement("div",{className:"PhotoView-Slider__Toolbar PhotoView-Slider__Toolbar--Left"},i(t)),o&&t&&r.default.createElement("div",{className:"PhotoView-Slider__Toolbar PhotoView-Slider__Toolbar--Right"},o(t)))}function C(e){var n=e.touches[0],t=n.clientX,r=n.clientY;if(e.touches.length>=2){var i=e.touches[1],o=i.clientX,a=i.clientY;return[(t+o)/2,(r+a)/2,Math.sqrt(Math.pow(o-t,2)+Math.pow(a-r,2))]}return[t,r,0]}var R=function(e,n,t,r){var i,o=t*n,a=(o-r)/2,u=e;return o<=r?(i=1,u=0):e>0&&a-e<=0?(i=2,u=a):e<0&&a+e<=0&&(i=3,u=-a),[i,u]};function P(e,n,t,r,i,o,a,u,l,c){void 0===a&&(a=innerWidth/2),void 0===u&&(u=innerHeight/2),void 0===l&&(l=0),void 0===c&&(c=0);var d=R(e,o,t,innerWidth)[0],s=R(n,o,r,innerHeight),f=innerWidth/2,h=innerHeight/2;return{x:a-o/i*(a-(f+e))-f+(r/t>=3&&t*o===innerWidth?0:d?l/2:l),y:u-o/i*(u-(h+n))-h+(s[0]?c/2:c),lastCX:a,lastCY:u}}function S(e,n,t){var r=e%180!=0;return r?[t,n,r]:[n,t,r]}function _(e,n,t){var r=S(t,innerWidth,innerHeight),i=r[0],o=r[1],a=0,u=i,l=o,c=e/n*o,d=n/e*i;return e<i&&n<o?(u=e,l=n):e<i&&n>=o?u=c:e>=i&&n<o||e/n>i/o?l=d:n/e>=3&&!r[2]?a=((l=d)-o)/2:u=c,{width:u,height:l,x:0,y:a,pause:!0}}function k(n,t){var r=t.leading,i=void 0!==r&&r,o=t.maxWait,a=t.wait,u=void 0===a?o||0:a,l=e.useRef(n);l.current=n;var c=e.useRef(0),d=e.useRef(),s=function(){return d.current&&clearTimeout(d.current)},f=e.useCallback(function(){var e=[].slice.call(arguments),n=Date.now();function t(){c.current=n,s(),l.current.apply(null,e)}var r=c.current,a=n-r;if(0===r&&(i&&t(),c.current=n),void 0!==o){if(a>o)return void t()}else a<u&&(c.current=n);s(),d.current=setTimeout(function(){t(),c.current=0},u)},[u,o,i]);return f.cancel=s,f}var M=function(e,n,t){return W(e,n,t,100,function(e){return e},function(){return W(n,e,t)})},V=function(e){return 1-Math.pow(1-e,4)};function W(e,n,t,r,i,o){void 0===r&&(r=400),void 0===i&&(i=V);var a=n-e;if(0!==a){var u=Date.now(),l=0,c=function(){var n=Math.min(1,(Date.now()-u)/r);t(e+i(n)*a)&&n<1?d():(cancelAnimationFrame(l),n>=1&&o&&o())};d()}function d(){l=requestAnimationFrame(c)}}var N={T:0,L:0,W:0,H:0,FIT:void 0},Y=function(){var n=e.useRef(!1);return e.useEffect(function(){return n.current=!0,function(){n.current=!1}},[]),n},X=["className"];function T(e){var n=e.className,t=void 0===n?"":n,a=o(e,X);return r.default.createElement("div",i({className:"PhotoView__Spinner "+t},a),r.default.createElement("svg",{viewBox:"0 0 32 32",width:"36",height:"36",fill:"white"},r.default.createElement("path",{opacity:".25",d:"M16 0 A16 16 0 0 0 16 32 A16 16 0 0 0 16 0 M16 4 A12 12 0 0 1 16 28 A12 12 0 0 1 16 4"}),r.default.createElement("path",{d:"M16 0 A16 16 0 0 1 32 16 L28 16 A12 12 0 0 0 16 4z"})))}var L=["src","loaded","broken","className","onPhotoLoad","loadingElement","brokenElement"];function I(e){var n=e.src,t=e.loaded,a=e.broken,u=e.className,l=e.onPhotoLoad,c=e.loadingElement,d=e.brokenElement,s=o(e,L),f=Y();return n&&!a?r.default.createElement(r.default.Fragment,null,r.default.createElement("img",i({className:"PhotoView__Photo"+(u?" "+u:""),src:n,onLoad:function(e){var n=e.target;f.current&&l({loaded:!0,naturalWidth:n.naturalWidth,naturalHeight:n.naturalHeight})},onError:function(){f.current&&l({broken:!0})},alt:""},s)),!t&&(r.default.createElement("span",{className:"PhotoView__icon"},c)||r.default.createElement(T,{className:"PhotoView__icon"}))):d?r.default.createElement("span",{className:"PhotoView__icon"},"function"==typeof d?d({src:n}):d):null}var F={naturalWidth:void 0,naturalHeight:void 0,width:void 0,height:void 0,loaded:void 0,broken:!1,x:0,y:0,touched:!1,maskTouched:!1,rotate:0,scale:1,CX:0,CY:0,lastX:0,lastY:0,lastCX:0,lastCY:0,lastScale:1,touchTime:0,touchLength:0,pause:!0,stopRaf:!0,reach:void 0};function A(n){var t=n.item,o=t.src,l=t.render,c=t.width,d=void 0===c?0:c,f=t.height,g=void 0===f?0:f,p=t.originRef,w=n.visible,b=n.speed,E=n.easing,y=n.wrapClassName,x=n.className,V=n.style,X=n.loadingElement,T=n.brokenElement,L=n.onPhotoTap,A=n.onMaskTap,D=n.onReachMove,H=n.onReachUp,O=n.onPhotoResize,B=n.isActive,j=n.expose,q=u(F),z=q[0],K=q[1],U=e.useRef(0),G=Y(),J=z.naturalWidth,Q=void 0===J?d:J,Z=z.naturalHeight,$=void 0===Z?g:Z,ee=z.width,ne=void 0===ee?d:ee,te=z.height,re=void 0===te?g:te,ie=z.loaded,oe=void 0===ie?!o:ie,ae=z.broken,ue=z.x,le=z.y,ce=z.touched,de=z.stopRaf,se=z.maskTouched,fe=z.rotate,he=z.scale,ve=z.CX,me=z.CY,ge=z.lastX,pe=z.lastY,we=z.lastCX,be=z.lastCY,Ee=z.lastScale,ye=z.touchTime,xe=z.touchLength,Ce=z.pause,Re=z.reach,Pe=a({onScale:function(e){return Se(h(e))},onRotate:function(e){fe!==e&&(j({rotate:e}),K(i({rotate:e},_(Q,$,e))))}});function Se(e,n,t){he!==e&&(j({scale:e}),K(i({scale:e},P(ue,le,ne,re,he,e,n,t),e<=1&&{x:0,y:0})))}var _e=k(function(e,n,t){if(void 0===t&&(t=0),(ce||se)&&B){var r=S(fe,ne,re),o=r[0],a=r[1];if(0===t&&0===U.current){var u=Math.abs(e-ve)<=20,l=Math.abs(n-me)<=20;if(u&&l)return void K({lastCX:e,lastCY:n});U.current=u?n>me?3:2:1}var c,d=e-we,s=n-be;if(0===t){var f=R(d+ge,he,o,innerWidth)[0],v=R(s+pe,he,a,innerHeight);c=function(e,n,t,r){return n&&1===e||"x"===r?"x":t&&e>1||"y"===r?"y":void 0}(U.current,f,v[0],Re),void 0!==c&&D(c,e,n,he)}if("x"===c||se)return void K({reach:"x"});var m=h(he+(t-xe)/100/2*he,Q/ne,.2);j({scale:m}),K(i({touchLength:t,reach:c,scale:m},P(ue,le,ne,re,he,m,e,n,d,s)))}},{maxWait:8});function ke(e){return!de&&!ce&&(G.current&&K(i({},e,{pause:w})),G.current)}var Me,Ve,We,Ne,Ye,Xe,Te,Le,Ie=(Ye=function(e){return ke({x:e})},Xe=function(e){return ke({y:e})},Te=function(e){return G.current&&(j({scale:e}),K({scale:e})),!ce&&G.current},Le=a({X:function(e){return Ye(e)},Y:function(e){return Xe(e)},S:function(e){return Te(e)}}),function(e,n,t,r,i,o,a,u,l,c,d){var s=S(c,i,o),f=s[0],h=s[1],v=R(e,u,f,innerWidth),m=v[0],g=v[1],p=R(n,u,h,innerHeight),w=p[0],b=p[1],E=Date.now()-d;if(E>=200||u!==a||Math.abs(l-a)>1){var y=P(e,n,i,o,a,u),x=y.x,C=y.y,_=m?g:x!==e?x:null,k=w?b:C!==n?C:null;return null!==_&&W(e,_,Le.X),null!==k&&W(n,k,Le.Y),void(u!==a&&W(a,u,Le.S))}var V=(e-t)/E,N=(n-r)/E,Y=Math.sqrt(Math.pow(V,2)+Math.pow(N,2)),X=!1,T=!1;!function(e,n){var t,r=e,i=0,o=0,a=function(o){t||(t=o);var a=o-t,c=Math.sign(e),d=-.001*c,s=Math.sign(-r)*Math.pow(r,2)*2e-4,f=r*a+(d+s)*Math.pow(a,2)/2;i+=f,t=o,c*(r+=(d+s)*a)<=0?l():n(i)?u():l()};function u(){o=requestAnimationFrame(a)}function l(){cancelAnimationFrame(o)}u()}(Y,function(t){var r=e+t*(V/Y),i=n+t*(N/Y),o=R(r,a,f,innerWidth),u=o[0],l=o[1],c=R(i,a,h,innerHeight),d=c[0],s=c[1];if(u&&!X&&(X=!0,m?W(r,l,Le.X):M(l,r+(r-l),Le.X)),d&&!T&&(T=!0,w?W(i,s,Le.Y):M(s,i+(i-s),Le.Y)),X&&T)return!1;var v=X||Le.X(l),g=T||Le.Y(s);return v&&g})}),Fe=(Me=L,Ve=function(e,n){Re||Se(1!==he?1:Math.max(2,Q/ne),e,n)},We=e.useRef(0),Ne=k(function(){We.current=0,Me.apply(void 0,[].slice.call(arguments))},{wait:300}),function(){var e=[].slice.call(arguments);We.current+=1,Ne.apply(void 0,e),We.current>=2&&(Ne.cancel(),We.current=0,Ve.apply(void 0,e))});function Ae(e,n){if(U.current=0,(ce||se)&&B){K({touched:!1,maskTouched:!1,pause:!1,stopRaf:!1,reach:void 0});var t=h(he,Q/ne);if(Ie(ue,le,ge,pe,ne,re,he,t,Ee,fe,ye),H(e,n),ve===e&&me===n){if(ce)return void Fe(e,n);se&&A(e,n)}}}function De(e,n,t){void 0===t&&(t=0),K({touched:!0,CX:e,CY:n,lastCX:e,lastCY:n,lastX:ue,lastY:le,lastScale:he,touchLength:t,touchTime:Date.now()})}function He(e){K({maskTouched:!0,CX:e.clientX,CY:e.clientY,lastX:ue,lastY:le})}m(s?void 0:"mousemove",function(e){e.preventDefault(),_e(e.clientX,e.clientY)}),m(s?void 0:"mouseup",function(e){Ae(e.clientX,e.clientY)}),m(s?"touchmove":void 0,function(e){e.preventDefault();var n=C(e);_e.apply(void 0,n)},{passive:!1}),m(s?"touchend":void 0,function(e){var n=e.changedTouches[0];Ae(n.clientX,n.clientY)},{passive:!1}),m("resize",k(function(){oe&&!ce&&(K(_(Q,$,fe)),O())},{maxWait:8})),v(function(){B&&j(i({scale:he,rotate:fe},Pe))},[B]);var Oe=function(n,t,r,i,o,l,c,d,s,f){var h=function(n,t,r,i,o){var a=e.useRef(!1),l=u({lead:!0,scale:r}),c=l[0],d=c.lead,s=c.scale,f=l[1],h=k(function(e){try{return o(!0),f({lead:!1,scale:e}),Promise.resolve()}catch(e){return Promise.reject(e)}},{wait:i});return v(function(){a.current?(o(!1),f({lead:!0}),h(r)):a.current=!0},[r]),d?[n*s,t*s,r/s]:[n*r,t*r,1]}(l,c,d,s,f),m=h[0],g=h[1],p=h[2],w=function(n,t,r,i,o){var u=e.useState(N),l=u[0],c=u[1],d=e.useState(0),s=d[0],f=d[1],h=e.useRef(),v=a({OK:function(){return n&&f(4)}});function m(e){o(!1),f(e)}return e.useEffect(function(){if(h.current||(h.current=Date.now()),r){if(function(e,n){var t=e&&e.current;if(t&&1===t.nodeType){var r=t.getBoundingClientRect();n({T:r.top,L:r.left,W:r.width,H:r.height,FIT:"IMG"===t.tagName?getComputedStyle(t).objectFit:void 0})}}(t,c),n)return Date.now()-h.current<250?(f(1),requestAnimationFrame(function(){f(2),requestAnimationFrame(function(){return m(3)})}),void setTimeout(v.OK,i)):void f(4);m(5)}},[n,r]),[s,l]}(n,t,r,s,f),b=w[0],E=w[1],y=E.W,x=E.FIT,C=innerWidth/2,R=innerHeight/2,P=b<3||b>4;return[P?y?E.L:C:i+(C-l*d/2),P?y?E.T:R:o+(R-c*d/2),m,P&&x?m*(E.H/y):g,0===b?p:P?y/(l*d)||.01:p,P?x?1:0:1,b,x]}(w,p,oe,ue,le,ne,re,he,b,function(e){return K({pause:e})}),Be=Oe[4],je=Oe[6],qe="transform "+b+"ms "+E,ze={className:x,onMouseDown:s?void 0:function(e){e.stopPropagation(),0===e.button&&De(e.clientX,e.clientY,0)},onTouchStart:s?function(e){e.stopPropagation(),De.apply(void 0,C(e))}:void 0,onWheel:function(e){if(!Re){var n=h(he-e.deltaY/100/2,Q/ne);K({stopRaf:!0}),Se(n,e.clientX,e.clientY)}},style:{width:Oe[2]+"px",height:Oe[3]+"px",opacity:Oe[5],objectFit:4===je?void 0:Oe[7],transform:fe?"rotate("+fe+"deg)":void 0,transition:je>2?qe+", opacity "+b+"ms ease, height "+(je<4?b/2:je>4?b:0)+"ms "+E:void 0}};return r.default.createElement("div",{className:"PhotoView__PhotoWrap"+(y?" "+y:""),style:V,onMouseDown:!s&&B?He:void 0,onTouchStart:s&&B?function(e){return He(e.touches[0])}:void 0},r.default.createElement("div",{className:"PhotoView__PhotoBox",style:{transform:"matrix("+Be+", 0, 0, "+Be+", "+Oe[0]+", "+Oe[1]+")",transition:ce||Ce?void 0:qe,willChange:B?"transform":void 0}},o?r.default.createElement(I,i({src:o,loaded:oe,broken:ae},ze,{onPhotoLoad:function(e){K(i({},e,e.loaded&&_(e.naturalWidth||0,e.naturalHeight||0,fe)))},loadingElement:X,brokenElement:T})):l&&l({attrs:ze,scale:Be,rotate:fe})))}var D={x:0,touched:!1,pause:!1,lastCX:void 0,lastCY:void 0,bg:void 0,lastBg:void 0,overlay:!0,minimal:!0,scale:1,rotate:0};function H(n){var t=n.loop,i=void 0===t?3:t,o=n.speed,l=n.easing,h=n.photoClosable,g=n.maskClosable,y=void 0===g||g,C=n.maskOpacity,R=void 0===C?1:C,P=n.pullClosable,S=void 0===P||P,_=n.pullAction,k=n.bannerVisible,M=void 0===k||k,V=n.overlayRender,W=n.toolbarRender,N=n.showBackdropImage,Y=n.disableScroll,X=void 0===Y||Y,T=n.toolbarLeftRender,L=n.toolbarRightRender,I=n.sidebarWidth,F=n.sidebarLeftRender,H=n.sidebarRightRender,O=n.className,B=n.maskClassName,j=n.photoClassName,q=n.photoWrapClassName,z=n.loadingElement,K=n.brokenElement,U=n.images,G=n.index,J=void 0===G?0:G,Q=n.onIndexChange,Z=n.visible,$=n.onClose,ee=n.afterClose,ne=n.portalContainer,te=n.fullScreen,re=n.onFullScreen,ie=e.useRef(),oe=u(D),ae=oe[0],ue=oe[1],le=e.useState(0),ce=le[0],de=le[1],se=ae.x,fe=ae.touched,he=ae.pause,ve=ae.lastCX,me=ae.lastCY,ge=ae.bg,pe=void 0===ge?R:ge,we=ae.lastBg,be=ae.overlay,Ee=ae.minimal,ye=ae.scale,xe=ae.rotate,Ce=ae.onScale,Re=ae.onRotate,Pe=n.hasOwnProperty("index"),Se=Pe?J:ce,_e=Pe?Q:de,ke=e.useRef(Se),Me=U.length,Ve=U[Se],We="boolean"==typeof i?i:Me>i,Ne=function(n,t){var r=e.useReducer(function(e){return!e},!1)[1],i=e.useRef(0),o=function(t){var r=e.useRef(t);function o(e){r.current=e}return e.useMemo(function(){!function(e){n?(e(n),i.current=1):i.current=2}(o)},[t]),[r.current,o]}(n),a=o[1];return[o[0],i.current,function(){r(),2===i.current&&(a(!1),t&&t()),i.current=0}]}(Z,ee),Ye=Ne[0],Xe=Ne[1],Te=Ne[2];v(function(){if(Ye)return ue({pause:!0,x:Se*-(innerWidth+d)}),void(ke.current=Se);ue(D)},[Ye]);var Le=a({close:function(e){Re&&Re(0),ue({overlay:!0,lastBg:pe}),$(e)},changeIndex:function(e,n){void 0===n&&(n=!1);var t=We?ke.current+(e-Se):e,r=Me-1,i=f(t,0,r),o=We?t:i,a=innerWidth+d;ue({touched:!1,lastCX:void 0,lastCY:void 0,x:-a*o,pause:n}),ke.current=o,_e&&_e(We?e<0?r:e>r?0:e:i)}}),Ie=Le.close,Fe=Le.changeIndex,Ae=e.useCallback(function(){re(!te)},[te,re]),De=e.useMemo(function(){return function(){!document.fullscreenElement&&te&&Ae()}},[te,Ae]),He=e.useMemo(function(){return function(){if(document.fullscreenElement)document.exitFullscreen();else if(te){var e=ie.current;if(!e)return;e.requestFullscreen().then(function(){}).catch(function(e){console.log("Error al intentar activar el modo de pantalla completa",e)})}}},[te]);function Oe(e){return e?Ie():ue({overlay:!be})}function Be(){ue({x:-(innerWidth+d)*Se,lastCX:void 0,lastCY:void 0,pause:!0}),ke.current=Se}function je(e,n,t,r){"x"===e?function(e){if(void 0!==ve){var n=e-ve,t=n;!We&&(0===Se&&n>0||Se===Me-1&&n<0)&&(t=n/2),ue({touched:!0,lastCX:ve,x:-(innerWidth+d)*ke.current+t,pause:!1})}else ue({touched:!0,lastCX:e,x:se,pause:!1})}(n):"y"===e&&function(e,n){if(void 0!==me){var t=null===R?null:f(R,.01,R-Math.abs(e-me)/100/4);ue({touched:!0,lastCY:me,bg:1===n?t:R,minimal:1===n})}else ue({touched:!0,lastCY:e,bg:pe,minimal:!0})}(t,r)}function qe(e,n){var t=e-(null!=ve?ve:e),r=n-(null!=me?me:n),i=!1;if(t<-40)Fe(Se+1);else if(t>40)Fe(Se-1);else{var o=-(innerWidth+d)*ke.current;Math.abs(r)>100&&Ee&&S?(i=!0,Ie()):Math.abs(r)>100&&Ee&&"function"==typeof _&&_({direction:r<0?"top":"bottom",offsetY:r}),ue({touched:!1,x:o,lastCX:void 0,lastCY:void 0,bg:R,overlay:!!i||be})}}e.useEffect(function(){if(ie.current)return He(),document.addEventListener("fullscreenchange",De),function(){document.removeEventListener("fullscreenchange",De)}},[te,De,He]),m("keydown",function(e){if(Z)switch(e.key){case"ArrowLeft":Fe(Se-1,!1);break;case"ArrowRight":Fe(Se+1,!1);break;case"Escape":Ie()}});var ze=function(n,t,r){return e.useMemo(function(){var e=n.length;return r?n.concat(n).concat(n).slice(e+t-1,e+t+2):n.slice(Math.max(t-1,0),Math.min(t+2,e+1))},[n,t,r])}(U,Se,We);if(!Ye)return null;var Ke=be&&!Xe,Ue=Z?pe:we,Ge=Ce&&Re&&{images:U,index:Se,visible:Z,onClose:Ie,onIndexChange:Fe,overlayVisible:Ke,overlay:Ve&&Ve.overlay,scale:ye,rotate:xe,onScale:Ce,onRotate:Re,toggleFullScreen:function(){return re(!te)}},Je=o?o(Xe):400,Qe=l?l(Xe):c,Ze=o?o(3):600,$e=l?l(3):c,en="number"==typeof I?I+"px":I,nn=innerWidth<=900;return r.default.createElement(p,{className:"PhotoView-Portal"+(Ke?"":" PhotoView-Slider__clean")+(Z?"":" PhotoView-Slider__willClose")+(O?" "+O:""),role:"dialog",onClick:function(e){return e.stopPropagation()},container:ne},Z&&X&&r.default.createElement(E,null),r.default.createElement("div",{className:"PhotoView-Container"},F&&Ge&&!nn&&r.default.createElement("div",{className:"PhotoView-Sidebar PhotoView-Sidebar__Left "+(1===Xe?" PhotoView-Slider__fadeIn":2===Xe?" PhotoView-Slider__fadeOut":""),style:{width:en,transitionTimingFunction:Qe,transitionDuration:(fe?0:Je)+"ms",animationDuration:Je+"ms"}},F(Ge)),r.default.createElement("div",{ref:ie,className:"PhotoView-Viewer"},r.default.createElement("div",{className:"PhotoView-Slider__Backdrop"+(B?" "+B:"")+(1===Xe?" PhotoView-Slider__fadeIn":2===Xe?" PhotoView-Slider__fadeOut":"")+" "+(N?"with-backdrop-image":""),style:{background:N?"url("+Ve.src+")":Ue?"rgba(0, 0, 0, "+Ue+")":void 0,transitionTimingFunction:Qe,transitionDuration:(fe?0:Je)+"ms",animationDuration:Je+"ms"},onAnimationEnd:Te}),r.default.createElement(x,{bannerVisible:M,index:Se,imageLength:Me,overlayParams:Ge,toolbarRender:W,toolbarLeftRender:T,toolbarRightRender:L}),ze.map(function(e,n){var t=We||0!==Se?ke.current-1+n:Se+n;return r.default.createElement(A,{key:We?e.key+"/"+e.src+"/"+t:e.key,item:e,speed:Je,easing:Qe,visible:Z,onReachMove:je,onReachUp:qe,onPhotoTap:function(){return Oe(h)},onMaskTap:function(){return Oe(y)},wrapClassName:q,className:j,style:{left:(innerWidth+d)*t+"px",transform:"translate3d("+se+"px, 0px, 0)",transition:fe||he?void 0:"transform "+Ze+"ms "+$e},loadingElement:z,brokenElement:K,onPhotoResize:Be,isActive:ke.current===t,expose:ue})}),!s&&M&&r.default.createElement(r.default.Fragment,null,(We||0!==Se)&&r.default.createElement("div",{className:"PhotoView-Slider__ArrowLeft",onClick:function(){return Fe(Se-1,!0)}},r.default.createElement(w,null)),(We||Se+1<Me)&&r.default.createElement("div",{className:"PhotoView-Slider__ArrowRight",onClick:function(){return Fe(Se+1,!0)}},r.default.createElement(b,null))),V&&Ge&&r.default.createElement("div",{className:"PhotoView-Slider__Overlay"},V(Ge))),H&&Ge&&!nn&&r.default.createElement("div",{className:"PhotoView-Sidebar PhotoView-Sidebar__Right "+(1===Xe?" PhotoView-Slider__fadeIn":2===Xe?" PhotoView-Slider__fadeOut":""),style:{width:en,transitionTimingFunction:Qe,transitionDuration:(fe?0:Je)+"ms",animationDuration:Je+"ms"}},H(Ge))))}var O=["children","onIndexChange","onVisibleChange","sidebarLeftRender","sidebarRightRender","sidebarWidth"],B={images:[],visible:!1,index:0,fullScreen:!1};exports.PhotoProvider=function(n){var t=n.children,c=n.onIndexChange,d=n.onVisibleChange,s=n.sidebarLeftRender,f=n.sidebarRightRender,h=n.sidebarWidth,v=void 0===h?400:h,m=o(n,O),g=u(B),p=g[0],w=g[1],b=e.useRef(0),E=e.useRef(!1),y=p.images,x=p.visible,C=p.index,R=e.useCallback(function(){if(s||f){var e=Object.getOwnPropertyDescriptor(window,"innerWidth");!e||e.configurable||E.current!==p.fullScreen?(Object.defineProperty(window,"innerWidth",{get:function(){return window.outerWidth<=900||p.fullScreen?window.outerWidth:window.outerWidth-v},configurable:!0,enumerable:!0}),E.current=p.fullScreen):console.warn("innerWidth is already defined and is not configurable")}},[s,f,p.fullScreen,v]);e.useEffect(function(){R()},[]),e.useEffect(function(){R()},[p.fullScreen,R]);var P=a({nextId:function(){return b.current+=1},update:function(e){var n=y.findIndex(function(n){return n.key===e.key});if(n>-1){var t=y.slice();return t.splice(n,1,e),void w({images:t})}w(function(n){return{images:n.images.concat(e)}})},remove:function(e){w(function(n){var t=n.images.filter(function(n){return n.key!==e});return{images:t,index:Math.min(t.length-1,C)}})},show:function(e){var n=y.findIndex(function(n){return n.key===e});w({visible:!0,index:n}),d&&d(!0,n,p)}}),S=a({close:function(){w({visible:!1}),d&&d(!1,C,p)},changeIndex:function(e){w({index:e}),c&&c(e,p)},fullScreen:function(e){w({fullScreen:e})}}),_=e.useMemo(function(){return i({},p,P)},[p,P]);return r.default.createElement(l.Provider,{value:_},t,r.default.createElement(H,i({images:y,visible:x,index:C,fullScreen:p.fullScreen,onIndexChange:S.changeIndex,onClose:S.close,onFullScreen:S.fullScreen,sidebarWidth:v,sidebarLeftRender:s,sidebarRightRender:f},m)))},exports.PhotoSlider=H,exports.PhotoView=function(n){var t,r,o=n.src,u=n.render,c=n.overlay,d=n.width,s=n.height,f=n.triggers,h=void 0===f?["onClick"]:f,v=n.children,m=e.useContext(l),g=(t=function(){return m.nextId()},(r=e.useRef({sign:!1,fn:void 0}).current).sign||(r.sign=!0,r.fn=t()),r.fn),p=e.useRef(null);e.useImperativeHandle(null==v?void 0:v.ref,function(){return p.current}),e.useEffect(function(){return function(){m.remove(g)}},[]);var w=a({render:function(e){return u&&u(e)},show:function(e,n){m.show(g),function(e,n){if(v){var t=v.props[e];t&&t(n)}}(e,n)}}),b=e.useMemo(function(){var e={};return h.forEach(function(n){e[n]=w.show.bind(null,n)}),e},[]);return e.useEffect(function(){m.update({key:g,src:o,originRef:p,render:w.render,overlay:c,width:d,height:s})},[o]),v?e.Children.only(e.cloneElement(v,i({},b,{ref:p}))):null}; | ||
//# sourceMappingURL=react-photo-view.js.map |
@@ -1,2 +0,2 @@ | ||
import e,{useRef as t,useReducer as n,createContext as o,useEffect as i,useLayoutEffect as r,useMemo as a,useCallback as c,useState as l,useContext as s,useImperativeHandle as d,Children as u,cloneElement as h}from"react";import{createPortal as m}from"react-dom";function f(){return f=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var o in n)({}).hasOwnProperty.call(n,o)&&(e[o]=n[o])}return e},f.apply(null,arguments)}function g(e,t){if(null==e)return{};var n={};for(var o in e)if({}.hasOwnProperty.call(e,o)){if(t.includes(o))continue;n[o]=e[o]}return n}function v(e){const{current:n}=t({fn:e,curr:void 0});if(n.fn=e,!n.curr){const t=Object.create(null);Object.keys(e).forEach(e=>{t[e]=(...t)=>n.fn[e].call(n.fn,...t)}),n.curr=t}return n.curr}function w(e){return n((e,t)=>f({},e,"function"==typeof t?t(e):t),e)}var p=o(void 0);const b="cubic-bezier(0.25, 0.8, 0.25, 1)",y=20,x=1,C="undefined"!=typeof window&&"ontouchstart"in window,E=(e,t,n)=>Math.max(Math.min(e,n),t),_=(e,t=0,n=0)=>E(e,1*(1-n),Math.max(6,t)*(1+n));var P="undefined"==typeof window||/ServerSideRendering/.test(navigator&&navigator.userAgent)?i:r;function R(e,n,o){const r=t(n);r.current=n,i(()=>{function t(e){r.current(e)}return e&&window.addEventListener(e,t,o),()=>{e&&window.removeEventListener(e,t)}},[e])}const k=["container"];function V(t){let{container:n=document.body}=t,o=g(t,k);return m(e.createElement("div",f({},o)),n)}function W(t){return e.createElement("svg",f({width:"44",height:"44",viewBox:"0 0 768 768"},t),e.createElement("path",{d:"M640.5 352.5v63h-390l178.5 180-45 45-256.5-256.5 256.5-256.5 45 45-178.5 180h390z"}))}function S(t){return e.createElement("svg",f({width:"44",height:"44",viewBox:"0 0 768 768"},t),e.createElement("path",{d:"M384 127.5l256.5 256.5-256.5 256.5-45-45 178.5-180h-390v-63h390l-178.5-180z"}))}function $(){return i(()=>{const{style:e}=document.body,t=e.overflow;return e.overflow="hidden",()=>{e.overflow=t}},[]),null}function N(t){return e.createElement("svg",f({width:"44",height:"44",viewBox:"0 0 768 768"},t),e.createElement("path",{d:"M607.5 205.5l-178.5 178.5 178.5 178.5-45 45-178.5-178.5-178.5 178.5-45-45 178.5-178.5-178.5-178.5 45-45 178.5 178.5 178.5-178.5z"}))}function Y({bannerVisible:t,index:n,imageLength:o,toolbarRender:i,overlayParams:r,toolbarLeftRender:a,toolbarRightRender:c}){return e.createElement(e.Fragment,null,t&&e.createElement("div",{className:"PhotoView-Slider__BannerWrap"},e.createElement("div",{className:"PhotoView-Slider__Counter"},n+1," / ",o),e.createElement("div",{className:"PhotoView-Slider__BannerRight"},i&&r&&i(r),e.createElement(N,{className:"PhotoView-Slider__toolbarIcon",onClick:close}))),a&&r&&e.createElement("div",{className:"PhotoView-Slider__Toolbar PhotoView-Slider__Toolbar--Left"},a(r)),c&&r&&e.createElement("div",{className:"PhotoView-Slider__Toolbar PhotoView-Slider__Toolbar--Right"},c(r)))}function X(e){const{clientX:t,clientY:n}=e.touches[0];if(e.touches.length>=2){const{clientX:o,clientY:i}=e.touches[1];return[(t+o)/2,(n+i)/2,Math.sqrt((o-t)**2+(i-n)**2)]}return[t,n,0]}const M=(e,t,n,o)=>{const i=n*t,r=(i-o)/2;let a,c=e;return i<=o?(a=1,c=0):e>0&&r-e<=0?(a=2,c=r):e<0&&r+e<=0&&(a=3,c=-r),[a,c]};function T(e,t,n,o,i,r,a=innerWidth/2,c=innerHeight/2,l=0,s=0){const[d]=M(e,r,n,innerWidth),[u]=M(t,r,o,innerHeight),h=innerWidth/2,m=innerHeight/2;return{x:a-r/i*(a-(h+e))-h+(o/n>=3&&n*r===innerWidth?0:d?l/2:l),y:c-r/i*(c-(m+t))-m+(u?s/2:s),lastCX:a,lastCY:c}}function L(e,t,n){const o=e%180!=0;return o?[n,t,o]:[t,n,o]}function I(e,t,n){const[o,i,r]=L(n,innerWidth,innerHeight);let a=0,c=o,l=i;const s=e/t*i,d=t/e*o;return e<o&&t<i?(c=e,l=t):e<o&&t>=i?c=s:e>=o&&t<i||e/t>o/i?l=d:t/e>=3&&!r?(l=d,a=(l-i)/2):c=s,{width:c,height:l,x:0,y:a,pause:!0}}function A(e,{leading:n=!1,maxWait:o,wait:i=o||0}){const r=t(e);r.current=e;const a=t(0),l=t(),s=()=>l.current&&clearTimeout(l.current),d=c((...e)=>{const t=Date.now();function c(){a.current=t,s(),r.current.apply(null,e)}const d=a.current,u=t-d;if(0===d&&(n&&c(),a.current=t),void 0!==o){if(u>o)return void c()}else u<i&&(a.current=t);s(),l.current=setTimeout(()=>{c(),a.current=0},i)},[i,o,n]);return d.cancel=s,d}const D=(e,t,n)=>O(e,t,n,100,e=>e,()=>O(t,e,n)),F=e=>1-(1-e)**4;function O(e,t,n,o=400,i=F,r){const a=t-e;if(0===a)return;const c=Date.now();let l=0;const s=()=>{const t=Math.min(1,(Date.now()-c)/o);n(e+i(t)*a)&&t<1?d():(cancelAnimationFrame(l),t>=1&&r&&r())};function d(){l=requestAnimationFrame(s)}d()}const H={T:0,L:0,W:0,H:0,FIT:void 0},B=()=>{const e=t(!1);return i(()=>(e.current=!0,()=>{e.current=!1}),[]),e},j=["className"];function z(t){let{className:n=""}=t,o=g(t,j);return e.createElement("div",f({className:`PhotoView__Spinner ${n}`},o),e.createElement("svg",{viewBox:"0 0 32 32",width:"36",height:"36",fill:"white"},e.createElement("path",{opacity:".25",d:"M16 0 A16 16 0 0 0 16 32 A16 16 0 0 0 16 0 M16 4 A12 12 0 0 1 16 28 A12 12 0 0 1 16 4"}),e.createElement("path",{d:"M16 0 A16 16 0 0 1 32 16 L28 16 A12 12 0 0 0 16 4z"})))}const q=["src","loaded","broken","className","onPhotoLoad","loadingElement","brokenElement"];function K(t){let{src:n,loaded:o,broken:i,className:r,onPhotoLoad:a,loadingElement:c,brokenElement:l}=t,s=g(t,q);const d=B();return n&&!i?e.createElement(e.Fragment,null,e.createElement("img",f({className:"PhotoView__Photo"+(r?` ${r}`:""),src:n,onLoad:function(e){const{naturalWidth:t,naturalHeight:n}=e.target;d.current&&a({loaded:!0,naturalWidth:t,naturalHeight:n})},onError:function(){d.current&&a({broken:!0})},alt:""},s)),!o&&(e.createElement("span",{className:"PhotoView__icon"},c)||e.createElement(z,{className:"PhotoView__icon"}))):l?e.createElement("span",{className:"PhotoView__icon"},"function"==typeof l?l({src:n}):l):null}const U={naturalWidth:void 0,naturalHeight:void 0,width:void 0,height:void 0,loaded:void 0,broken:!1,x:0,y:0,touched:!1,maskTouched:!1,rotate:0,scale:1,CX:0,CY:0,lastX:0,lastY:0,lastCX:0,lastCY:0,lastScale:1,touchTime:0,touchLength:0,pause:!0,stopRaf:!0,reach:void 0};function G({item:{src:n,render:o,width:r=0,height:a=0,originRef:c},visible:s,speed:d,easing:u,wrapClassName:h,className:m,style:g,loadingElement:p,brokenElement:b,onPhotoTap:y,onMaskTap:x,onReachMove:E,onReachUp:k,onPhotoResize:V,isActive:W,expose:S}){const[$,N]=w(U),Y=t(0),F=B(),{naturalWidth:j=r,naturalHeight:z=a,width:q=r,height:G=a,loaded:J=!n,broken:Q,x:Z,y:ee,touched:te,stopRaf:ne,maskTouched:oe,rotate:ie,scale:re,CX:ae,CY:ce,lastX:le,lastY:se,lastCX:de,lastCY:ue,lastScale:he,touchTime:me,touchLength:fe,pause:ge,reach:ve}=$,we=v({onScale:e=>pe(_(e)),onRotate(e){ie!==e&&(S({rotate:e}),N(f({rotate:e},I(j,z,e))))}});function pe(e,t,n){re!==e&&(S({scale:e}),N(f({scale:e},T(Z,ee,q,G,re,e,t,n),e<=1&&{x:0,y:0})))}const be=A((e,t,n=0)=>{if((te||oe)&&W){const[o,i]=L(ie,q,G);if(0===n&&0===Y.current){const n=Math.abs(e-ae)<=20,o=Math.abs(t-ce)<=20;if(n&&o)return void N({lastCX:e,lastCY:t});Y.current=n?t>ce?3:2:1}const r=e-de,a=t-ue;let c;if(0===n){const[n]=M(r+le,re,o,innerWidth),[l]=M(a+se,re,i,innerHeight);c=((e,t,n,o)=>t&&1===e||"x"===o?"x":n&&e>1||"y"===o?"y":void 0)(Y.current,n,l,ve),void 0!==c&&E(c,e,t,re)}if("x"===c||oe)return void N({reach:"x"});const l=_(re+(n-fe)/100/2*re,j/q,.2);S({scale:l}),N(f({touchLength:n,reach:c,scale:l},T(Z,ee,q,G,re,l,e,t,r,a)))}},{maxWait:8});function ye(e){return!ne&&!te&&(F.current&&N(f({},e,{pause:s})),F.current)}const xe=function(){const e=v({X:e=>ye({x:e}),Y:e=>ye({y:e}),S:e=>{return t=e,F.current&&(S({scale:t}),N({scale:t})),!te&&F.current;var t}});return(t,n,o,i,r,a,c,l,s,d,u)=>{const[h,m]=L(d,r,a),[f,g]=M(t,l,h,innerWidth),[v,w]=M(n,l,m,innerHeight),p=Date.now()-u;if(p>=200||l!==c||Math.abs(s-c)>1){const{x:o,y:i}=T(t,n,r,a,c,l),s=f?g:o!==t?o:null,d=v?w:i!==n?i:null;return null!==s&&O(t,s,e.X),null!==d&&O(n,d,e.Y),void(l!==c&&O(c,l,e.S))}const b=(t-o)/p,y=(n-i)/p,x=Math.sqrt(b**2+y**2);let C=!1,E=!1;!function(e,t){let n,o=e,i=0,r=0;const a=r=>{n||(n=r);const a=r-n,s=Math.sign(e),d=-.001*s,u=Math.sign(-o)*o**2*2e-4,h=o*a+(d+u)*a**2/2;o+=(d+u)*a,i+=h,n=r,s*o<=0?l():t(i)?c():l()};function c(){r=requestAnimationFrame(a)}function l(){cancelAnimationFrame(r)}c()}(x,o=>{const i=t+o*(b/x),r=n+o*(y/x),[a,l]=M(i,c,h,innerWidth),[s,d]=M(r,c,m,innerHeight);if(a&&!C&&(C=!0,f?O(i,l,e.X):D(l,i+(i-l),e.X)),s&&!E&&(E=!0,v?O(r,d,e.Y):D(d,r+(r-d),e.Y)),C&&E)return!1;const u=C||e.X(l),g=E||e.Y(d);return u&&g})}}(),Ce=function(e){const n=t(0),o=A((...t)=>{n.current=0,e(...t)},{wait:300});return function(...e){n.current+=1,o(...e),n.current>=2&&(o.cancel(),n.current=0,((e,t)=>{ve||pe(1!==re?1:Math.max(2,j/q),e,t)})(...e))}}(y);function Ee(e,t){if(Y.current=0,(te||oe)&&W){N({touched:!1,maskTouched:!1,pause:!1,stopRaf:!1,reach:void 0});const n=_(re,j/q);if(xe(Z,ee,le,se,q,G,re,n,he,ie,me),k(e,t),ae===e&&ce===t){if(te)return void Ce(e,t);oe&&x(e,t)}}}function _e(e,t,n=0){N({touched:!0,CX:e,CY:t,lastCX:e,lastCY:t,lastX:Z,lastY:ee,lastScale:re,touchLength:n,touchTime:Date.now()})}function Pe(e){N({maskTouched:!0,CX:e.clientX,CY:e.clientY,lastX:Z,lastY:ee})}R(C?void 0:"mousemove",e=>{e.preventDefault(),be(e.clientX,e.clientY)}),R(C?void 0:"mouseup",e=>{Ee(e.clientX,e.clientY)}),R(C?"touchmove":void 0,e=>{e.preventDefault();const t=X(e);be(...t)},{passive:!1}),R(C?"touchend":void 0,({changedTouches:e})=>{const t=e[0];Ee(t.clientX,t.clientY)},{passive:!1}),R("resize",A(()=>{J&&!te&&(N(I(j,z,ie)),V())},{maxWait:8})),P(()=>{W&&S(f({scale:re,rotate:ie},we))},[W]);const[Re,ke,Ve,We,Se,$e,Ne,Ye]=function(e,n,o,r,a,c,s,d,u,h){const[m,f,g]=function(e,n,o,i,r){const a=t(!1),[{lead:c,scale:l},s]=w({lead:!0,scale:o}),d=A(async e=>{r(!0),s({lead:!1,scale:e})},{wait:i});return P(()=>{a.current?(r(!1),s({lead:!0}),d(o)):a.current=!0},[o]),c?[e*l,n*l,o/l]:[e*o,n*o,1]}(c,s,d,u,h),[p,b]=function(e,n,o,r,a){const[c,s]=l(H),[d,u]=l(0),h=t(),m=v({OK:()=>e&&u(4)});function f(e){a(!1),u(e)}return i(()=>{if(h.current||(h.current=Date.now()),o){if(function(e,t){const n=e&&e.current;if(n&&1===n.nodeType){const{top:e,left:o,width:i,height:r}=n.getBoundingClientRect();t({T:e,L:o,W:i,H:r,FIT:"IMG"===n.tagName?getComputedStyle(n).objectFit:void 0})}}(n,s),e)return Date.now()-h.current<250?(u(1),requestAnimationFrame(()=>{u(2),requestAnimationFrame(()=>f(3))}),void setTimeout(m.OK,r)):void u(4);f(5)}},[e,o]),[d,c]}(e,n,o,u,h),{T:y,L:x,W:C,H:E,FIT:_}=b,R=innerWidth/2,k=innerHeight/2,V=p<3||p>4;return[V?C?x:R:r+(R-c*d/2),V?C?y:k:a+(k-s*d/2),m,V&&_?m*(E/C):f,0===p?g:V?C/(c*d)||.01:g,V?_?1:0:1,p,_]}(s,c,J,Z,ee,q,G,re,d,e=>N({pause:e})),Xe=`transform ${d}ms ${u}`,Me={className:m,onMouseDown:C?void 0:function(e){e.stopPropagation(),0===e.button&&_e(e.clientX,e.clientY,0)},onTouchStart:C?function(e){e.stopPropagation(),_e(...X(e))}:void 0,onWheel:function(e){if(!ve){const t=_(re-e.deltaY/100/2,j/q);N({stopRaf:!0}),pe(t,e.clientX,e.clientY)}},style:{width:`${Ve}px`,height:`${We}px`,opacity:$e,objectFit:4===Ne?void 0:Ye,transform:ie?`rotate(${ie}deg)`:void 0,transition:Ne>2?`${Xe}, opacity ${d}ms ease, height ${Ne<4?d/2:Ne>4?d:0}ms ${u}`:void 0}};return e.createElement("div",{className:"PhotoView__PhotoWrap"+(h?` ${h}`:""),style:g,onMouseDown:!C&&W?Pe:void 0,onTouchStart:C&&W?e=>Pe(e.touches[0]):void 0},e.createElement("div",{className:"PhotoView__PhotoBox",style:{transform:`matrix(${Se}, 0, 0, ${Se}, ${Re}, ${ke})`,transition:te||ge?void 0:Xe,willChange:W?"transform":void 0}},n?e.createElement(K,f({src:n,loaded:J,broken:Q},Me,{onPhotoLoad:function(e){N(f({},e,e.loaded&&I(e.naturalWidth||0,e.naturalHeight||0,ie)))},loadingElement:p,brokenElement:b})):o&&o({attrs:Me,scale:Se,rotate:ie})))}const J={x:0,touched:!1,pause:!1,lastCX:void 0,lastCY:void 0,bg:void 0,lastBg:void 0,overlay:!0,minimal:!0,scale:1,rotate:0};function Q(o){const{loop:i=3,speed:r,easing:c,photoClosable:s,maskClosable:d=!0,maskOpacity:u=x,pullClosable:h=!0,pullAction:m,bannerVisible:f=!0,overlayRender:g,toolbarRender:p,showBackdropImage:_,disableScroll:k=!0,toolbarLeftRender:N,toolbarRightRender:X,sidebarWidth:M,sidebarLeftRender:T,sidebarRightRender:L,className:I,maskClassName:A,photoClassName:D,photoWrapClassName:F,loadingElement:O,brokenElement:H,images:B,index:j=0,onIndexChange:z,visible:q,onClose:K,afterClose:U,portalContainer:Q}=o,[Z,ee]=w(J),[te,ne]=l(0),{x:oe,touched:ie,pause:re,lastCX:ae,lastCY:ce,bg:le=u,lastBg:se,overlay:de,minimal:ue,scale:he,rotate:me,onScale:fe,onRotate:ge}=Z,ve=o.hasOwnProperty("index"),we=ve?j:te,pe=ve?z:ne,be=t(we),ye=B.length,xe=B[we],Ce="boolean"==typeof i?i:ye>i,[Ee,_e,Pe]=function(e,o){const[,i]=n(e=>!e,!1),r=t(0),[c,l]=function(n){const o=t(n);function i(e){o.current=e}return a(()=>{(t=>{e?(t(e),r.current=1):r.current=2})(i)},[n]),[o.current,i]}(e);return[c,r.current,function(){i(),2===r.current&&(l(!1),o&&o()),r.current=0}]}(q,U);P(()=>{if(Ee)return ee({pause:!0,x:we*-(innerWidth+y)}),void(be.current=we);ee(J)},[Ee]);const{close:Re,changeIndex:ke}=v({close(e){ge&&ge(0),ee({overlay:!0,lastBg:le}),K(e)},changeIndex(e,t=!1){const n=Ce?be.current+(e-we):e,o=ye-1,i=E(n,0,o),r=Ce?n:i,a=innerWidth+y;ee({touched:!1,lastCX:void 0,lastCY:void 0,x:-a*r,pause:t}),be.current=r,pe&&pe(Ce?e<0?o:e>o?0:e:i)}});function Ve(e){return e?Re():ee({overlay:!de})}function We(){ee({x:-(innerWidth+y)*we,lastCX:void 0,lastCY:void 0,pause:!0}),be.current=we}function Se(e,t,n,o){"x"===e?function(e){if(void 0===ae)return void ee({touched:!0,lastCX:e,x:oe,pause:!1});const t=e-ae;let n=t;!Ce&&(0===we&&t>0||we===ye-1&&t<0)&&(n=t/2),ee({touched:!0,lastCX:ae,x:-(innerWidth+y)*be.current+n,pause:!1})}(t):"y"===e&&function(e,t){if(void 0===ce)return void ee({touched:!0,lastCY:e,bg:le,minimal:!0});const n=null===u?null:E(u,.01,u-Math.abs(e-ce)/100/4);ee({touched:!0,lastCY:ce,bg:1===t?n:u,minimal:1===t})}(n,o)}function $e(e,t){const n=e-(null!=ae?ae:e),o=t-(null!=ce?ce:t);let i=!1;if(n<-40)return void ke(we+1);if(n>40)return void ke(we-1);const r=-(innerWidth+y)*be.current;Math.abs(o)>100&&ue&&h?(i=!0,Re()):Math.abs(o)>100&&ue&&"function"==typeof m&&m({direction:o<0?"top":"bottom",offsetY:o}),ee({touched:!1,x:r,lastCX:void 0,lastCY:void 0,bg:u,overlay:!!i||de})}R("keydown",e=>{if(q)switch(e.key){case"ArrowLeft":ke(we-1,!1);break;case"ArrowRight":ke(we+1,!1);break;case"Escape":Re()}});const Ne=function(e,t,n){return a(()=>{const o=e.length;return n?e.concat(e).concat(e).slice(o+t-1,o+t+2):e.slice(Math.max(t-1,0),Math.min(t+2,o+1))},[e,t,n])}(B,we,Ce);if(!Ee)return null;const Ye=de&&!_e,Xe=q?le:se,Me=fe&&ge&&{images:B,index:we,visible:q,onClose:Re,onIndexChange:ke,overlayVisible:Ye,overlay:xe&&xe.overlay,scale:he,rotate:me,onScale:fe,onRotate:ge},Te=r?r(_e):400,Le=c?c(_e):b,Ie=r?r(3):600,Ae=c?c(3):b,De="number"==typeof M?`${M}px`:M,Fe=innerWidth<=900;return e.createElement(V,{className:`PhotoView-Portal${Ye?"":" PhotoView-Slider__clean"}${q?"":" PhotoView-Slider__willClose"}${I?` ${I}`:""}`,role:"dialog",onClick:e=>e.stopPropagation(),container:Q},q&&k&&e.createElement($,null),e.createElement("div",{className:"PhotoView-Container"},T&&Me&&!Fe&&e.createElement("div",{className:"PhotoView-Sidebar PhotoView-Sidebar__Left "+(1===_e?" PhotoView-Slider__fadeIn":2===_e?" PhotoView-Slider__fadeOut":""),style:{width:De,transitionTimingFunction:Le,transitionDuration:`${ie?0:Te}ms`,animationDuration:`${Te}ms`}},T(Me)),e.createElement("div",{className:"PhotoView-Viewer"},e.createElement("div",{className:`PhotoView-Slider__Backdrop${A?` ${A}`:""}${1===_e?" PhotoView-Slider__fadeIn":2===_e?" PhotoView-Slider__fadeOut":""} ${_?"with-backdrop-image":""}`,style:{background:_?`url(${xe.src})`:Xe?`rgba(0, 0, 0, ${Xe})`:void 0,transitionTimingFunction:Le,transitionDuration:`${ie?0:Te}ms`,animationDuration:`${Te}ms`},onAnimationEnd:Pe}),e.createElement(Y,{bannerVisible:f,index:we,imageLength:ye,overlayParams:Me,toolbarRender:p,toolbarLeftRender:N,toolbarRightRender:X}),Ne.map((t,n)=>{const o=Ce||0!==we?be.current-1+n:we+n;return e.createElement(G,{key:Ce?`${t.key}/${t.src}/${o}`:t.key,item:t,speed:Te,easing:Le,visible:q,onReachMove:Se,onReachUp:$e,onPhotoTap:()=>Ve(s),onMaskTap:()=>Ve(d),wrapClassName:F,className:D,style:{left:(innerWidth+y)*o+"px",transform:`translate3d(${oe}px, 0px, 0)`,transition:ie||re?void 0:`transform ${Ie}ms ${Ae}`},loadingElement:O,brokenElement:H,onPhotoResize:We,isActive:be.current===o,expose:ee})}),!C&&f&&e.createElement(e.Fragment,null,(Ce||0!==we)&&e.createElement("div",{className:"PhotoView-Slider__ArrowLeft",onClick:()=>ke(we-1,!0)},e.createElement(W,null)),(Ce||we+1<ye)&&e.createElement("div",{className:"PhotoView-Slider__ArrowRight",onClick:()=>ke(we+1,!0)},e.createElement(S,null))),g&&Me&&e.createElement("div",{className:"PhotoView-Slider__Overlay"},g(Me))),L&&Me&&!Fe&&e.createElement("div",{className:"PhotoView-Sidebar PhotoView-Sidebar__Right "+(1===_e?" PhotoView-Slider__fadeIn":2===_e?" PhotoView-Slider__fadeOut":""),style:{width:De,transitionTimingFunction:Le,transitionDuration:`${ie?0:Te}ms`,animationDuration:`${Te}ms`}},L(Me))))}const Z=["children","onIndexChange","onVisibleChange","sidebarLeftRender","sidebarRightRender","sidebarWidth"],ee={images:[],visible:!1,index:0};function te(n){let{children:o,onIndexChange:r,onVisibleChange:c,sidebarLeftRender:l,sidebarRightRender:s,sidebarWidth:d=400}=n,u=g(n,Z);const[h,m]=w(ee),b=t(0),{images:y,visible:x,index:C}=h;i(()=>{if(!l&&!s)return;const e=Object.getOwnPropertyDescriptor(window,"innerWidth");!e||e.configurable?Object.defineProperty(window,"innerWidth",{get:()=>window.outerWidth<=900?window.outerWidth:window.outerWidth-d,configurable:!0,enumerable:!0}):console.warn("innerWidth is already defined and is not configurable")},[]);const E=v({nextId:()=>b.current+=1,update(e){const t=y.findIndex(t=>t.key===e.key);if(t>-1){const n=y.slice();return n.splice(t,1,e),void m({images:n})}m(t=>({images:t.images.concat(e)}))},remove(e){m(t=>{const n=t.images.filter(t=>t.key!==e);return{images:n,index:Math.min(n.length-1,C)}})},show(e){const t=y.findIndex(t=>t.key===e);m({visible:!0,index:t}),c&&c(!0,t,h)}}),_=v({close(){m({visible:!1}),c&&c(!1,C,h)},changeIndex(e){m({index:e}),r&&r(e,h)}}),P=a(()=>f({},h,E),[h,E]);return e.createElement(p.Provider,{value:P},o,e.createElement(Q,f({images:y,visible:x,index:C,onIndexChange:_.changeIndex,onClose:_.close,sidebarWidth:d,sidebarLeftRender:l,sidebarRightRender:s},u)))}const ne=({src:e,render:n,overlay:o,width:r,height:c,triggers:l=["onClick"],children:m})=>{const g=s(p),w=function(){const{current:e}=t({sign:!1,fn:void 0});return e.sign||(e.sign=!0,e.fn=g.nextId()),e.fn}(),b=t(null);d(null==m?void 0:m.ref,()=>b.current),i(()=>()=>{g.remove(w)},[]);const y=v({render:e=>n&&n(e),show(e,t){g.show(w),function(e,t){if(m){const n=m.props[e];n&&n(t)}}(e,t)}}),x=a(()=>{const e={};return l.forEach(t=>{e[t]=y.show.bind(null,t)}),e},[]);return i(()=>{g.update({key:w,src:e,originRef:b,render:y.render,overlay:o,width:r,height:c})},[e]),m?u.only(h(m,f({},x,{ref:b}))):null};export{te as PhotoProvider,Q as PhotoSlider,ne as PhotoView}; | ||
import e,{useRef as t,useReducer as n,createContext as o,useEffect as r,useLayoutEffect as i,useMemo as a,useCallback as c,useState as l,useContext as s,useImperativeHandle as u,Children as d,cloneElement as h}from"react";import{createPortal as m}from"react-dom";function f(){return f=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var o in n)({}).hasOwnProperty.call(n,o)&&(e[o]=n[o])}return e},f.apply(null,arguments)}function g(e,t){if(null==e)return{};var n={};for(var o in e)if({}.hasOwnProperty.call(e,o)){if(t.includes(o))continue;n[o]=e[o]}return n}function v(e){const{current:n}=t({fn:e,curr:void 0});if(n.fn=e,!n.curr){const t=Object.create(null);Object.keys(e).forEach(e=>{t[e]=(...t)=>n.fn[e].call(n.fn,...t)}),n.curr=t}return n.curr}function w(e){return n((e,t)=>f({},e,"function"==typeof t?t(e):t),e)}var p=o(void 0);const b="cubic-bezier(0.25, 0.8, 0.25, 1)",y=20,x=1,E="undefined"!=typeof window&&"ontouchstart"in window,C=(e,t,n)=>Math.max(Math.min(e,n),t),_=(e,t=0,n=0)=>C(e,1*(1-n),Math.max(6,t)*(1+n));var P="undefined"==typeof window||/ServerSideRendering/.test(navigator&&navigator.userAgent)?r:i;function S(e,n,o){const i=t(n);i.current=n,r(()=>{function t(e){i.current(e)}return e&&window.addEventListener(e,t,o),()=>{e&&window.removeEventListener(e,t)}},[e])}const R=["container"];function k(t){let{container:n=document.body}=t,o=g(t,R);return m(e.createElement("div",f({},o)),n)}function V(t){return e.createElement("svg",f({width:"44",height:"44",viewBox:"0 0 768 768"},t),e.createElement("path",{d:"M640.5 352.5v63h-390l178.5 180-45 45-256.5-256.5 256.5-256.5 45 45-178.5 180h390z"}))}function W(t){return e.createElement("svg",f({width:"44",height:"44",viewBox:"0 0 768 768"},t),e.createElement("path",{d:"M384 127.5l256.5 256.5-256.5 256.5-45-45 178.5-180h-390v-63h390l-178.5-180z"}))}function $(){return r(()=>{const{style:e}=document.body,t=e.overflow;return e.overflow="hidden",()=>{e.overflow=t}},[]),null}function N(t){return e.createElement("svg",f({width:"44",height:"44",viewBox:"0 0 768 768"},t),e.createElement("path",{d:"M607.5 205.5l-178.5 178.5 178.5 178.5-45 45-178.5-178.5-178.5 178.5-45-45 178.5-178.5-178.5-178.5 45-45 178.5 178.5 178.5-178.5z"}))}function Y({bannerVisible:t,index:n,imageLength:o,toolbarRender:r,overlayParams:i,toolbarLeftRender:a,toolbarRightRender:c}){return e.createElement(e.Fragment,null,t&&e.createElement("div",{className:"PhotoView-Slider__BannerWrap"},e.createElement("div",{className:"PhotoView-Slider__Counter"},n+1," / ",o),e.createElement("div",{className:"PhotoView-Slider__BannerRight"},r&&i&&r(i),e.createElement(N,{className:"PhotoView-Slider__toolbarIcon",onClick:close}))),a&&i&&e.createElement("div",{className:"PhotoView-Slider__Toolbar PhotoView-Slider__Toolbar--Left"},a(i)),c&&i&&e.createElement("div",{className:"PhotoView-Slider__Toolbar PhotoView-Slider__Toolbar--Right"},c(i)))}function X(e){const{clientX:t,clientY:n}=e.touches[0];if(e.touches.length>=2){const{clientX:o,clientY:r}=e.touches[1];return[(t+o)/2,(n+r)/2,Math.sqrt((o-t)**2+(r-n)**2)]}return[t,n,0]}const M=(e,t,n,o)=>{const r=n*t,i=(r-o)/2;let a,c=e;return r<=o?(a=1,c=0):e>0&&i-e<=0?(a=2,c=i):e<0&&i+e<=0&&(a=3,c=-i),[a,c]};function T(e,t,n,o,r,i,a=innerWidth/2,c=innerHeight/2,l=0,s=0){const[u]=M(e,i,n,innerWidth),[d]=M(t,i,o,innerHeight),h=innerWidth/2,m=innerHeight/2;return{x:a-i/r*(a-(h+e))-h+(o/n>=3&&n*i===innerWidth?0:u?l/2:l),y:c-i/r*(c-(m+t))-m+(d?s/2:s),lastCX:a,lastCY:c}}function L(e,t,n){const o=e%180!=0;return o?[n,t,o]:[t,n,o]}function F(e,t,n){const[o,r,i]=L(n,innerWidth,innerHeight);let a=0,c=o,l=r;const s=e/t*r,u=t/e*o;return e<o&&t<r?(c=e,l=t):e<o&&t>=r?c=s:e>=o&&t<r||e/t>o/r?l=u:t/e>=3&&!i?(l=u,a=(l-r)/2):c=s,{width:c,height:l,x:0,y:a,pause:!0}}function I(e,{leading:n=!1,maxWait:o,wait:r=o||0}){const i=t(e);i.current=e;const a=t(0),l=t(),s=()=>l.current&&clearTimeout(l.current),u=c((...e)=>{const t=Date.now();function c(){a.current=t,s(),i.current.apply(null,e)}const u=a.current,d=t-u;if(0===u&&(n&&c(),a.current=t),void 0!==o){if(d>o)return void c()}else d<r&&(a.current=t);s(),l.current=setTimeout(()=>{c(),a.current=0},r)},[r,o,n]);return u.cancel=s,u}const A=(e,t,n)=>O(e,t,n,100,e=>e,()=>O(t,e,n)),D=e=>1-(1-e)**4;function O(e,t,n,o=400,r=D,i){const a=t-e;if(0===a)return;const c=Date.now();let l=0;const s=()=>{const t=Math.min(1,(Date.now()-c)/o);n(e+r(t)*a)&&t<1?u():(cancelAnimationFrame(l),t>=1&&i&&i())};function u(){l=requestAnimationFrame(s)}u()}const H={T:0,L:0,W:0,H:0,FIT:void 0},B=()=>{const e=t(!1);return r(()=>(e.current=!0,()=>{e.current=!1}),[]),e},j=["className"];function z(t){let{className:n=""}=t,o=g(t,j);return e.createElement("div",f({className:`PhotoView__Spinner ${n}`},o),e.createElement("svg",{viewBox:"0 0 32 32",width:"36",height:"36",fill:"white"},e.createElement("path",{opacity:".25",d:"M16 0 A16 16 0 0 0 16 32 A16 16 0 0 0 16 0 M16 4 A12 12 0 0 1 16 28 A12 12 0 0 1 16 4"}),e.createElement("path",{d:"M16 0 A16 16 0 0 1 32 16 L28 16 A12 12 0 0 0 16 4z"})))}const q=["src","loaded","broken","className","onPhotoLoad","loadingElement","brokenElement"];function K(t){let{src:n,loaded:o,broken:r,className:i,onPhotoLoad:a,loadingElement:c,brokenElement:l}=t,s=g(t,q);const u=B();return n&&!r?e.createElement(e.Fragment,null,e.createElement("img",f({className:"PhotoView__Photo"+(i?` ${i}`:""),src:n,onLoad:function(e){const{naturalWidth:t,naturalHeight:n}=e.target;u.current&&a({loaded:!0,naturalWidth:t,naturalHeight:n})},onError:function(){u.current&&a({broken:!0})},alt:""},s)),!o&&(e.createElement("span",{className:"PhotoView__icon"},c)||e.createElement(z,{className:"PhotoView__icon"}))):l?e.createElement("span",{className:"PhotoView__icon"},"function"==typeof l?l({src:n}):l):null}const U={naturalWidth:void 0,naturalHeight:void 0,width:void 0,height:void 0,loaded:void 0,broken:!1,x:0,y:0,touched:!1,maskTouched:!1,rotate:0,scale:1,CX:0,CY:0,lastX:0,lastY:0,lastCX:0,lastCY:0,lastScale:1,touchTime:0,touchLength:0,pause:!0,stopRaf:!0,reach:void 0};function G({item:{src:n,render:o,width:i=0,height:a=0,originRef:c},visible:s,speed:u,easing:d,wrapClassName:h,className:m,style:g,loadingElement:p,brokenElement:b,onPhotoTap:y,onMaskTap:x,onReachMove:C,onReachUp:R,onPhotoResize:k,isActive:V,expose:W}){const[$,N]=w(U),Y=t(0),D=B(),{naturalWidth:j=i,naturalHeight:z=a,width:q=i,height:G=a,loaded:J=!n,broken:Q,x:Z,y:ee,touched:te,stopRaf:ne,maskTouched:oe,rotate:re,scale:ie,CX:ae,CY:ce,lastX:le,lastY:se,lastCX:ue,lastCY:de,lastScale:he,touchTime:me,touchLength:fe,pause:ge,reach:ve}=$,we=v({onScale:e=>pe(_(e)),onRotate(e){re!==e&&(W({rotate:e}),N(f({rotate:e},F(j,z,e))))}});function pe(e,t,n){ie!==e&&(W({scale:e}),N(f({scale:e},T(Z,ee,q,G,ie,e,t,n),e<=1&&{x:0,y:0})))}const be=I((e,t,n=0)=>{if((te||oe)&&V){const[o,r]=L(re,q,G);if(0===n&&0===Y.current){const n=Math.abs(e-ae)<=20,o=Math.abs(t-ce)<=20;if(n&&o)return void N({lastCX:e,lastCY:t});Y.current=n?t>ce?3:2:1}const i=e-ue,a=t-de;let c;if(0===n){const[n]=M(i+le,ie,o,innerWidth),[l]=M(a+se,ie,r,innerHeight);c=((e,t,n,o)=>t&&1===e||"x"===o?"x":n&&e>1||"y"===o?"y":void 0)(Y.current,n,l,ve),void 0!==c&&C(c,e,t,ie)}if("x"===c||oe)return void N({reach:"x"});const l=_(ie+(n-fe)/100/2*ie,j/q,.2);W({scale:l}),N(f({touchLength:n,reach:c,scale:l},T(Z,ee,q,G,ie,l,e,t,i,a)))}},{maxWait:8});function ye(e){return!ne&&!te&&(D.current&&N(f({},e,{pause:s})),D.current)}const xe=function(){const e=v({X:e=>ye({x:e}),Y:e=>ye({y:e}),S:e=>{return t=e,D.current&&(W({scale:t}),N({scale:t})),!te&&D.current;var t}});return(t,n,o,r,i,a,c,l,s,u,d)=>{const[h,m]=L(u,i,a),[f,g]=M(t,l,h,innerWidth),[v,w]=M(n,l,m,innerHeight),p=Date.now()-d;if(p>=200||l!==c||Math.abs(s-c)>1){const{x:o,y:r}=T(t,n,i,a,c,l),s=f?g:o!==t?o:null,u=v?w:r!==n?r:null;return null!==s&&O(t,s,e.X),null!==u&&O(n,u,e.Y),void(l!==c&&O(c,l,e.S))}const b=(t-o)/p,y=(n-r)/p,x=Math.sqrt(b**2+y**2);let E=!1,C=!1;!function(e,t){let n,o=e,r=0,i=0;const a=i=>{n||(n=i);const a=i-n,s=Math.sign(e),u=-.001*s,d=Math.sign(-o)*o**2*2e-4,h=o*a+(u+d)*a**2/2;o+=(u+d)*a,r+=h,n=i,s*o<=0?l():t(r)?c():l()};function c(){i=requestAnimationFrame(a)}function l(){cancelAnimationFrame(i)}c()}(x,o=>{const r=t+o*(b/x),i=n+o*(y/x),[a,l]=M(r,c,h,innerWidth),[s,u]=M(i,c,m,innerHeight);if(a&&!E&&(E=!0,f?O(r,l,e.X):A(l,r+(r-l),e.X)),s&&!C&&(C=!0,v?O(i,u,e.Y):A(u,i+(i-u),e.Y)),E&&C)return!1;const d=E||e.X(l),g=C||e.Y(u);return d&&g})}}(),Ee=function(e){const n=t(0),o=I((...t)=>{n.current=0,e(...t)},{wait:300});return function(...e){n.current+=1,o(...e),n.current>=2&&(o.cancel(),n.current=0,((e,t)=>{ve||pe(1!==ie?1:Math.max(2,j/q),e,t)})(...e))}}(y);function Ce(e,t){if(Y.current=0,(te||oe)&&V){N({touched:!1,maskTouched:!1,pause:!1,stopRaf:!1,reach:void 0});const n=_(ie,j/q);if(xe(Z,ee,le,se,q,G,ie,n,he,re,me),R(e,t),ae===e&&ce===t){if(te)return void Ee(e,t);oe&&x(e,t)}}}function _e(e,t,n=0){N({touched:!0,CX:e,CY:t,lastCX:e,lastCY:t,lastX:Z,lastY:ee,lastScale:ie,touchLength:n,touchTime:Date.now()})}function Pe(e){N({maskTouched:!0,CX:e.clientX,CY:e.clientY,lastX:Z,lastY:ee})}S(E?void 0:"mousemove",e=>{e.preventDefault(),be(e.clientX,e.clientY)}),S(E?void 0:"mouseup",e=>{Ce(e.clientX,e.clientY)}),S(E?"touchmove":void 0,e=>{e.preventDefault();const t=X(e);be(...t)},{passive:!1}),S(E?"touchend":void 0,({changedTouches:e})=>{const t=e[0];Ce(t.clientX,t.clientY)},{passive:!1}),S("resize",I(()=>{J&&!te&&(N(F(j,z,re)),k())},{maxWait:8})),P(()=>{V&&W(f({scale:ie,rotate:re},we))},[V]);const[Se,Re,ke,Ve,We,$e,Ne,Ye]=function(e,n,o,i,a,c,s,u,d,h){const[m,f,g]=function(e,n,o,r,i){const a=t(!1),[{lead:c,scale:l},s]=w({lead:!0,scale:o}),u=I(async e=>{i(!0),s({lead:!1,scale:e})},{wait:r});return P(()=>{a.current?(i(!1),s({lead:!0}),u(o)):a.current=!0},[o]),c?[e*l,n*l,o/l]:[e*o,n*o,1]}(c,s,u,d,h),[p,b]=function(e,n,o,i,a){const[c,s]=l(H),[u,d]=l(0),h=t(),m=v({OK:()=>e&&d(4)});function f(e){a(!1),d(e)}return r(()=>{if(h.current||(h.current=Date.now()),o){if(function(e,t){const n=e&&e.current;if(n&&1===n.nodeType){const{top:e,left:o,width:r,height:i}=n.getBoundingClientRect();t({T:e,L:o,W:r,H:i,FIT:"IMG"===n.tagName?getComputedStyle(n).objectFit:void 0})}}(n,s),e)return Date.now()-h.current<250?(d(1),requestAnimationFrame(()=>{d(2),requestAnimationFrame(()=>f(3))}),void setTimeout(m.OK,i)):void d(4);f(5)}},[e,o]),[u,c]}(e,n,o,d,h),{T:y,L:x,W:E,H:C,FIT:_}=b,S=innerWidth/2,R=innerHeight/2,k=p<3||p>4;return[k?E?x:S:i+(S-c*u/2),k?E?y:R:a+(R-s*u/2),m,k&&_?m*(C/E):f,0===p?g:k?E/(c*u)||.01:g,k?_?1:0:1,p,_]}(s,c,J,Z,ee,q,G,ie,u,e=>N({pause:e})),Xe=`transform ${u}ms ${d}`,Me={className:m,onMouseDown:E?void 0:function(e){e.stopPropagation(),0===e.button&&_e(e.clientX,e.clientY,0)},onTouchStart:E?function(e){e.stopPropagation(),_e(...X(e))}:void 0,onWheel:function(e){if(!ve){const t=_(ie-e.deltaY/100/2,j/q);N({stopRaf:!0}),pe(t,e.clientX,e.clientY)}},style:{width:`${ke}px`,height:`${Ve}px`,opacity:$e,objectFit:4===Ne?void 0:Ye,transform:re?`rotate(${re}deg)`:void 0,transition:Ne>2?`${Xe}, opacity ${u}ms ease, height ${Ne<4?u/2:Ne>4?u:0}ms ${d}`:void 0}};return e.createElement("div",{className:"PhotoView__PhotoWrap"+(h?` ${h}`:""),style:g,onMouseDown:!E&&V?Pe:void 0,onTouchStart:E&&V?e=>Pe(e.touches[0]):void 0},e.createElement("div",{className:"PhotoView__PhotoBox",style:{transform:`matrix(${We}, 0, 0, ${We}, ${Se}, ${Re})`,transition:te||ge?void 0:Xe,willChange:V?"transform":void 0}},n?e.createElement(K,f({src:n,loaded:J,broken:Q},Me,{onPhotoLoad:function(e){N(f({},e,e.loaded&&F(e.naturalWidth||0,e.naturalHeight||0,re)))},loadingElement:p,brokenElement:b})):o&&o({attrs:Me,scale:We,rotate:re})))}const J={x:0,touched:!1,pause:!1,lastCX:void 0,lastCY:void 0,bg:void 0,lastBg:void 0,overlay:!0,minimal:!0,scale:1,rotate:0};function Q(o){const{loop:i=3,speed:s,easing:u,photoClosable:d,maskClosable:h=!0,maskOpacity:m=x,pullClosable:f=!0,pullAction:g,bannerVisible:p=!0,overlayRender:_,toolbarRender:R,showBackdropImage:N,disableScroll:X=!0,toolbarLeftRender:M,toolbarRightRender:T,sidebarWidth:L,sidebarLeftRender:F,sidebarRightRender:I,className:A,maskClassName:D,photoClassName:O,photoWrapClassName:H,loadingElement:B,brokenElement:j,images:z,index:q=0,onIndexChange:K,visible:U,onClose:Q,afterClose:Z,portalContainer:ee,fullScreen:te,onFullScreen:ne}=o,oe=t(),[re,ie]=w(J),[ae,ce]=l(0),{x:le,touched:se,pause:ue,lastCX:de,lastCY:he,bg:me=m,lastBg:fe,overlay:ge,minimal:ve,scale:we,rotate:pe,onScale:be,onRotate:ye}=re,xe=o.hasOwnProperty("index"),Ee=xe?q:ae,Ce=xe?K:ce,_e=t(Ee),Pe=z.length,Se=z[Ee],Re="boolean"==typeof i?i:Pe>i,[ke,Ve,We]=function(e,o){const[,r]=n(e=>!e,!1),i=t(0),[c,l]=function(n){const o=t(n);function r(e){o.current=e}return a(()=>{(t=>{e?(t(e),i.current=1):i.current=2})(r)},[n]),[o.current,r]}(e);return[c,i.current,function(){r(),2===i.current&&(l(!1),o&&o()),i.current=0}]}(U,Z);P(()=>{if(ke)return ie({pause:!0,x:Ee*-(innerWidth+y)}),void(_e.current=Ee);ie(J)},[ke]);const{close:$e,changeIndex:Ne}=v({close(e){ye&&ye(0),ie({overlay:!0,lastBg:me}),Q(e)},changeIndex(e,t=!1){const n=Re?_e.current+(e-Ee):e,o=Pe-1,r=C(n,0,o),i=Re?n:r,a=innerWidth+y;ie({touched:!1,lastCX:void 0,lastCY:void 0,x:-a*i,pause:t}),_e.current=i,Ce&&Ce(Re?e<0?o:e>o?0:e:r)}}),Ye=c(()=>{ne(!te)},[te,ne]),Xe=a(()=>()=>{!document.fullscreenElement&&te&&Ye()},[te,Ye]),Me=a(()=>()=>{if(document.fullscreenElement)document.exitFullscreen();else if(te){const e=oe.current;if(!e)return;e.requestFullscreen().then(()=>{}).catch(e=>{console.log("Error al intentar activar el modo de pantalla completa",e)})}},[te]);function Te(e){return e?$e():ie({overlay:!ge})}function Le(){ie({x:-(innerWidth+y)*Ee,lastCX:void 0,lastCY:void 0,pause:!0}),_e.current=Ee}function Fe(e,t,n,o){"x"===e?function(e){if(void 0===de)return void ie({touched:!0,lastCX:e,x:le,pause:!1});const t=e-de;let n=t;!Re&&(0===Ee&&t>0||Ee===Pe-1&&t<0)&&(n=t/2),ie({touched:!0,lastCX:de,x:-(innerWidth+y)*_e.current+n,pause:!1})}(t):"y"===e&&function(e,t){if(void 0===he)return void ie({touched:!0,lastCY:e,bg:me,minimal:!0});const n=null===m?null:C(m,.01,m-Math.abs(e-he)/100/4);ie({touched:!0,lastCY:he,bg:1===t?n:m,minimal:1===t})}(n,o)}function Ie(e,t){const n=e-(null!=de?de:e),o=t-(null!=he?he:t);let r=!1;if(n<-40)return void Ne(Ee+1);if(n>40)return void Ne(Ee-1);const i=-(innerWidth+y)*_e.current;Math.abs(o)>100&&ve&&f?(r=!0,$e()):Math.abs(o)>100&&ve&&"function"==typeof g&&g({direction:o<0?"top":"bottom",offsetY:o}),ie({touched:!1,x:i,lastCX:void 0,lastCY:void 0,bg:m,overlay:!!r||ge})}r(()=>{if(oe.current)return Me(),document.addEventListener("fullscreenchange",Xe),()=>{document.removeEventListener("fullscreenchange",Xe)}},[te,Xe,Me]),S("keydown",e=>{if(U)switch(e.key){case"ArrowLeft":Ne(Ee-1,!1);break;case"ArrowRight":Ne(Ee+1,!1);break;case"Escape":$e()}});const Ae=function(e,t,n){return a(()=>{const o=e.length;return n?e.concat(e).concat(e).slice(o+t-1,o+t+2):e.slice(Math.max(t-1,0),Math.min(t+2,o+1))},[e,t,n])}(z,Ee,Re);if(!ke)return null;const De=ge&&!Ve,Oe=U?me:fe,He=be&&ye&&{images:z,index:Ee,visible:U,onClose:$e,onIndexChange:Ne,overlayVisible:De,overlay:Se&&Se.overlay,scale:we,rotate:pe,onScale:be,onRotate:ye,toggleFullScreen:()=>ne(!te)},Be=s?s(Ve):400,je=u?u(Ve):b,ze=s?s(3):600,qe=u?u(3):b,Ke="number"==typeof L?`${L}px`:L,Ue=innerWidth<=900;return e.createElement(k,{className:`PhotoView-Portal${De?"":" PhotoView-Slider__clean"}${U?"":" PhotoView-Slider__willClose"}${A?` ${A}`:""}`,role:"dialog",onClick:e=>e.stopPropagation(),container:ee},U&&X&&e.createElement($,null),e.createElement("div",{className:"PhotoView-Container"},F&&He&&!Ue&&e.createElement("div",{className:"PhotoView-Sidebar PhotoView-Sidebar__Left "+(1===Ve?" PhotoView-Slider__fadeIn":2===Ve?" PhotoView-Slider__fadeOut":""),style:{width:Ke,transitionTimingFunction:je,transitionDuration:`${se?0:Be}ms`,animationDuration:`${Be}ms`}},F(He)),e.createElement("div",{ref:oe,className:"PhotoView-Viewer"},e.createElement("div",{className:`PhotoView-Slider__Backdrop${D?` ${D}`:""}${1===Ve?" PhotoView-Slider__fadeIn":2===Ve?" PhotoView-Slider__fadeOut":""} ${N?"with-backdrop-image":""}`,style:{background:N?`url(${Se.src})`:Oe?`rgba(0, 0, 0, ${Oe})`:void 0,transitionTimingFunction:je,transitionDuration:`${se?0:Be}ms`,animationDuration:`${Be}ms`},onAnimationEnd:We}),e.createElement(Y,{bannerVisible:p,index:Ee,imageLength:Pe,overlayParams:He,toolbarRender:R,toolbarLeftRender:M,toolbarRightRender:T}),Ae.map((t,n)=>{const o=Re||0!==Ee?_e.current-1+n:Ee+n;return e.createElement(G,{key:Re?`${t.key}/${t.src}/${o}`:t.key,item:t,speed:Be,easing:je,visible:U,onReachMove:Fe,onReachUp:Ie,onPhotoTap:()=>Te(d),onMaskTap:()=>Te(h),wrapClassName:H,className:O,style:{left:(innerWidth+y)*o+"px",transform:`translate3d(${le}px, 0px, 0)`,transition:se||ue?void 0:`transform ${ze}ms ${qe}`},loadingElement:B,brokenElement:j,onPhotoResize:Le,isActive:_e.current===o,expose:ie})}),!E&&p&&e.createElement(e.Fragment,null,(Re||0!==Ee)&&e.createElement("div",{className:"PhotoView-Slider__ArrowLeft",onClick:()=>Ne(Ee-1,!0)},e.createElement(V,null)),(Re||Ee+1<Pe)&&e.createElement("div",{className:"PhotoView-Slider__ArrowRight",onClick:()=>Ne(Ee+1,!0)},e.createElement(W,null))),_&&He&&e.createElement("div",{className:"PhotoView-Slider__Overlay"},_(He))),I&&He&&!Ue&&e.createElement("div",{className:"PhotoView-Sidebar PhotoView-Sidebar__Right "+(1===Ve?" PhotoView-Slider__fadeIn":2===Ve?" PhotoView-Slider__fadeOut":""),style:{width:Ke,transitionTimingFunction:je,transitionDuration:`${se?0:Be}ms`,animationDuration:`${Be}ms`}},I(He))))}const Z=["children","onIndexChange","onVisibleChange","sidebarLeftRender","sidebarRightRender","sidebarWidth"],ee={images:[],visible:!1,index:0,fullScreen:!1};function te(n){let{children:o,onIndexChange:i,onVisibleChange:l,sidebarLeftRender:s,sidebarRightRender:u,sidebarWidth:d=400}=n,h=g(n,Z);const[m,b]=w(ee),y=t(0),x=t(!1),{images:E,visible:C,index:_}=m,P=c(()=>{if(!s&&!u)return;const e=Object.getOwnPropertyDescriptor(window,"innerWidth");!e||e.configurable||x.current!==m.fullScreen?(Object.defineProperty(window,"innerWidth",{get:()=>window.outerWidth<=900||m.fullScreen?window.outerWidth:window.outerWidth-d,configurable:!0,enumerable:!0}),x.current=m.fullScreen):console.warn("innerWidth is already defined and is not configurable")},[s,u,m.fullScreen,d]);r(()=>{P()},[]),r(()=>{P()},[m.fullScreen,P]);const S=v({nextId:()=>y.current+=1,update(e){const t=E.findIndex(t=>t.key===e.key);if(t>-1){const n=E.slice();return n.splice(t,1,e),void b({images:n})}b(t=>({images:t.images.concat(e)}))},remove(e){b(t=>{const n=t.images.filter(t=>t.key!==e);return{images:n,index:Math.min(n.length-1,_)}})},show(e){const t=E.findIndex(t=>t.key===e);b({visible:!0,index:t}),l&&l(!0,t,m)}}),R=v({close(){b({visible:!1}),l&&l(!1,_,m)},changeIndex(e){b({index:e}),i&&i(e,m)},fullScreen(e){b({fullScreen:e})}}),k=a(()=>f({},m,S),[m,S]);return e.createElement(p.Provider,{value:k},o,e.createElement(Q,f({images:E,visible:C,index:_,fullScreen:m.fullScreen,onIndexChange:R.changeIndex,onClose:R.close,onFullScreen:R.fullScreen,sidebarWidth:d,sidebarLeftRender:s,sidebarRightRender:u},h)))}const ne=({src:e,render:n,overlay:o,width:i,height:c,triggers:l=["onClick"],children:m})=>{const g=s(p),w=function(){const{current:e}=t({sign:!1,fn:void 0});return e.sign||(e.sign=!0,e.fn=g.nextId()),e.fn}(),b=t(null);u(null==m?void 0:m.ref,()=>b.current),r(()=>()=>{g.remove(w)},[]);const y=v({render:e=>n&&n(e),show(e,t){g.show(w),function(e,t){if(m){const n=m.props[e];n&&n(t)}}(e,t)}}),x=a(()=>{const e={};return l.forEach(t=>{e[t]=y.show.bind(null,t)}),e},[]);return r(()=>{g.update({key:w,src:e,originRef:b,render:y.render,overlay:o,width:i,height:c})},[e]),m?d.only(h(m,f({},x,{ref:b}))):null};export{te as PhotoProvider,Q as PhotoSlider,ne as PhotoView}; | ||
//# sourceMappingURL=react-photo-view.modern.js.map |
@@ -1,2 +0,2 @@ | ||
import e,{useRef as n,useReducer as t,createContext as r,useEffect as i,useLayoutEffect as o,useMemo as a,useCallback as c,useState as l,useContext as u,useImperativeHandle as d,Children as s,cloneElement as h}from"react";import{createPortal as f}from"react-dom";function v(){return v=Object.assign?Object.assign.bind():function(e){for(var n=1;n<arguments.length;n++){var t=arguments[n];for(var r in t)({}).hasOwnProperty.call(t,r)&&(e[r]=t[r])}return e},v.apply(null,arguments)}function m(e,n){if(null==e)return{};var t={};for(var r in e)if({}.hasOwnProperty.call(e,r)){if(n.includes(r))continue;t[r]=e[r]}return t}function g(e){var t=n({fn:e,curr:void 0}).current;if(t.fn=e,!t.curr){var r=Object.create(null);Object.keys(e).forEach(function(e){r[e]=function(){var n;return(n=t.fn[e]).call.apply(n,[t.fn].concat([].slice.call(arguments)))}}),t.curr=r}return t.curr}function p(e){return t(function(e,n){return v({},e,"function"==typeof n?n(e):n)},e)}var w=r(void 0),b="cubic-bezier(0.25, 0.8, 0.25, 1)",y=20,x="undefined"!=typeof window&&"ontouchstart"in window,C=function(e,n,t){return Math.max(Math.min(e,t),n)},E=function(e,n,t){return void 0===n&&(n=0),void 0===t&&(t=0),C(e,1*(1-t),Math.max(6,n)*(1+t))},P="undefined"==typeof window||/ServerSideRendering/.test(navigator&&navigator.userAgent)?i:o;function _(e,t,r){var o=n(t);o.current=t,i(function(){function n(e){o.current(e)}return e&&window.addEventListener(e,n,r),function(){e&&window.removeEventListener(e,n)}},[e])}var R=["container"];function k(n){var t=n.container,r=void 0===t?document.body:t,i=m(n,R);return f(e.createElement("div",v({},i)),r)}function V(n){return e.createElement("svg",v({width:"44",height:"44",viewBox:"0 0 768 768"},n),e.createElement("path",{d:"M640.5 352.5v63h-390l178.5 180-45 45-256.5-256.5 256.5-256.5 45 45-178.5 180h390z"}))}function W(n){return e.createElement("svg",v({width:"44",height:"44",viewBox:"0 0 768 768"},n),e.createElement("path",{d:"M384 127.5l256.5 256.5-256.5 256.5-45-45 178.5-180h-390v-63h390l-178.5-180z"}))}function S(){return i(function(){var e=document.body.style,n=e.overflow;return e.overflow="hidden",function(){e.overflow=n}},[]),null}function M(n){return e.createElement("svg",v({width:"44",height:"44",viewBox:"0 0 768 768"},n),e.createElement("path",{d:"M607.5 205.5l-178.5 178.5 178.5 178.5-45 45-178.5-178.5-178.5 178.5-45-45 178.5-178.5-178.5-178.5 45-45 178.5 178.5 178.5-178.5z"}))}function N(n){var t=n.toolbarRender,r=n.overlayParams,i=n.toolbarLeftRender,o=n.toolbarRightRender;return e.createElement(e.Fragment,null,n.bannerVisible&&e.createElement("div",{className:"PhotoView-Slider__BannerWrap"},e.createElement("div",{className:"PhotoView-Slider__Counter"},n.index+1," / ",n.imageLength),e.createElement("div",{className:"PhotoView-Slider__BannerRight"},t&&r&&t(r),e.createElement(M,{className:"PhotoView-Slider__toolbarIcon",onClick:close}))),i&&r&&e.createElement("div",{className:"PhotoView-Slider__Toolbar PhotoView-Slider__Toolbar--Left"},i(r)),o&&r&&e.createElement("div",{className:"PhotoView-Slider__Toolbar PhotoView-Slider__Toolbar--Right"},o(r)))}function Y(e){var n=e.touches[0],t=n.clientX,r=n.clientY;if(e.touches.length>=2){var i=e.touches[1],o=i.clientX,a=i.clientY;return[(t+o)/2,(r+a)/2,Math.sqrt(Math.pow(o-t,2)+Math.pow(a-r,2))]}return[t,r,0]}var X=function(e,n,t,r){var i,o=t*n,a=(o-r)/2,c=e;return o<=r?(i=1,c=0):e>0&&a-e<=0?(i=2,c=a):e<0&&a+e<=0&&(i=3,c=-a),[i,c]};function T(e,n,t,r,i,o,a,c,l,u){void 0===a&&(a=innerWidth/2),void 0===c&&(c=innerHeight/2),void 0===l&&(l=0),void 0===u&&(u=0);var d=X(e,o,t,innerWidth)[0],s=X(n,o,r,innerHeight),h=innerWidth/2,f=innerHeight/2;return{x:a-o/i*(a-(h+e))-h+(r/t>=3&&t*o===innerWidth?0:d?l/2:l),y:c-o/i*(c-(f+n))-f+(s[0]?u/2:u),lastCX:a,lastCY:c}}function L(e,n,t){var r=e%180!=0;return r?[t,n,r]:[n,t,r]}function I(e,n,t){var r=L(t,innerWidth,innerHeight),i=r[0],o=r[1],a=0,c=i,l=o,u=e/n*o,d=n/e*i;return e<i&&n<o?(c=e,l=n):e<i&&n>=o?c=u:e>=i&&n<o||e/n>i/o?l=d:n/e>=3&&!r[2]?a=((l=d)-o)/2:c=u,{width:c,height:l,x:0,y:a,pause:!0}}function A(e,t){var r=t.leading,i=void 0!==r&&r,o=t.maxWait,a=t.wait,l=void 0===a?o||0:a,u=n(e);u.current=e;var d=n(0),s=n(),h=function(){return s.current&&clearTimeout(s.current)},f=c(function(){var e=[].slice.call(arguments),n=Date.now();function t(){d.current=n,h(),u.current.apply(null,e)}var r=d.current,a=n-r;if(0===r&&(i&&t(),d.current=n),void 0!==o){if(a>o)return void t()}else a<l&&(d.current=n);h(),s.current=setTimeout(function(){t(),d.current=0},l)},[l,o,i]);return f.cancel=h,f}var D=function(e,n,t){return O(e,n,t,100,function(e){return e},function(){return O(n,e,t)})},F=function(e){return 1-Math.pow(1-e,4)};function O(e,n,t,r,i,o){void 0===r&&(r=400),void 0===i&&(i=F);var a=n-e;if(0!==a){var c=Date.now(),l=0,u=function(){var n=Math.min(1,(Date.now()-c)/r);t(e+i(n)*a)&&n<1?d():(cancelAnimationFrame(l),n>=1&&o&&o())};d()}function d(){l=requestAnimationFrame(u)}}var H={T:0,L:0,W:0,H:0,FIT:void 0},B=function(){var e=n(!1);return i(function(){return e.current=!0,function(){e.current=!1}},[]),e},j=["className"];function z(n){var t=n.className,r=void 0===t?"":t,i=m(n,j);return e.createElement("div",v({className:"PhotoView__Spinner "+r},i),e.createElement("svg",{viewBox:"0 0 32 32",width:"36",height:"36",fill:"white"},e.createElement("path",{opacity:".25",d:"M16 0 A16 16 0 0 0 16 32 A16 16 0 0 0 16 0 M16 4 A12 12 0 0 1 16 28 A12 12 0 0 1 16 4"}),e.createElement("path",{d:"M16 0 A16 16 0 0 1 32 16 L28 16 A12 12 0 0 0 16 4z"})))}var q=["src","loaded","broken","className","onPhotoLoad","loadingElement","brokenElement"];function K(n){var t=n.src,r=n.loaded,i=n.broken,o=n.className,a=n.onPhotoLoad,c=n.loadingElement,l=n.brokenElement,u=m(n,q),d=B();return t&&!i?e.createElement(e.Fragment,null,e.createElement("img",v({className:"PhotoView__Photo"+(o?" "+o:""),src:t,onLoad:function(e){var n=e.target;d.current&&a({loaded:!0,naturalWidth:n.naturalWidth,naturalHeight:n.naturalHeight})},onError:function(){d.current&&a({broken:!0})},alt:""},u)),!r&&(e.createElement("span",{className:"PhotoView__icon"},c)||e.createElement(z,{className:"PhotoView__icon"}))):l?e.createElement("span",{className:"PhotoView__icon"},"function"==typeof l?l({src:t}):l):null}var U={naturalWidth:void 0,naturalHeight:void 0,width:void 0,height:void 0,loaded:void 0,broken:!1,x:0,y:0,touched:!1,maskTouched:!1,rotate:0,scale:1,CX:0,CY:0,lastX:0,lastY:0,lastCX:0,lastCY:0,lastScale:1,touchTime:0,touchLength:0,pause:!0,stopRaf:!0,reach:void 0};function G(t){var r=t.item,o=r.src,a=r.render,c=r.width,u=void 0===c?0:c,d=r.height,s=void 0===d?0:d,h=r.originRef,f=t.visible,m=t.speed,w=t.easing,b=t.wrapClassName,y=t.className,C=t.style,R=t.loadingElement,k=t.brokenElement,V=t.onPhotoTap,W=t.onMaskTap,S=t.onReachMove,M=t.onReachUp,N=t.onPhotoResize,F=t.isActive,j=t.expose,z=p(U),q=z[0],G=z[1],J=n(0),Q=B(),Z=q.naturalWidth,$=void 0===Z?u:Z,ee=q.naturalHeight,ne=void 0===ee?s:ee,te=q.width,re=void 0===te?u:te,ie=q.height,oe=void 0===ie?s:ie,ae=q.loaded,ce=void 0===ae?!o:ae,le=q.broken,ue=q.x,de=q.y,se=q.touched,he=q.stopRaf,fe=q.maskTouched,ve=q.rotate,me=q.scale,ge=q.CX,pe=q.CY,we=q.lastX,be=q.lastY,ye=q.lastCX,xe=q.lastCY,Ce=q.lastScale,Ee=q.touchTime,Pe=q.touchLength,_e=q.pause,Re=q.reach,ke=g({onScale:function(e){return Ve(E(e))},onRotate:function(e){ve!==e&&(j({rotate:e}),G(v({rotate:e},I($,ne,e))))}});function Ve(e,n,t){me!==e&&(j({scale:e}),G(v({scale:e},T(ue,de,re,oe,me,e,n,t),e<=1&&{x:0,y:0})))}var We=A(function(e,n,t){if(void 0===t&&(t=0),(se||fe)&&F){var r=L(ve,re,oe),i=r[0],o=r[1];if(0===t&&0===J.current){var a=Math.abs(e-ge)<=20,c=Math.abs(n-pe)<=20;if(a&&c)return void G({lastCX:e,lastCY:n});J.current=a?n>pe?3:2:1}var l,u=e-ye,d=n-xe;if(0===t){var s=X(u+we,me,i,innerWidth)[0],h=X(d+be,me,o,innerHeight);l=function(e,n,t,r){return n&&1===e||"x"===r?"x":t&&e>1||"y"===r?"y":void 0}(J.current,s,h[0],Re),void 0!==l&&S(l,e,n,me)}if("x"===l||fe)return void G({reach:"x"});var f=E(me+(t-Pe)/100/2*me,$/re,.2);j({scale:f}),G(v({touchLength:t,reach:l,scale:f},T(ue,de,re,oe,me,f,e,n,u,d)))}},{maxWait:8});function Se(e){return!he&&!se&&(Q.current&&G(v({},e,{pause:f})),Q.current)}var Me,Ne,Ye,Xe,Te,Le,Ie,Ae,De=(Te=function(e){return Se({x:e})},Le=function(e){return Se({y:e})},Ie=function(e){return Q.current&&(j({scale:e}),G({scale:e})),!se&&Q.current},Ae=g({X:function(e){return Te(e)},Y:function(e){return Le(e)},S:function(e){return Ie(e)}}),function(e,n,t,r,i,o,a,c,l,u,d){var s=L(u,i,o),h=s[0],f=s[1],v=X(e,c,h,innerWidth),m=v[0],g=v[1],p=X(n,c,f,innerHeight),w=p[0],b=p[1],y=Date.now()-d;if(y>=200||c!==a||Math.abs(l-a)>1){var x=T(e,n,i,o,a,c),C=x.x,E=x.y,P=m?g:C!==e?C:null,_=w?b:E!==n?E:null;return null!==P&&O(e,P,Ae.X),null!==_&&O(n,_,Ae.Y),void(c!==a&&O(a,c,Ae.S))}var R=(e-t)/y,k=(n-r)/y,V=Math.sqrt(Math.pow(R,2)+Math.pow(k,2)),W=!1,S=!1;!function(e,n){var t,r=e,i=0,o=0,a=function(o){t||(t=o);var a=o-t,u=Math.sign(e),d=-.001*u,s=Math.sign(-r)*Math.pow(r,2)*2e-4,h=r*a+(d+s)*Math.pow(a,2)/2;i+=h,t=o,u*(r+=(d+s)*a)<=0?l():n(i)?c():l()};function c(){o=requestAnimationFrame(a)}function l(){cancelAnimationFrame(o)}c()}(V,function(t){var r=e+t*(R/V),i=n+t*(k/V),o=X(r,a,h,innerWidth),c=o[0],l=o[1],u=X(i,a,f,innerHeight),d=u[0],s=u[1];if(c&&!W&&(W=!0,m?O(r,l,Ae.X):D(l,r+(r-l),Ae.X)),d&&!S&&(S=!0,w?O(i,s,Ae.Y):D(s,i+(i-s),Ae.Y)),W&&S)return!1;var v=W||Ae.X(l),g=S||Ae.Y(s);return v&&g})}),Fe=(Me=V,Ne=function(e,n){Re||Ve(1!==me?1:Math.max(2,$/re),e,n)},Ye=n(0),Xe=A(function(){Ye.current=0,Me.apply(void 0,[].slice.call(arguments))},{wait:300}),function(){var e=[].slice.call(arguments);Ye.current+=1,Xe.apply(void 0,e),Ye.current>=2&&(Xe.cancel(),Ye.current=0,Ne.apply(void 0,e))});function Oe(e,n){if(J.current=0,(se||fe)&&F){G({touched:!1,maskTouched:!1,pause:!1,stopRaf:!1,reach:void 0});var t=E(me,$/re);if(De(ue,de,we,be,re,oe,me,t,Ce,ve,Ee),M(e,n),ge===e&&pe===n){if(se)return void Fe(e,n);fe&&W(e,n)}}}function He(e,n,t){void 0===t&&(t=0),G({touched:!0,CX:e,CY:n,lastCX:e,lastCY:n,lastX:ue,lastY:de,lastScale:me,touchLength:t,touchTime:Date.now()})}function Be(e){G({maskTouched:!0,CX:e.clientX,CY:e.clientY,lastX:ue,lastY:de})}_(x?void 0:"mousemove",function(e){e.preventDefault(),We(e.clientX,e.clientY)}),_(x?void 0:"mouseup",function(e){Oe(e.clientX,e.clientY)}),_(x?"touchmove":void 0,function(e){e.preventDefault();var n=Y(e);We.apply(void 0,n)},{passive:!1}),_(x?"touchend":void 0,function(e){var n=e.changedTouches[0];Oe(n.clientX,n.clientY)},{passive:!1}),_("resize",A(function(){ce&&!se&&(G(I($,ne,ve)),N())},{maxWait:8})),P(function(){F&&j(v({scale:me,rotate:ve},ke))},[F]);var je=function(e,t,r,o,a,c,u,d,s,h){var f=function(e,t,r,i,o){var a=n(!1),c=p({lead:!0,scale:r}),l=c[0],u=l.lead,d=l.scale,s=c[1],h=A(function(e){try{return o(!0),s({lead:!1,scale:e}),Promise.resolve()}catch(e){return Promise.reject(e)}},{wait:i});return P(function(){a.current?(o(!1),s({lead:!0}),h(r)):a.current=!0},[r]),u?[e*d,t*d,r/d]:[e*r,t*r,1]}(c,u,d,s,h),v=f[0],m=f[1],w=f[2],b=function(e,t,r,o,a){var c=l(H),u=c[0],d=c[1],s=l(0),h=s[0],f=s[1],v=n(),m=g({OK:function(){return e&&f(4)}});function p(e){a(!1),f(e)}return i(function(){if(v.current||(v.current=Date.now()),r){if(function(e,n){var t=e&&e.current;if(t&&1===t.nodeType){var r=t.getBoundingClientRect();n({T:r.top,L:r.left,W:r.width,H:r.height,FIT:"IMG"===t.tagName?getComputedStyle(t).objectFit:void 0})}}(t,d),e)return Date.now()-v.current<250?(f(1),requestAnimationFrame(function(){f(2),requestAnimationFrame(function(){return p(3)})}),void setTimeout(m.OK,o)):void f(4);p(5)}},[e,r]),[h,u]}(e,t,r,s,h),y=b[0],x=b[1],C=x.W,E=x.FIT,_=innerWidth/2,R=innerHeight/2,k=y<3||y>4;return[k?C?x.L:_:o+(_-c*d/2),k?C?x.T:R:a+(R-u*d/2),v,k&&E?v*(x.H/C):m,0===y?w:k?C/(c*d)||.01:w,k?E?1:0:1,y,E]}(f,h,ce,ue,de,re,oe,me,m,function(e){return G({pause:e})}),ze=je[4],qe=je[6],Ke="transform "+m+"ms "+w,Ue={className:y,onMouseDown:x?void 0:function(e){e.stopPropagation(),0===e.button&&He(e.clientX,e.clientY,0)},onTouchStart:x?function(e){e.stopPropagation(),He.apply(void 0,Y(e))}:void 0,onWheel:function(e){if(!Re){var n=E(me-e.deltaY/100/2,$/re);G({stopRaf:!0}),Ve(n,e.clientX,e.clientY)}},style:{width:je[2]+"px",height:je[3]+"px",opacity:je[5],objectFit:4===qe?void 0:je[7],transform:ve?"rotate("+ve+"deg)":void 0,transition:qe>2?Ke+", opacity "+m+"ms ease, height "+(qe<4?m/2:qe>4?m:0)+"ms "+w:void 0}};return e.createElement("div",{className:"PhotoView__PhotoWrap"+(b?" "+b:""),style:C,onMouseDown:!x&&F?Be:void 0,onTouchStart:x&&F?function(e){return Be(e.touches[0])}:void 0},e.createElement("div",{className:"PhotoView__PhotoBox",style:{transform:"matrix("+ze+", 0, 0, "+ze+", "+je[0]+", "+je[1]+")",transition:se||_e?void 0:Ke,willChange:F?"transform":void 0}},o?e.createElement(K,v({src:o,loaded:ce,broken:le},Ue,{onPhotoLoad:function(e){G(v({},e,e.loaded&&I(e.naturalWidth||0,e.naturalHeight||0,ve)))},loadingElement:R,brokenElement:k})):a&&a({attrs:Ue,scale:ze,rotate:ve})))}var J={x:0,touched:!1,pause:!1,lastCX:void 0,lastCY:void 0,bg:void 0,lastBg:void 0,overlay:!0,minimal:!0,scale:1,rotate:0};function Q(r){var i=r.loop,o=void 0===i?3:i,c=r.speed,u=r.easing,d=r.photoClosable,s=r.maskClosable,h=void 0===s||s,f=r.maskOpacity,v=void 0===f?1:f,m=r.pullClosable,w=void 0===m||m,E=r.pullAction,R=r.bannerVisible,M=void 0===R||R,Y=r.overlayRender,X=r.toolbarRender,T=r.showBackdropImage,L=r.disableScroll,I=void 0===L||L,A=r.toolbarLeftRender,D=r.toolbarRightRender,F=r.sidebarWidth,O=r.sidebarLeftRender,H=r.sidebarRightRender,B=r.className,j=r.maskClassName,z=r.photoClassName,q=r.photoWrapClassName,K=r.loadingElement,U=r.brokenElement,Q=r.images,Z=r.index,$=void 0===Z?0:Z,ee=r.onIndexChange,ne=r.visible,te=r.onClose,re=r.afterClose,ie=r.portalContainer,oe=p(J),ae=oe[0],ce=oe[1],le=l(0),ue=le[0],de=le[1],se=ae.x,he=ae.touched,fe=ae.pause,ve=ae.lastCX,me=ae.lastCY,ge=ae.bg,pe=void 0===ge?v:ge,we=ae.lastBg,be=ae.overlay,ye=ae.minimal,xe=ae.scale,Ce=ae.rotate,Ee=ae.onScale,Pe=ae.onRotate,_e=r.hasOwnProperty("index"),Re=_e?$:ue,ke=_e?ee:de,Ve=n(Re),We=Q.length,Se=Q[Re],Me="boolean"==typeof o?o:We>o,Ne=function(e,r){var i=t(function(e){return!e},!1)[1],o=n(0),c=function(t){var r=n(t);function i(e){r.current=e}return a(function(){!function(n){e?(n(e),o.current=1):o.current=2}(i)},[t]),[r.current,i]}(e),l=c[1];return[c[0],o.current,function(){i(),2===o.current&&(l(!1),r&&r()),o.current=0}]}(ne,re),Ye=Ne[0],Xe=Ne[1],Te=Ne[2];P(function(){if(Ye)return ce({pause:!0,x:Re*-(innerWidth+y)}),void(Ve.current=Re);ce(J)},[Ye]);var Le=g({close:function(e){Pe&&Pe(0),ce({overlay:!0,lastBg:pe}),te(e)},changeIndex:function(e,n){void 0===n&&(n=!1);var t=Me?Ve.current+(e-Re):e,r=We-1,i=C(t,0,r),o=Me?t:i,a=innerWidth+y;ce({touched:!1,lastCX:void 0,lastCY:void 0,x:-a*o,pause:n}),Ve.current=o,ke&&ke(Me?e<0?r:e>r?0:e:i)}}),Ie=Le.close,Ae=Le.changeIndex;function De(e){return e?Ie():ce({overlay:!be})}function Fe(){ce({x:-(innerWidth+y)*Re,lastCX:void 0,lastCY:void 0,pause:!0}),Ve.current=Re}function Oe(e,n,t,r){"x"===e?function(e){if(void 0!==ve){var n=e-ve,t=n;!Me&&(0===Re&&n>0||Re===We-1&&n<0)&&(t=n/2),ce({touched:!0,lastCX:ve,x:-(innerWidth+y)*Ve.current+t,pause:!1})}else ce({touched:!0,lastCX:e,x:se,pause:!1})}(n):"y"===e&&function(e,n){if(void 0!==me){var t=null===v?null:C(v,.01,v-Math.abs(e-me)/100/4);ce({touched:!0,lastCY:me,bg:1===n?t:v,minimal:1===n})}else ce({touched:!0,lastCY:e,bg:pe,minimal:!0})}(t,r)}function He(e,n){var t=e-(null!=ve?ve:e),r=n-(null!=me?me:n),i=!1;if(t<-40)Ae(Re+1);else if(t>40)Ae(Re-1);else{var o=-(innerWidth+y)*Ve.current;Math.abs(r)>100&&ye&&w?(i=!0,Ie()):Math.abs(r)>100&&ye&&"function"==typeof E&&E({direction:r<0?"top":"bottom",offsetY:r}),ce({touched:!1,x:o,lastCX:void 0,lastCY:void 0,bg:v,overlay:!!i||be})}}_("keydown",function(e){if(ne)switch(e.key){case"ArrowLeft":Ae(Re-1,!1);break;case"ArrowRight":Ae(Re+1,!1);break;case"Escape":Ie()}});var Be=function(e,n,t){return a(function(){var r=e.length;return t?e.concat(e).concat(e).slice(r+n-1,r+n+2):e.slice(Math.max(n-1,0),Math.min(n+2,r+1))},[e,n,t])}(Q,Re,Me);if(!Ye)return null;var je=be&&!Xe,ze=ne?pe:we,qe=Ee&&Pe&&{images:Q,index:Re,visible:ne,onClose:Ie,onIndexChange:Ae,overlayVisible:je,overlay:Se&&Se.overlay,scale:xe,rotate:Ce,onScale:Ee,onRotate:Pe},Ke=c?c(Xe):400,Ue=u?u(Xe):b,Ge=c?c(3):600,Je=u?u(3):b,Qe="number"==typeof F?F+"px":F,Ze=innerWidth<=900;return e.createElement(k,{className:"PhotoView-Portal"+(je?"":" PhotoView-Slider__clean")+(ne?"":" PhotoView-Slider__willClose")+(B?" "+B:""),role:"dialog",onClick:function(e){return e.stopPropagation()},container:ie},ne&&I&&e.createElement(S,null),e.createElement("div",{className:"PhotoView-Container"},O&&qe&&!Ze&&e.createElement("div",{className:"PhotoView-Sidebar PhotoView-Sidebar__Left "+(1===Xe?" PhotoView-Slider__fadeIn":2===Xe?" PhotoView-Slider__fadeOut":""),style:{width:Qe,transitionTimingFunction:Ue,transitionDuration:(he?0:Ke)+"ms",animationDuration:Ke+"ms"}},O(qe)),e.createElement("div",{className:"PhotoView-Viewer"},e.createElement("div",{className:"PhotoView-Slider__Backdrop"+(j?" "+j:"")+(1===Xe?" PhotoView-Slider__fadeIn":2===Xe?" PhotoView-Slider__fadeOut":"")+" "+(T?"with-backdrop-image":""),style:{background:T?"url("+Se.src+")":ze?"rgba(0, 0, 0, "+ze+")":void 0,transitionTimingFunction:Ue,transitionDuration:(he?0:Ke)+"ms",animationDuration:Ke+"ms"},onAnimationEnd:Te}),e.createElement(N,{bannerVisible:M,index:Re,imageLength:We,overlayParams:qe,toolbarRender:X,toolbarLeftRender:A,toolbarRightRender:D}),Be.map(function(n,t){var r=Me||0!==Re?Ve.current-1+t:Re+t;return e.createElement(G,{key:Me?n.key+"/"+n.src+"/"+r:n.key,item:n,speed:Ke,easing:Ue,visible:ne,onReachMove:Oe,onReachUp:He,onPhotoTap:function(){return De(d)},onMaskTap:function(){return De(h)},wrapClassName:q,className:z,style:{left:(innerWidth+y)*r+"px",transform:"translate3d("+se+"px, 0px, 0)",transition:he||fe?void 0:"transform "+Ge+"ms "+Je},loadingElement:K,brokenElement:U,onPhotoResize:Fe,isActive:Ve.current===r,expose:ce})}),!x&&M&&e.createElement(e.Fragment,null,(Me||0!==Re)&&e.createElement("div",{className:"PhotoView-Slider__ArrowLeft",onClick:function(){return Ae(Re-1,!0)}},e.createElement(V,null)),(Me||Re+1<We)&&e.createElement("div",{className:"PhotoView-Slider__ArrowRight",onClick:function(){return Ae(Re+1,!0)}},e.createElement(W,null))),Y&&qe&&e.createElement("div",{className:"PhotoView-Slider__Overlay"},Y(qe))),H&&qe&&!Ze&&e.createElement("div",{className:"PhotoView-Sidebar PhotoView-Sidebar__Right "+(1===Xe?" PhotoView-Slider__fadeIn":2===Xe?" PhotoView-Slider__fadeOut":""),style:{width:Qe,transitionTimingFunction:Ue,transitionDuration:(he?0:Ke)+"ms",animationDuration:Ke+"ms"}},H(qe))))}var Z=["children","onIndexChange","onVisibleChange","sidebarLeftRender","sidebarRightRender","sidebarWidth"],$={images:[],visible:!1,index:0};function ee(t){var r=t.children,o=t.onIndexChange,c=t.onVisibleChange,l=t.sidebarLeftRender,u=t.sidebarRightRender,d=t.sidebarWidth,s=void 0===d?400:d,h=m(t,Z),f=p($),b=f[0],y=f[1],x=n(0),C=b.images,E=b.visible,P=b.index;i(function(){if(l||u){var e=Object.getOwnPropertyDescriptor(window,"innerWidth");!e||e.configurable?Object.defineProperty(window,"innerWidth",{get:function(){return window.outerWidth<=900?window.outerWidth:window.outerWidth-s},configurable:!0,enumerable:!0}):console.warn("innerWidth is already defined and is not configurable")}},[]);var _=g({nextId:function(){return x.current+=1},update:function(e){var n=C.findIndex(function(n){return n.key===e.key});if(n>-1){var t=C.slice();return t.splice(n,1,e),void y({images:t})}y(function(n){return{images:n.images.concat(e)}})},remove:function(e){y(function(n){var t=n.images.filter(function(n){return n.key!==e});return{images:t,index:Math.min(t.length-1,P)}})},show:function(e){var n=C.findIndex(function(n){return n.key===e});y({visible:!0,index:n}),c&&c(!0,n,b)}}),R=g({close:function(){y({visible:!1}),c&&c(!1,P,b)},changeIndex:function(e){y({index:e}),o&&o(e,b)}}),k=a(function(){return v({},b,_)},[b,_]);return e.createElement(w.Provider,{value:k},r,e.createElement(Q,v({images:C,visible:E,index:P,onIndexChange:R.changeIndex,onClose:R.close,sidebarWidth:s,sidebarLeftRender:l,sidebarRightRender:u},h)))}var ne=function(e){var t,r,o=e.src,c=e.render,l=e.overlay,f=e.width,m=e.height,p=e.triggers,b=void 0===p?["onClick"]:p,y=e.children,x=u(w),C=(t=function(){return x.nextId()},(r=n({sign:!1,fn:void 0}).current).sign||(r.sign=!0,r.fn=t()),r.fn),E=n(null);d(null==y?void 0:y.ref,function(){return E.current}),i(function(){return function(){x.remove(C)}},[]);var P=g({render:function(e){return c&&c(e)},show:function(e,n){x.show(C),function(e,n){if(y){var t=y.props[e];t&&t(n)}}(e,n)}}),_=a(function(){var e={};return b.forEach(function(n){e[n]=P.show.bind(null,n)}),e},[]);return i(function(){x.update({key:C,src:o,originRef:E,render:P.render,overlay:l,width:f,height:m})},[o]),y?s.only(h(y,v({},_,{ref:E}))):null};export{ee as PhotoProvider,Q as PhotoSlider,ne as PhotoView}; | ||
import e,{useRef as n,useReducer as t,createContext as r,useEffect as i,useLayoutEffect as o,useMemo as a,useCallback as c,useState as l,useContext as u,useImperativeHandle as s,Children as d,cloneElement as f}from"react";import{createPortal as h}from"react-dom";function v(){return v=Object.assign?Object.assign.bind():function(e){for(var n=1;n<arguments.length;n++){var t=arguments[n];for(var r in t)({}).hasOwnProperty.call(t,r)&&(e[r]=t[r])}return e},v.apply(null,arguments)}function m(e,n){if(null==e)return{};var t={};for(var r in e)if({}.hasOwnProperty.call(e,r)){if(n.includes(r))continue;t[r]=e[r]}return t}function g(e){var t=n({fn:e,curr:void 0}).current;if(t.fn=e,!t.curr){var r=Object.create(null);Object.keys(e).forEach(function(e){r[e]=function(){var n;return(n=t.fn[e]).call.apply(n,[t.fn].concat([].slice.call(arguments)))}}),t.curr=r}return t.curr}function p(e){return t(function(e,n){return v({},e,"function"==typeof n?n(e):n)},e)}var w=r(void 0),b="cubic-bezier(0.25, 0.8, 0.25, 1)",y=20,x="undefined"!=typeof window&&"ontouchstart"in window,E=function(e,n,t){return Math.max(Math.min(e,t),n)},C=function(e,n,t){return void 0===n&&(n=0),void 0===t&&(t=0),E(e,1*(1-t),Math.max(6,n)*(1+t))},P="undefined"==typeof window||/ServerSideRendering/.test(navigator&&navigator.userAgent)?i:o;function _(e,t,r){var o=n(t);o.current=t,i(function(){function n(e){o.current(e)}return e&&window.addEventListener(e,n,r),function(){e&&window.removeEventListener(e,n)}},[e])}var S=["container"];function R(n){var t=n.container,r=void 0===t?document.body:t,i=m(n,S);return h(e.createElement("div",v({},i)),r)}function k(n){return e.createElement("svg",v({width:"44",height:"44",viewBox:"0 0 768 768"},n),e.createElement("path",{d:"M640.5 352.5v63h-390l178.5 180-45 45-256.5-256.5 256.5-256.5 45 45-178.5 180h390z"}))}function V(n){return e.createElement("svg",v({width:"44",height:"44",viewBox:"0 0 768 768"},n),e.createElement("path",{d:"M384 127.5l256.5 256.5-256.5 256.5-45-45 178.5-180h-390v-63h390l-178.5-180z"}))}function W(){return i(function(){var e=document.body.style,n=e.overflow;return e.overflow="hidden",function(){e.overflow=n}},[]),null}function M(n){return e.createElement("svg",v({width:"44",height:"44",viewBox:"0 0 768 768"},n),e.createElement("path",{d:"M607.5 205.5l-178.5 178.5 178.5 178.5-45 45-178.5-178.5-178.5 178.5-45-45 178.5-178.5-178.5-178.5 45-45 178.5 178.5 178.5-178.5z"}))}function N(n){var t=n.toolbarRender,r=n.overlayParams,i=n.toolbarLeftRender,o=n.toolbarRightRender;return e.createElement(e.Fragment,null,n.bannerVisible&&e.createElement("div",{className:"PhotoView-Slider__BannerWrap"},e.createElement("div",{className:"PhotoView-Slider__Counter"},n.index+1," / ",n.imageLength),e.createElement("div",{className:"PhotoView-Slider__BannerRight"},t&&r&&t(r),e.createElement(M,{className:"PhotoView-Slider__toolbarIcon",onClick:close}))),i&&r&&e.createElement("div",{className:"PhotoView-Slider__Toolbar PhotoView-Slider__Toolbar--Left"},i(r)),o&&r&&e.createElement("div",{className:"PhotoView-Slider__Toolbar PhotoView-Slider__Toolbar--Right"},o(r)))}function Y(e){var n=e.touches[0],t=n.clientX,r=n.clientY;if(e.touches.length>=2){var i=e.touches[1],o=i.clientX,a=i.clientY;return[(t+o)/2,(r+a)/2,Math.sqrt(Math.pow(o-t,2)+Math.pow(a-r,2))]}return[t,r,0]}var X=function(e,n,t,r){var i,o=t*n,a=(o-r)/2,c=e;return o<=r?(i=1,c=0):e>0&&a-e<=0?(i=2,c=a):e<0&&a+e<=0&&(i=3,c=-a),[i,c]};function T(e,n,t,r,i,o,a,c,l,u){void 0===a&&(a=innerWidth/2),void 0===c&&(c=innerHeight/2),void 0===l&&(l=0),void 0===u&&(u=0);var s=X(e,o,t,innerWidth)[0],d=X(n,o,r,innerHeight),f=innerWidth/2,h=innerHeight/2;return{x:a-o/i*(a-(f+e))-f+(r/t>=3&&t*o===innerWidth?0:s?l/2:l),y:c-o/i*(c-(h+n))-h+(d[0]?u/2:u),lastCX:a,lastCY:c}}function L(e,n,t){var r=e%180!=0;return r?[t,n,r]:[n,t,r]}function F(e,n,t){var r=L(t,innerWidth,innerHeight),i=r[0],o=r[1],a=0,c=i,l=o,u=e/n*o,s=n/e*i;return e<i&&n<o?(c=e,l=n):e<i&&n>=o?c=u:e>=i&&n<o||e/n>i/o?l=s:n/e>=3&&!r[2]?a=((l=s)-o)/2:c=u,{width:c,height:l,x:0,y:a,pause:!0}}function I(e,t){var r=t.leading,i=void 0!==r&&r,o=t.maxWait,a=t.wait,l=void 0===a?o||0:a,u=n(e);u.current=e;var s=n(0),d=n(),f=function(){return d.current&&clearTimeout(d.current)},h=c(function(){var e=[].slice.call(arguments),n=Date.now();function t(){s.current=n,f(),u.current.apply(null,e)}var r=s.current,a=n-r;if(0===r&&(i&&t(),s.current=n),void 0!==o){if(a>o)return void t()}else a<l&&(s.current=n);f(),d.current=setTimeout(function(){t(),s.current=0},l)},[l,o,i]);return h.cancel=f,h}var A=function(e,n,t){return O(e,n,t,100,function(e){return e},function(){return O(n,e,t)})},D=function(e){return 1-Math.pow(1-e,4)};function O(e,n,t,r,i,o){void 0===r&&(r=400),void 0===i&&(i=D);var a=n-e;if(0!==a){var c=Date.now(),l=0,u=function(){var n=Math.min(1,(Date.now()-c)/r);t(e+i(n)*a)&&n<1?s():(cancelAnimationFrame(l),n>=1&&o&&o())};s()}function s(){l=requestAnimationFrame(u)}}var H={T:0,L:0,W:0,H:0,FIT:void 0},B=function(){var e=n(!1);return i(function(){return e.current=!0,function(){e.current=!1}},[]),e},j=["className"];function z(n){var t=n.className,r=void 0===t?"":t,i=m(n,j);return e.createElement("div",v({className:"PhotoView__Spinner "+r},i),e.createElement("svg",{viewBox:"0 0 32 32",width:"36",height:"36",fill:"white"},e.createElement("path",{opacity:".25",d:"M16 0 A16 16 0 0 0 16 32 A16 16 0 0 0 16 0 M16 4 A12 12 0 0 1 16 28 A12 12 0 0 1 16 4"}),e.createElement("path",{d:"M16 0 A16 16 0 0 1 32 16 L28 16 A12 12 0 0 0 16 4z"})))}var q=["src","loaded","broken","className","onPhotoLoad","loadingElement","brokenElement"];function K(n){var t=n.src,r=n.loaded,i=n.broken,o=n.className,a=n.onPhotoLoad,c=n.loadingElement,l=n.brokenElement,u=m(n,q),s=B();return t&&!i?e.createElement(e.Fragment,null,e.createElement("img",v({className:"PhotoView__Photo"+(o?" "+o:""),src:t,onLoad:function(e){var n=e.target;s.current&&a({loaded:!0,naturalWidth:n.naturalWidth,naturalHeight:n.naturalHeight})},onError:function(){s.current&&a({broken:!0})},alt:""},u)),!r&&(e.createElement("span",{className:"PhotoView__icon"},c)||e.createElement(z,{className:"PhotoView__icon"}))):l?e.createElement("span",{className:"PhotoView__icon"},"function"==typeof l?l({src:t}):l):null}var U={naturalWidth:void 0,naturalHeight:void 0,width:void 0,height:void 0,loaded:void 0,broken:!1,x:0,y:0,touched:!1,maskTouched:!1,rotate:0,scale:1,CX:0,CY:0,lastX:0,lastY:0,lastCX:0,lastCY:0,lastScale:1,touchTime:0,touchLength:0,pause:!0,stopRaf:!0,reach:void 0};function G(t){var r=t.item,o=r.src,a=r.render,c=r.width,u=void 0===c?0:c,s=r.height,d=void 0===s?0:s,f=r.originRef,h=t.visible,m=t.speed,w=t.easing,b=t.wrapClassName,y=t.className,E=t.style,S=t.loadingElement,R=t.brokenElement,k=t.onPhotoTap,V=t.onMaskTap,W=t.onReachMove,M=t.onReachUp,N=t.onPhotoResize,D=t.isActive,j=t.expose,z=p(U),q=z[0],G=z[1],J=n(0),Q=B(),Z=q.naturalWidth,$=void 0===Z?u:Z,ee=q.naturalHeight,ne=void 0===ee?d:ee,te=q.width,re=void 0===te?u:te,ie=q.height,oe=void 0===ie?d:ie,ae=q.loaded,ce=void 0===ae?!o:ae,le=q.broken,ue=q.x,se=q.y,de=q.touched,fe=q.stopRaf,he=q.maskTouched,ve=q.rotate,me=q.scale,ge=q.CX,pe=q.CY,we=q.lastX,be=q.lastY,ye=q.lastCX,xe=q.lastCY,Ee=q.lastScale,Ce=q.touchTime,Pe=q.touchLength,_e=q.pause,Se=q.reach,Re=g({onScale:function(e){return ke(C(e))},onRotate:function(e){ve!==e&&(j({rotate:e}),G(v({rotate:e},F($,ne,e))))}});function ke(e,n,t){me!==e&&(j({scale:e}),G(v({scale:e},T(ue,se,re,oe,me,e,n,t),e<=1&&{x:0,y:0})))}var Ve=I(function(e,n,t){if(void 0===t&&(t=0),(de||he)&&D){var r=L(ve,re,oe),i=r[0],o=r[1];if(0===t&&0===J.current){var a=Math.abs(e-ge)<=20,c=Math.abs(n-pe)<=20;if(a&&c)return void G({lastCX:e,lastCY:n});J.current=a?n>pe?3:2:1}var l,u=e-ye,s=n-xe;if(0===t){var d=X(u+we,me,i,innerWidth)[0],f=X(s+be,me,o,innerHeight);l=function(e,n,t,r){return n&&1===e||"x"===r?"x":t&&e>1||"y"===r?"y":void 0}(J.current,d,f[0],Se),void 0!==l&&W(l,e,n,me)}if("x"===l||he)return void G({reach:"x"});var h=C(me+(t-Pe)/100/2*me,$/re,.2);j({scale:h}),G(v({touchLength:t,reach:l,scale:h},T(ue,se,re,oe,me,h,e,n,u,s)))}},{maxWait:8});function We(e){return!fe&&!de&&(Q.current&&G(v({},e,{pause:h})),Q.current)}var Me,Ne,Ye,Xe,Te,Le,Fe,Ie,Ae=(Te=function(e){return We({x:e})},Le=function(e){return We({y:e})},Fe=function(e){return Q.current&&(j({scale:e}),G({scale:e})),!de&&Q.current},Ie=g({X:function(e){return Te(e)},Y:function(e){return Le(e)},S:function(e){return Fe(e)}}),function(e,n,t,r,i,o,a,c,l,u,s){var d=L(u,i,o),f=d[0],h=d[1],v=X(e,c,f,innerWidth),m=v[0],g=v[1],p=X(n,c,h,innerHeight),w=p[0],b=p[1],y=Date.now()-s;if(y>=200||c!==a||Math.abs(l-a)>1){var x=T(e,n,i,o,a,c),E=x.x,C=x.y,P=m?g:E!==e?E:null,_=w?b:C!==n?C:null;return null!==P&&O(e,P,Ie.X),null!==_&&O(n,_,Ie.Y),void(c!==a&&O(a,c,Ie.S))}var S=(e-t)/y,R=(n-r)/y,k=Math.sqrt(Math.pow(S,2)+Math.pow(R,2)),V=!1,W=!1;!function(e,n){var t,r=e,i=0,o=0,a=function(o){t||(t=o);var a=o-t,u=Math.sign(e),s=-.001*u,d=Math.sign(-r)*Math.pow(r,2)*2e-4,f=r*a+(s+d)*Math.pow(a,2)/2;i+=f,t=o,u*(r+=(s+d)*a)<=0?l():n(i)?c():l()};function c(){o=requestAnimationFrame(a)}function l(){cancelAnimationFrame(o)}c()}(k,function(t){var r=e+t*(S/k),i=n+t*(R/k),o=X(r,a,f,innerWidth),c=o[0],l=o[1],u=X(i,a,h,innerHeight),s=u[0],d=u[1];if(c&&!V&&(V=!0,m?O(r,l,Ie.X):A(l,r+(r-l),Ie.X)),s&&!W&&(W=!0,w?O(i,d,Ie.Y):A(d,i+(i-d),Ie.Y)),V&&W)return!1;var v=V||Ie.X(l),g=W||Ie.Y(d);return v&&g})}),De=(Me=k,Ne=function(e,n){Se||ke(1!==me?1:Math.max(2,$/re),e,n)},Ye=n(0),Xe=I(function(){Ye.current=0,Me.apply(void 0,[].slice.call(arguments))},{wait:300}),function(){var e=[].slice.call(arguments);Ye.current+=1,Xe.apply(void 0,e),Ye.current>=2&&(Xe.cancel(),Ye.current=0,Ne.apply(void 0,e))});function Oe(e,n){if(J.current=0,(de||he)&&D){G({touched:!1,maskTouched:!1,pause:!1,stopRaf:!1,reach:void 0});var t=C(me,$/re);if(Ae(ue,se,we,be,re,oe,me,t,Ee,ve,Ce),M(e,n),ge===e&&pe===n){if(de)return void De(e,n);he&&V(e,n)}}}function He(e,n,t){void 0===t&&(t=0),G({touched:!0,CX:e,CY:n,lastCX:e,lastCY:n,lastX:ue,lastY:se,lastScale:me,touchLength:t,touchTime:Date.now()})}function Be(e){G({maskTouched:!0,CX:e.clientX,CY:e.clientY,lastX:ue,lastY:se})}_(x?void 0:"mousemove",function(e){e.preventDefault(),Ve(e.clientX,e.clientY)}),_(x?void 0:"mouseup",function(e){Oe(e.clientX,e.clientY)}),_(x?"touchmove":void 0,function(e){e.preventDefault();var n=Y(e);Ve.apply(void 0,n)},{passive:!1}),_(x?"touchend":void 0,function(e){var n=e.changedTouches[0];Oe(n.clientX,n.clientY)},{passive:!1}),_("resize",I(function(){ce&&!de&&(G(F($,ne,ve)),N())},{maxWait:8})),P(function(){D&&j(v({scale:me,rotate:ve},Re))},[D]);var je=function(e,t,r,o,a,c,u,s,d,f){var h=function(e,t,r,i,o){var a=n(!1),c=p({lead:!0,scale:r}),l=c[0],u=l.lead,s=l.scale,d=c[1],f=I(function(e){try{return o(!0),d({lead:!1,scale:e}),Promise.resolve()}catch(e){return Promise.reject(e)}},{wait:i});return P(function(){a.current?(o(!1),d({lead:!0}),f(r)):a.current=!0},[r]),u?[e*s,t*s,r/s]:[e*r,t*r,1]}(c,u,s,d,f),v=h[0],m=h[1],w=h[2],b=function(e,t,r,o,a){var c=l(H),u=c[0],s=c[1],d=l(0),f=d[0],h=d[1],v=n(),m=g({OK:function(){return e&&h(4)}});function p(e){a(!1),h(e)}return i(function(){if(v.current||(v.current=Date.now()),r){if(function(e,n){var t=e&&e.current;if(t&&1===t.nodeType){var r=t.getBoundingClientRect();n({T:r.top,L:r.left,W:r.width,H:r.height,FIT:"IMG"===t.tagName?getComputedStyle(t).objectFit:void 0})}}(t,s),e)return Date.now()-v.current<250?(h(1),requestAnimationFrame(function(){h(2),requestAnimationFrame(function(){return p(3)})}),void setTimeout(m.OK,o)):void h(4);p(5)}},[e,r]),[f,u]}(e,t,r,d,f),y=b[0],x=b[1],E=x.W,C=x.FIT,_=innerWidth/2,S=innerHeight/2,R=y<3||y>4;return[R?E?x.L:_:o+(_-c*s/2),R?E?x.T:S:a+(S-u*s/2),v,R&&C?v*(x.H/E):m,0===y?w:R?E/(c*s)||.01:w,R?C?1:0:1,y,C]}(h,f,ce,ue,se,re,oe,me,m,function(e){return G({pause:e})}),ze=je[4],qe=je[6],Ke="transform "+m+"ms "+w,Ue={className:y,onMouseDown:x?void 0:function(e){e.stopPropagation(),0===e.button&&He(e.clientX,e.clientY,0)},onTouchStart:x?function(e){e.stopPropagation(),He.apply(void 0,Y(e))}:void 0,onWheel:function(e){if(!Se){var n=C(me-e.deltaY/100/2,$/re);G({stopRaf:!0}),ke(n,e.clientX,e.clientY)}},style:{width:je[2]+"px",height:je[3]+"px",opacity:je[5],objectFit:4===qe?void 0:je[7],transform:ve?"rotate("+ve+"deg)":void 0,transition:qe>2?Ke+", opacity "+m+"ms ease, height "+(qe<4?m/2:qe>4?m:0)+"ms "+w:void 0}};return e.createElement("div",{className:"PhotoView__PhotoWrap"+(b?" "+b:""),style:E,onMouseDown:!x&&D?Be:void 0,onTouchStart:x&&D?function(e){return Be(e.touches[0])}:void 0},e.createElement("div",{className:"PhotoView__PhotoBox",style:{transform:"matrix("+ze+", 0, 0, "+ze+", "+je[0]+", "+je[1]+")",transition:de||_e?void 0:Ke,willChange:D?"transform":void 0}},o?e.createElement(K,v({src:o,loaded:ce,broken:le},Ue,{onPhotoLoad:function(e){G(v({},e,e.loaded&&F(e.naturalWidth||0,e.naturalHeight||0,ve)))},loadingElement:S,brokenElement:R})):a&&a({attrs:Ue,scale:ze,rotate:ve})))}var J={x:0,touched:!1,pause:!1,lastCX:void 0,lastCY:void 0,bg:void 0,lastBg:void 0,overlay:!0,minimal:!0,scale:1,rotate:0};function Q(r){var o=r.loop,u=void 0===o?3:o,s=r.speed,d=r.easing,f=r.photoClosable,h=r.maskClosable,v=void 0===h||h,m=r.maskOpacity,w=void 0===m?1:m,C=r.pullClosable,S=void 0===C||C,M=r.pullAction,Y=r.bannerVisible,X=void 0===Y||Y,T=r.overlayRender,L=r.toolbarRender,F=r.showBackdropImage,I=r.disableScroll,A=void 0===I||I,D=r.toolbarLeftRender,O=r.toolbarRightRender,H=r.sidebarWidth,B=r.sidebarLeftRender,j=r.sidebarRightRender,z=r.className,q=r.maskClassName,K=r.photoClassName,U=r.photoWrapClassName,Q=r.loadingElement,Z=r.brokenElement,$=r.images,ee=r.index,ne=void 0===ee?0:ee,te=r.onIndexChange,re=r.visible,ie=r.onClose,oe=r.afterClose,ae=r.portalContainer,ce=r.fullScreen,le=r.onFullScreen,ue=n(),se=p(J),de=se[0],fe=se[1],he=l(0),ve=he[0],me=he[1],ge=de.x,pe=de.touched,we=de.pause,be=de.lastCX,ye=de.lastCY,xe=de.bg,Ee=void 0===xe?w:xe,Ce=de.lastBg,Pe=de.overlay,_e=de.minimal,Se=de.scale,Re=de.rotate,ke=de.onScale,Ve=de.onRotate,We=r.hasOwnProperty("index"),Me=We?ne:ve,Ne=We?te:me,Ye=n(Me),Xe=$.length,Te=$[Me],Le="boolean"==typeof u?u:Xe>u,Fe=function(e,r){var i=t(function(e){return!e},!1)[1],o=n(0),c=function(t){var r=n(t);function i(e){r.current=e}return a(function(){!function(n){e?(n(e),o.current=1):o.current=2}(i)},[t]),[r.current,i]}(e),l=c[1];return[c[0],o.current,function(){i(),2===o.current&&(l(!1),r&&r()),o.current=0}]}(re,oe),Ie=Fe[0],Ae=Fe[1],De=Fe[2];P(function(){if(Ie)return fe({pause:!0,x:Me*-(innerWidth+y)}),void(Ye.current=Me);fe(J)},[Ie]);var Oe=g({close:function(e){Ve&&Ve(0),fe({overlay:!0,lastBg:Ee}),ie(e)},changeIndex:function(e,n){void 0===n&&(n=!1);var t=Le?Ye.current+(e-Me):e,r=Xe-1,i=E(t,0,r),o=Le?t:i,a=innerWidth+y;fe({touched:!1,lastCX:void 0,lastCY:void 0,x:-a*o,pause:n}),Ye.current=o,Ne&&Ne(Le?e<0?r:e>r?0:e:i)}}),He=Oe.close,Be=Oe.changeIndex,je=c(function(){le(!ce)},[ce,le]),ze=a(function(){return function(){!document.fullscreenElement&&ce&&je()}},[ce,je]),qe=a(function(){return function(){if(document.fullscreenElement)document.exitFullscreen();else if(ce){var e=ue.current;if(!e)return;e.requestFullscreen().then(function(){}).catch(function(e){console.log("Error al intentar activar el modo de pantalla completa",e)})}}},[ce]);function Ke(e){return e?He():fe({overlay:!Pe})}function Ue(){fe({x:-(innerWidth+y)*Me,lastCX:void 0,lastCY:void 0,pause:!0}),Ye.current=Me}function Ge(e,n,t,r){"x"===e?function(e){if(void 0!==be){var n=e-be,t=n;!Le&&(0===Me&&n>0||Me===Xe-1&&n<0)&&(t=n/2),fe({touched:!0,lastCX:be,x:-(innerWidth+y)*Ye.current+t,pause:!1})}else fe({touched:!0,lastCX:e,x:ge,pause:!1})}(n):"y"===e&&function(e,n){if(void 0!==ye){var t=null===w?null:E(w,.01,w-Math.abs(e-ye)/100/4);fe({touched:!0,lastCY:ye,bg:1===n?t:w,minimal:1===n})}else fe({touched:!0,lastCY:e,bg:Ee,minimal:!0})}(t,r)}function Je(e,n){var t=e-(null!=be?be:e),r=n-(null!=ye?ye:n),i=!1;if(t<-40)Be(Me+1);else if(t>40)Be(Me-1);else{var o=-(innerWidth+y)*Ye.current;Math.abs(r)>100&&_e&&S?(i=!0,He()):Math.abs(r)>100&&_e&&"function"==typeof M&&M({direction:r<0?"top":"bottom",offsetY:r}),fe({touched:!1,x:o,lastCX:void 0,lastCY:void 0,bg:w,overlay:!!i||Pe})}}i(function(){if(ue.current)return qe(),document.addEventListener("fullscreenchange",ze),function(){document.removeEventListener("fullscreenchange",ze)}},[ce,ze,qe]),_("keydown",function(e){if(re)switch(e.key){case"ArrowLeft":Be(Me-1,!1);break;case"ArrowRight":Be(Me+1,!1);break;case"Escape":He()}});var Qe=function(e,n,t){return a(function(){var r=e.length;return t?e.concat(e).concat(e).slice(r+n-1,r+n+2):e.slice(Math.max(n-1,0),Math.min(n+2,r+1))},[e,n,t])}($,Me,Le);if(!Ie)return null;var Ze=Pe&&!Ae,$e=re?Ee:Ce,en=ke&&Ve&&{images:$,index:Me,visible:re,onClose:He,onIndexChange:Be,overlayVisible:Ze,overlay:Te&&Te.overlay,scale:Se,rotate:Re,onScale:ke,onRotate:Ve,toggleFullScreen:function(){return le(!ce)}},nn=s?s(Ae):400,tn=d?d(Ae):b,rn=s?s(3):600,on=d?d(3):b,an="number"==typeof H?H+"px":H,cn=innerWidth<=900;return e.createElement(R,{className:"PhotoView-Portal"+(Ze?"":" PhotoView-Slider__clean")+(re?"":" PhotoView-Slider__willClose")+(z?" "+z:""),role:"dialog",onClick:function(e){return e.stopPropagation()},container:ae},re&&A&&e.createElement(W,null),e.createElement("div",{className:"PhotoView-Container"},B&&en&&!cn&&e.createElement("div",{className:"PhotoView-Sidebar PhotoView-Sidebar__Left "+(1===Ae?" PhotoView-Slider__fadeIn":2===Ae?" PhotoView-Slider__fadeOut":""),style:{width:an,transitionTimingFunction:tn,transitionDuration:(pe?0:nn)+"ms",animationDuration:nn+"ms"}},B(en)),e.createElement("div",{ref:ue,className:"PhotoView-Viewer"},e.createElement("div",{className:"PhotoView-Slider__Backdrop"+(q?" "+q:"")+(1===Ae?" PhotoView-Slider__fadeIn":2===Ae?" PhotoView-Slider__fadeOut":"")+" "+(F?"with-backdrop-image":""),style:{background:F?"url("+Te.src+")":$e?"rgba(0, 0, 0, "+$e+")":void 0,transitionTimingFunction:tn,transitionDuration:(pe?0:nn)+"ms",animationDuration:nn+"ms"},onAnimationEnd:De}),e.createElement(N,{bannerVisible:X,index:Me,imageLength:Xe,overlayParams:en,toolbarRender:L,toolbarLeftRender:D,toolbarRightRender:O}),Qe.map(function(n,t){var r=Le||0!==Me?Ye.current-1+t:Me+t;return e.createElement(G,{key:Le?n.key+"/"+n.src+"/"+r:n.key,item:n,speed:nn,easing:tn,visible:re,onReachMove:Ge,onReachUp:Je,onPhotoTap:function(){return Ke(f)},onMaskTap:function(){return Ke(v)},wrapClassName:U,className:K,style:{left:(innerWidth+y)*r+"px",transform:"translate3d("+ge+"px, 0px, 0)",transition:pe||we?void 0:"transform "+rn+"ms "+on},loadingElement:Q,brokenElement:Z,onPhotoResize:Ue,isActive:Ye.current===r,expose:fe})}),!x&&X&&e.createElement(e.Fragment,null,(Le||0!==Me)&&e.createElement("div",{className:"PhotoView-Slider__ArrowLeft",onClick:function(){return Be(Me-1,!0)}},e.createElement(k,null)),(Le||Me+1<Xe)&&e.createElement("div",{className:"PhotoView-Slider__ArrowRight",onClick:function(){return Be(Me+1,!0)}},e.createElement(V,null))),T&&en&&e.createElement("div",{className:"PhotoView-Slider__Overlay"},T(en))),j&&en&&!cn&&e.createElement("div",{className:"PhotoView-Sidebar PhotoView-Sidebar__Right "+(1===Ae?" PhotoView-Slider__fadeIn":2===Ae?" PhotoView-Slider__fadeOut":""),style:{width:an,transitionTimingFunction:tn,transitionDuration:(pe?0:nn)+"ms",animationDuration:nn+"ms"}},j(en))))}var Z=["children","onIndexChange","onVisibleChange","sidebarLeftRender","sidebarRightRender","sidebarWidth"],$={images:[],visible:!1,index:0,fullScreen:!1};function ee(t){var r=t.children,o=t.onIndexChange,l=t.onVisibleChange,u=t.sidebarLeftRender,s=t.sidebarRightRender,d=t.sidebarWidth,f=void 0===d?400:d,h=m(t,Z),b=p($),y=b[0],x=b[1],E=n(0),C=n(!1),P=y.images,_=y.visible,S=y.index,R=c(function(){if(u||s){var e=Object.getOwnPropertyDescriptor(window,"innerWidth");!e||e.configurable||C.current!==y.fullScreen?(Object.defineProperty(window,"innerWidth",{get:function(){return window.outerWidth<=900||y.fullScreen?window.outerWidth:window.outerWidth-f},configurable:!0,enumerable:!0}),C.current=y.fullScreen):console.warn("innerWidth is already defined and is not configurable")}},[u,s,y.fullScreen,f]);i(function(){R()},[]),i(function(){R()},[y.fullScreen,R]);var k=g({nextId:function(){return E.current+=1},update:function(e){var n=P.findIndex(function(n){return n.key===e.key});if(n>-1){var t=P.slice();return t.splice(n,1,e),void x({images:t})}x(function(n){return{images:n.images.concat(e)}})},remove:function(e){x(function(n){var t=n.images.filter(function(n){return n.key!==e});return{images:t,index:Math.min(t.length-1,S)}})},show:function(e){var n=P.findIndex(function(n){return n.key===e});x({visible:!0,index:n}),l&&l(!0,n,y)}}),V=g({close:function(){x({visible:!1}),l&&l(!1,S,y)},changeIndex:function(e){x({index:e}),o&&o(e,y)},fullScreen:function(e){x({fullScreen:e})}}),W=a(function(){return v({},y,k)},[y,k]);return e.createElement(w.Provider,{value:W},r,e.createElement(Q,v({images:P,visible:_,index:S,fullScreen:y.fullScreen,onIndexChange:V.changeIndex,onClose:V.close,onFullScreen:V.fullScreen,sidebarWidth:f,sidebarLeftRender:u,sidebarRightRender:s},h)))}var ne=function(e){var t,r,o=e.src,c=e.render,l=e.overlay,h=e.width,m=e.height,p=e.triggers,b=void 0===p?["onClick"]:p,y=e.children,x=u(w),E=(t=function(){return x.nextId()},(r=n({sign:!1,fn:void 0}).current).sign||(r.sign=!0,r.fn=t()),r.fn),C=n(null);s(null==y?void 0:y.ref,function(){return C.current}),i(function(){return function(){x.remove(E)}},[]);var P=g({render:function(e){return c&&c(e)},show:function(e,n){x.show(E),function(e,n){if(y){var t=y.props[e];t&&t(n)}}(e,n)}}),_=a(function(){var e={};return b.forEach(function(n){e[n]=P.show.bind(null,n)}),e},[]);return i(function(){x.update({key:E,src:o,originRef:C,render:P.render,overlay:l,width:h,height:m})},[o]),y?d.only(f(y,v({},_,{ref:C}))):null};export{ee as PhotoProvider,Q as PhotoSlider,ne as PhotoView}; | ||
//# sourceMappingURL=react-photo-view.module.js.map |
@@ -139,2 +139,3 @@ import type React from 'react'; | ||
onIndexChange: (index: number) => void; | ||
toggleFullScreen: () => void; | ||
/** | ||
@@ -141,0 +142,0 @@ * 是否可见 |
{ | ||
"name": "@starlly-labs/photo-viewer", | ||
"version": "1.0.6", | ||
"version": "1.0.7", | ||
"description": "An exquisite React photo preview component", | ||
@@ -5,0 +5,0 @@ "author": "johnjaider1000", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
420270
775