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Aa,EAAK,GAAM,OAAO,KAAK,OAAO,IAAI,cAAe,EAAK,EAAI,EAEzE,YAAY,MAAQ,QAAQ,WAC5B,YAAY,QAAU,QAAQ,aAC9B,YAAY,QAAU,QAAQ,aAC9B,YAAY,KAAO,QAAQ,UAC3B,YAAY,SAAW,QAAQ,cAC/B,YAAY,MAAQ,QAAQ,WAC5B,YAAY,MAAQ,QAAQ,WAC5B,YAAY,QAAU,QAAQ,aAC9B,YAAY,UAAY,QAAQ,eAChC,YAAY,SAAW,QAAQ,cAC/B,YAAY,QAAU,QAAQ,aAC9B,YAAY,IAAM,QAAQ,SAC1B,YAAY,QAAU,QAAQ,aAC9B,YAAY,OAAS,QAAQ,YAC7B,YAAY,WAAa,QAAQ,gBACjC,YAAY,WAAa,QAAQ,gBACjC,YAAY,SAAW,QAAQ,cAC/B,YAAY,OAAS,QAAQ,YAC7B,YAAY,OAAS,QAAQ,YAC7B,YAAY,KAAO,QAAQ,UAC3B,YAAY,KAAO,QAAQ,UAC3B,OAAO,QAAU","file":"/npm/kado@4.4.0/lib/Application.js","sourceRoot":"","sourcesContent":["/**\n * Minified by jsDelivr using Terser v5.39.0.\n * Original file: /npm/kado@4.4.0/lib/Application.js\n *\n * Do NOT use SRI with dynamically generated files! More information: https://www.jsdelivr.com/using-sri-with-dynamic-files\n */\n","'use strict'\n/**\n * Kado - High Quality JavaScript Libraries based on ES6+ <https://kado.org>\n * Copyright © 2013-2022 Bryan Tong, NULLIVEX LLC. All rights reserved.\n *\n * This file is part of Kado.\n *\n * Kado is free software: you can redistribute it and/or modify\n * it under the terms of the GNU General Public License as published by\n * the Free Software Foundation, either version 3 of the License, or\n * (at your option) any later version.\n *\n * Kado is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n * GNU General Public License for more details.\n *\n * You should have received a copy of the GNU General Public License\n * along with Kado.  If not, see <https://www.gnu.org/licenses/>.\n */\nconst Assert = require('./Assert')\nconst fs = require('./FileSystem')\nconst instance = {}\n\nclass Application {\n  static getInstance (name) {\n    if (!instance[name]) instance[name] = new Application()\n    return instance[name]\n  }\n\n  constructor () {\n    // setup default config\n    this.config = new Application.Mapper(this.getDefaultConfig())\n    // instances\n    this.asset = new Application.Asset()\n    this.cli = new Application.Command.CommandServer(this)\n    this.connect = new Application.Connect()\n    this.cron = new Application.Cron()\n    this.database = new Application.Database()\n    this.email = new Application.Email()\n    this.event = new Application.Event()\n    this.history = new Application.History()\n    this.http = new Application.HyperText()\n    this.lang = new Application.Language()\n    this.library = new Application.Library()\n    this.log = new Application.Log()\n    this.message = new Application.Message()\n    this.nav = new Application.Navigation()\n    this.permission = new Application.Permission()\n    this.router = new Application.Router()\n    this.search = new Application.Search()\n    this.util = new Application.Util()\n    this.view = new Application.View()\n    // variables\n    this.db = {}\n    this.dev = null\n    this.isSetup = false\n    this.listening = false\n    this.modules = {}\n    this.name = 'main'\n    this.started = false\n    this.trustProxy = false\n    this.version = '0.0.0'\n  }\n\n  getDefaultConfig () { return {} }\n\n  setConfig (cfg) {\n    this.config.merge(cfg || {})\n    return this\n  }\n\n  setName (name) {\n    this.name = name\n    return this\n  }\n\n  setTrustProxy (trustProxy = false) {\n    Assert.isType('boolean', trustProxy)\n    this.trustProxy = trustProxy\n    return this\n  }\n\n  setVersion (version) {\n    this.version = version\n    return this\n  }\n\n  setupMode () {\n    if (this.config.get('dev') !== undefined) {\n      this.dev = this.config.get('dev')\n    }\n    // set dev mode if debug is turned on and the dev option is null\n    if (this.dev === null &&\n      (process.env.NODE_DEBUG === 'kado' || process.env.DEV === 'kado')\n    ) {\n      process.env.NODE_DEBUG = 'kado'\n      this.dev = true\n    }\n  }\n\n  setupPaths () {\n    // paths\n    this.KADO_ROOT = fs.path.dirname(__dirname)\n    this.KADO_USER_ROOT = fs.path.dirname(fs.path.dirname(this.KADO_ROOT))\n    const userPackageJson = fs.path.resolve(\n      fs.path.join(this.KADO_USER_ROOT, 'package.json')\n    )\n    if (!fs.exists(userPackageJson)) this.KADO_USER_ROOT = this.KADO_ROOT\n    this.INTERFACE_ROOT = fs.path.resolve(\n      fs.path.join(this.KADO_USER_ROOT, this.name)\n    )\n  }\n\n  setupLibrary () {\n    this.library.addPath(fs.path.resolve(this.KADO_USER_ROOT + '/lib'))\n    this.library.addPath(fs.path.resolve(this.KADO_ROOT + '/lib'))\n  }\n\n  setupRouter () {\n    this.router.setPreparer(Application.Router.standardPreparation(this))\n  }\n\n  setup () {\n    if (this.isSetup === true) return this\n    this.setupMode()\n    this.setupPaths()\n    this.setupLibrary()\n    this.setupRouter()\n    this.isSetup = true\n    return this\n  }\n\n  addModule (mod) {\n    Assert.isType('Module', Object.getPrototypeOf(mod))\n    if (!this.modules) this.modules = {}\n    this.modules[mod.name] = mod\n    return this\n  }\n\n  getModule (name) {\n    if (!this.modules) return false\n    return this.modules[name]\n  }\n\n  removeModule (name) {\n    if (this.modules[name]) {\n      const mod = this.modules[name]\n      delete this.modules[name]\n      return mod\n    }\n    return false\n  }\n\n  lib (name) {\n    return require(this.library.search(name))\n  }\n\n  startConnect () {\n    // connect all connector style instances\n    //  Connect\n    //  Database\n    return Application.Connect.each(this.connect, null, {}, 'start')\n      .then(() => {\n        return Application.Connect.each(this.database, null, {}, 'start')\n      })\n  }\n\n  stopConnect () {\n    // disconnect all connector style instances\n    //  Database\n    //  Connect\n    return Application.Connect.each(this.database, null, {}, 'stop')\n      .then(() => {\n        return Application.Connect.each(this.connect, null, {}, 'stop')\n      })\n  }\n\n  isCommand (argv) {\n    return argv instanceof Array && argv.length > 2\n  }\n\n  command (argv) {\n    return Promise.resolve().then(() => {\n      if (this.isCommand(argv) === false) return false\n      return this.cli.run(argv)\n    })\n  }\n\n  startServer () {\n    // make servers listen\n    //  HyperText\n    return Application.Connect.each(this.http, null, {}, 'start')\n      .then((rv) => { this.listening = true; return rv })\n  }\n\n  stopServer () {\n    // stop listening on all servers\n    //  HyperText\n    return Application.Connect.each(this.http, null, {}, 'stop')\n      .then((rv) => { this.listening = false; return rv })\n  }\n\n  start (argv) {\n    this.setup()\n    return this.startConnect()\n      .then(() => { this.started = true })\n      .then(() => {\n        if (!argv) return\n        return this.command(argv)\n          .then((code) => {\n            if (code === undefined) code = 0\n            Assert.isOk(code >= 0, `Invalid command return code: ${code}`)\n            return this.stop().then(() => { process.exit(code || 0) })\n          })\n      })\n  }\n\n  listen () {\n    return this.startServer()\n  }\n\n  stop () {\n    return Promise.resolve()\n      .then(() => {\n        Assert.isOk(this.started, 'Cannot stop already idle')\n      })\n      .then(() => { return this.stopConnect() })\n      .then(() => { if (this.listening) return this.stopServer() })\n  }\n\n  // router methods\n  use (fn) { return this.router.use(fn) }\n  final (fn) { return this.router.final(fn) }\n  // http methods\n  acl (uri, fn) { return this.router.add('ACL', uri, fn) }\n  bind (uri, fn) { return this.router.add('BIND', uri, fn) }\n  checkout (uri, fn) { return this.router.add('CHECKOUT', uri, fn) }\n  copy (uri, fn) { return this.router.add('COPY', uri, fn) }\n  delete (uri, fn) { return this.router.add('DELETE', uri, fn) }\n  get (uri, fn) { return this.router.add('GET', uri, fn) }\n  head (uri, fn) { return this.router.add('HEAD', uri, fn) }\n  link (uri, fn) { return this.router.add('LINK', uri, fn) }\n  lock (uri, fn) { return this.router.add('LOCK', uri, fn) }\n  msearch (uri, fn) { return this.router.add('M-SEARCH', uri, fn) }\n  merge (uri, fn) { return this.router.add('MERGE', uri, fn) }\n  mkactivity (uri, fn) { return this.router.add('MKACTIVITY', uri, fn) }\n  mkcalendar (uri, fn) { return this.router.add('MKCALENDAR', uri, fn) }\n  mkcol (uri, fn) { return this.router.add('MKCOL', uri, fn) }\n  move (uri, fn) { return this.router.add('MOVE', uri, fn) }\n  notify (uri, fn) { return this.router.add('NOTIFY', uri, fn) }\n  options (uri, fn) { return this.router.add('OPTIONS', uri, fn) }\n  patch (uri, fn) { return this.router.add('PATCH', uri, fn) }\n  post (uri, fn) { return this.router.add('POST', uri, fn) }\n  propfind (uri, fn) { return this.router.add('PROPFIND', uri, fn) }\n  proppatch (uri, fn) { return this.router.add('PROPPATCH', uri, fn) }\n  purge (uri, fn) { return this.router.add('PURGE', uri, fn) }\n  put (uri, fn) { return this.router.add('PUT', uri, fn) }\n  rebind (uri, fn) { return this.router.add('REBIND', uri, fn) }\n  report (uri, fn) { return this.router.add('REPORT', uri, fn) }\n  source (uri, fn) { return this.router.add('SOURCE', uri, fn) }\n  subscribe (uri, fn) { return this.router.add('SUBSCRIBE', uri, fn) }\n  trace (uri, fn) { return this.router.add('TRACE', uri, fn) }\n  unbind (uri, fn) { return this.router.add('UNBIND', uri, fn) }\n  unlink (uri, fn) { return this.router.add('UNLINK', uri, fn) }\n  unlock (uri, fn) { return this.router.add('UNLOCK', uri, fn) }\n  unsubscribe (uri, fn) { return this.router.add('UNSUBSCRIBE', uri, fn) }\n}\nApplication.Asset = require('./Asset')\nApplication.Command = require('./Command')\nApplication.Connect = require('./Connect')\nApplication.Cron = require('./Cron')\nApplication.Database = require('./Database')\nApplication.Email = require('./Email')\nApplication.Event = require('./Event')\nApplication.History = require('./History')\nApplication.HyperText = require('./HyperText')\nApplication.Language = require('./Language')\nApplication.Library = require('./Library')\nApplication.Log = require('./Log')\nApplication.Message = require('./Message')\nApplication.Mapper = require('./Mapper')\nApplication.Navigation = require('./Navigation')\nApplication.Permission = require('./Permission')\nApplication.Profiler = require('./Profiler')\nApplication.Router = require('./Router')\nApplication.Search = require('./Search')\nApplication.Util = require('./Util')\nApplication.View = require('./View')\nmodule.exports = Application\n"]}