"use strict";function e(e){return e&&"object"==typeof e&&"default"in e?e.default:e}Object.defineProperty(exports,"__esModule",{value:!0});var t=require("react"),n=e(t),o=e(require("react-dom")),r=e(require("no-scroll")),i=e(require("classnames")),a=e(require("screenfull"));function c(e,t){if(null==e)return{};var n,o,r={},i=Object.keys(e);for(o=0;o=0||(r[n]=e[n]);return r}function l(e){var t=e.className,o=c(e,["className"]);return n.createElement("div",Object.assign({className:t},o),n.createElement("svg",{fill:"#ffffff",width:"24px",height:"24px",viewBox:"0 0 24 24"},n.createElement("path",{d:"M20 11H7.83l5.59-5.59L12 4l-8 8 8 8 1.41-1.41L7.83 13H20v-2z"})))}function u(e){var t=e.className,o=c(e,["className"]);return n.createElement("div",Object.assign({className:t},o),n.createElement("svg",{fill:"#ffffff",width:"36px",height:"36px",viewBox:"0 0 24 24"},n.createElement("path",{d:"M15.41 16.09l-4.58-4.59 4.58-4.59L14 5.5l-6 6 6 6z"})))}function s(e){var t=e.className,o=c(e,["className"]);return n.createElement("div",Object.assign({className:t},o),n.createElement("svg",{fill:"#ffffff",width:"36px",height:"36px",viewBox:"0 0 24 24"},n.createElement("path",{d:"M8.59 16.34l4.58-4.59-4.58-4.59L10 5.75l6 6-6 6z"})))}var d,h=function(e,n,o,r){var i=t.useRef();t.useEffect((function(){i.current=o}),[o]),t.useEffect((function(){if(r&&r.addEventListener){var t=function(e){return i.current(e)};return e&&r.addEventListener(n,t),function(){r.removeEventListener(n,t)}}}),[e,n,r])},f="undefined"!=typeof window;!function(e){e[e.Prev=0]="Prev",e[e.Next=1]="Next"}(d||(d={}));var g=function(e){var c,g,m,v,w,p=e.open,E=e.src,b=e.srcIndex,N=void 0===b?0:b,x=e.fullscreen,y=e.keyboardNavigation,k=void 0===y||y,C=e.closeOnEsc,L=void 0===C||C,O=e.mouseIdleTimeout,P=void 0===O?5e3:O,q=e.animationDuration,j=void 0===q?250:q,S=e.classNames,z=e.onClose,H=e.onChangeIndex,I=t.useRef(null),M=t.useRef(null),B=t.useState(p),R=B[0],T=B[1],W=t.useState({width:f?window.innerWidth:0,height:f?window.innerHeight:0}),_=W[0],A=W[1],D=t.useState(!1),F=D[0],G=D[1],J=t.useState(N),K=J[0],Q=J[1];null===I.current&&f&&(I.current=document.createElement("div"));var U=function(){r.on(),window.addEventListener("resize",Y),I.current&&!document.body.contains(I.current)&&document.body.appendChild(I.current),x&&a.isEnabled&&(a.request(),a.on("change",X))},V=function(){window.removeEventListener("resize",Y),I.current&&document.body.contains(I.current)&&document.body.removeChild(I.current),a.isEnabled&&(a.exit(),a.off("change",X)),r.off()};h(p,"keydown",(function(e){37===e.keyCode&&k?Z(d.Prev):39===e.keyCode&&k?Z(d.Next):27===e.keyCode&&L&&z()}),f?document:void 0),h(p,"mousemove",(function(){M.current&&clearTimeout(M.current),!0===F&&G(!1),M.current=setTimeout((function(){G(!0)}),P)}),f?document.querySelector("*"):void 0),t.useEffect((function(){Q(N)}),[N]),t.useEffect((function(){return p&&U(),function(){R&&V()}}),[]),t.useEffect((function(){p&&!R&&(T(!0),U())}),[p]);var X=function(){a.isEnabled&&!a.isFullscreen&&p&&z()},Y=function(){A({width:window.innerWidth,height:window.innerHeight})},Z=function(e){if(e===d.Prev&&0!==K){var t=K-1;H?H(t):Q(t)}else if(e===d.Next&&E[K+1]){var n=K+1;H?H(n):Q(n)}},$=E[K],ee={position:"absolute",overflow:"hidden",userSelect:"none"},te=$.width,ne=$.height;if(te>_.width){var oe=_.width/te;ne*=oe,te*=oe}if(ne>_.height){var re=_.height/ne;ne*=re,te*=re}return ne>te||te<_.width?(ee.left=(_.width-te)/2,ee.height=_.height,ee.width=te):(ee.top=(_.height-ne)/2,ee.height=ne,ee.width=_.width),_.height>ne?(ee.height=ne,ee.top=(_.height-ne)/2):_.width>te&&(ee.height=_.height,ee.left=(_.width-te)/2),R&&I.current?o.createPortal(n.createElement("div",{className:i("react-google-photo-overlay",null==S?void 0:S.overlay),style:{animation:(p?null!==(c=null==S?void 0:S.animationIn)&&void 0!==c?c:"react-google-photo-fade-in":null!==(g=null==S?void 0:S.animationOut)&&void 0!==g?g:"react-google-photo-fade-out")+" "+j+"ms"},onAnimationEnd:function(){p||(T(!1),V())}},n.createElement("div",{style:ee},E.map((function(e,t){var o;return n.createElement("img",{key:t,src:e.src,alt:e.alt,width:ee.width,height:ee.height,className:i("react-google-photo-overlay-image",null==S?void 0:S.image,(o={},o["react-google-photo-overlay-image-open"]=t===K,o))})}))),0!==K&&n.createElement("div",{className:i("react-google-photo-column","react-google-photo-left-column"),onClick:function(){return Z(d.Prev)}},n.createElement(u,{className:i("react-google-photo-arrow-button","react-google-photo-arrow-button-left",(m={},m["react-google-photo-arrow-button-hide"]=F,m))})),E[K+1]&&n.createElement("div",{className:i("react-google-photo-column","react-google-photo-right-column"),onClick:function(){return Z(d.Next)}},n.createElement(s,{className:i("react-google-photo-arrow-button","react-google-photo-arrow-button-right",(v={},v["react-google-photo-arrow-button-hide"]=F,v))})),n.createElement("div",{onClick:function(){z()}},n.createElement(l,{className:i("react-google-photo-arrow-button-return",(w={},w["react-google-photo-arrow-button-hide"]=F,w))}))),I.current):null};exports.GooglePhoto=g,exports.default=g; //# sourceMappingURL=react-google-photo.cjs.production.min.js.map