1 | function t(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,"symbol"==typeof(i=function(t,e){if("object"!=typeof t||null===t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var n=r.call(t,"string");if("object"!=typeof n)return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(n.key))?i:String(i),n)}var i}function e(e,r,n){return r&&t(e.prototype,r),n&&t(e,n),Object.defineProperty(e,"prototype",{writable:!1}),e}function r(){return r=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var r=arguments[e];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(t[n]=r[n])}return t},r.apply(this,arguments)}function n(t,e){if(null==t)return{};var r,n,i={},a=Object.keys(t);for(n=0;n<a.length;n++)e.indexOf(r=a[n])>=0||(i[r]=t[r]);return i}function i(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r<e;r++)n[r]=t[r];return n}function a(t,e){var r="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(r)return(r=r.call(t)).next.bind(r);if(Array.isArray(t)||(r=function(t,e){if(t){if("string"==typeof t)return i(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?i(t,e):void 0}}(t))||e&&t&&"number"==typeof t.length){r&&(t=r);var n=0;return function(){return n>=t.length?{done:!0}:{done:!1,value:t[n++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var o,s=new Set;function u(t){var e;s.has(t)||(s.add(t),"undefined"!=typeof console&&(e=console).warn.apply(e,[t].concat([].slice.call(arguments,1))))}function l(t,e){if(void 0===e&&(e="assertion failed"),null==t)throw Error(e)}var c={},h=/^#([0-9a-f]{3}|[0-9a-f]{6}|[0-9a-f]{8})$/,d=/^rgba?\(\s*(\d+%?)\s*,\s*(\d+%?)\s*,\s*(\d+%?)(?:\s*[,/]\s*(\d*(?:\.\d*)?%?)?)?\)$/;function p(t){if(h.test(t))return function(t){return t.length<7?[Number("0x"+t[1].repeat(2)),Number("0x"+t[2].repeat(2)),Number("0x"+t[3].repeat(2)),4===t.length?1:Number("0x"+t[4].repeat(2))]:[Number("0x"+t.slice(1,3)),Number("0x"+t.slice(3,5)),Number("0x"+t.slice(5,7)),7===t.length?1:Number("0x"+t.slice(7,9))]}(t);if(d.test(t))return m(t);if(c[t])return c[t].slice(0);o||((o=document.createElement("div")).style.cssText="\n position: absolute;\n visibility: hidden;\n pointer-events: none;\n "),o.style.color=t,document.body.appendChild(o);var e=getComputedStyle(o).color;return o.remove(),c[t]=m(e)}function m(t){try{var e=t.match(d),r=e[4];return[e[1],e[2],e[3],void 0===r?"1":r].map(function(t){return t.endsWith("%")?2.55*Number(t.slice(0,-1)):Number(t)})}catch(e){return u("rgb-color parsing failed (parsing value: '"+t+"')"),[0,0,0,1]}}function f(t){return(4===t.length?"rgba":"rgb")+"("+t.join(",")+")"}function v(t){var e=t.map(function(t){return t/255}),r=e[1],n=e[2];return.2126*g(e[0])+.7152*g(r)+.0722*g(n)}var g=function(t){return t<=.03928?t/12.92:Math.pow((t+.055)/1.055,2.4)};function _(t,e){return void 0===e&&(e=1),y(t,-e)}function b(t,e){return void 0===e&&(e=1),y(t,e)}function y(t,e){void 0===e&&(e=1);var r,n,i,a,o,s,u,l=t[3],c=void 0===l?1:l,h=(i=(r=[t[0],t[1],t[2]])[1],a=r[2],o=L((.4124564*(n=w(n=r[0]))+.3575761*(i=w(i))+.1804375*(a=w(a)))/k.Xn),[(u=116*(s=L((.2126729*n+.7151522*i+.072175*a)/k.Yn))-16)<0?0:u,500*(o-s),200*(s-L((.0193339*n+.119192*i+.9503041*a)/k.Zn))]);h[0]+=k.Kn*e;var d=function(t){var e,r,n,i=t[1],a=t[2];return r=(t[0]+16)/116,e=isNaN(i)?r:r+i/500,n=isNaN(a)?r:r-a/200,r=k.Yn*S(r),[A(3.2404542*(e=k.Xn*S(e))-1.5371385*r-.4985314*(n=k.Zn*S(n))),A(-.969266*e+1.8760108*r+.041556*n),A(.0556434*e-.2040259*r+1.0572252*n)]}(h);return 1===c?d:[].concat(d,[c])}var k={Kn:18,Xn:.95047,Yn:1,Zn:1.08883,t0:.137931034,t1:.206896552,t2:.12841855,t3:.008856452};function w(t){return(t/=255)<=.04045?t/12.92:Math.pow((t+.055)/1.055,2.4)}function L(t){return t>k.t3?Math.pow(t,1/3):t/k.t2+k.t0}function A(t){return 255*(t<=.00304?12.92*t:1.055*Math.pow(t,1/2.4)-.055)}function S(t){return t>k.t1?t*t*t:k.t2*(t-k.t0)}var O={__proto__:null,parseCssColorValue:p,rgbaToString:f,luminance:v,darken:_,brighten:b},V=function(){function t(t){var e=this;this.map_=void 0,this.mapState_=void 0,this.listeners_=[],this.map_=t,t.addListener("bounds_changed",function(){return e.handleBoundsChange()}),this.handleBoundsChange()}t.getInstance=function(e){return this.instances_.has(e)||this.instances_.set(e,new t(e)),this.instances_.get(e)};var e=t.prototype;return e.addListener=function(t){var e=this;return this.listeners_.push(t),{remove:function(){e.listeners_.splice(e.listeners_.indexOf(t),1)}}},e.getMapState=function(){return this.mapState_},e.handleBoundsChange=function(){var t=this.map_.getCenter(),e=this.map_.getBounds();if(t&&e){this.mapState_={center:t,bounds:e,zoom:this.map_.getZoom()||0,heading:this.map_.getHeading()||0,tilt:this.map_.getTilt()||0};for(var r,n=a(this.listeners_);!(r=n()).done;)(0,r.value)(this.mapState_)}else console.debug("MapStateObserver.handleBoundsChange(): map center and/or bounds undefined. Not updating map state.")},t}();V.instances_=new Map;var E=[{isValid:function(t){return"object"==typeof t&&t instanceof google.maps.LatLng},fromLatLng:function(t){return t},toLatLng:function(t){return t}},{isValid:function(t){return Array.isArray(t)&&2===t.length},fromLatLng:function(t){return[t.lng(),t.lat()]},toLatLng:function(t){return new google.maps.LatLng(t[1],t[0])}},{isValid:function(t){return null!==t&&"object"==typeof t&&"lat"in t&&"lng"in t},fromLatLng:function(t){return t.toJSON()},toLatLng:function(t){return new google.maps.LatLng(t)}}];function C(t){for(var e,r=a(E);!(e=r()).done;){var n=e.value;if(n.isValid(t))return n}throw new Error("unknown position format")}function I(t){return C(t).toLatLng(t)}var P,M=["position","draggable","collisionBehavior","title","zIndex","color","backgroundColor","borderColor","glyphColor","icon","glyph","scale","content","classList"],D=function(){function t(t){this.marker_=void 0,this.callbackDepth_=0,this.marker_=t}return t.prototype.getComputedAttributeValue=function(t){var e=this.marker_[t];if("function"!=typeof e)return this.marker_[t];if(this.callbackDepth_++,this.callbackDepth_>10)throw new Error("maximum recursion depth reached. This is probably caused by a cyclic dependency in dynamic attributes.");var r=this.marker_.getDynamicAttributeState(),n=e({data:r.data,map:r.map,marker:r.marker,attr:this});return this.callbackDepth_--,n},t}();P=D,function(){Object.defineProperty(P.prototype,"position",{get:function(){var t=this.getComputedAttributeValue("position");if(t)return I(t)}});for(var t,e=function(){var e=t.value;if("position"===e)return 1;Object.defineProperty(P.prototype,e,{get:function(){return this.getComputedAttributeValue(e)}})},r=a(M);!(t=r()).done;)e()}();var N,j,x,R=["map"],T=function(){function t(t,e){void 0===t&&(t={}),this.map_=null,this.mapObserver_=null,this.mapEventListeners_=[],this.data_=null,this.markerState_={hovered:!1,content:document.createElement("div")},this.attributes_={},this.attributeDefaults_={},this.computedAttributes_=new D(this),this.markerView_=void 0,this.pinView_=void 0,this.updateScheduled_=!1;var r=t.map,i=n(t,R);!function(){if(!("google"in window)||!google.maps)throw console.error("Google Maps API couldn't be found. Please make sure to wait for the Google Maps API to load before creating markers."),new Error("Google Maps API not found.");if(google.maps&&!google.maps.marker)throw console.error("Google Maps API was loaded without the required marker-library. To load it, add the '&libraries=marker' parameter to the API url or use `await google.maps.importLibrary('marker');` before creating a marker."),new Error("Google Maps Marker Library not found.")}(),this.pinView_=new google.maps.marker.PinElement,this.markerView_=new google.maps.marker.AdvancedMarkerElement,this.markerView_.content=this.pinView_.element,e&&(this.data_=e),this.setAttributes(i),r&&(this.map=r,this.update())}t.registerIconProvider=function(e,r){void 0===r&&(r="default"),t.iconProviders.set(r,e)};var r=t.prototype;return r.addListener=function(t,e){if(t in x)return this.markerView_.addListener("click"===t?"gmp-click":t,e);var r=this.markerView_.element;return l(r),r.addEventListener(t,e),{remove:function(){r.removeEventListener(t,e)}}},r.setData=function(t){this.data_=t,this.update()},r.setAttributes=function(t){Object.assign(this.attributes_,t),this.update()},r.update=function(){var t=this;this.updateScheduled_||(this.updateScheduled_=!0,queueMicrotask(function(){t.updateScheduled_=!1,t.performUpdate()}))},r.performUpdate=function(){if(this.map){var t=this.computedAttributes_,e=t.position;e?(this.markerView_.map!==this.map_&&(this.markerView_.map=this.map_),this.markerView_.position=e,this.markerView_.gmpDraggable=t.draggable||!1,this.markerView_.title=t.title||"",this.markerView_.zIndex=t.zIndex,this.markerView_.collisionBehavior=t.collisionBehavior,this.pinView_.scale=t.scale,this.updateContent_(t),t.content&&(this.markerState_.content=t.content)):this.markerView_.map=null}else this.markerView_.map=null},r.updateContent_=function(t){var e=t.content,r=t.classList;if(e?(e.className=r?Array.isArray(r)?r.join(" "):r:"",this.markerView_.content=e):(this.markerView_.content=this.pinView_.element,this.updateColors_(t),this.updateGlyph_(t)),this.markerView_.element){var n=this.markerView_.element,i=t.color,a=t.backgroundColor,o=void 0===a?null:a,s=t.glyphColor,u=void 0===s?null:s,l=t.borderColor,c=void 0===l?null:l,h=t.scale,d=void 0===h?null:h;n.style.setProperty("--marker-color",void 0===i?null:i),n.style.setProperty("--marker-background-color",o),n.style.setProperty("--marker-glyph-color",u),n.style.setProperty("--marker-border-color",c),n.style.setProperty("--marker-scale",d?d.toString():null)}},r.updateColors_=function(t){var e=t.color,r=t.backgroundColor,n=t.borderColor,i=t.glyphColor;if(e){var a=p(e),o=_(a,1.2),s=b(a,1.2);r||(r=f(a)),n||(n=f(o)),i||(i=f(v(a)>.4?o:s))}this.pinView_.background=r,this.pinView_.borderColor=n,this.pinView_.glyphColor=i},r.updateGlyph_=function(e){if(e.icon){var r="default",n=e.icon;if(e.icon.includes(":")){var i=e.icon.split(":");r=i[0],n=i[1]}var a=t.iconProviders.get(r);a?this.pinView_.glyph=a(n):u("An icon is set but no icon provider "+("default"===r?"":"with namespace '"+r+"' ")+"is configured.\nYou can register an icon-provider using e.g. `Marker.iconProvider = MaterialIcons()` to use the material icons webfont.")}else this.pinView_.glyph=e.glyph||void 0},r.bindEvents_=function(){var t=this;l(this.mapObserver_),this.mapEventListeners_=[this.mapObserver_.addListener(function(){return t.update()}),this.addListener("pointerenter",function(){t.markerState_.hovered=!0,t.update()}),this.addListener("pointerleave",function(){t.markerState_.hovered=!1,t.update()})]},r.unbindEvents_=function(){for(var t,e=a(this.mapEventListeners_);!(t=e()).done;)t.value.remove();this.mapEventListeners_=[]},r.getDynamicAttributeState=function(){return l(this.mapObserver_,"this.mapObserver_ is not defined"),{data:this.data_,map:this.mapObserver_.getMapState(),marker:this.markerState_}},e(t,[{key:"map",get:function(){return this.map_||null},set:function(t){this.map_!==t&&(this.unbindEvents_(),this.mapObserver_=null,this.map_=t,t&&(this.mapObserver_=V.getInstance(t),this.bindEvents_()),this.update())}}]),t}();N=T,T.iconProviders=new Map,function(){for(var t,e=function(){var e=t.value;Object.defineProperty(N.prototype,e,{get:function(){return this.attributes_[e]||this.attributeDefaults_[e]},set:function(t){this.attributes_[e]=t,this.update()}})},r=a(M);!(t=r()).done;)e()}(),function(t){t.OPTIONAL_AND_HIDES_LOWER_PRIORITY="OPTIONAL_AND_HIDES_LOWER_PRIORITY",t.REQUIRED="REQUIRED",t.REQUIRED_AND_HIDES_OPTIONAL="REQUIRED_AND_HIDES_OPTIONAL"}(j||(j={})),function(t){t.click="click",t.dragstart="dragstart",t.drag="drag",t.dragend="dragend"}(x||(x={}));var B=["map","key"],G=function(){function t(t,e){this.map_=null,this.markers_=new Map,this.markerAttributes_={},this.generatedKeyCache_=new WeakMap,this.key=void 0;var r,i=[];1===arguments.length?r=t:(i=t,r=e);var a=r.map,o=r.key,s=n(r,B);this.key=o,this.markerAttributes_=s,this.setData(i),a&&(this.map=a)}var i=t.prototype;return i.setData=function(t){for(var e,n=this,i=new Map(t.map(function(t){return[n.generateKey(t),t]})),o=new Set(this.markers_.keys()),s=new Set(i.keys()),l=[].concat(o).filter(function(t){return!s.has(t)}),c=[].concat(s).filter(function(t){return!o.has(t)}),h=[].concat(s).filter(function(t){return o.has(t)}),d=a(l);!(e=d()).done;){var p=e.value;this.markers_.get(p).map=null,this.markers_.delete(p)}for(var m,f=r({map:this.map},this.markerAttributes_),v=a(c);!(m=v()).done;){var g=m.value,_=this.createMarker(f,i.get(g));this.markers_.set(g,_)}h.length>0&&!this.key&&u("MarkerCollection: updating markers without a key can cause performance issues. Add an attribute named 'key' to the marker-collection to make records identifyable.");for(var b,y=a(h);!(b=y()).done;){var k=b.value,w=this.markers_.get(k),L=i.get(k);w.setData(L)}},i.setAttributes=function(t){this.markerAttributes_=t;for(var e,r=a(this.markers_.values());!(e=r()).done;)e.value.setAttributes(t)},i.generateKey=function(t){if(!this.key){var e=this.generatedKeyCache_.get(t);return e||(e=Math.random().toString(36).slice(2),this.generatedKeyCache_.set(t,e)),e}return this.key(t)},i.createMarker=function(t,e){return new T(t,e)},e(t,[{key:"map",get:function(){return this.map_},set:function(t){if(t!==this.map){this.map_=t;for(var e,r=a(this.markers_.values());!(e=r()).done;)e.value.map=t}}}]),t}();export{j as CollisionBehavior,T as Marker,G as MarkerCollection,M as attributeKeys,O as color,C as getPositionFormat,E as positionFormats,I as toLatLng};
|