!function(t){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=t();else if("function"==typeof define&&define.amd)define([],t);else{("undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this).SmartPhoto=t()}}(function(){return function(){return function t(e,a,o){function i(r,s){if(!a[r]){if(!e[r]){var d="function"==typeof require&&require;if(!s&&d)return d(r,!0);if(n)return n(r,!0);var c=new Error("Cannot find module '"+r+"'");throw c.code="MODULE_NOT_FOUND",c}var l=a[r]={exports:{}};e[r][0].call(l.exports,function(t){return i(e[r][1][t]||t)},l,l.exports,t,e,a,o)}return a[r].exports}for(var n="function"==typeof require&&require,r=0;r<o.length;r++)i(o[r]);return i}}()({1:[function(t,e,a){"use strict";Object.defineProperty(a,"__esModule",{value:!0});var o=function(){function t(t,e){for(var a=0;a<e.length;a++){var o=e[a];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(t,o.key,o)}}return function(e,a,o){return a&&t(e.prototype,a),o&&t(e,o),e}}();t("ie-array-find-polyfill");var i,n=t("morphdom"),r=(i=n)&&i.__esModule?i:{default:i},s=t("./util");function d(t){if(Array.isArray(t)){for(var e=0,a=Array(t.length);e<t.length;e++)a[e]=t[e];return a}return Array.from(t)}var c="input paste copy click change keydown keyup keypress contextmenu mouseup mousedown mousemove touchstart touchend touchmove compositionstart compositionend focus",l=c.replace(/([a-z]+)/g,"[data-action-$1],")+"[data-action]",h=function(){function t(e){var a=this;!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.atemplate=[],e&&Object.keys(e).forEach(function(t){a[t]=e[t]}),this.data||(this.data={}),this.templates||(this.templates=[]);for(var o=0,i=this.templates.length;o<i;o+=1){var n=this.templates[o],r=(0,s.selector)("#"+n).innerHTML;this.atemplate.push({id:n,html:r,binded:!1})}}return o(t,[{key:"addDataBind",value:function(t){var e=this;(0,s.on)(t,"[data-bind]","input change click",function(t){var a,o,i=t.delegateTarget,n=i.getAttribute("data-bind"),r=i.getAttribute("href"),s=i.value;r&&(s=s.replace("#","")),"checkbox"===i.getAttribute("type")?(a=[],o=document.querySelectorAll('[data-bind="'+n+'"]'),[].forEach.call(o,function(t){t.checked&&a.push(t.value)})):"radio"!==i.getAttribute("type")&&e.updateDataByString(n,s)})}},{key:"addActionBind",value:function(t){var e=this;(0,s.on)(t,l,c,function(t){var a=t.delegateTarget,o="action";c.split(" ").forEach(function(e){a.getAttribute("data-action-"+e)&&t.type===e&&(o+="-"+e)});var i=a.getAttribute("data-"+o);if(i){var n,r=i.replace(/\(.*?\);?/,""),s=i.replace(/(.*?)\((.*?)\);?/,"$2").split(",");if(e.e=t,e.method&&e.method[r])(n=e.method)[r].apply(n,d(s));else e[r]&&e[r].apply(e,d(s))}})}},{key:"addTemplate",value:function(t,e){this.atemplate.push({id:t,html:e,binded:!1}),this.templates.push(t)}},{key:"getData",value:function(){return JSON.parse(JSON.stringify(this.data))}},{key:"saveData",value:function(t){var e=JSON.stringify(this.data);localStorage.setItem(t,e)}},{key:"setData",value:function(t){var e=this;Object.keys(t).forEach(function(a){"function"!=typeof t[a]&&(e.data[a]=t[a])})}},{key:"loadData",value:function(t){var e=JSON.parse(localStorage.getItem(t));e&&this.setData(e)}},{key:"getRand",value:function(t,e){return~~(Math.random()*(e-t+1))+t}},{key:"getRandText",value:function(t){for(var e="",a="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",o=a.length,i=0;i<t;i+=1)e+=a.charAt(Math.floor(this.getRand(0,o)));return e}},{key:"getDataFromObj",value:function(t,e){for(var a=(t=(t=t.replace(/\[([\w\-\.ã-ã‚“ã‚¡-ヶ亜-熙]+)\]/g,".$1")).replace(/^\./,"")).split(".");a.length;){var o=a.shift();if(!(o in e))return null;e=e[o]}return e}},{key:"getDataByString",value:function(t){var e=this.data;return this.getDataFromObj(t,e)}},{key:"updateDataByString",value:function(t,e){for(var a=this.data,o=t.split(".");o.length>1;)a=a[o.shift()];a[o.shift()]=e}},{key:"removeDataByString",value:function(t){for(var e=this.data,a=t.split(".");a.length>1;)e=e[a.shift()];var o=a.shift();o.match(/^\d+$/)?e.splice(Number(o),1):delete e[o]}},{key:"resolveBlock",value:function(t,e,a){var o=this,i=t.match(/<!-- BEGIN ([\w\-\.ã-ã‚“ã‚¡-ヶ亜-熙]+):touch#([\w\-\.ã-ã‚“ã‚¡-ヶ亜-熙]+) -->/g),n=t.match(/<!-- BEGIN ([\w\-\.ã-ã‚“ã‚¡-ヶ亜-熙]+):touchnot#([\w\-\.ã-ã‚“ã‚¡-ヶ亜-熙]+) -->/g),r=t.match(/<!-- BEGIN ([\w\-\.ã-ã‚“ã‚¡-ヶ亜-熙]+):exist -->/g),s=t.match(/<!-- BEGIN ([\w\-\.ã-ã‚“ã‚¡-ヶ亜-熙]+):empty -->/g);if(i)for(var d=0,c=i.length;d<c;d+=1){var l=i[d],h=(l=l.replace(/([\w\-\.ã-ã‚“ã‚¡-ヶ亜-熙]+):touch#([\w\-\.ã-ã‚“ã‚¡-ヶ亜-熙]+)/,"($1):touch#($2)")).replace(/BEGIN/,"END"),u=new RegExp(l+"(([\\n\\r\\t]|.)*?)"+h,"g");t=t.replace(u,function(t,a,i,n){return""+("function"==typeof e[a]?e[a].apply(o):o.getDataFromObj(a,e))===i?n:""})}if(n)for(var f=0,p=n.length;f<p;f+=1){var m=n[f],v=(m=m.replace(/([\w\-\.ã-ã‚“ã‚¡-ヶ亜-熙]+):touchnot#([\w\-\.ã-ã‚“ã‚¡-ヶ亜-熙]+)/,"($1):touchnot#($2)")).replace(/BEGIN/,"END"),g=new RegExp(m+"(([\\n\\r\\t]|.)*?)"+v,"g");t=t.replace(g,function(t,a,i,n){return""+("function"==typeof e[a]?e[a].apply(o):o.getDataFromObj(a,e))!==i?n:""})}if(r)for(var y=0,x=r.length;y<x;y+=1){var w=r[y],P=(w=w.replace(/([\w\-\.ã-ã‚“ã‚¡-ヶ亜-熙]+):exist/,"($1):exist")).replace(/BEGIN/,"END"),E=new RegExp(w+"(([\\n\\r\\t]|.)*?)"+P,"g");t=t.replace(E,function(t,a,i){var n="function"==typeof e[a]?e[a].apply(o):o.getDataFromObj(a,e);return n||0===n?i:""})}if(s)for(var b=0,_=s.length;b<_;b+=1){var I=s[b],N=(I=I.replace(/([\w\-\.ã-ã‚“ã‚¡-ヶ亜-熙]+):empty/,"($1):empty")).replace(/BEGIN/,"END"),S=new RegExp(I+"(([\\n\\r\\t]|.)*?)"+N,"g");t=t.replace(S,function(t,a,i){var n="function"==typeof e[a]?e[a].apply(o):o.getDataFromObj(a,e);return n||0===n?"":i})}return t=t.replace(/{([\w\-\.ã-ã‚“ã‚¡-ヶ亜-熙]+)}(\[([\w\-\.ã-ã‚“ã‚¡-ヶ亜-熙]+)\])*/g,function(t,i,n,r){var s=void 0;if(""+i=="i")s=a;else{if(!e[i]&&0!==e[i])return r&&o.convert&&o.convert[r]?o.convert[r].call(o,""):"";s="function"==typeof e[i]?e[i].apply(o):e[i]}return r&&o.convert&&o.convert[r]?o.convert[r].call(o,s):s})}},{key:"resolveAbsBlock",value:function(t){var e=this;return t=t.replace(/{(.*?)}/g,function(t,a){var o=e.getDataByString(a);return void 0!==o?"function"==typeof o?o.apply(e):o:t})}},{key:"resolveInclude",value:function(t){return t=t.replace(/<!-- #include id="(.*?)" -->/g,function(t,e){return(0,s.selector)("#"+e).innerHTML})}},{key:"resolveWith",value:function(t){return t=t.replace(/<!-- BEGIN ([\w\-\.ã-ã‚“ã‚¡-ヶ亜-熙]+):with -->(([\n\r\t]|.)*?)<!-- END ([\w\-\.ã-ã‚“ã‚¡-ヶ亜-熙]+):with -->/g,function(t,e){return t=t.replace(/data\-bind=['"](.*?)['"]/g,"data-bind='"+e+".$1'")})}},{key:"resolveLoop",value:function(t){var e=this;return t=t.replace(/<!-- BEGIN ([\w\-\.ã-ã‚“ã‚¡-ヶ亜-熙]+?):loop -->(([\n\r\t]|.)*?)<!-- END ([\w\-\.ã-ã‚“ã‚¡-ヶ亜-熙]+?):loop -->/g,function(t,a,o){var i=e.getDataByString(a),n=[],r="";if((n="function"==typeof i?i.apply(e):i)instanceof Array)for(var s=0,d=n.length;s<d;s+=1)r+=e.resolveBlock(o,n[s],s);return r=r.replace(/\\([^\\])/g,"$1")})}},{key:"removeData",value:function(t){var e=this.data;return Object.keys(e).forEach(function(a){for(var o=0,i=t.length;o<i;o+=1)a===t[o]&&delete e[a]}),this}},{key:"hasLoop",value:function(t){return!!t.match(/<!-- BEGIN ([\w\-\.ã-ã‚“ã‚¡-ヶ亜-熙]+?):loop -->(([\n\r\t]|.)*?)<!-- END ([\w\-\.ã-ã‚“ã‚¡-ヶ亜-熙]+?):loop -->/g)}},{key:"getHtml",value:function(t,e){var a=this.atemplate.find(function(e){return e.id===t}),o="";if(a&&a.html&&(o=a.html),e&&(o=t),!o)return"";var i=this.data;for(o=this.resolveInclude(o),o=this.resolveWith(o);this.hasLoop(o);)o=this.resolveLoop(o);return o=(o=this.resolveBlock(o,i)).replace(/\\([^\\])/g,"$1"),(o=this.resolveAbsBlock(o)).replace(/^([\t ])*\n/gm,"")}},{key:"update",value:function(){var t=this,e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"html",a=arguments[1],o=this.templates;this.beforeUpdated&&this.beforeUpdated();for(var i=function(i,n){var d=o[i],c="#"+d,l=t.getHtml(d),h=(0,s.selector)("[data-id='"+d+"']");if(h)if("text"===e)h.innerText=l;else if(a){var u=document.createElement("div");u.innerHTML=l;var f=u.querySelector(a).outerHTML;(0,r.default)(h.querySelector(a),f)}else(0,r.default)(h,"<div data-id='"+d+"'>"+l+"</div>");else(0,s.selector)(c).insertAdjacentHTML("afterend",'<div data-id="'+d+'"></div>'),"text"===e?(0,s.selector)("[data-id='"+d+"']").innerText=l:(0,s.selector)("[data-id='"+d+"']").innerHTML=l;var p=t.atemplate.find(function(t){return t.id===d});p.binded||(p.binded=!0,t.addDataBind((0,s.selector)("[data-id='"+d+"']")),t.addActionBind((0,s.selector)("[data-id='"+d+"']")))},n=0,d=o.length;n<d;n+=1)i(n);return this.updateBindingData(a),this.onUpdated&&this.onUpdated(a),this}},{key:"updateBindingData",value:function(t){for(var e=this,a=this.templates,o=0,i=a.length;o<i;o+=1){var n=a[o],r=(0,s.selector)("[data-id='"+n+"']");t&&(r=r.querySelector(t));var d=r.querySelectorAll("[data-bind]");[].forEach.call(d,function(t){var a=e.getDataByString(t.getAttribute("data-bind"));"checkbox"===t.getAttribute("type")||"radio"===t.getAttribute("type")?a===t.value&&(t.checked=!0):t.value=a});var c=r.querySelectorAll("[data-bind-oneway]");[].forEach.call(c,function(t){var a=e.getDataByString(t.getAttribute("data-bind-oneway"));"checkbox"===t.getAttribute("type")||"radio"===t.getAttribute("type")?a===t.value&&(t.checked=!0):t.value=a})}return this}},{key:"applyMethod",value:function(t){for(var e,a=arguments.length,o=Array(a>1?a-1:0),i=1;i<a;i++)o[i-1]=arguments[i];return(e=this.method)[t].apply(e,o)}},{key:"getComputedProp",value:function(t){return this.data[t].apply(this)}},{key:"remove",value:function(t){for(var e=this.data,a=t.split(".");a.length>1;)e=e[a.shift()];var o=a.shift();return o.match(/^\d+$/)?e.splice(Number(o),1):delete e[o],this}}]),t}();a.default=h,e.exports=a.default},{"./util":2,"ie-array-find-polyfill":5,morphdom:6}],2:[function(t,e,a){"use strict";Object.defineProperty(a,"__esModule",{value:!0});var o=a.matches=function(t,e){for(var a=(t.document||t.ownerDocument).querySelectorAll(e),o=a.length;--o>=0&&a.item(o)!==t;);return o>-1},i=(a.selector=function(t){return document.querySelector(t)},a.findAncestor=function(t,e){if("function"==typeof t.closest)return t.closest(e)||null;for(;t&&t!==document;){if(o(t,e))return t;t=t.parentElement}return null});a.on=function(t,e,a,o){a.split(" ").forEach(function(a){t.addEventListener(a,function(t){t.target;var a=i(t.target,e);a&&(t.delegateTarget=a,o(t))})})}},{}],3:[function(t,e,a){try{var o=new window.CustomEvent("test");if(o.preventDefault(),!0!==o.defaultPrevented)throw new Error("Could not prevent default")}catch(t){var i=function(t,e){var a,o;return e=e||{bubbles:!1,cancelable:!1,detail:void 0},(a=document.createEvent("CustomEvent")).initCustomEvent(t,e.bubbles,e.cancelable,e.detail),o=a.preventDefault,a.preventDefault=function(){o.call(this);try{Object.defineProperty(this,"defaultPrevented",{get:function(){return!0}})}catch(t){this.defaultPrevented=!0}},a};i.prototype=window.Event.prototype,window.CustomEvent=i}},{}],4:[function(t,e,a){(function(t,e){!function(t){var o,i=t.Promise,n=i&&"resolve"in i&&"reject"in i&&"all"in i&&"race"in i&&(new i(function(t){o=t}),"function"==typeof o);void 0!==a&&a?(a.Promise=n?i:I,a.Polyfill=I):n||(t.Promise=I);var r="pending",s="sealed",d="fulfilled",c="rejected",l=function(){};function h(t){return"[object Array]"===Object.prototype.toString.call(t)}var u,f=void 0!==e?e:setTimeout,p=[];function m(){for(var t=0;t<p.length;t++)p[t][0](p[t][1]);p=[],u=!1}function v(t,e){p.push([t,e]),u||(u=!0,f(m,0))}function g(t){var e=t.owner,a=e.state_,o=e.data_,i=t[a],n=t.then;if("function"==typeof i){a=d;try{o=i(o)}catch(t){P(n,t)}}y(n,o)||(a===d&&x(n,o),a===c&&P(n,o))}function y(t,e){var a;try{if(t===e)throw new TypeError("A promises callback cannot return that same promise.");if(e&&("function"==typeof e||"object"==typeof e)){var o=e.then;if("function"==typeof o)return o.call(e,function(o){a||(a=!0,e!==o?x(t,o):w(t,o))},function(e){a||(a=!0,P(t,e))}),!0}}catch(e){return a||P(t,e),!0}return!1}function x(t,e){t!==e&&y(t,e)||w(t,e)}function w(t,e){t.state_===r&&(t.state_=s,t.data_=e,v(b,t))}function P(t,e){t.state_===r&&(t.state_=s,t.data_=e,v(_,t))}function E(t){var e=t.then_;t.then_=void 0;for(var a=0;a<e.length;a++)g(e[a])}function b(t){t.state_=d,E(t)}function _(t){t.state_=c,E(t)}function I(t){if("function"!=typeof t)throw new TypeError("Promise constructor takes a function argument");if(this instanceof I==!1)throw new TypeError("Failed to construct 'Promise': Please use the 'new' operator, this object constructor cannot be called as a function.");this.then_=[],function(t,e){function a(t){P(e,t)}try{t(function(t){x(e,t)},a)}catch(t){a(t)}}(t,this)}I.prototype={constructor:I,state_:r,then_:null,data_:void 0,then:function(t,e){var a={owner:this,then:new this.constructor(l),fulfilled:t,rejected:e};return this.state_===d||this.state_===c?v(g,a):this.then_.push(a),a.then},catch:function(t){return this.then(null,t)}},I.all=function(t){if(!h(t))throw new TypeError("You must pass an array to Promise.all().");return new this(function(e,a){var o=[],i=0;function n(t){return i++,function(a){o[t]=a,--i||e(o)}}for(var r,s=0;s<t.length;s++)(r=t[s])&&"function"==typeof r.then?r.then(n(s),a):o[s]=r;i||e(o)})},I.race=function(t){if(!h(t))throw new TypeError("You must pass an array to Promise.race().");return new this(function(e,a){for(var o,i=0;i<t.length;i++)(o=t[i])&&"function"==typeof o.then?o.then(e,a):e(o)})},I.resolve=function(t){return t&&"object"==typeof t&&t.constructor===this?t:new this(function(e){e(t)})},I.reject=function(t){return new this(function(e,a){a(t)})}}("undefined"!=typeof window?window:void 0!==t?t:"undefined"!=typeof self?self:this)}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},t("timers").setImmediate)},{timers:8}],5:[function(t,e,a){"use strict";Array.prototype.find||Object.defineProperty(Array.prototype,"find",{value:function(t){if(null==this)throw new TypeError("this is null or not defined");var e=Object(this),a=e.length>>>0;if("function"!=typeof t)throw new TypeError("predicate must be a function");for(var o=arguments[1],i=0;i<a;){var n=e[i];if(t.call(o,n,i,e))return n;i++}}})},{}],6:[function(t,e,a){"use strict";var o,i="http://www.w3.org/1999/xhtml",n="undefined"==typeof document?void 0:document,r=n?n.body||n.createElement("div"):{},s=r.hasAttributeNS?function(t,e,a){return t.hasAttributeNS(e,a)}:r.hasAttribute?function(t,e,a){return t.hasAttribute(a)}:function(t,e,a){return null!=t.getAttributeNode(e,a)};function d(t,e){var a=t.nodeName,o=e.nodeName;return a===o||!!(e.actualize&&a.charCodeAt(0)<91&&o.charCodeAt(0)>90)&&a===o.toUpperCase()}function c(t,e,a){t[a]!==e[a]&&(t[a]=e[a],t[a]?t.setAttribute(a,""):t.removeAttribute(a,""))}var l={OPTION:function(t,e){c(t,e,"selected")},INPUT:function(t,e){c(t,e,"checked"),c(t,e,"disabled"),t.value!==e.value&&(t.value=e.value),s(e,null,"value")||t.removeAttribute("value")},TEXTAREA:function(t,e){var a=e.value;t.value!==a&&(t.value=a);var o=t.firstChild;if(o){var i=o.nodeValue;if(i==a||!a&&i==t.placeholder)return;o.nodeValue=a}},SELECT:function(t,e){if(!s(e,null,"multiple")){for(var a=0,o=e.firstChild;o;){var i=o.nodeName;if(i&&"OPTION"===i.toUpperCase()){if(s(o,null,"selected")){a;break}a++}o=o.nextSibling}t.selectedIndex=a}}},h=1,u=3,f=8;function p(){}function m(t){return t.id}var v,g=(v=function(t,e){var a,o,i,n,r,d=e.attributes;for(a=d.length-1;a>=0;--a)i=(o=d[a]).name,n=o.namespaceURI,r=o.value,n?(i=o.localName||i,t.getAttributeNS(n,i)!==r&&t.setAttributeNS(n,i,r)):t.getAttribute(i)!==r&&t.setAttribute(i,r);for(a=(d=t.attributes).length-1;a>=0;--a)!1!==(o=d[a]).specified&&(i=o.name,(n=o.namespaceURI)?(i=o.localName||i,s(e,n,i)||t.removeAttributeNS(n,i)):s(e,null,i)||t.removeAttribute(i))},function(t,e,a){if(a||(a={}),"string"==typeof e)if("#document"===t.nodeName||"HTML"===t.nodeName){var r=e;(e=n.createElement("html")).innerHTML=r}else s=e,!o&&n.createRange&&(o=n.createRange()).selectNode(n.body),o&&o.createContextualFragment?c=o.createContextualFragment(s):(c=n.createElement("body")).innerHTML=s,e=c.childNodes[0];var s,c,g,y=a.getNodeKey||m,x=a.onBeforeNodeAdded||p,w=a.onNodeAdded||p,P=a.onBeforeElUpdated||p,E=a.onElUpdated||p,b=a.onBeforeNodeDiscarded||p,_=a.onNodeDiscarded||p,I=a.onBeforeElChildrenUpdated||p,N=!0===a.childrenOnly,S={};function k(t){g?g.push(t):g=[t]}function B(t,e,a){!1!==b(t)&&(e&&e.removeChild(t),_(t),function t(e,a){if(e.nodeType===h)for(var o=e.firstChild;o;){var i=void 0;a&&(i=y(o))?k(i):(_(o),o.firstChild&&t(o,a)),o=o.nextSibling}}(t,a))}function D(t){w(t);for(var e=t.firstChild;e;){var a=e.nextSibling,o=y(e);if(o){var i=S[o];i&&d(e,i)&&(e.parentNode.replaceChild(i,e),A(i,e))}D(e),e=a}}function A(a,o,i){var r,s=y(o);if(s&&delete S[s],!e.isSameNode||!e.isSameNode(t)){if(!i){if(!1===P(a,o))return;if(v(a,o),E(a),!1===I(a,o))return}if("TEXTAREA"!==a.nodeName){var c,p,m,g,w=o.firstChild,b=a.firstChild;t:for(;w;){for(m=w.nextSibling,c=y(w);b;){if(p=b.nextSibling,w.isSameNode&&w.isSameNode(b)){w=m,b=p;continue t}r=y(b);var _=b.nodeType,N=void 0;if(_===w.nodeType&&(_===h?(c?c!==r&&((g=S[c])?b.nextSibling===g?N=!1:(a.insertBefore(g,b),p=b.nextSibling,r?k(r):B(b,a,!0),b=g):N=!1):r&&(N=!1),(N=!1!==N&&d(b,w))&&A(b,w)):_!==u&&_!=f||(N=!0,b.nodeValue!==w.nodeValue&&(b.nodeValue=w.nodeValue))),N){w=m,b=p;continue t}r?k(r):B(b,a,!0),b=p}if(c&&(g=S[c])&&d(g,w))a.appendChild(g),A(g,w);else{var T=x(w);!1!==T&&(T&&(w=T),w.actualize&&(w=w.actualize(a.ownerDocument||n)),a.appendChild(w),D(w))}w=m,b=p}for(;b;)p=b.nextSibling,(r=y(b))?k(r):B(b,a,!0),b=p}var O=l[a.nodeName];O&&O(a,o)}}!function t(e){if(e.nodeType===h)for(var a=e.firstChild;a;){var o=y(a);o&&(S[o]=a),t(a),a=a.nextSibling}}(t);var T,O,C=t,G=C.nodeType,L=e.nodeType;if(!N)if(G===h)L===h?d(t,e)||(_(t),C=function(t,e){for(var a=t.firstChild;a;){var o=a.nextSibling;e.appendChild(a),a=o}return e}(t,(T=e.nodeName,(O=e.namespaceURI)&&O!==i?n.createElementNS(O,T):n.createElement(T)))):C=e;else if(G===u||G===f){if(L===G)return C.nodeValue!==e.nodeValue&&(C.nodeValue=e.nodeValue),C;C=e}if(C===e)_(t);else if(A(C,e,N),g)for(var X=0,z=g.length;X<z;X++){var Y=S[g[X]];Y&&B(Y,Y.parentNode,!1)}return!N&&C!==t&&t.parentNode&&(C.actualize&&(C=C.actualize(t.ownerDocument||n)),t.parentNode.replaceChild(C,t)),C});e.exports=g},{}],7:[function(t,e,a){var o,i,n=e.exports={};function r(){throw new Error("setTimeout has not been defined")}function s(){throw new Error("clearTimeout has not been defined")}function d(t){if(o===setTimeout)return setTimeout(t,0);if((o===r||!o)&&setTimeout)return o=setTimeout,setTimeout(t,0);try{return o(t,0)}catch(e){try{return o.call(null,t,0)}catch(e){return o.call(this,t,0)}}}!function(){try{o="function"==typeof setTimeout?setTimeout:r}catch(t){o=r}try{i="function"==typeof clearTimeout?clearTimeout:s}catch(t){i=s}}();var c,l=[],h=!1,u=-1;function f(){h&&c&&(h=!1,c.length?l=c.concat(l):u=-1,l.length&&p())}function p(){if(!h){var t=d(f);h=!0;for(var e=l.length;e;){for(c=l,l=[];++u<e;)c&&c[u].run();u=-1,e=l.length}c=null,h=!1,function(t){if(i===clearTimeout)return clearTimeout(t);if((i===s||!i)&&clearTimeout)return i=clearTimeout,clearTimeout(t);try{i(t)}catch(e){try{return i.call(null,t)}catch(e){return i.call(this,t)}}}(t)}}function m(t,e){this.fun=t,this.array=e}function v(){}n.nextTick=function(t){var e=new Array(arguments.length-1);if(arguments.length>1)for(var a=1;a<arguments.length;a++)e[a-1]=arguments[a];l.push(new m(t,e)),1!==l.length||h||d(p)},m.prototype.run=function(){this.fun.apply(null,this.array)},n.title="browser",n.browser=!0,n.env={},n.argv=[],n.version="",n.versions={},n.on=v,n.addListener=v,n.once=v,n.off=v,n.removeListener=v,n.removeAllListeners=v,n.emit=v,n.prependListener=v,n.prependOnceListener=v,n.listeners=function(t){return[]},n.binding=function(t){throw new Error("process.binding is not supported")},n.cwd=function(){return"/"},n.chdir=function(t){throw new Error("process.chdir is not supported")},n.umask=function(){return 0}},{}],8:[function(t,e,a){(function(e,o){var i=t("process/browser.js").nextTick,n=Function.prototype.apply,r=Array.prototype.slice,s={},d=0;function c(t,e){this._id=t,this._clearFn=e}a.setTimeout=function(){return new c(n.call(setTimeout,window,arguments),clearTimeout)},a.setInterval=function(){return new c(n.call(setInterval,window,arguments),clearInterval)},a.clearTimeout=a.clearInterval=function(t){t.close()},c.prototype.unref=c.prototype.ref=function(){},c.prototype.close=function(){this._clearFn.call(window,this._id)},a.enroll=function(t,e){clearTimeout(t._idleTimeoutId),t._idleTimeout=e},a.unenroll=function(t){clearTimeout(t._idleTimeoutId),t._idleTimeout=-1},a._unrefActive=a.active=function(t){clearTimeout(t._idleTimeoutId);var e=t._idleTimeout;e>=0&&(t._idleTimeoutId=setTimeout(function(){t._onTimeout&&t._onTimeout()},e))},a.setImmediate="function"==typeof e?e:function(t){var e=d++,o=!(arguments.length<2)&&r.call(arguments,1);return s[e]=!0,i(function(){s[e]&&(o?t.apply(null,o):t.call(null),a.clearImmediate(e))}),e},a.clearImmediate="function"==typeof o?o:function(t){delete s[t]}}).call(this,t("timers").setImmediate,t("timers").clearImmediate)},{"process/browser.js":7,timers:8}],9:[function(t,e,a){"use strict";Object.defineProperty(a,"__esModule",{value:!0});var o,i=function(){function t(t,e){for(var a=0;a<e.length;a++){var o=e[a];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(t,o.key,o)}}return function(e,a,o){return a&&t(e.prototype,a),o&&t(e,o),e}}(),n=t("a-template"),r=(o=n)&&o.__esModule?o:{default:o};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}t("custom-event-polyfill");var d='<div class="\\{classNames.smartPhoto\\}"\x3c!-- BEGIN hide:exist --\x3e aria-hidden="true"\x3c!-- END hide:exist --\x3e\x3c!-- BEGIN hide:empty --\x3e aria-hidden="false"\x3c!-- END hide:empty --\x3e role="dialog">\n\t<div class="\\{classNames.smartPhotoBody\\}">\n\t\t<div class="\\{classNames.smartPhotoInner\\}">\n\t\t\t <div class="\\{classNames.smartPhotoHeader\\}">\n\t\t\t\t\t<span class="\\{classNames.smartPhotoCount\\}">{currentIndex}[increment]/{total}</span>\n\t\t\t\t\t<span class="\\{classNames.smartPhotoCaption\\}" aria-live="polite" tabindex="-1">\x3c!-- BEGIN groupItems:loop --\x3e\x3c!-- \\BEGIN currentIndex:touch#{index} --\x3e{caption}\x3c!-- \\END currentIndex:touch#{index} --\x3e\x3c!-- END groupItems:loop --\x3e</span>\n\t\t\t\t\t<button class="\\{classNames.smartPhotoDismiss\\}" data-action-click="hidePhoto()"><span class="smartphoto-sr-only">\\{message.closeDialog\\}</span></button>\n\t\t\t\t</div>\n\t\t\t\t<div class="\\{classNames.smartPhotoContent\\}"\x3c!-- BEGIN isSmartPhone:exist --\x3e data-action-touchstart="beforeDrag" data-action-touchmove="onDrag" data-action-touchend="afterDrag(false)"\x3c!-- END isSmartPhone:exist --\x3e\x3c!-- BEGIN isSmartPhone:empty --\x3e data-action-click="hidePhoto()"\x3c!-- END isSmartPhone:empty --\x3e>\n\t\t\t\t</div>\n\t\t\t\t<ul style="transform:translate({translateX}[round]px,{translateY}[round]px);" class="\\{classNames.smartPhotoList\\}\x3c!-- BEGIN onMoveClass:exist --\x3e \\{classNames.smartPhotoListOnMove\\}\x3c!-- END onMoveClass:exist --\x3e">\n\t\t\t\t\t\x3c!-- BEGIN groupItems:loop --\x3e\n\t\t\t\t\t<li style="transform:translate({translateX}[round]px,{translateY}[round]px);" class="\x3c!-- \\BEGIN currentIndex:touch#{index} --\x3ecurrent\x3c!-- \\END currentIndex:touch#{index} --\x3e">\n\t\t\t\t\t\t\x3c!-- BEGIN processed:exist --\x3e\n\t\t\t\t\t\t<div style="transform:translate({x}[round]px,{y}[round]px) scale({scale});" class="\\\\{classNames.smartPhotoImgWrap\\\\}"\x3c!-- \\BEGIN isSmartPhone:empty --\x3e data-action-mousemove="onDrag" data-action-mousedown="beforeDrag" data-action-mouseup="afterDrag"\x3c!-- \\END isSmartPhone:empty --\x3e\x3c!-- \\BEGIN isSmartPhone:exist --\x3e data-action-touchstart="beforeDrag" data-action-touchmove="onDrag" data-action-touchend="afterDrag"\x3c!-- \\END isSmartPhone:exist --\x3e>\n\t\t\t\t\t\t\t<img style="\x3c!-- \\BEGIN currentIndex:touch#{index} --\x3etransform:translate(\\{photoPosX\\}[virtualPos]px,\\{photoPosY\\}[virtualPos]px) scale(\\{scaleSize\\});\x3c!-- \\END currentIndex:touch#{index} --\x3ewidth:{width}px;" src="{src}" class="\\\\{classNames.smartPhotoImg\\\\}\x3c!-- \\BEGIN scale:exist --\x3e \\\\{classNames.smartPhotoImgOnMove\\\\}\x3c!-- \\END scale:exist --\x3e\x3c!-- \\BEGIN elastic:exist --\x3e \\\\{classNames.smartPhotoImgElasticMove\\\\}\x3c!-- \\END elastic:exist --\x3e\x3c!-- \\BEGIN appear:exist --\x3e active\x3c!-- \\END appear:exist --\x3e" ondragstart="return false;">\n\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\x3c!-- END processed:exist --\x3e\n\t\t\t\t\t\t\x3c!-- BEGIN processed:empty --\x3e\n\t\t\t\t\t\t<div class="\\\\{classNames.smartPhotoLoaderWrap\\\\}">\n\t\t\t\t\t\t\t<span class="\\\\{classNames.smartPhotoLoader\\\\}"></span>\n\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\x3c!-- END processed:empty --\x3e\n\t\t\t\t\t</li>\n\t\t\t\t\t\x3c!-- END groupItems:loop --\x3e\n\t\t\t\t</ul>\n\t\t\t\t\x3c!-- BEGIN arrows:exist --\x3e\n\t\t\t\t<ul class="\\{classNames.smartPhotoArrows\\}"\x3c!-- BEGIN hideUi:exist --\x3e aria-hidden="true"\x3c!-- END hideUi:exist --\x3e\x3c!-- BEGIN hideUi:exist --\x3e aria-hidden="false"\x3c!-- END hideUi:exist --\x3e>\n\t\t\t\t\t<li class="\\{classNames.smartPhotoArrowLeft\\}\x3c!-- BEGIN isSmartPhone:exist --\x3e \\{classNames.smartPhotoArrowHideIcon\\}\x3c!-- END isSmartPhone:exist --\x3e"\x3c!-- BEGIN showPrevArrow:empty --\x3e aria-hidden="true"\x3c!-- END showPrevArrow:empty --\x3e><a href="#" data-action-click="gotoSlide({prev})" role="button"><span class="smartphoto-sr-only">\\{message.gotoPrevImage\\}</span></a></li>\n\t\t\t\t\t<li class="\\{classNames.smartPhotoArrowRight\\}\x3c!-- BEGIN isSmartPhone:exist --\x3e \\{classNames.smartPhotoArrowHideIcon\\}\x3c!-- END isSmartPhone:exist --\x3e"\x3c!-- BEGIN showNextArrow:empty --\x3e aria-hidden="true"\x3c!-- END showNextArrow:empty --\x3e><a href="#" data-action-click="gotoSlide({next})" role="button"><span class="smartphoto-sr-only">\\{message.gotoNextImage\\}</span></a></li>\n\t\t\t\t</ul>\n\t\t\t\t\x3c!-- END arrows:exist --\x3e\n\t\t\t\t\x3c!-- BEGIN nav:exist --\x3e\n\t\t\t\t<nav class="\\{classNames.smartPhotoNav\\}"\x3c!-- BEGIN hideUi:exist --\x3e aria-hidden="true"\x3c!-- END hideUi:exist --\x3e\x3c!-- BEGIN hideUi:exist --\x3e aria-hidden="false"\x3c!-- END hideUi:exist --\x3e>\n\t\t\t\t\t<ul>\n\t\t\t\t\t\t\x3c!-- BEGIN groupItems:loop --\x3e\n\t\t\t\t\t\t<li><a href="#" data-action-click="gotoSlide({index})" class="\x3c!-- \\BEGIN currentIndex:touch#{index} --\x3ecurrent\x3c!-- \\END currentIndex:touch#{index} --\x3e" style="background-image:url({thumb});" role="button"><span class="smartphoto-sr-only">go to {caption}</span></a></li>\n\t\t\t\t\t\t\x3c!-- END groupItems:loop --\x3e\n\t\t\t\t\t</ul>\n\t\t\t\t</nav>\n\t\t\t\t\x3c!-- END nav:exist --\x3e\n\t\t</div>\n\t\t\x3c!-- BEGIN appearEffect:exist --\x3e\n\t\t<img src=\\{appearEffect.img\\}\n\t\tclass="\\{classNames.smartPhotoImgClone\\}"\n\t\tstyle="width:\\{appearEffect.width\\}px;height:\\{appearEffect.height\\}px;transform:translate(\\{appearEffect.left\\}px,\\{appearEffect.top\\}px) scale(1)" />\n\t\t\x3c!-- END appearEffect:exist --\x3e\n\t</div>\n</div>\n',c=t("../lib/util"),l=t("es6-promise-polyfill").Promise,h={classNames:{smartPhoto:"smartphoto",smartPhotoClose:"smartphoto-close",smartPhotoBody:"smartphoto-body",smartPhotoInner:"smartphoto-inner",smartPhotoContent:"smartphoto-content",smartPhotoImg:"smartphoto-img",smartPhotoImgOnMove:"smartphoto-img-onmove",smartPhotoImgElasticMove:"smartphoto-img-elasticmove",smartPhotoImgWrap:"smartphoto-img-wrap",smartPhotoArrows:"smartphoto-arrows",smartPhotoNav:"smartphoto-nav",smartPhotoArrowRight:"smartphoto-arrow-right",smartPhotoArrowLeft:"smartphoto-arrow-left",smartPhotoArrowHideIcon:"smartphoto-arrow-hide",smartPhotoImgLeft:"smartphoto-img-left",smartPhotoImgRight:"smartphoto-img-right",smartPhotoList:"smartphoto-list",smartPhotoListOnMove:"smartphoto-list-onmove",smartPhotoHeader:"smartphoto-header",smartPhotoCount:"smartphoto-count",smartPhotoCaption:"smartphoto-caption",smartPhotoDismiss:"smartphoto-dismiss",smartPhotoLoader:"smartphoto-loader",smartPhotoLoaderWrap:"smartphoto-loader-wrap",smartPhotoImgClone:"smartphoto-img-clone"},message:{gotoNextImage:"go to the next image",gotoPrevImage:"go to the previous image",closeDialog:"close the image dialog"},arrows:!0,nav:!0,showAnimation:!0,verticalGravity:!1,useOrientationApi:!1,useHistoryApi:!0,swipeTopToClose:!1,swipeBottomToClose:!0,swipeOffset:100,headerHeight:60,footerHeight:60,forceInterval:10,registance:.5,loadOffset:2,resizeStyle:"fit"},u=function(t){function e(t,a){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,e);var o=s(this,(e.__proto__||Object.getPrototypeOf(e)).call(this));o.data=c.extend({},h,a),o.data.currentIndex=0,o.data.oldIndex=0,o.data.hide=!0,o.data.group={},o.data.scaleSize=1,o.data.scale=!1,o.pos={x:0,y:0},o.data.photoPosX=0,o.data.photoPosY=0,o.convert={increment:o.increment,virtualPos:o.virtualPos,round:o.round},o.data.groupItems=o.groupItems,o.elements="string"==typeof t?document.querySelectorAll(t):t;var i=new Date;o.tapSecond=i.getTime(),o.onListMove=!1,o.clicked=!1,o.id=o._getUniqId(),o.vx=0,o.vy=0,o.data.appearEffect=null,o.addTemplate(o.id,d),o.data.isSmartPhone=o._isSmartPhone();var n=document.querySelector("body");c.append(n,"<div data-id='"+o.id+"'></div>"),[].forEach.call(o.elements,function(t){o.addNewItem(t)}),o.update();var r=o._getCurrentItemByHash();return r&&c.triggerEvent(r.element,"click"),setInterval(function(){o._doAnim()},o.data.forceInterval),o.data.isSmartPhone?(window.addEventListener("orientationchange",function(){o.groupItems()&&(o._resetTranslate(),o._setPosByCurrentIndex(),o._setHashByCurrentIndex(),o._setSizeByScreen(),o.update())}),o.data.useOrientationApi?(window.addEventListener("deviceorientation",function(t){var e=window.orientation;t&&t.gamma&&!o.data.appearEffect&&(o.isBeingZoomed||o.photoSwipable||o.data.elastic||!o.data.scale||(0===e?o._calcGravity(t.gamma,t.beta):90===e?o._calcGravity(t.beta,t.gamma):-90===e?o._calcGravity(-t.beta,-t.gamma):180===e&&o._calcGravity(-t.gamma,-t.beta)))}),o):s(o)):(window.addEventListener("resize",function(){o.groupItems()&&(o._resetTranslate(),o._setPosByCurrentIndex(),o._setSizeByScreen(),o.update())}),window.addEventListener("keydown",function(t){var e=t.keyCode||t.which;!0!==o.data.hide&&(37===e?o.gotoSlide(o.data.prev):39===e?o.gotoSlide(o.data.next):27===e&&o.hidePhoto())}),s(o))}return function(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)}(e,r.default),i(e,[{key:"on",value:function(t,e){var a=this;this._getElementByClass(this.data.classNames.smartPhoto).addEventListener(t,function(t){e.call(a,t)})}},{key:"increment",value:function(t){return t+1}},{key:"round",value:function(t){return Math.round(t)}},{key:"virtualPos",value:function(t){return(t=parseInt(t,10))/this._getSelectedItem().scale/this.data.scaleSize}},{key:"groupItems",value:function(){return this.data.group[this.data.currentGroup]}},{key:"_resetTranslate",value:function(){var t=this;this.groupItems().forEach(function(e,a){e.translateX=t._getWindowWidth()*a})}},{key:"addNewItem",value:function(t){var e=this,a=t.getAttribute("data-group")||"nogroup",o=this.data.group;"nogroup"===a&&t.setAttribute("data-group","nogroup"),o[a]||(o[a]=[]);var i=o[a].length,n=document.querySelector("body"),r=t.getAttribute("href"),s=t.querySelector("img"),d=r;s&&(d=s.currentSrc?s.currentSrc:s.src);var c={src:r,thumb:d,caption:t.getAttribute("data-caption"),groupId:a,translateX:this._getWindowWidth()*i,index:i,translateY:0,width:50,height:50,id:t.getAttribute("data-id")||i,loaded:!1,processed:!1,element:t};o[a].push(c),this.data.currentGroup=a,t.getAttribute("data-id")||t.setAttribute("data-id",i),t.setAttribute("data-index",i),t.addEventListener("click",function(a){a.preventDefault(),e.data.currentGroup=t.getAttribute("data-group"),e.data.currentIndex=parseInt(t.getAttribute("data-index"),10),e._setHashByCurrentIndex();var o=e._getSelectedItem();o.loaded?(e._initPhoto(),e.addAppearEffect(t,o),e.clicked=!0,e.update(),n.style.overflow="hidden",e._fireEvent("open")):e._loadItem(o).then(function(){e._initPhoto(),e.addAppearEffect(t,o),e.clicked=!0,e.update(),n.style.overflow="hidden",e._fireEvent("open")})})}},{key:"_initPhoto",value:function(){this.data.total=this.groupItems().length,this.data.hide=!1,this.data.photoPosX=0,this.data.photoPosY=0,this._setPosByCurrentIndex(),this._setSizeByScreen(),this.setArrow(),"fill"===this.data.resizeStyle&&this.data.isSmartPhone&&(this.data.scale=!0,this.data.hideUi=!0,this.data.scaleSize=this._getScaleBoarder())}},{key:"onUpdated",value:function(){var t=this;if(this.data.appearEffect&&this.data.appearEffect.once&&(this.data.appearEffect.once=!1,this.execEffect().then(function(){t.data.appearEffect=null,t.data.appear=!0,t.update()})),this.clicked){this.clicked=!1;var e=this.data.classNames;this._getElementByClass(e.smartPhotoCaption).focus()}}},{key:"execEffect",value:function(){var t=this;return new l(function(e){c.isOldIE()&&e();var a=t.data,o=a.appearEffect,i=a.classNames,n=t._getElementByClass(i.smartPhotoImgClone);n.addEventListener("transitionend",function t(){n.removeEventListener("transitionend",t,!0),e()},!0),setTimeout(function(){n.style.transform="translate("+o.afterX+"px, "+o.afterY+"px) scale("+o.scale+")"},10)})}},{key:"addAppearEffect",value:function(t,e){if(!1!==this.data.showAnimation){var a=t.querySelector("img"),o=c.getViewPos(a),i={},n=1;i.width=a.offsetWidth,i.height=a.offsetHeight,i.top=o.top,i.left=o.left,i.once=!0,i.img=e.src;var r=this._getWindowWidth(),s=this._getWindowHeight(),d=s-this.data.headerHeight-this.data.footerHeight;"fill"===this.data.resizeStyle&&this.data.isSmartPhone?n=a.offsetWidth>a.offsetHeight?s/a.offsetHeight:r/a.offsetWidth:(i.width>=i.height?n=e.height<d?e.width/i.width:d/i.height:i.height>i.width&&(n=e.height<d?e.height/i.height:d/i.height),i.width*n>r&&(n=r/i.width));var l=(n-1)/2*a.offsetWidth+(r-a.offsetWidth*n)/2,h=(n-1)/2*a.offsetHeight+(s-a.offsetHeight*n)/2;i.afterX=l,i.afterY=h,i.scale=n,this.data.appearEffect=i}else this.data.appear=!0}},{key:"hidePhoto",value:function(){var t=this,e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"bottom";this.data.hide=!0,this.data.appear=!1,this.data.appearEffect=null,this.data.hideUi=!1,this.data.scale=!1,this.data.scaleSize=1;var a=void 0!==window.pageXOffset?window.pageXOffset:(document.documentElement||document.body.parentNode||document.body).scrollLeft,o=void 0!==window.pageYOffset?window.pageYOffset:(document.documentElement||document.body.parentNode||document.body).scrollTop,i=document.querySelector("body");window.location.hash,window.scroll(a,o),this._doHideEffect(e).then(function(){t.update(),i.style.overflow="",t._fireEvent("close")})}},{key:"_doHideEffect",value:function(t){var e=this;return new l(function(a){c.isOldIE()&&a();var o=e.data.classNames,i=e._getElementByClass(o.smartPhoto),n=e._getElementByQuery(".current ."+o.smartPhotoImg),r=e._getWindowHeight();i.style.opacity=0,"bottom"===t?n.style.transform="translateY("+r+"px)":"top"===t&&(n.style.transform="translateY(-"+r+"px)"),i.addEventListener("transitionend",function t(){i.removeEventListener("transitionend",t,!0),a()},!0)})}},{key:"_getElementByClass",value:function(t){return document.querySelector('[data-id="'+this.id+'"] .'+t)}},{key:"_getElementByQuery",value:function(t){return document.querySelector('[data-id="'+this.id+'"] '+t)}},{key:"_getTouchPos",value:function(){var t=0,e=0,a="undefined"==typeof event?this.e:event;return this._isTouched(a)?(t=a.touches[0].pageX,e=a.touches[0].pageY):a.pageX&&(t=a.pageX,e=a.pageY),{x:t,y:e}}},{key:"_getGesturePos",value:function(t){var e=t.touches;return[{x:e[0].pageX,y:e[0].pageY},{x:e[1].pageX,y:e[1].pageY}]}},{key:"_setPosByCurrentIndex",value:function(){var t=this,e=-1*this.groupItems()[this.data.currentIndex].translateX;this.pos.x=e,setTimeout(function(){t.data.translateX=e,t.data.translateY=0,t._listUpdate()},1)}},{key:"_setHashByCurrentIndex",value:function(){var t=void 0!==window.pageXOffset?window.pageXOffset:(document.documentElement||document.body.parentNode||document.body).scrollLeft,e=void 0!==window.pageYOffset?window.pageYOffset:(document.documentElement||document.body.parentNode||document.body).scrollTop,a=this.groupItems()[this.data.currentIndex].id;this.data.currentGroup;window.scroll(t,e)}},{key:"_setHash",value:function(t){window.history&&window.history.pushState&&this.data.useHistoryApi&&(t?window.history.replaceState(null,null,""+location.pathname+location.search+"#"+t):window.history.replaceState(null,null,""+location.pathname+location.search))}},{key:"_getCurrentItemByHash",value:function(){var t=this.data.group,e=location.hash.substr(1),a=c.parseQuery(e),o=null,i=function(t){a.group===t.groupId&&a.photo===t.id&&(o=t)};return Object.keys(t).forEach(function(e){t[e].forEach(i)}),o}},{key:"_loadItem",value:function(t){return new l(function(e){var a=new Image;a.onload=function(){t.width=a.width,t.height=a.height,t.loaded=!0,e()},a.onerror=function(){e()},a.src=t.src})}},{key:"_getItemByIndex",value:function(t){var e=this.data;return e.group[e.currentGroup][t]?e.group[e.currentGroup][t]:null}},{key:"_loadNeighborItems",value:function(){for(var t=this,e=this.data.currentIndex,a=this.data.loadOffset,o=e+a,i=[],n=e-a;n<o;n++){var r=this._getItemByIndex(n);r&&!r.loaded&&i.push(this._loadItem(r))}i.length&&l.all(i).then(function(){t._initPhoto(),t.update()})}},{key:"_setSizeByScreen",value:function(){var t=this._getWindowWidth(),e=this._getWindowHeight(),a=this.data.headerHeight,o=this.data.footerHeight,i=e-(a+o);this.groupItems().forEach(function(a){a.loaded&&(a.processed=!0,a.scale=i/a.height,a.height<i&&(a.scale=1),a.x=(a.scale-1)/2*a.width+(t-a.width*a.scale)/2,a.y=(a.scale-1)/2*a.height+(e-a.height*a.scale)/2,a.width*a.scale>t&&(a.scale=t/a.width,a.x=(a.scale-1)/2*a.width))})}},{key:"_slideList",value:function(){var t=this;this.data.scaleSize=1,this.isBeingZoomed=!1,this.data.hideUi=!1,this.data.scale=!1,this.data.photoPosX=0,this.data.photoPosY=0,this.data.onMoveClass=!0,this._setPosByCurrentIndex(),this._setHashByCurrentIndex(),this._setSizeByScreen(),setTimeout(function(){var e=t._getSelectedItem();t.data.onMoveClass=!1,t.setArrow(),t.update(),t.data.oldIndex!==t.data.currentIndex&&t._fireEvent("change"),t.data.oldIndex=t.data.currentIndex,t._loadNeighborItems(),e.loaded||t._loadItem(e).then(function(){t._initPhoto(),t.update()})},200)}},{key:"gotoSlide",value:function(t){this.e&&this.e.preventDefault&&this.e.preventDefault(),this.data.currentIndex=parseInt(t,10),this.data.currentIndex||(this.data.currentIndex=0),this._slideList()}},{key:"setArrow",value:function(){var t=this.groupItems().length,e=this.data.currentIndex+1,a=this.data.currentIndex-1;this.data.showNextArrow=!1,this.data.showPrevArrow=!1,e!==t&&(this.data.next=e,this.data.showNextArrow=!0),-1!==a&&(this.data.prev=a,this.data.showPrevArrow=!0)}},{key:"beforeDrag",value:function(){if(this._isGestured(this.e))this.beforeGesture();else if(this.isBeingZoomed=!1,this.data.scale)this.beforePhotoDrag();else{var t=this._getTouchPos();this.isSwipable=!0,this.dragStart=!0,this.firstPos=t,this.oldPos=t}}},{key:"afterDrag",value:function(){var t=this.groupItems(),e=(new Date).getTime(),a=this.tapSecond-e,o=0,i=0;if(this.isSwipable=!1,this.onListMove=!1,this.oldPos&&(o=this.oldPos.x-this.firstPos.x,i=this.oldPos.y-this.firstPos.y),this.isBeingZoomed)this.afterGesture();else if(this.data.scale)this.afterPhotoDrag();else if(c.isSmartPhone()||0!==o||0!==i){if(Math.abs(a)<=500&&0===o&&0===i)return this.e.preventDefault(),void this.zoomPhoto();this.tapSecond=e,this._fireEvent("swipeend"),"horizontal"===this.moveDir&&(o>=this.data.swipeOffset&&0!==this.data.currentIndex?this.data.currentIndex-=1:o<=-this.data.swipeOffset&&this.data.currentIndex!==t.length-1&&(this.data.currentIndex+=1),this._slideList()),"vertical"===this.moveDir&&(this.data.swipeBottomToClose&&i>=this.data.swipeOffset?this.hidePhoto("bottom"):this.data.swipeTopToClose&&i<=-this.data.swipeOffset?this.hidePhoto("top"):(this.data.translateY=0,this._slideList()))}else this.zoomPhoto()}},{key:"onDrag",value:function(){if(this.e.preventDefault(),this._isGestured(this.e)&&!1===this.onListMove)this.onGesture();else if(!this.isBeingZoomed)if(this.data.scale)this.onPhotoDrag();else if(this.isSwipable){var t=this._getTouchPos(),e=t.x-this.oldPos.x,a=t.y-this.firstPos.y;this.dragStart&&(this._fireEvent("swipestart"),this.dragStart=!1,Math.abs(e)>Math.abs(a)?this.moveDir="horizontal":this.moveDir="vertical"),"horizontal"===this.moveDir?(this.pos.x+=e,this.data.translateX=this.pos.x):this.data.translateY=a,this.onListMove=!0,this.oldPos=t,this._listUpdate()}}},{key:"zoomPhoto",value:function(){var t=this;this.data.hideUi=!0,this.data.scaleSize=this._getScaleBoarder(),this.data.scaleSize<=1||(this.data.photoPosX=0,this.data.photoPosY=0,this._photoUpdate(),setTimeout(function(){t.data.scale=!0,t._photoUpdate(),t._fireEvent("zoomin")},300))}},{key:"zoomOutPhoto",value:function(){this.data.scaleSize=1,this.isBeingZoomed=!1,this.data.hideUi=!1,this.data.scale=!1,this.data.photoPosX=0,this.data.photoPosY=0,this._photoUpdate(),this._fireEvent("zoomout")}},{key:"beforePhotoDrag",value:function(){var t=this._getTouchPos();this.photoSwipable=!0,this.data.photoPosX||(this.data.photoPosX=0),this.data.photoPosY||(this.data.photoPosY=0),this.oldPhotoPos=t,this.firstPhotoPos=t}},{key:"onPhotoDrag",value:function(){if(this.photoSwipable){this.e.preventDefault();var t=this._getTouchPos(),e=t.x-this.oldPhotoPos.x,a=t.y-this.oldPhotoPos.y,o=this._round(this.data.scaleSize*e,6),i=this._round(this.data.scaleSize*a,6);"number"==typeof o&&(this.data.photoPosX+=o,this.photoVX=o),"number"==typeof i&&(this.data.photoPosY+=i,this.photoVY=i),this.oldPhotoPos=t,this._photoUpdate()}}},{key:"afterPhotoDrag",value:function(){if(this.oldPhotoPos.x===this.firstPhotoPos.x&&this.photoSwipable)this.photoSwipable=!1,this.zoomOutPhoto();else{this.photoSwipable=!1;var t=this._getSelectedItem(),e=this._makeBound(t),a=this.data.swipeOffset*this.data.scaleSize,o=0,i=0;if(this.data.photoPosX>e.maxX?o=-1:this.data.photoPosX<e.minX&&(o=1),this.data.photoPosY>e.maxY?i=-1:this.data.photoPosY<e.minY&&(i=1),this.data.photoPosX-e.maxX>a&&0!==this.data.currentIndex)return void this.gotoSlide(this.data.prev);if(e.minX-this.data.photoPosX>a&&this.data.currentIndex+1!==this.data.total)return void this.gotoSlide(this.data.next);0===o&&0===i?(this.vx=this.photoVX/5,this.vy=this.photoVY/5):this._registerElasticForce(o,i)}}},{key:"beforeGesture",value:function(){this._fireEvent("gesturestart");var t=this._getGesturePos(this.e),e=this._getDistance(t[0],t[1]);this.isBeingZoomed=!0,this.oldDistance=e,this.data.scale=!0,this.e.preventDefault()}},{key:"onGesture",value:function(){var t=this._getGesturePos(this.e),e=this._getDistance(t[0],t[1]),a=(e-this.oldDistance)/100,o=this.data.scaleSize,i=this.data.photoPosX,n=this.data.photoPosY;this.isBeingZoomed=!0,this.data.scaleSize+=this._round(a,6),this.data.scaleSize<.2&&(this.data.scaleSize=.2),this.data.scaleSize<o&&(this.data.photoPosX=(1+this.data.scaleSize-o)*i,this.data.photoPosY=(1+this.data.scaleSize-o)*n),this.data.scaleSize<1||this.data.scaleSize>this._getScaleBoarder()?this.data.hideUi=!0:this.data.hideUi=!1,this.oldDistance=e,this.e.preventDefault(),this._photoUpdate()}},{key:"afterGesture",value:function(){this.data.scaleSize>this._getScaleBoarder()||(this.data.photoPosX=0,this.data.photoPosY=0,this.data.scale=!1,this.data.scaleSize=1,this.data.hideUi=!1,this._fireEvent("gestureend"),this._photoUpdate())}},{key:"_getForceAndTheta",value:function(t,e){return{force:Math.sqrt(t*t+e*e),theta:Math.atan2(e,t)}}},{key:"_getScaleBoarder",value:function(){var t=this._getSelectedItem(),e=this._getWindowWidth(),a=this._getWindowHeight();return c.isSmartPhone()?t.width>t.height?a/(t.height*t.scale):e/(t.width*t.scale):1/t.scale}},{key:"_makeBound",value:function(t){var e=t.width*t.scale*this.data.scaleSize,a=t.height*t.scale*this.data.scaleSize,o=void 0,i=void 0,n=void 0,r=void 0,s=this._getWindowWidth(),d=this._getWindowHeight();return o=s>e?-1*(n=(s-e)/2):-1*(n=(e-s)/2),i=d>a?-1*(r=(d-a)/2):-1*(r=(a-d)/2),{minX:this._round(o,6)*this.data.scaleSize,minY:this._round(i,6)*this.data.scaleSize,maxX:this._round(n,6)*this.data.scaleSize,maxY:this._round(r,6)*this.data.scaleSize}}},{key:"_registerElasticForce",value:function(t,e){var a=this,o=this._getSelectedItem(),i=this._makeBound(o);this.data.elastic=!0,1===t?this.data.photoPosX=i.minX:-1===t&&(this.data.photoPosX=i.maxX),1===e?this.data.photoPosY=i.minY:-1===e&&(this.data.photoPosY=i.maxY),this._photoUpdate(),setTimeout(function(){a.data.elastic=!1,a._photoUpdate()},300)}},{key:"_getSelectedItem",value:function(){var t=this.data,e=t.currentIndex;return t.group[t.currentGroup][e]}},{key:"_getUniqId",value:function(){return(Date.now().toString(36)+Math.random().toString(36).substr(2,5)).toUpperCase()}},{key:"_getDistance",value:function(t,e){var a=t.x-e.x,o=t.y-e.y;return Math.sqrt(a*a+o*o)}},{key:"_round",value:function(t,e){var a=Math.pow(10,e);return t*=a,t=Math.round(t),t/=a}},{key:"_isTouched",value:function(t){return!(!t||!t.touches)}},{key:"_isGestured",value:function(t){return!!(t&&t.touches&&t.touches.length>1)}},{key:"_isSmartPhone",value:function(){var t=navigator.userAgent;return t.indexOf("iPhone")>0||t.indexOf("iPad")>0||t.indexOf("ipod")>0||t.indexOf("Android")>0}},{key:"_calcGravity",value:function(t,e){(t>5||t<-5)&&(this.vx+=.05*t),!1!==this.data.verticalGravity&&(e>5||e<-5)&&(this.vy+=.05*e)}},{key:"_photoUpdate",value:function(){var t=this.data.classNames,e=this._getElementByQuery(".current").querySelector("."+t.smartPhotoImg),a=this._getElementByQuery("."+t.smartPhotoNav),o=this._getElementByQuery("."+t.smartPhotoArrows),i="translate("+this.virtualPos(this.data.photoPosX)+"px,"+this.virtualPos(this.data.photoPosY)+"px) scale("+this.data.scaleSize+")";e.style.transform=i,this.data.scale?c.addClass(e,t.smartPhotoImgOnMove):c.removeClass(e,t.smartPhotoImgOnMove),this.data.elastic?c.addClass(e,t.smartPhotoImgElasticMove):c.removeClass(e,t.smartPhotoImgElasticMove),this.data.hideUi?(a&&a.setAttribute("aria-hidden","true"),o&&o.setAttribute("aria-hidden","true")):(a&&a.setAttribute("aria-hidden","false"),o&&o.setAttribute("aria-hidden","false"))}},{key:"_getWindowWidth",value:function(){return document&&document.documentElement?document.documentElement.clientWidth:window&&window.innerWidth?window.innerWidth:0}},{key:"_getWindowHeight",value:function(){return document&&document.documentElement?document.documentElement.clientHeight:window&&window.innerHeight?window.innerHeight:0}},{key:"_listUpdate",value:function(){var t=this.data.classNames,e=this._getElementByQuery("."+t.smartPhotoList),a="translate("+this.data.translateX+"px,"+this.data.translateY+"px)";e.style.transform=a,this.data.onMoveClass?c.addClass(e,t.smartPhotoListOnMove):c.removeClass(e,t.smartPhotoListOnMove)}},{key:"_fireEvent",value:function(t){var e=this._getElementByClass(this.data.classNames.smartPhoto);c.triggerEvent(e,t)}},{key:"_doAnim",value:function(){if(!(this.isBeingZoomed||this.isSwipable||this.photoSwipable||this.data.elastic)&&this.data.scale){this.data.photoPosX+=this.vx,this.data.photoPosY+=this.vy;var t=this._getSelectedItem(),e=this._makeBound(t);this.data.photoPosX<e.minX?(this.data.photoPosX=e.minX,this.vx*=-.2):this.data.photoPosX>e.maxX&&(this.data.photoPosX=e.maxX,this.vx*=-.2),this.data.photoPosY<e.minY?(this.data.photoPosY=e.minY,this.vy*=-.2):this.data.photoPosY>e.maxY&&(this.data.photoPosY=e.maxY,this.vy*=-.2);var a=this._getForceAndTheta(this.vx,this.vy),o=a.force,i=a.theta;o-=this.data.registance,Math.abs(o)<.5||(this.vx=Math.cos(i)*o,this.vy=Math.sin(i)*o,this._photoUpdate())}}}]),e}();a.default=u,e.exports=a.default},{"../lib/util":11,"a-template":1,"custom-event-polyfill":3,"es6-promise-polyfill":4}],10:[function(t,e,a){"use strict";e.exports=t("./core/")},{"./core/":9}],11:[function(t,e,a){"use strict";Object.defineProperty(a,"__esModule",{value:!0});var o="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t};a.isSmartPhone=function(){var t=navigator.userAgent;return t.indexOf("iPhone")>0||t.indexOf("iPad")>0||t.indexOf("ipod")>0||t.indexOf("Android")>0};a.extend=function t(e){e=e||{};for(var a=1;a<arguments.length;a++){var i=arguments[a];if(i)for(var n in i)i.hasOwnProperty(n)&&("object"===o(i[n])?e[n]=t(e[n],i[n]):e[n]=i[n])}return e},a.triggerEvent=function(t,e,a){var o=void 0;window.CustomEvent?o=new CustomEvent(e,{cancelable:!0}):(o=document.createEvent("CustomEvent")).initCustomEvent(e,!1,!1,a),t.dispatchEvent(o)},a.parseQuery=function(t){for(var e,a,o,i=t.split("&"),n={},r=0,s=i.length;r<s;r++)void 0!==(e=i[r].split("="))[0]&&(a=e[0],o=void 0!==e[1]?e.slice(1).join("="):a,n[a]=decodeURIComponent(o));return n},a.getViewPos=function(t){return{left:t.getBoundingClientRect().left,top:t.getBoundingClientRect().top}},a.removeElement=function(t){t&&t.parentNode&&t.parentNode.removeChild(t)},a.append=function(t,e){var a=document.createElement("div");for(a.innerHTML=e;a.children.length>0;)t.appendChild(a.children[0])},a.addClass=function(t,e){t.classList?t.classList.add(e):t.className+=" "+e},a.removeClass=function(t,e){t.classList?t.classList.remove(e):t.className=t.className.replace(new RegExp("(^|\\b)"+e.split(" ").join("|")+"(\\b|$)","gi")," ")};var i=a.getBrowser=function(){var t=window.navigator.userAgent.toLowerCase(),e=window.navigator.appVersion.toLowerCase(),a="unknown";return-1!=t.indexOf("msie")?a=-1!=e.indexOf("msie 6.")?"ie6":-1!=e.indexOf("msie 7.")?"ie7":-1!=e.indexOf("msie 8.")?"ie8":-1!=e.indexOf("msie 9.")?"ie9":-1!=e.indexOf("msie 10.")?"ie10":"ie":-1!=t.indexOf("trident/7")?a="ie11":-1!=t.indexOf("chrome")?a="chrome":-1!=t.indexOf("safari")?a="safari":-1!=t.indexOf("opera")?a="opera":-1!=t.indexOf("firefox")&&(a="firefox"),a};a.isOldIE=function(){var t=i();return-1!==t.indexOf("ie")&&parseInt(t.replace(/[^0-9]/g,""))<=10}},{}]},{},[10])(10)});