@americana/maplibre-shield-generator
Advanced tools
Comparing version 0.0.1-alpha.17 to 0.0.1-alpha.18
@@ -1,3 +0,3 @@ | ||
var Ye=Object.create;var ge=Object.defineProperty;var Ke=Object.getOwnPropertyDescriptor;var Ze=Object.getOwnPropertyNames;var et=Object.getPrototypeOf,tt=Object.prototype.hasOwnProperty;var it=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports);var lt=(t,e,i,l)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of Ze(e))!tt.call(t,n)&&n!==i&&ge(t,n,{get:()=>e[n],enumerable:!(l=Ke(e,n))||l.enumerable});return t};var nt=(t,e,i)=>(i=t!=null?Ye(et(t)):{},lt(e||!t||!t.__esModule?ge(i,"default",{value:t,enumerable:!0}):i,t));var Se=it((Ht,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=nt(Se(),1),we=ot,ce={red:0,orange:60,yellow:120,green:180,blue:240,purple:300};function ot(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 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: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 rt='"sans-serif-condensed", "Arial Narrow", sans-serif',O=(t,e)=>`bold ${t}px ${e||rt}`,q=12;function ie(t,e,i){return 255-t/255*(255-i)-(1-t/255)*(255-e)}function at(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 dt(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?dt:at,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 N={Middle:"middle",Top:"top",Bottom:"bottom"};function xe(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 ht(t,e){return{scale:xe(t,e),valign:N.Middle}}function st(t,e){return{scale:xe(t,{height:e.width/2,width:e.height}),valign:N.Top}}function me(t,e){var i=t.height/e.height,l=t.width/e.width;return{scale:Math.min(l,i),valign:N.Middle}}function ut(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 ft(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=O(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=Me[n.constraintFunc],b=w({height:S,width:d},{height:p,width:f},n.options);var m=Math.min(y,q*b.scale);u.font=O(m,t.options.shieldFont),u.textAlign="center",u.textBaseline="top",a=u.measureText(e),p=a.actualBoundingBoxDescent;var x;switch(b.valign){case N.Top:x=r;break;case N.Bottom:x=r+S-p;break;case N.Middle:default:x=r+(S-p)/2;break}return{xBaseline:c,yBaseline:x,fontPx:m}}var pt={padding:{top:0,bottom:0,left:0,right:0}};function D(t,e,i,l){i==null&&(i=pt);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)),ft(t,e,n,l,o,r)}function ke(t,e,i,l){Ce(t,e,l),e.fillText(i,l.xBaseline,l.yBaseline)}function ne(t,e,i,l){Ce(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 Ce(t,e,i){e.textAlign="center",e.textBaseline="top",e.font=O(i.fontPx,t.options.shieldFont)}function Te(t,e,i,l){let n={padding:{top:t.options.bannerPadding,bottom:0,left:0,right:0}};var o=D(t,i,n,{width:e.canvas.width,height:t.options.bannerHeight-t.options.bannerPadding});e.fillStyle=t.options.bannerTextColor,e.font=O(o.fontPx,t.options.shieldFont),e.textBaseline="top",e.textAlign="center",e.fillText(i,o.xBaseline,o.yBaseline+l*t.options.bannerHeight-t.options.bannerPadding)}function ve(t,e,i,l){let n={padding:{top:t.options.bannerPadding,bottom:0,left:0,right:0}};var o=D(t,i,n,{width:e.canvas.width,height:t.options.bannerHeight-t.options.bannerPadding});e.strokeStyle=e.shadowColor=t.options.bannerTextHaloColor,e.font=O(o.fontPx,t.options.shieldFont),e.textBaseline="top",e.textAlign="center",e.shadowBlur=0,e.lineWidth=t.px(2),e.strokeText(i,o.xBaseline,o.yBaseline+l*t.options.bannerHeight-t.options.bannerPadding),e.shadowColor=null,e.shadowBlur=null}function oe(t,e,i){var l=t.emptySprite();return l.font=O(i,t.options.shieldFont),Math.ceil(l.measureText(e).width)}var Me={};function J(t,e){Me[t]=e}J("ellipse",ht);J("rect",me);J("roundedRect",ut);J("southHalfEllipse",st);function gt(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 yt(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 We(){I("branson",yt,20),I("paBelt",gt,20)}var Fe=20,Be=34,Ie=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(Ie))+t.px(2),h=t.px(Fe);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(Be),s))}else return t.px(n)}function St(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 ze(t,e){var i=oe(t,e,t.px(Ie))+t.px(2),l=Math.max(t.px(Fe),Math.min(t.px(Be),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,b=t.shieldSize()-y;return e.beginPath(),e.moveTo(p,d),e.arcTo(S,d,S,c,u),e.arcTo(S,b,p,b,u),e.arcTo(a,b,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 ct(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,b=(p+S)/2,m=d+a,x=c-f,C=(2*p+b)/3,k=(b+2*S)/3,T=(x+c)/2,M=(T+2*c)/3;return e.beginPath(),e.moveTo(b,c),e.bezierCurveTo(C,M,p,T,p,x),e.arcTo(p,d,w,d,a),e.arcTo(S,d,S,m,a),e.lineTo(S,x),e.bezierCurveTo(S,T,k,M,b,c),e.closePath(),e.lineWidth=y,e.fillStyle=o,e.fill(),r!=null&&(e.strokeStyle=r,e.stroke()),g}function wt(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,b=f-t.px(2.5),m=f-t.px(1),x=p+h*t.px(2),C=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,C,d,x,c,p),e.lineTo(b,p),e.bezierCurveTo(m,x,f,C,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 bt(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,b=(p+S)/2,m=S-f,x=d+g*f,C=Math.atan((b-w)/Math.abs(c-f-x)),k=Math.sin(C),T=Math.cos(C),M=Math.tan(C/2),v=Math.tan(Math.PI/4-C/2),R=w-f*T,W=b-f*v,P=b+f*v,_=m+f*T,B=x+g*f*M,F=x+g*f*k,H=c-g*f*(1-k);return e.beginPath(),e.moveTo(b,c),e.arcTo(W,c,R,F,f),e.arcTo(p,B,p,x,f),e.arcTo(p,d,w,d,f),e.arcTo(S,d,S,x,f),e.arcTo(S,B,_,F,f),e.arcTo(P,c,b,c,f),e.closePath(),e.lineWidth=u,e.fillStyle=o,e.fill(),r!=null&&(e.strokeStyle=r,e.stroke()),y}function xt(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,b=p-d,m=n?t.shieldSize()-d:d,x=n?d:t.shieldSize()-d,C=m+y*c*(1+u),k=x-y*c*(1-u),T=w+(C-m)*f,M=T+c*a,v=w+y*(k-m)*f,R=w+y*(x-m)*f,W=v+y*c*a,P=p-R,_=p-v,B=p-M;return e.beginPath(),e.moveTo(B,m),e.arcTo(b,m,_,k,c),e.arcTo(P,x,W,x,c),e.arcTo(R,x,T,C,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 mt(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,b=Math.atan((c-a-f)/(d-a-w)),m=Math.sin(b),x=Math.cos(b),C=Math.tan(b/2),k=Math.tan(Math.PI/4-b/2),T=f+a*(1-x),M=c-a*x,v=c-a*k,R=c+a*k,W=c+a*x,P=p-a*(1-x),_=S+a*(1-m),B=w-a*m,F=w-a*C,H=w+a*C,G=w+a*m,A=d-a*(1-m);return e.beginPath(),e.moveTo(c,d),e.arcTo(v,d,T,G,a),e.arcTo(f,H,f,w,a),e.arcTo(f,F,M,_,a),e.arcTo(v,S,c,S,a),e.arcTo(R,S,P,B,a),e.arcTo(p,F,p,w,a),e.arcTo(p,H,W,A,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 kt(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,b=t.px(g),m=t.px(y),x=t.px(o),C=w,k=d-w,T=n?t.shieldSize()-w:w,M=n?w:t.shieldSize()-w,v=M-a*x,R=C+a*(v-T)*S,W=(C+k)/2,P=k-a*(v-T)*S,_=Math.atan(x/(W-C)),B=(Math.PI/2-_+r)/2,F=Math.tan(B),H=(Math.PI/2-r)/2,G=Math.tan(H),A=C+b*F*f,V=R+m*G,L=P-m*G,E=k-b*F*f,$=v-a*b*F*p;return e.beginPath(),e.moveTo(W,M),e.arcTo(C,v,A,$,b),e.arcTo(R,T,V,T,m),e.lineTo(L,T),e.arcTo(P,T,E,$,m),e.arcTo(k,v,W,M,b),e.closePath(),e.lineWidth=c,e.fillStyle=s,e.fill(),h!=null&&(e.strokeStyle=h,e.stroke()),d}function Ct(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,b=d+f,m=c-f,x=a*Math.tan(Math.PI/4-Math.asin(f/(w-p))/2),C=b+x,k=m-x;return e.beginPath(),e.moveTo(w,c),e.arcTo(p,m,p,k,a),e.arcTo(p,b,w,d,a),e.lineTo(w,d),e.arcTo(S,b,S,C,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 Tt(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,b=S,m=t.shieldSize()-S,x=(b+m)/2,C=b+d*a*y,k=x-d*g,T=x+d*g,M=m-d*a*y,v=c+(x-k)*u,R=c+(x-b)*u,W=w-(x-b)*u,P=w-(x-k)*u,_=R-d*a*g,B=R+d*a,F=W-d*a,H=W+d*a*g;return e.beginPath(),e.moveTo(B,b),e.arcTo(W,b,H,C,d),e.arcTo(w,x,P,T,d),e.arcTo(W,m,F,m,d),e.arcTo(R,m,_,M,d),e.arcTo(c,x,v,k,d),e.arcTo(R,b,B,b,d),e.closePath(),e.lineWidth=p,e.fillStyle=o,e.fill(),r!=null&&(e.strokeStyle=r,e.stroke()),f}function vt(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,b=f-S,m=S,x=t.shieldSize()-S,C=w+d*a*y,k=(w+b)/2,T=b-d*a*y,M=m+c,v=(m+x)/2,R=x-c,W=w+(v-M)*a,P=b-(v-M)*a,_=v-d*a*u,B=v+d*a*u,F=Math.atan(c/(k-W)),H=Math.sin(F),G=Math.cos(F),A=(Math.PI/2-o-F)/2,V=Math.cos(A),L=d*Math.cos(o+A)/V,E=d*Math.sin(o+A)/V,$=W+L-d*u,qe=W+L-d*H,De=P-L+d*H,Ve=P-L+d*u,$e=M+E-d*G,je=M+E-d*y,Je=R-E+d*y,Qe=R-E+d*G;return e.beginPath(),e.moveTo(k,x),e.arcTo(W,R,$,Je,d),e.arcTo(w,v,C,_,d),e.arcTo(W,M,qe,$e,d),e.lineTo(k,m),e.arcTo(P,M,Ve,je,d),e.arcTo(b,v,T,B,d),e.arcTo(P,R,De,Qe,d),e.lineTo(k,x),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 _e(t,e,i,l,n){return He[e](t,i,l,n)}var He={},re={};function I(t,e,i){He[t]=e,i!==void 0&&(re[t]=i)}I("diamond",mt);I("ellipse",St);I("escutcheon",ct);I("fishhead",wt);I("hexagonVertical",Ct);I("hexagonHorizontal",Tt);I("octagonVertical",vt);I("pentagon",kt);I("roundedRectangle",Q);I("trapezoid",xt);I("triangle",bt);We();function Ge(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 Mt(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 Ae(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=Mt(t,l.data,o),n=D(t,i.ref,e,r),!(n.fontPx>t.px(q)));s++);else l=t.spriteRepo.getSprite(e.spriteBlank);return l}function Rt(t){return t!=null&&typeof t.textColor<"u"?t.textColor:"black"}function Oe(t){return typeof t.shapeBlank<"u"?(e,i,l)=>_e(e,t.shapeBlank.drawFunc,i,t.shapeBlank.params,l):ze}function Wt(t,e,i,l){let o=de(i)*t.px(t.options.bannerHeight);e.save(),e.translate(0,o),Oe(i)(t,e,l.ref),e.restore()}function Pt(t,e){return typeof e.shapeBlank<"u"?Y(t,e.shapeBlank.drawFunc):t.shieldSize()}function Ft(t,e,i,l){var n=de(i),o=null,r=Ae(t,i,l);let s=n*t.px(t.options.bannerHeight);if(r==null?(e.translate(0,s),Oe(i)(t,e,l.ref),e.translate(0,-s),o={width:e.canvas.width,height:Pt(t,i)}):o={width:r.data.width,height:r.data.height},i.notext)return e;var h=D(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=Rt(i),ke(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 Le(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})),Ee(t,e.spriteID,i)}function Ee(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 Xe(t,e){Ee(t,e,t.emptySprite())}function Ne(t,e){return e.refsByName&&t.name&&e.refsByName[t.name]?e.refsByName[t.name]:t.ref}function Bt(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=Ne(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 It(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 zt(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=Bt(t.shieldDef,e);if(i==null)return null;e.ref=Ne(e,i);let l=de(i),n=Ae(t,i,e),o=t.shieldSize(),r=t.shieldSize();if(n==null){if(typeof i.shapeBlank<"u"){let g=zt(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=It(e.ref)),Ge(t,h,i,ve),n==null?Wt(t,h,i,e):le(h,n,s,i.verticalReflect,i.colorLighten,i.colorDarken),Ft(t,h,i,e),Ge(t,h,i,Te),h}function Ue(){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 Ue()}};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)){Xe(this._renderContext,e.id);return}i.spriteID=e.id,this._renderContext.debugOptions=this.debugOptions,i&&Le(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}},Yt=new ee;export{ee as InMemorySpriteRepository,fe as ShieldRenderer,pe as URLShieldRenderer,Ue as getDOMPixelRatio,le as transposeImageData}; | ||
var Ke=Object.create;var pe=Object.defineProperty;var Ze=Object.getOwnPropertyDescriptor;var et=Object.getOwnPropertyNames;var tt=Object.getPrototypeOf,it=Object.prototype.hasOwnProperty;var lt=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports);var nt=(t,e,i,l)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of et(e))!it.call(t,n)&&n!==i&&pe(t,n,{get:()=>e[n],enumerable:!(l=Ze(e,n))||l.enumerable});return t};var ot=(t,e,i)=>(i=t!=null?Ke(tt(t)):{},nt(e||!t||!t.__esModule?pe(i,"default",{value:t,enumerable:!0}):i,t));var Se=lt((At,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=ot(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),a=o.length,s=a<=4;l=1,s?(i=[parseInt(o[0]+o[0],16),parseInt(o[1]+o[1],16),parseInt(o[2]+o[2],16)],a===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)],a===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],p=h==="rgb",o=h.replace(/a$/,"");n=o;var a=o==="cmyk"?4:o==="gray"?1:3;i=e[2].trim().split(/\s*[,\/]\s*|\s+/).map(function(r,f){if(/%$/.test(r))return f===a?parseFloat(r)/100:o==="rgb"?parseFloat(r)*255/100:parseFloat(r);if(o[f]==="h"){if(/deg$/.test(r))return parseFloat(r);if(ce[r]!==void 0)return ce[r]}return parseFloat(r)}),h===o&&i.push(1),l=p||i[a]===void 0?1:i[a],i=i.slice(0,a)}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,a,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 p=0;p<3;p++)a=e+1/3*-(p-1),a<0?a++:a>1&&a--,6*a<1?h=n+(o-n)*6*a:2*a<1?h=o:3*a<2?h=n+(o-n)*(2/3-a)*6:h=n,s[p]=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),a=o-n,s,h,p;return o===n?s=0:e===o?s=(i-l)/a:i===o?s=2+(l-e)/a:l===o&&(s=4+(e-i)/a),s=Math.min(s*60,360),s<0&&(s+=360),p=(n+o)/2,o===n?h=0:p<=.5?h=a/(o+n):h=a/(2-o-n),[s,h*100,p*100]};function N(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,a=n.space[0]==="h"?J.max:D.max;return e=Array(3),e[0]=Math.min(Math.max(n.values[0],o[0]),a[0]),e[1]=Math.min(Math.max(n.values[1],o[1]),a[1]),e[2]=Math.min(Math.max(n.values[2],o[2]),a[2]),n.space[0]==="h"&&(e=J.rgb(e)),e.push(Math.min(Math.max(n.alpha,0),1)),e}var rt='"sans-serif-condensed", "Arial Narrow", sans-serif',L=(t,e)=>`bold ${t}px ${e||rt}`,q=12;function ie(t,e,i){return 255-t/255*(255-i)-(1-t/255)*(255-e)}function dt(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 ht(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 a=t.createImageData(e.data.width,e.data.height),s=n||o?ht:dt,h=n?N(n):N("#000"),p=o?N(o):N("#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,g=(y*e.data.width+u)*4;s(e.data.data,a.data,g,f,h,p)}else for(let y=0;y<e.data.data.length;y+=4)s(e.data.data,a.data,y,y,h,p);t.putImageData(a,0,i)}var G={Middle:"middle",Top:"top",Bottom:"bottom"};function xe(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 st(t,e){return{scale:xe(t,e),valign:G.Middle}}function ut(t,e){return{scale:xe(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 ft(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 pt(t,e,i,l,n,o){var a=t.px(i.top)||0,s=t.px(i.bottom)||0,h=t.px(i.left)||0,p=t.px(i.right)||0,y=t.px(o),u=t.gfxFactory.createGraphics(l);u.font=L(q,t.options.shieldFont),u.textAlign="center",u.textBaseline="top";var r=u.measureText(e),f=r.width,g=r.actualBoundingBoxDescent,S=l.height-a-s,d=l.width-h-p,c=h+d/2;let w=Re[n.constraintFunc],b=w({height:S,width:d},{height:g,width:f},n.options);var m=Math.min(y,q*b.scale);u.font=L(m,t.options.shieldFont),u.textAlign="center",u.textBaseline="top",r=u.measureText(e),g=r.actualBoundingBoxDescent;var x;switch(b.valign){case G.Top:x=a;break;case G.Bottom:x=a+S-g;break;case G.Middle:default:x=a+(S-g)/2;break}return{xBaseline:c,yBaseline:x,fontPx:m}}var yt={padding:{top:0,bottom:0,left:0,right:0}};function V(t,e,i,l){i==null&&(i=yt);var n=i.padding||{},o={constraintFunc:"rect"},a=14;return typeof i.textLayout<"u"&&(o=i.textLayout),typeof i.maxFontSize<"u"&&(a=Math.min(a,i.maxFontSize)),pt(t,e,n,l,o,a)}function ke(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=L(i.fontPx,t.options.shieldFont)}function ve(t,e,i,l){let n={padding:{top:t.options.bannerPadding,bottom:0,left:0,right:0}};var o=V(t,i,n,{width:e.canvas.width,height:t.options.bannerHeight-t.options.bannerPadding});e.fillStyle=t.options.bannerTextColor,e.font=L(o.fontPx,t.options.shieldFont),e.textBaseline="top",e.textAlign="center",e.fillText(i,o.xBaseline,o.yBaseline+l*t.options.bannerHeight-t.options.bannerPadding)}function Me(t,e,i,l){let n={padding:{top:t.options.bannerPadding,bottom:0,left:0,right:0}};var o=V(t,i,n,{width:e.canvas.width,height:t.options.bannerHeight-t.options.bannerPadding});e.strokeStyle=e.shadowColor=t.options.bannerTextHaloColor,e.font=L(o.fontPx,t.options.shieldFont),e.textBaseline="top",e.textAlign="center",e.shadowBlur=0,e.lineWidth=t.px(2),e.strokeText(i,o.xBaseline,o.yBaseline+l*t.options.bannerHeight-t.options.bannerPadding),e.shadowColor=null,e.shadowBlur=null}function oe(t,e,i){var l=t.emptySprite();return l.font=L(i,t.options.shieldFont),Math.ceil(l.measureText(e).width)}var Re={};function U(t,e){Re[t]=e}U("diamond",Ce);U("ellipse",st);U("rect",me);U("roundedRect",ft);U("southHalfEllipse",ut);U("triangleDown",gt);function St(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 ct(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,a=.7*t.shieldSize()-2*n,s=.4*t.shieldSize()+n,h=.45*t.shieldSize()-2*n;return e.beginPath(),e.rect(o,s,a,h),e.fillStyle=l,e.strokeStyle=i.strokeColor,e.fill(),e.lineWidth=n,e.stroke(),e}function Pe(){I("branson",ct,20),I("paBelt",St,20)}var Be=20,Ie=34,ze=18;function z(t,e,i,l){if(ae[l]!==void 0)return t.px(ae[l]);let n=e.rectWidth==null?null:e.rectWidth,o=e.angle==null?0:e.angle,a=Math.tan(o);if(n==null){let s=oe(t,i,t.px(ze))+t.px(2),h=t.px(Be);switch(l){case"pentagon":let p=e.offset==null?0:e.offset;s+=(t.shieldSize()-t.px(p))*a/2;break;case"trapezoid":s+=t.shieldSize()*a/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(Ie),s))}else return t.px(n)}function wt(t,e,i,l){let n=i.fillColor==null?"white":i.fillColor,o=i.strokeColor==null?"black":i.strokeColor,a=z(t,i,l),s=t.px(1),h=a/2-s,p=t.shieldSize()/2-s;return e.beginPath(),e.ellipse(e.canvas.width/2,t.shieldSize()/2,h,p,0,2*Math.PI,!1),e.fillStyle=n,e.fill(),e.lineWidth=s,e.strokeStyle=o,e.stroke(),a}function _e(t,e){var i=oe(t,e,t.px(ze))+t.px(2),l=Math.max(t.px(Be),Math.min(t.px(Ie),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,a=i.radius==null?0:i.radius,s=i.outlineWidth==null?1:i.outlineWidth,h=z(t,i,l),p=t.px(s),y=p/2,u=t.px(a),r=y,f=y+u,g=h-y-u,S=h-y,d=y,c=y+u,w=t.shieldSize()-y-u,b=t.shieldSize()-y;return e.beginPath(),e.moveTo(g,d),e.arcTo(S,d,S,c,u),e.arcTo(S,b,g,b,u),e.arcTo(r,b,r,w,u),e.arcTo(r,d,f,d,u),e.closePath(),e.lineWidth=p,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,a=i.strokeColor==null?"black":i.strokeColor,s=i.radius==null?0:i.radius,h=i.outlineWidth==null?1:i.outlineWidth,p=z(t,i,l),y=t.px(h),u=y/2,r=t.px(s),f=t.px(n),g=u,S=p-u,d=u,c=t.shieldSize()-u,w=g+r,b=(g+S)/2,m=d+r,x=c-f,k=(2*g+b)/3,C=(b+2*S)/3,T=(x+c)/2,M=(T+2*c)/3;return e.beginPath(),e.moveTo(b,c),e.bezierCurveTo(k,M,g,T,g,x),e.arcTo(g,d,w,d,r),e.arcTo(S,d,S,m,r),e.lineTo(S,x),e.bezierCurveTo(S,T,C,M,b,c),e.closePath(),e.lineWidth=y,e.fillStyle=o,e.fill(),a!=null&&(e.strokeStyle=a,e.stroke()),p}function xt(t,e,i,l){let n=i.pointUp==null?!1:i.pointUp,o=i.fillColor==null?"white":i.fillColor,a=i.strokeColor==null?"black":i.strokeColor,s=i.outlineWidth==null?1:i.outlineWidth,h=n?-1:1,p=z(t,i,l),y=t.px(s),u=y/2,r=u,f=p-u,g=n?t.shieldSize()-u:u,S=n?u:t.shieldSize()-u,d=r+t.px(1),c=r+t.px(2.5),w=(r+f)/2,b=f-t.px(2.5),m=f-t.px(1),x=g+h*t.px(2),k=g+h*t.px(4.5),C=g+h*t.px(7),T=S-h*t.px(6),M=S-h*t.px(1),v=(r+w)/2,R=(w+f)/2;e.beginPath(),e.moveTo(w,S),e.bezierCurveTo(v,M,r,T,r,C),e.bezierCurveTo(r,k,d,x,c,g),e.lineTo(b,g),e.bezierCurveTo(m,x,f,k,f,C),e.bezierCurveTo(f,T,R,M,w,S),e.closePath(),e.lineWidth=y,e.fillStyle=o,e.fill(),a!=null&&(e.strokeStyle=a,e.stroke())}function mt(t,e,i,l){let n=i.pointUp==null?!1:i.pointUp,o=i.fillColor==null?"white":i.fillColor,a=i.strokeColor==null?"black":i.strokeColor,s=i.radius==null?0:i.radius,h=i.outlineWidth==null?1:i.outlineWidth,p=n?-1:1,y=z(t,i,l,"triangle"),u=t.px(h),r=u/2,f=t.px(s),g=r,S=y-r,d=n?t.shieldSize()-r:r,c=n?r:t.shieldSize()-r,w=g+f,b=(g+S)/2,m=S-f,x=d+p*f,k=Math.atan((b-w)/Math.abs(c-f-x)),C=Math.sin(k),T=Math.cos(k),M=Math.tan(k/2),v=Math.tan(Math.PI/4-k/2),R=w-f*T,W=b-f*v,P=b+f*v,_=m+f*T,B=x+p*f*M,F=x+p*f*C,H=c-p*f*(1-C);return e.beginPath(),e.moveTo(b,c),e.arcTo(W,c,R,F,f),e.arcTo(g,B,g,x,f),e.arcTo(g,d,w,d,f),e.arcTo(S,d,S,x,f),e.arcTo(S,B,_,F,f),e.arcTo(P,c,b,c,f),e.closePath(),e.lineWidth=u,e.fillStyle=o,e.fill(),a!=null&&(e.strokeStyle=a,e.stroke()),y}function Ct(t,e,i,l){let n=i.shortSideUp==null?!1:i.shortSideUp,o=i.angle==null?0:i.angle,a=i.fillColor==null?"white":i.fillColor,s=i.strokeColor==null?"black":i.strokeColor,h=i.radius==null?0:i.radius,p=i.outlineWidth==null?1:i.outlineWidth,y=n?-1:1,u=Math.sin(o),r=Math.cos(o),f=Math.tan(o),g=z(t,i,l,"trapezoid"),S=t.px(p),d=S/2,c=t.px(h),w=d,b=g-d,m=n?t.shieldSize()-d:d,x=n?d:t.shieldSize()-d,k=m+y*c*(1+u),C=x-y*c*(1-u),T=w+(k-m)*f,M=T+c*r,v=w+y*(C-m)*f,R=w+y*(x-m)*f,W=v+y*c*r,P=g-R,_=g-v,B=g-M;return e.beginPath(),e.moveTo(B,m),e.arcTo(b,m,_,C,c),e.arcTo(P,x,W,x,c),e.arcTo(R,x,T,k,c),e.arcTo(w,m,B,m,c),e.closePath(),e.lineWidth=S,e.fillStyle=a,e.fill(),s!=null&&(e.strokeStyle=s,e.stroke()),g}function kt(t,e,i,l){let n=i.fillColor==null?"white":i.fillColor,o=i.strokeColor==null?"black":i.strokeColor,a=i.radius==null?0:i.radius,s=i.outlineWidth==null?1:i.outlineWidth,h=Y(t,"diamond"),p=z(t,i,l,"diamond"),y=t.px(s),u=y/2,r=t.px(a),f=u,g=p-u,S=u,d=h-u,c=(f+g)/2,w=(S+d)/2,b=Math.atan((c-r-f)/(d-r-w)),m=Math.sin(b),x=Math.cos(b),k=Math.tan(b/2),C=Math.tan(Math.PI/4-b/2),T=f+r*(1-x),M=c-r*x,v=c-r*C,R=c+r*C,W=c+r*x,P=g-r*(1-x),_=S+r*(1-m),B=w-r*m,F=w-r*k,H=w+r*k,A=w+r*m,O=d-r*(1-m);return e.beginPath(),e.moveTo(c,d),e.arcTo(v,d,T,A,r),e.arcTo(f,H,f,w,r),e.arcTo(f,F,M,_,r),e.arcTo(v,S,c,S,r),e.arcTo(R,S,P,B,r),e.arcTo(g,F,g,w,r),e.arcTo(g,H,W,O,r),e.arcTo(R,d,c,d,r),e.closePath(),e.lineWidth=y,e.fillStyle=n,e.fill(),o!=null&&(e.strokeStyle=o,e.stroke()),p}function Tt(t,e,i,l){let n=i.pointUp==null?!0:i.pointUp,o=i.offset==null?0:i.offset,a=i.angle==null?0:i.angle,s=i.fillColor==null?"white":i.fillColor,h=i.strokeColor==null?"black":i.strokeColor,p=i.radius1==null?0:i.radius1,y=i.radius2==null?0:i.radius2,u=i.outlineWidth==null?1:i.outlineWidth,r=n?-1:1,f=Math.sin(a),g=Math.cos(a),S=Math.tan(a),d=z(t,i,l,"pentagon"),c=t.px(u),w=c/2,b=t.px(p),m=t.px(y),x=t.px(o),k=w,C=d-w,T=n?t.shieldSize()-w:w,M=n?w:t.shieldSize()-w,v=M-r*x,R=k+r*(v-T)*S,W=(k+C)/2,P=C-r*(v-T)*S,_=Math.atan(x/(W-k)),B=(Math.PI/2-_+a)/2,F=Math.tan(B),H=(Math.PI/2-a)/2,A=Math.tan(H),O=k+b*F*f,$=R+m*A,E=P-m*A,X=C-b*F*f,j=v-r*b*F*g;return e.beginPath(),e.moveTo(W,M),e.arcTo(k,v,O,j,b),e.arcTo(R,T,$,T,m),e.lineTo(E,T),e.arcTo(P,T,X,j,m),e.arcTo(C,v,W,M,b),e.closePath(),e.lineWidth=c,e.fillStyle=s,e.fill(),h!=null&&(e.strokeStyle=h,e.stroke()),d}function vt(t,e,i,l){let n=i.offset==null?0:i.offset,o=i.fillColor==null?"white":i.fillColor,a=i.strokeColor==null?"black":i.strokeColor,s=i.radius==null?0:i.radius,h=i.outlineWidth==null?1:i.outlineWidth,p=z(t,i,l),y=t.px(h),u=y/2,r=t.px(s),f=t.px(n),g=u,S=p-u,d=u,c=t.shieldSize()-u,w=(g+S)/2,b=d+f,m=c-f,x=r*Math.tan(Math.PI/4-Math.asin(f/(w-g))/2),k=b+x,C=m-x;return e.beginPath(),e.moveTo(w,c),e.arcTo(g,m,g,C,r),e.arcTo(g,b,w,d,r),e.lineTo(w,d),e.arcTo(S,b,S,k,r),e.arcTo(S,m,w,c,r),e.lineTo(w,c),e.closePath(),e.lineWidth=y,e.fillStyle=o,e.fill(),a!=null&&(e.strokeStyle=a,e.stroke()),p}function Mt(t,e,i,l){let n=i.angle==null?0:i.angle,o=i.fillColor==null?"white":i.fillColor,a=i.strokeColor==null?"black":i.strokeColor,s=i.radius==null?0:i.radius,h=i.outlineWidth==null?1:i.outlineWidth,p=Math.sin(n),y=Math.cos(n),u=Math.tan(n),r=Math.tan(Math.PI/4-n/2),f=z(t,i,l,"hexagonHorizontal"),g=t.px(h),S=g/2,d=t.px(s),c=S,w=f-S,b=S,m=t.shieldSize()-S,x=(b+m)/2,k=b+d*r*y,C=x-d*p,T=x+d*p,M=m-d*r*y,v=c+(x-C)*u,R=c+(x-b)*u,W=w-(x-b)*u,P=w-(x-C)*u,_=R-d*r*p,B=R+d*r,F=W-d*r,H=W+d*r*p;return e.beginPath(),e.moveTo(B,b),e.arcTo(W,b,H,k,d),e.arcTo(w,x,P,T,d),e.arcTo(W,m,F,m,d),e.arcTo(R,m,_,M,d),e.arcTo(c,x,v,C,d),e.arcTo(R,b,B,b,d),e.closePath(),e.lineWidth=g,e.fillStyle=o,e.fill(),a!=null&&(e.strokeStyle=a,e.stroke()),f}function Rt(t,e,i,l){let n=i.offset==null?0:i.offset,o=i.angle==null?0:i.angle,a=i.fillColor==null?"white":i.fillColor,s=i.strokeColor==null?"black":i.strokeColor,h=i.radius==null?0:i.radius,p=i.outlineWidth==null?1:i.outlineWidth,y=Math.sin(o),u=Math.cos(o),r=Math.tan(o),f=z(t,i,l),g=t.px(p),S=g/2,d=t.px(h),c=t.px(n),w=S,b=f-S,m=S,x=t.shieldSize()-S,k=w+d*r*y,C=(w+b)/2,T=b-d*r*y,M=m+c,v=(m+x)/2,R=x-c,W=w+(v-M)*r,P=b-(v-M)*r,_=v-d*r*u,B=v+d*r*u,F=Math.atan(c/(C-W)),H=Math.sin(F),A=Math.cos(F),O=(Math.PI/2-o-F)/2,$=Math.cos(O),E=d*Math.cos(o+O)/$,X=d*Math.sin(o+O)/$,j=W+E-d*u,qe=W+E-d*H,Ve=P-E+d*H,$e=P-E+d*u,je=M+X-d*A,Je=M+X-d*y,Qe=R-X+d*y,Ye=R-X+d*A;return e.beginPath(),e.moveTo(C,x),e.arcTo(W,R,j,Qe,d),e.arcTo(w,v,k,_,d),e.arcTo(W,M,qe,je,d),e.lineTo(C,m),e.arcTo(P,M,$e,Je,d),e.arcTo(b,v,T,B,d),e.arcTo(P,R,Ve,Ye,d),e.lineTo(C,x),e.closePath(),e.lineWidth=g,e.fillStyle=a,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 He(t,e,i,l,n){return Ge[e](t,i,l,n)}var Ge={},ae={};function I(t,e,i){Ge[t]=e,i!==void 0&&(ae[t]=i)}I("diamond",kt);I("ellipse",wt);I("escutcheon",bt);I("fishhead",xt);I("hexagonVertical",vt);I("hexagonHorizontal",Mt);I("octagonVertical",Rt);I("pentagon",Tt);I("roundedRectangle",Q);I("trapezoid",Ct);I("triangle",mt);Pe();function Ae(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 Wt(t,e,i){return{width:e.width,height:e.height+i*t.px(t.options.bannerHeight+t.options.bannerPadding)}}function re(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 Oe(t,e,i){var l=null,n,o=0,a;if(Array.isArray(e.spriteBlank))for(var s=0;s<e.spriteBlank.length&&(l=t.spriteRepo.getSprite(e.spriteBlank[s]),a=Wt(t,l.data,o),n=V(t,i.ref,e,a),!(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 Le(t){return typeof t.shapeBlank<"u"?(e,i,l)=>He(e,t.shapeBlank.drawFunc,i,t.shapeBlank.params,l):_e}function Ft(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 Bt(t,e){return typeof e.shapeBlank<"u"?Y(t,e.shapeBlank.drawFunc):t.shieldSize()}function It(t,e,i,l){var n=de(i),o=null,a=Oe(t,i,l);let s=n*t.px(t.options.bannerHeight);if(a==null?(e.translate(0,s),Le(i)(t,e,l.ref),e.translate(0,-s),o={width:e.canvas.width,height:Bt(t,i)}):o={width:a.data.width,height:a.data.height},i.notext)return e;var h=V(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),ke(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 zt(t,e){var i=t[e.network];if(e==null)return null;if(i==null)return console.debug("Generic shield for",JSON.stringify(e)),re(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||""]}),!re(l)&&"noref"in i&&(i=i.noref,i.notext=!0),!re(l)&&!i.notext&&!(i.refsByName&&e.name)?null:i}function _t(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 Ht(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=zt(t.shieldDef,e);if(i==null)return null;e.ref=Ue(e,i);let l=de(i),n=Oe(t,i,e),o=t.shieldSize(),a=t.shieldSize();if(n==null){if(typeof i.shapeBlank<"u"){let p=Ht(t,i,e.ref);o=p.width,a=p.height}}else o=n.data.width,a=n.data.height;let s=l*t.px(t.options.bannerHeight);a+=s;let h=t.gfxFactory.createGraphics({width:o,height:a});return e.ref&&i.numberingSystem==="roman"&&(e.ref=_t(e.ref)),Ae(t,h,i,Me),n==null?Ft(t,h,i,e):le(h,n,s,i.verticalReflect,i.colorLighten,i.colorDarken),It(t,h,i,e),Ae(t,h,i,ve),h}function De(){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 De()}};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)){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?.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)}},ge=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}},Zt=new ee;export{ee as InMemorySpriteRepository,fe as ShieldRenderer,ge as URLShieldRenderer,De 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.1-alpha.17", | ||
"version": "0.0.1-alpha.18", | ||
"author": "OpenStreetMap Americana Contributors", | ||
@@ -6,0 +6,0 @@ "type": "module", |
@@ -16,2 +16,3 @@ # Americana Shield Renderer | ||
3. **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 | ||
@@ -21,33 +22,34 @@ 1. The `ref` string, which defines a text sequence that should be drawn on top of the shield graphic | ||
```typescript | ||
let routeParser = { | ||
//format is `shield|${network}=${ref}|${name}` | ||
parse: (id: string) => { | ||
let id_parts = id.split("|"); | ||
let network_ref = id_parts[1].split("="); | ||
```typescript | ||
let routeParser = { | ||
//format is `shield|${network}=${ref}|${name}` | ||
parse: (id: string) => { | ||
let id_parts = id.split("|"); | ||
let network_ref = id_parts[1].split("="); | ||
return { | ||
network: network_ref[0], | ||
ref: network_ref[1], | ||
name: id_parts[2], | ||
}; | ||
}, | ||
format: (network: string, ref: string, name: string) => | ||
`shield|${network}=${ref}|${name}`, | ||
}; | ||
``` | ||
return { | ||
network: network_ref[0], | ||
ref: network_ref[1], | ||
name: id_parts[2], | ||
}; | ||
}, | ||
format: (network: string, ref: string, name: string) => | ||
`shield|${network}=${ref}|${name}`, | ||
}; | ||
``` | ||
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: | ||
```typescript | ||
let shieldPredicate = (imageID: string) => imageID.startsWith("shield"); | ||
``` | ||
```typescript | ||
let shieldPredicate = (imageID: string) => imageID.startsWith("shield"); | ||
``` | ||
This step can be skipped if all unhandled image IDs are shields. | ||
This step can be skipped if all unhandled image IDs are shields. | ||
Additionally, you can specify which networks will be handled. The example below ignores all nwn, lwn, ncn, etc network values: | ||
Additionally, you can specify which networks will be handled. The example below ignores all `nwn`, `lwn`, `ncn`, etc. network values: | ||
```typescript | ||
let networkPredicate = (network: string) => !/^[lrni][chimpw]n$/.test(network); | ||
``` | ||
```typescript | ||
let networkPredicate = (network: string) => | ||
!/^[lrni][chimpw]n$/.test(network); | ||
``` | ||
@@ -58,15 +60,15 @@ 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. | ||
```typescript | ||
new URLShieldRenderer("shields.json", routeParser) | ||
.filterImageID(shieldPredicate) | ||
.filterNetwork(networkPredicate) | ||
.renderOnMaplibreGL(map); | ||
``` | ||
```typescript | ||
new URLShieldRenderer("shields.json", routeParser) | ||
.filterImageID(shieldPredicate) | ||
.filterNetwork(networkPredicate) | ||
.renderOnMaplibreGL(map); | ||
``` | ||
```typescript | ||
new ShieldRenderer(shields, routeParser) | ||
.filterImageID(shieldPredicate) | ||
.filterNetwork(networkPredicate) | ||
.renderOnMaplibreGL(map); | ||
``` | ||
```typescript | ||
new ShieldRenderer(shields, routeParser) | ||
.filterImageID(shieldPredicate) | ||
.filterNetwork(networkPredicate) | ||
.renderOnMaplibreGL(map); | ||
``` | ||
@@ -276,2 +278,3 @@ ## Shield Definition | ||
- `diamond` | ||
- `ellipse` | ||
@@ -281,2 +284,3 @@ - `rect` | ||
- `southHalfEllipse` | ||
- `triangleDown` | ||
@@ -283,0 +287,0 @@ ### Defining drawn shield shapes |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
227718
2055
316