Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@americana/maplibre-shield-generator

Package Overview
Dependencies
Maintainers
2
Versions
25
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@americana/maplibre-shield-generator - npm Package Compare versions

Comparing version 0.0.2 to 0.0.3-test-1

dist/index.d.js

4

dist/index.js

@@ -1,3 +0,3 @@

var Ze=Object.create;var ge=Object.defineProperty;var et=Object.getOwnPropertyDescriptor;var tt=Object.getOwnPropertyNames;var it=Object.getPrototypeOf,lt=Object.prototype.hasOwnProperty;var nt=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports);var ot=(t,e,i,l)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of tt(e))!lt.call(t,n)&&n!==i&&ge(t,n,{get:()=>e[n],enumerable:!(l=et(e,n))||l.enumerable});return t};var rt=(t,e,i)=>(i=t!=null?Ze(it(t)):{},ot(e||!t||!t.__esModule?ge(i,"default",{value:t,enumerable:!0}):i,t));var Se=nt((Ot,ye)=>{"use strict";ye.exports={aliceblue:[240,248,255],antiquewhite:[250,235,215],aqua:[0,255,255],aquamarine:[127,255,212],azure:[240,255,255],beige:[245,245,220],bisque:[255,228,196],black:[0,0,0],blanchedalmond:[255,235,205],blue:[0,0,255],blueviolet:[138,43,226],brown:[165,42,42],burlywood:[222,184,135],cadetblue:[95,158,160],chartreuse:[127,255,0],chocolate:[210,105,30],coral:[255,127,80],cornflowerblue:[100,149,237],cornsilk:[255,248,220],crimson:[220,20,60],cyan:[0,255,255],darkblue:[0,0,139],darkcyan:[0,139,139],darkgoldenrod:[184,134,11],darkgray:[169,169,169],darkgreen:[0,100,0],darkgrey:[169,169,169],darkkhaki:[189,183,107],darkmagenta:[139,0,139],darkolivegreen:[85,107,47],darkorange:[255,140,0],darkorchid:[153,50,204],darkred:[139,0,0],darksalmon:[233,150,122],darkseagreen:[143,188,143],darkslateblue:[72,61,139],darkslategray:[47,79,79],darkslategrey:[47,79,79],darkturquoise:[0,206,209],darkviolet:[148,0,211],deeppink:[255,20,147],deepskyblue:[0,191,255],dimgray:[105,105,105],dimgrey:[105,105,105],dodgerblue:[30,144,255],firebrick:[178,34,34],floralwhite:[255,250,240],forestgreen:[34,139,34],fuchsia:[255,0,255],gainsboro:[220,220,220],ghostwhite:[248,248,255],gold:[255,215,0],goldenrod:[218,165,32],gray:[128,128,128],green:[0,128,0],greenyellow:[173,255,47],grey:[128,128,128],honeydew:[240,255,240],hotpink:[255,105,180],indianred:[205,92,92],indigo:[75,0,130],ivory:[255,255,240],khaki:[240,230,140],lavender:[230,230,250],lavenderblush:[255,240,245],lawngreen:[124,252,0],lemonchiffon:[255,250,205],lightblue:[173,216,230],lightcoral:[240,128,128],lightcyan:[224,255,255],lightgoldenrodyellow:[250,250,210],lightgray:[211,211,211],lightgreen:[144,238,144],lightgrey:[211,211,211],lightpink:[255,182,193],lightsalmon:[255,160,122],lightseagreen:[32,178,170],lightskyblue:[135,206,250],lightslategray:[119,136,153],lightslategrey:[119,136,153],lightsteelblue:[176,196,222],lightyellow:[255,255,224],lime:[0,255,0],limegreen:[50,205,50],linen:[250,240,230],magenta:[255,0,255],maroon:[128,0,0],mediumaquamarine:[102,205,170],mediumblue:[0,0,205],mediumorchid:[186,85,211],mediumpurple:[147,112,219],mediumseagreen:[60,179,113],mediumslateblue:[123,104,238],mediumspringgreen:[0,250,154],mediumturquoise:[72,209,204],mediumvioletred:[199,21,133],midnightblue:[25,25,112],mintcream:[245,255,250],mistyrose:[255,228,225],moccasin:[255,228,181],navajowhite:[255,222,173],navy:[0,0,128],oldlace:[253,245,230],olive:[128,128,0],olivedrab:[107,142,35],orange:[255,165,0],orangered:[255,69,0],orchid:[218,112,214],palegoldenrod:[238,232,170],palegreen:[152,251,152],paleturquoise:[175,238,238],palevioletred:[219,112,147],papayawhip:[255,239,213],peachpuff:[255,218,185],peru:[205,133,63],pink:[255,192,203],plum:[221,160,221],powderblue:[176,224,230],purple:[128,0,128],rebeccapurple:[102,51,153],red:[255,0,0],rosybrown:[188,143,143],royalblue:[65,105,225],saddlebrown:[139,69,19],salmon:[250,128,114],sandybrown:[244,164,96],seagreen:[46,139,87],seashell:[255,245,238],sienna:[160,82,45],silver:[192,192,192],skyblue:[135,206,235],slateblue:[106,90,205],slategray:[112,128,144],slategrey:[112,128,144],snow:[255,250,250],springgreen:[0,255,127],steelblue:[70,130,180],tan:[210,180,140],teal:[0,128,128],thistle:[216,191,216],tomato:[255,99,71],turquoise:[64,224,208],violet:[238,130,238],wheat:[245,222,179],white:[255,255,255],whitesmoke:[245,245,245],yellow:[255,255,0],yellowgreen:[154,205,50]}});var te=rt(Se(),1),we=at,ce={red:0,orange:60,yellow:120,green:180,blue:240,purple:300};function at(t){var e,i=[],l=1,n;if(typeof t=="string")if(te.default[t])i=te.default[t].slice(),n="rgb";else if(t==="transparent")l=0,n="rgb",i=[0,0,0];else if(/^#[A-Fa-f0-9]+$/.test(t)){var o=t.slice(1),r=o.length,s=r<=4;l=1,s?(i=[parseInt(o[0]+o[0],16),parseInt(o[1]+o[1],16),parseInt(o[2]+o[2],16)],r===4&&(l=parseInt(o[3]+o[3],16)/255)):(i=[parseInt(o[0]+o[1],16),parseInt(o[2]+o[3],16),parseInt(o[4]+o[5],16)],r===8&&(l=parseInt(o[6]+o[7],16)/255)),i[0]||(i[0]=0),i[1]||(i[1]=0),i[2]||(i[2]=0),n="rgb"}else if(e=/^((?:rgb|hs[lvb]|hwb|cmyk?|xy[zy]|gray|lab|lchu?v?|[ly]uv|lms)a?)\s*\(([^\)]*)\)/.exec(t)){var h=e[1],g=h==="rgb",o=h.replace(/a$/,"");n=o;var r=o==="cmyk"?4:o==="gray"?1:3;i=e[2].trim().split(/\s*[,\/]\s*|\s+/).map(function(a,f){if(/%$/.test(a))return f===r?parseFloat(a)/100:o==="rgb"?parseFloat(a)*255/100:parseFloat(a);if(o[f]==="h"){if(/deg$/.test(a))return parseFloat(a);if(ce[a]!==void 0)return ce[a]}return parseFloat(a)}),h===o&&i.push(1),l=g||i[r]===void 0?1:i[r],i=i.slice(0,r)}else t.length>10&&/[0-9](?:\s|\/)/.test(t)&&(i=t.match(/([0-9]+)/g).map(function(y){return parseFloat(y)}),n=t.match(/([a-z])/ig).join("").toLowerCase());else isNaN(t)?Array.isArray(t)||t.length?(i=[t[0],t[1],t[2]],n="rgb",l=t.length===4?t[3]:1):t instanceof Object&&(t.r!=null||t.red!=null||t.R!=null?(n="rgb",i=[t.r||t.red||t.R||0,t.g||t.green||t.G||0,t.b||t.blue||t.B||0]):(n="hsl",i=[t.h||t.hue||t.H||0,t.s||t.saturation||t.S||0,t.l||t.lightness||t.L||t.b||t.brightness]),l=t.a||t.alpha||t.opacity||1,t.opacity!=null&&(l/=100)):(n="rgb",i=[t>>>16,(t&65280)>>>8,t&255]);return{space:n,values:i,alpha:l}}var D={name:"rgb",min:[0,0,0],max:[255,255,255],channel:["red","green","blue"],alias:["RGB"]};var j={name:"hsl",min:[0,0,0],max:[360,100,100],channel:["hue","saturation","lightness"],alias:["HSL"],rgb:function(t){var e=t[0]/360,i=t[1]/100,l=t[2]/100,n,o,r,s,h;if(i===0)return h=l*255,[h,h,h];l<.5?o=l*(1+i):o=l+i-l*i,n=2*l-o,s=[0,0,0];for(var g=0;g<3;g++)r=e+1/3*-(g-1),r<0?r++:r>1&&r--,6*r<1?h=n+(o-n)*6*r:2*r<1?h=o:3*r<2?h=n+(o-n)*(2/3-r)*6:h=n,s[g]=h*255;return s}};D.hsl=function(t){var e=t[0]/255,i=t[1]/255,l=t[2]/255,n=Math.min(e,i,l),o=Math.max(e,i,l),r=o-n,s,h,g;return o===n?s=0:e===o?s=(i-l)/r:i===o?s=2+(l-e)/r:l===o&&(s=4+(e-i)/r),s=Math.min(s*60,360),s<0&&(s+=360),g=(n+o)/2,o===n?h=0:g<=.5?h=r/(o+n):h=r/(2-o-n),[s,h*100,g*100]};function X(t){Array.isArray(t)&&t.raw&&(t=String.raw(...arguments));var e,i,l,n=we(t);if(!n.space)return[];let o=n.space[0]==="h"?j.min:D.min,r=n.space[0]==="h"?j.max:D.max;return e=Array(3),e[0]=Math.min(Math.max(n.values[0],o[0]),r[0]),e[1]=Math.min(Math.max(n.values[1],o[1]),r[1]),e[2]=Math.min(Math.max(n.values[2],o[2]),r[2]),n.space[0]==="h"&&(e=j.rgb(e)),e.push(Math.min(Math.max(n.alpha,0),1)),e}var dt='"sans-serif-condensed", "Arial Narrow", sans-serif',N=(t,e)=>`bold ${t}px ${e||dt}`,q=12;function ie(t,e,i){return 255-t/255*(255-i)-(1-t/255)*(255-e)}function ht(t,e,i,l){e[l]=t[i],e[l+1]=t[i+1],e[l+2]=t[i+2],e[l+3]=t[i+3]}function st(t,e,i,l,n,o){e[l]=ie(t[i],n[0],o[0]),e[l+1]=ie(t[i+1],n[1],o[1]),e[l+2]=ie(t[i+2],n[2],o[2]),e[l+3]=t[i+3]}function le(t,e,i,l,n,o){let r=t.createImageData(e.data.width,e.data.height),s=n||o?st:ht,h=n?X(n):X("#000"),g=o?X(o):X("#fff");if(l)for(let y=0;y<e.data.height;y++)for(let u=0;u<e.data.width;u++){let f=((e.data.height-y-1)*e.data.width+u)*4,p=(y*e.data.width+u)*4;s(e.data.data,r.data,p,f,h,g)}else for(let y=0;y<e.data.data.length;y+=4)s(e.data.data,r.data,y,y,h,g);t.putImageData(r,0,i)}var G={Middle:"middle",Top:"top",Bottom:"bottom"};function be(t,e){var i=t.width,l=t.height,n=e.width,o=e.height;return i*l/Math.sqrt(i*i*o*o+l*l*n*n)}function ut(t,e){return{scale:be(t,e),valign:G.Middle}}function ft(t,e){return{scale:be(t,{height:e.width/2,width:e.height}),valign:G.Top}}function me(t,e){var i=t.height/e.height,l=t.width/e.width;return{scale:Math.min(l,i),valign:G.Middle}}function pt(t,e,i){let l=2;return i!==void 0&&i.radius!==void 0&&(l=i.radius),me({width:t.width-l*(2-Math.sqrt(2)),height:t.height-l*(2-Math.sqrt(2))},e)}function Ce(t,e){let i=t.width,l=t.height,n=e.width,o=e.height;return{scale:i*l/(l*n+i*o),valign:G.Middle}}function gt(t,e){return{scale:Ce(t,e).scale,valign:G.Top}}function yt(t,e,i,l,n,o){var r=t.px(i.top)||0,s=t.px(i.bottom)||0,h=t.px(i.left)||0,g=t.px(i.right)||0,y=t.px(o),u=t.gfxFactory.createGraphics(l);u.font=N(q,t.options.shieldFont),u.textAlign="center",u.textBaseline="top";var a=u.measureText(e),f=a.width,p=a.actualBoundingBoxDescent,S=l.height-r-s,d=l.width-h-g,c=h+d/2;let w=We[n.constraintFunc],x=w({height:S,width:d},{height:p,width:f},n.options);var m=Math.min(y,q*x.scale);u.font=N(m,t.options.shieldFont),u.textAlign="center",u.textBaseline="top",a=u.measureText(e),p=a.actualBoundingBoxDescent;var b;switch(x.valign){case G.Top:b=r;break;case G.Bottom:b=r+S-p;break;case G.Middle:default:b=r+(S-p)/2;break}return{xBaseline:c,yBaseline:b,fontPx:m}}var St={padding:{top:0,bottom:0,left:0,right:0}};function J(t,e,i,l){i==null&&(i=St);var n=i.padding||{},o={constraintFunc:"rect"},r=14;return typeof i.textLayout<"u"&&(o=i.textLayout),typeof i.maxFontSize<"u"&&(r=Math.min(r,i.maxFontSize)),yt(t,e,n,l,o,r)}function Te(t,e,i,l){ke(t,e,l),e.fillText(i,l.xBaseline,l.yBaseline)}function ne(t,e,i,l){ke(t,e,l),e.shadowColor=e.strokeStyle,e.shadowBlur=0,e.lineWidth=t.px(2),e.strokeText(i,l.xBaseline,l.yBaseline),e.shadowColor=null,e.shadowBlur=null}function ke(t,e,i){e.textAlign="center",e.textBaseline="top",e.font=N(i.fontPx,t.options.shieldFont)}function ve(t,e,i,l){Re(t,e,i,l,!0)}function Me(t,e,i,l){Re(t,e,i,l,!1)}function Re(t,e,i,l,n){let o={padding:{top:t.options.bannerPadding,bottom:0,left:0,right:0}};var r=J(t,i,o,{width:e.canvas.width,height:t.px(t.options.bannerHeight-t.options.bannerPadding)});e.font=N(r.fontPx,t.options.shieldFont),e.textBaseline="top",e.textAlign="center",n?(e.fillStyle=t.options.bannerTextColor,e.fillText(i,r.xBaseline,r.yBaseline+l*t.px(t.options.bannerHeight-t.options.bannerPadding))):(e.strokeStyle=e.shadowColor=t.options.bannerTextHaloColor,e.shadowBlur=0,e.lineWidth=t.px(2),e.strokeText(i,r.xBaseline,r.yBaseline+l*t.px(t.options.bannerHeight-t.options.bannerPadding)),e.shadowColor=null,e.shadowBlur=null)}function oe(t,e,i){var l=t.emptySprite();return l.font=N(i,t.options.shieldFont),Math.ceil(l.measureText(e).width)}var We={};function U(t,e){We[t]=e}U("diamond",Ce);U("ellipse",ut);U("rect",me);U("roundedRect",pt);U("southHalfEllipse",ft);U("triangleDown",gt);function ct(t,e,i){Q(t,e,{fillColor:"white",strokeColor:"black",outlineWidth:1,radius:2,rectWidth:20});let l=i.fillColor,n=t.px(.5),o=t.shieldSize()/3-n;return e.beginPath(),e.arc(t.shieldSize()/2,t.shieldSize()/2,o,0,2*Math.PI,!1),e.fillStyle=l,e.strokeStyle=i.strokeColor,e.fill(),e.lineWidth=n,e.stroke(),e}function wt(t,e,i){Q(t,e,{fillColor:"#006747",strokeColor:"white",outlineWidth:1,radius:2,rectWidth:20});let l=i.fillColor,n=t.px(.5),o=.15*t.shieldSize()+n,r=.7*t.shieldSize()-2*n,s=.4*t.shieldSize()+n,h=.45*t.shieldSize()-2*n;return e.beginPath(),e.rect(o,s,r,h),e.fillStyle=l,e.strokeStyle=i.strokeColor,e.fill(),e.lineWidth=n,e.stroke(),e}function Pe(){I("branson",wt,20),I("paBelt",ct,20)}var Ie=20,ze=34,_e=18;function z(t,e,i,l){if(re[l]!==void 0)return t.px(re[l]);let n=e.rectWidth==null?null:e.rectWidth,o=e.angle==null?0:e.angle,r=Math.tan(o);if(n==null){let s=oe(t,i,t.px(_e))+t.px(2),h=t.px(Ie);switch(l){case"pentagon":let g=e.offset==null?0:e.offset;s+=(t.shieldSize()-t.px(g))*r/2;break;case"trapezoid":s+=t.shieldSize()*r/2;break;case"triangle":h+=t.px(2);break;case"diamond":case"hexagonHorizontal":h+=t.px(4);break}return Math.max(h,Math.min(t.px(ze),s))}else return t.px(n)}function xt(t,e,i,l){let n=i.fillColor==null?"white":i.fillColor,o=i.strokeColor==null?"black":i.strokeColor,r=z(t,i,l),s=t.px(1),h=r/2-s,g=t.shieldSize()/2-s;return e.beginPath(),e.ellipse(e.canvas.width/2,t.shieldSize()/2,h,g,0,2*Math.PI,!1),e.fillStyle=n,e.fill(),e.lineWidth=s,e.strokeStyle=o,e.stroke(),r}function He(t,e){var i=oe(t,e,t.px(_e))+t.px(2),l=Math.max(t.px(Ie),Math.min(t.px(ze),i));return t.gfxFactory.createGraphics({width:l,height:t.shieldSize()})}function Q(t,e,i,l){let n=i.fillColor==null?"white":i.fillColor,o=i.strokeColor==null?"black":i.strokeColor,r=i.radius==null?0:i.radius,s=i.outlineWidth==null?1:i.outlineWidth,h=z(t,i,l),g=t.px(s),y=g/2,u=t.px(r),a=y,f=y+u,p=h-y-u,S=h-y,d=y,c=y+u,w=t.shieldSize()-y-u,x=t.shieldSize()-y;return e.beginPath(),e.moveTo(p,d),e.arcTo(S,d,S,c,u),e.arcTo(S,x,p,x,u),e.arcTo(a,x,a,w,u),e.arcTo(a,d,f,d,u),e.closePath(),e.lineWidth=g,e.fillStyle=n,e.fill(),o!=null&&(e.strokeStyle=o,e.stroke()),h}function bt(t,e,i,l){let n=i.offset==null?0:i.offset,o=i.fillColor==null?"white":i.fillColor,r=i.strokeColor==null?"black":i.strokeColor,s=i.radius==null?0:i.radius,h=i.outlineWidth==null?1:i.outlineWidth,g=z(t,i,l),y=t.px(h),u=y/2,a=t.px(s),f=t.px(n),p=u,S=g-u,d=u,c=t.shieldSize()-u,w=p+a,x=(p+S)/2,m=d+a,b=c-f,T=(2*p+x)/3,C=(x+2*S)/3,k=(b+c)/2,M=(k+2*c)/3;return e.beginPath(),e.moveTo(x,c),e.bezierCurveTo(T,M,p,k,p,b),e.arcTo(p,d,w,d,a),e.arcTo(S,d,S,m,a),e.lineTo(S,b),e.bezierCurveTo(S,k,C,M,x,c),e.closePath(),e.lineWidth=y,e.fillStyle=o,e.fill(),r!=null&&(e.strokeStyle=r,e.stroke()),g}function mt(t,e,i,l){let n=i.pointUp==null?!1:i.pointUp,o=i.fillColor==null?"white":i.fillColor,r=i.strokeColor==null?"black":i.strokeColor,s=i.outlineWidth==null?1:i.outlineWidth,h=n?-1:1,g=z(t,i,l),y=t.px(s),u=y/2,a=u,f=g-u,p=n?t.shieldSize()-u:u,S=n?u:t.shieldSize()-u,d=a+t.px(1),c=a+t.px(2.5),w=(a+f)/2,x=f-t.px(2.5),m=f-t.px(1),b=p+h*t.px(2),T=p+h*t.px(4.5),C=p+h*t.px(7),k=S-h*t.px(6),M=S-h*t.px(1),v=(a+w)/2,R=(w+f)/2;e.beginPath(),e.moveTo(w,S),e.bezierCurveTo(v,M,a,k,a,C),e.bezierCurveTo(a,T,d,b,c,p),e.lineTo(x,p),e.bezierCurveTo(m,b,f,T,f,C),e.bezierCurveTo(f,k,R,M,w,S),e.closePath(),e.lineWidth=y,e.fillStyle=o,e.fill(),r!=null&&(e.strokeStyle=r,e.stroke())}function Ct(t,e,i,l){let n=i.pointUp==null?!1:i.pointUp,o=i.fillColor==null?"white":i.fillColor,r=i.strokeColor==null?"black":i.strokeColor,s=i.radius==null?0:i.radius,h=i.outlineWidth==null?1:i.outlineWidth,g=n?-1:1,y=z(t,i,l,"triangle"),u=t.px(h),a=u/2,f=t.px(s),p=a,S=y-a,d=n?t.shieldSize()-a:a,c=n?a:t.shieldSize()-a,w=p+f,x=(p+S)/2,m=S-f,b=d+g*f,T=Math.atan((x-w)/Math.abs(c-f-b)),C=Math.sin(T),k=Math.cos(T),M=Math.tan(T/2),v=Math.tan(Math.PI/4-T/2),R=w-f*k,W=x-f*v,F=x+f*v,_=m+f*k,B=b+g*f*M,P=b+g*f*C,H=c-g*f*(1-C);return e.beginPath(),e.moveTo(x,c),e.arcTo(W,c,R,P,f),e.arcTo(p,B,p,b,f),e.arcTo(p,d,w,d,f),e.arcTo(S,d,S,b,f),e.arcTo(S,B,_,P,f),e.arcTo(F,c,x,c,f),e.closePath(),e.lineWidth=u,e.fillStyle=o,e.fill(),r!=null&&(e.strokeStyle=r,e.stroke()),y}function Tt(t,e,i,l){let n=i.shortSideUp==null?!1:i.shortSideUp,o=i.angle==null?0:i.angle,r=i.fillColor==null?"white":i.fillColor,s=i.strokeColor==null?"black":i.strokeColor,h=i.radius==null?0:i.radius,g=i.outlineWidth==null?1:i.outlineWidth,y=n?-1:1,u=Math.sin(o),a=Math.cos(o),f=Math.tan(o),p=z(t,i,l,"trapezoid"),S=t.px(g),d=S/2,c=t.px(h),w=d,x=p-d,m=n?t.shieldSize()-d:d,b=n?d:t.shieldSize()-d,T=m+y*c*(1+u),C=b-y*c*(1-u),k=w+(T-m)*f,M=k+c*a,v=w+y*(C-m)*f,R=w+y*(b-m)*f,W=v+y*c*a,F=p-R,_=p-v,B=p-M;return e.beginPath(),e.moveTo(B,m),e.arcTo(x,m,_,C,c),e.arcTo(F,b,W,b,c),e.arcTo(R,b,k,T,c),e.arcTo(w,m,B,m,c),e.closePath(),e.lineWidth=S,e.fillStyle=r,e.fill(),s!=null&&(e.strokeStyle=s,e.stroke()),p}function kt(t,e,i,l){let n=i.fillColor==null?"white":i.fillColor,o=i.strokeColor==null?"black":i.strokeColor,r=i.radius==null?0:i.radius,s=i.outlineWidth==null?1:i.outlineWidth,h=Y(t,"diamond"),g=z(t,i,l,"diamond"),y=t.px(s),u=y/2,a=t.px(r),f=u,p=g-u,S=u,d=h-u,c=(f+p)/2,w=(S+d)/2,x=Math.atan((c-a-f)/(d-a-w)),m=Math.sin(x),b=Math.cos(x),T=Math.tan(x/2),C=Math.tan(Math.PI/4-x/2),k=f+a*(1-b),M=c-a*b,v=c-a*C,R=c+a*C,W=c+a*b,F=p-a*(1-b),_=S+a*(1-m),B=w-a*m,P=w-a*T,H=w+a*T,A=w+a*m,O=d-a*(1-m);return e.beginPath(),e.moveTo(c,d),e.arcTo(v,d,k,A,a),e.arcTo(f,H,f,w,a),e.arcTo(f,P,M,_,a),e.arcTo(v,S,c,S,a),e.arcTo(R,S,F,B,a),e.arcTo(p,P,p,w,a),e.arcTo(p,H,W,O,a),e.arcTo(R,d,c,d,a),e.closePath(),e.lineWidth=y,e.fillStyle=n,e.fill(),o!=null&&(e.strokeStyle=o,e.stroke()),g}function vt(t,e,i,l){let n=i.pointUp==null?!0:i.pointUp,o=i.offset==null?0:i.offset,r=i.angle==null?0:i.angle,s=i.fillColor==null?"white":i.fillColor,h=i.strokeColor==null?"black":i.strokeColor,g=i.radius1==null?0:i.radius1,y=i.radius2==null?0:i.radius2,u=i.outlineWidth==null?1:i.outlineWidth,a=n?-1:1,f=Math.sin(r),p=Math.cos(r),S=Math.tan(r),d=z(t,i,l,"pentagon"),c=t.px(u),w=c/2,x=t.px(g),m=t.px(y),b=t.px(o),T=w,C=d-w,k=n?t.shieldSize()-w:w,M=n?w:t.shieldSize()-w,v=M-a*b,R=T+a*(v-k)*S,W=(T+C)/2,F=C-a*(v-k)*S,_=Math.atan(b/(W-T)),B=(Math.PI/2-_+r)/2,P=Math.tan(B),H=(Math.PI/2-r)/2,A=Math.tan(H),O=T+x*P*f,V=R+m*A,L=F-m*A,E=C-x*P*f,$=v-a*x*P*p;return e.beginPath(),e.moveTo(W,M),e.arcTo(T,v,O,$,x),e.arcTo(R,k,V,k,m),e.lineTo(L,k),e.arcTo(F,k,E,$,m),e.arcTo(C,v,W,M,x),e.closePath(),e.lineWidth=c,e.fillStyle=s,e.fill(),h!=null&&(e.strokeStyle=h,e.stroke()),d}function Mt(t,e,i,l){let n=i.offset==null?0:i.offset,o=i.fillColor==null?"white":i.fillColor,r=i.strokeColor==null?"black":i.strokeColor,s=i.radius==null?0:i.radius,h=i.outlineWidth==null?1:i.outlineWidth,g=z(t,i,l),y=t.px(h),u=y/2,a=t.px(s),f=t.px(n),p=u,S=g-u,d=u,c=t.shieldSize()-u,w=(p+S)/2,x=d+f,m=c-f,b=a*Math.tan(Math.PI/4-Math.asin(f/(w-p))/2),T=x+b,C=m-b;return e.beginPath(),e.moveTo(w,c),e.arcTo(p,m,p,C,a),e.arcTo(p,x,w,d,a),e.lineTo(w,d),e.arcTo(S,x,S,T,a),e.arcTo(S,m,w,c,a),e.lineTo(w,c),e.closePath(),e.lineWidth=y,e.fillStyle=o,e.fill(),r!=null&&(e.strokeStyle=r,e.stroke()),g}function Rt(t,e,i,l){let n=i.angle==null?0:i.angle,o=i.fillColor==null?"white":i.fillColor,r=i.strokeColor==null?"black":i.strokeColor,s=i.radius==null?0:i.radius,h=i.outlineWidth==null?1:i.outlineWidth,g=Math.sin(n),y=Math.cos(n),u=Math.tan(n),a=Math.tan(Math.PI/4-n/2),f=z(t,i,l,"hexagonHorizontal"),p=t.px(h),S=p/2,d=t.px(s),c=S,w=f-S,x=S,m=t.shieldSize()-S,b=(x+m)/2,T=x+d*a*y,C=b-d*g,k=b+d*g,M=m-d*a*y,v=c+(b-C)*u,R=c+(b-x)*u,W=w-(b-x)*u,F=w-(b-C)*u,_=R-d*a*g,B=R+d*a,P=W-d*a,H=W+d*a*g;return e.beginPath(),e.moveTo(B,x),e.arcTo(W,x,H,T,d),e.arcTo(w,b,F,k,d),e.arcTo(W,m,P,m,d),e.arcTo(R,m,_,M,d),e.arcTo(c,b,v,C,d),e.arcTo(R,x,B,x,d),e.closePath(),e.lineWidth=p,e.fillStyle=o,e.fill(),r!=null&&(e.strokeStyle=r,e.stroke()),f}function Wt(t,e,i,l){let n=i.offset==null?0:i.offset,o=i.angle==null?0:i.angle,r=i.fillColor==null?"white":i.fillColor,s=i.strokeColor==null?"black":i.strokeColor,h=i.radius==null?0:i.radius,g=i.outlineWidth==null?1:i.outlineWidth,y=Math.sin(o),u=Math.cos(o),a=Math.tan(o),f=z(t,i,l),p=t.px(g),S=p/2,d=t.px(h),c=t.px(n),w=S,x=f-S,m=S,b=t.shieldSize()-S,T=w+d*a*y,C=(w+x)/2,k=x-d*a*y,M=m+c,v=(m+b)/2,R=b-c,W=w+(v-M)*a,F=x-(v-M)*a,_=v-d*a*u,B=v+d*a*u,P=Math.atan(c/(C-W)),H=Math.sin(P),A=Math.cos(P),O=(Math.PI/2-o-P)/2,V=Math.cos(O),L=d*Math.cos(o+O)/V,E=d*Math.sin(o+O)/V,$=W+L-d*u,Ve=W+L-d*H,$e=F-L+d*H,je=F-L+d*u,Je=M+E-d*A,Qe=M+E-d*y,Ye=R-E+d*y,Ke=R-E+d*A;return e.beginPath(),e.moveTo(C,b),e.arcTo(W,R,$,Ye,d),e.arcTo(w,v,T,_,d),e.arcTo(W,M,Ve,Je,d),e.lineTo(C,m),e.arcTo(F,M,je,Qe,d),e.arcTo(x,v,k,B,d),e.arcTo(F,R,$e,Ke,d),e.lineTo(C,b),e.closePath(),e.lineWidth=p,e.fillStyle=r,e.fill(),s!=null&&(e.strokeStyle=s,e.stroke()),f}function Y(t,e){switch(e){case"diamond":return t.shieldSize()+t.px(4);default:return t.shieldSize()}}function Ge(t,e,i,l,n){return Ae[e](t,i,l,n)}var Ae={},re={};function I(t,e,i){Ae[t]=e,i!==void 0&&(re[t]=i)}I("diamond",kt);I("ellipse",xt);I("escutcheon",bt);I("fishhead",mt);I("hexagonVertical",Mt);I("hexagonHorizontal",Rt);I("octagonVertical",Wt);I("pentagon",vt);I("roundedRectangle",Q);I("trapezoid",Tt);I("triangle",Ct);Pe();function Oe(t,e,i,l){if(i==null||typeof i.banners>"u")return e;for(var n=0;n<i.banners.length;n++)l(t,e,i.banners[n],n);return e}function Ft(t,e,i){return{width:e.width,height:e.height+i*t.px(t.options.bannerHeight+t.options.bannerPadding)}}function ae(t){return t!==null&&t.length!==0&&t.length<=6}function de(t){return t==null||typeof t.banners>"u"?0:t.banners.length}function Le(t,e,i){var l=null,n,o=0,r;if(Array.isArray(e.spriteBlank))for(var s=0;s<e.spriteBlank.length&&(l=t.spriteRepo.getSprite(e.spriteBlank[s]),r=Ft(t,l.data,o),n=J(t,i.ref,e,r),!(n.fontPx>t.px(q)));s++);else l=t.spriteRepo.getSprite(e.spriteBlank);return l}function Pt(t){return t!=null&&typeof t.textColor<"u"?t.textColor:"black"}function Ee(t){return typeof t.shapeBlank<"u"?(e,i,l)=>Ge(e,t.shapeBlank.drawFunc,i,t.shapeBlank.params,l):He}function Bt(t,e,i,l){let o=de(i)*t.px(t.options.bannerHeight);e.save(),e.translate(0,o),Ee(i)(t,e,l.ref),e.restore()}function It(t,e){return typeof e.shapeBlank<"u"?Y(t,e.shapeBlank.drawFunc):t.shieldSize()}function zt(t,e,i,l){var n=de(i),o=null,r=Le(t,i,l);let s=n*t.px(t.options.bannerHeight);if(r==null?(e.translate(0,s),Ee(i)(t,e,l.ref),e.translate(0,-s),o={width:e.canvas.width,height:It(t,i)}):o={width:r.data.width,height:r.data.height},i.notext)return e;var h=J(t,l.ref,i,o);return h.yBaseline+=n*t.px(t.options.bannerHeight),typeof t.options.SHIELD_TEXT_HALO_COLOR_OVERRIDE<"u"?(e.strokeStyle=options.SHIELD_TEXT_HALO_COLOR_OVERRIDE,ne(t,e,l.ref,h)):i.textHaloColor&&(e.strokeStyle=i.textHaloColor,ne(t,e,l.ref,h)),e.fillStyle=Pt(i),Te(t,e,l.ref,h),t.options.SHIELD_TEXT_BBOX_COLOR&&(e.strokeStyle=t.options.SHIELD_TEXT_BBOX_COLOR,e.lineWidth=t.px(1),e.strokeRect(t.px(i.padding.left-.5),n*t.px(t.options.bannerHeight)+t.px(i.padding.top-.5),o.width-t.px(i.padding.left+i.padding.right-1),o.height-t.px(i.padding.top+i.padding.bottom-1))),e}function Xe(t,e){let i=he(t,e);i==null&&(console.warn("Didn't produce a shield for",JSON.stringify(e)),i=t.gfxFactory.createGraphics({width:1,height:1})),Ne(t,e.spriteID,i)}function Ne(t,e,i){let l=i.getImageData(0,0,i.canvas.width,i.canvas.height);t.spriteRepo.putSprite(e,{width:i.canvas.width,height:i.canvas.height,data:l.data},t.px(1))}function Ue(t,e){Ne(t,e,t.emptySprite())}function De(t,e){return e.refsByName&&t.name&&e.refsByName[t.name]?e.refsByName[t.name]:t.ref}function _t(t,e){var i=t[e.network];if(e==null)return null;if(i==null)return console.debug("Generic shield for",JSON.stringify(e)),ae(e.ref)?t.default:null;var l=De(e,i);return i.overrideByRef&&(i={...i,...i.overrideByRef[l]}),i.overrideByName&&(i={...i,...i.overrideByName[e.name||""]}),!ae(l)&&"noref"in i&&(i=i.noref,i.notext=!0),!ae(l)&&!i.notext&&!(i.refsByName&&e.name)?null:i}function Ht(t){let e=parseInt(t,10);if(isNaN(e))return t;let i="M".repeat(e/1e3)+"D".repeat(e%1e3/500)+"C".repeat(e%500/100)+"L".repeat(e%100/50)+"X".repeat(e%50/10)+"V".repeat(e%10/5)+"I".repeat(e%5);return i=i.replace("DCCCC","CM").replace("CCCC","CD").replace("LXXXX","XC").replace("XXXX","XL").replace("VIIII","IX").replace("IIII","IV"),i+t.slice(e.toString().length)}function Gt(t,e,i){let l=Math.max(t.shieldSize(),z(t,e.shapeBlank.params,i,e.shapeBlank.drawFunc)),n=Y(t,e.shapeBlank.drawFunc);return{width:l,height:n}}function he(t,e){let i=_t(t.shieldDef,e);if(i==null)return null;e.ref=De(e,i);let l=de(i),n=Le(t,i,e),o=t.shieldSize(),r=t.shieldSize();if(n==null){if(typeof i.shapeBlank<"u"){let g=Gt(t,i,e.ref);o=g.width,r=g.height}}else o=n.data.width,r=n.data.height;let s=l*t.px(t.options.bannerHeight);r+=s;let h=t.gfxFactory.createGraphics({width:o,height:r});return e.ref&&i.numberingSystem==="roman"&&(e.ref=Ht(e.ref)),Oe(t,h,i,Me),n==null?Bt(t,h,i,e):le(h,n,s,i.verticalReflect,i.colorLighten,i.colorDarken),zt(t,h,i,e),Oe(t,h,i,ve),h}function qe(){return(typeof window<"u"&&window.devicePixelRatio)>1?2:1}var K=class{createGraphics(e){var i=document.createElement("canvas").getContext("2d"),i=document.createElement("canvas").getContext("2d",{willReadFrequently:!0});return i.imageSmoothingQuality="high",i.textAlign="center",i.textBaseline="top",i.canvas.width=e.width,i.canvas.height=e.height,i}pixelRatio(){return qe()}};var se=class{shieldDef;options;debugOptions;gfxFactory;spriteRepo;_emptySpriteCache;emptySprite(){return this._emptySpriteCache||(this._emptySpriteCache=this.gfxFactory.createGraphics({width:1,height:1})),this._emptySpriteCache}px(e){return e*this.gfxFactory.pixelRatio()}shieldSize(){return this.px(this.options.shieldSize)}},ue=class{map;constructor(e){this.map=e}getSprite(e){return this.map.style.getImage(e)}putSprite(e,i,l){this.map.addImage(e,i,{pixelRatio:l})}},Z=class{_shieldPredicate=()=>!0;_networkPredicate=()=>!0;_routeParser;_renderContext;constructor(e){this._routeParser=e,this._renderContext=new se,this._renderContext.gfxFactory=new K}setShields(e){this._renderContext.options=e.options,this._renderContext.shieldDef=e.networks}debugOptions(e){return this._renderContext.debugOptions=e,this}filterImageID(e){return this._shieldPredicate=e,this}filterNetwork(e){return this._networkPredicate=e,this}graphicsFactory(e){return this._renderContext.gfxFactory=e,this}renderOnMaplibreGL(e){return this.renderOnRepository(new ue(e)),e.on("styleimagemissing",this.getStyleImageMissingHandler()),this}renderOnRepository(e){return this._renderContext.spriteRepo||(this._renderContext.spriteRepo=e),this}getStyleImageMissingHandler(){return e=>{try{if(!this._shieldPredicate(e.id))return;let i=this._routeParser.parse(e.id);if(!this._networkPredicate(i.network)){Ue(this._renderContext,e.id);return}i.spriteID=e.id,this._renderContext.debugOptions=this.debugOptions,i&&Xe(this._renderContext,i)}catch(i){console.error(`Exception while loading image \u2018${e?.id}\u2019:
`,i)}}}getGraphicForRoute(e,i,l){return he(this._renderContext,{network:e,ref:i,name:l,spriteID:this._routeParser.format(e,i,l)})}emptySprite(){return this._renderContext.emptySprite()}createGraphics(e){return this._renderContext.gfxFactory.createGraphics(e)}pixelRatio(){return this._renderContext.px(1)}},fe=class extends Z{constructor(e,i){super(i),this.setShields(e)}},pe=class extends Z{constructor(e,i){super(i),this.setShieldURL(e)}async setShieldURL(e){await fetch(e).then(i=>i.json()).then(i=>super.setShields(i)).catch(i=>console.error(i))}},ee=class{sprites={};getSprite(e){return this.sprites[e]}hasSprite(e){return e in this.sprites}putSprite(e,i){this.sprites[e]=i}},ei=new ee;export{ee as InMemorySpriteRepository,fe as ShieldRenderer,pe as URLShieldRenderer,qe as getDOMPixelRatio,le as transposeImageData};
var Ze=Object.create;var ge=Object.defineProperty;var et=Object.getOwnPropertyDescriptor;var tt=Object.getOwnPropertyNames;var it=Object.getPrototypeOf,lt=Object.prototype.hasOwnProperty;var nt=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports);var ot=(t,e,i,l)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of tt(e))!lt.call(t,n)&&n!==i&&ge(t,n,{get:()=>e[n],enumerable:!(l=et(e,n))||l.enumerable});return t};var rt=(t,e,i)=>(i=t!=null?Ze(it(t)):{},ot(e||!t||!t.__esModule?ge(i,"default",{value:t,enumerable:!0}):i,t));var Se=nt((Ot,ye)=>{"use strict";ye.exports={aliceblue:[240,248,255],antiquewhite:[250,235,215],aqua:[0,255,255],aquamarine:[127,255,212],azure:[240,255,255],beige:[245,245,220],bisque:[255,228,196],black:[0,0,0],blanchedalmond:[255,235,205],blue:[0,0,255],blueviolet:[138,43,226],brown:[165,42,42],burlywood:[222,184,135],cadetblue:[95,158,160],chartreuse:[127,255,0],chocolate:[210,105,30],coral:[255,127,80],cornflowerblue:[100,149,237],cornsilk:[255,248,220],crimson:[220,20,60],cyan:[0,255,255],darkblue:[0,0,139],darkcyan:[0,139,139],darkgoldenrod:[184,134,11],darkgray:[169,169,169],darkgreen:[0,100,0],darkgrey:[169,169,169],darkkhaki:[189,183,107],darkmagenta:[139,0,139],darkolivegreen:[85,107,47],darkorange:[255,140,0],darkorchid:[153,50,204],darkred:[139,0,0],darksalmon:[233,150,122],darkseagreen:[143,188,143],darkslateblue:[72,61,139],darkslategray:[47,79,79],darkslategrey:[47,79,79],darkturquoise:[0,206,209],darkviolet:[148,0,211],deeppink:[255,20,147],deepskyblue:[0,191,255],dimgray:[105,105,105],dimgrey:[105,105,105],dodgerblue:[30,144,255],firebrick:[178,34,34],floralwhite:[255,250,240],forestgreen:[34,139,34],fuchsia:[255,0,255],gainsboro:[220,220,220],ghostwhite:[248,248,255],gold:[255,215,0],goldenrod:[218,165,32],gray:[128,128,128],green:[0,128,0],greenyellow:[173,255,47],grey:[128,128,128],honeydew:[240,255,240],hotpink:[255,105,180],indianred:[205,92,92],indigo:[75,0,130],ivory:[255,255,240],khaki:[240,230,140],lavender:[230,230,250],lavenderblush:[255,240,245],lawngreen:[124,252,0],lemonchiffon:[255,250,205],lightblue:[173,216,230],lightcoral:[240,128,128],lightcyan:[224,255,255],lightgoldenrodyellow:[250,250,210],lightgray:[211,211,211],lightgreen:[144,238,144],lightgrey:[211,211,211],lightpink:[255,182,193],lightsalmon:[255,160,122],lightseagreen:[32,178,170],lightskyblue:[135,206,250],lightslategray:[119,136,153],lightslategrey:[119,136,153],lightsteelblue:[176,196,222],lightyellow:[255,255,224],lime:[0,255,0],limegreen:[50,205,50],linen:[250,240,230],magenta:[255,0,255],maroon:[128,0,0],mediumaquamarine:[102,205,170],mediumblue:[0,0,205],mediumorchid:[186,85,211],mediumpurple:[147,112,219],mediumseagreen:[60,179,113],mediumslateblue:[123,104,238],mediumspringgreen:[0,250,154],mediumturquoise:[72,209,204],mediumvioletred:[199,21,133],midnightblue:[25,25,112],mintcream:[245,255,250],mistyrose:[255,228,225],moccasin:[255,228,181],navajowhite:[255,222,173],navy:[0,0,128],oldlace:[253,245,230],olive:[128,128,0],olivedrab:[107,142,35],orange:[255,165,0],orangered:[255,69,0],orchid:[218,112,214],palegoldenrod:[238,232,170],palegreen:[152,251,152],paleturquoise:[175,238,238],palevioletred:[219,112,147],papayawhip:[255,239,213],peachpuff:[255,218,185],peru:[205,133,63],pink:[255,192,203],plum:[221,160,221],powderblue:[176,224,230],purple:[128,0,128],rebeccapurple:[102,51,153],red:[255,0,0],rosybrown:[188,143,143],royalblue:[65,105,225],saddlebrown:[139,69,19],salmon:[250,128,114],sandybrown:[244,164,96],seagreen:[46,139,87],seashell:[255,245,238],sienna:[160,82,45],silver:[192,192,192],skyblue:[135,206,235],slateblue:[106,90,205],slategray:[112,128,144],slategrey:[112,128,144],snow:[255,250,250],springgreen:[0,255,127],steelblue:[70,130,180],tan:[210,180,140],teal:[0,128,128],thistle:[216,191,216],tomato:[255,99,71],turquoise:[64,224,208],violet:[238,130,238],wheat:[245,222,179],white:[255,255,255],whitesmoke:[245,245,245],yellow:[255,255,0],yellowgreen:[154,205,50]}});var te=rt(Se(),1),we=at,ce={red:0,orange:60,yellow:120,green:180,blue:240,purple:300};function at(t){var e,i=[],l=1,n;if(typeof t=="string")if(te.default[t])i=te.default[t].slice(),n="rgb";else if(t==="transparent")l=0,n="rgb",i=[0,0,0];else if(/^#[A-Fa-f0-9]+$/.test(t)){var o=t.slice(1),r=o.length,s=r<=4;l=1,s?(i=[parseInt(o[0]+o[0],16),parseInt(o[1]+o[1],16),parseInt(o[2]+o[2],16)],r===4&&(l=parseInt(o[3]+o[3],16)/255)):(i=[parseInt(o[0]+o[1],16),parseInt(o[2]+o[3],16),parseInt(o[4]+o[5],16)],r===8&&(l=parseInt(o[6]+o[7],16)/255)),i[0]||(i[0]=0),i[1]||(i[1]=0),i[2]||(i[2]=0),n="rgb"}else if(e=/^((?:rgb|hs[lvb]|hwb|cmyk?|xy[zy]|gray|lab|lchu?v?|[ly]uv|lms)a?)\s*\(([^\)]*)\)/.exec(t)){var h=e[1],g=h==="rgb",o=h.replace(/a$/,"");n=o;var r=o==="cmyk"?4:o==="gray"?1:3;i=e[2].trim().split(/\s*[,\/]\s*|\s+/).map(function(a,f){if(/%$/.test(a))return f===r?parseFloat(a)/100:o==="rgb"?parseFloat(a)*255/100:parseFloat(a);if(o[f]==="h"){if(/deg$/.test(a))return parseFloat(a);if(ce[a]!==void 0)return ce[a]}return parseFloat(a)}),h===o&&i.push(1),l=g||i[r]===void 0?1:i[r],i=i.slice(0,r)}else t.length>10&&/[0-9](?:\s|\/)/.test(t)&&(i=t.match(/([0-9]+)/g).map(function(y){return parseFloat(y)}),n=t.match(/([a-z])/ig).join("").toLowerCase());else isNaN(t)?Array.isArray(t)||t.length?(i=[t[0],t[1],t[2]],n="rgb",l=t.length===4?t[3]:1):t instanceof Object&&(t.r!=null||t.red!=null||t.R!=null?(n="rgb",i=[t.r||t.red||t.R||0,t.g||t.green||t.G||0,t.b||t.blue||t.B||0]):(n="hsl",i=[t.h||t.hue||t.H||0,t.s||t.saturation||t.S||0,t.l||t.lightness||t.L||t.b||t.brightness]),l=t.a||t.alpha||t.opacity||1,t.opacity!=null&&(l/=100)):(n="rgb",i=[t>>>16,(t&65280)>>>8,t&255]);return{space:n,values:i,alpha:l}}var U={name:"rgb",min:[0,0,0],max:[255,255,255],channel:["red","green","blue"],alias:["RGB"]};var j={name:"hsl",min:[0,0,0],max:[360,100,100],channel:["hue","saturation","lightness"],alias:["HSL"],rgb:function(t){var e=t[0]/360,i=t[1]/100,l=t[2]/100,n,o,r,s,h;if(i===0)return h=l*255,[h,h,h];l<.5?o=l*(1+i):o=l+i-l*i,n=2*l-o,s=[0,0,0];for(var g=0;g<3;g++)r=e+1/3*-(g-1),r<0?r++:r>1&&r--,6*r<1?h=n+(o-n)*6*r:2*r<1?h=o:3*r<2?h=n+(o-n)*(2/3-r)*6:h=n,s[g]=h*255;return s}};U.hsl=function(t){var e=t[0]/255,i=t[1]/255,l=t[2]/255,n=Math.min(e,i,l),o=Math.max(e,i,l),r=o-n,s,h,g;return o===n?s=0:e===o?s=(i-l)/r:i===o?s=2+(l-e)/r:l===o&&(s=4+(e-i)/r),s=Math.min(s*60,360),s<0&&(s+=360),g=(n+o)/2,o===n?h=0:g<=.5?h=r/(o+n):h=r/(2-o-n),[s,h*100,g*100]};function E(t){Array.isArray(t)&&t.raw&&(t=String.raw(...arguments));var e,i,l,n=we(t);if(!n.space)return[];let o=n.space[0]==="h"?j.min:U.min,r=n.space[0]==="h"?j.max:U.max;return e=Array(3),e[0]=Math.min(Math.max(n.values[0],o[0]),r[0]),e[1]=Math.min(Math.max(n.values[1],o[1]),r[1]),e[2]=Math.min(Math.max(n.values[2],o[2]),r[2]),n.space[0]==="h"&&(e=j.rgb(e)),e.push(Math.min(Math.max(n.alpha,0),1)),e}var dt='"sans-serif-condensed", "Arial Narrow", sans-serif',X=(t,e)=>`bold ${t}px ${e||dt}`,q=12;function ie(t,e,i){return 255-t/255*(255-i)-(1-t/255)*(255-e)}function ht(t,e,i,l){e[l]=t[i],e[l+1]=t[i+1],e[l+2]=t[i+2],e[l+3]=t[i+3]}function st(t,e,i,l,n,o){e[l]=ie(t[i],n[0],o[0]),e[l+1]=ie(t[i+1],n[1],o[1]),e[l+2]=ie(t[i+2],n[2],o[2]),e[l+3]=t[i+3]}function le(t,e,i,l,n,o){let r=t.createImageData(e.data.width,e.data.height),s=n||o?st:ht,h=n?E(n):E("#000"),g=o?E(o):E("#fff");if(l)for(let y=0;y<e.data.height;y++)for(let u=0;u<e.data.width;u++){let f=((e.data.height-y-1)*e.data.width+u)*4,p=(y*e.data.width+u)*4;s(e.data.data,r.data,p,f,h,g)}else for(let y=0;y<e.data.data.length;y+=4)s(e.data.data,r.data,y,y,h,g);t.putImageData(r,0,i)}var A={Middle:"middle",Top:"top",Bottom:"bottom"};function be(t,e){var i=t.width,l=t.height,n=e.width,o=e.height;return i*l/Math.sqrt(i*i*o*o+l*l*n*n)}function ut(t,e){return{scale:be(t,e),valign:A.Middle}}function ft(t,e){return{scale:be(t,{height:e.width/2,width:e.height}),valign:A.Top}}function Ce(t,e){var i=t.height/e.height,l=t.width/e.width;return{scale:Math.min(l,i),valign:A.Middle}}function pt(t,e,i){let l=2;return i!==void 0&&i.radius!==void 0&&(l=i.radius),Ce({width:t.width-l*(2-Math.sqrt(2)),height:t.height-l*(2-Math.sqrt(2))},e)}function ke(t,e){let i=t.width,l=t.height,n=e.width,o=e.height;return{scale:i*l/(l*n+i*o),valign:A.Middle}}function gt(t,e){return{scale:ke(t,e).scale,valign:A.Top}}function yt(t,e,i,l,n,o){var r=t.px(i.top)||0,s=t.px(i.bottom)||0,h=t.px(i.left)||0,g=t.px(i.right)||0,y=t.px(o),u=t.gfxFactory.createGraphics(l);u.font=X(q,t.options.shieldFont),u.textAlign="center",u.textBaseline="top";var a=u.measureText(e),f=a.width,p=a.actualBoundingBoxDescent,S=l.height-r-s,d=l.width-h-g,c=h+d/2;let w=We[n.constraintFunc],x=w({height:S,width:d},{height:p,width:f},n.options);var C=Math.min(y,q*x.scale);u.font=X(C,t.options.shieldFont),u.textAlign="center",u.textBaseline="top",a=u.measureText(e),p=a.actualBoundingBoxDescent;var b;switch(x.valign){case A.Top:b=r;break;case A.Bottom:b=r+S-p;break;case A.Middle:default:b=r+(S-p)/2;break}return{xBaseline:c,yBaseline:b,fontPx:C}}var St={padding:{top:0,bottom:0,left:0,right:0}};function J(t,e,i,l){i==null&&(i=St);var n=i.padding||{},o={constraintFunc:"rect"},r=14;return typeof i.textLayout!="undefined"&&(o=i.textLayout),typeof i.maxFontSize!="undefined"&&(r=Math.min(r,i.maxFontSize)),yt(t,e,n,l,o,r)}function me(t,e,i,l){Te(t,e,l),e.fillText(i,l.xBaseline,l.yBaseline)}function ne(t,e,i,l){Te(t,e,l),e.shadowColor=e.strokeStyle,e.shadowBlur=0,e.lineWidth=t.px(2),e.strokeText(i,l.xBaseline,l.yBaseline),e.shadowColor=null,e.shadowBlur=null}function Te(t,e,i){e.textAlign="center",e.textBaseline="top",e.font=X(i.fontPx,t.options.shieldFont)}function ve(t,e,i,l){Re(t,e,i,l,!0)}function Me(t,e,i,l){Re(t,e,i,l,!1)}function Re(t,e,i,l,n){let o={padding:{top:t.options.bannerPadding,bottom:0,left:0,right:0}};var r=J(t,i,o,{width:e.canvas.width,height:t.px(t.options.bannerHeight-t.options.bannerPadding)});e.font=X(r.fontPx,t.options.shieldFont),e.textBaseline="top",e.textAlign="center",n?(e.fillStyle=t.options.bannerTextColor,e.fillText(i,r.xBaseline,r.yBaseline+l*t.px(t.options.bannerHeight-t.options.bannerPadding))):(e.strokeStyle=e.shadowColor=t.options.bannerTextHaloColor,e.shadowBlur=0,e.lineWidth=t.px(2),e.strokeText(i,r.xBaseline,r.yBaseline+l*t.px(t.options.bannerHeight-t.options.bannerPadding)),e.shadowColor=null,e.shadowBlur=null)}function oe(t,e,i){var l=t.emptySprite();return l.font=X(i,t.options.shieldFont),Math.ceil(l.measureText(e).width)}var We={};function N(t,e){We[t]=e}N("diamond",ke);N("ellipse",ut);N("rect",Ce);N("roundedRect",pt);N("southHalfEllipse",ft);N("triangleDown",gt);function ct(t,e,i){Q(t,e,{fillColor:"white",strokeColor:"black",outlineWidth:1,radius:2,rectWidth:20});let l=i.fillColor,n=t.px(.5),o=t.shieldSize()/3-n;return e.beginPath(),e.arc(t.shieldSize()/2,t.shieldSize()/2,o,0,2*Math.PI,!1),e.fillStyle=l,e.strokeStyle=i.strokeColor,e.fill(),e.lineWidth=n,e.stroke(),e}function wt(t,e,i){Q(t,e,{fillColor:"#006747",strokeColor:"white",outlineWidth:1,radius:2,rectWidth:20});let l=i.fillColor,n=t.px(.5),o=.15*t.shieldSize()+n,r=.7*t.shieldSize()-2*n,s=.4*t.shieldSize()+n,h=.45*t.shieldSize()-2*n;return e.beginPath(),e.rect(o,s,r,h),e.fillStyle=l,e.strokeStyle=i.strokeColor,e.fill(),e.lineWidth=n,e.stroke(),e}function Pe(){I("branson",wt,20),I("paBelt",ct,20)}var Ie=20,ze=34,_e=18;function z(t,e,i,l){if(re[l]!==void 0)return t.px(re[l]);let n=e.rectWidth==null?null:e.rectWidth,o=e.angle==null?0:e.angle,r=Math.tan(o);if(n==null){let s=oe(t,i,t.px(_e))+t.px(2),h=t.px(Ie);switch(l){case"pentagon":let g=e.offset==null?0:e.offset;s+=(t.shieldSize()-t.px(g))*r/2;break;case"trapezoid":s+=t.shieldSize()*r/2;break;case"triangle":h+=t.px(2);break;case"diamond":case"hexagonHorizontal":h+=t.px(4);break}return Math.max(h,Math.min(t.px(ze),s))}else return t.px(n)}function xt(t,e,i,l){let n=i.fillColor==null?"white":i.fillColor,o=i.strokeColor==null?"black":i.strokeColor,r=z(t,i,l),s=t.px(1),h=r/2-s,g=t.shieldSize()/2-s;return e.beginPath(),e.ellipse(e.canvas.width/2,t.shieldSize()/2,h,g,0,2*Math.PI,!1),e.fillStyle=n,e.fill(),e.lineWidth=s,e.strokeStyle=o,e.stroke(),r}function He(t,e){var i=oe(t,e,t.px(_e))+t.px(2),l=Math.max(t.px(Ie),Math.min(t.px(ze),i));return t.gfxFactory.createGraphics({width:l,height:t.shieldSize()})}function Q(t,e,i,l){let n=i.fillColor==null?"white":i.fillColor,o=i.strokeColor==null?"black":i.strokeColor,r=i.radius==null?0:i.radius,s=i.outlineWidth==null?1:i.outlineWidth,h=z(t,i,l),g=t.px(s),y=g/2,u=t.px(r),a=y,f=y+u,p=h-y-u,S=h-y,d=y,c=y+u,w=t.shieldSize()-y-u,x=t.shieldSize()-y;return e.beginPath(),e.moveTo(p,d),e.arcTo(S,d,S,c,u),e.arcTo(S,x,p,x,u),e.arcTo(a,x,a,w,u),e.arcTo(a,d,f,d,u),e.closePath(),e.lineWidth=g,e.fillStyle=n,e.fill(),o!=null&&(e.strokeStyle=o,e.stroke()),h}function bt(t,e,i,l){let n=i.offset==null?0:i.offset,o=i.fillColor==null?"white":i.fillColor,r=i.strokeColor==null?"black":i.strokeColor,s=i.radius==null?0:i.radius,h=i.outlineWidth==null?1:i.outlineWidth,g=z(t,i,l),y=t.px(h),u=y/2,a=t.px(s),f=t.px(n),p=u,S=g-u,d=u,c=t.shieldSize()-u,w=p+a,x=(p+S)/2,C=d+a,b=c-f,m=(2*p+x)/3,k=(x+2*S)/3,T=(b+c)/2,M=(T+2*c)/3;return e.beginPath(),e.moveTo(x,c),e.bezierCurveTo(m,M,p,T,p,b),e.arcTo(p,d,w,d,a),e.arcTo(S,d,S,C,a),e.lineTo(S,b),e.bezierCurveTo(S,T,k,M,x,c),e.closePath(),e.lineWidth=y,e.fillStyle=o,e.fill(),r!=null&&(e.strokeStyle=r,e.stroke()),g}function Ct(t,e,i,l){let n=i.pointUp==null?!1:i.pointUp,o=i.fillColor==null?"white":i.fillColor,r=i.strokeColor==null?"black":i.strokeColor,s=i.outlineWidth==null?1:i.outlineWidth,h=n?-1:1,g=z(t,i,l),y=t.px(s),u=y/2,a=u,f=g-u,p=n?t.shieldSize()-u:u,S=n?u:t.shieldSize()-u,d=a+t.px(1),c=a+t.px(2.5),w=(a+f)/2,x=f-t.px(2.5),C=f-t.px(1),b=p+h*t.px(2),m=p+h*t.px(4.5),k=p+h*t.px(7),T=S-h*t.px(6),M=S-h*t.px(1),v=(a+w)/2,R=(w+f)/2;e.beginPath(),e.moveTo(w,S),e.bezierCurveTo(v,M,a,T,a,k),e.bezierCurveTo(a,m,d,b,c,p),e.lineTo(x,p),e.bezierCurveTo(C,b,f,m,f,k),e.bezierCurveTo(f,T,R,M,w,S),e.closePath(),e.lineWidth=y,e.fillStyle=o,e.fill(),r!=null&&(e.strokeStyle=r,e.stroke())}function kt(t,e,i,l){let n=i.pointUp==null?!1:i.pointUp,o=i.fillColor==null?"white":i.fillColor,r=i.strokeColor==null?"black":i.strokeColor,s=i.radius==null?0:i.radius,h=i.outlineWidth==null?1:i.outlineWidth,g=n?-1:1,y=z(t,i,l,"triangle"),u=t.px(h),a=u/2,f=t.px(s),p=a,S=y-a,d=n?t.shieldSize()-a:a,c=n?a:t.shieldSize()-a,w=p+f,x=(p+S)/2,C=S-f,b=d+g*f,m=Math.atan((x-w)/Math.abs(c-f-b)),k=Math.sin(m),T=Math.cos(m),M=Math.tan(m/2),v=Math.tan(Math.PI/4-m/2),R=w-f*T,W=x-f*v,F=x+f*v,_=C+f*T,B=b+g*f*M,P=b+g*f*k,H=c-g*f*(1-k);return e.beginPath(),e.moveTo(x,c),e.arcTo(W,c,R,P,f),e.arcTo(p,B,p,b,f),e.arcTo(p,d,w,d,f),e.arcTo(S,d,S,b,f),e.arcTo(S,B,_,P,f),e.arcTo(F,c,x,c,f),e.closePath(),e.lineWidth=u,e.fillStyle=o,e.fill(),r!=null&&(e.strokeStyle=r,e.stroke()),y}function mt(t,e,i,l){let n=i.shortSideUp==null?!1:i.shortSideUp,o=i.angle==null?0:i.angle,r=i.fillColor==null?"white":i.fillColor,s=i.strokeColor==null?"black":i.strokeColor,h=i.radius==null?0:i.radius,g=i.outlineWidth==null?1:i.outlineWidth,y=n?-1:1,u=Math.sin(o),a=Math.cos(o),f=Math.tan(o),p=z(t,i,l,"trapezoid"),S=t.px(g),d=S/2,c=t.px(h),w=d,x=p-d,C=n?t.shieldSize()-d:d,b=n?d:t.shieldSize()-d,m=C+y*c*(1+u),k=b-y*c*(1-u),T=w+(m-C)*f,M=T+c*a,v=w+y*(k-C)*f,R=w+y*(b-C)*f,W=v+y*c*a,F=p-R,_=p-v,B=p-M;return e.beginPath(),e.moveTo(B,C),e.arcTo(x,C,_,k,c),e.arcTo(F,b,W,b,c),e.arcTo(R,b,T,m,c),e.arcTo(w,C,B,C,c),e.closePath(),e.lineWidth=S,e.fillStyle=r,e.fill(),s!=null&&(e.strokeStyle=s,e.stroke()),p}function Tt(t,e,i,l){let n=i.fillColor==null?"white":i.fillColor,o=i.strokeColor==null?"black":i.strokeColor,r=i.radius==null?0:i.radius,s=i.outlineWidth==null?1:i.outlineWidth,h=Y(t,"diamond"),g=z(t,i,l,"diamond"),y=t.px(s),u=y/2,a=t.px(r),f=u,p=g-u,S=u,d=h-u,c=(f+p)/2,w=(S+d)/2,x=Math.atan((c-a-f)/(d-a-w)),C=Math.sin(x),b=Math.cos(x),m=Math.tan(x/2),k=Math.tan(Math.PI/4-x/2),T=f+a*(1-b),M=c-a*b,v=c-a*k,R=c+a*k,W=c+a*b,F=p-a*(1-b),_=S+a*(1-C),B=w-a*C,P=w-a*m,H=w+a*m,G=w+a*C,O=d-a*(1-C);return e.beginPath(),e.moveTo(c,d),e.arcTo(v,d,T,G,a),e.arcTo(f,H,f,w,a),e.arcTo(f,P,M,_,a),e.arcTo(v,S,c,S,a),e.arcTo(R,S,F,B,a),e.arcTo(p,P,p,w,a),e.arcTo(p,H,W,O,a),e.arcTo(R,d,c,d,a),e.closePath(),e.lineWidth=y,e.fillStyle=n,e.fill(),o!=null&&(e.strokeStyle=o,e.stroke()),g}function vt(t,e,i,l){let n=i.pointUp==null?!0:i.pointUp,o=i.offset==null?0:i.offset,r=i.angle==null?0:i.angle,s=i.fillColor==null?"white":i.fillColor,h=i.strokeColor==null?"black":i.strokeColor,g=i.radius1==null?0:i.radius1,y=i.radius2==null?0:i.radius2,u=i.outlineWidth==null?1:i.outlineWidth,a=n?-1:1,f=Math.sin(r),p=Math.cos(r),S=Math.tan(r),d=z(t,i,l,"pentagon"),c=t.px(u),w=c/2,x=t.px(g),C=t.px(y),b=t.px(o),m=w,k=d-w,T=n?t.shieldSize()-w:w,M=n?w:t.shieldSize()-w,v=M-a*b,R=m+a*(v-T)*S,W=(m+k)/2,F=k-a*(v-T)*S,_=Math.atan(b/(W-m)),B=(Math.PI/2-_+r)/2,P=Math.tan(B),H=(Math.PI/2-r)/2,G=Math.tan(H),O=m+x*P*f,V=R+C*G,D=F-C*G,L=k-x*P*f,$=v-a*x*P*p;return e.beginPath(),e.moveTo(W,M),e.arcTo(m,v,O,$,x),e.arcTo(R,T,V,T,C),e.lineTo(D,T),e.arcTo(F,T,L,$,C),e.arcTo(k,v,W,M,x),e.closePath(),e.lineWidth=c,e.fillStyle=s,e.fill(),h!=null&&(e.strokeStyle=h,e.stroke()),d}function Mt(t,e,i,l){let n=i.offset==null?0:i.offset,o=i.fillColor==null?"white":i.fillColor,r=i.strokeColor==null?"black":i.strokeColor,s=i.radius==null?0:i.radius,h=i.outlineWidth==null?1:i.outlineWidth,g=z(t,i,l),y=t.px(h),u=y/2,a=t.px(s),f=t.px(n),p=u,S=g-u,d=u,c=t.shieldSize()-u,w=(p+S)/2,x=d+f,C=c-f,b=a*Math.tan(Math.PI/4-Math.asin(f/(w-p))/2),m=x+b,k=C-b;return e.beginPath(),e.moveTo(w,c),e.arcTo(p,C,p,k,a),e.arcTo(p,x,w,d,a),e.lineTo(w,d),e.arcTo(S,x,S,m,a),e.arcTo(S,C,w,c,a),e.lineTo(w,c),e.closePath(),e.lineWidth=y,e.fillStyle=o,e.fill(),r!=null&&(e.strokeStyle=r,e.stroke()),g}function Rt(t,e,i,l){let n=i.angle==null?0:i.angle,o=i.fillColor==null?"white":i.fillColor,r=i.strokeColor==null?"black":i.strokeColor,s=i.radius==null?0:i.radius,h=i.outlineWidth==null?1:i.outlineWidth,g=Math.sin(n),y=Math.cos(n),u=Math.tan(n),a=Math.tan(Math.PI/4-n/2),f=z(t,i,l,"hexagonHorizontal"),p=t.px(h),S=p/2,d=t.px(s),c=S,w=f-S,x=S,C=t.shieldSize()-S,b=(x+C)/2,m=x+d*a*y,k=b-d*g,T=b+d*g,M=C-d*a*y,v=c+(b-k)*u,R=c+(b-x)*u,W=w-(b-x)*u,F=w-(b-k)*u,_=R-d*a*g,B=R+d*a,P=W-d*a,H=W+d*a*g;return e.beginPath(),e.moveTo(B,x),e.arcTo(W,x,H,m,d),e.arcTo(w,b,F,T,d),e.arcTo(W,C,P,C,d),e.arcTo(R,C,_,M,d),e.arcTo(c,b,v,k,d),e.arcTo(R,x,B,x,d),e.closePath(),e.lineWidth=p,e.fillStyle=o,e.fill(),r!=null&&(e.strokeStyle=r,e.stroke()),f}function Wt(t,e,i,l){let n=i.offset==null?0:i.offset,o=i.angle==null?0:i.angle,r=i.fillColor==null?"white":i.fillColor,s=i.strokeColor==null?"black":i.strokeColor,h=i.radius==null?0:i.radius,g=i.outlineWidth==null?1:i.outlineWidth,y=Math.sin(o),u=Math.cos(o),a=Math.tan(o),f=z(t,i,l),p=t.px(g),S=p/2,d=t.px(h),c=t.px(n),w=S,x=f-S,C=S,b=t.shieldSize()-S,m=w+d*a*y,k=(w+x)/2,T=x-d*a*y,M=C+c,v=(C+b)/2,R=b-c,W=w+(v-M)*a,F=x-(v-M)*a,_=v-d*a*u,B=v+d*a*u,P=Math.atan(c/(k-W)),H=Math.sin(P),G=Math.cos(P),O=(Math.PI/2-o-P)/2,V=Math.cos(O),D=d*Math.cos(o+O)/V,L=d*Math.sin(o+O)/V,$=W+D-d*u,Ve=W+D-d*H,$e=F-D+d*H,je=F-D+d*u,Je=M+L-d*G,Qe=M+L-d*y,Ye=R-L+d*y,Ke=R-L+d*G;return e.beginPath(),e.moveTo(k,b),e.arcTo(W,R,$,Ye,d),e.arcTo(w,v,m,_,d),e.arcTo(W,M,Ve,Je,d),e.lineTo(k,C),e.arcTo(F,M,je,Qe,d),e.arcTo(x,v,T,B,d),e.arcTo(F,R,$e,Ke,d),e.lineTo(k,b),e.closePath(),e.lineWidth=p,e.fillStyle=r,e.fill(),s!=null&&(e.strokeStyle=s,e.stroke()),f}function Y(t,e){switch(e){case"diamond":return t.shieldSize()+t.px(4);default:return t.shieldSize()}}function Ae(t,e,i,l,n){return Ge[e](t,i,l,n)}var Ge={},re={};function I(t,e,i){Ge[t]=e,i!==void 0&&(re[t]=i)}I("diamond",Tt);I("ellipse",xt);I("escutcheon",bt);I("fishhead",Ct);I("hexagonVertical",Mt);I("hexagonHorizontal",Rt);I("octagonVertical",Wt);I("pentagon",vt);I("roundedRectangle",Q);I("trapezoid",mt);I("triangle",kt);Pe();function Oe(t,e,i,l){if(i==null||typeof i.banners=="undefined")return e;for(var n=0;n<i.banners.length;n++)l(t,e,i.banners[n],n);return e}function Ft(t,e,i){return{width:e.width,height:e.height+i*t.px(t.options.bannerHeight+t.options.bannerPadding)}}function ae(t){return t!==null&&t.length!==0&&t.length<=6}function de(t){return t==null||typeof t.banners=="undefined"?0:t.banners.length}function De(t,e,i){var l=null,n,o=0,r;if(Array.isArray(e.spriteBlank))for(var s=0;s<e.spriteBlank.length&&(l=t.spriteRepo.getSprite(e.spriteBlank[s]),r=Ft(t,l.data,o),n=J(t,i.ref,e,r),!(n.fontPx>t.px(q)));s++);else l=t.spriteRepo.getSprite(e.spriteBlank);return l}function Pt(t){return t!=null&&typeof t.textColor!="undefined"?t.textColor:"black"}function Le(t){return typeof t.shapeBlank!="undefined"?(e,i,l)=>Ae(e,t.shapeBlank.drawFunc,i,t.shapeBlank.params,l):He}function Bt(t,e,i,l){let o=de(i)*t.px(t.options.bannerHeight);e.save(),e.translate(0,o),Le(i)(t,e,l.ref),e.restore()}function It(t,e){return typeof e.shapeBlank!="undefined"?Y(t,e.shapeBlank.drawFunc):t.shieldSize()}function zt(t,e,i,l){var n=de(i),o=null,r=De(t,i,l);let s=n*t.px(t.options.bannerHeight);if(r==null?(e.translate(0,s),Le(i)(t,e,l.ref),e.translate(0,-s),o={width:e.canvas.width,height:It(t,i)}):o={width:r.data.width,height:r.data.height},i.notext)return e;var h=J(t,l.ref,i,o);return h.yBaseline+=n*t.px(t.options.bannerHeight),typeof t.options.SHIELD_TEXT_HALO_COLOR_OVERRIDE!="undefined"?(e.strokeStyle=options.SHIELD_TEXT_HALO_COLOR_OVERRIDE,ne(t,e,l.ref,h)):i.textHaloColor&&(e.strokeStyle=i.textHaloColor,ne(t,e,l.ref,h)),e.fillStyle=Pt(i),me(t,e,l.ref,h),t.options.SHIELD_TEXT_BBOX_COLOR&&(e.strokeStyle=t.options.SHIELD_TEXT_BBOX_COLOR,e.lineWidth=t.px(1),e.strokeRect(t.px(i.padding.left-.5),n*t.px(t.options.bannerHeight)+t.px(i.padding.top-.5),o.width-t.px(i.padding.left+i.padding.right-1),o.height-t.px(i.padding.top+i.padding.bottom-1))),e}function Ee(t,e){let i=he(t,e);i==null&&(console.warn("Didn't produce a shield for",JSON.stringify(e)),i=t.gfxFactory.createGraphics({width:1,height:1})),Xe(t,e.spriteID,i)}function Xe(t,e,i){let l=i.getImageData(0,0,i.canvas.width,i.canvas.height);t.spriteRepo.putSprite(e,{width:i.canvas.width,height:i.canvas.height,data:l.data},t.px(1))}function Ne(t,e){Xe(t,e,t.emptySprite())}function Ue(t,e){return e.refsByName&&t.name&&e.refsByName[t.name]?e.refsByName[t.name]:t.ref}function _t(t,e){var i=t[e.network];if(e==null)return null;if(i==null)return console.debug("Generic shield for",JSON.stringify(e)),ae(e.ref)?t.default:null;var l=Ue(e,i);return i.overrideByRef&&(i={...i,...i.overrideByRef[l]}),i.overrideByName&&(i={...i,...i.overrideByName[e.name||""]}),!ae(l)&&"noref"in i&&(i=i.noref,i.notext=!0),!ae(l)&&!i.notext&&!(i.refsByName&&e.name)?null:i}function Ht(t){let e=parseInt(t,10);if(isNaN(e))return t;let i="M".repeat(e/1e3)+"D".repeat(e%1e3/500)+"C".repeat(e%500/100)+"L".repeat(e%100/50)+"X".repeat(e%50/10)+"V".repeat(e%10/5)+"I".repeat(e%5);return i=i.replace("DCCCC","CM").replace("CCCC","CD").replace("LXXXX","XC").replace("XXXX","XL").replace("VIIII","IX").replace("IIII","IV"),i+t.slice(e.toString().length)}function At(t,e,i){let l=Math.max(t.shieldSize(),z(t,e.shapeBlank.params,i,e.shapeBlank.drawFunc)),n=Y(t,e.shapeBlank.drawFunc);return{width:l,height:n}}function he(t,e){let i=_t(t.shieldDef,e);if(i==null)return null;e.ref=Ue(e,i);let l=de(i),n=De(t,i,e),o=t.shieldSize(),r=t.shieldSize();if(n==null){if(typeof i.shapeBlank!="undefined"){let g=At(t,i,e.ref);o=g.width,r=g.height}}else o=n.data.width,r=n.data.height;let s=l*t.px(t.options.bannerHeight);r+=s;let h=t.gfxFactory.createGraphics({width:o,height:r});return e.ref&&i.numberingSystem==="roman"&&(e.ref=Ht(e.ref)),Oe(t,h,i,Me),n==null?Bt(t,h,i,e):le(h,n,s,i.verticalReflect,i.colorLighten,i.colorDarken),zt(t,h,i,e),Oe(t,h,i,ve),h}function qe(){return(typeof window!="undefined"&&window.devicePixelRatio)>1?2:1}var K=class{createGraphics(e){var i=document.createElement("canvas").getContext("2d"),i=document.createElement("canvas").getContext("2d",{willReadFrequently:!0});return i.imageSmoothingQuality="high",i.textAlign="center",i.textBaseline="top",i.canvas.width=e.width,i.canvas.height=e.height,i}pixelRatio(){return qe()}};var se=class{emptySprite(){return this._emptySpriteCache||(this._emptySpriteCache=this.gfxFactory.createGraphics({width:1,height:1})),this._emptySpriteCache}px(e){return e*this.gfxFactory.pixelRatio()}shieldSize(){return this.px(this.options.shieldSize)}},ue=class{constructor(e){this.map=e}getSprite(e){return this.map.style.getImage(e)}putSprite(e,i,l){this.map.addImage(e,i,{pixelRatio:l})}},Z=class{constructor(e){this._shieldPredicate=()=>!0;this._networkPredicate=()=>!0;this._shieldDefCallbacks=[];this._routeParser=e,this._renderContext=new se,this._renderContext.gfxFactory=new K}setShields(e){this._renderContext.options=e.options,this._renderContext.shieldDef=e.networks,this._shieldDefCallbacks.forEach(i=>i(e.networks))}getShieldDefinitions(){return this._renderContext.shieldDef}debugOptions(e){return this._renderContext.debugOptions=e,this}filterImageID(e){return this._shieldPredicate=e,this}filterNetwork(e){return this._networkPredicate=e,this}graphicsFactory(e){return this._renderContext.gfxFactory=e,this}renderOnMaplibreGL(e){return this.renderOnRepository(new ue(e)),e.on("styleimagemissing",this.getStyleImageMissingHandler()),this}onShieldDefLoad(e){return this._renderContext.shieldDef?e(this._renderContext.shieldDef):this._shieldDefCallbacks.push(e),this}renderOnRepository(e){return this._renderContext.spriteRepo||(this._renderContext.spriteRepo=e),this}getStyleImageMissingHandler(){return e=>{try{if(!this._shieldPredicate(e.id))return;let i=this._routeParser.parse(e.id);if(!this._networkPredicate(i.network)){Ne(this._renderContext,e.id);return}i.spriteID=e.id,this._renderContext.debugOptions=this.debugOptions,i&&Ee(this._renderContext,i)}catch(i){console.error(`Exception while loading image \u2018${e==null?void 0:e.id}\u2019:
`,i)}}}getGraphicForRoute(e,i,l){return he(this._renderContext,{network:e,ref:i,name:l,spriteID:this._routeParser.format(e,i,l)})}emptySprite(){return this._renderContext.emptySprite()}createGraphics(e){return this._renderContext.gfxFactory.createGraphics(e)}pixelRatio(){return this._renderContext.px(1)}},fe=class extends Z{constructor(e,i){super(i),this.setShields(e)}},pe=class extends Z{constructor(e,i){super(i),this.setShieldURL(e)}async setShieldURL(e){await fetch(e).then(i=>i.json()).then(i=>super.setShields(i)).catch(i=>console.error(i))}},ee=class{constructor(){this.sprites={}}getSprite(e){return this.sprites[e]}hasSprite(e){return e in this.sprites}putSprite(e,i){this.sprites[e]=i}},ei=new ee;export{ee as InMemorySpriteRepository,fe as ShieldRenderer,pe as URLShieldRenderer,qe as getDOMPixelRatio,le as transposeImageData};
//# sourceMappingURL=index.js.map
{
"name": "@americana/maplibre-shield-generator",
"description": "Generate highway shields for maplibre-gl-js maps",
"version": "0.0.2",
"version": "0.0.3-test-1",
"author": "OpenStreetMap Americana Contributors",

@@ -18,3 +18,8 @@ "type": "module",

"license": "CC0-1.0",
"main": "dist/index.js",
"main": "dist/maplibre-shield-generator-cjs.js",
"module": "dist/maplibre-shield-generator-esm.js",
"browser": {
"dist/maplibre-shield-generator-cjs.js": "dist/maplibre-shield-generator.js",
"dist/maplibre-shield-generator-esm.js": "dist/maplibre-shield-generator-esm.js"
},
"source": "src/index.ts",

@@ -53,2 +58,5 @@ "devDependencies": {

},
"files": [
"dist/*"
],
"directories": {

@@ -55,0 +63,0 @@ "test": "test"

@@ -7,5 +7,5 @@ # Americana Shield Renderer

## Shield rendering workflow
## Usage
Rendering shields requires the following compoments:
Rendering shields requires the following components:

@@ -16,4 +16,10 @@ 1. **Encode shield information in vector tiles**. First, your tiles must contain the information which tells the shield renderer what shields to draw. In OpenMapTiles, shield information is encoded in the [`transportation_name`](https://openmaptiles.org/schema/#transportation_name) vector tile layer with a series of attributes named `route_1`, `route_2`, etc. Each attribute contains a text string which contains all of the information needed to determine which graphic to display, including numeric route number if the shield is numbered. However, this library allows you to specify how the shield information has been encoded, and it's possible to stitch together data from multiple fields when encoding shield data.

3. **Define a parser that describes how route information is encoded**. There are three parts to a route definition:
3. Import the library:
```html
<script type="text/javascript" src="maplibre-shield-generator.js"></script>
```
4. **Define a parser that describes how route information is encoded**. There are three parts to a route definition:
1. The `network` string, which defines a network with a common shield shape, graphic, and color

@@ -41,3 +47,3 @@ 1. The `ref` string, which defines a text sequence that should be drawn on top of the shield graphic

4. **(Optional) Create predicates that define which shields will be handled**. For example, if all sprite IDs in your style that need a shield begin with the string `shield|`, this would look like:
5. **(Optional) Create predicates that define which shields will be handled**. For example, if all sprite IDs in your style that need a shield begin with the string `shield|`, this would look like:

@@ -57,8 +63,8 @@ ```typescript

5. **Create shield definitions and artwork**. The shield definition is expressed as a JSON file along with a set of sprites containing any raster artwork used for the shields. It can be generated as an object or hosted as a JSON file accessible by URL. See the next section for how to create this definition.
6. **Create shield definitions and artwork**. The shield definition is expressed as a JSON file along with a set of sprites containing any raster artwork used for the shields. It can be generated as an object or hosted as a JSON file accessible by URL. See the next section for how to create this definition.
6. **Hook up the shield generator to a maplibre-gl-js map**. Pass either the URL of the JSON shield definition or create an object in javascript code. There are two separate classes for each approach.
7. **Hook up the shield generator to a maplibre-gl-js map**. Pass either the URL of the JSON shield definition or create an object in javascript code. There are two separate classes for each approach.
```typescript
new URLShieldRenderer("shields.json", routeParser)
new mapLibreShieldGenerator.URLShieldRenderer("shields.json", routeParser)
.filterImageID(shieldPredicate)

@@ -70,3 +76,3 @@ .filterNetwork(networkPredicate)

```typescript
new ShieldRenderer(shields, routeParser)
new mapLibreShieldGenerator.ShieldRenderer(shields, routeParser)
.filterImageID(shieldPredicate)

@@ -77,3 +83,3 @@ .filterNetwork(networkPredicate)

## Shield Definition
## Shield definition

@@ -80,0 +86,0 @@ The purpose of the shield definition is to define which graphics and text to draw for each network/ref/name combination that you wish to display. This can be created in javascript as an object, or as an HTTP-accessible JSON file.

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc