PageSourceSearch

https://www.wildflphoto.com/sp/smartphoto.js?v=1

js wildflphoto.com collected 2026-10-02 12:00:23 UTC 119,774 bytes, 3,734 lines download raw bytes

1/**
2 * Modules in this bundle
3 * @license
4 *
5 * smartphoto:
6 *   license: MIT (http://opensource.org/licenses/MIT)
7 *   author: appleple
8 *   homepage: http://developer.a-blogcms.jp
9 *   version: 1.4.3
10 *
11 * a-template:
12 *   license: MIT (http://opensource.org/licenses/MIT)
13 *   author: steelydylan
14 *   version: 0.5.4
15 *
16 * custom-event-polyfill:
17 *   license: MIT (http://opensource.org/licenses/MIT)
18 *   contributors: Frank Panetta, Mikhail Reenko <[email protected]>, Joscha Feth <[email protected]>
19 *   homepage: https://github.com/krambuhl/custom-event-polyfill#readme
20 *   version: 0.3.0
21 *
22 * es6-promise-polyfill:
23 *   license: MIT (http://opensource.org/licenses/MIT)
24 *   author: Roman Dvornov <[email protected]>
25 *   homepage: https://github.com/lahmatiy/es6-promise-polyfill#readme
26 *   version: 1.2.0
27 *
28 * ie-array-find-polyfill:
29 *   license: MIT (http://opensource.org/licenses/MIT)
30 *   author: Carlos Abdalla
31 *   homepage: https://github.com/abdalla/ie-array-find-polyfill#readme
32 *   version: 1.1.0
33 *
34 * morphdom:
35 *   license: MIT (http://opensource.org/licenses/MIT)
36 *   author: Patrick Steele-Idem <[email protected]>
37 *   homepage: https://github.com/patrick-steele-idem/morphdom#readme
38 *   version: 2.3.3
39 *
40 * process:
41 *   license: MIT (http://opensource.org/licenses/MIT)
42 *   author: Roman Shtylman <[email protected]>
43 *   homepage: https://github.com/shtylman/node-process#readme
44 *   version: 0.11.10
45 *
46 * timers-browserify:
47 *   licenses: MIT (http://opensource.org/licenses/MIT)
48 *   author: J. Ryan Stinnett <[email protected]>
49 *   contributors: Guy Bedford <[email protected]>, Ionut-Cristian Florescu <[email protected]>, James Halliday <[email protected]>, Jan Schär <[email protected]>, Johannes Ewald <[email protected]>, Jonathan Prins <[email protected]>, Matt Esch <[email protected]>
50 *   homepage: https://github.com/jryans/timers-browserify
51 *   version: 1.4.2
52 *
53 * This header is generated by licensify (https://github.com/twada/licensify)
54 */
55(function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.SmartPhoto = f()}})(function(){var define,module,exports;return (function(){function r(e,n,t){function o(i,f){if(!n[i]){if(!e[i]){var c="function"==typeof require&&require;if(!f&&c)return c(i,!0);if(u)return u(i,!0);var a=new Error("Cannot find module '"+i+"'");throw a.code="MODULE_NOT_FOUND",a}var p=n[i]={exports:{}};e[i][0].call(p.exports,function(r){var n=e[i][1][r];return o(n||r)},p,p.exports,r,e,n,t)}return n[i].exports}for(var u="function"==typeof require&&require,i=0;i<t.length;i++)o(t[i]);return o}return r})()({1:[function(require,module,exports){
56'use strict';
57
58Object.defineProperty(exports, "__esModule", {
59  value: true
60});
61
62var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
63
64require('ie-array-find-polyfill');
65
66var _morphdom = require('morphdom');
67
68var _morphdom2 = _interopRequireDefault(_morphdom);
69
70var _util = require('./util');
71
72function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
73
74function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } else { return Array.from(arr); } }
75
76function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
77
78var eventType = 'input paste copy click change keydown keyup keypress contextmenu mouseup mousedown mousemove touchstart touchend touchmove compositionstart compositionend focus';
79var bindType = 'input change click';
80var dataAction = eventType.replace(/([a-z]+)/g, '[data-action-$1],') + '[data-action]';
81
82var aTemplate = function () {
83  function aTemplate(opt) {
84    var _this = this;
85
86    _classCallCheck(this, aTemplate);
87
88    this.atemplate = [];
89    if (opt) {
90      Object.keys(opt).forEach(function (key) {
91        _this[key] = opt[key];
92      });
93    }
94    if (!this.data) {
95      this.data = {};
96    }
97    if (!this.templates) {
98      this.templates = [];
99    }
100    var templates = this.templates;
101    var length = templates.length;
102    for (var i = 0, n = length; i < n; i += 1) {
103      var template = this.templates[i];
104      var html = (0, _util.selector)('#' + template).innerHTML;
105      this.atemplate.push({ id: template, html: html, binded: false });
106    }
107  }
108
109  _createClass(aTemplate, [{
110    key: 'addDataBind',
111    value: function addDataBind(ele) {
112      var _this2 = this;
113
114      (0, _util.on)(ele, '[data-bind]', bindType, function (e) {
115        var target = e.delegateTarget;
116        var data = target.getAttribute('data-bind');
117        var attr = target.getAttribute('href');
118        var value = target.value;
119        if (attr) {
120          value = value.replace('#', '');
121        }
122        if (target.getAttribute('type') === 'checkbox') {
123          (function () {
124            var arr = [];
125            var items = document.querySelectorAll('[data-bind="' + data + '"]');
126            [].forEach.call(items, function (item) {
127              if (item.checked) {
128                arr.push(item.value);
129              }
130            });
131          })();
132        } else if (target.getAttribute('type') !== 'radio') {
133          _this2.updateDataByString(data, value);
134        }
135      });
136    }
137  }, {
138    key: 'addActionBind',
139    value: function addActionBind(ele) {
140      var _this3 = this;
141
142      (0, _util.on)(ele, dataAction, eventType, function (e) {
143        var target = e.delegateTarget;
144        var events = eventType.split(' ');
145        var action = 'action';
146        events.forEach(function (event) {
147          if (target.getAttribute('data-action-' + event)) {
148            if (e.type === event) {
149              action += '-' + event;
150            }
151          }
152        });
153        var string = target.getAttribute('data-' + action);
154        if (!string) {
155          return;
156        }
157        var method = string.replace(/\(.*?\);?/, '');
158        var parameter = string.replace(/(.*?)\((.*?)\);?/, '$2');
159        var pts = parameter.split(','); // 引き数
160        _this3.e = e;
161        if (_this3.method && _this3.method[method]) {
162          var _method;
163
164          (_method = _this3.method)[method].apply(_method, _toConsumableArray(pts));
165        } else if (_this3[method]) {
166          _this3[method].apply(_this3, _toConsumableArray(pts));
167        }
168      });
169    }
170  }, {
171    key: 'addTemplate',
172    value: function addTemplate(id, html) {
173      this.atemplate.push({ id: id, html: html, binded: false });
174      this.templates.push(id);
175    }
176
177    // loadHtml() {
178    //   const templates = this.templates;
179    //   const promises = [];
180    //   templates.forEach((template) => {
181    //     const d = new $.Deferred();
182    //     promises.push(d);
183    //     const src = selector(`#${template}`).getAttribute('src');
184    //     $.ajax({
185    //       url: src,
186    //       type: 'GET',
187    //       dataType: 'text'
188    //     }).success((data) => {
189    //       selector(`#${template}`).innerHTML = data;
190    //       d.resolve();
191    //     });
192    //   });
193    //   return $.when(...promises);
194    // }
195
196  }, {
197    key: 'getData',
198    value: function getData() {
199      return JSON.parse(JSON.stringify(this.data));
200    }
201  }, {
202    key: 'saveData',
203    value: function saveData(key) {
204      var data = JSON.stringify(this.data);
205      localStorage.setItem(key, data);
206    }
207  }, {
208    key: 'setData',
209    value: function setData(opt) {
210      var _this4 = this;
211
212      Object.keys(opt).forEach(function (key) {
213        if (typeof opt[key] !== 'function') {
214          _this4.data[key] = opt[key];
215        }
216      });
217    }
218  }, {
219    key: 'loadData',
220    value: function loadData(key) {
221      var data = JSON.parse(localStorage.getItem(key));
222      if (data) {
223        this.setData(data);
224      }
225    }
226  }, {
227    key: 'getRand',
228    value: function getRand(a, b) {
229      return ~~(Math.random() * (b - a + 1)) + a;
230    }
231  }, {
232    key: 'getRandText',
233    value: function getRandText(limit) {
234      var ret = '';
235      var strings = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
236      var length = strings.length;
237      for (var i = 0; i < limit; i += 1) {
238        ret += strings.charAt(Math.floor(this.getRand(0, length)));
239      }
240      return ret;
241    }
242  }, {
243    key: 'getDataFromObj',
244    value: function getDataFromObj(s, o) {
245      s = s.replace(/\[([\w\-\.ぁ-んァ-ヶ亜-熙]+)\]/g, '.$1'); // convert indexes to properties
246      s = s.replace(/^\./, ''); // strip leading dot
247      var a = s.split('.');
248      while (a.length) {
249        var n = a.shift();
250        if (n in o) {
251          o = o[n];
252        } else {
253          return null;
254        }
255      }
256      return o;
257    }
258  }, {
259    key: 'getDataByString',
260    value: function getDataByString(s) {
261      var o = this.data;
262      return this.getDataFromObj(s, o);
263    }
264  }, {
265    key: 'updateDataByString',
266    value: function updateDataByString(path, newValue) {
267      var object = this.data;
268      var stack = path.split('.');
269      while (stack.length > 1) {
270        object = object[stack.shift()];
271      }
272      object[stack.shift()] = newValue;
273    }
274  }, {
275    key: 'removeDataByString',
276    value: function removeDataByString(path) {
277      var object = this.data;
278      var stack = path.split('.');
279      while (stack.length > 1) {
280        object = object[stack.shift()];
281      }
282      var shift = stack.shift();
283      if (shift.match(/^\d+$/)) {
284        object.splice(Number(shift), 1);
285      } else {
286        delete object[shift];
287      }
288    }
289  }, {
290    key: 'resolveBlock',
291    value: function resolveBlock(html, item, i) {
292      var that = this;
293      var touchs = html.match(/<!-- BEGIN ([\w\-\.ぁ-んァ-ヶ亜-熙]+):touch#([\w\-\.ぁ-んァ-ヶ亜-熙]+) -->/g);
294      var touchnots = html.match(/<!-- BEGIN ([\w\-\.ぁ-んァ-ヶ亜-熙]+):touchnot#([\w\-\.ぁ-んァ-ヶ亜-熙]+) -->/g);
295      var exists = html.match(/<!-- BEGIN ([\w\-\.ぁ-んァ-ヶ亜-熙]+):exist -->/g);
296      var empties = html.match(/<!-- BEGIN ([\w\-\.ぁ-んァ-ヶ亜-熙]+):empty -->/g);
297      /* タッチブロック解決*/
298      if (touchs) {
299        for (var k = 0, n = touchs.length; k < n; k += 1) {
300          var start = touchs[k];
301          start = start.replace(/([\w\-\.ぁ-んァ-ヶ亜-熙]+):touch#([\w\-\.ぁ-んァ-ヶ亜-熙]+)/, '($1):touch#($2)');
302          var end = start.replace(/BEGIN/, 'END');
303          var reg = new RegExp(start + '(([\\n\\r\\t]|.)*?)' + end, 'g');
304          html = html.replace(reg, function (m, key2, val, next) {
305            var itemkey = typeof item[key2] === 'function' ? item[key2].apply(that) : that.getDataFromObj(key2, item);
306            if ('' + itemkey === val) {
307              return next;
308            }
309            return '';
310          });
311        }
312      }
313      /* タッチノットブロック解決*/
314      if (touchnots) {
315        for (var _k = 0, _n = touchnots.length; _k < _n; _k += 1) {
316          var _start = touchnots[_k];
317          _start = _start.replace(/([\w\-\.ぁ-んァ-ヶ亜-熙]+):touchnot#([\w\-\.ぁ-んァ-ヶ亜-熙]+)/, '($1):touchnot#($2)');
318          var _end = _start.replace(/BEGIN/, 'END');
319          var _reg = new RegExp(_start + '(([\\n\\r\\t]|.)*?)' + _end, 'g');
320          html = html.replace(_reg, function (m, key2, val, next) {
321            var itemkey = typeof item[key2] === 'function' ? item[key2].apply(that) : that.getDataFromObj(key2, item);
322            if ('' + itemkey !== val) {
323              return next;
324            }
325            return '';
326          });
327        }
328      }
329      /* existブロックを解決*/
330      if (exists) {
331        for (var _k2 = 0, _n2 = exists.length; _k2 < _n2; _k2 += 1) {
332          var _start2 = exists[_k2];
333          _start2 = _start2.replace(/([\w\-\.ぁ-んァ-ヶ亜-熙]+):exist/, '($1):exist');
334          var _end2 = _start2.replace(/BEGIN/, 'END');
335          var _reg2 = new RegExp(_start2 + '(([\\n\\r\\t]|.)*?)' + _end2, 'g');
336          html = html.replace(_reg2, function (m, key2, next) {
337            var itemkey = typeof item[key2] === 'function' ? item[key2].apply(that) : that.getDataFromObj(key2, item);
338            if (itemkey || itemkey === 0) {
339              return next;
340            }
341            return '';
342          });
343        }
344      }
345      /* emptyブロックを解決*/
346      if (empties) {
347        for (var _k3 = 0, _n3 = empties.length;
347 _k3 < _n3; _k3 += 1) {
348          var _start3 = empties[_k3];
349          _start3 = _start3.replace(/([\w\-\.ぁ-んァ-ヶ亜-熙]+):empty/, '($1):empty');
350          var _end3 = _start3.replace(/BEGIN/, 'END');
351          var empty = new RegExp(_start3 + '(([\\n\\r\\t]|.)*?)' + _end3, 'g');
352          html = html.replace(empty, function (m, key2, next) {
353            var itemkey = typeof item[key2] === 'function' ? item[key2].apply(that) : that.getDataFromObj(key2, item);
354            if (!itemkey && itemkey !== 0) {
355              return next;
356            }
357            return '';
358          });
359        }
360      }
361      /* 変数解決*/
362      html = html.replace(/{([\w\-\.ぁ-んァ-ヶ亜-熙]+)}(\[([\w\-\.ぁ-んァ-ヶ亜-熙]+)\])*/g, function (n, key3, key4, converter) {
363        var data = void 0;
364        if ('' + key3 === 'i') {
365          data = i;
366        } else if (item[key3] || item[key3] === 0) {
367          if (typeof item[key3] === 'function') {
368            data = item[key3].apply(that);
369          } else {
370            data = item[key3];
371          }
372        } else {
373          if (converter && that.convert && that.convert[converter]) {
374            return that.convert[converter].call(that, '');
375          }
376          return '';
377        }
378        if (converter && that.convert && that.convert[converter]) {
379          return that.convert[converter].call(that, data);
380        }
381        return data;
382      });
383      return html;
384    }
385    /* 絶対パス形式の変数を解決*/
386
387  }, {
388    key: 'resolveAbsBlock',
389    value: function resolveAbsBlock(html) {
390      var that = this;
391      html = html.replace(/{(.*?)}/g, function (n, key3) {
392        var data = that.getDataByString(key3);
393        if (typeof data !== 'undefined') {
394          if (typeof data === 'function') {
395            return data.apply(that);
396          }
397          return data;
398        }
399        return n;
400      });
401      return html;
402    }
403  }, {
404    key: 'resolveInclude',
405    value: function resolveInclude(html) {
406      var include = /<!-- #include id="(.*?)" -->/g;
407      html = html.replace(include, function (m, key) {
408        return (0, _util.selector)('#' + key).innerHTML;
409      });
410      return html;
411    }
412  }, {
413    key: 'resolveWith',
414    value: function resolveWith(html) {
415      var width = /<!-- BEGIN ([\w\-\.ぁ-んァ-ヶ亜-熙]+):with -->(([\n\r\t]|.)*?)<!-- END ([\w\-\.ぁ-んァ-ヶ亜-熙]+):with -->/g;
416      html = html.replace(width, function (m, key) {
417        m = m.replace(/data\-bind=['"](.*?)['"]/g, 'data-bind=\'' + key + '.$1\'');
418        return m;
419      });
420      return html;
421    }
422  }, {
423    key: 'resolveLoop',
424    value: function resolveLoop(html) {
425      var loop = /<!-- BEGIN ([\w\-\.ぁ-んァ-ヶ亜-熙]+?):loop -->(([\n\r\t]|.)*?)<!-- END ([\w\-\.ぁ-んァ-ヶ亜-熙]+?):loop -->/g;
426      var that = this;
427      /* ループ文解決*/
428      html = html.replace(loop, function (m, key, val) {
429        var keyItem = that.getDataByString(key);
430        var keys = [];
431        if (typeof keyItem === 'function') {
432          keys = keyItem.apply(that);
433        } else {
434          keys = keyItem;
435        }
436        var ret = '';
437        if (keys instanceof Array) {
438          for (var i = 0, n = keys.length; i < n; i += 1) {
439            ret += that.resolveBlock(val, keys[i], i);
440          }
441        }
442        /* エスケープ削除*/
443        ret = ret.replace(/\\([^\\])/g, '$1');
444        return ret;
445      });
446      return html;
447    }
448  }, {
449    key: 'removeData',
450    value: function removeData(arr) {
451      var data = this.data;
452      Object.keys(data).forEach(function (i) {
453        for (var t = 0, n = arr.length; t < n; t += 1) {
454          if (i === arr[t]) {
455            delete data[i];
456          }
457        }
458      });
459      return this;
460    }
461  }, {
462    key: 'hasLoop',
463    value: function hasLoop(txt) {
464      var loop = /<!-- BEGIN ([\w\-\.ぁ-んァ-ヶ亜-熙]+?):loop -->(([\n\r\t]|.)*?)<!-- END ([\w\-\.ぁ-んァ-ヶ亜-熙]+?):loop -->/g;
465      if (txt.match(loop)) {
466        return true;
467      }
468      return false;
469    }
470  }, {
471    key: 'getHtml',
472    value: function getHtml(query, row) {
473      var template = this.atemplate.find(function (item) {
474        return item.id === query;
475      });
476      var html = '';
477      if (template && template.html) {
478        html = template.html;
479      }
480      if (row) {
481        html = query;
482      }
483      if (!html) {
484        return '';
485      }
486      var data = this.data;
487      /* インクルード解決*/
488      html = this.resolveInclude(html);
489      /* with解決*/
490      html = this.resolveWith(html);
491      /* ループ解決*/
492      while (this.hasLoop(html)) {
493        html = this.resolveLoop(html);
494      }
495      /* 変数解決*/
496      html = this.resolveBlock(html, data);
497      /* エスケープ削除*/
498      html = html.replace(/\\([^\\])/g, '$1');
499      /* 絶対パスで指定された変数を解決*/
500      html = this.resolveAbsBlock(html);
501      /* 空行削除*/
502      return html.replace(/^([\t ])*\n/gm, '');
503    }
504  }, {
505    key: 'update',
506    value: function update() {
507      var _this5 = this;
508
509      var renderWay = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'html';
510      var part = arguments[1];
511
512      var templates = this.templates;
513      if (this.beforeUpdated) {
514        this.beforeUpdated();
515      }
516
517      var _loop = function _loop(i, n) {
518        var tem = templates[i];
519        var query = '#' + tem;
520        var html = _this5.getHtml(tem);
521        var target = (0, _util.selector)('[data-id=\'' + tem + '\']');
522        if (!target) {
523          (0, _util.selector)(query).insertAdjacentHTML('afterend', '<div data-id="' + tem + '"></div>');
524          if (renderWay === 'text') {
525            (0, _util.selector)('[data-id=\'' + tem + '\']').innerText = html;
526          } else {
527            (0, _util.selector)('[data-id=\'' + tem + '\']').innerHTML = html;
528          }
529        } else if (renderWay === 'text') {
530          target.innerText = html;
531        } else if (part) {
532          var doc = document.createElement('div');
533          doc.innerHTML = html;
534          var partHtml = doc.querySelector(part).outerHTML;
535          (0, _morphdom2.default)(target.querySelector(part), partHtml);
536        } else {
537          (0, _morphdom2.default)(target, '<div data-id=\'' + tem + '\'>' + html + '</div>');
538        }
539        var template = _this5.atemplate.find(function (item) {
540          return item.id === tem;
541        });
542        if (!template.binded) {
543          template.binded = true;
544          _this5.addDataBind((0, _util.selector)('[data-id=\'' + tem + '\']'));
545          _this5.addActionBind((0, _util.selector)('[data-id=\'' + tem + '\']'));
546        }
547      };
548
549      for (var i = 0, n = templates.length; i < n; i += 1) {
550        _loop(i, n);
551      }
552      this.updateBindingData(part);
553      if (this.onUpdated) {
554        this.onUpdated(part);
555      }
556      return this;
557    }
558  }, {
559    key: 'updateBindingData',
560    value: function updateBindingData(part) {
561      var _this6 = this;
562
563      var templates = this.templates;
564      for (var i = 0, n = templates.length; i < n; i += 1) {
565        var temp = templates[i];
566        var _template = (0, _util.selector)('[data-id=\'' + temp + '\']');
567        if (part) {
568          _template = _template.querySelector(part);
569        }
570        var binds = _template.querySelectorAll('[data-bind]');
571        [].forEach.call(binds, function (item) {
572          var data = _this6.getDataByString(item.getAttribute('data-bind'));
573          if (item.getAttribute('type') === 'checkbox' || item.getAttribute('type') === 'radio') {
574            if (data === item.value) {
575              item.checked = true;
576            }
577          } else {
578            // if(item !== document.activeElement) {
579            item.value = data;
580            // }
581          }
582        });
583        var onewaybinds = _template.querySelectorAll('[data-bind-oneway]');
584        [].forEach.call(onewaybinds, function (item) {
585          var data = _this6.getDataByString(item.getAttribute('data-bind-oneway'));
586          if (item.getAttribute('type') === 'checkbox' || item.getAttribute('type') === 'radio') {
587            if (data === item.value) {
588              item.checked = true;
589            }
590          } else {
591            // if(item !== document.activeElement) {
592            item.value = data;
593            // }
594          }
595        });
596      }
597      return this;
598    }
599  }, {
600    key: 'applyMethod',
601    value: function applyMethod(method) {
602      var _method2;
603
604      for (var _len = arguments.length, args = Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
605        args[_key - 1] = arguments[_key];
606      }
607
608      return (_method2 = this.method)[method].apply(_method2, args);
609    }
610  }, {
611    key: 'getComputedProp',
612    value: function getComputedProp(prop) {
613      return this.data[prop].apply(this);
614    }
615  }, {
616    key: 'remove',
617    value: function remove(path) {
618      var object = this.data;
619      var stack = path.split('.');
620      while (stack.length > 1) {
621        object = object[stack.shift()];
622      }
623      var shift = stack.shift();
624      if (shift.match(/^\d+$/)) {
625        object.splice(Number(shift), 1);
626      } else {
627        delete object[shift];
628      }
629      return this;
630    }
631  }]);
632
633  return aTemplate;
634}();
635
636exports.default = aTemplate;
637module.exports = exports['default'];
638},{"./util":2,"ie-array-find-polyfill":5,"morphdom":6}],2:[function(require,module,exports){
639'use strict';
640
641Object.defineProperty(exports, "__esModule", {
642  value: true
643});
644var matches = exports.matches = function matches(element, query) {
645  var matches = (element.document || element.ownerDocument).querySelectorAll(query);
646  var i = matches.length;
647  while (--i >= 0 && matches.item(i) !== element) {}
648  return i > -1;
649};
650
651var selector = exports.selector = function selector(_selector) {
652  return document.querySelector(_selector);
653};
654
655var findAncestor = exports.findAncestor = function findAncestor(element, selector) {
656  if (typeof element.closest === 'function') {
657    return element.closest(selector) || null;
658  }
659  while (element && element !== document) {
660    if (matches(element, selector)) {
661      return element;
662    }
663    element = element.parentElement;
664  }
665  return null;
666};
667
668var on = exports.on = function on(element, query, eventNames, fn) {
669  var events = eventNames.split(' ');
670  events.forEach(function (event) {
671    element.addEventListener(event, function (e) {
672      var target = e.target;
673      var delegateTarget = findAncestor(e.target, query);
674      if (delegateTarget) {
675        e.delegateTarget = delegateTarget;
676        fn(e);
677      }
678    });
679  });
680};
681},{}],3:[function(require,module,exports){
682// Polyfill for creating CustomEvents on IE9/10/11
683
684// code pulled from:
685// https://github.com/d4tocchini/customevent-polyfill
686// https://developer.mozilla.org/en-US/docs/Web/API/CustomEvent#Polyfill
687
688try {
689    var ce = new window.CustomEvent('test');
690    ce.preventDefault();
691    if (ce.defaultPrevented !== true) {
692        // IE has problems with .preventDefault() on custom events
693        // http://stackoverflow.com/questions/23349191
694        throw new Error('Could not prevent default');
695    }
696} catch(e) {
697  var CustomEvent = function(event, params) {
698    var evt, origPrevent;
699    params = params || {
700      bubbles: false,
701      cancelable: false,
702      detail: undefined
703    };
704
705    evt = document.createEvent("CustomEvent");
706    evt.initCustomEvent(event, params.bubbles, params.cancelable, params.detail);
707    origPrevent = evt.preventDefault;
708    evt.preventDefault = function () {
709      origPrevent.call(this);
710      try {
711        Object.defineProperty(this, 'defaultPrevented', {
712          get: function () {
713            return true;
714          }
715        });
716      } catch(e) {
717        this.defaultPrevented = true;
718      }
719    };
720    return evt;
721  };
722
723  CustomEvent.prototype = window.Event.prototype;
724  window.CustomEvent = CustomEvent; // expose definition to window
725}
726
727},{}],4:[function(require,module,exports){
728(function (global,setImmediate){
729(function(global){
730
731//
732// Check for native Promise and it has correct interface
733//
734
735var NativePromise = global['Promise'];
736var nativePromiseSupported =
737  NativePromise &&
738  // Some of these methods are missing from
739  // Firefox/Chrome experimental implementations
740  'resolve' in NativePromise &&
741  'reject' in NativePromise &&
742  'all' in NativePromise &&
743  'race' in NativePromise &&
744  // Older version of the spec had a resolver object
745  // as the arg rather than a function
746  (function(){
747    var resolve;
748    new NativePromise(function(r){ resolve = r; });
749    return typeof resolve === 'function';
750  })();
751
752
753//
754// export if necessary
755//
756
757if (typeof exports !== 'undefined' && exports)
758{
759  // node.js
760  exports.Promise = nativePromiseSupported ? NativePromise : Promise;
761  exports.Polyfill = Promise;
762}
763else
764{
765  // AMD
766  if (typeof define == 'function' && define.amd)
767  {
768    define(function(){
769      return nativePromiseSupported ? NativePromise : Promise;
770    });
771  }
772  else
773  {
774    // in browser add to global
775    if (!nativePromiseSupported)
776      global['Promise'] = Promise;
777  }
778}
779
780
781//
782// Polyfill
783//
784
785var PENDING = 'pending';
786var SEALED = 'sealed';
787var FULFILLED = 'fulfilled';
788var REJECTED = 'rejected';
789var NOOP = function(){};
790
791function isArray(value) {
792  return Object.prototype.toString.call(value) === '[object Array]';
793}
794
795// async calls
796var asyncSetTimer = typeof setImmediate !== 'undefined' ? setImmediate : setTimeout;
797var asyncQueue = [];
798var asyncTimer;
799
800function asyncFlush(){
801  // run promise callbacks
802  for (var i = 0; i < asyncQueue.length; i++)
803    asyncQueue[i][0](asyncQueue[i][1]);
804
805  // reset async asyncQueue
806  asyncQueue = [];
807  asyncTimer = false;
808}
809
810function asyncCall(callback, arg){
811  asyncQueue.push([callback, arg]);
812
813  if (!asyncTimer)
814  {
815    asyncTimer = true;
816    asyncSetTimer(asyncFlush, 0);
817  }
818}
819
820
821function invokeResolver(resolver, promise) {
822  function resolvePromise(value) {
823    resolve(promise, value);
824  }
825
826  function rejectPromise(reason) {
827    reject(promise, reason);
828  }
829
830  try {
831    resolver(resolvePromise, rejectPromise);
832  } catch(e) {
833    rejectPromise(e);
834  }
835}
836
837function invokeCallback(subscriber){
838  var owner = subscriber.owner;
839  var settled = owner.state_;
840  var value = owner.data_;  
841  var callback = subscriber[settled];
842  var promise = subscriber.then;
843
844  if (typeof callback === 'function')
845  {
846    settled = FULFILLED;
847    try {
848      value = callback(value);
849    } catch(e) {
850      reject(promise, e);
851    }
852  }
853
854  if (!handleThenable(promise, value))
855  {
856    if (settled === FULFILLED)
857      resolve(promise, value);
858
859    if (settled === REJECTED)
860      reject(promise, value);
861  }
862}
863
864function handleThenable(promise, value) {
865  var resolved;
866
867  try {
868    if (promise === value)
869      throw new TypeError('A promises callback cannot return that same promise.');
870
871    if (value && (typeof value === 'function' || typeof value === 'object'))
872    {
873      var then = value.then;  // then should be retrived only once
874
875      if (typeof then === 'function')
876      {
877        then.call(value, function(val){
878          if (!resolved)
879          {
880            resolved = true;
881
882            if (value !== val)
883              resolve(promise, val);
884            else
885              fulfill(promise, val);
886          }
887        }, function(reason){
888          if (!resolved)
889          {
890            resolved = true;
891
892            reject(promise, reason);
893          }
894        });
895
896        return true;
897      }
898    }
899  } catch (e) {
900    if (!resolved)
901      reject(promise, e);
902
903    return true;
904  }
905
906  return false;
vendor: 1,148 bytes, lines 907-961
907}
908
909function resolve(promise, value){
910  if (promise === value || !handleThenable(promise, value))
911    fulfill(promise, value);
912}
913
914function fulfill(promise, value){
915  if (promise.state_ === PENDING)
916  {
917    promise.state_ = SEALED;
918    promise.data_ = value;
919
920    asyncCall(publishFulfillment, promise);
921  }
922}
923
924function reject(promise, reason){
925  if (promise.state_ === PENDING)
926  {
927    promise.state_ = SEALED;
928    promise.data_ = reason;
929
930    asyncCall(publishRejection, promise);
931  }
932}
933
934function publish(promise) {
935  var callbacks = promise.then_;
936  promise.then_ = undefined;
937
938  for (var i = 0; i < callbacks.length; i++) {
939    invokeCallback(callbacks[i]);
940  }
941}
942
943function publishFulfillment(promise){
944  promise.state_ = FULFILLED;
945  publish(promise);
946}
947
948function publishRejection(promise){
949  promise.state_ = REJECTED;
950  publish(promise);
951}
952
953/**
954* @class
955*/
956function Promise(resolver){
957  if (typeof resolver !== 'function')
958    throw new TypeError('Promise constructor takes a function argument');
959
960  if (this instanceof Promise === false)
961    throw new TypeError('Failed to construct \'Promise\': Please use the \'new\' operator, this object c
961onstructor cannot be called as a function.');
962
963  this.then_ = [];
964
965  invokeResolver(resolver, this);
966}
967
968Promise.prototype = {
969  constructor: Promise,
970
971  state_: PENDING,
972  then_: null,
973  data_: undefined,
974
975  then: function(onFulfillment, onRejection){
976    var subscriber = {
977      owner: this,
978      then: new this.constructor(NOOP),
979      fulfilled: onFulfillment,
980      rejected: onRejection
981    };
982
983    if (this.state_ === FULFILLED || this.state_ === REJECTED)
984    {
985      // already resolved, call callback async
986      asyncCall(invokeCallback, subscriber);
987    }
988    else
989    {
990      // subscribe
991      this.then_.push(subscriber);
992    }
993
994    return subscriber.then;
995  },
996
997  'catch': function(onRejection) {
998    return this.then(null, onRejection);
999  }
1000};
1001
1002Promise.all = function(promises){
1003  var Class = this;
1004
1005  if (!isArray(promises))
1006    throw new TypeError('You must pass an array to Promise.all().');
1007
1008  return new Class(function(resolve, reject){
1009    var results = [];
1010    var remaining = 0;
1011
1012    function resolver(index){
1013      remaining++;
1014      return function(value){
1015        results[index] = value;
1016        if (!--remaining)
1017          resolve(results);
1018      };
1019    }
1020
1021    for (var i = 0, promise; i < promises.length; i++)
1022    {
1023      promise = promises[i];
1024
1025      if (promise && typeof promise.then === 'function')
1026        promise.then(resolver(i), reject);
1027      else
1028        results[i] = promise;
1029    }
1030
1031    if (!remaining)
1032      resolve(results);
1033  });
1034};
1035
1036Promise.race = function(promises){
1037  var Class = this;
1038
1039  if (!isArray(promises))
1040    throw new TypeError('You must pass an array to Promise.race().');
1041
1042  return new Class(function(resolve, reject) {
1043    for (var i = 0, promise; i < promises.length; i++)
1044    {
1045      promise = promises[i];
1046
1047      if (promise && typeof promise.then === 'function')
1048        promise.then(resolve, reject);
1049      else
1050        resolve(promise);
1051    }
1052  });
1053};
1054
1055Promise.resolve = function(value){
1056  var Class = this;
1057
1058  if (value && typeof value === 'object' && value.constructor === Class)
1059    return value;
1060
1061  return new Class(function(resolve){
1062    resolve(value);
1063  });
1064};
1065
1066Promise.reject = function(reason){
1067  var Class = this;
1068
1069  return new Class(function(resolve, reject){
1070    reject(reason);
1071  });
1072};
1073
1074})(typeof window != 'undefined' ? window : typeof global != 'undefined' ? global : typeof self != 'undefined' ? self : this);
1075
1076}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {},require("timers").setImmediate)
1077},{"timers":8}],5:[function(require,module,exports){
1078'use strict';
1079if (!Array.prototype.find) {
1080    Object.defineProperty(Array.prototype, 'find', {
1081        value: function (predicate) {
1082
1083            if (this == null) {
1084                throw new TypeError('this is null or not defined');
1085            }
1086
1087            var obj = Object(this);
1088            var len = obj.length >>> 0;
1089
1090            if (typeof predicate !== 'function') {
1091                throw new TypeError('predicate must be a function');
1092            }
1093
1094            var thisArg = arguments[1];
1095
1096            var index = 0;
1097
1098            while (index < len) {
1099                var iValue = obj[index];
1100                if (predicate.call(thisArg, iValue, index, obj)) {
1101                    return iValue;
1102                }
1103                index++;
1104            }
1105
1106            return undefined;
1107        }
1108    });
1109}
1110},{}],6:[function(require,module,exports){
1111'use strict';
1112
1113var range; // Create a range object for efficently rendering strings to elements.
1114var NS_XHTML = 'http://www.w3.org/1999/xhtml';
1115
1116var doc = typeof document === 'undefined' ? undefined : document;
1117
1118var testEl = doc ?
1119    doc.body || doc.createElement('div') :
1120    {};
1121
1122// Fixes <https://github.com/patrick-steele-idem/morphdom/issues/32>
1123// (IE7+ support) <=IE7 does not support el.hasAttribute(name)
1124var actualHasAttributeNS;
1125
1126if (testEl.hasAttributeNS) {
1127    actualHasAttributeNS = function(el, namespaceURI, name) {
1128        return el.hasAttributeNS(namespaceURI, name);
1129    };
1130} else if (testEl.hasAttribute) {
1131    actualHasAttributeNS = function(el, namespaceURI, name) {
1132        return el.hasAttribute(name);
1133    };
1134} else {
1135    actualHasAttributeNS = function(el, namespaceURI, name) {
1136        return el.getAttributeNode(namespaceURI, name) != null;
1137    };
1138}
1139
1140var hasAttributeNS = actualHasAttributeNS;
1141
1142
1143function toElement(str) {
1144    if (!range && doc.createRange) {
1145        range = doc.createRange();
1146        range.selectNode(doc.body);
1147    }
1148
1149    var fragment;
1150    if (range && range.createContextualFragment) {
1151        fragment = range.createContextualFragment(str);
1152    } else {
1153        fragment = doc.createElement('body');
1154        fragment.innerHTML = str;
1155    }
1156    return fragment.childNodes[0];
1157}
1158
1159/**
1160 * Returns true if two node's names are the same.
1161 *
1162 * NOTE: We don't bother checking `namespaceURI` because you will never find two HTML elements with the same
1163 *       nodeName and different namespace URIs.
1164 *
1165 * @param {Element} a
1166 * @param {Element} b The target element
1167 * @return {boolean}
1168 */
1169function compareNodeNames(fromEl, toEl) {
1170    var fromNodeName = fromEl.nodeName;
1171    var toNodeName = toEl.nodeName;
1172
1173    if (fromNodeName === toNodeName) {
1174        return true;
1175    }
1176
1177    if (toEl.actualize &&
1178        fromNodeName.charCodeAt(0) < 91 && /* from tag name is upper case */
1179        toNodeName.charCodeAt(0) > 90 /* target tag name is lower case */) {
1180        // If the target element is a virtual DOM node then we may need to normalize the tag name
1181        // before comparing. Normal HTML elements that are in the "http://www.w3.org/1999/xhtml"
1182        // are converted to upper case
1183        return fromNodeName === toNodeName.toUpperCase();
1184    } else {
1185        return false;
1186    }
1187}
1188
1189/**
1190 * Create an element, optionally with a known namespace URI.
1191 *
1192 * @param {string} name the element name, e.g. 'div' or 'svg'
1193 * @param {string} [namespaceURI] the element's namespace URI, i.e. the value of
1194 * its `xmlns` attribute or its inferred namespace.
1195 *
1196 * @return {Element}
1197 */
1198function createElementNS(name, namespaceURI) {
1199    return !namespaceURI || namespaceURI === NS_XHTML ?
1200        doc.createElement(name) :
1201        doc.createElementNS(namespaceURI, name);
1202}
1203
1204/**
1205 * Copies the children of one DOM element to another DOM element
1206 */
1207function moveChildren(fromEl, toEl) {
1208    var curChild = fromEl.firstChild;
1209    while (curChild) {
1210        var nextChild = curChild.nextSibling;
1211        toEl.appendChild(curChild);
1212        curChild = nextChild;
1213    }
1214    return toEl;
1215}
1216
1217function morphAttrs(fromNode, toNode) {
1218    var attrs = toNode.attributes;
1219    var i;
1220    var attr;
1221    var attrName;
1222    var attrNamespaceURI;
1223    var attrValue;
1224    var fromValue;
1225
1226    for (i = attrs.length - 1; i >= 0; --i) {
1227        attr = attrs[i];
1228        attrName = attr.name;
1229        attrNamespaceURI = attr.namespaceURI;
1230        attrValue = attr.value;
1231
1232        if (attrNamespaceURI) {
1233            attrName = attr.localName || attrName;
1234            fromValue = fromNode.getAttributeNS(attrNamespaceURI, attrName);
1235
1236            if (fromValue !== attrValue) {
1237                fromNode.setAttributeNS(attrNamespaceURI, attrName, attrValue);
1238            }
1239        } else {
1240            fromValue = fromNode.getAttribute(attrName);
1241
1242            if (fromValue !== attrValue) {
1243                fromNode.setAttribute(attrName, attrValue);
1244            }
1245        }
1246    }
1247
1248    // Remove any extra attributes found on the original DOM element that
1249    // weren't found on the target element.
1250    attrs = fromNode.attributes;
1251
1252    for (i = attrs.length - 1; i >= 0; --i) {
1253        attr = attrs[i];
1254        if (attr.specified !== false) {
1255            attrName = attr.name;
1256            attrNamespaceURI = attr.namespaceURI;
1257
1258            if (attrNamespaceURI) {
1259                attrName = attr.localName || attrName;
1260
1261                if (!hasAttributeNS(toNode, attrNamespaceURI, attrName)) {
1262                    fromNode.removeAttributeNS(attrNamespaceURI, attrName);
1263                }
1264            } else {
1265                if (!hasAttributeNS(toNode, null, attrName)) {
1266                    fromNode.removeAttribute(attrName);
1267                }
1268            }
1269        }
1270    }
1271}
1272
1273function syncBooleanAttrProp(fromEl, toEl, name) {
1274    if (fromEl[name] !== toEl[name]) {
1275        fromEl[name] = toEl[name];
1276        if (fromEl[name]) {
1277            fromEl.setAttribute(name, '');
1278        } else {
1279            fromEl.removeAttribute(name, '');
1280        }
1281    }
1282}
1283
1284var specialElHandlers = {
1285    /**
1286     * Needed for IE. Apparently IE doesn't think that "selected" is an
1287     * attribute when reading over the attributes using selectEl.attributes
1288     */
1289    OPTION: function(fromEl, toEl) {
1290        syncBooleanAttrProp(fromEl, toEl, 'selected');
1291    },
1292    /**
1293     * The "value" attribute is special for the <input> element since it sets
1294     * the initial value. Changing the "value" attribute without changing the
1295     * "value" property will have no effect since it is only used to the set the
1296     * initial value.  Similar for the "checked" attribute, and "disabled".
1297     */
1298    INPUT: function(fromEl, toEl) {
1299        syncBooleanAttrProp(fromEl, toEl, 'checked');
1300        syncBooleanAttrProp(fromEl, toEl, 'disabled');
1301
1302        if (fromEl.value !== toEl.value) {
1303            fromEl.value = toEl.value;
1304        }
1305
1306        if (!hasAttributeNS(toEl, null, 'value')) {
1307            fromEl.removeAttribute('value');
1308        }
1309    },
1310
1311    TEXTAREA: function(fromEl, toEl) {
1312        var newValue = toEl.value;
1313        if (fromEl.value !== newValue) {
1314            fromEl.value = newValue;
1315        }
1316
1317        var firstChild = fromEl.firstChild;
1318        if (firstChild) {
1319            // Needed for IE. Apparently IE sets the placeholder as the
1320            // node value and vise versa. This ignores an empty update.
1321            var oldValue = firstChild.nodeValue;
1322
1323            if (oldValue == newValue || (!newValue && oldValue == fromEl.placeholder)) {
1324                return;
1325            }
1326
1327            firstChild.nodeValue = newValue;
1328        }
1329    },
1330    SELECT: function(fromEl, toEl) {
1331        if (!hasAttributeNS(toEl, null, 'multiple')) {
1332            var selectedIndex = -1;
1333            var i = 0;
1334            var curChild = toEl.firstChild;
1335            while(curChild) {
1336                var nodeName = curChild.nodeName;
1337                if (nodeName && nodeName.toUpperCase() === 'OPTION') {
1338                    if (hasAttributeNS(curChild, null, 'selected')) {
1339                        selectedIndex = i;
1340                        break;
1341                    }
1342                    i++;
1343                }
1344                curChild = curChild.nextSibling;
1345            }
1346
1347            fromEl.selectedIndex = i;
1348        }
1349    }
1350};
1351
1352var ELEMENT_NODE = 1;
1353var TEXT_NODE = 3;
1354var COMMENT_NODE = 8;
1355
1356function noop() {}
1357
1358function defaultGetNodeKey(node) {
1359    return node.id;
1360}
1361
1362function morphdomFactory(morphAttrs) {
1363
1364    return function morphdom(fromNode, toNode, options) {
1365        if (!options) {
1366            options = {};
1367        }
1368
1369        if (typeof toNode === 'string') {
1370            if (fromNode.nodeName === '#document' || fromNode.nodeName === 'HTML') {
1371                var toNodeHtml = toNode;
1372                toNode = doc.createElement('html');
1373                toNode.innerHTML = toNodeHtml;
1374            } else {
1375                toNode = toElement(toNode);
1376            }
1377        }
1378
1379        var getNodeKey = options.getNodeKey || defaultGetNodeKey;
1380        var onBeforeNodeAdded = options.onBeforeNodeAdded || noop;
1381        var onNodeAdded = options.onNodeAdded || noop;
1382        var onBeforeElUpdated = options.onBeforeElUpdated || noop;
1383        var onElUpdated = options.onElUpdated || noop;
1384        var onBeforeNodeDiscarded = options.onBeforeNodeDiscarded || noop;
1385        var onNodeDiscarded = options.onNodeDiscarded || noop;
1386        var onBeforeElChildrenUpdated = options.onBeforeElChildrenUpdated || noop;
1387        var childrenOnly = options.childrenOnly === true;
1388
1389        // This object is used as a lookup to quickly find all keyed elements in the original DOM tree.
1390        var fromNodesLookup = {};
1391        var keyedRemovalList;
1392
1393        function addKeyedRemoval(key) {
1394            if (keyedRemovalList) {
1395                keyedRemovalList.push(key);
1396            } else {
1397                keyedRemovalList = [key];
1398            }
1399        }
1400
1401        function walkDiscardedChildNodes(node, skipKeyedNodes) {
1402            if (node.nodeType === ELEMENT_NODE) {
1403                var curChild = node.firstChild;
1404                while (curChild) {
1405
1406                    var key = undefined;
1407
1408                    if (skipKeyedNodes && (key = getNodeKey(curChild))) {
1409                        // If we are skipping keyed nodes then we add the key
1410                        // to a list so that it can be handled at the very end.
1411                        addKeyedRemoval(key);
1412                    } else {
1413                        // Only report the node as discarded if it is not keyed. We do this because
1414                        // at the end we loop through all keyed elements that were unmatched
1415                        // and then discard them in one final pass.
1416                        onNodeDiscarded(curChild);
1417                        if (curChild.firstChild) {
1418                            walkDiscardedChildNodes(curChild, skipKeyedNodes);
1419                        }
1420                    }
1421
1422                    curChild = curChild.nextSibling;
1423                }
1424            }
1425        }
1426
1427        /**
1428         * Removes a DOM node out of the original DOM
1429         *
1430         * @param  {Node} node The node to remove
1431         * @param  {Node} parentNode The nodes parent
1432         * @param  {Boolean} skipKeyedNodes If true then elements with keys will be skipped and not discarded.
1433         * @return {undefined}
1434         */
1435        function removeNode(node, parentNode, skipKeyedNodes) {
1436            if (onBeforeNodeDiscarded(node) === false) {
1437                return;
1438            }
1439
1440            if (parentNode) {
1441                parentNode.removeChild(node);
1442            }
1443
1444            onNodeDiscarded(node);
1445            walkDiscardedChildNodes(node, skipKeyedNodes);
1446        }
1447
1448        // // TreeWalker implementation is no faster, but keeping this around in case this changes in the future
1449        // function indexTree(root) {
1450        //     var treeWalker = document.createTreeWalker(
1451        //         root,
1452        //         NodeFilter.SHOW_ELEMENT);
1453        //
1454        //     var el;
1455        //     while((el = treeWalker.nextNode())) {
1456        //         var key = getNodeKey(el);
1457        //         if (key) {
1458        //             fromNodesLookup[key] = el;
1459        //         }
1460        //     }
1461        // }
1462
1463        // // NodeIterator implementation is no faster, but keeping this around in case this changes in the future
1464        //
1465        // function indexTree(node) {
1466        //     var nodeIterator = document.createNodeIterator(node, NodeFilter.SHOW_ELEMENT);
1467        //     var el;
1468        //     while((el = nodeIterator.nextNode())) {
1469        //         var key = getNodeKey(el);
1470        //         if (key) {
1471        //             fromNodesLookup[key] = el;
1472        //         }
1473        //     }
1474        // }
1475
1476        function indexTree(node) {
1477            if (node.nodeType === ELEMENT_NODE) {
1478                var curChild = node.firstChild;
1479                while (curChild) {
1480                    var key = getNodeKey(curChild);
1481                    if (key) {
1482                        fromNodesLookup[key] = curChild;
1483                    }
1484
1485                    // Walk recursively
1486                    indexTree(curChild);
1487
1488                    curChild = curChild.nextSibling;
1489                }
1490            }
1491        }
1492
1493        indexTree(fromNode);
1494
1495        function handleNodeAdded(el) {
1496            onNodeAdded(el);
1497
1498            var curChild = el.firstChild;
1499            while (curChild) {
1500                var nextSibling = curChild.nextSibling;
1501
1502                var key = getNodeKey(curChild);
1503                if (key) {
1504                    var unmatchedFromEl = fromNodesLookup[key];
1505                    if (unmatchedFromEl && compareNodeNames(curChild, unmatchedFromEl)) {
1506                        curChild.parentNode.replaceChild(unmatchedFromEl, curChild);
1507                        morphEl(unmatchedFromEl, curChild);
1508                    }
1509                }
1510
1511                handleNodeAdded(curChild);
1512                curChild = nextSibling;
1513            }
1514        }
1515
1516        function morphEl(fromEl, toEl, childrenOnly) {
1517            var toElKey = getNodeKey(toEl);
1518            var curFromNodeKey;
1519
1520            if (toElKey) {
1521                // If an element with an ID is being morphed then it is will be in the final
1522                // DOM so clear it out of the saved elements collection
1523                delete fromNodesLookup[toElKey];
1524            }
1525
1526            if (toNode.isSameNode && toNode.isSameNode(fromNode)) {
1527                return;
1528            }
1529
1530            if (!childrenOnly) {
1531                if (onBeforeElUpdated(fromEl, toEl) === false) {
1532                    return;
1533                }
1534
1535                morphAttrs(fromEl, toEl);
1536                onElUpdated(fromEl);
1537
1538                if (onBeforeElChildrenUpdated(fromEl, toEl) === false) {
1539                    return;
1540                }
1541            }
1542
1543            if (fromEl.nodeName !== 'TEXTAREA') {
1544                var curToNodeChild = toEl.firstChild;
1545                var curFromNodeChild = fromEl.firstChild;
1546                var curToNodeKey;
1547
1548                var fromNextSibling;
1549                var toNextSibling;
1550                var matchingFromEl;
1551
1552                outer: while (curToNodeChild) {
1553                    toNextSibling = curToNodeChild.nextSibling;
1554                    curToNodeKey = getNodeKey(curToNodeChild);
1555
1556                    while (curFromNodeChild) {
1557                        fromNextSibling = curFromNodeChild.nextSibling;
1558
1559                        if (curToNodeChild.isSameNode && curToNodeChild.isSameNode(curFromNodeChild)) {
1560                            curToNodeChild = toNextSibling;
1561                            curFromNodeChild = fromNextSibling;
1562                            continue outer;
1563                        }
1564
1565                        curFromNodeKey = getNodeKey(curFromNodeChild);
1566
1567                        var curFromNodeType = curFromNodeChild.nodeType;
1568
1569                        var isCompatible = undefined;
1570
1571                        if (curFromNodeType === curToNodeChild.nodeType) {
1572                            if (curFromNodeType === ELEMENT_NODE) {
1573                                // Both nodes being compared are Element nodes
1574
1575                                if (curToNodeKey) {
1576                                    // The target node has a key so we want to match it up with the correct element
1577                                    // in the original DOM tree
1578                                    if (curToNodeKey !== curFromNodeKey) {
1579                                        // The current element in the original DOM tree does not have a matching key so
1580                                        // let's check our lookup to see if there is a matching element in the original
1581                                        // DOM tree
1582                                        if ((matchingFromEl = fromNodesLookup[curToNodeKey])) {
1583                                            if (curFromNodeChild.nextSibling === matchingFromEl) {
1584                                                // Special case for single element removals. To avoid removing the original
1585                                                // DOM node out of the tree (since that can break CSS transitions, etc.),
1586                                                // we will instead discard the current node and wait until the next
1587                                                // iteration to properly match up the keyed target element with its matching
1588                                                // element in the original tree
1589                                                isCompatible = false;
1590                                            } else {
1591                                                // We found a matching keyed element somewhere in the original DOM tree.
1592                                                // Let's moving the original DOM node into the current position and morph
1593                                                // it.
1594
1595                                                // NOTE: We use insertBefore instead of replaceChild because we want to go through
1596                                                // the `removeNode()` function for the node that is being discarded so that
1597                                                // all lifecycle hooks are correctly invoked
1598                                                fromEl.insertBefore(matchingFromEl, curFromNodeChild);
1599
1600                                                fromNextSibling = curFromNodeChild.nextSibling;
1601
1602                                                if (curFromNodeKey) {
1603                                                    // Since the node is keyed it might be matched up later so we defer
1604                                                    // the actual removal to later
1605                                                    addKeyedRemoval(curFromNodeKey);
1606                                                } else {
1607                                                    // NOTE: we skip nested keyed nodes from being removed since there is
1608                                                    //       still a chance they will be matched up later
1609                                                    removeNode(curFromNodeChild, fromEl, true /* skip keyed nodes */);
1610                                                }
1611
1612                                                curFromNodeChild = matchingFromEl;
1613                                            }
1614                                        } else {
1615                                            // The nodes are not compatible since the "to" node has a key and there
1616                                            // is no matching keyed node in the source tree
1617                                            isCompatible = false;
1618                                        }
1619                                    }
1620                                } else if (curFromNodeKey) {
1621                                    // The original has a key
1622                                    isCompatible = false;
1623                                }
1624
1625                                isCompatible = isCompatible !== false && compareNodeNames(curFromNodeChild, curToNodeChild);
1626                                if (isCompatible) {
1627                                    // We found compatible DOM elements so transform
1628                                    // the current "from" node to match the current
1629                                    // target DOM node.
1630                                    morphEl(curFromNodeChild, curToNodeChild);
1631                                }
1632
1633                            } else if (curFromNodeType === TEXT_NODE || curFromNodeType == COMMENT_NODE) {
vendor: 7,941 bytes, lines 1634-1794
1634                                // Both nodes being compared are Text or Comment nodes
1635                                isCompatible = true;
1636                                // Simply update nodeValue on the original node to
1637                                // change the text value
1638                                if (curFromNodeChild.nodeValue !== curToNodeChild.nodeValue) {
1639                                    curFromNodeChild.nodeValue = curToNodeChild.nodeValue;
1640                                }
1641
1642                            }
1643                        }
1644
1645                        if (isCompatible) {
1646                            // Advance both the "to" child and the "from" child since we found a match
1647                            curToNodeChild = toNextSibling;
1648                            curFromNodeChild = fromNextSibling;
1649                            continue outer;
1650                        }
1651
1652                        // No compatible match so remove the old node from the DOM and continue trying to find a
1653                        // match in the original DOM. However, we only do this if the from node is not keyed
1654                        // since it is possible that a keyed node might match up with a node somewhere else in the
1655                        // target tree and we don't want to discard it just yet since it still might find a
1656                        // home in the final DOM tree. After everything is done we will remove any keyed nodes
1657                        // that didn't find a home
1658                        if (curFromNodeKey) {
1659                            // Since the node is keyed it might be matched up later so we defer
1660                            // the actual removal to later
1661                            addKeyedRemoval(curFromNodeKey);
1662                        } else {
1663                            // NOTE: we skip nested keyed nodes from being removed since there is
1664                            //       still a chance they will be matched up later
1665                            removeNode(curFromNodeChild, fromEl, true /* skip keyed nodes */);
1666                        }
1667
1668                        curFromNodeChild = fromNextSibling;
1669                    }
1670
1671                    // If we got this far then we did not find a candidate match for
1672                    // our "to node" and we exhausted all of the children "from"
1673                    // nodes. Therefore, we will just append the current "to" node
1674                    // to the end
1675                    if (curToNodeKey && (matchingFromEl = fromNodesLookup[curToNodeKey]) && compareNodeNames(matchingFromEl, curToNodeChild)) {
1676                        fromEl.appendChild(matchingFromEl);
1677                        morphEl(matchingFromEl, curToNodeChild);
1678                    } else {
1679                        var onBeforeNodeAddedResult = onBeforeNodeAdded(curToNodeChild);
1680                        if (onBeforeNodeAddedResult !== false) {
1681                            if (onBeforeNodeAddedResult) {
1682                                curToNodeChild = onBeforeNodeAddedResult;
1683                            }
1684
1685                            if (curToNodeChild.actualize) {
1686                                curToNodeChild = curToNodeChild.actualize(fromEl.ownerDocument || doc);
1687                            }
1688                            fromEl.appendChild(curToNodeChild);
1689                            handleNodeAdded(curToNodeChild);
1690                        }
1691                    }
1692
1693                    curToNodeChild = toNextSibling;
1694                    curFromNodeChild = fromNextSibling;
1695                }
1696
1697                // We have processed all of the "to nodes". If curFromNodeChild is
1698                // non-null then we still have some from nodes left over that need
1699                // to be removed
1700                while (curFromNodeChild) {
1701                    fromNextSibling = curFromNodeChild.nextSibling;
1702                    if ((curFromNodeKey = getNodeKey(curFromNodeChild))) {
1703                        // Since the node is keyed it might be matched up later so we defer
1704                        // the actual removal to later
1705                        addKeyedRemoval(curFromNodeKey);
1706                    } else {
1707                        // NOTE: we skip nested keyed nodes from being removed since there is
1708                        //       still a chance they will be matched up later
1709                        removeNode(curFromNodeChild, fromEl, true /* skip keyed nodes */);
1710                    }
1711                    curFromNodeChild = fromNextSibling;
1712                }
1713            }
1714
1715            var specialElHandler = specialElHandlers[fromEl.nodeName];
1716            if (specialElHandler) {
1717                specialElHandler(fromEl, toEl);
1718            }
1719        } // END: morphEl(...)
1720
1721        var morphedNode = fromNode;
1722        var morphedNodeType = morphedNode.nodeType;
1723        var toNodeType = toNode.nodeType;
1724
1725        if (!childrenOnly) {
1726            // Handle the case where we are given two DOM nodes that are not
1727            // compatible (e.g. <div> --> <span> or <div> --> TEXT)
1728            if (morphedNodeType === ELEMENT_NODE) {
1729                if (toNodeType === ELEMENT_NODE) {
1730                    if (!compareNodeNames(fromNode, toNode)) {
1731                        onNodeDiscarded(fromNode);
1732                        morphedNode = moveChildren(fromNode, createElementNS(toNode.nodeName, toNode.namespaceURI));
1733                    }
1734                } else {
1735                    // Going from an element node to a text node
1736                    morphedNode = toNode;
1737                }
1738            } else if (morphedNodeType === TEXT_NODE || morphedNodeType === COMMENT_NODE) { // Text or comment node
1739                if (toNodeType === morphedNodeType) {
1740                    if (morphedNode.nodeValue !== toNode.nodeValue) {
1741                        morphedNode.nodeValue = toNode.nodeValue;
1742                    }
1743
1744                    return morphedNode;
1745                } else {
1746                    // Text node to something else
1747                    morphedNode = toNode;
1748                }
1749            }
1750        }
1751
1752        if (morphedNode === toNode) {
1753            // The "to node" was not compatible with the "from node" so we had to
1754            // toss out the "from node" and use the "to node"
1755            onNodeDiscarded(fromNode);
1756        } else {
1757            morphEl(morphedNode, toNode, childrenOnly);
1758
1759            // We now need to loop over any keyed nodes that might need to be
1760            // removed. We only do the removal if we know that the keyed node
1761            // never found a match. When a keyed node is matched up we remove
1762            // it out of fromNodesLookup and we use fromNodesLookup to determine
1763            // if a keyed node has been matched up or not
1764            if (keyedRemovalList) {
1765                for (var i=0, len=keyedRemovalList.length; i<len; i++) {
1766                    var elToRemove = fromNodesLookup[keyedRemovalList[i]];
1767                    if (elToRemove) {
1768                        removeNode(elToRemove, elToRemove.parentNode, false);
1769                    }
1770                }
1771            }
1772        }
1773
1774        if (!childrenOnly && morphedNode !== fromNode && fromNode.parentNode) {
1775            if (morphedNode.actualize) {
1776                morphedNode = morphedNode.actualize(fromNode.ownerDocument || doc);
1777            }
1778            // If we had to swap out the from node with a new node because the old
1779            // node was not compatible with the target node then we need to
1780            // replace the old DOM node in the original DOM tree. This is only
1781            // possible if the original DOM node was part of a DOM tree which
1782            // we know is the case if it has a parent node.
1783            fromNode.parentNode.replaceChild(morphedNode, fromNode);
1784        }
1785
1786        return morphedNode;
1787    };
1788}
1789
1790var morphdom = morphdomFactory(morphAttrs);
1791
1792module.exports = morphdom;
1793
1794},{}],7
vendor: 5,461 bytes, lines 1794-1980
1794:[function(require,module,exports){
1795// shim for using process in browser
1796var process = module.exports = {};
1797
1798// cached from whatever global is present so that test runners that stub it
1799// don't break things.  But we need to wrap it in a try catch in case it is
1800// wrapped in strict mode code which doesn't define any globals.  It's inside a
1801// function because try/catches deoptimize in certain engines.
1802
1803var cachedSetTimeout;
1804var cachedClearTimeout;
1805
1806function defaultSetTimout() {
1807    throw new Error('setTimeout has not been defined');
1808}
1809function defaultClearTimeout () {
1810    throw new Error('clearTimeout has not been defined');
1811}
1812(function () {
1813    try {
1814        if (typeof setTimeout === 'function') {
1815            cachedSetTimeout = setTimeout;
1816        } else {
1817            cachedSetTimeout = defaultSetTimout;
1818        }
1819    } catch (e) {
1820        cachedSetTimeout = defaultSetTimout;
1821    }
1822    try {
1823        if (typeof clearTimeout === 'function') {
1824            cachedClearTimeout = clearTimeout;
1825        } else {
1826            cachedClearTimeout = defaultClearTimeout;
1827        }
1828    } catch (e) {
1829        cachedClearTimeout = defaultClearTimeout;
1830    }
1831} ())
1832function runTimeout(fun) {
1833    if (cachedSetTimeout === setTimeout) {
1834        //normal enviroments in sane situations
1835        return setTimeout(fun, 0);
1836    }
1837    // if setTimeout wasn't available but was latter defined
1838    if ((cachedSetTimeout === defaultSetTimout || !cachedSetTimeout) && setTimeout) {
1839        cachedSetTimeout = setTimeout;
1840        return setTimeout(fun, 0);
1841    }
1842    try {
1843        // when when somebody has screwed with setTimeout but no I.E. maddness
1844        return cachedSetTimeout(fun, 0);
1845    } catch(e){
1846        try {
1847            // When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally
1848            return cachedSetTimeout.call(null, fun, 0);
1849        } catch(e){
1850            // same as above but when it's a version of I.E. that must have the global object for 'this', hopfully our context correct otherwise it will throw a global error
1851            return cachedSetTimeout.call(this, fun, 0);
1852        }
1853    }
1854
1855
1856}
1857function runClearTimeout(marker) {
1858    if (cachedClearTimeout === clearTimeout) {
1859        //normal enviroments in sane situations
1860        return clearTimeout(marker);
1861    }
1862    // if clearTimeout wasn't available but was latter defined
1863    if ((cachedClearTimeout === defaultClearTimeout || !cachedClearTimeout) && clearTimeout) {
1864        cachedClearTimeout = clearTimeout;
1865        return clearTimeout(marker);
1866    }
1867    try {
1868        // when when somebody has screwed with setTimeout but no I.E. maddness
1869        return cachedClearTimeout(marker);
1870    } catch (e){
1871        try {
1872            // When we are in I.E. but the script has been evaled so I.E. doesn't  trust the global object when called normally
1873            return cachedClearTimeout.call(null, marker);
1874        } catch (e){
1875            // same as above but when it's a version of I.E. that must have the global object for 'this', hopfully our context correct otherwise it will throw a global error.
1876            // Some versions of I.E. have different rules for clearTimeout vs setTimeout
1877            return cachedClearTimeout.call(this, marker);
1878        }
1879    }
1880
1881
1882
1883}
1884var queue = [];
1885var draining = false;
1886var currentQueue;
1887var queueIndex = -1;
1888
1889function cleanUpNextTick() {
1890    if (!draining || !currentQueue) {
1891        return;
1892    }
1893    draining = false;
1894    if (currentQueue.length) {
1895        queue = currentQueue.concat(queue);
1896    } else {
1897        queueIndex = -1;
1898    }
1899    if (queue.length) {
1900        drainQueue();
1901    }
1902}
1903
1904function drainQueue() {
1905    if (draining) {
1906        return;
1907    }
1908    var timeout = runTimeout(cleanUpNextTick);
1909    draining = true;
1910
1911    var len = queue.length;
1912    while(len) {
1913        currentQueue = queue;
1914        queue = [];
1915        while (++queueIndex < len) {
1916            if (currentQueue) {
1917                currentQueue[queueIndex].run();
1918            }
1919        }
1920        queueIndex = -1;
1921        len = queue.length;
1922    }
1923    currentQueue = null;
1924    draining = false;
1925    runClearTimeout(timeout);
1926}
1927
1928process.nextTick = function (fun) {
1929    var args = new Array(arguments.length - 1);
1930    if (arguments.length > 1) {
1931        for (var i = 1; i < arguments.length; i++) {
1932            args[i - 1] = arguments[i];
1933        }
1934    }
1935    queue.push(new Item(fun, args));
1936    if (queue.length === 1 && !draining) {
1937        runTimeout(drainQueue);
1938    }
1939};
1940
1941// v8 likes predictible objects
1942function Item(fun, array) {
1943    this.fun = fun;
1944    this.array = array;
1945}
1946Item.prototype.run = function () {
1947    this.fun.apply(null, this.array);
1948};
1949process.title = 'browser';
1950process.browser = true;
1951process.env = {};
1952process.argv = [];
1953process.version = ''; // empty string to avoid regexp issues
1954process.versions = {};
1955
1956function noop() {}
1957
1958process.on = noop;
1959process.addListener = noop;
1960process.once = noop;
1961process.off = noop;
1962process.removeListener = noop;
1963process.removeAllListeners = noop;
1964process.emit = noop;
1965process.prependListener = noop;
1966process.prependOnceListener = noop;
1967
1968process.listeners = function (name) { return [] }
1969
1970process.binding = function (name) {
1971    throw new Error('process.binding is not supported');
1972};
1973
1974process.cwd = function () { return '/' };
1975process.chdir = function (dir) {
1976    throw new Error('process.chdir is not supported');
1977};
1978process.umask = function() { return 0; };
1979
1980},{}],
19808:[function(require,module,exports){
1981(function (setImmediate,clearImmediate){
1982var nextTick = require('process/browser.js').nextTick;
1983var apply = Function.prototype.apply;
1984var slice = Array.prototype.slice;
1985var immediateIds = {};
1986var nextImmediateId = 0;
1987
1988// DOM APIs, for completeness
1989
1990exports.setTimeout = function() {
1991  return new Timeout(apply.call(setTimeout, window, arguments), clearTimeout);
1992};
1993exports.setInterval = function() {
1994  return new Timeout(apply.call(setInterval, window, arguments), clearInterval);
1995};
1996exports.clearTimeout =
1997exports.clearInterval = function(timeout) { timeout.close(); };
1998
1999function Timeout(id, clearFn) {
2000  this._id = id;
2001  this._clearFn = clearFn;
2002}
2003Timeout.prototype.unref = Timeout.prototype.ref = function() {};
2004Timeout.prototype.close = function() {
2005  this._clearFn.call(window, this._id);
2006};
2007
2008// Does not start the time, just sets up the members needed.
2009exports.enroll = function(item, msecs) {
2010  clearTimeout(item._idleTimeoutId);
2011  item._idleTimeout = msecs;
2012};
2013
2014exports.unenroll = function(item) {
2015  clearTimeout(item._idleTimeoutId);
2016  item._idleTimeout = -1;
2017};
2018
2019exports._unrefActive = exports.active = function(item) {
2020  clearTimeout(item._idleTimeoutId);
2021
2022  var msecs = item._idleTimeout;
2023  if (msecs >= 0) {
2024    item._idleTimeoutId = setTimeout(function onTimeout() {
2025      if (item._onTimeout)
2026        item._onTimeout();
2027    }, msecs);
2028  }
2029};
2030
2031// That's not how node.js implements it but the exposed api is the same.
2032exports.setImmediate = typeof setImmediate === "function" ? setImmediate : function(fn) {
2033  var id = nextImmediateId++;
2034  var args = arguments.length < 2 ? false : slice.call(arguments, 1);
2035
2036  immediateIds[id] = true;
2037
2038  nextTick(function onNextTick() {
2039    if (immediateIds[id]) {
2040      // fn.call() is faster so we optimize for the common use-case
2041      // @see http://jsperf.com/call-apply-segu
2042      if (args) {
2043        fn.apply(null, args);
2044      } else {
2045        fn.call(null);
2046      }
2047      // Prevent ids from leaking
2048      exports.clearImmediate(id);
2049    }
2050  });
2051
2052  return id;
2053};
2054
2055exports.clearImmediate = typeof clearImmediate === "function" ? clearImmediate : function(id) {
2056  delete immediateIds[id];
2057};
2058}).call(this,require("timers").setImmediate,require("timers").clearImmediate)
2059},{"process/browser.js":7,"timers":8}],9:[function(require,module,exports){
2060"use strict";
2061
2062Object.defineProperty(exports, "__esModule", {
2063  value: true
2064});
2065exports["default"] = void 0;
2066
2067var _aTemplate = _interopRequireDefault(require("a-template"));
2068
2069require("custom-event-polyfill");
2070
2071function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
2072
2073function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
2074
2075function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
2076
2077function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
2078
2079function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
2080
2081function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
2082
2083function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
2084
2085function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
2086
2087function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
2088
2089function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
2090
2091var template = "<div class=\"\\{classNames.smartPhoto\\}\"<!-- BEGIN hide:exist --> aria-hidden=\"true\"<!-- END hide:exist --><!-- BEGIN hide:empty --> aria-hidden=\"false\"<!-- END hide:empty --> 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\"><!-- BEGIN groupItems:loop --><!-- \\BEGIN currentIndex:touch#{index} -->{caption}<!-- \\END currentIndex:touch#{index} --><!-- END groupItems:loop --></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\\}\"<!-- BEGIN isSmartPhone:exist --> data-action-touchstart=\"beforeDrag\" data-action-touchmove=\"onDrag\" data-action-touchend=\"afterDrag(false)\"<!-- END isSmartPhone:exist --><!-- BEGIN isSmartPhone:empty --> data-action-click=\"hidePhoto()\"<!-- END isSmartPhone:empty -->>\n\t\t\t\t</div>\n\t\t\t\t<ul style=\"transform:translate({translateX}[round]px,{translateY}[round]px);\" class=\"\\{classNames.smartPhotoList\\}<!-- BEGIN onMoveClass:exist --> \\{classNames.smartPhotoListOnMove\\}<!-- END onMoveClass:exist -->\">\n\t\t\t\t\t<!-- BEGIN groupItems:loop -->\n\t\t\t\t\t<li style=\"transform:translate({translateX}[round]px,{translateY}[round]px);\" class=\"<!-- \\BEGIN currentIndex:touch#{index} -->current<!-- \\END currentIndex:touch#{index} -->\">\n\t\t\t\t\t\t<!-- BEGIN processed:exist -->\n\t\t\t\t\t\t<div style=\"transform:translate({x}[round]px,{y}[round]px) scale({scale});\" class=\"\\\\{classNames.smartPhotoImgWrap\\\\}\"<!-- \\BEGIN isSmartPhone:empty --> data-action-mousemove=\"onDrag\" data-action-mousedown=\"beforeDrag\" data-action-mouseup=\"afterDrag\"<!-- \\END isSmartPhone:empty --><!-- \\BEGIN isSmartPhone:exist --> data-action-touchstart=\"beforeDrag\" data-action-touchmove=\"onDrag\" data-action-touchend=\"afterDrag\"<!-- \\END isSmartPhone:exist -->>\n\t\t\t\t\t\t\t<img style=\"<!-- \\BEGIN currentIndex:touch#{index} -->transform:translate(\\{photoPosX\\}[virtualPos]px,\\{photoPosY\\}[virtualPos]px) scale(\\{scaleSize\\});<!-- \\END currentIndex:touch#{index} -->width:{width}px;\" src=\"{src}\" class=\"\\\\{classNames.smartPhotoImg\\\\}<!-- \\BEGIN scale:exist -->  \\\\{classNames.smartPhotoImgOnMove\\\\}<!-- \\END scale:exist --><!-- \\BEGIN elastic:exist --> \\\\{classNames.smartPhotoImgElasticMove\\\\}<!-- \\END elastic:exist --><!-- \\BEGIN appear:exist --> active<!-- \\END appear:exist -->\" ondragstart=\"return false;\">\n\t\t\t\t\t\t</div>\n\t\t\t\t\t\t<!-- END processed:exist -->\n\t\t\t\t\t\t<!-- BEGIN processed:empty -->\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<!-- END processed:empty -->\n\t\t\t\t\t</li>\n\t\t\t\t\t<!-- END groupItems:loop -->\n\t\t\t\t</ul>\n\t\t\t\t<!-- BEGIN arrows:exist -->\n\t\t\t\t<ul class=\"\\{classNames.smartPhotoArrows\\}\"<!-- BEGIN hideUi:exist --> aria-hidden=\"true\"<!-- END hideUi:exist --><!-- BEGIN hideUi:exist --> aria-hidden=\"false\"<!-- END hideUi:exist -->>\n\t\t\t\t\t<li class=\"\\{classNames.smartPhotoArrowLeft\\}<!-- BEGIN isSmartPhone:exist --> \\{classNames.smartPhotoArrowHideIcon\\}<!-- END isSmartPhone:exist -->\"<!-- BEGIN showPrevArrow:empty --> aria-hidden=\"true\"<!-- END showPrevArrow:empty -->>
2091<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\\}<!-- BEGIN isSmartPhone:exist --> \\{classNames.smartPhotoArrowHideIcon\\}<!-- END isSmartPhone:exist -->\"<!-- BEGIN showNextArrow:empty --> aria-hidden=\"true\"<!-- END showNextArrow:empty -->><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<!-- END arrows:exist -->\n\t\t\t\t<!-- BEGIN nav:exist -->\n\t\t\t\t<nav class=\"\\{classNames.smartPhotoNav\\}\"<!-- BEGIN hideUi:exist --> aria-hidden=\"true\"<!-- END hideUi:exist --><!-- BEGIN hideUi:exist --> aria-hidden=\"false\"<!-- END hideUi:exist -->>\n\t\t\t\t\t<ul>\n\t\t\t\t\t\t<!-- BEGIN groupItems:loop -->\n\t\t\t\t\t\t<li><a href=\"#\" data-action-click=\"gotoSlide({index})\" class=\"<!-- \\BEGIN currentIndex:touch#{index} -->current<!-- \\END currentIndex:touch#{index} -->\" 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<!-- END groupItems:loop -->\n\t\t\t\t\t</ul>\n\t\t\t\t</nav>\n\t\t\t\t<!-- END nav:exist -->\n\t\t</div>\n\t\t<!-- BEGIN appearEffect:exist -->\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<!-- END appearEffect:exist -->\n\t</div>\n</div>\n";
2092
2093var util = require('../lib/util');
2094
2095var Promise = require('es6-promise-polyfill').Promise;
2096
2097var defaults = {
2098  classNames: {
2099    smartPhoto: 'smartphoto',
2100    smartPhotoClose: 'smartphoto-close',
2101    smartPhotoBody: 'smartphoto-body',
2102    smartPhotoInner: 'smartphoto-inner',
2103    smartPhotoContent: 'smartphoto-content',
2104    smartPhotoImg: 'smartphoto-img',
2105    smartPhotoImgOnMove: 'smartphoto-img-onmove',
2106    smartPhotoImgElasticMove: 'smartphoto-img-elasticmove',
2107    smartPhotoImgWrap: 'smartphoto-img-wrap',
2108    smartPhotoArrows: 'smartphoto-arrows',
2109    smartPhotoNav: 'smartphoto-nav',
2110    smartPhotoArrowRight: 'smartphoto-arrow-right',
2111    smartPhotoArrowLeft: 'smartphoto-arrow-left',
2112    smartPhotoArrowHideIcon: 'smartphoto-arrow-hide',
2113    smartPhotoImgLeft: 'smartphoto-img-left',
2114    smartPhotoImgRight: 'smartphoto-img-right',
2115    smartPhotoList: 'smartphoto-list',
2116    smartPhotoListOnMove: 'smartphoto-list-onmove',
2117    smartPhotoHeader: 'smartphoto-header',
2118    smartPhotoCount: 'smartphoto-count',
2119    smartPhotoCaption: 'smartphoto-caption',
2120    smartPhotoDismiss: 'smartphoto-dismiss',
2121    smartPhotoLoader: 'smartphoto-loader',
2122    smartPhotoLoaderWrap: 'smartphoto-loader-wrap',
2123    smartPhotoImgClone: 'smartphoto-img-clone'
2124  },
2125  message: {
2126    gotoNextImage: 'go to the next image',
2127    gotoPrevImage: 'go to the previous image',
2128    closeDialog: 'close the image dialog'
2129  },
2130  arrows: true,
2131  nav: true,
2132  showAnimation: true,
2133  verticalGravity: false,
2134  useOrientationApi: false,
2135  useHistoryApi: true,
2136  swipeTopToClose: false,
2137  swipeBottomToClose: true,
2138  swipeOffset: 100,
2139  headerHeight: 60,
2140  footerHeight: 60,
2141  forceInterval: 10,
2142  registance: 0.5,
2143  loadOffset: 2,
2144  resizeStyle: 'fit'
2145};
2146
2147var SmartPhoto =
2148/*#__PURE__*/
2149function (_ATemplate) {
2150  _inherits(SmartPhoto, _ATemplate);
2151
2152  function SmartPhoto(selector, settings) {
2153    var _this;
2154
2155    _classCallCheck(this, SmartPhoto);
2156
2157    _this = _possibleConstructorReturn(this, _getPrototypeOf(SmartPhoto).call(this));
2158    _this.data = util.extend({}, defaults, settings);
2159    _this.data.currentIndex = 0;
2160    _this.data.oldIndex = 0;
2161    _this.data.hide = true;
2162    _this.data.group = {};
2163    _this.data.scaleSize = 1;
2164    _this.data.scale = false;
2165    _this.pos = {
2166      x: 0,
2167      y: 0
2168    };
2169    _this.data.photoPosX = 0;
2170    _this.data.photoPosY = 0;
2171    _this.convert = {
2172      increment: _this.increment,
2173      virtualPos: _this.virtualPos,
2174      round: _this.round
2175    };
2176    _this.data.groupItems = _this.groupItems;
2177    _this.elements = typeof selector === 'string' ? document.querySelectorAll(selector) : selector;
2178    var date = new Date();
2179    _this.tapSecond = date.getTime();
2180    _this.onListMove = false;
2181    _this.clicked = false;
2182    _this.id = _this._getUniqId();
2183    _this.vx = 0;
2184    _this.vy = 0;
2185    _this.data.appearEffect = null;
2186
2187    _this.addTemplate(_this.id, template);
2188
2189    _this.data.isSmartPhone = _this._isSmartPhone();
2190    var body = document.querySelector('body');
2191    util.append(body, "<div data-id='".concat(_this.id, "'></div>"));
2192    [].forEach.call(_this.elements, function (element) {
2193      _this.addNewItem(element);
2194    });
2195
2196    _this.update();
2197
2198    var currentItem = _this._getCurrentItemByHash();
2199
2200    if (currentItem) {
2201      util.triggerEvent(currentItem.element, 'click');
2202    }
2203
2204    setInterval(function () {
2205      _this._doAnim();
2206    }, _this.data.forceInterval);
2207
2208    if (!_this.data.isSmartPhone) {
2209      window.addEventListener('resize', function () {
2210        if (!_this.groupItems()) {
2211          return;
2212        }
2213
2214        _this._resetTranslate();
2215
2216        _this._setPosByCurrentIndex();
2217
2218        _this._setSizeByScreen();
2219
2220        _this.update();
2221      });
2222      window.addEventListener('keydown', function (e) {
2223        var code = e.keyCode || e.which;
2224
2225        if (_this.data.hide === true) {
2226          return;
2227        }
2228
2229        if (code === 37) {
2230          _this.gotoSlide(_this.data.prev);
2231        } else if (code === 39) {
2232          _this.gotoSlide(_this.data.next);
2233        } else if (code === 27) {
2234          _this.hidePhoto();
2235        }
2236      });
2237      return _possibleConstructorReturn(_this);
2238    }
2239
2240    window.addEventListener('orientationchange', function () {
2241      if (!_this.groupItems()) {
2242        return;
2243      }
2244
2245      _this._resetTranslate();
2246
2247      _this._setPosByCurrentIndex();
2248
2249      _this._setHashByCurrentIndex();
2250
2251      _this._setSizeByScreen();
2252
2253      _this.update();
2254    });
2255
2256    if (!_this.data.useOrientationApi) {
2257      return _possibleConstructorReturn(_this);
2258    }
2259
2260    window.addEventListener('deviceorientation', function (e) {
2261      var _window = window,
2262          orientation = _window.orientation;
2263
2264      if (!e || !e.gamma || _this.data.appearEffect) {
2265        return;
2266      }
2267
2268      if (!_this.isBeingZoomed && !_this.photoSwipable && !_this.data.elastic && _this.data.scale) {
2269        if (orientation === 0) {
2270          _this._calcGravity(e.gamma, e.beta);
2271        } else if (orientation === 90) {
2272          _this._calcGravity(e.beta, e.gamma);
2273        } else if (orientation === -90) {
2274          _this._calcGravity(-e.beta, -e.gamma);
2275        } else if (orientation === 180) {
2276          _this._calcGravity(-e.gamma, -e.beta);
2277        }
2278      }
2279    });
2280    return _this;
2281  }
2282
2283  _createClass(SmartPhoto, [{
2284    key: "on",
2285    value: function on(event, fn) {
2286      var _this2 = this;
2287
2288      var photo = this._getElementByClass(this.data.classNames.smartPhoto);
2289
2290      photo.addEventListener(event, function (e) {
2291        fn.call(_this2, e);
2292      });
2293    }
2294  }, {
2295    key: "increment",
2296    value: function increment(item) {
2297      return item + 1;
2298    }
2299  }, {
2300    key: "round",
2301    value: function round(number) {
2302      return Math.round(number);
2303    }
2304  }, {
2305    key: "virtualPos",
2306    value: function virtualPos(pos) {
2307      pos = parseInt(pos, 10);
2308
2309      var item = this._getSelectedItem();
2310
2311      return pos / item.scale / this.data.scaleSize;
2312    }
2313  }, {
2314    key: "groupItems",
2315    value: function groupItems() {
2316      return this.data.group[this.data.currentGroup];
2317    }
2318  }, {
2319    key: "_resetTranslate",
2320    value: function _resetTranslate() {
2321      var _this3 = this;
2322
2323      var items = this.groupItems();
2324      items.forEach(function (item, index) {
2325        item.translateX = _this3._getWindowWidth() * index;
2326      });
2327    }
2328  }, {
2329    key: "addNewItem",
2330    value: function addNewItem(element) {
2331      var _this4 = this;
2332
2333      var groupId = element.getAttribute('data-group') || 'nogroup';
2334      var group = this.data.group;
2335
2336      if (groupId === 'nogroup') {
2337        element.setAttribute('data-group', 'nogroup');
2338      }
2339
2340      if (!group[groupId]) {
2341        group[groupId] = [];
2342      }
2343
2344      var index = group[groupId].length;
2345      var body = document.querySelector('body');
2346      var src = element.getAttribute('href');
2347      var img = element.querySelector('img');
2348      var thumb = src;
2349
2350      if (img) {
2351        if (img.currentSrc) {
2352          thumb = img.currentSrc;
2353        } else {
2354          thumb = img.src;
2355        }
2356      }
2357
2358      var item = {
2359        src: src,
2360        thumb: thumb,
2361        caption: element.getAttribute('data-caption'),
2362        groupId: groupId,
2363        translateX: this._getWindowWidth() * index,
2364        index: index,
2365        translateY: 0,
2366        width: 50,
2367        height: 50,
2368        id: element.getAttribute('data-id') || index,
2369        loaded: false,
2370        processed: false,
2371        element: element
2372      };
2373      group[groupId].push(item);
2374      this.data.currentGroup = groupId;
2375      var id = element.getAttribute('data-id');
2376
2377      if (!id) {
2378        element.setAttribute('data-id', index);
2379      }
2380
2381      element.setAttribute('data-index', index);
2382      element.addEventListener('click', function (event) {
2383        event.preventDefault();
2384        _this4.data.currentGroup = element.getAttribute('data-group');
2385        _this4.data.currentIndex = parseInt(element.getAttribute('data-index'), 10);
2386
2387        _this4._setHashByCurrentIndex();
2388
2389        var currentItem = _this4._getSelectedItem();
2390
2391        if (currentItem.loaded) {
2392          _this4._initPhoto();
2393
2394          _this4.addAppearEffect(element, currentItem);
2395
2396          _this4.clicked = true;
2397
2398          _this4.update();
2399
2400          body.style.overflow = 'hidden';
2401
2402          _this4._fireEvent('open');
2403        } else {
2404          _this4._loadItem(currentItem).then(function () {
2405            _this4._initPhoto();
2406
2407            _this4.addAppearEffect(element, currentItem);
2408
2409            _this4.clicked = true;
2410
2411            _this4.update();
2412
2413            body.style.overflow = 'hidden';
2414
2415            _this4._fireEvent('open');
2416          });
2417        }
2418      });
2419    }
2420  }, {
2421    key: "_initPhoto",
2422    value: function _initPhoto() {
2423      this.data.total = this.groupItems().length;
2424      this.data.hide = false;
2425      this.data.photoPosX = 0;
2426      this.data.photoPosY = 0;
2427
2428      this._setPosByCurrentIndex();
2429
2430      this._setSizeByScreen();
2431
2432      this.setArrow();
2433
2434      if (this.data.resizeStyle === 'fill' && this.data.isSmartPhone) {
2435        this.data.scale = true;
2436        this.data.hideUi = true;
2437        this.data.scaleSize = this._getScaleBoarder();
2438      }
2439    }
2440  }, {
2441    key: "onUpdated",
2442    value: function onUpdated() {
2443      var _this5 = this;
2444
2445      if (this.data.appearEffect && this.data.appearEffect.once) {
2446        this.data.appearEffect.once = false;
2447        this.execEffect().then(function () {
2448          _this5.data.appearEffect = null;
2449          _this5.data.appear = true;
2450
2451          _this5.update();
2452        });
2453      }
2454
2455      if (this.clicked) {
2456        this.clicked = false;
2457        var classNames = this.data.classNames;
2458
2459        var caption = this._getElementByClass(classNames.smartPhotoCaption);
2460
2461        caption.focus();
2462      }
2463    }
2464  }, {
2465    key: "execEffect",
2466    value: function execEffect() {
2467      var _this6 = this;
2468
2469      return new Promise(function (resolve) {
2470        if (util.isOldIE()) {
2471          resolve();
2472        }
2473
2474        var _this6$data = _this6.data,
2475            appearEffect = _this6$data.appearEffect,
2476            classNames = _this6$data.classNames;
2477
2478        var effect = _this6._getElementByClass(classNames.smartPhotoImgClone);
2479
2480        var handler = function handler() {
2481          effect.removeEventListener('transitionend', handler, true);
2482          resolve();
2483        };
2484
2485        effect.addEventListener('transitionend', handler, true);
2486        setTimeout(function () {
2487          effect.style.transform = "translate(".concat(appearEffect.afterX, "px, ").concat(appearEffect.afterY, "px) scale(").concat(appearEffect.scale, ")");
2488        }, 10);
2489      });
2490    }
2491  }, {
2492    key: "addAppearEffect",
2493    value: function addAppearEffect(element, item) {
2494      if (this.data.showAnimation === false) {
2495        this.data.appear = true;
2496        return;
2497      }
2498
2499      var img = element.querySelector('img');
2500      var pos = util.getViewPos(img);
2501      var appear = {};
2502      var scale = 1;
2503      appear.width = img.offsetWidth;
2504      appear.height = img.offsetHeight;
2505      appear.top = pos.top;
2506      appear.left = pos.left;
2507      appear.once = true;
2508      appear.img = item.src;
2509
2510      var toX = this._getWindowWidth();
2511
2512      var toY = this._getWindowHeight();
2513
2514      var screenY = toY - this.data.headerHeight - this.data.footerHeight;
2515
2516      if (this.data.resizeStyle === 'fill' && this.data.isSmartPhone) {
2517        if (img.offsetWidth > img.offsetHeight) {
2518          scale = toY / img.offsetHeight;
2519        } else {
2520          scale = toX / img.offsetWidth;
2521        }
2522      } else {
2523        if (appear.width >= appear.height) {
2524          if (item.height < screenY) {
2525            scale = item.width / appear.width;
2526          } else {
2527            scale = screenY / appear.height;
2528          }
2529        } else if (appear.height > appear.width) {
2530          if (item.height < screenY) {
2531            scale = item.height / appear.height;
2532          } else {
2533            scale = screenY / appear.height;
2534          }
2535        }
2536
2537        if (appear.width * scale > toX) {
2538          scale = toX / appear.width;
2539        }
2540      }
2541
2542      var x = (scale - 1) / 2 * img.offsetWidth + (toX - img.offsetWidth * scale) / 2;
2543      var y = (scale - 1) / 2 * img.offsetHeight + (toY - img.offsetHeight * scale) / 2;
2544      appear.afterX = x;
2545      appear.afterY = y;
2546      appear.scale = scale;
2547      this.data.appearEffect = appear;
2548    }
2549  }, {
2550    key: "hidePhoto",
2551    value: function hidePhoto() {
2552      var _this7 = this;
2553
2554      var dir = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'bottom';
2555      this.data.hide = true;
2556      this.data.appear = false;
2557      this.data.appearEffect = null;
2558      this.data.hideUi = false;
2559      this.data.scale = false;
2560      this.data.scaleSize = 1;
2561      var scrollX = window.pageXOffset !== undefined ? window.pageXOffset : (document.documentElement || document.body.parentNode || document.body).scrollLeft;
2562      var scrollY = window.pageYOffset !== undefined ? window.pageYOffset : (document.documentElement || document.body.parentNode || document.body).scrollTop;
2563      var body = document.querySelector('body');
2564
2565      if (window.location.hash) {
2566        this._setHash('');
2567      }
2568
2569      window.scroll(scrollX, scrollY);
2570
2571      this._doHideEffect(dir).then(function () {
2572        _this7.update();
2573
2574        body.style.overflow = '';
2575
2576        _this7._fireEvent('close');
2577      });
2578    }
2579  }, {
2580    key: "_doHideEffect",
2581    value: function _doHideEffect(dir) {
2582      var _this8 = this;
2583
2584      return new Promise(function (resolve) {
2585        if (util.isOldIE()) {
2586          resolve();
2587        }
2588
2589        var classNames = _this8.data.classNames;
2590
2591        var photo = _this8._getElementByClass(classNames.smartPhoto);
2592
2593        var img = _this8._getElementByQuery(".current .".concat(classNames.smartPhotoImg));
2594
2595        var height = _this8._getWindowHeight();
2596
2597        var handler = function handler() {
2598          photo.removeEventListener('transitionend', handler, true);
2599          resolve();
2600        };
2601
2602        photo.style.opacity = 0;
2603
2604        if (dir === 'bottom') {
2605          img.style.transform = "translateY(".concat(height, "px)");
2606        } else if (dir === 'top') {
2607          img.style.transform = "translateY(-".concat(height, "px)");
2608        }
2609
2610        photo.addEventListener('transitionend', handler, true);
2611      });
2612    }
2613  }, {
2614    key: "_getElementByClass",
2615    value: function _getElementByClass(className) {
2616      return document.querySelector("[data-id=\"".concat(this.id, "\"] .").concat(className));
2617    }
2618  }, {
2619    key: "_getElementByQuery",
2620    value: function _getElementByQuery(query) {
2621      return document.querySelector("[data-id=\"".concat(this.id, "\"] ").concat(query));
2622    }
2623  }, {
2624    key: "_getTouchPos",
2625    value: function _getTouchPos() {
2626      var x = 0;
2627      var y = 0;
2628      var e = typeof event === 'undefined' ? this.e : event;
2629
2630      if (this._isTouched(e)) {
2631        x = e.touches[0].pageX;
2632        y = e.touches[0].pageY;
2633      } else if (e.pageX) {
2634        x = e.pageX;
2635        y = e.pageY;
2636      }
2637
2638      return {
2639        x: x,
2640        y: y
2641      };
2642    }
2643  }, {
2644    key: "_getGesturePos",
2645    value: function _getGesturePos(e) {
2646      var touches = e.touches;
2647      return [{
2648        x: touches[0].pageX,
2649        y: touches[0].pageY
2650      }, {
2651        x: touches[1].pageX,
2652        y: touches[1].pageY
2653      }];
2654    }
2655  }, {
2656    key: "_setPosByCurrentIndex",
2657    value: function _setPosByCurrentIndex() {
2658      var _this9 = this;
2659
2660      var items = this.groupItems();
2661      var moveX = -1 * items[this.data.currentIndex].translateX;
2662      this.pos.x = moveX;
2663      setTimeout(function () {
2664        _this9.data.translateX = moveX;
2665        _this9.data.translateY = 0;
2666
2667        _this9._listUpdate();
2668      }, 1);
2669    }
2670  }, {
2671    key: "_setHashByCurrentIndex",
2672    value: function _setHashByCurrentIndex() {
2673      var scrollX = window.pageXOffset !== undefined ? window.pageXOffset : (document.documentElement || document.body.parentNode || document.body).scrollLeft;
2674      var scrollY = window.pageYOffset !== undefined ? window.pageYOffset : (document.documentElement || document.body.parentNode || document.body).scrollTop;
2675      var items = this.groupItems();
2676      var id = items[this.data.currentIndex].id;
2677      var group = this.data.currentGroup;
2678      var hash = "group=".concat(group, "&photo=").concat(id);
2679
2680      this._setHash(hash);
2681
2682      window.scroll(scrollX, scrollY);
2683    }
2684  }, {
2685    key: "_setHash",
2686    value: function _setHash(hash) {
2687      if (!(window.history && window.history.pushState) || !this.data.useHistoryApi) {
2688        return;
2689      }
2690
2691      if (hash) {
2692        window.history.replaceState(null, null, "".concat(location.pathname).concat(location.search, "#").concat(hash));
2693      } else {
2694        window.history.replaceState(null, null, "".concat(location.pathname).concat(location.search));
2695      }
2696    }
2697  }, {
2698    key: "_getCurrentItemByHash",
2699    value: function _getCurrentItemByHash() {
2700      var group = this.data.group;
2701      var hash = location.hash.substr(1);
2702      var hashObj = util.parseQuery(hash);
2703      var currentItem = null;
2704
2705      var getCurrentItem = function getCurrentItem(item) {
2706        if (hashObj.group === item.groupId && hashObj.photo === item.id) {
2707          currentItem = item;
2708        }
2709      };
2710
2711      Object.keys(group).forEach(function (key) {
2712        group[key].forEach(getCurrentItem);
2713      });
2714      return currentItem;
2715    }
2716  }, {
2717    key: "_loadItem",
2718    value: function _loadItem(item) {
2719      return new Promise(function (resolve) {
2720        var img = new Image();
2721
2722        img.onload = function () {
2723          item.width = img.width;
2724          item.height = img.height;
2725          item.loaded = true;
2726          resolve();
2727        };
2728
2729        img.onerror = function () {
2730          resolve();
2731        };
2732
2733        img.src = item.src;
2734      });
2735    }
2736  }, {
2737    key: "_getItemByIndex",
2738    value: function _getItemByIndex(index) {
2739      var data = this.data;
2740
2741      if (data.group[data.currentGroup][index]) {
2742        return data.group[data.currentGroup][index];
2743      } else {
2744        return null;
2745      }
2746    }
2747  }, {
2748    key: "_loadNeighborItems",
2749    value: function _loadNeighborItems() {
2750      var _this10 = this;
2751
2752      var index = this.data.currentIndex;
2753      var loadOffset = this.data.loadOffset;
2754      var from = index - loadOffset;
2755      var to = index + loadOffset;
2756      var promises = [];
2757
2758      for (var i = from; i < to; i++) {
2759        var item = this._getItemByIndex(i);
2760
2761        if (item && !item.loaded) {
2762          promises.push(this._loadItem(item));
2763        }
2764      }
2765
2766      if (promises.length) {
2767        Promise.all(promises).then(function () {
2768          _this10._initPhoto();
2769
2770          _this10.update();
2771        });
2772      }
2773    }
2774  }, {
2775    key: "_setSizeByScreen",
2776    value: function _setSizeByScreen() {
2777      var windowX = this._getWindowWidth();
2778
2779      var windowY = this._getWindowHeight();
2780
2781      var headerHeight = this.data.headerHeight;
2782      var footerHeight = this.data.footerHeight;
2783      var screenY = windowY - (headerHeight + footerHeight);
2784      var items = this.groupItems();
2785      items.forEach(function (item) {
2786        if (!item.loaded) {
2787          return;
2788        }
2789
2790        item.processed = true;
2791        item.scale = screenY / item.height;
2792
2793        if (item.height < screenY) {
2794          item.scale = 1;
2795        }
2796
2797        item.x = (item.scale - 1) / 2 * item.width + (windowX - item.width * item.scale) / 2;
2798        item.y = (item.scale - 1) / 2 * item.height + (windowY - item.height * item.scale) / 2;
2799
2800        if (item.width * item.scale > windowX) {
2801          item.scale = windowX / item.width;
2802          item.x = (item.scale - 1) / 2 * item.width;
2803        }
2804      });
2805    }
2806  }, {
2807    key: "_slideList",
2808    value: function _slideList() {
2809      var _this11 = this;
2810
2811      this.data.scaleSize = 1;
2812      this.isBeingZoomed = false;
2813      this.data.hideUi = false;
2814      this.data.scale = false;
2815      this.data.photoPosX = 0;
2816      this.data.photoPosY = 0;
2817      this.data.onMoveClass = true;
2818
2819      this._setPosByCurrentIndex();
2820
2821      this._setHashByCurrentIndex();
2822
2823      this._setSizeByScreen();
2824
2825      setTimeout(function () {
2826        var item = _this11._getSelectedItem();
2827
2828        _this11.data.onMoveClass = false;
2829
2830        _this11.setArrow();
2831
2832        _this11.update();
2833
2834        if (_this11.data.oldIndex !== _this11.data.currentIndex) {
2835          _this11._fireEvent('change');
2836        }
2837
2838        _this11.data.oldIndex = _this11.data.currentIndex;
2839
2840        _this11._loadNeighborItems();
2841
2842        if (!item.loaded) {
2843          _this11._loadItem(item).then(function () {
2844            _this11._initPhoto();
2845
2846            _this11.update();
2847          });
2848        }
2849      }, 200);
2850    }
2851  }, {
2852    key: "gotoSlide",
2853    value: function gotoSlide(index) {
2854      if (this.e && this.e.preventDefault) {
2855        this.e.preventDefault();
2856      }
2857
2858      this.data.currentIndex = parseInt(index, 10);
2859
2860      if (!this.data.currentIndex) {
2861        this.data.currentIndex = 0;
2862      }
2863
2864      this._slideList();
2865    }
2866  }, {
2867    key: "setArrow",
2868    value: function setArrow() {
2869      var items = this.groupItems();
2870      var length = items.length;
2871      var next = this.data.currentIndex + 1;
2872      var prev = this.data.currentIndex - 1;
2873      this.data.showNextArrow = false;
2874      this.data.showPrevArrow = false;
2875
2876      if (next !== length) {
2877        this.data.next = next;
2878        this.data.showNextArrow = true;
2879      }
2880
2881      if (prev !== -1) {
2882        this.data.prev = prev;
2883        this.data.showPrevArrow = true;
2884      }
2885    }
2886  }, {
2887    key: "beforeDrag",
2888    value: function beforeDrag() {
2889      if (this._isGestured(this.e)) {
2890        this.beforeGesture();
2891        return;
2892      }
2893
2894      this.isBeingZoomed = false;
2895
2896      if (this.data.scale) {
2897        this.beforePhotoDrag();
2898        return;
2899      }
2900
2901      var pos = this._getTouchPos();
2902
2903      this.isSwipable = true;
2904      this.dragStart = true;
2905      this.firstPos = pos;
2906      this.oldPos = pos;
2907    }
2908  }, {
2909    key: "afterDrag",
2910    value: function afterDrag() {
2911      var items = this.groupItems();
2912      var date = new Date();
2913      var tapSecond = date.getTime();
2914      var offset = this.tapSecond - tapSecond;
2915      var swipeWidth = 0;
2916      var swipeHeight = 0;
2917      this.isSwipable = false;
2918      this.onListMove = false;
2919
2920      if (this.oldPos) {
2921        swipeWidth = this.oldPos.x - this.firstPos.x;
2922        swipeHeight = this.oldPos.y - this.firstPos.y;
2923      }
2924
2925      if (this.isBeingZoomed) {
2926        this.afterGesture();
2927        return;
2928      }
2929
2930      if (this.data.scale) {
2931        this.afterPhotoDrag();
2932        return;
2933      } else if (!util.isSmartPhone() && swipeWidth === 0 && swipeHeight === 0) {
2934        this.zoomPhoto();
2935        return;
2936      }
2937
2938      if (Math.abs(offset) <= 500 && swipeWidth === 0 && swipeHeight === 0) {
2939        this.e.preventDefault();
2940        this.zoomPhoto();
2941        return;
2942      }
2943
2944      this.tapSecond = tapSecond;
2945
2946      this._fireEvent('swipeend');
2947
2948      if (this.moveDir === 'horizontal') {
2949        if (swipeWidth >= this.data.swipeOffset && this.data.currentIndex !== 0) {
2950          this.data.currentIndex -= 1;
2951        } else if (swipeWidth <= -this.data.swipeOffset && this.data.currentIndex !== items.length - 1) {
2952          this.data.currentIndex += 1;
2953        }
2954
2955        this._slideList();
2956      }
2957
2958      if (this.moveDir === 'vertical') {
2959        if (this.data.swipeBottomToClose && swipeHeight >= this.data.swipeOffset) {
2960          this.hidePhoto('bottom');
2961        } else if (this.data.swipeTopToClose && swipeHeight <= -this.data.swipeOffset) {
2962          this.hidePhoto('top');
2963        } else {
2964          this.data.translateY = 0;
2965
2966          this._slideList();
2967        }
2968      }
2969    }
2970  }, {
2971    key: "onDrag",
2972    value: function onDrag() {
2973      this.e.preventDefault();
2974
2975      if (this._isGestured(this.e) && this.onListMove === false) {
2976        this.onGesture();
2977        return;
2978      }
2979
2980      if (this.isBeingZoomed) {
2981        return;
2982      }
2983
2984      if (this.data.scale) {
2985        this.onPhotoDrag();
2986        return;
2987      }
2988
2989      if (!this.isSwipable) {
2990        return;
2991      }
2992
2993      var pos = this._getTouchPos();
2994
2995      var x = pos.x - this.oldPos.x;
2996      var y = pos.y - this.firstPos.y;
2997
2998      if (this.dragStart) {
2999        this._fireEvent('swipestart');
3000
3001        this.dragStart = false;
3002
3003        if (Math.abs(x) > Math.abs(y)) {
3004          this.moveDir = 'horizontal';
3005        } else {
3006          this.moveDir = 'vertical';
3007        }
3008      }
3009
3010      if (this.moveDir === 'horizontal') {
3011        this.pos.x += x;
3012        this.data.translateX = this.pos.x;
3013      } else {
3014        this.data.translateY = y;
3015      }
3016
3017      this.onListMove = true;
3018      this.oldPos = pos;
3019
3020      this._listUpdate();
3021    }
3022  }, {
3023    key: "zoomPhoto",
3024    value: function zoomPhoto() {
3025      var _this12 = this;
3026
3027      this.data.hideUi = true;
3028      this.data.scaleSize = this._getScaleBoarder();
3029
3030      if (this.data.scaleSize <= 1) {
3031        return;
3032      }
3033
3034      this.data.photoPosX = 0;
3035      this.data.photoPosY = 0;
3036
3037      this._photoUpdate();
3038
3039      setTimeout(function () {
3040        _this12.data.scale = true;
3041
3042        _this12._photoUpdate();
3043
3044        _this12._fireEvent('zoomin');
3045      }, 300);
3046    }
3047  }, {
3048    key: "zoomOutPhoto",
3049    value: function zoomOutPhoto() {
3050      this.data.scaleSize = 1;
3051      this.isBeingZoomed = false;
3052      this.data.hideUi = false;
3053      this.data.scale = false;
3054      this.data.photoPosX = 0;
3055      this.data.photoPosY = 0;
3056
3057      this._photoUpdate();
3058
3059      this._fireEvent('zoomout');
3060    }
3061  }, {
3062    key: "beforePhotoDrag",
3063    value: function beforePhotoDrag() {
3064      var pos = this._getTouchPos();
3065
3066      this.photoSwipable = true;
3067
3068      if (!this.data.photoPosX) {
3069        this.data.photoPosX = 0;
3070      }
3071
3072      if (!this.data.photoPosY) {
3073        this.data.photoPosY = 0;
3074      }
3075
3076      this.oldPhotoPos = pos;
3077      this.firstPhotoPos = pos;
3078    }
3079  }, {
3080    key: "onPhotoDrag",
3081    value: function onPhotoDrag() {
3082      if (!this.photoSwipable) {
3083        return;
3084      }
3085
3086      this.e.preventDefault();
3087
3088      var pos = this._getTouchPos();
3089
3090      var x = pos.x - this.oldPhotoPos.x;
3091      var y = pos.y - this.oldPhotoPos.y;
3092
3093      var moveX = this._round(this.data.scaleSize * x, 6);
3094
3095      var moveY = this._round(this.data.scaleSize * y, 6);
3096
3097      if (typeof moveX === 'number') {
3098        this.data.photoPosX += moveX;
3099        this.photoVX = moveX;
3100      }
3101
3102      if (typeof moveY === 'number') {
3103        this.data.photoPosY += moveY;
3104        this.photoVY = moveY;
3105      }
3106
3107      this.oldPhotoPos = pos;
3108
3109      this._photoUpdate();
3110    }
3111  }, {
3112    key: "afterPhotoDrag",
3113    value: function afterPhotoDrag() {
3114      if (this.oldPhotoPos.x === this.firstPhotoPos.x && this.photoSwipable) {
3115        this.photoSwipable = false;
3116        this.zoomOutPhoto();
3117      } else {
3118        this.photoSwipable = false;
3119
3120        var item = this._getSelectedItem();
3121
3122        var bound = this._makeBound(item);
3123
3124        var offset = this.data.swipeOffset * this.data.scaleSize;
3125        var flagX = 0;
3126        var flagY = 0;
3127
3128        if (this.data.photoPosX > bound.maxX) {
3129          flagX = -1;
3130        } else if (this.data.photoPosX < bound.minX) {
3131          flagX = 1;
3132        }
3133
3134        if (this.data.photoPosY > bound.maxY) {
3135          flagY = -1;
3136        } else if (this.data.photoPosY < bound.minY) {
3137          flagY = 1;
3138        }
3139
3140        if (this.data.photoPosX - bound.maxX > offset && this.data.currentIndex !== 0) {
3141          this.gotoSlide(this.data.prev);
3142          return;
3143        }
3144
3145        if (bound.minX - this.data.photoPosX > offset && this.data.currentIndex + 1 !== this.data.total) {
3146          this.gotoSlide(this.data.next);
3147          return;
3148        } // todo
3149        // if(this.data.photoPosY - bound.maxY > offset) {
3150        //   this.hidePhoto();
3151        //   return;
3152        // }
3153
3154
3155        if (flagX === 0 && flagY === 0) {
3156          this.vx = this.photoVX / 5;
3157          this.vy = this.photoVY / 5;
3158        } else {
3159          this._registerElasticForce(flagX, flagY);
3160        }
3161      }
3162    }
3163  }, {
3164    key: "beforeGesture",
3165    value: function beforeGesture() {
3166      this._fireEvent('gesturestart');
3167
3168      var pos = this._getGesturePos(this.e);
3169
3170      var distance = this._getDistance(pos[0], pos[1]);
3171
3172      this.isBeingZoomed = true;
3173      this.oldDistance = distance;
3174      this.data.scale = true;
3175      this.e.preventDefault();
3176    }
3177  }, {
3178    key: "onGesture",
3179    value: function onGesture() {
3180      var pos = this._getGesturePos(this.e);
3181
3182      var distance = this._getDistance(pos[0], pos[1]);
3183
3184      var size = (distance - this.oldDistance) / 100;
3185      var oldScaleSize = this.data.scaleSize;
3186      var posX = this.data.photoPosX;
3187      var posY = this.data.photoPosY;
3188      this.isBeingZoomed = true;
3189      this.data.scaleSize += this._round(size, 6);
3190
3191      if (this.data.scaleSize < 0.2) {
3192        this.data.scaleSize = 0.2;
3193      } // todo
3194
3195
3196      if (this.data.scaleSize < oldScaleSize) {
3197        this.data.photoPosX = (1 + this.data.scaleSize - oldScaleSize) * posX;
3198        this.data.photoPosY = (1 + this.data.scaleSize - oldScaleSize) * posY;
3199      }
3200
3201      if (this.data.scaleSize < 1 || this.data.scaleSize > this._getScaleBoarder()) {
3202        this.data.hideUi = true;
3203      } else {
3204        this.data.hideUi = false;
3205      }
3206
3207      this.oldDistance = distance;
3208      this.e.preventDefault();
3209
3210      this._photoUpdate();
3211    }
3212  }, {
3213    key: "afterGesture",
3214    value: function afterGesture() {
3215      if (this.data.scaleSize > this._getScaleBoarder()) {
3216        return;
3217      }
3218
3219      this.data.photoPosX = 0;
3220      this.data.photoPosY = 0;
3221      this.data.scale = false;
3222      this.data.scaleSize = 1;
3223      this.data.hideUi = false;
3224
3225      this._fireEvent('gestureend');
3226
3227      this._photoUpdate();
3228    }
3229  }, {
3230    key: "_getForceAndTheta",
3231    value: function _getForceAndTheta(vx, vy) {
3232      return {
3233        force: Math.sqrt(vx * vx + vy * vy),
3234        theta: Math.atan2(vy, vx)
3235      };
3236    }
3237  }, {
3238    key: "_getScaleBoarder",
3239    value: function _getScaleBoarder() {
3240      var item = this._getSelectedItem();
3241
3242      var windowWidth = this._getWindowWidth();
3243
3244      var windowHeight = this._getWindowHeight();
3245
3246      if (!util.isSmartPhone()) {
3247        return 1 / item.scale;
3248      }
3249
3250      if (item.width > item.height) {
3251        return windowHeight / (item.height * item.scale);
3252      }
3253
3254      return windowWidth / (item.width * item.scale);
3255    }
3256  }, {
3257    key: "_makeBound",
3258    value: function _makeBound(item) {
3259      var width = item.width * item.scale * this.data.scaleSize;
3260      var height = item.height * item.scale * this.data.scaleSize;
3261      var minX;
3262      var minY;
3263      var maxX;
3264      var maxY;
3265
3266      var windowWidth = this._getWindowWidth();
3267
3268      var windowHeight = this._getWindowHeight();
3269
3270      if (windowWidth > width) {
3271        maxX = (windowWidth - width) / 2;
3272        minX = -1 * maxX;
3273      } else {
3274        maxX = (width - windowWidth) / 2;
3275        minX = -1 * maxX;
3276      }
3277
3278      if (windowHeight > height) {
3279        maxY = (windowHeight - height) / 2;
3280        minY = -1 * maxY;
3281      } else {
3282        maxY = (height - windowHeight) / 2;
3283        minY = -1 * maxY;
3284      }
3285
3286      return {
3287        minX: this._round(minX, 6) * this.data.scaleSize,
3288        minY: this._round(minY, 6) * this.data.scaleSize,
3289        maxX: this._round(maxX, 6) * this.data.scaleSize,
3290        maxY: this._round(maxY, 6) * this.data.scaleSize
3291      };
3292    }
3293  }, {
3294    key: "_registerElasticForce",
3295    value: function _registerElasticForce(x, y) {
3296      var _this13 = this;
3297
3298      var item = this._getSelectedItem();
3299
3300      var bound = this._makeBound(item);
3301
3302      this.data.elastic = true;
3303
3304      if (x === 1) {
3305        this.data.photoPosX = bound.minX;
3306      } else if (x === -1) {
3307        this.data.photoPosX = bound.maxX;
3308      }
3309
3310      if (y === 1) {
3311        this.data.photoPosY = bound.minY;
3312      } else if (y === -1) {
3313        this.data.photoPosY = bound.maxY;
3314      }
3315
3316      this._photoUpdate();
3317
3318      setTimeout(function () {
3319        _this13.data.elastic = false;
3320
3321        _this13._photoUpdate();
3322      }, 300);
3323    }
3324  }, {
3325    key: "_getSelectedItem",
3326    value: function _getSelectedItem() {
3327      var data = this.data;
3328      var index = data.currentIndex;
3329      return data.group[data.currentGroup][index];
3330    }
3331  }, {
3332    key: "_getUniqId",
3333    value: function _getUniqId() {
3334      return (Date.now().toString(36) + Math.random().toString(36).substr(2, 5)).toUpperCase();
3335    }
3336  }, {
3337    key: "_getDistance",
3338    value: function _getDistance(point1, point2) {
3339      var x = point1.x - point2.x;
3340      var y = point1.y - point2.y;
3341      return Math.sqrt(x * x + y * y);
3342    }
3343  }, {
3344    key: "_round",
3345    value: function _round(val, precision) {
3346      var digit = Math.pow(10, precision);
3347      val *= digit;
3348      val = Math.round(val);
3349      val /= digit;
3350      return val;
3351    }
3352  }, {
3353    key: "_isTouched",
3354    value: function _isTouched(e) {
3355      if (e && e.touches) {
3356        return true;
3357      }
3358
3359      return false;
3360    }
3361  }, {
3362    key: "_isGestured",
3363    value: function _isGestured(e) {
3364      if (e && e.touches && e.touches.length > 1) {
3365        return true;
3366      }
3367
3368      return false;
3369    }
3370  }, {
3371    key: "_isSmartPhone",
3372    value: function _isSmartPhone() {
3373      var agent = navigator.userAgent;
3374
3375      if (agent.indexOf('iPhone') > 0 || agent.indexOf('iPad') > 0 || agent.indexOf('ipod') > 0 || agent.indexOf('Android') > 0) {
3376        return true;
3377      }
3378
3379      return false;
3380    }
3381  }, {
3382    key: "_calcGravity",
3383    value: function _calcGravity(gamma, beta) {
3384      if (gamma > 5 || gamma < -5) {
3385        this.vx += gamma * 0.05;
3386      }
3387
3388      if (this.data.verticalGravity === false) {
3389        return;
3390      }
3391
3392      if (beta > 5 || beta < -5) {
3393        this.vy += beta * 0.05;
3394      }
3395    }
3396  }, {
3397    key: "_photoUpdate",
3398    value: function _photoUpdate() {
3399      var classNames = this.data.classNames;
3400
3401      var current = this._getElementByQuery('.current');
3402
3403      var img = current.querySelector(".".concat(classNames.smartPhotoImg));
3404
3405      var nav = this._getElementByQuery(".".concat(classNames.smartPhotoNav));
3406
3407      var arrows = this._getElementByQuery(".".concat(classNames.smartPhotoArrows));
3408
3409      var photoPosX = this.virtualPos(this.data.photoPosX);
3410      var photoPosY = this.virtualPos(this.data.photoPosY);
3411      var scaleSize = this.data.scaleSize;
3412      var transform = "translate(".concat(photoPosX, "px,").concat(photoPosY, "px) scale(").concat(scaleSize, ")");
3413      img.style.transform = transform;
3414
3415      if (this.data.scale) {
3416        util.addClass(img, classNames.smartPhotoImgOnMove);
3417      } else {
3418        util.removeClass(img, classNames.smartPhotoImgOnMove);
3419      }
3420
3421      if (this.data.elastic) {
3422        util.addClass(img, classNames.smartPhotoImgElasticMove);
3423      } else {
3424        util.removeClass(img, classNames.smartPhotoImgElasticMove);
3425      }
3426
3427      if (this.data.hideUi) {
3428        if (nav) {
3429          nav.setAttribute('aria-hidden', 'true');
3430        }
3431
3432        if (arrows) {
3433          arrows.setAttribute('aria-hidden', 'true');
3434        }
3435      } else {
3436        if (nav) {
3437          nav.setAttribute('aria-hidden', 'false');
3438        }
3439
3440        if (arrows) {
3441          arrows.setAttribute('aria-hidden', 'false');
3442        }
3443      }
3444    }
3445  }, {
3446    key: "_getWindowWidth",
3447    value: function _getWindowWidth() {
3448      if (document && document.documentElement) {
3449        return document.documentElement.clientWidth;
3450      } else if (window && window.innerWidth) {
3451        return window.innerWidth;
3452      }
3453
3454      return 0;
3455    }
3456  }, {
3457    key: "_getWindowHeight",
3458    value: function _getWindowHeight() {
3459      if (document && document.documentElement) {
3460        return document.documentElement.clientHeight;
3461      } else if (window && window.innerHeight) {
3462        return window.innerHeight;
3463      }
3464
3465      return 0;
3466    }
3467  }, {
3468    key: "_listUpdate",
3469    value: function _listUpdate() {
3470      var classNames = this.data.classNames;
3471
3472      var list = this._getElementByQuery(".".concat(classNames.smartPhotoList));
3473
3474      var transform = "translate(".concat(this.data.translateX, "px,").concat(this.data.translateY, "px)");
3475      list.style.transform = transform; // $list
3476
3477      if (this.data.onMoveClass) {
3478        util.addClass(list, classNames.smartPhotoListOnMove);
3479      } else {
3480        util.removeClass(list, classNames.smartPhotoListOnMove);
3481      }
3482    }
3483  }, {
3484    key: "_fireEvent",
3485    value: function _fireEvent(eventName) {
3486      var photo = this._getElementByClass(this.data.classNames.smartPhoto);
3487
3488      util.triggerEvent(photo, eventName);
3489    }
3490  }, {
3491    key: "_doAnim",
3492    value: function _doAnim() {
3493      if (this.isBeingZoomed || this.isSwipable || this.photoSwipable || this.data.elastic || !this.data.scale) {
3494        return;
3495      }
3496
3497      this.data.photoPosX += this.vx;
3498      this.data.photoPosY += this.vy;
3499
3500      var item = this._getSelectedItem();
3501
3502      var bound = this._makeBound(item);
3503
3504      if (this.data.photoPosX < bound.minX) {
3505        this.data.photoPosX = bound.minX;
3506        this.vx *= -0.2;
3507      } else if (this.data.photoPosX > bound.maxX) {
3508        this.data.photoPosX = bound.maxX;
3509        this.vx *= -0.2;
3510      }
3511
3512      if (this.data.photoPosY < bound.minY) {
3513        this.data.photoPosY = bound.minY;
3514        this.vy *= -0.2;
3515      } else if (this.data.photoPosY > bound.maxY) {
3516        this.data.photoPosY = bound.maxY;
3517        this.vy *= -0.2;
3518      }
3519
3520      var power = this._getForceAndTheta(this.vx, this.vy);
3521
3522      var force = power.force;
3523      var theta = power.theta;
3524      force -= this.data.registance;
3525
3526      if (Math.abs(force) < 0.5) {
3527        return;
3528      }
3529
3530      this.vx = Math.cos(theta) * force;
3531      this.vy = Math.sin(theta) * force;
3532
3533      this._photoUpdate();
3534    }
3535  }]);
3536
3537  return SmartPhoto;
3538}(_aTemplate["default"]);
3539
3540exports["default"] = SmartPhoto;
3541module.exports = exports["default"];
3542
3543},{"../lib/util":11,"a-template":1,"custom-event-polyfill":3,"es6-promise-polyfill":4}
3543],10:[function(require,module,exports){
3544'use strict';
3545
3546module.exports = require('./core/');
3547
3548},{"./core/":9}],11:[function(require,module,exports){
3549"use strict";
3550
3551Object.defineProperty(exports, "__esModule", {
3552  value: true
3553});
3554exports.isOldIE = exports.getBrowser = exports.removeClass = exports.addClass = exports.append = exports.removeElement = exports.getViewPos = exports.parseQuery = exports.triggerEvent = exports.extend = exports.isSmartPhone = void 0;
3555
3556function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
3557
3558var isSmartPhone = function isSmartPhone() {
3559  var agent = navigator.userAgent;
3560
3561  if (agent.indexOf('iPhone') > 0 || agent.indexOf('iPad') > 0 || agent.indexOf('ipod') > 0 || agent.indexOf('Android') > 0) {
3562    return true;
3563  } else {
3564    return false;
3565  }
3566};
3567
3568exports.isSmartPhone = isSmartPhone;
3569
3570function deepExtend(out) {
3571  out = out || {};
3572
3573  for (var i = 1; i < arguments.length; i++) {
3574    var obj = arguments[i];
3575
3576    if (!obj) {
3577      continue;
3578    }
3579
3580    for (var key in obj) {
3581      if (obj.hasOwnProperty(key)) {
3582        if (_typeof(obj[key]) === 'object') out[key] = deepExtend(out[key], obj[key]);else out[key] = obj[key];
3583      }
3584    }
3585  }
3586
3587  return out;
3588}
3589
3590;
3591var extend = deepExtend;
3592exports.extend = extend;
3593
3594var triggerEvent = function triggerEvent(el, eventName, options) {
3595  var event;
3596
3597  if (window.CustomEvent) {
3598    event = new CustomEvent(eventName, {
3599      cancelable: true
3600    });
3601  } else {
3602    event = document.createEvent('CustomEvent');
3603    event.initCustomEvent(eventName, false, false, options);
3604  }
3605
3606  el.dispatchEvent(event);
3607};
3608
3609exports.triggerEvent = triggerEvent;
3610
3611var parseQuery = function parseQuery(query) {
3612  var s = query.split('&'),
3613      data = {},
3614      i = 0,
3615      iz = s.length,
3616      param,
3617      key,
3618      value;
3619
3620  for (; i < iz; i++) {
3621    param = s[i].split('=');
3622
3623    if (param[0] !== void 0) {
3624      key = param[0];
3625      value = param[1] !== void 0 ? param.slice(1).join('=') : key;
3626      data[key] = decodeURIComponent(value);
3627    }
3628  }
3629
3630  return data;
3631};
3632
3633exports.parseQuery = parseQuery;
3634
3635var getViewPos = function getViewPos(element) {
3636  return {
3637    left: element.getBoundingClientRect().left,
3638    top: element.getBoundingClientRect().top
3639  };
3640};
3641
3642exports.getViewPos = getViewPos;
3643
3644var removeElement = function removeElement(element) {
3645  if (element && element.parentNode) {
3646    element.parentNode.removeChild(element);
3647  }
3648};
3649
3650exports.removeElement = removeElement;
3651
3652var append = function append(element, string) {
3653  var div = document.createElement('div');
3654  div.innerHTML = string;
3655
3656  while (div.children.length > 0) {
3657    element.appendChild(div.children[0]);
3658  }
3659};
3660
3661exports.append = append;
3662
3663var addClass = function addClass(element, className) {
3664  if (element.classList) {
3665    element.classList.add(className);
3666  } else {
3667    element.className += " ".concat(className);
3668  }
3669};
3670
3671exports.addClass = addClass;
3672
3673var removeClass = function removeClass(element, className) {
3674  if (element.classList) {
3675    element.classList.remove(className);
3676  } else {
3677    element.className = element.className.replace(new RegExp('(^|\\b)' + className.split(' ').join('|') + '(\\b|$)', 'gi'), ' ');
3678  }
3679};
3680
3681exports.removeClass = removeClass;
3682
3683var getBrowser = function getBrowser() {
3684  var ua = window.navigator.userAgent.toLowerCase();
3685  var ver = window.navigator.appVersion.toLowerCase();
3686  var name = 'unknown';
3687
3688  if (ua.indexOf('msie') != -1) {
3689    if (ver.indexOf('msie 6.') != -1) {
3690      name = 'ie6';
3691    } else if (ver.indexOf('msie 7.') != -1) {
3692      name = 'ie7';
3693    } else if (ver.indexOf('msie 8.') != -1) {
3694      name = 'ie8';
3695    } else if (ver.indexOf('msie 9.') != -1) {
3696      name = 'ie9';
3697    } else if (ver.indexOf('msie 10.') != -1) {
3698      name = 'ie10';
3699    } else {
3700      name = 'ie';
3701    }
3702  } else if (ua.indexOf('trident/7') != -1) {
3703    name = 'ie11';
3704  } else if (ua.indexOf('chrome') != -1) {
3705    name = 'chrome';
3706  } else if (ua.indexOf('safari') != -1) {
3707    name = 'safari';
3708  } else if (ua.indexOf('opera') != -1) {
3709    name = 'opera';
3710  } else if (ua.indexOf('firefox') != -1) {
3711    name = 'firefox';
3712  }
3713
3714  return name;
3715};
3716
3717exports.getBrowser = getBrowser;
3718
3719var isOldIE = function isOldIE() {
3720  var browser = getBrowser();
3721
3722  if (browser.indexOf('ie') !== -1) {
3723    if (parseInt(browser.replace(/[^0-9]/g, '')) <= 10) {
3724      return true;
3725    }
3726  }
3727
3728  return false;
3729};
3730
3731exports.isOldIE = isOldIE;
3732
3733},{}]},{},[10])(10)
3734});

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.