{% load static %}
{% load l10n %}
{% load i18n %}

{% block require_config %}
<script>
    var CKEDITOR_BASEPATH = '{{ STATIC_URL }}packages/ckeditor/';
    require.config({
        baseUrl: '{{ STATIC_URL }}js',
        urlArgs: '_dc={{ app_settings.VERSION }}',
        paths: {
            'plugins': '{{ STATIC_URL }}plugins',
            'widget-templates': '{% url "widgets" ""%}'.replace(/\/$/, ""),
            'report-templates': '{% url "report-templates" ""%}'.replace(/\/$/, ""),
            'function-templates': '{% url "function-templates" ""%}'.replace(/\/$/, ""),
            'templates': '{% url "templates" ""%}'.replace(/\/$/, ""),
            'datatype-config-templates': '{% url "datatype_template" ""%}'.replace(/\/$/, ""),
            'nifty': '{{ STATIC_URL }}plugins/nifty',
            'async': '{{ STATIC_URL }}packages/requirejs-plugins/src/async',
            'text': '{{ STATIC_URL }}packages/requirejs-text/text',
            'jquery-lib': '{{ STATIC_URL }}packages/jquery/dist/jquery.min',
            'jquery': '{{ STATIC_URL }}packages/jquery-migrate/dist/jquery-migrate.min',
            'js-cookie': '{{ STATIC_URL }}packages/js-cookie/src/js.cookie',
            'select2': '{{ STATIC_URL }}packages/select2/select2',
            'bootstrap': '{{ STATIC_URL }}packages/bootstrap/dist/js/bootstrap.min',
            'jquery-ui': '{{ STATIC_URL }}packages/jqueryui/jquery-ui.min',
            'backbone': '{{ STATIC_URL }}packages/backbone/backbone-min',
            'underscore': '{{ STATIC_URL }}packages/underscore/underscore-min',
            'jquery-validate': '{{ STATIC_URL }}packages/jquery-validation/dist/jquery.validate.min',
            'd3': '{{ STATIC_URL }}packages/d3/dist/d3.min',
            'dropzone': '{{ STATIC_URL }}packages/dropzone/dist/min/dropzone-amd-module.min',
            'ckeditor': '{{ STATIC_URL }}packages/ckeditor/ckeditor',
            'ckeditor-jquery': '{{ STATIC_URL }}packages/ckeditor/adapters/jquery',
            'knockout': '{{ STATIC_URL }}packages/knockout/build/output/knockout-latest',
            'knockout-mapping': '{{ STATIC_URL }}packages/knockout-mapping/dist/knockout.mapping.min',
            'moment': '{{ STATIC_URL }}packages/moment/min/moment.min',
            'bootstrap-datetimepicker': '{{ STATIC_URL }}packages/eonasdan-bootstrap-datetimepicker/build/js/bootstrap-datetimepicker.min',
            'blueimp-gallery': '{{ STATIC_URL }}packages/blueimp-gallery/js/blueimp-gallery.min',
            'blueimp-jquery': '{{ STATIC_URL }}packages/blueimp-gallery/js/jquery.blueimp-gallery.min',
            'blueimp-helper': '{{ STATIC_URL }}packages/blueimp-gallery/js/blueimp-helper.min',
            'datatables.net': '{{ STATIC_URL }}packages/datatables.net/js/jquery.dataTables.min',
            'datatables.net-bs': '{{ STATIC_URL }}packages/datatables.net-bs/js/dataTables.bootstrap.min',
            'datatables.net-buttons': '{{ STATIC_URL }}packages/datatables.net-buttons/js/dataTables.buttons.min',
            'datatables.net-buttons-print': '{{ STATIC_URL }}packages/datatables.net-buttons/js/buttons.print.min',
            'datatables.net-buttons-html5': '{{ STATIC_URL }}packages/datatables.net-buttons/js/buttons.html5.min',
            'datatables.net-buttons-bs': '{{ STATIC_URL }}packages/datatables.net-buttons-bs/js/buttons.bootstrap.min',
            'datatables.net-responsive': '{{ STATIC_URL }}packages/datatables.net-responsive/js/dataTables.responsive',
            'datatables.net-responsive-bs': '{{ STATIC_URL }}packages/datatables.net-responsive-bs/js/responsive.bootstrap',
            'chosen': '{{ STATIC_URL }}packages/chosen-js/chosen.jquery.min',
            'mapbox-gl': '{{ STATIC_URL }}packages/mapbox-gl/dist/mapbox-gl',
            'mapbox-gl-draw': '{{ STATIC_URL }}packages/@mapbox/mapbox-gl-draw/dist/mapbox-gl-draw',
            'mapbox-gl-geocoder': '{{ STATIC_URL }}packages/@mapbox/mapbox-gl-geocoder/dist/mapbox-gl-geocoder.min',
            'proj4': '{{ STATIC_URL }}packages/proj4/dist/proj4',
            'noUiSlider': '{{ STATIC_URL }}packages/nouislider/distribute/nouislider.min',
            'geojson-extent': '{{ STATIC_URL }}packages/@mapbox/geojson-extent/geojson-extent',
            'geojsonhint': '{{ STATIC_URL }}packages/@mapbox/geojsonhint/geojsonhint',
            'bootstrap-colorpicker': '{{ STATIC_URL }}packages/bootstrap-colorpicker/dist/js/bootstrap-colorpicker.min',
            'uuid': '{{ STATIC_URL }}packages/uuidjs/dist/uuid.core',
            'turf': '{{ STATIC_URL }}packages/@turf/turf/turf.min',
            'geohash': '{{ STATIC_URL }}packages/latlon-geohash/latlon-geohash',
            'leaflet': '{{ STATIC_URL }}packages/leaflet/dist/leaflet',
            'leaflet-iiif': '{{ STATIC_URL }}packages/leaflet-iiif/leaflet-iiif',
            'leaflet-draw': '{{ STATIC_URL }}packages/leaflet-draw/dist/leaflet.draw',
            'leaflet-fullscreen': '{{ STATIC_URL }}packages/leaflet.fullscreen/Control.FullScreen',
            'leaflet-side-by-side': '{{ STATIC_URL }}plugins/leaflet-side-by-side/index',
            'metismenu': '{{ STATIC_URL }}packages/metismenu/dist/metisMenu.min',
            'knockstrap': '{{ STATIC_URL }}packages/knockstrap/build/knockstrap.min',
            'jqtree': '{{ STATIC_URL }}packages/jqtree/tree.jquery',
            'core-js':'{{ STATIC_URL }}packages/core-js/client/shim.min',
            'dom-4': '{{ STATIC_URL }}packages/dom4/build/dom4',
            'numeral': '{{ STATIC_URL }}packages/numeral/numeral',
            'togeojson': '{{ STATIC_URL }}packages/@tmcw/togeojson/dist/togeojson.umd',
            'cytoscape': '{{ STATIC_URL }}packages/cytoscape/dist/cytoscape.min',
            'cytoscape-cola': '{{ STATIC_URL }}packages/cytoscape-cola/cytoscape-cola',
            'webcola': '{{ STATIC_URL }}packages/webcola/WebCola/cola.min',
            {% block paths %}{% endblock paths %}
        },
        packages: [{
            name: "codemirror",
            location: '{{ STATIC_URL }}packages/codemirror',
            main: "lib/codemirror"
        }],
        shim: {
            'nifty': {
                exports: 'nifty',
                deps: ['bootstrap', 'jquery', 'jquery-ui', 'metismenu']
            },
            'metismenu': {
                deps: ['jquery', 'jquery-ui']
            },
            'chosen': {
                deps: ['jquery']
            },
            'bootstrap': {
                deps: ['jquery', 'jquery-ui']
            },
            'knockout-mapping': {
                deps: ['knockout']
            },
            'jquery-validate': {
                deps: ['jquery']
            },
            'jquery-ui': {
                deps: ['jquery']
            },
            'jqtree': {
                deps: ['jquery']
            },
            'datatables': {
                deps: ['jquery']
            },
            'datatables.net': {
                deps: ['jquery']
            },
            'datatables.net-buttons-bs': {
                deps: ['datatables.net-buttons']
            },
            'noUiSlider': {
                deps: ['jquery'],
                exports : '$'
            },
            'jquery': {
                deps: ['jquery-lib'],
                exports : '$'
            },
            'mapbox-gl-draw': {
                deps: ['mapbox-gl']
            },
            'select2': {
                deps: ['jquery'],
            },
            'moment': {
                deps: ['jquery']
            },
            'uuid': {
                exports: 'UUID'
            },
            'geohash': {
                exports: 'Geohash'
            },
            'leaflet-iiif': {
                deps: ['leaflet']
            },
            'leaflet-draw': {
                deps: ['leaflet']
            },
            'leaflet-fullscreen': {
                deps: ['leaflet']
            },
            'ckeditor': {
                deps: ['jquery']
            },
            'ckeditor-jquery': {
                deps: ['ckeditor']
            },
            {% block shim %}{% endblock shim %}
        }
    });
</script>
{% endblock require_config %}

{% block arches_modules %}
<script>
    require(['utils/set-csrf-token']);

    // put values here that should be accessible application wide
    define('arches', [], function () {
        return {
            urls: {
                root: "{% url 'root' %}",
                home: "{% url 'home' %}",
                media: "{{ STATIC_URL }}",
                rdm: "{% url 'rdm' ''%}",
                uploadedfiles: "{{ MEDIA_URL }}",
                url_subpath: "{{app_settings.FORCE_SCRIPT_NAME}}",
                concept_tree: "{% url 'concept_tree' '' %}",
                concept: "{% url 'concept' 'aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa' %}",
                concept_search: "{% url 'concept_search' %}",
                concept_value: "{% url 'concept_value' %}",
                concept_manage_parents: "{% url 'concept_manage_parents' 'aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa' %}",
                concept_make_collection: "{% url 'make_collection' 'aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa' %}",
                change_password: "{% url 'change_password' %}",
                export_concept: "{% url 'export_concept' 'aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa' %}",
                export_concept_collections: "{% url 'export_concept_collections' %}",
                get_concept_collections: "{% url 'get_concept_collections' %}",
                dropdown: "{% url 'dropdown' %}",
                paged_dropdown: "{% url 'paged_dropdown' %}",
                get_pref_label: "{% url 'get_pref_label' %}",
                from_sparql_endpoint: "{% url 'from_sparql_endpoint' 'aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa' %}",
                search_sparql_endpoint: "{% url 'search_sparql_endpoint' %}",
                confirm_delete: "{% url 'confirm_delete' 'aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa' %}",
                search_home: "{% url 'search_home' %}",
                search_terms: "{% url 'search_terms' %}",
                search_results: "{% url 'search_results' %}",
                export_results: "{% url 'export_results' %}",
                get_export_file: "{% url 'get_export_file' %}",
                buffer: "{% url 'buffer'%}",
                config: "{% url 'config' %}",
                node: "{% url 'node' 'aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa' %}",
                graph_nodes: function(graphid){return "{% url 'graph_nodes' 'aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa' %}".replace('aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa', graphid)},
                nodegroup: "{% url 'nodegroup' %}",
                node_layer: "{% url 'node_layer' 'aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa' %}",
                graph: "{% url 'graph' 'aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa' %}".replace('aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa', ''),
                graph_designer: function(graphid){return "{% url 'graph_designer' 'aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa' %}".replace('aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa', graphid)},
                graph_settings: function(graphid){return "{% url 'graph_settings' 'aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa' %}".replace('aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa', graphid)},
                get_notifications: "{% url 'get_notifications' %}",
                dismiss_notifications: "{% url 'dismiss_notifications' %}",
                get_notification_types: "{% url 'get_notification_types' %}",
                update_notification_types: "{% url 'update_notification_types' %}",
                card: "{% url 'card' '' %}",
                reorder_cards: "{% url 'reorder_cards'%}",
                resource: "{% url 'resource' %}",
                resource_editor: "{% url 'resource_editor' 'aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa' %}".replace('aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa', ''),
                resource_copy: "{% url 'resource_copy' 'aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa' %}".replace('aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa', ''),
                resource_report: "{% url 'resource_report' 'aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa' %}".replace('aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa', ''),
                resource_edit_log: "{% url 'resource_edit_log' 'aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa' %}".replace('aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa', ''),
                get_resource_edit_log: function(graphid){return "{% url 'resource_edit_log' 'aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa' %}".replace('aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa', graphid)},
                resource_data: "{% url 'resource_data' 'aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa' 'aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa' %}".replace(/aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa/g, ''),
                resource_cards: "{% url 'resource_cards' 'aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa' %}".replace('aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa', ''),
                related_resources: "{% url 'related_resources' 'aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa' %}".replace('aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa', ''),
                resource_descriptors: "{% url 'resource_descriptors' 'aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa' %}".replace('aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa', ''),
                resource_tiles: "{% url 'resource_tiles' 'aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa' %}",
                tile: "{% url 'tile' %}",
                reorder_tiles: "{% url 'reorder_tiles' %}",
                reorder_nodes: "{% url 'reorder_nodes' %}",
                delete_provisional_tile: "{% url 'delete_provisional_tile' %}",
                tile_history: "{% url 'tile_history' %}",
                download_files: "{% url 'download_files' %}",
                apply_functions: "{% url 'apply_functions' 'aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa' %}".replace('aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa', ''),
                remove_functions: "{% url 'remove_functions' 'aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa' %}".replace('aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa', ''),
                time_wheel_config: "{% url 'time_wheel_config' %}",
                reindex: "{% url 'reindex' %}",
                permission_data: "{% url 'permission_data' %}",
                resource_permission_data: "{% url 'resource_permission_data' %}",
                permission_manager_data: "{% url 'permission_manager_data' %}",
                clear_user_permission_cache: "{% url 'clear_user_permission_cache' %}",
                get_user_names: "{% url 'get_user_names' %}",
                feature_popup_content: "{% url 'feature_popup_content' %}",
                related_resource_candidates: "{% url 'related_resource_candidates' %}",
                relatable_resources: "{% url 'relatable_resources' %}",
                get_domain_connections: function(graphid){return "{% url 'get_domain_connections' 'aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa' %}".replace('aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa', graphid)},
                clone_graph: function(graphid){return "{% url 'clone_graph' 'aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa' %}".replace('aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa', graphid)},
                export_graph: function(graphid){return "{% url 'export_graph' 'aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa' %}".replace('aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa', graphid)},
                delete_graph: function(graphid){return "{% url 'delete_graph' 'aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa' %}".replace('aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa', graphid)},
                delete_instances: function(graphid){return "{% url 'delete_instances' 'aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa' %}".replace('aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa', graphid)},
                export_mapping_file: function(graphid){return "{% url 'export_mapping_file' 'aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa' %}".replace('aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa', graphid)},
                add_resource: function(graphid){return "{% url 'add_resource' 'aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa' %}".replace('aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa', graphid)},
                function_manager: function(graphid){return "{% url 'function_manager' 'aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa' %}".replace('aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa', graphid)},
                mobile_survey_resources: function(surveyid){return "{% url 'mobile_survey_resources' 'aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa' %}".replace('aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa', surveyid)},
                collector_designer: function(surveyid){return "{% url 'collector_designer' 'aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa' %}".replace('aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa', surveyid)},
                plugin: function(pluginid){return "{% url 'plugins' 'aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa' %}".replace('aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa', pluginid)},
                transaction_reverse: function(transactionid) {return "{% url 'transaction_reverse' 'aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa' %}".replace('aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa', transactionid)},
                mvt: function(nodeid){return decodeURI("{% url 'mvt' 'aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa' '{z}' '{x}' '{y}' %}").replace('aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa', nodeid)},
                collector_manager: "{% url 'collector_manager' %}",
                help_template: "{% url 'help_templates' %}",
                graphs_api: "{% url 'graphs_api' 'aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa' %}".replace('aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa', ''),
                api_card: "{% url 'api_card' 'aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa' %}".replace('aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa', ''),
                api_tiles: function (tileid) {
                    return "{% url 'api_tiles' 'aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa' %}".replace('aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa', tileid)
                },
                api_nodegroup: function (nodegroupid) {
                    return "{% url 'api_nodegroup' 'aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa' %}".replace('aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa', nodegroupid)
                },
                api_nodes: function (nodeid) {
                    return "{% url 'api_nodes' 'aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa' %}".replace('aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa', nodeid)
                },
                api_node_value: "{% url 'api_node_value' %}",
                api_resource_report: function(resourceid){return "{% url 'api_resource_report' 'aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa' %}".replace('aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa', resourceid)},
                api_bulk_resource_report: "{% url 'api_bulk_resource_report' %}",
                api_bulk_disambiguated_resource_instance: "{% url 'api_bulk_disambiguated_resource_instance' %}",
                api_resources: function(resourceid){return "{% url 'resources' 'aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa' %}".replace('aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa', resourceid)},
                api_search_component_data: "{% url 'api_search_component_data' 'aaaa'%}".replace('aaaa', ''),
                geojson: "{% url 'geojson' %}",
                icons: "{% url 'icons' %}",
                ontology_properties: "{% url 'ontology_properties' %}",
                iiifmanifest: "{% url 'iiifmanifest' %}",
                manifest_manager: "{% url 'manifest_manager' %}",
                etl_manager: "{% url 'etl_manager' %}",
                iiifannotations: "{% url 'iiifannotations' %}",
                iiifannotationnodes: "{% url 'iiifannotationnodes' %}",
                validatejson: "{% url 'validatejson' 'aaaa'%}".replace('aaaa', ''),
                get_dsl: "{% url 'get_dsl' %}",
                transform_edtf_for_tile: "{% url 'transform_edtf_for_tile' %}",
                {% block urls %}{% endblock urls %}
            },
            geocoderPlaceHolder: "{% trans 'Find an address...' %}",
            confirmNav: {
                title: "{% trans 'Edits pending...' %}",
                text: "{% trans 'You currently have edits pending, are you sure you would like to proceed (and discard any pending edits)?' %}"
            },
            confirmGraphDelete: {
                title: "{% trans 'Delete Branch/Resource Model?' %}",
                text: "{% trans 'Deleting this branch/resource model will remove it (and all associated data) entirely.  Are you sure you would like to proceed?' %}"
            },
            confirmAllResourceDelete: {
                title: "{% trans 'Delete All Resources Associated with this Graph?' %}",
                text: "{% trans 'Deleting All Resources removes all associated data with this graph entirely.  Are you sure you would like to proceed?' %}"
            },
            confirmResourceDelete: {
                title: "{% trans 'Delete Resource?' %}",
                text: "{% trans 'Deleting this resource will remove it (and all associated data) entirely.  Are you sure you would like to proceed?' %}"
            },
            confirmMaplayerDelete: {
                title: "{% trans 'Delete map layer?' %}",
                text: "{% trans 'Deleting this map layer will remove it entirely.  You cannot undo this action.  Are you sure you would like to proceed?' %}"
            },
            confirmSurveyDelete: {
                title: "{% trans 'Delete survey?' %}",
                text: "{% trans 'Deleting this survey will remove it entirely.  You cannot undo this action.  Are you sure you would like to proceed?' %}"
            },
            graphImportFailed: {
                title: "{% trans 'Graph import failed.'%}"
            },
            requestFailed: {
                title: "{% trans 'Request Failed...' %}",
                text: "{% trans 'Sorry! The request failed. Please try again.  Contact your system administrator if the problem persists.' %}"
            },
            resourceCopySuccess: {
                title: "{% trans 'Resource Successfully Copied.'%}",
                text: "{% trans 'Click here to edit copy' %}"
            },
            resourceCopyFailed: {
                title: "{% trans 'Resource Copy Failed...'%}",
                text: "{% trans 'Sorry! The copy request failed. Please try again.  Contact your system administrator if the problem persists.' %}"
            },
            mapboxApiKey: '{{ map_info.mapbox_api_key }}',
            hexBinSize: {{ map_info.hex_bin_size | unlocalize }},
            mapboxSprites: '{{ map_info.mapbox_sprites }}',
            mapboxGlyphs: '{{ map_info.mapbox_glyphs }}',
            hexBinBounds: {{ map_info.hex_bin_bounds }},
            mapDefaultX: {{ map_info.x|unlocalize }},
            mapDefaultY: {{ map_info.y|unlocalize }},
            mapDefaultZoom: {{ map_info.zoom | unlocalize }},
            mapDefaultMinZoom: {{ map_info.map_min_zoom | unlocalize }},
            mapDefaultMaxZoom: {{ map_info.map_max_zoom | unlocalize }},
            preferredCoordinateSystems: {% autoescape off %}{{ map_info.preferred_coordinate_systems }}{% endautoescape %},
            useSemanticRelationships: {{ app_settings.USE_SEMANTIC_RESOURCE_RELATIONSHIPS|lower }},
            geocoderDefault: '{{ map_info.geocoder_default }}',
            mapMarkers: [{% autoescape off %}{% for map_marker in map_markers %}{
                'name': '{{ map_marker.name }}',
                'url': '{{ map_marker.url }}',
            },{% endfor %}{% endautoescape %}],
            mapSources: {{% autoescape off %}{% for map_source in map_sources %}
                '{{ map_source.name }}': {{ map_source.source_json }},
            {% endfor %}{% for resource_map_source in resource_map_sources %}
                '{{ resource_map_source.name }}': {{ resource_map_source.source }},
            {% endfor %}{% endautoescape %}},
            mapLayers: [{% autoescape off %}{% for map_layer in map_layers %}{
                'maplayerid': '{{ map_layer.maplayerid }}',
                'name': '{{ map_layer.name }}',
                'layer_definitions': {{ map_layer.layer_json }},
                'isoverlay': {{ map_layer.isoverlay|lower }},
                'icon': '{{ map_layer.icon }}',
                'legend': '{{ map_layer.legend | default_if_none:"" | escapejs  }}',
                'searchonly': {{ map_layer.searchonly|lower }},
                'activated': {{ map_layer.activated|lower }},
                'addtomap': {{ map_layer.addtomap|lower }},
                'is_resource_layer': false,
                'centerx': {{ map_layer.centerx|default_if_none:"null"|unlocalize }},
                'centery': {{ map_layer.centery|default_if_none:"null"|unlocalize }},
                'zoom': {{ map_layer.zoom|default_if_none:"null"|unlocalize }}
            },{% endfor %}{% for resource_map_layer in resource_map_layers %}{
                'maplayerid': '{{ resource_map_layer.nodeid }}',
                'name': '{{ resource_map_layer.name }}',
                'layer_definitions': {{ resource_map_layer.layer_definitions }},
                'searchonly': false,
                'isoverlay': true,
                'icon': '{{ resource_map_layer.icon }}',
                'legend': '{{ resource_map_layer.legend | escapejs  }}',
                'activated': true,
                'addtomap': {{ resource_map_layer.addtomap|lower }},
                'is_resource_layer': true
            },{% endfor %}{% endautoescape %}],
            conceptCollections: [{% autoescape off %}{% for concept_collection in concept_collections %}{
                'label': '{{ concept_collection.label | escapejs }}',
                'id': '{{ concept_collection.id }}',
            },{% endfor %}{% endautoescape %}],
            geocodingProviders: [{% autoescape off %}{% for provider in geocoding_providers %}{
                'name': '{{ provider.name }}',
                'geocoderid': '{{ provider.geocoderid }}',
                'api_key': {% if provider.api_key != None %} '{{ provider.api_key }}' {% elif provider.api_key == None %} null {% endif %},
                'component': '{{ provider.component }}'
            },{% endfor %}{% endautoescape %}],
            resources: [{% autoescape off %}{% for resource in resource_graphs %}{
              'maplayerid': '{{resource.graphid}}',
              'graphid': '{{resource.graphid}}',
              'name': '{{ resource.name | escapejs }}',
              'icon': '{{ resource.iconclass }}',
            },{% endfor %}{% endautoescape %}],
            userEmail: '{{ user.email }}',
            celeryRunning: '{{celery_running}}',
            exportHtmlTemplates: [{% autoescape off %}{% for template in export_html_templates %}
                '{{ template }}',
            {% endfor %}{% endautoescape %}],
            graphs: {% autoescape off %}{{graphs|default:"[]"}}{% endautoescape %},
            translations: {
                'deactivateSurveyTitle': '{% trans "You are deactivating an active survey" %}',
                'deactivateSurveyMessage': '{% trans "Users will not be able to download this survey to their device" %}',
                'activateSurveyTitle': '{% trans "You are activating this survey" %}',
                'activateSurveyMessage': '{% trans "Users will immediately be able to download this survey and begin collecting data" %}',
                'mapAddPoint': '{% trans "Add point" %}',
                'mapAddLine': '{% trans "Add line" %}',
                'mapAddPolygon': '{% trans "Add polygon" %}',
                'mapSelectDrawing': '{% trans "Select drawing" %}',
                'riSelectCreateNew': '{% trans "Create a new ${graphName}" %}',
                'riSelectPlaceholder': '{% trans "Add new Relationship" %}',
                'reNetworkReponseError': '{% trans "Network response was not ok" %}',
                'workflowWastbinWarning': '{% trans "You are about to delete ${val}." %}',
                'workflowWastbinWarning2': '{% trans "Are you sure you want to continue?" %}',
                'workflowWastbinWarning3': '{% trans "You are about to quit the workflow." %}',
                'termSearchConcept': '{% trans "Concepts" %}',
                'termSearchTerm': '{% trans "Term Matches" %}',
                'timeWheelDateMatches': '{% trans "${total} date values" %}',
                'cardConstraintsPlaceholder': '{% trans "Select Widgets" %}',
                'cardFunctionNodeDesc': '{% trans "(This card data will define the resource description.)" %}',
                'cardFunctionNodeName': '{% trans "(This card data will define the resource name.)" %}',
                'mobileSurveyNameLong': '{% trans "Model Details" %}',
                'mobileSurveyDesc': '{% trans "Summary of how this model participates in the survey" %}',
                'groupingErrorTitle': '{% trans "Settings Conflict: Remove this card from grouped card?" %}',
                'groupingErrorMessage': "{% trans 'The cardinality of this card can\'t be changed until you remove it from being grouped with the ${cardName} card.  Do you want to remove this card from being grouped with the ${cardName} card' %}",
                'modelDoesNotExist': '{% trans "!! Referenced model does not exist -- Delete and select a new model !!" %}',
                'idColumnSelection': '{% trans "Use as an id" %}',
            },
            version: '{{ app_settings.VERSION }}'
        };
    });

    define('resource-types', [], function () {
        var resourceTypes = {
            {% for type, type_data in resource_types %}
            "{{type}}": {
                id: "{{type_data.resourcetypeid}}",
                icon: "{{type_data.icon_class}}",
                name: "{{type_data.name}}",
                defaultDescription: "{{type_data.default_description}}",
                descriptionNode: "{{type_data.description_node}}",
                categories: [
                    {% for category in type_data.categories %}
                    "{{category}}"
                    {% endfor %}
                ],
                color: "{{type_data.marker_color}}",
                strokeColor: "{{type_data.stroke_color}}",
                fillColor: "{{type_data.fill_color}}"
            },
            {% endfor %}
        };

        return resourceTypes;
    });

    define('widgets', [{% for widget in widgets %}'{{ widget.component }}',{% endfor %}], function () {
        return {{% autoescape off %}{% for widget in widgets %}
            '{{ widget.pk }}': {
                'name': '{{ widget.name }}',
                'component': '{{ widget.component }}',
                'datatype': '{{ widget.datatype }}',
                'defaultconfig': '{{ widget.defaultconfig_json }}'
            },
        {% endfor %}{% endautoescape %}};
    });

    define('report-templates', [{% for template in report_templates %}'{{ template.component }}',{% endfor %}], function () {
        return {{% autoescape off %}{% for template in report_templates %}
            '{{ template.pk }}': {
                'componentname': '{{ template.componentname }}',
                'component': '{{ template.component }}',
                'defaultconfig': '{{ template.defaultconfig_json }}',
                'name': '{{ template.name }}',
                'preload_resource_data': '{{ template.preload_resource_data }}'
            },
        {% endfor %}{% endautoescape %}};
    });

    define('card-components', [{% for component in card_components %}'{{ component.component }}',{% endfor %}], function () {
        return {{% autoescape off %}{% for component in card_components %}
            '{{ component.pk }}': {
                'componentname': '{{ component.componentname }}',
                'component': '{{ component.component }}',
                'defaultconfig': '{{ component.defaultconfig_json }}'
            },
        {% endfor %}{% endautoescape %}};
    });

    define('function-templates', [{% for template in function_templates %}'{{ template.component }}',{% endfor %}], function () {
         return;
    });

    define('component-templates', ['views/components/nodegroup-selector','views/components/simple-switch'], function () {
         return;
    });

    define('geocoder-templates', [{% for provider in geocoding_providers %}'{{ provider.component }}',{% endfor %}], function () {
         return;
    });

    define('file-renderers', function () {
        return [{% autoescape off %}{% for renderer in app_settings.RENDERERS %}
                {'name': '{{ renderer.name }}',
                'title': '{{ renderer.title }}',
                'description': '{{ renderer.description }}',
                'component': '{{ renderer.component }}',
                'id': '{{ renderer.id }}',
                'iconclass': '{{ renderer.iconclass }}',
                'text': '{{ renderer.title }}',
                'type': '{{ renderer.type }}',
                'ext': '{{ renderer.ext }}',
                'exclude': '{{ renderer.exclude }}',
                 },
                {% endfor %}{% endautoescape %}];
    });

    define('datatype-config-components',
        [{% for datatype in datatypes %}
            {% if datatype.configcomponent != None %}
            "{{ datatype.configcomponent }}",
            {% endif %}
        {% endfor %}
        ],
        function () { return });

    define('geoms', function () {
        {% autoescape off %}return {{geoms}};{% endautoescape %}
    });

    define('search-components', [{% for component in search_components %}'{{ component.componentpath }}',{% endfor %}], function () {
            return {% autoescape off %}[{% for component in search_components %}
                {{component.toJSON}},
            {% endfor %}]{% endautoescape %};
    });

    define('leaflet-draw-local', [
        'leaflet',
        'leaflet-draw'
    ], function (L) {
        L.drawLocal.draw.toolbar.actions.title = '{% trans "Cancel drawing" %}';
        L.drawLocal.draw.toolbar.actions.text = '{% trans "Cancel" %}';

        L.drawLocal.draw.toolbar.finish.title = '{% trans "Finish drawing" %}';
        L.drawLocal.draw.toolbar.finish.text = '{% trans "Finish" %}';

        L.drawLocal.draw.toolbar.undo.title = '{% trans "Delete last point drawn" %}';
        L.drawLocal.draw.toolbar.undo.text = '{% trans "Delete last point" %}';

        L.drawLocal.draw.toolbar.buttons.polyline = '{% trans "Draw a polyline" %}';
        L.drawLocal.draw.toolbar.buttons.polygon = '{% trans "Draw a polygon" %}';
        L.drawLocal.draw.toolbar.buttons.rectangle = '{% trans "Draw a rectangle" %}';
        L.drawLocal.draw.toolbar.buttons.circle = '{% trans "Draw a circle" %}';
        L.drawLocal.draw.toolbar.buttons.marker = '{% trans "Draw a marker" %}';

        L.drawLocal.draw.handlers.circle.tooltip.start = '{% trans "Click and drag to draw circle." %}';
        L.drawLocal.draw.handlers.circle.radius = '{% trans "Radius" %}';

        L.drawLocal.draw.handlers.marker.tooltip.start = '{% trans "Click map to place marker." %}';

        L.drawLocal.draw.handlers.polygon.tooltip.start = '{% trans "Click to start drawing shape." %}';
        L.drawLocal.draw.handlers.polygon.tooltip.cont = '{% trans "Click to continue drawing shape." %}';
        L.drawLocal.draw.handlers.polygon.tooltip.end = '{% trans "Click first point to close this shape." %}';

        L.drawLocal.draw.handlers.polyline.error = '{% trans "<strong>Error:</strong> shape edges cannot cross!" %}';
        L.drawLocal.draw.handlers.polyline.tooltip.start = '{% trans "Click to start drawing line." %}';
        L.drawLocal.draw.handlers.polyline.tooltip.cont = '{% trans "Click to continue drawing line." %}';
        L.drawLocal.draw.handlers.polyline.tooltip.end = '{% trans "Click last point to finish line." %}';

        L.drawLocal.draw.handlers.rectangle.tooltip.start = '{% trans "Click and drag to draw rectangle." %}';
        L.drawLocal.draw.handlers.simpleshape.tooltip.end = '{% trans "Release mouse to finish drawing." %}';

        L.drawLocal.edit.toolbar.actions.save.title = '{% trans "Apply changes." %}';
        L.drawLocal.edit.toolbar.actions.save.text = '{% trans "Apply" %}';

        L.drawLocal.edit.toolbar.actions.cancel.title = '{% trans "Undo edits, discards all changes." %}';
        L.drawLocal.edit.toolbar.actions.cancel.text = '{% trans "Undo" %}';

        L.drawLocal.edit.toolbar.buttons.edit = '{% trans "Edit drawings." %}';
        L.drawLocal.edit.toolbar.buttons.editDisabled = '{% trans "No drawings to edit." %}';
        L.drawLocal.edit.toolbar.buttons.remove = '{% trans "Delete drawings." %}';
        L.drawLocal.edit.toolbar.buttons.removeDisabled = '{% trans "No drawings to delete." %}';

        L.drawLocal.edit.handlers.edit.tooltip.text = '{% trans "Drag handles, or marker to edit feature." %}';
        L.drawLocal.edit.handlers.edit.tooltip.subtext = '{% trans "Click undo to cancel changes." %}';

        L.drawLocal.edit.handlers.remove.tooltip.text = '{% trans "Click on a feature to remove" %}';
    });
</script>
{% endblock arches_modules %}

{% block project_modules %}
{% endblock project_modules %}
