Fantasy-Map-Generator/dist/assets/index.73bf34f9.js

72 lines
529 KiB
JavaScript

var rn=Object.defineProperty;var sn=(e,t,n)=>t in e?rn(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var oa=(e,t,n)=>(sn(e,typeof t!="symbol"?t+"":t,n),n);const ln=function(){const t=document.createElement("link").relList;if(t&&t.supports&&t.supports("modulepreload"))return;for(const r of document.querySelectorAll('link[rel="modulepreload"]'))i(r);new MutationObserver(r=>{for(const c of r)if(c.type==="childList")for(const f of c.addedNodes)f.tagName==="LINK"&&f.rel==="modulepreload"&&i(f)}).observe(document,{childList:!0,subtree:!0});function n(r){const c={};return r.integrity&&(c.integrity=r.integrity),r.referrerpolicy&&(c.referrerPolicy=r.referrerpolicy),r.crossorigin==="use-credentials"?c.credentials="include":r.crossorigin==="anonymous"?c.credentials="omit":c.credentials="same-origin",c}function i(r){if(r.ep)return;r.ep=!0;const c=n(r);fetch(r.href,c)}};ln();const zt=location.hostname&&location.hostname!=="localhost"&&location.hostname!=="127.0.0.1";var da;const cn=window.innerWidth<600||((da=window.navigator.userAgentData)==null?void 0:da.mobile),un=255,Dt=65535,Ht=4294967295,ha=Boolean(localStorage.getItem("debug")),Ft=ha||!zt,Q=ha||!zt,dn=!0;function De(e){return e[e.length-1]}function hn(e){return[...new Set(e)]}function yt({maxValue:e,length:t,from:n}){const i=gn(e);return n?i.from(n):new i(t)}function gn(e){return console.assert(Number.isInteger(e)&&e>=0&&e<=Ht,`Array maxValue must be an integer between 0 and ${Ht}, got ${e}`),e<=un?Uint8Array:e<=Dt?Uint16Array:(e<=Ht,Uint32Array)}function O(e,t=0){const n=Math.pow(10,t);return Math.round(e*n)/n}function Ie(e,t,n){return Math.min(Math.max(e,t),n)}function ga(e,t,n){return Ie((e-t)/(n-t),0,1)}const ne=document.getElementById.bind(document);Node.prototype.on=function(e,t,n){this.addEventListener(e,t,n)};Node.prototype.off=function(e,t){this.removeEventListener(e,t)};function ze(e){return localStorage.getItem(e)||null}function pa(e,t){return localStorage.setItem(e,t)}const pn=window.Delaunator,mn=window.Voronoi,dt=window.graphWidth,ht=window.graphHeight;function fn(e){var c;const t=Number((c=ne("pointsInput"))==null?void 0:c.dataset.cells);if(t!==e.cellsDesired)return!0;const n=O(Math.sqrt(dt*ht/t),2),i=Math.floor((dt+.5*n-1e-10)/n),r=Math.floor((ht+.5*n-1e-10)/n);return e.spacing!==n||e.cellsX!==i||e.cellsY!==r}function yn(){Math.random=aleaPRNG(seed);const{spacing:e,cellsDesired:t,boundary:n,points:i,cellsX:r,cellsY:c}=bn(),{cells:f,vertices:z}=ma(i,n);return{spacing:e,cellsDesired:t,boundary:n,points:i,cellsX:r,cellsY:c,cells:f,vertices:z}}function bn(){Q&&console.time("placePoints");const e=+ne("pointsInput").dataset.cells,t=O(Math.sqrt(dt*ht/e),2),n=vn(dt,ht,t),i=kn(dt,ht,t),r=Math.floor((dt+.5*t-1e-10)/t),c=Math.floor((ht+.5*t-1e-10)/t);return Q&&console.timeEnd("placePoints"),{spacing:t,cellsDesired:e,boundary:n,points:i,cellsX:r,cellsY:c}}function ma(e,t){Q&&console.time("calculateDelaunay");const n=e.concat(t),i=pn.from(n);Q&&console.timeEnd("calculateDelaunay"),Q&&console.time("calculateVoronoi");const r=new mn(i,n,e.length),c=r.cells;c.i=yt({maxValue:e.length,length:e.length}).map((z,m)=>m);const f=r.vertices;return Q&&console.timeEnd("calculateVoronoi"),{cells:c,vertices:f}}function vn(e,t,n){const i=O(-1*n),r=n*2,c=e-i*2,f=t-i*2,z=Math.ceil(c/r)-1,m=Math.ceil(f/r)-1,b=[];for(let A=.5;A<z;A++){let u=Math.ceil(c*A/z+i);b.push([u,i],[u,f+i])}for(let A=.5;A<m;A++){let u=Math.ceil(f*A/m+i);b.push([i,u],[c+i,u])}return b}function kn(e,t,n){const i=n/2,r=i*.9,c=r*2,f=()=>Math.random()*c-r;let z=[];for(let m=i;m<t;m+=n)for(let b=i;b<e;b+=n){const A=Math.min(O(b+f(),2),e),u=Math.min(O(m+f(),2),t);z.push([A,u])}return z}function Xe(e,t,n){return Math.floor(Math.min(t/n.spacing,n.cellsY-1))*n.cellsX+Math.floor(Math.min(e/n.spacing,n.cellsX-1))}function wn(e,t,n){return pack.cells.q.findAll(e,t,n).map(r=>r[2])}function Zt(e){return pack.cells.v[e].map(t=>pack.vertices.p[t])}function Te(e,t,n=1/0){const i=pack.cells.q.find(e,t,n);return i?i[2]:void 0}function fa(e){return grid.cells.v[e].map(t=>grid.vertices.p[t])}function Sn(e){return pack.cells.h[e]>=20}function Ys(e){return pack.cells.h[e]<20}(function(){const t=function(c,f,z,m,b){this.node=c,this.x0=f,this.y0=z,this.x1=m,this.y1=b},n=function(c,f,z){var m={x:c,y:f,x0:this._x0,y0:this._y0,x3:this._x1,y3:this._y1,quads:[],node:this._root};for(m.node&&m.quads.push(new t(m.node,m.x0,m.y0,m.x3,m.y3)),i(m,z);m.q=m.quads.pop();)if(!(!(m.node=m.q.node)||(m.x1=m.q.x0)>m.x3||(m.y1=m.q.y0)>m.y3||(m.x2=m.q.x1)<m.x0||(m.y2=m.q.y1)<m.y0))if(m.node.length){m.node.explored=!0;var b=(m.x1+m.x2)/2,A=(m.y1+m.y2)/2;m.quads.push(new t(m.node[3],b,A,m.x2,m.y2),new t(m.node[2],m.x1,A,b,m.y2),new t(m.node[1],b,m.y1,m.x2,A),new t(m.node[0],m.x1,m.y1,b,A)),(m.i=(f>=A)<<1|c>=b)&&(m.q=m.quads[m.quads.length-1],m.quads[m.quads.length-1]=m.quads[m.quads.length-1-m.i],m.quads[m.quads.length-1-m.i]=m.q)}else{var u=c-+this._x.call(null,m.node.data),C=f-+this._y.call(null,m.node.data),g=u*u+C*C;r(m,g)}return m.result};d3.quadtree.prototype.findAll=n;var i=function(c,f){c.result=[],c.x0=c.x-f,c.y0=c.y-f,c.x3=c.x+f,c.y3=c.y+f,c.radius=f*f},r=function(c,f){if(c.node.data.scanned=!0,f<c.radius)do c.result.push(c.node.data),c.node.data.selected=!0;while(c.node=c.node.next)}})();const An=window.d3;function be(e,t){return e===void 0&&t===void 0?Math.random():(t===void 0&&(t=e,e=0),Math.floor(Math.random()*(t-e+1))+e)}function V(e){return e>=1?!0:e<=0?!1:Math.random()<e}function zn(e){return t=>t%e===0}function Ce(e=100,t=30,n=0,i=300,r=0){const c=An.randomNormal(e,t),f=Ie(c(),n,i);return O(f,r)}function xn(e){return~~e+ +V(e%1)}function ie(e){return e[Math.floor(Math.random()*e.length)]}function he(e){const t=Object.entries(e).map(([n,i])=>new Array(i).fill(n)).flat();return ie(t)}function Ot(e,t,n){return Math.round(e+(t-e)*Math.pow(Math.random(),n))}function et(e){if(typeof e!="string")return console.error("The value should be a string",e),0;const t=Number(e);if(!isNaN(t))return xn(t);const n=e.startsWith("-"),i=n?-1:1;n&&(e=e.substring(1));const[r,c]=e.split("-"),f=be(i*+r,+c);return isNaN(f)||f<0?(console.error("Cannot parse number. Check the format",e),0):f}function Jt(){return String(Math.floor(Math.random()*1e9))}window.HeightmapGenerator=function(){let e=null,t=null,n,i;const r=h=>{const{cellsDesired:v,cells:E,points:P}=h;t=E.h||yt({maxValue:100,length:P.length}),n=u(v),i=C(),e=h},c=()=>t,f=()=>{t=null,e=null},z=(h,v)=>{var T;const P=(((T=heightmapTemplates[v])==null?void 0:T.template)||"").split(`
`);if(!P.length)throw new Error(`Heightmap template: no steps. Template: ${v}. Steps: ${P}`);r(h);for(const R of P){const L=R.trim().split(" ");if(L.length<2)throw new Error(`Heightmap template: steps < 2. Template: ${v}. Step: ${L}`);A(...L)}return t},m=(h,v)=>new Promise(E=>{const P=document.createElement("canvas"),T=P.getContext("2d"),{cellsX:R,cellsY:L}=h;P.width=R,P.height=L;const M=new Image;M.src=`./heightmaps/${v}.png`,M.onload=()=>{T.drawImage(M,0,0,R,L);const I=T.getImageData(0,0,R,L);r(h),S(I.data),P.remove(),M.remove(),E(t)}}),b=async function(h){Q&&console.time("defineHeightmap");const v=ne("templateInput").value;Math.random=aleaPRNG(seed);const P=v in heightmapTemplates?z(h,v):await m(h,v);return Q&&console.timeEnd("defineHeightmap"),f(),P};function A(h,v,E,P,T){if(h==="Hill")return g(v,E,P,T);if(h==="Pit")return p(v,E,P,T);if(h==="Range")return B(v,E,P,T);if(h==="Trough")return k(v,E,P,T);if(h==="Strait")return d(v,E);if(h==="Mask")return l(v);if(h==="Invert")return a(v,E);if(h==="Add")return s(E,+v,1);if(h==="Multiply")return s(E,0,+v);if(h==="Smooth")return o(v)}function u(h){return{1e3:.93,2e3:.95,5e3:.97,1e4:.98,2e4:.99,3e4:.991,4e4:.993,5e4:.994,6e4:.995,7e4:.9955,8e4:.996,9e4:.9964,1e5:.9973}[h]||.98}function C(){return{1e3:.75,2e3:.77,5e3:.79,1e4:.81,2e4:.82,3e4:.83,4e4:.84,5e4:.86,6e4:.87,7e4:.88,8e4:.91,9e4:.92,1e5:.93}[cells]||.81}const g=(h,v,E,P)=>{for(h=et(h);h>0;)T(),h--;function T(){const R=new Uint8Array(t.length);let L=0,M,I=lim(et(v));do{const G=w(E,graphWidth),D=w(P,graphHeight);M=Xe(G,D,e),L++}while(t[M]+I>90&&L<50);R[M]=I;const H=[M];for(;H.length;){const G=H.shift();for(const D of e.cells.c[G])R[D]||(R[D]=R[G]**n*(Math.random()*.2+.9),R[D]>1&&H.push(D))}t=t.map((G,D)=>lim(G+R[D]))}},p=(h,v,E,P)=>{for(h=et(h);h>0;)T(),h--;function T(){const R=new Uint8Array(t.length);let L=0,M,I=lim(et(v));do{const G=w(E,graphWidth),D=w(P,graphHeight);M=Xe(G,D,e),L++}while(t[M]<20&&L<50);const H=[M];for(;H.length;){const G=H.shift();if(I=I**n*(Math.random()*.2+.9),I<1)return;e.cells.c[G].forEach(function(D,U){R[D]||(t[D]=lim(t[D]-I*(Math.random()*.2+.9)),R[D]=1,H.push(D))})}}},B=(h,v,E,P)=>{for(h=et(h);h>0;)T(),h--;function T(){const R=new Uint8Array(t.length);let L=lim(et(v));const M=w(E,graphWidth),I=w(P,graphHeight);let H=0,G=0,D,U;do D=Math.random()*graphWidth*.8+graphWidth*.1,U=Math.random()*graphHeight*.7+graphHeight*.15,H=Math.abs(U-I)+Math.abs(D-M),G++;while((H<graphWidth/8||H>graphWidth/3)&&G<50);const F=Xe(M,I,e),j=Xe(D,U,e);let Z=te(F,j);function te(ee,le){const Y=[ee],W=e.points;for(R[ee]=1;ee!==le;){let de=1/0;if(e.cells.c[ee].forEach(function(me){if(R[me])return;let pe=(W[le][0]-W[me][0])**2+(W[le][1]-W[me][1])**2;Math.random()>.85&&(pe=pe/2),pe<de&&(de=pe,ee=me)}),de===1/0)return Y;Y.push(ee),R[ee]=1}return Y}let q=Z.slice(),X=0;for(;q.length;){const ee=q.slice();if(q=[],X++,ee.forEach(le=>{t[le]=lim(t[le]+L*(Math.random()*.3+.85))}),L=L**i-1,L<2)break;ee.forEach(le=>{e.cells.c[le].forEach(Y=>{R[Y]||(q.push(Y),R[Y]=1)})})}Z.forEach((ee,le)=>{if(le%6===0)for(const Y of d3.range(X)){const W=e.cells.c[ee][d3.scan(e.cells.c[ee],(de,me)=>t[de]-t[me])];t[W]=(t[ee]*2+t[W])/3,ee=W}})}},k=(h,v,E,P)=>{for(h=et(h);h>0;)T(),h--;function T(){const R=new Uint8Array(t.length);let L=lim(et(v)),M=0,I,H,G,D=0,U,F;do I=w(E,graphWidth),H=w(P,graphHeight),G=Xe(I,H,e),M++;while(t[G]<20&&M<50);M=0;do U=Math.random()*graphWidth*.8+graphWidth*.1,F=Math.random()*graphHeight*.7+graphHeight*.15,D=Math.abs(F-H)+Math.abs(U-I),M++;while((D<graphWidth/8||D>graphWidth/2)&&M<50);let j=Z(G,Xe(U,F,e));function Z(X,ee){const le=[X],Y=e.points;for(R[X]=1;X!==ee;){let W=1/0;if(e.cells.c[X].forEach(function(de){if(R[de])return;let me=(Y[ee][0]-Y[de][0])**2+(Y[ee][1]-Y[de][1])**2;Math.random()>.8&&(me=me/2),me<W&&(W=me,X=de)}),W===1/0)return le;le.push(X),R[X]=1}return le}let te=j.slice(),q=0;for(;te.length;){const X=te.slice();if(te=[],q++,X.forEach(ee=>{t[ee]=lim(t[ee]-L*(Math.random()*.3+.85))}),L=L**i-1,L<2)break;X.forEach(ee=>{e.cells.c[ee].forEach(le=>{R[le]||(te.push(le),R[le]=1)})})}j.forEach((X,ee)=>{if(ee%6===0)for(const le of d3.range(q)){const Y=e.cells.c[X][d3.scan(e.cells.c[X],(W,de)=>t[W]-t[de])];t[Y]=(t[X]*2+t[Y])/3,X=Y}})}},d=(h,v="vertical")=>{if(h=Math.min(et(h),e.cellsX/3),h<1&&V(h))return;const E=new Uint8Array(t.length),P=v==="vertical",T=P?Math.floor(Math.random()*graphWidth*.4+graphWidth*.3):5,R=P?5:Math.floor(Math.random()*graphHeight*.4+graphHeight*.3),L=P?Math.floor(graphWidth-T-graphWidth*.1+Math.random()*graphWidth*.2):graphWidth-5,M=P?graphHeight-5:Math.floor(graphHeight-R-graphHeight*.1+Math.random()*graphHeight*.2),I=Xe(T,R,e),H=Xe(L,M,e);let G=U(I,H);const D=[];function U(j,Z){const te=[],q=e.points;for(;j!==Z;){let X=1/0;e.cells.c[j].forEach(function(ee){let le=(q[Z][0]-q[ee][0])**2+(q[Z][1]-q[ee][1])**2;Math.random()>.8&&(le=le/2),le<X&&(X=le,j=ee)}),te.push(j)}return te}const F=.1/h;for(;h>0;){const j=.9-F*h;G.forEach(function(Z){e.cells.c[Z].forEach(function(te){E[te]||(E[te]=1,D.push(te),t[te]**=j,t[te]>100&&(t[te]=5))})}),G=D.slice(),h--}},s=(h,v,E,P)=>{const T=h==="land"?20:h==="all"?0:+h.split("-")[0],R=h==="land"||h==="all"?100:+h.split("-")[1],L=T===20;t=t.map(M=>M<T||M>R?M:(v&&(M=L?Math.max(M+v,20):M+v),E!==1&&(M=L?(M-20)*E+20:M*E),P&&(M=L?(M-20)**P+20:M**P),lim(M)))},o=(h=2,v=0)=>{t=t.map((E,P)=>{const T=[E];return e.cells.c[P].forEach(R=>T.push(t[R])),h===1?d3.mean(T)+v:lim((E*(h-1)+d3.mean(T)+v)/h)})},l=(h=1)=>{const v=h?Math.abs(h):1;t=t.map((E,P)=>{const[T,R]=e.points[P],L=2*T/graphWidth-1,M=2*R/graphHeight-1;let I=(1-L**2)*(1-M**2);h<0&&(I=1-I);const H=E*I;return lim((E*(v-1)+H)/v)})},a=(h,v)=>{if(!V(h))return;const E=v!=="y",P=v!=="x",{cellsX:T,cellsY:R}=e;t=t.map((M,I)=>{const H=I%T,G=Math.floor(I/T),D=E?T-H-1:H,U=P?R-G-1:G,F=D+U*T;return t[F]})};function w(h,v){if(typeof h!="string"){ERROR&&console.error("Range should be a string");return}const E=h.split("-")[0]/100||0,P=h.split("-")[1]/100||E;return be(E*v,P*v)}function S(h){for(let v=0;v<t.length;v++){const E=h[v*4]/255,P=E<.2?E:.2+(E-.2)**.8;t[v]=minmax(Math.floor(P*100),0,100)}}return{setGraph:r,getHeights:c,generate:b,fromTemplate:z,fromPrecreated:m,addHill:g,addRange:B,addTrough:k,addStrait:d,addPit:p,smooth:o,modify:s,mask:l,invert:a}}();var Cn=xt;xt.polyline=xt;xt.polygon=Bn;function xt(e,t,n){var i=e.length,r=gt(e[0],t),c=[],f,z,m,b,A;for(n||(n=[]),f=1;f<i;f++){for(z=e[f-1],m=e[f],b=A=gt(m,t);;)if(r|b){if(r&b)break;r?(z=Gt(z,m,r,t),r=gt(z,t)):(m=Gt(z,m,b,t),b=gt(m,t))}else{c.push(z),b!==A?(c.push(m),f<i-1&&(n.push(c),c=[])):f===i-1&&c.push(m);break}r=A}return c.length&&n.push(c),n}function Bn(e,t){var n,i,r,c,f,z,m;for(i=1;i<=8;i*=2){for(n=[],r=e[e.length-1],c=!(gt(r,t)&i),f=0;f<e.length;f++)z=e[f],m=!(gt(z,t)&i),m!==c&&n.push(Gt(r,z,i,t)),m&&n.push(z),r=z,c=m;if(e=n,!e.length)break}return n}function Gt(e,t,n,i){return n&8?[e[0]+(t[0]-e[0])*(i[3]-e[1])/(t[1]-e[1]),i[3]]:n&4?[e[0]+(t[0]-e[0])*(i[1]-e[1])/(t[1]-e[1]),i[1]]:n&2?[i[2],e[1]+(t[1]-e[1])*(i[2]-e[0])/(t[0]-e[0])]:n&1?[i[0],e[1]+(t[1]-e[1])*(i[0]-e[0])/(t[0]-e[0])]:null}function gt(e,t){var n=0;return e[0]<t[0]?n|=1:e[0]>t[2]&&(n|=2),e[1]<t[1]?n|=4:e[1]>t[3]&&(n|=8),n}const{graphWidth:Mn,graphHeight:En,pack:Ln}=window;function Et(e){return Cn.polygon(e,[0,0,Mn,En])}function In(e,t,n=10){if(e.length===2)return 1;const i=(f,z)=>(f[0]-z[0])**2+(f[1]-z[1])**2;let r=1,c=1/0;for(let f=0;f<e.length-1;f++){const z=e[f],m=e[f+1],b=Math.sqrt(i(z,m)),A=Math.ceil(b/n),u=(m[0]-z[0])/A,C=(m[1]-z[1])/A;for(let g=0;g<A;g++){const p=z[0]+g*u,B=z[1]+g*C,k=i(t,[p,B]);k>=c||(c=k,r=f+1)}}return r}function ya(e,t){const{cells:n,vertices:i}=Ln,r=n.v[e].filter(u=>i.c[u].some(C=>C===t)),[c,f]=i.p[r[0]],[z,m]=i.p[r[1]],b=(c+z)/2,A=(f+m)/2;return[b,A]}function it(e,t=1){return e.replace(/[\d\.-][\d\.e-]*/g,n=>String(O(+n,t)))}function ba(e){return e.charAt(0).toUpperCase()+e.slice(1)}function ia(e){const t=e.length/2,n=e.split(" ");if(n.length<2)return n;let i="",r="",c="",f="";return n.forEach((z,m)=>{m+1!==n.length&&(z+=" "),f+=z,!i||f.length<t?i+=z:c?r+=z:c=z}),r?i.length<r.length?[i+c,r]:[i,c+r]:[i,c]}function Yt(e){if(!e)return[0,0,0,0,0,1];const t=e.replace(/[a-z()]/g,"").replace(/[ ]/g,",").split(",");return[t[0]||0,t[1]||0,t[2]||0,t[3]||0,t[4]||0,t[5]||1]}const Rn=e=>{try{JSON.parse(e)}catch{return!1}return!0};window.OceanLayers=function(){let e,t,n,i;const r=function(){const m=oceanLayers.attr("layers");if(m==="none")return;Q&&console.time("drawOceanLayers"),lineGen.curve(d3.curveBasisClosed),e=grid.cells,n=grid.cells.i.length,t=grid.vertices;const b=m==="random"?c():m.split(",").map(g=>+g),A=[],u=O(.4/b.length,2);i=new Uint8Array(n);for(const g of e.i){const p=e.t[g];if(p>0||i[g]||!b.includes(p))continue;const B=C(g,p);if(!B)continue;i[g]=1;const k=f(B,p);if(k.length<4)continue;const d=1+p*-2,s=k.filter((l,a)=>!(a%d)||t.c[l].some(w=>w>=n));if(s.length<4)continue;const o=Et(s.map(l=>t.p[l]));A.push([p,o])}for(const g of b){let B=A.filter(k=>k[0]===g).map(k=>it(lineGen(k[1]))).join("");B&&oceanLayers.append("path").attr("d",B).attr("fill","#ecf2f9").style("opacity",u)}function C(g,p){return e.b[g]?e.v[g].find(B=>t.c[B].some(k=>k>=n)):e.v[g][e.c[g].findIndex(B=>e.t[B]<p||!e.t[B])]}Q&&console.timeEnd("drawOceanLayers")};function c(){const z=[];let m=.2;for(let b=-9;b<0;b++)V(m)?(m=.2,z.push(b)):m*=2;return z}function f(z,m){const b=[];for(let A=0,u=z;A===0||u!==z&&A<1e4;A++){const C=b[b.length-1];b.push(u);const g=t.c[u];g.filter(s=>e.t[s]===m).forEach(s=>i[s]=1);const p=t.v[u],B=!e.t[g[0]]||e.t[g[0]]===m-1,k=!e.t[g[1]]||e.t[g[1]]===m-1,d=!e.t[g[2]]||e.t[g[2]]===m-1;if(p[0]!==void 0&&p[0]!==C&&B!==k?u=p[0]:p[1]!==void 0&&p[1]!==C&&k!==d?u=p[1]:p[2]!==void 0&&p[2]!==C&&B!==d&&(u=p[2]),u===b[b.length-1]){ERROR&&console.error("Next vertex is not found");break}}return b.push(b[0]),b}return r}();window.Rivers=function(){const e=function(S=!0){Q&&console.time("generateRivers"),Math.random=aleaPRNG(seed);const{cells:h,features:v}=pack,E={},P={},T=function(U,F){E[F]?E[F].push(U):E[F]=[U]};h.fl=new Uint16Array(h.i.length),h.r=new Uint16Array(h.i.length),h.conf=new Uint8Array(h.i.length);let R=1;const L=t();Lakes.prepareLakeData(L),n(L),M(),H(),D(),Lakes.cleanupLakeData(),S&&(h.h=Uint8Array.from(L),G()),Q&&console.timeEnd("generateRivers");function M(){const F=(pointsInput.dataset.cells/1e4)**.25,j=grid.cells.prec;pack.cells.area;const Z=h.i.filter(q=>L[q]>=20).sort((q,X)=>L[X]-L[q]),te=Lakes.setClimateData(L);Z.forEach(function(q){var Y;h.fl[q]+=j[h.g[q]]/F;const X=te[q]?v.filter(W=>q===W.outCell&&W.flux>W.evaporation):[];for(const W of X){const de=h.c[q].find(me=>L[me]<20&&h.f[me]===W.i);h.fl[de]+=Math.max(W.flux-W.evaporation,0),h.r[de]!==W.river&&(h.c[de].some(pe=>h.r[pe]===W.river)?(h.r[de]=W.river,T(de,W.river)):(h.r[de]=R,T(de,R),R++)),W.outlet=h.r[de],I(q,h.fl[de],W.outlet)}const ee=(Y=X[0])==null?void 0:Y.outlet;for(const W of X)if(!!Array.isArray(W.inlets))for(const de of W.inlets)P[de]=ee;if(h.b[q]&&h.r[q])return T(-1,h.r[q]);let le=null;if(te[q]?le=h.c[q].filter(de=>!X.map(me=>me.i).includes(h.f[de])).sort((de,me)=>L[de]-L[me])[0]:h.haven[q]?le=h.haven[q]:le=h.c[q].sort((W,de)=>L[W]-L[de])[0],!(L[q]<=L[le])){if(h.fl[q]<30){L[le]>=20&&(h.fl[le]+=h.fl[q]);return}h.r[q]||(h.r[q]=R,T(q,R),R++),I(le,h.fl[q],h.r[q])}})}function I(U,F,j){const Z=h.fl[U]-h.conf[U],te=h.r[U];if(te?F>Z?(h.conf[U]+=h.fl[U],L[U]>=20&&(P[te]=j),h.r[U]=j):(h.conf[U]+=F,L[U]>=20&&(P[j]=te)):h.r[U]=j,L[U]<20){const q=v[h.f[U]];q.type==="lake"&&((!q.river||F>q.enteringFlux)&&(q.river=j,q.enteringFlux=F),q.flux=q.flux+F,q.inlets?q.inlets.push(j):q.inlets=[j])}else h.fl[U]+=F;T(U,j)}function H(){h.r=new Uint16Array(h.i.length),h.conf=new Uint16Array(h.i.length),pack.rivers=[];const U=O(1/(pointsInput.dataset.cells/1e4)**.25,2),F=U*1.2;for(const j in E){const Z=E[j];if(Z.length<3)continue;const te=+j;for(const pe of Z)pe<0||h.h[pe]<20||(h.r[pe]?h.conf[pe]=1:h.r[pe]=te);const q=Z[0],X=Z[Z.length-2],ee=P[j]||0,le=!ee||ee===te?F:U,Y=i(Z),W=h.fl[X],de=o(Y),me=l(C(W,Y.length,le,0));pack.rivers.push({i:te,source:q,mouth:X,discharge:W,length:de,width:me,widthFactor:le,sourceWidth:0,parent:ee,cells:Z})}}function G(){for(const F of pack.cells.i){if(h.h[F]<35||!h.fl[F])continue;const j=h.c[F].filter(q=>h.h[q]>h.h[F]),Z=j.reduce((q,X)=>q+h.fl[X],0)/j.length;if(!Z)continue;const te=Math.floor(h.fl[F]/Z);te&&(h.h[F]-=Math.min(te,5))}}function D(){for(const U of h.i){if(!h.conf[U])continue;const F=h.c[U].filter(j=>h.r[j]&&L[j]>L[U]).map(j=>h.fl[j]).sort((j,Z)=>Z-j);h.conf[U]=F.reduce((j,Z,te)=>te?j+Z:j,0)}}},t=()=>{const{h:S,c:h,t:v}=pack.cells;return Array.from(S).map((E,P)=>E<20||v[P]<1?E:E+v[P]/100+d3.mean(h[P].map(T=>v[T]))/1e4)},n=function(S){const{cells:h,features:v}=pack,E=+document.getElementById("resolveDepressionsStepsOutput").value,P=E*.85,T=E*.75,R=D=>v[h.f[D]].height||S[D],L=v.filter(D=>D.type==="lake"),M=h.i.filter(D=>S[D]>=20&&!h.b[D]);M.sort((D,U)=>S[D]-S[U]);const I=[];let H=1/0,G=null;for(let D=0;H&&D<E;D++){if(I.length>5&&d3.sum(I)>0){S=t(),H=I[0];break}if(H=0,D<P)for(const U of L){if(U.closed)continue;const F=d3.min(U.shoreline.map(j=>S[j]));if(!(F>=100||U.height>F)){if(D>T){U.shoreline.forEach(j=>S[j]=h.h[j]),U.height=d3.min(U.shoreline.map(j=>S[j]))-1,U.closed=!0;continue}H++,U.height=F+.2}}for(const U of M){const F=d3.min(h.c[U].map(j=>R(j)));F>=100||S[U]>F||(H++,S[U]=F+.1)}G!==null&&I.push(H-G),G=H}H&&WARN&&console.warn(`Unresolved depressions: ${H}. Edit heightmap to fix`)},i=function(S,h=null,v=.5){const{fl:E,conf:P,h:T}=pack.cells,R=[],L=S.length-1,M=r(S,h);let I=T[S[0]]<20?1:10,H=0;const G=(D,U)=>D===L?H:U;for(let D=0;D<=L;D++,I++){const U=S[D],F=D===L,[j,Z]=M[D],te=G(D,E[U]);if(H=te,R.push([j,Z,te]),F)break;const q=S[D+1],[X,ee]=M[D+1];if(q===-1){R.push([X,ee,H]);break}const le=(X-j)**2+(ee-Z)**2;if(le<=25&&S.length>=6)continue;const Y=G(D+1,E[q]),W=P[q]||te===Y,de=v+1/I+Math.max(v-I/100,0),me=Math.atan2(ee-Z,X-j),pe=Math.sin(me)*de,we=Math.cos(me)*de;if(I<10&&(le>64||le>36&&S.length<5)){const ke=(j*2+X)/3+-pe,He=(Z*2+ee)/3+we,Be=(j+X*2)/3+pe/2,Fe=(Z+ee*2)/3-we/2,[_,oe]=W?[te,te]:[(te*2+Y)/3,(te+Y*2)/3];R.push([ke,He,_],[Be,Fe,oe])}else if(le>25||S.length<6){const ke=(j+X)/2+-pe,He=(Z+ee)/2+we,Be=W?te:(te+Y)/2;R.push([ke,He,Be])}}return R},r=(S,h)=>{if(h)return h;const{p:v}=pack.cells;return S.map((E,P)=>E===-1?c(S[P-1]):v[E])},c=S=>{const[h,v]=pack.cells.p[S],E=Math.min(v,graphHeight-v,h,graphWidth-h);return E===v?[h,0]:E===graphHeight-v?[h,graphHeight]:E===h?[0,v]:[graphWidth,v]},A=[1,1,2,3,5,8,13,21,34].map(S=>S/200),u=De(A),C=(S,h,v,E=0)=>{const P=Math.min(S**.9/500,2),T=h*.005+(A[h]||u);return v*(T+P)+E},g=function(S,h,v=0){const E=[],P=[];for(let L=0;L<S.length;L++){const[M,I]=S[L-1]||S[L],[H,G,D]=S[L],[U,F]=S[L+1]||S[L],j=C(D,L,h,v),Z=Math.atan2(I-F,M-U),te=Math.sin(Z)*j,q=Math.cos(Z)*j;E.push([H-te,G+q]),P.push([H+te,G-q])}const T=lineGen(P.reverse());let R=lineGen(E);return R=R.substring(R.indexOf("C")),it(T+R,1)},p=function(){const S=pack.rivers;if(!!S.length)for(const h of S)h.basin=w(h.i),h.name=B(h.mouth),h.type=s(h)},B=function(S){return Names.getCulture(pack.cells.culture[S])},k={main:{big:{River:1},small:{Creek:9,River:3,Brook:3,Stream:1}},fork:{big:{Fork:1},small:{Branch:1}}};let d=null;const s=function({i:S,length:h,parent:v}){if(d===null){const T=Math.ceil(pack.rivers.length*.15);d=pack.rivers.map(R=>R.length||0).sort((R,L)=>R-L)[T]}const E=h<d,P=each(3)(S)&&v&&v!==S;return rw(k[P?"fork":"main"][E?"small":"big"])},o=S=>{const h=S.reduce((v,E,P,T)=>v+(P?Math.hypot(E[0]-T[P-1][0],E[1]-T[P-1][1]):0),0);return O(h,2)},l=S=>O((S/1.5)**1.8,2),a=function(S){const h=pack.cells,v=pack.rivers.filter(E=>E.i===S||E.parent===S||E.basin===S).map(E=>E.i);v.forEach(E=>rivers.select("#river"+E).remove()),h.r.forEach((E,P)=>{!E||!v.includes(E)||(h.r[P]=0,h.fl[P]=grid.cells.prec[h.g[P]],h.conf[P]=0)}),pack.rivers=pack.rivers.filter(E=>!v.includes(E.i))},w=function(S){var v;const h=(v=pack.rivers.find(E=>E.i===S))==null?void 0:v.parent;return!h||S===h?S:w(h)};return{generate:e,alterHeights:t,resolveDepressions:n,addMeandering:i,getRiverPath:g,specify:p,getName:B,getType:s,getBasin:w,getWidth:l,getOffset:C,getApproximateLength:o,getRiverPoints:r,remove:a}}();window.Lakes=function(){const e=function(m){const b=pack.cells,A=new Uint16Array(b.i.length);return pack.features.forEach(u=>{if(u.type!=="lake")return;u.flux=u.shoreline.reduce((p,B)=>p+grid.cells.prec[b.g[B]],0),u.temp=u.cells<6?grid.cells.temp[b.g[u.firstCell]]:O(d3.mean(u.shoreline.map(p=>grid.cells.temp[b.g[p]])),1);const C=(u.height-18)**heightExponentInput.value,g=(700*(u.temp+.006*C)/50+75)/(80-u.temp);u.evaporation=O(g*u.cells),!u.closed&&(u.outCell=u.shoreline[d3.scan(u.shoreline,(p,B)=>m[p]-m[B])],A[u.outCell]=u.i)}),A},t=function(m){const b=new Set;m.vertices.forEach(A=>pack.vertices.c[A].forEach(u=>pack.cells.h[u]>=20&&b.add(u))),m.shoreline=[...b]},n=m=>{const b=pack.cells,A=+document.getElementById("lakeElevationLimitOutput").value;pack.features.forEach(u=>{if(u.type!=="lake")return;delete u.flux,delete u.inlets,delete u.outlet,delete u.height,delete u.closed,!u.shoreline&&Lakes.getShoreline(u);const C=u.shoreline.sort((d,s)=>m[d]-m[s])[0];if(u.height=m[C]-.1,A===80){u.closed=!1;return}let g=!0;const p=u.height+A,B=[C],k=[];for(k[C]=!0;g&&B.length;){const d=B.pop();for(const s of b.c[d])if(!k[s]&&!(m[s]>=p)){if(m[s]<20){const o=pack.features[b.f[s]];if(o.type==="ocean"||u.height>o.height){g=!1;break}}k[s]=!0,B.push(s)}}u.closed=g})},i=function(){var m;for(const b of pack.features){if(b.type!=="lake")continue;delete b.river,delete b.enteringFlux,delete b.outCell,delete b.closed,b.height=O(b.height,3);const A=(m=b.inlets)==null?void 0:m.filter(C=>pack.rivers.find(g=>g.i===C));!A||!A.length?delete b.inlets:b.inlets=A,b.outlet&&pack.rivers.find(C=>C.i===b.outlet)||delete b.outlet}},r=function(){for(const m of pack.features){if(m.type!=="lake")continue;const b=lakes.select(`[data-f="${m.i}"]`).node();!b||(m.group=z(m),document.getElementById(m.group).appendChild(b))}},c=function(){Math.random=aleaPRNG(seed);for(const m of pack.features)m.type==="lake"&&(m.name=f(m))},f=function(m){const b=pack.cells.c[m.firstCell].find(u=>pack.cells.h[u]>=20),A=pack.cells.culture[b];return Names.getCulture(A)};function z(m){if(m.temp<-3)return"frozen";if(m.height>60&&m.cells<10&&m.firstCell%10===0)return"lava";if(!m.inlets&&!m.outlet){if(m.evaporation>m.flux*4)return"dry";if(m.cells<3&&m.firstCell%10===0)return"sinkhole"}return!m.outlet&&m.evaporation>m.flux?"salt":"freshwater"}return{setClimateData:e,cleanupLakeData:i,prepareLakeData:n,defineGroup:r,generateName:c,getName:f,getShoreline:t}}();const Je=ne("tooltip"),Tn={info:"linear-gradient(0.1turn, #ffffff00, #5e5c5c80, #ffffff00)",success:"linear-gradient(0.1turn, #ffffff00, #127912cc, #ffffff00)",warn:"linear-gradient(0.1turn, #ffffff00, #be5d08cc, #ffffff00)",error:"linear-gradient(0.1turn, #ffffff00, #e11d1dcc, #ffffff00)"};function se(e,t=!1,n="info",i=0){Je.textContent=e,Je.style.background=Tn[n],t&&(Je.dataset.main=e,Je.dataset.color=Je.style.background),i&&setTimeout(ct,i)}function ct(){Je.dataset.color="",Je.dataset.main="",Je.textContent=""}function Pn(){Je.style.background=Je.dataset.color||"",Je.textContent=Je.dataset.main||""}function Ut(e){if(!e.target)return;const t=e.target,{parentNode:n,dataset:i}=t,r=i.tip,c=n==null?void 0:n.dataset.tip;let f=r||c;!f||(i.shortcut&&!cn&&(f+=`. Shortcut: ${i.shortcut}`),se(f))}function Hn(){var e,t,n;(e=ne("dialogs"))==null||e.on("mousemove",Ut),(t=ne("optionsContainer"))==null||t.on("mousemove",Ut),(n=ne("exitCustomization"))==null||n.on("mousemove",Ut)}function Un(){document.querySelectorAll("[data-locked]").forEach(t=>{t.addEventListener("mouseover",Fn),t.on("click",Nn)})}function Nn(){const e=this.id.slice(5);(this.className==="icon-lock"?On:mt)(e)}const Kn="Click to lock the option and always use the current value on new map generation",Dn="Click to unlock the option and allow it to be randomized on new map generation";function Fn(e){e.stopPropagation();const n=this.className==="icon-lock"?Dn:Kn;se(n)}function mt(e){const t=document.querySelector('[data-stored="'+e+'"]');t&&!(t instanceof HTMLInputElement)&&pa(e,t.value);const n=document.getElementById("lock_"+e);n&&(n.dataset.locked="1",n.className="icon-lock")}function On(e){localStorage.removeItem(e);const t=document.getElementById("lock_"+e);t&&(t.dataset.locked="0",t.className="icon-lock-open")}function Ne(e){const t=document.getElementById("lock_"+e);return Boolean(t&&t.dataset.locked==="1")}const Gn="aeiouy\u0251'\u0259\xF8\u025B\u0153\xE6\u0276\u0252\u0268\u026A\u0254\u0250\u028A\u0264\u026F\u0430\u043E\u0438\u0435\u0451\u044D\u044B\u0443\u044E\u044F\xE0\xE8\xEC\xF2\xF9\u1EF3\u1E81\u0201\u0205\u0209\u020D\u0215\xE1\xE9\xED\xF3\xFA\xFD\u1E83\u0151\u0171\xE2\xEA\xEE\xF4\xFB\u0177\u0175\xE4\xEB\xEF\xF6\xFC\xFF\u1E85\xE3\u1EBD\u0129\xF5\u0169\u1EF9\u0105\u0119\u012F\u01EB\u0173\u0101\u0113\u012B\u014D\u016B\u0233\u0103\u0115\u012D\u014F\u016D\u01CE\u011B\u01D0\u01D2\u01D4\u0227\u0117\u022F\u1E8F\u1E87\u1EA1\u1EB9\u1ECB\u1ECD\u1EE5\u1EF5\u1E89\u1E1B\u1E2D\u1E75\u1E73";function Ze(e){return Gn.includes(e)}function Ke(e,t=3){for(;e.length>t&&e.length&&Ze(e.at(-1));)e=e.slice(0,-1);return e}const jn=[{name:"guo",probability:1,condition:new RegExp(" Guo$"),action:e=>e.slice(0,-4)},{name:"orszag",probability:1,condition:new RegExp("orszag$"),action:e=>e.length<9?e+"ian":e.slice(0,-6)},{name:"stan",probability:1,condition:new RegExp("stan$"),action:e=>e.length<9?e+"i":Ke(e.slice(0,-4))},{name:"land",probability:1,condition:new RegExp("land$"),action:e=>{if(e.length>9)return e.slice(0,-4);const t=Ke(e.slice(0,-4),0);return t.length<3?e+"ic":t.length<4?t+"lish":t+"ish"}},{name:"que",probability:1,condition:new RegExp("que$"),action:e=>e.replace(/que$/,"can")},{name:"a",probability:1,condition:new RegExp("a$"),action:e=>e+"n"},{name:"o",probability:1,condition:new RegExp("o$"),action:e=>e.replace(/o$/,"an")},{name:"u",probability:1,condition:new RegExp("u$"),action:e=>e+"an"},{name:"i",probability:1,condition:new RegExp("i$"),action:e=>e+"an"},{name:"e",probability:1,condition:new RegExp("e$"),action:e=>e+"an"},{name:"ay",probability:1,condition:new RegExp("ay$"),action:e=>e+"an"},{name:"os",probability:1,condition:new RegExp("os$"),action:e=>{const t=Ke(e.slice(0,-2),0);return t.length<4?e.slice(0,-1):t+"ian"}},{name:"es",probability:1,condition:new RegExp("es$"),action:e=>{const t=Ke(e.slice(0,-2),0);return t.length>7?e.slice(0,-1):t+"ian"}},{name:"l",probability:.8,condition:new RegExp("l$"),action:e=>e+"ese"},{name:"n",probability:.8,condition:new RegExp("n$"),action:e=>e+"ese"},{name:"ad",probability:.8,condition:new RegExp("ad$"),action:e=>e+"ian"},{name:"an",probability:.8,condition:new RegExp("an$"),action:e=>e+"ian"},{name:"ish",probability:.25,condition:new RegExp("^[a-zA-Z]{6}$"),action:e=>Ke(e.slice(0,-1))+"ish"},{name:"an",probability:.5,condition:new RegExp("^[a-zA-Z]{0-7}$"),action:e=>Ke(e)+"an"}];function We(e){for(const t of jn)if(V(t.probability)&&t.condition.test(e))return t.action(e);return e}const Wn=e=>e+(["st","nd","rd"][((e+90)%100-10)%10-1]||"th");function bt(e,t=[]){const i=e.replace("Old ","O ").replace(/[()]/g,"").split(" "),r=i.join("");let c=i.length===2?i[0][0]+i[1][0]:r.slice(0,2);for(let f=1;f<r.length-1&&t.includes(c);f++)c=r[0]+r[f].toUpperCase();return c}window.Names=function(){let e=[];const t=function(g){const p=[],B=g.split(",");for(const k of B){let d=k.trim().toLowerCase();const s=!/[^\u0000-\u007f]/.test(d);for(let o=-1,l="";o<d.length;o+=l.length||1,l=""){let a=d[o]||"",w=0;for(let S=o+1;d[S]&&l.length<5;S++){const h=d[S],v=d[S+1];if(l+=h,l===" "||l==="-"||!v||v===" "||v==="-")break;if(Ze(h)&&(w=1),!(h==="y"&&v==="e")&&!(s&&(h==="o"&&v==="o"||h==="e"&&v==="e"||h==="a"&&v==="e"||h==="c"&&v==="h"))&&(Ze(h)===v||w&&Ze(d[S+2])))break}p[a]===void 0&&(p[a]=[]),p[a].push(l)}}return p},n=g=>e[g]=nameBases[g]||nameBases[g].b?t(nameBases[g].b):null,i=()=>e=[],r=function(g,p,B,k){if(g===void 0){ERROR&&console.error("Please define a base");return}e[g]||n(g);const d=e[g];if(!d||d[""]===void 0)return se("Namesbase "+g+" is incorrect. Please check in namesbase editor",!1,"error"),ERROR&&console.error("Namebase "+g+" is incorrect!"),"ERROR";p||(p=nameBases[g].min),B||(B=nameBases[g].max),k!==""&&(k=nameBases[g].d);let s=d[""],o=ie(s),l="";for(let S=0;S<20;S++){if(o==="")if(l.length<p)o="",l="",s=d[""];else break;else if(l.length+o.length>B){l.length<p&&(l+=o);break}else s=d[De(o)]||d[""];l+=o,o=ie(s)}const a=De(l);(a==="'"||a===" "||a==="-")&&(l=l.slice(0,-1));let w=[...l].reduce(function(S,h,v,E){return h===E[v+1]&&!k.includes(h)?S:S.length?S.slice(-1)==="-"&&h===" "?S:S.slice(-1)===" "||S.slice(-1)==="-"?S+h.toUpperCase():h==="a"&&E[v+1]==="e"||v+2<E.length&&h===E[v+1]&&h===E[v+2]?S:S+h:h.toUpperCase()},"");return w.split(" ").some(S=>S.length<2)&&(w=w.split(" ").map((S,h)=>h?S.toLowerCase():S).join("")),w.length<2&&(ERROR&&console.error("Name is too short! Random name will be selected"),w=ie(nameBases[g].b.split(","))),w},c=function(g,p,B,k){if(g===void 0)return ERROR&&console.error("Please define a culture");const d=pack.cultures[g].base;return r(d,p,B,k)},f=function(g){return g===void 0?ERROR&&console.error("Please define a culture"):z(pack.cultures[g].base)},z=function(g){nameBases[g]===void 0&&(se(`Namebase ${g} does not exist. Please upload custom namebases of change the base in Cultures Editor`,!1,"error"),g=1);const p=nameBases[g].min-1,B=Math.max(nameBases[g].max-2,p);return r(g,p,B,"")},m=function(g,p,B){if(g===void 0)return ERROR&&console.error("Please define a base name");if(p===void 0&&B===void 0)return ERROR&&console.error("Please define a culture");if(B===void 0&&(B=pack.cultures[p].base),g.includes(" ")&&(g=ba(g.replace(/ /g,"").toLowerCase())),g.length>6&&g.slice(-4)==="berg"&&(g=g.slice(0,-4)),g.length>5&&g.slice(-3)==="ton"&&(g=g.slice(0,-3)),B===5&&["sk","ev","ov"].includes(g.slice(-2)))g=g.slice(0,-2);else{if(B===12)return Ze(g.slice(-1))?g:g+"u";B===18&&V(.4)&&(g=Ze(g.slice(0,1).toLowerCase())?"Al"+g.toLowerCase():"Al "+g)}if(B>32&&B<42)return g;if(g.length>3&&Ze(g.slice(-1)))if(Ze(g.slice(-2,-1))&&V(.85))g=g.slice(0,-2);else if(V(.7))g=g.slice(0,-1);else return g;else if(V(.4))return g;let k="ia";const d=Math.random(),s=g.length;return B===3&&d<.03&&s<7||B===4&&d<.03&&s<7||B===13&&d<.03&&s<7?k="terra":B===2&&d<.03&&s<7?k="terre":B===0&&d<.5&&s<7||B===1&&d<.4&&s<7||B===6&&d<.3&&s<7||B===32&&d<.1&&s<7?k="land":B===7&&d<.1?k="eia":B===9&&d<.35?k="maa":B===15&&d<.4&&s<6?k="orszag":B===16?k=d<.6?"stan":"ya":B===10?k="guk":B===11?k=" Guo":B===14?k=d<.5&&s<6?"tlan":"co":(B===17&&d<.8||B===18&&d<.8)&&(k="a"),b(g,k)};function b(g,p){if(g.slice(-1*p.length)===p)return g;const B=p.charAt(0);return g.slice(-1)===B&&(g=g.slice(0,-1)),Ze(B)===Ze(g.slice(-1))&&Ze(B)===Ze(g.slice(-2,-1))&&(g=g.slice(0,-1)),g.slice(-1)===B&&(g=g.slice(0,-1)),g+p}const A=function(g){if(!g&&Ne("mapName"))return;g&&Ne("mapName")&&unlock("mapName");const p=V(.7)?2:V(.5)?be(0,6):be(0,31);if(!nameBases[p])return se("Namebase is not found",!1,"error"),"";const B=nameBases[p].min-1,k=Math.max(nameBases[p].max-3,B),d=r(p,B,k,""),s=V(.7)?u(d):d;mapName.value=s};function u(g){const p=V(.8)?"ia":"land";return p==="ia"&&g.length>6?g=g.slice(0,-(g.length-3)):p==="land"&&g.length>6&&(g=g.slice(0,-(g.length-5))),b(g,p)}return{getBase:r,getCulture:c,getCultureShort:f,getBaseShort:z,getState:m,updateChain:n,clearChains:i,getNameBases:function(){return[{name:"German",i:0,min:5,max:12,d:"lt",m:0,b:"Achern,Aichhalden,Aitern,Albbruck,Alpirsbach,Altensteig,Althengstett,Appenweier,Auggen,Wildbad,Badenen,Badenweiler,Baiersbronn,Ballrechten,Bellingen,Berghaupten,Bernau,Biberach,Biederbach,Binzen,Birkendorf,Birkenfeld,Bischweier,Blumberg,Bollen,Bollschweil,Bonndorf,Bosingen,Braunlingen,Breisach,Breisgau,Breitnau,Brigachtal,Buchenbach,Buggingen,Buhl,Buhlertal,Calw,Dachsberg,Dobel,Donaueschingen,Dornhan,Dornstetten,Dottingen,Dunningen,Durbach,Durrheim,Ebhausen,Ebringen,Efringen,Egenhausen,Ehrenkirchen,Ehrsberg,Eimeldingen,Eisenbach,Elzach,Elztal,Emmendingen,Endingen,Engelsbrand,Enz,Enzklosterle,Eschbronn,Ettenheim,Ettlingen,Feldberg,Fischerbach,Fischingen,Fluorn,Forbach,Freiamt,Freiburg,Freudenstadt,Friedenweiler,Friesenheim,Frohnd,Furtwangen,Gaggenau,Geisingen,Gengenbach,Gernsbach,Glatt,Glatten,Glottertal,Gorwihl,Gottenheim,Grafenhausen,Grenzach,Griesbach,Gutach,Gutenbach,Hag,Haiterbach,Hardt,Harmersbach,Hasel,Haslach,Hausach,Hausen,Hausern,Heitersheim,Herbolzheim,Herrenalb,Herrischried,Hinterzarten,Hochenschwand,Hofen,Hofstetten,Hohberg,Horb,Horben,Hornberg,Hufingen,Ibach,Ihringen,Inzlingen,Kandern,Kappel,Kappelrodeck,Karlsbad,Karlsruhe,Kehl,Keltern,Kippenheim,Kirchzarten,Konigsfeld,Krozingen,Kuppenheim,Kussaberg,Lahr,Lauchringen,Lauf,Laufenburg,Lautenbach,Lauterbach,Lenzkirch,Liebenzell,Loffenau,Loffingen,Lorrach,Lossburg,Mahlberg,Malsburg,Malsch,March,Marxzell,Marzell,Maulburg,Monchweiler,Muhlenbach,Mullheim,Munstertal,Murg,Nagold,Neubulach,Neuenburg,Neuhausen,Neuried,Neuweiler,Niedereschach,Nordrach,Oberharmersbach,Oberkirch,Oberndorf,Oberbach,Oberried,Oberwolfach,Offenburg,Ohlsbach,Oppenau,Ortenberg,otigheim,Ottenhofen,Ottersweier,Peterstal,Pfaffenweiler,Pfalzgrafenweiler,Pforzheim,Rastatt,Renchen,Rheinau,Rheinfelden,Rheinmunster,Rickenbach,Rippoldsau,Rohrdorf,Rottweil,Rummingen,Rust,Sackingen,Sasbach,Sasbachwalden,Schallbach,Schallstadt,Schapbach,Schenkenzell,Schiltach,Schliengen,Schluchsee,Schomberg,Schonach,Schonau,Schonenberg,Schonwald,Schopfheim,Schopfloch,Schramberg,Schuttertal,Schwenningen,Schworstadt,Seebach,Seelbach,Seewald,Sexau,Simmersfeld,Simonswald,Sinzheim,Solden,Staufen,Stegen,Steinach,Steinen,Steinmauern,Straubenhardt,Stuhlingen,Sulz,Sulzburg,Teinach,Tiefenbronn,Tiengen,Titisee,Todtmoos,Todtnau,Todtnauberg,Triberg,Tunau,Tuningen,uhlingen,Unterkirnach,Reichenbach,Utzenfeld,Villingen,Villingendorf,Vogtsburg,Vohrenbach,Waldachtal,Waldbronn,Waldkirch,Waldshut,Wehr,Weil,Weilheim,Weisenbach,Wembach,Wieden,Wiesental,Wildberg,Winzeln,Wittlingen,Wittnau,Wolfach,Wutach,Wutoschingen,Wyhlen,Zavelstein"},{name:"English",i:1,min:6,max:11,d:"",m:.1,b:"Abingdon,Albrighton,Alcester,Almondbury,Altrincham,Amersham,Andover,Appleby,Ashboume,Atherstone,Aveton,Axbridge,Aylesbury,Baldock,Bamburgh,Barton,Basingstoke,Berden,Bere,Berkeley,Berwick,Betley,Bideford,Bingley,Birmingham,Blandford,Blechingley,Bodmin,Bolton,Bootham,Boroughbridge,Boscastle,Bossinney,Bramber,Brampton,Brasted,Bretford,Bridgetown,Bridlington,Bromyard,Bruton,Buckingham,Bungay,Burton,Calne,Cambridge,Canterbury,Carlisle,Castleton,Caus,Charmouth,Chawleigh,Chichester,Chillington,Chinnor,Chipping,Chisbury,Cleobury,Clifford,Clifton,Clitheroe,Cockermouth,Coleshill,Combe,Congleton,Crafthole,Crediton,Cuddenbeck,Dalton,Darlington,Dodbrooke,Drax,Dudley,Dunstable,Dunster,Dunwich,Durham,Dymock,Exeter,Exning,Faringdon,Felton,Fenny,Finedon,Flookburgh,Fowey,Frampton,Gateshead,Gatton,Godmanchester,Grampound,Grantham,Guildford,Halesowen,Halton,Harbottle,Harlow,Hatfield,Hatherleigh,Haydon,Helston,Henley,Hertford,Heytesbury,Hinckley,Hitchin,Holme,Hornby,Horsham,Kendal,Kenilworth,Kilkhampton,Kineton,Kington,Kinver,Kirby,Knaresborough,Knutsford,Launceston,Leighton,Lewes,Linton,Louth,Luton,Lyme,Lympstone,Macclesfield,Madeley,Malborough,Maldon,Manchester,Manningtree,Marazion,Marlborough,Marshfield,Mere,Merryfield,Middlewich,Midhurst,Milborne,Mitford,Modbury,Montacute,Mousehole,Newbiggin,Newborough,Newbury,Newenden,Newent,Norham,Northleach,Noss,Oakham,Olney,Orford,Ormskirk,Oswestry,Padstow,Paignton,Penkneth,Penrith,Penzance,Pershore,Petersfield,Pevensey,Pickering,Pilton,Pontefract,Portsmouth,Preston,Quatford,Reading,Redcliff,Retford,Rockingham,Romney,Rothbury,Rothwell,Salisbury,Saltash,Seaford,Seasalter,Sherston,Shifnal,Shoreham,Sidmouth,Skipsea,Skipton,Solihull,Somerton,Southam,Southwark,Standon,Stansted,Stapleton,Stottesdon,Sudbury,Swavesey,Tamerton,Tarporley,Tetbury,Thatcham,Thaxted,Thetford,Thornbury,Tintagel,Tiverton,Torksey,Totnes,Towcester,Tregoney,Trematon,Tutbury,Uxbridge,Wallingford,Wareham,Warenmouth,Wargrave,Warton,Watchet,Watford,Wendover,Westbury,Westcheap,Weymouth,Whitford,Wickwar,Wigan,Wigmore,Winchelsea,Winkleigh,Wiscombe,Witham,Witheridge,Wiveliscombe,Woodbury,Yeovil"},{name:"French",i:2,min:5,max:13,d:"nlrs",m:.1,b:"Adon,Aillant,Amilly,Andonville,Ardon,Artenay,Ascheres,Ascoux,Attray,Aubin,Audeville,Aulnay,Autruy,Auvilliers,Auxy,Aveyron,Baccon,Bardon,Barville,Batilly,Baule,Bazoches,Beauchamps,Beaugency,Beaulieu,Beaune,Bellegarde,Boesses,Boigny,Boiscommun,Boismorand,Boisseaux,Bondaroy,Bonnee,Bonny,Bordes,Bou,Bougy,Bouilly,Boulay,Bouzonville,Bouzy,Boynes,Bray,Breteau,Briare,Briarres,Bricy,Bromeilles,Bucy,Cepoy,Cercottes,Cerdon,Cernoy,Cesarville,Chailly,Chaingy,Chalette,Chambon,Champoulet,Chanteau,Chantecoq,Chapell,Charme,Charmont,Charsonville,Chateau,Chateauneuf,Chatel,Chatenoy,Chatillon,Chaussy,Checy,Chevannes,Chevillon,Chevilly,Chevry,Chilleurs,Choux,Chuelles,Clery,Coinces,Coligny,Combleux,Combreux,Conflans,Corbeilles,Corquilleroy,Cortrat,Coudroy,Coullons,Coulmiers,Courcelles,Courcy,Courtemaux,Courtempierre,Courtenay,Cravant,Crottes,Dadonville,Dammarie,Dampierre,Darvoy,Desmonts,Dimancheville,Donnery,Dordives,Dossainville,Douchy,Dry,Echilleuses,Egry,Engenville,Epieds,Erceville,Ervauville,Escrennes,Escrignelles,Estouy,Faverelles,Fay,Feins,Ferolles,Ferrieres,Fleury,Fontenay,Foret,Foucherolles,Freville,Gatinais,Gaubertin,Gemigny,Germigny,Gidy,Gien,Girolles,Givraines,Gondreville,Grangermont,Greneville,Griselles,Guigneville,Guilly,Gyleslonains,Huetre,Huisseau,Ingrannes,Ingre,Intville,Isdes,Jargeau,Jouy,Juranville,Bussiere,Laas,Ladon,Lailly,Langesse,Leouville,Ligny,Lombreuil,Lorcy,Lorris,Loury,Louzouer,Malesherbois,Marcilly,Mardie,Mareau,Marigny,Marsainvilliers,Melleroy,Menestreau,Merinville,Messas,Meung,Mezieres,Migneres,Mignerette,Mirabeau,Montargis,Montbarrois,Montbouy,Montcresson,Montereau,Montigny,Montliard,Mormant,Morville,Moulinet,Moulon,Nancray,Nargis,Nesploy,Neuville,Neuvy,Nevoy,Nibelle,Nogent,Noyers,Ocre,Oison,Olivet,Ondreville,Onzerain,Orleans,Ormes,Orville,Oussoy,Outarville,Ouzouer,Pannecieres,Pannes,Patay,Paucourt,Pers,Pierrefitte,Pithiverais,Pithiviers,Poilly,Potier,Prefontaines,Presnoy,Pressigny,Puiseaux,Quiers,Ramoulu,Rebrechien,Rouvray,Rozieres,Rozoy,Ruan,Sandillon,Santeau,Saran,Sceaux,Seichebrieres,Semoy,Sennely,Sermaises,Sigloy,Solterre,Sougy,Sully,Sury,Tavers,Thignonville,Thimory,Thorailles,Thou,Tigy,Tivernon,Tournoisis,Trainou,Treilles,Trigueres,Trinay,Vannes,Varennes,Vennecy,Vieilles,Vienne,Viglain,Vignes,Villamblain,Villemandeur,Villemoutiers,Villemurlin,Villeneuve,Villereau,Villevoques,Villorceau,Vimory,Vitry,Vrigny,Ivre"},{name:"Italian",i:3,min:5,max:12,d:"cltr",m:.1,b:"Accumoli,Acquafondata,Acquapendente,Acuto,Affile,Agosta,Alatri,Albano,Allumiere,Alvito,Amaseno,Amatrice,Anagni,Anguillara,Anticoli,Antrodoco,Anzio,Aprilia,Aquino,Arce,Arcinazzo,Ardea,Ariccia,Arlena,Arnara,Arpino,Arsoli,Artena,Ascrea,Atina,Ausonia,Bagnoregio,Barbarano,Bassano,Bassiano,Bellegra,Belmonte,Blera,Bolsena,Bomarzo,Borbona,Borgo,Borgorose,Boville,Bracciano,Broccostella,Calcata,Camerata,Campagnano,Campodimele,Campoli,Canale,Canepina,Canino,Cantalice,Cantalupo,Canterano,Capena,Capodimonte,Capranica,Caprarola,Carbognano,Casalattico,Casalvieri,Casape,Casaprota,Casperia,Cassino,Castelforte,Castelliri,Castello,Castelnuovo,Castiglione,Castro,Castrocielo,Cave,Ceccano,Celleno,Cellere,Ceprano,Cerreto,Cervara,Cervaro,Cerveteri,Ciampino,Ciciliano,Cineto,Cisterna,Cittaducale,Cittareale,Civita,Civitavecchia,Civitella,Colfelice,Collalto,Colle,Colleferro,Collegiove,Collepardo,Collevecchio,Colli,Colonna,Concerviano,Configni,Contigliano,Corchiano,Coreno,Cori,Cottanello,Esperia,Fabrica,Faleria,Fara,Farnese,Ferentino,Fiamignano,Fiano,Filacciano,Filettino,Fiuggi,Fiumicino,Fondi,Fontana,Fonte,Fontechiari,Forano,Formello,Formia,Frascati,Frasso,Frosinone,Fumone,Gaeta,Gallese,Gallicano,Gallinaro,Gavignano,Genazzano,Genzano,Gerano,Giuliano,Gorga,Gradoli,Graffignano,Greccio,Grottaferrata,Grotte,Guarcino,Guidonia,Ischia,Isola,Itri,Jenne,Labico,Labro,Ladispoli,Lanuvio,Lariano,Latera,Lenola,Leonessa,Licenza,Longone,Lubriano,Maenza,Magliano,Mandela,Manziana,Marano,Marcellina,Marcetelli,Marino,Marta,Mazzano,Mentana,Micigliano,Minturno,Mompeo,Montalto,Montasola,Monte,Montebuono,Montefiascone,Monteflavio,Montelanico,Monteleone,Montelibretti,Montenero,Monterosi,Monterotondo,Montopoli,Montorio,Moricone,Morlupo,Morolo,Morro,Nazzano,Nemi,Nepi,Nerola,Nespolo,Nettuno,Norma,Olevano,Onano,Oriolo,Orte,Orvinio,Paganico,Palestrina,Paliano,Palombara,Pastena,Patrica,Percile,Pescorocchiano,Pescosolido,Petrella,Piansano,Picinisco,Pico,Piedimonte,Piglio,Pignataro,Pisoniano,Pofi,Poggio,Poli,Pomezia,Pontecorvo,Pontinia,Ponza,Ponzano,Posta,Pozzaglia,Priverno,Proceno,Prossedi,Riano,Rieti,Rignano,Riofreddo,Ripi,Rivodutri,Rocca,Roccagiovine,Roccagorga,Roccantica,Roccasecca,Roiate,Ronciglione,Roviano,Sabaudia,Sacrofano,Salisano,Sambuci,Santa,Santi,Santopadre,Saracinesco,Scandriglia,Segni,Selci,Sermoneta,Serrone,Settefrati,Sezze,Sgurgola,Sonnino,Sora,Soriano,Sperlonga,Spigno,Stimigliano,Strangolagalli,Subiaco,Supino,Sutri,Tarano,Tarquinia,Terelle,Terracina,Tessennano,Tivoli,Toffia,Tolfa,Torre,Torri,Torrice,Torricella,Torrita,Trevi,Trevignano,Trivigliano,Turania,Tuscania,Vacone,Valentano,Vallecorsa,Vallemaio,Vallepietra,Vallerano,Vallerotonda,Vallinfreda,Valmontone,Varco,Vasanello,Vejano,Velletri,Ventotene,Veroli,Vetralla,Vicalvi,Vico,Vicovaro,Vignanello,Viterbo,Viticuso,Vitorchiano,Vivaro,Zagarolo"},{name:"Castillian",i:4,min:5,max:11,d:"lr",m:0,b:"Abanades,Ablanque,Adobes,Ajofrin,Alameda,Alaminos,Alarilla,Albalate,Albares,Albarreal,Albendiego,Alcabon,Alcanizo,Alcaudete,Alcocer,Alcolea,Alcoroches,Aldea,Aldeanueva,Algar,Algora,Alhondiga,Alique,Almadrones,Almendral,Almoguera,Almonacid,Almorox,Alocen,Alovera,Alustante,Angon,Anguita,Anover,Anquela,Arbancon,Arbeteta,Arcicollar,Argecilla,Arges,Armallones,Armuna,Arroyo,Atanzon,Atienza,Aunon,Azuqueca,Azutan,Baides,Banos,Banuelos,Barcience,Bargas,Barriopedro,Belvis,Berninches,Borox,Brihuega,Budia,Buenaventura,Bujalaro,Burguillos,Burujon,Bustares,Cabanas,Cabanillas,Calera,Caleruela,Calzada,Camarena,Campillo,Camunas,Canizar,Canredondo,Cantalojas,Cardiel,Carmena,Carranque,Carriches,Casa,Casarrubios,Casas,Casasbuenas,Caspuenas,Castejon,Castellar,Castilforte,Castillo,Castilnuevo,Cazalegas,Cebolla,Cedillo,Cendejas,Centenera,Cervera,Checa,Chequilla,Chillaron,Chiloeches,Chozas,Chueca,Cifuentes,Cincovillas,Ciruelas,Ciruelos,Cobeja,Cobeta,Cobisa,Cogollor,Cogolludo,Condemios,Congostrina,Consuegra,Copernal,Corduente,Corral,Cuerva,Domingo,Dosbarrios,Driebes,Duron,El,Embid,Erustes,Escalona,Escalonilla,Escamilla,Escariche,Escopete,Espinosa,Espinoso,Esplegares,Esquivias,Estables,Estriegana,Fontanar,Fuembellida,Fuensalida,Fuentelsaz,Gajanejos,Galve,Galvez,Garciotum,Gascuena,Gerindote,Guadamur,Henche,Heras,Herreria,Herreruela,Hijes,Hinojosa,Hita,Hombrados,Hontanar,Hontoba,Horche,Hormigos,Huecas,Huermeces,Huerta,Hueva,Humanes,Illan,Illana,Illescas,Iniestola,Irueste,Jadraque,Jirueque,Lagartera,Las,Layos,Ledanca,Lillo,Lominchar,Loranca,Los,Lucillos,Lupiana,Luzaga,Luzon,Madridejos,Magan,Majaelrayo,Malaga,Malaguilla,Malpica,Mandayona,Mantiel,Manzaneque,Maqueda,Maranchon,Marchamalo,Marjaliza,Marrupe,Mascaraque,Masegoso,Matarrubia,Matillas,Mazarete,Mazuecos,Medranda,Megina,Mejorada,Mentrida,Mesegar,Miedes,Miguel,Millana,Milmarcos,Mirabueno,Miralrio,Mocejon,Mochales,Mohedas,Molina,Monasterio,Mondejar,Montarron,Mora,Moratilla,Morenilla,Muduex,Nambroca,Navalcan,Negredo,Noblejas,Noez,Nombela,Noves,Numancia,Nuno,Ocana,Ocentejo,Olias,Olmeda,Ontigola,Orea,Orgaz,Oropesa,Otero,Palmaces,Palomeque,Pantoja,Pardos,Paredes,Pareja,Parrillas,Pastrana,Pelahustan,Penalen,Penalver,Pepino,Peralejos,Peralveche,Pinilla,Pioz,Piqueras,Polan,Portillo,Poveda,Pozo,Pradena,Prados,Puebla,Puerto,Pulgar,Quer,Quero,Quintanar,Quismondo,Rebollosa,Recas,Renera,Retamoso,Retiendas,Riba,Rielves,Rillo,Riofrio,Robledillo,Robledo,Romanillos,Romanones,Rueda,Sacecorbo,Sacedon,Saelices,Salmeron,San,Santa,Santiuste,Santo,Sartajada,Sauca,Sayaton,Segurilla,Selas,Semillas,Sesena,Setiles,Sevilleja,Sienes,Siguenza,Solanillos,Somolinos,Sonseca,Sotillo,Sotodasos,Talavera,Tamajon,Taragudo,Taravilla,Tartanedo,Tembleque,Tendilla,Terzaga,Tierzo,Tordellego,Tordelrabano,Tordesilos,Torija,Torralba,Torre,Torrecilla,Torrecuadrada,Torrejon,Torremocha,Torrico,Torrijos,Torrubia,Tortola,Tortuera,Tortuero,Totanes,Traid,Trijueque,Trillo,Turleque,Uceda,Ugena,Ujados,Urda,Utande,Valdarachas,Valdesotos,Valhermoso,Valtablado,Valverde,Velada,Viana,Vinuelas,Yebes,Yebra,Yelamos,Yeles,Yepes,Yuncler,Yunclillos,Yuncos,Yunquera,Zaorejas,Zarzuela,Zorita"},{name:"Ruthenian",i:5,min:5,max:10,d:"",m:0,b:"Belgorod,Beloberezhye,Belyi,Belz,Berestiy,Berezhets,Berezovets,Berezutsk,Bobruisk,Bolonets,Borisov,Borovsk,Bozhesk,Bratslav,Bryansk,Brynsk,Buryn,Byhov,Chechersk,Chemesov,Cheremosh,Cherlen,Chern,Chernigov,Chernitsa,Chernobyl,Chernogorod,Chertoryesk,Chetvertnia,Demyansk,Derevesk,Devyagoresk,Dichin,Dmitrov,Dorogobuch,Dorogobuzh,Drestvin,Drokov,Drutsk,Dubechin,Dubichi,Dubki,Dubkov,Dveren,Galich,Glebovo,Glinsk,Goloty,Gomiy,Gorodets,Gorodische,Gorodno,Gorohovets,Goroshin,Gorval,Goryshon,Holm,Horobor,Hoten,Hotin,Hotmyzhsk,Ilovech,Ivan,Izborsk,Izheslavl,Kamenets,Kanev,Karachev,Karna,Kavarna,Klechesk,Klyapech,Kolomyya,Kolyvan,Kopyl,Korec,Kornik,Korochunov,Korshev,Korsun,Koshkin,Kotelno,Kovyla,Kozelsk,Kozelsk,Kremenets,Krichev,Krylatsk,Ksniatin,Kulatsk,Kursk,Kursk,Lebedev,Lida,Logosko,Lomihvost,Loshesk,Loshichi,Lubech,Lubno,Lubutsk,Lutsk,Luchin,Luki,Lukoml,Luzha,Lvov,Mtsensk,Mdin,Medniki,Melecha,Merech,Meretsk,Mescherskoe,Meshkovsk,Metlitsk,Mezetsk,Mglin,Mihailov,Mikitin,Mikulino,Miloslavichi,Mogilev,Mologa,Moreva,Mosalsk,Moschiny,Mozyr,Mstislav,Mstislavets,Muravin,Nemech,Nemiza,Nerinsk,Nichan,Novgorod,Novogorodok,Obolichi,Obolensk,Obolensk,Oleshsk,Olgov,Omelnik,Opoka,Opoki,Oreshek,Orlets,Osechen,Oster,Ostrog,Ostrov,Perelai,Peremil,Peremyshl,Pererov,Peresechen,Perevitsk,Pereyaslav,Pinsk,Ples,Polotsk,Pronsk,Proposhesk,Punia,Putivl,Rechitsa,Rodno,Rogachev,Romanov,Romny,Roslavl,Rostislavl,Rostovets,Rsha,Ruza,Rybchesk,Rylsk,Rzhavesk,Rzhev,Rzhischev,Sambor,Serensk,Serensk,Serpeysk,Shilov,Shuya,Sinech,Sizhka,Skala,Slovensk,Slutsk,Smedin,Sneporod,Snitin,Snovsk,Sochevo,Sokolec,Starica,Starodub,Stepan,Sterzh,Streshin,Sutesk,Svinetsk,Svisloch,Terebovl,Ternov,Teshilov,Teterin,Tiversk,Torchevsk,Toropets,Torzhok,Tripolye,Trubchevsk,Tur,Turov,Usvyaty,Uteshkov,Vasilkov,Velil,Velye,Venev,Venicha,Verderev,Vereya,Veveresk,Viazma,Vidbesk,Vidychev,Voino,Volodimer,Volok,Volyn,Vorobesk,Voronich,Voronok,Vorotynsk,Vrev,Vruchiy,Vselug,Vyatichsk,Vyatka,Vyshegorod,Vyshgorod,Vysokoe,Yagniatin,Yaropolch,Yasenets,Yuryev,Yuryevets,Zaraysk,Zhitomel,Zholvazh,Zizhech,Zubkov,Zudechev,Zvenigorod"},{name:"Nordic",i:6,min:6,max:10,d:"kln",m:.1,b:"Akureyri,Aldra,Alftanes,Andenes,Austbo,Auvog,Bakkafjordur,Ballangen,Bardal,Beisfjord,Bifrost,Bildudalur,Bjerka,Bjerkvik,Bjorkosen,Bliksvaer,Blokken,Blonduos,Bolga,Bolungarvik,Borg,Borgarnes,Bosmoen,Bostad,Bostrand,Botsvika,Brautarholt,Breiddalsvik,Bringsli,Brunahlid,Budardalur,Byggdakjarni,Dalvik,Djupivogur,Donnes,Drageid,Drangsnes,Egilsstadir,Eiteroga,Elvenes,Engavogen,Ertenvog,Eskifjordur,Evenes,Eyrarbakki,Fagernes,Fallmoen,Fellabaer,Fenes,Finnoya,Fjaer,Fjelldal,Flakstad,Flateyri,Flostrand,Fludir,Gardaber,Gardur,Gimstad,Givaer,Gjeroy,Gladstad,Godoya,Godoynes,Granmoen,Gravdal,Grenivik,Grimsey,Grindavik,Grytting,Hafnir,Halsa,Hauganes,Haugland,Hauknes,Hella,Helland,Hellissandur,Hestad,Higrav,Hnifsdalur,Hofn,Hofsos,Holand,Holar,Holen,Holkestad,Holmavik,Hopen,Hovden,Hrafnagil,Hrisey,Husavik,Husvik,Hvammstangi,Hvanneyri,Hveragerdi,Hvolsvollur,Igeroy,Indre,Inndyr,Innhavet,Innes,Isafjordur,Jarklaustur,Jarnsreykir,Junkerdal,Kaldvog,Kanstad,Karlsoy,Kavosen,Keflavik,Kjelde,Kjerstad,Klakk,Kopasker,Kopavogur,Korgen,Kristnes,Krutoga,Krystad,Kvina,Lande,Laugar,Laugaras,Laugarbakki,Laugarvatn,Laupstad,Leines,Leira,Leiren,Leland,Lenvika,Loding,Lodingen,Lonsbakki,Lopsmarka,Lovund,Luroy,Maela,Melahverfi,Meloy,Mevik,Misvaer,Mornes,Mosfellsber,Moskenes,Myken,Naurstad,Nesberg,Nesjahverfi,Nesset,Nevernes,Obygda,Ofoten,Ogskardet,Okervika,Oknes,Olafsfjordur,Oldervika,Olstad,Onstad,Oppeid,Oresvika,Orsnes,Orsvog,Osmyra,Overdal,Prestoya,Raudalaekur,Raufarhofn,Reipo,Reykholar,Reykholt,Reykjahlid,Rif,Rinoya,Rodoy,Rognan,Rosvika,Rovika,Salhus,Sanden,Sandgerdi,Sandoker,Sandset,Sandvika,Saudarkrokur,Selfoss,Selsoya,Sennesvik,Setso,Siglufjordur,Silvalen,Skagastrond,Skjerstad,Skonland,Skorvogen,Skrova,Sleneset,Snubba,Softing,Solheim,Solheimar,Sorarnoy,Sorfugloy,Sorland,Sormela,Sorvaer,Sovika,Stamsund,Stamsvika,Stave,Stokka,Stokkseyri,Storjord,Storo,Storvika,Strand,Straumen,Strendene,Sudavik,Sudureyri,Sundoya,Sydalen,Thingeyri,Thorlakshofn,Thorshofn,Tjarnabyggd,Tjotta,Tosbotn,Traelnes,Trofors,Trones,Tverro,Ulvsvog,Unnstad,Utskor,Valla,Vandved,Varmahlid,Vassos,Vevelstad,Vidrek,Vik,Vikholmen,Vogar,Vogehamn,Vopnafjordur"},{name:"Greek",i:7,min:5,max:11,d:"s",m:.1,b:"Abdera,Abila,Abydos,Acanthus,Acharnae,Actium,Adramyttium,Aegae,Aegina,Aegium,Aenus,Agrinion,Aigosthena,Akragas,Akrai,Akrillai,Akroinon,Akrotiri,Alalia,Alexandreia,Alexandretta,Alexandria,Alinda,Amarynthos,Amaseia,Ambracia,Amida,Amisos,Amnisos,Amphicaea,Amphigeneia,Amphipolis,Amphissa,Ankon,Antigona,Antipatrea,Antioch,Antioch,Antiochia,Andros,Apamea,Aphidnae,Apollonia,Argos,Arsuf,Artanes,Artemita,Argyroupoli,Asine,Asklepios,Aspendos,Assus,Astacus,Athenai,Athmonia,Aytos,Ancient,Baris,Bhrytos,Borysthenes,Berge,Boura,Bouthroton,Brauron,Byblos,Byllis,Byzantium,Bythinion,Callipolis,Cebrene,Chalcedon,Calydon,Carystus,Chamaizi,Chalcis,Chersonesos,Chios,Chytri,Clazomenae,Cleonae,Cnidus,Colosse,Corcyra,Croton,Cyme,Cyrene,Cythera,Decelea,Delos,Delphi,Demetrias,Dicaearchia,Dimale,Didyma,Dion,Dioscurias,Dodona,Dorylaion,Dyme,Edessa,Elateia,Eleusis,Eleutherna,Emporion,Ephesus,Ephyra,Epidamnos,Epidauros,Eresos,Eretria,Erythrae,Eubea,Gangra,Gaza,Gela,Golgi,Gonnos,Gorgippia,Gournia,Gortyn,Gythium,Hagios,Hagia,Halicarnassus,Halieis,Helike,Heliopolis,Hellespontos,Helorus,Hemeroskopeion,Heraclea,Hermione,Hermonassa,Hierapetra,Hierapolis,Himera,Histria,Hubla,Hyele,Ialysos,Iasus,Idalium,Imbros,Iolcus,Itanos,Ithaca,Juktas,Kallipolis,Kamares,Kameiros,Kannia,Kamarina,Kasmenai,Katane,Kerkinitida,Kepoi,Kimmerikon,Kios,Klazomenai,Knidos,Knossos,Korinthos,Kos,Kourion,Kume,Kydonia,Kynos,Kyrenia,Lamia,Lampsacus,Laodicea,Lapithos,Larissa,Lato,Laus,Lebena,Lefkada,Lekhaion,Leibethra,Leontinoi,Lepreum,Lessa,Lilaea,Lindus,Lissus,Epizephyrian,Madytos,Magnesia,Mallia,Mantineia,Marathon,Marmara,Maroneia,Masis,Massalia,Megalopolis,Megara,Mesembria,Messene,Metapontum,Methana,Methone,Methumna,Miletos,Misenum,Mochlos,Monastiraki,Morgantina,Mulai,Mukenai,Mylasa,Myndus,Myonia,Myra,Myrmekion,Mutilene,Myos,Nauplios,Naucratis,Naupactus,Naxos,Neapoli,Neapolis,Nemea,Nicaea,Nicopolis,Nirou,Nymphaion,Nysa,Oenoe,Oenus,Odessos,Olbia,Olous,Olympia,Olynthus,Opus,Orchomenus,Oricos,Orestias,Oreus,Oropus,Onchesmos,Pactye,Pagasae,Palaikastro,Pandosia,Panticapaeum,Paphos,Parium,Paros,Parthenope,Patrae,Pavlopetri,Pegai,Pelion,Peiraies,Pella,Percote,Pergamum,Petsofa,Phaistos,Phaleron,Phanagoria,Pharae,Pharnacia,Pharos,Phaselis,Philippi,Pithekussa,Philippopolis,Platanos,Phlius,Pherae,Phocaea,Pinara,Pisa,Pitane,Pitiunt,Pixous,Plataea,Poseidonia,Potidaea,Priapus,Priene,Prousa,Pseira,Psychro,Pteleum,Pydna,Pylos,Pyrgos,Rhamnus,Rhegion,Rhithymna,Rhodes,Rhypes,Rizinia,Salamis,Same,Samos,Scyllaeum,Selinus,Seleucia,Semasus,Sestos,Scidrus,Sicyon,Side,Sidon,Siteia,Sinope,Siris,Sklavokampos,Smyrna,Soli,Sozopolis,Sparta,Stagirus,Stratos,Stymphalos,Sybaris,Surakousai,Taras,Tanagra,Tanais,Tauromenion,Tegea,Temnos,Tenedos,Tenea,Teos,Thapsos,Thassos,Thebai,Theodosia,Therma,Thespiae,Thronion,Thoricus,Thurii,Thyreum,Thyria,Tiruns,Tithoraea,Tomis,Tragurion,Trapeze,Trapezus,Tripolis,Troizen,Troliton,Troy,Tylissos,Tyras,Tyros,Tyritake,Vasiliki,Vathypetros,Zakynthos,Zakros,Zankle"},{name:"Roman",i:8,min:6,max:11,d:"ln",m:.1,b:"Abila,Adflexum,Adnicrem,Aelia,Aelius,Aeminium,Aequum,Agrippina,Agrippinae,Ala,Albanianis,Ambianum,Andautonia,Apulum,Aquae,Aquaegranni,Aquensis,Aquileia,Aquincum,Arae,Argentoratum,Ariminum,Ascrivium,Atrebatum,Atuatuca,Augusta,Aurelia,Aurelianorum,Batavar,Batavorum,Belum,Biriciana,Blestium,Bonames,Bonna,Bononia,Borbetomagus,Bovium,Bracara,Brigantium,Burgodunum,Caesaraugusta,Caesarea,Caesaromagus,Calleva,Camulodunum,Cannstatt,Cantiacorum,Capitolina,Castellum,Castra,Castrum,Cibalae,Clausentum,Colonia,Concangis,Condate,Confluentes,Conimbriga,Corduba,Coria,Corieltauvorum,Corinium,Coriovallum,Cornoviorum,Danum,Deva,Divodurum,Dobunnorum,Drusi,Dubris,Dumnoniorum,Durnovaria,Durocobrivis,Durocornovium,Duroliponte,Durovernum,Durovigutum,Eboracum,Edetanorum,Emerita,Emona,Euracini,Faventia,Flaviae,Florentia,Forum,Gerulata,Gerunda,Glevensium,Hadriani,Herculanea,Isca,Italica,Iulia,Iuliobrigensium,Iuvavum,Lactodurum,Lagentium,Lauri,Legionis,Lemanis,Lentia,Lepidi,Letocetum,Lindinis,Lindum,Londinium,Lopodunum,Lousonna,Lucus,Lugdunum,Luguvalium,Lutetia,Mancunium,Marsonia,Martius,Massa,Matilo,Mattiacorum,Mediolanum,Mod,Mogontiacum,Moridunum,Mursa,Naissus,Nervia,Nida,Nigrum,Novaesium,Noviomagus,Olicana,Ovilava,Parisiorum,Partiscum,Paterna,Pistoria,Placentia,Pollentia,Pomaria,Pons,Portus,Praetoria,Praetorium,Pullum,Ragusium,Ratae,Raurica,Regina,Regium,Regulbium,Rigomagus,Roma,Romula,Rutupiae,Salassorum,Salernum,Salona,Scalabis,Segovia,Silurum,Sirmium,Siscia,Sorviodurum,Sumelocenna,Tarraco,Taurinorum,Theranda,Traiectum,Treverorum,Tungrorum,Turicum,Ulpia,Valentia,Venetiae,Venta,Verulamium,Vesontio,Vetera,Victoriae,Victrix,Villa,Viminacium,Vindelicorum,Vindobona,Vinovia,Viroconium"},{name:"Finnic",i:9,min:5,max:11,d:"akiut",m:0,b:"Aanekoski,Abjapaluoja,Ahlainen,Aholanvaara,Ahtari,Aijala,Aimala,Akaa,Alajarvi,Alatornio,Alavus,Antsla,Aspo,Bennas,Bjorkoby,Elva,Emasalo,Espoo,Esse,Evitskog,Forssa,Haapajarvi,Haapamaki,Haapavesi,Haapsalu,Haavisto,Hameenlinna,Hameenmaki,Hamina,Hanko,Harjavalta,Hattuvaara,Haukipudas,Hautajarvi,Havumaki,Heinola,Hetta,Hinkabole,Hirmula,Hossa,Huittinen,Husula,Hyryla,Hyvinkaa,Iisalmi,Ikaalinen,Ilmola,Imatra,Inari,Iskmo,Itakoski,Jamsa,Jarvenpaa,Jeppo,Jioesuu,Jiogeva,Joensuu,Jokela,Jokikyla,Jokisuu,Jormua,Juankoski,Jungsund,Jyvaskyla,Kaamasmukka,Kaarina,Kajaani,Kalajoki,Kallaste,Kankaanpaa,Kannus,Kardla,Karesuvanto,Karigasniemi,Karkkila,Karkku,Karksinuia,Karpankyla,Kaskinen,Kasnas,Kauhajoki,Kauhava,Kauniainen,Kauvatsa,Kehra,Keila,Kellokoski,Kelottijarvi,Kemi,Kemijarvi,Kerava,Keuruu,Kiikka,Kiipu,Kilinginiomme,Kiljava,Kilpisjarvi,Kitee,Kiuruvesi,Kivesjarvi,Kiviioli,Kivisuo,Klaukkala,Klovskog,Kohtlajarve,Kokemaki,Kokkola,Kolho,Koria,Koskue,Kotka,Kouva,Kouvola,Kristiina,Kaupunki,Kuhmo,Kunda,Kuopio,Kuressaare,Kurikka,Kusans,Kuusamo,Kylmalankyla,Lahti,Laitila,Lankipohja,Lansikyla,Lappeenranta,Lapua,Laurila,Lautiosaari,Lepsama,Liedakkala,Lieksa,Lihula,Littoinen,Lohja,Loimaa,Loksa,Loviisa,Luohuanylipaa,Lusi,Maardu,Maarianhamina,Malmi,Mantta,Masaby,Masala,Matasvaara,Maula,Miiluranta,Mikkeli,Mioisakula,Munapirtti,Mustvee,Muurahainen,Naantali,Nappa,Narpio,Nickby,Niinimaa,Niinisalo,Nikkila,Nilsia,Nivala,Nokia,Nummela,Nuorgam,Nurmes,Nuvvus,Obbnas,Oitti,Ojakkala,Ollola,onningeby,Orimattila,Orivesi,Otanmaki,Otava,Otepaa,Oulainen,Oulu,Outokumpu,Paavola,Paide,Paimio,Pakankyla,Paldiski,Parainen,Parkano,Parkumaki,Parola,Perttula,Pieksamaki,Pietarsaari,Pioltsamaa,Piolva,Pohjavaara,Porhola,Pori,Porrasa,Porvoo,Pudasjarvi,Purmo,Pussi,Pyhajarvi,Raahe,Raasepori,Raisio,Rajamaki,Rakvere,Rapina,Rapla,Rauma,Rautio,Reposaari,Riihimaki,Rovaniemi,Roykka,Ruonala,Ruottala,Rutalahti,Saarijarvi,Salo,Sastamala,Saue,Savonlinna,Seinajoki,Sillamae,Sindi,Siuntio,Somero,Sompujarvi,Suonenjoki,Suurejaani,Syrjantaka,Tampere,Tamsalu,Tapa,Temmes,Tiorva,Tormasenvaara,Tornio,Tottijarvi,Tulppio,Turenki,Turi,Tuukkala,Tuurala,Tuuri,Tuuski,Ulvila,Unari,Upinniemi,Utti,Uusikaarlepyy,Uusikaupunki,Vaaksy,Vaalimaa,Vaarinmaja,Vaasa,Vainikkala,Valga,Valkeakoski,Vantaa,Varkaus,Vehkapera,Vehmasmaki,Vieki,Vierumaki,Viitasaari,Viljandi,Vilppula,Viohma,Vioru,Virrat,Ylike,Ylivieska,Ylojarvi"},{name:"Korean",i:10,min:5,max:11,d:"",m:0,b:"Aewor,Andong,Angang,Anjung,Anmyeon,Ansan,Anseong,Anyang,Aphae,Apo,Asan,Baebang,Baekseok,Baeksu,Beobwon,Beolgyo,Beomseo,Boeun,Bongdam,Bongdong,Bonghwa,Bongyang,Boryeong,Boseong,Buan,Bubal,Bucheon,Buksam,Busan,Busan,Busan,Buyeo,Changnyeong,Changwon,Cheonan,Cheongdo,Cheongjin,Cheongju,Cheongju,Cheongsong,Cheongyang,Cheorwon,Chirwon,Chowol,Chuncheon,Chuncheon,Chungju,Chungmu,Daecheon,Daedeok,Daegaya,Daegu,Daegu,Daegu,Daejeon,Daejeon,Daejeon,Daejeong,Daesan,Damyang,Dangjin,Danyang,Dasa,Dogye,Dolsan,Dong,Dongducheon,Donggwangyang,Donghae,Dongsong,Doyang,Eonyang,Eumseong,Gaeseong,Galmal,Gampo,Ganam,Ganggyeong,Ganghwa,Gangjin,Gangneung,Ganseong,Gapyeong,Gaun,Gaya,Geochang,Geoje,Geojin,Geoncheon,Geumho,Geumil,Geumsan,Geumseong,Geumwang,Gijang,Gimcheon,Gimhae,Gimhwa,Gimje,Gimpo,Goa,Gochang,Gochon,Goesan,Gohan,Goheung,Gokseong,Gongdo,Gongju,Gonjiam,Goseong,Goyang,Gujwa,Gumi,Gungnae,Gunpo,Gunsan,Gunsan,Gunwi,Guri,Gurye,Guryongpo,Gwacheon,Gwangcheon,Gwangju,Gwangju,Gwangju,Gwangju,Gwangmyeong,Gwangyang,Gwansan,Gyeongju,Gyeongsan,Gyeongseong,Gyeongseong,Gyeryong,Hadong,Haeju,Haenam,Hamchang,Hamheung,Hampyeong,Hamyang,Hamyeol,Hanam,Hanrim,Hapcheon,Hapdeok,Hayang,Heunghae,Heungnam,Hoengseong,Hongcheon,Hongnong,Hongseong,Hwacheon,Hwado,Hwando,Hwaseong,Hwasun,Hwawon,Hyangnam,Icheon,Iksan,Illo,Imsil,Incheon,Incheon,Incheon,Inje,Iri,Iri,Jangan,Janghang,Jangheung,Janghowon,Jangseong,Jangseungpo,Jangsu,Jecheon,Jeju,Jeomchon,Jeongeup,Jeonggwan,Jeongju,Jeongok,Jeongseon,Jeonju,Jeonju,Jeungpyeong,Jido,Jiksan,Jillyang,Jinan,Jincheon,Jindo,Jingeon,Jinhae,Jinjeop,Jinju,Jinju,Jinnampo,Jinyeong,Jocheon,Jochiwon,Jori,Judeok,Jumunjin,Maepo,Mangyeong,Masan,Masan,Migeum,Miryang,Mokcheon,Mokpo,Mokpo,Muan,Muju,Mungyeong,Munmak,Munsan,Munsan,Naeseo,Naesu,Najin,Naju,Namhae,Namji,Nampyeong,Namwon,Namyang,Namyangju,Nohwa,Nongong,Nonsan,Ochang,Ocheon,Oedong,Okcheon,Okgu,Onam,Onsan,Onyang,Opo,Osan,Osong,Paengseong,Paju,Pocheon,Pogok,Pohang,Poseung,Punggi,Pungsan,Pyeongchang,Pyeonghae,Pyeongtaek,Pyeongyang,Sabi,Sabuk,Sacheon,Samcheok,Samcheonpo,Samho,Samhyang,Samnangjin,Samrye,Sancheong,Sangdong,Sangju,Sanyang,Sapgyo,Sariwon,Sejong,Seocheon,Seogwipo,Seokjeok,Seonggeo,Seonghwan,Seongjin,Seongju,Seongnam,Seongsan,Seonsan,Seosan,Seoul,Seungju,Siheung,Sinbuk,Sindong,Sineuiju,Sintaein,Soheul,Sokcho,Songak,Songjeong,Songnim,Songtan,Sunchang,Suncheon,Suwon,Taean,Taebaek,Tongjin,Tongyeong,Uijeongbu,Uiryeong,Uiseong,Uiwang,Ujeong,Uljin,Ulleung,Ulsan,Ulsan,Unbong,Ungcheon,Ungjin,Wabu,Waegwan,Wando,Wanggeomseong,Wiryeseong,Wondeok,Wonju,Wonsan,Yangchon,Yanggu,Yangju,Yangpyeong,Yangsan,Yangyang,Yecheon,Yeocheon,Yeoju,Yeomchi,Yeoncheon,Yeongam,Yeongcheon,Yeongdeok,Yeongdong,Yeonggwang,Yeongju,Yeongwol,Yeongyang,Yeonil,Yeonmu,Yeosu,Yesan,Yongin,Yongjin,Yugu,Wayang"},{name:"Chinese",i:11,min:5,max:10,d:"",m:0,b:"Anding,Anlu,Anqing,Anshun,Baan,Baixing,Banyang,Baoding,Baoqing,Binzhou,Caozhou,Changbai,Changchun,Changde,Changling,Changsha,Changtu,Changzhou,Chaozhou,Cheli,Chengde,Chengdu,Chenzhou,Chizhou,Chongqing,Chuxiong,Chuzhou,Dading,Dali,Daming,Datong,Daxing,Dean,Dengke,Dengzhou,Deqing,Dexing,Dihua,Dingli,Dongan,Dongchang,Dongchuan,Dongping,Duyun,Fengtian,Fengxiang,Fengyang,Fenzhou,Funing,Fuzhou,Ganzhou,Gaoyao,Gaozhou,Gongchang,Guangnan,Guangning,Guangping,Guangxin,Guangzhou,Guide,Guilin,Guiyang,Hailong,Hailun,Hangzhou,Hanyang,Hanzhong,Heihe,Hejian,Henan,Hengzhou,Hezhong,Huaian,Huaide,Huaiqing,Huanglong,Huangzhou,Huining,Huizhou,Hulan,Huzhou,Jiading,Jian,Jianchang,Jiande,Jiangning,Jiankang,Jianning,Jiaxing,Jiayang,Jilin,Jinan,Jingjiang,Jingzhao,Jingzhou,Jinhua,Jinzhou,Jiujiang,Kaifeng,Kaihua,Kangding,Kuizhou,Laizhou,Lanzhou,Leizhou,Liangzhou,Lianzhou,Liaoyang,Lijiang,Linan,Linhuang,Linjiang,Lintao,Liping,Liuzhou,Longan,Longjiang,Longqing,Longxing,Luan,Lubin,Lubin,Luzhou,Mishan,Nanan,Nanchang,Nandian,Nankang,Nanning,Nanyang,Nenjiang,Ningan,Ningbo,Ningguo,Ninguo,Ningwu,Ningxia,Ningyuan,Pingjiang,Pingle,Pingliang,Pingyang,Puer,Puzhou,Qianzhou,Qingyang,Qingyuan,Qingzhou,Qiongzhou,Qujing,Quzhou,Raozhou,Rende,Ruian,Ruizhou,Runing,Shafeng,Shajing,Shaoqing,Shaowu,Shaoxing,Shaozhou,Shinan,Shiqian,Shouchun,Shuangcheng,Shulei,Shunde,Shunqing,Shuntian,Shuoping,Sicheng,Sien,Sinan,Sizhou,Songjiang,Suiding,Suihua,Suining,Suzhou,Taian,Taibei,Tainan,Taiping,Taiwan,Taiyuan,Taizhou,Taonan,Tengchong,Tieli,Tingzhou,Tongchuan,Tongqing,Tongren,Tongzhou,Weihui,Wensu,Wenzhou,Wuchang,Wuding,Wuzhou,Xian,Xianchun,Xianping,Xijin,Xiliang,Xincheng,Xingan,Xingde,Xinghua,Xingjing,Xingqing,Xingyi,Xingyuan,Xingzhong,Xining,Xinmen,Xiping,Xuanhua,Xunzhou,Xuzhou,Yanan,Yangzhou,Yanji,Yanping,Yanqi,Yanzhou,Yazhou,Yichang,Yidu,Yilan,Yili,Yingchang,Yingde,Yingtian,Yingzhou,Yizhou,Yongchang,Yongping,Yongshun,Yongzhou,Yuanzhou,Yuezhou,Yulin,Yunnan,Yunyang,Zezhou,Zhangde,Zhangzhou,Zhaoqing,Zhaotong,Zhenan,Zhending,Zhengding,Zhenhai,Zhenjiang,Zhenxi,Zhenyun,Zhongshan,Zunyi"},{name:"Japanese",i:12,min:4,max:10,d:"",m:0,b:"Abira,Aga,Aikawa,Aizumisato,Ajigasawa,Akkeshi,Amagi,Ami,Anan,Ando,Asakawa,Ashikita,Bandai,Biratori,China,Chonan,Esashi,Fuchu,Fujimi,Funagata,Genkai,Godo,Goka,Gonohe,Gyokuto,Haboro,Hamatonbetsu,Happo,Harima,Hashikami,Hayashima,Heguri,Hidaka,Higashiagatsuma,Higashiura,Hiranai,Hirogawa,Hiroo,Hodatsushimizu,Hoki,Hokuei,Hokuryu,Horokanai,Ibigawa,Ichikai,Ichikawamisato,Ichinohe,Iide,Iijima,Iizuna,Ikawa,Inagawa,Itakura,Iwaizumi,Iwate,Kagamino,Kaisei,Kamifurano,Kamiita,Kamijima,Kamikawa,Kamikawa,Kamikawa,Kaminokawa,Kamishihoro,Kamitonda,Kamiyama,Kanda,Kanna,Kasagi,Kasuya,Katsuura,Kawabe,Kawagoe,Kawajima,Kawamata,Kawamoto,Kawanehon,Kawanishi,Kawara,Kawasaki,Kawasaki,Kawatana,Kawazu,Kihoku,Kikonai,Kin,Kiso,Kitagata,Kitajima,Kiyama,Kiyosato,Kofu,Koge,Kohoku,Kokonoe,Kora,Kosa,Kosaka,Kotohira,Kudoyama,Kumejima,Kumenan,Kumiyama,Kunitomi,Kurate,Kushimoto,Kutchan,Kyonan,Kyotamba,Mashike,Matsumae,Mifune,Mihama,Minabe,Minami,Minamiechizen,Minamioguni,Minamiosumi,Minamitane,Misaki,Misasa,Misato,Miyashiro,Miyoshi,Mori,Moseushi,Mutsuzawa,Nagaizumi,Nagatoro,Nagayo,Nagomi,Nakadomari,Nakanojo,Nakashibetsu,Nakatosa,Namegawa,Namie,Nanbu,Nanporo,Naoshima,Nasu,Niseko,Nishihara,Nishiizu,Nishikatsura,Nishikawa,Nishinoshima,Nishiwaga,Nogi,Noto,Nyuzen,Oarai,Obuse,Odai,Ogawara,Oharu,Oi,Oirase,Oishida,Oiso,Oizumi,Oji,Okagaki,Oketo,Okutama,Omu,Ono,Osaki,Osakikamijima,Otobe,Otsuki,Owani,Reihoku,Rifu,Rikubetsu,Rishiri,Rokunohe,Ryuo,Saka,Sakuho,Samani,Satsuma,Sayo,Saza,Setana,Shakotan,Shibayama,Shikama,Shimamoto,Shimizu,Shimokawa,Shintomi,Shirakawa,Shisui,Shitara,Sobetsu,Sue,Sumita,Suooshima,Suttsu,Tabuse,Tachiarai,Tadami,Tadaoka,Taiji,Taiki,Takachiho,Takahama,Taketoyo,Tako,Taragi,Tateshina,Tatsugo,Tawaramoto,Teshikaga,Tobe,Toin,Tokigawa,Toma,Tomioka,Tonosho,Tosa,Toyo,Toyokoro,Toyotomi,Toyoyama,Tsubata,Tsubetsu,Tsukigata,Tsunan,Tsuno,Tsuwano,Umi,Wakasa,Yamamoto,Yamanobe,Yamatsuri,Yanaizu,Yasuda,Yoichi,Yonaguni,Yoro,Yoshino,Yubetsu,Yugawara,Yuni,Yusuhara,Yuza"},{name:"Portuguese",i:13,min:5,max:11,d:"",m:.1,b:"Abrigada,Afonsoeiro,Agueda,Aguiar,Aguilada,Alagoas,Alagoinhas,Albufeira,Alcacovas,Alcanhoes,Alcobaca,Alcochete,Alcoutim,Aldoar,Alexania,Alfeizerao,Algarve,Alenquer,Almada,Almagreira,Almeirim,Alpalhao,Alpedrinha,Alvalade,Alverca,Alvor,Alvorada,Amadora,Amapa,Amieira,Anapolis,Anhangueira,Ansiaes,Apelacao,Aracaju,Aranhas,Arega,Areira,Araguaina,Araruama,Arganil,Armacao,Arouca,Asfontes,Assenceira,Avelar,Aveiro,Azambuja,Azinheira,Azueira,Bahia,Bairros,Balsas,Barcarena,Barreiras,Barreiro,Barretos,Batalha,Beira,Beja,Benavente,Betim,Boticas,Braga,Braganca,Brasilia,Brejo,Cabecao,Cabeceiras,Cabedelo,Cabofrio,Cachoeiras,Cadafais,Calheta,Calihandriz,Calvao,Camacha,Caminha,Campinas,Canidelo,Canha,Canoas,Capinha,Carmoes,Cartaxo,Carvalhal,Carvoeiro,Cascavel,Castanhal,Castelobranco,Caueira,Caxias,Chapadinha,Chaves,Celheiras,Cocais,Coimbra,Comporta,Coentral,Conde,Copacabana,Coqueirinho,Coruche,Corumba,Couco,Cubatao,Curitiba,Damaia,Doisportos,Douradilho,Dourados,Enxames,Enxara,Erada,Erechim,Ericeira,Ermidasdosado,Ervidel,Escalhao,Escariz,Esmoriz,Estombar,Espinhal,Espinho,Esposende,Esquerdinha,Estela,Estoril,Eunapolis,Evora,Famalicao,Famoes,Fanhoes,Fanzeres,Fatela,Fatima,Faro,Felgueiras,Ferreira,Figueira,Flecheiras,Florianopolis,Fornalhas,Fortaleza,Freiria,Freixeira,Frielas,Fronteira,Funchal,Fundao,Gaeiras,Gafanhadaboahora,Goa,Goiania,Gracas,Gradil,Grainho,Gralheira,Guarulhos,Guetim,Guimaraes,Horta,Iguacu,Igrejanova,Ilhavo,Ilheus,Ipanema,Iraja,Itaboral,Itacuruca,Itaguai,Itanhaem,Itapevi,Juazeiro,Lagos,Lavacolchos,Laies,Lamego,Laranjeiras,Leiria,Limoeiro,Linhares,Lisboa,Lomba,Lorvao,Lourencomarques,Lourical,Lourinha,Luziania,Macao,Macapa,Macedo,Machava,Malveira,Manaus,Mangabeira,Mangaratiba,Marambaia,Maranhao,Maringue,Marinhais,Matacaes,Matosinhos,Maxial,Maxias,Mealhada,Meimoa,Meires,Milharado,Mira,Miranda,Mirandela,Mogadouro,Montalegre,Montesinho,Moura,Mourao,Mozelos,Negroes,Neiva,Nespereira,Nilopolis,Niteroi,Nordeste,Obidos,Odemira,Odivelas,Oeiras,Oleiros,Olhao,Olhalvo,Olhomarinho,Olinda,Olival,Oliveira,Oliveirinha,Oporto,Ourem,Ovar,Palhais,Palheiros,Palmeira,Palmela,Palmital,Pampilhosa,Pantanal,Paradinha,Parelheiros,Paripueira,Paudalho,Pedrosinho,Penafiel,Peniche,Pedrogao,Pegoes,Pinhao,Pinheiro,Pinhel,Pombal,Pontal,Pontinha,Portel,Portimao,Poxim,Quarteira,Queijas,Queluz,Quiaios,Ramalhal,Reboleira,Recife,Redinha,Ribadouro,Ribeira,Ribeirao,Rosais,Roteiro,Sabugal,Sacavem,Sagres,Sandim,Sangalhos,Santarem,Santos,Sarilhos,Sarzedas,Satao,Satuba,Seixal,Seixas,Seixezelo,Seixo,Selmes,Sepetiba,Serta,Setubal,Silvares,Silveira,Sinhaem,Sintra,Sobral,Sobralinho,Sorocaba,Tabuacotavir,Tabuleiro,Taveiro,Teixoso,Telhado,Telheiro,Tomar,Torrao,Torreira,Torresvedras,Tramagal,Trancoso,Troviscal,Vagos,Valpacos,Varzea,Vassouras,Velas,Viana,Vidigal,Vidigueira,Vidual,Viladerei,Vilamar,Vimeiro,Vinhais,Vinhos,Viseu,Vitoria,Vlamao,Vouzela"},{name:"Nahuatl",i:14,min:6,max:13,d:"l",m:0,b:"Acaltepec,Acaltepecatl,Acapulco,Acatlan,Acaxochitlan,Ajuchitlan,Atotonilco,Azcapotzalco,Camotlan,Campeche,Chalco,Chapultepec,Chiapan,Chiapas,Chihuahua,Cihuatlan,Cihuatlancihuatl,Coahuila,Coatepec,Coatlan,Coatzacoalcos,Colima,Colotlan,Coyoacan,Cuauhillan,Cuauhnahuac,Cuauhtemoc,Cuernavaca,Ecatepec,Epatlan,Guanajuato,Huaxacac,Huehuetlan,Hueyapan,Ixtapa,Iztaccihuatl,Iztapalapa,Jalisco,Jocotepec,Jocotepecxocotl,Matixco,Mazatlan,Michhuahcan,Michoacan,Michoacanmichin,Minatitlan,Naucalpan,Nayarit,Nezahualcoyotl,Oaxaca,Ocotepec,Ocotlan,Olinalan,Otompan,Popocatepetl,Queretaro,Sonora,Tabasco,Tamaulipas,Tecolotlan,Tenochtitlan,Teocuitlatlan,Teocuitlatlanteotl,Teotlalco,Teotlalcoteotl,Tepotzotlan,Tepoztlantepoztli,Texcoco,Tlachco,Tlalocan,Tlaxcala,Tlaxcallan,Tollocan,Tolutepetl,Tonanytlan,Tototlan,Tuchtlan,Tuxpan,Uaxacac,Xalapa,Xochimilco,Xolotlan,Yaotlan,Yopico,Yucatan,Yztac,Zacatecas,Zacualco"},{name:"Hungarian",i:15,min:6,max:13,d:"",m:.1,b:"Aba,Abadszalok,Abony,Adony,Ajak,Albertirsa,Alsozsolca,Aszod,Babolna,Bacsalmas,Baktaloranthaza,Balassagyarmat,Balatonalmadi,Balatonboglar,Balatonfured,Balatonfuzfo,Balkany,Balmazujvaros,Barcs,Bataszek,Batonyterenye,Battonya,Bekes,Berettyoujfalu,Berhida,Biatorbagy,Bicske,Biharkeresztes,Bodajk,Boly,Bonyhad,Budakalasz,Budakeszi,Celldomolk,Csakvar,Csenger,Csongrad,Csorna,Csorvas,Csurgo,Dabas,Demecser,Derecske,Devavanya,Devecser,Dombovar,Dombrad,Dorogullo,Dunafoldvar,Dunaharaszti,Dunavarsany,Dunavecse,Edeleny,Elek,Emod,Encs,Enying,Ercsi,Fegyvernek,Fehergyarmat,Felsozsolca,Fertoszentmiklos,Fonyod,Fot,Fuzesabony,Fuzesgyarmat,Gardony,God,Gyal,Gyomaendrod,Gyomro,Hajdudorog,Hajduhadhaz,Hajdunanas,Hajdusamson,Hajduszoboszlo,Halasztelek,Harkany,Hatvan,Heves,Heviz,Ibrany,Isaszeg,Izsak,Janoshalma,Janossomorja,Jaszapati,Jaszarokszallas,Jaszfenyszaru,Jaszkiser,Kaba,Kalocsa,Kapuvar,Karcag,Kecel,Kemecse,Kenderes,Kerekegyhaza,Kerepes,Keszthely,Kisber,Kiskoros,Kiskunmajsa,Kistarcsa,Kistelek,Kisujszallas,Kisvarda,Komadi,Komarom,Komlo,Kormend,Korosladany,Koszeg,Kozarmisleny,Kunhegyes,Kunszentmarton,Kunszentmiklos,Labatlan,Lajosmizse,Lenti,Letavertes,Letenye,Lorinci,Maglod,Mako,Mandok,Marcali,Martfu,Martonvasar,Mateszalka,Melykut,Mezobereny,Mezocsat,Mezohegyes,Mezokeresztes,Mezokovacshaza,Mezokovesd,Mezotur,Mindszent,Mohacs,Monor,Mor,Morahalom,Nadudvar,Nagyatad,Nagyecsed,Nagyhalasz,Nagykallo,Nagykata,Nagykoros,Nagymaros,Nyekladhaza,Nyergesujfalu,Nyiradony,Nyirbator,Nyirmada,Nyirtelek,Ocsa,Orkeny,Oroszlany,Paks,Pannonhalma,Paszto,Pecel,Pecsvarad,Pilis,Pilisvorosvar,Polgar,Polgardi,Pomaz,Puspokladany,Pusztaszabolcs,Putnok,Racalmas,Rackeve,Rakamaz,Rakoczifalva,Sajoszentpeter,Sandorfalva,Sarbogard,Sarkad,Sarospatak,Sarvar,Satoraljaujhely,Siklos,Simontornya,Solt,Soltvadkert,Sumeg,Szabadszallas,Szarvas,Szazhalombatta,Szecseny,Szeghalom,Szendro,Szentgotthard,Szentlorinc,Szerencs,Szigethalom,Szigetvar,Szikszo,Tab,Tamasi,Tapioszele,Tapolca,Tat,Tata,Teglas,Tet,Tiszacsege,Tiszafoldvar,Tiszafured,Tiszakecske,Tiszalok,Tiszaujvaros,Tiszavasvari,Tokaj,Tokol,Tolna,Tompa,Torokbalint,Torokszentmiklos,Totkomlos,Tura,Turkeve,Ujkigyos,ujszasz,Vamospercs,Varpalota,Vasarosnameny,Vasvar,Vecses,Velence,Veresegyhaz,Verpelet,Veszto,Zahony,Zalaszentgrot,Zirc,Zsambek"},{name:"Turkish",i:16,min:4,max:10,d:"",m:0,b:"Adapazari,Adiyaman,Afshin,Afyon,Ari,Akchaabat,Akchakale,Akchakoca,Akdamadeni,Akhisar,Aksaray,Akshehir,Alaca,Alanya,Alapli,Alashehir,Amasya,Anamur,Antakya,Ardeshen,Artvin,Aydin,Ayvalik,Babaeski,Bafra,Balikesir,Bandirma,Bartin,Bashiskele,Batman,Bayburt,Belen,Bergama,Besni,Beypazari,Beyshehir,Biga,Bilecik,Bingul,Birecik,Bismil,Bitlis,Bodrum,Bolu,Bolvadin,Bor,Bostanichi,Boyabat,Bozuyuk,Bucak,Bulancak,Bulanik,Burdur,Burhaniye,Chan,Chanakkale,Chankiri,Charshamba,Chaycuma,Chayeli,Chayirova,Cherkezkuy,Cheshme,Ceyhan,Ceylanpinar,Chine,Chivril,Cizre,Chorlu,Chumra,Dalaman,Darica,Denizli,Derik,Derince,Develi,Devrek,Didim,Dilovasi,Dinar,Diyadin,Diyarbakir,Doubayazit,Durtyol,Duzce,Duzichi,Edirne,Edremit,Elazi,Elbistan,Emirda,Erbaa,Ercish,Erdek,Erdemli,Ereli,Ergani,Erzin,Erzincan,Erzurum,Eskishehir,Fatsa,Fethiye,Gazipasha,Gebze,Gelibolu,Gerede,Geyve,Giresun,Guksun,Gulbashi,Gulcuk,Gurnen,Gumushhane,Guroymak,Hakkari,Harbiye,Havza,Hayrabolu,Hilvan,Idil,Idir,Ilgin,Imamolu,Incirliova,Inegul,Iskenderun,Iskilip,Islahiye,Isparta,Izmit,Iznik,Kadirli,Kahramanmarash,Kahta,Kaman,Kapakli,Karabuk,Karacabey,Karadeniz Ereli,Karakupru,Karaman,Karamursel,Karapinar,Karasu,Kars,Kartepe,Kastamonu,Kemer,Keshan,Kilimli,Kilis,Kirikhan,Kirikkale,Kirklareli,Kirshehir,Kiziltepe,Kurfez,Korkuteli,Kovancilar,Kozan,Kozlu,Kozluk,Kulu,Kumluca,Kurtalan,Kushadasi,Kutahya,Luleburgaz,Malatya,Malazgirt,Malkara,Manavgat,Manisa,Mardin,Marmaris,Mersin,Merzifon,Midyat,Milas,Mula,Muratli,Mush,Mut,Nazilli,Nevshehir,Nide,Niksar,Nizip,Nusaybin,udemish,Oltu,Ordu,Orhangazi,Ortaca,Osmancik,Osmaniye,Patnos,Payas,Pazarcik,Polatli,Reyhanli,Rize,Safranbolu,Salihli,Samanda,Samsun,Sandikli,shanliurfa,Saray,Sarikamish,Sarikaya,sharkishla,shereflikochhisar,Serik,Serinyol,Seydishehir,Siirt,Silifke,Silopi,Silvan,Simav,Sinop,shirnak,Sivas,Siverek,Surke,Soma,Sorgun,Suluova,Sungurlu,Suruch,Susurluk,Tarsus,Tatvan,Tavshanli,Tekirda,Terme,Tire,Tokat,Tosya,Trabzon,Tunceli,Turgutlu,Turhal,Unye,Ushak,Uzunkurpru,Van,Vezirkurpru,Viranshehir,Yahyali,Yalova,Yenishehir,Yerkury,Yozgat,Yuksekova,Zile,Zonguldak"},{name:"Berber",i:17,min:4,max:10,d:"s",m:.2,b:"Abkhouch,Adrar,Agadir,Agelmam,Aghmat,Agrakal,Agulmam,Ahaggar,Almou,Anfa,Annaba,Aousja,Arbat,Argoub,Arif,Asfi,Assamer,Assif,Azaghar,Azmour,Azrou,Beccar,Beja,Bennour,Benslimane,Berkane,Berrechid,Bizerte,Bouskoura,Boutferda,Dar Bouazza,Darallouch,Darchaabane,Dcheira,Denden,Djebel,Djedeida,Drargua,Essaouira,Ezzahra,Fas,Fnideq,Ghezeze,Goubellat,Grisaffen,Guelmim,Guercif,Hammamet,Harrouda,Hoceima,Idurar,Ifendassen,Ifoghas,Imilchil,Inezgane,Izoughar,Jendouba,Kacem,Kelibia,Kenitra,Kerrando,Khalidia,Khemisset,Khenifra,Khouribga,Kidal,Korba,Korbous,Lahraouyine,Larache,Leyun,Lqliaa,Manouba,Martil,Mazagan,Mcherga,Mdiq,Megrine,Mellal,Melloul,Midelt,Mohammedia,Mornag,Mrrakc,Nabeul,Nadhour,Nador,Nawaksut,Nefza,Ouarzazate,Ouazzane,Oued Zem,Oujda,Ouladteima,Qsentina,Rades,Rafraf,Safi,Sefrou,Sejnane,Settat,Sijilmassa,Skhirat,Slimane,Somaa,Sraghna,Susa,Tabarka,Taferka,Tafza,Tagbalut,Tagerdayt,Takelsa,Tanja,Tantan,Taourirt,Taroudant,Tasfelalayt,Tattiwin,Taza,Tazerka,Tazizawt,Tebourba,Teboursouk,Temara,Testour,Tetouan,Tibeskert,Tifelt,Tinariwen,Tinduf,Tinja,Tiznit,Toubkal,Trables,Tubqal,Tunes,Urup,Watlas,Wehran,Wejda,Youssoufia,Zaghouan,Zahret,Zemmour,Zriba"},{name:"Arabic",i:18,min:4,max:9,d:"ae",m:.2,b:"Abadilah,Abayt,Abha,Abud,Aden,Ahwar,Ajman,Alabadilah,Alabar,Alahjer,Alain,Alaraq,Alarish,Alarjam,Alashraf,Alaswaaq,Alawali,Albarar,Albawadi,Albirk,Aldhabiyah,Alduwaid,Alfareeq,Algayed,Alhada,Alhafirah,Alhamar,Alharam,Alharidhah,Alhawtah,Alhazim,Alhrateem,Alhudaydah,Alhujun,Alhuwaya,Aljahra,Aljohar,Aljubail,Alkawd,Alkhalas,Alkhawaneej,Alkhen,Alkhhafah,Alkhobar,Alkhuznah,Alkiranah,Allisafah,Allith,Almadeed,Almardamah,Almarwah,Almasnaah,Almejammah,Almojermah,Almshaykh,Almurjan,Almuwayh,Almuzaylif,Alnaheem,Alnashifah,Alqadeimah,Alqah,Alqahma,Alqalh,Alqouz,Alquaba,Alqunfudhah,Alqurayyat,Alradha,Alraqmiah,Alsadyah,Alsafa,Alshagab,Alshoqiq,Alshuqaiq,Alsilaa,Althafeer,Alwakrah,Alwasqah,Amaq,Amran,Annaseem,Aqbiyah,Arafat,Arar,Ardah,Arrawdah,Asfan,Ashayrah,Ashshahaniyah,Askar,Assaffaniyah,Ayaar,Aziziyah,Baesh,Bahrah,Baish,Balhaf,Banizayd,Baqaa,Baqal,Bidiyah,Bisha,Biyatah,Buqhayq,Burayda,Dafiyat,Damad,Dammam,Dariyah,Daynah,Dhafar,Dhahran,Dhalkut,Dhamar,Dhubab,Dhurma,Dibab,Dirab,Doha,Dukhan,Duwaibah,Enaker,Fadhla,Fahaheel,Fanateer,Farasan,Fardah,Fujairah,Ghalilah,Ghar,Ghizlan,Ghomgyah,Ghran,Hababah,Habil,Hadiyah,Haffah,Hajanbah,Hajrah,Halban,Haqqaq,Haradh,Hasar,Hathah,Hawarwar,Hawaya,Hawiyah,Hebaa,Hefar,Hijal,Husnah,Huwailat,Huwaitah,Irqah,Isharah,Ithrah,Jamalah,Jarab,Jareef,Jarwal,Jash,Jazan,Jeddah,Jiblah,Jihanah,Jilah,Jizan,Joha,Joraibah,Juban,Jubbah,Juddah,Jumeirah,Kamaran,Keyad,Khab,Khabtsaeed,Khaiybar,Khasab,Khathirah,Khawarah,Khulais,Khulays,Klayah,Kumzar,Limah,Linah,Mabar,Madrak,Mahab,Mahalah,Makhtar,Makshosh,Manfuhah,Manifah,Manshabah,Mareah,Masdar,Mashwar,Masirah,Maskar,Masliyah,Mastabah,Maysaan,Mazhar,Mdina,Meeqat,Mirbah,Mirbat,Mokhtara,Muharraq,Muladdah,Musandam,Musaykah,Muscat,Mushayrif,Musrah,Mussafah,Mutrah,Nafhan,Nahdah,Nahwa,Najran,Nakhab,Nizwa,Oman,Qadah,Qalhat,Qamrah,Qasam,Qatabah,Qawah,Qosmah,Qurain,Quraydah,Quriyat,Qurwa,Rabigh,Radaa,Rafha,Rahlah,Rakamah,Rasheedah,Rasmadrakah,Risabah,Rustaq,Ryadh,Saabah,Saabar,Sabtaljarah,Sabya,Sadad,Sadah,Safinah,Saham,Sahlat,Saihat,Salalah,Salmalzwaher,Salmiya,Sanaa,Sanaban,Sayaa,Sayyan,Shabayah,Shabwah,Shafa,Shalim,Shaqra,Sharjah,Sharkat,Sharurah,Shatifiyah,Shibam,Shidah,Shifiyah,Shihar,Shoqra,Shoqsan,Shuwaq,Sibah,Sihmah,Sinaw,Sirwah,Sohar,Suhailah,Sulaibiya,Sunbah,Tabuk,Taif,Taqah,Tarif,Tharban,Thumrait,Thuqbah,Thuwal,Tubarjal,Turaif,Turbah,Tuwaiq,Ubar,Umaljerem,Urayarah,Urwah,Wabrah,Warbah,Yabreen,Yadamah,Yafur,Yarim,Yemen,Yiyallah,Zabid,Zahwah,Zallaq,Zinjibar,Zulumah"},{name:"Inuit",i:19,min:5,max:15,d:"alutsn",m:0,b:"Aaluik,Aappilattoq,Aasiaat,Agdleruussakasit,Aggas,Akia,Akilia,Akuliaruseq,Akuliarutsip,Akunnaaq,Agissat,Agssaussat,Alluitsup,Alluttoq,Aluit,Aluk,Ammassalik,Amarortalik,Amitsorsuaq,Anarusuk,Angisorsuaq,Anguniartarfik,Annertussoq,Annikitsoq,Anoraliuirsoq,Appat,Apparsuit,Apusiaajik,Arsivik,Arsuk,Ataa,Atammik,Ateqanngitsorsuaq,Atilissuaq,Attu,Aukarnersuaq,Augpalugtoq, Aumat,Auvilikavsak,Auvilkikavsaup,Avadtlek,Avallersuaq,Bjornesk,Blabaerdalen,Blomsterdalen,Brattalhid,Bredebrae,Brededal,Claushavn,Edderfulegoer,Egger,Eqalugalinnguit,Eqalugarssuit,Eqaluit,Eqqua,Etah,Graah,Hakluyt,Haredalen,Hareoen,Hundeo,Igdlorssuit,Igaliku,Igdlugdlip,Igdluluarssuk,Iginniafik,Ikamiuk,Ikamiut,Ikarissat,Ikateq,Ikeq,Ikerasak,Ikerasaarsuk,Ikermiut,Ikermoissuaq,Ikertivaq,Ikorfarssuit,Ikorfat,Ilimanaq,Illorsuit,Iluileq,Iluiteq,Ilulissat,Illunnguit,Imaarsivik,Imartunarssuk,Immikkoortukajik,Innaarsuit,Ingjald,Inneruulalik,Inussullissuaq,Iqek,Ikerasakassak,Iperaq,Ippik,Isortok,Isungartussoq,Itileq,Itivdleq,Itissaalik,Ittit,Ittoqqortoormiit,Ivingmiut,Ivittuut,Kanajoorartuut,Kangaamiut,Kangaarsuk,Kangaatsiaq,Kangeq,Kangerluk,Kangerlussuaq,Kanglinnguit,Kapisillit,Karrat,Kekertamiut,Kiatak,Kiatassuaq,Kiataussaq,Kigatak,Kigdlussat,Kinaussak,Kingittorsuaq,Kitak,Kitsissuarsuit,Kitsissut,Klenczner,Kook,Kraulshavn,Kujalleq,Kullorsuaq,Kulusuk,Kuurmiit,Kuusuaq,Laksedalen,Maniitsoq,Marrakajik,Mattaangassut,Mernoq,Mittivakkat,Moriusaq,Myggbukta,Naajaat,Nako,Nangissat,Nanortalik,Nanuuseq,Nappassoq,Narsarmijt,Narssaq,Narsarsuaq,Narssarssuk,Nasaussaq,Nasiffik,Natsiarsiorfik,Naujanguit,Niaqornaarsuk,Niaqornat,Nordfjordspasset,Nugatsiaq,Nuluuk,Nunaa,Nunarssit,Nunarsuaq,Nunataaq,Nunatakavsaup,Nutaarmiut,Nuugaatsiaq,Nuuk,Nuukullak,Nuuluk,Nuussuaq,Olonkinbyen,Oqaatsut,Oqaits\xFAnguit,Oqonermiut,Oodaaq,Paagussat,Palungataq,Pamialluk,Paamiut,Paatuut,Patuersoq,Perserajoq,Paornivik,Pituffik,Puugutaa,Puulkuip,Qaanaq,Qaarsorsuaq,Qaarsorsuatsiaq,Qaasuitsup,Qaersut,Qajartalik,Qallunaat,Qaneq,Qaqaarissorsuaq,Qaqit,Qaqortok,Qasigiannguit,Qasse,Qassimiut,Qeertartivaq,Qeertartivatsiaq,Qeqertaq,Qeqertarssdaq,Qeqertarsuaq,Qeqertasussuk,Qeqertarsuatsiaat,Qeqertat,Qeqqata,Qernertoq,Qernertunnguit,Qianarreq,Qilalugkiarfik,Qingagssat,Qingaq,Qoornuup,Qorlortorsuaq,Qullikorsuit,Qunnerit,Qutdleq,Ravnedalen,Ritenbenk,Rypedalen,Sarfannguit,Saarlia,Saarloq,Saatoq,Saatorsuaq,Saatup,Saattut,Sadeloe,Salleq,Salliaruseq,Sammeqqat,Sammisoq,Sanningassoq,Saqqaq,Saqqarlersuaq,Saqqarliit,Sarqaq,Sattiaatteq,Savissivik,Serfanguaq,Sermersooq,Sermersut,Sermilik,Sermiligaaq,Sermitsiaq,Simitakaja,Simiutaq,Singamaq,Siorapaluk,Sisimiut,Sisuarsuit,Skal,Skarvefjeld,Skjoldungen,Storoen,Sullorsuaq,Suunikajik,Sverdrup,Taartoq,Takiseeq,Talerua,Tarqo,Tasirliaq,Tasiusak,Tiilerilaaq,Timilersua,Timmiarmiut,Tingmjarmiut,Traill,Tukingassoq,Tuttorqortooq,Tuujuk,Tuttulissuup,Tussaaq,Uigordlit,Uigorlersuaq,Uilortussoq,Uiivaq,Ujuaakajiip,Ukkusissat,Umanat,Upernavik,Upernattivik,Upepnagssivik,Upernivik,Uttorsiutit,Uumannaq,Uummannaarsuk,Uunartoq,Uvkusigssat,Ymer"},{name:"Basque",i:20,min:4,max:11,d:"r",m:.1,b:"Abadio,Abaltzisketa,Abanto Zierbena,Aduna,Agurain,Aia,Aiara,Aizarnazabal,Ajangiz,Albiztur,Alegia,Alkiza,Alonsotegi,Altzaga,Altzo,Amezketa,Amorebieta,Amoroto,Amurrio,Andoain,Anoeta,Antzuola,Arakaldo,Arama,Aramaio,Arantzazu,Arbatzegi ,Areatza,Aretxabaleta,Arraia,Arrankudiaga,Arrasate,Arratzu,Arratzua,Arrieta,Arrigorriaga,Artea,Artzentales,Artziniega,Asparrena,Asteasu,Astigarraga,Ataun,Atxondo,Aulesti,Azkoitia,Azpeitia,Bakio,Baliarrain,Balmaseda,Barakaldo,Barrika,Barrundia,Basauri,Bastida,Beasain,Bedia,Beizama,Belauntza,Berango,Berantevilla,Berastegi,Bergara,Bermeo,Bernedo,Berriatua,Berriz,Berrobi,Bidania,Bilar,Bilbao,Burgelu,Busturia,Deba,Derio,Dima,Donemiliaga,Donostia,Dulantzi,Durango,Ea,Eibar,Elantxobe,Elduain,Elgeta,Elgoibar,Elorrio,Erandio,Ereno,Ermua,Errenteria,Errezil,Erribera Beitia,Erriberagoitia,Errigoiti,Eskoriatza,Eskuernaga,Etxebarri,Etxebarria,Ezkio,Fika,Forua,Fruiz,Gabiria,Gaintza,Galdakao,Galdames,Gamiz,Garai,Gasteiz,Gatika,Gatzaga,Gaubea,Gauna,Gautegiz Arteaga,Gaztelu,Gernika,Gerrikaitz,Getaria,Getxo,Gizaburuaga,Goiatz,Gordexola,Gorliz,Harana,Hernani,Hernialde,Hondarribia,Ibarra,Ibarrangelu,Idiazabal,Iekora,Igorre,Ikaztegieta,Iruna Oka,Irun,Irura,Iruraiz,Ispaster,Itsaso,Itsasondo,Iurreta,Izurtza,Jatabe,Kanpezu,Karrantza Harana,Kortezubi,Kripan,Kuartango,Lanestosa,Lantziego,Larrabetzu,Larraul,Lasarte,Laudio,Laukiz,Lazkao,Leaburu,Legazpi,Legorreta,Legutio,Leintz,Leioa,Lekeitio,Lemoa,Lemoiz,Leza,Lezama,Lezo,Lizartza,Loiu,Lumo,Manaria,Maeztu,Mallabia,Markina,Maruri,Manueta,Menaka,Mendaro,Mendata,Mendexa,Moreda Araba,Morga,Mundaka,Mungia,Munitibar,Murueta,Muskiz,Mutiloa,Mutriku,Muxika,Nabarniz,Onati,Oiartzun,Oion,Okondo,Olaberria,Ondarroa,Ordizia,Orendain,Orexa,Oria,Orio,Ormaiztegi,Orozko,Ortuella,Otxandio,Pasaia,Plentzia,Portugalete,Samaniego,Santurtzi,Segura,Sestao,Sondika,Sopela,Sopuerta,Soraluze,Sukarrieta,Tolosa,Trapagaran,Turtzioz,Ubarrundia,Ubide,Ugao,Urdua,Urduliz,Urizaharra,Urkabustaiz,Urnieta,Urretxu,Usurbil,Xemein,Zaia,Zaldibar,Zaldibia,Zalduondo,Zambrana,Zamudio,Zaratamo,Zarautz,Zeanuri,Zeberio,Zegama,Zerain,Zestoa,Zierbena,Zigoitia,Ziortza,Zizurkil,Zuia,Zumaia,Zumarraga"},{name:"Nigerian",i:21,min:4,max:10,d:"",m:.3,b:"Abadogo,Abafon,Abdu,Acharu,Adaba,Adealesu,Adeto,Adyongo,Afaga,Afamju,Afuje,Agbelagba,Agigbigi,Agogoke,Ahute,Aiyelaboro,Ajebe,Ajola,Akarekwu,Akessan,Akunuba,Alawode,Alkaijji,Amangam,Amaoji,Amgbaye,Amtasa,Amunigun,Anase,Aniho,Animahun,Antul,Anyoko,Apekaa,Arapagi,Asamagidi,Asande,Ataibang,Awgbagba,Awhum,Awodu,Babanana,Babateduwa,Bagu,Bakura,Bandakwai,Bangdi,Barbo,Barkeje,Basa,Basabra,Basansagawa,Bieleshin,Bilikani,Birnindodo,Braidu,Bulakawa,Buriburi,Burisidna,Busum,Bwoi,Cainnan,Chakum,Charati,Chondugh,Dabibikiri,Dagwarga,Dallok,Danalili,Dandala,Darpi,Dhayaki,Dokatofa,Doma,Dozere,Duci,Dugan,Ebelibri,Efem,Efoi,Egudu,Egundugbo,Ekoku,Ekpe,Ekwere,Erhua,Eteu,Etikagbene,Ewhoeviri,Ewhotie,Ezemaowa,Fatima,Gadege,Galakura,Galea,Gamai,Gamen,Ganjin,Gantetudu,Garangamawa,Garema,Gargar,Gari,Garinbode,Garkuwa,Garu Kime,Gazabu,Gbure,Gerti,Gidan,Giringwe,Gitabaremu,Giyagiri,Giyawa,Gmawa,Golakochi,Golumba,Guchi,Gudugu,Gunji,Gusa,Gwambula,Gwamgwam,Gwodoti,Hayinlere,Hayinmaialewa,Hirishi,Hombo,Ibefum,Iberekodo,Ibodeipa,Icharge,Ideoro,Idofin,Idofinoka,Idya,Iganmeji,Igbetar,Igbogo,Ijoko,Ijuwa,Ikawga,Ikekogbe,Ikhin,Ikoro,Ikotefe,Ikotokpora,Ikpakidout,Ikpeoniong,Ilofa,Imuogo,Inyeneke,Iorsugh,Ipawo,Ipinlerere,Isicha,Itakpa,Itoki,Iyedeame,Jameri,Jangi,Jara,Jare,Jataudakum,Jaurogomki,Jepel,Jibam,Jirgu,Jirkange,Kafinmalama,Kamkem,Katab,Katanga,Katinda,Katirije,Kaurakimba,Keffinshanu,Kellumiri,Kiagbodor,Kibiare,Kingking,Kirbutu,Kita,Kogbo,Kogogo,Kopje,Koriga,Koroko,Korokorosei,Kotoku,Kuata,Kujum,Kukau,Kunboon,Kuonubogbene,Kurawe,Kushinahu,Kwaramakeri,Ladimeji,Lafiaro,Lahaga,Laindebajanle,Laindegoro,Lajere,Lakati,Ligeri,Litenswa,Lokobimagaji,Lusabe,Maba,Madarzai,Magoi,Maialewa,Maianita,Maijuja,Mairakuni,Maleh,Malikansaa,Mallamkola,Mallammaduri,Marmara,Masagu,Masoma,Mata,Matankali,Mbalare,Megoyo,Meku,Miama,Mige,Mkporagwu,Modi,Molafa,Mshi,Msugh,Muduvu,Murnachehu,Namnai,Nanumawa,Nasudu,Ndagawo,Ndamanma,Ndiebeleagu,Ndiwulunbe,Ndonutim,Ngaruwa,Ngbande,Nguengu,Nto Ekpe,Nubudi,Nyajo,Nyido,Nyior,Obafor,Obazuwa,Odajie,Odiama,Ofunatam,Ogali,Ogan,Ogbaga,Ogbahu,Ogultu,Ogunbunmi,Ogunmakin,Ojaota,Ojirami,Ojopode,Okehin,Olugunna,Omotunde,Onipede,Onisopi,Onma,Orhere,Orya,Oshotan,Otukwang,Otunade,Pepegbene,Poros,Rafin,Rampa,Rimi,Rinjim,Robertkiri,Rugan,Rumbukawa,Sabiu,Sabon,Sabongari,Sai,Salmatappare,Sangabama,Sarabe,Seboregetore,Seibiri,Sendowa,Shafar,Shagwa,Shata,Shefunda,Shengu,Sokoron,Sunnayu,Taberlma,Tafoki,Takula,Talontan,Taraku,Tarhemba,Tayu,Ter,Timtim,Timyam,Tindirke,Tirkalou,Tokunbo,Tonga,Torlwam,Tseakaadza,Tseanongo,Tseavungu,Tsebeeve,Tsekov,Tsepaegh,Tuba,Tumbo,Tungalombo,Tungamasu,Tunganrati,Tunganyakwe,Tungenzuri,Ubimimi,Uhkirhi,Umoru,Umuabai,Umuaja,Umuajuju,Umuimo,Umuojala,Unchida,Ungua,Unguwar,Unongo,Usha,Ute,Utongbo,Vembera,Vorokotok,Wachin,Walebaga,Wurawura,Wuro,Yanbashi,Yanmedi,Yenaka,Yoku,Zamangera,Zarunkwari,Zilumo,Zulika"},{name:"Celtic",i:22,min:4,max:12,d:"nld",m:0,b:"Aberaman,Aberangell,Aberarth,Aberavon,Aberbanc,Aberbargoed,Aberbeeg,Abercanaid,Abercarn,Abercastle,Abercegir,Abercraf,Abercregan,Abercych,Abercynon,Aberdare,Aberdaron,Aberdaugleddau,Aberdeen,Aberdulais,Aberdyfi,Aberedw,Abereiddy,Abererch,Abereron,Aberfan,Aberffraw,Aberffrwd,Abergavenny,Abergele,Aberglasslyn,Abergorlech,Abergwaun,Abergwesyn,Abergwili,Abergwynfi,Abergwyngregyn,Abergynolwyn,Aberhafesp,Aberhonddu,Aberkenfig,Aberllefenni,Abermain,Abermaw,Abermorddu,Abermule,Abernant,Aberpennar,Aberporth,Aberriw,Abersoch,Abersychan,Abertawe,Aberteifi,Aberthin,Abertillery,Abertridwr,Aberystwyth,Achininver,Afonhafren,Alisaha,Antinbhearmor,Ardenna,Attacon,Beira,Bhrura,Boioduro,Bona,Boudobriga,Bravon,Brigant,Briganta,Briva,Cambodunum,Cambra,Caracta,Catumagos,Centobriga,Ceredigion,Chalain,Dinn,Diwa,Dubingen,Duro,Ebora,Ebruac,Eburodunum,Eccles,Eighe,Eireann,Ferkunos,Genua,Ghrainnse,Inbhear,Inbhir,Inbhirair,Innerleithen,Innerleven,Innerwick,Inver,Inveraldie,Inverallan,Inveralmond,Inveramsay,Inveran,Inveraray,Inverarnan,Inverbervie,Inverclyde,Inverell,Inveresk,Inverfarigaig,Invergarry,Invergordon,Invergowrie,Inverhaddon,Inverkeilor,Inverkeithing,Inverkeithney,Inverkip,Inverleigh,Inverleith,Inverloch,Inverlochlarig,Inverlochy,Invermay,Invermoriston,Inverness,Inveroran,Invershin,Inversnaid,Invertrossachs,Inverugie,Inveruglas,Inverurie,Kilninver,Kirkcaldy,Kirkintilloch,Krake,Latense,Leming,Lindomagos,Llanaber,Lochinver,Lugduno,Magoduro,Monmouthshire,Narann,Novioduno,Nowijonago,Octoduron,Penning,Pheofharain,Ricomago,Rossinver,Salodurum,Seguia,Sentica,Theorsa,Uige,Vitodurum,Windobona"},{name:"Mesopotamian",i:23,min:4,max:9,d:"srpl",m:.1,b:"Adab,Akkad,Akshak,Amnanum,Arbid,Arpachiyah,Arrapha,Assur,Babilim,Badtibira,Balawat,Barsip,Borsippa,Carchemish,Chagar Bazar,Chuera,Ctesiphon ,Der,Dilbat,Diniktum,Doura,Durkurigalzu,Ekallatum,Emar,Erbil,Eridu,Eshnunn,Fakhariya ,Gawra,Girsu,Hadatu,Hamoukar,Haradum,Harran,Hatra,Idu,Irisagrig,Isin,Jemdet,Kahat,Kartukulti,Khaiber,Kish ,Kisurra,Kuara,Kutha,Lagash,Larsa ,Leilan,Marad,Mardaman,Mari,Mashkan,Mumbaqat ,Nabada,Nagar,Nerebtum,Nimrud,Nineveh,Nippur,Nuzi,Qalatjarmo,Qatara,Rawda,Seleucia,Shaduppum,Shanidar,Sharrukin,Shemshara,Shibaniba,Shuruppak,Sippar,Tarbisu,Tellagrab,Tellessawwan,Tellessweyhat,Tellhassuna,Telltaya,Telul,Terqa,Thalathat,Tutub,Ubaid ,Umma,Ur,Urfa,Urkesh,Uruk,Urum,Zabalam,Zenobia"},{name:"Iranian",i:24,min:5,max:11,d:"",m:.1,b:"Abali,Abrisham,Absard,Abuzeydabad,Afus,Alavicheh,Alikosh,Amol,Anarak,Anbar,Andisheh,Anshan,Aran,Ardabil,Arderica,Ardestan,Arjomand,Asgaran,Asgharabad,Ashian,Awan,Babajan,Badrud,Bafran,Baghestan,Baghshad,Bahadoran,Baharan Shahr,Baharestan,Bakun,Bam,Baqershahr,Barzok,Bastam,Behistun,Bitistar,Bumahen,Bushehr,Chadegan,Chahardangeh,Chamgardan,Chermahin,Choghabonut,Chugan,Damaneh,Damavand,Darabgard,Daran,Dastgerd,Dehaq,Dehaqan,Dezful,Dizicheh,Dorcheh,Dowlatabad,Duruntash,Ecbatana,Eslamshahr,Estakhr,Ezhiyeh,Falavarjan,Farrokhi,Fasham,Ferdowsieh,Fereydunshahr,Ferunabad,Firuzkuh,Fuladshahr,Ganjdareh,Ganzak,Gaz,Geoy,Godin,Goldasht,Golestan,Golpayegan,Golshahr,Golshan,Gorgab,Guged,Habibabad,Hafshejan,Hajjifiruz,Hana,Harand,Hasanabad,Hasanlu,Hashtgerd,Hecatompylos,Hormirzad,Imanshahr,Isfahan,Jandaq,Javadabad,Jiroft,Jowsheqan ,Jowzdan,Kabnak,Kahriz Sang,Kahrizak,Kangavar,Karaj,Karkevand,Kashan,Kelishad,Kermanshah,Khaledabad,Khansar,Khorramabad,Khur,Khvorzuq,Kilan,Komeh,Komeshcheh,Konar,Kuhpayeh,Kul,Kushk,Lavasan,Laybid,Liyan,Lyan,Mahabad,Mahallat,Majlesi,Malard,Manzariyeh,Marlik,Meshkat,Meymeh,Miandasht,Mish,Mobarakeh,Nahavand,Nain,Najafabad,Naqshe,Narezzash,Nasimshahr,Nasirshahr,Nasrabad,Natanz,Neyasar,Nikabad,Nimvar,Nushabad,Pakdasht,Parand,Pardis,Parsa,Pasargadai,Patigrabana,Pir Bakran,Pishva,Qahderijan,Qahjaverestan,Qamsar,Qarchak,Qods,Rabat,Ray-shahr,Rezvanshahr,Rhages,Robat Karim,Rozveh,Rudehen,Sabashahr,Safadasht,Sagzi,Salehieh,Sandal,Sarvestan,Sedeh,Sefidshahr,Semirom,Semnan,Shadpurabad,Shah,Shahdad,Shahedshahr,Shahin,Shahpour,Shahr,Shahreza,Shahriar,Sharifabad,Shemshak,Shiraz,Shushan,Shushtar,Sialk,Sin,Sukhteh,Tabas,Tabriz,Takhte,Talkhuncheh,Talli,Tarq,Temukan,Tepe,Tiran,Tudeshk,Tureng,Urmia,Vahidieh,Vahrkana,Vanak,Varamin,Varnamkhast,Varzaneh,Vazvan,Yahya,Yarim,Yasuj,Zarrin Shahr,Zavareh,Zayandeh,Zazeran,Ziar,Zibashahr,Zranka"},{name:"Hawaiian",i:25,min:5,max:10,d:"auo",m:1,b:"Aapueo,Ahoa,Ahuakaio,Ahuakamalii,Ahuakeio,Ahupau,Aki,Alaakua,Alae,Alaeloa,Alaenui,Alamihi,Aleamai,Alena,Alio,Aupokopoko,Auwahi,Hahakea,Haiku,Halakaa,Halehaku,Halehana,Halemano,Haleu,Haliimaile,Hamakuapoko,Hamoa,Hanakaoo,Hanaulu,Hanawana,Hanehoi,Haneoo,Haou,Hikiaupea,Hoalua,Hokuula,Honohina,Honokahua,Honokala,Honokalani,Honokeana,Honokohau,Honokowai,Honolua,Honolulu,Honolulunui,Honomaele,Honomanu,Hononana,Honopou,Hoolawa,Hopenui,Hualele,Huelo,Hulaia,Ihuula,Ilikahi,Kaalaea,Kaalelehinale,Kaapahu,Kaehoeho,Kaeleku,Kaeo,Kahakuloa,Kahalawe,Kahalawe,Kahalehili,Kahana,Kahilo,Kahuai,Kaiaula,Kailihiakoko,Kailua,Kainehe,Kakalahale,Kakanoni,Kakio,Kakiweka,Kalena,Kalenanui,Kaleoaihe,Kalepa,Kaliae,Kalialinui,Kalihi,Kalihi,Kalihi,Kalimaohe,Kaloi,Kamani,Kamaole,Kamehame,Kanahena,Kanaio,Kaniaula,Kaonoulu,Kaopa,Kapaloa,Kapaula,Kapewakua,Kapohue,Kapuaikini,Kapunakea,Kapuuomahuka,Kauau,Kauaula,Kaukuhalahala,Kaulalo,Kaulanamoa,Kauluohana,Kaumahalua,Kaumakani,Kaumanu,Kaunauhane,Kaunuahane,Kaupakulua,Kawaipapa,Kawaloa,Kawaloa,Kawalua,Kawela,Keaa,Keaalii,Keaaula,Keahua,Keahuapono,Keakuapauaela,Kealahou,Keanae,Keauhou,Kekuapawela,Kelawea,Keokea,Keopuka,Kepio,Kihapuhala,Kikoo,Kilolani,Kipapa,Koakupuna,Koali,Koananai,Koheo,Kolea,Kolokolo,Kooka,Kopili,Kou,Kualapa,Kuhiwa,Kuholilea,Kuhua,Kuia,Kuiaha,Kuikui,Kukoae,Kukohia,Kukuiaeo,Kukuioolu,Kukuipuka,Kukuiula,Kulahuhu,Kumunui,Lapakea,Lapalapaiki,Lapueo,Launiupoko,Loiloa,Lole,Lualailua,Maalo,Mahinahina,Mahulua,Maiana,Mailepai,Makaakini,Makaalae,Makaehu,Makaiwa,Makaliua,Makapipi,Makapuu,Makawao,Makila,Mala,Maluaka,Mamalu,Manawaiapiki,Manawainui,Maulili,Mehamenui,Miana,Mikimiki,Moalii,Moanui,Mohopili,Mohopilo,Mokae,Mokuia,Mokupapa,Mooiki,Mooloa,Moomuku,Muolea,Nahuakamalii,Nailiilipoko,Nakaaha,Nakalepo,Nakaohu,Nakapehu,Nakula,Napili,Niniau,Niumalu,Nuu,Ohia,Oloewa,Olowalu,Omaopio,Onau,Onouli,Opaeula,Opana,Opikoula,Paakea,Paeahu,Paehala,Paeohi,Pahoa,Paia,Pakakia,Pakala,Palauea,Palemo,Panaewa,Paniau,Papaaea,Papaanui,Papaauhau,Papahawahawa,Papaka,Papauluana,Pauku,Paunau,Pauwalu,Pauwela,Peahi,Piapia,Pohakanele,Pohoula,Polaiki,Polanui,Polapola,Polua,Poopoo,Popoiwi,Popoloa,Poponui,Poupouwela,Puaa,Puaaluu,Puahoowali,Puakea,Puako,Pualaea,Puehuehu,Puekahi,Pueokauiki,Pukaauhuhu,Pukalani,Pukuilua,Pulehu,Pulehuiki,Pulehunui,Punaluu,Puolua,Puou,Puuhaehae,Puuhaoa,Puuiki,Puuki,Puukohola,Puulani,Puumaneoneo,Puunau,Puunoa,Puuomaiai,Puuomaile,Uaoa,Uhao,Ukumehame,Ulaino,Ulumalu,Wahikuli,Waiahole,Waiakoa,Waianae,Waianu,Waiawa,Waiehu,Waieli,Waihee,Waikapu,Wailamoa,Wailaulau,Wailua,Wailuku,Wainee,Waiohole,Waiohonu,Waiohue,Waiohuli,Waiokama,Waiokila,Waiopai,Waiopua,Waipao,Waipio,Waipioiki,Waipionui,Waipouli,Wakiu,Wananalua"},{name:"Karnataka",i:26,min:5,max:11,d:"tnl",m:0,b:"Adityapatna,Adyar,Afzalpur,Aland,Alnavar,Alur,Ambikanagara,Anekal,Ankola,Annigeri,Arkalgud,Arsikere,Athni,Aurad,Badami,Bagalkot,Bagepalli,Bail,Bajpe,Bangalore,Bangarapet,Bankapura,Bannur,Bantval,Basavakalyan,Basavana,Belgaum,Beltangadi,Belur,Bhadravati,Bhalki,Bhatkal,Bhimarayanagudi,Bidar,Bijapur,Bilgi,Birur,Bommasandra,Byadgi,Challakere,Chamarajanagar,Channagiri,Channapatna,Channarayapatna,Chik,Chikmagalur,Chiknayakanhalli,Chikodi,Chincholi,Chintamani,Chitapur,Chitgoppa,Chitradurga,Dandeli,Dargajogihalli,Devadurga,Devanahalli,Dod,Donimalai,Gadag,Gajendragarh,Gangawati,Gauribidanur,Gokak,Gonikoppal,Gubbi,Gudibanda,Gulbarga,Guledgudda,Gundlupet,Gurmatkal,Haliyal,Hangal,Harapanahalli,Harihar,Hassan,Hatti,Haveri,Hebbagodi,Heggadadevankote,Hirekerur,Holalkere,Hole,Homnabad,Honavar,Honnali,Hoovina,Hosakote,Hosanagara,Hosdurga,Hospet,Hubli,Hukeri,Hungund,Hunsur,Ilkal,Indi,Jagalur,Jamkhandi,Jevargi,Jog,Kadigenahalli,Kadur,Kalghatgi,Kamalapuram,Kampli,Kanakapura,Karkal,Karwar,Khanapur,Kodiyal,Kolar,Kollegal,Konnur,Koppa,Koppal,Koratagere,Kotturu,Krishnarajanagara,Krishnarajasagara,Krishnarajpet,Kudchi,Kudligi,Kudremukh,Kumta,Kundapura,Kundgol,Kunigal,Kurgunta,Kushalnagar,Kushtagi,Lakshmeshwar,Lingsugur,Londa,Maddur,Madhugiri,Madikeri,Mahalingpur,Malavalli,Mallar,Malur,Mandya,Mangalore,Manvi,Molakalmuru,Mudalgi,Mudbidri,Muddebihal,Mudgal,Mudhol,Mudigere,Mulbagal,Mulgund,Mulki,Mulur,Mundargi,Mundgod,Munirabad,Mysore,Nagamangala,Nanjangud,Narasimharajapura,Naregal,Nargund,Navalgund,Nipani,Pandavapura,Pavagada,Piriyapatna,Pudu,Puttur,Rabkavi,Raichur,Ramanagaram,Ramdurg,Ranibennur,Raybag,Robertson,Ron,Sadalgi,Sagar,Sakleshpur,Saligram,Sandur,Sankeshwar,Saundatti,Savanur,Sedam,Shahabad,Shahpur,Shaktinagar,Shiggaon,Shikarpur,Shirhatti,Shorapur,Shrirangapattana,Siddapur,Sidlaghatta,Sindgi,Sindhnur,Sira,Siralkoppa,Sirsi,Siruguppa,Somvarpet,Sorab,Sringeri,Srinivaspur,Sulya,Talikota,Tarikere,Tekkalakote,Terdal,Thumbe,Tiptur,Tirthahalli,Tirumakudal,Tumkur,Turuvekere,Udupi,Vijayapura,Wadi,Yadgir,Yelandur,Yelbarga,Yellapur,Yenagudde"},{name:"Quechua",i:27,min:6,max:12,d:"l",m:0,b:"Altomisayoq,Ancash,Andahuaylas,Apachekta,Apachita,Apu\xA0,Apurimac,Arequipa,Atahuallpa,Atawalpa,Atico,Ayacucho,Ayllu,Cajamarca,Carhuac,Carhuacatac,Cashan,Caullaraju,Caxamalca,Cayesh,Chacchapunta,Chacraraju,Champara,Chanchan,Chekiacraju,Chinchey,Chontah,Chopicalqui,Chucuito,Chuito,Chullo,Chumpi,Chuncho,Chuquiapo,Churup,Cochapata,Cojup,Collota,Conococha,Copa,Corihuayrachina,Cusichaca,Despacho,Haika,Hanpiq,Hatun,Haywarisqa,Huaca,Hualcan,Huamanga,Huamashraju,Huancarhuas,Huandoy,Huantsan,Huarmihuanusca,Huascaran,Huaylas,Huayllabamba,Huichajanca,Huinayhuayna,Huinioch,Illiasca,Intipunku,Ishinca,Jahuacocha,Jirishanca,Juli,Jurau,Kakananpunta,Kamasqa,Karpay,Kausay,Khuya\xA0,Kuelap,Llaca,Llactapata,Llanganuco,Llaqta,Llupachayoc,Machu,Mallku,Matarraju,Mikhuy,Milluacocha,Munay,Ocshapalca,Ollantaytambo,Pacamayo,Paccharaju,Pachacamac,Pachakamaq,Pachakuteq,Pachakuti,Pachamama\xA0\xA0,Paititi,Pajaten,Palcaraju,Pampa,Panaka,Paqarina,Paqo,Parap,Paria,Patallacta,Phuyupatamarca,Pisac,Pongos,Pucahirca,Pucaranra,Puscanturpa,Putaca,Qawaq\xA0,Qayqa,Qochamoqo,Qollana,Qorihuayrachina,Qorimoqo,Quenuaracra,Queshque,Quillcayhuanca,Quillya,Quitaracsa,Quitaraju,Qusqu,Rajucolta,Rajutakanan,Rajutuna,Ranrahirca,Ranrapalca,Raria,Rasac,Rimarima,Riobamba,Runkuracay,Rurec,Sacsa,Saiwa,Sarapo,Sayacmarca,Sinakara,TamboColorado,Tamboccocha,Taripaypacha,Taulliraju,Tawantinsuyu,Taytanchis,Tiwanaku,Tocllaraju,Tsacra,Tuco,Tullparaju,Tumbes,Ulta,Uruashraju,Vallunaraju,Vilcabamba,Wacho\xA0,Wankawillka,Wayra,Yachay,Yahuarraju,Yanamarey,Yanesha,Yerupaja"},{name:"Swahili",i:28,min:4,max:9,d:"",m:0,b:"Abim,Adjumani,Alebtong,Amolatar,Amuria,Amuru,Apac,Arua,Arusha,Babati,Baragoi,Bombo,Budaka,Bugembe,Bugiri,Buikwe,Bukedea,Bukoba,Bukomansimbi,Bukungu,Buliisa,Bundibugyo,Bungoma,Busembatya,Bushenyi,Busia,Busia,Busolwe,Butaleja,Butambala,Butere,Buwenge,Buyende,Dadaab,Dodoma,Dokolo,Eldoret,Elegu,Emali,Embu,Entebbe,Garissa,Gede,Gulu,Handeni,Hima,Hoima,Hola,Ibanda,Iganga,Iringa,Isingiro,Isiolo,Jinja,Kaabong,Kabale,Kaberamaido,Kabuyanda,Kabwohe,Kagadi,Kahama,Kajiado,Kakamega,Kakinga,Kakira,Kakiri,Kakuma,Kalangala,Kaliro,Kalisizo,Kalongo,Kalungu,Kampala,Kamuli,Kamwenge,Kanoni,Kanungu,Kapchorwa,Kapenguria,Kasese,Kasulu,Katakwi,Kayunga,Kericho,Keroka,Kiambu,Kibaale,Kibaha,Kibingo,Kiboga,Kibwezi,Kigoma,Kihiihi,Kilifi,Kira,Kiruhura,Kiryandongo,Kisii,Kisoro,Kisumu,Kitale,Kitgum,Kitui,Koboko,Korogwe,Kotido,Kumi,Kyazanga,Kyegegwa,Kyenjojo,Kyotera,Lamu,Langata,Lindi,Lodwar,Lokichoggio,Londiani,Loyangalani,Lugazi,Lukaya,Luweero,Lwakhakha,Lwengo,Lyantonde,Machakos,Mafinga,Makambako,Makindu,Malaba,Malindi,Manafwa,Mandera,Maralal,Marsabit,Masaka,Masindi,MasindiPort,Masulita,Matugga,Mayuge,Mbale,Mbarara,Mbeya,Meru,Mitooma,Mityana,Mombasa,Morogoro,Moroto,Moshi,Moyale,Moyo,Mpanda,Mpigi,Mpondwe,Mtwara,Mubende,Mukono,Mumias,Muranga,Musoma,Mutomo,Mutukula,Mwanza,Nagongera,Nairobi,Naivasha,Nakapiripirit,Nakaseke,Nakasongola,Nakuru,Namanga,Namayingo,Namutumba,Nansana,Nanyuki,Narok,Naromoru,Nebbi,Ngora,Njeru,Njombe,Nkokonjeru,Ntungamo,Nyahururu,Nyeri,Oyam,Pader,Paidha,Pakwach,Pallisa,Rakai,Ruiru,Rukungiri,Rwimi,Sanga,Sembabule,Shimoni,Shinyanga,Singida,Sironko,Songea,Soroti,Ssabagabo,Sumbawanga,Tabora,Takaungu,Tanga,Thika,Tororo,Tunduma,Vihiga,Voi,Wajir,Wakiso,Watamu,Webuye,Wobulenzi,Wote,Wundanyi,Yumbe,Zanzibar"},{name:"Vietnamese",i:29,min:3,max:12,d:"",m:1,b:"An Khe,An Nhon,Ayun Pa,Ba Don,Ba Ria,Bac Giang,Bac Kan,Bac Lieu,Bac Ninh,Bao Loc,Ben Cat,Ben Tre,Bien Hoa,Bim Son,Binh Long,Binh Minh,Buon Ho,Buon Ma Thuot,Ca Mau,Cai Lay,Cam Pha,Cam Ranh,Can Tho,Cao Bang,Cao Lanh,Chau Doc,Chi Linh,Cua Lo,Da Lat,Da Nang,Di An,Dien Ban,Dien Bien Phu,Dong Ha,Dong Hoi,Dong Trieu,Duyen Hai,Gia Nghia,Gia Rai,Go Cong,Ha Giang,Ha Long,Ha Noi,Ha Tinh,Hai Duong,Hai Phong,Hoa Binh,Hoang Mai,Hoi An,Hong Linh,Hong Ngu,Hue,Hung Yen,Huong Thuy,Huong Tra,Kien Tuong,Kon Tum,Ky Anh,La Gi,Lai Chau,Lang Son,Lao Cai,Long Khanh,Long My,Long Xuyen,Mong Cai,Muong Lay,My Hao,My Tho,Nam Dinh,Nga Bay,Nga Nam,Nghia Lo,Nha Trang,Ninh Binh,Ninh Hoa,Phan Rang Thap Cham,Phan Thiet,Pho Yen,Phu Ly,Phu My,Phu Tho,Phuoc Long,Pleiku,Quang Ngai,Quang Tri,Quang Yen,Quy Nhon,Rach Gia,Sa Dec,Sam Son,Soc Trang,Son La,Son Tay,Song Cau,Song Cong,Tam Diep,Tam Ky,Tan An,Tan Chau,Tan Uyen,Tay Ninh,Thai Binh,Thai Hoa,Thai Nguyen,Thanh Hoa,Thu Dau Mot,Thuan An,Tra Vinh,Tu Son,Tuy Hoa,Tuyen Quang,Uong Bi,Vi Thanh,Viet Tri,Vinh,Vinh Chau,Vinh Long,Vinh Yen,Vung Tau,Yen Bai"},{name:"Cantonese",i:30,min:5,max:11,d:"",m:0,b:"Chaiwan,Chekham,Cheungshawan,Chingchung,Chinghoi,Chingsen,Chingshing,Chiunam,Chiuon,Chiuyeung,Chiyuen,Choihung,Chuehoi,Chuiman,Chungfa,Chungfu,Chungsan,Chunguktsuen,Dakhing,Daopo,Daumun,Dingwu,Dinpak,Donggun,Dongyuen,Duenchau,Fachau,Fado,Fanling,Fatgong,Fatshan,Fotan,Fuktien,Fumun,Funggong,Funghoi,Fungshun,Fungtei,Gamtin,Gochau,Goming,Gonghoi,Gongshing,Goyiu,Hanghau,Hangmei,Hashan,Hengfachuen,Hengon,Heungchau,Heunggong,Heungkiu,Hingning,Hohfuktong,Hoichue,Hoifung,Hoiping,Hokong,Hokshan,Homantin,Hotin,Hoyuen,Hunghom,Hungshuikiu,Jiuling,Kamping,Kamsheung,Kamwan,Kaulongtong,Keilun,Kinon,Kinsang,Kityeung,Kongmun,Kukgong,Kwaifong,Kwaihing,Kwongchau,Kwongling,Kwongming,Kwuntong,Laichikok,Laiking,Laiwan,Lamtei,Lamtin,Leitung,Leungking,Limkong,Linchau,Linnam,Linping,Linshan,Loding,Lokcheong,Lokfu,Lokmachau,Longchuen,Longgong,Longmun,Longping,Longwa,Longwu,Lowu,Luichau,Lukfung,Lukho,Lungmun,Macheung,Maliushui,Maonshan,Mauming,Maunam,Meifoo,Mingkum,Mogong,Mongkok,Muichau,Muigong,Muiyuen,Naiwai,Namcheong,Namhoi,Namhong,Namo,Namsha,Namshan,Nganwai,Ngchuen,Ngoumun,Ngwa,Nngautaukok,Onting,Pakwun,Paotoishan,Pingshan,Pingyuen,Poklo,Polam,Pongon,Poning,Potau,Puito,Punyue,Saiwanho,Saiyingpun,Samshing,Samshui,Samtsen,Samyuenlei,Sanfung,Sanhing,Sanhui,Sanwai,Sanwui,Seiwui,Shamshuipo,Shanmei,Shantau,Shatin,Shatinwai,Shaukeiwan,Shauking,Shekkipmei,Shekmun,Shekpai,Sheungshui,Shingkui,Shiuhing,Shundak,Shunyi,Shupinwai,Simshing,Siuhei,Siuhong,Siukwan,Siulun,Suikai,Taihing,Taikoo,Taipo,Taishuihang,Taiwai,Taiwo,Taiwohau,Tinhau,Tinho,Tinking,Tinshuiwai,Tiukengleng,Toishan,Tongfong,Tonglowan,Tsakyoochung,Tsamgong,Tsangshing,Tseungkwano,Tsihing,Tsimshatsui,Tsinggong,Tsingshantsuen,Tsingwun,Tsingyi,Tsingyuen,Tsiuchau,Tsuenshekshan,Tsuenwan,Tuenmun,Tungchung,Waichap,Waichau,Waidong,Wailoi,Waishing,Waiyeung,Wanchai,Wanfau,Wanon,Wanshing,Wingon,Wongchukhang,Wongpo,Wongtaisin,Woping,Wukaisha,Yano,Yaumatei,Yauoi,Yautong,Yenfa,Yeungchun,Yeungdong,Yeunggong,Yeungsai,Yeungshan,Yimtin,Yingdak,Yiuping,Yongshing,Yongyuen,Yuenlong,Yuenshing,Yuetsau,Yuknam,Yunping,Yuyuen"},{name:"Mongolian",i:31,min:5,max:12,d:"aou",m:.3,b:"Adaatsag,Airag,Alag Erdene,Altai,Altanshiree,Altantsogts,Arbulag,Baatsagaan,Batnorov,Batshireet,Battsengel,Bayan Adarga,Bayan Agt,Bayanbulag,Bayandalai,Bayandun,Bayangovi,Bayanjargalan,Bayankhongor,Bayankhutag,Bayanlig,Bayanmonkh,Bayannuur,Bayan Ondor,Bayan Ovoo,Bayantal,Bayantsagaan,Bayantumen,Bayan Uul,Bayanzurkh,Berkh,Biger,Binder,Bogd,Bombogor,Bor Ondor,Bugat,Bulgan,Buregkhangai,Burentogtokh,Buutsagaan,Buyant,Chandmani,Chandmani Ondor,Choibalsan,Chuluunkhoroot,Chuluut,Dadal,Dalanjargalan,Dalanzadgad,Darkhan,Darvi,Dashbalbar,Dashinchilen,Delger,Delgerekh,Delgerkhaan,Delgerkhangai,Delgertsogt,Deluun,Deren,Dorgon,Duut,Erdene,Erdenebulgan,Erdeneburen,Erdenedalai,Erdenemandal,Erdenetsogt,Galshar,Galt,Galuut,Govi Ugtaal,Gurvan,Gurvanbulag,Gurvansaikhan,Gurvanzagal,Ikhkhet,Ikh Tamir,Ikh Uul,Jargalan,Jargalant,Jargaltkhaan,Jinst,Khairkhan,Khalhgol,Khaliun,Khanbogd,Khangai,Khangal,Khankh,Khankhongor,Khashaat,Khatanbulag,Khatgal,Kherlen,Khishig Ondor,Khokh,Kholonbuir,Khongor,Khotont,Khovd,Khovsgol,Khuld,Khureemaral,Khurmen,Khutag Ondor,Luus,Mandakh,Mandal Ovoo,Mankhan,Manlai,Matad,Mogod,Monkhkhairkhan,Moron,Most,Myangad,Nogoonnuur,Nomgon,Norovlin,Noyon,Ogii,Olgii,Olziit,Omnodelger,Ondorkhaan,Ondorshil,Ondor Ulaan,Orgon,Orkhon,Rashaant,Renchinlkhumbe,Sagsai,Saikhan,Saikhandulaan,Saikhan Ovoo,Sainshand,Saintsagaan,Selenge,Sergelen,Sevrei,Sharga,Sharyngol,Shine Ider,Shinejinst,Shiveegovi,Sumber,Taishir,Tarialan,Tariat,Teshig,Togrog,Tolbo,Tomorbulag,Tonkhil,Tosontsengel,Tsagaandelger,Tsagaannuur,Tsagaan Ovoo,Tsagaan Uur,Tsakhir,Tseel,Tsengel,Tsenkher,Tsenkhermandal,Tsetseg,Tsetserleg,Tsogt,Tsogt Ovoo,Tsogttsetsii,Tunel,Tuvshruulekh,Ulaanbadrakh,Ulaankhus,Ulaan Uul,Uyench,Yesonbulag,Zag,Zamyn Uud,Zereg"},{name:"Human Generic",i:32,min:6,max:11,d:"peolst",m:0,b:"Grimegrove,Cliffshear,Eaglevein,Basinborn,Whalewich,Faypond,Pondshade,Earthfield,Dustwatch,Houndcall,Oakenbell,Wildwell,Direwallow,Springmire,Bayfrost,Fearwich,Ghostdale,Cursespell,Shadowvein,Freygrave,Freyshell,Tradewick,Grasswallow,Kilshell,Flatwall,Mosswind,Edgehaven,Newfalls,Flathand,Lostcairn,Grimeshore,Littleshade,Millstrand,Snowbay,Quickbell,Crystalrock,Snakewharf,Oldwall,Whitvalley,Stagport,Deadkeep,Claymond,Angelhand,Ebonhold,Shimmerrun,Honeywater,Gloomburn,Arrowburgh,Slyvein,Dawnforest,Dirtshield,Southbreak,Clayband,Oakenrun,Graypost,Deepcairn,Lagoonpass,Cavewharf,Thornhelm,Smoothwallow,Lightfront,Irongrave,Stonespell,Cavemeadow,Millbell,Shimmerwell,Eldermere,Roguehaven,Dogmeadow,Pondside,Springview,Embervault,Dryhost,Bouldermouth,Stormhand,Oakenfall,Clearguard,Lightvale,Freyshear,Flameguard,Bellcairn,Bridgeforest,Scorchwich,Mythgulch,Maplesummit,Mosshand,Iceholde,Knightlight,Dawnwater,Laststar,Westpoint,Goldbreach,Falsevale,Pinegarde,Shroudrock,Whitwharf,Autumnband,Oceanstar,Rosedale,Snowtown,Chillstrand,Saltmouth,Crystalsummit,Redband,Thorncairn,Beargarde,Pearlhaven,Lostward,Northpeak,Sandhill,Cliffgate,Sandminster,Cloudcrest,Mythshear,Dragonward,Coldholde,Knighttide,Boulderharbor,Faybarrow,Dawnpass,Pondtown,Timberside,Madfair,Crystalspire,Shademeadow,Dragonbreak,Castlecross,Dogwell,Caveport,Wildlight,Mudfront,Eldermere,Midholde,Ravenwall,Mosstide,Everborn,Lastmere,Dawncall,Autumnkeep,Oldwatch,Shimmerwood,Eldergate,Deerchill,Fallpoint,Silvergulch,Cavemire,Deerbrook,Pinepond,Ravenside,Thornyard,Scorchstall,Swiftwell,Roguereach,Cloudwood,Smoothtown,Kilhill,Ironhollow,Stillhall,Rustmore,Ragefair,Ghostward,Deadford,Smallmire,Barebreak,Westforest,Bonemouth,Evercoast,Sleekgulch,Neverfront,Lostshield,Icelight,Quickgulch,Brinepeak,Hollowstorm,Limeband,Basinmore,Steepmoor,Blackford,Stormtide,Wildyard,Wolfpass,Houndburn,Pondfalls,Pureshell,Silvercairn,Houndwallow,Dewmere,Fearpeak,Bellstall,Diredale,Crowgrove,Moongulf,Kilholde,Sungulf,Baremore,Bleakwatch,Farrun,Grimeshire,Roseborn,Heartford,Scorchpost,Cloudbay,Whitlight,Timberham,Cloudmouth,Curseminster,Basinfrost,Maplevein,Sungarde,Cloudstar,Bellport,Silkwich,Ragehall,Bellreach,Swampmaw,Snakemere,Highbourne,Goldyard,Lakemond,Shadeville,Mightmouth,Nevercrest,Pinemount,Claymouth,Rosereach,Oldreach,Brittlehelm,Heartfall,Bonegulch,Silkhollow,Crystalgulf,Mutewell,Flameside,Blackwatch,Greenwharf,Moonacre,Beachwick,Littleborough,Castlefair,Stoneguard,Nighthall,Cragbury,Swanwall,Littlehall,Mudford,Shadeforest,Mightglen,Millhand,Easthill,Amberglen,Nighthall,Cragbury,Swanwall,Littlehall,Mudford,Shadeforest,Mightglen,Millhand,Easthill,Amberglen,Smoothcliff,Lakecross,Quicklight,Eaglecall,Silentkeep,Dragonshear,Ebonfront,Oakenmeadow,Cliffshield,Stormhorn,Cavefell,Wildedenn,Earthgate,Brittlecall,Swangarde,Steamwallow,Demonfall,Sleethallow,Mossstar,Dragonhold,Smoothgrove,Sleetrun,Flamewell,Mistvault,Heartvault,Newborough,Deeppoint,Littlehold,Westshell,Caveminster,Swiftshade,Grimwood,Littlemire,Bridgefalls,Lastmere,Fayyard,Madham,Curseguard,Earthpass,Silkbrook,Winterview,Grimeborough,Dustcross,Dogcoast,Dirtstall,Oxlight,Pondstall,Sleetglen,Ghostpeak,Snowshield,Loststar,Chillwharf,Sleettide,Millgulch,Whiteshore,Sunmond,Moonwell,Grassdrift,Westmeadow,Crowvault,Everchill,Bearmire,Bronzegrasp,Oxbrook,Cursefield,Steammouth,Smoothham,Arrowdenn,Stillstrand,Mudwich"},{name:"Elven",i:33,min:6,max:12,d:"lenmsrg",m:0,b:"Adrindest,Aethel,Afranthemar,Aggar,Aiqua,Alari,Allanar,Allanbelle,Almalian,Alora,Alyanasari,Alyelona,Alyran,Amenalenora,Ammar,Amymabelle,Ancalen,AnhAlora,Anore,Anyndell,Arasari,Aren,Ashesari,Ashletheas,Ashmebel,Asrannore,Athelle,Aymlume,Baethei,Bel-Didhel,Belanore,Borethanil,Brinorion,Caelora,Chaggaust,Chaulssad,Chaundra,ChetarIthlin,Cyhmel,Cyla,Cyonore,Cyrangroth,Doladress,Dolarith,Dolasea,Dolonde,Dorthore,Dorwine,Draethe,Dranzan,Draugaust,Dreghei,Drelhei,Dryndlu,E'ana,E'ebel,Eahil,Edhil,Edraithion,Efho,Efranluma,Efvanore,Einyallond,Elathlume,Eld-Sinnocrin,Elddrinn,Elelthyr,Elheinn,Ellanalin,Ellena,Ellheserin,Ellnlin,Ellorthond,Elralara,Elstyr,Eltaesi,Elunore,Eman,EmneLenora,Emyel,Emyranserine,Enhethyr,Ennore,Entheas,Eriargond,Erranlenor,ErrarIthinn,Esari,Esath,Eserius,Eshsalin,Eshthalas,Esseavad,Esyana,EsyseAiqua,Evraland,Faellenor,Faladhell,Famelenora,Fethalas,Filranlean,Filsaqua,Formarion,Ferdor,Gafetheas,GafSerine,Gansari,Geliene,Gondorwin,Guallu,Haeth,Hanluna,Haulssad,Helatheas,Hellerien,Heloriath,Himlarien,Himliene,Hinnead,Hlaughei,Hlinas,Hloireenil,Hluihei,Hluitar,Hlurthei,Hlynead,Iaenarion,Ifrennoris,IllaAncalen,Illanathaes,Illfanora,Imlarlon,Imyfaluna,Imyse,Imyvelian,Inferius,Inhalon,Inllune,Inlurth,innsshe,Inransera,Iralserin,Irethtalos,Irholona,Ishal,Ishlashara,Isyenshara,Ithelion,Iymerius,Iaron,Iulil,Jaal,Jamkadi,Kaalume,Kaansera,Kalthalas,Karanthanil,Karnosea,Kasethyr,Keatheas,Kelsya,KethAiqua,Kmlon,Kyathlenor,Kyhasera,Lahetheas,Lammydr,Lefdorei,Lelhamelle,Lelon,Lenora,Lilean,Lindoress,Lindeenil,Lirillaquen,Litys,Llaughei,Llurthei,Lya,Lyenalon,Lyfa,Lylharion,Lylmhil,Lynathalas,Lir,Machei,Masenoris,Mathathlona,Mathethil,Mathntheas,Meethalas,Melelume,Menyamar,Menzithl,Minthyr,Mithlonde,Mornetheas,Mytha,Mythnserine,Mythsemelle,Mythsthas,Myvanas,Naahona,Nalore,NasadIlaurth,Nasin,Nathemar,Navethas,Neadar,Neanor,Neilon,Nelalon,Nellean,Nelnetaesi,Nfanor,Nilenathyr,Nionande,Nurtaleewe,Nylm,Nytenanas,Nythanlenor,Nythfelon,Nythodorei,Nytlenor,Nidiel,Noruiben,O'anlenora,O'lalona,Obeth,Ofaenathyr,Oflhone,Ollethlune,Ollmarion,Ollmnaes,Ollsmel,Olranlune,Olyaneas,Olynahil,Omanalon,Omyselon,Onelion,Onelond,Onylanor,Orlormel,Orlynn,Ormrion,Oshana,Oshmahona,Oshvamel,Raethei,Raineas,Rauguall,Rauthe,Rauthei,Reisera,Reslenora,Rrharrvhei,Ryanasera,Rymaserin,Sahnor,Saselune,Sel-Zedraazin,Selananor,Sellerion,Selmaluma,Serin,Serine,Shaeras,Shemnas,Shemserin,Sheosari,Sileltalos,Siriande,Siriathil,Sohona,Srannor,Sshanntyr,Sshaulssin,Sshaulu,Syholume,Sylharius,Sylranbel,Symdorei,Syranbel,Szoberr,Silon,Taesi,Thalas,Thalor,Thalore,Tharenlon,Tharlarast,Thelethlune,Thelhohil,Thelnora,Themar,Thene,Thilfalean,Thilnaenor,Thvethalas,Thylathlond,Tiregul,Tirion,Tlauven,Tlindhe,Ulal,Ullallanar,Ullmatalos,Ullve,Ulmetheas,Ulrenserine,Ulssin,Umnalin,Umye,Umyheserine,Unanneas,Unarith,Undraeth,Unysarion,Vel-Shonidor,Venas,Vinargothr,Waethe,Wasrion,Wlalean,Y'maqua,Yaeluma,Yeelume,Yele,Yethrion,Ymserine,Yueghed,Yuereth,Yuerran,Yuethin,Nandeedil,Olwen,Yridhremben"},{name:"Dark Elven",i:34,min:6,max:14,d:"nrslamg",m:.2,b:"Abaethaggar,Abburth,Afranthemar,Aharasplit,Aidanat,Ald'ruhn,Ashamanu,Ashesari,Ashletheas,Baerario,Baereghel,Baethei,Bahashae,Balmora,Bel-Didhel,Borethanil,Buiyrandyn,Caellagith,Caellathala,Caergroth,Caldras,Chaggar,Chaggaust,Channtar,Charrvhel'raugaust,Chaulssin,Chaundra,ChedNasad,ChetarIthlin,ChethRrhinn,Chymaer,Clarkarond,Cloibbra,Commoragh,Cyrangroth,Cilben,D'eldarc,Daedhrog,Dalkyn,Do'Urden,Doladress,Dolarith,Dolonde,Draethe,Dranzan,Dranzithl,Draugaust,Dreghei,Drelhei,Dryndlu,Dusklyngh,DyonG'ennivalz,Edraithion,Eld-Sinnocrin,Ellorthond,Enhethyr,Entheas,ErrarIthinn,Eryndlyn,Faladhell,Faneadar,Fethalas,Filranlean,Formarion,Ferdor,Gafetheas,Ghrond,Gilranel,Glamordis,Gnaarmok,Gnisis,Golothaer,Gondorwin,Guallidurth,Guallu,Gulshin,Haeth,Haggraef,Harganeth,Harkaldra,Haulssad,Haundrauth,Heloriath,Hlammachar,Hlaughei,Hloireenil,Hluitar,Inferius,innsshe,Ithilaughym,Iz'aiogith,Jaal,Jhachalkhyn,Kaerabrae,Karanthanil,Karondkar,Karsoluthiyl,Kellyth,Khuul,Lahetheas,Lidurth,Lindeenil,Lirillaquen,LithMy'athar,LlurthDreier,Lolth,Lothuial,Luihaulen'tar,Maeralyn,Maerimydra,Mathathlona,Mathethil,Mellodona,Menagith,Menegwen,Menerrendil,Menzithl,Menzoberranzan,Mila-Nipal,Mithryn,Molagmar,Mundor,Myvanas,Naggarond,NasadIlaurth,Nauthor,Navethas,Neadar,Nurtaleewe,Nidiel,Noruiben,O'lalona,Obeth,Ofaenathyr,Orlormel,Orlytlar,Pelagiad,Raethei,Raugaust,Rauguall,Rilauven,Rrharrvhei,Sadrith,Sel-Zedraazin,Seydaneen,Shaz'rir,Skaal,Sschindylryn,Shamath,Shamenz,Shanntur,Sshanntynlan,Sshanntyr,Shaulssin,SzithMorcane,Szithlin,Szobaeth,Sirdhemben,T'lindhet,Tebh'zhor,Telmere,Telnarquel,Tharlarast,Thylathlond,Tlaughe,Trizex,Tyrybblyn,Ugauth,Ughym,Ullmatalos,Ulmetheas,Ulrenserine,Uluitur,Undraeth,Undraurth,Undrek'Thoz,Ungethal,UstNatha,V'elddrinnsshar,Vaajha,Vel-Shonidor,Velddra,Velothi,Venead,Vhalth'vha,Vinargothr,Vojha,Waethe,Waethei,Xaalkis,Yakaridan,Yeelume,Yuethin,Yuethindrynn,Zirnakaynin,Nandeedil,olwen,Uhaelben,Uthaessien,Yridhremben"},{name:"Dwarven",i:35,min:4,max:11,d:"dk",m:0,b:"Addundad,Ahagzad,Ahazil,Akil,Akzizad,Anumush,Araddush,Arar,Arbhur,Badushund,Baragzig,Baragzund,Barakinb,Barakzig,Barakzinb,Barakzir,Baramunz,Barazinb,Barazir,Bilgabar,Bilgatharb,Bilgathaz,Bilgila,Bilnaragz,Bilnulbar,Bilnulbun,Bizaddum,Bizaddush,Bizanarg,Bizaram,Bizinbiz,Biziram,Bunaram,Bundinar,Bundushol,Bundushund,Bundushur,Buzaram,Buzundab,Buzundush,Gabaragz,Gabaram,Gabilgab,Gabilgath,Gabizir,Gabunal,Gabunul,Gabuzan,Gatharam,Gatharbhur,Gathizdum,Gathuragz,Gathuraz,Gila,Giledzir,Gilukkhath,Gilukkhel,Gunala,Gunargath,Gunargil,Gundumunz,Gundusharb,Gundushizd,Kharbharbiln,Kharbhatharb,Kharbhela,Kharbilgab,Kharbuzadd,Khatharbar,Khathizdin,Khathundush,Khazanar,Khazinbund,Khaziragz,Khaziraz,Khizdabun,Khizdusharbh,Khizdushath,Khizdushel,Khizdushur,Kholedzar,Khundabiln,Khundabuz,Khundinarg,Khundushel,Khuragzig,Khuramunz,Kibarak,Kibilnal,Kibizar,Kibunarg,Kibundin,Kibuzan,Kinbadab,Kinbaragz,Kinbarakz,Kinbaram,Kinbizah,Kinbuzar,Nala,Naledzar,Naledzig,Naledzinb,Naragzah,Naragzar,Naragzig,Narakzah,Narakzar,Naramunz,Narazar,Nargabad,Nargabar,Nargatharb,Nargila,Nargundum,Nargundush,Nargunul,Narukthar,Narukthel,Nula,Nulbadush,Nulbaram,Nulbilnarg,Nulbunal,Nulbundab,Nulbundin,Nulbundum,Nulbuzah,Nuledzah,Nuledzig,Nulukkhaz,Nulukkhund,Nulukkhur,Sharakinb,Sharakzar,Sharamunz,Sharbarukth,Shatharbhizd,Shatharbiz,Shathazah,Shathizdush,Shathola,Shaziragz,Shizdinar,Shizdushund,Sholukkharb,Shundinulb,Shundushund,Shurakzund,Shuramunz,Tumunzadd,Tumunzan,Tumunzar,Tumunzinb,Tumunzir,Ukthad,Ulbirad,Ulbirar,Ulunzar,Ulur,Umunzad,Undalar,Undukkhil,Undun,Undur,Unduzur,Unzar,Unzathun,Usharar,Zaddinarg,Zaddushur,Zaharbad,Zaharbhizd,Zarakib,Zarakzar,Zaramunz,Zarukthel,Zinbarukth,Zirakinb,Zirakzir,Ziramunz,Ziruktharbh,Zirukthur,Zundumunz"},{name:"Goblin",i:36,min:4,max:9,d:"eag",m:0,b:"Crild,Cielb,Srurd,Fruict,Xurx,Crekork,Strytzakt,Ialsirt,Gnoklig,Kleardeek,Gobbledak,Thelt,Swaxi,Ulm,Shaxi,Thult,Jasheafta,Kleabtong,Bhiagielt,Kuipuinx,Hiszils,Nilbog,Gneabs,Stiolx,Esz,Honk,Veekz,Vohniots,Bratliaq,Slehzit,Diervaq,Zriokots,Buyagh,Treaq,Phax,Ilm,Blus,Srefs,Biokvish,Gigganqi,Watvielx,Katmelt,Slofboif,gobbok,Klilm,Blix,Qosx,Fygsee,Moft,Asinx,Joimtoilm,Styrzangai,Prolkeh,Stioskurt,Mogg,Cel,Far,Rekx,Chalk,Paas,Brybsil,Utiarm,Eebligz,Iahzaarm,Stuikvact,Gobbrin,Ish,Suirx,Utha,Taxai,Onq,Stiaggaltia,Dobruing,Breshass,Cosvil,Traglila,Felhob,Hobgar,Preang,Sios,Wruilt,Chox,Pyreazzi,Glamzofs,Froihiofz,Givzieqee,Vreagaald,Bugbig,Kluirm,Ulb,Driord,Stroir,Croibieq,Bridvelb,Wrogdilk,Slukex,Ozbiard,Gagablin,Heszai,Kass,Chiafzia,Thresxea,Een,Oimzoishai,Enissee,Glernaahx,Qeerags,Phigheldai,Ziggek"},{name:"Orc",i:37,min:4,max:8,d:"gzrcu",m:0,b:"ModhOdod,BodRugniz,Rildral,Zalbrez,Bebugh,Grurro,Ibruzzed,Goccogmurd,CheganKhed,BedgezGraz,IkhUgnan,NoGolkon,Dhezza,Chuccuz,Dribor,Khezdrugh,Uzdriboz,Nolgazgredh,KrogvurOz,ZrucraBi,ErLigvug,OkhUggekh,Vrobrun,Raggird,Adgoz,Chugga,Ghagrocroz,Khuldrerradh,IrmekhBhor,KuzgrurdDedh,ZunBergrord,AdhKhorkol,Alzokh,Mubror,Bozdra,Brugroz,Nuzecro,Qidzodkakh,GharedKrin,OrkudhBhur,EkhKrerdrugh,KrarZurmurd,Nuccag,Rezegh,Lorgran,Grergran,Nadguggez,Mocculdrer,BrorkrilZrog,RurguzVig,CharRodkeg,UghBhelgag,Zulbriz,Rodrekh,Erbragh,Bhicrur,Arkugzo,Arrordri,MiccolBurd,OddighKrodh,UghVruron,VrughNardrer,Dhoddud,Murmad,Chuzar,Vrazin,Ridgozedh,Lazzogno,MughakhChil,VrolburNur,KrighBhurdin,GhadhDrurzan,Adran,Chazgro,Krorgrug,Grodzakh,Ugrudraz,Iggulzaz,KudrukhLi,QuccuBan,GrighKaggaz,ArdGrughokh,Zolbred,Drozgrir,Agkadh,Zuggedh,Lulkore,Dhulbazzol,DhazonNer,ZrazzuzVaz,BrurKorre,EkhMezred,Vaddog,Drirdradh,Qashnagh,Arad,Zadarord,Khorbriccord,NelzorZroz,DruccoRad,DhodhBrerdrodh,BhakhZradgukh,Qirrer,Uzord,Bulbredh,Khuzdraz,Churgrorgadh,Legvicrodh,GazdrakhVrard,VagordKhod,GidhUcceg,BhogKirgol,Brogved,Aga,Kudzal,Brolzug,Ughudadh,Noshnogradh,ZubodUr,ZrulbukhDekh,ReVurkog,RoghChirzaz,Kharkiz,Bhogug,Bozziz,Vuccidh,Ruddirgrad,Zordrordud,GrirkrunQur,IbulBrad,AdAdzurd,GaghDruzred,Acran,Morbraz,Drurgin,Chogidh,Nogvolkar,Uzaggor,KazzuzZrar,ArrulChukh,DiChudun,GhoUgnud,Uzron,Uzdroz,Gholgard,Zragmukh,Qiddolzog,Reradgri,QiccadChal,NubudId,ZrardKrodog,KrudhKhogzokh,Vizdrun,Orrad,Darmon,Ulkin,Zigmorbredh,Bizzadurd,MuccugGhuz,MabraghBhard,DurKhaddol,BheghGegnod,Qazzudh,Drobagh,Zorrudh,Dodkakh,Gribrabrokh,Quggidkad,DududhAkh,DrizdedhAd,GhordBhozdrokh,ZadEzzedh,Larud,Ashnedh,Gridkog,Qirzodh,Bhirgoshbel,Ghirmarokh,ArizDru,AgzilGhal,DrodhAshnugh,UghErrod,Lugekh,Buccel,Rarurd,Verrugh,Qommorbrord,Bagzildre,NazadLudh,IbaghChol,GrazKhulgag,QigKrorkodh,Rozzez,Koggodh,Ruzgrin,Zrigud,Zragrizgrakh,Irdrelzug,VrurzarMol,KezulBruz,GurGhogkagh,KigRadkodh,Ulgor,Kroddadh,Eldrird,Bozgrun,Digzagkigh,Azrurdrekh,KhuzdordDugh,DhurkighGrer,MeGheggor,KoGerkradh,Bashnud,Nirdrukh,Adog,Egmod,Vruzzegvukh,Nagrubagh,DugkegVuz,MorkirZrudh,NudhKuldra,DhodhGhigin,Graldrodh,Rero,Merkraz,Ummo,Largraragh,Brordeggeg,UldrukhBhudh,DregvekhOg,GughZozgrod,GhidZrogiz,Khebun,Ordol,Ghadag,Dredagh,Bhiccozdur,Chizeril,KarkorZrid,EmmanMaz,LiBogzel,EkhBeccon,Dashnukh,Kacruz,Krummel,Dirdrurd,Khalbammedh,Dhizdrermodh,GharuZrug,BhurkrukhLen,ZuZredzokh,BralLazogh,Velgrudh,Dorgri,Irbraz,Udral,Bigkurel,Zarralkod,DhoggunBhogh,AdgrilGha,DrukhQodgoz,KaNube,Vrurgu,Mazgar,Lalga,Bolkan,Kudgroccukh,Zraldrozzuz,VorordUz,ZacradLe,BrukhZrabrul,GagDrugmag,Kraghird,Bhummagh,Brazadh,Kalbrugh,Brogzozir,Mugmodror,RezgrughErd,UmmughEkh,GuNuccul,VunGaghukh,Ghizgil,Arbran,Bulgragh,Negvidh,Girodgrurd,Ghedgrolbrol,DrogvukhDrodh,DhalgronMog,MulDhazzug,ChazCharard,Drurkuz,Niddeg,Bagguz,Ogkal,Rordrushnokh,Gorkozzil,KorkrirGrar,RigaghZrad"},{name:"Giant",i:38,min:5,max:10,d:"kdtng",m:0,b:"Kostand,Throtrek,Solfod,Shurakzund,Heimfara,Anumush,Dulkun,Sigbeorn,Velhera,Glumvat,Khundinarg,Shathizdush,Baramunz,Nargunul,Magald,Noluch,Yotane,Tumunzar,Giledzir,Nurkel,Khizdabun,Yudgor,Hartreo,Galfald,Vigkan,Kibarak,Girkun,Gomruch,Guddud,Darnaric,Botharic,Gunargath,Oldstin,Rizen,Marbold,Nargundush,Hargarth,Kengord,Maerdis,Brerstin,Sigbi,Zigez,Umunzad,Nelkun,Yili,Usharar,Ranhera,Mistoch,Nuledzah,Nulbilnarg,Nulukkhur,Tulkug,Kigine,Marbrand,Gagkake,Khathizdin,Geru,Nagu,Grimor,Kaltoch,Koril,Druguk,Khatharbar,Debuch,Eraddam,Neliz,Brozu,Morluch,Enuz,Gatal,Beratira,Gurkale,Gluthmark,Iora,Tozage,Agane,Kegkez,Nuledzig,Bahourg,Jornangar,Kilfond,Dankuc,Rurki,Eldond,Barakzig,Olane,Gostuz,Grimtira,Brildung,Nulbaram,Nargabar,Narazar,Natan,oci,Khaziragz,Gabuzan,Orga,Addundad,Yulkake,Nulukkhaz,Bundushund,Guril,Barakinb,Sadgach,Vylwed,Vozig,Hildlaug,Chergun,Dagdhor,Kibizar,Shundushund,Mornkin,Jaldhor,inez,Lingarth,Churtec,Naragzah,Gabizir,Zugke,Ranava,Minu,Barazinb,Fynwyn,Talkale,Widhyrde,Sidga,Velfirth,Varkud,Shathola,Duhal,Srokvan,Guruge,Lindira,Rannerg,Kilkan,Gudgiz,Baragzund,Aerora,Inginy,Kharbharbiln,Theoddan,Rirkan,Undukkhil,Borgbert,Dina,Gortho,Kinbuzar,Kuzake,Drard,Gorkege,Nargatharb,Diru,Shatharbiz,Sgandrol,Sharakzar,Barakzinb,Dinez,Jarwar,Khizdushel,Wylaeya,Khazanar,Beornelde,Arangrim,Sholukkharb,Stighere,Gulwo,Irkin,Jornmoth,Gundusharb,Gabaram,Shizdinar,Memron,Guzi,Naramunz,Morntaric,Somrud,Norginny,Bremrol,Rurkoc,Zugkan,Vorkige,Kinbadab,Gila,Sulduch,Natil,Idgurth,Gabaragz,Tolkeg,Eradhelm,Dugfast,Froththorn,Galgrim,Theodgrim,Valdhere,Gazin,Tigkiz,Burthug,Chazruc,Kakkek,Toren"},{name:"Draconic",i:39,min:6,max:14,d:"aliuszrox",m:0,b:"Aaronarra,Adalon,Adamarondor,Aeglyl,Aerosclughpalar,Aghazstamn,Aglaraerose,Agoshyrvor,Alduin,Alhazmabad,Altagos,Ammaratha,Amrennathed,Anaglathos,Andrathanach,Araemra,Araugauthos,Arauthator,Arharzel,Arngalor,Arveiaturace,Athauglas,Augaurath,Auntyrlothtor,Azarvilandral,Azhaq,Balagos,Baratathlaer,Bleucorundum,BrazzPolis,Canthraxis,Capnolithyl,Charvekkanathor,Chellewis,Chelnadatilar,Cirrothamalan,Claugiyliamatar,Cragnortherma,Dargentum,Dendeirmerdammarar,Dheubpurcwenpyl,Domborcojh,Draconobalen,Dragansalor,Dupretiskava,Durnehviir,Eacoathildarandus,Eldrisithain,Enixtryx,Eormennoth,Esmerandanna,Evenaelorathos,Faenphaele,Felgolos,Felrivenser,Firkraag,Fll'Yissetat,Furlinastis,Galadaeros,Galglentor,Garnetallisar,Garthammus,Gaulauntyr,Ghaulantatra,Glouroth,Greshrukk,Guyanothaz,Haerinvureem,Haklashara,Halagaster,Halaglathgar,Havarlan,Heltipyre,Hethcypressarvil,Hoondarrh,Icehauptannarthanyx,Iiurrendeem,Ileuthra,Iltharagh,Ingeloakastimizilian,Irdrithkryn,Ishenalyr,Iymrith,Jaerlethket,Jalanvaloss,Jhannexydofalamarne,Jharakkan,Kasidikal,Kastrandrethilian,Khavalanoth,Khuralosothantar,Kisonraathiisar,Kissethkashaan,Kistarianth,Klauth,Klithalrundrar,Krashos,Kreston,Kriionfanthicus,Krosulhah,Krustalanos,Kruziikrel,Kuldrak,Lareth,Latovenomer,Lhammaruntosz,Llimark,Ma'fel'no'sei'kedeh'naar,MaelestorRex,Magarovallanthanz,Mahatnartorian,Mahrlee,Malaeragoth,Malagarthaul,Malazan,Maldraedior,Maldrithor,MalekSalerno,Maughrysear,Mejas,Meliordianix,Merah,Mikkaalgensis,Mirmulnir,Mistinarperadnacles,Miteach,Mithbarazak,Morueme,Moruharzel,Naaslaarum,Nahagliiv,Nalavarauthatoryl,Naxorlytaalsxar,Nevalarich,Nolalothcaragascint,Nurvureem,Nymmurh,Odahviing,Olothontor,Ormalagos,Otaaryliakkarnos,Paarthurnax,Pelath,Pelendralaar,Praelorisstan,Praxasalandos,Protanther,Qiminstiir,Quelindritar,Ralionate,Rathalylaug,Rathguul,Rauglothgor,Raumorthadar,Relonikiv,Ringreemeralxoth,Roraurim,Ruuthundrarar,Rylatar'ralah'tyma,Rynnarvyx,Sablaxaahl,Sahloknir,Sahrotaar,Samdralyrion,Saryndalaghlothtor,Sawaka,Shalamalauth,Shammagar,Sharndrel,Shianax,Skarlthoon,Skurge,Smergadas,Ssalangan,Sssurist,Sussethilasis,Sylvallitham,Tamarand,Tantlevgithus,Taraunramorlamurla,Tarlacoal,Tenaarlaktor,Thalagyrt,Tharas'kalagram,Thauglorimorgorus,Thoklastees,Thyka,Tsenshivah,Ueurwen,Uinnessivar,Urnalithorgathla,Velcuthimmorhar,Velora,Vendrathdammarar,Venomindhar,Viinturuth,Voaraghamanthar,Voslaarum,Vr'tark,Vrondahorevos,Vuljotnaak,Vulthuryol,Wastirek,Worlathaugh,Xargithorvar,Xavarathimius,Yemere,Ylithargathril,Ylveraasahlisar,Za-Jikku,Zarlandris,Zellenesterex,Zilanthar,Zormapalearath,Zundaerazylym,Zz'Pzora"},{name:"Arachnid",i:40,min:4,max:10,d:"erlsk",m:0,b:"Aaqok'ser,Acah,Aiced,Aisi,Aizachis,Allinqel,As'taq,Ashrash,Caaqtos,Caq'zux,Ceek'sax,Ceezuq,Cek'siereel,Cen'qi,Ceqru,Ceqzocer,Cezeed,Chachocaq,Charis,Chashar,Chashilieth,Checib,Chen'qal,Chernul,Cherzoq,Chezi,Chiazu,Chikoqal,Chishros,Chixhi,Chizhi,Chizoser,Chollash,Choq'sha,Chouk'rix,Cinchichail,Collul,Ecush'taid,Eenqachal,Ekiqe,El'zos,El'zur,Ellu,Eq'tur,Eqa,Eqas,Er'uria,Erikas,Ertu,Es'tase,Esrub,Evirrot,Exha,Haqsho,Heekath,Hiavheesh,Hitha,Hok'thi,Hossa,Iacid,Iciever,Ik'si,Illuq,Iri,Isicer,Isnir,Ivrid,Kaalzux,Keezut,Kheellavas,Kheizoh,Khellinqesh,Khiachod,Khika,Khinchi,Khirzur,Khivila,Khonrud,Khontid,Khosi,Khrakku,Khraqshis,Khrerrith,Khrethish'ti,Khriashus,Khrika,Khrirni,Khrocoqshesh,Klashirel,Klassa,Kleil'sha,Kliakis,Klishuth,Klith'osha,Krarnit,Kras'tex,Kreelzi,Krivas,Krotieqas,Laco,Lairta,Lais'tid,Laizuh,Lasnoth,Lekkol,Len'qeer,Leqanches,Lezad,Lhezsi,Lhilir,Lhivhath,Lhok'thu,Lialliesed,Liaraq,Liarisriq,Liceva,Lichorro,Lilla,Livorzish,Lokieqib,Nakar,Nakur,Naros,Natha,Necuk'saih,Neerhaca,Neet'er,Neezoh,Nenchiled,Nerhalneth,Nir'ih,Nizus,Noreeqo,Novalsher,On'qix,Qailloncho,Qak'sovo,Qalitho,Qartori,Qas'tor,Qasol,Qavrud,Qavud,Qazar,Qazieveq,Qazru,Qeik'thoth,Qekno,Qeqravee,Qes'tor,Qhaaviq,Qhaik'sal,Qhak'sish,Qhazsakais,Qhechorte,Qheliva,Qhenchaqes,Qherazal,Qhesoh,Qhiallud,Qhon'qos,Qhoshielleed,Qish'tur,Qisih,Qollal,Qorhoci,Qouxet,Qranchiq,Racith,Rak'zes,Ranchis,Rarhie,Rarzi,Rarzisiaq,Ras'tih,Ravosho,Recad,Rekid,Relshacash,Reqishee,Rernee,Rertachis,Rezhokketh,Reziel,Rhacish,Rhail'shel,Rhairhizse,Rhakivex,Rhaqeer,Rhartix,Rheciezsei,Rheevid,Rhel'shir,Rhetovraix,Rhevhie,Rhialzub,Rhiavekot,Rhikkos,Rhiqese,Rhiqi,Rhiqracar,Rhisned,Rhokno,Rhousnateb,Rhouvaqid,Riakeesnex,Rik'sid,Rintachal,Rir'ul,Rorrucis,Rosharhir,Rourk'u,Rouzakri,Sailiqei,Sanchiqed,Sanqad,Saqshu,Sat'ier,Sazi,Seiqas,Shieth'i,Shiqsheh,Shizha,Shrachuvo,Shranqo,Shravhos,Shravuth,Shreerhod,Shrethuh,Shriantieth,Shronqash,Shrovarhir,Shrozih,Siacaqoh,Siezosh,Silrul,Siq'sha,Sirro,Sornosi,Srachussi,Sreqrud,Srirnukaaq,Szaca,Szacih,Szaqova,Szasu,Szazhilos,Szeerrud,Szeezsad,Szeknur,Szesir,Szet'as,Szetirrar,Szezhirros,Szilshith,Szon'qol,Szornuq,Xaax'uq,Xeekke,Xosax,Yaconchi,Yacozses,Yazrer,Yeek'su,Yeeq'zox,Yeqil,Yeqroq,Yeveed,Yevied,Yicaveeh,Yirresh,Yisie,Yithik'thaih,Yorhaqshes,Zacheek'sa,Zakkasa,Zaqi,Zelraq,Zeqo,Zhaivoq,Zharuncho,Zhath'arhish,Zhavirrit,Zhazilraq,Zhazot,Zhazsachiel,Zhek'tha,Zhequ,Zhias'ted,Zhicat,Zhicur,Zhiese,Zhirhacil,Zhizri,Zhochizses,Zhorkir,Ziarih,Zirnib,Zis'teq,Zivezeh"},{name:"Serpents",i:41,min:5,max:11,d:"slrk",m:0,b:"Aj'ha,Aj'i,Aj'tiss,Ajakess,Aksas,Aksiss,Al'en,An'jeshe,Apjige,Arkkess,Athaz,Atus,Azras,Caji,Cakrasar,Cal'arrun,Capji,Cathras,Cej'han,Ces,Cez'jenta,Cij'te,Cinash,Cizran,Coth'jus,Cothrash,Culzanek,Cunaless,Ej'tesh,Elzazash,Ergek,Eshjuk,Ethris,Gan'jas,Gapja,Gar'thituph,Gopjeguss,Gor'thesh,Gragishaph,Grar'theness,Grath'ji,Gressinas,Grolzesh,Grorjar,Grozrash,Guj'ika,Harji,Hej'hez,Herkush,Horgarrez,Illuph,Ipjar,Ithashin,Kaj'ess,Kar'kash,Kepjusha,Ki'kintus,Kissere,Koph,Kopjess,Kra'kasher,Krak,Krapjez,Krashjuless,Kraz'ji,Krirrigis,Krussin,Ma'lush,Mage,Maj'tak,Mal'a,Mapja,Mar'kash,Mar'kis,Marjin,Mas,Mathan,Men'jas,Meth'jaresh,Mij'hegak,Min'jash,Mith'jas,Monassu,Moss,Naj'hass,Najugash,Nak,Napjiph,Nar'ka,Nar'thuss,Narrusha,Nash,Nashjekez,Nataph,Nij'ass,Nij'tessiph,Nishjiss,Norkkuss,Nus,Olluruss,Or'thi,Or'thuss,Paj'a,Parkka,Pas,Pathujen,Paz'jaz,Pepjerras,Pirkkanar,Pituk,Porjunek,Pu'ke,Ragen,Ran'jess,Rargush,Razjuph,Rilzan,Riss,Rithruz,Rorgiss,Rossez,Rraj'asesh,Rraj'tass,Rrar'kess,Rrar'thuph,Rras,Rrazresh,Rrej'hish,Rrigelash,Rris,Rris,Rroksurrush,Rukrussush,Rurri,Russa,Ruth'jes,Sa'kitesh,Sar'thass,Sarjas,Sazjuzush,Ser'thez,Sezrass,Shajas,Shas,Shashja,Shass,Shetesh,Shijek,Shun'jaler,Shurjarri,Skaler,Skalla,Skallentas,Skaph,Skar'kerriz,Skath'jeruk,Sker'kalas,Skor,Skoz'ji,Sku'lu,Skuph,Skur'thur,Slalli,Slalt'har,Slelziress,Slil'ar,Sloz'jisa,Sojesh,Solle,Sorge,Sral'e,Sran'ji,Srapjess,Srar'thazur,Srash,Srath'jess,Srathrarre,Srerkkash,Srus,Sruss'tugeph,Sun,Suss'tir,Uzrash,Vargush,Vek,Vess'tu,Viph,Vult'ha,Vupjer,Vushjesash,Xagez,Xassa,Xulzessu,Zaj'tiss,Zan'jer,Zarriss,Zassegus,Zirres,Zsor,Zurjass"}]},getMapName:A,calculateChain:t}}();window.Biomes=function(){return{getDefault:()=>{const t=["Marine","Hot desert","Cold desert","Savanna","Grassland","Tropical seasonal forest","Temperate deciduous forest","Tropical rainforest","Temperate rainforest","Taiga","Tundra","Glacier","Wetland"],n=["#466eab","#fbe79f","#b5b887","#d2d082","#c8d68f","#b6d95d","#29bc56","#7dcb35","#409c43","#4b6b32","#96784b","#d5e7eb","#0b9131"],i=[0,4,10,22,30,50,100,80,90,12,4,0,12],r=[0,3,2,120,120,120,120,150,150,100,5,0,150],c=[{},{dune:3,cactus:6,deadTree:1},{dune:9,deadTree:1},{acacia:1,grass:9},{grass:1},{acacia:8,palm:1},{deciduous:1},{acacia:5,palm:3,deciduous:1,swamp:1},{deciduous:6,swamp:1},{conifer:1},{grass:1},{},{swamp:1}],f=[10,200,150,60,50,70,70,80,90,200,1e3,5e3,150],z=[new Uint8Array([1,1,1,1,1,1,1,1,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,10]),new Uint8Array([3,3,3,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,9,9,9,9,10,10,10]),new Uint8Array([5,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,9,9,9,9,9,10,10,10]),new Uint8Array([5,6,6,6,6,6,6,8,8,8,8,8,8,8,8,8,8,9,9,9,9,9,9,10,10,10]),new Uint8Array([7,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,9,9,9,9,9,9,9,10,10])];for(let m=0;m<c.length;m++){const b=[];for(const A in c[m])for(let u=0;u<c[m][A];u++)b.push(A);c[m]=b}return{i:d3.range(0,t.length),name:t,color:n,biomesMartix:z,habitability:i,iconsDensity:r,icons:c,cost:f}}}}();const Qe=window.d3,qn=["#dababf","#fb8072","#80b1d3","#fdb462","#b3de69","#fccde5","#c6b9c1","#bc80bd","#ccebc5","#ffed6f","#8dd3c7","#eb8de7"];function va(e){const t=Qe.scaleSequential(Qe.interpolateRainbow);return Qe.shuffle(Qe.range(e).map(i=>i<12?qn[i]:Qe.color(t((i-12)/(e-12))).hex()))}function Ct(){return Qe.color(Qe.scaleSequential(Qe.interpolateRainbow)(Math.random())).hex()}function tt(e,t=.2,n=.3){const i=e&&e[0]==="#"?e:Ct(),r=Ct(),c=Qe.interpolate(i,r)(t);return Qe.color(c).brighter(n).hex()}window.Cultures=function(){let e;const t=function(){Q&&console.time("generateCultures"),e=pack.cells,e.culture=new Uint16Array(e.i.length);let A=Math.min(+culturesInput.value,+culturesSet.selectedOptions[0].dataset.max);const u=e.i.filter(a=>e.s[a]);if(u.length<A*25)if(A=Math.floor(u.length/50),A)WARN&&console.warn(`Not enough populated cells (${u.length}). Will generate only ${A} cultures`),alertMessage.innerHTML=` There are only ${u.length} populated cells and it's insufficient livable area.<br />
Only ${A} out of ${culturesInput.value} requested cultures will be generated.<br />
Please consider changing climate settings in the World Configurator`,$("#alert").dialog({resizable:!1,title:"Extreme climate warning",buttons:{Ok:function(){$(this).dialog("close")}}});else{WARN&&console.warn("There are no populated cells. Cannot generate cultures"),pack.cultures=[{name:"Wildlands",i:0,base:1,shield:"round"}],alertMessage.innerHTML=` The climate is harsh and people cannot live in this world.<br />
No cultures, states and burgs will be created.<br />
Please consider changing climate settings in the World Configurator`,$("#alert").dialog({resizable:!1,title:"Extreme climate warning",buttons:{Ok:function(){$(this).dialog("close")}}});return}const C=pack.cultures=s(A),g=d3.quadtree(),p=va(A),B=document.getElementById("emblemShape").value,k=[];C.forEach(function(a,w){const S=a.center=d(a.sort?a.sort:h=>e.s[h]);g.add(e.p[S]),a.i=w+1,delete a.odd,delete a.sort,a.color=p[w],a.type=o(S),a.expansionism=l(a.type),a.origins=[0],a.code=bt(a.name,k),k.push(a.code),e.culture[S]=w+1,B==="random"&&(a.shield=b())});function d(a){let w,S=(graphWidth+graphHeight)/2/A;const h=[...u].sort((E,P)=>a(P)-a(E)),v=Math.floor(h.length/2);do w=h[Ot(0,v,5)],S*=.9;while(g.find(e.p[w][0],e.p[w][1],S)!==void 0);return w}C.unshift({name:"Wildlands",i:0,base:1,origins:[null],shield:"round"}),nameBases.length||(ERROR&&console.error("Name base is empty, default nameBases will be applied"),nameBases=Names.getNameBases()),C.forEach(a=>a.base=a.base%nameBases.length);function s(a){let w=i(a);if(a===w.length)return w;if(w.every(v=>v.odd===1))return w.splice(0,a);const S=Math.min(a,w.length),h=[];for(let v,E,P=0;h.length<S&&P<200;P++){do E=be(w.length-1),v=w[E];while(!V(v.odd));h.push(v),w.splice(E,1)}return h}function o(a){if(e.h[a]<70&&[1,2,4].includes(e.biome[a]))return"Nomadic";if(e.h[a]>50)return"Highland";const w=pack.features[e.f[e.haven[a]]];return w.type==="lake"&&w.cells>5?"Lake":e.harbor[a]&&w.type!=="lake"&&V(.1)||e.harbor[a]===1&&V(.6)||pack.features[e.f[a]].group==="isle"&&V(.4)?"Naval":e.r[a]&&e.fl[a]>100?"River":e.t[a]>2&&[3,7,8,9,10,12].includes(e.biome[a])?"Hunting":"Generic"}function l(a){let w=1;return a==="Lake"?w=.8:a==="Naval"?w=1.5:a==="River"?w=.9:a==="Nomadic"?w=1.5:a==="Hunting"?w=.7:a==="Highland"&&(w=1.2),O((Math.random()*powerInput.value/2+1)*w,1)}Q&&console.timeEnd("generateCultures")},n=function(A){const u=i();let C,g,p;pack.cultures.length<u.length?(C=pack.cultures.length,g=u[C].base,p=u[C].name):(C=be(pack.cultures.length-1),p=Names.getCulture(C,5,8,""),g=pack.cultures[C].base);const B=bt(p,pack.cultures.map(l=>l.code)),k=pack.cultures.length,d=d3.color(d3.scaleSequential(d3.interpolateRainbow)(Math.random())).hex();let s=C.shield;document.getElementById("emblemShape").value==="random"&&(s=b()),pack.cultures.push({name:p,color:d,base:g,center:A,i:k,expansionism:1,type:"Generic",cells:0,area:0,rural:0,urban:0,origins:[0],code:B,shield:s})},i=function(A){const u=pack.cells,C=u.s,g=d3.max(C),p=u.t,B=u.h,k=grid.cells.temp,d=a=>Math.ceil(C[a]/g*3),s=(a,w)=>{const S=Math.abs(k[u.g[a]]-w);return S?S+1:1},o=(a,w,S=4)=>w.includes(u.biome[a])?1:S,l=(a,w=4)=>u.haven[a]&&pack.features[u.f[u.haven[a]]].type!=="lake"?1:w;if(culturesSet.value==="european")return[{name:"Shwazen",base:0,odd:1,sort:a=>d(a)/s(a,10)/o(a,[6,8]),shield:"swiss"},{name:"Angshire",base:1,odd:1,sort:a=>d(a)/s(a,10)/l(a),shield:"wedged"},{name:"Luari",base:2,odd:1,sort:a=>d(a)/s(a,12)/o(a,[6,8]),shield:"french"},{name:"Tallian",base:3,odd:1,sort:a=>d(a)/s(a,15),shield:"horsehead"},{name:"Astellian",base:4,odd:1,sort:a=>d(a)/s(a,16),shield:"spanish"},{name:"Slovan",base:5,odd:1,sort:a=>d(a)/s(a,6)*p[a],shield:"polish"},{name:"Norse",base:6,odd:1,sort:a=>d(a)/s(a,5),shield:"heater"},{name:"Elladan",base:7,odd:1,sort:a=>d(a)/s(a,18)*B[a],shield:"boeotian"},{name:"Romian",base:8,odd:.2,sort:a=>d(a)/s(a,15)/p[a],shield:"roman"},{name:"Soumi",base:9,odd:1,sort:a=>d(a)/s(a,5)/o(a,[9])*p[a],shield:"pavise"},{name:"Portuzian",base:13,odd:1,sort:a=>d(a)/s(a,17)/l(a),shield:"renaissance"},{name:"Vengrian",base:15,odd:1,sort:a=>d(a)/s(a,11)/o(a,[4])*p[a],shield:"horsehead2"},{name:"Turchian",base:16,odd:.05,sort:a=>d(a)/s(a,14),shield:"round"},{name:"Euskati",base:20,odd:.05,sort:a=>d(a)/s(a,15)*B[a],shield:"oldFrench"},{name:"Keltan",base:22,odd:.05,sort:a=>d(a)/s(a,11)/o(a,[6,8])*p[a],shield:"oval"}];if(culturesSet.value==="oriental")return[{name:"Koryo",base:10,odd:1,sort:a=>d(a)/s(a,12)/p[a],shield:"round"},{name:"Hantzu",base:11,odd:1,sort:a=>d(a)/s(a,13),shield:"banner"},{name:"Yamoto",base:12,odd:1,sort:a=>d(a)/s(a,15)/p[a],shield:"round"},{name:"Turchian",base:16,odd:1,sort:a=>d(a)/s(a,12),shield:"round"},{name:"Berberan",base:17,odd:.2,sort:a=>d(a)/s(a,19)/o(a,[1,2,3],7)*p[a],shield:"oval"},{name:"Eurabic",base:18,odd:1,sort:a=>d(a)/s(a,26)/o(a,[1,2],7)*p[a],shield:"oval"},{name:"Efratic",base:23,odd:.1,sort:a=>d(a)/s(a,22)*p[a],shield:"round"},{name:"Tehrani",base:24,odd:1,sort:a=>d(a)/s(a,18)*B[a],shield:"round"},{name:"Maui",base:25,odd:.2,sort:a=>d(a)/s(a,24)/l(a)/p[a],shield:"vesicaPiscis"},{name:"Carnatic",base:26,odd:.5,sort:a=>d(a)/s(a,26),shield:"round"},{name:"Vietic",base:29,odd:.8,sort:a=>d(a)/s(a,25)/o(a,[7],7)/p[a],shield:"banner"},{name:"Guantzu",base:30,odd:.5,sort:a=>d(a)/s(a,17),shield:"banner"},{name:"Ulus",base:31,odd:1,sort:a=>d(a)/s(a,5)/o(a,[2,4,10],7)*p[a],shield:"banner"}];if(culturesSet.value==="english"){const a=()=>Names.getBase(1,5,9,"",0);return[{name:a(),base:1,odd:1,shield:"heater"},{name:a(),base:1,odd:1,shield:"wedged"},{name:a(),base:1,odd:1,shield:"swiss"},{name:a(),base:1,odd:1,shield:"oldFrench"},{name:a(),base:1,odd:1,shield:"swiss"},{name:a(),base:1,odd:1,shield:"spanish"},{name:a(),base:1,odd:1,shield:"hessen"},{name:a(),base:1,odd:1,shield:"fantasy5"},{name:a(),base:1,odd:1,shield:"fantasy4"},{name:a(),base:1,odd:1,shield:"fantasy1"}]}return culturesSet.value==="antique"?[{name:"Roman",base:8,odd:1,sort:a=>d(a)/s(a,14)/p[a],shield:"roman"},{name:"Roman",base:8,odd:1,sort:a=>d(a)/s(a,15)/l(a),shield:"roman"},{name:"Roman",base:8,odd:1,sort:a=>d(a)/s(a,16)/l(a),shield:"roman"},{name:"Roman",base:8,odd:1,sort:a=>d(a)/s(a,17)/p[a],shield:"roman"},{name:"Hellenic",base:7,odd:1,sort:a=>d(a)/s(a,18)/l(a)*B[a],shield:"boeotian"},{name:"Hellenic",base:7,odd:1,sort:a=>d(a)/s(a,19)/l(a)*B[a],shield:"boeotian"},{name:"Macedonian",base:7,odd:.5,sort:a=>d(a)/s(a,12)*B[a],shield:"round"},{name:"Celtic",base:22,odd:1,sort:a=>d(a)/s(a,11)**.5/o(a,[6,8]),shield:"round"},{name:"Germanic",base:0,odd:1,sort:a=>d(a)/s(a,10)**.5/o(a,[6,8]),shield:"round"},{name:"Persian",base:24,odd:.8,sort:a=>d(a)/s(a,18)*B[a],shield:"oval"},{name:"Scythian",base:24,odd:.5,sort:a=>d(a)/s(a,11)**.5/o(a,[4]),shield:"round"},{name:"Cantabrian",base:20,odd:.5,sort:a=>d(a)/s(a,16)*B[a],shield:"oval"},{name:"Estian",base:9,odd:.2,sort:a=>d(a)/s(a,5)*p[a],shield:"pavise"},{name:"Carthaginian",base:17,odd:.3,sort:a=>d(a)/s(a,19)/l(a),shield:"oval"},{name:"Mesopotamian",base:23,odd:.2,sort:a=>d(a)/s(a,22)/o(a,[1,2,3]),shield:"oval"}]:culturesSet.value==="highFantasy"?[{name:"Quenian (Elfish)",base:33,odd:1,sort:a=>d(a)/o(a,[6,7,8,9],10)*p[a],shield:"gondor"},{name:"Eldar (Elfish)",base:33,odd:1,sort:a=>d(a)/o(a,[6,7,8,9],10)*p[a],shield:"noldor"},{name:"Trow (Dark Elfish)",base:34,odd:.9,sort:a=>d(a)/o(a,[7,8,9,12],10)*p[a],shield:"hessen"},{name:"Lothian (Dark Elfish)",base:34,odd:.3,sort:a=>d(a)/o(a,[7,8,9,12],10)*p[a],shield:"wedged"},{name:"Dunirr (Dwarven)",base:35,odd:1,sort:a=>d(a)+B[a],shield:"ironHills"},{name:"Khazadur (Dwarven)",base:35,odd:1,sort:a=>d(a)+B[a],shield:"erebor"},{name:"Kobold (Goblin)",base:36,odd:1,sort:a=>p[a]-C[a],shield:"moriaOrc"},{name:"Uruk (Orkish)",base:37,odd:1,sort:a=>B[a]*p[a],shield:"urukHai"},{name:"Ugluk (Orkish)",base:37,odd:.5,sort:a=>B[a]*p[a]/o(a,[1,2,10,11]),shield:"moriaOrc"},{name:"Yotunn (Giants)",base:38,odd:.7,sort:a=>s(a,-10),shield:"pavise"},{name:"Rake (Drakonic)",base:39,odd:.7,sort:a=>-C[a],shield:"fantasy2"},{name:"Arago (Arachnid)",base:40,odd:.7,sort:a=>p[a]-C[a],shield:"horsehead2"},{name:"Aj'Snaga (Serpents)",base:41,odd:.7,sort:a=>d(a)/o(a,[12],10),shield:"fantasy1"},{name:"Anor (Human)",base:32,odd:1,sort:a=>d(a)/s(a,10),shield:"fantasy5"},{name:"Dail (Human)",base:32,odd:1,sort:a=>d(a)/s(a,13),shield:"roman"},{name:"Rohand (Human)",base:16,odd:1,sort:a=>d(a)/s(a,16),shield:"round"},{name:"Dulandir (Human)",base:31,odd:1,sort:a=>d(a)/s(a,5)/o(a,[2,4,10],7)*p[a],shield:"easterling"}]:culturesSet.value==="darkFantasy"?[{name:"Angshire",base:1,odd:1,sort:a=>d(a)/s(a,10)/l(a),shield:"heater"},{name:"Enlandic",base:1,odd:1,sort:a=>d(a)/s(a,12),shield:"heater"},{name:"Westen",base:1,odd:1,sort:a=>d(a)/s(a,10),shield:"heater"},{name:"Nortumbic",base:1,odd:1,sort:a=>d(a)/s(a,7),shield:"heater"},{name:"Mercian",base:1,odd:1,sort:a=>d(a)/s(a,9),shield:"heater"},{name:"Kentian",base:1,odd:1,sort:a=>d(a)/s(a,12),shield:"heater"},{name:"Norse",base:6,odd:.7,sort:a=>d(a)/s(a,5)/l(a),shield:"oldFrench"},{name:"Schwarzen",base:0,odd:.3,sort:a=>d(a)/s(a,10)/o(a,[6,8]),shield:"gonfalon"},{name:"Luarian",base:2,odd:.3,sort:a=>d(a)/s(a,12)/o(a,[6,8]),shield:"oldFrench"},{name:"Hetallian",base:3,odd:.3,sort:a=>d(a)/s(a,15),shield:"oval"},{name:"Astellian",base:4,odd:.3,sort:a=>d(a)/s(a,16),shield:"spanish"},{name:"Kiswaili",base:28,odd:.05,sort:a=>d(a)/s(a,29)/o(a,[1,3,5,7]),shield:"vesicaPiscis"},{name:"Yoruba",base:21,odd:.05,sort:a=>d(a)/s(a,15)/o(a,[5,7]),shield:"vesicaPiscis"},{name:"Koryo",base:10,odd:.05,sort:a=>d(a)/s(a,12)/p[a],shield:"round"},{name:"Hantzu",base:11,odd:.05,sort:a=>d(a)/s(a,13),shield:"banner"},{name:"Yamoto",base:12,odd:.05,sort:a=>d(a)/s(a,15)/p[a],shield:"round"},{name:"Guantzu",base:30,odd:.05,sort:a=>d(a)/s(a,17),shield:"banner"},{name:"Ulus",base:31,odd:.05,sort:a=>d(a)/s(a,5)/o(a,[2,4,10],7)*p[a],shield:"banner"},{name:"Turan",base:16,odd:.05,sort:a=>d(a)/s(a,12),shield:"round"},{name:"Berberan",base:17,odd:.05,sort:a=>d(a)/s(a,19)/o(a,[1,2,3],7)*p[a],shield:"round"},{name:"Eurabic",base:18,odd:.05,sort:a=>d(a)/s(a,26)/o(a,[1,2],7)*p[a],shield:"round"},{name:"Slovan",base:5,odd:.05,sort:a=>d(a)/s(a,6)*p[a],shield:"round"},{name:"Keltan",base:22,odd:.1,sort:a=>d(a)/s(a,11)**.5/o(a,[6,8]),shield:"vesicaPiscis"},{name:"Elladan",base:7,odd:.2,sort:a=>d(a)/s(a,18)/l(a)*B[a],shield:"boeotian"},{name:"Romian",base:8,odd:.2,sort:a=>d(a)/s(a,14)/p[a],shield:"roman"},{name:"Eldar",base:33,odd:.5,sort:a=>d(a)/o(a,[6,7,8,9],10)*p[a],shield:"fantasy5"},{name:"Trow",base:34,odd:.8,sort:a=>d(a)/o(a,[7,8,9,12],10)*p[a],shield:"hessen"},{name:"Durinn",base:35,odd:.8,sort:a=>d(a)+B[a],shield:"erebor"},{name:"Kobblin",base:36,odd:.8,sort:a=>p[a]-C[a],shield:"moriaOrc"},{name:"Uruk",base:37,odd:.8,sort:a=>B[a]*p[a]/o(a,[1,2,10,11]),shield:"urukHai"},{name:"Yotunn",base:38,odd:.8,sort:a=>s(a,-10),shield:"pavise"},{name:"Drake",base:39,odd:.9,sort:a=>-C[a],shield:"fantasy2"},{name:"Rakhnid",base:40,odd:.9,sort:a=>p[a]-C[a],shield:"horsehead2"},{name:"Aj'Snaga",base:41,odd:.9,sort:a=>d(a)/o(a,[12],10),shield:"fantasy1"}]:culturesSet.value==="random"?d3.range(A).map(function(){const a=be(nameBases.length-1);return{name:Names.getBaseShort(a),base:a,odd:1,shield:b()}}):[{name:"Shwazen",base:0,odd:.7,sort:a=>d(a)/s(a,10)/o(a,[6,8]),shield:"hessen"},{name:"Angshire",base:1,odd:1,sort:a=>d(a)/s(a,10)/l(a),shield:"heater"},{name:"Luari",base:2,odd:.6,sort:a=>d(a)/s(a,12)/o(a,[6,8]),shield:"oldFrench"},{name:"Tallian",base:3,odd:.6,sort:a=>d(a)/s(a,15),shield:"horsehead2"},{name:"Astellian",base:4,odd:.6,sort:a=>d(a)/s(a,16),shield:"spanish"},{name:"Slovan",base:5,odd:.7,sort:a=>d(a)/s(a,6)*p[a],shield:"round"},{name:"Norse",base:6,odd:.7,sort:a=>d(a)/s(a,5),shield:"heater"},{name:"Elladan",base:7,odd:.7,sort:a=>d(a)/s(a,18)*B[a],shield:"boeotian"},{name:"Romian",base:8,odd:.7,sort:a=>d(a)/s(a,15),shield:"roman"},{name:"Soumi",base:9,odd:.3,sort:a=>d(a)/s(a,5)/o(a,[9])*p[a],shield:"pavise"},{name:"Koryo",base:10,odd:.1,sort:a=>d(a)/s(a,12)/p[a],shield:"round"},{name:"Hantzu",base:11,odd:.1,sort:a=>d(a)/s(a,13),shield:"banner"},{name:"Yamoto",base:12,odd:.1,sort:a=>d(a)/s(a,15)/p[a],shield:"round"},{name:"Portuzian",base:13,odd:.4,sort:a=>d(a)/s(a,17)/l(a),shield:"spanish"},{name:"Nawatli",base:14,odd:.1,sort:a=>B[a]/s(a,18)/o(a,[7]),shield:"square"},{name:"Vengrian",base:15,odd:.2,sort:a=>d(a)/s(a,11)/o(a,[4])*p[a],shield:"wedged"},{name:"Turchian",base:16,odd:.2,sort:a=>d(a)/s(a,13),shield:"round"},{name:"Berberan",base:17,odd:.1,sort:a=>d(a)/s(a,19)/o(a,[1,2,3],7)*p[a],shield:"round"},{name:"Eurabic",base:18,odd:.2,sort:a=>d(a)/s(a,26)/o(a,[1,2],7)*p[a],shield:"round"},{name:"Inuk",base:19,odd:.05,sort:a=>s(a,-1)/o(a,[10,11])/l(a),shield:"square"},{name:"Euskati",base:20,odd:.05,sort:a=>d(a)/s(a,15)*B[a],shield:"spanish"},{name:"Yoruba",base:21,odd:.05,sort:a=>d(a)/s(a,15)/o(a,[5,7]),shield:"vesicaPiscis"},{name:"Keltan",base:22,odd:.05,sort:a=>d(a)/s(a,11)/o(a,[6,8])*p[a],shield:"vesicaPiscis"},{name:"Efratic",base:23,odd:.05,sort:a=>d(a)/s(a,22)*p[a],shield:"diamond"},{name:"Tehrani",base:24,odd:.1,sort:a=>d(a)/s(a,18)*B[a],shield:"round"},{name:"Maui",base:25,odd:.05,sort:a=>d(a)/s(a,24)/l(a)/p[a],shield:"round"},{name:"Carnatic",base:26,odd:.05,sort:a=>d(a)/s(a,26),shield:"round"},{name:"Inqan",base:27,odd:.05,sort:a=>B[a]/s(a,13),shield:"square"},{name:"Kiswaili",base:28,odd:.1,sort:a=>d(a)/s(a,29)/o(a,[1,3,5,7]),shield:"vesicaPiscis"},{name:"Vietic",base:29,odd:.1,sort:a=>d(a)/s(a,25)/o(a,[7],7)/p[a],shield:"banner"},{name:"Guantzu",base:30,odd:.1,sort:a=>d(a)/s(a,17),shield:"banner"},{name:"Ulus",base:31,odd:.1,sort:a=>d(a)/s(a,5)/o(a,[2,4,10],7)*p[a],shield:"banner"}]},r=function(){Q&&console.time("expandCultures"),e=pack.cells;const A=new PriorityQueue({comparator:(g,p)=>g.p-p.p});pack.cultures.forEach(function(g){!g.i||g.removed||A.queue({e:g.center,p:0,c:g.i})});const u=e.i.length/5e3*3e3*neutralInput.value,C=[];for(;A.length;){const g=A.dequeue(),p=g.e,B=g.p,k=g.c,d=pack.cultures[k].type;e.c[p].forEach(function(s){const o=e.biome[s],l=c(k,o,d),a=o===e.biome[p]?0:20,w=f(s,e.h[s],d),S=z(e.r[s],s,d),h=m(e.t[s],d),v=B+(l+a+w+S+h)/pack.cultures[k].expansionism;v>u||(!C[s]||v<C[s])&&(e.s[s]>0&&(e.culture[s]=k),C[s]=v,A.queue({e:s,p:v,c:k}))})}Q&&console.timeEnd("expandCultures")};function c(A,u,C){return e.biome[pack.cultures[A].center]===u?10:C==="Hunting"?biomesData.cost[u]*5:C==="Nomadic"&&u>4&&u<10?biomesData.cost[u]*10:biomesData.cost[u]*2}function f(A,u,C){const g=pack.features[e.f[A]],p=e.area[A];return C==="Lake"&&g.type==="lake"?10:C==="Naval"&&u<20?p*2:C==="Nomadic"&&u<20?p*50:u<20?p*6:C==="Highland"&&u<44?3e3:C==="Highland"&&u<62?200:C==="Highland"?0:u>=67?200:u>=44?30:0}function z(A,u,C){return C==="River"?A?0:100:A?Ie(e.fl[u]/10,20,100):0}function m(A,u){return A===1?u==="Naval"||u==="Lake"?0:u==="Nomadic"?60:20:A===2?u==="Naval"||u==="Nomadic"?30:0:A!==-1&&(u==="Naval"||u==="Lake")?100:0}const b=function(){const A=he(COA.shields.types);return he(COA.shields[A])};return{generate:t,add:n,expand:r,getDefault:i,getRandomShield:b}}();function wt(){var e;if(coastline.select("#sea_island").size()&&+coastline.select("#sea_island").attr("auto-filter")){const t=scale>1.5&&scale<=2.6?null:scale>2.6?"url(#blurFilter)":"url(#dropShadow)";coastline.select("#sea_island").attr("filter",t)}if(labels.style("display")!=="none"&&labels.selectAll("g").each(function(){if(this.id==="burgLabels")return;const t=+this.dataset.size,n=Math.max(O((t+t/scale)/2,2),1);rescaleLabels.checked&&this.setAttribute("font-size",n),hideLabels.checked&&(n*scale<6||n*scale>60)?this.classList.add("hidden"):this.classList.remove("hidden")}),emblems.style("display")!=="none"&&emblems.selectAll("g").each(function(){const t=this.getAttribute("font-size")*scale,n=hideEmblems.checked&&(t<25||t>300);n?this.classList.add("hidden"):this.classList.remove("hidden"),!n&&window.COArenderer&&this.children.length&&!this.children[0].getAttribute("href")&&renderGroupCOAs(this)}),oceanPattern.select("rect").attr("fill",scale>10?"#fff":"url(#oceanic)").attr("opacity",scale>10?.2:null),!customization){const t=+statesHalo.attr("data-width"),n=O(t/scale**.8,2);statesHalo.attr("stroke-width",n).style("display",n>.1?"block":"none")}if(+markers.attr("rescale")&&((e=pack.markers)==null||e.forEach(t=>{const{i:n,x:i,y:r,size:c=30,hidden:f}=t,z=!f&&document.getElementById(`marker${n}`);if(!z)return;const m=Math.max(O(c/5+24/scale,2),1);z.setAttribute("width",m),z.setAttribute("height",m),z.setAttribute("x",O(i-m/2,1)),z.setAttribute("y",O(r-m,1))})),ruler.style("display")!=="none"){const t=O(10/scale**.3*2,2);ruler.selectAll("text").attr("font-size",t)}}function ge(e){return e.ctrlKey||e.metaKey}const lt=document.getElementById("prompt"),Vn=lt.querySelector("#promptForm"),Ye=lt.querySelector("#promptInput"),Zn=lt.querySelector("#promptText"),Jn=lt.querySelector("#promptCancel"),Yn="Please provide an input",Xn={default:1,step:.01,min:0,max:100,required:!0};function Qn(e=Yn,t=Xn,n){if(t.default===void 0)return console.error("Prompt: options object does not have default value defined");Zn.innerHTML=e,Ye.type=typeof t.default=="number"?"number":"text",t.step!==void 0&&(Ye.step=String(t.step)),t.min!==void 0&&(Ye.min=String(t.min)),t.max!==void 0&&(Ye.max=String(t.max)),Ye.required=t.required!==!1,Ye.placeholder="type a "+Ye.type,Ye.value=String(t.default),lt.style.display="block",Vn.addEventListener("submit",i=>{i.preventDefault(),lt.style.display="none";const r=Ye.type==="number"?Number(Ye.value):Ye.value;n&&n(r)},{once:!0})}Jn.addEventListener("click",()=>{lt.style.display="none"});const $n={"\xB0C":e=>O(e)+"\xB0C","\xB0F":e=>O(e*9/5+32)+"\xB0F",K:e=>O(e+273.15)+"K","\xB0R":e=>O((e+273.15)*9/5)+"\xB0R","\xB0De":e=>O((100-e)*3/2)+"\xB0De","\xB0N":e=>O(e*33/100)+"\xB0N","\xB0R\xE9":e=>O(e*4/5)+"\xB0R\xE9","\xB0R\xF8":e=>O(e*21/40+7.5)+"\xB0R\xF8"};function Xt(e){var i;const t=((i=ne("temperatureScale"))==null?void 0:i.value)||"\xB0C",n=$n[t];return n(e)}function Qt(e){return e>=1e9?O(e/1e9,1)+"B":e>=1e8?O(e/1e6)+"M":e>=1e6?O(e/1e6,1)+"M":e>=1e4?O(e/1e3)+"K":e>=1e3?O(e/1e3,1)+"K":O(e)}function _n(e,t,n,i){return function r(c,f){if(f>=i.length)return n(c);const z=new Map,m=i[f++];let b=-1;for(const A of c){const u=m(A,++b,c),C=z.get(u);C?C.push(A):z.set(u,[A])}for(const[A,u]of z)z.set(A,r(u,f));return t(z)}(e,0)}function Xs(e,t,n){return _n(e,Array.from,t,n)}function vt(e,t){let n;return(...i)=>{let r;return n&&clearTimeout(n),n=setTimeout(()=>{r=e(...i)},t),r}}function eo(e,t=300){let n,i,r;return function(){const c=this,f=arguments;n?(clearTimeout(i),i=setTimeout(()=>{Date.now()-r>=t&&(e.apply(c,f),r=Date.now())},Math.max(t-(Date.now()-r),0))):(e.apply(c,f),r=Date.now(),n=!0)}}function ka(e,t){const n=new XMLHttpRequest;n.onload=function(){const i=new FileReader;i.onloadend=function(){t(i.result)},i.readAsDataURL(n.response)},n.open("GET",e),n.responseType="blob",n.send()}let pt={};to();io();function $t(){return{political:["toggleBorders","toggleIcons","toggleIce","toggleLabels","toggleRivers","toggleRoutes","toggleScaleBar","toggleStates"],cultural:["toggleBorders","toggleCultures","toggleIcons","toggleLabels","toggleRivers","toggleRoutes","toggleScaleBar"],religions:["toggleBorders","toggleIcons","toggleLabels","toggleReligions","toggleRivers","toggleRoutes","toggleScaleBar"],provinces:["toggleBorders","toggleIcons","toggleProvinces","toggleRivers","toggleScaleBar"],biomes:["toggleBiomes","toggleIce","toggleRivers","toggleScaleBar"],heightmap:["toggleHeight","toggleRivers"],physical:["toggleCoordinates","toggleHeight","toggleIce","toggleRivers","toggleScaleBar"],poi:["toggleBorders","toggleHeight","toggleIce","toggleIcons","toggleMarkers","toggleRivers","toggleRoutes","toggleScaleBar"],military:["toggleBorders","toggleIcons","toggleLabels","toggleMilitary","toggleRivers","toggleRoutes","toggleScaleBar","toggleStates"],emblems:["toggleBorders","toggleIcons","toggleIce","toggleEmblems","toggleRivers","toggleRoutes","toggleScaleBar","toggleStates"],landmass:["toggleScaleBar"]}}function to(){pt=$t();const e=JSON.parse(localStorage.getItem("presets"));if(!!e){for(const t in e)pt[t]||layersPreset.add(new Option(t,t));pt=e}}function ao(){var t;const e=ze("preset")||((t=ne("layersPreset"))==null?void 0:t.value)||"political";no(e)}function no(e){const t=pt[e];ne("mapLayers").querySelectorAll("li").forEach(function(r){const{id:c}=r;(t.includes(c)&&!Pe(c)||!t.includes(c)&&Pe(c))&&r.click()}),ne("layersPreset").value=e,pa("preset",e);const i=$t()[e];ne("removePresetButton").style.display=i?"none":"inline-block",ne("savePresetButton").style.display="none",ne("canvas3d")&&setTimeout(ThreeD.update(),400)}function wa(){const e=ne("mapLayers").querySelectorAll("li:not(.buttonoff)"),t=Array.from(e).map(i=>i.id).sort(),n=$t();for(const i in pt)if(JSON.stringify(pt[i].sort())===JSON.stringify(t)){ne("layersPreset").value=i,ne("removePresetButton").style.display=n[i]?"none":"inline-block",ne("savePresetButton").style.display="none";return}ne("layersPreset").value="custom",ne("removePresetButton").style.display="none",ne("savePresetButton").style.display="inline-block"}const ra={toggleBiomes:ho,toggleBorders:Bo,toggleCells:bo,toggleCompass:Ho,toggleCoordinates:Ro,toggleCultures:So,toggleEmblems:Xo,toggleGrid:Lo,toggleHeight:ro,toggleIce:ko,toggleIcons:Vo,toggleLabels:qo,toggleMarkers:Oo,toggleMilitary:Fo,togglePopulation:fo,togglePrec:po,toggleProvinces:Mo,toggleRelief:Uo,toggleReligions:zo,toggleRivers:Ko,toggleRoutes:Do,toggleRulers:Zo,toggleScaleBar:Jo,toggleStates:Co,toggleTemp:co,toggleTexture:No,toggleZones:Yo};function oo(e){const t=e.target.id;!t||t==="mapLayers"||!ra[t]||ra[t]()}function io(){ne("mapLayers").on("click",oo)}function ro(e){if(customization===1){se("You cannot turn off the layer when heightmap is in edit mode",!1,"error");return}if(!terrs.selectAll("*").size())Le("toggleHeight"),so(),e&&ge(e)&&editStyle("terrs");else{if(e&&ge(e)){editStyle("terrs");return}Ee("toggleHeight"),terrs.selectAll("*").remove()}}function so(){Q&&console.time("drawHeightmap"),terrs.selectAll("*").remove();const{cells:e,vertices:t}=pack,n=e.i.length,i=new Uint8Array(e.i.length),r=new Array(101).fill(""),c=Sa(terrs.attr("scheme")),f=terrs.attr("terracing")/10,z=+terrs.attr("skip")+1,m=+terrs.attr("relax");switch(+terrs.attr("curve")){case 0:lineGen.curve(d3.curveBasisClosed);break;case 1:lineGen.curve(d3.curveLinear);break;case 2:lineGen.curve(d3.curveStep);break;default:lineGen.curve(d3.curveBasisClosed)}let b=20;const A=e.i.sort((g,p)=>e.h[g]-e.h[p]);for(const g of A){const p=e.h[g];if(p>b&&(b+=z),b>100)break;if(p<b||i[g]||!e.c[g].some(o=>e.h[o]<p))continue;const k=e.v[g].find(o=>t.c[o].some(l=>e.h[l]<p)),d=u(k,p);if(d.length<3)continue;const s=C(d).map(o=>t.p[o]);r[p]+=round(lineGen(s))}terrs.append("rect").attr("x",0).attr("y",0).attr("width",graphWidth).attr("height",graphHeight).attr("fill",c(.8));for(const g of d3.range(20,101)){if(r[g].length<10)continue;const p=lo(g,c);f&&terrs.append("path").attr("d",r[g]).attr("transform","translate(.7,1.4)").attr("fill",d3.color(p).darker(f)).attr("data-height",g),terrs.append("path").attr("d",r[g]).attr("fill",p).attr("data-height",g)}function u(g,p){const B=[];for(let k=0,d=g;k===0||d!==g&&k<2e4;k++){const s=B[B.length-1];B.push(d);const o=t.c[d];o.filter(h=>e.h[h]===p).forEach(h=>i[h]=1);const l=o[0]>=n||e.h[o[0]]<p,a=o[1]>=n||e.h[o[1]]<p,w=o[2]>=n||e.h[o[2]]<p,S=t.v[d];if(S[0]!==s&&l!==a?d=S[0]:S[1]!==s&&a!==w?d=S[1]:S[2]!==s&&l!==w&&(d=S[2]),d===B[B.length-1]){ERROR&&console.error("Next vertex is not found");break}}return B}function C(g){if(!m)return g;const p=m+1;return g.filter((B,k)=>k%p===0)}Q&&console.timeEnd("drawHeightmap")}function Sa(e){return e==="bright"?d3.scaleSequential(d3.interpolateSpectral):e==="light"?d3.scaleSequential(d3.interpolateRdYlGn):e==="green"?d3.scaleSequential(d3.interpolateGreens):e==="monochrome"?d3.scaleSequential(d3.interpolateGreys):d3.scaleSequential(d3.interpolateSpectral)}function lo(e,t=Sa()){return t(1-(e<20?e-5:e)/100)}function co(e){if(!temperature.selectAll("*").size())Le("toggleTemp"),uo(),e&&ge(e)&&editStyle("temperature");else{if(e&&ge(e)){editStyle("temperature");return}Ee("toggleTemp"),temperature.selectAll("*").remove()}}function uo(){Q&&console.time("drawTemp"),temperature.selectAll("*").remove(),lineGen.curve(d3.curveBasisClosed);const e=d3.scaleSequential(d3.interpolateSpectral),t=+temperatureEquatorOutput.max,n=+temperatureEquatorOutput.min,i=t-n,r=grid.cells,c=grid.vertices,f=r.i.length,z=new Uint8Array(f),m=d3.min(r.temp),b=d3.max(r.temp),A=Math.max(Math.round(Math.abs(m-b)/5),1),u=d3.range(m+A,b,A),C=[],g=[];for(const o of r.i){const l=r.temp[o];if(z[o]||!u.includes(l))continue;const a=B(o,l);if(!a)continue;z[o]=1;const S=s(a,l).filter((v,E)=>E%4===0||c.c[v].some(P=>P>=f));if(S.length<6)continue;const h=S.map(v=>c.p[v]);C.push([l,h]),k(h,l)}temperature.append("path").attr("d",`M0,0 h${graphWidth} v${graphHeight} h${-graphWidth} Z`).attr("fill",e(1-(m-n)/i)).attr("stroke","none");for(const o of u){const l=C.filter(S=>S[0]===o).map(S=>round(lineGen(S[1]))).join("");if(!l)continue;const a=e(1-(o-n)/i),w=d3.color(a).darker(.2);temperature.append("path").attr("d",l).attr("fill",a).attr("stroke",w)}temperature.append("g").attr("id","tempLabels").attr("fill-opacity",1).selectAll("text").data(g).enter().append("text").attr("x",o=>o[0]).attr("y",o=>o[1]).text(o=>Xt(o[2]));function B(o,l){return r.b[o]?r.v[o].find(a=>c.c[a].some(w=>w>=f)):r.v[o][r.c[o].findIndex(a=>r.temp[a]<l||!r.temp[a])]}function k(o,l){const a=svgWidth/2,w=o[d3.scan(o,(S,h)=>S[1]-h[1]+(Math.abs(S[0]-a)-Math.abs(h[0]-a))/2)];if(d(w[0],w[1],l),o.length>20){const S=o[d3.scan(o,(v,E)=>E[1]-v[1]+(Math.abs(v[0]-a)-Math.abs(E[0]-a))/2)];(w[1]-S[1])**2+(w[0]-S[0])**2>100&&d(S[0],S[1],l)}}function d(o,l,a){o<20||o>svgWidth-20||l<20||l>svgHeight-20||g.push([o,l,a])}function s(o,l){const a=[];for(let w=0,S=o;w===0||S!==o&&w<2e4;w++){const h=a[a.length-1];a.push(S);const v=c.c[S];v.filter(L=>r.temp[L]===l).forEach(L=>z[L]=1);const E=v[0]>=f||r.temp[v[0]]<l,P=v[1]>=f||r.temp[v[1]]<l,T=v[2]>=f||r.temp[v[2]]<l,R=c.v[S];if(R[0]!==h&&E!==P?S=R[0]:R[1]!==h&&P!==T?S=R[1]:R[2]!==h&&E!==T&&(S=R[2]),S===a[a.length-1]){ERROR&&console.error("Next vertex is not found");break}}return a.push(o),a}Q&&console.timeEnd("drawTemp")}function ho(e){if(!biomes.selectAll("path").size())Le("toggleBiomes"),go(),e&&ge(e)&&editStyle("biomes");else{if(e&&ge(e)){editStyle("biomes");return}biomes.selectAll("path").remove(),Ee("toggleBiomes")}}function go(){biomes.selectAll("path").remove();const e=pack.cells,t=pack.vertices,n=e.i.length,i=new Uint8Array(e.i.length),r=new Array(biomesData.i.length).fill("");for(const f of e.i){if(!e.biome[f]||i[f])continue;const z=e.biome[f];if(!e.c[f].some(C=>e.biome[C]!==z))continue;const b=e.v[f].find(C=>t.c[C].some(g=>e.biome[g]!==z)),A=c(b,z);if(A.length<3)continue;const u=Et(A.map(C=>t.p[C]));r[z]+="M"+u.join("L")+"Z"}r.forEach(function(f,z){f.length<10||biomes.append("path").attr("d",f).attr("fill",biomesData.color[z]).attr("stroke",biomesData.color[z]).attr("id","biome"+z)});function c(f,z){const m=[];for(let b=0,A=f;b===0||A!==f&&b<2e4;b++){const u=m[m.length-1];m.push(A);const C=t.c[A];C.filter(d=>e.biome[d]===z).forEach(d=>i[d]=1);const g=C[0]>=n||e.biome[C[0]]!==z,p=C[1]>=n||e.biome[C[1]]!==z,B=C[2]>=n||e.biome[C[2]]!==z,k=t.v[A];if(k[0]!==u&&g!==p?A=k[0]:k[1]!==u&&p!==B?A=k[1]:k[2]!==u&&g!==B&&(A=k[2]),A===m[m.length-1]){ERROR&&console.error("Next vertex is not found");break}}return m}}function po(e){if(!prec.selectAll("circle").size())Le("togglePrec"),mo(),e&&ge(e)&&editStyle("prec");else{if(e&&ge(e)){editStyle("prec");return}Ee("togglePrec");const t=d3.transition().duration(1e3).ease(d3.easeSinIn);prec.selectAll("text").attr("opacity",1).transition(t).attr("opacity",0),prec.selectAll("circle").transition(t).attr("r",0).remove(),prec.transition().delay(1e3).style("display","none")}}function mo(){prec.selectAll("circle").remove();const{cells:e,points:t}=grid;prec.style("display","block");const n=d3.transition().duration(800).ease(d3.easeSinIn);prec.selectAll("text").attr("opacity",0).transition(n).attr("opacity",1);const i=(pointsInput.dataset.cells/1e4)**.25,r=e.i.filter(f=>e.h[f]>=20&&e.prec[f]),c=f=>O(Math.sqrt(f/4)/i,2);prec.selectAll("circle").data(r).enter().append("circle").attr("cx",f=>t[f][0]).attr("cy",f=>t[f][1]).attr("r",0).transition(n).attr("r",f=>c(e.prec[f]))}function fo(e){if(!population.selectAll("line").size())Le("togglePopulation"),yo(),e&&ge(e)&&editStyle("population");else{if(e&&ge(e)){editStyle("population");return}if(Ee("togglePopulation"),!population.select("line").datum())population.selectAll("line").remove();else{const n=d3.transition().duration(1e3).ease(d3.easeSinIn);population.select("#rural").selectAll("line").transition(n).attr("y2",i=>i[1]).remove(),population.select("#urban").selectAll("line").transition(n).delay(1e3).attr("y2",i=>i[1]).remove()}}}function yo(e){population.selectAll("line").remove();const t=pack.cells,n=t.p,i=pack.burgs,r=d3.transition().duration(2e3).ease(d3.easeSinIn),c=Array.from(t.i.filter(z=>t.pop[z]>0),z=>[n[z][0],n[z][1],n[z][1]-t.pop[z]/8]);population.select("#rural").selectAll("line").data(c).enter().append("line").attr("x1",z=>z[0]).attr("y1",z=>z[1]).attr("x2",z=>z[0]).attr("y2",z=>z[1]).transition(r).attr("y2",z=>z[2]);const f=i.filter(z=>z.i&&!z.removed).map(z=>[z.x,z.y,z.y-z.population/8*urbanization]);population.select("#urban").selectAll("line").data(f).enter().append("line").attr("x1",z=>z[0]).attr("y1",z=>z[1]).attr("x2",z=>z[0]).attr("y2",z=>z[1]).transition(r).delay(500).attr("y2",z=>z[2])}function bo(e){if(!cells.selectAll("path").size())Le("toggleCells"),vo(),e&&ge(e)&&editStyle("cells");else{if(e&&ge(e)){editStyle("cells");return}cells.selectAll("path").remove(),Ee("toggleCells")}}function vo(){cells.selectAll("path").remove();const e=customization===1?grid.cells.i:pack.cells.i,t=customization===1?fa:getPackPolygon;let n="";e.forEach(i=>n+="M"+t(i)),cells.append("path").attr("d",n)}function ko(e){if(!Pe("toggleIce"))Le("toggleIce"),$("#ice").fadeIn(),ice.selectAll("*").size()||wo(),e&&ge(e)&&editStyle("ice");else{if(e&&ge(e)){editStyle("ice");return}$("#ice").fadeOut(),Ee("toggleIce")}}function wo(){const e=grid.cells,t=grid.vertices,n=e.i.length,i=e.temp,r=e.h,c=new Uint8Array(e.i.length);Math.random=aleaPRNG(seed);const f=-8,z=1;for(const A of grid.cells.i){const u=i[A];if(u>z||u>f&&r[A]>=20)continue;if(u<=f){if(c[A]||!e.c[A].some(d=>i[d]>f))continue;const p=e.v[A].find(d=>t.c[d].some(s=>i[s]>f)),B=b(p);if(B.length<3)continue;const k=Et(B.map(d=>t.p[d]));ice.append("polygon").attr("points",k).attr("type","iceShield");continue}if(V(ga(u,-7,2.5))||grid.features[e.f[A]].type==="lake")continue;let C=(6.5+u)/10;e.t[A]===-1&&(C*=1.3),C=Math.min(C*(.4+be()*1.2),.95),m(A,C)}function m(A,u){const C=grid.points[A],g=fa(A).map(p=>[p[0]+(C[0]-p[0])*u|0,p[1]+(C[1]-p[1])*u|0]);ice.append("polygon").attr("points",g).attr("cell",A).attr("size",O(1-u,2))}function b(A){const u=[];for(let C=0,g=A;C===0||g!==A&&C<2e4;C++){const p=De(u);u.push(g);const B=t.c[g];B.filter(l=>i[l]<=f).forEach(l=>c[l]=1);const k=B[0]>=n||i[B[0]]>f,d=B[1]>=n||i[B[1]]>f,s=B[2]>=n||i[B[2]]>f,o=t.v[g];if(o[0]!==p&&k!==d?g=o[0]:o[1]!==p&&d!==s?g=o[1]:o[2]!==p&&k!==s&&(g=o[2]),g===u[u.length-1]){ERROR&&console.error("Next vertex is not found");break}}return u}}function So(e){const t=pack.cultures.filter(i=>i.i&&!i.removed);if(!cults.selectAll("path").size()&&t.length)Le("toggleCultures"),Ao(),e&&ge(e)&&editStyle("cults");else{if(e&&ge(e)){editStyle("cults");return}cults.selectAll("path").remove(),Ee("toggleCultures")}}function Ao(){Q&&console.time("drawCultures"),cults.selectAll("path").remove();const{cells:e,vertices:t,cultures:n}=pack,i=e.i.length,r=new Uint8Array(e.i.length),c=new Array(n.length).fill("");for(const m of e.i){if(!e.culture[m]||r[m])continue;r[m]=1;const b=e.culture[m];if(!e.c[m].some(p=>e.culture[p]!==b))continue;const u=e.v[m].find(p=>t.c[p].some(B=>e.culture[B]!==b)),C=z(u,b);if(C.length<3)continue;const g=C.map(p=>t.p[p]);c[b]+="M"+g.join("L")+"Z"}const f=c.map((m,b)=>[m,b]).filter(m=>m[0].length>10);cults.selectAll("path").data(f).enter().append("path").attr("d",m=>m[0]).attr("fill",m=>n[m[1]].color).attr("id",m=>"culture"+m[1]);function z(m,b){const A=[];for(let u=0,C=m;u===0||C!==m&&u<2e4;u++){const g=A[A.length-1];A.push(C);const p=t.c[C];p.filter(o=>e.culture[o]===b).forEach(o=>r[o]=1);const B=p[0]>=i||e.culture[p[0]]!==b,k=p[1]>=i||e.culture[p[1]]!==b,d=p[2]>=i||e.culture[p[2]]!==b,s=t.v[C];if(s[0]!==g&&B!==k?C=s[0]:s[1]!==g&&k!==d?C=s[1]:s[2]!==g&&B!==d&&(C=s[2]),C===A[A.length-1]){ERROR&&console.error("Next vertex is not found");break}}return A}Q&&console.timeEnd("drawCultures")}function zo(e){const t=pack.religions.filter(n=>n.i&&!n.removed);if(!relig.selectAll("path").size()&&t.length)Le("toggleReligions"),xo(),e&&ge(e)&&editStyle("relig");else{if(e&&ge(e)){editStyle("relig");return}relig.selectAll("path").remove(),Ee("toggleReligions")}}function xo(){Q&&console.time("drawReligions"),relig.selectAll("path").remove();const{cells:e,vertices:t,religions:n}=pack,i=e.i.length,r=new Uint8Array(e.i.length),c=new Array(n.length),f=new Array(n.length).fill(""),z=new Array(n.length).fill("");for(const u of e.i){if(!e.religion[u]||r[u])continue;r[u]=1;const C=e.religion[u];if(!e.c[u].filter(s=>e.religion[s]!==C).length)continue;const p=e.c[u].map(s=>e.religion[s]).find(s=>s!==C),B=e.v[u].find(s=>t.c[s].some(o=>e.religion[o]===p)),k=A(B,C,p);if(k.length<3)continue;const d=k.map(s=>t.p[s[0]]);c[C]||(c[C]=[]),c[C].push(d),f[C]+="M"+d.join("L")+"Z",z[C]+="M"+t.p[k[0][0]]+k.reduce((s,o,l,a)=>l?o[2]?a[l+1]&&!a[l+1][2]?s+"M"+t.p[o[0]]:s:s+"L"+t.p[o[0]]:s,"")}const m=f.map((u,C)=>[u.length>10?u:null,C,n[C].color]).filter(u=>u[0]);relig.selectAll("path").data(m).enter().append("path").attr("d",u=>u[0]).attr("fill",u=>u[2]).attr("id",u=>"religion"+u[1]);const b=z.map((u,C)=>[u.length>10?u:null,C,n[C].color]).filter(u=>u[0]);relig.selectAll(".path").data(b).enter().append("path").attr("d",u=>u[0]).attr("fill","none").attr("stroke",u=>u[2]).attr("id",u=>"religion-gap"+u[1]).attr("stroke-width","10px");function A(u,C,g){const p=[];let B=t.c[u].some(d=>e.h[d]>=20&&e.religion[d]!==C);function k(d){g=e.religion[d],B=e.h[d]>=20}for(let d=0,s=u;d===0||s!==u&&d<2e4;d++){const o=p[p.length-1]?p[p.length-1][0]:-1;p.push([s,g,B]);const l=t.c[s];l.filter(v=>e.religion[v]===C).forEach(v=>r[v]=1);const a=l[0]>=i||e.religion[l[0]]!==C,w=l[1]>=i||e.religion[l[1]]!==C,S=l[2]>=i||e.religion[l[2]]!==C,h=t.v[s];if(h[0]!==o&&a!==w?(s=h[0],k(a?l[0]:l[1])):h[1]!==o&&w!==S?(s=h[1],k(w?l[1]:l[2])):h[2]!==o&&a!==S&&(s=h[2],k(S?l[2]:l[0])),s===p[p.length-1][0]){ERROR&&console.error("Next vertex is not found");break}}return p}Q&&console.timeEnd("drawReligions")}function Co(e){if(!Pe("toggleStates"))Le("toggleStates"),regions.style("display",null),Aa(),e&&ge(e)&&editStyle("regions");else{if(e&&ge(e)){editStyle("regions");return}regions.style("display","none").selectAll("path").remove(),Ee("toggleStates")}}function Aa(){Q&&console.time("drawStates"),regions.selectAll("path").remove();const{cells:e,vertices:t,features:n}=pack,i=pack.states,r=e.i.length,c=new Uint8Array(e.i.length),f=new Array(i.length),z=new Array(i.length).fill(""),m=new Array(i.length).fill(""),b=new Array(i.length).fill(""),A=l=>t.p[l[0]].join(","),u=n.map(l=>{if(l.type!=="lake")return!1;l.shoreline||Lakes.getShoreline(l);const a=l.shoreline.map(w=>e.state[w]);return!(new Set(a).size>1)});for(const l of e.i){if(!e.state[l]||c[l])continue;const a=e.state[l];if(!e.c[l].some(R=>e.state[R]!==a))continue;const S=e.c[l].map(R=>e.state[R]).find(R=>R!==a),h=e.v[l].find(R=>t.c[R].some(L=>e.state[L]===S)),v=o(h,a),E=v.filter(R=>R[1]!=="innerLake");if(E.length<3)continue;f[a]||(f[a]=[]);const P=E.map(R=>t.p[R[0]]);f[a].push(P),z[a]+="M"+P.join("L");let T=!0;b[a]+=E.map(R=>{if(R[1]==="border")return T=!0,"";const L=T?"M":"L";return T=!1,`${L}${A(R)}`}).join(""),T=!0,m[a]+=v.map(R=>{if(R[1]==="land")return T=!0,"";const L=T?"M":"L";return T=!1,`${L}${A(R)}`}).join("")}f.forEach((l,a)=>{const w=l.sort((S,h)=>h.length-S.length);i[a].pole=polylabel(w,1)});const C=z.map((l,a)=>[l.length>10?l:null,a,i[a].color]).filter(l=>l[0]),g=m.map((l,a)=>[l.length>10?l:null,a,i[a].color]).filter(l=>l[0]),p=b.map((l,a)=>[l.length>10?l:null,a,i[a].color]).filter(l=>l[0]),B=C.map(l=>`<path id="state${l[1]}" d="${l[0]}" fill="${l[2]}" stroke="none"/>`).join(""),k=g.map(l=>`<path id="state-gap${l[1]}" d="${l[0]}" fill="none" stroke="${l[2]}"/>`).join(""),d=C.map(l=>`<clipPath id="state-clip${l[1]}"><use href="#state${l[1]}"/></clipPath>`).join(""),s=p.map(l=>`<path id="state-border${l[1]}" d="${l[0]}" clip-path="url(#state-clip${l[1]})" stroke="${d3.color(l[2])?d3.color(l[2]).darker().hex():"#666666"}"/>`).join("");statesBody.html(B+k),defs.select("#statePaths").html(d),statesHalo.html(s);function o(l,a){const w=[],S=h=>{if(h.find(P=>e.b[P]))return"border";const E=h.find(P=>e.h[P]<20);return E?u[e.f[E]]?"innerLake":n[e.f[E]].type:"land"};for(let h=0,v=l;h===0||v!==l&&h<2e4;h++){const E=w.length?w[w.length-1][0]:-1,P=t.c[v];w.push([v,S(P)]),P.filter(I=>e.state[I]===a).forEach(I=>c[I]=1);const T=P[0]>=r||e.state[P[0]]!==a,R=P[1]>=r||e.state[P[1]]!==a,L=P[2]>=r||e.state[P[2]]!==a,M=t.v[v];if(M[0]!==E&&T!==R?v=M[0]:M[1]!==E&&R!==L?v=M[1]:M[2]!==E&&T!==L&&(v=M[2]),v===E){ERROR&&console.error("Next vertex is not found");break}}return w.length&&w.push(w[0]),w}wt(),Q&&console.timeEnd("drawStates")}function Bo(e){if(!Pe("toggleBorders"))Le("toggleBorders"),za(),e&&ge(e)&&editStyle("borders");else{if(e&&ge(e)){editStyle("borders");return}Ee("toggleBorders"),borders.selectAll("path").remove()}}function za(){Q&&console.time("drawBorders"),borders.selectAll("path").remove();const{cells:e,vertices:t}=pack,n=e.i.length,i=[],r=[],c=new Array(pack.states.length).fill("").map(m=>[]),f=new Array(pack.provinces.length).fill("").map(m=>[]);for(let m=0;m<e.i.length;m++){if(!e.state[m])continue;const b=e.province[m],A=e.state[m],u=e.c[m].find(g=>e.state[g]===A&&b>e.province[g]&&f[b][g]!==e.province[g]);if(u){const g=e.province[u];f[b][u]=g;const p=e.v[m].find(k=>t.c[k].some(d=>e.province[d]===g)),B=z(p,b,e.province,g,f);if(B.length>1){r.push("M"+B.map(k=>t.p[k]).join(" ")),m--;continue}}const C=e.c[m].find(g=>e.h[g]>=20&&A>e.state[g]&&c[A][g]!==e.state[g]);if(C!==void 0){const g=e.state[C];c[A][C]=g;const p=e.v[m].find(k=>t.c[k].some(d=>e.h[d]>=20&&e.state[d]===g)),B=z(p,A,e.state,g,c);if(B.length>1){i.push("M"+B.map(k=>t.p[k]).join(" ")),m--;continue}}}stateBorders.append("path").attr("d",i.join(" ")),provinceBorders.append("path").attr("d",r.join(" "));function z(m,b,A,u,C){let g=[];const p=k=>k>=n||A[k]!==b,B=k=>t.c[k].some(d=>A[d]===b)&&t.c[k].some(d=>A[d]===u&&e.h[d]>=20);for(let k=0;k<1e3;k++){k===999&&ERROR&&console.error("Find starting vertex: limit is reached",m,b,u);const d=g[g.length-2]||-1,s=t.v[m],o=t.c[m],l=p(o[0])!==p(o[1])&&B(s[0]),a=p(o[1])!==p(o[2])&&B(s[1]),w=p(o[0])!==p(o[2])&&B(s[2]);if(l+a+w===1||(m=l&&d!==s[0]?s[0]:a&&d!==s[1]?s[1]:s[2],m===g[0]))break;if(m===d)return[];g.push(m)}g=[m];for(let k=0;k<1e3;k++){k===999&&ERROR&&console.error("Find path: limit is reached",m,b,u);const d=g[g.length-2]||-1,s=t.v[m],o=t.c[m];o.filter(S=>A[S]===u).forEach(S=>C[b][S]=u);const l=p(o[0])!==p(o[1])&&B(s[0]),a=p(o[1])!==p(o[2])&&B(s[1]),w=p(o[0])!==p(o[2])&&B(s[2]);if(m=l&&d!==s[0]?s[0]:a&&d!==s[1]?s[1]:s[2],m===d||m===g[g.length-1]||g.length>1&&l+a+w<2||(g.push(m),m===g[0]))break}return g}Q&&console.timeEnd("drawBorders")}function Mo(e){if(!Pe("toggleProvinces"))Le("toggleProvinces"),Eo(),e&&ge(e)&&editStyle("provs");else{if(e&&ge(e)){editStyle("provs");return}provs.selectAll("*").remove(),Ee("toggleProvinces")}}function Eo(){Q&&console.time("drawProvinces");const e=provs.attr("data-labels")==1;provs.selectAll("*").remove();const t=pack.provinces,{body:n,gap:i}=xa(),r=provs.append("g").attr("id","provincesBody"),c=n.map((b,A)=>[b.length>10?b:null,A,t[A].color]).filter(b=>b[0]);r.selectAll("path").data(c).enter().append("path").attr("d",b=>b[0]).attr("fill",b=>b[2]).attr("stroke","none").attr("id",b=>"province"+b[1]);const f=i.map((b,A)=>[b.length>10?b:null,A,t[A].color]).filter(b=>b[0]);r.selectAll(".path").data(f).enter().append("path").attr("d",b=>b[0]).attr("fill","none").attr("stroke",b=>b[2]).attr("id",b=>"province-gap"+b[1]);const z=provs.append("g").attr("id","provinceLabels");z.style("display",`${e?"block":"none"}`);const m=t.filter(b=>b.i&&!b.removed&&b.pole);z.selectAll(".path").data(m).enter().append("text").attr("x",b=>b.pole[0]).attr("y",b=>b.pole[1]).attr("id",b=>"provinceLabel"+b.i).text(b=>b.name),Q&&console.timeEnd("drawProvinces")}function xa(){const e=pack.cells,t=pack.vertices,n=pack.provinces,i=e.i.length,r=new Uint8Array(e.i.length),c=new Array(n.length),f=new Array(n.length).fill(""),z=new Array(n.length).fill("");for(const b of e.i){if(!e.province[b]||r[b])continue;const A=e.province[b];if(!e.c[b].some(k=>e.province[k]!==A))continue;const C=e.c[b].map(k=>e.province[k]).find(k=>k!==A),g=e.v[b].find(k=>t.c[k].some(d=>e.province[d]===C)),p=m(g,A,C);if(p.length<3)continue;const B=p.map(k=>t.p[k[0]]);c[A]||(c[A]=[]),c[A].push(B),f[A]+="M"+B.join("L"),z[A]+="M"+t.p[p[0][0]]+p.reduce((k,d,s,o)=>s?d[2]?o[s+1]&&!o[s+1][2]?k+"M"+t.p[d[0]]:k:k+"L"+t.p[d[0]]:k,"")}return c.forEach((b,A)=>{const u=b.sort((C,g)=>g.length-C.length);n[A].pole=polylabel(u,1)}),{body:f,gap:z};function m(b,A,u){const C=[];let g=t.c[b].some(B=>e.h[B]>=20&&e.province[B]!==A);function p(B){u=e.province[B],g=e.h[B]>=20}for(let B=0,k=b;B===0||k!==b&&B<2e4;B++){const d=C[C.length-1]?C[C.length-1][0]:-1;C.push([k,u,g]);const s=t.c[k];s.filter(S=>e.province[S]===A).forEach(S=>r[S]=1);const o=s[0]>=i||e.province[s[0]]!==A,l=s[1]>=i||e.province[s[1]]!==A,a=s[2]>=i||e.province[s[2]]!==A,w=t.v[k];if(w[0]!==d&&o!==l?(k=w[0],p(o?s[0]:s[1])):w[1]!==d&&l!==a?(k=w[1],p(l?s[1]:s[2])):w[2]!==d&&o!==a&&(k=w[2],p(a?s[2]:s[0])),k===C[C.length-1][0]){ERROR&&console.error("Next vertex is not found");break}}return C.push([b,u,g]),C}}function Lo(e){if(!gridOverlay.selectAll("*").size())Le("toggleGrid"),Io(),calculateFriendlyGridSize(),e&&ge(e)&&editStyle("gridOverlay");else{if(e&&ge(e)){editStyle("gridOverlay");return}Ee("toggleGrid"),gridOverlay.selectAll("*").remove()}}function Io(){gridOverlay.selectAll("*").remove();const e="#pattern_"+(gridOverlay.attr("type")||"pointyHex"),t=gridOverlay.attr("stroke")||"#808080",n=gridOverlay.attr("stroke-width")||.5,i=gridOverlay.attr("stroke-dasharray")||null,r=gridOverlay.attr("stroke-linecap")||null,c=gridOverlay.attr("scale")||1,f=gridOverlay.attr("dx")||0,z=gridOverlay.attr("dy")||0,m=`scale(${c}) translate(${f} ${z})`,b=Math.max(+mapWidthInput.value,graphWidth),A=Math.max(+mapHeightInput.value,graphHeight);d3.select(e).attr("stroke",t).attr("stroke-width",n).attr("stroke-dasharray",i).attr("stroke-linecap",r).attr("patternTransform",m),gridOverlay.append("rect").attr("width",b).attr("height",A).attr("fill","url("+e+")").attr("stroke","none")}function Ro(e){if(!coordinates.selectAll("*").size())Le("toggleCoordinates"),To(),e&&ge(e)&&editStyle("coordinates");else{if(e&&ge(e)){editStyle("coordinates");return}Ee("toggleCoordinates"),coordinates.selectAll("*").remove()}}function To(){if(!Pe("toggleCoordinates"))return;coordinates.selectAll("*").remove();const e=[.5,1,2,5,10,15,30],t=mapCoordinates.lonT/scale/10,n=e.reduce((u,C)=>Math.abs(C-t)<Math.abs(u-t)?C:u),i=+coordinates.attr("data-size");coordinates.attr("font-size",Math.max(O(i/scale**.8,2),.1));const r=d3.geoGraticule().extent([[mapCoordinates.lonW,mapCoordinates.latN],[mapCoordinates.lonE+.1,mapCoordinates.latS+.1]]).stepMajor([400,400]).stepMinor([n,n]),c=d3.geoEquirectangular().fitSize([graphWidth,graphHeight],r()),f=coordinates.append("g").attr("id","coordinateGrid"),z=coordinates.append("g").attr("id","coordinateLabels"),m=Po(scale+i+2,scale+i/2),b=r.lines().map(u=>{const C=u.coordinates[0][1]===u.coordinates[1][1],g=u.coordinates[0],p=c(g),[B,k]=C?[O(m.x,2),O(p[1],2)]:[O(p[0],2),O(m.y,2)],d=C?g[1]:g[0],s=d&&(Number.isInteger(d)?C?g[1]<0?-g[1]+"\xB0S":g[1]+"\xB0N":g[0]<0?-g[0]+"\xB0W":g[0]+"\xB0E":"");return{lat:C,x:B,y:k,text:s}}),A=round(d3.geoPath(c)(r()));f.append("path").attr("d",A).attr("vector-effect","non-scaling-stroke"),z.selectAll("text").data(b).enter().append("text").attr("x",u=>u.x).attr("y",u=>u.y).text(u=>u.text)}function Po(e,t){const n=ne("viewbox"),r=ne("map").createSVGPoint();return r.x=e,r.y=t,r.matrixTransform(n.getScreenCTM().inverse())}function Ho(e){if(!Pe("toggleCompass"))Le("toggleCompass"),$("#compass").fadeIn(),compass.selectAll("*").size()||(compass.append("use").attr("xlink:href","#rose"),shiftCompass()),e&&ge(e)&&editStyle("compass");else{if(e&&ge(e)){editStyle("compass");return}$("#compass").fadeOut(),Ee("toggleCompass")}}function Uo(e){if(!Pe("toggleRelief"))Le("toggleRelief"),terrain.selectAll("*").size()||ReliefIcons(),$("#terrain").fadeIn(),e&&ge(e)&&editStyle("terrain");else{if(e&&ge(e)){editStyle("terrain");return}$("#terrain").fadeOut(),Ee("toggleRelief")}}function No(e){if(Pe("toggleTexture")){if(e&&ge(e))return editStyle("texture");$("#texture").fadeOut(),Ee("toggleTexture")}else{if(Le("toggleTexture"),!texture.selectAll("*").size()){const t=+styleTextureShiftX.value,n=+styleTextureShiftY.value,i=texture.append("image").attr("id","textureImage").attr("x",t).attr("y",n).attr("width",graphWidth-t).attr("height",graphHeight-n).attr("preserveAspectRatio","xMidYMid slice");ka(styleTextureInput.value,r=>i.attr("xlink:href",r))}$("#texture").fadeIn(),zoom.scaleBy(svg,1.00001),e&&ge(e)&&editStyle("texture")}}function Ko(e){if(!Pe("toggleRivers"))Le("toggleRivers"),Ca(),e&&ge(e)&&editStyle("rivers");else{if(e&&ge(e))return editStyle("rivers");rivers.selectAll("*").remove(),Ee("toggleRivers")}}function Ca(){Q&&console.time("drawRivers"),rivers.selectAll("*").remove();const{addMeandering:e,getRiverPath:t}=Rivers;lineGen.curve(d3.curveCatmullRom.alpha(.1));const n=pack.rivers.map(({cells:i,points:r,i:c,widthFactor:f,sourceWidth:z})=>{if(!i||i.length<2)return;r&&r.length!==i.length&&(console.error(`River ${c} has ${i.length} cells, but only ${r.length} points defined. Resetting points data`),r=void 0);const m=e(i,r),b=t(m,f,z);return`<path id="river${c}" d="${b}"/>`});rivers.html(n.join("")),Q&&console.timeEnd("drawRivers")}function Do(e){if(!Pe("toggleRoutes"))Le("toggleRoutes"),$("#routes").fadeIn(),e&&ge(e)&&editStyle("routes");else{if(e&&ge(e)){editStyle("routes");return}$("#routes").fadeOut(),Ee("toggleRoutes")}}function Fo(e){if(!Pe("toggleMilitary"))Le("toggleMilitary"),$("#armies").fadeIn(),e&&ge(e)&&editStyle("armies");else{if(e&&ge(e)){editStyle("armies");return}$("#armies").fadeOut(),Ee("toggleMilitary")}}function Oo(e){if(!Pe("toggleMarkers"))Le("toggleMarkers"),Go(),e&&ge(e)&&editStyle("markers");else{if(e&&ge(e))return editStyle("markers");markers.selectAll("*").remove(),Ee("toggleMarkers")}}function Go(){const e=+markers.attr("rescale"),i=(+markers.attr("pinned")?pack.markers.filter(({pinned:r})=>r):pack.markers).map(r=>Wo(r,e));markers.html(i.join(""))}const jo=(e="bubble",t="#fff",n="#000")=>{if(e==="bubble")return`<path d="M6,19 l9,10 L24,19" fill="${n}" stroke="none" /><circle cx="15" cy="15" r="10" fill="${t}" stroke="${n}"/>`;if(e==="pin")return`<path d="m 15,3 c -5.5,0 -9.7,4.09 -9.7,9.3 0,6.8 9.7,17 9.7,17 0,0 9.7,-10.2 9.7,-17 C 24.7,7.09 20.5,3 15,3 Z" fill="${t}" stroke="${n}"/>`;if(e==="square")return`<path d="m 20,25 -5,4 -5,-4 z" fill="${n}"/><path d="M 5,5 H 25 V 25 H 5 Z" fill="${t}" stroke="${n}"/>`;if(e==="squarish")return`<path d="m 5,5 h 20 v 20 h -6 l -4,4 -4,-4 H 5 Z" fill="${t}" stroke="${n}" />`;if(e==="diamond")return`<path d="M 2,15 15,1 28,15 15,29 Z" fill="${t}" stroke="${n}" />`;if(e==="hex")return`<path d="M 15,29 4.61,21 V 9 L 15,3 25.4,9 v 12 z" fill="${t}" stroke="${n}" />`;if(e==="hexy")return`<path d="M 15,29 6,21 5,8 15,4 25,8 24,21 Z" fill="${t}" stroke="${n}" />`;if(e==="shieldy")return`<path d="M 15,29 6,21 5,7 c 0,0 5,-3 10,-3 5,0 10,3 10,3 l -1,14 z" fill="${t}" stroke="${n}" />`;if(e==="shield")return`<path d="M 4.6,5.2 H 25 v 6.7 A 20.3,20.4 0 0 1 15,29 20.3,20.4 0 0 1 4.6,11.9 Z" fill="${t}" stroke="${n}" />`;if(e==="pentagon")return`<path d="M 4,16 9,4 h 12 l 5,12 -11,13 z" fill="${t}" stroke="${n}" />`;if(e==="heptagon")return`<path d="M 15,29 6,22 4,12 10,4 h 10 l 6,8 -2,10 z" fill="${t}" stroke="${n}" />`;if(e==="circle")return`<circle cx="15" cy="15" r="11" fill="${t}" stroke="${n}" />`;if(e==="no")return""};function Wo(e,t=1){const{i:n,icon:i,x:r,y:c,dx:f=50,dy:z=50,px:m=12,size:b=30,pin:A,fill:u,stroke:C}=e,g=`marker${n}`,p=t?Math.max(O(b/5+24/scale,2),1):b,B=O(r-p/2,1),k=O(c-p,1),d=jo(A,u,C);return`<svg id="${g}" viewbox="0 0 30 30" width="${p}" height="${p}" x="${B}" y="${k}"><g>${d}</g><text x="${f}%" y="${z}%" font-size="${m}px" >${i}</text></svg>`}function qo(e){if(!Pe("toggleLabels"))Le("toggleLabels"),labels.style("display",null),wt(),e&&ge(e)&&editStyle("labels");else{if(e&&ge(e)){editStyle("labels");return}Ee("toggleLabels"),labels.style("display","none")}}function Vo(e){if(!Pe("toggleIcons"))Le("toggleIcons"),$("#icons").fadeIn(),e&&ge(e)&&editStyle("burgIcons");else{if(e&&ge(e)){editStyle("burgIcons");return}Ee("toggleIcons"),$("#icons").fadeOut()}}function Zo(e){if(!Pe("toggleRulers"))Le("toggleRulers"),e&&ge(e)&&editStyle("ruler"),rulers.draw(),ruler.style("display",null);else{if(e&&ge(e)){editStyle("ruler");return}Ee("toggleRulers"),ruler.selectAll("*").remove(),ruler.style("display","none")}}function Jo(e){if(!Pe("toggleScaleBar"))Le("toggleScaleBar"),$("#scaleBar").fadeIn(),e&&ge(e)&&editUnits();else{if(e&&ge(e)){editUnits();return}$("#scaleBar").fadeOut(),Ee("toggleScaleBar")}}function Yo(e){if(!Pe("toggleZones"))Le("toggleZones"),$("#zones").fadeIn(),e&&ge(e)&&editStyle("zones");else{if(e&&ge(e)){editStyle("zones");return}Ee("toggleZones"),$("#zones").fadeOut()}}function Xo(e){if(!Pe("toggleEmblems"))Le("toggleEmblems"),emblems.selectAll("use").size()||Qo(),$("#emblems").fadeIn(),e&&ge(e)&&editStyle("emblems");else{if(e&&ge(e)){editStyle("emblems");return}$("#emblems").fadeOut(),Ee("toggleEmblems")}}function Qo(){Q&&console.time("drawEmblems");const{states:e,provinces:t,burgs:n}=pack,i=e.filter(d=>d.i&&!d.removed&&d.coa&&d.coaSize!=0),r=t.filter(d=>d.i&&!d.removed&&d.coa&&d.coaSize!=0),c=n.filter(d=>d.i&&!d.removed&&d.coa&&d.coaSize!=0),f=()=>{const d=Ie((graphHeight+graphWidth)/40,10,100),s=1+i.length/100-(15-i.length)/200,o=+ne("emblemsStateSizeInput").value||1;return O(d/s*o)},z=()=>{const d=Ie((graphHeight+graphWidth)/100,5,70),s=1+r.length/1e3-(115-r.length)/1e3,o=+ne("emblemsProvinceSizeInput").value||1;return O(d/s*o)},b=(()=>{const d=Ie((graphHeight+graphWidth)/185,2,50),s=1+c.length/1e3-(450-c.length)/1e3,o=+ne("emblemsBurgSizeInput").value||1;return O(d/s*o)})(),A=c.map(d=>{const{x:s,y:o}=d,l=d.coaSize||1,a=b*l/2;return{type:"burg",i:d.i,x:s,y:o,size:l,shift:a}}),u=z(),C=r.map(d=>{d.pole||xa();const[s,o]=d.pole||pack.cells.p[d.center],l=d.coaSize||1,a=u*l/2;return{type:"province",i:d.i,x:s,y:o,size:l,shift:a}}),g=f(),p=i.map(d=>{const[s,o]=d.pole||pack.cells.p[d.center],l=d.coaSize||1,a=g*l/2;return{type:"state",i:d.i,x:s,y:o,size:l,shift:a}}),B=A.concat(C).concat(p),k=d3.forceSimulation(B).alphaMin(.6).alphaDecay(.2).velocityDecay(.6).force("collision",d3.forceCollide().radius(d=>d.shift)).stop();d3.timeout(function(){const d=Math.ceil(Math.log(k.alphaMin())/Math.log(1-k.alphaDecay()));for(let h=0;h<d;++h)k.tick();const o=B.filter(h=>h.type==="burg").map(h=>`<use data-i="${h.i}" x="${O(h.x-h.shift)}" y="${O(h.y-h.shift)}" width="${h.size}em" height="${h.size}em"/>`).join("");emblems.select("#burgEmblems").attr("font-size",b).html(o);const a=B.filter(h=>h.type==="province").map(h=>`<use data-i="${h.i}" x="${O(h.x-h.shift)}" y="${O(h.y-h.shift)}" width="${h.size}em" height="${h.size}em"/>`).join("");emblems.select("#provinceEmblems").attr("font-size",u).html(a);const S=B.filter(h=>h.type==="state").map(h=>`<use data-i="${h.i}" x="${O(h.x-h.shift)}" y="${O(h.y-h.shift)}" width="${h.size}em" height="${h.size}em"/>`).join("");emblems.select("#stateEmblems").attr("font-size",g).html(S),wt()}),Q&&console.timeEnd("drawEmblems")}function Pe(e){return!ne(e).classList.contains("buttonoff")}function Ee(e){ne(e).classList.add("buttonoff"),wa()}function Le(e){ne(e).classList.remove("buttonoff"),wa()}$("#mapLayers").sortable({items:"li:not(.solid)",containment:"parent",cancel:".solid",update:$o});function $o(e,t){const n=Nt(t.item.attr("id"));if(!n)return;const i=Nt(t.item.prev().attr("id")),r=Nt(t.item.next().attr("id"));i?n.insertAfter(i):r&&n.insertBefore(r)}function Nt(e){if(e==="toggleHeight")return $("#terrs");if(e==="toggleBiomes")return $("#biomes");if(e==="toggleCells")return $("#cells");if(e==="toggleGrid")return $("#gridOverlay");if(e==="toggleCoordinates")return $("#coordinates");if(e==="toggleCompass")return $("#compass");if(e==="toggleRivers")return $("#rivers");if(e==="toggleRelief")return $("#terrain");if(e==="toggleReligions")return $("#relig");if(e==="toggleCultures")return $("#cults");if(e==="toggleStates")return $("#regions");if(e==="toggleProvinces")return $("#provs");if(e==="toggleBorders")return $("#borders");if(e==="toggleRoutes")return $("#routes");if(e==="toggleTemp")return $("#temperature");if(e==="togglePrec")return $("#prec");if(e==="togglePopulation")return $("#population");if(e==="toggleIce")return $("#ice");if(e==="toggleTexture")return $("#texture");if(e==="toggleEmblems")return $("#emblems");if(e==="toggleLabels")return $("#labels");if(e==="toggleIcons")return $("#icons");if(e==="toggleMarkers")return $("#markers");if(e==="toggleRulers")return $("#ruler")}window.BurgsAndStates=function(){const e=function(){const{cells:o,cultures:l}=pack,a=o.i.length;o.burg=new Uint16Array(a),o.road=new Uint16Array(a),o.crossroad=new Uint16Array(a);const w=pack.burgs=E();pack.states=P();const S=Routes.getRoads();T(),c(),f();const h=Routes.getTrails();t();const v=Routes.getSearoutes();b(),A(),g(),p(),Routes.draw(S,h,v),r();function E(){Q&&console.time("placeCapitals");let R=+regionsOutput.value,L=[0];const M=()=>.5+Math.random()*.5,I=new Int16Array(o.s.map(U=>U*M())),H=o.i.filter(U=>I[U]>0&&o.culture[U]).sort((U,F)=>I[F]-I[U]);if(H.length<R*10)if(R=Math.floor(H.length/10),R)WARN&&console.warn(`Not enough populated cells (${H.length}). Will generate only ${R} states`);else return WARN&&console.warn("There is no populated cells. Cannot generate states"),L;let G=d3.quadtree(),D=(graphWidth+graphHeight)/2/R;for(let U=0;L.length<=R;U++){const F=H[U],[j,Z]=o.p[F];G.find(j,Z,D)===void 0&&(L.push({cell:F,x:j,y:Z}),G.add([j,Z])),U===H.length-1&&(WARN&&console.warn("Cannot place capitals with current spacing. Trying again with reduced spacing"),G=d3.quadtree(),U=-1,L=[0],D/=1.2)}return L[0]=G,Q&&console.timeEnd("placeCapitals"),L}function P(){Q&&console.time("createStates");const R=[{i:0,name:"Neutrals"}],L=va(w.length-1),M=zn(5);return w.forEach(function(I,H){if(!H)return;I.i=I.state=H,I.culture=o.culture[I.cell],I.name=Names.getCultureShort(I.culture),I.feature=o.f[I.cell],I.capital=1;const G=O(Math.random()*powerInput.value+1,1),D=I.name.length<9&&M(I.cell)?I.name:Names.getCultureShort(I.culture),U=Names.getState(D,I.culture),F=l[I.culture].type,j=COA.generate(null,null,null,F);j.shield=COA.getShield(I.culture,null),R.push({i:H,color:L[H-1],name:U,expansionism:G,capital:H,type:F,center:I.cell,culture:I.culture,coa:j}),o.burg[I.cell]=H}),Q&&console.timeEnd("createStates"),R}function T(){Q&&console.time("placeTowns");const R=new Int16Array(o.s.map(U=>U*Ce(1,3,0,20,3))),L=o.i.filter(U=>!o.burg[U]&&R[U]>0&&o.culture[U]).sort((U,F)=>R[F]-R[U]),M=manorsInput.value==1e3?O(L.length/5/(grid.points.length/1e4)**.8):manorsInput.valueAsNumber,I=Math.min(M,L.length);let H=0;const G=w[0];let D=(graphWidth+graphHeight)/150/(I**.7/66);for(;H<I&&D>1;){for(let U=0;H<I&&U<L.length;U++){if(o.burg[L[U]])continue;const F=L[U],j=o.p[F][0],Z=o.p[F][1],te=D*Ce(1,.3,.2,2,2);if(G.find(j,Z,te)!==void 0)continue;const q=w.length,X=o.culture[F],ee=Names.getCulture(X);w.push({cell:F,x:j,y:Z,state:0,i:q,culture:X,name:ee,capital:0,feature:o.f[F]}),G.add([j,Z]),o.burg[F]=q,H++}D*=.5}manorsInput.value!=1e3&&H<M&&ERROR&&console.error(`Cannot place all burgs. Requested ${M}, placed ${H}`),w[0]={name:void 0},Q&&console.timeEnd("placeTowns")}},t=function(){Q&&console.time("specifyBurgs");const o=pack.cells;pack.vertices;const l=pack.features,a=grid.cells.temp;for(const S of pack.burgs){if(!S.i||S.lock)continue;const h=S.cell,v=o.haven[h];if(v&&a[o.g[h]]>0){const L=o.f[v],M=l[L].cells>1&&(S.capital&&o.harbor[h]||o.harbor[h]===1);S.port=M?L:0}else S.port=0;if(S.population=O(Math.max((o.s[h]+o.road[h]/2)/8+S.i/1e3+h%100/1e3,.1),3),S.capital&&(S.population=O(S.population*1.3,3)),S.port){S.population=S.population*1.3;const[L,M]=ya(h,v);S.x=L,S.y=M}if(S.population=O(S.population*Ce(2,3,.6,20,3),3),!S.port&&o.r[h]){const L=Math.min(o.fl[h]/150,1);h%2?S.x=O(S.x+L,2):S.x=O(S.x-L,2),o.r[h]%2?S.y=O(S.y+L,2):S.y=O(S.y-L,2)}const E=pack.states[S.state],P=E.coa;let T=.25;S.capital?T+=.1:S.port&&(T-=.1),S.culture!==E.culture&&(T-=.25),S.type=n(h,S.port);const R=S.capital&&V(.2)?"Capital":S.type==="Generic"?"City":S.type;S.coa=COA.generate(P,T,null,R),S.coa.shield=COA.getShield(S.culture,S.state)}const w=pack.burgs.filter(S=>!S.removed&&S.port>0);for(const S of l){if(!S.i||S.land||S.border)continue;const h=w.filter(v=>v.port===S.i);h.length===1&&(h[0].port=0)}Q&&console.timeEnd("specifyBurgs")},n=function(o,l){const a=pack.cells;if(l)return"Naval";if(a.haven[o]&&pack.features[a.f[a.haven[o]]].type==="lake")return"Lake";if(a.h[o]>60)return"Highland";if(a.r[o]&&a.r[o].length>100&&a.r[o].length>=pack.rivers[0].length)return"River";if(!a.burg[o]||pack.burgs[a.burg[o]].population<6){if(population<5&&[1,2,3,4].includes(a.biome[o]))return"Nomadic";if(a.biome[o]>4&&a.biome[o]<10)return"Hunting"}return"Generic"},i=function(o){const l=pack.cells;pack.burgs.filter(a=>o?a.i==o.i:a.i&&!a.removed).forEach(a=>{const w=a.population;a.citadel=a.capital||w>50&&V(.75)||V(.5)?1:0,a.plaza=w>50||w>30&&V(.75)||w>10&&V(.5)||V(.25)?1:0,a.walls=a.capital||w>30||w>20&&V(.75)||w>10&&V(.5)||V(.2)?1:0,a.shanty=w>60||w>40&&V(.75)||w>20&&a.walls&&V(.4)?1:0;const S=l.religion[a.cell],h=pack.states[a.state].form==="Theocracy";a.temple=S&&h||w>50||w>35&&V(.75)||w>20&&V(.5)?1:0})},r=function(){Q&&console.time("drawBurgs"),burgIcons.selectAll("circle").remove(),burgLabels.selectAll("text").remove(),icons.selectAll("use").remove();const o=pack.burgs.filter(M=>M.capital&&!M.removed),l=burgIcons.select("#cities"),a=burgLabels.select("#cities"),w=l.attr("size")||1,S=anchors.selectAll("#cities"),h=S.attr("size")||2;l.selectAll("circle").data(o).enter().append("circle").attr("id",M=>"burg"+M.i).attr("data-id",M=>M.i).attr("cx",M=>M.x).attr("cy",M=>M.y).attr("r",w),a.selectAll("text").data(o).enter().append("text").attr("id",M=>"burgLabel"+M.i).attr("data-id",M=>M.i).attr("x",M=>M.x).attr("y",M=>M.y).attr("dy",`${w*-1.5}px`).text(M=>M.name),S.selectAll("use").data(o.filter(M=>M.port)).enter().append("use").attr("xlink:href","#icon-anchor").attr("data-id",M=>M.i).attr("x",M=>O(M.x-h*.47,2)).attr("y",M=>O(M.y-h*.47,2)).attr("width",h).attr("height",h);const v=pack.burgs.filter(M=>M.i&&!M.capital&&!M.removed),E=burgIcons.select("#towns"),P=burgLabels.select("#towns"),T=E.attr("size")||.5,R=anchors.selectAll("#towns"),L=R.attr("size")||1;E.selectAll("circle").data(v).enter().append("circle").attr("id",M=>"burg"+M.i).attr("data-id",M=>M.i).attr("cx",M=>M.x).attr("cy",M=>M.y).attr("r",T),P.selectAll("text").data(v).enter().append("text").attr("id",M=>"burgLabel"+M.i).attr("data-id",M=>M.i).attr("x",M=>M.x).attr("y",M=>M.y).attr("dy",`${T*-1.5}px`).text(M=>M.name),R.selectAll("use").data(v.filter(M=>M.port)).enter().append("use").attr("xlink:href","#icon-anchor").attr("data-id",M=>M.i).attr("x",M=>O(M.x-L*.47,2)).attr("y",M=>O(M.y-L*.47,2)).attr("width",L).attr("height",L),Q&&console.timeEnd("drawBurgs")},c=function(){Q&&console.time("expandStates");const{cells:o,states:l,cultures:a,burgs:w}=pack;o.state=new Uint16Array(o.i.length);const S=new PriorityQueue({comparator:(L,M)=>L.p-M.p}),h=[],v=o.i.length/5e3*2500*neutralInput.value*statesNeutral;for(l.filter(L=>L.i&&!L.removed).forEach(L=>{const M=w[L.capital].cell;o.state[M]=L.i;const I=a[L.culture].center,H=o.biome[I];S.queue({e:L.center,p:0,s:L.i,b:H}),h[L.center]=1});S.length;){const L=S.dequeue(),{e:M,p:I,s:H,b:G}=L,{type:D,culture:U}=l[H];o.c[M].forEach(F=>{if(o.state[F]&&F===l[o.state[F]].center)return;const j=U===o.culture[F]?-9:100,Z=o.h[F]<20?0:o.s[F]?Math.max(20-o.s[F],0):5e3,te=E(G,o.biome[F],D),q=P(pack.features[o.f[F]],o.h[F],D),X=T(o.r[F],F,D),ee=R(o.t[F],D),le=Math.max(j+Z+te+q+X+ee,0),Y=I+10+le/l[H].expansionism;Y>v||(!h[F]||Y<h[F])&&(o.h[F]>=20&&(o.state[F]=H),h[F]=Y,S.queue({e:F,p:Y,s:H,b:G}))})}w.filter(L=>L.i&&!L.removed).forEach(L=>L.state=o.state[L.cell]);function E(L,M,I){return L===M?10:I==="Hunting"?biomesData.cost[M]*2:I==="Nomadic"&&M>4&&M<10?biomesData.cost[M]*3:biomesData.cost[M]}function P(L,M,I){return I==="Lake"&&L.type==="lake"?10:I==="Naval"&&M<20?300:I==="Nomadic"&&M<20?1e4:M<20?1e3:I==="Highland"&&M<62?1100:I==="Highland"?0:M>=67?2200:M>=44?300:0}function T(L,M,I){return I==="River"?L?0:100:L?Ie(o.fl[M]/10,20,100):0}function R(L,M){return L===1?M==="Naval"||M==="Lake"?0:M==="Nomadic"?60:20:L===2?M==="Naval"||M==="Nomadic"?30:0:L!==-1&&(M==="Naval"||M==="Lake")?100:0}Q&&console.timeEnd("expandStates")},f=function(){Q&&console.time("normalizeStates");const o=pack.cells,l=pack.burgs;for(const a of o.i){if(o.h[a]<20||o.burg[a]||o.c[a].some(v=>l[o.burg[v]].capital))continue;const w=o.c[a].filter(v=>o.h[v]>=20),S=w.filter(v=>o.state[v]!==o.state[a]);if(S.length<2)continue;const h=w.filter(v=>o.state[v]===o.state[a]);h.length>2||S.length<=h.length||(o.state[a]=o.state[S[0]])}Q&&console.timeEnd("normalizeStates")},z=function(){Q&&console.time("updateCulturesForBurgsAndStates"),pack.burgs=pack.burgs.map((o,l)=>l===0?o:{...o,culture:pack.cells.culture[o.cell]}),pack.states=pack.states.map((o,l)=>l===0?o:{...o,culture:pack.cells.culture[o.center]}),Q&&console.timeEnd("updateCulturesForBurgsAndStates")},m=function(o){Q&&console.time("drawStateLabels");const{cells:l,features:a,states:w}=pack,S=[];lineGen.curve(d3.curveBundle.beta(1));const h=options.stateLabelsMode||"auto";for(const E of w){let U=function(j,Z,te){const q=[j],X=new Set;for(;q.length;){const ee=q.pop(),le=l.c[ee].filter(Y=>l.state[Y]===Z);l.c[ee].forEach(function(Y,W){const de=a[l.f[Y]].type==="lake"&&a[l.f[Y]].cells<te;if(l.b[Y]||l.state[Y]!==Z&&!de)return X.add(l.v[ee][W]);const me=le.some(pe=>l.c[Y].includes(pe));if(X.size>20&&!me&&!de)return X.add(l.v[ee][W]);P[Y]||(P[Y]=1,q.push(Y))})}return X},F=function(j,Z){const te=j.p.map(function(we){return we[0]<=0||we[1]<=0||we[0]>=graphWidth||we[1]>=graphHeight?!1:P[Te(we[0],we[1])]}),q=d3.range(j.p.length).filter(we=>te[we]);if(!q.length)return[0];const X=j.p.length<200?0:j.p.length<600?.5:1,ee=q[d3.scan(q,(we,ke)=>j.p[we][0]-j.p[ke][0]+(Math.abs(j.p[we][1]-Z)-Math.abs(j.p[ke][1]-Z))*X)],le=q[d3.scan(q,(we,ke)=>j.p[ke][0]-j.p[we][0]-(Math.abs(j.p[ke][1]-Z)-Math.abs(j.p[we][1]-Z))*X)],Y=new PriorityQueue({comparator:(we,ke)=>we.p-ke.p}),W=[],de=[];for(Y.queue({e:le,p:0});Y.length;){const we=Y.dequeue(),ke=we.e,He=we.p;if(ke===ee)break;for(const Be of j.v[ke]){if(Be===-1)continue;const Fe=He+(te[Be]?1:100);de[Be]||Fe>=W[Be]||(W[Be]=Fe,de[Be]=ke,Y.queue({e:Be,p:Fe}))}}const me=[ee];let pe=ee;for(;pe!==le;)pe=de[pe],te[pe]&&me.push(pe);return me};if(!E.i||E.removed||!E.cells||o&&!o.includes(E.i))continue;const P=[],T=Te(E.pole[0],E.pole[1]),R=l.state[T]===E.i?T:E.center,M=[...U(R,E.i,E.cells/10)].map(j=>pack.vertices.p[j]),I=Delaunator.from(M),H=new Voronoi(I,M,M.length),G=F(H.vertices,E.pole[1]),D=G.map(j=>H.vertices.p[j]).filter((j,Z)=>Z%15===0||Z+1===G.length);S.push([E.i,D])}(function(){const P=labels.select("#states"),T=defs.select("#textPaths"),R=Pe("toggleLabels");R||toggleLabels(),o||(P.selectAll("text").remove(),T.selectAll("path[id*='stateLabel']").remove());const L=P.append("text").attr("x",0).attr("x",0).text("Average"),M=L.node().getComputedTextLength()/7;S.forEach(I=>{const H=I[0],G=w[I[0]],{name:D,fullName:U}=G;o&&(T.select("#textPath_stateLabel"+H).remove(),P.select("#stateLabel"+H).remove());const F=I[1].length>1?it(lineGen(I[1])):`M${I[1][0][0]-50},${I[1][0][1]}h${100}`,j=T.append("path").attr("d",F).attr("id","textPath_stateLabel"+H),Z=I[1].length>1?j.node().getTotalLength()/M:0,[te,q]=v(h,D,U,Z);if(Z&&Z<te[0].length){const oe=I[1],ce=oe[0],ye=oe[oe.length-1],[Se,ve]=[ye[0]-ce[0],ye[1]-ce[1]],Ue=Math.abs(M*te[0].length/Se)/2;oe[0]=[O(ce[0]-Se*Ue),O(ce[1]-ve*Ue)],oe[oe.length-1]=[O(ye[0]+Se*Ue),O(ye[1]+ve*Ue)],j.attr("d",it(lineGen(oe)))}L.attr("font-size",q+"%");const X=(te.length-1)/-2,ee=te.map((oe,ce)=>{L.text(oe);const ye=L.node().getBBox().width/-2;return`<tspan x=${O(ye,1)} dy="${ce?1:X}em">${oe}</tspan>`}),le=P.append("text").attr("id","stateLabel"+H).append("textPath").attr("xlink:href","#textPath_stateLabel"+H).attr("startOffset","50%").attr("font-size",q+"%").node();if(le.insertAdjacentHTML("afterbegin",ee.join("")),h==="full"||te.length===1)return;const Y=pack.cells.state,W=le.parentNode.getBBox(),de=()=>+Y[Te(W.x,W.y)]===H,me=()=>+Y[Te(W.x+W.width/2,W.y)]===H,pe=()=>+Y[Te(W.x+W.width,W.y)]===H,we=()=>+Y[Te(W.x+W.width,W.y+W.height)]===H,ke=()=>+Y[Te(W.x+W.width/2,W.y+W.height)]===H,He=()=>+Y[Te(W.x,W.y+W.height)]===H;if(de()+me()+pe()+we()+ke()+He()>3)return;const Be=Z>U.length*1.8?U:D;L.text(Be);const Fe=L.node().getBBox().width/-2;le.innerHTML=`<tspan x="${Fe}px">${Be}</tspan>`;const _=Ie(O(Z/Be.length*60),40,130);le.setAttribute("font-size",_+"%")}),L.remove(),R||toggleLabels()})();function v(E,P,T,R){if(E==="short"||E==="auto"&&R<P.length){const I=ia(P),H=R/I[0].length;return[I,Ie(O(H*60),50,150)]}if(R>T.length*2.5){const I=[T],H=R/I[0].length;return[I,Ie(O(H*70),70,170)]}const L=ia(T),M=R/L[0].length;return[L,Ie(O(M*60),70,150)]}Q&&console.timeEnd("drawStateLabels")},b=function(){Q&&console.time("collectStatistics");const{cells:o,states:l}=pack;l.forEach(a=>{a.removed||(a.cells=a.area=a.burgs=a.rural=a.urban=0,a.neighbors=new Set)});for(const a of o.i){if(o.h[a]<20)continue;const w=o.state[a];o.c[a].filter(S=>o.h[S]>=20&&o.state[S]!==w).forEach(S=>l[w].neighbors.add(o.state[S])),l[w].cells+=1,l[w].area+=o.area[a],l[w].rural+=o.pop[a],o.burg[a]&&(l[w].urban+=pack.burgs[o.burg[a]].population,l[w].burgs++)}l.forEach(a=>{!a.neighbors||(a.neighbors=Array.from(a.neighbors))}),Q&&console.timeEnd("collectStatistics")},A=function(){Q&&console.time("assignColors");const o=["#66c2a5","#fc8d62","#8da0cb","#e78ac3","#a6d854","#ffd92f"];pack.states.forEach(l=>{if(!l.i||l.removed)return;const a=l.neighbors;l.color=o.find(w=>a.every(S=>pack.states[S].color!==w)),l.color||(l.color=Ct()),o.push(o.shift())}),o.forEach(l=>{pack.states.filter(w=>w.color===l).forEach((w,S)=>{!S||(w.color=tt(w.color))})}),Q&&console.timeEnd("assignColors")},u={War:6,Conflict:2,Campaign:4,Invasion:2,Rebellion:2,Conquest:2,Intervention:1,Expedition:1,Crusade:1},C=o=>(o.neighbors.length?o.neighbors:[0]).map(a=>{const w=a&&V(.8)?pack.states[a].name:Names.getCultureShort(o.culture),S=Ce(options.year-100,150,1,options.year-6),h=S+Ce(4,5,1,options.year-S-1);return{name:We(w)+" "+he(u),start:S,end:h}}).sort((a,w)=>a.start-w.start),g=function(){pack.states.forEach(o=>{!o.i||o.removed||(o.campaigns=C(o))})},p=function(){Q&&console.time("generateDiplomacy");const o=pack.cells,l=pack.states,a=l[0].diplomacy=[],w=l.filter(T=>T.i&&!l.removed),S={Ally:1,Friendly:2,Neutral:1,Suspicion:10,Rival:9},h={Ally:10,Friendly:8,Neutral:5,Suspicion:1},v={Friendly:1,Neutral:12,Suspicion:2,Unknown:6},E={Neutral:1,Suspicion:2,Rival:1,Unknown:1};if(w.forEach(T=>T.diplomacy=new Array(l.length).fill("x")),w.length<2)return;const P=d3.mean(w.map(T=>T.area));for(let T=1;T<l.length;T++)if(!l[T].removed){if(l[T].diplomacy.includes("Vassal")){const R=l[T].diplomacy.indexOf("Vassal");for(let L=1;L<l.length;L++)if(!(L===T||L===R)){l[T].diplomacy[L]=l[R].diplomacy[L],l[R].diplomacy[L]==="Suzerain"&&(l[T].diplomacy[L]="Ally");for(let M=1;M<l.length;M++)M===T||M===R||l[M].diplomacy[R]==="Suzerain"||l[M].diplomacy[R]==="Vassal"||(l[M].diplomacy[T]=l[M].diplomacy[R])}continue}for(let R=T+1;R<l.length;R++){if(l[R].removed)continue;if(l[R].diplomacy.includes("Vassal")){const G=l[R].diplomacy.indexOf("Vassal");l[T].diplomacy[R]=l[T].diplomacy[G];continue}const L=l[T].type==="Naval"&&l[R].type==="Naval"&&o.f[l[T].center]!==o.f[l[R].center],M=L?!1:l[T].neighbors.includes(R),I=L||M?!1:l[T].neighbors.map(G=>l[G].neighbors).join("").includes(R);let H=he(L?E:M?S:I?h:v);M&&V(.8)&&l[T].area>P&&l[R].area<P&&l[T].area/l[R].area>2&&(H="Vassal"),l[T].diplomacy[R]=H==="Vassal"?"Suzerain":H,l[R].diplomacy[T]=H}}for(let T=1;T<l.length;T++){const R=l[T].diplomacy;if(l[T].removed||!R.includes("Rival")||R.includes("Vassal")||R.includes("Enemy"))continue;const L=ie(R.map((q,X)=>q==="Rival"&&!l[X].diplomacy.includes("Vassal")?X:0).filter(q=>q));let M=l[T].area*l[T].expansionism,I=l[L].area*l[L].expansionism;if(M<I*Ce(1.6,.8,0,10,2))continue;const H=l[T].name,G=l[L].name,D=[T],U=[L],F=l[L].diplomacy,j=[`${H}-${Ke(G)}ian War`,`${H} declared a war on its rival ${G}`],Z=options.year,te=Z-Ce(2,2,0,5);l[T].campaigns.push({name:`${Ke(G)}ian War`,start:te,end:Z}),l[L].campaigns.push({name:`${Ke(H)}ian War`,start:te,end:Z}),R.forEach((q,X)=>{q==="Suzerain"&&(D.push(X),j.push(`${H}'s vassal ${l[X].name} joined the war on attackers side`))}),F.forEach((q,X)=>{q==="Suzerain"&&(U.push(X),j.push(`${G}'s vassal ${l[X].name} joined the war on defenders side`))}),M=d3.sum(D.map(q=>l[q].area*l[q].expansionism)),I=d3.sum(U.map(q=>l[q].area*l[q].expansionism)),F.forEach((q,X)=>{if(!(q!=="Ally"||l[X].diplomacy.includes("Vassal"))){if(l[X].diplomacy[T]!=="Rival"&&M/I>2*Ce(1.6,.8,0,10,2)){const ee=l[X].diplomacy.includes("Enemy")?"Being already at war,":`Frightened by ${H},`;j.push(`${ee} ${l[X].name} severed the defense pact with ${G}`),F[X]=l[X].diplomacy[L]="Suspicion";return}U.push(X),I+=l[X].area*l[X].expansionism,j.push(`${G}'s ally ${l[X].name} joined the war on defenders side`),l[X].diplomacy.map((ee,le)=>ee==="Suzerain"?le:0).filter(ee=>ee).forEach(ee=>{U.push(ee),I+=l[ee].area*l[ee].expansionism,j.push(`${l[X].name}'s vassal ${l[ee].name} joined the war on defenders side`)})}}),R.forEach((q,X)=>{if(q!=="Ally"||l[X].diplomacy.includes("Vassal")||U.includes(X))return;const ee=l[X].name;if(l[X].diplomacy[L]!=="Rival"&&(V(.2)||M<=I*1.2)){j.push(`${H}'s ally ${ee} avoided entering the war`);return}if(l[X].diplomacy.map((Y,W)=>Y==="Ally"?W:0).filter(Y=>Y).some(Y=>U.includes(Y))){j.push(`${H}'s ally ${ee} did not join the war as its allies are in war on both sides`);return}D.push(X),M+=l[X].area*l[X].expansionism,j.push(`${H}'s ally ${ee} joined the war on attackers side`),l[X].diplomacy.map((Y,W)=>Y==="Suzerain"?W:0).filter(Y=>Y).forEach(Y=>{D.push(Y),I+=l[Y].area*l[Y].expansionism,j.push(`${l[X].name}'s vassal ${l[Y].name} joined the war on attackers side`)})}),D.forEach(q=>U.forEach(X=>l[q].diplomacy[X]=l[X].diplomacy[q]="Enemy")),a.push(j)}Q&&console.timeEnd("generateDiplomacy")},B=function(o){Q&&console.time("defineStateForms");const l=pack.states.filter(I=>I.i&&!I.removed);if(l.length<1)return;const a={Monarchy:25,Republic:2,Union:1},w={Monarchy:25,Republic:8,Union:3},S=d3.median(pack.states.map(I=>I.area)),h=l.map(I=>I.area).sort((I,H)=>H-I)[Math.max(Math.ceil(l.length**.4)-2,0)],v=pack.states.map(I=>{let H=Math.min(Math.floor(I.area/S*2.6),4);return H===4&&I.area<h&&(H=3),H}),E=["Duchy","Grand Duchy","Principality","Kingdom","Empire"],P={Republic:75,Federation:4,"Trade Company":4,"Most Serene Republic":2,Oligarchy:2,Tetrarchy:1,Triumvirate:1,Diarchy:1,Junta:1},T={Union:3,League:4,Confederation:1,"United Kingdom":1,"United Republic":1,"United Provinces":2,Commonwealth:1,Heptarchy:1},R={Theocracy:20,Brotherhood:1,Thearchy:2,See:1,"Holy State":1},L={"Free Territory":2,Council:3,Commune:1,Community:1};for(const I of l){if(o&&!o.includes(I.i))continue;const H=v[I.i],G=pack.cells.religion[I.center],D=G&&pack.religions[G].expansion==="state"||V(.1)&&["Organized","Cult"].includes(pack.religions[G].type),U=V(.01-H/500);D?I.form="Theocracy":U?I.form="Anarchy":I.form=I.type==="Naval"?he(w):he(a),I.formName=M(I,H),I.fullName=d(I)}function M(I,H){const G=pack.cultures[I.culture].base;if(I.form==="Monarchy"){const D=E[H];if(I.diplomacy){if(D==="Duchy"&&I.neighbors.length>1&&be(6)<I.neighbors.length&&I.diplomacy.includes("Vassal"))return"Marches";if(G===1&&V(.3)&&I.diplomacy.includes("Vassal"))return"Dominion";if(V(.3)&&I.diplomacy.includes("Vassal"))return"Protectorate"}return G===16&&(D==="Empire"||D==="Kingdom")?"Sultanate":G===5&&(D==="Empire"||D==="Kingdom")?"Tsardom":[16,31].includes(G)&&(D==="Empire"||D==="Kingdom")?"Khaganate":G===12&&(D==="Kingdom"||D==="Grand Duchy")?"Shogunate":[18,17].includes(G)&&D==="Empire"?"Caliphate":G===18&&(D==="Grand Duchy"||D==="Duchy")?"Emirate":G===7&&(D==="Grand Duchy"||D==="Duchy")?"Despotate":G===31&&(D==="Grand Duchy"||D==="Duchy")?"Ulus":G===16&&(D==="Grand Duchy"||D==="Duchy")?"Horde":G===24&&(D==="Grand Duchy"||D==="Duchy")?"Satrapy":D}if(I.form==="Republic"){if(H<2&&I.burgs===1){if(Ke(I.name)===Ke(pack.burgs[I.capital].name))return I.name=pack.burgs[I.capital].name,"Free City";if(V(.3))return"City-state"}return he(P)}if(I.form==="Union")return he(T);if(I.form==="Anarchy")return he(L);if(I.form==="Theocracy"){if([0,1,2,3,4,6,8,9,13,15,20].includes(G)){if(V(.1))return"Divine "+E[H];if(H<2&&V(.5))return"Diocese";if(H<2&&V(.5))return"Bishopric"}if(V(.9)&&[7,5].includes(G)){if(H<2)return"Eparchy";if(H===2)return"Exarchate";if(H>2)return"Patriarchate"}return V(.9)&&[21,16].includes(G)?"Imamah":H>2&&V(.8)&&[18,17,28].includes(G)?"Caliphate":he(R)}}Q&&console.timeEnd("defineStateForms")},k=["Empire","Sultanate","Khaganate","Shogunate","Caliphate","Despotate","Theocracy","Oligarchy","Union","Confederation","Trade Company","League","Tetrarchy","Triumvirate","Diarchy","Horde","Marches"],d=function(o){return o.formName?!o.name&&o.formName?"The "+o.formName:k.includes(o.formName)&&!/-| /.test(o.name)?`${We(o.name)} ${o.formName}`:`${o.formName} of ${o.name}`:o.name};return{generate:e,expandStates:c,normalizeStates:f,assignColors:A,drawBurgs:r,specifyBurgs:t,defineBurgFeatures:i,getType:n,drawStateLabels:m,collectStatistics:b,generateCampaign:C,generateCampaigns:g,generateDiplomacy:p,defineStateForms:B,getFullName:d,generateProvinces:function(o){Q&&console.time("generateProvinces");const l=o?Jt():seed;Math.random=aleaPRNG(l);const{cells:a,states:w,burgs:S}=pack,h=pack.provinces=[0];a.province=new Uint16Array(a.i.length);const v=+provincesInput.value;if(w.length<2||!v){w.forEach(M=>M.provinces=[]);return}const E=v==100?1e3:Ce(20,5,5,100)*v**.5,P={Monarchy:{County:22,Earldom:6,Shire:2,Landgrave:2,Margrave:2,Barony:2,Captaincy:1,Seneschalty:1},Republic:{Province:6,Department:2,Governorate:2,District:1,Canton:1,Prefecture:1},Theocracy:{Parish:3,Deanery:1},Union:{Province:1,State:1,Canton:1,Republic:1,County:1,Council:1},Anarchy:{Council:1,Commune:1,Community:1,Tribe:1},Wild:{Territory:10,Land:5,Region:2,Tribe:1,Clan:1,Dependency:1,Area:1}};w.forEach(M=>{if(M.provinces=[],!M.i||M.removed)return;const I=S.filter(D=>D.state===M.i&&!D.removed).sort((D,U)=>U.population*Ce(1,.2,.5,1.5,3)-D.population).sort((D,U)=>U.capital-D.capital);if(I.length<2)return;const H=Math.max(Math.ceil(I.length*v/100),2),G=Object.assign({},P[M.form]);for(let D=0;D<H;D++){const U=h.length;M.provinces.push(U);const F=I[D].cell,j=I[D].i,Z=I[D].culture,te=V(.5),q=te?I[D].name:Names.getState(Names.getCultureShort(Z),Z),X=he(G);G[X]+=10;const ee=q+" "+X,le=tt(M.color),Y=te?.8:.4,W=n(F,j.port),de=COA.generate(I[D].coa,Y,null,W);de.shield=COA.getShield(Z,M.i),h.push({i:U,state:M.i,center:F,burg:j,name:q,formName:X,fullName:ee,color:le,coa:de})}});const T=new PriorityQueue({comparator:(M,I)=>M.p-I.p}),R=[];for(h.forEach(function(M){!M.i||M.removed||(a.province[M.center]=M.i,T.queue({e:M.center,p:0,province:M.i,state:M.state}),R[M.center]=1)});T.length;){const M=T.dequeue(),I=M.e,H=M.p,G=M.province,D=M.state;a.c[I].forEach(function(U){const F=a.h[U]>=20;if(!F&&!a.t[U]||F&&a.state[U]!==D)return;const j=a.h[U]>=70?100:a.h[U]>=50?30:a.h[U]>=20?10:100,Z=H+j;Z>E||(!R[U]||Z<R[U])&&(F&&(a.province[U]=G),R[U]=Z,T.queue({e:U,p:Z,province:G,state:D}))})}for(const M of a.i){if(a.burg[M])continue;const I=a.c[M].filter(F=>a.state[F]===a.state[M]).map(F=>a.province[F]),H=I.filter(F=>F!==a.province[M]);if(H.length<2)continue;const G=I.filter(F=>F===a.province[M]).length;if(G.length>2)continue;const D=H.map(F=>H.reduce((j,Z)=>Z===F?j+1:j,0)),U=d3.max(D);G>=U||(a.province[M]=H[D.indexOf(U)])}const L=Array.from(a.i).filter(M=>a.state[M]&&!a.province[M]);w.forEach(M=>{var U;if(!M.provinces.length)return;const I=M.provinces.map(F=>{var j;return(j=h[F])==null?void 0:j.name}),H=[M.name,...I].filter(F=>F&&!/new/i.test(F)),G=()=>{if(H.length<1)return null;const F=be(H.length-1),j=H.splice(F,1);return j[0]?`New ${j[0]}`:null};let D=L.filter(F=>a.state[F]===M.i&&!a.province[F]);for(;D.length;){let oe=function(ce,ye){if(a.f[ce]!==a.f[ye])return!1;const Se=[ce],ve=new Uint8Array(a.i.length),Ue=a.state[ce];for(;Se.length;){const Ve=Se.pop();if(Ve===ye)return!0;a.c[Ve].forEach(Oe=>{ve[Oe]||a.h[Oe]<20||a.state[Oe]!==Ue||(Se.push(Oe),ve[Oe]=1)})}return!1};const F=h.length,j=D.find(ce=>a.burg[ce]),Z=j||D[0],te=j?a.burg[j]:0;a.province[Z]=F;const q=[];for(q[Z]=1,T.queue({e:Z,p:0});T.length;){const ce=T.dequeue(),ye=ce.e,Se=ce.p;a.c[ye].forEach(function(ve){if(a.province[ve])return;const Ue=a.h[ve]>=20;if(a.state[ve]&&a.state[ve]!==M.i)return;const Ve=Ue?a.state[ve]===M.i?3:20:a.t[ve]?10:30,Oe=Se+Ve;Oe>E||(!q[ve]||Oe<q[ve])&&(Ue&&a.state[ve]===M.i&&(a.province[ve]=F),q[ve]=Oe,T.queue({e:ve,p:Oe}))})}const X=a.culture[Z],ee=pack.features[a.f[Z]],le=tt(M.color),Y=D.filter(ce=>a.province[ce]===F),W=Y.length===ee.cells&&!Y.find(ce=>a.f[ce]!==ee.i),de=!W&&!Y.find(ce=>pack.features[a.f[ce]].group!=="isle"),me=!W&&!de&&V(.5)&&!oe(M.center,Z),pe=function(){const ce=me&&V(.8)&&G();return ce||(j&&V(.5)?S[te].name:Names.getState(Names.getCultureShort(X),X))}(),we=function(){return W?"Island":de?"Islands":me?"Colony":he(P.Wild)}(),ke=pe+" "+we,He=V(me?.95:W||de?.7:.3),Be=He?0:.4,Fe=n(Z,(U=S[te])==null?void 0:U.port),_=COA.generate(M.coa,Be,He,Fe);_.shield=COA.getShield(X,M.i),h.push({i:F,state:M.i,center:Z,burg:te,name:pe,formName:we,fullName:ke,color:le,coa:_}),M.provinces.push(F),D=L.filter(ce=>a.state[ce]===M.i&&!a.province[ce])}}),Q&&console.timeEnd("generateProvinces")},updateCultures:z}}();window.Routes=function(){const e=function(){Q&&console.time("generateMainRoads");const m=pack.cells,A=pack.burgs.filter(C=>C.i&&!C.removed).filter(C=>C.capital).sort((C,g)=>C.population-g.population);if(A.length<2)return[];const u=[];for(const C of A){const g=A.filter(p=>p.feature===C.feature&&p!==C);for(const p of g){const[B,k]=c(C.cell,p.cell,!0);f(C.cell,k,"main",B).forEach(s=>u.push(s))}}return m.i.forEach(C=>m.s[C]+=m.road[C]/2),Q&&console.timeEnd("generateMainRoads"),u},t=function(){Q&&console.time("generateTrails");const m=pack.cells,b=pack.burgs.filter(u=>u.i&&!u.removed);if(b.length<2)return[];let A=[];for(const u of pack.features.filter(C=>C.land)){const C=b.filter(g=>g.feature===u.i);C.length<2||C.forEach(function(g,p){let B=[];if(p){if(m.road[g.cell])return;const[k,d]=c(g.cell,null,!0);if(d===null)return;B=f(g.cell,d,"small",k)}else{const k=d3.scan(C,(l,a)=>(a.y-g.y)**2+(a.x-g.x)**2-((l.y-g.y)**2+(l.x-g.x)**2)),d=C[k].cell;if(m.road[d])return;const[s,o]=c(g.cell,d,!0);B=f(g.cell,o,"small",s)}B&&(A=A.concat(B))})}return Q&&console.timeEnd("generateTrails"),A},n=function(){Q&&console.time("generateSearoutes");const{cells:m,burgs:b,features:A}=pack,u=b.filter(k=>k.port>0&&!k.removed);if(!u.length)return[];const C=new Set(u.map(k=>k.port));let g=[];const p=[];C.forEach(k=>{var s;const d=u.filter(o=>o.port===k);if(!!d.length){(s=A[k])!=null&&s.border&&B(k,d[0]);for(let o=0;o<d.length;o++){const l=d[o].cell;if(!p[l])for(let a=o+1;a<d.length;a++){const w=d[a].cell;if(p[w])continue;const[S,h,v]=z(w,l,!0);if(!v)continue;const E=f(w,h,"ocean",S);g=g.concat(E),p[l]=1,p[w]=1}}}});function B(k,d){const{x:s,y:o,cell:l}=d,a=v=>Math.abs(v[0]-s)+Math.abs(v[1]-o),[w,S]=[[0,o],[s,0],[graphWidth,o],[s,graphHeight]].sort((v,E)=>a(v)-a(E))[0],h=Te(w,S);if(m.f[h]===k&&m.h[h]<20){const[v,E,P]=z(h,l,!0);if(P){const T=f(h,E,"ocean",v);g=g.concat(T),De(T).push([w,S])}}}return Q&&console.timeEnd("generateSearoutes"),g},i=function(m,b,A){Q&&console.time("drawRoutes");const{cells:u,burgs:C}=pack,{burg:g,p}=u,B=o=>[C[o].x,C[o].y],k=o=>o.map(l=>Array.isArray(l)?l:g[l]?B(g[l]):p[l]),d=o=>it(lineGen(k(o)),1),s=(o,l)=>o.map((a,w)=>`<path id="${l}${w}" d="${d(a)}" />`).join("");lineGen.curve(d3.curveCatmullRom.alpha(.1)),roads.html(s(m,"road")),trails.html(s(b,"trail")),lineGen.curve(d3.curveBundle.beta(1)),searoutes.html(s(A,"searoute")),Q&&console.timeEnd("drawRoutes")};return{getRoads:e,getTrails:t,getSearoutes:n,draw:i,regenerate:function(){routes.selectAll("path").remove(),pack.cells.road=new Uint16Array(pack.cells.i.length),pack.cells.crossroad=new Uint16Array(pack.cells.i.length);const m=e(),b=t(),A=n();i(m,b,A)}};function c(m,b=null,A=null){const u=pack.cells,C=new PriorityQueue({comparator:(B,k)=>B.p-k.p}),g=[],p=[];for(C.queue({e:m,p:0});C.length;){const B=C.dequeue(),k=B.e,d=B.p;if(A&&u.road[k])return[p,k];for(const s of u.c[k]){if(u.h[s]<20)continue;const o=u.state&&u.state[s]!==u.state[k]?400:0,l=biomesData.habitability[u.biome[s]];if(!l)continue;const a=l?Math.max(100-l,0):400,w=Math.abs(u.h[s]-u.h[k])*10,S=u.h[s]>80?u.h[s]:0,h=10+o+a+w+S,v=d+(u.road[s]||u.burg[s]?h/3:h);if(!(p[s]||v>=g[s])){if(p[s]=k,s===b)return[p,b];g[s]=v,C.queue({e:s,p:v})}}}return[p,b]}function f(m,b,A,u){const C=pack.cells,g=[];let p=[],B=b,k=b;const d=A==="main"?5:1;(A==="ocean"||!C.road[k])&&p.push(b),C.road[k]||(C.road[k]=d);for(let s=0,o=1e3;s<o&&!(!u[B]||(B=u[B],C.road[B]?(p.length&&(p.push(B),g.push(p),p[0]!==b&&(C.road[p[0]]+=d,C.crossroad[p[0]]+=d),B!==m&&(C.road[B]+=d,C.crossroad[B]+=d)),p=[],k=B):(k&&p.push(k),k=null,p.push(B)),C.road[B]+=d,B===m));s++);return p.length>1&&g.push(p),g}function z(m,b=null,A=null){const u=pack.cells,C=grid.cells.temp,g=new PriorityQueue({comparator:(k,d)=>k.p-d.p}),p=[],B=[];for(g.queue({e:m,p:0});g.length;){const k=g.dequeue(),d=k.e,s=k.p;if(A&&d!==m&&u.road[d])return[B,d,!0];for(const o of u.c[d]){if(o===b)return B[o]=d,[B,b,!0];if(u.h[o]>=20||C[u.g[o]]<=-5)continue;const l=(u.p[o][1]-u.p[d][1])**2+(u.p[o][0]-u.p[d][0])**2,a=s+(u.road[o]?1+l/2:l+(u.t[o]?1:100));B[o]||a>=p[o]||(B[o]=d,p[o]=a,g.queue({e:o,p:a}))}}return[B,b,!1]}}();window.Religions=function(){const e={Number:1,Being:3,Adjective:5,"Color + Animal":5,"Adjective + Animal":5,"Adjective + Being":5,"Adjective + Genitive":1,"Color + Being":3,"Color + Genitive":3,"Being + of + Genitive":2,"Being + of the + Genitive":1,"Animal + of + Genitive":1,"Adjective + Being + of + Genitive":2,"Adjective + Animal + of + Genitive":2},t=[];for(const k in e)for(let d=0;d<e[k];d++)t.push(k);const n={number:["One","Two","Three","Four","Five","Six","Seven","Eight","Nine","Ten","Eleven","Twelve"],being:["Ancestor","Ancient","Brother","Chief","Council","Creator","Deity","Elder","Father","Forebear","Forefather","Giver","God","Goddess","Guardian","Lady","Lord","Maker","Master","Mother","Numen","Overlord","Reaper","Ruler","Sister","Spirit","Virgin"],animal:["Antelope","Ape","Badger","Basilisk","Bear","Beaver","Bison","Boar","Buffalo","Camel","Cat","Centaur","Chimera","Cobra","Crane","Crocodile","Crow","Cyclope","Deer","Dog","Dragon","Eagle","Elk","Falcon","Fox","Goat","Goose","Hare","Hawk","Heron","Horse","Hound","Hyena","Ibis","Jackal","Jaguar","Kraken","Lark","Leopard","Lion","Mantis","Marten","Moose","Mule","Narwhal","Owl","Ox","Panther","Pegasus","Phoenix","Rat","Raven","Rook","Scorpion","Serpent","Shark","Sheep","Snake","Sphinx","Spider","Swan","Tiger","Turtle","Unicorn","Viper","Vulture","Walrus","Wolf","Wolverine","Worm","Wyvern"],adjective:["Aggressive","Almighty","Ancient","Beautiful","Benevolent","Big","Blind","Blond","Bloody","Brave","Broken","Brutal","Burning","Calm","Cheerful","Crazy","Cruel","Dead","Deadly","Devastating","Distant","Disturbing","Divine","Dying","Eternal","Evil","Explicit","Fair","Far","Fat","Fatal","Favorable","Flying","Friendly","Frozen","Giant","Good","Grateful","Great","Happy","High","Holy","Honest","Huge","Hungry","Immutable","Infallible","Inherent","Last","Latter","Lost","Loud","Lucky","Mad","Magical","Main","Major","Marine","Naval","New","Old","Patient","Peaceful","Pregnant","Prime","Proud","Pure","Sacred","Sad","Scary","Secret","Selected","Severe","Silent","Sleeping","Slumbering","Strong","Sunny","Superior","Sustainable","Troubled","Unhappy","Unknown","Waking","Wild","Wise","Worried","Young"],genitive:["Cold","Day","Death","Doom","Fate","Fire","Fog","Frost","Gates","Heaven","Home","Ice","Justice","Life","Light","Lightning","Love","Nature","Night","Pain","Snow","Springs","Summer","Thunder","Time","Victory","War","Winter"],theGenitive:["Abyss","Blood","Dawn","Earth","East","Eclipse","Fall","Harvest","Moon","North","Peak","Rainbow","Sea","Sky","South","Stars","Storm","Sun","Tree","Underworld","West","Wild","Word","World"],color:["Amber","Black","Blue","Bright","Brown","Dark","Golden","Green","Grey","Light","Orange","Pink","Purple","Red","White","Yellow"]},i={Folk:{Shamanism:2,Animism:2,"Ancestor worship":1,Polytheism:2},Organized:{Polytheism:5,Dualism:1,Monotheism:4,"Non-theism":1},Cult:{Cult:1,"Dark Cult":1},Heresy:{Heresy:1}},r={"Random + type":3,"Random + ism":1,"Supreme + ism":5,"Faith of + Supreme":5,"Place + ism":1,"Culture + ism":2,"Place + ian + type":6,"Culture + type":4},c={Shamanism:{Beliefs:3,Shamanism:2,Spirits:1},Animism:{Spirits:1,Beliefs:1},"Ancestor worship":{Beliefs:1,Forefathers:2,Ancestors:2},Polytheism:{Deities:3,Faith:1,Gods:1,Pantheon:1},Dualism:{Religion:3,Faith:1,Cult:1},Monotheism:{Religion:1,Church:1},"Non-theism":{Beliefs:3,Spirits:1},Cult:{Cult:4,Sect:4,Arcanum:1,Coterie:1,Order:1,Worship:1},"Dark Cult":{Cult:2,Sect:2,Blasphemy:1,Circle:1,Coven:1,Idols:1,Occultism:1},Heresy:{Heresy:3,Sect:2,Apostates:1,Brotherhood:1,Circle:1,Dissent:1,Dissenters:1,Iconoclasm:1,Schism:1,Society:1}},f=function(){var P,T;Q&&console.time("generateReligions");const k=pack.cells,d=pack.states,s=pack.cultures,o=pack.religions=[];if(k.religion=new Uint16Array(k.culture),pack.cultures.forEach(R=>{if(!R.i)return o.push({i:0,name:"No religion"});if(R.removed){o.push({i:R.i,name:"Extinct religion for "+R.name,color:tt(R.color,.1,0),removed:!0});return}const L=he(i.Folk),M=R.name+" "+he(c[L]),I=L==="Animism"?null:C(R.i),H=tt(R.color,.1,0);o.push({i:R.i,name:M,color:H,culture:R.i,type:"Folk",form:L,deity:I,center:R.center,origins:[0]})}),religionsInput.value==0||pack.cultures.length<2)return o.filter(R=>R.i).forEach(R=>R.code=bt(R.name));const l=pack.burgs.filter(R=>R.i&&!R.removed),a=l.length>+religionsInput.value?l.sort((R,L)=>L.population-R.population).map(R=>R.cell):k.i.filter(R=>k.s[R]>2).sort((R,L)=>k.s[L]-k.s[R]),w=d3.quadtree(),S=(graphWidth+graphHeight)/6/religionsInput.value,h=Math.floor(be(10,40)/100*religionsInput.value),v=+religionsInput.value-h+o.length;function E({x:R,y:L,r:M,max:I}){if(I===0)return[0];const H=wn(R,L,M),G=hn(H.map(D=>k.religion[D]).filter(D=>D));return G.length?G.slice(0,I):[0]}for(let R=0;o.length<v&&R<1e3;R++){let L=a[Ot(0,a.length-1,5)];const M=he(i.Organized),I=k.state[L],H=k.culture[L],G=M==="Non-theism"?null:C(H);let[D,U]=p(M,G,L);U==="state"&&!I&&(U="global"),U==="culture"&&!H&&(U="global"),U==="state"&&Math.random()>.5&&(L=d[I].center),U==="culture"&&Math.random()>.5&&(L=s[H].center),!k.burg[L]&&k.c[L].some(W=>k.burg[W])&&(L=k.c[L].find(W=>k.burg[W]));const[F,j]=k.p[L],Z=S*gauss(1,.3,.2,2,2);if(w.find(F,j,Z)!==void 0)continue;const q=(U==="culture"||V(.5))&&o.find(W=>W.culture===H&&W.type==="Folk");q&&U==="culture"&&q.name.slice(0,3)!=="Old"&&(q.name="Old "+q.name);const X=q?[q.i]:E({x:F,y:j,r:150/v,max:2}),ee=be(3,8),le=((P=o[H])==null?void 0:P.color)||((T=d[I])==null?void 0:T.color)||Ct(),Y=tt(le,.3,0);o.push({i:o.length,name:D,color:Y,culture:H,type:"Organized",form:M,deity:G,expansion:U,expansionism:ee,center:L,origins:X}),w.add([F,j])}for(let R=0;o.length<v+h&&R<1e3;R++){const L=he(i.Cult);let M=a[Ot(0,a.length-1,1)];!k.burg[M]&&k.c[M].some(q=>k.burg[q])&&(M=k.c[M].find(q=>k.burg[q]));const[I,H]=k.p[M],G=S*gauss(2,.3,1,3,2);if(w.find(I,H,G)!==void 0)continue;const D=k.culture[M],U=E({x:I,y:H,r:300/v,max:be(0,4)}),F=C(D),j=B(L,M),Z=gauss(1.1,.5,0,5),te=tt(s[D].color,.5,0);o.push({i:o.length,name:j,color:te,culture:D,type:"Cult",form:L,deity:F,expansion:"global",expansionism:Z,center:M,origins:U}),w.add([I,H])}m(),o.filter(R=>R.type==="Organized").forEach(R=>{if(R.expansionism<3)return;const L=gauss(0,1,0,3);for(let M=0;M<L;M++){let I=ie(k.i.filter(Z=>k.religion[Z]===R.i&&k.c[Z].some(te=>k.religion[te]!==R.i)));if(!I)continue;!k.burg[I]&&k.c[I].some(Z=>k.burg[Z])&&(I=k.c[I].find(Z=>k.burg[Z]));const[H,G]=k.p[I];if(w.find(H,G,S/10)!==void 0)continue;const D=k.culture[I],U=B("Heresy",I),F=gauss(1.2,.5,0,5),j=tt(R.color,.4,.2);o.push({i:o.length,name:U,color:j,culture:D,type:"Heresy",form:R.form,deity:R.deity,expansion:"global",expansionism:F,center:I,origins:[R.i]}),w.add([H,G])}}),b(),A(),Q&&console.timeEnd("generateReligions")},z=function(k){const{cells:d,religions:s}=pack,o=d.religion[k],l=d.culture[k],a=tt(s[o].color,.3,0),w=s[o].type==="Organized"?he({Organized:4,Cult:1,Heresy:2}):he({Organized:5,Cult:2}),S=he(i[w]),h=w==="Heresy"?s[o].deity:S==="Non-theism"?null:C(l);let v,E;w==="Organized"?[v,E]=p(S,h,k):(v=B(S,k),E="global");const P=w==="Heresy"?s[o].form:S,T=bt(v,s.map(L=>L.code)),R=s.length;s.push({i:R,name:v,color:a,culture:l,type:w,form:P,deity:h,expansion:E,expansionism:0,center:k,cells:0,area:0,rural:0,urban:0,origins:[o],code:T}),d.religion[k]=R},m=function(){const k=pack.cells,d=pack.religions,s=new PriorityQueue({comparator:(w,S)=>w.p-S.p}),o=[];d.filter(w=>w.type==="Organized"||w.type==="Cult").forEach(w=>{k.religion[w.center]=w.i,s.queue({e:w.center,p:0,r:w.i,s:k.state[w.center],c:w.culture}),o[w.center]=1});const l=k.i.length/5e3*200*gauss(1,.3,.2,2,2)*neutralInput.value,a=d3.max(k.pop)/3;for(;s.length;){const w=s.dequeue(),S=w.e,h=w.p,v=w.r,E=w.c,P=w.s,T=d[v].expansion;k.c[S].forEach(function(R){if(T==="culture"&&E!==k.culture[R]||T==="state"&&P!==k.state[R])return;const L=E!==k.culture[R]?10:0,M=P!==k.state[R]?10:0,I=k.road[R]?1:biomesData.cost[k.biome[R]],H=Math.max(O(a-k.pop[R]),0),G=Math.max(k.h[R],20)-20,D=k.h[R]<20?k.road[R]?50:1e3:0,U=h+(L+M+I+H+G+D)/d[v].expansionism;U>l||(!o[R]||U<o[R])&&(k.h[R]>=20&&k.culture[R]&&(k.religion[R]=v),o[R]=U,s.queue({e:R,p:U,r:v,c:E,s:P}))})}},b=function(){const k=pack.cells,d=pack.religions,s=new PriorityQueue({comparator:(a,w)=>a.p-w.p}),o=[];d.filter(a=>a.type==="Heresy").forEach(a=>{const w=k.religion[a.center];k.religion[a.center]=a.i,s.queue({e:a.center,p:0,r:a.i,b:w}),o[a.center]=1});const l=k.i.length/5e3*500*neutralInput.value;for(;s.length;){const a=s.dequeue(),w=a.e,S=a.p,h=a.r,v=a.b;k.c[w].forEach(function(E){const P=k.religion[E]===v?0:2e3,T=k.road[E]?0:biomesData.cost[k.biome[E]],R=Math.max(k.h[E],20)-20,L=k.h[E]<20?k.road[E]?50:1e3:0,M=S+(P+T+R+L)/Math.max(d[h].expansionism,.1);M>l||(!o[E]||M<o[E])&&(k.h[E]>=20&&k.culture[E]&&(k.religion[E]=h),o[E]=M,s.queue({e:E,p:M,r:h}))})}};function A(){const{cells:k,religions:d}=pack,s=d.map(o=>o.code);d.forEach(o=>{if(!o.i||(o.code=bt(o.name,s),k.religion[o.center]===o.i))return;const l=k.i.filter(a=>k.religion[a]===o.i);!l.length||(o.center=l.sort((a,w)=>k.pop[w]-k.pop[a])[0])})}function u(){Q&&console.time("updateCulturesForReligions"),pack.religions=pack.religions.map((k,d)=>d===0?k:{...k,culture:pack.cells.culture[k.center]}),Q&&console.timeEnd("updateCulturesForReligions")}const C=function(k){if(k===void 0){ERROR&&console.error("Please define a culture");return}const d=g();return Names.getCulture(k,null,null,"",.8)+", The "+d};function g(){const k=ie(t);if(k==="Number")return ie(n.number);if(k==="Being")return ie(n.being);if(k==="Adjective")return ie(n.adjective);if(k==="Color + Animal")return ie(n.color)+" "+ie(n.animal);if(k==="Adjective + Animal")return ie(n.adjective)+" "+ie(n.animal);if(k==="Adjective + Being")return ie(n.adjective)+" "+ie(n.being);if(k==="Adjective + Genitive")return ie(n.adjective)+" "+ie(n.genitive);if(k==="Color + Being")return ie(n.color)+" "+ie(n.being);if(k==="Color + Genitive")return ie(n.color)+" "+ie(n.genitive);if(k==="Being + of + Genitive")return ie(n.being)+" of "+ie(n.genitive);if(k==="Being + of the + Genitive")return ie(n.being)+" of the "+ie(n.theGenitive);if(k==="Animal + of + Genitive")return ie(n.animal)+" of "+ie(n.genitive);if(k==="Adjective + Being + of + Genitive")return ie(n.adjective)+" "+ie(n.being)+" of "+ie(n.genitive);if(k==="Adjective + Animal + of + Genitive")return ie(n.adjective)+" "+ie(n.animal)+" of "+ie(n.genitive)}function p(k,d,s){const{cells:o,cultures:l,burgs:a,states:w}=pack,S=()=>Names.getCulture(o.culture[s],null,null,"",0),h=()=>he(c[k]),v=()=>d.split(/[ ,]+/)[0],E=()=>l[o.culture[s]].name,P=R=>{const L=o.burg[s],M=o.state[s],I=L?a[L].name:w[M].name;let H=Ke(I.split(/[ ,]+/)[0]);return R?We(H):H},T=he(r);return T==="Random + type"?[S()+" "+h(),"global"]:T==="Random + ism"?[Ke(S())+"ism","global"]:T==="Supreme + ism"&&d?[Ke(v())+"ism","global"]:T==="Faith of + Supreme"&&d?[ie(["Faith","Way","Path","Word","Witnesses"])+" of "+v(),"global"]:T==="Place + ism"?[P()+"ism","state"]:T==="Culture + ism"?[Ke(E())+"ism","culture"]:T==="Place + ian + type"?[P("adj")+" "+h(),"state"]:T==="Culture + type"?[E()+" "+h(),"culture"]:[Ke(S())+"ism","global"]}function B(k,d){const s=pack.cells,o=function(){return he(c[k])},l=function(){return Ke(Names.getCulture(s.culture[d],null,null,"",0).split(/[ ,]+/)[0])},a=function(){return Ke(pack.burgs[s.burg[d]].name.split(/[ ,]+/)[0])};return s.burg[d]?a()+"ian "+o():Math.random()>.5?l()+"ian "+o():o()+" of the "+g()}return{generate:f,add:z,getDeityName:C,expandReligions:m,updateCultures:u}}();window.Military=function(){const e=function(){Q&&console.time("generateMilitaryForces");const{cells:A,states:u}=pack,{p:C}=A,g=u.filter(v=>v.i&&!v.removed);options.military||(options.military=n());const p=d3.sum(g.map(v=>v.expansionism)),B=d3.sum(g.map(v=>v.area)),k={x:0,Ally:-.2,Friendly:-.1,Neutral:0,Suspicion:.1,Enemy:1,Unknown:0,Rival:.5,Vassal:.5,Suzerain:-.5},d={melee:{Nomadic:.5,Highland:1.2,Lake:1,Naval:.7,Hunting:1.2,River:1.1},ranged:{Nomadic:.9,Highland:1.3,Lake:1,Naval:.8,Hunting:2,River:.8},mounted:{Nomadic:2.3,Highland:.6,Lake:.7,Naval:.3,Hunting:.7,River:.8},machinery:{Nomadic:.8,Highland:1.4,Lake:1.1,Naval:1.4,Hunting:.4,River:1.1},naval:{Nomadic:.5,Highland:.5,Lake:1.2,Naval:1.8,Hunting:.7,River:1.2},armored:{Nomadic:1,Highland:.5,Lake:1,Naval:1,Hunting:.7,River:1.1},aviation:{Nomadic:.5,Highland:.5,Lake:1.2,Naval:1.2,Hunting:.6,River:1.2},magical:{Nomadic:1,Highland:2,Lake:1,Naval:1,Hunting:1,River:1}},s={nomadic:{melee:.2,ranged:.5,mounted:3,machinery:.4,naval:.3,armored:1.6,aviation:1,magical:.5},wetland:{melee:.8,ranged:2,mounted:.3,machinery:1.2,naval:1,armored:.2,aviation:.5,magical:.5},highland:{melee:1.2,ranged:1.6,mounted:.3,machinery:3,naval:1,armored:.8,aviation:.3,magical:2}},o={nomadic:{melee:.3,ranged:.8,mounted:3,machinery:.4,naval:1,armored:1.6,aviation:1,magical:.5},wetland:{melee:1,ranged:1.6,mounted:.2,machinery:1.2,naval:1,armored:.2,aviation:.5,magical:.5},highland:{melee:1.2,ranged:2,mounted:.3,machinery:3,naval:1,armored:.8,aviation:.3,magical:2}};g.forEach(v=>{v.temp={};const E=v.diplomacy,P=Ie(v.expansionism/p/(v.area/B),.25,4),T=E.some(M=>M==="Enemy")?1:E.some(M=>M==="Rival")?.8:E.some(M=>M==="Suspicion")?.5:.1,R=v.neighbors.map(M=>M?pack.states[M].diplomacy[v.i]:"Suspicion").reduce((M,I)=>M+=k[I],.5),L=Ie(R,.3,3);v.alert=Ie(O(P*T*L,2),.1,5),v.temp.platoons=[];for(const M of options.military){if(!d[M.type])continue;let I=d[M.type][v.type]||1;M.type==="mounted"&&v.formName.includes("Horde")?I*=2:M.type==="naval"&&v.form==="Republic"&&(I*=1.2),v.temp[M.name]=I*v.alert}});const l=v=>[1,2,3,4].includes(A.biome[v])?"nomadic":[7,8,9,12].includes(A.biome[v])?"wetland":A.h[v]>=70?"highland":"generic";function a(v,E,P,T,R){return!(v.biomes&&!v.biomes.includes(E)||v.states&&!v.states.includes(P)||v.cultures&&!v.cultures.includes(T)||v.religions&&!v.religions.includes(R))}for(const v of A.i){if(!A.pop[v])continue;const E=A.biome[v],P=A.state[v],T=A.culture[v],R=A.religion[v],L=u[P];if(!P||L.removed)continue;let M=A.pop[v]/100;T!==L.culture&&(M=L.form==="Union"?M/1.2:M/2),R!==A.religion[L.center]&&(M=L.form==="Theocracy"?M/2.2:M/1.4),A.f[v]!==A.f[L.center]&&(M=L.type==="Naval"?M/1.2:M/1.8);const I=l(v);for(const H of options.military){const G=+H.rural;if(isNaN(G)||G<=0||!L.temp[H.name]||!a(H,E,P,T,R)||H.type==="naval"&&!A.haven[v])continue;const D=I==="generic"?1:s[I][H.type],U=M*G*D,F=O(U*L.temp[H.name]*populationRate);if(!F)continue;let[j,Z]=C[v],te=0;if(H.type==="naval"){const q=A.haven[v];[j,Z]=C[q],te=1}L.temp.platoons.push({cell:v,a:F,t:F,x:j,y:Z,u:H.name,n:te,s:H.separate,type:H.type})}}for(const v of pack.burgs){if(!v.i||v.removed||!v.state||!v.population)continue;const E=A.biome[v.cell],P=v.state,T=v.culture,R=A.religion[v.cell],L=u[P];let M=v.population*urbanization/100;v.capital&&(M*=1.2),T!==L.culture&&(M=L.form==="Union"?M/1.2:M/2),R!==A.religion[L.center]&&(M=L.form==="Theocracy"?M/2.2:M/1.4),A.f[v.cell]!==A.f[L.center]&&(M=L.type==="Naval"?M/1.2:M/1.8);const I=l(v.cell);for(const H of options.military){const G=+H.urban;if(isNaN(G)||G<=0||!L.temp[H.name]||!a(H,E,P,T,R)||H.type==="naval"&&(!v.port||!A.haven[v.cell]))continue;const D=I==="generic"?1:o[I][H.type],U=M*G*D,F=O(U*L.temp[H.name]*populationRate);if(!F)continue;let[j,Z]=C[v.cell],te=0;if(H.type==="naval"){const q=A.haven[v.cell];[j,Z]=C[q],te=1}L.temp.platoons.push({cell:v.cell,a:F,t:F,x:j,y:Z,u:H.name,n:te,s:H.separate,type:H.type})}}const w=3*populationRate,S=(v,E)=>!v.s&&!E.s||v.u===E.u;g.forEach(v=>{v.military=h(v.temp.platoons,v),delete v.temp}),t();function h(v,E){if(!v.length)return[];v.sort((L,M)=>L.a-M.a);const P=d3.quadtree(v,L=>L.x,L=>L.y);v.forEach(L=>{P.remove(L);const M=P.find(L.x,L.y,20);if(M&&M.t&&S(L,M)){T(L,M);return}if(L.t>w)return;const I=(w-L.t)/(L.s?40:20),H=P.findAll(L.x,L.y,I);for(const G of H)if(G.t<w&&S(L,G)){T(L,G);break}});function T(L,M){M.childen?M.childen.push(L):M.childen=[L],L.childen&&L.childen.forEach(I=>M.childen.push(I)),M.t+=L.t,L.t=0}const R=v.filter(L=>L.t).sort((L,M)=>M.t-L.t).map((L,M)=>{const I={};return I[L.u]=L.a,(L.childen||[]).forEach(H=>I[H.u]=I[H.u]?I[H.u]+=H.a:H.a),{i:M,a:L.t,cell:L.cell,x:L.x,y:L.y,bx:L.x,by:L.y,u:I,n:L.n,name,state:E.i}});return R.forEach(L=>{L.name=z(L,R),L.icon=m(L),b(L,E)}),R}Q&&console.timeEnd("generateMilitaryForces")};function t(){const A=pack.states.filter(u=>u.i&&!u.removed);armies.selectAll("g > g").each(function(){const u=notes.findIndex(C=>C.id===this.id);u!=-1&&notes.splice(u,1)}),armies.selectAll("g").remove(),A.forEach(u=>i(u.military,u.i))}const n=function(){return[{icon:"\u2694\uFE0F",name:"infantry",rural:.25,urban:.2,crew:1,power:1,type:"melee",separate:0},{icon:"\u{1F3F9}",name:"archers",rural:.12,urban:.2,crew:1,power:1,type:"ranged",separate:0},{icon:"\u{1F434}",name:"cavalry",rural:.12,urban:.03,crew:2,power:2,type:"mounted",separate:0},{icon:"\u{1F4A3}",name:"artillery",rural:0,urban:.03,crew:8,power:12,type:"machinery",separate:0},{icon:"\u{1F30A}",name:"fleet",rural:0,urban:.015,crew:100,power:50,type:"naval",separate:1}]},i=function(A,u){const C=+armies.attr("box-size"),g=a=>a.n?C*4:C*6,p=C*2,B=a=>O(a.x-g(a)/2,2),k=a=>O(a.y-C,2),d=pack.states[u].color[0]==="#"?pack.states[u].color:"#999",s=d3.color(d).darker().hex(),l=armies.append("g").attr("id","army"+u).attr("fill",d).selectAll("g").data(A).enter().append("g").attr("id",a=>"regiment"+u+"-"+a.i).attr("data-name",a=>a.name).attr("data-state",u).attr("data-id",a=>a.i);l.append("rect").attr("x",a=>B(a)).attr("y",a=>k(a)).attr("width",a=>g(a)).attr("height",p),l.append("text").attr("x",a=>a.x).attr("y",a=>a.y).text(a=>f(a)),l.append("rect").attr("fill",s).attr("x",a=>B(a)-p).attr("y",a=>k(a)).attr("width",p).attr("height",p),l.append("text").attr("class","regimentIcon").attr("x",a=>B(a)-C).attr("y",a=>a.y).text(a=>a.icon)},r=function(A,u){const C=+armies.attr("box-size"),g=A.n?C*4:C*6,p=C*2,B=O(A.x-g/2,2),k=O(A.y-C,2);let d=armies.select("g#army"+u);if(!d.size()){const l=pack.states[u].color[0]==="#"?pack.states[u].color:"#999";d=armies.append("g").attr("id","army"+u).attr("fill",l)}const s=d3.color(d.attr("fill")).darker().hex(),o=d.append("g").attr("id","regiment"+u+"-"+A.i).attr("data-name",A.name).attr("data-state",u).attr("data-id",A.i);o.append("rect").attr("x",B).attr("y",k).attr("width",g).attr("height",p),o.append("text").attr("x",A.x).attr("y",A.y).text(f(A)),o.append("rect").attr("fill",s).attr("x",B-p).attr("y",k).attr("width",p).attr("height",p),o.append("text").attr("class","regimentIcon").attr("x",B-C).attr("y",A.y).text(A.icon)},c=function(A,u,C){const g=armies.select("g#army"+A.state).select("g#regiment"+A.state+"-"+A.i);if(!g.size())return;const p=Math.hypot(A.x-u,A.y-C)*8;A.x=u,A.y=C;const B=+armies.attr("box-size"),k=A.n?B*4:B*6,d=B*2,s=a=>O(a-k/2,2),o=a=>O(a-B,2),l=d3.transition().duration(p).ease(d3.easeSinInOut);g.select("rect").transition(l).attr("x",s(u)).attr("y",o(C)),g.select("text").transition(l).attr("x",u).attr("y",C),g.selectAll("rect:nth-of-type(2)").transition(l).attr("x",s(u)-d).attr("y",o(C)),g.select(".regimentIcon").transition(l).attr("x",s(u)-B).attr("y",C)},f=A=>A.a>(A.n?999:99999)?Qt(A.a):A.a,z=function(A,u){const C=pack.cells,g=A.n?null:C.province[A.cell]&&pack.provinces[C.province[A.cell]]?pack.provinces[C.province[A.cell]].name:C.burg[A.cell]&&pack.burgs[C.burg[A.cell]]?pack.burgs[C.burg[A.cell]].name:null,p=Wn(u.filter(k=>k.n===A.n&&k.i<A.i).length+1),B=A.n?"Fleet":"Regiment";return`${p}${g?` (${g}) `:" "}${B}`},m=function(A){if(!A.n&&!Object.values(A.u).length)return"\u{1F530}";if(!A.n&&pack.states[A.state].form==="Monarchy"&&pack.cells.burg[A.cell]&&pack.burgs[pack.cells.burg[A.cell]].capital)return"\u{1F451}";const u=Object.entries(A.u).sort((g,p)=>p[1]-g[1])[0][0];return options.military.find(g=>g.name===u).icon},b=function(A,u){const C=pack.cells,g=C.burg[A.cell]&&pack.burgs[C.burg[A.cell]]?pack.burgs[C.burg[A.cell]].name:C.province[A.cell]&&pack.provinces[C.province[A.cell]]?pack.provinces[C.province[A.cell]].fullName:null,p=g?`${A.name} is ${A.n?"based":"stationed"} in ${g}. `:"",B=A.a?Object.keys(A.u).map(a=>`\u2014 ${a}: ${A.u[a]}`).join(`\r
`):null,k=B?`\r
\r
Regiment composition in ${options.year} ${options.eraShort}:\r
${B}.`:"",d=u.campaigns?ie(u.campaigns):null,s=d?be(d.start,d.end):Ce(options.year-100,150,1,options.year-6),o=d?` during the ${d.name}`:"",l=`Regiment was formed in ${s} ${options.era}${o}. ${p}${k}`;notes.push({id:`regiment${u.i}-${A.i}`,name:`${A.icon} ${A.name}`,legend:l})};return{generate:e,redraw:t,getDefaultOptions:n,getName:z,generateNote:b,drawRegiments:i,drawRegiment:r,moveRegiment:c,getTotal:f,getEmblem:m}}();window.addEventListener("resize",function(e){stored("mapWidth")&&stored("mapHeight")||(mapWidthInput.value=window.innerWidth,mapHeightInput.value=window.innerHeight,changeMapSize())});location.hostname&&location.hostname!=="localhost"&&location.hostname!=="127.0.0.1"&&(window.onbeforeunload=()=>"Are you sure you want to navigate away?");function sa([e,t]){const n=pack.cells.h[Te(e,t)],i=grid.cells.h[Xe(e,t,grid)],r=n<20?i:n;return _o(r)}function _o(e,t){const n=heightUnit.value;let i=3.281;n==="m"?i=1:n==="f"&&(i=.5468);let r=-990;return e>=20?r=Math.pow(e-18,+heightExponentInput.value):e<20&&e>0&&(r=(e-20)/e*50),t&&(r=Math.abs(r)),O(r*i)+" "+n}Array.from(document.getElementsByClassName("speaker")).forEach(e=>{const t=e.previousElementSibling;e.addEventListener("click",()=>ei(t.value))});function ei(e){const t=new SpeechSynthesisUtterance(e),n=speechSynthesis.getVoices();if(n.length){const i=+document.getElementById("speakerVoice").value;t.voice=n[i]}speechSynthesis.speak(t)}function ft(e,t,n=t){Array.from(e.options).some(r=>r.value===t)||e.options.add(new Option(n,t)),e.value=t}window.Markers=function(){let e=[],t=[];function n(){const K=document.getElementById("culturesSet").value.includes("Fantasy");return[{type:"volcanoes",icon:"\u{1F30B}",dx:52,px:13,min:10,each:500,multiplier:1,list:p,add:B},{type:"hot-springs",icon:"\u2668\uFE0F",dy:52,min:30,each:1200,multiplier:1,list:k,add:d},{type:"mines",icon:"\u26CF\uFE0F",dx:48,px:13,min:1,each:15,multiplier:1,list:s,add:o},{type:"bridges",icon:"\u{1F309}",px:14,min:1,each:5,multiplier:1,list:l,add:a},{type:"inns",icon:"\u{1F37B}",px:14,min:1,each:100,multiplier:1,list:w,add:S},{type:"lighthouses",icon:"\u{1F6A8}",px:14,min:1,each:2,multiplier:1,list:h,add:v},{type:"waterfalls",icon:"\u27F1",dy:54,px:16,min:1,each:5,multiplier:1,list:E,add:P},{type:"battlefields",icon:"\u2694\uFE0F",dy:52,min:50,each:700,multiplier:1,list:T,add:R},{type:"dungeons",icon:"\u{1F5DD}\uFE0F",dy:51,px:13,min:30,each:200,multiplier:1,list:M,add:I},{type:"lake-monsters",icon:"\u{1F409}",dy:48,min:2,each:10,multiplier:1,list:H,add:G},{type:"sea-monsters",icon:"\u{1F991}",min:50,each:700,multiplier:1,list:D,add:U},{type:"hill-monsters",icon:"\u{1F479}",dy:54,px:13,min:30,each:600,multiplier:1,list:F,add:j},{type:"sacred-mountains",icon:"\u{1F5FB}",dy:48,min:1,each:5,multiplier:1,list:Z,add:te},{type:"sacred-forests",icon:"\u{1F333}",min:30,each:1e3,multiplier:1,list:q,add:X},{type:"sacred-pineries",icon:"\u{1F332}",px:13,min:30,each:800,multiplier:1,list:ee,add:le},{type:"sacred-palm-groves",icon:"\u{1F334}",px:13,min:1,each:100,multiplier:1,list:Y,add:W},{type:"brigands",icon:"\u{1F4B0}",px:13,min:50,each:100,multiplier:1,list:de,add:me},{type:"pirates",icon:"\u{1F3F4}\u200D\u2620\uFE0F",dx:51,min:40,each:300,multiplier:1,list:pe,add:we},{type:"statues",icon:"\u{1F5FF}",min:80,each:1200,multiplier:1,list:ke,add:He},{type:"ruins",icon:"\u{1F3FA}",min:80,each:1200,multiplier:1,list:Be,add:Fe},{type:"circuses",icon:"\u{1F3AA}",min:80,each:1e3,multiplier:1,list:_,add:oe},{type:"jousts",icon:"\u{1F93A}",dx:48,min:5,each:500,multiplier:1,list:ce,add:ye},{type:"canoes",icon:"\u{1F6F6}",min:1e3,each:2e3,multiplier:1,list:Se,add:ve},{type:"migration",icon:"\u{1F417}",min:20,each:1e3,multiplier:1,list:Ue,add:Ve},{type:"dances",icon:"\u{1F483}\u{1F3FD}",min:5,each:60,multiplier:1,list:Oe,add:$e},{type:"mirage",icon:"\u{1F4A6}",min:10,each:400,multiplier:1,list:rt,add:nt},{type:"portals",icon:"\u{1F300}",px:14,min:16,each:8,multiplier:+K,list:_e,add:qe},{type:"rifts",icon:"\u{1F386}",min:1,each:3e3,multiplier:+K,list:st,add:ot}]}const i=()=>e,r=N=>{e=N},c=function(){r(n()),pack.markers=[],m()},f=()=>{pack.markers=pack.markers.filter(({i:N,lock:K,cell:J})=>{var ue;if(K)return t[J]=!0,!0;const ae=`marker${N}`;(ue=document.getElementById(ae))==null||ue.remove();const re=notes.findIndex(fe=>fe.id===ae);return re!=-1&&notes.splice(re,1),!1}),m()},z=N=>{var ae;const K=e.find(re=>re.type===N.type);if(K){const{icon:re,type:ue,dx:fe,dy:Me,px:xe}=K;return N=C({icon:re,type:ue,dx:fe,dy:Me,px:xe},N),K.add("marker"+N.i,N.cell),N}const J=((ae=De(pack.markers))==null?void 0:ae.i)+1||0;return pack.markers.push({...N,i:J}),t[N.cell]=!0,{...N,i:J}};function m(){Q&&console.time("addMarkers"),e.forEach(({type:N,icon:K,dx:J,dy:ae,px:re,min:ue,each:fe,multiplier:Me,list:xe,add:Ge})=>{if(Me===0)return;let je=Array.from(xe(pack)),ut=b(je,ue,fe,Me);for(;ut&&je.length;){const[At]=A(je),Pt=C({icon:K,type:N,dx:J,dy:ae,px:re},{cell:At});Ge("marker"+Pt.i,At),ut--}}),t=[],Q&&console.timeEnd("addMarkers")}function b(N,K,J,ae){if(!N.length||N.length<K/ae)return 0;const re=Math.ceil(N.length/J*ae);return N.length<re?N.length:re}function A(N){const K=Math.floor(Math.random()*N.length);return N.splice(K,1)}function u(N){const{cells:K,burgs:J}=pack,ae=K.burg[N];if(ae){const{x:re,y:ue}=J[ae];return[re,ue]}return K.p[N]}function C(N,K){var ue;const J=((ue=De(pack.markers))==null?void 0:ue.i)+1||0,[ae,re]=u(K.cell);return K={...N,x:ae,y:re,...K,i:J},pack.markers.push(K),t[K.cell]=!0,K}function g(N){const K="marker"+N;notes=notes.filter(J=>J.id!==K),pack.markers=pack.markers.filter(J=>J.i!==N)}function p({cells:N}){return N.i.filter(K=>!t[K]&&N.h[K]>=70)}function B(N,K){const{cells:J}=pack,ae=Names.getCulture(J.culture[K]),re=V(.3)?"Mount "+ae:Math.random()>.3?ae+" Volcano":ae;notes.push({id:N,name:re,legend:`Active volcano. Height: ${sa(J.p[K])}`})}function k({cells:N}){return N.i.filter(K=>!t[K]&&N.h[K]>50)}function d(N,K){const{cells:J}=pack,ae=Names.getCulture(J.culture[K]),re=Xt(Ce(35,15,20,100));notes.push({id:N,name:ae+" Hot Springs",legend:`A hot springs area. Average temperature: ${re}`})}function s({cells:N}){return N.i.filter(K=>!t[K]&&N.h[K]>47&&N.burg[K])}function o(N,K){const{cells:J}=pack,re=he({salt:5,gold:2,silver:4,copper:2,iron:3,lead:1,tin:1}),ue=pack.burgs[J.burg[K]],fe=`${ue.name} \u2014 ${re} mining town`,Me=O(ue.population*populationRate*urbanization),xe=`${ue.name} is a mining town of ${Me} people just nearby the ${re} mine`;notes.push({id:N,name:fe,legend:xe})}function l({cells:N,burgs:K}){const J=d3.mean(N.fl.filter(ae=>ae));return N.i.filter(ae=>!t[ae]&&N.burg[ae]&&N.t[ae]!==1&&K[N.burg[ae]].population>20&&N.r[ae]&&N.fl[ae]>J)}function a(N,K){const{cells:J}=pack,ae=pack.burgs[J.burg[K]],re=pack.rivers.find(je=>je.i===pack.cells.r[K]),ue=re?`${re.name} ${re.type}`:"river",fe=re&&V(.2)?`${re.name} Bridge`:`${ae.name} Bridge`,Me={stone:10,wooden:1,lengthy:2,formidable:2,rickety:1,beaten:1,weathered:1},xe=["collapse during the flood","being rumoured to attract trolls","the drying up of local trade","banditry infested the area","the old waypoints crumbled"],Ge=V(.7)?`A ${he(Me)} bridge spans over the ${ue} near ${ae.name}`:`An old crossing of the ${ue}, rarely used since ${ie(xe)}`;notes.push({id:N,name:fe,legend:Ge})}function w({cells:N}){return N.i.filter(K=>!t[K]&&N.h[K]>=20&&N.road[K]>4&&N.pop[K]>10)}function S(N,K){const J=["Dark","Light","Bright","Golden","White","Black","Red","Pink","Purple","Blue","Green","Yellow","Amber","Orange","Brown","Grey"],ae=["Antelope","Ape","Badger","Bear","Beaver","Bison","Boar","Buffalo","Cat","Crane","Crocodile","Crow","Deer","Dog","Eagle","Elk","Fox","Goat","Goose","Hare","Hawk","Heron","Horse","Hyena","Ibis","Jackal","Jaguar","Lark","Leopard","Lion","Mantis","Marten","Moose","Mule","Narwhal","Owl","Panther","Rat","Raven","Rook","Scorpion","Shark","Sheep","Snake","Spider","Swan","Tiger","Turtle","Wolf","Wolverine","Camel","Falcon","Hound","Ox"],re=["New","Good","High","Old","Great","Big","Major","Happy","Main","Huge","Far","Beautiful","Fair","Prime","Ancient","Golden","Proud","Lucky","Fat","Honest","Giant","Distant","Friendly","Loud","Hungry","Magical","Superior","Peaceful","Frozen","Divine","Favorable","Brave","Sunny","Flying"],ue=["Boiled","Grilled","Roasted","Spit-roasted","Stewed","Stuffed","Jugged","Mashed","Baked","Braised","Poached","Marinated","Pickled","Smoked","Dried","Dry-aged","Corned","Fried","Pan-fried","Deep-fried","Dressed","Steamed","Cured","Syrupped","Flame-Broiled"],fe=["beef","pork","bacon","chicken","lamb","chevon","hare","rabbit","hart","deer","antlers","bear","buffalo","badger","beaver","turkey","pheasant","duck","goose","teal","quail","pigeon","seal","carp","bass","pike","catfish","sturgeon","escallop","pie","cake","pottage","pudding","onions","carrot","potato","beet","garlic","cabbage","eggplant","eggs","broccoli","zucchini","pepper","olives","pumpkin","spinach","peas","chickpea","beans","rice","pasta","bread","apples","peaches","pears","melon","oranges","mango","tomatoes","cheese","corn","rat tails","pig ears"],Me=["hot","cold","fire","ice","smoky","misty","shiny","sweet","bitter","salty","sour","sparkling","smelly"],xe=["wine","brandy","gin","whisky","rom","beer","cider","mead","liquor","spirits","vodka","tequila","absinthe","nectar","milk","kvass","kumis","tea","water","juice","sap"],Ge=V(.3)?"inn":"tavern",je=V(.7),ut=ie(ae),At=je?V(.6)?ie(J)+" "+ut:ie(re)+" "+ut:ie(re)+" "+ba(Ge),Pt=je&&V(.3)?ut:ie(fe),an=`${ie(ue)} ${Pt}`.toLowerCase(),nn=`${V(.5)?ie(Me):ie(J)} ${ie(xe)}`.toLowerCase(),on=`A big and famous roadside ${Ge}. Delicious ${an} with ${nn} is served here`;notes.push({id:N,name:"The "+At,legend:on})}function h({cells:N}){return N.i.filter(K=>!t[K]&&N.harbor[K]>6&&N.c[K].some(J=>N.h[J]<20&&N.road[J]))}function v(N,K){const{cells:J}=pack,ae=J.burg[K]?pack.burgs[J.burg[K]].name:Names.getCulture(J.culture[K]);notes.push({id:N,name:We(ae)+" Lighthouse"+name,legend:"A lighthouse to serve as a beacon for ships in the open sea"})}function E({cells:N}){return N.i.filter(K=>N.r[K]&&!t[K]&&N.h[K]>=50&&N.c[K].some(J=>N.h[J]<40&&N.r[J]))}function P(N,K){const{cells:J}=pack,ae=["A gorgeous waterfall flows here","The rapids of an exceptionally beautiful waterfall","An impressive waterfall has cut through the land","The cascades of a stunning waterfall","A river drops down from a great height forming a wonderous waterfall","A breathtaking waterfall cuts through the landscape"],re=J.burg[K]?pack.burgs[J.burg[K]].name:Names.getCulture(J.culture[K]);notes.push({id:N,name:We(re)+" Waterfall"+name,legend:`${ie(ae)}`})}function T({cells:N}){return N.i.filter(K=>!t[K]&&N.state[K]&&N.pop[K]>2&&N.h[K]<50&&N.h[K]>25)}function R(N,K){const{cells:J,states:ae}=pack,re=ae[J.state[K]];re.campaigns||(re.campaigns=BurgsAndStates.generateCampaign(re));const ue=ie(re.campaigns),fe=L(ue.start,ue.end),Me=Names.getCulture(J.culture[K])+" Battlefield",xe=`A historical battle of the ${ue.name}. \r
Date: ${fe} ${options.era}`;notes.push({id:N,name:Me,legend:xe})}function L(N=100,K=1e3){return new Date(be(N,K),be(12),be(31)).toLocaleDateString("en",{year:"numeric",month:"long",day:"numeric"})}function M({cells:N}){return N.i.filter(K=>!t[K]&&N.pop[K]&&N.pop[K]<3)}function I(N,K){const J=`${seed}${K}`,ae="Dungeon",re=`<div>Undiscovered dungeon. See <a href="https://watabou.github.io/one-page-dungeon/?seed=${J}" target="_blank">One page dungeon</a></div><iframe src="https://watabou.github.io/one-page-dungeon/?seed=${J}" sandbox="allow-scripts allow-same-origin"></iframe>`;notes.push({id:N,name:ae,legend:re})}function H({features:N}){return N.filter(K=>K.type==="lake"&&K.group==="freshwater"&&!t[K.firstCell]).map(K=>K.firstCell)}function G(N,K){const J=pack.features[pack.cells.f[K]];if(J.type!=="lake")return;const ae=`${J.name} Monster`,ue=`Rumors say a relic monster of ${Ce(10,5,5,100)} ${heightUnit.value} long inhabits ${J.name} Lake. Truth or lie, folks are afraid to fish in the lake`;notes.push({id:N,name:ae,legend:ue})}function D({cells:N,features:K}){return N.i.filter(J=>!t[J]&&N.h[J]<20&&N.road[J]&&K[N.f[J]].type==="ocean")}function U(N,K){const J=`${Names.getCultureShort(0)} Monster`,re=`Old sailors tell stories of a gigantic sea monster inhabiting these dangerous waters. Rumors say it can be ${Ce(25,10,10,100)} ${heightUnit.value} long`;notes.push({id:N,name:J,legend:re})}function F({cells:N}){return N.i.filter(K=>!t[K]&&N.h[K]>=50&&N.pop[K])}function j(N,K){const{cells:J}=pack,ae=["great","big","huge","prime","golden","proud","lucky","fat","giant","hungry","magical","superior","terrifying","horrifying","feared"],re=["Locals","Elders","Inscriptions","Tipplers","Legends","Whispers","Rumors","Journeying folk","Tales"],ue=["Ogre","Troll","Cyclops","Giant","Monster","Beast","Dragon","Undead","Ghoul","Vampire","Hag","Banshee","Bearded Devil","Roc","Hydra","Warg"],fe=["steals cattle at night","prefers eating children","doesn't mind of human flesh","keeps the region at bay","eats kids whole","abducts young women","terrorizes the region","harasses travelers in the area","snatches people from homes","attacks anyone who dares to approach its lair","attacks unsuspecting victims"],Me=ie(ue),xe=Names.getCulture(J.culture[K]),Ge=`${xe} ${Me}`,je=`${ie(re)} speak of a ${ie(ae)} ${Me} who inhabits ${xe} hills and ${ie(fe)}`;notes.push({id:N,name:Ge,legend:je})}function Z({cells:N}){return N.i.filter(K=>!t[K]&&N.h[K]>=70&&N.c[K].some(J=>N.culture[J])&&N.c[K].every(J=>N.h[J]<60))}function te(N,K){const{cells:J,cultures:ae}=pack,re=J.c[K].map(xe=>J.culture[xe]).find(xe=>xe),ue=`${Names.getCulture(re)} Mountain`,fe=sa(J.p[K]),Me=`A sacred mountain of ${ae[re].name} culture. Height: ${fe}`;notes.push({id:N,name:ue,legend:Me})}function q({cells:N}){return N.i.filter(K=>!t[K]&&N.culture[K]&&[6,8].includes(N.biome[K]))}function X(N,K){const{cells:J,cultures:ae}=pack,re=J.culture[K],ue=`${Names.getCulture(re)} Forest`,fe=`A sacred forest of ${ae[re].name} culture`;notes.push({id:N,name:ue,legend:fe})}function ee({cells:N}){return N.i.filter(K=>!t[K]&&N.culture[K]&&N.biome[K]===9)}function le(N,K){const{cells:J,cultures:ae}=pack,re=J.culture[K],ue=`${Names.getCulture(re)} Pinery`,fe=`A sacred pinery of ${ae[re].name} culture`;notes.push({id:N,name:ue,legend:fe})}function Y({cells:N}){return N.i.filter(K=>!t[K]&&N.culture[K]&&N.biome[K]===1&&N.pop[K]>1&&N.road[K])}function W(N,K){const{cells:J,cultures:ae}=pack,re=J.culture[K],ue=`${Names.getCulture(re)} Palm Grove`,fe=`A sacred palm grove of ${ae[re].name} culture`;notes.push({id:N,name:ue,legend:fe})}function de({cells:N}){return N.i.filter(K=>!t[K]&&N.culture[K]&&N.road[K]>4)}function me(N,K){const{cells:J}=pack,ae=["Apes","Badgers","Bears","Beavers","Bisons","Boars","Cats","Crows","Dogs","Foxes","Hares","Hawks","Hyenas","Jackals","Jaguars","Leopards","Lions","Owls","Panthers","Rats","Ravens","Rooks","Scorpions","Sharks","Snakes","Spiders","Tigers","Wolfs","Wolverines","Falcons"],re={brigands:4,bandits:3,robbers:1,highwaymen:1},ue=J.culture[K],fe=J.biome[K],xe=J.p[K]>=70?"highlander":[1,2].includes(fe)?"desert":[3,4].includes(fe)?"mounted":[5,6,7,8,9].includes(fe)?"forest":fe===12?"swamp":"angry",Ge=`${Names.getCulture(ue)} ${ie(ae)}`,je=`A gang of ${xe} ${he(re)}`;notes.push({id:N,name:Ge,legend:je})}function pe({cells:N}){return N.i.filter(K=>!t[K]&&N.h[K]<20&&N.road[K])}function we(N,K){const J="Pirates",ae="Pirate ships have been spotted in these waters";notes.push({id:N,name:J,legend:ae})}function ke({cells:N}){return N.i.filter(K=>!t[K]&&N.h[K]>=20&&N.h[K]<40)}function He(N,K){const{cells:J}=pack,ae=["Statue","Obelisk","Monument","Column","Monolith","Pillar","Megalith","Stele","Runestone","Sculpture","Effigy","Idol"],re={cypriot:"\u{10801}\u{10802}\u{10803}\u{10804}\u{10805}\u{10808}\u{1080A}\u{1080B}\u{1080C}\u{1080D}\u{1080E}\u{1080F}\u{10810}\u{10811}\u{10812}\u{10813}\u{10814}\u{10815}\u{10816}\u{10817}\u{10818}\u{10819}\u{1081A}\u{1081B}\u{1081C}\u{1081D}\u{1081E}\u{1081F}\u{10820}\u{10821}\u{10822}\u{10823}\u{10824}\u{10825}\u{10826}\u{10827}\u{10828}\u{10829}\u{1082A}\u{1082B}\u{1082C}\u{1082D}\u{1082E}\u{1082F}\u{10830}\u{10831}\u{10832}\u{10833}\u{10834}\u{10835}\u{10837}\u{10838}\u{1083C}\u{1083F} ",geez:"\u1200\u1208\u1210\u1218\u1220\u1228\u1230\u1240\u1260\u1270\u1280\u1290\u12A0\u12A8\u12C8\u12D0\u12D8\u12E8\u12F0\u1308\u1320\u1330\u1338\u1340\u1348\u1350 ",coptic:"\u2CB2\u2CB4\u2CB6\u2CB8\u2CBA\u2CBC\u2CBE\u2CC0\u2CC1\u2CC2\u2CC3\u2CC4\u2CC6\u2CC8\u2CCA\u2CCC\u2CCE\u2CD0\u2CD2\u2CD4\u2CD6\u2CD8\u2CDA\u2CDC\u2CDE\u2CE0\u2CE2\u2CE4\u2CE5\u2CE7\u2CE9\u2CEA\u2CEB\u2CEC\u2CED\u2CF2\u2CF9\u2CFE ",tibetan:"\u0F00\u0F01\u0F02\u0F03\u0F04\u0F05\u0F06\u0F07\u0F08\u0F09\u0F0A\u0F0B\u0F0C\u0F10\u0F11\u0F12\u0F13\u0F14\u0F15\u0F16\u0F17\u0F18\u0F19\u0F1A\u0F1B\u0F1C\u0F20\u0F21\u0F22\u0F23\u0F24\u0F25\u0F26\u0F27\u0F28\u0F29\u0F2A\u0F2B\u0F2C\u0F2D\u0F2E\u0F2F\u0F30\u0F31\u0F32\u0F33\u0F34\u0F35\u0F36\u0F37\u0F38\u0F39\u0F3A\u0F3B\u0F3C\u0F3D\u0F3E\u0F3F",mongolian:"\u1800\u1810\u1811\u1812\u1820\u1821\u1826\u1827\u1828\u1829\u182A\u182D\u182E\u182F\u1830\u1831\u1832\u1833\u1835\u183B\u183C\u183D\u183E\u183F\u1840\u1841\u1846\u184D\u184E\u184F\u1850\u1851\u1852\u1853\u1854\u1855\u1856\u1857\u1859\u185C\u185D\u185E\u185F\u1860\u1861\u186D\u186E\u186F\u1870\u1871\u1872\u1873\u1874\u1880\u1881\u1882\u188B\u188F\u1890\u1891\u1892\u1893\u189B\u189C\u189E\u189F\u18A0\u18A1\u18A2\u18A4\u18A5\u18A6"},ue=J.culture[K],fe=ie(ae),Me=`${Names.getCulture(ue)} ${fe}`,xe=re[ie(Object.keys(re))],Ge=Array(be(40,100)).fill(null).map(()=>ie(xe)).join(""),je=`An ancient ${fe.toLowerCase()}. It has an inscription, but no one can translate it:
<div style="font-size: 1.8em; line-break: anywhere;">${Ge}</div>`;notes.push({id:N,name:Me,legend:je})}function Be({cells:N}){return N.i.filter(K=>!t[K]&&N.culture[K]&&N.h[K]>=20&&N.h[K]<60)}function Fe(N,K){const ae=ie(["City","Town","Settlement","Pyramid","Fort","Stronghold","Temple","Sacred site","Mausoleum","Outpost","Fortification","Fortress","Castle"]),re=`Ruined ${ae}`,ue=`Ruins of an ancient ${ae.toLowerCase()}. Untold riches may lie within`;notes.push({id:N,name:re,legend:ue})}function _({cells:N}){return N.i.filter(K=>!t[K]&&N.culture[K]&&N.h[K]>=20&&pack.cells.road[K])}function oe(N,K){const ae=ie(["Fantastical","Wonderous","Incomprehensible","Magical","Extraordinary","Unmissable","World-famous","Breathtaking"]),re=`Travelling ${ae} Circus`,ue=`Roll up, roll up, this ${ae.toLowerCase()} circus is here for a limited time only`;notes.push({id:N,name:re,legend:ue})}function ce({cells:N,burgs:K}){return N.i.filter(J=>!t[J]&&N.burg[J]&&K[N.burg[J]].population>20)}function ye(N,K){const{cells:J,burgs:ae}=pack,re=["Joust","Competition","Melee","Tournament","Contest"],ue=["cunning","might","speed","the greats","acumen","brutality"];if(!J.burg[K])return;const fe=ae[J.burg[K]].name,Me=ie(re),xe=ie(ue),Ge=`${fe} ${Me}`,je=`Warriors from around the land gather for a ${Me.toLowerCase()} of ${xe} in ${fe}, with fame, fortune and favour on offer to the victor`;notes.push({id:N,name:Ge,legend:je})}function Se({cells:N}){return N.i.filter(K=>!t[K]&&N.r[K])}function ve(N,K){const J=pack.rivers.find(fe=>fe.i===pack.cells.r[K]),ae="Minor Jetty",ue=`A small location along the ${J?`${J.name} ${J.type}`:"river"} to launch boats from sits here, along with a weary looking owner, willing to sell passage along the river`;notes.push({id:N,name:ae,legend:ue})}function Ue({cells:N}){return N.i.filter(K=>!t[K]&&N.h[K]>=20&&N.pop[K]<=2)}function Ve(N,K){const ae=ie(["Antelopes","Apes","Badgers","Bears","Beavers","Bisons","Boars","Buffalo","Cats","Cranes","Crocodiles","Crows","Deers","Dogs","Eagles","Elks","Foxs","Goats","Geese","Hares","Hawks","Herons","Horses","Hyenas","Ibises","Jackals","Jaguars","Larks","Leopards","Lions","Mantises","Martens","Mooses","Mules","Owls","Panthers","Rats","Ravens","Rooks","Scorpions","Sharks","Sheeps","Snakes","Spiders","Tigers","Wolfs","Wolverines","Camels","Falcons","Hounds","Oxen"]),re=`${ae} migration`,ue=`A huge group of ${ae.toLowerCase()} is migrating, though whether part of their annual routine, or something more extraordinary`;notes.push({id:N,name:re,legend:ue})}function Oe({cells:N,burgs:K}){return N.i.filter(J=>!t[J]&&N.burg[J]&&K[N.burg[J]].population>15)}function $e(N,K){const{cells:J,burgs:ae}=pack,re=ae[J.burg[K]].name,ue=["gala","dance","performance","ball","soiree","jamboree","exhibition","carnival","festival","jubilee"],fe=["great and the good","nobility","local elders","foreign dignitaries","spiritual leaders","suspected revolutionaries"],Me=ie(ue),xe=`${re} ${Me}`,Ge=`A ${Me} has been organised at ${re} as a chance to gather the ${ie(fe)} of the area together to be merry, make alliances and scheme around the crisis`;notes.push({id:N,name:xe,legend:Ge})}function rt({cells:N}){return N.i.filter(K=>!t[K]&&N.biome[K]===1)}function nt(N,K){const ae=ie(["Entrancing","Diaphanous","Illusory","Distant","Perculiar"]),re=`${ae} mirage`,ue=`This ${ae.toLowerCase()} mirage has been luring travellers out of their way for eons`;notes.push({id:N,name:re,legend:ue})}function _e({burgs:N}){return N.slice(1,Math.ceil(N.length/10)+1).filter(({cell:K})=>!t[K]).map(K=>K.cell)}function qe(N,K){const{cells:J,burgs:ae}=pack;if(!J.burg[K])return;const ue=`${ae[J.burg[K]].name} Portal`,fe="An element of the magic portal system connecting major cities. The portals were installed centuries ago, but still work fine";notes.push({id:N,name:ue,legend:fe})}function st({cells:N}){return N.i.filter(K=>!t[K]&&pack.cells.pop[K]<=3&&biomesData.habitability[pack.cells.biome[K]])}function ot(N,K){const J=["Demonic","Interdimensional","Abyssal","Cosmic","Cataclysmic","Subterranean","Ancient"],ae=["all known nearby beings to flee in terror","cracks in reality itself to form","swarms of foes to spill forth","the life of nearby plants to wither and decay","an emmissary to step through with an all-powerful relic"],re=ie(J),ue=`${re} Rift`,fe=`A rumoured ${re.toLowerCase()} rift in this area is causing ${ie(ae)}.`;notes.push({id:N,name:ue,legend:fe})}return{add:z,generate:c,regenerate:f,getConfig:i,setConfig:r,deleteMarker:g}}();window.COA=function(){const e={field:{metals:3,colours:4,stains:+V(.03),patterns:1},division:{metals:5,colours:8,stains:+V(.03),patterns:1},charge:{metals:2,colours:3,stains:+V(.05),patterns:0},metals:{argent:3,or:2},colours:{gules:5,azure:4,sable:3,purpure:3,vert:2},stains:{murrey:1,sanguine:1,tenn\u00E9:1},patterns:{semy:8,ermine:6,vair:4,counterVair:1,vairInPale:1,vairEnPointe:2,vairAncien:2,potent:2,counterPotent:1,potentInPale:1,potentEnPointe:1,chequy:8,lozengy:5,fusily:2,pally:8,barry:10,gemelles:1,bendy:8,bendySinister:4,palyBendy:2,barryBendy:1,pappellony:2,pappellony2:3,scaly:1,plumetty:1,masoned:6,fretty:3,grillage:1,chainy:1,maily:2,honeycombed:1}},t={types:{conventional:30,crosses:10,animals:2,animalHeads:1,birds:2,aquatic:1,seafaring:1,fantastic:3,plants:1,agriculture:1,arms:3,bodyparts:1,people:1,architecture:1,miscellaneous:3,inescutcheon:3,uploaded:0},single:{conventional:12,crosses:8,plants:2,animals:10,animalHeads:2,birds:4,aquatic:2,seafaring:2,fantastic:7,agriculture:1,arms:6,bodyparts:1,people:2,architecture:1,miscellaneous:10,inescutcheon:5,uploaded:0},semy:{conventional:4,crosses:1},conventional:{lozenge:2,fusil:4,mascle:4,rustre:2,lozengeFaceted:3,lozengePloye:1,roundel:4,roundel2:3,annulet:4,mullet:5,mulletPierced:1,mulletFaceted:1,mullet4:3,mullet6:4,mullet6Pierced:1,mullet6Faceted:1,mullet7:1,mullet8:1,mullet10:1,estoile:1,compassRose:1,billet:5,delf:0,triangle:3,trianglePierced:1,goutte:4,heart:4,pique:2,carreau:1,trefle:2,fleurDeLis:6,sun:3,sunInSplendour:1,crescent:5,fountain:1},inescutcheon:{inescutcheonHeater:1,inescutcheonSpanish:1,inescutcheonFrench:1,inescutcheonHorsehead:1,inescutcheonHorsehead2:1,inescutcheonPolish:1,inescutcheonHessen:1,inescutcheonSwiss:1,inescutcheonBoeotian:1,inescutcheonRoman:1,inescutcheonKite:1,inescutcheonOldFrench:1,inescutcheonRenaissance:1,inescutcheonBaroque:1,inescutcheonTarge:1,inescutcheonTarge2:1,inescutcheonPavise:1,inescutcheonWedged:1,inescutcheonFlag:1,inescutcheonPennon:1,inescutcheonGuidon:1,inescutcheonBanner:1,inescutcheonDovetail:1,inescutcheonGonfalon:1,inescutcheonPennant:1,inescutcheonRound:1,inescutcheonOval:1,inescutcheonVesicaPiscis:1,inescutcheonSquare:1,inescutcheonDiamond:1,inescutcheonNo:1,inescutcheonFantasy1:1,inescutcheonFantasy2:1,inescutcheonFantasy3:1,inescutcheonFantasy4:1,inescutcheonFantasy5:1,inescutcheonNoldor:1,inescutcheonGondor:1,inescutcheonEasterling:1,inescutcheonErebor:1,inescutcheonIronHills:1,inescutcheonUrukHai:1,inescutcheonMoriaOrc:1},crosses:{crossHummetty:15,crossVoided:1,crossPattee:2,crossPatteeAlisee:1,crossFormee:1,crossFormee2:2,crossPotent:2,crossJerusalem:1,crosslet:1,crossClechy:3,crossBottony:1,crossFleury:3,crossPatonce:1,crossPommy:1,crossGamma:1,crossArrowed:1,crossFitchy:1,crossCercelee:1,crossMoline:2,crossFourchy:1,crossAvellane:1,crossErminee:1,crossBiparted:1,crossMaltese:3,crossTemplar:2,crossCeltic:1,crossCeltic2:1,crossTriquetra:1,crossCarolingian:1,crossOccitan:1,crossSaltire:3,crossBurgundy:1,crossLatin:3,crossPatriarchal:1,crossOrthodox:1,crossCalvary:1,crossDouble:1,crossTau:1,crossSantiago:1,crossAnkh:1},animals:{lionRampant:6,lionPassant:2,lionPassantGuardant:1,wolfRampant:1,wolfPassant:1,wolfStatant:1,greyhoundCourant:1,greyhoundSejant:1,mastiffStatant:1,boarRampant:1,horseRampant:2,horseSalient:1,horsePassant:1,bearRampant:2,bearPassant:1,bullPassant:1,goat:1,lamb:1,lambPassantReguardant:1,agnusDei:1,elephant:1,camel:1,porcupine:1,snake:1},animalHeads:{wolfHeadErased:2,bullHeadCaboshed:1,deerHeadCaboshed:1,lionHeadCaboshed:2},fantastic:{dragonPassant:2,dragonRampant:2,wyvern:1,wyvernWithWingsDisplayed:1,griffinPassant:1,griffinRampant:1,eagleTwoHeards:2,unicornRampant:1,pegasus:1,serpent:1,basilisk:1},birds:{eagle:9,raven:2,cock:3,parrot:1,swan:2,swanErased:1,heron:1,owl:1},plants:{tree:1,oak:1,cinquefoil:1,rose:1,apple:1},aquatic:{escallop:5,pike:1,cancer:1,dolphin:1},seafaring:{anchor:6,boat:2,boat2:1,lymphad:2,armillarySphere:1},agriculture:{garb:2,rake:1,plough:2},arms:{sword:4,falchion:1,sabre:1,sabresCrossed:1,sabre2:1,hatchet:3,axe:3,lochaberAxe:1,mallet:1,bowWithArrow:3,bow:1,arrow:1,arrowsSheaf:1,helmet:2,cannon:1},bodyparts:{hand:4,head:1,headWreathed:1,foot:1},people:{cavalier:3,monk:1,angel:2},architecture:{tower:1,castle:1},miscellaneous:{crown:2,crown2:1,orb:1,chalice:1,key:1,buckle:1,bugleHorn:1,bugleHorn2:1,bell:2,pot:1,bucket:1,horseshoe:3,attire:1,stagsAttires:1,ramsHorn:1,cowHorns:2,wing:1,wingSword:1,lute:1,harp:1,wheel:2,crosier:1,fasces:1,log:1,chain:1,anvil:1},Naval:{anchor:3,boat:1,lymphad:2,armillarySphere:1,escallop:1,dolphin:1},Highland:{tower:1,raven:1,wolfHeadErased:1,wolfPassant:1,goat:1,axe:1},River:{tower:1,garb:1,rake:1,boat:1,pike:2,bullHeadCaboshed:1,apple:1,plough:1},Lake:{cancer:2,escallop:1,pike:2,heron:1,boat:1,boat2:2},Nomadic:{pot:1,buckle:1,wheel:2,sabre:2,sabresCrossed:1,bow:2,arrow:1,horseRampant:1,horseSalient:1,crescent:1,camel:3},Hunting:{bugleHorn:2,bugleHorn2:1,stagsAttires:2,attire:2,hatchet:1,bowWithArrow:1,arrowsSheaf:1,deerHeadCaboshed:1,wolfStatant:1,oak:1,greyhoundSejant:1},City:{key:3,bell:2,lute:1,tower:1,castle:1,mallet:1,cannon:1,anvil:1},Capital:{crown:2,orb:1,lute:1,castle:3,tower:1,crown2:2},\u0421athedra:{chalice:1,orb:1,crosier:2,lamb:1,monk:2,angel:3,crossLatin:2,crossPatriarchal:1,crossOrthodox:1,crossCalvary:1,agnusDei:3},natural:{fountain:"azure",garb:"or",raven:"sable"},sinister:["crossGamma","lionRampant","lionPassant","wolfRampant","wolfPassant","wolfStatant","wolfHeadErased","greyhound\u0421ourant","greyhoundSejant","mastiffStatant","boarRampant","horseRampant","horseSalient","horsePassant","bullPassant","bearRampant","bearPassant","goat","lamb","lambPassantReguardant","agnusDei","elephant","eagle","raven","cock","parrot","swan","swanErased","heron","pike","dragonPassant","dragonRampant","wyvern","wyvernWithWingsDisplayed","griffinPassant","griffinRampant","unicornRampant","pegasus","serpent","hatchet","lochaberAxe","hand","wing","wingSword","lute","harp","bow","head","headWreathed","knight","lymphad","log","crosier","dolphin","sabre","monk","owl","axe","camel","fasces","lionPassantGuardant","helmet","foot","plough","sabre2","cannon","porcupine","basilisk","snake","anvil"],reversed:["goutte","mullet","mullet7","crescent","crossTau","cancer","sword","falchion","sabresCrossed","hand","horseshoe","bowWithArrow","arrow","arrowsSheaf","rake","crossTriquetra","crossLatin","crossTau","sabre2"]},n={conventional:{e:20,abcdefgzi:3,beh:3,behdf:2,acegi:1,kn:3,bhdf:1,jeo:1,abc:3,jln:6,jlh:3,kmo:2,jleh:1,def:3,abcpqh:4,ABCDEFGHIJKL:1},complex:{e:40,beh:1,kn:1,jeo:1,abc:2,jln:7,jlh:2,def:1,abcpqh:1},divisions:{perPale:{e:15,pq:5,jo:2,jl:2,ABCDEFGHIJKL:1},perFess:{e:12,kn:4,jkl:2,gizgiz:1,jlh:3,kmo:1,ABCDEFGHIJKL:1},perBend:{e:5,lm:5,bcfdgh:1},perBendSinister:{e:1,jo:1},perCross:{e:4,jlmo:1,j:1,jo:2,jl:1},perChevron:{e:1,jlh:1,dfk:1,dfbh:2,bdefh:1},perChevronReversed:{e:1,mok:2,dfh:2,dfbh:1,bdefh:1},perSaltire:{bhdf:8,e:3,abcdefgzi:1,bh:1,df:1,ABCDEFGHIJKL:1},perPile:{ee:3,be:2,abceh:1,abcabc:1,jleh:1}},ordinariesOn:{pale:{ee:12,beh:10,kn:3,bb:1},fess:{ee:1,def:3},bar:{defdefdef:1},fessCotissed:{ee:1,def:3},fessDoubleCotissed:{ee:1,defdef:3},bend:{ee:2,jo:1,joe:1},bendSinister:{ee:1,lm:1,lem:4},bendlet:{joejoejoe:1},bendletSinister:{lemlemlem:1},bordure:{ABCDEFGHIJKL:1},chief:{abc:5,bbb:1},quarter:{jjj:1},canton:{yyyy:1},cross:{eeee:1,behdfbehdf:3,behbehbeh:2},crossParted:{e:5,ee:1},saltire:{ee:5,jlemo:1},saltireParted:{e:5,ee:1},pall:{ee:1,jleh:5,jlhh:3},pallReversed:{ee:1,bemo:5},pile:{bbb:1},pileInBend:{eeee:1,eeoo:1},pileInBendSinister:{eeee:1,eemm:1}},ordinariesOff:{pale:{yyy:1},fess:{abc:3,abcz:1},bar:{abc:2,abcgzi:1,jlh:5,bgi:2,ach:1},gemelle:{abc:1},bend:{ccg:2,ccc:1},bendSinister:{aai:2,aaa:1},bendlet:{ccg:2,ccc:1},bendletSinister:{aai:2,aaa:1},bordure:{e:4,jleh:2,kenken:1,peqpeq:1},orle:{e:4,jleh:1,kenken:1,peqpeq:1},chief:{emo:2,emoz:1,ez:2},terrace:{e:5,def:1,bdf:3},mount:{e:5,def:1,bdf:3},point:{e:2,def:1,bdf:3,acbdef:1},flaunches:{e:3,kn:1,beh:3},gyron:{bh:1},quarter:{e:1},canton:{e:5,beh:1,def:1,bdefh:1,kn:1},cross:{acgi:1},pall:{BCKFEILGJbdmfo:1},pallReversed:{aczac:1},chevron:{ach:3,hhh:1},chevronReversed:{bbb:1},pile:{acdfgi:1,acac:1},pileInBend:{cg:1},pileInBendSinister:{ai:1},label:{defgzi:2,eh:3,defdefhmo:1,egiegi:1,pqn:5}},inescutcheon:{e:4,jln:1},mascle:{e:15,abcdefgzi:3,beh:3,bdefh:4,acegi:1,kn:3,joe:2,abc:3,jlh:8,jleh:1,df:3,abcpqh:4,pqe:3,eknpq:3},lionRampant:{e:10,def:2,abc:2,bdefh:1,kn:1,jlh:2,abcpqh:1},lionPassant:{e:10,def:1,abc:1,bdefh:1,jlh:1,abcpqh:1},wolfPassant:{e:10,def:1,abc:1,bdefh:1,jlh:1,abcpqh:1},greyhound\u0421ourant:{e:10,def:1,abc:1,bdefh:1,jlh:1,abcpqh:1},griffinRampant:{e:10,def:2,abc:2,bdefh:1,kn:1,jlh:2,abcpqh:1},griffinPassant:{e:10,def:1,abc:1,bdefh:1,jlh:1,abcpqh:1},boarRampant:{e:12,beh:1,kn:1,jln:2},eagle:{e:15,beh:1,kn:1,abc:1,jlh:2,def:2,pq:1},raven:{e:15,beh:1,kn:1,jeo:1,abc:3,jln:3,def:1},wyvern:{e:10,jln:1},garb:{e:1,def:3,abc:2,beh:1,kn:1,jln:3,jleh:1,abcpqh:1,joe:1,lme:1},crown:{e:10,abcdefgzi:1,beh:3,behdf:2,acegi:1,kn:1,pq:2,abc:1,jln:4,jleh:1,def:2,abcpqh:3},hand:{e:10,jln:2,kn:1,jeo:1,abc:2,pqe:1},armillarySphere:{e:1},tree:{e:1},lymphad:{e:1},head:{e:1},headWreathed:{e:1},cavalier:{e:1},angel:{e:1}},i={straight:50,wavy:8,engrailed:4,invecked:3,rayonne:3,embattled:1,raguly:1,urdy:1,dancetty:1,indented:2,dentilly:1,bevilled:1,angled:1,flechy:1,barby:1,enclavy:1,escartely:1,arched:2,archedReversed:1,nowy:1,nowyReversed:1,embattledGhibellin:1,embattledNotched:1,embattledGrady:1,dovetailedIndented:1,dovetailed:1,potenty:1,potentyDexter:1,potentySinister:1,nebuly:2,seaWaves:1,dragonTeeth:1,firTrees:1},r={variants:{perPale:5,perFess:5,perBend:2,perBendSinister:1,perChevron:1,perChevronReversed:1,perCross:5,perPile:1,perSaltire:1,gyronny:1,chevronny:1},perPale:i,perFess:i,perBend:i,perBendSinister:i,perChevron:i,perChevronReversed:i,perCross:{straight:20,wavy:5,engrailed:4,invecked:3,rayonne:1,embattled:1,raguly:1,urdy:1,indented:2,dentilly:1,bevilled:1,angled:1,embattledGhibellin:1,embattledGrady:1,dovetailedIndented:1,dovetailed:1,potenty:1,potentyDexter:1,potentySinister:1,nebuly:1},perPile:i},c={lined:{pale:7,fess:5,bend:3,bendSinister:2,chief:5,bar:2,gemelle:1,fessCotissed:1,fessDoubleCotissed:1,bendlet:2,bendletSinister:1,terrace:3,cross:6,crossParted:1,saltire:2,saltireParted:1},straight:{bordure:8,orle:4,mount:1,point:2,flaunches:1,gore:1,gyron:1,quarter:1,canton:2,pall:3,pallReversed:2,chevron:4,chevronReversed:3,pile:2,pileInBend:2,pileInBendSinister:1,piles:1,pilesInPoint:2,label:1}};return{generate:function(u,C,g,p){(!u||u==="custom")&&(u=null,C=0,g=0);let B=null,k=[];const d=V(C)?u.t1:E("field");d.includes("-")&&(B=d);const s={t1:d};let o=!!V(B?.5:.93);const l=o&&V(.3)||V(.5)?(u==null?void 0:u.ordinaries)&&V(C)?u.ordinaries[0].ordinary:he(c.lined):null,a=!o&&V(.65)||V(.3)?l||he(c.straight):null,w=["chief","terrace","chevron","quarter","flaunches"].includes(a),S=V(w||o&&a?.03:o?.3:a?.7:.995),h=S?(u==null?void 0:u.division)&&V(C-.1)?u.division.division:he(r.variants):null;if(o&&(o=(u==null?void 0:u.charges)&&V(C-.1)?u.charges[0].charge:p&&p!=="Generic"&&V(.2)?he(t[p]):v()),h){const I=E("division",k,V(.98)?s.t1:null);s.division={division:h,t:I},r[h]&&(s.division.line=B||a&&V(.7)?"straight":he(r[h]))}if(a&&(s.ordinaries=[{ordinary:a,t:E("charge",k,s.t1)}],l&&(s.ordinaries[0].line=B||h&&V(.7)?"straight":he(i)),h&&!o&&!B&&V(.5)&&a!=="bordure"&&a!=="orle"&&(V(.8)?s.ordinaries[0].divided="counter":V(.6)?s.ordinaries[0].divided="field":s.ordinaries[0].divided="division")),o){let D=function(U){U.size=(U.size||1)*M(U.p,a,h),U.p=[...new Set(U.p)].join(""),V(.02)&&t.sinister.includes(U.charge)&&(U.sinister=1),V(.02)&&t.reversed.includes(U.charge)&&(U.reversed=1)},I="e",H="gules";const G=s.ordinaries?s.ordinaries[0].t:null;if(n.ordinariesOn[a]&&V(.8)){for(I=he(n.ordinariesOn[a]);t.natural[o]===G;)o=v();H=!B&&V(.3)?s.t1:E("charge",[],G)}else if(n.ordinariesOff[a]&&V(.95)){for(I=he(n.ordinariesOff[a]);t.natural[o]===s.t1;)o=v();H=!B&&V(.3)?G:E("charge",k,s.t1)}else if(n.divisions[h]){for(I=he(n.divisions[h]);t.natural[o]===s.t1;)o=v();H=E("charge",G?k.concat(G):k,s.t1)}else if(n[o]){for(I=he(n[o]);t.natural[o]===s.t1;)o=v();H=E("charge",k,s.t1)}else{for(I=B?"e":t.conventional[o]?he(n.conventional):he(n.complex);t.natural[o]===s.t1;)o=v();H=E("charge",k.concat(G),s.t1)}if(t.natural[o]&&(H=t.natural[o]),s.charges=[{charge:o,t:H,p:I}],I==="ABCDEFGHIKL"&&V(.95)){s.charges[0].charge=he(t.conventional);const U=v(t.single),F=E("charge",k,s.t1);s.charges.push({charge:U,t:F,p:"e"})}else if(V(.8)&&o==="inescutcheon"){const U=v(t.types),F=E("charge",[],H);s.charges.push({charge:U,t:F,p:I,size:.5})}else if(h&&!a){const U=!B&&(!s.line||s.line==="straight");if(V(.3)&&["perPale","perFess"].includes(h)&&s.line==="straight"){if(s.charges[0].divided="field",V(.95)){const F=I==="e"||V(.5)?"e":he(n.divisions[h]),j=v(t.single),Z=E("charge",k,s.division.t);s.charges.push({charge:j,t:Z,p:F,divided:"division"})}}else if(U&&V(.4))s.charges[0].divided="counter";else if(["perPale","perFess","perBend","perBendSinister"].includes(h)&&V(.8)){const[F,j]=h==="perPale"?["p","q"]:h==="perFess"?["k","n"]:h==="perBend"?["l","m"]:["j","o"];s.charges[0].p=F;const Z=v(t.single),te=E("charge",k,s.division.t);s.charges.push({charge:Z,t:te,p:j})}else if(["perCross","perSaltire"].includes(h)&&V(.5)){const[F,j,Z,te]=h==="perCross"?["j","l","m","o"]:["b","d","f","h"];s.charges[0].p=F;const q=v(t.single),X=E("charge",[],s.division.t),ee=v(t.single),le=E("charge",[],s.division.t),Y=v(t.single),W=E("charge",[],s.t1);s.charges.push({charge:q,t:X,p:j},{charge:ee,t:le,p:Z},{charge:Y,t:W,p:te})}else U&&I.length>1&&(s.charges[0].divided="counter")}s.charges.forEach(U=>D(U))}if(V(g)&&u.charges){const I=T(u.t1,s.t1),H=I?E("division",k,s.t1):u.t1,G={ordinary:"canton",t:H};s.charges&&s.charges.forEach((F,j)=>{F.size===1.5&&(F.size=1.4),F.p.includes("a")&&(F.p=F.p.replaceAll("a","")),F.p.includes("j")&&(F.p=F.p.replaceAll("j","")),F.p.includes("y")&&(F.p=F.p.replaceAll("y","")),F.p||s.charges.splice(j,1)});let D=u.charges[0].charge;D==="inescutcheon"&&u.charges[1]&&(D=u.charges[1].charge);let U=I?u.t1:u.charges[0].t;T(H,U)&&(U=E("charge",k,H)),s.charges||(s.charges=[]),s.charges.push({charge:D,t:U,p:"y",size:.5}),s.ordinaries?s.ordinaries.push(G):s.ordinaries=[G]}function v(I){const H=he(I||(a||S?t.types:t.single));return H==="inescutcheon"?"inescutcheon":he(t[H])}function E(I,H=[],G){const D=G?G.includes("-")?G.split("-")[1]:G:null;let U=he(e[I]);G&&U!=="patterns"&&(U=P(D)==="metals"?"colours":"metals"),U==="metals"&&H.includes("or")&&H.includes("argent")&&(U="colours");let F=he(e[U]);for(;F===D||H.includes(F);)F=he(e[U]);return U!=="patterns"&&I!=="charge"&&k.push(F),U==="patterns"&&(B=F,F=R(F,I)),F}function P(I){const H=I.includes("-")?I.split("-")[1]:I;if(Object.keys(e.metals).includes(H))return"metals";if(Object.keys(e.colours).includes(H))return"colours";if(Object.keys(e.stains).includes(H))return"stains"}function T(I,H){return G(I)===G(H);function G(D){return Object.keys(e.metals).includes(D)?"metals":Object.keys(e.colours).includes(D)?"colours":Object.keys(e.stains).includes(D)?"stains":"pattern"}}function R(I,H,G=""){let D=null,U=null;if(V(.1)?G="-small":V(.1)?G="-smaller":V(.01)?G="-big":V(.005)&&(G="-smallest"),V(.5)&&["vair","vairInPale","vairEnPointe"].includes(I)?(D="azure",U="argent"):V(.8)&&I==="ermine"?(D="argent",U="sable"):I==="pappellony"?V(.2)?(D="gules",U="or"):V(.2)?(D="argent",U="sable"):V(.2)&&(D="azure",U="argent"):I==="masoned"?V(.3)?(D="gules",U="argent"):V(.3)?(D="argent",U="sable"):V(.1)&&(D="or",U="sable"):I==="fretty"?U==="sable"||V(.35)?(D="argent",U="gules"):V(.25)?(D="sable",U="or"):V(.15)&&(D="gules",U="argent"):I==="semy"&&(I+="_of_"+v(t.semy)),!D||!U){const F=V(.7);D=he(F?e.metals:e.colours),U=he(F?e.colours:e.metals)}return H==="division"&&(k.includes(D)&&(D=L(D)),k.includes(U)&&(U=L(U))),k.push(D,U),`${I}-${D}-${U}${G}`}function L(I,H){const G=P(I);for(;!H||H===I;)H=he(e[G]);return H}function M(I,H=null,G=null){return I==="e"&&(H==="bordure"||H==="orle")?1.1:I==="e"?1.5:I==="jln"||I==="jlh"?.7:I==="abcpqh"||I==="ez"||I==="be"||["a","b","c","d","f","g","h","i","bh","df"].includes(I)?.5:["j","l","m","o","jlmo"].includes(I)&&G==="perCross"?.6:I.length>10?.18:I.length>7?.3:I.length>4?.4:I.length>2?.5:.7}return s},toString:u=>JSON.stringify(u).replaceAll("#","%23"),copy:u=>JSON.parse(JSON.stringify(u)),getShield:function(u,C){var B;const g=document.getElementById("emblemShape");return(((B=g.selectedOptions[0])==null?void 0:B.parentNode.label)||"Diversiform")!=="Diversiform"?g.value:g.value==="state"&&C&&pack.states[C].coa?pack.states[C].coa.shield:pack.cultures[u].shield?pack.cultures[u].shield:(ERROR&&console.error("Shield shape is not defined on culture level",pack.cultures[u]),"heater")},shields:{types:{basic:10,regional:2,historical:1,specific:1,banner:1,simple:2,fantasy:1,middleEarth:0},basic:{heater:12,spanish:6,french:1},regional:{horsehead:1,horsehead2:1,polish:1,hessen:1,swiss:1},historical:{boeotian:1,roman:2,kite:1,oldFrench:5,renaissance:2,baroque:2},specific:{targe:1,targe2:0,pavise:5,wedged:10},banner:{flag:1,pennon:0,guidon:0,banner:0,dovetail:1,gonfalon:5,pennant:0},simple:{round:12,oval:6,vesicaPiscis:1,square:1,diamond:2,no:0},fantasy:{fantasy1:2,fantasy2:2,fantasy3:1,fantasy4:1,fantasy5:3},middleEarth:{noldor:1,gondor:1,easterling:1,erebor:1,ironHills:1,urukHai:1,moriaOrc:1}}}}();window.Submap=function(){const e=(c,f)=>c.cells.h[f]<20,t=(c,f)=>c>0&&c<graphWidth&&f>0&&f<graphHeight;function n(c,f){const z=f.projection,m=f.inverse,b=S=>INFO&&console.log("SUBMAP:",S),A=performance.now();invokeActiveZooming(),seed=c.seed,Math.random=aleaPRNG(seed),INFO&&console.group("SubMap with seed: "+seed),DEBUG&&console.log("Using Options:",f),applyMapSize(),grid=generateGrid(),drawScaleBar(scale);const u=(S,h,v)=>{for(const[E,[P,T]]of S.entries()){const[R,L]=m(P,T),M=h.find(R,L,1/0)[2];v(E,M)}};b("Resampling heightmap, temperature and precipitation.");const C=grid.points.length;grid.cells.h=new Uint8Array(C),grid.cells.temp=new Int8Array(C),grid.cells.prec=new Uint8Array(C);const g=new Uint32Array(C),p=c.grid,B=c.grid.points.map(S=>[]);if(u(grid.points,c.pack.cells.q,(S,h)=>{const v=c.pack.cells.g[h];grid.cells.h[S]=p.cells.h[v],grid.cells.temp[S]=p.cells.temp[v],grid.cells.prec[S]=p.cells.prec[v],f.depressRivers&&B[v].push(S),g[S]=v}),f.smoothHeightMap){const S=grid.cells;S.h.forEach((h,v)=>{const E=S.c[v].map(P=>S.h[P]);E.push(h),S.h[v]=h>=20?Math.max(d3.mean(E),20):Math.min(d3.mean(E),19)})}if(f.depressRivers){b("Generating riverbeds.");const S=new Uint16Array(grid.cells.i.length);c.pack.rivers.forEach(h=>h.cells.forEach(v=>{if(v<0)return;const E=c.pack.cells.g[v],P=B[E];if(!P)throw"TargetCell shouldn't be empty.";P.forEach(T=>{grid.cells.h[T]<20||(S[T]=1)})})),grid.cells.h.forEach((h,v)=>{S[v]||h<20||(grid.cells.h[v]=Math.min(h+2,100))})}b("Detect features, ocean and generating lakes."),markFeatures(),markupGridOcean(),f.addLakesInDepressions&&(addLakesInDeepDepressions(),openNearSeaLakes()),OceanLayers(),calculateMapCoordinates(),b("Cell cleanup."),reGraph(),b("Define coastline."),drawCoastline();const k=c.pack.cells,d=c.pack.cells.p.map(S=>[]),s=pack.cells.i.length,o=pack.cells;o.culture=new Uint16Array(s),o.state=new Uint16Array(s),o.burg=new Uint16Array(s),o.religion=new Uint16Array(s),o.road=new Uint16Array(s),o.crossroad=new Uint16Array(s),o.province=new Uint16Array(s),b("Resampling culture, state and religion map.");for(const[S,h]of o.g.entries()){const v=g[h];if(v===void 0){console.error("Can not find old cell id",g,"in",h);continue}const E=k.i.filter(T=>k.g[T]==v);let P;if(E.length){const T=L=>(L[0]-o.p[S][0])**2+(L[1]-o.p[S][1])**2;let R=1/0;if(E.forEach(L=>{e(c.pack,L)!==e(pack,S)&&console.warn(`cell sank because of addLakesInDepressions: ${L}`);const[M,I]=k.p[L],H=T(z(M,I));isNaN(H)&&console.error("Distance is not a number!","Old point:",M,I),H<R&&([R,P]=[H,L])}),P===void 0){console.warn("Warning, no match for",S,"(parent:",h,")");continue}}else{if(!p.cells.h[v]<20){console.error(`Warning, ${h} should be water cell, not ${p.cells.h[v]}`);continue}o.p[S];const[T,R]=m(x,y);if(P=k.q.find(T,R,1/0)[2],!P){console.warn("Warning, no id found in quad",S,"parent",h);continue}}e(pack,S)!==e(c.pack,P)&&WARN&&console.warn("Type discrepancy detected:",S,P,`${pack.cells.t[S]} != ${k.t[P]}`),o.culture[S]=k.culture[P],o.state[S]=k.state[P],o.religion[S]=k.religion[P],o.province[S]=k.province[P],d[P].push(S)}b("Regenerating river network."),Rivers.generate(),drawRivers(),Lakes.defineGroup(),b("Regenerating Biome."),defineBiomes(),rankCells(),b("Porting Cultures"),pack.cultures=c.pack.cultures;const l=new Set(pack.cells.culture);pack.cultures.forEach((S,h)=>{if(!h)return;if(!l.has(h)){S.removed=!0,S.center=null;return}const v=d[S.center];S.center=v.length?v[0]:pack.cells.culture.findIndex(E=>E===h)}),b("Porting and locking burgs."),r(c,z,f),b("Porting states.");const a=new Set(pack.cells.state);pack.states=c.pack.states,pack.states.forEach((S,h)=>{!S.i||S.removed||(a.has(h)||(S.removed=!0),S.neighbors=S.neighbors.filter(v=>a.has(v)),S.center=pack.burgs[S.capital].cell?pack.burgs[S.capital].cell:pack.cells.state.findIndex(v=>v===h))}),b("Porting provinces.");const w=new Set(pack.cells.province);pack.provinces=c.pack.provinces,pack.provinces.forEach((S,h)=>{if(!S||S.removed)return;if(!w.has(h)){S.removed=!0;return}const v=d[S.center];S.center=v.length?v[0]:pack.cells.province.findIndex(E=>E===h)}),BurgsAndStates.drawBurgs(),b("Regenerating road network."),Routes.regenerate(),drawStates(),drawBorders(),BurgsAndStates.drawStateLabels(),Rivers.specify(),Lakes.generateName(),b("Porting military.");for(const S of pack.states)if(!!S.military){for(const h of S.military){[h.x,h.y]=z(h.x,h.y),[h.bx,h.by]=z(h.bx,h.by);const v=d[h.cell];h.cell=v&&v.length?v[0]:null}S.military=S.military.filter(h=>h.cell).map((h,v)=>({...h,i:v}))}Military.redraw(),b("Copying markers.");for(const S of pack.markers){const[h,v]=z(S.x,S.y);t(h,v)?(S.x=h,S.y=v,S.cell=Te(h,v),f.lockMarkers&&(S.lock=!0)):Markers.deleteMarker(S.i)}layerIsOn("toggleMarkers")&&drawMarkers(),b("Redraw emblems."),drawEmblems(),b("Regenerating Zones."),addZones(),Names.getMapName(),b("Restoring Notes."),notes=c.notes,b("Submap done."),WARN&&console.warn(`TOTAL: ${O((performance.now()-A)/1e3,2)}s`),showStatistics(),INFO&&console.groupEnd("Generated Map "+seed)}const i=(c,f,z=3)=>(m,b)=>{const A=B=>(m-pack.cells.p[B][0])**2+(b-pack.cells.p[B][0])**2,u=Te(m,b),C=new Set([u]),g=(B,k)=>{const[d,s]=B.filter(c).reduce(([a,w],S)=>{const v=pack.cells.c[S].filter(f).reduce((E,P)=>A(P)<A(E)?P:E);return a===void 0?[S,v]:v&&A(a)<A(S)?[S,v]:[a,w]},[void 0,void 0]);if(d&&s)return[d,s];const o=new Set(B.map(a=>pack.cells.c[a]).flat()),l=Array.from(o).filter(a=>!C.has(a));return k>=z||!l.length?[void 0,void 0]:(l.forEach(a=>C.add(a)),g(l,k+1))};return g([u],1)};function r(c,f,z){const m=pack.cells;pack.burgs=c.pack.burgs,pack.burgs.forEach((b,A)=>{if(A==0)return;if([b.x,b.y]=f(b.x,b.y),b.population=b.population*z.scale,!t(b.x,b.y)){b.removed=!0,b.cell=null;return}const u=Te(b.x,b.y);let C;const g=B=>m.t[B]===1&&!m.burg[B],p=B=>m.t[B]===-1;if(m.burg[u]&&(C=i(g,B=>!0,3)),(e(pack,u)||b.port)&&(C=i(g,p,6)),C){const[B,k]=C(b.x,b.y);if(!B){WARN&&console.warn(`Can not relocate Burg: ${b.name} sunk and destroyed. :-(`),b.cell=null,b.removed=!0;return}DEBUG&&console.log(`Moving ${b.name} from ${u} to ${B} near ${k}.`),[b.x,b.y]=b.port?ya(B,k):m.p[B],b.port&&(b.port=m.f[k]),b.cell=B,b.port&&!e(pack,k)&&console.error("betrayal! negihbor must be water!",b)}else b.cell=u;b.lock||(b.lock=z.lockBurgs),m.burg[b.cell]=A})}return{resample:n,findNearest:i}}();const ti=[{family:"Arial"},{family:"Times New Roman"},{family:"Georgia"},{family:"Garamond"},{family:"Lucida Sans Unicode"},{family:"Courier New"},{family:"Verdana"},{family:"Impact"},{family:"Comic Sans MS"},{family:"Papyrus"},{family:"Almendra SC",src:"url(https://fonts.gstatic.com/s/almendrasc/v13/Iure6Yx284eebowr7hbyTaZOrLQ.woff2)",unicodeRange:"U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+2074, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD"},{family:"Amarante",src:"url(https://fonts.gstatic.com/s/amarante/v22/xMQXuF1KTa6EvGx9bp-wAXs.woff2)",unicodeRange:"U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+2074, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD"},{family:"Amatic SC",src:"url(https://fonts.gstatic.com/s/amaticsc/v11/TUZ3zwprpvBS1izr_vOMscGKfrUC.woff2)",unicodeRange:"U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+2074, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD"},{family:"Arima Madurai",src:"url(https://fonts.gstatic.com/s/arimamadurai/v14/t5tmIRoeKYORG0WNMgnC3seB3T7Prw.woff2)",unicodeRange:"U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+2074, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD"},{family:"Architects Daughter",src:"url(https://fonts.gstatic.com/s/architectsdaughter/v8/RXTgOOQ9AAtaVOHxx0IUBM3t7GjCYufj5TXV5VnA2p8.woff2)",unicodeRange:"U+0000-00FF, U+0131, U+0152-0153, U+02C6, U+02DA, U+02DC, U+2000-206F, U+2074, U+20AC, U+2212, U+2215"},{family:"Bitter",src:"url(https://fonts.gstatic.com/s/bitter/v12/zfs6I-5mjWQ3nxqccMoL2A.woff2)",unicodeRange:"U+0000-00FF, U+0131, U+0152-0153, U+02C6, U+02DA, U+02DC, U+2000-206F, U+2074, U+20AC, U+2212, U+2215"},{family:"Caesar Dressing",src:"url(https://fonts.gstatic.com/s/caesardressing/v6/yYLx0hLa3vawqtwdswbotmK4vrRHdrz7.woff2)",unicodeRange:"U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+2074, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD"},{family:"Cinzel",src:"url(https://fonts.gstatic.com/s/cinzel/v7/zOdksD_UUTk1LJF9z4tURA.woff2)",unicodeRange:"U+0000-00FF, U+0131, U+0152-0153, U+02C6, U+02DA, U+02DC, U+2000-206F, U+2074, U+20AC, U+2212, U+2215"},{family:"Dancing Script",src:"url(https://fonts.gstatic.com/s/dancingscript/v9/KGBfwabt0ZRLA5W1ywjowUHdOuSHeh0r6jGTOGdAKHA.woff2)",unicodeRange:"U+0000-00FF, U+0131, U+0152-0153, U+02C6, U+02DA, U+02DC, U+2000-206F, U+2074, U+20AC, U+2212, U+2215"},{family:"Faster One",src:"url(https://fonts.gstatic.com/s/fasterone/v17/H4ciBXCHmdfClFb-vWhf-LyYhw.woff2)",unicodeRange:"U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+2074, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD"},{family:"Forum",src:"url(https://fonts.gstatic.com/s/forum/v16/6aey4Ky-Vb8Ew8IROpI.woff2)",unicodeRange:"U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+2074, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD"},{family:"Fredericka the Great",src:"url(https://fonts.gstatic.com/s/frederickathegreat/v6/9Bt33CxNwt7aOctW2xjbCstzwVKsIBVV--Sjxbc.woff2)",unicodeRange:"U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+2074, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD"},{family:"Gloria Hallelujah",src:"url(https://fonts.gstatic.com/s/gloriahallelujah/v9/CA1k7SlXcY5kvI81M_R28cNDay8z-hHR7F16xrcXsJw.woff2)",unicodeRange:"U+0000-00FF, U+0131, U+0152-0153, U+02C6, U+02DA, U+02DC, U+2000-206F, U+2074, U+20AC, U+2212, U+2215"},{family:"Great Vibes",src:"url(https://fonts.gstatic.com/s/greatvibes/v5/6q1c0ofG6NKsEhAc2eh-3Y4P5ICox8Kq3LLUNMylGO4.woff2)",unicodeRange:"U+0000-00FF, U+0131, U+0152-0153, U+02C6, U+02DA, U+02DC, U+2000-206F, U+2074, U+20AC, U+2212, U+2215"},{family:"Henny Penny",src:"url(https://fonts.gstatic.com/s/hennypenny/v17/wXKvE3UZookzsxz_kjGSfPQtvXI.woff2)",unicodeRange:"U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+2074, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD"},{family:"IM Fell English",src:"url(https://fonts.gstatic.com/s/imfellenglish/v7/xwIisCqGFi8pff-oa9uSVAkYLEKE0CJQa8tfZYc_plY.woff2)",unicodeRange:"U+0000-00FF, U+0131, U+0152-0153, U+02C6, U+02DA, U+02DC, U+2000-206F, U+2074, U+20AC, U+2212, U+2215"},{family:"Kelly Slab",src:"url(https://fonts.gstatic.com/s/kellyslab/v15/-W_7XJX0Rz3cxUnJC5t6fkQLfg.woff2)",unicodeRange:"U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+2074, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD"},{family:"Kranky",src:"url(https://fonts.gstatic.com/s/kranky/v24/hESw6XVgJzlPsFn8oR2F.woff2)",unicodeRange:"U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+2074, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD"},{family:"Lobster Two",src:"url(https://fonts.gstatic.com/s/lobstertwo/v18/BngMUXZGTXPUvIoyV6yN5-fN5qU.woff2)",unicodeRange:"U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+2074, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD"},{family:"Kaushan Script",src:"url(https://fonts.gstatic.com/s/kaushanscript/v6/qx1LSqts-NtiKcLw4N03IEd0sm1ffa_JvZxsF_BEwQk.woff2)",unicodeRange:"U+0000-00FF, U+0131, U+0152-0153, U+02C6, U+02DA, U+02DC, U+2000-206F, U+2074, U+20AC, U+2212, U+2215"},{family:"Macondo",src:"url(https://fonts.gstatic.com/s/macondo/v21/RrQQboN9-iB1IXmOe2LE0Q.woff2)",unicodeRange:"U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+2074, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD"},{family:"MedievalSharp",src:"url(https://fonts.gstatic.com/s/medievalsharp/v9/EvOJzAlL3oU5AQl2mP5KdgptMqhwMg.woff2)",unicodeRange:"U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+2074, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD"},{family:"Metal Mania",src:"url(https://fonts.gstatic.com/s/metalmania/v22/RWmMoKWb4e8kqMfBUdPFJdXFiaQ.woff2)",unicodeRange:"U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+2074, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD"},{family:"Metamorphous",src:"url(https://fonts.gstatic.com/s/metamorphous/v7/Wnz8HA03aAXcC39ZEX5y133EOyqs.woff2)",unicodeRange:"U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+2074, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD"},{family:"Montez",src:"url(https://fonts.gstatic.com/s/montez/v8/aq8el3-0osHIcFK6bXAPkw.woff2)",unicodeRange:"U+0000-00FF, U+0131, U+0152-0153, U+02C6, U+02DA, U+02DC, U+2000-206F, U+2074, U+20AC, U+2212, U+2215"},{family:"Nova Script",src:"url(https://fonts.gstatic.com/s/novascript/v10/7Au7p_IpkSWSTWaFWkumvlQKGFw.woff2)",unicodeRange:"U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+2074, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD"},{family:"Orbitron",src:"url(https://fonts.gstatic.com/s/orbitron/v9/HmnHiRzvcnQr8CjBje6GQvesZW2xOQ-xsNqO47m55DA.woff2)",unicodeRange:"U+0000-00FF, U+0131, U+0152-0153, U+02C6, U+02DA, U+02DC, U+2000-206F, U+2074, U+20AC, U+2212, U+2215"},{family:"Oregano",src:"url(https://fonts.gstatic.com/s/oregano/v13/If2IXTPxciS3H4S2oZDVPg.woff2)",unicodeRange:"U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+2074, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD"},{family:"Pirata One",src:"url(https://fonts.gstatic.com/s/pirataone/v22/I_urMpiDvgLdLh0fAtofhi-Org.woff2)",unicodeRange:"U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+2074, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD"},{family:"Sail",src:"url(https://fonts.gstatic.com/s/sail/v16/DPEjYwiBxwYJJBPJAQ.woff2)",unicodeRange:"U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+2074, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD"},{family:"Satisfy",src:"url(https://fonts.gstatic.com/s/satisfy/v8/2OzALGYfHwQjkPYWELy-cw.woff2)",unicodeRange:"U+0000-00FF, U+0131, U+0152-0153, U+02C6, U+02DA, U+02DC, U+2000-206F, U+2074, U+20AC, U+2212, U+2215"},{family:"Shadows Into Light",src:"url(https://fonts.gstatic.com/s/shadowsintolight/v7/clhLqOv7MXn459PTh0gXYFK2TSYBz0eNcHnp4YqE4Ts.woff2)",unicodeRange:"U+0000-00FF, U+0131, U+0152-0153, U+02C6, U+02DA, U+02DC, U+2000-206F, U+2074, U+20AC, U+2212, U+2215"},{family:"Tapestry",src:"url(https://fonts.gstatic.com/s/macondo/v21/RrQQboN9-iB1IXmOe2LE0Q.woff2)",unicodeRange:"U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+2074, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD"},{family:"Uncial Antiqua",src:"url(https://fonts.gstatic.com/s/uncialantiqua/v5/N0bM2S5WOex4OUbESzoESK-i-MfWQZQ.woff2)",unicodeRange:"U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+2074, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD"},{family:"Underdog",src:"url(https://fonts.gstatic.com/s/underdog/v6/CHygV-jCElj7diMroWSlWV8.woff2)",unicodeRange:"U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+2074, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD"},{family:"UnifrakturMaguntia",src:"url(https://fonts.gstatic.com/s/unifrakturmaguntia/v16/WWXPlieVYwiGNomYU-ciRLRvEmK7oaVemGZM.woff2)",unicodeRange:"U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+2074, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD"},{family:"Yellowtail",src:"url(https://fonts.gstatic.com/s/yellowtail/v8/GcIHC9QEwVkrA19LJU1qlPk_vArhqVIZ0nv9q090hN8.woff2)",unicodeRange:"U+0000-00FF, U+0131, U+0152-0153, U+02C6, U+02DA, U+02DC, U+2000-206F, U+2074, U+20AC, U+2212, U+2215"}];ni();function ai(e){const{family:t,src:n,...i}=e;if(oi(t),!n)return;const r=new FontFace(t,n,{...i,display:"block"});document.fonts.add(r)}function ni(){ti.forEach(e=>ai(e))}function oi(e){const t=document.getElementById("styleSelectFont"),n=document.createElement("option");n.value=e,n.innerText=e,n.style.fontFamily=e,t.add(n)}window.addEventListener("resize",function(e){stored("mapWidth")&&stored("mapHeight")||(mapWidthInput.value=window.innerWidth,mapHeightInput.value=window.innerHeight,changeMapSize())});location.hostname&&location.hostname!=="localhost"&&location.hostname!=="127.0.0.1"&&(window.onbeforeunload=()=>"Are you sure you want to navigate away?");Array.from(document.getElementsByClassName("speaker")).forEach(e=>{const t=e.previousElementSibling;e.addEventListener("click",()=>ii(t.value))});function ii(e){const t=new SpeechSynthesisUtterance(e),n=speechSynthesis.getVoices();if(n.length){const i=+document.getElementById("speakerVoice").value;t.voice=n[i]}speechSynthesis.speak(t)}const ri="modulepreload",la={},si="/",St=function(t,n){return!n||n.length===0?t():Promise.all(n.map(i=>{if(i=`${si}${i}`,i in la)return;la[i]=!0;const r=i.endsWith(".css"),c=r?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${i}"]${c}`))return;const f=document.createElement("link");if(f.rel=r?"stylesheet":ri,r||(f.as="script",f.crossOrigin=""),f.href=i,document.head.appendChild(f),r)return new Promise((z,m)=>{f.addEventListener("load",z),f.addEventListener("error",()=>m(new Error(`Unable to preload CSS for ${i}`)))})})).then(()=>t())};$("#optionsContainer").draggable({handle:".drag-trigger",snap:"svg",snapMode:"both"});$("#exitCustomization").draggable({handle:"div"});$("#mapLayers").disableSelection();ze("disable_click_arrow_tooltip")&&(ct(),optionsTrigger.classList.remove("glow"));optionsTrigger.addEventListener("mouseenter",function(){optionsTrigger.classList.contains("glow")||document.getElementById("options").style.display==="none"&&(regenerate.style.display="block")});collapsible.addEventListener("mouseleave",function(){regenerate.style.display="none"});document.getElementById("options").querySelector("div.tab").addEventListener("click",function(e){if(e.target.tagName!=="BUTTON")return;const t=e.target.id,n=document.getElementById("options").querySelector(".tab > button.active");n&&t===n.id||(n&&n.classList.remove("active"),document.getElementById(t).classList.add("active"),document.getElementById("options").querySelectorAll(".tabcontent").forEach(i=>i.style.display="none"),t==="layersTab"?layersContent.style.display="block":t==="styleTab"?styleContent.style.display="block":t==="optionsTab"?Lt.style.display="block":t==="toolsTab"?customization===1?customizationMenu.style.display="block":toolsContent.style.display="block":t==="aboutTab"&&(aboutContent.style.display="block"))});document.getElementById("options").addEventListener("change",Ba);document.getElementById("dialogs").addEventListener("change",Ba);document.getElementById("options").addEventListener("input",Ma);document.getElementById("dialogs").addEventListener("input",Ma);function Ba(e){e.target.dataset.stored&&mt(e.target.dataset.stored)}function Ma(e){const t=e.target.id,n=e.target.value;if(t==="manorsInput")return manorsOutput.value=n==1e3?"auto":n;if(t.slice(-5)==="Input"){const i=document.getElementById(t.slice(0,-5)+"Output");i&&(i.value=n)}else if(t.slice(-6)==="Output"){const i=document.getElementById(t.slice(0,-6)+"Input");i&&(i.value=n)}}const Lt=document.getElementById("optionsContent");Lt.addEventListener("input",function(e){const t=e.target.id,n=e.target.value;t==="mapWidthInput"||t==="mapHeightInput"?li():t==="pointsInput"?bi(+n):t==="culturesSet"?wi():t==="regionsInput"||t==="regionsOutput"?Ai(n):t==="emblemShape"?Si(n):t==="tooltipSizeInput"||t==="tooltipSizeOutput"?Ci(n):t==="themeHueInput"?Mi(n):t==="themeColorInput"?Bt(themeColorInput.value,transparencyInput.value):t==="transparencyInput"&&Bt(themeColorInput.value,n)});Lt.addEventListener("change",function(e){const t=e.target.id,n=e.target.value;t==="zoomExtentMin"||t==="zoomExtentMax"?Ei(n):t==="optionsSeed"?gi():t==="uiSizeInput"||t==="uiSizeOutput"?zi(n):t==="shapeRendering"?Li(n):t==="yearInput"?Ri():t==="eraInput"?Ti():t==="stateLabelsModeInput"&&(options.stateLabelsMode=n)});Lt.addEventListener("click",function(e){const t=e.target.id;t==="toggleFullscreen"?ci():t==="optionsMapHistory"?pi():t==="optionsCopySeed"?fi():t==="optionsEraRegenerate"?Ii():t==="templateInputContainer"?Pi():t==="zoomExtentDefault"?mi():t==="translateExtent"?ui(e.target):t==="speakerTest"?hi():t==="themeColorRestore"&&Bi()});function li(){Ea(),localStorage.setItem("mapWidth",mapWidthInput.value),localStorage.setItem("mapHeight",mapHeightInput.value)}function Ea(){svgWidth=Math.min(+mapWidthInput.value,window.innerWidth),svgHeight=Math.min(+mapHeightInput.value,window.innerHeight),svg.attr("width",svgWidth).attr("height",svgHeight);const e=Math.max(+mapWidthInput.value,graphWidth),t=Math.max(+mapHeightInput.value,graphHeight);Zoom.translateExtent([0,0,e,t]),landmass.select("rect").attr("x",0).attr("y",0).attr("width",e).attr("height",t),oceanPattern.select("rect").attr("x",0).attr("y",0).attr("width",e).attr("height",t),oceanLayers.select("rect").attr("x",0).attr("y",0).attr("width",e).attr("height",t),fogging.selectAll("rect").attr("x",0).attr("y",0).attr("width",e).attr("height",t),defs.select("mask#fog > rect").attr("width",e).attr("height",t),texture.select("image").attr("width",e).attr("height",t),fitScaleBar(),window.fitLegendBox&&fitLegendBox()}function ci(){mapWidthInput.value!=window.innerWidth||mapHeightInput.value!=window.innerHeight?(mapWidthInput.value=window.innerWidth,mapHeightInput.value=window.innerHeight,localStorage.removeItem("mapHeight"),localStorage.removeItem("mapWidth")):(mapWidthInput.value=graphWidth,mapHeightInput.value=graphHeight),Ea()}function ui(e){const t=!Number(e.dataset.on),n=t?[-graphWidth/2,-graphHeight/2,graphWidth*1.5,graphHeight*1.5]:[0,0,graphWidth,graphHeight];Zoom.translateExtent(n),e.dataset.on=Number(t)}const di=setInterval(function(){const e=speechSynthesis.getVoices();if(e.length)clearInterval(di);else return;const t=document.getElementById("speakerVoice");e.forEach((n,i)=>{t.options.add(new Option(n.name,i,!1))}),ze("speakerVoice")?t.value=ze("speakerVoice"):t.value=e.findIndex(n=>n.lang==="en-US")},1e3);function hi(){const e=`${mapName.value}, ${options.year} ${options.era}`,t=new SpeechSynthesisUtterance(e),n=speechSynthesis.getVoices();if(n.length){const i=+document.getElementById("speakerVoice").value;t.voice=n[i]}speechSynthesis.speak(t)}function gi(){if(optionsSeed.value==seed)return se("The current map already has this seed",!1,"error");La()}function pi(){const e=mapHistory.map((t,n)=>{const i=new Date(t.created).toLocaleTimeString(),r=`<i data-tip="Click to generate a map with this seed" onclick="restoreSeed(${n})" class="icon-history optionsSeedRestore"></i>`;return`<li>Seed: ${t.seed} ${r}. Size: ${t.width}x${t.height}. Template: ${t.template}. Created: ${i}</li>`});alertMessage.innerHTML=`<ol style="margin: 0; padding-left: 1.5em">
${e.join("")}
</ol>`,$("#alert").dialog({resizable:!1,title:"Seed history",position:{my:"center",at:"center",of:"svg"}})}function mi(){zoomExtentMin.value=1,zoomExtentMax.value=20,Zoom.scaleExtent([1,20]),Zoom.scaleTo(svg,1)}function fi(){const e=document.querySelectorAll("i.icon-lock").length,t=`?seed=${optionsSeed.value}&width=${graphWidth}&height=${graphHeight}${e?"":"&options=default"}`;navigator.clipboard.writeText(location.host+location.pathname+t).then(()=>{se("Map URL is copied to clipboard",!1,"success",3e3)}).catch(n=>se("Could not copy URL: "+n,!1,"error",5e3))}const yi={1:1e3,2:2e3,3:5e3,4:1e4,5:2e4,6:3e4,7:4e4,8:5e4,9:6e4,10:7e4,11:8e4,12:9e4,13:1e5};function bi(e){const t=yi[e]||1e3;pointsInput.dataset.cells=t,pointsOutputFormatted.value=vi(t),pointsOutputFormatted.style.color=ki(t)}function vi(e){return e/1e3+"K"}function ki(e){return e>5e4?"#b12117":e!==1e4?"#dfdf12":"#053305"}function wi(){const e=culturesSet.selectedOptions[0].dataset.max;culturesInput.max=culturesOutput.max=e,+culturesOutput.value>+e&&(culturesInput.value=culturesOutput.value=e)}function Si(e){const t=document.getElementById("emblemShapeImage"),n=window.COArenderer&&COArenderer.shieldPaths[e];n?t.setAttribute("d",n):t.removeAttribute("d");const i=["culture","state","random"].includes(e)?null:e;e==="random"&&pack.cultures.filter(c=>!c.removed).forEach(c=>c.shield=Cultures.getRandomShield());const r=(c,f)=>{const z=document.getElementById(c);!z||(z.remove(),COArenderer.trigger(c,f))};pack.states.forEach(c=>{if(!c.i||c.removed||!c.coa||c.coa==="custom")return;const f=i||COA.getShield(c.culture,null);f!==c.coa.shield&&(c.coa.shield=f,r("stateCOA"+c.i,c.coa))}),pack.provinces.forEach(c=>{if(!c.i||c.removed||!c.coa||c.coa==="custom")return;const f=pack.cells.culture[c.center],z=i||COA.getShield(f,c.state);z!==c.coa.shield&&(c.coa.shield=z,r("provinceCOA"+c.i,c.coa))}),pack.burgs.forEach(c=>{if(!c.i||c.removed||!c.coa||c.coa==="custom")return;const f=i||COA.getShield(c.culture,c.state);f!==c.coa.shield&&(c.coa.shield=f,r("burgCOA"+c.i,c.coa))})}function Ai(e){regionsOutput.style.color=+e?null:"#b12117",burgLabels.select("#capitals").attr("data-size",Math.max(O(6-e/20),3)),labels.select("#countries").attr("data-size",Math.max(O(18-e/6),4))}function zi(e){if(isNaN(+e)||+e<.5)return;const t=xi();+e>t&&(e=t),uiSizeInput.value=uiSizeOutput.value=e,document.getElementsByTagName("body")[0].style.fontSize=O(e*10,2)+"px",document.getElementById("options").style.width=e*300+"px"}function xi(){return O(Math.min(window.innerHeight/465,window.innerWidth/302),1)}function Ci(e){tooltip.style.fontSize=`calc(${e}px + 0.5vw)`}const jt="#997787";function Bi(){localStorage.removeItem("themeColor"),Bt(jt,transparencyInput.value)}function Mi(e){const{s:t,l:n}=d3.hsl(themeColorInput.value),i=d3.hsl(+e,t,n).hex();Bt(i,transparencyInput.value)}function Bt(e,t){transparencyInput.value=transparencyOutput.value=t;const n=(100-+t)/100,i=Math.min(n+.3,1),{h:r,s:c,l:f}=d3.hsl(e||jt);themeColorInput.value=e||jt,themeHueInput.value=r;const z=(A,u,C,g)=>d3.hsl(A,u,C,g).toString(),m=[{name:"--bg-main",h:r,s:c,l:f,alpha:n},{name:"--bg-lighter",h:r,s:c,l:f+.02,alpha:n},{name:"--bg-light",h:r,s:c-.02,l:f+.06,alpha:n},{name:"--light-solid",h:r,s:c+.01,l:f+.05,alpha:1},{name:"--dark-solid",h:r,s:c,l:f-.2,alpha:1},{name:"--header",h:r,s:c,l:f-.03,alpha:i},{name:"--header-active",h:r,s:c,l:f-.09,alpha:i},{name:"--bg-disabled",h:r,s:c-.04,l:f+.09,alphaReduced:i},{name:"--bg-dialogs",h:0,s:0,l:.98,alpha:n}],b=document.documentElement.style;m.forEach(({name:A,h:u,s:C,l:g,alpha:p})=>{b.setProperty(A,z(u,C,g,p))})}function Ei(e){const t=Math.max(+ne("zoomExtentMin").value,.01),n=Math.min(+ne("zoomExtentMax").value,200);Zoom.scaleExtent([t,n]);const i=Ie(+e,.01,200);Zoom.scaleTo(svg,i)}function Li(e){var t;(t=fmg.viewbox)==null||t.attr("shape-rendering",e)}function Ii(){unlock("era"),options.era=eraInput.value=Names.getBaseShort(V(.7)?1:be(nameBases.length))+" Era",options.eraShort=options.era.split(" ").map(e=>e[0].toUpperCase()).join("")}function Ri(){if(!!yearInput.value){if(isNaN(+yearInput.value)){se("Current year should be a number",!1,"error");return}options.year=+yearInput.value}}function Ti(){!eraInput.value||(mt("era"),options.era=eraInput.value)}async function Pi(){(await St(()=>import("./heightmap-selection.js_v_1.87.b0b46f49.js"),[])).open()}document.getElementById("sticked").addEventListener("click",function(e){const t=e.target.id;t==="newMapButton"?La():t==="saveButton"?Hi():t==="exportButton"?Ui():t==="loadButton"?Ni():t==="zoomReset"&&Zoom.reset(1e3)});function La(e){if(customization)return se("New map cannot be generated when edit mode is active, please exit the mode and retry",!1,"error");if((Date.now()-De(mapHistory).created)/6e4<5)return regenerateMap(e);alertMessage.innerHTML=`Are you sure you want to generate a new map?<br />
All unsaved changes made to the current map will be lost`,$("#alert").dialog({resizable:!1,title:"Generate new map",buttons:{Cancel:function(){$(this).dialog("close")},Generate:function(){closeDialogs(),regenerateMap(e)}}})}function Hi(){const e=document.getElementById("sharableLinkContainer");e.style.display="none",$("#saveMapData").dialog({title:"Save map",resizable:!1,width:"25em",position:{my:"center",at:"center",of:"svg"},buttons:{Close:function(){$(this).dialog("close")}}})}function Ui(){document.getElementById("showLabels").checked=!hideLabels.checked,$("#exportMapData").dialog({title:"Export map data",resizable:!1,width:"26em",position:{my:"center",at:"center",of:"svg"},buttons:{Close:function(){$(this).dialog("close")}}})}async function Ni(){if($("#loadMapData").dialog({title:"Load map",resizable:!1,width:"24em",position:{my:"center",at:"center",of:"svg"},buttons:{Close:function(){$(this).dialog("close")}}}),Cloud.providers.dropbox.api){document.getElementById("dropboxConnectButton").style.display="none",document.getElementById("loadFromDropboxSelect").style.display="block";const e=document.getElementById("loadFromDropboxButtons"),t=document.getElementById("loadFromDropboxSelect");t.innerHTML='<option value="" disabled selected>Loading...</option>';const n=await Cloud.providers.dropbox.list();if(!n){e.style.display="none",t.innerHTML='<option value="" disabled selected>Save files to Dropbox first</option>';return}e.style.display="block",t.innerHTML="",n.forEach(({name:i,updated:r,size:c,path:f})=>{const z=O(c/1024/1024,2)+" MB",b=`${new Date(r).toLocaleDateString()}: ${i} [${z}]`,A=new Option(b,f);t.options.add(A)});return}document.getElementById("dropboxConnectButton").style.display="inline-block",document.getElementById("loadFromDropboxButtons").style.display="none",document.getElementById("loadFromDropboxSelect").style.display="none"}document.getElementById("mapToLoad").addEventListener("change",function(){const e=this.files[0];this.value="",closeDialogs(),uploadMap(e)});viewMode.addEventListener("click",Ki);function Ki(e){const t=e.target;if(t.tagName!=="BUTTON")return;const n=t.classList.contains("pressed");Ia(),!n&&t.id!=="viewStandard"&&(viewStandard.classList.remove("pressed"),t.classList.add("pressed"),Di(t.id))}function Ia(){viewMode.querySelectorAll(".pressed").forEach(e=>e.classList.remove("pressed")),heightmap3DView.classList.remove("pressed"),viewStandard.classList.add("pressed"),document.getElementById("canvas3d")&&(ThreeD.stop(),document.getElementById("canvas3d").remove(),options3dUpdate.offsetParent&&$("#options3d").dialog("close"),preview3d.offsetParent&&$("#preview3d").dialog("close"))}async function Di(e){const t=document.createElement("canvas");t.id="canvas3d",t.dataset.type=e,e==="heightmap3DView"?(t.width=parseFloat(preview3d.style.width)||graphWidth/3,t.height=t.width/(graphWidth/graphHeight),t.style.display="block"):(t.width=svgWidth,t.height=svgHeight,t.style.position="absolute",t.style.display="none"),await ThreeD.create(t,e)&&(t.style.display="block",t.onmouseenter=()=>{const i="Left mouse to change angle, middle mouse / mousewheel to zoom, right mouse to pan. <b>O</b> to toggle options";+t.dataset.hovered>2?se(""):se(i),t.dataset.hovered=(+t.dataset.hovered|0)+1},e==="heightmap3DView"?(document.getElementById("preview3d").appendChild(t),$("#preview3d").dialog({title:"3D Preview",resizable:!0,position:{my:"left bottom",at:"left+10 bottom-20",of:"svg"},resizeStop:Fi,close:Ia})):document.body.insertBefore(t,optionsContainer),Oi())}function Fi(){const e=document.getElementById("canvas3d");e.width=parseFloat(preview3d.style.width),e.height=parseFloat(preview3d.style.height)-2,ThreeD.redraw()}function Oi(){if(options3dUpdate.offsetParent){$("#options3d").dialog("close");return}if($("#options3d").dialog({title:"3D mode settings",resizable:!1,width:"fit-content",position:{my:"right top",at:"right-30 top+10",of:"svg",collision:"fit"}}),e(),fmg.modules.options3d)return;fmg.modules.options3d=!0,document.getElementById("options3dUpdate").addEventListener("click",ThreeD.update),document.getElementById("options3dSave").addEventListener("click",ThreeD.saveScreenshot),document.getElementById("options3dOBJSave").addEventListener("click",ThreeD.saveOBJ),document.getElementById("options3dScaleRange").addEventListener("input",t),document.getElementById("options3dScaleNumber").addEventListener("change",t),document.getElementById("options3dLightnessRange").addEventListener("input",n),document.getElementById("options3dLightnessNumber").addEventListener("change",n),document.getElementById("options3dSunX").addEventListener("change",i),document.getElementById("options3dSunY").addEventListener("change",i),document.getElementById("options3dSunZ").addEventListener("change",i),document.getElementById("options3dMeshRotationRange").addEventListener("input",r),document.getElementById("options3dMeshRotationNumber").addEventListener("change",r),document.getElementById("options3dGlobeRotationRange").addEventListener("input",r),document.getElementById("options3dGlobeRotationNumber").addEventListener("change",r),document.getElementById("options3dMeshLabels3d").addEventListener("change",c),document.getElementById("options3dMeshSkyMode").addEventListener("change",f),document.getElementById("options3dMeshSky").addEventListener("input",z),document.getElementById("options3dMeshWater").addEventListener("input",z),document.getElementById("options3dGlobeResolution").addEventListener("change",m);function e(){const b=document.getElementById("canvas3d").dataset.type==="viewGlobe";options3dMesh.style.display=b?"none":"block",options3dGlobe.style.display=b?"block":"none",options3dScaleRange.value=options3dScaleNumber.value=ThreeD.options.scale,options3dLightnessRange.value=options3dLightnessNumber.value=ThreeD.options.lightness*100,options3dSunX.value=ThreeD.options.sun.x,options3dSunY.value=ThreeD.options.sun.y,options3dSunZ.value=ThreeD.options.sun.z,options3dMeshRotationRange.value=options3dMeshRotationNumber.value=ThreeD.options.rotateMesh,options3dGlobeRotationRange.value=options3dGlobeRotationNumber.value=ThreeD.options.rotateGlobe,options3dMeshLabels3d.value=ThreeD.options.labels3d,options3dMeshSkyMode.value=ThreeD.options.extendedWater,options3dColorSection.style.display=ThreeD.options.extendedWater?"block":"none",options3dMeshSky.value=ThreeD.options.skyColor,options3dMeshWater.value=ThreeD.options.waterColor,options3dGlobeResolution.value=ThreeD.options.resolution}function t(){options3dScaleRange.value=options3dScaleNumber.value=this.value,ThreeD.setScale(+this.value)}function n(){options3dLightnessRange.value=options3dLightnessNumber.value=this.value,ThreeD.setLightness(this.value/100)}function i(){const b=+options3dSunX.value,A=+options3dSunY.value,u=+options3dSunZ.value;ThreeD.setSun(b,A,u)}function r(){(this.nextElementSibling||this.previousElementSibling).value=this.value;const b=+this.value;ThreeD.setRotation(b)}function c(){ThreeD.toggleLabels()}function f(){const b=ThreeD.options.extendedWater;options3dColorSection.style.display=b?"none":"block",ThreeD.toggleSky()}function z(){ThreeD.setColors(options3dMeshSky.value,options3dMeshWater.value)}function m(){ThreeD.setResolution(this.value)}}window.scale=1;window.viewX=0;window.viewY=0;window.Zoom=function(){function e(){const{k:b,x:A,y:u}=d3.event.transform,C=Boolean(scale-b),g=Boolean(viewX-A||viewY-u);!C&&!g||(scale=b,viewX=A,viewY=u,handleZoom(C,g))}const t=vt(e,50),n=d3.zoom().scaleExtent([1,20]).on("zoom",t);function i(){svg.call(n)}function r(b,A,u=8,C=2e3){const g=d3.zoomIdentity.translate(b*-u+graphWidth/2,A*-u+graphHeight/2).scale(u);svg.transition().duration(C).call(n.transform,g)}function c(b=1e3){svg.transition().duration(b).call(n.transform,d3.zoomIdentity)}function f([b,A]){n.scaleExtent([b,A])}function z([b,A,u,C]){n.translateExtent([[b,A],[u,C]])}function m(b,A){n.scaleTo(b,A)}return{setZoomBehavior:i,to:r,reset:c,scaleExtent:f,translateExtent:z,scaleTo:m}}();$("#optionsContainer").draggable({handle:".drag-trigger",snap:"svg",snapMode:"both"});$("#exitCustomization").draggable({handle:"div"});$("#mapLayers").disableSelection();ze("disable_click_arrow_tooltip")&&(ct(),optionsTrigger.classList.remove("glow"));optionsTrigger.addEventListener("mouseenter",function(){optionsTrigger.classList.contains("glow")||document.getElementById("options").style.display==="none"&&(regenerate.style.display="block")});collapsible.addEventListener("mouseleave",function(){regenerate.style.display="none"});document.getElementById("options").querySelector("div.tab").addEventListener("click",function(e){if(e.target.tagName!=="BUTTON")return;const t=e.target.id,n=document.getElementById("options").querySelector(".tab > button.active");n&&t===n.id||(n&&n.classList.remove("active"),document.getElementById(t).classList.add("active"),document.getElementById("options").querySelectorAll(".tabcontent").forEach(i=>i.style.display="none"),t==="layersTab"?layersContent.style.display="block":t==="styleTab"?styleContent.style.display="block":t==="optionsTab"?It.style.display="block":t==="toolsTab"?customization===1?customizationMenu.style.display="block":toolsContent.style.display="block":t==="aboutTab"&&(aboutContent.style.display="block"))});document.getElementById("options").addEventListener("change",Ra);document.getElementById("dialogs").addEventListener("change",Ra);document.getElementById("options").addEventListener("input",Ta);document.getElementById("dialogs").addEventListener("input",Ta);function Ra(e){e.target.dataset.stored&&mt(e.target.dataset.stored)}function Ta(e){const t=e.target.id,n=e.target.value;if(t==="manorsInput")return manorsOutput.value=n==1e3?"auto":n;if(t.slice(-5)==="Input"){const i=document.getElementById(t.slice(0,-5)+"Output");i&&(i.value=n)}else if(t.slice(-6)==="Output"){const i=document.getElementById(t.slice(0,-6)+"Input");i&&(i.value=n)}}const It=document.getElementById("optionsContent");It.addEventListener("input",function(e){const t=e.target.id,n=e.target.value;t==="mapWidthInput"||t==="mapHeightInput"?Gi():t==="pointsInput"?_i(+n):t==="culturesSet"?Ha():t==="regionsInput"||t==="regionsOutput"?Ua(n):t==="emblemShape"?ar(n):t==="tooltipSizeInput"||t==="tooltipSizeOutput"?Ka(n):t==="themeHueInput"?or(n):t==="themeColorInput"?kt(themeColorInput.value,transparencyInput.value):t==="transparencyInput"&&kt(themeColorInput.value,n)});It.addEventListener("change",function(e){const t=e.target.id,n=e.target.value;t==="zoomExtentMin"||t==="zoomExtentMax"?ir(n):t==="optionsSeed"?Ji():t==="uiSizeInput"||t==="uiSizeOutput"?Wt(n):t==="shapeRendering"?Da(n):t==="yearInput"?hr():t==="eraInput"?gr():t==="stateLabelsModeInput"&&(options.stateLabelsMode=n)});It.addEventListener("click",function(e){const t=e.target.id;t==="toggleFullscreen"?Wi():t==="optionsMapHistory"?Yi():t==="optionsCopySeed"?Qi():t==="optionsEraRegenerate"?dr():t==="templateInputContainer"?pr():t==="zoomExtentDefault"?Xi():t==="translateExtent"?qi(e.target):t==="speakerTest"?Zi():t==="themeColorRestore"&&nr()});function Gi(){Pa(),localStorage.setItem("mapWidth",mapWidthInput.value),localStorage.setItem("mapHeight",mapHeightInput.value)}function Pa(){svgWidth=Math.min(+mapWidthInput.value,window.innerWidth),svgHeight=Math.min(+mapHeightInput.value,window.innerHeight),svg.attr("width",svgWidth).attr("height",svgHeight);const e=Math.max(+mapWidthInput.value,graphWidth),t=Math.max(+mapHeightInput.value,graphHeight);Zoom.translateExtent([0,0,e,t]),landmass.select("rect").attr("x",0).attr("y",0).attr("width",e).attr("height",t),oceanPattern.select("rect").attr("x",0).attr("y",0).attr("width",e).attr("height",t),oceanLayers.select("rect").attr("x",0).attr("y",0).attr("width",e).attr("height",t),fogging.selectAll("rect").attr("x",0).attr("y",0).attr("width",e).attr("height",t),defs.select("mask#fog > rect").attr("width",e).attr("height",t),texture.select("image").attr("width",e).attr("height",t),fitScaleBar(),window.fitLegendBox&&fitLegendBox()}function ji(){const e=+zoomExtentMin.value,t=+zoomExtentMax.value;graphWidth=+mapWidthInput.value,graphHeight=+mapHeightInput.value,svgWidth=Math.min(graphWidth,window.innerWidth),svgHeight=Math.min(graphHeight,window.innerHeight),svg.attr("width",svgWidth).attr("height",svgHeight),Zoom.translateExtent([0,0,graphWidth,graphHeight]),Zoom.scaleExtent([e,t]),Zoom.scaleTo(svg,e)}function Wi(){mapWidthInput.value!=window.innerWidth||mapHeightInput.value!=window.innerHeight?(mapWidthInput.value=window.innerWidth,mapHeightInput.value=window.innerHeight,localStorage.removeItem("mapHeight"),localStorage.removeItem("mapWidth")):(mapWidthInput.value=graphWidth,mapHeightInput.value=graphHeight),Pa()}function qi(e){const t=!Number(e.dataset.on),n=t?[-graphWidth/2,-graphHeight/2,graphWidth*1.5,graphHeight*1.5]:[0,0,graphWidth,graphHeight];Zoom.translateExtent(n),e.dataset.on=Number(t)}const Vi=setInterval(function(){const e=speechSynthesis.getVoices();if(e.length)clearInterval(Vi);else return;const t=document.getElementById("speakerVoice");e.forEach((n,i)=>{t.options.add(new Option(n.name,i,!1))}),ze("speakerVoice")?t.value=ze("speakerVoice"):t.value=e.findIndex(n=>n.lang==="en-US")},1e3);function Zi(){const e=`${mapName.value}, ${options.year} ${options.era}`,t=new SpeechSynthesisUtterance(e),n=speechSynthesis.getVoices();if(n.length){const i=+document.getElementById("speakerVoice").value;t.voice=n[i]}speechSynthesis.speak(t)}function Ji(){if(optionsSeed.value==seed)return se("The current map already has this seed",!1,"error");Fa()}function Yi(){const e=mapHistory.map((t,n)=>{const i=new Date(t.created).toLocaleTimeString(),r=`<i data-tip="Click to generate a map with this seed" onclick="restoreSeed(${n})" class="icon-history optionsSeedRestore"></i>`;return`<li>Seed: ${t.seed} ${r}. Size: ${t.width}x${t.height}. Template: ${t.template}. Created: ${i}</li>`});alertMessage.innerHTML=`<ol style="margin: 0; padding-left: 1.5em">
${e.join("")}
</ol>`,$("#alert").dialog({resizable:!1,title:"Seed history",position:{my:"center",at:"center",of:"svg"}})}function Xi(){zoomExtentMin.value=1,zoomExtentMax.value=20,Zoom.scaleExtent([1,20]),Zoom.scaleTo(svg,1)}function Qi(){const e=document.querySelectorAll("i.icon-lock").length,t=`?seed=${optionsSeed.value}&width=${graphWidth}&height=${graphHeight}${e?"":"&options=default"}`;navigator.clipboard.writeText(location.host+location.pathname+t).then(()=>{se("Map URL is copied to clipboard",!1,"success",3e3)}).catch(n=>se("Could not copy URL: "+n,!1,"error",5e3))}const $i={1:1e3,2:2e3,3:5e3,4:1e4,5:2e4,6:3e4,7:4e4,8:5e4,9:6e4,10:7e4,11:8e4,12:9e4,13:1e5};function _i(e){const t=$i[e]||1e3;pointsInput.dataset.cells=t,pointsOutputFormatted.value=er(t),pointsOutputFormatted.style.color=tr(t)}function er(e){return e/1e3+"K"}function tr(e){return e>5e4?"#b12117":e!==1e4?"#dfdf12":"#053305"}function Ha(){const e=culturesSet.selectedOptions[0].dataset.max;culturesInput.max=culturesOutput.max=e,+culturesOutput.value>+e&&(culturesInput.value=culturesOutput.value=e)}function ar(e){const t=document.getElementById("emblemShapeImage"),n=window.COArenderer&&COArenderer.shieldPaths[e];n?t.setAttribute("d",n):t.removeAttribute("d");const i=["culture","state","random"].includes(e)?null:e;e==="random"&&pack.cultures.filter(c=>!c.removed).forEach(c=>c.shield=Cultures.getRandomShield());const r=(c,f)=>{const z=document.getElementById(c);!z||(z.remove(),COArenderer.trigger(c,f))};pack.states.forEach(c=>{if(!c.i||c.removed||!c.coa||c.coa==="custom")return;const f=i||COA.getShield(c.culture,null);f!==c.coa.shield&&(c.coa.shield=f,r("stateCOA"+c.i,c.coa))}),pack.provinces.forEach(c=>{if(!c.i||c.removed||!c.coa||c.coa==="custom")return;const f=pack.cells.culture[c.center],z=i||COA.getShield(f,c.state);z!==c.coa.shield&&(c.coa.shield=z,r("provinceCOA"+c.i,c.coa))}),pack.burgs.forEach(c=>{if(!c.i||c.removed||!c.coa||c.coa==="custom")return;const f=i||COA.getShield(c.culture,c.state);f!==c.coa.shield&&(c.coa.shield=f,r("burgCOA"+c.i,c.coa))})}function Ua(e){regionsOutput.style.color=+e?null:"#b12117",burgLabels.select("#capitals").attr("data-size",Math.max(O(6-e/20),3)),labels.select("#countries").attr("data-size",Math.max(O(18-e/6),4))}function Wt(e){if(isNaN(+e)||+e<.5)return;const t=Na();+e>t&&(e=t),uiSizeInput.value=uiSizeOutput.value=e,document.getElementsByTagName("body")[0].style.fontSize=O(e*10,2)+"px",document.getElementById("options").style.width=e*300+"px"}function Na(){return O(Math.min(window.innerHeight/465,window.innerWidth/302),1)}function Ka(e){tooltip.style.fontSize=`calc(${e}px + 0.5vw)`}const qt="#997787";function nr(){localStorage.removeItem("themeColor"),kt(qt,transparencyInput.value)}function or(e){const{s:t,l:n}=d3.hsl(themeColorInput.value),i=d3.hsl(+e,t,n).hex();kt(i,transparencyInput.value)}function kt(e,t){transparencyInput.value=transparencyOutput.value=t;const n=(100-+t)/100,i=Math.min(n+.3,1),{h:r,s:c,l:f}=d3.hsl(e||qt);themeColorInput.value=e||qt,themeHueInput.value=r;const z=(A,u,C,g)=>d3.hsl(A,u,C,g).toString(),m=[{name:"--bg-main",h:r,s:c,l:f,alpha:n},{name:"--bg-lighter",h:r,s:c,l:f+.02,alpha:n},{name:"--bg-light",h:r,s:c-.02,l:f+.06,alpha:n},{name:"--light-solid",h:r,s:c+.01,l:f+.05,alpha:1},{name:"--dark-solid",h:r,s:c,l:f-.2,alpha:1},{name:"--header",h:r,s:c,l:f-.03,alpha:i},{name:"--header-active",h:r,s:c,l:f-.09,alpha:i},{name:"--bg-disabled",h:r,s:c-.04,l:f+.09,alphaReduced:i},{name:"--bg-dialogs",h:0,s:0,l:.98,alpha:n}],b=document.documentElement.style;m.forEach(({name:A,h:u,s:C,l:g,alpha:p})=>{b.setProperty(A,z(u,C,g,p))})}function ir(e){const t=Math.max(+ne("zoomExtentMin").value,.01),n=Math.min(+ne("zoomExtentMax").value,200);Zoom.scaleExtent([t,n]);const i=Ie(+e,.01,200);Zoom.scaleTo(svg,i)}function rr(){var f,z;(!ze("mapWidth")||!ze("mapHeight"))&&(mapWidthInput.value=window.innerWidth,mapHeightInput.value=window.innerHeight);const e=ze("template");if(e){const m=((f=heightmapTemplates[e])==null?void 0:f.name)||((z=precreatedHeightmaps[e])==null?void 0:z.name)||e;ft(ne("templateInput"),e,m)}ze("distanceUnit")&&ft(distanceUnitInput,ze("distanceUnit")),ze("heightUnit")&&ft(heightUnit,ze("heightUnit"));for(let m=0;m<localStorage.length;m++){const b=localStorage.key(m);if(b==="speakerVoice")continue;const A=ne(b+"Input")||ne(b),u=ne(b+"Output"),C=ze(b);A&&(A.value=C),u&&(u.value=C),mt(b),b.slice(0,5)==="style"&&ft(stylePreset,b,b.slice(5))}ze("winds")&&(options.winds=localStorage.getItem("winds").split(",").map(m=>+m)),ze("military")&&(options.military=JSON.parse(ze("military"))),ze("tooltipSize")&&Ka(ze("tooltipSize")),ze("regions")&&Ua(ze("regions")),uiSizeInput.max=uiSizeOutput.max=Na(),ze("uiSize")?Wt(ze("uiSize")):Wt(Ie(O(mapWidthInput.value/1280,1),1,2.5));const t=new URL(window.location.href).searchParams,n=+t.get("width"),i=+t.get("height");n&&(mapWidthInput.value=n),i&&(mapHeightInput.value=i);const r=ze("transparency")||5,c=ze("themeColor");kt(c,r),Da(shapeRendering.value),options.stateLabelsMode=stateLabelsModeInput.value}function sr(){const e=new URL(window.location.href).searchParams.get("options")==="default";(e||!Ne("template"))&&lr(),(e||!Ne("regions"))&&(regionsInput.value=regionsOutput.value=Ce(18,5,2,30)),(e||!Ne("provinces"))&&(provincesInput.value=provincesOutput.value=Ce(20,10,20,100)),(e||!Ne("manors"))&&(manorsInput.value=1e3,manorsOutput.value="auto"),(e||!Ne("religions"))&&(religionsInput.value=religionsOutput.value=Ce(5,2,2,10)),(e||!Ne("power"))&&(powerInput.value=powerOutput.value=Ce(4,2,0,10,2)),(e||!Ne("neutral"))&&(neutralInput.value=neutralOutput.value=O(1+Math.random(),1)),(e||!Ne("cultures"))&&(culturesInput.value=culturesOutput.value=Ce(12,3,5,30)),(e||!Ne("culturesSet"))&&cr(),(e||!Ne("prec"))&&(precInput.value=precOutput.value=Ce(100,40,5,500));const t=30,n=-30;(e||!Ne("temperatureEquator"))&&(temperatureEquatorOutput.value=temperatureEquatorInput.value=be(t-10,t)),(e||!Ne("temperaturePole"))&&(temperaturePoleOutput.value=temperaturePoleInput.value=be(n,n+30));const i=navigator.language==="en-US";(e||!Ne("distanceScale"))&&(distanceScaleOutput.value=distanceScaleInput.value=Ce(3,1,1,5)),ze("distanceUnit")||(distanceUnitInput.value=i?"mi":"km"),ze("heightUnit")||(heightUnit.value=i?"ft":"m"),ze("temperatureScale")||(temperatureScale.value=i?"\xB0F":"\xB0C"),ur()}function lr(){const e={};for(const i in heightmapTemplates)e[i]=heightmapTemplates[i].probability||0;const t=rw(e),n=heightmapTemplates[t].name;ft(ne("templateInput"),t,n)}function cr(){const e={world:10,european:10,oriental:2,english:5,antique:3,highFantasy:11,darkFantasy:3,random:1};culturesSet.value=rw(e),Ha()}function Da(e){var t;(t=fmg.viewbox)==null||t.attr("shape-rendering",e)}function ur(){ze("year")||(yearInput.value=be(100,2e3)),ze("era")||(eraInput.value=Names.getBaseShort(V(.7)?1:be(nameBases.length))+" Era"),options.year=+yearInput.value,options.era=eraInput.value,options.eraShort=options.era.split(" ").map(e=>e[0].toUpperCase()).join("")}function dr(){unlock("era"),options.era=eraInput.value=Names.getBaseShort(V(.7)?1:be(nameBases.length))+" Era",options.eraShort=options.era.split(" ").map(e=>e[0].toUpperCase()).join("")}function hr(){if(!!yearInput.value){if(isNaN(+yearInput.value)){se("Current year should be a number",!1,"error");return}options.year=+yearInput.value}}function gr(){!eraInput.value||(mt("era"),options.era=eraInput.value)}async function pr(){(await St(()=>import("./heightmap-selection.js_v_1.87.b0b46f49.js"),[])).open()}document.getElementById("sticked").addEventListener("click",function(e){const t=e.target.id;t==="newMapButton"?Fa():t==="saveButton"?mr():t==="exportButton"?fr():t==="loadButton"?yr():t==="zoomReset"&&Zoom.reset(1e3)});function Fa(e){if(customization)return se("New map cannot be generated when edit mode is active, please exit the mode and retry",!1,"error");if((Date.now()-De(mapHistory).created)/6e4<5)return regenerateMap(e);alertMessage.innerHTML=`Are you sure you want to generate a new map?<br />
All unsaved changes made to the current map will be lost`,$("#alert").dialog({resizable:!1,title:"Generate new map",buttons:{Cancel:function(){$(this).dialog("close")},Generate:function(){closeDialogs(),regenerateMap(e)}}})}function mr(){const e=document.getElementById("sharableLinkContainer");e.style.display="none",$("#saveMapData").dialog({title:"Save map",resizable:!1,width:"25em",position:{my:"center",at:"center",of:"svg"},buttons:{Close:function(){$(this).dialog("close")}}})}function fr(){document.getElementById("showLabels").checked=!hideLabels.checked,$("#exportMapData").dialog({title:"Export map data",resizable:!1,width:"26em",position:{my:"center",at:"center",of:"svg"},buttons:{Close:function(){$(this).dialog("close")}}})}async function yr(){if($("#loadMapData").dialog({title:"Load map",resizable:!1,width:"24em",position:{my:"center",at:"center",of:"svg"},buttons:{Close:function(){$(this).dialog("close")}}}),Cloud.providers.dropbox.api){document.getElementById("dropboxConnectButton").style.display="none",document.getElementById("loadFromDropboxSelect").style.display="block";const e=document.getElementById("loadFromDropboxButtons"),t=document.getElementById("loadFromDropboxSelect");t.innerHTML='<option value="" disabled selected>Loading...</option>';const n=await Cloud.providers.dropbox.list();if(!n){e.style.display="none",t.innerHTML='<option value="" disabled selected>Save files to Dropbox first</option>';return}e.style.display="block",t.innerHTML="",n.forEach(({name:i,updated:r,size:c,path:f})=>{const z=O(c/1024/1024,2)+" MB",b=`${new Date(r).toLocaleDateString()}: ${i} [${z}]`,A=new Option(b,f);t.options.add(A)});return}document.getElementById("dropboxConnectButton").style.display="inline-block",document.getElementById("loadFromDropboxButtons").style.display="none",document.getElementById("loadFromDropboxSelect").style.display="none"}document.getElementById("mapToLoad").addEventListener("change",function(){const e=this.files[0];this.value="",closeDialogs(),uploadMap(e)});viewMode.addEventListener("click",br);function br(e){const t=e.target;if(t.tagName!=="BUTTON")return;const n=t.classList.contains("pressed");Oa(),!n&&t.id!=="viewStandard"&&(viewStandard.classList.remove("pressed"),t.classList.add("pressed"),vr(t.id))}function Oa(){viewMode.querySelectorAll(".pressed").forEach(e=>e.classList.remove("pressed")),heightmap3DView.classList.remove("pressed"),viewStandard.classList.add("pressed"),document.getElementById("canvas3d")&&(ThreeD.stop(),document.getElementById("canvas3d").remove(),options3dUpdate.offsetParent&&$("#options3d").dialog("close"),preview3d.offsetParent&&$("#preview3d").dialog("close"))}async function vr(e){const t=document.createElement("canvas");t.id="canvas3d",t.dataset.type=e,e==="heightmap3DView"?(t.width=parseFloat(preview3d.style.width)||graphWidth/3,t.height=t.width/(graphWidth/graphHeight),t.style.display="block"):(t.width=svgWidth,t.height=svgHeight,t.style.position="absolute",t.style.display="none"),await ThreeD.create(t,e)&&(t.style.display="block",t.onmouseenter=()=>{const i="Left mouse to change angle, middle mouse / mousewheel to zoom, right mouse to pan. <b>O</b> to toggle options";+t.dataset.hovered>2?se(""):se(i),t.dataset.hovered=(+t.dataset.hovered|0)+1},e==="heightmap3DView"?(document.getElementById("preview3d").appendChild(t),$("#preview3d").dialog({title:"3D Preview",resizable:!0,position:{my:"left bottom",at:"left+10 bottom-20",of:"svg"},resizeStop:kr,close:Oa})):document.body.insertBefore(t,optionsContainer),wr())}function kr(){const e=document.getElementById("canvas3d");e.width=parseFloat(preview3d.style.width),e.height=parseFloat(preview3d.style.height)-2,ThreeD.redraw()}function wr(){if(options3dUpdate.offsetParent){$("#options3d").dialog("close");return}if($("#options3d").dialog({title:"3D mode settings",resizable:!1,width:"fit-content",position:{my:"right top",at:"right-30 top+10",of:"svg",collision:"fit"}}),e(),fmg.modules.options3d)return;fmg.modules.options3d=!0,document.getElementById("options3dUpdate").addEventListener("click",ThreeD.update),document.getElementById("options3dSave").addEventListener("click",ThreeD.saveScreenshot),document.getElementById("options3dOBJSave").addEventListener("click",ThreeD.saveOBJ),document.getElementById("options3dScaleRange").addEventListener("input",t),document.getElementById("options3dScaleNumber").addEventListener("change",t),document.getElementById("options3dLightnessRange").addEventListener("input",n),document.getElementById("options3dLightnessNumber").addEventListener("change",n),document.getElementById("options3dSunX").addEventListener("change",i),document.getElementById("options3dSunY").addEventListener("change",i),document.getElementById("options3dSunZ").addEventListener("change",i),document.getElementById("options3dMeshRotationRange").addEventListener("input",r),document.getElementById("options3dMeshRotationNumber").addEventListener("change",r),document.getElementById("options3dGlobeRotationRange").addEventListener("input",r),document.getElementById("options3dGlobeRotationNumber").addEventListener("change",r),document.getElementById("options3dMeshLabels3d").addEventListener("change",c),document.getElementById("options3dMeshSkyMode").addEventListener("change",f),document.getElementById("options3dMeshSky").addEventListener("input",z),document.getElementById("options3dMeshWater").addEventListener("input",z),document.getElementById("options3dGlobeResolution").addEventListener("change",m);function e(){const b=document.getElementById("canvas3d").dataset.type==="viewGlobe";options3dMesh.style.display=b?"none":"block",options3dGlobe.style.display=b?"block":"none",options3dScaleRange.value=options3dScaleNumber.value=ThreeD.options.scale,options3dLightnessRange.value=options3dLightnessNumber.value=ThreeD.options.lightness*100,options3dSunX.value=ThreeD.options.sun.x,options3dSunY.value=ThreeD.options.sun.y,options3dSunZ.value=ThreeD.options.sun.z,options3dMeshRotationRange.value=options3dMeshRotationNumber.value=ThreeD.options.rotateMesh,options3dGlobeRotationRange.value=options3dGlobeRotationNumber.value=ThreeD.options.rotateGlobe,options3dMeshLabels3d.value=ThreeD.options.labels3d,options3dMeshSkyMode.value=ThreeD.options.extendedWater,options3dColorSection.style.display=ThreeD.options.extendedWater?"block":"none",options3dMeshSky.value=ThreeD.options.skyColor,options3dMeshWater.value=ThreeD.options.waterColor,options3dGlobeResolution.value=ThreeD.options.resolution}function t(){options3dScaleRange.value=options3dScaleNumber.value=this.value,ThreeD.setScale(+this.value)}function n(){options3dLightnessRange.value=options3dLightnessNumber.value=this.value,ThreeD.setLightness(this.value/100)}function i(){const b=+options3dSunX.value,A=+options3dSunY.value,u=+options3dSunZ.value;ThreeD.setSun(b,A,u)}function r(){(this.nextElementSibling||this.previousElementSibling).value=this.value;const b=+this.value;ThreeD.setRotation(b)}function c(){ThreeD.toggleLabels()}function f(){const b=ThreeD.options.extendedWater;options3dColorSection.style.display=b?"none":"block",ThreeD.toggleSky()}function z(){ThreeD.setColors(options3dMeshSky.value,options3dMeshWater.value)}function m(){ThreeD.setResolution(this.value)}}function Sr(){const e=Yt(this.getAttribute("transform")),t=+e[0]-d3.event.x,n=+e[1]-d3.event.y,i=legend.node().getBBox();d3.event.on("drag",function(){const r=O((t+d3.event.x+i.width)/svgWidth*100,2),c=O((n+d3.event.y+i.height)/svgHeight*100,2),f=`translate(${t+d3.event.x},${n+d3.event.y})`;legend.attr("transform",f).attr("data-x",r).attr("data-y",c)})}function Ar(){legend.selectAll("*").remove(),legend.attr("data",null)}class Ga{constructor(){this.data=[]}create(t,n){const i=new t(n);return this.data.push(i),i}toString(){return this.data.map(t=>t.toString()).join("; ")}fromString(t){this.data=[];const n={Ruler:ja,Opisometer:zr,RouteOpisometer:xr,Planimeter:Cr},i=t.split("; ");for(const r of i){const[c,f]=r.split(": ");if(!c||!f)continue;const z=f.split(" ").map(m=>m.split(",").map(b=>+b));this.create(n[c],z)}}draw(){this.data.forEach(t=>t.draw())}undraw(){this.data.forEach(t=>t.undraw())}remove(t){if(t===void 0)return;const n=this.data.find(r=>r.id===t);n.undraw();const i=this.data.indexOf(n);rulers.data.splice(i,1)}}class Rt{constructor(t){this.points=t,this.id=rulers.data.length}toString(){return this.constructor.name+": "+this.points.join(" ")}getSize(){return O(1/scale**.3*2,2)}getDash(){return O(30/distanceScaleInput.value,2)}drag(){const t=Yt(this.getAttribute("transform")),n=+t[0]-d3.event.x,i=+t[1]-d3.event.y;d3.event.on("drag",function(){const r=`translate(${n+d3.event.x},${i+d3.event.y})`;this.setAttribute("transform",r)})}addPoint(t){const n=d3.event.sourceEvent.shiftKey?9:100,i=De(this.points);t=[t[0]|0,t[1]|0],!((i[0]-t[0])**2+(i[1]-t[1])**2<n)&&(this.points.push(t),this.updateCurve(),this.updateLabel())}optimize(){const n=[];for(let i=0,r=this.points[0];i<this.points.length;i++){const c=this.points[i];(!i||i===this.points.length-1?1/0:(c[0]-r[0])**2+(c[1]-r[1])**2)<900||(n.push(c),r=c)}this.points=n,this.updateCurve(),this.updateLabel()}undraw(){var t;(t=this.el)==null||t.remove()}}class ja extends Rt{constructor(t){super(t)}getPointsString(){return this.points.join(" ")}updatePoint(t,n,i){this.points[t]=[n,i]}getPointId(t,n){return this.points.findIndex(i=>i[0]==t&&i[1]==n)}pushPoint(t){const[n,i]=this.points[t];t?this.points.push([n,i]):this.points.unshift([n,i])}draw(){this.el&&this.el.selectAll("*").remove();const t=this.getPointsString(),n=this.getSize(),i=this.getDash(),r=this.el=ruler.append("g").attr("class","ruler").call(d3.drag().on("start",this.drag)).attr("font-size",10*n);return r.append("polyline").attr("points",t).attr("class","white").attr("stroke-width",n).call(d3.drag().on("start",()=>this.addControl(this))),r.append("polyline").attr("points",t).attr("class","gray").attr("stroke-width",O(n*1.2,2)).attr("stroke-dasharray",i),r.append("g").attr("class","rulerPoints").attr("stroke-width",.5*n).attr("font-size",2*n),r.append("text").attr("dx",".35em").attr("dy","-.45em").on("click",()=>rulers.remove(this.id)),this.drawPoints(r),this.updateLabel(),this}drawPoints(t){const n=t.select(".rulerPoints");n.selectAll("circle").remove();for(let i=0;i<this.points.length;i++){const[r,c]=this.points[i];this.drawPoint(n,r,c,i)}}drawPoint(t,n,i,r){const c=this;t.append("circle").attr("r","1em").attr("cx",n).attr("cy",i).attr("class",this.isEdge(r)?"edge":"control").on("click",function(){c.removePoint(c,r)}).call(d3.drag().clickDistance(3).on("start",function(){c.dragControl(c,r)}))}isEdge(t){return t===0||t===this.points.length-1}updateLabel(){const t=this.getLength(),n=O(t*distanceScaleInput.value)+" "+distanceUnitInput.value,[i,r]=De(this.points);this.el.select("text").attr("x",i).attr("y",r).text(n)}getLength(){let t=0;for(let n=0;n<this.points.length-1;n++){const[i,r]=this.points[n],[c,f]=this.points[n+1];t+=Math.hypot(i-c,r-f)}return t}dragControl(t,n){let i=t.isEdge(n)&&d3.event.sourceEvent.ctrlKey,r=t.el.select(`circle:nth-child(${n+1})`);const c=t.el.selectAll("polyline");let f=O(d3.event.x,1),z=O(d3.event.y,1),m;d3.event.on("drag",function(){if(i){if(d3.event.dx<.1&&d3.event.dy<.1)return;t.pushPoint(n),t.drawPoints(t.el),n&&n++,r=t.el.select(`circle:nth-child(${n+1})`),i=!1}const b=d3.event.sourceEvent.shiftKey;b&&!m&&(m=Math.abs(d3.event.dx)>Math.abs(d3.event.dy)?"x":"y");const A=m==="y"?f:O(d3.event.x,1),u=m==="x"?z:O(d3.event.y,1);b||(m=null,f=A,z=u),t.updatePoint(n,A,u),c.attr("points",t.getPointsString()),r.attr("cx",A).attr("cy",u),t.updateLabel()})}addControl(t){const n=O(d3.event.x,1),i=O(d3.event.y,1),r=In(t.points,[n,i]);t.points.splice(r,0,[n,i]),t.drawPoints(t.el),t.dragControl(t,r)}removePoint(t,n){this.points.length<3||(this.points.splice(n,1),t.draw())}}class zr extends Rt{constructor(t){super(t)}draw(){this.el&&this.el.selectAll("*").remove();const t=this.getSize(),n=this.getDash(),i=this,r=this.el=ruler.append("g").attr("class","opisometer").call(d3.drag().on("start",this.drag)).attr("font-size",10*t);r.append("path").attr("class","white").attr("stroke-width",t),r.append("path").attr("class","gray").attr("stroke-width",t).attr("stroke-dasharray",n);const c=r.append("g").attr("class","rulerPoints").attr("stroke-width",.5*t).attr("font-size",2*t);return c.append("circle").attr("r","1em").call(d3.drag().on("start",function(){i.dragControl(i,0)})),c.append("circle").attr("r","1em").call(d3.drag().on("start",function(){i.dragControl(i,1)})),r.append("text").attr("dx",".35em").attr("dy","-.45em").on("click",()=>rulers.remove(this.id)),this.updateCurve(),this.updateLabel(),this}updateCurve(){lineGen.curve(d3.curveCatmullRom.alpha(.5));const t=it(lineGen(this.points));this.el.selectAll("path").attr("d",t);const n=this.points[0],i=De(this.points);this.el.select(".rulerPoints > circle:first-child").attr("cx",n[0]).attr("cy",n[1]),this.el.select(".rulerPoints > circle:last-child").attr("cx",i[0]).attr("cy",i[1])}updateLabel(){const t=this.el.select("path").node().getTotalLength(),n=O(t*distanceScaleInput.value)+" "+distanceUnitInput.value,[i,r]=De(this.points);this.el.select("text").attr("x",i).attr("y",r).text(n)}dragControl(t,n){const i=d3.event.sourceEvent.shiftKey?9:100;let r=n?De(t.points):t.points[0];d3.event.on("drag",function(){const c=[d3.event.x|0,d3.event.y|0];(r[0]-c[0])**2+(r[1]-c[1])**2<i||(n?t.points.push(c):t.points.unshift(c),r=c,t.updateCurve(),t.updateLabel())}),d3.event.on("end",function(){d3.event.sourceEvent.shiftKey||t.optimize()})}}class xr extends Rt{constructor(t){super(t),pack.cells?this.cellStops=t.map(n=>Te(n[0],n[1])):this.cellStops=null}checkCellStops(){this.cellStops||(this.cellStops=this.points.map(t=>Te(t[0],t[1])))}trackCell(t,n){this.checkCellStops();const i=this.cellStops,r=i.indexOf(t);if(n){if(De(i)===t)return;i.length>1&&r!=-1?(i.splice(r+1),this.points.splice(r+1)):(i.push(t),this.points.push(this.getCellRouteCoord(t)))}else{if(i[0]===t)return;i.length>1&&r!=-1?(i.splice(0,r),this.points.splice(0,r)):(i.unshift(t),this.points.unshift(this.getCellRouteCoord(t)))}this.updateCurve(),this.updateLabel()}getCellRouteCoord(t){const n=pack.cells,i=pack.burgs,r=n.burg[t],c=r?i[r].x:n.p[t][0],f=r?i[r].y:n.p[t][1];return[c,f]}draw(){this.el&&this.el.selectAll("*").remove();const t=this.getSize(),n=this.getDash(),i=this,r=this.el=ruler.append("g").attr("class","opisometer").attr("font-size",10*t);r.append("path").attr("class","white").attr("stroke-width",t),r.append("path").attr("class","gray").attr("stroke-width",t).attr("stroke-dasharray",n);const c=r.append("g").attr("class","rulerPoints").attr("stroke-width",.5*t).attr("font-size",2*t);return c.append("circle").attr("r","1em").call(d3.drag().on("start",function(){i.dragControl(i,0)})),c.append("circle").attr("r","1em").call(d3.drag().on("start",function(){i.dragControl(i,1)})),r.append("text").attr("dx",".35em").attr("dy","-.45em").on("click",()=>rulers.remove(this.id)),this.updateCurve(),this.updateLabel(),this}updateCurve(){lineGen.curve(d3.curveCatmullRom.alpha(.5));const t=it(lineGen(this.points));this.el.selectAll("path").attr("d",t);const n=this.points[0],i=De(this.points);this.el.select(".rulerPoints > circle:first-child").attr("cx",n[0]).attr("cy",n[1]),this.el.select(".rulerPoints > circle:last-child").attr("cx",i[0]).attr("cy",i[1])}updateLabel(){const t=this.el.select("path").node().getTotalLength(),n=O(t*distanceScaleInput.value)+" "+distanceUnitInput.value,[i,r]=De(this.points);this.el.select("text").attr("x",i).attr("y",r).text(n)}dragControl(t,n){d3.event.on("drag",function(){const i=[d3.event.x|0,d3.event.y|0],r=pack.cells,c=Te(i[0],i[1]);!r.road[c]&&!d3.event.sourceEvent.shiftKey||t.trackCell(c,n)})}}class Cr extends Rt{constructor(t){super(t)}draw(){this.el&&this.el.selectAll("*").remove();const t=this.getSize(),n=this.el=ruler.append("g").attr("class","planimeter").call(d3.drag().on("start",this.drag)).attr("font-size",10*t);return n.append("path").attr("class","planimeter").attr("stroke-width",t),n.append("text").on("click",()=>rulers.remove(this.id)),this.updateCurve(),this.updateLabel(),this}updateCurve(){lineGen.curve(d3.curveCatmullRomClosed.alpha(.5));const t=it(lineGen(this.points));this.el.selectAll("path").attr("d",t)}updateLabel(){if(this.points.length<3)return;const t=O(Math.abs(d3.polygonArea(this.points))),n=Qt(getArea(t))+" "+getAreaUnit(),i=polylabel([this.points],1);this.el.select("text").attr("x",i[0]).attr("y",i[1]).text(n)}}function Br(e){if(scaleBar.style("display")==="none")return;scaleBar.selectAll("*").remove();const t=+distanceScaleInput.value,n=distanceUnitInput.value,i=+barSizeInput.value;let c=100*i*t/e;c>900?c=O(c,-3):c>90?c=O(c,-2):c>9?c=O(c,-1):c=O(c);const f=c*e/t;scaleBar.append("line").attr("x1",.5).attr("y1",0).attr("x2",f+i-.5).attr("y2",0).attr("stroke-width",i).attr("stroke","white"),scaleBar.append("line").attr("x1",0).attr("y1",i).attr("x2",f+i).attr("y2",i).attr("stroke-width",i).attr("stroke","#3d3d3d");const z=i+" "+O(f/5-i,2);scaleBar.append("line").attr("x1",0).attr("y1",0).attr("x2",f+i).attr("y2",0).attr("stroke-width",O(i*3,2)).attr("stroke-dasharray",z).attr("stroke","#3d3d3d");const m=O(5*i,1);scaleBar.selectAll("text").data(d3.range(0,6)).enter().append("text").attr("x",A=>O(A*f/5,2)).attr("y",0).attr("dy","-.5em").attr("font-size",m).text(A=>O(A*f/5*t/e)+(A<5?"":" "+n)),barLabel.value!==""&&scaleBar.append("text").attr("x",(f+1)/2).attr("y",2*i).attr("dominant-baseline","text-before-edge").attr("font-size",m).text(barLabel.value);const b=scaleBar.node().getBBox();scaleBar.insert("rect",":first-child").attr("x",-10).attr("y",-20).attr("width",b.width+10).attr("height",b.height+15).attr("stroke-width",i).attr("stroke","none").attr("filter","url(#blur5)").attr("fill",barBackColor.value).attr("opacity",+barBackOpacity.value),Mr()}function Mr(){if(!scaleBar.select("rect").size()||scaleBar.style("display")==="none")return;const e=isNaN(+barPosX.value)?.99:barPosX.value/100,t=isNaN(+barPosY.value)?.99:barPosY.value/100,n=scaleBar.select("rect").node().getBBox(),i=O(svgWidth*e-n.width+10),r=O(svgHeight*t-n.height+20);scaleBar.attr("transform",`translate(${i},${r})`)}const _t=["default","ancient","gloom","light","watercolor","clean","atlas","cyberpunk","monochrome"],ca="fmgStyle_";{const e=_t.map(r=>`<option value="${r}">${r}</option>`),n=Object.keys(localStorage).filter(r=>r.startsWith(ca)).map(r=>`<option value="${r}">${r.replace(ca,"")} [custom]</option>`),i=e.join("")+n.join("");document.getElementById("stylePreset").innerHTML=i}async function Er(){const e=localStorage.getItem("presetStyle")||"default",t=await Lr(e),[n,i]=t;Rr(i),Tr(),stylePreset.value=stylePreset.dataset.old=n,Pr()}async function Lr(e){let t=e;if(!_t.includes(e)){const r=localStorage.getItem(e);if(!r)ERROR&&console.error(`Custom style ${e} in not found in localStorage. Applying default style`),t="default";else{if(Rn(r))return[e,JSON.parse(r)];ERROR&&console.error(`Custom style ${e} stored in localStorage is not valid. Applying default style`),t="default"}}const i=await Ir(t);return[t,i]}async function Ir(e){const t=await fetch(`./styles/${e}.json`).then(n=>n.json()).catch(n=>(ERROR&&console.error("Error on loading style preset",e,n),null));if(!t)throw new Error("Cannot fetch style preset",e);return t}function Rr(e){for(const t in e){const n=document.querySelector(t);if(!!n)for(const i in e[t]){const r=e[t][i];if(r==="null"||r===null){n.removeAttribute(i);continue}i==="text-shadow"?n.style[i]=r:n.setAttribute(i,r)}}}function Tr(){const e=svg.attr("data-filter");mapFilters.querySelectorAll(".pressed").forEach(t=>t.classList.remove("pressed")),e&&mapFilters.querySelector("#"+e).classList.add("pressed")}function Pr(){const e=_t.includes(stylePreset.value);removeStyleButton.style.display=e?"none":"inline-block"}function Wa(){Zoom.setZoomBehavior(),viewbox.style("cursor","default").on(".drag",null).on("click",Hr).on("touchmove mousemove",Ur),legend.call(d3.drag().on("start",Sr))}function Hr(){const e=d3.event.target;if(!e||!e.parentElement||!e.parentElement.parentElement)return;const t=e.parentElement,n=t.parentElement,i=n.parentElement,r=d3.mouse(this),c=Te(r[0],r[1]);if(n.id==="emblems")editEmblem();else if(t.id==="rivers")editRiver(e.id);else if(n.id==="routes")editRoute();else if(e.tagName==="tspan"&&n.parentNode.parentNode.id==="labels")editLabel();else if(n.id==="burgLabels")editBurg();else if(n.id==="burgIcons")editBurg();else if(t.id==="ice")editIce();else if(t.id==="terrain")editReliefIcon();else if(n.id==="markers"||i.id==="markers")editMarker();else if(n.id==="coastline")editCoastline();else if(i.id==="armies")editRegiment();else if(pack.cells.t[c]===1){const f=byId("island_"+pack.cells.f[c]);editCoastline(f)}else n.id==="lakes"&&editLake()}const Ur=vt(Nr,100);function Nr(){const e=d3.mouse(this),t=Te(e[0],e[1]);if(t===void 0)return;Kr(d3.event);const n=Xe(e[0],e[1],grid);tooltip.dataset.main?Pn():Dr(e,d3.event,t,n),cellInfo!=null&&cellInfo.offsetParent&&updateCellInfo(e,t,n)}function Kr(e){if(notesEditor!=null&&notesEditor.offsetParent)return;let t=e.target.id||e.target.parentNode.id||e.target.parentNode.parentNode.id;(e.target.parentNode.parentNode.id==="burgLabels"||e.target.parentNode.parentNode.id==="burgIcons")&&(t="burg"+e.target.dataset.id);const n=notes.find(i=>i.id===t);n!==void 0&&n.legend!==""?(document.getElementById("notes").style.display="block",document.getElementById("notesHeader").innerHTML=n.name,document.getElementById("notesBody").innerHTML=n.legend):!options.pinNotes&&!(markerEditor!=null&&markerEditor.offsetParent)&&(document.getElementById("notes").style.display="none",document.getElementById("notesHeader").innerHTML="",document.getElementById("notesBody").innerHTML="")}function Dr(e,t,n,i){var m,b,A,u,C,g;se("");const r=t.composedPath();if(!r[r.length-8])return;const c=r[r.length-7].id,f=r[r.length-8].id,z=pack.cells.h[n]>=20;if(c==="armies")return se(t.target.parentNode.dataset.name+". Click to edit");if(c==="emblems"&&t.target.tagName==="use"){const p=t.target.parentNode,[B,k]=p.id==="burgEmblems"?[pack.burgs,"burg"]:p.id==="provinceEmblems"?[pack.provinces,"province"]:[pack.states,"state"],d=+t.target.dataset.i;t.shiftKey&&highlightEmblemElement(k,B[d]),d3.select(t.target).raise(),d3.select(p).raise();const s=B[d].fullName||B[d].name;se(`${s} ${k} emblem. Click to edit. Hold Shift to show associated area or place`);return}if(c==="rivers"){const p=+t.target.id.slice(5),B=pack.rivers.find(d=>d.i===p),k=B?B.name+" "+B.type:"";se(k+". Click to edit"),riversOverview!=null&&riversOverview.offsetParent&&highlightEditorLine(riversOverview,p,5e3);return}if(c==="routes")return se("Click to edit the Route");if(c==="terrain")return se("Click to edit the Relief Icon");if(f==="burgLabels"||f==="burgIcons"){const p=+r[r.length-10].dataset.id,B=pack.burgs[p],k=Qt(B.population*populationRate*urbanization);se(`${B.name}. Population: ${k}. Click to edit`),burgsOverview!=null&&burgsOverview.offsetParent&&highlightEditorLine(burgsOverview,p,5e3);return}if(c==="labels")return se("Click to edit the Label");if(c==="markers")return se("Click to edit the Marker and pin the marker note");if(c==="ruler"){const p=t.target.tagName,B=t.target.getAttribute("class");if(p==="circle"&&B==="edge")return se("Drag to adjust. Hold Ctrl and drag to add a point. Click to remove the point");if(p==="circle"&&B==="control")return se("Drag to adjust. Hold Shift and drag to keep axial direction. Click to remove the point");if(p==="circle")return se("Drag to adjust the measurer");if(p==="polyline")return se("Click on drag to add a control point");if(p==="path")return se("Drag to move the measurer");if(p==="text")return se("Drag to move, click to remove the measurer")}if(f==="burgIcons"||f==="burgLabels")return se("Click to edit the Burg");if(c==="lakes"&&!z){const p=+t.target.dataset.f,B=(m=pack.features[p])==null?void 0:m.name,k=f==="freshwater"?B:B+" "+f;se(`${k} lake. Click to edit`);return}if(c==="coastline")return se("Click to edit the coastline");if(c==="zones"){const p=r[r.length-8];se(p.dataset.description),zonesEditor!=null&&zonesEditor.offsetParent&&highlightEditorLine(zonesEditor,p.id,5e3);return}if(c==="ice")return se("Click to edit the Ice");if(layerIsOn("togglePrec")&&z)se("Annual Precipitation: "+getFriendlyPrecipitation(n));else if(layerIsOn("togglePopulation"))se(getPopulationTip(n));else if(layerIsOn("toggleTemp"))se("Temperature: "+Xt(grid.cells.temp[i]));else if(layerIsOn("toggleBiomes")&&pack.cells.biome[n]){const p=pack.cells.biome[n];se("Biome: "+biomesData.name[p]),biomesEditor!=null&&biomesEditor.offsetParent&&highlightEditorLine(biomesEditor,p)}else if(layerIsOn("toggleReligions")&&pack.cells.religion[n]){const p=pack.cells.religion[n],B=pack.religions[p],k=B.type==="Cult"||B.type=="Heresy"?B.type:B.type+" religion";se(k+": "+B.name),religionsEditor!=null&&religionsEditor.offsetParent&&highlightEditorLine(religionsEditor,p)}else if(pack.cells.state[n]&&(layerIsOn("toggleProvinces")||layerIsOn("toggleStates"))){const p=pack.cells.state[n],B=pack.states[p].fullName,k=pack.cells.province[n],d=k?pack.provinces[k].fullName+", ":"";se(d+B),(b=document.getElementById("statesEditor"))!=null&&b.offsetParent&&highlightEditorLine(statesEditor,p),(A=document.getElementById("diplomacyEditor"))!=null&&A.offsetParent&&highlightEditorLine(diplomacyEditor,p),(u=document.getElementById("militaryOverview"))!=null&&u.offsetParent&&highlightEditorLine(militaryOverview,p),(C=document.getElementById("provincesEditor"))!=null&&C.offsetParent&&highlightEditorLine(provincesEditor,k)}else if(layerIsOn("toggleCultures")&&pack.cells.culture[n]){const p=pack.cells.culture[n];se("Culture: "+pack.cultures[p].name),(g=document.getElementById("culturesEditor"))!=null&&g.offsetParent&&highlightEditorLine(culturesEditor,p)}else layerIsOn("toggleHeight")&&se("Height: "+getFriendlyHeight(e))}function Fr(){zt&&Or(),zt&&Gr(),Un(),Hn()}function Or(){"serviceWorker"in navigator&&window.addEventListener("load",()=>{navigator.serviceWorker.register("../../sw.js").catch(e=>{console.error("ServiceWorker registration failed: ",e)})})}function Gr(){window.addEventListener("beforeinstallprompt",async e=>{e.preventDefault(),(await St(()=>import("./installation.aec0617b.js"),[])).init(e)},{once:!0})}function qa(e){const t=e.toString()+" "+e.stack,n=/(\b(https?|ftp|file):\/\/[-A-Z0-9+&@#\/%?=~_|!:,.;]*[-A-Z0-9+&@#\/%=~_|])/gi;return t.replace(n,c=>"<i>"+c.split("/").at(-1)+"</i>").replace(/at /gi,"<br>&nbsp;&nbsp;at ")}const Va=document.createElement("template");Va.innerHTML=`
<style>
fill-box:not([disabled]) {
cursor: pointer;
}
fill-box > svg {
vertical-align: middle;
pointer-events: none;
}
fill-box > svg > rect {
stroke: #666666;
stroke-width: 2;
}
</style>
<svg>
<rect x="0" y="0" width="100%" height="100%">
</svg>
`;class jr extends HTMLElement{constructor(){super();oa(this,"tooltip");this.tooltip=this.dataset.tip||"Fill style. Click to change"}showTip(){se(this.tooltip)}connectedCallback(){var n,i,r;this.appendChild(Va.content.cloneNode(!0)),(n=this.querySelector("rect"))==null||n.setAttribute("fill",this.fill),(i=this.querySelector("svg"))==null||i.setAttribute("width",this.size),(r=this.querySelector("svg"))==null||r.setAttribute("height",this.size),this.addEventListener("mousemove",this.showTip)}disconnectedCallback(){this.removeEventListener("mousemove",this.showTip)}get fill(){return this.getAttribute("fill")||"#333"}set fill(n){var i;this.setAttribute("fill",n),(i=this.querySelector("rect"))==null||i.setAttribute("fill",n)}get size(){return this.getAttribute("size")||"1em"}}customElements.define("fill-box",jr);console.log("Hello World");Fr();const Ae=window.d3;window.fmg={modules:{}};options={pinNotes:!1,showMFCGMap:!0,winds:[225,45,225,315,135,315],stateLabelsMode:"auto"};populationRate=+ne("populationRateInput").value;distanceScale=+ne("distanceScaleInput").value;urbanization=+ne("urbanizationInput").value;urbanDensity=+ne("urbanDensityInput").value;statesNeutral=1;rr();rulers=new Ga;biomesData=Biomes.getDefault();nameBases=Names.getNameBases();graphWidth=+ne("mapWidthInput").value;graphHeight=+ne("mapHeightInput").value;svgWidth=graphWidth;svgHeight=graphHeight;defineSvg(graphWidth,graphHeight);scaleBar.on("mousemove",()=>se("Click to open Units Editor")).on("click",()=>editUnits());legend.on("mousemove",()=>se("Drag to change the position. Click to hide the legend")).on("click",()=>Ar());document.on("DOMContentLoaded",async()=>{if(location.hostname)Za(),await qr();else{const e="https://github.com/Azgaar/Fantasy-Map-Generator/wiki/Run-FMG-locally";alertMessage.innerHTML=`Fantasy Map Generator cannot run serverless. Follow the <a href="${e}" target="_blank">instructions</a> on how you can
easily run a local web-server`,$("#alert").dialog({resizable:!1,title:"Loading error",width:"28em",position:{my:"center center-4em",at:"center",of:"svg"},buttons:{OK:function(){$(this).dialog("close")}}})}Wa()});function Za(){Ae.select("#loading").transition().duration(3e3).style("opacity",0),Ae.select("#optionsContainer").transition().duration(2e3).style("opacity",1),Ae.select("#tooltip").transition().duration(3e3).style("opacity",1)}function Wr(){Ae.select("#loading").transition().duration(200).style("opacity",1),Ae.select("#optionsContainer").transition().duration(100).style("opacity",0),Ae.select("#tooltip").transition().duration(200).style("opacity",0)}async function qr(){const t=new URL(window.location.href).searchParams;if(t.get("maplink")){console.warn("Load map from URL");const i=t.get("maplink");if(/(ftp|http|https):\/\/(\w+:{0,1}\w*@)?(\S+)(:[0-9]+)?(\/|\/([\w#!:.?+=&%@!\-\/]))?/.test(i)){setTimeout(()=>{loadMapFromURL(i,1)},1e3);return}else showUploadErrorMessage("Map link is not a valid URL",i)}if(t.get("seed")){console.warn("Generate map for seed"),await Kt();return}const n=()=>new Promise((i,r)=>{ldb.get("lastMap",c=>{if(c){console.warn("Load last saved map");try{uploadMap(c),i()}catch(f){r(f)}}else r("No map stored")})});if(onloadMap.value==="saved")try{await n()}catch(i){console.error(i),console.warn("Cannot load stored map, random map to be generated"),await Kt()}else console.warn("Generate random map"),await Kt()}async function Kt(){await Er(),await Ja(),Vr(),ao()}function Vr(){const t=new URL(window.location.href).searchParams;if(t.get("from")==="MFCG"&&document.referrer)if(t.get("seed").length===13){const f=t.get("seed").slice(-4);t.set("burg",f)}else{Zr(t);return}const i=t.get("scale"),r=t.get("cell"),c=t.get("burg");if(i||r||c){const f=+i||8;if(r){const b=+t.get("cell"),[A,u]=pack.cells.p[b];Zoom.to(A,u,f,1600);return}if(c){const b=isNaN(+c)?pack.burgs.find(C=>C.name===c):pack.burgs[+c];if(!b)return;const{x:A,y:u}=b;Zoom.to(A,u,f,1600);return}const z=+t.get("x")||graphWidth/2,m=+t.get("y")||graphHeight/2;Zoom.to(z,m,f,1600)}}function Zr(e){const{cells:t,burgs:n}=pack;if(pack.burgs.length<2){console.error("Cannot select a burg for MFCG");return}const i=+e.get("size"),r=+e.get("coast"),c=+e.get("port"),f=+e.get("river");let z=m(r,c,f);z.length||(z=m(r,!c,!f)),z.length||(z=m(!r,0,!f)),z.length||(z=[n[1]]);function m(p,B,k){return B&&k?n.filter(d=>d.port&&t.r[d.cell]):!B&&p&&k?n.filter(d=>!d.port&&t.t[d.cell]===1&&t.r[d.cell]):!p&&!k?n.filter(d=>t.t[d.cell]!==1&&!t.r[d.cell]):!p&&k?n.filter(d=>t.t[d.cell]!==1&&t.r[d.cell]):p&&k?n.filter(d=>t.t[d.cell]===1&&t.r[d.cell]):[]}const b=Ae.scan(z,(p,B)=>Math.abs(p.population-i)-Math.abs(B.population-i)),A=z[b].i;if(!A){console.error("Cannot select a burg for MFCG");return}const u=n[A],C=new URL(document.referrer);for(let p of C.searchParams)p[0]==="name"?u.name=p[1]:p[0]==="size"?u.population=+p[1]:p[0]==="seed"?u.MFCG=+p[1]:p[0]==="shantytown"?u.shanty=+p[1]:u[p[0]]=+p[1];e.get("name")&&e.get("name")!="null"&&(u.name=e.get("name"));const g=burgLabels.select("[data-id='"+A+"']");g.size()&&g.text(u.name).classed("drag",!0).on("mouseover",function(){Ae.select(this).classed("drag",!1),g.on("mouseover",null)}),Zoom.to(u.x,u.y,8,1600),wt(),se("Here stands the glorious city of "+u.name,!0,"success",15e3)}(function(){document.addEventListener("dragover",function(t){t.stopPropagation(),t.preventDefault(),ne("mapOverlay").style.display=null}),document.addEventListener("dragleave",function(t){ne("mapOverlay").style.display="none"}),document.addEventListener("drop",function(t){t.stopPropagation(),t.preventDefault();const n=ne("mapOverlay");if(n.style.display="none",t.dataTransfer.items==null||t.dataTransfer.items.length!==1)return;const i=t.dataTransfer.items[0].getAsFile();if(i.name.indexOf(".map")==-1){alertMessage.innerHTML="Please upload a <b>.map</b> file you have previously downloaded",$("#alert").dialog({resizable:!1,title:"Invalid file format",position:{my:"center",at:"center",of:"svg"},buttons:{Close:function(){$(this).dialog("close")}}});return}n.style.display=null,n.innerHTML="Uploading<span>.</span><span>.</span><span>.</span>",closeDialogs&&closeDialogs(),uploadMap(i,()=>{n.style.display="none",n.innerHTML="Drop a .map file to open"})})})();async function Ja(e){try{const t=performance.now(),{seed:n,graph:i}=e||{};wt(),Jr(n),Ft&&console.group("Generated Map "+seed),ji(),sr(),fn(grid)?grid=i||yn():delete grid.cells.h,grid.cells.h=await HeightmapGenerator.generate(grid),Yr(),Xr(),Qr(),$r(),OceanLayers(),_r(),window.mapCoordinates=es(),ts(),as(),ns(),os(),Rivers.generate(),Ca(),Lakes.defineGroup(),ss(),cs(),Cultures.generate(),Cultures.expand(),BurgsAndStates.generate(),Religions.generate(),BurgsAndStates.defineStateForms(),BurgsAndStates.generateProvinces(),BurgsAndStates.defineBurgFeatures(),Aa(),za(),BurgsAndStates.drawStateLabels(),Rivers.specify(),Lakes.generateName(),Military.generate(),Markers.generate(),us(),Br(scale),Names.getMapName(),dn&&console.warn(`TOTAL: ${O((performance.now()-t)/1e3,2)}s`),ds(),Ft&&console.groupEnd("Generated Map "+seed)}catch(t){console.error(t);const n=qa(t);ct(),alertMessage.innerHTML=`An error has occurred on map generation. Please retry. <br />If error is critical, clear the stored data and try again.
<p id="errorBox">${n}</p>`,$("#alert").dialog({resizable:!1,title:"Generation error",width:"32em",buttons:{"Clear data":function(){localStorage.clear(),localStorage.setItem("version",version)},Regenerate:function(){hs("generation error"),$(this).dialog("close")},Ignore:function(){$(this).dialog("close")}},position:{my:"center",at:"center",of:"svg"}})}}function Jr(e){if(e)seed=e;else{const t=!mapHistory[0],n=new URL(window.location.href),i=n.searchParams,r=n.searchParams.get("seed");t&&i.get("from")==="MFCG"&&r.length===13?seed=r.slice(0,-4):t&&r?seed=r:optionsSeed.value&&optionsSeed.value!=seed?seed=optionsSeed.value:seed=Jt()}ne("optionsSeed").value=seed,Math.random=aleaPRNG(seed)}function Yr(){Q&&console.time("markFeatures"),Math.random=aleaPRNG(seed);const e=grid.cells,t=grid.cells.h;e.f=new Uint16Array(e.i.length),e.t=new Int8Array(e.i.length),grid.features=[0];for(let n=1,i=[0];i[0]!==-1;n++){e.f[i[0]]=n;const r=t[i[0]]>=20;let c=!1;for(;i.length;){const z=i.pop();e.b[z]&&(c=!0),e.c[z].forEach(m=>{const b=t[m]>=20;r===b&&!e.f[m]?(e.f[m]=n,i.push(m)):r&&!b&&(e.t[z]=1,e.t[m]=-1)})}const f=r?"island":c?"ocean":"lake";grid.features.push({i:n,land:r,border:c,type:f}),i[0]=e.f.findIndex(z=>!z)}Q&&console.timeEnd("markFeatures")}function Xr(){Q&&console.time("markupGridOcean"),Ya(grid.cells,-2,-1,-10),Q&&console.timeEnd("markupGridOcean")}function Ya(e,t,n,i){for(let r=t,c=1/0;c>0&&r>i;r+=n){c=0;const f=r-n;for(let z=0;z<e.i.length;z++)if(e.t[z]===f)for(const m of e.c[z])e.t[m]||(e.t[m]=r,c++)}}function Qr(){Q&&console.time("addLakesInDeepDepressions");const{cells:e,features:t}=grid,{c:n,h:i,b:r}=e,c=+ne("lakeElevationLimitOutput").value;if(c===80)return;for(const z of e.i){if(r[z]||i[z]<20)continue;const m=Ae.min(n[z].map(g=>i[g]));if(i[z]>m)continue;let b=!0;const A=i[z]+c,u=[z],C=[];for(C[z]=!0;b&&u.length;){const g=u.pop();for(const p of n[g])if(!C[p]&&!(i[p]>=A)){if(i[p]<20){b=!1;break}C[p]=!0,u.push(p)}}if(b){const g=[z].concat(n[z].filter(p=>i[p]===i[z]));f(g)}}function f(z){const m=t.length;z.forEach(b=>{e.h[b]=19,e.t[b]=-1,e.f[b]=m,n[b].forEach(A=>!z.includes(A)&&(e.t[n]=1))}),t.push({i:m,land:!1,border:!1,type:"lake"})}Q&&console.timeEnd("addLakesInDeepDepressions")}function $r(){if(ne("templateInput").value==="Atoll")return;const e=grid.cells,t=grid.features;if(!t.find(r=>r.type==="lake"))return;Q&&console.time("openLakes");const n=22;for(const r of e.i){const c=e.f[r];if(t[c].type!=="lake")continue;e:for(const f of e.c[r])if(!(e.t[f]!==1||e.h[f]>n))for(const z of e.c[f]){const m=e.f[z];if(t[m].type==="ocean"){i(f,c,m);break e}}}function i(r,c,f){e.h[r]=19,e.t[r]=-1,e.f[r]=f,e.c[r].forEach(function(z){e.h[z]>=20&&(e.t[z]=1)}),t[c].type="ocean"}Q&&console.timeEnd("openLakes")}function _r(){const[e,t]=i(),n=new URL(window.location.href).searchParams.get("options")==="default";(n||!Ne("mapSize"))&&(mapSizeOutput.value=mapSizeInput.value=O(e)),(n||!Ne("latitude"))&&(latitudeOutput.value=latitudeInput.value=O(t));function i(){const r=ne("templateInput").value;if(r==="africa-centric")return[45,53];if(r==="arabia")return[20,35];if(r==="atlantics")return[42,23];if(r==="britain")return[7,20];if(r==="caribbean")return[15,40];if(r==="east-asia")return[11,28];if(r==="eurasia")return[38,19];if(r==="europe")return[20,16];if(r==="europe-accented")return[14,22];if(r==="europe-and-central-asia")return[25,10];if(r==="europe-central")return[11,22];if(r==="europe-north")return[7,18];if(r==="greenland")return[22,7];if(r==="hellenica")return[8,27];if(r==="iceland")return[2,15];if(r==="indian-ocean")return[45,55];if(r==="mediterranean-sea")return[10,29];if(r==="middle-east")return[8,31];if(r==="north-america")return[37,17];if(r==="us-centric")return[66,27];if(r==="us-mainland")return[16,30];if(r==="world")return[78,27];if(r==="world-from-pacific")return[75,32];const c=grid.features.some(m=>m.land&&m.border),f=c?80:100,z=()=>Ce(V(.5)?40:60,15,25,75);if(!c){if(r==="Pangea")return[100,50];if(r==="Shattered"&&V(.7))return[100,50];if(r==="Continents"&&V(.5))return[100,50];if(r==="Archipelago"&&V(.35))return[100,50];if(r==="High Island"&&V(.25))return[100,50];if(r==="Low Island"&&V(.1))return[100,50]}return r==="Pangea"?[Ce(70,20,30,f),z()]:r==="Volcano"?[Ce(20,20,10,f),z()]:r==="Mediterranean"?[Ce(25,30,15,80),z()]:r==="Peninsula"?[Ce(15,15,5,80),z()]:r==="Isthmus"?[Ce(15,20,3,80),z()]:r==="Atoll"?[Ce(5,10,2,f),z()]:[Ce(30,20,15,f),z()]}}function es(){const e=+ne("mapSizeOutput").value,t=+ne("latitudeOutput").value,n=O(e/100*180,1),i=O(90-(180-n)*t/100,1),r=O(i-n,1),c=O(Math.min(graphWidth/graphHeight*n/2,180));return{latT:n,latN:i,latS:r,lonT:c*2,lonW:-c,lonE:c}}function ts(){Q&&console.time("calculateTemperatures");const e=grid.cells;e.temp=new Int8Array(e.i.length);const t=+temperatureEquatorInput.value,n=+temperaturePoleInput.value,i=t-n,r=Ae.easePolyInOut.exponent(.5);Ae.range(0,e.i.length,grid.cellsX).forEach(function(f){const z=grid.points[f][1],m=Math.abs(mapCoordinates.latN-z/graphHeight*mapCoordinates.latT),b=t-r(m/90)*i;for(let A=f;A<f+grid.cellsX;A++)e.temp[A]=Ie(b-c(e.h[A]),-128,127)});function c(f){if(f<20)return 0;const z=+heightExponentInput.value,m=Math.pow(f-18,z);return O(m/1e3*6.5)}Q&&console.timeEnd("calculateTemperatures")}function as(){Q&&console.time("generatePrecipitation"),prec.selectAll("*").remove();const{cells:e,cellsX:t,cellsY:n}=grid;e.prec=new Uint8Array(e.i.length);const i=(pointsInput.dataset.cells/1e4)**.25,r=precInput.value/100,c=i*r,f=[],z=[];let m=0,b=0;const A=[4,2,2,2,1,1,2,2,2,2,3,3,2,2,1,1,1,.5],u=85;Ae.range(0,e.i.length,t).forEach(function(k,d){const s=mapCoordinates.latN-d/n*mapCoordinates.latT,o=(Math.abs(s)-1)/5|0,l=A[o],a=Math.abs(s-89)/30|0,{isWest:w,isEast:S,isNorth:h,isSouth:v}=g(a);w&&f.push([k,l,a]),S&&z.push([k+t-1,l,a]),h&&b++,v&&m++}),f.length&&p(f,120*c,1,t),z.length&&p(z,120*c,-1,t);const C=m+b;if(b){const k=(Math.abs(mapCoordinates.latN)-1)/5|0,d=mapCoordinates.latT>60?Ae.mean(A):A[k],s=b/C*60*c*d;p(Ae.range(0,t,1),s,t,n)}if(m){const k=(Math.abs(mapCoordinates.latS)-1)/5|0,d=mapCoordinates.latT>60?Ae.mean(A):A[k],s=m/C*60*c*d;p(Ae.range(e.i.length-t,e.i.length,1),s,-t,n)}function g(k){const d=options.winds[k],s=d>40&&d<140,o=d>220&&d<320,l=d>100&&d<260,a=d>280||d<80;return{isWest:s,isEast:o,isNorth:l,isSouth:a}}function p(k,d,s,o){const l=d;for(let a of k){a[0]&&(d=Math.min(l*a[1],255),a=a[0]);let w=d-e.h[a];if(!(w<=0))for(let S=0,h=a;S<o;S++,h+=s){if(e.temp[h]<-5)continue;if(e.h[h]<20){e.h[h+s]>=20?e.prec[h+s]+=Math.max(w/be(10,20),1):(w=Math.min(w+5*c,d),e.prec[h]+=5*c);continue}const v=e.h[h+s]<=u,E=v?B(w,h,s):w;e.prec[h]+=E;const P=E>1.5?1:0;w=v?Ie(w-E+P,0,d):0}}}function B(k,d,s){const o=Math.max(k/(10*c),1),l=Math.max(e.h[d+s]-e.h[d],0),a=(e.h[d+s]/70)**2;return Ie(o+l*a,1,k)}(function(){const d=prec.append("g").attr("id","wind");Ae.range(0,6).forEach(function(s){if(f.length>1){const o=f.filter(l=>l[2]===s);if(o&&o.length>3){const l=o[0][0],a=o[o.length-1][0],w=(grid.points[l][1]+grid.points[a][1])/2;d.append("text").attr("x",20).attr("y",w).text("\u21C9")}}if(z.length>1){const o=z.filter(l=>l[2]===s);if(o&&o.length>3){const l=o[0][0],a=o[o.length-1][0],w=(grid.points[l][1]+grid.points[a][1])/2;d.append("text").attr("x",graphWidth-52).attr("y",w).text("\u21C7")}}}),b&&d.append("text").attr("x",graphWidth/2).attr("y",42).text("\u21CA"),m&&d.append("text").attr("x",graphWidth/2).attr("y",graphHeight-20).text("\u21C8")})(),Q&&console.timeEnd("generatePrecipitation")}function ns(){Q&&console.time("reGraph");const{cells:e,points:t,features:n}=grid,i={p:[],g:[],h:[]},r=grid.spacing**2;for(const b of e.i){const A=e.h[b],u=e.t[b];if(A<20&&u!==-1&&u!==-2||u===-2&&(b%4===0||n[e.f[b]].type==="lake"))continue;const[C,g]=t[b];if(c(b,C,g,A),u===1||u===-1){if(e.b[b])continue;e.c[b].forEach(function(p){if(!(b>p)&&e.t[p]===u){if((g-t[p][1])**2+(C-t[p][0])**2<r)return;const k=O((C+t[p][0])/2,1),d=O((g+t[p][1])/2,1);c(b,k,d,A)}})}}function c(b,A,u,C){i.p.push([A,u]),i.g.push(b),i.h.push(C)}function f(b){const A=Math.abs(Ae.polygonArea(Zt(b)));return Math.min(A,Dt)}const{cells:z,vertices:m}=ma(i.p,grid.boundary);pack.vertices=m,pack.cells=z,pack.cells.p=i.p,pack.cells.g=yt({maxValue:grid.points.length,from:i.g}),pack.cells.q=Ae.quadtree(i.p.map(([b,A],u)=>[b,A,u])),pack.cells.h=yt({maxValue:100,from:i.h}),pack.cells.area=yt({maxValue:Dt,from:pack.cells.i}).map(f),Q&&console.timeEnd("reGraph")}function os(){Q&&console.time("drawCoastline"),is();const{cells:e,vertices:t,features:n}=pack,i=e.i.length,r=new Uint8Array(n.length),c=Ae.scan(n.map(u=>u.land?u.cells:0),(u,C)=>C-u),f=defs.select("#land"),z=defs.select("#water");lineGen.curve(Ae.curveBasisClosed);for(const u of e.i){if(!(!u&&e.h[u]>=20)&&e.t[u]!==-1&&e.t[u]!==1)continue;const g=e.f[u];if(r[g]||n[g].type==="ocean")continue;const p=n[g].type==="lake"?1:-1,B=m(u,p);if(B===-1)continue;let k=b(B,p);n[g].type==="lake"&&A(k,1.2),r[g]=1;let d=Et(k.map(l=>t.p[l]));const s=Ae.polygonArea(d);s>0&&n[g].type==="lake"&&(d=d.reverse(),k=k.reverse()),n[g].area=Math.abs(s),n[g].vertices=k;const o=round(lineGen(d));if(n[g].type==="lake")f.append("path").attr("d",o).attr("fill","black").attr("id","land_"+g),lakes.select("#freshwater").append("path").attr("d",o).attr("id","lake_"+g).attr("data-f",g);else{f.append("path").attr("d",o).attr("fill","white").attr("id","land_"+g),z.append("path").attr("d",o).attr("fill","black").attr("id","water_"+g);const l=n[g].group==="lake_island"?"lake_island":"sea_island";coastline.select("#"+l).append("path").attr("d",o).attr("id","island_"+g).attr("data-f",g)}if(g===c){const l=d[Ae.scan(d,(w,S)=>w[0]-S[0])],a=d[Ae.scan(d,(w,S)=>S[0]-w[0])];rulers.create(ja,[l,a])}}function m(u,C){if(C===-1&&e.b[u])return e.v[u].find(B=>t.c[B].some(k=>k>=i));const g=e.c[u].filter(B=>e.t[B]===C),p=e.c[u].indexOf(Ae.min(g));return p===-1?p:e.v[u][p]}function b(u,C){const g=[];for(let p=0,B=u;p===0||B!==u&&p<5e4;p++){const k=g[g.length-1];g.push(B);const d=t.c[B],s=t.v[B],o=d[0]>=i||e.t[d[0]]===C,l=d[1]>=i||e.t[d[1]]===C,a=d[2]>=i||e.t[d[2]]===C;if(s[0]!==k&&o!==l?B=s[0]:s[1]!==k&&l!==a?B=s[1]:s[2]!==k&&o!==a&&(B=s[2]),B===g[g.length-1]){console.error("Next vertex is not found");break}}return g}function A(u,C){const g=t.p,p=Ae.quadtree();for(let B=0;B<u.length;B++){const k=u[B];let[d,s]=[g[k][0],g[k][1]];if(B&&u[B+1]&&p.find(d,s,C)!==void 0){const o=u[B-1],l=u[B+1],[a,w]=[g[o][0],g[o][1]],[S,h]=[g[l][0],g[l][1]];[d,s]=[(a+S)/2,(w+h)/2],g[k]=[d,s]}p.add([d,s])}}Q&&console.timeEnd("drawCoastline")}function is(){Q&&console.time("reMarkFeatures");const e=pack.cells,t=pack.features=[0];e.f=new Uint16Array(e.i.length),e.t=new Int8Array(e.i.length),e.haven=e.i.length<65535?new Uint16Array(e.i.length):new Uint32Array(e.i.length),e.harbor=new Uint8Array(e.i.length);const n=c=>{const f=e.c[c].filter(b=>e.h[b]<20),z=f.map(b=>(e.p[c][0]-e.p[b][0])**2+(e.p[c][1]-e.p[b][1])**2),m=f[z.indexOf(Math.min.apply(Math,z))];e.haven[c]=m,e.harbor[c]=f.length};if(!e.i.length)return;for(let c=1,f=[0];f[0]!==-1;c++){const z=f[0];e.f[z]=c;const m=e.h[z]>=20;let b=!1,A=1;for(;f.length;){const g=f.pop();e.b[g]&&(b=!0),e.c[g].forEach(function(p){const B=e.h[p]>=20;m&&!B?(e.t[g]=1,e.t[p]=-1,e.haven[g]||n(g)):m&&B&&(!e.t[p]&&e.t[g]===1?e.t[p]=2:!e.t[g]&&e.t[p]===1&&(e.t[g]=2)),!e.f[p]&&m===B&&(f.push(p),e.f[p]=c,A++)})}const u=m?"island":b?"ocean":"lake";let C;u==="ocean"?C=i(A):u==="island"&&(C=r(z,A)),t.push({i:c,land:m,border:b,type:u,cells:A,firstCell:z,group:C}),f[0]=e.f.findIndex(g=>!g)}Ya(pack.cells,3,1,0);function i(c){return c>grid.cells.i.length/25?"ocean":c>grid.cells.i.length/100?"sea":"gulf"}function r(c,f){return c&&t[e.f[c-1]].type==="lake"?"lake_island":f>grid.cells.i.length/10?"continent":f>grid.cells.i.length/1e3?"island":"isle"}Q&&console.timeEnd("reMarkFeatures")}function rs(e,t,n){return e>40&&t>-2&&n<25||e>24&&t>-2&&n>24&&n<60}function ss(){Q&&console.time("defineBiomes");const{cells:e}=pack,{temp:t,prec:n}=grid.cells;e.biome=new Uint8Array(e.i.length);for(const r of e.i){const c=t[e.g[r]],f=e.h[r],z=f<20?0:i(r);e.biome[r]=ls(z,c,f)}function i(r){let c=n[e.g[r]];e.r[r]&&(c+=Math.max(e.fl[r]/20,2));const f=e.c[r].filter(Sn).map(z=>n[e.g[z]]).concat([c]);return O(4+Ae.mean(f))}Q&&console.timeEnd("defineBiomes")}function ls(e,t,n){if(n<20)return 0;if(t<-5)return 11;if(rs(e,t,n))return 12;const i=Math.min(e/5|0,4),r=Math.min(Math.max(20-t,0),25);return biomesData.biomesMartix[i][r]}function cs(){Q&&console.time("rankCells");const{cells:e,features:t}=pack;e.s=new Int16Array(e.i.length),e.pop=new Float32Array(e.i.length);const n=Ae.median(e.fl.filter(c=>c))||0,i=Ae.max(e.fl)+Ae.max(e.conf),r=Ae.mean(e.area);for(const c of e.i){if(e.h[c]<20)continue;let f=+biomesData.habitability[e.biome[c]];if(!!f){if(n&&(f+=ga(e.fl[c]+e.conf[c],n,i)*250),f-=(e.h[c]-50)/5,e.t[c]===1){e.r[c]&&(f+=15);const z=t[e.f[e.haven[c]]];z.type==="lake"?z.group==="freshwater"?f+=30:z.group=="salt"?f+=10:z.group=="frozen"?f+=1:z.group=="dry"||z.group=="sinkhole"?f-=5:z.group=="lava"&&(f-=30):(f+=5,e.harbor[c]===1&&(f+=20))}e.s[c]=f/5,e.pop[c]=e.s[c]>0?e.s[c]*e.area[c]/r:0}}Q&&console.timeEnd("rankCells")}function us(e=1){Q&&console.time("addZones");const{cells:t,states:n,burgs:i}=pack,r=new Uint8Array(t.i.length),c=[];for(let s=0;s<O(Math.random()*1.8*e);s++)f();for(let s=0;s<O(Math.random()*1.6*e);s++)z();for(let s=0;s<O(Math.random()*1.6*e);s++)m();for(let s=0;s<O(Math.random()*1.6*e);s++)b();for(let s=0;s<O(Math.random()*1.8*e);s++)A();for(let s=0;s<O(Math.random()*1.4*e);s++)u();for(let s=0;s<O(Math.random()*1.4*e);s++)C();for(let s=0;s<O(Math.random()*1*e);s++)g();for(let s=0;s<O(Math.random()*1.4*e);s++)p();for(let s=0;s<O(Math.random()*1.4*e);s++)B();for(let s=0;s<O(Math.random()*1.2*e);s++)k();d();function f(){const s=n.filter(P=>P.diplomacy&&P.diplomacy.some(T=>T==="Enemy"));if(!s.length)return;const o=ie(s),l=o.diplomacy.findIndex(P=>P==="Enemy"),a=ie(t.i.filter(P=>t.state[P]===l&&t.c[P].some(T=>t.state[T]===o.i)));if(!a)return;const w=[],S=[a],h=be(5,30);for(;S.length;){const P=V(.4)?S.shift():S.pop();if(w.push(P),w.length>h)break;t.c[P].forEach(T=>{r[T]||t.state[T]===l&&(r[T]=1,S.push(T))})}const v=he({Invasion:4,Occupation:3,Raid:2,Conquest:2,Subjugation:1,Foray:1,Skirmishes:1,Incursion:2,Pillaging:1,Intervention:1}),E=We(o.name)+" "+v;c.push({name:E,type:"Invasion",cells:w,fill:"url(#hatch1)"})}function z(){const s=ie(n.filter(E=>E.i&&!E.removed&&E.neighbors.some(P=>P)));if(!s)return;const o=ie(s.neighbors.filter(E=>E&&!n[E].removed));if(!o)return;const l=t.i.find(E=>t.state[E]===s.i&&!s.removed&&t.c[E].some(P=>t.state[P]===o)),a=[],w=[];l&&w.push(l);const S=be(10,30);for(;w.length;){const E=w.shift();if(a.push(E),a.length>S)break;t.c[E].forEach(P=>{r[P]||t.state[P]===s.i&&(r[P]=1,!(P%4!==0&&!t.c[P].some(T=>t.state[T]===o))&&w.push(P))})}const h=he({Rebels:5,Insurgents:2,Mutineers:1,Rioters:1,Separatists:1,Secessionists:1,Insurrection:2,Rebellion:1,Conspiracy:2}),v=We(n[o].name)+" "+h;c.push({name:v,type:"Rebels",cells:a,fill:"url(#hatch3)"})}function m(){const s=ie(pack.religions.filter(v=>v.type==="Organized"));if(!s)return;const o=ie(t.i.filter(v=>t.religion[v]&&t.religion[v]!==s.i&&t.c[v].some(E=>t.religion[E]===s.i)));if(!o)return;const l=t.religion[o],a=[],w=[o],S=be(10,30);for(;w.length;){const v=w.shift();if(a.push(v),a.length>S)break;t.c[v].forEach(E=>{r[E]||t.religion[E]===l&&(t.h[E]<20||(r[E]=1,w.push(E)))})}const h=We(s.name.split(" ")[0])+" Proselytism";c.push({name:h,type:"Proselytism",cells:a,fill:"url(#hatch6)"})}function b(){const s=ie(pack.religions.filter(a=>a.type==="Heresy"));if(!s)return;const o=t.i.filter(a=>!r[a]&&t.religion[a]===s.i);if(!o.length)return;o.forEach(a=>r[a]=1);const l=We(s.name.split(" ")[0])+" Crusade";c.push({name:l,type:"Crusade",cells:o,fill:"url(#hatch6)"})}function A(){const s=ie(i.filter(T=>!r[T.cell]&&T.i&&!T.removed));if(!s)return;const o=[],l=[],a=be(20,37),w=new PriorityQueue({comparator:(T,R)=>T.p-R.p});for(w.queue({e:s.cell,p:0});w.length;){const T=w.dequeue();(t.burg[T.e]||t.pop[T.e])&&o.push(T.e),r[T.e]=1,t.c[T.e].forEach(function(R){const L=t.road[T.e],M=L?Math.max(10-L,1):100,I=T.p+M;I>a||(!l[R]||I<l[R])&&(l[R]=I,w.queue({e:R,p:I}))})}const S=()=>ie(["Great","Silent","Severe","Blind","Unknown","Loud","Deadly","Burning","Bloody","Brutal","Fatal"]),h=()=>ie(["Ape","Bear","Boar","Cat","Cow","Dog","Pig","Fox","Bird","Horse","Rat","Raven","Sheep","Spider","Wolf"]),v=()=>ie(["Golden","White","Black","Red","Pink","Purple","Blue","Green","Yellow","Amber","Orange","Brown","Grey"]),E=he({Fever:5,Pestilence:2,Flu:2,Pox:2,Smallpox:2,Plague:4,Cholera:2,Dropsy:1,Leprosy:2}),P=he({[v()]:4,[h()]:2,[S()]:1})+" "+E;c.push({name:P,type:"Disease",cells:o,fill:"url(#hatch12)"})}function u(){const s=ie(i.filter(v=>!r[v.cell]&&v.i&&!v.removed));if(!s)return;const o=[],l=[],a=be(5,25),w=new PriorityQueue({comparator:(v,E)=>v.p-E.p});for(w.queue({e:s.cell,p:0});w.length;){const v=w.dequeue();(t.burg[v.e]||t.pop[v.e])&&o.push(v.e),r[v.e]=1,t.c[v.e].forEach(function(E){const P=be(1,10),T=v.p+P;T>a||(!l[E]||T<l[E])&&(l[E]=T,w.queue({e:E,p:T}))})}const S=he({Famine:5,Dearth:1,Drought:3,Earthquake:3,Tornadoes:1,Wildfires:1}),h=We(s.name)+" "+S;c.push({name:h,type:"Disaster",cells:o,fill:"url(#hatch5)"})}function C(){const s=ne("markers").querySelector("use[data-id='#marker_volcano']");if(!s)return;const o=+s.dataset.x,l=+s.dataset.y,a=Te(o,l),w=s.id,S=notes.filter(T=>T.id===w);S[0]&&(S[0].legend=S[0].legend.replace("Active volcano","Erupting volcano"));const h=S[0]?S[0].name.replace(" Volcano","")+" Eruption":"Volcano Eruption",v=[],E=[a],P=be(10,30);for(;E.length;){const T=V(.5)?E.shift():E.pop();if(v.push(T),v.length>P)break;t.c[T].forEach(R=>{r[R]||t.h[R]<20||(r[R]=1,E.push(R))})}c.push({name:h,type:"Disaster",cells:v,fill:"url(#hatch7)"})}function g(){const s=t.i.filter(v=>!r[v]&&t.road[v]&&t.h[v]>=70);if(!s.length)return;const o=+ie(s),l=[],a=[o],w=be(3,15);for(;a.length;){const v=V(.3)?a.shift():a.pop();if(l.push(v),l.length>w)break;t.c[v].forEach(E=>{r[E]||t.h[E]<65||(r[E]=1,a.push(E))})}const h=We(Names.getCultureShort(t.culture[o]))+" Avalanche";c.push({name:h,type:"Disaster",cells:l,fill:"url(#hatch5)"})}function p(){const s=t.i.filter(v=>!r[v]&&t.h[v]>50&&t.h[v]<70);if(!s.length)return;const o=ie(s),l=[],a=[o],w=be(3,15);for(;a.length;){const v=a.pop();if(t.h[v]>=20&&l.push(v),l.length>w)break;t.c[v].forEach(E=>{r[E]||t.r[E]||(r[E]=1,a.push(E))})}const h=We(Names.getCultureShort(t.culture[o]))+" Fault";c.push({name:h,type:"Disaster",cells:l,fill:"url(#hatch2)"})}function B(){const s=t.fl.filter(R=>R),o=Ae.mean(s),l=Ae.max(s),a=(l-o)/2+o,w=t.i.filter(R=>!r[R]&&t.h[R]<50&&t.r[R]&&t.fl[R]>a&&t.burg[R]);if(!w.length)return;const S=+ie(w),h=t.r[S],v=[],E=[S],P=be(5,30);for(;E.length;){const R=E.pop();if(v.push(R),v.length>P)break;t.c[R].forEach(L=>{r[L]||t.h[L]<20||t.r[L]!==h||t.h[L]>50||t.fl[L]<o||(r[L]=1,E.push(L))})}const T=We(i[t.burg[S]].name)+" Flood";c.push({name:T,type:"Disaster",cells:v,fill:"url(#hatch13)"})}function k(){const s=t.i.filter(v=>!r[v]&&t.t[v]===-1&&pack.features[t.f[v]].type!=="lake");if(!s.length)return;const o=+ie(s),l=[],a=[o],w=be(10,30);for(;a.length;){const v=a.shift();if(t.t[v]===1&&l.push(v),l.length>w)break;t.c[v].forEach(E=>{r[E]||t.t[E]>2||pack.features[t.f[E]].type!=="lake"&&(r[E]=1,a.push(E))})}const h=We(Names.getCultureShort(t.culture[o]))+" Tsunami";c.push({name:h,type:"Disaster",cells:l,fill:"url(#hatch13)"})}function d(){zones.selectAll("g").data(c).enter().append("g").attr("id",(s,o)=>"zone"+o).attr("data-description",s=>s.name).attr("data-type",s=>s.type).attr("data-cells",s=>s.cells.join(",")).attr("fill",s=>s.fill).selectAll("polygon").data(s=>s.cells).enter().append("polygon").attr("points",s=>Zt(s)).attr("id",function(s){return this.parentNode.id+"_"+s})}Q&&console.timeEnd("addZones")}function ds(){const e=ne("templateInput").value,t=e in heightmapTemplates,n=t?"template":"precreated",i=t&&!Ne("template")?"random ":"",r=` Seed: ${seed}
Canvas size: ${graphWidth}x${graphHeight} px
Heightmap: ${e} (${i}${n})
Points: ${grid.points.length}
Cells: ${pack.cells.i.length}
Map size: ${mapSizeOutput.value}%
States: ${pack.states.length-1}
Provinces: ${pack.provinces.length-1}
Burgs: ${pack.burgs.length-1}
Religions: ${pack.religions.length-1}
Culture set: ${culturesSet.selectedOptions[0].innerText}
Cultures: ${pack.cultures.length-1}`;mapId=Date.now(),mapHistory.push({seed,width:graphWidth,height:graphHeight,template:e,created:mapId}),Ft&&console.log(r)}const hs=vt(async function(e){console.warn("Generate new random map");const n=+ne("pointsInput").dataset.cells>1e4;n&&Wr(),closeDialogs("#worldConfigurator, #options3d"),customization=0,Zoom.reset(1e3),gs(),await Ja(e),restoreLayers(),ThreeD.options.isOn&&ThreeD.redraw(),$("#worldConfigurator").is(":visible")&&editWorld(),n&&Za(),ct()},250);function gs(){viewbox.selectAll("path, circle, polygon, line, text, use, #zones > g, #armies > g, #ruler > g").remove(),document.getElementById("deftemp").querySelectorAll("path, clipPath, svg").forEach(e=>e.remove()),ne("coas").innerHTML="",notes=[],rulers=new Ga,unfog()}window.ReliefIcons=function(){const e=function(){TIME&&console.time("drawRelief"),terrain.selectAll("*").remove();const f=pack.cells,z=terrain.attr("density")||.4,m=2*(terrain.attr("size")||1),b=.2*m,A=[];for(const C of f.i){let l=function(){const S=biomesData.iconsDensity[p]/100,h=2/S/z;if(!(Math.random()>S*10))for(const[v,E]of c(k,s,d,o,h)){if(!d3.polygonContains(B,[v,E]))continue;let P=(4+Math.random())*m;const T=t(C,biomesData.icons[p]);T==="#relief-grass-1"&&(P*=1.2),A.push({i:T,x:O(v-P,2),y:O(E-P,2),s:O(P*2,2)})}},a=function(S){const h=2/z,[v,E]=w(S,g);for(const[P,T]of c(k,s,d,o,h))!d3.polygonContains(B,[P,T])||A.push({i:v,x:O(P-E,2),y:O(T-E,2),s:O(E*2,2)})},w=function(S,h){const v=grid.cells.temp[pack.cells.g[S]],E=h>70&&v<0?"mountSnow":h>70?"mount":"hill",P=h>70?(h-45)*b:Ie((h-40)*b,3,6);return[r(E),P]};const g=f.h[C];if(g<20||f.r[C])continue;const p=f.biome[C];if(g<50&&biomesData.iconsDensity[p]===0)continue;const B=Zt(C),[k,d]=d3.extent(B,S=>S[0]),[s,o]=d3.extent(B,S=>S[1]);g<50?l():a(C)}A.sort((C,g)=>C.y+C.s-(g.y+g.s));let u="";for(const C of A)u+=`<use href="${C.i}" x="${C.x}" y="${C.y}" width="${C.s}" height="${C.s}"/>`;terrain.html(u),TIME&&console.timeEnd("drawRelief")};function t(f,z){let m=z[Math.floor(Math.random()*z.length)];const b=grid.cells.temp[pack.cells.g[f]];return m==="conifer"&&b<0&&(m="coniferSnow"),r(m)}function n(f){switch(f){case"mount":return be(2,7);case"mountSnow":return be(1,6);case"hill":return be(2,5);case"conifer":return 2;case"coniferSnow":return 1;case"swamp":return be(2,3);case"cactus":return be(1,3);case"deadTree":return be(1,2);default:return 2}}function i(f){switch(f){case"mountSnow":return"mount";case"vulcan":return"mount";case"coniferSnow":return"conifer";case"cactus":return"dune";case"deadTree":return"dune";default:return f}}function r(f){const z=terrain.attr("set")||"simple";return z==="simple"?"#relief-"+i(f)+"-1":z==="colored"?"#relief-"+f+"-"+n(f):z==="gray"?"#relief-"+f+"-"+n(f)+"-bw":"#relief-"+i(f)+"-1"}function*c(f,z,m,b,A,u=3){if(!(m>=f)||!(b>=z)||!(A>0))throw new Error;const C=m-f,g=b-z,p=A*A,B=3*p,k=A*Math.SQRT1_2,d=Math.ceil(C/k),s=Math.ceil(g/k),o=new Array(d*s),l=[];function a(S,h){const v=S/k|0,E=h/k|0,P=Math.max(v-2,0),T=Math.max(E-2,0),R=Math.min(v+3,d),L=Math.min(E+3,s);for(let M=T;M<L;++M){const I=M*d;for(let H=P;H<R;++H){const G=o[I+H];if(G){const D=G[0]-S,U=G[1]-h;if(D*D+U*U<p)return!1}}}return!0}function w(S,h){return l.push(o[d*(h/k|0)+(S/k|0)]=[S,h]),[S+f,h+z]}yield w(C/2,g/2);e:for(;l.length;){const S=Math.random()*l.length|0,h=l[S];for(let E=0;E<u;++E){const P=2*Math.PI*Math.random(),T=Math.sqrt(Math.random()*B+p),R=h[0]+T*Math.cos(P),L=h[1]+T*Math.sin(P);if(0<=R&&R<C&&0<=L&&L<g&&a(R,L)){yield w(R,L);continue e}}const v=l.pop();S<l.length&&(l[S]=v)}}return e}();{const e=Array.from(document.getElementById("filters").querySelectorAll("filter")),t='<option value="" selected>None</option>',n=e.map(r=>{const c=r.getAttribute("id"),f=r.getAttribute("name");return`<option value="url(#${c})">${f}</option>`}),i=t+n.join("");document.getElementById("styleFilterInput").innerHTML=i,document.getElementById("styleStatesBodyFilter").innerHTML=i}styleElements.addEventListener("change",function(e){e.target.dataset.stored&&lock(e.target.dataset.stored)});styleElementSelect.addEventListener("change",Xa);function Xa(){var r,c,f;const e=styleElementSelect.value;let t=d3.select("#"+e);styleElements.querySelectorAll("tbody").forEach(z=>z.style.display="none");const n=e!=="ocean"&&(t.style("display")==="none"||!t.selectAll("*").size());styleIsOff.style.display=n?"block":"none";const i=styleGroupSelect.value;if(["routes","labels","coastline","lakes","anchors","burgIcons","borders"].includes(e)){const z=i&&t.select("#"+i);t=i&&z.size()?z:t.select("g")}if(["landmass","ocean","regions","legend"].includes(e)||(styleOpacity.style.display="block",styleOpacityInput.value=styleOpacityOutput.value=t.attr("opacity")||1),["landmass","legend","regions"].includes(e)||(styleFilter.style.display="block",styleFilterInput.value=t.attr("filter")||""),["rivers","lakes","landmass","prec","ice","fogging"].includes(e)&&(styleFill.style.display="block",styleFillInput.value=styleFillOutput.value=t.attr("fill")),["armies","routes","lakes","borders","cults","relig","cells","coastline","prec","ice","icons","coordinates","zones","gridOverlay"].includes(e)&&(styleStroke.style.display="block",styleStrokeInput.value=styleStrokeOutput.value=t.attr("stroke"),styleStrokeWidth.style.display="block",styleStrokeWidthInput.value=styleStrokeWidthOutput.value=t.attr("stroke-width")||""),["routes","borders","temperature","legend","population","coordinates","zones","gridOverlay"].includes(e)&&(styleStrokeDash.style.display="block",styleStrokeDasharrayInput.value=t.attr("stroke-dasharray")||"",styleStrokeLinecapInput.value=t.attr("stroke-linecap")||"inherit"),["cells","gridOverlay","coordinates","compass","terrain","temperature","routes","texture","biomes","zones"].includes(e)&&(styleClipping.style.display="block",styleClippingInput.value=t.attr("mask")||""),e==="texture"&&(styleTexture.style.display="block"),e==="terrs"&&(styleHeightmap.style.display="block",styleHeightmapScheme.value=terrs.attr("scheme"),styleHeightmapTerracingInput.value=styleHeightmapTerracingOutput.value=terrs.attr("terracing"),styleHeightmapSkipInput.value=styleHeightmapSkipOutput.value=terrs.attr("skip"),styleHeightmapSimplificationInput.value=styleHeightmapSimplificationOutput.value=terrs.attr("relax"),styleHeightmapCurve.value=terrs.attr("curve")),e==="markers"&&(styleMarkers.style.display="block",styleRescaleMarkers.checked=+markers.attr("rescale")),e==="gridOverlay"&&(styleGrid.style.display="block",styleGridType.value=t.attr("type"),styleGridScale.value=t.attr("scale")||1,styleGridShiftX.value=t.attr("dx")||0,styleGridShiftY.value=t.attr("dy")||0,ea()),e==="compass"){styleCompass.style.display="block";const z=Yt(compass.select("use").attr("transform"));styleCompassShiftX.value=z[0],styleCompassShiftY.value=z[1],styleCompassSizeInput.value=styleCompassSizeOutput.value=z[2]}if(e==="terrain"&&(styleRelief.style.display="block",styleReliefSizeOutput.innerHTML=styleReliefSizeInput.value=terrain.attr("size"),styleReliefDensityOutput.innerHTML=styleReliefDensityInput.value=terrain.attr("density"),styleReliefSet.value=terrain.attr("set")),e==="population"&&(stylePopulation.style.display="block",stylePopulationRuralStrokeInput.value=stylePopulationRuralStrokeOutput.value=population.select("#rural").attr("stroke"),stylePopulationUrbanStrokeInput.value=stylePopulationUrbanStrokeOutput.value=population.select("#urban").attr("stroke"),styleStrokeWidth.style.display="block",styleStrokeWidthInput.value=styleStrokeWidthOutput.value=t.attr("stroke-width")||""),e==="regions"){styleStates.style.display="block",styleStatesBodyOpacity.value=styleStatesBodyOpacityOutput.value=statesBody.attr("opacity")||1,styleStatesBodyFilter.value=statesBody.attr("filter")||"",styleStatesHaloWidth.value=styleStatesHaloWidthOutput.value=statesHalo.attr("data-width")||10,styleStatesHaloOpacity.value=styleStatesHaloOpacityOutput.value=statesHalo.attr("opacity")||1;const z=parseFloat((c=(r=statesHalo.attr("filter"))==null?void 0:r.match(/blur\(([^)]+)\)/))==null?void 0:c[1])||0;styleStatesHaloBlur.value=styleStatesHaloBlurOutput.value=z}e==="labels"&&(styleFill.style.display="block",styleStroke.style.display="block",styleStrokeWidth.style.display="block",styleShadow.style.display="block",styleSize.style.display="block",styleVisibility.style.display="block",styleFillInput.value=styleFillOutput.value=t.attr("fill")||"#3e3e4b",styleStrokeInput.value=styleStrokeOutput.value=t.attr("stroke")||"#3a3a3a",styleStrokeWidthInput.value=styleStrokeWidthOutput.value=t.attr("stroke-width")||0,styleShadowInput.value=t.style("text-shadow")||"white 0 0 4px",styleFont.style.display="block",styleSelectFont.value=t.attr("font-family"),styleFontSize.value=t.attr("data-size")),e==="provs"&&(styleFill.style.display="block",styleSize.style.display="block",styleFillInput.value=styleFillOutput.value=t.attr("fill")||"#111111",styleFont.style.display="block",styleSelectFont.value=t.attr("font-family"),styleFontSize.value=t.attr("data-size")),e=="burgIcons"&&(styleFill.style.display="block",styleStroke.style.display="block",styleStrokeWidth.style.display="block",styleStrokeDash.style.display="block",styleRadius.style.display="block",styleFillInput.value=styleFillOutput.value=t.attr("fill")||"#ffffff",styleStrokeInput.value=styleStrokeOutput.value=t.attr("stroke")||"#3e3e4b",styleStrokeWidthInput.value=styleStrokeWidthOutput.value=t.attr("stroke-width")||.24,styleStrokeDasharrayInput.value=t.attr("stroke-dasharray")||"",styleStrokeLinecapInput.value=t.attr("stroke-linecap")||"inherit",styleRadiusInput.value=t.attr("size")||1),e=="anchors"&&(styleFill.style.display="block",styleStroke.style.display="block",styleStrokeWidth.style.display="block",styleIconSize.style.display="block",styleFillInput.value=styleFillOutput.value=t.attr("fill")||"#ffffff",styleStrokeInput.value=styleStrokeOutput.value=t.attr("stroke")||"#3e3e4b",styleStrokeWidthInput.value=styleStrokeWidthOutput.value=t.attr("stroke-width")||.24,styleIconSizeInput.value=t.attr("size")||2),e==="legend"&&(styleStroke.style.display="block",styleStrokeWidth.style.display="block",styleSize.style.display="block",styleLegend.style.display="block",styleLegendColItemsOutput.value=styleLegendColItems.value=t.attr("data-columns"),styleLegendBackOutput.value=styleLegendBack.value=t.select("#legendBox").attr("fill"),styleLegendOpacityOutput.value=styleLegendOpacity.value=t.select("#legendBox").attr("fill-opacity"),styleStrokeInput.value=styleStrokeOutput.value=t.attr("stroke")||"#111111",styleStrokeWidthInput.value=styleStrokeWidthOutput.value=t.attr("stroke-width")||.5,styleFont.style.display="block",styleSelectFont.value=t.attr("font-family"),styleFontSize.value=t.attr("data-size")),e==="ocean"&&(styleOcean.style.display="block",styleOceanFill.value=styleOceanFillOutput.value=oceanLayers.select("#oceanBase").attr("fill"),styleOceanPattern.value=(f=document.getElementById("oceanicPattern"))==null?void 0:f.getAttribute("href"),styleOceanPatternOpacity.value=styleOceanPatternOpacityOutput.value=document.getElementById("oceanicPattern").getAttribute("opacity")||1,outlineLayers.value=oceanLayers.attr("layers")),e==="temperature"&&(styleStrokeWidth.style.display="block",styleTemperature.style.display="block",styleStrokeWidthInput.value=styleStrokeWidthOutput.value=t.attr("stroke-width")||"",styleTemperatureFillOpacityInput.value=styleTemperatureFillOpacityOutput.value=t.attr("fill-opacity")||.1,styleTemperatureFillInput.value=styleTemperatureFillOutput.value=t.attr("fill")||"#000",styleTemperatureFontSizeInput.value=styleTemperatureFontSizeOutput.value=t.attr("font-size")||"8px"),e==="coordinates"&&(styleSize.style.display="block",styleFontSize.value=t.attr("data-size")),e==="armies"&&(styleArmies.style.display="block",styleArmiesFillOpacity.value=styleArmiesFillOpacityOutput.value=t.attr("fill-opacity"),styleArmiesSize.value=styleArmiesSizeOutput.value=t.attr("box-size")),e==="emblems"&&(styleEmblems.style.display="block",styleStrokeWidth.style.display="block",styleStrokeWidthInput.value=styleStrokeWidthOutput.value=t.attr("stroke-width")||1),styleGroupSelect.options.length=0,["routes","labels","coastline","lakes","anchors","burgIcons","borders"].includes(e)?(document.getElementById(e).querySelectorAll("g").forEach(m=>{if(m.id==="burgLabels")return;const b=new Option(`${m.id} (${m.childElementCount})`,m.id,!1,!1);styleGroupSelect.options.add(b)}),styleGroupSelect.value=t.attr("id"),styleGroup.style.display="block"):(styleGroupSelect.options.add(new Option(e,e,!1,!0)),styleGroup.style.display="none"),e==="coastline"&&styleGroupSelect.value==="sea_island"&&(styleCoastline.style.display="block",(styleCoastlineAuto.checked=coastline.select("#sea_island").attr("auto-filter"))&&(styleFilter.style.display="none"))}styleGroupSelect.addEventListener("change",Xa);function Re(){const e=styleElementSelect.value,t=styleGroupSelect.value;return t===e?svg.select("#"+e):svg.select("#"+e).select("#"+t)}styleFillInput.addEventListener("input",function(){styleFillOutput.value=this.value,Re().attr("fill",this.value)});styleStrokeInput.addEventListener("input",function(){styleStrokeOutput.value=this.value,Re().attr("stroke",this.value),styleElementSelect.value==="gridOverlay"&&layerIsOn("toggleGrid")&&drawGrid()});styleStrokeWidthInput.addEventListener("input",function(){styleStrokeWidthOutput.value=this.value,Re().attr("stroke-width",+this.value),styleElementSelect.value==="gridOverlay"&&layerIsOn("toggleGrid")&&drawGrid()});styleStrokeDasharrayInput.addEventListener("input",function(){Re().attr("stroke-dasharray",this.value),styleElementSelect.value==="gridOverlay"&&layerIsOn("toggleGrid")&&drawGrid()});styleStrokeLinecapInput.addEventListener("change",function(){Re().attr("stroke-linecap",this.value),styleElementSelect.value==="gridOverlay"&&layerIsOn("toggleGrid")&&drawGrid()});styleOpacityInput.addEventListener("input",function(){styleOpacityOutput.value=this.value,Re().attr("opacity",this.value)});styleFilterInput.addEventListener("change",function(){if(styleGroupSelect.value==="ocean")return oceanLayers.attr("filter",this.value);Re().attr("filter",this.value)});styleTextureInput.addEventListener("change",function(){this.value==="none"?texture.select("image").attr("xlink:href",""):ka(this.value,e=>texture.select("image").attr("xlink:href",e))});styleTextureShiftX.addEventListener("input",function(){texture.select("image").attr("x",this.value).attr("width",graphWidth-this.valueAsNumber)});styleTextureShiftY.addEventListener("input",function(){texture.select("image").attr("y",this.value).attr("height",graphHeight-this.valueAsNumber)});styleClippingInput.addEventListener("change",function(){Re().attr("mask",this.value)});styleGridType.addEventListener("change",function(){Re().attr("type",this.value),layerIsOn("toggleGrid")&&drawGrid(),ea()});styleGridScale.addEventListener("input",function(){Re().attr("scale",this.value),layerIsOn("toggleGrid")&&drawGrid(),ea()});function ea(){const e=styleGridScale.value*25,t=`${O(e*distanceScaleInput.value,2)} ${distanceUnitInput.value}`;styleGridSizeFriendly.value=t}styleGridShiftX.addEventListener("input",function(){Re().attr("dx",this.value),layerIsOn("toggleGrid")&&drawGrid()});styleGridShiftY.addEventListener("input",function(){Re().attr("dy",this.value),layerIsOn("toggleGrid")&&drawGrid()});styleShiftX.addEventListener("input",Qa);styleShiftY.addEventListener("input",Qa);function Qa(){const e=styleShiftX.value||0,t=styleShiftY.value||0;Re().attr("transform",`translate(${e},${t})`)}styleRescaleMarkers.addEventListener("change",function(){markers.attr("rescale",+this.checked),invokeActiveZooming()});styleCoastlineAuto.addEventListener("change",function(){coastline.select("#sea_island").attr("auto-filter",+this.checked),styleFilter.style.display=this.checked?"none":"block",invokeActiveZooming()});styleOceanFill.addEventListener("input",function(){oceanLayers.select("rect").attr("fill",this.value),styleOceanFillOutput.value=this.value});styleOceanPattern.addEventListener("change",function(){var e;(e=document.getElementById("oceanicPattern"))==null||e.setAttribute("href",this.value)});styleOceanPatternOpacity.addEventListener("input",function(){document.getElementById("oceanicPattern").setAttribute("opacity",this.value),styleOceanPatternOpacityOutput.value=this.value});outlineLayers.addEventListener("change",function(){oceanLayers.selectAll("path").remove(),oceanLayers.attr("layers",this.value),OceanLayers()});styleHeightmapScheme.addEventListener("change",function(){terrs.attr("scheme",this.value),drawHeightmap()});styleHeightmapTerracingInput.addEventListener("input",function(){terrs.attr("terracing",this.value),drawHeightmap()});styleHeightmapSkipInput.addEventListener("input",function(){terrs.attr("skip",this.value),drawHeightmap()});styleHeightmapSimplificationInput.addEventListener("input",function(){terrs.attr("relax",this.value),drawHeightmap()});styleHeightmapCurve.addEventListener("change",function(){terrs.attr("curve",this.value),drawHeightmap()});styleReliefSet.addEventListener("change",function(){terrain.attr("set",this.value),ReliefIcons(),layerIsOn("toggleRelief")||toggleRelief()});styleReliefSizeInput.addEventListener("change",function(){terrain.attr("size",this.value),styleReliefSizeOutput.value=this.value,ReliefIcons(),layerIsOn("toggleRelief")||toggleRelief()});styleReliefDensityInput.addEventListener("change",function(){terrain.attr("density",this.value),styleReliefDensityOutput.value=this.value,ReliefIcons(),layerIsOn("toggleRelief")||toggleRelief()});styleTemperatureFillOpacityInput.addEventListener("input",function(){temperature.attr("fill-opacity",this.value),styleTemperatureFillOpacityOutput.value=this.value});styleTemperatureFontSizeInput.addEventListener("input",function(){temperature.attr("font-size",this.value+"px"),styleTemperatureFontSizeOutput.value=this.value+"px"});styleTemperatureFillInput.addEventListener("input",function(){temperature.attr("fill",this.value),styleTemperatureFillOutput.value=this.value});stylePopulationRuralStrokeInput.addEventListener("input",function(){population.select("#rural").attr("stroke",this.value),stylePopulationRuralStrokeOutput.value=this.value});stylePopulationUrbanStrokeInput.addEventListener("input",function(){population.select("#urban").attr("stroke",this.value),stylePopulationUrbanStrokeOutput.value=this.value});styleCompassSizeInput.addEventListener("input",function(){styleCompassSizeOutput.value=this.value,ta()});styleCompassShiftX.addEventListener("input",ta);styleCompassShiftY.addEventListener("input",ta);function ta(){const e=`translate(${styleCompassShiftX.value} ${styleCompassShiftY.value}) scale(${styleCompassSizeInput.value})`;compass.select("use").attr("transform",e)}styleLegendColItems.addEventListener("input",function(){styleLegendColItemsOutput.value=this.value,legend.select("#legendBox").attr("data-columns",this.value),redrawLegend()});styleLegendBack.addEventListener("input",function(){styleLegendBackOutput.value=this.value,legend.select("#legendBox").attr("fill",this.value)});styleLegendOpacity.addEventListener("input",function(){styleLegendOpacityOutput.value=this.value,legend.select("#legendBox").attr("fill-opacity",this.value)});styleSelectFont.addEventListener("change",ps);function ps(){const e=styleSelectFont.value;Re().attr("font-family",e),styleElementSelect.value==="legend"&&redrawLegend()}styleShadowInput.addEventListener("input",function(){Re().style("text-shadow",this.value)});styleFontAdd.addEventListener("click",function(){addFontNameInput.value="",addFontURLInput.value="",$("#addFontDialog").dialog({title:"Add custom font",width:"26em",position:{my:"center",at:"center",of:"svg"},buttons:{Add:function(){const e=addFontNameInput.value,t=addFontURLInput.value,n=addFontMethod.value;if(!e)return se("Please provide a font name",!1,"error");if(n==="fontURL"?fonts.find(r=>r.family===e&&r.src===t):fonts.find(r=>r.family===e))return se("The font is already added",!1,"error");n==="fontURL"?addWebFont(e,t):n==="googleFont"?addGoogleFont(e):n==="localFont"&&addLocalFont(e),addFontNameInput.value="",addFontURLInput.value="",$(this).dialog("close")},Cancel:function(){$(this).dialog("close")}}})});addFontMethod.addEventListener("change",function(){addFontURLInput.style.display=this.value==="fontURL"?"inline":"none"});styleFontSize.addEventListener("change",function(){aa(Re(),+this.value)});styleFontPlus.addEventListener("click",function(){const e=+Re().attr("data-size")+1;aa(Re(),Math.min(e,999))});styleFontMinus.addEventListener("click",function(){const e=+Re().attr("data-size")-1;aa(Re(),Math.max(e,1))});function aa(e,t){styleFontSize.value=t;const i=(r=>r==="labels"?Math.max(O((t+t/scale)/2,2),1):r==="coordinates"?O(t/scale**.8,2):t)(styleElementSelect.value);e.attr("data-size",t).attr("font-size",i),styleElementSelect.value==="legend"&&redrawLegend()}styleRadiusInput.addEventListener("change",function(){na(+this.value)});styleRadiusPlus.addEventListener("click",function(){const e=Math.max(O(Re().attr("size")*1.1,2),.2);na(e)});styleRadiusMinus.addEventListener("click",function(){const e=Math.max(O(Re().attr("size")*.9,2),.2);na(e)});function na(e,t){const n=t?burgIcons.select("#"+t):Re(),i=n.attr("id");n.attr("size",e),n.selectAll("circle").each(function(){this.setAttribute("r",e)}),styleRadiusInput.value=e,burgLabels.select("g#"+i).selectAll("text").each(function(){this.setAttribute("dy",`${e*-1.5}px`)}),Tt(e*2,i)}styleIconSizeInput.addEventListener("change",function(){Tt(+this.value)});styleIconSizePlus.addEventListener("click",function(){const e=Math.max(O(Re().attr("size")*1.1,2),.2);Tt(e)});styleIconSizeMinus.addEventListener("click",function(){const e=Math.max(O(Re().attr("size")*.9,2),.2);Tt(e)});function Tt(e,t){const n=t?anchors.select("#"+t):Re();if(!n.size()){console.warn(`Group ${t} not found. Can not set icon size!`);return}const i=+n.attr("size"),r=(e-i)/2;n.attr("size",e),n.selectAll("use").each(function(){const c=+this.getAttribute("x"),f=+this.getAttribute("y");this.setAttribute("x",c-r),this.setAttribute("y",f-r),this.setAttribute("width",e),this.setAttribute("height",e)}),styleIconSizeInput.value=e}styleStatesBodyOpacity.addEventListener("input",function(){styleStatesBodyOpacityOutput.value=this.value,statesBody.attr("opacity",this.value)});styleStatesBodyFilter.addEventListener("change",function(){statesBody.attr("filter",this.value)});styleStatesHaloWidth.addEventListener("input",function(){styleStatesHaloWidthOutput.value=this.value,statesHalo.attr("data-width",this.value).attr("stroke-width",this.value)});styleStatesHaloOpacity.addEventListener("input",function(){styleStatesHaloOpacityOutput.value=this.value,statesHalo.attr("opacity",this.value)});styleStatesHaloBlur.addEventListener("input",function(){styleStatesHaloBlurOutput.value=this.value;const e=+this.value>0?`blur(${this.value}px)`:null;statesHalo.attr("filter",e)});styleArmiesFillOpacity.addEventListener("input",function(){armies.attr("fill-opacity",this.value),styleArmiesFillOpacityOutput.value=this.value});styleArmiesSize.addEventListener("input",function(){armies.attr("box-size",this.value).attr("font-size",this.value*2),styleArmiesSizeOutput.value=this.value,armies.selectAll("g").remove(),pack.states.forEach(e=>{!e.i||e.removed||!e.military.length||Military.drawRegiments(e.military,e.i)})});emblemsStateSizeInput.addEventListener("change",()=>drawEmblems());emblemsProvinceSizeInput.addEventListener("change",()=>drawEmblems());emblemsBurgSizeInput.addEventListener("change",()=>drawEmblems());mapFilters.addEventListener("click",ms);function ms(e){if(e.target.tagName!=="BUTTON")return;const t=e.target;if(svg.attr("data-filter",null).attr("filter",null),t.classList.contains("pressed"))return t.classList.remove("pressed");mapFilters.querySelectorAll(".pressed").forEach(n=>n.classList.remove("pressed")),t.classList.add("pressed"),svg.attr("data-filter",t.id).attr("filter","url(#filter-"+t.id+")")}document.querySelectorAll(".sortable").forEach(function(e){e.on("click",function(){fs(this)})});function fs(e){const t=e.classList.contains("alphabetically")?"name":"number";let n=e.className.includes("-down")?"-up":"-down";!e.className.includes("icon-sort")&&t==="name"&&(n="-up");const i=e.parentNode;i.querySelectorAll("div.sortable").forEach(r=>{r.classList.forEach(c=>{c.includes("icon-sort")&&r.classList.remove(c)})}),e.classList.add("icon-sort-"+t+n),ys(i)}function ys(e){const t=e.querySelector("div[class*='icon-sort']");if(!t)return;const n=t.dataset.sortby,i=t.classList.contains("alphabetically"),r=t.className.includes("-down")?-1:1,c=e.nextElementSibling;Array.from(c.children).sort((z,m)=>{const b=i?z.dataset[n]:+z.dataset[n],A=i?m.dataset[n]:+m.dataset[n];return(b>A?1:b<A?-1:0)*r}).forEach(z=>c.appendChild(z))}function $a(e,t=1){for(;ne(e+t);)t++;return e+t}toolsContent.addEventListener("click",function(e){if(customization)return se("Please exit the customization mode first",!1,"warning");if(!["BUTTON","I"].includes(e.target.tagName))return;const t=e.target.id;if(t==="editHeightmapButton"?editHeightmap():t==="editBiomesButton"?editBiomes():t==="editStatesButton"?editStates():t==="editProvincesButton"?editProvinces():t==="editDiplomacyButton"?editDiplomacy():t==="editCulturesButton"?editCultures():t==="editReligions"?editReligions():t==="editEmblemButton"?bs():t==="editNamesBaseButton"?editNamesbase():t==="editUnitsButton"?editUnits():t==="editNotesButton"?editNotes():t==="editZonesButton"?editZones():t==="overviewChartsButton"?Os():t==="overviewBurgsButton"?overviewBurgs():t==="overviewRiversButton"?overviewRivers():t==="overviewMilitaryButton"?overviewMilitary():t==="overviewMarkersButton"?overviewMarkers():t==="overviewCellsButton"&&Fs(),e.target.parentNode.id==="regenerateFeature"){if(sessionStorage.getItem("regenerateFeatureDontAsk"))return ua(e,t);alertMessage.innerHTML="Regeneration will remove all the custom changes for the element.<br /><br />Are you sure you want to proceed?",$("#alert").dialog({resizable:!1,title:"Regenerate element",buttons:{Proceed:function(){ua(e,t),$(this).dialog("close")},Cancel:function(){$(this).dialog("close")}},open:function(){const i='<span><input id="dontAsk" class="checkbox" type="checkbox"><label for="dontAsk" class="checkbox-label dontAsk"><i>do not ask again</i></label><span>';this.parentElement.querySelector(".ui-dialog-buttonpane").insertAdjacentHTML("afterbegin",i)},close:function(){const i=this.parentElement.querySelector(".checkbox");i!=null&&i.checked&&sessionStorage.setItem("regenerateFeatureDontAsk",!0),$(this).dialog("destroy")}})}t==="configRegenerateMarkers"&&Ds(),t==="addLabel"?Ls():t==="addBurgTool"?Rs():t==="addRiver"?Ts():t==="addRoute"?Hs():t==="addMarker"?Ns():t==="openSubmapMenu"?UISubmap.openSubmapMenu():t==="openResampleMenu"&&UISubmap.openResampleMenu()});function ua(e,t){t==="regenerateStateLabels"?(BurgsAndStates.drawStateLabels(),layerIsOn("toggleLabels")||toggleLabels()):t==="regenerateReliefIcons"?(ReliefIcons(),layerIsOn("toggleRelief")||toggleRelief()):t==="regenerateRoutes"?(Routes.regenerate(),layerIsOn("toggleRoutes")||toggleRoutes()):t==="regenerateRivers"?vs():t==="regeneratePopulation"?ks():t==="regenerateStates"?ws():t==="regenerateProvinces"?Ss():t==="regenerateBurgs"?As():t==="regenerateEmblems"?zs():t==="regenerateReligions"?xs():t==="regenerateCultures"?Cs():t==="regenerateMilitary"?Bs():t==="regenerateIce"?Ms():t==="regenerateMarkers"?_a():t==="regenerateZones"&&Es(e)}async function bs(){var i,r;let e,t,n;if((i=pack.states[1])!=null&&i.coa)e="state",t="stateCOA1",n=pack.states[1];else if((r=pack.burgs[1])!=null&&r.coa)e="burg",t="burgCOA1",n=pack.burgs[1];else{se("No emblems to edit, please generate states and burgs first",!1,"error");return}await COArenderer.trigger(t,n.coa),editEmblem(e,t,n)}function vs(){Rivers.generate(),Lakes.defineGroup(),Rivers.specify(),layerIsOn("toggleRivers")?drawRivers():toggleRivers()}function ks(){rankCells(),pack.burgs.forEach(e=>{if(!e.i||e.removed||e.lock)return;const t=e.cell;e.population=O(Math.max((pack.cells.s[t]+pack.cells.road[t]/2)/8+e.i/1e3+t%100/1e3,.1),3),e.capital&&(e.population=e.population*1.3),e.port&&(e.population=e.population*1.3),e.population=O(e.population*gauss(2,3,.6,20,3),3)})}function ws(){var m,b,A;const e=Jt();Math.random=aleaPRNG(e);const t=+regionsOutput.value,n=pack.burgs.filter(u=>u.i&&!u.removed);if(!n.length)return se("There are no any burgs to generate states. Please create burgs first",!1,"error");if(n.length<t&&se(`Not enough burgs to generate ${t} states. Will generate only ${n.length} states`,!1,"warn"),n.filter(u=>u.capital).forEach(u=>{moveBurgToGroup(u.i,"towns"),u.capital=0}),document.querySelectorAll("[id^=stateCOA]").forEach(u=>u.remove()),document.querySelectorAll("[id^=provinceCOA]").forEach(u=>u.remove()),emblems.selectAll("use").remove(),unfog(),!t){se("Cannot generate zero states. Please check the <i>States Number</i> option",!1,"warn"),pack.states=pack.states.slice(0,1),pack.states[0].diplomacy=[],pack.provinces=[0],pack.cells.state=new Uint16Array(pack.cells.i.length),borders.selectAll("path").remove(),regions.selectAll("path").remove(),labels.select("#states").selectAll("text"),defs.select("#textPaths").selectAll("path[id*='stateLabel']").remove(),document.getElementById("burgsOverviewRefresh").offsetParent&&burgsOverviewRefresh.click(),document.getElementById("statesEditorRefresh").offsetParent&&statesEditorRefresh.click();return}const i=n.map((u,C)=>[u,u.population*Math.random()]).sort((u,C)=>C[1]-u[1]).map(u=>u[0]),r=d3.quadtree(),c=pack.states[0].name,f=Math.min(t,n.length)+1;let z=(graphWidth+graphHeight)/2/f;pack.states=d3.range(f).map(u=>{if(!u)return{i:u,name:c};let C=null;for(const a of i){const{x:w,y:S}=a;if(r.find(w,S,z)===void 0){a.capital=1,C=a,r.add([w,S]),moveBurgToGroup(a.i,"cities");break}z=Math.max(z-1,1)}const g=C.culture,p=C.name.length<9&&C.cell%5===0?C.name:Names.getCulture(g,3,6,"",0),B=Names.getState(p,g),d=[1,2,3,4].includes(pack.cells.biome[C.cell])?"Nomadic":pack.cultures[g].type==="Nomadic"?"Generic":pack.cultures[g].type,s=O(Math.random()*powerInput.value+1,1),o=pack.cultures[g].type,l=COA.generate(C.coa,.3,null,o);return l.shield=C.coa.shield,{i:u,name:B,type:d,capital:C.i,center:C.cell,culture:g,expansionism:s,coa:l}}),BurgsAndStates.expandStates(),BurgsAndStates.normalizeStates(),BurgsAndStates.collectStatistics(),BurgsAndStates.assignColors(),BurgsAndStates.generateCampaigns(),BurgsAndStates.generateDiplomacy(),BurgsAndStates.defineStateForms(),BurgsAndStates.generateProvinces(!0),layerIsOn("toggleStates")?drawStates():toggleStates(),layerIsOn("toggleBorders")?drawBorders():toggleBorders(),BurgsAndStates.drawStateLabels(),Military.generate(),layerIsOn("toggleEmblems")&&drawEmblems(),(m=document.getElementById("burgsOverviewRefresh"))!=null&&m.offsetParent&&burgsOverviewRefresh.click(),(b=document.getElementById("statesEditorRefresh"))!=null&&b.offsetParent&&statesEditorRefresh.click(),(A=document.getElementById("militaryOverviewRefresh"))!=null&&A.offsetParent&&militaryOverviewRefresh.click()}function Ss(){unfog(),BurgsAndStates.generateProvinces(!0),drawBorders(),layerIsOn("toggleProvinces")&&drawProvinces(),document.querySelectorAll("[id^=provinceCOA]").forEach(e=>e.remove()),emblems.selectAll("use").remove(),layerIsOn("toggleEmblems")&&drawEmblems()}function As(){var b,A;const{cells:e,states:t}=pack,n=pack.burgs.filter(u=>u.lock);rankCells(),e.burg=new Uint16Array(e.i.length);const i=pack.burgs=[0];t.filter(u=>u.i).forEach(u=>u.capital=0),pack.provinces.filter(u=>u.i).forEach(u=>u.burg=0);const r=d3.quadtree();for(let u=0;u<n.length;u++){const C=i.length,g=n[u];if(g.i=C,i.push(g),r.add([g.x,g.y]),e.burg[g.cell]=C,g.capital){const p=g.state;t[p].capital=C,t[p].center=g.cell}}const c=new Int16Array(e.s.map(u=>u*Math.random())),f=e.i.filter(u=>c[u]>0&&e.culture[u]).sort((u,C)=>c[C]-c[u]),z=manorsInput.value==="1000"?O(f.length/5/(grid.points.length/1e4)**.8)+t.length:+manorsInput.value+t.length,m=(graphWidth+graphHeight)/150/(z**.7/66);for(let u=0;u<f.length&&i.length<z;u++){const C=i.length,g=f[u],[p,B]=e.p[g],k=m*gauss(1,.3,.2,2,2);if(r.find(p,B,k)!==void 0)continue;const d=e.state[g],s=d&&!t[d].capital;s&&(t[d].capital=C,t[d].center=g);const o=e.culture[g],l=Names.getCulture(o);i.push({cell:g,x:p,y:B,state:d,i:C,culture:o,name:l,capital:s,feature:e.f[g]}),r.add([p,B]),e.burg[g]=C}t.filter(u=>u.i&&!u.removed&&!u.capital).forEach(u=>{const C=addBurg([e.p[u.center][0],e.p[u.center][1]]);u.capital=C,u.center=pack.burgs[C].cell,pack.burgs[C].capital=1,pack.burgs[C].state=u.i,moveBurgToGroup(C,"cities")}),pack.features.forEach(u=>{u.port&&(u.port=0)}),BurgsAndStates.specifyBurgs(),BurgsAndStates.defineBurgFeatures(),BurgsAndStates.drawBurgs(),Routes.regenerate(),document.querySelectorAll("[id^=burgCOA]").forEach(u=>u.remove()),emblems.selectAll("use").remove(),layerIsOn("toggleEmblems")&&drawEmblems(),(b=document.getElementById("burgsOverviewRefresh"))!=null&&b.offsetParent&&burgsOverviewRefresh.click(),(A=document.getElementById("statesEditorRefresh"))!=null&&A.offsetParent&&statesEditorRefresh.click()}function zs(){document.querySelectorAll("[id^=stateCOA]").forEach(e=>e.remove()),document.querySelectorAll("[id^=provinceCOA]").forEach(e=>e.remove()),document.querySelectorAll("[id^=burgCOA]").forEach(e=>e.remove()),emblems.selectAll("use").remove(),pack.states.forEach(e=>{if(!e.i||e.removed)return;const t=pack.cultures[e.culture].type;e.coa=COA.generate(null,null,null,t),e.coa.shield=COA.getShield(e.culture,null)}),pack.burgs.forEach(e=>{if(!e.i||e.removed)return;const t=pack.states[e.state];let n=t?.25:0;e.capital?n+=.1:e.port&&(n-=.1),t&&e.culture!==t.culture&&(n-=.25),e.coa=COA.generate(t?t.coa:null,n,null,e.type),e.coa.shield=COA.getShield(e.culture,t?e.state:0)}),pack.provinces.forEach(e=>{if(!e.i||e.removed)return;const t=e.burg?pack.burgs[e.burg]:pack.states[e.state];let n=!1;e.burg||(n=V(.2),e.formName==="Colony"?n=V(.95):e.formName==="Island"?n=V(.6):e.formName==="Islands"?n=V(.5):e.formName==="Territory"?n=V(.4):e.formName==="Land"&&(n=V(.3)));const i=e.burg&&e.name.slice(0,3)===t.name.slice(0,3),r=n?0:i?.8:.4,c=pack.cells.culture[e.center],f=BurgsAndStates.getType(e.center,t.port);e.coa=COA.generate(t.coa,r,n,f),e.coa.shield=COA.getShield(c,e.state)}),layerIsOn("toggleEmblems")&&drawEmblems()}function xs(){Religions.generate(),layerIsOn("toggleReligions")?drawReligions():toggleReligions()}function Cs(){Cultures.generate(),Cultures.expand(),BurgsAndStates.updateCultures(),Religions.updateCultures(),layerIsOn("toggleCultures")?drawCultures():toggleCultures(),refreshAllEditors()}function Bs(){Military.generate(),layerIsOn("toggleMilitary")||toggleMilitary(),document.getElementById("militaryOverviewRefresh").offsetParent&&militaryOverviewRefresh.click()}function Ms(){layerIsOn("toggleIce")||toggleIce(),ice.selectAll("*").remove(),drawIce()}function _a(){Markers.regenerate(),turnButtonOn("toggleMarkers"),drawMarkers(),document.getElementById("markersOverviewRefresh").offsetParent&&markersOverviewRefresh.click()}function Es(e){ge(e)?Qn("Please provide zones number multiplier",{default:1,step:.01,min:0,max:100},n=>t(n)):t(gauss(1,.5,.6,5,2));function t(n){zones.selectAll("g").remove(),addZones(n),document.getElementById("zonesEditorRefresh").offsetParent&&zonesEditorRefresh.click(),layerIsOn("toggleZones")||toggleZones()}}function at(){addFeature.querySelectorAll("button.pressed").forEach(e=>e.classList.remove("pressed")),Wa(),ct()}function Ls(){if(document.getElementById("addLabel").classList.contains("pressed")){at();return}addFeature.querySelectorAll("button.pressed").forEach(t=>t.classList.remove("pressed")),addLabel.classList.add("pressed"),closeDialogs(".stable"),viewbox.style("cursor","crosshair").on("click",Is),se("Click on map to place label. Hold Shift to add multiple",!0),layerIsOn("toggleLabels")||toggleLabels()}function Is(){const e=d3.mouse(this),t=Te(e[0],e[1]),n=pack.cells.culture[t],i=Names.getCulture(n),r=$a("label"),c=labelGroupSelect.value,f=["","states","burgLabels"].includes(c)?"#addedLabels":"#"+c;let z=labels.select(f);z.size()||(z=labels.append("g").attr("id","addedLabels").attr("fill","#3e3e4b").attr("opacity",1).attr("stroke","#3a3a3a").attr("stroke-width",0).attr("font-family","Almendra SC").attr("font-size",18).attr("data-size",18).attr("filter",null));const m=z.append("text").attr("x",0).attr("x",0).text(i),b=m.node().getBBox().width,A=b/-2;m.remove(),z.classed("hidden",!1),z.append("text").attr("id",r).append("textPath").attr("xlink:href","#textPath_"+r).attr("startOffset","50%").attr("font-size","100%").append("tspan").attr("x",A).text(i),defs.select("#textPaths").append("path").attr("id","textPath_"+r).attr("d",`M${e[0]-b},${e[1]} h${b*2}`),d3.event.shiftKey===!1&&at()}function Rs(){at(),document.getElementById("addBurgTool").classList.add("pressed"),overviewBurgs(),document.getElementById("addNewBurg").click()}function Ts(){if(document.getElementById("addRiver").classList.contains("pressed")){at(),document.getElementById("addNewRiver").classList.remove("pressed");return}addFeature.querySelectorAll("button.pressed").forEach(t=>t.classList.remove("pressed")),addRiver.classList.add("pressed"),document.getElementById("addNewRiver").classList.add("pressed"),closeDialogs(".stable"),viewbox.style("cursor","crosshair").on("click",Ps),se("Click on map to place new river or extend an existing one. Hold Shift to place multiple rivers",!0,"warn"),layerIsOn("toggleRivers")||toggleRivers()}function Ps(){var L;const{cells:e,rivers:t}=pack;let n=Te(...d3.mouse(this));if(e.r[n])return se("There is already a river here",!1,"error");if(e.h[n]<20)return se("Cannot create river in water cell",!1,"error");if(e.b[n])return;const{alterHeights:i,resolveDepressions:r,addMeandering:c,getRiverPath:f,getBasin:z,getName:m,getType:b,getWidth:A,getOffset:u,getApproximateLength:C}=Rivers,g=[];let p=t.length?De(t).i+1:1,B=p;const k=grid.cells.prec[e.g[n]];e.fl[n]=k;const d=i();for(r(d);n;){e.r[n]=p,g.push(n);const M=e.c[n].sort((U,F)=>d[U]-d[F])[0];if(d[n]<=d[M])return se(`Cell ${n} is depressed, river cannot flow further`,!1,"error");if(d[M]<20){g.push(M);const U=pack.features[e.f[M]];U.type==="lake"&&(U.outlet&&(B=U.outlet),U.inlets?U.inlets.push(p):U.inlets=[p]);break}if(e.b[M]){e.fl[M]+=e.fl[n],g.push(-1);break}if(!e.r[M]){e.fl[M]+=e.fl[n],n=M;continue}const I=e.r[M],H=t.find(U=>U.i===I),G=(H==null?void 0:H.cells)||e.i.filter(U=>e.r[U]===I),D=G.filter(U=>d[U]>d[M]);if(g.length<=D.length){e.conf[M]+=e.fl[n],g.push(M),B=I;break}(L=document.getElementById("river"+I))==null||L.remove(),g.forEach(U=>e.r[U]=I),G.forEach(U=>{d[U]>d[M]?(e.r[U]=0,e.fl[U]=grid.cells.prec[e.g[U]]):(g.push(U),e.fl[U]+=e.fl[n])}),p=I;break}const s=t.find(M=>M.i===p),o=g[0],l=g[g.length-2],a=O(1/(pointsInput.dataset.cells/1e4)**.25,2),w=(s==null?void 0:s.widthFactor)||(!B||B===p?a*1.2:a),S=c(g),h=e.fl[l],v=C(S),E=A(u(h,S.length,w));if(s)s.source=o,s.length=v,s.discharge=h,s.width=E,s.cells=g;else{const M=z(B),I=m(l),H=b({i:p,length:v,parent:B});t.push({i:p,source:o,mouth:l,discharge:h,length:v,width:E,widthFactor:w,sourceWidth:0,parent:B,cells:g,basin:M,name:I,type:H})}lineGen.curve(d3.curveCatmullRom.alpha(.1));const P=f(S,w),T="river"+p;viewbox.select("#rivers").append("path").attr("id",T).attr("d",P),d3.event.shiftKey===!1&&(Lakes.cleanupLakeData(),at(),document.getElementById("addNewRiver").classList.remove("pressed"),addNewRiver.offsetParent&&riversOverviewRefresh.click())}function Hs(){if(document.getElementById("addRoute").classList.contains("pressed")){at();return}addFeature.querySelectorAll("button.pressed").forEach(t=>t.classList.remove("pressed")),addRoute.classList.add("pressed"),closeDialogs(".stable"),viewbox.style("cursor","crosshair").on("click",Us),se("Click on map to add a first control point",!0),layerIsOn("toggleRoutes")||toggleRoutes()}function Us(){at();const e=d3.mouse(this),t=$a("route");elSelected=routes.select("g").append("path").attr("id",t).attr("data-new",1).attr("d",`M${e[0]},${e[1]}`),editRoute(!0)}function Ns(){var t;if((t=document.getElementById("addMarker"))==null?void 0:t.classList.contains("pressed")){at();return}addFeature.querySelectorAll("button.pressed").forEach(n=>n.classList.remove("pressed")),addMarker.classList.add("pressed"),markersAddFromOverview.classList.add("pressed"),viewbox.style("cursor","crosshair").on("click",Ks),se("Click on map to add a marker. Hold Shift to add multiple",!0),layerIsOn("toggleMarkers")||toggleMarkers()}function Ks(){var u,C;const{markers:e}=pack,t=d3.mouse(this),n=O(t[0],2),i=O(t[1],2),r=Te(t[0],t[1]),z=(e.length&&((C=(u=elSelected==null?void 0:elSelected.node())==null?void 0:u.parentElement)==null?void 0:C.id)==="markers"?e.find(g=>g.i===+elSelected.attr("id").slice(6)):null)||{icon:"\u2753"},m=Markers.add({...z,x:n,y:i,cell:r}),b=document.getElementById("markers"),A=+b.getAttribute("rescale");b.insertAdjacentHTML("beforeend",drawMarker(m,A)),d3.event.shiftKey===!1&&(document.getElementById("markerAdd").classList.remove("pressed"),document.getElementById("markersAddFromOverview").classList.remove("pressed"),at())}function Ds(){e();function e(){const{markers:n}=pack,i=Markers.getConfig(),r=`<thead style='font-weight:bold'><tr>
<td data-tip="Marker type name">Type</td>
<td data-tip="Marker icon">Icon</td>
<td data-tip="Marker number multiplier">Multiplier</td>
<td data-tip="Number of markers of that type on the current map">Number</td>
</tr></thead>`,c=i.map(({type:z,icon:m,multiplier:b},A)=>{const u=`markerIconInput${A}`;return`<tr>
<td><input value="${z}" /></td>
<td style="position: relative">
<input id="${u}" style="width: 5em" value="${m}" />
<i class="icon-edit pointer" style="position: absolute; margin:.4em 0 0 -1.4em; font-size:.85em"></i>
</td>
<td><input type="number" min="0" max="100" step="0.1" value="${b}" /></td>
<td style="text-align:center">${n.filter(C=>C.type===z).length}</td>
</tr>`}),f=`<table class="table">${r}<tbody>${c.join("")}</tbody></table>`;alertMessage.innerHTML=f,alertMessage.querySelectorAll("i").forEach(z=>{z.addEventListener("click",function(){const m=this.previousElementSibling;selectIcon(m.value,b=>m.value=b)})})}const t=()=>{const n=alertMessage.querySelectorAll("tbody > tr"),i=Array.from(n).map(f=>{const z=f.querySelectorAll("input");return{type:z[0].value,icon:z[1].value,multiplier:parseFloat(z[2].value)}}),c=Markers.getConfig().map((f,z)=>{const{type:m,icon:b,multiplier:A}=i[z];return{...f,type:m,icon:b,multiplier:A}});Markers.setConfig(c)};$("#alert").dialog({resizable:!1,title:"Markers generation settings",position:{my:"left top",at:"left+10 top+10",of:"svg",collision:"fit"},buttons:{Regenerate:()=>{t(),_a(),e()},Close:function(){$(this).dialog("close")}},open:function(){const n=$(this).dialog("widget").find(".ui-dialog-buttonset > button");n[0].addEventListener("mousemove",()=>se("Apply changes and regenerate markers")),n[1].addEventListener("mousemove",()=>se("Close the window"))},close:function(){$(this).dialog("destroy")}})}function Fs(){$("#cellInfo").dialog({resizable:!1,width:"22em",title:"Cell Details",position:{my:"right top",at:"right-10 top+10",of:"svg",collision:"fit"}})}async function Os(){(await St(()=>import("./charts-overview.js_v_1.87.711ec26c.js"),[])).open()}window.ThreeD=function(){const e={scale:50,lightness:.7,shadow:.5,sun:{x:100,y:600,z:1e3},rotateMesh:0,rotateGlobe:.5,skyColor:"#9ecef5",waterColor:"#466eab",extendedWater:0,labels3d:0,resolution:2};let t,n,i,r,c,f,z,m,b,A,u,C,g,p,B,k=[],d=[],s=[];const o=document.createElement("canvas").getContext("2d"),l=async function(_,oe="viewMesh"){return e.isOn=!0,e.isGlobe=oe==="viewGlobe",e.isGlobe?le(_):G(_)},a=function(){Z(),n.remove(b),t.setSize(t.domElement.width,t.domElement.height),e.isGlobe?Y():te(graphWidth,graphHeight,grid.cellsX,grid.cellsY),pe()},w=function(){e.isGlobe?Y():ee()},S=function(){cancelAnimationFrame(c),z.dispose(),m.dispose(),f.dispose(),C&&C.dispose(),g&&g.dispose(),Z(),t.renderLists.dispose(),t.dispose(),n.remove(b),n.remove(u),n.remove(A),n.remove(p),t=void 0,n=void 0,r=void 0,i=void 0,f=void 0,z=void 0,m=void 0,b=void 0,ThreeD.options.isOn=!1},h=function(_){e.scale=_,m.vertices.forEach((oe,ce)=>oe.z=q(ce)),m.verticesNeedUpdate=!0,m.computeVertexNormals(),m.verticesNeedUpdate=!1,a()},v=function(_){e.lightness=_,A.intensity=_,pe()},E=function(_,oe,ce){e.sun={x:_,y:oe,z:ce},u.position.set(_,oe,ce),pe()},P=function(_){e.isGlobe?e.rotateGlobe=_:e.rotateMesh=_,r.autoRotateSpeed=_;const oe=!r.autoRotate&&Boolean(_),ce=r.autoRotate&&!Boolean(_);r.autoRotate=Boolean(_),oe&&ke(),ce&&cancelAnimationFrame(c)},T=function(){e.extendedWater?(n.background=null,n.fog=null,n.remove(p)):X(graphWidth,graphHeight),e.extendedWater=!e.extendedWater,a()},R=function(){e.labels3d=!e.labels3d,e.labels3d?j().then(()=>w()):(Z(),w())},L=function(_,oe){e.skyColor=_,n.background=n.fog.color=new THREE.Color(_),e.waterColor=oe,g.color=new THREE.Color(oe),pe()},M=function(_){e.resolution=_,w()},I=async function(){const _=t.domElement.toDataURL("image/jpeg"),oe=document.createElement("a");oe.download=getFileName()+".jpeg",oe.href=_,oe.click(),se('Screenshot is saved. Open "Downloads" screen (CTRL + J) to check',!0,"success",7e3),window.setTimeout(()=>window.URL.revokeObjectURL(_),5e3)},H=async function(){downloadFile(await W(),getFileName()+".obj","text/plain;charset=UTF-8")};async function G(_){return await He()?(n=new THREE.Scene,A=new THREE.AmbientLight(13421772,e.lightness),n.add(A),u=new THREE.SpotLight(13421772,.8,2e3,.8,0,0),u.position.set(e.sun.x,e.sun.y,e.sun.z),u.castShadow=!0,n.add(u),t=new THREE.WebGLRenderer({canvas:_,antialias:!0,preserveDrawingBuffer:!0}),t.setSize(_.width,_.height),t.shadowMap.enabled=!0,e.extendedWater&&X(graphWidth,graphHeight),te(graphWidth,graphHeight,grid.cellsX,grid.cellsY),i=new THREE.PerspectiveCamera(70,_.width/_.height,.1,2e3),i.position.set(0,O(svgWidth/3.5),500),r=await Be(i,_),r.enableKeys=!1,r.minDistance=10,r.maxDistance=1e3,r.maxPolarAngle=Math.PI/2,r.autoRotate=Boolean(e.rotateMesh),r.autoRotateSpeed=e.rotateMesh,r.autoRotate&&ke(),r.addEventListener("change",pe),!0):(se("Cannot load 3d library",!1,"error",4e3),!1)}function D(_,oe,ce){const ye=new THREE.TextureLoader().load(_);ye.anisotropy=t.getMaxAnisotropy();const Se=new THREE.SpriteMaterial({map:ye}),ve=new THREE.Sprite(Se);return ve.scale.set(oe,ce,1),ve.renderOrder=1,ve}async function U({text:_,font:oe,size:ce,color:ye,quality:Se}){return o.font=`${ce*Se}px ${oe}`,o.canvas.width=o.measureText(_).width,o.canvas.height=ce*Se*1.25,o.clearRect(0,0,o.canvas.width,o.canvas.height),o.font=`${ce*Se}px ${oe}`,o.fillStyle=ye,o.fillText(_,0,ce*Se),D(o.canvas.toDataURL(),o.canvas.width/Se,o.canvas.height/Se)}function F(_,oe){const ce=_-graphWidth/2,ye=oe-graphHeight/2;B.ray.origin.x=ce,B.ray.origin.z=ye;const Se=B.intersectObject(b)[0].point.y;return[ce,Se,ye]}async function j(){var nt;B=new THREE.Raycaster,B.set(new THREE.Vector3(0,1e3,0),new THREE.Vector3(0,-1,0));const _=viewbox.select("#labels #states"),oe=burgLabels.select("#cities"),ce=burgLabels.select("#towns");burgIcons.select("#cities"),burgIcons.select("#towns");const ye={font:_.attr("font-family"),size:+_.attr("data-size"),color:_.attr("fill"),elevation:20,quality:20},Se={font:oe.attr("font-family"),size:+oe.attr("data-size"),color:oe.attr("fill"),elevation:10,quality:20,iconSize:1,iconColor:"#666",line:10-oe.attr("data-size")/2},ve={font:ce.attr("font-family"),size:+ce.attr("data-size"),color:ce.attr("fill"),elevation:5,quality:30,iconSize:.5,iconColor:"#666",line:5-ce.attr("data-size")/2},Ue=new THREE.MeshPhongMaterial({color:Se.iconColor}),Ve=new THREE.MeshPhongMaterial({color:ve.iconColor}),Oe=new THREE.CylinderGeometry(Se.iconSize*2,Se.iconSize*2,Se.iconSize,16,1),$e=new THREE.CylinderGeometry(ve.iconSize*2,ve.iconSize*2,ve.iconSize,16,1),rt=new THREE.LineBasicMaterial({color:Se.iconColor});for(let _e=1;_e<pack.burgs.length;_e++){const qe=pack.burgs[_e];if(qe.removed)continue;const st=qe.capital,[ot,N,K]=F(qe.x,qe.y),J=st?Se:ve;if(layerIsOn("toggleLabels")){const ae=await U({text:qe.name,...J});ae.position.set(ot,N+J.elevation,K),ae.size=J.size,k.push(ae),n.add(ae)}if(layerIsOn("toggleIcons")){const ae=st?Oe:$e,re=st?Ue:Ve,ue=new THREE.Mesh(ae,re);ue.position.set(ot,N,K),d.push(ue),n.add(ue);const fe=[new THREE.Vector3(ot,N,K),new THREE.Vector3(ot,N+J.line,K)],Me=new THREE.BufferGeometry().setFromPoints(fe),xe=new THREE.Line(Me,rt);s.push(xe),n.add(xe)}}if(layerIsOn("toggleLabels"))for(let _e=1;_e<pack.states.length;_e++){const qe=pack.states[_e];if(qe.removed)continue;const[st,ot,N]=F(qe.pole[0],qe.pole[1]),K=((nt=_.select("#stateLabel"+qe.i))==null?void 0:nt.text())||qe.name,J=await U({text:K,...ye});J.position.set(st,ot+ye.elevation,N),J.size=ye.size,k.push(J),n.add(J)}we()}function Z(){B=void 0;for(const _ of k)n.remove(_),_.material.map.dispose(),_.material.dispose(),_.geometry.dispose();k=[];for(const _ of d)n.remove(_),_.material.dispose(),_.geometry.dispose();d=[];for(const _ of s)n.remove(_),_.material.dispose(),_.geometry.dispose();s=[]}async function te(_,oe,ce,ye){const Se={noLabels:e.labels3d,noWater:e.extendedWater,fullMap:!0},ve=await getMapURL("mesh",Se);window.setTimeout(()=>window.URL.revokeObjectURL(ve),5e3),z&&z.dispose(),z=new THREE.TextureLoader().load(ve,pe),z.needsUpdate=!0,f&&f.dispose(),f=new THREE.MeshLambertMaterial,f.map=z,f.transparent=!0,m&&m.dispose(),m=new THREE.PlaneGeometry(_,oe,ce-1,ye-1),m.vertices.forEach((Ue,Ve)=>Ue.z=q(Ve)),m.computeVertexNormals(),b&&n.remove(b),b=new THREE.Mesh(m,f),b.rotation.x=-Math.PI/2,b.castShadow=!0,b.receiveShadow=!0,n.add(b),e.labels3d&&(pe(),await j())}function q(_){const oe=grid.cells.h[_];return oe<20?0:(oe-18)/82*e.scale}function X(_,oe){n.background=new THREE.Color(e.skyColor),C=new THREE.PlaneGeometry(_*10,oe*10,1),g=new THREE.MeshBasicMaterial({color:e.waterColor}),n.fog=new THREE.Fog(n.background,500,3e3),p=new THREE.Mesh(C,g),p.rotation.x=-Math.PI/2,p.position.y-=3,n.add(p)}async function ee(){z&&z.dispose();const _={noLabels:e.labels3d,noWater:e.extendedWater,fullMap:!0},oe=await getMapURL("mesh",_);window.setTimeout(()=>window.URL.revokeObjectURL(oe),4e3),z=new THREE.TextureLoader().load(oe,pe),f.map=z}async function le(_){return await He()?(n=new THREE.Scene,n.background=new THREE.TextureLoader().load("https://i0.wp.com/azgaar.files.wordpress.com/2019/10/stars-1.png",pe),t=new THREE.WebGLRenderer({canvas:_,antialias:!0,preserveDrawingBuffer:!0}),t.setSize(_.width,_.height),f&&f.dispose(),f=new THREE.MeshBasicMaterial,Y(!0),i=new THREE.PerspectiveCamera(45,_.width/_.height,.1,1e3).translateZ(5),r=await Be(i,t.domElement),r.enableKeys=!1,r.minDistance=1.8,r.maxDistance=10,r.autoRotate=Boolean(e.rotateGlobe),r.autoRotateSpeed=e.rotateGlobe,r.addEventListener("change",pe),!0):(se("Cannot load 3d library",!1,"error",4e3),!1)}async function Y(_){const oe=mapCoordinates.latT>179,ce=e.resolution,ye=512*ce,Se=1024*ce,ve=O(mapCoordinates.latT/180*ye),Ue=oe?ve*2:O(graphWidth/graphHeight*ve),Ve=oe?0:(90-mapCoordinates.latN)/180*ye,Oe=oe?0:Ue/4,$e=document.createElement("canvas").getContext("2d");if($e.canvas.width=Se,$e.canvas.height=ye,!oe){const nt=new Image;nt.onload=function(){$e.drawImage(nt,0,0,Se,ye)},nt.src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAIAAAACACAYAAADDPmHLAAAgAElEQVR4Xl2d669lV5Xd73XZrodtiPIhf3dLUT5F+dCJSCstpaNASFqdINGkH3TiThoCpMFAMAZssA3Gr7JdLt/M3xjzt/cujinuvefss/Z6zMeYY8619u0ffeXrd//sn3755qWH92/uv/DCzfPP37t58YXnb3i98PzzN88999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IlbGliGFBEL+X0u2BVUzKuSu4k5zFCudezTBk8iBLIgrTz1olFp0J6jUtFXsCRRwqtUTVgaYXKHE9YAk398pLD7tDGTIlxI97INrHFG6G3GpGkxfvs/FDbr/lYY0EYuVIjEV7Gt2I2l08izsWDq0r6JmDwV+On80k4Ky1Ptl2vuBRs5/cyNZT9PeeIvb/Ac44T/YFP/OUAAAAAElFTkSuQmCC"}const rt=new Image;rt.onload=function(){$e.drawImage(rt,Oe,Ve,Ue,ve),z&&z.dispose(),z=new THREE.CanvasTexture($e.canvas,pe),f.map=z,_&&de()},rt.src=await getMapURL("mesh",{globe:!0,fullMap:!0})}async function W(){return await(await Fe()).parse(b)}function de(){m=new THREE.SphereBufferGeometry(1,64,64),b=new THREE.Mesh(m,f),n.add(b),r.autoRotate?ke():pe()}const me=eo(we,200);function pe(){t.render(n,i),me()}function we(){for(const[_,oe]of k.entries()){const ce=oe.position.distanceTo(i.position),ye=ce<100*oe.size&&ce>oe.size*6;oe.visible=ye,s[_]&&(s[_].visible=ye)}}function ke(){c=requestAnimationFrame(ke),r.update()}function He(){return window.THREE?Promise.resolve(!0):new Promise(_=>{const oe=document.createElement("script");oe.src="libs/three.min.js",document.head.append(oe),oe.onload=()=>_(!0),oe.onerror=()=>_(!1)})}function Be(_,oe){return THREE.OrbitControls?new THREE.OrbitControls(_,oe):new Promise(ce=>{const ye=document.createElement("script");ye.src="libs/orbitControls.min.js",document.head.append(ye),ye.onload=()=>ce(new THREE.OrbitControls(_,oe)),ye.onerror=()=>ce(!1)})}function Fe(){return THREE.OBJExporter?new THREE.OBJExporter:new Promise(_=>{const oe=document.createElement("script");oe.src="libs/objexporter.min.js",document.head.append(oe),oe.onload=()=>_(new THREE.OBJExporter),oe.onerror=()=>_(!1)})}return{create:l,redraw:a,update:w,stop:S,options:e,setScale:h,setLightness:v,setSun:E,setRotation:P,toggleLabels:R,toggleSky:T,setResolution:M,setColors:L,saveScreenshot:I,saveOBJ:H}}();window.UISubmap=function(){ne("submapPointsInput").addEventListener("input",function(){const p=ne("submapPointsOutputFormatted"),B=cellsDensityMap[+this.value]||1e3;this.dataset.cells=B,p.value=getCellsDensityValue(B),p.style.color=getCellsDensityColor(B)}),ne("submapScaleInput").addEventListener("input",function(p){const B=Math.pow(1.1,+p.target.value);ne("submapScaleOutput").value=O(B,2)}),ne("submapAngleInput").addEventListener("input",function(p){ne("submapAngleOutput").value=p.target.value});const e=ne("submapPreview"),t=ne("submapScaleInput"),n=ne("submapShiftX"),i=ne("submapShiftY");function r(){$("#submapOptionsDialog").dialog({title:"Create a submap",resizable:!1,position:{my:"center",at:"center",of:"svg"},buttons:{Submap:function(){$(this).dialog("close"),A()},Cancel:function(){$(this).dialog("close")}}})}const c=p=>({angle:+ne("submapAngleInput").value/180*Math.PI,shiftX:+ne("submapShiftX").value,shiftY:+ne("submapShiftY").value,ratio:+ne("submapScaleInput").value,mirrorH:ne("submapMirrorH").checked,mirrorV:ne("submapMirrorV").checked});async function f(){resetZoom(0),ne("submapAngleInput").value=0,ne("submapAngleOutput").value="0",ne("submapScaleOutput").value=1,ne("submapMirrorH").checked=!1,ne("submapMirrorV").checked=!1,t.value=0,n.value=0,i.value=0;const p=Math.min(400,window.innerWidth*.5),B=p/graphWidth,k=graphHeight*B;e.style.width=p+"px",e.style.height=k+"px";const d=w=>w.dispatchEvent(new Event("input",{bubbles:!0}));e.onwheel=w=>{t.value=t.valueAsNumber-Math.sign(w.deltaY),d(t)};let s=!1,o=0,l=0;e.onmousedown=w=>{s=!0,o=n.value-w.clientX/B,l=i.value-w.clientY/B},e.onmouseup=w=>s=!1,e.onmouseleave=w=>s=!1,e.onmousemove=w=>{!s||(w.preventDefault(),n.value=Math.round(o+w.clientX/B),i.value=Math.round(l+w.clientY/B),d(n))},$("#resampleDialog").dialog({title:"Transform map",resizable:!1,position:{my:"center",at:"center",of:"svg"},buttons:{Transform:function(){$(this).dialog("close"),m()},Cancel:function(){$(this).dialog("close")}}});const a=await z(e,p*2,k*2);a.style.position="absolute",a.style.width=p+"px",a.style.height=k+"px",ne("resampleDialog").oninput=w=>{const{angle:S,shiftX:h,shiftY:v,ratio:E,mirrorH:P,mirrorV:T}=c(),R=Math.pow(1.1,E),L=`
translate(${h*B}px, ${v*B}px)
scale(${P?-R:R}, ${T?-R:R})
rotate(${S}rad)
`;a.style.transform=L,a.style["transform-origin"]="center",w.stopPropagation()}}async function z(p,B,k){const d=await getMapURL("png",{globe:!1,noWater:!0,fullMap:!0,noLabels:!0,noScaleBar:!0,noIce:!0}),s=document.createElement("canvas"),o=s.getContext("2d");s.width=B,s.height=k;const l=new Image;return l.src=d,l.onload=function(){o.drawImage(l,0,0,B,k)},p.textContent="",p.appendChild(s),s}const m=vt(function(){WARN&&console.warn("Resampling current map");const p=+ne("submapPointsInput").value;if(!cellsDensityMap[p])return console.error("Unknown cell number!");const{angle:B,shiftX:k,shiftY:d,ratio:s,mirrorH:o,mirrorV:l}=c(),[a,w]=[graphWidth/2,graphHeight/2],S=I=>(H,G)=>[(H-a)*Math.cos(I)-(G-w)*Math.sin(I)+a,(G-w)*Math.cos(I)+(H-a)*Math.sin(I)+w],h=(I,H)=>(G,D)=>[G+I,D+H],v=I=>(H,G)=>[(H-a)*I+a,(G-w)*I+w],E=(I,H)=>[-I+2*a,H],P=(I,H)=>[I,-H+2*w],T=(I,H)=>(G,D)=>I(...H(G,D)),R=(I,H)=>[I,H];let L=R,M=R;B&&([L,M]=[S(B),S(-B)]),s&&([L,M]=[T(v(Math.pow(1.1,s)),L),T(M,v(Math.pow(1.1,-s)))]),o&&([L,M]=[T(E,L),T(M,E)]),l&&([L,M]=[T(P,L),T(M,P)]),(k||d)&&(L=T(h(k,d),L),M=T(M,h(-k,-d))),changeCellsDensity(p),u({lockMarkers:!1,lockBurgs:!1,depressRivers:!1,addLakesInDepressions:!1,promoteTowns:!1,smoothHeightMap:!1,rescaleStyles:!1,scale:1,projection:L,inverse:M})},1e3);function b(){return[[Math.abs(viewX/scale),Math.abs(viewY/scale)],[Math.abs(viewX/scale)+graphWidth/scale,Math.abs(viewY/scale)+graphHeight/scale]]}const A=vt(function(){WARN&&console.warn("Resampling current map"),closeDialogs("#worldConfigurator, #options3d");const p=v=>Boolean(ne(v).checked),[[B,k],[d,s]]=b(),o=scale,l={lockMarkers:p("submapLockMarkers"),lockBurgs:p("submapLockBurgs"),depressRivers:p("submapDepressRivers"),addLakesInDepressions:p("submapAddLakeInDepression"),promoteTowns:p("submapPromoteTowns"),rescaleStyles:p("submapRescaleStyles"),smoothHeightMap:scale>2,inverse:(v,E)=>[v/o+B,E/o+k],projection:(v,E)=>[(v-B)*o,(E-k)*o],scale:o},a=ne("mapSizeOutput"),w=ne("latitudeOutput"),h=90-(180-mapSizeInput.value/100*180)*w.value/100-k/graphHeight*a.value*180/100;a.value/=scale,w.value=(90-h)/(180-a.value/100*180)*100,ne("mapSizeInput").value=a.value,ne("latitudeInput").value=w.value,distanceScaleInput.value=distanceScaleOutput.value=O(distanceScale=distanceScaleOutput.value/scale,2),populationRateInput.value=populationRateOutput.value=O(populationRate=populationRateOutput.value/scale,2),customization=0,u(l)},1e3);async function u(p){resetZoom(0);let B={grid:structuredClone(grid),pack:structuredClone(pack),notes:structuredClone(notes),seed,graphWidth,graphHeight};undraw();try{const k=scale;if(await Submap.resample(B,p),p.promoteTowns){const d="largetowns";moveAllBurgsToGroup("towns",d),changeRadius(O(k*.8,2),d),changeFontSize(svg.select(`#labels #${d}`),O(k*2,2)),invokeActiveZooming()}p.rescaleStyles&&C(k)}catch(k){g(k)}B=null,restoreLayers(),ThreeD.options.isOn&&ThreeD.redraw(),$("#worldConfigurator").is(":visible")&&editWorld()}function C(p){const B=[...ne("burgIcons").querySelectorAll("g")];for(const s of B){const o=O(Ie(s.getAttribute("size")*p,.2,10),2);changeRadius(o,s.id);const l=s.attributes["stroke-width"];l.value=+l.value*p}const k=[...ne("burgLabels").querySelectorAll("g")];for(const s of k){const o=+s.dataset.size;s.dataset.size=Math.max(O((o+o/p)/2,2),1)*p}const d=Ie((p-1)*.3+1,.5,5);emblemsStateSizeInput.value=Ie(+emblemsStateSizeInput.value*d,.5,5),emblemsProvinceSizeInput.value=Ie(+emblemsProvinceSizeInput.value*d,.5,5),emblemsBurgSizeInput.value=Ie(+emblemsBurgSizeInput.value*d,.5,5),drawEmblems()}function g(p){ERROR&&console.error(p),ct(),alertMessage.innerHTML=`Map resampling failed: <br />You may retry after clearing stored data or contact us at discord.
<p id="errorBox">${qa(p)}</p>`,$("#alert").dialog({resizable:!1,title:"Resampling error",width:"32em",buttons:{Ok:function(){$(this).dialog("close")}},position:{my:"center",at:"center",of:"svg"}})}return{openSubmapMenu:r,openResampleMenu:f}}();document.addEventListener("keydown",Gs);document.addEventListener("keyup",js);function Gs(e){if(!en())return;const{code:t,ctrlKey:n,altKey:i}=e;i&&!n&&e.preventDefault(),n&&["KeyS","KeyC"].includes(t)&&e.preventDefault(),["F1","F2","F6","F9","Tab"].includes(t)&&e.preventDefault()}function js(e){if(!en())return;e.stopPropagation();const{code:t,key:n,ctrlKey:i,metaKey:r,shiftKey:c,altKey:f}=e,z=i||r||n==="Control",m=c||n==="Shift",b=f||n==="Alt";t==="F1"?showInfo():t==="F2"?regeneratePrompt():t==="F6"?quickSave():t==="F9"?quickLoad():t==="Tab"?toggleOptions(e):t==="Escape"?Zs():t==="Delete"?Vs():t==="KeyO"&&document.getElementById("canvas3d")?toggle3dOptions():z&&t==="KeyQ"?toggleSaveReminder():z&&t==="KeyS"?dowloadMap():z&&t==="KeyC"?saveToDropbox():z&&t==="KeyZ"&&(undo==null?void 0:undo.offsetParent)?undo.click():z&&t==="KeyY"&&(redo==null?void 0:redo.offsetParent)?redo.click():m&&t==="KeyH"?editHeightmap():m&&t==="KeyB"?editBiomes():m&&t==="KeyS"?editStates():m&&t==="KeyP"?editProvinces():m&&t==="KeyD"?editDiplomacy():m&&t==="KeyC"?editCultures():m&&t==="KeyN"?editNamesbase():m&&t==="KeyZ"?editZones():m&&t==="KeyR"?editReligions():m&&t==="KeyY"?openEmblemEditor():m&&t==="KeyQ"?editUnits():m&&t==="KeyO"?editNotes():m&&t==="KeyA"?overviewCharts():m&&t==="KeyT"?overviewBurgs():m&&t==="KeyV"?overviewRivers():m&&t==="KeyM"?overviewMilitary():m&&t==="KeyK"?overviewMarkers():m&&t==="KeyE"?viewCellDetails():n==="!"?toggleAddBurg():n==="@"?toggleAddLabel():n==="#"?toggleAddRiver():n==="$"?toggleAddRoute():n==="%"?toggleAddMarker():b&&t==="KeyB"?console.table(pack.burgs):b&&t==="KeyS"?console.table(pack.states):b&&t==="KeyC"?console.table(pack.cultures):b&&t==="KeyR"?console.table(pack.religions):b&&t==="KeyF"?console.table(pack.features):t==="KeyX"?toggleTexture():t==="KeyH"?toggleHeight():t==="KeyB"?toggleBiomes():t==="KeyE"?toggleCells():t==="KeyG"?toggleGrid():t==="KeyO"?toggleCoordinates():t==="KeyW"?toggleCompass():t==="KeyV"?toggleRivers():t==="KeyF"?toggleRelief():t==="KeyC"?toggleCultures():t==="KeyS"?toggleStates():t==="KeyP"?toggleProvinces():t==="KeyZ"?toggleZones():t==="KeyD"?toggleBorders():t==="KeyR"?toggleReligions():t==="KeyU"?toggleRoutes():t==="KeyT"?toggleTemp():t==="KeyN"?togglePopulation():t==="KeyJ"?toggleIce():t==="KeyA"?togglePrec():t==="KeyY"?toggleEmblems():t==="KeyL"?toggleLabels():t==="KeyI"?toggleIcons():t==="KeyM"?toggleMilitary():t==="KeyK"?toggleMarkers():t==="Equal"?toggleRulers():t==="Slash"?toggleScaleBar():t==="ArrowLeft"?zoom.translateBy(svg,10,0):t==="ArrowRight"?zoom.translateBy(svg,-10,0):t==="ArrowUp"?zoom.translateBy(svg,0,10):t==="ArrowDown"?zoom.translateBy(svg,0,-10):n==="+"||n==="-"?Ws(n):n==="0"?resetZoom(1e3):n==="1"?zoom.scaleTo(svg,1):n==="2"?zoom.scaleTo(svg,2):n==="3"?zoom.scaleTo(svg,3):n==="4"?zoom.scaleTo(svg,4):n==="5"?zoom.scaleTo(svg,5):n==="6"?zoom.scaleTo(svg,6):n==="7"?zoom.scaleTo(svg,7):n==="8"?zoom.scaleTo(svg,8):n==="9"?zoom.scaleTo(svg,9):z&&qs()}function en(){const{tagName:e,contentEditable:t}=document.activeElement;return!(["INPUT","SELECT","TEXTAREA"].includes(e)||e==="DIV"&&t==="true"||document.getSelection().toString())}function Ws(e){var r,c,f,z,m,b,A;const t=e==="+"?1:-1;let n=null;if((r=document.getElementById("brushRadius"))!=null&&r.offsetParent?n=document.getElementById("brushRadius"):(c=document.getElementById("biomesManuallyBrush"))!=null&&c.offsetParent?n=document.getElementById("biomesManuallyBrush"):(f=document.getElementById("statesManuallyBrush"))!=null&&f.offsetParent?n=document.getElementById("statesManuallyBrush"):(z=document.getElementById("provincesManuallyBrush"))!=null&&z.offsetParent?n=document.getElementById("provincesManuallyBrush"):(m=document.getElementById("culturesManuallyBrush"))!=null&&m.offsetParent?n=document.getElementById("culturesManuallyBrush"):(b=document.getElementById("zonesBrush"))!=null&&b.offsetParent?n=document.getElementById("zonesBrush"):(A=document.getElementById("religionsManuallyBrush"))!=null&&A.offsetParent&&(n=document.getElementById("religionsManuallyBrush")),n){const u=minmax(+n.value+t,+n.min,+n.max);n.value=document.getElementById(n.id+"Number").value=u;return}const i=e==="+"?1.2:.8;zoom.scaleBy(svg,i)}function qs(){zonesRemove!=null&&zonesRemove.offsetParent&&(zonesRemove.classList.contains("pressed")?zonesRemove.classList.remove("pressed"):zonesRemove.classList.add("pressed"))}function Vs(){const e=Array.from(document.querySelectorAll("[role='dialog'] .fastDelete")).find(n=>n.style.display!=="none");e&&e.click();const t=Array.from(document.querySelectorAll("[role='dialog']")).filter(n=>n.style.display!=="none");!t.length||t.forEach(n=>n.querySelectorAll("button").forEach(i=>i.textContent==="Remove"&&i.click()))}function Zs(){closeDialogs(),hideOptions()}window.COArenderer=function(){const e={argent:"#fafafa",or:"#ffe066",gules:"#d7374a",sable:"#333333",azure:"#377cd7",vert:"#26c061",purpure:"#522d5b",murrey:"#85185b",sanguine:"#b63a3a",tenn\u00E9:"#cc7f19"},t={heater:{a:[-43.75,-50],b:[0,-50],c:[43.75,-50],d:[-43.75,0],e:[0,0],f:[43.75,0],g:[-32.25,37.5],h:[0,50],i:[32.25,37.5],y:[-50,-50],z:[0,62.5],j:[-37.5,-37.5],k:[0,-37.5],l:[37.5,-37.5],m:[-30,30],n:[0,42.5],o:[30,30],p:[-37.5,0],q:[37.5,0],A:[-66.2,-66.6],B:[-22,-66.6],C:[22,-66.6],D:[66.2,-66.6],K:[-66.2,-20],E:[66.2,-20],J:[-55.5,26],F:[55.5,26],I:[-33,62],G:[33,62],H:[0,89.5]},spanish:{a:[-43.75,-50],b:[0,-50],c:[43.75,-50],d:[-43.75,0],e:[0,0],f:[43.75,0],g:[-43.75,50],h:[0,50],i:[43.75,50],y:[-50,-50],z:[0,50],j:[-37.5,-37.5],k:[0,-37.5],l:[37.5,-37.5],m:[-37.5,37.5],n:[0,37.5],o:[37.5,37.5],p:[-37.5,0],q:[37.5,0],A:[-66.2,-66.6],B:[-22,-66.6],C:[22,-66.6],D:[66.2,-66.6],K:[-66.4,-20],E:[66.4,-20],J:[-66.4,26],F:[66.4,26],I:[-49,70],G:[49,70],H:[0,92]},french:{a:[-43.75,-50],b:[0,-50],c:[43.75,-50],d:[-43.75,0],e:[0,0],f:[43.75,0],g:[-43.75,50],h:[0,50],i:[43.75,50],y:[-50,-50],z:[0,65],j:[-37.5,-37.5],k:[0,-37.5],l:[37.5,-37.5],m:[-37.5,37.5],n:[0,37.5],o:[37.5,37.5],p:[-37.5,0],q:[37.5,0],A:[-66.2,-66.6],B:[-22,-66.6],C:[22,-66.6],D:[66.2,-66.6],K:[-66.4,-20],E:[66.4,-20],J:[-66.4,26],F:[66.4,26],I:[-65.4,70],G:[65.4,70],H:[0,89]},horsehead:{a:[-43.75,-47.5],b:[0,-50],c:[43.75,-47.5],d:[-35,0],e:[0,0],f:[35,0],h:[0,50],y:[-50,-50],z:[0,55],j:[-35,-35],k:[0,-40],l:[35,-35],m:[-30,30],n:[0,40],o:[30,30],p:[-27.5,0],q:[27.5,0],A:[-71,-52],B:[-24,-73],C:[24,-73],D:[71,-52],K:[-62,-16],E:[62,-16],J:[-39,20],F:[39,20],I:[-33.5,60],G:[33.5,60],H:[0,91.5]},horsehead2:{a:[-37.5,-47.5],b:[0,-50],c:[37.5,-47.5],d:[-35,0],e:[0,0],f:[35,0],g:[-35,47.5],h:[0,50],i:[35,47.5],y:[-50,-50],z:[0,55],j:[-30,-30],k:[0,-40],l:[30,-30],m:[-30,30],n:[0,40],o:[30,30],p:[-27.5,0],q:[27.5,0],A:[-49,-39],B:[-22,-70],C:[22,-70],D:[49,-39],K:[-51,-2],E:[51,-2],J:[-38.5,31],F:[38.5,31],I:[-35,67],G:[35,67],H:[0,85]},polish:{a:[-35,-50],b:[0,-50],c:[35,-50],d:[-40,0],e:[0,0],f:[40,0],g:[-37.5,50],h:[0,50],i:[37.5,50],y:[-50,-50],z:[0,65],j:[-27.5,-27.5],k:[0,-45],l:[27.5,-27.5],m:[-27.5,27.5],n:[0,45],o:[27.5,27.5],p:[-32.5,0],q:[32.5,0],A:[-48,-52],B:[-23,-80],C:[23,-80],D:[48,-52],K:[-47,-10],E:[47,-10],J:[-62,32],F:[62,32],I:[-37,68],G:[37,68],H:[0,86]},hessen:{a:[-43.75,-50],b:[0,-50],c:[43.75,-50],d:[-43.75,0],e:[0,0],f:[43.75,0],g:[-43.75,50],h:[0,50],i:[43.75,50],y:[-50,-50],z:[0,52.5],j:[-40,-40],k:[0,-40],l:[40,-40],m:[-40,40],n:[0,40],o:[40,40],p:[-40,0],q:[40,0],A:[-69,-64],B:[-22,-76],C:[22,-76],D:[69,-64],K:[-66.4,-20],E:[66.4,-20],J:[-62,26],F:[62,26],I:[-46,70],G:[46,70],H:[0,91.5]},swiss:{a:[-43.75,-50],b:[0,-50],c:[43.75,-50],d:[-43.75,0],e:[0,0],f:[43.75,0],g:[-32,37.5],h:[0,50],i:[32,37.5],y:[-50,-50],z:[0,62.5],j:[-37.5,-37.5],k:[0,-37.5],l:[37.5,-37.5],m:[-32,32.5],n:[0,42.5],o:[32,32.5],p:[-37.5,0],q:[37.5,0],A:[-66.2,-66.6],B:[-22,-66],C:[22,-66],D:[66.2,-66.6],K:[-63,-20],E:[63,-20],J:[-50,26],F:[50,26],I:[-29,62],G:[29,62],H:[0,89.5]},boeotian:{a:[-37.5,-47.5],b:[0,-47.5],c:[37.5,-47.5],d:[-25,0],e:[0,0],f:[25,0],g:[-37.5,47.5],h:[0,47.5],i:[37.5,47.5],y:[-48,-48],z:[0,60],j:[-32.5,-37.5],k:[0,-45],l:[32.5,-37.5],m:[-32.5,37.5],n:[0,45],o:[32.5,37.5],p:[-20,0],q:[20,0],A:[-45,-55],B:[-20,-77],C:[20,-77],D:[45,-55],K:[-59,-25],E:[59,-25],J:[-58,27],F:[58,27],I:[-39,63],G:[39,63],H:[0,81]},roman:{a:[-40,-52.5],b:[0,-52.5],c:[40,-52.5],d:[-40,0],e:[0,0],f:[40,0],g:[-40,52.5],h:[0,52.5],i:[40,52.5],y:[-42.5,-52.5],z:[0,65],j:[-30,-37.5],k:[0,-37.5],l:[30,-37.5],m:[-30,37.5],n:[0,37.5],o:[30,37.5],p:[-30,0],q:[30,0],A:[-51.5,-65],B:[-17,-75],C:[17,-75],D:[51.5,-65],K:[-51.5,-21],E:[51.5,-21],J:[-51.5,21],F:[51.5,21],I:[-51.5,65],G:[51.5,65],H:[-17,75],L:[17,75]},kite:{b:[0,-65],e:[0,-15],h:[0,35],z:[0,35],k:[0,-50],n:[0,20],p:[-20,-15],q:[20,-15],A:[-38,-52],B:[-29,-78],C:[29,-78],D:[38,-52],K:[-33,-20],E:[33,-20],J:[-25,11],F:[25,11],I:[-15,42],G:[15,42],H:[0,73],L:[0,-91]},oldFrench:{a:[-43.75,-50],b:[0,-50],c:[43.75,-50],d:[-43.75,0],e:[0,0],f:[43.75,0],g:[-37.5,50],h:[0,50],i:[37.5,50],y:[-50,-50],z:[0,62.5],j:[-37.5,-37.5],k:[0,-37.5],l:[37.5,-37.5],m:[-37.5,37.5],n:[0,45],o:[37.5,37.5],p:[-37.5,0],q:[37.5,0],A:[-66.2,-66.6],B:[-22,-66.6],C:[22,-66.6],D:[66.2,-66.6],K:[-66.2,-20],E:[66.2,-20],J:[-64,26],F:[64,26],I:[-45,62],G:[45,62],H:[0,91]},renaissance:{a:[-43.75,-50],b:[0,-50],c:[43.75,-50],d:[-41.5,0],e:[0,0],f:[41.5,0],g:[-43.75,50],h:[0,50],i:[43.75,50],y:[-50,-50],z:[0,62.5],j:[-37.5,-37.5],k:[0,-37.5],l:[37.5,-37.5],m:[-37.5,37.5],n:[0,37.5],o:[37.5,37.5],p:[-37.5,0],q:[37.5,0],A:[-61,-55],B:[-23,-67],C:[23,-67],D:[61,-55],K:[-55,-11],E:[55,-11],J:[-65,31],F:[65,31],I:[-45,76],G:[45,76],H:[0,87]},baroque:{a:[-43.75,-45],b:[0,-45],c:[43.75,-45],d:[-43.75,0],e:[0,0],f:[43.75,0],g:[-43.75,50],h:[0,50],i:[43.75,50],y:[-50,-50],z:[0,60],j:[-37.5,-37.5],k:[0,-37.5],l:[37.5,-37.5],m:[-37.5,37.5],n:[0,37.5],o:[37.5,37.5],p:[-37.5,0],q:[37.5,0],A:[-65,-54.5],B:[-22,-65],C:[22,-65],D:[65,-54.5],K:[-58.5,-15],E:[58.5,-15],J:[-65,31],F:[66,31],I:[-35,73],G:[35,73],H:[0,89]},targe:{a:[-43.75,-50],b:[0,-50],c:[43.75,-50],d:[-43.75,0],e:[0,0],f:[43.75,0],g:[-43.75,50],h:[0,50],i:[43.75,50],y:[-50,-50],z:[0,50],j:[-40,-40],k:[0,-40],l:[40,-40],m:[-40,40],n:[0,40],o:[40,40],p:[-32.5,0],q:[32.5,0],A:[-66.2,-60],B:[-22,-77],C:[22,-86],D:[60,-66.6],K:[-28,-20],E:[57,-20],J:[-61,26],F:[61,26],I:[-49,63],G:[49,59],H:[0,80]},targe2:{a:[-43.75,-50],b:[0,-50],c:[43.75,-50],d:[-40,0],e:[0,0],f:[40,0],g:[-43.75,50],h:[0,50],i:[43.75,50],y:[-50,-50],z:[0,60],j:[-37.5,-37.5],k:[0,-37.5],l:[37.5,-37.5],m:[-37.5,37.5],n:[0,37.5],o:[37.5,37.5],p:[-32.5,0],q:[32.5,0],A:[-55,-59],B:[-15,-59],C:[24,-79],D:[51,-58],K:[-40,-14],E:[51,-14],J:[-64,26],F:[62,26],I:[-46,66],G:[48,67],H:[0,83]},pavise:{a:[-40,-52.5],b:[0,-52.5],c:[40,-52.5],d:[-40,0],e:[0,0],f:[40,0],g:[-40,52.5],h:[0,52.5],i:[40,52.5],y:[-42.5,-52.5],z:[0,60],j:[-30,-35],k:[0,-37.5],l:[30,-35],m:[-30,35],n:[0,37.5],o:[30,35],p:[-30,0],q:[30,0],A:[-57,-55],B:[-22,-74],C:[22,-74],D:[57,-55],K:[-54,-11],E:[54,-11],J:[-50,36],F:[50,36],I:[-46,81],G:[46,81],H:[0,81]},wedged:{a:[-43.75,-50],b:[0,-50],c:[43.75,-50],d:[-43.75,0],e:[0,0],f:[43.75,0],g:[-32.25,37.5],h:[0,50],i:[32.25,37.5],y:[-50,-50],z:[0,62.5],j:[-37.5,-37.5],k:[0,-37.5],l:[37.5,-37.5],m:[-32.5,32.5],n:[0,42.5],o:[32.5,32.5],p:[-37.5,0],q:[37.5,0],A:[-66,-53],B:[-22,-72.5],C:[22,-72.5],D:[66,-53],K:[-62.6,-13],E:[62.6,-13],J:[-50,26],F:[50,26],I:[-27,62],G:[27,62],H:[0,87]},flag:{a:[-60,-40],b:[0,-40],c:[60,-40],d:[-60,0],e:[0,0],f:[60,0],g:[-60,40],h:[0,40],i:[60,40],y:[-60,-42.5],z:[0,40],j:[-45,-30],k:[0,-30],l:[45,-30],m:[-45,30],n:[0,30],o:[45,30],p:[-45,0],q:[45,0],A:[-81,-51],B:[-27,-51],C:[27,-51],D:[81,-51],K:[-81,-17],E:[81,-17],J:[-81,17],F:[81,17],I:[-81,51],G:[81,51],H:[-27,51],L:[27,51]},pennon:{a:[-75,-40],d:[-75,0],e:[-25,0],f:[25,0],g:[-75,40],y:[-70,-42.5],j:[-60,-30],m:[-60,30],p:[-60,0],q:[5,0],A:[-81,-48],B:[-43,-36],C:[-4.5,-24],D:[33,-12],E:[72,0],F:[33,12],G:[-4.5,24],H:[-43,36],I:[-81,48],J:[-81,17],K:[-81,-17]},guidon:{a:[-60,-40],b:[0,-40],c:[60,-40],d:[-60,0],e:[0,0],g:[-60,40],h:[0,40],i:[60,40],y:[-60,-42.5],z:[0,40],j:[-45,-30],k:[0,-30],l:[45,-30],m:[-45,30],n:[0,30],o:[45,30],p:[-45,0],A:[-81,-51],B:[-27,-51],C:[27,-51],D:[78,-51],K:[-81,-17],E:[40.5,-17],J:[-81,17],F:[40.5,17],I:[-81,51],G:[78,51],H:[-27,51],L:[27,51]},banner:{a:[-50,-50],b:[0,-50],c:[50,-50],d:[-50,0],e:[0,0],f:[50,0],g:[-50,40],h:[0,40],i:[50,40],y:[-50,-50],z:[0,40],j:[-37.5,-37.5],k:[0,-37.5],l:[37.5,-37.5],m:[-37.5,27.5],n:[0,27.5],o:[37.5,27.5],p:[-37.5,0],q:[37.5,0],A:[-66.5,-66.5],B:[-22,-66.5],C:[22,-66.5],D:[66.5,-66.5],K:[-66.5,-20],E:[66.5,-20],J:[-66.5,26],F:[66.5,26],I:[-66.5,66.5],G:[66.5,66.5],H:[-25,75],L:[25,75]},dovetail:{a:[-49.75,-50],b:[0,-50],c:[49.75,-50],d:[-49.75,0],e:[0,0],f:[49.75,0],g:[-49.75,50],i:[49.75,50],y:[-50,-50],z:[0,40],j:[-37.5,-37.5],k:[0,-37.5],l:[37.5,-37.5],m:[-37.5,37.5],n:[0,32.5],o:[37.5,37.5],p:[-37.5,0],q:[37.5,0],A:[-66.5,-66.5],B:[-22,-66.5],C:[22,-66.5],D:[66.5,-66.5],K:[-66.5,-16.5],E:[66.5,-16.5],J:[-66.5,34.5],F:[66.5,34.5],I:[-66.5,84.5],G:[66.5,84.5],H:[-25,64],L:[25,64]},gonfalon:{a:[-49.75,-50],b:[0,-50],c:[49.75,-50],d:[-49.75,0],e:[0,0],f:[49.75,0],g:[-49.75,50],h:[0,50],i:[49.75,50],y:[-50,-50],z:[0,50],j:[-37.5,-37.5],k:[0,-37.5],l:[37.5,-37.5],m:[-37.5,37.5],n:[0,37.5],o:[37.5,37.5],p:[-37.5,0],q:[37.5,0],A:[-66.5,-66.5],B:[-22,-66.5],C:[22,-66.5],D:[66.5,-66.5],K:[-66.5,-20],E:[66.5,-20],J:[-66.5,26],F:[66.5,26],I:[-40,63],G:[40,63],H:[0,88]},pennant:{a:[-45,-50],b:[0,-50],c:[45,-50],e:[0,0],h:[0,50],y:[-50,-50],z:[0,50],j:[-32.5,-37.5],k:[0,-37.5],l:[32.5,-37.5],n:[0,37.5],A:[-60,-76],B:[-22,-76],C:[22,-76],D:[60,-76],K:[-46,-38],E:[46,-38],J:[-31,0],F:[31,0],I:[-16,38],G:[16,38],H:[0,76]},round:{a:[-40,-40],b:[0,-40],c:[40,-40],d:[-40,0],e:[0,0],f:[40,0],g:[-40,40],h:[0,40],i:[40,40],y:[-48,-48],z:[0,57.5],j:[-35.5,-35.5],k:[0,-37.5],l:[35.5,-35.5],m:[-35.5,35.5],n:[0,37.5],o:[35.5,35.5],p:[-36.5,0],q:[36.5,0],A:[-59,-48],B:[-23,-73],C:[23,-73],D:[59,-48],K:[-76,-10],E:[76,-10],J:[-70,31],F:[70,31],I:[-42,64],G:[42,64],H:[0,77]},oval:{a:[-37.5,-50],b:[0,-50],c:[37.5,-50],d:[-43,0],e:[0,0],f:[43,0],g:[-37.5,50],h:[0,50],i:[37.5,50],y:[-48,-48],z:[0,60],j:[-35.5,-37.5],k:[0,-37.5],l:[35.5,-37.5],m:[-35.5,37.5],n:[0,50],o:[35.5,37.5],p:[-36.5,0],q:[36.5,0],A:[-48,-48],B:[-23,-78],C:[23,-78],D:[48,-48],K:[-59,-10],E:[59,-10],J:[-55,31],F:[55,31],I:[-36,68],G:[36,68],H:[0,85]},vesicaPiscis:{a:[-32,-37],b:[0,-50],c:[32,-37],d:[-32,0],e:[0,0],f:[32,0],g:[-32,37],h:[0,50],i:[32,37],y:[-50,-50],z:[0,62],j:[-27.5,-27.5],k:[0,-37],l:[27.5,-27.5],m:[-27.5,27.5],n:[0,42],o:[27.5,27.5],p:[-27.5,0],q:[27.5,0],A:[-45,-32],B:[-29,-63],C:[29,-63],D:[45,-32],K:[-50,0],E:[50,0],J:[-45,32],F:[45,32],I:[-29,63],G:[29,63],H:[0,89],L:[0,-89]},square:{a:[-49.75,-50],b:[0,-50],c:[49.75,-50],d:[-49.75,0],e:[0,0],f:[49.75,0],g:[-49.75,50],h:[0,50],i:[49.75,50],y:[-50,-50],z:[0,50],j:[-37.5,-37.5],k:[0,-37.5],l:[37.5,-37.5],m:[-37.5,37.5],n:[0,37.5],o:[37.5,37.5],p:[-37.5,0],q:[37.5,0],A:[-66.5,-66.5],B:[-22,-66.5],C:[22,-66.5],D:[66.5,-66.5],K:[-66.5,-20],E:[66.5,-20],J:[-66.5,26],F:[66.5,26],I:[-66.5,66.5],G:[66.5,66.5],H:[-22,66.5],L:[22,66.5]},diamond:{a:[-32,-37],b:[0,-50],c:[32,-37],d:[-43,0],e:[0,0],f:[43,0],g:[-32,37],h:[0,50],i:[32,37],y:[-50,-50],z:[0,62],j:[-27.5,-27.5],k:[0,-37],l:[27.5,-27.5],m:[-27.5,27.5],n:[0,42],o:[27.5,27.5],p:[-37,0],q:[37,0],A:[-43,-28],B:[-22,-56],C:[22,-56],D:[43,-28],K:[-63,0],E:[63,0],J:[-42,28],F:[42,28],I:[-22,56],G:[22,56],H:[0,83],L:[0,-82]},no:{a:[-66.5,-66.5],b:[0,-66.5],c:[66.5,-66.5],d:[-66.5,0],e:[0,0],f:[66.5,0],g:[-66.5,66.5],h:[0,66.5],i:[66.5,66.5],y:[-50,-50],z:[0,75],j:[-50,-50],k:[0,-50],l:[50,-50],m:[-50,50],n:[0,50],o:[50,50],p:[-50,0],q:[50,0],A:[-91.5,-91.5],B:[-30.5,-91.5],C:[30.5,-91.5],D:[91.5,-91.5],K:[-91.5,-30.5],E:[91.5,-30.5],J:[-91.5,30.5],F:[91.5,30.5],I:[-91.5,91.5],G:[91.5,91.5],H:[-30.5,91.5],L:[30.5,91.5]},fantasy1:{a:[-45,-45],b:[0,-50],c:[45,-45],d:[-40,0],e:[0,0],f:[40,0],g:[-36,42.5],h:[0,50],i:[36,42.5],y:[-50,-50],z:[0,60],j:[-37,-37],k:[0,-40],l:[37,-37],m:[-32,32],n:[0,40],o:[32,32],p:[-28.5,0],q:[28.5,0],A:[-66,-55],B:[-22,-67],C:[22,-67],D:[66,-55],K:[-53,-20],E:[53,-20],J:[-46,26],F:[46,26],I:[-29,62],G:[29,62],H:[0,84]},fantasy2:{a:[-45,-45],b:[0,-45],c:[45,-45],d:[-35,0],e:[0,0],f:[35,0],g:[-36,42.5],h:[0,45],i:[36,42.5],y:[-50,-50],z:[0,55],j:[-32.5,-32.5],k:[0,-40],l:[32.5,-32.5],m:[-30,30],n:[0,40],o:[30,30],p:[-27.5,0],q:[27.5,0],A:[-58,-35],B:[-44,-67],C:[44,-67],D:[58,-35],K:[-39,-5],E:[39,-5],J:[-57,26],F:[57,26],I:[-32,58],G:[32,58],H:[0,83],L:[0,-72]},fantasy3:{a:[-40,-45],b:[0,-50],c:[40,-45],d:[-35,0],e:[0,0],f:[35,0],g:[-36,42.5],h:[0,50],i:[36,42.5],y:[-50,-50],z:[0,55],j:[-32.5,-32.5],k:[0,-40],l:[32.5,-32.5],m:[-30,30],n:[0,40],o:[30,30],p:[-27.5,0],q:[27.5,0],A:[-56,-42],B:[-22,-72],C:[22,-72],D:[56,-42],K:[-37,-11],E:[37,-11],J:[-60,20],F:[60,20],I:[-34,56],G:[34,56],H:[0,83]},fantasy4:{a:[-50,-45],b:[0,-50],c:[50,-45],d:[-45,0],e:[0,0],f:[45,0],g:[-40,45],h:[0,50],i:[40,45],y:[-50,-50],z:[0,62.5],j:[-37.5,-37.5],k:[0,-45],l:[37.5,-37.5],m:[-37.5,37.5],n:[0,45],o:[37.5,37.5],p:[-35,0],q:[35,0],A:[-75,-56],B:[-36,-61],C:[36,-61],D:[75,-56],K:[-67,-12],E:[67,-12],J:[-63,32],F:[63,32],I:[-42,75],G:[42,75],H:[0,91.5],L:[0,-79]},fantasy5:{a:[-45,-50],b:[0,-50],c:[45,-50],d:[-40,0],e:[0,0],f:[40,0],g:[-30,45],h:[0,50],i:[30,45],y:[-50,-50],z:[0,60],j:[-37,-37],k:[0,-40],l:[37,-37],m:[-32,32],n:[0,40],o:[32,32],p:[-28.5,0],q:[28.5,0],A:[-61,-67],B:[-22,-76],C:[22,-76],D:[61,-67],K:[-58,-25],E:[58,-25],J:[-48,20],F:[48,20],I:[-28.5,60],G:[28.5,60],H:[0,89]},noldor:{b:[0,-65],e:[0,-15],h:[0,35],z:[0,35],k:[0,-50],n:[0,30],p:[-20,-15],q:[20,-15],A:[-34,-47],B:[-20,-68],C:[20,-68],D:[34,-47],K:[-18,-20],E:[18,-20],J:[-26,11],F:[26,11],I:[-14,43],G:[14,43],H:[0,74],L:[0,-85]},gondor:{a:[-32.5,-50],b:[0,-50],c:[32.5,-50],d:[-32.5,0],e:[0,0],f:[32.5,0],g:[-32.5,50],h:[0,50],i:[32.5,50],y:[-42.5,-52.5],z:[0,65],j:[-25,-37.5],k:[0,-37.5],l:[25,-37.5],m:[-25,30],n:[0,37.5],o:[25,30],p:[-25,0],q:[25,0],A:[-42,-52],B:[-17,-75],C:[17,-75],D:[42,-52],K:[-42,-15],E:[42,-15],J:[-42,22],F:[42,22],I:[-26,60],G:[26,60],H:[0,87]},easterling:{a:[-40,-47.5],b:[0,-47.5],c:[40,-47.5],d:[-40,0],e:[0,0],f:[40,0],g:[-40,47.5],h:[0,47.5],i:[40,47.5],y:[-42.5,-52.5],z:[0,65],j:[-30,-37.5],k:[0,-37.5],l:[30,-37.5],m:[-30,37.5],n:[0,37.5],o:[30,37.5],p:[-30,0],q:[30,0],A:[-52,-72],B:[0,-65],D:[52,-72],K:[-52,-24],E:[52,-24],J:[-52,24],F:[52,24],I:[-52,72],G:[52,72],H:[0,65]},erebor:{a:[-40,-40],b:[0,-55],c:[40,-40],d:[-40,0],e:[0,0],f:[40,0],g:[-40,40],h:[0,55],i:[40,40],y:[-50,-50],z:[0,50],j:[-35,-35],k:[0,-45],l:[35,-35],m:[-35,35],n:[0,45],o:[35,35],p:[-37.5,0],q:[37.5,0],A:[-47,-46],B:[-22,-81],C:[22,-81],D:[47,-46],K:[-66.5,0],E:[66.5,0],J:[-47,46],F:[47,46],I:[-22,81],G:[22,81]},ironHills:{a:[-43.75,-50],b:[0,-50],c:[43.75,-50],d:[-43.25,0],e:[0,0],f:[43.25,0],g:[-42.5,42.5],h:[0,50],i:[42.5,42.5],y:[-50,-50],z:[0,62.5],j:[-32.5,-32.5],k:[0,-40],l:[32.5,-32.5],m:[-32.5,32.5],n:[0,40],o:[32.5,32.5],p:[-37.5,0],q:[37.5,0],A:[-61,-67],B:[-22,-74],C:[22,-74],D:[61,-67],K:[-59,-20],E:[59,-20],J:[-57,26],F:[57,26],I:[-33,64],G:[33,64],H:[0,88]},urukHai:{a:[-40,-45],b:[0,-45],c:[40,-45],d:[-36,0],e:[0,0],f:[36,0],g:[-32.25,40],h:[0,40],i:[32.25,40],y:[-50,-50],z:[0,40],j:[-32.5,-32.5],k:[0,-37.5],l:[32.5,-32.5],m:[-27.5,27.5],n:[0,32.5],o:[27.5,27.5],p:[-37.5,0],q:[37.5,0],A:[-31,-79],B:[-1,-90],C:[31,-74],D:[61,-57],K:[-55,-19],E:[53,-19],J:[-45,19],F:[45,19],I:[-33,57],G:[35,57],H:[0,57],L:[-39,-50]},moriaOrc:{a:[-37.5,-37.5],b:[0,-37.5],c:[37.5,-37.5],d:[-37.5,0],e:[0,0],f:[37.5,0],g:[-37.5,37.5],h:[0,37.5],i:[37.5,37.5],y:[-50,-50],z:[0,40],j:[-30,-30],k:[0,-30],l:[30,-30],m:[-30,30],n:[0,30],o:[30,30],p:[-30,0],q:[30,0],A:[-48,-48],B:[-16,-50],C:[16,-46],D:[39,-61],K:[-52,-19],E:[52,-26],J:[-42,9],F:[52,9],I:[-31,40],G:[40,43],H:[4,47]}},n={horsehead:.9,horsehead2:.9,polish:.85,swiss:.95,boeotian:.75,roman:.95,kite:.65,targe2:.9,pavise:.9,wedged:.95,flag:.7,pennon:.5,guidon:.65,banner:.8,dovetail:.8,pennant:.6,oval:.95,vesicaPiscis:.8,diamond:.8,no:1.2,fantasy1:.8,fantasy2:.7,fantasy3:.7,fantasy5:.9,noldor:.5,gondor:.75,easterling:.8,erebor:.9,urukHai:.8,moriaOrc:.7},i={heater:"0 10 200 200",spanish:"0 10 200 200",french:"0 10 200 200",horsehead:"0 10 200 200",horsehead2:"0 10 200 200",polish:"0 0 200 200",hessen:"0 5 200 200",swiss:"0 10 200 200",boeotian:"0 0 200 200",roman:"0 0 200 200",kite:"0 0 200 200",oldFrench:"0 10 200 200",renaissance:"0 5 200 200",baroque:"0 10 200 200",targe:"0 0 200 200",targe2:"0 0 200 200",pavise:"0 0 200 200",wedged:"0 10 200 200",flag:"0 0 200 200",pennon:"2.5 0 200 200",guidon:"2.5 0 200 200",banner:"0 10 200 200",dovetail:"0 10 200 200",gonfalon:"0 10 200 200",pennant:"0 0 200 200",round:"0 0 200 200",oval:"0 0 200 200",vesicaPiscis:"0 0 200 200",square:"0 0 200 200",diamond:"0 0 200 200",no:"0 0 200 200",fantasy1:"0 0 200 200",fantasy2:"0 5 200 200",fantasy3:"0 5 200 200",fantasy4:"0 5 200 200",fantasy5:"0 0 200 200",noldor:"0 0 200 200",gondor:"0 5 200 200",easterling:"0 0 200 200",erebor:"0 0 200 200",ironHills:"0 5 200 200",urukHai:"0 0 200 200",moriaOrc:"0 0 200 200"},r={heater:"m25,25 h150 v50 a150,150,0,0,1,-75,125 a150,150,0,0,1,-75,-125 z",spanish:"m25,25 h150 v100 a75,75,0,0,1,-150,0 z",french:"m 25,25 h 150 v 139.15 c 0,41.745 -66,18.15 -75,36.3 -9,-18.15 -75,5.445 -75,-36.3 v 0 z",horsehead:"m 20,40 c 0,60 40,80 40,100 0,10 -4,15 -0.35,30 C 65,185.7 81,200 100,200 c 19.1,0 35.3,-14.6 40.5,-30.4 C 144.2,155 140,150 140,140 140,120 180,100 180,40 142.72,40 150,15 100,15 55,15 55,40 20,40 Z",horsehead2:"M60 20c-5 20-10 35-35 55 25 35 35 65 30 100 20 0 35 10 45 26 10-16 30-26 45-26-5-35 5-65 30-100a87 87 0 01-35-55c-25 3-55 3-80 0z",polish:"m 90.3,6.3 c -12.7,0 -20.7,10.9 -40.5,14 0,11.8 -4.9,23.5 -11.4,31.1 0,0 12.7,6 12.7,19.3 C 51.1,90.8 30,90.8 30,90.8 c 0,0 -3.6,7.4 -3.6,22.4 0,34.3 23.1,60.2 40.7,68.2 17.6,8 27.7,11.4 32.9,18.6 5.2,-7.3 15.3,-10.7 32.8,-18.6 17.6,-8 40.7,-33.9 40.7,-68.2 0,-15 -3.6,-22.4 -3.6,-22.4 0,0 -21.1,0 -21.1,-20.1 0,-13.3 12.7,-19.3 12.7,-19.3 C 155.1,43.7 150.2,32.1 150.2,20.3 130.4,17.2 122.5,6.3 109.7,6.3 102.5,6.3 100,10 100,10 c 0,0 -2.5,-3.7 -9.7,-3.7 z",hessen:"M170 20c4 5 8 13 15 20 0 0-10 0-10 15 0 100-15 140-75 145-65-5-75-45-75-145 0-15-10-15-10-15l15-20c0 15 10-5 70-5s70 20 70 5z",swiss:"m 25,20 c -0.1,0 25.2,8.5 37.6,8.5 C 75.1,28.5 99.1,20 100,20 c 0.6,0 24.9,8.5 37.3,8.5 C 149.8,28.5 174.4,20 175,20 l -0.3,22.6 C 173.2,160.3 100,200 100,200 100,200 26.5,160.9 25.2,42.6 Z",boeotian:"M150 115c-5 0-10-5-10-15s5-15 10-15c10 0 7 10 15 10 10 0 0-30 0-30-10-25-30-55-65-55S45 40 35 65c0 0-10 30 0 30 8 0 5-10 15-10 5 0 10 5 10 15s-5 15-10 15c-10 0-7-10-15-10-10 0 0 30 0 30 10 25 30 55 65 55s55-30 65-55c0 0 10-30 0-30-8 0-5 10-15 10z",roman:"m 160,170 c -40,20 -80,20 -120,0 V 30 C 80,10 120,10 160,30 Z",kite:"m 53.3,46.4 c 0,4.1 1,12.3 1,12.3 7.1,55.7 45.7,141.3 45.7,141.3 0,0 38.6,-85.6 45.7,-141.2 0,0 1,-8.1 1,-12.3 C 146.7,20.9 125.8,0.1 100,0.1 74.2,0.1 53.3,20.9 53.3,46.4 Z",oldFrench:"m25,25 h150 v75 a100,100,0,0,1,-75,100 a100,100,0,0,1,-75,-100 z",renaissance:"M 25,33.9 C 33.4,50.3 36.2,72.9 36.2,81.7 36.2,109.9 25,122.6 25,141 c 0,29.4 24.9,44.1 40.2,47.7 15.3,3.7 29.3,0 34.8,11.3 5.5,-11.3 19.6,-7.6 34.8,-11.3 C 150.1,185 175,170.3 175,141 c 0,-18.4 -11.2,-31.1 -11.2,-59.3 0,-8.8 2.8,-31.3 11.2,-47.7 L 155.7,14.4 C 138.2,21.8 119.3,25.7 100,25.7 c -19.3,0 -38.2,-3.9 -55.7,-11.3 z",baroque:"m 100,25 c 18,0 50,2 75,14 v 37 l -2.7,3.2 c -4.9,5.4 -6.6,9.6 -6.7,16.2 0,6.5 2,11.6 6.9,17.2 l 2.8,3.1 v 10.2 c 0,17.7 -2.2,27.7 -7.8,35.9 -5,7.3 -11.7,11.3 -32.3,19.4 -12.6,5 -20.2,8.8 -28.6,14.5 C 103.3,198 100,200 100,200 c 0,0 -2.8,-2.3 -6.4,-4.7 C 85.6,189.8 78,186 65,180.9 32.4,168.1 26.9,160.9 25.8,129.3 L 25,116 l 3.3,-3.3 c 4.8,-5.2 7,-10.7 7,-17.3 0,-6.8 -1.8,-11.1 -6.5,-16.1 L 25,76 V 39 C 50,27 82,25 100,25 Z",targe:"m 20,35 c 15,0 115,-60 155,-10 -5,10 -15,15 -10,50 5,45 10,70 -10,90 C 125,195 75,195 50,175 25,150 30,130 35,85 50,95 65,85 65,70 65,50 50,45 40,50 30,55 27,65 30,70 23,73 20,70 14,70 11,60 20,45 20,35 Z",targe2:"m 84,32.2 c 6.2,-1 19.5,-31.4 94.1,-20.2 -30.57,33.64 -21.66,67.37 -11.2,95 20.2,69.5 -41.17549,84.7 -66.88,84.7 C 74.32,191.7071 8.38,168.95 32,105.9 36.88,92.88 31,89 31,82.6 35.15,82.262199 56.79,86.17 56.5,69.8 56.20,52.74 42.2,47.9 25.9,55.2 25.9,51.4 39.8,6.7 84,32.2 Z",pavise:"M95 7L39.9 37.3a10 10 0 00-5.1 9.5L46 180c.4 5.2 3.7 10 9 10h90c5.3 0 9.6-4.8 10-10l10.6-133.2a10 10 0 00-5-9.5L105 7c-4.2-2.3-6.2-2.3-10 0z",wedged:"m 51.2,19 h 96.4 c 3.1,12.7 10.7,20.9 26.5,20.8 C 175.7,94.5 165.3,144.3 100,200 43.5,154.2 22.8,102.8 25.1,39.7 37,38.9 47.1,34.7 51.2,19 Z",round:"m 185,100 a 85,85 0 0 1 -85,85 85,85 0 0 1 -85,-85 85,85 0 0 1 85,-85 85,85 0 0 1 85,85",oval:"m 32.3,99.5 a 67.7,93.7 0 1 1 0,1.3 z",vesicaPiscis:"M 100,0 C 63.9,20.4 41,58.5 41,100 c 0,41.5 22.9,79.6 59,100 36.1,-20.4 59,-58.5 59,-100 C 159,58.5 136.1,20.4 100,0 Z",square:"M 25,25 H 175 V 175 H 25 Z",diamond:"M 25,100 100,200 175,100 100,0 Z",no:"m0,0 h200 v200 h-200 z",flag:"M 10,40 h180 v120 h-180 Z",pennon:"M 10,40 l190,60 -190,60 Z",guidon:"M 10,40 h190 l-65,60 65,60 h-190 Z",banner:"m 25,25 v 170 l 25,-40 25,40 25,-40 25,40 25,-40 25,40 V 25 Z",dovetail:"m 25,25 v 175 l 75,-40 75,40 V 25 Z",gonfalon:"m 25,25 v 125 l 75,50 75,-50 V 25 Z",pennant:"M 25,15 100,200 175,15 Z",fantasy1:"M 100,5 C 85,30 40,35 15,40 c 40,35 20,90 40,115 15,25 40,30 45,45 5,-15 30,-20 45,-45 20,-25 0,-80 40,-115 C 160,35 115,30 100,5 Z",fantasy2:"m 152,21 c 0,0 -27,14 -52,-4 C 75,35 48,21 48,21 50,45 30,55 30,75 60,75 60,115 32,120 c 3,40 53,50 68,80 15,-30 65,-40 68,-80 -28,-5 -28,-45 2,-45 C 170,55 150,45 152,21 Z",fantasy3:"M 167,67 C 165,0 35,0 33,67 c 32,-7 27,53 -3,43 -5,45 60,65 70,90 10,-25 75,-47.51058 70,-90 -30,10 -35,-50 -3,-43 z",fantasy4:"M100 9C55 48 27 27 13 39c23 50 3 119 49 150 14 9 28 11 38 11s27-4 38-11c55-39 24-108 49-150-14-12-45 7-87-30z",fantasy5:"M 100,0 C 75,25 30,25 30,25 c 0,69 20,145 70,175 50,-30 71,-106 70,-175 0,0 -45,0 -70,-25 z",noldor:"m 55,75 h 2 c 3,-25 38,-10 3,20 15,50 30,75 40,105 10,-30 25,-55 40,-105 -35,-30 0,-45 3,-20 h 2 C 150,30 110,20 100,0 90,20 50,30 55,75 Z",gondor:"m 100,200 c 15,-15 38,-35 45,-60 h 5 V 30 h -5 C 133,10 67,10 55,30 h -5 v 110 h 5 c 7,25 30,45 45,60 z",easterling:"M 160,185 C 120,170 80,170 40,185 V 15 c 40,15 80,15 120,0 z",erebor:"M25 135 V60 l22-13 16-37 h75 l15 37 22 13 v75l-22 18-16 37 H63l-16-37z",ironHills:"m 30,25 60,-10 10,10 10,-10 60,10 -5,125 -65,50 -65,-50 z",urukHai:"M 30,60 C 40,60 60,50 60,20 l -5,-3 45,-17 75,40 -5,5 -35,155 -5,-35 H 70 v 35 z",moriaOrc:"M45 35c5 3 7 10 13 9h19c4-2 7-4 9-9 6 1 9 9 16 11 7-2 14 0 21 0 6-3 6-10 10-15 2-5 1-10-2-15-2-4-5-14-4-16 3 6 7 11 12 14 7 3 3 12 7 16 3 6 4 12 9 18 2 4 6 8 5 14 0 6-1 12 3 18-3 6-2 13-1 20 1 6-2 12-1 18 0 6-3 13 0 18 8 4 0 8-5 7-4 3-9 3-13 9-5 5-5 13-8 19 0 6 0 15-7 16-1 6-7 6-10 12-1-6 0-6-2-9l2-19c2-4 5-12-3-12-4-5-11-5-15 1l-13-18c-3-4-2 9-3 12 2 2-4-6-7-5-8-2-8 7-11 11-2 4-5 10-8 9 3-10 3-16 1-23-1-4 2-9-4-11 0-6 1-13-2-19-4-2-9-6-13-7V91c4-7-5-13 0-19-3-7 2-11 2-18-1-6 1-12 3-17v-1z"},c={straight:"m 0,100 v15 h 200 v -15 z",engrailed:"m 0,95 a 6.25,6.25 0 0 0 12.5,0 6.25,6.25 0 0 0 12.5,0 6.25,6.25 0 0 0 12.5,0 6.25,6.25 0 0 0 12.5,0 6.25,6.25 0 0 0 12.5,0 6.25,6.25 0 0 0 12.5,0 6.25,6.25 0 0 0 12.5,0 6.25,6.25 0 0 0 12.5,0 6.25,6.25 0 0 0 12.5,0 6.25,6.25 0 0 0 12.5,0 6.25,6.25 0 0 0 12.5,0 6.25,6.25 0 0 0 12.5,0 6.25,6.25 0 0 0 12.5,0 6.25,6.25 0 0 0 12.5,0 6.25,6.25 0 0 0 12.5,0 6.25,6.25 0 0 0 12.5,0 v 20 H 0 Z",invecked:"M0,102.5 a6.25,6.25,0,0,1,12.5,0 a6.25,6.25,0,0,1,12.5,0 a6.25,6.25,0,0,1,12.5,0 a6.25,6.25,0,0,1,12.5,0 a6.25,6.25,0,0,1,12.5,0 a6.25,6.25,0,0,1,12.5,0 a6.25,6.25,0,0,1,12.5,0 a6.25,6.25,0,0,1,12.5,0 a6.25,6.25,0,0,1,12.5,0 a6.25,6.25,0,0,1,12.5,0 a6.25,6.25,0,0,1,12.5,0 a6.25,6.25,0,0,1,12.5,0 a6.25,6.25,0,0,1,12.5,0 a6.25,6.25,0,0,1,12.5,0 a6.25,6.25,0,0,1,12.5,0 a6.25,6.25,0,0,1,12.5,0 v12.5 H0 z",embattled:"M 0,105 H 2.5 V 95 h 15 v 10 h 15 V 95 h 15 v 10 h 15 V 95 h 15 v 10 h 15 V 95 h 15 v 10 h 15 V 95 h 15 v 10 h 15 V 95 h 15 v 10 h 15 V 95 h 15 v 10 h 2.5 v 10 H 0 Z",wavy:"m 200,115 v -15 c -8.9,3.5 -16,3.1 -25,0 -8.9,-3.5 -16,-3.1 -25,0 -8.9,3.5 -16,3.2 -25,0 -8.9,-3.5 -16,-3.2 -25,0 -8.9,3.5 -16,3.1 -25,0 -8.9,-3.5 -16,-3.1 -25,0 -8.9,3.5 -16,3.2 -25,0 -8.9,-3.5 -16,-3.2 -25,0 v 15 z",raguly:"m 200,95 h -3 l -5,10 h -10 l 5,-10 h -10 l -5,10 h -10 l 5,-10 h -10 l -5,10 h -10 l 5,-10 h -10 l -5,10 h -10 l 5,-10 h -10 l -5,10 h -10 l 5,-10 H 97 l -5,10 H 82 L 87,95 H 77 l -5,10 H 62 L 67,95 H 57 l -5,10 H 42 L 47,95 H 37 l -5,10 H 22 L 27,95 H 17 l -5,10 H 2 L 7,95 H 0 v 20 h 200 z",dancetty:"m 0,105 10,-15 15,20 15,-20 15,20 15,-20 15,20 15,-20 15,20 15,-20 15,20 15,-20 15,20 15,-20 10,15 v 10 H 0 Z",dentilly:"M 180,105 170,95 v 10 L 160,95 v 10 L 150,95 v 10 L 140,95 v 10 L 130,95 v 10 L 120,95 v 10 L 110,95 v 10 L 100,95 v 10 L 90,95 v 10 L 80,95 v 10 L 70,95 v 10 L 60,95 v 10 L 50,95 v 10 L 40,95 v 10 L 30,95 v 10 L 20,95 v 10 L 10,95 v 10 L 0,95 v 20 H 200 V 105 L 190,95 v 10 L 180,95 Z",angled:"m 0,95 h 100 v 10 h 100 v 10 H 0 Z",urdy:"m 200,90 -5,5 v 10 l -5,5 -5,-5 V 95 l -5,-5 -5,5 v 10 l -5,5 -5,-5 V 95 l -5,-5 -5,5 v 10 l -5,5 -5,-5 V 95 l -5,-5 -5,5 v 10 l -5,6 -5,-6 V 95 l -5,-5 -5,5 v 10 l -5,5 -5,-5 V 95 l -5,-5 -5,5 v 10 l -5,5 -5,-5 V 95 l -5,-5 -5,5 v 10 l -5,6 -5,-6 V 95 l -5,-5 -5,5 v 10 l -5,5 -5,-5 V 95 l -5,-5 -5,5 v 10 l -5,5 -5,-5 V 95 l -5,-5 -5,5 v 10 l -5,5 -5,-5 V 95 L 0,90 v 25 h 200",indented:"m 100,95 5,10 5,-10 5,10 5,-10 5,10 5,-10 5,10 5,-10 5,10 5,-10 5,10 5,-10 5,10 5,-10 5,10 5,-10 5,10 5,-10 5,10 5,-10 v 20 H 0 V 95 l 5,10 5,-10 5,10 5,-10 5,10 5,-10 5,10 5,-10 5,10 5,-10 5,10 5,-10 5,10 5,-10 5,10 5,-10 5,10 5,-10 5,10 z",bevilled:"m 0,92.5 h 110 l -20,15 H 200 V 115 H 0 Z",nowy:"m 0,95 h 80 c 0,0 0.1,20.1 20,20 19.9,-0.1 20,-20 20,-20 h 80 v 20 H 0 Z",nowyReversed:"m 200,105 h -80 c 0,0 -0.1,-20.1 -20,-20 -19.9,0.1 -20,20 -20,20 H 0 v 10 h 200 z",potenty:"m 3,95 v 5 h 5 v 5 H 0 v 10 h 200 l 0.5,-10 H 193 v -5 h 5 v -5 h -15 v 5 h 5 v 5 h -15 v -5 h 5 v -5 h -15 v 5 h 5 v 5 h -15 v -5 h 5 v -5 h -15 v 5 h 5 v 5 h -15 v -5 h 5 v -5 h -15 v 5 h 5 v 5 h -15 v -5 h 5 v -5 h -15 v 5 h 5 v 5 H 100.5 93 v -5 h 5 V 95 H 83 v 5 h 5 v 5 H 73 v -5 h 5 V 95 H 63 v 5 h 5 v 5 H 53 v -5 h 5 V 95 H 43 v 5 h 5 v 5 H 33 v -5 h 5 V 95 H 23 v 5 h 5 v 5 H 13 v -5 h 5 v -5 z",potentyDexter:"m 200,105 h -2 v -10 0 0 h -10 v 5 h 5 v 5 H 183 V 95 h -10 v 5 h 5 v 5 H 168 V 95 h -10 v 5 h 5 v 5 H 153 V 95 h -10 v 5 h 5 v 5 H 138 V 95 h -10 v 5 h 5 v 5 H 123 V 95 h -10 v 5 h 5 v 5 h -10 v 0 0 -10 H 98 v 5 h 5 v 5 H 93 V 95 H 83 v 5 h 5 v 5 H 78 V 95 H 68 v 5 h 5 v 5 H 63 V 95 H 53 v 5 h 5 v 5 H 48 V 95 H 38 v 5 h 5 v 5 H 33 V 95 H 23 v 5 h 5 v 5 H 18 V 95 H 8 v 5 h 5 v 5 H 3 V 95 H 0 v 20 h 200 z",potentySinister:"m 2.5,95 v 10 H 0 v 10 h 202.5 v -15 h 5 v -5 h -10 v 10 h -10 v -5 h 5 v -5 h -10 v 10 h -10 v -5 h 5 v -5 h -10 v 10 h -10 v -5 h 5 v -5 h -10 v 10 h -10 v -5 h 5 v -5 h -10 v 10 h -10 v -5 h 5 v -5 h -10 v 10 h -10 v -5 h 5 v -5 h -10 v 10 h -10 v -5 h 5 v -5 h -10 v 10 h -10 v -5 h 5 v -5 h -10 v 10 h -10 v -5 h 5 v -5 h -10 v 10 h -10 v -5 h 5 v -5 h -10 v 10 h -10 v -5 h 5 v -5 h -10 v 10 h -10 v -5 h 5 v -5 h -10 v 10 h -10 v -5 h 5 v -5 z",embattledGhibellin:"M 200,200 V 100 l -5,-5 v 10 l -5,-5 -5,5 V 95 l -5,5 -5,-5 v 10 l -5,-5 -5,5 V 95 l -5,5 -5,-5 v 10 l -5,-5 -5,5 V 95 l -5,5 -5,-5 v 10 l -5,-5 -5,5 V 95 l -5,5 -5,-5 v 10 l -5,-5 -5,5 V 95 l -5,5 -5,-5 v 10 l -5,-5 -5,5 V 95 l -5,5 -5,-5 v 10 l -5,-5 -5,5 V 95 l -5,5 -5,-5 v 10 l -5,-5 -5,5 V 95 l -5,5 -5,-5 v 10 l -5,-5 -5,5 V 95 l -5,5 -5,-5 v 10 l -5,-5 -5,5 V 95 l -5,5 v 15 h 200",embattledNotched:"m 200,105 h -5 V 95 l -5,5 -5,-5 v 10 h -5 V 95 l -5,5 -5,-5 v 10 h -5 V 95 l -5,5 -5,-5 v 10 h -5 V 95 l -5,5 -5,-5 v 10 h -5 V 95 l -5,5 -5,-5 v 10 h -5 V 95 l -5,5 -5,-5 v 10 h -5 V 95 l -5,5 -5,-5 v 10 H 90 V 95 l -5,5 -5,-5 v 10 H 75 V 95 l -5,5 -5,-5 v 10 H 60 V 95 l -5,5 -5,-5 v 10 H 45 V 95 l -5,5 -5,-5 v 10 H 30 V 95 l -5,5 -5,-5 v 10 H 15 V 95 l -5,5 -5,-5 v 10 H 0 v 10 h 200",embattledGrady:"m 0,95 v 20 H 200 V 95 h -2.5 v 5 h -5 v 5 h -5 v -5 h -5 v -5 h -5 v 5 h -5 v 5 h -5 v -5 h -5 v -5 h -5 v 5 h -5 v 5 h -5 v -5 h -5 v -5 h -5 v 5 h -5 v 5 h -5 v -5 h -5 v -5 h -5 v 5 h -5 v 5 h -5 v -5 h -5 v -5 h -5 v 5 h -5 v 5 h -5 v -5 h -5 v -5 h -5 v 5 h -5 v 5 h -5 v -5 h -5 v -5 h -5 v 5 h -5 v 5 h -5 v -5 h -5 v -5 h -5 v 5 h -5 v 5 h -5 v -5 h -5 v -5 h -5 v 5 h -5 v 5 h -5 v -5 h -5 v -5 z",dovetailed:"m 200,95 h -7 l 4,10 h -14 l 4,-10 h -14 l 4,10 h -14 l 4,-10 h -14 l 4,10 h -14 l 4,-10 h -14 l 4,10 h -14 l 4,-10 h -14 l 4,10 h -14 l 4,-10 H 93 l 4,10 H 83 L 87,95 H 73 l 4,10 H 63 L 67,95 H 53 l 4,10 H 43 L 47,95 H 33 l 4,10 H 23 L 27,95 H 13 l 4,10 H 3 L 7,95 H 0 v 20 h 200",dovetailedIndented:"m 200,100 -7,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 -4.46,-3.55 -4.25,0 -7.16,3.17 -8.75,5.18 -1.59,2.01 -4.5,5.18 -8.75,5.18 -2.16,0 -3.91,-1.63 -3.91,-3.64 0,-2.01 1.75,-3.64 3.91,-3.64 0.7,0 1.36,0.17 1.93,0.48 -0.34,-2.01 -2.21,-3.55 -4.46,-3.55 -4.25,0 -7.16,3.17 -8.75,5.18 -1.59,2.01 -4.5,5.18 -8.75,5.18 -2.16,0 -3.91,-1.63 -3.91,-3.64 0,-2.01 1.75,-3.64 3.91,-3.64 0.7,0 1.36,0.17 1.93,0.48 -0.34,-2.01 -2.21,-3.55 -4.46,-3.55 -4.25,0 -7.16,3.17 -8.75,5.18 -1.59,2.01 -4.5,5.18 -8.75,5.18 -2.16,0 -3.91,-1.63 -3.91,-3.64 0,-2.01 1.75,-3.64 3.91,-3.64 0.7,0 1.36,0.17 1.93,0.48 -0.34,-2.01 -2.2,-3.55 -4.46,-3.55 -4.25,0 -7.16,3.17 -8.75,5.18 -1.59,2.01 -4.5,5.18 -8.75,5.18 -2.16,0 -3.91,-1.63 -3.91,-3.64 0,-2.01 1.44,-3.6 3.6,-3.6 0.7,0 1.36,0.17 1.93,0.48 -0.34,-2.01 -2.21,-3.55 -4.46,-3.55 -4.25,0 -6.6,3.09 -8.19,5.09 -1.59,2.01 -4.5,5.18 -8.75,5.18 -2.16,0 -3.91,-1.63 -3.91,-3.64 0,-2.01 1.75,-3.64 3.91,-3.64 0.7,0 1.36,0.17 1.93,0.48 -0.34,-2.01 -2.21,-3.55 -4.46,-3.55 -4.25,0 -7.16,3.17 -8.75,5.18 -1.59,2.01 -4.5,5.18 -8.75,5.18 -2.16,0 -3.91,-1.63 -3.91,-3.64 0,-2.01 1.75,-3.64 3.91,-3.64 0.7,0 1.36,0.17 1.93,0.48 -0.34,-2.01 -2.2,-3.55 -4.46,-3.55 -4.25,0 -7.16,3.17 -8.75,5.18 -1.59,2.01 -4.5,5.18 -8.75,5.18 -2.16,0 -3.91,-1.63 -3.91,-3.64 0,-2.01 1.75,-3.64 3.91,-3.64 0.7,0 1.36,0.17 1.93,0.48 -0.34,-2.01 -2.2,-3.55 -4.46,-3.55 -4.25,0 -7.16,3.17 -8.75,5.18 -1.59,2.01 -4.5,5.18 -8.75,5.18 -2.16,0 -3.91,-1.63 -3.91,-3.64 0,-2.01 1.75,-3.64 3.91,-3.64 0.7,0 1.36,0.17 1.93,0.48 -0.34,-2.01 -2.21,-3.55 -4.46,-3.55 z",dragonTeeth:"M 9.4,85 C 6.5,88.1 4.1,92.9 3,98.8 1.9,104.6 2.3,110.4 3.8,115 2.4,113.5 0,106.6 0,109.3 v 5.7 h 200 v -5.7 c -1.1,-2.4 -2,-5.1 -2.6,-8 -1.1,-5.9 -0.7,-11.6 0.8,-16.2 -2.9,3.1 -5.3,7.9 -6.4,13.8 -1.1,5.9 -0.7,11.6 0.8,16.2 -2.9,-3.1 -5.3,-7.9 -6.4,-13.8 -1.1,-5.9 -0.7,-11.6 0.8,-16.2 -2.9,3.1 -5.3,7.9 -6.4,13.8 -1.1,5.9 -0.7,11.6 0.8,16.2 -2.9,-3.1 -5.3,-7.9 -6.4,-13.8 -1.1,-5.9 -0.7,-11.6 0.8,-16.2 -2.9,3.1 -5.3,7.9 -6.4,13.8 -1.1,5.9 -0.7,11.6 0.8,16.2 -2.9,-3.1 -5.3,-7.9 -6.4,-13.8 -1.1,-5.9 -0.7,-11.6 0.8,-16.2 -2.9,3.1 -5.3,7.9 -6.4,13.8 -1.1,5.9 -0.7,11.6 0.8,16.2 -2.9,-3.1 -5.3,-7.9 -6.4,-13.8 -1.1,-5.9 -0.7,-11.6 0.8,-16.2 -2.9,3.1 -5.3,7.9 -6.4,13.8 -1.1,5.9 -0.7,11.6 0.8,16.2 -2.9,-3.1 -5.3,-7.9 -6.4,-13.8 -1.1,-5.9 -0.7,-11.6 0.8,-16.2 -2.9,3.1 -5.3,7.9 -6.4,13.8 -1.1,5.9 -0.7,11.6 0.8,16.2 -2.9,-3.1 -5.3,-7.9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h 85 v 15 H 0 Z",barby:"m 0,100 h 85 l 15,15 15,-15 h 85 v 15 H 0 Z",enclavy:"M 0,100 H 85 V 85 h 30 v 15 h 85 v 15 H 0 Z",escartely:"m 0,100 h 85 v 15 h 30 v -15 h 85 v 15 H 0 Z",arched:"m 100,95 c 40,-0.2 100,20 100,20 H 0 c 0,0 60,-19.8 100,-20 z",archedReversed:"m 0,85 c 0,0 60,20.2 100,20 40,-0.2 100,-20 100,-20 v 30 H 0 Z"},f={perFess:'<rect x="0" y="100" width="200" height="100"/>',perPale:'<rect x="100" y="0" width="100" height="200"/>',perBend:'<polygon points="0,0 200,200 0,200"/>',perBendSinister:'<polygon points="200,0 0,200 200,200"/>',perChevron:'<polygon points="0,200 100,100 200,200"/>',perChevronReversed:'<polygon points="0,0 100,100 200,0"/>',perCross:'<rect x="100" y="0" width="100" height="100"/><rect x="0" y="100" width="100" height="100"/>',perPile:'<polygon points="0,0 15,0 100,200 185,0 200,0 200,200 0,200"/>',perSaltire:'<polygon points="0,0 0,200 200,0 200,200"/>',gyronny:'<polygon points="0,0 200,200 200,100 0,100"/><polygon points="200,0 0,200 100,200 100,0"/>',chevronny:'<path d="M0,80 100,-15 200,80 200,120 100,25 0,120z M0,160 100,65 200,160 200,200 100,105 0,200z M0,240 100,145 200,240 0,240z"/>',perFessLined:o=>`<path d="${o}"/><rect x="0" y="115" width="200" height="85" shape-rendering="crispedges"/>`,perPaleLined:o=>`<path d="${o}" transform="rotate(-90 100 100)"/><rect x="115" y="0" width="85" height="200" shape-rendering="crispedges"/>`,perBendLined:o=>`<path d="${o}" transform="translate(-10 -10) rotate(45 110 110) scale(1.1)"/><rect x="0" y="115" width="200" height="85" transform="translate(-10 -10) rotate(45 110 110) scale(1.1)" shape-rendering="crispedges"/>`,perBendSinisterLined:o=>`<path d="${o}" transform="translate(-10 -10) rotate(-45 110 110) scale(1.1)"/><rect x="0" y="115" width="200" height="85" transform="translate(-10 -10) rotate(-45 110 110) scale(1.1)" shape-rendering="crispedges"/>`,perChevronLined:o=>`<rect x="15" y="115" width="200" height="200" transform="translate(70 70) rotate(45 100 100)"/><path d="${o}" transform="translate(129 71) rotate(-45 -100 100) scale(-1 1)"/><path d="${o}" transform="translate(71 71) rotate(45 100 100)"/>`,perChevronReversedLined:o=>`<rect x="15" y="115" width="200" height="200" transform="translate(-70 -70) rotate(225.001 100 100)"/><path d="${o}" transform="translate(-70.7 -70.7) rotate(225 100 100) scale(1 1)"/><path d="${o}" transform="translate(270.7 -70.7) rotate(-225 -100 100) scale(-1 1)"/>`,perCrossLined:o=>`<rect x="100" y="0" width="100" height="92.5"/><rect x="0" y="107.5" width="100" height="92.5"/><path d="${o}" transform="translate(0 50) scale(.5001)"/><path d="${o}" transform="translate(200 150) scale(-.5)"/>`,perPileLined:o=>`<path d="${o}" transform="translate(161.66 10) rotate(66.66 -100 100) scale(-1 1)"/><path d="${o}" transform="translate(38.33 10) rotate(-66.66 100 100)"/><polygon points="-2.15,0 84.15,200 115.85,200 202.15,0 200,200 0,200"/>`,fess:'<rect x="0" y="75" width="200" height="50"/>',pale:'<rect x="75" y="0" width="50" height="200"/>',bend:'<polygon points="35,0 200,165 200,200 165,200 0,35 0,0"/>',bendSinister:'<polygon points="0,165 165,0 200,0 200,35 35,200 0,200"/>',chief:'<rect width="200" height="75"/>',bar:'<rect x="0" y="87.5" width="200" height="25"/>',gemelle:'<rect x="0" y="76" width="200" height="16"/><rect x="0" y="108" width="200" height="16"/>',fessCotissed:'<rect x="0" y="67" width="200" height="8"/><rect x="0" y="83" width="200" height="34"/><rect x="0" y="125" width="200" height="8"/>',fessDoubleCotissed:'<rect x="0" y="60" width="200" height="7.5"/><rect x="0" y="72.5" width="200" height="7.5"/><rect x="0" y="85" width="200" height="30"/><rect x="0" y="120" width="200" height="7.5"/><rect x="0" y="132.5" width="200" height="7.5"/>',bendlet:'<polygon points="22,0 200,178 200,200 178,200 0,22 0,0"/>',bendletSinister:'<polygon points="0,178 178,0 200,0 200,22 22,200 0,200"/>',terrace:'<rect x="0" y="145" width="200" height="55"/>',cross:'<polygon points="85,0 85,85 0,85 0,115 85,115 85,200 115,200 115,115 200,115 200,85 115,85 115,0"/>',crossParted:'<path d="M 80 0 L 80 80 L 0 80 L 0 95 L 80 95 L 80 105 L 0 105 L 0 120 L 80 120 L 80 200 L 95 200 L 95 120 L 105 120 L 105 200 L 120 200 L 120 120 L 200 120 L 200 105 L 120 105 L 120 95 L 200 95 L 200 80 L 120 80 L 120 0 L 105 0 L 105 80 L 95 80 L 95 0 L 80 0 z M 95 95 L 105 95 L 105 105 L 95 105 L 95 95 z"/>',saltire:'<path d="M 0,21 79,100 0,179 0,200 21,200 100,121 179,200 200,200 200,179 121,100 200,21 200,0 179,0 100,79 21,0 0,0 Z"/>',saltireParted:'<path d="M 7 0 L 89 82 L 82 89 L 0 7 L 0 28 L 72 100 L 0 172 L 0 193 L 82 111 L 89 118 L 7 200 L 28 200 L 100 128 L 172 200 L 193 200 L 111 118 L 118 111 L 200 193 L 200 172 L 128 100 L 200 28 L 200 7 L 118 89 L 111 82 L 193 0 L 172 0 L 100 72 L 28 0 L 7 0 z M 100 93 L 107 100 L 100 107 L 93 100 L 100 93 z"/>',mount:'<path d="m0,250 a100,100,0,0,1,200,0"/>',point:'<path d="M0,200 Q80,180 100,135 Q120,180 200,200"/>',flaunches:'<path d="M0,0 q120,100 0,200 M200,0 q-120,100 0,200"/>',gore:'<path d="M20,0 Q30,75 100,100 Q80,150 100,200 L0,200 L0,0 Z"/>',pall:'<polygon points="0,0 30,0 100,70 170,0 200,0 200,30 122,109 122,200 78,200 78,109 0,30"/>',pallReversed:'<polygon points="0,200 0,170 78,91 78,0 122,0 122,91 200,170 200,200 170,200 100,130 30,200"/>',chevron:'<polygon points="0,125 100,60 200,125 200,165 100,100 0,165"/>',chevronReversed:'<polygon points="0,75 100,140 200,75 200,35 100,100 0,35"/>',gyron:'<polygon points="0,0 100,100 0,100"/>',quarter:'<rect width="50%" height="50%"/>',canton:'<rect width="37.5%" height="37.5%"/>',pile:'<polygon points="70,0 100,175 130,0"/>',pileInBend:'<polygon points="200,200 200,144 25,25 145,200"/>',pileInBendSinister:'<polygon points="0,200 0,144 175,25 55,200"/>',piles:'<polygon points="46,0 75,175 103,0"/><polygon points="95,0 125,175 154,0"/>',pilesInPoint:'<path d="M15,0 100,200 60,0Z M80,0 100,200 120,0Z M140,0 100,200 185,0Z"/>',label:'<path d="m 46,54.8 6.6,-15.6 95.1,0 5.9,15.5 -16.8,0.1 4.5,-11.8 L 104,43 l 4.3,11.9 -16.8,0 4.3,-11.8 -37.2,0 4.5,11.8 -16.9,0 z"/>',fessLined:o=>`<path d="${o}" transform="translate(0 -25)"/><path d="${o}" transform="translate(0 25) rotate(180 100 100)"/><rect x="0" y="88" width="200" height="24" stroke="none"/>`,paleLined:o=>`<path d="${o}" transform="rotate(-90 100 100) translate(0 -25)"/><path d="${o}" transform="rotate(90 100 100) translate(0 -25)"/><rect x="88" y="0" width="24" height="200" stroke="none"/>`,bendLined:o=>`<path d="${o}" transform="translate(8 -18) rotate(45 110 100) scale(1.1 1)"/><path d="${o}" transform="translate(-28 18) rotate(225 110 100) scale(1.1 1)"/><rect x="0" y="88" width="200" height="24" transform="translate(-10 0) rotate(45 110 100) scale(1.1 1)" stroke="none"/>`,bendSinisterLined:o=>`<path d="${o}" transform="translate(-28 -18) rotate(-45 110 100) scale(1.1 1)"/><path d="${o}" transform="translate(8 18) rotate(-225 110 100) scale(1.1 1)"/><rect x="0" y="88" width="200" height="24" transform="translate(-10 0) rotate(-45 110 100) scale(1.1 1)" stroke="none"/>`,chiefLined:o=>`<path d="${o}" transform="translate(0,-25) rotate(180.00001 100 100)"/><rect width="200" height="62" stroke="none"/>`,barLined:o=>`<path d="${o}" transform="translate(0,-12.5)"/><path d="${o}" transform="translate(0,12.5) rotate(180.00001 100 100)"/><rect x="0" y="94" width="200" height="12" stroke="none"/>`,gemelleLined:o=>`<path d="${o}" transform="translate(0,-22.5)"/><path d="${o}" transform="translate(0,22.5) rotate(180.00001 100 100)"/>`,fessCotissedLined:o=>`<path d="${o}" transform="translate(0 15) scale(1 .5)"/><path d="${o}" transform="translate(0 85) rotate(180 100 50) scale(1 .5)"/><rect x="0" y="80" width="200" height="40"/>`,fessDoubleCotissedLined:o=>`<rect x="0" y="85" width="200" height="30"/><rect x="0" y="72.5" width="200" height="7.5"/><rect x="0" y="120" width="200" height="7.5"/><path d="${o}" transform="translate(0 10) scale(1 .5)"/><path d="${o}" transform="translate(0 90) rotate(180 100 50) scale(1 .5)"/>`,bendletLined:o=>`<path d="${o}" transform="translate(2 -12) rotate(45 110 100) scale(1.1 1)"/><path d="${o}" transform="translate(-22 12) rotate(225 110 100) scale(1.1 1)"/><rect x="0" y="94" width="200" height="12" transform="translate(-10 0) rotate(45 110 100) scale(1.1 1)" stroke="none"/>`,bendletSinisterLined:o=>`<path d="${o}" transform="translate(-22 -12) rotate(-45 110 100) scale(1.1 1)"/><path d="${o}" transform="translate(2 12) rotate(-225 110 100) scale(1.1 1)"/><rect x="0" y="94" width="200" height="12" transform="translate(-10 0) rotate(-45 110 100) scale(1.1 1)" stroke="none"/>`,terraceLined:o=>`<path d="${o}" transform="translate(0,50)"/><rect x="0" y="164" width="200" height="36" stroke="none"/>`,crossLined:o=>`<path d="${o}" transform="translate(0,-14.5)"/><path d="${o}" transform="rotate(180 100 100) translate(0,-14.5)"/><path d="${o}" transform="rotate(-90 100 100) translate(0,-14.5)"/><path d="${o}" transform="rotate(-270 100 100) translate(0,-14.5)"/>`,crossPartedLined:o=>`<path d="${o}" transform="translate(0,-20)"/><path d="${o}" transform="rotate(180 100 100) translate(0,-20)"/><path d="${o}" transform="rotate(-90 100 100) translate(0,-20)"/><path d="${o}" transform="rotate(-270 100 100) translate(0,-20)"/>`,saltireLined:o=>`<path d="${o}" transform="translate(0 -10) rotate(45 110 100) scale(1.1 1)"/><path d="${o}" transform="translate(-20 10) rotate(225 110 100) scale(1.1 1)"/><path d="${o}" transform="translate(-20 -10) rotate(-45 110 100) scale(1.1 1)"/><path d="${o}" transform="translate(0 10) rotate(-225 110 100) scale(1.1 1)"/>`,saltirePartedLined:o=>`<path d="${o}" transform="translate(3 -13) rotate(45 110 100) scale(1.1 1)"/><path d="${o}" transform="translate(-23 13) rotate(225 110 100) scale(1.1 1)"/><path d="${o}" transform="translate(-23 -13) rotate(-45 110 100) scale(1.1 1)"/><path d="${o}" transform="translate(3 13) rotate(-225 110 100) scale(1.1 1)"/>`},z={semy:(o,l,a,w,S)=>`<pattern id="${o}" width="${w*.125}" height="${w*.125}" viewBox="0 0 200 200" stroke="#000"><rect width="200" height="200" fill="${l}" stroke="none"/><g fill="${a}"><use transform="translate(-100 -50)" href="#${S}"/><use transform="translate(100 -50)" href="#${S}"/><use transform="translate(0 50)" href="#${S}"/></g></pattern>`,vair:(o,l,a,w)=>`<pattern id="${o}" width="${w*.125}" height="${w*.25}" viewBox="0 0 25 50" stroke="#000" stroke-width=".2"><rect width="25" height="25" fill="${l}" stroke="none"/><path d="m12.5,0 l6.25,6.25 v12.5 l6.25,6.25 h-25 l6.25,-6.25 v-12.5 z" fill="${a}"/><rect x="0" y="25" width="25" height="25" fill="${a}" stroke="none"/><path d="m25,25 l-6.25,6.25 v12.5 l-6.25,6.25 l-6.25,-6.25 v-12.5 l-6.25,-6.25 z" fill="${l}"/><path d="M0 50 h25" fill="none"/></pattern>`,counterVair:(o,l,a,w)=>`<pattern id="${o}" width="${w*.125}" height="${w*.25}" viewBox="0 0 25 50" stroke="#000" stroke-width=".2"><rect width="25" height="50" fill="${a}" stroke="none"/><path d="m 12.5,0 6.25,6.25 v 12.5 L 25,25 18.75,31.25 v 12.5 L 12.5,50 6.25,43.75 V 31.25 L 0,25 6.25,18.75 V 6.25 Z" fill="${l}"/></pattern>`,vairInPale:(o,l,a,w)=>`<pattern id="${o}" width="${w*.125}" height="${w*.125}" viewBox="0 0 25 25"><rect width="25" height="25" fill="${l}"/><path d="m12.5,0 l6.25,6.25 v12.5 l6.25,6.25 h-25 l6.25,-6.25 v-12.5 z" fill="${a}" stroke="#000" stroke-width=".2"/></pattern>`,vairEnPointe:(o,l,a,w)=>`<pattern id="${o}" width="${w*.125}" height="${w*.25}" viewBox="0 0 25 50"><rect width="25" height="25" fill="${a}"/><path d="m12.5,0 l6.25,6.25 v12.5 l6.25,6.25 h-25 l6.25,-6.25 v-12.5 z" fill="${l}"/><rect x="0" y="25" width="25" height="25" fill="${l}" stroke-width="1" stroke="${l}"/><path d="m12.5,25 l6.25,6.25 v12.5 l6.25,6.25 h-25 l6.25,-6.25 v-12.5 z" fill="${a}"/></pattern>`,vairAncien:(o,l,a,w)=>`<pattern id="${o}" width="${w*.125}" height="${w*.125}" viewBox="0 0 100 100"><rect width="100" height="100" fill="${l}"/><path fill="${a}" stroke="none" d="m 0,90 c 10,0 25,-5 25,-40 0,-25 10,-40 25,-40 15,0 25,15 25,40 0,35 15,40 25,40 v 10 H 0 Z"/><path fill="none" stroke="#000" d="M 0,90 c 10,0 25,-5 25,-40 0,-35 15,-40 25,-40 10,0 25,5 25,40 0,35 15,40 25,40 M0,100 h100"/></pattern>`,potent:(o,l,a,w)=>`<pattern id="${o}" width="${w*.125}" height="${w*.125}" viewBox="0 0 200 200" stroke="#000"><rect width="200" height="100" fill="${l}" stroke="none"/><rect y="100" width="200" height="100" fill="${a}" stroke="none"/><path d="m25 50h50v-50h50v50h50v50h-150z" fill="${a}"/><path d="m25 100v50h50v50h50v-50h50v-50z" fill="${l}"/><path d="m0 0h200 M0 100h200" fill="none"/></pattern>`,counterPotent:(o,l,a,w)=>`<pattern id="${o}" width="${w*.125}" height="${w*.125}" viewBox="0 0 200 200" stroke="none"><rect width="200" height="200" fill="${l}"/><path d="m25 50h50v-50h50v50h50v100h-50v50h-50v-50h-50v-50z" fill="${a}"/><path d="m0 0h200 M0 100h200 M0 200h200"/></pattern>`,potentInPale:(o,l,a,w)=>`<pattern id="${o}" width="${w*.125}" height="${w*.0625}" viewBox="0 0 200 100" stroke-width="1"><rect width="200" height="100" fill="${l}" stroke="none"/><path d="m25 50h50v-50h50v50h50v50h-150z" fill="${a}" stroke="#000"/><path d="m0 0h200 M0 100h200" fill="none" stroke="#000"/></pattern>`,potentEnPointe:(o,l,a,w)=>`<pattern id="${o}" width="${w*.125}" height="${w*.125}" viewBox="0 0 200 200" stroke="none"><rect width="200" height="200" fill="${l}"/><path d="m0 0h25v50h50v50h50v-50h50v-50h25v100h-25v50h-50v50h-50v-50h-50v-50h-25v-100" fill="${a}"/></pattern>`,ermine:(o,l,a,w)=>`<pattern id="${o}" width="${w*.125}" height="${w*.125}" viewBox="0 0 200 200" fill="${a}"><rect width="200" height="200" fill="${l}"/><g stroke="none" fill="${a}"><g transform="translate(-100 -50)"><path d="m100 81.1c-4.25 17.6-12.7 29.8-21.2 38.9 3.65-0.607 7.9-3.04 11.5-5.47-2.42 4.86-4.86 8.51-7.3 12.7 1.82-0.607 6.07-4.86 12.7-10.9 1.21 8.51 2.42 17.6 4.25 23.6 1.82-5.47 3.04-15.2 4.25-23.6 3.65 3.65 7.3 7.9 12.7 10.9l-7.9-13.3c3.65 1.82 7.9 4.86 11.5 6.07-9.11-9.11-17-21.2-20.6-38.9z"/><path d="m82.4 81.7c-0.607-0.607-6.07 2.42-9.72-4.25 7.9 6.68 15.2-7.3 21.8 1.82 1.82 4.25-6.68 10.9-12.1 2.42z"/><path d="m117 81.7c0.607-1.21 6.07 2.42 9.11-4.86-7.3 7.3-15.2-7.3-21.2 2.42-1.82 4.25 6.68 10.9 12.1 2.42z"/><path d="m101 66.5c-1.02-0.607 3.58-4.25-3.07-8.51 5.63 7.9-10.2 10.9-1.54 17.6 3.58 2.42 12.2-2.42 4.6-9.11z"/></g><g transform="translate(100 -50)"><path d="m100 81.1c-4.25 17.6-12.7 29.8-21.2 38.9 3.65-0.607 7.9-3.04 11.5-5.47-2.42 4.86-4.86 8.51-7.3 12.7 1.82-0.607 6.07-4.86 12.7-10.9 1.21 8.51 2.42 17.6 4.25 23.6 1.82-5.47 3.04-15.2 4.25-23.6 3.65 3.65 7.3 7.9 12.7 10.9l-7.9-13.3c3.65 1.82 7.9 4.86 11.5 6.07-9.11-9.11-17-21.2-20.6-38.9z"/><path d="m82.4 81.7c-0.607-0.607-6.07 2.42-9.72-4.25 7.9 6.68 15.2-7.3 21.8 1.82 1.82 4.25-6.68 10.9-12.1 2.42z"/><path d="m117 81.7c0.607-1.21 6.07 2.42 9.11-4.86-7.3 7.3-15.2-7.3-21.2 2.42-1.82 4.25 6.68 10.9 12.1 2.42z"/><path d="m101 66.5c-1.02-0.607 3.58-4.25-3.07-8.51 5.63 7.9-10.2 10.9-1.54 17.6 3.58 2.42 12.2-2.42 4.6-9.11z"/></g><g transform="translate(0 50)"><path d="m100 81.1c-4.25 17.6-12.7 29.8-21.2 38.9 3.65-0.607 7.9-3.04 11.5-5.47-2.42 4.86-4.86 8.51-7.3 12.7 1.82-0.607 6.07-4.86 12.7-10.9 1.21 8.51 2.42 17.6 4.25 23.6 1.82-5.47 3.04-15.2 4.25-23.6 3.65 3.65 7.3 7.9 12.7 10.9l-7.9-13.3c3.65 1.82 7.9 4.86 11.5 6.07-9.11-9.11-17-21.2-20.6-38.9z"/><path d="m82.4 81.7c-0.607-0.607-6.07 2.42-9.72-4.25 7.9 6.68 15.2-7.3 21.8 1.82 1.82 4.25-6.68 10.9-12.1 2.42z"/><path d="m117 81.7c0.607-1.21 6.07 2.42 9.11-4.86-7.3 7.3-15.2-7.3-21.2 2.42-1.82 4.25 6.68 10.9 12.1 2.42z"/><path d="m101 66.5c-1.02-0.607 3.58-4.25-3.07-8.51 5.63 7.9-10.2 10.9-1.54 17.6 3.58 2.42 12.2-2.42 4.6-9.11z"/></g></g></pattern>`,chequy:(o,l,a,w)=>`<pattern id="${o}" width="${w*.25}" height="${w*.25}" viewBox="0 0 50 50" fill="${a}"><rect width="50" height="50"/><rect width="25" height="25" fill="${l}"/><rect x="25" y="25" width="25" height="25" fill="${l}"/></pattern>`,lozengy:(o,l,a,w)=>`<pattern id="${o}" width="${w*.125}" height="${w*.125}" viewBox="0 0 50 50"><rect width="50" height="50" fill="${l}"/><polygon points="25,0 50,25 25,50 0,25" fill="${a}"/></pattern>`,fusily:(o,l,a,w)=>`<pattern id="${o}" width="${w*.125}" height="${w*.25}" viewBox="0 0 50 100"><rect width="50" height="100" fill="${a}"/><polygon points="25,0 50,50 25,100 0,50" fill="${l}"/></pattern>`,pally:(o,l,a,w)=>`<pattern id="${o}" width="${w*.5}" height="${w*.125}" viewBox="0 0 100 25"><rect width="100" height="25" fill="${a}"/><rect x="25" y="0" width="25" height="25" fill="${l}"/><rect x="75" y="0" width="25" height="25" fill="${l}"/></pattern>`,barry:(o,l,a,w)=>`<pattern id="${o}" width="${w*.125}" height="${w*.5}" viewBox="0 0 25 100"><rect width="25" height="100" fill="${a}"/><rect x="0" y="25" width="25" height="25" fill="${l}"/><rect x="0" y="75" width="25" height="25" fill="${l}"/></pattern>`,gemelles:(o,l,a,w)=>`<pattern id="${o}" width="${w*.125}" height="${w*.125}" viewBox="0 0 50 50"><rect width="50" height="50" fill="${l}"/><rect y="5" width="50" height="10" fill="${a}"/><rect y="40" width="50" height="10" fill="${a}"/></pattern>`,bendy:(o,l,a,w)=>`<pattern id="${o}" width="${w*.5}" height="${w*.5}" viewBox="0 0 100 100"><rect width="100" height="100" fill="${l}"/><polygon points="0,25 75,100 25,100 0,75" fill="${a}"/><polygon points="25,0 75,0 100,25 100,75" fill="${a}"/></pattern>`,bendySinister:(o,l,a,w)=>`<pattern id="${o}" width="${w*.5}" height="${w*.5}" viewBox="0 0 100 100"><rect width="100" height="100" fill="${a}"/><polygon points="0,25 25,0 75,0 0,75" fill="${l}"/><polygon points="25,100 100,25 100,75 75,100" fill="${l}"/></pattern>`,palyBendy:(o,l,a,w)=>`<pattern id="${o}" width="${w*.6258}" height="${w*.3576}" viewBox="0 0 175 100"><rect y="0" x="0" width="175" height="100" fill="${a}"/><g fill="${l}"><path d="m0 20 35 30v50l-35-30z"/><path d="m35 0 35 30v50l-35-30z"/><path d="m70 0h23l12 10v50l-35-30z"/><path d="m70 80 23 20h-23z"/><path d="m105 60 35 30v10h-35z"/><path d="m105 0h35v40l-35-30z"/><path d="m 140,40 35,30 v 30 h -23 l -12,-10z"/><path d="M 175,0 V 20 L 152,0 Z"/></g></pattern>`,barryBendy:(o,l,a,w)=>`<pattern id="${o}" width="${w*.3572}" height="${w*.6251}" viewBox="0 0 100 175"><rect width="100" height="175" fill="${a}"/><g fill="${l}"><path d="m20 0 30 35h50l-30-35z"/><path d="m0 35 30 35h50l-30-35z"/><path d="m0 70v23l10 12h50l-30-35z"/><path d="m80 70 20 23v-23z"/><path d="m60 105 30 35h10v-35z"/><path d="m0 105v35h40l-30-35z"/><path d="m 40,140 30,35 h 30 v -23 l -10,-12 z"/><path d="m0 175h20l-20-23z"/></g></pattern>`,pappellony:(o,l,a,w)=>`<pattern id="${o}" width="${w*.125}" height="${w*.125}" viewBox="0 0 100 100"><rect width="100" height="100" fill="${l}"/><circle cx="0" cy="51" r="45" stroke="${a}" fill="${l}" stroke-width="10"/><circle cx="100" cy="51" r="45" stroke="${a}" fill="${l}" stroke-width="10"/><circle cx="50" cy="1" r="45" stroke="${a}" fill="${l}" stroke-width="10"/></pattern>`,pappellony2:(o,l,a,w)=>`<pattern id="${o}" width="${w*.125}" height="${w*.125}" viewBox="0 0 100 100" stroke="#000" stroke-width="2"><rect width="100" height="100" fill="${l}" stroke="none"/><circle cy="50" r="49" fill="${a}"/><circle cx="100" cy="50" r="49" fill="${a}"/><circle cx="50" cy="0" r="49" fill="${l}"/></pattern>`,scaly:(o,l,a,w)=>`<pattern id="${o}" width="${w*.125}" height="${w*.125}" viewBox="0 0 100 100" stroke="#000"><rect width="100" height="100" fill="${l}" stroke="none"/><path d="M 0,84 C -40,84 -50,49 -50,49 -50,79 -27,99 0,99 27,99 50,79 50,49 50,49 40,84 0,84 Z" fill="${a}"/><path d="M 100,84 C 60,84 50,49 50,49 c 0,30 23,50 50,50 27,0 50,-20 50,-50 0,0 -10,35 -50,35 z" fill="${a}"/><path d="M 50,35 C 10,35 0,0 0,0 0,30 23,50 50,50 77,50 100,30 100,0 100,0 90,35 50,35 Z" fill="${a}"/></pattern>`,plumetty:(o,l,a,w)=>`<pattern id="${o}" width="${w*.125}" height="${w*.25}" viewBox="0 0 50 100" stroke-width=".8"><rect width="50" height="100" fill="${a}" stroke="none"/><path fill="${l}" stroke="none" d="M 25,100 C 44,88 49.5,74 50,50 33.5,40 25,25 25,4e-7 25,25 16.5,40 0,50 0.5,74 6,88 25,100 Z"/><path fill="none" stroke="${a}" d="m17 40c5.363 2.692 10.7 2.641 16 0m-19 7c7.448 4.105 14.78 3.894 22 0m-27 7c6-2 10.75 3.003 16 3 5.412-0.0031 10-5 16-3m-35 9c4-7 12 3 19 2 7 1 15-9 19-2m-35 6c6-2 11 3 16 3s10-5 16-3m-30 7c8 0 8 3 14 3s7-3 14-3m-25 8c7.385 4.048 14.72 3.951 22 0m-19 8c5.455 2.766 10.78 2.566 16 0m-8 6v-78"/><g fill="none" stroke="${l}"><path d="m42 90c2.678 1.344 5.337 2.004 8 2m-11 5c3.686 2.032 7.344 3.006 10.97 3m0.0261-1.2e-4v-30"/><path d="m0 92c2.689 0.0045 5.328-0.6687 8-2m-8 10c3.709-0.0033 7.348-1.031 11-3m-11 3v-30"/><path d="m0 7c5.412-0.0031 10-5 16-3m-16 11c7 1 15-9 19-2m-19 9c5 0 10-5 16-3m-16 10c6 0 7-3 14-3m-14.02 11c3.685-0.002185 7.357-1.014 11.02-3m-11 10c2.694-0.01117 5.358-0.7036 7.996-2m-8 6v-48"/><path d="m34 4c6-2 10.75 3.003 16 3m-19 6c4-7 12 3 19 2m-16 4c6-2 11 3 16 3m-14 4c8 0 8 3 14 3m-11 5c3.641 1.996 7.383 2.985 11 3m-8 5c2.762 1.401 5.303 2.154 8.002 2.112m-0.00154 3.888v-48"/></g></pattern>`,masoned:(o,l,a,w)=>`<pattern id="${o}" width="${w*.125}" height="${w*.125}" viewBox="0 0 100 100" fill="none"><rect width="100" height="100" fill="${l}"/><rect width="100" height="50" stroke="${a}" stroke-width="4"/><line x1="50" y1="50" x2="50" y2="100" stroke="${a}" stroke-width="5"/></pattern>`,fretty:(o,l,a,w)=>`<pattern id="${o}" width="${w*.2}" height="${w*.2}" viewBox="0 0 140 140" stroke="#000" stroke-width="2"><rect width="140" height="140" fill="${l}" stroke="none"/><path d="m-15 5 150 150 20-20-150-150z" fill="${a}"/><path d="m10 150 140-140-20-20-140 140z" fill="${a}" stroke="none"/><path d="m0 120 20 20 120-120-20-20z" fill="none"/></pattern>`,grillage:(o,l,a,w)=>`<pattern id="${o}" width="${w*.25}" height="${w*.25}" viewBox="0 0 200 200" stroke="#000" stroke-width="2"><rect width="200" height="200" fill="${l}" stroke="none"/><path d="m205 65v-30h-210v30z" fill="${a}"/><path d="m65-5h-30v210h30z" fill="${a}"/><path d="m205 165v-30h-210v30z" fill="${a}"/><path d="m165,65h-30v140h30z" fill="${a}"/><path d="m 165,-5h-30v40h30z" fill="${a}"/></pattern>`,chainy:(o,l,a,w)=>`<pattern id="${o}" width="${w*.167}" height="${w*.167}" viewBox="0 0 200 200" stroke="#000" stroke-width="2"><rect x="-6.691e-6" width="200" height="200" fill="${l}" stroke="none"/><path d="m155-5-20-20-160 160 20 20z" fill="${a}"/><path d="m45 205 160-160 20 20-160 160z" fill="${a}"/><path d="m45-5 20-20 160 160-20 20-160-160" fill="${a}"/><path d="m-5 45-20 20 160 160 20-20-160-160" fill="${a}"/></pattern>`,maily:(o,l,a,w)=>`<pattern id="${o}" width="${w*.167}" height="${w*.167}" viewBox="0 0 200 200" stroke="#000" stroke-width="1.2"><path fill="${l}" stroke="none" d="M0 0h200v200H0z"/><g fill="${a}"><path d="m80-2c-5.27e-4 2.403-0.1094 6.806-0.3262 9.199 5.014-1.109 10.1-1.768 15.19-2.059 0.09325-1.712 0.1401-5.426 0.1406-7.141z"/><path d="m100 5a95 95 0 0 0-95 95 95 95 0 0 0 95 95 95 95 0 0 0 95-95 95 95 0 0 0-95-95zm0 15a80 80 0 0 1 80 80 80 80 0 0 1-80 80 80 80 0 0 1-80-80 80 80 0 0 1 80-80z"/><path d="m92.8 20.33c-5.562 0.4859-11.04 1.603-16.34 3.217-7.793 25.31-27.61 45.12-52.91 52.91-5.321 1.638-10.8 2.716-16.34 3.217-2.394 0.2168-6.796 0.3256-9.199 0.3262v15c1.714-4.79e-4 5.429-0.04737 7.141-0.1406 5.109-0.2761 10.19-0.9646 15.19-2.059 36.24-7.937 64.54-36.24 72.47-72.47z"/><path d="m202 80c-2.403-5.31e-4 -6.806-0.1094-9.199-0.3262 1.109 5.014 1.768 10.1 2.059 15.19 1.712 0.09326 5.426 0.1401 7.141 0.1406z"/><path d="m179.7 92.8c-0.4859-5.562-1.603-11.04-3.217-16.34-25.31-7.793-45.12-27.61-52.91-52.91-1.638-5.321-2.716-10.8-3.217-16.34-0.2168-2.394-0.3256-6.796-0.3262-9.199h-15c4.8e-4 1.714 0.0474 5.429 0.1406 7.141 0.2761 5.109 0.9646 10.19 2.059 15.19 7.937 36.24 36.24 64.54 72.47 72.47z"/><path d="m120 202c5.3e-4 -2.403 0.1094-6.806 0.3262-9.199-5.014 1.109-10.1 1.768-15.19 2.059-0.0933 1.712-0.1402 5.426-0.1406 7.141z"/><path d="m107.2 179.7c5.562-0.4859 11.04-1.603 16.34-3.217 7.793-25.31 27.61-45.12 52.91-52.91 5.321-1.638 10.8-2.716 16.34-3.217 2.394-0.2168 6.796-0.3256 9.199-0.3262v-15c-1.714 4.7e-4 -5.429 0.0474-7.141 0.1406-5.109 0.2761-10.19 0.9646-15.19 2.059-36.24 7.937-64.54 36.24-72.47 72.47z"/><path d="m -2,120 c 2.403,5.4e-4 6.806,0.1094 9.199,0.3262 -1.109,-5.014 -1.768,-10.1 -2.059,-15.19 -1.712,-0.0933 -5.426,-0.1402 -7.141,-0.1406 z"/><path d="m 20.33,107.2 c 0.4859,5.562 1.603,11.04 3.217,16.34 25.31,7.793 45.12,27.61 52.91,52.91 1.638,5.321 2.716,10.8 3.217,16.34 0.2168,2.394 0.3256,6.796 0.3262,9.199 L 95,202 c -4.8e-4,-1.714 -0.0472,-5.44 -0.1404,-7.152 -0.2761,-5.109 -0.9646,-10.19 -2.059,-15.19 -7.937,-36.24 -36.24,-64.54 -72.47,-72.47 z"/></g></pattern>`,honeycombed:(o,l,a,w)=>`<pattern id="${o}" width="${w*.143}" height="${w*.24514}" viewBox="0 0 70 120"><rect width="70" height="120" fill="${l}"/><path d="M 70,0 V 20 L 35,40 m 35,80 V 100 L 35,80 M 0,120 V 100 L 35,80 V 40 L 0,20 V 0" stroke="${a}" fill="none" stroke-width="3"/></pattern>`},m=async function(o,l){const{shield:a,division:w,ordinaries:S=[],charges:h=[]}=l,v=S.filter(Y=>!Y.above),E=S.filter(Y=>Y.above),P=r[a],T=w?w.t.includes("-")?w.t.split("-")[1]:w.t:null,R=t[a],L=n[a]||1,M=i[a]||"0 0 200 200",I=`<clipPath id="${a}_${o}"><path d="${P}"/></clipPath>`,H=w?`<clipPath id="divisionClip_${o}">${p(w.division,w.line)}</clipPath>`:"",G=await b(l,o,P),D=C(l,o),U=`<radialGradient id="backlight_${o}" cx="100%" cy="100%" r="150%"><stop stop-color="#fff" stop-opacity=".3" offset="0"/><stop stop-color="#fff" stop-opacity=".15" offset=".25"/><stop stop-color="#000" stop-opacity="0" offset="1"/></radialGradient>`,F=`<rect x="0" y="0" width="200" height="200" fill="${B(l.t1)}"/>`,j=w?q():"",Z=`<path d="${P}" fill="url(#backlight_${o})" stroke="#333"/>`,te=`<svg id="${o}" width="200" height="200" viewBox="${M}">
<defs>${I}${H}${G}${D}${U}</defs>
<g clip-path="url(#${a}_${o})">${F}${j}${X()}</g>
${Z}</svg>`;return document.getElementById("coas").insertAdjacentHTML("beforeend",te),!0;function q(){let Y="";for(const W of v)W.divided==="field"?Y+=ee(W,W.t):W.divided==="counter"&&(Y+=ee(W,T));for(const W of h)W.divided==="field"?Y+=le(W,W.t):W.divided==="counter"&&(Y+=le(W,T));for(const W of E)W.divided==="field"?Y+=ee(W,W.t):W.divided==="counter"&&(Y+=ee(W,T));Y+=`<g clip-path="url(#divisionClip_${o})"><rect x="0" y="0" width="200" height="200" fill="${B(w.t)}"/>`;for(const W of v)W.divided==="division"?Y+=ee(W,W.t):W.divided==="counter"&&(Y+=ee(W,l.t1));for(const W of h)W.divided==="division"?Y+=le(W,W.t):W.divided==="counter"&&(Y+=le(W,l.t1));for(const W of E)W.divided==="division"?Y+=ee(W,W.t):W.divided==="counter"&&(Y+=ee(W,l.t1));return Y+="</g>"}function X(){let Y="";return v.filter(W=>!W.divided).forEach(W=>{Y+=ee(W,W.t)}),h.filter(W=>!W.divided||!w).forEach(W=>{Y+=le(W,W.t)}),E.filter(W=>!W.divided).forEach(W=>{Y+=ee(W,W.t)}),Y}function ee(Y,W){const de=B(W);let me=`<g fill="${de}" stroke="none">`;return Y.ordinary==="bordure"?me+=`<path d="${P}" fill="none" stroke="${de}" stroke-width="16.7%"/>`:Y.ordinary==="orle"?me+=`<path d="${P}" fill="none" stroke="${de}" stroke-width="5%" transform="scale(.85)" transform-origin="center">`:me+=p(Y.ordinary,Y.line),me+"</g>"}function le(Y,W){const de=B(W),me=[...new Set(Y.p)].filter(ke=>R[ke]);let pe="";pe+=`<g fill="${de}" stroke="#000">`;for(const ke of me){const He=we(Y,ke);pe+=`<use href="#${Y.charge}_${o}" transform="${He}"></use>`}return pe+"</g>";function we(ke,He){const Be=(ke.size||1)*L,Fe=ke.sinister?-Be:Be,_=ke.reversed?-Be:Be;let[oe,ce]=R[He];oe=oe-100*(Fe-1),ce=ce-100*(_-1);const ye=ke.sinister||ke.reversed?`${Fe} ${_}`:Be;return`translate(${oe} ${ce}) scale(${ye})`}}};async function b(o,l,a){var v;let w=o.charges?o.charges.map(E=>E.charge):[];k(o.t1)&&w.push(k(o.t1)),k((v=o.division)==null?void 0:v.t)&&w.push(k(o.division.t));const S=[...new Set(w)];return(await Promise.all(S.map(async E=>E==="inescutcheon"?`<g id="inescutcheon_${l}"><path transform="translate(66 66) scale(.34)" d="${a}"/></g>`:await u(E,l)))).join("")}const A=location.hostname?"./charges/":"http://armoria.herokuapp.com/charges/";async function u(o,l){return fetch(A+o+".svg").then(w=>{if(w.ok)return w.text();throw new Error("Cannot fetch charge")}).then(w=>{const S=document.createElement("html");S.innerHTML=w;const h=S.querySelector("g");return h.setAttribute("id",o+"_"+l),h.outerHTML}).catch(w=>{ERROR&&console.error(w)})}function C(o,l){const a=S=>S.includes("-");let w=[];return o.t1.includes("-")&&w.push(o.t1),o.division&&a(o.division.t)&&w.push(o.division.t),o.ordinaries&&o.ordinaries.filter(S=>a(S.t)).forEach(S=>w.push(S.t)),o.charges&&o.charges.filter(S=>a(S.t)).forEach(S=>w.push(S.t)),w.length?[...new Set(w)].map(S=>{const[h,v,E,P]=S.split("-"),T=k(S);return T?z.semy(S,B(v),B(E),g(P),T+"_"+l):z[h](S,B(v),B(E),g(P),T)}).join(""):""}function g(o){return o==="small"?.8:o==="smaller"?.5:o==="smallest"?.25:o==="big"?1.6:1}function p(o,l){const a=o+"Lined";if(!l||l==="straight"||!f[a])return f[o];const w=c[l];return f[a](w)}function B(o){return e[o]?e[o]:`url(#${o})`}function k(o){return/^semy/.test(o)?o.match(/semy_of_(.*?)-/)[1]:!1}const d=async function(o,l){if(l==="custom"){console.warn("Cannot render custom emblem",l);return}if(!l){console.warn(`Emblem ${o} is undefined`);return}if(!document.getElementById(o))return m(o,l)};return{trigger:d,add:function(o,l,a,w,S){const h=o+"COA"+l,v=document.getElementById(o+"Emblems");if(emblems.selectAll("use").size()){const E=+v.getAttribute("font-size")||50,P=`<use data-i="${l}" x="${w-E/2}" y="${S-E/2}" width="1em" height="1em" href="#${h}"/>`;v.insertAdjacentHTML("beforeend",P)}layerIsOn("toggleEmblems")&&d(h,a)},shieldPaths:r}}();const tn=window.indexedDB||window.mozIndexedDB||window.webkitIndexedDB||window.msIndexedDB;tn||console.error("indexedDB not supported");const Mt=tn.open("d2",1);Mt.onsuccess=function(){this.result};Mt.onerror=function(e){console.error("indexedDB request error",e)};Mt.onupgradeneeded=function(e){const t=Mt.result.createObjectStore("s",{keyPath:"k"});t.transaction.oncomplete=function(n){n.target.db}};const Vt=function(){if(localStorage.getItem("noReminder"))return;const e=["Please don't forget to save your work as a .map file","Please remember to save work as a .map file","Saving in .map format will ensure your data won't be lost in case of issues","Safety is number one priority. Please save the map","Don't forget to save your map on a regular basis!","Just a gentle reminder for you to save the map","Please don't forget to save your progress (saving as .map is the best option)","Don't want to be reminded about need to save? Press CTRL+Q"],t=15*60*1e3;Vt.reminder=setInterval(()=>{customization||se(ie(e),!0,"warn",2500)},t),Vt.status=1};Vt();window.Cloud=function(){const e=c=>`auth-${c}`,t=(c,f)=>localStorage.setItem(e(c),f),n=c=>localStorage.getItem(e(c));return{providers:{dropbox:{name:"dropbox",clientId:"pdr9ae64ip0qno4",authWindow:void 0,token:null,api:null,async call(c,f){try{return this.api||await this.initialize(),await this.api[c](f)}catch(z){if(z.name!=="DropboxResponseError")throw z;return await this.auth(),await this.api[c](f)}},initialize(){const c=n(this.name);return c?this.connect(c):this.auth()},async connect(c){await St(()=>import("./dropbox-sdk.min.f49dfee9.js"),[]);const f=new Dropbox.DropboxAuth({clientId:this.clientId});f.setAccessToken(c),this.api=new Dropbox.Dropbox({auth:f})},async save(c,f){const z=await this.call("filesUpload",{path:"/"+c,contents:f});return DEBUG&&console.log("Dropbox response:",z),!0},async load(c){const z=(await this.call("filesDownload",{path:c})).result.fileBlob;if(!z)throw new Error("Invalid response from dropbox.");return z},async list(){return(await this.call("filesListFolder",{path:""})).result.entries.map(({name:z,client_modified:m,size:b,path_lower:A})=>({name:z,updated:m,size:b,path:A})).filter(({size:z})=>z).reverse()},auth(){const z=window.innerWidth/2-320,m=window.innerHeight/2-480/2.5;return this.authWindow=window.open("./dropbox.html","auth",`width=640, height=${480}, top=${m}, left=${z}}`),new Promise((b,A)=>{const u=setTimeout(()=>{this.authWindow.close(),A(new Error("Timeout. No auth for Dropbox"))},12e4);window.addEventListener("dropboxauth",C=>{clearTimeout(u),b()})})},async setDropBoxToken(c){DEBUG&&console.log("Access token:",c),t(this.name,c),await this.connect(c),this.authWindow.close(),window.dispatchEvent(new Event("dropboxauth"))},returnError(c){console.error(c),se(c.replaceAll("+"," "),!0,"error",4e3),this.authWindow.close()},async getLink(c){if((await this.call("sharingListSharedLinks",{path:c})).result.links.length)return m.result.links[0].url;const z={require_password:!1,audience:"public",access:"viewer",requested_visibility:"public",allow_download:!0},m=await this.call("sharingCreateSharedLinkWithSettings",{path:c,settings:z});return DEBUG&&console.log("Dropbox link object:",m.result),m.result.url}}}}}();window.Formats=function(){async function e(t,n=","){const r=(await t.text()).split(`
`),c=r.shift().split(n).map(z=>z.toLowerCase()),f=r.filter(z=>z.trim()!=="").map(z=>z.split(n));return{headers:c,data:f,iterator:function*(z){const m=z?this.data.sort(z):this.data;for(const b of m)yield Object.fromEntries(b.map((A,u)=>[this.headers[u],A]))}}}return{csvParser:e}}();export{Jt as a,ne as b,ba as c,Xs as d,Qt as e,Xt as f,yn as g,Ys as i,O as r,fn as s,se as t};