2194 lines
274 KiB
JavaScript
2194 lines
274 KiB
JavaScript
var stocks_list_more_txt=<iai:variable vid="więcej informacji"/>;var stocks_list_choose=<iai:variable vid="Wybierz"/>;var pickupl_nopoints=<iai:variable vid="Wpisz inny adres, brak punktów odbioru"/>;var mapTooltipLink_class="btn-small",autocompleteData=[],ajaxGetPickupNoMap=function(){$(".mapContainer_pickup, .pickupl_submit").show();var t={courierId:pickup_sites.courierId,isCod:pickup_sites.isCod};$.ajax({type:"GET",url:"/ajax/getPickups.php",data:t,dataType:"json",success:function(t){return t.pickupPoints.length?void setPickupPointsNoMap(t):(Alertek.show_alert(pickupl_nopoints),$(".loadingMap").hide(),!1)},error:function(){orderdetails_payments.ajaxLoadSite(0),$(".no_google_api_key div.asideContainer_pickup").show(),Alertek.show_alert(pickupl_error)}})},setPickupPointsNoMap=function(r){const e=document.getElementById("payitem_cash").checked?0:1;var s=$("#pickup_copy").clone(),t="";for(i in r.pickupPoints){const o=document.querySelector(`#item_${r.pickupPoints[i].courierId}-${e}`).parentElement,a=o.querySelector(".name").innerHTML,d=o.querySelector(".photo").innerHTML;var l=r.pickupPoints[i],n=""==l.address.buildingAndHouseNumber?l.address.street:l.address.street+" "+l.address.buildingAndHouseNumber;pickup_clone=s.clone(),pickup_clone.find("input[name=pickup_point], input[name=stock]").attr("id","pickup_point_"+l.id).val(l.id),pickup_clone.find("label").attr({id:"pp_"+l.id,"data-latitude":l.coordinates.latitude,"data-longitude":l.coordinates.longitude,"data-id":l.id,"data-requires_client_number":l.requiresClientNumber,"data-courier-id":r.pickupPoints[i].courierId,for:"pickup_point_"+l.id}),pickup_clone.find(".zipcodePickup").after(`<strong class="map__price">${r.pickupPoints[i].price}</strong>`),l.coordinates.longitude?pickup_clone.find("label .map_dir").attr("href","https://www.google.com/maps/dir/?api=1&destination="+l.coordinates.latitude+","+l.coordinates.longitude):pickup_clone.find("label .map_dir").attr("href","https://maps.google.com?saddr=Current+Location&daddr="+l.address.street+"+"+l.address.postcode+"+"+l.address.city),pickup_clone.find("b.headerText").text(l.name),pickup_clone.find("span.streetText").text(n),pickup_clone.find("span.zipcodePickup").html(l.address.postcode+" <span class=\"cityText\">"+l.address.city+"</span>"),pickup_clone.find("div.moreText").text(l.location),pickup_clone.find("a.moreLink").attr("href",l.link),pickup_clone.find(".headerText").before(`<h3 class="courierName">${d}${a}</h3>`),l.requiresClientNumber||pickup_clone.find("input[name=client_courier_number]").remove(),t+=pickup_clone.html(),autocompleteData.push({label:l.address.city+", "+l.address.street+" "+l.address.buildingAndHouseNumber+" "+l.address.postcode+" "+l.id,value:l.address.city+", "+l.address.street+" "+l.address.buildingAndHouseNumber+", "+l.id,description:l.location,id:l.id})}$("#pickup_site .asideContainer_pickup").html(t)},pickup_sites={geokoder:0,mapa:0,zoom:0,markerIcon:0,language:0,markersArray:[],contentsArray:[],markerInfo:0,timeout:0,loadNavBoolPickup:!1,pickupCount:0,pickupIteration:0,pickupFind:0,pickupFirstActive:!0,calendar:{},markerAnimation:0,pickupsType:0,google_api_key:"",courierId:app_shop.vars.courierId,isCod:!1,search_lat:"",search_lng:"",markerClusters:"",ClusterMaxZoom:13,minimumClusterSize:10,autocomplete:!1,adress:{street_number:"",route:"",locality:"",administrative_area_level_1:"",country:"",postal_code:""},fillInAddress:function(l,e){pickup_sites.adress={street_number:"",route:"",locality:"",administrative_area_level_1:"",country:"",postal_code:""};var t={street_number:"short_name",route:"long_name",locality:"long_name",administrative_area_level_1:"short_name",country:"long_name",postal_code:"short_name"};if(pickup_sites.search_lat="",pickup_sites.search_lng="",l&&!l.geometry)return!1;if(!l)return $("div.asideContainer_pickup").prepend("<div class=\"menu_messages_message\">"+pickupl_select_adress+"</div>"),$(".loadingMap").hide(),!1;$(".mapContainer_pickup, .asideContainer_pickup, .pickupl_submit, #pickup_map").show(),pickup_sites.search_lat=l.geometry.location.lat(),pickup_sites.search_lng=l.geometry.location.lng();for(var o,d=0;d<l.address_components.length;d++)if(o=l.address_components[d].types[0],t[o]){var p=l.address_components[d][t[o]];pickup_sites.adress[o]=p}if(e){var r="";pickup_sites.adress.route&&(r+=pickup_sites.adress.route,pickup_sites.adress.street_number&&(r+=" "+pickup_sites.adress.street_number)),pickup_sites.adress.locality&&(pickup_sites.adress.route&&(r+=", "),r+=pickup_sites.adress.locality),pickup_sites.adress.country&&(pickup_sites.adress.locality&&(r+=", "),r+=pickup_sites.adress.country),$("#autocomplete_location").val(r)}},getLocation:function(){""==pickup_sites.search_lat&&""==pickup_sites.search_lng?pickup_sites.geokoder.geocode({address:$("#autocomplete_location").val()},function(o){var e=o&&o.length?o[0]:null;pickup_sites.fillInAddress(e,!0),pickup_sites.ajaxGetPickup(!1)}):pickup_sites.ajaxGetPickup(!1)},ajaxGetPickup:function(n){if($("div.asideContainer_pickup .menu_messages_message").remove(),!pickup_sites.adress.locality)return $("div.asideContainer_pickup").prepend("<div class=\"menu_messages_message\">"+pickupl_select_adress+"</div>"),$(".loadingMap").hide(),!1;$(".mapContainer_pickup, .asideContainer_pickup, .pickupl_submit, #pickup_map").show(),$("label.pickup_point").hide(),$("div.loadingMap").fadeIn("normal",function(){}),$("span.loadingMarkers").hide();var e={courierId:pickup_sites.courierId,"location[latitude]":pickup_sites.search_lat,"location[longitude]":pickup_sites.search_lng,isCod:pickup_sites.isCod};if(n)var e={courierId:pickup_sites.courierId,"location[latitude]":pickup_sites.search_lat,"location[longitude]":pickup_sites.search_lng,radius:function(){var t=pickup_sites.mapa.getZoom();return 15<=t?1:14==t?2:13==t?4:12==t?7:11==t?10:10==t?15:20}(),isCod:pickup_sites.isCod};$.ajax({type:"GET",url:"/ajax/getPickups.php",data:e,dataType:"json",success:function(t){if(!jQuery.isEmptyObject(selected_pickup_point)){for(i in t.pickupPoints)t.pickupPoints[i].id==selected_pickup_point.id&&delete t.pickupPoints[i];t.pickupPoints.unshift(selected_pickup_point)}if(!t.pickupPoints.length)return n?$("div.asideContainer_pickup").prepend("<div class=\"menu_messages_message\">"+pickupl_nopoints_in_area+"</div>"):$("div.asideContainer_pickup").prepend("<div class=\"menu_messages_message\">"+pickupl_nopoints+"</div>"),$(".loadingMap").hide(),!1;if(!pickup_sites.adress.route)for(i in t.pickupPoints)if($.trim(t.pickupPoints[i].address.city).toLowerCase()==$.trim(pickup_sites.adress.locality).toLowerCase())return e.radius=30,$.ajax({type:"GET",url:"/ajax/getPickups.php",data:e,dataType:"json",success:function(t){setPickupPoints(t,!0)},error:function(){}}),!1;setPickupPoints(t,!1)},error:function(){$("div.asideContainer_pickup").prepend("<div class=\"menu_messages_message\">"+pickupl_error+"</div>")}})},showSel:function(){pickup_sites.pickupCount=$(".asideContainer_pickup .pickup_point").length,pickup_sites.pickupIteration=0,$("div.loadingMap").fadeIn("normal",function(){}),$("span.loadingMap").hide(),$("span.loadingMarkers").css("display","block"),$("span.loadingMarkersCount").text(pickup_sites.pickupCount),$("span.loadingMarkersComplete").text(pickup_sites.pickupIteration),pickup_sites.markersArray=[];var o=[];$(".asideContainer_pickup .pickup_point").each(function(e){$this=$(this),o[e]={},o[e].idek=$this.data("id"),o[e].headerText=$.trim($this.find(".headerText").text()),o[e].streetText=$this.find(".streetText").text(),o[e].cityText=$.trim($this.find(".cityText").text()),o[e].moreText=$.trim($this.find(".moreLink").text()),o[e].moreLink=$.trim($this.find(".moreLink").attr("href")),o[e].infoText=$.trim($this.find(".infoText").text()),o[e].timeText=$.trim($this.find(".timeText").text()),o[e].latitude=$.trim($this.data("latitude")),o[e].longitude=$.trim($this.data("longitude")),o[e].icon=$.trim($this.data("icon"))});for(var e="";e=o.pop();)e.latitude&&e.longitude?pickup_sites.findAdres(e.headerText,e.streetText,e.cityText,e.moreText,e.moreLink,e.infoText,e.timeText,"none","another",!1,e.idek,e.latitude,e.longitude,e.icon):function(t){setTimeout(function(){pickup_sites.findAdres(t.headerText,t.streetText,t.cityText,t.moreText,t.moreLink,t.infoText,t.timeText,"none","another",!1,t.idek,t.latitude,t.longitude,t.icon)},pickup_sites.timeout)}(e)},printDates:function(t){return!!$("#selectPickupDay").size()&&void $.ajax({type:"GET",url:"/ajax/basket-delivery.php",data:{stock_id:t},dataType:"json",success:function(t){return t?void($("#selectPickupDay").html(""),$.each(t,function(o,e){$("#selectPickupDay").append("<label class=\"pickupl_date\"><input name=\"calendar_select_date\" type=\"radio\" class=\"pickupl_radio\" value=\""+e.date+"\"></input><div class=\"pickupl_date_sub\"><span class=\"pickupl_date_day\">"+e.d+"</span><span class=\"pickupl_date_month\">"+iaical_monthNames[e.m-1]+"</span></div></label>")}),$("#selectPickupDayWrapper").show(),$(".pickupl_hour_wrapper").show(),$("#selectPickupDay [name=\"calendar_select_date\"]").eq(1).prop("checked",!0)):($("#selectPickupDayWrapper").hide(),!1)},error:function(){Alertek.show_alert(pickupl_error)}})},setZoom:function(){var o=new google.maps.LatLngBounds;for(var e in pickup_sites.markersArray)o.extend(pickup_sites.markersArray[e].getPosition());pickup_sites.mapa.setCenter(o.getCenter()),pickup_sites.mapa.fitBounds(o),pickup_sites.mapa.setZoom(pickup_sites.mapa.getZoom()),15<pickup_sites.mapa.getZoom()&&pickup_sites.mapa.setZoom(15)},mapInit:function(){if($("#mymap").length)return!1;$("#autocomplete_location").size()&&!$("#mymap").size()&&(pickup_sites.autocomplete=new google.maps.places.Autocomplete(document.getElementById("autocomplete_location")),$("label.pickup_point").hide()),pickup_sites.zoom=pickupsZoom,pickup_sites.geokoder=new google.maps.Geocoder;var d=new google.maps.LatLng(parseInt(bCordPickups),parseInt(lCordPickups));if(pickup_sites.markerAnimation=""!=markersAnimationPickups,markerPickupsCustomIcon=""!=markerPickupsCustomIcon,"ROADMAP"==mapTypePickups)var e=google.maps.MapTypeId.ROADMAP;else if("SATELLITE"==mapTypePickups)var e=google.maps.MapTypeId.SATELLITE;else if("HYBRID"==mapTypePickups)var e=google.maps.MapTypeId.HYBRID;else if("TERRAIN"==mapTypePickups)var e=google.maps.MapTypeId.TERRAIN;else var e=google.maps.MapTypeId.ROADMAP;if(navControlPickups=""!=navControlPickups,mapTypeControlPickups=""!=mapTypeControlPickups,scControlPickups=""!=scControlPickups,"ZOOM_PAN"==controlTypePickups)var p=google.maps.NavigationControlStyle.ZOOM_PAN;else if("SMALL"==controlTypePickups)var p=google.maps.NavigationControlStyle.SMALL;else if("ANDROID"==controlTypePickups)var p=google.maps.NavigationControlStyle.ANDROID;else var p=google.maps.NavigationControlStyle.ZOOM_PAN;if("DROPDOWN_MENU"==mapTypeControlStylePickups)var _=google.maps.MapTypeControlStyle.DROPDOWN_MENU;else if("HORIZONTAL_BAR"==mapTypeControlStylePickups)google.maps.MapTypeControlStyle.HORIZONTAL_BAR;else var _=google.maps.MapTypeControlStyle.DROPDOWN_MENU;if(""!=$("img.marker_face").attr("src")&&markerPickupsCustomIcon){var m=new google.maps.Size($("img.marker_face").width(),$("img.marker_face").height()),a=new google.maps.Point(0,0),r=new google.maps.Point(parseInt($("img.marker_face").width()/2),parseInt($("img.marker_face").height()/2));pickup_sites.markerIcon=new google.maps.MarkerImage($("img.marker_face").attr("src"),m,a,r)}if(window.google_map_style_array)var s={gestureHandling:"cooperative",zoom:pickup_sites.zoom,center:d,mapTypeId:e,navigationControl:navControlPickups,mapTypeControl:mapTypeControlPickups,scaleControl:scControlPickups,styles:google_map_style_array,navigationControlOptions:{style:p},mapTypeControlOptions:{style:_}};else var s={gestureHandling:"cooperative",zoom:pickup_sites.zoom,center:d,mapTypeId:e,navigationControl:navControlPickups,mapTypeControl:mapTypeControlPickups,scaleControl:scControlPickups,navigationControlOptions:{style:p},mapTypeControlOptions:{style:_}};""===pickup_sites.google_api_key&&($(".pickupl_sel").removeAttr("disabled"),$("div#ps_other").css("opacity","1.0"),$("div#ps_other").css("cursor","pointer")),pickup_sites.mapa=new google.maps.Map(document.getElementById("pickup_map"),s),pickup_sites.markerInfo=new google.maps.InfoWindow,google.maps.event.addListener(pickup_sites.mapa,"idle",function(){$("span.loadingMap").text($("span.loadingNav").text())}),pickup_sites.autocomplete?(pickup_sites.autocomplete.addListener("place_changed",function(){var t=pickup_sites.autocomplete.getPlace();pickup_sites.fillInAddress(t,!1),pickup_sites.getLocation()}),pickup_sites.getLocation()):pickup_sites.showSel()},markerClickFunction:function(e,t){return function(o){o.cancelBubble=!0,o.returnValue=!1,o.stopPropagation&&(o.stopPropagation(),o.preventDefault()),pickup_sites.infoWindow.setContent(t),pickup_sites.infoWindow.setPosition(e),pickup_sites.infoWindow.open(pickup_sites.mapa)}},geokoderPrepare:function(P,e,t,o,n,a,r,s,l,d,p,_,m,c,u,g){if(e==google.maps.GeocoderStatus.OK){pickup_sites.timeout=100,pickup_sites.pickupIteration++,pickup_sites.pickupFind++;var y="<div class=\"mapTooltip\"><b class=\"mapTooltipName\">"+t+"</b>";y+="<div class=\"mapTooltipAdress\"><span>"+o+" </span> <span>"+n+"</span></div>",s&&(y+="<div class=\"mapTooltipComment\">"+s+"</div>"),y+="<div class=\"mapTooltipTime\">"+l+"</div>",r&&(y+="<div class=\"mapTooltipLink\"><a class=\"btn-small\" title=\"Zobacz szczeg\xF3\u0142owe informacje\" href=\""+r+"\" target=\"_blank\">"+a+"</a></div>"),y+="</div>";var k={title:t,pickupPointID:m};k.position=P,k.map=pickup_sites.mapa,pickup_sites.markerAnimation&&(k.animation=google.maps.Animation.DROP),g&&""!=g?k.icon=g:""!=$("img.marker_face").attr("src")&&markerPickupsCustomIcon&&(k.icon=pickup_sites.markerIcon);var f=new google.maps.Marker(k);pickup_sites.markersArray.push(f),google.maps.event.addListener(f,"click",function(e){return function(t){t.cancelBubble=!0,t.returnValue=!1,t.stopPropagation&&(t.stopPropagation(),t.preventDefault()),pickup_sites.markerInfo.setContent(y),pickup_sites.markerInfo.open(pickup_sites.mapa,e),$(".asideContainer_pickup [value=\""+e.pickupPointID+"\"]").prop("checked",!0),$(".asideContainer_pickup").scrollTop(0),$(".asideContainer_pickup").scrollTop($("#pickup_site [name=\"pickup_point\"]:checked + label").position().top)}}(f,i));var v=$(".asideContainer_pickup [value=\""+f.pickupPointID+"\"]").get(0);$("label[for=\"pickup_point_"+f.pickupPointID+"\"]").show().fadeTo("slow",1),google.maps.event.addDomListener(v,"click",function(t){return function(){$(".asideContainer_pickup [value=\""+t.pickupPointID+"\"]").prop("checked",!0),pickup_sites.markerInfo.setContent(y),pickup_sites.mapa.setCenter(k.position),pickup_sites.mapa.getZoom()<pickup_sites.ClusterMaxZoom&&pickup_sites.mapa.setZoom(pickup_sites.ClusterMaxZoom+1),pickup_sites.markerInfo.open(pickup_sites.mapa,t)}}(f,i)),pickup_sites.pickupIteration<pickup_sites.pickupCount&&$("span.loadingMarkersComplete").text(pickup_sites.pickupIteration),pickup_sites.pickupIteration>=pickup_sites.pickupCount&&setTimeout(function(){$("div.loadingMap").fadeOut("normal",function(){});var n=$(".markerCluster[src*=\"m1.png\"]").attr("src"),e=n.substring(0,n.indexOf("1.png"));pickup_sites.setZoom();var t=!0;pickup_sites.mapa.zoom<pickup_sites.ClusterMaxZoom&&!jQuery.isEmptyObject(selected_pickup_point)?pickup_sites.minimumClusterSizeTMP=2:(t=!1,pickup_sites.minimumClusterSizeTMP=pickup_sites.minimumClusterSize),!pickup_sites.markerClusters||t?pickup_sites.markerClusters=new MarkerClusterer(pickup_sites.mapa,pickup_sites.markersArray,{imagePath:e,maxZoom:pickup_sites.ClusterMaxZoom,minimumClusterSize:pickup_sites.minimumClusterSizeTMP}):(pickup_sites.markerClusters.clearMarkers(),pickup_sites.markerClusters.addMarkers(pickup_sites.markersArray)),jQuery.isEmptyObject(selected_pickup_point)||($("label.pickup_point:first-of-type").prev().prop("checked",!0),pickup_sites.markerInfo.setContent(y),pickup_sites.markerInfo.open(pickup_sites.mapa,pickup_sites.markersArray[pickup_sites.markersArray.length-1]),selected_pickup_point={})},300)}else e==google.maps.GeocoderStatus.OVER_QUERY_LIMIT?(pickup_sites.timeout+=50,setTimeout(function(){pickup_sites.findAdres(t,o,n,a,r,s,l,d,p,_,m,c,u,g)},pickup_sites.timeout)):(pickup_sites.pickupIteration++,pickup_sites.pickupIteration<=pickup_sites.pickupCount&&$("span.loadingMarkersComplete").text(pickup_sites.pickupIteration),pickup_sites.pickupIteration>=pickup_sites.pickupCount&&setTimeout(function(){$("div.loadingMap").fadeOut("normal",function(){});var n=$(".markerCluster[src*=\"m1.png\"]").attr("src"),e=n.substring(0,n.indexOf("1.png")-1);pickup_sites.setZoom();var t=!0;pickup_sites.mapa.zoom<pickup_sites.ClusterMaxZoom&&!jQuery.isEmptyObject(selected_pickup_point)?(pickup_sites.minimumClusterSizeTMP=2,selected_pickup_point={}):(t=!1,pickup_sites.minimumClusterSizeTMP=pickup_sites.minimumClusterSize),!pickup_sites.markerClusters||t?pickup_sites.markerClusters=new MarkerClusterer(pickup_sites.mapa,pickup_sites.markersArray,{imagePath:e,maxZoom:pickup_sites.ClusterMaxZoom,minimumClusterSize:pickup_sites.minimumClusterSizeTMP}):(pickup_sites.markerClusters.clearMarkers(),pickup_sites.markerClusters.addMarkers(pickup_sites.markersArray))},300))},findAdres:function(f,e,t,o,n,a,r,s,l,d,p,_,m,c){if(_&&m){var u=new google.maps.LatLng(_,m);pickup_sites.geokoderPrepare(u,"OK",f,e,t,o,n,a,r,s,l,d,p,_,m,c)}else pickup_sites.geokoder.geocode({address:e+" , "+t},function(u,g){var y=u&&u.length?u[0].geometry.location:null;pickup_sites.geokoderPrepare(y,g,f,e,t,o,n,a,r,s,l,d,p,_,m,c)})}};function init_pickupl_site(){if(pickup_sites.autocomplete&&pickup_sites.autocomplete.setComponentRestrictions({country:pickup_sites.country_code}),"undefined"!=typeof mapSiteType&&"pickup_site"==mapSiteType){var a=$("div.loadingMap").width()/2,e=$("div.loadingMap").height()/2,t=$("div.loadingBox").width()/2,o=$("div.loadingBox").height()/2;pickup_sites.google_api_key=google_api_key,$("div.loadingBox").css("left",a-t),$("div.loadingBox").css("top",e-o),$("div.loadingBox").fadeTo("normal",1,function(){})}$(".no_google_api_key").length&&(orderdetails_payments.ajaxLoadSite(1),ajaxGetPickupNoMap())}var setPickupPoints=function(l,e,t){if(!$.isEmptyObject(pickup_sites.markersArray)&&!t)for(i in pickup_sites.markersArray)pickup_sites.markersArray[i].setMap(null);if($("#pickup_site .asideContainer_pickup").html(""),e){var o=[];for(i in l.pickupPoints)$.trim(l.pickupPoints[i].address.city).toLowerCase()==$.trim(pickup_sites.adress.locality).toLowerCase()&&o.push(l.pickupPoints[i]);o.length&&(l.pickupPoints=o)}const n=document.getElementById("payitem_cash").checked?0:1;for(i in l.pickupPoints){const e=document.querySelector(`#item_${l.pickupPoints[i].courierId}-${n}`).parentElement,t=e.querySelector(".name").innerHTML,o=e.querySelector(".photo").innerHTML;var d=l.pickupPoints[i],a=$("#pickup_copy").clone();a.find("input[name=pickup_point]").attr("id","pickup_point_"+d.id),a.find("input[name=pickup_point]").attr("data-courier-id",d.courierId),a.find(".zipcodePickup").after(`<strong class="map__price">${d.price}</strong>`),a.find("input[name=pickup_point]").val(d.id),a.find("label").attr("data-latitude",d.coordinates.latitude),a.find("label").attr("data-longitude",d.coordinates.longitude),a.find("label").attr("data-id",d.id),a.find("label").attr("data-requires_client_number",d.requiresClientNumber),a.find("label").attr("for","pickup_point_"+d.id),a.find("label").hide().css("opacity","0"),d.markerIconUrl&&(a.find("label").attr("data-icon",d.markerIconUrl),a.find("label").find("svg").replaceWith("<img src=\""+d.markerIconUrl+"\" alt=\""+d.id+"\"/>")),d.coordinates.longitude?a.find("label .map_dir").attr("href","https://www.google.com/maps/dir/?api=1&destination="+d.coordinates.latitude+","+d.coordinates.longitude):a.find("label .map_dir").attr("href","https://maps.google.com?saddr=Current+Location&daddr="+d.address.street+"+"+d.address.postcode+"+"+d.address.city),a.find("b.headerText").text(d.name);var r=""!=d.address.buildingAndHouseNumber&&null!=d.address.buildingAndHouseNumber?d.address.street+" "+d.address.buildingAndHouseNumber:d.address.street;a.find("span.streetText").text(r),a.find("span.zipcodePickup").html(d.address.postcode+" <span class=\"cityText\">"+d.address.city+"</span>"),a.find("div.moreText").text(d.location),a.find("a.moreLink").attr("href",d.link),a.find(".headerText").before(`<h3 class="courierName">${o}${t}</h3>`),d.requiresClientNumber||a.find("input[name=client_courier_number]").remove(),$("#pickup_site .asideContainer_pickup").append(a.find(" > *"))}pickup_sites.showSel()};function geolocate(){pickup_sites.search_lat="",pickup_sites.search_lng="",navigator.geolocation&&navigator.geolocation.getCurrentPosition(function(n){var e={lat:n.coords.latitude,lng:n.coords.longitude},t=new google.maps.Circle({center:e,radius:n.coords.accuracy});pickup_sites.autocomplete.setBounds(t.getBounds())})}$(document).on("click","#locationField .btn",function(){return $("#mymap").length?(leafletGetTextLocation(),$(".leafleat-suggestions").remove()):pickup_sites.getLocation(),!1}),$(document).on("click","div.morePickup",function(){var t=$("label.pickup_point.moreInfoShow");$(this).parents("label.pickup_point").addClass("moreInfoShow"),t.removeClass("moreInfoShow")}),$(document).on("click","#pickup_site [name=\"pickup_point\"], #pickup_site [name=\"stock\"]",function(){$("#pickup_site [name=\"client_courier_number\"]").prop("disabled",!0),$(this).find("+ label [name=\"client_courier_number\"]").prop("disabled",!1).focus(),pickup_sites.printDates($(this).val())}),app_shop.run(function(){pickup_sites.country_code=app_shop.vars.country_code,pickup_sites.language=app_shop.vars.language,pickup_sites.isCod=app_shop.vars.isCod,pickup_sites.courierId=app_shop.vars.courierId,init_pickupl_site();var o="https://maps.googleapis.com/maps/api/js?key="+app_shop.vars.apiKey+"&libraries=places&callback=pickup_sites.mapInit",e=document.createElement("script");e.setAttribute("src",o),document.body.appendChild(e)},"all","#pickup_site");function MarkerClusterer(r,e,t){this.extend(MarkerClusterer,google.maps.OverlayView),this.map_=r,this.markers_=[],this.clusters_=[],this.sizes=[53,56,66,78,90],this.styles_=[],this.ready_=!1;var o=t||{};this.gridSize_=o.gridSize||60,this.minClusterSize_=o.minimumClusterSize||2,this.maxZoom_=o.maxZoom||null,this.styles_=o.styles||[],this.imagePath_=o.imagePath||this.MARKER_CLUSTER_IMAGE_PATH_,this.imageExtension_=o.imageExtension||this.MARKER_CLUSTER_IMAGE_EXTENSION_,this.zoomOnClick_=!0,null!=o.zoomOnClick&&(this.zoomOnClick_=o.zoomOnClick),this.averageCenter_=!1,null!=o.averageCenter&&(this.averageCenter_=o.averageCenter),this.setupStyles_(),this.setMap(r),this.prevZoom_=this.map_.getZoom();var n=this;google.maps.event.addListener(this.map_,"zoom_changed",function(){var a=n.map_.getZoom(),r=n.map_.minZoom||0,t=Math.min(n.map_.maxZoom||100,n.map_.mapTypes[n.map_.getMapTypeId()].maxZoom);a=Math.min(Math.max(a,r),t),n.prevZoom_!=a&&(n.prevZoom_=a,n.resetViewport())}),google.maps.event.addListener(this.map_,"idle",function(){n.redraw()}),e&&(e.length||Object.keys(e).length)&&this.addMarkers(e,!1)}MarkerClusterer.prototype.MARKER_CLUSTER_IMAGE_PATH_="../images/m",MarkerClusterer.prototype.MARKER_CLUSTER_IMAGE_EXTENSION_="png",MarkerClusterer.prototype.extend=function(o,e){return function(o){for(var e in o.prototype)this.prototype[e]=o.prototype[e];return this}.apply(o,[e])},MarkerClusterer.prototype.onAdd=function(){this.setReady_(!0)},MarkerClusterer.prototype.draw=function(){},MarkerClusterer.prototype.setupStyles_=function(){if(!this.styles_.length)for(var o,n=0;o=this.sizes[n];n++)this.styles_.push({url:this.imagePath_+(n+1)+"."+this.imageExtension_,height:o,width:o})},MarkerClusterer.prototype.fitMapToMarkers=function(){for(var a,r=this.getMarkers(),t=new google.maps.LatLngBounds,o=0;a=r[o];o++)t.extend(a.getPosition());this.map_.fitBounds(t)},MarkerClusterer.prototype.setStyles=function(t){this.styles_=t},MarkerClusterer.prototype.getStyles=function(){return this.styles_},MarkerClusterer.prototype.isZoomOnClick=function(){return this.zoomOnClick_},MarkerClusterer.prototype.isAverageCenter=function(){return this.averageCenter_},MarkerClusterer.prototype.getMarkers=function(){return this.markers_},MarkerClusterer.prototype.getTotalMarkers=function(){return this.markers_.length},MarkerClusterer.prototype.setMaxZoom=function(t){this.maxZoom_=t},MarkerClusterer.prototype.getMaxZoom=function(){return this.maxZoom_},MarkerClusterer.prototype.calculator_=function(r,e){for(var t=0,s=r.length,n=s;0!==n;)n=parseInt(n/10,10),t++;return t=Math.min(t,e),{text:s,index:t}},MarkerClusterer.prototype.setCalculator=function(t){this.calculator_=t},MarkerClusterer.prototype.getCalculator=function(){return this.calculator_},MarkerClusterer.prototype.addMarkers=function(a,e){if(a.length)for(var t,r=0;t=a[r];r++)this.pushMarkerTo_(t);else if(Object.keys(a).length)for(var t in a)this.pushMarkerTo_(a[t]);e||this.redraw()},MarkerClusterer.prototype.pushMarkerTo_=function(o){if(o.isAdded=!1,o.draggable){var e=this;google.maps.event.addListener(o,"dragend",function(){o.isAdded=!1,e.repaint()})}this.markers_.push(o)},MarkerClusterer.prototype.addMarker=function(o,e){this.pushMarkerTo_(o),e||this.redraw()},MarkerClusterer.prototype.removeMarker_=function(a){var e=-1;if(this.markers_.indexOf)e=this.markers_.indexOf(a);else for(var r,s=0;r=this.markers_[s];s++)if(r==a){e=s;break}return-1!=e&&(a.setMap(null),this.markers_.splice(e,1),!0)},MarkerClusterer.prototype.removeMarker=function(n,e){var t=this.removeMarker_(n);return!e&&t&&(this.resetViewport(),this.redraw(),!0)},MarkerClusterer.prototype.removeMarkers=function(r,e){for(var t,l,d=!1,p=0;t=r[p];p++)l=this.removeMarker_(t),d=d||l;if(!e&&d)return this.resetViewport(),this.redraw(),!0},MarkerClusterer.prototype.setReady_=function(t){this.ready_||(this.ready_=t,this.createClusters_())},MarkerClusterer.prototype.getTotalClusters=function(){return this.clusters_.length},MarkerClusterer.prototype.getMap=function(){return this.map_},MarkerClusterer.prototype.setMap=function(t){this.map_=t},MarkerClusterer.prototype.getGridSize=function(){return this.gridSize_},MarkerClusterer.prototype.setGridSize=function(t){this.gridSize_=t},MarkerClusterer.prototype.getMinClusterSize=function(){return this.minClusterSize_},MarkerClusterer.prototype.setMinClusterSize=function(t){this.minClusterSize_=t},MarkerClusterer.prototype.getExtendedBounds=function(d){var e=this.getProjection(),t=new google.maps.LatLng(d.getNorthEast().lat(),d.getNorthEast().lng()),o=new google.maps.LatLng(d.getSouthWest().lat(),d.getSouthWest().lng()),n=e.fromLatLngToDivPixel(t);n.x+=this.gridSize_,n.y-=this.gridSize_;var a=e.fromLatLngToDivPixel(o);a.x-=this.gridSize_,a.y+=this.gridSize_;var r=e.fromDivPixelToLatLng(n),s=e.fromDivPixelToLatLng(a);return d.extend(r),d.extend(s),d},MarkerClusterer.prototype.isMarkerInBounds_=function(o,e){return e.contains(o.getPosition())},MarkerClusterer.prototype.clearMarkers=function(){this.resetViewport(!0),this.markers_=[]},MarkerClusterer.prototype.resetViewport=function(a){for(var e,r=0;e=this.clusters_[r];r++)e.remove();for(var s,r=0;s=this.markers_[r];r++)s.isAdded=!1,a&&s.setMap(null);this.clusters_=[]},MarkerClusterer.prototype.repaint=function(){var n=this.clusters_.slice();this.clusters_.length=0,this.resetViewport(),this.redraw(),window.setTimeout(function(){for(var e,a=0;e=n[a];a++)e.remove()},0)},MarkerClusterer.prototype.redraw=function(){this.createClusters_()},MarkerClusterer.prototype.distanceBetweenPoints_=function(s,e){if(!s||!e)return 0;var t=(e.lat()-s.lat())*Math.PI/180,o=(e.lng()-s.lng())*Math.PI/180,n=Math.sin(t/2)*Math.sin(t/2)+Math.cos(s.lat()*Math.PI/180)*Math.cos(e.lat()*Math.PI/180)*Math.sin(o/2)*Math.sin(o/2),r=2*Math.atan2(Math.sqrt(n),Math.sqrt(1-n));return 6371*r},MarkerClusterer.prototype.addToClosestCluster_=function(d){for(var e,p,_=4e4,m=null,c=d.getPosition(),r=0;e=this.clusters_[r];r++)if(p=e.getCenter(),p){var u=this.distanceBetweenPoints_(p,d.getPosition());u<_&&(_=u,m=e)}if(m&&m.isMarkerInClusterBounds(d))m.addMarker(d);else{var e=new Cluster(this);e.addMarker(d),this.clusters_.push(e)}},MarkerClusterer.prototype.createClusters_=function(){if(this.ready_)for(var a,r=new google.maps.LatLngBounds(this.map_.getBounds().getSouthWest(),this.map_.getBounds().getNorthEast()),t=this.getExtendedBounds(r),o=0;a=this.markers_[o];o++)!a.isAdded&&this.isMarkerInBounds_(a,t)&&this.addToClosestCluster_(a)};function Cluster(t){this.markerClusterer_=t,this.map_=t.getMap(),this.gridSize_=t.getGridSize(),this.minClusterSize_=t.getMinClusterSize(),this.averageCenter_=t.isAverageCenter(),this.center_=null,this.markers_=[],this.bounds_=null,this.clusterIcon_=new ClusterIcon(this,t.getStyles(),t.getGridSize())}Cluster.prototype.isMarkerAlreadyAdded=function(n){if(this.markers_.indexOf)return-1!=this.markers_.indexOf(n);for(var e,a=0;e=this.markers_[a];a++)if(e==n)return!0;return!1},Cluster.prototype.addMarker=function(s){if(this.isMarkerAlreadyAdded(s))return!1;if(!this.center_)this.center_=s.getPosition(),this.calculateBounds_();else if(this.averageCenter_){var e=this.markers_.length+1,t=(this.center_.lat()*(e-1)+s.getPosition().lat())/e,o=(this.center_.lng()*(e-1)+s.getPosition().lng())/e;this.center_=new google.maps.LatLng(t,o),this.calculateBounds_()}s.isAdded=!0,this.markers_.push(s);var n=this.markers_.length;if(n<this.minClusterSize_&&s.getMap()!=this.map_&&s.setMap(this.map_),n==this.minClusterSize_)for(var a=0;a<n;a++)this.markers_[a].setMap(null);return n>=this.minClusterSize_&&s.setMap(null),this.updateIcon(),!0},Cluster.prototype.getMarkerClusterer=function(){return this.markerClusterer_},Cluster.prototype.getBounds=function(){for(var a,r=new google.maps.LatLngBounds(this.center_,this.center_),t=this.getMarkers(),o=0;a=t[o];o++)r.extend(a.getPosition());return r},Cluster.prototype.remove=function(){this.clusterIcon_.remove(),this.markers_.length=0,delete this.markers_},Cluster.prototype.getSize=function(){return this.markers_.length},Cluster.prototype.getMarkers=function(){return this.markers_},Cluster.prototype.getCenter=function(){return this.center_},Cluster.prototype.calculateBounds_=function(){var t=new google.maps.LatLngBounds(this.center_,this.center_);this.bounds_=this.markerClusterer_.getExtendedBounds(t)},Cluster.prototype.isMarkerInClusterBounds=function(t){return this.bounds_.contains(t.getPosition())},Cluster.prototype.getMap=function(){return this.map_},Cluster.prototype.updateIcon=function(){var s=this.map_.getZoom(),e=this.markerClusterer_.getMaxZoom();if(e&&s>e){for(var t,l=0;t=this.markers_[l];l++)t.setMap(this.map_);return}if(this.markers_.length<this.minClusterSize_)return void this.clusterIcon_.hide();var d=this.markerClusterer_.getStyles().length,a=this.markerClusterer_.getCalculator()(this.markers_,d);this.clusterIcon_.setCenter(this.center_),this.clusterIcon_.setSums(a),this.clusterIcon_.show()};function ClusterIcon(n,e,t){n.getMarkerClusterer().extend(ClusterIcon,google.maps.OverlayView),this.styles_=e,this.padding_=t||0,this.cluster_=n,this.center_=null,this.map_=n.getMap(),this.div_=null,this.sums_=null,this.visible_=!1,this.setMap(this.map_)}ClusterIcon.prototype.triggerClusterClick=function(){var t=this.cluster_.getMarkerClusterer();google.maps.event.trigger(t,"clusterclick",this.cluster_),t.isZoomOnClick()&&this.map_.fitBounds(this.cluster_.getBounds())},ClusterIcon.prototype.onAdd=function(){if(this.div_=document.createElement("DIV"),this.visible_){var n=this.getPosFromLatLng_(this.center_);this.div_.style.cssText=this.createCss(n),this.div_.innerHTML=this.sums_.text}var e=this.getPanes();e.overlayMouseTarget.appendChild(this.div_);var t=this;google.maps.event.addDomListener(this.div_,"click",function(){t.triggerClusterClick()})},ClusterIcon.prototype.getPosFromLatLng_=function(o){var e=this.getProjection().fromLatLngToDivPixel(o);return e.x-=parseInt(this.width_/2,10),e.y-=parseInt(this.height_/2,10),e},ClusterIcon.prototype.draw=function(){if(this.visible_){var t=this.getPosFromLatLng_(this.center_);this.div_.style.top=t.y+"px",this.div_.style.left=t.x+"px"}},ClusterIcon.prototype.hide=function(){this.div_&&(this.div_.style.display="none"),this.visible_=!1},ClusterIcon.prototype.show=function(){if(this.div_){var t=this.getPosFromLatLng_(this.center_);this.div_.style.cssText=this.createCss(t),this.div_.style.display=""}this.visible_=!0},ClusterIcon.prototype.remove=function(){this.setMap(null)},ClusterIcon.prototype.onRemove=function(){this.div_&&this.div_.parentNode&&(this.hide(),this.div_.parentNode.removeChild(this.div_),this.div_=null)},ClusterIcon.prototype.setSums=function(t){this.sums_=t,this.text_=t.text,this.index_=t.index,this.div_&&(this.div_.innerHTML=t.text),this.useStyle()},ClusterIcon.prototype.useStyle=function(){var o=Math.max(0,this.sums_.index-1);o=Math.min(this.styles_.length-1,o);var n=this.styles_[o];this.url_=n.url,this.height_=n.height,this.width_=n.width,this.textColor_=n.textColor,this.anchor_=n.anchor,this.textSize_=n.textSize,this.backgroundPosition_=n.backgroundPosition},ClusterIcon.prototype.setCenter=function(t){this.center_=t},ClusterIcon.prototype.createCss=function(r){var e=["background-image:url("+this.url_+");"],t=this.backgroundPosition_?this.backgroundPosition_:"0 0";e.push("background-position:"+t+";"),"object"==typeof this.anchor_?("number"==typeof this.anchor_[0]&&0<this.anchor_[0]&&this.anchor_[0]<this.height_?e.push("height:"+(this.height_-this.anchor_[0])+"px; padding-top:"+this.anchor_[0]+"px;"):e.push("height:"+this.height_+"px; line-height:"+this.height_+"px;"),"number"==typeof this.anchor_[1]&&0<this.anchor_[1]&&this.anchor_[1]<this.width_?e.push("width:"+(this.width_-this.anchor_[1])+"px; padding-left:"+this.anchor_[1]+"px;"):e.push("width:"+this.width_+"px; text-align:center;")):e.push("height:"+this.height_+"px; line-height:"+this.height_+"px; width:"+this.width_+"px; text-align:center;");var o=this.textColor_?this.textColor_:"black",n=this.textSize_?this.textSize_:11;return e.push("cursor:pointer; top:"+r.y+"px; left:"+r.x+"px; color:"+o+"; position:absolute; font-size:"+n+"px; font-family:Arial,sans-serif; font-weight:bold"),e.join("")},$(document).on("click",".map_button_search > .pickup_search_here",function(){pickup_sites.search_lat=pickup_sites.mapa.center.lat(),pickup_sites.search_lng=pickup_sites.mapa.center.lng(),pickup_sites.ajaxGetPickup(!0)});var mymap,isLoaded=!1,isWaitingEnd=!1,leafletGetPickups=function(l,e,t){radius=15<=t?1:14==t?2:13==t?4:12==t?7:11==t?10:10==t?15:20;const s=pickup_sites.courierId.split("-")[1],o=document.querySelectorAll(`#osc_order1_${"1"==s?"prepaid":"dvp"} input[data-pickuppoint="y"]`),d=[];o.forEach(o=>{let n;const r=o.value.split("-")[0];n=t?{courierId:r,"location[latitude]":l,"location[longitude]":e,radius:radius,isCod:pickup_sites.isCod}:{courierId:r,"location[latitude]":l,"location[longitude]":e,isCod:pickup_sites.isCod},d.push($.ajax({type:"GET",url:"/ajax/getPickups.php",data:n,dataType:"json"}))}),Promise.all(d).then(n=>{const r={cities:[],pickupPoints:[]};if(n.forEach(t=>{0<t.cities.length&&(r.cities=[...r.cities,...t.cities]),0<t.pickupPoints.length&&(r.pickupPoints=[...r.pickupPoints,...t.pickupPoints])}),!jQuery.isEmptyObject(selected_pickup_point)){for(i in r.pickupPoints)r.pickupPoints[i].id==selected_pickup_point.id&&delete r.pickupPoints[i];r.pickupPoints.unshift(selected_pickup_point),console.log("pickupPoints unshift")}if(!r.pickupPoints.length)return $("div.asideContainer_pickup .menu_messages_message").length&&$("div.asideContainer_pickup .menu_messages_message").remove(),radius?($("div.asideContainer_pickup .menu_messages_message").length&&$("div.asideContainer_pickup .menu_messages_message").remove(),$("div.asideContainer_pickup").prepend("<div class=\"menu_messages_message\">"+pickupl_nopoints_in_area+"</div>")):$("div.asideContainer_pickup").prepend("<div class=\"menu_messages_message\">"+pickupl_nopoints+"</div>"),$(".loadingMap").hide(),!1;for(i in leafletItems=[],r.pickupPoints){var t=r.pickupPoints[i].coordinates.latitude,l=r.pickupPoints[i].coordinates.longitude;(""==t||""==l)&&($.ajaxSetup({async:!1}),$.get(location.protocol+"//nominatim.openstreetmap.org/search?format=json&q="+r.pickupPoints[i].address.street+", "+r.pickupPoints[i].address.city+" "+r.pickupPoints[i].address.city+" "+r.pickupPoints[i].address.country,function(o){jQuery.isEmptyObject(o)?console.log("nie mog\u0119 znale\u017A\u0107 korodynat\xF3w adresu!"):(t=o[0].lat,l=o[0].lon)})),r.pickupPoints[i].iconOptions=getMarkerIcon(r.pickupPoints[i].courierId),r.pickupPoints[i].price=document.getElementById(`item_${r.pickupPoints[i].courierId}-${s}`).parentElement.querySelector(".price").innerHTML,leafletItems.push({id:r.pickupPoints[i].id,name:r.pickupPoints[i].name,link:r.pickupPoints[i].link,address:r.pickupPoints[i].address,courierId:r.pickupPoints[i].courierId,price:r.pickupPoints[i].price,iconOptions:r.pickupPoints[i].iconOptions,lat:t,lon:l})}setPickupPointsNoMap(r,!1,!0),jQuery.isEmptyObject(leafletItems)||leafletStartMap(leafletItems[0].lat,leafletItems[0].lon,!0)})},leafletMarker=[],leafletItems=[];function leafletDelMarkers(){for(i=0;i<markersList.length;i++)mymap.removeLayer(markers[markersList[i]]);markersList=[]}function leafletOnClick(s){var t=s.target.getPopup(),e=t.getContent(),o=new DOMParser,n=o.parseFromString(e,"text/html"),a=$(n).find("b").attr("data-id");$(".asideContainer_pickup label.pickup_point[data-id=\""+a+"\"]").click()}var markers={},markersList=[],leafletStartMap=function(n,e){const a=document.getElementById("payitem_cash").checked?0:1;for(isLoaded||(mymap=L.map("mymap").setView([n,e],13),L.tileLayer("https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png",{attribution:"© <a href=\"https://www.openstreetmap.org/copyright\">OpenStreetMap</a> contributors"}).addTo(mymap),isLoaded=!0,isWaitingEnd=!0),$(".loadingPoints").remove(),i=0;i<leafletItems.length;i++){let r=`<a target="_blank" class="btn-small"title="`+stocks_list_more_txt+`"href="`+leafletItems[i].link+`">`+stocks_list_more_txt+`</a><a class="btn-small fbs02_btn" title="`+stocks_list_choose+`" href="#close">`+stocks_list_choose+`</a>`,e="";e=null==leafletItems[i].address.street?`<div class="mapTooltipAdress">`+leafletItems[i].address+`</div>`:`<div class="mapTooltipAdress"><span>`+leafletItems[i].address.street+` `+leafletItems[i].address.buildingAndHouseNumber+`</span> <span>`+leafletItems[i].address.city+`</span></div>`;const t=`<strong class="map__price">${leafletItems[i].price}</strong>`,o=document.querySelector(`#item_${leafletItems[i].courierId}-${a}`).parentElement,s=o.querySelector(".name").innerHTML,l=o.querySelector(".photo").innerHTML;let d=`<h3 class="courierName">${l}${s}</h3><b class="mapTooltipName"data-id="`+leafletItems[i].id+`">`+leafletItems[i].name+`</b><br/>`+e+t+`<br/>`+r;markersList.push(leafletItems[i].id),markers[leafletItems[i].id]=L.marker([leafletItems[i].lat,leafletItems[i].lon],{icon:leafletItems[i].iconOptions}).addTo(mymap).on("click",leafletOnClick).bindPopup(d)}mymap.setView(new L.LatLng(n,e));let r=$(".asideContainer_pickup label.pickup_point").eq(0).attr("data-id");$(".asideContainer_pickup input[value=\""+r+"\"]").click(),$("img.leaflet-marker-icon").each(function(){var n=$(this).attr("src"),a=n.includes("preview/");a&&(n=n.replace("preview/",""));var t=n.includes("marker-icon");t&&(n=n.replace("-2x","")),$(this).attr("src",n)})},timeoutLeafLet=null;$(document).on("input","#autocomplete_location.autocomplete_nomap",function(){var t=$(this);clearTimeout(timeoutLeafLet),timeoutLeafLet=setTimeout(function(){3<t.val().length&&leafletGetLocation(t.val())},500)}),$(document).off("click.suggestions").on("click.suggestions",".leafleat-suggestions div",function(){$("#autocomplete_location").val($(this).text()),$(".leafleat-suggestions").remove();const o=$(this).attr("data-lat"),e=$(this).attr("data-lon");leafletDelMarkers(),selected_pickup_point={},leafletGetPickups(o,e)}),$(document).on("click",".map_button_search > .pickup_search_here_leaflet",function(){var o=mymap.getCenter(),e=mymap.getZoom();leafletDelMarkers(),selected_pickup_point={},leafletGetPickups(o.lat,o.lng,e)}),$(document).on("click","#pickup_site [name=\"pickup_point\"], #pickup_site [name=\"stock\"]",function(){const o=$(this).val();if(markers[o]){let e=markers[o].getLatLng();mymap.setView(new L.LatLng(e.lat,e.lng)),markers[o].openPopup()}});var leafletGetCoords=function(n){let a="",r="";n?$.get(location.protocol+"//nominatim.openstreetmap.org/search?format=json&q="+n,function(t){jQuery.isEmptyObject(t)?($(".asideContainer_pickup label.pickup_point").length&&($(".asideContainer_pickup label.pickup_point").each(function(){var s=$(this).data("id"),e=$(this).find(".headerText").text(),t=$(this).find(".map_dir").attr("href"),o=$(this).find(".streetText").text()+"<br/>"+$(this).find(".zipcodePickup").text(),n=$(this).data("latitude"),a=$(this).data("longitude");leafletItems.push({id:s,name:e,link:t,address:o,lat:n,lon:a})}),leafletStartMap(leafletItems[0].lat,leafletItems[0].lon,!0)),$("div.asideContainer_pickup .menu_messages_message").length&&$("div.asideContainer_pickup .menu_messages_message").remove(),$("div.asideContainer_pickup").prepend("<div class=\"menu_messages_message\">"+pickupl_nopoints+"</div>")):(a=t[0].lat,r=t[0].lon,leafletGetPickups(a,r))}):$(".asideContainer_pickup label.pickup_point").length&&($(".asideContainer_pickup label.pickup_point").each(function(){var s=$(this).data("id"),e=$(this).find(".headerText").text(),t=$(this).find(".map_dir").attr("href"),o=$(this).find(".streetText").text()+"<br/>"+$(this).find(".zipcodePickup").text(),n=$(this).data("latitude"),a=$(this).data("longitude");leafletItems.push({id:s,name:e,link:t,address:o,lat:n,lon:a})}),leafletStartMap(leafletItems[0].lat,leafletItems[0].lon,!0))},leafletGetLocation=function(t){$.get(location.protocol+"//nominatim.openstreetmap.org/search?format=json&q="+t,function(t){if(!jQuery.isEmptyObject(t))for(i in $("#locationField").append("<div class=\"leafleat-suggestions\"></div>"),t)$(".leafleat-suggestions").append("<div data-lat=\""+t[i].lat+"\" data-lon=\""+t[i].lon+"\">"+t[i].display_name+"</div>");else leafletStartMap(53.428,14.552,!0),$("div.asideContainer_pickup .menu_messages_message").length&&$("div.asideContainer_pickup .menu_messages_message").remove(),$("div.asideContainer_pickup").prepend("<div class=\"menu_messages_message\">"+pickupl_nopoints+"</div>")})},leafletGetTextLocation=function(){$("#mymap").prepend(`<div class="loadingPoints"><img src="/gfx/pol/loader.gif?r=1585561104"><span style="margin-left: 5px;">${<iai:variable vid="Ładowanie mapy" />}...</span></div>`);var t=$("#autocomplete_location").val();selected_pickup_point={},$.get(location.protocol+"//nominatim.openstreetmap.org/search?format=json&q="+t,function(e){if(!jQuery.isEmptyObject(e))leafletDelMarkers(),leafletGetPickups(e[0].lat,e[0].lon),$("#autocomplete_location").val(e[0].display_name);else{if(t.search(",")){var a=t.split(","),o=a[a.length-1].trim();leafletGetCoords(o)}$("div.asideContainer_pickup .menu_messages_message").length&&$("div.asideContainer_pickup .menu_messages_message").remove(),$("div.asideContainer_pickup").prepend("<div class=\"menu_messages_message\">"+pickupl_nopoints+"</div>")}})};app_shop.run(function(){if($("#autocomplete_location").length&&""!=$("#autocomplete_location").val()){let t=$("#autocomplete_location").val();leafletGetCoords(t)}else leafletGetCoords(!1)},"all","#mymap"),app_shop.run(function(){$("#mymap").before($(".map_button_search"))},1,"#mymap"),app_shop.run(function(){$("#mymap").prepend($(".map_button_search"))},[2,3,4],"#mymap"),!function(o,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e(o.L={})}(this,function(n){"use strict";function v(e){var o,n,a,d;for(n=1,a=arguments.length;n<a;n++)for(o in d=arguments[n])e[o]=d[o];return e}function P(){}function h(n,o){var t=Array.prototype.slice;if(n.bind)return n.bind.apply(n,t.call(arguments,1));var a=t.call(arguments,2);return function(){return n.apply(o,a.length?a.concat(t.call(arguments)):arguments)}}function H(t){return t._leaflet_id=t._leaflet_id||++wo,t._leaflet_id}function a(o,n,t){var a,r,s,l;return l=function(){a=!1,r&&(s.apply(t,r),r=!1)},s=function(){a?r=arguments:(o.apply(t,arguments),setTimeout(l,n),a=!0)}}function V(s,a,t){var r=a[1],e=a[0],n=r-e;return s===r&&t?s:((s-e)%n+n)%n+e}function Y(){return!1}function o(e,o){var t=Math.pow(10,void 0===o?6:o);return Math.round(e*t)/t}function r(t){return t.trim?t.trim():t.replace(/^\s+|\s+$/g,"")}function u(t){return r(t).split(/\s+/)}function l(e,o){for(var t in e.hasOwnProperty("options")||(e.options=e.options?zo(e.options):{}),o)e.options[t]=o[t];return e.options}function _(o,a,t){var r=[];for(var e in o)r.push(encodeURIComponent(t?e.toUpperCase():e)+"="+encodeURIComponent(o[e]));return(a&&-1!==a.indexOf("?")?"&":"?")+r.join("&")}function e(t,e){return t.replace(So,function(o,n){var t=e[n];if(void 0===t)throw new Error("No value provided for variable "+o);return"function"==typeof t&&(t=t(e)),t})}function m(e,o){for(var t=0;t<e.length;t++)if(e[t]===o)return t;return-1}function t(t){return window["webkit"+t]||window["moz"+t]||window["ms"+t]}function d(e){var o=+new Date,t=Math.max(0,16-(o-f));return f=o+t,window.setTimeout(e,t)}function ae(e,o,t){return t&&Io===d?void e.call(o):Io.call(window,h(e,o))}function p(t){t&&Eo.call(window,t)}function c(){}function y(e,o,t){this.x=t?Math.round(e):e,this.y=t?Math.round(o):o}function b(e,o,t){return e instanceof y?e:Ao(e)?new y(e[0],e[1]):null==e?e:"object"==typeof e&&"x"in e&&"y"in e?new y(e.x,e.y):new y(e,o,t)}function C(o,n){if(o)for(var t=n?[o,n]:o,a=0,r=t.length;a<r;a++)this.extend(t[a])}function w(o,e){return!o||o instanceof C?o:new C(o,e)}function g(o,n){if(o)for(var t=n?[o,n]:o,a=0,r=t.length;a<r;a++)this.extend(t[a])}function S(o,e){return o instanceof g?o:new g(o,e)}function I(e,o,t){if(isNaN(e)||isNaN(o))throw new Error("Invalid LatLng object: ("+e+", "+o+")");this.lat=+e,this.lng=+o,void 0!==t&&(this.alt=+t)}function M(e,o,t){return e instanceof I?e:Ao(e)&&"object"!=typeof e[0]?3===e.length?new I(e[0],e[1],e[2]):2===e.length?new I(e[0],e[1]):null:null==e?e:"object"==typeof e&&"lat"in e?new I(e.lat,"lng"in e?e.lng:e.lon,e.alt):void 0===o?null:new I(e,o,t)}function B(n,o,t,a){return Ao(n)?(this._a=n[0],this._b=n[1],this._c=n[2],void(this._d=n[3])):void(this._a=n,this._b=o,this._c=t,this._d=a)}function O(n,o,t,a){return new B(n,o,t,a)}function R(t){return document.createElementNS("http://www.w3.org/2000/svg",t)}function D(e,o){var t,n,a,r,s,l,y="";for(t=0,a=e.length;t<a;t++){for(n=0,r=(s=e[t]).length;n<r;n++)y+=(n?"L":"M")+(l=s[n]).x+" "+l.y;y+=o?Et?"z":"x":""}return y||"M0 0"}function N(t){return 0<=navigator.userAgent.toLowerCase().indexOf(t)}function j(n,o,t,a){return"touchstart"===o?function(n,o,a){var t=h(function(t){if("mouse"!==t.pointerType&&t.MSPOINTER_TYPE_MOUSE&&t.pointerType!==t.MSPOINTER_TYPE_MOUSE){if(!(0>Rt.indexOf(t.target.tagName)))return;go(t)}Q(t,o)});n["_leaflet_touchstart"+a]=t,n.addEventListener(kt,t,!1),Dt||(document.documentElement.addEventListener(kt,W,!0),document.documentElement.addEventListener(At,G,!0),document.documentElement.addEventListener(It,K,!0),document.documentElement.addEventListener(Ot,K,!0),Dt=!0)}(n,t,a):"touchmove"===o?function(n,o,a){function t(t){(t.pointerType!==t.MSPOINTER_TYPE_MOUSE&&"mouse"!==t.pointerType||0!==t.buttons)&&Q(t,o)}n["_leaflet_touchmove"+a]=t,n.addEventListener(At,t,!1)}(n,t,a):"touchend"==o&&function(n,o,a){function t(t){Q(t,o)}n["_leaflet_touchend"+a]=t,n.addEventListener(It,t,!1),n.addEventListener(Ot,t,!1)}(n,t,a),this}function W(t){Nt[t.pointerId]=t,Cn++}function G(t){Nt[t.pointerId]&&(Nt[t.pointerId]=t)}function K(t){delete Nt[t.pointerId],Cn--}function Q(e,o){for(var t in e.touches=[],Nt)e.touches.push(Nt[t]);e.changedTouches=[e],o(e)}function re(n,s,a){function t(n){var o;if(xt){if(!it||"mouse"===n.pointerType)return;o=Cn}else o=n.touches.length;if(!(1<o)){var r=Date.now(),a=r-(l||r);d=n.touches?n.touches[0]:n,c=0<a&&250>=a,l=r}}function o(e){if(c&&!d.cancelBubble){if(xt){if(!it||"mouse"===e.pointerType)return;var o,n,p={};for(n in d)o=d[n],p[n]=o&&o.bind?o.bind(d):o;d=p}d.type="dblclick",d.button=0,s(d),l=null}}var l,d,c=!1;return n["_leaflet_"+An+a]=t,n["_leaflet_"+Ko+a]=o,n["_leaflet_dblclick"+a]=s,n.addEventListener(An,t,!!zt&&{passive:!1}),n.addEventListener(Ko,o,!!zt&&{passive:!1}),n.addEventListener("dblclick",s,!1),this}function Pe(o,a){var t=o["_leaflet_"+An+a],r=o["_leaflet_"+Ko+a],e=o["_leaflet_dblclick"+a];return o.removeEventListener(An,t,!!zt&&{passive:!1}),o.removeEventListener(Ko,r,!!zt&&{passive:!1}),it||o.removeEventListener("dblclick",e,!1),this}function Qe(t){return"string"==typeof t?document.getElementById(t):t}function Pt(e,o){var t=e.style[o]||e.currentStyle&&e.currentStyle[o];if((!t||"auto"===t)&&document.defaultView){var n=document.defaultView.getComputedStyle(e,null);t=n?n[o]:null}return"auto"===t?null:t}function wt(n,o,t){var a=document.createElement(n);return a.className=o||"",t&&t.appendChild(a),a}function Mt(o){var e=o.parentNode;e&&e.removeChild(o)}function Bt(t){for(;t.firstChild;)t.removeChild(t.firstChild)}function Ht(o){var e=o.parentNode;e&&e.lastChild!==o&&e.appendChild(o)}function Wt(o){var e=o.parentNode;e&&e.firstChild!==o&&e.insertBefore(o,e.firstChild)}function Ft(e,o){if(void 0!==e.classList)return e.classList.contains(o);var t=Gt(e);return 0<t.length&&new RegExp("(^|\\s)"+o+"(\\s|$)").test(t)}function qt(n,a){if(void 0!==n.classList)for(var t=u(a),r=0,s=t.length;r<s;r++)n.classList.add(t[r]);else if(!Ft(n,a)){var l=Gt(n);Ut(n,(l?l+" ":"")+a)}}function Vt(o,e){void 0===o.classList?Ut(o,r((" "+Gt(o)+" ").replace(" "+e+" "," "))):o.classList.remove(e)}function Ut(o,e){void 0===o.className.baseVal?o.className=e:o.className.baseVal=e}function Gt(t){return t.correspondingElement&&(t=t.correspondingElement),void 0===t.className.baseVal?t.className:t.className.baseVal}function Xt(o,e){"opacity"in o.style?o.style.opacity=e:"filter"in o.style&&function(e,o){var a=!1;try{a=e.filters.item("DXImageTransform.Microsoft.Alpha")}catch(t){if(1===o)return}o=Math.round(100*o),a?(a.Enabled=100!==o,a.Opacity=o):e.style.filter+=" progid:DXImageTransform.Microsoft.Alpha(opacity="+o+")"}(o,e)}function Jt(e){for(var o=document.documentElement.style,t=0;t<e.length;t++)if(e[t]in o)return e[t];return!1}function Qt(n,o,t){var a=o||new y(0,0);n.style[Kt]=(pt?"translate("+a.x+"px,"+a.y+"px)":"translate3d("+a.x+"px,"+a.y+"px,0)")+(t?" scale("+t+")":"")}function $t(o,e){o._leaflet_pos=e,gt?Qt(o,e):(o.style.left=e.x+"px",o.style.top=e.y+"px")}function eo(t){return t._leaflet_pos||new y(0,0)}function to(){so(window,"dragstart",go)}function oo(){lo(window,"dragstart",go)}function no(t){for(;-1===t.tabIndex;)t=t.parentNode;t.style&&(ao(),No=(Do=t).style.outline,t.style.outline="none",so(window,"keydown",ao))}function ao(){Do&&(Do.style.outline=No,No=Do=void 0,lo(window,"keydown",ao))}function io(t){for(;!((t=t.parentNode).offsetWidth&&t.offsetHeight||t===document.body););return t}function ro(o){var e=o.getBoundingClientRect();return{x:e.width/o.offsetWidth||1,y:e.height/o.offsetHeight||1,boundingClientRect:e}}function so(r,a,s,l){if("object"==typeof a)for(var e in a)po(r,e,a[e],s);else for(var n=0,p=(a=u(a)).length;n<p;n++)po(r,a[n],s,l);return this}function lo(a,s,l,d){if("object"==typeof s)for(var e in s)_o(a,e,s[e],l);else if(s)for(var n=0,_=(s=u(s)).length;n<_;n++)_o(a,s[n],l,d);else{for(var p in a._leaflet_events)_o(a,p,a._leaflet_events[p]);delete a._leaflet_events}return this}function po(a,r,s,l){var e=r+H(s)+(l?"_"+H(l):"");if(a._leaflet_events&&a._leaflet_events[e])return this;var t=function(e){return s.call(l||a,e||window.event)},d=t;xt&&0===r.indexOf("touch")?j(a,r,t,e):!Lt||"dblclick"!==r||xt&&ht?"addEventListener"in a?"mousewheel"===r?a.addEventListener("onwheel"in a?"wheel":"mousewheel",t,!!zt&&{passive:!1}):"mouseenter"===r||"mouseleave"===r?(t=function(t){t=t||window.event,Po(a,t)&&d(t)},a.addEventListener("mouseenter"===r?"mouseover":"mouseout",t,!1)):("click"===r&&nt&&(t=function(t){!function(n,o){var t=n.timeStamp||n.originalEvent&&n.originalEvent.timeStamp,a=Jo&&t-Jo;return a&&100<a&&500>a||n.target._simulatedClick&&!n._simulated?yo(n):void(Jo=t,o(n))}(t,d)}),a.addEventListener(r,t,!1)):"attachEvent"in a&&a.attachEvent("on"+r,t):re(a,t,e),a._leaflet_events=a._leaflet_events||{},a._leaflet_events[e]=t}function _o(a,r,t,s){var e=r+H(t)+(s?"_"+H(s):""),n=a._leaflet_events&&a._leaflet_events[e];return n?void(xt&&0===r.indexOf("touch")?function(n,o,t){var a=n["_leaflet_"+o+t];"touchstart"===o?n.removeEventListener(kt,a,!1):"touchmove"===o?n.removeEventListener(At,a,!1):"touchend"==o&&(n.removeEventListener(It,a,!1),n.removeEventListener(Ot,a,!1))}(a,r,e):!Lt||"dblclick"!==r||xt&&ht?"removeEventListener"in a?"mousewheel"===r?a.removeEventListener("onwheel"in a?"wheel":"mousewheel",n,!!zt&&{passive:!1}):a.removeEventListener("mouseenter"===r?"mouseover":"mouseleave"===r?"mouseout":r,n,!1):"detachEvent"in a&&a.detachEvent("on"+r,n):Pe(a,e),a._leaflet_events[e]=null):this}function mo(t){return t.stopPropagation?t.stopPropagation():t.originalEvent?t.originalEvent._stopped=!0:t.cancelBubble=!0,xo(t),this}function co(t){return po(t,"mousewheel",mo),this}function uo(t){return so(t,"mousedown touchstart dblclick",mo),po(t,"click",vo),this}function go(t){return t.preventDefault?t.preventDefault():t.returnValue=!1,this}function yo(t){return go(t),mo(t),this}function ho(n,o){if(!o)return new y(n.clientX,n.clientY);var t=ro(o),a=t.boundingClientRect;return new y((n.clientX-a.left)/t.x-o.clientLeft,(n.clientY-a.top)/t.y-o.clientTop)}function fo(t){return it?t.wheelDeltaY/2:t.deltaY&&0===t.deltaMode?-t.deltaY/$o:t.deltaY&&1===t.deltaMode?20*-t.deltaY:t.deltaY&&2===t.deltaMode?60*-t.deltaY:t.deltaX||t.deltaZ?0:t.wheelDelta?(t.wheelDeltaY||t.wheelDelta)/2:t.detail&&32765>Math.abs(t.detail)?20*-t.detail:t.detail?60*(t.detail/-32765):0}function vo(t){ln[t.type]=!0}function xo(o){var e=ln[o.type];return ln[o.type]=!1,e}function Po(e,o){var t=o.relatedTarget;if(!t)return!0;try{for(;t&&t!==e;)t=t.parentNode}catch(t){return!1}return t!==e}function ko(t){return new kn(t)}function bo(e,t){if(!t||!e.length)return e.slice();var n=t*t;return e=function(o,a){var t=o.length,r=new("undefined"==typeof Uint8Array?Array:Uint8Array)(t);r[0]=r[t-1]=1,function a(r,t,l,e,n){var o,d,c,u=0;for(d=e+1;d<=n-1;d++)c=me(r[d],r[e],r[n],!0),u<c&&(o=d,u=c);l<u&&(t[o]=1,a(r,t,l,e,o),a(r,t,l,o,n))}(o,r,a,0,t-1);var e,s=[];for(e=0;e<t;e++)r[e]&&s.push(o[e]);return s}(e=function(o,n){for(var t=[o[0]],a=1,r=0,l=o.length;a<l;a++)d=o[a],_=o[r],u=_.x-d.x,y=_.y-d.y,n<u*u+y*y&&(t.push(o[a]),r=a);var d,_,u,y;return r<l-1&&t.push(o[l-1]),t}(e,n),n)}function Lo(e,o,t){return Math.sqrt(me(e,o,t,!0))}function _e(t,a,r,s,e){var n,p,u,y=s?oe:pe(t,r),h=pe(a,r);for(oe=h;;){if(!(y|h))return[t,a];if(y&h)return!1;u=pe(p=de(t,a,n=y||h,r,e),r),n===y?(t=p,y=u):(a=p,h=u)}}function de(r,s,t,l,e){var n,d,p=s.x-r.x,m=s.y-r.y,a=l.min,c=l.max;return 8&t?(n=r.x+p*(c.y-r.y)/m,d=c.y):4&t?(n=r.x+p*(a.y-r.y)/m,d=a.y):2&t?(n=c.x,d=r.y+m*(c.x-r.x)/p):1&t&&(n=a.x,d=r.y+m*(a.x-r.x)/p),new y(n,d,e)}function pe(e,o){var t=0;return e.x<o.min.x?t|=1:e.x>o.max.x&&(t|=2),e.y<o.min.y?t|=4:e.y>o.max.y&&(t|=8),t}function me(o,a,t,r){var e,s=a.x,l=a.y,d=t.x-s,u=t.y-l,h=d*d+u*u;return 0<h&&(1<(e=((o.x-s)*d+(o.y-l)*u)/h)?(s=t.x,l=t.y):0<e&&(s+=d*e,l+=u*e)),d=o.x-s,u=o.y-l,r?d*d+u*u:new y(s,l)}function fe(t){return!Ao(t[0])||"object"!=typeof t[0][0]&&void 0!==t[0][0]}function ge(t){return console.warn("Deprecated use of _flat, please use L.LineUtil.isFlat instead."),fe(t)}function ve(t,o,n){var a,r,s,l,p,_,m,c,u,h=[1,4,2,8];for(r=0,m=t.length;r<m;r++)t[r]._code=pe(t[r],o);for(l=0;4>l;l++){for(c=h[l],a=[],r=0,s=(m=t.length)-1;r<m;s=r++)p=t[r],_=t[s],p._code&c?_._code&c||((u=de(_,p,c,o,n))._code=pe(u,o),a.push(u)):(_._code&c&&((u=de(_,p,c,o,n))._code=pe(u,o),a.push(u)),a.push(p));t=a}return t}function ye(e,o){var t,n,s,d,c="Feature"===e.type?e.geometry:e,y=c?c.coordinates:null,r=[],a=o&&o.pointToLayer,h=o&&o.coordsToLatLng||Fe;if(!y&&!c)return null;switch(c.type){case"Point":return we(a,e,t=h(y),o);case"MultiPoint":for(s=0,d=y.length;s<d;s++)t=h(y[s]),r.push(we(a,e,t,o));return new Se(r);case"LineString":case"MultiLineString":return n=Ue(y,"LineString"===c.type?0:1,h),new Ne(n,o);case"Polygon":case"MultiPolygon":return n=Ue(y,"Polygon"===c.type?1:2,h),new De(n,o);case"GeometryCollection":for(s=0,d=c.geometries.length;s<d;s++){var u=ye({geometry:c.geometries[s],type:"Feature",properties:e.properties},o);u&&r.push(u)}return new Se(r);default:throw new Error("Invalid GeoJSON object.");}}function we(n,o,t,a){return n?n(o,t):new Ae(t,a&&a.markersInheritOptions&&a)}function Fe(t){return new I(t[1],t[0],t[2])}function Ue(n,a,t){for(var r,s=[],l=0,d=n.length;l<d;l++)r=a?Ue(n[l],a-1,t):(t||Fe)(n[l]),s.push(r);return s}function Ve(n,e){return e="number"==typeof e?e:6,void 0===n.alt?[o(n.lng,e),o(n.lat,e)]:[o(n.lng,e),o(n.lat,e),o(n.alt,e)]}function qe(r,a,t,s){for(var e=[],n=0,l=r.length;n<l;n++)e.push(a?qe(r[n],a-1,t,s):Ve(r[n],s));return!a&&t&&e.push(e[0]),e}function Ge(o,e){return o.feature?v({},o.feature,{geometry:e}):Ke(e)}function Ke(t){return"Feature"===t.type||"FeatureCollection"===t.type?t:{type:"Feature",properties:{},geometry:t}}function Ye(o,e){return new je(o,e)}function Xe(o,e){return new an(o,e)}function $e(t){return Ct?new cn(t):null}function To(t){return Et||St?new mn(t):null}var Co=Object.freeze;Object.freeze=function(t){return t};var zo=Object.create||function(t){return P.prototype=t,new P},wo=0,So=/\{ *([\w_-]+) *\}/g,Ao=Array.isArray||function(t){return"[object Array]"===Object.prototype.toString.call(t)},f=0,Io=window.requestAnimationFrame||t("RequestAnimationFrame")||d,Eo=window.cancelAnimationFrame||t("CancelAnimationFrame")||t("CancelRequestAnimationFrame")||function(t){window.clearTimeout(t)},T=(Object.freeze||Object)({freeze:Co,extend:v,create:zo,bind:h,lastId:wo,stamp:H,throttle:a,wrapNum:V,falseFn:Y,formatNum:o,trim:r,splitWords:u,setOptions:l,getParamString:_,template:e,isArray:Ao,indexOf:m,emptyImageUrl:"data:image/gif;base64,R0lGODlhAQABAAD/ACwAAAAAAQABAAACADs=",requestFn:Io,cancelFn:Eo,requestAnimFrame:ae,cancelAnimFrame:p});c.extend=function(o){function a(){this.initialize&&this.initialize.apply(this,arguments),this.callInitHooks()}var t=a.__super__=this.prototype,r=zo(t);for(var e in(r.constructor=a).prototype=r,this)this.hasOwnProperty(e)&&"prototype"!==e&&"__super__"!==e&&(a[e]=this[e]);return o.statics&&(v(a,o.statics),delete o.statics),o.includes&&(function(t){if("undefined"!=typeof L&&L&&L.Mixin){t=Ao(t)?t:[t];for(var n=0;n<t.length;n++)t[n]===L.Mixin.Events&&console.warn("Deprecated include of L.Mixin.Events: this property will be removed in future releases, please inherit from L.Evented instead.",new Error().stack)}}(o.includes),v.apply(null,[r].concat(o.includes)),delete o.includes),r.options&&(o.options=v(zo(r.options),o.options)),v(r,o),r._initHooks=[],r.callInitHooks=function(){if(!this._initHooksCalled){t.callInitHooks&&t.callInitHooks.call(this),this._initHooksCalled=!0;for(var e=0,a=r._initHooks.length;e<a;e++)r._initHooks[e].call(this)}},a},c.include=function(t){return v(this.prototype,t),this},c.mergeOptions=function(t){return v(this.prototype.options,t),this},c.addInitHook=function(e){var o=Array.prototype.slice.call(arguments,1),t="function"==typeof e?e:function(){this[e].apply(this,o)};return this.prototype._initHooks=this.prototype._initHooks||[],this.prototype._initHooks.push(t),this};var z={on:function(t,o,r){if("object"==typeof t)for(var s in t)this._on(s,t[s],o);else for(var e=0,l=(t=u(t)).length;e<l;e++)this._on(t[e],o,r);return this},off:function(t,o,r){if(!t)delete this._events;else if("object"==typeof t)for(var s in t)this._off(s,t[s],o);else for(var e=0,l=(t=u(t)).length;e<l;e++)this._off(t[e],o,r);return this},_on:function(e,n,t){this._events=this._events||{};var a=this._events[e];a||(a=[],this._events[e]=a),t===this&&(t=void 0);for(var r={fn:n,ctx:t},l=a,o=0,_=l.length;o<_;o++)if(l[o].fn===n&&l[o].ctx===t)return;l.push(r)},_off:function(e,o,t){var n,a,r;if(this._events&&(n=this._events[e]))if(!o){for(a=0,r=n.length;a<r;a++)n[a].fn=Y;delete this._events[e]}else if(t===this&&(t=void 0),n)for(a=0,r=n.length;a<r;a++){var s=n[a];if(s.ctx===t&&s.fn===o)return s.fn=Y,this._firingCount&&(this._events[e]=n=n.slice()),void n.splice(a,1)}},fire:function(a,r,t){if(!this.listens(a,t))return this;var s=v({},r,{type:a,target:this,sourceTarget:r&&r.sourceTarget||this});if(this._events){var e=this._events[a];if(e){this._firingCount=this._firingCount+1||1;for(var n,l=0,d=e.length;l<d;l++)n=e[l],n.fn.call(n.ctx||this,s);this._firingCount--}}return t&&this._propagateEvent(s),this},listens:function(n,o){var t=this._events&&this._events[n];if(t&&t.length)return!0;if(o)for(var a in this._eventParents)if(this._eventParents[a].listens(n,o))return!0;return!1},once:function(o,a,t){if("object"==typeof o){for(var r in o)this.once(r,o[r],a);return this}var e=h(function(){this.off(o,a,t).off(o,e,t)},this);return this.on(o,a,t).on(o,e,t)},addEventParent:function(t){return this._eventParents=this._eventParents||{},this._eventParents[H(t)]=t,this},removeEventParent:function(t){return this._eventParents&&delete this._eventParents[H(t)],this},_propagateEvent:function(o){for(var e in this._eventParents)this._eventParents[e].fire(o.type,v({layer:o.target,propagatedFrom:o.target},o),!0)}};z.addEventListener=z.on,z.removeEventListener=z.clearAllEventListeners=z.off,z.addOneTimeEventListener=z.once,z.fireEvent=z.fire,z.hasEventListeners=z.listens;var E=c.extend(z),Z=Math.trunc||function(t){return 0<t?Math.floor(t):Math.ceil(t)};y.prototype={clone:function(){return new y(this.x,this.y)},add:function(t){return this.clone()._add(b(t))},_add:function(t){return this.x+=t.x,this.y+=t.y,this},subtract:function(t){return this.clone()._subtract(b(t))},_subtract:function(t){return this.x-=t.x,this.y-=t.y,this},divideBy:function(t){return this.clone()._divideBy(t)},_divideBy:function(t){return this.x/=t,this.y/=t,this},multiplyBy:function(t){return this.clone()._multiplyBy(t)},_multiplyBy:function(t){return this.x*=t,this.y*=t,this},scaleBy:function(t){return new y(this.x*t.x,this.y*t.y)},unscaleBy:function(t){return new y(this.x/t.x,this.y/t.y)},round:function(){return this.clone()._round()},_round:function(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this},floor:function(){return this.clone()._floor()},_floor:function(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this},ceil:function(){return this.clone()._ceil()},_ceil:function(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this},trunc:function(){return this.clone()._trunc()},_trunc:function(){return this.x=Z(this.x),this.y=Z(this.y),this},distanceTo:function(e){var t=(e=b(e)).x-this.x,n=e.y-this.y;return Math.sqrt(t*t+n*n)},equals:function(t){return(t=b(t)).x===this.x&&t.y===this.y},contains:function(t){return t=b(t),Math.abs(t.x)<=Math.abs(this.x)&&Math.abs(t.y)<=Math.abs(this.y)},toString:function(){return"Point("+o(this.x)+", "+o(this.y)+")"}},C.prototype={extend:function(t){return t=b(t),this.min||this.max?(this.min.x=Math.min(t.x,this.min.x),this.max.x=Math.max(t.x,this.max.x),this.min.y=Math.min(t.y,this.min.y),this.max.y=Math.max(t.y,this.max.y)):(this.min=t.clone(),this.max=t.clone()),this},getCenter:function(t){return new y((this.min.x+this.max.x)/2,(this.min.y+this.max.y)/2,t)},getBottomLeft:function(){return new y(this.min.x,this.max.y)},getTopRight:function(){return new y(this.max.x,this.min.y)},getTopLeft:function(){return this.min},getBottomRight:function(){return this.max},getSize:function(){return this.max.subtract(this.min)},contains:function(e){var t,r;return(e="number"==typeof e[0]||e instanceof y?b(e):w(e))instanceof C?(t=e.min,r=e.max):t=r=e,t.x>=this.min.x&&r.x<=this.max.x&&t.y>=this.min.y&&r.y<=this.max.y},intersects:function(t){t=w(t);var r=this.min,l=this.max,d=t.min,e=t.max,n=e.x>=r.x&&d.x<=l.x,o=e.y>=r.y&&d.y<=l.y;return n&&o},overlaps:function(t){t=w(t);var r=this.min,l=this.max,d=t.min,e=t.max,n=e.x>r.x&&d.x<l.x,o=e.y>r.y&&d.y<l.y;return n&&o},isValid:function(){return this.min&&this.max}},g.prototype={extend:function(e){var o,a,l=this._southWest,s=this._northEast;if(e instanceof I)a=o=e;else{if(!(e instanceof g))return e?this.extend(M(e)||S(e)):this;if(o=e._southWest,a=e._northEast,!o||!a)return this}return l||s?(l.lat=Math.min(o.lat,l.lat),l.lng=Math.min(o.lng,l.lng),s.lat=Math.max(a.lat,s.lat),s.lng=Math.max(a.lng,s.lng)):(this._southWest=new I(o.lat,o.lng),this._northEast=new I(a.lat,a.lng)),this},pad:function(o){var a=this._southWest,t=this._northEast,r=Math.abs(a.lat-t.lat)*o,e=Math.abs(a.lng-t.lng)*o;return new g(new I(a.lat-r,a.lng-e),new I(t.lat+r,t.lng+e))},getCenter:function(){return new I((this._southWest.lat+this._northEast.lat)/2,(this._southWest.lng+this._northEast.lng)/2)},getSouthWest:function(){return this._southWest},getNorthEast:function(){return this._northEast},getNorthWest:function(){return new I(this.getNorth(),this.getWest())},getSouthEast:function(){return new I(this.getSouth(),this.getEast())},getWest:function(){return this._southWest.lng},getSouth:function(){return this._southWest.lat},getEast:function(){return this._northEast.lng},getNorth:function(){return this._northEast.lat},contains:function(e){e="number"==typeof e[0]||e instanceof I||"lat"in e?M(e):S(e);var t,o,d=this._southWest,l=this._northEast;return e instanceof g?(t=e.getSouthWest(),o=e.getNorthEast()):t=o=e,t.lat>=d.lat&&o.lat<=l.lat&&t.lng>=d.lng&&o.lng<=l.lng},intersects:function(t){t=S(t);var r=this._southWest,l=this._northEast,d=t.getSouthWest(),e=t.getNorthEast(),n=e.lat>=r.lat&&d.lat<=l.lat,o=e.lng>=r.lng&&d.lng<=l.lng;return n&&o},overlaps:function(t){t=S(t);var r=this._southWest,l=this._northEast,d=t.getSouthWest(),e=t.getNorthEast(),n=e.lat>r.lat&&d.lat<l.lat,o=e.lng>r.lng&&d.lng<l.lng;return n&&o},toBBoxString:function(){return[this.getWest(),this.getSouth(),this.getEast(),this.getNorth()].join(",")},equals:function(t,n){return!!t&&(t=S(t),this._southWest.equals(t.getSouthWest(),n)&&this._northEast.equals(t.getNorthEast(),n))},isValid:function(){return this._southWest&&this._northEast}};var k,Zo={latLngToPoint:function(n,o){var t=this.projection.project(n),a=this.scale(o);return this.transformation._transform(t,a)},pointToLatLng:function(n,o){var t=this.scale(o),a=this.transformation.untransform(n,t);return this.projection.unproject(a)},project:function(t){return this.projection.project(t)},unproject:function(t){return this.projection.unproject(t)},scale:function(t){return 256*Math.pow(2,t)},zoom:function(t){return Math.log(t/256)/Math.LN2},getProjectedBounds:function(e){if(this.infinite)return null;var o=this.projection.bounds,t=this.scale(e);return new C(this.transformation.transform(o.min,t),this.transformation.transform(o.max,t))},infinite:!(I.prototype={equals:function(t,n){return!!t&&(t=M(t),Math.max(Math.abs(this.lat-t.lat),Math.abs(this.lng-t.lng))<=(void 0===n?1e-9:n))},toString:function(t){return"LatLng("+o(this.lat,t)+", "+o(this.lng,t)+")"},distanceTo:function(t){return Mo.distance(this,M(t))},wrap:function(){return Mo.wrapLatLng(this)},toBounds:function(e){var o=180*e/40075017,t=o/Math.cos(Math.PI/180*this.lat);return S([this.lat-o,this.lng-t],[this.lat+o,this.lng+t])},clone:function(){return new I(this.lat,this.lng,this.alt)}}),wrapLatLng:function(o){var e=this.wrapLng?V(o.lng,this.wrapLng,!0):o.lng;return new I(this.wrapLat?V(o.lat,this.wrapLat,!0):o.lat,e,o.alt)},wrapLatLngBounds:function(r){var a=r.getCenter(),t=this.wrapLatLng(a),l=a.lat-t.lat,e=a.lng-t.lng;if(0==l&&0==e)return r;var n=r.getSouthWest(),o=r.getNorthEast();return new g(new I(n.lat-l,n.lng-e),new I(o.lat-l,o.lng-e))}},Mo=v({},Zo,{wrapLng:[-180,180],R:6371e3,distance:function(p,l){var t=Math.PI/180,d=p.lat*t,e=l.lat*t,n=Math.sin((l.lat-p.lat)*t/2),o=Math.sin((l.lng-p.lng)*t/2),s=n*n+Math.cos(d)*Math.cos(e)*o*o,r=2*Math.atan2(Math.sqrt(s),Math.sqrt(1-s));return this.R*r}}),F={R:6378137,MAX_LATITUDE:85.0511287798,project:function(o){var a=Math.PI/180,t=this.MAX_LATITUDE,r=Math.max(Math.min(t,o.lat),-t),e=Math.sin(r*a);return new y(this.R*o.lng*a,this.R*Math.log((1+e)/(1-e))/2)},unproject:function(o){var e=180/Math.PI;return new I((2*Math.atan(Math.exp(o.y/this.R))-Math.PI/2)*e,o.x*e/this.R)},bounds:(k=6378137*Math.PI,new C([-k,-k],[k,k]))};B.prototype={transform:function(o,e){return this._transform(o.clone(),e)},_transform:function(o,e){return e=e||1,o.x=e*(this._a*o.x+this._b),o.y=e*(this._c*o.y+this._d),o},untransform:function(o,e){return e=e||1,new y((o.x/e-this._b)/this._a,(o.y/e-this._d)/this._c)}};var U,Bo,Oo,Ro,Do,No,jo=v({},Mo,{code:"EPSG:3857",projection:F,transformation:(U=.5/(Math.PI*F.R),O(U,.5,-U,.5))}),qo=v({},jo,{code:"EPSG:900913"}),X=document.documentElement.style,J=("ActiveXObject"in window),tt=J&&!document.addEventListener,it="msLaunchUri"in navigator&&!("documentMode"in document),et=N("webkit"),nt=N("android"),ot=N("android 2")||N("android 3"),st=parseInt(/WebKit\/([0-9]+)|$/.exec(navigator.userAgent)[1],10),rt=nt&&N("Google")&&537>st&&!("AudioNode"in window),at=!!window.opera,ht=N("chrome"),ut=N("gecko")&&!et&&!at&&!J,lt=!ht&&N("safari"),ct=N("phantom"),_t=("OTransition"in X),dt=0===navigator.platform.indexOf("Win"),pt=J&&"transition"in X,mt="WebKitCSSMatrix"in window&&"m11"in new window.WebKitCSSMatrix&&!ot,ft=("MozPerspective"in X),gt=!window.L_DISABLE_3D&&(pt||mt||ft)&&!_t&&!ct,vt="undefined"!=typeof orientation||N("mobile"),yt=!window.PointerEvent&&window.MSPointerEvent,xt=!et&&(window.PointerEvent||yt),Lt=!window.L_NO_TOUCH&&(xt||"ontouchstart"in window||window.DocumentTouch&&document instanceof window.DocumentTouch),bt=vt&&at,Tt=1<(window.devicePixelRatio||window.screen.deviceXDPI/window.screen.logicalXDPI),zt=function(){var t=!1;try{var n=Object.defineProperty({},"passive",{get:function(){t=!0}});window.addEventListener("testPassiveEventSupport",Y,n),window.removeEventListener("testPassiveEventSupport",Y,n)}catch(t){}return t},Ct=!!document.createElement("canvas").getContext,Et=document.createElementNS&&R("svg").createSVGRect,St=!Et&&function(){try{var o=document.createElement("div");o.innerHTML="<v:shape adj=\"1\"/>";var e=o.firstChild;return e.style.behavior="url(#default#VML)",e&&"object"==typeof e.adj}catch(t){return!1}}(),Zt=(Object.freeze||Object)({ie:J,ielt9:tt,edge:it,webkit:et,android:nt,android23:ot,androidStock:rt,opera:at,chrome:ht,gecko:ut,safari:lt,phantom:ct,opera12:_t,win:dt,ie3d:pt,webkit3d:mt,gecko3d:ft,any3d:gt,mobile:vt,mobileWebkit:vt&&et,mobileWebkit3d:vt&&mt,msPointer:yt,pointer:xt,touch:Lt,mobileOpera:bt,mobileGecko:vt&&ut,retina:Tt,passiveEvents:zt,canvas:Ct,svg:Et,vml:St}),kt=yt?"MSPointerDown":"pointerdown",At=yt?"MSPointerMove":"pointermove",It=yt?"MSPointerUp":"pointerup",Ot=yt?"MSPointerCancel":"pointercancel",Rt=["INPUT","SELECT","OPTION"],Nt={},Dt=!1,Cn=0,An=yt?"MSPointerDown":xt?"pointerdown":"touchstart",Ko=yt?"MSPointerUp":xt?"pointerup":"touchend",Kt=Jt(["transform","webkitTransform","OTransform","MozTransform","msTransform"]),Yt=Jt(["webkitTransition","transition","OTransition","MozTransition","msTransition"]),Yo="webkitTransition"===Yt||"OTransition"===Yt?Yt+"End":"transitionend";if("onselectstart"in document)Bo=function(){so(window,"selectstart",go)},Oo=function(){lo(window,"selectstart",go)};else{var Xo=Jt(["userSelect","WebkitUserSelect","OUserSelect","MozUserSelect","msUserSelect"]);Bo=function(){if(Xo){var t=document.documentElement.style;Ro=t[Xo],t[Xo]="none"}},Oo=function(){Xo&&(document.documentElement.style[Xo]=Ro,Ro=void 0)}}var Jo,Mn=(Object.freeze||Object)({TRANSFORM:Kt,TRANSITION:Yt,TRANSITION_END:Yo,get:Qe,getStyle:Pt,create:wt,remove:Mt,empty:Bt,toFront:Ht,toBack:Wt,hasClass:Ft,addClass:qt,removeClass:Vt,setClass:Ut,getClass:Gt,setOpacity:Xt,testProp:Jt,setTransform:Qt,setPosition:$t,getPosition:eo,disableTextSelection:Bo,enableTextSelection:Oo,disableImageDrag:to,enableImageDrag:oo,preventOutline:no,restoreOutline:ao,getSizedParentNode:io,getScale:ro}),$o=dt&&ht?2*window.devicePixelRatio:ut?window.devicePixelRatio:1,ln={},pn=(Object.freeze||Object)({on:so,off:lo,stopPropagation:mo,disableScrollPropagation:co,disableClickPropagation:uo,preventDefault:go,stop:yo,getMousePosition:ho,getWheelDelta:fo,fakeStop:vo,skipped:xo,isExternalTarget:Po,addListener:so,removeListener:lo}),yn=E.extend({run:function(n,o,t,a){this.stop(),this._el=n,this._inProgress=!0,this._duration=t||.25,this._easeOutPower=1/Math.max(a||.5,.2),this._startPos=eo(n),this._offset=o.subtract(this._startPos),this._startTime=+new Date,this.fire("start"),this._animate()},stop:function(){this._inProgress&&(this._step(!0),this._complete())},_animate:function(){this._animId=ae(this._animate,this),this._step()},_step:function(e){var o=+new Date-this._startTime,t=1e3*this._duration;o<t?this._runFrame(this._easeOut(o/t),e):(this._runFrame(1),this._complete())},_runFrame:function(e,o){var t=this._startPos.add(this._offset.multiplyBy(e));o&&t._round(),$t(this._el,t),this.fire("step")},_complete:function(){p(this._animId),this._inProgress=!1,this.fire("end")},_easeOut:function(t){return 1-Math.pow(1-t,this._easeOutPower)}}),fn=E.extend({options:{crs:jo,center:void 0,zoom:void 0,minZoom:void 0,maxZoom:void 0,layers:[],maxBounds:void 0,renderer:void 0,zoomAnimation:!0,zoomAnimationThreshold:4,fadeAnimation:!0,markerZoomAnimation:!0,transform3DLimit:8388608,zoomSnap:1,zoomDelta:1,trackResize:!0},initialize:function(o,e){e=l(this,e),this._handlers=[],this._layers={},this._zoomBoundLayers={},this._sizeChanged=!0,this._initContainer(o),this._initLayout(),this._onResize=h(this._onResize,this),this._initEvents(),e.maxBounds&&this.setMaxBounds(e.maxBounds),void 0!==e.zoom&&(this._zoom=this._limitZoom(e.zoom)),e.center&&void 0!==e.zoom&&this.setView(M(e.center),e.zoom,{reset:!0}),this.callInitHooks(),this._zoomAnimated=Yt&>&&!bt&&this.options.zoomAnimation,this._zoomAnimated&&(this._createAnimProxy(),so(this._proxy,Yo,this._catchTransitionEnd,this)),this._addLayers(this.options.layers)},setView:function(e,t,r){return(t=void 0===t?this._zoom:this._limitZoom(t),e=this._limitCenter(M(e),t,this.options.maxBounds),r=r||{},this._stop(),this._loaded&&!r.reset&&!0!==r)&&(void 0!==r.animate&&(r.zoom=v({animate:r.animate},r.zoom),r.pan=v({animate:r.animate,duration:r.duration},r.pan)),this._zoom===t?this._tryAnimatedPan(e,r.pan):this._tryAnimatedZoom&&this._tryAnimatedZoom(e,t,r.zoom))?(clearTimeout(this._sizeTimer),this):(this._resetView(e,t),this)},setZoom:function(o,e){return this._loaded?this.setView(this.getCenter(),o,{zoom:e}):(this._zoom=o,this)},zoomIn:function(t,n){return t=t||(gt?this.options.zoomDelta:1),this.setZoom(this._zoom+t,n)},zoomOut:function(t,n){return t=t||(gt?this.options.zoomDelta:1),this.setZoom(this._zoom-t,n)},setZoomAround:function(r,a,t){var l=this.getZoomScale(a),e=this.getSize().divideBy(2),n=(r instanceof y?r:this.latLngToContainerPoint(r)).subtract(e).multiplyBy(1-1/l),o=this.containerPointToLatLng(e.add(n));return this.setView(o,a,{zoom:t})},_getBoundsCenterZoom:function(t,o){o=o||{},t=t.getBounds?t.getBounds():S(t);var a=b(o.paddingTopLeft||o.padding||[0,0]),p=b(o.paddingBottomRight||o.padding||[0,0]),e=this.getBoundsZoom(t,!1,a.add(p));if((e="number"==typeof o.maxZoom?Math.min(o.maxZoom,e):e)===1/0)return{center:t.getCenter(),zoom:e};var m=p.subtract(a).divideBy(2),_=this.project(t.getSouthWest(),e),s=this.project(t.getNorthEast(),e);return{center:this.unproject(_.add(s).divideBy(2).add(m),e),zoom:e}},fitBounds:function(e,t){if(!(e=S(e)).isValid())throw new Error("Bounds are not valid.");var n=this._getBoundsCenterZoom(e,t);return this.setView(n.center,n.zoom,t)},fitWorld:function(t){return this.fitBounds([[-90,-180],[90,180]],t)},panTo:function(o,e){return this.setView(o,this._zoom,{pan:e})},panBy:function(e,t){if(t=t||{},!(e=b(e).round()).x&&!e.y)return this.fire("moveend");if(!0!==t.animate&&!this.getSize().contains(e))return this._resetView(this.unproject(this.project(this.getCenter()).add(e)),this.getZoom()),this;if(this._panAnim||(this._panAnim=new yn,this._panAnim.on({step:this._onPanTransitionStep,end:this._onPanTransitionEnd},this)),t.noMoveStart||this.fire("movestart"),!1!==t.animate){qt(this._mapPane,"leaflet-pan-anim");var r=this._getMapPanePos().subtract(e).round();this._panAnim.run(this._mapPane,r,t.duration||.25,t.easeLinearity)}else this._rawPanBy(e),this.fire("move").fire("moveend");return this},flyTo:function(y,b,t){function o(e){var o=(a*a-f*f+(e?-1:1)*l*l*h*h)/(2*(e?a:f)*l*h),t=Math.sqrt(o*o+1)-o;return 1e-9>t?-18:Math.log(t)}function n(t){return(Math.exp(t)-Math.exp(-t))/2}function T(t){return(Math.exp(t)+Math.exp(-t))/2}function e(e){return f*(T(c)*function(e){return n(e)/T(e)}(c+u*e)-n(c))/l}if(!1===(t=t||{}).animate||!gt)return this.setView(y,b,t);this._stop();var d=this.project(this.getCenter()),p=this.project(y),s=this.getSize(),r=this._zoom;y=M(y),b=void 0===b?r:b;var f=Math.max(s.x,s.y),a=f*this.getZoomScale(r,b),h=p.distanceTo(d)||1,u=1.42,l=u*u,c=o(0),_=Date.now(),m=(o(1)-c)/u,g=t.duration?1e3*t.duration:.8*(1e3*m);return this._moveStart(!0,t.noMoveStart),function a(){var o=(Date.now()-_)/g,t=function(t){return 1-Math.pow(1-t,1.5)}(o)*m;1>=o?(this._flyToFrame=ae(a,this),this._move(this.unproject(d.add(p.subtract(d).multiplyBy(e(t)/h)),r),this.getScaleZoom(f/function(t){return f*(T(c)/T(c+u*t))}(t),r),{flyTo:!0})):this._move(y,b)._moveEnd(!0)}.call(this),this},flyToBounds:function(e,o){var t=this._getBoundsCenterZoom(e,o);return this.flyTo(t.center,t.zoom,o)},setMaxBounds:function(t){return(t=S(t)).isValid()?(this.options.maxBounds&&this.off("moveend",this._panInsideMaxBounds),this.options.maxBounds=t,this._loaded&&this._panInsideMaxBounds(),this.on("moveend",this._panInsideMaxBounds)):(this.options.maxBounds=null,this.off("moveend",this._panInsideMaxBounds))},setMinZoom:function(o){var e=this.options.minZoom;return this.options.minZoom=o,this._loaded&&e!==o&&(this.fire("zoomlevelschange"),this.getZoom()<this.options.minZoom)?this.setZoom(o):this},setMaxZoom:function(o){var e=this.options.maxZoom;return this.options.maxZoom=o,this._loaded&&e!==o&&(this.fire("zoomlevelschange"),this.getZoom()>this.options.maxZoom)?this.setZoom(o):this},panInsideBounds:function(n,o){this._enforcingBounds=!0;var t=this.getCenter(),a=this._limitCenter(t,this._zoom,S(n));return t.equals(a)||this.panTo(a,o),this._enforcingBounds=!1,this},panInside:function(c,d){var u=b((d=d||{}).paddingTopLeft||d.padding||[0,0]),p=b(d.paddingBottomRight||d.padding||[0,0]),e=this.getCenter(),n=this.project(e),o=this.project(c),s=this.getPixelBounds(),r=s.getSize().divideBy(2),a=w([s.min.add(u),s.max.subtract(p)]);if(!a.contains(o)){this._enforcingBounds=!0;var _=n.subtract(o),m=b(o.x+_.x,o.y+_.y);(o.x<a.min.x||o.x>a.max.x)&&(m.x=n.x-_.x,0<_.x?m.x+=r.x-u.x:m.x-=r.x-p.x),(o.y<a.min.y||o.y>a.max.y)&&(m.y=n.y-_.y,0<_.y?m.y+=r.y-u.y:m.y-=r.y-p.y),this.panTo(this.unproject(m),d),this._enforcingBounds=!1}return this},invalidateSize:function(t){if(!this._loaded)return this;t=v({animate:!1,pan:!0},!0===t?{animate:!0}:t);var s=this.getSize();this._sizeChanged=!0,this._lastCenter=null;var r=this.getSize(),l=s.divideBy(2).round(),e=r.divideBy(2).round(),n=l.subtract(e);return n.x||n.y?(t.animate&&t.pan?this.panBy(n):(t.pan&&this._rawPanBy(n),this.fire("move"),t.debounceMoveend?(clearTimeout(this._sizeTimer),this._sizeTimer=setTimeout(h(this.fire,this,"moveend"),200)):this.fire("moveend")),this.fire("resize",{oldSize:s,newSize:r})):this},stop:function(){return this.setZoom(this._limitZoom(this._zoom)),this.options.zoomSnap||this.fire("viewreset"),this._stop()},locate:function(e){if(e=this._locateOptions=v({timeout:1e4,watch:!1},e),!("geolocation"in navigator))return this._handleGeolocationError({code:0,message:"Geolocation not supported."}),this;var t=h(this._handleGeolocationResponse,this),n=h(this._handleGeolocationError,this);return e.watch?this._locationWatchId=navigator.geolocation.watchPosition(t,n,e):navigator.geolocation.getCurrentPosition(t,n,e),this},stopLocate:function(){return navigator.geolocation&&navigator.geolocation.clearWatch&&navigator.geolocation.clearWatch(this._locationWatchId),this._locateOptions&&(this._locateOptions.setView=!1),this},_handleGeolocationError:function(e){var o=e.code,t=e.message||(1===o?"permission denied":2===o?"position unavailable":"timeout");this._locateOptions.setView&&!this._loaded&&this.fitWorld(),this.fire("locationerror",{code:o,message:"Geolocation error: "+t+"."})},_handleGeolocationResponse:function(r){var a=new I(r.coords.latitude,r.coords.longitude),t=a.toBounds(2*r.coords.accuracy),l=this._locateOptions;if(l.setView){var e=this.getBoundsZoom(t);this.setView(a,l.maxZoom?Math.min(e,l.maxZoom):e)}var n={latlng:a,bounds:t,timestamp:r.timestamp};for(var o in r.coords)"number"==typeof r.coords[o]&&(n[o]=r.coords[o]);this.fire("locationfound",n)},addHandler:function(e,o){if(!o)return this;var t=this[e]=new o(this);return this._handlers.push(t),this.options[e]&&t.enable(),this},remove:function(){if(this._initEvents(!0),this._containerId!==this._container._leaflet_id)throw new Error("Map container is being reused by another instance");try{delete this._container._leaflet_id,delete this._containerId}catch(t){this._container._leaflet_id=void 0,this._containerId=void 0}for(var t in void 0!==this._locationWatchId&&this.stopLocate(),this._stop(),Mt(this._mapPane),this._clearControlPos&&this._clearControlPos(),this._resizeRequest&&(p(this._resizeRequest),this._resizeRequest=null),this._clearHandlers(),this._loaded&&this.fire("unload"),this._layers)this._layers[t].remove();for(t in this._panes)Mt(this._panes[t]);return this._layers=[],this._panes=[],delete this._mapPane,delete this._renderer,this},createPane:function(e,o){var t=wt("div","leaflet-pane"+(e?" leaflet-"+e.replace("Pane","")+"-pane":""),o||this._mapPane);return e&&(this._panes[e]=t),t},getCenter:function(){return this._checkIfLoaded(),this._lastCenter&&!this._moved()?this._lastCenter:this.layerPointToLatLng(this._getCenterLayerPoint())},getZoom:function(){return this._zoom},getBounds:function(){var t=this.getPixelBounds();return new g(this.unproject(t.getBottomLeft()),this.unproject(t.getTopRight()))},getMinZoom:function(){return void 0===this.options.minZoom?this._layersMinZoom||0:this.options.minZoom},getMaxZoom:function(){return void 0===this.options.maxZoom?void 0===this._layersMaxZoom?1/0:this._layersMaxZoom:this.options.maxZoom},getBoundsZoom:function(e,t,n){e=S(e),n=b(n||[0,0]);var d=this.getZoom()||0,m=this.getMinZoom(),f=this.getMaxZoom(),o=e.getNorthWest(),s=e.getSouthEast(),r=this.getSize().subtract(n),a=w(this.project(s,d),this.project(o,d)).getSize(),h=gt?this.options.zoomSnap:1,u=r.x/a.x,l=r.y/a.y,c=t?Math.max(u,l):Math.min(u,l);return d=this.getScaleZoom(c,d),h&&(d=Math.round(d/(h/100))*(h/100),d=t?Math.ceil(d/h)*h:Math.floor(d/h)*h),Math.max(m,Math.min(f,d))},getSize:function(){return this._size&&!this._sizeChanged||(this._size=new y(this._container.clientWidth||0,this._container.clientHeight||0),this._sizeChanged=!1),this._size.clone()},getPixelBounds:function(e,o){var t=this._getTopLeftPoint(e,o);return new C(t,t.add(this.getSize()))},getPixelOrigin:function(){return this._checkIfLoaded(),this._pixelOrigin},getPixelWorldBounds:function(t){return this.options.crs.getProjectedBounds(void 0===t?this.getZoom():t)},getPane:function(t){return"string"==typeof t?this._panes[t]:t},getPanes:function(){return this._panes},getContainer:function(){return this._container},getZoomScale:function(e,o){var a=this.options.crs;return o=void 0===o?this._zoom:o,a.scale(e)/a.scale(o)},getScaleZoom:function(n,o){var r=this.options.crs;o=void 0===o?this._zoom:o;var a=r.zoom(n*r.scale(o));return isNaN(a)?1/0:a},project:function(o,e){return e=void 0===e?this._zoom:e,this.options.crs.latLngToPoint(M(o),e)},unproject:function(o,e){return e=void 0===e?this._zoom:e,this.options.crs.pointToLatLng(b(o),e)},layerPointToLatLng:function(o){var e=b(o).add(this.getPixelOrigin());return this.unproject(e)},latLngToLayerPoint:function(t){return this.project(M(t))._round()._subtract(this.getPixelOrigin())},wrapLatLng:function(t){return this.options.crs.wrapLatLng(M(t))},wrapLatLngBounds:function(t){return this.options.crs.wrapLatLngBounds(S(t))},distance:function(o,e){return this.options.crs.distance(M(o),M(e))},containerPointToLayerPoint:function(t){return b(t).subtract(this._getMapPanePos())},layerPointToContainerPoint:function(t){return b(t).add(this._getMapPanePos())},containerPointToLatLng:function(o){var e=this.containerPointToLayerPoint(b(o));return this.layerPointToLatLng(e)},latLngToContainerPoint:function(t){return this.layerPointToContainerPoint(this.latLngToLayerPoint(M(t)))},mouseEventToContainerPoint:function(t){return ho(t,this._container)},mouseEventToLayerPoint:function(t){return this.containerPointToLayerPoint(this.mouseEventToContainerPoint(t))},mouseEventToLatLng:function(t){return this.layerPointToLatLng(this.mouseEventToLayerPoint(t))},_initContainer:function(o){var e=this._container=Qe(o);if(!e)throw new Error("Map container not found.");if(e._leaflet_id)throw new Error("Map container is already initialized.");so(e,"scroll",this._onScroll,this),this._containerId=H(e)},_initLayout:function(){var o=this._container;this._fadeAnimated=this.options.fadeAnimation&>,qt(o,"leaflet-container"+(Lt?" leaflet-touch":"")+(Tt?" leaflet-retina":"")+(tt?" leaflet-oldie":"")+(lt?" leaflet-safari":"")+(this._fadeAnimated?" leaflet-fade-anim":""));var e=Pt(o,"position");"absolute"!==e&&"relative"!==e&&"fixed"!==e&&(o.style.position="relative"),this._initPanes(),this._initControlPos&&this._initControlPos()},_initPanes:function(){var t=this._panes={};this._paneRenderers={},this._mapPane=this.createPane("mapPane",this._container),$t(this._mapPane,new y(0,0)),this.createPane("tilePane"),this.createPane("shadowPane"),this.createPane("overlayPane"),this.createPane("markerPane"),this.createPane("tooltipPane"),this.createPane("popupPane"),this.options.markerZoomAnimation||(qt(t.markerPane,"leaflet-zoom-hide"),qt(t.shadowPane,"leaflet-zoom-hide"))},_resetView:function(n,o){$t(this._mapPane,new y(0,0));var r=!this._loaded;this._loaded=!0,o=this._limitZoom(o),this.fire("viewprereset");var a=this._zoom!==o;this._moveStart(a,!1)._move(n,o)._moveEnd(a),this.fire("viewreset"),r&&this.fire("load")},_moveStart:function(o,e){return o&&this.fire("zoomstart"),e||this.fire("movestart"),this},_move:function(n,o,r){void 0===o&&(o=this._zoom);var a=this._zoom!==o;return this._zoom=o,this._lastCenter=n,this._pixelOrigin=this._getNewPixelOrigin(n),(a||r&&r.pinch)&&this.fire("zoom",r),this.fire("move",r)},_moveEnd:function(t){return t&&this.fire("zoomend"),this.fire("moveend")},_stop:function(){return p(this._flyToFrame),this._panAnim&&this._panAnim.stop(),this},_rawPanBy:function(t){$t(this._mapPane,this._getMapPanePos().subtract(t))},_getZoomSpan:function(){return this.getMaxZoom()-this.getMinZoom()},_panInsideMaxBounds:function(){this._enforcingBounds||this.panInsideBounds(this.options.maxBounds)},_checkIfLoaded:function(){if(!this._loaded)throw new Error("Set map center and zoom first.")},_initEvents:function(o){this._targets={};var e=o?lo:so;e((this._targets[H(this._container)]=this)._container,"click dblclick mousedown mouseup mouseover mouseout mousemove contextmenu keypress keydown keyup",this._handleDOMEvent,this),this.options.trackResize&&e(window,"resize",this._onResize,this),gt&&this.options.transform3DLimit&&(o?this.off:this.on).call(this,"moveend",this._onMoveEnd)},_onResize:function(){p(this._resizeRequest),this._resizeRequest=ae(function(){this.invalidateSize({debounceMoveend:!0})},this)},_onScroll:function(){this._container.scrollTop=0,this._container.scrollLeft=0},_onMoveEnd:function(){var t=this._getMapPanePos();Math.max(Math.abs(t.x),Math.abs(t.y))>=this.options.transform3DLimit&&this._resetView(this.getCenter(),this.getZoom())},_findEventTargets:function(e,n){for(var t,a=[],r="mouseout"===n||"mouseover"===n,s=e.target||e.srcElement,l=!1;s;){if((t=this._targets[H(s)])&&("click"===n||"preclick"===n)&&!e._simulated&&this._draggableMoved(t)){l=!0;break}if(t&&t.listens(n,!0)){if(r&&!Po(s,e))break;if(a.push(t),r)break}if(s===this._container)break;s=s.parentNode}return a.length||l||r||!Po(s,e)||(a=[this]),a},_handleDOMEvent:function(o){if(this._loaded&&!xo(o)){var e=o.type;"mousedown"!==e&&"keypress"!==e&&"keyup"!==e&&"keydown"!==e||no(o.target||o.srcElement),this._fireDOMEvent(o,e)}},_mouseEvents:["click","dblclick","mouseover","mouseout","contextmenu"],_fireDOMEvent:function(e,t,a){if("click"===e.type){var l=v({},e);l.type="preclick",this._fireDOMEvent(l,l.type,a)}if(!e._stopped&&(a=(a||[]).concat(this._findEventTargets(e,t))).length){var d=a[0];"contextmenu"===t&&d.listens(t,!0)&&go(e);var n={originalEvent:e};if("keypress"!==e.type&&"keydown"!==e.type&&"keyup"!==e.type){var o=d.getLatLng&&(!d._radius||10>=d._radius);n.containerPoint=o?this.latLngToContainerPoint(d.getLatLng()):this.mouseEventToContainerPoint(e),n.layerPoint=this.containerPointToLayerPoint(n.containerPoint),n.latlng=o?d.getLatLng():this.layerPointToLatLng(n.layerPoint)}for(var s=0;s<a.length;s++)if(a[s].fire(t,n,!0),n.originalEvent._stopped||!1===a[s].options.bubblingMouseEvents&&-1!==m(this._mouseEvents,t))return}},_draggableMoved:function(t){return(t=t.dragging&&t.dragging.enabled()?t:this).dragging&&t.dragging.moved()||this.boxZoom&&this.boxZoom.moved()},_clearHandlers:function(){for(var t=0,n=this._handlers.length;t<n;t++)this._handlers[t].disable()},whenReady:function(o,e){return this._loaded?o.call(e||this,{target:this}):this.on("load",o,e),this},_getMapPanePos:function(){return eo(this._mapPane)||new y(0,0)},_moved:function(){var t=this._getMapPanePos();return t&&!t.equals([0,0])},_getTopLeftPoint:function(o,e){return(o&&void 0!==e?this._getNewPixelOrigin(o,e):this.getPixelOrigin()).subtract(this._getMapPanePos())},_getNewPixelOrigin:function(e,o){var t=this.getSize()._divideBy(2);return this.project(e,o)._subtract(t)._add(this._getMapPanePos())._round()},_latLngToNewLayerPoint:function(n,o,t){var a=this._getNewPixelOrigin(t,o);return this.project(n,o)._subtract(a)},_latLngBoundsToNewLayerBounds:function(n,o,t){var a=this._getNewPixelOrigin(t,o);return w([this.project(n.getSouthWest(),o)._subtract(a),this.project(n.getNorthWest(),o)._subtract(a),this.project(n.getSouthEast(),o)._subtract(a),this.project(n.getNorthEast(),o)._subtract(a)])},_getCenterLayerPoint:function(){return this.containerPointToLayerPoint(this.getSize()._divideBy(2))},_getCenterOffset:function(t){return this.latLngToLayerPoint(t).subtract(this._getCenterLayerPoint())},_limitCenter:function(r,a,t){if(!t)return r;var l=this.project(r,a),e=this.getSize().divideBy(2),n=new C(l.subtract(e),l.add(e)),o=this._getBoundsOffset(n,t,a);return o.round().equals([0,0])?r:this.unproject(l.add(o),a)},_limitOffset:function(n,o){if(!o)return n;var t=this.getPixelBounds(),a=new C(t.min.add(n),t.max.add(n));return n.add(this._getBoundsOffset(a,o))},_getBoundsOffset:function(s,a,t){var r=w(this.project(a.getNorthEast(),t),this.project(a.getSouthWest(),t)),e=r.min.subtract(s.min),n=r.max.subtract(s.max);return new y(this._rebound(e.x,-n.x),this._rebound(e.y,-n.y))},_rebound:function(o,e){return 0<o+e?Math.round(o-e)/2:Math.max(0,Math.ceil(o))-Math.max(0,Math.floor(e))},_limitZoom:function(t){var n=this.getMinZoom(),a=this.getMaxZoom(),r=gt?this.options.zoomSnap:1;return r&&(t=Math.round(t/r)*r),Math.max(n,Math.min(a,t))},_onPanTransitionStep:function(){this.fire("move")},_onPanTransitionEnd:function(){Vt(this._mapPane,"leaflet-pan-anim"),this.fire("moveend")},_tryAnimatedPan:function(e,o){var t=this._getCenterOffset(e)._trunc();return(!0===(o&&o.animate)||this.getSize().contains(t))&&(this.panBy(t,o),!0)},_createAnimProxy:function(){var t=this._proxy=wt("div","leaflet-proxy leaflet-zoom-animated");this._panes.mapPane.appendChild(t),this.on("zoomanim",function(e){var o=Kt,t=this._proxy.style[o];Qt(this._proxy,this.project(e.center,e.zoom),this.getZoomScale(e.zoom,1)),t===this._proxy.style[o]&&this._animatingZoom&&this._onZoomTransitionEnd()},this),this.on("load moveend",this._animMoveEnd,this),this._on("unload",this._destroyAnimProxy,this)},_destroyAnimProxy:function(){Mt(this._proxy),this.off("load moveend",this._animMoveEnd,this),delete this._proxy},_animMoveEnd:function(){var o=this.getCenter(),e=this.getZoom();Qt(this._proxy,this.project(o,e),this.getZoomScale(e,1))},_catchTransitionEnd:function(t){this._animatingZoom&&0<=t.propertyName.indexOf("transform")&&this._onZoomTransitionEnd()},_nothingToAnimate:function(){return!this._container.getElementsByClassName("leaflet-zoom-animated").length},_tryAnimatedZoom:function(e,o,t){if(this._animatingZoom)return!0;if(t=t||{},!this._zoomAnimated||!1===t.animate||this._nothingToAnimate()||Math.abs(o-this._zoom)>this.options.zoomAnimationThreshold)return!1;var a=this.getZoomScale(o),s=this._getCenterOffset(e)._divideBy(1-1/a);return(!0===t.animate||this.getSize().contains(s))&&(ae(function(){this._moveStart(!0,!1)._animateZoom(e,o,!0)},this),!0)},_animateZoom:function(n,o,t,a){this._mapPane&&(t&&(this._animatingZoom=!0,this._animateToCenter=n,this._animateToZoom=o,qt(this._mapPane,"leaflet-zoom-anim")),this.fire("zoomanim",{center:n,zoom:o,noUpdate:a}),setTimeout(h(this._onZoomTransitionEnd,this),250))},_onZoomTransitionEnd:function(){this._animatingZoom&&(this._mapPane&&Vt(this._mapPane,"leaflet-zoom-anim"),this._animatingZoom=!1,this._move(this._animateToCenter,this._animateToZoom),ae(function(){this._moveEnd(!0)},this))}}),kn=c.extend({options:{position:"topright"},initialize:function(t){l(this,t)},getPosition:function(){return this.options.position},setPosition:function(o){var e=this._map;return e&&e.removeControl(this),this.options.position=o,e&&e.addControl(this),this},getContainer:function(){return this._container},addTo:function(n){this.remove(),this._map=n;var o=this._container=this.onAdd(n),t=this.getPosition(),a=n._controlCorners[t];return qt(o,"leaflet-control"),-1===t.indexOf("bottom")?a.appendChild(o):a.insertBefore(o,a.firstChild),this._map.on("unload",this.remove,this),this},remove:function(){return this._map&&(Mt(this._container),this.onRemove&&this.onRemove(this._map),this._map.off("unload",this.remove,this),this._map=null),this},_refocusOnMap:function(t){this._map&&t&&0<t.screenX&&0<t.screenY&&this._map.getContainer().focus()}});fn.include({addControl:function(t){return t.addTo(this),this},removeControl:function(t){return t.remove(),this},_initControlPos:function(){function t(n,e){a[n+e]=wt("div","leaflet-"+n+" leaflet-"+e,o)}var a=this._controlCorners={},o=this._controlContainer=wt("div","leaflet-control-container",this._container);t("top","left"),t("top","right"),t("bottom","left"),t("bottom","right")},_clearControlPos:function(){for(var t in this._controlCorners)Mt(this._controlCorners[t]);Mt(this._controlContainer),delete this._controlCorners,delete this._controlContainer}});var Sn=kn.extend({options:{collapsed:!0,position:"topright",autoZIndex:!0,hideSingleBase:!1,sortLayers:!1,sortFunction:function(n,o,t,a){return t<a?-1:a<t?1:0}},initialize:function(n,o,t){for(var a in l(this,t),this._layerControlInputs=[],this._layers=[],this._lastZIndex=0,this._handlingClick=!1,n)this._addLayer(n[a],a);for(a in o)this._addLayer(o[a],a,!0)},onAdd:function(o){this._initLayout(),this._update(),(this._map=o).on("zoomend",this._checkDisabledLayers,this);for(var e=0;e<this._layers.length;e++)this._layers[e].layer.on("add remove",this._onLayerChange,this);return this._container},addTo:function(t){return kn.prototype.addTo.call(this,t),this._expandIfNotCollapsed()},onRemove:function(){this._map.off("zoomend",this._checkDisabledLayers,this);for(var t=0;t<this._layers.length;t++)this._layers[t].layer.off("add remove",this._onLayerChange,this)},addBaseLayer:function(o,e){return this._addLayer(o,e),this._map?this._update():this},addOverlay:function(o,e){return this._addLayer(o,e,!0),this._map?this._update():this},removeLayer:function(o){o.off("add remove",this._onLayerChange,this);var e=this._getLayer(H(o));return e&&this._layers.splice(this._layers.indexOf(e),1),this._map?this._update():this},expand:function(){qt(this._container,"leaflet-control-layers-expanded"),this._section.style.height=null;var t=this._map.getSize().y-(this._container.offsetTop+50);return t<this._section.clientHeight?(qt(this._section,"leaflet-control-layers-scrollbar"),this._section.style.height=t+"px"):Vt(this._section,"leaflet-control-layers-scrollbar"),this._checkDisabledLayers(),this},collapse:function(){return Vt(this._container,"leaflet-control-layers-expanded"),this},_initLayout:function(){var o=this._container=wt("div","leaflet-control-layers"),t=this.options.collapsed;o.setAttribute("aria-haspopup",!0),uo(o),co(o);var a=this._section=wt("section","leaflet-control-layers-list");t&&(this._map.on("click",this.collapse,this),nt||so(o,{mouseenter:this.expand,mouseleave:this.collapse},this));var e=this._layersLink=wt("a","leaflet-control-layers-toggle",o);e.href="#",e.title="Layers",Lt?(so(e,"click",yo),so(e,"click",this.expand,this)):so(e,"focus",this.expand,this),t||this.expand(),this._baseLayersList=wt("div","leaflet-control-layers-base",a),this._separator=wt("div","leaflet-control-layers-separator",a),this._overlaysList=wt("div","leaflet-control-layers-overlays",a),o.appendChild(a)},_getLayer:function(o){for(var e=0;e<this._layers.length;e++)if(this._layers[e]&&H(this._layers[e].layer)===o)return this._layers[e]},_addLayer:function(e,o,t){this._map&&e.on("add remove",this._onLayerChange,this),this._layers.push({layer:e,name:o,overlay:t}),this.options.sortLayers&&this._layers.sort(h(function(o,e){return this.options.sortFunction(o.layer,e.layer,o.name,e.name)},this)),this.options.autoZIndex&&e.setZIndex&&(this._lastZIndex++,e.setZIndex(this._lastZIndex)),this._expandIfNotCollapsed()},_update:function(){if(!this._container)return this;Bt(this._baseLayersList),Bt(this._overlaysList),this._layerControlInputs=[];var e,t,o,n,p=0;for(o=0;o<this._layers.length;o++)n=this._layers[o],this._addItem(n),t=t||n.overlay,e=e||!n.overlay,p+=n.overlay?0:1;return this.options.hideSingleBase&&(e=e&&1<p,this._baseLayersList.style.display=e?"":"none"),this._separator.style.display=t&&e?"":"none",this},_onLayerChange:function(e){this._handlingClick||this._update();var o=this._getLayer(H(e.target)),t=o.overlay?"add"===e.type?"overlayadd":"overlayremove":"add"===e.type?"baselayerchange":null;t&&this._map.fire(t,o)},_createRadioElement:function(n,o){var t="<input type=\"radio\" class=\"leaflet-control-layers-selector\" name=\""+n+"\""+(o?" checked=\"checked\"":"")+"/>",a=document.createElement("div");return a.innerHTML=t,a.firstChild},_addItem:function(a){var r,s=document.createElement("label"),l=this._map.hasLayer(a.layer);a.overlay?((r=document.createElement("input")).type="checkbox",r.className="leaflet-control-layers-selector",r.defaultChecked=l):r=this._createRadioElement("leaflet-base-layers_"+H(this),l),this._layerControlInputs.push(r),r.layerId=H(a.layer),so(r,"click",this._onInputClick,this);var e=document.createElement("span");e.innerHTML=" "+a.name;var n=document.createElement("div");return s.appendChild(n),n.appendChild(r),n.appendChild(e),(a.overlay?this._overlaysList:this._baseLayersList).appendChild(s),this._checkDisabledLayers(),s},_onInputClick:function(){var t,s,d=this._layerControlInputs,l=[],e=[];this._handlingClick=!0;for(var n=d.length-1;0<=n;n--)t=d[n],s=this._getLayer(t.layerId).layer,t.checked?l.push(s):t.checked||e.push(s);for(n=0;n<e.length;n++)this._map.hasLayer(e[n])&&this._map.removeLayer(e[n]);for(n=0;n<l.length;n++)this._map.hasLayer(l[n])||this._map.addLayer(l[n]);this._handlingClick=!1,this._refocusOnMap()},_checkDisabledLayers:function(){for(var t,o,l=this._layerControlInputs,s=this._map.getZoom(),e=l.length-1;0<=e;e--)t=l[e],o=this._getLayer(t.layerId).layer,t.disabled=void 0!==o.options.minZoom&&s<o.options.minZoom||void 0!==o.options.maxZoom&&s>o.options.maxZoom},_expandIfNotCollapsed:function(){return this._map&&!this.options.collapsed&&this.expand(),this},_expand:function(){return this.expand()},_collapse:function(){return this.collapse()}}),te=kn.extend({options:{position:"topleft",zoomInText:"+",zoomInTitle:"Zoom in",zoomOutText:"−",zoomOutTitle:"Zoom out"},onAdd:function(n){var o=wt("div","leaflet-control-zoom leaflet-bar"),t=this.options;return this._zoomInButton=this._createButton(t.zoomInText,t.zoomInTitle,"leaflet-control-zoom-in",o,this._zoomIn),this._zoomOutButton=this._createButton(t.zoomOutText,t.zoomOutTitle,"leaflet-control-zoom-out",o,this._zoomOut),this._updateDisabled(),n.on("zoomend zoomlevelschange",this._updateDisabled,this),o},onRemove:function(t){t.off("zoomend zoomlevelschange",this._updateDisabled,this)},disable:function(){return this._disabled=!0,this._updateDisabled(),this},enable:function(){return this._disabled=!1,this._updateDisabled(),this},_zoomIn:function(t){!this._disabled&&this._map._zoom<this._map.getMaxZoom()&&this._map.zoomIn(this._map.options.zoomDelta*(t.shiftKey?3:1))},_zoomOut:function(t){!this._disabled&&this._map._zoom>this._map.getMinZoom()&&this._map.zoomOut(this._map.options.zoomDelta*(t.shiftKey?3:1))},_createButton:function(s,a,t,r,e){var n=wt("a",t,r);return n.innerHTML=s,n.href="#",n.title=a,n.setAttribute("role","button"),n.setAttribute("aria-label",a),uo(n),so(n,"click",yo),so(n,"click",e,this),so(n,"click",this._refocusOnMap,this),n},_updateDisabled:function(){var t=this._map;Vt(this._zoomInButton,"leaflet-disabled"),Vt(this._zoomOutButton,"leaflet-disabled"),(this._disabled||t._zoom===t.getMinZoom())&&qt(this._zoomOutButton,"leaflet-disabled"),(this._disabled||t._zoom===t.getMaxZoom())&&qt(this._zoomInButton,"leaflet-disabled")}});fn.mergeOptions({zoomControl:!0}),fn.addInitHook(function(){this.options.zoomControl&&(this.zoomControl=new te,this.addControl(this.zoomControl))});var ie=kn.extend({options:{position:"bottomleft",maxWidth:100,metric:!0,imperial:!0},onAdd:function(n){var o=wt("div","leaflet-control-scale"),t=this.options;return this._addScales(t,"leaflet-control-scale-line",o),n.on(t.updateWhenIdle?"moveend":"move",this._update,this),n.whenReady(this._update,this),o},onRemove:function(t){t.off(this.options.updateWhenIdle?"moveend":"move",this._update,this)},_addScales:function(e,o,t){e.metric&&(this._mScale=wt("div",o,t)),e.imperial&&(this._iScale=wt("div",o,t))},_update:function(){var e=this._map,o=e.getSize().y/2,t=e.distance(e.containerPointToLatLng([0,o]),e.containerPointToLatLng([this.options.maxWidth,o]));this._updateScales(t)},_updateScales:function(t){this.options.metric&&t&&this._updateMetric(t),this.options.imperial&&t&&this._updateImperial(t)},_updateMetric:function(e){var o=this._getRoundNum(e),t=1e3>o?o+" m":o/1e3+" km";this._updateScale(this._mScale,t,o/e)},_updateImperial:function(e){var o,n,a,d=3.2808399*e;5280<d?(o=d/5280,n=this._getRoundNum(o),this._updateScale(this._iScale,n+" mi",n/o)):(a=this._getRoundNum(d),this._updateScale(this._iScale,a+" ft",a/d))},_updateScale:function(e,o,t){e.style.width=Math.round(this.options.maxWidth*t)+"px",e.innerHTML=o},_getRoundNum:function(e){var o=Math.pow(10,(Math.floor(e)+"").length-1),t=e/o;return o*(t=10<=t?10:5<=t?5:3<=t?3:2<=t?2:1)}}),ee=kn.extend({options:{position:"bottomright",prefix:"<a href=\"https://leafletjs.com\" title=\"A JS library for interactive maps\">Leaflet</a>"},initialize:function(t){l(this,t),this._attributions={}},onAdd:function(o){for(var e in(o.attributionControl=this)._container=wt("div","leaflet-control-attribution"),uo(this._container),o._layers)o._layers[e].getAttribution&&this.addAttribution(o._layers[e].getAttribution());return this._update(),this._container},setPrefix:function(t){return this.options.prefix=t,this._update(),this},addAttribution:function(t){return t&&(this._attributions[t]||(this._attributions[t]=0),this._attributions[t]++,this._update()),this},removeAttribution:function(t){return t&&this._attributions[t]&&(this._attributions[t]--,this._update()),this},_update:function(){if(this._map){var e=[];for(var o in this._attributions)this._attributions[o]&&e.push(o);var t=[];this.options.prefix&&t.push(this.options.prefix),e.length&&t.push(e.join(", ")),this._container.innerHTML=t.join(" | ")}}});fn.mergeOptions({attributionControl:!0}),fn.addInitHook(function(){this.options.attributionControl&&new ee().addTo(this)}),kn.Layers=Sn,kn.Zoom=te,kn.Scale=ie,kn.Attribution=ee,ko.layers=function(e,o,t){return new Sn(e,o,t)},ko.zoom=function(t){return new te(t)},ko.scale=function(t){return new ie(t)},ko.attribution=function(t){return new ee(t)};var ne=c.extend({initialize:function(t){this._map=t},enable:function(){return this._enabled||(this._enabled=!0,this.addHooks()),this},disable:function(){return this._enabled&&(this._enabled=!1,this.removeHooks()),this},enabled:function(){return!!this._enabled}});ne.addTo=function(o,e){return o.addHandler(e,this),this};var oe,Bn,On=Lt?"touchstart mousedown":"mousedown",En={mousedown:"mouseup",touchstart:"touchend",pointerdown:"touchend",MSPointerDown:"touchend"},he={mousedown:"mousemove",touchstart:"touchmove",pointerdown:"touchmove",MSPointerDown:"touchmove"},ue=E.extend({options:{clickTolerance:3},initialize:function(n,o,t,a){l(this,a),this._element=n,this._dragStartTarget=o||n,this._preventOutline=t},enable:function(){this._enabled||(so(this._dragStartTarget,On,this._onDown,this),this._enabled=!0)},disable:function(){this._enabled&&(ue._dragging===this&&this.finishDrag(),lo(this._dragStartTarget,On,this._onDown,this),this._enabled=!1,this._moved=!1)},_onDown:function(e){if(!e._simulated&&this._enabled&&(this._moved=!1,!Ft(this._element,"leaflet-zoom-anim")&&!(ue._dragging||e.shiftKey||1!==e.which&&1!==e.button&&!e.touches||((ue._dragging=this)._preventOutline&&no(this._element),to(),Bo(),this._moving)))){this.fire("down");var o=e.touches?e.touches[0]:e,t=io(this._element);this._startPoint=new y(o.clientX,o.clientY),this._parentScale=ro(t),so(document,he[e.type],this._onMove,this),so(document,En[e.type],this._onUp,this)}},_onMove:function(e){if(!e._simulated&&this._enabled)if(e.touches&&1<e.touches.length)this._moved=!0;else{var o=e.touches&&1===e.touches.length?e.touches[0]:e,t=new y(o.clientX,o.clientY)._subtract(this._startPoint);(t.x||t.y)&&(Math.abs(t.x)+Math.abs(t.y)<this.options.clickTolerance||(t.x/=this._parentScale.x,t.y/=this._parentScale.y,go(e),this._moved||(this.fire("dragstart"),this._moved=!0,this._startPos=eo(this._element).subtract(t),qt(document.body,"leaflet-dragging"),this._lastTarget=e.target||e.srcElement,window.SVGElementInstance&&this._lastTarget instanceof SVGElementInstance&&(this._lastTarget=this._lastTarget.correspondingUseElement),qt(this._lastTarget,"leaflet-drag-target")),this._newPos=this._startPos.add(t),this._moving=!0,p(this._animRequest),this._lastEvent=e,this._animRequest=ae(this._updatePosition,this,!0)))}},_updatePosition:function(){var t={originalEvent:this._lastEvent};this.fire("predrag",t),$t(this._element,this._newPos),this.fire("drag",t)},_onUp:function(t){!t._simulated&&this._enabled&&this.finishDrag()},finishDrag:function(){for(var t in Vt(document.body,"leaflet-dragging"),this._lastTarget&&(Vt(this._lastTarget,"leaflet-drag-target"),this._lastTarget=null),he)lo(document,he[t],this._onMove,this),lo(document,En[t],this._onUp,this);oo(),Oo(),this._moved&&this._moving&&(p(this._animRequest),this.fire("dragend",{distance:this._newPos.distanceTo(this._startPos)})),this._moving=!1,ue._dragging=!1}}),le=(Object.freeze||Object)({simplify:bo,pointToSegmentDistance:Lo,closestPointOnSegment:function(e,o,t){return me(e,o,t)},clipSegment:_e,_getEdgeIntersection:de,_getBitCode:pe,_sqClosestPointOnSegment:me,isFlat:fe,_flat:ge}),ce=(Object.freeze||Object)({clipPolygon:ve}),xe={project:function(t){return new y(t.lng,t.lat)},unproject:function(t){return new I(t.y,t.x)},bounds:new C([-180,-90],[180,90])},Le={R:6378137,R_MINOR:6356752.314245179,bounds:new C([-20037508.34279,-15496570.73972],[20037508.34279,18764656.23138]),project:function(n){var a=Math.PI/180,t=this.R,l=n.lat*a,d=this.R_MINOR/t,p=Math.sqrt(1-d*d),o=p*Math.sin(l),s=Math.tan(Math.PI/4-l/2)/Math.pow((1-o)/(1+o),p/2);return l=-t*Math.log(Math.max(s,1e-10)),new y(n.lng*a*t,l)},unproject:function(a){for(var l,m=180/Math.PI,d=this.R,e=this.R_MINOR/d,n=Math.sqrt(1-e*e),o=Math.exp(-a.y/d),s=Math.PI/2-2*Math.atan(o),c=0,u=.1;15>c&&1e-7<Math.abs(u);c++)l=n*Math.sin(s),l=Math.pow((1-l)/(1+l),n/2),s+=u=Math.PI/2-2*Math.atan(o*l)-s;return new I(s*m,a.x*m/d)}},be=(Object.freeze||Object)({LonLat:xe,Mercator:Le,SphericalMercator:F}),Te=v({},Mo,{code:"EPSG:3395",projection:Le,transformation:(Bn=.5/(Math.PI*Le.R),O(Bn,.5,-Bn,.5))}),ze=v({},Mo,{code:"EPSG:4326",projection:xe,transformation:O(1/180,1,-1/180,.5)}),Me=v({},Zo,{projection:xe,transformation:O(1,0,-1,0),scale:function(t){return Math.pow(2,t)},zoom:function(t){return Math.log(t)/Math.LN2},distance:function(n,o){var t=o.lng-n.lng,a=o.lat-n.lat;return Math.sqrt(t*t+a*a)},infinite:!0});Zo.Earth=Mo,Zo.EPSG3395=Te,Zo.EPSG3857=jo,Zo.EPSG900913=qo,Zo.EPSG4326=ze,Zo.Simple=Me;var Ce=E.extend({options:{pane:"overlayPane",attribution:null,bubblingMouseEvents:!0},addTo:function(t){return t.addLayer(this),this},remove:function(){return this.removeFrom(this._map||this._mapToAdd)},removeFrom:function(t){return t&&t.removeLayer(this),this},getPane:function(t){return this._map.getPane(t?this.options[t]||t:this.options.pane)},addInteractiveTarget:function(t){return this._map._targets[H(t)]=this},removeInteractiveTarget:function(t){return delete this._map._targets[H(t)],this},getAttribution:function(){return this.options.attribution},_layerAdd:function(e){var o=e.target;if(o.hasLayer(this)){if(this._map=o,this._zoomAnimated=o._zoomAnimated,this.getEvents){var t=this.getEvents();o.on(t,this),this.once("remove",function(){o.off(t,this)},this)}this.onAdd(o),this.getAttribution&&o.attributionControl&&o.attributionControl.addAttribution(this.getAttribution()),this.fire("add"),o.fire("layeradd",{layer:this})}}});fn.include({addLayer:function(o){if(!o._layerAdd)throw new Error("The provided object is not a Layer.");var e=H(o);return this._layers[e]||((this._layers[e]=o)._mapToAdd=this,o.beforeAdd&&o.beforeAdd(this),this.whenReady(o._layerAdd,o)),this},removeLayer:function(o){var e=H(o);return this._layers[e]&&(this._loaded&&o.onRemove(this),o.getAttribution&&this.attributionControl&&this.attributionControl.removeAttribution(o.getAttribution()),delete this._layers[e],this._loaded&&(this.fire("layerremove",{layer:o}),o.fire("remove")),o._map=o._mapToAdd=null),this},hasLayer:function(t){return!!t&&H(t)in this._layers},eachLayer:function(e,o){for(var t in this._layers)e.call(o,this._layers[t]);return this},_addLayers:function(e){for(var t=0,r=(e=e?Ao(e)?e:[e]:[]).length;t<r;t++)this.addLayer(e[t])},_addZoomLimit:function(t){!isNaN(t.options.maxZoom)&&isNaN(t.options.minZoom)||(this._zoomBoundLayers[H(t)]=t,this._updateZoomLevels())},_removeZoomLimit:function(o){var e=H(o);this._zoomBoundLayers[e]&&(delete this._zoomBoundLayers[e],this._updateZoomLevels())},_updateZoomLevels:function(){var t=1/0,o=-1/0,l=this._getZoomSpan();for(var s in this._zoomBoundLayers){var e=this._zoomBoundLayers[s].options;t=void 0===e.minZoom?t:Math.min(t,e.minZoom),o=void 0===e.maxZoom?o:Math.max(o,e.maxZoom)}this._layersMaxZoom=o===-1/0?void 0:o,this._layersMinZoom=t===1/0?void 0:t,l!==this._getZoomSpan()&&this.fire("zoomlevelschange"),void 0===this.options.maxZoom&&this._layersMaxZoom&&this.getZoom()>this._layersMaxZoom&&this.setZoom(this._layersMaxZoom),void 0===this.options.minZoom&&this._layersMinZoom&&this.getZoom()<this._layersMinZoom&&this.setZoom(this._layersMinZoom)}});var Ee=Ce.extend({initialize:function(e,o){var t,n;if(l(this,o),this._layers={},e)for(t=0,n=e.length;t<n;t++)this.addLayer(e[t])},addLayer:function(o){var e=this.getLayerId(o);return this._layers[e]=o,this._map&&this._map.addLayer(o),this},removeLayer:function(o){var e=o in this._layers?o:this.getLayerId(o);return this._map&&this._layers[e]&&this._map.removeLayer(this._layers[e]),delete this._layers[e],this},hasLayer:function(t){return!!t&&(t in this._layers||this.getLayerId(t)in this._layers)},clearLayers:function(){return this.eachLayer(this.removeLayer,this)},invoke:function(e){var o,n,s=Array.prototype.slice.call(arguments,1);for(o in this._layers)(n=this._layers[o])[e]&&n[e].apply(n,s);return this},onAdd:function(t){this.eachLayer(t.addLayer,t)},onRemove:function(t){this.eachLayer(t.removeLayer,t)},eachLayer:function(e,o){for(var t in this._layers)e.call(o,this._layers[t]);return this},getLayer:function(t){return this._layers[t]},getLayers:function(){var t=[];return this.eachLayer(t.push,t),t},setZIndex:function(t){return this.invoke("setZIndex",t)},getLayerId:function(t){return H(t)}}),Se=Ee.extend({addLayer:function(t){return this.hasLayer(t)?this:(t.addEventParent(this),Ee.prototype.addLayer.call(this,t),this.fire("layeradd",{layer:t}))},removeLayer:function(t){return this.hasLayer(t)?(t in this._layers&&(t=this._layers[t]),t.removeEventParent(this),Ee.prototype.removeLayer.call(this,t),this.fire("layerremove",{layer:t})):this},setStyle:function(t){return this.invoke("setStyle",t)},bringToFront:function(){return this.invoke("bringToFront")},bringToBack:function(){return this.invoke("bringToBack")},getBounds:function(){var e=new g;for(var o in this._layers){var t=this._layers[o];e.extend(t.getBounds?t.getBounds():t.getLatLng())}return e}}),Ze=c.extend({options:{popupAnchor:[0,0],tooltipAnchor:[0,0]},initialize:function(t){l(this,t)},createIcon:function(t){return this._createIcon("icon",t)},createShadow:function(t){return this._createIcon("shadow",t)},_createIcon:function(n,o){var t=this._getIconUrl(n);if(!t){if("icon"===n)throw new Error("iconUrl not set in Icon options (see the docs).");return null}var a=this._createImg(t,o&&"IMG"===o.tagName?o:null);return this._setIconStyles(a,n),a},_setIconStyles:function(n,a){var t=this.options,r=t[a+"Size"];"number"==typeof r&&(r=[r,r]);var s=b(r),l=b("shadow"===a&&t.shadowAnchor||t.iconAnchor||s&&s.divideBy(2,!0));n.className="leaflet-marker-"+a+" "+(t.className||""),l&&(n.style.marginLeft=-l.x+"px",n.style.marginTop=-l.y+"px"),s&&(n.style.width=s.x+"px",n.style.height=s.y+"px")},_createImg:function(o,e){return(e=e||document.createElement("img")).src=o,e},_getIconUrl:function(t){return Tt&&this.options[t+"RetinaUrl"]||this.options[t+"Url"]}}),ke=Ze.extend({options:{iconUrl:"marker-icon.png",iconRetinaUrl:"marker-icon-2x.png",shadowUrl:"marker-shadow.png",iconSize:[25,41],iconAnchor:[12,41],popupAnchor:[1,-34],tooltipAnchor:[16,-28],shadowSize:[41,41]},_getIconUrl:function(t){return ke.imagePath||(ke.imagePath=this._detectIconPath()),(this.options.imagePath||ke.imagePath)+Ze.prototype._getIconUrl.call(this,t)},_detectIconPath:function(){var o=wt("div","leaflet-default-icon-path",document.body),e=Pt(o,"background-image")||Pt(o,"backgroundImage");return document.body.removeChild(o),e=null===e||0!==e.indexOf("url")?"":e.replace(/^url\(["']?/,"").replace(/marker-icon\.png["']?\)$/,"")}}),Be=ne.extend({initialize:function(t){this._marker=t},addHooks:function(){var t=this._marker._icon;this._draggable||(this._draggable=new ue(t,t,!0)),this._draggable.on({dragstart:this._onDragStart,predrag:this._onPreDrag,drag:this._onDrag,dragend:this._onDragEnd},this).enable(),qt(t,"leaflet-marker-draggable")},removeHooks:function(){this._draggable.off({dragstart:this._onDragStart,predrag:this._onPreDrag,drag:this._onDrag,dragend:this._onDragEnd},this).disable(),this._marker._icon&&Vt(this._marker._icon,"leaflet-marker-draggable")},moved:function(){return this._draggable&&this._draggable._moved},_adjustPan:function(_){var l=this._marker,t=l._map,d=this._marker.options.autoPanSpeed,e=this._marker.options.autoPanPadding,n=eo(l._icon),o=t.getPixelBounds(),s=t.getPixelOrigin(),r=w(o.min._subtract(s).add(e),o.max._subtract(s).subtract(e));if(!r.contains(n)){var a=b((Math.max(r.max.x,n.x)-r.max.x)/(o.max.x-r.max.x)-(Math.min(r.min.x,n.x)-r.min.x)/(o.min.x-r.min.x),(Math.max(r.max.y,n.y)-r.max.y)/(o.max.y-r.max.y)-(Math.min(r.min.y,n.y)-r.min.y)/(o.min.y-r.min.y)).multiplyBy(d);t.panBy(a,{animate:!1}),this._draggable._newPos._add(a),this._draggable._startPos._add(a),$t(l._icon,this._draggable._newPos),this._onDrag(_),this._panRequest=ae(this._adjustPan.bind(this,_))}},_onDragStart:function(){this._oldLatLng=this._marker.getLatLng(),this._marker.closePopup().fire("movestart").fire("dragstart")},_onPreDrag:function(t){this._marker.options.autoPan&&(p(this._panRequest),this._panRequest=ae(this._adjustPan.bind(this,t)))},_onDrag:function(o){var a=this._marker,t=a._shadow,r=eo(a._icon),e=a._map.layerPointToLatLng(r);t&&$t(t,r),a._latlng=e,o.latlng=e,o.oldLatLng=this._oldLatLng,a.fire("move",o).fire("drag",o)},_onDragEnd:function(t){p(this._panRequest),delete this._oldLatLng,this._marker.fire("moveend").fire("dragend",t)}}),Ae=Ce.extend({options:{icon:new ke,interactive:!0,keyboard:!0,title:"",alt:"",zIndexOffset:0,opacity:1,riseOnHover:!1,riseOffset:250,pane:"markerPane",shadowPane:"shadowPane",bubblingMouseEvents:!1,draggable:!1,autoPan:!1,autoPanPadding:[50,50],autoPanSpeed:10},initialize:function(o,e){l(this,e),this._latlng=M(o)},onAdd:function(t){this._zoomAnimated=this._zoomAnimated&&t.options.markerZoomAnimation,this._zoomAnimated&&t.on("zoomanim",this._animateZoom,this),this._initIcon(),this.update()},onRemove:function(t){this.dragging&&this.dragging.enabled()&&(this.options.draggable=!0,this.dragging.removeHooks()),delete this.dragging,this._zoomAnimated&&t.off("zoomanim",this._animateZoom,this),this._removeIcon(),this._removeShadow()},getEvents:function(){return{zoom:this.update,viewreset:this.update}},getLatLng:function(){return this._latlng},setLatLng:function(o){var e=this._latlng;return this._latlng=M(o),this.update(),this.fire("move",{oldLatLng:e,latlng:this._latlng})},setZIndexOffset:function(t){return this.options.zIndexOffset=t,this.update()},getIcon:function(){return this.options.icon},setIcon:function(t){return this.options.icon=t,this._map&&(this._initIcon(),this.update()),this._popup&&this.bindPopup(this._popup,this._popup.options),this},getElement:function(){return this._icon},update:function(){if(this._icon&&this._map){var t=this._map.latLngToLayerPoint(this._latlng).round();this._setPos(t)}return this},_initIcon:function(){var n=this.options,a="leaflet-zoom-"+(this._zoomAnimated?"animated":"hide"),t=n.icon.createIcon(this._icon),r=!1;t!==this._icon&&(this._icon&&this._removeIcon(),r=!0,n.title&&(t.title=n.title),"IMG"===t.tagName&&(t.alt=n.alt||"")),qt(t,a),n.keyboard&&(t.tabIndex="0"),this._icon=t,n.riseOnHover&&this.on({mouseover:this._bringToFront,mouseout:this._resetZIndex});var s=n.icon.createShadow(this._shadow),l=!1;s!==this._shadow&&(this._removeShadow(),l=!0),s&&(qt(s,a),s.alt=""),this._shadow=s,1>n.opacity&&this._updateOpacity(),r&&this.getPane().appendChild(this._icon),this._initInteraction(),s&&l&&this.getPane(n.shadowPane).appendChild(this._shadow)},_removeIcon:function(){this.options.riseOnHover&&this.off({mouseover:this._bringToFront,mouseout:this._resetZIndex}),Mt(this._icon),this.removeInteractiveTarget(this._icon),this._icon=null},_removeShadow:function(){this._shadow&&Mt(this._shadow),this._shadow=null},_setPos:function(t){this._icon&&$t(this._icon,t),this._shadow&&$t(this._shadow,t),this._zIndex=t.y+this.options.zIndexOffset,this._resetZIndex()},_updateZIndex:function(t){this._icon&&(this._icon.style.zIndex=this._zIndex+t)},_animateZoom:function(o){var e=this._map._latLngToNewLayerPoint(this._latlng,o.zoom,o.center).round();this._setPos(e)},_initInteraction:function(){if(this.options.interactive&&(qt(this._icon,"leaflet-interactive"),this.addInteractiveTarget(this._icon),Be)){var t=this.options.draggable;this.dragging&&(t=this.dragging.enabled(),this.dragging.disable()),this.dragging=new Be(this),t&&this.dragging.enable()}},setOpacity:function(t){return this.options.opacity=t,this._map&&this._updateOpacity(),this},_updateOpacity:function(){var t=this.options.opacity;this._icon&&Xt(this._icon,t),this._shadow&&Xt(this._shadow,t)},_bringToFront:function(){this._updateZIndex(this.options.riseOffset)},_resetZIndex:function(){this._updateZIndex(0)},_getPopupAnchor:function(){return this.options.icon.options.popupAnchor},_getTooltipAnchor:function(){return this.options.icon.options.tooltipAnchor}}),Ie=Ce.extend({options:{stroke:!0,color:"#3388ff",weight:3,opacity:1,lineCap:"round",lineJoin:"round",dashArray:null,dashOffset:null,fill:!1,fillColor:null,fillOpacity:.2,fillRule:"evenodd",interactive:!0,bubblingMouseEvents:!0},beforeAdd:function(t){this._renderer=t.getRenderer(this)},onAdd:function(){this._renderer._initPath(this),this._reset(),this._renderer._addPath(this)},onRemove:function(){this._renderer._removePath(this)},redraw:function(){return this._map&&this._renderer._updatePath(this),this},setStyle:function(t){return l(this,t),this._renderer&&(this._renderer._updateStyle(this),this.options.stroke&&t&&t.hasOwnProperty("weight")&&this._updateBounds()),this},bringToFront:function(){return this._renderer&&this._renderer._bringToFront(this),this},bringToBack:function(){return this._renderer&&this._renderer._bringToBack(this),this},getElement:function(){return this._path},_reset:function(){this._project(),this._update()},_clickTolerance:function(){return(this.options.stroke?this.options.weight/2:0)+this._renderer.options.tolerance}}),Oe=Ie.extend({options:{fill:!0,radius:10},initialize:function(o,e){l(this,e),this._latlng=M(o),this._radius=this.options.radius},setLatLng:function(o){var e=this._latlng;return this._latlng=M(o),this.redraw(),this.fire("move",{oldLatLng:e,latlng:this._latlng})},getLatLng:function(){return this._latlng},setRadius:function(t){return this.options.radius=this._radius=t,this.redraw()},getRadius:function(){return this._radius},setStyle:function(o){var e=o&&o.radius||this._radius;return Ie.prototype.setStyle.call(this,o),this.setRadius(e),this},_project:function(){this._point=this._map.latLngToLayerPoint(this._latlng),this._updateBounds()},_updateBounds:function(){var n=this._radius,o=this._radiusY||n,t=this._clickTolerance(),a=[n+t,o+t];this._pxBounds=new C(this._point.subtract(a),this._point.add(a))},_update:function(){this._map&&this._updatePath()},_updatePath:function(){this._renderer._updateCircle(this)},_empty:function(){return this._radius&&!this._renderer._bounds.intersects(this._pxBounds)},_containsPoint:function(t){return t.distanceTo(this._point)<=this._radius+this._clickTolerance()}}),Re=Oe.extend({initialize:function(e,o,a){if("number"==typeof o&&(o=v({},a,{radius:o})),l(this,o),this._latlng=M(e),isNaN(this.options.radius))throw new Error("Circle radius cannot be NaN");this._mRadius=this.options.radius},setRadius:function(t){return this._mRadius=t,this.redraw()},getRadius:function(){return this._mRadius},getBounds:function(){var t=[this._radius,this._radiusY||this._radius];return new g(this._map.layerPointToLatLng(this._point.subtract(t)),this._map.layerPointToLatLng(this._point.add(t)))},setStyle:Ie.prototype.setStyle,_project:function(){var l=this._latlng.lng,d=this._latlng.lat,t=this._map,p=t.options.crs;if(p.distance===Mo.distance){var e=Math.PI/180,n=this._mRadius/Mo.R/e,o=t.project([d+n,l]),s=t.project([d-n,l]),r=o.add(s).divideBy(2),a=t.unproject(r).lat,_=Math.acos((Math.cos(n*e)-Math.sin(d*e)*Math.sin(a*e))/(Math.cos(d*e)*Math.cos(a*e)))/e;(isNaN(_)||0===_)&&(_=n/Math.cos(Math.PI/180*d)),this._point=r.subtract(t.getPixelOrigin()),this._radius=isNaN(_)?0:r.x-t.project([a,l-_]).x,this._radiusY=r.y-o.y}else{var c=p.unproject(p.project(this._latlng).subtract([this._mRadius,0]));this._point=t.latLngToLayerPoint(this._latlng),this._radius=this._point.x-t.latLngToLayerPoint(c).x}this._updateBounds()}}),Ne=Ie.extend({options:{smoothFactor:1,noClip:!1},initialize:function(o,e){l(this,e),this._setLatLngs(o)},getLatLngs:function(){return this._latlngs},setLatLngs:function(t){return this._setLatLngs(t),this.redraw()},isEmpty:function(){return!this._latlngs.length},closestLayerPoint:function(e){for(var o,n,r=1/0,l=null,d=me,c=0,u=this._parts.length;c<u;c++)for(var g,y=this._parts[c],f=1,x=y.length;f<x;f++)g=d(e,o=y[f-1],n=y[f],!0),g<r&&(r=g,l=d(e,o,n));return l&&(l.distance=Math.sqrt(r)),l},getCenter:function(){if(!this._map)throw new Error("Must add layer to map before using getCenter()");var e,t,o,n,r,s,y,h=this._rings[0],g=h.length;if(!g)return null;for(t=e=0;e<g-1;e++)t+=h[e].distanceTo(h[e+1])/2;if(0===t)return this._map.layerPointToLatLng(h[0]);for(n=e=0;e<g-1;e++)if(r=h[e],s=h[e+1],t<(n+=o=r.distanceTo(s)))return y=(n-t)/o,this._map.layerPointToLatLng([s.x-y*(s.x-r.x),s.y-y*(s.y-r.y)])},getBounds:function(){return this._bounds},addLatLng:function(t,n){return n=n||this._defaultShape(),t=M(t),n.push(t),this._bounds.extend(t),this.redraw()},_setLatLngs:function(t){this._bounds=new g,this._latlngs=this._convertLatLngs(t)},_defaultShape:function(){return fe(this._latlngs)?this._latlngs:this._latlngs[0]},_convertLatLngs:function(o){for(var n=[],t=fe(o),a=0,r=o.length;a<r;a++)t?(n[a]=M(o[a]),this._bounds.extend(n[a])):n[a]=this._convertLatLngs(o[a]);return n},_project:function(){var t=new C;this._rings=[],this._projectLatlngs(this._latlngs,this._rings,t),this._bounds.isValid()&&t.isValid()&&(this._rawPxBounds=t,this._updateBounds())},_updateBounds:function(){var o=this._clickTolerance(),e=new y(o,o);this._pxBounds=new C([this._rawPxBounds.min.subtract(e),this._rawPxBounds.max.add(e)])},_projectLatlngs:function(o,n,t){var a,r,l=o[0]instanceof I,p=o.length;if(l){for(r=[],a=0;a<p;a++)r[a]=this._map.latLngToLayerPoint(o[a]),t.extend(r[a]);n.push(r)}else for(a=0;a<p;a++)this._projectLatlngs(o[a],n,t)},_clipPoints:function(){var e=this._renderer._bounds;if(this._parts=[],this._pxBounds&&this._pxBounds.intersects(e))if(this.options.noClip)this._parts=this._rings;else{var o,n,a,r,s,l,y,h=this._parts;for(a=o=0,r=this._rings.length;o<r;o++)for(n=0,s=(y=this._rings[o]).length;n<s-1;n++)(l=_e(y[n],y[n+1],e,n,!0))&&(h[a]=h[a]||[],h[a].push(l[0]),l[1]===y[n+1]&&n!==s-2||(h[a].push(l[1]),a++))}},_simplifyPoints:function(){for(var e=this._parts,o=this.options.smoothFactor,t=0,n=e.length;t<n;t++)e[t]=bo(e[t],o)},_update:function(){this._map&&(this._clipPoints(),this._simplifyPoints(),this._updatePath())},_updatePath:function(){this._renderer._updatePoly(this)},_containsPoint:function(e,o){var t,n,a,r,s,l,y=this._clickTolerance();if(!this._pxBounds||!this._pxBounds.contains(e))return!1;for(t=0,r=this._parts.length;t<r;t++)for(n=0,a=(s=(l=this._parts[t]).length)-1;n<s;a=n++)if((o||0!==n)&&Lo(e,l[a],l[n])<=y)return!0;return!1}});Ne._flat=ge;var De=Ne.extend({options:{fill:!0},isEmpty:function(){return!this._latlngs.length||!this._latlngs[0].length},getCenter:function(){if(!this._map)throw new Error("Must add layer to map before using getCenter()");var e,t,o,n,a,r,s,l,h,P=this._rings[0],x=P.length;if(!x)return null;for(r=s=l=0,e=0,t=x-1;e<x;t=e++)o=P[e],n=P[t],a=o.y*n.x-n.y*o.x,s+=(o.x+n.x)*a,l+=(o.y+n.y)*a,r+=3*a;return h=0===r?P[0]:[s/r,l/r],this._map.layerPointToLatLng(h)},_convertLatLngs:function(e){var o=Ne.prototype._convertLatLngs.call(this,e),t=o.length;return 2<=t&&o[0]instanceof I&&o[0].equals(o[t-1])&&o.pop(),o},_setLatLngs:function(t){Ne.prototype._setLatLngs.call(this,t),fe(this._latlngs)&&(this._latlngs=[this._latlngs])},_defaultShape:function(){return fe(this._latlngs[0])?this._latlngs[0]:this._latlngs[0][0]},_clipPoints:function(){var t=this._renderer._bounds,o=this.options.weight,n=new y(o,o);if(t=new C(t.min.subtract(n),t.max.add(n)),this._parts=[],this._pxBounds&&this._pxBounds.intersects(t))if(this.options.noClip)this._parts=this._rings;else for(var r,s=0,l=this._rings.length;s<l;s++)(r=ve(this._rings[s],t,!0)).length&&this._parts.push(r)},_updatePath:function(){this._renderer._updatePoly(this,!0)},_containsPoint:function(e){var o,n,a,r,s,l,u,h,v=!1;if(!this._pxBounds||!this._pxBounds.contains(e))return!1;for(r=0,u=this._parts.length;r<u;r++)for(s=0,l=(h=(o=this._parts[r]).length)-1;s<h;l=s++)n=o[s],a=o[l],n.y>e.y!=a.y>e.y&&e.x<(a.x-n.x)*(e.y-n.y)/(a.y-n.y)+n.x&&(v=!v);return v||Ne.prototype._containsPoint.call(this,e,!0)}}),je=Se.extend({initialize:function(o,e){l(this,e),this._layers={},o&&this.addData(o)},addData:function(e){var n,a,r,_=Ao(e)?e:e.features;if(_){for(n=0,a=_.length;n<a;n++)((r=_[n]).geometries||r.geometry||r.features||r.coordinates)&&this.addData(r);return this}var p=this.options;if(p.filter&&!p.filter(e))return this;var o=ye(e,p);return o?(o.feature=Ke(e),o.defaultOptions=o.options,this.resetStyle(o),p.onEachFeature&&p.onEachFeature(e,o),this.addLayer(o)):this},resetStyle:function(t){return void 0===t?this.eachLayer(this.resetStyle,this):(t.options=v({},t.defaultOptions),this._setLayerStyle(t,this.options.style),this)},setStyle:function(t){return this.eachLayer(function(e){this._setLayerStyle(e,t)},this)},_setLayerStyle:function(o,e){o.setStyle&&("function"==typeof e&&(e=e(o.feature)),o.setStyle(e))}}),We={toGeoJSON:function(t){return Ge(this,{type:"Point",coordinates:Ve(this.getLatLng(),t)})}};Ae.include(We),Re.include(We),Oe.include(We),Ne.include({toGeoJSON:function(o){var e=!fe(this._latlngs);return Ge(this,{type:(e?"Multi":"")+"LineString",coordinates:qe(this._latlngs,e?1:0,!1,o)})}}),De.include({toGeoJSON:function(n){var o=!fe(this._latlngs),t=o&&!fe(this._latlngs[0]),a=qe(this._latlngs,t?2:o?1:0,!0,n);return o||(a=[a]),Ge(this,{type:(t?"Multi":"")+"Polygon",coordinates:a})}}),Ee.include({toMultiPoint:function(t){var o=[];return this.eachLayer(function(n){o.push(n.toGeoJSON(t).geometry.coordinates)}),Ge(this,{type:"MultiPoint",coordinates:o})},toGeoJSON:function(l){var t=this.feature&&this.feature.geometry&&this.feature.geometry.type;if("MultiPoint"===t)return this.toMultiPoint(l);var e="GeometryCollection"===t,n=[];return this.eachLayer(function(o){if(o.toGeoJSON){var a=o.toGeoJSON(l);if(e)n.push(a.geometry);else{var t=Ke(a);"FeatureCollection"===t.type?n.push.apply(n,t.features):n.push(t)}}}),e?Ge(this,{geometries:n,type:"GeometryCollection"}):{type:"FeatureCollection",features:n}}});var He=Ce.extend({options:{opacity:1,alt:"",interactive:!1,crossOrigin:!1,errorOverlayUrl:"",zIndex:1,className:""},initialize:function(e,o,t){this._url=e,this._bounds=S(o),l(this,t)},onAdd:function(){this._image||(this._initImage(),1>this.options.opacity&&this._updateOpacity()),this.options.interactive&&(qt(this._image,"leaflet-interactive"),this.addInteractiveTarget(this._image)),this.getPane().appendChild(this._image),this._reset()},onRemove:function(){Mt(this._image),this.options.interactive&&this.removeInteractiveTarget(this._image)},setOpacity:function(t){return this.options.opacity=t,this._image&&this._updateOpacity(),this},setStyle:function(t){return t.opacity&&this.setOpacity(t.opacity),this},bringToFront:function(){return this._map&&Ht(this._image),this},bringToBack:function(){return this._map&&Wt(this._image),this},setUrl:function(t){return this._url=t,this._image&&(this._image.src=t),this},setBounds:function(t){return this._bounds=S(t),this._map&&this._reset(),this},getEvents:function(){var t={zoom:this._reset,viewreset:this._reset};return this._zoomAnimated&&(t.zoomanim=this._animateZoom),t},setZIndex:function(t){return this.options.zIndex=t,this._updateZIndex(),this},getBounds:function(){return this._bounds},getElement:function(){return this._image},_initImage:function(){var o="IMG"===this._url.tagName,e=this._image=o?this._url:wt("img");qt(e,"leaflet-image-layer"),this._zoomAnimated&&qt(e,"leaflet-zoom-animated"),this.options.className&&qt(e,this.options.className),e.onselectstart=Y,e.onmousemove=Y,e.onload=h(this.fire,this,"load"),e.onerror=h(this._overlayOnError,this,"error"),(this.options.crossOrigin||""===this.options.crossOrigin)&&(e.crossOrigin=!0===this.options.crossOrigin?"":this.options.crossOrigin),this.options.zIndex&&this._updateZIndex(),o?this._url=e.src:(e.src=this._url,e.alt=this.options.alt)},_animateZoom:function(e){var o=this._map.getZoomScale(e.zoom),t=this._map._latLngBoundsToNewLayerBounds(this._bounds,e.zoom,e.center).min;Qt(this._image,t,o)},_reset:function(){var e=this._image,o=new C(this._map.latLngToLayerPoint(this._bounds.getNorthWest()),this._map.latLngToLayerPoint(this._bounds.getSouthEast())),t=o.getSize();$t(e,o.min),e.style.width=t.x+"px",e.style.height=t.y+"px"},_updateOpacity:function(){Xt(this._image,this.options.opacity)},_updateZIndex:function(){this._image&&void 0!==this.options.zIndex&&null!==this.options.zIndex&&(this._image.style.zIndex=this.options.zIndex)},_overlayOnError:function(){this.fire("error");var t=this.options.errorOverlayUrl;t&&this._url!==t&&(this._url=t,this._image.src=t)}}),Je=He.extend({options:{autoplay:!0,loop:!0,keepAspectRatio:!0},_initImage:function(){var o="VIDEO"===this._url.tagName,a=this._image=o?this._url:wt("video");if(qt(a,"leaflet-image-layer"),this._zoomAnimated&&qt(a,"leaflet-zoom-animated"),this.options.className&&qt(a,this.options.className),a.onselectstart=Y,a.onmousemove=Y,a.onloadeddata=h(this.fire,this,"load"),o){for(var t=a.getElementsByTagName("source"),r=[],e=0;e<t.length;e++)r.push(t[e].src);this._url=0<t.length?r:[a.src]}else{Ao(this._url)||(this._url=[this._url]),!this.options.keepAspectRatio&&a.style.hasOwnProperty("objectFit")&&(a.style.objectFit="fill"),a.autoplay=!!this.options.autoplay,a.loop=!!this.options.loop;for(var s,l=0;l<this._url.length;l++)s=wt("source"),s.src=this._url[l],a.appendChild(s)}}}),tn=He.extend({_initImage:function(){var t=this._image=this._url;qt(t,"leaflet-image-layer"),this._zoomAnimated&&qt(t,"leaflet-zoom-animated"),this.options.className&&qt(t,this.options.className),t.onselectstart=Y,t.onmousemove=Y}}),en=Ce.extend({options:{offset:[0,7],className:"",pane:"popupPane"},initialize:function(o,e){l(this,o),this._source=e},onAdd:function(t){this._zoomAnimated=t._zoomAnimated,this._container||this._initLayout(),t._fadeAnimated&&Xt(this._container,0),clearTimeout(this._removeTimeout),this.getPane().appendChild(this._container),this.update(),t._fadeAnimated&&Xt(this._container,1),this.bringToFront()},onRemove:function(t){t._fadeAnimated?(Xt(this._container,0),this._removeTimeout=setTimeout(h(Mt,void 0,this._container),200)):Mt(this._container)},getLatLng:function(){return this._latlng},setLatLng:function(t){return this._latlng=M(t),this._map&&(this._updatePosition(),this._adjustPan()),this},getContent:function(){return this._content},setContent:function(t){return this._content=t,this.update(),this},getElement:function(){return this._container},update:function(){this._map&&(this._container.style.visibility="hidden",this._updateContent(),this._updateLayout(),this._updatePosition(),this._container.style.visibility="",this._adjustPan())},getEvents:function(){var t={zoom:this._updatePosition,viewreset:this._updatePosition};return this._zoomAnimated&&(t.zoomanim=this._animateZoom),t},isOpen:function(){return!!this._map&&this._map.hasLayer(this)},bringToFront:function(){return this._map&&Ht(this._container),this},bringToBack:function(){return this._map&&Wt(this._container),this},_prepareOpen:function(e,o,n){if(o instanceof Ce||(n=o,o=e),o instanceof Se)for(var s in e._layers){o=e._layers[s];break}if(!n)if(o.getCenter)n=o.getCenter();else{if(!o.getLatLng)throw new Error("Unable to get source layer LatLng.");n=o.getLatLng()}return this._source=o,this.update(),n},_updateContent:function(){if(this._content){var o=this._contentNode,e="function"==typeof this._content?this._content(this._source||this):this._content;if("string"==typeof e)o.innerHTML=e;else{for(;o.hasChildNodes();)o.removeChild(o.firstChild);o.appendChild(e)}this.fire("contentupdate")}},_updatePosition:function(){if(this._map){var o=this._map.latLngToLayerPoint(this._latlng),a=b(this.options.offset),s=this._getAnchor();this._zoomAnimated?$t(this._container,o.add(s)):a=a.add(o).add(s);var r=this._containerBottom=-a.y,e=this._containerLeft=-Math.round(this._containerWidth/2)+a.x;this._container.style.bottom=r+"px",this._container.style.left=e+"px"}},_getAnchor:function(){return[0,0]}}),nn=en.extend({options:{maxWidth:300,minWidth:50,maxHeight:null,autoPan:!0,autoPanPaddingTopLeft:null,autoPanPaddingBottomRight:null,autoPanPadding:[5,5],keepInView:!1,closeButton:!0,autoClose:!0,closeOnEscapeKey:!0,className:""},openOn:function(t){return t.openPopup(this),this},onAdd:function(t){en.prototype.onAdd.call(this,t),t.fire("popupopen",{popup:this}),this._source&&(this._source.fire("popupopen",{popup:this},!0),this._source instanceof Ie||this._source.on("preclick",mo))},onRemove:function(t){en.prototype.onRemove.call(this,t),t.fire("popupclose",{popup:this}),this._source&&(this._source.fire("popupclose",{popup:this},!0),this._source instanceof Ie||this._source.off("preclick",mo))},getEvents:function(){var t=en.prototype.getEvents.call(this);return(void 0===this.options.closeOnClick?this._map.options.closePopupOnClick:this.options.closeOnClick)&&(t.preclick=this._close),this.options.keepInView&&(t.moveend=this._adjustPan),t},_close:function(){this._map&&this._map.closePopup(this)},_initLayout:function(){var n=this._container=wt("div","leaflet-popup "+(this.options.className||"")+" leaflet-zoom-animated"),t=this._wrapper=wt("div","leaflet-popup-content-wrapper",n);if(this._contentNode=wt("div","leaflet-popup-content",t),uo(t),co(this._contentNode),so(t,"contextmenu",mo),this._tipContainer=wt("div","leaflet-popup-tip-container",n),this._tip=wt("div","leaflet-popup-tip",this._tipContainer),this.options.closeButton){var o=this._closeButton=wt("a","leaflet-popup-close-button",n);o.href="#close",o.innerHTML="×",so(o,"click",this._onCloseButtonClick,this)}},_updateLayout:function(){var e=this._contentNode,o=e.style;o.width="",o.whiteSpace="nowrap";var t=e.offsetWidth;t=Math.min(t,this.options.maxWidth),t=Math.max(t,this.options.minWidth),o.width=t+1+"px",o.whiteSpace="",o.height="";var a=e.offsetHeight,s=this.options.maxHeight;s&&s<a?(o.height=s+"px",qt(e,"leaflet-popup-scrolled")):Vt(e,"leaflet-popup-scrolled"),this._containerWidth=this._container.offsetWidth},_animateZoom:function(e){var o=this._map._latLngToNewLayerPoint(this._latlng,e.zoom,e.center),t=this._getAnchor();$t(this._container,o.add(t))},_adjustPan:function(){if(this.options.autoPan){this._map._panAnim&&this._map._panAnim.stop();var l=this._map,d=parseInt(Pt(this._container,"marginBottom"),10)||0,t=this._container.offsetHeight+d,p=this._containerWidth,e=new y(this._containerLeft,-t-this._containerBottom);e._add(eo(this._container));var n=l.layerPointToContainerPoint(e),o=b(this.options.autoPanPadding),s=b(this.options.autoPanPaddingTopLeft||o),r=b(this.options.autoPanPaddingBottomRight||o),a=l.getSize(),_=0,c=0;n.x+p+r.x>a.x&&(_=n.x+p-a.x+r.x),0>n.x-_-s.x&&(_=n.x-s.x),n.y+t+r.y>a.y&&(c=n.y+t-a.y+r.y),0>n.y-c-s.y&&(c=n.y-s.y),(_||c)&&l.fire("autopanstart").panBy([_,c])}},_onCloseButtonClick:function(t){this._close(),yo(t)},_getAnchor:function(){return b(this._source&&this._source._getPopupAnchor?this._source._getPopupAnchor():[0,0])}});fn.mergeOptions({closePopupOnClick:!0}),fn.include({openPopup:function(e,t,n){return e instanceof nn||(e=new nn(n).setContent(e)),t&&e.setLatLng(t),this.hasLayer(e)?this:(this._popup&&this._popup.options.autoClose&&this.closePopup(),this._popup=e,this.addLayer(e))},closePopup:function(t){return t&&t!==this._popup||(t=this._popup,this._popup=null),t&&this.removeLayer(t),this}}),Ce.include({bindPopup:function(o,e){return o instanceof nn?(l(o,e),(this._popup=o)._source=this):(this._popup&&!e||(this._popup=new nn(e,this)),this._popup.setContent(o)),this._popupHandlersAdded||(this.on({click:this._openPopup,keypress:this._onKeyPress,remove:this.closePopup,move:this._movePopup}),this._popupHandlersAdded=!0),this},unbindPopup:function(){return this._popup&&(this.off({click:this._openPopup,keypress:this._onKeyPress,remove:this.closePopup,move:this._movePopup}),this._popupHandlersAdded=!1,this._popup=null),this},openPopup:function(o,e){return this._popup&&this._map&&(e=this._popup._prepareOpen(this,o,e),this._map.openPopup(this._popup,e)),this},closePopup:function(){return this._popup&&this._popup._close(),this},togglePopup:function(t){return this._popup&&(this._popup._map?this.closePopup():this.openPopup(t)),this},isPopupOpen:function(){return!!this._popup&&this._popup.isOpen()},setPopupContent:function(t){return this._popup&&this._popup.setContent(t),this},getPopup:function(){return this._popup},_openPopup:function(o){var e=o.layer||o.target;this._popup&&this._map&&(yo(o),e instanceof Ie?this.openPopup(o.layer||o.target,o.latlng):this._map.hasLayer(this._popup)&&this._popup._source===e?this.closePopup():this.openPopup(e,o.latlng))},_movePopup:function(t){this._popup.setLatLng(t.latlng)},_onKeyPress:function(t){13===t.originalEvent.keyCode&&this._openPopup(t)}});var on=en.extend({options:{pane:"tooltipPane",offset:[0,0],direction:"auto",permanent:!1,sticky:!1,interactive:!1,opacity:.9},onAdd:function(t){en.prototype.onAdd.call(this,t),this.setOpacity(this.options.opacity),t.fire("tooltipopen",{tooltip:this}),this._source&&this._source.fire("tooltipopen",{tooltip:this},!0)},onRemove:function(t){en.prototype.onRemove.call(this,t),t.fire("tooltipclose",{tooltip:this}),this._source&&this._source.fire("tooltipclose",{tooltip:this},!0)},getEvents:function(){var t=en.prototype.getEvents.call(this);return Lt&&!this.options.permanent&&(t.preclick=this._close),t},_close:function(){this._map&&this._map.closeTooltip(this)},_initLayout:function(){var t="leaflet-tooltip "+(this.options.className||"")+" leaflet-zoom-"+(this._zoomAnimated?"animated":"hide");this._contentNode=this._container=wt("div",t)},_updateLayout:function(){},_adjustPan:function(){},_setPosition:function(t){var s=this._map,d=this._container,p=s.latLngToContainerPoint(s.getCenter()),e=s.layerPointToContainerPoint(t),n=this.options.direction,c=d.offsetWidth,_=d.offsetHeight,r=b(this.options.offset),a=this._getAnchor();t="top"===n?t.add(b(-c/2+r.x,-_+r.y+a.y,!0)):"bottom"===n?t.subtract(b(c/2-r.x,-r.y,!0)):"center"===n?t.subtract(b(c/2+r.x,_/2-a.y+r.y,!0)):"right"===n||"auto"===n&&e.x<p.x?(n="right",t.add(b(r.x+a.x,a.y-_/2+r.y,!0))):(n="left",t.subtract(b(c+a.x-r.x,_/2-a.y-r.y,!0))),Vt(d,"leaflet-tooltip-right"),Vt(d,"leaflet-tooltip-left"),Vt(d,"leaflet-tooltip-top"),Vt(d,"leaflet-tooltip-bottom"),qt(d,"leaflet-tooltip-"+n),$t(d,t)},_updatePosition:function(){var t=this._map.latLngToLayerPoint(this._latlng);this._setPosition(t)},setOpacity:function(t){this.options.opacity=t,this._container&&Xt(this._container,t)},_animateZoom:function(o){var e=this._map._latLngToNewLayerPoint(this._latlng,o.zoom,o.center);this._setPosition(e)},_getAnchor:function(){return b(this._source&&this._source._getTooltipAnchor&&!this.options.sticky?this._source._getTooltipAnchor():[0,0])}});fn.include({openTooltip:function(e,t,n){return e instanceof on||(e=new on(n).setContent(e)),t&&e.setLatLng(t),this.hasLayer(e)?this:this.addLayer(e)},closeTooltip:function(t){return t&&this.removeLayer(t),this}}),Ce.include({bindTooltip:function(o,e){return o instanceof on?(l(o,e),(this._tooltip=o)._source=this):(this._tooltip&&!e||(this._tooltip=new on(e,this)),this._tooltip.setContent(o)),this._initTooltipInteractions(),this._tooltip.options.permanent&&this._map&&this._map.hasLayer(this)&&this.openTooltip(),this},unbindTooltip:function(){return this._tooltip&&(this._initTooltipInteractions(!0),this.closeTooltip(),this._tooltip=null),this},_initTooltipInteractions:function(e){if(e||!this._tooltipHandlersAdded){var o=e?"off":"on",t={remove:this.closeTooltip,move:this._moveTooltip};this._tooltip.options.permanent?t.add=this._openTooltip:(t.mouseover=this._openTooltip,t.mouseout=this.closeTooltip,this._tooltip.options.sticky&&(t.mousemove=this._moveTooltip),Lt&&(t.click=this._openTooltip)),this[o](t),this._tooltipHandlersAdded=!e}},openTooltip:function(o,e){return this._tooltip&&this._map&&(e=this._tooltip._prepareOpen(this,o,e),this._map.openTooltip(this._tooltip,e),this._tooltip.options.interactive&&this._tooltip._container&&(qt(this._tooltip._container,"leaflet-clickable"),this.addInteractiveTarget(this._tooltip._container))),this},closeTooltip:function(){return this._tooltip&&(this._tooltip._close(),this._tooltip.options.interactive&&this._tooltip._container&&(Vt(this._tooltip._container,"leaflet-clickable"),this.removeInteractiveTarget(this._tooltip._container))),this},toggleTooltip:function(t){return this._tooltip&&(this._tooltip._map?this.closeTooltip():this.openTooltip(t)),this},isTooltipOpen:function(){return this._tooltip.isOpen()},setTooltipContent:function(t){return this._tooltip&&this._tooltip.setContent(t),this},getTooltip:function(){return this._tooltip},_openTooltip:function(o){var e=o.layer||o.target;this._tooltip&&this._map&&this.openTooltip(e,this._tooltip.options.sticky?o.latlng:void 0)},_moveTooltip:function(e){var o,n,s=e.latlng;this._tooltip.options.sticky&&e.originalEvent&&(o=this._map.mouseEventToContainerPoint(e.originalEvent),n=this._map.containerPointToLayerPoint(o),s=this._map.layerPointToLatLng(n)),this._tooltip.setLatLng(s)}});var sn=Ze.extend({options:{iconSize:[12,12],html:!1,bgPos:null,className:"leaflet-div-icon"},createIcon:function(n){var o=n&&"DIV"===n.tagName?n:document.createElement("div"),t=this.options;if(t.html instanceof Element?(Bt(o),o.appendChild(t.html)):o.innerHTML=!1===t.html?"":t.html,t.bgPos){var a=b(t.bgPos);o.style.backgroundPosition=-a.x+"px "+-a.y+"px"}return this._setIconStyles(o,"icon"),o},createShadow:function(){return null}});Ze.Default=ke;var rn=Ce.extend({options:{tileSize:256,opacity:1,updateWhenIdle:vt,updateWhenZooming:!0,updateInterval:200,zIndex:1,bounds:null,minZoom:0,maxZoom:void 0,maxNativeZoom:void 0,minNativeZoom:void 0,noWrap:!1,pane:"tilePane",className:"",keepBuffer:2},initialize:function(t){l(this,t)},onAdd:function(){this._initContainer(),this._levels={},this._tiles={},this._resetView(),this._update()},beforeAdd:function(t){t._addZoomLimit(this)},onRemove:function(t){this._removeAllTiles(),Mt(this._container),t._removeZoomLimit(this),this._container=null,this._tileZoom=void 0},bringToFront:function(){return this._map&&(Ht(this._container),this._setAutoZIndex(Math.max)),this},bringToBack:function(){return this._map&&(Wt(this._container),this._setAutoZIndex(Math.min)),this},getContainer:function(){return this._container},setOpacity:function(t){return this.options.opacity=t,this._updateOpacity(),this},setZIndex:function(t){return this.options.zIndex=t,this._updateZIndex(),this},isLoading:function(){return this._loading},redraw:function(){return this._map&&(this._removeAllTiles(),this._update()),this},getEvents:function(){var e={viewprereset:this._invalidateAll,viewreset:this._resetView,zoom:this._resetView,moveend:this._onMoveEnd};return this.options.updateWhenIdle||(this._onMove||(this._onMove=a(this._onMoveEnd,this.options.updateInterval,this)),e.move=this._onMove),this._zoomAnimated&&(e.zoomanim=this._animateZoom),e},createTile:function(){return document.createElement("div")},getTileSize:function(){var t=this.options.tileSize;return t instanceof y?t:new y(t,t)},_updateZIndex:function(){this._container&&void 0!==this.options.zIndex&&null!==this.options.zIndex&&(this._container.style.zIndex=this.options.zIndex)},_setAutoZIndex:function(o){for(var n,a=this.getPane().children,r=-o(-1/0,1/0),s=0,p=a.length;s<p;s++)n=a[s].style.zIndex,a[s]!==this._container&&n&&(r=o(r,+n));isFinite(r)&&(this.options.zIndex=r+o(-1,1),this._updateZIndex())},_updateOpacity:function(){if(this._map&&!tt){Xt(this._container,this.options.opacity);var e=+new Date,a=!1,s=!1;for(var d in this._tiles){var l=this._tiles[d];if(l.current&&l.loaded){var n=Math.min(1,(e-l.loaded)/200);Xt(l.el,n),1>n?a=!0:(l.active?s=!0:this._onOpaqueTile(l),l.active=!0)}}s&&!this._noPrune&&this._pruneTiles(),a&&(p(this._fadeFrame),this._fadeFrame=ae(this._updateOpacity,this))}},_onOpaqueTile:Y,_initContainer:function(){this._container||(this._container=wt("div","leaflet-layer "+(this.options.className||"")),this._updateZIndex(),1>this.options.opacity&&this._updateOpacity(),this.getPane().appendChild(this._container))},_updateLevels:function(){var o=this._tileZoom,n=this.options.maxZoom;if(void 0!==o){for(var t in this._levels)this._levels[t].el.children.length||t===o?(this._levels[t].el.style.zIndex=n-Math.abs(o-t),this._onUpdateLevel(t)):(Mt(this._levels[t].el),this._removeTilesAtZoom(t),this._onRemoveLevel(t),delete this._levels[t]);var a=this._levels[o],r=this._map;return a||((a=this._levels[o]={}).el=wt("div","leaflet-tile-container leaflet-zoom-animated",this._container),a.el.style.zIndex=n,a.origin=r.project(r.unproject(r.getPixelOrigin()),o).round(),a.zoom=o,this._setZoomTransform(a,r.getCenter(),r.getZoom()),a.el.offsetWidth,this._onCreateLevel(a)),this._level=a}},_onUpdateLevel:Y,_onRemoveLevel:Y,_onCreateLevel:Y,_pruneTiles:function(){if(this._map){var t,n,s=this._map.getZoom();if(s>this.options.maxZoom||s<this.options.minZoom)this._removeAllTiles();else{for(t in this._tiles)(n=this._tiles[t]).retain=n.current;for(t in this._tiles)if((n=this._tiles[t]).current&&!n.active){var r=n.coords;this._retainParent(r.x,r.y,r.z,r.z-5)||this._retainChildren(r.x,r.y,r.z,r.z+2)}for(t in this._tiles)this._tiles[t].retain||this._removeTile(t)}}},_removeTilesAtZoom:function(o){for(var e in this._tiles)this._tiles[e].coords.z===o&&this._removeTile(e)},_removeAllTiles:function(){for(var t in this._tiles)this._removeTile(t)},_invalidateAll:function(){for(var t in this._levels)Mt(this._levels[t].el),this._onRemoveLevel(t),delete this._levels[t];this._removeAllTiles(),this._tileZoom=void 0},_retainParent:function(_,l,t,d){var e=Math.floor(_/2),n=Math.floor(l/2),o=t-1,s=new y(+e,+n);s.z=+o;var r=this._tileCoordsToKey(s),a=this._tiles[r];return a&&a.active?a.retain=!0:(a&&a.loaded&&(a.retain=!0),d<o&&this._retainParent(e,n,o,d))},_retainChildren:function(o,r,t,s){for(var e=2*o;e<2*o+2;e++)for(var l,d=2*r;d<2*r+2;d++){l=new y(e,d),l.z=t+1;var c=this._tileCoordsToKey(l),m=this._tiles[c];m&&m.active?m.retain=!0:(m&&m.loaded&&(m.retain=!0),t+1<s&&this._retainChildren(e,d,t+1,s))}},_resetView:function(o){var e=o&&(o.pinch||o.flyTo);this._setView(this._map.getCenter(),this._map.getZoom(),e,e)},_animateZoom:function(t){this._setView(t.center,t.zoom,!0,t.noUpdate)},_clampZoom:function(o){var e=this.options;return void 0!==e.minNativeZoom&&o<e.minNativeZoom?e.minNativeZoom:void 0!==e.maxNativeZoom&&e.maxNativeZoom<o?e.maxNativeZoom:o},_setView:function(o,a,t,r){var e=this._clampZoom(Math.round(a));(void 0!==this.options.maxZoom&&e>this.options.maxZoom||void 0!==this.options.minZoom&&e<this.options.minZoom)&&(e=void 0);var s=this.options.updateWhenZooming&&e!==this._tileZoom;r&&!s||(this._tileZoom=e,this._abortLoading&&this._abortLoading(),this._updateLevels(),this._resetGrid(),void 0!==e&&this._update(o),t||this._pruneTiles(),this._noPrune=!!t),this._setZoomTransforms(o,a)},_setZoomTransforms:function(e,o){for(var t in this._levels)this._setZoomTransform(this._levels[t],e,o)},_setZoomTransform:function(o,a,t){var r=this._map.getZoomScale(t,o.zoom),e=o.origin.multiplyBy(r).subtract(this._map._getNewPixelOrigin(a,t)).round();gt?Qt(o.el,e,r):$t(o.el,e)},_resetGrid:function(){var o=this._map,a=o.options.crs,t=this._tileSize=this.getTileSize(),r=this._tileZoom,e=this._map.getPixelWorldBounds(this._tileZoom);e&&(this._globalTileRange=this._pxBoundsToTileRange(e)),this._wrapX=a.wrapLng&&!this.options.noWrap&&[Math.floor(o.project([0,a.wrapLng[0]],r).x/t.x),Math.ceil(o.project([0,a.wrapLng[1]],r).x/t.y)],this._wrapY=a.wrapLat&&!this.options.noWrap&&[Math.floor(o.project([a.wrapLat[0],0],r).y/t.x),Math.ceil(o.project([a.wrapLat[1],0],r).y/t.y)]},_onMoveEnd:function(){this._map&&!this._map._animatingZoom&&this._update()},_getTiledPixelBounds:function(s){var a=this._map,t=a._animatingZoom?Math.max(a._animateToZoom,a.getZoom()):a.getZoom(),r=a.getZoomScale(t,this._tileZoom),e=a.project(s,this._tileZoom).floor(),n=a.getSize().divideBy(2*r);return new C(e.subtract(n),e.add(n))},_update:function(t){var d=this._map;if(d){var _=this._clampZoom(d.getZoom());if(void 0===t&&(t=d.getCenter()),void 0!==this._tileZoom){var m=this._getTiledPixelBounds(t),e=this._pxBoundsToTileRange(m),n=e.getCenter(),o=[],s=this.options.keepBuffer,r=new C(e.getBottomLeft().subtract([s,-s]),e.getTopRight().add([s,-s]));if(!(isFinite(e.min.x)&&isFinite(e.min.y)&&isFinite(e.max.x)&&isFinite(e.max.y)))throw new Error("Attempted to load an infinite number of tiles");for(var a in this._tiles){var c=this._tiles[a].coords;c.z===this._tileZoom&&r.contains(new y(c.x,c.y))||(this._tiles[a].current=!1)}if(1<Math.abs(_-this._tileZoom))this._setView(t,_);else{for(var u=e.min.y;u<=e.max.y;u++)for(var h,f=e.min.x;f<=e.max.x;f++)if(h=new y(f,u),h.z=this._tileZoom,this._isValidTile(h)){var k=this._tiles[this._tileCoordsToKey(h)];k?k.current=!0:o.push(h)}if(o.sort(function(o,e){return o.distanceTo(n)-e.distanceTo(n)}),0!==o.length){this._loading||(this._loading=!0,this.fire("loading"));var P=document.createDocumentFragment();for(f=0;f<o.length;f++)this._addTile(o[f],P);this._level.el.appendChild(P)}}}}},_isValidTile:function(n){var o=this._map.options.crs;if(!o.infinite){var t=this._globalTileRange;if(!o.wrapLng&&(n.x<t.min.x||n.x>t.max.x)||!o.wrapLat&&(n.y<t.min.y||n.y>t.max.y))return!1}if(!this.options.bounds)return!0;var a=this._tileCoordsToBounds(n);return S(this.options.bounds).overlaps(a)},_keyToBounds:function(t){return this._tileCoordsToBounds(this._keyToTileCoords(t))},_tileCoordsToNwSe:function(o){var a=this._map,t=this.getTileSize(),r=o.scaleBy(t),e=r.add(t);return[a.unproject(r,o.z),a.unproject(e,o.z)]},_tileCoordsToBounds:function(e){var o=this._tileCoordsToNwSe(e),t=new g(o[0],o[1]);return this.options.noWrap||(t=this._map.wrapLatLngBounds(t)),t},_tileCoordsToKey:function(t){return t.x+":"+t.y+":"+t.z},_keyToTileCoords:function(e){var o=e.split(":"),t=new y(+o[0],+o[1]);return t.z=+o[2],t},_removeTile:function(o){var e=this._tiles[o];e&&(Mt(e.el),delete this._tiles[o],this.fire("tileunload",{tile:e.el,coords:this._keyToTileCoords(o)}))},_initTile:function(o){qt(o,"leaflet-tile");var e=this.getTileSize();o.style.width=e.x+"px",o.style.height=e.y+"px",o.onselectstart=Y,o.onmousemove=Y,tt&&1>this.options.opacity&&Xt(o,this.options.opacity),nt&&!ot&&(o.style.WebkitBackfaceVisibility="hidden")},_addTile:function(o,a){var t=this._getTilePos(o),r=this._tileCoordsToKey(o),e=this.createTile(this._wrapCoords(o),h(this._tileReady,this,o));this._initTile(e),2>this.createTile.length&&ae(h(this._tileReady,this,o,null,e)),$t(e,t),this._tiles[r]={el:e,coords:o,current:!0},a.appendChild(e),this.fire("tileloadstart",{tile:e,coords:o})},_tileReady:function(e,o,t){o&&this.fire("tileerror",{error:o,tile:t,coords:e});var n=this._tileCoordsToKey(e);(t=this._tiles[n])&&(t.loaded=+new Date,this._map._fadeAnimated?(Xt(t.el,0),p(this._fadeFrame),this._fadeFrame=ae(this._updateOpacity,this)):(t.active=!0,this._pruneTiles()),o||(qt(t.el,"leaflet-tile-loaded"),this.fire("tileload",{tile:t.el,coords:e})),this._noTilesToLoad()&&(this._loading=!1,this.fire("load"),tt||!this._map._fadeAnimated?ae(this._pruneTiles,this):setTimeout(h(this._pruneTiles,this),250)))},_getTilePos:function(t){return t.scaleBy(this.getTileSize()).subtract(this._level.origin)},_wrapCoords:function(o){var e=new y(this._wrapX?V(o.x,this._wrapX):o.x,this._wrapY?V(o.y,this._wrapY):o.y);return e.z=o.z,e},_pxBoundsToTileRange:function(o){var e=this.getTileSize();return new C(o.min.unscaleBy(e).floor(),o.max.unscaleBy(e).ceil().subtract([1,1]))},_noTilesToLoad:function(){for(var t in this._tiles)if(!this._tiles[t].loaded)return!1;return!0}}),an=rn.extend({options:{minZoom:0,maxZoom:18,subdomains:"abc",errorTileUrl:"",zoomOffset:0,tms:!1,zoomReverse:!1,detectRetina:!1,crossOrigin:!1},initialize:function(o,e){this._url=o,(e=l(this,e)).detectRetina&&Tt&&0<e.maxZoom&&(e.tileSize=Math.floor(e.tileSize/2),e.zoomReverse?(e.zoomOffset--,e.minZoom++):(e.zoomOffset++,e.maxZoom--),e.minZoom=Math.max(0,e.minZoom)),"string"==typeof e.subdomains&&(e.subdomains=e.subdomains.split("")),nt||this.on("tileunload",this._onTileRemove)},setUrl:function(o,e){return this._url===o&&void 0===e&&(e=!0),this._url=o,e||this.redraw(),this},createTile:function(e,o){var t=document.createElement("img");return so(t,"load",h(this._tileOnLoad,this,o,t)),so(t,"error",h(this._tileOnError,this,o,t)),!this.options.crossOrigin&&""!==this.options.crossOrigin||(t.crossOrigin=!0===this.options.crossOrigin?"":this.options.crossOrigin),t.alt="",t.setAttribute("role","presentation"),t.src=this.getTileUrl(e),t},getTileUrl:function(a){var o={r:Tt?"@2x":"",s:this._getSubdomain(a),x:a.x,y:a.y,z:this._getZoomForUrl()};if(this._map&&!this._map.options.crs.infinite){var t=this._globalTileRange.max.y-a.y;this.options.tms&&(o.y=t),o["-y"]=t}return e(this._url,v(o,this.options))},_tileOnLoad:function(o,e){tt?setTimeout(h(o,this,null,e),0):o(null,e)},_tileOnError:function(n,o,t){var a=this.options.errorTileUrl;a&&o.getAttribute("src")!==a&&(o.src=a),n(t,o)},_onTileRemove:function(t){t.tile.onload=null},_getZoomForUrl:function(){var t=this._tileZoom,n=this.options.maxZoom;return this.options.zoomReverse&&(t=n-t),t+this.options.zoomOffset},_getSubdomain:function(o){var e=Math.abs(o.x+o.y)%this.options.subdomains.length;return this.options.subdomains[e]},_abortLoading:function(){var t,n;for(t in this._tiles)this._tiles[t].coords.z!==this._tileZoom&&((n=this._tiles[t].el).onload=Y,n.onerror=Y,n.complete||(n.src="data:image/gif;base64,R0lGODlhAQABAAD/ACwAAAAAAQABAAACADs=",Mt(n),delete this._tiles[t]))},_removeTile:function(o){var e=this._tiles[o];if(e)return rt||e.el.setAttribute("src","data:image/gif;base64,R0lGODlhAQABAAD/ACwAAAAAAQABAAACADs="),rn.prototype._removeTile.call(this,o)},_tileReady:function(e,o,t){if(this._map&&(!t||t.getAttribute("src")!=="data:image/gif;base64,R0lGODlhAQABAAD/ACwAAAAAAQABAAACADs="))return rn.prototype._tileReady.call(this,e,o,t)}}),hn=an.extend({defaultWmsParams:{service:"WMS",request:"GetMap",layers:"",styles:"",format:"image/jpeg",transparent:!1,version:"1.1.1"},options:{crs:null,uppercase:!1},initialize:function(s,a){this._url=s;var d=v({},this.defaultWmsParams);for(var r in a)r in this.options||(d[r]=a[r]);var e=(a=l(this,a)).detectRetina&&Tt?2:1,n=this.getTileSize();d.width=n.x*e,d.height=n.y*e,this.wmsParams=d},onAdd:function(o){this._crs=this.options.crs||o.options.crs,this._wmsVersion=parseFloat(this.wmsParams.version);var e=1.3<=this._wmsVersion?"crs":"srs";this.wmsParams[e]=this._crs.code,an.prototype.onAdd.call(this,o)},getTileUrl:function(a){var l=this._tileCoordsToNwSe(a),t=this._crs,d=w(t.project(l[0]),t.project(l[1])),e=d.min,n=d.max,o=(1.3<=this._wmsVersion&&this._crs===ze?[e.y,e.x,n.y,n.x]:[e.x,e.y,n.x,n.y]).join(","),s=an.prototype.getTileUrl.call(this,a);return s+_(this.wmsParams,s,this.options.uppercase)+(this.options.uppercase?"&BBOX=":"&bbox=")+o},setParams:function(o,e){return v(this.wmsParams,o),e||this.redraw(),this}});an.WMS=hn,Xe.wms=function(o,e){return new hn(o,e)};var un=Ce.extend({options:{padding:.1,tolerance:0},initialize:function(t){l(this,t),H(this),this._layers=this._layers||{}},onAdd:function(){this._container||(this._initContainer(),this._zoomAnimated&&qt(this._container,"leaflet-zoom-animated")),this.getPane().appendChild(this._container),this._update(),this.on("update",this._updatePaths,this)},onRemove:function(){this.off("update",this._updatePaths,this),this._destroyContainer()},getEvents:function(){var t={viewreset:this._reset,zoom:this._onZoom,moveend:this._update,zoomend:this._onZoomEnd};return this._zoomAnimated&&(t.zoomanim=this._onAnimZoom),t},_onAnimZoom:function(t){this._updateTransform(t.center,t.zoom)},_onZoom:function(){this._updateTransform(this._map.getCenter(),this._map.getZoom())},_updateTransform:function(a,l){var t=this._map.getZoomScale(l,this._zoom),d=eo(this._container),e=this._map.getSize().multiplyBy(.5+this.options.padding),n=this._map.project(this._center,l),o=this._map.project(a,l).subtract(n),s=e.multiplyBy(-t).add(d).add(e).subtract(o);gt?Qt(this._container,s,t):$t(this._container,s)},_reset:function(){for(var t in this._update(),this._updateTransform(this._center,this._zoom),this._layers)this._layers[t]._reset()},_onZoomEnd:function(){for(var t in this._layers)this._layers[t]._project()},_updatePaths:function(){for(var t in this._layers)this._layers[t]._update()},_update:function(){var e=this.options.padding,o=this._map.getSize(),t=this._map.containerPointToLayerPoint(o.multiplyBy(-e)).round();this._bounds=new C(t,t.add(o.multiplyBy(1+2*e)).round()),this._center=this._map.getCenter(),this._zoom=this._map.getZoom()}}),cn=un.extend({getEvents:function(){var t=un.prototype.getEvents.call(this);return t.viewprereset=this._onViewPreReset,t},_onViewPreReset:function(){this._postponeUpdatePaths=!0},onAdd:function(){un.prototype.onAdd.call(this),this._draw()},_initContainer:function(){var t=this._container=document.createElement("canvas");so(t,"mousemove",this._onMouseMove,this),so(t,"click dblclick mousedown mouseup contextmenu",this._onClick,this),so(t,"mouseout",this._handleMouseOut,this),this._ctx=t.getContext("2d")},_destroyContainer:function(){p(this._redrawRequest),delete this._ctx,Mt(this._container),lo(this._container),delete this._container},_updatePaths:function(){if(!this._postponeUpdatePaths){for(var t in this._redrawBounds=null,this._layers)this._layers[t]._update();this._redraw()}},_update:function(){if(!this._map._animatingZoom||!this._bounds){un.prototype._update.call(this);var n=this._bounds,o=this._container,t=n.getSize(),a=Tt?2:1;$t(o,n.min),o.width=a*t.x,o.height=a*t.y,o.style.width=t.x+"px",o.style.height=t.y+"px",Tt&&this._ctx.scale(2,2),this._ctx.translate(-n.min.x,-n.min.y),this.fire("update")}},_reset:function(){un.prototype._reset.call(this),this._postponeUpdatePaths&&(this._postponeUpdatePaths=!1,this._updatePaths())},_initPath:function(o){this._updateDashArray(o);var e=(this._layers[H(o)]=o)._order={layer:o,prev:this._drawLast,next:null};this._drawLast&&(this._drawLast.next=e),this._drawLast=e,this._drawFirst=this._drawFirst||this._drawLast},_addPath:function(t){this._requestRedraw(t)},_removePath:function(n){var o=n._order,t=o.next,a=o.prev;t?t.prev=a:this._drawLast=a,a?a.next=t:this._drawFirst=t,delete n._order,delete this._layers[H(n)],this._requestRedraw(n)},_updatePath:function(t){this._extendRedrawBounds(t),t._project(),t._update(),this._requestRedraw(t)},_updateStyle:function(t){this._updateDashArray(t),this._requestRedraw(t)},_updateDashArray:function(e){if("string"==typeof e.options.dashArray){var o,a,l=e.options.dashArray.split(/[, ]+/),s=[];for(a=0;a<l.length;a++){if(o=+l[a],isNaN(o))return;s.push(o)}e.options._dashArray=s}else e.options._dashArray=e.options.dashArray},_requestRedraw:function(t){this._map&&(this._extendRedrawBounds(t),this._redrawRequest=this._redrawRequest||ae(this._redraw,this))},_extendRedrawBounds:function(o){if(o._pxBounds){var e=(o.options.weight||0)+1;this._redrawBounds=this._redrawBounds||new C,this._redrawBounds.extend(o._pxBounds.min.subtract([e,e])),this._redrawBounds.extend(o._pxBounds.max.add([e,e]))}},_redraw:function(){this._redrawRequest=null,this._redrawBounds&&(this._redrawBounds.min._floor(),this._redrawBounds.max._ceil()),this._clear(),this._draw(),this._redrawBounds=null},_clear:function(){var o=this._redrawBounds;if(o){var e=o.getSize();this._ctx.clearRect(o.min.x,o.min.y,e.x,e.y)}else this._ctx.clearRect(0,0,this._container.width,this._container.height)},_draw:function(){var t,n=this._redrawBounds;if(this._ctx.save(),n){var a=n.getSize();this._ctx.beginPath(),this._ctx.rect(n.min.x,n.min.y,a.x,a.y),this._ctx.clip()}this._drawing=!0;for(var r=this._drawFirst;r;r=r.next)t=r.layer,(!n||t._pxBounds&&t._pxBounds.intersects(n))&&t._updatePath();this._drawing=!1,this._ctx.restore()},_updatePoly:function(e,o){if(this._drawing){var t,n,s,l,u=e._parts,c=u.length,r=this._ctx;if(c){for(r.beginPath(),t=0;t<c;t++){for(n=0,s=u[t].length;n<s;n++)l=u[t][n],r[n?"lineTo":"moveTo"](l.x,l.y);o&&r.closePath()}this._fillStroke(r,e)}}},_updateCircle:function(o){if(this._drawing&&!o._empty()){var a=o._point,t=this._ctx,r=Math.max(Math.round(o._radius),1),e=(Math.max(Math.round(o._radiusY),1)||r)/r;1!=e&&(t.save(),t.scale(1,e)),t.beginPath(),t.arc(a.x,a.y/e,r,0,2*Math.PI,!1),1!=e&&t.restore(),this._fillStroke(t,o)}},_fillStroke:function(e,o){var t=o.options;t.fill&&(e.globalAlpha=t.fillOpacity,e.fillStyle=t.fillColor||t.color,e.fill(t.fillRule||"evenodd")),t.stroke&&0!==t.weight&&(e.setLineDash&&e.setLineDash(o.options&&o.options._dashArray||[]),e.globalAlpha=t.opacity,e.lineWidth=t.weight,e.strokeStyle=t.color,e.lineCap=t.lineCap,e.lineJoin=t.lineJoin,e.stroke())},_onClick:function(e){for(var o,a,l=this._map.mouseEventToLayerPoint(e),s=this._drawFirst;s;s=s.next)(o=s.layer).options.interactive&&o._containsPoint(l)&&!this._map._draggableMoved(o)&&(a=o);a&&(vo(e),this._fireEvent([a],e))},_onMouseMove:function(o){if(this._map&&!this._map.dragging.moving()&&!this._map._animatingZoom){var e=this._map.mouseEventToLayerPoint(o);this._handleMouseHover(o,e)}},_handleMouseOut:function(o){var e=this._hoveredLayer;e&&(Vt(this._container,"leaflet-interactive"),this._fireEvent([e],o,"mouseout"),this._hoveredLayer=null,this._mouseHoverThrottled=!1)},_handleMouseHover:function(e,o){if(!this._mouseHoverThrottled){for(var t,n,a=this._drawFirst;a;a=a.next)(t=a.layer).options.interactive&&t._containsPoint(o)&&(n=t);n!==this._hoveredLayer&&(this._handleMouseOut(e),n&&(qt(this._container,"leaflet-interactive"),this._fireEvent([n],e,"mouseover"),this._hoveredLayer=n)),this._hoveredLayer&&this._fireEvent([this._hoveredLayer],e),this._mouseHoverThrottled=!0,setTimeout(L.bind(function(){this._mouseHoverThrottled=!1},this),32)}},_fireEvent:function(e,o,t){this._map._fireDOMEvent(o,t||o.type,e)},_bringToFront:function(n){var o=n._order;if(o){var t=o.next,a=o.prev;t&&((t.prev=a)?a.next=t:t&&(this._drawFirst=t),o.prev=this._drawLast,(this._drawLast.next=o).next=null,this._drawLast=o,this._requestRedraw(n))}},_bringToBack:function(n){var o=n._order;if(o){var t=o.next,a=o.prev;a&&((a.next=t)?t.prev=a:a&&(this._drawLast=a),o.prev=null,o.next=this._drawFirst,this._drawFirst.prev=o,this._drawFirst=o,this._requestRedraw(n))}}}),_n=function(){try{return document.namespaces.add("lvml","urn:schemas-microsoft-com:vml"),function(t){return document.createElement("<lvml:"+t+" class=\"lvml\">")}}catch(t){return function(t){return document.createElement("<"+t+" xmlns=\"urn:schemas-microsoft.com:vml\" class=\"lvml\">")}}}(),dn=St?_n:R,mn=un.extend({getEvents:function(){var t=un.prototype.getEvents.call(this);return t.zoomstart=this._onZoomStart,t},_initContainer:function(){this._container=dn("svg"),this._container.setAttribute("pointer-events","none"),this._rootGroup=dn("g"),this._container.appendChild(this._rootGroup)},_destroyContainer:function(){Mt(this._container),lo(this._container),delete this._container,delete this._rootGroup,delete this._svgSize},_onZoomStart:function(){this._update()},_update:function(){if(!this._map._animatingZoom||!this._bounds){un.prototype._update.call(this);var e=this._bounds,o=e.getSize(),t=this._container;this._svgSize&&this._svgSize.equals(o)||(this._svgSize=o,t.setAttribute("width",o.x),t.setAttribute("height",o.y)),$t(t,e.min),t.setAttribute("viewBox",[e.min.x,e.min.y,o.x,o.y].join(" ")),this.fire("update")}},_initPath:function(o){var e=o._path=dn("path");o.options.className&&qt(e,o.options.className),o.options.interactive&&qt(e,"leaflet-interactive"),this._updateStyle(o),this._layers[H(o)]=o},_addPath:function(t){this._rootGroup||this._initContainer(),this._rootGroup.appendChild(t._path),t.addInteractiveTarget(t._path)},_removePath:function(t){Mt(t._path),t.removeInteractiveTarget(t._path),delete this._layers[H(t)]},_updatePath:function(t){t._project(),t._update()},_updateStyle:function(e){var o=e._path,t=e.options;o&&(t.stroke?(o.setAttribute("stroke",t.color),o.setAttribute("stroke-opacity",t.opacity),o.setAttribute("stroke-width",t.weight),o.setAttribute("stroke-linecap",t.lineCap),o.setAttribute("stroke-linejoin",t.lineJoin),t.dashArray?o.setAttribute("stroke-dasharray",t.dashArray):o.removeAttribute("stroke-dasharray"),t.dashOffset?o.setAttribute("stroke-dashoffset",t.dashOffset):o.removeAttribute("stroke-dashoffset")):o.setAttribute("stroke","none"),t.fill?(o.setAttribute("fill",t.fillColor||t.color),o.setAttribute("fill-opacity",t.fillOpacity),o.setAttribute("fill-rule",t.fillRule||"evenodd")):o.setAttribute("fill","none"))},_updatePoly:function(o,e){this._setPath(o,D(o._parts,e))},_updateCircle:function(o){var a=o._point,t=Math.max(Math.round(o._radius),1),r="a"+t+","+(Math.max(Math.round(o._radiusY),1)||t)+" 0 1,0 ",e=o._empty()?"M0 0":"M"+(a.x-t)+","+a.y+r+2*t+",0 "+r+2*-t+",0 ";this._setPath(o,e)},_setPath:function(o,e){o._path.setAttribute("d",e)},_bringToFront:function(t){Ht(t._path)},_bringToBack:function(t){Wt(t._path)}});St&&mn.include({_initContainer:function(){this._container=wt("div","leaflet-vml-container")},_update:function(){this._map._animatingZoom||(un.prototype._update.call(this),this.fire("update"))},_initPath:function(o){var e=o._container=_n("shape");qt(e,"leaflet-vml-shape "+(this.options.className||"")),e.coordsize="1 1",o._path=_n("path"),e.appendChild(o._path),this._updateStyle(o),this._layers[H(o)]=o},_addPath:function(o){var e=o._container;this._container.appendChild(e),o.options.interactive&&o.addInteractiveTarget(e)},_removePath:function(o){var e=o._container;Mt(e),o.removeInteractiveTarget(e),delete this._layers[H(o)]},_updateStyle:function(e){var o=e._stroke,a=e._fill,l=e.options,s=e._container;s.stroked=!!l.stroke,s.filled=!!l.fill,l.stroke?(o||(o=e._stroke=_n("stroke")),s.appendChild(o),o.weight=l.weight+"px",o.color=l.color,o.opacity=l.opacity,o.dashStyle=l.dashArray?Ao(l.dashArray)?l.dashArray.join(" "):l.dashArray.replace(/( *, *)/g," "):"",o.endcap=l.lineCap.replace("butt","flat"),o.joinstyle=l.lineJoin):o&&(s.removeChild(o),e._stroke=null),l.fill?(a||(a=e._fill=_n("fill")),s.appendChild(a),a.color=l.fillColor||l.color,a.opacity=l.fillOpacity):a&&(s.removeChild(a),e._fill=null)},_updateCircle:function(n){var o=n._point.round(),t=Math.round(n._radius),a=Math.round(n._radiusY||t);this._setPath(n,n._empty()?"M0 0":"AL "+o.x+","+o.y+" "+t+","+a+" 0,23592600")},_setPath:function(o,e){o._path.v=e},_bringToFront:function(t){Ht(t._container)},_bringToBack:function(t){Wt(t._container)}}),fn.include({getRenderer:function(o){var e=o.options.renderer||this._getPaneRenderer(o.options.pane)||this.options.renderer||this._renderer;return e||(e=this._renderer=this._createRenderer()),this.hasLayer(e)||this.addLayer(e),e},_getPaneRenderer:function(o){if("overlayPane"===o||void 0===o)return!1;var e=this._paneRenderers[o];return void 0===e&&(e=this._createRenderer({pane:o}),this._paneRenderers[o]=e),e},_createRenderer:function(t){return this.options.preferCanvas&&$e(t)||To(t)}});var gn=De.extend({initialize:function(o,e){De.prototype.initialize.call(this,this._boundsToLatLngs(o),e)},setBounds:function(t){return this.setLatLngs(this._boundsToLatLngs(t))},_boundsToLatLngs:function(t){return[(t=S(t)).getSouthWest(),t.getNorthWest(),t.getNorthEast(),t.getSouthEast()]}});mn.create=dn,mn.pointsToPath=D,je.geometryToLayer=ye,je.coordsToLatLng=Fe,je.coordsToLatLngs=Ue,je.latLngToCoords=Ve,je.latLngsToCoords=qe,je.getFeature=Ge,je.asFeature=Ke,fn.mergeOptions({boxZoom:!0});var vn=ne.extend({initialize:function(t){this._map=t,this._container=t._container,this._pane=t._panes.overlayPane,this._resetStateTimeout=0,t.on("unload",this._destroy,this)},addHooks:function(){so(this._container,"mousedown",this._onMouseDown,this)},removeHooks:function(){lo(this._container,"mousedown",this._onMouseDown,this)},moved:function(){return this._moved},_destroy:function(){Mt(this._pane),delete this._pane},_resetState:function(){this._resetStateTimeout=0,this._moved=!1},_clearDeferredResetState:function(){0!==this._resetStateTimeout&&(clearTimeout(this._resetStateTimeout),this._resetStateTimeout=0)},_onMouseDown:function(t){return!!(t.shiftKey&&(1===t.which||1===t.button))&&void(this._clearDeferredResetState(),this._resetState(),Bo(),to(),this._startPoint=this._map.mouseEventToContainerPoint(t),so(document,{contextmenu:yo,mousemove:this._onMouseMove,mouseup:this._onMouseUp,keydown:this._onKeyDown},this))},_onMouseMove:function(e){this._moved||(this._moved=!0,this._box=wt("div","leaflet-zoom-box",this._container),qt(this._container,"leaflet-crosshair"),this._map.fire("boxzoomstart")),this._point=this._map.mouseEventToContainerPoint(e);var o=new C(this._point,this._startPoint),t=o.getSize();$t(this._box,o.min),this._box.style.width=t.x+"px",this._box.style.height=t.y+"px"},_finish:function(){this._moved&&(Mt(this._box),Vt(this._container,"leaflet-crosshair")),Oo(),oo(),lo(document,{contextmenu:yo,mousemove:this._onMouseMove,mouseup:this._onMouseUp,keydown:this._onKeyDown},this)},_onMouseUp:function(o){if((1===o.which||1===o.button)&&(this._finish(),this._moved)){this._clearDeferredResetState(),this._resetStateTimeout=setTimeout(h(this._resetState,this),0);var e=new g(this._map.containerPointToLatLng(this._startPoint),this._map.containerPointToLatLng(this._point));this._map.fitBounds(e).fire("boxzoomend",{boxZoomBounds:e})}},_onKeyDown:function(t){27===t.keyCode&&this._finish()}});fn.addInitHook("addHandler","boxZoom",vn),fn.mergeOptions({doubleClickZoom:!0});var xn=ne.extend({addHooks:function(){this._map.on("dblclick",this._onDoubleClick,this)},removeHooks:function(){this._map.off("dblclick",this._onDoubleClick,this)},_onDoubleClick:function(o){var a=this._map,t=a.getZoom(),r=a.options.zoomDelta,e=o.originalEvent.shiftKey?t-r:t+r;"center"===a.options.doubleClickZoom?a.setZoom(e):a.setZoomAround(o.containerPoint,e)}});fn.addInitHook("addHandler","doubleClickZoom",xn),fn.mergeOptions({dragging:!0,inertia:!ot,inertiaDeceleration:3400,inertiaMaxSpeed:1/0,easeLinearity:.2,worldCopyJump:!1,maxBoundsViscosity:0});var wn=ne.extend({addHooks:function(){if(!this._draggable){var t=this._map;this._draggable=new ue(t._mapPane,t._container),this._draggable.on({dragstart:this._onDragStart,drag:this._onDrag,dragend:this._onDragEnd},this),this._draggable.on("predrag",this._onPreDragLimit,this),t.options.worldCopyJump&&(this._draggable.on("predrag",this._onPreDragWrap,this),t.on("zoomend",this._onZoomEnd,this),t.whenReady(this._onZoomEnd,this))}qt(this._map._container,"leaflet-grab leaflet-touch-drag"),this._draggable.enable(),this._positions=[],this._times=[]},removeHooks:function(){Vt(this._map._container,"leaflet-grab"),Vt(this._map._container,"leaflet-touch-drag"),this._draggable.disable()},moved:function(){return this._draggable&&this._draggable._moved},moving:function(){return this._draggable&&this._draggable._moving},_onDragStart:function(){var o=this._map;if(o._stop(),this._map.options.maxBounds&&this._map.options.maxBoundsViscosity){var e=S(this._map.options.maxBounds);this._offsetLimit=w(this._map.latLngToContainerPoint(e.getNorthWest()).multiplyBy(-1),this._map.latLngToContainerPoint(e.getSouthEast()).multiplyBy(-1).add(this._map.getSize())),this._viscosity=Math.min(1,Math.max(0,this._map.options.maxBoundsViscosity))}else this._offsetLimit=null;o.fire("movestart").fire("dragstart"),o.options.inertia&&(this._positions=[],this._times=[])},_onDrag:function(e){if(this._map.options.inertia){var o=this._lastTime=+new Date,t=this._lastPos=this._draggable._absPos||this._draggable._newPos;this._positions.push(t),this._times.push(o),this._prunePositions(o)}this._map.fire("move",e).fire("drag",e)},_prunePositions:function(t){for(;1<this._positions.length&&50<t-this._times[0];)this._positions.shift(),this._times.shift()},_onZoomEnd:function(){var o=this._map.getSize().divideBy(2),e=this._map.latLngToLayerPoint([0,0]);this._initialWorldOffset=e.subtract(o).x,this._worldWidth=this._map.getPixelWorldBounds().getSize().x},_viscousLimit:function(o,e){return o-(o-e)*this._viscosity},_onPreDragLimit:function(){if(this._viscosity&&this._offsetLimit){var o=this._draggable._newPos.subtract(this._draggable._startPos),e=this._offsetLimit;o.x<e.min.x&&(o.x=this._viscousLimit(o.x,e.min.x)),o.y<e.min.y&&(o.y=this._viscousLimit(o.y,e.min.y)),o.x>e.max.x&&(o.x=this._viscousLimit(o.x,e.max.x)),o.y>e.max.y&&(o.y=this._viscousLimit(o.y,e.max.y)),this._draggable._newPos=this._draggable._startPos.add(o)}},_onPreDragWrap:function(){var r=this._worldWidth,a=Math.round(r/2),t=this._initialWorldOffset,l=this._draggable._newPos.x,e=(l-a+t)%r+a-t,n=(l+a+t)%r-a-t,o=Math.abs(e+t)<Math.abs(n+t)?e:n;this._draggable._absPos=this._draggable._newPos.clone(),this._draggable._newPos.x=o},_onDragEnd:function(_){var d=this._map,t=d.options,p=!t.inertia||2>this._times.length;if(d.fire("dragend",_),p)d.fire("moveend");else{this._prunePositions(+new Date);var e=this._lastPos.subtract(this._positions[0]),n=(this._lastTime-this._times[0])/1e3,o=t.easeLinearity,s=e.multiplyBy(o/n),r=s.distanceTo([0,0]),a=Math.min(t.inertiaMaxSpeed,r),m=s.multiplyBy(a/r),u=a/(t.inertiaDeceleration*o),l=m.multiplyBy(-u/2).round();l.x||l.y?(l=d._limitOffset(l,d.options.maxBounds),ae(function(){d.panBy(l,{duration:u,easeLinearity:o,noMoveStart:!0,animate:!0})})):d.fire("moveend")}}});fn.addInitHook("addHandler","dragging",wn),fn.mergeOptions({keyboard:!0,keyboardPanDelta:80});var Pn=ne.extend({keyCodes:{left:[37],right:[39],down:[40],up:[38],zoomIn:[187,107,61,171],zoomOut:[189,109,54,173]},initialize:function(t){this._map=t,this._setPanDelta(t.options.keyboardPanDelta),this._setZoomDelta(t.options.zoomDelta)},addHooks:function(){var t=this._map._container;0>=t.tabIndex&&(t.tabIndex="0"),so(t,{focus:this._onFocus,blur:this._onBlur,mousedown:this._onMouseDown},this),this._map.on({focus:this._addHooks,blur:this._removeHooks},this)},removeHooks:function(){this._removeHooks(),lo(this._map._container,{focus:this._onFocus,blur:this._onBlur,mousedown:this._onMouseDown},this),this._map.off({focus:this._addHooks,blur:this._removeHooks},this)},_onMouseDown:function(){if(!this._focused){var n=document.body,o=document.documentElement,t=n.scrollTop||o.scrollTop,a=n.scrollLeft||o.scrollLeft;this._map._container.focus(),window.scrollTo(a,t)}},_onFocus:function(){this._focused=!0,this._map.fire("focus")},_onBlur:function(){this._focused=!1,this._map.fire("blur")},_setPanDelta:function(e){var o,a,l=this._panKeys={},s=this.keyCodes;for(o=0,a=s.left.length;o<a;o++)l[s.left[o]]=[-1*e,0];for(o=0,a=s.right.length;o<a;o++)l[s.right[o]]=[e,0];for(o=0,a=s.down.length;o<a;o++)l[s.down[o]]=[0,e];for(o=0,a=s.up.length;o<a;o++)l[s.up[o]]=[0,-1*e]},_setZoomDelta:function(e){var o,a,l=this._zoomKeys={},s=this.keyCodes;for(o=0,a=s.zoomIn.length;o<a;o++)l[s.zoomIn[o]]=e;for(o=0,a=s.zoomOut.length;o<a;o++)l[s.zoomOut[o]]=-e},_addHooks:function(){so(document,"keydown",this._onKeyDown,this)},_removeHooks:function(){lo(document,"keydown",this._onKeyDown,this)},_onKeyDown:function(n){if(!(n.altKey||n.ctrlKey||n.metaKey)){var o,r=n.keyCode,a=this._map;if(r in this._panKeys)a._panAnim&&a._panAnim._inProgress||(o=this._panKeys[r],n.shiftKey&&(o=b(o).multiplyBy(3)),a.panBy(o),a.options.maxBounds&&a.panInsideBounds(a.options.maxBounds));else if(r in this._zoomKeys)a.setZoom(a.getZoom()+(n.shiftKey?3:1)*this._zoomKeys[r]);else{if(27!==r||!a._popup||!a._popup.options.closeOnEscapeKey)return;a.closePopup()}yo(n)}}});fn.addInitHook("addHandler","keyboard",Pn),fn.mergeOptions({scrollWheelZoom:!0,wheelDebounceTime:40,wheelPxPerZoomLevel:60});var Ln=ne.extend({addHooks:function(){so(this._map._container,"mousewheel",this._onWheelScroll,this),this._delta=0},removeHooks:function(){lo(this._map._container,"mousewheel",this._onWheelScroll,this)},_onWheelScroll:function(n){var o=fo(n),t=this._map.options.wheelDebounceTime;this._delta+=o,this._lastMousePos=this._map.mouseEventToContainerPoint(n),this._startTime||(this._startTime=+new Date);var a=Math.max(t-(+new Date-this._startTime),0);clearTimeout(this._timer),this._timer=setTimeout(h(this._performZoom,this),a),yo(n)},_performZoom:function(){var r=this._map,a=r.getZoom(),t=this._map.options.zoomSnap||0;r._stop();var l=this._delta/(4*this._map.options.wheelPxPerZoomLevel),e=4*Math.log(2/(1+Math.exp(-Math.abs(l))))/Math.LN2,n=t?Math.ceil(e/t)*t:e,o=r._limitZoom(a+(0<this._delta?n:-n))-a;this._delta=0,this._startTime=null,o&&("center"===r.options.scrollWheelZoom?r.setZoom(a+o):r.setZoomAround(this._lastMousePos,a+o))}});fn.addInitHook("addHandler","scrollWheelZoom",Ln),fn.mergeOptions({tap:!0,tapTolerance:15});var bn=ne.extend({addHooks:function(){so(this._map._container,"touchstart",this._onDown,this)},removeHooks:function(){lo(this._map._container,"touchstart",this._onDown,this)},_onDown:function(e){if(e.touches){if(go(e),this._fireClick=!0,1<e.touches.length)return this._fireClick=!1,void clearTimeout(this._holdTimeout);var o=e.touches[0],t=o.target;this._startPos=this._newPos=new y(o.clientX,o.clientY),t.tagName&&"a"===t.tagName.toLowerCase()&&qt(t,"leaflet-active"),this._holdTimeout=setTimeout(h(function(){this._isTapValid()&&(this._fireClick=!1,this._onUp(),this._simulateEvent("contextmenu",o))},this),1e3),this._simulateEvent("mousedown",o),so(document,{touchmove:this._onMove,touchend:this._onUp},this)}},_onUp:function(e){if(clearTimeout(this._holdTimeout),lo(document,{touchmove:this._onMove,touchend:this._onUp},this),this._fireClick&&e&&e.changedTouches){var o=e.changedTouches[0],t=o.target;t&&t.tagName&&"a"===t.tagName.toLowerCase()&&Vt(t,"leaflet-active"),this._simulateEvent("mouseup",o),this._isTapValid()&&this._simulateEvent("click",o)}},_isTapValid:function(){return this._newPos.distanceTo(this._startPos)<=this._map.options.tapTolerance},_onMove:function(o){var e=o.touches[0];this._newPos=new y(e.clientX,e.clientY),this._simulateEvent("mousemove",e)},_simulateEvent:function(e,o){var t=document.createEvent("MouseEvents");t._simulated=!0,o.target._simulatedClick=!0,t.initMouseEvent(e,!0,!0,window,1,o.screenX,o.screenY,o.clientX,o.clientY,!1,!1,!1,!1,0,null),o.target.dispatchEvent(t)}});Lt&&!xt&&fn.addInitHook("addHandler","tap",bn),fn.mergeOptions({touchZoom:Lt&&!ot,bounceAtZoomLimits:!0});var Tn=ne.extend({addHooks:function(){qt(this._map._container,"leaflet-touch-zoom"),so(this._map._container,"touchstart",this._onTouchStart,this)},removeHooks:function(){Vt(this._map._container,"leaflet-touch-zoom"),lo(this._map._container,"touchstart",this._onTouchStart,this)},_onTouchStart:function(n){var o=this._map;if(n.touches&&2===n.touches.length&&!o._animatingZoom&&!this._zooming){var t=o.mouseEventToContainerPoint(n.touches[0]),a=o.mouseEventToContainerPoint(n.touches[1]);this._centerPoint=o.getSize()._divideBy(2),this._startLatLng=o.containerPointToLatLng(this._centerPoint),"center"!==o.options.touchZoom&&(this._pinchStartLatLng=o.containerPointToLatLng(t.add(a)._divideBy(2))),this._startDist=t.distanceTo(a),this._startZoom=o.getZoom(),this._moved=!1,this._zooming=!0,o._stop(),so(document,"touchmove",this._onTouchMove,this),so(document,"touchend",this._onTouchEnd,this),go(n)}},_onTouchMove:function(r){if(r.touches&&2===r.touches.length&&this._zooming){var a=this._map,t=a.mouseEventToContainerPoint(r.touches[0]),l=a.mouseEventToContainerPoint(r.touches[1]),e=t.distanceTo(l)/this._startDist;if(this._zoom=a.getScaleZoom(e,this._startZoom),!a.options.bounceAtZoomLimits&&(this._zoom<a.getMinZoom()&&1>e||this._zoom>a.getMaxZoom()&&1<e)&&(this._zoom=a._limitZoom(this._zoom)),"center"!==a.options.touchZoom){var n=t._add(l)._divideBy(2)._subtract(this._centerPoint);if(1==e&&0===n.x&&0===n.y)return;this._center=a.unproject(a.project(this._pinchStartLatLng,this._zoom).subtract(n),this._zoom)}else if(this._center=this._startLatLng,1==e)return;this._moved||(a._moveStart(!0,!1),this._moved=!0),p(this._animRequest);var o=h(a._move,a,this._center,this._zoom,{pinch:!0,round:!1});this._animRequest=ae(o,this,!0),go(r)}},_onTouchEnd:function(){this._moved&&this._zooming?(this._zooming=!1,p(this._animRequest),lo(document,"touchmove",this._onTouchMove),lo(document,"touchend",this._onTouchEnd),this._map.options.zoomAnimation?this._map._animateZoom(this._center,this._map._limitZoom(this._zoom),!0,this._map.options.zoomSnap):this._map._resetView(this._center,this._map._limitZoom(this._zoom))):this._zooming=!1}});fn.addInitHook("addHandler","touchZoom",Tn),fn.BoxZoom=vn,fn.DoubleClickZoom=xn,fn.Drag=wn,fn.Keyboard=Pn,fn.ScrollWheelZoom=Ln,fn.Tap=bn,fn.TouchZoom=Tn,Object.freeze=Co,n.version="1.6.0+HEAD.0c81bdf",n.Control=kn,n.control=ko,n.Browser=Zt,n.Evented=E,n.Mixin={Events:z},n.Util=T,n.Class=c,n.Handler=ne,n.extend=v,n.bind=h,n.stamp=H,n.setOptions=l,n.DomEvent=pn,n.DomUtil=Mn,n.PosAnimation=yn,n.Draggable=ue,n.LineUtil=le,n.PolyUtil=ce,n.Point=y,n.point=b,n.Bounds=C,n.bounds=w,n.Transformation=B,n.transformation=O,n.Projection=be,n.LatLng=I,n.latLng=M,n.LatLngBounds=g,n.latLngBounds=S,n.CRS=Zo,n.GeoJSON=je,n.geoJSON=Ye,n.geoJson=Ye,n.Layer=Ce,n.LayerGroup=Ee,n.layerGroup=function(o,e){return new Ee(o,e)},n.FeatureGroup=Se,n.featureGroup=function(t){return new Se(t)},n.ImageOverlay=He,n.imageOverlay=function(e,o,t){return new He(e,o,t)},n.VideoOverlay=Je,n.videoOverlay=function(e,o,t){return new Je(e,o,t)},n.SVGOverlay=tn,n.svgOverlay=function(e,o,t){return new tn(e,o,t)},n.DivOverlay=en,n.Popup=nn,n.popup=function(o,e){return new nn(o,e)},n.Tooltip=on,n.tooltip=function(o,e){return new on(o,e)},n.Icon=Ze,n.icon=function(t){return new Ze(t)},n.DivIcon=sn,n.divIcon=function(t){return new sn(t)},n.Marker=Ae,n.marker=function(o,e){return new Ae(o,e)},n.TileLayer=an,n.tileLayer=Xe,n.GridLayer=rn,n.gridLayer=function(t){return new rn(t)},n.SVG=mn,n.svg=To,n.Renderer=un,n.Canvas=cn,n.canvas=$e,n.Path=Ie,n.CircleMarker=Oe,n.circleMarker=function(o,e){return new Oe(o,e)},n.Circle=Re,n.circle=function(e,o,t){return new Re(e,o,t)},n.Polyline=Ne,n.polyline=function(o,e){return new Ne(o,e)},n.Polygon=De,n.polygon=function(o,e){return new De(o,e)},n.Rectangle=gn,n.rectangle=function(o,e){return new gn(o,e)},n.Map=fn,n.map=function(o,e){return new fn(o,e)};var zn=window.L;n.noConflict=function(){return window.L=zn,this},window.L=n});
|
|
/////////////////////////////////////////////////////////////////////////
|
|
//MAPA
|
|
|
|
// Zmienna trzymająca informacje o customowych markerach
|
|
const defaultIconSize = [50,45];
|
|
const mapMarkerIcons = {
|
|
inpost: L.icon({
|
|
iconUrl: "/data/include/deliveries/markers/inpost/marker_locker.png",
|
|
iconSize: defaultIconSize,
|
|
className: ""
|
|
}),
|
|
default: L.icon({
|
|
iconUrl: "/gfx/standards/marker-icon.png",
|
|
iconSize: defaultIconSize,
|
|
className: ""
|
|
}),
|
|
// default: "/gfx/standards/marker-icon.png"
|
|
// custom : "/data/include/cms/map_marker/testMarkerIcon.svg?v=1703749620844"
|
|
orlen: L.icon({
|
|
iconUrl: "/data/include/deliveries/markers/paczkaOrlen/marker_orlen.png",
|
|
iconSize: defaultIconSize,
|
|
className: ""
|
|
}),
|
|
}
|
|
let newMarkerIcon = mapMarkerIcons.default;
|
|
|
|
function getMarkerIcon(courierId){
|
|
if(courierId == 100153) return mapMarkerIcons.inpost;
|
|
else if(courierId == 100411) return mapMarkerIcons.orlen;
|
|
else return mapMarkerIcons.default;
|
|
}
|
|
|
|
// zmienne trzymające id dostaw z mapą i czy mapa już była załadowana
|
|
const deliveryPickupPoints = [] ;
|
|
let finpostjs = false;
|
|
// funkcja inicjująca mapę
|
|
function loadMap() {
|
|
var htmlContent = `
|
|
<div id="fbs_z02_cover">
|
|
<div id="fbs_z02_wrapper" class="dialog_fbs_z02">
|
|
<a id="fbs_z02_close" href="#close"></a>
|
|
<div id="fbs_z02_modal">
|
|
<div id="pickup_site">
|
|
<h1 class="big_label">${<iai:variable vid="Wybierz punkt odbioru"/>}</h1>
|
|
<img class="markerCluster" style="display:none;" src="/gfx/pol/m1.png?r=1607932189">
|
|
<img class="markerCluster" style="display:none;" src="/gfx/pol/m2.png?r=1607932189">
|
|
<img class="markerCluster" style="display:none;" src="/gfx/pol/m3.png?r=1607932189">
|
|
<img class="markerCluster" style="display:none;" src="/gfx/pol/m4.png?r=1607932189">
|
|
<img class="markerCluster" style="display:none;" src="/gfx/pol/m5.png?r=1607932189">
|
|
<img class="marker_face" src="/gfx/pol/marker_face.png?r=1607932189">
|
|
<div class="pickup_site_sub">
|
|
<div class="locationField_sub">
|
|
<div id="locationField">
|
|
<input id="autocomplete_location" class="autocomplete_nomap" type="text" placeholder="${<iai:variable vid="Wpisz adres"/>}" value="">
|
|
<a class="btn bm-oscop__btn"><span>${<iai:variable vid="Szukaj punktów"/>}</span></a>
|
|
</div>
|
|
</div>
|
|
<div id="pickup_list_form">
|
|
<div class="pickup_map_sidebar">
|
|
<div id="mymap" class="mymap">
|
|
<div class="map_button_search">
|
|
<a href="#search_here" class="btn pickup_search_here_leaflet" title="${<iai:variable vid="Kliknij, aby wyszukać punktów na tym obszarze"/>}"> ${<iai:variable vid="Szukaj na tym obszarze"/>} </a>
|
|
</div>
|
|
</div>
|
|
<div class="asideContainer_pickup --hide-map-el">
|
|
<div class="menu_messages_message">${<iai:variable vid="Wpisz inny adres, brak punktów odbioru"/>}.</div>
|
|
</div>
|
|
</div>
|
|
<!-- TUTAJ -->
|
|
</div>
|
|
</div>
|
|
<div id="pickup_copy" style="display:none;">
|
|
<input type="radio" value="" id="" name="pickup_point">
|
|
<label class="pickup_point" required="required" data-id="" data-requires_client_number="" data-longitude="" data-latitude="" for="">
|
|
<div class="pickup_point_sub">
|
|
<!-- I TUTAJ -->
|
|
<b class="headerText"></b>
|
|
<div>
|
|
<span class="streetText"></span>
|
|
<span class="zipcodePickup">
|
|
<span class="cityText"></span>
|
|
</span>
|
|
<input type="text" name="client_courier_number" disabled="" required="required" placeholder="${<iai:variable vid="Nr klienta w systemie kuriera"/>}:">
|
|
</div>
|
|
</div>
|
|
<a class="btn map_dir" target="_blank">
|
|
<i class="icon-delivery"></i>
|
|
${<iai:variable vid="Wyznacz trasę"/>}
|
|
</a>
|
|
<a title="Wybierz" href="#close" class="btn fbs02_btn">${<iai:variable vid="Wybierz"/>}</a>
|
|
</label>
|
|
</div>
|
|
</div>
|
|
<div class="mobile-change__btns">
|
|
<button class="bm-oscop__btn" data-show="list" onclick="toggleMapList(event)">Pokaż Listę</button>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>`;
|
|
|
|
// funkcja wyszukująca markery na mapie
|
|
function runSearchPickup() {
|
|
if (typeof mymap !== 'undefined') {
|
|
mymap.eachLayer(function (layer) {
|
|
if (layer._icon !== undefined) {
|
|
mymap.removeLayer(layer);
|
|
}
|
|
});
|
|
leafletGetTextLocation();
|
|
}
|
|
document.querySelector('.asideContainer_pickup').innerHTML = '';
|
|
}
|
|
|
|
// Funkcja obsługująca dostawy z mapą
|
|
function createEventsInpost(ITEM_ID) {
|
|
var ITEM_FOR_MAP = '#item_' + ITEM_ID;
|
|
var oscItem = document.querySelector(ITEM_FOR_MAP).closest('.osc_item');
|
|
|
|
document.querySelector(ITEM_FOR_MAP).addEventListener('click', function (e) {
|
|
const deliveryValue = ITEM_FOR_MAP.slice(1);
|
|
|
|
// Weź adres klienta do mapy(zalogowany lub niezalogowany: zwykly lub dostawa na inny adres)
|
|
const clientStreet = getAddressInfo("street");
|
|
const clientZipCode = getAddressInfo("zipcode");
|
|
const clientCity = getAddressInfo("city");
|
|
|
|
// Jesli nie ma informacji potrzebnej do mapy, zapisz wiadomosc do errora
|
|
let errorMessage = "";
|
|
|
|
if(!clientStreet) errorMessage += `${<iai:variable vid="Wpisz ulicę i numer domu klienta"/>} <br>`;
|
|
if(!clientZipCode) errorMessage += `${<iai:variable vid="Podaj kod pocztowy adresu dostawy"/>} <br>`;
|
|
if(!clientCity) errorMessage += `${<iai:variable vid="Wpisz miasto odbiorcy przesyłki"/>}`;
|
|
|
|
// Zablokuj wybranie mapy jak nie ma adresu
|
|
if(errorMessage !== ""){
|
|
Alertek.show_alert(errorMessage);
|
|
const scrolledToElement = document.getElementById("deliver_to_billingaddr").checked ? document.getElementById("delivery_firstname") : document.getElementById("client_firstname");
|
|
scrollToHeight(scrolledToElement);
|
|
e.target.checked = false;
|
|
checkPrevShipping();
|
|
return false;
|
|
}
|
|
app_shop.vars.courierId = ITEM_ID;
|
|
|
|
if (oscItem.querySelector('.finpost_loading')) oscItem.querySelector('.finpost_loading').style.display = "block";
|
|
|
|
// Pokaż/Wstaw mapę
|
|
if (finpostjs){
|
|
document.getElementById("fbs_z02_cover").style.display = "block";
|
|
disablePageScroll();
|
|
}
|
|
else {
|
|
document.querySelector('body').insertAdjacentHTML("beforeend",htmlContent);
|
|
disablePageScroll();
|
|
|
|
// Naprawienie searchu w leaflet(stackuja sie wyniki bez tego)
|
|
document.getElementById("autocomplete_location").addEventListener("keyup", (e) => {
|
|
const suggestions = document.querySelector(".leafleat-suggestions");
|
|
if(!suggestions) return;
|
|
else suggestions.remove();
|
|
});
|
|
htmlContent = '';
|
|
}
|
|
|
|
// Wstaw adres klienta
|
|
const searchField = document.getElementById("autocomplete_location");
|
|
searchField.value = `${clientStreet} ${clientZipCode} ${clientCity}`;
|
|
|
|
// Zamknij popup
|
|
document.getElementById("fbs_z02_close").addEventListener('click', closeMap);
|
|
document.getElementById("fbs_z02_cover").addEventListener('click', function (e) {
|
|
if (e.target.closest('#fbs_z02_wrapper')) return;
|
|
closeMap();
|
|
});
|
|
|
|
// Zmiana miejsca przycisku "szukaj na tym obszarze" na mobile
|
|
if (window.innerWidth < 757) document.getElementById("pickup_list_form").insertAdjacentElement("beforebegin",document.querySelector('.map_button_search'));
|
|
if (!oscItem.querySelector('.fselectedPoint')) oscItem.insertAdjacentHTML("beforeend",`<label class="fselectedPoint" style="padding: 0px;" for="${deliveryValue}"></label>`);
|
|
|
|
// wyszukiwanie punktów odbioru na mapie
|
|
if (finpostjs) {
|
|
pickup_sites.courierId = ITEM_ID;
|
|
runSearchPickup();
|
|
}
|
|
if (!finpostjs) {
|
|
console.log("pickup_sites_list.js loaded");
|
|
finpostjs = true;
|
|
pickup_sites.courierId = ITEM_ID;
|
|
runSearchPickup();
|
|
|
|
document.querySelector('#locationField .btn').click();
|
|
// Wybranie punktu i wstawienie go koło dostawy
|
|
document.querySelector('.asideContainer_pickup').addEventListener("change", (e) => {
|
|
if(e.target.type !== "radio") return;
|
|
|
|
//Wyczyść poprzednie punkty odbioru
|
|
clearSelectedPoints();
|
|
|
|
// Wybierz dobrą metode dostawy
|
|
const courierId = document.querySelector(`#pickup_list_form .asideContainer_pickup label[data-id="${e.target.value}"]`).dataset.courierId;
|
|
const prepaidValue = document.getElementById("payitem_cash").checked ? 0 : 1
|
|
const courierInput = document.querySelector(`#item_${courierId}-${prepaidValue}`);
|
|
courierInput.checked = true;
|
|
changeCurrentShippingInfo(courierInput);
|
|
|
|
const selectedPoint = document.querySelector('[name="shipping"]:checked').closest('.osc_item').querySelector('.fselectedPoint');
|
|
selectedPoint.innerHTML = "";
|
|
|
|
// utworzenie informacji o punkcie odbioru
|
|
const deliveryId = document.querySelector('[name="pickup_point"]:checked').value;
|
|
const chosenPoint = document.querySelector(`.asideContainer_pickup label[data-id="${deliveryId}"]`);
|
|
const pickupName = chosenPoint.querySelector(".headerText").innerHTML;
|
|
const streetName = chosenPoint.querySelector(".streetText").innerHTML;
|
|
const cityName = chosenPoint.querySelector(".cityText").innerHTML;
|
|
const zipCodeName = chosenPoint.querySelector(".zipcodePickup").innerHTML.slice(0, chosenPoint.querySelector(".zipcodePickup").innerHTML.search("<span"));
|
|
|
|
createPickuppointInfo(selectedPoint, deliveryId, pickupName, streetName, cityName, zipCodeName, courierId);
|
|
});
|
|
// Wyjście z mapy po kliknięciu na "Wybierz"
|
|
document.getElementById("pickup_list_form").addEventListener("click",e => {
|
|
if(!e.target.classList.contains("fbs02_btn")) return;
|
|
closeMap();
|
|
});
|
|
}
|
|
changeCurrentShippingInfo(e.target);
|
|
});
|
|
}
|
|
deliveryPickupPoints.forEach(point => createEventsInpost(point));
|
|
}
|
|
// zamknięcie mapy
|
|
function closeMap(){
|
|
document.getElementById("fbs_z02_cover").style.display = "none";
|
|
enablePageScroll();
|
|
}
|
|
// Zdobądź wartość adresu, kodu pocztowego i miasta
|
|
function getAddressInfo(query){
|
|
if(document.getElementById("deliver_to_billingaddr").checked){
|
|
if(document.getElementById(`delivery_${query}`).value.trim()) return document.getElementById(`delivery_${query}`).value;
|
|
};
|
|
return document.getElementById(`client_${query}`).value;
|
|
}
|
|
// utworzenie informacji o punkcie odbioru
|
|
function createPickuppointInfo(selectedPoint, deliveryPointId, name, streetText, cityText, zipcodeText, courierId){
|
|
// Pokazanie elementu fselectedPoint
|
|
selectedPoint.style.display = "block";
|
|
|
|
// Wstawienie danych w punkt odbioru
|
|
selectedPoint.dataset.courierId = courierId;
|
|
selectedPoint.dataset.deliveryPointId = deliveryPointId;
|
|
selectedPoint.dataset.name = name;
|
|
selectedPoint.dataset.street = streetText;
|
|
selectedPoint.dataset.city = cityText;
|
|
selectedPoint.dataset.zipcode = zipcodeText;
|
|
|
|
// Wstawienie danych o punkcie odbioru
|
|
selectedPoint.insertAdjacentHTML("beforeend", `
|
|
<label class="pickup_point" for="${selectedPoint.getAttribute("for")}">
|
|
<div class="pickup_point_sub">
|
|
<b class="headerText">${name}</b>
|
|
<div>
|
|
<span class="streetText">${streetText}</span>
|
|
<span class="zipcodePickup">
|
|
${zipcodeText}
|
|
<span class="cityText">${cityText}</span>
|
|
</span>
|
|
</div>
|
|
</div>
|
|
</label>
|
|
<input type="hidden" name="pickup_point" value="${deliveryPointId}">
|
|
`);
|
|
}
|
|
|
|
// Zmiana widoku listy, mapy na mobilce
|
|
function toggleMapList(e){
|
|
const ifList = e.target.dataset.show === "list";
|
|
e.target.innerHTML = ifList ? "Pokaż Mapę" : "Pokaż Listę";
|
|
|
|
// Schowaj/ Pokaż mapę i listę
|
|
if(ifList){
|
|
document.querySelector(".map_button_search").classList.add("--hide-map-el");
|
|
document.getElementById("mymap").classList.add("--hide-map-el");
|
|
document.querySelector(".asideContainer_pickup").classList.remove("--hide-map-el");
|
|
}else{
|
|
document.querySelector(".map_button_search").classList.remove("--hide-map-el");
|
|
document.getElementById("mymap").classList.remove("--hide-map-el");
|
|
document.querySelector(".asideContainer_pickup").classList.add("--hide-map-el");
|
|
}
|
|
|
|
e.target.dataset.show = ifList ? "map" : "list";
|
|
}
|
|
///////////////////////////////////////////////////////////////////////////
|
|
// DANE KLIENTA
|
|
|
|
document.getElementById("cop_seection1").addEventListener("click", (e) => {
|
|
// Pokazanie się okna od logowania
|
|
if(e.target.classList.contains("get_signin")) showSigninModal();
|
|
|
|
// Sprawdzenie czy kliknięcie było na "Załóź konto w sklepie Opcjonalnie"
|
|
if(e.target.id === "register_client_checkbox"){
|
|
const registerForm = document.querySelector(".register__form");
|
|
if(e.target.checked) registerForm.classList.add("--fade-in");
|
|
else registerForm.classList.remove("--fade-in");
|
|
return;
|
|
}
|
|
|
|
// Ukrycie/Pokazanie hasła
|
|
if(e.target.id === "toggle_password") return togglePassword(e.target);
|
|
|
|
// Sprawdzenie czy kliknięcie było na firmę, czy na osobę prywatną
|
|
if(e.target.id === "client_type1") return document.querySelectorAll("#cop_seection1 .firm-group").forEach(el => el.classList.add("--fade-in"));
|
|
if(e.target.id === "client_type2") return document.querySelectorAll("#cop_seection1 .firm-group").forEach(el => el.classList.remove("--fade-in"));
|
|
|
|
// Sprawdzenie czy dostawa na inny adres czy nie
|
|
if(e.target.id === "deliver_to_billingaddr"){
|
|
let ifBillingaddr = false;
|
|
if(e.target.checked) ifBillingaddr = true;
|
|
return showDeliveryForm(ifBillingaddr);
|
|
}
|
|
|
|
// Sprawdzenie czy kliknięcie będzie na guzik "Wybierz z listy adresów" i pokazanie popupa
|
|
if(e.target.classList.contains("delivery__address-list-button")){
|
|
app_shop.fn.addressModal = new Modal({
|
|
element: $(".delivery__address-list-container"),
|
|
classList: "--fade-in-modal",
|
|
afterShow: () => {
|
|
disablePageScroll();
|
|
document.querySelector(".delivery__address-list").addEventListener("click", handleClickAddressList);
|
|
},
|
|
beforeClose: () => {
|
|
enablePageScroll();
|
|
document.querySelector(".delivery__address-list").removeEventListener("click", handleClickAddressList);
|
|
},
|
|
});
|
|
return;
|
|
}
|
|
});
|
|
|
|
// Pokaż/schowaj hasło
|
|
function togglePassword(el){
|
|
const passwordInput = document.querySelector(".register__password");
|
|
let showPassword = false;
|
|
if(passwordInput.type === "password") showPassword = true;
|
|
|
|
passwordInput.type = showPassword ? "text" : "password";
|
|
el.classList.remove(showPassword ? "register__show-password" : "register__hide-password");
|
|
el.classList.add(showPassword ? "register__hide-password" : "register__show-password");
|
|
el.innerHTML = showPassword ? `${<iai:variable vid="Ukryj hasło"/>}` : `${<iai:variable vid="Pokaż hasło"/>}`;
|
|
}
|
|
|
|
// Pokaż popup logowania
|
|
function showSigninModal(){
|
|
app_shop.fn.signinModal = new Modal({
|
|
element: $("#signin-form-ajax"),
|
|
classList: "--fade-in-modal",
|
|
afterShow: ()=>{
|
|
disablePageScroll();
|
|
document.querySelector(".signin_login_input").addEventListener("keydown", logInOnEnter);
|
|
document.querySelector(".signin_pass_input").addEventListener("keydown", logInOnEnter);
|
|
},
|
|
beforeClose: ()=>{
|
|
enablePageScroll();
|
|
document.querySelector(".signin_login_input").removeEventListener("keydown", logInOnEnter);
|
|
document.querySelector(".signin_pass_input").removeEventListener("keydown", logInOnEnter);
|
|
},
|
|
});
|
|
}
|
|
|
|
// Pokaż(true)/Schowaj(false) formularz dostawy na inny adres
|
|
function showDeliveryForm(style){
|
|
const deliveryWrapper = document.querySelector(".ajax_cop #client_new_additional .delivery_box.cn_wrapper");
|
|
if((style && deliveryWrapper.classList.contains("--more")) || (!style && !deliveryWrapper.classList.contains("--more"))) return;
|
|
|
|
// formularz dostawy na inny adres
|
|
style ? deliveryWrapper.classList.add("--more") : deliveryWrapper.classList.remove("--more");
|
|
|
|
// przycisk od wybierania z listy adresów
|
|
listBtn = document.querySelector(".delivery__address-list-button");
|
|
if(listBtn) style ? listBtn.classList.add("--fade-in") : listBtn.classList.remove("--fade-in");
|
|
|
|
// Zmiana regionu jeśli region klienta różni się od regionu dostawy
|
|
const deliveryRegion = document.getElementById("delivery_region").value;
|
|
const clientRegion = document.getElementById("client_region").value;
|
|
if(deliveryRegion !== clientRegion) changeRegion();
|
|
}
|
|
|
|
// EventListener listy adresów
|
|
function handleClickAddressList(e){
|
|
const addressLi = e.target.closest("li");
|
|
if(!addressLi) return;
|
|
|
|
// Uzupełnienie informacji o formularzu
|
|
const addressForm = document.querySelector(".delivery_box.cn_wrapper");
|
|
changeDeliveryValue("#delivery_firstname", addressLi.dataset.firstname);
|
|
changeDeliveryValue("#delivery_lastname", addressLi.dataset.lastname);
|
|
|
|
const firmName = addressForm.querySelector("#delivery_additional");
|
|
if(addressLi.dataset.additional) {
|
|
firmName.value = addressLi.dataset.additional;
|
|
firmName.classList.add("focused");
|
|
addSuccess(firmName);
|
|
}
|
|
else {
|
|
firmName.value = "";
|
|
firmName.classList.remove("focused");
|
|
clearValidation(firmName);
|
|
}
|
|
changeDeliveryValue("#delivery_street", addressLi.dataset.street);
|
|
changeDeliveryValue("#delivery_zipcode", addressLi.dataset.zipcode);
|
|
changeDeliveryValue("#delivery_city", addressLi.dataset.city);
|
|
changeDeliveryValue("#delivery_phone", addressLi.dataset.phone);
|
|
|
|
// Zmień państwo i przeładuj metody płatności jeśli jest inny
|
|
const deliveryRegion = addressForm.querySelector("#delivery_region");
|
|
if(deliveryRegion.value !== addressLi.dataset.region_id) {
|
|
addressForm.querySelector("#delivery_region").value = addressLi.dataset.region_id;
|
|
changeRegion();
|
|
}
|
|
|
|
// nadanie klasy aktywnemu adresowi
|
|
e.target.closest("ul").querySelectorAll("li").forEach(el => el.classList.remove("--active-address"));
|
|
addressLi.classList.add("--active-address");
|
|
|
|
// Zamkniencie modala
|
|
setTimeout(() => app_shop.fn.addressModal.closeModal(),100)
|
|
}
|
|
|
|
// Zmień wartości pól input delivery
|
|
function changeDeliveryValue(selector, newValue){
|
|
const selectedInput = document.querySelector(selector);
|
|
selectedInput.value = newValue;
|
|
addSuccess(selectedInput);
|
|
selectedInput.classList.add("focused")
|
|
}
|
|
|
|
// OBSŁUGA LOGOWANIA
|
|
const SIGNIN = (signinInput) => JSON.stringify({
|
|
query: `mutation {
|
|
login(${signinInput}) {
|
|
status
|
|
}
|
|
}`,
|
|
});
|
|
|
|
function logInOnEnter(e){
|
|
if(e.key==="Enter") logInToAccount(false)
|
|
}
|
|
const signinForm = document.querySelector(".signin-form_box_text form");
|
|
if(signinForm) signinForm.addEventListener("submit", logInToAccount);
|
|
|
|
async function logInToAccount(event){
|
|
if(event) event.preventDefault();
|
|
const login = document.querySelector(".signin_login_input").value;
|
|
const password = document.querySelector(".signin_pass_input").value;
|
|
const loginStatus = await fetchData({
|
|
data: SIGNIN(`
|
|
login: "${login.replace(/"/g, '\\"')}",
|
|
password: "${password.replace(/"/g, '\\"')}",
|
|
`),
|
|
linkParameter: '?mutation=signin',
|
|
alert: false,
|
|
});
|
|
if (loginStatus.errors) {
|
|
Alertek.show_alert(`${<iai:variable vid="Podany login lub hasło nie jest poprawne"/>}`);
|
|
return;
|
|
}
|
|
app_shop.fn.signinModal.closeModal();
|
|
getClientNew();
|
|
|
|
if(document.querySelector(".order2_terms_wrapper_sub.email")) document.querySelector(".order2_terms_wrapper_sub.email").remove();
|
|
if(document.querySelector(".order2_terms_wrapper_sub.sms")) document.querySelector(".order2_terms_wrapper_sub.sms").remove();
|
|
}
|
|
|
|
// Zalogowanie/inicjacja użytkownika
|
|
function getClientNew(){
|
|
console.log("fn: getClientNew");
|
|
app_shop.fn.ajaxLoadSite(1);
|
|
|
|
// Przygotowanie jesli użytkownik nie jest zalogowany
|
|
if(!document.querySelector(".--logged")) document.getElementById("client_form").remove();
|
|
document.querySelector(".step1_sub").insertAdjacentHTML("beforeend",'<div class="signup"></div>');
|
|
$.ajax({
|
|
url: "/client-new.php?ajax=true&set_render=content",
|
|
timeout: 16e3,
|
|
complete: function (e, a) {
|
|
throwAjaxError(a);
|
|
app_shop.fn.ajaxLoadSite(0);
|
|
},
|
|
success: function (e, a) {
|
|
app_shop.fn.load(
|
|
"place-order.php",
|
|
[["#cop_seection1", "#cop_seection1"]],
|
|
function () {
|
|
history.go(-1);
|
|
},
|
|
"?set_render=content"
|
|
).then(() => {
|
|
changeRegion();
|
|
})
|
|
},
|
|
});
|
|
};
|
|
|
|
/////////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
// WALIDACJA
|
|
|
|
// wyczyść klasy walidacji
|
|
function clearValidation(input){
|
|
const wrapper = input.closest(".has-feedback")
|
|
wrapper.classList.remove('--success', '--error', 'has-error', 'has-success');
|
|
};
|
|
// wyczyść wiadomość błędu
|
|
function removeErrorMessage(input) {
|
|
const valMessage = input.closest('.has-feedback').querySelector('.validate_message');
|
|
if(valMessage) valMessage.remove();
|
|
};
|
|
// dodaj klasy błędu
|
|
function addError(input){
|
|
clearValidation(input);
|
|
removeErrorMessage(input);
|
|
const wrapper = input.closest(".has-feedback");
|
|
clearValidation(wrapper);
|
|
wrapper.classList.add('--error', 'has-error');
|
|
};
|
|
// dodaj klasy sukcesu
|
|
function addSuccess(input){
|
|
clearValidation(input);
|
|
removeErrorMessage(input);
|
|
const wrapper = input.closest(".has-feedback");
|
|
clearValidation(wrapper);
|
|
wrapper.classList.add('--success', 'has-success');
|
|
};
|
|
// dodaj error wraz z wiadomością
|
|
function addErrorMessage(input, message){
|
|
addError(input);
|
|
input.closest('.has-feedback').insertAdjacentHTML("beforeend",`<span class="help-block validate_message text-danger">${message}.</span>`);
|
|
}
|
|
// waliduj elementy wymagające wysłania requesta (zipcode, nip)
|
|
async function validateRequest(target, order=false){
|
|
const wrapper = target.closest(".has-feedback");
|
|
let reqData = `${target.name}=${target.value}`;
|
|
|
|
if(target.dataset.serialize) {
|
|
const serializeEl = document.querySelector(target.dataset.serialize);
|
|
reqData += '&' + `${serializeEl.name}=${encodeURIComponent(serializeEl.value)}`;
|
|
}
|
|
if(target.dataset.revalidate) {
|
|
target.dataset.revalidate.split(",").forEach(elQuery => {
|
|
validateRequest(document.querySelector(elQuery));
|
|
})
|
|
}
|
|
if(target.value === '') {
|
|
addErrorMessage(target, <iai:variable vid="Proszę wypełnić to pole"/>);
|
|
return false;
|
|
}
|
|
|
|
const resData = await $.ajax({
|
|
url: '/ajax/client-new.php?validAjax=true',
|
|
type: 'POST',
|
|
timeout: 16000,
|
|
dataType: 'JSON',
|
|
data: reqData,
|
|
});
|
|
|
|
if(resData.errno) {
|
|
let error_message = '';
|
|
if (resData.message.error_code) {
|
|
if (resData.message.zipcode_pattern && (resData.message.error_code === 'incorect_zipcode' || resData.message.error_code === 'incorect_delivery_zipcode')) {
|
|
error_message = clientNewErrorCode[resData.message.error_code] + ' ' + `${<iai:variable vid="Poprawne formaty kodu pocztowego dla wybranego kraju to [X - cyfra; Y - litera"/>}]:` + ' ';
|
|
error_message += resData.message.zipcode_pattern.join(', ');
|
|
}
|
|
else if (clientNewErrorCode[resData.message.error_code]) error_message = clientNewErrorCode[resData.message.error_code];
|
|
}
|
|
addError(target);
|
|
if (error_message) addErrorMessage(target, error_message);
|
|
return false
|
|
}else{
|
|
addSuccess(target);
|
|
if (target.name==="client_email" && !order) {
|
|
$.ajax({
|
|
url: '/ajax/client-new.php?checkClientExists=true',
|
|
type: 'POST',
|
|
timeout: 16000,
|
|
dataType: 'JSON',
|
|
data: {'client_mail': target.value},
|
|
}).then(function succesFn(resData) {
|
|
if(resData.client_exists === true || resData.login) showEmailPopup(resData);
|
|
});
|
|
}
|
|
return true;
|
|
}
|
|
};
|
|
// Pokaż popup jeśli użytkownik wpisał email który posiada już konto
|
|
function showEmailPopup(resData){
|
|
app_shop.fn.emailModal = new Modal({
|
|
html: `
|
|
<div class="propose_main">
|
|
<div class="propose_info">
|
|
<span class="propose_title">${<iai:variable vid="Mamy już zarejestrowane konto dla podanego adresu e-mail"/>}</span>
|
|
<span class="propose_text">${<iai:variable vid="Adres e-mail"/>}:</span>
|
|
<div class="propose_json_mail">
|
|
${resData.mail}
|
|
</div>
|
|
</div>
|
|
<p class="cn_propose_desc">
|
|
${<iai:variable vid="Proponujemy Ci użycie tego konta, co pozwoli Ci korzystać z przywilejów zarezerwowanych dla wielokrotnych klientów. Aby się zalogować na wcześniej założone konto, wystarczy kliknięcie na link, który możemy Ci wysłać w e-mailu"/>}
|
|
</p>
|
|
<div class="cn_propose_desc">
|
|
<div>
|
|
<a class="bm-oscop__btn button_password_recover"href="/password-recover.php?operation=recover&email=${resData.mail}">
|
|
${<iai:variable vid="Wyślij e-mail"/>}
|
|
</a>
|
|
</div>
|
|
<div>
|
|
<a href="/signin.php" id="mail_propose_signin" onclick="handleShowSigninModalFromEmailModal(event)">
|
|
${<iai:variable vid="Pamiętam swój login i hasło i mogę je podać"/>}
|
|
</a>
|
|
</div>
|
|
<div>
|
|
<a href="#close" class="place-order__close_toplayer_link" id="mail_propose_close" onclick="app_shop.fn.emailModal.closeModal()">
|
|
${<iai:variable vid="Chcę stworzyć nowe konto przy użyciu tego adresu (niezalecane)"/>}
|
|
</a>
|
|
</div>
|
|
</div>
|
|
</div>`,
|
|
classList: "--fade-in-modal",
|
|
afterShow: disablePageScroll,
|
|
beforeClose: enablePageScroll,
|
|
});
|
|
return;
|
|
}
|
|
function handleShowSigninModalFromEmailModal(e){
|
|
e.preventDefault();
|
|
app_shop.fn.emailModal.closeModal();
|
|
showSigninModal();
|
|
}
|
|
|
|
// event listener zmian w kontenerze cop_seection1
|
|
const validateRequestId = ["client_zipcode", "delivery_zipcode", "client_nip", "client_email"];
|
|
const notEmptyFieldsId = ["client_firstname", "client_lastname", "client_city", "delivery_firstname", "delivery_lastname", "delivery_city", "client_firm"];
|
|
document.getElementById("cop_seection1").addEventListener("change", (e) => {
|
|
// walidacja zipcode, nipu i emaila
|
|
if(validateRequestId.includes(e.target.id)) return validateRequest(e.target);
|
|
|
|
// zmiana regionu
|
|
if(e.target.name === "client_region" || e.target.name === "delivery_region") {
|
|
const clientType = e.target.name.split("_")[0];
|
|
validateRequest(document.getElementById(`${clientType}_zipcode`));
|
|
if(clientType === "client" && document.getElementById("client_type1").checked === true) validateRequest(document.getElementById("client_nip"));
|
|
changeRegion();
|
|
return;
|
|
}
|
|
|
|
// Walidacja ulicy i numeru domu
|
|
if(e.target.id === "client_street" || e.target.id === "delivery_street") validateStreet(e.target);
|
|
// Walidacja numeru telefonu
|
|
if(e.target.id === "client_phone" || e.target.id === "delivery_phone") validatePhone(e.target);
|
|
// Walidacja loginu i hasła rejestracji
|
|
if(e.target.classList.contains("register__login")) testLogin();
|
|
if(e.target.classList.contains("register__password")) testPassword();
|
|
// Walidacja imienia nazwiska miasta i firmy(wymagające po prostu nie bycia pustym)
|
|
if(notEmptyFieldsId.includes(e.target.id)) validateNotEmpty(e.target);
|
|
|
|
// Sprawdzenie czy firma w dostawie na inny adres została wpisana
|
|
if(e.target.id === "delivery_additional"){
|
|
if(e.target.value.length > 0) addSuccess(e.target);
|
|
else clearValidation(e.target);
|
|
};
|
|
});
|
|
// funkcje walidacji poszczególnych elementów
|
|
function validateStreet(streetEl){
|
|
const streetParts = streetEl.value.split(" ");
|
|
const addressNumber = Number(streetParts[streetParts.length-1][0]);
|
|
if(streetEl.value.length === 0 || (streetEl.value.length > 0 && (!addressNumber || streetParts.length < 2))){
|
|
addErrorMessage(streetEl, <iai:variable vid="Wpisz nazwę ulicy lub miejscowości i numer domu"/>);
|
|
return false;
|
|
}else{
|
|
addSuccess(streetEl);
|
|
return true;
|
|
}
|
|
}
|
|
function validatePhone(streetEl){
|
|
const phoneNumber = streetEl.value.replaceAll(" ","");
|
|
if(phoneNumber.length===0 || (phoneNumber.length > 0 && !(Number(phoneNumber)) || phoneNumber.length<9)){
|
|
addErrorMessage(streetEl, <iai:variable vid="Wpisz swój telefon"/>);
|
|
return false;
|
|
}else {
|
|
addSuccess(streetEl);
|
|
return true;
|
|
}
|
|
}
|
|
function validateNotEmpty(checkEl){
|
|
if(checkEl.value.length < 1) {
|
|
addErrorMessage(checkEl, <iai:variable vid="Proszę wypełnić to pole"/>);
|
|
return false;
|
|
}
|
|
else{
|
|
addSuccess(checkEl);
|
|
return true;
|
|
}
|
|
}
|
|
|
|
// Sprawdzenie loginu i hasla
|
|
function testLogin(){
|
|
const login = document.querySelector(".register__login");
|
|
if(login.value.trim().length < 1){
|
|
addErrorMessage(login, <iai:variable vid="Proszę wypełnić to pole"/>);
|
|
return false;
|
|
}
|
|
else if(!/^[A-Za-z0-9@._-]*$/.test(login.value.trim()) || Number(login.value.trim()) || login.value.trim().length<3){
|
|
addErrorMessage(login, <iai:variable vid="Login musi mieć minimum 3, a maksimum 40 znaków. Możesz użyć liter i cyfr oraz symboli @ . - _"/>);
|
|
return false;
|
|
}else{
|
|
addSuccess(login);
|
|
return true;
|
|
}
|
|
}
|
|
function testPassword(){
|
|
const repeatPassword = document.getElementById("repeat_password");
|
|
const password = document.querySelector(".register__password");
|
|
repeatPassword.value = password.value;
|
|
if(password.value.trim().length < 1){
|
|
addError(password);
|
|
password.closest('.has-feedback').insertAdjacentHTML("beforeend", `<span class="help-block validate_message text-danger">${<iai:variable vid="Proszę wypełnić to pole"/>}.</span>`);
|
|
return false;
|
|
}
|
|
if(password.value.trim().length < 6){
|
|
addError(password);
|
|
password.closest('.has-feedback').insertAdjacentHTML("beforeend", `<span class="help-block validate_message text-danger">${<iai:variable vid="Hasło musi składać się z minimum 6 znaków"/>}.</span>`);
|
|
return false;
|
|
}else{
|
|
addSuccess(password);
|
|
return true;
|
|
}
|
|
}
|
|
|
|
// Obsługa przesuwających się labelek
|
|
document.querySelector("body").addEventListener("change", (e) => {
|
|
if(e.target.classList.contains("f-control")){
|
|
if(e.target.value.length > 0) e.target.classList.add("focused");
|
|
else e.target.classList.remove("focused");
|
|
}
|
|
})
|
|
|
|
///////////////////////////////////////////////////////////////////////
|
|
// DOSTAWA I PŁATNOSĆI
|
|
|
|
const SET_REGION = (setRegionInput) => JSON.stringify({
|
|
query: `mutation {
|
|
setRegion(${setRegionInput}) {
|
|
status
|
|
error {
|
|
code
|
|
message
|
|
}
|
|
}
|
|
}`,
|
|
});
|
|
|
|
// Zmiana regionu dostawy
|
|
async function changeRegion(payAndDelData = null, firstLoad = false) {
|
|
console.log("fn: changeRegion");
|
|
|
|
// Pobranie informacji o regionie z formularza
|
|
const clientRegion = document.getElementById("client_region").value;
|
|
const deliveryRegion = document.getElementById("deliver_to_billingaddr").checked ? document.getElementById("delivery_region").value : clientRegion;
|
|
|
|
|
|
|
|
// Zmiana regionu
|
|
const regionStatus = await this.fetchData({
|
|
data: SET_REGION(`SetRegionInput: {
|
|
billingRegionId: ${clientRegion},
|
|
deliveryRegionId: ${deliveryRegion},
|
|
areForced: true
|
|
}`),
|
|
linkParameter: '?mutation=setRegion',
|
|
});
|
|
const { status } = regionStatus?.data?.setRegion || {};
|
|
if (status !== 'success') return alert("Błąd podczas zmiany kraju. Przeładuj stronę jeszcze raz.");
|
|
|
|
// Pobranie nowych metod płatności i dostaw
|
|
getNewPaymentsAndDeliveries(payAndDelData, firstLoad);
|
|
};
|
|
|
|
// załadowanie metod dostaw i płatności
|
|
function getNewPaymentsAndDeliveries(data = null, firstLoad = false) {
|
|
console.log("fn: order1_new");
|
|
// Wyczyszczenie zapisanych poprzednich metod płatności
|
|
prevPayment = undefined;
|
|
prevShipping = undefined;
|
|
// Wyczyszczenie punktow odbioru
|
|
deliveryPickupPoints.length = 0;
|
|
app_shop.fn.ajaxLoadSite(1);
|
|
|
|
// Dane do uzupełnienia przy edycji
|
|
let paymentValue, deliveryId;
|
|
if(data){
|
|
paymentValue = data.paymentMethodId;
|
|
deliveryId = `item_${data.deliveryMethodId}-${paymentValue === "cash" ? "0" : "1"}`;
|
|
}
|
|
|
|
// Pobranie metod płatności i dostawy
|
|
$.ajax({
|
|
url: "/ajax/get-deliveries.php?mode=productAndBasket&prepaids=true",
|
|
dataType: "json",
|
|
timeout: 1e4,
|
|
async: !0,
|
|
complete: function (e, a) {
|
|
throwAjaxError(a);
|
|
app_shop.fn.ajaxLoadSite(0);
|
|
},
|
|
success: function (e) {
|
|
let prepaidMarkup = "";
|
|
|
|
// Stworzenie markupa dla metod dostaw
|
|
e.prepaid.forEach(function (method) {
|
|
prepaidMarkup += prepareDeliveryMarkup(method, deliveryId);
|
|
});
|
|
|
|
// Stworzenie markupa dla metod dostaw (dla płatności przy odbiorze)
|
|
let dvpMarkup = "";
|
|
e.dvp.forEach(function (method) {
|
|
dvpMarkup += prepareDeliveryMarkup(method, deliveryId);
|
|
});
|
|
|
|
// Wstawienie metod dostaw na strone
|
|
const deliveryMarkup = `<div id="osc_order1"><div id="osc_order1_prepaid" style="${paymentValue === "cash" ? "display:none;" : "display:block;"}">${prepaidMarkup}</div><div id="osc_order1_dvp" style="${paymentValue === "cash" ? "display:block;" : "display:none;"}">${dvpMarkup}</div></div>`;
|
|
const previousDeliveries = document.getElementById("osc_order1");
|
|
if(previousDeliveries) previousDeliveries.remove();
|
|
document.querySelector(".ajax_cop .step2_sub").insertAdjacentHTML("beforeend",deliveryMarkup);
|
|
|
|
// Stworzenie metod płatności
|
|
let prepaidsMethodMarkup = "";
|
|
let prepaidsTransferMarkup = createPaymentContainerMarkup("transfer");
|
|
let prepaidsCardMarkup = createPaymentContainerMarkup("card");
|
|
|
|
// Sprawdzenie czy sklep ma możliwość płatności bankiem/kartą
|
|
let ifPaymentTransfer = false;
|
|
let ifPaymentCard = false;
|
|
|
|
// Przygotowanie Płatności
|
|
e.prepaids_method.forEach(function (method) {
|
|
const checkedPayment = paymentValue === method.id;
|
|
|
|
const markup = `
|
|
<label class="osc_item" for="payitem_${method.id}">
|
|
<input id="payitem_${method.id}" value="${method.id}" type="radio" name="payform_id" ${checkedPayment ? "checked" : ""} data-group="${method.group}">
|
|
<div class="photo">
|
|
<img src="${method.icon}" alt="${method.name}">
|
|
</div>
|
|
<div class="name">
|
|
<span>${method.name}</span>
|
|
</div>
|
|
${2 == method.id ? '<div class="voucher-value" style="display:none;"></div>' : ""}
|
|
<div class="comment">${method.description}</div>
|
|
</label>`;
|
|
|
|
// Przygotowanie metod dla przelewów online/kart płatności
|
|
if(method.group === "transfer") {
|
|
prepaidsTransferMarkup += markup;
|
|
ifPaymentTransfer = true;
|
|
}
|
|
else if(method.group === "card"){
|
|
prepaidsCardMarkup += markup;
|
|
ifPaymentCard = true;
|
|
}
|
|
else{
|
|
prepaidsMethodMarkup += markup;
|
|
// okienko vouchera
|
|
if(method.id === 2){
|
|
prepaidsMethodMarkup += `
|
|
<div class="order__voucher_container osc_item-modal">
|
|
<div class="order__voucher_headlines">
|
|
<strong class="order__voucher_headline">Bon towarowy</strong>
|
|
<span class="order__voucher_description">Zapłać za zakupy bonem towarowym</span>
|
|
</div>
|
|
<div class="order__voucher_wrapper">
|
|
<div class="order__voucher_group --number f-group">
|
|
<div class="order__voucher_feedback f-feedback --required has-feedback">
|
|
<input id="order_voucher_id" class="order__voucher_input f-control form-control" value="" name="voucher_id" type="text">
|
|
<label class="order__voucher_label f-label" for="order_voucher_id">${<iai:variable vid="Numer bonu"/>}</label>
|
|
<span class="order__voucher_status f-control-feedback"></span>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<div class="order__voucher_buttons">
|
|
<button class="order__voucher_button bm-oscop__btn">${<iai:variable vid="Zatwierdź bon"/>}</button>
|
|
</div>
|
|
<small class="order__voucher_info">Jeżeli posiadasz więcej bonów, możesz wpisać ich numery przy podsumowaniu zamówienia.</small>
|
|
</div>`
|
|
}
|
|
}
|
|
});
|
|
prepaidsTransferMarkup +="</div></div></label>";
|
|
prepaidsCardMarkup +="</div></div></label>";
|
|
|
|
// Dołączenie metody płatność przy odbiorze
|
|
if(e.dvp.length) prepaidsMethodMarkup += `
|
|
<label class="osc_item" for="payitem_cash">
|
|
<input id="payitem_cash" value="cash" type="radio" name="payform_id" ${paymentValue === "cash" ? "checked" : ""}>
|
|
<div class="photo">
|
|
<img src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADIAAAAWCAIAAAANYFjGAAACvUlEQVR4Ac1XNZQsVRCtahufWXd3d43xDIcEh4wU9wR3+M4n2wQnwjXB3d1tfXtHu/u94vW89U3Wes/ceed21eg9t+T0QE1NTV8OoD8LGQtJ0NPTQzkGIUlRVRX2CLPm5LNvHEykFmB3EJIU2AtYdvqLH9987PlrP/7u9dfen7DtNBHBLrBbWUQ0OfvbW58+vpD+trOps668acb847m37vnxj3dhF9Bgm+CcASAAiTiViX/169t/TX+uqUY8xXVd7+8YzFhsZu7vv6a+rq8YVBUVFdVbt2wrfcfVl9525RkPXn3eozdf9PTzd7/47qHf/v4EGPh1o6q0rLm6uShWUlFY1Vo7WFne+OTEbbdecdq7rz7trVsL0//6pj7s7uwK+H3+aMSPcZolv9+P4EBiASdNm/9mcXK9JOJENWBiGf79w6dw4lkeylJUpaokVldV4guEfP4AAsqacgJijHGHC3JzRpwjZ0GFautq09F8b91CQKFM01Td0AyfIcaYVsC5K4xLVa4scWzbSiSS4jPetzxBVoNkyuZA3I0l5BURCbPfrhu//vzdPiwIFAdlhCJZAUlGFBFNTU5PTk5Pzy6Y8ZT511feuwUkDrosnVqB1IoKKvFEanExUd7YiU4SgZeWFu/POkXK2kTrfQJElBFxQoUVDdigR8J+BO65WyS7a90zklCwuHDimmFEQn7+51t+QzNNS4tWe+4WAqLLq0BJUq3L4DOMouLCqMHJTsyLHkso+1REqQyX0+XHuhlgnIiRIMeyvJVFy0S4zjp0YzkLa5xciknVdW97ixgT61EcxsFxGCqKXFvAXVeyK15eHbnHbMtSFG3stAt3K0veJMmR2oy8ksrx82+IRsKqoWuajihbShq4As4dJtcFZ3YwvzIQKXBjohVnJZEAgLL8W47tkOPoAb9Mc/SmOUf/YvwP3b7irCzN40MAAAAASUVORK5CYII=" alt="${<iai:variable vid="Płatność przy odbiorze"/>}">
|
|
</div>
|
|
<div class="name">
|
|
<span>${<iai:variable vid="Płatność przy odbiorze"/>}</span>
|
|
</div>
|
|
</label>`;
|
|
|
|
// Wstawienie metod płatności na stronę
|
|
const previousPayments = document.getElementById("osc_prepaids_method");
|
|
if(previousPayments) previousPayments.remove();
|
|
document.querySelector(".ajax_cop #checkout_step3_1 .step3_sub").insertAdjacentHTML("beforeend", `<div id="osc_prepaids_method"> ${ifPaymentTransfer ? prepaidsTransferMarkup : ""}${ifPaymentCard ? prepaidsCardMarkup : ""}${prepaidsMethodMarkup}</div>`);
|
|
|
|
// Wstawienie błędu jeśli metody płatności są puste
|
|
const currentPayments = document.getElementById("osc_prepaids_method");
|
|
if(document.getElementById("osc_prepaids_method").innerHTML === "") currentPayments.insertAdjacentHTML("beforeend",'<div class="menu_messages_warning" id="menu_messages_warning"><div class="menu_messages_message_sub"><p>' + <iai:variable vid="Brak metod płatności"/> + <iai:variable vid="w celu uzyskania informacji jak skompletować zamówienie"/> + ', <a href="/contact.php">' + `${<iai:variable vid="skontaktuj się z nami"/>}` + "</a></p></div></div>");
|
|
|
|
// Wstawienie pickuppoint jeśli edycja i istnieje
|
|
if(data?.pickupData !== undefined && data?.pickupData !== null){
|
|
const selectedShipping = document.querySelector(`#cop_seection2 input#${deliveryId}`);
|
|
checkPrevPickupPoint(
|
|
selectedShipping.parentElement.querySelector(".fselectedPoint"),
|
|
data.pickupData.id,
|
|
data.pickupData.name,
|
|
`${data.pickupData.address.street} ${data.pickupData.address.buildingAndHouseNumber}`,
|
|
data.pickupData.address.city,
|
|
data.pickupData.address.postcode,
|
|
data.deliveryMethodId
|
|
).then(pointExists=>{
|
|
// Odznaczenie punktu jeśli punkt odbioru nie istnieje(Wcześniej był zaznaczony przy edycji)
|
|
if(!pointExists) selectedShipping.checked = false;
|
|
});
|
|
}// Sprawdzenie czy użytkownik ma zapisane poprzednio użyte metody w przeglądarce(tylko przy pierwszym załadowaniu strony)
|
|
else if(localStorage.getItem("prevPaymentMethod") && localStorage.getItem("prevDeliveryMethod") && firstLoad){
|
|
const prevPaymentMethod = JSON.parse(localStorage.getItem("prevPaymentMethod"));
|
|
|
|
// Zaznaczenie metod płatności które nie tworzą popupa
|
|
if(prevPaymentMethod.id !== "payitem_2" && prevPaymentMethod.group !== "card" && prevPaymentMethod.group !== "transfer") document.getElementById(prevPaymentMethod.id).click();
|
|
else if(prevPaymentMethod.group === "card" || prevPaymentMethod.group === "transfer"){
|
|
const paymentMethodId = prevPaymentMethod.id.replace("-clone", "");
|
|
cloneElement(document.getElementById(paymentMethodId));
|
|
}
|
|
|
|
// poprzednia dostawa
|
|
const prevDeliveryMethod = JSON.parse(localStorage.getItem("prevDeliveryMethod"));
|
|
const prevDeliveryInput = document.querySelector(`input#${prevDeliveryMethod.id}`);
|
|
|
|
// Sprawdzenie czy istnieje metoda płatności(na wypadek gdyby była usunięta lub klient zamawiał do innego kraju)
|
|
if(prevDeliveryInput){
|
|
// sprawdzenie czy dostawa miała punkt odbioru
|
|
if(prevDeliveryMethod.fselectedPoint){
|
|
checkPrevPickupPoint(
|
|
prevDeliveryInput.parentElement.querySelector(".fselectedPoint"),
|
|
prevDeliveryMethod.fselectedPoint.deliveryPointId,
|
|
prevDeliveryMethod.fselectedPoint.name,
|
|
prevDeliveryMethod.fselectedPoint.street,
|
|
prevDeliveryMethod.fselectedPoint.city,
|
|
prevDeliveryMethod.fselectedPoint.zipcode,
|
|
prevDeliveryMethod.fselectedPoint.courierId
|
|
).then(pointExists=>{
|
|
if(pointExists) prevDeliveryInput.checked = true;
|
|
});
|
|
}else{
|
|
prevDeliveryInput.checked = true;
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
// Zaznaczenie karty/banku w przypadku edycji
|
|
const checkedPayment = document.querySelector(`#osc_prepaids_method input[name="payform_id"]:checked`)
|
|
if(checkedPayment && (checkedPayment.dataset.group === "card" || checkedPayment.dataset.group === "transfer")){
|
|
cloneElement(checkedPayment);
|
|
}
|
|
// Przeładowanie mapy
|
|
loadMap();
|
|
// Przeliczenie kosztu dostawy
|
|
calculateBasketCost();
|
|
// Zmiana daty dostawy i pokazanych opcji dostawy
|
|
const firstInput = document.getElementById("osc_order1 input");
|
|
if(firstInput) deliveryDate(firstInput.value, firstInput.dataset.delivery, firstInput.dataset.pickuppoint);
|
|
calculateBasketCost();
|
|
app_shop.fn.ajaxLoadSite(0);
|
|
},
|
|
});
|
|
};
|
|
// Stworzenie kontenera na "przelewy online" lub "karta platnicza"
|
|
function createPaymentContainerMarkup(method){
|
|
const operationName = method === "transfer" ? <iai:variable vid="Przelew online"/> : <iai:variable vid="Karta płatnicza"/>;
|
|
const methodName = method === "transfer" ? "banków" : "kart płatniczych";
|
|
return `<label class="osc_item" for="payitem_${method}">
|
|
<input id="payitem_${method}" value="no_${method}" type="radio" name="payform_id" data-group="${method}"/>
|
|
<div class="photo">
|
|
<img src="${`/gfx/standards/payment_group_${method}.svg`}" alt="${operationName}">
|
|
</div>
|
|
<div class="name">
|
|
<span>${operationName}</span>
|
|
</div>
|
|
<div class="osc_item-modal ${method}__methods">
|
|
<h2>Lista ${methodName}</h2>
|
|
<span>Wybierz z ${methodName}</span>
|
|
<div class="payments-container">`;
|
|
}
|
|
|
|
// Przygotowanie html dla metod dostaw
|
|
function prepareDeliveryMarkup(method, deliveryId){
|
|
// zapisanie do listy dostaw z mapą
|
|
if (method.pickuppoint === "y" && !deliveryPickupPoints.includes(method.id)) deliveryPickupPoints.push(method.id);
|
|
const cost = Number(method.cost) === 0 ? <iai:variable vid="Gratis!"/> : method.cost_formatted;
|
|
const disabled = method.minworthreached === "false" ? 'disabled="disabled"' : "";
|
|
const avaliableFrom = disabled ? '<span class="minworthtest_formatted">' + `${<iai:variable vid="Forma dostawy dostępna od"/>}: ` + method.minworthtest_formatted + "</span>" : "";
|
|
const ifChecked = deliveryId === `item_${method.id}`;
|
|
|
|
// Obliczenie daty dostawy
|
|
let date = new Date();
|
|
date.setDate(date.getDate()+method.time);
|
|
const deliveryDate = date.toLocaleDateString('en-GB').replaceAll("/", ".");
|
|
|
|
// uzupełnienie markupa dla metod dostaw dvp
|
|
return `<label class="osc_item" for="item_${method.id}">
|
|
<input id="item_${method.id}" value="${method.id}" type="radio" name="shipping" data-pickuppoint="${method.pickuppoint}" data-delivery="${method.time_days}#${method.time_hours}#${method.time_minutes}#${method.week_day}#${method.week_amount}#${method.time}" ${ifChecked ? "checked" : ""}>
|
|
<div class="photo">
|
|
<img src="${method.icon}" alt="${method.name}">
|
|
</div>
|
|
<div class="delivery_info">
|
|
<div class="name">
|
|
<span>${method.name}</span>
|
|
${avaliableFrom}
|
|
</div>
|
|
<div class="price ${cost === <iai:variable vid="Gratis!"/> ? `cost_free` :""}">${cost}</div>
|
|
</div>
|
|
<div class="delivery_date">
|
|
${<iai:variable vid="Przewidywana dostawa"/>}:
|
|
<strong>${orderTxt[`shipping${parseInt(method.week_day)}`]} ${deliveryDate}</strong>
|
|
</div>
|
|
${method.pickuppoint === "y" ? `<div class="fselectedPoint" style="padding:0;display:none;" for="item_${method.id}"></div>` : ""}
|
|
</label>`;
|
|
}
|
|
|
|
// Sprawdź czy poprzedni punkt odbioru dalej istnieje
|
|
const SEARCH_PICKUP_POINTS_QUERY = (searchPickupPointsInput) => JSON.stringify({
|
|
query: `query {
|
|
searchPickupPoints(${searchPickupPointsInput}) {
|
|
data
|
|
gps {
|
|
latitude
|
|
longitude
|
|
}
|
|
}
|
|
}`,
|
|
})
|
|
async function checkPrevPickupPoint(selectedPoint, deliveryPointId, name, street, city, zipcode, courierId){
|
|
if(!name || !city || !zipcode) return false;
|
|
// Pobranie punktów z tym samym id co poprzedni
|
|
app_shop.fn.ajaxLoadSite(1)
|
|
const resultData = await fetchData({
|
|
data: SEARCH_PICKUP_POINTS_QUERY(`
|
|
SearchPickupPointsInput: {
|
|
shippingId: ${courierId},
|
|
query: "${deliveryPointId}",
|
|
cashOnDelivery: false,
|
|
}
|
|
`),
|
|
linkParameter: "?query=searchPickupPoints",
|
|
});
|
|
app_shop.fn.ajaxLoadSite(0);
|
|
if(resultData?.error?.message) return false;
|
|
|
|
// Sprawdzenie czy poprzedni punkt dalej istnieje
|
|
let pointExists = false;
|
|
resultData.data.searchPickupPoints.forEach(point => {
|
|
if(point.data.includes(deliveryPointId)) pointExists = true;
|
|
})
|
|
// Utworzenie nowego punktu odbioru
|
|
if(pointExists) createPickuppointInfo(selectedPoint, deliveryPointId, name, street, city, zipcode, courierId);
|
|
return pointExists;
|
|
}
|
|
|
|
// Obsługa kliknięć na dostawy i metody płatności
|
|
let prevPayment;
|
|
let prevShipping;
|
|
function checkPrevShipping(){
|
|
if(prevShipping){
|
|
prevShipping.checked=true;
|
|
changeCurrentShippingInfo(prevShipping);
|
|
}
|
|
}
|
|
// Przeliczenie kosztu i czasu dostawy i zapisanie nowej metody dostawy
|
|
function changeCurrentShippingInfo(shippingMethod){
|
|
calculateBasketCost();
|
|
deliveryDate(shippingMethod.value, shippingMethod.dataset.delivery, shippingMethod.dataset.pickuppoint);
|
|
app_shop.vars.checkedShipping = shippingMethod.value;
|
|
}
|
|
document.getElementById("cop_seection2").addEventListener("click", e => {
|
|
// kliknięcie na dostawe
|
|
if(e.target.name === "shipping"){
|
|
// Wyczyszczenie wszystkich zaznaczonych punktów odbioru
|
|
clearSelectedPoints();
|
|
|
|
// Nie robienie niczego jeśli kliknąłeś na ten sam element
|
|
if(app_shop.vars.checkedShipping === e.target.value) return;
|
|
if(e.target.dataset.working_days) e.target.dataset.working_days.split("#").map(function (e) {return parseInt(e, 10);});
|
|
|
|
// zapisanie jako poprzednia metoda płatności jeśli nie wymaga wyboru punktu odbioru
|
|
if(e.target.dataset.pickuppoint === "n"){
|
|
prevShipping=e.target;
|
|
|
|
// Przeliczenie kosztu dostawy i czasu dostawy
|
|
changeCurrentShippingInfo(e.target);
|
|
}
|
|
return;
|
|
}
|
|
|
|
// kliknięcie na płatność
|
|
if(e.target.name === "payform_id"){
|
|
// Usunięcie klona poprzedniego przelewu online/ karty płatniczej
|
|
removePrevClone();
|
|
|
|
// Wyskakujące okienko od vouchera
|
|
if(e.target.value === "2" && (e.target.parentElement.querySelector(".voucher-value") && e.target.parentElement.querySelector(".voucher-value").style.display === "none")) {
|
|
app_shop.fn.voucherModal = new Modal({
|
|
element: $(".order__voucher_container"),
|
|
classList: "--fade-in-modal",
|
|
afterShow: () => {
|
|
disablePageScroll();
|
|
document.getElementById("order_voucher_id").addEventListener("keydown", handleClickVoucherEnter);
|
|
document.querySelector(".order__voucher_button").addEventListener("click", handleClickVoucherSubmit);
|
|
},
|
|
beforeClose: () => {
|
|
enablePageScroll();
|
|
document.getElementById("order_voucher_id").removeEventListener("keydown", handleClickVoucherEnter);
|
|
document.querySelector(".order__voucher_button").removeEventListener("click", handleClickVoucherSubmit);
|
|
|
|
// Odznacz/Zaznacz poprzedzni jeśli użytkownik nie podał poprawnego kodu
|
|
if(e.target.parentElement.querySelector(".voucher-value").style.display === "none"){
|
|
if(prevPayment) prevPayment.checked = true;
|
|
else e.target.checked = false;
|
|
}
|
|
},
|
|
});
|
|
return;
|
|
}
|
|
|
|
// Przelewy online i karty płatnosci
|
|
if(e.target.dataset.group === "transfer" || e.target.dataset.group === "card"){
|
|
if(!e.target.closest(".osc_item-modal")) showPaymentMethodModal(e.target.dataset.group);
|
|
return;
|
|
}
|
|
|
|
// Inne metody płatności
|
|
if(e.target.value !== "2" && e.target.dataset.group !== "transfer" && e.target.dataset.group !== "card"){
|
|
const voucherOptionContainer = document.getElementById("payitem_2").parentElement;
|
|
voucherOptionContainer.querySelector(".comment").style.display = "block";
|
|
voucherOptionContainer.querySelector(".voucher-value").style.display = "none";
|
|
voucherOptionContainer.querySelector(".voucher-value").innerHTML = ``;
|
|
}
|
|
|
|
// Zmien metody dostawy pomiedzy prepaid a dvp
|
|
if(!prevPayment && e.target.id === "payitem_cash") changeDeliveryOptions();
|
|
if(prevPayment && e.target.id !== prevPayment.id && (e.target.id === "payitem_cash" || prevPayment.id==="payitem_cash")) changeDeliveryOptions();
|
|
prevPayment = e.target;
|
|
}
|
|
});
|
|
|
|
// Schowanie sklonowanej metody płatności
|
|
function removePrevClone(){
|
|
const prevClone = document.querySelector(".osc_item-clone");
|
|
if(!prevClone) return;
|
|
const cloneGroupName = prevClone.querySelector("input").dataset.group;
|
|
document.getElementById(`payitem_${cloneGroupName}`).closest(".osc_item").style.display="flex";
|
|
prevClone.remove();
|
|
}
|
|
|
|
// Utworzenie modala po kliknieciu na "przelewy online" lub "karta platnicza"
|
|
let ifChosenNewPaymentMethod = false;
|
|
function showPaymentMethodModal(method){
|
|
app_shop.fn.paymentModal = new Modal({
|
|
element: $(`.${method}__methods`),
|
|
classList: "--fade-in-modal",
|
|
afterShow: () => {
|
|
disablePageScroll();
|
|
document.querySelectorAll(`.${method}__methods .osc_item input`).forEach(el => {
|
|
el.addEventListener("click", handlePaymentMethodClick);
|
|
})
|
|
},
|
|
beforeClose: () => {
|
|
enablePageScroll();
|
|
if(!ifChosenNewPaymentMethod) prevPayment ? prevPayment.checked = true : document.getElementById(`payitem_${method}`).checked = false;
|
|
document.querySelectorAll(`.${method}__methods .osc_item input`).forEach(el => {
|
|
el.removeEventListener("click", handlePaymentMethodClick);
|
|
})
|
|
ifChosenNewPaymentMethod=false;
|
|
},
|
|
})
|
|
}
|
|
|
|
// Metoda oblugujaca kliknieca w metody platnosci w popupie
|
|
function handlePaymentMethodClick(e){
|
|
// usuń poprzedni klon i stwórz nowy
|
|
removePrevClone();
|
|
cloneElement(e.target);
|
|
|
|
// zamkniecie modala
|
|
ifChosenNewPaymentMethod = true;
|
|
app_shop.fn.paymentModal.closeModal();
|
|
return false;
|
|
}
|
|
function cloneElement(originalPaymentElement){
|
|
// sklonowanie kliknietego elementu
|
|
const clonedMethod = originalPaymentElement.closest(".osc_item").cloneNode(true);
|
|
const clonedInput = clonedMethod.querySelector("input");
|
|
|
|
// Zmiana id i klasy sklonowanego elementu dla rozróżnienia
|
|
clonedInput.id = clonedInput.id+"-clone";
|
|
clonedMethod.setAttribute("for", clonedInput.id);
|
|
clonedMethod.classList.add("osc_item-clone");
|
|
|
|
// Wstawienie klona po "przelewy online" lub "karta platnicza"
|
|
const standInEl = document.getElementById(`payitem_${clonedInput.dataset.group}`).closest(".osc_item");
|
|
standInEl.after(clonedMethod);
|
|
standInEl.style.display = "none";
|
|
clonedInput.checked = true;
|
|
}
|
|
|
|
|
|
// Zmiana opcji dostawy zależnie od płatności
|
|
function changeDeliveryOptions(){
|
|
if(document.getElementById("payitem_cash") && document.getElementById("payitem_cash").checked) changePrepaidDvp("none", "block");
|
|
else changePrepaidDvp("block", "none");
|
|
|
|
document.querySelectorAll("#checkout_step2_1 input").forEach((el) => el.checked = false);
|
|
app_shop.vars.checkedShipping = "";
|
|
calculateBasketCost();
|
|
}
|
|
|
|
// zmień pokazane metody dostawy
|
|
function changePrepaidDvp(prepaidStyle, dvpStyle){
|
|
const prepaid = document.getElementById("osc_order1_prepaid");
|
|
const dvp = document.getElementById("osc_order1_dvp");
|
|
prepaid.style.display = prepaidStyle;
|
|
dvp.style.display = dvpStyle;
|
|
clearSelectedPoints();
|
|
}
|
|
|
|
// Wyczyszczenie informacji o punktach odbioru
|
|
function clearSelectedPoints(){
|
|
const fSelectedPoints = document.querySelectorAll("#osc_order1 .fselectedPoint");
|
|
fSelectedPoints.forEach(el => {
|
|
el.innerHTML="";
|
|
el.style.display="none";
|
|
});
|
|
}
|
|
// Zatwierdź bon towarowy enterem
|
|
function handleClickVoucherEnter(e){
|
|
if(e.key === "Enter") handleClickVoucherSubmit();
|
|
}
|
|
|
|
// Zatwierdź bon towarowy
|
|
function handleClickVoucherSubmit(){
|
|
const voucherNumber = document.getElementById("order_voucher_id");
|
|
const voucherRadioButton = document.getElementById("payitem_2");
|
|
const voucherOptionContainer = voucherRadioButton.parentElement;
|
|
$.ajax({
|
|
url: "/ajax/gift-cards-and-vouchers.php",
|
|
type: "POST",
|
|
timeout: 16000,
|
|
data: `action=auth&number=${voucherNumber.value}`,
|
|
complete: function (e, a) {
|
|
throwAjaxError(a);
|
|
},
|
|
success: function (e) {
|
|
// Jeśli nieprawidłowy kod wyświetl błąd
|
|
if(e.errno !== "0"){
|
|
addErrorMessage(voucherNumber, <iai:variable vid="Wprowadzony kod jest niepoprawny"/>);
|
|
return;
|
|
}
|
|
|
|
// Zmien z dvp na prepaid jesli wcześniej była zapłata za pobraniem
|
|
if(prevPayment && voucherRadioButton.id !== prevPayment.id && prevPayment.id === "payitem_cash") changeDeliveryOptions();
|
|
prevPayment = e.target;
|
|
|
|
// Pokaż cenę
|
|
voucherOptionContainer.querySelector(".comment").style.display = "none";
|
|
voucherOptionContainer.querySelector(".voucher-value").style.display = "block";
|
|
voucherOptionContainer.querySelector(".voucher-value").innerHTML = `${e.result.value} ${e.result.currency}`;
|
|
|
|
// Wyczyść walidacje
|
|
removeErrorMessage(voucherNumber);
|
|
clearValidation(voucherNumber);
|
|
|
|
// Zamknij modal
|
|
app_shop.fn.voucherModal.closeModal();
|
|
},
|
|
})
|
|
}
|
|
|
|
//////////////////////////////////////////////////////////////////////
|
|
// PODSUMOWANIE
|
|
|
|
// Przeliczenie i pokazanie ceny w podsumowaniu
|
|
let xhrs;
|
|
const productsWorthPriceEl = document.querySelector("#order2_products_worth .operation_value");
|
|
const deliveryCostEl = document.querySelector("#order2_shipping_value .operation_value");
|
|
const paymentCostEl = document.querySelector("#order2_paymentcost_value .operation_value");
|
|
const insuranceValueEl = document.querySelector("#order2_insurance_value .operation_value");
|
|
const totalRebateEl = document.querySelector("#order2_total_rebate .operation_value");
|
|
const saldoValueEl = document.querySelector("#order2_saldo_value .operation_value");
|
|
const productsPointsEl = document.querySelector("#order2_products_points .operation_value");
|
|
const summaryCostEl = document.getElementById("summary-cost");
|
|
const summaryPointsEl = document.getElementById("summary-points");
|
|
function calculateBasketCost() {
|
|
// przygotowanie informacji o metodzie dostawy i platnosci
|
|
const orderInfo = {
|
|
delivery: document.querySelector('.ajax_cop input[name="shipping"]:checked') ? document.querySelector('.ajax_cop input[name="shipping"]:checked').value : "0-1",
|
|
payform_id: document.querySelector('.ajax_cop input[name="payform_id"]:checked') ? document.querySelector('.ajax_cop input[name="payform_id"]:checked').value : "cash"
|
|
}
|
|
xhrs && 4 != xhrs.readyState && 0 != xhrs.readyState && xhrs.abort(),
|
|
xhrs = $.ajax({
|
|
url: "/ajax/basket-cost.php",
|
|
dataType: "json",
|
|
data: orderInfo,
|
|
success: function (t) {
|
|
productsWorthPriceEl.innerHTML = formatPrice(t.products_worth, t.currency_sign) + "<small>" + orderTxt.gross + "</small>";
|
|
|
|
// Sprawdź cene dostawy
|
|
if(t.shipping_undefined) deliveryCostEl.parentElement.style.display = "none";
|
|
else {
|
|
deliveryCostEl.parentElement.style.display = "flex";
|
|
deliveryCostEl.classList.remove("cost_free");
|
|
if(t.shipping_cost_points) deliveryCostEl.innerHTMl = `${t.shipping_cost_points}${<iai:variable vid="pkt"/>}`;
|
|
else if(t.shipping_cost_after_rebate > 0) deliveryCostEl.innerHTML = formatPrice(t.shipping_cost_after_rebate, t.currency_sign) + "<small>" + <iai:variable vid="brutto"/> + "</small>"
|
|
else if(t.shipping_cost > 0){
|
|
deliveryCostEl.innerHTML = "<del>" + formatPrice(t.shipping_cost, t.currency_sign) + "</del> " + `${<iai:variable vid="Gratis!"/>} `;
|
|
deliveryCostEl.classList.add("cost_free");
|
|
}else{
|
|
deliveryCostEl.innerHTML = `${<iai:variable vid="Gratis!"/>} `;
|
|
deliveryCostEl.classList.add("cost_free");
|
|
}
|
|
}
|
|
checkShowPrice(paymentCostEl, Number(t.prepaid_cost), t.currency_sign);
|
|
checkShowPrice(insuranceValueEl, Number(t.insurance_cost), t.currency_sign);
|
|
checkShowPrice(totalRebateEl, Number(t.total_rebate_without_shipping), t.currency_sign);
|
|
checkShowPrice(saldoValueEl, Number(t.payment_amount_from_client_balance), t.currency_sign);
|
|
|
|
// punkty zamówienia
|
|
if(t.products_worth_at_points){
|
|
productsPointsEl.innerHTML = `${t.products_worth_at_points} ${<iai:variable vid="pkt"/>}.`;
|
|
productsPointsEl.parentElement.style.display = "flex";
|
|
summaryPointsEl.innerHTML = `+ ${t.products_worth_at_points} ${<iai:variable vid="pkt"/>}.`;
|
|
summaryPointsEl.style.display = "block";
|
|
}else {
|
|
productsPointsEl.parentElement.style.display = "none";
|
|
summaryPointsEl.style.display = "none";
|
|
}
|
|
|
|
// Cena całkowita
|
|
summaryCostEl.innerHTML = formatPrice(t.total_to_pay, t.currency_sign) + "<small>" + <iai:variable vid="brutto"/> + "</small>";
|
|
},
|
|
});
|
|
};
|
|
|
|
// funkcja od pokazania wybranej ceny (np rabat, ubezpieczenie...)
|
|
function checkShowPrice(priceContainer, price, currencySign){
|
|
priceContainer.innerHTML = formatPrice(price, currencySign);
|
|
if(price && price > 0) priceContainer.parentElement.style.display = "flex";
|
|
else priceContainer.parentElement.style.display = "none";
|
|
};
|
|
|
|
// funkcja od formatowania ceny
|
|
function formatPrice(price, currencySign) {
|
|
return format_price(price, { mask: app_shop.vars.currency_format, currency: currencySign, currency_space: app_shop.vars.currency_space, currency_before_price: app_shop.vars.currency_before_value });
|
|
};
|
|
|
|
// Funkcja od ustalenia daty dostawy
|
|
const deliveryMessageEl = document.querySelector("#order2_shiptime span:not(.operation_value)");
|
|
const deliveryDateEl = document.querySelector("#order2_shiptime .operation_value");
|
|
function deliveryDate(deliveryVal, delivery, pickuppoint) {
|
|
const date = delivery.split("#");
|
|
|
|
// Wybranie nazwy zaleznie czy dostawa jest do twojego mieszkania czy nie
|
|
if(deliveryVal === "0-0" || deliveryVal === "0-1" || pickuppoint === "y") deliveryMessageEl.innerHTML = `${<iai:variable vid="Odbiór zamówienia możliwy"/>}:`;
|
|
else deliveryMessageEl.innerHTML = `${<iai:variable vid="Przesyłka powinna być u Ciebie"/>}:`;
|
|
|
|
if(date[4]>0) deliveryDateEl.innerHTML = `${<iai:variable vid="za"/>} ` + parseInt(date[5]) + ` ${<iai:variable vid="dni"/>} `;
|
|
else{
|
|
if(parseInt(date[5]) === 0) deliveryDateEl.innerHTML = <iai:variable vid="Dzisiaj"/>;
|
|
else deliveryDateEl.innerHTML = orderTxt[`shipping${parseInt(date[3])}`];
|
|
}
|
|
};
|
|
|
|
// Obsługa klilnięć na elementy w podsumowaniu
|
|
const productsContainer = document.getElementById("checkout_step3_3");
|
|
document.getElementById("cop_seection3").addEventListener("click", (e) => {
|
|
|
|
// Kliknięcie na przyciski "Pokaż pozozostałe produkty" i "Zwiń listę"
|
|
const togggleProducts = e.target.closest(".order_products_action");
|
|
if(togggleProducts){
|
|
if(productsContainer.className.includes("--more")){
|
|
productsContainer.classList.remove("--more");
|
|
togggleProducts.querySelector("span").innerHTML = `${<iai:variable vid="Pokaż pozostałe produkty"/>}`;
|
|
}else{
|
|
productsContainer.classList.add("--more");
|
|
togggleProducts.querySelector("span").innerHTML = `${<iai:variable vid="Zwiń listę"/>}`;
|
|
}
|
|
}
|
|
|
|
// Kliknięcie na checkbox(nie zaznacz wszystkie i nie kod rabatowy)
|
|
if(e.target.type === "checkbox" && e.target.id !== "checkall-terms" && e.target.id !== "rebate_option"){
|
|
const checkboxAllTerms = document.getElementById("checkall-terms");
|
|
if(e.target.checked === false) checkboxAllTerms.checked = false;
|
|
else{
|
|
const termsInputs = document.querySelectorAll(".order2_terms_wrapper input:not(#checkall-terms)");
|
|
let checkedCount = 0;
|
|
termsInputs.forEach(el => el.checked === true ? checkedCount++ : "");
|
|
if(checkedCount === termsInputs.length) checkboxAllTerms.checked = true;
|
|
}
|
|
}
|
|
|
|
// Kliknięcie na przycisk "Zaznacz wszystkie"
|
|
if(e.target.id === "checkall-terms"){
|
|
const termsInputs = document.querySelectorAll(".order2_terms_wrapper input:not(#checkall-terms)");
|
|
let checkAll = false;
|
|
|
|
termsInputs.forEach(el => el.checked === false ? checkAll = true : "");
|
|
termsInputs.forEach(function (el) {
|
|
if(checkAll) el.checked = true;
|
|
else el.checked = false;
|
|
});
|
|
return;
|
|
}
|
|
|
|
// Usuń error na regulaminie
|
|
if(e.target.id === "order2_terms_conditions" || e.target.id === "order2_cancel"){
|
|
e.target.parentElement.querySelector("span").classList.remove("text-danger");
|
|
e.target.parentElement.querySelector("a").classList.remove("text-danger");
|
|
}
|
|
})
|
|
|
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
// KOD RABATOWY (funkcje)
|
|
|
|
// Funkcje do przerobienia kodu rabatowego
|
|
const ACTIVATE_REBATE_CODE = (code) => JSON.stringify({
|
|
query: `mutation {
|
|
activateRebateCode(code: "${code.replace(/"/g, '\\"')}") {
|
|
status
|
|
error {
|
|
code
|
|
message
|
|
}
|
|
}
|
|
}`,
|
|
})
|
|
const DEACTIVATE_REBATE_CODE = () => JSON.stringify({
|
|
query: `mutation {
|
|
deactivateRebateCode {
|
|
status
|
|
error {
|
|
code
|
|
message
|
|
}
|
|
}
|
|
}`,
|
|
})
|
|
|
|
// aktywacja kodu rabatowego
|
|
const rebateCode = document.getElementById("rebate_code");
|
|
async function updateCode(){
|
|
if(rebateCode.value.trim() === ""){
|
|
addError(rebateCode);
|
|
rebateCode.insertAdjacentHTML("afterend",`<span class="help-block validate_message text-danger">${<iai:variable vid="Wpisz kod rabatowy"/>}.</span>`);
|
|
return;
|
|
}
|
|
app_shop.fn.ajaxLoadSite(1);
|
|
|
|
// Wysłanie kodu do aktywacji
|
|
const rebateStatus = await fetchData({
|
|
data: ACTIVATE_REBATE_CODE(rebateCode.value),
|
|
linkParameter: "?mutation=activateRebateCode",
|
|
});
|
|
|
|
const { status } = rebateStatus?.data?.activateRebateCode;
|
|
app_shop.fn.ajaxLoadSite(0);
|
|
|
|
// Przeliczenie kosztu koszyka jeśli sukces
|
|
if (status === 'success') {
|
|
toggleActiveCode(true);
|
|
calculateBasketCost();
|
|
return;
|
|
}
|
|
|
|
// Pokazanie błędu
|
|
const { message } = rebateStatus?.data?.activateRebateCode?.error;
|
|
addError(rebateCode);
|
|
addErrorMessage(rebateCode, message);
|
|
// Schowaj kod (show=false, error=true)
|
|
toggleActiveCode(false, true);
|
|
}
|
|
|
|
// usunięcie aktywnego kodu rabatowego
|
|
async function removeCode(){
|
|
app_shop.fn.ajaxLoadSite(1);
|
|
|
|
const rebateStatus = await fetchData({
|
|
data: DEACTIVATE_REBATE_CODE(),
|
|
linkParameter: "?mutation=deactivateRebateCode",
|
|
});
|
|
|
|
app_shop.fn.ajaxLoadSite(0);
|
|
|
|
const { status } = rebateStatus?.data?.deactivateRebateCode;
|
|
if (status === 'success') {
|
|
toggleActiveCode(false);
|
|
calculateBasketCost();
|
|
}
|
|
}
|
|
|
|
// zmień widoczność kodu rabatowego
|
|
const rebateOptionWrapper = document.querySelector(".rebate__options");
|
|
const rebateCodeContainer = document.querySelector(".rebate__code");
|
|
const rebateActiveWrapper = document.querySelector(".rebate__active");
|
|
const activeCodeEl = document.getElementById("active-code");
|
|
const rebateOptionEl = document.getElementById("rebate_option");
|
|
function toggleActiveCode(show, error=false){
|
|
// Wyczyść walidacje
|
|
if(!error){
|
|
removeErrorMessage(rebateCode);
|
|
clearValidation(rebateCode);
|
|
}
|
|
|
|
// zmień widoczność
|
|
rebateOptionWrapper.style.display = show ? "none" : "flex";
|
|
rebateActiveWrapper.style.display = show ? "block" : "none";
|
|
|
|
if(!error) rebateCodeContainer.classList.remove("--fade-in");
|
|
else rebateCodeContainer.classList.add("--fade-in");
|
|
|
|
// zmień wartości
|
|
activeCodeEl.innerHTML = show ? rebateCode.value : "";
|
|
showInput = error ? true : false;
|
|
rebateOptionEl.checked = error ? true : false;
|
|
if(!error) rebateCode.value = "";
|
|
else activeCodeEl.innerHTML = "";
|
|
}
|
|
|
|
// eventListenery dla kodu rabatowego
|
|
let showInput = false;
|
|
const rebateCodeWrapper = document.querySelector(".rebate");
|
|
rebateCodeWrapper.addEventListener("click", (e) => {
|
|
// Rozwinięcie opcji rabatowej
|
|
if(e.target.id === "rebate_option" || e.target.classList.contains("rebate__active_change")){
|
|
showInput = !showInput;
|
|
if(showInput) rebateCodeContainer.classList.add("--fade-in");
|
|
else rebateCodeContainer.classList.remove("--fade-in");
|
|
}
|
|
|
|
// Kliknięcie na zrealizuj i dezaktywuj
|
|
if(e.target.className.includes("rebate__code-realize")) updateCode();
|
|
if(e.target.classList.contains("rebate__active_remove")) removeCode();
|
|
});
|
|
|
|
|
|
// Aktywacja kodu po naciśnięciu na enter
|
|
rebateCode.addEventListener("keydown", e=>{
|
|
if(e.key === "Enter") updateCode();
|
|
})
|
|
|
|
///////////////////////////////////////////////////////////////////////
|
|
// ZŁOŻENIE ZAMÓWIENIA
|
|
|
|
// Zwaliduj wszystkie dostępne inputy zawierające dane klienta i dane adresowe
|
|
async function validateAllInputs(){
|
|
// Zmienna trzymająca informację czy wystąpił jakiś błąd
|
|
let allGood = true;
|
|
|
|
// Sprawdzenie loginu i hasła jeśli zaznaczone
|
|
if(document.getElementById("register_client_checkbox") && document.getElementById("register_client_checkbox").checked){
|
|
allGood = testLogin() && allGood;
|
|
allGood = testPassword() && allGood;
|
|
}
|
|
if(!document.querySelector(".--logged")){
|
|
// Sprawdzenie emaila i telefonu
|
|
allGood = await validateRequest(document.getElementById("client_email"), true) && allGood;
|
|
allGood = validatePhone(document.getElementById("client_phone")) && allGood;
|
|
// Sprawdzenie nazwy firmy i nipu
|
|
if(document.getElementById("client_type1").checked){
|
|
allGood = validateNotEmpty(document.getElementById("client_firm")) && allGood;
|
|
allGood = await validateRequest(document.getElementById("client_nip"), true) && allGood;
|
|
}
|
|
// Sprawdzenie reszty pól
|
|
allGood = validateFormInputs("client") && allGood;
|
|
}
|
|
// Sprawdzanie pól dostawy na inny adres
|
|
if(document.getElementById("deliver_to_billingaddr").checked){
|
|
allGood = validateFormInputs("delivery") && allGood;
|
|
allGood = validatePhone(document.getElementById("delivery_phone")) && allGood;
|
|
}
|
|
return allGood
|
|
}
|
|
async function validateFormInputs(query){
|
|
let isFormGood = true;
|
|
|
|
isFormGood = validateNotEmpty(document.getElementById(`${query}_firstname`)) && isFormGood;
|
|
isFormGood = validateNotEmpty(document.getElementById(`${query}_lastname`)) && isFormGood;
|
|
isFormGood = validateStreet(document.getElementById(`${query}_street`)) && isFormGood;
|
|
isFormGood = await validateRequest(document.getElementById(`${query}_zipcode`),true) && isFormGood;
|
|
isFormGood = validateNotEmpty(document.getElementById(`${query}_city`)) && isFormGood;
|
|
|
|
return isFormGood;
|
|
}
|
|
|
|
// Obsługa złożenia zamówienia
|
|
const termsConditionsInput = document.getElementById("order2_terms_conditions");
|
|
const cancelConditionsInput = document.getElementById("order2_cancel");
|
|
document.querySelector(".order2_button_order").addEventListener("click", () => {
|
|
try {
|
|
app_shop.fn.ajaxLoadSite(1);
|
|
app_shop.vars.validation = 1;
|
|
// Sprawdzenie pól formularza
|
|
if(validateAllInputs() === false) app_shop.vars.validation = 0;
|
|
|
|
// znalezienie obecnie zaznaczonej metody dostawy i płatności
|
|
const deliveryMethod = document.querySelector(".ajax_cop [name=shipping]:checked");
|
|
const paymentMethod = document.querySelector(".ajax_cop [name=payform_id]:checked");
|
|
|
|
// sprawdzenie czy użytkownik zaakceptował regulamin
|
|
if(!termsConditionsInput.checked || !cancelConditionsInput.checked){
|
|
app_shop.vars.validation = 0;
|
|
showTermsError(termsConditionsInput);
|
|
showTermsError(cancelConditionsInput);
|
|
}// sprawdzenie czy użytkownik wybrał metodę dostawy i płatności (też sprawdzenie czy wybrał paczkomat i wpisał voucher)
|
|
else {
|
|
if(deliveryMethod){
|
|
if(deliveryMethod.dataset.pickuppoint === "y" && deliveryMethod.parentElement.querySelector(".fselectedPoint").innerHTML === "") orderValidationError(<iai:variable vid="Nie wybrano punktu odbioru"/>);
|
|
} else orderValidationError(<iai:variable vid="Proszę wybrać dostępną metodę dostawy"/>);
|
|
if(paymentMethod){
|
|
if(paymentMethod.value === "2" && document.getElementById("order_voucher_id").value === "") orderValidationError(<iai:variable vid="Nie podano identyfikatora bonu"/>);
|
|
} else orderValidationError(<iai:variable vid="Proszę wybrać metodę płatności"/>);
|
|
}
|
|
|
|
// Sprawdzenie formularza rejestracji nowego konta wraz z zakupem
|
|
let registerError = "";
|
|
const registerCheckbox = document.getElementById("register_client_checkbox");
|
|
if(registerCheckbox && registerCheckbox.checked){
|
|
if(!testLogin()) registerError += `${<iai:variable vid="Login musi mieć minimum 3, a maksimum 40 znaków. Możesz użyć liter i cyfr oraz symboli @ . - _"/>}<br>`;
|
|
if(!testPassword()) registerError += `${<iai:variable vid="Hasło musi składać się z minimum 6 znaków"/>}`;
|
|
if(registerError.length > 0){
|
|
orderValidationError(registerError);
|
|
scrollToHeight(document.querySelector(".register"));
|
|
}
|
|
}
|
|
|
|
// przerwanie składania zamówienia jeśli w trakcie walidacji wystąpił błąd
|
|
if (app_shop.vars.validation === 0) {
|
|
// scroll do elementów z błędem
|
|
if(document.getElementById("order2_terms_conditions").checked && document.getElementById("order2_cancel").checked){
|
|
const errorEl = document.querySelector(".--error.has-error");
|
|
if(errorEl) scrollToHeight(errorEl)
|
|
else if(!document.querySelector(`input[name="payform_id"]:checked`)) scrollToHeight(document.querySelector("#checkout_step3_1 h2"));
|
|
else if(!document.querySelector(`input[name="shipping"]:checked`)) scrollToHeight(document.querySelector("#checkout_step2_1 h2"));
|
|
}
|
|
Alertek.show_alert(`${<iai:variable vid="W formularzu wystąpiły błędy"/>}`);
|
|
return app_shop.fn.ajaxLoadSite(0), !1;
|
|
}
|
|
|
|
// Rejestracja użytkownika i/lub złożenie zamówienia
|
|
if(registerCheckbox && registerCheckbox.checked){
|
|
addClient(function() {
|
|
createOrder(deliveryMethod.value, paymentMethod.value);
|
|
}, function() {});
|
|
} else createOrder(deliveryMethod.value, paymentMethod.value);
|
|
return !1;
|
|
} catch (e) {
|
|
app_shop.fn.ajaxLoadSite(0);
|
|
console.log(e);
|
|
alert("blad");
|
|
}
|
|
});
|
|
// Przescrolluj do
|
|
function scrollToHeight(scrollToEl){
|
|
const yOffset = -45;
|
|
const y = scrollToEl.getBoundingClientRect().top + window.pageYOffset + yOffset;
|
|
window.scrollTo({top: y, behavior: 'smooth'});
|
|
}
|
|
|
|
// Schowaj/Pokaż error na warunkach regulaminun
|
|
function showTermsError(input){
|
|
if(!input.checked){
|
|
input.parentElement.querySelector("span").classList.add("text-danger");
|
|
input.parentElement.querySelector("a").classList.add("text-danger");
|
|
}
|
|
}
|
|
// złożenie zamówienia
|
|
function createOrder(deliveryMethod, paymentMethod){
|
|
// Weź dane klienta
|
|
const email = document.getElementById("client_email").value;
|
|
const phone = document.getElementById("client_phone").value;
|
|
const clientType = document.querySelector('.ajax_cop [name="client_type"]:checked').value;
|
|
const firmname = clientType === "firm" ? document.getElementById("client_firm").value : "";
|
|
const nip = clientType === "firm" ? document.getElementById("client_nip").value : "";
|
|
let firstname = document.getElementById("client_firstname").value;
|
|
let lastname = document.getElementById("client_lastname").value;
|
|
const street = document.getElementById("client_street").value;
|
|
const city = document.getElementById("client_city").value;
|
|
const zipcode = document.getElementById("client_zipcode").value;
|
|
const region = document.getElementById("client_region").value;
|
|
|
|
// Weź dane dostawy z innego adresu jeśli jest zaznaczone
|
|
let deliveryFirstname, deliveryLastname, deliveryFirmName, deliveryStreet, deliveryCity, deliveryZipcode, deliveryPhone, deliveryRegion;
|
|
if (document.getElementById("deliver_to_billingaddr").checked){
|
|
deliveryFirstname = document.getElementById("delivery_firstname").value;
|
|
deliveryLastname = document.getElementById("delivery_lastname").value;
|
|
deliveryFirmName = document.getElementById("delivery_additional").value;
|
|
deliveryStreet = document.getElementById("delivery_street").value;
|
|
deliveryCity = document.getElementById("delivery_city").value;
|
|
deliveryZipcode = document.getElementById("delivery_zipcode").value;
|
|
deliveryPhone = document.getElementById("delivery_phone").value;
|
|
deliveryRegion = document.getElementById("delivery_region").value;
|
|
};
|
|
|
|
// Informacje o newsletterze
|
|
const clientMailing = checkNewsletter("client_mailing_logg","#client_mailing");
|
|
const clientSms = checkNewsletter("client_send_sms_logg", "#client_sms");
|
|
|
|
// Kod rabatowy i kod vouchera
|
|
let rebateCode;
|
|
if (document.getElementById("active-code")) rebateCode = document.getElementById("active-code").innerHTML;
|
|
else rebateCode = "";
|
|
|
|
let voucherCode;
|
|
if(document.querySelector(".ajax_cop #payitem_2") && document.querySelector(".ajax_cop #payitem_2").checked) voucherCode = document.querySelector(".ajax_cop #order_voucher_id").value;
|
|
|
|
// Jeśli zalogowany użytkownik jest firmą i nie ma imienia i nazwiska
|
|
if (clientType.disabled && clientType.value === "firm") {
|
|
if (!firstname) firstname = (deliveryFirstname) ? deliveryFirstname : 'Klient';
|
|
if (!lastname) lastname = (deliveryLastname) ? deliveryLastname : 'Firma';
|
|
}
|
|
|
|
// czyszczenie imienia i nazwiska ze znaków specjalnych
|
|
firstname = firstname.replace(/[&\/\\#,+()$~%.'":*?<>{}!@~`^_]/g, "");
|
|
lastname = lastname.replace(/[&\/\\#,+()$~%.'":*?<>{}!@~`^_]/g, "");
|
|
|
|
// dodatkowe informacje (uwagi, faktura, punkt odbioru)
|
|
const shopRemarks = document.getElementById("shop_remarks").checked ? document.querySelector(".ajax_cop [name=remarks]").value : "";
|
|
const deliveryRemarks = document.getElementById("courier_remarks").checked ? document.querySelector(".ajax_cop [name=deliverer_remarks]").value : "";
|
|
|
|
const invoiceOption = document.querySelector("input[name=invoice]:checked").value;
|
|
const pickuppoint = document.querySelector("#osc_order1 input:checked").dataset.pickuppoint === "y" ? document.querySelector("#osc_order1 input:checked").parentElement.querySelector("label [name=pickup_point]").value : "";
|
|
const order = {
|
|
affiliate: "",
|
|
rebate_code: rebateCode,
|
|
rebate_profit_points_id: "",
|
|
client: {
|
|
email: email,
|
|
type: clientType,
|
|
firm: firmname,
|
|
nip: nip,
|
|
firstname: firstname,
|
|
lastname: lastname,
|
|
street: street,
|
|
city: city,
|
|
zipcode: zipcode,
|
|
phone: phone,
|
|
phone2: "",
|
|
region: region,
|
|
province: "",
|
|
delivery: { firstname: deliveryFirstname, lastname: deliveryLastname, additional: deliveryFirmName, street: deliveryStreet, city: deliveryCity, zipcode: deliveryZipcode, phone: deliveryPhone, region: deliveryRegion },
|
|
save_to_mailing_after_order: clientMailing,
|
|
save_to_mailing_sms_after_order: clientSms,
|
|
},
|
|
order: {
|
|
stock: 1,
|
|
payform_id: paymentMethod,
|
|
voucher_code: voucherCode,
|
|
remarks: shopRemarks,
|
|
wants_invoice: invoiceOption,
|
|
shipping: deliveryMethod,
|
|
shipping_for_points: "",
|
|
pickup_point: pickuppoint,
|
|
delivery_hour: "",
|
|
delivery_date: "",
|
|
delivery_text: "",
|
|
delivery_remarks: deliveryRemarks,
|
|
},
|
|
};
|
|
|
|
// złóż zamówienie jako zalogowany/niezalogowany użytkownik.
|
|
if (document.querySelector(".--logged")) sendOrder(order);
|
|
else {
|
|
const clientData = new FormData();
|
|
if(firmname) clientData.append("client_firm", firmname);
|
|
if(nip) clientData.append("client_nip", nip);
|
|
clientData.append("client_firstname", firstname);
|
|
clientData.append("client_lastname", lastname);
|
|
clientData.append("client_street", street);
|
|
clientData.append("client_zipcode", zipcode);
|
|
clientData.append("client_city", city);
|
|
clientData.append("client_region", region);
|
|
clientData.append("client_email", email);
|
|
clientData.append("client_phone", phone);
|
|
|
|
$.ajax({
|
|
url: "/client-new.php?operation=onceorder",
|
|
type: "POST",
|
|
data: clientData,
|
|
timeout: 1e4,
|
|
cache: !1,
|
|
contentType: !1,
|
|
processData: !1,
|
|
complete: function (e, a) {
|
|
throwAjaxError(a);
|
|
},
|
|
success: function (e, a) {
|
|
console.log("d2");
|
|
sendOrder(order);
|
|
},
|
|
});
|
|
}
|
|
}
|
|
|
|
function checkNewsletter(logged, regular){
|
|
if(document.querySelector(`.ajax_cop [name=${logged}]`)) return document.querySelector(`.ajax_cop [name=${logged}]`).value ? 1 : 0;
|
|
else if(document.querySelector(regular)) return document.querySelector(regular).checked ? 1 : 0;
|
|
else return 0;
|
|
}
|
|
// Funkcja wysyłająca zamówienie
|
|
function sendOrder(data){
|
|
$.ajax({
|
|
url: "/ajax/order-create.php",
|
|
type: "post",
|
|
timeout: 16e3,
|
|
dataType: "json",
|
|
data: data,
|
|
complete: function (e, a) {
|
|
throwAjaxError(a);
|
|
},
|
|
success: function (e) {
|
|
if(e.location){
|
|
// Zapisanie płatności i dostawy na następny raz
|
|
const paymentInput = document.querySelector(`input[name="payform_id"]:checked`)
|
|
const usedPaymentMethod = {
|
|
id: paymentInput.id,
|
|
group: paymentInput.dataset.group,
|
|
};
|
|
|
|
const deliveryMethod = document.querySelector(`input[name="shipping"]:checked`);
|
|
const selectedPoint = deliveryMethod.parentElement.querySelector(".fselectedPoint");
|
|
|
|
const usedDeliveryMethod = {
|
|
id: deliveryMethod.id,
|
|
fselectedPoint: selectedPoint ? {
|
|
deliveryPointId: selectedPoint.dataset.deliveryPointId,
|
|
name: selectedPoint.dataset.name,
|
|
street: selectedPoint.dataset.street,
|
|
zipcode: selectedPoint.dataset.zipcode,
|
|
city: selectedPoint.dataset.city,
|
|
courierId: selectedPoint.dataset.courierId
|
|
} : false
|
|
};
|
|
|
|
localStorage.setItem("prevPaymentMethod", JSON.stringify(usedPaymentMethod));
|
|
localStorage.setItem("prevDeliveryMethod", JSON.stringify(usedDeliveryMethod));
|
|
|
|
// Przeniesienie na stonę informacji o zamóieniu
|
|
window.location.href = e.location;
|
|
return;
|
|
}
|
|
if(e.errno){
|
|
app_shop.fn.ajaxLoadSite(0)
|
|
e.errno === 115 ? Alertek.show_alert(`${<iai:variable vid="Twój koszyk jest pusty"/>}`) : Alertek.show_alert(e.error);
|
|
}
|
|
},
|
|
});
|
|
}
|
|
|
|
// REJESTRACJA KLIENTA
|
|
const REGISTER_CLIENT = (registerClientInput) => JSON.stringify({
|
|
query: `mutation {
|
|
registerClient(${registerClientInput}) {
|
|
status
|
|
error {
|
|
code
|
|
message
|
|
}
|
|
}
|
|
}`,
|
|
});
|
|
// Funkcja tworząca nowego klienta wraz z zamówieniem
|
|
async function addClient(succes, error){
|
|
const clientType = document.querySelector("input[name=client_type]:checked").value;
|
|
const saveToMailing = document.getElementById("client_mailing");
|
|
let saveToMailingData = false;
|
|
if(saveToMailing && saveToMailing.checked) saveToMailingData = true;
|
|
|
|
const saveToSms = document.getElementById("client_sms");
|
|
let saveToSmsData = false;
|
|
if(saveToSms && saveToSms.checked) saveToSmsData = true;
|
|
|
|
const registerClientData = await fetchData({
|
|
data: REGISTER_CLIENT(`RegisterClientInput: {
|
|
clientData: {
|
|
clientDeliveryData: {
|
|
${clientType === "firm" ? `companyName: "${document.getElementById("client_firm").value}",` : ""}
|
|
firstname: "${document.getElementById("client_firstname").value}",
|
|
lastname: "${document.getElementById("client_lastname").value}",
|
|
street: "${document.getElementById("client_street").value}",
|
|
zipcode: "${document.getElementById("client_zipcode").value}",
|
|
city: "${document.getElementById("client_city").value}",
|
|
country: ${document.getElementById("client_region").value},
|
|
phone: "${document.getElementById("client_phone").value}",
|
|
}
|
|
${
|
|
document.getElementById("deliver_to_billingaddr").checked ? `clientDeliveryOtherAddressData: {
|
|
companyName: "${document.getElementById("delivery_additional").value}",
|
|
firstname: "${document.getElementById("delivery_firstname").value}",
|
|
lastname: "${document.getElementById("delivery_lastname").value}",
|
|
street: "${document.getElementById("delivery_street").value}",
|
|
zipcode: "${document.getElementById("delivery_zipcode").value}",
|
|
city: "${document.getElementById("delivery_city").value}",
|
|
country: ${document.getElementById("delivery_region").value},
|
|
phone: "${document.getElementById("delivery_phone").value}",
|
|
}` : ""
|
|
}
|
|
type: ${clientType},
|
|
${clientType === "firm" ? `taxNumber: "${document.getElementById("client_nip").value}",` : ""}
|
|
email: "${document.getElementById("client_email").value}",
|
|
saveToMailingAfterOrder: ${saveToMailingData},
|
|
saveToSmsAfterOrder: ${saveToSmsData},
|
|
}
|
|
loginAndPassword: {
|
|
login: "${document.querySelector(".register__login").value}",
|
|
password: "${document.querySelector(".register__password").value}",
|
|
passwordRepeat: "${document.querySelector(".register__password").value}",
|
|
}
|
|
reCaptchaToken: "${document.querySelector(`input[name="iai-recaptcha-token"`).value}"
|
|
}`),
|
|
linkParameter: '?mutation=registerClient',
|
|
});
|
|
if(!registerClientData?.data?.registerClient?.error || registerClientData?.error?.message) succes();
|
|
else {
|
|
Alertek.show_alert(registerClientData.data.registerClient.error?.message);
|
|
app_shop.fn.ajaxLoadSite(0);
|
|
}
|
|
}
|
|
|
|
// Zmiana informacji formularza w url params
|
|
function serializeFormData(form){
|
|
const formData = new FormData(form);
|
|
let serializedString = "";
|
|
for (const [name, value] of formData) {
|
|
serializedString += `${name}=${encodeURIComponent(value)}&`;
|
|
}
|
|
serializedString = serializedString.slice(0,-1);
|
|
return serializedString;
|
|
}
|
|
|
|
// Pokaz error (płatności, dostawy, zalozenie nowego konta)
|
|
function orderValidationError(text){
|
|
app_shop.vars.validation = 0;
|
|
Alertek.show_alert(`${text}`);
|
|
}
|
|
|
|
///////////////////////////////////////////////////////////////////
|
|
// RESZTA
|
|
|
|
// Wyłącz scrollowanie dla strony
|
|
function disablePageScroll(){
|
|
const documentBody = document.querySelector("body");
|
|
documentBody.style.paddingRight = `${15 + window.innerWidth - documentBody.clientWidth}px`;
|
|
documentBody.style.overflowY = "hidden";
|
|
}
|
|
function enablePageScroll(){
|
|
const documentBody = document.querySelector("body");
|
|
documentBody.style.paddingRight = "15px";
|
|
documentBody.style.overflowY = "auto";
|
|
}
|
|
|
|
// Zmiana funkcji by naprawić bugi
|
|
app_shop.fn.load = function(_url,target,callback,paramets) {
|
|
if(app_shop.vars.xhr && app_shop.vars.xhr.readystate != 4) app_shop.vars.xhr.abort();
|
|
$(target).addClass('load-content');
|
|
for(var i=0; target.length > i ; i++) $(target[i][0]).addClass('load-content');
|
|
|
|
app_shop.vars.xhr = $.ajax({
|
|
url: _url+paramets,
|
|
timeout: 16000,
|
|
success: function(data,textStatus) {
|
|
for(var i=0; target.length > i ; i++) $(target[i][0]).removeClass('load-content').html($(data).find(target[i][1]).html());
|
|
app_shop.fn.change_url(_url);
|
|
app_shop.fn.evalJSFromHtml(data);
|
|
if(callback) callback();
|
|
},
|
|
error: function(data) {
|
|
window.location.href = _url;
|
|
}
|
|
});
|
|
return app_shop.vars.xhr;
|
|
};
|
|
function throwAjaxError(e) {
|
|
-1 !== $.inArray(e, ["nocontent", "error", "timeout", "abort", "parsererror"]) && (console.log("Error:" + e), Alertek.show_alert( "Błąd podczas logowania, proszę spróbować ponownie" + " (" + e + ": " + $.now() + ")"), $.cookie("off_opc", !0));
|
|
};
|
|
async function fetchData(options = {}) {
|
|
const {
|
|
data,
|
|
link,
|
|
linkParameter = '',
|
|
alert = true
|
|
} = options;
|
|
if (!data) return false;
|
|
try {
|
|
const response = await fetch(`${link || app_shop.urls.graphql || '/graphql/v1/'}${linkParameter}`, {
|
|
method: 'POST',
|
|
headers: {
|
|
'Content-Type': 'application/json',
|
|
Accept: 'application/json',
|
|
},
|
|
body: data
|
|
});
|
|
const dataJson = await response.json();
|
|
if ((dataJson?.errors || dataJson?.error) && alert) {
|
|
Alertek.Error(<iai:variable vid="Wystąpił błąd połączenia. Sprawdź łącze internetowe lub spróbuj ponownie później"/>);
|
|
}
|
|
return dataJson;
|
|
} catch (error) {
|
|
console.error('GraphQL fetchData() Error:', error);
|
|
if (alert) {
|
|
Alertek.Error(<iai:variable vid="Wystąpił błąd połączenia. Sprawdź łącze internetowe lub spróbuj ponownie później"/>);
|
|
}
|
|
return false;
|
|
}
|
|
}
|
|
// element z numerem edycji jeśli jest
|
|
const editNumber = document.getElementById("edit-number");
|
|
|
|
if(document.querySelector(".ajax_cop").childElementCount && !editNumber) changeRegion(null, true);
|
|
|
|
// Jeśli edycja zamówienia uzupełnij dane (niewiadomo jak z voucherem bo go się nie da edytować)
|
|
if(editNumber){
|
|
const ORDER_DETAILS = (orderNumber) => JSON.stringify({
|
|
query: `query{
|
|
orderDetails(${orderNumber}){
|
|
status
|
|
client {
|
|
email
|
|
phone
|
|
billingData {
|
|
companyName
|
|
taxNumber
|
|
firstname
|
|
lastname
|
|
street
|
|
zipcode
|
|
city
|
|
province
|
|
countryName
|
|
}
|
|
deliveryData {
|
|
companyName
|
|
firstname
|
|
lastname
|
|
street
|
|
zipcode
|
|
city
|
|
countryName
|
|
province
|
|
phone
|
|
}
|
|
}
|
|
payment {
|
|
paymentMethod {
|
|
id
|
|
}
|
|
isFirstPayment
|
|
}
|
|
shipping {
|
|
courier {
|
|
id
|
|
fullId
|
|
icon
|
|
name
|
|
carrierName
|
|
pickupPoint
|
|
companyKey
|
|
companyGroupKey
|
|
}
|
|
pickupData {
|
|
id
|
|
codeExternal
|
|
name
|
|
location
|
|
link
|
|
markerIconUrl
|
|
requiredClientNumber
|
|
coordinates {
|
|
latitude
|
|
longitude
|
|
distance
|
|
}
|
|
phone
|
|
address {
|
|
buildingAndHouseNumber
|
|
city
|
|
country
|
|
postcode
|
|
street
|
|
}
|
|
courierId
|
|
}
|
|
remarks
|
|
}
|
|
remarks
|
|
checkoutType
|
|
}
|
|
}`
|
|
});
|
|
|
|
// Pobranie danych o edytowanym zamówieniu
|
|
async function getEditData(){
|
|
const data = await fetchData({
|
|
data: ORDER_DETAILS(`OrderDetailsInput: {
|
|
orderNumber: ${editNumber.value},
|
|
requestSource: order_edit
|
|
}
|
|
`),
|
|
linkParameter: "?query=orderDetails",
|
|
alert: false,
|
|
});
|
|
// Jesli error to zatrzymaj funkcje
|
|
if(!data?.data?.orderDetails) return changeRegion();
|
|
|
|
// Wstawienie danych
|
|
insertEditData(data.data.orderDetails);
|
|
}
|
|
function insertEditData(orderDetails){
|
|
const orderData = {
|
|
paymentMethodId: orderDetails.payment.paymentMethod.id,
|
|
deliveryMethodId: orderDetails.shipping.courier.id,
|
|
pickupData: orderDetails.shipping.pickupData,
|
|
};
|
|
// Sprawdzenie czy użytkownik miał inny adres Dostawy niż Billingowy.
|
|
let differentDelivery = false;
|
|
for(const [key, value] of Object.entries(orderDetails.client.billingData)){
|
|
if(key !== "taxNumber" && key !== "companyName"){
|
|
if(value !== orderDetails.client.deliveryData[key]) differentDelivery = true;
|
|
}
|
|
}
|
|
if(orderDetails.client.deliveryData.phone !== orderDetails.client.phone) differentDelivery = true;
|
|
|
|
// Uzupełnienie informacji innego adresu
|
|
if(differentDelivery){
|
|
// Pokazanie formularza dodatkowej dostawy
|
|
document.getElementById("deliver_to_billingaddr").checked = true;
|
|
document.querySelector(".ajax_cop #client_new_additional .delivery_box.cn_wrapper").classList.add("--more");
|
|
document.querySelector(".delivery__address-list-button").classList.add("--fade-in");
|
|
|
|
fillInput(document.getElementById("delivery_firstname"), orderDetails.client.deliveryData.firstname);
|
|
fillInput(document.getElementById("delivery_lastname"), orderDetails.client.deliveryData.lastname);
|
|
fillInput(document.getElementById("delivery_street"), orderDetails.client.deliveryData.street);
|
|
fillInput(document.getElementById("delivery_zipcode"), orderDetails.client.deliveryData.zipcode);
|
|
fillInput(document.getElementById("delivery_city"), orderDetails.client.deliveryData.city);
|
|
fillInput(document.getElementById("delivery_phone"), orderDetails.client.deliveryData.phone);
|
|
|
|
if(orderDetails.client.deliveryData.companyName) fillInput(document.getElementById("delivery_additional"), orderDetails.client.deliveryData.companyName);
|
|
document.querySelectorAll("#delivery_region option").forEach(opt => {
|
|
if(opt.text === orderDetails.client.deliveryData.countryName) document.getElementById("delivery_region").value = opt.value;
|
|
});
|
|
|
|
// Metody płatności i dostaw
|
|
if(document.getElementById("delivery_region").value !== document.getElementById("client_region").value) changeRegion(orderData);
|
|
else getNewPaymentsAndDeliveries(orderData, true);
|
|
// Jeśli nie było dostawy na inny adres uzupełnij metody dostaw i płatności
|
|
}else getNewPaymentsAndDeliveries(orderData, true);
|
|
|
|
// Uzupełnienie uwag dla sklepu/kuriera
|
|
if(orderDetails.remarks){
|
|
document.getElementById("shop_remarks").checked = true;
|
|
document.getElementById("order_comment_field").value = orderDetails.remarks;
|
|
}
|
|
if(orderDetails.shipping.remarks){
|
|
document.getElementById("courier_remarks").checked = true;
|
|
document.getElementById("order_comment2_field").value = orderDetails.shipping.remarks;
|
|
}
|
|
}
|
|
|
|
getEditData();
|
|
// funkcja od uzupełnienia inputów
|
|
function fillInput(input, value){
|
|
input.value = value;
|
|
input.classList.add("focused");
|
|
input.parentElement.classList.add("--success", "has-success");
|
|
}
|
|
} |