photoviewer
Version:
A JS plugin to view images just like in Windows.
15 lines • 43 kB
JavaScript
/*!
* ____ __ ______ __________ _ _____________ ____________
* / __ \/ / / / __ \/_ __/ __ \ | / / _/ ____/ | / / ____/ __ \
* / /_/ / /_/ / / / / / / / / / / | / // // __/ | | /| / / __/ / /_/ /
* / ____/ __ / /_/ / / / / /_/ /| |/ // // /___ | |/ |/ / /___/ _, _/
* /_/ /_/ /_/\____/ /_/ \____/ |___/___/_____/ |__/|__/_____/_/ |_|
*
* photoviewer - v3.10.3
* A JS plugin to view images just like in Windows.
* https://nzbin.github.io/photoviewer/
*
* Copyright (c) 2018-present nzbin
* Released under MIT License
*/
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):(t="undefined"!=typeof globalThis?globalThis:t||self).PhotoViewer=e()}(this,function(){"use strict";function A(t,e){for(var i=0;i<e.length;i++){var o=e[i];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(t,I(o.key),o)}}function n(t,e,i){(e=I(e))in t?Object.defineProperty(t,e,{value:i,enumerable:!0,configurable:!0,writable:!0}):t[e]=i}function I(t){t=function(t,e){if("object"!=typeof t||null===t)return t;var i=t[Symbol.toPrimitive];if(void 0===i)return("string"===e?String:Number)(t);if("object"!=typeof(i=i.call(t,e||"default")))return i;throw new TypeError("@@toPrimitive must return a primitive value.")}(t,"string");return"symbol"==typeof t?t:String(t)}var E=function(t,e){return new E.fn.init(t,e)},w=window.document,o=[],O=o.concat,F=o.filter,y=o.slice,j={},e={},B={"column-count":1,columns:1,"font-weight":1,"line-height":1,opacity:1,"z-index":1,zoom:1},N=/^\s*<(\w+|!)[^>]*>/,Y=/^<(\w+)\s*\/?>(?:<\/\1>|)$/,X=/<(?!area|br|col|embed|hr|img|input|link|meta|param)(([\w:]+)[^>]*)\/>/gi,q=/^(?:body|html)$/i,Z=["val","css","html","text","data","width","height","offset"],t=w.createElement("table"),W=w.createElement("tr"),U={tr:w.createElement("tbody"),tbody:t,thead:t,tfoot:t,td:W,th:W,"*":w.createElement("div")},K=/^[\w-]*$/,Q={},G=Q.toString,J=w.createElement("div"),l=Array.isArray||function(t){return"[object Array]"===Object.prototype.toString.call(t)},b=w.documentElement.contains?function(t,e){return t!==e&&t.contains(e)}:function(t,e){for(;e=e&&e.parentNode;)if(e===t)return!0;return!1};function h(t){return null==t?String(t):Q[G.call(t)]||"object"}function s(t){return"string"==typeof t}function c(t){return"function"==h(t)}function a(t){return null!=t&&t==t.window}function tt(t){return null!=t&&t.nodeType==t.DOCUMENT_NODE}function r(t){return"object"==h(t)}function u(t){return r(t)&&!a(t)&&Object.getPrototypeOf(t)==Object.prototype}function et(t){var e=!!t&&"length"in t&&t.length,i=h(t);return"function"!=i&&!a(t)&&("array"==i||0===e||"number"==typeof e&&0<e&&e-1 in t)}function d(t){return t.replace(/::/g,"/").replace(/([A-Z]+)([A-Z][a-z])/g,"$1_$2").replace(/([a-z\d])([A-Z])/g,"$1_$2").replace(/_/g,"-").toLowerCase()}function it(t,e){return"number"!=typeof e||B[d(t)]?e:e+"px"}function ot(t){return t.replace(/-+(.)?/g,function(t,e){return e?e.toUpperCase():""})}function nt(t){return t in e?e[t]:e[t]=new RegExp("(^|\\s)"+t+"(\\s|$)")}function f(t){return t instanceof E}function p(t,e,i,o){return c(e)?e.call(t,i,o):e}function st(t,e,i){null==i?t.removeAttribute(e):t.setAttribute(e,i)}function g(t,e){var i=t.className||"",o=i&&void 0!==i.baseVal;if(void 0===e)return o?i.baseVal:i;o?i.baseVal=e:t.className=e}function at(t,e){var i={width:["padding-left","padding-right","border-left-width","border-right-width"],height:["padding-top","padding-bottom","border-top-width","border-bottom-width"]};return"border-box"!==t.css("box-sizing")||0<window.navigator.userAgent.indexOf("MSIE ")||navigator.userAgent.match(/Trident.*rv:11\./)?parseFloat(t.css(e)):parseFloat(t.css(e))-parseFloat(t.css(i[e][0]))-parseFloat(t.css(i[e][1]))-parseFloat(t.css(i[e][2]))-parseFloat(t.css(i[e][3]))}function rt(e,i){var t=e.replace(/./,function(t){return t[0].toUpperCase()}),o=this[0];return void 0===i?a(o)?o.document.documentElement["client"+t]:tt(o)?o.documentElement["scroll"+t]:at(this,e):this.each(function(t){(o=E(this)).css(e,p(this,i,t,o[e]()))})}E.fn=E.prototype={constuctor:E,length:0,forEach:o.forEach,reduce:o.reduce,push:o.push,sort:o.sort,splice:o.splice,indexOf:o.indexOf,init:function(t,e){var i,o;if(!t)return this;if("string"==typeof t)if("<"==(t=t.trim())[0]&&N.test(t))i=E.fragment(t,RegExp.$1,e),t=null;else{if(void 0!==e)return E(e).find(t);i=E.qsa(w,t)}else{if(c(t))return E(w).ready(t);if(f(t))return t;if(l(t))o=t,i=F.call(o,function(t){return null!=t});else if(r(t))i=[t],t=null;else{if(void 0!==e)return E(e).find(t);i=E.qsa(w,t)}}return E.makeArray(i,t,this)},concat:function(){for(var t,e=[],i=0;i<arguments.length;i++)e[i]=f(t=arguments[i])?t.toArray():t;return O.apply(f(this)?this.toArray():this,e)},pluck:function(e){return E.map(this,function(t){return t[e]})},toArray:function(){return this.get()},get:function(t){return void 0===t?y.call(this):this[0<=t?t:t+this.length]},size:function(){return this.length},each:function(i){return o.every.call(this,function(t,e){return!1!==i.call(t,e,t)}),this},map:function(i){return E(E.map(this,function(t,e){return i.call(t,e,t)}))},slice:function(){return E(y.apply(this,arguments))},first:function(){var t=this[0];return t&&!r(t)?t:E(t)},last:function(){var t=this[this.length-1];return t&&!r(t)?t:E(t)},eq:function(t){return-1===t?this.slice(t):this.slice(t,+t+1)}},E.extend=E.fn.extend=function(){var t,e,i,o,n,s=arguments[0]||{},a=1,r=arguments.length,h=!1;for("boolean"==typeof s&&(h=s,s=arguments[a]||{},a++),"object"==typeof s||c(s)||(s={}),a===r&&(s=this,a--);a<r;a++)if(null!=(t=arguments[a]))for(e in t)n=s[e],s!==(i=t[e])&&(h&&i&&(u(i)||(o=l(i)))?(n=o?(o=!1,n&&l(n)?n:[]):n&&u(n)?n:{},s[e]=E.extend(h,n,i)):void 0!==i&&(s[e]=i));return s},E.extend({makeArray:function(t,e,i){for(var o=t?t.length:0,n=0;n<o;n++)i[n]=t[n];return i.length=o,i.selector=e||"",i},merge:function(t,e){for(var i=+e.length,o=0,n=t.length;o<i;o++)t[n++]=e[o];return t.length=n,t},qsa:function(t,e){var i,o="#"==e[0],n=!o&&"."==e[0],s=o||n?e.slice(1):e,a=K.test(s);return t.getElementById&&a&&o?(i=t.getElementById(s))?[i]:[]:1!==t.nodeType&&9!==t.nodeType&&11!==t.nodeType?[]:y.call(a&&!o&&t.getElementsByClassName?n?t.getElementsByClassName(s):t.getElementsByTagName(e):t.querySelectorAll(e))},fragment:function(t,e,i){var o,n,s;return(o=Y.test(t)?E(w.createElement(RegExp.$1)):o)||(t.replace&&(t=t.replace(X,"<$1></$2>")),void 0===e&&(e=N.test(t)&&RegExp.$1),(s=U[e=e in U?e:"*"]).innerHTML=""+t,o=E.each(y.call(s.childNodes),function(){s.removeChild(this)})),u(i)&&(n=E(o),E.each(i,function(t,e){-1<Z.indexOf(t)?n[t](e):n.attr(t,e)})),o},matches:function(t,e){var i,o;return!(!e||!t||1!==t.nodeType)&&((i=t.matches||t.webkitMatchesSelector||t.mozMatchesSelector||t.oMatchesSelector||t.matchesSelector)?i.call(t,e):((o=!(i=t.parentNode))&&(i=J).appendChild(t),i=~E.qsa(i,e).indexOf(t),o&&J.removeChild(t),i))},each:function(t,e){var i,o;if(et(t)){for(i=0;i<t.length;i++)if(!1===e.call(t[i],i,t[i]))return t}else for(o in t)if(!1===e.call(t[o],o,t[o]))return t;return t},map:function(t,e){var i,o,n,s,a=[];if(et(t))for(o=0;o<t.length;o++)null!=(i=e(t[o],o))&&a.push(i);else for(n in t)null!=(i=e(t[n],n))&&a.push(i);return 0<(s=a).length?E.fn.concat.apply([],s):s}}),E.each("Boolean Number String Function Array Date RegExp Object Error".split(" "),function(t,e){Q["[object "+e+"]"]=e.toLowerCase()}),E.fn.init.prototype=E.fn;function ht(){return!0}function lt(){return!1}var ct=1,x={},ut="onfocusin"in window,dt={focus:"focusin",blur:"focusout"},ft={mouseenter:"mouseover",mouseleave:"mouseout"},pt=/^([A-Z]|returnValue$|layer[XY]$|webkitMovement[XY]$)/,gt={preventDefault:"isDefaultPrevented",stopImmediatePropagation:"isImmediatePropagationStopped",stopPropagation:"isPropagationStopped"};function z(t){return t._zid||(t._zid=ct++)}function mt(o,n){if(n||!o.isDefaultPrevented){n=n||o,E.each(gt,function(t,e){var i=n[t];o[t]=function(){return this[e]=ht,i&&i.apply(n,arguments)},o[e]=lt});try{o.timeStamp||(o.timeStamp=Date.now())}catch(t){console.warn(t)}(void 0!==n.defaultPrevented?n.defaultPrevented:"returnValue"in n?!1===n.returnValue:n.getPreventDefault&&n.getPreventDefault())&&(o.isDefaultPrevented=ht)}return o}function vt(t){t=(""+t).split(".");return{e:t[0],ns:t.slice(1).sort().join(" ")}}function wt(t,e,i,o){var n,s;return(e=vt(e)).ns&&(s=e.ns,n=new RegExp("(?:^| )"+s.replace(" "," .* ?")+"(?: |$)")),(x[z(t)]||[]).filter(function(t){return t&&(!e.e||t.e==e.e)&&(!e.ns||n.test(t.ns))&&(!i||z(t.fn)===z(i))&&(!o||t.sel==o)})}function yt(t,e){return t.del&&!ut&&t.e in dt||!!e}function bt(t){return ft[t]||ut&&dt[t]||t}function xt(e,t,i,o,n){var s=z(e);(t||"").split(/\s/).forEach(function(t){wt(e,t,i,o).forEach(function(t){delete x[s][t.i],"removeEventListener"in e&&e.removeEventListener(bt(t.e),t.proxy,yt(t,n))})})}function zt(t,e,o,n){var i,s,a=E.map(e,function(t){var e=[];return"array"==(i=h(t))?(t.forEach(function(t){return void 0!==t.nodeType?e.push(t):f(t)?e=e.concat(t.get()):void(e=e.concat(E.fragment(t)))}),e):"object"==i||null==t?t:E.fragment(t)}),r=1<t.length;return a.length<1?t:t.each(function(t,e){s=n?e:e.parentNode;var i=b(w.documentElement,s);a.forEach(function(t){if(r)t=t.cloneNode(!0);else if(!s)return E(t).remove();o.call(e,t),i&&function t(e,i){i(e);for(var o=0,n=e.childNodes.length;o<n;o++)t(e.childNodes[o],i)}(t,function(t){var e;null==t.nodeName||"SCRIPT"!==t.nodeName.toUpperCase()||t.type&&"text/javascript"!==t.type||t.src||(e=t.ownerDocument?t.ownerDocument.defaultView:window).eval.call(e,t.innerHTML)})})})}var i,m="",v=w.createElement("div"),t=v.style.transitionProperty;function Mt(t){return i?i+t:t.toLowerCase()}void 0===v.style.transform&&E.each({Webkit:"webkit",Moz:"",O:"o"},function(t,e){if(void 0!==v.style[t+"TransitionProperty"])return m="-"+t.toLowerCase()+"-",i=e,!1}),v=null,E.fx={off:void 0===i&&void 0===t,speeds:{_default:400,fast:200,slow:600},cssPrefix:m,transitionEnd:Mt("TransitionEnd"),animationEnd:Mt("AnimationEnd")};var $t,Tt,Ct,Lt,_t,Et,Ht,kt,Vt,Dt=/^((translate|rotate|scale)(X|Y|Z|3d)?|matrix(3d)?|perspective|skew(X|Y)?)$/i,M={};function Pt(){return this.each(function(){var t,e,i;"none"==this.style.display&&(this.style.display=""),"none"==getComputedStyle(this,"").getPropertyValue("display")&&(this.style.display=(t=this.nodeName,j[t]||(e=w.createElement(t),w.body.appendChild(e),i=getComputedStyle(e,"").getPropertyValue("display"),e.parentNode.removeChild(e),j[t]=i="none"==i?"block":i),j[t]))})}function St(){return this.css("display","none")}function Rt(t,e,i,o,n){"function"!=typeof e||n||(n=e,e=void 0);i={opacity:i};return o&&(i.scale=o,t.css(E.fx.cssPrefix+"transform-origin","0 0")),t.animate(i,e,null,n)}$t=m+"transform",M[Tt=m+"transition-property"]=M[Ct=m+"transition-duration"]=M[_t=m+"transition-delay"]=M[Lt=m+"transition-timing-function"]=M[Et=m+"animation-name"]=M[Ht=m+"animation-duration"]=M[Vt=m+"animation-delay"]=M[kt=m+"animation-timing-function"]="";var W={find:function(t){var i=this,e=t?"object"==typeof t?E(t).filter(function(){var e=this;return o.some.call(i,function(t){return b(t,e)})}):1==this.length?E(E.qsa(this[0],t)):this.map(function(){return E.qsa(this,t)}):E();return e},closest:function(i,o){var n=[],s="object"==typeof i&&E(i);return this.each(function(t,e){for(;e&&!(s?0<=s.indexOf(e):E.matches(e,i));)e=e!==o&&!tt(e)&&e.parentNode;e&&n.indexOf(e)<0&&n.push(e)}),E(n)},css:function(t,e){if(arguments.length<2){var i,o,n=this[0];if("string"==typeof t)return n?n.style[ot(t)]||getComputedStyle(n,"").getPropertyValue(t):void 0;if(l(t))return n?(i={},o=getComputedStyle(n,""),E.each(t,function(t,e){i[e]=n.style[ot(e)]||o.getPropertyValue(e)}),i):void 0}var s="";if("string"==h(t))e||0===e?s=d(t)+":"+it(t,e):this.each(function(){this.style.removeProperty(d(t))});else for(var a in t)t[a]||0===t[a]?s+=d(a)+":"+it(a,t[a])+";":this.each(function(){this.style.removeProperty(d(a))});return this.each(function(){this.style.cssText+=";"+s})},addClass:function(i){var o=[];return i?this.each(function(t){var e;"className"in this&&(o=[],e=g(this),p(this,i,t,e).split(/\s+/g).forEach(function(t){E(this).hasClass(t)||o.push(t)},this),o.length)&&g(this,e+(e?" ":"")+o.join(" "))}):this},hasClass:function(t){return!!t&&o.some.call(this,function(t){return this.test(g(t))},nt(t))},removeClass:function(e){var i=[];return this.each(function(t){if("className"in this){if(void 0===e)return g(this,"");i=g(this),p(this,e,t,i).split(/\s+/g).forEach(function(t){i=i.replace(nt(t)," ")}),g(this,i.trim())}})},attr:function(i,o){var t;return"string"!=typeof i||1 in arguments?this.each(function(t){if(1===this.nodeType)if(r(i))for(var e in i)st(this,e,i[e]);else st(this,i,p(this,o,t,this.getAttribute(i)))}):0 in this&&1==this[0].nodeType&&null!=(t=this[0].getAttribute(i))?t:void 0},removeAttr:function(t){return this.each(function(){1===this.nodeType&&t.split(" ").forEach(function(t){st(this,t)},this)})},append:function(){return zt(this,arguments,function(t){this.insertBefore(t,null)},!0)},remove:function(){return this.each(function(){if(1===this.nodeType){r=void 0!==(n=this).getElementsByTagName?n.getElementsByTagName(s||"*"):void 0!==n.querySelectorAll?n.querySelectorAll(s||"*"):[];for(var t,i,e=void 0===s||s&&(s=s,(a=n).nodeName)&&a.nodeName.toLowerCase()===s.toLowerCase()?E.merge([n],r):r,o=0;void 0!==(i=e[o]);o++)i._zid&&(t=x[i._zid])&&t.forEach(t=>{var e=t.e+"."+t.ns.split(" ").join(".");xt(i,e,t.fn,t.sel)})}var n,s,a,r;null!=this.parentNode&&this.parentNode.removeChild(this)})},empty:function(){return this.each(function(){this.innerHTML=""})},html:function(i){return 0 in arguments?this.each(function(t){var e=this.innerHTML;E(this).empty().append(p(this,i,t,e))}):0 in this?this[0].innerHTML:null},width:function(t){return rt.call(this,"width",t)},height:function(t){return rt.call(this,"height",t)},scrollTop:function(t){var e;if(this.length)return e="scrollTop"in this[0],void 0===t?e?this[0].scrollTop:(a(this[0])?this[0]:this[0].defaultView).pageYOffset:this.each(e?function(){this.scrollTop=t}:function(){this.scrollTo(this.scrollX,t)})},scrollLeft:function(t){var e;if(this.length)return e="scrollLeft"in this[0],void 0===t?e?this[0].scrollLeft:(a(this[0])?this[0]:this[0].defaultView).pageXOffset:this.each(e?function(){this.scrollLeft=t}:function(){this.scrollTo(t,this.scrollY)})},offset:function(o){var t;return o?this.each(function(t){var e=E(this),t=p(this,o,t,e.offset()),i=e.offsetParent().offset(),t={top:t.top-i.top,left:t.left-i.left};"static"==e.css("position")&&(t.position="relative"),e.css(t)}):this.length?w.documentElement===this[0]||b(w.documentElement,this[0])?{left:(t=this[0].getBoundingClientRect()).left+window.pageXOffset,top:t.top+window.pageYOffset,width:Math.round(t.width),height:Math.round(t.height)}:{top:0,left:0}:null},offsetParent:function(){return this.map(function(){for(var t=this.offsetParent||w.body;t&&!q.test(t.nodeName)&&"static"==E(t).css("position");)t=t.offsetParent;return t})},position:function(){var t,e,i,o;if(this.length)return t=this[0],i=this.offsetParent(),o=q.test(i[0].nodeName)?{top:0,left:0}:i.offset(),"fixed"===E(t).css("position")?e=t.getBoundingClientRect():(e=this.offset(),o.top+=parseFloat(E(i[0]).css("border-top-width"))||0,o.left+=parseFloat(E(i[0]).css("border-left-width"))||0),{top:e.top-o.top-parseFloat(E(t).css("margin-top"))||0,left:e.left-o.left-parseFloat(E(t).css("margin-left"))||0}},on:function(u,d,f,p,g){var m,v,i=this;return u&&!s(u)?(E.each(u,function(t,e){i.on(t,d,f,e,g)}),i):(s(d)||c(p)||!1===p||(p=f,f=d,d=void 0),void 0!==p&&!1!==f||(p=f,f=void 0),!1===p&&(p=lt),i.each(function(t,i){var o,e,n,s,a,r,h,l,c;g&&(m=function(t){return xt(i,t.type,p),p.apply(this,arguments)}),e=u,n=p,s=f,r=(v=(a=d)?function(t){var e=E(t.target).closest(d,i).get(0);if(e&&e!==i)return t=E.extend(function(t){var e,i={originalEvent:t};for(e in t)pt.test(e)||void 0===t[e]||(i[e]=t[e]);return mt(i,t)}(t),{currentTarget:e,liveFired:i}),(m||p).apply(e,[t].concat(y.call(arguments,1)))}:v)||m,l=z(o=i),c=x[l]||(x[l]=[]),e.split(/\s/).forEach(function(t){if("ready"==t)return E(w).ready(n);var e=vt(t),i=(e.fn=n,e.sel=a,e.e in ft&&(n=function(t){t=t.relatedTarget;if(!t||t!==this&&!b(this,t))return e.fn.apply(this,arguments)}),(e.del=r)||n);e.proxy=function(t){var e;if(!(t=mt(t)).isImmediatePropagationStopped())return t.data=s,!1===(e=i.apply(o,null==t._args?[t]:[t].concat(t._args)))&&(t.preventDefault(),t.stopPropagation()),e},e.i=c.length,c.push(e),"addEventListener"in o&&o.addEventListener(bt(e.e),e.proxy,yt(e,h))})}))},off:function(t,i,e){var o=this;return t&&!s(t)?(E.each(t,function(t,e){o.off(t,i,e)}),o):(s(i)||c(e)||!1===e||(e=i,i=void 0),!1===e&&(e=lt),o.each(function(){xt(this,t,e,i)}))},show:function(t,e){return Pt.call(this),void 0===t?t=0:this.css("opacity",0),Rt(this,t,1,"1,1",e)},hide:function(t,e){return void 0===t?St.call(this):(i=e,Rt(this,t,0,"0,0",function(){St.call(E(this)),i&&i.call(this)}));var i},anim:function(t,e,i,o,n){var s,a,r,h={},l="",c=this,u=E.fx.transitionEnd,d=!1;if(void 0===e&&(e=E.fx.speeds._default/1e3),void 0===n&&(n=0),E.fx.off&&(e=0),"string"==typeof t)h[Et]=t,h[Ht]=e+"s",h[Vt]=n+"s",h[kt]=i||"linear",u=E.fx.animationEnd;else{for(s in a=[],t)Dt.test(s)?l+=s+"("+t[s]+") ":(h[s]=t[s],a.push(s.replace(/([A-Z])/g,"-$1").toLowerCase()));l&&(h[$t]=l,a.push($t)),0<e&&"object"==typeof t&&(h[Tt]=a.join(", "),h[Ct]=e+"s",h[_t]=n+"s",h[Lt]=i||"linear")}return r=function(t){if(void 0!==t){if(t.target!==t.currentTarget)return;E(t.target).off(u,r)}else E(this).off(u,r);d=!0,E(this).css(M),o&&o.call(this)},0<e&&(this.on(u,r),setTimeout(function(){d||r.call(c)},1e3*(e+n)+25)),this.size()&&this.get(0).clientLeft,this.css(h),e<=0&&setTimeout(function(){c.each(function(){r.call(this)})},0),this},animate:function(t,e,i,o,n){return c(e)&&(o=e,e=i=void 0),c(i)&&(o=i,i=void 0),u(e)&&(i=e.easing,o=e.complete,n=e.delay,e=e.duration),e=e&&("number"==typeof e?e:E.fx.speeds[e]||E.fx.speeds._default)/1e3,n=n&&parseFloat(n)/1e3,this.anim(t,e,i,o,n)},fadeTo:function(t,e,i){return Rt(this,t,e,null,i)},fadeIn:function(t,e){var i=this.css("opacity");return 0<i?this.css("opacity",0):i=1,Pt.call(this).fadeTo(t,i,e)}},At=(E.extend({isPlainObject:u,isArray:l,isFunction:c,noop:function(){}}),E.fn.extend(W),{draggable:!0,resizable:!0,movable:!0,keyboard:!0,title:!0,modalWidth:320,modalHeight:320,fixedModalSize:!1,initMaximized:!1,gapThreshold:.02,ratioThreshold:.1,minRatio:.05,maxRatio:16,headerToolbar:["maximize","close"],footerToolbar:["zoomIn","zoomOut","prev","fullscreen","next","actualSize","rotateRight"],icons:{minimize:'<svg viewBox="0 0 24 24" class="svg-inline-icon">\n <path fill="currentColor" d="M20,14H4V10H20"></path>\n </svg>',maximize:'<svg viewBox="0 0 24 24" class="svg-inline-icon">\n <path fill="currentColor" d="M4,4H20V20H4V4M6,8V18H18V8H6Z"></path>\n </svg>',close:'<svg viewBox="0 0 24 24" class="svg-inline-icon">\n <path fill="currentColor" d="M13.46,12L19,17.54V19H17.54L12,13.46L6.46,19H5V17.54L10.54,12\n L5,6.46V5H6.46L12,10.54L17.54,5H19V6.46L13.46,12Z"></path>\n </svg>',zoomIn:'<svg viewBox="0 0 24 24" class="svg-inline-icon">\n <path fill="currentColor" d="M15.5,14L20.5,19L19,20.5L14,15.5V14.71L13.73,14.43\n C12.59,15.41 11.11,16 9.5,16A6.5,6.5 0 0,1 3,9.5A6.5,6.5 0 0,1 9.5,3A6.5,6.5 0 0,1 16,9.5\n C16,11.11 15.41,12.59 14.43,13.73L14.71,14H15.5M9.5,14C12,14 14,12 14,9.5C14,7 12,5 9.5,5\n C7,5 5,7 5,9.5C5,12 7,14 9.5,14M12,10H10V12H9V10H7V9H9V7H10V9H12V10Z"></path>\n </svg>',zoomOut:'<svg viewBox="0 0 24 24" class="svg-inline-icon">\n <path fill="currentColor" d="M15.5,14H14.71L14.43,13.73C15.41,12.59 16,11.11 16,9.5\n A6.5,6.5 0 0,0 9.5,3A6.5,6.5 0 0,0 3,9.5A6.5,6.5 0 0,0 9.5,16\n C11.11,16 12.59,15.41 13.73,14.43L14,14.71V15.5L19,20.5L20.5,19L15.5,14M9.5,14\n C7,14 5,12 5,9.5C5,7 7,5 9.5,5C12,5 14,7 14,9.5C14,12 12,14 9.5,14M7,9H12V10H7V9Z"></path>\n </svg>',prev:'<svg viewBox="0 0 24 24" class="svg-inline-icon">\n <path fill="currentColor" d="M6,18V6H8V18H6M9.5,12L18,6V18L9.5,12Z"></path>\n </svg>',next:'<svg viewBox="0 0 24 24" class="svg-inline-icon">\n <path fill="currentColor" d="M16,18H18V6H16M6,18L14.5,12L6,6V18Z"></path>\n </svg>',fullscreen:'<svg viewBox="0 0 24 24" class="svg-inline-icon">\n <path fill="currentColor" d="M8.5,12.5L11,15.5L14.5,11L19,17H5M23,18V6A2,2 0 0,0 21,4H3\n A2,2 0 0,0 1,6V18A2,2 0 0,0 3,20H21A2,2 0 0,0 23,18Z"></path>\n </svg>',actualSize:'<svg viewBox="0 0 24 24" class="svg-inline-icon">\n <path fill="currentColor" d="M9.5,13.09L10.91,14.5L6.41,19H10V21H3V14H5V17.59L9.5,13.09\n M10.91,9.5L9.5,10.91L5,6.41V10H3V3H10V5H6.41L10.91,9.5M14.5,13.09L19,17.59V14H21V21H14V19\n H17.59L13.09,14.5L14.5,13.09M13.09,9.5L17.59,5H14V3H21V10H19V6.41L14.5,10.91\n L13.09,9.5Z"></path>\n </svg>',rotateLeft:'<svg viewBox="0 0 24 24" class="svg-inline-icon">\n <path fill="currentColor" d="M13,4.07V1L8.45,5.55L13,10V6.09C15.84,6.57 18,9.03 18,12\n C18,14.97 15.84,17.43 13,17.91V19.93C16.95,19.44 20,16.08 20,12C20,7.92 16.95,4.56 13,4.07\n M7.1,18.32C8.26,19.22 9.61,19.76 11,19.93V17.9C10.13,17.75 9.29,17.41 8.54,16.87L7.1,18.32\n M6.09,13H4.07C4.24,14.39 4.79,15.73 5.69,16.89L7.1,15.47C6.58,14.72 6.23,13.88 6.09,13\n M7.11,8.53L5.7,7.11C4.8,8.27 4.24,9.61 4.07,11H6.09C6.23,10.13 6.58,9.28 7.11,8.53Z"></path>\n </svg>',rotateRight:'<svg viewBox="0 0 24 24" class="svg-inline-icon">\n <path fill="currentColor" d="M16.89,15.5L18.31,16.89C19.21,15.73 19.76,14.39 19.93,13H17.91\n C17.77,13.87 17.43,14.72 16.89,15.5M13,17.9V19.92C14.39,19.75 15.74,19.21 16.9,18.31\n L15.46,16.87C14.71,17.41 13.87,17.76 13,17.9M19.93,11C19.76,9.61 19.21,8.27 18.31,7.11\n L16.89,8.53C17.43,9.28 17.77,10.13 17.91,11M15.55,5.55L11,1V4.07C7.06,4.56 4,7.92 4,12\n C4,16.08 7.05,19.44 11,19.93V17.91C8.16,17.43 6,14.97 6,12C6,9.03 8.16,6.57 11,6.09V10\n L15.55,5.55Z"></path>\n </svg>'},i18n:{minimize:"Minimize",maximize:"Maximize (Alt+X)",close:"Close (Q)",zoomIn:"Zoom-in (+)",zoomOut:"Zoom-out (-)",prev:"Prev (←)",next:"Next (→)",fullscreen:"Fullscreen (F)",actualSize:"Actual-size (Ctrl+Alt+0)",rotateLeft:"Rotate-left (Ctrl+,)",rotateRight:"Rotate-right (Ctrl+.)"},multiInstances:!0,initAnimation:!0,animationDuration:400,animationEasing:"ease-in-out",fixedModalPos:!1,zIndex:1090,dragHandle:null,callbacks:{beforeOpen:E.noop,opened:E.noop,beforeClose:E.noop,closed:E.noop,beforeChange:E.noop,changed:E.noop},index:0,progressiveLoading:!0,appendTo:"body",customButtons:{},positionFixed:!0,initModalPos:null,errorMsg:""}),It=window.document;function Ot(t,e,i,o){var n=o?t.h:t.w,o=o?t.w:t.h;(o>e.h||n>e.w)&&i.addClass("is-grab"),o<=e.h&&n<=e.w&&i.removeClass("is-grab")}function Ft(){return"ontouchstart"in window||window.DocumentTouch&&It instanceof window.DocumentTouch}function $(t){return/^(?:body|html)$/i.test(t.nodeName)}function T(i,t){return t.reduce(function(t,e){return t+parseFloat(i.css(e))},0)}function H(t){return"border-box"===t.css("box-sizing")}function jt(t,e,i,o,n){return n?Math.min(i/e,o/t,1):Math.min(i/t,o/e,1)}var C=E(window),k=E(It),L="click",Bt=Ft()?"touchstart":"mousedown",V=Ft()?"touchmove":"mousemove",D=Ft()?"touchend":"mouseup",P="photoviewer",_="."+P,S="."+P,R={isMoving:!1,isResizing:!1,zIndex:0};var Nt="html, body, .".concat(P,"-modal, .").concat(P,"-stage, .").concat(P,"-button, .").concat(P,"-resizable-handle");var Yt="html, body, .".concat(P,"-modal, .").concat(P,"-stage, .").concat(P,"-button");t=function(){function i(t,e){if(!(this instanceof i))throw new TypeError("Cannot call a class as a function");n(this,"isOpened",!1),n(this,"isMaximized",!1),n(this,"isRotated",!1),n(this,"rotationDegree",0),n(this,"imageData",{}),n(this,"modalData",{width:null,height:null,left:null,top:null}),n(this,"prevIndex",null),n(this,"_lastTimestamp",0),this.init(t,e)}var t,e,o;return t=i,(e=[{key:"init",value:function(t,e){this.options=E.extend(!0,{},At,e),e&&E.isArray(e.footerToolbar)&&(this.options.footerToolbar=e.footerToolbar),e&&E.isArray(e.headerToolbar)&&(this.options.headerToolbar=e.headerToolbar),R.zIndex=(0===R.zIndex?this.options:R).zIndex,this.open(),this.images=t,this.index=this.options.index,this._loadImage(this.index),this.options.draggable&&this.draggable(this.$photoviewer,this.dragHandle,_+"-button"),this.options.movable&&this.movable(this.$stage,this.$image),this.options.resizable&&this.resizable(this.$photoviewer,this.$stage,this.$image,this.options)}},{key:"_createBtns",value:function(t){var o=this,n=["minimize","maximize","close","zoomIn","zoomOut","prev","next","fullscreen","actualSize","rotateLeft","rotateRight"],s="";return E.each(t,function(t,e){var i="".concat(P,"-button ").concat(P,"-button-").concat(e);0<=n.indexOf(e)?s+='<button class="'.concat(i,'" title="').concat(o.options.i18n[e],'">\n ').concat(o.options.icons[e],"\n </button>"):o.options.customButtons[e]&&(s+='<button class="'.concat(i,'" title="').concat(o.options.customButtons[e].title||"",'">\n ').concat(o.options.customButtons[e].text,"\n </button>"))}),s}},{key:"_createTitle",value:function(){return this.options.title?'<div class="'.concat(P,'-title"></div>'):""}},{key:"_createTemplate",value:function(){return'<div class="'.concat(P,'-modal" tabindex="0" role="dialog">\n <div class="').concat(P,'-inner">\n <div class="').concat(P,'-header">\n <div class="').concat(P,"-toolbar ").concat(P,'-toolbar-header">\n ').concat(this._createBtns(this.options.headerToolbar),"\n </div>\n ").concat(this._createTitle(),'\n </div>\n <div class="').concat(P,'-stage">\n <img class="').concat(P,'-image" src="" alt="" />\n </div>\n <div class="').concat(P,'-footer">\n <div class="').concat(P,"-toolbar ").concat(P,'-toolbar-footer">\n ').concat(this._createBtns(this.options.footerToolbar),"\n </div>\n </div>\n </div>\n </div>").replace(/>\s+</g,"><")}},{key:"_build",value:function(){var t=this._createTemplate(),t=E(t);this.$photoviewer=t,this.$stage=t.find(_+"-stage"),this.$title=t.find(_+"-title"),this.$image=t.find(_+"-image"),this.$close=t.find(_+"-button-close"),this.$maximize=t.find(_+"-button-maximize"),this.$minimize=t.find(_+"-button-minimize"),this.$zoomIn=t.find(_+"-button-zoomIn"),this.$zoomOut=t.find(_+"-button-zoomOut"),this.$actualSize=t.find(_+"-button-actualSize"),this.$fullscreen=t.find(_+"-button-fullscreen"),this.$rotateLeft=t.find(_+"-button-rotateLeft"),this.$rotateRight=t.find(_+"-button-rotateRight"),this.$prev=t.find(_+"-button-prev"),this.$next=t.find(_+"-button-next"),this.$photoviewer.css("z-index",R.zIndex),this.options.positionFixed&&this.$photoviewer.css({position:"fixed"}),this.options.dragHandle&&this.options.dragHandle!==_+"-modal"?this.dragHandle=this.$photoviewer.find(this.options.dragHandle):this.dragHandle=this.$photoviewer,E(this.options.appendTo).eq(0).append(this.$photoviewer),this._stageEdgeValue={horizontal:T(this.$stage,["left","right","border-left-width","border-right-width"]),vertical:T(this.$stage,["top","bottom","border-top-width","border-bottom-width"])},this._modalEdgeValue={horizontal:T(this.$photoviewer,["padding-left","padding-right","border-left-width","border-right-width"]),vertical:T(this.$photoviewer,["padding-top","padding-bottom","border-top-width","border-bottom-width"])},this._addEvents(),this._addCustomButtonEvents()}},{key:"open",value:function(){this._triggerHook("beforeOpen",this),!this.options.multiInstances&&0<i.instances.length&&i.instances[0].close(),this._build(),this._setInitModalPos(),i.instances.push(this),this._triggerHook("opened",this)}},{key:"close",value:function(){var e=this;this._triggerHook("beforeClose",this),this.$photoviewer.remove(),0===(i.instances=i.instances.filter(function(t){return t!==e})).length&&(R.zIndex=this.options.zIndex,C.off("resize"+S)),this._triggerHook("closed",this)}},{key:"_getOffsetParentData",value:function(){var t=E(this.options.appendTo)[0];return{width:this.options.positionFixed||$(t)?C.width():t.clientWidth,height:this.options.positionFixed||$(t)?C.height():t.clientHeight,scrollLeft:this.options.positionFixed?0:$(t)?k.scrollLeft():t.scrollLeft,scrollTop:this.options.positionFixed?0:$(t)?k.scrollTop():t.scrollTop}}},{key:"_setModalToCenter",value:function(){var t,e,i,o,n,s=0,a=0,s=(H(this.$photoviewer)||(s+=this._modalEdgeValue.horizontal,a+=this._modalEdgeValue.vertical),E.isPlainObject(this.options.initModalPos)?(o=this.options.initModalPos.left,n=this.options.initModalPos.top,t=this.options.initModalPos.right,e=this.options.initModalPos.bottom):(o=((i=this._getOffsetParentData()).width-this.options.modalWidth-s)/2+i.scrollLeft,n=(i.height-this.options.modalHeight-a)/2+i.scrollTop),{width:this.modalData.width||this.options.modalWidth,height:this.modalData.height||this.options.modalHeight,left:this.modalData.left||o,top:this.modalData.top||n,right:this.modalData.right||t,bottom:this.modalData.bottom||e});this.$photoviewer.css(s)}},{key:"_setInitModalPos",value:function(){this.options.initMaximized?(this.maximize(),this.isOpened=!0):this._setModalToCenter(),this.$photoviewer[0].focus()}},{key:"_setModalSize",value:function(){var t,e,i,o,n=this,s=this.imageData.originalWidth+this._stageEdgeValue.horizontal,a=this.imageData.originalHeight+this._stageEdgeValue.vertical,r=0,h=0,l=(H(this.$photoviewer)?(s+=this._modalEdgeValue.horizontal,a+=this._modalEdgeValue.vertical):(r+=this._modalEdgeValue.horizontal,h+=this._modalEdgeValue.vertical),this._getOffsetParentData()),c=Math.max(this.options.gapThreshold,0)+1,c=Math.min(l.width/((s+r)*c),l.height/((a+h)*c),1),s=Math.max(s*c,this.options.modalWidth),a=Math.max(a*c,this.options.modalHeight),s=this.options.fixedModalSize?this.options.modalWidth:Math.round(s),a=this.options.fixedModalSize?this.options.modalHeight:Math.round(a),c=(E.isPlainObject(this.options.initModalPos)?(t=this.options.initModalPos.left,e=this.options.initModalPos.top,i=this.options.initModalPos.right,o=this.options.initModalPos.bottom):(t=(l.width-s-r)/2+l.scrollLeft,e=(l.height-a-h)/2+l.scrollTop),{width:s,height:a,left:t,top:e,right:i,bottom:o});this.options.initAnimation?this.$photoviewer.animate(c,this.options.animationDuration,this.options.animationEasing,function(){n._setImageSize()}):(this.$photoviewer.css(c),this._setImageSize()),this.isOpened=!0}},{key:"_setImageSize",value:function(){var t=this.$stage.width(),e=this.$stage.height(),i=this.imageData,o=i.originalWidth,i=i.originalHeight,n=jt(o,i,t,e,this.isRotated),o=o*n,i=i*n;this.$image.css({width:Math.round(o),height:Math.round(i),left:(t-Math.round(o))/2,top:(e-Math.round(i))/2}),E.extend(this.imageData,{initWidth:o,initHeight:i,initLeft:(t-o)/2,initTop:(e-i)/2,width:o,height:i,left:(t-o)/2,top:(e-i)/2}),Ot({w:o,h:i},{w:t,h:e},this.$stage,this.isRotated),this.imageLoaded||(this.$photoviewer.find(_+"-loader").remove(),this.$stage.removeClass(P+"-align-center"),this.options.initAnimation&&!this.options.progressiveLoading&&this.$image.fadeIn(),this.imageLoaded=!0,this._triggerHook("changed",[this,this.index]))}},{key:"_loadImage",value:function(t){var e,i,o,n=this,s=(this.imageLoaded=!1,this._triggerHook("beforeChange",[this,this.prevIndex]),this._removeErrorMsg(),this.$image.removeAttr("style").attr("src",""),this.isRotated=!1,this.rotationDegree=0,this.$photoviewer.append('<div class="'.concat(P,'-loader"></div>')),this.$stage.addClass(P+"-align-center"),this.options.initAnimation&&!this.options.progressiveLoading&&this.$image.hide(),null==(null==(s=this.images[t])?void 0:s.src)?"":this.images[t].src.toString()),a=(this.$image.attr("src",s),(null==(a=this.images[t])?void 0:a.title)||s.replace(/^.*?\/*([^/?]*)\.[a-z]+(\?.+|$)/gi,"$1"));this.options.title&&this.$title.html(a),this.$image.attr("alt",a),a=s,e=function(t){n.imageData={originalWidth:t.width,originalHeight:t.height},n.isMaximized||n.isOpened&&n.options.fixedModalPos?n._setImageSize():n._setModalSize()},i=function(){n.$photoviewer.find(_+"-loader").remove(),n._triggerHook("changed",[n,t]),n._setErrorMsg()},(o=new Image).onload=function(){e(o)},o.onerror=function(){i(o)},o.src=a}},{key:"_setErrorMsg",value:function(){var t=E.isFunction(this.options.errorMsg)?this.options.errorMsg(this,this.index):this.options.errorMsg;t&&(this.$stage.append('<span class="'.concat(P,'-error-msg">').concat(t,"</span>")),this.$image.addClass(P+"-image-error"))}},{key:"_removeErrorMsg",value:function(){this.$stage.find(_+"-error-msg").remove(),this.$image.removeClass(P+"-image-error")}},{key:"jump",value:function(t){var e=Date.now();e-this._lastTimestamp>=this.options.animationDuration&&(t=this.index+t,this.jumpTo(t),this._lastTimestamp=e)}},{key:"jumpTo",value:function(t){this.prevIndex=this.index;t%=this.images.length;t<=0&&(t=(t+this.images.length)%this.images.length),this.index=t,this._loadImage(this.index)}},{key:"_wheel",value:function(t){t.preventDefault();var e=1,e=(t.deltaY?e=0<t.deltaY?1:-1:t.wheelDelta?e=-t.wheelDelta/120:t.detail&&(e=0<t.detail?1:-1),-e*this.options.ratioThreshold),t={x:t.clientX-this.$stage.offset().left+k.scrollLeft(),y:t.clientY-this.$stage.offset().top+k.scrollTop()};this.zoom(e,t)}},{key:"zoom",value:function(t,e){t=t<0?1/(1-t):1+t,(t=this.$image.width()/this.imageData.originalWidth*t)>this.options.maxRatio||t<this.options.minRatio||this.zoomTo(t,e)}},{key:"zoomTo",value:function(t,e){var i=this.imageData,o=i.originalWidth,n=i.originalHeight,s=i.width,a=i.height,r=i.left,h=i.top,i=i.initWidth,l=this.$stage.width(),c=this.$stage.height(),o=o*t,n=n*t,t=(e=void 0===e?{x:l/2,y:c/2}:e).x-(e.x-r)/s*o,r=e.y-(e.y-h)/a*n,s=this.isRotated?(o-n)/2:0,e=this.isRotated?n:o,h=this.isRotated?o:n,a=l-o,u=c-n,t=e<=l?a/2:-s<t?-s:Math.max(t,a+s),r=h<=c?u/2:s<r?s:Math.max(r,u-s);Math.abs(i-o)<.05*i?this._setImageSize():(this.$image.css({width:Math.round(o),height:Math.round(n),left:Math.round(t),top:Math.round(r)}),Ot({w:Math.round(e),h:Math.round(h)},{w:l,h:c},this.$stage)),E.extend(this.imageData,{width:o,height:n,left:t,top:r})}},{key:"rotate",value:function(t){this.rotationDegree=this.rotationDegree+t,this.rotationDegree/90%2==0?this.isRotated=!1:this.isRotated=!0,this.rotateTo(this.rotationDegree)}},{key:"rotateTo",value:function(t){this.$image.css({transform:"rotate("+t+"deg)"}),this._setImageSize()}},{key:"maximize",value:function(){this.$photoviewer.addClass(P+"-maximized"),this.$photoviewer.css({width:"auto",height:"auto",top:0,right:0,bottom:0,left:0}),this.isMaximized=!0}},{key:"exitMaximize",value:function(){this.$photoviewer.removeClass(P+"-maximized"),this._setModalToCenter(),this.isMaximized=!1}},{key:"toggleMaximize",value:function(){var t,e;this.isMaximized?this.exitMaximize():(t=this.$photoviewer.width(),e=this.$photoviewer.height(),H(this.$photoviewer)&&(t+=this._modalEdgeValue.horizontal,e+=this._modalEdgeValue.vertical),this.modalData={width:t,height:e,left:parseFloat(this.$photoviewer.css("left")),top:parseFloat(this.$photoviewer.css("top"))},this.maximize()),this._setImageSize(),this.$photoviewer[0].focus()}},{key:"fullscreen",value:function(){var t;(t=this.$photoviewer[0]).requestFullscreen?t.requestFullscreen():t.mozRequestFullScreen?t.mozRequestFullScreen():t.webkitRequestFullscreen?t.webkitRequestFullscreen():t.msRequestFullscreen&&t.msRequestFullscreen(),this.$photoviewer[0].focus()}},{key:"resize",value:function(){this.isOpened&&(this.isMaximized?this._setImageSize():this._setModalSize())}},{key:"_keydown",value:function(t){if(this.options.keyboard){var e=t.keyCode||t.which||t.charCode,i=t.ctrlKey||t.metaKey,o=t.altKey;switch(e){case 37:this.jump(-1);break;case 39:this.jump(1);break;case 187:this.zoom(3*this.options.ratioThreshold,{x:this.$stage.width()/2,y:this.$stage.height()/2},t);break;case 189:this.zoom(3*-this.options.ratioThreshold,{x:this.$stage.width()/2,y:this.$stage.height()/2},t);break;case 61:this.zoom(3*this.options.ratioThreshold,{x:this.$stage.width()/2,y:this.$stage.height()/2},t);break;case 173:this.zoom(3*-this.options.ratioThreshold,{x:this.$stage.width()/2,y:this.$stage.height()/2},t);break;case 48:i&&o&&this.zoomTo(1,{x:this.$stage.width()/2,y:this.$stage.height()/2},t);break;case 188:i&&(t.preventDefault(),this.rotate(-90));break;case 190:i&&this.rotate(90);break;case 81:this.close();break;case 88:o&&this.toggleMaximize();break;case 70:this.fullscreen()}}}},{key:"_addEvents",value:function(){var i,o,n,e=this;this.$close.on(L+S,function(){e.close()}),this.$stage.on("wheel mousewheel DOMMouseScroll"+S,function(t){e._wheel(t)}),this.$zoomIn.on(L+S,function(){e.zoom(3*e.options.ratioThreshold)}),this.$zoomOut.on(L+S,function(){e.zoom(3*-e.options.ratioThreshold)}),this.$actualSize.on(L+S,function(){e.zoomTo(1)}),this.$prev.on(L+S,function(){e.jump(-1)}),this.$next.on(L+S,function(){e.jump(1)}),this.$rotateLeft.on(L+S,function(){e.rotate(-90)}),this.$rotateRight.on(L+S,function(){e.rotate(90)}),this.$maximize.on(L+S,function(){e.toggleMaximize()}),this.$fullscreen.on(L+S,function(){e.fullscreen()}),this.$photoviewer.on("keydown"+S,function(t){e._keydown(t)}),C.on("resize"+S,(i=function(){return e.resize()},o=500,n=null,function(){var t=this,e=arguments;clearTimeout(n),n=setTimeout(function(){i.apply(t,e)},o)}))}},{key:"_addCustomButtonEvents",value:function(){var t,i=this;for(t in this.options.customButtons)!function(e){i.$photoviewer.find(_+"-button-"+e).on(L+S,function(t){i.options.customButtons[e].click.apply(i,[i,t])})}(t)}},{key:"_triggerHook",value:function(t,e){this.options.callbacks[t]&&this.options.callbacks[t].apply(this,E.isArray(e)?e:[e])}}])&&A(t.prototype,e),o&&A(t,o),Object.defineProperty(t,"prototype",{writable:!1}),i}();return n(t,"instances",[]),E.extend(t.prototype,{draggable:function(i,t,e){function o(){k.off(V+S,l).off(D+S,o)}var n=this,s=0,a=0,r=0,h=0,l=function(t){var e;(t=t||window.event).preventDefault(),R.isMoving||R.isResizing||n.isMaximized||(e="touchmove"===t.type?t.targetTouches[0].pageX:t.clientX,t="touchmove"===t.type?t.targetTouches[0].pageY:t.clientY,e=e-s,t=t-a,i.css({left:e+r,top:t+h}))};E(t).on(Bt+S,function(t){if(t=t||window.event,i[0].focus(),E(t.target).closest(e).length)return!0;n.options.multiInstances&&i.css("z-index",++R.zIndex),s="touchstart"===t.type?t.targetTouches[0].pageX:t.clientX,a="touchstart"===t.type?t.targetTouches[0].pageY:t.clientY,r=parseFloat(i.css("left")),h=parseFloat(i.css("top")),i.css({left:r,top:h,right:"",bottom:""}),k.on(V+S,l).on(D+S,o)})}},{movable:function(s,a){function r(){k.off(V+S,m).off(D+S,r),R.isMoving=!1,E(Nt).removeClass("is-grabbing")}var h=this,l=0,c=0,u=0,d=0,f=0,p=0,g=0,m=function(t){(t=t||window.event).preventDefault();var e="touchmove"===t.type?t.targetTouches[0].pageX:t.clientX,t="touchmove"===t.type?t.targetTouches[0].pageY:t.clientY,e=e-l,t=t-c,i=e+u,o=t+d;0<p?g<t+d?o=g:t+d<-p+g&&(o=-p+g):o=d,0<f?-g<e+u?i=-g:e+u<-f-g&&(i=-f-g):i=u,a.css({left:i,top:o}),E.extend(h.imageData,{left:i,top:o})};s.on(Bt+S,function(t){(t=t||window.event).preventDefault();var e=a.width(),i=a.height(),o=s.width(),n=s.height();l="touchstart"===t.type?t.targetTouches[0].pageX:t.clientX,c="touchstart"===t.type?t.targetTouches[0].pageY:t.clientY,g=h.isRotated?(e-i)/2:0,f=h.isRotated?i-o:e-o,p=h.isRotated?e-n:i-n,R.isMoving=0<f||0<p,u=a.position().left-g,d=a.position().top+g,s.hasClass("is-grab")&&E(Nt).addClass("is-grabbing"),k.on(V+S,m).on(D+S,r)})}},{resizable:function(o,a,l,t){var r=this,e=E('<div class="'.concat(P,"-resizable-handle ").concat(P,'-resizable-handle-e"></div>')),i=E('<div class="'.concat(P,"-resizable-handle ").concat(P,'-resizable-handle-w"></div>')),n=E('<div class="'.concat(P,"-resizable-handle ").concat(P,'-resizable-handle-s"></div>')),s=E('<div class="'.concat(P,"-resizable-handle ").concat(P,'-resizable-handle-n"></div>')),h=E('<div class="'.concat(P,"-resizable-handle ").concat(P,'-resizable-handle-se"></div>')),c=E('<div class="'.concat(P,"-resizable-handle ").concat(P,'-resizable-handle-sw"></div>')),u=E('<div class="'.concat(P,"-resizable-handle ").concat(P,'-resizable-handle-ne"></div>')),d=E('<div class="'.concat(P,"-resizable-handle ").concat(P,'-resizable-handle-nw"></div>')),f={e:e,s:n,se:h,n:s,w:i,nw:d,ne:u,sw:c},p=(o.append(e,i,n,s,h,c,u,d),0),g=0,m={w:0,h:0,x:0,y:0},v={w:0,h:0,x:0,y:0},w={w:0,h:0,x:0,y:0},y=0,b=0,x=0,z="",M=t.modalWidth,$=t.modalHeight,T=function(t,e,i){var o=-e+m.w>M?e+m.x:m.x+m.w-M,n=-i+m.h>$?i+m.y:m.y+m.h-$;return{e:{width:Math.max(e+m.w,M)},s:{height:Math.max(i+m.h,$)},se:{width:Math.max(e+m.w,M),height:Math.max(i+m.h,$)},w:{width:Math.max(-e+m.w,M),left:o},n:{height:Math.max(-i+m.h,$),top:n},nw:{width:Math.max(-e+m.w,M),height:Math.max(-i+m.h,$),top:n,left:o},ne:{width:Math.max(e+m.w,M),height:Math.max(-i+m.h,$),top:n},sw:{width:Math.max(-e+m.w,M),height:Math.max(i+m.h,$),left:o}}[t]},C=function(t,e,i){var o=e+m.w>M?v.w-b+e-y:M-(m.w-v.w)-b-y,n=i+m.h>$?v.h-x+i+y:$-(m.h-v.h)-x+y,e=-e+m.w>M?v.w-b-e-y:M-(m.w-v.w)-b-y,i=-i+m.h>$?v.h-x-i+y:$-(m.h-v.h)-x+y,s=l.position().left,a=l.position().top,r=(0<o?s:Math.min(s,0))-y,h=(0<n?a:Math.min(a,0))+y,s=(0<e?s:Math.min(s,0))-y,a=(0<i?a:Math.min(a,0))+y;return{e:{left:-y<=o?(o-y)/2:Math.max(r,o)},s:{top:y<=n?(n+y)/2:Math.max(h,n)},se:{top:y<=n?(n+y)/2:Math.max(h,n),left:-y<=o?(o-y)/2:Math.max(r,o)},w:{left:-y<=e?(e-y)/2:Math.max(s,e)},n:{top:y<=i?(i+y)/2:Math.max(a,i)},nw:{top:y<=i?(i+y)/2:Math.max(a,i),left:-y<=e?(e-y)/2:Math.max(s,e)},ne:{top:y<=i?(i+y)/2:Math.max(a,i),left:-y<=o?(o-y)/2:Math.max(r,o)},sw:{top:y<=n?(n+y)/2:Math.max(h,n),left:-y<=e?(e-y)/2:Math.max(s,e)}}[t]},L=function(t){var e,i;(t=t||window.event).preventDefault(),r.isMaximized||(e="touchmove"===t.type?t.targetTouches[0].pageX:t.clientX,t="touchmove"===t.type?t.targetTouches[0].pageY:t.clientY,i=T(z,e=e-p,t=t-g),o.css(i),i=C(z,e,t),l.css(i))},_=function t(){k.off(V+S,L).off(D+S,t);var e=a.width(),i=a.height(),o=(R.isResizing&&Ot({w:b,h:x},{w:e,h:i},a),R.isResizing=!1,E(Yt).css("cursor",""),r.imageData),n=o.originalWidth,o=o.originalHeight,s=jt(n,o,e,i,r.isRotated),n=n*s,o=o*s;E.extend(r.imageData,{initWidth:n,initHeight:o,initLeft:(e-n)/2,initTop:(i-o)/2})};E.each(f,function(i,t){t.on(Bt+S,function(t){var e;e=i,(t=(t=t)||window.event).preventDefault(),R.isResizing=!0,p="touchstart"===t.type?t.targetTouches[0].pageX:t.clientX,g="touchstart"===t.type?t.targetTouches[0].pageY:t.clientY,m={w:o.width()+(H(o)?r._modalEdgeValue.horizontal:0),h:o.height()+(H(o)?r._modalEdgeValue.vertical:0),x:o.position().left,y:o.position().top},v={w:a.width(),h:a.height(),x:a.position().left,y:a.position().top},w={w:l.width(),h:l.height(),x:l.position().left,y:l.position().top},y=r.isRotated?(w.w-w.h)/2:0,b=r.isRotated?w.h:w.w,x=r.isRotated?w.w:w.h,z=e,E(Yt).css("cursor",e+"-resize"),k.on(V+S,L).on(D+S,_)})})}}),t});