<commit_before>define([
    'flight/lib/component',
    '../withDropdown',
    'detail/properties/properties',
    'tpl!./termForm',
    'tpl!./concept-options',
    'tpl!./entity',
    'service/vertex',
    'service/ontology',
    'util/vertex/formatters',
    'tpl!util/alert',
    'util/jquery.removePrefixedClasses'
], function(
    defineComponent,
    withDropdown,
    Properties,
    dropdownTemplate,
    conceptsTemplate,
    entityTemplate,
    VertexService,
    OntologyService,
    F,
    alertTemplate) {
    'use strict';

    return defineComponent(TermForm, withDropdown);

    function TermForm() {
        this.vertexService = new VertexService();
        this.ontologyService = new OntologyService();

        this.defaultAttrs({
            entityConceptMenuSelector: '.underneath .dropdown-menu a',
            actionButtonSelector: '.btn.btn-small.btn-primary',
            buttonDivSelector: '.buttons',
            objectSignSelector: '.object-sign',
            graphVertexSelector: '.graphVertexId',
            visibilitySelector: '.visibility',
            conceptSelector: 'select',
            helpSelector: '.help',
            addNewPropertiesSelector: '.none'
        });

        this.after('teardown', function() {
            if (this.promoted && this.promoted.length) {
                this.demoteSpanToTextVertex(this.promoted);
            }

            var info = $(this.attr.mentionNode).removeClass('focused').data('info');

            if (info) {
                this.updateConceptLabel(info['http://lumify.io#conceptType'] || '');
            }

            // Remove extra textNodes
            if (this.node.parentNode) {
                this.node.parentNode.normalize();
            }
        });

        this.after('initialize', function() {
            this.deferredConcepts = $.Deferred();
            this.setupContent();
            this.registerEvents();
        });

        this.showTypeahead = function() {
            if (!this.unresolve) {
                this.select('objectSignSelector').typeahead('lookup');
            }
        };

        this.onKeyPress = function(event) {
            if (!this.lastQuery || this.lastQuery === this.select('objectSignSelector').val()) {
                if (!this.select('actionButtonSelector').is(':disabled')) {
                    switch (event.which) {
                        case $.ui.keyCode.ENTER:
                            this.onButtonClicked(event);
                    }
                }
                return;
            }

            if (!this.debouncedLookup) {
                this.debouncedLookup = _.debounce(function() {
                    this.select('objectSignSelector').typeahead('lookup');
                }.bind(this), 100);
            }

            this.debouncedLookup();
        };

        this.reset = function() {
            this.currentGraphVertexId = null;
            this.select('helpSelector').show();
            this.select('visibilitySelector').hide();
            this.select('conceptSelector').attr('disabled', true).hide();
            this.select('actionButtonSelector').hide();
            this.updateResolveImageIcon();
        };

        this.graphVertexChanged = function(newGraphVertexId, item, initial) {
            var self = this;

            this.currentGraphVertexId = newGraphVertexId;
            if (!initial || newGraphVertexId) {
                this.select('graphVertexSelector').val(newGraphVertexId);
                var info = _.isObject(item) ? item.properties || item : $(this.attr.mentionNode).data('info');

                if (newGraphVertexId) {
                    this.select('conceptSelector').attr('disabled', true);
                } else {
                    this.select('conceptSelector').attr('disabled', false);
                }
                var conceptType = (info && (
                    (info['http://lumify.io#conceptType'] && info['http://lumify.io#conceptType'].value) ||
                        info['http://lumify.io#conceptType'] ||
                        (info.properties &&
                         info.properties['http://lumify.io#conceptType'] &&
                         info.properties['http://lumify.io#conceptType'].value)
                    )) || '';

                this.updateConceptSelect(conceptType).show();

                if (this.unresolve) {<commit_msg>fix resolving to an existing entity [Delivers #70670764]<commit_after>define([
    'flight/lib/component',
    '../withDropdown',
    'detail/properties/properties',
    'tpl!./termForm',
    'tpl!./concept-options',
    'tpl!./entity',
    'service/vertex',
    'service/ontology',
    'util/vertex/formatters',
    'tpl!util/alert',
    'util/jquery.removePrefixedClasses'
], function(
    defineComponent,
    withDropdown,
    Properties,
    dropdownTemplate,
    conceptsTemplate,
    entityTemplate,
    VertexService,
    OntologyService,
    F,
    alertTemplate) {
    'use strict';

    return defineComponent(TermForm, withDropdown);

    function TermForm() {
        this.vertexService = new VertexService();
        this.ontologyService = new OntologyService();

        this.defaultAttrs({
            entityConceptMenuSelector: '.underneath .dropdown-menu a',
            actionButtonSelector: '.btn.btn-small.btn-primary',
            buttonDivSelector: '.buttons',
            objectSignSelector: '.object-sign',
            graphVertexSelector: '.graphVertexId',
            visibilitySelector: '.visibility',
            conceptSelector: 'select',
            helpSelector: '.help',
            addNewPropertiesSelector: '.none'
        });

        this.after('teardown', function() {
            if (this.promoted && this.promoted.length) {
                this.demoteSpanToTextVertex(this.promoted);
            }

            var info = $(this.attr.mentionNode).removeClass('focused').data('info');

            if (info) {
                this.updateConceptLabel(info['http://lumify.io#conceptType'] || '');
            }

            // Remove extra textNodes
            if (this.node.parentNode) {
                this.node.parentNode.normalize();
            }
        });

        this.after('initialize', function() {
            this.deferredConcepts = $.Deferred();
            this.setupContent();
            this.registerEvents();
        });

        this.showTypeahead = function() {
            if (!this.unresolve) {
                this.select('objectSignSelector').typeahead('lookup');
            }
        };

        this.onKeyPress = function(event) {
            if (!this.lastQuery || this.lastQuery === this.select('objectSignSelector').val()) {
                if (!this.select('actionButtonSelector').is(':disabled')) {
                    switch (event.which) {
                        case $.ui.keyCode.ENTER:
                            this.onButtonClicked(event);
                    }
                }
                return;
            }

            if (!this.debouncedLookup) {
                this.debouncedLookup = _.debounce(function() {
                    this.select('objectSignSelector').typeahead('lookup');
                }.bind(this), 100);
            }

            this.debouncedLookup();
        };

        this.reset = function() {
            this.currentGraphVertexId = null;
            this.select('helpSelector').show();
            this.select('visibilitySelector').hide();
            this.select('conceptSelector').attr('disabled', true).hide();
            this.select('actionButtonSelector').hide();
            this.updateResolveImageIcon();
        };

        this.graphVertexChanged = function(newGraphVertexId, item, initial) {
            var self = this;

            this.currentGraphVertexId = newGraphVertexId;
            if (!initial || newGraphVertexId) {
                this.select('graphVertexSelector').val(newGraphVertexId);
                var info = _.isObject(item) ? item.properties || item : $(this.attr.mentionNode).data('info');

                if (newGraphVertexId) {
                    this.select('conceptSelector').attr('disabled', true);
                } else {
                    this.select('conceptSelector').attr('disabled', false);
                }
                var conceptType = _.findWhere(info, { name: 'http://lumify.io#conceptType' });
                conceptType = conceptType ? conceptType.value : '';

                this.updateConceptSelect(conceptType).show();

                if (this.unresolve) {
{'fraction_non_alphanumeric': 0.13298932801688754, 'fraction_numerical': 0.0016418435557640435, 'mean_word_length': 1.7979002624671916, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5218813', 'n_tokens_mistral': 2250, 'n_tokens_neox': 2118, 'n_words': 318}