<commit_before>/*
 | Copyright 2014 Esri
 |
 | Licensed under the Apache License, Version 2.0 (the "License");
 | you may not use this file except in compliance with the License.
 | You may obtain a copy of the License at
 |
 |    http://www.apache.org/licenses/LICENSE-2.0
 |
 | Unless required by applicable law or agreed to in writing, software
 | distributed under the License is distributed on an "AS IS" BASIS,
 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 | See the License for the specific language governing permissions and
 | limitations under the License.
 */

define(["dojo/ready", 
    "dojo/aspect", "dijit/registry",
    "dojo/json", "dojo/_base/array", "dojo/_base/Color", "dojo/_base/declare", 
    "dojo/_base/lang", "dojo/dom", "dojo/dom-geometry", "dojo/dom-attr", "dojo/dom-class", 
    "dojo/dom-construct", "dojo/dom-style", "dojo/on", "dojo/Deferred", "dojo/promise/all", 
    "dojo/query", "dijit/Menu", "dijit/CheckedMenuItem", "application/toolbar", 
    "application/has-config", "esri/arcgis/utils", "esri/lang", 
    "dijit/layout/BorderContainer", "dijit/layout/ContentPane", "dijit/focus",
    "esri/tasks/query", 
    "esri/dijit/HomeButton", "esri/dijit/LocateButton", 
    "esri/dijit/Legend", "esri/dijit/BasemapGallery", 
    "dojo/i18n!application/nls/BaseMapLabels",
    "esri/dijit/Measurement", "esri/dijit/OverviewMap", "esri/geometry/Extent", 
    "esri/layers/FeatureLayer", "application/NavToolBar/NavToolBar", 
    "application/FeatureList", "application/Filters/Filters", "application/TableOfContents", 
    "application/LanguageSelect/LanguageSelect",
    "application/ShareDialog", //"application/SearchSources",
    "esri/symbols/SimpleMarkerSymbol", "esri/symbols/PictureMarkerSymbol", "esri/graphic",
    "esri/dijit/InfoWindow",
    "dojo/NodeList-dom", "dojo/NodeList-traverse"], 
    function (
    ready, 
    aspect, registry,
    JSON, array, Color, declare, 
    lang, dom, domGeometry, domAttr, domClass, 
    domConstruct, domStyle, on, Deferred, all, 
    query, Menu, CheckedMenuItem, Toolbar, 
    has, arcgisUtils, esriLang, 
    BorderContainer, ContentPane, focusUtil,
    Query,
    HomeButton, LocateButton, 
    Legend, BasemapGallery, 
    i18n_BaseMapLabels,
    Measurement, OverviewMap, Extent, 
    FeatureLayer, NavToolBar,
    FeatureList, Filters, TableOfContents, LanguageSelect,
    ShareDialog, //SearchSources,
    SimpleMarkerSymbol, PictureMarkerSymbol, Graphic,
    InfoWindow) {

    return declare(null, {
        config: {},
        color: null,
        theme: null,
        map: null,
        initExt: null,
        mapExt: null,
        editorDiv: null,
        editor: null,
        editableLayers: null,
        timeFormats: ["shortDateShortTime", "shortDateLEShortTime", "shortDateShortTime24", "shortDateLEShortTime24", "shortDateLongTime", "shortDateLELongTime", "shortDateLongTime24", "shortDateLELongTime24"],
        
        startup: function (config) {
            // config will contain application and user defined info for the template such as i18n strings, the web map id
            // and application id and any url parameters and any application specific configuration information.
            if (config) {
                this.config = config;
                this.color = this.setColor(this.config.color);
                this.hoverColor = typeof(this.config.hoverColor)=='undefined' ? this.setColor('#000000', 0.4) : this.setColor(this.config.hoverColor, 0.9);
                this.focusColor = typeof(this.config.focusColor)=='undefined' ? this.setColor('#1f1f1f', 0.4) : this.setColor(this.config.focusColor, 0.9);
                this.activeColor = typeof(this.config.activeColor)=='undefined' ? this.focusColor : this.setColor(this.config.activeColor, 0.9);
                this.theme = this.setColor(this.config.theme);
                // document ready
                ready(lang.hitch(this, function () {
                    //supply either the webmap id or, if available, the item info
                    var itemInfo = this.config.itemInfo || this.config.webmap;
                    //If a custom extent is set as a url parameter handle that before creating the map
                    if (this.config.extent) {
                        var extArray = decodeURIComponent(this.config.extent).split(",");

                        if (extArray.length === 4) {
                            itemInfo.item.extent = [
                            [parseFloat(extArray[0]), parseFloat(extArray[1])],
                            [parseFloat(extArray[2]), parseFloat(extArray[3])]
                            ];
                        } else if (extArray.length === 5) {
                            this.initExt = new Extent(JSON.parse(this.config.extent));
                        }
                    }
                    this._createWebMap(itemInfo);
                }));
            } else {
                var error = new Error("Main:: Config is not defined");
                this.reportError(error);
            }

            var languages = [
                {
                    code:this.config.lang1code,
                    img:this.config.lang1imageSrc,
                    shortName:this.config.lang1shortName,
                    name:this.config.lang1name,
                    appId:this.config.lang1appId 
                },
                {
                    code:this.config.lang2code,
                    img:this.config.lang2imageSrc,
                    shortName:this.config.lang2shortName,
                    name:this.config.lang2name,
                    appId:this.config.lang2appId
                },
                {
                    code:this.config.lang3code,
                    img:this.config.lang3imageSrc,
                    shortName:this.config.lang3shortName,
                    name:this.config.lang3name,
                    appId:this.config.lang3appId
                }
            ];
            new LanguageSelect({
                locale: document.documentElement.lang,
                location: window.location,
                languages:languages,
            }, dom.byId('languageSelectNode')).startup();

        },

        reportError: function (error) {
            // remove loading class from body
            domClass.replace(document.body, "app-error","app-loading");
            // an error occurred - notify the user. In this example we pull the string from the
            // resource.js file located in the nls folder because we've set the application up
            // for localization. If you don't need to support multiple languages you can hardcode the<commit_msg>LanguageSelect button in active color<commit_after>/*
 | Copyright 2014 Esri
 |
 | Licensed under the Apache License, Version 2.0 (the "License");
 | you may not use this file except in compliance with the License.
 | You may obtain a copy of the License at
 |
 |    http://www.apache.org/licenses/LICENSE-2.0
 |
 | Unless required by applicable law or agreed to in writing, software
 | distributed under the License is distributed on an "AS IS" BASIS,
 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 | See the License for the specific language governing permissions and
 | limitations under the License.
 */

define(["dojo/ready", 
    "dojo/aspect", "dijit/registry",
    "dojo/json", "dojo/_base/array", "dojo/_base/Color", "dojo/_base/declare", 
    "dojo/_base/lang", "dojo/dom", "dojo/dom-geometry", "dojo/dom-attr", "dojo/dom-class", 
    "dojo/dom-construct", "dojo/dom-style", "dojo/on", "dojo/Deferred", "dojo/promise/all", 
    "dojo/query", "dijit/Menu", "dijit/CheckedMenuItem", "application/toolbar", 
    "application/has-config", "esri/arcgis/utils", "esri/lang", 
    "dijit/layout/BorderContainer", "dijit/layout/ContentPane", "dijit/focus",
    "esri/tasks/query", 
    "esri/dijit/HomeButton", "esri/dijit/LocateButton", 
    "esri/dijit/Legend", "esri/dijit/BasemapGallery", 
    "dojo/i18n!application/nls/BaseMapLabels",
    "esri/dijit/Measurement", "esri/dijit/OverviewMap", "esri/geometry/Extent", 
    "esri/layers/FeatureLayer", "application/NavToolBar/NavToolBar", 
    "application/FeatureList", "application/Filters/Filters", "application/TableOfContents", 
    "application/LanguageSelect/LanguageSelect",
    "application/ShareDialog", //"application/SearchSources",
    "esri/symbols/SimpleMarkerSymbol", "esri/symbols/PictureMarkerSymbol", "esri/graphic",
    "esri/dijit/InfoWindow",
    "dojo/NodeList-dom", "dojo/NodeList-traverse"], 
    function (
    ready, 
    aspect, registry,
    JSON, array, Color, declare, 
    lang, dom, domGeometry, domAttr, domClass, 
    domConstruct, domStyle, on, Deferred, all, 
    query, Menu, CheckedMenuItem, Toolbar, 
    has, arcgisUtils, esriLang, 
    BorderContainer, ContentPane, focusUtil,
    Query,
    HomeButton, LocateButton, 
    Legend, BasemapGallery, 
    i18n_BaseMapLabels,
    Measurement, OverviewMap, Extent, 
    FeatureLayer, NavToolBar,
    FeatureList, Filters, TableOfContents, LanguageSelect,
    ShareDialog, //SearchSources,
    SimpleMarkerSymbol, PictureMarkerSymbol, Graphic,
    InfoWindow) {

    return declare(null, {
        config: {},
        color: null,
        theme: null,
        map: null,
        initExt: null,
        mapExt: null,
        editorDiv: null,
        editor: null,
        editableLayers: null,
        timeFormats: ["shortDateShortTime", "shortDateLEShortTime", "shortDateShortTime24", "shortDateLEShortTime24", "shortDateLongTime", "shortDateLELongTime", "shortDateLongTime24", "shortDateLELongTime24"],
        
        startup: function (config) {
            // config will contain application and user defined info for the template such as i18n strings, the web map id
            // and application id and any url parameters and any application specific configuration information.
            if (config) {
                this.config = config;
                this.color = this.setColor(this.config.color);
                this.hoverColor = typeof(this.config.hoverColor)=='undefined' ? this.setColor('#000000', 0.4) : this.setColor(this.config.hoverColor, 0.9);
                this.focusColor = typeof(this.config.focusColor)=='undefined' ? this.setColor('#1f1f1f', 0.4) : this.setColor(this.config.focusColor, 0.9);
                this.activeColor = typeof(this.config.activeColor)=='undefined' ? this.focusColor : this.setColor(this.config.activeColor, 0.9);
                this.theme = this.setColor(this.config.theme);
                // document ready
                ready(lang.hitch(this, function () {
                    //supply either the webmap id or, if available, the item info
                    var itemInfo = this.config.itemInfo || this.config.webmap;
                    //If a custom extent is set as a url parameter handle that before creating the map
                    if (this.config.extent) {
                        var extArray = decodeURIComponent(this.config.extent).split(",");

                        if (extArray.length === 4) {
                            itemInfo.item.extent = [
                            [parseFloat(extArray[0]), parseFloat(extArray[1])],
                            [parseFloat(extArray[2]), parseFloat(extArray[3])]
                            ];
                        } else if (extArray.length === 5) {
                            this.initExt = new Extent(JSON.parse(this.config.extent));
                        }
                    }
                    this._createWebMap(itemInfo);
                }));
            } else {
                var error = new Error("Main:: Config is not defined");
                this.reportError(error);
            }

            var languages = [
                {
                    code:this.config.lang1code,
                    img:this.config.lang1imageSrc,
                    shortName:this.config.lang1shortName,
                    name:this.config.lang1name,
                    appId:this.config.lang1appId 
                },
                {
                    code:this.config.lang2code,
                    img:this.config.lang2imageSrc,
                    shortName:this.config.lang2shortName,
                    name:this.config.lang2name,
                    appId:this.config.lang2appId
                },
                {
                    code:this.config.lang3code,
                    img:this.config.lang3imageSrc,
                    shortName:this.config.lang3shortName,
                    name:this.config.lang3name,
                    appId:this.config.lang3appId
                }
            ];
            new LanguageSelect({
                locale: document.documentElement.lang,
                location: window.location,
                languages:languages,
                textColor:this.activeColor
            }, dom.byId('languageSelectNode')).startup();

        },

        reportError: function (error) {
            // remove loading class from body
            domClass.replace(document.body, "app-error","app-loading");
            // an error occurred - notify the user. In this example we pull the string from the
            // resource.js file located in the nls folder because we've set the application up
            // for localization. If you don't need to support multiple languages you can hardcode the
{'fraction_non_alphanumeric': 0.1100111648678824, 'fraction_numerical': 0.009229624116114625, 'mean_word_length': 2.090867264780308, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, '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': '6661299', 'n_tokens_mistral': 3858, 'n_tokens_neox': 3662, 'n_words': 828}