!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.ImagesPreview=e():t.ImagesPreview=e()}(this,function(){return function(t){function e(i){if(n[i])return n[i].exports;var r=n[i]={exports:{},id:i,loaded:!1};return t[i].call(r.exports,r,r.exports,e),r.loaded=!0,r.exports}var n={};return e.m=t,e.c=n,e.p="",e(0)}([function(t,e,n){"use strict";function i(t){return t&&t.__esModule?t:{"default":t}}function r(t,e,n){return e in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function o(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function s(t,e){if(!t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!e||"object"!=typeof e&&"function"!=typeof e?t:e}function a(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function, not "+typeof e);t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}),e&&(Object.setPrototypeOf?Object.setPrototypeOf(t,e):t.__proto__=e)}function h(t){if(t.naturalWidth)return{height:t.naturalHeight,width:t.naturalWidth};var e=new Image;return e.src=t.currentSrc||t.src,{height:e.height,width:e.width}}function u(){return Math.max(H.documentElement.clientWidth,window.innerWidth||0)}function c(t){t.preventDefault()}Object.defineProperty(e,"__esModule",{value:!0});var l=function(){function t(t,e){for(var n=0;n<e.length;n++){var i=e[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(t,i.key,i)}}return function(e,n,i){return n&&t(e.prototype,n),i&&t(e,i),e}}(),d=n(1),f=i(d),p=n(4),v=i(p),m=n(5),y=i(m),g=n(6),b=i(g),x=n(7),w=i(x),k=n(12),_=i(k),T=n(13),E=i(T),M=n(14),O=i(M),C=n(27),S=i(C),P=n(28),j=i(P),I=n(17),A=i(I),N=n(15),q=i(N),L=n(29),B=i(L),D=n(19),H=document,Q=H.body,R=function(t){function e(t){var n=arguments.length<=1||void 0===arguments[1]?{}:arguments[1];o(this,e);var i=s(this,Object.getPrototypeOf(e).call(this));return i.opts=n,i.threshold=n.threshold||200,i.fastThreshold=n.fastThreshold||30,n.convert=n.convert||function r(){return r},i.imgs=Array.prototype.slice.call(t),i._ontap=(0,E["default"])(i.ontap.bind(i)),i._containerTap=(0,E["default"])(i.hide.bind(i)),i.status=[],i.loaded=[],i.tx=0,n.bind!==!1&&y["default"].bind(H,"touchstart",i._ontap),i}return a(e,t),l(e,[{key:"ontap",value:function(t){var e=t.target,n=this.imgs.indexOf(e);n!==-1&&(this.show(),this.active(e,n,!0))}},{key:"show",value:function(){var t=this.container=H.createElement("div");t.id="images-preview";var e=u();t.style.width=e*this.imgs.length+40+"px",this.setTransform(-20),Q.appendChild(t);var n=this.dots=(0,j["default"])('<div class="imgs-preview-dots"><ul></ul></div>');Q.appendChild(n);for(var i=(0,v["default"])("ul",n),r=H.createDocumentFragment(),o=0,s=this.imgs.length;o<s;o++){i.appendChild(H.createElement("li"));var a=H.createElement("div");a.style.width=e+"px";var h=H.createElement("div"),l=this.imgs[o].currentSrc||this.imgs[o].src;if(h.className="wrapper",this.loaded.indexOf(o)!==-1){var d=this.createImage(h,l);d.style.display="block",this.positionWrapper(h,d)}else{h.appendChild((0,j["default"])('\n        <div class="mask" style="background-image:url(\''+l+"')\">\n        </div>"));var f=this.imgs[o].getBoundingClientRect(),p=f.height||e,m=Math.min(t.clientHeight-10,p)/2;(0,S["default"])(h.style,{width:e-10+"px",height:p+"px",left:"5px",marginTop:"-"+m+"px"})}a.appendChild(h),r.appendChild(a)}t.appendChild(r),this.zooms=[],this.emit("hide"),this.events=(0,q["default"])(t,this),this.docEvents=(0,q["default"])(document,this),this.events.bind("touchstart"),this.events.bind("touchmove"),this.events.bind("touchend"),this.docEvents.bind("touchend","ontouchend"),y["default"].bind(t,"touchstart",this._containerTap),y["default"].bind(H,"touchmove",c)}},{key:"ontouchstart",value:function(t){var e=this;this.animating&&this.tween.stop();var n=(0,A["default"])(t.target,".wrapper");if(!(t.touches.length>1||n)){var i=t.touches[0],r=i.clientX;this.down={x:r,at:Date.now()};var o=this.tx,s=u();this.move=function(t,n){var i=o+n.clientX-r;i=e.limit(i,s),isNaN(i)||e.setTransform(i)}}}},{key:"ontouchmove",value:function(t){if(!(t.touches.length>1||null==this.move)){t.preventDefault(),t.stopPropagation();var e=t.touches[0];this.move(t,e)}}},{key:"ontouchend",value:function(t){if(null!=this.move){this.animating&&this.tween.stop();var e=this.down;this.move=this.down=null;var n=t.changedTouches[0],i=n.clientX,r=Date.now();if(Math.abs(i-e.x)>this.fastThreshold&&r-e.at<this.threshold){var o=e.x>i?"left":"right";this.onswipe(o)}else this.restore()}}},{key:"active",value:function(t,e){var n=this,i=!(arguments.length<=2||void 0===arguments[2])&&arguments[2];if(null==e&&(e=this.imgs.indexOf(t)),!(e<0||e>this.imgs.length-1)){var r=u(),o=this.status[e];this.idx=e;var s=this.container.querySelectorAll(".wrapper")[e];(0,f["default"])(this.dots.querySelectorAll("li")[e]),this.emit("active",e);var a=e*r;if(this.setTransform(-a-20),!o){if(this.status[e]="loading",i){var h=(0,v["default"])(".image",s);h&&(h.style.display="none");var c=(0,v["default"])(".mask",s);c&&(c.style.display="none");var l=this.holder=H.createElement("div");l.className="imgs-preview-holder";var d=t.currentSrc||t.src;l.style.backgroundImage="url('"+d+"')";var p=t.getBoundingClientRect();(0,S["default"])(l.style,{left:p.left+"px",top:p.top+"px",width:p.width+"px",height:p.height+"px"}),Q.appendChild(l)}var m=this.createImage(s,t.currentSrc||t.src);i||(m.style.display="block");var y=new O["default"](s,{threshold:this.threshold,fastThreshold:this.fastThreshold,padding:5,tapreset:!1,draggable:!0,maxScale:4});y.on("swipe",this.onswipe.bind(this)),y.on("move",function(t){var e=-20-a-t;e=n.limit(e,r),n.setTransform(e)}),y.on("end",this.restore.bind(this)),this.zooms.push(y),this.loadImage(m,s).then(function(){n.loaded.push(e)},function(){})}}}},{key:"onswipe",value:function(t){var e=this,n=u(),i="left"==t?this.idx+1:this.idx-1;i=Math.max(0,i),i=Math.min(this.imgs.length-1,i),this.animate(-i*n-20).then(function(){var t=e.imgs[i];i!=e.idx&&e.active(t,i)})}},{key:"limit",value:function(t,e){return t=Math.min(0,t),t=Math.max(-40-(this.imgs.length-1)*e,t)}},{key:"restore",value:function(){var t=this,e=u(),n=Math.round((-this.tx-20)/e);this.animate(-n*e-20).then(function(){if(n!=t.idx){var e=t.imgs[n];t.active(e,n)}})}},{key:"loadImage",value:function(t,e){var n=this;if(t.complete){var i=(0,v["default"])(".mask",e);return i&&e.removeChild(i),this.positionWrapper(e,t),this.positionHolder(e,t.currentSrc||t.src,!1).then(function(){t.style.display="block"})}return this.positionHolder(e).then(function(){t.style.display="block";var i=(0,v["default"])(".mask",e);i.style.display="block";var r=(0,j["default"])('<div class="spin"></div>');e.clientHeight>n.container.clientHeight&&(r.style.top=n.container.clientHeight/2+"px"),e.appendChild(r);var o=(0,B["default"])(r,{color:"#ffffff",duration:1e3,width:4}),s=n;return new Promise(function(n,a){function h(){o(),r.parentNode&&e.removeChild(r),i.parentNode&&e.removeChild(i),s.positionWrapper(e,t),n()}return t.complete?h():(t.onload=h,void(t.onerror=function(t){o(),a(t)}))})})}},{key:"positionWrapper",value:function(t,e){var n=Math.max(H.documentElement.clientWidth,window.innerWidth||0),i=h(e),r=(n-10)*i.height/i.width,o=Math.min(this.container.clientHeight-10,r)/2;(0,S["default"])(t.style,{left:"5px",width:n-10+"px",height:r+"px",marginTop:"-"+o+"px"})}},{key:"createImage",value:function(t,e){var n=(0,v["default"])(".image",t);return n?n:(n=H.createElement("img"),n.className="image",n.src=this.opts.convert(e),t.appendChild(n),n)}},{key:"setTransform",value:function(t){var e=this.container;this.tx=t,D.has3d?e.style[D.transform]="translate3d("+t+"px,0,0)":e.style[D.transform]="translate("+t+"px)"}},{key:"animate",value:function n(t){function n(){(0,b["default"])(n),r.update()}var e=arguments.length<=1||void 0===arguments[1]?200:arguments[1],i=arguments.length<=2||void 0===arguments[2]?"out-circ":arguments[2];if(t==this.tx)return Promise.resolve(null);this.animating=!0;var r=this.tween=(0,w["default"])({x:this.tx}).ease(i).to({x:t}).duration(e);r.update(function(t){o.setTransform(t.x)});var o=this,s=new Promise(function(t){r.on("end",function(){n=function(){},o.animating=!1,t()})});return n(),s}},{key:"positionHolder",value:function(t,e){function n(){(0,b["default"])(n),o.update()}var i=arguments.length<=2||void 0===arguments[2]||arguments[2],r=this.holder;if(!r)return Promise.resolve(null);e&&(r.style.backgroundImage="url('"+e+"')");var o=(0,w["default"])({width:parseInt(r.style.width,10),height:parseInt(r.style.height,10),left:parseInt(r.style.left,10),top:parseInt(r.style.top,10),opacity:.3}).ease("out-cube").to({width:parseInt(t.style.width,10),height:parseInt(t.style.height,10),left:parseInt(t.style.left,10),top:this.container.clientHeight/2+parseInt(t.style.marginTop,10),opacity:1}).duration(300);o.update(function(t){var e=i?t.opacity:1;(0,S["default"])(r.style,{width:t.width+"px",height:t.height+"px",left:t.left+"px",top:t.top+"px",opacity:e})});var s=this,a=new Promise(function(t){o.on("end",function(){r.parentNode&&r.parentNode.removeChild(r),s.holder=null,n=function(){},t()})});return n(),a}},{key:"hide",value:function(){this.dots&&Q.removeChild(this.dots),y["default"].unbind(this.container,"touchstart",this._containTap),y["default"].unbind(H,"touchmove",c),this.zooms.forEach(function(t){t.unbind()}),this.hideImage(),this.zooms=[],this.status=[],this.container.style.backgroundColor="rgba(0,0,0,0)",this.emit("hide"),Q.removeChild(this.container)}},{key:"unbind",value:function(){y["default"].unbind(H,"touchstart",this._ontap)}},{key:"hideImage",value:function(){function t(){y["default"].unbind(s,D.transitionend,t),Q.removeChild(s)}var e=this.idx,n=this.imgs[e],i=n.getBoundingClientRect(),o=this.container.querySelectorAll(".wrapper")[e];if(!(0==i.height||i.bottom<0||i.top>this.container.clientHeight)){var s=H.createElement("div"),a=n.currentSrc||n.src;s.className="imgs-preview-holder",s.style.backgroundImage="url('"+a+"')",(0,S["default"])(s.style,r({width:parseInt(o.style.width,10)+"px",height:parseInt(o.style.height,10)+"px",left:parseInt(o.style.left,10)+"px",top:this.container.clientHeight/2+parseInt(o.style.marginTop,10)+"px"},D.transition,"all 0.25s ease-in")),Q.appendChild(s),y["default"].bind(s,D.transitionend,t),setTimeout(function(){(0,S["default"])(s.style,{width:i.width+"px",height:i.height+"px",top:i.top+"px",left:i.left+"px"})},20)}}}]),e}(_["default"]);e["default"]=R},function(t,e,n){var i=n(2);t.exports=function(t,e){var n=t.parentNode.childNodes,r=t.tagName;e=e||"active";for(var o=0,s=n.length;o<s;o++){var a=n[o];a&&1===a.nodeType&&a.tagName===r&&(a===t?i(a).add(e):i(a).remove(e))}}},function(t,e,n){function i(t){if(!t||!t.nodeType)throw new Error("A DOM element reference is required");this.el=t,this.list=t.classList}try{var r=n(3)}catch(o){var r=n(3)}var s=/\s+/,a=Object.prototype.toString;t.exports=function(t){return new i(t)},i.prototype.add=function(t){if(this.list)return this.list.add(t),this;var e=this.array(),n=r(e,t);return~n||e.push(t),this.el.className=e.join(" "),this},i.prototype.remove=function(t){if("[object RegExp]"==a.call(t))return this.removeMatching(t);if(this.list)return this.list.remove(t),this;var e=this.array(),n=r(e,t);return~n&&e.splice(n,1),this.el.className=e.join(" "),this},i.prototype.removeMatching=function(t){for(var e=this.array(),n=0;n<e.length;n++)t.test(e[n])&&this.remove(e[n]);return this},i.prototype.toggle=function(t,e){return this.list?("undefined"!=typeof e?e!==this.list.toggle(t,e)&&this.list.toggle(t):this.list.toggle(t),this):("undefined"!=typeof e?e?this.add(t):this.remove(t):this.has(t)?this.remove(t):this.add(t),this)},i.prototype.array=function(){var t=this.el.getAttribute("class")||"",e=t.replace(/^\s+|\s+$/g,""),n=e.split(s);return""===n[0]&&n.shift(),n},i.prototype.has=i.prototype.contains=function(t){return this.list?this.list.contains(t):!!~r(this.array(),t)}},function(t,e){t.exports=function(t,e){if(t.indexOf)return t.indexOf(e);for(var n=0;n<t.length;++n)if(t[n]===e)return n;return-1}},function(t,e){function n(t,e){return e.querySelector(t)}e=t.exports=function(t,e){return e=e||document,n(t,e)},e.all=function(t,e){return e=e||document,e.querySelectorAll(t)},e.engine=function(t){if(!t.one)throw new Error(".one callback required");if(!t.all)throw new Error(".all callback required");return n=t.one,e.all=t.all,e}},function(t,e){var n=window.addEventListener?"addEventListener":"attachEvent",i=window.removeEventListener?"removeEventListener":"detachEvent",r="addEventListener"!==n?"on":"";e.bind=function(t,e,i,o){return t[n](r+e,i,o||!1),i},e.unbind=function(t,e,n,o){return t[i](r+e,n,o||!1),n}},function(t,e){function n(t){var e=(new Date).getTime(),n=Math.max(0,16-(e-i)),r=setTimeout(t,n);return i=e,r}e=t.exports=window.requestAnimationFrame||window.webkitRequestAnimationFrame||window.mozRequestAnimationFrame||n;var i=(new Date).getTime(),r=window.cancelAnimationFrame||window.webkitCancelAnimationFrame||window.mozCancelAnimationFrame||window.clearTimeout;e.cancel=function(t){r.call(window,t)}},function(t,e,n){function i(t){return this instanceof i?(this._from=t,this.ease("linear"),void this.duration(500)):new i(t)}var r=n(8),o=n(9),s=n(10),a=n(11);t.exports=i,r(i.prototype),i.prototype.reset=function(){return this.isArray="array"===s(this._from),this._curr=o(this._from),this._done=!1,this._start=Date.now(),this},i.prototype.to=function(t){return this.reset(),this._to=t,this},i.prototype.duration=function(t){return this._duration=t,this},i.prototype.ease=function(t){if(t="function"==typeof t?t:a[t],!t)throw new TypeError("invalid easing function");return this._ease=t,this},i.prototype.stop=function(){return this.stopped=!0,this._done=!0,this.emit("stop"),this.emit("end"),this},i.prototype.step=function(){if(!this._done){var t=this._duration,e=Date.now(),n=e-this._start,i=n>=t;if(i)return this._from=this._to,this._update(this._to),this._done=!0,this.emit("end"),this;var r=this._from,o=this._to,s=this._curr,a=this._ease,h=(e-this._start)/t,u=a(h);if(this.isArray){for(var c=0;c<r.length;++c)s[c]=r[c]+(o[c]-r[c])*u;return this._update(s),this}for(var l in r)s[l]=r[l]+(o[l]-r[l])*u;return this._update(s),this}},i.prototype.update=function(t){return 0==arguments.length?this.step():(this._update=t,this)}},function(t,e){function n(t){if(t)return i(t)}function i(t){for(var e in n.prototype)t[e]=n.prototype[e];return t}t.exports=n,n.prototype.on=n.prototype.addEventListener=function(t,e){return this._callbacks=this._callbacks||{},(this._callbacks["$"+t]=this._callbacks["$"+t]||[]).push(e),this},n.prototype.once=function(t,e){function n(){this.off(t,n),e.apply(this,arguments)}return n.fn=e,this.on(t,n),this},n.prototype.off=n.prototype.removeListener=n.prototype.removeAllListeners=n.prototype.removeEventListener=function(t,e){if(this._callbacks=this._callbacks||{},0==arguments.length)return this._callbacks={},this;var n=this._callbacks["$"+t];if(!n)return this;if(1==arguments.length)return delete this._callbacks["$"+t],this;for(var i,r=0;r<n.length;r++)if(i=n[r],i===e||i.fn===e){n.splice(r,1);break}return this},n.prototype.emit=function(t){this._callbacks=this._callbacks||{};var e=[].slice.call(arguments,1),n=this._callbacks["$"+t];if(n){n=n.slice(0);for(var i=0,r=n.length;i<r;++i)n[i].apply(this,e)}return this},n.prototype.listeners=function(t){return this._callbacks=this._callbacks||{},this._callbacks["$"+t]||[]},n.prototype.hasListeners=function(t){return!!this.listeners(t).length}},function(t,e,n){function i(t){switch(r(t)){case"object":var e={};for(var n in t)t.hasOwnProperty(n)&&(e[n]=i(t[n]));return e;case"array":for(var e=new Array(t.length),o=0,s=t.length;o<s;o++)e[o]=i(t[o]);return e;case"regexp":var a="";return a+=t.multiline?"m":"",a+=t.global?"g":"",a+=t.ignoreCase?"i":"",new RegExp(t.source,a);case"date":return new Date(t.getTime());default:return t}}var r;try{r=n(10)}catch(o){r=n(10)}t.exports=i},function(t,e){var n=Object.prototype.toString;t.exports=function(t){switch(n.call(t)){case"[object Date]":return"date";case"[object RegExp]":return"regexp";case"[object Arguments]":return"arguments";case"[object Array]":return"array";case"[object Error]":return"error"}return null===t?"null":void 0===t?"undefined":t!==t?"nan":t&&1===t.nodeType?"element":(t=t.valueOf?t.valueOf():Object.prototype.valueOf.apply(t),typeof t)}},function(t,e){e.linear=function(t){return t},e.inQuad=function(t){return t*t},e.outQuad=function(t){return t*(2-t)},e.inOutQuad=function(t){return t*=2,t<1?.5*t*t:-.5*(--t*(t-2)-1)},e.inCube=function(t){return t*t*t},e.outCube=function(t){return--t*t*t+1},e.inOutCube=function(t){return t*=2,t<1?.5*t*t*t:.5*((t-=2)*t*t+2)},e.inQuart=function(t){return t*t*t*t},e.outQuart=function(t){return 1- --t*t*t*t},e.inOutQuart=function(t){return t*=2,t<1?.5*t*t*t*t:-.5*((t-=2)*t*t*t-2)},e.inQuint=function(t){return t*t*t*t*t},e.outQuint=function(t){return--t*t*t*t*t+1},e.inOutQuint=function(t){return t*=2,t<1?.5*t*t*t*t*t:.5*((t-=2)*t*t*t*t+2)},e.inSine=function(t){return 1-Math.cos(t*Math.PI/2)},e.outSine=function(t){return Math.sin(t*Math.PI/2)},e.inOutSine=function(t){return.5*(1-Math.cos(Math.PI*t))},e.inExpo=function(t){return 0==t?0:Math.pow(1024,t-1)},e.outExpo=function(t){return 1==t?t:1-Math.pow(2,-10*t)},e.inOutExpo=function(t){return 0==t?0:1==t?1:(t*=2)<1?.5*Math.pow(1024,t-1):.5*(-Math.pow(2,-10*(t-1))+2)},e.inCirc=function(t){return 1-Math.sqrt(1-t*t)},e.outCirc=function(t){return Math.sqrt(1- --t*t)},e.inOutCirc=function(t){return t*=2,t<1?-.5*(Math.sqrt(1-t*t)-1):.5*(Math.sqrt(1-(t-=2)*t)+1)},e.inBack=function(t){var e=1.70158;return t*t*((e+1)*t-e)},e.outBack=function(t){var e=1.70158;return--t*t*((e+1)*t+e)+1},e.inOutBack=function(t){var e=2.5949095;return(t*=2)<1?.5*(t*t*((e+1)*t-e)):.5*((t-=2)*t*((e+1)*t+e)+2)},e.inBounce=function(t){return 1-e.outBounce(1-t)},e.outBounce=function(t){return t<1/2.75?7.5625*t*t:t<2/2.75?7.5625*(t-=1.5/2.75)*t+.75:t<2.5/2.75?7.5625*(t-=2.25/2.75)*t+.9375:7.5625*(t-=2.625/2.75)*t+.984375},e.inOutBounce=function(t){return t<.5?.5*e.inBounce(2*t):.5*e.outBounce(2*t-1)+.5},e["in-quad"]=e.inQuad,e["out-quad"]=e.outQuad,e["in-out-quad"]=e.inOutQuad,e["in-cube"]=e.inCube,e["out-cube"]=e.outCube,e["in-out-cube"]=e.inOutCube,e["in-quart"]=e.inQuart,e["out-quart"]=e.outQuart,e["in-out-quart"]=e.inOutQuart,e["in-quint"]=e.inQuint,e["out-quint"]=e.outQuint,e["in-out-quint"]=e.inOutQuint,e["in-sine"]=e.inSine,e["out-sine"]=e.outSine,e["in-out-sine"]=e.inOutSine,e["in-expo"]=e.inExpo,e["out-expo"]=e.outExpo,e["in-out-expo"]=e.inOutExpo,e["in-circ"]=e.inCirc,e["out-circ"]=e.outCirc,e["in-out-circ"]=e.inOutCirc,e["in-back"]=e.inBack,e["out-back"]=e.outBack,e["in-out-back"]=e.inOutBack,e["in-bounce"]=e.inBounce,e["out-bounce"]=e.outBounce,e["in-out-bounce"]=e.inOutBounce},function(t,e,n){function i(t){if(t)return r(t)}function r(t){for(var e in i.prototype)t[e]=i.prototype[e];return t}t.exports=i,i.prototype.on=i.prototype.addEventListener=function(t,e){return this._callbacks=this._callbacks||{},(this._callbacks["$"+t]=this._callbacks["$"+t]||[]).push(e),this},i.prototype.once=function(t,e){function n(){this.off(t,n),e.apply(this,arguments)}return n.fn=e,this.on(t,n),this},i.prototype.off=i.prototype.removeListener=i.prototype.removeAllListeners=i.prototype.removeEventListener=function(t,e){if(this._callbacks=this._callbacks||{},0==arguments.length)return this._callbacks={},this;var n=this._callbacks["$"+t];if(!n)return this;if(1==arguments.length)return delete this._callbacks["$"+t],this;for(var i,r=0;r<n.length;r++)if(i=n[r],i===e||i.fn===e){n.splice(r,1);break}return this},i.prototype.emit=function(t){this._callbacks=this._callbacks||{};var e=[].slice.call(arguments,1),n=this._callbacks["$"+t];if(n){n=n.slice(0);for(var i=0,r=n.length;i<r;++i)n[i].apply(this,e)}return this},i.prototype.listeners=function(t){return this._callbacks=this._callbacks||{},this._callbacks["$"+t]||[]},i.prototype.hasListeners=function(t){return!!this.listeners(t).length}},function(t,e){function n(t,e){function r(e){function n(n){if(e!==n&&(r(),!n.defaultPrevented)){var i=e.preventDefault,o=e.stopPropagation;e.stopPropagation=function(){o.call(e),o.call(n)},e.preventDefault=function(){i.call(e),i.call(n)},t.apply(a,h)}}function r(t){e!==t&&(clearTimeout(u),s.removeEventListener("touchmove",r),i.forEach(function(t){s.removeEventListener(t,n)}))}if(e.touches&&!(e.touches.length>1)){var s=e.target,a=this,h=arguments,u=setTimeout(r,o);s.addEventListener("touchmove",r),i.forEach(function(t){s.addEventListener(t,n)})}}e=e||{};var o=e.timeout||n.timeout;return r.handler=t,r}var i=["touchend"];t.exports=n,n.timeout=200},function(t,e,n){function i(t,e){if(!(this instanceof i))return new i(t,e);e=e||{},this.el=t,this.padding=e.padding||0,this.container=t.parentNode,this.container.style.overflow="hidden",this.scale=1,this.maxScale=e.maxScale||5,this.threshold=e.threshold||200,this.fastThreshold=e.fastThreshold||30;var n=t.getBoundingClientRect();this.tapreset=e.tapreset||!1,this.sx=n.left+n.width/2,this.sy=n.top+n.height/2,this.tx=this.ty=0,this.animating=!1,this.pinch=new f(t,this.onPinchMove.bind(this)),this.pinch.on("start",this.onPinchStart.bind(this)),this.pinch.on("end",this.onPinchEnd.bind(this)),p?this.el.style[v+"Origin"]="center center 0px":this.el.style[v+"Origin"]="center center";var r=this._ontap=h(this.ontap.bind(this));s.bind(t,"touchstart",r),this.events=o(t,this),this.docEvents=o(document,this),e.draggable&&(this.events.bind("touchstart"),this.events.bind("touchmove"),this.events.bind("touchend"),this.docEvents.bind("touchend","ontouchend"))}function r(t){var e=1.20158;return--t*t*((e+1)*t+e)+1}var o=n(15),s=n(5),a=n(12),h=n(13),u=n(6),c=n(7),l=n(19),d=n(24),f=n(25),p=l.has3d,v=l.transform,m=Math.PI;a(i.prototype),i.prototype.ontouchstart=function(t){var e=t.touches;if(this.animating&&(t.stopPropagation(),this.tween.stop()),e&&1==e.length){var n=this.el.getBoundingClientRect();this.translateY=n.top<0||n.bottom>this.container.clientHeight,this.speed=0;var i=Date.now(),r=t.touches[0],o=r.clientX,s=r.clientY,a=this,h={x:this.tx,y:this.ty},u=this.getLimitation(100);this.move=function(t,e){a.down={x:o,y:s,at:i};var n=e.clientX,r=e.clientY,c=this.prev?this.prev.x:o,l=this.prev?this.prev.y:s;t.preventDefault();var f=Math.abs(n-c)>Math.abs(r-l);1==a.scale||f||t.stopPropagation(),a.calcuteSpeed(n,r);var p=h.x+n-o,v=h.y+r-s,y=d.limit(p,v,u),g=y.x-p;1==a.scale&&f&&(y.y=this.ty,this.angle=n-c>0?0:m),f&&this.emit("move",g),this.translateY||(y.y=h.y),a.setTransform(y.x,y.y,a.scale)}}},i.prototype.ontouchmove=function(t){if(this.move&&!this.animating&&!this.pinch.pinching){var e=t.touches;if(!e||1!=e.length)return void(this.move=null);var n=e[0];this.move(t,n)}},i.prototype.ontouchend=function(t){if(null!=this.move){if(null==this.down)return this.move=null;if(!this.pinch.pinching&&!this.animating){var e=Date.now(),n=t.changedTouches[0],i=n.clientX,r=n.clientY,o=this.down.x,s=this.down.y;this.calcuteSpeed(i,r);var a=Math.abs(i-o),h=this.getLimitation();if(a>this.fastThreshold&&a>Math.abs(r-s)&&e-this.down.at<this.threshold&&(this.tx<=h.minx||this.tx>=h.maxx)){var u=i>o?"right":"left";return this.down=this.move=null,this.emit("swipe",u)}this.down=this.move=null,this.emit("end"),this.speed&&this.momentum()}}},i.prototype.momentum=function(){var t=.001,e=this.getLimitation(this.padding),n=Math.min(this.speed,4),i=(4-m)/2,o=i*(n*n)/(2*t),s=this.tx+o*Math.cos(this.angle),a=this.ty+o*Math.sin(this.angle),h=d.limit(s,a,e),u=this.scale>1&&(s<e.minx||s>e.maxx)||a<e.miny||a>e.maxy,c=u?r:"out-circ",l=d.distance([s,a,h.x,h.y]),f=(1-l/o)*n/t;return(this.ty<e.miny||this.ty>e.maxy)&&(f=500,c="out-circ"),this.translateY||(h.y=this.ty),this.animate({x:h.x,y:h.y,scale:this.scale},f,c)},i.prototype.getLimitation=function(t){t=t||0;var e=d.viewport,n=e.width,i=e.height,r=this.el.getBoundingClientRect(),o=this.el.parentNode.getBoundingClientRect();return{maxx:this.tx-r.left+o.left+this.padding,minx:this.tx-(r.left-o.left+r.width-n)-this.padding,miny:i>r.height?this.ty-r.top:this.ty-r.top-(r.height-i)-t,maxy:i>r.height?this.ty+(i-r.top-r.height):this.ty-r.top+t}},i.prototype.ontap=function(){if(this.animating)return this.tween.stop();var t=Date.now();return this.lastTap&&t-this.lastTap<300?void this.emit("tap"):1==this.scale?void this.emit("tap"):(this.lastTap=Date.now(),void(this.tapreset?this.reset():this.emit("tap")))},i.prototype.reset=function(){this.emit("scale",{x:0,y:0,scale:1});var t=this.animate({x:0,y:0,scale:1},200);return t},i.prototype.onPinchStart=function(t){this.animating&&this.tween.stop(),this.start=t,this.bx=this.sx+this.tx,this.by=this.sy+this.ty,this.startScale=this.scale,this.emit("start")},i.prototype.onPinchMove=function(t){if(!this.animating){this.point={x:t.x,y:t.y};var e=t.x-this.start.x,n=t.y-this.start.y,i=this.bx+e,r=this.by+n,o=d.getAngle(i,r,t.x,t.y),s=d.distance([t.y,t.x,r,i])*(t.scale-1),a=this.bx-this.sx+e-s*Math.cos(o),h=this.by-this.sy+n-s*Math.sin(o);this.setTransform(a,h,t.scale*this.startScale)}},i.prototype.onPinchEnd=function(){this.scale!==this.startScale&&this.emit("scale",{x:this.tx,y:this.ty,scale:this.scale}),this.startScale=this.scale;var t=this.checkScale();t||this.checkPosition()},i.prototype.setTransform=function(t,e,n){isNaN(t)||isNaN(e)||(this.tx=t,this.ty=e,this.scale=n,p?this.el.style[v]="translate3d("+t+"px, "+e+"px, 0)  scale3d("+n+","+n+", 1)":this.el.style[v]="translate("+t+"px, "+e+"px)  scale("+n+","+n+")")},i.prototype.animate=function(t,e,n){function i(){u(i),s.update()}var r={x:this.tx,y:this.ty,scale:this.scale};n=n||"out-circ";var o=this;this.animating=!0;var s=this.tween=c(r).ease(n).to(t).duration(e);s.update(function(t){o.setTransform(t.x,t.y,t.scale)});var a=new Promise(function(t){s.on("end",function(){i=function(){},o.animating=!1,t()})});return i(),a},i.prototype.unbind=function(){this.setTransform(0,0,1),this.pinch.unbind(),this.events.unbind(),this.docEvents.unbind(),s.unbind(this.el,"touchstart",this._ontap)},i.prototype.checkPosition=function(){var t=this.el.getBoundingClientRect(),e={x:this.tx,y:this.ty,scale:this.scale},n=d.viewport,i=n.width,r=n.height,o=this.padding;t.left>o?e.x=this.tx-t.left+o:t.left+t.width<i-o&&(e.x=this.tx+(i-t.left-t.width-o));var s=t.top+t.height;return t.top>0&&s>r-o?e.y=this.ty-(s-r+o):t.top<o&&s<r-o&&(e.y=this.ty-t.top+o),e.x!==this.tx||e.y!==this.ty?this.animate(e,200):Promise.resolve()},i.prototype.checkScale=function(){if(this.scale<1)return this.reset();if(this.scale>this.maxScale){var t=this.point;return this.scaleAt(t.x,t.y,this.maxScale)}},i.prototype.limitScale=function(t){var e=this.sx+this.tx,n=this.sy+this.ty,i=this.point,r=Math.atan((i.y-n)/(i.x-e));(i.y<n&&i.x<e||i.y>n&&i.x<e)&&(r+=m);var o=d.distance([i.y,i.x,n,e])*(this.scale-t),s=this.tx+o*Math.cos(r),a=this.ty+o*Math.sin(r);return this.animate({x:s,y:a,scale:t},200)},i.prototype.scaleAt=function(t,e,n){var i=this.sx+this.tx,r=this.sy+this.ty,o=d.getAngle(i,r,t,e),s=d.distance([e,t,r,i])*(1-n/this.scale),a=this.tx+s*Math.cos(o),h=this.ty+s*Math.sin(o);return this.animate({x:a,y:h,scale:n},300)},i.prototype.calcuteSpeed=function(t,e){var n=this.prev||this.down,i=Date.now(),r=i-n.at;if(i-this.down.at<50||r>50){var o=d.distance([n.x,n.y,t,e]);this.speed=Math.abs(o/r),this.angle=d.getAngle(n.x,n.y,t,e)}r>50&&(this.prev={x:t,y:e,at:i})},t.exports=i},function(t,e,n){function i(t,e){if(!(this instanceof i))return new i(t,e);if(!t)throw new Error("element required");if(!e)throw new Error("object required");this.el=t,this.obj=e,this._events={}}function r(t){var e=t.split(/ +/);return{name:e.shift(),selector:e.join(" ")}}try{var o=n(5)}catch(s){var o=n(5)}try{var a=n(16)}catch(s){var a=n(16)}t.exports=i,i.prototype.sub=function(t,e,n){this._events[t]=this._events[t]||{},this._events[t][e]=n},i.prototype.bind=function(t,e){function n(){var t=[].slice.call(arguments).concat(c);h[e].apply(h,t)}var i=r(t),s=this.el,h=this.obj,u=i.name,e=e||"on"+u,c=[].slice.call(arguments,2);return i.selector?n=a.bind(s,i.selector,u,n):o.bind(s,u,n),this.sub(u,e,n),n},i.prototype.unbind=function(t,e){if(0==arguments.length)return this.unbindAll();if(1==arguments.length)return this.unbindAllOf(t);var n=this._events[t];if(n){var i=n[e];i&&o.unbind(this.el,t,i)}},i.prototype.unbindAll=function(){for(var t in this._events)this.unbindAllOf(t)},i.prototype.unbindAllOf=function(t){var e=this._events[t];if(e)for(var n in e)this.unbind(t,n)}},function(t,e,n){try{var i=n(17)}catch(r){var i=n(17)}try{var o=n(5)}catch(r){var o=n(5)}e.bind=function(t,e,n,r,s){return o.bind(t,n,function(n){var o=n.target||n.srcElement;n.delegateTarget=i(o,e,!0,t),n.delegateTarget&&r.call(t,n)},s)},e.unbind=function(t,e,n,i){o.unbind(t,e,n,i)}},function(t,e,n){function i(t,e,n){for(n=n||document.documentElement;t&&t!==n;){if(r(t,e))return t;t=t.parentNode}return r(t,e)?t:null}try{var r=n(18)}catch(o){var r=n(18)}t.exports=i},function(t,e,n){function i(t,e){if(!t||1!==t.nodeType)return!1;if(a)return a.call(t,e);for(var n=r.all(e,t.parentNode),i=0;i<n.length;++i)if(n[i]==t)return!0;return!1}try{var r=n(4)}catch(o){var r=n(4)}var s=Element.prototype,a=s.matches||s.webkitMatchesSelector||s.mozMatchesSelector||s.msMatchesSelector||s.oMatchesSelector;t.exports=i},function(t,e,n){var i=null;!function(){for(var t=["webkitTransform","MozTransform","msTransform","OTransform","transform"],e=document.createElement("p"),n=0;n<t.length;n++)if(null!=e.style[t[n]]){i=t[n];break}}();var r=null;!function(){var t={WebkitTransition:"webkitTransitionEnd",MozTransition:"transitionend",OTransition:"oTransitionEnd",msTransition:"MSTransitionEnd",transition:"transitionend"},e=document.createElement("p");for(var n in t)if(null!=e.style[n]){r=t[n];break}}(),e.transitionend=r,e.transition=n(20),e.transform=i,e.touchAction=n(21),e.has3d=n(22)},function(t,e){for(var n,i=["webkitTransition","MozTransition","OTransition","msTransition","transition"],r=document.createElement("p"),o=0;o<i.length;o++)if(null!=r.style[i[o]]){n=i[o];break}r=null,t.exports=n},function(t,e){function n(t){t||(t=document);var e=t.createElement("div"),n=null;return"touchAction"in e.style?n="touchAction":"msTouchAction"in e.style&&(n="msTouchAction"),e=null,n}t.exports=n()},function(t,e,n){var i=n(23);if(i&&window.getComputedStyle){var r={webkitTransform:"-webkit-transform",OTransform:"-o-transform",msTransform:"-ms-transform",MozTransform:"-moz-transform",transform:"transform"},o=document.createElement("div");o.style[i]="translate3d(1px,1px,1px)",document.body.insertBefore(o,null);var s=getComputedStyle(o).getPropertyValue(r[i]);document.body.removeChild(o),t.exports=null!=s&&s.length&&"none"!=s}else t.exports=!1},function(t,e){for(var n,i=["webkitTransform","MozTransform","msTransform","OTransform","transform"],r=document.createElement("p"),o=0;o<i.length;o++)if(n=i[o],null!=r.style[n]){t.exports=n;break}},function(t,e){e.distance=function(t){var e=Math.pow(t[0]-t[2],2),n=Math.pow(t[1]-t[3],2);return Math.sqrt(e+n)},e.midpoint=function(t){var e={};return e.x=(t[0]+t[2])/2,e.y=(t[1]+t[3])/2,e},Object.defineProperty(e,"viewport",{get:function(){return{height:Math.max(document.documentElement.clientHeight,window.innerHeight||0),width:Math.max(document.documentElement.clientWidth,window.innerWidth||0)}}}),e.getAngle=function(t,e,n,i){if(t==n&&e==i)return 0;var r=Math.atan((i-e)/(n-t));return n<t?r+Math.PI:r},e.limit=function(t,e,n){return t<n.minx?t=n.minx:t>n.maxx&&(t=n.maxx),e<n.miny?e=n.miny:e>n.maxy&&(e=n.maxy),{x:t,y:e}}},function(t,e,n){function i(t,e){return this instanceof i?(this.el=t,this.parent=t.parentNode,this.fn=e||function(){},this.midpoint=null,this.scale=1,this.lastScale=1,this.pinching=!1,this.events=r(t,this),this.events.bind("touchstart"),
this.events.bind("touchmove"),this.events.bind("touchend"),void(this.fingers={})):new i(t,e)}var r=n(15),o=n(12),s=n(26),a=n(24);t.exports=i,o(i.prototype),i.prototype.ontouchstart=function(t){var e=t.touches;if(!e||2!=e.length)return this;t.preventDefault(),t.stopPropagation();for(var n,i=[],r=0;r<e.length;r++)n=e[r],i.push(n.clientX,n.clientY);return this.pinching=!0,this.distance=a.distance(i),this.midpoint=a.midpoint(i),this.emit("start",this.midpoint),this},i.prototype.ontouchmove=function(t){var e=t.touches;if(!e||2!=e.length||!this.pinching)return this;t.preventDefault(),t.stopPropagation();for(var n,i=[],r=0;r<e.length;r++)n=e[r],i.push(n.clientX,n.clientY);var o=a.distance(i),h=a.midpoint(i);return t=s(t),t.scale=o/this.distance*this.scale,t.x=h.x,t.y=h.y,this.fn(t),this.lastScale=t.scale,this},i.prototype.ontouchend=function(t){var e=t.touches;return e&&2!=e.length&&this.pinching?(this.scale=this.lastScale,this.pinching=!1,this.emit("end"),this):this},i.prototype.unbind=function(){return this.events.unbind(),this}},function(t,e){function n(){}t.exports=function(t){return n.prototype=t,new n}},function(t,e){"use strict";function n(t){if(null===t||void 0===t)throw new TypeError("Object.assign cannot be called with null or undefined");return Object(t)}function i(){try{if(!Object.assign)return!1;var t=new String("abc");if(t[5]="de","5"===Object.getOwnPropertyNames(t)[0])return!1;for(var e={},n=0;n<10;n++)e["_"+String.fromCharCode(n)]=n;var i=Object.getOwnPropertyNames(e).map(function(t){return e[t]});if("0123456789"!==i.join(""))return!1;var r={};return"abcdefghijklmnopqrst".split("").forEach(function(t){r[t]=t}),"abcdefghijklmnopqrst"===Object.keys(Object.assign({},r)).join("")}catch(o){return!1}}var r=Object.prototype.hasOwnProperty,o=Object.prototype.propertyIsEnumerable;t.exports=i()?Object.assign:function(t,e){for(var i,s,a=n(t),h=1;h<arguments.length;h++){i=Object(arguments[h]);for(var u in i)r.call(i,u)&&(a[u]=i[u]);if(Object.getOwnPropertySymbols){s=Object.getOwnPropertySymbols(i);for(var c=0;c<s.length;c++)o.call(i,s[c])&&(a[s[c]]=i[s[c]])}}return a}},function(t,e){function n(t,e){if("string"!=typeof t)throw new TypeError("String expected");e||(e=document);var n=/<([\w:]+)/.exec(t);if(!n)return e.createTextNode(t);t=t.replace(/^\s+|\s+$/g,"");var i=n[1];if("body"==i){var r=e.createElement("html");return r.innerHTML=t,r.removeChild(r.lastChild)}var s=o[i]||o._default,a=s[0],h=s[1],u=s[2],r=e.createElement("div");for(r.innerHTML=h+t+u;a--;)r=r.lastChild;if(r.firstChild==r.lastChild)return r.removeChild(r.firstChild);for(var c=e.createDocumentFragment();r.firstChild;)c.appendChild(r.removeChild(r.firstChild));return c}t.exports=n;var i,r=!1;"undefined"!=typeof document&&(i=document.createElement("div"),i.innerHTML='  <link/><table></table><a href="/a">a</a><input type="checkbox"/>',r=!i.getElementsByTagName("link").length,i=void 0);var o={legend:[1,"<fieldset>","</fieldset>"],tr:[2,"<table><tbody>","</tbody></table>"],col:[2,"<table><tbody></tbody><colgroup>","</colgroup></table>"],_default:r?[1,"X<div>","</div>"]:[0,"",""]};o.td=o.th=[3,"<table><tbody><tr>","</tr></tbody></table>"],o.option=o.optgroup=[1,'<select multiple="multiple">',"</select>"],o.thead=o.tbody=o.colgroup=o.caption=o.tfoot=[1,"<table>","</table>"],o.polyline=o.ellipse=o.polygon=o.circle=o.text=o.line=o.path=o.rect=o.g=[1,'<svg xmlns="http://www.w3.org/2000/svg" version="1.1">',"</svg>"]},function(t,e,n){"use strict";function i(t){return t&&t.__esModule?t:{"default":t}}function r(t){var e=document.createElement("canvas");t.appendChild(e);var n=t.getBoundingClientRect(),i=e.getContext("2d");return e.height=n.height,e.width=n.width,(0,a["default"])(e),i}function o(t){4==t.length&&(t=t.replace(/[^#]/g,function(t){return t+t}));var e=c.exec(t);return e?{r:parseInt(e[1],16),g:parseInt(e[2],16),b:parseInt(e[3],16)}:null}Object.defineProperty(e,"__esModule",{value:!0}),e["default"]=function(t,e){function n(r){if(i.clearRect(0,0,a,s),!v){m||(m=r),t.parentNode||(v=!0);var o=(r-m)%h;i.beginPath(),i.strokeStyle="rgba("+l.r+", "+l.g+", "+l.b+", 0.4)",i.arc(d,f,p,0,2*Math.PI),i.lineWidth=e.width||4,i.lineCap="round",i.stroke();var c=-Math.PI/2+2*Math.PI*o/h,y=c+Math.PI/2;i.beginPath(),i.strokeStyle="rgba("+l.r+", "+l.g+", "+l.b+", 1)",i.arc(d,f,p,c,y),i.stroke(),(0,u["default"])(n)}}e=e||[];var i=r(t),s=t.clientHeight||32,a=t.clientWidth||32,h=e.duration||1e3,c=e.color||"#ffffff",l=o(c),d=s/2,f=a/2,p=Math.min(s,a)/2-4,v=void 0,m=void 0;return(0,u["default"])(n),function(){v=!0}};var s=n(30),a=i(s),h=n(6),u=i(h),c=/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i},function(t,e){t.exports=function(t){var e=t.getContext("2d"),n=window.devicePixelRatio||1;return 1!=n&&(t.style.width=t.width+"px",t.style.height=t.height+"px",t.width*=n,t.height*=n,e.scale(n,n)),t}}])});