diff --git a/dist/taxonomy-bundle+riot.js b/dist/taxonomy-bundle+riot.js index 1646ddc..63e10c6 100644 --- a/dist/taxonomy-bundle+riot.js +++ b/dist/taxonomy-bundle+riot.js @@ -1,2 +1,2 @@ -!function(){"use strict";function t(e){return(t="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(e)}function e(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function n(t,e){for(var n=0;nt.length)&&(e=t.length);for(var n=0,r=new Array(e);nv-f)for(var T=r(e[c],0);f'.concat(t,""),"application/xml").documentElement,!0)}(e,t):function(t,e){var n=w(e)?e:document.createElement("template");return n.innerHTML=t,n.content}(e,t)}function Tt(t,e){switch(!0){case T(t):d(e,t);break;case w(t):t.parentNode.replaceChild(e,t);break;default:t.appendChild(e)}}var wt=Object.freeze({createDOM:function(t){return this.dom=this.dom||function(t,e){return e&&("string"==typeof e?xt(t,e):e)}(t,this.html),this},mount:function(t,e,n,r){var i=this;if(void 0===r&&(r={}),!t)throw new Error("Please provide DOM node to mount properly your template");this.el&&this.unmount(e);var o=r,a=o.fragment,s=o.children,u=o.avoidDOMInjection,l=(s?s[0]:t).parentNode,c=w(t),f=c?Math.max(Array.from(l.childNodes).indexOf(t),0):null;return this.isTemplateTag=c,this.createDOM(t),this.dom&&(this.fragment=a||this.dom.cloneNode(!0)),this.el=this.isTemplateTag?l:t,this.children=this.isTemplateTag?s||Array.from(this.fragment.childNodes):null,!u&&this.fragment&&Tt(t,this.fragment),this.bindings=this.bindingsData.map((function(t){return function(t,e,n){var r=e.selector,i=e.type,o=e.redundantAttribute,a=e.expressions,s=r?t.querySelector(r):t;o&&s.removeAttribute(o);var u=a||[];return(vt[i]||vt[2])(s,Object.assign({},e,{expressions:n&&!r?bt(u,n):u}))}(i.el,t,f)})),this.bindings.forEach((function(t){return t.mount(e,n)})),this},update:function(t,e){return this.bindings.forEach((function(n){return n.update(t,e)})),this},unmount:function(t,e,n){if(this.el){switch(this.bindings.forEach((function(r){return r.unmount(t,e,n)})),!0){case this.children&&null!==n:m(this.children);break;case!0===n:g(this.el);break;case null!==n:m(this.el.childNodes)}this.el=null}return this},clone:function(){return Object.assign({},this,{el:null})}});function At(t,e){return void 0===e&&(e=[]),Object.assign({},wt,{html:t,bindingsData:e})}function Et(){return this}function Nt(t){return A(t)?t.prototype&&t.prototype.constructor?new t:t():t}function St(t,e,n,r){return void 0===r&&(r={}),Object.defineProperty(t,e,Object.assign({value:n,enumerable:!1,writable:!1,configurable:!0},r)),t}function Ot(t,e,n){return Object.entries(e).forEach((function(e){var r=o(e,2),i=r[0],a=r[1];St(t,i,a,n)})),t}function jt(t,e){return Object.entries(e).forEach((function(e){var n=o(e,2),r=n[0],i=n[1];t[r]||(t[r]=i)})),t}function Mt(t){return Array.isArray(t)?t:/^\[object (HTMLCollection|NodeList|Object)\]$/.test(Object.prototype.toString.call(t))&&"number"==typeof t.length?Array.from(t):[t]}function _t(t,e){return Mt("string"==typeof t?(e||document).querySelectorAll(t):t)}var It=function(t){return 1===t.length?t[0]:t};function Ct(e,n,r){var o="object"===t(n)?n:i({},n,r),a=Object.keys(o);return Mt(e).forEach((function(t){a.forEach((function(e){return t.setAttribute(e,o[e])}))})),e}function Ut(t,e){return function(t,e,n){var r="string"==typeof e?[e]:e;return It(Mt(t).map((function(t){return It(r.map((function(e){return t[n](e)})))})))}(t,e,"getAttribute")}var kt,zt=new Map,Bt=function(){return kt||(Ct(kt=_t("style[riot]")[0]||document.createElement("style"),"type","text/css"),kt.parentNode||document.head.appendChild(kt),kt)},Ft={CSS_BY_NAME:zt,add:function(t,e){return zt.has(t)||(zt.set(t,e),this.inject()),this},inject:function(){return Bt().innerHTML=a(zt.values()).join("\n"),this},remove:function(t){return zt.has(t)&&(zt.delete(t),this.inject()),this}};function Rt(t){for(var e=arguments.length,n=new Array(e>1?e-1:0),r=1;r=e.f?o():t.fonts.load(function(t){return w(t)+" "+t.f+"00 300px "+x(t.c)}(e.a),e.h).then((function(t){1<=t.length?r():setTimeout(a,25)}),(function(){o()}))}()})),o=null,a=new Promise((function(t,n){o=setTimeout(n,e.f)}));Promise.race([a,r]).then((function(){o&&(clearTimeout(o),o=null),e.g(e.a)}),(function(){e.j(e.a)}))};var U={D:"serif",C:"sans-serif"},k=null;function z(){if(null===k){var t=/AppleWebKit\/([0-9]+)(?:\.([0-9]+))/.exec(window.navigator.userAgent);k=!!t&&(536>parseInt(t[1],10)||536===parseInt(t[1],10)&&11>=parseInt(t[2],10))}return k}function B(t,e,n){for(var r in U)if(U.hasOwnProperty(r)&&e===t.f[U[r]]&&n===t.f[U[r]])return!0;return!1}function F(t){var e,n=t.g.a.offsetWidth,o=t.h.a.offsetWidth;(e=n===t.f.serif&&o===t.f["sans-serif"])||(e=z()&&B(t,n,o)),e?i()-t.A>=t.w?z()&&B(t,n,o)&&(null===t.u||t.u.hasOwnProperty(t.a.c))?R(t,t.v):R(t,t.B):function(t){setTimeout(r((function(){F(this)}),t),50)}(t):R(t,t.v)}function R(t,e){setTimeout(r((function(){l(this.g.a),l(this.h.a),l(this.j.a),l(this.m.a),e(this.a)}),t),0)}function P(t,e,n){this.c=t,this.a=e,this.f=0,this.m=this.j=!1,this.s=n}C.prototype.start=function(){this.f.serif=this.j.a.offsetWidth,this.f["sans-serif"]=this.m.a.offsetWidth,this.A=i(),F(this)};var L=null;function D(t){0==--t.f&&t.j&&(t.m?((t=t.a).g&&c(t.f,[t.a.c("wf","active")],[t.a.c("wf","loading"),t.a.c("wf","inactive")]),S(t,"active")):N(t.a))}function K(t){this.j=t,this.a=new O,this.h=0,this.f=this.g=!0}function H(t,e,n,i,o){var a=0==--t.h;(t.f||t.g)&&setTimeout((function(){var t=o||null,s=i||{};if(0===n.length&&a)N(e.a);else{e.f+=n.length,a&&(e.j=a);var u,l=[];for(u=0;u>8)+16*(t>>8),((240&t)>>4)+16*((240&t)>>4),(15&t)+16*(15&t)]:t&&null!=t.match(/^0x([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})$/i)?[t>>16,(65280&t)>>8,255&t]:void 0},rgba:function(t){var e=this.rgb(t);return e?[e[0],e[1],e[2],1]:null},hsl:function(t){var n=this.rgb(t);return n?e.rgb.hsl(n):null},hsla:function(t){var e=this.hsl(t);return!e||[e[0],e[1],e[2],1]},fromString:function(t){if(t)return(t=t.replace(/^#*/,"0x"))<=16777215&&(5==t.length||8==t.length)?t:void 0},toString:function(t){if(t)return t.replace(/^(0x)?/i,"#")},isValid:function(t){return null!=this.fromString(t)}},e.rgb={hex:function(t){if(t){var e=Number(t[0]).toString(16),n=Number(t[1]).toString(16),r=Number(t[2]).toString(16);return(1===e.length?"0":"")+e+(1===n.length?"0":"")+n+(1===r.length?"0":"")+r}},rgba:function(t){return t?[t[0],t[1],t[2],1]:null},hsl:function(t){if(t&&Array.isArray(t)&&!(t.length<3)){var e=t[0]/255,n=t[1]/255,r=t[2]/255,i=Math.max(e,n,r),o=Math.min(e,n,r),a=i-o,s=0;switch(i){case o:s=0;break;case e:s=(n-r)/a+(n=4)return"rgba("+Math.round(t[0])+","+Math.round(t[1])+","+Math.round(t[2])+","+t[3]+")"},isValid:function(t){return null!=this.fromString(t)}},e.hsl={hex:function(t){var n=e.hsl.rgb(t);return n?e.rgb.hex(n):null},rgb:function(t){if(t){var e,n=t[0],r=t[1],i=t[2],o=(1-Math.abs(2*i-1))*r,a=o*(1-Math.abs(n/60%2-1)),s=i-o/2;return n<60?e=[o+s,a+s,s]:n<120?e=[a+s,o+s,s]:n<180?e=[s,o+s,a+s]:n<240?e=[s,a+s,o+s]:n<300?e=[a+s,s,o+s]:n<360&&(e=[o+s,s,a+s]),e?[Math.round(255*e[0]),Math.round(255*e[1]),Math.round(255*e[2])]:void 0}},rgba:function(t){var e=this.rgb(t);return e?[e[0],e[1],e[2],1]:null},hsla:function(t){return t?[t[0],t[1],t[2],1]:null},fromString:function(t){var e;if(t&&(null!=(e=(t=t.replace(/ /g,"")).match(/^hsl\(([0-9.]+),([0-9.]+)(%?),([0-9.]+)(%?)\)$/i))||null!=(e=t.match(/^\[?([0-9.]+),([0-9.]+)(%?),([0-9.]+)(%?)\]?$/)))){var n=[parseFloat(e[1]),"%"==e[3]?e[2]/100:parseFloat(e[2]),"%"==e[5]?e[4]/100:parseFloat(e[4])];if(n[0]<360&&n[1]<=1&&n[2]<=1)return n}},toString:function(t){if(t&&Array.isArray(t)&&3==t.length)return"hsl("+(1*t[0]).toFixed(2)+", "+(100*t[1]).toFixed(2)+"%, "+(100*t[2]).toFixed(2)+"%)"},isValid:function(t){return null!=this.fromString(t)}},e.hsla={hex:function(t){return e.hsl.hex(t)},rgb:function(t){return e.hsl.rgb(t)},rgba:function(t){var e=this.rgb(t);return e?[e[0],e[1],e[2],t[3]]:null},hsl:function(t){return t?[t[0],t[1],t[2]]:null},fromString:function(t){var e;if(t&&((null!=(e=(t=t.replace(/ /g,"")).match(/^hsla\(([0-9.]+),([0-9.]+)(%?),([0-9.]+)(%?),([0-9.]+)\)$/i))||null!=(e=t.match(/^\[?([0-9.]+),([0-9.]+)(%?),([0-9.]+)(%?),([0-9.]+)\]?$/)))&&(t=[parseFloat(e[1]),"%"==e[3]?e[2]/100:parseFloat(e[2]),"%"==e[5]?e[4]/100:parseFloat(e[4]),parseFloat(e[6])])[0]<360&&t[1]<=1&&t[2]<=1))return t},toString:function(t){if(t&&Array.isArray(t)&&4==t.length)return"hsla("+(1*t[0]).toFixed(2)+", "+(100*t[1]).toFixed(2)+"%, "+(100*t[2]).toFixed(2)+"%,"+t[3]+")"},isValid:function(t){return null!=this.fromString(t)}},e.isValid=function(t){return e.hex.isValid(t)||e.rgb.isValid(t)||e.rgba.isValid(t)||e.hsl.isValid(t)||e.hsla.isValid(t)},e.getStringTypeAndValue=function(t){var n=e.hex.fromString(t),r=e.rgb.fromString(t),i=e.rgba.fromString(t),o=e.hsl.fromString(t),a=e.hsla.fromString(t);return n?{value:n,type:"hex"}:r?{value:r,type:"rgb"}:i?{value:i,type:"rgba"}:o?{value:o,type:"hsl"}:a?{value:a,type:"hsla"}:void 0},t.exports=e,"undefined"!=typeof window&&(window.colorConverter=e)})),ee=function(){function t(){e(this,t)}return r(t,[{key:"number",value:function(t,e,n){return t*(1-n)+e*n}},{key:"array",value:function(t,e,n){return t.map((function(t,r){return this.number(t,e[r],n)}))}}]),t}(),ne=function(){function t(){e(this,t),this.interpolate=new ee}return r(t,[{key:"findStopLessThanOrEqualTo",value:function(t,e){for(var n,r,i=0,o=t.length-1,a=0;i<=o;){if(n=t[a=Math.floor((i+o)/2)][0],r=t[a+1][0],e===n||e>n&&ee&&(o=a-1)}return Math.max(a-1,0)}},{key:"interpolationFactor",value:function(t,e,n,r){var i=r-n,o=t-n;return 0===i?0:1===e||void 0===e?o/i:(Math.pow(e,o)-1)/(Math.pow(e,i)-1)}}]),t}(),re=function(){function t(){e(this,t),this._families={}}return r(t,[{key:"getWeight",value:function(t){return/extra(- )?light/i.test(t)?200:/light/i.test(t)?300:/semi(- )?bold/i.test(t)?600:/bold/i.test(t)?700:/black/i.test(t)?900:400}},{key:"getStyle",value:function(t){return/italic$/i.test(t)?"italic":"normal"}},{key:"getFamily",value:function(t){var e=t.split(/( black| bold| light| regular| semi[- ]?bold| extra[- ]?light| italic)/i);return e&&e[0]?e[0]:""}},{key:"getProps",value:function(t){return{family:this.getFamily(t),style:this.getStyle(t),weight:this.getWeight(t)}}},{key:"add",value:function(t){this._families[t.family]=this._families[t.family]||[];var e=t.weight+("italic"==t.style?"i":"");-1==this._families[t.family].indexOf(e)&&this._families[t.family].push(e)}},{key:"download",value:function(){var t=[];for(var e in this._families)t.push(e+":"+this._families[e].join(","));t.length>0&&Qt.load({google:{families:t}})}}]),t}(),ie=new(function(){function n(){e(this,n),this.zooms=this.generateArray(1,20),this.stops=new ne,this.fonts=new re}return r(n,[{key:"generateArray",value:function(t,e){for(var n=[],r=t;r=n)return r[0][1];if(r[r.length-1][0]<=n)return r[r.length-1][1];var i=this.stops.findStopLessThanOrEqualTo(r,n),o=this.stops.interpolationFactor(n,e.base,r[i][0],r[i+1][0]),a=r[i][1],s=r[i+1][1];return+this.stops.interpolate.number(a,s,o).toFixed(2)}},{key:"parseColor",value:function(t,e,n){if(void 0!==t.minzoom&&n=n)return r[0][1];if(r[r.length-1][0]<=n)return r[r.length-1][1];var i=this.stops.findStopLessThanOrEqualTo(r,n),o=this.stops.interpolationFactor(n,e.base,r[i][0],r[i+1][0]),a=te.getStringTypeAndValue(r[i][1]),s=te.getStringTypeAndValue(r[i+1][1]),u="rgb"===a.type?a.value:te[a.type].rgb(a.value),l="rgb"===s.type?s.value:te[s.type].rgb(s.value);return te.rgba.toString([this.stops.interpolate.number(u[0],l[0],o),this.stops.interpolate.number(u[1],l[1],o),this.stops.interpolate.number(u[2],l[2],o),1])}},{key:"renderLine",value:function(t,e){var n=this.widthAndColorByZooms(t,{width:t.paint["line-width"],color:t.paint["line-color"],zooms:e,opacity:t.paint["line-opacity"]});if(t.paint["line-gap-width"]){var r=this.widthAndColorByZooms(t,{width:t.paint["line-gap-width"],color:t.paint["line-color"],zooms:e,opacity:t.paint["line-opacity"]});for(var i in r)n[i]&&"number"==typeof n[i].width&&(n[i].width+=r[i].width)}return n}},{key:"widthAndColorByZooms",value:function(t,e){var n=this,r=e.color||"#000",i=e.width||1,o=e.opacity,a=e.zooms||this.zooms,s={maxWidth:0};return s.id=t.id,a.forEach((function(e){var a=n.parseNumber(t,i,e);a>s.maxWidth&&(s.maxWidth=a),s[e]={width:a,color:n.parseColor(t,r,e),opacity:n.parseNumber(t,o,e)}})),s}},{key:"borderStyleFromCasing",value:function(t,e,n){if(!(t&&e&&t[n]&&e[n]))return"";var r=Math.max((t[n].width-e[n].width)/2,0);return"border-top-width:"+r+"px;border-bottom-width:"+r+"px;border-top-color:"+t[n].color+";border-bottom-color:"+t[n].color+";border-top-style:solid;border-bottom-style:solid;"}}]),n}()),oe=(Jt={css:null,exports:{components:{Annotation:Zt,LineRender:{css:null,exports:{state:{casing:{},lines:[]},onMounted(){this.state.casing={},this.state.lines=this.props.layers.filter((t=>{if(t.metadata&&t.metadata["taxonomy:group"]===this.props.group&&("line"==t.type||t.ref)){if(!t.metadata["taxonomy:casing"]&&!t.ref)return!0;this.state.casing[t.metadata["taxonomy:casing"]||t.ref]=t}return!1})).map((t=>(this.state.casing[t.id]&&(this.state.casing[t.id]=ie.renderLine(this.state.casing[t.id],this.props.zooms)),ie.renderLine(t,this.props.zooms)))),this.update()},getMinHeight(t){const e=12+t.maxWidth+(this.state.casing[t.id]?this.state.casing[t.id].maxWidth:0);return e>25?e:25},taxonomy:ie},template:function(t,e,n,r){return t('

id
',[{redundantAttribute:"expr12",selector:"[expr12]",expressions:[{type:e.TEXT,childNodeIndex:0,evaluate:function(t){return t.props.title}},{type:e.ATTRIBUTE,name:"id",evaluate:function(t){return t.props.group}}]},{type:n.EACH,getKey:null,condition:null,template:t('
',[{redundantAttribute:"expr14",selector:"[expr14]",expressions:[{type:e.TEXT,childNodeIndex:0,evaluate:function(t){return t.zoom}}]},{type:n.EACH,getKey:null,condition:function(t){return t.state.lines},template:t('',[{expressions:[{type:e.ATTRIBUTE,name:"style",evaluate:function(t){return["min-height: ",t.getMinHeight(t.line),"px;"].join("")}}]},{redundantAttribute:"expr16",selector:"[expr16]",expressions:[{type:e.ATTRIBUTE,name:"style",evaluate:function(t){return["width: 55px; height: ",t.line[t.zoom].width,"px; background-color: ",t.line[t.zoom].color,"; ",t.taxonomy.borderStyleFromCasing(t.state.casing[t.line.id],t.line,t.zoom)," opacity: ",t.line[t.zoom].opacity,";"].join("")}}]}]),redundantAttribute:"expr15",selector:"[expr15]",itemName:"line",indexName:null,evaluate:function(t){return t.state.lines}}]),redundantAttribute:"expr13",selector:"[expr13]",itemName:"zoom",indexName:null,evaluate:function(t){return t.props.zooms}},{type:n.EACH,getKey:null,condition:function(t){return t.state.lines},template:t(" ",[{expressions:[{type:e.TEXT,childNodeIndex:0,evaluate:function(t){return[t.line.id].join("")}},{type:e.ATTRIBUTE,name:"style",evaluate:function(t){return["min-height: ",t.getMinHeight(t.line),"px;"].join("")}}]}]),redundantAttribute:"expr17",selector:"[expr17]",itemName:"line",indexName:null,evaluate:function(t){return t.state.lines}}])},name:"line-render"},PolygonRender:{css:null,exports:{state:{casing:{},polygons:[]},onMounted(){this.state.polygons=this.props.layers.filter((t=>{if(t.metadata&&t.metadata["taxonomy:group"]===this.props.group){if("fill"==t.type&&!t.metadata["taxonomy:casing"])return!0;"line"==t.type&&t.metadata["taxonomy:casing"]&&(this.state.casing[t.metadata["taxonomy:casing"]]=t)}return!1})).map((t=>(this.state.casing[t.id]?this.state.casing[t.id]={color:ie.parseColor(t,this.state.casing[t.id].paint["line-color"],this.props.zooms[0]),width:ie.parseNumber(t,this.state.casing[t.id].paint["line-width"],this.props.zooms[0]),id:this.state.casing[t.id].id}:t.paint["fill-outline-color"]&&(this.state.casing[t.id]={color:ie.parseColor(t,t.paint["fill-outline-color"],this.props.zooms[0]),width:1,id:t.id}),{color:ie.parseColor(t,t.paint["fill-color"],this.props.zooms[0]),id:t.id,opacity:ie.parseNumber(t,t.paint["fill-opacity"],this.props.zooms[0])}))),this.update()}},template:function(t,e,n,r){return t('

',[{redundantAttribute:"expr8",selector:"[expr8]",expressions:[{type:e.TEXT,childNodeIndex:0,evaluate:function(t){return t.props.title}},{type:e.ATTRIBUTE,name:"id",evaluate:function(t){return t.props.group}}]},{type:n.EACH,getKey:null,condition:function(t){return t.state.polygons},template:t(' ',[{redundantAttribute:"expr10",selector:"[expr10]",expressions:[{type:e.ATTRIBUTE,name:"style",evaluate:function(t){return["width: 100px; height: 100px; background-color: ",t.polygon.color,"; ",t.state.casing[t.polygon.id]?"border: "+t.state.casing[t.polygon.id].width+"px solid "+t.state.casing[t.polygon.id].color+";":""," opacity: ",t.polygon.opacity,";"].join("")}}]},{redundantAttribute:"expr11",selector:"[expr11]",expressions:[{type:e.TEXT,childNodeIndex:0,evaluate:function(t){return t.polygon.id}}]}]),redundantAttribute:"expr9",selector:"[expr9]",itemName:"polygon",indexName:null,evaluate:function(t){return t.state.polygons}}])},name:"polygon-render"},SymbolRender:{css:null,exports:{state:{casing:{},symbols:[]},onMounted(){this.state.symbols=this.props.layers.filter((t=>t.metadata&&t.metadata["taxonomy:group"]===this.props.group&&"symbol"==t.type)).map((t=>{t.paint["text-halo-color"]&&(this.state.casing[t.id]=ie.widthAndColorByZooms(t,{width:t.paint["text-halo-width"],color:t.paint["text-halo-color"],zooms:this.props.zooms}));const e=ie.widthAndColorByZooms(t,{width:t.layout["text-size"],color:t.paint["text-color"],zooms:this.props.zooms});e["text-transform"]=t.layout["text-transform"]||"none",e.example=t.metadata["taxonomy:example"];const n=ie.fonts.getProps(t.layout["text-font"][0]);return e.fontStyle=this.fontPropsToStyle(n),ie.fonts.add(n),e})),this.update()},fontPropsToStyle:t=>"font-style: "+t.style+"; font-weight: "+t.weight+"; font-family: '"+t.family+"';",getMinHeight(t){const e=8+t.maxWidth+(this.state.casing[t.id]?this.state.casing[t.id].maxWidth:0);return e>25?e:25}},template:function(t,e,n,r){return t('

id
',[{redundantAttribute:"expr18",selector:"[expr18]",expressions:[{type:e.TEXT,childNodeIndex:0,evaluate:function(t){return t.props.title}},{type:e.ATTRIBUTE,name:"id",evaluate:function(t){return t.props.group}}]},{type:n.EACH,getKey:null,condition:null,template:t('
',[{redundantAttribute:"expr20",selector:"[expr20]",expressions:[{type:e.TEXT,childNodeIndex:0,evaluate:function(t){return t.zoom}}]},{type:n.EACH,getKey:null,condition:function(t){return t.state.symbols},template:t(' ',[{expressions:[{type:e.ATTRIBUTE,name:"style",evaluate:function(t){return["min-height: ",t.getMinHeight(t.symbol),"px;"].join("")}}]},{redundantAttribute:"expr22",selector:"[expr22]",expressions:[{type:e.TEXT,childNodeIndex:0,evaluate:function(t){return t.symbol.example||t.symbol.id}},{type:e.ATTRIBUTE,name:"style",evaluate:function(t){return["font-size: ",t.symbol[t.zoom].width,"px; color: ",t.symbol[t.zoom].color,"; ",t.state.casing[t.symbol.id]&&t.state.casing[t.symbol.id][t.zoom]?"text-shadow: 0 0 "+t.state.casing[t.symbol.id][t.zoom].width+"px "+t.state.casing[t.symbol.id][t.zoom].color+";":""," ",t.symbol.fontStyle," text-transform: ",t.symbol["text-transform"],";"].join("")}}]}]),redundantAttribute:"expr21",selector:"[expr21]",itemName:"symbol",indexName:null,evaluate:function(t){return t.state.symbols}}]),redundantAttribute:"expr19",selector:"[expr19]",itemName:"zoom",indexName:null,evaluate:function(t){return t.props.zooms}},{type:n.EACH,getKey:null,condition:function(t){return t.state.symbols},template:t(" ",[{expressions:[{type:e.TEXT,childNodeIndex:0,evaluate:function(t){return[t.symbol.id].join("")}},{type:e.ATTRIBUTE,name:"style",evaluate:function(t){return["min-height: ",t.getMinHeight(t.symbol),"px;"].join("")}}]}]),redundantAttribute:"expr23",selector:"[expr23]",itemName:"symbol",indexName:null,evaluate:function(t){return t.state.symbols}}])},name:"symbol-render"}},fetchStyleURL(t){var e=new XMLHttpRequest;e.addEventListener("load",(function(){switch(this.status){case 200:return t(null,JSON.parse(this.responseText));case 400:return t("You sent a bad request.");case 401:return t("You are not authorized to use this style.");case 500:return t("This server can not answer yet.")}})),e.open("GET",this.props.styleUrl),e.send()},setBackgroundColor(){var t=this.style.layers;for(var e in t)if("background"===t[e].type)return void(this.$(".container").style["background-color"]=t[e].paint["background-color"]||"#fff")},onMounted(){if(!this.props.styleUrl)return console.error("Style URL is missing");this.fetchStyleURL(((t,e)=>{if(t)return console.error("Error in fetch style");this.style=e,this.update()}))},onUpdated(){this.setBackgroundColor(),ie.fonts.download();const t=location&&location.hash&&location.hash.replace("#",""),e=t&&this.$(t);e&&window.scrollTo({top:e.offsetTop,behavior:"smooth"})},taxonomy:ie},template:function(t,e,n,r){return t('
',[{type:n.IF,evaluate:function(t){return t.style&&t.style.metadata},redundantAttribute:"expr0",selector:"[expr0]",template:t('
\n Powered by JawgMaps. Contribute on GitHub.\n
',[{type:n.IF,evaluate:function(t){return t.style.metadata["taxonomy:title"]},redundantAttribute:"expr1",selector:"[expr1]",template:t('

',[{redundantAttribute:"expr2",selector:"[expr2]",expressions:[{type:e.TEXT,childNodeIndex:0,evaluate:function(t){return t.style.metadata["taxonomy:title"]}}]}])},{type:n.EACH,getKey:null,condition:null,template:t('',[{type:n.IF,evaluate:function(t){return"line"===t.group.type},redundantAttribute:"expr4",selector:"[expr4]",template:t(null,[{type:n.TAG,getComponent:r,evaluate:function(t){return"line-render"},slots:[],attributes:[{type:e.ATTRIBUTE,name:"layers",evaluate:function(t){return t.style.layers}},{type:e.ATTRIBUTE,name:"title",evaluate:function(t){return t.group.title}},{type:e.ATTRIBUTE,name:"group",evaluate:function(t){return t.group.id}},{type:e.ATTRIBUTE,name:"zooms",evaluate:function(t){return t.taxonomy.getZooms(t.group.zooms)}}]}])},{type:n.IF,evaluate:function(t){return"polygon"===t.group.type},redundantAttribute:"expr5",selector:"[expr5]",template:t(null,[{type:n.TAG,getComponent:r,evaluate:function(t){return"polygon-render"},slots:[],attributes:[{type:e.ATTRIBUTE,name:"layers",evaluate:function(t){return t.style.layers}},{type:e.ATTRIBUTE,name:"title",evaluate:function(t){return t.group.title}},{type:e.ATTRIBUTE,name:"group",evaluate:function(t){return t.group.id}},{type:e.ATTRIBUTE,name:"zooms",evaluate:function(t){return t.taxonomy.getZooms(t.group.zooms)}}]}])},{type:n.IF,evaluate:function(t){return"symbol"===t.group.type},redundantAttribute:"expr6",selector:"[expr6]",template:t(null,[{type:n.TAG,getComponent:r,evaluate:function(t){return"symbol-render"},slots:[],attributes:[{type:e.ATTRIBUTE,name:"layers",evaluate:function(t){return t.style.layers}},{type:e.ATTRIBUTE,name:"title",evaluate:function(t){return t.group.title}},{type:e.ATTRIBUTE,name:"group",evaluate:function(t){return t.group.id}},{type:e.ATTRIBUTE,name:"zooms",evaluate:function(t){return t.taxonomy.getZooms(t.group.zooms)}}]}])},{type:n.IF,evaluate:function(t){return"annotation"===t.group.type},redundantAttribute:"expr7",selector:"[expr7]",template:t(null,[{type:n.TAG,getComponent:r,evaluate:function(t){return"annotation"},slots:[],attributes:[{type:e.ATTRIBUTE,name:"layers",evaluate:function(t){return t.style.layers}},{type:e.ATTRIBUTE,name:"content",evaluate:function(t){return t.group.content}},{type:e.ATTRIBUTE,name:"group",evaluate:function(t){return t.group.id}},{type:e.ATTRIBUTE,name:"zooms",evaluate:function(t){return t.taxonomy.getZooms(t.group.zooms)}}]}])}]),redundantAttribute:"expr3",selector:"[expr3]",itemName:"group",indexName:null,evaluate:function(t){return t.style.metadata["taxonomy:groups"]}}])}])},name:"taxonomy"},function(t,e,n){var r=void 0===n?{}:n,i=r.slots,o=r.attributes,a=r.parentScope;return function(){for(var t=arguments.length,e=new Array(t),n=0;nt.length)&&(e=t.length);for(var n=0,r=new Array(e);nv-p)for(var T=r(e[c],0);p'.concat(t,""),"application/xml").documentElement,!0)}(e,t):function(t,e){var n=w(e)?e:document.createElement("template");return n.innerHTML=t,n.content}(e,t)}function Tt(t,e){switch(!0){case T(t):d(e,t);break;case w(t):t.parentNode.replaceChild(e,t);break;default:t.appendChild(e)}}var wt=Object.freeze({createDOM:function(t){return this.dom=this.dom||function(t,e){return e&&("string"==typeof e?xt(t,e):e)}(t,this.html),this},mount:function(t,e,n,r){var i=this;if(void 0===r&&(r={}),!t)throw new Error("Please provide DOM node to mount properly your template");this.el&&this.unmount(e);var o=r,a=o.fragment,s=o.children,u=o.avoidDOMInjection,l=(s?s[0]:t).parentNode,c=w(t),p=c?Math.max(Array.from(l.childNodes).indexOf(t),0):null;return this.isTemplateTag=c,this.createDOM(t),this.dom&&(this.fragment=a||this.dom.cloneNode(!0)),this.el=this.isTemplateTag?l:t,this.children=this.isTemplateTag?s||Array.from(this.fragment.childNodes):null,!u&&this.fragment&&Tt(t,this.fragment),this.bindings=this.bindingsData.map((function(t){return function(t,e,n){var r=e.selector,i=e.type,o=e.redundantAttribute,a=e.expressions,s=r?t.querySelector(r):t;o&&s.removeAttribute(o);var u=a||[];return(vt[i]||vt[2])(s,Object.assign({},e,{expressions:n&&!r?bt(u,n):u}))}(i.el,t,p)})),this.bindings.forEach((function(t){return t.mount(e,n)})),this},update:function(t,e){return this.bindings.forEach((function(n){return n.update(t,e)})),this},unmount:function(t,e,n){if(this.el){switch(this.bindings.forEach((function(r){return r.unmount(t,e,n)})),!0){case this.children&&null!==n:m(this.children);break;case!0===n:g(this.el);break;case null!==n:m(this.el.childNodes)}this.el=null}return this},clone:function(){return Object.assign({},this,{el:null})}});function At(t,e){return void 0===e&&(e=[]),Object.assign({},wt,{html:t,bindingsData:e})}function Et(){return this}function Nt(t){return A(t)?t.prototype&&t.prototype.constructor?new t:t():t}function St(t,e,n,r){return void 0===r&&(r={}),Object.defineProperty(t,e,Object.assign({value:n,enumerable:!1,writable:!1,configurable:!0},r)),t}function Ot(t,e,n){return Object.entries(e).forEach((function(e){var r=o(e,2),i=r[0],a=r[1];St(t,i,a,n)})),t}function jt(t,e){return Object.entries(e).forEach((function(e){var n=o(e,2),r=n[0],i=n[1];t[r]||(t[r]=i)})),t}function Mt(t){return Array.isArray(t)?t:/^\[object (HTMLCollection|NodeList|Object)\]$/.test(Object.prototype.toString.call(t))&&"number"==typeof t.length?Array.from(t):[t]}function It(t,e){return Mt("string"==typeof t?(e||document).querySelectorAll(t):t)}var _t=function(t){return 1===t.length?t[0]:t};function Ct(e,n,r){var o="object"===t(n)?n:i({},n,r),a=Object.keys(o);return Mt(e).forEach((function(t){a.forEach((function(e){return t.setAttribute(e,o[e])}))})),e}function kt(t,e){return function(t,e,n){var r="string"==typeof e?[e]:e;return _t(Mt(t).map((function(t){return _t(r.map((function(e){return t[n](e)})))})))}(t,e,"getAttribute")}var zt,Ut=new Map,Bt=function(){return zt||(Ct(zt=It("style[riot]")[0]||document.createElement("style"),"type","text/css"),zt.parentNode||document.head.appendChild(zt),zt)},Rt={CSS_BY_NAME:Ut,add:function(t,e){return Ut.has(t)||(Ut.set(t,e),this.inject()),this},inject:function(){return Bt().innerHTML=a(Ut.values()).join("\n"),this},remove:function(t){return Ut.has(t)&&(Ut.delete(t),this.inject()),this}};function Ft(t){for(var e=arguments.length,n=new Array(e>1?e-1:0),r=1;r=e.f?o():t.fonts.load(function(t){return w(t)+" "+t.f+"00 300px "+x(t.c)}(e.a),e.h).then((function(t){1<=t.length?r():setTimeout(a,25)}),(function(){o()}))}()})),o=null,a=new Promise((function(t,n){o=setTimeout(n,e.f)}));Promise.race([a,r]).then((function(){o&&(clearTimeout(o),o=null),e.g(e.a)}),(function(){e.j(e.a)}))};var k={D:"serif",C:"sans-serif"},z=null;function U(){if(null===z){var t=/AppleWebKit\/([0-9]+)(?:\.([0-9]+))/.exec(window.navigator.userAgent);z=!!t&&(536>parseInt(t[1],10)||536===parseInt(t[1],10)&&11>=parseInt(t[2],10))}return z}function B(t,e,n){for(var r in k)if(k.hasOwnProperty(r)&&e===t.f[k[r]]&&n===t.f[k[r]])return!0;return!1}function R(t){var e,n=t.g.a.offsetWidth,o=t.h.a.offsetWidth;(e=n===t.f.serif&&o===t.f["sans-serif"])||(e=U()&&B(t,n,o)),e?i()-t.A>=t.w?U()&&B(t,n,o)&&(null===t.u||t.u.hasOwnProperty(t.a.c))?F(t,t.v):F(t,t.B):function(t){setTimeout(r((function(){R(this)}),t),50)}(t):F(t,t.v)}function F(t,e){setTimeout(r((function(){l(this.g.a),l(this.h.a),l(this.j.a),l(this.m.a),e(this.a)}),t),0)}function P(t,e,n){this.c=t,this.a=e,this.f=0,this.m=this.j=!1,this.s=n}C.prototype.start=function(){this.f.serif=this.j.a.offsetWidth,this.f["sans-serif"]=this.m.a.offsetWidth,this.A=i(),R(this)};var L=null;function D(t){0==--t.f&&t.j&&(t.m?((t=t.a).g&&c(t.f,[t.a.c("wf","active")],[t.a.c("wf","loading"),t.a.c("wf","inactive")]),S(t,"active")):N(t.a))}function K(t){this.j=t,this.a=new O,this.h=0,this.f=this.g=!0}function H(t,e,n,i,o){var a=0==--t.h;(t.f||t.g)&&setTimeout((function(){var t=o||null,s=i||{};if(0===n.length&&a)N(e.a);else{e.f+=n.length,a&&(e.j=a);var u,l=[];for(u=0;u>8)+16*(t>>8),((240&t)>>4)+16*((240&t)>>4),(15&t)+16*(15&t)]:t&&null!=t.match(/^0x([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})$/i)?[t>>16,(65280&t)>>8,255&t]:void 0},rgba:function(t){var e=this.rgb(t);return e?[e[0],e[1],e[2],1]:null},hsl:function(t){var n=this.rgb(t);return n?e.rgb.hsl(n):null},hsla:function(t){var e=this.hsl(t);return!e||[e[0],e[1],e[2],1]},fromString:function(t){if(t)return(t=t.replace(/^#*/,"0x"))<=16777215&&(5==t.length||8==t.length)?t:void 0},toString:function(t){if(t)return t.replace(/^(0x)?/i,"#")},isValid:function(t){return null!=this.fromString(t)}},e.rgb={hex:function(t){if(t){var e=Number(t[0]).toString(16),n=Number(t[1]).toString(16),r=Number(t[2]).toString(16);return(1===e.length?"0":"")+e+(1===n.length?"0":"")+n+(1===r.length?"0":"")+r}},rgba:function(t){return t?[t[0],t[1],t[2],1]:null},hsl:function(t){if(t&&Array.isArray(t)&&!(t.length<3)){var e=t[0]/255,n=t[1]/255,r=t[2]/255,i=Math.max(e,n,r),o=Math.min(e,n,r),a=i-o,s=0;switch(i){case o:s=0;break;case e:s=(n-r)/a+(n=4)return"rgba("+Math.round(t[0])+","+Math.round(t[1])+","+Math.round(t[2])+","+t[3]+")"},isValid:function(t){return null!=this.fromString(t)}},e.hsl={hex:function(t){var n=e.hsl.rgb(t);return n?e.rgb.hex(n):null},rgb:function(t){if(t){var e,n=t[0],r=t[1],i=t[2],o=(1-Math.abs(2*i-1))*r,a=o*(1-Math.abs(n/60%2-1)),s=i-o/2;return n<60?e=[o+s,a+s,s]:n<120?e=[a+s,o+s,s]:n<180?e=[s,o+s,a+s]:n<240?e=[s,a+s,o+s]:n<300?e=[a+s,s,o+s]:n<360&&(e=[o+s,s,a+s]),e?[Math.round(255*e[0]),Math.round(255*e[1]),Math.round(255*e[2])]:void 0}},rgba:function(t){var e=this.rgb(t);return e?[e[0],e[1],e[2],1]:null},hsla:function(t){return t?[t[0],t[1],t[2],1]:null},fromString:function(t){var e;if(t&&(null!=(e=(t=t.replace(/ /g,"")).match(/^hsl\(([0-9.]+),([0-9.]+)(%?),([0-9.]+)(%?)\)$/i))||null!=(e=t.match(/^\[?([0-9.]+),([0-9.]+)(%?),([0-9.]+)(%?)\]?$/)))){var n=[parseFloat(e[1]),"%"==e[3]?e[2]/100:parseFloat(e[2]),"%"==e[5]?e[4]/100:parseFloat(e[4])];if(n[0]<360&&n[1]<=1&&n[2]<=1)return n}},toString:function(t){if(t&&Array.isArray(t)&&3==t.length)return"hsl("+(1*t[0]).toFixed(2)+", "+(100*t[1]).toFixed(2)+"%, "+(100*t[2]).toFixed(2)+"%)"},isValid:function(t){return null!=this.fromString(t)}},e.hsla={hex:function(t){return e.hsl.hex(t)},rgb:function(t){return e.hsl.rgb(t)},rgba:function(t){var e=this.rgb(t);return e?[e[0],e[1],e[2],t[3]]:null},hsl:function(t){return t?[t[0],t[1],t[2]]:null},fromString:function(t){var e;if(t&&((null!=(e=(t=t.replace(/ /g,"")).match(/^hsla\(([0-9.]+),([0-9.]+)(%?),([0-9.]+)(%?),([0-9.]+)\)$/i))||null!=(e=t.match(/^\[?([0-9.]+),([0-9.]+)(%?),([0-9.]+)(%?),([0-9.]+)\]?$/)))&&(t=[parseFloat(e[1]),"%"==e[3]?e[2]/100:parseFloat(e[2]),"%"==e[5]?e[4]/100:parseFloat(e[4]),parseFloat(e[6])])[0]<360&&t[1]<=1&&t[2]<=1))return t},toString:function(t){if(t&&Array.isArray(t)&&4==t.length)return"hsla("+(1*t[0]).toFixed(2)+", "+(100*t[1]).toFixed(2)+"%, "+(100*t[2]).toFixed(2)+"%,"+t[3]+")"},isValid:function(t){return null!=this.fromString(t)}},e.isValid=function(t){return e.hex.isValid(t)||e.rgb.isValid(t)||e.rgba.isValid(t)||e.hsl.isValid(t)||e.hsla.isValid(t)},e.getStringTypeAndValue=function(t){var n=e.hex.fromString(t),r=e.rgb.fromString(t),i=e.rgba.fromString(t),o=e.hsl.fromString(t),a=e.hsla.fromString(t);return n?{value:n,type:"hex"}:r?{value:r,type:"rgb"}:i?{value:i,type:"rgba"}:o?{value:o,type:"hsl"}:a?{value:a,type:"hsla"}:void 0},t.exports=e,"undefined"!=typeof window&&(window.colorConverter=e)})),ee=function(){function t(){e(this,t)}return r(t,[{key:"findStopLessThanOrEqualTo",value:function(t,e){for(var n,r,i=0,o=t.length-1,a=0;i<=o;){if(n=t[a=Math.floor((i+o)/2)][0],r=t[a+1][0],e===n||e>n&&ee&&(o=a-1)}return Math.max(a-1,0)}},{key:"interpolationFactor",value:function(t,e,n,r){var i=r-n,o=t-n;return 0===i?0:1===e||void 0===e?o/i:(Math.pow(e,o)-1)/(Math.pow(e,i)-1)}},{key:"number",value:function(t,e,n){return t*(1-n)+e*n}},{key:"array",value:function(t,e,n){return t.map((function(t,r){return this.number(t,e[r],n)}))}},{key:"asExpression",value:function(t){if(Array.isArray(t))return t;if(!t.stops)throw new Error("".concat(JSON.stringify(t)," is not a correct expression"));return 1===t.base||void 0===t.base?["interpolate",["linear"],["zoom"]].concat(t.stops.reduce((function(t,e){return t.concat(e)}),[])):["interpolate",["exponential",t.base],["zoom"]].concat(t.stops.reduce((function(t,e){return t.concat(e)}),[]))}},{key:"parseInterpolate",value:function(t,e){if(!t||"interpolate"!==t[0]||t.length<4)return null;var n="exponential"===t[1][0]?t[1][1]:1,r=t.slice(3).reduce((function(t,e,n){return n%2==0?t.push([e]):t[t.length-1].push(e),t}),[]);if(1===r.length||r[0][0]>=e)return{value:r[0][1]};if(r[r.length-1][0]<=e)return{value:r[r.length-1][1]};var i=this.findStopLessThanOrEqualTo(r,e);return{lower:r[i][1],upper:r[i+1][1],t:this.interpolationFactor(e,n,r[i][0],r[i+1][0])}}}]),t}(),ne=function(){function t(){e(this,t),this._families={}}return r(t,[{key:"getWeight",value:function(t){return/extra(- )?light/i.test(t)?200:/light/i.test(t)?300:/semi(- )?bold/i.test(t)?600:/bold/i.test(t)?700:/black/i.test(t)?900:400}},{key:"getStyle",value:function(t){return/italic$/i.test(t)?"italic":"normal"}},{key:"getFamily",value:function(t){var e=t.split(/( black| bold| light| regular| semi[- ]?bold| extra[- ]?light| italic)/i);return e&&e[0]?e[0]:""}},{key:"getProps",value:function(t){return{family:this.getFamily(t),style:this.getStyle(t),weight:this.getWeight(t)}}},{key:"add",value:function(t){this._families[t.family]=this._families[t.family]||[];var e=t.weight+("italic"==t.style?"i":"");-1==this._families[t.family].indexOf(e)&&this._families[t.family].push(e)}},{key:"download",value:function(){var t=[];for(var e in this._families)t.push(e+":"+this._families[e].join(","));t.length>0&&Qt.load({google:{families:t}})}}]),t}(),re=new(function(){function n(){e(this,n),this.zooms=this.generateArray(1,20),this.expressions=new ee,this.fonts=new ne}return r(n,[{key:"generateArray",value:function(t,e){for(var n=[],r=t;rs.maxWidth&&(s.maxWidth=a),s[e]={width:isNaN(a)?0:a,color:n.parseColor(t,r,e),opacity:n.parseNumber(t,o,e)}})),s}},{key:"borderStyleFromCasing",value:function(t,e,n){if(!(t&&e&&t[n]&&e[n]))return"";var r=Math.max((t[n].width-e[n].width)/2,0);return"border-top-width:"+r+"px;border-bottom-width:"+r+"px;border-top-color:"+t[n].color+";border-bottom-color:"+t[n].color+";border-top-style:solid;border-bottom-style:solid;"}}]),n}()),ie=(Jt={css:null,exports:{components:{Annotation:Zt,LineRender:{css:null,exports:{state:{casing:{},lines:[]},onMounted(){this.state.casing={},this.state.lines=this.props.layers.filter((t=>{if(t.metadata&&t.metadata["taxonomy:group"]===this.props.group&&("line"==t.type||t.ref)){if(!t.metadata["taxonomy:casing"]&&!t.ref)return!0;this.state.casing[t.metadata["taxonomy:casing"]||t.ref]=t}return!1})).map((t=>(this.state.casing[t.id]&&(this.state.casing[t.id]=re.renderLine(this.state.casing[t.id],this.props.zooms)),re.renderLine(t,this.props.zooms)))),this.update()},getMinHeight(t){const e=12+t.maxWidth+(this.state.casing[t.id]?this.state.casing[t.id].maxWidth:0);return e>25?e:25},taxonomy:re},template:function(t,e,n,r){return t('

id
',[{redundantAttribute:"expr18",selector:"[expr18]",expressions:[{type:e.TEXT,childNodeIndex:0,evaluate:function(t){return t.props.title}},{type:e.ATTRIBUTE,name:"id",evaluate:function(t){return t.props.group}}]},{type:n.EACH,getKey:null,condition:null,template:t('
',[{redundantAttribute:"expr20",selector:"[expr20]",expressions:[{type:e.TEXT,childNodeIndex:0,evaluate:function(t){return t.zoom}}]},{type:n.EACH,getKey:null,condition:function(t){return t.state.lines},template:t('',[{expressions:[{type:e.ATTRIBUTE,name:"style",evaluate:function(t){return["min-height: ",t.getMinHeight(t.line),"px;"].join("")}}]},{redundantAttribute:"expr22",selector:"[expr22]",expressions:[{type:e.ATTRIBUTE,name:"style",evaluate:function(t){return["width: 55px; height: ",t.line[t.zoom].width,"px; background-color: ",t.line[t.zoom].color,"; ",t.taxonomy.borderStyleFromCasing(t.state.casing[t.line.id],t.line,t.zoom)," opacity: ",t.line[t.zoom].opacity,";"].join("")}}]}]),redundantAttribute:"expr21",selector:"[expr21]",itemName:"line",indexName:null,evaluate:function(t){return t.state.lines}}]),redundantAttribute:"expr19",selector:"[expr19]",itemName:"zoom",indexName:null,evaluate:function(t){return t.props.zooms}},{type:n.EACH,getKey:null,condition:function(t){return t.state.lines},template:t(" ",[{expressions:[{type:e.TEXT,childNodeIndex:0,evaluate:function(t){return[t.line.id].join("")}},{type:e.ATTRIBUTE,name:"style",evaluate:function(t){return["min-height: ",t.getMinHeight(t.line),"px;"].join("")}}]}]),redundantAttribute:"expr23",selector:"[expr23]",itemName:"line",indexName:null,evaluate:function(t){return t.state.lines}}])},name:"line-render"},PolygonRender:{css:null,exports:{state:{casing:{},polygons:[]},onMounted(){this.state.polygons=this.props.layers.filter((t=>{if(t.metadata&&t.metadata["taxonomy:group"]===this.props.group){if("fill"==t.type&&!t.metadata["taxonomy:casing"])return!0;"line"==t.type&&t.metadata["taxonomy:casing"]&&(this.state.casing[t.metadata["taxonomy:casing"]]=t)}return!1})).map((t=>(this.state.casing[t.id]?this.state.casing[t.id]={color:re.parseColor(t,this.state.casing[t.id].paint["line-color"],this.props.zooms[0]),width:re.parseNumber(t,this.state.casing[t.id].paint["line-width"],this.props.zooms[0]),id:this.state.casing[t.id].id}:t.paint["fill-outline-color"]&&(this.state.casing[t.id]={color:re.parseColor(t,t.paint["fill-outline-color"],this.props.zooms[0]),width:1,id:t.id}),{color:re.parseColor(t,t.paint["fill-color"],this.props.zooms[0]),id:t.id,opacity:re.parseNumber(t,t.paint["fill-opacity"],this.props.zooms[0])}))),this.update()}},template:function(t,e,n,r){return t('

',[{redundantAttribute:"expr8",selector:"[expr8]",expressions:[{type:e.TEXT,childNodeIndex:0,evaluate:function(t){return t.props.title}},{type:e.ATTRIBUTE,name:"id",evaluate:function(t){return t.props.group}}]},{type:n.EACH,getKey:null,condition:function(t){return t.state.polygons},template:t(' ',[{redundantAttribute:"expr10",selector:"[expr10]",expressions:[{type:e.ATTRIBUTE,name:"style",evaluate:function(t){return["width: 100px; height: 100px; background-color: ",t.polygon.color,"; ",t.state.casing[t.polygon.id]?"border: "+t.state.casing[t.polygon.id].width+"px solid "+t.state.casing[t.polygon.id].color+";":""," opacity: ",t.polygon.opacity,";"].join("")}}]},{redundantAttribute:"expr11",selector:"[expr11]",expressions:[{type:e.TEXT,childNodeIndex:0,evaluate:function(t){return t.polygon.id}}]}]),redundantAttribute:"expr9",selector:"[expr9]",itemName:"polygon",indexName:null,evaluate:function(t){return t.state.polygons}}])},name:"polygon-render"},SymbolRender:{css:null,exports:{state:{casing:{},symbols:[]},onMounted(){this.state.symbols=this.props.layers.filter((t=>t.metadata&&t.metadata["taxonomy:group"]===this.props.group&&"symbol"==t.type)).map((t=>{t.paint["text-halo-color"]&&(this.state.casing[t.id]=re.widthAndColorByZooms(t,{width:t.paint["text-halo-width"],color:t.paint["text-halo-color"],zooms:this.props.zooms}));const e=re.widthAndColorByZooms(t,{width:t.layout["text-size"],color:t.paint["text-color"],zooms:this.props.zooms});e["text-transform"]=t.layout["text-transform"]||"none",e.example=t.metadata["taxonomy:example"];const n=re.fonts.getProps(t.layout["text-font"][0]);return e.fontStyle=this.fontPropsToStyle(n),re.fonts.add(n),e})),this.update()},fontPropsToStyle:t=>"font-style: "+t.style+"; font-weight: "+t.weight+"; font-family: '"+t.family+"';",getMinHeight(t){const e=8+t.maxWidth+(this.state.casing[t.id]?this.state.casing[t.id].maxWidth:0);return e>25?e:25}},template:function(t,e,n,r){return t('

id
',[{redundantAttribute:"expr12",selector:"[expr12]",expressions:[{type:e.TEXT,childNodeIndex:0,evaluate:function(t){return t.props.title}},{type:e.ATTRIBUTE,name:"id",evaluate:function(t){return t.props.group}}]},{type:n.EACH,getKey:null,condition:null,template:t('
',[{redundantAttribute:"expr14",selector:"[expr14]",expressions:[{type:e.TEXT,childNodeIndex:0,evaluate:function(t){return t.zoom}}]},{type:n.EACH,getKey:null,condition:function(t){return t.state.symbols},template:t(' ',[{expressions:[{type:e.ATTRIBUTE,name:"style",evaluate:function(t){return["min-height: ",t.getMinHeight(t.symbol),"px;"].join("")}}]},{redundantAttribute:"expr16",selector:"[expr16]",expressions:[{type:e.TEXT,childNodeIndex:0,evaluate:function(t){return t.symbol.example||t.symbol.id}},{type:e.ATTRIBUTE,name:"style",evaluate:function(t){return["font-size: ",t.symbol[t.zoom].width,"px; color: ",t.symbol[t.zoom].color,"; ",t.state.casing[t.symbol.id]&&t.state.casing[t.symbol.id][t.zoom]?"text-shadow: 0 0 "+t.state.casing[t.symbol.id][t.zoom].width+"px "+t.state.casing[t.symbol.id][t.zoom].color+";":""," ",t.symbol.fontStyle," text-transform: ",t.symbol["text-transform"],";"].join("")}}]}]),redundantAttribute:"expr15",selector:"[expr15]",itemName:"symbol",indexName:null,evaluate:function(t){return t.state.symbols}}]),redundantAttribute:"expr13",selector:"[expr13]",itemName:"zoom",indexName:null,evaluate:function(t){return t.props.zooms}},{type:n.EACH,getKey:null,condition:function(t){return t.state.symbols},template:t(" ",[{expressions:[{type:e.TEXT,childNodeIndex:0,evaluate:function(t){return[t.symbol.id].join("")}},{type:e.ATTRIBUTE,name:"style",evaluate:function(t){return["min-height: ",t.getMinHeight(t.symbol),"px;"].join("")}}]}]),redundantAttribute:"expr17",selector:"[expr17]",itemName:"symbol",indexName:null,evaluate:function(t){return t.state.symbols}}])},name:"symbol-render"}},fetchStyleURL(t){var e=new XMLHttpRequest;e.addEventListener("load",(function(){switch(this.status){case 200:return t(null,JSON.parse(this.responseText));case 400:return t("You sent a bad request.");case 401:return t("You are not authorized to use this style.");case 500:return t("This server can not answer yet.")}})),e.open("GET",this.props.styleUrl),e.send()},setBackgroundColor(){var t=this.style.layers;for(var e in t)if("background"===t[e].type)return void(this.$(".container").style["background-color"]=t[e].paint["background-color"]||"#fff")},onMounted(){if(!this.props.styleUrl)return console.error("Style URL is missing");this.fetchStyleURL(((t,e)=>{if(t)return console.error("Error in fetch style");this.style=e,this.update()}))},onUpdated(){this.setBackgroundColor(),re.fonts.download();const t=location&&location.hash&&location.hash.replace("#",""),e=t&&this.$(t);e&&window.scrollTo({top:e.offsetTop,behavior:"smooth"})},taxonomy:re},template:function(t,e,n,r){return t('
',[{type:n.IF,evaluate:function(t){return t.style&&t.style.metadata},redundantAttribute:"expr0",selector:"[expr0]",template:t('
\n Powered by JawgMaps. Contribute on GitHub.\n
',[{type:n.IF,evaluate:function(t){return t.style.metadata["taxonomy:title"]},redundantAttribute:"expr1",selector:"[expr1]",template:t('

',[{redundantAttribute:"expr2",selector:"[expr2]",expressions:[{type:e.TEXT,childNodeIndex:0,evaluate:function(t){return t.style.metadata["taxonomy:title"]}}]}])},{type:n.EACH,getKey:null,condition:null,template:t('',[{type:n.IF,evaluate:function(t){return"line"===t.group.type},redundantAttribute:"expr4",selector:"[expr4]",template:t(null,[{type:n.TAG,getComponent:r,evaluate:function(t){return"line-render"},slots:[],attributes:[{type:e.ATTRIBUTE,name:"layers",evaluate:function(t){return t.style.layers}},{type:e.ATTRIBUTE,name:"title",evaluate:function(t){return t.group.title}},{type:e.ATTRIBUTE,name:"group",evaluate:function(t){return t.group.id}},{type:e.ATTRIBUTE,name:"zooms",evaluate:function(t){return t.taxonomy.getZooms(t.group.zooms)}}]}])},{type:n.IF,evaluate:function(t){return"polygon"===t.group.type},redundantAttribute:"expr5",selector:"[expr5]",template:t(null,[{type:n.TAG,getComponent:r,evaluate:function(t){return"polygon-render"},slots:[],attributes:[{type:e.ATTRIBUTE,name:"layers",evaluate:function(t){return t.style.layers}},{type:e.ATTRIBUTE,name:"title",evaluate:function(t){return t.group.title}},{type:e.ATTRIBUTE,name:"group",evaluate:function(t){return t.group.id}},{type:e.ATTRIBUTE,name:"zooms",evaluate:function(t){return t.taxonomy.getZooms(t.group.zooms)}}]}])},{type:n.IF,evaluate:function(t){return"symbol"===t.group.type},redundantAttribute:"expr6",selector:"[expr6]",template:t(null,[{type:n.TAG,getComponent:r,evaluate:function(t){return"symbol-render"},slots:[],attributes:[{type:e.ATTRIBUTE,name:"layers",evaluate:function(t){return t.style.layers}},{type:e.ATTRIBUTE,name:"title",evaluate:function(t){return t.group.title}},{type:e.ATTRIBUTE,name:"group",evaluate:function(t){return t.group.id}},{type:e.ATTRIBUTE,name:"zooms",evaluate:function(t){return t.taxonomy.getZooms(t.group.zooms)}}]}])},{type:n.IF,evaluate:function(t){return"annotation"===t.group.type},redundantAttribute:"expr7",selector:"[expr7]",template:t(null,[{type:n.TAG,getComponent:r,evaluate:function(t){return"annotation"},slots:[],attributes:[{type:e.ATTRIBUTE,name:"layers",evaluate:function(t){return t.style.layers}},{type:e.ATTRIBUTE,name:"content",evaluate:function(t){return t.group.content}},{type:e.ATTRIBUTE,name:"group",evaluate:function(t){return t.group.id}},{type:e.ATTRIBUTE,name:"zooms",evaluate:function(t){return t.taxonomy.getZooms(t.group.zooms)}}]}])}]),redundantAttribute:"expr3",selector:"[expr3]",itemName:"group",indexName:null,evaluate:function(t){return t.style.metadata["taxonomy:groups"]}}])}])},name:"taxonomy"},function(t,e,n){var r=void 0===n?{}:n,i=r.slots,o=r.attributes,a=r.parentScope;return function(){for(var t=arguments.length,e=new Array(t),n=0;n acc.concat(e), [])) + } + return ["interpolate", ["exponential", exp.base], + ["zoom"] + ].concat(exp.stops.reduce((acc, e) => acc.concat(e), [])) + } + parseInterpolate(exp, value) { + if (!exp || exp[0] !== 'interpolate' || exp.length < 4) { + return null + } + + const base = exp[1][0] === "exponential" ? exp[1][1] : 1 + const stops = exp.slice(3).reduce((acc, e, i) => { + i % 2 === 0 ? acc.push([e]) : acc[acc.length - 1].push(e) + return acc + }, []); + if (stops.length === 1 || stops[0][0] >= value) { + return { + value: stops[0][1] + }; + } else if (stops[stops.length - 1][0] <= value) { + return { + value: stops[stops.length - 1][1] + }; + } + const index = this.findStopLessThanOrEqualTo(stops, value); + return { + lower: stops[index][1], + upper: stops[index + 1][1], + t: this.interpolationFactor(value, base, stops[index][0], stops[index + 1][0]) + } + } } class Fonts { @@ -116,7 +152,7 @@ class Fonts { class Taxonomy { constructor() { this.zooms = this.generateArray(1, 20); - this.stops = new Stops(); + this.expressions = new Expressions(); this.fonts = new Fonts(); } generateArray(min, max) { @@ -147,17 +183,12 @@ class Taxonomy { } else if (typeof width === 'number') { return width; } - const stops = width.stops; - if (stops.length === 1 || stops[0][0] >= zoom) { - return stops[0][1]; - } else if (stops[stops.length - 1][0] <= zoom) { - return stops[stops.length - 1][1]; + const expression = this.expressions.asExpression(width) + const interpolate = this.expressions.parseInterpolate(expression, zoom) + if (interpolate) { + if (interpolate.value) return interpolate.value + return +this.expressions.number(interpolate.lower, interpolate.upper, interpolate.t).toFixed(2); } - const index = this.stops.findStopLessThanOrEqualTo(stops, zoom); - const t = this.stops.interpolationFactor(zoom, width.base, stops[index][0], stops[index + 1][0]); - const outputLower = stops[index][1]; - const outputUpper = stops[index + 1][1]; - return +this.stops.interpolate.number(outputLower, outputUpper, t).toFixed(2); } parseColor(layer, color, zoom) { if ( @@ -170,30 +201,27 @@ class Taxonomy { } else if (typeof color === 'string') { return color; } - const stops = color.stops; - if (stops.length === 1 || stops[0][0] >= zoom) { - return stops[0][1]; - } else if (stops[stops.length - 1][0] <= zoom) { - return stops[stops.length - 1][1]; + const expression = this.expressions.asExpression(color) + const interpolate = this.expressions.parseInterpolate(expression, zoom) + if (interpolate) { + if (interpolate.value) return interpolate.value + const typeValueLower = colorConverter.getStringTypeAndValue(interpolate.lower); + const typeValueUpper = colorConverter.getStringTypeAndValue(interpolate.upper); + const outputLower = + typeValueLower.type === 'rgb' ? + typeValueLower.value : + colorConverter[typeValueLower.type].rgb(typeValueLower.value); + const outputUpper = + typeValueUpper.type === 'rgb' ? + typeValueUpper.value : + colorConverter[typeValueUpper.type].rgb(typeValueUpper.value); + return colorConverter.rgba.toString([ + this.expressions.number(outputLower[0], outputUpper[0], interpolate.t), + this.expressions.number(outputLower[1], outputUpper[1], interpolate.t), + this.expressions.number(outputLower[2], outputUpper[2], interpolate.t), + 1, + ]); } - const index = this.stops.findStopLessThanOrEqualTo(stops, zoom); - const t = this.stops.interpolationFactor(zoom, color.base, stops[index][0], stops[index + 1][0]); - const typeValueLower = colorConverter.getStringTypeAndValue(stops[index][1]); - const typeValueUpper = colorConverter.getStringTypeAndValue(stops[index + 1][1]); - const outputLower = - typeValueLower.type === 'rgb' - ? typeValueLower.value - : colorConverter[typeValueLower.type].rgb(typeValueLower.value); - const outputUpper = - typeValueUpper.type === 'rgb' - ? typeValueUpper.value - : colorConverter[typeValueUpper.type].rgb(typeValueUpper.value); - return colorConverter.rgba.toString([ - this.stops.interpolate.number(outputLower[0], outputUpper[0], t), - this.stops.interpolate.number(outputLower[1], outputUpper[1], t), - this.stops.interpolate.number(outputLower[2], outputUpper[2], t), - 1, - ]); } renderLine(layer, zooms) { const line = this.widthAndColorByZooms(layer, { @@ -231,7 +259,7 @@ class Taxonomy { res.maxWidth = parsedWidth; } res[zoom] = { - width: parsedWidth, + width: isNaN(parsedWidth) ? 0 : parsedWidth, color: this.parseColor(layer, color, zoom), opacity: this.parseNumber(layer, opacity, zoom), }; @@ -262,4 +290,4 @@ class Taxonomy { } } -export default new Taxonomy(); +export default new Taxonomy(); \ No newline at end of file