{"version":3,"file":"js/app_packs_src_decidim_map_js.js","mappings":";;;;;;;;;;;AAAA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AAGA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AAEA;AACA;AAEA;AAEA;;AAEA;AACA;AACA;AACA;AACA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;ACpCA;AACA;AACA;AAAA;AAGA;AAAA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AAEA;AACA;AAEA;AACA;AAAA;AAAA;AAAA;AAGA;AACA;AAAA;AAAA;AAAA;AAGA;AACA;AAAA;AAAA;AAAA;AAGA;AAEA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;;AAEA;AAAA;AAAA;AAAA;AACA;AAAA;AAAA;AAGA;AACA;AACA;AACA;AACA;AAAA;AAAA;AAAA;AAGA;AACA;AACA;AACA;AACA;AAAA;AAAA;AAAA;AAGA;AACA;AAAA;AAAA;AAAA;AAGA;AACA;AACA;AACA;AACA;AACA;AAAA;AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AC5EA;AACA;AACA;AAAA;AAEA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAEA;AACA;AACA;AACA;AACA;AACA;AAAA;AAAA;AAAA;AAEA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AAAA;AAAA;AAAA;AAGA;AACA;AAAA;AAAA;AAAA;AAGA;AACA;AACA;AACA;AACA;AAAA;AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AChDA;AACA;AACA;AACA;AAAA;AAEA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAEA;AAEA;AACA;AACA;AACA;AACA;AACA;AAAA;AAAA;AAAA;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AAKA;AAEA;AAAA;AAIA;AACA;AACA;AACA;AACA;AACA;AAEA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAAA;AAAA;AACA;AACA;AAAA;AAAA;AACA;AACA;AACA;AACA;AAAA;AAAA;AAAA;AAGA;AACA;AACA;AACA;AAAA;AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;ACzEA;AACA;AAEA;AAAA;AAEA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AAEA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAAA;AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AC3CA;AAAA;AAEA;AAAA;AAAA;AAAA;AAAA;AAAA;AAEA;AACA;AAAA;AAAA;AAAA;AAGA;AACA;AAAA;AAAA;AAAA;AAGA;AACA;AACA;AACA;AAAA;AAAA;;;;;;;;;;;;;;;;ACfA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AAEA;;;;;;;;;;AC7CA;;AAEA;AACA;AACA;AACA;AACA;AACA;AAAA;AACA;AAAA;AAAA;AACA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAAA;AAAA;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAAA;AAAA;AAAA;AAAA;AAAA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AAAA;AAAA;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AAEA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AAAA;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAAA;AAAA;AACA;AACA;AACA;AACA;AACA;AAAA;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAAA;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAAA;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;;AAIA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AAGA;AACA;AAEA;AACA;AAMA;AAAA;AAAA;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAOA;AACA;AACA;AAIA;AAGA;AACA;AACA;AACA;AACA;AACA;AAEA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAAA;AAAA;AAAA;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;AACA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AACA;AAEA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AAGA;AAGA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA","sources":["webpack://decidim-app/./app/packs/src/decidim/map.js","webpack://decidim-app/./app/packs/src/decidim/map/controller.js","webpack://decidim-app/./app/packs/src/decidim/map/controller/drag_marker.js","webpack://decidim-app/./app/packs/src/decidim/map/controller/markers.js","webpack://decidim-app/./app/packs/src/decidim/map/controller/static.js","webpack://decidim-app/./app/packs/src/decidim/map/controller_registry.js","webpack://decidim-app/./app/packs/src/decidim/map/factory.js","webpack://decidim-app/./app/packs/src/decidim/vendor/jquery-tmpl.js"],"sourcesContent":["import \"src/decidim/map/factory\"\n\n$(() => {\n // Load the map controller factory method in the document.ready handler to\n // allow overriding it by any script that is loaded before the document is\n // ready.\n let $mapElements = $(\"[data-decidim-map]\");\n if ($mapElements.length < 1 && $(\"#map\").length > 0) {\n throw new Error(\n \"DEPRECATION: Please update your maps customizations or include 'decidim/map/legacy.js' for legacy support!\"\n );\n }\n\n $mapElements.each((_i, el) => {\n const $map = $(el);\n let mapId = $map.attr(\"id\");\n if (!mapId) {\n mapId = `map-${Math.random().toString(36).substr(2, 9)}`;\n $map.attr(\"id\", mapId);\n }\n\n const mapConfig = $map.data(\"decidim-map\");\n const ctrl = window.Decidim.createMapController(mapId, mapConfig);\n const map = ctrl.load();\n\n $map.data(\"map\", map);\n $map.data(\"map-controller\", ctrl);\n\n $map.trigger(\"configure.decidim\", [map, mapConfig]);\n\n ctrl.start();\n\n // Indicates the map is loaded with the map objects initialized and ready\n // to be used.\n $map.trigger(\"ready.decidim\", [map, mapConfig]);\n });\n});\n","import * as L from \"leaflet\";\nimport \"src/decidim/map/icon\"\nimport MapControllerRegistry from \"src/decidim/map/controller_registry\"\n\nexport default class MapController {\n constructor(mapId, config) {\n // Remove the old map if there is already one with the same ID.\n const old = MapControllerRegistry.getController(mapId);\n if (old) {\n old.remove();\n }\n\n this.mapId = mapId;\n this.config = $.extend({\n popupTemplateId: \"marker-popup\",\n markerColor: \"#ef604d\"\n }, config);\n\n this.map = null;\n this.eventHandlers = {};\n\n MapControllerRegistry.setController(mapId, this);\n }\n\n getConfig() {\n return this.config;\n }\n\n getMap() {\n return this.map;\n }\n\n load() {\n this.map = L.map(this.mapId);\n\n this.map.scrollWheelZoom.disable();\n\n // Fix the keyboard navigation on the map\n this.map.on(\"popupopen\", (ev) => {\n const $popup = $(ev.popup.getElement());\n $popup.attr(\"tabindex\", 0).focus();\n });\n this.map.on(\"popupclose\", (ev) => {\n $(ev.popup._source._icon).focus();\n });\n\n return this.map;\n }\n\n // Override this in the specific map controllers.\n start() {}\n\n remove() {\n if (this.map) {\n this.map.remove();\n this.map = null;\n }\n }\n\n createIcon() {\n return new L.DivIcon.SVGIcon.DecidimIcon({\n fillColor: this.config.markerColor,\n iconSize: L.point(28, 36)\n });\n }\n\n setEventHandler(name, callback) {\n this.eventHandlers[name] = callback;\n }\n\n triggerEvent(eventName, payload) {\n const handler = this.eventHandlers[eventName];\n if (typeof handler === \"function\") {\n return Reflect.apply(handler, this, payload);\n }\n return null;\n }\n}\n","import * as L from \"leaflet\";\nimport MapController from \"src/decidim/map/controller\"\nimport \"src/decidim/vendor/leaflet-tilelayer-here\"\n\nexport default class MapDragMarkerController extends MapController {\n start() {\n if (this.config.marker) {\n this.addMarker(this.config.marker);\n } else {\n this.map.fitWorld();\n }\n }\n\n addMarker(markerData) {\n if (markerData.latitude === null || markerData.longitude === null) {\n return;\n }\n\n const coordinates = {\n lat: markerData.latitude,\n lng: markerData.longitude\n };\n this.triggerEvent(\"coordinates\", [coordinates]);\n\n this.marker = L.marker(coordinates, {\n icon: this.createIcon(),\n keyboard: true,\n title: markerData.title,\n draggable: true\n });\n this.marker.on(\"drag\", (ev) => {\n this.triggerEvent(\"coordinates\", [ev.target.getLatLng()]);\n });\n this.marker.addTo(this.map);\n\n const zoom = parseInt(this.config.zoom, 10) || 14;\n this.map.setView(coordinates, zoom);\n }\n\n getMarker() {\n return this.marker;\n }\n\n removeMarker() {\n if (this.marker) {\n this.marker.remove();\n this.marker = null;\n }\n }\n}\n","import \"src/decidim/vendor/jquery-tmpl\"\nimport * as L from \"leaflet\";\nimport MapController from \"src/decidim/map/controller\"\nimport \"leaflet.markercluster\";\n\nexport default class MapMarkersController extends MapController {\n start() {\n this.markerClusters = null;\n\n if (Array.isArray(this.config.markers) && this.config.markers.length > 0) {\n this.addMarkers(this.config.markers);\n } else {\n this.map.fitWorld();\n }\n }\n\n addMarkers(markersData) {\n if (this.markerClusters === null) {\n this.markerClusters = new L.MarkerClusterGroup();\n this.map.addLayer(this.markerClusters);\n }\n\n // Pre-compiles the template\n $.template(\n this.config.popupTemplateId,\n $(`#${this.config.popupTemplateId}`).html()\n );\n\n const bounds = new L.LatLngBounds(\n markersData.map(\n (markerData) => [markerData.latitude, markerData.longitude]\n )\n );\n\n markersData.forEach((markerData) => {\n let marker = new L.Marker([markerData.latitude, markerData.longitude], {\n icon: this.createIcon(),\n keyboard: true,\n title: markerData.title\n });\n\n let node = document.createElement(\"div\");\n\n $.tmpl(this.config.popupTemplateId, markerData).appendTo(node);\n marker.bindPopup(node, {\n maxwidth: 640,\n minWidth: 500,\n keepInView: true,\n className: \"map-info\"\n }).openPopup();\n\n this.markerClusters.addLayer(marker);\n });\n\n // Make sure there is enough space in the map for the padding to be\n // applied. Otherwise the map will automatically zoom out (test it on\n // mobile). Make sure there is at least the same amount of width and\n // height available on both sides + the padding (i.e. 4x padding in\n // total).\n const size = this.map.getSize();\n if (size.y >= 400 && size.x >= 400) {\n this.map.fitBounds(bounds, { padding: [100, 100] });\n } else if (size.y >= 120 && size.x >= 120) {\n this.map.fitBounds(bounds, { padding: [30, 30] });\n } else {\n this.map.fitBounds(bounds);\n }\n }\n\n clearMarkers() {\n this.map.removeLayer(this.markerClusters);\n this.markerClusters = new L.MarkerClusterGroup();\n this.map.addLayer(this.markerClusters);\n }\n}\n","import * as L from \"leaflet\";\nimport MapController from \"src/decidim/map/controller\"\n\nconst openLink = window.open;\n\nexport default class MapStaticController extends MapController {\n start() {\n this.map.removeControl(this.map.zoomControl);\n this.map.dragging.disable();\n this.map.touchZoom.disable();\n this.map.doubleClickZoom.disable();\n this.map.scrollWheelZoom.disable();\n this.map.boxZoom.disable();\n this.map.keyboard.disable();\n if (this.map.tap) {\n this.map.tap.disable();\n }\n\n if (this.config.zoom) {\n this.map.setZoom(this.config.zoom);\n } else {\n this.map.setZoom(15);\n }\n\n if (this.config.latitude && this.config.longitude) {\n const coordinates = [this.config.latitude, this.config.longitude];\n\n this.map.panTo(coordinates);\n const marker = L.marker(coordinates, {\n icon: this.createIcon(),\n keyboard: true,\n title: this.config.title\n }).addTo(this.map);\n marker._icon.removeAttribute(\"tabindex\");\n }\n\n if (this.config.link) {\n this.map._container.addEventListener(\"click\", (ev) => {\n ev.preventDefault();\n this.map._container.focus();\n openLink(this.config.link, \"_blank\");\n });\n }\n }\n}\n","const CONTROLLER_REGISTRY = {};\n\nexport default class MapControllerRegistry {\n static getController(mapId) {\n return CONTROLLER_REGISTRY[mapId];\n }\n\n static setController(mapId, map) {\n CONTROLLER_REGISTRY[mapId] = map;\n }\n\n static findByMap(map) {\n return Object.values(CONTROLLER_REGISTRY).find((ctrl) => {\n return ctrl.getMap() === map;\n });\n }\n}\n","import MapMarkersController from \"src/decidim/map/controller/markers\"\nimport MapStaticController from \"src/decidim/map/controller/static\"\nimport MapDragMarkerController from \"src/decidim/map/controller/drag_marker\"\n\n/**\n * A factory method that creates a new map controller instance. This method\n * can be overridden in order to return different types of maps for\n * differently configured map elements.\n *\n * For instance, one map could pass an extra `type` configuration with the\n * value \"custom\" for the map element, this factory method would identify\n * it and then return a different controller for that map than the default.\n * This would allow this types of maps to function differently.\n *\n * An example how to use in the ERB view:\n * <%= dynamic_map_for type: \"custom\" do %>\n * <%= javascript_pack_tag \"map_customization\" %>\n * <% end %>\n *\n * And then the actual customization at `map_customization.js.es6`:\n * var originalCreateMapController = window.Decidim.createMapController;\n * window.Decidim.createMapController = (mapId, config) => {\n * if (config.type === \"custom\") {\n * // Obviously you need to implement CustomMapController for this to\n * // work.\n * return new window.Decidim.CustomMapController(mapId, config);\n * }\n *\n * return originalCreateMapController(mapId, config);\n * }\n *\n * @param {string} mapId The ID of the map element.\n * @param {Object} config The map configuration object.\n * @returns {MapController} The controller for the map.\n */\nconst createMapController = function(mapId, config) {\n if (config.type === \"static\") {\n return new MapStaticController(mapId, config);\n } else if (config.type === \"drag-marker\") {\n return new MapDragMarkerController(mapId, config);\n }\n\n return new MapMarkersController(mapId, config);\n}\n\nwindow.Decidim.createMapController = createMapController;\n","/* eslint-disable */\n\n/*\n * jQuery Templating Plugin\n * Copyright 2010, John Resig\n * Dual licensed under the MIT or GPL Version 2 licenses.\n */\n;(function( jQuery, undefined ){\n var oldManip = jQuery.fn.domManip, tmplItmAtt = \"_tmplitem\", htmlExpr = /^[^<]*(<[\\w\\W]+>)[^>]*$|\\{\\{\\! /,\n newTmplItems = {}, wrappedItems = {}, appendToTmplItems, topTmplItem = { key: 0, data: {} }, itemKey = 0, cloneIndex = 0, stack = [];\n\n function newTmplItem( options, parentItem, fn, data ) {\n // Returns a template item data structure for a new rendered instance of a template (a 'template item').\n // The content field is a hierarchical array of strings and nested items (to be\n // removed and replaced by nodes field of dom elements, once inserted in DOM).\n var newItem = {\n data: data || (parentItem ? parentItem.data : {}),\n _wrap: parentItem ? parentItem._wrap : null,\n tmpl: null,\n parent: parentItem || null,\n nodes: [],\n calls: tiCalls,\n nest: tiNest,\n wrap: tiWrap,\n html: tiHtml,\n update: tiUpdate\n };\n if ( options ) {\n jQuery.extend( newItem, options, { nodes: [], parent: parentItem } );\n }\n if ( fn ) {\n // Build the hierarchical content to be used during insertion into DOM\n newItem.tmpl = fn;\n newItem._ctnt = newItem._ctnt || newItem.tmpl( jQuery, newItem );\n newItem.key = ++itemKey;\n // Keep track of new template item, until it is stored as jQuery Data on DOM element\n (stack.length ? wrappedItems : newTmplItems)[itemKey] = newItem;\n }\n return newItem;\n }\n\n // Override appendTo etc., in order to provide support for targeting multiple elements. (This code would disappear if integrated in jquery core).\n jQuery.each({\n appendTo: \"append\",\n prependTo: \"prepend\",\n insertBefore: \"before\",\n insertAfter: \"after\",\n replaceAll: \"replaceWith\"\n }, function( name, original ) {\n jQuery.fn[ name ] = function( selector ) {\n var ret = [], insert = jQuery( selector ), elems, i, l, tmplItems,\n parent = this.length === 1 && this[0].parentNode;\n\n appendToTmplItems = newTmplItems || {};\n if ( parent && parent.nodeType === 11 && parent.childNodes.length === 1 && insert.length === 1 ) {\n insert[ original ]( this[0] );\n ret = this;\n } else {\n for ( i = 0, l = insert.length; i < l; i++ ) {\n cloneIndex = i;\n elems = (i > 0 ? this.clone(true) : this).get();\n jQuery.fn[ original ].apply( jQuery(insert[i]), elems );\n ret = ret.concat( elems );\n }\n cloneIndex = 0;\n ret = this.pushStack( ret, name, insert.selector );\n }\n tmplItems = appendToTmplItems;\n appendToTmplItems = null;\n jQuery.tmpl.complete( tmplItems );\n return ret;\n };\n });\n\n jQuery.fn.extend({\n // Use first wrapped element as template markup.\n // Return wrapped set of template items, obtained by rendering template against data.\n tmpl: function( data, options, parentItem ) {\n return jQuery.tmpl( this[0], data, options, parentItem );\n },\n\n // Find which rendered template item the first wrapped DOM element belongs to\n tmplItem: function() {\n return jQuery.tmplItem( this[0] );\n },\n\n // Consider the first wrapped element as a template declaration, and get the compiled template or store it as a named template.\n template: function( name ) {\n return jQuery.template( name, this[0] );\n },\n\n domManip: function( args, table, callback, options ) {\n // This appears to be a bug in the appendTo, etc. implementation\n // it should be doing .call() instead of .apply(). See #6227\n if ( args[0] && args[0].nodeType ) {\n var dmArgs = jQuery.makeArray( arguments ), argsLength = args.length, i = 0, tmplItem;\n while ( i < argsLength && !(tmplItem = jQuery.data( args[i++], \"tmplItem\" ))) {}\n if ( argsLength > 1 ) {\n dmArgs[0] = [jQuery.makeArray( args )];\n }\n if ( tmplItem && cloneIndex ) {\n dmArgs[2] = function( fragClone ) {\n // Handler called by oldManip when rendered template has been inserted into DOM.\n jQuery.tmpl.afterManip( this, fragClone, callback );\n };\n }\n oldManip.apply( this, dmArgs );\n } else {\n oldManip.apply( this, arguments );\n }\n cloneIndex = 0;\n if ( !appendToTmplItems ) {\n jQuery.tmpl.complete( newTmplItems );\n }\n return this;\n }\n });\n\n jQuery.extend({\n // Return wrapped set of template items, obtained by rendering template against data.\n tmpl: function( tmpl, data, options, parentItem ) {\n var ret, topLevel = !parentItem;\n if ( topLevel ) {\n // This is a top-level tmpl call (not from a nested template using {{tmpl}})\n parentItem = topTmplItem;\n tmpl = jQuery.template[tmpl] || jQuery.template( null, tmpl );\n wrappedItems = {}; // Any wrapped items will be rebuilt, since this is top level\n } else if ( !tmpl ) {\n // The template item is already associated with DOM - this is a refresh.\n // Re-evaluate rendered template for the parentItem\n tmpl = parentItem.tmpl;\n newTmplItems[parentItem.key] = parentItem;\n parentItem.nodes = [];\n if ( parentItem.wrapped ) {\n updateWrapped( parentItem, parentItem.wrapped );\n }\n // Rebuild, without creating a new template item\n return jQuery( build( parentItem, null, parentItem.tmpl( jQuery, parentItem ) ));\n }\n if ( !tmpl ) {\n return []; // Could throw...\n }\n if ( typeof data === \"function\" ) {\n data = data.call( parentItem || {} );\n }\n if ( options && options.wrapped ) {\n updateWrapped( options, options.wrapped );\n }\n ret = jQuery.isArray( data ) ?\n jQuery.map( data, function( dataItem ) {\n return dataItem ? newTmplItem( options, parentItem, tmpl, dataItem ) : null;\n }) :\n [ newTmplItem( options, parentItem, tmpl, data ) ];\n return topLevel ? jQuery( build( parentItem, null, ret ) ) : ret;\n },\n\n // Return rendered template item for an element.\n tmplItem: function( elem ) {\n var tmplItem;\n if ( elem instanceof jQuery ) {\n elem = elem[0];\n }\n while ( elem && elem.nodeType === 1 && !(tmplItem = jQuery.data( elem, \"tmplItem\" )) && (elem = elem.parentNode) ) {}\n return tmplItem || topTmplItem;\n },\n\n // Set:\n // Use $.template( name, tmpl ) to cache a named template,\n // where tmpl is a template string, a script element or a jQuery instance wrapping a script element, etc.\n // Use $( \"selector\" ).template( name ) to provide access by name to a script block template declaration.\n\n // Get:\n // Use $.template( name ) to access a cached template.\n // Also $( selectorToScriptBlock ).template(), or $.template( null, templateString )\n // will return the compiled template, without adding a name reference.\n // If templateString includes at least one HTML tag, $.template( templateString ) is equivalent\n // to $.template( null, templateString )\n template: function( name, tmpl ) {\n if (tmpl) {\n // Compile template and associate with name\n if ( typeof tmpl === \"string\" ) {\n // This is an HTML string being passed directly in.\n tmpl = buildTmplFn( tmpl )\n } else if ( tmpl instanceof jQuery ) {\n tmpl = tmpl[0] || {};\n }\n if ( tmpl.nodeType ) {\n // If this is a template block, use cached copy, or generate tmpl function and cache.\n tmpl = jQuery.data( tmpl, \"tmpl\" ) || jQuery.data( tmpl, \"tmpl\", buildTmplFn( tmpl.innerHTML ));\n }\n return typeof name === \"string\" ? (jQuery.template[name] = tmpl) : tmpl;\n }\n // Return named compiled template\n return name ? (typeof name !== \"string\" ? jQuery.template( null, name ):\n (jQuery.template[name] ||\n // If not in map, treat as a selector. (If integrated with core, use quickExpr.exec)\n jQuery.template( null, htmlExpr.test( name ) ? name : jQuery( name )))) : null;\n },\n\n encode: function( text ) {\n // Do HTML encoding replacing < > & and ' and \" by corresponding entities.\n return (\"\" + text).split(\"<\").join(\"<\").split(\">\").join(\">\").split('\"').join(\""\").split(\"'\").join(\"'\");\n }\n });\n\n jQuery.extend( jQuery.tmpl, {\n tag: {\n \"tmpl\": {\n _default: { $2: \"null\" },\n open: \"if($notnull_1){_=_.concat($item.nest($1,$2));}\"\n // tmpl target parameter can be of type function, so use $1, not $1a (so not auto detection of functions)\n // This means that {{tmpl foo}} treats foo as a template (which IS a function).\n // Explicit parens can be used if foo is a function that returns a template: {{tmpl foo()}}.\n },\n \"wrap\": {\n _default: { $2: \"null\" },\n open: \"$item.calls(_,$1,$2);_=[];\",\n close: \"call=$item.calls();_=call._.concat($item.wrap(call,_));\"\n },\n \"each\": {\n _default: { $2: \"$index, $value\" },\n open: \"if($notnull_1){$.each($1a,function($2){with(this){\",\n close: \"}});}\"\n },\n \"if\": {\n open: \"if(($notnull_1) && $1a){\",\n close: \"}\"\n },\n \"else\": {\n _default: { $1: \"true\" },\n open: \"}else if(($notnull_1) && $1a){\"\n },\n \"html\": {\n // Unecoded expression evaluation.\n open: \"if($notnull_1){_.push($1a);}\"\n },\n \"=\": {\n // Encoded expression evaluation. Abbreviated form is ${}.\n _default: { $1: \"$data\" },\n open: \"if($notnull_1){_.push($.encode($1a));}\"\n },\n \"!\": {\n // Comment tag. Skipped by parser\n open: \"\"\n }\n },\n\n // This stub can be overridden, e.g. in jquery.tmplPlus for providing rendered events\n complete: function( items ) {\n newTmplItems = {};\n },\n\n // Call this from code which overrides domManip, or equivalent\n // Manage cloning/storing template items etc.\n afterManip: function afterManip( elem, fragClone, callback ) {\n // Provides cloned fragment ready for fixup prior to and after insertion into DOM\n var content = fragClone.nodeType === 11 ?\n jQuery.makeArray(fragClone.childNodes) :\n fragClone.nodeType === 1 ? [fragClone] : [];\n\n // Return fragment to original caller (e.g. append) for DOM insertion\n callback.call( elem, fragClone );\n\n // Fragment has been inserted:- Add inserted nodes to tmplItem data structure. Replace inserted element annotations by jQuery.data.\n storeTmplItems( content );\n cloneIndex++;\n }\n });\n\n //========================== Private helper functions, used by code above ==========================\n\n function build( tmplItem, nested, content ) {\n // Convert hierarchical content into flat string array\n // and finally return array of fragments ready for DOM insertion\n var frag, ret = content ? jQuery.map( content, function( item ) {\n return (typeof item === \"string\") ?\n // Insert template item annotations, to be converted to jQuery.data( \"tmplItem\" ) when elems are inserted into DOM.\n (tmplItem.key ? item.replace( /(<\\w+)(?=[\\s>])(?![^>]*_tmplitem)([^>]*)/g, \"$1 \" + tmplItmAtt + \"=\\\"\" + tmplItem.key + \"\\\" $2\" ) : item) :\n // This is a child template item. Build nested template.\n build( item, tmplItem, item._ctnt );\n }) :\n // If content is not defined, insert tmplItem directly. Not a template item. May be a string, or a string array, e.g. from {{html $item.html()}}.\n tmplItem;\n if ( nested ) {\n return ret;\n }\n\n // top-level template\n ret = ret.join(\"\");\n\n // Support templates which have initial or final text nodes, or consist only of text\n // Also support HTML entities within the HTML markup.\n ret.replace( /^\\s*([^<\\s][^<]*)?(<[\\w\\W]+>)([^>]*[^>\\s])?\\s*$/, function( all, before, middle, after) {\n frag = jQuery( middle ).get();\n\n storeTmplItems( frag );\n if ( before ) {\n frag = unencode( before ).concat(frag);\n }\n if ( after ) {\n frag = frag.concat(unencode( after ));\n }\n });\n return frag ? frag : unencode( ret );\n }\n\n function unencode( text ) {\n // Use createElement, since createTextNode will not render HTML entities correctly\n var el = document.createElement( \"div\" );\n el.innerHTML = text;\n return jQuery.makeArray(el.childNodes);\n }\n\n // Generate a reusable function that will serve to render a template against data\n function buildTmplFn( markup ) {\n return new Function(\"jQuery\",\"$item\",\n \"var $=jQuery,call,_=[],$data=$item.data;\" +\n\n // Introduce the data as local variables using with(){}\n \"with($data){_.push('\" +\n\n // Convert the template into pure JavaScript\n jQuery.trim(markup)\n .replace( /([\\\\'])/g, \"\\\\$1\" )\n .replace( /[\\r\\t\\n]/g, \" \" )\n .replace( /\\$\\{([^\\}]*)\\}/g, \"{{= $1}}\" )\n .replace( /\\{\\{(\\/?)(\\w+|.)(?:\\(((?:[^\\}]|\\}(?!\\}))*?)?\\))?(?:\\s+(.*?)?)?(\\(((?:[^\\}]|\\}(?!\\}))*?)\\))?\\s*\\}\\}/g,\n function( all, slash, type, fnargs, target, parens, args ) {\n var tag = jQuery.tmpl.tag[ type ], def, expr, exprAutoFnDetect;\n if ( !tag ) {\n throw \"Template command not found: \" + type;\n }\n def = tag._default || [];\n if ( parens && !/\\w$/.test(target)) {\n target += parens;\n parens = \"\";\n }\n if ( target ) {\n target = unescape( target );\n args = args ? (\",\" + unescape( args ) + \")\") : (parens ? \")\" : \"\");\n // Support for target being things like a.toLowerCase();\n // In that case don't call with template item as 'this' pointer. Just evaluate...\n expr = parens ? (target.indexOf(\".\") > -1 ? target + parens : (\"(\" + target + \").call($item\" + args)) : target;\n exprAutoFnDetect = parens ? expr : \"(typeof(\" + target + \")==='function'?(\" + target + \").call($item):(\" + target + \"))\";\n } else {\n exprAutoFnDetect = expr = def.$1 || \"null\";\n }\n fnargs = unescape( fnargs );\n return \"');\" +\n tag[ slash ? \"close\" : \"open\" ]\n .split( \"$notnull_1\" ).join( target ? \"typeof(\" + target + \")!=='undefined' && (\" + target + \")!=null\" : \"true\" )\n .split( \"$1a\" ).join( exprAutoFnDetect )\n .split( \"$1\" ).join( expr )\n .split( \"$2\" ).join( fnargs ?\n fnargs.replace( /\\s*([^\\(]+)\\s*(\\((.*?)\\))?/g, function( all, name, parens, params ) {\n params = params ? (\",\" + params + \")\") : (parens ? \")\" : \"\");\n return params ? (\"(\" + name + \").call($item\" + params) : all;\n })\n : (def.$2||\"\")\n ) +\n \"_.push('\";\n }) +\n \"');}return _;\"\n );\n }\n function updateWrapped( options, wrapped ) {\n // Build the wrapped content.\n options._wrap = build( options, true,\n // Suport imperative scenario in which options.wrapped can be set to a selector or an HTML string.\n jQuery.isArray( wrapped ) ? wrapped : [htmlExpr.test( wrapped ) ? wrapped : jQuery( wrapped ).html()]\n ).join(\"\");\n }\n\n function unescape( args ) {\n return args ? args.replace( /\\\\'/g, \"'\").replace(/\\\\\\\\/g, \"\\\\\" ) : null;\n }\n function outerHtml( elem ) {\n var div = document.createElement(\"div\");\n div.appendChild( elem.cloneNode(true) );\n return div.innerHTML;\n }\n\n // Store template items in jQuery.data(), ensuring a unique tmplItem data data structure for each rendered template instance.\n function storeTmplItems( content ) {\n var keySuffix = \"_\" + cloneIndex, elem, elems, newClonedItems = {}, i, l, m;\n for ( i = 0, l = content.length; i < l; i++ ) {\n if ( (elem = content[i]).nodeType !== 1 ) {\n continue;\n }\n elems = elem.getElementsByTagName(\"*\");\n for ( m = elems.length - 1; m >= 0; m-- ) {\n processItemKey( elems[m] );\n }\n processItemKey( elem );\n }\n function processItemKey( el ) {\n var pntKey, pntNode = el, pntItem, tmplItem, key;\n // Ensure that each rendered template inserted into the DOM has its own template item,\n if ( (key = el.getAttribute( tmplItmAtt ))) {\n while ( pntNode.parentNode && (pntNode = pntNode.parentNode).nodeType === 1 && !(pntKey = pntNode.getAttribute( tmplItmAtt ))) { }\n if ( pntKey !== key ) {\n // The next ancestor with a _tmplitem expando is on a different key than this one.\n // So this is a top-level element within this template item\n // Set pntNode to the key of the parentNode, or to 0 if pntNode.parentNode is null, or pntNode is a fragment.\n pntNode = pntNode.parentNode ? (pntNode.nodeType === 11 ? 0 : (pntNode.getAttribute( tmplItmAtt ) || 0)) : 0;\n if ( !(tmplItem = newTmplItems[key]) ) {\n // The item is for wrapped content, and was copied from the temporary parent wrappedItem.\n tmplItem = wrappedItems[key];\n tmplItem = newTmplItem( tmplItem, newTmplItems[pntNode]||wrappedItems[pntNode], null, true );\n tmplItem.key = ++itemKey;\n newTmplItems[itemKey] = tmplItem;\n }\n if ( cloneIndex ) {\n cloneTmplItem( key );\n }\n }\n el.removeAttribute( tmplItmAtt );\n } else if ( cloneIndex && (tmplItem = jQuery.data( el, \"tmplItem\" )) ) {\n // This was a rendered element, cloned during append or appendTo etc.\n // TmplItem stored in jQuery data has already been cloned in cloneCopyEvent. We must replace it with a fresh cloned tmplItem.\n cloneTmplItem( tmplItem.key );\n newTmplItems[tmplItem.key] = tmplItem;\n pntNode = jQuery.data( el.parentNode, \"tmplItem\" );\n pntNode = pntNode ? pntNode.key : 0;\n }\n if ( tmplItem ) {\n pntItem = tmplItem;\n // Find the template item of the parent element.\n // (Using !=, not !==, since pntItem.key is number, and pntNode may be a string)\n while ( pntItem && pntItem.key != pntNode ) {\n // Add this element as a top-level node for this rendered template item, as well as for any\n // ancestor items between this item and the item of its parent element\n pntItem.nodes.push( el );\n pntItem = pntItem.parent;\n }\n // Delete content built during rendering - reduce API surface area and memory use, and avoid exposing of stale data after rendering...\n delete tmplItem._ctnt;\n delete tmplItem._wrap;\n // Store template item as jQuery data on the element\n jQuery.data( el, \"tmplItem\", tmplItem );\n }\n function cloneTmplItem( key ) {\n key = key + keySuffix;\n tmplItem = newClonedItems[key] =\n (newClonedItems[key] || newTmplItem( tmplItem, newTmplItems[tmplItem.parent.key + keySuffix] || tmplItem.parent, null, true ));\n }\n }\n }\n\n //---- Helper functions for template item ----\n\n function tiCalls( content, tmpl, data, options ) {\n if ( !content ) {\n return stack.pop();\n }\n stack.push({ _: content, tmpl: tmpl, item:this, data: data, options: options });\n }\n\n function tiNest( tmpl, data, options ) {\n // nested template, using {{tmpl}} tag\n return jQuery.tmpl( jQuery.template( tmpl ), data, options, this );\n }\n\n function tiWrap( call, wrapped ) {\n // nested template, using {{wrap}} tag\n var options = call.options || {};\n options.wrapped = wrapped;\n // Apply the template, which may incorporate wrapped content,\n return jQuery.tmpl( jQuery.template( call.tmpl ), call.data, options, call.item );\n }\n\n function tiHtml( filter, textOnly ) {\n var wrapped = this._wrap;\n return jQuery.map(\n jQuery( jQuery.isArray( wrapped ) ? wrapped.join(\"\") : wrapped ).filter( filter || \"*\" ),\n function(e) {\n return textOnly ?\n e.innerText || e.textContent :\n e.outerHTML || outerHtml(e);\n });\n }\n\n function tiUpdate() {\n var coll = this.nodes;\n jQuery.tmpl( null, null, null, this).insertBefore( coll[0] );\n jQuery( coll ).remove();\n }\n})( jQuery );\n"],"names":[],"sourceRoot":""}