PageSourceSearch

https://alin.net/wp-content/cache/min/1/wp-content/plugins/mapsvg/dist/mapsvg-front.umd.js?ver=1717480286

js alin.net collected 2026-10-02 13:37:35 UTC 368,372 bytes, 1,632 lines download raw bytes

1(function(global,factory){typeof exports==='object'&&typeof module!=='undefined'?factory(exports,require('Handlebars'),require('Bloodhound'),require('CodeMirror')):typeof define==='function'&&define.amd?define(['exports','Handlebars','Bloodhound','CodeMirror'],factory):(global=global||self,factory(global.mapsvg={},global.Handlebars,global.Bloodhound,global.CodeMirror))}(this,(function(exports,Handlebars,Bloodhound,CodeMirror){'use strict';Handlebars=Handlebars&&Handlebars.hasOwnProperty('default')?Handlebars['default']:Handlebars;Bloodhound=Bloodhound&&Bloodhound.hasOwnProperty('default')?Bloodhound['default']:Bloodhound;var MapSVG=function(){};const $=jQuery;MapSVG.formBuilder={};MapSVG.mediaUploader={};if(typeof wp!=="undefined"&&typeof wp.media!=="undefined"){MapSVG.mediaUploader=wp.media({title:"Choose images",button:{text:"Choose images",},multiple:!0,})}
2MapSVG.templatesLoaded={};if(typeof mapsvg_paths!=="undefined"){MapSVG.urls=mapsvg_paths}else{MapSVG.urls={}}
3if(typeof ajaxurl!=="undefined"){MapSVG.urls.ajaxurl=ajaxurl}
4MapSVG.instances=[];MapSVG.userAgent=navigator.userAgent.toLowerCase();MapSVG.touchDevice="ontouchstart" in window||navigator.MaxTouchPoints>0||navigator.msMaxTouchPoints>0;MapSVG.ios=MapSVG.userAgent.indexOf("ipad")>-1||MapSVG.userAgent.indexOf("iphone")>-1||MapSVG.userAgent.indexOf("ipod")>-1;MapSVG.android=MapSVG.userAgent.indexOf("android");MapSVG.isPhone=window.matchMedia("only screen and (max-width: 812px)").matches;MapSVG.browser={};MapSVG.browser.ie=MapSVG.userAgent.indexOf("msie")>-1||MapSVG.userAgent.indexOf("trident")>-1||MapSVG.userAgent.indexOf("edge")>-1?{}:!1;MapSVG.browser.firefox=MapSVG.userAgent.indexOf("firefox")>-1;MapSVG.browser.safari=MapSVG.userAgent.indexOf("safari")>-1&&MapSVG.userAgent.indexOf("chrome")===-1;var ua=window.navigator.userAgent;MapSVG.device={};MapSVG.device.ios=!!ua.match(/iPad/i)||!!ua.match(/iPhone/i);MapSVG.device.android=!!ua.match(/Android/i);if(!String.prototype.trim){String.prototype.trim=function(){return this.replace(/^\s+|\s+$/g,"")}}
5MapSVG.mouseCoords=function(e){if(e.clientX){return{x:e.clientX+$(document).scrollLeft(),y:e.clientY+$(document).scrollTop()}}
6if(e.pageX){return{x:e.pageX,y:e.pageY}}else if(MapSVG.touchDevice){e=e.originalEvent||e;return e.touches&&e.touches[0]?{x:e.touches[0].pageX,y:e.touches[0].pageY}:{x:e.changedTouches[0].pageX,y:e.changedTouches[0].pageY}}};MapSVG.addInstance=function(mapsvg){MapSVG.instances.push(mapsvg)};MapSVG.get=function(index){return MapSVG.instances[index]};MapSVG.getById=function(id){var instance=MapSVG.instances.filter(function(i){return i.id==id});if(instance.length>0){return instance[0]}};MapSVG.getByContainerId=function(id){var instance=MapSVG.instances.filter(function(i){return i.$map.attr("id")==id});if(instance.length>0){return instance[0]}};MapSVG.extend=function(sub,base){sub.prototype=Object.create(base.prototype);sub.prototype.constructor=sub};MapSVG.ucfirst=function(string){return string.charAt(0).toUpperCase()+string.slice(1)};MapSVG.parseBoolean=function(string){switch(String(string).toLowerCase()){case "on":case "true":case "1":case "yes":case "y":return!0;case "off":case "false":case "0":case "no":case "n":return!1;default:return undefined}};MapSVG.isNumber=function(n){return!isNaN(parseFloat(n))&&isFinite(n)};MapSVG.safeURL=function(url){if(url.indexOf("http://")==0||url.indexOf("https://")==0)
7url="//"+url.split("://").pop();return url.replace(/^.*\/\/[^\/]+/,"")};MapSVG.convertToText=function(obj){var string=[];if(obj===null){return null}
8if(obj===undefined){return'""'}else if(typeof obj=="object"&&obj.join==undefined){var prop;for(prop in obj){if(obj.hasOwnProperty(prop)){var key='"'+prop.replace(/\"/g,'\\"')+'"';string.push(key+": "+MapSVG.convertToText(obj[prop]))}}
9return"{"+string.join(",")+"}"}else if(typeof obj=="object"&&!(obj.join==undefined)){var prop;for(prop in obj){string.push(MapSVG.convertToText(obj[prop]))}
10return"["+string.join(",")+"]"}else if(typeof obj=="function"){return obj.toString().replace("function anonymous","function")}else{return JSON.stringify(obj)}};if(!("remove" in Element.prototype)){Element.prototype.remove=function(){if(this.parentNode){this.parentNode.removeChild(this)}}}
11Math.hypot=Math.hypot||function(){var y=0;var length=arguments.length;for(var i=0;i<length;i++){if(arguments[i]===Infinity||arguments[i]===-Infinity){return Infinity}
12y+=arguments[i]*arguments[i]}
13return Math.sqrt(y)};SVGElement.prototype.getTransformToElement=SVGElement.prototype.getTransformToElement||function(toElement){let value;try{value=toElement.getScreenCTM().inverse().multiply(this.getScreenCTM())}catch(e){return}
14return value};Map.prototype.toArray=function(){return Array.from(this,([name,value])=>value)};MapSVG.ResizeSensor=class ResizeSensor{constructor(element,callback){var _this=this;_this.element=element;_this.callback=callback;var style=getComputedStyle(element);var zIndex=parseInt(style.zIndex);if(isNaN(zIndex)){zIndex=0}
15zIndex--;_this.expand=document.createElement("div");_this.expand.style.position="absolute";_this.expand.style.left="0px";_this.expand.style.top="0px";_this.expand.style.right="0px";_this.expand.style.bottom="0px";_this.expand.style.overflow="hidden";_this.expand.style.zIndex=zIndex.toString();_this.expand.style.visibility="hidden";var expandChild=document.createElement("div");expandChild.style.position="absolute";expandChild.style.left="0px";expandChild.style.top="0px";expandChild.style.width="10000000px";expandChild.style.height="10000000px";_this.expand.appendChild(expandChild);_this.shrink=document.createElement("div");_this.shrink.style.position="absolute";_this.shrink.style.left="0px";_this.shrink.style.top="0px";_this.shrink.style.right="0px";_this.shrink.style.bottom="0px";_this.shrink.style.overflow="hidden";_this.shrink.style.zIndex=zIndex.toString();_this.shrink.style.visibility="hidden";var shrinkChild=document.createElement("div");shrinkChild.style.position="absolute";shrinkChild.style.left="0px";shrinkChild.style.top="0px";shrinkChild.style.width="200%";shrinkChild.style.height="200%";_this.shrink.appendChild(shrinkChild);_this.element.appendChild(_this.expand);_this.element.appendChild(_this.shrink);var size=element.getBoundingClientRect();_this.currentWidth=size.width;_this.currentHeight=size.height;_this.setScroll();_this.expand.addEventListener("scroll",function(){_this.onScroll()});_this.shrink.addEventListener("scroll",function(){_this.onScroll()})}
16onScroll(){var _this=this;var size=_this.element.getBoundingClientRect();var newWidth=size.width;var newHeight=size.height;if(newWidth!=_this.currentWidth||newHeight!=_this.currentHeight){_this.currentWidth=newWidth;_this.currentHeight=newHeight;_this.callback()}
17this.setScroll()}
18setScroll(){this.expand.scrollLeft=10000000;this.expand.scrollTop=10000000;this.shrink.scrollLeft=10000000;this.shrink.scrollTop=10000000}
19destroy(){this.expand.remove();this.shrink.remove()}};MapSVG.nonce=function(){return mapsvg_runtime_vars.nonce};MapSVG.fixColorHash=(color)=>{const hexColorNoHash=new RegExp(/^([0-9a-f]{3}|[0-9a-f]{6})$/i);if(color&&color.match(hexColorNoHash)!==null){color="#"+color}
20return color};MapSVG.throttle=(method,delay,scope,params)=>{clearTimeout(method._tId);method._tId=setTimeout(function(){method.apply(scope,params)},delay)};MapSVG.geocode=(query,callback)=>
20{if(!window.google){console.error("MapSVG: can't do Geocoding - Google Maps API is not loaded.");jQuery.growl.error({title:"Error",message:"Google Maps API files are not loaded",});return!1}
21if(!MapSVG.geocoder){MapSVG.geocoder=new google.maps.Geocoder()}
22MapSVG.throttle(MapSVG.geocoder.geocode,500,MapSVG.geocoder,[query,function(results,status){if(status==="OK"){callback(results)}else{jQuery.growl.error({title:"Error: "+status,message:"There is some problem with Google API keys. See browser's console for more details",})}},])};MapSVG.handleFailedRequest=(response)=>{var message="";if(response.status===403){if(response.responseText.indexOf("Wordfence")!==-1){message+="The request has been blocked by Wordfence. "+'Switch Wordfence to "Learning mode", and save the map settings again. '+"If the settings are saved successfully, you can switch Wordfence back to normal mode."}else{message+="The request has been blocked by your server. "+"Do you have mod_sec Apache's module enabled? If that's the case you need to change its settings."}}else{if(response&&response.responseText){try{var _response=JSON.parse(response.responseText);if(_response&&_response.data&&_response.data.error){message=_response.data.error}}catch(e){}}}
23$.growl.error({title:"Error: "+response.status+" "+response.statusText,message:message,duration:30000,})};if(!Object.values){Object.values=function(object){return Object.keys(object).map(function(k){return object[k]})}}
24window.MapSVG=MapSVG;const defRegionTemplate="<div>\n"+"  <p>This is the demo content of the <strong>Region %templateType%</strong>.</p>\n"+'  <p>How to edit it: if you are in mapsvg control panel now, click on the following link to open the template editor for this view: <a href="#" class="mapsvg-template-link" data-template="%templateTypeSnake%Region">Menu > Templates > Region %templateType%</a>.</p>\n'+'  <p>More information about templates: <a href="https://mapsvg.com/docs/map-editor/templates" target="_blank">mapsvg.com/docs/map-editor/templates</a></p>\n'+"</div>\n"+"<hr />\n\n"+"<!-- Region fields are available in this template -->\n"+"<h5>{{#if title}} {{title}} {{else}} {{id}} {{/if}}</h5>\n"+"<p>Status: {{status_text}}</p>\n\n"+"<!-- Show all linked Database Objects: -->\n"+"{{#each objects}}\n\n"+"  <!-- DB Object are available inside of this block -->\n\n"+"  <h5>{{title}}</h5>\n"+"  <!-- When you need to render a field as HTML, use 3 curly braces instead of 2:-->\n"+"  <p>{{{description}}}</p>\n"+"  <p><em>{{location.address.formatted}}</em></p>\n\n"+"  <!-- Show all images: -->\n"+"  {{#each images}}\n"+'    <!-- Image fields "thumbnail", "medium", "full" -->\n'+"    <!-- are available in this block                -->\n"+'    <img src="{{thumbnail}}" />\n'+"  {{/each}}\n\n"+"{{/each}}";const defDBTemplate="<div>\n"+"  <p>This is the demo content of the <strong>DB Object %templateType%</strong>.</p>\n"+'  <p>How to edit it: if you are in mapsvg control panel now, click on the following link to open the template editor for this view: <a href="#" class="mapsvg-template-link" data-template="%templateTypeSnake%">Menu > Templates > DB Object %templateType%</a>.</p>\n'+'  <p>More information about templates: <a href="https://mapsvg.com/docs/map-editor/templates" target="_blank">mapsvg.com/docs/map-editor/templates</a></p>\n'+"</div>\n"+"<hr />\n\n"+"<!-- DB Object fields are available in this template. -->\n"+"<h5>{{title}}</h5>\n"+"<!-- When you need to render a fields as HTML, use 3 curly braces instead of 2:-->\n"+"<p>{{{description}}}</p>\n"+"<p><em>{{location.address.formatted}}</em></p>\n\n"+"<!-- Show all images: -->\n"+"{{#each images}}\n"+'  <!-- Image fields "thumbnail", "medium", "full" -->\n'+"  <!-- are available in this block                -->\n"+'  <img src="{{thumbnail}}" />\n'+"{{/each}}\n\n"+"<!-- Show all linked Regions, comma-separated: -->\n"+"<p> Regions: \n"+"  {{#each regions}}\n"+"    <!-- Region fields are available in this block -->\n"+"    {{#if title}}\n"+"      {{title}}\n"+"    {{else}}\n"+"      {{id}}\n"+"    {{/if}}{{#unless @last}}, {{/unless}}\n"+"  {{/each}}\n"+"</p>";const dirItemItemTemplate="<!-- If Directory Source = Database: DB Object fields are available in this template -->\n"+"<!-- If Directory Source = Regions: Region fields are available in this template -->\n"+"{{title}}";const DefaultOptions={source:"",markerLastID:0,regionLastID:0,dataLastID:1,disableAll:!1,width:null,height:null,lockAspectRatio:!1,padding:{top:0,left:0,right:0,bottom:0},maxWidth:null,maxHeight:null,minWidth:null,minHeight:null,loadingText:"Loading map...",colorsIgnore:!1,colors:{baseDefault:"#000000",background:"#eeeeee",selected:4
240,hover:20,directory:"#fafafa",detailsView:"",status:{},clusters:"",clustersBorders:"",clustersText:"",clustersHover:"",clustersHoverBorders:"",clustersHoverText:"",markers:{base:{opacity:100,saturation:100},hovered:{opacity:100,saturation:100},unhovered:{opacity:40,saturation:100},active:{opacity:100,saturation:100},inactive:{opacity:40,saturation:100},},},regions:{},clustering:{on:!1},viewBox:[],cursor:"default",manualRegions:!1,onClick:null,mouseOver:null,mouseOut:null,menuOnClick:null,beforeLoad:null,afterLoad:null,zoom:{on:!0,limit:[0,22],delta:2,buttons:{on:!0,location:"right"},mousewheel:!0,fingers:!0,hideSvg:!1,hideSvgZoomLevel:7,},scroll:{on:!0,limit:!1,background:!1,spacebar:!1},responsive:!0,tooltips:{on:!1,position:"bottom-right",template:"",maxWidth:"",minWidth:100},popovers:{on:!1,position:"top",template:"",centerOn:!0,width:300,maxWidth:50,maxHeight:50,},multiSelect:!1,regionStatuses:{"1":{label:"Enabled",value:"1",color:"",disabled:!1},"0":{label:"Disabled",value:"0",color:"",disabled:!0},},events:{afterLoad:"function(){\n"+"  // var mapsvg = this;\n"+"  // var regions = mapsvg.regions;\n"+"  // var dbObjects = mapsvg.database.getLoaded();\n"+"}",beforeLoad:"function(){\n"+"  // var mapsvg = this;\n"+"  // var settings = mapsvg.options;\n"+"  // console.log(settings);\n"+"}",databaseLoaded:"function (){\n"+"  // var mapsvg = this;\n"+"  // var dbObjects = mapsvg.database.getLoaded();\n"+"}","click.region":"function (e, mapsvg){\n"+"  // var region = this;\n"+"  // console.log(region);\n"+"}","mouseover.region":"function (e, mapsvg){\n"+"  // var region = this;\n"+"  // console.log(region);\n"+"}","mouseout.region":"function (e, mapsvg){\n"+"  // var region = this;\n"+"  // console.log(region);\n"+"}","click.marker":"function (e, mapsvg){\n"+"  // var marker = this;\n"+"  // console.log(marker);\n"+"}","mouseover.marker":"function (e, mapsvg){\n"+"  // var marker = this;\n"+"  // console.log(marker);\n"+"}","mouseout.marker":"function (e, mapsvg){\n"+"  // var marker = this;\n"+"  // console.log(marker);\n"+"}","click.directoryItem":"function (e, regionOrObject, mapsvg){\n"+"  // var itemjQueryObject = this;\n"+"}","mouseover.directoryItem":"function (e, regionOrObject, mapsvg){\n"+"  // var itemjQueryObject = this;\n"+"}","mouseout.directoryItem":"function (e, regionOrObject, mapsvg){\n"+"  // var itemjQueryObject = this;\n"+"}","shown.popover":"function (mapsvg){\n"+"  // var popoverjQueryObject = this;\n"+"}","closed.popover":"function (mapsvg){\n"+"  // var popoverjQueryObject = this;\n"+"}","closed.detailsView":"function (mapsvg){\n"+"  // var detailsjQueryObject = this;\n"+"}","shown.detailsView":"function (mapsvg){\n"+"  // var detailsjQueryObject = this;\n"+"}",}
24,css:"#mapsvg-map-%id% .mapsvg-tooltip {\n\n}\n"+"#mapsvg-map-%id% .mapsvg-popover {\n\n}\n"+"#mapsvg-map-%id% .mapsvg-details-container {\n\n}\n"+"#mapsvg-map-%id% .mapsvg-directory-item {\n\n}\n"+"#mapsvg-map-%id% .mapsvg-region-label {\n"+"  /* background-color: rgba(255,255,255,.6); */\n"+"  font-size: 11px;\n"+"  padding: 3px 5px;\n"+"  border-radius: 4px;\n"+"}\n"+"#mapsvg-map-%id% .mapsvg-marker-label {\n"+"  padding: 3px 5px;\n"+"  /*\n"+"  border-radius: 4px;\n"+"  background-color: white;\n"+"  margin-top: -4px;\n"+"  */\n}\n"+"#mapsvg-map-%id% .mapsvg-filters-wrap {\n\n}\n"+"\n\n\n\n\n\n",templates:{popoverRegion:defRegionTemplate.replace(/%templateType%/g,"Popover").replace(/%templateTypeSnake%/g,"popover"),popoverMarker:defDBTemplate.replace(/%templateType%/g,"Popover").replace(/%templateTypeSnake%/g,"popover"),tooltipRegion:"<!-- Region fields are available in this template -->\n{{id}} - {{title}}",tooltipMarker:"<!-- DB Object fields are available in this template -->\n{{title}}",directoryItem:dirItemItemTemplate,directoryCategoryItem:'<!-- Available fields: "label", "value", "counter" -->\n<span class="mapsvg-category-label">{{label}}</span>\n<span class="mapsvg-category-counter">{{counter}}</span>\n<span class="mapsvg-chevron"></span>',detailsView:defDBTemplate.replace(/%templateType%/g,"Details View").replace(/%templateTypeSnake%/g,"detailsView"),detailsViewRegion:defRegionTemplate.replace(/%templateType%/g,"Details View").replace(/%templateTypeSnake%/g,"detailsView"),labelMarker:"<!-- DB Object fields are available in this template -->\n{{title}}",labelRegion:"<!-- Region fields are available in this template -->\n{{title}}",labelLocation:"You are here!",},choropleth:{on:!1,source:"regions",sourceFieldSelect:{on:!1,variants:[],},bubbleMode:!1,bubbleSize:{min:20,max:40,},labels:{low:"low",high:"high"},colors:{lowRGB:null,highRGB:null,low:"#550000",high:"#ee0000",noData:"#333333"},min:0,max:0,coloring:{mode:"gradient",noData:{color:"#999999",description:"No data",},gradient:{colors:{lowRGB:null,highRGB:null,diffRGB:null,low:"#550000",high:"#ee0000",},labels:{low:"low",high:"high",},values:{min:null,max:null,maxAdjusted:null,},},palette:{outOfRange:{color:"#ececec",description:"Out of range",},colors:[{color:"#550000",valueFrom:0,valueTo:50,description:"",},],},legend:{on:!0,layout:"vertical",container:"bottom-left",title:"Choropleth map",text:"",description:"",width:"20%",height:"20%",},},},filters:{on:!0,source:"database",location:"header",modalLocation:"map",width:"100%",hide:!1,showButtonText:"Filters",clearButtonText:"Clear all",clearButton:!1,searchButton:!1,searchButtonText:"Search",padding:"",},menu:{on:!1,hideOnMobile:!0,location:"leftSidebar",locationMobile:"leftSidebar",search:!1,containerId:"",searchPlaceholder:"Search...",searchFallback:!1,source:"database",showFirst:"map",showMapOnClick:!0,minHeight:"400",sortBy:"id",sortDirection:"desc",categories:{on:!1,groupBy:"",hideEmpty:!0,collapse:!0,collapseOther:!0,},clickActions:{region:"default",marker:"default",directoryItem:{triggerClick:!0,showPopover:!1,showDetail
24s:!0,},},detailsViewLocation:"overDirectory",noResultsText:"No results found",filterout:{field:"",cond:"=",val:""},},database:{pagination:{on:!0,perpage:30,next:"Next",prev:"Prev.",showIn:"both",},loadOnStart:!0,table:"",},actions:{map:{afterLoad:{selectRegion:!1,},},region:{mouseover:{showTooltip:!1,},click:{addIdToUrl:!1,showDetails:!0,showDetailsFor:"region",filterDirectory:!1,loadObjects:!1,showPopover:!1,showPopoverFor:"region",goToLink:!1,linkField:"Region.link",},touch:{showPopover:!1,},},marker:{mouseover:{showTooltip:!1,},click:{showDetails:!0,showPopover:!1,goToLink:!1,linkField:"Object.link",},touch:{showPopover:!1,},},directoryItem:{click:{showDetails:!0,showPopover:!1,goToLink:!1,selectRegion:!0,fireRegionOnClick:!0,linkField:"Object.link",},hover:{centerOnMarker:!1,},},},detailsView:{location:"map",containerId:"",width:"100%",mobileFullscreen:!0,},mobileView:{labelMap:"Map",labelList:"List",labelClose:"Close",},googleMaps:{on:!1,apiKey:"",loaded:!1,center:"auto",type:"roadmap",minZoom:1,style:"default",styleJSON:[],language:"en",},groups:[],floors:[],layersControl:{on:!1,position:"top-left",label:"Show on map",expanded:!0,maxHeight:"100%",},floorsControl:{on:!1,position:"top-left",label:"Floors",expanded:!1,maxHeight:"100%",},containers:{leftSidebar:{on:!1,width:"250px"},rightSidebar:{on:!1,width:"250px"},header:{on:!0,height:"auto"},footer:{on:!1,height:"auto"},},labelsMarkers:{on:!1},labelsRegions:{on:!1},svgFileVersion:1,fitMarkers:!1,fitMarkersOnStart:!1,fitSingleMarkerZoom:20,controls:{location:"right",zoom:!0,zoomReset:!1,userLocation:!1,previousMap:!1,},previousMapsIds:[],};var trimLeft=/^\s+/,trimRight=/\s+$/,tinyCounter=0,mathRound=Math.round,mathMin=Math.min,mathMax=Math.max,mathRandom=Math.random;function tinycolor(color,opts){color=color?color:"";opts=opts||{};if(color instanceof tinycolor){return color}
25if(!(this instanceof tinycolor)){return new tinycolor(color,opts)}
26var rgb=inputToRGB(color);(this._originalInput=color),(this._r=rgb.r),(this._g=rgb.g),(this._b=rgb.b),(this._a=rgb.a),(this._roundA=mathRound(100*this._a)/100),(this._format=opts.format||rgb.format);this._gradientType=opts.gradientType;if(this._r<1){this._r=mathRound(this._r)}
27if(this._g<1){this._g=mathRound(this._g)}
28if(this._b<1){this._b=mathRound(this._b)}
29this._ok=rgb.ok;this._tc_id=tinyCounter++}
30tinycolor.prototype={isDark:function(){return this.getBrightness()<128},isLight:function(){return!this.isDark()},isValid:function(){return this._ok},getOriginalInput:function(){return this._originalInput},getFormat:function(){return this._format},getAlpha:function(){return this._a},getBrightness:function(){var rgb=this.toRgb();return(rgb.r*299+rgb.g*587+rgb.b*114)/1000},getLuminance:function(){var rgb=this.toRgb();var RsRGB,GsRGB,BsRGB,R,G,B;RsRGB=rgb.r/255;GsRGB=rgb.g/255;BsRGB=rgb.b/255;if(RsRGB<=0.03928){R=RsRGB/12.92}else{R=Math.pow((RsRGB+0.055)/1.055,2.4)}
31if(GsRGB<=0.03928){G=GsRGB/12.92}else{G=Math.pow((GsRGB+0.055)/1.055,2.4)}
32if(BsRGB<=0.03928){B=BsRGB/12.92}else{B=Math.pow((BsRGB+0.055)/1.055,2.4)}
33return 0.2126*R+0.7152*G+0.0722*B},setAlpha:function(value){this._a=boundAlpha(value);this._roundA=mathRound(100*this._a)/100;return this},toHsv:function(){var hsv=rgbToHsv(this._r,this._g,this._b);return{h:hsv.h*360,s:hsv.s,v:hsv.v,a:this._a}},toHsvString:function(){var hsv=rgbToHsv(this._r,this._g,this._b);var h=mathRound(hsv.h*360),s=mathRound(hsv.s*100),v=mathRound(hsv.v*100);return this._a==1?"hsv("+h+", "+s+"%, "+v+"%)":"hsva("+h+", "+s+"%, "+v+"%, "+this._roundA+")"},toHsl:function(){var hsl=rgbToHsl(this._r,this._g,this._b);return{h:hsl.h*360,s:hsl.s,l:hsl.l,a:this._a}},toHslString:function(){var hsl=rgbToHsl(this._r,this._g,this._b);var h=mathRound(hsl.h*360),s=mathRound(hsl.s*100),l=mathRound(hsl.l*100);return this._a==1?"hsl("+h+", "+s+"%, "+l+"%)":"hsla("+h+", "+s+"%, "+l+"%, "+this._roundA+")"},toHex:function(allow3Char){return rgbToHex(this._r,this._g,this._b,allow3Char)},toHexString:function(allow3Char){return"#"+this.toHex(allow3Char)},toHex8:function(allow4Char){return rgbaToHex(this._r,this._g,this._b,this._a,allow4Char)},toHex8String:function(allow4Char){return"#"+this.toHex8(allow4Char)},toRgb:function(){return{r:mathRound(this._r),g:mathRound(this._g),b:mathRound(this._b),a:this._a}},toRgbString:function(){return this._a==1?"rgb("+mathRound(this._r)+", "+mathRound(this._g)+", "+mathRound(this._b)+")":"rgba("+mathRound(this._r)+", "+mathRound(this._g)+", "+mathRound(this._b)+", "+this._roundA+")"},toPercentageRgb:function(){return{r:mathRound(bound01(this._r,255)*100)+"%",g:mathRound(bound01(this._g,255)*100)+"%",b:mathRound(bound01(this._b,255)*100)+"%",a:this._a,}},toPercentageRgbString:function(){return this._a==1?"rgb("+mathRound(bound01(this._r,255)*100)+"%, "+mathRound(bound01(this._g,255)*100)+"%, "+mathRound(bound01(this._b,255)*100)+"%)":"rgba("+mathRound(bound01(this._r,255)*100)+"%, "+mathRound(bound01(this._g,255)*100)+"%, "+mathRound(bound01(this._b,255)*100)+"%, "+this._roundA+")"},toName:function(){if(this._a===0){return"transparent"}
34if(this._a<1){return!1}
35return hexNames[rgbToHex(this._r,this._g,this._b,!0)]||!1},toFilter:function(secondColor){var hex8String="#"+rgbaToArgbHex(this._r,this._g,this._b,this._a);var secondHex8String=hex8String;var gradientType=this._gradientType?"GradientType = 1, ":"";if(secondColor){var s=tinycolor(secondColor);secondHex8String="#"+rgbaToArgbHex(s._r,s._g,s._b,s._a)}
36return("progid:DXImageTransform.Microsoft.gradient("+gradientType+"startColorstr="+hex8String+",endColorstr="+secondHex8String+")")},toString:function(format){var formatSet=!!format;format=format||this._format;var formattedString=!1;var hasAlpha=this._a<1&&this._a>=0;var needsAlphaFormat=!formatSet&&hasAlpha&&(format==="hex"||format==="hex6"||format==="hex3"||format==="hex4"||format==="hex8"||format==="name");if(needsAlphaFormat){if(format==="name"&&this._a===0){return this.toName()}
37return this.toRgbString()}
38if(format==="rgb"){formattedString=this.toRgbString()}
39if(format==="prgb"){formattedString=this.toPercentageRgbString()}
40if(format==="hex"||format==="hex6"){formattedString=this.toHexString()}
41if(format==="hex3"){formattedString=this.toHexString(!0)}
42if(format==="hex4"){formattedString=this.toHex8String(!0)}
43if(format==="hex8"){formattedString=this.toHex8String()}
44if(format==="name"){formattedString=this.toName()}
45if(format==="hsl"){formattedString=this.toHslString()}
46if(format==="hsv"){formattedString=this.toHsvString()}
47return formattedString||this.toHexString()},clone:function(){return tinycolor(this.toString())},_applyModification:function(fn,args){var color=fn.apply(null,[this].concat([].slice.call(args)));this._r=color._r;this._g=color._g;this._b=color._b;this.setAlpha(color._a);return this},lighten:function(){return this._applyModification(lighten,arguments)},brighten:function(){return this._applyModification(brighten,arguments)},darken:function(){return this._applyModification(darken,arguments)},desaturate:function(){return this._applyModification(desaturate,arguments)},saturate:function(){return this._applyModification(saturate,arguments)},greyscale:function(){return this._applyModification(greyscale,arguments)},spin:function(){return this._applyModification(spin,arguments)},_applyCombination:function(fn,args){return fn.apply(null,[this].concat([].slice.call(args)))},analogous:function(){return this._applyCombination(analogous,arguments)},complement:function(){return this._applyCombination(complement,arguments)},monochromatic:function(){return this._applyCombination(monochromatic,arguments)},splitcomplement:function(){return this._applyCombination(splitcomplement,arguments)},triad:function(){return this._applyCombination(triad,arguments)},tetrad:function(){return this._applyCombination(tetrad,arguments)},};
vendor: 9,085 bytes, lines 47-87
47tinycolor.fromRatio=function(color,opts){if(typeof color=="object"){var newColor={};for(var i in color){if(color.hasOwnProperty(i)){if(i==="a"){newColor[i]=color[i]}else{newColor[i]=convertToPercentage(color[i])}}}
48color=newColor}
49return tinycolor(color,opts)};function inputToRGB(color){var rgb={r:0,g:0,b:0};var a=1;var s=null;var v=null;var l=null;var ok=!1;var format=!1;if(typeof color=="string"){color=stringInputToObject(color)}
50if(typeof color=="object"){if(isValidCSSUnit(color.r)&&isValidCSSUnit(color.g)&&isValidCSSUnit(color.b)){rgb=rgbToRgb(color.r,color.g,color.b);ok=!0;format=String(color.r).substr(-1)==="%"?"prgb":"rgb"}else if(isValidCSSUnit(color.h)&&isValidCSSUnit(color.s)&&isValidCSSUnit(color.v)){s=convertToPercentage(color.s);v=convertToPercentage(color.v);rgb=hsvToRgb(color.h,s,v);ok=!0;format="hsv"}else if(isValidCSSUnit(color.h)&&isValidCSSUnit(color.s)&&isValidCSSUnit(color.l)){s=convertToPercentage(color.s);l=convertToPercentage(color.l);rgb=hslToRgb(color.h,s,l);ok=!0;format="hsl"}
51if(color.hasOwnProperty("a")){a=color.a}}
52a=boundAlpha(a);return{ok:ok,format:color.format||format,r:mathMin(255,mathMax(rgb.r,0)),g:mathMin(255,mathMax(rgb.g,0)),b:mathMin(255,mathMax(rgb.b,0)),a:a,}}
53function rgbToRgb(r,g,b){return{r:bound01(r,255)*255,g:bound01(g,255)*255,b:bound01(b,255)*255,}}
54function rgbToHsl(r,g,b){r=bound01(r,255);g=bound01(g,255);b=bound01(b,255);var max=mathMax(r,g,b),min=mathMin(r,g,b);var h,s,l=(max+min)/2;if(max==min){h=s=0}else{var d=max-min;s=l>0.5?d/(2-max-min):d/(max+min);switch(max){case r:h=(g-b)/d+(g<b?6:0);break;case g:h=(b-r)/d+2;break;case b:h=(r-g)/d+4;break}
55h/=6}
56return{h:h,s:s,l:l}}
57function hslToRgb(h,s,l){var r,g,b;h=bound01(h,360);s=bound01(s,100);l=bound01(l,100);function hue2rgb(p,q,t){if(t<0)t+=1;if(t>1)t-=1;if(t<1/6)return p+(q-p)*6*t;if(t<1/2)return q;if(t<2/3)return p+(q-p)*(2/3-t)*6;return p}
58if(s===0){r=g=b=l}else{var q=l<0.5?l*(1+s):l+s-l*s;var p=2*l-q;r=hue2rgb(p,q,h+1/3);g=hue2rgb(p,q,h);b=hue2rgb(p,q,h-1/3)}
59return{r:r*255,g:g*255,b:b*255}}
60function rgbToHsv(r,g,b){r=bound01(r,255);g=bound01(g,255);b=bound01(b,255);var max=mathMax(r,g,b),min=mathMin(r,g,b);var h,s,v=max;var d=max-min;s=max===0?0:d/max;if(max==min){h=0}else{switch(max){case r:h=(g-b)/d+(g<b?6:0);break;case g:h=(b-r)/d+2;break;case b:h=(r-g)/d+4;break}
61h/=6}
62return{h:h,s:s,v:v}}
63function hsvToRgb(h,s,v){h=bound01(h,360)*6;s=bound01(s,100);v=bound01(v,100);var i=Math.floor(h),f=h-i,p=v*(1-s),q=v*(1-f*s),t=v*(1-(1-f)*s),mod=i%6,r=[v,q,p,p,t,v][mod],g=[t,v,v,q,p,p][mod],b=[p,p,t,v,v,q][mod];return{r:r*255,g:g*255,b:b*255}}
64function rgbToHex(r,g,b,allow3Char){var hex=[pad2(mathRound(r).toString(16)),pad2(mathRound(g).toString(16)),pad2(mathRound(b).toString(16)),];if(allow3Char&&hex[0].charAt(0)==hex[0].charAt(1)&&hex[1].charAt(0)==hex[1].charAt(1)&&hex[2].charAt(0)==hex[2].charAt(1)){return hex[0].charAt(0)+hex[1].charAt(0)+hex[2].charAt(0)}
65return hex.join("")}
66function rgbaToHex(r,g,b,a,allow4Char){var hex=[pad2(mathRound(r).toString(16)),pad2(mathRound(g).toString(16)),pad2(mathRound(b).toString(16)),pad2(convertDecimalToHex(a)),];if(allow4Char&&hex[0].charAt(0)==hex[0].charAt(1)&&hex[1].charAt(0)==hex[1].charAt(1)&&hex[2].charAt(0)==hex[2].charAt(1)&&hex[3].charAt(0)==hex[3].charAt(1)){return hex[0].charAt(0)+hex[1].charAt(0)+hex[2].charAt(0)+hex[3].charAt(0)}
67return hex.join("")}
68function rgbaToArgbHex(r,g,b,a){var hex=[pad2(convertDecimalToHex(a)),pad2(mathRound(r).toString(16)),pad2(mathRound(g).toString(16)),pad2(mathRound(b).toString(16)),];return hex.join("")}
69tinycolor.equals=function(color1,color2){if(!color1||!color2){return!1}
70return tinycolor(color1).toRgbString()==tinycolor(color2).toRgbString()};tinycolor.random=function(){return tinycolor.fromRatio({r:mathRandom(),g:mathRandom(),b:mathRandom(),})};function desaturate(color,amount){amount=amount===0?0:amount||10;var hsl=tinycolor(color).toHsl();hsl.s-=amount/100;hsl.s=clamp01(hsl.s);return tinycolor(hsl)}
71function saturate(color,amount){amount=amount===0?0:amount||10;var hsl=tinycolor(color).toHsl();hsl.s+=amount/100;hsl.s=clamp01(hsl.s);return tinycolor(hsl)}
72function greyscale(color){return tinycolor(color).desaturate(100)}
73function lighten(color,amount){amount=amount===0?0:amount||10;var hsl=tinycolor(color).toHsl();hsl.l+=amount/100;hsl.l=clamp01(hsl.l);return tinycolor(hsl)}
74function brighten(color,amount){amount=amount===0?0:amount||10;var rgb=tinycolor(color).toRgb();rgb.r=mathMax(0,mathMin(255,rgb.r-mathRound(255*-(amount/100))));rgb.g=mathMax(0,mathMin(255,rgb.g-mathRound(255*-(amount/100))));rgb.b=mathMax(0,mathMin(255,rgb.b-mathRound(255*-(amount/100))));return tinycolor(rgb)}
75function darken(color,amount){amount=amount===0?0:amount||10;var hsl=tinycolor(color).toHsl();hsl.l-=amount/100;hsl.l=clamp01(hsl.l);return tinycolor(hsl)}
76function spin(color,amount){var hsl=tinycolor(color).toHsl();var hue=(hsl.h+amount)%360;hsl.h=hue<0?360+hue:hue;return tinycolor(hsl)}
77function complement(color){var hsl=tinycolor(color).toHsl();hsl.h=(hsl.h+180)%360;return tinycolor(hsl)}
78function triad(color){var hsl=tinycolor(color).toHsl();var h=hsl.h;return[tinycolor(color),tinycolor({h:(h+120)%360,s:hsl.s,l:hsl.l}),tinycolor({h:(h+240)%360,s:hsl.s,l:hsl.l}),]}
79function tetrad(color){var hsl=tinycolor(color).toHsl();var h=hsl.h;return[tinycolor(color),tinycolor({h:(h+90)%360,s:hsl.s,l:hsl.l}),tinycolor({h:(h+180)%360,s:hsl.s,l:hsl.l}),tinycolor({h:(h+270)%360,s:hsl.s,l:hsl.l}),]}
80function splitcomplement(color){var hsl=tinycolor(color).toHsl();var h=hsl.h;return[tinycolor(color),tinycolor({h:(h+72)%360,s:hsl.s,l:hsl.l}),tinycolor({h:(h+216)%360,s:hsl.s,l:hsl.l}),]}
81function analogous(color,results,slices){results=results||6;slices=slices||30;var hsl=tinycolor(color).toHsl();var part=360/slices;var ret=[tinycolor(color)];for(hsl.h=(hsl.h-((part*results)>>1)+720)%360;--results;){hsl.h=(hsl.h+part)%360;ret.push(tinycolor(hsl))}
82return ret}
83function monochromatic(color,results){results=results||6;var hsv=tinycolor(color).toHsv();var h=hsv.h,s=hsv.s,v=hsv.v;var ret=[];var modification=1/results;while(results--){ret.push(tinycolor({h:h,s:s,v:v}));v=(v+modification)%1}
84return ret}
85tinycolor.mix=function(color1,color2,amount){amount=amount===0?0:amount||50;var rgb1=tinycolor(color1).toRgb();var rgb2=tinycolor(color2).toRgb();var p=amount/100;var rgba={r:(rgb2.r-rgb1.r)*p+rgb1.r,g:(rgb2.g-rgb1.g)*p+rgb1.g,b:(rgb2.b-rgb1.b)*p+rgb1.b,a:(rgb2.a-rgb1.a)*p+rgb1.a,};return tinycolor(rgba)};tinycolor.readability=function(color1,color2){var c1=tinycolor(color1);var c2=tinycolor(color2);return((Math.max(c1.getLuminance(),c2.getLuminance())+0.05)/(Math.min(c1.getLuminance(),c2.getLuminance())+0.05))};tinycolor.isReadable=function(color1,color2,wcag2){var readability=tinycolor.readability(color1,color2);var wcag2Parms,out;out=!1;wcag2Parms=validateWCAG2Parms(wcag2);switch(wcag2Parms.level+wcag2Parms.size){case "AAsmall":case "AAAlarge":out=readability>=4.5;break;case "AAlarge":out=readability>=3;break;case "AAAsmall":out=readability>=7;break}
86return out};tinycolor.mostReadable=function(baseColor,colorList,args){var bestColor=null;var bestScore=0;var readability;var includeFallbackColors,level,size;args=args||{};includeFallbackColors=args.includeFallbackColors;level=args.level;size=args.size;for(var i=0;i<colorList.length;i++){readability=tinycolor.readability(baseColor,colorList[i]);if(readability>bestScore){bestScore=readability;bestColor=tinycolor(colorList[i])}}
87if(tinycolor.isReadable(baseColor,bestColor,{level:level,size:size})||!includeFallbackColors){return bestColor}else{args.includeFallbackColors=!1;return tinycolor.mostReadable(baseColor,["#fff","#000"],args)}};var names=(tinycolor.names={aliceblue:"f0f8ff",antiquewhite:"faebd7",aqua:"0ff",aquamarine:"7fffd4",azure:"f0ffff",beige:"f5f5dc",bisque:"ffe4c4",black:"000",blanchedalmond:"ffebcd",blue:"00f",blueviolet:"8a2be2",brown:"a52a2a",burlywood:"deb887",burntsienna:"ea7e5d",cadetblue:"5f9ea0",chartreuse:"7fff00",chocolate:"d2691e",coral:"ff7f50",cornflowerblue:"6495ed",cornsilk:"fff8dc",crimson:"dc143c",cyan:"0ff",darkblue:"00008b",darkcyan:"008b8b",darkgoldenrod:"b8860b",darkgray:"a9a9a9",darkgreen:"006400",darkgrey:"a9a9a9",darkkhaki:"bdb76b",darkmagenta:"8b008b",darkolivegreen:"556b2f",darkorange:"ff8c00",darkorchid:"9932cc",darkred:"8b0000",darksalmon:"e9967a",darkseagreen:"8fbc8f",darkslateblue:"483d8b",darkslategray:"2f4f4f",darkslategrey:"2f4f4f",darkturquoise:"00ced1",darkviolet:"9400d3",deeppink:"ff1493",deepskyblue:"00bfff",dimgray:"696969",dimgrey:"696969",dodgerblue:"1e90ff",firebrick:"b22222",floralwhite:"fffaf0",forestgreen:"228b22",fuchsia:"f0f",gainsboro:"dcdcdc",ghostwhite:"f8f8ff",gold:"ffd700",goldenrod:"daa520",gray:"808080",green:"008000",greenyellow:"adff2f",grey:"808080",honeydew:"f0fff0",hotpink:"ff69b4",indianred:"cd5c5c",indigo:"4b0082",ivory:"fffff0",khaki:"f0e68c",lavender:"e6e6fa",lavenderblush:"fff0f5",lawngreen:"7cfc00",lemonchiffon:"fffacd",lightblue:"add8e6",lightcoral:"f08080",lightcyan:"e0ffff",lightgoldenrodyellow:"fafad2",lightgray:"d3d3d3",lightgreen:"90ee9
870",lightgrey:"d3d3d3",lightpink:"ffb6c1",lightsalmon:"ffa07a",lightseagreen:"20b2aa",lightskyblue:"87cefa",lightslategray:"789",lightslategrey:"789",lightsteelblue:"b0c4de",lightyellow:"ffffe0",lime:"0f0",limegreen:"32cd32",linen:"faf0e6",magenta:"f0f",maroon:"800000",mediumaquamarine:"66cdaa",mediumblue:"0000cd",mediumorchid:"ba55d3",mediumpurple:"9370db",mediumseagreen:"3cb371",mediumslateblue:"7b68ee",mediumspringgreen:"00fa9a",mediumturquoise:"48d1cc",mediumvioletred:"c71585",midnightblue:"191970",mintcream:"f5fffa",mistyrose:"ffe4e1",moccasin:"ffe4b5",navajowhite:"ffdead",navy:"000080",oldlace:"fdf5e6",olive:"808000",olivedrab:"6b8e23",orange:"ffa500",orangered:"ff4500",orchid:"da70d6",palegoldenrod:"eee8aa",palegreen:"98fb98",paleturquoise:"afeeee",palevioletred:"db7093",papayawhip:"ffefd5",peachpuff:"ffdab9",peru:"cd853f",pink:"ffc0cb",plum:"dda0dd",powderblue:"b0e0e6",purple:"800080",rebeccapurple:"663399",red:"f00",rosybrown:"bc8f8f",royalblue:"4169e1",saddlebrown:"8b4513",salmon:"fa8072",sandybrown:"f4a460",seagreen:"2e8b57",seashell:"fff5ee",sienna:"a0522d",silver:"c0c0c0",skyblue:"87ceeb",slateblue:"6a5acd",slategray:"708090",slategrey:"708090",snow:"fffafa",springgreen:"00ff7f",steelblue:"4682b4",tan:"d2b48c",teal:"008080",thistle:"d8bfd8",tomato:"ff6347",turquoise:"40e0d0",violet:"ee82ee",wheat:"f5deb3",white:"fff",whitesmoke:"f5f5f5",yellow:"ff0",yellowgreen:"9acd32",});var hexNames=(tinycolor.hexNames=flip(names));function flip(o){var flipped={};for(var i in o){if(o.hasOwnProperty(i)){flipped[o[i]]=i}}
88return flipped}
89function boundAlpha(a){a=parseFloat(a);if(isNaN(a)||a<0||a>1){a=1}
90return a}
91function bound01(n,max){if(isOnePointZero(n)){n="100%"}
92var processPercent=isPercentage(n);n=mathMin(max,mathMax(0,parseFloat(n)));if(processPercent){n=parseInt(n*max,10)/100}
93if(Math.abs(n-max)<0.000001){return 1}
94return(n%max)/parseFloat(max)}
95function clamp01(val){return mathMin(1,mathMax(0,val))}
96function parseIntFromHex(val){return parseInt(val,16)}
97function isOnePointZero(n){return typeof n=="string"&&n.indexOf(".")!=-1&&parseFloat(n)===1}
98function isPercentage(n){return typeof n==="string"&&n.indexOf("%")!=-1}
99function pad2(c){return c.length==1?"0"+c:""+c}
100function convertToPercentage(n){if(n<=1){n=n*100+"%"}
101return n}
102function convertDecimalToHex(d){return Math.round(parseFloat(d)*255).toString(16)}
103function convertHexToDecimal(h){return parseIntFromHex(h)/255}
104var matchers=(function(){var CSS_INTEGER="[-\\+]?\\d+%?";var CSS_NUMBER="[-\\+]?\\d*\\.\\d+%?";var CSS_UNIT="(?:"+CSS_NUMBER+")|(?:"+CSS_INTEGER+")";var PERMISSIVE_MATCH3="[\\s|\\(]+("+CSS_UNIT+")[,|\\s]+("+CSS_UNIT+")[,|\\s]+("+CSS_UNIT+")\\s*\\)?";var PERMISSIVE_MATCH4="[\\s|\\(]+("+CSS_UNIT+")[,|\\s]+("+CSS_UNIT+")[,|\\s]+("+CSS_UNIT+")[,|\\s]+("+CSS_UNIT+")\\s*\\)?";return{CSS_UNIT:new RegExp(CSS_UNIT),rgb:new RegExp("rgb"+PERMISSIVE_MATCH3),rgba:new RegExp("rgba"+PERMISSIVE_MATCH4),hsl:new RegExp("hsl"+PERMISSIVE_MATCH3),hsla:new RegExp("hsla"+PERMISSIVE_MATCH4),hsv:new RegExp("hsv"+PERMISSIVE_MATCH3),hsva:new RegExp("hsva"
104+PERMISSIVE_MATCH4),hex3:/^#?([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})$/,hex6:/^#?([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})$/,hex4:/^#?([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})$/,hex8:/^#?([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})$/,}})();function isValidCSSUnit(color){return!!matchers.CSS_UNIT.exec(color)}
105function stringInputToObject(color){color=color.replace(trimLeft,"").replace(trimRight,"").toLowerCase();var named=!1;if(names[color]){color=names[color];named=!0}else if(color=="transparent"){return{r:0,g:0,b:0,a:0,format:"name"}}
106var match;if((match=matchers.rgb.exec(color))){return{r:match[1],g:match[2],b:match[3]}}
107if((match=matchers.rgba.exec(color))){return{r:match[1],g:match[2],b:match[3],a:match[4]}}
108if((match=matchers.hsl.exec(color))){return{h:match[1],s:match[2],l:match[3]}}
109if((match=matchers.hsla.exec(color))){return{h:match[1],s:match[2],l:match[3],a:match[4]}}
110if((match=matchers.hsv.exec(color))){return{h:match[1],s:match[2],v:match[3]}}
111if((match=matchers.hsva.exec(color))){return{h:match[1],s:match[2],v:match[3],a:match[4]}}
112if((match=matchers.hex8.exec(color))){return{r:parseIntFromHex(match[1]),g:parseIntFromHex(match[2]),b:parseIntFromHex(match[3]),a:convertHexToDecimal(match[4]),format:named?"name":"hex8",}}
113if((match=matchers.hex6.exec(color))){return{r:parseIntFromHex(match[1]),g:parseIntFromHex(match[2]),b:parseIntFromHex(match[3]),format:named?"name":"hex",}}
114if((match=matchers.hex4.exec(color))){return{r:parseIntFromHex(match[1]+""+match[1]),g:parseIntFromHex(match[2]+""+match[2]),b:parseIntFromHex(match[3]+""+match[3]),a:convertHexToDecimal(match[4]+""+match[4]),format:named?"name":"hex8",}}
115if((match=matchers.hex3.exec(color))){return{r:parseIntFromHex(match[1]+""+match[1]),g:parseIntFromHex(match[2]+""+match[2]),b:parseIntFromHex(match[3]+""+match[3]),format:named?"name":"hex",}}
116return!1}
117function validateWCAG2Parms(parms){var level,size;parms=parms||{level:"AA",size:"small"};level=(parms.level||"AA").toUpperCase();size=(parms.size||"small").toLowerCase();if(level!=="AA"&&level!=="AAA"){level="AA"}
118if(size!=="small"&&size!=="large"){size="small"}
119return{level:level,size:size}}
120const $$1=jQuery;class Server{constructor(){this.apiUrl=MapSVG.urls.api}
121getUrl(path){return this.apiUrl+path}
122get(path,data){return $$1.ajax({url:this.apiUrl+path,type:"GET",data:data,beforeSend:function(xhr){if(MapSVG.nonce()){xhr.setRequestHeader("X-WP-Nonce",MapSVG.nonce())}},})}
123post(path,data){const ajaxParams={url:this.apiUrl+path,type:"POST",data:data,beforeSend:function(xhr){if(MapSVG.nonce()){xhr.setRequestHeader("X-WP-Nonce",MapSVG.nonce())}},};if(data instanceof FormData){ajaxParams.processData=!1;ajaxParams.contentType=!1}
124return $$1.ajax(ajaxParams)}
125put(path,data){const ajaxParams={url:this.apiUrl+path,type:"POST",data:data,beforeSend:function(xhr){if(MapSVG.nonce()){xhr.setRequestHeader("X-WP-Nonce",MapSVG.nonce())}
126xhr.setRequestHeader("X-HTTP-Method-Override","PUT")},};if(data instanceof FormData){ajaxParams.processData=!1;ajaxParams.contentType=!1}
127return $$1.ajax(ajaxParams)}
128delete(path,data){return $$1.ajax({url:this.apiUrl+path,type:"POST",data:data,beforeSend:function(xhr){if(MapSVG.nonce()){xhr.setRequestHeader("X-WP-Nonce",MapSVG.nonce())}
129xhr.setRequestHeader("X-HTTP-Method-Override","DELETE")},})}
130ajax(path,data){data.url=this.getUrl(path);data.beforeSend=function(xhr){if(MapSVG.nonce()){xhr.setRequestHeader("X-WP-Nonce",MapSVG.nonce())}};return $$1.ajax(data)}}
131class Events{constructor(context){this.events={};this.context=context}
132on(event,callbackOrObjectType,callback){if(!this.events[event])
133this.events[event]=[];let callbackFunction;if(typeof callbackOrObjectType==="string"){callbackFunction=callback}else{callbackFunction=callbackOrObjectType}
134this.events[event].push(callbackFunction);return this}
135off(event,callback){const _this=this;if(this.events[event]&&this.events[event].length){this.events[event].forEach(function(_callback,index){if(typeof callback==="undefined"){_this.events[event].splice(index,1)}else if(_callback===callback){_this.events[event].splice(index,1)}})}
136return this}
137trigger(event,thisArg,args){if(this.events[event]&&this.events[event].length)
138this.events[event].forEach((callback)=>{try{callback&&callback.apply(thisArg||this.context,args||[this.context])}catch(err){console.error(err)}});return this}}
139class ArrayIndexed extends Array{constructor(indexKey,items,options){if(items){super(...items)}else{super()}
140this.key=indexKey;this.dict={};this.nextId=1;if(options){this.options=options}else{this.options={autoId:!1,unique:!1}}
141if(this.length>0){let i=0;const _this=this;if(this.options.autoId){let maxId=0;let missingIds=!1;this.forEach(function(item){if(item[_this.key]!=null){if(item[_this.key]>maxId){maxId=item[_this.key]}}else{missingIds=!0}});this.nextId=++maxId;if(missingIds){this.forEach(function(item){if(item[_this.key]==null){item[_this.key]=_this.nextId;_this.nextId++}})}}
142this.forEach(function(item){_this.dict[item[_this.key]]=i;i++})}}
143push(item){const length=super.push(item);if(this.options.autoId===!0){item[this.key]=this.nextId;this.nextId++}
144this.dict[item[this.key]]=length-1;return length}
145pop(){const item=this[this.length-1];const id=item[this.key];const length=super.pop();delete this.dict[id];this.reindex();return super.pop()}
146update(data){if(data[this.key]!=null){const obj=this.get(data[this.key]);for(const i in data){obj[i]=data[i]}
147return obj}
148return!1}
149get(id){return this.findById(id)}
150findById(id){return this[this.dict[id]]}
151deleteById(id){const index=this.dict[id];if(typeof index!=="undefined"){delete this.dict[id];this.splice(index,1)}}
152delete(id){this.deleteById(id)}
153clear(){this.length=0;this.reindex()}
154reindex(){const _this=this;this.dict={};this.forEach(function(item,index){_this.dict[item[_this.key]]=index})}
155sort(compareFn){super.sort(compareFn);this.reindex();return this}
156splice(start,deleteCount){const res=super.splice(start,deleteCount);this.reindex();return res}}
157class SchemaField{constructor(field){const booleans=["visible","searchable","readonly","protected"];for(const key in field){this[key]=field[key]}
158booleans.forEach((paramName)=>{if(typeof this[paramName]!=="undefined"){this[paramName]=MapSVG.parseBoolean(this[paramName])}else{this[paramName]=!1}});if(typeof this.options!=="undefined"){if(!(this.options instanceof ArrayIndexed)){this.options=new ArrayIndexed("value",this.options)}}}}
159class Schema{constructor(options){this.fields=new ArrayIndexed("name");this.build(options);this.lastChangeTime=Date.now();this.events=new Events(this)}
160build(options){const allowedParams=["id","title","type","name","fields"];
160allowedParams.forEach((paramName)=>{const setter="set"+MapSVG.ucfirst(paramName);if(typeof options[paramName]!=="undefined"&&typeof this[setter]=="function"){this[setter](options[paramName])}})}
161update(options){this.build(options)}
162setId(id){this.id=id}
163setTitle(title){this.title=title}
164setName(name){this.name=name}
165loaded(){return this.fields.length!==0}
166setFields(fields){if(fields){this.fields.clear();fields.forEach((fieldParams)=>{this.fields.push(new SchemaField(fieldParams))})}}
167getFields(){return this.fields}
168getFieldsAsArray(){return this.fields}
169getFieldNames(){return this.fields.map((f)=>f.name)}
170getField(field){return this.fields.findById(field)}
171getFieldByType(type){let f=null;this.fields.forEach(function(field){if(field.type===type)
172f=field});return f}
173getColumns(filters){filters=filters||{};const columns=this.fields;const needfilters=Object.keys(filters).length!==0;let results=[];if(needfilters){let filterpass;columns.forEach(function(obj){filterpass=!0;for(const param in filters){filterpass=obj[param]==filters[param]}
174filterpass&&results.push(obj)})}else{results=columns}
175return results}
176getData(){const data={id:this.id,title:this.title,name:this.name,fields:this.fields,type:this.t
176ype,};return data}}
177class Query{constructor(options){this.filters={};this.filterout={};this.page=1;if(options){for(const i in options){if(typeof options[i]!=="undefined"){this[i]=options[i]}}}}
178setFields(fields){const _this=this;for(const key in fields){if(key=="filters"){_this.setFilters(fields[key])}else{_this[key]=fields[key]}}}
179update(query){for(const i in query){if(typeof query[i]!=="undefined"){if(i==="filters"){this.setFilters(query[i])}else{this[i]=query[i]}}}}
180get(){return{search:this.search,searchField:this.searchField,searchFallback:this.searchFallback,filters:this.filters,filterout:this.filterout,page:this.page,sort:this.sort,perpage:this.perpage,lastpage:this.lastpage,}}
181clearFilters(){this.resetFilters()}
182setFilters(fields){const _this=this;for(const key in fields){if(fields[key]===null||fields[key]===""||fields[key]===undefined){if(_this.filters[key]){delete _this.filters[key]}}else{_this.filters[key]=fields[key]}}}
183setSearch(search){this.search=search}
184setFilterOut(fields){if(fields===null){delete this.filterout}else{this.filterout=fields}}
185resetFilters(fields){this.filters={};this.setSearch("")}
186setFilterField(field,value){this.filters[field]=value}
187hasFilters(){return Object.keys(this.filters).length>0||this.search.length>0}
188removeFilter(fieldName){this.filters[fieldName]=null;delete this.filters[fieldName]}
189requestSchema(requestSchema){this.withSchema=requestSchema?requestSchema:!0}}
190class LocationAddress{constructor(fields){for(const i in fields){this[i]=fields[i]}}
191getData(){const copy={};["route","address_formatted","administrative_area_level_1","administrative_area_level_1_short","administrative_area_level_2","administrative_area_level_2_short","country","country_short","postal_code",].forEach((field)=>{if(this[field]){copy[field]=this[field]}});return copy}
192get state(){return this.country_short==="US"?this.administrative_area_level_1:null}
193get state_short(){return this.country_short==="US"?this.administrative_area_level_1_short:null}
194get county(){return this.country_short==="US"?this.administrative_area_level_2:null}
195get zip(){return this.postal_code}}
196class ScreenPoint{constructor(x,y){this.x=x;this.y=y}}
197class SVGPoint{constructor(x,y){let _x,_y;if(typeof x==="object"){if(x.x&&x.y){_x=parseFloat(x.x+"");_y=parseFloat(x.y+"")}else{console.error("MapSVG: incorrect format of {x, y} object for SVGPoint.");_x=0;_y=0}}else{_x=parseFloat(x+"");_y=parseFloat(y+"")}
198this.x=_x;this.y=_y}
199toString(){return this.x+","+this.y}}
200class GeoPoint{constructor(lat,lng){let _lat,_lng;if(typeof lat==="object"){if(lat.lat&&lat.lng){_lat=parseFloat(lat.lat+"");_lng=parseFloat(lat.lng+"")}else{console.error("MapSVG: incorrect format of {lat, lng} object for GeoPoint.");_lat=0;_lng=0}}else{_lat=parseFloat(lat+"");_lng=parseFloat(lng+"")}
201this.lat=_lat;this.lng=_lng}
202toString(){return this.lat+","+this.lng}}
203class Location{constructor(options){this.update(options)}
204update(options){if(options.object){this.setObject(options.object)}
205if(options.img){this.setImage(options.img)}
206if(options.address){this.setAddress(options.address)}
207if(options.svgPoint){this.setSvgPoint(options.svgPoint)}
208if(options.geoPoint){this.setGeoPoint(options.geoPoint)}}
209setObject(object){this.object=object}
210setImage(imgUrl){if(typeof imgUrl!=="string"){return}
211let src=imgUrl.split("/").pop();if(imgUrl.indexOf("uploads")!==-1){src="uploads/"+src}
212this.img=src;this.imagePath=this.getImageUrl();this.marker&&this.marker&&this.marker.setImage(this.imagePath)}
213getImageUrl(){if(this.img&&this.img.indexOf("uploads/")===0){return MapSVG.urls.uploads+"markers/"+this.img.replace("uploads/","")}else{return MapSVG.urls.root+"markers/"+(this.img||"_pin_default.png")}}
214setAddress(address){this.address=new LocationAddress(address)}
215setSvgPoint(svgPoint){this.svgPoint=svgPoint instanceof SVGPoint?svgPoint:new SVGPoint(svgPoint);if(this.marker){this.marker.setSvgPointFromLocation()}}
216setGeoPoint(geoPoint){this.geoPoint=geoPoint instanceof GeoPoint?geoPoint:new GeoPoint(geoPoint);if(this.marker){this.marker.setSvgPointFromLocation()}}
217getMarkerImage(){if(this.img&&this.img.indexOf("uploads/")===0){return MapSVG.urls.uploads+"markers/"+this.img.replace("uploads/","")}else{return MapSVG.urls.root+"markers/"+(this.img||"_pin_default.png")}}
218getData(){const data={img:this.img,imagePath:this.imagePath,markerImagePath:this.marker&&this.marker.object?this.marker.object.getMarkerImage():this.imagePath,address:this.address,};if(this.geoPoint){data.geoPoint={lat:this.geoPoint.lat,lng:this.geoPoint.lng}}
219if(this.svgPoint){data.svgPoint={x:this.svgPoint.x,y:this.svgPoint.y}}
220return data}}
221class CustomObject{constructor(params,schema){this.initialLoad=!0;this.setSchema(schema);this.dirtyFields=[];this.regions=[];this._regions={};
221if(params.id!==undefined){this.id=params.id}
222this.initialLoad=!0;this.build(params);this.initialLoad=!1;if(this.id){this.clearDirtyFields()}}
223setSchema(schema){this.schema=schema;this.schema.events.on("changed",()=>this.setLocationField());this.fields=schema.getFieldNames();this.setLocationField()}
224build(params){for(const fieldName in params){const field=this.schema.getField(fieldName);if(field){if(!this.initialLoad){this.dirtyFields.push(fieldName)}
225switch(field.type){case "region":this.regions=params[fieldName];break;case "location":if(params[fieldName]!=null&&params[fieldName]!=""&&Object.keys(params[fieldName]).length!==0){const data={img:this.isMarkersByFieldEnabled()?this.getMarkerImage():params[fieldName].img,address:new LocationAddress(params[fieldName].address),};if(params[fieldName].geoPoint&&params[fieldName].geoPoint.lat&&params[fieldName].geoPoint.lng){data.geoPoint=new GeoPoint(params[fieldName].geoPoint)}else if(params[fieldName].svgPoint&&params[fieldName].svgPoint.x&&params[fieldName].svgPoint.y){data.svgPoint=new SVGPoint(params[fieldName].svgPoint)}
226if(this.location!=null){this.location.update(data)}else{this.location=new Location(data)}}else{this.location=null}
227break;case "post":if(params.post){this.post=params.post}
228break;case "select":this[fieldName]=params[fieldName];if(!field.multiselect){this[fieldName+"_text"]=this.getEnumLabel(field,params,fieldName)}
229break;case "radio":this[fieldName]=params[fieldName];this[fieldName+"_text"]=this.getEnumLabel(field,params,fieldName);break;default:this[fieldName]=params[fieldName];break}}}
230const locationField=this.getLocationField();if(locationField&&this.isMarkersByFieldEnabled()&&this.isMarkerFieldChanged(params)){this.reloadMarkerImage()}}
231isMarkerFieldChanged(params){return Object.keys(params).indexOf(this.getLocationField().markerField)!==-1}
232setLocationField(){}
233getLocationField(){return this.schema.getFieldByType("location")}
234reloadMarkerImage(){this.location&&this.location.setImage(this.getMarkerImage())}
235getMarkerImage(){let fieldValue;if(this.isMarkersByFieldEnabled()){const locationField=this.getLocationField();fieldValue=this[locationField.markerField];if(!fieldValue){return locationField.defaultMarkerPath||MapSVG.defaultMarkerImage}else{if(locationField.markerField==="regions"){fieldValue=fieldValue[0]&&fieldValue[0].id}else if(typeof fieldValue==="object"&&fieldValue.length){fieldValue=fieldValue[0].value}
236return(locationField.markersByField[fieldValue]||locationField.defaultMarkerPath||MapSVG.defaultMarkerImage)}}else{return this.location.imagePath}}
237isMarkersByFieldEnabled(){const locationField=this.getLocationField();if(!locationField){return!1}
238if(locationField.markersByFieldEnabled&&locationField.markerField&&Object.values(locationField.markersByField).length>0){return!0}else{return!1}}
239clone(){const data=this.getData();return new CustomObject(data,this.schema)}
240getEnumLabel(field,params,fieldName){const value=field.options.get(params[fieldName]);if(typeof value!=="undefined"){return value.label}else{return""}}
241update(params){this.build(params)}
242getDirtyFields(){const data={};this.dirtyFields.forEach((field)=>{data[field]=this[field]});data.id=this.id;if(data.location!=null&&data.location instanceof Location){data.location=data.location.getData()}
243if(this.schema.getFieldByType("region")){data.regions=this.regions}
244return data}
245clearDirtyFields(){this.dirtyFields=[]}
246getData(){const data={};const fields=this.schema.getFields();fields.forEach((field)=>{switch(field.type){case "region":data[field.name]=this[field.name];break;case "select":data[field.name]=this[field.name];if(!field.multiselect){data[field.name+"_text"]=this[field.name+"_text"]}
247break;case "post":data[field.name]=this[field.name];data.post=this.post;break;case "status":case "radio":data[field.name]=this[field.name];data[field.name+"_text"]=this[field.name+"_text"];break;case "location":data[field.name]=this[field.name]?this[field.name].getData():null;break;default:data[field.name]=this[field.name];break}});return data}
248getRegions(regionsTableName){return this.regions}
249getRegionsForTable(regionsTableName){return this.regions?this.regions.filter((region)=>!region.tableName||region.tableName===regionsTableName):[]}}
250const $$2=jQuery;class Repository{constructor(objectName,path){this.server=new Server();this.query=new Query();this.events=new Events(this);this.className="";this.objectNameSingle=objectName;this.objectNameMany=objectName+"s";this.setPath(path);this.objects=new ArrayIndexed("id");this.completeChunks=0}
251setNoFiltersNoLoad(value){this.noFiltersNoLoad=value}
252setDataSource(path){this.setPath(path);this.query=new Query({withSchema:!0}
252);return this.find().done(()=>{this.query.update({withSchema:!1})})}
253setPath(path){this.path=path.replace(/\/+$/,"")+"/"}
254setSchema(schema){this.schema=schema}
255getSchema(){return this.schema}
256loadDataFromResponse(response){let data;data=this.decodeData(response);this.objects.clear();if(data[this.objectNameMany]&&data[this.objectNameMany].length){this.hasMoreRecords=this.query.perpage&&data[this.objectNameMany].length>this.query.perpage;if(this.hasMoreRecords){data[this.objectNameMany].pop()}
257data[this.objectNameMany].forEach((obj)=>{this.objects.push(obj)})}else{this.hasMoreRecords=!1}
258this.loaded=!0;this.events.trigger("loaded")}
259reload(){return this.find()}
260create(object){const defer=jQuery.Deferred();defer.promise();const data={};data[this.objectNameSingle]=this.encodeData(object);this.server.post(this.path,data).done((response)=>{const data=this.decodeData(response);const object=data[this.objectNameSingle];this.objects.push(object);defer.resolve(object);this.events.trigger("created",this,[object])}).fail((response)=>{defer.reject(response)});return defer}
261findById(id,nocache=!1){const defer=jQuery.Deferred();defer.promise();let object;if(!nocache){object=this.objects.findById(id.toString())}
262if(!nocache&&object){defer.resolve(object)}else{this.server.get(this.path+id).done((response)=>{const data=this.decodeData(response);defer.resolve(data[this.objectNameSingle])}).fail((response)=>{defer.reject(response)})}
263return defer}
264find(query){this.events.trigger("load");const defer=jQuery.Deferred();defer.promise();if(typeof query!=="undefined"){this.query.update(query)}
265if(this.noFiltersNoLoad&&!this.query.hasFilters()){this.objects.clear();this.events.trigger("loaded");defer.resolve(this.getLoaded());return defer}
266if(!this.schema){this.query.update({withSchema:!0})}
267this.server.get(this.path,this.query).done((response)=>{if(!this.schema){this.query.update({withSchema:!1})}
268this.loadDataFromResponse(response);defer.resolve(this.getLoaded())}).fail((response)=>{defer.reject(response)});return defer}
269getLoaded(){return this.objects}
270getLoadedObject(id){return this.objects.findById(id.toString())}
271getLoadedAsArray(){return this.objects}
272update(object){const defer=jQuery.Deferred();defer.promise();const data={};const objectUpdatedFields="getDirtyFields" in object?object.getDirtyFields():object;data[this.objectNameSingle]=this.encodeData(objectUpdatedFields);this.server.put(this.path+objectUpdatedFields.id,data).done((response)=>{if("clearDirtyFields" in object){object.clearDirtyFields()}
273defer.resolve(object);this.events.trigger("updated",this,object)}).fail((response,stat)=>{defer.reject(response,stat)});return defer}
274delete(id){const defer=jQuery.Deferred();defer.promise();this.server.delete(this.path+id).done((response)=>{this.objects.delete(id.toString());this.events.trigger("deleted");defer.resolve()}).fail((response)=>{defer.reject(response)});return defer}
275clear(){const defer=jQuery.Deferred();defer.promise();this.server.delete(this.path).done((response)=>{this.objects.clear();this.events.trigger("loaded");this.events.trigger("cleared");defer.resolve()}).fail((response)=>{defer.reject(response)});return defer}
276onFirstPage(){return this.query.page===1}
277onLastPage(){return this.hasMoreRecords===!1}
278encodeData(params){return params}
279decodeData(dataJSON){let data;if(typeof dataJSON==="string"){data=JSON.parse(dataJSON)}else{data=dataJSON}
280if((data.object||data.region||data.regions||data.objects)&&data.schema){this.setSchema(new Schema(data.schema))}
281const dataFormatted={};for(const key in data){if(data[key]){switch(key){case "object":case "region":dataFormatted[key]=new CustomObject(data[key],this.schema);break;case "objects":case "regions":dataFormatted[key]=data[key].map((obj)=>new CustomObject(obj,this.schema));break;case "schema":dataFormatted[key]=this.schema||new Schema(data[key]);break;case "schemas":dataFormatted[key]=data[key].map((obj)=>new Schema(obj));break}}}
282return dataFormatted}
283import(data,convertLatlngToAddress,mapsvg){const _this=this;const locationField=_this.schema.getFieldByType("location");let language="en";if(locationField&&locationField.language){language=locationField.language}
284data=this.formatCSV(data,mapsvg);return this.importByChunks(data,language,convertLatlngToAddress).done(function(){_this.find()})}
285importByChunks(data,language,convertLatlngToAddress){const _this=this;let i,j,temparray,chunk=50;const chunks=[];for(i=0,j=data.length;i<j;i+=chunk){temparray=data.slice(i,i+chunk);chunks.push(temparray)}
286if(chunks.length>0){let delay=0;const delayPlus=chunks[0][0]&&chunks[0][0].location?1000:0;var defer=$$2.Deferred();defer.promise();_this.completeChunks=0;chunks.forEach(function(chunk){delay+=delayPlus;setTimeout(function(){const data={language:language,convertLatlngToAddress:convertLatlngToAddress,};data[_this.objectNameMany]=JSON.stringify(chunk);_this.server.post(_this.path+"import",data).done(function(_data){_this.completeChunk(chunks,defer)}).fail((response)=>{console.error(response)})},delay)})}
287return defer}
288completeChunk(chunks,defer){const _this=this;_this.completeChunks++;if(_this.completeChunks===chunks.length){defer.resolve()}}
289formatCSV(data,mapsvg){const _this=this;const latLngRegex=/^(\-?\d+(\.\d+)?),\s*(\-?\d+(\.\d+)?)$/g;const regionsTable=mapsvg.regionsRepository.getSchema().name;data.forEach(function(object,index){const newObject={};for(const key in object){let field=_this.schema.getField(key);if(key==="post"){field={type:"post"}}
290if(field!==undefined){switch(field.type){case "region":newObject[key]={};newObject[key]=object[key].split(",").map(function(regionId){return regionId.trim()}).filter(function(rId){return(mapsvg.getRegion(rId)!==undefined||mapsvg.regions.find(function(item){return item.title===rId})!==undefined)}).map(function(rId){let r=mapsvg.getRegion(rId);if(typeof r==="undefined"){r=mapsvg.regions.find(function(item){return item.title===rId})}
291return{id:r.id,title:r.title,tableName:regionsTable}});break;case "location":if(object[key].match(latLngRegex)){const coords=object[key].split(",").map(function(n){return parseFloat(n)});if(coords.length==2&&coords[0]>-90&&coords[0]<90&&coords[1]>-180&&coords[1]<180){newObject[key]={geoPoint:{lat:coords[0],lng:coords[1]},}}else{newObject[key]=""}}else if(object[key]){newObject[key]={address:object[key]}}
292if(typeof newObject[key]=="object"){newObject[key].img=mapsvg.options.defaultMarkerImage}
293break;case "select":const field=_this.schema.getField(key);if(field.multiselect){const labels=_this.schema.getField(key).options.map(function(f){return f.label});newObject[key]=object[key].split(",").map(function(label){return label.trim()}).filter(function(label){return labels.indexOf(label)!==-1}).map(function(label){return _this.schema.getField(key).options.filter(function(option){return option.label==label})[0]});if(newObject[key].length===0){const values=_this.schema.getField(key).options.map(function(f){return f.value+""});newObject[key]=object[key].split(",").map(function(value){return value.trim()}).filter(function(value){return values.indexOf(value)!==-1}).map(function(value){return _this.schema.getField(key).options.filter(function(option){return option.value==value})[0]})}}else{newObject[key]=object[key]}
294break;case "radio":case "text":case "textarea":case "status":default:newObject[key]=object[key];break}}}
295data[index]=newObject});return data}}
296class MapsRepository extends Repository{constructor(){super("map","maps");this.path="maps/"}
297encodeData(params){const data={};if(typeof params.options!=="undefined"){data.options=JSON.stringify(params.options);data.options=data.options.replace(/select/g,"!mapsvg-encoded-slct");data.options=data.options.replace(/table/g,"!mapsvg-encoded-tbl");data.options=data.options.replace(/database/g,"!mapsvg-encoded-db");data.options=data.options.replace(/varchar/g,"!mapsvg-encoded-vc");data.options=data.options.replace(/int\(11\)/g,"!mapsvg-encoded-int")}
298if(typeof params.title!=="undefined"){data.title=params.title}
299if(typeof params.id!=="undefined"){data.id=params.id}
300if(typeof params.status!=="undefined"){data.status=params.status}
301return data}
302decodeData(dataJSON){let data;if(typeof dataJSON==="string"){data=JSON.parse(dataJSON)}else{data=dataJSON}
303return data}
304copy(id,title){const defer=jQuery.Deferred();defer.promise();const data={options:{title:title}};this.server.post(this.path+id+"/copy",this.encodeData(data)).done((response)=>{const data=this.decodeData(response);this.objects.clear();this.events.trigger("loaded");this.events.trigger("cleared");defer.resolve(data.map)}).fail(()=>{defer.reject()});return defer}
305createFromV2(object){const defer=jQuery.Deferred();defer.promise();const data={};data[this.objectNameSingle]=this.encodeData(object);this.server.post(this.path+"/createFromV2",data).done((response)=>{const data=this.decodeData(response);const object=data[this.objectNameSingle];this.objects.push(object);defer.resolve(object);this.events.trigger("created",this,[object])}).fail(()=>{defer.reject()});return defer}
306delete(id){const defer=jQuery.Deferred();defer.promise();this.server.delete(this.path+id).done((response)=>{this.objects.delete(id.toString());this.events.trigger("deleted");defer.resolve()}).fail(()=>{defer.reject()});return defer}}
307class MapsV2Repository extends Repository{constructor(){super("map","maps");this.path="maps-v2/"}
308encodeData(params){const data={};data.options=JSON.stringify(params.options);data.options=data.options.replace(/select/g,"!mapsvg-encoded-slct");data.options=data.options.replace(/table/g,"!mapsvg-encoded-tbl");data.options=data.options.replace(/database/g,"!mapsvg-encoded-db");data.options=data.options.replace(/varchar/g,"!mapsvg-encoded-vc");data.id=params.id;data.title=params.title;return data}
309decodeData(dataJSON){let data;
309if(typeof dataJSON==="string"){data=JSON.parse(dataJSON)}else{data=dataJSON}
310return data}}
311class Converter{constructor(mapElement,defViewBox,viewBox,geoViewBox){this.mapElement=mapElement;this.defViewBox=defViewBox;this.viewBox=viewBox;this.yShift=0;if(geoViewBox){this.setGeoViewBox(geoViewBox)}}
312setYShift(){if(this.defViewBox.width===20426){this.yShift=0;return}
313if(this.geoViewBox){const topLeftPoint=this.convertGeoToSVG(this.geoViewBox.ne);this.yShift=topLeftPoint.y-this.defViewBox.y}}
314setGeoViewBox(geoViewBox){this.geoViewBox=geoViewBox;this.mapLonDelta=this.geoViewBox.ne.lng-this.geoViewBox.sw.lng;this.mapLatBottomDegree=(this.geoViewBox.sw.lat*Math.PI)/180;this.worldMapWidth=(this.defViewBox.width/this.mapLonDelta)*360;this.worldMapRadius=((this.defViewBox.width/this.mapLonDelta)*360)/(2*Math.PI);this.setYShift()}
315setWorldShift(on){this.worldShift=on}
316getScale(){return this.mapElement.clientWidth/this.viewBox.width}
317convertSVGToPixel(svgPoint){const scale=this.getScale();let shiftXByGM=0;const shiftYByGM=0;if(this.worldShift){if(this.viewBox.x-this.defViewBox.x>this.defViewBox.width){shiftXByGM=this.worldMapWidth*Math.floor((this.viewBox.x-this.defViewBox.x)/this.defViewBox.width)}}
318return new ScreenPoint((svgPoint.x-this.viewBox.x+shiftXByGM)*scale,(svgPoint.y-this.viewBox.y+shiftYByGM)*scale)}
319convertPixelToSVG(screenPoint){const scale=this.getScale();return new SVGPoint(screenPoint.x/scale+this.viewBox.x,screenPoint.y/scale+this.viewBox.y)}
320convertGeoToSVG(geoPoint){if(!this.geoViewBox){throw new Error("Can't do convertGeoToSVG() - geoViewBox is not provided.")}
321let x=(geoPoint.lng-this.geoViewBox.sw.lng)*(this.defViewBox.width/this.mapLonDelta);const lat=(geoPoint.lat*Math.PI)/180;const mapOffsetY=(this.worldMapRadius/2)*Math.log((1+Math.sin(this.mapLatBottomDegree))/(1-Math.sin(this.mapLatBottomDegree)));let y=this.defViewBox.height-((this.worldMapRadius/2)*Math.log((1+Math.sin(lat))/(1-Math.sin(lat)))-mapOffsetY);x+=this.defViewBox.x;y+=this.defViewBox.y;y-=this.yShift;return new SVGPoint(x,y)}
322convertSVGToGeo(svgPoint){if(!this.geoViewBox){throw new Error("Can't do convertSVGToGeo() - geoViewBox is not provided.")}
323const tx=svgPoint.x-this.defViewBox.x;const ty=svgPoint.y-this.defViewBox.y;const mapOffsetY=(this.worldMapRadius/2)*Math.log((1+Math.sin(this.mapLatBottomDegree))/(1-Math.sin(this.mapLatBottomDegree)));const equatorY=this.defViewBox.height+mapOffsetY;const a=(equatorY-ty)/this.worldMapRadius;let lat=(180/Math.PI)*(2*Math.atan(Math.exp(a))-Math.PI/2);let lng=this.geoViewBox.sw.lng+(tx/this.defViewBox.width)*this.mapLonDelta;lat=parseFloat(lat.toFixed(6));lng=parseFloat(lng.toFixed(6));return new GeoPoint(lat,lng)}}
324const $$3=jQuery;class ResizeSensor{constructor(element,callback){const _this=this;_this.element=element;_this.callback=callback;const style=getComputedStyle(element);let zIndex=parseInt(style.zIndex);if(isNaN(zIndex)){zIndex=0}
325zIndex--;_this.expand=document.createElement("div");_this.expand.style.position="absolute";_this.expand.style.left="0px";_this.expand.style.top="0px";_this.expand.style.right="0px";_this.expand.style.bottom="0px";_this.expand.style.overflow="hidden";_this.expand.style.zIndex=zIndex.toString();_this.expand.style.visibility="hidden";const expandChild=document.createElement("div");expandChild.style.position="absolute";expandChild.style.left="0px";expandChild.style.top="0px";expandChild.style.width="10000000px";expandChild.style.height="10000000px";_this.expand.appendChild(expandChild);_this.shrink=document.createElement("div");_this.shrink.style.position="absolute";_this.shrink.style.left="0px";_this.shrink.style.top="0px";_this.shrink.style.right="0px";_this.shrink.style.bottom="0px";_this.shrink.style.overflow="hidden";_this.shrink.style.zIndex=zIndex.toString();_this.shrink.style.visibility="hidden";const shrinkChild=document.createElement("div");shrinkChild.style.position="absolute";shrinkChild.style.left="0px";shrinkChild.style.top="0px";shrinkChild.style.width="200%";shrinkChild.style.height="200%";_this.shrink.appendChild(shrinkChild);_this.element.appendChild(_this.expand);_this.element.appendChild(_this.shrink);const size=element.getBoundingClientRect();_this.currentWidth=size.width;_this.currentHeight=size.height;_this.setScroll();_this.expand.addEventListener("scroll",function(){_this.onScroll()});_this.shrink.addEventListener("scroll",function(){_this.onScroll()})}
326onScroll(){const _this=this;const size=_this.element.getBoundingClientRect();const newWidth=size.width;const newHeight=size.height;if(newWidth!=_this.currentWidth||newHeight!=_this.currentHeight){_this.currentWidth=newWidth;_this.currentHeight=newHeight;_this.callback()}
327this.setScroll()}
328setScroll(){this.expand.scrollLeft=10000000;this.expand.scrollTop=10000000;this.shrink.scrollLeft=10000000;this.shrink.scrollTop=10000000}
329destroy(){this.expand.remove();this.shrink.remove()}}
330class ViewBox{constructor(x,y,width,height){if(typeof x==="object"){if(x.hasOwnProperty("x")&&x.hasOwnProperty("y")&&x.hasOwnProperty("width")&&x.hasOwnProperty("height")){this.x=typeof x.x==="string"?parseFloat(x.x):x.x;
330this.y=typeof x.y==="string"?parseFloat(x.y):x.y;this.width=typeof x.width==="string"?parseFloat(x.width):x.width;this.height=typeof x.height==="string"?parseFloat(x.height):x.height}else if(typeof x==="object"&&x.length&&x.length===4){this.x=typeof x[0]==="string"?parseFloat(x[0]):x[0];this.y=typeof x[1]==="string"?parseFloat(x[1]):x[1];this.width=typeof x[2]==="string"?parseFloat(x[2]):x[2];this.height=typeof x[3]==="string"?parseFloat(x[3]):x[3]}}else{this.x=typeof x==="string"?parseFloat(x):x;this.y=typeof y==="string"?parseFloat(y):y;this.width=typeof width==="string"?parseFloat(width):width;this.height=typeof height==="string"?parseFloat(height):height}}
331update(newViewBox){this.x=newViewBox.x;this.y=newViewBox.y;this.width=newViewBox.width;this.height=newViewBox.height}
332toString(){return this.x+" "+this.y+" "+this.width+" "+this.height}
333toArray(){return[this.x,this.y,this.width,this.height]}
334clone(){return new ViewBox({x:this.x,y:this.y,width:this.width,height:this.height})}
335fitsInViewBox(viewBox,atLeastByOneDimension){if(atLeastByOneDimension===!0){return viewBox.width>this.width||viewBox.height>this.height}else{return viewBox.width>this.width&&viewBox.height>this.height}}
336addPadding(padding){if(padding.top){this.y-=padding.top;this.height+=padding.top}
337if(padding.right){this.width+=padding.right}
338if(padding.bottom){this.height+=padding.bottom}
339if(padding.left){this.x-=padding.left;this.width+=padding.left}}}
340class GeoViewBox{constructor(sw,ne){this.sw=sw;this.ne=ne}}
341const $$4=jQuery;class MapObject{constructor(element,mapsvg){this.id="";this.objects=[];this.events=new Events(this);this.element=element;this.mapsvg=mapsvg}
342getBBox(){return new ViewBox(1,2,3,4)}
343getGeoBounds(){const bbox=this.getBBox();const pointSW=new SVGPoint(bbox.x,bbox.y+bbox.height);const pointNE=new SVGPoint(bbox.x+bbox.width,bbox.y);const sw=this.mapsvg.converter.convertSVGToGeo(pointSW);const ne=this.mapsvg.converter.convertSVGToGeo(pointNE);return{sw:sw,ne:ne}}
344getComputedStyle(prop,elem){elem=elem||this.element;return MapObject.getComputedStyle(prop,elem)}
345static getComputedStyle(prop,elem){const _p1=elem.getAttribute(prop);if(_p1){return _p1}
346const _p2=elem.getAttribute("style");if(_p2){const s=_p2.split(";");const z=s.filter(function(e){e=e.trim();const attr=e.split(":");if(attr[0]==prop)
347return!0});if(z.length){return z[0].split(":").pop().trim()}}
348const parent=elem.parentElement;const elemType=parent?parent.tagName:null;if(elemType&&elemType!="svg")
349return MapObject.getComputedStyle(prop,parent);else return undefined}
350getStyle(prop){const _p1=this.attr(prop);if(_p1){return _p1}
351const _p2=this.attr("style");if(_p2){const s=_p2.split(";");const z=s.filter(function(e){var e=e.trim();if(e.indexOf(prop)===0)
352return e});return z.length?z[0].split(":").pop().trim():undefined}
353return""}
354getCenter(){const x=this.element.getBoundingClientRect().left;const y=this.element.getBoundingClientRect().top;const w=this.element.getBoundingClientRect().width;const h=this.element.getBoundingClientRect().height;const point=new ScreenPoint(x+w/2,y+h/2);return point}
355getCenterSVG(){const bbox=this.getBBox();const point=new SVGPoint(bbox.x+bbox.width/2,bbox.y+bbox.height/2);return point}
356getCenterLatLng(yShift){yShift=yShift?yShift:0;const bbox=this.getBBox();const x=bbox.x+bbox.width/2;const y=bbox.y+bbox.height/2-yShift;const point=new SVGPoint(x,y);return this.mapsvg.converter.convertSVGToGeo(point)}
357attr(v1,v2=null){const svgDom=this.element;if(typeof v1=="object"){for(const key in v1){const item=v1[key];if(typeof item==="string"||typeof item==="number"){svgDom.setAttribute(key,""+item)}}}else if(typeof v1=="string"&&(typeof v2=="string"||typeof v2=="number")){svgDom.setAttribute(v1,""+v2)}else if(v2==undefined){return svgDom.getAttribute(v1)}}
358setId(id){if(id!==undefined){this.id=id;this.element.setAttribute("id",id)}}}
359const $$5=jQuery;class Marker extends MapObject{constructor(params){super(null,params.mapsvg);this.element=$$5("<div />").addClass("mapsvg-marker")[0];this.image=$$5('<img src="" />').addClass("mapsvg-marker-image")[0];if(params.object){this.setObject(params.object)}
360if(!(params.location instanceof Location)){throw new Error("MapSVG.Marker: no Location provided for Marker initializaton")}else{this.location=params.location;this.location.marker=this}
361this.setImage(this.location.imagePath);$$5(this.element).append(this.image);if(params.width&&params.height){this.setSize(params.width,params.height)}else{this.setSize(15,24)}
362this.setId(this.mapsvg.markerId());this.setSvgPointFromLocation();this.setAltAttr()}
363reload(){this.setImage();this.setSvgPointFromLocation()}
364getImagePath(){return(this.object&&this.object.getMarkerImage())||this.location.getMarkerImage()}
365setSize(width,height){this.width=width;this.height=height;this.setCentered(this.width===this.height)}
366setSvgPointFromLocation(){const svgPoint=this.location.geoPoint&&this.location.geoPoint.lat!==0&&this.location.geoPoint.lng!==0?this.mapsvg.converter.convertGeoToSVG(this.location.geoPoint):this.location.svgPoint;if(svgPoint){this.setSvgPoint(svgPoint)}}
367setId(id){MapObject.prototype.setId.call(this,id);this.mapsvg.markers.reindex()}
368getBBox(){if(this.centered){return new ViewBox(this.svgPoint.x-this.width/2/this.mapsvg.scale,this.svgPoint.y-this.height/2/this.mapsvg.scale,this.width/this.mapsvg.scale,this.height/this.mapsvg.scale)}else{return new ViewBox(this.svgPoint.x-this.width/2/this.mapsvg.scale,this.svgPoint.y-this.height/this.mapsvg.scale,this.width/this.mapsvg.scale,this.height/this.mapsvg.scale)}}
369getOptions(){const o={id:this.id,src:this.src,svgPoint:this.svgPoint,geoPoint:this.geoPoint,};$$5.each(o,function(key,val){if(val==undefined){delete o[key]}});return o}
370update(data){for(const key in data){const setter="set"+MapSVG.ucfirst(key);if(setter in this)
371this[setter](data[key])}}
372setImage(src,skipChangingLocationImage=!1){if(!src){src=this.getImagePath()}
373this.src=MapSVG.safeURL(src);const img=new Image();const marker=this;img.onload=function(){if(marker.image.getAttribute("src")!=="src"){marker.image.setAttribute("src",marker.src)}
374marker.setSize(this.width,this.height);marker.adjustScreenPosition()};img.src=this.src;this.events.trigger("change")}
375setAltAttr(){const marker=this;marker.altAttr=typeof marker.object!="undefined"&&typeof marker.object.title!="undefined"&&marker.object.title!==""?marker.object.title:marker.id;marker.image.setAttribute("alt",marker.altAttr)}
376setSvgPoint(svgPoint){this.svgPoint=svgPoint;this.adjustScreenPosition();this.events.trigger("change")}
377adjustScreenPosition(){const pos=this.mapsvg.converter.convertSVGToPixel(this.svgPoint);pos.x-=this.width/2;pos.y-=!this.centered?this.height:this.height/2;this.setScreenPosition(pos.x,pos.y)}
378moveSrceenPositionBy(deltaX,deltaY){const oldPos=this.screenPoint,x=oldPos.x-deltaX,y=oldPos.y-deltaY;this.setScreenPosition(x,y)}
379setScreenPosition(x,y){if(this.screenPoint instanceof ScreenPoint){this.screenPoint.x=x;this.screenPoint.y=y}else{this.screenPoint=new ScreenPoint(x,y)}
380this.updateVisibility();if(this.visible===!0){this.element.style.transform="translate("+x+"px,"+y+"px)";this.adjustLabelScreenPosition()}}
381adjustLabelScreenPosition(){if(this.label){const markerPos=this.screenPoint,x=Math.round(markerPos.x+this.width/2-$$5(this.label).outerWidth()/2),y=Math.round(markerPos.y-$$5(this.label).outerHeight())}}
382inViewBox(){const x=this.screenPoint.x,y=this.screenPoint.y,mapFullWidth=this.mapsvg.containers.map.offsetWidth,mapFullHeight=this.mapsvg.containers.map.offsetHeight;return(x-this.width/2<2*mapFullWidth&&x+this.width/2>-mapFullWidth&&y-this.height/2<2*mapFullHeight&&y+this.height/2>-mapFullHeight)}
383updateVisibility(){if(this.inViewBox()===!0){this.visible=!0;this.element.classList.remove("mapsvg-out-of-sight");if(this.label){this.label.classList.remove("mapsvg-out-of-sight")}}else{this.visible=!1;this.element.classList.add("mapsvg-out-of-sight");if(this.label){this.label.classList.add("mapsvg-out-of-sight")}}
384return this.visible}
385isMoving(){return this.moving}
386setMoving(value){this.moving=value}
387drag(startCoords,scale,endCallback,clickCallback){const _this=this;this.svgPointBeforeDrag=new SVGPoint(this.svgPoint.x,this.svgPoint.y);this.setMoving(!0);$$5("body").on("mousemove.drag.mapsvg",function(e){e.preventDefault();$$5(_this.mapsvg.containers.map).addClass("no-transitions");const mouseNew=MapSVG.mouseCoords(e);const dx=mouseNew.x-startCoords.x;const dy=mouseNew.y-startCoords.y;const newSvgPoint=new SVGPoint(_this.svgPointBeforeDrag.x+dx/scale,_this.svgPointBeforeDrag.y+dy/scale);_this.setSvgPoint(newSvgPoint)});$$5("body").on("mouseup.drag.mapsvg",function(e){e.preventDefault();_this.undrag();const mouseNew=MapSVG.mouseCoords(e);const dx=mouseNew.x-startCoords.x;const dy=mouseNew.y-startCoords.y;const newSvgPoint=new SVGPoint(_this.svgPointBeforeDrag.x+dx/scale,_this.svgPointBeforeDrag.y+dy/scale);_this.setSvgPoint(newSvgPoint);if(_this.mapsvg.isGeo()){_this.geoPoint=_this.mapsvg.converter.convertSVGToGeo(newSvgPoint)}
388endCallback&&endCallback.call(_this);if(_this.svgPointBeforeDrag.x==_this.svgPoint.x&&_this.svgPointBeforeDrag.y==_this.svgPoint.y)
389clickCallback&&clickCallback.call(_this)})}
390undrag(){this.setMoving(!1);$$5("body").off(".drag.mapsvg");$$5(this.mapsvg.containers.map).removeClass("no-transitions")}
391delete(){if(this.label){this.label.remove();this.label=null}
392$$5(this.element).empty().remove()}
393setObject(obj){this.object=obj;$$5(this.element).attr("data-object-id",this.object.id)}
394hide(){$$5(this.element).addClass("mapsvg-marker-hidden");if(this.label){$$5(this.label).hide()}}
395show(){$$5(this.element).removeClass("mapsvg-marker-hidden");if(this.label){$$5(this.label).show()}}
396highlight(){$$5(this.element).addClass("mapsvg-marker-hover")}
397unhighlight(){$$5(this.element).removeClass("mapsvg-marker-hover")}
398select(){this.selected=!0;$$5(this.element).addClass("mapsvg-marker-active")}
399deselect(){this.selected=!1;$$5(this.element).removeClass("mapsvg-marker-active")}
400getData(){return this.object}
401getChoroplethColor(){const markerValue=parseFloat(this.object[this.mapsvg.options.choropleth.sourceField]);let color;if(!markerValue){color=this.mapsvg.options.choropleth.coloring.noData.color}else if(this.mapsvg.options.choropleth.coloring.mode==="gradient"){const gradient=this.mapsvg.options.choropleth.coloring.gradient,w=gradient.values.maxAdjusted===0?0:(markerValue-gradient.values.min)/gradient.values.maxAdjusted,r=Math.round(gradient.colors.diffRGB.r*w+gradient.colors.lowRGB.r),g=Math.round(gradient.colors.diffRGB.g*w+gradient.colors.lowRGB.g),b=Math.round(gradient.colors.diffRGB.b*w+gradient.colors.lowRGB.b),a=(gradient.colors.diffRGB.a*w+gradient.colors.lowRGB.a).toFixed(2);color="rgba("+r+","+g+","+b+","+a+")"}else{const paletteColors=this.mapsvg.options.choropleth.coloring.palette.colors;if(!paletteColors[0].valueFrom&&markerValue<paletteColors[0].valueTo){color=paletteColors[0].color}else if(!paletteColors[paletteColors.length-1].valueTo&&markerValue>paletteColors[paletteColors.length-1].valueFrom){color=paletteColors[paletteColors.length-1].color}
401else{paletteColors.forEach(function(paletteColor){if(markerValue>=paletteColor.valueFrom&&markerValue<paletteColor.valueTo){color=paletteColor.color}});color=color?color:this.mapsvg.options.choropleth.coloring.palette.outOfRange.color}}
402return color}
403getBubbleSize(){let bubbleSize;if(this.object[this.mapsvg.options.choropleth.sourceField]){const maxBubbleSize=Number(this.mapsvg.options.choropleth.bubbleSize.max),minBubbleSize=Number(this.mapsvg.options.choropleth.bubbleSize.min),maxSourceFieldvalue=this.mapsvg.options.choropleth.coloring.gradient.values.max,minSourceFieldvalue=this.mapsvg.options.choropleth.coloring.gradient.values.min,sourceFieldvalue=parseFloat(this.object[this.mapsvg.options.choropleth.sourceField]);bubbleSize=((sourceFieldvalue-minSourceFieldvalue)/(maxSourceFieldvalue-minSourceFieldvalue))*(maxBubbleSize-minBubbleSize)+Number(minBubbleSize)}else{bubbleSize=!1}
404return bubbleSize}
405getBubbleScreenPosition(){const bubbleSize=Number(this.getBubbleSize());return{x:this.width/2-bubbleSize/2,y:this.height-bubbleSize/2,}}
406drawBubble(){const bubbleId="mapsvg-bubble-"+this.object.id;const bubbleValue=parseFloat(this.object[this.mapsvg.options.choropleth.sourceField]);if(bubbleValue){if(!this.bubble){this.bubble=$$5('<div id="'+bubbleId+'" data-marker-id="'+this.element.id+'" class="mapsvg-bubble mapsvg-marker-bubble"></div>')[0];$$5(this.element).append(this.bubble)}
407const color=this.getChoroplethColor(),bubbleSize=Number(this.getBubbleSize());$$5(this.bubble).css("background-color",color).css("width",bubbleSize+"px").css("height",bubbleSize+"px").css("lineHeight",bubbleSize-2+"px")}else{$$5("#"+bubbleId).remove();delete this.bubble}}
408setBubbleMode(bubbleMode){this.bubbleMode=bubbleMode;if(bubbleMode){this.setCentered(!0);this.drawBubble();if(this.bubble){this.width=this.bubble.offsetWidth;this.height=this.bubble.offsetHeight;this.adjustScreenPosition()}}else{this.setImage(this.src)}}
409setLabel(html){if(html){if(!this.label){this.label=$$5("<div />").addClass("mapsvg-marker-label")[0];$$5(this.element).append(this.label)}
410$$5(this.label).html(html)}else{if(this.label){$$5(this.label).remove();delete this.label}}}
411setCentered(on){this.centered=on}}
412const $$6=jQuery;class MarkerCluster extends MapObject{constructor(options,mapsvg){super(null,mapsvg);this.svgPoint=options.svgPoint;this.cellX=options.cellX;this.cellY=options.cellY;this.markers=options.markers||[];this.cellSize=50;this.width=30;this.elem=$$6('<div class="mapsvg-marker-cluster">'+this.markers.length+"</div>")[0];$$6(this.elem).data("cluster",this);if(this.markers.length<2){$$6(this.elem).hide()}
413this.adjustScreenPosition()}
414addMarker(marker){this.markers.push(marker);if(this.markers.length>1){if(this.markers.length===2){$$6(this.elem).show()}
415if(this.markers.length===2){const x=this.markers.map(function(m){return m.svgPoint.x});this.min_x=Math.min.apply(null,x);this.max_x=Math.max.apply(null,x);const y=this.markers.map(function(m){return m.svgPoint.y});this.min_y=Math.min.apply(null,y);this.max_y=Math.max.apply(null,y);this.svgPoint.x=this.min_x+(this.max_x-this.min_x)/2;this.svgPoint.y=this.min_y+(this.max_y-this.min_y)/2}
416if(this.markers.length>2){if(marker.svgPoint.x<this.min_x){this.min_x=marker.svgPoint.x}else if(marker.svgPoint.x>this.max_x){this.max_x=marker.svgPoint.x}
417if(marker.svgPoint.y<this.min_y){this.min_y=marker.svgPoint.y}else if(marker.svgPoint.x>this.max_x){this.max_y=marker.svgPoint.y}
418this.svgPoint.x=this.min_x+(this.max_x-this.min_x)/2;this.svgPoint.y=this.min_y+(this.max_y-this.min_y)/2}}else{this.svgPoint.x=marker.svgPoint.x;this.svgPoint.y=marker.svgPoint.y}
419$$6(this.elem).text(this.markers.length);this.adjustScreenPosition()}
420canTakeMarker(marker){const _this=this;const screenPoint=_this.mapsvg.converter.convertSVGToPixel(marker.svgPoint);return(this.cellX===Math.ceil(screenPoint.x/this.cellSize)&&this.cellY===Math.ceil(screenPoint.y/this.cellSize))}
421destroy(){this.markers=null;$$6(this.elem).remove()}
422adjustScreenPosition(){const pos=this.mapsvg.converter.convertSVGToPixel(this.svgPoint);pos.x-=this.width/2;pos.y-=this.width/2;this.setScreenPosition(pos.x,pos.y)}
423moveSrceenPositionBy(deltaX,deltaY){const oldPos=this.screenPoint,x=oldPos.x-deltaX,y=oldPos.y-deltaY;this.setScreenPosition(x,y)}
424setScreenPosition(x,y){if(this.screenPoint instanceof ScreenPoint){this.screenPoint.x=x;this.screenPoint.y=y}else{this.screenPoint=new ScreenPoint(x,y)}
425this.updateVisibility();if(this.visible===!0){this.elem.style.transform="translate("+x+"px,"+y+"px)"}}
426inViewBox(){const x=this.screenPoint.x,y=this.screenPoint.y,mapFullWidth=this.mapsvg.containers.map.offsetWidth,mapFullHeight=this.mapsvg.containers.map.offsetHeight;return(x-this.width/2<mapFullWidth&&x+this.width/2>0&&y-this.width/2<mapFullHeight&&y+this.width/2>0)}
427updateVisibility(){if(this.inViewBox()===!0){this.visible=!0;this.elem.classList.remove("mapsvg-out-of-sight")}else{this.visible=!1;this.elem.classList.add("mapsvg-out-of-sight")}
428return this.visible}
429getBBox(){let bbox={x:this.svgPoint.x,y:this.svgPoint.y,width:this.cellSize/this.mapsvg.getScale(),height:this.cellSize/this.mapsvg.getScale(),};bbox=$$6.extend(!0,{},bbox);return new ViewBox(bbox.x,bbox.y,bbox.width,bbox.height)}
430getData(){return this.markers.map((m)=>m.object)}}
431const $$7=jQuery;class Region extends MapObject{constructor(element,mapsvg){super(element,mapsvg);this.id=this.element.getAttribute("id");if(this.id&&this.mapsvg.options.regionPrefix){this.setId(this.id.replace(this.mapsvg.options.regionPrefix,""))}
432this.id_no_spaces=this.id.replace(/\s/g,"_");this.element.setAttribute("class",(this.element.className||"")+" mapsvg-region");this.setStyleInitial();const regionOptions=this.mapsvg.options.regions&&this.mapsvg.options.regions[this.id]?this.mapsvg.options.regions[this.id]:null;this.disabled=this.getDisabledState();this.disabled&&this.attr("class",this.attr("class")+" mapsvg-disabled");this.default_attr={};this.selected_attr={};this.hover_attr={};let selected=!1;if(regionOptions&&regionOptions.selected){selected=!0;delete regionOptions.selected}
433regionOptions&&this.update(regionOptions);this.setFill();if(selected){this.setSelected()}
434this.saveState()}
435adjustStroke(scale){$$7(this.element).css({"stroke-width":this.style["stroke-width"]/scale})}
436setStyleInitial(){this.style={fill:this.getComputedStyle("fill")};this.style.stroke=this.getComputedStyle("stroke")||"";let w;w=this.getComputedStyle("stroke-width");w=w?w.replace("px",""):"1";w=parseFloat(w);this.style["stroke-width"]=w;$$7(this.element).attr("data-stroke-width",w)}
437saveState(){this.initialState=JSON.stringify(this.getOptions())}
438getBBox(){const _bbox=this.element.getBBox();const bbox=new ViewBox(_bbox.x,_bbox.y,_bbox.width,_bbox.height);const matrix=this.element.getTransformToElement(this.mapsvg.containers.svg);if(!matrix){return _bbox}
439const x2=bbox.x+bbox.width;const y2=bbox.y+bbox.height;let position=this.mapsvg.containers.svg.createSVGPoint();position.x=bbox.x;position.y=bbox.y;position=position.matrixTransform(matrix);bbox.x=position.x;bbox.y=position.y;position.x=x2;position.y=y2;position=position.matrixTransform(matrix);bbox.width=position.x-bbox.x;bbox.height=position.y-bbox.y;return bbox}
440changed(){return JSON.stringify(this.getOptions())!=this.initialState}
441edit(){this.elemOriginal=$$7(this.element).clone()[0]}
442editCommit(){this.elemOriginal=null}
443editCancel(){this.mapsvg.containers.svg.appendChild(this.elemOriginal);this.element=this.elemOriginal;this.elemOriginal=null}
444getOptions(forTemplate){let o;o={id:this.id,id_no_spaces:this.id_no_spaces,title:this.title,fill:this.mapsvg.options.regions[this.id]&&this.mapsvg.options.regions[this.id].fill,data:this.data,choroplethValue:this.choroplethValue,};if(forTemplate){o.disabled=this.disabled}
445for(const key in o){if(typeof o[key]==="undefined"){delete o[key]}}
446if(this.customAttrs){const that=this;this.customAttrs.forEach(function(attr){o[attr]=that[attr]})}
447return o}
448forTemplate(){const data={id:this.id,title:this.title,objects:this.objects,data:this.data,};if(this.data){for(const key in this.data){if(key!="title"&&key!="id")
449data[key]=this.data[key]}}
450return data}
451getData(){return this.forTemplate()}
452update(options){for(const key in options){const setter="set"+MapSVG.ucfirst(key);if(setter in this)
453this[setter](options[key]);else{this[key]=options[key];this.customAttrs=this.customAttrs||[];this.customAttrs.push(key)}}}
454setTitle(title){if(title){this.title=title}
455this.element.setAttribute("title",this.title)}
456setStyle(style){$$7.extend(!0,this.style,style);this.setFill()}
457getChoroplethColor(){const o=this.mapsvg.options.choropleth;let color="";if(this.data&&(this.data[this.mapsvg.options.regionChoroplethField]||this.data[this.mapsvg.options.regionChoroplethField]===0)){const w=o.maxAdjusted===0?0:(parseFloat(this.data[this.mapsvg.options.regionChoroplethField])-o.min)/o.maxAdjusted;const c={r:Math.round(o.colors.diffRGB.r*w+o.colors.lowRGB.r),g:Math.round(o.colors.diffRGB.g*w+o.colors.lowRGB.g),b:Math.round(o.colors.diffRGB.b*w+o.colors.lowRGB.b),a:(o.colors.diffRGB.a*w+o.colors.lowRGB.a).toFixed(2),};color="rgba("+c.r+","+c.g+","+c.b+","+c.a+")"}else{color=o.colors.noData}
458return color}
459_new_getChoroplethColor(){let regionValue=parseFloat(this.data[this.mapsvg.options.choropleth.sourceField]),color;if(!regionValue){color=this.mapsvg.options.choropleth.coloring.noData.color}else if(this.mapsvg.options.choropleth.coloring.mode==="gradient"){const gradient=this.mapsvg.options.choropleth.coloring.gradient,w=gradient.values.maxAdjusted===0?0:(regionValue-gradient.values.min)/gradient.values.maxAdjusted,r=Math.round(gradient.colors.diffRGB.r*w+gradient.colors.lowRGB.r),g=Math.round(gradient.colors.diffRGB.g*w+gradient.colors.lowRGB.g),b=Math.round(gradient.colors.diffRGB.b*w+gradient.colors.lowRGB.b),a=(gradient.colors.diffRGB.a*w+gradient.colors.lowRGB.a).toFixed(2);color="rgba("+r+","+g+","+b+","+a+")"}else{const paletteColors=this.mapsvg.options.choropleth.coloring.palette.colors;if(!paletteColors[0].valueFrom&&regionValue<paletteColors[0].valueTo){color=paletteColors[0].color}else if(!paletteColors[paletteColors.length-1].valueTo&&regionValue>paletteColors[paletteColors.length-1].valueFrom){color=paletteColors[paletteColors.length-1].color}else{paletteColors.forEach(function(paletteColor){if(regionValue>=paletteColor.valueFrom&&regionValue<paletteColor.valueTo){color=paletteColor.color}});color=color?color:this.mapsvg.options.choropleth.coloring.palette.outOfRange.color}}
460return color}
461getBubbleSize(){let bubbleSize;if(this.data[this.mapsvg.options.choropleth.sourceField]){const maxBubbleSize=Number(this.mapsvg.options.choropleth.bubbleSize.max),minBubbleSize=Number(this.mapsvg.options.choropleth.bubbleSize.min),maxSourceFieldvalue=this.mapsvg.options.choropleth.coloring.gradient.values.max,minSourceFieldvalue=this.mapsvg.options.choropleth.coloring.gradient.values.min,sourceFieldvalue=parseFloat(this.data[this.mapsvg.options.choropleth.sourceField]);bubbleSize=((sourceFieldvalue-minSourceFieldvalue)/(maxSourceFieldvalue-minSourceFieldvalue))*(maxBubbleSize-minBubbleSize)+minBubbleSize}else{bubbleSize=!1}
462return bubbleSize}
463setFill(fill){if(this.mapsvg.options.colorsIgnore){$$7(this.element).css(this.style);return}
464if(fill){const regions={};regions[this.id]={fill:fill};$$7.extend(!0,this.mapsvg.options,{regions:regions})}else if(!fill&&fill!==undefined&&this.mapsvg.options.regions&&this.mapsvg.options.regions[this.id]&&this.mapsvg.options.regions[this.id].fill){delete this.mapsvg.options.regions[this.id].fill}
465if(this.mapsvg.options.choropleth.on){this.default_attr.fill=this.getChoroplethColor()}else if(this.status!==undefined&&this.mapsvg.regions&&this.mapsvg.regionsRepository.getSchema().getFieldByType("status")&&this.mapsvg.regionsRepository.getSchema().getFieldByType("status").optionsDict&&this.mapsvg.regionsRepository.getSchema().getFieldByType("status").optionsDict[this.status]&&this.mapsvg.regionsRepository.getSchema().getFieldByType("status").optionsDict[this.status].color){this.default_attr.fill=this.mapsvg.regionsRepository.getSchema().getFieldByType("status").optionsDict[this.status].color}else if(this.mapsvg.options.regions[this.id]&&this.mapsvg.options.regions[this.id].fill){this.default_attr.fill=this.mapsvg.options.regions[this.id].fill}else if(this.mapsvg.options.colors.base){this.default_attr.fill=this.mapsvg.options.colors.base}else if(this.style.fill!="none"){this.default_attr.fill=this.style.fill?this.style.fill:this.mapsvg.options.colors.baseDefault}else{this.default_attr.fill="none"}
466if(MapSVG.isNumber(this.mapsvg.options.colors.selected))
467this.selected_attr.fill=tinycolor(this.default_attr.fill).lighten(parseFloat(""+this.mapsvg.options.colors.selected)).toRgbString();else this.selected_attr.fill=this.mapsvg.options.colors.selected;if(MapSVG.isNumber(this.mapsvg.options.colors.hover))
468this.hover_attr.fill=tinycolor(this.default_attr.fill).lighten(parseFloat(""+this.mapsvg.options.colors.hover)).toRgbString();else this.hover_attr.fill=this.mapsvg.options.colors.hover;$$7(this.element).css("fill",this.default_attr.fill);this.fill=this.default_attr.fill;if(this.style.stroke!="none"&&this.mapsvg.options.colors.stroke!=undefined){$$7(this.element).css("stroke",this.mapsvg.options.colors.stroke)}else{const s=this.style.stroke==undefined?"":this.style.stroke;$$7(this.element).css("stroke",s)}
469if(this.selected)
470this.setSelected()}
471setDisabled(on,skipSetFill){on=on!==undefined?MapSVG.parseBoolean(on):this.getDisabledState();const prevDisabled=this.disabled;this.disabled=on;this.attr("class",this.attr("class").replace("mapsvg-disabled",""));if(on){this.attr("class",this.attr("class")+" mapsvg-disabled")}
472if(this.disabled!=prevDisabled)
473this.mapsvg.deselectRegion(this);!skipSetFill&&this.setFill()}
474setStatus(status){const statusOptions=this.mapsvg.options.regionStatuses&&this.mapsvg.options.regionStatuses[status];if(statusOptions){this.status=status;if(this.data){this.data.status=status;this.data.status_text=statusOptions.label}
475this.setDisabled(statusOptions.disabled,!0)}else{this.status=undefined;if(this.data){this.data.status=undefined;this.data.status_text=undefined}
476this.setDisabled(!1,!0)}
477this.setFill()}
478setSelected(){this.mapsvg.selectRegion(this)}
479setchoroplethValue(val){if($$7.isNumeric(val)){if(typeof val==="string"){val=parseFloat(val)}
480this.choroplethValue=val}else{this.choroplethValue=undefined}}
481getDisabledState(asDefault){const opts=this.mapsvg.options.regions[this.id];if(!asDefault&&opts&&opts.disabled!==undefined){return opts.disabled}else{return(this.mapsvg.options.disableAll||this.style.fill==="none"||this.id=="labels"||this.id=="Labels")}}
482highlight(){$$7(this.element).css({fill:this.hover_attr.fill});$$7(this.element).addClass("mapsvg-region-hover")}
483unhighlight(){$$7(this.element).css({fill:this.default_attr.fill});$$7(this.element).removeClass("mapsvg-region-hover")}
484select(){$$7(this.element).css({fill:this.selected_attr.fill});this.selected=!0;$$7(this.element).addClass("mapsvg-region-active")}
485deselect(){$$7(this.element).css({fill:this.default_attr.fill});this.selected=!1;$$7(this.element).removeClass("mapsvg-region-active")}
486setData(data){this.data=data;if(typeof data.title!=="undefined"){this.setTitle(data.title)}}
487drawBubble(){if(this.data){const bubbleId="mapsvg-bubble-"+this.id;const bubbleValue=parseFloat(this.data[this.mapsvg.options.choropleth.sourceField]);if(bubbleValue){if(!this.center){this.center=this.getCenterSVG()}
488const pos=this.mapsvg.converter.convertSVGToPixel(this.center);if(!this.bubble){this.bubble=$$7('<div id="'+bubbleId+'" class="mapsvg-bubble mapsvg-region-bubble"></div>')[0];$$7(this.mapsvg.layers.bubbles).append(this.bubble)}
489const color=this.getChoroplethColor();const bubbleSize=Number(this.getBubbleSize());$$7(this.bubble).css("transform","translate(-50%,-50%) translate("+pos.x+"px,"+pos.y+"px)").css("background-color",color).css("width",bubbleSize+"px").css("height",bubbleSize+"px").css("lineHeight",bubbleSize-2+"px")}else{delete this.bubble}}}
490adjustLabelScreenPosition(){if(this.label){if(!this.center){this.center=this.getCenterSVG()}
491const pos=this.mapsvg.converter.convertSVGToPixel(this.center),x=pos.x-this.label.offsetWidth/2,y=pos.y-this.label.offsetHeight/2;this.setLabelScreenPosition(x,y)}}
492adjustBubbleScreenPosition(){if(this.bubble){if(!this.center){this.center=this.getCenterSVG()}
493const pos=this.mapsvg.converter.convertSVGToPixel(this.center),x=pos.x-this.bubble.offsetWidth/2,y=pos.y-this.bubble.offsetHeight/2;this.setBubbleScreenPosition(x,y)}}
494moveLabelScreenPositionBy(deltaX,deltaY){if(this.label){const labelStyle=window.getComputedStyle(this.label),matrix=labelStyle.transform||labelStyle.webkitTransform,matrixValues=matrix.match(/matrix.*\((.+)\)/)[1].split(", "),x=parseFloat(matrixValues[4])-deltaX,y=parseFloat(matrixValues[5])-deltaY;this.setLabelScreenPosition(x,y)}}
495moveBubbleScreenPositionBy(deltaX,deltaY){if(this.bubble){const labelStyle=window.getComputedStyle(this.bubble),matrix=labelStyle.transform||labelStyle.webkitTransform,matrixValues=matrix.match(/matrix.*\((.+)\)/)[1].split(", "),x=parseFloat(matrixValues[4])-deltaX,y=parseFloat(matrixValues[5])-deltaY;this.setBubbleScreenPosition(x,y)}}
496setLabelScreenPosition(x,y){if(this.label){this.label.style.transform="translate("+x+"px,"+y+"px)"}}
497setBubbleScreenPosition(x,y){if(this.bubble){this.bubble.style.transform="translate("+x+"px,"+y+"px)"}}}
498class SchemaRepository extends Repository{constructor(){const objectName="schema";super(objectName,+objectName+"s");this.className="Schema";this.objectNameSingle=objectName;this.objectNameMany=objectName+"s";this.path=objectName+"s/";this.events=new Events(this)}
499create(schema){const defer=jQuery.Deferred();defer.promise();const data={};data[this.objectNameSingle]=this.encodeData(schema);this.server.post(this.path,data).done((response)=>{const data=this.decodeData(response);schema.id=data[this.objectNameSingle].id;this.objects.push(schema);this.events.trigger("created");schema.events.trigger("created");defer.resolve(schema)}).fail(()=>{defer.reject()});return defer}
500update(schema){const defer=jQuery.Deferred();defer.promise();const data={};data[this.objectNameSingle]=this.encodeData(schema);this.server.put(this.path+schema.id,data).done((response)=>{const data=this.decodeData(response);this.objects.push(schema);defer.resolve(schema);this.events.trigger("changed");schema.events.trigger("changed")}).fail(()=>{defer.reject()});return defer}
501encodeData(schema){const _schema=schema.getData();let fieldsJsonString=JSON.stringify(_schema);fieldsJsonString=fieldsJsonString.replace(/select/g,"!mapsvg-encoded-slct");fieldsJsonString=fieldsJsonString.replace(/table/g,"!mapsvg-encoded-tbl");fieldsJsonString=fieldsJsonString.replace(/database/g,"!mapsvg-encoded-db");fieldsJsonString=fieldsJsonString.replace(/varchar/g,"!mapsvg-encoded-vc");fieldsJsonString=fieldsJsonString.replace(/int\(11\)/g,"!mapsvg-encoded-int");const back=JSON.parse(fieldsJsonString);back.fields=JSON.stringify(_schema.fields);return back}}
502const $$8=jQuery;class Controller{constructor(options){this.containers={main:options.container,};this.mapsvg=options.mapsvg;this.template=options.template||"";this.scrollable=options.scrollable===undefined?!0:options.scrollable;this.withToolbar=options.withToolbar===undefined?!0:options.withToolbar;this.autoresize=MapSVG.parseBoolean(options.autoresize);this.templates={toolbar:Handlebars.compile(this.getToolbarTemplate()),main:Handlebars.compile(this.getMainTemplate()),};this.data=options.data;this.width=options.width;this.color=options.color;this.events=new Events(this);if(options.events){for(const eventName in options.events){if(typeof options.events[eventName]==="function"){this.events.on(eventName,options.events[eventName])}}}}
503viewDidLoad(){const _this=this;_this.updateScroll();if(this.autoresize){_this.adjustHeight();this.resizeSensor.setScroll()}}
504_viewDidLoad(){this.updateScroll()}
505viewDidAppear(){}
506viewDidDisappear(){}
507updateScroll(){if(!this.scrollable)
508return;const _this=this;$$8(this.containers.contentWrap).nanoScroller({preventPageScrolling:!0,});setTimeout(function(){$$8(_this.containers.contentWrap).nanoScroller({preventPageScrolling:!0,})},300)}
509adjustHeight(){const _this=this;$$8(_this.containers.main).height($$8(_this.containers.main).find(".mapsvg-auto-height").outerHeight()+(_this.containers.toolbar?$$8(_this.containers.toolbar).outerHeight():0))}
510_init(){const _this=this;_this.render();_this.init()}
511init(){}
512getToolbarTemplate(){return""}
513setMainTemplate(template){return(this.templates.main=Handlebars.compile(template))}
514getMainTemplate(){return this.template}
515render(){const _this=this;this.containers.view=$$8("<div />").attr("id","mapsvg-controller-"+this.name).addClass("mapsvg-controller-view")[0];
515this.containers.contentWrap=$$8("<div />").addClass("mapsvg-controller-view-wrap")[0];this.containers.contentWrap2=$$8("<div />")[0];this.containers.sizer=$$8("<div />").addClass("mapsvg-auto-height")[0];this.containers.contentView=$$8("<div />").addClass("mapsvg-controller-view-content")[0];this.containers.sizer.appendChild(this.containers.contentView);if(this.scrollable){$$8(this.containers.contentWrap).addClass("nano");$$8(this.containers.contentWrap2).addClass("nano-content")}
516this.containers.contentWrap.appendChild(this.containers.contentWrap2);this.containers.contentWrap2.appendChild(this.containers.sizer);if(this.withToolbar&&this.templates.toolbar){this.containers.toolbar=$$8("<div />").addClass("mapsvg-controller-view-toolbar")[0];this.containers.view.appendChild(this.containers.toolbar)}
517this.containers.view.append(this.containers.contentWrap);this.containers.main.appendChild(this.containers.view);$$8(this.containers.main).data("controller",this);if(this.width)
518this.containers.view.style.width=this.width;if(this.color)
519this.containers.view.style["background-color"]=this.color;_this.viewReadyToFill();this.redraw();setTimeout(function(){_this._viewDidLoad();_this.viewDidLoad();_this.setEventHandlersCommon();_this.setEventHandlers()},1)}
520viewReadyToFill(){const _this=this;if(_this.autoresize){_this.resizeSensor=new ResizeSensor(this.containers.sizer,()=>{_this.adjustHeight();_this.updateScroll();_this.events.trigger("resize",this,[this])})}}
521redraw(data){if(data!==undefined){this.data=data}
522try{$$8(this.containers.contentView).html(this.templates.main(this.data))}catch(err){console.error(err);$$8(this.containers.contentView).html("")}
523if(this.withToolbar&&this.templates.toolbar)
524$$8(this.containers.toolbar).html(this.templates.toolbar(this.data));this.updateTopShift();if(this.noPadding)
525this.containers.contentView.style.padding="0";this.updateScroll()}
526updateTopShift(){const _this=this;if(!this.withToolbar)
527return;$$8(_this.containers.contentWrap).css({top:$$8(_this.containers.toolbar).outerHeight(!0)+"px",});setTimeout(function(){$$8(_this.containers.contentWrap).css({top:$$8(_this.containers.toolbar).outerHeight(!0)+"px",})},100);setTimeout(function(){$$8(_this.containers.contentWrap).css({top:$$8(_this.containers.toolbar).outerHeight(!0)+"px",})},200);setTimeout(function(){$$8(_this.containers.contentWrap).css({top:$$8(_this.containers.toolbar).outerHeight(!0)+"px",});_this.updateScroll()},500)}
528setEventHandlersCommon(){}
529setEventHandlers(){}
530destroy(){delete this.resizeSensor;$$8(this.containers.view).empty().remove()}}
531const $$9=jQuery;class DirectoryController extends Controller{constructor(options){super(options);this.repository=options.repository;this.noPadding=!0;this.position=options.position;this.search=options.search}
532getToolbarTemplate(){let t='<div class="mapsvg-directory-search-wrap">';t+='<div class="mapsvg-directory-filter-wrap filter-wrap"></div>';t+="</div>";t+="</div>";return t}
533viewDidLoad(){const _this=this;this.menuBtn=$$9('<div class="mapsvg-button-menu"><i class="mapsvg-icon-menu"></i> '+this.mapsvg.options.mobileView.labelList+"</div>")[0];this.mapBtn=$$9('<div class="mapsvg-button-map"><i class="mapsvg-icon-map"></i> '+this.mapsvg.options.mobileView.labelMap+"</div>")[0];if(MapSVG.isPhone&&_this.mapsvg.options.menu.hideOnMobile){if(this.mapsvg.options.menu.showFirst=="map"){this.toggle(!1)}else{this.toggle(!0)}}
534this.mobileButtons=$$9('<div class="mapsvg-mobile-buttons"></div>')[0];this.mobileButtons.append(this.menuBtn,this.mapBtn);if(this.mapsvg.options.menu.on!==!1){this.mapsvg.containers.wrapAll.appendChild(this.mobileButtons)}
535this.events.trigger("shown",this.containers.view)}
536setEventHandlers(){const _this=this;$$9(window).on("resize",function(){_this.updateTopShift()});$$9(this.menuBtn).on("click",function(){_this.toggle(!0)});$$9(this.mapBtn).on("click",function(){_this.toggle(!1);_this.mapsvg.redraw()});$$9(this.containers.view).on("click.menu.mapsvg",".mapsvg-directory-item",function(e){if(e.target.nodeName=="A"){return}
537const objID=$$9(this).data("object-id");let regions;let marker;let detailsViewObject;let eventObject;_this.deselectItems();_this.selectItems(objID,!1);
537if(MapSVG.isPhone&&_this.mapsvg.options.menu.showMapOnClick){_this.toggle(!1)}
538if(_this.mapsvg.options.menu.source=="regions"){regions=[_this.mapsvg.getRegion(objID)];eventObject=regions[0];detailsViewObject=regions[0]}else{detailsViewObject=_this.repository.getLoadedObject(objID);eventObject=detailsViewObject;const _regions=detailsViewObject.getRegions(_this.mapsvg.regionsRepository.schema.name);if(_regions){regions=_regions.map(function(region){return _this.mapsvg.getRegion(region.id)}).filter(function(r){return r!==undefined})}}
539if(detailsViewObject.location&&detailsViewObject.location.marker)
540marker=detailsViewObject.location.marker;if(_this.mapsvg.options.actions.directoryItem.click.showDetails){_this.mapsvg.loadDetailsView(detailsViewObject)}
541if(regions&&regions.length>0){if(_this.mapsvg.options.actions.directoryItem.click.zoom){_this.mapsvg.zoomTo(regions,_this.mapsvg.options.actions.directoryItem.click.zoomToLevel)}
542if(regions.length>1){_this.mapsvg.setMultiSelect(!0)}
543regions.forEach(function(region){const center=region.getCenter();e.clientX=center[0];e.clientY=center[1];if(_this.mapsvg.options.actions.directoryItem.click.selectRegion){_this.mapsvg.selectRegion(region,!0)}
544if(_this.mapsvg.options.actions.directoryItem.click.showRegionPopover){if(_this.mapsvg.options.actions.directoryItem.click.zoom){setTimeout(function(){_this.mapsvg.showPopover(region)},500)}else{_this.mapsvg.showPopover(region)}}
545if(_this.mapsvg.options.actions.directoryItem.click.fireRegionOnClick){_this.mapsvg.events.trigger("click.region",region,[region])}});if(regions.length>1){_this.mapsvg.setMultiSelect(!1,!1)}}
546if(marker){if(_this.mapsvg.options.actions.directoryItem.click.zoomToMarker){_this.mapsvg.zoomTo(marker,_this.mapsvg.options.actions.directoryItem.click.zoomToMarkerLevel)}
547if(_this.mapsvg.options.actions.directoryItem.click.showMarkerPopover){if(_this.mapsvg.options.actions.directoryItem.click.zoomToMarker){setTimeout(function(){_this.mapsvg.showPopover(detailsViewObject)},500)}else{_this.mapsvg.showPopover(detailsViewObject)}}
548if(_this.mapsvg.options.actions.directoryItem.click.fireMarkerOnClick){_this.mapsvg.events.trigger("click.marker",marker,[e,_this.mapsvg])}
549_this.mapsvg.selectMarker(marker)}
550_this.events.trigger("click",this,[e,eventObject,_this.mapsvg]);const actions=_this.mapsvg.options.actions;if(actions.directoryItem.click.goToLink){const linkParts=actions.directoryItem.click.linkField.split(".");let url;if(linkParts.length>1){const obj=linkParts.shift();const attr="."+linkParts.join(".");if(obj=="Region"){if(regions[0]&&regions[0].data)
551url=eval("regions[0].data"+attr)}else{if(detailsViewObject)
552url=eval("detailsViewObject"+attr)}
553if(url){if(actions.directoryItem.click.newTab){const win=window.open(url,"_blank");win.focus()}else{window.location.href=url}}}}
554if(actions.directoryItem.click.showAnotherMap){if(_this.mapsvg.editMode){alert('"Show another map" action is disabled in the preview');return!0}
555const linkParts2=actions.directoryItem.click.showAnotherMapField.split(".");if(linkParts2.length>1){const obj2=linkParts2.shift();const attr2="."+linkParts2.join(".");let map_id;if(obj2=="Region"){if(regions[0]&&regions[0].data)
556map_id=eval("regions[0].data"+attr2)}else{if(detailsViewObject)
557map_id=eval("detailsViewObject"+attr2)}
558if(map_id){const container=actions.directoryItem.click.showAnotherMapContainerId?$$9("#"+actions.directoryItem.click.showAnotherMapContainerId)[0]:$$9(_this.mapsvg.containers.map)[0];_this.mapsvg.loadMap(map_id,container)}}}}).on("mouseover.menu.mapsvg",".mapsvg-directory-item",function(e){const objID=$$9(this).data("object-id");let regions;let detailsViewObject;let eventObject;let marker;if(_this.mapsvg.options.menu.source=="regions"){regions=[_this.mapsvg.getRegion(objID)];eventObject=regions[0];detailsViewObject=regions[0]}else{detailsViewObject=_this.repository.getLoadedObject(objID);eventObject=detailsViewObject;const _regions=detailsViewObject.getRegions(_this.mapsvg.regionsRepository.schema.name);if(_regions){regions=_regions.map(function(region){return _this.mapsvg.getRegion(region.id)})}
559if(detailsViewObject.location){marker=detailsViewObject.location.marker}}
560if(regions&&regions.length){_this.mapsvg.highlightRegions(regions)}
561if(marker){_this.mapsvg.highlightMarker(marker);if(_this.mapsvg.options.actions.directoryItem.hover.centerOnMarker){_this.mapsvg.centerOn(marker)}}
562_this.events.trigger("mouseover",$$9(this),[e,eventObject,_this.mapsvg])}).on("mouseout.menu.mapsvg",".mapsvg-directory-item",function(e){const objID=$$9(this).data("object-id");let regions;let detailsViewObject;let eventObject;let marker;if(_this.mapsvg.options.menu.source=="regions"){regions=[_this.mapsvg.getRegion(objID)];eventObject=regions[0];detailsViewObject=regions[0]}else{detailsViewObject=_this.repository.getLoadedObject(objID);eventObject=detailsViewObject;
562const _regions=detailsViewObject.getRegions(_this.mapsvg.regionsRepository.schema.name);if(_regions){regions=_regions.map(function(region){return _this.mapsvg.getRegion(region.id)})}
563if(detailsViewObject.location){marker=detailsViewObject.location.marker}}
564if(regions&&regions.length){_this.mapsvg.unhighlightRegions()}
565if(marker){_this.mapsvg.unhighlightMarker()}
566_this.events.trigger("mouseout",$$9(this),[e,eventObject,_this.mapsvg])});$$9(this.containers.contentView).on("click",".mapsvg-category-item",function(){const panel=$$9(this).next(".mapsvg-category-block");if(panel[0].style.maxHeight||panel.hasClass("active")){panel[0].style.maxHeight=null}else{panel[0].style.maxHeight=panel[0].scrollHeight+"px"}
567if($$9(this).hasClass("active")){$$9(this).toggleClass("active",!1);$$9(this).next(".mapsvg-category-block").addClass("collapsed").removeClass("active")}else{if(_this.mapsvg.options.menu.categories.collapseOther){$$9(this).parent().find(".mapsvg-category-item.active").removeClass("active");$$9(this).parent().find(".mapsvg-category-block.active").removeClass("active").addClass("collapsed")}
568$$9(this).toggleClass("active",!0);$$9(this).next(".mapsvg-category-block").removeClass("collapsed").addClass("active")}
569const panels=$$9(".mapsvg-category-block.collapsed");panels.each(function(i,panel){panel.style.maxHeight=null})})}
570highlightItems(ids){const _this=this;if(typeof ids!="object")
571ids=[ids];ids.forEach(function(id){$$9(_this.containers.view).find("#mapsvg-directory-item-"+_this.convertId(id)).addClass("hover")})}
572unhighlightItems(){$$9(this.containers.view).find(".mapsvg-directory-item").removeClass("hover")}
573selectItems(ids,scrollTo=!0){if(typeof ids!="object")
574ids=[ids];ids.forEach((id)=>{$$9(this.containers.view).find("#mapsvg-directory-item-"+this.convertId(id)).addClass("selected")});if(scrollTo&&$$9("#mapsvg-directory-item-"+ids[0]).length>0){this.scrollable&&$$9(this.containers.contentWrap).nanoScroller({scrollTo:$$9(this.containers.view).find("#mapsvg-directory-item-"+this.convertId(ids[0])),})}}
575deselectItems(){$$9(this.containers.view).find(".mapsvg-directory-item").removeClass("selected")}
576removeItems(ids){$$9(this.containers.view).find("#mapsvg-directory-item-"+this.convertId(ids)).remove()}
577filterOut(items){const _this=this;if(this.repository.path.indexOf("regions")!==-1){let f;f={field:"",val:"",};if(_this.mapsvg.options.menu.filterout.field){f.field=_this.mapsvg.options.menu.filterout.field;f.val=_this.mapsvg.options.menu.filterout.val}
578items=items.filter(function(item){let ok=!0;const status=_this.mapsvg.options.regionStatuses;if(status[item.status]){ok=!status[item.status].disabled}
579if(ok&&f.field){ok=item[f.field]!=f.val}
580return ok})}
581return items}
582loadItemsToDirectory(){let items=[];const _this=this;if(!_this.repository.loaded)
583return!1;if(_this.mapsvg.options.menu.categories&&_this.mapsvg.options.menu.categories.on&&_this.mapsvg.options.menu.categories.groupBy){const categoryField=_this.mapsvg.options.menu.categories.groupBy;if(_this.repository.getSchema().getField(categoryField)===undefined||_this.repository.getSchema().getField(categoryField).options===undefined){return!1}
584const categories=_this.repository.getSchema().getField(categoryField).options;categories.forEach(function(category){let dbItems=_this.repository.getLoaded();dbItems=_this.filterOut(dbItems);const itemArr=[];dbItems.forEach((item)=>{itemArr.push(item)});const catItems=itemArr.filter(function(object){if(categoryField==="regions"){const objectRegions=typeof object[categoryField]!=="undefined"&&object[categoryField].length?object[categoryField]:[];const objectRegionIDs=objectRegions.map(function(region){return region.id});return objectRegionIDs.indexOf(category.id)!==-1}else{return object[categoryField]==category.value}});category.counter=catItems.length;if(categoryField==="regions"){category.label=category.title;category.value=category.id}
585catItems.sort(function(a,b){const field=_this.mapsvg.options.menu.sortBy;return a[field]==b[field]?0:(_this.mapsvg.options.menu.sortDirection==="asc"?+(a[field]>[field]):+(a[field]<[field]))||-1});items.push({category:category,items:catItems})});if(_this.mapsvg.options.menu.categories.hideEmpty){items=items.filter(function(item){return item.category.counter>0})}}else{if(_this.mapsvg.options.menu.source==="regions"){items=_this.repository.getLoaded().map((r)=>{const data=r.getData();data.objects=_this.mapsvg.getRegion(data.id).objects;data.id_no_spaces=data.id.split(" ").join("_");return data});items=_this.filterOut(items)}else{items=_this.repository.getLoaded().map((r)=>r.getData(_this.mapsvg.regionsRepository.schema.name))}}
586try{$$9(this.containers.contentView).html(this.templates.main({items:items}))}catch(err){console.error('MapSVG: Error in the "Directory item" template');console.error(err)}
587if(items.length===0){$$9(this.containers.contentView).html('<div class="mapsvg-no-results">'+this.mapsvg.options.menu.noResultsText+"</div>")}
588if(_this.mapsvg.options.menu.categories.on){if(_this.mapsvg.options.menu.categories.collapse&&items.length>1){$$9(this.containers.contentView).find(".mapsvg-category-block").addClass("collapsed")}else if(_this.mapsvg.options.menu.categories.collapse&&items.length===1){$$9(this.containers.contentView).find(".mapsvg-category-item").addClass("active");$$9(this.containers.contentView).find(".mapsvg-category-block").addClass("active");const panel=$$9(this.containers.contentView).find(".mapsvg-category-block")[0];if(panel)
589panel.style.maxHeight=panel.scrollHeight+"px"}else if(!_this.mapsvg.options.menu.categories.collapse){$$9(this.containers.contentView).find(".mapsvg-category-item").addClass("active");$$9(this.containers.contentView).find(".mapsvg-category-block").addClass("active");const panels=$$9(this.containers.contentView).find(".mapsvg-category-block");if(panels.length)
590panels.each(function(i,panel){panel.style.maxHeight=panel.scrollHeight+"px"})}}
591this.updateTopShift();this.updateScroll()}
592toggle(on){const _this=this;if(on){$$9(this.containers.main).parent().show();$$9(_this.mapsvg.containers.mapContainer).hide();$$9(this.menuBtn).addClass("active");$$9(this.mapBtn).removeClass("active")}else{$$9(this.containers.main).parent().hide();$$9(_this.mapsvg.containers.mapContainer).show();$$9(this.menuBtn).removeClass("active");$$9(this.mapBtn).addClass("active")}
593if(!$$9(this.containers.main).parent().is(":visible")){if(MapSVG.isPhone){$$9(_this.mapsvg.containers.wrap).css("height","auto");_this.updateScroll()}}else{if(MapSVG.isPhone&&$$9(this.containers.main).height()<parseInt(this.mapsvg.options.menu.minHeight)){$$9(_this.mapsvg.containers.wrap).css("height",parseInt(this.mapsvg.options.menu.minHeight)+"px");_this.updateScroll()}}
594this.updateTopShift()}
595addPagination(pager){$$9(this.containers.contentView).append('<div class="mapsvg-pagination-container"></div>');$$9(this.containers.contentView).find(".mapsvg-pagination-container").html(pager)}
596convertId(id){return(id+"").split(" ").join("_").replace(/(:|\(|\)|\.|\[|\]|,|=|@)/g,"\\$1")}}
597const $$a=jQuery;class DetailsController extends Controller{constructor(options){super(options);this.modal=options.modal}
598getToolbarTemplate(){if(this.withToolbar)
599return'<div class="mapsvg-popover-close mapsvg-details-close"></div>';else return""}
600viewDidLoad(){const _this=this;this.events.trigger("shown",_this,[_this]);if(this.modal&&MapSVG.isPhone&&this.mapsvg.options.detailsView.mobileFullscreen&&!this.mobileCloseBtn){this.mobileCloseBtn=$$a('<button class="mapsvg-mobile-modal-close">'+_this.mapsvg.options.mobileView.labelClose+"</button>")[0];this.containers.view.appendChild(this.mobileCloseBtn)}}
601setEventHandlers(){const _this=this;$$a(this.containers.toolbar).on("click touchend",".mapsvg-popover-close",function(e){e.stopPropagation();_this.destroy();_this.events.trigger("closed",_this,[_this])});$$a(this.containers.view).on("click touchend",".mapsvg-mobile-modal-close",function(e){e.stopPropagation();_this.destroy();_this.events.trigger("closed",_this,[_this])})}}
602const $$b=jQuery;class FormElement{constructor(options,formBuilder,external){this.readonly=typeof options.readonly!=="undefined"?options.readonly:!1;this.protected=typeof options.protected!=="undefined"?options.protected:!1;this.auto_increment=typeof options.auto_increment!=="undefined"?options.auto_increment:!1;this.not_null=typeof options.not_null!=="undefined"?options.not_null:!1;this.searchable=typeof options.searchable!=="undefined"?options.searchable:!1;this.visible=typeof options.visible!=="undefined"?options.visible:!0;this.formBuilder=formBuilder;this.events=new Events(this);this.type=options.type;this.value=options.value;this.db_type=options.db_type||"varchar(255)";this.label=this.label||(options.label===undefined?"Label":options.label);this.name=this.name||options.name||"label";this.help=options.help||"";this.placeholder=options.placeholder;this.setExternal(external);let t=this.type;if(t==="marker"&&this.mapIsGeo){t="marker-geo"}
603if(t==="location"&&this.mapIsGeo){t="location-geo"}
604if(this.filtersMode){this.parameterName=options.parameterName||"";this.parameterNameShort=this.parameterName.split(".")[1];this.name=this.parameterNameShort;this.placeholder=options.placeholder||"";this.templates={main:Handlebars.compile($$b("#mapsvg-filters-tmpl-"+t+"-view").html()),}}else{this.templates={main:Handlebars.compile($$b("#mapsvg-data-tmpl-"+t+"-view").html()),}}
605this.inputs={}}
606init(){this.setDomElements();this.setEventHandlers()}
607setDomElements(){this.domElements={main:$$b(this.templates.main(this.getDataForTemplate()))[0],};$$b(this.domElements.main).data("formElement",this);this.addSelect2()}
608setEventHandlers(){const _this=this;if(this.formBuilder.editMode){$$b(this.domElements.main).on("click",function(){_this.events.trigger("click",_this,[_this])})}}
609addSelect2(){if($$b().mselect2){$$b(this.domElements.main).find("select").css({width:"100%",display:"block"}).mselect2().on("select2:focus",function(){$$b(this).mselect2("open")});$$b(this.domElements.main).find(".select2-selection--multiple .select2-search__field").css("width","100%")}}
610setEditorEventHandlers(){const _this=this;$$b(this.domElements.edit).on("click","button.mapsvg-remove",function(){$$b(_this.domElements.main).empty().remove();$$b(_this.domElements.edit).empty().remove();_this.events.trigger("delete",_this,[_this])});$$b(this.domElements.edit).on("click",".mapsvg-filter-insert-options",function(){const objType=_this.parameterName.split(".")[0];const fieldName=_this.parameterName.split(".")[1];let field;if(objType=="Object"){field=_this.formBuilder.mapsvg.objectsRepository.getSchema().getField(fieldName)}else{if(fieldName=="id"){const options=[];_this.formBuilder.mapsvg.regions.forEach(function(r){options.push({label:r.id,value:r.id})});field={options:options,}}else if(fieldName==="title"){const options=[];_this.formBuilder.mapsvg.regions.forEach(function(r){options.push({label:r.title,value:r.title})});field={options:options}}else{field=_this.formBuilder.mapsvg.regionsRepository.getSchema().getField(fieldName)}}
611if((field&&field.options)||fieldName==="regions"){let options;if(fieldName=="regions"){const _options=_this.formBuilder.mapsvg.regions.map((r)=>{return{id:r.id,title:r.title}}
611);_options.sort(function(a,b){if(a.title<b.title)
612return-1;if(a.title>b.title)
613return 1;return 0});options=_options.map(function(o){return(o.title||o.id)+":"+o.id})}else{options=field.options.map(function(o){return o.label+":"+o.value})}
614$$b(this).closest(".form-group").find("textarea").val(options.join("\n")).trigger("change")}});$$b(this.domElements.edit).on("keyup change paste","input, textarea, select",function(){const prop=$$b(this).attr("name");const array=$$b(this).data("array");if(_this.type==="status"&&array){const param=$$b(this).data("param");const index=$$b(this).closest("tr").index();_this.options[index]=_this.options[index]||{label:"",value:"",color:"",disabled:!1,};_this.options[index][param]=$$b(this).is(":checkbox")?$$b(this).prop("checked"):$$b(this).val();_this.redraw()}else if(_this.type==="distance"&&array){const param=$$b(this).data("param");const index=$$b(this).closest("tr").index();if(!_this.options[index]){_this.options[index]={value:"",default:!1}}
615if(param==="default"){_this.options.forEach(function(option){option.default=!1});_this.options[index].default=$$b(this).prop("checked")}else{_this.options[index].value=$$b(this).val()}
616_this.redraw()}else if(prop=="label"||prop=="name"){return!1}else{let value;value=$$b(this).attr("type")=="checkbox"?$$b(this).prop("checked"):$$b(this).val();if($$b(this).attr("type")=="radio"){const name=$$b(this).attr("name");value=$$b('input[name="'+name+'"]:checked').val()}
617_this.update(prop,value)}});$$b(this.domElements.edit).on("keyup change paste",'input[name="label"]',function(){if(!_this.nameChanged){_this.label=$$b(this).val()+"";if(_this.type!="region"&&_this.type!="location"&&_this.type!="title"){let str=$$b(this).val()+"";str=str.toLowerCase().replace(/ /g,"_").replace(/\W/g,"");if(str.length<64){$$b(_this.domElements.edit).find('input[name="name"]').val(str)}
618_this.name=str+""}
619$$b(_this.domElements.main).find("label").first().html(_this.label);if(!_this.filtersMode){$$b(_this.domElements.main).find("label").first().append('<div class="field-name">'+_this.name+"</div>")}}});$$b(this.domElements.edit).on("keyup change paste",'input[name="name"]',function(e){if(e.target.value){if(e.target.value.match(/[^a-zA-Z0-9_]/g)){e.target.value=e.target.value.replace(/[^a-zA-Z0-9_]/g,"");$$b(e.target).trigger("change")}
620if(e.target.value[0].match(/[^a-zA-Z_]/g)){e.target.value=e.target.value[0].replace(/[^a-zA-Z_]/g,"")+e.target.value.slice(1);$$b(e.target).trigger("change")}}
621if(_this.type!="region")
622_this.name=e.target.value;$$b(_this.domElements.main).find("label").html(_this.label+'<div class="field-name">'+_this.name+"</div>");_this.nameChanged=!0});$$b(this.domElements.edit).on("keyup change paste",'textarea[name="help"]',function(e){$$b(_this.domElements.main).find(".form-text").text(e.target.value)})}
623getEditor(){if(!this.filtersMode){this.templates.edit=this.templates.edit||Handlebars.compile($$b("#mapsvg-data-tmpl-"+this.type+"-control").html())}else{this.templates.edit=this.templates.edit||Handlebars.compile($$b("#mapsvg-filters-tmpl-"+this.type+"-control").html())}
624this.domElements.edit=$$b("<div>"+this.templates.edit(this.getDataForTemplate())+"</div>")[0];return this.domElements.edit}
625destroyEditor(){$$b(this.domElements.edit).empty().remove()}
626initEditor(){$$b(this.domElements.edit).find("input").first().select();if($$b().colorpicker){$$b(this.domElements.edit).find(".cpicker").colorpicker().on("changeColor.colorpicker",function(event){const input=$$b(this).find("input");if(input.val()=="")
627$$b(this).find("i").css({"background-color":""})})}
628if($$b().mselect2){if(this.type!=="distance"){$$b(this.domElements.edit).find("select").css({width:"100%",display:"block"}).mselect2()}}
629this.setEditorEventHandlers()}
630getSchema(){let data;data={type:this.type,db_type:this.db_type,label:this.label,name:this.name,value:this.value,searchable:this.searchable,help:this.help,visible:this.visible===undefined?!0:this.visible,readonly:this.readonly,placeholder:this.placeholder,protected:this.protected,auto_increment:this.auto_increment,not_null:this.not_null,};if(this.options){data.options=this.getSchemaFieldOptionsList()}
631if(this.filtersMode){data.parameterName=this.parameterName;data.parameterNameShort=this.parameterName.split(".")[1]}
632return data}
633getSchemaFieldOptionsList(){const options=[];this.options.forEach((option,index)=>{if(this.options[index].value!==""){options.push(this.options[index])}});return options}
634getDataForTemplate(){const data=this.getSchema();data._name=data.name;if(this.namespace){data.name=this.name.split("[")[0];let suffix=this.name.split("[")[1]||"";if(suffix)
635suffix="["+suffix;data.name=this.namespace+"["+data.name+"]"+suffix}
636data.external=this.external;return data}
637update(prop,value){const _this=this;if(prop=="options"){const options=[];value=value.split("\n").forEach(function(row){row=row.trim().split(":");if(_this.type=="checkbox"&&row.length==3){options.push({label:row[0],name:row[1],value:row[2],})}else if((_this.type=="radio"||_this.type=="select"||_this.type=="checkboxes")&&row.length==2){options.push({label:row[0],value:row[1],})}});this.options=options}else{this[prop]=value}
638if(prop=="parameterName"){$$b(this.domElements.edit).find(".mapsvg-filter-param-name").text(value)}}
639redraw(){const newView=$$b(this.templates.main(this.getDataForTemplate()));$$b(this.domElements.main).html(newView.html());
639if($$b().mselect2){if(this.type!=="distance"){$$b(this.domElements.main).find("select").css({width:"100%",display:"block"}).mselect2().on("select2:focus",function(){$$b(this).mselect2("open")})}else{$$b(this.domElements.main).find("select").mselect2().on("select2:focus",function(){$$b(this).mselect2("open")})}}}
640redrawEditor(){if(this.domElements.edit){$$b(this.domElements.edit).empty();$$b(this.domElements.edit).html("<div>"+this.templates.edit(this.getDataForTemplate())+"</div>");this.initEditor()}}
641setOptions(options){if(options){this.options=[];this.optionsDict={};options.forEach((value,key)=>{this.options.push(value);this.optionsDict[key]=value});return this.options}else{return this.setOptions([{label:"Option one",name:"option_one",value:1},{label:"Option two",name:"option_two",value:2},])}}
642getData(){return{name:this.name,value:this.getValue()}}
643destroy(){if($$b().mselect2){const sel=$$b(this.domElements.main).find(".mapsvg-select2");if(sel.length){sel.mselect2("destroy")}}}
644show(){$$b(this.domElements.main).show()}
645hide(){$$b(this.domElements.main).hide()}
646setExternal(params){this.external=params;if(typeof this.external.mapIsGeo!=="undefined"){this.mapIsGeo=this.external.mapIsGeo}
647if(typeof this.external.editMode!=="undefined"){this.editMode=this.external.editMode}
648if(typeof this.external.filtersMode!=="undefined"){this.filtersMode=this.external.filtersMode}
649if(typeof this.external.namespace!=="undefined"){this.namespace=this.external.namespace}}
650getValue(){return this.value}
651setValue(value,updateInput=!0){this.value=value;if(updateInput){this.setInputValue(value)}}
652setInputValue(value){return}
653triggerChanged(){this.events.trigger("changed",this,[this])}}
654const $$c=jQuery;class CheckboxFormElement extends FormElement{constructor(options,formBuilder,external){super(options,formBuilder,external);if(typeof options.showAsSwitch==="undefined"){this.showAsSwitch=!0}else{this.showAsSwitch=options.showAsSwitch}
655this.db_type="tinyint(1)";this.checkboxLabel=options.checkboxLabel;this.checkboxValue=options.checkboxValue}
656setDomElements(){super.setDomElements();this.inputs.checkbox=$$c(this.domElements.main).find("input")[0];this.inputs.switch=$$c(this.domElements.main).find("input")[0]}
657setEventHandlers(){super.setEventHandlers();$$c(this.inputs.checkbox).on("change",(e)=>{this.setValue(e.target.checked,!1);this.triggerChanged()})}
658setEditorEventHandlers(){super.setEditorEventHandlers();$$c(this.domElements.edit).on("change","[name='showAsSwitch']",(e)=>{if(this.showAsSwitch){$$c(this.domElements.main).find("[name='checkboxToSwitch']").addClass("form-switch form-switch-md")}
659if(!this.showAsSwitch){$$c(this.domElements.main).find("[name='checkboxToSwitch']").removeClass("form-switch form-switch-md")}});$$c(this.domElements.edit).on("keyup change paste",'[name="checkboxLabel"]',(e)=>{$$c(this.domElements.main).find(".form-check-label").text(e.target.value)})}
660getSchema(){const schema=super.getSchema();if(this.checkboxLabel){schema.checkboxLabel=this.checkboxLabel}
661if(this.checkboxValue){schema.checkboxValue=this.checkboxValue}
662schema.showAsSwitch=this.showAsSwitch;return schema}
663setInputValue(value){this.inputs.checkbox.checked=value===!0}}
664const $$d=jQuery;class CheckboxesFormElement extends FormElement{constructor(options,formBuilder,external){super(options,formBuilder,external);this.db_type="text";this.checkboxLabel=options.checkboxLabel;this.setOptions(options.options)}
665setDomElements(){super.setDomElements();this.$checkboxes=$$d(this.domElements.main).find('input[type="checkbox"]');this.setInputValue(this.value||[])}
666setEventHandlers(){super.setEventHandlers();this.$checkboxes.on("change",(e)=>{const values=[];$$d(this.domElements.main).find("input:checked").each((i,el)=>{values.push(jQuery(el).attr("value"))});this.setValue(values,!1);this.triggerChanged()})}
667setInputValue(values){if(values===null){$$d(this.domElements.main).find(`input`).prop("checked",!1)}else{values.forEach((value)=>{$$d(this.domElements.main).find(`input[value="${value}"]`).prop("checked",!0)})}}}
668const $$e=jQuery;class DateFormElement extends FormElement{constructor(options,formBuilder,external){super(options,formBuilder,external);
668if(this.formBuilder.admin){this.languages=["en-GB","ar","az","bg","bs","ca","cs","cy","da","de","el","es","et","eu","fa","fi","fo","fr","gl","he","hr","hu","hy","id","is","it","ja","ka","kh","kk","kr","lt","lv","mk","ms","nb","nl","nl-BE","no","pl","pt-BR","pt","ro","rs","rs-latin","ru","sk","sl","sq","sr","sr-latin","sv","sw","th","tr","uk","vi","zh-CN","zh-TW",]}
669this.db_type="varchar(50)";this.language=options.language}
670setDomElements(){super.setDomElements();this.inputs.date=$$e(this.domElements.main).find("input")[0]}
671setEventHandlers(){super.setEventHandlers();$$e(this.inputs.date).on("change",(e)=>{this.setValue(e.target.value,!1);this.triggerChanged()})}
672getSchema(){const schema=super.getSchema();schema.language=this.language;return schema}
673getDataForTemplate(){const data=super.getDataForTemplate();if(this.formBuilder.admin)
674data.languages=this.languages;data.language=this.language;return data}}
675const $$f=jQuery;class DistanceFormElement extends FormElement{constructor(options,formBuilder,external){super(options,formBuilder,external);this.name="distance";this.label=this.label||(options.label===undefined?"Search radius":options.label);this.distanceControl=options.distanceControl||"select";this.distanceUnits=options.distanceUnits||"km";this.distanceUnitsLabel=options.distanceUnitsLabel||"km";this.fromLabel=options.fromLabel||"from";this.placeholder=options.placeholder;this.userLocationButton=options.userLocationButton||!1;this.type=options.type;this.addressField=options.addressField||!0;this.addressFieldPlaceholder=options.addressFieldPlaceholder||"Address";this.languages=[{value:"sq",label:"Albanian"},{value:"ar",label:"Arabic"},{value:"eu",label:"Basque",},{value:"be",label:"Belarusian"},{value:"bg",label:"Bulgarian"},{value:"my",label:"Burmese",},{value:"bn",label:"Bengali"},{value:"ca",label:"Catalan"},{value:"zh-cn",label:"Chinese (simplified)",},{value:"zh-tw",label:"Chinese (traditional)"},{value:"hr",label:"Croatian",},{value:"cs",label:"Czech"},{value:"da",label:"Danish"},{value:"nl",label:"Dutch",},{value:"en",label:"English"},{value:"en-au",label:"English (australian)",},{value:"en-gb",label:"English (great Britain)"},{value:"fa",label:"Farsi",},{value:"fi",label:"Finnish"},{value:"fil",label:"Filipino"},{value:"fr",label:"French",},{value:"gl",label:"Galician"},{value:"de",label:"German"},{value:"el",label:"Greek",},{value:"gu",label:"Gujarati"},{value:"iw",label:"Hebrew"},{value:"hi",label:"Hindi",},{value:"hu",label:"Hungarian"},{value:"id",label:"Indonesian"},{value:"it",label:"Italian",},{value:"ja",label:"Japanese"},{value:"kn",label:"Kannada"},{value:"kk",label:"Kazakh",},{value:"ko",label:"Korean"},{value:"ky",label:"Kyrgyz"},{value:"lt",label:"Lithuanian",},{value:"lv",label:"Latvian"},{value:"mk",label:"Macedonian"},{value:"ml",label:"Malayalam",},{value:"mr",label:"Marathi"},{value:"no",label:"Norwegian"},{value:"pl",label:"Polish",},{value:"pt",label:"Portuguese"},{value:"pt-br",label:"Portuguese (brazil)",},{value:"pt-pt",label:"Portuguese (portugal)"},{value:"pa",label:"Punjabi",},{value:"ro",label:"Romanian"},{value:"ru",label:"Russian"},{value:"sr",label:"Serbian",},{value:"sk",label:"Slovak"},{value:"sl",label:"Slovenian"},{value:"es",label:"Spanish",},{value:"sv",label:"Swedish"},{value:"tl",label:"Tagalog"},{value:"ta",label:"Tamil",},{value:"te",label:"Telugu"},{value:"th",label:"Thai"},{value:"tr",label:"Turkish",},{value:"uk",label:"Ukrainian"},{value:"uz",label:"Uzbek"},{value:"vi",label:"Vietnamese",},];this.countries=MapSVG.countries;this.country=options.country;this.language=options.language;this.searchByZip=options.searchByZip;this.zipLength=parseInt(options.zipLength)||5;this.userLocationButton=MapSVG.parseBoolean(options.userLocationButton);this.options=options.options||[{value:"10",default:!0},{value:"30",default:!1},{value:"50",default:!1},{value:"100",default:!1},];let defOption;if(this.value){this.options.forEach((option)=>{if(option.value===this.value.length){defOption=option}})}
676if(!defOption){defOption=this.options.find(function(option){return option.default===!0})}
677if(!defOption){defOption=this.options[0]}
678const defLengthOption=this.options.find((opt)=>opt.selected===!0);this.defaultLength=defOption.value;this.setDefaultValue()}
679setDefaultValue(){this.value={units:this.distanceUnits,geoPoint:{lat:null,lng:null},length:this.defaultLength,address:"",country:this.country,}}
680setDomElements(){super.setDomElements();this.inputs.units=($$f(this.domElements.main).find('[name="distanceUnits"]')[0]);this.inputs.geoPoint=($$f(this.domElements.main).find('[name="distanceGeoPoint"]')[0]);this.inputs.length=($$f(this.domElements.main).find('[name="distanceLength"]')[0]);this.inputs.address=($$f(this.domElements.main).find('[name="distance"]')[0])}
681getSchema(){const schema=super.getSchema();schema.distanceControl=this.distanceControl;schema.distanceUnits=this.distanceUnits;schema.distanceUnitsLabel=this.distanceUnitsLabel;schema.fromLabel=this.fromLabel;schema.addressField=this.addressField;schema.addressFieldPlaceholder=this.addressFieldPlaceholder;schema.userLocationButton=this.userLocationButton;schema.placeholder=this.placeholder;schema.language=this.language;schema.country=this.country;schema.searchByZip=this.searchByZip;schema.zipLength=parseInt(this.zipLength+"");schema.userLocationButton=MapSVG.parseBoolean(this.userLocationButton);if(schema.distanceControl==="none"){schema.distanceDefault=schema.options.filter(function(o){return o.default})[0].value}
682schema.options.forEach(function(option,index){if(schema.options[index].value===""){schema.options.splice(index,1)}else{schema.options[index].default=MapSVG.parseBoolean(schema.options[index].default)}});return schema}
683getDataForTemplate(){const data=super.getDataForTemplate();if(this.formBuilder.admin){data.languages=this.languages;data.countries=this.countries}
684data.language=this.language;data.country=this.country;data.searchByZip=this.searchByZip;data.zipLength=this.zipLength;data.userLocationButton=MapSVG.parseBoolean(this.userLocationButton);return data}
685destroy(){if($$f().mselect2){const sel=$$f(this.domElements.main).find(".mapsvg-select2");if(sel.length){sel.mselect2("destroy")}}}
686initEditor(){super.initEditor();this.mayBeAddDistanceRow();if($$f().mselect2){$$f(this.domElements.edit).find("select").mselect2()}}
687setEventHandlers(){super.setEventHandlers();const _this=this;$$f(this.domElements.edit).on("keyup change paste",".mapsvg-edit-distance-row input",function(){_this.mayBeAddDistanceRow()});const server=new Server();const locations=new Bloodhound({datumTokenizer:Bloodhound.tokenizers.obj.whitespace("formatted_address"),queryTokenizer:Bloodhound.tokenizers.whitespace,remote:{url:server.getUrl("geocoding")+"?address="+(this.searchByZip===!0?"zip%20":"")+"%QUERY%&language="+this.language+(this.country?"&country="+this.country:""),wildcard:"%QUERY%",transform:function(response){if(response.error_message){alert(response.error_message)}
688return response.results},rateLimitWait:600,},});const thContainer=$$f(this.domElements.main).find(".typeahead");this.spinner=$$f("<span class='spinner-border spinner-border-sm'></span>")[0];if(this.searchByZip){$$f(this.domElements.main).find(".mapsvg-distance-fields").addClass("search-by-zip");thContainer.on("change keyup",(e)=>{const zip=$$f(e.target).val().toString();if(zip.length===_this.zipLength){$$f(this.spinner).appendTo($$f(e.target).closest(".distance-search-wrap"));this.formBuilder.setIsLoading(!0);locations.search($$f(e.target).val(),(data)=>this.handleAddressFieldChange(zip,data),(data)=>this.handleAddressFieldChange(zip,data,!0))}})}else{const tH=thContainer.typeahead({minLength:3},{name:"mapsvg-addresses",display:"formatted_address",limit:5,async:!0,source:(query,sync,async)=>{const request={address:query};if(this.country){request.componentRestrictions={country:this.country}}
689MapSVG.geocode(request,async)},}).on("typeahead:asyncrequest",(e)=>{$$f(this.spinner).appendTo($$f(e.target).closest(".twitter-typeahead"));this.formBuilder.setIsLoading(!0)}).on("typeahead:asynccancel typeahead:asyncreceive",(e)=>{$$f(this.spinner).remove();this.formBuilder.setIsLoading(!1)});$$f(this.domElements.main).find(".mapsvg-distance-fields").removeClass("search-by-zip")}
690if(_this.userLocationButton){const userLocationButton=$$f(this.domElements.main).find(".user-location-button");userLocationButton.on("click",()=>{_this.formBuilder.mapsvg.showUserLocation((location)=>{locations.search(location.geoPoint.lat+","+location.geoPoint.lng,(data)=>this.setAddressByUserLocation(data,location),(data)=>this.setAddressByUserLocation(data,location));this.setValue({geoPoint:location.geoPoint});this.triggerChanged()})})}
691thContainer.on("change keyup",(e)=>{const input=e.target;if(input.value===""&&this.getValue()!==null){this.setValue(null);this.triggerChanged()}});thContainer.on("typeahead:select",(ev,item)=>{this.setValue({address:item.formatted_address,geoPoint:item.geometry.location.toJSON(),});this.triggerChanged();thContainer.blur()});$$f(this.inputs.geoPoint).on("change",(e)=>{const geoPoint=e.target.value.split(",").map((value)=>parseFloat(value));this.setValue({geoPoint:{lat:geoPoint[0],lng:geoPoint[1]}},!1);this.triggerChanged()});$$f(this.inputs.length).on("change",(e)=>{this.setLength(parseInt(e.target.value),!1);this.triggerChanged()})}
692setAddressByUserLocation(data,location){if(data&&data[0]){this.setAddress(data[0].formatted_address)}else{this.setAddress(location.geoPoint.lat+","+location.geoPoint.lng)}}
693handleAddressFieldChange(zip,data,removeSpinner=!1){if(removeSpinner){$$f(this.spinner).remove();this.formBuilder.setIsLoading(!1)}
694if(data&&data[0]){this.setValue({address:zip,geoPoint:data[0].geometry.location},!1);this.triggerChanged()}}
695addSelect2(){if($$f().mselect2){$$f(this.domElements.main).find("select").mselect2().on("select2:focus",function(){$$f(this).mselect2("open")})}}
696mayBeAddDistanceRow(){const _this=this;const editDistanceRow=$$f($$f("#mapsvg-edit-distance-row").html());const z=$$f(_this.domElements.edit).find(".mapsvg-edit-distance-row:last-child input");if(z&&z.last()&&z.last().val()&&z.last().val().toString().trim().length){const newRow=editDistanceRow.clone();newRow.insertAfter($$f(_this.domElements.edit).find(".mapsvg-edit-distance-row:last-child"))}
697const rows=$$f(_this.domElements.edit).find(".mapsvg-edit-distance-row");const row1=rows.eq(rows.length-2);const row2=rows.eq(rows.length-1);if(row1.length&&row2.length&&!row1.find("input:eq(0)").val().toString().trim()&&!row2.find("input:eq(0)").val().toString().trim()){row2.remove()}}
698setValue(value,updateInput=!0){if(value===null){this.setGeoPoint(null);this.setAddress("")}else{for(const key in value){if(typeof this.value[key]!==undefined){const method="set"+MapSVG.ucfirst(key);if(typeof this[method]==="function"){this[method](value[key],updateInput)}}}}}
699setGeoPoint(geoPoint,updateInput=!0){this.value.geoPoint=geoPoint===null?{lat:null,lng:null}:geoPoint;if(updateInput){this.setInputGeoPointValue(geoPoint)}}
700setInputGeoPointValue(geoPoint){this.inputs.geoPoint.value=geoPoint?geoPoint.lat+","+geoPoint.lng:""}
701setLength(length,updateInput=!0){this.value.length=parseInt(length.toString());this.defaultLength=this.value.length;if(updateInput){this.setInputLengthValue(this.value.length)}}
702setInputLengthValue(length){this.inputs.length.value=length.toString()}
703setAddress(address,updateInput=!0){this.value.address=address!==null?address:"";if(updateInput){this.setInputAddressValue(this.value.address)}}
704setInputAddressValue(address){this.inputs.address.value=address}
705getValue(){return this.value.geoPoint.lat===null?null:this.value}}
706const $$g=jQuery;class EmptyFormElement extends FormElement{constructor(options,formBuilder,external){super(options,formBuilder,external);this.readonly=!0}}
707class IdFormElement extends FormElement{constructor(options,formBuilder,external){super(options,formBuilder,external)}
708getData(){return{name:"id",value:this.value}}}
709function createCommonjsModule(fn,module){return module={exports:{}},fn(module,module.exports),module.exports}
710var sortable_min=createCommonjsModule(function(module){/**!
711     * Sortable
712     * @author	RubaXa   <[email protected]>
713     * @license MIT
714     */
715(function sortableModule(factory){{module.exports=factory()}})(function sortableFactory(){if(typeof window=="undefined"||!window.document){return function sortableError(){throw new Error("Sortable.js requires a window with a document")}}
716var dragEl,parentEl,ghostEl,cloneEl,rootEl,nextEl,scrollEl,scrollParentEl,scrollCustomFn,lastEl,lastCSS,lastParentCSS,oldIndex,newIndex,activeGroup,putSortable,autoScroll={},tapEvt,touchEvt,moved,RSPACE=/\s+/g,expando="Sortable"+new Date().getTime(),win=window,document=win.document,parseInt=win.parseInt,$=win.jQuery||win.Zepto,Polymer=win.Polymer,supportDraggable=!!("draggable" in document.createElement("div")),supportCssPointerEvents=(function(el){if(navigator.userAgent.match(/Trident.*rv[ :]?11\./)){return!1}
717el=document.createElement("x");el.style.cssText="pointer-events:auto";return el.style.pointerEvents==="auto"})(),_silent=!1,abs=Math.abs,min=Math.min,touchDragOverListeners=[],_autoScroll=_throttle(function(evt,options,rootEl){if(rootEl&&options.scroll){var el,rect,sens=options.scrollSensitivity,speed=options.scrollSpeed,x=evt.clientX,y=evt.clientY,winWidth=window.innerWidth,winHeight=window.innerHeight,vx,vy,scrollOffsetX,scrollOffsetY;if(scrollParentEl!==rootEl){scrollEl=options.scroll;scrollParentEl=rootEl;scrollCustomFn=options.scrollFn;if(scrollEl===!0){scrollEl=rootEl;do{if(scrollEl.offsetWidth<scrollEl.scrollWidth||scrollEl.offsetHeight<scrollEl.scrollHeight){break}}while((scrollEl=scrollEl.parentNode));}}
718if(scrollEl){el=scrollEl;rect=scrollEl.getBoundingClientRect();vx=(abs(rect.right-x)<=sens)-(abs(rect.left-x)<=sens);vy=(abs(rect.bottom-y)<=sens)-(abs(rect.top-y)<=sens)}
719if(!(vx||vy)){vx=(winWidth-x<=sens)-(x<=sens);vy=(winHeight-y<=sens)-(y<=sens);(vx||vy)&&(el=win)}
720if(autoScroll.vx!==vx||autoScroll.vy!==vy||autoScroll.el!==el){autoScroll.el=el;autoScroll.vx=vx;autoScroll.vy=vy;clearInterval(autoScroll.pid);if(el){autoScroll.pid=setInterval(function(){scrollOffsetY=vy?vy*speed:0;scrollOffsetX=vx?vx*speed:0;if("function"===typeof scrollCustomFn){return scrollCustomFn.call(_this,scrollOffsetX,scrollOffsetY,evt)}
721if(el===win){win.scrollTo(win.pageXOffset+scrollOffsetX,win.pageYOffset+scrollOffsetY)}else{el.scrollTop+=scrollOffsetY;el.scrollLeft+=scrollOffsetX}},24)}}}},30),_prepareGroup=function(options){function toFn(value,pull){if(value===void 0||value===!0){value=group.name}
722if(typeof value==="function"){return value}else{return function(to,from){var fromGroup=from.options.group.name;return pull?value:value&&(value.join?value.indexOf(fromGroup)>-1:fromGroup==value)}}}
723var group={};var originalGroup=options.group;if(!originalGroup||typeof originalGroup!="object"){originalGroup={name:originalGroup}}
724group.name=originalGroup.name;group.checkPull=toFn(originalGroup.pull,!0);group.checkPut=toFn(originalGroup.put);options.group=group};function Sortable(el,options){if(!(el&&el.nodeType&&el.nodeType===1)){throw "Sortable: `el` must be HTMLElement, and not "+{}.toString.call(el)}
725this.el=el;this.options=options=_extend({},options);el[expando]=this;var defaults={group:Math.random(),sort:!0,disabled:!1,store:null,handle:null,scroll:!0,scrollSensitivity:30,scrollSpeed:10,draggable:/[uo]l/i.test(el.nodeName)?"li":">*",ghostClass:"sortable-ghost",chosenClass:"sortable-chosen",dragClass:"sortable-drag",ignore:"a, img",filter:null,animation:0,setData:function(dataTransfer,dragEl){dataTransfer.setData("Text",dragEl.textContent)},dropBubble:!1,dragoverBubble:!1,dataIdAttr:"data-id",delay:0,forceFallback:!1,fallbackClass:"sortable-fallback",fallbackOnBody:!1,fallbackTolerance:0,fallbackOffset:{x:0,y:0},};for(var name in defaults){!(name in options)&&(options[name]=defaults[name])}
726_prepareGroup(options);for(var fn in this){if(fn.charAt(0)==="_"&&typeof this[fn]==="function"){this[fn]=this[fn].bind(this)}}
727this.nativeDraggable=options.forceFallback?!1:supportDraggable;_on(el,"mousedown",this._onTapStart);_on(el,"touchstart",this._onTapStart);if(this.nativeDraggable){_on(el,"dragover",this);_on(el,"dragenter",this)}
728touchDragOverListeners.push(this._onDragOver);options.store&&this.sort(options.store.get(this))}
729Sortable.prototype={constructor:Sortable,_onTapStart:function(evt){if(evt.target.tagName=="i"||evt.target.tagName=="I"){evt.target.click();return}
730var _this=this,el=this.el,options=this.options,type=evt.type,touch=evt.touches&&evt.touches[0],target=(touch||evt).target,originalTarget=(evt.target.shadowRoot&&evt.path[0])||target,filter=options.filter,startIndex;if(dragEl){return}
731if((type==="mousedown"&&evt.button!==0)||options.disabled){return}
732if(options.handle&&!_closest(originalTarget,options.handle,el)){return}
733target=_closest(target,options.draggable,el);if(!target){return}
734startIndex=_index(target,options.draggable);if(typeof filter==="function"){if(filter.call(this,evt,target,this)){_dispatchEvent(_this,originalTarget,"filter",target,el,startIndex);evt.preventDefault();return}}else if(filter){filter=filter.split(",").some(function(criteria){criteria=_closest(originalTarget,criteria.trim(),el);if(criteria){_dispatchEvent(_this,criteria,"filter",target,el,startIndex);return!0}});if(filter){evt.preventDefault();return}}
735this._prepareDragStart(evt,touch,target,startIndex)},_prepareDragStart:function(evt,touch,target,startIndex){var _this=this,el=_this.el,options=_this.options,ownerDocument=el.ownerDocument,dragStartFn;if(target&&!dragEl&&target.parentNode===el){tapEvt=evt;rootEl=el;dragEl=target;parentEl=dragEl.parentNode;nextEl=dragEl.nextSibling;activeGroup=options.group;oldIndex=startIndex;this._lastX=(touch||evt).clientX;this._lastY=(touch||evt).clientY;dragEl.style["will-change"]="transform";dragStartFn=function(){_this._disableDelayedDrag();dragEl.draggable=_this.nativeDraggable;_toggleClass(dragEl,options.chosenClass,!0);_this._triggerDragStart(touch);_dispatchEvent(_this,rootEl,"choose",dragEl,rootEl,oldIndex)};options.ignore.split(",").forEach(function(criteria){_find(dragEl,criteria.trim(),_disableDraggable)});_on(ownerDocument,"mouseup",_this._onDrop);_on(ownerDocument,"touchend",_this._onDrop);_on(ownerDocument,"touchcancel",_this._onDrop);if(options.delay){_on(ownerDocument,"mouseup",_this._disableDelayedDrag);_on(ownerDocument,"touchend",_this._disableDelayedDrag);_on(ownerDocument,"touchcancel",_this._disableDelayedDrag);_on(ownerDocument,"mousemove",_this._disableDelayedDrag);_on(ownerDocument,"touchmove",_this._disableDelayedDrag);_this._dragStartTimer=setTimeout(dragStartFn,options.delay)}else{dragStartFn()}}},_disableDelayedDrag:function(){var ownerDocument=this.el.ownerDocument;clearTimeout(this._dragStartTimer);_off(ownerDocument,"mouseup",this._disableDelayedDrag);_off(ownerDocument,"touchend",this._disableDelayedDrag);_off(ownerDocument,"touchcancel",this._disableDelayedDrag);_off(ownerDocument,"mousemove",this._disableDelayedDrag);_off(ownerDocument,"touchmove",this._disableDelayedDrag)},_triggerDragStart:function(touch){if(touch){tapEvt={target:dragEl,clientX:touch.clientX,clientY:touch.clientY,};this._onDragStart(tapEvt,"touch")}else if(!this.nativeDraggable){this._onDragStart(tapEvt,!0)}else{_on(dragEl,"dragend",this);_on(rootEl,"dragstart",this._onDragStart)}
736try{if(document.selection){setTimeout(function(){document.selection.empty()})}else{window.getSelection().removeAllRanges()}}catch(err){}},_dragStarted:function(){if(rootEl&&dragEl){var options=this.options;_toggleClass(dragEl,options.ghostClass,!0);_toggleClass(dragEl,options.dragClass,!1);Sortable.active=this;_dispatchEvent(this,rootEl,"start",dragEl,rootEl,oldIndex)}},_emulateDragOver:function(){if(touchEvt){if(this._lastX===touchEvt.clientX&&this._lastY===touchEvt.clientY){return}
737this._lastX=touchEvt.clientX;this._lastY=touchEvt.clientY;if(!supportCssPointerEvents){_css(ghostEl,"display","none")}
738var target=document.elementFromPoint(touchEvt.clientX,touchEvt.clientY),parent=target,i=touchDragOverListeners.length;if(parent){do{if(parent[expando]){while(i--){touchDragOverListeners[i]({clientX:touchEvt.clientX,clientY:touchEvt.clientY,target:target,rootEl:parent,})}
739break}
740target=parent}
740while((parent=parent.parentNode));}
741if(!supportCssPointerEvents){_css(ghostEl,"display","")}}},_onTouchMove:function(evt){if(tapEvt){var options=this.options,fallbackTolerance=options.fallbackTolerance,fallbackOffset=options.fallbackOffset,touch=evt.touches?evt.touches[0]:evt,dx=touch.clientX-tapEvt.clientX+fallbackOffset.x,dy=touch.clientY-tapEvt.clientY+fallbackOffset.y,translate3d=evt.touches?"translate3d("+dx+"px,"+dy+"px,0)":"translate("+dx+"px,"+dy+"px)";if(!Sortable.active){if(fallbackTolerance&&min(abs(touch.clientX-this._lastX),abs(touch.clientY-this._lastY))<fallbackTolerance){return}
742this._dragStarted()}
743this._appendGhost();moved=!0;touchEvt=touch;_css(ghostEl,"webkitTransform",translate3d);_css(ghostEl,"mozTransform",translate3d);_css(ghostEl,"msTransform",translate3d);_css(ghostEl,"transform",translate3d);evt.preventDefault()}},_appendGhost:function(){if(!ghostEl){var rect=dragEl.getBoundingClientRect(),css=_css(dragEl),options=this.options,ghostRect;ghostEl=dragEl.cloneNode(!0);_toggleClass(ghostEl,options.ghostClass,!1);_toggleClass(ghostEl,options.fallbackClass,!0);_toggleClass(ghostEl,options.dragClass,!0);_css(ghostEl,"top",rect.top-parseInt(css.marginTop,10));_css(ghostEl,"left",rect.left-parseInt(css.marginLeft,10));_css(ghostEl,"width",rect.width);_css(ghostEl,"height",rect.height);_css(ghostEl,"opacity","0.8");_css(ghostEl,"position","fixed");_css(ghostEl,"zIndex","100000");_css(ghostEl,"pointerEvents","none");(options.fallbackOnBody&&document.body.appendChild(ghostEl))||rootEl.appendChild(ghostEl);ghostRect=ghostEl.getBoundingClientRect();_css(ghostEl,"width",rect.width*2-ghostRect.width);_css(ghostEl,"height",rect.height*2-ghostRect.height)}},_onDragStart:function(evt,useFallback){var dataTransfer=evt.dataTransfer,options=this.options;this._offUpEvents();if(activeGroup.checkPull(this,this,dragEl,evt)=="clone"){cloneEl=_clone(dragEl);_css(cloneEl,"display","none");rootEl.insertBefore(cloneEl,dragEl);_dispatchEvent(this,rootEl,"clone",dragEl)}
744_toggleClass(dragEl,options.dragClass,!0);if(useFallback){if(useFallback==="touch"){_on(document,"touchmove",this._onTouchMove);_on(document,"touchend",this._onDrop);_on(document,"touchcancel",this._onDrop)}else{_on(document,"mousemove",this._onTouchMove);_on(document,"mouseup",this._onDrop)}
745this._loopId=setInterval(this._emulateDragOver,50)}else{if(dataTransfer){dataTransfer.effectAllowed="move";options.setData&&options.setData.call(this,dataTransfer,dragEl)}
746_on(document,"drop",this);setTimeout(this._dragStarted,0)}},_onDragOver:function(evt){var el=this.el,target,dragRect,targetRect,revert,options=this.options,group=options.group,activeSortable=Sortable.active,isOwner=activeGroup===group,canSort=options.sort;if(evt.preventDefault!==void 0){evt.preventDefault();!options.dragoverBubble&&evt.stopPropagation()}
747moved=!0;if(activeGroup&&!options.disabled&&(isOwner?canSort||(revert=!rootEl.contains(dragEl)):putSortable===this||(activeGroup.checkPull(this,activeSortable,dragEl,evt)&&group.checkPut(this,activeSortable,dragEl,evt)))&&(evt.rootEl===void 0||evt.rootEl===this.el)){_autoScroll(evt,options,this.el);if(_silent){return}
748target=_closest(evt.target,options.draggable,el);dragRect=dragEl.getBoundingClientRect();putSortable=this;if(revert){_cloneHide(!0);parentEl=rootEl;if(cloneEl||nextEl){rootEl.insertBefore(dragEl,cloneEl||nextEl)}else if(!canSort){rootEl.appendChild(dragEl)}
749return}
750if(el.children.length===0||el.children[0]===ghostEl||(el===evt.target&&(target=_ghostIsLast(el,evt)))){if(target){if(target.animated){return}
751targetRect=target.getBoundingClientRect()}
752_cloneHide(isOwner);if(_onMove(rootEl,el,dragEl,dragRect,target,targetRect,evt)!==!1){if(!dragEl.contains(el)){el.appendChild(dragEl);parentEl=el}
753this._animate(dragRect,dragEl);target&&this._animate(targetRect,target)}}else if(target&&!target.animated&&target!==dragEl&&target.parentNode[expando]!==void 0){if(lastEl!==target){lastEl=target;lastCSS=_css(target);lastParentCSS=_css(target.parentNode)}
754targetRect=target.getBoundingClientRect();var width=targetRect.right-targetRect.left,height=targetRect.bottom-targetRect.top,floating=/left|right|inline/.test(lastCSS.cssFloat+lastCSS.display)||(lastParentCSS.display=="flex"&&lastParentCSS["flex-direction"].indexOf("row")===0),isWide=target.offsetWidth>dragEl.offsetWidth,isLong=target.offsetHeight>dragEl.offsetHeight,halfway=(floating?(evt.clientX-targetRect.left)/width:(evt.clientY-targetRect.top)/height)>0.5,nextSibling=target.nextElementSibling,moveVector=_onMove(rootEl,el,dragEl,dragRect,target,targetRect,evt),after;if(moveVector!==!1){_silent=!0;setTimeout(_unsilent,30);_cloneHide(isOwner);
754if(moveVector===1||moveVector===-1){after=moveVector===1}else if(floating){var elTop=dragEl.offsetTop,tgTop=target.offsetTop;if(elTop===tgTop){after=(target.previousElementSibling===dragEl&&!isWide)||(halfway&&isWide)}else if(target.previousElementSibling===dragEl||dragEl.previousElementSibling===target){after=(evt.clientY-targetRect.top)/height>0.5}else{after=tgTop>elTop}}else{after=(nextSibling!==dragEl&&!isLong)||(halfway&&isLong)}
755if(!dragEl.contains(el)){if(after&&!nextSibling){el.appendChild(dragEl)}else{target.parentNode.insertBefore(dragEl,after?nextSibling:target)}}
756parentEl=dragEl.parentNode;this._animate(dragRect,dragEl);this._animate(targetRect,target)}}}},_animate:function(prevRect,target){var ms=this.options.animation;if(ms){var currentRect=target.getBoundingClientRect();_css(target,"transition","none");_css(target,"transform","translate3d("+(prevRect.left-currentRect.left)+"px,"+(prevRect.top-currentRect.top)+"px,0)");target.offsetWidth;_css(target,"transition","all "+ms+"ms");_css(target,"transform","translate3d(0,0,0)");clearTimeout(target.animated);target.animated=setTimeout(function(){_css(target,"transition","");_css(target,"transform","");target.animated=!1},ms)}},_offUpEvents:function(){var ownerDocument=this.el.ownerDocument;_off(document,"touchmove",this._onTouchMove);_off(ownerDocument,"mouseup",this._onDrop);_off(ownerDocument,"touchend",this._onDrop);_off(ownerDocument,"touchcancel",this._onDrop)},_onDrop:function(evt){var el=this.el,options=this.options;clearInterval(this._loopId);clearInterval(autoScroll.pid);clearTimeout(this._dragStartTimer);_off(document,"mousemove",this._onTouchMove);if(this.nativeDraggable){_off(document,"drop",this);_off(el,"dragstart",this._onDragStart)}
757this._offUpEvents();if(evt){if(moved){evt.preventDefault();!options.dropBubble&&evt.stopPropagation()}
758ghostEl&&ghostEl.parentNode.removeChild(ghostEl);if(dragEl){if(this.nativeDraggable){_off(dragEl,"dragend",this)}
759_disableDraggable(dragEl);dragEl.style["will-change"]="";_toggleClass(dragEl,this.options.ghostClass,!1);_toggleClass(dragEl,this.options.chosenClass,!1);if(rootEl!==parentEl){newIndex=_index(dragEl,options.draggable);if(newIndex>=0){_dispatchEvent(null,parentEl,"add",dragEl,rootEl,oldIndex,newIndex);_dispatchEvent(this,rootEl,"remove",dragEl,rootEl,oldIndex,newIndex);_dispatchEvent(null,parentEl,"sort",dragEl,rootEl,oldIndex,newIndex);_dispatchEvent(this,rootEl,"sort",dragEl,rootEl,oldIndex,newIndex)}}else{cloneEl&&cloneEl.parentNode.removeChild(cloneEl);if(dragEl.nextSibling!==nextEl){newIndex=_index(dragEl,options.draggable);if(newIndex>=0){_dispatchEvent(this,rootEl,"update",dragEl,rootEl,oldIndex,newIndex);_dispatchEvent(this,rootEl,"sort",dragEl,rootEl,oldIndex,newIndex)}}}
760if(Sortable.active){if(newIndex==null||newIndex===-1){newIndex=oldIndex}
761_dispatchEvent(this,rootEl,"end",dragEl,rootEl,oldIndex,newIndex);this.save()}}}
762this._nulling()},_nulling:function(){rootEl=dragEl=parentEl=ghostEl=nextEl=cloneEl=scrollEl=scrollParentEl=tapEvt=touchEvt=moved=newIndex=lastEl=lastCSS=putSortable=activeGroup=Sortable.active=null},handleEvent:function(evt){var type=evt.type;if(type==="dragover"||type==="dragenter"){if(dragEl){this._onDragOver(evt);_globalDragOver(evt)}}else if(type==="drop"||type==="dragend"){this._onDrop(evt)}},toArray:function(){var order=[],el,children=this.el.children,i=0,n=children.length,options=this.options;for(;i<n;i++){el=children[i];if(_closest(el,options.draggable,this.el)){order.push(el.getAttribute(options.dataIdAttr)||_generateId(el))}}
763return order},sort:function(order){var items={},rootEl=this.el;this.toArray().forEach(function(id,i){var el=rootEl.children[i];if(_closest(el,this.options.draggable,rootEl)){items[id]=el}},this);order.forEach(function(id){if(items[id]){rootEl.removeChild(items[id]);rootEl.appendChild(items[id])}})},save:function(){var store=this.options.store;store&&store.set(this)},closest:function(el,selector){return _closest(el,selector||this.options.draggable,this.el)},option:function(name,value){var options=this.options;if(value===void 0){return options[name]}else{options[name]=value;if(name==="group"){_prepareGroup(options)}}},destroy:function(){var el=this.el;el[expando]=null;_off(el,"mousedown",this._onTapStart);_off(el,"touchstart",this._onTapStart);if(this.nativeDraggable){_off(el,"dragover",this);_off(el,"dragenter",this)}
764Array.prototype.forEach.call(el.querySelectorAll("[draggable]"),function(el){el.removeAttribute("draggable")});touchDragOverListeners.splice(touchDragOverListeners.indexOf(this._onDragOver),1);this._onDrop();this.el=el=null},};function _cloneHide(state){if(cloneEl&&cloneEl.state!==state){_css(cloneEl,"display",state?"none":"");!state&&cloneEl.state&&rootEl.insertBefore(cloneEl,dragEl);cloneEl.state=state}}
765function _closest(el,selector,ctx){if(el){ctx=ctx||document;do{if((selector===">*"&&el.parentNode===ctx)||_matches(el,selector)){return el}}while((el=_getParentOrHost(el)));}
766return null}
767function _getParentOrHost(el){var parent=el.host;return parent&&parent.nodeType?parent:el.parentNode}
768function _globalDragOver(evt){if(evt.dataTransfer){evt.dataTransfer.dropEffect="move"}
769evt.preventDefault()}
770function _on(el,event,fn){el.addEventListener(event,fn,!1)}
771function _off(el,event,fn){el.removeEventListener(event,fn,!1)}
772function _toggleClass(el,name,state){if(el){if(el.classList){el.classList[state?"add":"remove"](name)}else{var className=(" "+el.className+" ").replace(RSPACE," ").replace(" "+name+" "," ");el.className=(className+(state?" "+name:"")).replace(RSPACE," ")}}}
773function _css(el,prop,val){var style=el&&el.style;if(style){if(val===void 0){if(document.defaultView&&document.defaultView.getComputedStyle){val=document.defaultView.getComputedStyle(el,"")}else if(el.currentStyle){val=el.currentStyle}
774return prop===void 0?val:val[prop]}else{if(!(prop in style)){prop="-webkit-"+prop}
775style[prop]=val+(typeof val==="string"?"":"px")}}}
776function _find(ctx,tagName,iterator){if(ctx){var list=ctx.getElementsByTagName(tagName),i=0,n=list.length;if(iterator){for(;i<n;i++){iterator(list[i],i)}}
777return list}
778return[]}
779function _dispatchEvent(sortable,rootEl,name,targetEl,fromEl,startIndex,newIndex){sortable=sortable||rootEl[expando];
779var evt=document.createEvent("Event"),options=sortable.options,onName="on"+name.charAt(0).toUpperCase()+name.substr(1);evt.initEvent(name,!0,!0);evt.to=rootEl;evt.from=fromEl||rootEl;evt.item=targetEl||rootEl;evt.clone=cloneEl;evt.oldIndex=startIndex;evt.newIndex=newIndex;rootEl.dispatchEvent(evt);if(options[onName]){options[onName].call(sortable,evt)}}
780function _onMove(fromEl,toEl,dragEl,dragRect,targetEl,targetRect,originalEvt){var evt,sortable=fromEl[expando],onMoveFn=sortable.options.onMove,retVal;evt=document.createEvent("Event");evt.initEvent("move",!0,!0);evt.to=toEl;evt.from=fromEl;evt.dragged=dragEl;evt.draggedRect=dragRect;evt.related=targetEl||toEl;evt.relatedRect=targetRect||toEl.getBoundingClientRect();fromEl.dispatchEvent(evt);if(onMoveFn){retVal=onMoveFn.call(sortable,evt,originalEvt)}
781return retVal}
782function _disableDraggable(el){el.draggable=!1}
783function _unsilent(){_silent=!1}
784function _ghostIsLast(el,evt){var lastEl=el.lastElementChild,rect=lastEl.getBoundingClientRect();return((evt.clientY-(rect.top+rect.height)>5||evt.clientX-(rect.right+rect.width)>5)&&lastEl)}
785function _generateId(el){var str=el.tagName+el.className+el.src+el.href+el.textContent,i=str.length,sum=0;while(i--){sum+=str.charCodeAt(i)}
786return sum.toString(36)}
787function _index(el,selector){var index=0;if(!el||!el.parentNode){return-1}
788while(el&&(el=el.previousElementSibling)){if(el.nodeName.toUpperCase()!=="TEMPLATE"&&(selector===">*"||_matches(el,selector))){index++}}
789return index}
790function _matches(el,selector){if(el){selector=selector.split(".");var tag=selector.shift().toUpperCase(),re=new RegExp("\\s("+selector.join("|")+")(?=\\s)","g");return((tag===""||el.nodeName.toUpperCase()==tag)&&(!selector.length||((" "+el.className+" ").match(re)||[]).length==selector.length))}
791return!1}
792function _throttle(callback,ms){var args,_this;return function(){if(args===void 0){args=arguments;_this=this;setTimeout(function(){if(args.length===1){callback.call(_this,args[0])}else{callback.apply(_this,args)}
793args=void 0},ms)}}}
794function _extend(dst,src){if(dst&&src){for(var key in src){if(src.hasOwnProperty(key)){dst[key]=src[key]}}}
795return dst}
796function _clone(el){return $?$(el).clone(!0)[0]:Polymer&&Polymer.dom?Polymer.dom(el).cloneNode(!0):el.cloneNode(!0)}
797Sortable.utils={on:_on,off:_off,css:_css,find:_find,is:function(el,selector){return!!_closest(el,selector,el)},extend:_extend,throttle:_throttle,closest:_closest,toggleClass:_toggleClass,clone:_clone,index:_index,};Sortable.create=function(el,options){return new Sortable(el,options)};Sortable.version="1.4.2";return Sortable})});const $$h=jQuery;class ImagesFormElement extends FormElement{constructor(options,formBuilder,external){super(options,formBuilder,external);this.searchType=options.searchType||"fulltext";this.mediaUploader=external.mediaUploader;this.button_text=options.button_text||"Browse...";this.db_type="text";this.label=options.label||"Images";this.name=options.name||"images";this.images=this.value||[];this.value=JSON.stringify(this.value)}
798init(){super.init();this.redrawImages()}
799setDomElements(){super.setDomElements()}
800getData(){this.updateData();return{name:this.name,value:this.images}}
801getSchema(){const schema=super.getSchema();schema.button_text=this.button_text;return schema}
802updateData(){const newListOfImages=[];$$h(this.domElements.main).find(".mapsvg-thumbnail-wrap").each(function(index,el){const imageData=$$h(el).data("image");newListOfImages.push(imageData)});this.images=newListOfImages;this.value=JSON.stringify(this.images);$$h(this.domElements.main).find("input").val(this.value)}
803setEventHandlers(){super.setEventHandlers();if(this.formBuilder.editMode){return}
804const _this=this;const imageDOM=$$h(this.domElements.main).find(".mapsvg-data-images");this.external.mediaUploader.on("select",()=>{if(_this.formBuilder.mediaUploaderisOpenedFor!==_this)
805return!1;const attachments=_this.external.mediaUploader.state().get("selection").toJSON();attachments.forEach(function(img){const image={sizes:{}};for(const type in img.sizes){image[type]=img.sizes[type].url.replace("http://","//").replace("https://","//");image.sizes[type]={width:img.sizes[type].width,height:img.sizes[type].height,}}
806if(!image.thumbnail){image.thumbnail=image.full;image.sizes.thumbnail={width:img.sizes.full.width,height:img.sizes.full.height,}}
807if(!image.medium){image.medium=image.full;image.sizes.medium={width:img.sizes.full.width,height:img.sizes.full.height,}}
808image.caption=img.caption;image.description=img.description;_this.images.push(image)});this.setValue(this.images);_this.redrawImages()});$$h(_this.domElements.main).on("click",".mapsvg-upload-image",function(e){e.preventDefault();_this.formBuilder.mediaUploaderisOpenedFor=_this;_this.external.mediaUploader.open()});$$h(_this.domElements.main).on("click",".mapsvg-image-delete",function(e){e.preventDefault();$$h(this).closest(".mapsvg-thumbnail-wrap").remove();_this.updateData()});_this.sortable=new sortable_min(imageDOM[0],{animation:150,onStart:function(){$$h(_this.domElements.main).addClass("sorting")},onEnd:function(evt){_this.images=[];$$h(_this.domElements.main).find("img").each(function(i,image){_this.images.push($$h(image).data("image"))});this.value=JSON.stringify(_this.images);$$h(_this.domElements.main).find("input").val(this.value);$$h(_this.domElements.main).removeClass("sorting")},})}
809redrawImages(){const imageDOM=$$h(this.domElements.main).find(".mapsvg-data-images");imageDOM.empty();
809this.images&&this.images.forEach(function(image){const img=$$h('<img class="mapsvg-data-thumbnail" />').attr("src",image.thumbnail).data("image",image);const imgContainer=$$h('<div class="mapsvg-thumbnail-wrap"></div>').data("image",image);imgContainer.append(img);imgContainer.append('<i class="mfa mfa-times  mapsvg-image-delete"></i>');imageDOM.append(imgContainer)});$$h(this.domElements.main).find("input").val(this.value)}
810destroy(){super.destroy();this.external.mediaUploader.off("select")}}
811const $$i=jQuery;class LocationFormElement extends FormElement{constructor(options,formBuilder,external){super(options,formBuilder,external);this.label=this.label||(options.label===undefined?"Location":options.label);this.name="location";this.db_type="text";this.languages=[{value:"sq",label:"Albanian"},{value:"ar",label:"Arabic"},{value:"eu",label:"Basque",},{value:"be",label:"Belarusian"},{value:"bg",label:"Bulgarian"},{value:"my",label:"Burmese",},{value:"bn",label:"Bengali"},{value:"ca",label:"Catalan"},{value:"zh-cn",label:"Chinese (simplified)",},{value:"zh-tw",label:"Chinese (traditional)"},{value:"hr",label:"Croatian",},{value:"cs",label:"Czech"},{value:"da",label:"Danish"},{value:"nl",label:"Dutch",},{value:"en",label:"English"},{value:"en-au",label:"English (australian)",},{value:"en-gb",label:"English (great Britain)"},{value:"fa",label:"Farsi",},{value:"fi",label:"Finnish"},{value:"fil",label:"Filipino"},{value:"fr",label:"French",},{value:"gl",label:"Galician"},{value:"de",label:"German"},{value:"el",label:"Greek",},{value:"gu",label:"Gujarati"},{value:"iw",label:"Hebrew"},{value:"hi",label:"Hindi",},{value:"hu",label:"Hungarian"},{value:"id",label:"Indonesian"},{value:"it",label:"Italian",},{value:"ja",label:"Japanese"},{value:"kn",label:"Kannada"},{value:"kk",label:"Kazakh",},{value:"ko",label:"Korean"},{value:"ky",label:"Kyrgyz"},{value:"lt",label:"Lithuanian",},{value:"lv",label:"Latvian"},{value:"mk",label:"Macedonian"},{value:"ml",label:"Malayalam",},{value:"mr",label:"Marathi"},{value:"no",label:"Norwegian"},{value:"pl",label:"Polish",},{value:"pt",label:"Portuguese"},{value:"pt-br",label:"Portuguese (brazil)",},{value:"pt-pt",label:"Portuguese (portugal)"},{value:"pa",label:"Punjabi",},{value:"ro",label:"Romanian"},{value:"ru",label:"Russian"},{value:"sr",label:"Serbian",},{value:"sk",label:"Slovak"},{value:"sl",label:"Slovenian"},{value:"es",label:"Spanish",},{value:"sv",label:"Swedish"},{value:"tl",label:"Tagalog"},{value:"ta",label:"Tamil",},{value:"te",label:"Telugu"},{value:"th",label:"Thai"},{value:"tr",label:"Turkish",},{value:"uk",label:"Ukrainian"},{value:"uz",label:"Uzbek"},{value:"vi",label:"Vietnamese",},];this.language=options.language;this.markerImages=MapSVG.markerImages;this.markersByField=options.markersByField;this.markerField=options.markerField;this.markersByFieldEnabled=MapSVG.parseBoolean(options.markersByFieldEnabled);this.defaultMarkerPath=options.defaultMarkerPath||this.formBuilder.mapsvg.getData().options.defaultMarkerImage;this.templates.marker=Handlebars.compile($$i("#mapsvg-data-tmpl-marker").html())}
812init(){super.init();if(this.value){this.renderMarker()}
813this.renderMarkerSelector()}
814getSchema(){const schema=super.getSchema();schema.language=this.language;schema.defaultMarkerPath=this.defaultMarkerPath;schema.markersByField=this.markersByField;schema.markerField=this.markerField;schema.markersByFieldEnabled=MapSVG.parseBoolean(this.markersByFieldEnabled);return schema}
815getData(){return{name:this.name,value:this.value}}
816getDataForTemplate(){const data=super.getDataForTemplate();if(this.formBuilder.admin){data.languages=this.languages;data.markerImages=MapSVG.markerImages;data.markersByField=this.markersByField;data.markerField=this.markerField;data.markersByFieldEnabled=MapSVG.parseBoolean(this.markersByFieldEnabled);const _this=this;data.markerImages.forEach(function(m){if(m.relativeUrl===_this.defaultMarkerPath){m.default=!0}else{m.default=!1}})}
817data.language=this.language;if(this.value){data.location=this.value;if(data.location.marker){data.location.img=(this.value.marker.src.indexOf(MapSVG.urls.uploads)===0?"uploads/":"")+this.value.marker.src.split("/").pop()}}
818data.showUploadBtn=data.external.filtersMode;return data}
819initEditor(){super.initEditor();this.renderMarkerSelector();this.fillMarkersByFieldOptions(this.markerField)}
820setDomElements(){super.setDomElements();this.domElements.markerImageButton=$$i(this.domElements.main).find("img")[0]}
821setEventHandlers(){super.setEventHandlers();const _this=this;const server=new Server();if(_this.formBuilder.mapsvg.isGeo()){const locations=new Bloodhound({datumTokenizer:Bloodhound.tokenizers.obj.whitespace("formatted_address"),queryTokenizer:Bloodhound.tokenizers.whitespace,remote:{url:server.getUrl("geocoding")+"?address=%QUERY%&language="+this.language,wildcard:"%QUERY%",transform:function(response){if(response.error_message){alert(response.error_message)}
822return response.results},rateLimitWait:600,},});const thContainer=$$i(this.domElements.main).find(".typeahead");const tH=thContainer.typeahead({minLength:3},{name:"mapsvg-addresses",display:"formatted_address",async:!0,source:(query,sync,async)=>{const preg=new RegExp(/^[-+]?([1-8]?\d(\.\d+)?|90(\.0+)?),\s*[-+]?(180(\.0+)?|((1[0-7]\d)|([1-9]?\d))(\.\d+)?)$/);if(preg.test(query)){const latlng=query.split(",").map((item)=>item.trim());const item={formatted_address:latlng.join(","),address_components:[],geometry:{location:{lat:()=>latlng[0],lng:()=>latlng[1],},},};sync([item]);return}
823MapSVG.geocode({address:query},async)},}).on("typeahead:asyncrequest",function(e){$$i(e.target).addClass("tt-loading")}).on("typeahead:asynccancel typeahead:asyncreceive",function(e){$$i(e.target).removeClass("tt-loading")});thContainer.on("typeahead:select",(ev,item)=>{this.setValue(null,!1);const address={};address.formatted=item.formatted_address;item.address_components.forEach((addr_item)=>{const type=addr_item.types[0];address[type]=addr_item.long_name;if(addr_item.short_name!=addr_item.long_name){address[type+"_short"]=addr_item.short_name}});const locationData={address:address,geoPoint:new GeoPoint(item.geometry.location.lat(),item.geometry.location.lng()),img:this.getMarkerImage(this.formBuilder.getData()),imagePath:this.getMarkerImage(this.formBuilder.getData()),};this.setValue(locationData,!1);thContainer.typeahead("val","");this.triggerChanged()})}
824$$i(this.domElements.main).on("change",".marker-file-uploader",function(){_this.markerIconUpload(this)});$$i(this.domElements.main).on("click",".mapsvg-marker-image-btn-trigger",function(e){e.preventDefault();$$i(this).toggleClass("active");_this.toggleMarkerSelector()});$$i(this.domElements.main).on("click",".mapsvg-marker-delete",function(e){e.preventDefault();_this.setValue(null);_this.triggerChanged()})}
825setEditorEventHandlers(){super.setEditorEventHandlers();const _this=this;$$i(this.domElements.edit).on("change",".marker-file-uploader",function(){_this.markerIconUpload(this)});$$i(this.domElements.edit).on("change",'select[name="markerField"]',function(){const fieldName=$$i(this).val();_this.resetMarkersByField();const newOptions=_this.fillMarkersByFieldOptions(fieldName);_this.setMarkersByField(newOptions)});$$i(this.domElements.edit).on("click",".mapsvg-marker-image-selector button",function(e){e.preventDefault();const src=$$i(this).find("img").attr("src");$$i(this).parent().find("button").removeClass("active");$$i(this).addClass("active");_this.setDefaultMarkerPath(src)});$$i(this.domElements.edit).on("click",".mapsvg-marker-image-btn-trigger",function(e){$$i(this).toggleClass("active");_this.toggleMarkerSelectorInLocationEditor.call(_this,$$i(this),e)})}
826markerIconUpload(input){const uploadBtn=$$i(input).closest(".btn-file").buttonLoading(!0);for(let i=0;i<input.files.length;i++){const data=new FormData();data.append("file",input.files[0]);const server=new Server();server.ajax("markers",{type:"POST",data:data,processData:!1,contentType:!1,}).done((resp)=>{if(resp.error){alert(resp.error)}else{const marker=resp.marker;const newMarker=`
827                            <button class="btn btn-outline-secondary mapsvg-marker-image-btn mapsvg-marker-image-btn-choose active">
828                                <img src="${marker.relativeUrl}" />
829                            </button>
830                            </button>
831                        `;$$i(this.domElements.markerSelector).find(".mapsvg-marker-image-btn.active").removeClass("active");$$i(newMarker).appendTo(this.domElements.markerSelector);this.setMarkerImage(marker.relativeUrl);MapSVG.markerImages.push(marker)}}).always(function(){uploadBtn.buttonLoading(!1)})}}
832mayBeAddDistanceRow(){const _this=this;if(!this.domElements.editDistanceRow){this.domElements.editDistanceRow=$$i($$i("#mapsvg-edit-distance-row").html())[0]}
833const z=$$i(this.domElements.edit).find(".mapsvg-edit-distance-row:last-child input");if(z&&z.last()&&z.last().val()&&(z.last().val()+"").trim().length){const newRow=$$i(this.templates.editDistanceRow).clone();newRow.insertAfter($$i(_this.domElements.edit).find(".mapsvg-edit-distance-row:last-child"))}
834const rows=$$i(_this.domElements.edit).find(".mapsvg-edit-distance-row");const row1=rows.eq(rows.length-2);const row2=rows.eq(rows.length-1);if(row1.length&&row2.length&&!row1.find("input:eq(0)").val().toString().trim()&&!row2.find("input:eq(0)").val().toString().trim()){row2.remove()}}
835fillMarkersByFieldOptions(fieldName){const _this=this;const field=_this.formBuilder.mapsvg.objectsRepository.getSchema().getField(fieldName);const options={};if(field){const markerImg=_this.formBuilder.mapsvg.options.defaultMarkerImage;const rows=[];field.options.forEach(function(option){const value=field.type==="region"?option.id:option.value;const label=field.type==="region"?option.title||option.id:option.label;const img=_this.markersByField&&_this.markersByField[value]?_this.markersByField[value]:markerImg;rows.push('<tr data-option-id="'+value+'"><td>'+label+'</td><td><button class="btn dropdown-toggle btn-outline-secondary mapsvg-marker-image-btn-trigger mapsvg-marker-image-btn"><img src="'+img+'" class="new-marker-img" /><span class="caret"></span></button></td></tr>');options[value]=img});$$i("#markers-by-field").empty().append(rows)}
836return options}
837renderMarker(marker){if(marker&&marker.location){this.value=marker.location.getData()}
838this.renderMarkerHtml()}
839renderMarkerHtml(){if(!this.value){$$i(this.domElements.main).find(".mapsvg-new-marker").hide()}else{$$i(this.domElements.main).find(".mapsvg-new-marker").show().html(this.templates.marker(this.value))}}
840toggleMarkerSelector(){if(this.domElements.markerSelectorWrap&&$$i(this.domElements.markerSelectorWrap).is(":visible")){$$i(this.domElements.markerSelectorWrap).hide();return}
841if(this.domElements.markerSelectorWrap&&$$i(this.domElements.markerSelectorWrap).not(":visible")){$$i(this.domElements.markerSelector).find(".active").removeClass("active");if(this.value&&this.value.markerImagePath){$$i(this.domElements.markerSelector).find('[src="'+this.value.markerImagePath+'"]').parent().addClass("active")}
842$$i(this.domElements.markerSelectorWrap).show();return}}
843renderMarkerSelector(){const _this=this;const view=this.formBuilder.editMode?this.domElements.edit:this.domElements.main;if(!view)
844return;const currentImage=this.value?this.value.markerImagePath:null;const images=MapSVG.markerImages.map(function(image){return('<button class="btn btn-outline-secondary mapsvg-marker-image-btn mapsvg-marker-image-btn-choose '+(currentImage==image.relativeUrl?"active":"")+'"><img src="'+image.relativeUrl+'" /></button>')});this.domElements.markerSelectorWrap=$$i(view).find(".mapsvg-marker-image-selector")[0];this.domElements.markerSelector=$$i(this.domElements.markerSelectorWrap).find(".mapsvg-marker-images")[0];if(this.domElements.markerSelector){$$i(this.domElements.markerSelector).empty()}
845if(!this.formBuilder.editMode){this.domElements.markerSelectorWrap.style.display="none";$$i(this.domElements.markerSelector).on("click",".mapsvg-marker-image-btn-choose",function(e){e.preventDefault();const src=$$i(this).find("img").attr("src");$$i(_this.domElements.markerSelectorWrap).hide();$$i(_this.domElements.markerSelector).find(".active").removeClass("active");$$i(this).addClass("active");$$i(_this.domElements.main).find(".mapsvg-marker-image-btn-trigger").toggleClass("active",!1);$$i(_this.domElements.markerImageButton).attr("src",src);_this.setMarkerImage(src)})}
846$$i(this.domElements.markerSelector).html(images.join(""))}
847setMarkerImage(src){this.setDefaultMarkerPath(src);const value=this.value;if(value){value.img=src;value.imagePath=src;this.setValue(value);this.triggerChanged();this.renderMarker()}}
848toggleMarkerSelectorInLocationEditor(jQueryObj,e){e.preventDefault();const _this=this;if(jQueryObj.data("markerSelector")&&jQueryObj.data("markerSelector").is(":visible")){jQueryObj.data("markerSelector").hide();return}
849if(jQueryObj.data("markerSelector")&&jQueryObj.data("markerSelector").not(":visible")){jQueryObj.data("markerSelector").show();return}
850const markerBtn=$$i(this).closest("td").find(".mapsvg-marker-image-btn-trigger");const currentImage=markerBtn.attr("src");const images=MapSVG.markerImages.map(function(image){return('<button class="btn btn-outline-secondary mapsvg-marker-image-btn mapsvg-marker-image-btn-choose '+(currentImage==image.relativeUrl?"active":"")+'"><img src="'+image.relativeUrl+'" /></button>')});if(!jQueryObj.data("markerSelector")){const ms=$$i('<div class="mapsvg-marker-image-selector"></div>');jQueryObj.closest("td").append(ms);jQueryObj.data("markerSelector",ms)}else{jQueryObj.data("markerSelector").empty()}
851jQueryObj.data("markerSelector").html(images.join(""));jQueryObj.data("markerSelector").on("click",".mapsvg-marker-image-btn-choose",function(e){e.preventDefault();const src=$$i(this).find("img").attr("src");jQueryObj.data("markerSelector").hide();const td=$$i(this).closest("td");const fieldId=$$i(this).closest("tr").data("option-id");const btn=td.find(".mapsvg-marker-image-btn-trigger");btn.toggleClass("active",!1);btn.find("img").attr("src",src);_this.setMarkerByField(fieldId,src)})}
852setMarkersByField(options){this.markersByField=options}
853resetMarkersByField(){this.markersByField={}}
854setMarkerByField(fieldId,markerImg){this.markersByField=this.markersByField||{};this.markersByField[fieldId]=markerImg}
855deleteMarker(){$$i(this.domElements.main).find(".mapsvg-new-marker").hide();$$i(this.domElements.main).find(".mapsvg-marker-id").attr("disabled","disabled")}
856destroy(){if($$i().mselect2){const sel=$$i(this.domElements.main).find(".mapsvg-select2");if(sel.length){sel.mselect2("destroy")}}
857this.domElements.markerSelector&&$$i(this.domElements.markerSelector).popover("dispose")}
858setDefaultMarkerPath(path){this.defaultMarkerPath=path;this.formBuilder.mapsvg.setDefaultMarkerImage(path)}
859getMarkerImage(data){let fieldValue;if(this.markersByFieldEnabled){fieldValue=data[this.markerField];if(!fieldValue){return this.defaultMarkerPath||MapSVG.defaultMarkerImage}else{if(this.markerField==="regions"){fieldValue=fieldValue[0]&&fieldValue[0].id}else if(typeof fieldValue==="object"&&fieldValue.length){fieldValue=fieldValue[0].value}
860if(this.markersByField[fieldValue]){return(this.markersByField[fieldValue]||this.defaultMarkerPath||MapSVG.defaultMarkerImage)}}}else{return this.defaultMarkerPath||MapSVG.defaultMarkerImage}}
861setValue(value,updateInput=!0){this.value=value;if(this.value){if(!this.value.address){this.value.address={}}
862if(Object.keys(this.value.address).length<2&&this.value.geoPoint){this.value.address.formatted=this.value.geoPoint.lat+","+this.value.geoPoint.lng}}
863this.renderMarker()}}
864const $$j=jQuery;class ModalFormElement extends FormElement{constructor(options,formBuilder,external){super(options,formBuilder,external);this.showButtonText=options.showButtonText}
865getSchema(){const schema=super.getSchema();schema.showButtonText=this.showButtonText;return schema}}
866const $$k=jQuery;class PostFormElement extends FormElement{constructor(options,formBuilder,external){super(options,formBuilder,external);
866if(this.formBuilder.admin)
867this.post_types=this.formBuilder.admin.getPostTypes();this.post_type=options.post_type||this.post_types[0];this.add_fields=MapSVG.parseBoolean(options.add_fields);this.db_type="int(11)";this.name="post";this.post=options.post}
868setDomElements(){super.setDomElements();this.inputs.postSelect=($$k(this.domElements.main).find(".mapsvg-find-post")[0])}
869getSchema(){const schema=super.getSchema();schema.post_type=this.post_type;schema.add_fields=this.add_fields;return schema}
870destroy(){if($$k().mselect2){const sel=$$k(this.domElements.main).find(".mapsvg-select2");if(sel.length){sel.mselect2("destroy")}}}
871getDataForTemplate(){const data=super.getDataForTemplate();if(this.formBuilder.admin)
872data.post_types=this.formBuilder.admin.getPostTypes();data.post_type=this.post_type;data.post=this.post;data.add_fields=this.add_fields||0;return data}
873setEventHandlers(){super.setEventHandlers();const server=new Server();$$k(this.inputs.postSelect).mselect2({placeholder:"Search post by title",allowClear:!0,disabled:this.readonly,ajax:{url:server.getUrl("posts"),dataType:"json",delay:250,data:(params)=>{return{filters:{post_type:this.post_type},search:params.term,page:params.page,}},processResults:(data,params)=>{params.page=params.page||1;return{results:data.posts?data.posts:[],pagination:{more:!1,},}},cache:!0,},escapeMarkup:(markup)=>{return markup},minimumInputLength:1,templateResult:this.formatRepo,templateSelection:this.formatRepoSelection,}).on("select2:select",(e)=>{const post=e.params.data;this.setValue(post);this.setInputValue(post);this.triggerChanged()}).on("change",(e)=>{if(e.target.value===""){$$k(this.domElements.main).find(".mapsvg-post-id").text("");$$k(this.domElements.main).find(".mapsvg-post-url").text("");this.setValue(null,!1);this.triggerChanged()}})}
874formatRepo(repo){if(repo.loading){return repo.text}else{return"<div class='select2-result-repository clearfix'>"+repo.post_title+"</div>"}}
875formatRepoSelection(repo){return repo.post_title||repo.text}
876setValue(post,updateInput=!0){this.value=post;if(updateInput){this.setInputValue(post)}}
877setInputValue(post){$$k(this.domElements.main).find(".mapsvg-post-id").text(post.id);$$k(this.domElements.main).find(".mapsvg-post-url").text(post.url).attr("href",post.url)}}
878const $$l=jQuery;class RadioFormElement extends FormElement{constructor(options,formBuilder,external){super(options,formBuilder,external);this.setOptions(options.options)}
879setDomElements(){super.setDomElements();this.inputs.radios=this.formBuilder.getForm().elements[this.name];this.$radios=$$l(this.domElements.main).find('input[type="radio"]')}
880setEventHandlers(){super.setEventHandlers();this.$radios.on("change",(e)=>{this.setValue(e.target.value,!1);this.triggerChanged()})}
881setInputValue(value){if(value===null){this.$radios.prop("checked",!1)}else{this.inputs.radios.value=value}}}
882const $$m=jQuery;class RegionsFormElement extends FormElement{constructor(options,formBuilder,external){super(options,formBuilder,external);this.searchable=MapSVG.parseBoolean(options.searchable);this.options=this.formBuilder.getRegionsList();this.label=options.label===undefined?"Regions":options.label;this.name="regions";this.db_type="text";if(typeof this.value==="undefined"){this.value=[]}
883this.regionsTableName=this.formBuilder.mapsvg.regionsRepository.getSchema().name}
884setDomElements(){super.setDomElements();this.inputs.select=$$m(this.domElements.main).find("select")[0]}
885getData(){return{name:"regions",value:this.value}}
886getSchema(){const schema=super.getSchema();if(schema.multiselect)
887schema.db_type="text";const opts=$$m.extend(!0,{},{options:this.options});schema.options=opts.options;schema.optionsDict={};schema.options.forEach(function(option){schema.optionsDict[option.id]=option.title||option.id});return schema}
888getDataForTemplate(){const data=super.getDataForTemplate();data.regionsTableName=this.regionsTableName;data.regionsFromCurrentTable=this.getRegionsForCurrentTable();return data}
889getRegionsForCurrentTable(){return this.value?this.value.filter((region)=>region.tableName===this.regionsTableName):[]}
890setEventHandlers(){super.setEventHandlers();$$m(this.inputs.select).on("change",(e)=>{const selectedOptions=Array.from(this.inputs.select.selectedOptions);const selectedValues=selectedOptions.map((option)=>option.value);this.setValue(selectedValues,!1);this.triggerChanged()})}
891destroy(){if($$m().mselect2){const sel=$$m(this.domElements.main).find(".mapsvg-select2");if(sel.length){sel.mselect2("destroy")}}}
892setValue(regionIds,updateInput=!0){const regionsFromOtherTables=this.value.filter((region)=>region.tableName!==this.regionsTableName);const regions=[];regionIds.forEach((regionId)=>{const region=this.formBuilder.mapsvg.getRegion(regionId);regions.push({id:region.id,title:region.title,tableName:this.regionsTableName})});
892this.value=regions.concat(regionsFromOtherTables);if(updateInput){this.setInputValue(regionIds)}}}
893const $$n=jQuery;class SaveFormElement extends FormElement{constructor(options,formBuilder,external){super(options,formBuilder,external);this.readonly=!0}
894setDomElements(){super.setDomElements();this.inputs.btnSave=$$n(this.domElements.main).find(".btn-save")[0];this.inputs.btnClose=$$n(this.domElements.main).find(".mapsvg-close")[0]}
895setEventHandlers(){super.setEventHandlers();$$n(this.inputs.btnSave).on("click",(e)=>{e.preventDefault();this.events.trigger("click.btn.save")});$$n(this.inputs.btnClose).on("click",(e)=>{e.preventDefault();this.events.trigger("click.btn.close")})}}
896const $$o=jQuery;class SearchFormElement extends FormElement{constructor(options,formBuilder,external){super(options,formBuilder,external);this.searchFallback=MapSVG.parseBoolean(options.searchFallback)||!1;this.width=options.width||"100%";this.name="search"}
897setDomElements(){super.setDomElements();this.inputs.text=$$o(this.domElements.main).find("input")[0]}
898setEventHandlers(){super.setEventHandlers();$$o(this.inputs.text).on("change keyup paste",(e)=>{this.setValue(e.target.value,!1);this.triggerChanged()})}
899setInputValue(value){this.inputs.text.value=value}
900getSchema(){const schema=super.getSchema();schema.searchFallback=MapSVG.parseBoolean(this.searchFallback);schema.placeholder=this.placeholder;schema.width=this.width;return schema}}
901const $$p=jQuery;class SelectFormElement extends FormElement{constructor(options,formBuilder,external){super(options,formBuilder,external);this.searchable=MapSVG.parseBoolean(options.searchable);this.multiselect=MapSVG.parseBoolean(options.multiselect);this.optionsGrouped=options.optionsGrouped;this.db_type=this.multiselect?"text":"varchar(255)";this.setOptions(options.options)}
902setDomElements(){super.setDomElements();this.inputs.select=$$p(this.domElements.main).find("select")[0]}
903getSchema(){const schema=super.getSchema();schema.multiselect=MapSVG.parseBoolean(this.multiselect);if(schema.multiselect)
904schema.db_type="text";schema.optionsGrouped=this.optionsGrouped;const opts=$$p.extend(!0,{},{options:this.options});schema.options=opts.options||[];schema.optionsDict={};schema.options.forEach(function(option){schema.optionsDict[option.value]=option.label});return schema}
905setEventHandlers(){super.setEventHandlers();$$p(this.inputs.select).on("change",(e)=>{if(this.multiselect){const selectedOptions=Array.from(this.inputs.select.selectedOptions);const selectedValues=selectedOptions.map((option)=>{return{label:option.label,value:option.value}});this.setValue(selectedValues,!1);this.triggerChanged()}else{this.setValue(this.inputs.select.value,!1);this.triggerChanged()}})}
906addSelect2(){if($$p().mselect2){const select2Options={};if(this.formBuilder.filtersMode&&this.type=="select"){select2Options.placeholder=this.placeholder;if(!this.multiselect){select2Options.allowClear=!0}}
907$$p(this.domElements.main).find("select").css({width:"100%",display:"block"}).mselect2(select2Options).on("select2:focus",function(){$$p(this).mselect2("open")});$$p(this.domElements.main).find(".select2-selection--multiple .select2-search__field").css("width","100%")}}
908setOptions(options){if(options){this.options=[];this.optionsDict={};options.forEach((value,key)=>{this.options.push(value);if(this.optionsGrouped){value.options.forEach((value2,key2)=>{this.optionsDict[value2.value]=value2})}else{this.optionsDict[key]=value}});return this.options}else{return this.setOptions([{label:"Option one",name:"option_one",value:1},{label:"Option two",name:"option_two",value:2},])}}
909setInputValue(value){if(this.multiselect){if(this.value){$$p(this.inputs.select).val(this.value.map((el)=>el.value))}else{$$p(this.inputs.select).val([])}}else{this.inputs.select.value=this.value}
910$$p(this.inputs.select).trigger("change.select2")}}
911const $$q=jQuery;class StatusFormElement extends FormElement{constructor(options,formBuilder,external){super(options,formBuilder,external);this.label=options.label||"Status";this.name="status";this.setOptions(options.options)}
912setDomElements(){super.setDomElements();this.inputs.select=$$q(this.domElements.main).find("select")[0];
912if($$q().colorpicker){$$q(this.domElements.main).find(".cpicker").colorpicker().on("changeColor.colorpicker",function(event){const input=$$q(this).find("input");if(input.val()=="")
913$$q(this).find("i").css({"background-color":""})});this.domElements.edit&&$$q(this.domElements.edit).find(".cpicker").colorpicker().on("changeColor.colorpicker",function(event){const input=$$q(this).find("input");if(input.val()=="")
914$$q(this).find("i").css({"background-color":""})})}}
915destroy(){if($$q().mselect2){const sel=$$q(this.domElements.main).find(".mapsvg-select2");if(sel.length){sel.mselect2("destroy")}}}
916setEditorEventHandlers(){super.setEditorEventHandlers();const _this=this;$$q(this.domElements.edit).on("keyup change paste",".mapsvg-edit-status-row input",function(){_this.mayBeAddStatusRow()})}
917initEditor(){super.initEditor();const _this=this;$$q(_this.domElements.edit).find(".cpicker").colorpicker().on("changeColor.colorpicker",function(event){const input=$$q(this).find("input");const index=$$q(this).closest("tr").index();if(input.val()=="")
918$$q(this).find("i").css({"background-color":""});_this.options[index]=_this.options[index]||{label:"",value:"",color:"",disabled:!1,};_this.options[index].color=input.val()});_this.mayBeAddStatusRow()}
919mayBeAddStatusRow(){const _this=this;const editStatusRow=$$q($$q("#mapsvg-edit-status-row").html());const z=$$q(_this.domElements.edit).find(".mapsvg-edit-status-label:last-child");if(z&&z.last()&&z.last().val()&&(z.last().val()+"").trim().length){const newRow=editStatusRow.clone();newRow.insertAfter($$q(_this.domElements.edit).find(".mapsvg-edit-status-row:last-child"));newRow.find(".cpicker").colorpicker().on("changeColor.colorpicker",function(event){const input=$$q(this).find("input");const index=$$q(this).closest("tr").index();if(input.val()=="")
920$$q(this).find("i").css({"background-color":""});_this.options[index]=_this.options[index]||{label:"",value:"",color:"",disabled:!1,};_this.options[index].color=input.val()})}
921const rows=$$q(_this.domElements.edit).find(".mapsvg-edit-status-row");const row1=rows.eq(rows.length-2);const row2=rows.eq(rows.length-1);if(row1.length&&row2.length&&!(row1.find("input:eq(0)").val().toString().trim()||row1.find("input:eq(1)").val().toString().trim()||row1.find("input:eq(2)").val().toString().trim())&&!(row2.find("input:eq(0)").val().toString().trim()||row2.find("input:eq(1)").val().toString().trim()||row2.find("input:eq(2)").val().toString().trim())){row2.remove()}}
922setEventHandlers(){super.setEventHandlers();$$q(this.inputs.select).on("change keyup paste",(e)=>{this.setValue(e.target.value,!1);this.triggerChanged()})}
923getSchema(){const schema=super.getSchema();const opts=$$q.extend(!0,{},{options:this.options});schema.options=opts.options;schema.optionsDict={};schema.options.forEach(function(option,index){if(schema.options[index].value===""){schema.options.splice(index,1)}else{schema.options[index].disabled=MapSVG.parseBoolean(schema.options[index].disabled);schema.optionsDict[option.value]=option}});return schema}
924setInputValue(value){this.inputs.select.value=value}}
925const $$r=jQuery;class TextareaFormElement extends FormElement{constructor(options,formBuilder,external){super(options,formBuilder,external);this.searchType=options.searchType||"fulltext";this.searchable=MapSVG.parseBoolean(options.searchable);this.autobr=options.autobr;this.html=options.html;this.db_type="text"}
926setDomElements(){super.setDomElements();this.inputs.textarea=$$r(this.domElements.main).find("textarea")[0];if(this.html){this.editor=CodeMirror.fromTextArea(this.inputs.textarea,{mode:{name:"handlebars",base:"text/html"},matchBrackets:!0,lineNumbers:!0,});if(this.formBuilder.admin){this.editor.on("change",this.setTextareaValue)}}}
927setEventHandlers(){super.setEventHandlers();$$r(this.inputs.textarea).on("change keyup paste",(e)=>{this.setValue(e.target.value,!1);this.triggerChanged()})}
928getSchema(){const schema=super.getSchema();schema.autobr=this.autobr;schema.html=this.html;return schema}
929getDataForTemplate(){const data=super.getDataForTemplate();data.html=this.html;return data}
930setTextareaValue(codemirror,changeobj){const handler=codemirror.getValue();const textarea=$$r(codemirror.getTextArea());textarea.val(handler).trigger("change")}
931destroy(){const cm=$$r(this.domElements.main).find(".CodeMirror");
931if(cm.length){cm.empty().remove()}}}
932const $$s=jQuery;class TextFormElement extends FormElement{constructor(options,formBuilder,external){super(options,formBuilder,external);this.searchFallback=MapSVG.parseBoolean(options.searchFallback);this.searchType=options.searchType;this.width=this.formBuilder.filtersHide&&!this.formBuilder.modal?null:options.width||"100%";this.db_type="varchar(255)"}
933setDomElements(){super.setDomElements();this.inputs.text=$$s(this.domElements.main).find('input[type="text"]')[0]}
934getSchema(){const schema=super.getSchema();schema.searchType=this.searchType;return schema}
935setEventHandlers(){super.setEventHandlers();$$s(this.inputs.text).on("change keyup paste",(e)=>{this.setValue(e.target.value,!1);this.triggerChanged()})}
936setInputValue(value){this.inputs.text.value=value}}
937const $$t=jQuery;class TitleFormElement extends FormElement{constructor(options,formBuilder,external){super(options,formBuilder,external);this.searchFallback=MapSVG.parseBoolean(options.searchFallback);this.width=this.formBuilder.filtersHide&&!this.formBuilder.modal?null:options.width||"100%";this.db_type="varchar(255)"}
938setDomElements(){super.setDomElements();this.inputs.text=$$t(this.domElements.main).find('input[type="text"]')[0]}
939getSchema(){const schema=super.getSchema();schema.searchType=this.searchType;return schema}
940setEventHandlers(){super.setEventHandlers();$$t(this.inputs.text).on("change keyup paste",(e)=>{this.setValue(e.target.value,!1);this.triggerChanged()})}
941setInputValue(value){this.inputs.text.value=value}}
942const $$u=jQuery;class ColorPickerFormElement extends FormElement{constructor(options,formBuilder,external){super(options,formBuilder,external);this.searchFallback=MapSVG.parseBoolean(options.searchFallback);this.width=this.formBuilder.filtersHide&&!this.formBuilder.modal?null:options.width||"100%";this.db_type="varchar(255)"}
943setDomElements(){super.setDomElements();this.inputs.text=$$u(this.domElements.main).find("input.cpicker")[0];$$u(this.domElements.main).find(".colorpicker-element").colorpicker()}
944getSchema(){const schema=super.getSchema();schema.searchType=this.searchType;return schema}
945setEventHandlers(){super.setEventHandlers();$$u(this.inputs.text).on("change keyup paste",(e)=>{this.setValue(e.target.value,!1);this.triggerChanged()});$$u(this.domElements.main).find(".colorpicker-element").colorpicker().on("changeColor.colorpicker",(e)=>{this.setValue(this.inputs.text.value,!1);this.triggerChanged()})}
946setInputValue(value){this.inputs.text.value=value}}
947const $$v=jQuery;class FormElementFactory{constructor(options){this.mapsvg=options.mapsvg;this.editMode=options.editMode;this.filtersMode=options.filtersMode;this.namespace=options.namespace;this.mediaUploader=options.mediaUploader;this.formBuilder=options.formBuilder;this.showNames=options.showNames!==!1}
948create(options){const types={checkbox:CheckboxFormElement,checkboxes:CheckboxesFormElement,date:DateFormElement,distance:DistanceFormElement,empty:EmptyFormElement,id:IdFormElement,image:ImagesFormElement,location:LocationFormElement,modal:ModalFormElement,post:PostFormElement,radio:RadioFormElement,region:RegionsFormElement,save:SaveFormElement,search:SearchFormElement,select:SelectFormElement,status:StatusFormElement,text:TextFormElement,textarea:TextareaFormElement,title:TitleFormElement,colorpicker:ColorPickerFormElement,};const formElement=new types[options.type](options,this.formBuilder,this.getExtraParams());formElement.init();return formElement}
949getExtraParams(){const databaseFields=[];const databaseFieldsFilterable=[];const databaseFieldsFilterableShort=[];const regionFields=[];const regionFieldsFilterable=[];const regions=new ArrayIndexed("id");let mapIsGeo=!1;if(this.mapsvg){mapIsGeo=this.mapsvg.isGeo();const schemaObjects=this.mapsvg.objectsRepository.getSchema();if(schemaObjects){schemaObjects.getFields().forEach(function(obj){if(obj.type=="text"||obj.type=="region"||obj.type=="textarea"||obj.type=="post"||obj.type=="select"||obj.type=="radio"||obj.type=="checkbox"){if(obj.type=="post"){databaseFields.push("Object.post.post_title")}else{databaseFields.push("Object."+obj.name)}}
950if(obj.type=="region"||obj.type=="select"||obj.type=="radio"){databaseFieldsFilterable.push("Object."+obj.name);databaseFieldsFilterableShort.push(obj.name)}})}
951const schemaRegions=this.mapsvg.regionsRepository.getSchema();
951if(schemaRegions){schemaRegions.getFieldsAsArray().forEach(function(obj){if(obj.type=="status"||obj.type=="text"||obj.type=="textarea"||obj.type=="post"||obj.type=="select"||obj.type=="radio"||obj.type=="checkbox"){if(obj.type=="post"){regionFields.push("Region.post.post_title")}else{regionFields.push("Region."+obj.name)}}
952if(obj.type=="status"||obj.type=="select"||obj.type=="radio"){regionFieldsFilterable.push("Region."+obj.name)}})}
953this.mapsvg.regions.forEach((region)=>{regions.push({id:region.id,title:region.title})})}
954return{databaseFields:databaseFields,databaseFieldsFilterable:databaseFieldsFilterable,databaseFieldsFilterableShort:databaseFieldsFilterableShort,regionFields:regionFields,regionFieldsFilterable:regionFieldsFilterable,regions:regions,mapIsGeo:mapIsGeo,mediaUploader:this.mediaUploader,filtersMode:this.filtersMode,showNames:this.showNames,}}}
955const $$w=jQuery;class FormBuilder{constructor(options){const _this=this;this.events=new Events();this.container=options.container;this.namespace=options.namespace;this.mediaUploader=options.mediaUploader;this.schema=options.schema||[];this.editMode=options.editMode==undefined?!1:options.editMode;this.filtersMode=options.filtersMode==undefined?!1:options.filtersMode;this.filtersHide=options.filtersHide==undefined?!1:options.filtersHide;this.modal=options.modal==undefined?!1:options.modal;this.admin=options.admin;this.mapsvg=options.mapsvg;this.data=options.data||{};this.clearButton=options.clearButton||!1;this.clearButtonText=options.clearButtonText||"";this.searchButton=options.searchButton||!1;this.searchButtonText=options.searchButtonText||"";this.showButtonText=options.showButtonText||"";this.scrollable=typeof options.scrollable!=="undefined"?options.scrollable:!_this.editMode&&!_this.filtersMode;this.showNames=typeof options.showNames!=="undefined"?options.showNames:!0;this.formElementFactory=new FormElementFactory({mapsvg:this.mapsvg,formBuilder:this,mediaUploader:this.mediaUploader,editMode:this.editMode,filtersMode:this.filtersMode,namespace:this.namespace,showNames:this.showNames,});this.events=new Events(this);if(options.events&&Object.keys(options.events).length>0){for(const eventName in options.events){this.events.on(eventName,options.events[eventName])}}
956this.template="form-builder";this.closeOnSave=options.closeOnSave===!0;this.newRecord=options.newRecord===!0;this.types=options.types||["text","textarea","checkbox","radio","select","image","region","location","post","date",];this.templates={};this.elements={};this.view=$$w("<div />").addClass("mapsvg-form-builder")[0];if(this.editMode)
957$$w(this.view).addClass("full-flex");if(!this.showNames){$$w(this.view).addClass("hide-names")}
958this.formElements=new ArrayIndexed("name");if(!MapSVG.templatesLoaded[this.template]){this.loadTemplates(()=>this.init())}else{this.init()}}
959loadTemplates(callback){$$w.get(MapSVG.urls.root+"dist/"+this.template+".html?v="+MapSVG.version,(data)=>{$$w(data).appendTo("body");MapSVG.templatesLoaded[this.template]=!0;Handlebars.registerPartial("dataMarkerPartial",$$w("#mapsvg-data-tmpl-marker").html());if(this.editMode){Handlebars.registerPartial("markerByFieldPartial",$$w("#mapsvg-markers-by-field-tmpl-partial").html())}
960callback()})}
961init(){const _this=this;MapSVG.formBuilder=this;this.form=document.createElement("form");this.form.className="mapsvg-data-form-view";if(!this.filtersMode){this.form.classList.add("form-horizontal")}
962if(this.editMode){const template=document.getElementById("mapsvg-form-editor-tmpl-ui").innerHTML;const templateCompiled=Handlebars.compile(template);this.view.innerHTML=templateCompiled({types:this.types});this.view.classList.add("edit");this.form.classList.add("mapsvg-data-flex-full");this.form.classList.add("mapsvg-data-container");$$w(this.view).find(".mapsvg-data-preview").prepend(this.form);this.formEditor=$$w(this.view).find("#mapsvg-data-form-edit")[0]}else{this.view.appendChild(this.form)}
963_this.elements={buttons:{text:$$w(_this.view).find("#mapsvg-data-btn-text")[0],textarea:$$w(_this.view).find("#mapsvg-data-btn-textarea")[0],checkbox:$$w(_this.view).find("#mapsvg-data-btn-checkbox")[0],radio:$$w(_this.view).find("#mapsvg-data-btn-radio")[0],select:$$w(_this.view).find("#mapsvg-data-btn-select")[0],image:$$w(_this.view).find("#mapsvg-data-btn-image")[0],region:$$w(_this.view).find("#mapsvg-data-btn-region")[0],marker:$$w(_this.view).find("#mapsvg-data-btn-marker")[0],saveSchema:$$w(_this.view).find("#mapsvg-data-btn-save-schema")[0],},containers:{buttons_add:$$w(_this.view).find("#mapsvg-data-buttons-add")[0],},};_this.redraw()}
964getForm(){return this.form}
965getFormEditor(){return this.formEditor}
966viewDidLoad(){}
967setEventHandlers(){const _this=this;$$w(this.getForm()).on("submit",(e)=>{e.preventDefault()});if(this.filtersMode&&this.clearButton){$$w(this.elements.buttons.clearButton).on("click",(e)=>{e.preventDefault();this.clearAllFields()})}
968$$w(window).off("keydown.form.mapsvg").on("keydown.form.mapsvg",function(e){if(M
968apSVG.formBuilder){if((e.metaKey||e.ctrlKey)&&e.keyCode==13)
969MapSVG.formBuilder.save();else if(e.keyCode==27)
970MapSVG.formBuilder.close()}});if(this.editMode){$$w(this.view).on("click","#mapsvg-data-buttons-add button",function(e){e.preventDefault();const type=$$w(this).data("create");const formElement=_this.formElementFactory.create({type:type});_this.addField(formElement)});$$w(this.view).on("click","#mapsvg-data-btn-save-schema",function(e){e.preventDefault();const fields=_this.getSchema();const counts={};_this.formElements.forEach(function(elem){counts[elem.name]=(counts[elem.name]||0)+1});$$w(_this.getForm()).find(".form-group").removeClass("has-error");const errors=[];const reservedFields=["lat","lon","lng","location","location_lat","location_lon","location_lng","location_address","location_img","marker","marker_id","regions","region_id","post","post_title","post_url","keywords","status",];const reservedFieldsToTypes={regions:"region",status:"status",post:"post",marker:"marker",location:"location",};let errUnique,errEmpty;_this.formElements.forEach(function(formElement,index){let err=!1;if(!_this.filtersMode){if(counts[formElement.name]>1){if(!errUnique){errUnique="Field names should be unique";errors.push(errUnique);err=!0}}else if(formElement.name.length===0){if(!errEmpty){errEmpty="Field name can't be empty";errors.push(errEmpty);err=!0}}else if(reservedFields.indexOf(formElement.name)!=-1){if(!reservedFieldsToTypes[formElement.name]||(reservedFieldsToTypes[formElement.name]&&reservedFieldsToTypes[formElement.name]!=formElement.type)){const msg='Field name "'+formElement.name+'" is reserved, please set another name';errors.push(msg);err=!0}}}
971if(formElement.options&&formElement.type!="region"&&formElement.type!="marker"){const vals=formElement.options.map(function(obj){return obj.value});const uniq=[...Array.from(new Set(vals).values())];if(vals.length!=uniq.length){errors.push('Check "Options" list - values should not repeat');err=!0}}
972err&&$$w(formElement.domElements.main).addClass("has-error")});if(errors.length===0){_this.events.trigger("saveSchema",_this,[_this,fields])}else{jQuery.growl.error({title:"Errors",message:errors.join("<br />")})}});setTimeout(function(){const el=_this.getForm();_this.sortable=new Sortable(el,{animation:150,onStart:function(){$$w(_this.getForm()).addClass("sorting")},onEnd:function(){setTimeout(function(){$$w(_this.getForm()).removeClass("sorting");_this.formElements.clear();$$w(el).find(".form-group").each(function(index,elem){_this.formElements.push($$w(elem).data("formElement"))})},500)},})},1000)}
973new ResizeSensor(this.view,function(){_this.scrollApi&&_this.scrollApi.reinitialise()})}
974clearAllFields(){this.formElements.forEach((f)=>f.setValue(null));this.events.trigger("cleared")}
975setFormElementEventHandlers(formElement){if(this.editMode){formElement.events.on("click",(elem)=>{this.edit(elem)});formElement.events.on("delete",(elem)=>{this.deleteField(elem)})}else{formElement.events.on("changed",(_formElement)=>{const name=_formElement.name;const value=_formElement.getValue();if(_formElement.type!=="search"){this.events.trigger("changed.field",_formElement,[_formElement,name,value])}else{this.events.trigger("changed.search",_formElement,[_formElement,value])}})}}
976save(){const _this=this;if(_this.markerBackup){const marker=_this.mapsvg.getEditingMarker();marker.events.off("change");_this.markerBackup=marker.getOptions();_this.mapsvg.unsetEditingMarker()}
977const data=_this.getData();_this.saved=!0;this.events.trigger("save",_this,[_this,data])}
978getFormElementByType(type){return this.formElements.find((el)=>el.type===type)}
979getData(){const data={};this.formElements.forEach((formElement)=>{if(formElement.readonly===!1||formElement.type==="id"){const _formElementData=formElement.getData();data[_formElementData.name]=_formElementData.value}});return data}
980reset(){this.formElements.forEach((formElement)=>{formElement.setValue(null)})}
981update(data){this.schema.getFields().forEach((field)=>{const formElement=this.formElements.get(field.name);if(formElement){if(typeof data[field.name]!=="undefined"){if(formElement.getValue()!==data[field.name]){formElement.setValue(data[field.name])}}else{formElement.setValue(null)}}})}
982redraw(){const _this=this;delete _this.markerBackup;$$w(this.container).empty();$$w(this.getForm()).empty();this.formElements.clear();this.schema&&this.schema.fields.length>0&&this.schema.fields.forEach((fieldSettings)=>{if(this.filtersMode){if(fieldSettings.type=="distance"){fieldSettings.value=this.data.distance?this.data.distance:fieldSettings.value!==undefined?fieldSettings.value:null}else{fieldSettings.value=this.data[fieldSettings.parameterNameShort]}}else{fieldSettings.value=this.data?this.data[fieldSettings.name]:fieldSettings.value!==undefined?fieldSettings.value:null}
983if(fieldSettings.type=="location"&&!this.editMode){if(fieldSettings.value&&fieldSettings.value.marker&&fieldSettings.value.marker.id);this.admin&&this.admin.setMode&&this.admin.setMode("editMarkers");this.admin&&this.admin.enableMarkersMode(!0)}else if(fieldSettings.type=="post"){fieldSettings.post=this.data.post}else if(fieldSettings.type==="region"){fieldSettings.options=new ArrayIndexed("id",this.getRegionsList())}
984const formElement=this.formElementFactory.create(fieldSettings);if(this.filtersMode){if(!this.filtersHide||(this.filtersHide&&this.modal&&fieldSettings.type!=="search")||(!this.modal&&fieldSettings.type==="search")){this.addField(formElement)}}else{this.addField(formElement)}});if(!_this.editMode){if(this.schema.fields.length===0&&!this.filtersMode){const formElement=this.formElementFactory.create({type:"empty"});_this.addField(formElement)}else{if(_this.admin&&!_this.admin.isMetabox){const formElement=this.formElementFactory.create({type:"save"});formElement.events.on("click.btn.save",()=>{this.save()});formElement.events.on("click.btn.close",()=>{this.close()});_this.addField(formElement)}}}
985if(_this.filtersMode&&_this.filtersHide&&!_this.modal){const formElement=this.formElementFactory.create({type:"modal",showButtonText:_this.showButtonText,});
985this.showFiltersButton=_this.addField(formElement)}
986if(this.scrollable){const nano=$$w('<div class="nano"></div>');const nanoContent=$$w('<div class="nano-content"></div>');nano.append(nanoContent);nanoContent.append(this.view);$$w(_this.container).append(nano);nano.jScrollPane({contentWidth:"0px",mouseWheelSpeed:30});_this.scrollApi=nano.data("jsp")}else{$$w(_this.container).append(this.view)}
987if(_this.filtersMode&&_this.clearButton){_this.elements.buttons.clearButton=$$w('<div class="form-group mapsvg-filters-reset-container">'+'<button type="button" class="btn btn-outline-secondary mapsvg-filters-reset">'+_this.clearButtonText+"</button></div>")[0];$$w(this.getForm()).append(_this.elements.buttons.clearButton)}
988if(_this.filtersMode&&_this.searchButton){_this.elements.buttons.searchButton=$$w('<div class="form-group mapsvg-filters-reset-container" id="mapsvg-search-container"><button class="btn btn-outline-secondary mapsvg-filters-reset">'+_this.searchButtonText+"</button></div>")[0];$$w(this.getForm()).append(_this.elements.buttons.searchButton)}
989if(!this.editMode&&!_this.filtersMode)
990$$w(this.view).find("input:visible,textarea:visible").not(".tt-hint").first().focus();const cm=$$w(this.container).find(".CodeMirror");cm.each(function(index,el){el&&el.CodeMirror.refresh()});_this.setEventHandlers();this.events.trigger("init",this,[this,this.getData()]);this.events.trigger("loaded",this,[this])}
991updateExtraParamsInFormElements(){this.formElements.forEach((formElement)=>{formElement.setExternal(this.formElementFactory.getExtraParams());if(formElement.type==="location"){formElement.redraw()}})}
992deleteField(formElement){const _this=this;_this.formElements.delete(formElement.name)}
993getExtraParams(){const databaseFields=[];this.mapsvg.objectsRepository.getSchema().getFields().forEach(function(obj){if(obj.type=="text"||obj.type=="region"||obj.type=="textarea"||obj.type=="post"||obj.type=="select"||obj.type=="radio"||obj.type=="checkbox"){if(obj.type=="post"){databaseFields.push("Object.post.post_title")}else{databaseFields.push("Object."+obj.name)}}});let databaseFieldsFilterableShort=[];databaseFieldsFilterableShort=this.mapsvg.objectsRepository.getSchema().getFieldsAsArray().filter(function(obj){return obj.type=="select"||obj.type=="radio"||obj.type=="region"}).map(function(obj){return obj.name});let markerFieldsShort=[];markerFieldsShort=databaseFieldsFilterableShort.filter((o)=>o.type==="select"||o.type==="radio");const regionFields=this.mapsvg.regionsRepository.getSchema().getFieldsAsArray().map(function(obj){if(obj.type=="status"||obj.type=="text"||obj.type=="textarea"||obj.type=="post"||obj.type=="select"||obj.type=="radio"||obj.type=="checkbox"){if(obj.type=="post"){return"Region.post.post_title"}else{return"Region."+obj.name}}});return{databaseFields:databaseFields,databaseFieldsFilterableShort:databaseFieldsFilterableShort,regionFields:regionFields,markerFieldsShort:markerFieldsShort,}}
994addField(formElement){const _this=this;if(["region","marker","post","status","distance","location","search"].indexOf(formElement.type)!=-1){let repeat=!1;_this.formElements.forEach(function(control){if(control.type==formElement.type)
995repeat=!0});if(repeat){jQuery.growl.error({title:"Error",message:'You can add only 1 "'+MapSVG.ucfirst(formElement.type)+'" field',});return}}
996_this.formElements.push(formElement);_this.getForm().append(formElement.domElements.main);this.setFormElementEventHandlers(formElement);if(this.editMode){if(formElement.protected){formElement.hide()}else{this.edit(formElement)}}
997return formElement}
998edit(formElement){const _this=this;_this.currentlyEditing&&_this.currentlyEditing.destroyEditor();this.getFormEditor().appendChild(formElement.getEditor());formElement.initEditor();_this.currentlyEditing=formElement;$$w(_this.getForm()).find(".form-group.active").removeClass("active");$$w(formElement.domElements.main).addClass("active")}
999get(){}
1000getSchema(){return this.formElements.map(function(formElement){return formElement.getSchema()})}
1001close(){this.formElements.forEach((formElement)=>formElement.destroy());this.mediaUploader&&this.mediaUploader.off("select");MapSVG.formBuilder=null;this.events.trigger("close",this,[this])}
1002destroy(){$$w(this.view).empty().remove();this.sortable=null}
1003toJSON(addEmpty){const obj={};function add(obj,name,value){if(!addEmpty&&!value)
1004return!1;if(name.length==1){obj[name[0]]=value}else{if(obj[name[0]]==null){if(name[1]===""){obj[name[0]]=[]}else{obj[name[0]]={}}}
1005if(obj[name[0]].length!==undefined){obj[name[0]].push(value)}else{add(obj[name[0]],name.slice(1),value)}}}
1006$$w(this.elements.containers.formView).find("input, textarea, select").each(function(){if(!$$w(this).data("skip")&&!$$w(this).prop("disabled")&&$$w(this).attr("name")&&!(!addEmpty&&$$w(this).attr("type")=="checkbox"&&$$w(this).attr("checked")==undefined)&&!($$w(this).attr("type")=="radio"&&$$w(this).attr("checked")==undefined)){let value;if($$w(this).attr("type")=="checkbox"){value=$$w(this).prop("checked")}else{value=$$w(this).val()}
1007add(obj,$$w(this).attr("name").replace(/]/g,"").split("["),value)}});return obj}
1008getRegionsList(){return this.mapsvg.regions.map(function(r){return{id:r.id,title:r.title}}
1008)}
1009getRegionsAsArray(){return this.mapsvg.regions}
1010setRegions(location){const regionsFormElement=this.formElements.get("regions");if(this.mapsvg.options.source.indexOf("/geo-calibrated/usa.svg")!==-1){regionsFormElement.setValue(["US-"+location.address.state_short])}else if(this.mapsvg.options.source.indexOf("/geo-calibrated/world.svg")!==-1){if(location.address.country_short){regionsFormElement.setValue([location.address.country_short])}}else{if(location.address.administrative_area_level_1){this.mapsvg.regions.forEach((_region)=>{if(_region.title===location.address.administrative_area_level_1||_region.title===location.address.administrative_area_level_2||_region.id===location.address.country_short+"-"+location.address.administrative_area_level_1_short){regionsFormElement.setValue([_region.id])}})}}}
1011setIsLoading(value){this.isLoading=value;if(this.searchButton){if(this.isLoading){$$w(this.elements.buttons.searchButton).find("button").attr("disabled","disabled")}else{$$w(this.elements.buttons.searchButton).find("button").removeAttr("disabled")}}}}
1012const $$x=jQuery;class FiltersController extends DetailsController{constructor(options){super(options);this.showButtonText=options.showButtonText;this.clearButton=options.clearButton;this.clearButtonText=options.clearButtonText;this.searchButton=options.searchButton;this.searchButtonText=options.searchButtonText;this.padding=options.padding;this.schema=options.schema;this.hideFilters=options.hide;this.query=options.query}
1013viewDidLoad(){super.viewDidLoad();const _this=this;this.formBuilder=new FormBuilder({container:this.containers.contentView,filtersMode:!0,schema:this.schema,modal:this.modal,filtersHide:this.hideFilters,showButtonText:this.showButtonText,clearButton:this.clearButton,clearButtonText:this.clearButtonText,searchButton:this.searchButton,searchButtonText:this.searchButtonText,editMode:!1,mapsvg:this.mapsvg,data:{},admin:!1,events:{"changed.field":(formElement,field,value)=>{const filters={};let _value=value;if(field==="regions"){_value={};_value.region_ids=value instanceof Array?value:[value];_value.table_name=this.mapsvg.options.database.regionsTableName;if(_value.region_ids.length===0||_value.region_ids[0]===""){_value=null}}
1014filters[field]=_value;this.query.setFilters(filters);_this.events.trigger("changed.field",_this,[field,value]);_this.events.trigger("changed.fields",_this,[field,value])},"changed.search":(formElement,value)=>{this.query.setSearch(value);_this.events.trigger("changed.search",_this,[value])},cleared:(formBuilder)=>{this.query.clearFilters();this.events.trigger("cleared",_this,[])},loaded:(formBuilder)=>{$$x(formBuilder.container).find(".mapsvg-form-builder").css({padding:_this.padding,});this.updateScroll();this.events.trigger("loaded")},},})}
1015reset(){this.formBuilder&&this.formBuilder.reset()}
1016update(query){const _query=Object.assign({},query.filters);_query.search=query.search;this.formBuilder&&this.formBuilder.update(_query)}
1017setFiltersCounter(){if(this.hideFilters){const filtersCounter=Object.keys(this.query.filters).length;const filtersCounterString=filtersCounter===0?"":filtersCounter.toString();this.formBuilder&&this.formBuilder.showFiltersButton&&$$x(this.formBuilder.showFiltersButton.domElements.main).find("button").html(this.showButtonText+" <b>"+filtersCounterString+"</b>")}}
1018setEventHandlers(){super.setEventHandlers();const _this=this;$$x(this.containers.view).on("click",".mapsvg-btn-show-filters",function(){_this.events.trigger("click.btn.showFilters")});$$x(this.containers.view).on("click","#mapsvg-search-container button",function(){_this.events.trigger("click.btn.searchButton")})}}
1019const $$y=jQuery;class PopoverController extends Controller{constructor(options){super(options);this.autoresize=!0;this.point=options.point;this.yShift=options.yShift;this.mapObject=options.mapObject;this.id=this.mapObject.id+"_"+Math.random();$$y(this.containers.main).data("popover-id",this.id)}
1020setPoint(point){this.point=point}
1021getToolbarTemplate(){if(this.withToolbar)
1022return'<div class="mapsvg-popover-close"></div>';else return""}
1023viewDidLoad(){super.viewDidLoad.call(this);
1023if(MapSVG.isPhone&&this.mapsvg.options.popovers.mobileFullscreen&&!this.mobileCloseBtn){this.mobileCloseBtn=$$y('<button class="mapsvg-mobile-modal-close">'+this.mapsvg.getData().options.mobileView.labelClose+"</button>")[0];$$y(this.containers.view).append(this.mobileCloseBtn)}
1024this.adjustScreenPosition();$$y(this.containers.main).toggleClass("mapsvg-popover-animate",!0);$$y(this.containers.main).toggleClass("mapsvg-popover-visible",!0);this.adjustHeight();this.updateScroll();this.autoresize&&this.resizeSensor.setScroll();this.events.trigger("shown",this,[this])}
1025adjustHeight(){$$y(this.containers.main).height($$y(this.containers.main).find(".mapsvg-auto-height").outerHeight()+(this.containers.toolbar?$$y(this.containers.toolbar).outerHeight():0))}
1026adjustScreenPosition(){if(this.point){const pos=this.mapsvg.converter.convertSVGToPixel(this.point);pos.y-=this.yShift;pos.x=Math.round(pos.x);pos.y=Math.round(pos.y);this.setScreenPosition(pos.x,pos.y)}}
1027moveSrceenPositionBy(deltaX,deltaY){const oldPos=this.screenPoint,x=oldPos.x-deltaX,y=oldPos.y-deltaY;this.setScreenPosition(x,y)}
1028setScreenPosition(x,y){this.screenPoint=new ScreenPoint(x,y);$$y(this.containers.main).css({transform:"translateX(-50%) translate("+x+"px,"+y+"px)",})}
1029setEventHandlers(){$$y("body").off(".popover.mapsvg");$$y(this.containers.view).on("click touchend",".mapsvg-popover-close, .mapsvg-mobile-modal-close",(e)=>{e.stopImmediatePropagation();this.close()});$$y("body").on("mouseup.popover.mapsvg touchend.popover.mapsvg",(e)=>{if(this.mapsvg.isScrolling||$$y(e.target).closest(".mapsvg-directory").length||$$y(e.target).closest(".mapsvg-popover").length||$$y(e.target).hasClass("mapsvg-btn-map"))
1030return;this.close()})}
1031close(){if($$y(this.containers.main).data("popover-id")!=this.id||!$$y(this.containers.main).is(":visible"))
1032return;this.destroy();if(this.mapObject instanceof Region){this.mapsvg.deselectRegion(this.mapObject)}
1033if(this.mapObject instanceof Marker){this.mapsvg.deselectAllMarkers()}
1034this.events.trigger("closed",this,[this])}
1035destroy(){$$y(this.containers.main).toggleClass("mapsvg-popover-animate",!1);$$y(this.containers.main).toggleClass("mapsvg-popover-visible",!1);super.destroy.call(this)}
1036show(){$$y(this.containers.main).toggleClass("mapsvg-popover-animate",!0);$$y(this.containers.main).toggleClass("mapsvg-popover-visible",!0)}}
1037const $$z=jQuery;class Tooltip extends Controller{constructor(options){super(options);this.scrollable=!1;this.withToolbar=!1;this.autoresize=!1;this.screenPoint=new ScreenPoint(0,0);this.posOriginal={};this.posShifted={};this.posShiftedPrev={};this.mirror={};this.noPadding=!0;this.setPosition(options.position);this.setSize(options.minWidth,options.maxWidth)}
1038setSize(minWidth,maxWidth){this.minWidth=minWidth;this.maxWidth=maxWidth;this.containers.main.style["min-width"]=this.minWidth+"px";this.containers.main.style["max-width"]=this.maxWidth+"px"}
1039setPosition(position){const ex=position.split("-");if(ex[0].indexOf("top")!=-1||ex[0].indexOf("bottom")!=-1){this.posOriginal.topbottom=ex[0]}
1040if(ex[0].indexOf("left")!=-1||ex[0].indexOf("right")!=-1){this.posOriginal.leftright=ex[0]}
1041if(ex[1]){this.posOriginal.leftright=ex[1]}
1042this.containers.main.className=this.containers.main.className.replace(/(^|\s)mapsvg-tt-\S+/g,"");this.containers.main.classList.add("mapsvg-tt-"+position)}
1043setScreenPoint(x,y){this.screenPoint.x=x;this.screenPoint.y=y}
1044viewDidLoad(){super.viewDidLoad.call(this)}
1045viewDidAppear(){super.viewDidAppear();this.events.trigger("shown",this,[this])}
1046setScreenPosition(x,y){this.setScreenPoint(x,y);this.containers.main.style.transform="translateX(-50%) translate("+x+"px,"+y+"px)"}
1047setEventHandlers(){const event="mousemove.tooltip.mapsvg-"+this.mapsvg.id;$$z("body").off(event).on(event,(e)=>{MapSVG.mouse=MapSVG.mouseCoords(e);this.containers.main.style.left=e.clientX+$$z(window).scrollLeft()-$$z(this.mapsvg.containers.map).offset().left+"px";this.containers.main.style.top=e.clientY+$$z(window).scrollTop()-$$z(this.mapsvg.containers.map).offset().top+"px";const m=new ScreenPoint(e.clientX+$$z(window).scrollLeft(),e.clientY+$$z(window).scrollTop());const _tbbox=this.containers.main.getBoundingClientRect();const _mbbox=this.mapsvg.containers.map.getBoundingClientRect();const tbbox={top:_tbbox.top+$$z(window).scrollTop(),bottom:_tbbox.bottom+$$z(window).scrollTop(),left:_tbbox.left+$$z(window).scrollLeft(),right:_tbbox.right+$$z(window).scrollLeft(),width:_tbbox.width,height:_tbbox.height,};const mbbox={top:_mbbox.top+$$z(window).scrollTop(),bottom:_mbbox.bottom+$$z(window).scrollTop(),left:_mbbox.left+$$z(window).scrollLeft(),right:_mbbox.right+$$z(window).scrollLeft(),width:_mbbox.width,height:_mbbox.height,};if(m.x>mbbox.right||m.y>mbbox.bottom||m.x<mbbox.left||m.y<mbbox.top){return}
1048if(this.mirror.top||this.mirror.bottom){if(this.mirror.top&&m.y>this.mirror.top){this.mirror.top=0;delete this.posShifted.topbottom}else if(this.mirror.bottom&&m.y<this.mirror.bottom){this.mirror.bottom=0;delete this.posShifted.topbottom}}else{if(tbbox.bottom<mbbox.top+tbbox.height){this.posShifted.topbottom="bottom";this.mirror.top=m.y}else if(tbbox.top>mbbox.bottom-tbbox.height){this.posShifted.topbottom="top";this.mirror.bottom=m.y}}
1049if(this.mirror.right||this.mirror.left){if(this.mirror.left&&m.x>this.mirror.left){this.mirror.left=0;delete this.posShifted.leftright}else if(this.mirror.right&&m.x<this.mirror.right){this.mirror.right=0;delete this.posShifted.leftright}}else{if(tbbox.right<mbbox.left+tbbox.width){this.posShifted.leftright="right";this.mirror.left=m.x}else if(tbbox.left>mbbox.right-tbbox.width){this.posShifted.leftright="left";this.mirror.right=m.x}}
1050let pos=$$z.extend({},this.posOriginal,this.posShifted);const _pos=[];pos.topbottom&&_pos.push(pos.topbottom);pos.leftright&&_pos.push(pos.leftright);pos=_pos.join("-");if(this.posShifted.topbottom!=this.posOriginal.topbottom||this.posShifted.leftright!=this.posOriginal.leftright){this.containers.main.className=this.containers.main.className.replace(/(^|\s)mapsvg-tt-\S+/g,"");this.containers.main.classList.add("mapsvg-tt-"+pos);this.posShiftedPrev=pos}})}
1051setContent(template,data){this.containers.main.innerHTML=template(data);return this}
1052show(){this.containers.main.classList.add("mapsvg-tooltip-visible");return this}
1053hide(){this.containers.main.classList.remove("mapsvg-tooltip-visible");return this}}
1054const $$A=jQuery;class MapSVGMap{constructor(containerId,mapParams,externalParams){this.markerOptions={src:MapSVG.urls.root+"markers/pin1_red.png"};const options=mapParams.options;this.updateOutdatedOptions(options);this.dirtyFields=[];this.containerId=containerId;this.options=$$A.extend(!0,{},DefaultOptions,options);this.options.source=this.urlToRelativePath(this.options.source);this.editMode=this.options.editMode;delete this.options.editMode;this.id=mapParams.id;this.svgFileLastChanged=mapParams.svgFileLastChanged;this.regions=new ArrayIndexed("id");this.objects=new ArrayIndexed("id");this.events=new Events(this);this.highlightedRegions=[];this.editRegions={on:!1};this.editMarkers={on:!1};this.editData={on:!1};this.controllers={};this.containers={map:document.getElementById(this.containerId),scrollpane:$$A('<div class="mapsvg-scrollpane"></div>')[0],scrollpaneWrap:$$A('<div class="mapsvg-scrollpane-wrap"></div>')[0],layers:$$A('<div class="mapsvg-layers-wrap"></div>')[0],};this.containers.map.appendChild(this.containers.layers);this.containers.map.appendChild(this.containers.scrollpaneWrap);this.containers.scrollpaneWrap.appendChild(this.containers.scrollpane);this.whRatio=0;this.isScrolling=!1;this.markerOptions={};this.svgDefault={};this.scale=1;this._scale=1;this.selected_id=[];this.regions=new ArrayIndexed("id");if(!this.options.database.regionsTableName){this.options.database.regionsTableName="regions_"+this.id}
1055if(!this.options.database.objectsTableName){this.options.database.objectsTableName="objects_"+this.id}
1056this.regionsRepository=new Repository("region","regions/"+this.options.database.regionsTableName);this.regionsRepository.query.update({perpage:0});this.objectsRepository=new Repository("object","objects/"+this.options.database.objectsTableName);if(this.options.database.noFiltersNoLoad){this.objectsRepository.setNoFiltersNoLoad(!0)}
1057this.objectsRepository.query.update({perpage:this.options.database.pagination.on?this.options.database.pagination.perpage:0,});this.schemaRepository=new SchemaRepository();this.markers=new ArrayIndexed("id");this.markersClusters=new ArrayIndexed("id");this._viewBox=new ViewBox(0,0,0,0);this.viewBox=new ViewBox(0,0,0,0);this.zoomLevel=0;this.scroll={tx:0,ty:0,vxi:0,vyi:0,x:0,y:0,dx:0,dy:0,vx:0,vy:0,gx:0,gy:0,touchScrollStart:0,};this.layers={};this.geoCoordinates=!1;this.geoViewBox=new GeoViewBox(new GeoPoint(0,0),new GeoPoint(0,0));this.eventsPreventList={};this.googleMaps={loaded:!1,initialized:!1,map:null,zoomLimit:!0,maxZoomService:null,};this.afterLoadBlockers=1;this.loaded=!1;if(this.id){this.afterLoadBlockers+=2}
1058if(this.options.googleMaps.on){this.afterLoadBlockers++}
1059if(this.filtersShouldBeShown()){this.afterLoadBlockers++}
1060this.init()}
1061urlToRelativePath(url){if(url.indexOf("//")===0)
1062url=url.replace(/^\/\/[^/]+/,"").replace("//","/");else url=url.replace(/^.*:\/\/[^/]+/,"").replace("//","/");return url}
1063setGroups(groups){const _this=this;if(!this.groups){_this.groups=new ArrayIndexed("id",_this.options.groups,{autoId:!0,unique:!0,})}else{this.options.groups=this.groups}
1064_this.groups.forEach(function(g){g.objects&&g.objects.length&&g.objects.forEach(function(obj){_this.containers.svg.querySelector("#"+obj.value).classList.toggle("mapsvg-hidden",!g.visible)})})}
1065getGroupSelectOptions(){const _this=this;const optionGroups=[];const options=[];const options2=[];$$A(_this.containers.svg).find("g").each(function(index){const id=$$A(this)[0].getAttribute("id");if(id){const title=$$A(this)[0].getAttribute("title");options.push({label:title||id,value:id})}});optionGroups.push({title:"SVG Layers / Groups",options:options});$$A(_this.containers.svg).find("path,ellipse,circle,polyline,polygon,rectangle,img,text").each(function(index){const id=$$A(this)[0].getAttribute("id");if(id){const title=$$A(this)[0].getAttribute("title");options2.push({label:title||id,value:id})}});optionGroups.push({title:"Other SVG objects",options:options2});return optionGroups}
1066setLayersControl(options){const _this=this;if(options)
1067$$A.extend(!0,this.options.layersControl,options);if(this.options.layersControl.on){if(!this.containers.layersControl){this.containers.layersControl=document.createElement("div");this.containers.layersControl.classList.add("mapsvg-layers-control");this.containers.layersControlLabel=document.createElement("div");this.containers.layersControlLabel.classList.add("mapsvg-layers-label");this.containers.layersControl.appendChild(this.containers.layersControlLabel);const layersControlWrap=document.createElement("div");layersControlWrap.classList.add("mapsvg-layers-list-wrap");this.containers.layersControl.appendChild(layersControlWrap);this.containers.layersControlListNano=document.createElement("div");this.containers.layersControlListNano.classList.add("nano");layersControlWrap.appendChild(this.containers.layersControlListNano);this.containers.layersControlList=document.createElement("div");this.containers.layersControlList.classList.add("mapsvg-layers-list");this.containers.layersControlList.classList.add("nano-content");this.containers.layersControlListNano.appendChild(this.containers.layersControlList);this.containers.mapContainer.appendChild(this.containers.layersControl)}
1068this.containers.layersControl.style.display="block";this.containers.layersControlLabel.innerHTML=this.options.layersControl.label;this.containers.layersControlLabel.style.display="block";this.containers.layersControlList.innerHTML="";while(this.containers.layersControlList.firstChild){this.containers.layersControlList.removeChild(this.containers.layersControlList.firstChild)}
1069this.containers.layersControl.classList.remove("mapsvg-top-left","mapsvg-top-right","mapsvg-bottom-left","mapsvg-bottom-right");this.containers.layersControl.classList.add("mapsvg-"+this.options.layersControl.position);if(this.options.menu.on&&!this.options.menu.customContainer&&this.options.layersControl.position.indexOf("left")!==-1){this.containers.layersControl.style.left=this.options.menu.width}
1070this.containers.layersControl.style.maxHeight=this.options.layersControl.maxHeight;this.options.groups.forEach((g)=>{const item=document.createElement("div");item.classList.add("mapsvg-layers-item");item.setAttribute("data-group-id",g.id);item.innerHTML='<input type="checkbox" class="ios8-switch ios8-switch-sm" '+(g.visible?"checked":"")+" /><label>"+g.title+"</label>";this.containers.layersControlList.appendChild(item)});$$A(this.containers.layersControlListNano).nanoScroller({preventPageScrolling:!0,iOSNativeScrolling:!0,});$$A(this.containers.layersControl).off();$$A(this.containers.layersControl).on("click",".mapsvg-layers-item",function(){const id=$$A(this).data("group-id");const input=$$A(this).find("input");input.prop("checked",!input.prop("checked"));_this.groups.forEach(function(g){if(g.id===id)
1071g.visible=!g.visible});_this.setGroups()});$$A(this.containers.layersControlLabel).off();$$A(this.containers.layersControlLabel).on("click",()=>{$$A(_this.containers.layersControl).toggleClass("closed")});$$A(this.containers.layersControl).toggleClass("closed",!this.options.layersControl.expanded)}else{if(this.containers.layersControl){this.containers.layersControl.style.display="none"}}}
1072loadDataObjects(params){return this.objectsRepository.find(params)}
1073loadDirectory(){if(!this.editMode&&this.options.menu.source==="database"&&!this.objectsRepository.loaded){return}
1074if(this.options.menu.on){this.controllers.directory.loadItemsToDirectory()}
1075this.setPagination()}
1076setPagination(){const _this=this;this.containers.pagerMap&&$$A(this.containers.pagerMap).empty().remove();this.containers.pagerDir&&$$A(this.containers.pagerDir).empty().remove();if(_this.options.database.pagination.on&&_this.options.database.pagination.perpage!==0){this.containers.directory.classList.toggle("mapsvg-with-pagination",["directory","both"].indexOf(_this.options.database.pagination.showIn)!==-1);this.containers.map.classList.toggle("mapsvg-with-pagination",["map","both"].indexOf(_this.options.database.pagination.showIn)!==-1);if(_this.options.menu.on){this.containers.pagerDir=_this.getPagination();_this.controllers.directory.addPagination(this.containers.pagerDir)}
1077this.containers.pagerMap=_this.getPagination();this.containers.map.appendChild(this.containers.pagerMap)}}
1078getPagination(callback){const _this=this;const pager=$$A('<nav class="mapsvg-pagination"><ul class="pager"><!--<li class="mapsvg-first"><a href="#">
1078First</a></li>--><li class="mapsvg-prev"><a href="#">&larr; '+_this.options.database.pagination.prev+" "+_this.options.database.pagination.perpage+'</a></li><li class="mapsvg-next"><a href="#">'+_this.options.database.pagination.next+" "+_this.options.database.pagination.perpage+' &rarr;</a></li><!--<li class="mapsvg-last"><a href="#">Last</a></li>--></ul></nav>');if(this.objectsRepository.onFirstPage()&&this.objectsRepository.onLastPage()){pager.hide()}else{pager.find(".mapsvg-prev").removeClass("disabled");pager.find(".mapsvg-first").removeClass("disabled");pager.find(".mapsvg-last").removeClass("disabled");pager.find(".mapsvg-next").removeClass("disabled");this.objectsRepository.onLastPage()&&pager.find(".mapsvg-next").addClass("disabled")&&pager.find(".mapsvg-last").addClass("disabled");this.objectsRepository.onFirstPage()&&pager.find(".mapsvg-prev").addClass("disabled")&&pager.find(".mapsvg-first").addClass("disabled")}
1079pager.on("click",".mapsvg-next:not(.disabled)",(e)=>{e.preventDefault();if(this.objectsRepository.onLastPage())
1080return;const query=new Query({page:this.objectsRepository.query.page+1});this.objectsRepository.find(query).done(function(){callback&&callback()})}).on("click",".mapsvg-prev:not(.disabled)",function(e){e.preventDefault();if(_this.objectsRepository.onFirstPage())
1081return;const query=new Query({page:_this.objectsRepository.query.page-1});_this.objectsRepository.find(query).done(function(){callback&&callback()})}).on("click",".mapsvg-first:not(.disabled)",function(e){e.preventDefault();if(_this.objectsRepository.onFirstPage())
1082return;const query=new Query({page:1});_this.objectsRepository.find(query).done(function(){callback&&callback()})}).on("click",".mapsvg-last:not(.disabled)",function(e){e.preventDefault();if(_this.objectsRepository.onLastPage())
1083return;const query=new Query({lastpage:!0});_this.objectsRepository.find(query).done(function(){callback&&callback()})});return pager[0]}
1084deleteMarkers(){while(this.markers.length){this.markerDelete(this.markers[0])}}
1085deleteClusters(){if(this.markersClusters){this.markersClusters.forEach(function(markerCluster){markerCluster.destroy()});this.markersClusters.clear()}}
1086addLocations(){const _this=this;this.firstDataLoad=this.firstDataLoad===undefined;let locationField=this.objectsRepository.getSchema().getFieldByType("location");if(!locationField){return}
1087locationField=locationField.name;if(locationField){if(this.firstDataLoad){this.setMarkerImagesDependency()}
1088_this.deleteMarkers();_this.deleteClusters();_this.clusters={};_this.clustersByZoom=[];if(this.objectsRepository.getLoaded().length>0){this.objectsRepository.getLoaded().forEach(function(object){if(object[locationField]){if(object[locationField].img&&(object[locationField].geoPoint||object[locationField].svgPoint)){new Marker({location:object[locationField],object:object,mapsvg:_this,})}}});if(_this.options.clustering.on){_this.startClusterizer()}else{this.objectsRepository.getLoaded().forEach(function(object){if(object.location&&object.location.marker){_this.markerAdd(object.location.marker)}});_this.mayBeFitMarkers()}}}}
1089addClustersFromWorker(zoomLevel,clusters){const _this=this;_this.clustersByZoom[zoomLevel]=[];for(const cell in clusters){const markers=clusters[cell].markers.map(function(marker){return _this.objectsRepository.objects.findById(marker.id).location.marker});_this.clustersByZoom[zoomLevel].push(new MarkerCluster({markers:markers,svgPoint:new SVGPoint(clusters[cell].x,clusters[cell].y),cellX:clusters[cell].cellX,cellY:clusters[cell].cellY,},_this))}
1090if(_this.zoomLevel===zoomLevel){_this.clusterizeMarkers()}}
1091startClusterizer(){if(!this.objectsRepository||this.objectsRepository.getLoaded().length===0){return}
1092const locationField=this.objectsRepository.getSchema().getFieldByType("location");if(!locationField){return!1}
1093if(!this.clusterizerWorker){this.clusterizerWorker=new Worker(MapSVG.urls.root+"js/mapsvg/Core/clustering.js");this.clusterizerWorker.onmessage=(evt)=>{if(evt.data.clusters){this.addClustersFromWorker(evt.data.zoomLevel,evt.data.clusters)}}}
1094const objectsData=[];this.objectsRepository.getLoaded().filter((o)=>{return o.location&&o.location.marker}
1094).forEach((o)=>{objectsData.push({id:o.id,x:o.location.marker.svgPoint.x,y:o.location.marker.svgPoint.y,})});this.clusterizerWorker.postMessage({objects:objectsData,cellSize:50,mapWidth:this.containers.map.clientWidth,zoomLevels:this.zoomLevels,zoomLevel:this.zoomLevel,zoomDelta:this.zoomDelta,svgViewBox:this.svgDefault.viewBox,});this.events.on("zoom",()=>{this.clusterizerWorker.postMessage({message:"zoom",zoomLevel:this.zoomLevel,})})}
1095clusterizeMarkers(skipFitMarkers){$$A(this.layers.markers).children().each((i,obj)=>{$$A(obj).detach()});this.markers.clear();this.markersClusters.clear();this.clustersByZoom&&this.clustersByZoom[this.zoomLevel]&&this.clustersByZoom[this.zoomLevel].forEach((cluster)=>{if(this.options.googleMaps.on&&this.googleMaps.map&&this.googleMaps.map.getZoom()>=17){this.markerAdd(cluster.markers[0])}else{if(cluster.markers.length>1){this.markersClusterAdd(cluster)}else{this.markerAdd(cluster.markers[0])}}});if(this.editingMarker){this.markerAdd(this.editingMarker)}
1096if(!skipFitMarkers){this.mayBeFitMarkers()}
1097if(this.options.labelsMarkers.on){this.setLabelsMarkers()}}
1098getCssUrl(){return MapSVG.urls.root+"css/mapsvg.css"}
1099isGeo(){return this.mapIsGeo}
1100functionFromString(string){let func;let error;const fn=string.trim();if(fn.indexOf("{")==-1||fn.indexOf("function")!==0||fn.indexOf("(")==-1){return new SyntaxError("MapSVG user function error: no function body.")}
1101const fnBody=fn.substring(fn.indexOf("{")+1,fn.lastIndexOf("}"));const params=fn.substring(fn.indexOf("(")+1,fn.indexOf(")"));try{func=new Function(params,fnBody)}catch(err){error=err}
1102if(!error)
1103return func;else return error}
1104getOptions(forTemplate,forWeb){const options=$$A.extend(!0,{},this.options);function clearEmpties(o){for(const k in o){if(!o[k]||typeof o[k]!=="object"){continue}
1105clearEmpties(o[k]);if(Object.keys(o[k]).length===0){delete o[k]}}}
1106clearEmpties(options.regions);$$A.extend(!0,options,this.optionsDelta);options.viewBox=this._viewBox.toArray();options.filtersSchema=this.filtersSchema.getFieldsAsArray();if(options.filtersSchema.length>0){options.filtersSchema.forEach((field)=>{if(field.type==="distance"){field.value=""}})}
1107delete options.markers;if(forTemplate){options.svgFilename=options.source.split("/").pop();options.svgFiles=MapSVG.svgFiles}
1108if(forWeb)
1109$$A.each(options,(key,val)=>{if(JSON.stringify(val)==JSON.stringify(this.defaults[key]))
1110delete options[key]});delete options.backend;return options}
1111restoreDeltaOptions(){this.update(this.optionsDelta);this.optionsDelta={}}
1112setEvents(functions){let compiledFunction;for(const eventName in functions){if(typeof functions[eventName]==="string"){compiledFunction=functions[eventName]!=""?this.functionFromString(functions[eventName]):null;if(!compiledFunction||compiledFunction.error||compiledFunction instanceof TypeError||compiledFunction instanceof SyntaxError){continue}}else if(typeof functions[eventName]==="function"){compiledFunction=functions[eventName]}
1113this.events.off(eventName);this.events.on(eventName,compiledFunction);if(eventName.indexOf("directory")!==-1){const event=eventName.split(".")[0];if(this.controllers&&this.controllers.directory){this.controllers.directory.events.off(event);this.controllers.directory.events.on(event,compiledFunction)}}}
1114$$A.extend(!0,this.options.events,functions)}
1115setActions(options){$$A.extend(!0,this.options.actions,options)}
1116setDetailsView(options){options=options||this.options.detailsView||{};$$A.extend(!0,this.options.detailsView,options);if(this.options.detailsView.location==="top"&&this.options.menu.position==="left"){this.options.detailsView.location="leftSidebar"}else if(this.options.detailsView.location==="top"&&this.options.menu.position==="right"){this.options.detailsView.location="rightSidebar"}
1117if(this.options.detailsView.location==="near"||this.options.detailsView.location==="mapContainer"){this.options.detailsView.location="map"}
1118if(!this.containers.detailsView){this.containers.detailsView=$$A('<div class="mapsvg-details-container"></div>')[0]}
1119$$A(this.containers.detailsView).toggleClass("mapsvg-details-container-relative",!(MapSVG.isPhone&&this.options.detailsView.mobileFullscreen)&&!this.shouldBeScrollable(this.options.detailsView.location));if(this.options.detailsView.location==="custom"){$$A("#"+this.options.detailsView.containerId).append($$A(this.containers.detailsView))}else{if(MapSVG.isPhone&&this.options.detailsView.mobileFullscreen){$$A("body").append($$A(this.containers.detailsView));$$A(this.containers.detailsView).addClass("mapsvg-container-fullscreen")}else{this.containers[this.options.detailsView.location].append(this.containers.detailsView)}
1120if(this.options.detailsView.margin){$$A(this.containers.detailsView).css("margin",this.options.detailsView.margin)}
1121$$A(this.containers.detailsView).css("width",this.options.detailsView.width)}}
1122setMobileView(options){$$A.extend(!0,this.options.mobileView,options)}
1123attachDataToRegions(object){this.regions.forEach(function(region){region.objects=[]});this.objectsRepository.getLoaded().forEach((obj,index)=>{const regions=obj.getRegionsForTable(this.options.database.regionsTableName);if(regions&&regions.length){regions.forEach((region)=>{const r=this.getRegion(region.id);if(r)
1124r.objects.push(obj)})}})}
1125setTemplates(templates){this.templates=this.templates||{};for(let name in templates){if(name!=undefined){this.options.templates[name]=templates[name];let t=this.options.templates[name];if(name=="directoryItem"||name=="directoryCategoryItem"){const dirItemTemplate=this.options.templates.directoryItem;t='{{#each items}}<div id="mapsvg-directory-item-{{#if id_no_spaces}}{{id_no_spaces}}{{else}}{{id}}{{/if}}" class="mapsvg-directory-item" data-object-id="{{id}}">'+dirItemTemplate+"</div>{{/each}}";if(this.options.menu.categories&&this.options.menu.categories.on&&this.options.menu.categories.groupBy){const t2=this.options.templates.directoryCategoryItem;t='{{#each items}}{{#with category}}<div id="mapsvg-category-item-{{value}}" class="mapsvg-category-item" data-category-value="{{value}}">'+t2+'</div><div class="mapsvg-category-block" data-category-id="{{value}}">{{/with}}'+t+"</div>{{/each}}"}
1126name="directory"}
1127try{this.options.templates[name]=t;this.templates[name]=Handlebars.compile(t,{strict:!1})}catch(err){console.error(err);this.templates[name]=Handlebars.compile("",{strict:!1})}
1128if(this.editMode&&(name=="directory"||name=="directoryCategoryItem")&&this.controllers&&this.controllers.directory){this.controllers.directory.templates.main=this.templates[name];this.loadDirectory()}}}}
1129update(options){for(const key in options){if(key=="regions"){for(const id in options.regions){const region=this.getRegion(id);region&&region.update(options.regions[id]);if(options.regions[id].disabled!=undefined){this.deselectRegion(region);this.options.regions[id]=this.options.regions[id]||{};this.options.regions[id].disabled=region.disabled}}}else{const setter="set"+MapSVG.ucfirst(key);if(typeof this[setter]=="function")
1130this[setter](options[key]);else{this.options[key]=options[key]}}}}
1131getDirtyFields(){return this.getData()}
1132clearDirtyFields(){this.dirtyFields=[]}
1133setTitle(title){title&&(this.options.title=title)}
1134setExtension(extension){if(extension){this.options.extension=extension}else{delete this.options.extension}}
1135setDisableLinks(on){on=MapSVG.parseBoolean(on);if(on){$$A(this.containers.map).on("click.a.mapsvg","a",function(e){e.preventDefault()})}else{$$A(this.containers.map).off("click.a.mapsvg")}
1136this.disableLinks=on}
1137setLoadingText(val){this.options.loadingText=val}
1138setLockAspectRatio(onoff){this.options.lockAspectRatio=MapSVG.parseBoolean(onoff)}
1139setMarkerEditHandler(handler){this.markerEditHandler=handler}
1140setChoroplethSourceField(field){this.options.choropleth.sourceField=field;this.redrawChoropleth()}
1141setRegionEditHandler(handler){this.regionEditHandler=handler}
1142setDisableAll(on){on=MapSVG.parseBoolean(on);$$A.extend(!0,this.options,{disableAll:on});$$A(this.containers.map).toggleClass("mapsvg-disabled-regions",on)}
1143setRegionStatuses(_statuses){this.options.regionStatuses={};const colors={};_statuses.forEach((statusOptions)=>{this.options.regionStatuses[statusOptions.value]=statusOptions;colors[statusOptions.value]=statusOptions.color.length?statusOptions.color:undefined});this.setColors({status:colors})}
1144setColorsIgnore(val){this.options.colorsIgnore=MapSVG.parseBoolean(val);this.regionsRedrawColors()}
1145setColors(colors){for(const i in colors){if(i==="status"){for(const s in colors[i]){MapSVG.fixColorHash(colors[i][s])}}else{if(typeof colors[i]=="string"){MapSVG.fixColorHash(colors[i])}}}
1146$$A.extend(!0,this.options,{colors:colors});if(colors&&colors.status)
1147this.options.colors.status=colors.status;if(this.options.colors.markers){for(const z in this.options.colors.markers){for(const x in this.options.colors.markers[z]){this.options.colors.markers[z][x]=parseInt(this.options.colors.markers[z][x])}}}
1148if(this.options.colors.background)
1149$$A(this.containers.map).css({background:this.options.colors.background});if(this.options.colors.hover){this.options.colors.hover=!isNaN(this.options.colors.hover)?parseInt(this.options.colors.hover+""):this.options.colors.hover}
1150if(this.options.colors.selected){this.options.colors.selected=!isNaN(this.options.colors.selected)?parseInt(this.options.colors.selected+""):this.options.colors.selected}
1151$$A(this.containers.leftSidebar).css({"background-color":this.options.colors.leftSidebar,});$$A(this.containers.rightSidebar).css({"background-color":this.options.colors.rightSidebar,});$$A(this.containers.header).css({"background-color":this.options.colors.header});$$A(this.containers.footer).css({"background-color":this.options.colors.footer});if($$A(this.containers.detailsView)&&this.options.colors.detailsView!==undefined){$$A(this.containers.detailsView).css({"background-color":this.options.colors.detailsView,})}
1152if($$A(this.containers.directory)&&this.options.colors.directory!==undefined){$$A(this.containers.directory).css({"background-color":this.options.colors.directory,})}
1153if($$A(this.containers.filtersModal)&&this.options.colors.modalFilters!==undefined){$$A(this.containers.filtersModal).css({"background-color":this.options.colors.modalFilters,})}
1154if($$A(this.containers.filters)&&this.options.colors.directorySearch){$$A(this.containers.filters).css({"background-color":this.options.colors.directorySearch,})}else if($$A(this.containers.filters)){$$A(this.containers.filters).css({"background-color":"",})}
1155if(!this.containers.clustersCss){this.containers.clustersCss=($$A("<style></style>").appendTo("body")[0])}
1156let css="";if(this.options.colors.clusters){css+="background-color: "+this.options.colors.clusters+";"}
1157if(this.options.colors.clustersBorders){css+="border-color: "+this.options.colors.clustersBorders+";"}
1158if(this.options.colors.clustersText){css+="color: "+this.options.colors.clustersText+";"}
1159$$A(this.containers.clustersCss).html(".mapsvg-marker-cluster {"+css+"}");if(!this.containers.clustersHoverCss){this.containers.clustersHoverCss=($$A("<style></style>").appendTo("body")[0])}
1160let cssHover="";if(this.options.colors.clustersHover){cssHover+="background-color: "+this.options.colors.clustersHover+";"}
1161if(this.options.colors.clustersHoverBorders){cssHover+="border-color: "+this.options.colors.clustersHoverBorders+";"}
1162if(this.options.colors.clustersHoverText){cssHover+="color: "+this.options.colors.clustersHoverText+";"}
1163$$A(this.containers.clustersHoverCss).html(".mapsvg-marker-cluster:hover {"+cssHover+"}");if(!this.containers.markersCss){this.containers.markersCss=$$A("<style></style>").appendTo("head")[0]}
1164const markerCssText=".mapsvg-with-marker-active .mapsvg-marker {\n"+"  opacity: "+this.options.colors.markers.inactive.opacity/100+";\n"+"  -webkit-filter: grayscale("+(100-this.options.colors.markers.inactive.saturation)+"%);\n"+"  filter: grayscale("+(100-this.options.colors.markers.inactive.saturation)+"%);\n"+"}\n"+".mapsvg-with-marker-active .mapsvg-marker-active {\n"+"  opacity: "+this.options.colors.markers.active.opacity/100+";\n"+"  -webkit-filter: grayscale("+(100-this.options.colors.markers.active.saturation)+"%);\n"+"  filter: grayscale("+(100-this.options.colors.markers.active.saturation)+"%);\n"+"}\n"+".mapsvg-with-marker-hover .mapsvg-marker {\n"+"  opacity: "+this.options.colors.markers.unhovered.opacity/100+";\n"+"  -webkit-filter: grayscale("+(100-this.options.colors.markers.unhovered.saturation)+"%);\n"+"  filter: grayscale("+(100-this.options.colors.markers.unhovered.saturation)+"%);\n"+"}\n"+".mapsvg-with-marker-hover .mapsvg-marker-hover {\n"+"  opacity: "+this.options.colors.markers.hovered.opacity/100+";\n"+"  -webkit-filter: grayscale("+(100-this.options.colors.markers.hovered.saturation)+"%);\n"+"  filter: grayscale("+(100-this.options.colors.markers.hovered.saturation)+"%);\n"+"}\n";$$A(this.containers.markersCss).html(markerCssText);$$A.each(this.options.colors,(key,color)=>{if(color===null||color=="")
1165delete this.options.colors[key]});this.regionsRedrawColors()}
1166setTooltips(options){if(options.on!==undefined)
1167options.on=MapSVG.parseBoolean(options.on);$$A.extend(!0,this.options,{tooltips:options});if(!this.containers.tooltip){this.containers.tooltip=$$A("<div />").addClass("mapsvg-tooltip")[0];$$A(this.containers.map).append(this.containers.tooltip);this.controllers.tooltip=new Tooltip({mapsvg:this,container:this.containers.tooltip,position:this.options.tooltips.position,maxWidth:this.options.tooltips.maxWidth,minWidth:this.options.tooltips.minWidth,});this.controllers.tooltip._init()}
1168if(typeof this.options.tooltips.position!=="undefined"){this.controllers.tooltip.setPosition(this.options.tooltips.position)}
1169if(typeof this.options.tooltips.maxWidth!=="undefined"||typeof this.options.tooltips.minWidth!=="undefined"){this.controllers.tooltip.setSize(this.options.tooltips.minWidth,this.options.tooltips.maxWidth)}}
1170setPopovers(options){if(options.on!==undefined)
1171options.on=MapSVG.parseBoolean(options.on);$$A.extend(this.options.popovers,options);if(!this.containers.popover){this.containers.popover=$$A("<div />").addClass("mapsvg-popover")[0];this.layers.popovers.append(this.containers.popover)}
1172$$A(this.containers.popover).css({width:this.options.popovers.width+(this.options.popovers.width=="auto"?"":"px"),"max-width":this.options.popovers.maxWidth+"%","max-height":(this.options.popovers.maxHeight*$$A(this.containers.wrap).outerHeight())/100+"px",});if(this.options.popovers.mobileFullscreen&&MapSVG.isPhone){$$A("body").toggleClass("mapsvg-fullscreen-popovers",!0);$$A(this.containers.popover).appendTo("body")}}
1173setRegionPrefix(prefix){this.options.regionPrefix=prefix}
1174setInitialViewBox(v){if(typeof v=="string")
1175v=v.trim().split(" ").map(function(v){return parseFloat(v)});this._viewBox.update(new ViewBox(v));if(this.options.googleMaps.on){this.options.googleMaps.center=this.googleMaps.map.getCenter().toJSON();this.options.googleMaps.zoom=this.googleMaps.map.getZoom()}
1176this.zoomLevel=0;this.setZoomLevels()}
1177setViewBoxOnStart(){this.viewBoxFull=this.svgDefault.viewBox;this.viewBoxFake=this.viewBox;this.whRatioFull=this.viewBoxFull.width/this.viewBox.width;this.containers.svg.setAttribute("viewBox",this.viewBoxFull.toString());if((MapSVG.device.ios||MapSVG.device.android)&&this.svgDefault.viewBox.width>1500){this.iosDownscaleFactor=this.svgDefault.viewBox.width>9999?100:10;this.containers.svg.style.width=(this.svgDefault.viewBox.width/this.iosDownscaleFactor).toString()+"px"}else{this.containers.svg.style.width=this.svgDefault.viewBox.width+"px"}
1178this.vbStart=!0}
1179setViewBox(viewBox,adjustGoogleMap=!0){let initial=!1;if(typeof viewBox==="undefined"||(viewBox.width===0&&viewBox.height===0)){viewBox=this.svgDefault.viewBox;initial=!0}
1180const isZooming=viewBox.width!=this.viewBox.width||viewBox.height!=this.viewBox.height;this.viewBox.update(viewBox);this.whRatio=this.viewBox.width/this.viewBox.height;!this.vbStart&&this.setViewBoxOnStart();if(initial){if(this._viewBox.width===0&&this._viewBox.height===0){this._viewBox.update(this.viewBox)}
1181this._scale=1}
1182this.scale=this.getScale();this.superScale=(this.whRatioFull*this.svgDefault.viewBox.width)/this.viewBox.width;const w=this.svgDefault.viewBox.width/this.containers.map.clientWidth;this.superScale=this.superScale/w;if((MapSVG.device.ios||MapSVG.device.android)&&this.svgDefault.viewBox.width>1500){this.superScale*=this.iosDownscaleFactor}
1183this.scroll.tx=Math.round((this.svgDefault.viewBox.x-this.viewBox.x)*this.scale);this.scroll.ty=Math.round((this.svgDefault.viewBox.y-this.viewBox.y)*this.scale);if(this.googleMaps.map&&adjustGoogleMap!==!1){const googlePrevZoom=this.googleMaps.map.getZoom();this.googleMaps.map.setCenter(this.getCenterGeoPoint());this.googleMaps.map.setZoom(this.getZoomForGoogle())}else{this.containers.scrollpane.style.transform="translate("+this.scroll.tx+"px,"+this.scroll.ty+"px)";this.containers.svg.style.transform="scale("+this.superScale+")";this.syncZoomLevelWithGoogle()}
1184this.movingItemsAdjustScreenPosition();if(isZooming){this.adjustStrokes();this.toggleSvgLayerOnZoom();if(this.options.clustering.on){this.throttle(this.clusterizeOnZoom,400,this)}else{this.events.trigger("zoom")}}
1185return!0}
1186syncZoomLevelWithGoogle(){if(this.googleMaps.map&&this.googleMaps.map.getZoom()!==this.getZoomForGoogle()&&typeof this.zoomDelta!=="undefined"){this.zoomLevel=this.googleMaps.map.getZoom()-this.zoomDelta}}
1187getCenterGeoPoint(){return this.converter.convertSVGToGeo(this.getCenterSvgPoint())}
1188getCenterSvgPoint(){return new SVGPoint(this.viewBox.x+this.viewBox.width/2,this.viewBox.y+this.viewBox.height/2)}
1189getZoomForGoogle(){if(typeof this.zoomLevel==="string"){this.zoomLevel=parseInt(this.zoomLevel)}
1190return this.zoomLevel+this.zoomDelta}
1191getZoomRange(){const range={min:0,max:0};if(this.options.googleMaps.on){range.min=Math.max(0,this.options.zoom.limit[0]+this.zoomDelta)-this.zoomDelta;range.max=Math.min(22,this.options.zoom.limit[1]+this.zoomDelta)-this.zoomDelta}else{range.min=this.options.zoom.limit[0];range.max=this.options.zoom.limit[1]}
1192return range}
1193enableMovingElementsAnimation(){$$A(this.containers.map).removeClass("no-transitions-markers no-transitions-labels no-transitions-bubbles")}
1194disableMovingElementsAnimation(){$$A(this.containers.map).addClass("no-transitions-markers no-transitions-labels no-transitions-bubbles")}
1195clusterizeOnZoom(){if(this.options.googleMaps.on&&this.googleMaps.map&&this.zoomDelta){this.zoomLevel=this.googleMaps.map.getZoom()-this.zoomDelta}
1196this.events.trigger("zoom");this.clusterizeMarkers(!0)}
1197throttle(method,delay,scope,params){clearTimeout(method._tId);method._tId=setTimeout(function(){method.apply(scope,params)},delay)}
1198setViewBoxByGoogleMapBounds(){const googleMapBounds=this.googleMaps.map.getBounds();if(!googleMapBounds)
1199return;const googleMapBoundsJSON=googleMapBounds.toJSON();if(googleMapBoundsJSON.west==-180&&googleMapBoundsJSON.east==180){const center=this.googleMaps.map.getCenter().toJSON()}
1200const ne=new GeoPoint(googleMapBounds.getNorthEast().lat(),googleMapBounds.getNorthEast().lng());
1200const sw=new GeoPoint(googleMapBounds.getSouthWest().lat(),googleMapBounds.getSouthWest().lng());const xyNE=this.converter.convertGeoToSVG(ne);const xySW=this.converter.convertGeoToSVG(sw);if(xyNE.x<xySW.y){const mapPointsWidth=(this.svgDefault.viewBox.width/this.converter.mapLonDelta)*360;xySW.x=-(mapPointsWidth-xySW.y)}
1201const width=xyNE.x-xySW.x;const height=xySW.y-xyNE.y;const viewBox=new ViewBox(xySW.x,xyNE.y,width,height);this.setViewBox(viewBox)}
1202redraw(){this.disableAnimation();if(MapSVG.browser.ie){$$A(this.containers.svg).css({height:this.svgDefault.viewBox.height})}
1203if(this.options.googleMaps.on&&this.googleMaps.map){google.maps.event.trigger(this.googleMaps.map,"resize")}else{this.setViewBox(this.viewBox)}
1204$$A(this.containers.popover)&&$$A(this.containers.popover).css({"max-height":(this.options.popovers.maxHeight*$$A(this.containers.wrap).outerHeight())/100+"px",});if(this.controllers&&this.controllers.directory){this.controllers.directory.updateTopShift();this.controllers.directory.updateScroll()}
1205this.movingItemsAdjustScreenPosition();this.adjustStrokes();this.enableAnimation()}
1206setSize(width,height,responsive){this.options.width=width;this.options.height=height;this.options.responsive=responsive!=null&&responsive!=undefined?MapSVG.parseBoolean(responsive):this.options.responsive;if(!this.options.width&&!this.options.height){this.options.width=this.svgDefault.width;this.options.height=this.svgDefault.height}else if(!this.options.width&&this.options.height){this.options.width=(this.options.height*this.svgDefault.width)/this.svgDefault.height}else if(this.options.width&&!this.options.height){this.options.height=(this.options.width*this.svgDefault.height)/this.svgDefault.width}
1207this.whRatio=this.options.width/this.options.height;this.scale=this.getScale();this.setResponsive(responsive);if(this.options.choropleth.on&&this.options.choropleth.bubbleMode){this.redrawBubbles()}
1208this.movingItemsAdjustScreenPosition()}
1209setResponsive(on){on=on!=undefined?MapSVG.parseBoolean(on):this.options.responsive;$$A(this.containers.map).css({width:"100%",height:"0","padding-bottom":(this.viewBox.height*100)/this.viewBox.width+"%",});if(on){$$A(this.containers.wrap).css({width:"100%",height:"auto",})}else{$$A(this.containers.wrap).css({width:this.options.width+"px",height:this.options.height+"px",})}
1210$$A.extend(!0,this.options,{responsive:on});if(!this.resizeSensor){this.resizeSensor=new ResizeSensor(this.containers.map,()=>{this.redraw()})}
1211this.redraw()}
1212setScroll(options,skipEvents){options.on!=undefined&&(options.on=MapSVG.parseBoolean(options.on));options.limit!=undefined&&(options.limit=MapSVG.parseBoolean(options.limit));$$A.extend(!0,this.options,{scroll:options});!skipEvents&&this.setEventHandlers()}
1213setZoom(options){options=options||{};options.on!=undefined&&(options.on=MapSVG.parseBoolean(options.on));options.fingers!=undefined&&(options.fingers=MapSVG.parseBoolean(options.fingers));options.mousewheel!=undefined&&(options.mousewheel=MapSVG.parseBoolean(options.mousewheel));options.delta=2;if(options.limit){if(typeof options.limit=="string")
1214options.limit=options.limit.split(";");options.limit=[parseInt(options.limit[0]),parseInt(options.limit[1])]}
1215if(!this.zoomLevels){this.setZoomLevels()}
1216$$A.extend(!0,this.options,{zoom:options});$$A(this.containers.scrollpaneWrap).off("wheel.mapsvg");if(this.options.zoom.mousewheel){if(MapSVG.browser.firefox){this.firefoxScroll={insideIframe:!1,scrollX:0,scrollY:0};$$A(this.containers.scrollpaneWrap).on("mouseenter",()=>{this.firefoxScroll.insideIframe=!0;this.firefoxScroll.scrollX=window.scrollX;this.firefoxScroll.scrollY=window.scrollY}).on("mouseleave",()=>{this.firefoxScroll.insideIframe=!1});$$A(document).scroll(()=>{if(this.firefoxScroll.insideIframe)
1217window.scrollTo(this.firefoxScroll.scrollX,this.firefoxScroll.scrollY)})}
1218$$A(this.containers.scrollpaneWrap).on("wheel.mapsvg",(event)=>{event.preventDefault();this.mouseWheelZoom(event);return!1});$$A(this.layers.markers).on("wheel.mapsvg",(event)=>{event.preventDefault();this.mouseWheelZoom(event);return!1})}
1219this.canZoom=!0}
1220mouseWheelZoom(event){event.preventDefault();const d=Math.sign(-event.originalEvent.deltaY);const center=this.getSvgPointAtClick(event.originalEvent);d>0?this.zoomIn(center):this.zoomOut(center)}
1221setControls(options){options=options||{};$$A.extend(!0,this.options,{controls:options});this.options.controls.zoom=MapSVG.parseBoolean(this.options.controls.zoom);this.options.controls.zoomReset=MapSVG.parseBoolean(this.options.controls.zoomReset);this.options.controls.userLocation=MapSVG.parseBoolean(this.options.controls.userLocation);this.options.controls.previousMap=MapSVG.parseBoolean(this.options.controls.previousMap);const loc=this.options.controls.location||"right";if(!this.containers.controls){const buttons=$$A("<div />").addClass("mapsvg-buttons");const zoomGroup=$$A("<div />").addClass("mapsvg-btn-group").appendTo(buttons);const zoomIn=$$A("<div />").addClass("mapsvg-btn-map mapsvg-in");zoomIn.on("touchend click",(e)=>{if(e.cancelable){e.preventDefault()}
1222e.stopPropagation();this.zoomIn()});const zoomOut=$$A("<div />").addClass("mapsvg-btn-map mapsvg-out");zoomOut.on("touchend click",(e)=>{if(e.cancelable){e.preventDefault()}
1223e.stopPropagation();this.zoomOut()});zoomGroup.append(zoomIn).append(zoomOut);const location=$$A("<div />").addClass("mapsvg-btn-map mapsvg-btn-location");location.on("touchend click",(e)=>{if(e.cancelable){e.preventDefault()}
1224e.stopPropagation();this.showUserLocation((location)=>
1224{if(this.options.scroll.on){this.centerOn(location.marker)}})});const userLocationIcon='<svg version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" viewBox="0 0 447.342 447.342" style="enable-background:new 0 0 447.342 447.342;" xml:space="preserve"><path d="M443.537,3.805c-3.84-3.84-9.686-4.893-14.625-2.613L7.553,195.239c-4.827,2.215-7.807,7.153-7.535,12.459 c0.254,5.305,3.727,9.908,8.762,11.63l129.476,44.289c21.349,7.314,38.125,24.089,45.438,45.438l44.321,129.509 c1.72,5.018,6.325,8.491,11.63,8.762c5.306,0.271,10.244-2.725,12.458-7.535L446.15,18.429 C448.428,13.491,447.377,7.644,443.537,3.805z"/></svg>';location.html(userLocationIcon);const locationGroup=$$A("<div />").addClass("mapsvg-btn-group").appendTo(buttons);locationGroup.append(location);const zoomResetIcon='<svg height="14px" version="1.1" viewBox="0 0 14 14" width="14px" xmlns="http://www.w3.org/2000/svg" xmlns:sketch="http://www.bohemiancoding.com/sketch/ns" xmlns:xlink="http://www.w3.org/1999/xlink"><g fill="none" fill-rule="evenodd" id="Page-1" stroke="none" stroke-width="1"><g fill="#000000" transform="translate(-215.000000, -257.000000)"><g id="fullscreen" transform="translate(215.000000, 257.000000)"><path d="M2,9 L0,9 L0,14 L5,14 L5,12 L2,12 L2,9 L2,9 Z M0,5 L2,5 L2,2 L5,2 L5,0 L0,0 L0,5 L0,5 Z M12,12 L9,12 L9,14 L14,14 L14,9 L12,9 L12,12 L12,12 Z M9,0 L9,2 L12,2 L12,5 L14,5 L14,0 L9,0 L9,0 Z" /></g></g></g></svg>';const zoomResetButton=$$A("<div />").html(zoomResetIcon).addClass("mapsvg-btn-map mapsvg-btn-zoom-reset");zoomResetButton.on("touchend click",(e)=>{if(e.cancelable){e.preventDefault()}
1225e.stopPropagation();this.viewBoxReset(!0)});const zoomResetGroup=$$A("<div />").addClass("mapsvg-btn-group").appendTo(buttons);zoomResetGroup.append(zoomResetButton);const previousMapIcon='<svg xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:cc="http://creativecommons.org/ns#" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:svg="http://www.w3.org/2000/svg" xmlns="http://www.w3.org/2000/svg" xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd" xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape" version="1.1" id="mapsvg-previous-map-icon" x="0px" y="0px" viewBox="0 0 512 512" style="enable-background:new 0 0 512 512;" xml:space="preserve" sodipodi:docname="undo.svg" inkscape:version="0.92.4 (5da689c313, 2019-01-14)"><metadata id="metadata19"><rdf:RDF><cc:Work rdf:about="">'+'<dc:format>image/svg+xml</dc:format><dc:type rdf:resource="http://purl.org/dc/dcmitype/StillImage" /></cc:Work></rdf:RDF></metadata><defs id="defs17" /><sodipodi:namedview pagecolor="#ffffff" bordercolor="#666666" borderopacity="1" objecttolerance="10" gridtolerance="10" guidetolerance="10" inkscape:pageopacity="0" inkscape:pageshadow="2" inkscape:window-width="1920" inkscape:window-height="1017" id="namedview15" showgrid="false" inkscape:zoom="1.0103686" inkscape:cx="181.33521" inkscape:cy="211.70893" inkscape:window-x="-8" inkscape:window-y="-8" inkscape:window-maximized="1" inkscape:current-layer="Capa_1" /> <g id="g6" transform="matrix(0.53219423,0,0,0.52547259,122.72749,106.63302)">'+'<g id="g4"><path d="m 142.716,293.147 -94,-107.602 94,-107.602 c 7.596,-8.705 6.71,-21.924 -1.995,-29.527 -8.705,-7.596 -21.917,-6.703 -29.527,1.995 L 5.169,171.782 c -6.892,7.882 -6.892,19.65 0,27.532 l 106.026,121.372 c 4.143,4.729 9.94,7.157 15.771,7.157 4.883,0 9.786,-1.702 13.755,-5.169 8.706,-7.603 9.598,-20.822 1.995,-29.527 z" id="path2" inkscape:connector-curvature="0" /></g></g><g id="g12" transform="matrix(0.53219423,0,0,0.52547259,122.72749,106.63302)"><g id="g10"> <path d="M 359.93,164.619 H 20.926 C 9.368,164.619 0,173.986 0,185.545 c 0,11.558 9.368,20.926 20.926,20.926 H 359.93 c 60.776,0 110.218,49.441 110.218,110.211 0,60.77 -49.442,110.211 -110.218,110.211 H 48.828 c -11.558,0 -20.926,9.368 -20.926,20.926 0,11.558 9.368,20.926 20.926,20.926 H 359.93 C 443.774,468.745 512,400.526 512,316.682 512,232.838 443.781,164.619 359.93,164.619 Z" '+'id="path8" inkscape:connector-curvature="0" /></g></g></svg>';const previousMapButton=$$A("<div />").html(previousMapIcon).addClass("mapsvg-btn-map mapsvg-btn-previous-map");previousMapButton.on("touchend click",(e)=>{if(e.cancelable){e.preventDefault()}
1226e.stopPropagation();this.loadPreviousMap()});const previousMapGroup=$$A("<div />").addClass("mapsvg-btn-group").appendTo(buttons);previousMapGroup.append(previousMapButton);this.containers.controls=buttons[0];this.controls={zoom:zoomGroup[0],userLocation:locationGroup[0],zoomReset:zoomResetGroup[0],previousMap:previousMapGroup[0],};$$A(this.containers.map).append($$A(this.containers.controls))}
1227$$A(this.controls.zoom).toggle(this.options.controls.zoom);$$A(this.controls.userLocation).toggle(this.options.controls.userLocation);$$A(this.controls.zoomReset).toggle(this.options.controls.zoomReset);$$A(this.controls.previousMap).toggle(this.options.controls.previousMap&&this.options.previousMapsIds.length>0);$$A(this.containers.controls).removeClass("left");$$A(this.containers.controls).removeClass("right");(loc=="right"&&$$A(this.containers.controls).addClass("right"))||(loc=="left"&&$$A(this.containers.controls).addClass("left"))}
1228setZoomLevels(){if(!this.zoomLevels){this.zoomLevels=new ArrayIndexed("zoomLevel")}else{this.zoomLevels.clear()}
1229for(let i=-20;i<0;i++){const _scale=1/Math.pow(this.options.zoom.delta,Math.abs(i));this.zoomLevels.push({zoomLevel:i,_scale:_scale,viewBox:new ViewBox(0,0,this._viewBox.width/_scale,this._viewBox.height/_scale),})}
1230for(let z=0;z<=20;z++){const _scale=Math.pow(this.options.zoom.delta,Math.abs(z));this.zoomLevels.push({zoomLevel:z,_scale:_scale,viewBox:new ViewBox(0,0,this._viewBox.width/_scale,this._viewBox.height/_scale),})}}
1231setCursor(type){type=type=="pointer"?"pointer":"default";this.options.cursor=type;if(type=="pointer")
1232$$A(this.containers.map).addClass("mapsvg-cursor-pointer");else $$A(this.containers.map).removeClass("mapsvg-cursor-pointer")}
1233setMultiSelect(on,deselect){this.options.multiSelect=MapSVG.parseBoolean(on);if(deselect!==!1)
1234this.deselectAllRegions()}
1235_new_setChoropleth(options){options=options||this.options.choropleth;options.on!=undefined&&(options.on=MapSVG.parseBoolean(options.on));if(typeof options.coloring==="undefined"||typeof options.coloring.palette==="undefined"||typeof options.coloring.palette.colors==="undefined"){if(typeof options.sourceFieldSelect==="undefined"||typeof options.sourceFieldSelect.variants==="undefined"){$$A.extend(!0,this.options.choropleth,options)}else{this.options.choropleth.sourceFieldSelect.variants=options.sourceFieldSelect.variants}}else{const paletteColorsIndexes=Object.keys(options.coloring.palette.colors);if(paletteColorsIndexes.length>1||(paletteColorsIndexes[0]=="0"&&Object.keys(options.coloring.palette.colors[0]).length>1)){this.options.choropleth.coloring.palette.colors=options.coloring.palette.colors}else{const paletteColorIndex=Object.keys(options.coloring.palette.colors)[0];$$A.extend(!0,this.options.choropleth.coloring.palette.colors[paletteColorIndex],options.coloring.palette.colors[paletteColorIndex])}}
1236this.updateChoroplethMinMax();if(this.options.choropleth.on&&this.options.choropleth.sourceFieldSelect.on&&this.options.choropleth.sourceFieldSelect.variants){if(!this.containers.choroplethSourceSelect){const sourceSelectOptions=[];
1236this.options.choropleth.sourceFieldSelect.variants.forEach((variant)=>{sourceSelectOptions.push($$A('<option value="'+variant+'" '+(variant===this.options.choropleth.sourceField?"selected":"")+">"+variant+"</option>"))});this.containers.choroplethSourceSelect={container:$$A('<div class="mapsvg-choropleth-source-field"></div>')[0],select:$$A('<select id="mapsvg-choropleth-source-field-select" class="mapsvg-select2"></select>')[0],options:sourceSelectOptions,};$$A(this.containers.choroplethSourceSelect.select).append(this.containers.choroplethSourceSelect.options);$$A(this.containers.choroplethSourceSelect.container).append($$A(this.containers.choroplethSourceSelect.select));$$A(this.containers.map).append($$A(this.containers.choroplethSourceSelect.container));$$A(this.containers.choroplethSourceSelect.select).mselect2();$$A(this.containers.choroplethSourceSelect.select).mselect2().on("select2:select select2:unselecting",(e)=>{if(e.cancelable){e.preventDefault()}
1237e.stopPropagation();this.setChoropleth({sourceField:$$A(e.target).mselect2().val()})})}else{$$A(this.containers.choroplethSourceSelect.select).mselect2("destroy");$$A(this.containers.choroplethSourceSelect.select).find("option").remove();this.containers.choroplethSourceSelect.options=[];
1237this.options.choropleth.sourceFieldSelect.variants.forEach((variant)=>{this.containers.choroplethSourceSelect.options.push($$A('<option value="'+variant+'" '+(variant===this.options.choropleth.sourceField?"selected":"")+">"+variant+"</option>")[0])});$$A(this.containers.choroplethSourceSelect.select).append(this.containers.choroplethSourceSelect.options);$$A(this.containers.choroplethSourceSelect.select).mselect2({width:"100%"})}}
1238if((!this.options.choropleth.on||!this.options.choropleth.sourceFieldSelect.on)&&this.containers.choroplethSourceSelect&&$$A(this.containers.choroplethSourceSelect.container).is(":visible")){$$A(this.containers.choroplethSourceSelect.container).hide()}else if(this.options.choropleth.on&&this.options.choropleth.sourceFieldSelect.on&&this.containers.choroplethSourceSelect&&!$$A(this.containers.choroplethSourceSelect.container).is(":visible")){$$A(this.containers.choroplethSourceSelect.container).show()}
1239$$A(this.containers.map).find(".mapsvg-choropleth-legend").remove();if(this.options.choropleth.on&&this.options.choropleth.coloring.legend.on){const legend=this.options.choropleth.coloring.legend;let coloring="";if(this.options.choropleth.coloring.mode==="gradient"){coloring+='<div class="mapsvg-choropleth-legend-gradient-no-data">'+this.options.choropleth.coloring.noData.description+"</div>";let legendGradient="";for(let chunkIdx=1;chunkIdx<5;chunkIdx++){legendGradient+='<div class="mapsvg-choropleth-legend-gradient-chunk">'+((this.options.choropleth.coloring.gradient.values.maxAdjusted*chunkIdx)/5+this.options.choropleth.coloring.gradient.values.min)+"</div>"}
1240coloring+='<div class="mapsvg-choropleth-legend-gradient-colors">'+legendGradient+"</div>"}else{coloring+='<div class="mapsvg-choropleth-legend-palette-color-wrap" data-idx="no-data">'+'<div class="mapsvg-choropleth-legend-palette-color"></div>'+'<div class="mapsvg-choropleth-legend-palette-color-description">'+this.options.choropleth.coloring.noData.description+"</div>"+"</div>";coloring+='<div class="mapsvg-choropleth-legend-palette-color-wrap" data-idx="out-of-range">'+'<div class="mapsvg-choropleth-legend-palette-color"></div>'+'<div class="mapsvg-choropleth-legend-palette-color-description">'+this.options.choropleth.coloring.palette.outOfRange.description+"</div>"+"</div>";const paletteColors=this.options.choropleth.coloring.palette.colors;paletteColors.forEach((paletteColor,idx)=>{let paletteColorElementText="";if(paletteColor.description){paletteColorElementText=paletteColor.description}else{if(idx===0&&!paletteColor.valueFrom&&paletteColor.valueFrom!==0){if(legend.layout==="vertical"){paletteColorElementText="Less then "+paletteColor.valueTo}else{paletteColorElementText="< "+paletteColor.valueTo}}else if(idx===paletteColors.length-1&&!paletteColor.valueTo){if(legend.layout==="vertical"){paletteColorElementText=paletteColor.valueFrom+" or more"}else{paletteColorElementText=paletteColor.valueFrom+" <"}}else{paletteColorElementText=paletteColor.valueFrom+" &#8804; "+paletteColor.valueTo}}
1241coloring+='<div class="mapsvg-choropleth-legend-palette-color-wrap" data-idx="'+idx+'">'+'<div class="mapsvg-choropleth-legend-palette-color"></div>'+'<div class="mapsvg-choropleth-legend-palette-color-description">'+paletteColorElementText+"</div>"+"</div>"})}
1242this.containers.legend={title:$$A('<div class="mapsvg-choropleth-legend-title">'+legend.title+"</div>")[0],text:$$A('<div class="mapsvg-choropleth-legend-text">'+legend.text+"</div>")[0],coloring:$$A('<div class="mapsvg-choropleth-legend-'+this.options.choropleth.coloring.mode+'">'+coloring+"</div>")[0],description:$$A('<div class="mapsvg-choropleth-legend-description">'+legend.description+"</div>")[0],container:$$A("<div />").addClass("mapsvg-choropleth-legend mapsvg-choropleth-legend-"+legend.layout+" mapsvg-choropleth-legend-container-"+legend.container)[0],};$$A(this.containers.legend.container).append(this.containers.legend.title).append(this.containers.legend.text).append(this.containers.legend.coloring).append(this.containers.legend.description);$$A(this.containers.map).append(this.containers.legend.container);this.setChoroplethLegendCSS();this.regionsRepository.events.on("updated",()=>{this.redrawChoropleth()});this.objectsRepository.events.on("updated",()=>{this.redrawChoropleth()})}
1243if(this.options.choropleth.on&&this.options.choropleth.coloring.mode==="gradient"){const colors=this.options.choropleth.coloring.gradient.colors;if(colors){colors.lowRGB=tinycolor(colors.low).toRgb();colors.highRGB=tinycolor(colors.high).toRgb();colors.diffRGB={r:colors.highRGB.r-colors.lowRGB.r,g:colors.highRGB.g-colors.lowRGB.g,b:colors.highRGB.b-colors.lowRGB.b,a:colors.highRGB.a-colors.lowRGB.a,};this.containers.legend&&this.setChoroplethLegendCSS()}}
1244this.redrawChoropleth()}
1245redrawChoropleth(){this.updateChoroplethMinMax();this.redrawBubbles();this.regionsRedrawColors()}
1246updateChoroplethMinMax(){if(this.options.choropleth.on){const gradient=this.options.choropleth.coloring.gradient,values=[];gradient.values.min=0;gradient.values.max=null;if(this.options.choropleth.source==="regions"){this.regions.forEach((region)=>{const choropleth=region.data&&region.data[this.options.choropleth.sourceField];choropleth!=undefined&&choropleth!==""&&values.push(choropleth)})}
1246else{this.objectsRepository.objects.forEach((object)=>{const choropleth=object[this.options.choropleth.sourceField];choropleth!=undefined&&choropleth!==""&&values.push(choropleth)})}
1247if(values.length>0){gradient.values.min=Math.min.apply(null,values);gradient.values.max=Math.max.apply(null,values);gradient.values.maxAdjusted=gradient.values.max-gradient.values.min}}}
1248setChoroplethLegendCSS(){const gradient=this.options.choropleth.coloring.gradient,legend=this.options.choropleth.coloring.legend,noData=this.options.choropleth.coloring.noData,outOfRange=this.options.choropleth.coloring.palette.outOfRange;$$A(".mapsvg-choropleth-legend").css({width:legend.width,height:legend.height,});if(this.options.choropleth.coloring.mode==="gradient"){if(legend.layout==="horizontal"){$$A(".mapsvg-choropleth-legend-horizontal .mapsvg-choropleth-legend-gradient-colors").css({background:"linear-gradient(to right,"+gradient.colors.low+" 1%,"+gradient.colors.high+" 100%)",})}else{$$A(".mapsvg-choropleth-legend-vertical .mapsvg-choropleth-legend-gradient-colors").css({background:"linear-gradient(to bottom,"+gradient.colors.low+" 1%,"+gradient.colors.high+" 100%)",})}
1249$$A(".mapsvg-choropleth-legend-gradient-no-data").css({"background-color":noData.color,})}else{const paletteColors=this.options.choropleth.coloring.palette.colors;paletteColors.forEach(function(paletteColor,idx){$$A('.mapsvg-choropleth-legend-palette-color-wrap[data-idx="'+idx+'"] .mapsvg-choropleth-legend-palette-color').css({"background-color":paletteColor.color,})});$$A('.mapsvg-choropleth-legend-palette-color-wrap[data-idx="no-data"] .mapsvg-choropleth-legend-palette-color').css({"background-color":noData.color,});$$A('.mapsvg-choropleth-legend-palette-color-wrap[data-idx="out-of-range"] .mapsvg-choropleth-legend-palette-color').css({"background-color":outOfRange.color,})}}
1250setCss(css){this.options.css=css||(this.options.css?this.options.css.replace(/%id%/g,""+this.id):"");this.liveCss=this.liveCss||$$A("<style></style>").appendTo("head")[0];$$A(this.liveCss).html(this.options.css)}
1251setFilters(options){options=options||this.options.filters;options.on!=undefined&&(options.on=MapSVG.parseBoolean(options.on));options.hide!=undefined&&(options.hide=MapSVG.parseBoolean(options.hide));$$A.extend(!0,this.options,{filters:options});if(!MapSVG.googleMapsApiLoaded&&this.options.filters.on&&this.filtersSchema.getField("distance")){this.loadGoogleMapsAPI(()=>{return 1},()=>{return 1})}
1252if(["leftSidebar","rightSidebar","header","footer","custom","map"].indexOf(this.options.filters.location)===-1){this.options.filters.location="leftSidebar"}
1253if(this.options.filters.on){if(this.formBuilder){this.formBuilder.destroy()}
1254if(!this.containers.filters){this.containers.filters=$$A('<div class="mapsvg-filters-wrap"></div>')[0]}else{$$A(this.containers.filters).empty();$$A(this.containers.filters).show()}
1255$$A(this.containers.filters).css({"background-color":this.options.colors.directorySearch,});if($$A(this.containers.filtersModal)){$$A(this.containers.filtersModal).css({width:this.options.filters.width})}
1256if(this.options.filters.location==="custom"){$$A(this.containers.filters).removeClass("mapsvg-filter-container-custom").addClass("mapsvg-filter-container-custom");if($$A("#"+this.options.filters.containerId).length){$$A("#"+this.options.filters.containerId).append(this.containers.filters)}else{$$A(this.containers.filters).hide();console.error("MapSVG: filter container #"+this.options.filters.containerId+" does not exists")}}else{if(MapSVG.isPhone){$$A(this.containers.header).append($$A(this.containers.filters));this.setContainers({header:{on:!0}})}else{const location=MapSVG.isPhone?"header":this.options.filters.location;if(this.options.menu.on&&this.controllers.directory&&this.options.menu.location===this.options.filters.location){$$A(this.controllers.directory.containers.view).find(".mapsvg-directory-filter-wrap").append($$A(this.containers.filters));this.controllers.directory.updateTopShift()}else{$$A(this.containers[location]).append($$A(this.containers.filters));this.controllers.directory&&this.controllers.directory.updateTopShift()}}}
1257this.loadFiltersController(this.containers.filters,!1);this.updateFiltersState()}else{if($$A(this.containers.filters)){$$A(this.containers.filters).empty();$$A(this.containers.filters).hide()}}
1258if(this.options.menu.on&&this.controllers.directory&&this.options.menu.location===this.options.filters.location){this.controllers.directory.updateTopShift()}}
1259updateFiltersState(){if(this.options.filters&&this.options.filters.on&&this.controllers.filters){this.controllers.filters.update(this.objectsRepository.query);this.updateFilterTags()}}
1260setGlobalDistanceFilter(){if(this.objectsRepository&&this.objectsRepository.query.filters&&this.objectsRepository.query.filters.distance){const dist=this.objectsRepository.query.filters.distance;MapSVG.distanceSearch=this.objectsRepository.query.filters.distance}else{MapSVG.distanceSearch=null}}
1261updateFilterTags(){$$A(this.containers.filterTags)&&$$A(this.containers.filterTags).empty();for(const field_name in this.objectsRepository.query.filters){let field_value=this.objectsRepository.query.filters[field_name];let _field_name=field_name;const filterField=this.filtersSchema.getField(_field_name);if(field_name=="regions"){_field_name="";field_value=field_value.region_ids.map((id)=>this.getRegion(id).title)}else{_field_name=filterField&&filterField.label}
1262if(field_name!=="distance"){if(!this.containers.filterTags){this.containers.filterTags=$$A('<div class="mapsvg-filter-tags"></div>')[0];if($$A(this.containers.filters));else{if(this.options.menu.on&&this.controllers.directory){$$A(this.controllers.directory.containers.toolbar).append(this.containers.filterTags);this.controllers.directory.updateTopShift()}else{$$A(this.containers.map).append(this.containers.filterTags);if(this.options.zoom.buttons.on){if(this.options.layersControl.on){if(this.options.layersControl.position=="top-left"){$$A(this.containers.filterTags).css({right:0,bottom:0,})}else{$$A(this.containers.filterTags).css({bottom:0,})}}else{if(this.options.zoom.buttons.location=="left"){$$A(this.containers.filterTags).css({right:0,})}}}}}
1263$$A(this.containers.filterTags).on("click",".mapsvg-filter-delete",(e)=>{const filterField=$$A(e.target).data("filter");$$A(e.target).parent().remove();this.objectsRepository.query.removeFilter(filterField);this.deselectAllRegions();this.loadDataObjects()})}
1264$$A(this.containers.filterTags).append('<div class="mapsvg-filter-tag">'+(_field_name?_field_name+": ":"")+field_value+' <span class="mapsvg-filter-delete" data-filter="'+field_name+'">
1264×</span></div>')}}}
1265setContainers(options){const _this=this;if(!this.containersCreated){this.containers.wrapAll=document.createElement("div");this.containers.wrapAll.classList.add("mapsvg-wrap-all");this.containers.wrapAll.id="mapsvg-map-"+this.id;this.containers.wrapAll.setAttribute("data-map-id",this.id?this.id.toString():"");this.containers.wrap=document.createElement("div");this.containers.wrap.classList.add("mapsvg-wrap");this.containers.mapContainer=document.createElement("div");this.containers.mapContainer.classList.add("mapsvg-map-container");this.containers.leftSidebar=document.createElement("div");this.containers.leftSidebar.className="mapsvg-sidebar mapsvg-top-container mapsvg-sidebar-left";this.containers.rightSidebar=document.createElement("div");this.containers.rightSidebar.className="mapsvg-sidebar mapsvg-top-container mapsvg-sidebar-right";this.containers.header=document.createElement("div");this.containers.header.className="mapsvg-header mapsvg-top-container";this.containers.footer=document.createElement("div");this.containers.footer.className="mapsvg-footer mapsvg-top-container";_this.containers.wrapAll=$$A('<div class="mapsvg-wrap-all"></div>').attr("id","mapsvg-map-"+this.id).attr("data-map-id",this.id)[0];_this.containers.wrap=$$A('<div class="mapsvg-wrap"></div>')[0];_this.containers.mapContainer=$$A('<div class="mapsvg-map-container"></div>')[0];_this.containers.leftSidebar=$$A('<div class="mapsvg-sidebar mapsvg-top-container mapsvg-sidebar-left"></div>')[0];_this.containers.rightSidebar=$$A('<div class="mapsvg-sidebar mapsvg-top-container mapsvg-sidebar-right"></div>')[0];_this.containers.header=$$A('<div class="mapsvg-header mapsvg-top-container"></div>')[0];_this.containers.footer=$$A('<div class="mapsvg-footer mapsvg-top-container"></div>')[0];$$A(_this.containers.wrapAll).insertBefore(_this.containers.map);$$A(_this.containers.wrapAll).append(_this.containers.header);$$A(_this.containers.wrapAll).append(_this.containers.wrap);$$A(_this.containers.wrapAll).append(_this.containers.footer);$$A(_this.containers.mapContainer).append(_this.containers.map);$$A(_this.containers.wrap).append(_this.containers.leftSidebar);$$A(_this.containers.wrap).append(_this.containers.mapContainer);$$A(_this.containers.wrap).append(_this.containers.rightSidebar);_this.containersCreated=!0}
1266options=options||_this.options.containers||{};for(const contName in options){if(options[contName].on!==undefined){options[contName].on=MapSVG.parseBoolean(options[contName].on)}
1267if(options[contName].width){if(typeof options[contName].width!="string"||(options[contName].width.indexOf("px")===-1&&options[contName].width.indexOf("%")===-1&&options[contName].width!=="auto")){options[contName].width=options[contName].width+"px"}
1268$$A(_this.containers[contName]).css({"flex-basis":options[contName].width})}
1269if(options[contName].height){if(typeof options[contName].height!="string"||(options[contName].height.indexOf("px")===-1&&options[contName].height.indexOf("%")===-1&&options[contName].height!=="auto")){options[contName].height=options[contName].height+"px"}
1270$$A(_this.containers[contName]).css({"flex-basis":options[contName].height,height:options[contName].height,})}
1271$$A.extend(!0,_this.options,{containers:options});let on=_this.options.containers[contName].on;if(MapSVG.isPhone&&_this.options.menu.hideOnMobile&&_this.options.menu.location===contName&&["leftSidebar","rightSidebar"].indexOf(contName)!==-1){on=!1}else if(MapSVG.isPhone&&_this.options.menu.location==="custom"&&["leftSidebar","rightSidebar"].indexOf(contName)!==-1){on=!1;$$A(_this.containers.wrapAll).addClass("mapsvg-hide-map-list-buttons")}else if(MapSVG.isPhone&&!_this.options.menu.hideOnMobile&&_this.options.menu.location===contName&&["leftSidebar","rightSidebar"].indexOf(contName)!==-1){$$A(_this.containers.wrapAll).addClass("mapsvg-hide-map-list-buttons");$$A(_this.containers.wrapAll).addClass("mapsvg-directory-visible")}
1272$$A(_this.containers[contName]).toggle(on)}
1273_this.setDetailsView()}
1274shouldBeScrollable(container){const _this=this;switch(container){case "map":case "leftSidebar":case "rightSidebar":return!0;
1274case "custom":return!1;case "header":case "footer":if(_this.options.containers[container].height&&_this.options.containers[container].height!=="auto"&&_this.options.containers[container].height!=="100%"){return!0}else{return!1}
1275default:return!1}}
1276setDirectory(options){return this.setMenu(options)}
1277setMenu(options){options=options||this.options.menu;options.on!=undefined&&(options.on=MapSVG.parseBoolean(options.on));options.search!=undefined&&(options.search=MapSVG.parseBoolean(options.search));options.showMapOnClick!=undefined&&(options.showMapOnClick=MapSVG.parseBoolean(options.showMapOnClick));options.searchFallback!=undefined&&(options.searchFallback=MapSVG.parseBoolean(options.searchFallback));options.customContainer!=undefined&&(options.customContainer=MapSVG.parseBoolean(options.customContainer));$$A.extend(!0,this.options,{menu:options});this.controllers=this.controllers||{};if(!this.containers.directory){this.containers.directory=$$A('<div class="mapsvg-directory"></div>')[0]}
1278$$A(this.containers.directory).toggleClass("flex",this.shouldBeScrollable(this.options.menu.location));if(this.options.menu.on){if(!this.controllers.directory){this.controllers.directory=new DirectoryController({container:this.containers.directory,template:this.options.templates.directory,mapsvg:this,repository:this.options.menu.source==="regions"?this.regionsRepository:this.objectsRepository,scrollable:this.shouldBeScrollable(this.options.menu.location),events:{click:(e,regionOrObject,mapsvg)=>{this.events.trigger("click.directoryItem",this,[e,regionOrObject,mapsvg,])},mouseover:(e,regionOrObject,mapsvg)=>{this.events.trigger("mouseover.directoryItem",this,[e,regionOrObject,mapsvg,])},mouseout:(e,regionOrObject,mapsvg)=>{this.events.trigger("mouseout.directoryItem",this,[e,regionOrObject,mapsvg,])},},});this.controllers.directory._init()}
1279if(options.source){this.controllers.directory.repository=this.options.menu.source==="regions"?this.regionsRepository:this.objectsRepository}
1280if(options.sortBy||options.sortDirection){this.controllers.directory.repository.query.update({sort:[{field:this.options.menu.sortBy,order:this.options.menu.sortDirection,},],})}
1281this.setFilterOut();if(options.location){this.controllers.directory.scrollable=this.shouldBeScrollable(this.options.menu.location)}
1282let $container;if(MapSVG.isPhone&&this.options.menu.hideOnMobile){$container=$$A(this.containers.leftSidebar)}else{$container=this.options.menu.location!=="custom"?$$A(this.containers[this.options.menu.location]):$$A("#"+this.options.menu.containerId)}
1283$container.append(this.containers.directory);if(this.options.colors.directory){$$A(this.containers.directory).css({"background-color":this.options.colors.directory,})}
1284this.setFilters();this.setTemplates({directoryItem:this.options.templates.directoryItem});if((this.options.menu.source==="regions"&&this.regionsRepository.loaded)||(this.options.menu.source==="database"&&this.objectsRepository.loaded)){if(this.editMode&&(options.sortBy||options.sortDirection||options.filterout)){this.controllers.directory.repository.reload()}
1285this.loadDirectory()}}else{this.controllers.directory&&this.controllers.directory.destroy();this.controllers.directory=null}}
1286setDatabase(options){options=options||this.options.database;if(options.pagination){if(options.pagination.on!=undefined){options.pagination.on=MapSVG.parseBoolean(options.pagination.on)}
1287if(options.pagination.perpage!=undefined){options.pagination.perpage=parseInt(options.pagination.perpage)}}
1288$$A.extend(!0,this.options,{database:options});if(options.pagination){if(options.pagination.on!==undefined||options.pagination.perpage){const query=new Query({perpage:this.options.database.pagination.on?this.options.database.pagination.perpage:0,});this.objectsRepository.find(query)}else{this.setPagination()}}}
1289updateGoogleMapsMaxZoom(geoPoint){this.googleMaps.maxZoomService.getMaxZoomAtLatLng(geoPoint,(result)=>{if(result.status==="OK"){this.googleMaps.currentMaxZoom=result.zoom}})}
1290setGoogleMaps(options){options=options||this.options.googleMaps;options.on!=undefined&&(options.on=MapSVG.parseBoolean(options.on));if(!this.googleMaps){this.googleMaps={loaded:!1,initialized:!1,map:null,overlay:null}}
1291$$A.extend(!0,this.options,{googleMaps:options});if(this.options.googleMaps.on){$$A(this.containers.map).toggleClass("mapsvg-with-google-map",!0);if(!MapSVG.googleMapsApiLoaded){this.loadGoogleMapsAPI(()=>{this.setGoogleMaps()},()=>{this.setGoogleMaps({on:!1})})}else{if(!this.googleMaps.map){this.containers.googleMaps=$$A('<div class="mapsvg-layer mapsvg-layer-gm" id="mapsvg-google-maps-'+this.id+'"></div>').prependTo(this.containers.map)[0];$$A(this.containers.googleMaps).css({position:"absolute",top:0,left:0,bottom:0,right:0,"z-index":"0",});this.googleMaps.map=new google.maps.Map(this.containers.googleMaps,{mapTypeId:options.type,fullscreenControl:!1,keyboardShortcuts:!1,mapTypeControl:!1,scaleControl:!1,scrollwheel:!1,streetViewControl:!1,zoomControl:!1,styles:options.styleJSON,tilt:0,});const southWest=new google.maps.LatLng(this.geoViewBox.sw.lat,this.geoViewBox.sw.lng);const northEast=new google.maps.LatLng(this.geoViewBox.ne.lat,this.geoViewBox.ne.lng);const bounds=new google.maps.LatLngBounds(southWest,northEast);this.googleMaps.overlay=this.createGoogleMapOverlay(bounds,this.googleMaps.map);if(!this.options.googleMaps.center||!this.options.googleMaps.zoom){this.googleMaps.map.fitBounds(bounds,0)}else{this.googleMaps.map.setZoom(this.options.googleMaps.zoom);this.googleMaps.map.setCenter(this.options.googleMaps.center)}
1292this.googleMaps.initialized=!0;this.googleMaps.maxZoomService=new google.maps.MaxZoomService();this.googleMaps.map.addListener("idle",()=>{this.isZooming=!1});google.maps.event.addListenerOnce(this.googleMaps.map,"idle",()=>{setTimeout(()=>{$$A(this.containers.map).addClass("mapsvg-fade-in");setTimeout(()=>{$$A(this.containers.map).removeClass("mapsvg-google-map-loading");$$A(this.containers.map).removeClass("mapsvg-fade-in");
1292if(!this.options.googleMaps.center||!this.options.googleMaps.zoom){this.options.googleMaps.center=this.googleMaps.map.getCenter().toJSON();this.options.googleMaps.zoom=this.googleMaps.map.getZoom()}
1293this.zoomDelta=this.options.googleMaps.zoom-this.zoomLevel;this.updateGoogleMapsMaxZoom(this.options.googleMaps.center);this.setInitialViewBox(this.viewBox);this.toggleSvgLayerOnZoom();this.events.trigger("googleMapsLoaded");this.afterLoadBlockers--;this.finalizeMapLoading()},300)},1)});this.events.on("googleMapsBoundsChanged",(bounds)=>{this.setViewBoxByGoogleMapsOverlay()})}else{$$A(this.containers.map).toggleClass("mapsvg-with-google-map",!0);$$A(this.containers.googleMaps)&&$$A(this.containers.googleMaps).show();if(options.type){this.googleMaps.map.setMapTypeId(options.type)}
1294this.setViewBoxByGoogleMapsOverlay()}}}else{$$A(this.containers.map).toggleClass("mapsvg-with-google-map",!1);$$A(this.containers.googleMaps)&&$$A(this.containers.googleMaps).hide();this.googleMaps.initialized=!1}
1295if(this.converter){this.converter.setWorldShift(this.options.googleMaps.on)}}
1296createGoogleMapOverlay(bounds,map){class GoogleMapsOverlay extends google.maps.OverlayView{constructor(bounds,googleMap
1296Instance,mapsvg){super();this.bounds_=bounds;this.map_=googleMapInstance;this.mapsvg=mapsvg;this.setMap(googleMapInstance);this.prevCoords={sw:{x:0,y:0},sw2:{x:0,y:0},ne:{x:0,y:0},ne2:{x:0,y:0},}}
1297draw(){this.mapsvg.events.trigger("googleMapsBoundsChanged",this.map_,[this.getPixelBounds(),this.map_,])}
1298onAdd(){this.element=document.createElement("div");this.element.style.borderStyle="none";this.element.style.borderWidth="0px";this.element.style.position="absolute";const panes=this.getPanes();panes.overlayLayer.appendChild(this.element)}
1299getPixelBounds(){const overlayProjection=this.getProjection();if(!overlayProjection)
1300return;const geoSW=this.bounds_.getSouthWest();const geoNE=this.bounds_.getNorthEast();const coords={sw:overlayProjection.fromLatLngToDivPixel(geoSW),ne:overlayProjection.fromLatLngToDivPixel(geoNE),sw2:overlayProjection.fromLatLngToContainerPixel(geoSW),ne2:overlayProjection.fromLatLngToContainerPixel(geoNE),};const ww=overlayProjection.getWorldWidth();if(this.prevCoords.sw){if(coords.ne.x<coords.sw.x){if(Math.abs(this.prevCoords.sw.x-coords.sw.x)>Math.abs(this.prevCoords.ne.x-coords.ne.x)){coords.sw.x=coords.sw.x-ww}else{coords.ne.x=coords.ne.x+ww}
1301if(Math.abs(this.prevCoords.sw2.x-coords.sw2.x)>Math.abs(this.prevCoords.ne2.x-coords.ne2.x)){coords.sw2.x=coords.sw2.x-ww}else{coords.ne2.x=coords.ne2.x+ww}}}
1302this.prevCoords=coords;return{sw:coords.sw2,ne:coords.ne2}}}
1303return new GoogleMapsOverlay(bounds,map,this)}
1304loadGoogleMapsAPI(callback,fail){if(!this.options.googleMaps.apiKey){console.error("MapSVG: can't load Google API because no API key has been provided");return}
1305if(window.google!==undefined&&google.maps){MapSVG.googleMapsApiLoaded=!0}
1306if(MapSVG.googleMapsApiLoaded){if(typeof callback=="function"){callback()}
1307return}
1308MapSVG.googleMapsLoadCallbacks=MapSVG.googleMapsLoadCallbacks||[];if(typeof callback=="function"){MapSVG.googleMapsLoadCallbacks.push(callback)}
1309if(MapSVG.googleMapsApiIsLoading){return}
1310MapSVG.googleMapsApiIsLoading=!0;window.gm_authFailure=()=>{if(MapSVG.GoogleMapBadApiKey){MapSVG.GoogleMapBadApiKey()}else{if(this.editMode){alert("Google maps API key is incorrect.")}else{console.error("MapSVG: Google maps API key is incorrect.")}}};this.googleMapsScript=document.createElement("script");this.googleMapsScript.onload=()=>{MapSVG.googleMapsApiLoaded=!0;MapSVG.googleMapsLoadCallbacks.forEach((_callback)=>{if(typeof callback=="function")
1311_callback()})};const gmLibraries=[];if(this.options.googleMaps.drawingTools){gmLibraries.push("drawing")}
1312if(this.options.googleMaps.geometry){gmLibraries.push("geometry")}
1313let libraries="";if(gmLibraries.length>0){libraries="&libraries="+gmLibraries.join(",")}
1314this.googleMapsScript.src="https://maps.googleapis.com/maps/api/js?language="+this.options.googleMaps.language+"&key="+this.options.googleMaps.apiKey+libraries;document.head.appendChild(this.googleMapsScript)}
1315loadDetailsView(obj){this.controllers.popover&&this.controllers.popover.close();if(this.controllers.detailsView)
1316this.controllers.detailsView.destroy();this.controllers.detailsView=new DetailsController({autoresize:MapSVG.isPhone&&this.options.detailsView.mobileFullscreen&&this.options.detailsView.location!=="custom"?!1:this.options.detailsView.autoresize,container:this.containers.detailsView,template:obj instanceof Region?this.options.templates.detailsViewRegion:this.options.templates.detailsView,mapsvg:this,data:obj.getData(),modal:MapSVG.isPhone&&this.options.detailsView.mobileFullscreen&&this.options.detailsView.location!=="custom",scrollable:(MapSVG.isPhone&&this.options.detailsView.mobileFullscreen&&this.options.detailsView.location!=="custom")||this.shouldBeScrollable(this.options.detailsView.location),withToolbar:!(MapSVG.isPhone&&this.options.detailsView.mobileFullscreen&&this.options.detailsView.location!=="custom")&&this.shouldBeScrollable(this.options.detailsView.location),events:{shown:(detailsController)=>{this.events.trigger("shown.detailsView",this,[this,detailsController]);$$A(window).trigger("shown.detailsView",[this,detailsController])},closed:(detailsController)=>{this.deselectAllRegions();this.deselectAllMarkers();this.controllers&&this.controllers.directory&&this.controllers.directory.deselectItems();this.events.trigger("closed.detailsView",[this,detailsController])},},});this.controllers.detailsView._init()}
1317loadFiltersModal(){if(this.options.filters.modalLocation!="custom"){if(!this.containers.filtersModal){this.containers.filtersModal=$$A('<div class="mapsvg-details-container mapsvg-filters-wrap"></div>')[0]}
1318this.setColors();$$A(this.containers.filtersModal).css({width:this.options.filters.width});if(MapSVG.isPhone){$$A("body").append($$A(this.containers.filtersModal));$$A(this.containers.filtersModal).css({width:""})}else{$$A(this.containers[this.options.filters.modalLocation]).append($$A(this.containers.filtersModal))}}else{this.containers.filtersModal=$$A("#"+this.options.filters.containerId)[0];$$A(this.containers.filtersModal).css({width:""})}
1319this.loadFiltersController(this.containers.filtersModal,!0)}
1320loadFiltersController(container,modal=!1){if(!this.filtersShouldBeShown()){return}
1321let filtersInDirectory,filtersHide;if(MapSVG.isPhone){filtersInDirectory=!0;filtersHide=this.options.filters.hideOnMobile}else{filtersInDirectory=this.options.menu.on&&this.controllers.directory&&this.options.menu.location===this.options.filters.location;filtersHide=this.options.filters.hide}
1322const scrollable=modal||(!filtersInDirectory&&["leftSidebar","rightSidebar"].indexOf(this.options.filters.location)!==-1);this.filtersRepository=this.options.filters.source==="regions"?this.regionsRepository:this.objectsRepository;if(this.options.filters.searchButton){this.changedFields=null;this.changedSearch=null}else{this.changedSearch=()=>{this.filtersRepository.query.searchFallback=this.filtersSchema.getFieldByType("search").searchFallback;this.throttle(this.filtersRepository.reload,400,this.filtersRepository)};this.changedFields=()=>{this.throttle(this.filtersRepository.reload,400,this.filtersRepository)}}
1323this.controllers.filters=new FiltersController({container:container,query:this.filtersRepository.query,mapsvg:this,schema:this.filtersSchema,template:'<div class="mapsvg-filters-container"></div>',scrollable:scrollable,modal:modal,withToolbar:MapSVG.isPhone?!1:modal,width:$$A(container).hasClass("mapsvg-map-container")?this.options.filters.width:"100%",hide:this.options.filters.hide,hideOnMobile:this.options.filters.hideOnMobile,showButtonText:this.options.filters.showButtonText,clearButton:this.options.filters.clearButton,clearButtonText:this.options.filters.clearButtonText,searchButton:this.options.filters.searchButton,searchButtonText:this.options.filters.searchButtonText,padding:this.options.filters.padding,events:{cleared:()=>{this.deselectAllRegions();this.filtersRepository.reload()},"changed.fields":this.changedFields,"changed.search":this.changedSearch,"click.btn.searchButton":()=>{this.filtersRepository.reload()},loaded:()=>{this.controllers.directory&&this.controllers.directory.updateTopShift();this.afterLoadBlockers--;this.finalizeMapLoading()},"click.btn.showFilters":()=>{this.loadFiltersModal()},},});this.controllers.filters._init()}
1324filtersShouldBeShown(){return(this.options.filters.on&&this.options.filtersSchema&&this.options.filtersSchema.length>0)}
1325textSearch(text,fallback=!1){const query=new Query({filters:{search:text},searchFallback:fallback,});this.filtersRepository.find(query)}
1326getRegion(id){return this.regions.findById(id)}
1327getRegions(){return this.regions}
1328getMarker(id){return this.markers.findById(id)}
1329checkId(id){if(this.getRegion(id))
1330return{canUse:!1,error:"This ID is already being used by a Region"};else if(this.getMarker(id))
1331return{canUse:!1,error:"This ID is already being used by another Marker"};else return{canUse:!0,error:""}}
1332regionsRedrawColors(){this.regions.forEach((region)=>{region.setFill()})}
1333redrawBubbles(){$$A(this.containers.map).removeClass("bubbles-regions-on bubbles-database-on");if(this.options.choropleth.on&&this.options.choropleth.bubbleMode){$$A(this.containers.map).addClass("bubbles-"+this.options.choropleth.source+"-on")}
1334this.regions.forEach(function(region){region.drawBubble()});const markersBubbleMode=this.options.choropleth.on&&this.options.choropleth.source=="database"&&this.options.choropleth.bubbleMode;
1334this.markers.forEach(function(marker){marker.setBubbleMode(markersBubbleMode)})}
1335destroy(){if(this.controllers&&this.controllers.directory){this.controllers.directory.mobileButtons.remove()}
1336$$A(this.containers.map).empty().insertBefore($$A(this.containers.wrapAll)).attr("style","").removeClass("mapsvg mapsvg-responsive");this.controllers.popover&&this.controllers.popover.close();if(this.controllers.detailsView)
1337this.controllers.detailsView.destroy();$$A(this.containers.detailsView).remove();$$A(this.containers.popover).remove();$$A(this.containers.tooltip).remove();$$A(this.containers.wrapAll).remove()}
1338getData(){return{id:this.id,title:this.options.title,options:this.getOptions(!1,!1),}}
1339mayBeFitMarkers(){if(!this.lastTimeFitWas){this.lastTimeFitWas=Date.now()-99999}
1340this.fitDelta=Date.now()-this.lastTimeFitWas;if(this.fitDelta>1000&&!this.firstDataLoad&&!this.fitOnDataLoadDone&&this.options.fitMarkers){this.fitMarkers();this.fitOnDataLoadDone=!0}
1341if(this.firstDataLoad&&(this.options.fitMarkersOnStart||(this.options.fitMarkers&&this.options.database.loadOnStart===!1))){this.firstDataLoad=!1;if(this.options.googleMaps.on&&!this.googleMaps.map){this.events.on("googleMapsLoaded",()=>{this.fitMarkers()})}else{this.fitMarkers()}}
1342this.lastTimeFitWas=Date.now()}
1343fitMarkers(){const dbObjects=this.objectsRepository.getLoaded();if(!dbObjects||dbObjects.length===0){return}
1344if(this.options.googleMaps.on&&typeof google!=="undefined"){const lats=[];const lngs=[];if(dbObjects.length>1){dbObjects.forEach((object)=>{if(object.location&&object.location.geoPoint){lats.push(object.location.geoPoint.lat);lngs.push(object.location.geoPoint.lng)}});const minlat=Math.min.apply(null,lats),maxlat=Math.max.apply(null,lats);const minlng=Math.min.apply(null,lngs),maxlng=Math.max.apply(null,lngs);const bbox=new google.maps.LatLngBounds({lat:minlat,lng:minlng},{lat:maxlat,lng:maxlng});this.googleMaps.map.fitBounds(bbox,0)}else{if(dbObjects[0].location&&dbObjects[0].location.geoPoint.lat&&dbObjects[0].location.geoPoint.lng){const coords={lat:dbObjects[0].location.geoPoint.lat,lng:dbObjects[0].location.geoPoint.lng,};if(this.googleMaps.map){this.googleMaps.map.setCenter(coords);this.googleMaps.map.setZoom(this.options.fitSingleMarkerZoom)}}}}else{if(this.options.clustering.on){const arr=[];this.markersClusters.forEach((c)=>{arr.push(c)});this.markers.forEach((m)=>{arr.push(m)});this.zoomTo(arr);return}else{this.zoomTo(this.markers);return}}}
1345setFitSingleMarkerZoom(zoom){this.options.fitSingleMarkerZoom=parseInt(zoom)}
1346showUserLocation(callback){this.getUserLocation((geoPoint)=>{this.userLocation=null;this.userLocation=new Location({geoPoint:geoPoint,img:MapSVG.urls.root+"/markers/user-location.svg",});this.userLocationMarker&&this.userLocationMarker.delete();this.userLocationMarker=new Marker({location:this.userLocation,mapsvg:this,width:15,height:15,});$$A(this.userLocationMarker.element).addClass("mapsvg-user-location");this.userLocationMarker.centered=!0;this.getLayer("markers").append(this.userLocationMarker.element);this.userLocationMarker.adjustScreenPosition();callback&&callback(this.userLocation)})}
1347getUserLocation(callback){if(navigator.geolocation){navigator.geolocation.getCurrentPosition(function(position){const pos=new GeoPoint(position.coords.latitude,position.coords.longitude);callback&&callback(pos)})}else{return!1}}
1348getScale(){const scale2=this.containers.map.clientWidth/this.viewBox.width;return scale2||1}
1349getViewBox(){return this.viewBox}
1350viewBoxSetBySize(width,height){this.setSize(width,height);this._viewBox.update(this.viewBoxGetBySize(width,height));this.setViewBox(this._viewBox);$$A(window).trigger("resize");this.setSize(width,height);this.setZoomLevels();return this.viewBox}
1351viewBoxGetBySize(width,height){const new_ratio=width/height;const old_ratio=this.svgDefault.viewBox.width/this.svgDefault.viewBox.height;const vb=this.svgDefault.viewBox.clone();if(new_ratio!=old_ratio){if(new_ratio>old_ratio){vb.width=this.svgDefault.viewBox.height*new_ratio;vb.x=this.svgDefault.viewBox.x-(vb.width-this.svgDefault.viewBox.width)/2}else{vb.height=this.svgDefault.viewBox.width/new_ratio;vb.y=this.svgDefault.viewBox.y-(vb.height-this.svgDefault.viewBox.height)/2}}
1352return vb}
1353viewBoxReset(toInitial){if(this.options.googleMaps.on&&this.googleMaps.map){if(!toInitial){this.options.googleMaps.center=null;this.options.googleMaps.zoom=null}
1354if(!this.options.googleMaps.center||!this.options.googleMaps.zoom){const southWest=new google.maps.LatLng(this.geoViewBox.sw.lat,this.geoViewBox.sw.lng);const northEast=new google.maps.LatLng(this.geoViewBox.ne.lat,this.geoViewBox.ne.lng);const bounds=new google.maps.LatLngBounds(southWest,northEast);this.googleMaps.map.fitBounds(bounds,0);this.options.googleMaps.center=this.googleMaps.map.getCenter().toJSON();this.options.googleMaps.zoom=this.googleMaps.map.getZoom()}else{this.googleMaps.map.setZoom(this.options.googleMaps.zoom);this.googleMaps.map.setCenter(this.options.googleMaps.center)}}else{if(toInitial){const v=this._viewBox||this.svgDefault.viewBox;this.zoomLevel=0;this._scale=1;this.setViewBox(v)}else{this.setViewBox()}}
1355return this.viewBox}
1356getGeoViewBox(){const v=this.viewBox;const p1=new SVGPoint(v.x,v.y);const p2=new SVGPoint(v.x+v.width,v.y);const p3=new SVGPoint(v.x,v.y);const p4=new SVGPoint(v.x,v.y+v.height);const leftLon=this.converter.convertSVGToGeo(p1).lng;const rightLon=this.converter.convertSVGToGeo(p2).lng;const topLat=this.converter.convertSVGToGeo(p3).lat;const bottomLat=this.converter.convertSVGToGeo(p4).lat;
1356return[leftLon,topLat,rightLon,bottomLat]}
1357setStrokes(){$$A(this.containers.svg).find("path, polygon, circle, ellipse, rect, line, polyline").each((index,elem)=>{const width=MapObject.getComputedStyle("stroke-width",elem);if(width){$$A(elem).attr("data-stroke-width",width.replace("px",""))}})}
1358adjustStrokes(){$$A(this.containers.svg).find("path, polygon, circle, ellipse, rect, line, polyline").each((index,elem)=>{const width=elem.getAttribute("data-stroke-width");if(width){$$A(elem).css("stroke-width",Number(width)/this.scale)}})}
1359zoomIn(center){if(this.canZoom){this.isZooming=!0;this.canZoom=!1;setTimeout(()=>{this.isZooming=!1;this.canZoom=!0},700);this.zoom(1,center)}}
1360zoomOut(center){if(this.canZoom){this.isZooming=!0;this.canZoom=!1;setTimeout(()=>{this.isZooming=!1;this.canZoom=!0},700);this.zoom(-1,center)}}
1361zoomTo(mapObjects,zoomToLevel){if(mapObjects instanceof Marker||mapObjects instanceof MarkerCluster){return this.zoomToMarkerOrCluster(mapObjects,zoomToLevel)}else{const convertedObjects=!Array.isArray(mapObjects)?[mapObjects]:mapObjects;const bbox=this.getGroupBBox(convertedObjects);return this.fitViewBox(bbox,zoomToLevel)}}
1362zoomToMarkerOrCluster(mapObject,zoomToLevel){this.zoomLevel=zoomToLevel||1;const foundZoomLevel=this.zoomLevels.get(this.zoomLevel);if(!foundZoomLevel){return!1}
1363const vb=foundZoomLevel.viewBox;if(this.canZoom){this.isZooming=!0;this.canZoom=!1;setTimeout(()=>{this.isZooming=!1;this.canZoom=!0},700);const vbNew=new ViewBox(mapObject.svgPoint.x-vb.width/2,mapObject.svgPoint.y-vb.height/2,vb.width,vb.height);this.setViewBox(vbNew);this._scale=foundZoomLevel._scale;return!0}
1364return!1}
1365getGroupBBox(mapObjects){let _bbox;const xmax=[];const ymax=[];const xmin=[];const ymin=[];for(let i=0;i<mapObjects.length;i++){_bbox=mapObjects[i].getBBox();xmin.push(_bbox.x);ymin.push(_bbox.y);const _w=_bbox.x+_bbox.width;const _h=_bbox.y+_bbox.height;xmax.push(_w);ymax.push(_h)}
1366const _xmin=Math.min(...xmin);const _ymin=Math.min(...ymin);const width=Math.max(...xmax)-_xmin;const height=Math.max(...ymax)-_ymin;let padding=10;const point1=new ScreenPoint(padding,0);const point2=new ScreenPoint(0,0);padding=this.converter.convertPixelToSVG(point1).x-this.converter.convertPixelToSVG(point2).x;return new ViewBox(_xmin-padding,_ymin-padding,width+padding*2,height+padding*2)}
1367fitViewBox(fitViewBox,forceZoomLevel){let viewBoxPrev;let foundZoomLevelNumber=0;let foundZoomLevel;let newViewBox;
1367this.zoomLevels.forEach((zoomLevel)=>{if(viewBoxPrev&&viewBoxPrev.x!==undefined){if(fitViewBox.fitsInViewBox(viewBoxPrev)&&zoomLevel.viewBox.fitsInViewBox(fitViewBox,!0)){foundZoomLevelNumber=forceZoomLevel?forceZoomLevel:zoomLevel.zoomLevel;foundZoomLevel=this.zoomLevels.get(foundZoomLevelNumber);newViewBox=new ViewBox(fitViewBox.x-foundZoomLevel.viewBox.width/2+fitViewBox.width/2,fitViewBox.y-foundZoomLevel.viewBox.height/2+fitViewBox.height/2,foundZoomLevel.viewBox.width,foundZoomLevel.viewBox.height)}}
1368viewBoxPrev=zoomLevel&&zoomLevel.viewBox});if(foundZoomLevel){if(this.canZoom){this.isZooming=!0;this.canZoom=!1;setTimeout(()=>{this.isZooming=!1;this.canZoom=!0},700);this.zoomLevel=foundZoomLevelNumber;this._scale=foundZoomLevel._scale;this.setViewBox(newViewBox);return!0}}else{return!1}}
1369zoomToRegion(region,zoomToLevel){this.fitViewBox(region.getBBox(),zoomToLevel);return!0}
1370centerOn(region,yShift){if(this.options.googleMaps.on){yShift=yShift?(yShift+12)/this.getScale():0;$$A(this.containers.map).addClass("scrolling");const latLng=region.getCenterLatLng(yShift);this.googleMaps.map.panTo(latLng);setTimeout(()=>{$$A(this.containers.map).removeClass("scrolling")},100)}else{yShift=yShift?(yShift+12)/this.getScale():0;const bbox=region.getBBox();const vb=this.viewBox;const newViewBox=new ViewBox(bbox.x-vb.width/2+bbox.width/2,bbox.y-vb.height/2+bbox.height/2-yShift,vb.width,vb.height);this.setViewBox(newViewBox)}}
1371zoom(delta,center){let newViewBox=new ViewBox(0,0,0,0);const d=delta>0?1:-1;if(!this.zoomLevels.get(this.zoomLevel+d))
1372return;const newZoomLevel=this.zoomLevel+d;const zoomIn=d>0;const zoomOut=d<0;const zoomRange=this.getZoomRange();const isInZoomRange=this.zoomLevel>=zoomRange.min&&this.zoomLevel<=zoomRange.max;const goingOutOfZoomRange=isInZoomRange&&(newZoomLevel>zoomRange.max||newZoomLevel<zoomRange.min);const outOfRangeAndMovingAway=!isInZoomRange&&((zoomIn&&newZoomLevel>zoomRange.max)||(zoomOut&&newZoomLevel<zoomRange.min));if(goingOutOfZoomRange||outOfRangeAndMovingAway){return}
1373this.zoomLevel=newZoomLevel;const z=this.zoomLevels.get(this.zoomLevel);this._scale=z._scale;newViewBox=z.viewBox;let shift=[];if(center){const koef=zoomIn?0.5:-1;newViewBox.x=this.viewBox.x+(center.x-this.viewBox.x)*koef;newViewBox.y=this.viewBox.y+(center.y-this.viewBox.y)*koef}else{shift=[(this.viewBox.width-newViewBox.width)/2,(this.viewBox.height-newViewBox.height)/2,];newViewBox.x=this.viewBox.x+shift[0];newViewBox.y=this.viewBox.y+shift[1]}
1374this.shiftViewBoxToScrollBoundaries(newViewBox);this.setViewBox(newViewBox)}
1375toggleSvgLayerOnZoom(){if(this.options.googleMaps.on&&this.googleMaps.map&&this.options.zoom.hideSvg&&this.googleMaps.map.getZoom()>=this.options.zoom.hideSvgZoomLevel){if(!$$A(this.containers.svg).hasClass("mapsvg-invisible")){$$A(this.containers.svg).animate({opacity:0}
1375,400,"linear",()=>{$$A(this.containers.svg).addClass("mapsvg-invisible")})}}else{if($$A(this.containers.svg).hasClass("mapsvg-invisible")){$$A(this.containers.svg).animate({opacity:1},400,"linear",()=>{$$A(this.containers.svg).removeClass("mapsvg-invisible")})}}}
1376shiftViewBoxToScrollBoundaries(newViewBox){if(this.options.scroll.limit){if(newViewBox.x<this.svgDefault.viewBox.x)
1377newViewBox.x=this.svgDefault.viewBox.x;else if(newViewBox.x+newViewBox.width>this.svgDefault.viewBox.x+this.svgDefault.viewBox.width)
1378newViewBox.x=this.svgDefault.viewBox.x+this.svgDefault.viewBox.width-newViewBox.width;if(newViewBox.y<this.svgDefault.viewBox.y)
1379newViewBox.y=this.svgDefault.viewBox.y;else if(newViewBox.y+newViewBox.height>this.svgDefault.viewBox.y+this.svgDefault.viewBox.height)
1380newViewBox.y=this.svgDefault.viewBox.y+this.svgDefault.viewBox.height-newViewBox.height}
1381return newViewBox}
1382markerDelete(marker){if(this.editingMarker&&this.editingMarker.id==marker.id){this.unsetEditingMarker()}
1383if(this.markers.findById(marker.id)){this.markers.delete(marker.id)}
1384marker.delete();marker=null;if(this.markers.length===0)
1385this.options.markerLastID=0}
1386markersClusterAdd(markersCluster){this.layers.markers.append(markersCluster.elem);this.markersClusters.push(markersCluster);markersCluster.adjustScreenPosition()}
1387markerAdd(marker){$$A(marker.element).hide();marker.adjustScreenPosition();this.layers.markers.append(marker.element);this.markers.push(marker);marker.mapped=!0;setTimeout(function(){$$A(marker.element).show()},100)}
1388markerRemove(marker){if(this.editingMarker&&this.editingMarker.id==marker.id){this.editingMarker=null;delete this.editingMarker}
1389if(this.markers.findById(marker.id)){this.markers.findById(marker.id).element.remove();this.markers.delete(marker.id);marker=null}
1390if(this.markers.length===0)
1391this.options.markerLastID=0}
1392markerId(){this.options.markerLastID=this.options.markerLastID+1;const id="marker_"+this.options.markerLastID;if(this.getMarker(id))
1393return this.markerId();else return id}
1394movingItemsAdjustScreenPosition(){this.markersAdjustScreenPosition();this.popoverAdjustScreenPosition();this.bubblesRegionsAdjustScreenPosition();this.labelsRegionsAdjustScreenPosition()}
1395movingItemsMoveScreenPositionBy(deltaX,deltaY){this.markersMoveScreenPositionBy(deltaX,deltaY);this.popoverMoveScreenPositionBy(deltaX,deltaY);this.bubblesRegionsMoveScreenPositionBy(deltaX,deltaY);this.labelsRegionsMoveScreenPositionBy(deltaX,deltaY)}
1396labelsRegionsAdjustScreenPosition(){if($$A(this.containers.map).is(":visible")){this.regions.forEach(function(region){region.adjustLabelScreenPosition()})}}
1397bubblesRegionsAdjustScreenPosition(){if($$A(this.containers.map).is(":visible")){this.regions.forEach(function(region){region.adjustBubbleScreenPosition()})}}
1398labelsRegionsMoveScreenPositionBy(deltaX,deltaY){if($$A(this.containers.map).is(":visible")){this.regions.forEach(function(region){region.moveLabelScreenPositionBy(deltaX,deltaY)})}}
1399bubblesRegionsMoveScreenPositionBy(deltaX,deltaY){if($$A(this.containers.map).is(":visible")){this.regions.forEach((region)=>{region.moveBubbleScreenPositionBy(deltaX,deltaY)})}}
1400markersAdjustScreenPosition(){this.markers.forEach((marker)=>{marker.adjustScreenPosition()});this.markersClusters.forEach((cluster)=>{cluster.adjustScreenPosition()});if(this.userLocationMarker){this.userLocationMarker.adjustScreenPosition()}}
1401markersMoveScreenPositionBy(deltaX,deltaY){this.markers.forEach((marker)=>{marker.moveSrceenPositionBy(deltaX,deltaY)});this.markersClusters.forEach((cluster)=>{cluster.moveSrceenPositionBy(deltaX,deltaY)});if(this.userLocationMarker){this.userLocationMarker.moveSrceenPositionBy(deltaX,deltaY)}}
1402setEditingMarker(marker){this.editingMarker=marker;if(!this.editingMarker.mapped){this.editingMarker.needToRemove=!0;this.markerAdd(this.editingMarker)}}
1403unsetEditingMarker(){if(this.editingMarker&&this.editingMarker.needToRemove){this.markerRemove(this.editingMarker)}
1404this.editingMarker=null}
1405getEditingMarker(){return this.editingMarker}
1406scrollStart(e,mapsvg){if($$A(e.target).hasClass("mapsvg-btn-map")||$$A(e.target).closest(".mapsvg-choropleth").length)
1407return;if(this.editMarkers.on&&$$A(e.target).hasClass("mapsvg-marker"))
1408return;e.preventDefault();$$A(this.containers.map).addClass("no-transitions");const ce=e.originalEvent&&e.originalEvent.touches&&e.originalEvent.touches[0]?e.originalEvent.touches[0]:e;this.scrollStarted=!0;this.scroll={tx:this.scroll.tx||0,ty:this.scroll.ty||0,vxi:this.viewBox.x,vyi:this.viewBox.y,x:ce.clientX,y:ce.clientY,dx:0,dy:0,vx:0,vy:0,gx:ce.clientX,gy:ce.clientY,touchScrollStart:0,};
1408if(e.type.indexOf("mouse")===0){$$A(document).on("mousemove.scroll.mapsvg",(e)=>{this.scrollMove(e)});if(this.options.scroll.spacebar){$$A(document).on("keyup.scroll.mapsvg",(e)=>{if(e.keyCode==32){this.scrollEnd(e,mapsvg)}})}else{$$A(document).on("mouseup.scroll.mapsvg",(e)=>{this.scrollEnd(e,mapsvg)})}}}
1409scrollMove(e){e.preventDefault();if(!this.isScrolling){this.isScrolling=!0;$$A(this.containers.map).addClass("scrolling")}
1410const ce=e.originalEvent&&e.originalEvent.touches&&e.originalEvent.touches[0]?e.originalEvent.touches[0]:e;this.panBy(this.scroll.gx-ce.clientX,this.scroll.gy-ce.clientY);this.scroll.gx=ce.clientX;this.scroll.gy=ce.clientY;this.scroll.dx=this.scroll.x-ce.clientX;this.scroll.dy=this.scroll.y-ce.clientY;let vx=this.scroll.vxi+this.scroll.dx/this.scale;let vy=this.scroll.vyi+this.scroll.dy/this.scale;if(this.options.scroll.limit){if(vx<this.svgDefault.viewBox.x)
1411vx=this.svgDefault.viewBox.x;else if(this.viewBox.width+vx>this.svgDefault.viewBox.x+this.svgDefault.viewBox.width)
1412vx=this.svgDefault.viewBox.x+this.svgDefault.viewBox.width-this.viewBox.width;if(vy<this.svgDefault.viewBox.y)
1413vy=this.svgDefault.viewBox.y;else if(this.viewBox.height+vy>this.svgDefault.viewBox.y+this.svgDefault.viewBox.height)
1414vy=this.svgDefault.viewBox.y+this.svgDefault.viewBox.height-this.viewBox.height}
1415this.scroll.vx=vx;this.scroll.vy=vy}
1416scrollEnd(e,mapsvg,noClick){setTimeout(()=>{this.enableAnimation();this.scrollStarted=!1;this.isScrolling=!1},100);if(this.googleMaps&&this.googleMaps.overlay){this.googleMaps.overlay.draw()}
1417$$A(this.containers.map).removeClass("scrolling");$$A(document).off("keyup.scroll.mapsvg");$$A(document).off("mousemove.scroll.mapsvg");$$A(document).off("mouseup.scroll.mapsvg");if(noClick!==!0&&Math.abs(this.scroll.dx)<5&&Math.abs(this.scroll.dy)<5){if(this.editMarkers.on)
1418this.clickAddsMarker&&this.markerAddClickHandler(e);else if(this.objectClickedBeforeScroll)
1419if(this.objectClickedBeforeScroll instanceof Marker){this.markerClickHandler(e,this.objectClickedBeforeScroll)}else if(this.objectClickedBeforeScroll instanceof Region){this.regionClickHandler(e,this.objectClickedBeforeScroll)}else if(this.objectClickedBeforeScroll instanceof MarkerCluster){this.markerClusterClickHandler(e,this.objectClickedBeforeScroll)}}
1420this.viewBox.x=this.scroll.vx||this.viewBox.x;this.viewBox.y=this.scroll.vy||this.viewBox.y}
1421setViewBoxByGoogleMapsOverlay(){const bounds=this.googleMaps.overlay.getPixelBounds();const scale=(bounds.ne.x-bounds.sw.x)/this.svgDefault.viewBox.width;const vb=new ViewBox(this.svgDefault.viewBox.x-bounds.sw.x/scale,this.svgDefault.viewBox.y-bounds.ne.y/scale,this.containers.map.offsetWidth/scale,this.containers.map.offsetHeight/scale);this.setViewBox(vb,!1)}
1422panBy(x,y){let tx=this.scroll.tx-x;let ty=this.scroll.ty-y;const scrolled={x:!0,y:!0};if(this.options.scroll.limit){const svg=$$A(this.containers.svg)[0].getBoundingClientRect();const bounds=$$A(this.containers.map)[0].getBoundingClientRect();if((svg.left-x>bounds.left&&x<0)||(svg.right-x<bounds.right&&x>0)){tx=this.scroll.tx;scrolled.x=!1}
1423if((svg.top-y>bounds.top&&y<0)||(svg.bottom-y<bounds.bottom&&y>0)){ty=this.scroll.ty;scrolled.y=!1}}
1424$$A(this.containers.scrollpane).css({transform:"translate("+tx+"px,"+ty+"px)",});this.scroll.tx=tx;this.scroll.ty=ty;if(scrolled.x||scrolled.y){const moveX=scrolled.x?x:0;const moveY=scrolled.y?y:0;this.movingItemsMoveScreenPositionBy(moveX,moveY);if(this.googleMaps.map){let point=this.googleMaps.map.getCenter();const projection=this.googleMaps.overlay.getProjection();const pixelpoint=projection.fromLatLngToDivPixel(point);pixelpoint.x+=moveX;pixelpoint.y+=moveY;point=projection.fromDivPixelToLatLng(pixelpoint);this.googleMaps.map.setCenter(point)}}
1425return scrolled}
1426setObjectClickedBeforeScroll(object){this.objectClickedBeforeScroll=object}
1427touchStart(_e,mapsvg){_e.preventDefault();if(this.scrollStarted){this.scrollEnd(_e,mapsvg,!0)}
1428const e=_e.originalEvent;if(this.options.zoom.fingers&&e.touches&&e.touches.length==2){this.touchZoomStart=!0;this.scaleDistStart=Math.hypot(e.touches[0].pageX-e.touches[1].pageX,e.touches[0].pageY-e.touches[1].pageY)}else if(e.touches&&e.touches.length==1){this.scrollStart(_e,mapsvg)}
1429$$A(document).on("touchmove.scroll.mapsvg",(e)=>{e.preventDefault();this.touchMove(e,this)}).on("touchend.scroll.mapsvg",(e)=>{e.preventDefault();this.touchEnd(e,this)})}
1430touchMove(_e,mapsvg){_e.preventDefault();const e=_e.originalEvent;if(this.options.zoom.fingers&&e.touches&&e.touches.length==2){if(!MapSVG.ios){e.scale=Math.hypot(e.touches[0].pageX-e.touches[1].pageX,e.touches[0].pageY-e.touches[1].pageY)/this.scaleDistStart}
1431if(e.scale!=1&&this.canZoom){const d=e.scale>1?1:-1;const cx=e.touches[0].pageX>=e.touches[1].pageX?e.touches[0].pageX-(e.touches[0].pageX-e.touches[1].pageX)/2-$$A(this.containers.map).offset().left:e.touches[1].pageX-(e.touches[1].pageX-e.touches[0].pageX)/2-$$A(this.containers.map).offset().left;const cy=e.touches[0].pageY>=e.touches[1].pageY?e.touches[0].pageY-(e.touches[0].pageY-e.touches[1].pageY)-$$A(this.containers.map).offset().top:e.touches[1].pageY-(e.touches[1].pageY-e.touches[0].pageY)-$$A(this.containers.map).offset().top;const center=this.converter.convertPixelToSVG(new ScreenPoint(cx,cy));if(d>0)
1432this.zoomIn(center);else this.zoomOut(center)}}else if(e.touches&&e.touches.length==1){this.scrollMove(_e)}}
1433touchEnd(_e,mapsvg){_e.preventDefault();const e=_e.originalEvent;if(this.touchZoomStart){this.touchZoomStart=!1}else if(this.scrollStarted){this.scrollEnd(_e,mapsvg)}
1434$$A(document).off("touchmove.scroll.mapsvg");$$A(document).off("touchend.scroll.mapsvg")}
1435getSelected(){return this.selected_id}
1436selectRegion(id,skipDirectorySelection){let region;if(typeof id=="string"){region=this.getRegion(id)}else{region=id}
1437if(!region)
1438return;let ids;if(this.options.multiSelect&&!this.editRegions.on){if(region.selected){this.deselectRegion(region);if(!skipDirectorySelection&&this.options.menu.on){if(this.options.menu.source=="database"){if(region.objects&&region.objects.length){ids=region.objects.map((obj)=>{return obj.id.toString()})}}else{ids=[region.id]}
1439this.controllers.directory.deselectItems()}
1440return}}else if(this.selected_id.length>0){this.deselectAllRegions();if(!skipDirectorySelection&&this.options.menu.on){if(this.options.menu.source=="database"){if(region.objects&&region.objects.length){ids=region.objects.map((obj)=>{return obj.id.toString()})}}else{ids=[region.id]}
1441this.controllers.directory.deselectItems()}}
1442this.selected_id.push(region.id);region.select();const skip=this.options.actions.region.click.filterDirectory;if(!skip&&!skipDirectorySelection&&this.options.menu.on&&this.controllers&&this.controllers.directory){if(this.options.menu.source=="database"){if(region.objects&&region.objects.length){ids=region.objects.map((obj)=>{return obj.id.toString()})}else{ids=[region.id]}}else{ids=[region.id]}
1443this.controllers.directory.selectItems(ids)}
1444if(this.options.actions.region.click.addIdToUrl&&!this.options.actions.region.click.showAnotherMap){window.location.hash="/m/"+region.id}}
1445deselectAllRegions(){$$A.each(this.selected_id,(index,id)=>{this.deselectRegion(this.getRegion(id))})}
1446deselectRegion(region){if(!region)
1447region=this.getRegion(this.selected_id[0]);if(region){region.deselect();const i=$$A.inArray(region.id,this.selected_id);this.selected_id.splice(i,1)}
1448if(this.options.actions.region.click.addIdToUrl){if(window.location.hash.indexOf(region.id)!==-1){history.replaceState(null,null," ")}}}
1449highlightRegions(regions){regions.forEach((region)=>{if(region&&!region.selected&&!region.disabled){this.highlightedRegions.push(region);region.highlight()}})}
1450unhighlightRegions(){this.highlightedRegions.forEach((region)=>{if(region&&!region.selected&&!region.disabled)
1451region.unhighlight()});this.highlightedRegions=[]}
1452selectMarker(marker){if(!(marker instanceof Marker))
1453return;this.deselectAllMarkers();marker.select();this.selected_marker=marker;$$A(this.layers.markers).addClass("mapsvg-with-marker-active");if(this.options.menu.on&&this.options.menu.source=="database"){this.controllers.directory.deselectItems();this.controllers.directory.selectItems(marker.object.id)}}
1454deselectAllMarkers(){this.selected_marker&&this.selected_marker.deselect();$$A(this.layers.markers).removeClass("mapsvg-with-marker-active")}
1455deselectMarker(marker){if(marker){marker.deselect()}}
1456highlightMarker(marker){$$A(this.layers.markers).addClass("mapsvg-with-marker-hover");marker.highlight();this.highlighted_marker=marker}
1457unhighlightMarker(){$$A(this.layers.markers).removeClass("mapsvg-with-marker-hover");this.highlighted_marker&&this.highlighted_marker.unhighlight()}
1458convertMouseToSVG(e){const mc=MapSVG.mouseCoords(e);const x=mc.x-$$A(this.containers.map).offset().left;const y=mc.y-$$A(this.containers.map).offset().top;const screenPoint=new ScreenPoint(x,y);return this.converter.convertPixelToSVG(screenPoint)}
1459pickChoroplethColor(choroplethValue){const w=(choroplethValue-this.options.choropleth.coloring.gradient.values.min)/this.options.choropleth.coloring.gradient.values.maxAdjusted;const rgba={r:Math.round(this.options.choropleth.coloring.gradient.colors.diffRGB.r*w+this.options.choropleth.coloring.gradient.colors.lowRGB.r),g:Math.round(this.options.choropleth.coloring.gradient.colors.diffRGB.g*w+this.options.choropleth.coloring.gradient.colors.lowRGB.g),b:Math.round(this.options.choropleth.coloring.gradient.colors.diffRGB.b*w+this.options.choropleth.coloring.gradient.colors.lowRGB.b),a:Math.round(this.options.choropleth.coloring.gradient.colors.diffRGB.a*w+this.options.choropleth.coloring.gradient.colors.lowRGB.a),};return rgba}
1460isRegionDisabled(id,svgfill){if(this.options.regions[id]&&(this.options.regions[id].disabled||svgfill=="none")){return!0}else if((this.options.regions[id]==undefined||MapSVG.parseBoolean(this.options.regions[id].disabled))&&(this.options.disableAll||svgfill=="none"||id=="labels"||id=="Labels")){return!0}else{return!1}}
1461loadMap(id,container){if(!(container instanceof HTMLElement)){console.error("Can't load a new map: container was not provided.");return}
1462const previousMapsIds=[...this.options.previousMapsIds];const currentMapId=this.id;if(previousMapsIds[previousMapsIds.length-1]!==id){previousMapsIds.push(currentMapId)}else{previousMapsIds.pop()}
1463let showPreviousMapButton;if(typeof this.options.actions.region.click.showAnotherMapContainerId!=="undefined"&&this.options.actions.region.click.showAnotherMapContainerId!==""){showPreviousMapButton=!1}else{showPreviousMapButton=this.options.controls.previousMap}
1464const mapsRepo=new MapsRepository();const sameContainer=container===this.containers.map;mapsRepo.findById(id).done((map)=>{sameContainer&&this.destroy();const newMap=new MapSVGMap(container.getAttribute("id"),map);newMap.events.on("afterLoad",function(){this.options.previousMapsIds=previousMapsIds;this.options.controls.previousMap=showPreviousMapButton;this.setControls(this.options.controls)})})}
1465loadPreviousMap(){const previousMapId=this.options.previousMapsIds[this.options.previousMapsIds.length-1];const container=document.getElementById(this.containerId);this.loadMap(previousMapId,container)}
1466markerClusterClickHandler(e,markerCluster){this.objectClickedBeforeScroll=null;if(this.eventsPreventList.click)
1467return;this.zoomTo(markerCluster.markers);return}
1468regionClickHandler(e,region){this.objectClickedBeforeScroll=null;if(this.eventsPreventList.click)
1469return;this.selectRegion(region.id);if(this.editRegions.on){this.regionEditHandler.call(region);return}
1470const actions=this.options.actions;if(actions.region.click.zoom){this.zoomTo(region,parseInt(actions.region.click.zoomToLevel))}
1471if(actions.region.click.filterDirectory){const query=new Query({filters:{regions:{table_name:this.regionsRepository.getSchema().name,region_ids:[region.id],},},});this.objectsRepository.query.resetFilters();this.setFilterOut();this.objectsRepository.find(query).done(()=>{if(this.controllers.popover){this.controllers.popover.redraw(region.forTemplate())}
1472if(this.controllers.detailsView){this.controllers.detailsView.redraw(region.forTemplate())}});this.updateFiltersState()}
1473if(actions.region.click.showDetails){this.loadDetailsView(region)}
1474if(actions.region.click.showPopover){if(actions.region.click.zoom){setTimeout(()=>{this.showPopover(region)},400)}else{this.showPopover(region)}}else if(e&&e.type.indexOf("touch")!==-1&&actions.region.touch.showPopover){if(actions.region.click.zoom){setTimeout(()=>{this.showPopover(region)},400)}else{this.showPopover(region)}}
1475if(actions.region.click.goToLink){const linkParts=actions.region.click.linkField.split(".");let url;if(linkParts.length>1){const obj=linkParts.shift();const attr="."+linkParts.join(".");if(obj=="Region"){if(region.data){try{url=eval("region.data"+attr)}catch(err){console.log("No such field as region.data"+attr)}}}else{if(region.objects&&region.objects[0]){try{url=eval("region.objects[0]"+attr)}catch(err){console.log("No such field as region.objects[0]"+attr)}}}
1476if(url&&!this.disableLinks){if(this.editMode){alert("Redirect: "+url+"\nLinks are disabled in the preview.");return}
1477if(actions.region.click.newTab){const win=window.open(url,"_blank");win.focus()}else{window.location.href=url}}}}
1478if(actions.region.click.showAnotherMap){if(this.editMode){alert('"Show another map" action is disabled in the preview');return}
1479const linkParts=actions.region.click.showAnotherMapField.split(".");if(linkParts.length>1){const obj=linkParts.shift();const attr="."+linkParts.join(".");let map_id;if(obj=="Region"){if(region.data)
1480map_id=eval("region.data"+attr)}else{if(region.objects&&region.objects[0])
1481map_id=eval("region.objects[0]"+attr)}
1482if(map_id){const container=actions.region.click.showAnotherMapContainerId?$$A("#"+actions.region.click.showAnotherMapContainerId)[0]:$$A(this.containers.map)[0];this.loadMap(map_id,container)}}}
1483this.events.trigger("click.region",region,[e,region,this])}
1484markerClickHandler(e,marker){this.objectClickedBeforeScroll=null;if(this.eventsPreventList.click)
1485return;const actions=this.options.actions;this.selectMarker(marker);const passingObject=marker.object;if(actions.marker.click.zoom){this.zoomTo(marker,parseInt(actions.marker.click.zoomToLevel))}
1486if(actions.marker.click.filterDirectory){const query=new Query({filters:{id:marker.object.id}});this.objectsRepository.find(query);this.updateFiltersState()}
1487if(actions.marker.click.showDetails)
1488this.loadDetailsView(passingObject);if(actions.marker.click.showPopover){if(actions.marker.click.zoom){setTimeout(()=>{this.showPopover(passingObject)},500)}else{this.showPopover(passingObject)}}else if(e&&e.type.indexOf("touch")!==-1&&actions.marker.touch.showPopover){if(actions.marker.click.zoom){setTimeout(()=>{this.showPopover(passingObject)},500)}else{this.showPopover(passingObject)}}
1489if(actions.marker.click.goToLink){const linkParts=actions.marker.click.linkField.split(".");let url;if(linkParts.length>1){const obj=linkParts.shift();const attr="."+linkParts.join(".");try{url=eval("passingObject"+attr)}catch(err){console.log("MapSVG: No such field as passingObject"+attr)}
1490if(url&&!this.disableLinks)
1491if(this.editMode){alert("Redirect: "+url+"\nLinks are disabled in the preview.");return}
1492if(actions.marker.click.newTab){const win=window.open(url,"_blank");win.focus()}else{window.location.href=url}}}
1493this.events.trigger("click.marker",marker,[e,marker,this])}
1494fileExists(url){if(url.substr(0,4)=="data")
1495return!0;const http=new XMLHttpRequest();http.open("HEAD",url,!1);http.send();return http.status!=404}
1496hideMarkers(){this.markers.forEach(function(marker){marker.hide()});$$A(this.containers.wrap).addClass("mapsvg-edit-marker-mode")}
1497hideMarkersExceptOne(id){this.markers.forEach(function(marker){if(typeof id==="undefined"||(marker.object&&id!=marker.object.id)){marker.hide()}});$$A(this.containers.wrap).addClass("mapsvg-edit-marker-mode")}
1498showMarkers(){this.markers.forEach(function(m){m.show()});this.deselectAllMarkers();$$A(this.containers.wrap).removeClass("mapsvg-edit-marker-mode")}
1499markerAddClickHandler(e){if($$A(e.target).hasClass("mapsvg-marker"))
1500return;const svgPoint=this.getSvgPointAtClick(e);const geoPoint=this.isGeo()?this.converter.convertSVGToGeo(svgPoint):null;if(!$$A.isNumeric(svgPoint.x)||!$$A.isNumeric(svgPoint.y))
1501return;if(this.editingMarker){if(geoPoint){this.editingMarker.location.setGeoPoint(geoPoint)}else{this.editingMarker.location.setSvgPoint(svgPoint)}
1502return}
1503const location=new Location({svgPoint:svgPoint,geoPoint:geoPoint,img:this.options.defaultMarkerImage,});const marker=new Marker({location:location,mapsvg:this,});this.markerAdd(marker);this.markerEditHandler&&this.markerEditHandler.call(location,location)}
1504getSvgPointAtClick(e){const mc=MapSVG.mouseCoords(e);const x=mc.x-$$A(this.containers.map).offset().left;const y=mc.y-$$A(this.containers.map).offset().top;const screenPoint=new ScreenPoint(x,y);return this.converter.convertPixelToSVG(screenPoint)}
1505setDefaultMarkerImage(src){this.options.defaultMarkerImage=src}
1506setMarkerImagesDependency(){this.locationField=this.objectsRepository.schema.getFieldByType("location");if(this.locationField&&this.locationField.markersByFieldEnabled&&this.locationField.markerField&&Object.values(this.locationField.markersByField).length>0){this.setMarkersByField=!0}else{this.setMarkersByField=!1}}
1507getMarkerImage(fieldValueOrObject,location){let fieldValue;if(this.setMarkersByField){if(typeof fieldValueOrObject==="object"){fieldValue=fieldValueOrObject[this.locationField.markerField];if(this.locationField.markerField==="regions"){fieldValue=fieldValue[0]&&fieldValue[0].id}else if(typeof fieldValue==="object"&&fieldValue.length){fieldValue=fieldValue[0].value}}else{fieldValue=fieldValueOrObject}
1508if(this.locationField.markersByField[fieldValue]){return this.locationField.markersByField[fieldValue]}}
1509return location&&location.imagePath?location.imagePath:this.options.defaultMarkerImage?this.options.defaultMarkerImage:MapSVG.urls.root+"markers/_pin_default.png"}
1510setMarkersEditMode(on,clickAddsMarker){this.editMarkers.on=MapSVG.parseBoolean(on);this.clickAddsMarker=this.editMarkers.on;this.setEventHandlers()}
1511setRegionsEditMode(on){this.editRegions.on=MapSVG.parseBoolean(on);this.deselectAllRegions();this.setEventHandlers()}
1512setEditMode(on){this.editMode=on}
1513setDataEditMode(on){this.editData.on=MapSVG.parseBoolean(on);this.deselectAllRegions();this.setEventHandlers()}
1514download(){window.location.href=window.location.origin+this.options.source}
1515popoverAdjustScreenPosition(){if(this.controllers.popover instanceof PopoverController){this.controllers.popover.adjustScreenPosition()}}
1516popoverMoveScreenPositionBy(deltaX,deltaY){if(this.controllers.popover instanceof PopoverController){this.controllers.popover.moveSrceenPositionBy(deltaX,deltaY)}}
1517showPopover(object){const mapObject=object instanceof Region?object:object.location&&object.location.marker?object.location.marker:null;if(!mapObject)
1518return;let point;if(mapObject instanceof Marker){point=mapObject.svgPoint}else{point=mapObject.getCenterSVG()}
1519this.controllers.popover&&this.controllers.popover.destroy();this.controllers.popover=new PopoverController({container:this.containers.popover,point:point,yShift:mapObject instanceof Marker?mapObject.height:0,template:object instanceof Region?this.options.templates.popoverRegion:this.options.templates.popoverMarker,mapsvg:this,data:object.getData(),mapObject:mapObject,scrollable:!0,withToolbar:!(MapSVG.isPhone&&this.options.popovers.mobileFullscreen),events:{shown:(popover)=>{if(this.options.popovers.centerOn){const shift=popover.containers.main.offsetHeight/2;if(this.options.popovers.centerOn&&!(MapSVG.isPhone&&this.options.popovers.mobileFullscreen)){this.centerOn(mapObject,shift)}}
1520this.popoverShowingFor=mapObject;this.events.trigger("shown.popover",this,[this,popover]);$$A(window).trigger("shown.popover",[this,popover])},closed:(popover)=>{this.options.popovers.resetViewboxOnClose&&this.viewBoxReset(!0);this.popoverShowingFor=null;this.events.trigger("closed.popover",this,[this,popover])},resize:(popover)=>{if(this.options.popovers.centerOn){const shift=popover.containers.main.offsetHeight/2;if(this.options.popovers.centerOn&&!(MapSVG.isPhone&&this.options.popovers.mobileFullscreen)){this.centerOn(mapObject,shift)}}},},});this.controllers.popover._init()}
1521hidePopover(){this.controllers.popover&&this.controllers.popover.close()}
1522popoverOffHandler(e){if(this.isScrolling||$$A(e.target).closest(".mapsvg-popover").length||$$A(e.target).hasClass("mapsvg-btn-map"))
1523return;this.controllers.popover&&this.controllers.popover.close()}
1524mouseOverHandler(e,object){if(this.eventsPreventList.mouseover){return}
1525if(object instanceof Marker){if(this.options.actions.marker.mouseover.showTooltip){this.showTooltip(object)}}
1526if(object instanceof Region){if(this.options.actions.region.mouseover.showTooltip){this.showTooltip(object)}}
1527let ids;if(this.options.menu.on){if(this.options.menu.source=="database"){if(object instanceof Region&&object.objects.length){ids=object.objects.map((obj)=>{return obj.id})}
1528if(object instanceof Marker){ids=object.object?[object.object.id]:[]}}else{if(object instanceof Region){ids=[object.id]}
1529if(this instanceof Marker&&object.object.regions&&object.object.regions.length){ids=object.object.regions.map((obj)=>{return obj.id})}}
1530this.controllers.directory.highlightItems(ids)}
1531if(object instanceof Region){if(!object.selected)
1532object.highlight();this.events.trigger("mouseover.region",object,[e,this])}else{this.highlightMarker(object);this.events.trigger("mouseover.marker",object,[e,this])}}
1533showTooltip(object){let name,_object;if(object instanceof Region){name="tooltipRegion";_object=object}else if(object instanceof Marker){name="tooltipMarker";_object=object.object}else{name="tooltipMarker";_object=object}
1534if(_object!=null&&this.popoverShowingFor!==object){this.controllers.tooltip.setMainTemplate(this.options.templates[name]);this.controllers.tooltip.redraw(_object.getData());this.controllers.tooltip.show()}}
1535mouseOutHandler(e,object){if(this.eventsPreventList.mouseout){return}
1536if(this.controllers.tooltip)
1537this.controllers.tooltip.hide();if(object instanceof Region){if(!object.selected)
1538object.unhighlight();this.events.trigger("mouseout.region",object,[e,this])}else{this.unhighlightMarker();this.events.trigger("mouseout.marker",object,[e,this])}
1539let ids;if(this.options.menu.on){if(this.options.menu.source=="database"){if(object instanceof Marker){const marker=
1539object;ids=marker.object?[marker.object.id]:[]}}
1540this.controllers.directory.unhighlightItems()}}
1541eventsPrevent(event){this.eventsPreventList[event]=!0}
1542eventsRestore(event){if(event){this.eventsPreventList[event]=!1}else{this.eventsPreventList={}}}
1543setEventHandlers(){const _this=this;$$A(_this.containers.map).off(".common.mapsvg");$$A(_this.containers.scrollpane).off(".common.mapsvg");$$A(document).off(".scroll.mapsvg");$$A(document).off(".scrollInit.mapsvg");if(_this.editMarkers.on){$$A(_this.containers.map).on("touchstart.common.mapsvg mousedown.common.mapsvg",".mapsvg-marker",function(e){e.originalEvent.preventDefault();const marker=_this.getMarker($$A(this).attr("id"));const startCoords=MapSVG.mouseCoords(e);marker.drag(startCoords,_this.scale)})}
1544if(!_this.editMarkers.on){$$A(_this.containers.map).on("mouseover.common.mapsvg",".mapsvg-region",function(e){const id=$$A(this).attr("id");_this.mouseOverHandler.call(_this,e,_this.getRegion(id))}).on("mouseleave.common.mapsvg",".mapsvg-region",function(e){const id=$$A(this).attr("id");_this.mouseOutHandler.call(_this,e,_this.getRegion(id))})}
1545if(!_this.editRegions.on){$$A(_this.containers.map).on("mouseover.common.mapsvg",".mapsvg-marker",function(e){const id=$$A(this).attr("id");_this.mouseOverHandler.call(_this,e,_this.getMarker(id))}).on("mouseleave.common.mapsvg",".mapsvg-marker",function(e){const id=$$A(this).attr("id");_this.mouseOutHandler.call(_this,e,_this.getMarker(id))})}
1546if(_this.options.scroll.spacebar){$$A(document).on("keydown.scroll.mapsvg",function(e){if(!(document.activeElement.tagName==="INPUT"&&$$A(document.activeElement).attr("type")==="text")&&!_this.isScrolling&&e.keyCode==32){e.preventDefault();$$A(_this.containers.map).addClass("mapsvg-scrollable");$$A(document).on("mousemove.scrollInit.mapsvg",function(e){_this.isScrolling=!0;$$A(document).off("mousemove.scrollInit.mapsvg");_this.scrollStart(e,_this)}).on("keyup.scroll.mapsvg",function(e){if(e.keyCode==32){$$A(document).off("mousemove.scrollInit.mapsvg");$$A(_this.containers.map).removeClass("mapsvg-scrollable")}})}})}else if(!_this.options.scroll.on){if(!_this.editMarkers.on){$$A(_this.containers.map).on("touchstart.common.mapsvg",".mapsvg-region",function(e){_this.scroll.touchScrollStart=$$A(window).scrollTop()});$$A(_this.containers.map).on("touchstart.common.mapsvg",".mapsvg-marker",function(e){_this.scroll.touchScrollStart=$$A(window).scrollTop()});$$A(_this.containers.map).on("touchend.common.mapsvg mouseup.common.mapsvg",".mapsvg-region",function(e){if(e.cancelable){e.preventDefault()}
1547if(!_this.scroll.touchScrollStart||_this.scroll.touchScrollStart===$$A(window).scrollTop()){_this.regionClickHandler(e,_this.getRegion($$A(this).attr("id")))}});$$A(_this.containers.map).on("touchend.common.mapsvg mouseup.common.mapsvg",".mapsvg-marker",function(e){if(e.cancelable){e.preventDefault()}
1548if(!_this.scroll.touchScrollStart||_this.scroll.touchScrollStart===$$A(window).scrollTop()){_this.markerClickHandler.call(_this,e,_this.getMarker($$A(this).attr("id")))}});$$A(_this.containers.map).on("touchend.common.mapsvg mouseup.common.mapsvg",".mapsvg-marker-cluster",function(e){if(e.cancelable){e.preventDefault()}
1549if(!_this.scroll.touchScrollStart||_this.scroll.touchScrollStart==$$A(window).scrollTop()){const cluster=$$A(this).data("cluster");_this.zoomTo(cluster.markers)}})}else{if(_this.clickAddsMarker)
1550$$A(_this.containers.map).on("touchend.common.mapsvg mouseup.common.mapsvg",function(e){if(e.cancelable){e.preventDefault()}
1551_this.markerAddClickHandler(e)})}}else{$$A(_this.containers.map).on("touchstart.common.mapsvg mousedown.common.mapsvg",function(e){if($$A(e.target).hasClass("mapsvg-popover")||$$A(e.target).closest(".mapsvg-popover").length){if($$A(e.target).hasClass("mapsvg-popover-close")){if(e.type=="touchstart"){if(e.cancelable){e.preventDefault()}}}
1552return}
1553if(e.type=="touchstart"){if(e.cancelable){e.preventDefault()}}
1554let obj;if(e.target&&$$A(e.target).attr("class")&&$$A(e.target).attr("class").indexOf("mapsvg-region")!=-1){obj=_this.getRegion($$A(e.target).attr("id"));_this.setObjectClickedBeforeScroll(obj)}else if(e.target&&$$A(e.target).attr("class")&&$$A(e.target).attr("class").indexOf("mapsvg-marker")!=-1&&$$A(e.target).attr("class").indexOf("mapsvg-marker-cluster")===-1){if(_this.editMarkers.on){return}
1555obj=_this.getMarker($$A(e.target).attr("id"));_this.setObjectClickedBeforeScroll(obj)}else if(e.target&&$$A(e.target).attr("class")&&$$A(e.target).attr("class").indexOf("mapsvg-marker-cluster")!=-1){if(_this.editMarkers.on){return}
1556obj=$$A(e.target).data("cluster");_this.setObjectClickedBeforeScroll(obj)}
1557if(e.type=="mousedown"){_this.scrollStart(e,_this)}else{_this.touchStart(e,_this)}})}
1558$$A(_this.containers.map).on("mouseleave.common.mapsvg",".mapsvg-choropleth-gradient-wrap",(e)=>{this.controllers.tooltip.hide()})}
1559setLabelsRegions(options){options=options||this.options.labelsRegions;options.on!=undefined&&(options.on=MapSVG.parseBoolean(options.on));$$A.extend(!0,this.options,{labelsRegions:options});if(this.options.labelsRegions.on){this.regions.forEach((region)=>
1559{if(!region.label){region.label=jQuery('<div class="mapsvg-region-label" />')[0];$$A(this.layers.labels).append(region.label)}
1560try{$$A(region.label).html(this.templates.labelRegion(region.forTemplate()))}catch(err){console.error('MapSVG: Error in the "Region Label" template')}});this.labelsRegionsAdjustScreenPosition()}else{this.regions.forEach((region)=>{if(region.label){$$A(region.label).remove();region.label=null;delete region.label}})}}
1561setLabelsMarkers(options){options=options||this.options.labelsMarkers;options.on!=undefined&&(options.on=MapSVG.parseBoolean(options.on));$$A.extend(!0,this.options,{labelsMarkers:options});if(this.options.labelsMarkers.on){this.markers.forEach((marker)=>{try{marker.setLabel(this.templates.labelMarker(marker.object))}catch(err){console.error('MapSVG: Error in the "Marker Label" template')}})}else{this.markers.forEach((marker)=>{marker.setLabel("")})}}
1562addLayer(name){this.layers[name]=$$A('<div class="mapsvg-layer mapsvg-layer-'+name+'"></div>')[0];this.containers.layers.appendChild(this.layers[name]);return this.layers[name]}
1563getLayer(name){return this.layers[name]}
1564getDb(){return this.objectsRepository}
1565getDbRegions(){return this.regionsRepository}
1566regionAdd(svgObject){const region=new Region(svgObject,this);region.setStatus(1);this.regions.push(region);this.regions.sort(function(a,b){return a.id==b.id?0:+(a.id>b.id)||-1});return region}
1567regionDelete(id){if(this.regions.findById(id)){this.regions.findById(id).elem.remove();this.regions.delete(id)}else if($$A("#"+id).length){$$A("#"+id).remove()}}
1568reloadRegions(){this.regions.clear();$$A(this.containers.svg).find(".mapsvg-region").removeClass("mapsvg-region");$$A(this.containers.svg).find(".mapsvg-region-disabled").removeClass("mapsvg-region-disabled");$$A(this.containers.svg).find("path, polygon, circle, ellipse, rect").each((index,element)=>{const elem=element;if($$A(elem).closest("defs").length)
1569return;if(elem.getAttribute("data-stroke-width")){elem.style["stroke-width"]=elem.getAttribute("data-stroke-width")}
1570if(elem.getAttribute("id")){if(!this.options.regionPrefix||(this.options.regionPrefix&&elem.getAttribute("id").indexOf(this.options.regionPrefix)===0)){const region=new Region(elem,this);this.regions.push(region)}}})}
1571reloadRegionsFull(){const statuses=this.regionsRepository.getSchema().getFieldByType("status");this.regions.forEach((region)=>{const _region=this.regionsRepository.getLoaded().findById(region.id);if(_region){region.setData(_region);if(statuses&&_region.status!==undefined&&_region.status!==null){region.setStatus(_region.status)}}else{if(this.options.filters.filteredRegionsStatus||this.options.filters.filteredRegionsStatus===0||(this.options.menu.source==="regions"&&this.options.menu.filterout&&this.options.menu.filterout.field==="status"&&this.options.menu.filterout.val)||this.options.menu.filterout.val===0){const status=this.options.filters.filteredRegionsStatus||this.options.filters.filteredRegionsStatus===0?this.options.filters.filteredRegionsStatus:this.options.menu.filterout.val;region.setStatus(status)}}});this.loadDirectory();this.setChoropleth();this.setLayersControl();this.setGroups();if(this.options.labelsRegions.on){this.setLabelsRegions()}}
1572fixMarkersWorldScreen(){if(this.googleMaps.map)
1573setTimeout(()=>{const markers={left:0,right:0,leftOut:0,rightOut:0};if(this.markers.length>1){this.markers.forEach((m)=>{if($$A(m.element).offset().left<$$A(this.containers.map).offset().left+this.containers.map.clientWidth/2){markers.left++;if($$A(m.element).offset().left<$$A(this.containers.map).offset().left){markers.leftOut++}}else{markers.right++;if($$A(m.element).offset().left>$$A(this.containers.map).offset().left+this.containers.map.clientWidth){markers.rightOut++}}});if((markers.left===0&&markers.rightOut)||(markers.right===0&&markers.leftOut)){const k=markers.left===0?1:-1;const ww=(this.svgDefault.viewBox.width/this.converter.mapLonDelta)*360*this.getScale();this.googleMaps.map.panBy(k*ww,0)}}},600)}
1574updateOutdatedOptions(options){if(options.menu&&(options.menu.position||options.menu.customContainer)){if(options.menu.customContainer){options.menu.location="custom"}else{options.menu.position=options.menu.position==="left"?"left":"right";options.menu.location=options.menu.position==="left"?"leftSidebar":"rightSidebar";if(!options.containers||!options.containers[options.menu.location]){options.containers=options.containers||{};options.containers[options.menu.location]={on:!1,width:"200px"}}
1575options.containers[options.menu.location].width=options.menu.width;if(MapSVG.parseBoolean(options.menu.on)){options.containers[options.menu.location].on=!0}}
1576delete options.menu.position;delete options.menu.width;delete options.menu.customContainer}
1577if(options.detailsView&&(options.detailsView.location==="mapContainer"||options.detailsView.location==="near"||options.detailsView.location==="top")){options.detailsView.location="map"}
1578if(!options.controls){options.controls={};options.controls.zoom=options.zoom&&options.zoom.on&&(!options.zoom.buttons||options.zoom.buttons.location!=="hide");options.controls.location=options.zoom&&options.zoom.buttons&&options.zoom.buttons.location!=="hide"?options.zoom.buttons.location:"right"}
1579if(options.colors&&!options.colors.markers){options.colors.markers={base:{opacity:100,saturation:100},hovered:{opacity:100,saturation:100},unhovered:{opacity:100,saturation:100},active:{opacity:100,saturation:100},inactive:{opacity:100,saturation:100},}}
1580if(options.tooltipsMode){options.tooltips.mode=options.tooltipsMode;delete options.tooltipsMode}
1581if(options.popover){options.popovers=options.popover;delete options.popover}}
1582init(){MapSVG.addInstance(this);if(this.options.source===""){throw new Error("MapSVG: please provide SVG file source.")}
1583this.disableAnimation();this.setEvents(this.options.events);this.events.trigger("beforeLoad");if(this.options.googleMaps.apiKey&&(this.editMode||this.options.googleMaps.on||(this.options.filters.on&&this.options.filtersSchema&&this.options.filtersSchema.find((f)=>f.type==="distance")))){this.loadGoogleMapsAPI(()=>{return 1},()=>{return 1})}
1584this.containers.map.classList.add("mapsvg");this.setCss();if(this.options.colors&&this.options.colors.background){this.containers.map.style.background=this.options.colors.background}
1585this.setContainers(this.options.containers);this.setColors();this.addLoadingMessage();this.addLayer("markers");this.addLayer("labels");this.addLayer("bubbles");this.addLayer("popovers");this.addLayer("scrollpane");this.loadExtensions();$$A.ajax({url:this.options.source+"?v="+this.svgFileLastChanged}).fail((resp)=>{this.svgLoadingFailed(resp)}).done((xmlData)=>{this.renderSvgData(xmlData)});return this}
1586getContainer(name){return this.containers[name]}
1587renderSvgData(xmlData){const svgTag=$$A(xmlData).find("svg");this.containers.svg=svgTag[0];if(svgTag.attr("width")&&svgTag.attr("height")){this.svgDefault.width=parseFloat(svgTag.attr("width").replace(/px/g,""));this.svgDefault.height=parseFloat(svgTag.attr("height").replace(/px/g,""));this.svgDefault.viewBox=svgTag.attr("viewBox")?new ViewBox(svgTag.attr("viewBox").split(" ")):new ViewBox(0,0,this.svgDefault.width,this.svgDefault.height)}else if(svgTag.attr("viewBox")){this.svgDefault.viewBox=new ViewBox(svgTag.attr("viewBox").split(" "));this.svgDefault.width=this.svgDefault.viewBox.width;this.svgDefault.height=this.svgDefault.viewBox.height}else{const msg="MapSVG: width/height and viewBox are missing in the SVG file. Can't parse the file because of that.";if(this.editMode){alert(msg)}else{console.error(msg)}
1588return!1}
1589this.geoViewBox=this.getGeoViewBoxFromSvgTag(this.containers.svg);if(this.options.viewBox&&this.options.viewBox.length==4){this._viewBox=new ViewBox(this.options.viewBox)}else{this._viewBox=new ViewBox(this.svgDefault.viewBox)}
1590svgTag.attr("preserveAspectRatio","xMidYMid meet");svgTag.removeAttr("width");svgTag.removeAttr("height");$$A(this.containers.scrollpane).append(svgTag);this.setStrokes();this.reloadRegions();this.setSize(this.options.width,this.options.height,this.options.responsive);if(this.options.disableAll){this.setDisableAll(!0)}
1591this.setViewBox(this._viewBox);this.converter=new Converter(this.containers.map,this.svgDefault.viewBox,this.viewBox);if(this.geoViewBox){this.converter.setGeoViewBox(this.geoViewBox)}
1592this.setResponsive(this.options.responsive);this.setScroll(this.options.scroll,!0);this.setZoom(this.options.zoom);this.setControls(this.options.controls);this.setGoogleMaps();this.setTooltips(this.options.tooltips);this.setPopovers(this.options.popovers);if(this.options.cursor)
1593this.setCursor(this.options.cursor);this.setTemplates(this.options.templates);this.loadExtensions();this.filtersSchema=new Schema({fields:this.options.filtersSchema});this.objectsRepository.events.on("load",()=>{this.showLoadingMessage()});this.objectsRepository.events.on("loaded",()=>{this.setGlobalDistanceFilter();this.fitOnDataLoadDone=!1;this.addLocations();this.fixMarkersWorldScreen();
1593this.attachDataToRegions();this.loadDirectory();if(this.options.labelsMarkers.on){this.setLabelsMarkers()}
1594if(this.options.templates.labelRegion.indexOf("{{objects")!==-1){this.setLabelsRegions()}
1595if(this.options.filters.on&&this.options.filters.source==="database"&&this.controllers.filters&&this.controllers.filters.hideFilters){this.controllers.filters.setFiltersCounter()}
1596this.hideLoadingMessage();this.events.trigger("databaseLoaded");this.updateFiltersState();this.setChoropleth()});this.objectsRepository.events.on("schemaChanged",()=>{this.objectsRepository.reload()});this.objectsRepository.events.on("updated",(obj)=>{this.attachDataToRegions(obj);this.reloadRegionsFull()});this.objectsRepository.events.on("created",(obj)=>{this.attachDataToRegions(obj);this.reloadRegionsFull()});this.objectsRepository.events.on("deleted",(id)=>{this.attachDataToRegions();this.reloadRegionsFull()});this.regionsRepository.events.on("load",()=>{this.showLoadingMessage()});this.regionsRepository.events.on("loaded",()=>{this.hideLoadingMessage();this.reloadRegionsFull();if(this.options.filters.on&&this.options.filters.source==="regions"&&this.controllers.filters&&this.controllers.filters.hideFilters){this.controllers.filters.setFiltersCounter()}
1597this.events.trigger("regionsLoaded")});this.regionsRepository.events.on("updated",(regionData)=>{this.reloadRegionsFull()});this.regionsRepository.events.on("created",(regionData)=>{this.reloadRegionsFull()});this.regionsRepository.events.on("deleted",(regionData)=>{this.reloadRegionsFull()});this.setMenu();this.setFilters();this.setFilterOut();this.setEventHandlers();this.afterLoadBlockers--;if(!this.id){this.finalizeMapLoading();return}
1598if(!this.options.data_regions){this.regionsRepository.find().done((data)=>{this.afterLoadBlockers--;this.finalizeMapLoading()})}else{this.regionsRepository.loadDataFromResponse(this.options.data_regions);this.afterLoadBlockers--}
1599if(!this.options.data_objects){if(this.options.database.loadOnStart||this.editMode){this.objectsRepository.find().done((data)=>{this.afterLoadBlockers--;this.finalizeMapLoading()})}else{this.afterLoadBlockers--;this.finalizeMapLoading()}}else{if(this.editMode||this.options.database.loadOnStart){this.objectsRepository.loadDataFromResponse(this.options.data_objects);this.afterLoadBlockers--}else{this.afterLoadBlockers--}
1600delete this.options.data_regions;delete this.options.data_objects;this.finalizeMapLoading()}}
1601setFilterOut(){if(this.options.menu.filterout.field){const f={};f[this.options.menu.filterout.field]=this.options.menu.filterout.val;if(this.options.menu.source=="regions");else{this.objectsRepository.query.setFilterOut(f)}}else{this.objectsRepository.query.setFilterOut(null)}}
1602getGeoViewBoxFromSvgTag(svgTag){const geo=$$A(svgTag).attr("mapsvg:geoViewBox")||$$A(svgTag).attr("mapsvg:geoviewbox");if(geo){const geoParts=geo.split(" ").map((p)=>parseFloat(p));if(geoParts.length==4){this.mapIsGeo=!0;this.geoCoordinates=!0;const sw=new GeoPoint(geoParts[3],geoParts[0]);const ne=new GeoPoint(geoParts[1],geoParts[2]);return new GeoViewBox(sw,ne)}}else{return null}}
1603svgLoadingFailed(resp){if(resp.status==404){let msg="MapSVG: file not found - "+this.options.source+"\n\nIf you moved MapSVG from another server please read the following docs page: https://mapsvg.com/docs/installation/moving";if(this.editMode){msg+="\n\nIf you know the correct path for the SVG file, please write it and press OK:";const oldSvgPath=this.options.source;const userSvgPath=prompt(msg,oldSvgPath);if(userSvgPath!==null){$$A.ajax({url:userSvgPath+"?v="+this.svgFileLastChanged}).fail(function(){location.reload()}).done((xmlData)=>{this.options.source=userSvgPath;this.renderSvgData(xmlData);const mapsRepo=new MapsRepository();mapsRepo.update(this)})}else{location.reload()}}else{console.error(msg)}}else{const msg="MapSVG: can't load SVG file for unknown reason. Please contact support: https://mapsvg.ticksy.com";if(this.editMode){alert(msg)}else{console.error(msg)}}}
1604addLoadingMessage(){this.containers.loading=document.createElement("div");this.containers.loading.className="mapsvg-loading";const loadingTextBlock=document.createElement("div");loadingTextBlock.className="mapsvg-loading-text";loadingTextBlock.innerHTML=this.options.loadingText;const spinner=document.createElement("div");spinner.className="spinner-border spinner-border-sm";this.containers.loading.appendChild(spinner);this.containers.loading.appendChild(loadingTextBlock);this.containers.map.appendChild(this.containers.loading);
1604if(this.options.googleMaps.on){$$A(this.containers.map).addClass("mapsvg-google-map-loading")}}
1605hideLoadingMessage(){$$A(this.containers.loading).hide()}
1606showLoadingMessage(){$$A(this.containers.loading).show()}
1607disableAnimation(){this.containers.map.classList.add("no-transitions")}
1608enableAnimation(){$$A(this.containers.map).removeClass("no-transitions")}
1609loadExtensions(){if(this.options.extension&&$$A().mapSvg.extensions&&$$A().mapSvg.extensions[_this.options.extension]){const ext=$$A().mapSvg.extensions[_this.options.extension];ext&&ext.common(this)}}
1610finalizeMapLoading(){if(this.afterLoadBlockers>0||this.loaded){return}
1611this.selectRegionByIdFromUrl();setTimeout(()=>{this.movingItemsAdjustScreenPosition();this.adjustStrokes();setTimeout(()=>{this.hideLoadingMessage();$$A(this.containers.loading).find(".mapsvg-loading-text").hide();this.enableAnimation()},200)},100);this.loaded=!0;this.events.trigger("afterLoad")}
1612selectRegionByIdFromUrl(){const match=RegExp("[?&]mapsvg_select=([^&]*)").exec(window.location.search);if(match){const select=decodeURIComponent(match[1].replace(/\+/g," "));this.selectRegion(select)}
1613if(window.location.hash){const query=window.location.hash.replace("#/m/","");const region=this.getRegion(query);if(region&&this.options.actions.map.afterLoad.selectRegion){this.regionClickHandler(null,region)}}}
1614createForm(options){return new FormBuilder(options)}
1615getApiUrl(path){const server=new Server();return server.getUrl(path)}
1616getConverter(){return this.converter}
1617setChoropleth(options){const _this=this;options=options||_this.options.choropleth;options.on!=undefined&&(options.on=MapSVG.parseBoolean(options.on));$$A.extend(!0,_this.options,{choropleth:options});let needsRedraw=!1;if(!_this.$gauge){_this.$gauge={};_this.$gauge.gradient=$$A("<td>&nbsp;</td>").addClass("mapsvg-gauge-gradient");_this.setGaugeGradientCSS();_this.$gauge.container=$$A("<div />").addClass("mapsvg-gauge").hide();_this.$gauge.table=$$A("<table />");const tr=$$A("<tr />");_this.$gauge.labelLow=$$A("<td>"+_this.options.choropleth.labels.low+"</td>");_this.$gauge.labelHigh=$$A("<td>"+_this.options.choropleth.labels.high+"</td>");tr.append(_this.$gauge.labelLow);tr.append(_this.$gauge.gradient);tr.append(_this.$gauge.labelHigh);_this.$gauge.table.append(tr);_this.$gauge.container.append(_this.$gauge.table);$$A(_this.containers.map).append(_this.$gauge.container)}
1618if(!_this.options.choropleth.on&&_this.$gauge.container.is(":visible")){_this.$gauge.container.hide();needsRedraw=!0}else if(_this.options.choropleth.on&&!_this.$gauge.container.is(":visible")){_this.$gauge.container.show();needsRedraw=!0;_this.regionsRepository.events.on("change",function(){_this.redrawGauge()})}
1619if(options.colors){_this.options.choropleth.colors.lowRGB=tinycolor(_this.options.choropleth.colors.low).toRgb();_this.options.choropleth.colors.highRGB=tinycolor(_this.options.choropleth.colors.high).toRgb();_this.options.choropleth.colors.diffRGB={r:_this.options.choropleth.colors.highRGB.r-_this.options.choropleth.colors.lowRGB.r,g:_this.options.choropleth.colors.highRGB.g-_this.options.choropleth.colors.lowRGB.g,b:_this.options.choropleth.colors.highRGB.b-_this.options.choropleth.colors.lowRGB.b,a:_this.options.choropleth.colors.highRGB.a-_this.options.choropleth.colors.lowRGB.a,};needsRedraw=!0;_this.$gauge&&_this.setGaugeGradientCSS()}
1620if(options.labels){_this.$gauge.labelLow.html(_this.options.choropleth.labels.low);_this.$gauge.labelHigh.html(_this.options.choropleth.labels.high)}
1621needsRedraw&&_this.redrawGauge()}
1622redrawGauge(){const _this=this;_this.updateGaugeMinMax();_this.regionsRedrawColors()}
1623updateGaugeMinMax(){const _this=this;_this.options.choropleth.min=0;_this.options.choropleth.max=!1;const values=[];_this.regions.forEach(function(r){const gauge=r.data&&r.data[_this.options.regionChoroplethField];gauge!=undefined&&values.push(gauge)});if(values.length>0){_this.options.choropleth.min=values.length==1?0:Math.min.apply(null,values);_this.options.choropleth.max=Math.max.apply(null,values);_this.options.choropleth.maxAdjusted=_this.options.choropleth.max-_this.options.choropleth.min}}
1624setGaugeGradientCSS(){const _this=this;_this.$gauge.gradient.css({background:"linear-gradient(to right,"+_this.options.choropleth.colors.low+" 1%,"+_this.options.choropleth.colors.high+" 100%)",filter:'progid:DXImageTransform.Microsoft.gradient( startColorstr="'+_this.options.choropleth.colors.low+'", endColorstr="'+_this.options.choropleth.colors.high+'",GradientType=1 )',})}
1625get $map(){return $$A(this.getContainer("map"))}
1626get $svg(){return $$A(this.getContainer("svg"))}
1627get $popover(){return $$A(this.getContainer("popover"))}
1628get $details(){return $$A(this.getContainer("detailsView"))}
1629get $directory(){return $$A(this.getContainer("directory"))}
1630get database(){return this.objectsRepository}
1631get regionsDatabase(){return this.regionsRepository}}
1632exports.MapSVGMap=MapSVGMap;exports.arrayIndexed=ArrayIndexed;exports.customObject=CustomObject;exports.formBuilder=FormBuilder;exports.geoPoint=GeoPoint;exports.globals=MapSVG;exports.location=Location;exports.map=MapSVGMap;exports.mapsRepository=MapsRepository;exports.mapsV2Repository=MapsV2Repository;exports.marker=Marker;exports.query=Query;
1632exports.repository=Repository;exports.schema=Schema;exports.schemaRepository=SchemaRepository;exports.screenPoint=ScreenPoint;exports.server=Server;exports.svgPoint=SVGPoint;Object.defineProperty(exports,'__esModule',{value:!0})})))

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.