/* MIT License - Copyright (c) Ricky Brundritt. */ !function(t){"use strict";a.addTemplate=function(t,e,l){var o=a._imageTemplates;!l&&o[t.toLowerCase()]||(o[t.toLowerCase()]=e)},a.getElement=function(t,e,l,o,c){void 0===e&&(e=""),void 0===l&&(l="#1A73AA"),void 0===o&&(o="white"),void 0===c&&(c=1);var s=document.createElement("div");return s.innerHTML=a._applyStyle(t,e,l,o,c),s},a.getTemplate=function(t,e){void 0===e&&(e=1),e=Math.abs(e||1);var l=a._imageTemplates;if("string"==typeof t&&l[t.toLowerCase()]){for(var o=l[t.toLowerCase()],c=/calc\(([0-9.]+)[px]*\s*\*\s*\{scale\}\)/gi,s=o,r=c.exec(o);r;)s=s.replace(r[0],parseFloat(r[1])*e+""),r=c.exec(o);return s=s.replace("{scale}",e+"")}throw new Error("Invalid templateName.")},a.getAllTemplateNames=function(){return Object.keys(a._imageTemplates)},a._applyStyle=function(t,e,l,o,c){return void 0===e&&(e=""),l=(l=void 0===l?"#1A73AA":l)||"#1A73AA",o=(o=void 0===o?"white":o)||"#fff",a.getTemplate(t,c=void 0===c?1:c).replace(/{color}/g,l).replace(/{secondaryColor}/g,o).replace(/{text}/g,e||"")},a._imageTemplates={marker:'{text}',"marker-thick":'{text}',"marker-circle":'{text}',pin:'{text}',"pin-round":'{text}',"marker-flat":'{text}',"marker-arrow":'{text}',"marker-ball-pin":'{text}',"marker-square":'{text}',"marker-square-cluster":'+{text}',"marker-square-rounded":'{text}',"marker-square-rounded-cluster":'+{text}',flag:'{text}',"flag-triangle":'{text}',"rounded-square":'{text}',"rounded-square-thick":'{text}',triangle:'{text}',"triangle-thick":'{text}',hexagon:'{text}',"hexagon-thick":'{text}',"hexagon-rounded":'{text}',"hexagon-rounded-thick":'{text}',"triangle-arrow-up":'{text}',"triangle-arrow-left":'{text}',"arrow-up":'{text}',"arrow-up-thin":'{text}',car:'{text}',checker:'',"checker-rotated":'',"zig-zag":'',"zig-zag-vertical":'',"circles-spaced":'',circles:'',"diagonal-lines-up":'',"diagonal-lines-down":'',"diagonal-stripes-up":'',"diagonal-stripes-down":'',"grid-lines":'',"rotated-grid-lines":'',"rotated-grid-stripes":'',"x-fill":'',dots:''};var r=a;function a(){}function e(t){this._images={},this._map=t}e.prototype.add=function(a,e,i,h){var g=this;return void 0===i&&(i=100),void 0===h&&(h=100),new Promise(function(l,o){var c,t,s=g._images,r=g._map;s[a]?l():"string"==typeof e&&(t={url:c=/i||e.height>h)&&(t=Math.min(i/e.width,h/e.height))<1&&(e.width=e.width*t,e.height=e.height*t),r.addImage(a,e),s[a]=c,l()},e.onerror=e.onabort=function(){o('Failed to load "'.concat(a,'" image.'))},e.src=URL.createObjectURL(t)}).catch(function(){o('Failed to load "'.concat(a,'" image.'))}))})},e.prototype.clear=function(){var e=this;Object.keys(e._images).forEach(function(t){e._map.removeImage(t)}),e._images={}},e.prototype.getImageIds=function(){return Object.keys(this._images)},e.prototype.hasImage=function(t){return!!this._images[t]},e.prototype.createFromTemplate=function(t,e,l,o,c,s){e=r._applyStyle(e,s=void 0===s?"":s,l=void 0===l?"#1A73AA":l,o=void 0===o?"white":o,c=void 0===c?1:c);return this.add(t,e)},e.prototype.remove=function(t){this._map.removeImage(t),delete this._images[t]},e.prototype.reload=function(){var l=this,o=this;Object.keys(o._images).forEach(function(t){var e;o._map.hasImage(t)||((e=new Image).onload=function(){o._map.addImage(t,e)},e.src=l._images[t])})},t.SvgManager=e,t.SvgTemplateManager=r}(this.maplibregl=this.maplibregl||{});