d1-web
Version: 
Lightweight responsive front-end framework
1,554 lines (1,349 loc) • 181 kB
JavaScript
/*! d1-web v2.7.5 */
(function () {
  'use strict';
  if (!Element.prototype.matches) {
    Element.prototype.matches = Element.prototype.msMatchesSelector || Element.prototype.webkitMatchesSelector;
  }
  if (!Element.prototype.closest) {
    Element.prototype.closest = function (s) {
      var el = this;
      do {
        if (el.matches(s)) return el;
        el = el.parentElement || el.parentNode;
      } while (el !== null && el.nodeType === 1);
      return null;
    };
  }
  function _classCallCheck(instance, Constructor) {
    if (!(instance instanceof Constructor)) {
      throw new TypeError("Cannot call a class as a 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);
    }
  }
  function _createClass(Constructor, protoProps, staticProps) {
    if (protoProps) _defineProperties(Constructor.prototype, protoProps);
    if (staticProps) _defineProperties(Constructor, staticProps);
    return Constructor;
  }
  function _defineProperty(obj, key, value) {
    if (key in obj) {
      Object.defineProperty(obj, key, {
        value: value,
        enumerable: true,
        configurable: true,
        writable: true
      });
    } else {
      obj[key] = value;
    }
    return obj;
  }
  function ownKeys(object, enumerableOnly) {
    var keys = Object.keys(object);
    if (Object.getOwnPropertySymbols) {
      var symbols = Object.getOwnPropertySymbols(object);
      if (enumerableOnly) symbols = symbols.filter(function (sym) {
        return Object.getOwnPropertyDescriptor(object, sym).enumerable;
      });
      keys.push.apply(keys, symbols);
    }
    return keys;
  }
  function _objectSpread2(target) {
    for (var i = 1; i < arguments.length; i++) {
      var source = arguments[i] != null ? arguments[i] : {};
      if (i % 2) {
        ownKeys(Object(source), true).forEach(function (key) {
          _defineProperty(target, key, source[key]);
        });
      } else if (Object.getOwnPropertyDescriptors) {
        Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
      } else {
        ownKeys(Object(source)).forEach(function (key) {
          Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
        });
      }
    }
    return target;
  }
  function _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);
  }
  function _getPrototypeOf(o) {
    _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) {
      return o.__proto__ || Object.getPrototypeOf(o);
    };
    return _getPrototypeOf(o);
  }
  function _setPrototypeOf(o, p) {
    _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) {
      o.__proto__ = p;
      return o;
    };
    return _setPrototypeOf(o, p);
  }
  function _isNativeReflectConstruct() {
    if (typeof Reflect === "undefined" || !Reflect.construct) return false;
    if (Reflect.construct.sham) return false;
    if (typeof Proxy === "function") return true;
    try {
      Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {}));
      return true;
    } catch (e) {
      return false;
    }
  }
  function _assertThisInitialized(self) {
    if (self === void 0) {
      throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
    }
    return self;
  }
  function _possibleConstructorReturn(self, call) {
    if (call && (typeof call === "object" || typeof call === "function")) {
      return call;
    }
    return _assertThisInitialized(self);
  }
  function _createSuper(Derived) {
    var hasNativeReflectConstruct = _isNativeReflectConstruct();
    return function _createSuperInternal() {
      var Super = _getPrototypeOf(Derived),
          result;
      if (hasNativeReflectConstruct) {
        var NewTarget = _getPrototypeOf(this).constructor;
        result = Reflect.construct(Super, arguments, NewTarget);
      } else {
        result = Super.apply(this, arguments);
      }
      return _possibleConstructorReturn(this, result);
    };
  }
  function _toConsumableArray(arr) {
    return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread();
  }
  function _arrayWithoutHoles(arr) {
    if (Array.isArray(arr)) return _arrayLikeToArray(arr);
  }
  function _iterableToArray(iter) {
    if (typeof Symbol !== "undefined" && Symbol.iterator in Object(iter)) return Array.from(iter);
  }
  function _unsupportedIterableToArray(o, minLen) {
    if (!o) return;
    if (typeof o === "string") return _arrayLikeToArray(o, minLen);
    var n = Object.prototype.toString.call(o).slice(8, -1);
    if (n === "Object" && o.constructor) n = o.constructor.name;
    if (n === "Map" || n === "Set") return Array.from(o);
    if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
  }
  function _arrayLikeToArray(arr, len) {
    if (len == null || len > arr.length) len = arr.length;
    for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i];
    return arr2;
  }
  function _nonIterableSpread() {
    throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
  }
  /*! app - core of d1-web */
  // (() => {
  // const main = new (function () {
  var _default$m = /*#__PURE__*/function () {
    function _default() {
      _classCallCheck(this, _default);
      this.sequence = 0;
      this.plugins = {};
      this.handlers = {};
      this.opt = {
        plug: {},
        debug: 0,
        cAct: 'act',
        cHide: 'hide',
        cToggle: 'toggle',
        cOff: 'off',
        cClose: 'close',
        cJs: 'js',
        hClose: '#cancel',
        hOk: '#ok',
        sCancel: 'Cancel',
        sOk: 'OK'
      };
    }
    _createClass(_default, [{
      key: "init",
      value: function init(opt) {
        var _this = this;
        // console.time('start');
        document.body.classList.add(this.opt.cJs); // prepare body: anti-hover, anti-target
        this.fire('start'); //options
        if (!opt) {
          opt = document.body.dataset.d1;
          if (opt) opt = this.parse(opt);
        }
        this.setOpt(opt);
        this.dbg(['opt', this.opt]);
        this.fire('options');
        this.initPlugins(); // plugins
        // bind events
        this.b([window], 'hashchange', function (e) {
          return _this.on('hashchange', e);
        }); // on window
        this.b([document], ['invalid', 'focus', 'blur'], function (e) {
          return _this.on(e.type, e);
        }, true); //useCapture
        this.b([document], ['click', 'keydown', 'input', 'change', 'submit'], function (e) {
          return _this.on(e.type, e);
        });
        if (location.hash) this.on('hashchange');
        this.fire('after');
        this.fire('ready');
      } // event delegation
      // https://gomakethings.com/why-event-delegation-is-a-better-way-to-listen-for-events-in-vanilla-js/
    }, {
      key: "on",
      value: function on(t, e) {
        this.fire('before', e);
        this.fire(t, e); //this.fire(t + 'ed', e)
        //if (!e || !e.defaultPrevented)
        this.fire('after', e);
      }
    }, {
      key: "arrange",
      value: function arrange(n) {
        if (n) this.fire('arrange', {
          n: n
        });
      } //plugins
    }, {
      key: "setOpt",
      value: function setOpt(opt) {
        var _this2 = this;
        if (opt) Object.keys(opt)
        /*.filter(k => k != 'plug')*/
        .forEach(function (k) {
          return _this2.opt[k] = opt[k];
        });
      }
    }, {
      key: "plug",
      value: function plug(c, n) {
        var p = new c();
        this.plugins[n || p.name] = p;
      }
    }, {
      key: "initPlugins",
      value: function initPlugins() {
        var _this3 = this;
        if (this.opt.disable) this.opt.disable.forEach(function (p) {
          return delete _this3.plugins[p];
        });
        this.dbg(['plugins', this.plugins]);
        Object.keys(this.plugins).forEach(function (k) {
          _this3.plugins[k].install(_this3);
          _this3.fire('plugin', {
            name: k,
            plugin: _this3.plugins[k]
          });
        });
        this.fire('init');
        this.fire('arrange'); // , {n: document.body}
        this.fire('plugins');
      } // call method of plugin
    }, {
      key: "pf",
      value: function pf(p, f) {
        var _this$plugins$p;
        for (var _len = arguments.length, a = new Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++) {
          a[_key - 2] = arguments[_key];
        }
        if (this.plugins[p] && this.plugins[p][f]) (_this$plugins$p = this.plugins[p])[f].apply(_this$plugins$p, a);else this.dbg(['no plugin function', p + '.' + f + '()'], -1);
      }
    }, {
      key: "toggle",
      value: function toggle() {
        for (var _len2 = arguments.length, a = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
          a[_key2] = arguments[_key2];
        }
        this.pf.apply(this, ['toggle', 'toggle'].concat(a));
      }
    }, {
      key: "fetch",
      value: function fetch() {
        for (var _len3 = arguments.length, a = new Array(_len3), _key3 = 0; _key3 < _len3; _key3++) {
          a[_key3] = arguments[_key3];
        }
        this.pf.apply(this, ['fetch', 'fetch'].concat(a));
      }
    }, {
      key: "dialog",
      value: function dialog() {
        for (var _len4 = arguments.length, a = new Array(_len4), _key4 = 0; _key4 < _len4; _key4++) {
          a[_key4] = arguments[_key4];
        }
        this.pf.apply(this, ['dialog', 'openDialog'].concat(a));
      } //events
    }, {
      key: "fire",
      value: function fire(et, e) {
        var _e,
            _this4 = this;
        e = (_e = e) !== null && _e !== void 0 ? _e : {};
        if (!e.type) e.type = et;
        this.dbg(['fire ' + et, e]);
        if (this.handlers[et]) this.handlers[et].forEach(function (h) {
          var _e2;
          return (_e2 = e) !== null && _e2 !== void 0 && _e2.unfire ? null : h.call(_this4, e);
        });
      }
    }, {
      key: "listen",
      value: function listen(et, f) {
        //if (!this.handlers[et]) this.handlers[et] = []
        //this.handlers[et].push(f)
        this.h(et, '', f);
      } //handle
    }, {
      key: "h",
      value: function h(et, s, f, before) {
        var _this5 = this;
        if (et instanceof Array) et.forEach(function (ett) {
          return _this5.h(ett, s, f, before);
        });else {
          if (!this.handlers[et]) this.handlers[et] = [];
          this.handlers[et][before ? 'unshift' : 'push'](function (e) {
            if (s) e.recv = e.target.closest ? e.target.closest(s) : null;
            if (!s || e.recv) f(e);
          });
        }
      }
    }, {
      key: "dispatch",
      value: function dispatch(n, et, p) {
        // {view: window, bubbles: true, cancelable: true, composed: false}
        if (!p) p = {
          bubbles: true,
          cancelable: true,
          view: window
        };
        if (typeof Event === 'function') {
          //-ie
          if (et instanceof Array) et.forEach(function (ett) {
            return n.dispatchEvent(new Event(ett, p));
          });else n.dispatchEvent(new Event(et, p));
        }
      } //utils
      // debug
    }, {
      key: "isDebug",
      value: function isDebug(l) {
        return this.opt.debug > (l || 0) || location.href.indexOf('d1debug') != -1;
      }
    }, {
      key: "dbg",
      value: function dbg(s, l, e) {
        if (this.isDebug(l)) console[e || l < 0 ? 'error' : 'log'](s);
      } // sequence for IDs of generated nodes
    }, {
      key: "seq",
      value: function seq() {
        return ++this.sequence;
      } // convert to array
    }, {
      key: "a",
      value: function a(c) {
        return c ? Array.prototype.slice.call(c) : c;
      } // get object item by path
    }, {
      key: "path",
      value: function path(r, p, def) {
        if (p) {
          if (this.typeOf(p) === 'string') p = p.split('.');
          for (var i = 0; i < p.length; i++) {
            if (p[i] || p[i] === 0) {
              if (r === null || r[p[i]] === undefined) return def;
              r = r[p[i]];
            }
          }
        }
        return r;
      } // find node
    }, {
      key: "q",
      value: function q(s, n) {
        try {
          return (n || document).querySelector(s);
        } catch (e) {
          return null;
        }
      } // find nodes
    }, {
      key: "qq",
      value: function qq(s, n) {
        try {
          return this.a((n || document).querySelectorAll(s));
        } catch (e) {
          return [];
        }
      }
    }, {
      key: "next",
      value: function next(n, s, prev) {
        while (n = n[prev ? 'previousElementSibling' : 'nextElementSibling']) {
          if (n.matches(s)) return n;
        }
      }
    }, {
      key: "nn",
      value: function nn(q) {
        if (!q) return [];else if (typeof q === 'string') return this.qq(q);else if (q.tagName) return [q];else return this.a(q);
      } // add event listener
    }, {
      key: "b",
      value: function b(q, et, f, capt) {
        if (!et) this.e(q, f);
        if (f) this.nn(q).forEach(function (n) {
          return et instanceof Array ? et.forEach(function (ett) {
            return n.addEventListener(ett, function (e) {
              return f(e);
            }, capt);
          }) : n.addEventListener(et, function (e) {
            return f(e);
          }
          /*f.bind(this)*/
          , capt);
        });
      } // execute for each node
    }, {
      key: "e",
      value: function e(q, f) {
        var _this6 = this;
        if (f) this.nn(q).forEach(function (n) {
          return f.call(_this6, n);
        });
      } // execute for each node inside some node
    }, {
      key: "ee",
      value: function ee(n, q, f) {
        this.e(this.qq(q, n), f);
      } // add/remove classes
    }, {
      key: "cls",
      value: function cls(n, add, del, rev) {
        var _this7 = this,
            _n$classList,
            _n$classList2;
        var a = rev ? [del, add] : [add, del];
        a = a.map(function (c) {
          return !c || _this7.typeOf(c) === 'array' ? c : c.split(/\s+/).filter(function (x) {
            return x;
          });
        });
        if (a[1]) (_n$classList = n.classList).remove.apply(_n$classList, _toConsumableArray(a[1]));
        if (a[0]) (_n$classList2 = n.classList).add.apply(_n$classList2, _toConsumableArray(a[0]));
      }
    }, {
      key: "typeOf",
      value: function typeOf(v) {
        return Object.prototype.toString.call(v).slice(8, -1).toLowerCase();
      }
    }, {
      key: "parse",
      value: function parse(j, def) {
        var r = '';
        try {
          r = JSON.parse(j);
        } catch (e) {
          this.dbg(['JSON parse failed', j], -1);
          r = def === true ? j : def === undefined ? null : def;
        }
        return r;
      } // insert node
      //pos: -1=before, false=prepend, 0=append(default), 1=after
    }, {
      key: "ins",
      value: function ins(tag, t, attrs, n, pos) {
        var c = document.createElement(tag || 'span');
        if (this.typeOf(t) === 'array') t.forEach(function (m) {
          return m.nodeType ? c.appendChild(m) : c.innerHTML += m;
        });else if (t && t.nodeType) c.appendChild(t);else if (t) c.innerHTML = t;
        if (attrs) {
          if (this.typeOf(attrs) === 'string') attrs = {
            className: attrs
          };
          for (var i in attrs) {
            if (attrs[i] !== null && attrs[i] !== undefined) {
              if (i.match(/-/)) c.setAttribute(i.replace(/^-/, ''), attrs[i]);else c[i] = attrs[i];
            }
          }
        }
        return n ? pos ? n.parentNode.insertBefore(c, pos < 0 ? n : n.nextSibling) : pos === false ? n.insertBefore(c, n.firstChild) : n.appendChild(c) : c;
      } // remove all children
    }, {
      key: "clr",
      value: function clr(n) {
        if (n) while (n.firstChild) {
          n.removeChild(n.firstChild);
        }
      } // insert close link with icon
    }, {
      key: "x",
      value: function x(d, pos, cls) {
        return this.ins('a', this.i('close', '✕'), {
          href: this.opt.hClose,
          className: cls || ''
        }, d, pos);
      } // insert icon
    }, {
      key: "i",
      value: function i(ico, alt) {
        return this.plugins.icons ? this.plugins.icons.i(ico, alt) : this.ins('span', alt || ico);
      } // get node toggle status
    }, {
      key: "vis",
      value: function vis(n) {
        return n && !n.classList.contains(this.opt.cOff);
      } // fix clone IDs
    }, {
      key: "fixIds",
      value: function fixIds(m) {
        var _this8 = this;
        this.ee(m, '[id]', function (n) {
          var x = n.id;
          var id = 'id-' + _this8.seq();
          n.id = id;
          _this8.ee(m, 'a[href="#' + x + '"]', function (a) {
            return a.href = '#' + id;
          });
          _this8.ee(m, 'label[for="' + x + '"]', function (a) {
            return a.htmlFor = id;
          });
        });
      }
    }]);
    return _default;
  }(); // listen to all events
  /*! func - function derorators */
  var Func = /*#__PURE__*/function () {
    function Func() {
      _classCallCheck(this, Func);
    }
    _createClass(Func, null, [{
      key: "throttle",
      value: function throttle(f, ms) {
        var p = false,
            c,
            a;
        return function ff() {
          if (p) {
            //2
            c = this;
            a = arguments;
          } else {
            f.apply(this, arguments); //1
            p = true;
            setTimeout(function () {
              //3
              p = false;
              if (a) {
                ff.apply(c, a);
                a = c = null;
              }
            }, ms);
          }
        };
      }
    }, {
      key: "delay",
      value: function delay(f, ms, skip) {
        var p = null;
        return function () {
          var _arguments = arguments,
              _this = this;
          if (skip && p) clearTimeout(p);
          p = setTimeout(function () {
            f.apply(_this, _arguments);
            p = null;
          }, ms);
        };
      }
    }, {
      key: "debounce",
      value: function debounce(f, ms) {
        return Func.delay(f, ms, true);
      }
    }]);
    return Func;
  }();
  /*! date - parse and format date */
  var Dt = /*#__PURE__*/function () {
    function Dt() {
      _classCallCheck(this, Dt);
    }
    _createClass(Dt, null, [{
      key: "parse",
      value: function parse(s) {
        var d = '';
        var m = (s || '').match(/^(\d+)([\-\.\/\s])(\d+)[\-\.\/\s](\d+)(\D(\d+))?(\D(\d+))?(\D(\d+))?(\D(\d+))?$/);
        if (m) {
          var x;
          if (m[2] == '.') x = [4, 3, 1]; //d.m.Y
          else if (m[2] == '/') x = [4, 1, 3]; //m/d Y
            else x = [1, 3, 4]; //Y-m-d
          d = new Date(m[x[0]], m[x[1]] - 1, m[x[2]], m[6] || 0, m[8] || 0, m[10] || 0, m[12] || 0); //return d ? d.getTime() : NaN;
        }
        return d; // || NaN;
      }
      /*
        x: date object
        t: include time
        f: y=Y-m-d (default), d=d.m.Y, m=m/d Y, i=ISO
      */
    }, {
      key: "fmt",
      value: function fmt(x, t, f) {
        if (!x) return '';
        if (f == 'i') {
          return new Date(x - x.getTimezoneOffset() * 60000).toISOString().replace(/Z$/, '').substr(0, t ? 30 : 10);
        }
        var y = x.getFullYear();
        var m = Dt.n(x.getMonth() + 1);
        var d = Dt.n(x.getDate());
        var h = Dt.n(x.getHours());
        var i = Dt.n(x.getMinutes());
        var s = Dt.n(x.getSeconds());
        return (f == 'm' ? m + '/' + d + ' ' + y : f == 'd' ? d + '.' + m + '.' + y : y + '-' + m + '-' + d) + (t && h + i + s > 0 ? ' ' + Dt.n(x.getHours()) + ':' + Dt.n(x.getMinutes()) + ':' + Dt.n(x.getSeconds()) : '');
      }
    }, {
      key: "n",
      value: function n(v, l) {
        return ('000' + v).substr(-(l || 2));
      }
    }]);
    return Dt;
  }();
  /*! url - url build and arguments */
  var Url = /*#__PURE__*/function () {
    function Url() {
      _classCallCheck(this, Url);
    }
    _createClass(Url, null, [{
      key: "build",
      value: // build url from link node or string, with additional parameters
      function build(a, args) {
        a = Url.url2a(a);
        var g = Url.get(true, a);
        Object.keys(args).forEach(function (k) {
          return g[encodeURIComponent(k)] = encodeURIComponent(args[k]);
        });
        var q = Object.keys(g).map(function (k) {
          return k + '=' + g[k];
        }).join('&');
        return a.host ? a.protocol + '//' + a.host + a.pathname + (q ? '?' + q : '') + a.hash : a.href.replace(/[\?#].*$/, '') + (q ? '?' + q : '') + a.hash; //ie
      } // get url parameter(s) from link node or string
    }, {
      key: "get",
      value: function get(g) {
        var a = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
        if (a === true) a = location.href;
        if (!a) return null;
        a = Url.url2a(a);
        var i,
            gets = {};
        var args = a.search ? a.search.replace(/^\?/, '').split('&') : [];
        for (i = 0; i < args.length; i++) {
          var v = args[i].split('=');
          gets[v[0]] = decodeURIComponent(v[1].replace(/\+/g, ' '));
        }
        return g === true ? gets : gets[g]; //protocol, host (hostname, port), pathname, search, hash
      }
    }, {
      key: "url2a",
      value: function url2a(a) {
        if (a && !a.tagName) {
          var h = a;
          a = document.createElement('a');
          a.href = h;
        }
        return a;
      }
    }]);
    return Url;
  }();
  var _default$l = /*#__PURE__*/function () {
    function _default(name) {
      _classCallCheck(this, _default);
      this.app = null;
      this.name = name || 'plugin';
      this.opt = {};
    }
    _createClass(_default, [{
      key: "install",
      value: function install(app) {
        var _this = this;
        if (!app.opt.plug[this.name]) app.opt.plug[this.name] = {};
        var opt = app.opt.plug[this.name];
        Object.keys(this.opt).forEach(function (k) {
          return k in opt ? null : opt[k] = _this.opt[k];
        });
        this.opt = opt; //
        this.app = app;
        this.app.listen('init', function (e) {
          return _this.init();
        });
        if (this.arrange) this.app.listen('arrange', function (e) {
          return _this.arrange(e);
        });
      }
    }, {
      key: "init",
      value: function init() {
        console.log('plugin.init()');
      }
    }]);
    return _default;
  }();
  /*! iconset - svg paths for building icons */
  // "module.exports" is used over "export default"
  // to work with build step "css-icons.js"
  var iconset = {
    menu: [7, 'M.5 1h6v1h-6zm0 2h6v1h-6zm0 2h6v1h-6z'],
    sort: [7, 'M1 1h2v1h-2zm0 2h3.5v1h-3.5zm0 2h5v1h-5z'],
    more: [17, 'M7 2h3v3h-3zm0 5h3v3h-3zm0 5h3v3h-3z'],
    grid: [7, 'M1 1h2v2h-2zM4 1h2v2h-2zM1 4h2v2h-2zM4 4h2v2h-2z'],
    home: [10, 'M1 4.8h1v4h2v-3h2v3h2v-4h1l-4-4z'],
    find: [12, 'M5 1a4 4 0 1 0 .01 0zm0 1a3 3 0 1 1-.01 0m3 5l-1 1 3 3 1-1z'],
    config: [220, 'M35 67l75 -44 75 44 0 89-75 44-75-44zm75 8a35 35 0 1 0 .01 0z'],
    close: [12, 'M2 1l4 4 4-4 1 1-4 4 4 4-1 1-4-4-4 4-1-1 4-4-4-4z'],
    user: [10, 'M5 9C13 -1.5 -3 -1.5 5 9zM1 8.5q4 1 8 0-4 -3 -8 0z'],
    exit: [10, 'M1 1h4v1h-3v6h3v1h-4zm2 3h3v-2l3 3-3 3v-2h-3z'],
    key: [20, 'M2 16l7-7v-4l3-3q7 0 7 7l-3 3h-4l-6 6h-4zm3 1h1l6-6h-1zm11-12a1.5 1.5 0 1 0 .01 .01z'],
    lock: [10, 'M1.5 4h7v5h-7zm1 0c0-4 5-4 5 0h-1c0-3-3-3-3 0zm2 1v2h1v-2z'],
    edit: [10, 'M7 1q1.6 .4 2 2l-5 5-3 1 1-3zM2.3 6.3l-.5 1.5.4.4 1.5-.5z'],
    add: [7, 'M3 1h1v2h2v1h-2v2h-1v-2h-2v-1h2z'],
    "delete": [20, 'M5 3l5 5 5-5 2 2-5 5 5 5-2 2-5-5-5 5-2-2 5-5-5-5z'],
    ok: [100, 'M10 48l11-9 18 22 40-50 11 9-51 65z'],
    up: [10, 'M1 6l4-4 4 4-1 1-3-3-3 3z'],
    down: [10, 'M1 4l4 4 4-4-1-1-3 3-3-3z'],
    left: [10, 'M6 1l1 1-3 3 3 3-1 1-4-4z'],
    right: [10, 'M4 1l4 4-4 4-1-1 3-3-3-3z'],
    asc: [12, 'M2 7l-1-1 5-5 5 5-1 1 -3.25 -3.2v7h-1.5v-7z'],
    desc: [12, 'M2 5l-1 1 5 5 5-5-1-1 -3.25 3.2v-7h-1.5v7z'],
    back: [12, 'M7 2l-1-1 -5 5 5 5 1-1 -3.2 -3.25h7v-1.5h-7z'],
    forward: [12, 'M5 2l 1-1 5 5 -5 5 -1-1 3.2 -3.25h-7v-1.5h7z'],
    upload: [10, 'M1 8h8v1h-8zm1-4h2v3h2v-3h2l-3-3z'],
    download: [10, 'M1 8h8v1h-8zm1-3.7h2v-3h2v3h2l-3 3z'],
    first: [12, 'M2 2h1.5v8h-1.5zm2 4l6-4v8z'],
    last: [12, 'M2 2v8l6-4zm6.5 0h1.5v8h-1.5z'],
    folder: [12, 'M1 1.5h4l1 2h5v7h-10zm1 3v5h8v-5z'],
    open: [12, 'M.5 1.5h4l1 2h6.3l-2.3 7h-9zm3 3l-2 5h7l2-5z'],
    file: [12, 'M2 1h5l3 3v7h-8zm1 1v8h6v-6h-2v-2z'],
    attach: [15, 'M4.5 11q0 3 3 3t3-3v-8q0-2-2-2t-2 2v7h1v-7q0-1 1-1t1 1v8q0 2-2 2t-2-2v-7h-1z'],
    audio: [19, 'M8 14h-1v-10l8-2v10h-1v-6.5l-6 1.5za3 2 -20 1 1 0 -.01zm7-2a3 2 -20 1 1 0 -.01z'],
    video: [12, 'M1 3h7v2l3-2v6l-3-2v2h-7z'],
    image: [12, 'M1 2h10v8h-10zm1 1v5l3-3 2 2 1-1 2 2 v-5zm5.5 .5a1 1 0 1 0 .001 0z'],
    text: [12, 'M2 1h5l3 3v7h-8zm1 1v8h6v-6h-2v-2zm1 4h4v1h-4zm0 2h4v1h-4z'],
    tree: [26, 'M9 3h8v6h-3v3h8v5h2v6h-6v-6h2v-3h-6v3h2v6h-6v-6h2v-3h-6v3h2v6h-6v-6h2v-5h8v-3h-3z'],
    list: [7, 'M1 1h1v1h-1zm0 2h1v1h-1zm0 2h1v1h-1z M3 1h3v1h-3zm0 2h3v1h-3zm0 2h3v1h-3z'],
    // link: [20, 'M9 7l6-6 4 4-6 6-1-1 5-5-2-2-5 5zm-8 8l6-6 1 1-5 5 2 2 5-5 1 1-6 6zm5.5 -2.5l6-6 1 1-6 6z'],
    // link: [17, 'M2 11q-2 2 0 4t4 0l2-2q2-2 0-4t-4 0zm5 -5q-2 2 0 4t4 0l2-2q2-2 0-4t-4 0zm3-1q1-1 2 0t0 2l-9 9q-1 1 -2 0 t0-2z'],
    link: [17, 'M12 1h2l2 2v2l-4 4h-2l5-5-2-2-5 5v-2zm-5 7h-2l-4 4v2l2 2h2l4-4v-2l-5 5-2-2zm-1 4l-1-1 6-6 1 1z'],
    chart: [10, 'M1 9v-3h2v3zm3 0v-5h2v5zm3 0v-7h2v7z'],
    no: [7, 'M1 3h5v1h-5z'],
    ban: [20, 'M10 2a8 8 0 1 0 .01 0m0 2a6 6 0 1 1 -.01 0zm-4.5 .5l-1 1 10 10 1-1z'],
    warning: [16, 'M8 1.7l-7 12h14zm0 9a1 1 0 1 1-.01 0c-3-7 3-7 0 0z'],
    info: [20, 'M10 2a8 8 0 1 0 .01 0zm-1 3h2v2h-2zm-1 4h3v5l1 1h-3v-5'],
    share: [22, 'M6 8a3 3 0 1 0 .01 0zm10-5a3 3 0 1 0 .01 0zm0 10a3 3 0 1 0 .01 0zm-10-3v2l10 5v-2zv2l10-5v-2z'],
    world: [12, 'M6 1.2a4.8 4.8 0 1 0 .01 0zm0 .8a4 4 0 1 1-.01 0za3 4 0 1 0 .01 0za2.2 4 0 1 1-.01 0za.5 4 0 1 0 .01 0zm4 4a4 .2 0 1 0 0 .01z'],
    flag: [10, 'M2 1h1v1q2-1 3 0t3-0v4q-2 1-3 0t-3 0v3h-1z'],
    pin: [10, 'M2 4a3 3 0 0 1 6 0q0 2 -3 5q-3-3-3-5zm3 -2a2 2 0 1 0 .01 0z'],
    //date: [10, 'M1 1.5h8v7h-8zm1 2v4h6v-4zm.5-3v2h1.5v-2zm3.5 0v2h1.5v-2z'],
    date: [11, 'M1 1.5h9v8h-9zm1 2v5h7v-5zm.5-3v2h1.5v-2zm4.5 0v2h1.5v-2z'],
    time: [24, 'M12 1a10 10 0 1 1 -.01 0zm0 2a8 8 0 1 0 .01 0zm-1.2 1h2v6.5l3.5 3.5-1.5 1.5-4-4z'],
    refresh: [20, 'M10 .3v3a7 7 0 1 0 7 7h-2a5 5 0 1 1-5-5v3l5-4z'],
    //refresh2: [20, 'M14.5 5.5a7 7 0 1 0 0 9l-1.5-1.5a5 5 0 1 1 0-6l-2 2h5.5v-5.5z'],
    view: [12, 'm1 6q5-6 10 0v1q-5 -6-10 0zm5-3a2.8 2.8 0 1 1 -.01 0zm0 1.8a1.1 1.1 0 1 0 .01 0z'],
    //card: [14, 'M1 3h12v8h-12zm1 1v1h10v-1zm0 3v3h10v-3z'],
    card: [14, 'M1 3.5q0-1 1-1h10q1 0 1 1v7q0 1 -1 1h-10q-1 0-1-1zm1 0v1h10v-1zm0 3v4h10v-4z'],
    sum: [12, 'M2.5 3v-1h7v1h-5l3 3-3 3h5v1h-7v-1l3-3z'],
    //copy: [9, 'M1 3 h1v4h4v1h-5zm2-2h5v5h-5zm1 1v3h3v-3z'],
    copy: [12, 'M2 3 h1v7h5v1h-6zm2-2h6v8h-6zm1 1v6h4v-6z'],
    help: [18, 'M9 2a7 7 0 1 0 .01 0zm-3 5q0-3 3-3t3 3c0 3-2 2-2 4h-2c0-3 2-2 2-4q0-1-1-1t-1 1zm3 4.5a1.3 1.3 0 1 1 -.01 0z'],
    phone: [13, 'M3 1l2 3-1.2 1.2 4 4 1.2-1.2 3 2c-3 6 -15 -6 -9-9z'],
    //mail: [14, 'M1 2.5h12v9h-12zm1 1v1l5 5 5 -5v-1z'],
    mail: [14, 'M1 2.5h12v9h-12zm1 1v1l5 3 5 -3v-1zm0 2v5h10v-5l-5 3z'],
    chat: [12, 'M6 1.2a5 4 0 1 0 .01 0zm0 1a4 3 0 1 1-.01 0zm-3.8 5.5l-1 3 4-2z'],
    send: [12, 'M1 2l10 4-10 4 1.5-3.6 6-.4-6-.4z'],
    bookmark: [8, 'M4 5l-2 2v-6h4v6z'],
    star: [32, 'M16 2 l9 28-23-18 28 0-23 18z'],
    heart: [6, 'M3 2c2-2 4 1 0 3c-4-2-2-5 0-3z'],
    tag: [9, 'M1 5.2l4-4h3v3l-4 4zm6-3.1a.6 .6 0 1 0 .01 .01z'],
    expand: [10, 'M1 1h3v1h-2v2h-1zm5 0h3v3h-1v-2h-2zm2 5h1v3h-3v-1h2zm-7 0h1v2h2v1h-3z'],
    collapse: [10, 'M4 4h-3v-1h2v-2h1zm2 0v-3h1v2h2v1zm0 2h3v1h-2v2h-1zm-2 0v3h-1v-2h-2v-1z'],
    box: [26, 'M3 6l10-2.7 10 2.7-10 3zm-.8 1.2l10 3v13l-10-4zm21.6 0l-10 3v13l10-4z'],
    columns: [16, 'M1.5 2.5h13v11h-13zm1 2v8h5v-8zm6 0v8h5v-8z'],
    //storage: [9, 'M1 1h7v3h-7zm0 4h7v3h-7zm4-3v1h2v-1zm0 4v1h2v-1z'],
    //storage: [10, 'M1 3v-2h9v2zm0 3zv-2h9v2zm0 3zv-2h9v2zm6 -1.5v1h2v-1zm0-3v1h2v-1zm0-3v1h2v-1z'],
    storage: [14, 'M1.5 4.5v-3h11v3zm0 4zv-3h11v3zm0 4zv-3h11v3zm8 -2v1h2v-1zm0-4v1h2v-1zm0-4v1h2v-1z'],
    settings: [11, 'M1 2h9v1h-9zm0 3h9v1h-9zm0 3h9v1h-9zm2-7h1v3h-1zm4 3h1v3h-1zm-3 3h1v3h-1z'],
    power: [18, 'M6 3a6.7 6.7 0 1 0 6 0v2a4.9 4.9 0 1 1 -6 0zm2-1.5h2v8h-2z'],
    energy: [11, 'M5 1.5l-2 4h2l-2 5 5-6h-2l2-3z'],
    sound: [9, 'M3 6h-2v-3h2l3-2v7zm3.7-3q2 1.5 0 3z'],
    mic: [20, 'M7 5 a3 3 0 1 1 6 0v4a3 3 0 1 1 -6 0zm-2 4a5 5 0 1 0 10 0zm4 4v3h-3v2h8v-2h-3v-3z'],
    photo: [10, 'M1 2.5h2l1-1h2l1 1h2v5h-8zm4 .5a1.8 1.8 0 1 0 .01 0z'],
    print: [10, 'M1 2.5h2v-1h4v1h2v4h-8zm2 2l-1 4h6l-1-4zm4-1h1v-.5h-1z'],
    play: [12, 'M3 2v8l7-4z'],
    pause: [9, 'M2 2h2v5h-2zm3 0h2v5h-2z'],
    stop: [9, 'M2 2h5v5h-5z'],
    rec: [10, 'M5 2a3 3 0 1 0 .01 0z'],
    layers: [14, 'M1 5.5l6-3 6 3-6 3zm0 3l2-1 4 2 4-2 2 1-6 3z'],
    none: [1, 'M1 1z']
  };
  var _default$k = /*#__PURE__*/function (_Plugin) {
    _inherits(_default, _Plugin);
    var _super = _createSuper(_default);
    function _default() {
      var _this;
      _classCallCheck(this, _default);
      _this = _super.call(this, 'icons');
      _this.opt = {
        cIcon: 'icon',
        // class of svg icon
        pIcon: 'icon-',
        // class prefix of tag to insert icon into
        cEmpty: 'empty',
        qReplace: '.replace',
        re: {
          '+': ['ok', 'y'],
          '-': ['no', 'n'],
          'x': ['ban', 'e'],
          '!': ['warning', 'w'],
          '?': ['help', 'i']
        },
        // sort: !+-?x
        iconSize: 24,
        pSvg: 'icon-' // id prefix to search on page; set false to skip search
      };
      _this.parsed = {};
      _this.icons = iconset;
      return _this;
    }
    _createClass(_default, [{
      key: "init",
      value: function init() {
        var _this2 = this;
        document.body.classList.add('js-icons');
        this.app.listen('active', function (e) {
          return _this2.iconize(e.n, e.on);
        }); // as soon as possible
        this.arrange({
          n: document.body
        }); // console.timeEnd('start');
      }
    }, {
      key: "arrange",
      value: function arrange(_ref) {
        var _this3 = this;
        var n = _ref.n;
        if (n) {
          this.app.ee(n, '[class*="' + this.opt.pIcon + '"]', function (n) {
            return _this3.iconize(n);
          });
          this.app.ee(n, this.opt.qReplace, function (n) {
            return _this3.replace(n);
          });
        }
      }
    }, {
      key: "iconize",
      value: function iconize(n, on) {
        var m = n.className.match(new RegExp('(?:^|\\s)' + (on ? '(?:act-)' : '') + this.opt.pIcon + '([\\w\\-_\\/]+)'));
        if (m && (on === undefined || n.matches('[class*="act-"]'))) {
          this.app.ee(n, 'svg', function (s) {
            return s.parentNode.removeChild(s);
          });
          this.addIcon(m[1], n);
        }
      }
    }, {
      key: "addIcon",
      value: function addIcon(i, n) {
        var t = n.textContent;
        var icon = this.i(i);
        if (icon) {
          var _icon$classList;
          if (n.classList.contains(this.opt.cEmpty)) {
            this.app.clr(n);
            if (!n.hasAttribute('title')) n.title = t;
            n.classList.remove(this.opt.cEmpty);
          }
          if (n.firstChild && !n.firstChild.tagName) this.app.ins('span', n.firstChild, {}, n, false);
          n.insertBefore(icon, n.firstChild); // n.classList.add(this.opt.pIcon + i.split(/[\/_]/)[0]);
          var m = n.className.match(/\bic_([\w\-_]+)\b/);
          if (m) (_icon$classList = icon.classList).add.apply(_icon$classList, _toConsumableArray(m[1].split('_')));
        }
      }
    }, {
      key: "i",
      value: function i(ico, alt) {
        var a = ico.split(/[\/_]/);
        ico = a[0];
        if (this.parsed[ico] === undefined) {
          var svg = '';
          if (this.opt.pSvg !== false) {
            var id = this.opt.pSvg + ico;
            var sym = document.getElementById(id);
            if (sym && sym.tagName.toLowerCase() == 'symbol') svg = '<svg><use xlink:href="#' + id + '"></use></svg>'; // from page
          }
          if (!svg) {
            svg = this.icons[ico] || '';
            if (typeof svg !== 'string') {
              svg = '<svg viewBox="0 0 ' + svg[0] + ' ' + svg[0] + '"><path d="' + svg[1] + '"/></svg>'; // from array
            }
          }
          var n;
          if (svg) {
            var div = document.createElement('div');
            div.innerHTML = svg;
            n = div.firstChild;
            if (!n.getAttribute('width')) n.setAttribute('width', this.opt.iconSize);
            if (!n.getAttribute('height')) n.setAttribute('height', this.opt.iconSize);
            if (!n.getAttribute('class')) n.setAttribute('class', this.opt.cIcon);
          } else n = '';
          this.parsed[ico] = n;
        }
        return this.parsed[ico] ? this.prepareSvg(this.parsed[ico].cloneNode(true), a.slice(1)) : alt ? this.app.ins('span', alt) : null;
      }
    }, {
      key: "prepareSvg",
      value: function prepareSvg(n, a) {
        var _n$classList;
        var w = a.filter(function (x) {
          return x.match(/^\d+$/);
        });
        var c = a.filter(function (x) {
          return x && !x.match(/^\d+$/);
        });
        if (w.length) n.classList.add('js-resized');
        if (w[0]) n.style.width = w[0] + 'px';
        if (w[1]) n.style.height = w[1] + 'px';
        if (c.length) (_n$classList = n.classList).add.apply(_n$classList, _toConsumableArray(c));
        return n;
      }
    }, {
      key: "replace",
      value: function replace(n) {
        var _this4 = this;
        this.app.ee(n, '*', function (m) {
          return _this4.replaceItem(m, n);
        });
      }
    }, {
      key: "replaceItem",
      value: function replaceItem(n, p) {
        var t = 'innerText' in n && !n.firstElementChild ? n.innerText.replace(/^\s+|\s+$/g, '') : '';
        if (t.length == 1 && t in this.opt.re && !('val' in n.dataset)) {
          n.innerHTML = '';
          var i = p.dataset[this.opt.re[t][1]] || this.opt.re[t][0];
          this.app.ins('', this.i(i, t), 'text-' + this.opt.re[t][1], n);
          n.dataset.val = t;
        }
      }
    }]);
    return _default;
  }(_default$l);
  var _default$j = /*#__PURE__*/function (_Plugin) {
    _inherits(_default, _Plugin);
    var _super = _createSuper(_default);
    function _default() {
      var _this;
      _classCallCheck(this, _default);
      _this = _super.call(this, 'code');
      _this.langs = {
        html: {
          nm: 'HTML',
          re: [[/[a-z0-9_\-]+(?==")/g, 'w'], // attr name
          [/".*?"/g, 'e'], // attr value
          [/<[^!A-Z][\s\S]*?>/g, 'i'], // tag |&[\w#]+;
          [/<\![\s\S]*?>/g, 'n'] // comment
          ]
        },
        js: {
          nm: 'JavaScript',
          re: [[/".*?"|'.*?'/g, 'w'], // string // |'.*?'
          [/(\b|\b\d+\.|\.)\d+\b/g, 'e'], // number
          [/[{}()\[\]]/g, 'y'], // bracket
          [/\b(break|case|catch|class|const|continue|debugger|default|delete|do|else|export|extends|finally|for|function|if|import|in|instanceof|new|return|super|switch|this|throw|try|typeof|var|void|while|with|yield|let|await|null|undefined|true|false|arguments|get|set|require)\b/g, 'i'], // keyword
          [/\/\*[\s\S]*?\*\/|(\/\/|#\!)[^\n]*/g, 'n'] // comment
          ]
        },
        css: {
          nm: 'CSS',
          re: [[/".*?"|'.*?'/g, 'w'], // string // |'.*?'
          [/#[\w\-]+/g, 'e'], // id, color
          [/[{}()]/g, 'y'], // brackets
          [/\.[A-za-z][\w\-]*/g, 'y'], // class
          [/((@\w+|\!important)|\b(none|inherit|initial|unset|attr|url|calc|var|rgba?|hsla?))\b/g, 'i'], // keyword
          [/\/\*[\s\S]*?\*\//g, 'n'] // comment
          ]
        }
      };
      _this.opt = {
        defLang: 'html',
        qCode: '.code'
      };
      return _this;
    }
    _createClass(_default, [{
      key: "init",
      value: function init() {
        var _this2 = this;
        this.app.e(this.opt.qCode, function (n) {
          return _this2.showCode(n);
        });
        this.app.e('code[class*="language-"]', function (n) {
          return _this2.hiliteNode(n);
        });
        this.app.listen('update', function (e) {
          return _this2.updateCode(e);
        });
      }
    }, {
      key: "updateCode",
      value: function updateCode(e) {
        if (e.n) {
          var p = e.n.closest(this.opt.qCode);
          if (p) this.showCode(p);
        }
      }
    }, {
      key: "showCode",
      value: function showCode(src) {
        var lang = src.dataset.lang || this.opt.defLang;
        var t = this.spaces(src.innerHTML);
        if (!src.vCode) {
          var cont = this.app.ins('div', '', {
            classList: 'bord'
          }, src, 1);
          cont.appendChild(src);
          src.classList.add('pad');
          var id = 'code-' + this.app.seq();
          this.app.ins('div', this.app.ins('a', (this.langs[lang] ? this.langs[lang].nm : lang) || lang, {
            className: 'pad',
            href: '#' + id
          }), '-r bg small', cont);
          var pre = this.app.ins('pre', '', {
            id: id,
            className: this.app.opt.cToggle + ' ' + this.app.opt.cOff + ' fit pad'
          }, cont);
          var cod = this.app.ins('code', '', 'language-' + lang, pre);
          src.vCode = cod;
        } //src.vCode.textContent = t;
        src.vCode.innerHTML = this.hiliteText(t, lang);
      }
    }, {
      key: "spaces",
      value: function spaces(s) {
        return s.replace(/^\s*\r?\n|\s+$/g, '').replace(/\t/g, '  '); //.replace(/=""/g, '');
      }
    }, {
      key: "hiliteNode",
      value: function hiliteNode(n) {
        n.innerHTML = this.hiliteText(this.spaces(n.textContent), this.app.a(n.classList).filter(function (c) {
          return c.match(/language-/);
        })[0].substr(9));
      }
    }, {
      key: "hiliteText",
      value: function hiliteText(t, lang) {
        var _this3 = this;
        var l = this.langs[lang];
        var d = this.app.ins('div');
        d.textContent = t;
        t = d.innerHTML;
        if (l && l.re) l.re.forEach(function (re) {
          return t = t.replace(re[0], function (m) {
            return _this3.token(re[1], m);
          });
        });
        return t;
      }
    }, {
      key: "token",
      value: function token(c, m) {
        return "<Span Class = 'text-" + c + "'>" + m + "</Span>";
      }
    }]);
    return _default;
  }(_default$l);
  var _default$i = /*#__PURE__*/function (_Plugin) {
    _inherits(_default, _Plugin);
    var _super = _createSuper(_default);
    function _default() {
      var _this;
      _classCallCheck(this, _default);
      _this = _super.call(this, 'toggle');
      _this.nEsc = 0;
      _this.opt = {
        keepHash: true,
        mediaSuffixes: ['-mobile', '-desktop'],
        dlgUnscroll: true,
        //qTgl: '.toggle[id]',
        qTrg: '[id].target',
        qPop: '.pop>div[id]',
        qNav: '.nav ul',
        //auto [id]
        qDlg: '.dlg',
        //generated dialogs may have no [id]
        qTab: '.tabs+div>div[id]',
        qTre: 'ul.tree ul',
        //auto [id]
        qDrw: '.drawer[id]',
        qAccRoot: 'ul.tree.accordion',
        qAcc: 'ul.tree.accordion ul',
        qGal: '.gal>a[id]',
        // dup of gallery.opt.qGal
        qSubMem: '.tabs.mem+div>div[id], ul.mem:not(.nav) ul',
        //qMedia: '[id].target-mobile, [id].target-desktop',
        qDrawer: '.drawer[id]:not(.shift)',
        qTip: '[data-tip=""][title], .tip[title]',
        qModal: '.gal>a[id], .dlg',
        qMassTgl: 'a[data-nodes]:not([data-set])',
        cMem: 'mem',
        cFade: 'fade',
        cTarget: 'target',
        // css
        cToggle: 'toggle',
        // js
        hUnhash: '#_'
      };
      return _this;
    }
    _createClass(_default, [{
      key: "init",
      value: function init() {
        var _this2 = this;
        var app = this.app;
        app.e('a[data-href]', function (n) {
          return n.href = n.dataset.href;
        });
        app.listen('before', function (e) {
          return (e === null || e === void 0 ? void 0 : e.type) == 'click' ? _this2.beforeClick(e) : null;
        }); // click out
        app.listen('keydown', function (e) {
          return _this2.onKey(e);
        }); //esc
        app.listen('click', function (e) {
          return _this2.onClick(e);
        });
        app.h('click', 'a[href^="#"]', function (e) {
          return _this2.onClickHash(e);
        });
        app.listen('hashchange', function (e) {
          return _this2.onHash(e);
        }); //initial state, #
        app.listen('esc', function (e) {
          return _this2.esc(e);
        }); //click #cancel, hash #cancel, key-27
        app.listen('active', function (e) {
          return _this2.hiliteLink(e.n, e.on);
        });
        app.h('click', this.opt.qMassTgl, function (e) {
          return _this2.massToggle(e.recv, e);
        });
        app.listen('modal', function (e) {
          return _this2.modalStyle(e);
        }); //toggle
        var q = this.opt;
        this.opt.qTgl = this.opt.mediaSuffixes.concat(['']).map(function (x) {
          return (
            /*'[id]' + */
            '.' + app.opt.cToggle + x
          );
        }).join(', ');
        this.opt.qUnpop = [q.qPop, q.qNav, q.qDlg, q.qDrw
        /*, q.qGal*/
        ].join(', ');
        this.opt.qUnpopOn = [q.qPop, q.qNav, q.qDlg, q.qDrw
        /*, q.qGal*/
        ].map(function (n) {
          return n + ':not(.' + app.opt.cOff + ')';
        }).join(', ');
        this.arrangeOnce();
      }
    }, {
      key: "arrangeOnce",
      value: function arrangeOnce() {
        var _this3 = this;
        var n = null;
        var app = this.app;
        var q = this.opt;
        var togglers = [q.qTrg, q.qPop, q.qNav, q.qDlg, q.qTab, q.qTre, q.qDrw
        /*, q.qMedia/*, q.qGal*/
        ].join(', '); //initialize togglers
        app.e(togglers, function (n) {
          return _this3.initToggler(n);
        });
        this.opt.mediaSuffixes.forEach(function (x) {
          return app.e(_this3.opt.qTrg + x, function (n) {
            return _this3.initToggler(n, x);
          });
        });
        app.e(this.opt.qMassTgl, function (n) {
          return app.e(n.dataset.nodes, function (m) {
            return _this3.initToggler(m, '', true);
          });
        }); //let autohide = [        q.qPop, q.qNav, q.qDlg, q.qTab, q.qAcc, q.qDrw, q.qMedia/*, q.qGal*/].join(', ');
        //app.e(autohide, n => this.tgl(n, 0)); //autohide
        app.ee(n, this.opt.qNav + ', ' + this.opt.qTre, function (m) {
          return _this3.attachSubNav(m);
        }); //nav, tree: attach to links
        app.ee(n, this.opt.qGal + ':last-child', function (m) {
          return app.x(m, 1);
        }); //gal: auto add close link
        app.ee(n, this.opt.qSubMem, function (m) {
          return m.classList.add(_this3.opt.cMem);
        }); //initialize sub mem
        app.ee(n, '[id]', function (m) {
          return _this3.restoreVisibility(m);
        }); //restore visibility
        app.ee(n, this.opt.qTab + ':not(.' + app.opt.cOff + ') ~ [id]:not(.' + app.opt.cOff + ')', function (m) {
          return _this3.tgl(m, 0);
        }); //undup tabs
        app.ee(n, this.opt.qTab + ':first-of-type', function (m) {
          return app.qq(_this3.opt.qTab, m.parentNode).filter(function (m) {
            return app.vis(m);
          }).length ? null : _this3.tgl(app.q(app.q('a[href^="#"]', m.parentNode.previousElementSibling).hash), 1);
        }); //inactive tabs: show first
        //init links state
        app.ee(n, '.' + app.opt.cToggle + '[id]', function (m) {
          return _this3.hiliteLinks(m);
        });
        app.ee(n, this.opt.qMassTgl, function (m) {
          return _this3.massToggle(m);
        });
      }
    }, {
      key: "arrange",
      value: function arrange(_ref) {
        var n = _ref.n;
        this.app.ee(n, this.opt.qTip, function (m) {
          m.setAttribute('data-tip', m.title.replace(/\s\s+/g, '\n'));
          m.removeAttribute('title');
        }); //init tooltips
      }
    }, {
      key: "modalStyle",
      value: function modalStyle(e, src) {
        var wasModal = document.body.classList.contains(this.opt.cFade);
        var modal = this.app.q(this.opt.qDlg + ':not(.' + this.app.opt.cOff + '), ' + this.opt.qGal + '[id="' + location.hash.substr(1) + '"]'); // add / remove overlay for every opened modal
        // ...
        // hide / show scrollbar
        if (wasModal !== !!modal) {
          //console.log('modalStyle', e);
          var bar = window.innerWidth - document.documentElement.clientWidth; //scroll bar width
          var s = document.body.style;
          document.body.classList[modal ? 'add' : 'remove'](this.opt.cFade);
          if (this.opt.dlgUnscroll) {
            //hide scroll
            s.overflow = modal ? 'hidden' : '';
            if (!(modal && s.paddingRight)) s.paddingRight = modal ? '' + bar + 'px' : ''; // avoid width reflow
          }
          this.app.dbg(['modalStyle', modal, s.paddingRight]);
        } //else console.log('modalStyle SKIP')
        //focus first input
        if (modal && e !== null && e !== void 0 && e.show) {
          //const f1 = this.app.q('input, a:not(.' + this.app.opt.cClose + ')', modal);
          var f1 = this.app.q('input:not([type="hidden"]), select, textarea, a.btn', modal);
          var f = this.app.q(':focus', modal);
          if (f1 && !f) {
            this.app.dbg(['focus', modal, f1, f]);
            f1.focus(); //focus just once when dialog is opened
            if (f1.type == 'text') f1.select();
          }
        }
      }
    }, {
      key: "esc",
      value: function esc(e) {
        this.app.dbg(['esc', e]);
        if (e && e.preventDefault) e.preventDefault();
        this.unpop(); //if (e.type != 'hashchange') {
        this.addHistory(); //this.modalStyle(null, 'esc');
        this.app.fire('modal', {
          n: null,
          src: 'esc',
          show: false
        }); //}
      }
    }, {
      key: "addHistory",
      value: function addHistory(h) {
        if (h) {
          history.pushState({}, '', h); //following required to re-render hash changes (test: open gallery, esc)
          //history.pushState({}, '', h);
          //history.go(-1);
        } else if (location.hash) {
          location.hash = this.opt.hUnhash; //this.app.opt.hClose; // update :target styles
          if (location.hash) history.replaceState({}, '', location.pathname + location.search); // remove hash in url
          //this.addHistory(location.pathname + location.search /* + this.app.opt.hClose*/);
        }
      }
    }, {
      key: "onKey",
      value: function onKey(e) {
        var k = e.keyCode;
        this.app.dbg(['keydown', k, this.nEsc]);
        if (k == 27 && this.nEsc >= 4) localStorage.clear();
        if (k == 27) this.app.fire('esc', e);
        this.nEsc = k == 27 && this.nEsc < 4 ? this.nEsc + 1 : 0;
      }
    }, {
      key: "onHash",
      value: function onHash(e) {
        var _ref2;
        if ((_ref2 = e ? e.newURL : location.hash) !== null && _ref2 !== void 0 && _ref2.match(new RegExp(this.opt.hUnhash + '$'))) return;
        this.app.dbg(['hashchange', location.hash, e === null || e === void 0 ? void 0 : e.newURL]);
        this.nEsc = 0;
        if (!location.hash || location.hash === this.app.opt.hClose) this.app.fire('esc', e);else if (location.hash === '#unstore') localStorage.clear();else {
          var d = this.app.q(location.hash);
          if (d) {
            var t = d.matches(this.opt.qTgl); // let g = d.matches(this.opt.qGal);
            if (t) {
              this.unpop();
              this.toggle(d, true);
              if (!this.opt.keepHash) this.addHistory();
            }
            /*
            else if (g) {
              this.app.fire('modal', {n: d, src: 'gal', show: true});
            }
            else this.app.fire('modal', {n: d, src: '#', show: false});
            */
          }
          this.app.fire('modal', {
            n: d,
            src: '#',
            show: null
          });
        }
      }
    }, {
      key: "beforeClick",
      value: function b