{"version":3,"file":"filemanager.min.js","sources":["../node_modules/webix-jet/dist/es6/jet.js","../node_modules/jet-restate/index.js","../node_modules/jet-hotkey/index.js","../sources/helpers/icons.js","../sources/views/menus/menubody.js","../sources/views/menus/contextmenu.js","../sources/views/sections/dataview.js","../sources/views/cards.js","../sources/helpers/common.js","../node_modules/@wbx/view-codemirror-editor/codemirror.js","../sources/views/editor.js","../sources/helpers/prompt.js","../sources/views/menus/addnewmenu.js","../sources/views/folders.js","../sources/views/list.js","../sources/views/mobile/previewpopup.js","../sources/views/mobile/sidetree.js","../sources/views/panel-double.js","../sources/views/panel-search.js","../sources/views/panel.js","../sources/views/preview/info.js","../sources/views/preview/index.js","../node_modules/@wbx/view-plyr/plyr.js","../sources/views/preview/media.js","../sources/views/preview/template.js","../sources/views/progress.js","../sources/helpers/responsive.js","../sources/views/topbar.js","../sources/views/top.js","../sources/export_views.js","../sources/models/Backend.js","../sources/models/Cache.js","../sources/models/LocalData.js","../sources/models/Upload.js","../sources/models/Progress.js","../sources/models/Operations.js","../sources/app.js","../sources/locales/en.js"],"sourcesContent":["class NavigationBlocked {\r\n}\n\nclass JetBase {\r\n constructor(webix, config) {\r\n this.webixJet = true;\r\n this.webix = webix;\r\n this._events = [];\r\n this._subs = {};\r\n this._data = {};\r\n if (config && config.params)\r\n webix.extend(this._data, config.params);\r\n }\r\n getRoot() {\r\n return this._root;\r\n }\r\n destructor() {\r\n this._detachEvents();\r\n this._destroySubs();\r\n this._events = this._container = this.app = this._parent = this._root = null;\r\n }\r\n setParam(id, value, url) {\r\n if (this._data[id] !== value) {\r\n this._data[id] = value;\r\n this._segment.update(id, value, 0);\r\n if (url) {\r\n return this.show(null);\r\n }\r\n }\r\n }\r\n getParam(id, parent) {\r\n const value = this._data[id];\r\n if (typeof value !== \"undefined\" || !parent) {\r\n return value;\r\n }\r\n const view = this.getParentView();\r\n if (view) {\r\n return view.getParam(id, parent);\r\n }\r\n }\r\n getUrl() {\r\n return this._segment.suburl();\r\n }\r\n getUrlString() {\r\n return this._segment.toString();\r\n }\r\n getParentView() {\r\n return this._parent;\r\n }\r\n $$(id) {\r\n if (typeof id === \"string\") {\r\n const root = this.getRoot();\r\n return root.queryView((obj => (obj.config.id === id || obj.config.localId === id) &&\r\n (obj.$scope === root.$scope)), \"self\");\r\n }\r\n else {\r\n return id;\r\n }\r\n }\r\n on(obj, name, code) {\r\n const id = obj.attachEvent(name, code);\r\n this._events.push({ obj, id });\r\n return id;\r\n }\r\n contains(view) {\r\n for (const key in this._subs) {\r\n const kid = this._subs[key].view;\r\n if (kid === view || kid.contains(view)) {\r\n return true;\r\n }\r\n }\r\n return false;\r\n }\r\n getSubView(name) {\r\n const sub = this.getSubViewInfo(name);\r\n if (sub) {\r\n return sub.subview.view;\r\n }\r\n }\r\n getSubViewInfo(name) {\r\n const sub = this._subs[name || \"default\"];\r\n if (sub) {\r\n return { subview: sub, parent: this };\r\n }\r\n if (name === \"_top\") {\r\n this._subs[name] = { url: \"\", id: null, popup: true };\r\n return this.getSubViewInfo(name);\r\n }\r\n // when called from a child view, searches for nearest parent with subview\r\n if (this._parent) {\r\n return this._parent.getSubViewInfo(name);\r\n }\r\n return null;\r\n }\r\n _detachEvents() {\r\n const events = this._events;\r\n for (let i = events.length - 1; i >= 0; i--) {\r\n events[i].obj.detachEvent(events[i].id);\r\n }\r\n }\r\n _destroySubs() {\r\n // destroy sub views\r\n for (const key in this._subs) {\r\n const subView = this._subs[key].view;\r\n // it possible that subview was not loaded with any content yet\r\n // so check on null\r\n if (subView) {\r\n subView.destructor();\r\n }\r\n }\r\n // reset to prevent memory leaks\r\n this._subs = {};\r\n }\r\n _init_url_data() {\r\n const url = this._segment.current();\r\n this._data = {};\r\n this.webix.extend(this._data, url.params, true);\r\n }\r\n _getDefaultSub() {\r\n if (this._subs.default) {\r\n return this._subs.default;\r\n }\r\n for (const key in this._subs) {\r\n const sub = this._subs[key];\r\n if (!sub.branch && sub.view && key !== \"_top\") {\r\n const child = sub.view._getDefaultSub();\r\n if (child) {\r\n return child;\r\n }\r\n }\r\n }\r\n }\r\n _routed_view() {\r\n const parent = this.getParentView();\r\n if (!parent) {\r\n return true;\r\n }\r\n const sub = parent._getDefaultSub();\r\n if (!sub && sub !== this) {\r\n return false;\r\n }\r\n return parent._routed_view();\r\n }\r\n}\n\nfunction parse(url) {\r\n // remove starting /\r\n if (url[0] === \"/\") {\r\n url = url.substr(1);\r\n }\r\n // split url by \"/\"\r\n const parts = url.split(\"/\");\r\n const chunks = [];\r\n // for each page in url\r\n for (let i = 0; i < parts.length; i++) {\r\n const test = parts[i];\r\n const result = {};\r\n // detect params\r\n // support old \t\t\tsome:a=b:c=d\r\n // and new notation\t\tsome?a=b&c=d\r\n let pos = test.indexOf(\":\");\r\n if (pos === -1) {\r\n pos = test.indexOf(\"?\");\r\n }\r\n if (pos !== -1) {\r\n const params = test.substr(pos + 1).split(/[\\:\\?\\&]/g);\r\n // create hash of named params\r\n for (const param of params) {\r\n const dchunk = param.split(\"=\");\r\n result[dchunk[0]] = decodeURIComponent(dchunk[1]);\r\n }\r\n }\r\n // store parsed values\r\n chunks[i] = {\r\n page: (pos > -1 ? test.substr(0, pos) : test),\r\n params: result,\r\n isNew: true\r\n };\r\n }\r\n // return array of page objects\r\n return chunks;\r\n}\r\nfunction url2str(stack) {\r\n const url = [];\r\n for (const chunk of stack) {\r\n url.push(\"/\" + chunk.page);\r\n const params = obj2str(chunk.params);\r\n if (params) {\r\n url.push(\"?\" + params);\r\n }\r\n }\r\n return url.join(\"\");\r\n}\r\nfunction obj2str(obj) {\r\n const str = [];\r\n for (const key in obj) {\r\n if (typeof obj[key] === \"object\")\r\n continue;\r\n if (str.length) {\r\n str.push(\"&\");\r\n }\r\n str.push(key + \"=\" + encodeURIComponent(obj[key]));\r\n }\r\n return str.join(\"\");\r\n}\n\nclass Route {\r\n constructor(route, index) {\r\n this._next = 1;\r\n if (typeof route === \"string\") {\r\n this.route = {\r\n url: parse(route),\r\n path: route\r\n };\r\n }\r\n else {\r\n this.route = route;\r\n }\r\n this.index = index;\r\n }\r\n current() {\r\n return this.route.url[this.index];\r\n }\r\n next() {\r\n return this.route.url[this.index + this._next];\r\n }\r\n suburl() {\r\n return this.route.url.slice(this.index);\r\n }\r\n shift(params) {\r\n const route = new Route(this.route, this.index + this._next);\r\n route.setParams(route.route.url, params, route.index);\r\n return route;\r\n }\r\n setParams(url, params, index) {\r\n if (params) {\r\n const old = url[index].params;\r\n for (var key in params)\r\n old[key] = params[key];\r\n }\r\n }\r\n refresh() {\r\n const url = this.route.url;\r\n for (let i = this.index + 1; i < url.length; i++) {\r\n url[i].isNew = true;\r\n }\r\n }\r\n toString() {\r\n const str = url2str(this.suburl());\r\n return str ? str.substr(1) : \"\";\r\n }\r\n _join(path, kids) {\r\n let url = this.route.url;\r\n if (path === null) { // change of parameters, route elements are not affected\r\n return url;\r\n }\r\n const old = this.route.url;\r\n let reset = true;\r\n url = old.slice(0, this.index + (kids ? this._next : 0));\r\n if (path) {\r\n url = url.concat(parse(path));\r\n for (let i = 0; i < url.length; i++) {\r\n if (old[i]) {\r\n url[i].view = old[i].view;\r\n }\r\n if (reset && old[i] && url[i].page === old[i].page) {\r\n url[i].isNew = false;\r\n }\r\n else if (url[i].isNew) {\r\n // if some segment was marked as new, all subsegments must be updated as well\r\n reset = false;\r\n }\r\n }\r\n }\r\n return url;\r\n }\r\n append(path) {\r\n const url = this._join(path, true);\r\n this.route.path = url2str(url);\r\n this.route.url = url;\r\n return this.route.path;\r\n }\r\n show(path, view, kids) {\r\n const url = this._join(path.url, kids);\r\n this.setParams(url, path.params, this.index + (kids ? this._next : 0));\r\n return new Promise((res, rej) => {\r\n const redirect = url2str(url);\r\n const obj = {\r\n url,\r\n redirect,\r\n confirm: Promise.resolve()\r\n };\r\n const app = view ? view.app : null;\r\n // when creating a new route, it possible that it will not have any content\r\n // guard is not necessary in such case\r\n if (app) {\r\n const result = app.callEvent(\"app:guard\", [obj.redirect, view, obj]);\r\n if (!result) {\r\n rej(new NavigationBlocked());\r\n return;\r\n }\r\n }\r\n obj.confirm.catch(err => rej(err)).then(() => {\r\n if (obj.redirect === null) {\r\n rej(new NavigationBlocked());\r\n return;\r\n }\r\n if (obj.redirect !== redirect) {\r\n app.show(obj.redirect);\r\n rej(new NavigationBlocked());\r\n return;\r\n }\r\n this.route.path = redirect;\r\n this.route.url = url;\r\n res();\r\n });\r\n });\r\n }\r\n size(n) {\r\n this._next = n;\r\n }\r\n split() {\r\n const route = {\r\n url: this.route.url.slice(this.index + 1),\r\n path: \"\"\r\n };\r\n if (route.url.length) {\r\n route.path = url2str(route.url);\r\n }\r\n return new Route(route, 0);\r\n }\r\n update(name, value, index) {\r\n const chunk = this.route.url[this.index + (index || 0)];\r\n if (!chunk) {\r\n this.route.url.push({ page: \"\", params: {} });\r\n return this.update(name, value, index);\r\n }\r\n if (name === \"\") {\r\n chunk.page = value;\r\n }\r\n else {\r\n chunk.params[name] = value;\r\n }\r\n this.route.path = url2str(this.route.url);\r\n }\r\n}\n\nclass JetView extends JetBase {\r\n constructor(app, config) {\r\n super(app.webix);\r\n this.app = app;\r\n //this.$config = config;\r\n this._children = [];\r\n }\r\n ui(ui, config) {\r\n config = config || {};\r\n const container = config.container || ui.container;\r\n const jetview = this.app.createView(ui);\r\n this._children.push(jetview);\r\n jetview.render(container, this._segment, this);\r\n if (typeof ui !== \"object\" || (ui instanceof JetBase)) {\r\n // raw webix UI\r\n return jetview;\r\n }\r\n else {\r\n return jetview.getRoot();\r\n }\r\n }\r\n show(path, config) {\r\n config = config || {};\r\n // convert parameters object to url\r\n if (typeof path === \"object\") {\r\n for (const key in path) {\r\n this.setParam(key, path[key]);\r\n }\r\n path = null;\r\n }\r\n else {\r\n // deligate to app in case of root prefix\r\n if (path.substr(0, 1) === \"/\") {\r\n return this.app.show(path, config);\r\n }\r\n // local path, do nothing\r\n if (path.indexOf(\"./\") === 0) {\r\n path = path.substr(2);\r\n }\r\n // parent path, call parent view\r\n if (path.indexOf(\"../\") === 0) {\r\n const parent = this.getParentView();\r\n if (parent) {\r\n return parent.show(path.substr(3), config);\r\n }\r\n else {\r\n return this.app.show(\"/\" + path.substr(3));\r\n }\r\n }\r\n const sub = this.getSubViewInfo(config.target);\r\n if (sub) {\r\n if (sub.parent !== this) {\r\n return sub.parent.show(path, config);\r\n }\r\n else if (config.target && config.target !== \"default\") {\r\n return this._renderFrameLock(config.target, sub.subview, {\r\n url: path,\r\n params: config.params,\r\n });\r\n }\r\n }\r\n else {\r\n if (path) {\r\n return this.app.show(\"/\" + path, config);\r\n }\r\n }\r\n }\r\n return this._show(this._segment, { url: path, params: config.params }, this);\r\n }\r\n _show(segment, path, view) {\r\n return segment.show(path, view, true).then(() => {\r\n this._init_url_data();\r\n return this._urlChange();\r\n }).then(() => {\r\n if (segment.route.linkRouter) {\r\n this.app.getRouter().set(segment.route.path, { silent: true });\r\n this.app.callEvent(\"app:route\", [segment.route.path]);\r\n }\r\n });\r\n }\r\n init(_$view, _$) {\r\n // stub\r\n }\r\n ready(_$view, _$url) {\r\n // stub\r\n }\r\n config() {\r\n this.app.webix.message(\"View:Config is not implemented\");\r\n }\r\n urlChange(_$view, _$url) {\r\n // stub\r\n }\r\n destroy() {\r\n // stub\r\n }\r\n destructor() {\r\n this.destroy();\r\n this._destroyKids();\r\n // destroy actual UI\r\n if (this._root) {\r\n this._root.destructor();\r\n super.destructor();\r\n }\r\n }\r\n use(plugin, config) {\r\n plugin(this.app, this, config);\r\n }\r\n refresh() {\r\n const url = this.getUrl();\r\n this.destroy();\r\n this._destroyKids();\r\n this._destroySubs();\r\n this._detachEvents();\r\n if (this._container.tagName) {\r\n this._root.destructor();\r\n }\r\n this._segment.refresh();\r\n return this._render(this._segment);\r\n }\r\n render(root, url, parent) {\r\n if (typeof url === \"string\") {\r\n url = new Route(url, 0);\r\n }\r\n this._segment = url;\r\n this._parent = parent;\r\n this._init_url_data();\r\n root = root || document.body;\r\n const _container = (typeof root === \"string\") ? this.webix.toNode(root) : root;\r\n if (this._container !== _container) {\r\n this._container = _container;\r\n return this._render(url);\r\n }\r\n else {\r\n return this._urlChange().then(() => this.getRoot());\r\n }\r\n }\r\n _render(url) {\r\n const config = this.config();\r\n if (config.then) {\r\n return config.then(cfg => this._render_final(cfg, url));\r\n }\r\n else {\r\n return this._render_final(config, url);\r\n }\r\n }\r\n _render_final(config, url) {\r\n // get previous view in the same slot\r\n let slot = null;\r\n let container = null;\r\n let show = false;\r\n if (!this._container.tagName) {\r\n slot = this._container;\r\n if (slot.popup) {\r\n container = document.body;\r\n show = true;\r\n }\r\n else {\r\n container = this.webix.$$(slot.id);\r\n }\r\n }\r\n else {\r\n container = this._container;\r\n }\r\n // view already destroyed\r\n if (!this.app || !container) {\r\n return Promise.reject(null);\r\n }\r\n let response;\r\n const current = this._segment.current();\r\n // using wrapper object, so ui can be changed from app:render event\r\n const result = { ui: {} };\r\n this.app.copyConfig(config, result.ui, this._subs);\r\n this.app.callEvent(\"app:render\", [this, url, result]);\r\n result.ui.$scope = this;\r\n /* destroy old HTML attached views before creating new one */\r\n if (!slot && current.isNew && current.view) {\r\n current.view.destructor();\r\n }\r\n try {\r\n // special handling for adding inside of multiview - preserve old id\r\n if (slot && !show) {\r\n const oldui = container;\r\n const parent = oldui.getParentView();\r\n if (parent && parent.name === \"multiview\" && !result.ui.id) {\r\n result.ui.id = oldui.config.id;\r\n }\r\n }\r\n this._root = this.app.webix.ui(result.ui, container);\r\n const asWin = this._root;\r\n // check for url added to ignore this.ui calls\r\n if (show && asWin.setPosition && !asWin.isVisible()) {\r\n asWin.show();\r\n }\r\n // check, if we are replacing some older view\r\n if (slot) {\r\n if (slot.view && slot.view !== this && slot.view !== this.app) {\r\n slot.view.destructor();\r\n }\r\n slot.id = this._root.config.id;\r\n if (this.getParentView() || !this.app.app)\r\n slot.view = this;\r\n else {\r\n // when we have subapp, set whole app as a view\r\n // so on destruction, the whole app will be destroyed\r\n slot.view = this.app;\r\n }\r\n }\r\n if (current.isNew) {\r\n current.view = this;\r\n current.isNew = false;\r\n }\r\n response = Promise.resolve(this._init(this._root, url)).then(() => {\r\n return this._urlChange().then(() => {\r\n this._initUrl = null;\r\n return this.ready(this._root, url.suburl());\r\n });\r\n });\r\n }\r\n catch (e) {\r\n response = Promise.reject(e);\r\n }\r\n return response.catch(err => this._initError(this, err));\r\n }\r\n _init(view, url) {\r\n return this.init(view, url.suburl());\r\n }\r\n _urlChange() {\r\n this.app.callEvent(\"app:urlchange\", [this, this._segment]);\r\n const waits = [];\r\n for (const key in this._subs) {\r\n const frame = this._subs[key];\r\n const wait = this._renderFrameLock(key, frame, null);\r\n if (wait) {\r\n waits.push(wait);\r\n }\r\n }\r\n return Promise.all(waits).then(() => {\r\n return this.urlChange(this._root, this._segment.suburl());\r\n });\r\n }\r\n _renderFrameLock(key, frame, path) {\r\n // if subview is not occupied by some rendering yet\r\n if (!frame.lock) {\r\n // retreive and store rendering end promise\r\n const lock = this._renderFrame(key, frame, path);\r\n if (lock) {\r\n // clear lock after frame rendering\r\n // as promise.finally is not supported by Webix lesser than 6.2\r\n // using a more verbose notation\r\n frame.lock = lock.then(() => frame.lock = null, () => frame.lock = null);\r\n }\r\n }\r\n // return rendering end promise\r\n return frame.lock;\r\n }\r\n _renderFrame(key, frame, path) {\r\n //default route\r\n if (key === \"default\") {\r\n if (this._segment.next()) {\r\n // we have a next segment in url, render it\r\n let params = path ? path.params : null;\r\n if (frame.params) {\r\n params = this.webix.extend(params || {}, frame.params);\r\n }\r\n return this._createSubView(frame, this._segment.shift(params));\r\n }\r\n else if (frame.view && frame.popup) {\r\n // there is no next segment, delete the existing sub-view\r\n frame.view.destructor();\r\n frame.view = null;\r\n }\r\n }\r\n //if new path provided, set it to the frame\r\n if (path !== null) {\r\n frame.url = path.url;\r\n if (frame.params) {\r\n path.params = this.webix.extend(path.params || {}, frame.params);\r\n }\r\n }\r\n // in case of routed sub-view\r\n if (frame.route) {\r\n // we have a new path for sub-view\r\n if (path !== null) {\r\n return frame.route.show(path, frame.view).then(() => {\r\n return this._createSubView(frame, frame.route);\r\n });\r\n }\r\n // do not trigger onChange for isolated sub-views\r\n if (frame.branch) {\r\n return;\r\n }\r\n }\r\n let view = frame.view;\r\n // if view doesn't exists yet, init it\r\n if (!view && frame.url) {\r\n if (typeof frame.url === \"string\") {\r\n // string, so we have isolated subview url\r\n frame.route = new Route(frame.url, 0);\r\n if (path)\r\n frame.route.setParams(frame.route.route.url, path.params, 0);\r\n if (frame.params)\r\n frame.route.setParams(frame.route.route.url, frame.params, 0);\r\n return this._createSubView(frame, frame.route);\r\n }\r\n else {\r\n // object, so we have an embeded subview\r\n if (typeof frame.url === \"function\" && !(view instanceof frame.url)) {\r\n view = new (this.app._override(frame.url))(this.app, \"\");\r\n }\r\n if (!view) {\r\n view = frame.url;\r\n }\r\n }\r\n }\r\n // trigger onChange for already existed view\r\n if (view) {\r\n return view.render(frame, (frame.route || this._segment), this);\r\n }\r\n }\r\n _initError(view, err) {\r\n /*\r\n if view is destroyed, ignore any view related errors\r\n */\r\n if (this.app) {\r\n this.app.error(\"app:error:initview\", [err, view]);\r\n }\r\n return true;\r\n }\r\n _createSubView(sub, suburl) {\r\n return this.app.createFromURL(suburl.current()).then(view => {\r\n return view.render(sub, suburl, this);\r\n });\r\n }\r\n _destroyKids() {\r\n // destroy child views\r\n const uis = this._children;\r\n for (let i = uis.length - 1; i >= 0; i--) {\r\n if (uis[i] && uis[i].destructor) {\r\n uis[i].destructor();\r\n }\r\n }\r\n // reset vars for better GC processing\r\n this._children = [];\r\n }\r\n}\n\n// wrapper for raw objects and Jet 1.x structs\r\nclass JetViewRaw extends JetView {\r\n constructor(app, config) {\r\n super(app, config);\r\n this._ui = config.ui;\r\n }\r\n config() {\r\n return this._ui;\r\n }\r\n}\n\nclass SubRouter {\r\n constructor(cb, config, app) {\r\n this.path = \"\";\r\n this.app = app;\r\n }\r\n set(path, config) {\r\n this.path = path;\r\n const a = this.app;\r\n a.app.getRouter().set(a._segment.append(this.path), { silent: true });\r\n }\r\n get() {\r\n return this.path;\r\n }\r\n}\n\nlet _once = true;\r\nclass JetAppBase extends JetBase {\r\n constructor(config) {\r\n const webix = (config || {}).webix || window.webix;\r\n config = webix.extend({\r\n name: \"App\",\r\n version: \"1.0\",\r\n start: \"/home\"\r\n }, config, true);\r\n super(webix, config);\r\n this.config = config;\r\n this.app = this.config.app;\r\n this.ready = Promise.resolve();\r\n this._services = {};\r\n this.webix.extend(this, this.webix.EventSystem);\r\n }\r\n getUrl() {\r\n return this._subSegment.suburl();\r\n }\r\n getUrlString() {\r\n return this._subSegment.toString();\r\n }\r\n getService(name) {\r\n let obj = this._services[name];\r\n if (typeof obj === \"function\") {\r\n obj = this._services[name] = obj(this);\r\n }\r\n return obj;\r\n }\r\n setService(name, handler) {\r\n this._services[name] = handler;\r\n }\r\n destructor() {\r\n this.getSubView().destructor();\r\n super.destructor();\r\n }\r\n // copy object and collect extra handlers\r\n copyConfig(obj, target, config) {\r\n // raw ui config\r\n if (obj instanceof JetBase ||\r\n (typeof obj === \"function\" && obj.prototype instanceof JetBase)) {\r\n obj = { $subview: obj };\r\n }\r\n // subview placeholder\r\n if (typeof obj.$subview != \"undefined\") {\r\n return this.addSubView(obj, target, config);\r\n }\r\n // process sub-properties\r\n const isArray = obj instanceof Array;\r\n target = target || (isArray ? [] : {});\r\n for (const method in obj) {\r\n let point = obj[method];\r\n // view class\r\n if (typeof point === \"function\" && point.prototype instanceof JetBase) {\r\n point = { $subview: point };\r\n }\r\n if (point && typeof point === \"object\" &&\r\n !(point instanceof this.webix.DataCollection) && !(point instanceof RegExp) && !(point instanceof Map)) {\r\n if (point instanceof Date) {\r\n target[method] = new Date(point);\r\n }\r\n else {\r\n const copy = this.copyConfig(point, (point instanceof Array ? [] : {}), config);\r\n if (copy !== null) {\r\n if (isArray)\r\n target.push(copy);\r\n else\r\n target[method] = copy;\r\n }\r\n }\r\n }\r\n else {\r\n target[method] = point;\r\n }\r\n }\r\n return target;\r\n }\r\n getRouter() {\r\n return this.$router;\r\n }\r\n clickHandler(e, target) {\r\n if (e) {\r\n target = target || (e.target || e.srcElement);\r\n if (target && target.getAttribute) {\r\n const trigger = target.getAttribute(\"trigger\");\r\n if (trigger) {\r\n this._forView(target, view => view.app.trigger(trigger));\r\n e.cancelBubble = true;\r\n return e.preventDefault();\r\n }\r\n const route = target.getAttribute(\"route\");\r\n if (route) {\r\n this._forView(target, view => view.show(route));\r\n e.cancelBubble = true;\r\n return e.preventDefault();\r\n }\r\n }\r\n }\r\n const parent = target.parentNode;\r\n if (parent) {\r\n this.clickHandler(e, parent);\r\n }\r\n }\r\n getRoot() {\r\n return this.getSubView().getRoot();\r\n }\r\n refresh() {\r\n if (!this._subSegment) {\r\n return Promise.resolve(null);\r\n }\r\n return this.getSubView().refresh().then(view => {\r\n this.callEvent(\"app:route\", [this.getUrl()]);\r\n return view;\r\n });\r\n }\r\n loadView(url) {\r\n const views = this.config.views;\r\n let result = null;\r\n if (url === \"\") {\r\n return Promise.resolve(this._loadError(\"\", new Error(\"Webix Jet: Empty url segment\")));\r\n }\r\n try {\r\n if (views) {\r\n if (typeof views === \"function\") {\r\n // custom loading strategy\r\n result = views(url);\r\n }\r\n else {\r\n // predefined hash\r\n result = views[url];\r\n }\r\n if (typeof result === \"string\") {\r\n url = result;\r\n result = null;\r\n }\r\n }\r\n if (!result) {\r\n if (url === \"_hidden\") {\r\n result = { hidden: true };\r\n }\r\n else if (url === \"_blank\") {\r\n result = {};\r\n }\r\n else {\r\n url = url.replace(/\\./g, \"/\");\r\n result = this.require(\"jet-views\", url);\r\n }\r\n }\r\n }\r\n catch (e) {\r\n result = this._loadError(url, e);\r\n }\r\n // custom handler can return view or its promise\r\n if (!result.then) {\r\n result = Promise.resolve(result);\r\n }\r\n // set error handler\r\n result = result\r\n .then(module => module.__esModule ? module.default : module)\r\n .catch(err => this._loadError(url, err));\r\n return result;\r\n }\r\n _forView(target, handler) {\r\n const view = this.webix.$$(target);\r\n if (view) {\r\n handler(view.$scope);\r\n }\r\n }\r\n _loadViewDynamic(url) {\r\n return null;\r\n }\r\n createFromURL(chunk) {\r\n let view;\r\n if (chunk.isNew || !chunk.view) {\r\n view = this.loadView(chunk.page)\r\n .then(ui => this.createView(ui, name, chunk.params));\r\n }\r\n else {\r\n view = Promise.resolve(chunk.view);\r\n }\r\n return view;\r\n }\r\n _override(ui) {\r\n const over = this.config.override;\r\n if (over) {\r\n let dv;\r\n while (ui) {\r\n dv = ui;\r\n ui = over.get(ui);\r\n }\r\n return dv;\r\n }\r\n return ui;\r\n }\r\n createView(ui, name, params) {\r\n ui = this._override(ui);\r\n let obj;\r\n if (typeof ui === \"function\") {\r\n if (ui.prototype instanceof JetAppBase) {\r\n // UI class\r\n return new ui({ app: this, name, params, router: SubRouter });\r\n }\r\n else if (ui.prototype instanceof JetBase) {\r\n // UI class\r\n return new ui(this, { name, params });\r\n }\r\n else {\r\n // UI factory functions\r\n ui = ui(this);\r\n }\r\n }\r\n if (ui instanceof JetBase) {\r\n obj = ui;\r\n }\r\n else {\r\n // UI object\r\n obj = new JetViewRaw(this, { name, ui });\r\n }\r\n return obj;\r\n }\r\n // show view path\r\n show(url, config) {\r\n if (url && this.app && url.indexOf(\"//\") == 0)\r\n return this.app.show(url.substr(1), config);\r\n return this.render(this._container, url || this.config.start, config);\r\n }\r\n // event helpers\r\n trigger(name, ...rest) {\r\n this.apply(name, rest);\r\n }\r\n apply(name, data) {\r\n this.callEvent(name, data);\r\n }\r\n action(name) {\r\n return this.webix.bind(function (...rest) {\r\n this.apply(name, rest);\r\n }, this);\r\n }\r\n on(name, handler) {\r\n this.attachEvent(name, handler);\r\n }\r\n use(plugin, config) {\r\n plugin(this, null, config);\r\n }\r\n error(name, er) {\r\n this.callEvent(name, er);\r\n this.callEvent(\"app:error\", er);\r\n /* tslint:disable */\r\n if (this.config.debug) {\r\n for (var i = 0; i < er.length; i++) {\r\n console.error(er[i]);\r\n if (er[i] instanceof Error) {\r\n let text = er[i].message;\r\n if (text.indexOf(\"Module build failed\") === 0) {\r\n text = text.replace(/\\x1b\\[[0-9;]*m/g, \"\");\r\n document.body.innerHTML = `
${text}`;\r\n }\r\n else {\r\n text += \"