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AChB,GAAG,KAAK,EAAS,SAAS,SAAS,EAAS,GAGpC,GAAG,WAAW,IACrB,GAAG,SAAS,IACZ,GAAG,SAAS,KAEN,GAAG,SAAS,EAAO,KAAK,SAAS,KACjC,GAAG,SAAS,EAAO,KAAK,SAAS,GAAqB,WACxD,EAAO,KAAK,SAAS,GAAqB,QAAI,CAAC,GAGnD,EAAO,KAAK,SAAS,GAAqB,QAAE,GAAW,EAExD,GAED,IAIG,IAAI,EAAc,QAAQ,aAC1B,KAAK,QAAU,IAAI,EAAY,KAAK,KAAK,UAiBzC,KAAK,QAAU,SAAS,GAE3B,IAAI,EAAS,KAMb,OAJI,EAAU,KACV,EAAS,EAAU,IAGhB,CACJ,EAcA,KAAK,SAAW,SAAS,GAExB,KAAK,QAAQ,KACb,EAAK,KAAK,QAAQ,IAEtB,IAAI,EAAS,EAEb,GAAI,EAAO,MAAQ,EAAO,KAAK,SAAW,EAAO,KAAK,QAAQ,GAAK,CAC/D,IAAI,EAAS,EAAO,KAAK,QAAQ,GAC7B,EAAgB,WACvB,EAAS,EAAgB,SAE1B,CACA,OAAO,CACJ,EAcA,KAAK,MAAQ,SAAS,GAErB,KAAK,QAAQ,KACb,EAAK,KAAK,QAAQ,IAEtB,IAAI,EAAS,UAEb,GAAI,EAAO,MAAQ,EAAO,KAAK,SAAW,EAAO,KAAK,QAAQ,GAAK,CAC/D,IAAI,EAAS,EAAO,KAAK,QAAQ,GAC7B,EAAa,QACpB,EAAS,EAAa,MAEvB,CACA,OAAO,CACJ,CAEJ,EAMA,OAAO,QAAU","file":"/npm/amigo2-instance-data@2.5.17/lib/amigo2-instance-data.js","sourceRoot":"","sourcesContent":["/**\n * Minified by jsDelivr using Terser v5.39.0.\n * Original file: /npm/amigo2-instance-data@2.5.17/lib/amigo2-instance-data.js\n *\n * Do NOT use SRI with dynamically generated files! More information: https://www.jsdelivr.com/using-sri-with-dynamic-files\n */\n","/* \n * The framework to hang the rest of the amigo2 package internals on.\n *\n * @module: amigo2\n */\n\nvar us = require('underscore');\nvar bbop = require('bbop-core');\n\n/**\n * \"Constructor\" for amigo2.\n * \n * Parameters:\n *  more_dispatch - addition to or override of default dispatch table\n *\n * @constructor \n * @returns {Object} amigo2 object\n */\nvar amigo = function(more_dispatch){\n    this._is_a = 'amigo2-instance-data';\n\n    var anchor = this;\n\n    // // The (TODO: now unused?) API lib.\n    // this.api = require('./api');\n\n    // // TODO: No longer necessary w/NPM switch.\n    // this.version = require('./version');\n\n    // // TODO: Not entirely sure what this was doing anyways.\n    //this.data.statistics = require('./data/statistics');\n\n    ///\n    /// Dealing with access to the \"statically\" created instance data.\n    ///\n\n    // .data subsection.\n    this.data = {};\n    // Objects.\n    this.data.context = require('./data/context');\n    this.data.definitions = require('./data/definitions');\n    this.data.golr = require('./data/golr');\n    this.data.xrefs = require('./data/xrefs');\n    this.data.server = require('./data/server');\n\n    ///\n    /// Externalized functions built on our data base.\n    ///\n\n    // Does it look like a term?\n    var meta_data = this.data.server.meta_data;\n    var tre_str = meta_data.term_regexp;\n    var tre = new RegExp(tre_str); // compile upfront\n\n    // Construct a one-time map of aliases to canonical IDs.\n    var alias_map = {};\n    if( anchor.data && anchor.data.context ){\n\tus.each(anchor.data.context, function(context_data, context_id){\n\t    \n\t    if( context_data.aliases ){\n\t\tus.each(context_data.aliases, function(alias){\n\t\t    alias_map[alias] = context_id;\n\t\t});\n\t    }\n\t});\n    }\n    \n    /*\n     * Function: term_id_p\n     * \n     * True or false on whether or not a string looks like a GO term id.\n     * \n     * Parameters:\n     *  term_id - the string to test\n     * \n     * Returns:\n     *  boolean\n     */\n    this.term_id_p =function(term_id){\n\tvar retval = false;\n\tif( tre.test(term_id) ){\n            retval = true;\n\t}\n\treturn retval;\n    };\n\n    /*\n     * Function: get_image_resource\n     * \n     * Get a named resource from the meta_data hash if possible.\n     * \n     * Parameters:\n     *  resource - the string id of the resource\n     * \n     * Returns:\n     * string (url) of resource\n     */\n    this.get_image_resource = function(resource){\n\t\n\tvar retval = null;\n\tvar mangled_res = 'bbop_img_' + resource;\n\t\n\tif( meta_data[mangled_res] ){\n            retval = meta_data[mangled_res];\n\t}\n\treturn retval;\n    };\n\n    ///\n    /// Function/object generators.\n    ///\n\n    // Generate the linker from the internal xrefs and server refs.\n    var linker_gen = require('./linker');\n    this.linker = new linker_gen(this.data.xrefs, this.data.server);\n    \n    // Need the to feed the linker into the dispatch table generator.\n    var dispatch_gen = require('./data/dispatch');\n    anchor.data.dispatch = dispatch_gen(anchor.linker);\n    // Allow override of dispatch table with arguments into AmiGO at\n    // instantiation time.\n    if( us.isObject(more_dispatch) ){\n\tus.each(more_dispatch, function(contexts, field_name){\n\n\t    // Make sure we start with a nice something here.\n\t    if( ! us.isObject(anchor.data.dispatch[field_name]) ){\n\t\tanchor.data.dispatch[field_name] = {};\n\t    }\n\n\t    // Add any default functions (if no context is provided).\n\t    if( us.isFunction(contexts.default) ){\n\t\tanchor.data.dispatch[field_name]['default'] = contexts.default;\n\t    }\n\n\t    // Add additional context information.\n\t    if( contexts.context ){ // double check the jump\n\t\tus.each(contexts.context, function(run_fun, context){\n\n\t\t    // Now merge the structure in if it fits.\n\t\t    if( us.isFunction(run_fun) &&\n\t\t\tus.isString(context) &&\n\t\t\tus.isString(field_name) ){\n\n\t\t\tif( ! us.isObject(anchor.data.dispatch[field_name]) ||\n\t\t\t    ! us.isObject(anchor.data.dispatch[field_name]['context']) ){\n\t\t\t    anchor.data.dispatch[field_name]['context'] = {};\n\t\t\t}\n\t\t\t// Write into the final form.\n\t\t\tanchor.data.dispatch[field_name]['context'][context] = run_fun;\n\t\t    }\n\t\t});\n\t    }\n\t});\n    }\n\n    // Use this nice dispatch table as the argument to the handler.\n    var handler_gen = require('./handler');\n    this.handler = new handler_gen(this.data.dispatch);\n    \n    // .ui subsection.\n    //    this.ui = {};\n\n    /*\n     * Function: dealias\n     * \n     * Attempt to convert an incoming ID into the canonical ID used\n     * for the context.\n     * \n     * Parameters:\n     *  map_id - the string id of the entity\n     * \n     * Returns:\n     *  string (true id) or null\n     */\n    this.dealias = function(map_id){\n\t\n\tvar retval = null;\n\n\tif( alias_map[map_id] ){\n\t    retval = alias_map[map_id];\n\t}\n\n\treturn retval;\n    };\n\n    /*\n     * Function: readable\n     * \n     * Get readable label for the entity, if it can be found in the\n     * context.\n     * \n     * Parameters:\n     *  id - the string id of the entity\n     * \n     * Returns:\n     *  string label, or incoming id if not found\n     */\n    this.readable = function(id){\n\t\n\tif( this.dealias(id) ){\n\t    id = this.dealias(id);\n\t}\n\tvar retval = id;\n\n\tif( anchor.data && anchor.data.context && anchor.data.context[id] ){\n\t    var entry =  anchor.data.context[id];\n\t    if( entry['readable'] ){\n\t\tretval = entry['readable'];\n\t    }\n\t}\n\treturn retval;\n    };\n\n    /*\n     * Function: color\n     * \n     * Get color string for the entity, if it can be found in the\n     * context.\n     * \n     * Parameters:\n     *  id - the string id of the entity\n     * \n     * Returns:\n     *  string label, or \"#888888\" if not found\n     */\n    this.color = function(id){\n\t\n\tif( this.dealias(id) ){\n\t    id = this.dealias(id);\n\t}\n\tvar retval = '#888888';\n\n\tif( anchor.data && anchor.data.context && anchor.data.context[id] ){\n\t    var entry =  anchor.data.context[id];\n\t    if( entry['color'] ){\n\t\tretval = entry['color'];\n\t    }\n\t}\n\treturn retval;\n    };\n\n};\n\n///\n/// Exportable body.\n///\n\nmodule.exports = amigo;\n"]}