!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):(t="undefined"!=typeof globalThis?globalThis:t||self).Loca=e()}(this,(function(){"use strict";var e="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function r(t,e){return t(e={exports:{}},e.exports),e.exports}var n,i=r((function(r,n){!function(r){
/*! *****************************************************************************
	    Copyright (c) Microsoft Corporation.

	    Permission to use, copy, modify, and/or distribute this software for any
	    purpose with or without fee is hereby granted.

	    THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
	    REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
	    AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
	    INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
	    LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
	    OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
	    PERFORMANCE OF THIS SOFTWARE.
	    ***************************************************************************** */
var n=function(t,e){return(n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var r in e)e.hasOwnProperty(r)&&(t[r]=e[r])})(t,e)};function i(t,e){function r(){this.constructor=t}n(t,e),t.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)}var o=function(){return(o=Object.assign||function(t){for(var e,r=1,n=arguments.length;r<n;r++)for(var i in e=arguments[r])Object.prototype.hasOwnProperty.call(e,i)&&(t[i]=e[i]);return t}).apply(this,arguments)};function a(){for(var t=0,e=0,r=arguments.length;e<r;e++)t+=arguments[e].length;var n=Array(t),i=0;for(e=0;e<r;e++)for(var o=arguments[e],a=0,s=o.length;a<s;a++,i++)n[i]=o[a];return n}var s="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:void 0!==e?e:"undefined"!=typeof self?self:{};function l(t,e){return t(e={exports:{}},e.exports),e.exports}var u,c=l((function(e,r){Object.defineProperty(r,"__esModule",{value:!0});
/*! *****************************************************************************
	    Copyright (c) Microsoft Corporation.

	    Permission to use, copy, modify, and/or distribute this software for any
	    purpose with or without fee is hereby granted.

	    THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
	    REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
	    AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
	    INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
	    LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
	    OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
	    PERFORMANCE OF THIS SOFTWARE.
	    ***************************************************************************** */
var n=function(t,e){return(n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r])})(t,e)};function i(t,e){function r(){this.constructor=t}n(t,e),t.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)}var o=function(){return(o=Object.assign||function(t){for(var e,r=1,n=arguments.length;r<n;r++)for(var i in e=arguments[r])Object.prototype.hasOwnProperty.call(e,i)&&(t[i]=e[i]);return t}).apply(this,arguments)},a={aliceblue:"#f0f8ff",antiquewhite:"#faebd7",aqua:"#00ffff",aquamarine:"#7fffd4",azure:"#f0ffff",beige:"#f5f5dc",bisque:"#ffe4c4",black:"#000000",blanchedalmond:"#ffebcd",blue:"#0000ff",blueviolet:"#8a2be2",brown:"#a52a2a",burlywood:"#deb887",cadetblue:"#5f9ea0",chartreuse:"#7fff00",chocolate:"#d2691e",coral:"#ff7f50",cornflowerblue:"#6495ed",cornsilk:"#fff8dc",crimson:"#dc143c",cyan:"#00ffff",darkblue:"#00008b",darkcyan:"#008b8b",darkgoldenrod:"#b8860b",darkgray:"#a9a9a9",darkgreen:"#006400",darkkhaki:"#bdb76b",darkmagenta:"#8b008b",darkolivegreen:"#556b2f",darkorange:"#ff8c00",darkorchid:"#9932cc",darkred:"#8b0000",darksalmon:"#e9967a",darkseagreen:"#8fbc8f",darkslateblue:"#483d8b",darkslategray:"#2f4f4f",darkturquoise:"#00ced1",darkviolet:"#9400d3",deeppink:"#ff1493",deepskyblue:"#00bfff",dimgray:"#696969",dodgerblue:"#1e90ff",firebrick:"#b22222",floralwhite:"#fffaf0",forestgreen:"#228b22",fuchsia:"#ff00ff",gainsboro:"#dcdcdc",ghostwhite:"#f8f8ff",gold:"#ffd700",goldenrod:"#daa520",grey:"#808080",gray:"#808080",green:"#008000",greenyellow:"#adff2f",honeydew:"#f0fff0",hotpink:"#ff69b4",indianred:"#cd5c5c",indigo:"#4b0082",ivory:"#fffff0",khaki:"#f0e68c",lavender:"#e6e6fa",lavenderblush:"#fff0f5",lawngreen:"#7cfc00",lemonchiffon:"#fffacd",lightblue:"#add8e6",lightcoral:"#f08080",lightcyan:"#e0ffff",lightgoldenrodyellow:"#fafad2",lightgrey:"#d3d3d3",lightgreen:"#90ee90",lightpink:"#ffb6c1",lightsalmon:"#ffa07a",lightseagreen:"#20b2aa",lightskyblue:"#87cefa",lightslategray:"#778899",lightsteelblue:"#b0c4de",lightyellow:"#ffffe0",lime:"#00ff00",limegreen:"#32cd32",linen:"#faf0e6",magenta:"#ff00ff",maroon:"#800000",mediumaquamarine:"#66cdaa",mediumblue:"#0000cd",mediumorchid:"#ba55d3",mediumpurple:"#9370d8",mediumseagreen:"#3cb371",mediumslateblue:"#7b68ee",mediumspringgreen:"#00fa9a",mediumturquoise:"#48d1cc",mediumvioletred:"#c71585",midnightblue:"#191970",mintcream:"#f5fffa",mistyrose:"#ffe4e1",moccasin:"#ffe4b5",navajowhite:"#ffdead",navy:"#000080",oldlace:"#fdf5e6",olive:"#808000",olivedrab:"#6b8e23",orange:"#ffa500",orangered:"#ff4500",orchid:"#da70d6",palegoldenrod:"#eee8aa",palegreen:"#98fb98",paleturquoise:"#afeeee",palevioletred:"#d87093",papayawhip:"#ffefd5",peachpuff:"#ffdab9",peru:"#cd853f",pink:"#ffc0cb",plum:"#dda0dd",powderblue:"#b0e0e6",purple:"#800080",rebeccapurple:"#663399",red:"#ff0000",rosybrown:"#bc8f8f",royalblue:"#4169e1",saddlebrown:"#8b4513",salmon:"#fa8072",sandybrown:"#f4a460",seagreen:"#2e8b57",seashell:"#fff5ee",sienna:"#a0522d",silver:"#c0c0c0",skyblue:"#87ceeb",slateblue:"#6a5acd",slategray:"#708090",snow:"#fffafa",springgreen:"#00ff7f",steelblue:"#4682b4",tan:"#d2b48c",teal:"#008080",thistle:"#d8bfd8",tomato:"#ff6347",turquoise:"#40e0d0",violet:"#ee82ee",wheat:"#f5deb3",white:"#ffffff",whitesmoke:"#f5f5f5",yellow:"#ffff00",yellowgreen:"#9acd32"},l={argbToArray:function(t,e){if(void 0===e&&(e=!1),!t)return t;for(var r=[],n=0,i=t.length;n<i;n+=2){var o=parseInt(t.substr(n,2),16);e&&(o=parseInt(o/255+"")),r.push(o)}return r.push(r.shift()),r},rgbaStrToArray:function(t){var e=t.split(",");return e[0]=parseFloat(e[0].slice(5))/255,e[1]=parseFloat(e[1])/255,e[2]=parseFloat(e[2])/255,e[3]=parseFloat(e[3]),e},rgbStrToArray:function(t){var e=t.split(",");return e[0]=parseFloat(e[0].slice(4))/255,e[1]=parseFloat(e[1])/255,e[2]=parseFloat(e[2])/255,e[3]=1,e},argbHex2Rgba:function(t){for(var e=[],r=1,n=t.length;r<n;r+=2)e.push(parseInt(t.substr(r,2),16));return e.push((e.shift()/255).toFixed(2)),"rgba("+e.join(",")+")"},rgbaHex2Array:function(t){for(var e=[],r=1,n=t.length;r<n;r+=2)e.push(parseInt(t.substr(r,2),16)/255);return e},rgbHex2Array:function(t){for(var e=[],r=1,n=t.length;r<n;r+=2)e.push(parseInt(t.substr(r,2),16)/255);return e[3]=1,e},sortRgbHex2Array:function(t){for(var e=[],r=1,n=t.length;r<n;r+=1){var i=t.substr(r,1);e.push(parseInt(i+i,16)/255)}return e[3]=1,e},colorNameToHex:function(t){return void 0===t&&(t=""),t=t.toLowerCase(),a[t]},colorToArray:function(t){if(t instanceof Array)return[t[0]/255,t[1]/255,t[2]/255,t[3]||1];if(/^rgba\(/.test(t))return this.rgbaStrToArray(t);if(/^rgb\(/.test(t))return this.rgbStrToArray(t);if("#"===t[0]&&"string"==typeof t){var e=t.length;if(4===e)return this.sortRgbHex2Array(t);if(7===e)return this.rgbHex2Array(t);if(9===e)return this.rgbaHex2Array(t)}else if("string"==typeof t){var r=this.colorNameToHex(t);return this.rgbHex2Array(r)}return t}},u={mousePos:function(t,e){if(e.target){var r=t.getBoundingClientRect(),n=[t.clientLeft,t.clientTop],i=e;return e instanceof TouchEvent&&e.touches&&e.changedTouches&&(i=e.touches.length>0?e.touches[0]:e.changedTouches[e.changedTouches.length-1]),[i.clientX-r.left-n[0],i.clientY-r.left-n[1]]}return[0,0]}},c={angleToRad:function(t){return t/180*Math.PI},radToAngle:function(t){return 180*t/Math.PI}},f={getGuid:function(t,e){return void 0===t&&(t=""),void 0===e&&(e=10),t+Math.round(Math.random()*Math.pow(10,e))+"_"+(new Date).getTime()},pushArray:function(t,e){var r=t.length,n=e.length;t.length=r+n;for(var i=0;i<n;i++)t[r+i]=e[i];return t},JSONP:function(t,e,r){void 0===r&&(r={}),t=encodeURI(t);var n=f.getGuid("jsonp_",6)+"_",i=document.createElement("script");i.type="text/javascript",i.async=!0,r=Object.assign({},{callback:"callback",type:"json",charset:"utf-8"},r);var o=function(){window[n]=null,i.onerror=null,i.parentNode&&i.parentNode.removeChild(i)};i.onerror=function(){o(),e&&e("error",{url:t,info:"Request Error"})},window[n]=function(r){o(),e&&e("complete",{info:"ok",url:t,data:r})};var a="?";-1!==t.indexOf("?")&&(a="&");var s=t+a+r.callback+"="+n;i.src=s,(document.getElementsByTagName("body")[0]||document.getElementsByTagName("head")[0]).appendChild(i)},grid:{bin:function(t,e){void 0===e&&(e=100);for(var r={},n=[],i=2*e,o=-1,a=t.length;++o<a;){var s=t[o].coordinaties,l=Math.floor(s[0]/i),u=Math.floor(s[1]/i),c=l+"-"+u,f=r[c];f?f.coordinates.push(t[o]):(r[c]=f={rowCol:[l,u],center:[l*i+e,u*i+e],coordinates:[t[o]]},n.push(f))}return n},buildGeometry:function(t,e){var r=[],n=e.gap,i=e.radius,o=n/2,a=t.center,s=a[0],l=a[1],u=[s-i+o,l+i-o],c=[s-i+o,l-i+o],f=[s+i-o,l-i+o],h=[s+i-o,l+i-o];return r.push.apply(r,[u,c,f,h,u]),r}},hexagon:{thirdPi:Math.PI/3,angles:[0,Math.PI/3,2*Math.PI/3,Math.PI/3,Math.PI/3,5*Math.PI/3],bin:function(t,e){void 0===e&&(e=100);for(var r={},n=[],i=2*e*Math.sin(this.thirdPi),o=1.5*e,a=0,s=t.length;a<s;++a){var l=t[a].coordinaties,u=l[0],c=l[1];c/=o;var f=Math.round(c);u=u/i-(1&f)/2;var h=Math.round(u),d=c-f;if(3*Math.abs(d)>1){var p=u-h,m=h+(u<h?-1:1)/2,v=f+(c<f?-1:1),g=u-m,y=c-v;p*p+d*d>g*g+y*y&&(h=m+(1&f?1:-1)/2,f=v)}var b=h+"-"+f,x=r[b];x?x.coordinates.push(t[a]):(r[b]=x={rowCol:[h,f],center:[(h+(1&f)/2)*i,f*o],coordinates:[t[a]]},n.push(x))}return n},buildGeometry:function(t,e){var r=[],n=e.gap,i=e.radius,o=n/2,a=i/2,s=Math.sqrt(3)*i,l=Math.sqrt(Math.pow(s,2)+Math.pow(i,2)),u=t.center,c=u[0],f=u[1],h=[c,f+l/2-o],d=[c-s/2+o,f+a-o/2],p=[c-s/2+o,f-a+o/2],m=[c,f-l/2+o],v=[c+s/2-o,f-a+o/2],g=[c+s/2-o,f+a-o/2];return r.push.apply(r,[h,d,p,m,v,g,h]),r}},multiToSingle:function(t){var e=[];if("MultiPoint"===t.type)for(var r=t.properties,n=(a=t.coordinates).length,i=0;i<n;++i){var o=a[i];e.push({properties:r,type:"Point",coordinates:o})}else if("MultiLineString"===t.type)for(r=t.properties,n=(a=t.coordinates).length,i=0;i<n;++i)o=a[i],e.push({properties:r,type:"Point",coordinates:o});else if("MultiPolygon"===t.type){var a;for(r=t.properties,n=(a=t.coordinates).length,i=0;i<n;++i)o=a[i],e.push({properties:r,type:"Point",coordinates:o})}return e}},h={ColorUtil:l,DomUtil:u,MathUtil:c,CommonUtil:f},d=h.ColorUtil,p=function(){function t(){}return t.getInstance=function(){return this.instance},t.prototype.parse=function(t,e,r){for(var n={},i={},o={},a=0,s=t.length;a<s;a++){var l=t[a],u=function(t){var i=r[t],o=void 0===e[t]?i.defaultValue:e[t];i.render,o instanceof Function&&(o=o(a,l));var s=o;"attribute"===i.render&&("colors"===i.type?(s=[],o.map((function(t){s.push(d.colorToArray(t))}))):"color"===i.type&&(s=d.colorToArray(o)),n[t]?n[t].push(s):n[t]=[s])};for(var c in r)u(c)}var f=function(t){var n=r[t],a=void 0===e[t]?n.defaultValue:e[t],s=a;"uniform"===n.render?("colors"===n.type?(s=[],a.map((function(t){s.push(d.colorToArray(t))}))):"color"===n.type&&(s=d.colorToArray(a)),i[t]=s):"config"===n.render&&("color"===n.type&&(s=d.colorToArray(a)),o[t]=s)};for(var c in r)f(c);return{attributes:n,uniforms:i,configs:o}},t.instance=new t,t}(),m=p.getInstance(),v=function(){function t(){this.events={}}return t.prototype.on=function(t,e,r,n){void 0===r&&(r=this),void 0===n&&(n=!1);for(var i=0,o=Array.isArray(t)?t:[t];i<o.length;i++){var a=o[i];this._on(a,e,r,n)}return this},t.prototype.off=function(t,e,r){void 0===r&&(r=this);var n=this.events;if(t in n)for(var i=0;i<n[t].length;i+=1)if(n[t][i].fn===e&&n[t][i].context===r)return n[t].splice(i,1),this;return this},t.prototype.hasEvents=function(t,e,r){void 0===r&&(r=this);var n=this.events;if(t&&e&&t in n)for(var i=0;i<n[t].length;i+=1)if(n[t][i].fn===e&&n[t][i].context===r)return!0;return!1},t.prototype.clearEvents=function(t){return t?this.events[t]&&delete this.events[t]:this.events={},this},t.prototype.emit=function(t,e){if(void 0===e&&(e={}),!(t in this.events))return this;for(var r=o(o({},e),{type:t}),n=this.events[t],i=0,a=n.length;i<a;i+=1){var s=n[i];s.fn&&(s.fn.call(s.context,r),s.once&&(this.events[t].splice(i,1),i-=1,a-=1))}return this},t.prototype.getEvents=function(){return this.events},t.prototype._on=function(t,e,r,n){if(void 0===r&&(r=this),void 0===n&&(n=!1),this.hasEvents(t,e,r))return this;var i=this.events;return i[t]=i[t]||[],i[t].push({fn:e,context:r||this,once:n}),this},t}(),g="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:void 0!==s?s:"undefined"!=typeof self?self:{};function y(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}function b(t,e){return t(e={exports:{}},e.exports),e.exports}var x=new(b((function(t,e){
/*!@license
	     * UAParser.js v0.7.27
	     * Lightweight JavaScript-based User-Agent string parser
	     * https://github.com/faisalman/ua-parser-js
	     *
	     * Copyright © 2012-2021 Faisal Salman <f@faisalman.com>
	     * Licensed under MIT License
	     */
!function(r,n){var i="function",o="object",a="string",s="model",l="name",u="type",c="vendor",f="version",h="architecture",d="console",p="mobile",m="tablet",v="smarttv",g="wearable",y={extend:function(t,e){var r={};for(var n in t)e[n]&&e[n].length%2==0?r[n]=e[n].concat(t[n]):r[n]=t[n];return r},has:function(t,e){return typeof t===a&&-1!==e.toLowerCase().indexOf(t.toLowerCase())},lowerize:function(t){return t.toLowerCase()},major:function(t){return typeof t===a?t.replace(/[^\d\.]/g,"").split(".")[0]:n},trim:function(t,e){return t=t.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,""),void 0===e?t:t.substring(0,255)}},b={rgx:function(t,e){for(var r,a,s,l,u,c,f=0;f<e.length&&!u;){var h=e[f],d=e[f+1];for(r=a=0;r<h.length&&!u;)if(u=h[r++].exec(t))for(s=0;s<d.length;s++)c=u[++a],typeof(l=d[s])===o&&l.length>0?2==l.length?typeof l[1]==i?this[l[0]]=l[1].call(this,c):this[l[0]]=l[1]:3==l.length?typeof l[1]!==i||l[1].exec&&l[1].test?this[l[0]]=c?c.replace(l[1],l[2]):n:this[l[0]]=c?l[1].call(this,c,l[2]):n:4==l.length&&(this[l[0]]=c?l[3].call(this,c.replace(l[1],l[2])):n):this[l]=c||n;f+=2}},str:function(t,e){for(var r in e)if(typeof e[r]===o&&e[r].length>0){for(var i=0;i<e[r].length;i++)if(y.has(e[r][i],t))return"?"===r?n:r}else if(y.has(e[r],t))return"?"===r?n:r;return t}},x={browser:{oldSafari:{version:{"1.0":"/8",1.2:"/1",1.3:"/3","2.0":"/412","2.0.2":"/416","2.0.3":"/417","2.0.4":"/419","?":"/"}},oldEdge:{version:{.1:"12.",21:"13.",31:"14.",39:"15.",41:"16.",42:"17.",44:"18."}}},os:{windows:{version:{ME:"4.90","NT 3.11":"NT3.51","NT 4.0":"NT4.0",2e3:"NT 5.0",XP:["NT 5.1","NT 5.2"],Vista:"NT 6.0",7:"NT 6.1",8:"NT 6.2",8.1:"NT 6.3",10:["NT 6.4","NT 10.0"],RT:"ARM"}}}},_={browser:[[/\b(?:crmo|crios)\/([\w\.]+)/i],[f,[l,"Chrome"]],[/(?:edgios|edga|edg)\/([\w\.]+)/i],[f,[l,"Edge"]],[/edge\/([\w\.]+)/i],[[f,b.str,x.browser.oldEdge.version],[l,"Edge"]],[/(opera\smini)\/([\w\.-]+)/i,/(opera\s[mobiletab]{3,6})\b.+version\/([\w\.-]+)/i,/(opera)(?:.+version\/|[\/\s]+)([\w\.]+)/i],[l,f],[/opios[\/\s]+([\w\.]+)/i],[f,[l,"Opera Mini"]],[/\sopr\/([\w\.]+)/i],[f,[l,"Opera"]],[/(kindle)\/([\w\.]+)/i,/(lunascape|maxthon|netfront|jasmine|blazer|instagram)[\/\s]?([\w\.]*)/i,/(avant\s|iemobile|slim)(?:browser)?[\/\s]?([\w\.]*)/i,/(ba?idubrowser)[\/\s]?([\w\.]+)/i,/(?:ms|\()(ie)\s([\w\.]+)/i,/(chromium|flock|rockmelt|midori|epiphany|silk|skyfire|ovibrowser|bolt|iron|vivaldi|iridium|phantomjs|bowser|quark|qupzilla|falkon)\/([\w\.-]+)/i,/(rekonq|puffin|brave|whale|qqbrowserlite|qq)\/([\w\.]+)/i,/(weibo)__([\d\.]+)/i],[l,f],[/(?:[\s\/]uc?\s?browser|(?:juc.+)ucweb)[\/\s]?([\w\.]+)/i],[f,[l,"UCBrowser"]],[/(?:windowswechat)?\sqbcore\/([\w\.]+)\b.*(?:windowswechat)?/i],[f,[l,"WeChat(Win) Desktop"]],[/micromessenger\/([\w\.]+)/i],[f,[l,"WeChat"]],[/konqueror\/([\w\.]+)/i],[f,[l,"Konqueror"]],[/trident.+rv[:\s]([\w\.]{1,9})\b.+like\sgecko/i],[f,[l,"IE"]],[/yabrowser\/([\w\.]+)/i],[f,[l,"Yandex"]],[/(avast|avg)\/([\w\.]+)/i],[[l,/(.+)/,"$1 Secure Browser"],f],[/focus\/([\w\.]+)/i],[f,[l,"Firefox Focus"]],[/opt\/([\w\.]+)/i],[f,[l,"Opera Touch"]],[/coc_coc_browser\/([\w\.]+)/i],[f,[l,"Coc Coc"]],[/dolfin\/([\w\.]+)/i],[f,[l,"Dolphin"]],[/coast\/([\w\.]+)/i],[f,[l,"Opera Coast"]],[/xiaomi\/miuibrowser\/([\w\.]+)/i],[f,[l,"MIUI Browser"]],[/fxios\/([\w\.-]+)/i],[f,[l,"Firefox"]],[/(qihu|qhbrowser|qihoobrowser|360browser)/i],[[l,"360 Browser"]],[/(oculus|samsung|sailfish)browser\/([\w\.]+)/i],[[l,/(.+)/,"$1 Browser"],f],[/(comodo_dragon)\/([\w\.]+)/i],[[l,/_/g," "],f],[/m?(qqbrowser|baiduboxapp|2345Explorer)[\/\s]?([\w\.]+)/i],[l,f],[/(MetaSr)[\/\s]?([\w\.]+)/i,/(LBBROWSER)/i],[l],[/;fbav\/([\w\.]+);/i],[f,[l,"Facebook"]],[/FBAN\/FBIOS|FB_IAB\/FB4A/i],[[l,"Facebook"]],[/\s(electron)\/([\w\.]+)\ssafari/i,/safari\s(line)\/([\w\.]+)/i,/\b(line)\/([\w\.]+)\/iab/i],[l,f],[/\bgsa\/([\w\.]+)\s.*safari\//i],[f,[l,"GSA"]],[/headlesschrome(?:\/([\w\.]+)|\s)/i],[f,[l,"Chrome Headless"]],[/\swv\).+(chrome)\/([\w\.]+)/i],[[l,"Chrome WebView"],f],[/droid.+\sversion\/([\w\.]+)\b.+(?:mobile\ssafari|safari)/i],[f,[l,"Android Browser"]],[/(chrome|omniweb|arora|[tizenoka]{5}\s?browser)\/v?([\w\.]+)/i],[l,f],[/version\/([\w\.]+)\s.*mobile\/\w+\s(safari)/i],[f,[l,"Mobile Safari"]],[/version\/([\w\.]+)\s.*(mobile\s?safari|safari)/i],[f,l],[/webkit.+?(mobile\s?safari|safari)(\/[\w\.]+)/i],[l,[f,b.str,x.browser.oldSafari.version]],[/(webkit|khtml)\/([\w\.]+)/i],[l,f],[/(navigator|netscape)\/([\w\.-]+)/i],[[l,"Netscape"],f],[/ile\svr;\srv:([\w\.]+)\).+firefox/i],[f,[l,"Firefox Reality"]],[/ekiohf.+(flow)\/([\w\.]+)/i,/(swiftfox)/i,/(icedragon|iceweasel|camino|chimera|fennec|maemo\sbrowser|minimo|conkeror)[\/\s]?([\w\.\+]+)/i,/(firefox|seamonkey|k-meleon|icecat|iceape|firebird|phoenix|palemoon|basilisk|waterfox)\/([\w\.-]+)$/i,/(firefox)\/([\w\.]+)\s[\w\s\-]+\/[\w\.]+$/i,/(mozilla)\/([\w\.]+)\s.+rv\:.+gecko\/\d+/i,/(polaris|lynx|dillo|icab|doris|amaya|w3m|netsurf|sleipnir)[\/\s]?([\w\.]+)/i,/(links)\s\(([\w\.]+)/i,/(gobrowser)\/?([\w\.]*)/i,/(ice\s?browser)\/v?([\w\._]+)/i,/(mosaic)[\/\s]([\w\.]+)/i],[l,f]],cpu:[[/(?:(amd|x(?:(?:86|64)[_-])?|wow|win)64)[;\)]/i],[[h,"amd64"]],[/(ia32(?=;))/i],[[h,y.lowerize]],[/((?:i[346]|x)86)[;\)]/i],[[h,"ia32"]],[/\b(aarch64|armv?8e?l?)\b/i],[[h,"arm64"]],[/\b(arm(?:v[67])?ht?n?[fl]p?)\b/i],[[h,"armhf"]],[/windows\s(ce|mobile);\sppc;/i],[[h,"arm"]],[/((?:ppc|powerpc)(?:64)?)(?:\smac|;|\))/i],[[h,/ower/,"",y.lowerize]],[/(sun4\w)[;\)]/i],[[h,"sparc"]],[/((?:avr32|ia64(?=;))|68k(?=\))|\barm(?:64|(?=v(?:[1-7]|[5-7]1)l?|;|eabi))|(?=atmel\s)avr|(?:irix|mips|sparc)(?:64)?\b|pa-risc)/i],[[h,y.lowerize]]],device:[[/\b(sch-i[89]0\d|shw-m380s|sm-[pt]\w{2,4}|gt-[pn]\d{2,4}|sgh-t8[56]9|nexus\s10)/i],[s,[c,"Samsung"],[u,m]],[/\b((?:s[cgp]h|gt|sm)-\w+|galaxy\snexus)/i,/\ssamsung[\s-]([\w-]+)/i,/sec-(sgh\w+)/i],[s,[c,"Samsung"],[u,p]],[/\((ip(?:hone|od)[\s\w]*);/i],[s,[c,"Apple"],[u,p]],[/\((ipad);[\w\s\),;-]+apple/i,/applecoremedia\/[\w\.]+\s\((ipad)/i,/\b(ipad)\d\d?,\d\d?[;\]].+ios/i],[s,[c,"Apple"],[u,m]],[/\b((?:agr|ags[23]|bah2?|sht?)-a?[lw]\d{2})/i],[s,[c,"Huawei"],[u,m]],[/d\/huawei([\w\s-]+)[;\)]/i,/\b(nexus\s6p|vog-[at]?l\d\d|ane-[at]?l[x\d]\d|eml-a?l\d\da?|lya-[at]?l\d[\dc]|clt-a?l\d\di?|ele-l\d\d)/i,/\b(\w{2,4}-[atu][ln][01259][019])[;\)\s]/i],[s,[c,"Huawei"],[u,p]],[/\b(poco[\s\w]+)(?:\sbuild|\))/i,/\b;\s(\w+)\sbuild\/hm\1/i,/\b(hm[\s\-_]?note?[\s_]?(?:\d\w)?)\sbuild/i,/\b(redmi[\s\-_]?(?:note|k)?[\w\s_]+)(?:\sbuild|\))/i,/\b(mi[\s\-_]?(?:a\d|one|one[\s_]plus|note lte)?[\s_]?(?:\d?\w?)[\s_]?(?:plus)?)\sbuild/i],[[s,/_/g," "],[c,"Xiaomi"],[u,p]],[/\b(mi[\s\-_]?(?:pad)(?:[\w\s_]+))(?:\sbuild|\))/i],[[s,/_/g," "],[c,"Xiaomi"],[u,m]],[/;\s(\w+)\sbuild.+\soppo/i,/\s(cph[12]\d{3}|p(?:af|c[al]|d\w|e[ar])[mt]\d0|x9007)\b/i],[s,[c,"OPPO"],[u,p]],[/\svivo\s(\w+)(?:\sbuild|\))/i,/\s(v[12]\d{3}\w?[at])(?:\sbuild|;)/i],[s,[c,"Vivo"],[u,p]],[/\s(rmx[12]\d{3})(?:\sbuild|;)/i],[s,[c,"Realme"],[u,p]],[/\s(milestone|droid(?:[2-4x]|\s(?:bionic|x2|pro|razr))?:?(\s4g)?)\b[\w\s]+build\//i,/\smot[\s-](\w*)/i,/((?:moto[\s\w\(\)]+|xt\d{3,4}|nexus\s6)(?=\sbuild|\)))/i],[s,[c,"Motorola"],[u,p]],[/\s(mz60\d|xoom[\s2]{0,2})\sbuild\//i],[s,[c,"Motorola"],[u,m]],[/((?=lg)?[vl]k\-?\d{3})\sbuild|\s3\.[\s\w;-]{10}lg?-([06cv9]{3,4})/i],[s,[c,"LG"],[u,m]],[/(nexus\s[45])/i,/lg[e;\s\/-]+((?!browser|netcast)\w+)/i,/\blg(\-?[\d\w]+)\sbuild/i],[s,[c,"LG"],[u,p]],[/(ideatab[\w\-\s]+)/i,/lenovo\s?(s(?:5000|6000)(?:[\w-]+)|tab(?:[\s\w]+)|yt[\d\w-]{6}|tb[\d\w-]{6})/i],[s,[c,"Lenovo"],[u,m]],[/(?:maemo|nokia).*(n900|lumia\s\d+)/i,/nokia[\s_-]?([\w\.-]*)/i],[s,[c,"Nokia"],[u,p]],[/droid.+;\s(pixel\sc)[\s)]/i],[s,[c,"Google"],[u,m]],[/droid.+;\s(pixel[\s\daxl]{0,6})(?:\sbuild|\))/i],[s,[c,"Google"],[u,p]],[/droid.+\s([c-g]\d{4}|so[-l]\w+|xq-a\w[4-7][12])(?=\sbuild\/|\).+chrome\/(?![1-6]{0,1}\d\.))/i],[s,[c,"Sony"],[u,p]],[/sony\stablet\s[ps]\sbuild\//i,/(?:sony)?sgp\w+(?:\sbuild\/|\))/i],[[s,"Xperia Tablet"],[c,"Sony"],[u,m]],[/\s(kb2005|in20[12]5|be20[12][59])\b/i,/\ba000(1)\sbuild/i,/\boneplus\s(a\d{4})[\s)]/i],[s,[c,"OnePlus"],[u,p]],[/(alexa)webm/i,/(kf[a-z]{2}wi)(\sbuild\/|\))/i,/(kf[a-z]+)(\sbuild\/|\)).+silk\//i],[s,[c,"Amazon"],[u,m]],[/(sd|kf)[0349hijorstuw]+(\sbuild\/|\)).+silk\//i],[[s,"Fire Phone"],[c,"Amazon"],[u,p]],[/\((playbook);[\w\s\),;-]+(rim)/i],[s,c,[u,m]],[/\(bb10;\s(\w+)/i],[s,[c,"BlackBerry"],[u,p]],[/(?:\b|asus_)(transfo[prime\s]{4,10}\s\w+|eeepc|slider\s\w+|nexus\s7|padfone|p00[cj])/i],[s,[c,"ASUS"],[u,m]],[/\s(z[es]6[027][01][km][ls]|zenfone\s\d\w?)\b/i],[s,[c,"ASUS"],[u,p]],[/(nexus\s9)/i],[s,[c,"HTC"],[u,m]],[/(htc)[;_\s-]{1,2}([\w\s]+(?=\)|\sbuild)|\w+)/i,/(zte)-(\w*)/i,/(alcatel|geeksphone|nexian|panasonic|(?=;\s)sony)[_\s-]?([\w-]*)/i],[c,[s,/_/g," "],[u,p]],[/droid[x\d\.\s;]+\s([ab][1-7]\-?[0178a]\d\d?)/i],[s,[c,"Acer"],[u,m]],[/droid.+;\s(m[1-5]\snote)\sbuild/i,/\bmz-([\w-]{2,})/i],[s,[c,"Meizu"],[u,p]],[/(blackberry)[\s-]?(\w+)/i,/(blackberry|benq|palm(?=\-)|sonyericsson|acer|asus|dell|meizu|motorola|polytron)[\s_-]?([\w-]*)/i,/(hp)\s([\w\s]+\w)/i,/(asus)-?(\w+)/i,/(microsoft);\s(lumia[\s\w]+)/i,/(lenovo)[_\s-]?([\w-]+)/i,/linux;.+(jolla);/i,/droid.+;\s(oppo)\s?([\w\s]+)\sbuild/i],[c,s,[u,p]],[/(archos)\s(gamepad2?)/i,/(hp).+(touchpad(?!.+tablet)|tablet)/i,/(kindle)\/([\w\.]+)/i,/\s(nook)[\w\s]+build\/(\w+)/i,/(dell)\s(strea[kpr\s\d]*[\dko])/i,/[;\/]\s?(le[\s\-]+pan)[\s\-]+(\w{1,9})\sbuild/i,/[;\/]\s?(trinity)[\-\s]*(t\d{3})\sbuild/i,/\b(gigaset)[\s\-]+(q\w{1,9})\sbuild/i,/\b(vodafone)\s([\w\s]+)(?:\)|\sbuild)/i],[c,s,[u,m]],[/\s(surface\sduo)\s/i],[s,[c,"Microsoft"],[u,m]],[/droid\s[\d\.]+;\s(fp\du?)\sbuild/i],[s,[c,"Fairphone"],[u,p]],[/\s(u304aa)\sbuild/i],[s,[c,"AT&T"],[u,p]],[/sie-(\w*)/i],[s,[c,"Siemens"],[u,p]],[/[;\/]\s?(rct\w+)\sbuild/i],[s,[c,"RCA"],[u,m]],[/[;\/\s](venue[\d\s]{2,7})\sbuild/i],[s,[c,"Dell"],[u,m]],[/[;\/]\s?(q(?:mv|ta)\w+)\sbuild/i],[s,[c,"Verizon"],[u,m]],[/[;\/]\s(?:barnes[&\s]+noble\s|bn[rt])([\w\s\+]*)\sbuild/i],[s,[c,"Barnes & Noble"],[u,m]],[/[;\/]\s(tm\d{3}\w+)\sbuild/i],[s,[c,"NuVision"],[u,m]],[/;\s(k88)\sbuild/i],[s,[c,"ZTE"],[u,m]],[/;\s(nx\d{3}j)\sbuild/i],[s,[c,"ZTE"],[u,p]],[/[;\/]\s?(gen\d{3})\sbuild.*49h/i],[s,[c,"Swiss"],[u,p]],[/[;\/]\s?(zur\d{3})\sbuild/i],[s,[c,"Swiss"],[u,m]],[/[;\/]\s?((zeki)?tb.*\b)\sbuild/i],[s,[c,"Zeki"],[u,m]],[/[;\/]\s([yr]\d{2})\sbuild/i,/[;\/]\s(dragon[\-\s]+touch\s|dt)(\w{5})\sbuild/i],[[c,"Dragon Touch"],s,[u,m]],[/[;\/]\s?(ns-?\w{0,9})\sbuild/i],[s,[c,"Insignia"],[u,m]],[/[;\/]\s?((nxa|Next)-?\w{0,9})\sbuild/i],[s,[c,"NextBook"],[u,m]],[/[;\/]\s?(xtreme\_)?(v(1[045]|2[015]|[3469]0|7[05]))\sbuild/i],[[c,"Voice"],s,[u,p]],[/[;\/]\s?(lvtel\-)?(v1[12])\sbuild/i],[[c,"LvTel"],s,[u,p]],[/;\s(ph-1)\s/i],[s,[c,"Essential"],[u,p]],[/[;\/]\s?(v(100md|700na|7011|917g).*\b)\sbuild/i],[s,[c,"Envizen"],[u,m]],[/[;\/]\s?(trio[\s\w\-\.]+)\sbuild/i],[s,[c,"MachSpeed"],[u,m]],[/[;\/]\s?tu_(1491)\sbuild/i],[s,[c,"Rotor"],[u,m]],[/(shield[\w\s]+)\sbuild/i],[s,[c,"Nvidia"],[u,m]],[/(sprint)\s(\w+)/i],[c,s,[u,p]],[/(kin\.[onetw]{3})/i],[[s,/\./g," "],[c,"Microsoft"],[u,p]],[/droid\s[\d\.]+;\s(cc6666?|et5[16]|mc[239][23]x?|vc8[03]x?)\)/i],[s,[c,"Zebra"],[u,m]],[/droid\s[\d\.]+;\s(ec30|ps20|tc[2-8]\d[kx])\)/i],[s,[c,"Zebra"],[u,p]],[/\s(ouya)\s/i,/(nintendo)\s([wids3utch]+)/i],[c,s,[u,d]],[/droid.+;\s(shield)\sbuild/i],[s,[c,"Nvidia"],[u,d]],[/(playstation\s[345portablevi]+)/i],[s,[c,"Sony"],[u,d]],[/[\s\(;](xbox(?:\sone)?(?!;\sxbox))[\s\);]/i],[s,[c,"Microsoft"],[u,d]],[/smart-tv.+(samsung)/i],[c,[u,v]],[/hbbtv.+maple;(\d+)/i],[[s,/^/,"SmartTV"],[c,"Samsung"],[u,v]],[/(?:linux;\snetcast.+smarttv|lg\snetcast\.tv-201\d)/i],[[c,"LG"],[u,v]],[/(apple)\s?tv/i],[c,[s,"Apple TV"],[u,v]],[/crkey/i],[[s,"Chromecast"],[c,"Google"],[u,v]],[/droid.+aft([\w])(\sbuild\/|\))/i],[s,[c,"Amazon"],[u,v]],[/\(dtv[\);].+(aquos)/i],[s,[c,"Sharp"],[u,v]],[/hbbtv\/\d+\.\d+\.\d+\s+\([\w\s]*;\s*(\w[^;]*);([^;]*)/i],[[c,y.trim],[s,y.trim],[u,v]],[/[\s\/\(](android\s|smart[-\s]?|opera\s)tv[;\)\s]/i],[[u,v]],[/((pebble))app\/[\d\.]+\s/i],[c,s,[u,g]],[/droid.+;\s(glass)\s\d/i],[s,[c,"Google"],[u,g]],[/droid\s[\d\.]+;\s(wt63?0{2,3})\)/i],[s,[c,"Zebra"],[u,g]],[/droid .+?; ([^;]+?)(?: build|\) applewebkit).+? mobile safari/i],[s,[u,p]],[/droid .+?;\s([^;]+?)(?: build|\) applewebkit).+?(?! mobile) safari/i],[s,[u,m]],[/\s(tablet|tab)[;\/]/i,/\s(mobile)(?:[;\/]|\ssafari)/i],[[u,y.lowerize]],[/(android[\w\.\s\-]{0,9});.+build/i],[s,[c,"Generic"]],[/(phone)/i],[[u,p]]],engine:[[/windows.+\sedge\/([\w\.]+)/i],[f,[l,"EdgeHTML"]],[/webkit\/537\.36.+chrome\/(?!27)([\w\.]+)/i],[f,[l,"Blink"]],[/(presto)\/([\w\.]+)/i,/(webkit|trident|netfront|netsurf|amaya|lynx|w3m|goanna)\/([\w\.]+)/i,/ekioh(flow)\/([\w\.]+)/i,/(khtml|tasman|links)[\/\s]\(?([\w\.]+)/i,/(icab)[\/\s]([23]\.[\d\.]+)/i],[l,f],[/rv\:([\w\.]{1,9})\b.+(gecko)/i],[f,l]],os:[[/microsoft\s(windows)\s(vista|xp)/i],[l,f],[/(windows)\snt\s6\.2;\s(arm)/i,/(windows\sphone(?:\sos)*)[\s\/]?([\d\.\s\w]*)/i,/(windows\smobile|windows)[\s\/]?([ntce\d\.\s]+\w)(?!.+xbox)/i],[l,[f,b.str,x.os.windows.version]],[/(win(?=3|9|n)|win\s9x\s)([nt\d\.]+)/i],[[l,"Windows"],[f,b.str,x.os.windows.version]],[/ip[honead]{2,4}\b(?:.*os\s([\w]+)\slike\smac|;\sopera)/i,/cfnetwork\/.+darwin/i],[[f,/_/g,"."],[l,"iOS"]],[/(mac\sos\sx)\s?([\w\s\.]*)/i,/(macintosh|mac(?=_powerpc)\s)(?!.+haiku)/i],[[l,"Mac OS"],[f,/_/g,"."]],[/(android|webos|palm\sos|qnx|bada|rim\stablet\sos|meego|sailfish|contiki)[\/\s-]?([\w\.]*)/i,/(blackberry)\w*\/([\w\.]*)/i,/(tizen|kaios)[\/\s]([\w\.]+)/i,/\((series40);/i],[l,f],[/\(bb(10);/i],[f,[l,"BlackBerry"]],[/(?:symbian\s?os|symbos|s60(?=;)|series60)[\/\s-]?([\w\.]*)/i],[f,[l,"Symbian"]],[/mozilla.+\(mobile;.+gecko.+firefox/i],[[l,"Firefox OS"]],[/\b(?:hp)?wos(?:browser)?\/([\w\.]+)/i],[f,[l,"webOS"]],[/crkey\/([\d\.]+)/i],[f,[l,"Chromecast"]],[/(cros)\s[\w]+\s([\w\.]+\w)/i],[[l,"Chromium OS"],f],[/(nintendo|playstation)\s([wids345portablevuch]+)/i,/(xbox);\s+xbox\s([^\);]+)/i,/(mint)[\/\s\(\)]?(\w*)/i,/(mageia|vectorlinux)[;\s]/i,/(joli|[kxln]?ubuntu|debian|suse|opensuse|gentoo|arch(?=\slinux)|slackware|fedora|mandriva|centos|pclinuxos|redhat|zenwalk|linpus|raspbian)(?:\sgnu\/linux)?(?:\slinux)?[\/\s-]?(?!chrom|package)([\w\.-]*)/i,/(hurd|linux)\s?([\w\.]*)/i,/(gnu)\s?([\w\.]*)/i,/\s([frentopc-]{0,4}bsd|dragonfly)\s?(?!amd|[ix346]{1,2}86)([\w\.]*)/i,/(haiku)\s(\w+)/i],[l,f],[/(sunos)\s?([\w\.\d]*)/i],[[l,"Solaris"],f],[/((?:open)?solaris)[\/\s-]?([\w\.]*)/i,/(aix)\s((\d)(?=\.|\)|\s)[\w\.])*/i,/(plan\s9|minix|beos|os\/2|amigaos|morphos|risc\sos|openvms|fuchsia)/i,/(unix)\s?([\w\.]*)/i],[l,f]]},w=function(t,e){if("object"==typeof t&&(e=t,t=n),!(this instanceof w))return new w(t,e).getResult();var i=t||(void 0!==r&&r.navigator&&r.navigator.userAgent?r.navigator.userAgent:""),o=e?y.extend(_,e):_;return this.getBrowser=function(){var t={name:n,version:n};return b.rgx.call(t,i,o.browser),t.major=y.major(t.version),t},this.getCPU=function(){var t={architecture:n};return b.rgx.call(t,i,o.cpu),t},this.getDevice=function(){var t={vendor:n,model:n,type:n};return b.rgx.call(t,i,o.device),t},this.getEngine=function(){var t={name:n,version:n};return b.rgx.call(t,i,o.engine),t},this.getOS=function(){var t={name:n,version:n};return b.rgx.call(t,i,o.os),t},this.getResult=function(){return{ua:this.getUA(),browser:this.getBrowser(),engine:this.getEngine(),os:this.getOS(),device:this.getDevice(),cpu:this.getCPU()}},this.getUA=function(){return i},this.setUA=function(t){return i=typeof t===a&&t.length>255?y.trim(t,255):t,this},this.setUA(i),this};w.VERSION="0.7.27",w.BROWSER={NAME:l,MAJOR:"major",VERSION:f},w.CPU={ARCHITECTURE:h},w.DEVICE={MODEL:s,VENDOR:c,TYPE:u,CONSOLE:d,MOBILE:p,SMARTTV:v,TABLET:m,WEARABLE:g,EMBEDDED:"embedded"},w.ENGINE={NAME:l,VERSION:f},w.OS={NAME:l,VERSION:f},t.exports&&(e=t.exports=w),e.UAParser=w;var C=void 0!==r&&(r.jQuery||r.Zepto);if(C&&!C.ua){var S=new w;C.ua=S.getResult(),C.ua.get=function(){return S.getUA()},C.ua.set=function(t){S.setUA(t);var e=S.getResult();for(var r in e)C.ua[r]=e[r]}}}("object"==typeof window?window:g)})).UAParser),_={_id:Math.random(),_version:"1.0",_container:{},_key:"",_branch:"LOCA",records:{},bowserInfo:{},init:function(){this.getGpu(),setTimeout((function(){_.send()}),2e3),setInterval((function(){_.send()}),1e4)},setAPIKey:function(t){this._key=t},setContainer:function(t){this._container=t;var e=t.getBoundingClientRect();this.bowserInfo.size=[e.width,e.height]},setVersion:function(t){this._version=t},getGpu:function(){var t=document.createElement("canvas").getContext("webgl");if(t){var e=t.getExtension("WEBGL_debug_renderer_info");this.bowserInfo.gpu=e&&t.getParameter(e.UNMASKED_RENDERER_WEBGL)}},getKey:function(t,e){void 0===t&&(t=""),t=t;var r=[];return"[object Object]"===Object.prototype.toString.call(e)&&(r=Object.keys(e)),void 0!==e&&t?t+"@"+r.join():t},record:function(t,e,r){this.records[t]||(this.records[t]={});var n=this.getKey(e,r);null==this.records[t][n]&&(this.records[t][n]=0)},send:function(){var t=[];for(var e in this.records)if(this.records.hasOwnProperty(e)){var r=this.records[e],n=[];for(var i in r)r.hasOwnProperty(i)&&0==r[i]&&(n.push(i),r[i]=1);n.length&&t.push(e+"~"+n.join(","))}if(t.length){var o=x.getResult(),a="https://webapi.amap.com/count?"+["type=nfl","k="+this._key,"m="+("moblie"===o.device.type?1:0),"pf="+o.os.name,"v="+this._version,"branch="+this._branch,"logversion=2.0","gc="+this.bowserInfo.gpu,"log="+t.join("!"),"appname="+window.location.origin+window.location.pathname,"sdkversion="+this._version].join("&");h.CommonUtil.JSONP(a)}},sendDeviceInfo:function(){}},w=function(t){function e(e){var r=t.call(this)||this;return r.CLASS_NAME="Layer",r.meshes=[],r.buryPoint=_,r.id=h.CommonUtil.getGuid(),r.map=e.map,r.zIndex=e.zIndex,r.visible=e.visible,r.opacity=e.opacity,r.zooms=e.zooms,r.style=m,r}return i(e,t),e.prototype.setSource=function(t,e){this.source&&this.source.removeLayer(this),this.buryPoint.record(this.CLASS_NAME,"setSource"),this.source=t,e&&this.setStyle(e),this.source.addLayer(this)},e.prototype.setStyle=function(t){t&&this.buryPoint.record(this.CLASS_NAME,"setStyle",t),this.styleOptions=t},e.prototype.filterDataset=function(){for(var t=this.dataset,e=this.meshes,r={willFusion:[],didFusion:[],didFusionDataset:[]},n=function(n){var i=t[n].id,o=e.find((function(t){return t.id===i}));o?(r.didFusion.push(o),r.didFusionDataset.push(t[n])):r.willFusion.push(t[n])},i=0;i<t.length;i++)n(i);return r},e.prototype.setMap=function(t){this.map=t},e.prototype.onAdd=function(){this._startTime=performance.now(),this.emit("loaded")},e.prototype.onRemove=function(){this._startTime=0},e.prototype.setZooms=function(t){this.zooms=t},e.prototype.setOpacity=function(t){this.opacity=t},e.prototype.setzIndex=function(t){this.zIndex=t},e.prototype.show=function(){this.visible=!0},e.prototype.hide=function(){this.visible=!1},e.prototype.getTimer=function(){return performance.now()-this._startTime},e}(v),C=function(){function t(t){var e=this;this.startPos=[0,0],this.lastPos=[0,0],this.clickCount=0,this._isDown=!1,this.onWheel=function(t){var r=t.deltaX,n=t.deltaY;e.map.emit("wheel",{event:t,deltaX:r,deltaY:n})},this.onMouseDown=function(t){e._isDown=!0,e.container&&(e.startPos=h.DomUtil.mousePos(e.container,t),e.lastPos=e.startPos),e.map.emit("mousedown",{event:t,pos:e.startPos})},this.onMouseMove=function(t){var r=[0,0],n=function(){for(var t=0,e=0,r=arguments.length;e<r;e++)t+=arguments[e].length;var n=Array(t),i=0;for(e=0;e<r;e++)for(var o=arguments[e],a=0,s=o.length;a<s;a++,i++)n[i]=o[a];return n}(e.lastPos),i={event:t,lastPos:n,deltaPos:r,startPos:e.startPos};if(e._isDown&&e.container){var o=h.DomUtil.mousePos(e.container,t);r=[o[0]-n[0],o[1]-n[1]],e.lastPos=o,i.deltaPos=r,e.map.emit("drag",i)}e.map.emit("mousemove",i)},this.onMouseUp=function(t){e._isDown=!1;var r=[0,0];e.container&&(r=h.DomUtil.mousePos(e.container,t),Math.abs(r[0]-e.startPos[0])<=1&&Math.abs(r[1]-e.startPos[1])<=1&&(e.clickCount++,e.clickCount>=2?e.map.emit("dblclick",{event:t,pos:r}):e.map.emit("click",{event:t,pos:r})),e.map.emit("mouseup",{event:t,pos:r}),setTimeout((function(){e.clickCount=0}),300))},this.onContextMenu=function(t){if(t.preventDefault(),e.container){var r=h.DomUtil.mousePos(e.container,t);e.map.emit("rightclick",{event:t,pos:r})}},this.map=t,this.container=this.map.container,this.bindEvents()}return t.prototype.bindEvents=function(){var t,e,r,n,i;null===(t=this.container)||void 0===t||t.addEventListener("wheel",this.onWheel),null===(e=this.container)||void 0===e||e.addEventListener("mousedown",this.onMouseDown),null===(r=this.container)||void 0===r||r.addEventListener("mousemove",this.onMouseMove),null===(n=this.container)||void 0===n||n.addEventListener("mouseup",this.onMouseUp),null===(i=this.container)||void 0===i||i.addEventListener("contextmenu",this.onContextMenu)},t}(),S=b((function(t,e){Object.defineProperty(e,"__esModule",{value:!0});var r=function(){function t(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,n.key,n)}}return function(e,r,n){return r&&t(e.prototype,r),n&&t(e,n),e}}(),n=-1,i=function(){function t(){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.__events__={},this.__id__=++n}return r(t,[{key:"on",value:function(t,e,r){var n=this.__events__,i=n[t]=n[t]||[];r===this&&(r=void 0);for(var o=-1,a=i;++o<a;){var s=i[o],l=s.fn,u=s.ctx;if(l===e&&u===r)return this}var c={fn:e,ctx:r};return i.push(c),this}},{key:"once",value:function(t,e,r){function n(r){this.off(t,n),e.call(this,r)}return n.listener=e,this.on(t,n,r)}},{key:"off",value:function(t,e,r){var n=this.__events__;if(!t)return this.__events__={},this;if(!e)return delete n[t],this;var i=n[t];if(i)for(var o=i.length;--o>=0;){var a=i[o],s=a.fn;a.ctx===r&&(s!==e&&s!==s.listener||(i.splice(o,1),s=function(){}))}return this}},{key:"emit",value:function(t,e){var r=this.__events__[t];if(r)for(var n=function(t){for(var e=-1,r=arguments.length<=1?0:arguments.length-1;++e<r;){var n=arguments.length<=e+1?void 0:arguments[e+1];for(var i in n)n.hasOwnProperty(i)&&(t[i]=n[i])}return t}({},e,{target:this,type:t}),i=-1,o=r.length;++i<o;){var a=r[i],s=a.fn,l=a.ctx;s.call(l||this,n)}return this}},{key:"events",get:function(){return this.__events__}},{key:"id",get:function(){return this.__id__}}]),t}();e.default=i}));y(S);var k=b((function(t,e){Object.defineProperty(e,"__esModule",{value:!0});var r=function(t,e){if(Array.isArray(t))return t;if(Symbol.iterator in Object(t))return function(t,e){var r=[],n=!0,i=!1,o=void 0;try{for(var a,s=t[Symbol.iterator]();!(n=(a=s.next()).done)&&(r.push(a.value),!e||r.length!==e);n=!0);}catch(t){i=!0,o=t}finally{try{!n&&s.return&&s.return()}finally{if(i)throw o}}return r}(t,e);throw new TypeError("Invalid attempt to destructure non-iterable instance")};e.default={remove:function(t,e){var r=[];if(!t||!t.length)return r;if("function"==typeof e){for(var n=-1,i=[],o=t.length;++n<o;){var a=t[n];e(a,n,t)&&(r.push(a),i.push(n))}!function(t,e){for(var r=t?e.length:0;r-- >0;){var n=e[r];t.splice(n,1)}}(t,i)}return r},normalize:function t(e){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(!Array.isArray(e))return e;var i=n.type,o=void 0===i?"":i,a=n.range,s=void 0===a?[0,1]:a,l=n.min,u=void 0===l?Math.min.apply(Math,e):l,c=n.max,f=void 0===c?Math.max.apply(Math,e):c;o=o.toLowerCase();for(var h=[],d=f-u,p=-1,m=e.length;++p<m;){var v=e[p];v>f&&(v=f),v<u&&(v=u);var g=void 0;g="log"!==o?(v-u)/d:Math.log10(v),h.push(g)}"log"===o&&(h=t(h));var y=r(s,2),b=y[0],x=y[1];if(0!==b||1!==x){for(var _=-1,w=h.length,C=x-b,S=[];++_<w;){var k=C*h[_]+b;S.push(k)}h=S}return h},forInMap:function(t,e){for(var r in t)t.hasOwnProperty(r)&&e(t[r],r,t)}}}));y(k);var A=b((function(t,e){Object.defineProperty(e,"__esModule",{value:!0}),function(){if("performance"in window==0&&(window.performance={}),Date.now=Date.now||function(){return(new Date).getTime()},"now"in window.performance==0){var t=window.performance.timing&&window.performance.timing.navigationStart?window.performance.timing.navigationStart:Date.now();window.performance.now=function(){return Date.now()-t}}}();var r="undefined"!=typeof window&&(window.requestAnimationFrame||window.msRequestAnimationFrame||window.mozRequestAnimationFrame||window.webkitRequestAnimationFrame)||function(t){setTimeout(t,16)},n="undefined"!=typeof window&&(window.cancelAnimationFrame||window.msCancelAnimationFrame||window.mozCancelAnimationFrame||window.webkitCancelAnimationFrame)||function(t){clearTimeout(t)};e.requestAnimationFrame=r,e.cancelAnimationFrame=n}));y(A),A.requestAnimationFrame,A.cancelAnimationFrame;var M=b((function(t,e){Object.defineProperty(e,"__esModule",{value:!0}),e.Ev={UPDATE:"update",START:"start",REPEAT:"repeat",REPEAT_COMPLETE:"repeatComplete",AFTER_UPDATE:"afterUpdate",COMPLETE:"complete",PAUSE:"pause",STOP:"stop",RESET:"reset"},e.Attr={DURATION:"duration",REPEAT:"repeat",DELAY:"delay",EASING:"easing",INTERVAL:"interval",YOYO:"yoyo",START:"startAt"},e.Easing={LINEAR:"Linear",QUADRATIC_IN:"QuadraticIn",QUADRATIC_OUT:"QuadraticOut",QUADRATIC_IN_OUT:"QuadraticInOut",CUBIC_IN:"CubicIn",CUBIC_OUT:"CubicOut",CUBIC_IN_OUT:"CubicInOut",QUARTIC_IN:"QuarticIn",QUARTIC_OUT:"QuarticOut",QUARTIC_IN_OUT:"QuarticInOut",QUINTIC_IN:"QuinticIn",QUINTIC_OUT:"QuinticOut",QUINTIC_IN_OUT:"QuinticInOut",SINUSOIDAL_IN:"SinusoidalIn",SINUSOIDAL_OUT:"SinusoidalOut",SINUSOIDAL_IN_OUT:"SinusoidalInOut",EXPONENTIAL_IN:"ExponentialIn",EXPONENTIAL_OUT:"ExponentialOut",EXPONENTIAL_IN_OUT:"ExponentialInOut",CIRCULAR_IN:"CircularIn",CIRCULAR_OUT:"CircularOut",CIRCULAR_IN_OUT:"CircularInOut",ELASTIC_IN:"ElasticIn",ELASTIC_OUT:"ElasticOut",ELASTIC_IN_OUT:"ElasticInOut",BACK_IN:"BackIn",BACK_OUT:"BackOut",BACK_IN_OUT:"BackInOut",BOUNCE_IN:"BounceIn",BOUNCE_OUT:"BounceOut",BOUNCE_IN_OUT:"BounceInOut"}}));y(M),M.Ev,M.Attr,M.Easing;var z=b((function(t,e){Object.defineProperty(e,"__esModule",{value:!0});var r=function(){function t(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,n.key,n)}}return function(e,r,n){return r&&t(e.prototype,r),n&&t(e,n),e}}(),n=o(S),i=o(k);function o(t){return t&&t.__esModule?t:{default:t}}var a=i.default.remove,s=i.default.forInMap,l=function(t){function e(t){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,e);var r=function(t,e){if(!t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!e||"object"!=typeof e&&"function"!=typeof e?t:e}(this,(e.__proto__||Object.getPrototypeOf(e)).call(this));return r._options={},r._savedClipMap={},r._clips=[],r._clipMap={},r._options=t||{},r}return function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function, not "+typeof e);t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}),e&&(Object.setPrototypeOf?Object.setPrototypeOf(t,e):t.__proto__=e)}(e,t),r(e,[{key:"_startAni",value:function(){var t=this;this._timer=(0,A.requestAnimationFrame)((function e(r){t._timer=(0,A.requestAnimationFrame)(e),t._update(r)}))}},{key:"_stopAni",value:function(){var t=this._timer;return!!t&&((0,A.cancelAnimationFrame)(t),this._timer=null,!0)}},{key:"_update",value:function(t){var e=this._clips;this.emit(M.Ev.UPDATE,{timestamp:t});for(var r=0;r<e.length;){var n=e[r];n.update(t)?r++:this._rmClip(n)}this._clips=e,this.emit(M.Ev.AFTER_UPDATE),0===e.length&&(this._stopAni(),this.emit(M.Ev.COMPLETE))}},{key:"start",value:function(){var t=this._clips,e=t.length;if(this._timer||0===e)return this;this.emit(M.Ev.START);for(var r=-1;++r<e;)t[r].start();return this._startAni(),this}},{key:"stop",value:function(){return this._stop(!1),this}},{key:"pause",value:function(){return this._stop(!0),this}},{key:"reset",value:function(){this._stop(!1,!0,!1);var t=this._savedClipMap,e=[];return s(t,(function(t){t.stop(!0),e.push(t)})),this._clips=e,this.emit(M.Ev.RESET),this}},{key:"_stop",value:function(t,e){var r=!(arguments.length>2&&void 0!==arguments[2])||arguments[2];this._stopAni();var n=this._clips,i=n.length;if(i){for(var o=-1;++o<i;){var a=n[o];t?a.pause():a.stop(e)}r&&this.emit(t?M.Ev.PAUSE:M.Ev.STOP)}}},{key:"addClip",value:function(t){var e=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];Array.isArray(t)||(t=[t]);for(var r=-1,n=t.length;++r<n;){var i=t[r];this._hasSavedClip(i)||(this._addClip(i),this._addSavedClip(i),this._timer&&e&&i.start())}return this}},{key:"_addClip",value:function(t){var e=this._clips;-1===e.indexOf(t)&&(e.push(t),t._animation=this)}},{key:"_addSavedClip",value:function(t){var e=this._savedClipMap,r=t.id;e[r]!==t&&(e[r]=t,t._animation=this)}},{key:"removeClip",value:function(t){var e=this._savedClipMap;return t?(this._rmClip(t),this._rmSavedClip(t),t._animation=null):(s(e,(function(t){t._animation=null})),this._clips=[],this._savedClipMap={}),this}},{key:"_rmClip",value:function(t){a(this._clips,(function(e){return e===t}))}},{key:"_rmSavedClip",value:function(t){this._hasSavedClip(t)&&delete this._savedClipMap[t.id]}},{key:"getClips",value:function(){return this._clips}},{key:"_hasSavedClip",value:function(t){var e=t.id,r=this._savedClipMap[e];return r&&r===t}},{key:"_hasClip",value:function(t){return-1!==this._clips.indexOf(t)}},{key:"destroy",value:function(){this.off(),this._stopAni(),this.removeClip()}}]),e}(n.default);l.Event=M.Ev,e.default=l}));y(z);var O=b((function(t,e){Object.defineProperty(e,"__esModule",{value:!0});var r={Linear:function(t){return t},QuadraticIn:function(t){return t*t},QuadraticOut:function(t){return t*(2-t)},QuadraticInOut:function(t){return(t*=2)<1?.5*t*t:-.5*(--t*(t-2)-1)},CubicIn:function(t){return t*t*t},CubicOut:function(t){return--t*t*t+1},CubicInOut:function(t){return(t*=2)<1?.5*t*t*t:.5*((t-=2)*t*t+2)},QuarticIn:function(t){return t*t*t*t},QuarticOut:function(t){return 1- --t*t*t*t},QuarticInOut:function(t){return(t*=2)<1?.5*t*t*t*t:-.5*((t-=2)*t*t*t-2)},QuinticIn:function(t){return t*t*t*t*t},QuinticOut:function(t){return--t*t*t*t*t+1},QuinticInOut:function(t){return(t*=2)<1?.5*t*t*t*t*t:.5*((t-=2)*t*t*t*t+2)},SinusoidalIn:function(t){return 1-Math.cos(t*Math.PI/2)},SinusoidalOut:function(t){return Math.sin(t*Math.PI/2)},SinusoidalInOut:function(t){return.5*(1-Math.cos(Math.PI*t))},ExponentialIn:function(t){return 0===t?0:Math.pow(1024,t-1)},ExponentialOut:function(t){return 1===t?1:1-Math.pow(2,-10*t)},ExponentialInOut:function(t){return 0===t?0:1===t?1:(t*=2)<1?.5*Math.pow(1024,t-1):.5*(2-Math.pow(2,-10*(t-1)))},CircularIn:function(t){return 1-Math.sqrt(1-t*t)},CircularOut:function(t){return Math.sqrt(1- --t*t)},CircularInOut:function(t){return(t*=2)<1?-.5*(Math.sqrt(1-t*t)-1):.5*(Math.sqrt(1-(t-=2)*t)+1)},ElasticIn:function(t){var e,r=.1;return 0===t?0:1===t?1:(!r||r<1?(r=1,e=.1):e=.4*Math.asin(1/r)/(2*Math.PI),-r*Math.pow(2,10*(t-=1))*Math.sin((t-e)*(2*Math.PI)/.4))},ElasticOut:function(t){var e,r=.1;return 0===t?0:1===t?1:(!r||r<1?(r=1,e=.1):e=.4*Math.asin(1/r)/(2*Math.PI),r*Math.pow(2,-10*t)*Math.sin((t-e)*(2*Math.PI)/.4)+1)},ElasticInOut:function(t){var e,r=.1;return 0===t?0:1===t?1:(!r||r<1?(r=1,e=.1):e=.4*Math.asin(1/r)/(2*Math.PI),(t*=2)<1?r*Math.pow(2,10*(t-=1))*Math.sin((t-e)*(2*Math.PI)/.4)*-.5:r*Math.pow(2,-10*(t-=1))*Math.sin((t-e)*(2*Math.PI)/.4)*.5+1)},BackIn:function(t){var e=1.70158;return t*t*((e+1)*t-e)},BackOut:function(t){var e=1.70158;return--t*t*((e+1)*t+e)+1},BackInOut:function(t){var e=2.5949095;return(t*=2)<1?t*t*((e+1)*t-e)*.5:.5*((t-=2)*t*((e+1)*t+e)+2)},BounceIn:function(t){return 1-r.BounceOut(1-t)},BounceOut:function(t){return t<1/2.75?7.5625*t*t:t<2/2.75?7.5625*(t-=1.5/2.75)*t+.75:t<2.5/2.75?7.5625*(t-=2.25/2.75)*t+.9375:7.5625*(t-=2.625/2.75)*t+.984375},BounceInOut:function(t){return t<.5?.5*r.BounceIn(2*t):.5*r.BounceOut(2*t-1)+.5}};e.default=r}));y(O);var E=b((function(t,e){Object.defineProperty(e,"__esModule",{value:!0});var r,n={Linear:function(t,e){var r=t.length-1,i=r*e,o=Math.floor(i),a=n.Utils.Linear;return e<0?a(t[0],t[1],i):e>1?a(t[r],t[r-1],r-i):a(t[o],t[o+1>r?r:o+1],i-o)},Bezier:function(t,e){for(var r=0,i=t.length-1,o=Math.pow,a=n.Utils.Bernstein,s=0;s<=i;s++)r+=o(1-e,i-s)*o(e,s)*t[s]*a(i,s);return r},CatmullRom:function(t,e){var r=t.length-1,i=r*e,o=Math.floor(i),a=n.Utils.CatmullRom;return t[0]===t[r]?(e<0&&(o=Math.floor(i=r*(1+e))),a(t[(o-1+r)%r],t[o],t[(o+1)%r],t[(o+2)%r],i-o)):e<0?t[0]-(a(t[0],t[0],t[1],t[1],-i)-t[0]):e>1?t[r]-(a(t[r],t[r],t[r-1],t[r-1],i-r)-t[r]):a(t[o?o-1:0],t[o],t[r<o+1?r:o+1],t[r<o+2?r:o+2],i-o)},Utils:{Linear:function(t,e,r){return(e-t)*r+t},Bernstein:function(t,e){var r=n.Utils.Factorial;return r(t)/r(e)/r(t-e)},Factorial:(r=[1],function(t){var e=1;if(r[t])return r[t];for(var n=t;n>1;n--)e*=n;return r[t]=e,e}),CatmullRom:function(t,e,r,n,i){var o=.5*(r-t),a=.5*(n-e),s=i*i;return(2*e-2*r+o+a)*(i*s)+(-3*e+3*r-2*o-a)*s+o*i+e}}};e.default=n}));y(E);var P=b((function(t,e){Object.defineProperty(e,"__esModule",{value:!0});var r=function(){function t(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,n.key,n)}}return function(e,r,n){return r&&t(e.prototype,r),n&&t(e,n),e}}(),n=a(S),i=a(O),o=a(E);function a(t){return t&&t.__esModule?t:{default:t}}var s=function(t){function e(t,r){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,e);var n=function(t,e){if(!t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!e||"object"!=typeof e&&"function"!=typeof e?t:e}(this,(e.__proto__||Object.getPrototypeOf(e)).call(this));return n._options={},n._attr={},n._startAt=0,n._stopped=!0,n._paused=!1,n._startTime=0,n._pauseStart=0,n._pauseTime=0,n._reversed=!1,n._chainClips=[],n._tracks=[],n._interpolation=o.default.Linear,n._options=t||{},n._attr=r,n._initOption(t),n._tracks=n._transform(r),n}return function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function, not "+typeof e);t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}),e&&(Object.setPrototypeOf?Object.setPrototypeOf(t,e):t.__proto__=e)}(e,t),r(e,null,[{key:"registerPlugin",value:function(t){var e=t.type,r=this._plugins;r&&r[e]||(this._plugins=r||{},this._plugins[e]=t)}}]),r(e,[{key:"_initOption",value:function(t){var e=t[M.Attr.EASING]||M.Easing.LINEAR;this._easing=i.default[e]?i.default[e]:e,this._delay=t[M.Attr.DELAY]||0;var r=t[M.Attr.DURATION];this._duration=void 0===r?1e3:r,this._repeat_0=this._repeat=t[M.Attr.REPEAT]||1,this._interval=t[M.Attr.INTERVAL]||0,this._yoyo=t[M.Attr.YOYO]||!1,this._startAt=t[M.Attr.START]||0}},{key:"_transform",value:function(t){var e=this.constructor._plugins,r=[];for(var n in t)if(t.hasOwnProperty(n)){var i=t[n];for(var o in e){var a=e[o];if(a.test(i,n)){(i=a.parse(i,n)).__type__=a.type;break}}r.push({key:n,value:i})}return r}},{key:"start",value:function(t){var e=window.performance.now(),r=!1;if(this._paused)this._pauseTime+=e-this._pauseStart,this._paused=!1;else{if(!t&&!this._stopped)return this;r=!0,this._stopped=!1,this._startTime=e+this._delay}this.emit(M.Ev.START);var n=this._repeat;return n>1&&n===this._repeat_0&&r&&this.emit(M.Ev.REPEAT,{remain:0}),this}},{key:"stop",value:function(t){return this._stopped||(this._stopped=!0,this._paused=!1,this._pauseTime=0,this._pauseStart=0,this.emit(M.Ev.STOP),this.stopChain()),t&&(this._repeat=this._repeat_0),this}},{key:"pause",value:function(){return this._stopped||this._paused||(this._paused=!0,this._pauseStart=window.performance.now(),this.emit(M.Ev.PAUSE)),this}},{key:"update",value:function(t){if(this._stopped)return!0;if(this._paused||t&&t<this._startTime)return!0;var e=t-this._pauseTime,r=this._getProgress(e),n=r.progress,i=r.elapsed,o=this._updateAttr(n,i);return this.emit(M.Ev.UPDATE,{progress:n,keyframe:o,elapsed:i}),this._afterUpdate(e,i)}},{key:"_getProgress",value:function(t){var e=(t-this._startTime)/this._duration;return e+=this._startAt,e=Math.min(e,1),{progress:this._easing(this._reversed?1-e:e),elapsed:e}}},{key:"_updateAttr",value:function(t,e){for(var r=this._tracks,n={},i=0,o=r.length;i<o;){var a=r[i++],s=a.key,l=a.value,u=l.__type__;l=u?this.constructor._plugins[u].valueOf(l,t,e,s):this._interpolation(l,t),n[s]=l}return n}},{key:"_afterUpdate",value:function(t,e){if(1===e){var r=this._repeat,n=this._repeat_0;if(r>1)return isFinite(r)&&r--,this._startTime=t+this._interval,this._startAt=0,this._yoyo&&(this._reversed=!this._reversed),this._repeat=r,this.emit(M.Ev.REPEAT_COMPLETE,{repeat:r}),this.emit(M.Ev.REPEAT,{remain:n-r}),!0;this._stopped=!0,this._pauseTime=0,this._pauseStart=0,this._repeat=n,n>1&&this.emit(M.Ev.REPEAT_COMPLETE,{repeat:0}),this.emit(M.Ev.COMPLETE);for(var i=-1,o=this._chainClips,a=o.length,s=this._animation;++i<a;){var l=o[i];s&&s._addClip(l),l.start()}return!1}return!0}},{key:"chain",value:function(){for(var t=arguments.length,e=Array(t),r=0;r<t;r++)e[r]=arguments[r];return this._chainClips=e,this}},{key:"stopChain",value:function(){for(var t=-1,e=this._chainClips,r=e.length;++t<r;)e[t].stop();return this}},{key:"destroy",value:function(){this.off(),this._stopped=!0,this._paused=!1,this._startTime=0,this._pauseTime=0,this._pauseStart=0,this._chainClips=[];var t=this._animation;t&&t.removeClip(this),this._animation=null}}]),e}(n.default);s.Event=M.Ev,s.Attr=M.Attr,s.Easing=M.Easing,e.default=s}));y(P);var L=b((function(t,e){Object.defineProperty(e,"__esModule",{value:!0}),e.Clip=e.Animation=void 0;var r=i(z),n=i(P);function i(t){return t&&t.__esModule?t:{default:t}}e.default={Animation:r.default,Clip:n.default},e.Animation=r.default,e.Clip=n.default}));y(L),L.Clip,L.Animation;var T=b((function(t,e){var r={transparent:[0,0,0,0],aliceblue:[240,248,255,1],antiquewhite:[250,235,215,1],aqua:[0,255,255,1],aquamarine:[127,255,212,1],azure:[240,255,255,1],beige:[245,245,220,1],bisque:[255,228,196,1],black:[0,0,0,1],blanchedalmond:[255,235,205,1],blue:[0,0,255,1],blueviolet:[138,43,226,1],brown:[165,42,42,1],burlywood:[222,184,135,1],cadetblue:[95,158,160,1],chartreuse:[127,255,0,1],chocolate:[210,105,30,1],coral:[255,127,80,1],cornflowerblue:[100,149,237,1],cornsilk:[255,248,220,1],crimson:[220,20,60,1],cyan:[0,255,255,1],darkblue:[0,0,139,1],darkcyan:[0,139,139,1],darkgoldenrod:[184,134,11,1],darkgray:[169,169,169,1],darkgreen:[0,100,0,1],darkgrey:[169,169,169,1],darkkhaki:[189,183,107,1],darkmagenta:[139,0,139,1],darkolivegreen:[85,107,47,1],darkorange:[255,140,0,1],darkorchid:[153,50,204,1],darkred:[139,0,0,1],darksalmon:[233,150,122,1],darkseagreen:[143,188,143,1],darkslateblue:[72,61,139,1],darkslategray:[47,79,79,1],darkslategrey:[47,79,79,1],darkturquoise:[0,206,209,1],darkviolet:[148,0,211,1],deeppink:[255,20,147,1],deepskyblue:[0,191,255,1],dimgray:[105,105,105,1],dimgrey:[105,105,105,1],dodgerblue:[30,144,255,1],firebrick:[178,34,34,1],floralwhite:[255,250,240,1],forestgreen:[34,139,34,1],fuchsia:[255,0,255,1],gainsboro:[220,220,220,1],ghostwhite:[248,248,255,1],gold:[255,215,0,1],goldenrod:[218,165,32,1],gray:[128,128,128,1],green:[0,128,0,1],greenyellow:[173,255,47,1],grey:[128,128,128,1],honeydew:[240,255,240,1],hotpink:[255,105,180,1],indianred:[205,92,92,1],indigo:[75,0,130,1],ivory:[255,255,240,1],khaki:[240,230,140,1],lavender:[230,230,250,1],lavenderblush:[255,240,245,1],lawngreen:[124,252,0,1],lemonchiffon:[255,250,205,1],lightblue:[173,216,230,1],lightcoral:[240,128,128,1],lightcyan:[224,255,255,1],lightgoldenrodyellow:[250,250,210,1],lightgray:[211,211,211,1],lightgreen:[144,238,144,1],lightgrey:[211,211,211,1],lightpink:[255,182,193,1],lightsalmon:[255,160,122,1],lightseagreen:[32,178,170,1],lightskyblue:[135,206,250,1],lightslategray:[119,136,153,1],lightslategrey:[119,136,153,1],lightsteelblue:[176,196,222,1],lightyellow:[255,255,224,1],lime:[0,255,0,1],limegreen:[50,205,50,1],linen:[250,240,230,1],magenta:[255,0,255,1],maroon:[128,0,0,1],mediumaquamarine:[102,205,170,1],mediumblue:[0,0,205,1],mediumorchid:[186,85,211,1],mediumpurple:[147,112,219,1],mediumseagreen:[60,179,113,1],mediumslateblue:[123,104,238,1],mediumspringgreen:[0,250,154,1],mediumturquoise:[72,209,204,1],mediumvioletred:[199,21,133,1],midnightblue:[25,25,112,1],mintcream:[245,255,250,1],mistyrose:[255,228,225,1],moccasin:[255,228,181,1],navajowhite:[255,222,173,1],navy:[0,0,128,1],oldlace:[253,245,230,1],olive:[128,128,0,1],olivedrab:[107,142,35,1],orange:[255,165,0,1],orangered:[255,69,0,1],orchid:[218,112,214,1],palegoldenrod:[238,232,170,1],palegreen:[152,251,152,1],paleturquoise:[175,238,238,1],palevioletred:[219,112,147,1],papayawhip:[255,239,213,1],peachpuff:[255,218,185,1],peru:[205,133,63,1],pink:[255,192,203,1],plum:[221,160,221,1],powderblue:[176,224,230,1],purple:[128,0,128,1],rebeccapurple:[102,51,153,1],red:[255,0,0,1],rosybrown:[188,143,143,1],royalblue:[65,105,225,1],saddlebrown:[139,69,19,1],salmon:[250,128,114,1],sandybrown:[244,164,96,1],seagreen:[46,139,87,1],seashell:[255,245,238,1],sienna:[160,82,45,1],silver:[192,192,192,1],skyblue:[135,206,235,1],slateblue:[106,90,205,1],slategray:[112,128,144,1],slategrey:[112,128,144,1],snow:[255,250,250,1],springgreen:[0,255,127,1],steelblue:[70,130,180,1],tan:[210,180,140,1],teal:[0,128,128,1],thistle:[216,191,216,1],tomato:[255,99,71,1],turquoise:[64,224,208,1],violet:[238,130,238,1],wheat:[245,222,179,1],white:[255,255,255,1],whitesmoke:[245,245,245,1],yellow:[255,255,0,1],yellowgreen:[154,205,50,1]};function n(t){return(t=Math.round(t))<0?0:t>255?255:t}function i(t){return t<0?0:t>1?1:t}function o(t){return"%"===t[t.length-1]?n(parseFloat(t)/100*255):n(parseInt(t))}function a(t){return"%"===t[t.length-1]?i(parseFloat(t)/100):i(parseFloat(t))}function s(t,e,r){return r<0?r+=1:r>1&&(r-=1),6*r<1?t+(e-t)*r*6:2*r<1?e:3*r<2?t+(e-t)*(2/3-r)*6:t}try{e.parseCSSColor=function(t){var e,i=t.replace(/ /g,"").toLowerCase();if(i in r)return r[i].slice();if("#"===i[0])return 4===i.length?(e=parseInt(i.substr(1),16))>=0&&e<=4095?[(3840&e)>>4|(3840&e)>>8,240&e|(240&e)>>4,15&e|(15&e)<<4,1]:null:7===i.length&&(e=parseInt(i.substr(1),16))>=0&&e<=16777215?[(16711680&e)>>16,(65280&e)>>8,255&e,1]:null;var l=i.indexOf("("),u=i.indexOf(")");if(-1!==l&&u+1===i.length){var c=i.substr(0,l),f=i.substr(l+1,u-(l+1)).split(","),h=1;switch(c){case"rgba":if(4!==f.length)return null;h=a(f.pop());case"rgb":return 3!==f.length?null:[o(f[0]),o(f[1]),o(f[2]),h];case"hsla":if(4!==f.length)return null;h=a(f.pop());case"hsl":if(3!==f.length)return null;var d=(parseFloat(f[0])%360+360)%360/360,p=a(f[1]),m=a(f[2]),v=m<=.5?m*(p+1):m+p-m*p,g=2*m-v;return[n(255*s(g,v,d+1/3)),n(255*s(g,v,d)),n(255*s(g,v,d-1/3)),h];default:return null}}return null}}catch(t){}}));T.parseCSSColor;var D=b((function(t,e){Object.defineProperty(e,"__esModule",{value:!0});var r,n=function(t,e){if(Array.isArray(t))return t;if(Symbol.iterator in Object(t))return function(t,e){var r=[],n=!0,i=!1,o=void 0;try{for(var a,s=t[Symbol.iterator]();!(n=(a=s.next()).done)&&(r.push(a.value),!e||r.length!==e);n=!0);}catch(t){i=!0,o=t}finally{try{!n&&s.return&&s.return()}finally{if(i)throw o}}return r}(t,e);throw new TypeError("Invalid attempt to destructure non-iterable instance")},i=(r=T)&&r.__esModule?r:{default:r},o=i.default.parseCSSColor;function a(t){return(t=Math.round(t))<0?0:t>255?255:t}function s(t){return t<0?0:t>1?1:t}var l={isColor:function(t){if("string"==typeof t)return!!(0,i.default)(t);if(Array.isArray(t)){for(var e=0,r=t.length;e<r;){var n=t[e++];if("string"!=typeof n)return!1;if(!o(n))return!1}return!0}return!1},toColorIncrease:function(t){return[t[0]||0,t[1]||0,t[2]||0,t[3]||0]},toNormal:function(t){if(Array.isArray(t)){for(var e=[],r=0,n=t.length;r<n;){var i=t[r++];if("string"!=typeof i)return null;var a=o(i);if(!a)return null;e.push(a)}return e}return"string"==typeof t?o(t):null},toNormalArray:function(t){if(Array.isArray(t)){for(var e=[],r=0,n=t.length;r<n;){var i=t[r++];if("string"!=typeof i)return null;var a=o(i);if(!a)return null;e.push(a)}return e}return"string"==typeof t?[o(t)]:null},linearGradient:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:l.Utils.Linear,i=t.length-1,o=i*e,a=o>>0,s=r;return function(t,e,r){var i=n(t,4),o=i[0],a=i[1],l=i[2],u=i[3],c=n(e,4),f=c[0],h=c[1],d=c[2],p=c[3];return[s(o,f,r)>>0,s(a,h,r)>>0,s(l,d,r)>>0,s(u,p,r)]}(t[a],t[a+1>i?i:a+1],o-a)},mixColors:function(t,e){var r=this.toNormal(t);if(Array.isArray(e)&&r){var n=[a(r[0]+e[0]||0),a(r[1]+e[1]||0),a(r[2]+e[2]||0),s(r[3]+e[3]||0)];return"rgba("+[n[0],n[1],n[2],n[3]].join(",")+")"}return t},toRGBA:function(t){if(t&&t.length>=3){var e=void 0===t[3]?1:t[3];return"rgba("+a(t[0])+","+a(t[1])+","+a(t[2])+","+s(e)+")"}return"transparent"},Utils:{Linear:function(t,e,r){return(e-t)*r+t}}};e.default=l}));y(D),y(b((function(t,e){Object.defineProperty(e,"__esModule",{value:!0});var r=i(P),n=i(D);function i(t){return t&&t.__esModule?t:{default:t}}var o={type:"color",test:function(t,e){return n.default.isColor(t)},parse:function(t,e){return n.default.toNormalArray(t)},valueOf:function(t,e,r,i){var o=n.default.linearGradient(t,e);return n.default.toRGBA(o)}};r.default.registerPlugin(o),e.default=o})));var R=b((function(t,e){Object.defineProperty(e,"__esModule",{value:!0});var r="undefined"==typeof Float32Array?Array:Float32Array,n={create:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0,e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,n=new r(2);return n[0]=t,n[1]=e,n},copy:function(t,e){return t[0]=e[0],t[1]=e[1],t},clone:function(t){var e=new r(2);return e[0]=t[0],e[1]=t[1],e},set:function(t,e,r){return t[0]=e,t[1]=r,t},add:function(t,e,r){return t[0]=e[0]+r[0],t[1]=e[1]+r[1],t},scaleAndAdd:function(t,e,r,n){return t[0]=e[0]+r[0]*n,t[1]=e[1]+r[1]*n,t},sub:function(t,e,r){return t[0]=e[0]-r[0],t[1]=e[1]-r[1],t},length:function(t){return Math.sqrt(this.lengthSquare(t))},lengthSquare:function(t){return t[0]*t[0]+t[1]*t[1]},multiply:function(t,e,r){return t[0]=e[0]*r[0],t[1]=e[1]*r[1],t},divide:function(t,e,r){return t[0]=e[0]/r[0],t[1]=e[1]/r[1],t},dot:function(t,e){return t[0]*e[0]+t[1]*e[1]},scale:function(t,e,r){return t[0]=e[0]*r,t[1]=e[1]*r,t},normalize:function(t,e){var r=this.len(e);return 0===r?(t[0]=0,t[1]=0):(t[0]=e[0]/r,t[1]=e[1]/r),t},distance:function(t,e){return Math.sqrt(this.distanceSquare(t,e))},distanceSquare:function(t,e){return(t[0]-e[0])*(t[0]-e[0])+(t[1]-e[1])*(t[1]-e[1])},negate:function(t,e){return t[0]=-e[0],t[1]=-e[1],t},lerp:function(t,e,r,n){return t[0]=e[0]+n*(r[0]-e[0]),t[1]=e[1]+n*(r[1]-e[1]),t},applyTransform:function(t,e,r){var n=e[0],i=e[1];return t[0]=r[0]*n+r[2]*i+r[4],t[1]=r[1]*n+r[3]*i+r[5],t},min:function(t,e,r){return t[0]=Math.min(e[0],r[0]),t[1]=Math.min(e[1],r[1]),t},max:function(t,e,r){return t[0]=Math.max(e[0],r[0]),t[1]=Math.max(e[1],r[1]),t},getAngle:function(t,e){var r=0;return 0!=t[0]-e[0]&&(r=Math.atan2(t[1]-e[1],t[0]-e[0])),r}};n.len=n.length,n.lenSquare=n.lengthSquare,n.dist=n.distance,n.distSquare=n.distanceSquare,e.default=n}));y(R),y(b((function(t,e){Object.defineProperty(e,"__esModule",{value:!0});var r=function(t,e){if(Array.isArray(t))return t;if(Symbol.iterator in Object(t))return function(t,e){var r=[],n=!0,i=!1,o=void 0;try{for(var a,s=t[Symbol.iterator]();!(n=(a=s.next()).done)&&(r.push(a.value),!e||r.length!==e);n=!0);}catch(t){i=!0,o=t}finally{try{!n&&s.return&&s.return()}finally{if(i)throw o}}return r}(t,e);throw new TypeError("Invalid attempt to destructure non-iterable instance")},n=o(P),i=o(R);function o(t){return t&&t.__esModule?t:{default:t}}var a={type:"coordinate-2d",test:function(t,e){var n=!1;if(Array.isArray(t))for(var i=-1,o=t.length;++i<o;){var a=t[i];if(Array.isArray(a)){var s=r(a,2),l=s[0],u=s[1],c=[+l,+u];u=c[1],n="number"==typeof(l=c[0])&&"number"==typeof u&&isFinite(l)&&isFinite(u)}}return n},parse:function(t,e){for(var n=[],o=-1,a=t.length;++o<a;){var s=t[o],l=r(s,2),u=l[0],c=l[1],f=[+u,+c];u=f[0],c=f[1],n.push([u,c])}return function(t){for(var e=0,r=t.length,n=0,o=[],a=[],s=0;e<r-1;){var l=t[e],u=t[e+1],c=i.default.distance(l,u);n+=c,s=i.default.getAngle(u,l),o.push(l),a.push({length:n,segmentLength:c,segment:[l.slice(),u.slice()],path:o.slice(),angle:s}),e++}return a.sum=n,a}(n)},valueOf:function(t,e,n,o){for(var a=t.sum*e,s=-1,l=t.length,u=t[0];++s<l;){var c=t[s];if(a<=c.length){u=c;break}}var f=r(u.segment,2),h=f[0],d=f[1],p=(0==s?a:a-t[s-1].length)/u.segmentLength,m=i.default.create(),v=i.default.create();return i.default.sub(m,d,h),i.default.scaleAndAdd(v,h,m,p),v.step=u,v}};n.default.registerPlugin(a),e.default=a})));var I=b((function(t){var e=L.Animation,r=L.Clip;t.exports.default={Animation:e,Clip:r},t.exports.Animation=e,t.exports.Clip=r})),F=I.Animation,B=I.Clip;_.record("Base");var j=function(t){function e(e,r){var n=t.call(this)||this;return n.center=[0,0],n.zoom=10,n.pitch=0,n.rotation=0,n.zooms=[1,30],n.animate=new F,n.layers=[],n.buryPoint=_,n.inertiaFrameCount=60,n.frameFn=0,n.emptyFrame=!1,n.lowFrameRate=!1,n.remainingframeCount=n.inertiaFrameCount,n.timeline=performance.now(),n.container=document.getElementById(e),n.handler=new C(n),n.options=r,n.lowFrameRate=void 0===r.lowFrameRate?n.lowFrameRate:r.lowFrameRate,n.inertiaFrameCount=void 0===r.inertiaFrameCount?n.inertiaFrameCount:r.inertiaFrameCount,n.animate.addClip(new B({duration:1e4,repeat:1/0}),{x:[0,1]}),_.init(),n}return i(e,t),e.prototype.render=function(){var t=this;this.layers.sort((function(t,e){return t.zIndex-e.zIndex})),this.layers.forEach((function(e){e.visible&&e.opacity>0&&e.zooms[0]<t.zoom&&e.zooms[1]>t.zoom&&(e.beforeRender(),e.render(),e.afterRender())}))},e.prototype.setViewOptions=function(t){t&&(void 0!==t.zoom&&(this.zoom=Math.min(Math.max(this.zooms[0],t.zoom),this.zooms[1]),this.setZoom()),void 0!==t.center&&(this.setCenter(t.center),this.center=t.center),void 0!==t.pitch&&(this.pitch=Math.min(150,Math.max(t.pitch,0)),this.setPitch()),void 0!==t.rotation&&(this.setRotation(this.rotation-t.rotation),this.rotation=t.rotation)),this.requestRender(),this.emit("viewchange")},e.prototype.addLayer=function(t){!this.layers.some((function(e){return e.id===t.id}))&&(t.onAdd()||this.layers.push(t)),this.requestRender()},e.prototype.removeLayer=function(t){var e=this.layers.findIndex((function(e){return e.id===t.id}));if(e>-1){var r=this.layers.splice(e,1);r.length>=0&&(r[0].onRemove(),this.requestRender())}},e.prototype.requestRender=function(){var t=this;this.remainingframeCount=this.inertiaFrameCount;var e=function(){if(t.frameFn=requestAnimationFrame(e),t.emptyFrame=!t.emptyFrame,!t.lowFrameRate||!t.emptyFrame){if(t.remainingframeCount<=0)return cancelAnimationFrame(t.frameFn),void(t.frameFn=0);t.render(),t.remainingframeCount--}};this.remainingframeCount>0&&!this.frameFn&&e()},e.prototype.getTimeLine=function(){return{startTime:this.timeline,duration:performance.now()-this.timeline}},e.prototype.isLowFrame=function(){return this.lowFrameRate},e.Clip=B,e.Animation=F,e}(v);const{abs:V,cos:N,sin:U,acos:G,atan2:W,sqrt:q,pow:H}=Math;function Z(t){return t<0?-H(-t,1/3):H(t,1/3)}const Q=Math.PI,X=2*Q,Y=Q/2,J=Number.MAX_SAFE_INTEGER||9007199254740991,K=Number.MIN_SAFE_INTEGER||-9007199254740991,$={x:0,y:0,z:0},tt={Tvalues:[-.06405689286260563,.06405689286260563,-.1911188674736163,.1911188674736163,-.3150426796961634,.3150426796961634,-.4337935076260451,.4337935076260451,-.5454214713888396,.5454214713888396,-.6480936519369755,.6480936519369755,-.7401241915785544,.7401241915785544,-.820001985973903,.820001985973903,-.8864155270044011,.8864155270044011,-.9382745520027328,.9382745520027328,-.9747285559713095,.9747285559713095,-.9951872199970213,.9951872199970213],Cvalues:[.12793819534675216,.12793819534675216,.1258374563468283,.1258374563468283,.12167047292780339,.12167047292780339,.1155056680537256,.1155056680537256,.10744427011596563,.10744427011596563,.09761865210411388,.09761865210411388,.08619016153195327,.08619016153195327,.0733464814110803,.0733464814110803,.05929858491543678,.05929858491543678,.04427743881741981,.04427743881741981,.028531388628933663,.028531388628933663,.0123412297999872,.0123412297999872],arcfn:function(t,e){const r=e(t);let n=r.x*r.x+r.y*r.y;return void 0!==r.z&&(n+=r.z*r.z),q(n)},compute:function(t,e,r){if(0===t)return e[0].t=0,e[0];const n=e.length-1;if(1===t)return e[n].t=1,e[n];const i=1-t;let o=e;if(0===n)return e[0].t=t,e[0];if(1===n){const e={x:i*o[0].x+t*o[1].x,y:i*o[0].y+t*o[1].y,t:t};return r&&(e.z=i*o[0].z+t*o[1].z),e}if(n<4){let e,a,s,l=i*i,u=t*t,c=0;2===n?(o=[o[0],o[1],o[2],$],e=l,a=i*t*2,s=u):3===n&&(e=l*i,a=l*t*3,s=i*u*3,c=t*u);const f={x:e*o[0].x+a*o[1].x+s*o[2].x+c*o[3].x,y:e*o[0].y+a*o[1].y+s*o[2].y+c*o[3].y,t:t};return r&&(f.z=e*o[0].z+a*o[1].z+s*o[2].z+c*o[3].z),f}const a=JSON.parse(JSON.stringify(e));for(;a.length>1;){for(let e=0;e<a.length-1;e++)a[e]={x:a[e].x+(a[e+1].x-a[e].x)*t,y:a[e].y+(a[e+1].y-a[e].y)*t},void 0!==a[e].z&&(a[e]=a[e].z+(a[e+1].z-a[e].z)*t);a.splice(a.length-1,1)}return a[0].t=t,a[0]},computeWithRatios:function(t,e,r,n){const i=1-t,o=r,a=e;let s,l=o[0],u=o[1],c=o[2],f=o[3];return l*=i,u*=t,2===a.length?(s=l+u,{x:(l*a[0].x+u*a[1].x)/s,y:(l*a[0].y+u*a[1].y)/s,z:!!n&&(l*a[0].z+u*a[1].z)/s,t:t}):(l*=i,u*=2*i,c*=t*t,3===a.length?(s=l+u+c,{x:(l*a[0].x+u*a[1].x+c*a[2].x)/s,y:(l*a[0].y+u*a[1].y+c*a[2].y)/s,z:!!n&&(l*a[0].z+u*a[1].z+c*a[2].z)/s,t:t}):(l*=i,u*=1.5*i,c*=3*i,f*=t*t*t,4===a.length?(s=l+u+c+f,{x:(l*a[0].x+u*a[1].x+c*a[2].x+f*a[3].x)/s,y:(l*a[0].y+u*a[1].y+c*a[2].y+f*a[3].y)/s,z:!!n&&(l*a[0].z+u*a[1].z+c*a[2].z+f*a[3].z)/s,t:t}):void 0))},derive:function(t,e){const r=[];for(let n=t,i=n.length,o=i-1;i>1;i--,o--){const t=[];for(let r,i=0;i<o;i++)r={x:o*(n[i+1].x-n[i].x),y:o*(n[i+1].y-n[i].y)},e&&(r.z=o*(n[i+1].z-n[i].z)),t.push(r);r.push(t),n=t}return r},between:function(t,e,r){return e<=t&&t<=r||tt.approximately(t,e)||tt.approximately(t,r)},approximately:function(t,e,r){return V(t-e)<=(r||1e-6)},length:function(t){const e=tt.Tvalues.length;let r=0;for(let n,i=0;i<e;i++)n=.5*tt.Tvalues[i]+.5,r+=tt.Cvalues[i]*tt.arcfn(n,t);return.5*r},map:function(t,e,r,n,i){return n+(t-e)/(r-e)*(i-n)},lerp:function(t,e,r){const n={x:e.x+t*(r.x-e.x),y:e.y+t*(r.y-e.y)};return e.z&&r.z&&(n.z=e.z+t*(r.z-e.z)),n},pointToString:function(t){let e=t.x+"/"+t.y;return void 0!==t.z&&(e+="/"+t.z),e},pointsToString:function(t){return"["+t.map(tt.pointToString).join(", ")+"]"},copy:function(t){return JSON.parse(JSON.stringify(t))},angle:function(t,e,r){const n=e.x-t.x,i=e.y-t.y,o=r.x-t.x,a=r.y-t.y;return W(n*a-i*o,n*o+i*a)},round:function(t,e){const r=""+t,n=r.indexOf(".");return parseFloat(r.substring(0,n+1+e))},dist:function(t,e){const r=t.x-e.x,n=t.y-e.y;return q(r*r+n*n)},closest:function(t,e){let r,n,i=H(2,63);return t.forEach((function(t,o){n=tt.dist(e,t),n<i&&(i=n,r=o)})),{mdist:i,mpos:r}},abcratio:function(t,e){if(2!==e&&3!==e)return!1;if(void 0===t)t=.5;else if(0===t||1===t)return t;const r=H(t,e)+H(1-t,e);return V((r-1)/r)},projectionratio:function(t,e){if(2!==e&&3!==e)return!1;if(void 0===t)t=.5;else if(0===t||1===t)return t;const r=H(1-t,e);return r/(H(t,e)+r)},lli8:function(t,e,r,n,i,o,a,s){const l=(t-r)*(o-s)-(e-n)*(i-a);return 0!=l&&{x:((t*n-e*r)*(i-a)-(t-r)*(i*s-o*a))/l,y:((t*n-e*r)*(o-s)-(e-n)*(i*s-o*a))/l}},lli4:function(t,e,r,n){const i=t.x,o=t.y,a=e.x,s=e.y,l=r.x,u=r.y,c=n.x,f=n.y;return tt.lli8(i,o,a,s,l,u,c,f)},lli:function(t,e){return tt.lli4(t,t.c,e,e.c)},makeline:function(t,e){const r=t.x,n=t.y,i=e.x,o=e.y,a=(i-r)/3,s=(o-n)/3;return new ht(r,n,r+a,n+s,r+2*a,n+2*s,i,o)},findbbox:function(t){let e=J,r=J,n=K,i=K;return t.forEach((function(t){const o=t.bbox();e>o.x.min&&(e=o.x.min),r>o.y.min&&(r=o.y.min),n<o.x.max&&(n=o.x.max),i<o.y.max&&(i=o.y.max)})),{x:{min:e,mid:(e+n)/2,max:n,size:n-e},y:{min:r,mid:(r+i)/2,max:i,size:i-r}}},shapeintersections:function(t,e,r,n,i){if(!tt.bboxoverlap(e,n))return[];const o=[],a=[t.startcap,t.forward,t.back,t.endcap],s=[r.startcap,r.forward,r.back,r.endcap];return a.forEach((function(e){e.virtual||s.forEach((function(n){if(n.virtual)return;const a=e.intersects(n,i);a.length>0&&(a.c1=e,a.c2=n,a.s1=t,a.s2=r,o.push(a))}))})),o},makeshape:function(t,e,r){const n=e.points.length,i=t.points.length,o=tt.makeline(e.points[n-1],t.points[0]),a=tt.makeline(t.points[i-1],e.points[0]),s={startcap:o,forward:t,back:e,endcap:a,bbox:tt.findbbox([o,t,e,a]),intersections:function(t){return tt.shapeintersections(s,s.bbox,t,t.bbox,r)}};return s},getminmax:function(t,e,r){if(!r)return{min:0,max:0};let n,i,o=J,a=K;-1===r.indexOf(0)&&(r=[0].concat(r)),-1===r.indexOf(1)&&r.push(1);for(let s=0,l=r.length;s<l;s++)n=r[s],i=t.get(n),i[e]<o&&(o=i[e]),i[e]>a&&(a=i[e]);return{min:o,mid:(o+a)/2,max:a,size:a-o}},align:function(t,e){const r=e.p1.x,n=e.p1.y,i=-W(e.p2.y-n,e.p2.x-r);return t.map((function(t){return{x:(t.x-r)*N(i)-(t.y-n)*U(i),y:(t.x-r)*U(i)+(t.y-n)*N(i)}}))},roots:function(t,e){e=e||{p1:{x:0,y:0},p2:{x:1,y:0}};const r=t.length-1,n=tt.align(t,e),i=function(t){return 0<=t&&t<=1};if(2===r){const t=n[0].y,e=n[1].y,r=n[2].y,o=t-2*e+r;if(0!==o){const n=-q(e*e-t*r),a=-t+e;return[-(n+a)/o,-(-n+a)/o].filter(i)}return e!==r&&0===o?[(2*e-r)/(2*e-2*r)].filter(i):[]}const o=n[0].y,a=n[1].y,s=n[2].y;let l=3*a-o-3*s+n[3].y,u=3*o-6*a+3*s,c=-3*o+3*a,f=o;if(tt.approximately(l,0)){if(tt.approximately(u,0))return tt.approximately(c,0)?[]:[-f/c].filter(i);const t=q(c*c-4*u*f),e=2*u;return[(t-c)/e,(-c-t)/e].filter(i)}u/=l,c/=l,f/=l;const h=(3*c-u*u)/3,d=h/3,p=(2*u*u*u-9*u*c+27*f)/27,m=p/2,v=m*m+d*d*d;let g,y,b,x,_;if(v<0){const t=-h/3,e=q(t*t*t),r=-p/(2*e),n=G(r<-1?-1:r>1?1:r),o=2*Z(e);return b=o*N(n/3)-u/3,x=o*N((n+X)/3)-u/3,_=o*N((n+2*X)/3)-u/3,[b,x,_].filter(i)}if(0===v)return g=m<0?Z(-m):-Z(m),b=2*g-u/3,x=-g-u/3,[b,x].filter(i);{const t=q(v);return g=Z(-m+t),y=Z(m+t),[g-y-u/3].filter(i)}},droots:function(t){if(3===t.length){const e=t[0],r=t[1],n=t[2],i=e-2*r+n;if(0!==i){const t=-q(r*r-e*n),o=-e+r;return[-(t+o)/i,-(-t+o)/i]}return r!==n&&0===i?[(2*r-n)/(2*(r-n))]:[]}if(2===t.length){const e=t[0],r=t[1];return e!==r?[e/(e-r)]:[]}return[]},curvature:function(t,e,r,n,i){let o,a,s,l,u=0,c=0;const f=tt.compute(t,e),h=tt.compute(t,r),d=f.x*f.x+f.y*f.y;if(n?(o=q(H(f.y*h.z-h.y*f.z,2)+H(f.z*h.x-h.z*f.x,2)+H(f.x*h.y-h.x*f.y,2)),a=H(d+f.z*f.z,1.5)):(o=f.x*h.y-f.y*h.x,a=H(d,1.5)),0===o||0===a)return{k:0,r:0};if(u=o/a,c=a/o,!i){const i=tt.curvature(t-.001,e,r,n,!0).k,o=tt.curvature(t+.001,e,r,n,!0).k;l=(o-u+(u-i))/2,s=(V(o-u)+V(u-i))/2}return{k:u,r:c,dk:l,adk:s}},inflections:function(t){if(t.length<4)return[];const e=tt.align(t,{p1:t[0],p2:t.slice(-1)[0]}),r=e[2].x*e[1].y,n=e[3].x*e[1].y,i=e[1].x*e[2].y,o=18*(-3*r+2*n+3*i-e[3].x*e[2].y),a=18*(3*r-n-3*i),s=18*(i-r);if(tt.approximately(o,0)){if(!tt.approximately(a,0)){let t=-s/a;if(0<=t&&t<=1)return[t]}return[]}const l=a*a-4*o*s,u=Math.sqrt(l),c=2*o;return tt.approximately(c,0)?[]:[(u-a)/c,-(a+u)/c].filter((function(t){return 0<=t&&t<=1}))},bboxoverlap:function(t,e){const r=["x","y"],n=r.length;for(let i,o,a,s,l=0;l<n;l++)if(i=r[l],o=t[i].mid,a=e[i].mid,s=(t[i].size+e[i].size)/2,V(o-a)>=s)return!1;return!0},expandbox:function(t,e){e.x.min<t.x.min&&(t.x.min=e.x.min),e.y.min<t.y.min&&(t.y.min=e.y.min),e.z&&e.z.min<t.z.min&&(t.z.min=e.z.min),e.x.max>t.x.max&&(t.x.max=e.x.max),e.y.max>t.y.max&&(t.y.max=e.y.max),e.z&&e.z.max>t.z.max&&(t.z.max=e.z.max),t.x.mid=(t.x.min+t.x.max)/2,t.y.mid=(t.y.min+t.y.max)/2,t.z&&(t.z.mid=(t.z.min+t.z.max)/2),t.x.size=t.x.max-t.x.min,t.y.size=t.y.max-t.y.min,t.z&&(t.z.size=t.z.max-t.z.min)},pairiteration:function(t,e,r){const n=t.bbox(),i=e.bbox(),o=1e5,a=r||.5;if(n.x.size+n.y.size<a&&i.x.size+i.y.size<a)return[(o*(t._t1+t._t2)/2|0)/o+"/"+(o*(e._t1+e._t2)/2|0)/o];let s=t.split(.5),l=e.split(.5),u=[{left:s.left,right:l.left},{left:s.left,right:l.right},{left:s.right,right:l.right},{left:s.right,right:l.left}];u=u.filter((function(t){return tt.bboxoverlap(t.left.bbox(),t.right.bbox())}));let c=[];return 0===u.length||(u.forEach((function(t){c=c.concat(tt.pairiteration(t.left,t.right,a))})),c=c.filter((function(t,e){return c.indexOf(t)===e}))),c},getccenter:function(t,e,r){const n=e.x-t.x,i=e.y-t.y,o=r.x-e.x,a=r.y-e.y,s=n*N(Y)-i*U(Y),l=n*U(Y)+i*N(Y),u=o*N(Y)-a*U(Y),c=o*U(Y)+a*N(Y),f=(t.x+e.x)/2,h=(t.y+e.y)/2,d=(e.x+r.x)/2,p=(e.y+r.y)/2,m=f+s,v=h+l,g=d+u,y=p+c,b=tt.lli8(f,h,m,v,d,p,g,y),x=tt.dist(b,t);let _,w=W(t.y-b.y,t.x-b.x),C=W(e.y-b.y,e.x-b.x),S=W(r.y-b.y,r.x-b.x);return w<S?((w>C||C>S)&&(w+=X),w>S&&(_=S,S=w,w=_)):S<C&&C<w?(_=S,S=w,w=_):S+=X,b.s=w,b.e=S,b.r=x,b},numberSort:function(t,e){return t-e}};class et{constructor(t){this.curves=[],this._3d=!1,t&&(this.curves=t,this._3d=this.curves[0]._3d)}valueOf(){return this.toString()}toString(){return"["+this.curves.map((function(t){return tt.pointsToString(t.points)})).join(", ")+"]"}addCurve(t){this.curves.push(t),this._3d=this._3d||t._3d}length(){return this.curves.map((function(t){return t.length()})).reduce((function(t,e){return t+e}))}curve(t){return this.curves[t]}bbox(){const t=this.curves;for(var e=t[0].bbox(),r=1;r<t.length;r++)tt.expandbox(e,t[r].bbox());return e}offset(t){const e=[];return this.curves.forEach((function(r){e.push(...r.offset(t))})),new et(e)}}let rt={x:!1,y:!1};function nt(t,e,r){if("Z"===e)return;if("M"===e)return void(rt={x:r[0],y:r[1]});const n=new t(rt.x,rt.y,...r),i=r.slice(-2);return rt={x:i[0],y:i[1]},n}const{abs:it,min:ot,max:at,cos:st,sin:lt,acos:ut,sqrt:ct}=Math,ft=Math.PI;class ht{constructor(t){let e=t&&t.forEach?t:Array.from(arguments).slice(),r=!1;if("object"==typeof e[0]){r=e.length;const t=[];e.forEach((function(e){["x","y","z"].forEach((function(r){void 0!==e[r]&&t.push(e[r])}))})),e=t}let n=!1;const i=e.length;if(r){if(r>4){if(1!==arguments.length)throw new Error("Only new Bezier(point[]) is accepted for 4th and higher order curves");n=!0}}else if(6!==i&&8!==i&&9!==i&&12!==i&&1!==arguments.length)throw new Error("Only new Bezier(point[]) is accepted for 4th and higher order curves");const o=this._3d=!n&&(9===i||12===i)||t&&t[0]&&void 0!==t[0].z,a=this.points=[];for(let t=0,r=o?3:2;t<i;t+=r){var s={x:e[t],y:e[t+1]};o&&(s.z=e[t+2]),a.push(s)}const l=this.order=a.length-1,u=this.dims=["x","y"];o&&u.push("z"),this.dimlen=u.length;const c=tt.align(a,{p1:a[0],p2:a[l]});this._linear=!c.some((t=>it(t.y)>1e-4)),this._lut=[],this._t1=0,this._t2=1,this.update()}static SVGtoBeziers(t){return function(t,e){const r=function(t){const e=(t=t.replace(/,/g," ").replace(/-/g," - ").replace(/-\s+/g,"-").replace(/([a-zA-Z])/g," $1 ")).replace(/([a-zA-Z])\s?/g,"|$1").split("|"),r=e.length;let n,i,o,a,s,l,u=[],c=0,f=0,h=0,d=0,p=0,m=0,v=0,g=0,y=0,b=0,x=0,_=0,w=0,C="";for(n=1;n<r;n++)if(i=e[n],o=i.substring(0,1),a=o.toLowerCase(),u=i.replace(o,"").trim().split(" "),u=u.filter((function(t){return""!==t})).map(parseFloat),s=u.length,"m"===a){if(C+="M ","m"===o?(h+=u[0],d+=u[1]):(h=u[0],d=u[1]),c=h,f=d,C+=h+" "+d+" ",s>2)for(l=0;l<s;l+=2)"m"===o?(h+=u[l],d+=u[l+1]):(h=u[l],d=u[l+1]),C+="L "+h+" "+d+" "}else if("l"===a)for(l=0;l<s;l+=2)"l"===o?(h+=u[l],d+=u[l+1]):(h=u[l],d=u[l+1]),C+="L "+h+" "+d+" ";else if("h"===a)for(l=0;l<s;l++)"h"===o?h+=u[l]:h=u[l],C+="L "+h+" "+d+" ";else if("v"===a)for(l=0;l<s;l++)"v"===o?d+=u[l]:d=u[l],C+="L "+h+" "+d+" ";else if("q"===a)for(l=0;l<s;l+=4)"q"===o?(p=h+u[l],m=d+u[l+1],h+=u[l+2],d+=u[l+3]):(p=u[l],m=u[l+1],h=u[l+2],d=u[l+3]),C+="Q "+p+" "+m+" "+h+" "+d+" ";else if("t"===a)for(l=0;l<s;l+=2)p=h+(h-p),m=d+(d-m),"t"===o?(h+=u[l],d+=u[l+1]):(h=u[l],d=u[l+1]),C+="Q "+p+" "+m+" "+h+" "+d+" ";else if("c"===a)for(l=0;l<s;l+=6)"c"===o?(p=h+u[l],m=d+u[l+1],v=h+u[l+2],g=d+u[l+3],h+=u[l+4],d+=u[l+5]):(p=u[l],m=u[l+1],v=u[l+2],g=u[l+3],h=u[l+4],d=u[l+5]),C+="C "+p+" "+m+" "+v+" "+g+" "+h+" "+d+" ";else if("s"===a)for(l=0;l<s;l+=4)p=h+(h-v),m=d+(d-g),"s"===o?(v=h+u[l],g=d+u[l+1],h+=u[l+2],d+=u[l+3]):(v=u[l],g=u[l+1],h=u[l+2],d=u[l+3]),C+="C "+p+" "+m+" "+v+" "+g+" "+h+" "+d+" ";else if("a"===a)for(l=0;l<s;l+=7)y=u[l],b=u[l+1],x=u[l+2],_=u[l+3],w=u[l+4],"a"===o?(h+=u[l+5],d+=u[l+6]):(h=u[l+5],d=u[l+6]),C+="A "+y+" "+b+" "+x+" "+_+" "+w+" "+h+" "+d+" ";else"z"===a&&(C+="Z ",h=c,d=f);return C.trim()}(e).split(" "),n=new RegExp("[MLCQZ]","");let i,o,a,s=[],l={C:6,Q:4,L:2,M:2};for(;r.length;)i=r.splice(0,1)[0],n.test(i)&&(a=r.splice(0,l[i]).map(parseFloat),o=nt(t,i,a),o&&s.push(o));return new t.PolyBezier(s)}(ht,t)}static quadraticFromPoints(t,e,r,n){if(void 0===n&&(n=.5),0===n)return new ht(e,e,r);if(1===n)return new ht(t,e,e);const i=ht.getABC(2,t,e,r,n);return new ht(t,i.A,r)}static cubicFromPoints(t,e,r,n,i){void 0===n&&(n=.5);const o=ht.getABC(3,t,e,r,n);void 0===i&&(i=tt.dist(e,o.C));const a=i*(1-n)/n,s=tt.dist(t,r),l=(r.x-t.x)/s,u=(r.y-t.y)/s,c=i*l,f=i*u,h=a*l,d=a*u,p=e.x-c,m=e.y-f,v=e.x+h,g=e.y+d,y=o.A,b=y.x+(p-y.x)/(1-n),x=y.y+(m-y.y)/(1-n),_=y.x+(v-y.x)/n,w=y.y+(g-y.y)/n,C={x:t.x+(b-t.x)/n,y:t.y+(x-t.y)/n},S={x:r.x+(_-r.x)/(1-n),y:r.y+(w-r.y)/(1-n)};return new ht(t,C,S,r)}static getUtils(){return tt}getUtils(){return ht.getUtils()}static get PolyBezier(){return et}valueOf(){return this.toString()}toString(){return tt.pointsToString(this.points)}toSVG(){if(this._3d)return!1;const t=this.points,e=["M",t[0].x,t[0].y,2===this.order?"Q":"C"];for(let r=1,n=t.length;r<n;r++)e.push(t[r].x),e.push(t[r].y);return e.join(" ")}setRatios(t){if(t.length!==this.points.length)throw new Error("incorrect number of ratio values");this.ratios=t,this._lut=[]}verify(){const t=this.coordDigest();t!==this._print&&(this._print=t,this.update())}coordDigest(){return this.points.map((function(t,e){return""+e+t.x+t.y+(t.z?t.z:0)})).join("")}update(){this._lut=[],this.dpoints=tt.derive(this.points,this._3d),this.computedirection()}computedirection(){const t=this.points,e=tt.angle(t[0],t[this.order],t[1]);this.clockwise=e>0}length(){return tt.length(this.derivative.bind(this))}static getABC(t=2,e,r,n,i=.5){const o=tt.projectionratio(i,t),a=1-o,s={x:o*e.x+a*n.x,y:o*e.y+a*n.y},l=tt.abcratio(i,t);return{A:{x:r.x+(r.x-s.x)/l,y:r.y+(r.y-s.y)/l},B:r,C:s,S:e,E:n}}getABC(t,e){e=e||this.get(t);let r=this.points[0],n=this.points[this.order];return ht.getABC(this.order,r,e,n,t)}getLUT(t){if(this.verify(),t=t||100,this._lut.length===t)return this._lut;this._lut=[],t--;for(let e,r,n=0;n<t;n++)r=n/(t-1),e=this.compute(r),e.t=r,this._lut.push(e);return this._lut}on(e,r){r=r||5;const n=this.getLUT(),i=[];for(let t,o=0,a=0;o<n.length;o++)t=n[o],tt.dist(t,e)<r&&(i.push(t),a+=o/n.length);return!!i.length&&(t/=i.length)}project(t){const e=this.getLUT(),r=e.length-1,n=tt.closest(e,t),i=n.mpos,o=(i-1)/r,a=(i+1)/r,s=.1/r;let l,u,c=n.mdist,f=o,h=f;for(c+=1;f<a+s;f+=s)l=this.compute(f),u=tt.dist(t,l),u<c&&(c=u,h=f);return h=h<0?0:h>1?1:h,l=this.compute(h),l.t=h,l.d=c,l}get(t){return this.compute(t)}point(t){return this.points[t]}compute(t){return this.ratios?tt.computeWithRatios(t,this.points,this.ratios,this._3d):tt.compute(t,this.points,this._3d,this.ratios)}raise(){const t=this.points,e=[t[0]],r=t.length;for(let n,i,o=1;o<r;o++)n=t[o],i=t[o-1],e[o]={x:(r-o)/r*n.x+o/r*i.x,y:(r-o)/r*n.y+o/r*i.y};return e[r]=t[r-1],new ht(e)}derivative(t){return tt.compute(t,this.dpoints[0])}dderivative(t){return tt.compute(t,this.dpoints[1])}align(){let t=this.points;return new ht(tt.align(t,{p1:t[0],p2:t[t.length-1]}))}curvature(t){return tt.curvature(t,this.dpoints[0],this.dpoints[1],this._3d)}inflections(){return tt.inflections(this.points)}normal(t){return this._3d?this.__normal3(t):this.__normal2(t)}__normal2(t){const e=this.derivative(t),r=ct(e.x*e.x+e.y*e.y);return{x:-e.y/r,y:e.x/r}}__normal3(t){const e=this.derivative(t),r=this.derivative(t+.01),n=ct(e.x*e.x+e.y*e.y+e.z*e.z),i=ct(r.x*r.x+r.y*r.y+r.z*r.z);e.x/=n,e.y/=n,e.z/=n,r.x/=i,r.y/=i,r.z/=i;const o={x:r.y*e.z-r.z*e.y,y:r.z*e.x-r.x*e.z,z:r.x*e.y-r.y*e.x},a=ct(o.x*o.x+o.y*o.y+o.z*o.z);o.x/=a,o.y/=a,o.z/=a;const s=[o.x*o.x,o.x*o.y-o.z,o.x*o.z+o.y,o.x*o.y+o.z,o.y*o.y,o.y*o.z-o.x,o.x*o.z-o.y,o.y*o.z+o.x,o.z*o.z];return{x:s[0]*e.x+s[1]*e.y+s[2]*e.z,y:s[3]*e.x+s[4]*e.y+s[5]*e.z,z:s[6]*e.x+s[7]*e.y+s[8]*e.z}}hull(t){let e=this.points,r=[],n=[],i=0;for(n[i++]=e[0],n[i++]=e[1],n[i++]=e[2],3===this.order&&(n[i++]=e[3]);e.length>1;){r=[];for(let o,a=0,s=e.length-1;a<s;a++)o=tt.lerp(t,e[a],e[a+1]),n[i++]=o,r.push(o);e=r}return n}split(t,e){if(0===t&&e)return this.split(e).left;if(1===e)return this.split(t).right;const r=this.hull(t),n={left:2===this.order?new ht([r[0],r[3],r[5]]):new ht([r[0],r[4],r[7],r[9]]),right:2===this.order?new ht([r[5],r[4],r[2]]):new ht([r[9],r[8],r[6],r[3]]),span:r};return n.left._t1=tt.map(0,0,1,this._t1,this._t2),n.left._t2=tt.map(t,0,1,this._t1,this._t2),n.right._t1=tt.map(t,0,1,this._t1,this._t2),n.right._t2=tt.map(1,0,1,this._t1,this._t2),e?(e=tt.map(e,t,1,0,1),n.right.split(e).left):n}extrema(){const t={};let e=[];return this.dims.forEach(function(r){let n=function(t){return t[r]},i=this.dpoints[0].map(n);t[r]=tt.droots(i),3===this.order&&(i=this.dpoints[1].map(n),t[r]=t[r].concat(tt.droots(i))),t[r]=t[r].filter((function(t){return t>=0&&t<=1})),e=e.concat(t[r].sort(tt.numberSort))}.bind(this)),t.values=e.sort(tt.numberSort).filter((function(t,r){return e.indexOf(t)===r})),t}bbox(){const t=this.extrema(),e={};return this.dims.forEach(function(r){e[r]=tt.getminmax(this,r,t[r])}.bind(this)),e}overlaps(t){const e=this.bbox(),r=t.bbox();return tt.bboxoverlap(e,r)}offset(t,e){if(void 0!==e){const r=this.get(t),n=this.normal(t),i={c:r,n:n,x:r.x+n.x*e,y:r.y+n.y*e};return this._3d&&(i.z=r.z+n.z*e),i}if(this._linear){const e=this.normal(0),r=this.points.map((function(r){const n={x:r.x+t*e.x,y:r.y+t*e.y};return r.z&&e.z&&(n.z=r.z+t*e.z),n}));return[new ht(r)]}return this.reduce().map((function(e){return e._linear?e.offset(t)[0]:e.scale(t)}))}simple(){if(3===this.order){const t=tt.angle(this.points[0],this.points[3],this.points[1]),e=tt.angle(this.points[0],this.points[3],this.points[2]);if(t>0&&e<0||t<0&&e>0)return!1}const t=this.normal(0),e=this.normal(1);let r=t.x*e.x+t.y*e.y;return this._3d&&(r+=t.z*e.z),it(ut(r))<ft/3}reduce(){let t,e,r=0,n=0,i=.01,o=[],a=[],s=this.extrema().values;for(-1===s.indexOf(0)&&(s=[0].concat(s)),-1===s.indexOf(1)&&s.push(1),r=s[0],t=1;t<s.length;t++)n=s[t],e=this.split(r,n),e._t1=r,e._t2=n,o.push(e),r=n;return o.forEach((function(t){for(r=0,n=0;n<=1;)for(n=r+i;n<=1.01;n+=i)if(e=t.split(r,n),!e.simple()){if(n-=i,it(r-n)<i)return[];e=t.split(r,n),e._t1=tt.map(r,0,1,t._t1,t._t2),e._t2=tt.map(n,0,1,t._t1,t._t2),a.push(e),r=n;break}r<1&&(e=t.split(r,1),e._t1=tt.map(r,0,1,t._t1,t._t2),e._t2=t._t2,a.push(e))})),a}scale(t){const e=this.order;let r=!1;if("function"==typeof t&&(r=t),r&&2===e)return this.raise().scale(r);const n=this.clockwise,i=r?r(0):t,o=r?r(1):t,a=[this.offset(0,10),this.offset(1,10)],s=this.points,l=[],u=tt.lli4(a[0],a[0].c,a[1],a[1].c);if(!u)throw new Error("cannot scale this curve. Try reducing it first.");return[0,1].forEach((function(t){const r=l[t*e]=tt.copy(s[t*e]);r.x+=(t?o:i)*a[t].n.x,r.y+=(t?o:i)*a[t].n.y})),r?([0,1].forEach((function(i){if(2!==e||!i){var o=s[i+1],a={x:o.x-u.x,y:o.y-u.y},c=r?r((i+1)/e):t;r&&!n&&(c=-c);var f=ct(a.x*a.x+a.y*a.y);a.x/=f,a.y/=f,l[i+1]={x:o.x+c*a.x,y:o.y+c*a.y}}})),new ht(l)):([0,1].forEach((t=>{if(2===e&&t)return;const r=l[t*e],n=this.derivative(t),i={x:r.x+n.x,y:r.y+n.y};l[t+1]=tt.lli4(r,i,u,s[t+1])})),new ht(l))}outline(t,e,r,n){e=void 0===e?t:e;const i=this.reduce(),o=i.length,a=[];let s,l=[],u=0,c=this.length();const f=void 0!==r&&void 0!==n;function h(t,e,r,n,i){return function(o){const a=n/r,s=(n+i)/r,l=e-t;return tt.map(o,0,1,t+a*l,t+s*l)}}i.forEach((function(i){const o=i.length();f?(a.push(i.scale(h(t,r,c,u,o))),l.push(i.scale(h(-e,-n,c,u,o)))):(a.push(i.scale(t)),l.push(i.scale(-e))),u+=o})),l=l.map((function(t){return s=t.points,s[3]?t.points=[s[3],s[2],s[1],s[0]]:t.points=[s[2],s[1],s[0]],t})).reverse();const d=a[0].points[0],p=a[o-1].points[a[o-1].points.length-1],m=l[o-1].points[l[o-1].points.length-1],v=l[0].points[0],g=tt.makeline(m,d),y=tt.makeline(p,v),b=[g].concat(a).concat([y]).concat(l);return new et(b)}outlineshapes(t,e,r){e=e||t;const n=this.outline(t,e).curves,i=[];for(let t=1,e=n.length;t<e/2;t++){const o=tt.makeshape(n[t],n[e-t],r);o.startcap.virtual=t>1,o.endcap.virtual=t<e/2-1,i.push(o)}return i}intersects(t,e){return t?t.p1&&t.p2?this.lineIntersects(t):(t instanceof ht&&(t=t.reduce()),this.curveintersects(this.reduce(),t,e)):this.selfintersects(e)}lineIntersects(t){const e=ot(t.p1.x,t.p2.x),r=ot(t.p1.y,t.p2.y),n=at(t.p1.x,t.p2.x),i=at(t.p1.y,t.p2.y);return tt.roots(this.points,t).filter((t=>{var o=this.get(t);return tt.between(o.x,e,n)&&tt.between(o.y,r,i)}))}selfintersects(t){const e=this.reduce(),r=e.length-2,n=[];for(let i,o,a,s=0;s<r;s++)o=e.slice(s,s+1),a=e.slice(s+2),i=this.curveintersects(o,a,t),n.push(...i);return n}curveintersects(t,e,r){const n=[];t.forEach((function(t){e.forEach((function(e){t.overlaps(e)&&n.push({left:t,right:e})}))}));let i=[];return n.forEach((function(t){const e=tt.pairiteration(t.left,t.right,r);e.length>0&&(i=i.concat(e))})),i}arcs(t){return t=t||.5,this._iterate(t,[])}_error(t,e,r,n){const i=(n-r)/4,o=this.get(r+i),a=this.get(n-i),s=tt.dist(t,e),l=tt.dist(t,o),u=tt.dist(t,a);return it(l-s)+it(u-s)}_iterate(t,e){let r,n=0,i=1;do{r=0,i=1;let o,a,s,l,u,c=this.get(n),f=!1,h=!1,d=i,p=1;do{if(h=f,l=s,d=(n+i)/2,o=this.get(d),a=this.get(i),s=tt.getccenter(c,o,a),s.interval={start:n,end:i},f=this._error(s,c,n,i)<=t,u=h&&!f,u||(p=i),f){if(i>=1){if(s.interval.end=p=1,l=s,i>1){let t={x:s.x+s.r*st(s.e),y:s.y+s.r*lt(s.e)};s.e+=tt.angle({x:s.x,y:s.y},t,this.get(1))}break}i+=(i-n)/2}else i=d}while(!u&&r++<100);if(r>=100)break;l=l||s,e.push(l),n=p}while(i<1);return e}}var dt="function"==typeof Float32Array;function pt(t,e){return 1-3*e+3*t}function mt(t,e){return 3*e-6*t}function vt(t){return 3*t}function gt(t,e,r){return((pt(e,r)*t+mt(e,r))*t+vt(e))*t}function yt(t,e,r){return 3*pt(e,r)*t*t+2*mt(e,r)*t+vt(e)}function bt(t){return t}var xt=function(t,e,r,n){if(!(0<=t&&t<=1&&0<=r&&r<=1))throw new Error("bezier x values must be in [0, 1] range");if(t===e&&r===n)return bt;for(var i=dt?new Float32Array(11):new Array(11),o=0;o<11;++o)i[o]=gt(.1*o,t,r);function a(e){for(var n=0,o=1;10!==o&&i[o]<=e;++o)n+=.1;--o;var a=n+(e-i[o])/(i[o+1]-i[o])*.1,s=yt(a,t,r);return s>=.001?function(t,e,r,n){for(var i=0;i<4;++i){var o=yt(e,r,n);if(0===o)return e;e-=(gt(e,r,n)-t)/o}return e}(e,a,t,r):0===s?a:function(t,e,r,n,i){var o,a,s=0;do{(o=gt(a=e+(r-e)/2,n,i)-t)>0?r=a:e=a}while(Math.abs(o)>1e-7&&++s<10);return a}(e,n,n+.1,t,r)}return function(t){return 0===t?0:1===t?1:gt(a(t),e,n)}},_t=Object.freeze({__proto__:null,default:xt,__moduleExports:xt}),wt=function(){function t(t){var e=this;this.frameFn=0,this.animateConfigs=[],this.animateStatus="start",this.originConfig=[],this.map=t,this.map.animate.on("update",(function(){e.updateAnimates(),e.updateTrackAnimates()})),_.record("ViewControl")}return t.prototype.addAnimates=function(t,e){_.record("ViewControl","addAnimates");var r,n=t[0];t.length>1?r=this.addAnimates.bind(this,t.slice(1),e):1===t.length&&(r=e),this.setCustomStatusByMuli(n,r)},t.prototype.removeAnimate=function(t){_.record("ViewControl","removeAnimate");var e=this.animateConfigs.findIndex((function(e){return e===t}));return this.animateConfigs.splice(e,1)},t.prototype.removeAnimateByIndex=function(t){return _.record("ViewControl","removeAnimateByIndex"),this.animateConfigs.splice(t,1),this.animateConfigs},t.prototype.getAnimates=function(){return this.animateConfigs},t.prototype.clearAnimates=function(){_.record("ViewControl","clearAnimates"),this.animateConfigs=[],this.cancelAnimate()},t.prototype.getStatus=function(){return{zoom:this.map.getZoom(),center:this.map.getCenter(),pitch:this.map.getPitch(),rotation:this.map.getRotation()}},t.prototype.setStatus=function(t){var e=t.zoom,r=t.center,n=t.pitch,i=t.rotation;e&&this.map.setZoom(e),r&&this.map.setCenter(r),void 0!==n&&this.map.setPitch(n),void 0!==i&&this.map.setRotation(i)},t.prototype.setCustomStatusByMuli=function(t,e){var r,n,i=this.getStatus(),o=i.zoom,a=i.pitch,s=i.center,l=i.rotation,u=Object.keys(t),c=-1;for(var f in u.forEach((function(e){c<t[e].duration&&(c=t[e].duration,n=e)})),t){var h=t[f],d=h.value,p=h.control,m=h.duration,v=h.timing,g=(r=_t).default.apply(r,v),y="zoom"===f?o:"pitch"===f?a:"rotation"===f?l:s,b={type:f,bezier:"center"===f&&s?new ht({x:s[0],y:s[1]},{x:p[0][0],y:p[0][1]},{x:p[1][0],y:p[1][1]},{x:d[0],y:d[1]}):new ht({x:0,y:y},{x:p[0][0],y:p[0][1]},{x:p[1][0],y:p[1][1]},{x:1,y:d}),timing:g,duration:m,startTime:0,finish:n===f?e:void 0};this.addAnimateConfig(b)}},t.prototype.addAnimateConfig=function(t){t.startTime=Date.now(),this.animateConfigs.push(t)},t.prototype.pauseAnimate=function(){this.animateStatus="pause"},t.prototype.startAnimate=function(){this.animateStatus="start"},t.prototype.cancelAnimate=function(){this.animateStatus="stop",cancelAnimationFrame(this.frameFn),this.frameFn=0,this.animateConfigs=[]},t.prototype.updateAnimates=function(){if("start"===this.animateStatus){for(var t=[],e=Date.now(),r=0;r<this.animateConfigs.length;r++){var n=this.animateConfigs[r],i=n.timing,o=n.bezier,a=n.startTime,s=n.duration,l=n.type,u=n.finish,c=e-a;c>s?(n.isFinished=!0,u&&u(n)):t.push(n);var f=Math.min(1,i(c/s)),h=o.get(f);switch(l){case"zoom":this.setStatus({zoom:h.y});break;case"pitch":this.setStatus({pitch:h.y});break;case"rotation":this.setStatus({rotation:h.y});break;case"center":this.setStatus({center:[h.x,h.y]})}}this.animateConfigs=t}},t.prototype.updateTrackAnimates=function(){},t}(),Ct=function(){function t(t){this.layers=[],this.status="unload",this.dataset=[],this.options=t,this.id=h.CommonUtil.getGuid()}return t.prototype.onLoaded=function(){this.status="loaded";for(var t=0;t<this.layers.length;t++)this.layers[t].receiveDataset(this.dataset)},t.prototype.addLayer=function(t){this.layers.some((function(e){return e.id===t.id}))||(this.layers.push(t),t.receiveDataset(this.dataset))},t.prototype.removeLayer=function(t){var e=this.layers.findIndex((function(e){return e.id===t.id}));e>-1&&this.layers.splice(e,1)},t}(),St=At,kt=At;function At(t,e,r){r=r||2;var n,i,o,a,s,l,u,c=e&&e.length,f=c?e[0]*r:t.length,h=Mt(t,0,f,r,!0),d=[];if(!h||h.next===h.prev)return d;if(c&&(h=function(t,e,r,n){var i,o,a,s=[];for(i=0,o=e.length;i<o;i++)(a=Mt(t,e[i]*n,i<o-1?e[i+1]*n:t.length,n,!1))===a.next&&(a.steiner=!0),s.push(Bt(a));for(s.sort(Dt),i=0;i<s.length;i++)Rt(s[i],r),r=zt(r,r.next);return r}(t,e,h,r)),t.length>80*r){n=o=t[0],i=a=t[1];for(var p=r;p<f;p+=r)(s=t[p])<n&&(n=s),(l=t[p+1])<i&&(i=l),s>o&&(o=s),l>a&&(a=l);u=0!==(u=Math.max(o-n,a-i))?1/u:0}return Ot(h,d,r,n,i,u),d}function Mt(t,e,r,n,i){var o,a;if(i===Jt(t,e,r,n)>0)for(o=e;o<r;o+=n)a=Qt(o,t[o],t[o+1],a);else for(o=r-n;o>=e;o-=n)a=Qt(o,t[o],t[o+1],a);return a&&Ut(a,a.next)&&(Xt(a),a=a.next),a}function zt(t,e){if(!t)return t;e||(e=t);var r,n=t;do{if(r=!1,n.steiner||!Ut(n,n.next)&&0!==Nt(n.prev,n,n.next))n=n.next;else{if(Xt(n),(n=e=n.prev)===n.next)break;r=!0}}while(r||n!==e);return e}function Ot(t,e,r,n,i,o,a){if(t){!a&&o&&function(t,e,r,n){var i=t;do{null===i.z&&(i.z=Ft(i.x,i.y,e,r,n)),i.prevZ=i.prev,i.nextZ=i.next,i=i.next}while(i!==t);i.prevZ.nextZ=null,i.prevZ=null,function(t){var e,r,n,i,o,a,s,l,u=1;do{for(r=t,t=null,o=null,a=0;r;){for(a++,n=r,s=0,e=0;e<u&&(s++,n=n.nextZ);e++);for(l=u;s>0||l>0&&n;)0!==s&&(0===l||!n||r.z<=n.z)?(i=r,r=r.nextZ,s--):(i=n,n=n.nextZ,l--),o?o.nextZ=i:t=i,i.prevZ=o,o=i;r=n}o.nextZ=null,u*=2}while(a>1)}(i)}(t,n,i,o);for(var s,l,u=t;t.prev!==t.next;)if(s=t.prev,l=t.next,o?Pt(t,n,i,o):Et(t))e.push(s.i/r),e.push(t.i/r),e.push(l.i/r),Xt(t),t=l.next,u=l.next;else if((t=l)===u){a?1===a?Ot(t=Lt(zt(t),e,r),e,r,n,i,o,2):2===a&&Tt(t,e,r,n,i,o):Ot(zt(t),e,r,n,i,o,1);break}}}function Et(t){var e=t.prev,r=t,n=t.next;if(Nt(e,r,n)>=0)return!1;for(var i=t.next.next;i!==t.prev;){if(jt(e.x,e.y,r.x,r.y,n.x,n.y,i.x,i.y)&&Nt(i.prev,i,i.next)>=0)return!1;i=i.next}return!0}function Pt(t,e,r,n){var i=t.prev,o=t,a=t.next;if(Nt(i,o,a)>=0)return!1;for(var s=i.x<o.x?i.x<a.x?i.x:a.x:o.x<a.x?o.x:a.x,l=i.y<o.y?i.y<a.y?i.y:a.y:o.y<a.y?o.y:a.y,u=i.x>o.x?i.x>a.x?i.x:a.x:o.x>a.x?o.x:a.x,c=i.y>o.y?i.y>a.y?i.y:a.y:o.y>a.y?o.y:a.y,f=Ft(s,l,e,r,n),h=Ft(u,c,e,r,n),d=t.prevZ,p=t.nextZ;d&&d.z>=f&&p&&p.z<=h;){if(d!==t.prev&&d!==t.next&&jt(i.x,i.y,o.x,o.y,a.x,a.y,d.x,d.y)&&Nt(d.prev,d,d.next)>=0)return!1;if(d=d.prevZ,p!==t.prev&&p!==t.next&&jt(i.x,i.y,o.x,o.y,a.x,a.y,p.x,p.y)&&Nt(p.prev,p,p.next)>=0)return!1;p=p.nextZ}for(;d&&d.z>=f;){if(d!==t.prev&&d!==t.next&&jt(i.x,i.y,o.x,o.y,a.x,a.y,d.x,d.y)&&Nt(d.prev,d,d.next)>=0)return!1;d=d.prevZ}for(;p&&p.z<=h;){if(p!==t.prev&&p!==t.next&&jt(i.x,i.y,o.x,o.y,a.x,a.y,p.x,p.y)&&Nt(p.prev,p,p.next)>=0)return!1;p=p.nextZ}return!0}function Lt(t,e,r){var n=t;do{var i=n.prev,o=n.next.next;!Ut(i,o)&&Gt(i,n,n.next,o)&&Ht(i,o)&&Ht(o,i)&&(e.push(i.i/r),e.push(n.i/r),e.push(o.i/r),Xt(n),Xt(n.next),n=t=o),n=n.next}while(n!==t);return zt(n)}function Tt(t,e,r,n,i,o){var a=t;do{for(var s=a.next.next;s!==a.prev;){if(a.i!==s.i&&Vt(a,s)){var l=Zt(a,s);return a=zt(a,a.next),l=zt(l,l.next),Ot(a,e,r,n,i,o),void Ot(l,e,r,n,i,o)}s=s.next}a=a.next}while(a!==t)}function Dt(t,e){return t.x-e.x}function Rt(t,e){if(e=function(t,e){var r,n=e,i=t.x,o=t.y,a=-1/0;do{if(o<=n.y&&o>=n.next.y&&n.next.y!==n.y){var s=n.x+(o-n.y)*(n.next.x-n.x)/(n.next.y-n.y);if(s<=i&&s>a){if(a=s,s===i){if(o===n.y)return n;if(o===n.next.y)return n.next}r=n.x<n.next.x?n:n.next}}n=n.next}while(n!==e);if(!r)return null;if(i===a)return r;var l,u=r,c=r.x,f=r.y,h=1/0;n=r;do{i>=n.x&&n.x>=c&&i!==n.x&&jt(o<f?i:a,o,c,f,o<f?a:i,o,n.x,n.y)&&(l=Math.abs(o-n.y)/(i-n.x),Ht(n,t)&&(l<h||l===h&&(n.x>r.x||n.x===r.x&&It(r,n)))&&(r=n,h=l)),n=n.next}while(n!==u);return r}(t,e)){var r=Zt(e,t);zt(e,e.next),zt(r,r.next)}}function It(t,e){return Nt(t.prev,t,e.prev)<0&&Nt(e.next,t,t.next)<0}function Ft(t,e,r,n,i){return(t=1431655765&((t=858993459&((t=252645135&((t=16711935&((t=32767*(t-r)*i)|t<<8))|t<<4))|t<<2))|t<<1))|(e=1431655765&((e=858993459&((e=252645135&((e=16711935&((e=32767*(e-n)*i)|e<<8))|e<<4))|e<<2))|e<<1))<<1}function Bt(t){var e=t,r=t;do{(e.x<r.x||e.x===r.x&&e.y<r.y)&&(r=e),e=e.next}while(e!==t);return r}function jt(t,e,r,n,i,o,a,s){return(i-a)*(e-s)-(t-a)*(o-s)>=0&&(t-a)*(n-s)-(r-a)*(e-s)>=0&&(r-a)*(o-s)-(i-a)*(n-s)>=0}function Vt(t,e){return t.next.i!==e.i&&t.prev.i!==e.i&&!function(t,e){var r=t;do{if(r.i!==t.i&&r.next.i!==t.i&&r.i!==e.i&&r.next.i!==e.i&&Gt(r,r.next,t,e))return!0;r=r.next}while(r!==t);return!1}(t,e)&&(Ht(t,e)&&Ht(e,t)&&function(t,e){var r=t,n=!1,i=(t.x+e.x)/2,o=(t.y+e.y)/2;do{r.y>o!=r.next.y>o&&r.next.y!==r.y&&i<(r.next.x-r.x)*(o-r.y)/(r.next.y-r.y)+r.x&&(n=!n),r=r.next}while(r!==t);return n}(t,e)&&(Nt(t.prev,t,e.prev)||Nt(t,e.prev,e))||Ut(t,e)&&Nt(t.prev,t,t.next)>0&&Nt(e.prev,e,e.next)>0)}function Nt(t,e,r){return(e.y-t.y)*(r.x-e.x)-(e.x-t.x)*(r.y-e.y)}function Ut(t,e){return t.x===e.x&&t.y===e.y}function Gt(t,e,r,n){var i=qt(Nt(t,e,r)),o=qt(Nt(t,e,n)),a=qt(Nt(r,n,t)),s=qt(Nt(r,n,e));return i!==o&&a!==s||!(0!==i||!Wt(t,r,e))||!(0!==o||!Wt(t,n,e))||!(0!==a||!Wt(r,t,n))||!(0!==s||!Wt(r,e,n))}function Wt(t,e,r){return e.x<=Math.max(t.x,r.x)&&e.x>=Math.min(t.x,r.x)&&e.y<=Math.max(t.y,r.y)&&e.y>=Math.min(t.y,r.y)}function qt(t){return t>0?1:t<0?-1:0}function Ht(t,e){return Nt(t.prev,t,t.next)<0?Nt(t,e,t.next)>=0&&Nt(t,t.prev,e)>=0:Nt(t,e,t.prev)<0||Nt(t,t.next,e)<0}function Zt(t,e){var r=new Yt(t.i,t.x,t.y),n=new Yt(e.i,e.x,e.y),i=t.next,o=e.prev;return t.next=e,e.prev=t,r.next=i,i.prev=r,n.next=r,r.prev=n,o.next=n,n.prev=o,n}function Qt(t,e,r,n){var i=new Yt(t,e,r);return n?(i.next=n.next,i.prev=n,n.next.prev=i,n.next=i):(i.prev=i,i.next=i),i}function Xt(t){t.next.prev=t.prev,t.prev.next=t.next,t.prevZ&&(t.prevZ.nextZ=t.nextZ),t.nextZ&&(t.nextZ.prevZ=t.prevZ)}function Yt(t,e,r){this.i=t,this.x=e,this.y=r,this.prev=null,this.next=null,this.z=null,this.prevZ=null,this.nextZ=null,this.steiner=!1}function Jt(t,e,r,n){for(var i=0,o=e,a=r-n;o<r;o+=n)i+=(t[a]-t[o])*(t[o+1]+t[a+1]),a=o;return i}At.deviation=function(t,e,r,n){var i=e&&e.length,o=i?e[0]*r:t.length,a=Math.abs(Jt(t,0,o,r));if(i)for(var s=0,l=e.length;s<l;s++){var u=e[s]*r,c=s<l-1?e[s+1]*r:t.length;a-=Math.abs(Jt(t,u,c,r))}var f=0;for(s=0;s<n.length;s+=3){var h=n[s]*r,d=n[s+1]*r,p=n[s+2]*r;f+=Math.abs((t[h]-t[p])*(t[d+1]-t[h+1])-(t[h]-t[d])*(t[p+1]-t[h+1]))}return 0===a&&0===f?0:Math.abs((f-a)/a)},At.flatten=function(t){for(var e=t[0][0].length,r={vertices:[],holes:[],dimensions:e},n=0,i=0;i<t.length;i++){for(var o=0;o<t[i].length;o++)for(var a=0;a<e;a++)r.vertices.push(t[i][o][a]);i>0&&(n+=t[i-1].length,r.holes.push(n))}return r},St.default=kt;var Kt=h.CommonUtil,$t={multiToSingle:function(t){var e=[];if("MultiPoint"===t.type)for(var r=t.properties,n=(a=t.coordinates).length,i=0;i<n;++i){var o=a[i];e.push({properties:r,type:"Point",coordinates:o})}else if("MultiLineString"===t.type)for(r=t.properties,n=(a=t.coordinates).length,i=0;i<n;++i)o=a[i],e.push({properties:r,type:"Point",coordinates:o});else if("MultiPolygon"===t.type){var a;for(r=t.properties,n=(a=t.coordinates).length,i=0;i<n;++i)o=a[i],e.push({properties:r,type:"Point",coordinates:o})}return e},geojsonParser:function(t,e){if(void 0===e&&(e=!1),"FeatureCollection"===t.type&&t.features.length>0){var r=t.features,n=this.typeDivide(r);return e&&n.polygons.length>0&&(n.polygons=this.trianglePolygons(n.polygons)),n}return t},trianglePolygons:function(t){for(var e=[],r=0,n=t.length;r<n;r++){var i=t[r],a=o(o({},i),{polygons:[]});if("MultiPolygon"===i.geometry.type)for(var s=i.geometry.coordinates,l=0,u=s.length;l<u;l++){var c=s[l];a.polygons[l]=this.triangle(c)}else a.polygons[0]=this.triangle(i.geometry.coordinates);e[r]=a}return e},typeDivide:function(t){for(var e={points:[],lines:[],polygons:[],others:[]},r=0,n=t.length;r<n;r++){var i,a=t[r].geometry,s=a.type;e[i="Point"===s||"MultiPoint"===s?"points":"LineString"===s||"MultiLineString"===s?"lines":"Polygon"===s||"MultiPolygon"===s?"polygons":"others"][e[i].length]=o(o({},a),{properties:t[r].properties})}return e},triangle:function(t){var e=St.flatten(t);return{index:St(e.vertices,e.holes,e.dimensions),vertex:e.vertices}},mergeTriangles:function(t,e,r){void 0===r&&(r=3);var n=t.index,i=t.vertex,o=e.index,a=e.vertex,s=i.length/r,l=o.length,u=n.length;n.length+=o.length;for(var c=0;c<l;c++){var f=o[c];n[c+u]=f+s}return Kt.pushArray(i,a),{index:n,vertex:i}},isClock:function(t){for(var e=t.length,r=0,n=0;n<e;n++){var i=t[n],o=t[(n+1)%e];r+=(o[0]-i[0])*(o[1]+i[1])}return r>0}},te=function(t){function e(e){var r=t.call(this,e)||this;return r.type="geojson",r.url=e.url,_.record("GeoJSONSource"),r}return i(e,t),e.prototype.getDataset=function(){return this.load(),this.dataset},e.prototype.load=function(){var t=this;if("loaded"!==this.status&&"loading"!==this.status)if(this.status="loading",this.options.data){var e=this.options.data;this.valid(e)&&(this.dataset=this.parser(e),this.onLoaded())}else{var r=this.url;fetch(r).then((function(t){return t.json()})).then((function(e){t.valid(e)&&(t.dataset=t.parser(e),t.onLoaded())}))}},e.prototype.valid=function(t){return t||console.warn("无效数据"),!0},e.prototype.parser=function(t){var e=$t.geojsonParser(t);return[{id:h.CommonUtil.getGuid(),features:e}]},e.prototype.destroy=function(){this.dataset=[],this.url=""},e}(Ct),ee=function(){function t(){this.initStatus()}return t.prototype.initStatus=function(){console.log("gl",this.gl)},t.prototype.updateStatus=function(){},t.prototype.reset=function(){},t}(),re=function(){},ne=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return i(e,t),e.prototype.project=function(t){var r=t[0],n=t[1],i=t[2],o=e.RADIUS+i,a=h.MathUtil.angleToRad(r),s=h.MathUtil.angleToRad(n),l=o*Math.cos(s);return[l*Math.sin(a),o*Math.sin(s),l*Math.cos(a)]},e.prototype.unproject=function(t){var r=t[0],n=t[1],i=t[2],o=Math.sqrt(r*r+n*n+i*i),a=Math.asin(n/o),s=o*Math.cos(a);return[Math.asin(r/s),a,o-e.RADIUS]},e.prototype.getResolution=function(t){return 156543.03392804097/Math.pow(2,t)},e.RADIUS=6378137,e.CIRCUM=20037508.342789244,e.EARTH_SUN=1496e8,e.EARTH_MOON=363e6,e.EARTH_ANGLE=23.3/180*Math.PI,e}(re),ie=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return i(e,t),e.prototype.project=function(t){var r=e.r,n=e.d1,i=t[0],o=t[1],a=e.MAX_LATITUDE,s=o*n,l=Math.max(Math.min(a,i),-a)*n;return[s*r,(l=Math.log(Math.tan(Math.PI/4+l/2)))*r]},e.prototype.unproject=function(t){var r=e.r,n=e.d2,i=t[0],o=t[1];return[i/r*n,(2*Math.atan(Math.exp(o/r))-Math.PI/2)*n,0]},e.prototype.getResolution=function(t){return 156543.03392804097/Math.pow(2,t)},e.d1=Math.PI/180,e.d2=180/Math.PI,e.r=6378137,e.MAX_LATITUDE=85.0511287798,e}(re),oe=function(){function t(){this._colorMap=[],this._currentColor=[0,0,0,255],this._radix=256}return t.prototype.add=function(t){return this._colorMap[this._addColor()]=t,this._currentColor},t.prototype.clear=function(){this._currentColor=[0,0,0,255],this._colorMap={}},t.prototype.getColor=function(){return this._currentColor},t.prototype.getValue=function(t){var e=this._radix,r=e*e,n=t[0]+t[1]*e+t[2]*r;return this._colorMap[n]},t.prototype._addColor=function(){var t=this._radix,e=t*t,r=this._currentColor,n=r[0]+r[1]*t+r[2]*e+1;return this._currentColor[0]=n%t,this._currentColor[1]=~~(n/t)%t,this._currentColor[2]=~~(n/e)%t,n},t}();r.Bezier=ht,r.BuryPoint=_,r.ColorPick=oe,r.Context=ee,r.DataSource=Ct,r.Earth=ne,r.Event=v,r.GeoJSONSource=te,r.Geometry=$t,r.GeometryFusion=function(){},r.Layer=w,r.Map=j,r.Mercator=ie,r.Projection=re,r.Style=p,r.StyleInstance=m,r.Util=h,r.ViewControl=wt}));(u=c)&&u.__esModule&&Object.prototype.hasOwnProperty.call(u,"default")&&u.default;var f=c.Bezier,h=c.BuryPoint,d=c.ColorPick;c.Context,c.DataSource,c.Earth,c.Event;var p=c.GeoJSONSource,m=c.Geometry,v=c.GeometryFusion,g=c.Layer,y=c.Map;c.Mercator;var b,x=c.Projection,_=c.Style,w=c.StyleInstance,C=c.Util,S=c.ViewControl,k=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return i(e,t),e.getProject=function(){return this.instance},e.prototype.project=function(t){var e=[];return this.loca?((e=this.loca.customCoords.lngLatToCoord([t[0],t[1]]))[2]=t[2]||0,e):t},e.prototype.unproject=function(t){return t},e.prototype.coordsToContainer=function(t){return t},e.prototype.containerToCoords=function(t){return t},e.prototype.getResolution=function(t){return 156543.03392804097/Math.pow(2,t)},e.instance=new e,e}(x),A=k.getProject(),M=l((function(t,e){t.exports=function(){var t=function(t){return t instanceof Uint8Array||t instanceof Uint16Array||t instanceof Uint32Array||t instanceof Int8Array||t instanceof Int16Array||t instanceof Int32Array||t instanceof Float32Array||t instanceof Float64Array||t instanceof Uint8ClampedArray},e=function(t,e){for(var r=Object.keys(e),n=0;n<r.length;++n)t[r[n]]=e[r[n]];return t},r="\n";function n(t){return"undefined"!=typeof atob?atob(t):"base64:"+t}function i(t){var e=new Error("(regl) "+t);throw console.error(e),e}function o(t,e){t||i(e)}function a(t){return t?": "+t:""}function s(t,e,r){t in e||i("unknown parameter ("+t+")"+a(r)+". possible values: "+Object.keys(e).join())}function l(e,r){t(e)||i("invalid parameter type"+a(r)+". must be a typed array")}function u(t,e){switch(e){case"number":return"number"==typeof t;case"object":return"object"==typeof t;case"string":return"string"==typeof t;case"boolean":return"boolean"==typeof t;case"function":return"function"==typeof t;case"undefined":return void 0===t;case"symbol":return"symbol"==typeof t}}function c(t,e,r){u(t,e)||i("invalid parameter type"+a(r)+". expected "+e+", got "+typeof t)}function f(t,e){t>=0&&(0|t)===t||i("invalid parameter type, ("+t+")"+a(e)+". must be a nonnegative integer")}function h(t,e,r){e.indexOf(t)<0&&i("invalid value"+a(r)+". must be one of: "+e)}var d=["gl","canvas","container","attributes","pixelRatio","extensions","optionalExtensions","profile","onDone"];function p(t){Object.keys(t).forEach((function(t){d.indexOf(t)<0&&i('invalid regl constructor argument "'+t+'". must be one of '+d)}))}function m(t,e){for(t+="";t.length<e;)t=" "+t;return t}function v(){this.name="unknown",this.lines=[],this.index={},this.hasErrors=!1}function g(t,e){this.number=t,this.line=e,this.errors=[]}function y(t,e,r){this.file=t,this.line=e,this.message=r}function b(){var t=new Error,e=(t.stack||t).toString(),r=/compileProcedure.*\n\s*at.*\((.*)\)/.exec(e);if(r)return r[1];var n=/compileProcedure.*\n\s*at\s+(.*)(\n|$)/.exec(e);return n?n[1]:"unknown"}function x(){var t=new Error,e=(t.stack||t).toString(),r=/at REGLCommand.*\n\s+at.*\((.*)\)/.exec(e);if(r)return r[1];var n=/at REGLCommand.*\n\s+at\s+(.*)\n/.exec(e);return n?n[1]:"unknown"}function _(t,e){var r=t.split("\n"),i=1,o=0,a={unknown:new v,0:new v};a.unknown.name=a[0].name=e||b(),a.unknown.lines.push(new g(0,""));for(var s=0;s<r.length;++s){var l=r[s],u=/^\s*#\s*(\w+)\s+(.+)\s*$/.exec(l);if(u)switch(u[1]){case"line":var c=/(\d+)(\s+\d+)?/.exec(u[2]);c&&(i=0|c[1],c[2]&&((o=0|c[2])in a||(a[o]=new v)));break;case"define":var f=/SHADER_NAME(_B64)?\s+(.*)$/.exec(u[2]);f&&(a[o].name=f[1]?n(f[2]):f[2])}a[o].lines.push(new g(i++,l))}return Object.keys(a).forEach((function(t){var e=a[t];e.lines.forEach((function(t){e.index[t.number]=t}))})),a}function w(t){var e=[];return t.split("\n").forEach((function(t){if(!(t.length<5)){var r=/^ERROR:\s+(\d+):(\d+):\s*(.*)$/.exec(t);r?e.push(new y(0|r[1],0|r[2],r[3].trim())):t.length>0&&e.push(new y("unknown",0,t))}})),e}function C(t,e){e.forEach((function(e){var r=t[e.file];if(r){var n=r.index[e.line];if(n)return n.errors.push(e),void(r.hasErrors=!0)}t.unknown.hasErrors=!0,t.unknown.lines[0].errors.push(e)}))}function S(t,e,n,i,a){if(!t.getShaderParameter(e,t.COMPILE_STATUS)){var s=t.getShaderInfoLog(e),l=i===t.FRAGMENT_SHADER?"fragment":"vertex";P(n,"string",l+" shader source must be a string",a);var u=_(n,a),c=w(s);C(u,c),Object.keys(u).forEach((function(t){var e=u[t];if(e.hasErrors){var n=[""],i=[""];o("file number "+t+": "+e.name+"\n","color:red;text-decoration:underline;font-weight:bold"),e.lines.forEach((function(t){if(t.errors.length>0){o(m(t.number,4)+"|  ","background-color:yellow; font-weight:bold"),o(t.line+r,"color:red; background-color:yellow; font-weight:bold");var e=0;t.errors.forEach((function(n){var i=n.message,a=/^\s*'(.*)'\s*:\s*(.*)$/.exec(i);if(a){var s=a[1];switch(i=a[2],s){case"assign":s="="}e=Math.max(t.line.indexOf(s,e),0)}else e=0;o(m("| ",6)),o(m("^^^",e+3)+r,"font-weight:bold"),o(m("| ",6)),o(i+r,"font-weight:bold")})),o(m("| ",6)+r)}else o(m(t.number,4)+"|  "),o(t.line+r,"color:red")})),"undefined"==typeof document||window.chrome?console.log(n.join("")):(i[0]=n.join("%c"),console.log.apply(console,i))}function o(t,e){n.push(t),i.push(e||"")}})),o.raise("Error compiling "+l+" shader, "+u[0].name)}}function k(t,e,n,i,a){if(!t.getProgramParameter(e,t.LINK_STATUS)){var s=t.getProgramInfoLog(e),l=_(n,a),u='Error linking program with vertex shader, "'+_(i,a)[0].name+'", and fragment shader "'+l[0].name+'"';"undefined"!=typeof document?console.log("%c"+u+r+"%c"+s,"color:red;text-decoration:underline;font-weight:bold","color:red"):console.log(u+r+s),o.raise(u)}}function A(t){t._commandRef=b()}function M(t,e,r,n){function i(t){return t?n.id(t):0}function o(t,e){Object.keys(e).forEach((function(e){t[n.id(e)]=!0}))}A(t),t._fragId=i(t.static.frag),t._vertId=i(t.static.vert);var a=t._uniformSet={};o(a,e.static),o(a,e.dynamic);var s=t._attributeSet={};o(s,r.static),o(s,r.dynamic),t._hasCount="count"in t.static||"count"in t.dynamic||"elements"in t.static||"elements"in t.dynamic}function z(t,e){var r=x();i(t+" in command "+(e||b())+("unknown"===r?"":" called from "+r))}function O(t,e,r){t||z(e,r||b())}function E(t,e,r,n){t in e||z("unknown parameter ("+t+")"+a(r)+". possible values: "+Object.keys(e).join(),n||b())}function P(t,e,r,n){u(t,e)||z("invalid parameter type"+a(r)+". expected "+e+", got "+typeof t,n||b())}function L(t){t()}function T(t,e,r){t.texture?h(t.texture._texture.internalformat,e,"unsupported texture format for attachment"):h(t.renderbuffer._renderbuffer.format,r,"unsupported renderbuffer format for attachment")}var D=33071,R=9728,I=9984,F=9985,B=9986,j=9987,V=5121,N=5122,U=5123,G=5124,W=5125,q=5126,H=32819,Z=32820,Q=33635,X=34042,Y=36193,J={};function K(t,e){return t===Z||t===H||t===Q?2:t===X?4:J[t]*e}function $(t){return!(t&t-1||!t)}function tt(t,e,r){var n,i=e.width,a=e.height,s=e.channels;o(i>0&&i<=r.maxTextureSize&&a>0&&a<=r.maxTextureSize,"invalid texture shape"),t.wrapS===D&&t.wrapT===D||o($(i)&&$(a),"incompatible wrap mode for texture, both width and height must be power of 2"),1===e.mipmask?1!==i&&1!==a&&o(t.minFilter!==I&&t.minFilter!==B&&t.minFilter!==F&&t.minFilter!==j,"min filter requires mipmap"):(o($(i)&&$(a),"texture must be a square power of 2 to support mipmapping"),o(e.mipmask===(i<<1)-1,"missing or incomplete mipmap data")),e.type===q&&(r.extensions.indexOf("oes_texture_float_linear")<0&&o(t.minFilter===R&&t.magFilter===R,"filter not supported, must enable oes_texture_float_linear"),o(!t.genMipmaps,"mipmap generation not supported with float textures"));var l=e.images;for(n=0;n<16;++n)if(l[n]){var u=i>>n,c=a>>n;o(e.mipmask&1<<n,"missing mipmap data");var f=l[n];if(o(f.width===u&&f.height===c,"invalid shape for mip images"),o(f.format===e.format&&f.internalformat===e.internalformat&&f.type===e.type,"incompatible type for mip image"),f.compressed);else if(f.data){var h=Math.ceil(K(f.type,s)*u/f.unpackAlignment)*f.unpackAlignment;o(f.data.byteLength===h*c,"invalid data for image, buffer size is inconsistent with image format")}else f.element||f.copy}else t.genMipmaps||o(0==(e.mipmask&1<<n),"extra mipmap data");e.compressed&&o(!t.genMipmaps,"mipmap generation for compressed images not supported")}function et(t,e,r,n){var i=t.width,a=t.height,s=t.channels;o(i>0&&i<=n.maxTextureSize&&a>0&&a<=n.maxTextureSize,"invalid texture shape"),o(i===a,"cube map must be square"),o(e.wrapS===D&&e.wrapT===D,"wrap mode not supported by cube map");for(var l=0;l<r.length;++l){var u=r[l];o(u.width===i&&u.height===a,"inconsistent cube map face shape"),e.genMipmaps&&(o(!u.compressed,"can not generate mipmap for compressed textures"),o(1===u.mipmask,"can not specify mipmaps and generate mipmaps"));for(var c=u.images,f=0;f<16;++f){var h=c[f];if(h){var d=i>>f,p=a>>f;o(u.mipmask&1<<f,"missing mipmap data"),o(h.width===d&&h.height===p,"invalid shape for mip images"),o(h.format===t.format&&h.internalformat===t.internalformat&&h.type===t.type,"incompatible type for mip image"),h.compressed||(h.data?o(h.data.byteLength===d*p*Math.max(K(h.type,s),h.unpackAlignment),"invalid data for image, buffer size is inconsistent with image format"):h.element||h.copy)}}}}J[5120]=J[V]=1,J[N]=J[U]=J[Y]=J[Q]=J[H]=J[Z]=2,J[G]=J[W]=J[q]=J[X]=4;var rt=e(o,{optional:L,raise:i,commandRaise:z,command:O,parameter:s,commandParameter:E,constructor:p,type:c,commandType:P,isTypedArray:l,nni:f,oneOf:h,shaderError:S,linkError:k,callSite:x,saveCommandRef:A,saveDrawInfo:M,framebufferFormat:T,guessCommand:b,texture2D:tt,textureCube:et}),nt=0,it=0,ot=5,at=6;function st(t,e){this.id=nt++,this.type=t,this.data=e}function lt(t){return t.replace(/\\/g,"\\\\").replace(/"/g,'\\"')}function ut(t){if(0===t.length)return[];var e=t.charAt(0),r=t.charAt(t.length-1);if(t.length>1&&e===r&&('"'===e||"'"===e))return['"'+lt(t.substr(1,t.length-2))+'"'];var n=/\[(false|true|null|\d+|'[^']*'|"[^"]*")\]/.exec(t);if(n)return ut(t.substr(0,n.index)).concat(ut(n[1])).concat(ut(t.substr(n.index+n[0].length)));var i=t.split(".");if(1===i.length)return['"'+lt(t)+'"'];for(var o=[],a=0;a<i.length;++a)o=o.concat(ut(i[a]));return o}function ct(t){return"["+ut(t).join("][")+"]"}function ft(t,e){return new st(t,ct(e+""))}function ht(t){return"function"==typeof t&&!t._reglType||t instanceof st}function dt(t,e){return"function"==typeof t?new st(it,t):"number"==typeof t||"boolean"==typeof t?new st(ot,t):Array.isArray(t)?new st(at,t.map((function(t,r){return dt(t,e+"["+r+"]")}))):t instanceof st?t:void rt(!1,"invalid option type in uniform "+e)}var pt={DynamicVariable:st,define:ft,isDynamic:ht,unbox:dt,accessor:ct},mt={next:"function"==typeof requestAnimationFrame?function(t){return requestAnimationFrame(t)}:function(t){return setTimeout(t,16)},cancel:"function"==typeof cancelAnimationFrame?function(t){return cancelAnimationFrame(t)}:clearTimeout},vt="undefined"!=typeof performance&&performance.now?function(){return performance.now()}:function(){return+new Date};function gt(){var t={"":0},e=[""];return{id:function(r){var n=t[r];return n||(n=t[r]=e.length,e.push(r),n)},str:function(t){return e[t]}}}function yt(t,r,n){var i,o=document.createElement("canvas");function a(){var e=window.innerWidth,r=window.innerHeight;if(t!==document.body){var i=o.getBoundingClientRect();e=i.right-i.left,r=i.bottom-i.top}o.width=n*e,o.height=n*r}function s(){i?i.disconnect():window.removeEventListener("resize",a),t.removeChild(o)}return e(o.style,{border:0,margin:0,padding:0,top:0,left:0,width:"100%",height:"100%"}),t.appendChild(o),t===document.body&&(o.style.position="absolute",e(t.style,{margin:0,padding:0})),t!==document.body&&"function"==typeof ResizeObserver?(i=new ResizeObserver((function(){setTimeout(a)}))).observe(t):window.addEventListener("resize",a,!1),a(),{canvas:o,onDestroy:s}}function bt(t,e){function r(r){try{return t.getContext(r,e)}catch(t){return null}}return r("webgl")||r("experimental-webgl")||r("webgl-experimental")}function xt(t){return"string"==typeof t.nodeName&&"function"==typeof t.appendChild&&"function"==typeof t.getBoundingClientRect}function _t(t){return"function"==typeof t.drawArrays||"function"==typeof t.drawElements}function wt(t){return"string"==typeof t?t.split():(rt(Array.isArray(t),"invalid extension array"),t)}function Ct(t){return"string"==typeof t?(rt("undefined"!=typeof document,"not supported outside of DOM"),document.querySelector(t)):t}function St(t){var e,r,n,i,o=t||{},a={},s=[],l=[],u="undefined"==typeof window?1:window.devicePixelRatio,c=!1,f=function(t){t&&rt.raise(t)},h=function(){};if("string"==typeof o?(rt("undefined"!=typeof document,"selector queries only supported in DOM enviroments"),e=document.querySelector(o),rt(e,"invalid query string for element")):"object"==typeof o?xt(o)?e=o:_t(o)?n=(i=o).canvas:(rt.constructor(o),"gl"in o?i=o.gl:"canvas"in o?n=Ct(o.canvas):"container"in o&&(r=Ct(o.container)),"attributes"in o&&(a=o.attributes,rt.type(a,"object","invalid context attributes")),"extensions"in o&&(s=wt(o.extensions)),"optionalExtensions"in o&&(l=wt(o.optionalExtensions)),"onDone"in o&&(rt.type(o.onDone,"function","invalid or missing onDone callback"),f=o.onDone),"profile"in o&&(c=!!o.profile),"pixelRatio"in o&&(u=+o.pixelRatio,rt(u>0,"invalid pixel ratio"))):rt.raise("invalid arguments to regl"),e&&("canvas"===e.nodeName.toLowerCase()?n=e:r=e),!i){if(!n){rt("undefined"!=typeof document,"must manually specify webgl context outside of DOM environments");var d=yt(r||document.body,f,u);if(!d)return null;n=d.canvas,h=d.onDestroy}void 0===a.premultipliedAlpha&&(a.premultipliedAlpha=!0),i=bt(n,a)}return i?{gl:i,canvas:n,container:r,extensions:s,optionalExtensions:l,pixelRatio:u,profile:c,onDone:f,onDestroy:h}:(h(),f("webgl not supported, try upgrading your browser or graphics drivers http://get.webgl.org"),null)}function kt(t,e){var r={};function n(e){rt.type(e,"string","extension name must be string");var n,i=e.toLowerCase();try{n=r[i]=t.getExtension(i)}catch(t){}return!!n}for(var i=0;i<e.extensions.length;++i){var o=e.extensions[i];if(!n(o))return e.onDestroy(),e.onDone('"'+o+'" extension is not supported by the current WebGL context, try upgrading your system or a different browser'),null}return e.optionalExtensions.forEach(n),{extensions:r,restore:function(){Object.keys(r).forEach((function(t){if(r[t]&&!n(t))throw new Error("(regl): error restoring extension "+t)}))}}}function At(t,e){for(var r=Array(t),n=0;n<t;++n)r[n]=e(n);return r}var Mt=5120,zt=5121,Ot=5122,Et=5123,Pt=5124,Lt=5125,Tt=5126;function Dt(t){for(var e=16;e<=1<<28;e*=16)if(t<=e)return e;return 0}function Rt(t){var e,r;return e=(t>65535)<<4,e|=r=((t>>>=e)>255)<<3,e|=r=((t>>>=r)>15)<<2,(e|=r=((t>>>=r)>3)<<1)|(t>>>=r)>>1}function It(){var t=At(8,(function(){return[]}));function e(e){var r=Dt(e),n=t[Rt(r)>>2];return n.length>0?n.pop():new ArrayBuffer(r)}function r(e){t[Rt(e.byteLength)>>2].push(e)}function n(t,r){var n=null;switch(t){case Mt:n=new Int8Array(e(r),0,r);break;case zt:n=new Uint8Array(e(r),0,r);break;case Ot:n=new Int16Array(e(2*r),0,r);break;case Et:n=new Uint16Array(e(2*r),0,r);break;case Pt:n=new Int32Array(e(4*r),0,r);break;case Lt:n=new Uint32Array(e(4*r),0,r);break;case Tt:n=new Float32Array(e(4*r),0,r);break;default:return null}return n.length!==r?n.subarray(0,r):n}function i(t){r(t.buffer)}return{alloc:e,free:r,allocType:n,freeType:i}}var Ft=It();Ft.zero=It();var Bt=3408,jt=3410,Vt=3411,Nt=3412,Ut=3413,Gt=3414,Wt=3415,qt=33901,Ht=33902,Zt=3379,Qt=3386,Xt=34921,Yt=36347,Jt=36348,Kt=35661,$t=35660,te=34930,ee=36349,re=34076,ne=34024,ie=7936,oe=7937,ae=7938,se=35724,le=34047,ue=36063,ce=34852,fe=3553,he=34067,de=34069,pe=33984,me=6408,ve=5126,ge=5121,ye=36160,be=36053,xe=36064,_e=16384,we=function(t,e){var r=1;e.ext_texture_filter_anisotropic&&(r=t.getParameter(le));var n=1,i=1;e.webgl_draw_buffers&&(n=t.getParameter(ce),i=t.getParameter(ue));var o=!!e.oes_texture_float;if(o){var a=t.createTexture();t.bindTexture(fe,a),t.texImage2D(fe,0,me,1,1,0,me,ve,null);var s=t.createFramebuffer();if(t.bindFramebuffer(ye,s),t.framebufferTexture2D(ye,xe,fe,a,0),t.bindTexture(fe,null),t.checkFramebufferStatus(ye)!==be)o=!1;else{t.viewport(0,0,1,1),t.clearColor(1,0,0,1),t.clear(_e);var l=Ft.allocType(ve,4);t.readPixels(0,0,1,1,me,ve,l),t.getError()?o=!1:(t.deleteFramebuffer(s),t.deleteTexture(a),o=1===l[0]),Ft.freeType(l)}}var u=!0;if("undefined"==typeof navigator||!(/MSIE/.test(navigator.userAgent)||/Trident\//.test(navigator.appVersion)||/Edge/.test(navigator.userAgent))){var c=t.createTexture(),f=Ft.allocType(ge,36);t.activeTexture(pe),t.bindTexture(he,c),t.texImage2D(de,0,me,3,3,0,me,ge,f),Ft.freeType(f),t.bindTexture(he,null),t.deleteTexture(c),u=!t.getError()}return{colorBits:[t.getParameter(jt),t.getParameter(Vt),t.getParameter(Nt),t.getParameter(Ut)],depthBits:t.getParameter(Gt),stencilBits:t.getParameter(Wt),subpixelBits:t.getParameter(Bt),extensions:Object.keys(e).filter((function(t){return!!e[t]})),maxAnisotropic:r,maxDrawbuffers:n,maxColorAttachments:i,pointSizeDims:t.getParameter(qt),lineWidthDims:t.getParameter(Ht),maxViewportDims:t.getParameter(Qt),maxCombinedTextureUnits:t.getParameter(Kt),maxCubeMapSize:t.getParameter(re),maxRenderbufferSize:t.getParameter(ne),maxTextureUnits:t.getParameter(te),maxTextureSize:t.getParameter(Zt),maxAttributes:t.getParameter(Xt),maxVertexUniforms:t.getParameter(Yt),maxVertexTextureUnits:t.getParameter($t),maxVaryingVectors:t.getParameter(Jt),maxFragmentUniforms:t.getParameter(ee),glsl:t.getParameter(se),renderer:t.getParameter(oe),vendor:t.getParameter(ie),version:t.getParameter(ae),readFloat:o,npotTextureCube:u}};function Ce(e){return!!e&&"object"==typeof e&&Array.isArray(e.shape)&&Array.isArray(e.stride)&&"number"==typeof e.offset&&e.shape.length===e.stride.length&&(Array.isArray(e.data)||t(e.data))}var Se=function(t){return Object.keys(t).map((function(e){return t[e]}))},ke={shape:Pe,flatten:Ee};function Ae(t,e,r){for(var n=0;n<e;++n)r[n]=t[n]}function Me(t,e,r,n){for(var i=0,o=0;o<e;++o)for(var a=t[o],s=0;s<r;++s)n[i++]=a[s]}function ze(t,e,r,n,i,o){for(var a=o,s=0;s<e;++s)for(var l=t[s],u=0;u<r;++u)for(var c=l[u],f=0;f<n;++f)i[a++]=c[f]}function Oe(t,e,r,n,i){for(var o=1,a=r+1;a<e.length;++a)o*=e[a];var s=e[r];if(e.length-r==4){var l=e[r+1],u=e[r+2],c=e[r+3];for(a=0;a<s;++a)ze(t[a],l,u,c,n,i),i+=o}else for(a=0;a<s;++a)Oe(t[a],e,r+1,n,i),i+=o}function Ee(t,e,r,n){var i=1;if(e.length)for(var o=0;o<e.length;++o)i*=e[o];else i=0;var a=n||Ft.allocType(r,i);switch(e.length){case 0:break;case 1:Ae(t,e[0],a);break;case 2:Me(t,e[0],e[1],a);break;case 3:ze(t,e[0],e[1],e[2],a,0);break;default:Oe(t,e,0,a,0)}return a}function Pe(t){for(var e=[],r=t;r.length;r=r[0])e.push(r.length);return e}var Le={"[object Int8Array]":5120,"[object Int16Array]":5122,"[object Int32Array]":5124,"[object Uint8Array]":5121,"[object Uint8ClampedArray]":5121,"[object Uint16Array]":5123,"[object Uint32Array]":5125,"[object Float32Array]":5126,"[object Float64Array]":5121,"[object ArrayBuffer]":5121},Te={int8:5120,int16:5122,int32:5124,uint8:5121,uint16:5123,uint32:5125,float:5126,float32:5126},De={dynamic:35048,stream:35040,static:35044},Re=ke.flatten,Ie=ke.shape,Fe=35044,Be=35040,je=5121,Ve=5126,Ne=[];function Ue(t){return 0|Le[Object.prototype.toString.call(t)]}function Ge(t,e){for(var r=0;r<e.length;++r)t[r]=e[r]}function We(t,e,r,n,i,o,a){for(var s=0,l=0;l<r;++l)for(var u=0;u<n;++u)t[s++]=e[i*l+o*u+a]}function qe(e,r,n,i){var o=0,a={};function s(t){this.id=o++,this.buffer=e.createBuffer(),this.type=t,this.usage=Fe,this.byteLength=0,this.dimension=1,this.dtype=je,this.persistentData=null,n.profile&&(this.stats={size:0})}s.prototype.bind=function(){e.bindBuffer(this.type,this.buffer)},s.prototype.destroy=function(){d(this)};var l=[];function u(t,e){var r=l.pop();return r||(r=new s(t)),r.bind(),h(r,e,Be,0,1,!1),r}function c(t){l.push(t)}function f(t,r,n){t.byteLength=r.byteLength,e.bufferData(t.type,r,n)}function h(e,r,n,i,o,a){var s,l;if(e.usage=n,Array.isArray(r)){if(e.dtype=i||Ve,r.length>0)if(Array.isArray(r[0])){s=Ie(r);for(var u=1,c=1;c<s.length;++c)u*=s[c];e.dimension=u,f(e,l=Re(r,s,e.dtype),n),a?e.persistentData=l:Ft.freeType(l)}else if("number"==typeof r[0]){e.dimension=o;var h=Ft.allocType(e.dtype,r.length);Ge(h,r),f(e,h,n),a?e.persistentData=h:Ft.freeType(h)}else t(r[0])?(e.dimension=r[0].length,e.dtype=i||Ue(r[0])||Ve,f(e,l=Re(r,[r.length,r[0].length],e.dtype),n),a?e.persistentData=l:Ft.freeType(l)):rt.raise("invalid buffer data")}else if(t(r))e.dtype=i||Ue(r),e.dimension=o,f(e,r,n),a&&(e.persistentData=new Uint8Array(new Uint8Array(r.buffer)));else if(Ce(r)){s=r.shape;var d=r.stride,p=r.offset,m=0,v=0,g=0,y=0;1===s.length?(m=s[0],v=1,g=d[0],y=0):2===s.length?(m=s[0],v=s[1],g=d[0],y=d[1]):rt.raise("invalid shape"),e.dtype=i||Ue(r.data)||Ve,e.dimension=v;var b=Ft.allocType(e.dtype,m*v);We(b,r.data,m,v,g,y,p),f(e,b,n),a?e.persistentData=b:Ft.freeType(b)}else r instanceof ArrayBuffer?(e.dtype=je,e.dimension=o,f(e,r,n),a&&(e.persistentData=new Uint8Array(new Uint8Array(r)))):rt.raise("invalid buffer data")}function d(t){r.bufferCount--,i(t);var n=t.buffer;rt(n,"buffer must not be deleted already"),e.deleteBuffer(n),t.buffer=null,delete a[t.id]}function p(i,o,l,u){r.bufferCount++;var c=new s(o);function f(r){var i=Fe,o=null,a=0,s=0,l=1;return Array.isArray(r)||t(r)||Ce(r)||r instanceof ArrayBuffer?o=r:"number"==typeof r?a=0|r:r&&(rt.type(r,"object","buffer arguments must be an object, a number or an array"),"data"in r&&(rt(null===o||Array.isArray(o)||t(o)||Ce(o),"invalid data for buffer"),o=r.data),"usage"in r&&(rt.parameter(r.usage,De,"invalid buffer usage"),i=De[r.usage]),"type"in r&&(rt.parameter(r.type,Te,"invalid buffer type"),s=Te[r.type]),"dimension"in r&&(rt.type(r.dimension,"number","invalid dimension"),l=0|r.dimension),"length"in r&&(rt.nni(a,"buffer length must be a nonnegative integer"),a=0|r.length)),c.bind(),o?h(c,o,i,s,l,u):(a&&e.bufferData(c.type,a,i),c.dtype=s||je,c.usage=i,c.dimension=l,c.byteLength=a),n.profile&&(c.stats.size=c.byteLength*Ne[c.dtype]),f}function p(t,r){rt(r+t.byteLength<=c.byteLength,"invalid buffer subdata call, buffer is too small.  Can't write data of size "+t.byteLength+" starting from offset "+r+" to a buffer of size "+c.byteLength),e.bufferSubData(c.type,r,t)}function m(e,r){var n,i=0|(r||0);if(c.bind(),t(e)||e instanceof ArrayBuffer)p(e,i);else if(Array.isArray(e)){if(e.length>0)if("number"==typeof e[0]){var o=Ft.allocType(c.dtype,e.length);Ge(o,e),p(o,i),Ft.freeType(o)}else if(Array.isArray(e[0])||t(e[0])){n=Ie(e);var a=Re(e,n,c.dtype);p(a,i),Ft.freeType(a)}else rt.raise("invalid buffer data")}else if(Ce(e)){n=e.shape;var s=e.stride,l=0,u=0,h=0,d=0;1===n.length?(l=n[0],u=1,h=s[0],d=0):2===n.length?(l=n[0],u=n[1],h=s[0],d=s[1]):rt.raise("invalid shape");var m=Array.isArray(e.data)?c.dtype:Ue(e.data),v=Ft.allocType(m,l*u);We(v,e.data,l,u,h,d,e.offset),p(v,i),Ft.freeType(v)}else rt.raise("invalid data for buffer subdata");return f}return a[c.id]=c,l||f(i),f._reglType="buffer",f._buffer=c,f.subdata=m,n.profile&&(f.stats=c.stats),f.destroy=function(){d(c)},f}function m(){Se(a).forEach((function(t){t.buffer=e.createBuffer(),e.bindBuffer(t.type,t.buffer),e.bufferData(t.type,t.persistentData||t.byteLength,t.usage)}))}return n.profile&&(r.getTotalBufferSize=function(){var t=0;return Object.keys(a).forEach((function(e){t+=a[e].stats.size})),t}),{create:p,createStream:u,destroyStream:c,clear:function(){Se(a).forEach(d),l.forEach(d)},getBuffer:function(t){return t&&t._buffer instanceof s?t._buffer:null},restore:m,_initBuffer:h}}Ne[5120]=1,Ne[5122]=2,Ne[5124]=4,Ne[5121]=1,Ne[5123]=2,Ne[5125]=4,Ne[5126]=4;var He={points:0,point:0,lines:1,line:1,triangles:4,triangle:4,"line loop":2,"line strip":3,"triangle strip":5,"triangle fan":6},Ze=0,Qe=1,Xe=4,Ye=5120,Je=5121,Ke=5122,$e=5123,tr=5124,er=5125,rr=34963,nr=35040,ir=35044;function or(e,r,n,i){var o={},a=0,s={uint8:Je,uint16:$e};function l(t){this.id=a++,o[this.id]=this,this.buffer=t,this.primType=Xe,this.vertCount=0,this.type=0}r.oes_element_index_uint&&(s.uint32=er),l.prototype.bind=function(){this.buffer.bind()};var u=[];function c(t){var e=u.pop();return e||(e=new l(n.create(null,rr,!0,!1)._buffer)),h(e,t,nr,-1,-1,0,0),e}function f(t){u.push(t)}function h(i,o,a,s,l,u,c){var f;if(i.buffer.bind(),o){var h=c;c||t(o)&&(!Ce(o)||t(o.data))||(h=r.oes_element_index_uint?er:$e),n._initBuffer(i.buffer,o,a,h,3)}else e.bufferData(rr,u,a),i.buffer.dtype=f||Je,i.buffer.usage=a,i.buffer.dimension=3,i.buffer.byteLength=u;if(f=c,!c){switch(i.buffer.dtype){case Je:case Ye:f=Je;break;case $e:case Ke:f=$e;break;case er:case tr:f=er;break;default:rt.raise("unsupported type for element array")}i.buffer.dtype=f}i.type=f,rt(f!==er||!!r.oes_element_index_uint,"32 bit element buffers not supported, enable oes_element_index_uint first");var d=l;d<0&&(d=i.buffer.byteLength,f===$e?d>>=1:f===er&&(d>>=2)),i.vertCount=d;var p=s;if(s<0){p=Xe;var m=i.buffer.dimension;1===m&&(p=Ze),2===m&&(p=Qe),3===m&&(p=Xe)}i.primType=p}function d(t){i.elementsCount--,rt(null!==t.buffer,"must not double destroy elements"),delete o[t.id],t.buffer.destroy(),t.buffer=null}function p(e,r){var o=n.create(null,rr,!0),a=new l(o._buffer);function u(e){if(e)if("number"==typeof e)o(e),a.primType=Xe,a.vertCount=0|e,a.type=Je;else{var r=null,n=ir,i=-1,l=-1,c=0,f=0;Array.isArray(e)||t(e)||Ce(e)?r=e:(rt.type(e,"object","invalid arguments for elements"),"data"in e&&(r=e.data,rt(Array.isArray(r)||t(r)||Ce(r),"invalid data for element buffer")),"usage"in e&&(rt.parameter(e.usage,De,"invalid element buffer usage"),n=De[e.usage]),"primitive"in e&&(rt.parameter(e.primitive,He,"invalid element buffer primitive"),i=He[e.primitive]),"count"in e&&(rt("number"==typeof e.count&&e.count>=0,"invalid vertex count for elements"),l=0|e.count),"type"in e&&(rt.parameter(e.type,s,"invalid buffer type"),f=s[e.type]),"length"in e?c=0|e.length:(c=l,f===$e||f===Ke?c*=2:f!==er&&f!==tr||(c*=4))),h(a,r,n,i,l,c,f)}else o(),a.primType=Xe,a.vertCount=0,a.type=Je;return u}return i.elementsCount++,u(e),u._reglType="elements",u._elements=a,u.subdata=function(t,e){return o.subdata(t,e),u},u.destroy=function(){d(a)},u}return{create:p,createStream:c,destroyStream:f,getElements:function(t){return"function"==typeof t&&t._elements instanceof l?t._elements:null},clear:function(){Se(o).forEach(d)}}}var ar=new Float32Array(1),sr=new Uint32Array(ar.buffer),lr=5123;function ur(t){for(var e=Ft.allocType(lr,t.length),r=0;r<t.length;++r)if(isNaN(t[r]))e[r]=65535;else if(t[r]===1/0)e[r]=31744;else if(t[r]===-1/0)e[r]=64512;else{ar[0]=t[r];var n=sr[0],i=n>>>31<<15,o=(n<<1>>>24)-127,a=n>>13&1023;if(o<-24)e[r]=i;else if(o<-14){var s=-14-o;e[r]=i+(a+1024>>s)}else e[r]=o>15?i+31744:i+(o+15<<10)+a}return e}function cr(e){return Array.isArray(e)||t(e)}var fr=function(t){return!(t&t-1||!t)},hr=34467,dr=3553,pr=34067,mr=34069,vr=6408,gr=6406,yr=6407,br=6409,xr=6410,_r=32854,wr=32855,Cr=36194,Sr=32819,kr=32820,Ar=33635,Mr=34042,zr=6402,Or=34041,Er=35904,Pr=35906,Lr=36193,Tr=33776,Dr=33777,Rr=33778,Ir=33779,Fr=35986,Br=35987,jr=34798,Vr=35840,Nr=35841,Ur=35842,Gr=35843,Wr=36196,qr=5121,Hr=5123,Zr=5125,Qr=5126,Xr=10242,Yr=10243,Jr=10497,Kr=33071,$r=33648,tn=10240,en=10241,rn=9728,nn=9729,on=9984,an=9985,sn=9986,ln=9987,un=33170,cn=4352,fn=4353,hn=4354,dn=34046,pn=3317,mn=37440,vn=37441,gn=37443,yn=37444,bn=33984,xn=[on,sn,an,ln],_n=[0,br,xr,yr,vr],wn={};function Cn(t){return"[object "+t+"]"}wn[br]=wn[gr]=wn[zr]=1,wn[Or]=wn[xr]=2,wn[yr]=wn[Er]=3,wn[vr]=wn[Pr]=4;var Sn=Cn("HTMLCanvasElement"),kn=Cn("OffscreenCanvas"),An=Cn("CanvasRenderingContext2D"),Mn=Cn("ImageBitmap"),zn=Cn("HTMLImageElement"),On=Cn("HTMLVideoElement"),En=Object.keys(Le).concat([Sn,kn,An,Mn,zn,On]),Pn=[];Pn[qr]=1,Pn[Qr]=4,Pn[Lr]=2,Pn[Hr]=2,Pn[Zr]=4;var Ln=[];function Tn(t){return Array.isArray(t)&&(0===t.length||"number"==typeof t[0])}function Dn(t){return!!Array.isArray(t)&&!(0===t.length||!cr(t[0]))}function Rn(t){return Object.prototype.toString.call(t)}function In(t){return Rn(t)===Sn}function Fn(t){return Rn(t)===kn}function Bn(t){return Rn(t)===An}function jn(t){return Rn(t)===Mn}function Vn(t){return Rn(t)===zn}function Nn(t){return Rn(t)===On}function Un(t){if(!t)return!1;var e=Rn(t);return En.indexOf(e)>=0||Tn(t)||Dn(t)||Ce(t)}function Gn(t){return 0|Le[Object.prototype.toString.call(t)]}function Wn(t,e){var r=e.length;switch(t.type){case qr:case Hr:case Zr:case Qr:var n=Ft.allocType(t.type,r);n.set(e),t.data=n;break;case Lr:t.data=ur(e);break;default:rt.raise("unsupported texture type, must specify a typed array")}}function qn(t,e){return Ft.allocType(t.type===Lr?Qr:t.type,e)}function Hn(t,e){t.type===Lr?(t.data=ur(e),Ft.freeType(e)):t.data=e}function Zn(t,e,r,n,i,o){for(var a=t.width,s=t.height,l=t.channels,u=qn(t,a*s*l),c=0,f=0;f<s;++f)for(var h=0;h<a;++h)for(var d=0;d<l;++d)u[c++]=e[r*h+n*f+i*d+o];Hn(t,u)}function Qn(t,e,r,n,i,o){var a;if(a=void 0!==Ln[t]?Ln[t]:wn[t]*Pn[e],o&&(a*=6),i){for(var s=0,l=r;l>=1;)s+=a*l*l,l/=2;return s}return a*r*n}function Xn(r,n,i,o,a,s,l){var u={"don't care":cn,"dont care":cn,nice:hn,fast:fn},c={repeat:Jr,clamp:Kr,mirror:$r},f={nearest:rn,linear:nn},h=e({mipmap:ln,"nearest mipmap nearest":on,"linear mipmap nearest":an,"nearest mipmap linear":sn,"linear mipmap linear":ln},f),d={none:0,browser:yn},p={uint8:qr,rgba4:Sr,rgb565:Ar,"rgb5 a1":kr},m={alpha:gr,luminance:br,"luminance alpha":xr,rgb:yr,rgba:vr,rgba4:_r,"rgb5 a1":wr,rgb565:Cr},v={};n.ext_srgb&&(m.srgb=Er,m.srgba=Pr),n.oes_texture_float&&(p.float32=p.float=Qr),n.oes_texture_half_float&&(p.float16=p["half float"]=Lr),n.webgl_depth_texture&&(e(m,{depth:zr,"depth stencil":Or}),e(p,{uint16:Hr,uint32:Zr,"depth stencil":Mr})),n.webgl_compressed_texture_s3tc&&e(v,{"rgb s3tc dxt1":Tr,"rgba s3tc dxt1":Dr,"rgba s3tc dxt3":Rr,"rgba s3tc dxt5":Ir}),n.webgl_compressed_texture_atc&&e(v,{"rgb atc":Fr,"rgba atc explicit alpha":Br,"rgba atc interpolated alpha":jr}),n.webgl_compressed_texture_pvrtc&&e(v,{"rgb pvrtc 4bppv1":Vr,"rgb pvrtc 2bppv1":Nr,"rgba pvrtc 4bppv1":Ur,"rgba pvrtc 2bppv1":Gr}),n.webgl_compressed_texture_etc1&&(v["rgb etc1"]=Wr);var g=Array.prototype.slice.call(r.getParameter(hr));Object.keys(v).forEach((function(t){var e=v[t];g.indexOf(e)>=0&&(m[t]=e)}));var y=Object.keys(m);i.textureFormats=y;var b=[];Object.keys(m).forEach((function(t){var e=m[t];b[e]=t}));var x=[];Object.keys(p).forEach((function(t){var e=p[t];x[e]=t}));var _=[];Object.keys(f).forEach((function(t){var e=f[t];_[e]=t}));var w=[];Object.keys(h).forEach((function(t){var e=h[t];w[e]=t}));var C=[];Object.keys(c).forEach((function(t){var e=c[t];C[e]=t}));var S=y.reduce((function(t,e){var r=m[e];return r===br||r===gr||r===br||r===xr||r===zr||r===Or||n.ext_srgb&&(r===Er||r===Pr)?t[r]=r:r===wr||e.indexOf("rgba")>=0?t[r]=vr:t[r]=yr,t}),{});function k(){this.internalformat=vr,this.format=vr,this.type=qr,this.compressed=!1,this.premultiplyAlpha=!1,this.flipY=!1,this.unpackAlignment=1,this.colorSpace=yn,this.width=0,this.height=0,this.channels=0}function A(t,e){t.internalformat=e.internalformat,t.format=e.format,t.type=e.type,t.compressed=e.compressed,t.premultiplyAlpha=e.premultiplyAlpha,t.flipY=e.flipY,t.unpackAlignment=e.unpackAlignment,t.colorSpace=e.colorSpace,t.width=e.width,t.height=e.height,t.channels=e.channels}function M(t,e){if("object"==typeof e&&e){if("premultiplyAlpha"in e&&(rt.type(e.premultiplyAlpha,"boolean","invalid premultiplyAlpha"),t.premultiplyAlpha=e.premultiplyAlpha),"flipY"in e&&(rt.type(e.flipY,"boolean","invalid texture flip"),t.flipY=e.flipY),"alignment"in e&&(rt.oneOf(e.alignment,[1,2,4,8],"invalid texture unpack alignment"),t.unpackAlignment=e.alignment),"colorSpace"in e&&(rt.parameter(e.colorSpace,d,"invalid colorSpace"),t.colorSpace=d[e.colorSpace]),"type"in e){var r=e.type;rt(n.oes_texture_float||!("float"===r||"float32"===r),"you must enable the OES_texture_float extension in order to use floating point textures."),rt(n.oes_texture_half_float||!("half float"===r||"float16"===r),"you must enable the OES_texture_half_float extension in order to use 16-bit floating point textures."),rt(n.webgl_depth_texture||!("uint16"===r||"uint32"===r||"depth stencil"===r),"you must enable the WEBGL_depth_texture extension in order to use depth/stencil textures."),rt.parameter(r,p,"invalid texture type"),t.type=p[r]}var o=t.width,a=t.height,s=t.channels,l=!1;"shape"in e?(rt(Array.isArray(e.shape)&&e.shape.length>=2,"shape must be an array"),o=e.shape[0],a=e.shape[1],3===e.shape.length&&(s=e.shape[2],rt(s>0&&s<=4,"invalid number of channels"),l=!0),rt(o>=0&&o<=i.maxTextureSize,"invalid width"),rt(a>=0&&a<=i.maxTextureSize,"invalid height")):("radius"in e&&(o=a=e.radius,rt(o>=0&&o<=i.maxTextureSize,"invalid radius")),"width"in e&&(o=e.width,rt(o>=0&&o<=i.maxTextureSize,"invalid width")),"height"in e&&(a=e.height,rt(a>=0&&a<=i.maxTextureSize,"invalid height")),"channels"in e&&(s=e.channels,rt(s>0&&s<=4,"invalid number of channels"),l=!0)),t.width=0|o,t.height=0|a,t.channels=0|s;var u=!1;if("format"in e){var c=e.format;rt(n.webgl_depth_texture||!("depth"===c||"depth stencil"===c),"you must enable the WEBGL_depth_texture extension in order to use depth/stencil textures."),rt.parameter(c,m,"invalid texture format");var f=t.internalformat=m[c];t.format=S[f],c in p&&("type"in e||(t.type=p[c])),c in v&&(t.compressed=!0),u=!0}!l&&u?t.channels=wn[t.format]:l&&!u?t.channels!==_n[t.format]&&(t.format=t.internalformat=_n[t.channels]):u&&l&&rt(t.channels===wn[t.format],"number of channels inconsistent with specified format")}}function z(t){r.pixelStorei(mn,t.flipY),r.pixelStorei(vn,t.premultiplyAlpha),r.pixelStorei(gn,t.colorSpace),r.pixelStorei(pn,t.unpackAlignment)}function O(){k.call(this),this.xOffset=0,this.yOffset=0,this.data=null,this.needsFree=!1,this.element=null,this.needsCopy=!1}function E(e,r){var n=null;if(Un(r)?n=r:r&&(rt.type(r,"object","invalid pixel data type"),M(e,r),"x"in r&&(e.xOffset=0|r.x),"y"in r&&(e.yOffset=0|r.y),Un(r.data)&&(n=r.data)),rt(!e.compressed||n instanceof Uint8Array,"compressed texture data must be stored in a uint8array"),r.copy){rt(!n,"can not specify copy and data field for the same texture");var o=a.viewportWidth,s=a.viewportHeight;e.width=e.width||o-e.xOffset,e.height=e.height||s-e.yOffset,e.needsCopy=!0,rt(e.xOffset>=0&&e.xOffset<o&&e.yOffset>=0&&e.yOffset<s&&e.width>0&&e.width<=o&&e.height>0&&e.height<=s,"copy texture read out of bounds")}else if(n){if(t(n))e.channels=e.channels||4,e.data=n,"type"in r||e.type!==qr||(e.type=Gn(n));else if(Tn(n))e.channels=e.channels||4,Wn(e,n),e.alignment=1,e.needsFree=!0;else if(Ce(n)){var l=n.data;Array.isArray(l)||e.type!==qr||(e.type=Gn(l));var u,c,f,h,d,p,m=n.shape,v=n.stride;3===m.length?(f=m[2],p=v[2]):(rt(2===m.length,"invalid ndarray pixel data, must be 2 or 3D"),f=1,p=1),u=m[0],c=m[1],h=v[0],d=v[1],e.alignment=1,e.width=u,e.height=c,e.channels=f,e.format=e.internalformat=_n[f],e.needsFree=!0,Zn(e,l,h,d,p,n.offset)}else if(In(n)||Fn(n)||Bn(n))In(n)||Fn(n)?e.element=n:e.element=n.canvas,e.width=e.element.width,e.height=e.element.height,e.channels=4;else if(jn(n))e.element=n,e.width=n.width,e.height=n.height,e.channels=4;else if(Vn(n))e.element=n,e.width=n.naturalWidth,e.height=n.naturalHeight,e.channels=4;else if(Nn(n))e.element=n,e.width=n.videoWidth,e.height=n.videoHeight,e.channels=4;else if(Dn(n)){var g=e.width||n[0].length,y=e.height||n.length,b=e.channels;b=cr(n[0][0])?b||n[0][0].length:b||1;for(var x=ke.shape(n),_=1,w=0;w<x.length;++w)_*=x[w];var C=qn(e,_);ke.flatten(n,x,"",C),Hn(e,C),e.alignment=1,e.width=g,e.height=y,e.channels=b,e.format=e.internalformat=_n[b],e.needsFree=!0}}else e.width=e.width||1,e.height=e.height||1,e.channels=e.channels||4;e.type===Qr?rt(i.extensions.indexOf("oes_texture_float")>=0,"oes_texture_float extension not enabled"):e.type===Lr&&rt(i.extensions.indexOf("oes_texture_half_float")>=0,"oes_texture_half_float extension not enabled")}function P(t,e,n){var i=t.element,a=t.data,s=t.internalformat,l=t.format,u=t.type,c=t.width,f=t.height;z(t),i?r.texImage2D(e,n,l,l,u,i):t.compressed?r.compressedTexImage2D(e,n,s,c,f,0,a):t.needsCopy?(o(),r.copyTexImage2D(e,n,l,t.xOffset,t.yOffset,c,f,0)):r.texImage2D(e,n,l,c,f,0,l,u,a||null)}function L(t,e,n,i,a){var s=t.element,l=t.data,u=t.internalformat,c=t.format,f=t.type,h=t.width,d=t.height;z(t),s?r.texSubImage2D(e,a,n,i,c,f,s):t.compressed?r.compressedTexSubImage2D(e,a,n,i,u,h,d,l):t.needsCopy?(o(),r.copyTexSubImage2D(e,a,n,i,t.xOffset,t.yOffset,h,d)):r.texSubImage2D(e,a,n,i,h,d,c,f,l)}var T=[];function D(){return T.pop()||new O}function R(t){t.needsFree&&Ft.freeType(t.data),O.call(t),T.push(t)}function I(){k.call(this),this.genMipmaps=!1,this.mipmapHint=cn,this.mipmask=0,this.images=Array(16)}function F(t,e,r){var n=t.images[0]=D();t.mipmask=1,n.width=t.width=e,n.height=t.height=r,n.channels=t.channels=4}function B(t,e){var r=null;if(Un(e))A(r=t.images[0]=D(),t),E(r,e),t.mipmask=1;else if(M(t,e),Array.isArray(e.mipmap))for(var n=e.mipmap,i=0;i<n.length;++i)A(r=t.images[i]=D(),t),r.width>>=i,r.height>>=i,E(r,n[i]),t.mipmask|=1<<i;else A(r=t.images[0]=D(),t),E(r,e),t.mipmask=1;A(t,t.images[0]),!t.compressed||t.internalformat!==Tr&&t.internalformat!==Dr&&t.internalformat!==Rr&&t.internalformat!==Ir||rt(t.width%4==0&&t.height%4==0,"for compressed texture formats, mipmap level 0 must have width and height that are a multiple of 4")}function j(t,e){for(var r=t.images,n=0;n<r.length;++n){if(!r[n])return;P(r[n],e,n)}}var V=[];function N(){var t=V.pop()||new I;k.call(t),t.mipmask=0;for(var e=0;e<16;++e)t.images[e]=null;return t}function U(t){for(var e=t.images,r=0;r<e.length;++r)e[r]&&R(e[r]),e[r]=null;V.push(t)}function G(){this.minFilter=rn,this.magFilter=rn,this.wrapS=Kr,this.wrapT=Kr,this.anisotropic=1,this.genMipmaps=!1,this.mipmapHint=cn}function W(t,e){if("min"in e){var r=e.min;rt.parameter(r,h),t.minFilter=h[r],xn.indexOf(t.minFilter)>=0&&!("faces"in e)&&(t.genMipmaps=!0)}if("mag"in e){var n=e.mag;rt.parameter(n,f),t.magFilter=f[n]}var o=t.wrapS,a=t.wrapT;if("wrap"in e){var s=e.wrap;"string"==typeof s?(rt.parameter(s,c),o=a=c[s]):Array.isArray(s)&&(rt.parameter(s[0],c),rt.parameter(s[1],c),o=c[s[0]],a=c[s[1]])}else{if("wrapS"in e){var l=e.wrapS;rt.parameter(l,c),o=c[l]}if("wrapT"in e){var d=e.wrapT;rt.parameter(d,c),a=c[d]}}if(t.wrapS=o,t.wrapT=a,"anisotropic"in e){var p=e.anisotropic;rt("number"==typeof p&&p>=1&&p<=i.maxAnisotropic,"aniso samples must be between 1 and "),t.anisotropic=e.anisotropic}if("mipmap"in e){var m=!1;switch(typeof e.mipmap){case"string":rt.parameter(e.mipmap,u,"invalid mipmap hint"),t.mipmapHint=u[e.mipmap],t.genMipmaps=!0,m=!0;break;case"boolean":m=t.genMipmaps=e.mipmap;break;case"object":rt(Array.isArray(e.mipmap),"invalid mipmap type"),t.genMipmaps=!1,m=!0;break;default:rt.raise("invalid mipmap type")}m&&!("min"in e)&&(t.minFilter=on)}}function q(t,e){r.texParameteri(e,en,t.minFilter),r.texParameteri(e,tn,t.magFilter),r.texParameteri(e,Xr,t.wrapS),r.texParameteri(e,Yr,t.wrapT),n.ext_texture_filter_anisotropic&&r.texParameteri(e,dn,t.anisotropic),t.genMipmaps&&(r.hint(un,t.mipmapHint),r.generateMipmap(e))}var H=0,Z={},Q=i.maxTextureUnits,X=Array(Q).map((function(){return null}));function Y(t){k.call(this),this.mipmask=0,this.internalformat=vr,this.id=H++,this.refCount=1,this.target=t,this.texture=r.createTexture(),this.unit=-1,this.bindCount=0,this.texInfo=new G,l.profile&&(this.stats={size:0})}function J(t){r.activeTexture(bn),r.bindTexture(t.target,t.texture)}function K(){var t=X[0];t?r.bindTexture(t.target,t.texture):r.bindTexture(dr,null)}function $(t){var e=t.texture;rt(e,"must not double destroy texture");var n=t.unit,i=t.target;n>=0&&(r.activeTexture(bn+n),r.bindTexture(i,null),X[n]=null),r.deleteTexture(e),t.texture=null,t.params=null,t.pixels=null,t.refCount=0,delete Z[t.id],s.textureCount--}function tt(t,e){var n=new Y(dr);function o(t,e){var r=n.texInfo;G.call(r);var a=N();return"number"==typeof t?F(a,0|t,"number"==typeof e?0|e:0|t):t?(rt.type(t,"object","invalid arguments to regl.texture"),W(r,t),B(a,t)):F(a,1,1),r.genMipmaps&&(a.mipmask=(a.width<<1)-1),n.mipmask=a.mipmask,A(n,a),rt.texture2D(r,a,i),n.internalformat=a.internalformat,o.width=a.width,o.height=a.height,J(n),j(a,dr),q(r,dr),K(),U(a),l.profile&&(n.stats.size=Qn(n.internalformat,n.type,a.width,a.height,r.genMipmaps,!1)),o.format=b[n.internalformat],o.type=x[n.type],o.mag=_[r.magFilter],o.min=w[r.minFilter],o.wrapS=C[r.wrapS],o.wrapT=C[r.wrapT],o}function a(t,e,r,i){rt(!!t,"must specify image data");var a=0|e,s=0|r,l=0|i,u=D();return A(u,n),u.width=0,u.height=0,E(u,t),u.width=u.width||(n.width>>l)-a,u.height=u.height||(n.height>>l)-s,rt(n.type===u.type&&n.format===u.format&&n.internalformat===u.internalformat,"incompatible format for texture.subimage"),rt(a>=0&&s>=0&&a+u.width<=n.width&&s+u.height<=n.height,"texture.subimage write out of bounds"),rt(n.mipmask&1<<l,"missing mipmap data"),rt(u.data||u.element||u.needsCopy,"missing image data"),J(n),L(u,dr,a,s,l),K(),R(u),o}function u(t,e){var i=0|t,a=0|e||i;if(i===n.width&&a===n.height)return o;o.width=n.width=i,o.height=n.height=a,J(n);for(var s=0;n.mipmask>>s;++s){var u=i>>s,c=a>>s;if(!u||!c)break;r.texImage2D(dr,s,n.format,u,c,0,n.format,n.type,null)}return K(),l.profile&&(n.stats.size=Qn(n.internalformat,n.type,i,a,!1,!1)),o}return Z[n.id]=n,s.textureCount++,o(t,e),o.subimage=a,o.resize=u,o._reglType="texture2d",o._texture=n,l.profile&&(o.stats=n.stats),o.destroy=function(){n.decRef()},o}function et(t,e,n,o,a,u){var c=new Y(pr);Z[c.id]=c,s.cubeCount++;var f=new Array(6);function h(t,e,r,n,o,a){var s,u=c.texInfo;for(G.call(u),s=0;s<6;++s)f[s]=N();if("number"!=typeof t&&t)if("object"==typeof t)if(e)B(f[0],t),B(f[1],e),B(f[2],r),B(f[3],n),B(f[4],o),B(f[5],a);else if(W(u,t),M(c,t),"faces"in t){var d=t.faces;for(rt(Array.isArray(d)&&6===d.length,"cube faces must be a length 6 array"),s=0;s<6;++s)rt("object"==typeof d[s]&&!!d[s],"invalid input for cube map face"),A(f[s],c),B(f[s],d[s])}else for(s=0;s<6;++s)B(f[s],t);else rt.raise("invalid arguments to cube map");else{var p=0|t||1;for(s=0;s<6;++s)F(f[s],p,p)}for(A(c,f[0]),rt.optional((function(){i.npotTextureCube||rt(fr(c.width)&&fr(c.height),"your browser does not support non power or two texture dimensions")})),u.genMipmaps?c.mipmask=(f[0].width<<1)-1:c.mipmask=f[0].mipmask,rt.textureCube(c,u,f,i),c.internalformat=f[0].internalformat,h.width=f[0].width,h.height=f[0].height,J(c),s=0;s<6;++s)j(f[s],mr+s);for(q(u,pr),K(),l.profile&&(c.stats.size=Qn(c.internalformat,c.type,h.width,h.height,u.genMipmaps,!0)),h.format=b[c.internalformat],h.type=x[c.type],h.mag=_[u.magFilter],h.min=w[u.minFilter],h.wrapS=C[u.wrapS],h.wrapT=C[u.wrapT],s=0;s<6;++s)U(f[s]);return h}function d(t,e,r,n,i){rt(!!e,"must specify image data"),rt("number"==typeof t&&t===(0|t)&&t>=0&&t<6,"invalid face");var o=0|r,a=0|n,s=0|i,l=D();return A(l,c),l.width=0,l.height=0,E(l,e),l.width=l.width||(c.width>>s)-o,l.height=l.height||(c.height>>s)-a,rt(c.type===l.type&&c.format===l.format&&c.internalformat===l.internalformat,"incompatible format for texture.subimage"),rt(o>=0&&a>=0&&o+l.width<=c.width&&a+l.height<=c.height,"texture.subimage write out of bounds"),rt(c.mipmask&1<<s,"missing mipmap data"),rt(l.data||l.element||l.needsCopy,"missing image data"),J(c),L(l,mr+t,o,a,s),K(),R(l),h}function p(t){var e=0|t;if(e!==c.width){h.width=c.width=e,h.height=c.height=e,J(c);for(var n=0;n<6;++n)for(var i=0;c.mipmask>>i;++i)r.texImage2D(mr+n,i,c.format,e>>i,e>>i,0,c.format,c.type,null);return K(),l.profile&&(c.stats.size=Qn(c.internalformat,c.type,h.width,h.height,!1,!0)),h}}return h(t,e,n,o,a,u),h.subimage=d,h.resize=p,h._reglType="textureCube",h._texture=c,l.profile&&(h.stats=c.stats),h.destroy=function(){c.decRef()},h}function nt(){for(var t=0;t<Q;++t)r.activeTexture(bn+t),r.bindTexture(dr,null),X[t]=null;Se(Z).forEach($),s.cubeCount=0,s.textureCount=0}function it(){for(var t=0;t<Q;++t){var e=X[t];e&&(e.bindCount=0,e.unit=-1,X[t]=null)}Se(Z).forEach((function(t){t.texture=r.createTexture(),r.bindTexture(t.target,t.texture);for(var e=0;e<32;++e)if(0!=(t.mipmask&1<<e))if(t.target===dr)r.texImage2D(dr,e,t.internalformat,t.width>>e,t.height>>e,0,t.internalformat,t.type,null);else for(var n=0;n<6;++n)r.texImage2D(mr+n,e,t.internalformat,t.width>>e,t.height>>e,0,t.internalformat,t.type,null);q(t.texInfo,t.target)}))}function ot(){for(var t=0;t<Q;++t){var e=X[t];e&&(e.bindCount=0,e.unit=-1,X[t]=null),r.activeTexture(bn+t),r.bindTexture(dr,null),r.bindTexture(pr,null)}}return e(Y.prototype,{bind:function(){var t=this;t.bindCount+=1;var e=t.unit;if(e<0){for(var n=0;n<Q;++n){var i=X[n];if(i){if(i.bindCount>0)continue;i.unit=-1}X[n]=t,e=n;break}e>=Q&&rt.raise("insufficient number of texture units"),l.profile&&s.maxTextureUnits<e+1&&(s.maxTextureUnits=e+1),t.unit=e,r.activeTexture(bn+e),r.bindTexture(t.target,t.texture)}return e},unbind:function(){this.bindCount-=1},decRef:function(){--this.refCount<=0&&$(this)}}),l.profile&&(s.getTotalTextureSize=function(){var t=0;return Object.keys(Z).forEach((function(e){t+=Z[e].stats.size})),t}),{create2D:tt,createCube:et,clear:nt,getTexture:function(t){return null},restore:it,refresh:ot}}Ln[_r]=2,Ln[wr]=2,Ln[Cr]=2,Ln[Or]=4,Ln[Tr]=.5,Ln[Dr]=.5,Ln[Rr]=1,Ln[Ir]=1,Ln[Fr]=.5,Ln[Br]=1,Ln[jr]=1,Ln[Vr]=.5,Ln[Nr]=.25,Ln[Ur]=.5,Ln[Gr]=.25,Ln[Wr]=.5;var Yn=36161,Jn=32854,Kn=32855,$n=36194,ti=33189,ei=36168,ri=34041,ni=35907,ii=34836,oi=34842,ai=34843,si=[];function li(t,e,r){return si[t]*e*r}si[Jn]=2,si[Kn]=2,si[$n]=2,si[ti]=2,si[ei]=1,si[ri]=4,si[ni]=4,si[ii]=16,si[oi]=8,si[ai]=6;var ui=function(t,e,r,n,i){var o={rgba4:Jn,rgb565:$n,"rgb5 a1":Kn,depth:ti,stencil:ei,"depth stencil":ri};e.ext_srgb&&(o.srgba=ni),e.ext_color_buffer_half_float&&(o.rgba16f=oi,o.rgb16f=ai),e.webgl_color_buffer_float&&(o.rgba32f=ii);var a=[];Object.keys(o).forEach((function(t){var e=o[t];a[e]=t}));var s=0,l={};function u(t){this.id=s++,this.refCount=1,this.renderbuffer=t,this.format=Jn,this.width=0,this.height=0,i.profile&&(this.stats={size:0})}function c(e){var r=e.renderbuffer;rt(r,"must not double destroy renderbuffer"),t.bindRenderbuffer(Yn,null),t.deleteRenderbuffer(r),e.renderbuffer=null,e.refCount=0,delete l[e.id],n.renderbufferCount--}function f(e,s){var c=new u(t.createRenderbuffer());function f(e,n){var s=0,l=0,u=Jn;if("object"==typeof e&&e){var h=e;if("shape"in h){var d=h.shape;rt(Array.isArray(d)&&d.length>=2,"invalid renderbuffer shape"),s=0|d[0],l=0|d[1]}else"radius"in h&&(s=l=0|h.radius),"width"in h&&(s=0|h.width),"height"in h&&(l=0|h.height);"format"in h&&(rt.parameter(h.format,o,"invalid renderbuffer format"),u=o[h.format])}else"number"==typeof e?(s=0|e,l="number"==typeof n?0|n:s):e?rt.raise("invalid arguments to renderbuffer constructor"):s=l=1;if(rt(s>0&&l>0&&s<=r.maxRenderbufferSize&&l<=r.maxRenderbufferSize,"invalid renderbuffer size"),s!==c.width||l!==c.height||u!==c.format)return f.width=c.width=s,f.height=c.height=l,c.format=u,t.bindRenderbuffer(Yn,c.renderbuffer),t.renderbufferStorage(Yn,u,s,l),rt(0===t.getError(),"invalid render buffer format"),i.profile&&(c.stats.size=li(c.format,c.width,c.height)),f.format=a[c.format],f}function h(e,n){var o=0|e,a=0|n||o;return o===c.width&&a===c.height||(rt(o>0&&a>0&&o<=r.maxRenderbufferSize&&a<=r.maxRenderbufferSize,"invalid renderbuffer size"),f.width=c.width=o,f.height=c.height=a,t.bindRenderbuffer(Yn,c.renderbuffer),t.renderbufferStorage(Yn,c.format,o,a),rt(0===t.getError(),"invalid render buffer format"),i.profile&&(c.stats.size=li(c.format,c.width,c.height))),f}return l[c.id]=c,n.renderbufferCount++,f(e,s),f.resize=h,f._reglType="renderbuffer",f._renderbuffer=c,i.profile&&(f.stats=c.stats),f.destroy=function(){c.decRef()},f}function h(){Se(l).forEach((function(e){e.renderbuffer=t.createRenderbuffer(),t.bindRenderbuffer(Yn,e.renderbuffer),t.renderbufferStorage(Yn,e.format,e.width,e.height)})),t.bindRenderbuffer(Yn,null)}return u.prototype.decRef=function(){--this.refCount<=0&&c(this)},i.profile&&(n.getTotalRenderbufferSize=function(){var t=0;return Object.keys(l).forEach((function(e){t+=l[e].stats.size})),t}),{create:f,clear:function(){Se(l).forEach(c)},restore:h}},ci=36160,fi=36161,hi=3553,di=34069,pi=36064,mi=36096,vi=36128,gi=33306,yi=36053,bi=36054,xi=36055,_i=36057,wi=36061,Ci=36193,Si=5121,ki=5126,Ai=6407,Mi=6408,zi=6402,Oi=[Ai,Mi],Ei=[];Ei[Mi]=4,Ei[Ai]=3;var Pi=[];Pi[Si]=1,Pi[ki]=4,Pi[Ci]=2;var Li=33189,Ti=36168,Di=34041,Ri=[32854,32855,36194,35907,34842,34843,34836],Ii={};function Fi(t,r,n,i,o,a){var s={cur:null,next:null,dirty:!1,setFBO:null},l=["rgba"],u=["rgba4","rgb565","rgb5 a1"];r.ext_srgb&&u.push("srgba"),r.ext_color_buffer_half_float&&u.push("rgba16f","rgb16f"),r.webgl_color_buffer_float&&u.push("rgba32f");var c=["uint8"];function f(t,e,r){this.target=t,this.texture=e,this.renderbuffer=r;var n=0,i=0;e?(n=e.width,i=e.height):r&&(n=r.width,i=r.height),this.width=n,this.height=i}function h(t){t&&(t.texture&&t.texture._texture.decRef(),t.renderbuffer&&t.renderbuffer._renderbuffer.decRef())}function d(t,e,r){if(t)if(t.texture){var n=t.texture._texture,i=Math.max(1,n.width),o=Math.max(1,n.height);rt(i===e&&o===r,"inconsistent width/height for supplied texture"),n.refCount+=1}else{var a=t.renderbuffer._renderbuffer;rt(a.width===e&&a.height===r,"inconsistent width/height for renderbuffer"),a.refCount+=1}}function p(e,r){r&&(r.texture?t.framebufferTexture2D(ci,e,r.target,r.texture._texture.texture,0):t.framebufferRenderbuffer(ci,e,fi,r.renderbuffer._renderbuffer.renderbuffer))}function m(t){var e=hi,r=null,n=null,i=t;"object"==typeof t&&(i=t.data,"target"in t&&(e=0|t.target)),rt.type(i,"function","invalid attachment data");var o=i._reglType;return"texture2d"===o?(r=i,rt(e===hi)):"textureCube"===o?(r=i,rt(e>=di&&e<di+6,"invalid cube map target")):"renderbuffer"===o?(n=i,e=fi):rt.raise("invalid regl object for attachment"),new f(e,r,n)}function v(t,e,r,n,a){if(r){var s=i.create2D({width:t,height:e,format:n,type:a});return s._texture.refCount=0,new f(hi,s,null)}var l=o.create({width:t,height:e,format:n});return l._renderbuffer.refCount=0,new f(fi,null,l)}function g(t){return t&&(t.texture||t.renderbuffer)}function y(t,e,r){t&&(t.texture?t.texture.resize(e,r):t.renderbuffer&&t.renderbuffer.resize(e,r),t.width=e,t.height=r)}r.oes_texture_half_float&&c.push("half float","float16"),r.oes_texture_float&&c.push("float","float32");var b=0,x={};function _(){this.id=b++,x[this.id]=this,this.framebuffer=t.createFramebuffer(),this.width=0,this.height=0,this.colorAttachments=[],this.depthAttachment=null,this.stencilAttachment=null,this.depthStencilAttachment=null}function w(t){t.colorAttachments.forEach(h),h(t.depthAttachment),h(t.stencilAttachment),h(t.depthStencilAttachment)}function C(e){var r=e.framebuffer;rt(r,"must not double destroy framebuffer"),t.deleteFramebuffer(r),e.framebuffer=null,a.framebufferCount--,delete x[e.id]}function S(e){var r;t.bindFramebuffer(ci,e.framebuffer);var i=e.colorAttachments;for(r=0;r<i.length;++r)p(pi+r,i[r]);for(r=i.length;r<n.maxColorAttachments;++r)t.framebufferTexture2D(ci,pi+r,hi,null,0);t.framebufferTexture2D(ci,gi,hi,null,0),t.framebufferTexture2D(ci,mi,hi,null,0),t.framebufferTexture2D(ci,vi,hi,null,0),p(mi,e.depthAttachment),p(vi,e.stencilAttachment),p(gi,e.depthStencilAttachment);var o=t.checkFramebufferStatus(ci);t.isContextLost()||o===yi||rt.raise("framebuffer configuration not supported, status = "+Ii[o]),t.bindFramebuffer(ci,s.next?s.next.framebuffer:null),s.cur=s.next,t.getError()}function k(t,i){var o=new _;function f(t,e){var i;rt(s.next!==o,"can not update framebuffer which is currently in use");var a=0,h=0,p=!0,y=!0,b=null,x=!0,_="rgba",C="uint8",k=1,A=null,M=null,z=null,O=!1;if("number"==typeof t)a=0|t,h=0|e||a;else if(t){rt.type(t,"object","invalid arguments for framebuffer");var E=t;if("shape"in E){var P=E.shape;rt(Array.isArray(P)&&P.length>=2,"invalid shape for framebuffer"),a=P[0],h=P[1]}else"radius"in E&&(a=h=E.radius),"width"in E&&(a=E.width),"height"in E&&(h=E.height);("color"in E||"colors"in E)&&(b=E.color||E.colors,Array.isArray(b)&&rt(1===b.length||r.webgl_draw_buffers,"multiple render targets not supported")),b||("colorCount"in E&&(k=0|E.colorCount,rt(k>0,"invalid color buffer count")),"colorTexture"in E&&(x=!!E.colorTexture,_="rgba4"),"colorType"in E&&(C=E.colorType,x?(rt(r.oes_texture_float||!("float"===C||"float32"===C),"you must enable OES_texture_float in order to use floating point framebuffer objects"),rt(r.oes_texture_half_float||!("half float"===C||"float16"===C),"you must enable OES_texture_half_float in order to use 16-bit floating point framebuffer objects")):"half float"===C||"float16"===C?(rt(r.ext_color_buffer_half_float,"you must enable EXT_color_buffer_half_float to use 16-bit render buffers"),_="rgba16f"):"float"!==C&&"float32"!==C||(rt(r.webgl_color_buffer_float,"you must enable WEBGL_color_buffer_float in order to use 32-bit floating point renderbuffers"),_="rgba32f"),rt.oneOf(C,c,"invalid color type")),"colorFormat"in E&&(_=E.colorFormat,l.indexOf(_)>=0?x=!0:u.indexOf(_)>=0?x=!1:rt.optional((function(){x?rt.oneOf(E.colorFormat,l,"invalid color format for texture"):rt.oneOf(E.colorFormat,u,"invalid color format for renderbuffer")})))),("depthTexture"in E||"depthStencilTexture"in E)&&(O=!(!E.depthTexture&&!E.depthStencilTexture),rt(!O||r.webgl_depth_texture,"webgl_depth_texture extension not supported")),"depth"in E&&("boolean"==typeof E.depth?p=E.depth:(A=E.depth,y=!1)),"stencil"in E&&("boolean"==typeof E.stencil?y=E.stencil:(M=E.stencil,p=!1)),"depthStencil"in E&&("boolean"==typeof E.depthStencil?p=y=E.depthStencil:(z=E.depthStencil,p=!1,y=!1))}else a=h=1;var L=null,T=null,D=null,R=null;if(Array.isArray(b))L=b.map(m);else if(b)L=[m(b)];else for(L=new Array(k),i=0;i<k;++i)L[i]=v(a,h,x,_,C);rt(r.webgl_draw_buffers||L.length<=1,"you must enable the WEBGL_draw_buffers extension in order to use multiple color buffers."),rt(L.length<=n.maxColorAttachments,"too many color attachments, not supported"),a=a||L[0].width,h=h||L[0].height,A?T=m(A):p&&!y&&(T=v(a,h,O,"depth","uint32")),M?D=m(M):y&&!p&&(D=v(a,h,!1,"stencil","uint8")),z?R=m(z):!A&&!M&&y&&p&&(R=v(a,h,O,"depth stencil","depth stencil")),rt(!!A+!!M+!!z<=1,"invalid framebuffer configuration, can specify exactly one depth/stencil attachment");var I=null;for(i=0;i<L.length;++i)if(d(L[i],a,h),rt(!L[i]||L[i].texture&&Oi.indexOf(L[i].texture._texture.format)>=0||L[i].renderbuffer&&Ri.indexOf(L[i].renderbuffer._renderbuffer.format)>=0,"framebuffer color attachment "+i+" is invalid"),L[i]&&L[i].texture){var F=Ei[L[i].texture._texture.format]*Pi[L[i].texture._texture.type];null===I?I=F:rt(I===F,"all color attachments much have the same number of bits per pixel.")}return d(T,a,h),rt(!T||T.texture&&T.texture._texture.format===zi||T.renderbuffer&&T.renderbuffer._renderbuffer.format===Li,"invalid depth attachment for framebuffer object"),d(D,a,h),rt(!D||D.renderbuffer&&D.renderbuffer._renderbuffer.format===Ti,"invalid stencil attachment for framebuffer object"),d(R,a,h),rt(!R||R.texture&&R.texture._texture.format===Di||R.renderbuffer&&R.renderbuffer._renderbuffer.format===Di,"invalid depth-stencil attachment for framebuffer object"),w(o),o.width=a,o.height=h,o.colorAttachments=L,o.depthAttachment=T,o.stencilAttachment=D,o.depthStencilAttachment=R,f.color=L.map(g),f.depth=g(T),f.stencil=g(D),f.depthStencil=g(R),f.width=o.width,f.height=o.height,S(o),f}function h(t,e){rt(s.next!==o,"can not resize a framebuffer which is currently in use");var r=Math.max(0|t,1),n=Math.max(0|e||r,1);if(r===o.width&&n===o.height)return f;for(var i=o.colorAttachments,a=0;a<i.length;++a)y(i[a],r,n);return y(o.depthAttachment,r,n),y(o.stencilAttachment,r,n),y(o.depthStencilAttachment,r,n),o.width=f.width=r,o.height=f.height=n,S(o),f}return a.framebufferCount++,f(t,i),e(f,{resize:h,_reglType:"framebuffer",_framebuffer:o,destroy:function(){C(o),w(o)},use:function(t){s.setFBO({framebuffer:f},t)}})}function A(t){var o=Array(6);function a(t){var n;rt(o.indexOf(s.next)<0,"can not update framebuffer which is currently in use");var u,f={color:null},h=0,d=null,p="rgba",m="uint8",v=1;if("number"==typeof t)h=0|t;else if(t){rt.type(t,"object","invalid arguments for framebuffer");var g=t;if("shape"in g){var y=g.shape;rt(Array.isArray(y)&&y.length>=2,"invalid shape for framebuffer"),rt(y[0]===y[1],"cube framebuffer must be square"),h=y[0]}else"radius"in g&&(h=0|g.radius),"width"in g?(h=0|g.width,"height"in g&&rt(g.height===h,"must be square")):"height"in g&&(h=0|g.height);("color"in g||"colors"in g)&&(d=g.color||g.colors,Array.isArray(d)&&rt(1===d.length||r.webgl_draw_buffers,"multiple render targets not supported")),d||("colorCount"in g&&(v=0|g.colorCount,rt(v>0,"invalid color buffer count")),"colorType"in g&&(rt.oneOf(g.colorType,c,"invalid color type"),m=g.colorType),"colorFormat"in g&&(p=g.colorFormat,rt.oneOf(g.colorFormat,l,"invalid color format for texture"))),"depth"in g&&(f.depth=g.depth),"stencil"in g&&(f.stencil=g.stencil),"depthStencil"in g&&(f.depthStencil=g.depthStencil)}else h=1;if(d)if(Array.isArray(d))for(u=[],n=0;n<d.length;++n)u[n]=d[n];else u=[d];else{u=Array(v);var b={radius:h,format:p,type:m};for(n=0;n<v;++n)u[n]=i.createCube(b)}for(f.color=Array(u.length),n=0;n<u.length;++n){var x=u[n];rt("function"==typeof x&&"textureCube"===x._reglType,"invalid cube map"),h=h||x.width,rt(x.width===h&&x.height===h,"invalid cube map shape"),f.color[n]={target:di,data:u[n]}}for(n=0;n<6;++n){for(var _=0;_<u.length;++_)f.color[_].target=di+n;n>0&&(f.depth=o[0].depth,f.stencil=o[0].stencil,f.depthStencil=o[0].depthStencil),o[n]?o[n](f):o[n]=k(f)}return e(a,{width:h,height:h,color:u})}function u(t){var e,r=0|t;if(rt(r>0&&r<=n.maxCubeMapSize,"invalid radius for cube fbo"),r===a.width)return a;var i=a.color;for(e=0;e<i.length;++e)i[e].resize(r);for(e=0;e<6;++e)o[e].resize(r);return a.width=a.height=r,a}return a(t),e(a,{faces:o,resize:u,_reglType:"framebufferCube",destroy:function(){o.forEach((function(t){t.destroy()}))}})}function M(){s.cur=null,s.next=null,s.dirty=!0,Se(x).forEach((function(e){e.framebuffer=t.createFramebuffer(),S(e)}))}return e(s,{getFramebuffer:function(t){if("function"==typeof t&&"framebuffer"===t._reglType){var e=t._framebuffer;if(e instanceof _)return e}return null},create:k,createCube:A,clear:function(){Se(x).forEach(C)},restore:M})}Ii[yi]="complete",Ii[bi]="incomplete attachment",Ii[_i]="incomplete dimensions",Ii[xi]="incomplete, missing attachment",Ii[wi]="unsupported";var Bi=5126,ji=34962,Vi=34963,Ni=["attributes","elements","offset","count","primitive","instances"];function Ui(){this.state=0,this.x=0,this.y=0,this.z=0,this.w=0,this.buffer=null,this.size=0,this.normalized=!1,this.type=Bi,this.offset=0,this.stride=0,this.divisor=0}function Gi(e,r,n,i,o,a,s){for(var l=n.maxAttributes,u=new Array(l),c=0;c<l;++c)u[c]=new Ui;var f=0,h={},d={Record:Ui,scope:{},state:u,currentVAO:null,targetVAO:null,restore:m()?w:function(){},createVAO:C,getVAO:g,destroyBuffer:p,setVAO:m()?y:b,clear:m()?x:function(){}};function p(t){for(var r=0;r<u.length;++r){var n=u[r];n.buffer===t&&(e.disableVertexAttribArray(r),n.buffer=null)}}function m(){return r.oes_vertex_array_object}function v(){return r.angle_instanced_arrays}function g(t){return"function"==typeof t&&t._vao?t._vao:null}function y(t){if(t!==d.currentVAO){var e=m();t?e.bindVertexArrayOES(t.vao):e.bindVertexArrayOES(null),d.currentVAO=t}}function b(t){if(t!==d.currentVAO){if(t)t.bindAttrs();else{for(var r=v(),n=0;n<u.length;++n){var i=u[n];i.buffer?(e.enableVertexAttribArray(n),i.buffer.bind(),e.vertexAttribPointer(n,i.size,i.type,i.normalized,i.stride,i.offfset),r&&i.divisor&&r.vertexAttribDivisorANGLE(n,i.divisor)):(e.disableVertexAttribArray(n),e.vertexAttrib4f(n,i.x,i.y,i.z,i.w))}s.elements?e.bindBuffer(Vi,s.elements.buffer.buffer):e.bindBuffer(Vi,null)}d.currentVAO=t}}function x(){Se(h).forEach((function(t){t.destroy()}))}function _(){this.id=++f,this.attributes=[],this.elements=null,this.ownsElements=!1,this.count=0,this.offset=0,this.instances=-1,this.primitive=4;var t=m();this.vao=t?t.createVertexArrayOES():null,h[this.id]=this,this.buffers=[]}function w(){m()&&Se(h).forEach((function(t){t.refresh()}))}function C(e){var n=new _;function s(e){var i;if(Array.isArray(e))i=e,n.elements&&n.ownsElements&&n.elements.destroy(),n.elements=null,n.ownsElements=!1,n.offset=0,n.count=0,n.instances=-1,n.primitive=4;else{if(rt("object"==typeof e,"invalid arguments for create vao"),rt("attributes"in e,"must specify attributes for vao"),e.elements){var u=e.elements;n.ownsElements?"function"==typeof u&&"elements"===u._reglType?(n.elements.destroy(),n.ownsElements=!1):(n.elements(u),n.ownsElements=!1):a.getElements(e.elements)?(n.elements=e.elements,n.ownsElements=!1):(n.elements=a.create(e.elements),n.ownsElements=!0)}else n.elements=null,n.ownsElements=!1;i=e.attributes,n.offset=0,n.count=-1,n.instances=-1,n.primitive=4,n.elements&&(n.count=n.elements._elements.vertCount,n.primitive=n.elements._elements.primType),"offset"in e&&(n.offset=0|e.offset),"count"in e&&(n.count=0|e.count),"instances"in e&&(n.instances=0|e.instances),"primitive"in e&&(rt(e.primitive in He,"bad primitive type: "+e.primitive),n.primitive=He[e.primitive]),rt.optional((()=>{for(var t=Object.keys(e),r=0;r<t.length;++r)rt(Ni.indexOf(t[r])>=0,'invalid option for vao: "'+t[r]+'" valid options are '+Ni)})),rt(Array.isArray(i),"attributes must be an array")}rt(i.length<l,"too many attributes"),rt(i.length>0,"must specify at least one attribute");var c={},f=n.attributes;f.length=i.length;for(var h=0;h<i.length;++h){var d,p=i[h],m=f[h]=new Ui,v=p.data||p;Array.isArray(v)||t(v)||Ce(v)?(n.buffers[h]&&(d=n.buffers[h],t(v)&&d._buffer.byteLength>=v.byteLength?d.subdata(v):(d.destroy(),n.buffers[h]=null)),n.buffers[h]||(d=n.buffers[h]=o.create(p,ji,!1,!0)),m.buffer=o.getBuffer(d),m.size=0|m.buffer.dimension,m.normalized=!1,m.type=m.buffer.dtype,m.offset=0,m.stride=0,m.divisor=0,m.state=1,c[h]=1):o.getBuffer(p)?(m.buffer=o.getBuffer(p),m.size=0|m.buffer.dimension,m.normalized=!1,m.type=m.buffer.dtype,m.offset=0,m.stride=0,m.divisor=0,m.state=1):o.getBuffer(p.buffer)?(m.buffer=o.getBuffer(p.buffer),m.size=0|(+p.size||m.buffer.dimension),m.normalized=!!p.normalized||!1,"type"in p?(rt.parameter(p.type,Te,"invalid buffer type"),m.type=Te[p.type]):m.type=m.buffer.dtype,m.offset=0|(p.offset||0),m.stride=0|(p.stride||0),m.divisor=0|(p.divisor||0),m.state=1,rt(m.size>=1&&m.size<=4,"size must be between 1 and 4"),rt(m.offset>=0,"invalid offset"),rt(m.stride>=0&&m.stride<=255,"stride must be between 0 and 255"),rt(m.divisor>=0,"divisor must be positive"),rt(!m.divisor||!!r.angle_instanced_arrays,"ANGLE_instanced_arrays must be enabled to use divisor")):"x"in p?(rt(h>0,"first attribute must not be a constant"),m.x=+p.x||0,m.y=+p.y||0,m.z=+p.z||0,m.w=+p.w||0,m.state=2):rt(!1,"invalid attribute spec for location "+h)}for(var g=0;g<n.buffers.length;++g)!c[g]&&n.buffers[g]&&(n.buffers[g].destroy(),n.buffers[g]=null);return n.refresh(),s}return i.vaoCount+=1,s.destroy=function(){for(var t=0;t<n.buffers.length;++t)n.buffers[t]&&n.buffers[t].destroy();n.buffers.length=0,n.ownsElements&&(n.elements.destroy(),n.elements=null,n.ownsElements=!1),n.destroy()},s._vao=n,s._reglType="vao",s(e)}return _.prototype.bindAttrs=function(){for(var t=v(),r=this.attributes,n=0;n<r.length;++n){var i=r[n];i.buffer?(e.enableVertexAttribArray(n),e.bindBuffer(ji,i.buffer.buffer),e.vertexAttribPointer(n,i.size,i.type,i.normalized,i.stride,i.offset),t&&i.divisor&&t.vertexAttribDivisorANGLE(n,i.divisor)):(e.disableVertexAttribArray(n),e.vertexAttrib4f(n,i.x,i.y,i.z,i.w))}for(var o=r.length;o<l;++o)e.disableVertexAttribArray(o);var s=a.getElements(this.elements);s?e.bindBuffer(Vi,s.buffer.buffer):e.bindBuffer(Vi,null)},_.prototype.refresh=function(){var t=m();t&&(t.bindVertexArrayOES(this.vao),this.bindAttrs(),d.currentVAO=null,t.bindVertexArrayOES(null))},_.prototype.destroy=function(){if(this.vao){var t=m();this===d.currentVAO&&(d.currentVAO=null,t.bindVertexArrayOES(null)),t.deleteVertexArrayOES(this.vao),this.vao=null}this.ownsElements&&(this.elements.destroy(),this.elements=null,this.ownsElements=!1),h[this.id]&&(delete h[this.id],i.vaoCount-=1)},d}var Wi=35632,qi=35633,Hi=35718,Zi=35721;function Qi(t,r,n,i){var o={},a={};function s(t,e,r,n){this.name=t,this.id=e,this.location=r,this.info=n}function l(t,e){for(var r=0;r<t.length;++r)if(t[r].id===e.id)return void(t[r].location=e.location);t.push(e)}function u(e,n,i){var s=e===Wi?o:a,l=s[n];if(!l){var u=r.str(n);l=t.createShader(e),t.shaderSource(l,u),t.compileShader(l),rt.shaderError(t,l,u,e,i),s[n]=l}return l}var c={},f=[],h=0;function d(t,e){this.id=h++,this.fragId=t,this.vertId=e,this.program=null,this.uniforms=[],this.attributes=[],this.refCount=1,i.profile&&(this.stats={uniformsCount:0,attributesCount:0})}function p(e,n,o){var a,c,f=u(Wi,e.fragId),h=u(qi,e.vertId),d=e.program=t.createProgram();if(t.attachShader(d,f),t.attachShader(d,h),o)for(a=0;a<o.length;++a){var p=o[a];t.bindAttribLocation(d,p[0],p[1])}t.linkProgram(d),rt.linkError(t,d,r.str(e.fragId),r.str(e.vertId),n);var m=t.getProgramParameter(d,Hi);i.profile&&(e.stats.uniformsCount=m);var v=e.uniforms;for(a=0;a<m;++a)if(c=t.getActiveUniform(d,a)){if(c.size>1)for(var g=0;g<c.size;++g){var y=c.name.replace("[0]","["+g+"]");l(v,new s(y,r.id(y),t.getUniformLocation(d,y),c))}var b=c.name;c.size>1&&(b=b.replace("[0]","")),l(v,new s(b,r.id(b),t.getUniformLocation(d,b),c))}var x=t.getProgramParameter(d,Zi);i.profile&&(e.stats.attributesCount=x);var _=e.attributes;for(a=0;a<x;++a)(c=t.getActiveAttrib(d,a))&&l(_,new s(c.name,r.id(c.name),t.getAttribLocation(d,c.name),c))}function m(){o={},a={};for(var t=0;t<f.length;++t)p(f[t],null,f[t].attributes.map((function(t){return[t.location,t.name]})))}return i.profile&&(n.getMaxUniformsCount=function(){var t=0;return f.forEach((function(e){e.stats.uniformsCount>t&&(t=e.stats.uniformsCount)})),t},n.getMaxAttributesCount=function(){var t=0;return f.forEach((function(e){e.stats.attributesCount>t&&(t=e.stats.attributesCount)})),t}),{clear:function(){var e=t.deleteShader.bind(t);Se(o).forEach(e),o={},Se(a).forEach(e),a={},f.forEach((function(e){t.deleteProgram(e.program)})),f.length=0,c={},n.shaderCount=0},program:function(r,i,s,l){rt.command(r>=0,"missing vertex shader",s),rt.command(i>=0,"missing fragment shader",s);var u=c[i];u||(u=c[i]={});var h=u[r];if(h&&(h.refCount++,!l))return h;var m=new d(i,r);return n.shaderCount++,p(m,s,l),h||(u[r]=m),f.push(m),e(m,{destroy:function(){if(m.refCount--,m.refCount<=0){t.deleteProgram(m.program);var e=f.indexOf(m);f.splice(e,1),n.shaderCount--}u[m.vertId].refCount<=0&&(t.deleteShader(a[m.vertId]),delete a[m.vertId],delete c[m.fragId][m.vertId]),Object.keys(c[m.fragId]).length||(t.deleteShader(o[m.fragId]),delete o[m.fragId],delete c[m.fragId])}})},restore:m,shader:u,frag:-1,vert:-1}}var Xi=6408,Yi=5121,Ji=3333,Ki=5126;function $i(e,r,n,i,o,a,s){function l(l){var u;null===r.next?(rt(o.preserveDrawingBuffer,'you must create a webgl context with "preserveDrawingBuffer":true in order to read pixels from the drawing buffer'),u=Yi):(rt(null!==r.next.colorAttachments[0].texture,"You cannot read from a renderbuffer"),u=r.next.colorAttachments[0].texture._texture.type,rt.optional((function(){a.oes_texture_float?(rt(u===Yi||u===Ki,"Reading from a framebuffer is only allowed for the types 'uint8' and 'float'"),u===Ki&&rt(s.readFloat,"Reading 'float' values is not permitted in your browser. For a fallback, please see: https://www.npmjs.com/package/glsl-read-float")):rt(u===Yi,"Reading from a framebuffer is only allowed for the type 'uint8'")})));var c=0,f=0,h=i.framebufferWidth,d=i.framebufferHeight,p=null;t(l)?p=l:l&&(rt.type(l,"object","invalid arguments to regl.read()"),c=0|l.x,f=0|l.y,rt(c>=0&&c<i.framebufferWidth,"invalid x offset for regl.read"),rt(f>=0&&f<i.framebufferHeight,"invalid y offset for regl.read"),h=0|(l.width||i.framebufferWidth-c),d=0|(l.height||i.framebufferHeight-f),p=l.data||null),p&&(u===Yi?rt(p instanceof Uint8Array,"buffer must be 'Uint8Array' when reading from a framebuffer of type 'uint8'"):u===Ki&&rt(p instanceof Float32Array,"buffer must be 'Float32Array' when reading from a framebuffer of type 'float'")),rt(h>0&&h+c<=i.framebufferWidth,"invalid width for read pixels"),rt(d>0&&d+f<=i.framebufferHeight,"invalid height for read pixels"),n();var m=h*d*4;return p||(u===Yi?p=new Uint8Array(m):u===Ki&&(p=p||new Float32Array(m))),rt.isTypedArray(p,"data buffer for regl.read() must be a typedarray"),rt(p.byteLength>=m,"data buffer for regl.read() too small"),e.pixelStorei(Ji,4),e.readPixels(c,f,h,d,Xi,u,p),p}function u(t){var e;return r.setFBO({framebuffer:t.framebuffer},(function(){e=l(t)})),e}function c(t){return t&&"framebuffer"in t?u(t):l(t)}return c}function to(t){return Array.prototype.slice.call(t)}function eo(t){return to(t).join("")}function ro(){var t=0,r=[],n=[];function i(e){for(var i=0;i<n.length;++i)if(n[i]===e)return r[i];var o="g"+t++;return r.push(o),n.push(e),o}function o(){var r=[];function n(){r.push.apply(r,to(arguments))}var i=[];function o(){var e="v"+t++;return i.push(e),arguments.length>0&&(r.push(e,"="),r.push.apply(r,to(arguments)),r.push(";")),e}return e(n,{def:o,toString:function(){return eo([i.length>0?"var "+i.join(",")+";":"",eo(r)])}})}function a(){var t=o(),r=o(),n=t.toString,i=r.toString;function a(e,n){r(e,n,"=",t.def(e,n),";")}return e((function(){t.apply(t,to(arguments))}),{def:t.def,entry:t,exit:r,save:a,set:function(e,r,n){a(e,r),t(e,r,"=",n,";")},toString:function(){return n()+i()}})}function s(){var t=eo(arguments),r=a(),n=a(),i=r.toString,o=n.toString;return e(r,{then:function(){return r.apply(r,to(arguments)),this},else:function(){return n.apply(n,to(arguments)),this},toString:function(){var e=o();return e&&(e="else{"+e+"}"),eo(["if(",t,"){",i(),"}",e])}})}var l=o(),u={};function c(t,r){var n=[];function i(){var t="a"+n.length;return n.push(t),t}r=r||0;for(var o=0;o<r;++o)i();var s=a(),l=s.toString;return u[t]=e(s,{arg:i,toString:function(){return eo(["function(",n.join(),"){",l(),"}"])}})}function f(){var t=['"use strict";',l,"return {"];Object.keys(u).forEach((function(e){t.push('"',e,'":',u[e].toString(),",")})),t.push("}");var e=eo(t).replace(/;/g,";\n").replace(/}/g,"}\n").replace(/{/g,"{\n");return Function.apply(null,r.concat(e)).apply(null,n)}return{global:l,link:i,block:o,proc:c,scope:a,cond:s,compile:f}}var no="xyzw".split(""),io=5121,oo=1,ao=2,so=0,lo=1,uo=2,co=3,fo=4,ho=5,po=6,mo="dither",vo="blend.enable",go="blend.color",yo="blend.equation",bo="blend.func",xo="depth.enable",_o="depth.func",wo="depth.range",Co="depth.mask",So="colorMask",ko="cull.enable",Ao="cull.face",Mo="frontFace",zo="lineWidth",Oo="polygonOffset.enable",Eo="polygonOffset.offset",Po="sample.alpha",Lo="sample.enable",To="sample.coverage",Do="stencil.enable",Ro="stencil.mask",Io="stencil.func",Fo="stencil.opFront",Bo="stencil.opBack",jo="scissor.enable",Vo="scissor.box",No="viewport",Uo="profile",Go="framebuffer",Wo="vert",qo="frag",Ho="elements",Zo="primitive",Qo="count",Xo="offset",Yo="instances",Jo="vao",Ko="Width",$o="Height",ta=Go+Ko,ea=Go+$o,ra=No+Ko,na=No+$o,ia="drawingBuffer",oa=ia+Ko,aa=ia+$o,sa=[bo,yo,Io,Fo,Bo,To,No,Vo,Eo],la=34962,ua=34963,ca=3553,fa=34067,ha=2884,da=3042,pa=3024,ma=2960,va=2929,ga=3089,ya=32823,ba=32926,xa=32928,_a=5126,wa=35664,Ca=35665,Sa=35666,ka=5124,Aa=35667,Ma=35668,za=35669,Oa=35670,Ea=35671,Pa=35672,La=35673,Ta=35674,Da=35675,Ra=35676,Ia=35678,Fa=35680,Ba=4,ja=1028,Va=1029,Na=2304,Ua=2305,Ga=32775,Wa=32776,qa=519,Ha=7680,Za=0,Qa=1,Xa=32774,Ya=513,Ja=36160,Ka=36064,$a={0:0,1:1,zero:0,one:1,"src color":768,"one minus src color":769,"src alpha":770,"one minus src alpha":771,"dst color":774,"one minus dst color":775,"dst alpha":772,"one minus dst alpha":773,"constant color":32769,"one minus constant color":32770,"constant alpha":32771,"one minus constant alpha":32772,"src alpha saturate":776},ts=["constant color, constant alpha","one minus constant color, constant alpha","constant color, one minus constant alpha","one minus constant color, one minus constant alpha","constant alpha, constant color","constant alpha, one minus constant color","one minus constant alpha, constant color","one minus constant alpha, one minus constant color"],es={never:512,less:513,"<":513,equal:514,"=":514,"==":514,"===":514,lequal:515,"<=":515,greater:516,">":516,notequal:517,"!=":517,"!==":517,gequal:518,">=":518,always:519},rs={0:0,zero:0,keep:7680,replace:7681,increment:7682,decrement:7683,"increment wrap":34055,"decrement wrap":34056,invert:5386},ns={frag:35632,vert:35633},is={cw:Na,ccw:Ua};function os(e){return Array.isArray(e)||t(e)||Ce(e)}function as(t){return t.sort((function(t,e){return t===No?-1:e===No?1:t<e?-1:1}))}function ss(t,e,r,n){this.thisDep=t,this.contextDep=e,this.propDep=r,this.append=n}function ls(t){return t&&!(t.thisDep||t.contextDep||t.propDep)}function us(t){return new ss(!1,!1,!1,t)}function cs(t,e){var r=t.type;if(r===so){var n=t.data.length;return new ss(!0,n>=1,n>=2,e)}if(r===fo){var i=t.data;return new ss(i.thisDep,i.contextDep,i.propDep,e)}if(r===ho)return new ss(!1,!1,!1,e);if(r===po){for(var o=!1,a=!1,s=!1,l=0;l<t.data.length;++l){var u=t.data[l];if(u.type===lo)s=!0;else if(u.type===uo)a=!0;else if(u.type===co)o=!0;else if(u.type===so){o=!0;var c=u.data;c>=1&&(a=!0),c>=2&&(s=!0)}else u.type===fo&&(o=o||u.data.thisDep,a=a||u.data.contextDep,s=s||u.data.propDep)}return new ss(o,a,s,e)}return new ss(r===co,r===uo,r===lo,e)}var fs=new ss(!1,!1,!1,(function(){}));function hs(t,r,n,i,o,a,s,l,u,c,f,h,d,p,m){var v=c.Record,g={add:32774,subtract:32778,"reverse subtract":32779};n.ext_blend_minmax&&(g.min=Ga,g.max=Wa);var y=n.angle_instanced_arrays,b=n.webgl_draw_buffers,x=n.oes_vertex_array_object,_={dirty:!0,profile:m.profile},w={},C=[],S={},k={};function A(t){return t.replace(".","_")}function M(t,e,r){var n=A(t);C.push(t),w[n]=_[n]=!!r,S[n]=e}function z(t,e,r){var n=A(t);C.push(t),Array.isArray(r)?(_[n]=r.slice(),w[n]=r.slice()):_[n]=w[n]=r,k[n]=e}M(mo,pa),M(vo,da),z(go,"blendColor",[0,0,0,0]),z(yo,"blendEquationSeparate",[Xa,Xa]),z(bo,"blendFuncSeparate",[Qa,Za,Qa,Za]),M(xo,va,!0),z(_o,"depthFunc",Ya),z(wo,"depthRange",[0,1]),z(Co,"depthMask",!0),z(So,So,[!0,!0,!0,!0]),M(ko,ha),z(Ao,"cullFace",Va),z(Mo,Mo,Ua),z(zo,zo,1),M(Oo,ya),z(Eo,"polygonOffset",[0,0]),M(Po,ba),M(Lo,xa),z(To,"sampleCoverage",[1,!1]),M(Do,ma),z(Ro,"stencilMask",-1),z(Io,"stencilFunc",[qa,0,-1]),z(Fo,"stencilOpSeparate",[ja,Ha,Ha,Ha]),z(Bo,"stencilOpSeparate",[Va,Ha,Ha,Ha]),M(jo,ga),z(Vo,"scissor",[0,0,t.drawingBufferWidth,t.drawingBufferHeight]),z(No,No,[0,0,t.drawingBufferWidth,t.drawingBufferHeight]);var O={gl:t,context:d,strings:r,next:w,current:_,draw:h,elements:a,buffer:o,shader:f,attributes:c.state,vao:c,uniforms:u,framebuffer:l,extensions:n,timer:p,isBufferArgs:os},E={primTypes:He,compareFuncs:es,blendFuncs:$a,blendEquations:g,stencilOps:rs,glTypes:Te,orientationType:is};rt.optional((function(){O.isArrayLike=cr})),b&&(E.backBuffer=[Va],E.drawBuffer=At(i.maxDrawbuffers,(function(t){return 0===t?[0]:At(t,(function(t){return Ka+t}))})));var P=0;function L(){var t=ro(),e=t.link,n=t.global;t.id=P++,t.batchId="0";var i=e(O),o=t.shared={props:"a0"};Object.keys(O).forEach((function(t){o[t]=n.def(i,".",t)})),rt.optional((function(){t.CHECK=e(rt),t.commandStr=rt.guessCommand(),t.command=e(t.commandStr),t.assert=function(t,r,n){t("if(!(",r,"))",this.CHECK,".commandRaise(",e(n),",",this.command,");")},E.invalidBlendCombinations=ts}));var a=t.next={},s=t.current={};Object.keys(k).forEach((function(t){Array.isArray(_[t])&&(a[t]=n.def(o.next,".",t),s[t]=n.def(o.current,".",t))}));var l=t.constants={};Object.keys(E).forEach((function(t){l[t]=n.def(JSON.stringify(E[t]))})),t.invoke=function(r,n){switch(n.type){case so:var i=["this",o.context,o.props,t.batchId];return r.def(e(n.data),".call(",i.slice(0,Math.max(n.data.length+1,4)),")");case lo:return r.def(o.props,n.data);case uo:return r.def(o.context,n.data);case co:return r.def("this",n.data);case fo:return n.data.append(t,r),n.data.ref;case ho:return n.data.toString();case po:return n.data.map((function(e){return t.invoke(r,e)}))}},t.attribCache={};var u={};return t.scopeAttrib=function(t){var n=r.id(t);if(n in u)return u[n];var i=c.scope[n];return i||(i=c.scope[n]=new v),u[n]=e(i)},t}function T(t){var e,r=t.static,n=t.dynamic;if(Uo in r){var i=!!r[Uo];(e=us((function(t,e){return i}))).enable=i}else if(Uo in n){var o=n[Uo];e=cs(o,(function(t,e){return t.invoke(e,o)}))}return e}function D(t,e){var r=t.static,n=t.dynamic;if(Go in r){var i=r[Go];return i?(i=l.getFramebuffer(i),rt.command(i,"invalid framebuffer object"),us((function(t,e){var r=t.link(i),n=t.shared;e.set(n.framebuffer,".next",r);var o=n.context;return e.set(o,"."+ta,r+".width"),e.set(o,"."+ea,r+".height"),r}))):us((function(t,e){var r=t.shared;e.set(r.framebuffer,".next","null");var n=r.context;return e.set(n,"."+ta,n+"."+oa),e.set(n,"."+ea,n+"."+aa),"null"}))}if(Go in n){var o=n[Go];return cs(o,(function(t,e){var r=t.invoke(e,o),n=t.shared,i=n.framebuffer,a=e.def(i,".getFramebuffer(",r,")");rt.optional((function(){t.assert(e,"!"+r+"||"+a,"invalid framebuffer object")})),e.set(i,".next",a);var s=n.context;return e.set(s,"."+ta,a+"?"+a+".width:"+s+"."+oa),e.set(s,"."+ea,a+"?"+a+".height:"+s+"."+aa),a}))}return null}function R(t,e,r){var n=t.static,i=t.dynamic;function o(t){if(t in n){var o=n[t];rt.commandType(o,"object","invalid "+t,r.commandStr);var a,s,l=!0,u=0|o.x,c=0|o.y;return"width"in o?(a=0|o.width,rt.command(a>=0,"invalid "+t,r.commandStr)):l=!1,"height"in o?(s=0|o.height,rt.command(s>=0,"invalid "+t,r.commandStr)):l=!1,new ss(!l&&e&&e.thisDep,!l&&e&&e.contextDep,!l&&e&&e.propDep,(function(t,e){var r=t.shared.context,n=a;"width"in o||(n=e.def(r,".",ta,"-",u));var i=s;return"height"in o||(i=e.def(r,".",ea,"-",c)),[u,c,n,i]}))}if(t in i){var f=i[t],h=cs(f,(function(e,r){var n=e.invoke(r,f);rt.optional((function(){e.assert(r,n+"&&typeof "+n+'==="object"',"invalid "+t)}));var i=e.shared.context,o=r.def(n,".x|0"),a=r.def(n,".y|0"),s=r.def('"width" in ',n,"?",n,".width|0:","(",i,".",ta,"-",o,")"),l=r.def('"height" in ',n,"?",n,".height|0:","(",i,".",ea,"-",a,")");return rt.optional((function(){e.assert(r,s+">=0&&"+l+">=0","invalid "+t)})),[o,a,s,l]}));return e&&(h.thisDep=h.thisDep||e.thisDep,h.contextDep=h.contextDep||e.contextDep,h.propDep=h.propDep||e.propDep),h}return e?new ss(e.thisDep,e.contextDep,e.propDep,(function(t,e){var r=t.shared.context;return[0,0,e.def(r,".",ta),e.def(r,".",ea)]})):null}var a=o(No);if(a){var s=a;a=new ss(a.thisDep,a.contextDep,a.propDep,(function(t,e){var r=s.append(t,e),n=t.shared.context;return e.set(n,"."+ra,r[2]),e.set(n,"."+na,r[3]),r}))}return{viewport:a,scissor_box:o(Vo)}}function I(t,e){var r=t.static;if("string"==typeof r[qo]&&"string"==typeof r[Wo]){if(Object.keys(e.dynamic).length>0)return null;var n=e.static,i=Object.keys(n);if(i.length>0&&"number"==typeof n[i[0]]){for(var o=[],a=0;a<i.length;++a)rt("number"==typeof n[i[a]],"must specify all vertex attribute locations when using vaos"),o.push([0|n[i[a]],i[a]]);return o}}return null}function F(t,e,n){var i=t.static,o=t.dynamic;function a(t){if(t in i){var e=r.id(i[t]);rt.optional((function(){f.shader(ns[t],e,rt.guessCommand())}));var n=us((function(){return e}));return n.id=e,n}if(t in o){var a=o[t];return cs(a,(function(e,r){var n=e.invoke(r,a),i=r.def(e.shared.strings,".id(",n,")");return rt.optional((function(){r(e.shared.shader,".shader(",ns[t],",",i,",",e.command,");")})),i}))}return null}var s,l=a(qo),u=a(Wo),c=null;return ls(l)&&ls(u)?(c=f.program(u.id,l.id,null,n),s=us((function(t,e){return t.link(c)}))):s=new ss(l&&l.thisDep||u&&u.thisDep,l&&l.contextDep||u&&u.contextDep,l&&l.propDep||u&&u.propDep,(function(t,e){var r,n=t.shared.shader;r=l?l.append(t,e):e.def(n,".",qo);var i=n+".program("+(u?u.append(t,e):e.def(n,".",Wo))+","+r;return rt.optional((function(){i+=","+t.command})),e.def(i+")")})),{frag:l,vert:u,progVar:s,program:c}}function B(t,e){var r=t.static,n=t.dynamic,i={},o=!1;function s(){if(Jo in r){var t=r[Jo];return null!==t&&null===c.getVAO(t)&&(t=c.createVAO(t)),o=!0,i.vao=t,us((function(e){var r=c.getVAO(t);return r?e.link(r):"null"}))}if(Jo in n){o=!0;var e=n[Jo];return cs(e,(function(t,r){var n=t.invoke(r,e);return r.def(t.shared.vao+".getVAO("+n+")")}))}return null}var l=s(),u=!1;function f(){if(Ho in r){var t=r[Ho];if(i.elements=t,os(t)){var s=i.elements=a.create(t,!0);t=a.getElements(s),u=!0}else t&&(t=a.getElements(t),u=!0,rt.command(t,"invalid elements",e.commandStr));var c=us((function(e,r){if(t){var n=e.link(t);return e.ELEMENTS=n,n}return e.ELEMENTS=null,null}));return c.value=t,c}if(Ho in n){u=!0;var f=n[Ho];return cs(f,(function(t,e){var r=t.shared,n=r.isBufferArgs,i=r.elements,o=t.invoke(e,f),a=e.def("null"),s=e.def(n,"(",o,")"),l=t.cond(s).then(a,"=",i,".createStream(",o,");").else(a,"=",i,".getElements(",o,");");return rt.optional((function(){t.assert(l.else,"!"+o+"||"+a,"invalid elements")})),e.entry(l),e.exit(t.cond(s).then(i,".destroyStream(",a,");")),t.ELEMENTS=a,a}))}return o?new ss(l.thisDep,l.contextDep,l.propDep,(function(t,e){return e.def(t.shared.vao+".currentVAO?"+t.shared.elements+".getElements("+t.shared.vao+".currentVAO.elements):null")})):null}var h=f();function d(){if(Zo in r){var t=r[Zo];return i.primitive=t,rt.commandParameter(t,He,"invalid primitve",e.commandStr),us((function(e,r){return He[t]}))}if(Zo in n){var a=n[Zo];return cs(a,(function(t,e){var r=t.constants.primTypes,n=t.invoke(e,a);return rt.optional((function(){t.assert(e,n+" in "+r,"invalid primitive, must be one of "+Object.keys(He))})),e.def(r,"[",n,"]")}))}return u?ls(h)?h.value?us((function(t,e){return e.def(t.ELEMENTS,".primType")})):us((function(){return Ba})):new ss(h.thisDep,h.contextDep,h.propDep,(function(t,e){var r=t.ELEMENTS;return e.def(r,"?",r,".primType:",Ba)})):o?new ss(l.thisDep,l.contextDep,l.propDep,(function(t,e){return e.def(t.shared.vao+".currentVAO?"+t.shared.vao+".currentVAO.primitive:"+Ba)})):null}function p(t,a){if(t in r){var s=0|r[t];return a?i.offset=s:i.instances=s,rt.command(!a||s>=0,"invalid "+t,e.commandStr),us((function(t,e){return a&&(t.OFFSET=s),s}))}if(t in n){var c=n[t];return cs(c,(function(e,r){var n=e.invoke(r,c);return a&&(e.OFFSET=n,rt.optional((function(){e.assert(r,n+">=0","invalid "+t)}))),n}))}if(a){if(u)return us((function(t,e){return t.OFFSET=0,0}));if(o)return new ss(l.thisDep,l.contextDep,l.propDep,(function(t,e){return e.def(t.shared.vao+".currentVAO?"+t.shared.vao+".currentVAO.offset:0")}))}else if(o)return new ss(l.thisDep,l.contextDep,l.propDep,(function(t,e){return e.def(t.shared.vao+".currentVAO?"+t.shared.vao+".currentVAO.instances:-1")}));return null}var m=p(Xo,!0);function v(){if(Qo in r){var t=0|r[Qo];return i.count=t,rt.command("number"==typeof t&&t>=0,"invalid vertex count",e.commandStr),us((function(){return t}))}if(Qo in n){var a=n[Qo];return cs(a,(function(t,e){var r=t.invoke(e,a);return rt.optional((function(){t.assert(e,"typeof "+r+'==="number"&&'+r+">=0&&"+r+"===("+r+"|0)","invalid vertex count")})),r}))}if(u){if(ls(h)){if(h)return m?new ss(m.thisDep,m.contextDep,m.propDep,(function(t,e){var r=e.def(t.ELEMENTS,".vertCount-",t.OFFSET);return rt.optional((function(){t.assert(e,r+">=0","invalid vertex offset/element buffer too small")})),r})):us((function(t,e){return e.def(t.ELEMENTS,".vertCount")}));var s=us((function(){return-1}));return rt.optional((function(){s.MISSING=!0})),s}var c=new ss(h.thisDep||m.thisDep,h.contextDep||m.contextDep,h.propDep||m.propDep,(function(t,e){var r=t.ELEMENTS;return t.OFFSET?e.def(r,"?",r,".vertCount-",t.OFFSET,":-1"):e.def(r,"?",r,".vertCount:-1")}));return rt.optional((function(){c.DYNAMIC=!0})),c}return o?new ss(l.thisDep,l.contextDep,l.propDep,(function(t,e){return e.def(t.shared.vao,".currentVAO?",t.shared.vao,".currentVAO.count:-1")})):null}var g=d(),y=v(),b=p(Yo,!1);return{elements:h,primitive:g,count:y,instances:b,offset:m,vao:l,vaoActive:o,elementsActive:u,static:i}}function j(t,e){var r=t.static,n=t.dynamic,o={};return C.forEach((function(t){var a=A(t);function s(e,i){if(t in r){var s=e(r[t]);o[a]=us((function(){return s}))}else if(t in n){var l=n[t];o[a]=cs(l,(function(t,e){return i(t,e,t.invoke(e,l))}))}}switch(t){case ko:case vo:case mo:case Do:case xo:case jo:case Oo:case Po:case Lo:case Co:return s((function(r){return rt.commandType(r,"boolean",t,e.commandStr),r}),(function(e,r,n){return rt.optional((function(){e.assert(r,"typeof "+n+'==="boolean"',"invalid flag "+t,e.commandStr)})),n}));case _o:return s((function(r){return rt.commandParameter(r,es,"invalid "+t,e.commandStr),es[r]}),(function(e,r,n){var i=e.constants.compareFuncs;return rt.optional((function(){e.assert(r,n+" in "+i,"invalid "+t+", must be one of "+Object.keys(es))})),r.def(i,"[",n,"]")}));case wo:return s((function(t){return rt.command(cr(t)&&2===t.length&&"number"==typeof t[0]&&"number"==typeof t[1]&&t[0]<=t[1],"depth range is 2d array",e.commandStr),t}),(function(t,e,r){return rt.optional((function(){t.assert(e,t.shared.isArrayLike+"("+r+")&&"+r+".length===2&&typeof "+r+'[0]==="number"&&typeof '+r+'[1]==="number"&&'+r+"[0]<="+r+"[1]","depth range must be a 2d array")})),[e.def("+",r,"[0]"),e.def("+",r,"[1]")]}));case bo:return s((function(t){rt.commandType(t,"object","blend.func",e.commandStr);var r="srcRGB"in t?t.srcRGB:t.src,n="srcAlpha"in t?t.srcAlpha:t.src,i="dstRGB"in t?t.dstRGB:t.dst,o="dstAlpha"in t?t.dstAlpha:t.dst;return rt.commandParameter(r,$a,a+".srcRGB",e.commandStr),rt.commandParameter(n,$a,a+".srcAlpha",e.commandStr),rt.commandParameter(i,$a,a+".dstRGB",e.commandStr),rt.commandParameter(o,$a,a+".dstAlpha",e.commandStr),rt.command(-1===ts.indexOf(r+", "+i),"unallowed blending combination (srcRGB, dstRGB) = ("+r+", "+i+")",e.commandStr),[$a[r],$a[i],$a[n],$a[o]]}),(function(e,r,n){var i=e.constants.blendFuncs;function o(o,a){var s=r.def('"',o,a,'" in ',n,"?",n,".",o,a,":",n,".",o);return rt.optional((function(){e.assert(r,s+" in "+i,"invalid "+t+"."+o+a+", must be one of "+Object.keys($a))})),s}rt.optional((function(){e.assert(r,n+"&&typeof "+n+'==="object"',"invalid blend func, must be an object")}));var a=o("src","RGB"),s=o("dst","RGB");rt.optional((function(){var t=e.constants.invalidBlendCombinations;e.assert(r,t+".indexOf("+a+'+", "+'+s+") === -1 ","unallowed blending combination for (srcRGB, dstRGB)")}));var l=r.def(i,"[",a,"]"),u=r.def(i,"[",o("src","Alpha"),"]");return[l,r.def(i,"[",s,"]"),u,r.def(i,"[",o("dst","Alpha"),"]")]}));case yo:return s((function(r){return"string"==typeof r?(rt.commandParameter(r,g,"invalid "+t,e.commandStr),[g[r],g[r]]):"object"==typeof r?(rt.commandParameter(r.rgb,g,t+".rgb",e.commandStr),rt.commandParameter(r.alpha,g,t+".alpha",e.commandStr),[g[r.rgb],g[r.alpha]]):void rt.commandRaise("invalid blend.equation",e.commandStr)}),(function(e,r,n){var i=e.constants.blendEquations,o=r.def(),a=r.def(),s=e.cond("typeof ",n,'==="string"');return rt.optional((function(){function r(t,r,n){e.assert(t,n+" in "+i,"invalid "+r+", must be one of "+Object.keys(g))}r(s.then,t,n),e.assert(s.else,n+"&&typeof "+n+'==="object"',"invalid "+t),r(s.else,t+".rgb",n+".rgb"),r(s.else,t+".alpha",n+".alpha")})),s.then(o,"=",a,"=",i,"[",n,"];"),s.else(o,"=",i,"[",n,".rgb];",a,"=",i,"[",n,".alpha];"),r(s),[o,a]}));case go:return s((function(t){return rt.command(cr(t)&&4===t.length,"blend.color must be a 4d array",e.commandStr),At(4,(function(e){return+t[e]}))}),(function(t,e,r){return rt.optional((function(){t.assert(e,t.shared.isArrayLike+"("+r+")&&"+r+".length===4","blend.color must be a 4d array")})),At(4,(function(t){return e.def("+",r,"[",t,"]")}))}));case Ro:return s((function(t){return rt.commandType(t,"number",a,e.commandStr),0|t}),(function(t,e,r){return rt.optional((function(){t.assert(e,"typeof "+r+'==="number"',"invalid stencil.mask")})),e.def(r,"|0")}));case Io:return s((function(r){rt.commandType(r,"object",a,e.commandStr);var n=r.cmp||"keep",i=r.ref||0,o="mask"in r?r.mask:-1;return rt.commandParameter(n,es,t+".cmp",e.commandStr),rt.commandType(i,"number",t+".ref",e.commandStr),rt.commandType(o,"number",t+".mask",e.commandStr),[es[n],i,o]}),(function(t,e,r){var n=t.constants.compareFuncs;return rt.optional((function(){function i(){t.assert(e,Array.prototype.join.call(arguments,""),"invalid stencil.func")}i(r+"&&typeof ",r,'==="object"'),i('!("cmp" in ',r,")||(",r,".cmp in ",n,")")})),[e.def('"cmp" in ',r,"?",n,"[",r,".cmp]",":",Ha),e.def(r,".ref|0"),e.def('"mask" in ',r,"?",r,".mask|0:-1")]}));case Fo:case Bo:return s((function(r){rt.commandType(r,"object",a,e.commandStr);var n=r.fail||"keep",i=r.zfail||"keep",o=r.zpass||"keep";return rt.commandParameter(n,rs,t+".fail",e.commandStr),rt.commandParameter(i,rs,t+".zfail",e.commandStr),rt.commandParameter(o,rs,t+".zpass",e.commandStr),[t===Bo?Va:ja,rs[n],rs[i],rs[o]]}),(function(e,r,n){var i=e.constants.stencilOps;function o(o){return rt.optional((function(){e.assert(r,'!("'+o+'" in '+n+")||("+n+"."+o+" in "+i+")","invalid "+t+"."+o+", must be one of "+Object.keys(rs))})),r.def('"',o,'" in ',n,"?",i,"[",n,".",o,"]:",Ha)}return rt.optional((function(){e.assert(r,n+"&&typeof "+n+'==="object"',"invalid "+t)})),[t===Bo?Va:ja,o("fail"),o("zfail"),o("zpass")]}));case Eo:return s((function(t){rt.commandType(t,"object",a,e.commandStr);var r=0|t.factor,n=0|t.units;return rt.commandType(r,"number",a+".factor",e.commandStr),rt.commandType(n,"number",a+".units",e.commandStr),[r,n]}),(function(e,r,n){return rt.optional((function(){e.assert(r,n+"&&typeof "+n+'==="object"',"invalid "+t)})),[r.def(n,".factor|0"),r.def(n,".units|0")]}));case Ao:return s((function(t){var r=0;return"front"===t?r=ja:"back"===t&&(r=Va),rt.command(!!r,a,e.commandStr),r}),(function(t,e,r){return rt.optional((function(){t.assert(e,r+'==="front"||'+r+'==="back"',"invalid cull.face")})),e.def(r,'==="front"?',ja,":",Va)}));case zo:return s((function(t){return rt.command("number"==typeof t&&t>=i.lineWidthDims[0]&&t<=i.lineWidthDims[1],"invalid line width, must be a positive number between "+i.lineWidthDims[0]+" and "+i.lineWidthDims[1],e.commandStr),t}),(function(t,e,r){return rt.optional((function(){t.assert(e,"typeof "+r+'==="number"&&'+r+">="+i.lineWidthDims[0]+"&&"+r+"<="+i.lineWidthDims[1],"invalid line width")})),r}));case Mo:return s((function(t){return rt.commandParameter(t,is,a,e.commandStr),is[t]}),(function(t,e,r){return rt.optional((function(){t.assert(e,r+'==="cw"||'+r+'==="ccw"',"invalid frontFace, must be one of cw,ccw")})),e.def(r+'==="cw"?'+Na+":"+Ua)}));case So:return s((function(t){return rt.command(cr(t)&&4===t.length,"color.mask must be length 4 array",e.commandStr),t.map((function(t){return!!t}))}),(function(t,e,r){return rt.optional((function(){t.assert(e,t.shared.isArrayLike+"("+r+")&&"+r+".length===4","invalid color.mask")})),At(4,(function(t){return"!!"+r+"["+t+"]"}))}));case To:return s((function(t){rt.command("object"==typeof t&&t,a,e.commandStr);var r="value"in t?t.value:1,n=!!t.invert;return rt.command("number"==typeof r&&r>=0&&r<=1,"sample.coverage.value must be a number between 0 and 1",e.commandStr),[r,n]}),(function(t,e,r){return rt.optional((function(){t.assert(e,r+"&&typeof "+r+'==="object"',"invalid sample.coverage")})),[e.def('"value" in ',r,"?+",r,".value:1"),e.def("!!",r,".invert")]}))}})),o}function V(t,e){var r=t.static,n=t.dynamic,i={};return Object.keys(r).forEach((function(t){var n,o=r[t];if("number"==typeof o||"boolean"==typeof o)n=us((function(){return o}));else if("function"==typeof o){var a=o._reglType;"texture2d"===a||"textureCube"===a?n=us((function(t){return t.link(o)})):"framebuffer"===a||"framebufferCube"===a?(rt.command(o.color.length>0,'missing color attachment for framebuffer sent to uniform "'+t+'"',e.commandStr),n=us((function(t){return t.link(o.color[0])}))):rt.commandRaise('invalid data for uniform "'+t+'"',e.commandStr)}else cr(o)?n=us((function(e){return e.global.def("[",At(o.length,(function(r){return rt.command("number"==typeof o[r]||"boolean"==typeof o[r],"invalid uniform "+t,e.commandStr),o[r]})),"]")})):rt.commandRaise('invalid or missing data for uniform "'+t+'"',e.commandStr);n.value=o,i[t]=n})),Object.keys(n).forEach((function(t){var e=n[t];i[t]=cs(e,(function(t,r){return t.invoke(r,e)}))})),i}function N(t,e){var n=t.static,i=t.dynamic,a={};return Object.keys(n).forEach((function(t){var i=n[t],s=r.id(t),l=new v;if(os(i))l.state=oo,l.buffer=o.getBuffer(o.create(i,la,!1,!0)),l.type=0;else{var u=o.getBuffer(i);if(u)l.state=oo,l.buffer=u,l.type=0;else if(rt.command("object"==typeof i&&i,"invalid data for attribute "+t,e.commandStr),"constant"in i){var c=i.constant;l.buffer="null",l.state=ao,"number"==typeof c?l.x=c:(rt.command(cr(c)&&c.length>0&&c.length<=4,"invalid constant for attribute "+t,e.commandStr),no.forEach((function(t,e){e<c.length&&(l[t]=c[e])})))}else{u=os(i.buffer)?o.getBuffer(o.create(i.buffer,la,!1,!0)):o.getBuffer(i.buffer),rt.command(!!u,'missing buffer for attribute "'+t+'"',e.commandStr);var f=0|i.offset;rt.command(f>=0,'invalid offset for attribute "'+t+'"',e.commandStr);var h=0|i.stride;rt.command(h>=0&&h<256,'invalid stride for attribute "'+t+'", must be integer betweeen [0, 255]',e.commandStr);var d=0|i.size;rt.command(!("size"in i)||d>0&&d<=4,'invalid size for attribute "'+t+'", must be 1,2,3,4',e.commandStr);var p=!!i.normalized,m=0;"type"in i&&(rt.commandParameter(i.type,Te,"invalid type for attribute "+t,e.commandStr),m=Te[i.type]);var g=0|i.divisor;rt.optional((function(){"divisor"in i&&(rt.command(0===g||y,'cannot specify divisor for attribute "'+t+'", instancing not supported',e.commandStr),rt.command(g>=0,'invalid divisor for attribute "'+t+'"',e.commandStr));var r=e.commandStr,n=["buffer","offset","divisor","normalized","type","size","stride"];Object.keys(i).forEach((function(e){rt.command(n.indexOf(e)>=0,'unknown parameter "'+e+'" for attribute pointer "'+t+'" (valid parameters are '+n+")",r)}))})),l.buffer=u,l.state=oo,l.size=d,l.normalized=p,l.type=m||u.dtype,l.offset=f,l.stride=h,l.divisor=g}}a[t]=us((function(t,e){var r=t.attribCache;if(s in r)return r[s];var n={isStream:!1};return Object.keys(l).forEach((function(t){n[t]=l[t]})),l.buffer&&(n.buffer=t.link(l.buffer),n.type=n.type||n.buffer+".dtype"),r[s]=n,n}))})),Object.keys(i).forEach((function(t){var e=i[t];function r(r,n){var i=r.invoke(n,e),o=r.shared,a=r.constants,s=o.isBufferArgs,l=o.buffer;rt.optional((function(){r.assert(n,i+"&&(typeof "+i+'==="object"||typeof '+i+'==="function")&&('+s+"("+i+")||"+l+".getBuffer("+i+")||"+l+".getBuffer("+i+".buffer)||"+s+"("+i+'.buffer)||("constant" in '+i+"&&(typeof "+i+'.constant==="number"||'+o.isArrayLike+"("+i+".constant))))",'invalid dynamic attribute "'+t+'"')}));var u={isStream:n.def(!1)},c=new v;c.state=oo,Object.keys(c).forEach((function(t){u[t]=n.def(""+c[t])}));var f=u.buffer,h=u.type;function d(t){n(u[t],"=",i,".",t,"|0;")}return n("if(",s,"(",i,")){",u.isStream,"=true;",f,"=",l,".createStream(",la,",",i,");",h,"=",f,".dtype;","}else{",f,"=",l,".getBuffer(",i,");","if(",f,"){",h,"=",f,".dtype;",'}else if("constant" in ',i,"){",u.state,"=",ao,";","if(typeof "+i+'.constant === "number"){',u[no[0]],"=",i,".constant;",no.slice(1).map((function(t){return u[t]})).join("="),"=0;","}else{",no.map((function(t,e){return u[t]+"="+i+".constant.length>"+e+"?"+i+".constant["+e+"]:0;"})).join(""),"}}else{","if(",s,"(",i,".buffer)){",f,"=",l,".createStream(",la,",",i,".buffer);","}else{",f,"=",l,".getBuffer(",i,".buffer);","}",h,'="type" in ',i,"?",a.glTypes,"[",i,".type]:",f,".dtype;",u.normalized,"=!!",i,".normalized;"),d("size"),d("offset"),d("stride"),d("divisor"),n("}}"),n.exit("if(",u.isStream,"){",l,".destroyStream(",f,");","}"),u}a[t]=cs(e,r)})),a}function U(t){var e=t.static,r=t.dynamic,n={};return Object.keys(e).forEach((function(t){var r=e[t];n[t]=us((function(t,e){return"number"==typeof r||"boolean"==typeof r?""+r:t.link(r)}))})),Object.keys(r).forEach((function(t){var e=r[t];n[t]=cs(e,(function(t,r){return t.invoke(r,e)}))})),n}function G(t,e,r,i,o){var a=t.static,s=t.dynamic;rt.optional((function(){var t=[Go,Wo,qo,Ho,Zo,Xo,Qo,Yo,Uo,Jo].concat(C);function e(e){Object.keys(e).forEach((function(e){rt.command(t.indexOf(e)>=0,'unknown parameter "'+e+'"',o.commandStr)}))}e(a),e(s)}));var l=I(t,e),u=D(t),f=R(t,u,o),h=B(t,o),d=j(t,o),p=F(t,o,l);function m(t){var e=f[t];e&&(d[t]=e)}m(No),m(A(Vo));var v=Object.keys(d).length>0,g={framebuffer:u,draw:h,shader:p,state:d,dirty:v,scopeVAO:null,drawVAO:null,useVAO:!1,attributes:{}};if(g.profile=T(t),g.uniforms=V(r,o),g.drawVAO=g.scopeVAO=h.vao,!g.drawVAO&&p.program&&!l&&n.angle_instanced_arrays&&h.static.elements){var y=!0,b=p.program.attributes.map((function(t){var r=e.static[t];return y=y&&!!r,r}));if(y&&b.length>0){var x=c.getVAO(c.createVAO({attributes:b,elements:h.static.elements}));g.drawVAO=new ss(null,null,null,(function(t,e){return t.link(x)})),g.useVAO=!0}}return l?g.useVAO=!0:g.attributes=N(e,o),g.context=U(i),g}function W(t,e,r){var n=t.shared.context,i=t.scope();Object.keys(r).forEach((function(o){e.save(n,"."+o);var a=r[o].append(t,e);Array.isArray(a)?i(n,".",o,"=[",a.join(),"];"):i(n,".",o,"=",a,";")})),e(i)}function q(t,e,r,n){var i,o=t.shared,a=o.gl,s=o.framebuffer;b&&(i=e.def(o.extensions,".webgl_draw_buffers"));var l,u=t.constants,c=u.drawBuffer,f=u.backBuffer;l=r?r.append(t,e):e.def(s,".next"),n||e("if(",l,"!==",s,".cur){"),e("if(",l,"){",a,".bindFramebuffer(",Ja,",",l,".framebuffer);"),b&&e(i,".drawBuffersWEBGL(",c,"[",l,".colorAttachments.length]);"),e("}else{",a,".bindFramebuffer(",Ja,",null);"),b&&e(i,".drawBuffersWEBGL(",f,");"),e("}",s,".cur=",l,";"),n||e("}")}function H(t,e,r){var n=t.shared,i=n.gl,o=t.current,a=t.next,s=n.current,l=n.next,u=t.cond(s,".dirty");C.forEach((function(e){var n,c,f=A(e);if(!(f in r.state))if(f in a){n=a[f],c=o[f];var h=At(_[f].length,(function(t){return u.def(n,"[",t,"]")}));u(t.cond(h.map((function(t,e){return t+"!=="+c+"["+e+"]"})).join("||")).then(i,".",k[f],"(",h,");",h.map((function(t,e){return c+"["+e+"]="+t})).join(";"),";"))}else{n=u.def(l,".",f);var d=t.cond(n,"!==",s,".",f);u(d),f in S?d(t.cond(n).then(i,".enable(",S[f],");").else(i,".disable(",S[f],");"),s,".",f,"=",n,";"):d(i,".",k[f],"(",n,");",s,".",f,"=",n,";")}})),0===Object.keys(r.state).length&&u(s,".dirty=false;"),e(u)}function Z(t,e,r,n){var i=t.shared,o=t.current,a=i.current,s=i.gl;as(Object.keys(r)).forEach((function(i){var l=r[i];if(!n||n(l)){var u=l.append(t,e);if(S[i]){var c=S[i];ls(l)?e(s,u?".enable(":".disable(",c,");"):e(t.cond(u).then(s,".enable(",c,");").else(s,".disable(",c,");")),e(a,".",i,"=",u,";")}else if(cr(u)){var f=o[i];e(s,".",k[i],"(",u,");",u.map((function(t,e){return f+"["+e+"]="+t})).join(";"),";")}else e(s,".",k[i],"(",u,");",a,".",i,"=",u,";")}}))}function Q(t,e){y&&(t.instancing=e.def(t.shared.extensions,".angle_instanced_arrays"))}function X(t,e,r,n,i){var o,a,s,l=t.shared,u=t.stats,c=l.current,f=l.timer,h=r.profile;function d(){return"undefined"==typeof performance?"Date.now()":"performance.now()"}function m(t){t(o=e.def(),"=",d(),";"),"string"==typeof i?t(u,".count+=",i,";"):t(u,".count++;"),p&&(n?t(a=e.def(),"=",f,".getNumPendingQueries();"):t(f,".beginQuery(",u,");"))}function v(t){t(u,".cpuTime+=",d(),"-",o,";"),p&&(n?t(f,".pushScopeStats(",a,",",f,".getNumPendingQueries(),",u,");"):t(f,".endQuery();"))}function g(t){var r=e.def(c,".profile");e(c,".profile=",t,";"),e.exit(c,".profile=",r,";")}if(h){if(ls(h))return void(h.enable?(m(e),v(e.exit),g("true")):g("false"));g(s=h.append(t,e))}else s=e.def(c,".profile");var y=t.block();m(y),e("if(",s,"){",y,"}");var b=t.block();v(b),e.exit("if(",s,"){",b,"}")}function Y(t,e,r,n,i){var o=t.shared;function a(t){switch(t){case wa:case Aa:case Ea:return 2;case Ca:case Ma:case Pa:return 3;case Sa:case za:case La:return 4;default:return 1}}function s(r,n,i){var a=o.gl,s=e.def(r,".location"),l=e.def(o.attributes,"[",s,"]"),u=i.state,c=i.buffer,f=[i.x,i.y,i.z,i.w],h=["buffer","normalized","offset","stride"];function d(){e("if(!",l,".buffer){",a,".enableVertexAttribArray(",s,");}");var r,o=i.type;if(r=i.size?e.def(i.size,"||",n):n,e("if(",l,".type!==",o,"||",l,".size!==",r,"||",h.map((function(t){return l+"."+t+"!=="+i[t]})).join("||"),"){",a,".bindBuffer(",la,",",c,".buffer);",a,".vertexAttribPointer(",[s,r,o,i.normalized,i.stride,i.offset],");",l,".type=",o,";",l,".size=",r,";",h.map((function(t){return l+"."+t+"="+i[t]+";"})).join(""),"}"),y){var u=i.divisor;e("if(",l,".divisor!==",u,"){",t.instancing,".vertexAttribDivisorANGLE(",[s,u],");",l,".divisor=",u,";}")}}function p(){e("if(",l,".buffer){",a,".disableVertexAttribArray(",s,");",l,".buffer=null;","}if(",no.map((function(t,e){return l+"."+t+"!=="+f[e]})).join("||"),"){",a,".vertexAttrib4f(",s,",",f,");",no.map((function(t,e){return l+"."+t+"="+f[e]+";"})).join(""),"}")}u===oo?d():u===ao?p():(e("if(",u,"===",oo,"){"),d(),e("}else{"),p(),e("}"))}n.forEach((function(n){var o,l=n.name,u=r.attributes[l];if(u){if(!i(u))return;o=u.append(t,e)}else{if(!i(fs))return;var c=t.scopeAttrib(l);rt.optional((function(){t.assert(e,c+".state","missing attribute "+l)})),o={},Object.keys(new v).forEach((function(t){o[t]=e.def(c,".",t)}))}s(t.link(n),a(n.info.type),o)}))}function J(t,e,n,i,o,a){for(var s,l=t.shared,u=l.gl,c={},f=0;f<i.length;++f){var h=i[f],d=h.name,p=h.info.type,m=h.info.size,v=n.uniforms[d];if(m>1){if(!v)continue;var g=d.replace("[0]","");if(c[g])continue;c[g]=1}var y,b=t.link(h)+".location";if(v){if(!o(v))continue;if(ls(v)){var x=v.value;if(rt.command(null!=x,'missing uniform "'+d+'"',t.commandStr),p===Ia||p===Fa){rt.command("function"==typeof x&&(p===Ia&&("texture2d"===x._reglType||"framebuffer"===x._reglType)||p===Fa&&("textureCube"===x._reglType||"framebufferCube"===x._reglType)),"invalid texture for uniform "+d,t.commandStr);var _=t.link(x._texture||x.color[0]._texture);e(u,".uniform1i(",b,",",_+".bind());"),e.exit(_,".unbind();")}else if(p===Ta||p===Da||p===Ra){rt.optional((function(){rt.command(cr(x),"invalid matrix for uniform "+d,t.commandStr),rt.command(p===Ta&&4===x.length||p===Da&&9===x.length||p===Ra&&16===x.length,"invalid length for matrix uniform "+d,t.commandStr)}));var w=t.global.def("new Float32Array(["+Array.prototype.slice.call(x)+"])"),C=2;p===Da?C=3:p===Ra&&(C=4),e(u,".uniformMatrix",C,"fv(",b,",false,",w,");")}else{switch(p){case _a:1===m?rt.commandType(x,"number","uniform "+d,t.commandStr):rt.command(cr(x)&&x.length===m,"uniform "+d,t.commandStr),s="1f";break;case wa:rt.command(cr(x)&&x.length&&x.length%2==0&&x.length<=2*m,"uniform "+d,t.commandStr),s="2f";break;case Ca:rt.command(cr(x)&&x.length&&x.length%3==0&&x.length<=3*m,"uniform "+d,t.commandStr),s="3f";break;case Sa:rt.command(cr(x)&&x.length&&x.length%4==0&&x.length<=4*m,"uniform "+d,t.commandStr),s="4f";break;case Oa:1===m?rt.commandType(x,"boolean","uniform "+d,t.commandStr):rt.command(cr(x)&&x.length===m,"uniform "+d,t.commandStr),s="1i";break;case ka:1===m?rt.commandType(x,"number","uniform "+d,t.commandStr):rt.command(cr(x)&&x.length===m,"uniform "+d,t.commandStr),s="1i";break;case Ea:case Aa:rt.command(cr(x)&&x.length&&x.length%2==0&&x.length<=2*m,"uniform "+d,t.commandStr),s="2i";break;case Pa:case Ma:rt.command(cr(x)&&x.length&&x.length%3==0&&x.length<=3*m,"uniform "+d,t.commandStr),s="3i";break;case La:case za:rt.command(cr(x)&&x.length&&x.length%4==0&&x.length<=4*m,"uniform "+d,t.commandStr),s="4i"}m>1?(s+="v",x=t.global.def("["+Array.prototype.slice.call(x)+"]")):x=cr(x)?Array.prototype.slice.call(x):x,e(u,".uniform",s,"(",b,",",x,");")}continue}y=v.append(t,e)}else{if(!o(fs))continue;y=e.def(l.uniforms,"[",r.id(d),"]")}p===Ia?(rt(!Array.isArray(y),"must specify a scalar prop for textures"),e("if(",y,"&&",y,'._reglType==="framebuffer"){',y,"=",y,".color[0];","}")):p===Fa&&(rt(!Array.isArray(y),"must specify a scalar prop for cube maps"),e("if(",y,"&&",y,'._reglType==="framebufferCube"){',y,"=",y,".color[0];","}")),rt.optional((function(){function r(r,n){t.assert(e,r,'bad data or missing for uniform "'+d+'".  '+n)}function n(t,e){1===e&&rt(!Array.isArray(y),"must not specify an array type for uniform"),r("Array.isArray("+y+") && typeof "+y+'[0]===" '+t+'" || typeof '+y+'==="'+t+'"',"invalid type, expected "+t)}function i(e,n,i){Array.isArray(y)?rt(y.length&&y.length%e==0&&y.length<=e*i,"must have length of "+(1===i?"":"n * ")+e):r(l.isArrayLike+"("+y+")&&"+y+".length && "+y+".length % "+e+" === 0 && "+y+".length<="+e*i,"invalid vector, should have length of "+(1===i?"":"n * ")+e,t.commandStr)}function o(e){rt(!Array.isArray(y),"must not specify a value type"),r("typeof "+y+'==="function"&&'+y+'._reglType==="texture'+(e===ca?"2d":"Cube")+'"',"invalid texture type",t.commandStr)}switch(p){case ka:n("number",m);break;case Aa:i(2,"number",m);break;case Ma:i(3,"number",m);break;case za:i(4,"number",m);break;case _a:n("number",m);break;case wa:i(2,"number",m);break;case Ca:i(3,"number",m);break;case Sa:i(4,"number",m);break;case Oa:n("boolean",m);break;case Ea:i(2,"boolean",m);break;case Pa:i(3,"boolean",m);break;case La:i(4,"boolean",m);break;case Ta:i(4,"number",m);break;case Da:i(9,"number",m);break;case Ra:i(16,"number",m);break;case Ia:o(ca);break;case Fa:o(fa)}}));var S=1;switch(p){case Ia:case Fa:var k=e.def(y,"._texture");e(u,".uniform1i(",b,",",k,".bind());"),e.exit(k,".unbind();");continue;case ka:case Oa:s="1i";break;case Aa:case Ea:s="2i",S=2;break;case Ma:case Pa:s="3i",S=3;break;case za:case La:s="4i",S=4;break;case _a:s="1f";break;case wa:s="2f",S=2;break;case Ca:s="3f",S=3;break;case Sa:s="4f",S=4;break;case Ta:s="Matrix2fv";break;case Da:s="Matrix3fv";break;case Ra:s="Matrix4fv"}if(-1===s.indexOf("Matrix")&&m>1&&(s+="v",S=1),"M"===s.charAt(0)){e(u,".uniform",s,"(",b,",");var A=Math.pow(p-Ta+2,2),M=t.global.def("new Float32Array(",A,")");Array.isArray(y)?e("false,(",At(A,(function(t){return M+"["+t+"]="+y[t]})),",",M,")"):e("false,(Array.isArray(",y,")||",y," instanceof Float32Array)?",y,":(",At(A,(function(t){return M+"["+t+"]="+y+"["+t+"]"})),",",M,")"),e(");")}else if(S>1){for(var z=[],O=[],E=0;E<S;++E)Array.isArray(y)?O.push(y[E]):O.push(e.def(y+"["+E+"]")),a&&z.push(e.def());a&&e("if(!",t.batchId,"||",z.map((function(t,e){return t+"!=="+O[e]})).join("||"),"){",z.map((function(t,e){return t+"="+O[e]+";"})).join("")),e(u,".uniform",s,"(",b,",",O.join(","),");"),a&&e("}")}else{if(rt(!Array.isArray(y),"uniform value must not be an array"),a){var P=e.def();e("if(!",t.batchId,"||",P,"!==",y,"){",P,"=",y,";")}e(u,".uniform",s,"(",b,",",y,");"),a&&e("}")}}}function K(t,e,r,n){var i=t.shared,o=i.gl,a=i.draw,s=n.draw;function l(){var l,u=s.elements,c=e;return u?((u.contextDep&&n.contextDynamic||u.propDep)&&(c=r),l=u.append(t,c),s.elementsActive&&c("if("+l+")"+o+".bindBuffer("+ua+","+l+".buffer.buffer);")):(l=c.def(),c(l,"=",a,".",Ho,";","if(",l,"){",o,".bindBuffer(",ua,",",l,".buffer.buffer);}","else if(",i.vao,".currentVAO){",l,"=",t.shared.elements+".getElements("+i.vao,".currentVAO.elements);",x?"":"if("+l+")"+o+".bindBuffer("+ua+","+l+".buffer.buffer);","}")),l}function u(){var i,o=s.count,l=e;return o?((o.contextDep&&n.contextDynamic||o.propDep)&&(l=r),i=o.append(t,l),rt.optional((function(){o.MISSING&&t.assert(e,"false","missing vertex count"),o.DYNAMIC&&t.assert(l,i+">=0","missing vertex count")}))):(i=l.def(a,".",Qo),rt.optional((function(){t.assert(l,i+">=0","missing vertex count")}))),i}var c=l();function f(i){var o=s[i];return o?o.contextDep&&n.contextDynamic||o.propDep?o.append(t,r):o.append(t,e):e.def(a,".",i)}var h,d,p=f(Zo),m=f(Xo),v=u();if("number"==typeof v){if(0===v)return}else r("if(",v,"){"),r.exit("}");y&&(h=f(Yo),d=t.instancing);var g=c+".type",b=s.elements&&ls(s.elements)&&!s.vaoActive;function _(){function t(){r(d,".drawElementsInstancedANGLE(",[p,v,g,m+"<<(("+g+"-"+io+")>>1)",h],");")}function e(){r(d,".drawArraysInstancedANGLE(",[p,m,v,h],");")}c&&"null"!==c?b?t():(r("if(",c,"){"),t(),r("}else{"),e(),r("}")):e()}function w(){function t(){r(o+".drawElements("+[p,v,g,m+"<<(("+g+"-"+io+")>>1)"]+");")}function e(){r(o+".drawArrays("+[p,m,v]+");")}c&&"null"!==c?b?t():(r("if(",c,"){"),t(),r("}else{"),e(),r("}")):e()}y&&("number"!=typeof h||h>=0)?"string"==typeof h?(r("if(",h,">0){"),_(),r("}else if(",h,"<0){"),w(),r("}")):_():w()}function $(t,e,r,n,i){var o=L(),a=o.proc("body",i);return rt.optional((function(){o.commandStr=e.commandStr,o.command=o.link(e.commandStr)})),y&&(o.instancing=a.def(o.shared.extensions,".angle_instanced_arrays")),t(o,a,r,n),o.compile().body}function tt(t,e,r,n){Q(t,e),r.useVAO?r.drawVAO?e(t.shared.vao,".setVAO(",r.drawVAO.append(t,e),");"):e(t.shared.vao,".setVAO(",t.shared.vao,".targetVAO);"):(e(t.shared.vao,".setVAO(null);"),Y(t,e,r,n.attributes,(function(){return!0}))),J(t,e,r,n.uniforms,(function(){return!0}),!1),K(t,e,e,r)}function et(t,e){var r=t.proc("draw",1);Q(t,r),W(t,r,e.context),q(t,r,e.framebuffer),H(t,r,e),Z(t,r,e.state),X(t,r,e,!1,!0);var n=e.shader.progVar.append(t,r);if(r(t.shared.gl,".useProgram(",n,".program);"),e.shader.program)tt(t,r,e,e.shader.program);else{r(t.shared.vao,".setVAO(null);");var i=t.global.def("{}"),o=r.def(n,".id"),a=r.def(i,"[",o,"]");r(t.cond(a).then(a,".call(this,a0);").else(a,"=",i,"[",o,"]=",t.link((function(r){return $(tt,t,e,r,1)})),"(",n,");",a,".call(this,a0);"))}Object.keys(e.state).length>0&&r(t.shared.current,".dirty=true;"),t.shared.vao&&r(t.shared.vao,".setVAO(null);")}function nt(t,e,r,n){function i(){return!0}t.batchId="a1",Q(t,e),Y(t,e,r,n.attributes,i),J(t,e,r,n.uniforms,i,!1),K(t,e,e,r)}function it(t,e,r,n){Q(t,e);var i=r.contextDep,o=e.def(),a="a0",s="a1",l=e.def();t.shared.props=l,t.batchId=o;var u=t.scope(),c=t.scope();function f(t){return t.contextDep&&i||t.propDep}function h(t){return!f(t)}if(e(u.entry,"for(",o,"=0;",o,"<",s,";++",o,"){",l,"=",a,"[",o,"];",c,"}",u.exit),r.needsContext&&W(t,c,r.context),r.needsFramebuffer&&q(t,c,r.framebuffer),Z(t,c,r.state,f),r.profile&&f(r.profile)&&X(t,c,r,!1,!0),n)r.useVAO?r.drawVAO?f(r.drawVAO)?c(t.shared.vao,".setVAO(",r.drawVAO.append(t,c),");"):u(t.shared.vao,".setVAO(",r.drawVAO.append(t,u),");"):u(t.shared.vao,".setVAO(",t.shared.vao,".targetVAO);"):(u(t.shared.vao,".setVAO(null);"),Y(t,u,r,n.attributes,h),Y(t,c,r,n.attributes,f)),J(t,u,r,n.uniforms,h,!1),J(t,c,r,n.uniforms,f,!0),K(t,u,c,r);else{var d=t.global.def("{}"),p=r.shader.progVar.append(t,c),m=c.def(p,".id"),v=c.def(d,"[",m,"]");c(t.shared.gl,".useProgram(",p,".program);","if(!",v,"){",v,"=",d,"[",m,"]=",t.link((function(e){return $(nt,t,r,e,2)})),"(",p,");}",v,".call(this,a0[",o,"],",o,");")}}function ot(t,e){var r=t.proc("batch",2);t.batchId="0",Q(t,r);var n=!1,i=!0;Object.keys(e.context).forEach((function(t){n=n||e.context[t].propDep})),n||(W(t,r,e.context),i=!1);var o=e.framebuffer,a=!1;function s(t){return t.contextDep&&n||t.propDep}o?(o.propDep?n=a=!0:o.contextDep&&n&&(a=!0),a||q(t,r,o)):q(t,r,null),e.state.viewport&&e.state.viewport.propDep&&(n=!0),H(t,r,e),Z(t,r,e.state,(function(t){return!s(t)})),e.profile&&s(e.profile)||X(t,r,e,!1,"a1"),e.contextDep=n,e.needsContext=i,e.needsFramebuffer=a;var l=e.shader.progVar;if(l.contextDep&&n||l.propDep)it(t,r,e,null);else{var u=l.append(t,r);if(r(t.shared.gl,".useProgram(",u,".program);"),e.shader.program)it(t,r,e,e.shader.program);else{r(t.shared.vao,".setVAO(null);");var c=t.global.def("{}"),f=r.def(u,".id"),h=r.def(c,"[",f,"]");r(t.cond(h).then(h,".call(this,a0,a1);").else(h,"=",c,"[",f,"]=",t.link((function(r){return $(it,t,e,r,2)})),"(",u,");",h,".call(this,a0,a1);"))}}Object.keys(e.state).length>0&&r(t.shared.current,".dirty=true;"),t.shared.vao&&r(t.shared.vao,".setVAO(null);")}function at(t,e){var n=t.proc("scope",3);t.batchId="a2";var i=t.shared,o=i.current;function a(r){var o=e.shader[r];o&&n.set(i.shader,"."+r,o.append(t,n))}W(t,n,e.context),e.framebuffer&&e.framebuffer.append(t,n),as(Object.keys(e.state)).forEach((function(r){var o=e.state[r].append(t,n);cr(o)?o.forEach((function(e,i){n.set(t.next[r],"["+i+"]",e)})):n.set(i.next,"."+r,o)})),X(t,n,e,!0,!0),[Ho,Xo,Qo,Yo,Zo].forEach((function(r){var o=e.draw[r];o&&n.set(i.draw,"."+r,""+o.append(t,n))})),Object.keys(e.uniforms).forEach((function(o){var a=e.uniforms[o].append(t,n);Array.isArray(a)&&(a="["+a.join()+"]"),n.set(i.uniforms,"["+r.id(o)+"]",a)})),Object.keys(e.attributes).forEach((function(r){var i=e.attributes[r].append(t,n),o=t.scopeAttrib(r);Object.keys(new v).forEach((function(t){n.set(o,"."+t,i[t])}))})),e.scopeVAO&&n.set(i.vao,".targetVAO",e.scopeVAO.append(t,n)),a(Wo),a(qo),Object.keys(e.state).length>0&&(n(o,".dirty=true;"),n.exit(o,".dirty=true;")),n("a1(",t.shared.context,",a0,",t.batchId,");")}function st(t){if("object"==typeof t&&!cr(t)){for(var e=Object.keys(t),r=0;r<e.length;++r)if(pt.isDynamic(t[e[r]]))return!0;return!1}}function lt(t,e,r){var n=e.static[r];if(n&&st(n)){var i=t.global,o=Object.keys(n),a=!1,s=!1,l=!1,u=t.global.def("{}");o.forEach((function(e){var r=n[e];if(pt.isDynamic(r)){"function"==typeof r&&(r=n[e]=pt.unbox(r));var o=cs(r,null);a=a||o.thisDep,l=l||o.propDep,s=s||o.contextDep}else{switch(i(u,".",e,"="),typeof r){case"number":i(r);break;case"string":i('"',r,'"');break;case"object":Array.isArray(r)&&i("[",r.join(),"]");break;default:i(t.link(r))}i(";")}})),e.dynamic[r]=new pt.DynamicVariable(fo,{thisDep:a,contextDep:s,propDep:l,ref:u,append:c}),delete e.static[r]}function c(t,e){o.forEach((function(r){var i=n[r];if(pt.isDynamic(i)){var o=t.invoke(e,i);e(u,".",r,"=",o,";")}}))}}function ut(t,r,n,i,o){var a=L();a.stats=a.link(o),Object.keys(r.static).forEach((function(t){lt(a,r,t)})),sa.forEach((function(e){lt(a,t,e)}));var s=G(t,r,n,i,a);return et(a,s),at(a,s),ot(a,s),e(a.compile(),{destroy:function(){s.shader.program.destroy()}})}return{next:w,current:_,procs:function(){var t=L(),e=t.proc("poll"),r=t.proc("refresh"),o=t.block();e(o),r(o);var a,s=t.shared,l=s.gl,u=s.next,c=s.current;o(c,".dirty=false;"),q(t,e),q(t,r,null,!0),y&&(a=t.link(y)),n.oes_vertex_array_object&&r(t.link(n.oes_vertex_array_object),".bindVertexArrayOES(null);");for(var f=0;f<i.maxAttributes;++f){var h=r.def(s.attributes,"[",f,"]"),d=t.cond(h,".buffer");d.then(l,".enableVertexAttribArray(",f,");",l,".bindBuffer(",la,",",h,".buffer.buffer);",l,".vertexAttribPointer(",f,",",h,".size,",h,".type,",h,".normalized,",h,".stride,",h,".offset);").else(l,".disableVertexAttribArray(",f,");",l,".vertexAttrib4f(",f,",",h,".x,",h,".y,",h,".z,",h,".w);",h,".buffer=null;"),r(d),y&&r(a,".vertexAttribDivisorANGLE(",f,",",h,".divisor);")}return r(t.shared.vao,".currentVAO=null;",t.shared.vao,".setVAO(",t.shared.vao,".targetVAO);"),Object.keys(S).forEach((function(n){var i=S[n],a=o.def(u,".",n),s=t.block();s("if(",a,"){",l,".enable(",i,")}else{",l,".disable(",i,")}",c,".",n,"=",a,";"),r(s),e("if(",a,"!==",c,".",n,"){",s,"}")})),Object.keys(k).forEach((function(n){var i,a,s=k[n],f=_[n],h=t.block();if(h(l,".",s,"("),cr(f)){var d=f.length;i=t.global.def(u,".",n),a=t.global.def(c,".",n),h(At(d,(function(t){return i+"["+t+"]"})),");",At(d,(function(t){return a+"["+t+"]="+i+"["+t+"];"})).join("")),e("if(",At(d,(function(t){return i+"["+t+"]!=="+a+"["+t+"]"})).join("||"),"){",h,"}")}else i=o.def(u,".",n),a=o.def(c,".",n),h(i,");",c,".",n,"=",i,";"),e("if(",i,"!==",a,"){",h,"}");r(h)})),t.compile()}(),compile:ut}}function ds(){return{vaoCount:0,bufferCount:0,elementsCount:0,framebufferCount:0,shaderCount:0,textureCount:0,cubeCount:0,renderbufferCount:0,maxTextureUnits:0}}var ps=34918,ms=34919,vs=35007,gs=function(t,e){if(!e.ext_disjoint_timer_query)return null;var r=[];function n(){return r.pop()||e.ext_disjoint_timer_query.createQueryEXT()}function i(t){r.push(t)}var o=[];function a(t){var r=n();e.ext_disjoint_timer_query.beginQueryEXT(vs,r),o.push(r),d(o.length-1,o.length,t)}function s(){e.ext_disjoint_timer_query.endQueryEXT(vs)}function l(){this.startQueryIndex=-1,this.endQueryIndex=-1,this.sum=0,this.stats=null}var u=[];function c(){return u.pop()||new l}function f(t){u.push(t)}var h=[];function d(t,e,r){var n=c();n.startQueryIndex=t,n.endQueryIndex=e,n.sum=0,n.stats=r,h.push(n)}var p=[],m=[];function v(){var t,r,n=o.length;if(0!==n){m.length=Math.max(m.length,n+1),p.length=Math.max(p.length,n+1),p[0]=0,m[0]=0;var a=0;for(t=0,r=0;r<o.length;++r){var s=o[r];e.ext_disjoint_timer_query.getQueryObjectEXT(s,ms)?(a+=e.ext_disjoint_timer_query.getQueryObjectEXT(s,ps),i(s)):o[t++]=s,p[r+1]=a,m[r+1]=t}for(o.length=t,t=0,r=0;r<h.length;++r){var l=h[r],u=l.startQueryIndex,c=l.endQueryIndex;l.sum+=p[c]-p[u];var d=m[u],v=m[c];v===d?(l.stats.gpuTime+=l.sum/1e6,f(l)):(l.startQueryIndex=d,l.endQueryIndex=v,h[t++]=l)}h.length=t}}return{beginQuery:a,endQuery:s,pushScopeStats:d,update:v,getNumPendingQueries:function(){return o.length},clear:function(){r.push.apply(r,o);for(var t=0;t<r.length;t++)e.ext_disjoint_timer_query.deleteQueryEXT(r[t]);o.length=0,r.length=0},restore:function(){o.length=0,r.length=0}}},ys=16384,bs=256,xs=1024,_s=34962,ws="webglcontextlost",Cs="webglcontextrestored",Ss=1,ks=2,As=3;function Ms(t,e){for(var r=0;r<t.length;++r)if(t[r]===e)return r;return-1}function zs(t){var r=St(t);if(!r)return null;var n=r.gl,i=n.getContextAttributes(),o=n.isContextLost(),a=kt(n,r);if(!a)return null;var s=gt(),l=ds(),u=a.extensions,c=gs(n,u),f=vt(),h=n.drawingBufferWidth,d=n.drawingBufferHeight,p={tick:0,time:0,viewportWidth:h,viewportHeight:d,framebufferWidth:h,framebufferHeight:d,drawingBufferWidth:h,drawingBufferHeight:d,pixelRatio:r.pixelRatio},m={},v={elements:null,primitive:4,count:-1,offset:0,instances:-1},g=we(n,u),y=qe(n,l,r,_),b=or(n,u,y,l),x=Gi(n,u,g,l,y,b,v);function _(t){return x.destroyBuffer(t)}var w=Qi(n,s,l,r),C=Xn(n,u,g,(function(){A.procs.poll()}),p,l,r),S=ui(n,u,g,l,r),k=Fi(n,u,g,C,S,l),A=hs(n,s,u,g,y,b,C,k,m,x,w,v,p,c,r),M=$i(n,k,A.procs.poll,p,i,u,g),z=A.next,O=n.canvas,E=[],P=[],L=[],T=[r.onDestroy],D=null;function R(){if(0===E.length)return c&&c.update(),void(D=null);D=mt.next(R),Z();for(var t=E.length-1;t>=0;--t){var e=E[t];e&&e(p,null,0)}n.flush(),c&&c.update()}function I(){!D&&E.length>0&&(D=mt.next(R))}function F(){D&&(mt.cancel(R),D=null)}function B(t){t.preventDefault(),o=!0,F(),P.forEach((function(t){t()}))}function j(t){n.getError(),o=!1,a.restore(),w.restore(),y.restore(),C.restore(),S.restore(),k.restore(),x.restore(),c&&c.restore(),A.procs.refresh(),I(),L.forEach((function(t){t()}))}function V(){E.length=0,F(),O&&(O.removeEventListener(ws,B),O.removeEventListener(Cs,j)),w.clear(),k.clear(),S.clear(),x.clear(),C.clear(),b.clear(),y.clear(),c&&c.clear(),T.forEach((function(t){t()}))}function N(t){function r(t){var r=e({},t);function n(t){if(t in r){var e=r[t];delete r[t],Object.keys(e).forEach((function(n){r[t+"."+n]=e[n]}))}}return delete r.uniforms,delete r.attributes,delete r.context,delete r.vao,"stencil"in r&&r.stencil.op&&(r.stencil.opBack=r.stencil.opFront=r.stencil.op,delete r.stencil.op),n("blend"),n("depth"),n("cull"),n("stencil"),n("polygonOffset"),n("scissor"),n("sample"),"vao"in t&&(r.vao=t.vao),r}function n(t,e){var r={},n={};return Object.keys(t).forEach((function(i){var o=t[i];if(pt.isDynamic(o))n[i]=pt.unbox(o,i);else{if(e&&Array.isArray(o))for(var a=0;a<o.length;++a)if(pt.isDynamic(o[a]))return void(n[i]=pt.unbox(o,i));r[i]=o}})),{dynamic:n,static:r}}rt(!!t,"invalid args to regl({...})"),rt.type(t,"object","invalid args to regl({...})");var i=n(t.context||{},!0),a=n(t.uniforms||{},!0),s=n(t.attributes||{},!1),l=n(r(t),!1),u={gpuTime:0,cpuTime:0,count:0},c=A.compile(l,s,a,i,u),f=c.draw,h=c.batch,d=c.scope,p=[];function m(t){for(;p.length<t;)p.push(null);return p}function v(t,e){var r;if(o&&rt.raise("context lost"),"function"==typeof t)return d.call(this,null,t,0);if("function"==typeof e)if("number"==typeof t)for(r=0;r<t;++r)d.call(this,null,e,r);else{if(!Array.isArray(t))return d.call(this,t,e,0);for(r=0;r<t.length;++r)d.call(this,t[r],e,r)}else if("number"==typeof t){if(t>0)return h.call(this,m(0|t),0|t)}else{if(!Array.isArray(t))return f.call(this,t);if(t.length)return h.call(this,t,t.length)}}return e(v,{stats:u,destroy:function(){c.destroy()}})}O&&(O.addEventListener(ws,B,!1),O.addEventListener(Cs,j,!1));var U=k.setFBO=N({framebuffer:pt.define.call(null,Ss,"framebuffer")});function G(t,e){var r=0;A.procs.poll();var i=e.color;i&&(n.clearColor(+i[0]||0,+i[1]||0,+i[2]||0,+i[3]||0),r|=ys),"depth"in e&&(n.clearDepth(+e.depth),r|=bs),"stencil"in e&&(n.clearStencil(0|e.stencil),r|=xs),rt(!!r,"called regl.clear with no buffer specified"),n.clear(r)}function W(t){if(rt("object"==typeof t&&t,"regl.clear() takes an object as input"),"framebuffer"in t)if(t.framebuffer&&"framebufferCube"===t.framebuffer_reglType)for(var r=0;r<6;++r)U(e({framebuffer:t.framebuffer.faces[r]},t),G);else U(t,G);else G(null,t)}function q(t){function e(){var e=Ms(E,t);function r(){var t=Ms(E,r);E[t]=E[E.length-1],E.length-=1,E.length<=0&&F()}rt(e>=0,"cannot cancel a frame twice"),E[e]=r}return rt.type(t,"function","regl.frame() callback must be a function"),E.push(t),I(),{cancel:e}}function H(){var t=z.viewport,e=z.scissor_box;t[0]=t[1]=e[0]=e[1]=0,p.viewportWidth=p.framebufferWidth=p.drawingBufferWidth=t[2]=e[2]=n.drawingBufferWidth,p.viewportHeight=p.framebufferHeight=p.drawingBufferHeight=t[3]=e[3]=n.drawingBufferHeight}function Z(){p.tick+=1,p.time=X(),H(),A.procs.poll()}function Q(){C.refresh(),H(),A.procs.refresh(),c&&c.update()}function X(){return(vt()-f)/1e3}function Y(t,e){var r;switch(rt.type(e,"function","listener callback must be a function"),t){case"frame":return q(e);case"lost":r=P;break;case"restore":r=L;break;case"destroy":r=T;break;default:rt.raise("invalid event, must be one of frame,lost,restore,destroy")}return r.push(e),{cancel:function(){for(var t=0;t<r.length;++t)if(r[t]===e)return r[t]=r[r.length-1],void r.pop()}}}Q();var J=e(N,{clear:W,prop:pt.define.bind(null,Ss),context:pt.define.bind(null,ks),this:pt.define.bind(null,As),draw:N({}),buffer:function(t){return y.create(t,_s,!1,!1)},elements:function(t){return b.create(t,!1)},texture:C.create2D,cube:C.createCube,renderbuffer:S.create,framebuffer:k.create,framebufferCube:k.createCube,vao:x.createVAO,attributes:i,frame:q,on:Y,limits:g,hasExtension:function(t){return g.extensions.indexOf(t.toLowerCase())>=0},read:M,destroy:V,_gl:n,_refresh:Q,poll:function(){Z(),c&&c.update()},now:X,stats:l});return r.onDone(null,J),J}return zs}()})),z=function(){function t(){this._renderers=[]}return t.prototype.addRenderer=function(t){this._renderers.findIndex((function(e){return e===t}))<0&&this._renderers.push(t)},t.prototype.removeRenderer=function(t){var e=this._renderers.findIndex((function(e){return e===t}));e>-1&&this._renderers.splice(e,1)},t.prototype.destroyRenderers=function(){this._renderers.forEach((function(t){t.destroy()}))},t}(),O=function(){function t(){this._fusions=[]}return t.prototype.addFusion=function(t){this._fusions.findIndex((function(e){return e===t}))<0&&this._fusions.push(t)},t.prototype.removeFusion=function(t){var e=this._fusions.findIndex((function(e){return e===t}));e>-1&&this._fusions.splice(e,1)},t.prototype.destroyFusions=function(){this._fusions.forEach((function(t){t.destroy()}))},t}(),E="undefined"!=typeof Float32Array?Float32Array:Array;function P(t,e,r){var n=e[0],i=e[1],o=e[2],a=r[0],s=r[1],l=r[2];return t[0]=i*l-o*s,t[1]=o*a-n*l,t[2]=n*s-i*a,t}function L(t,e){var r=e[0],n=e[1],i=r*r+n*n;return i>0&&(i=1/Math.sqrt(i)),t[0]=e[0]*i,t[1]=e[1]*i,t}Math.hypot||(Math.hypot=function(){for(var t=0,e=arguments.length;e--;)t+=arguments[e]*arguments[e];return Math.sqrt(t)}),b=new E(3),E!=Float32Array&&(b[0]=0,b[1]=0,b[2]=0),function(){var t=new E(2);E!=Float32Array&&(t[0]=0,t[1]=0)}();var T=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e.trackConfig={},e._currentTrackIndex=-1,e}return i(e,t),e.prototype.addTrackAnimate=function(t,e){var r=t.path,n=t.timing,i=t.rotationSpeed,a=t.duration,s=this.cameraTrack(r),l=s.distances,u=s.angles,c=s.coords,h=s.allDistance,d=new f({x:0,y:0},{x:n[0][0],y:n[0][1]},{x:n[1][0],y:n[1][1]},{x:1,y:1}),p=Date.now();this.trackConfig=o(o({bezier:d,startTime:p,coords:c,distances:l,allDistance:h,angles:u},t),{angleTimes:this.rotateDuration(u,l,h,a,i),finish:e.bind(this)})},e.prototype.updateTrackAnimates=function(){if("start"===this.animateStatus){var t=Date.now(),e=this.trackConfig,r=e.timing,n=e.bezier,i=e.startTime,o=e.duration,a=e.finish,s=e.distances,l=e.allDistance,u=e.path,c=e.angles,f=e.angleTimes;if(s&&r){var h=t-i;h>o&&(a&&a(this.trackConfig),this.trackConfig={});for(var d=Math.min(1,h/o),p=0,m={index:0,segScale:0},v=l*n.get(d).y,g=0;g<s.length;g++){var y=s[g];if(p+y>=v){m.index=g,m.segScale=(v-p)/y;break}p+=y}var b=m.index,x=m.segScale,_=u[b],w=u[b+1];this._currentTrackIndex!=b&&this.map.map.setRotation(-c[b],!1,f[b]),this.setStatus({center:[_[0]+(w[0]-_[0])*x,_[1]+(w[1]-_[1])*x]}),this._currentTrackIndex=b}}},e.prototype.rotateDuration=function(t,e,r,n,i){for(var o=[],a=this.map.map.getRotation(),s=0;s<t.length;s++){var l=Math.abs(t[s]-a),u=0===s?1e3:e[s]/r*n,c=e[s]/r*n,f=l/i*1e3;o.push(Math.min(u,c,f)),a=t[s]}return o},e.prototype.cameraTrack=function(t){for(var e,r,n=[],i=[],o=[],a=!1,s=[0,1],l=0,u=0,c=t.length-1;u<c;u++){var f=a||A.project(t[u]),h=A.project(t[u+1]);n.push(Math.sqrt(Math.pow(f[0]-h[0],2)+Math.pow(f[1]-h[1],2)+Math.pow(f[2]-h[2],2))),l+=n[u],i.push(f);var d=[];L(d,[h[0]-f[0],h[1]-f[1]]);var p=[0,0,0];P(p,[s[0],s[1],0],[d[0],d[1],0]),o.push((o[u-1]||0)+(p[2]<0?1:-1)*Math.acos((e=d)[0]*(r=s)[0]+e[1]*r[1])*180/Math.PI),a=h,s=d}return{angles:o,coords:i,distances:n,allDistance:l}},e}(S),D=C.ColorUtil,R=function(t){function e(e){var r=t.call(this,"null",e)||this;r.size=[0,0],r.layers=[],r.rendererManager=new z,r.fusionManager=new O,r.controlContainer=document.createElement("div"),r.ambLight={color:"#fff",intensity:.5},r.dirLight={color:"rgb(255,255,255)",position:[0,-1,1],target:[0,0,0],intensity:.5},r.pointLight={color:"rgb(255,255,255)",position:[0,0,1e4],intensity:1,distance:0},r.map=e.map,r.viewControl=new T(r),r.coordinateCenter=e.coordinateCenter||[108.9398,34.3416],r.projection=A,r.projection.loca=r,r.customCoords=r.map.customCoords,r.camera=r.map.customCoords,r.camera.setCenter(r.coordinateCenter),r.initReGL(),r._animateRender();var n=r.map.getContainer();return r.controlContainer.className="amap-loca loca-controls",n.appendChild(r.controlContainer),r.map&&r.buryPoint.setAPIKey(window.AMap.getConfig().key),r.buryPoint.setVersion("2.0.0"),r.buryPoint.record("Loca"),r}return i(e,t),e.prototype.initReGL=function(){var t=this;if(this.map){var e=this.map.getGL&&this.map.getGL()||this.map.getContext().gl;e&&(M({gl:e,extensions:["OES_element_index_uint"],onDone:function(e,r){if(e)console.error(e);else{t.regl=r;var n=t.map.getContext();n&&n.setDirty(),t.requestRender()}}}),this.map.on("firstPaint",(function(){var e=t.map.getContext();e&&e.setDirty()})))}},e.prototype.requestRender=function(){this.map&&this.map.render()},e.prototype.add=function(t){this.map&&(this.layers.some((function(e){return e.id===t.id}))||(this.layers.push(t),t.setLoca(this),this.map.add(t.coreLayers)))},e.prototype.remove=function(t){if(this.map){var e=this.layers.findIndex((function(e){return e.id===t.id}));e>-1&&(this.layers.splice(e,1),this.map.remove(t.coreLayers),t.onRemove(),t.setLoca(null))}},e.prototype.getControlContainer=function(){return this.controlContainer},e.prototype.getCenter=function(){return this.map.getCenter().toArray()},e.prototype.getZoom=function(){return this.map.getZoom()},e.prototype.getPitch=function(){return this.map.getPitch()},e.prototype.getRotation=function(){return this.map.getRotation()},e.prototype.setRotation=function(t){this.map.setRotation(t,!0)},e.prototype.setZoom=function(t){this.map.setZoom(t,!0)},e.prototype.setCenter=function(t){this.map.setCenter(t,!0)},e.prototype.setPitch=function(t){this.map.setPitch(t,!0)},e.prototype.getLights=function(){var t=this.ambLight,e=t.intensity,r=t.color,n=this.dirLight,i=n.intensity,o=n.color,s=n.target,l=n.position,u=[s[0]-l[0],s[1]-l[1],s[2]-l[2]],c=this.pointLight,f=c.intensity,h=c.color,d=c.position,p=c.distance,m=this.customCoords.lngLatToCoord(d);return{ambIntensity:e,ambLightColor:D.colorToArray(r).slice(0,3),dirIntensity:i,dirLightColor:D.colorToArray(o).slice(0,3),dirVec:a(u),pointIntensity:f,pointLightColor:D.colorToArray(h).slice(0,3),pointPosition:[m[0],m[1],d[2]],pointDistence:p}},e.prototype.destroy=function(){this.animate.stop(),this.rendererManager.destroyRenderers(),this.fusionManager.destroyFusions();for(var t=0;this.layers.length>0;t=0)this.layers[t].destroy();this.regl.destroy(),this.animate.destroy(),this.map=null,this.animate=null},e.prototype._animateRender=function(){var t=this;this.animate.on("update",(function(){t.requestRender()}))},e}(y),I={title:{label:"图例",fontColor:"#fff",fontSize:"20px",fontWeight:"bold",padding:"0 0 5px 0",margin:0},style:{backgroundColor:"rgba(0,0,0,0.7)",fontSize:"14px",size:"16px",fontColor:"#fff",borderRadius:0,position:"absolute",padding:"10px 15px"},dataMap:[{label:"第一个",color:"#feedde"},{label:"第二个",color:"#fdbe85"},{label:"第三个",color:"#fd8d3c"},{label:"第四个",color:"#e6550d"},{label:"第五个",color:"#a63603"}]},F=function(){function t(t){this._loca=null,this._styles={},this._title={},this._loca=t.loca,this._ctrContainer=this._loca&&this._loca.getControlContainer(),this._container=document.createElement("div"),this._dataMap=t.dataMap||I.dataMap,this.setStyle(t),this.addTo(this._loca),h.record("Legend")}return t.prototype._createHTML=function(){var t,e,r=this,n=document.createElement("h5");n.innerHTML=this._title.label,n.style.cssText="color: "+this._title.fontColor+";font-size: "+this._title.fontSize+";text-align: "+this._title.textAlign+";font-weight: "+this._title.fontWeight+";padding: "+this._title.padding+";margin: "+this._title.margin+";";var i=document.createElement("ul");i.style.cssText="margin: 0; padding: 0; list-style: none;";var o="";this._dataMap.forEach((function(t){o+='\n                <li style="height: '+r._styles.size+'; box-sizing: content-box; padding: 2px 0;" ><span style="background-color: '+t.color+"; float:left; width: "+r._styles.size+"; height: "+r._styles.size+';"></span><a style="float:left; height: '+r._styles.size+"; line-height: "+r._styles.size+"; text-align: left; padding-left: 10px; font-size: "+r._styles.fontSize+"; color: "+r._styles.fontColor+';">'+t.label+"</a></li>\n            "})),i.innerHTML=o,this._container.innerHTML="",null===(t=this._container)||void 0===t||t.appendChild(n),null===(e=this._container)||void 0===e||e.appendChild(i)},t.prototype.setStyle=function(t){var e,r,n,i,o,a,s,l;void 0===t&&(t={style:{},title:{}});var u=I.style,c=t.style||{};this._styles.backgroundColor=c.backgroundColor||this._styles.backgroundColor||u.backgroundColor,this._styles.borderRadius=c.borderRadius||this._styles.borderRadius||u.borderRadius,this._styles.fontColor=c.fontColor||this._styles.fontColor||u.fontColor,this._styles.fontSize=c.fontSize||this._styles.fontSize||u.fontSize,this._styles.size=c.size||this._styles.size||u.size,this._styles.position=c.position||this._styles.position||u.position,this._styles.padding=c.padding||this._styles.padding||u.padding,this._styles.bottom=c.bottom||"",this._styles.right=c.right||"",this._styles.left=c.left||"",this._styles.top=c.top||"";var f=I.title,h=t.title||{};this._title.label=h.label||this._title.label||f.label,this._title.fontColor=h.fontColor||this._title.fontColor||f.fontColor,this._title.fontSize=h.fontSize||this._title.fontSize||f.fontSize,this._title.fontWeight=h.fontWeight||this._title.fontWeight||f.fontWeight,this._title.padding=h.padding||this._title.padding||f.padding,this._title.margin=h.margin||this._title.margin||f.margin,null===(e=this._container)||void 0===e||e.style.setProperty("background-color",this._styles.backgroundColor),null===(r=this._container)||void 0===r||r.style.setProperty("border-radius",this._styles.borderRadius),null===(n=this._container)||void 0===n||n.style.setProperty("position",this._styles.position),null===(i=this._container)||void 0===i||i.style.setProperty("padding",this._styles.padding),null===(o=this._container)||void 0===o||o.style.setProperty("bottom",this._styles.bottom),null===(a=this._container)||void 0===a||a.style.setProperty("right",this._styles.right),null===(s=this._container)||void 0===s||s.style.setProperty("left",this._styles.left),null===(l=this._container)||void 0===l||l.style.setProperty("top",this._styles.top),this._createHTML()},t.prototype.addTo=function(t){var e;t&&(this._loca=t,this._ctrContainer=t.getControlContainer(),this._container&&(null===(e=this._ctrContainer)||void 0===e||e.appendChild(this._container)))},t.prototype.remove=function(){var t;this._container&&(null===(t=this._ctrContainer)||void 0===t||t.removeChild(this._container)),this._ctrContainer=null,this._loca=null},t}(),B=function(t){function e(e){var r=t.call(this,e)||this;return r.id=C.CommonUtil.getGuid(),r.coreLayers=[],r.styleOptions={},r.customCenter=[102.216796875,37.9268676],r.colorPick=new d,r._needPickFrame=!1,r._pickPos=null,r._originMapState={},r._animate=new R.Animation,r._transitionOpacity=1,r._animateLayerState={},r.customCenter=e.customCenter||r.customCenter,r.loca=e.loca,r.loca&&(r.map=e.loca.map,r.onAdd()),r.projection=A,r}return i(e,t),e.prototype.onAdd=function(){t.prototype.onAdd.call(this),this.map&&this.loca&&(this.loca.add(this),this.loca.requestRender())},e.prototype.setLoca=function(t){void 0===t&&(t=null);var e=this.loca;this.loca=t,this.map=t?null==t?void 0:t.map:null,this.onAdd(),e&&e.requestRender()},e.prototype.createGLLayer=function(t){var e=this;if(window.AMap){var r=new window.AMap.GLCustomLayer({zIndex:t.zIndex,visible:t.visible,zooms:t.zooms,render:function(){e.render()}});r.beforeRender=this.beforeRender.bind(this),r.afterRender=this.afterRender.bind(this),this.coreLayers.push(r),this.map&&this.map.add(r)}},e.prototype.getLayerOptions=function(){return{opacity:this.opacity,zooms:this.zooms,visible:this.visible,zIndex:this.zIndex}},e.prototype.setOpacity=function(t){void 0===t&&(t=1),this.opacity=t,this.loca&&this.loca.requestRender()},e.prototype.setzIndex=function(t){void 0===t&&(t=10),this.zIndex=t,this.coreLayers.forEach((function(e){e.setzIndex(t)})),this.loca&&this.loca.requestRender()},e.prototype.setZooms=function(t){void 0===t&&(t=[2,20]),this.zooms=t,this.coreLayers.forEach((function(e){e.setZooms(t)})),this.loca&&this.loca.requestRender()},e.prototype.show=function(t,e){var r=this;if(void 0===t&&(t=0),this.visible=!0,this.coreLayers.forEach((function(t){t.show()})),t<=0)return this._transitionOpacity=1,void(this.loca&&this.loca.requestRender());this._transitionOpacity=0;var n=new R.Clip({duration:t},{opacity:[0,1]});this._animate.addClip(n),n.on("update",(function(t){r._transitionOpacity=t.keyframe.opacity,r.loca&&r.loca.requestRender()})),n.on("complete",(function(){r._animate.removeClip(n),e&&e.call(r)})),this._animate.start()},e.prototype.hide=function(t,e){var r=this;if(void 0===t&&(t=0),t<=0)return this.visible=!1,this._transitionOpacity=0,this.coreLayers.forEach((function(t){t.hide()})),void(this.loca&&this.loca.requestRender());this._transitionOpacity=1;var n=new R.Clip({duration:t},{opacity:[1,0]});this._animate.addClip(n),n.on("update",(function(t){r._transitionOpacity=t.keyframe.opacity,r.loca&&r.loca.requestRender()})),n.on("complete",(function(){r.visible=!1,r.coreLayers.forEach((function(t){t.hide()})),r._animate.removeClip(n),e&&e.call(r)})),this._animate.start()},e.prototype.setCustomCenter=function(t){this.customCenter=t,this.loca&&this.loca.requestRender()},e.prototype.beforeRender=function(){if(this.loca&&this.loca.regl){var t=this.loca.regl;this._pickFbo&&(this._pickFbo.width===t._gl.canvas.width&&this._pickFbo.height===t._gl.canvas.height||this._pickFbo({width:~~t._gl.canvas.width,height:~~t._gl.canvas.height})),this.loca.customCoords.setCenter(this.customCenter)}},e.prototype.remove=function(){var t;this.map&&this.loca&&(null===(t=this.loca)||void 0===t||t.remove(this),this.loca=null,this.map=null)},e.prototype.destroy=function(){this.remove(),this.styleOptions=null,this.fusion=null,this.renderer=null,this.dataset=[],this.meshes=[],this.source=null},e.prototype.queryFeature=function(t){var e,r,n;if(h.record(this.CLASS_NAME,"queryFeature"),this._canPickRender()&&(this._needPickFrame=!0,this._pickFbo&&t)){this._pickPos=t,this.pickRender();var i=(null===(e=this.loca)||void 0===e?void 0:e.regl)._gl,o=i.drawingBufferHeight/i.canvas.clientHeight,a=t[0]*o,s=i.drawingBufferHeight-t[1]*o,l=new Uint8Array(4);i.bindFramebuffer(i.FRAMEBUFFER,this._pickFbo._framebuffer.framebuffer),i.readPixels(a,s,1,1,i.RGBA,i.UNSIGNED_BYTE,l);var u=this.colorPick.getValue([l[0],l[1],l[2],l[3]]);return i.bindFramebuffer(i.FRAMEBUFFER,null),this._needPickFrame=!1,this._pickPos=null,(null===(r=this.loca)||void 0===r?void 0:r.map.getContext())&&(null===(n=this.loca)||void 0===n||n.map.getContext().setDirty()),u}},e.prototype.addAnimate=function(t,e){var r,n=this,i=new R.Clip({duration:t.duration,easing:t.easing,delay:t.delay,interval:t.repeat,repeat:t.repeat,startAt:t.startAt,yoyo:t.yoyo},((r={})[t.key]=t.value,r));this._animate.addClip(i),i.on("update",(function(e){n._animateLayerState[t.key]=e.keyframe[t.key],n.loca&&n.loca.requestRender()})),i.on("complete",(function(){n._animate.removeClip(i),e&&e.call(n)})),this._animate.start(),h.record(this.CLASS_NAME,"addAnimate")},e.prototype.createRenderer=function(){if(this.loca&&this.loca.regl&&!this._pickFbo){var t=this.loca.regl;this._pickFbo=t.framebuffer({width:~~t._gl.canvas.width,height:~~t._gl.canvas.height,stencil:!1})}},e.prototype.changeViewport=function(t,e){var r;if((this.map||!this.loca)&&(e=e||this._originMapState.size,t=t||this._originMapState.center,e&&t)){var n=null===(r=this.loca)||void 0===r?void 0:r.regl._gl,i=this.map.getCenter().toArray(),o=n.canvas.width,a=n.canvas.height;this._originMapState={center:i,size:[o,a]},n.canvas.width=e[0]*window.devicePixelRatio,n.canvas.height=e[1]*window.devicePixelRatio,n.canvas.style.width=e[0]+"px",n.canvas.style.height=e[1]+"px",n.viewport(0,0,n.canvas.width,n.canvas.height),this.map.updateView({size:e,center:t},!1)}},e.prototype._getOpacity=function(){return this._transitionOpacity*this.opacity},e.prototype._canPickRender=function(){var t;if(!this.loca)return!1;if(!this.visible)return!1;if(this.opacity<=0)return!1;var e=null===(t=this.loca)||void 0===t?void 0:t.getZoom();return!(e<this.zooms[0]||e>this.zooms[1])},e}(g),j={getLights:function(t){return{acceptLight:t.prop("acceptLight"),ambIntensity:t.prop("ambIntensity"),ambLightColor:t.prop("ambLightColor"),dirIntensity:t.prop("dirIntensity"),dirLightColor:t.prop("dirLightColor"),dirVec:t.prop("dirVec"),pointIntensity:t.prop("pointIntensity"),pointLightColor:t.prop("pointLightColor"),pointPosition:t.prop("pointPosition"),pointDistence:t.prop("pointDistence"),cameraPosition:t.prop("cameraPosition"),shininess:t.prop("shininess")}},getLightShader:function(){return"\n            uniform bool acceptLight;\n            uniform float ambIntensity;\n            uniform vec3 ambLightColor;\n\n            uniform float dirIntensity;\n            uniform vec3 dirLightColor;\n            uniform vec3 dirVec;\n\n            uniform float pointIntensity;\n            uniform float pointDistence;\n            uniform vec3 pointLightColor;\n            uniform vec3 pointPosition;\n            uniform vec3 cameraPosition;\n            uniform float shininess;\n\n            struct DiffHighLight {\n                vec3 diffuse;\n                vec3 hightLight;\n            };\n\n            // 环境反射\n            vec3 ambient() {\n                return ambLightColor * ambIntensity;\n            }\n\n            // 漫反射\n            vec3 diffuse(\n                vec3 normal,\n                vec3 lightDir,\n                vec3 lightColor,\n                float lightIntensity,\n                float weaken\n            ) {\n                vec3 nNormal = normalize(normal);\n                //计算光线方向和法向量的点积\n                float nDotL = max(dot(lightDir, nNormal), 0.0);\n                //计算漫反射光的颜色\n                return lightColor * nDotL * lightIntensity * weaken;\n            }\n\n            // 镜面反射\n            vec3 reflectLight(\n                vec3 cameraPosition,\n                vec3 lightDir,\n                vec3 position,\n                vec3 normal,\n                vec3 lightColor,\n                float shininess,\n                float lightIntensity,\n                float weaken\n            ) {\n                float specularLightWeighting = 0.0;\n                // vec3 lightDir = normalize(lightPosition - position);\n                vec3 cameraDirection = normalize(cameraPosition - position);\n                vec3 reflectionDirection = reflect(-lightDir, normal);\n                specularLightWeighting = pow(max(dot(reflectionDirection, cameraDirection), 0.0), shininess);\n                return lightColor * specularLightWeighting * lightIntensity * weaken;\n            }\n\n            // 计算衰减量\n            float lightWeaken(vec3 lightPosition, vec3 position, float distanceIntensity) {\n                // 光源和当前的距离，计算衰减\n                float dist = distance(lightPosition, position);\n                float weaken = 1.0 / (1.0 + dist + dist * dist);\n                if(distanceIntensity > 0.0) {\n                    weaken = clamp(-dist / distanceIntensity + 1.0, 0.0, 1.0);\n                } else {\n                    weaken = 1.0;\n                }\n                return weaken;\n            }\n\n            // 计算点光的漫反射和镜面反射\n            DiffHighLight pointLightCalc() {\n                vec3 normal = normalize(vNormal);\n                vec3 lightDir = normalize(pointPosition - vPosition);\n                float weaken = lightWeaken(pointPosition, vPosition, pointDistence);\n                vec3 diff = diffuse(normal, lightDir, pointLightColor, pointIntensity, weaken);\n                vec3 highL = reflectLight(cameraPosition, lightDir, vPosition, normal, pointLightColor, shininess, pointIntensity, weaken);\n                DiffHighLight result;\n                result.diffuse = diff;\n                result.hightLight = highL;\n                return result;\n            }\n\n            // 计算平行光的漫反射和镜面反射\n            DiffHighLight dirLightCalc() {\n                vec3 normal = normalize(vNormal);\n                vec3 diff = diffuse(normal, -dirVec, dirLightColor, dirIntensity, 1.0);\n                // vec3 highL = reflectLight(cameraPosition, dirVec, vPosition, normal, dirLightColor, shininess, dirIntensity, 1.0);\n                DiffHighLight result;\n                result.diffuse = diff;\n                result.hightLight = vec3(0);\n                return result;\n            }\n\n            // 计算最终的光和材质的光 颜色增益\n            vec3 lightColor(vec3 color) {\n                vec3 amb = ambient() * color;\n                DiffHighLight pointDiffHigh = pointLightCalc();\n                DiffHighLight dirDiffHigh = dirLightCalc();\n\n                return amb + dirDiffHigh.diffuse * color + dirDiffHigh.hightLight * color + pointDiffHigh.diffuse * color + pointDiffHigh.hightLight * color;;\n            }\n        "}},V={getColor:function(t){return{uniform:{isPick:t.prop("isPick")},attribute:{pickColor:t.prop("pickColor")}}},getColorShader:function(){return{vertex:"\n                uniform bool isPick;\n                attribute vec4 pickColor;\n                varying vec4 vPickColor;\n            ",fragment:"\n                uniform bool isPick;\n                varying vec4 vPickColor;\n            ",mainVert:"\n                vPickColor = pickColor;\n            ",mainFrag:"\n                if(isPick) {\n                    gl_FragColor = vec4(vPickColor.xyzw / 255.0);\n                }\n            "}}},N={Util:C,Light:j,Style:_,Layer:B,Legend:F,Project:k,Geometry:m,Container:R,ColorPick:d,ColorGLSL:V,Animation:R.Animation,Clip:R.Clip,ViewControl:S,GeoJSONSource:p,StyleInstance:w,GeometryFusion:v};r.ColorGLSL=V,r.ColorPick=d,r.Container=R,r.GeoJSONSource=p,r.Geometry=m,r.GeometryFusion=v,r.Layer=B,r.Legend=F,r.Light=j,r.Project=k,r.Style=_,r.StyleInstance=w,r.Util=C,r.ViewControl=S,r.default=N,Object.defineProperty(r,"__esModule",{value:!0})}(n)}));(n=i)&&n.__esModule&&Object.prototype.hasOwnProperty.call(n,"default")&&n.default;var o=1e-6,a="undefined"!=typeof Float32Array?Float32Array:Array,s=Math.random;var l=Math.PI/180;Math.hypot||(Math.hypot=function(){for(var t=0,e=arguments.length;e--;)t+=arguments[e]*arguments[e];return Math.sqrt(t)});var u=Object.freeze({__proto__:null,EPSILON:o,get ARRAY_TYPE(){return a},RANDOM:s,setMatrixArrayType:function(t){a=t},toRadian:function(t){return t*l},equals:function(t,e){return Math.abs(t-e)<=o*Math.max(1,Math.abs(t),Math.abs(e))}});function c(t,e,r){var n=e[0],i=e[1],o=e[2],a=e[3],s=r[0],l=r[1],u=r[2],c=r[3];return t[0]=n*s+o*l,t[1]=i*s+a*l,t[2]=n*u+o*c,t[3]=i*u+a*c,t}function f(t,e,r){return t[0]=e[0]-r[0],t[1]=e[1]-r[1],t[2]=e[2]-r[2],t[3]=e[3]-r[3],t}var h=c,d=f,p=Object.freeze({__proto__:null,create:function(){var t=new a(4);return a!=Float32Array&&(t[1]=0,t[2]=0),t[0]=1,t[3]=1,t},clone:function(t){var e=new a(4);return e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3],e},copy:function(t,e){return t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[3],t},identity:function(t){return t[0]=1,t[1]=0,t[2]=0,t[3]=1,t},fromValues:function(t,e,r,n){var i=new a(4);return i[0]=t,i[1]=e,i[2]=r,i[3]=n,i},set:function(t,e,r,n,i){return t[0]=e,t[1]=r,t[2]=n,t[3]=i,t},transpose:function(t,e){if(t===e){var r=e[1];t[1]=e[2],t[2]=r}else t[0]=e[0],t[1]=e[2],t[2]=e[1],t[3]=e[3];return t},invert:function(t,e){var r=e[0],n=e[1],i=e[2],o=e[3],a=r*o-i*n;return a?(a=1/a,t[0]=o*a,t[1]=-n*a,t[2]=-i*a,t[3]=r*a,t):null},adjoint:function(t,e){var r=e[0];return t[0]=e[3],t[1]=-e[1],t[2]=-e[2],t[3]=r,t},determinant:function(t){return t[0]*t[3]-t[2]*t[1]},multiply:c,rotate:function(t,e,r){var n=e[0],i=e[1],o=e[2],a=e[3],s=Math.sin(r),l=Math.cos(r);return t[0]=n*l+o*s,t[1]=i*l+a*s,t[2]=n*-s+o*l,t[3]=i*-s+a*l,t},scale:function(t,e,r){var n=e[0],i=e[1],o=e[2],a=e[3],s=r[0],l=r[1];return t[0]=n*s,t[1]=i*s,t[2]=o*l,t[3]=a*l,t},fromRotation:function(t,e){var r=Math.sin(e),n=Math.cos(e);return t[0]=n,t[1]=r,t[2]=-r,t[3]=n,t},fromScaling:function(t,e){return t[0]=e[0],t[1]=0,t[2]=0,t[3]=e[1],t},str:function(t){return"mat2("+t[0]+", "+t[1]+", "+t[2]+", "+t[3]+")"},frob:function(t){return Math.hypot(t[0],t[1],t[2],t[3])},LDU:function(t,e,r,n){return t[2]=n[2]/n[0],r[0]=n[0],r[1]=n[1],r[3]=n[3]-t[2]*r[1],[t,e,r]},add:function(t,e,r){return t[0]=e[0]+r[0],t[1]=e[1]+r[1],t[2]=e[2]+r[2],t[3]=e[3]+r[3],t},subtract:f,exactEquals:function(t,e){return t[0]===e[0]&&t[1]===e[1]&&t[2]===e[2]&&t[3]===e[3]},equals:function(t,e){var r=t[0],n=t[1],i=t[2],a=t[3],s=e[0],l=e[1],u=e[2],c=e[3];return Math.abs(r-s)<=o*Math.max(1,Math.abs(r),Math.abs(s))&&Math.abs(n-l)<=o*Math.max(1,Math.abs(n),Math.abs(l))&&Math.abs(i-u)<=o*Math.max(1,Math.abs(i),Math.abs(u))&&Math.abs(a-c)<=o*Math.max(1,Math.abs(a),Math.abs(c))},multiplyScalar:function(t,e,r){return t[0]=e[0]*r,t[1]=e[1]*r,t[2]=e[2]*r,t[3]=e[3]*r,t},multiplyScalarAndAdd:function(t,e,r,n){return t[0]=e[0]+r[0]*n,t[1]=e[1]+r[1]*n,t[2]=e[2]+r[2]*n,t[3]=e[3]+r[3]*n,t},mul:h,sub:d});function m(t,e,r){var n=e[0],i=e[1],o=e[2],a=e[3],s=e[4],l=e[5],u=r[0],c=r[1],f=r[2],h=r[3],d=r[4],p=r[5];return t[0]=n*u+o*c,t[1]=i*u+a*c,t[2]=n*f+o*h,t[3]=i*f+a*h,t[4]=n*d+o*p+s,t[5]=i*d+a*p+l,t}function v(t,e,r){return t[0]=e[0]-r[0],t[1]=e[1]-r[1],t[2]=e[2]-r[2],t[3]=e[3]-r[3],t[4]=e[4]-r[4],t[5]=e[5]-r[5],t}var g=m,y=v,b=Object.freeze({__proto__:null,create:function(){var t=new a(6);return a!=Float32Array&&(t[1]=0,t[2]=0,t[4]=0,t[5]=0),t[0]=1,t[3]=1,t},clone:function(t){var e=new a(6);return e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3],e[4]=t[4],e[5]=t[5],e},copy:function(t,e){return t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[3],t[4]=e[4],t[5]=e[5],t},identity:function(t){return t[0]=1,t[1]=0,t[2]=0,t[3]=1,t[4]=0,t[5]=0,t},fromValues:function(t,e,r,n,i,o){var s=new a(6);return s[0]=t,s[1]=e,s[2]=r,s[3]=n,s[4]=i,s[5]=o,s},set:function(t,e,r,n,i,o,a){return t[0]=e,t[1]=r,t[2]=n,t[3]=i,t[4]=o,t[5]=a,t},invert:function(t,e){var r=e[0],n=e[1],i=e[2],o=e[3],a=e[4],s=e[5],l=r*o-n*i;return l?(l=1/l,t[0]=o*l,t[1]=-n*l,t[2]=-i*l,t[3]=r*l,t[4]=(i*s-o*a)*l,t[5]=(n*a-r*s)*l,t):null},determinant:function(t){return t[0]*t[3]-t[1]*t[2]},multiply:m,rotate:function(t,e,r){var n=e[0],i=e[1],o=e[2],a=e[3],s=e[4],l=e[5],u=Math.sin(r),c=Math.cos(r);return t[0]=n*c+o*u,t[1]=i*c+a*u,t[2]=n*-u+o*c,t[3]=i*-u+a*c,t[4]=s,t[5]=l,t},scale:function(t,e,r){var n=e[0],i=e[1],o=e[2],a=e[3],s=e[4],l=e[5],u=r[0],c=r[1];return t[0]=n*u,t[1]=i*u,t[2]=o*c,t[3]=a*c,t[4]=s,t[5]=l,t},translate:function(t,e,r){var n=e[0],i=e[1],o=e[2],a=e[3],s=e[4],l=e[5],u=r[0],c=r[1];return t[0]=n,t[1]=i,t[2]=o,t[3]=a,t[4]=n*u+o*c+s,t[5]=i*u+a*c+l,t},fromRotation:function(t,e){var r=Math.sin(e),n=Math.cos(e);return t[0]=n,t[1]=r,t[2]=-r,t[3]=n,t[4]=0,t[5]=0,t},fromScaling:function(t,e){return t[0]=e[0],t[1]=0,t[2]=0,t[3]=e[1],t[4]=0,t[5]=0,t},fromTranslation:function(t,e){return t[0]=1,t[1]=0,t[2]=0,t[3]=1,t[4]=e[0],t[5]=e[1],t},str:function(t){return"mat2d("+t[0]+", "+t[1]+", "+t[2]+", "+t[3]+", "+t[4]+", "+t[5]+")"},frob:function(t){return Math.hypot(t[0],t[1],t[2],t[3],t[4],t[5],1)},add:function(t,e,r){return t[0]=e[0]+r[0],t[1]=e[1]+r[1],t[2]=e[2]+r[2],t[3]=e[3]+r[3],t[4]=e[4]+r[4],t[5]=e[5]+r[5],t},subtract:v,multiplyScalar:function(t,e,r){return t[0]=e[0]*r,t[1]=e[1]*r,t[2]=e[2]*r,t[3]=e[3]*r,t[4]=e[4]*r,t[5]=e[5]*r,t},multiplyScalarAndAdd:function(t,e,r,n){return t[0]=e[0]+r[0]*n,t[1]=e[1]+r[1]*n,t[2]=e[2]+r[2]*n,t[3]=e[3]+r[3]*n,t[4]=e[4]+r[4]*n,t[5]=e[5]+r[5]*n,t},exactEquals:function(t,e){return t[0]===e[0]&&t[1]===e[1]&&t[2]===e[2]&&t[3]===e[3]&&t[4]===e[4]&&t[5]===e[5]},equals:function(t,e){var r=t[0],n=t[1],i=t[2],a=t[3],s=t[4],l=t[5],u=e[0],c=e[1],f=e[2],h=e[3],d=e[4],p=e[5];return Math.abs(r-u)<=o*Math.max(1,Math.abs(r),Math.abs(u))&&Math.abs(n-c)<=o*Math.max(1,Math.abs(n),Math.abs(c))&&Math.abs(i-f)<=o*Math.max(1,Math.abs(i),Math.abs(f))&&Math.abs(a-h)<=o*Math.max(1,Math.abs(a),Math.abs(h))&&Math.abs(s-d)<=o*Math.max(1,Math.abs(s),Math.abs(d))&&Math.abs(l-p)<=o*Math.max(1,Math.abs(l),Math.abs(p))},mul:g,sub:y});function x(){var t=new a(9);return a!=Float32Array&&(t[1]=0,t[2]=0,t[3]=0,t[5]=0,t[6]=0,t[7]=0),t[0]=1,t[4]=1,t[8]=1,t}function _(t,e,r){var n=e[0],i=e[1],o=e[2],a=e[3],s=e[4],l=e[5],u=e[6],c=e[7],f=e[8],h=r[0],d=r[1],p=r[2],m=r[3],v=r[4],g=r[5],y=r[6],b=r[7],x=r[8];return t[0]=h*n+d*a+p*u,t[1]=h*i+d*s+p*c,t[2]=h*o+d*l+p*f,t[3]=m*n+v*a+g*u,t[4]=m*i+v*s+g*c,t[5]=m*o+v*l+g*f,t[6]=y*n+b*a+x*u,t[7]=y*i+b*s+x*c,t[8]=y*o+b*l+x*f,t}function w(t,e,r){return t[0]=e[0]-r[0],t[1]=e[1]-r[1],t[2]=e[2]-r[2],t[3]=e[3]-r[3],t[4]=e[4]-r[4],t[5]=e[5]-r[5],t[6]=e[6]-r[6],t[7]=e[7]-r[7],t[8]=e[8]-r[8],t}var C=_,S=w,k=Object.freeze({__proto__:null,create:x,fromMat4:function(t,e){return t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[4],t[4]=e[5],t[5]=e[6],t[6]=e[8],t[7]=e[9],t[8]=e[10],t},clone:function(t){var e=new a(9);return e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3],e[4]=t[4],e[5]=t[5],e[6]=t[6],e[7]=t[7],e[8]=t[8],e},copy:function(t,e){return t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[3],t[4]=e[4],t[5]=e[5],t[6]=e[6],t[7]=e[7],t[8]=e[8],t},fromValues:function(t,e,r,n,i,o,s,l,u){var c=new a(9);return c[0]=t,c[1]=e,c[2]=r,c[3]=n,c[4]=i,c[5]=o,c[6]=s,c[7]=l,c[8]=u,c},set:function(t,e,r,n,i,o,a,s,l,u){return t[0]=e,t[1]=r,t[2]=n,t[3]=i,t[4]=o,t[5]=a,t[6]=s,t[7]=l,t[8]=u,t},identity:function(t){return t[0]=1,t[1]=0,t[2]=0,t[3]=0,t[4]=1,t[5]=0,t[6]=0,t[7]=0,t[8]=1,t},transpose:function(t,e){if(t===e){var r=e[1],n=e[2],i=e[5];t[1]=e[3],t[2]=e[6],t[3]=r,t[5]=e[7],t[6]=n,t[7]=i}else t[0]=e[0],t[1]=e[3],t[2]=e[6],t[3]=e[1],t[4]=e[4],t[5]=e[7],t[6]=e[2],t[7]=e[5],t[8]=e[8];return t},invert:function(t,e){var r=e[0],n=e[1],i=e[2],o=e[3],a=e[4],s=e[5],l=e[6],u=e[7],c=e[8],f=c*a-s*u,h=-c*o+s*l,d=u*o-a*l,p=r*f+n*h+i*d;return p?(p=1/p,t[0]=f*p,t[1]=(-c*n+i*u)*p,t[2]=(s*n-i*a)*p,t[3]=h*p,t[4]=(c*r-i*l)*p,t[5]=(-s*r+i*o)*p,t[6]=d*p,t[7]=(-u*r+n*l)*p,t[8]=(a*r-n*o)*p,t):null},adjoint:function(t,e){var r=e[0],n=e[1],i=e[2],o=e[3],a=e[4],s=e[5],l=e[6],u=e[7],c=e[8];return t[0]=a*c-s*u,t[1]=i*u-n*c,t[2]=n*s-i*a,t[3]=s*l-o*c,t[4]=r*c-i*l,t[5]=i*o-r*s,t[6]=o*u-a*l,t[7]=n*l-r*u,t[8]=r*a-n*o,t},determinant:function(t){var e=t[0],r=t[1],n=t[2],i=t[3],o=t[4],a=t[5],s=t[6],l=t[7],u=t[8];return e*(u*o-a*l)+r*(-u*i+a*s)+n*(l*i-o*s)},multiply:_,translate:function(t,e,r){var n=e[0],i=e[1],o=e[2],a=e[3],s=e[4],l=e[5],u=e[6],c=e[7],f=e[8],h=r[0],d=r[1];return t[0]=n,t[1]=i,t[2]=o,t[3]=a,t[4]=s,t[5]=l,t[6]=h*n+d*a+u,t[7]=h*i+d*s+c,t[8]=h*o+d*l+f,t},rotate:function(t,e,r){var n=e[0],i=e[1],o=e[2],a=e[3],s=e[4],l=e[5],u=e[6],c=e[7],f=e[8],h=Math.sin(r),d=Math.cos(r);return t[0]=d*n+h*a,t[1]=d*i+h*s,t[2]=d*o+h*l,t[3]=d*a-h*n,t[4]=d*s-h*i,t[5]=d*l-h*o,t[6]=u,t[7]=c,t[8]=f,t},scale:function(t,e,r){var n=r[0],i=r[1];return t[0]=n*e[0],t[1]=n*e[1],t[2]=n*e[2],t[3]=i*e[3],t[4]=i*e[4],t[5]=i*e[5],t[6]=e[6],t[7]=e[7],t[8]=e[8],t},fromTranslation:function(t,e){return t[0]=1,t[1]=0,t[2]=0,t[3]=0,t[4]=1,t[5]=0,t[6]=e[0],t[7]=e[1],t[8]=1,t},fromRotation:function(t,e){var r=Math.sin(e),n=Math.cos(e);return t[0]=n,t[1]=r,t[2]=0,t[3]=-r,t[4]=n,t[5]=0,t[6]=0,t[7]=0,t[8]=1,t},fromScaling:function(t,e){return t[0]=e[0],t[1]=0,t[2]=0,t[3]=0,t[4]=e[1],t[5]=0,t[6]=0,t[7]=0,t[8]=1,t},fromMat2d:function(t,e){return t[0]=e[0],t[1]=e[1],t[2]=0,t[3]=e[2],t[4]=e[3],t[5]=0,t[6]=e[4],t[7]=e[5],t[8]=1,t},fromQuat:function(t,e){var r=e[0],n=e[1],i=e[2],o=e[3],a=r+r,s=n+n,l=i+i,u=r*a,c=n*a,f=n*s,h=i*a,d=i*s,p=i*l,m=o*a,v=o*s,g=o*l;return t[0]=1-f-p,t[3]=c-g,t[6]=h+v,t[1]=c+g,t[4]=1-u-p,t[7]=d-m,t[2]=h-v,t[5]=d+m,t[8]=1-u-f,t},normalFromMat4:function(t,e){var r=e[0],n=e[1],i=e[2],o=e[3],a=e[4],s=e[5],l=e[6],u=e[7],c=e[8],f=e[9],h=e[10],d=e[11],p=e[12],m=e[13],v=e[14],g=e[15],y=r*s-n*a,b=r*l-i*a,x=r*u-o*a,_=n*l-i*s,w=n*u-o*s,C=i*u-o*l,S=c*m-f*p,k=c*v-h*p,A=c*g-d*p,M=f*v-h*m,z=f*g-d*m,O=h*g-d*v,E=y*O-b*z+x*M+_*A-w*k+C*S;return E?(E=1/E,t[0]=(s*O-l*z+u*M)*E,t[1]=(l*A-a*O-u*k)*E,t[2]=(a*z-s*A+u*S)*E,t[3]=(i*z-n*O-o*M)*E,t[4]=(r*O-i*A+o*k)*E,t[5]=(n*A-r*z-o*S)*E,t[6]=(m*C-v*w+g*_)*E,t[7]=(v*x-p*C-g*b)*E,t[8]=(p*w-m*x+g*y)*E,t):null},projection:function(t,e,r){return t[0]=2/e,t[1]=0,t[2]=0,t[3]=0,t[4]=-2/r,t[5]=0,t[6]=-1,t[7]=1,t[8]=1,t},str:function(t){return"mat3("+t[0]+", "+t[1]+", "+t[2]+", "+t[3]+", "+t[4]+", "+t[5]+", "+t[6]+", "+t[7]+", "+t[8]+")"},frob:function(t){return Math.hypot(t[0],t[1],t[2],t[3],t[4],t[5],t[6],t[7],t[8])},add:function(t,e,r){return t[0]=e[0]+r[0],t[1]=e[1]+r[1],t[2]=e[2]+r[2],t[3]=e[3]+r[3],t[4]=e[4]+r[4],t[5]=e[5]+r[5],t[6]=e[6]+r[6],t[7]=e[7]+r[7],t[8]=e[8]+r[8],t},subtract:w,multiplyScalar:function(t,e,r){return t[0]=e[0]*r,t[1]=e[1]*r,t[2]=e[2]*r,t[3]=e[3]*r,t[4]=e[4]*r,t[5]=e[5]*r,t[6]=e[6]*r,t[7]=e[7]*r,t[8]=e[8]*r,t},multiplyScalarAndAdd:function(t,e,r,n){return t[0]=e[0]+r[0]*n,t[1]=e[1]+r[1]*n,t[2]=e[2]+r[2]*n,t[3]=e[3]+r[3]*n,t[4]=e[4]+r[4]*n,t[5]=e[5]+r[5]*n,t[6]=e[6]+r[6]*n,t[7]=e[7]+r[7]*n,t[8]=e[8]+r[8]*n,t},exactEquals:function(t,e){return t[0]===e[0]&&t[1]===e[1]&&t[2]===e[2]&&t[3]===e[3]&&t[4]===e[4]&&t[5]===e[5]&&t[6]===e[6]&&t[7]===e[7]&&t[8]===e[8]},equals:function(t,e){var r=t[0],n=t[1],i=t[2],a=t[3],s=t[4],l=t[5],u=t[6],c=t[7],f=t[8],h=e[0],d=e[1],p=e[2],m=e[3],v=e[4],g=e[5],y=e[6],b=e[7],x=e[8];return Math.abs(r-h)<=o*Math.max(1,Math.abs(r),Math.abs(h))&&Math.abs(n-d)<=o*Math.max(1,Math.abs(n),Math.abs(d))&&Math.abs(i-p)<=o*Math.max(1,Math.abs(i),Math.abs(p))&&Math.abs(a-m)<=o*Math.max(1,Math.abs(a),Math.abs(m))&&Math.abs(s-v)<=o*Math.max(1,Math.abs(s),Math.abs(v))&&Math.abs(l-g)<=o*Math.max(1,Math.abs(l),Math.abs(g))&&Math.abs(u-y)<=o*Math.max(1,Math.abs(u),Math.abs(y))&&Math.abs(c-b)<=o*Math.max(1,Math.abs(c),Math.abs(b))&&Math.abs(f-x)<=o*Math.max(1,Math.abs(f),Math.abs(x))},mul:C,sub:S});function A(t){return t[0]=1,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=1,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[10]=1,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,t}function M(t,e,r){var n=e[0],i=e[1],o=e[2],a=e[3],s=e[4],l=e[5],u=e[6],c=e[7],f=e[8],h=e[9],d=e[10],p=e[11],m=e[12],v=e[13],g=e[14],y=e[15],b=r[0],x=r[1],_=r[2],w=r[3];return t[0]=b*n+x*s+_*f+w*m,t[1]=b*i+x*l+_*h+w*v,t[2]=b*o+x*u+_*d+w*g,t[3]=b*a+x*c+_*p+w*y,b=r[4],x=r[5],_=r[6],w=r[7],t[4]=b*n+x*s+_*f+w*m,t[5]=b*i+x*l+_*h+w*v,t[6]=b*o+x*u+_*d+w*g,t[7]=b*a+x*c+_*p+w*y,b=r[8],x=r[9],_=r[10],w=r[11],t[8]=b*n+x*s+_*f+w*m,t[9]=b*i+x*l+_*h+w*v,t[10]=b*o+x*u+_*d+w*g,t[11]=b*a+x*c+_*p+w*y,b=r[12],x=r[13],_=r[14],w=r[15],t[12]=b*n+x*s+_*f+w*m,t[13]=b*i+x*l+_*h+w*v,t[14]=b*o+x*u+_*d+w*g,t[15]=b*a+x*c+_*p+w*y,t}function z(t,e,r){var n=e[0],i=e[1],o=e[2],a=e[3],s=n+n,l=i+i,u=o+o,c=n*s,f=n*l,h=n*u,d=i*l,p=i*u,m=o*u,v=a*s,g=a*l,y=a*u;return t[0]=1-(d+m),t[1]=f+y,t[2]=h-g,t[3]=0,t[4]=f-y,t[5]=1-(c+m),t[6]=p+v,t[7]=0,t[8]=h+g,t[9]=p-v,t[10]=1-(c+d),t[11]=0,t[12]=r[0],t[13]=r[1],t[14]=r[2],t[15]=1,t}function O(t,e){return t[0]=e[12],t[1]=e[13],t[2]=e[14],t}function E(t,e){var r=e[0],n=e[1],i=e[2],o=e[4],a=e[5],s=e[6],l=e[8],u=e[9],c=e[10];return t[0]=Math.hypot(r,n,i),t[1]=Math.hypot(o,a,s),t[2]=Math.hypot(l,u,c),t}function P(t,e){var r=new a(3);E(r,e);var n=1/r[0],i=1/r[1],o=1/r[2],s=e[0]*n,l=e[1]*i,u=e[2]*o,c=e[4]*n,f=e[5]*i,h=e[6]*o,d=e[8]*n,p=e[9]*i,m=e[10]*o,v=s+f+m,g=0;return v>0?(g=2*Math.sqrt(v+1),t[3]=.25*g,t[0]=(h-p)/g,t[1]=(d-u)/g,t[2]=(l-c)/g):s>f&&s>m?(g=2*Math.sqrt(1+s-f-m),t[3]=(h-p)/g,t[0]=.25*g,t[1]=(l+c)/g,t[2]=(d+u)/g):f>m?(g=2*Math.sqrt(1+f-s-m),t[3]=(d-u)/g,t[0]=(l+c)/g,t[1]=.25*g,t[2]=(h+p)/g):(g=2*Math.sqrt(1+m-s-f),t[3]=(l-c)/g,t[0]=(d+u)/g,t[1]=(h+p)/g,t[2]=.25*g),t}function L(t,e,r){return t[0]=e[0]-r[0],t[1]=e[1]-r[1],t[2]=e[2]-r[2],t[3]=e[3]-r[3],t[4]=e[4]-r[4],t[5]=e[5]-r[5],t[6]=e[6]-r[6],t[7]=e[7]-r[7],t[8]=e[8]-r[8],t[9]=e[9]-r[9],t[10]=e[10]-r[10],t[11]=e[11]-r[11],t[12]=e[12]-r[12],t[13]=e[13]-r[13],t[14]=e[14]-r[14],t[15]=e[15]-r[15],t}var T=M,D=L,R=Object.freeze({__proto__:null,create:function(){var t=new a(16);return a!=Float32Array&&(t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[11]=0,t[12]=0,t[13]=0,t[14]=0),t[0]=1,t[5]=1,t[10]=1,t[15]=1,t},clone:function(t){var e=new a(16);return e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3],e[4]=t[4],e[5]=t[5],e[6]=t[6],e[7]=t[7],e[8]=t[8],e[9]=t[9],e[10]=t[10],e[11]=t[11],e[12]=t[12],e[13]=t[13],e[14]=t[14],e[15]=t[15],e},copy:function(t,e){return t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[3],t[4]=e[4],t[5]=e[5],t[6]=e[6],t[7]=e[7],t[8]=e[8],t[9]=e[9],t[10]=e[10],t[11]=e[11],t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15],t},fromValues:function(t,e,r,n,i,o,s,l,u,c,f,h,d,p,m,v){var g=new a(16);return g[0]=t,g[1]=e,g[2]=r,g[3]=n,g[4]=i,g[5]=o,g[6]=s,g[7]=l,g[8]=u,g[9]=c,g[10]=f,g[11]=h,g[12]=d,g[13]=p,g[14]=m,g[15]=v,g},set:function(t,e,r,n,i,o,a,s,l,u,c,f,h,d,p,m,v){return t[0]=e,t[1]=r,t[2]=n,t[3]=i,t[4]=o,t[5]=a,t[6]=s,t[7]=l,t[8]=u,t[9]=c,t[10]=f,t[11]=h,t[12]=d,t[13]=p,t[14]=m,t[15]=v,t},identity:A,transpose:function(t,e){if(t===e){var r=e[1],n=e[2],i=e[3],o=e[6],a=e[7],s=e[11];t[1]=e[4],t[2]=e[8],t[3]=e[12],t[4]=r,t[6]=e[9],t[7]=e[13],t[8]=n,t[9]=o,t[11]=e[14],t[12]=i,t[13]=a,t[14]=s}else t[0]=e[0],t[1]=e[4],t[2]=e[8],t[3]=e[12],t[4]=e[1],t[5]=e[5],t[6]=e[9],t[7]=e[13],t[8]=e[2],t[9]=e[6],t[10]=e[10],t[11]=e[14],t[12]=e[3],t[13]=e[7],t[14]=e[11],t[15]=e[15];return t},invert:function(t,e){var r=e[0],n=e[1],i=e[2],o=e[3],a=e[4],s=e[5],l=e[6],u=e[7],c=e[8],f=e[9],h=e[10],d=e[11],p=e[12],m=e[13],v=e[14],g=e[15],y=r*s-n*a,b=r*l-i*a,x=r*u-o*a,_=n*l-i*s,w=n*u-o*s,C=i*u-o*l,S=c*m-f*p,k=c*v-h*p,A=c*g-d*p,M=f*v-h*m,z=f*g-d*m,O=h*g-d*v,E=y*O-b*z+x*M+_*A-w*k+C*S;return E?(E=1/E,t[0]=(s*O-l*z+u*M)*E,t[1]=(i*z-n*O-o*M)*E,t[2]=(m*C-v*w+g*_)*E,t[3]=(h*w-f*C-d*_)*E,t[4]=(l*A-a*O-u*k)*E,t[5]=(r*O-i*A+o*k)*E,t[6]=(v*x-p*C-g*b)*E,t[7]=(c*C-h*x+d*b)*E,t[8]=(a*z-s*A+u*S)*E,t[9]=(n*A-r*z-o*S)*E,t[10]=(p*w-m*x+g*y)*E,t[11]=(f*x-c*w-d*y)*E,t[12]=(s*k-a*M-l*S)*E,t[13]=(r*M-n*k+i*S)*E,t[14]=(m*b-p*_-v*y)*E,t[15]=(c*_-f*b+h*y)*E,t):null},adjoint:function(t,e){var r=e[0],n=e[1],i=e[2],o=e[3],a=e[4],s=e[5],l=e[6],u=e[7],c=e[8],f=e[9],h=e[10],d=e[11],p=e[12],m=e[13],v=e[14],g=e[15];return t[0]=s*(h*g-d*v)-f*(l*g-u*v)+m*(l*d-u*h),t[1]=-(n*(h*g-d*v)-f*(i*g-o*v)+m*(i*d-o*h)),t[2]=n*(l*g-u*v)-s*(i*g-o*v)+m*(i*u-o*l),t[3]=-(n*(l*d-u*h)-s*(i*d-o*h)+f*(i*u-o*l)),t[4]=-(a*(h*g-d*v)-c*(l*g-u*v)+p*(l*d-u*h)),t[5]=r*(h*g-d*v)-c*(i*g-o*v)+p*(i*d-o*h),t[6]=-(r*(l*g-u*v)-a*(i*g-o*v)+p*(i*u-o*l)),t[7]=r*(l*d-u*h)-a*(i*d-o*h)+c*(i*u-o*l),t[8]=a*(f*g-d*m)-c*(s*g-u*m)+p*(s*d-u*f),t[9]=-(r*(f*g-d*m)-c*(n*g-o*m)+p*(n*d-o*f)),t[10]=r*(s*g-u*m)-a*(n*g-o*m)+p*(n*u-o*s),t[11]=-(r*(s*d-u*f)-a*(n*d-o*f)+c*(n*u-o*s)),t[12]=-(a*(f*v-h*m)-c*(s*v-l*m)+p*(s*h-l*f)),t[13]=r*(f*v-h*m)-c*(n*v-i*m)+p*(n*h-i*f),t[14]=-(r*(s*v-l*m)-a*(n*v-i*m)+p*(n*l-i*s)),t[15]=r*(s*h-l*f)-a*(n*h-i*f)+c*(n*l-i*s),t},determinant:function(t){var e=t[0],r=t[1],n=t[2],i=t[3],o=t[4],a=t[5],s=t[6],l=t[7],u=t[8],c=t[9],f=t[10],h=t[11],d=t[12],p=t[13],m=t[14],v=t[15];return(e*a-r*o)*(f*v-h*m)-(e*s-n*o)*(c*v-h*p)+(e*l-i*o)*(c*m-f*p)+(r*s-n*a)*(u*v-h*d)-(r*l-i*a)*(u*m-f*d)+(n*l-i*s)*(u*p-c*d)},multiply:M,translate:function(t,e,r){var n,i,o,a,s,l,u,c,f,h,d,p,m=r[0],v=r[1],g=r[2];return e===t?(t[12]=e[0]*m+e[4]*v+e[8]*g+e[12],t[13]=e[1]*m+e[5]*v+e[9]*g+e[13],t[14]=e[2]*m+e[6]*v+e[10]*g+e[14],t[15]=e[3]*m+e[7]*v+e[11]*g+e[15]):(n=e[0],i=e[1],o=e[2],a=e[3],s=e[4],l=e[5],u=e[6],c=e[7],f=e[8],h=e[9],d=e[10],p=e[11],t[0]=n,t[1]=i,t[2]=o,t[3]=a,t[4]=s,t[5]=l,t[6]=u,t[7]=c,t[8]=f,t[9]=h,t[10]=d,t[11]=p,t[12]=n*m+s*v+f*g+e[12],t[13]=i*m+l*v+h*g+e[13],t[14]=o*m+u*v+d*g+e[14],t[15]=a*m+c*v+p*g+e[15]),t},scale:function(t,e,r){var n=r[0],i=r[1],o=r[2];return t[0]=e[0]*n,t[1]=e[1]*n,t[2]=e[2]*n,t[3]=e[3]*n,t[4]=e[4]*i,t[5]=e[5]*i,t[6]=e[6]*i,t[7]=e[7]*i,t[8]=e[8]*o,t[9]=e[9]*o,t[10]=e[10]*o,t[11]=e[11]*o,t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15],t},rotate:function(t,e,r,n){var i,a,s,l,u,c,f,h,d,p,m,v,g,y,b,x,_,w,C,S,k,A,M,z,O=n[0],E=n[1],P=n[2],L=Math.hypot(O,E,P);return L<o?null:(O*=L=1/L,E*=L,P*=L,i=Math.sin(r),s=1-(a=Math.cos(r)),l=e[0],u=e[1],c=e[2],f=e[3],h=e[4],d=e[5],p=e[6],m=e[7],v=e[8],g=e[9],y=e[10],b=e[11],x=O*O*s+a,_=E*O*s+P*i,w=P*O*s-E*i,C=O*E*s-P*i,S=E*E*s+a,k=P*E*s+O*i,A=O*P*s+E*i,M=E*P*s-O*i,z=P*P*s+a,t[0]=l*x+h*_+v*w,t[1]=u*x+d*_+g*w,t[2]=c*x+p*_+y*w,t[3]=f*x+m*_+b*w,t[4]=l*C+h*S+v*k,t[5]=u*C+d*S+g*k,t[6]=c*C+p*S+y*k,t[7]=f*C+m*S+b*k,t[8]=l*A+h*M+v*z,t[9]=u*A+d*M+g*z,t[10]=c*A+p*M+y*z,t[11]=f*A+m*M+b*z,e!==t&&(t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15]),t)},rotateX:function(t,e,r){var n=Math.sin(r),i=Math.cos(r),o=e[4],a=e[5],s=e[6],l=e[7],u=e[8],c=e[9],f=e[10],h=e[11];return e!==t&&(t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[3],t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15]),t[4]=o*i+u*n,t[5]=a*i+c*n,t[6]=s*i+f*n,t[7]=l*i+h*n,t[8]=u*i-o*n,t[9]=c*i-a*n,t[10]=f*i-s*n,t[11]=h*i-l*n,t},rotateY:function(t,e,r){var n=Math.sin(r),i=Math.cos(r),o=e[0],a=e[1],s=e[2],l=e[3],u=e[8],c=e[9],f=e[10],h=e[11];return e!==t&&(t[4]=e[4],t[5]=e[5],t[6]=e[6],t[7]=e[7],t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15]),t[0]=o*i-u*n,t[1]=a*i-c*n,t[2]=s*i-f*n,t[3]=l*i-h*n,t[8]=o*n+u*i,t[9]=a*n+c*i,t[10]=s*n+f*i,t[11]=l*n+h*i,t},rotateZ:function(t,e,r){var n=Math.sin(r),i=Math.cos(r),o=e[0],a=e[1],s=e[2],l=e[3],u=e[4],c=e[5],f=e[6],h=e[7];return e!==t&&(t[8]=e[8],t[9]=e[9],t[10]=e[10],t[11]=e[11],t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15]),t[0]=o*i+u*n,t[1]=a*i+c*n,t[2]=s*i+f*n,t[3]=l*i+h*n,t[4]=u*i-o*n,t[5]=c*i-a*n,t[6]=f*i-s*n,t[7]=h*i-l*n,t},fromTranslation:function(t,e){return t[0]=1,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=1,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[10]=1,t[11]=0,t[12]=e[0],t[13]=e[1],t[14]=e[2],t[15]=1,t},fromScaling:function(t,e){return t[0]=e[0],t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=e[1],t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[10]=e[2],t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,t},fromRotation:function(t,e,r){var n,i,a,s=r[0],l=r[1],u=r[2],c=Math.hypot(s,l,u);return c<o?null:(s*=c=1/c,l*=c,u*=c,n=Math.sin(e),a=1-(i=Math.cos(e)),t[0]=s*s*a+i,t[1]=l*s*a+u*n,t[2]=u*s*a-l*n,t[3]=0,t[4]=s*l*a-u*n,t[5]=l*l*a+i,t[6]=u*l*a+s*n,t[7]=0,t[8]=s*u*a+l*n,t[9]=l*u*a-s*n,t[10]=u*u*a+i,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,t)},fromXRotation:function(t,e){var r=Math.sin(e),n=Math.cos(e);return t[0]=1,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=n,t[6]=r,t[7]=0,t[8]=0,t[9]=-r,t[10]=n,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,t},fromYRotation:function(t,e){var r=Math.sin(e),n=Math.cos(e);return t[0]=n,t[1]=0,t[2]=-r,t[3]=0,t[4]=0,t[5]=1,t[6]=0,t[7]=0,t[8]=r,t[9]=0,t[10]=n,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,t},fromZRotation:function(t,e){var r=Math.sin(e),n=Math.cos(e);return t[0]=n,t[1]=r,t[2]=0,t[3]=0,t[4]=-r,t[5]=n,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[10]=1,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,t},fromRotationTranslation:z,fromQuat2:function(t,e){var r=new a(3),n=-e[0],i=-e[1],o=-e[2],s=e[3],l=e[4],u=e[5],c=e[6],f=e[7],h=n*n+i*i+o*o+s*s;return h>0?(r[0]=2*(l*s+f*n+u*o-c*i)/h,r[1]=2*(u*s+f*i+c*n-l*o)/h,r[2]=2*(c*s+f*o+l*i-u*n)/h):(r[0]=2*(l*s+f*n+u*o-c*i),r[1]=2*(u*s+f*i+c*n-l*o),r[2]=2*(c*s+f*o+l*i-u*n)),z(t,e,r),t},getTranslation:O,getScaling:E,getRotation:P,fromRotationTranslationScale:function(t,e,r,n){var i=e[0],o=e[1],a=e[2],s=e[3],l=i+i,u=o+o,c=a+a,f=i*l,h=i*u,d=i*c,p=o*u,m=o*c,v=a*c,g=s*l,y=s*u,b=s*c,x=n[0],_=n[1],w=n[2];return t[0]=(1-(p+v))*x,t[1]=(h+b)*x,t[2]=(d-y)*x,t[3]=0,t[4]=(h-b)*_,t[5]=(1-(f+v))*_,t[6]=(m+g)*_,t[7]=0,t[8]=(d+y)*w,t[9]=(m-g)*w,t[10]=(1-(f+p))*w,t[11]=0,t[12]=r[0],t[13]=r[1],t[14]=r[2],t[15]=1,t},fromRotationTranslationScaleOrigin:function(t,e,r,n,i){var o=e[0],a=e[1],s=e[2],l=e[3],u=o+o,c=a+a,f=s+s,h=o*u,d=o*c,p=o*f,m=a*c,v=a*f,g=s*f,y=l*u,b=l*c,x=l*f,_=n[0],w=n[1],C=n[2],S=i[0],k=i[1],A=i[2],M=(1-(m+g))*_,z=(d+x)*_,O=(p-b)*_,E=(d-x)*w,P=(1-(h+g))*w,L=(v+y)*w,T=(p+b)*C,D=(v-y)*C,R=(1-(h+m))*C;return t[0]=M,t[1]=z,t[2]=O,t[3]=0,t[4]=E,t[5]=P,t[6]=L,t[7]=0,t[8]=T,t[9]=D,t[10]=R,t[11]=0,t[12]=r[0]+S-(M*S+E*k+T*A),t[13]=r[1]+k-(z*S+P*k+D*A),t[14]=r[2]+A-(O*S+L*k+R*A),t[15]=1,t},fromQuat:function(t,e){var r=e[0],n=e[1],i=e[2],o=e[3],a=r+r,s=n+n,l=i+i,u=r*a,c=n*a,f=n*s,h=i*a,d=i*s,p=i*l,m=o*a,v=o*s,g=o*l;return t[0]=1-f-p,t[1]=c+g,t[2]=h-v,t[3]=0,t[4]=c-g,t[5]=1-u-p,t[6]=d+m,t[7]=0,t[8]=h+v,t[9]=d-m,t[10]=1-u-f,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,t},frustum:function(t,e,r,n,i,o,a){var s=1/(r-e),l=1/(i-n),u=1/(o-a);return t[0]=2*o*s,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=2*o*l,t[6]=0,t[7]=0,t[8]=(r+e)*s,t[9]=(i+n)*l,t[10]=(a+o)*u,t[11]=-1,t[12]=0,t[13]=0,t[14]=a*o*2*u,t[15]=0,t},perspective:function(t,e,r,n,i){var o,a=1/Math.tan(e/2);return t[0]=a/r,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=a,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[11]=-1,t[12]=0,t[13]=0,t[15]=0,null!=i&&i!==1/0?(o=1/(n-i),t[10]=(i+n)*o,t[14]=2*i*n*o):(t[10]=-1,t[14]=-2*n),t},perspectiveFromFieldOfView:function(t,e,r,n){var i=Math.tan(e.upDegrees*Math.PI/180),o=Math.tan(e.downDegrees*Math.PI/180),a=Math.tan(e.leftDegrees*Math.PI/180),s=Math.tan(e.rightDegrees*Math.PI/180),l=2/(a+s),u=2/(i+o);return t[0]=l,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=u,t[6]=0,t[7]=0,t[8]=-(a-s)*l*.5,t[9]=(i-o)*u*.5,t[10]=n/(r-n),t[11]=-1,t[12]=0,t[13]=0,t[14]=n*r/(r-n),t[15]=0,t},ortho:function(t,e,r,n,i,o,a){var s=1/(e-r),l=1/(n-i),u=1/(o-a);return t[0]=-2*s,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=-2*l,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[10]=2*u,t[11]=0,t[12]=(e+r)*s,t[13]=(i+n)*l,t[14]=(a+o)*u,t[15]=1,t},lookAt:function(t,e,r,n){var i,a,s,l,u,c,f,h,d,p,m=e[0],v=e[1],g=e[2],y=n[0],b=n[1],x=n[2],_=r[0],w=r[1],C=r[2];return Math.abs(m-_)<o&&Math.abs(v-w)<o&&Math.abs(g-C)<o?A(t):(f=m-_,h=v-w,d=g-C,i=b*(d*=p=1/Math.hypot(f,h,d))-x*(h*=p),a=x*(f*=p)-y*d,s=y*h-b*f,(p=Math.hypot(i,a,s))?(i*=p=1/p,a*=p,s*=p):(i=0,a=0,s=0),l=h*s-d*a,u=d*i-f*s,c=f*a-h*i,(p=Math.hypot(l,u,c))?(l*=p=1/p,u*=p,c*=p):(l=0,u=0,c=0),t[0]=i,t[1]=l,t[2]=f,t[3]=0,t[4]=a,t[5]=u,t[6]=h,t[7]=0,t[8]=s,t[9]=c,t[10]=d,t[11]=0,t[12]=-(i*m+a*v+s*g),t[13]=-(l*m+u*v+c*g),t[14]=-(f*m+h*v+d*g),t[15]=1,t)},targetTo:function(t,e,r,n){var i=e[0],o=e[1],a=e[2],s=n[0],l=n[1],u=n[2],c=i-r[0],f=o-r[1],h=a-r[2],d=c*c+f*f+h*h;d>0&&(c*=d=1/Math.sqrt(d),f*=d,h*=d);var p=l*h-u*f,m=u*c-s*h,v=s*f-l*c;return(d=p*p+m*m+v*v)>0&&(p*=d=1/Math.sqrt(d),m*=d,v*=d),t[0]=p,t[1]=m,t[2]=v,t[3]=0,t[4]=f*v-h*m,t[5]=h*p-c*v,t[6]=c*m-f*p,t[7]=0,t[8]=c,t[9]=f,t[10]=h,t[11]=0,t[12]=i,t[13]=o,t[14]=a,t[15]=1,t},str:function(t){return"mat4("+t[0]+", "+t[1]+", "+t[2]+", "+t[3]+", "+t[4]+", "+t[5]+", "+t[6]+", "+t[7]+", "+t[8]+", "+t[9]+", "+t[10]+", "+t[11]+", "+t[12]+", "+t[13]+", "+t[14]+", "+t[15]+")"},frob:function(t){return Math.hypot(t[0],t[1],t[2],t[3],t[4],t[5],t[6],t[7],t[8],t[9],t[10],t[11],t[12],t[13],t[14],t[15])},add:function(t,e,r){return t[0]=e[0]+r[0],t[1]=e[1]+r[1],t[2]=e[2]+r[2],t[3]=e[3]+r[3],t[4]=e[4]+r[4],t[5]=e[5]+r[5],t[6]=e[6]+r[6],t[7]=e[7]+r[7],t[8]=e[8]+r[8],t[9]=e[9]+r[9],t[10]=e[10]+r[10],t[11]=e[11]+r[11],t[12]=e[12]+r[12],t[13]=e[13]+r[13],t[14]=e[14]+r[14],t[15]=e[15]+r[15],t},subtract:L,multiplyScalar:function(t,e,r){return t[0]=e[0]*r,t[1]=e[1]*r,t[2]=e[2]*r,t[3]=e[3]*r,t[4]=e[4]*r,t[5]=e[5]*r,t[6]=e[6]*r,t[7]=e[7]*r,t[8]=e[8]*r,t[9]=e[9]*r,t[10]=e[10]*r,t[11]=e[11]*r,t[12]=e[12]*r,t[13]=e[13]*r,t[14]=e[14]*r,t[15]=e[15]*r,t},multiplyScalarAndAdd:function(t,e,r,n){return t[0]=e[0]+r[0]*n,t[1]=e[1]+r[1]*n,t[2]=e[2]+r[2]*n,t[3]=e[3]+r[3]*n,t[4]=e[4]+r[4]*n,t[5]=e[5]+r[5]*n,t[6]=e[6]+r[6]*n,t[7]=e[7]+r[7]*n,t[8]=e[8]+r[8]*n,t[9]=e[9]+r[9]*n,t[10]=e[10]+r[10]*n,t[11]=e[11]+r[11]*n,t[12]=e[12]+r[12]*n,t[13]=e[13]+r[13]*n,t[14]=e[14]+r[14]*n,t[15]=e[15]+r[15]*n,t},exactEquals:function(t,e){return t[0]===e[0]&&t[1]===e[1]&&t[2]===e[2]&&t[3]===e[3]&&t[4]===e[4]&&t[5]===e[5]&&t[6]===e[6]&&t[7]===e[7]&&t[8]===e[8]&&t[9]===e[9]&&t[10]===e[10]&&t[11]===e[11]&&t[12]===e[12]&&t[13]===e[13]&&t[14]===e[14]&&t[15]===e[15]},equals:function(t,e){var r=t[0],n=t[1],i=t[2],a=t[3],s=t[4],l=t[5],u=t[6],c=t[7],f=t[8],h=t[9],d=t[10],p=t[11],m=t[12],v=t[13],g=t[14],y=t[15],b=e[0],x=e[1],_=e[2],w=e[3],C=e[4],S=e[5],k=e[6],A=e[7],M=e[8],z=e[9],O=e[10],E=e[11],P=e[12],L=e[13],T=e[14],D=e[15];return Math.abs(r-b)<=o*Math.max(1,Math.abs(r),Math.abs(b))&&Math.abs(n-x)<=o*Math.max(1,Math.abs(n),Math.abs(x))&&Math.abs(i-_)<=o*Math.max(1,Math.abs(i),Math.abs(_))&&Math.abs(a-w)<=o*Math.max(1,Math.abs(a),Math.abs(w))&&Math.abs(s-C)<=o*Math.max(1,Math.abs(s),Math.abs(C))&&Math.abs(l-S)<=o*Math.max(1,Math.abs(l),Math.abs(S))&&Math.abs(u-k)<=o*Math.max(1,Math.abs(u),Math.abs(k))&&Math.abs(c-A)<=o*Math.max(1,Math.abs(c),Math.abs(A))&&Math.abs(f-M)<=o*Math.max(1,Math.abs(f),Math.abs(M))&&Math.abs(h-z)<=o*Math.max(1,Math.abs(h),Math.abs(z))&&Math.abs(d-O)<=o*Math.max(1,Math.abs(d),Math.abs(O))&&Math.abs(p-E)<=o*Math.max(1,Math.abs(p),Math.abs(E))&&Math.abs(m-P)<=o*Math.max(1,Math.abs(m),Math.abs(P))&&Math.abs(v-L)<=o*Math.max(1,Math.abs(v),Math.abs(L))&&Math.abs(g-T)<=o*Math.max(1,Math.abs(g),Math.abs(T))&&Math.abs(y-D)<=o*Math.max(1,Math.abs(y),Math.abs(D))},mul:T,sub:D});function I(){var t=new a(3);return a!=Float32Array&&(t[0]=0,t[1]=0,t[2]=0),t}function F(t){var e=t[0],r=t[1],n=t[2];return Math.hypot(e,r,n)}function B(t,e,r){var n=new a(3);return n[0]=t,n[1]=e,n[2]=r,n}function j(t,e,r){return t[0]=e[0]-r[0],t[1]=e[1]-r[1],t[2]=e[2]-r[2],t}function V(t,e,r){return t[0]=e[0]*r[0],t[1]=e[1]*r[1],t[2]=e[2]*r[2],t}function N(t,e,r){return t[0]=e[0]/r[0],t[1]=e[1]/r[1],t[2]=e[2]/r[2],t}function U(t,e){var r=e[0]-t[0],n=e[1]-t[1],i=e[2]-t[2];return Math.hypot(r,n,i)}function G(t,e){var r=e[0]-t[0],n=e[1]-t[1],i=e[2]-t[2];return r*r+n*n+i*i}function W(t){var e=t[0],r=t[1],n=t[2];return e*e+r*r+n*n}function q(t,e){var r=e[0],n=e[1],i=e[2],o=r*r+n*n+i*i;return o>0&&(o=1/Math.sqrt(o)),t[0]=e[0]*o,t[1]=e[1]*o,t[2]=e[2]*o,t}function H(t,e){return t[0]*e[0]+t[1]*e[1]+t[2]*e[2]}function Z(t,e,r){var n=e[0],i=e[1],o=e[2],a=r[0],s=r[1],l=r[2];return t[0]=i*l-o*s,t[1]=o*a-n*l,t[2]=n*s-i*a,t}var Q,X=j,Y=V,J=N,K=U,$=G,tt=F,et=W,rt=(Q=I(),function(t,e,r,n,i,o){var a,s;for(e||(e=3),r||(r=0),s=n?Math.min(n*e+r,t.length):t.length,a=r;a<s;a+=e)Q[0]=t[a],Q[1]=t[a+1],Q[2]=t[a+2],i(Q,Q,o),t[a]=Q[0],t[a+1]=Q[1],t[a+2]=Q[2];return t}),nt=Object.freeze({__proto__:null,create:I,clone:function(t){var e=new a(3);return e[0]=t[0],e[1]=t[1],e[2]=t[2],e},length:F,fromValues:B,copy:function(t,e){return t[0]=e[0],t[1]=e[1],t[2]=e[2],t},set:function(t,e,r,n){return t[0]=e,t[1]=r,t[2]=n,t},add:function(t,e,r){return t[0]=e[0]+r[0],t[1]=e[1]+r[1],t[2]=e[2]+r[2],t},subtract:j,multiply:V,divide:N,ceil:function(t,e){return t[0]=Math.ceil(e[0]),t[1]=Math.ceil(e[1]),t[2]=Math.ceil(e[2]),t},floor:function(t,e){return t[0]=Math.floor(e[0]),t[1]=Math.floor(e[1]),t[2]=Math.floor(e[2]),t},min:function(t,e,r){return t[0]=Math.min(e[0],r[0]),t[1]=Math.min(e[1],r[1]),t[2]=Math.min(e[2],r[2]),t},max:function(t,e,r){return t[0]=Math.max(e[0],r[0]),t[1]=Math.max(e[1],r[1]),t[2]=Math.max(e[2],r[2]),t},round:function(t,e){return t[0]=Math.round(e[0]),t[1]=Math.round(e[1]),t[2]=Math.round(e[2]),t},scale:function(t,e,r){return t[0]=e[0]*r,t[1]=e[1]*r,t[2]=e[2]*r,t},scaleAndAdd:function(t,e,r,n){return t[0]=e[0]+r[0]*n,t[1]=e[1]+r[1]*n,t[2]=e[2]+r[2]*n,t},distance:U,squaredDistance:G,squaredLength:W,negate:function(t,e){return t[0]=-e[0],t[1]=-e[1],t[2]=-e[2],t},inverse:function(t,e){return t[0]=1/e[0],t[1]=1/e[1],t[2]=1/e[2],t},normalize:q,dot:H,cross:Z,lerp:function(t,e,r,n){var i=e[0],o=e[1],a=e[2];return t[0]=i+n*(r[0]-i),t[1]=o+n*(r[1]-o),t[2]=a+n*(r[2]-a),t},hermite:function(t,e,r,n,i,o){var a=o*o,s=a*(2*o-3)+1,l=a*(o-2)+o,u=a*(o-1),c=a*(3-2*o);return t[0]=e[0]*s+r[0]*l+n[0]*u+i[0]*c,t[1]=e[1]*s+r[1]*l+n[1]*u+i[1]*c,t[2]=e[2]*s+r[2]*l+n[2]*u+i[2]*c,t},bezier:function(t,e,r,n,i,o){var a=1-o,s=a*a,l=o*o,u=s*a,c=3*o*s,f=3*l*a,h=l*o;return t[0]=e[0]*u+r[0]*c+n[0]*f+i[0]*h,t[1]=e[1]*u+r[1]*c+n[1]*f+i[1]*h,t[2]=e[2]*u+r[2]*c+n[2]*f+i[2]*h,t},random:function(t,e){e=e||1;var r=2*s()*Math.PI,n=2*s()-1,i=Math.sqrt(1-n*n)*e;return t[0]=Math.cos(r)*i,t[1]=Math.sin(r)*i,t[2]=n*e,t},transformMat4:function(t,e,r){var n=e[0],i=e[1],o=e[2],a=r[3]*n+r[7]*i+r[11]*o+r[15];return a=a||1,t[0]=(r[0]*n+r[4]*i+r[8]*o+r[12])/a,t[1]=(r[1]*n+r[5]*i+r[9]*o+r[13])/a,t[2]=(r[2]*n+r[6]*i+r[10]*o+r[14])/a,t},transformMat3:function(t,e,r){var n=e[0],i=e[1],o=e[2];return t[0]=n*r[0]+i*r[3]+o*r[6],t[1]=n*r[1]+i*r[4]+o*r[7],t[2]=n*r[2]+i*r[5]+o*r[8],t},transformQuat:function(t,e,r){var n=r[0],i=r[1],o=r[2],a=r[3],s=e[0],l=e[1],u=e[2],c=i*u-o*l,f=o*s-n*u,h=n*l-i*s,d=i*h-o*f,p=o*c-n*h,m=n*f-i*c,v=2*a;return c*=v,f*=v,h*=v,d*=2,p*=2,m*=2,t[0]=s+c+d,t[1]=l+f+p,t[2]=u+h+m,t},rotateX:function(t,e,r,n){var i=[],o=[];return i[0]=e[0]-r[0],i[1]=e[1]-r[1],i[2]=e[2]-r[2],o[0]=i[0],o[1]=i[1]*Math.cos(n)-i[2]*Math.sin(n),o[2]=i[1]*Math.sin(n)+i[2]*Math.cos(n),t[0]=o[0]+r[0],t[1]=o[1]+r[1],t[2]=o[2]+r[2],t},rotateY:function(t,e,r,n){var i=[],o=[];return i[0]=e[0]-r[0],i[1]=e[1]-r[1],i[2]=e[2]-r[2],o[0]=i[2]*Math.sin(n)+i[0]*Math.cos(n),o[1]=i[1],o[2]=i[2]*Math.cos(n)-i[0]*Math.sin(n),t[0]=o[0]+r[0],t[1]=o[1]+r[1],t[2]=o[2]+r[2],t},rotateZ:function(t,e,r,n){var i=[],o=[];return i[0]=e[0]-r[0],i[1]=e[1]-r[1],i[2]=e[2]-r[2],o[0]=i[0]*Math.cos(n)-i[1]*Math.sin(n),o[1]=i[0]*Math.sin(n)+i[1]*Math.cos(n),o[2]=i[2],t[0]=o[0]+r[0],t[1]=o[1]+r[1],t[2]=o[2]+r[2],t},angle:function(t,e){var r=t[0],n=t[1],i=t[2],o=e[0],a=e[1],s=e[2],l=Math.sqrt(r*r+n*n+i*i)*Math.sqrt(o*o+a*a+s*s),u=l&&H(t,e)/l;return Math.acos(Math.min(Math.max(u,-1),1))},zero:function(t){return t[0]=0,t[1]=0,t[2]=0,t},str:function(t){return"vec3("+t[0]+", "+t[1]+", "+t[2]+")"},exactEquals:function(t,e){return t[0]===e[0]&&t[1]===e[1]&&t[2]===e[2]},equals:function(t,e){var r=t[0],n=t[1],i=t[2],a=e[0],s=e[1],l=e[2];return Math.abs(r-a)<=o*Math.max(1,Math.abs(r),Math.abs(a))&&Math.abs(n-s)<=o*Math.max(1,Math.abs(n),Math.abs(s))&&Math.abs(i-l)<=o*Math.max(1,Math.abs(i),Math.abs(l))},sub:X,mul:Y,div:J,dist:K,sqrDist:$,len:tt,sqrLen:et,forEach:rt});function it(){var t=new a(4);return a!=Float32Array&&(t[0]=0,t[1]=0,t[2]=0,t[3]=0),t}function ot(t){var e=new a(4);return e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3],e}function at(t,e,r,n){var i=new a(4);return i[0]=t,i[1]=e,i[2]=r,i[3]=n,i}function st(t,e){return t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[3],t}function lt(t,e,r,n,i){return t[0]=e,t[1]=r,t[2]=n,t[3]=i,t}function ut(t,e,r){return t[0]=e[0]+r[0],t[1]=e[1]+r[1],t[2]=e[2]+r[2],t[3]=e[3]+r[3],t}function ct(t,e,r){return t[0]=e[0]-r[0],t[1]=e[1]-r[1],t[2]=e[2]-r[2],t[3]=e[3]-r[3],t}function ft(t,e,r){return t[0]=e[0]*r[0],t[1]=e[1]*r[1],t[2]=e[2]*r[2],t[3]=e[3]*r[3],t}function ht(t,e,r){return t[0]=e[0]/r[0],t[1]=e[1]/r[1],t[2]=e[2]/r[2],t[3]=e[3]/r[3],t}function dt(t,e,r){return t[0]=e[0]*r,t[1]=e[1]*r,t[2]=e[2]*r,t[3]=e[3]*r,t}function pt(t,e){var r=e[0]-t[0],n=e[1]-t[1],i=e[2]-t[2],o=e[3]-t[3];return Math.hypot(r,n,i,o)}function mt(t,e){var r=e[0]-t[0],n=e[1]-t[1],i=e[2]-t[2],o=e[3]-t[3];return r*r+n*n+i*i+o*o}function vt(t){var e=t[0],r=t[1],n=t[2],i=t[3];return Math.hypot(e,r,n,i)}function gt(t){var e=t[0],r=t[1],n=t[2],i=t[3];return e*e+r*r+n*n+i*i}function yt(t,e){var r=e[0],n=e[1],i=e[2],o=e[3],a=r*r+n*n+i*i+o*o;return a>0&&(a=1/Math.sqrt(a)),t[0]=r*a,t[1]=n*a,t[2]=i*a,t[3]=o*a,t}function bt(t,e){return t[0]*e[0]+t[1]*e[1]+t[2]*e[2]+t[3]*e[3]}function xt(t,e,r,n){var i=e[0],o=e[1],a=e[2],s=e[3];return t[0]=i+n*(r[0]-i),t[1]=o+n*(r[1]-o),t[2]=a+n*(r[2]-a),t[3]=s+n*(r[3]-s),t}function _t(t,e){return t[0]===e[0]&&t[1]===e[1]&&t[2]===e[2]&&t[3]===e[3]}function wt(t,e){var r=t[0],n=t[1],i=t[2],a=t[3],s=e[0],l=e[1],u=e[2],c=e[3];return Math.abs(r-s)<=o*Math.max(1,Math.abs(r),Math.abs(s))&&Math.abs(n-l)<=o*Math.max(1,Math.abs(n),Math.abs(l))&&Math.abs(i-u)<=o*Math.max(1,Math.abs(i),Math.abs(u))&&Math.abs(a-c)<=o*Math.max(1,Math.abs(a),Math.abs(c))}var Ct=ct,St=ft,kt=ht,At=pt,Mt=mt,zt=vt,Ot=gt,Et=function(){var t=it();return function(e,r,n,i,o,a){var s,l;for(r||(r=4),n||(n=0),l=i?Math.min(i*r+n,e.length):e.length,s=n;s<l;s+=r)t[0]=e[s],t[1]=e[s+1],t[2]=e[s+2],t[3]=e[s+3],o(t,t,a),e[s]=t[0],e[s+1]=t[1],e[s+2]=t[2],e[s+3]=t[3];return e}}(),Pt=Object.freeze({__proto__:null,create:it,clone:ot,fromValues:at,copy:st,set:lt,add:ut,subtract:ct,multiply:ft,divide:ht,ceil:function(t,e){return t[0]=Math.ceil(e[0]),t[1]=Math.ceil(e[1]),t[2]=Math.ceil(e[2]),t[3]=Math.ceil(e[3]),t},floor:function(t,e){return t[0]=Math.floor(e[0]),t[1]=Math.floor(e[1]),t[2]=Math.floor(e[2]),t[3]=Math.floor(e[3]),t},min:function(t,e,r){return t[0]=Math.min(e[0],r[0]),t[1]=Math.min(e[1],r[1]),t[2]=Math.min(e[2],r[2]),t[3]=Math.min(e[3],r[3]),t},max:function(t,e,r){return t[0]=Math.max(e[0],r[0]),t[1]=Math.max(e[1],r[1]),t[2]=Math.max(e[2],r[2]),t[3]=Math.max(e[3],r[3]),t},round:function(t,e){return t[0]=Math.round(e[0]),t[1]=Math.round(e[1]),t[2]=Math.round(e[2]),t[3]=Math.round(e[3]),t},scale:dt,scaleAndAdd:function(t,e,r,n){return t[0]=e[0]+r[0]*n,t[1]=e[1]+r[1]*n,t[2]=e[2]+r[2]*n,t[3]=e[3]+r[3]*n,t},distance:pt,squaredDistance:mt,length:vt,squaredLength:gt,negate:function(t,e){return t[0]=-e[0],t[1]=-e[1],t[2]=-e[2],t[3]=-e[3],t},inverse:function(t,e){return t[0]=1/e[0],t[1]=1/e[1],t[2]=1/e[2],t[3]=1/e[3],t},normalize:yt,dot:bt,cross:function(t,e,r,n){var i=r[0]*n[1]-r[1]*n[0],o=r[0]*n[2]-r[2]*n[0],a=r[0]*n[3]-r[3]*n[0],s=r[1]*n[2]-r[2]*n[1],l=r[1]*n[3]-r[3]*n[1],u=r[2]*n[3]-r[3]*n[2],c=e[0],f=e[1],h=e[2],d=e[3];return t[0]=f*u-h*l+d*s,t[1]=-c*u+h*a-d*o,t[2]=c*l-f*a+d*i,t[3]=-c*s+f*o-h*i,t},lerp:xt,random:function(t,e){var r,n,i,o,a,l;e=e||1;do{a=(r=2*s()-1)*r+(n=2*s()-1)*n}while(a>=1);do{l=(i=2*s()-1)*i+(o=2*s()-1)*o}while(l>=1);var u=Math.sqrt((1-a)/l);return t[0]=e*r,t[1]=e*n,t[2]=e*i*u,t[3]=e*o*u,t},transformMat4:function(t,e,r){var n=e[0],i=e[1],o=e[2],a=e[3];return t[0]=r[0]*n+r[4]*i+r[8]*o+r[12]*a,t[1]=r[1]*n+r[5]*i+r[9]*o+r[13]*a,t[2]=r[2]*n+r[6]*i+r[10]*o+r[14]*a,t[3]=r[3]*n+r[7]*i+r[11]*o+r[15]*a,t},transformQuat:function(t,e,r){var n=e[0],i=e[1],o=e[2],a=r[0],s=r[1],l=r[2],u=r[3],c=u*n+s*o-l*i,f=u*i+l*n-a*o,h=u*o+a*i-s*n,d=-a*n-s*i-l*o;return t[0]=c*u+d*-a+f*-l-h*-s,t[1]=f*u+d*-s+h*-a-c*-l,t[2]=h*u+d*-l+c*-s-f*-a,t[3]=e[3],t},zero:function(t){return t[0]=0,t[1]=0,t[2]=0,t[3]=0,t},str:function(t){return"vec4("+t[0]+", "+t[1]+", "+t[2]+", "+t[3]+")"},exactEquals:_t,equals:wt,sub:Ct,mul:St,div:kt,dist:At,sqrDist:Mt,len:zt,sqrLen:Ot,forEach:Et});function Lt(){var t=new a(4);return a!=Float32Array&&(t[0]=0,t[1]=0,t[2]=0),t[3]=1,t}function Tt(t,e,r){r*=.5;var n=Math.sin(r);return t[0]=n*e[0],t[1]=n*e[1],t[2]=n*e[2],t[3]=Math.cos(r),t}function Dt(t,e,r){var n=e[0],i=e[1],o=e[2],a=e[3],s=r[0],l=r[1],u=r[2],c=r[3];return t[0]=n*c+a*s+i*u-o*l,t[1]=i*c+a*l+o*s-n*u,t[2]=o*c+a*u+n*l-i*s,t[3]=a*c-n*s-i*l-o*u,t}function Rt(t,e,r){r*=.5;var n=e[0],i=e[1],o=e[2],a=e[3],s=Math.sin(r),l=Math.cos(r);return t[0]=n*l+a*s,t[1]=i*l+o*s,t[2]=o*l-i*s,t[3]=a*l-n*s,t}function It(t,e,r){r*=.5;var n=e[0],i=e[1],o=e[2],a=e[3],s=Math.sin(r),l=Math.cos(r);return t[0]=n*l-o*s,t[1]=i*l+a*s,t[2]=o*l+n*s,t[3]=a*l-i*s,t}function Ft(t,e,r){r*=.5;var n=e[0],i=e[1],o=e[2],a=e[3],s=Math.sin(r),l=Math.cos(r);return t[0]=n*l+i*s,t[1]=i*l-n*s,t[2]=o*l+a*s,t[3]=a*l-o*s,t}function Bt(t,e){var r=e[0],n=e[1],i=e[2],o=e[3],a=Math.sqrt(r*r+n*n+i*i),s=Math.exp(o),l=a>0?s*Math.sin(a)/a:0;return t[0]=r*l,t[1]=n*l,t[2]=i*l,t[3]=s*Math.cos(a),t}function jt(t,e){var r=e[0],n=e[1],i=e[2],o=e[3],a=Math.sqrt(r*r+n*n+i*i),s=a>0?Math.atan2(a,o)/a:0;return t[0]=r*s,t[1]=n*s,t[2]=i*s,t[3]=.5*Math.log(r*r+n*n+i*i+o*o),t}function Vt(t,e,r,n){var i,a,s,l,u,c=e[0],f=e[1],h=e[2],d=e[3],p=r[0],m=r[1],v=r[2],g=r[3];return(a=c*p+f*m+h*v+d*g)<0&&(a=-a,p=-p,m=-m,v=-v,g=-g),1-a>o?(i=Math.acos(a),s=Math.sin(i),l=Math.sin((1-n)*i)/s,u=Math.sin(n*i)/s):(l=1-n,u=n),t[0]=l*c+u*p,t[1]=l*f+u*m,t[2]=l*h+u*v,t[3]=l*d+u*g,t}function Nt(t,e){var r,n=e[0]+e[4]+e[8];if(n>0)r=Math.sqrt(n+1),t[3]=.5*r,r=.5/r,t[0]=(e[5]-e[7])*r,t[1]=(e[6]-e[2])*r,t[2]=(e[1]-e[3])*r;else{var i=0;e[4]>e[0]&&(i=1),e[8]>e[3*i+i]&&(i=2);var o=(i+1)%3,a=(i+2)%3;r=Math.sqrt(e[3*i+i]-e[3*o+o]-e[3*a+a]+1),t[i]=.5*r,r=.5/r,t[3]=(e[3*o+a]-e[3*a+o])*r,t[o]=(e[3*o+i]+e[3*i+o])*r,t[a]=(e[3*a+i]+e[3*i+a])*r}return t}var Ut,Gt,Wt,qt,Ht,Zt,Qt=ot,Xt=at,Yt=st,Jt=lt,Kt=ut,$t=Dt,te=dt,ee=bt,re=xt,ne=vt,ie=ne,oe=gt,ae=oe,se=yt,le=_t,ue=wt,ce=(Ut=I(),Gt=B(1,0,0),Wt=B(0,1,0),function(t,e,r){var n=H(e,r);return n<-.999999?(Z(Ut,Gt,e),tt(Ut)<1e-6&&Z(Ut,Wt,e),q(Ut,Ut),Tt(t,Ut,Math.PI),t):n>.999999?(t[0]=0,t[1]=0,t[2]=0,t[3]=1,t):(Z(Ut,e,r),t[0]=Ut[0],t[1]=Ut[1],t[2]=Ut[2],t[3]=1+n,se(t,t))}),fe=(qt=Lt(),Ht=Lt(),function(t,e,r,n,i,o){return Vt(qt,e,i,o),Vt(Ht,r,n,o),Vt(t,qt,Ht,2*o*(1-o)),t}),he=(Zt=x(),function(t,e,r,n){return Zt[0]=r[0],Zt[3]=r[1],Zt[6]=r[2],Zt[1]=n[0],Zt[4]=n[1],Zt[7]=n[2],Zt[2]=-e[0],Zt[5]=-e[1],Zt[8]=-e[2],se(t,Nt(t,Zt))}),de=Object.freeze({__proto__:null,create:Lt,identity:function(t){return t[0]=0,t[1]=0,t[2]=0,t[3]=1,t},setAxisAngle:Tt,getAxisAngle:function(t,e){var r=2*Math.acos(e[3]),n=Math.sin(r/2);return n>o?(t[0]=e[0]/n,t[1]=e[1]/n,t[2]=e[2]/n):(t[0]=1,t[1]=0,t[2]=0),r},getAngle:function(t,e){var r=ee(t,e);return Math.acos(2*r*r-1)},multiply:Dt,rotateX:Rt,rotateY:It,rotateZ:Ft,calculateW:function(t,e){var r=e[0],n=e[1],i=e[2];return t[0]=r,t[1]=n,t[2]=i,t[3]=Math.sqrt(Math.abs(1-r*r-n*n-i*i)),t},exp:Bt,ln:jt,pow:function(t,e,r){return jt(t,e),te(t,t,r),Bt(t,t),t},slerp:Vt,random:function(t){var e=s(),r=s(),n=s(),i=Math.sqrt(1-e),o=Math.sqrt(e);return t[0]=i*Math.sin(2*Math.PI*r),t[1]=i*Math.cos(2*Math.PI*r),t[2]=o*Math.sin(2*Math.PI*n),t[3]=o*Math.cos(2*Math.PI*n),t},invert:function(t,e){var r=e[0],n=e[1],i=e[2],o=e[3],a=r*r+n*n+i*i+o*o,s=a?1/a:0;return t[0]=-r*s,t[1]=-n*s,t[2]=-i*s,t[3]=o*s,t},conjugate:function(t,e){return t[0]=-e[0],t[1]=-e[1],t[2]=-e[2],t[3]=e[3],t},fromMat3:Nt,fromEuler:function(t,e,r,n){var i=.5*Math.PI/180;e*=i,r*=i,n*=i;var o=Math.sin(e),a=Math.cos(e),s=Math.sin(r),l=Math.cos(r),u=Math.sin(n),c=Math.cos(n);return t[0]=o*l*c-a*s*u,t[1]=a*s*c+o*l*u,t[2]=a*l*u-o*s*c,t[3]=a*l*c+o*s*u,t},str:function(t){return"quat("+t[0]+", "+t[1]+", "+t[2]+", "+t[3]+")"},clone:Qt,fromValues:Xt,copy:Yt,set:Jt,add:Kt,mul:$t,scale:te,dot:ee,lerp:re,length:ne,len:ie,squaredLength:oe,sqrLen:ae,normalize:se,exactEquals:le,equals:ue,rotationTo:ce,sqlerp:fe,setAxes:he});function pe(t,e,r){var n=.5*r[0],i=.5*r[1],o=.5*r[2],a=e[0],s=e[1],l=e[2],u=e[3];return t[0]=a,t[1]=s,t[2]=l,t[3]=u,t[4]=n*u+i*l-o*s,t[5]=i*u+o*a-n*l,t[6]=o*u+n*s-i*a,t[7]=-n*a-i*s-o*l,t}function me(t,e){return t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[3],t[4]=e[4],t[5]=e[5],t[6]=e[6],t[7]=e[7],t}var ve=Yt;var ge=Yt;function ye(t,e,r){var n=e[0],i=e[1],o=e[2],a=e[3],s=r[4],l=r[5],u=r[6],c=r[7],f=e[4],h=e[5],d=e[6],p=e[7],m=r[0],v=r[1],g=r[2],y=r[3];return t[0]=n*y+a*m+i*g-o*v,t[1]=i*y+a*v+o*m-n*g,t[2]=o*y+a*g+n*v-i*m,t[3]=a*y-n*m-i*v-o*g,t[4]=n*c+a*s+i*u-o*l+f*y+p*m+h*g-d*v,t[5]=i*c+a*l+o*s-n*u+h*y+p*v+d*m-f*g,t[6]=o*c+a*u+n*l-i*s+d*y+p*g+f*v-h*m,t[7]=a*c-n*s-i*l-o*u+p*y-f*m-h*v-d*g,t}var be=ye;var xe=ee;var _e=ne,we=_e,Ce=oe,Se=Ce;var ke=Object.freeze({__proto__:null,create:function(){var t=new a(8);return a!=Float32Array&&(t[0]=0,t[1]=0,t[2]=0,t[4]=0,t[5]=0,t[6]=0,t[7]=0),t[3]=1,t},clone:function(t){var e=new a(8);return e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3],e[4]=t[4],e[5]=t[5],e[6]=t[6],e[7]=t[7],e},fromValues:function(t,e,r,n,i,o,s,l){var u=new a(8);return u[0]=t,u[1]=e,u[2]=r,u[3]=n,u[4]=i,u[5]=o,u[6]=s,u[7]=l,u},fromRotationTranslationValues:function(t,e,r,n,i,o,s){var l=new a(8);l[0]=t,l[1]=e,l[2]=r,l[3]=n;var u=.5*i,c=.5*o,f=.5*s;return l[4]=u*n+c*r-f*e,l[5]=c*n+f*t-u*r,l[6]=f*n+u*e-c*t,l[7]=-u*t-c*e-f*r,l},fromRotationTranslation:pe,fromTranslation:function(t,e){return t[0]=0,t[1]=0,t[2]=0,t[3]=1,t[4]=.5*e[0],t[5]=.5*e[1],t[6]=.5*e[2],t[7]=0,t},fromRotation:function(t,e){return t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[3],t[4]=0,t[5]=0,t[6]=0,t[7]=0,t},fromMat4:function(t,e){var r=Lt();P(r,e);var n=new a(3);return O(n,e),pe(t,r,n),t},copy:me,identity:function(t){return t[0]=0,t[1]=0,t[2]=0,t[3]=1,t[4]=0,t[5]=0,t[6]=0,t[7]=0,t},set:function(t,e,r,n,i,o,a,s,l){return t[0]=e,t[1]=r,t[2]=n,t[3]=i,t[4]=o,t[5]=a,t[6]=s,t[7]=l,t},getReal:ve,getDual:function(t,e){return t[0]=e[4],t[1]=e[5],t[2]=e[6],t[3]=e[7],t},setReal:ge,setDual:function(t,e){return t[4]=e[0],t[5]=e[1],t[6]=e[2],t[7]=e[3],t},getTranslation:function(t,e){var r=e[4],n=e[5],i=e[6],o=e[7],a=-e[0],s=-e[1],l=-e[2],u=e[3];return t[0]=2*(r*u+o*a+n*l-i*s),t[1]=2*(n*u+o*s+i*a-r*l),t[2]=2*(i*u+o*l+r*s-n*a),t},translate:function(t,e,r){var n=e[0],i=e[1],o=e[2],a=e[3],s=.5*r[0],l=.5*r[1],u=.5*r[2],c=e[4],f=e[5],h=e[6],d=e[7];return t[0]=n,t[1]=i,t[2]=o,t[3]=a,t[4]=a*s+i*u-o*l+c,t[5]=a*l+o*s-n*u+f,t[6]=a*u+n*l-i*s+h,t[7]=-n*s-i*l-o*u+d,t},rotateX:function(t,e,r){var n=-e[0],i=-e[1],o=-e[2],a=e[3],s=e[4],l=e[5],u=e[6],c=e[7],f=s*a+c*n+l*o-u*i,h=l*a+c*i+u*n-s*o,d=u*a+c*o+s*i-l*n,p=c*a-s*n-l*i-u*o;return Rt(t,e,r),n=t[0],i=t[1],o=t[2],a=t[3],t[4]=f*a+p*n+h*o-d*i,t[5]=h*a+p*i+d*n-f*o,t[6]=d*a+p*o+f*i-h*n,t[7]=p*a-f*n-h*i-d*o,t},rotateY:function(t,e,r){var n=-e[0],i=-e[1],o=-e[2],a=e[3],s=e[4],l=e[5],u=e[6],c=e[7],f=s*a+c*n+l*o-u*i,h=l*a+c*i+u*n-s*o,d=u*a+c*o+s*i-l*n,p=c*a-s*n-l*i-u*o;return It(t,e,r),n=t[0],i=t[1],o=t[2],a=t[3],t[4]=f*a+p*n+h*o-d*i,t[5]=h*a+p*i+d*n-f*o,t[6]=d*a+p*o+f*i-h*n,t[7]=p*a-f*n-h*i-d*o,t},rotateZ:function(t,e,r){var n=-e[0],i=-e[1],o=-e[2],a=e[3],s=e[4],l=e[5],u=e[6],c=e[7],f=s*a+c*n+l*o-u*i,h=l*a+c*i+u*n-s*o,d=u*a+c*o+s*i-l*n,p=c*a-s*n-l*i-u*o;return Ft(t,e,r),n=t[0],i=t[1],o=t[2],a=t[3],t[4]=f*a+p*n+h*o-d*i,t[5]=h*a+p*i+d*n-f*o,t[6]=d*a+p*o+f*i-h*n,t[7]=p*a-f*n-h*i-d*o,t},rotateByQuatAppend:function(t,e,r){var n=r[0],i=r[1],o=r[2],a=r[3],s=e[0],l=e[1],u=e[2],c=e[3];return t[0]=s*a+c*n+l*o-u*i,t[1]=l*a+c*i+u*n-s*o,t[2]=u*a+c*o+s*i-l*n,t[3]=c*a-s*n-l*i-u*o,s=e[4],l=e[5],u=e[6],c=e[7],t[4]=s*a+c*n+l*o-u*i,t[5]=l*a+c*i+u*n-s*o,t[6]=u*a+c*o+s*i-l*n,t[7]=c*a-s*n-l*i-u*o,t},rotateByQuatPrepend:function(t,e,r){var n=e[0],i=e[1],o=e[2],a=e[3],s=r[0],l=r[1],u=r[2],c=r[3];return t[0]=n*c+a*s+i*u-o*l,t[1]=i*c+a*l+o*s-n*u,t[2]=o*c+a*u+n*l-i*s,t[3]=a*c-n*s-i*l-o*u,s=r[4],l=r[5],u=r[6],c=r[7],t[4]=n*c+a*s+i*u-o*l,t[5]=i*c+a*l+o*s-n*u,t[6]=o*c+a*u+n*l-i*s,t[7]=a*c-n*s-i*l-o*u,t},rotateAroundAxis:function(t,e,r,n){if(Math.abs(n)<o)return me(t,e);var i=Math.hypot(r[0],r[1],r[2]);n*=.5;var a=Math.sin(n),s=a*r[0]/i,l=a*r[1]/i,u=a*r[2]/i,c=Math.cos(n),f=e[0],h=e[1],d=e[2],p=e[3];t[0]=f*c+p*s+h*u-d*l,t[1]=h*c+p*l+d*s-f*u,t[2]=d*c+p*u+f*l-h*s,t[3]=p*c-f*s-h*l-d*u;var m=e[4],v=e[5],g=e[6],y=e[7];return t[4]=m*c+y*s+v*u-g*l,t[5]=v*c+y*l+g*s-m*u,t[6]=g*c+y*u+m*l-v*s,t[7]=y*c-m*s-v*l-g*u,t},add:function(t,e,r){return t[0]=e[0]+r[0],t[1]=e[1]+r[1],t[2]=e[2]+r[2],t[3]=e[3]+r[3],t[4]=e[4]+r[4],t[5]=e[5]+r[5],t[6]=e[6]+r[6],t[7]=e[7]+r[7],t},multiply:ye,mul:be,scale:function(t,e,r){return t[0]=e[0]*r,t[1]=e[1]*r,t[2]=e[2]*r,t[3]=e[3]*r,t[4]=e[4]*r,t[5]=e[5]*r,t[6]=e[6]*r,t[7]=e[7]*r,t},dot:xe,lerp:function(t,e,r,n){var i=1-n;return xe(e,r)<0&&(n=-n),t[0]=e[0]*i+r[0]*n,t[1]=e[1]*i+r[1]*n,t[2]=e[2]*i+r[2]*n,t[3]=e[3]*i+r[3]*n,t[4]=e[4]*i+r[4]*n,t[5]=e[5]*i+r[5]*n,t[6]=e[6]*i+r[6]*n,t[7]=e[7]*i+r[7]*n,t},invert:function(t,e){var r=Ce(e);return t[0]=-e[0]/r,t[1]=-e[1]/r,t[2]=-e[2]/r,t[3]=e[3]/r,t[4]=-e[4]/r,t[5]=-e[5]/r,t[6]=-e[6]/r,t[7]=e[7]/r,t},conjugate:function(t,e){return t[0]=-e[0],t[1]=-e[1],t[2]=-e[2],t[3]=e[3],t[4]=-e[4],t[5]=-e[5],t[6]=-e[6],t[7]=e[7],t},length:_e,len:we,squaredLength:Ce,sqrLen:Se,normalize:function(t,e){var r=Ce(e);if(r>0){r=Math.sqrt(r);var n=e[0]/r,i=e[1]/r,o=e[2]/r,a=e[3]/r,s=e[4],l=e[5],u=e[6],c=e[7],f=n*s+i*l+o*u+a*c;t[0]=n,t[1]=i,t[2]=o,t[3]=a,t[4]=(s-n*f)/r,t[5]=(l-i*f)/r,t[6]=(u-o*f)/r,t[7]=(c-a*f)/r}return t},str:function(t){return"quat2("+t[0]+", "+t[1]+", "+t[2]+", "+t[3]+", "+t[4]+", "+t[5]+", "+t[6]+", "+t[7]+")"},exactEquals:function(t,e){return t[0]===e[0]&&t[1]===e[1]&&t[2]===e[2]&&t[3]===e[3]&&t[4]===e[4]&&t[5]===e[5]&&t[6]===e[6]&&t[7]===e[7]},equals:function(t,e){var r=t[0],n=t[1],i=t[2],a=t[3],s=t[4],l=t[5],u=t[6],c=t[7],f=e[0],h=e[1],d=e[2],p=e[3],m=e[4],v=e[5],g=e[6],y=e[7];return Math.abs(r-f)<=o*Math.max(1,Math.abs(r),Math.abs(f))&&Math.abs(n-h)<=o*Math.max(1,Math.abs(n),Math.abs(h))&&Math.abs(i-d)<=o*Math.max(1,Math.abs(i),Math.abs(d))&&Math.abs(a-p)<=o*Math.max(1,Math.abs(a),Math.abs(p))&&Math.abs(s-m)<=o*Math.max(1,Math.abs(s),Math.abs(m))&&Math.abs(l-v)<=o*Math.max(1,Math.abs(l),Math.abs(v))&&Math.abs(u-g)<=o*Math.max(1,Math.abs(u),Math.abs(g))&&Math.abs(c-y)<=o*Math.max(1,Math.abs(c),Math.abs(y))}});function Ae(){var t=new a(2);return a!=Float32Array&&(t[0]=0,t[1]=0),t}function Me(t,e,r){return t[0]=e[0]-r[0],t[1]=e[1]-r[1],t}function ze(t,e,r){return t[0]=e[0]*r[0],t[1]=e[1]*r[1],t}function Oe(t,e,r){return t[0]=e[0]/r[0],t[1]=e[1]/r[1],t}function Ee(t,e){var r=e[0]-t[0],n=e[1]-t[1];return Math.hypot(r,n)}function Pe(t,e){var r=e[0]-t[0],n=e[1]-t[1];return r*r+n*n}function Le(t){var e=t[0],r=t[1];return Math.hypot(e,r)}function Te(t){var e=t[0],r=t[1];return e*e+r*r}var De=Le,Re=Me,Ie=ze,Fe=Oe,Be=Ee,je=Pe,Ve=Te,Ne=function(){var t=Ae();return function(e,r,n,i,o,a){var s,l;for(r||(r=2),n||(n=0),l=i?Math.min(i*r+n,e.length):e.length,s=n;s<l;s+=r)t[0]=e[s],t[1]=e[s+1],o(t,t,a),e[s]=t[0],e[s+1]=t[1];return e}}(),Ue=Object.freeze({__proto__:null,create:Ae,clone:function(t){var e=new a(2);return e[0]=t[0],e[1]=t[1],e},fromValues:function(t,e){var r=new a(2);return r[0]=t,r[1]=e,r},copy:function(t,e){return t[0]=e[0],t[1]=e[1],t},set:function(t,e,r){return t[0]=e,t[1]=r,t},add:function(t,e,r){return t[0]=e[0]+r[0],t[1]=e[1]+r[1],t},subtract:Me,multiply:ze,divide:Oe,ceil:function(t,e){return t[0]=Math.ceil(e[0]),t[1]=Math.ceil(e[1]),t},floor:function(t,e){return t[0]=Math.floor(e[0]),t[1]=Math.floor(e[1]),t},min:function(t,e,r){return t[0]=Math.min(e[0],r[0]),t[1]=Math.min(e[1],r[1]),t},max:function(t,e,r){return t[0]=Math.max(e[0],r[0]),t[1]=Math.max(e[1],r[1]),t},round:function(t,e){return t[0]=Math.round(e[0]),t[1]=Math.round(e[1]),t},scale:function(t,e,r){return t[0]=e[0]*r,t[1]=e[1]*r,t},scaleAndAdd:function(t,e,r,n){return t[0]=e[0]+r[0]*n,t[1]=e[1]+r[1]*n,t},distance:Ee,squaredDistance:Pe,length:Le,squaredLength:Te,negate:function(t,e){return t[0]=-e[0],t[1]=-e[1],t},inverse:function(t,e){return t[0]=1/e[0],t[1]=1/e[1],t},normalize:function(t,e){var r=e[0],n=e[1],i=r*r+n*n;return i>0&&(i=1/Math.sqrt(i)),t[0]=e[0]*i,t[1]=e[1]*i,t},dot:function(t,e){return t[0]*e[0]+t[1]*e[1]},cross:function(t,e,r){var n=e[0]*r[1]-e[1]*r[0];return t[0]=t[1]=0,t[2]=n,t},lerp:function(t,e,r,n){var i=e[0],o=e[1];return t[0]=i+n*(r[0]-i),t[1]=o+n*(r[1]-o),t},random:function(t,e){e=e||1;var r=2*s()*Math.PI;return t[0]=Math.cos(r)*e,t[1]=Math.sin(r)*e,t},transformMat2:function(t,e,r){var n=e[0],i=e[1];return t[0]=r[0]*n+r[2]*i,t[1]=r[1]*n+r[3]*i,t},transformMat2d:function(t,e,r){var n=e[0],i=e[1];return t[0]=r[0]*n+r[2]*i+r[4],t[1]=r[1]*n+r[3]*i+r[5],t},transformMat3:function(t,e,r){var n=e[0],i=e[1];return t[0]=r[0]*n+r[3]*i+r[6],t[1]=r[1]*n+r[4]*i+r[7],t},transformMat4:function(t,e,r){var n=e[0],i=e[1];return t[0]=r[0]*n+r[4]*i+r[12],t[1]=r[1]*n+r[5]*i+r[13],t},rotate:function(t,e,r,n){var i=e[0]-r[0],o=e[1]-r[1],a=Math.sin(n),s=Math.cos(n);return t[0]=i*s-o*a+r[0],t[1]=i*a+o*s+r[1],t},angle:function(t,e){var r=t[0],n=t[1],i=e[0],o=e[1],a=Math.sqrt(r*r+n*n)*Math.sqrt(i*i+o*o),s=a&&(r*i+n*o)/a;return Math.acos(Math.min(Math.max(s,-1),1))},zero:function(t){return t[0]=0,t[1]=0,t},str:function(t){return"vec2("+t[0]+", "+t[1]+")"},exactEquals:function(t,e){return t[0]===e[0]&&t[1]===e[1]},equals:function(t,e){var r=t[0],n=t[1],i=e[0],a=e[1];return Math.abs(r-i)<=o*Math.max(1,Math.abs(r),Math.abs(i))&&Math.abs(n-a)<=o*Math.max(1,Math.abs(n),Math.abs(a))},len:De,sub:Re,mul:Ie,div:Fe,dist:Be,sqrDist:je,sqrLen:Ve,forEach:Ne}),Ge=Object.freeze({__proto__:null,glMatrix:u,mat2:p,mat2d:b,mat3:k,mat4:R,quat:de,quat2:ke,vec2:Ue,vec3:nt,vec4:Pt});function We(t,e){var r=t.__state.conversionName.toString(),n=Math.round(t.r),i=Math.round(t.g),o=Math.round(t.b),a=t.a,s=Math.round(t.h),l=t.s.toFixed(1),u=t.v.toFixed(1);if(e||"THREE_CHAR_HEX"===r||"SIX_CHAR_HEX"===r){for(var c=t.hex.toString(16);c.length<6;)c="0"+c;return"#"+c}return"CSS_RGB"===r?"rgb("+n+","+i+","+o+")":"CSS_RGBA"===r?"rgba("+n+","+i+","+o+","+a+")":"HEX"===r?"0x"+t.hex.toString(16):"RGB_ARRAY"===r?"["+n+","+i+","+o+"]":"RGBA_ARRAY"===r?"["+n+","+i+","+o+","+a+"]":"RGB_OBJ"===r?"{r:"+n+",g:"+i+",b:"+o+"}":"RGBA_OBJ"===r?"{r:"+n+",g:"+i+",b:"+o+",a:"+a+"}":"HSV_OBJ"===r?"{h:"+s+",s:"+l+",v:"+u+"}":"HSVA_OBJ"===r?"{h:"+s+",s:"+l+",v:"+u+",a:"+a+"}":"unknown format"}var qe=Array.prototype.forEach,He=Array.prototype.slice,Ze={BREAK:{},extend:function(t){return this.each(He.call(arguments,1),(function(e){(this.isObject(e)?Object.keys(e):[]).forEach(function(r){this.isUndefined(e[r])||(t[r]=e[r])}.bind(this))}),this),t},defaults:function(t){return this.each(He.call(arguments,1),(function(e){(this.isObject(e)?Object.keys(e):[]).forEach(function(r){this.isUndefined(t[r])&&(t[r]=e[r])}.bind(this))}),this),t},compose:function(){var t=He.call(arguments);return function(){for(var e=He.call(arguments),r=t.length-1;r>=0;r--)e=[t[r].apply(this,e)];return e[0]}},each:function(t,e,r){if(t)if(qe&&t.forEach&&t.forEach===qe)t.forEach(e,r);else if(t.length===t.length+0){var n,i=void 0;for(i=0,n=t.length;i<n;i++)if(i in t&&e.call(r,t[i],i)===this.BREAK)return}else for(var o in t)if(e.call(r,t[o],o)===this.BREAK)return},defer:function(t){setTimeout(t,0)},debounce:function(t,e,r){var n=void 0;return function(){var i=this,o=arguments;function a(){n=null,r||t.apply(i,o)}var s=r||!n;clearTimeout(n),n=setTimeout(a,e),s&&t.apply(i,o)}},toArray:function(t){return t.toArray?t.toArray():He.call(t)},isUndefined:function(t){return void 0===t},isNull:function(t){return null===t},isNaN:function(t){function e(e){return t.apply(this,arguments)}return e.toString=function(){return t.toString()},e}((function(t){return isNaN(t)})),isArray:Array.isArray||function(t){return t.constructor===Array},isObject:function(t){return t===Object(t)},isNumber:function(t){return t===t+0},isString:function(t){return t===t+""},isBoolean:function(t){return!1===t||!0===t},isFunction:function(t){return t instanceof Function}},Qe=[{litmus:Ze.isString,conversions:{THREE_CHAR_HEX:{read:function(t){var e=t.match(/^#([A-F0-9])([A-F0-9])([A-F0-9])$/i);return null!==e&&{space:"HEX",hex:parseInt("0x"+e[1].toString()+e[1].toString()+e[2].toString()+e[2].toString()+e[3].toString()+e[3].toString(),0)}},write:We},SIX_CHAR_HEX:{read:function(t){var e=t.match(/^#([A-F0-9]{6})$/i);return null!==e&&{space:"HEX",hex:parseInt("0x"+e[1].toString(),0)}},write:We},CSS_RGB:{read:function(t){var e=t.match(/^rgb\(\s*(.+)\s*,\s*(.+)\s*,\s*(.+)\s*\)/);return null!==e&&{space:"RGB",r:parseFloat(e[1]),g:parseFloat(e[2]),b:parseFloat(e[3])}},write:We},CSS_RGBA:{read:function(t){var e=t.match(/^rgba\(\s*(.+)\s*,\s*(.+)\s*,\s*(.+)\s*,\s*(.+)\s*\)/);return null!==e&&{space:"RGB",r:parseFloat(e[1]),g:parseFloat(e[2]),b:parseFloat(e[3]),a:parseFloat(e[4])}},write:We}}},{litmus:Ze.isNumber,conversions:{HEX:{read:function(t){return{space:"HEX",hex:t,conversionName:"HEX"}},write:function(t){return t.hex}}}},{litmus:Ze.isArray,conversions:{RGB_ARRAY:{read:function(t){return 3===t.length&&{space:"RGB",r:t[0],g:t[1],b:t[2]}},write:function(t){return[t.r,t.g,t.b]}},RGBA_ARRAY:{read:function(t){return 4===t.length&&{space:"RGB",r:t[0],g:t[1],b:t[2],a:t[3]}},write:function(t){return[t.r,t.g,t.b,t.a]}}}},{litmus:Ze.isObject,conversions:{RGBA_OBJ:{read:function(t){return!!(Ze.isNumber(t.r)&&Ze.isNumber(t.g)&&Ze.isNumber(t.b)&&Ze.isNumber(t.a))&&{space:"RGB",r:t.r,g:t.g,b:t.b,a:t.a}},write:function(t){return{r:t.r,g:t.g,b:t.b,a:t.a}}},RGB_OBJ:{read:function(t){return!!(Ze.isNumber(t.r)&&Ze.isNumber(t.g)&&Ze.isNumber(t.b))&&{space:"RGB",r:t.r,g:t.g,b:t.b}},write:function(t){return{r:t.r,g:t.g,b:t.b}}},HSVA_OBJ:{read:function(t){return!!(Ze.isNumber(t.h)&&Ze.isNumber(t.s)&&Ze.isNumber(t.v)&&Ze.isNumber(t.a))&&{space:"HSV",h:t.h,s:t.s,v:t.v,a:t.a}},write:function(t){return{h:t.h,s:t.s,v:t.v,a:t.a}}},HSV_OBJ:{read:function(t){return!!(Ze.isNumber(t.h)&&Ze.isNumber(t.s)&&Ze.isNumber(t.v))&&{space:"HSV",h:t.h,s:t.s,v:t.v}},write:function(t){return{h:t.h,s:t.s,v:t.v}}}}}],Xe=void 0,Ye=void 0,Je=function(){Ye=!1;var t=arguments.length>1?Ze.toArray(arguments):arguments[0];return Ze.each(Qe,(function(e){if(e.litmus(t))return Ze.each(e.conversions,(function(e,r){if(Xe=e.read(t),!1===Ye&&!1!==Xe)return Ye=Xe,Xe.conversionName=r,Xe.conversion=e,Ze.BREAK})),Ze.BREAK})),Ye},Ke=void 0,$e={hsv_to_rgb:function(t,e,r){var n=Math.floor(t/60)%6,i=t/60-Math.floor(t/60),o=r*(1-e),a=r*(1-i*e),s=r*(1-(1-i)*e),l=[[r,s,o],[a,r,o],[o,r,s],[o,a,r],[s,o,r],[r,o,a]][n];return{r:255*l[0],g:255*l[1],b:255*l[2]}},rgb_to_hsv:function(t,e,r){var n=Math.min(t,e,r),i=Math.max(t,e,r),o=i-n,a=void 0;return 0===i?{h:NaN,s:0,v:0}:(a=t===i?(e-r)/o:e===i?2+(r-t)/o:4+(t-e)/o,(a/=6)<0&&(a+=1),{h:360*a,s:o/i,v:i/255})},rgb_to_hex:function(t,e,r){var n=this.hex_with_component(0,2,t);return n=this.hex_with_component(n,1,e),n=this.hex_with_component(n,0,r)},component_from_hex:function(t,e){return t>>8*e&255},hex_with_component:function(t,e,r){return r<<(Ke=8*e)|t&~(255<<Ke)}},tr="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},er=function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")},rr=function(){function t(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,n.key,n)}}return function(e,r,n){return r&&t(e.prototype,r),n&&t(e,n),e}}(),nr=function t(e,r,n){null===e&&(e=Function.prototype);var i=Object.getOwnPropertyDescriptor(e,r);if(void 0===i){var o=Object.getPrototypeOf(e);return null===o?void 0:t(o,r,n)}if("value"in i)return i.value;var a=i.get;return void 0!==a?a.call(n):void 0},ir=function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function, not "+typeof e);t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}),e&&(Object.setPrototypeOf?Object.setPrototypeOf(t,e):t.__proto__=e)},or=function(t,e){if(!t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!e||"object"!=typeof e&&"function"!=typeof e?t:e},ar=function(){function t(){if(er(this,t),this.__state=Je.apply(this,arguments),!1===this.__state)throw new Error("Failed to interpret color arguments");this.__state.a=this.__state.a||1}return rr(t,[{key:"toString",value:function(){return We(this)}},{key:"toHexString",value:function(){return We(this,!0)}},{key:"toOriginal",value:function(){return this.__state.conversion.write(this)}}]),t}();function sr(t,e,r){Object.defineProperty(t,e,{get:function(){return"RGB"===this.__state.space||ar.recalculateRGB(this,e,r),this.__state[e]},set:function(t){"RGB"!==this.__state.space&&(ar.recalculateRGB(this,e,r),this.__state.space="RGB"),this.__state[e]=t}})}function lr(t,e){Object.defineProperty(t,e,{get:function(){return"HSV"===this.__state.space||ar.recalculateHSV(this),this.__state[e]},set:function(t){"HSV"!==this.__state.space&&(ar.recalculateHSV(this),this.__state.space="HSV"),this.__state[e]=t}})}ar.recalculateRGB=function(t,e,r){if("HEX"===t.__state.space)t.__state[e]=$e.component_from_hex(t.__state.hex,r);else{if("HSV"!==t.__state.space)throw new Error("Corrupted color state");Ze.extend(t.__state,$e.hsv_to_rgb(t.__state.h,t.__state.s,t.__state.v))}},ar.recalculateHSV=function(t){var e=$e.rgb_to_hsv(t.r,t.g,t.b);Ze.extend(t.__state,{s:e.s,v:e.v}),Ze.isNaN(e.h)?Ze.isUndefined(t.__state.h)&&(t.__state.h=0):t.__state.h=e.h},ar.COMPONENTS=["r","g","b","h","s","v","hex","a"],sr(ar.prototype,"r",2),sr(ar.prototype,"g",1),sr(ar.prototype,"b",0),lr(ar.prototype,"h"),lr(ar.prototype,"s"),lr(ar.prototype,"v"),Object.defineProperty(ar.prototype,"a",{get:function(){return this.__state.a},set:function(t){this.__state.a=t}}),Object.defineProperty(ar.prototype,"hex",{get:function(){return"HEX"!==this.__state.space&&(this.__state.hex=$e.rgb_to_hex(this.r,this.g,this.b),this.__state.space="HEX"),this.__state.hex},set:function(t){this.__state.space="HEX",this.__state.hex=t}});var ur=function(){function t(e,r){er(this,t),this.initialValue=e[r],this.domElement=document.createElement("div"),this.object=e,this.property=r,this.__onChange=void 0,this.__onFinishChange=void 0}return rr(t,[{key:"onChange",value:function(t){return this.__onChange=t,this}},{key:"onFinishChange",value:function(t){return this.__onFinishChange=t,this}},{key:"setValue",value:function(t){return this.object[this.property]=t,this.__onChange&&this.__onChange.call(this,t),this.updateDisplay(),this}},{key:"getValue",value:function(){return this.object[this.property]}},{key:"updateDisplay",value:function(){return this}},{key:"isModified",value:function(){return this.initialValue!==this.getValue()}}]),t}(),cr={};Ze.each({HTMLEvents:["change"],MouseEvents:["click","mousemove","mousedown","mouseup","mouseover"],KeyboardEvents:["keydown"]},(function(t,e){Ze.each(t,(function(t){cr[t]=e}))}));var fr=/(\d+(\.\d+)?)px/;function hr(t){if("0"===t||Ze.isUndefined(t))return 0;var e=t.match(fr);return Ze.isNull(e)?0:parseFloat(e[1])}var dr={makeSelectable:function(t,e){void 0!==t&&void 0!==t.style&&(t.onselectstart=e?function(){return!1}:function(){},t.style.MozUserSelect=e?"auto":"none",t.style.KhtmlUserSelect=e?"auto":"none",t.unselectable=e?"on":"off")},makeFullscreen:function(t,e,r){var n=r,i=e;Ze.isUndefined(i)&&(i=!0),Ze.isUndefined(n)&&(n=!0),t.style.position="absolute",i&&(t.style.left=0,t.style.right=0),n&&(t.style.top=0,t.style.bottom=0)},fakeEvent:function(t,e,r,n){var i=r||{},o=cr[e];if(!o)throw new Error("Event type "+e+" not supported.");var a=document.createEvent(o);switch(o){case"MouseEvents":var s=i.x||i.clientX||0,l=i.y||i.clientY||0;a.initMouseEvent(e,i.bubbles||!1,i.cancelable||!0,window,i.clickCount||1,0,0,s,l,!1,!1,!1,!1,0,null);break;case"KeyboardEvents":var u=a.initKeyboardEvent||a.initKeyEvent;Ze.defaults(i,{cancelable:!0,ctrlKey:!1,altKey:!1,shiftKey:!1,metaKey:!1,keyCode:void 0,charCode:void 0}),u(e,i.bubbles||!1,i.cancelable,window,i.ctrlKey,i.altKey,i.shiftKey,i.metaKey,i.keyCode,i.charCode);break;default:a.initEvent(e,i.bubbles||!1,i.cancelable||!0)}Ze.defaults(a,n),t.dispatchEvent(a)},bind:function(t,e,r,n){var i=n||!1;return t.addEventListener?t.addEventListener(e,r,i):t.attachEvent&&t.attachEvent("on"+e,r),dr},unbind:function(t,e,r,n){var i=n||!1;return t.removeEventListener?t.removeEventListener(e,r,i):t.detachEvent&&t.detachEvent("on"+e,r),dr},addClass:function(t,e){if(void 0===t.className)t.className=e;else if(t.className!==e){var r=t.className.split(/ +/);-1===r.indexOf(e)&&(r.push(e),t.className=r.join(" ").replace(/^\s+/,"").replace(/\s+$/,""))}return dr},removeClass:function(t,e){if(e)if(t.className===e)t.removeAttribute("class");else{var r=t.className.split(/ +/),n=r.indexOf(e);-1!==n&&(r.splice(n,1),t.className=r.join(" "))}else t.className=void 0;return dr},hasClass:function(t,e){return new RegExp("(?:^|\\s+)"+e+"(?:\\s+|$)").test(t.className)||!1},getWidth:function(t){var e=getComputedStyle(t);return hr(e["border-left-width"])+hr(e["border-right-width"])+hr(e["padding-left"])+hr(e["padding-right"])+hr(e.width)},getHeight:function(t){var e=getComputedStyle(t);return hr(e["border-top-width"])+hr(e["border-bottom-width"])+hr(e["padding-top"])+hr(e["padding-bottom"])+hr(e.height)},getOffset:function(t){var e=t,r={left:0,top:0};if(e.offsetParent)do{r.left+=e.offsetLeft,r.top+=e.offsetTop,e=e.offsetParent}while(e);return r},isActive:function(t){return t===document.activeElement&&(t.type||t.href)}},pr=function(t){function e(t,r){er(this,e);var n=or(this,(e.__proto__||Object.getPrototypeOf(e)).call(this,t,r)),i=n;return n.__prev=n.getValue(),n.__checkbox=document.createElement("input"),n.__checkbox.setAttribute("type","checkbox"),dr.bind(n.__checkbox,"change",(function(){i.setValue(!i.__prev)}),!1),n.domElement.appendChild(n.__checkbox),n.updateDisplay(),n}return ir(e,t),rr(e,[{key:"setValue",value:function(t){var r=nr(e.prototype.__proto__||Object.getPrototypeOf(e.prototype),"setValue",this).call(this,t);return this.__onFinishChange&&this.__onFinishChange.call(this,this.getValue()),this.__prev=this.getValue(),r}},{key:"updateDisplay",value:function(){return!0===this.getValue()?(this.__checkbox.setAttribute("checked","checked"),this.__checkbox.checked=!0,this.__prev=!0):(this.__checkbox.checked=!1,this.__prev=!1),nr(e.prototype.__proto__||Object.getPrototypeOf(e.prototype),"updateDisplay",this).call(this)}}]),e}(ur),mr=function(t){function e(t,r,n){er(this,e);var i=or(this,(e.__proto__||Object.getPrototypeOf(e)).call(this,t,r)),o=n,a=i;if(i.__select=document.createElement("select"),Ze.isArray(o)){var s={};Ze.each(o,(function(t){s[t]=t})),o=s}return Ze.each(o,(function(t,e){var r=document.createElement("option");r.innerHTML=e,r.setAttribute("value",t),a.__select.appendChild(r)})),i.updateDisplay(),dr.bind(i.__select,"change",(function(){var t=this.options[this.selectedIndex].value;a.setValue(t)})),i.domElement.appendChild(i.__select),i}return ir(e,t),rr(e,[{key:"setValue",value:function(t){var r=nr(e.prototype.__proto__||Object.getPrototypeOf(e.prototype),"setValue",this).call(this,t);return this.__onFinishChange&&this.__onFinishChange.call(this,this.getValue()),r}},{key:"updateDisplay",value:function(){return dr.isActive(this.__select)?this:(this.__select.value=this.getValue(),nr(e.prototype.__proto__||Object.getPrototypeOf(e.prototype),"updateDisplay",this).call(this))}}]),e}(ur),vr=function(t){function e(t,r){er(this,e);var n=or(this,(e.__proto__||Object.getPrototypeOf(e)).call(this,t,r)),i=n;function o(){i.setValue(i.__input.value)}return n.__input=document.createElement("input"),n.__input.setAttribute("type","text"),dr.bind(n.__input,"keyup",o),dr.bind(n.__input,"change",o),dr.bind(n.__input,"blur",(function(){i.__onFinishChange&&i.__onFinishChange.call(i,i.getValue())})),dr.bind(n.__input,"keydown",(function(t){13===t.keyCode&&this.blur()})),n.updateDisplay(),n.domElement.appendChild(n.__input),n}return ir(e,t),rr(e,[{key:"updateDisplay",value:function(){return dr.isActive(this.__input)||(this.__input.value=this.getValue()),nr(e.prototype.__proto__||Object.getPrototypeOf(e.prototype),"updateDisplay",this).call(this)}}]),e}(ur);function gr(t){var e=t.toString();return e.indexOf(".")>-1?e.length-e.indexOf(".")-1:0}var yr=function(t){function e(t,r,n){er(this,e);var i=or(this,(e.__proto__||Object.getPrototypeOf(e)).call(this,t,r)),o=n||{};return i.__min=o.min,i.__max=o.max,i.__step=o.step,Ze.isUndefined(i.__step)?0===i.initialValue?i.__impliedStep=1:i.__impliedStep=Math.pow(10,Math.floor(Math.log(Math.abs(i.initialValue))/Math.LN10))/10:i.__impliedStep=i.__step,i.__precision=gr(i.__impliedStep),i}return ir(e,t),rr(e,[{key:"setValue",value:function(t){var r=t;return void 0!==this.__min&&r<this.__min?r=this.__min:void 0!==this.__max&&r>this.__max&&(r=this.__max),void 0!==this.__step&&r%this.__step!=0&&(r=Math.round(r/this.__step)*this.__step),nr(e.prototype.__proto__||Object.getPrototypeOf(e.prototype),"setValue",this).call(this,r)}},{key:"min",value:function(t){return this.__min=t,this}},{key:"max",value:function(t){return this.__max=t,this}},{key:"step",value:function(t){return this.__step=t,this.__impliedStep=t,this.__precision=gr(t),this}}]),e}(ur);var br=function(t){function e(t,r,n){er(this,e);var i=or(this,(e.__proto__||Object.getPrototypeOf(e)).call(this,t,r,n));i.__truncationSuspended=!1;var o=i,a=void 0;function s(){o.__onFinishChange&&o.__onFinishChange.call(o,o.getValue())}function l(t){var e=a-t.clientY;o.setValue(o.getValue()+e*o.__impliedStep),a=t.clientY}function u(){dr.unbind(window,"mousemove",l),dr.unbind(window,"mouseup",u),s()}return i.__input=document.createElement("input"),i.__input.setAttribute("type","text"),dr.bind(i.__input,"change",(function(){var t=parseFloat(o.__input.value);Ze.isNaN(t)||o.setValue(t)})),dr.bind(i.__input,"blur",(function(){s()})),dr.bind(i.__input,"mousedown",(function(t){dr.bind(window,"mousemove",l),dr.bind(window,"mouseup",u),a=t.clientY})),dr.bind(i.__input,"keydown",(function(t){13===t.keyCode&&(o.__truncationSuspended=!0,this.blur(),o.__truncationSuspended=!1,s())})),i.updateDisplay(),i.domElement.appendChild(i.__input),i}return ir(e,t),rr(e,[{key:"updateDisplay",value:function(){var t,r,n;return this.__input.value=this.__truncationSuspended?this.getValue():(t=this.getValue(),r=this.__precision,n=Math.pow(10,r),Math.round(t*n)/n),nr(e.prototype.__proto__||Object.getPrototypeOf(e.prototype),"updateDisplay",this).call(this)}}]),e}(yr);function xr(t,e,r,n,i){return n+(t-e)/(r-e)*(i-n)}var _r=function(t){function e(t,r,n,i,o){er(this,e);var a=or(this,(e.__proto__||Object.getPrototypeOf(e)).call(this,t,r,{min:n,max:i,step:o})),s=a;function l(t){t.preventDefault();var e=s.__background.getBoundingClientRect();return s.setValue(xr(t.clientX,e.left,e.right,s.__min,s.__max)),!1}function u(){dr.unbind(window,"mousemove",l),dr.unbind(window,"mouseup",u),s.__onFinishChange&&s.__onFinishChange.call(s,s.getValue())}function c(t){var e=t.touches[0].clientX,r=s.__background.getBoundingClientRect();s.setValue(xr(e,r.left,r.right,s.__min,s.__max))}function f(){dr.unbind(window,"touchmove",c),dr.unbind(window,"touchend",f),s.__onFinishChange&&s.__onFinishChange.call(s,s.getValue())}return a.__background=document.createElement("div"),a.__foreground=document.createElement("div"),dr.bind(a.__background,"mousedown",(function(t){document.activeElement.blur(),dr.bind(window,"mousemove",l),dr.bind(window,"mouseup",u),l(t)})),dr.bind(a.__background,"touchstart",(function(t){if(1!==t.touches.length)return;dr.bind(window,"touchmove",c),dr.bind(window,"touchend",f),c(t)})),dr.addClass(a.__background,"slider"),dr.addClass(a.__foreground,"slider-fg"),a.updateDisplay(),a.__background.appendChild(a.__foreground),a.domElement.appendChild(a.__background),a}return ir(e,t),rr(e,[{key:"updateDisplay",value:function(){var t=(this.getValue()-this.__min)/(this.__max-this.__min);return this.__foreground.style.width=100*t+"%",nr(e.prototype.__proto__||Object.getPrototypeOf(e.prototype),"updateDisplay",this).call(this)}}]),e}(yr),wr=function(t){function e(t,r,n){er(this,e);var i=or(this,(e.__proto__||Object.getPrototypeOf(e)).call(this,t,r)),o=i;return i.__button=document.createElement("div"),i.__button.innerHTML=void 0===n?"Fire":n,dr.bind(i.__button,"click",(function(t){return t.preventDefault(),o.fire(),!1})),dr.addClass(i.__button,"button"),i.domElement.appendChild(i.__button),i}return ir(e,t),rr(e,[{key:"fire",value:function(){this.__onChange&&this.__onChange.call(this),this.getValue().call(this.object),this.__onFinishChange&&this.__onFinishChange.call(this,this.getValue())}}]),e}(ur),Cr=function(t){function e(t,r){er(this,e);var n=or(this,(e.__proto__||Object.getPrototypeOf(e)).call(this,t,r));n.__color=new ar(n.getValue()),n.__temp=new ar(0);var i=n;n.domElement=document.createElement("div"),dr.makeSelectable(n.domElement,!1),n.__selector=document.createElement("div"),n.__selector.className="selector",n.__saturation_field=document.createElement("div"),n.__saturation_field.className="saturation-field",n.__field_knob=document.createElement("div"),n.__field_knob.className="field-knob",n.__field_knob_border="2px solid ",n.__hue_knob=document.createElement("div"),n.__hue_knob.className="hue-knob",n.__hue_field=document.createElement("div"),n.__hue_field.className="hue-field",n.__input=document.createElement("input"),n.__input.type="text",n.__input_textShadow="0 1px 1px ",dr.bind(n.__input,"keydown",(function(t){13===t.keyCode&&f.call(this)})),dr.bind(n.__input,"blur",f),dr.bind(n.__selector,"mousedown",(function(){dr.addClass(this,"drag").bind(window,"mouseup",(function(){dr.removeClass(i.__selector,"drag")}))})),dr.bind(n.__selector,"touchstart",(function(){dr.addClass(this,"drag").bind(window,"touchend",(function(){dr.removeClass(i.__selector,"drag")}))}));var o,a=document.createElement("div");function s(t){d(t),dr.bind(window,"mousemove",d),dr.bind(window,"touchmove",d),dr.bind(window,"mouseup",u),dr.bind(window,"touchend",u)}function l(t){p(t),dr.bind(window,"mousemove",p),dr.bind(window,"touchmove",p),dr.bind(window,"mouseup",c),dr.bind(window,"touchend",c)}function u(){dr.unbind(window,"mousemove",d),dr.unbind(window,"touchmove",d),dr.unbind(window,"mouseup",u),dr.unbind(window,"touchend",u),h()}function c(){dr.unbind(window,"mousemove",p),dr.unbind(window,"touchmove",p),dr.unbind(window,"mouseup",c),dr.unbind(window,"touchend",c),h()}function f(){var t=Je(this.value);!1!==t?(i.__color.__state=t,i.setValue(i.__color.toOriginal())):this.value=i.__color.toString()}function h(){i.__onFinishChange&&i.__onFinishChange.call(i,i.__color.toOriginal())}function d(t){-1===t.type.indexOf("touch")&&t.preventDefault();var e=i.__saturation_field.getBoundingClientRect(),r=t.touches&&t.touches[0]||t,n=r.clientX,o=r.clientY,a=(n-e.left)/(e.right-e.left),s=1-(o-e.top)/(e.bottom-e.top);return s>1?s=1:s<0&&(s=0),a>1?a=1:a<0&&(a=0),i.__color.v=s,i.__color.s=a,i.setValue(i.__color.toOriginal()),!1}function p(t){-1===t.type.indexOf("touch")&&t.preventDefault();var e=i.__hue_field.getBoundingClientRect(),r=1-((t.touches&&t.touches[0]||t).clientY-e.top)/(e.bottom-e.top);return r>1?r=1:r<0&&(r=0),i.__color.h=360*r,i.setValue(i.__color.toOriginal()),!1}return Ze.extend(n.__selector.style,{width:"122px",height:"102px",padding:"3px",backgroundColor:"#222",boxShadow:"0px 1px 3px rgba(0,0,0,0.3)"}),Ze.extend(n.__field_knob.style,{position:"absolute",width:"12px",height:"12px",border:n.__field_knob_border+(n.__color.v<.5?"#fff":"#000"),boxShadow:"0px 1px 3px rgba(0,0,0,0.5)",borderRadius:"12px",zIndex:1}),Ze.extend(n.__hue_knob.style,{position:"absolute",width:"15px",height:"2px",borderRight:"4px solid #fff",zIndex:1}),Ze.extend(n.__saturation_field.style,{width:"100px",height:"100px",border:"1px solid #555",marginRight:"3px",display:"inline-block",cursor:"pointer"}),Ze.extend(a.style,{width:"100%",height:"100%",background:"none"}),kr(a,"top","rgba(0,0,0,0)","#000"),Ze.extend(n.__hue_field.style,{width:"15px",height:"100px",border:"1px solid #555",cursor:"ns-resize",position:"absolute",top:"3px",right:"3px"}),(o=n.__hue_field).style.background="",o.style.cssText+="background: -moz-linear-gradient(top,  #ff0000 0%, #ff00ff 17%, #0000ff 34%, #00ffff 50%, #00ff00 67%, #ffff00 84%, #ff0000 100%);",o.style.cssText+="background: -webkit-linear-gradient(top,  #ff0000 0%,#ff00ff 17%,#0000ff 34%,#00ffff 50%,#00ff00 67%,#ffff00 84%,#ff0000 100%);",o.style.cssText+="background: -o-linear-gradient(top,  #ff0000 0%,#ff00ff 17%,#0000ff 34%,#00ffff 50%,#00ff00 67%,#ffff00 84%,#ff0000 100%);",o.style.cssText+="background: -ms-linear-gradient(top,  #ff0000 0%,#ff00ff 17%,#0000ff 34%,#00ffff 50%,#00ff00 67%,#ffff00 84%,#ff0000 100%);",o.style.cssText+="background: linear-gradient(top,  #ff0000 0%,#ff00ff 17%,#0000ff 34%,#00ffff 50%,#00ff00 67%,#ffff00 84%,#ff0000 100%);",Ze.extend(n.__input.style,{outline:"none",textAlign:"center",color:"#fff",border:0,fontWeight:"bold",textShadow:n.__input_textShadow+"rgba(0,0,0,0.7)"}),dr.bind(n.__saturation_field,"mousedown",s),dr.bind(n.__saturation_field,"touchstart",s),dr.bind(n.__field_knob,"mousedown",s),dr.bind(n.__field_knob,"touchstart",s),dr.bind(n.__hue_field,"mousedown",l),dr.bind(n.__hue_field,"touchstart",l),n.__saturation_field.appendChild(a),n.__selector.appendChild(n.__field_knob),n.__selector.appendChild(n.__saturation_field),n.__selector.appendChild(n.__hue_field),n.__hue_field.appendChild(n.__hue_knob),n.domElement.appendChild(n.__input),n.domElement.appendChild(n.__selector),n.updateDisplay(),n}return ir(e,t),rr(e,[{key:"updateDisplay",value:function(){var t=Je(this.getValue());if(!1!==t){var e=!1;Ze.each(ar.COMPONENTS,(function(r){if(!Ze.isUndefined(t[r])&&!Ze.isUndefined(this.__color.__state[r])&&t[r]!==this.__color.__state[r])return e=!0,{}}),this),e&&Ze.extend(this.__color.__state,t)}Ze.extend(this.__temp.__state,this.__color.__state),this.__temp.a=1;var r=this.__color.v<.5||this.__color.s>.5?255:0,n=255-r;Ze.extend(this.__field_knob.style,{marginLeft:100*this.__color.s-7+"px",marginTop:100*(1-this.__color.v)-7+"px",backgroundColor:this.__temp.toHexString(),border:this.__field_knob_border+"rgb("+r+","+r+","+r+")"}),this.__hue_knob.style.marginTop=100*(1-this.__color.h/360)+"px",this.__temp.s=1,this.__temp.v=1,kr(this.__saturation_field,"left","#fff",this.__temp.toHexString()),this.__input.value=this.__color.toString(),Ze.extend(this.__input.style,{backgroundColor:this.__color.toHexString(),color:"rgb("+r+","+r+","+r+")",textShadow:this.__input_textShadow+"rgba("+n+","+n+","+n+",.7)"})}}]),e}(ur),Sr=["-moz-","-o-","-webkit-","-ms-",""];function kr(t,e,r,n){t.style.background="",Ze.each(Sr,(function(i){t.style.cssText+="background: "+i+"linear-gradient("+e+", "+r+" 0%, "+n+" 100%); "}))}var Ar=function(t,e){var r=e||document,n=document.createElement("style");n.type="text/css",n.innerHTML=t;var i=r.getElementsByTagName("head")[0];try{i.appendChild(n)}catch(t){}},Mr='<div id="dg-save" class="dg dialogue">\n\n  Here\'s the new load parameter for your <code>GUI</code>\'s constructor:\n\n  <textarea id="dg-new-constructor"></textarea>\n\n  <div id="dg-save-locally">\n\n    <input id="dg-local-storage" type="checkbox"/> Automatically save\n    values to <code>localStorage</code> on exit.\n\n    <div id="dg-local-explain">The values saved to <code>localStorage</code> will\n      override those passed to <code>dat.GUI</code>\'s constructor. This makes it\n      easier to work incrementally, but <code>localStorage</code> is fragile,\n      and your friends may not see the same values you do.\n\n    </div>\n\n  </div>\n\n</div>',zr=function(t,e){var r=t[e];return Ze.isArray(arguments[2])||Ze.isObject(arguments[2])?new mr(t,e,arguments[2]):Ze.isNumber(r)?Ze.isNumber(arguments[2])&&Ze.isNumber(arguments[3])?Ze.isNumber(arguments[4])?new _r(t,e,arguments[2],arguments[3],arguments[4]):new _r(t,e,arguments[2],arguments[3]):Ze.isNumber(arguments[4])?new br(t,e,{min:arguments[2],max:arguments[3],step:arguments[4]}):new br(t,e,{min:arguments[2],max:arguments[3]}):Ze.isString(r)?new vr(t,e):Ze.isFunction(r)?new wr(t,e,""):Ze.isBoolean(r)?new pr(t,e):null};var Or=window.requestAnimationFrame||window.webkitRequestAnimationFrame||window.mozRequestAnimationFrame||window.oRequestAnimationFrame||window.msRequestAnimationFrame||function(t){setTimeout(t,1e3/60)},Er=function(){function t(){er(this,t),this.backgroundElement=document.createElement("div"),Ze.extend(this.backgroundElement.style,{backgroundColor:"rgba(0,0,0,0.8)",top:0,left:0,display:"none",zIndex:"1000",opacity:0,WebkitTransition:"opacity 0.2s linear",transition:"opacity 0.2s linear"}),dr.makeFullscreen(this.backgroundElement),this.backgroundElement.style.position="fixed",this.domElement=document.createElement("div"),Ze.extend(this.domElement.style,{position:"fixed",display:"none",zIndex:"1001",opacity:0,WebkitTransition:"-webkit-transform 0.2s ease-out, opacity 0.2s linear",transition:"transform 0.2s ease-out, opacity 0.2s linear"}),document.body.appendChild(this.backgroundElement),document.body.appendChild(this.domElement);var e=this;dr.bind(this.backgroundElement,"click",(function(){e.hide()}))}return rr(t,[{key:"show",value:function(){var t=this;this.backgroundElement.style.display="block",this.domElement.style.display="block",this.domElement.style.opacity=0,this.domElement.style.webkitTransform="scale(1.1)",this.layout(),Ze.defer((function(){t.backgroundElement.style.opacity=1,t.domElement.style.opacity=1,t.domElement.style.webkitTransform="scale(1)"}))}},{key:"hide",value:function(){var t=this,e=function e(){t.domElement.style.display="none",t.backgroundElement.style.display="none",dr.unbind(t.domElement,"webkitTransitionEnd",e),dr.unbind(t.domElement,"transitionend",e),dr.unbind(t.domElement,"oTransitionEnd",e)};dr.bind(this.domElement,"webkitTransitionEnd",e),dr.bind(this.domElement,"transitionend",e),dr.bind(this.domElement,"oTransitionEnd",e),this.backgroundElement.style.opacity=0,this.domElement.style.opacity=0,this.domElement.style.webkitTransform="scale(1.1)"}},{key:"layout",value:function(){this.domElement.style.left=window.innerWidth/2-dr.getWidth(this.domElement)/2+"px",this.domElement.style.top=window.innerHeight/2-dr.getHeight(this.domElement)/2+"px"}}]),t}();Ar(function(t){if(t&&"undefined"!=typeof window){var e=document.createElement("style");return e.setAttribute("type","text/css"),e.innerHTML=t,document.head.appendChild(e),t}}(".dg ul{list-style:none;margin:0;padding:0;width:100%;clear:both}.dg.ac{position:fixed;top:0;left:0;right:0;height:0;z-index:0}.dg:not(.ac) .main{overflow:hidden}.dg.main{-webkit-transition:opacity .1s linear;-o-transition:opacity .1s linear;-moz-transition:opacity .1s linear;transition:opacity .1s linear}.dg.main.taller-than-window{overflow-y:auto}.dg.main.taller-than-window .close-button{opacity:1;margin-top:-1px;border-top:1px solid #2c2c2c}.dg.main ul.closed .close-button{opacity:1 !important}.dg.main:hover .close-button,.dg.main .close-button.drag{opacity:1}.dg.main .close-button{-webkit-transition:opacity .1s linear;-o-transition:opacity .1s linear;-moz-transition:opacity .1s linear;transition:opacity .1s linear;border:0;line-height:19px;height:20px;cursor:pointer;text-align:center;background-color:#000}.dg.main .close-button.close-top{position:relative}.dg.main .close-button.close-bottom{position:absolute}.dg.main .close-button:hover{background-color:#111}.dg.a{float:right;margin-right:15px;overflow-y:visible}.dg.a.has-save>ul.close-top{margin-top:0}.dg.a.has-save>ul.close-bottom{margin-top:27px}.dg.a.has-save>ul.closed{margin-top:0}.dg.a .save-row{top:0;z-index:1002}.dg.a .save-row.close-top{position:relative}.dg.a .save-row.close-bottom{position:fixed}.dg li{-webkit-transition:height .1s ease-out;-o-transition:height .1s ease-out;-moz-transition:height .1s ease-out;transition:height .1s ease-out;-webkit-transition:overflow .1s linear;-o-transition:overflow .1s linear;-moz-transition:overflow .1s linear;transition:overflow .1s linear}.dg li:not(.folder){cursor:auto;height:27px;line-height:27px;padding:0 4px 0 5px}.dg li.folder{padding:0;border-left:4px solid rgba(0,0,0,0)}.dg li.title{cursor:pointer;margin-left:-4px}.dg .closed li:not(.title),.dg .closed ul li,.dg .closed ul li>*{height:0;overflow:hidden;border:0}.dg .cr{clear:both;padding-left:3px;height:27px;overflow:hidden}.dg .property-name{cursor:default;float:left;clear:left;width:40%;overflow:hidden;text-overflow:ellipsis}.dg .c{float:left;width:60%;position:relative}.dg .c input[type=text]{border:0;margin-top:4px;padding:3px;width:100%;float:right}.dg .has-slider input[type=text]{width:30%;margin-left:0}.dg .slider{float:left;width:66%;margin-left:-5px;margin-right:0;height:19px;margin-top:4px}.dg .slider-fg{height:100%}.dg .c input[type=checkbox]{margin-top:7px}.dg .c select{margin-top:5px}.dg .cr.function,.dg .cr.function .property-name,.dg .cr.function *,.dg .cr.boolean,.dg .cr.boolean *{cursor:pointer}.dg .cr.color{overflow:visible}.dg .selector{display:none;position:absolute;margin-left:-9px;margin-top:23px;z-index:10}.dg .c:hover .selector,.dg .selector.drag{display:block}.dg li.save-row{padding:0}.dg li.save-row .button{display:inline-block;padding:0px 6px}.dg.dialogue{background-color:#222;width:460px;padding:15px;font-size:13px;line-height:15px}#dg-new-constructor{padding:10px;color:#222;font-family:Monaco, monospace;font-size:10px;border:0;resize:none;box-shadow:inset 1px 1px 1px #888;word-wrap:break-word;margin:12px 0;display:block;width:440px;overflow-y:scroll;height:100px;position:relative}#dg-local-explain{display:none;font-size:11px;line-height:17px;border-radius:3px;background-color:#333;padding:8px;margin-top:10px}#dg-local-explain code{font-size:10px}#dat-gui-save-locally{display:none}.dg{color:#eee;font:11px 'Lucida Grande', sans-serif;text-shadow:0 -1px 0 #111}.dg.main::-webkit-scrollbar{width:5px;background:#1a1a1a}.dg.main::-webkit-scrollbar-corner{height:0;display:none}.dg.main::-webkit-scrollbar-thumb{border-radius:5px;background:#676767}.dg li:not(.folder){background:#1a1a1a;border-bottom:1px solid #2c2c2c}.dg li.save-row{line-height:25px;background:#dad5cb;border:0}.dg li.save-row select{margin-left:5px;width:108px}.dg li.save-row .button{margin-left:5px;margin-top:1px;border-radius:2px;font-size:9px;line-height:7px;padding:4px 4px 5px 4px;background:#c5bdad;color:#fff;text-shadow:0 1px 0 #b0a58f;box-shadow:0 -1px 0 #b0a58f;cursor:pointer}.dg li.save-row .button.gears{background:#c5bdad url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAsAAAANCAYAAAB/9ZQ7AAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAQJJREFUeNpiYKAU/P//PwGIC/ApCABiBSAW+I8AClAcgKxQ4T9hoMAEUrxx2QSGN6+egDX+/vWT4e7N82AMYoPAx/evwWoYoSYbACX2s7KxCxzcsezDh3evFoDEBYTEEqycggWAzA9AuUSQQgeYPa9fPv6/YWm/Acx5IPb7ty/fw+QZblw67vDs8R0YHyQhgObx+yAJkBqmG5dPPDh1aPOGR/eugW0G4vlIoTIfyFcA+QekhhHJhPdQxbiAIguMBTQZrPD7108M6roWYDFQiIAAv6Aow/1bFwXgis+f2LUAynwoIaNcz8XNx3Dl7MEJUDGQpx9gtQ8YCueB+D26OECAAQDadt7e46D42QAAAABJRU5ErkJggg==) 2px 1px no-repeat;height:7px;width:8px}.dg li.save-row .button:hover{background-color:#bab19e;box-shadow:0 -1px 0 #b0a58f}.dg li.folder{border-bottom:0}.dg li.title{padding-left:16px;background:#000 url(data:image/gif;base64,R0lGODlhBQAFAJEAAP////Pz8////////yH5BAEAAAIALAAAAAAFAAUAAAIIlI+hKgFxoCgAOw==) 6px 10px no-repeat;cursor:pointer;border-bottom:1px solid rgba(255,255,255,0.2)}.dg .closed li.title{background-image:url(data:image/gif;base64,R0lGODlhBQAFAJEAAP////Pz8////////yH5BAEAAAIALAAAAAAFAAUAAAIIlGIWqMCbWAEAOw==)}.dg .cr.boolean{border-left:3px solid #806787}.dg .cr.color{border-left:3px solid}.dg .cr.function{border-left:3px solid #e61d5f}.dg .cr.number{border-left:3px solid #2FA1D6}.dg .cr.number input[type=text]{color:#2FA1D6}.dg .cr.string{border-left:3px solid #1ed36f}.dg .cr.string input[type=text]{color:#1ed36f}.dg .cr.function:hover,.dg .cr.boolean:hover{background:#111}.dg .c input[type=text]{background:#303030;outline:none}.dg .c input[type=text]:hover{background:#3c3c3c}.dg .c input[type=text]:focus{background:#494949;color:#fff}.dg .c .slider{background:#303030;cursor:ew-resize}.dg .c .slider-fg{background:#2FA1D6;max-width:100%}.dg .c .slider:hover{background:#3c3c3c}.dg .c .slider:hover .slider-fg{background:#44abda}\n"));var Pr="Default",Lr=function(){try{return!!window.localStorage}catch(t){return!1}}(),Tr=void 0,Dr=!0,Rr=void 0,Ir=!1,Fr=[],Br=function t(e){var r=this,n=e||{};this.domElement=document.createElement("div"),this.__ul=document.createElement("ul"),this.domElement.appendChild(this.__ul),dr.addClass(this.domElement,"dg"),this.__folders={},this.__controllers=[],this.__rememberedObjects=[],this.__rememberedObjectIndecesToControllers=[],this.__listening=[],n=Ze.defaults(n,{closeOnTop:!1,autoPlace:!0,width:t.DEFAULT_WIDTH}),n=Ze.defaults(n,{resizable:n.autoPlace,hideable:n.autoPlace}),Ze.isUndefined(n.load)?n.load={preset:Pr}:n.preset&&(n.load.preset=n.preset),Ze.isUndefined(n.parent)&&n.hideable&&Fr.push(this),n.resizable=Ze.isUndefined(n.parent)&&n.resizable,n.autoPlace&&Ze.isUndefined(n.scrollable)&&(n.scrollable=!0);var i,o=Lr&&"true"===localStorage.getItem(Wr(this,"isLocal")),a=void 0,s=void 0;if(Object.defineProperties(this,{parent:{get:function(){return n.parent}},scrollable:{get:function(){return n.scrollable}},autoPlace:{get:function(){return n.autoPlace}},closeOnTop:{get:function(){return n.closeOnTop}},preset:{get:function(){return r.parent?r.getRoot().preset:n.load.preset},set:function(t){r.parent?r.getRoot().preset=t:n.load.preset=t,function(t){for(var e=0;e<t.__preset_select.length;e++)t.__preset_select[e].value===t.preset&&(t.__preset_select.selectedIndex=e)}(this),r.revert()}},width:{get:function(){return n.width},set:function(t){n.width=t,Xr(r,t)}},name:{get:function(){return n.name},set:function(t){n.name=t,s&&(s.innerHTML=n.name)}},closed:{get:function(){return n.closed},set:function(e){n.closed=e,n.closed?dr.addClass(r.__ul,t.CLASS_CLOSED):dr.removeClass(r.__ul,t.CLASS_CLOSED),this.onResize(),r.__closeButton&&(r.__closeButton.innerHTML=e?t.TEXT_OPEN:t.TEXT_CLOSED)}},load:{get:function(){return n.load}},useLocalStorage:{get:function(){return o},set:function(t){Lr&&(o=t,t?dr.bind(window,"unload",a):dr.unbind(window,"unload",a),localStorage.setItem(Wr(r,"isLocal"),t))}}}),Ze.isUndefined(n.parent)){if(this.closed=n.closed||!1,dr.addClass(this.domElement,t.CLASS_MAIN),dr.makeSelectable(this.domElement,!1),Lr&&o){r.useLocalStorage=!0;var l=localStorage.getItem(Wr(this,"gui"));l&&(n.load=JSON.parse(l))}this.__closeButton=document.createElement("div"),this.__closeButton.innerHTML=t.TEXT_CLOSED,dr.addClass(this.__closeButton,t.CLASS_CLOSE_BUTTON),n.closeOnTop?(dr.addClass(this.__closeButton,t.CLASS_CLOSE_TOP),this.domElement.insertBefore(this.__closeButton,this.domElement.childNodes[0])):(dr.addClass(this.__closeButton,t.CLASS_CLOSE_BOTTOM),this.domElement.appendChild(this.__closeButton)),dr.bind(this.__closeButton,"click",(function(){r.closed=!r.closed}))}else{void 0===n.closed&&(n.closed=!0);var u=document.createTextNode(n.name);dr.addClass(u,"controller-name"),s=jr(r,u);dr.addClass(this.__ul,t.CLASS_CLOSED),dr.addClass(s,"title"),dr.bind(s,"click",(function(t){return t.preventDefault(),r.closed=!r.closed,!1})),n.closed||(this.closed=!1)}n.autoPlace&&(Ze.isUndefined(n.parent)&&(Dr&&(Rr=document.createElement("div"),dr.addClass(Rr,"dg"),dr.addClass(Rr,t.CLASS_AUTO_PLACE_CONTAINER),document.body.appendChild(Rr),Dr=!1),Rr.appendChild(this.domElement),dr.addClass(this.domElement,t.CLASS_AUTO_PLACE)),this.parent||Xr(r,n.width)),this.__resizeHandler=function(){r.onResizeDebounced()},dr.bind(window,"resize",this.__resizeHandler),dr.bind(this.__ul,"webkitTransitionEnd",this.__resizeHandler),dr.bind(this.__ul,"transitionend",this.__resizeHandler),dr.bind(this.__ul,"oTransitionEnd",this.__resizeHandler),this.onResize(),n.resizable&&Qr(this),a=function(){Lr&&"true"===localStorage.getItem(Wr(r,"isLocal"))&&localStorage.setItem(Wr(r,"gui"),JSON.stringify(r.getSaveObject()))},this.saveToLocalStorageIfPossible=a,n.parent||((i=r.getRoot()).width+=1,Ze.defer((function(){i.width-=1})))};function jr(t,e,r){var n=document.createElement("li");return e&&n.appendChild(e),r?t.__ul.insertBefore(n,r):t.__ul.appendChild(n),t.onResize(),n}function Vr(t){dr.unbind(window,"resize",t.__resizeHandler),t.saveToLocalStorageIfPossible&&dr.unbind(window,"unload",t.saveToLocalStorageIfPossible)}function Nr(t,e){var r=t.__preset_select[t.__preset_select.selectedIndex];r.innerHTML=e?r.value+"*":r.value}function Ur(t,e){var r=t.getRoot(),n=r.__rememberedObjects.indexOf(e.object);if(-1!==n){var i=r.__rememberedObjectIndecesToControllers[n];if(void 0===i&&(i={},r.__rememberedObjectIndecesToControllers[n]=i),i[e.property]=e,r.load&&r.load.remembered){var o=r.load.remembered,a=void 0;if(o[t.preset])a=o[t.preset];else{if(!o.Default)return;a=o.Default}if(a[n]&&void 0!==a[n][e.property]){var s=a[n][e.property];e.initialValue=s,e.setValue(s)}}}}function Gr(t,e,r,n){if(void 0===e[r])throw new Error('Object "'+e+'" has no property "'+r+'"');var i=void 0;if(n.color)i=new Cr(e,r);else{var o=[e,r].concat(n.factoryArgs);i=zr.apply(t,o)}n.before instanceof ur&&(n.before=n.before.__li),Ur(t,i),dr.addClass(i.domElement,"c");var a=document.createElement("span");dr.addClass(a,"property-name"),a.innerHTML=i.property;var s=document.createElement("div");s.appendChild(a),s.appendChild(i.domElement);var l=jr(t,s,n.before);return dr.addClass(l,Br.CLASS_CONTROLLER_ROW),i instanceof Cr?dr.addClass(l,"color"):dr.addClass(l,tr(i.getValue())),function(t,e,r){if(r.__li=e,r.__gui=t,Ze.extend(r,{options:function(e){if(arguments.length>1){var n=r.__li.nextElementSibling;return r.remove(),Gr(t,r.object,r.property,{before:n,factoryArgs:[Ze.toArray(arguments)]})}if(Ze.isArray(e)||Ze.isObject(e)){var i=r.__li.nextElementSibling;return r.remove(),Gr(t,r.object,r.property,{before:i,factoryArgs:[e]})}},name:function(t){return r.__li.firstElementChild.firstElementChild.innerHTML=t,r},listen:function(){return r.__gui.listen(r),r},remove:function(){return r.__gui.remove(r),r}}),r instanceof _r){var n=new br(r.object,r.property,{min:r.__min,max:r.__max,step:r.__step});Ze.each(["updateDisplay","onChange","onFinishChange","step","min","max"],(function(t){var e=r[t],i=n[t];r[t]=n[t]=function(){var t=Array.prototype.slice.call(arguments);return i.apply(n,t),e.apply(r,t)}})),dr.addClass(e,"has-slider"),r.domElement.insertBefore(n.domElement,r.domElement.firstElementChild)}else if(r instanceof br){var i=function(e){if(Ze.isNumber(r.__min)&&Ze.isNumber(r.__max)){var n=r.__li.firstElementChild.firstElementChild.innerHTML,i=r.__gui.__listening.indexOf(r)>-1;r.remove();var o=Gr(t,r.object,r.property,{before:r.__li.nextElementSibling,factoryArgs:[r.__min,r.__max,r.__step]});return o.name(n),i&&o.listen(),o}return e};r.min=Ze.compose(i,r.min),r.max=Ze.compose(i,r.max)}else r instanceof pr?(dr.bind(e,"click",(function(){dr.fakeEvent(r.__checkbox,"click")})),dr.bind(r.__checkbox,"click",(function(t){t.stopPropagation()}))):r instanceof wr?(dr.bind(e,"click",(function(){dr.fakeEvent(r.__button,"click")})),dr.bind(e,"mouseover",(function(){dr.addClass(r.__button,"hover")})),dr.bind(e,"mouseout",(function(){dr.removeClass(r.__button,"hover")}))):r instanceof Cr&&(dr.addClass(e,"color"),r.updateDisplay=Ze.compose((function(t){return e.style.borderLeftColor=r.__color.toString(),t}),r.updateDisplay),r.updateDisplay());r.setValue=Ze.compose((function(e){return t.getRoot().__preset_select&&r.isModified()&&Nr(t.getRoot(),!0),e}),r.setValue)}(t,l,i),t.__controllers.push(i),i}function Wr(t,e){return document.location.href+"."+e}function qr(t,e,r){var n=document.createElement("option");n.innerHTML=e,n.value=e,t.__preset_select.appendChild(n),r&&(t.__preset_select.selectedIndex=t.__preset_select.length-1)}function Hr(t,e){e.style.display=t.useLocalStorage?"block":"none"}function Zr(t){var e=t.__save_row=document.createElement("li");dr.addClass(t.domElement,"has-save"),t.__ul.insertBefore(e,t.__ul.firstChild),dr.addClass(e,"save-row");var r=document.createElement("span");r.innerHTML="&nbsp;",dr.addClass(r,"button gears");var n=document.createElement("span");n.innerHTML="Save",dr.addClass(n,"button"),dr.addClass(n,"save");var i=document.createElement("span");i.innerHTML="New",dr.addClass(i,"button"),dr.addClass(i,"save-as");var o=document.createElement("span");o.innerHTML="Revert",dr.addClass(o,"button"),dr.addClass(o,"revert");var a=t.__preset_select=document.createElement("select");if(t.load&&t.load.remembered?Ze.each(t.load.remembered,(function(e,r){qr(t,r,r===t.preset)})):qr(t,Pr,!1),dr.bind(a,"change",(function(){for(var e=0;e<t.__preset_select.length;e++)t.__preset_select[e].innerHTML=t.__preset_select[e].value;t.preset=this.value})),e.appendChild(a),e.appendChild(r),e.appendChild(n),e.appendChild(i),e.appendChild(o),Lr){var s=document.getElementById("dg-local-explain"),l=document.getElementById("dg-local-storage");document.getElementById("dg-save-locally").style.display="block","true"===localStorage.getItem(Wr(0,"isLocal"))&&l.setAttribute("checked","checked"),Hr(t,s),dr.bind(l,"change",(function(){t.useLocalStorage=!t.useLocalStorage,Hr(t,s)}))}var u=document.getElementById("dg-new-constructor");dr.bind(u,"keydown",(function(t){!t.metaKey||67!==t.which&&67!==t.keyCode||Tr.hide()})),dr.bind(r,"click",(function(){u.innerHTML=JSON.stringify(t.getSaveObject(),void 0,2),Tr.show(),u.focus(),u.select()})),dr.bind(n,"click",(function(){t.save()})),dr.bind(i,"click",(function(){var e=prompt("Enter a new preset name.");e&&t.saveAs(e)})),dr.bind(o,"click",(function(){t.revert()}))}function Qr(t){var e=void 0;function r(r){return r.preventDefault(),t.width+=e-r.clientX,t.onResize(),e=r.clientX,!1}function n(){dr.removeClass(t.__closeButton,Br.CLASS_DRAG),dr.unbind(window,"mousemove",r),dr.unbind(window,"mouseup",n)}function i(i){return i.preventDefault(),e=i.clientX,dr.addClass(t.__closeButton,Br.CLASS_DRAG),dr.bind(window,"mousemove",r),dr.bind(window,"mouseup",n),!1}t.__resize_handle=document.createElement("div"),Ze.extend(t.__resize_handle.style,{width:"6px",marginLeft:"-3px",height:"200px",cursor:"ew-resize",position:"absolute"}),dr.bind(t.__resize_handle,"mousedown",i),dr.bind(t.__closeButton,"mousedown",i),t.domElement.insertBefore(t.__resize_handle,t.domElement.firstElementChild)}function Xr(t,e){t.domElement.style.width=e+"px",t.__save_row&&t.autoPlace&&(t.__save_row.style.width=e+"px"),t.__closeButton&&(t.__closeButton.style.width=e+"px")}function Yr(t,e){var r={};return Ze.each(t.__rememberedObjects,(function(n,i){var o={},a=t.__rememberedObjectIndecesToControllers[i];Ze.each(a,(function(t,r){o[r]=e?t.initialValue:t.getValue()})),r[i]=o})),r}function Jr(t){0!==t.length&&Or.call(window,(function(){Jr(t)})),Ze.each(t,(function(t){t.updateDisplay()}))}Br.toggleHide=function(){Ir=!Ir,Ze.each(Fr,(function(t){t.domElement.style.display=Ir?"none":""}))},Br.CLASS_AUTO_PLACE="a",Br.CLASS_AUTO_PLACE_CONTAINER="ac",Br.CLASS_MAIN="main",Br.CLASS_CONTROLLER_ROW="cr",Br.CLASS_TOO_TALL="taller-than-window",Br.CLASS_CLOSED="closed",Br.CLASS_CLOSE_BUTTON="close-button",Br.CLASS_CLOSE_TOP="close-top",Br.CLASS_CLOSE_BOTTOM="close-bottom",Br.CLASS_DRAG="drag",Br.DEFAULT_WIDTH=245,Br.TEXT_CLOSED="Close Controls",Br.TEXT_OPEN="Open Controls",Br._keydownHandler=function(t){"text"===document.activeElement.type||72!==t.which&&72!==t.keyCode||Br.toggleHide()},dr.bind(window,"keydown",Br._keydownHandler,!1),Ze.extend(Br.prototype,{add:function(t,e){return Gr(this,t,e,{factoryArgs:Array.prototype.slice.call(arguments,2)})},addColor:function(t,e){return Gr(this,t,e,{color:!0})},remove:function(t){this.__ul.removeChild(t.__li),this.__controllers.splice(this.__controllers.indexOf(t),1);var e=this;Ze.defer((function(){e.onResize()}))},destroy:function(){if(this.parent)throw new Error("Only the root GUI should be removed with .destroy(). For subfolders, use gui.removeFolder(folder) instead.");this.autoPlace&&Rr.removeChild(this.domElement);var t=this;Ze.each(this.__folders,(function(e){t.removeFolder(e)})),dr.unbind(window,"keydown",Br._keydownHandler,!1),Vr(this)},addFolder:function(t){if(void 0!==this.__folders[t])throw new Error('You already have a folder in this GUI by the name "'+t+'"');var e={name:t,parent:this};e.autoPlace=this.autoPlace,this.load&&this.load.folders&&this.load.folders[t]&&(e.closed=this.load.folders[t].closed,e.load=this.load.folders[t]);var r=new Br(e);this.__folders[t]=r;var n=jr(this,r.domElement);return dr.addClass(n,"folder"),r},removeFolder:function(t){this.__ul.removeChild(t.domElement.parentElement),delete this.__folders[t.name],this.load&&this.load.folders&&this.load.folders[t.name]&&delete this.load.folders[t.name],Vr(t);var e=this;Ze.each(t.__folders,(function(e){t.removeFolder(e)})),Ze.defer((function(){e.onResize()}))},open:function(){this.closed=!1},close:function(){this.closed=!0},hide:function(){this.domElement.style.display="none"},show:function(){this.domElement.style.display=""},onResize:function(){var t=this.getRoot();if(t.scrollable){var e=dr.getOffset(t.__ul).top,r=0;Ze.each(t.__ul.childNodes,(function(e){t.autoPlace&&e===t.__save_row||(r+=dr.getHeight(e))})),window.innerHeight-e-20<r?(dr.addClass(t.domElement,Br.CLASS_TOO_TALL),t.__ul.style.height=window.innerHeight-e-20+"px"):(dr.removeClass(t.domElement,Br.CLASS_TOO_TALL),t.__ul.style.height="auto")}t.__resize_handle&&Ze.defer((function(){t.__resize_handle.style.height=t.__ul.offsetHeight+"px"})),t.__closeButton&&(t.__closeButton.style.width=t.width+"px")},onResizeDebounced:Ze.debounce((function(){this.onResize()}),50),remember:function(){if(Ze.isUndefined(Tr)&&((Tr=new Er).domElement.innerHTML=Mr),this.parent)throw new Error("You can only call remember on a top level GUI.");var t=this;Ze.each(Array.prototype.slice.call(arguments),(function(e){0===t.__rememberedObjects.length&&Zr(t),-1===t.__rememberedObjects.indexOf(e)&&t.__rememberedObjects.push(e)})),this.autoPlace&&Xr(this,this.width)},getRoot:function(){for(var t=this;t.parent;)t=t.parent;return t},getSaveObject:function(){var t=this.load;return t.closed=this.closed,this.__rememberedObjects.length>0&&(t.preset=this.preset,t.remembered||(t.remembered={}),t.remembered[this.preset]=Yr(this)),t.folders={},Ze.each(this.__folders,(function(e,r){t.folders[r]=e.getSaveObject()})),t},save:function(){this.load.remembered||(this.load.remembered={}),this.load.remembered[this.preset]=Yr(this),Nr(this,!1),this.saveToLocalStorageIfPossible()},saveAs:function(t){this.load.remembered||(this.load.remembered={},this.load.remembered.Default=Yr(this,!0)),this.load.remembered[t]=Yr(this),this.preset=t,qr(this,t,!0),this.saveToLocalStorageIfPossible()},revert:function(t){Ze.each(this.__controllers,(function(e){this.getRoot().load.remembered?Ur(t||this.getRoot(),e):e.setValue(e.initialValue),e.__onFinishChange&&e.__onFinishChange.call(e,e.getValue())}),this),Ze.each(this.__folders,(function(t){t.revert(t)})),t||Nr(this.getRoot(),!1)},listen:function(t){var e=0===this.__listening.length;this.__listening.push(t),e&&Jr(this.__listening)},updateDisplay:function(){Ze.each(this.__controllers,(function(t){t.updateDisplay()})),Ze.each(this.__folders,(function(t){t.updateDisplay()}))}});var Kr={color:{Color:ar,math:$e,interpret:Je},controllers:{Controller:ur,BooleanController:pr,OptionController:mr,StringController:vr,NumberController:yr,NumberControllerBox:br,NumberControllerSlider:_r,FunctionController:wr,ColorController:Cr},dom:{dom:dr},gui:{GUI:Br},GUI:Br};const{abs:$r,cos:tn,sin:en,acos:rn,atan2:nn,sqrt:on,pow:an}=Math;function sn(t){return t<0?-an(-t,1/3):an(t,1/3)}const ln=Math.PI,un=2*ln,cn=ln/2,fn=Number.MAX_SAFE_INTEGER||9007199254740991,hn=Number.MIN_SAFE_INTEGER||-9007199254740991,dn={x:0,y:0,z:0},pn={Tvalues:[-.06405689286260563,.06405689286260563,-.1911188674736163,.1911188674736163,-.3150426796961634,.3150426796961634,-.4337935076260451,.4337935076260451,-.5454214713888396,.5454214713888396,-.6480936519369755,.6480936519369755,-.7401241915785544,.7401241915785544,-.820001985973903,.820001985973903,-.8864155270044011,.8864155270044011,-.9382745520027328,.9382745520027328,-.9747285559713095,.9747285559713095,-.9951872199970213,.9951872199970213],Cvalues:[.12793819534675216,.12793819534675216,.1258374563468283,.1258374563468283,.12167047292780339,.12167047292780339,.1155056680537256,.1155056680537256,.10744427011596563,.10744427011596563,.09761865210411388,.09761865210411388,.08619016153195327,.08619016153195327,.0733464814110803,.0733464814110803,.05929858491543678,.05929858491543678,.04427743881741981,.04427743881741981,.028531388628933663,.028531388628933663,.0123412297999872,.0123412297999872],arcfn:function(t,e){const r=e(t);let n=r.x*r.x+r.y*r.y;return void 0!==r.z&&(n+=r.z*r.z),on(n)},compute:function(t,e,r){if(0===t)return e[0].t=0,e[0];const n=e.length-1;if(1===t)return e[n].t=1,e[n];const i=1-t;let o=e;if(0===n)return e[0].t=t,e[0];if(1===n){const e={x:i*o[0].x+t*o[1].x,y:i*o[0].y+t*o[1].y,t:t};return r&&(e.z=i*o[0].z+t*o[1].z),e}if(n<4){let e,a,s,l=i*i,u=t*t,c=0;2===n?(o=[o[0],o[1],o[2],dn],e=l,a=i*t*2,s=u):3===n&&(e=l*i,a=l*t*3,s=i*u*3,c=t*u);const f={x:e*o[0].x+a*o[1].x+s*o[2].x+c*o[3].x,y:e*o[0].y+a*o[1].y+s*o[2].y+c*o[3].y,t:t};return r&&(f.z=e*o[0].z+a*o[1].z+s*o[2].z+c*o[3].z),f}const a=JSON.parse(JSON.stringify(e));for(;a.length>1;){for(let e=0;e<a.length-1;e++)a[e]={x:a[e].x+(a[e+1].x-a[e].x)*t,y:a[e].y+(a[e+1].y-a[e].y)*t},void 0!==a[e].z&&(a[e]=a[e].z+(a[e+1].z-a[e].z)*t);a.splice(a.length-1,1)}return a[0].t=t,a[0]},computeWithRatios:function(t,e,r,n){const i=1-t,o=r,a=e;let s,l=o[0],u=o[1],c=o[2],f=o[3];return l*=i,u*=t,2===a.length?(s=l+u,{x:(l*a[0].x+u*a[1].x)/s,y:(l*a[0].y+u*a[1].y)/s,z:!!n&&(l*a[0].z+u*a[1].z)/s,t:t}):(l*=i,u*=2*i,c*=t*t,3===a.length?(s=l+u+c,{x:(l*a[0].x+u*a[1].x+c*a[2].x)/s,y:(l*a[0].y+u*a[1].y+c*a[2].y)/s,z:!!n&&(l*a[0].z+u*a[1].z+c*a[2].z)/s,t:t}):(l*=i,u*=1.5*i,c*=3*i,f*=t*t*t,4===a.length?(s=l+u+c+f,{x:(l*a[0].x+u*a[1].x+c*a[2].x+f*a[3].x)/s,y:(l*a[0].y+u*a[1].y+c*a[2].y+f*a[3].y)/s,z:!!n&&(l*a[0].z+u*a[1].z+c*a[2].z+f*a[3].z)/s,t:t}):void 0))},derive:function(t,e){const r=[];for(let n=t,i=n.length,o=i-1;i>1;i--,o--){const t=[];for(let r,i=0;i<o;i++)r={x:o*(n[i+1].x-n[i].x),y:o*(n[i+1].y-n[i].y)},e&&(r.z=o*(n[i+1].z-n[i].z)),t.push(r);r.push(t),n=t}return r},between:function(t,e,r){return e<=t&&t<=r||pn.approximately(t,e)||pn.approximately(t,r)},approximately:function(t,e,r){return $r(t-e)<=(r||1e-6)},length:function(t){const e=pn.Tvalues.length;let r=0;for(let n,i=0;i<e;i++)n=.5*pn.Tvalues[i]+.5,r+=pn.Cvalues[i]*pn.arcfn(n,t);return.5*r},map:function(t,e,r,n,i){return n+(i-n)*((t-e)/(r-e))},lerp:function(t,e,r){const n={x:e.x+t*(r.x-e.x),y:e.y+t*(r.y-e.y)};return void 0!==e.z&&void 0!==r.z&&(n.z=e.z+t*(r.z-e.z)),n},pointToString:function(t){let e=t.x+"/"+t.y;return void 0!==t.z&&(e+="/"+t.z),e},pointsToString:function(t){return"["+t.map(pn.pointToString).join(", ")+"]"},copy:function(t){return JSON.parse(JSON.stringify(t))},angle:function(t,e,r){const n=e.x-t.x,i=e.y-t.y,o=r.x-t.x,a=r.y-t.y;return nn(n*a-i*o,n*o+i*a)},round:function(t,e){const r=""+t,n=r.indexOf(".");return parseFloat(r.substring(0,n+1+e))},dist:function(t,e){const r=t.x-e.x,n=t.y-e.y;return on(r*r+n*n)},closest:function(t,e){let r,n,i=an(2,63);return t.forEach((function(t,o){n=pn.dist(e,t),n<i&&(i=n,r=o)})),{mdist:i,mpos:r}},abcratio:function(t,e){if(2!==e&&3!==e)return!1;if(void 0===t)t=.5;else if(0===t||1===t)return t;const r=an(t,e)+an(1-t,e);return $r((r-1)/r)},projectionratio:function(t,e){if(2!==e&&3!==e)return!1;if(void 0===t)t=.5;else if(0===t||1===t)return t;const r=an(1-t,e);return r/(an(t,e)+r)},lli8:function(t,e,r,n,i,o,a,s){const l=(t-r)*(o-s)-(e-n)*(i-a);return 0!=l&&{x:((t*n-e*r)*(i-a)-(t-r)*(i*s-o*a))/l,y:((t*n-e*r)*(o-s)-(e-n)*(i*s-o*a))/l}},lli4:function(t,e,r,n){const i=t.x,o=t.y,a=e.x,s=e.y,l=r.x,u=r.y,c=n.x,f=n.y;return pn.lli8(i,o,a,s,l,u,c,f)},lli:function(t,e){return pn.lli4(t,t.c,e,e.c)},makeline:function(t,e){const r=t.x,n=t.y,i=e.x,o=e.y,a=(i-r)/3,s=(o-n)/3;return new Sn(r,n,r+a,n+s,r+2*a,n+2*s,i,o)},findbbox:function(t){let e=fn,r=fn,n=hn,i=hn;return t.forEach((function(t){const o=t.bbox();e>o.x.min&&(e=o.x.min),r>o.y.min&&(r=o.y.min),n<o.x.max&&(n=o.x.max),i<o.y.max&&(i=o.y.max)})),{x:{min:e,mid:(e+n)/2,max:n,size:n-e},y:{min:r,mid:(r+i)/2,max:i,size:i-r}}},shapeintersections:function(t,e,r,n,i){if(!pn.bboxoverlap(e,n))return[];const o=[],a=[t.startcap,t.forward,t.back,t.endcap],s=[r.startcap,r.forward,r.back,r.endcap];return a.forEach((function(e){e.virtual||s.forEach((function(n){if(n.virtual)return;const a=e.intersects(n,i);a.length>0&&(a.c1=e,a.c2=n,a.s1=t,a.s2=r,o.push(a))}))})),o},makeshape:function(t,e,r){const n=e.points.length,i=t.points.length,o=pn.makeline(e.points[n-1],t.points[0]),a=pn.makeline(t.points[i-1],e.points[0]),s={startcap:o,forward:t,back:e,endcap:a,bbox:pn.findbbox([o,t,e,a]),intersections:function(t){return pn.shapeintersections(s,s.bbox,t,t.bbox,r)}};return s},getminmax:function(t,e,r){if(!r)return{min:0,max:0};let n,i,o=fn,a=hn;-1===r.indexOf(0)&&(r=[0].concat(r)),-1===r.indexOf(1)&&r.push(1);for(let s=0,l=r.length;s<l;s++)n=r[s],i=t.get(n),i[e]<o&&(o=i[e]),i[e]>a&&(a=i[e]);return{min:o,mid:(o+a)/2,max:a,size:a-o}},align:function(t,e){const r=e.p1.x,n=e.p1.y,i=-nn(e.p2.y-n,e.p2.x-r);return t.map((function(t){return{x:(t.x-r)*tn(i)-(t.y-n)*en(i),y:(t.x-r)*en(i)+(t.y-n)*tn(i)}}))},roots:function(t,e){e=e||{p1:{x:0,y:0},p2:{x:1,y:0}};const r=t.length-1,n=pn.align(t,e),i=function(t){return 0<=t&&t<=1};if(2===r){const t=n[0].y,e=n[1].y,r=n[2].y,o=t-2*e+r;if(0!==o){const n=-on(e*e-t*r),a=-t+e;return[-(n+a)/o,-(-n+a)/o].filter(i)}return e!==r&&0===o?[(2*e-r)/(2*e-2*r)].filter(i):[]}const o=n[0].y,a=n[1].y,s=n[2].y;let l=3*a-o-3*s+n[3].y,u=3*o-6*a+3*s,c=-3*o+3*a,f=o;if(pn.approximately(l,0)){if(pn.approximately(u,0))return pn.approximately(c,0)?[]:[-f/c].filter(i);const t=on(c*c-4*u*f),e=2*u;return[(t-c)/e,(-c-t)/e].filter(i)}u/=l,c/=l,f/=l;const h=(3*c-u*u)/3,d=h/3,p=(2*u*u*u-9*u*c+27*f)/27,m=p/2,v=m*m+d*d*d;let g,y,b,x,_;if(v<0){const t=-h/3,e=on(t*t*t),r=-p/(2*e),n=rn(r<-1?-1:r>1?1:r),o=2*sn(e);return b=o*tn(n/3)-u/3,x=o*tn((n+un)/3)-u/3,_=o*tn((n+2*un)/3)-u/3,[b,x,_].filter(i)}if(0===v)return g=m<0?sn(-m):-sn(m),b=2*g-u/3,x=-g-u/3,[b,x].filter(i);{const t=on(v);return g=sn(-m+t),y=sn(m+t),[g-y-u/3].filter(i)}},droots:function(t){if(3===t.length){const e=t[0],r=t[1],n=t[2],i=e-2*r+n;if(0!==i){const t=-on(r*r-e*n),o=-e+r;return[-(t+o)/i,-(-t+o)/i]}return r!==n&&0===i?[(2*r-n)/(2*(r-n))]:[]}if(2===t.length){const e=t[0],r=t[1];return e!==r?[e/(e-r)]:[]}return[]},curvature:function(t,e,r,n,i){let o,a,s,l,u=0,c=0;const f=pn.compute(t,e),h=pn.compute(t,r),d=f.x*f.x+f.y*f.y;if(n?(o=on(an(f.y*h.z-h.y*f.z,2)+an(f.z*h.x-h.z*f.x,2)+an(f.x*h.y-h.x*f.y,2)),a=an(d+f.z*f.z,1.5)):(o=f.x*h.y-f.y*h.x,a=an(d,1.5)),0===o||0===a)return{k:0,r:0};if(u=o/a,c=a/o,!i){const i=pn.curvature(t-.001,e,r,n,!0).k,o=pn.curvature(t+.001,e,r,n,!0).k;l=(o-u+(u-i))/2,s=($r(o-u)+$r(u-i))/2}return{k:u,r:c,dk:l,adk:s}},inflections:function(t){if(t.length<4)return[];const e=pn.align(t,{p1:t[0],p2:t.slice(-1)[0]}),r=e[2].x*e[1].y,n=e[3].x*e[1].y,i=e[1].x*e[2].y,o=18*(-3*r+2*n+3*i-e[3].x*e[2].y),a=18*(3*r-n-3*i),s=18*(i-r);if(pn.approximately(o,0)){if(!pn.approximately(a,0)){let t=-s/a;if(0<=t&&t<=1)return[t]}return[]}const l=a*a-4*o*s,u=Math.sqrt(l),c=2*o;return pn.approximately(c,0)?[]:[(u-a)/c,-(a+u)/c].filter((function(t){return 0<=t&&t<=1}))},bboxoverlap:function(t,e){const r=["x","y"],n=r.length;for(let i,o,a,s,l=0;l<n;l++)if(i=r[l],o=t[i].mid,a=e[i].mid,s=(t[i].size+e[i].size)/2,$r(o-a)>=s)return!1;return!0},expandbox:function(t,e){e.x.min<t.x.min&&(t.x.min=e.x.min),e.y.min<t.y.min&&(t.y.min=e.y.min),e.z&&e.z.min<t.z.min&&(t.z.min=e.z.min),e.x.max>t.x.max&&(t.x.max=e.x.max),e.y.max>t.y.max&&(t.y.max=e.y.max),e.z&&e.z.max>t.z.max&&(t.z.max=e.z.max),t.x.mid=(t.x.min+t.x.max)/2,t.y.mid=(t.y.min+t.y.max)/2,t.z&&(t.z.mid=(t.z.min+t.z.max)/2),t.x.size=t.x.max-t.x.min,t.y.size=t.y.max-t.y.min,t.z&&(t.z.size=t.z.max-t.z.min)},pairiteration:function(t,e,r){const n=t.bbox(),i=e.bbox(),o=1e5,a=r||.5;if(n.x.size+n.y.size<a&&i.x.size+i.y.size<a)return[(o*(t._t1+t._t2)/2|0)/o+"/"+(o*(e._t1+e._t2)/2|0)/o];let s=t.split(.5),l=e.split(.5),u=[{left:s.left,right:l.left},{left:s.left,right:l.right},{left:s.right,right:l.right},{left:s.right,right:l.left}];u=u.filter((function(t){return pn.bboxoverlap(t.left.bbox(),t.right.bbox())}));let c=[];return 0===u.length||(u.forEach((function(t){c=c.concat(pn.pairiteration(t.left,t.right,a))})),c=c.filter((function(t,e){return c.indexOf(t)===e}))),c},getccenter:function(t,e,r){const n=e.x-t.x,i=e.y-t.y,o=r.x-e.x,a=r.y-e.y,s=n*tn(cn)-i*en(cn),l=n*en(cn)+i*tn(cn),u=o*tn(cn)-a*en(cn),c=o*en(cn)+a*tn(cn),f=(t.x+e.x)/2,h=(t.y+e.y)/2,d=(e.x+r.x)/2,p=(e.y+r.y)/2,m=f+s,v=h+l,g=d+u,y=p+c,b=pn.lli8(f,h,m,v,d,p,g,y),x=pn.dist(b,t);let _,w=nn(t.y-b.y,t.x-b.x),C=nn(e.y-b.y,e.x-b.x),S=nn(r.y-b.y,r.x-b.x);return w<S?((w>C||C>S)&&(w+=un),w>S&&(_=S,S=w,w=_)):S<C&&C<w?(_=S,S=w,w=_):S+=un,b.s=w,b.e=S,b.r=x,b},numberSort:function(t,e){return t-e}};class mn{constructor(t){this.curves=[],this._3d=!1,t&&(this.curves=t,this._3d=this.curves[0]._3d)}valueOf(){return this.toString()}toString(){return"["+this.curves.map((function(t){return pn.pointsToString(t.points)})).join(", ")+"]"}addCurve(t){this.curves.push(t),this._3d=this._3d||t._3d}length(){return this.curves.map((function(t){return t.length()})).reduce((function(t,e){return t+e}))}curve(t){return this.curves[t]}bbox(){const t=this.curves;for(var e=t[0].bbox(),r=1;r<t.length;r++)pn.expandbox(e,t[r].bbox());return e}offset(t){const e=[];return this.curves.forEach((function(r){e.push(...r.offset(t))})),new mn(e)}}const{abs:vn,min:gn,max:yn,cos:bn,sin:xn,acos:_n,sqrt:wn}=Math,Cn=Math.PI;class Sn{constructor(t){let e=t&&t.forEach?t:Array.from(arguments).slice(),r=!1;if("object"==typeof e[0]){r=e.length;const t=[];e.forEach((function(e){["x","y","z"].forEach((function(r){void 0!==e[r]&&t.push(e[r])}))})),e=t}let n=!1;const i=e.length;if(r){if(r>4){if(1!==arguments.length)throw new Error("Only new Bezier(point[]) is accepted for 4th and higher order curves");n=!0}}else if(6!==i&&8!==i&&9!==i&&12!==i&&1!==arguments.length)throw new Error("Only new Bezier(point[]) is accepted for 4th and higher order curves");const o=this._3d=!n&&(9===i||12===i)||t&&t[0]&&void 0!==t[0].z,a=this.points=[];for(let t=0,r=o?3:2;t<i;t+=r){var s={x:e[t],y:e[t+1]};o&&(s.z=e[t+2]),a.push(s)}const l=this.order=a.length-1,u=this.dims=["x","y"];o&&u.push("z"),this.dimlen=u.length;const c=pn.align(a,{p1:a[0],p2:a[l]});this._linear=!c.some((t=>vn(t.y)>1e-4)),this._lut=[],this._t1=0,this._t2=1,this.update()}static quadraticFromPoints(t,e,r,n){if(void 0===n&&(n=.5),0===n)return new Sn(e,e,r);if(1===n)return new Sn(t,e,e);const i=Sn.getABC(2,t,e,r,n);return new Sn(t,i.A,r)}static cubicFromPoints(t,e,r,n,i){void 0===n&&(n=.5);const o=Sn.getABC(3,t,e,r,n);void 0===i&&(i=pn.dist(e,o.C));const a=i*(1-n)/n,s=pn.dist(t,r),l=(r.x-t.x)/s,u=(r.y-t.y)/s,c=i*l,f=i*u,h=a*l,d=a*u,p=e.x-c,m=e.y-f,v=e.x+h,g=e.y+d,y=o.A,b=y.x+(p-y.x)/(1-n),x=y.y+(m-y.y)/(1-n),_=y.x+(v-y.x)/n,w=y.y+(g-y.y)/n,C={x:t.x+(b-t.x)/n,y:t.y+(x-t.y)/n},S={x:r.x+(_-r.x)/(1-n),y:r.y+(w-r.y)/(1-n)};return new Sn(t,C,S,r)}static getUtils(){return pn}getUtils(){return Sn.getUtils()}static get PolyBezier(){return mn}valueOf(){return this.toString()}toString(){return pn.pointsToString(this.points)}toSVG(){if(this._3d)return!1;const t=this.points,e=["M",t[0].x,t[0].y,2===this.order?"Q":"C"];for(let r=1,n=t.length;r<n;r++)e.push(t[r].x),e.push(t[r].y);return e.join(" ")}setRatios(t){if(t.length!==this.points.length)throw new Error("incorrect number of ratio values");this.ratios=t,this._lut=[]}verify(){const t=this.coordDigest();t!==this._print&&(this._print=t,this.update())}coordDigest(){return this.points.map((function(t,e){return""+e+t.x+t.y+(t.z?t.z:0)})).join("")}update(){this._lut=[],this.dpoints=pn.derive(this.points,this._3d),this.computedirection()}computedirection(){const t=this.points,e=pn.angle(t[0],t[this.order],t[1]);this.clockwise=e>0}length(){return pn.length(this.derivative.bind(this))}static getABC(t=2,e,r,n,i=.5){const o=pn.projectionratio(i,t),a=1-o,s={x:o*e.x+a*n.x,y:o*e.y+a*n.y},l=pn.abcratio(i,t);return{A:{x:r.x+(r.x-s.x)/l,y:r.y+(r.y-s.y)/l},B:r,C:s,S:e,E:n}}getABC(t,e){e=e||this.get(t);let r=this.points[0],n=this.points[this.order];return Sn.getABC(this.order,r,e,n,t)}getLUT(t){if(this.verify(),t=t||100,this._lut.length===t)return this._lut;this._lut=[],t--;for(let e,r,n=0;n<t;n++)r=n/(t-1),e=this.compute(r),e.t=r,this._lut.push(e);return this._lut}on(e,r){r=r||5;const n=this.getLUT(),i=[];for(let t,o=0,a=0;o<n.length;o++)t=n[o],pn.dist(t,e)<r&&(i.push(t),a+=o/n.length);return!!i.length&&(t/=i.length)}project(t){const e=this.getLUT(),r=e.length-1,n=pn.closest(e,t),i=n.mpos,o=(i-1)/r,a=(i+1)/r,s=.1/r;let l,u,c=n.mdist,f=o,h=f;for(c+=1;f<a+s;f+=s)l=this.compute(f),u=pn.dist(t,l),u<c&&(c=u,h=f);return h=h<0?0:h>1?1:h,l=this.compute(h),l.t=h,l.d=c,l}get(t){return this.compute(t)}point(t){return this.points[t]}compute(t){return this.ratios?pn.computeWithRatios(t,this.points,this.ratios,this._3d):pn.compute(t,this.points,this._3d,this.ratios)}raise(){const t=this.points,e=[t[0]],r=t.length;for(let n,i,o=1;o<r;o++)n=t[o],i=t[o-1],e[o]={x:(r-o)/r*n.x+o/r*i.x,y:(r-o)/r*n.y+o/r*i.y};return e[r]=t[r-1],new Sn(e)}derivative(t){return pn.compute(t,this.dpoints[0],this._3d)}dderivative(t){return pn.compute(t,this.dpoints[1],this._3d)}align(){let t=this.points;return new Sn(pn.align(t,{p1:t[0],p2:t[t.length-1]}))}curvature(t){return pn.curvature(t,this.dpoints[0],this.dpoints[1],this._3d)}inflections(){return pn.inflections(this.points)}normal(t){return this._3d?this.__normal3(t):this.__normal2(t)}__normal2(t){const e=this.derivative(t),r=wn(e.x*e.x+e.y*e.y);return{x:-e.y/r,y:e.x/r}}__normal3(t){const e=this.derivative(t),r=this.derivative(t+.01),n=wn(e.x*e.x+e.y*e.y+e.z*e.z),i=wn(r.x*r.x+r.y*r.y+r.z*r.z);e.x/=n,e.y/=n,e.z/=n,r.x/=i,r.y/=i,r.z/=i;const o={x:r.y*e.z-r.z*e.y,y:r.z*e.x-r.x*e.z,z:r.x*e.y-r.y*e.x},a=wn(o.x*o.x+o.y*o.y+o.z*o.z);o.x/=a,o.y/=a,o.z/=a;const s=[o.x*o.x,o.x*o.y-o.z,o.x*o.z+o.y,o.x*o.y+o.z,o.y*o.y,o.y*o.z-o.x,o.x*o.z-o.y,o.y*o.z+o.x,o.z*o.z];return{x:s[0]*e.x+s[1]*e.y+s[2]*e.z,y:s[3]*e.x+s[4]*e.y+s[5]*e.z,z:s[6]*e.x+s[7]*e.y+s[8]*e.z}}hull(t){let e=this.points,r=[],n=[],i=0;for(n[i++]=e[0],n[i++]=e[1],n[i++]=e[2],3===this.order&&(n[i++]=e[3]);e.length>1;){r=[];for(let o,a=0,s=e.length-1;a<s;a++)o=pn.lerp(t,e[a],e[a+1]),n[i++]=o,r.push(o);e=r}return n}split(t,e){if(0===t&&e)return this.split(e).left;if(1===e)return this.split(t).right;const r=this.hull(t),n={left:2===this.order?new Sn([r[0],r[3],r[5]]):new Sn([r[0],r[4],r[7],r[9]]),right:2===this.order?new Sn([r[5],r[4],r[2]]):new Sn([r[9],r[8],r[6],r[3]]),span:r};return n.left._t1=pn.map(0,0,1,this._t1,this._t2),n.left._t2=pn.map(t,0,1,this._t1,this._t2),n.right._t1=pn.map(t,0,1,this._t1,this._t2),n.right._t2=pn.map(1,0,1,this._t1,this._t2),e?(e=pn.map(e,t,1,0,1),n.right.split(e).left):n}extrema(){const t={};let e=[];return this.dims.forEach(function(r){let n=function(t){return t[r]},i=this.dpoints[0].map(n);t[r]=pn.droots(i),3===this.order&&(i=this.dpoints[1].map(n),t[r]=t[r].concat(pn.droots(i))),t[r]=t[r].filter((function(t){return t>=0&&t<=1})),e=e.concat(t[r].sort(pn.numberSort))}.bind(this)),t.values=e.sort(pn.numberSort).filter((function(t,r){return e.indexOf(t)===r})),t}bbox(){const t=this.extrema(),e={};return this.dims.forEach(function(r){e[r]=pn.getminmax(this,r,t[r])}.bind(this)),e}overlaps(t){const e=this.bbox(),r=t.bbox();return pn.bboxoverlap(e,r)}offset(t,e){if(void 0!==e){const r=this.get(t),n=this.normal(t),i={c:r,n:n,x:r.x+n.x*e,y:r.y+n.y*e};return this._3d&&(i.z=r.z+n.z*e),i}if(this._linear){const e=this.normal(0),r=this.points.map((function(r){const n={x:r.x+t*e.x,y:r.y+t*e.y};return r.z&&e.z&&(n.z=r.z+t*e.z),n}));return[new Sn(r)]}return this.reduce().map((function(e){return e._linear?e.offset(t)[0]:e.scale(t)}))}simple(){if(3===this.order){const t=pn.angle(this.points[0],this.points[3],this.points[1]),e=pn.angle(this.points[0],this.points[3],this.points[2]);if(t>0&&e<0||t<0&&e>0)return!1}const t=this.normal(0),e=this.normal(1);let r=t.x*e.x+t.y*e.y;return this._3d&&(r+=t.z*e.z),vn(_n(r))<Cn/3}reduce(){let t,e,r=0,n=0,i=.01,o=[],a=[],s=this.extrema().values;for(-1===s.indexOf(0)&&(s=[0].concat(s)),-1===s.indexOf(1)&&s.push(1),r=s[0],t=1;t<s.length;t++)n=s[t],e=this.split(r,n),e._t1=r,e._t2=n,o.push(e),r=n;return o.forEach((function(t){for(r=0,n=0;n<=1;)for(n=r+i;n<=1.01;n+=i)if(e=t.split(r,n),!e.simple()){if(n-=i,vn(r-n)<i)return[];e=t.split(r,n),e._t1=pn.map(r,0,1,t._t1,t._t2),e._t2=pn.map(n,0,1,t._t1,t._t2),a.push(e),r=n;break}r<1&&(e=t.split(r,1),e._t1=pn.map(r,0,1,t._t1,t._t2),e._t2=t._t2,a.push(e))})),a}scale(t){const e=this.order;let r=!1;if("function"==typeof t&&(r=t),r&&2===e)return this.raise().scale(r);const n=this.clockwise,i=r?r(0):t,o=r?r(1):t,a=[this.offset(0,10),this.offset(1,10)],s=this.points,l=[],u=pn.lli4(a[0],a[0].c,a[1],a[1].c);if(!u)throw new Error("cannot scale this curve. Try reducing it first.");return[0,1].forEach((function(t){const r=l[t*e]=pn.copy(s[t*e]);r.x+=(t?o:i)*a[t].n.x,r.y+=(t?o:i)*a[t].n.y})),r?([0,1].forEach((function(i){if(2!==e||!i){var o=s[i+1],a={x:o.x-u.x,y:o.y-u.y},c=r?r((i+1)/e):t;r&&!n&&(c=-c);var f=wn(a.x*a.x+a.y*a.y);a.x/=f,a.y/=f,l[i+1]={x:o.x+c*a.x,y:o.y+c*a.y}}})),new Sn(l)):([0,1].forEach((t=>{if(2===e&&t)return;const r=l[t*e],n=this.derivative(t),i={x:r.x+n.x,y:r.y+n.y};l[t+1]=pn.lli4(r,i,u,s[t+1])})),new Sn(l))}outline(t,e,r,n){e=void 0===e?t:e;const i=this.reduce(),o=i.length,a=[];let s,l=[],u=0,c=this.length();const f=void 0!==r&&void 0!==n;function h(t,e,r,n,i){return function(o){const a=n/r,s=(n+i)/r,l=e-t;return pn.map(o,0,1,t+a*l,t+s*l)}}i.forEach((function(i){const o=i.length();f?(a.push(i.scale(h(t,r,c,u,o))),l.push(i.scale(h(-e,-n,c,u,o)))):(a.push(i.scale(t)),l.push(i.scale(-e))),u+=o})),l=l.map((function(t){return s=t.points,s[3]?t.points=[s[3],s[2],s[1],s[0]]:t.points=[s[2],s[1],s[0]],t})).reverse();const d=a[0].points[0],p=a[o-1].points[a[o-1].points.length-1],m=l[o-1].points[l[o-1].points.length-1],v=l[0].points[0],g=pn.makeline(m,d),y=pn.makeline(p,v),b=[g].concat(a).concat([y]).concat(l);return b.length,new mn(b)}outlineshapes(t,e,r){e=e||t;const n=this.outline(t,e).curves,i=[];for(let t=1,e=n.length;t<e/2;t++){const o=pn.makeshape(n[t],n[e-t],r);o.startcap.virtual=t>1,o.endcap.virtual=t<e/2-1,i.push(o)}return i}intersects(t,e){return t?t.p1&&t.p2?this.lineIntersects(t):(t instanceof Sn&&(t=t.reduce()),this.curveintersects(this.reduce(),t,e)):this.selfintersects(e)}lineIntersects(t){const e=gn(t.p1.x,t.p2.x),r=gn(t.p1.y,t.p2.y),n=yn(t.p1.x,t.p2.x),i=yn(t.p1.y,t.p2.y);return pn.roots(this.points,t).filter((t=>{var o=this.get(t);return pn.between(o.x,e,n)&&pn.between(o.y,r,i)}))}selfintersects(t){const e=this.reduce(),r=e.length-2,n=[];for(let i,o,a,s=0;s<r;s++)o=e.slice(s,s+1),a=e.slice(s+2),i=this.curveintersects(o,a,t),n.push(...i);return n}curveintersects(t,e,r){const n=[];t.forEach((function(t){e.forEach((function(e){t.overlaps(e)&&n.push({left:t,right:e})}))}));let i=[];return n.forEach((function(t){const e=pn.pairiteration(t.left,t.right,r);e.length>0&&(i=i.concat(e))})),i}arcs(t){return t=t||.5,this._iterate(t,[])}_error(t,e,r,n){const i=(n-r)/4,o=this.get(r+i),a=this.get(n-i),s=pn.dist(t,e),l=pn.dist(t,o),u=pn.dist(t,a);return vn(l-s)+vn(u-s)}_iterate(t,e){let r,n=0,i=1;do{r=0,i=1;let o,a,s,l,u,c=this.get(n),f=!1,h=!1,d=i,p=1;do{if(h=f,l=s,d=(n+i)/2,o=this.get(d),a=this.get(i),s=pn.getccenter(c,o,a),s.interval={start:n,end:i},f=this._error(s,c,n,i)<=t,u=h&&!f,u||(p=i),f){if(i>=1){if(s.interval.end=p=1,l=s,i>1){let t={x:s.x+s.r*bn(s.e),y:s.y+s.r*xn(s.e)};s.e+=pn.angle({x:s.x,y:s.y},t,this.get(1))}break}i+=(i-n)/2}else i=d}while(!u&&r++<100);if(r>=100)break;l=l||s,e.push(l),n=p}while(i<1);return e}}var kn=Object.freeze({__proto__:null,Bezier:Sn});return r((function(t,e){t.exports=function(t,e,r,n){function i(t){return t&&"object"==typeof t&&"default"in t?t:{default:t}}function o(t){if(t&&t.u)return t;var e=Object.create(null);return t&&Object.keys(t).forEach((function(r){if("default"!==r){var n=Object.getOwnPropertyDescriptor(t,r);Object.defineProperty(e,r,n.get?n:{h:!0,get:function(){return t[r]}})}})),e.default=t,Object.freeze(e)}var a=i(t),s=o(r),l=function(t,e){return(l=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var r in e)e.hasOwnProperty(r)&&(t[r]=e[r])})(t,e)};function u(t,e){function r(){this.constructor=t}l(t,e),t.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)}var c=function(){return(c=Object.assign||function(t){for(var e,r=1,n=arguments.length;r<n;r++)for(var i in e=arguments[r])Object.prototype.hasOwnProperty.call(e,i)&&(t[i]=e[i]);return t}).apply(this,arguments)};function f(){for(var t=0,e=0,r=arguments.length;e<r;e++)t+=arguments[e].length;var n=Array(t),i=0;for(e=0;e<r;e++)for(var o=arguments[e],a=0,s=o.length;a<s;a++,i++)n[i]=o[a];return n}var h={v:{zooms:[2,20],zIndex:10,visible:!0,opacity:1,cullface:"back",shininess:30,hasSide:!0,depth:!0,acceptLight:!0},style:{topColor:{defaultValue:"rgba(200,200,200,1)",type:"color",render:"attribute"},bottomColor:{defaultValue:"rgba(200,200,200,1)",type:"color",render:"attribute"},sideTopColor:{defaultValue:"#ffffff",type:"color",render:"attribute"},sideBottomColor:{defaultValue:"#fff",type:"color",render:"attribute"},borderWidth:{defaultValue:10,type:"number",render:"attribute"},borderColor:{defaultValue:"rgba(250,250,250,1)",type:"color",render:"attribute"},altitude:{defaultValue:0,type:"number",render:"attribute"},height:{defaultValue:0,type:"number",render:"attribute"},texture:{defaultValue:!1,type:"image",render:"uniform"},textureSize:{defaultValue:[10,3],type:"array",render:"attribute"}}},d={v:{zooms:[2,20],zIndex:10,visible:!0,opacity:1,depth:!1},style:{color:{defaultValue:"rgba(200,200,200,1)",type:"color",render:"attribute"},borderWidth:{defaultValue:0,type:"number",render:"attribute"},borderColor:{defaultValue:"rgba(250,250,250,1)",type:"color",render:"attribute"},lineWidth:{defaultValue:20,type:"number",render:"attribute"},dashArray:{defaultValue:[1,0,1,0],type:"array",render:"attribute"},altitude:{defaultValue:0,type:"number",render:"attribute"}}},p={v:{zooms:[2,20],zIndex:10,visible:!0,opacity:1},style:{lineWidth:{defaultValue:1,type:"number",render:"attribute"},headColor:{defaultValue:"rgba(0, 0, 0, 0.75)",type:"color",render:"attribute"},trailColor:{defaultValue:"rgba(0, 0, 0, 0.25)",type:"color",render:"attribute"},altitude:{defaultValue:0,type:"number",render:"uniform"},interval:{defaultValue:1,type:"number",render:"uniform"},duration:{defaultValue:2e3,type:"number",render:"uniform"}}},m={v:{zooms:[2,20],zIndex:10,visible:!0,opacity:1,depth:!1},style:{size:{defaultValue:[20,20],type:"array",render:"attribute"},rotation:{defaultValue:0,type:"number",render:"attribute"},color:{defaultValue:"rgba(200,200,200,1)",type:"color",render:"attribute"},altitude:{defaultValue:0,type:"number",render:"attribute"},borderWidth:{defaultValue:0,type:"number",render:"attribute"},borderColor:{defaultValue:"rgba(250,250,250,1)",type:"color",render:"attribute"},texture:{defaultValue:null,type:"image",render:"uniform"},unit:{defaultValue:"px",type:"string",render:"uniform"},animate:{defaultValue:!1,type:"boolean",render:"uniform"},duration:{defaultValue:0,type:"number",render:"uniform"}}},v={v:{zooms:[2,20],zIndex:10,visible:!0,opacity:1,depth:!0},style:{radius:{defaultValue:20,type:"number",render:"attribute"},value:{defaultValue:10,type:"number",render:"attribute"},gradient:{defaultValue:{.5:"blue",.65:"rgb(117,211,248)",.7:"rgb(0, 255, 0)",.9:"#ffea00",1:"red"},type:"object",render:"uniform"},opacity:{defaultValue:[0,1],type:"array",render:"uniform"},height:{defaultValue:100,type:"number",render:"uniform"},heightBezier:{defaultValue:[.4,.2,.4,.8],type:"array",render:"uniform"},max:{defaultValue:null,type:"number",render:"uniform"},min:{defaultValue:null,type:"number",render:"uniform"},unit:{defaultValue:"px",type:"string",render:"uniform"}}},g={v:{zooms:[2,20],zIndex:10,visible:!0,opacity:1,blend:"normal"},style:{unit:{defaultValue:"px",type:"string",render:"uniform"},radius:{defaultValue:20,type:"number",render:"attribute"},borderWidth:{defaultValue:10,type:"number",render:"attribute"},blurWidth:{defaultValue:-1,type:"number",render:"attribute"},color:{defaultValue:"rgba(255,255,255,1)",type:"color",render:"attribute"},borderColor:{defaultValue:"rgba(255,255,255,1)",type:"color",render:"attribute"}}},y={v:{zooms:[2,20],zIndex:10,visible:!0,opacity:1},style:{unit:{defaultValue:"px",type:"string",render:"uniform"},icon:{defaultValue:"",type:"string",render:"attribute"},iconSize:{defaultValue:[20,20],type:"array",render:"attribute"},rotation:{defaultValue:0,type:"number",render:"attribute"},opacity:{defaultValue:1,type:"number",render:"attribute"}}},b={v:{zooms:[2,20],zIndex:10,visible:!0,opacity:1,depth:!0,acceptLight:!0,shininess:30,hasSide:!0,cullface:"back"},style:{unit:{defaultValue:"meter",type:"string",render:"uniform"},radius:{defaultValue:1e3,type:"number",render:"uniform"},gap:{defaultValue:0,type:"number",render:"uniform"},altitude:{defaultValue:0,type:"number",render:"attribute"},height:{defaultValue:0,type:"number",render:"attribute"},topColor:{defaultValue:"#ffffff",type:"color",render:"attribute"},sideTopColor:{defaultValue:"#ffffff",type:"color",render:"attribute"},sideBottomColor:{defaultValue:"#fff",type:"color",render:"attribute"},bottomColor:{defaultValue:"rgba(253,0,255,0)",type:"color",render:"attribute"}}},x={v:{zooms:[2,20],zIndex:10,visible:!0,opacity:1,depth:!0,acceptLight:!0,shininess:30,hasSide:!0,cullface:"back"},style:{unit:{defaultValue:"meter",type:"string",render:"uniform"},radius:{defaultValue:1e3,type:"number",render:"uniform"},gap:{defaultValue:0,type:"number",render:"uniform"},altitude:{defaultValue:0,type:"number",render:"attribute"},height:{defaultValue:0,type:"number",render:"attribute"},topColor:{defaultValue:"#ffffff",type:"color",render:"attribute"},bottomColor:{defaultValue:"rgba(253,0,255,0)",type:"color",render:"attribute"},sideTopColor:{defaultValue:"#ffffff",type:"color",render:"attribute"},sideBottomColor:{defaultValue:"#fff",type:"color",render:"attribute"}}},_={v:{zooms:[2,20],zIndex:10,visible:!0,opacity:1},style:{lineColors:{defaultValue:["rgba(10,10,10,1)"],type:"colors",render:"attribute"},height:{defaultValue:function(t,e){return.7*e.distance},type:"number",render:"attribute"},smoothSteps:{defaultValue:50,type:"number",render:"uniform"}}},w={v:{zooms:[2,20],zIndex:10,visible:!0,opacity:1,depth:!0},style:{maxHeightScale:{defaultValue:.5,type:"number",render:"uniform"},lineColors:{defaultValue:["rgb(255,228,105)","rgb(255,164,105)","rgba(1, 34, 249,1)"],type:"colors",render:"attribute"},dash:{defaultValue:[10,0,10,0],type:"array",render:"attribute"},lineWidth:{defaultValue:[10,20],type:"number",render:"attribute"},height:{defaultValue:0,type:"number",render:"attribute"},speed:{defaultValue:10,type:"number",render:"attribute"},smoothSteps:{defaultValue:50,type:"number",render:"uniform"},headColor:{defaultValue:"rgba(255, 255, 0, 1)",type:"color",render:"uniform"},trailColor:{defaultValue:"rgba(255, 255, 0, 0)",type:"color",render:"uniform"},unit:{defaultValue:"px",type:"number",render:"uniform"},flowLength:{defaultValue:10,type:"number",render:"uniform"}}},C={v:{zooms:[2,20],zIndex:10,visible:!0,opacity:1,depth:!1,acceptLight:!0,shininess:30,hasSide:!0,cullface:"back"},style:{unit:{defaultValue:"px",type:"string",render:"uniform"},sideNumber:{defaultValue:3,type:"number",render:"uniform"},rotation:{defaultValue:0,type:"number",render:"attribute"},radius:{defaultValue:20,type:"number",render:"attribute"},altitude:{defaultValue:0,type:"number",render:"attribute"},height:{defaultValue:100,type:"number",render:"attribute"},topColor:{defaultValue:"#ffffff",type:"color",render:"attribute"},sideTopColor:{defaultValue:"#ffffff",type:"color",render:"attribute"},sideBottomColor:{defaultValue:"#fff",type:"color",render:"attribute"}}},S=Object.freeze({__proto__:null,polygon:h,line:d,pulseline:p,scatter:m,heatmap:v,grid:b,hexagon:x,link:_,point:g,icon:y,pulselink:w,p:{v:{zooms:[2,20],zIndex:10,visible:!0,opacity:1,depth:!0},style:{source:{defaultValue:"",type:"string",render:"attribute"},rotation:{defaultValue:{x:0,y:0,z:0},type:"object",render:"attribute"},scale:{defaultValue:{x:0,y:0,z:0},type:"object",render:"attribute"},translate:{defaultValue:{x:0,y:0,z:0},type:"object",render:"attribute"}}},prism:C}),k=t.Util.CommonUtil.pushArray,A=function(r){function n(){return null!==r&&r.apply(this,arguments)||this}return u(n,r),n.getInstance=function(){return this.m},n.prototype.buildGeometry=function(){},n.prototype.buildStyle=function(e,r){for(var n=h.style,i=[],o=0;o<e.length;o++)if(e[o].features&&e[o].features.polygons){for(var a=e[o].features.polygons,s=t.StyleInstance.parse(a,r,n),l={},u=0;u<a.length;u++)if(s)for(var c in s.attributes){var f=s.attributes[c];l[c]||(l[c]=[]),f[u].length>0?k(l[c],f[u]):l[c][l[c].length]=f[u]}i.push({attributes:l,uniforms:s.uniforms,g:s.g})}return i},n.prototype.fusion=function(e,r,n,i){if(!this.regl)return[];if(!n.loca)return[];var o=[];i=i||this.buildStyle(e,r);for(var a=n.loca.customCoords,s=0;s<e.length;s++){var l=e[s];if(l.features&&l.features.polygons&&i[s]){for(var u=l.features.polygons,c=i[s],f={index:[],vertex:[],color:[],normal:[],uv:[],textureSize:[],pickColor:[],topOrBottom:[]},h=[],d=[],p=[],m=[],v=0;v<u.length;v++){var g=u[v],y=n.colorPick.add(g),b=g.coordinates;if("MultiPolygon"===g.type)for(var x=0,_=b.length;x<_;x++){var w=b[x],C=this.triangles(w,{style:c,index:v,pickColor:y},a,n.hasSide),S=f.vertex.length;h.push(S),d.push(S+C.S.C),p.push(S+C.S.top),t.Geometry.mergeTriangles(f,C),k(f.color,C.color),k(f.pickColor,C.pickColor),k(f.normal,C.normal),k(f.uv,C.uv),k(f.textureSize,C.textureSize),k(f.topOrBottom,C.topOrBottom)}else C=this.triangles(b,{style:c,index:v,pickColor:y},a,n.hasSide),S=f.vertex.length,h.push(S),d.push(S+C.S.C),p.push(S+C.S.top),t.Geometry.mergeTriangles(f,C),k(f.color,C.color),k(f.pickColor,C.pickColor),k(f.normal,C.normal),k(f.uv,C.uv),k(f.textureSize,C.textureSize),k(f.topOrBottom,C.topOrBottom);m[v]=f.vertex.length}o[s]={id:l.id,attributes:{position:{buffer:this.regl.buffer(f.vertex),offset:0,P:12,_:!1,divisor:0},topOrBottom:{buffer:this.regl.buffer(f.topOrBottom),offset:0,P:4,_:!1,divisor:0},color:{buffer:this.regl.buffer(f.color),offset:0,P:16,_:!1,divisor:0},pickColor:{buffer:this.regl.buffer(f.pickColor),offset:0,P:16,_:!1,divisor:0},normal:{buffer:this.regl.buffer(f.normal),offset:0,P:12,_:!1,divisor:0},uv:{buffer:this.regl.buffer(f.uv),offset:0,P:8,_:!1,divisor:0},textureSize:{buffer:this.regl.buffer(f.textureSize),offset:0,P:8,_:!1,divisor:0},index:this.regl.elements({primitive:"triangles",type:"uint32",data:f.index})},uniforms:c.uniforms,g:c.g,k:{S:{bottom:h,C:d,top:p,W:m},origin:{position:f.vertex,color:f.color}}}}}return o},n.prototype.triangles=function(r,n,i,o){void 0===o&&(o=!0);for(var a=t.Geometry.triangle(r),s=a.vertex,l=a.index,u=[],c=n.index,f=n.pickColor,h=n.style.attributes,d=h.height,p=h.altitude,m=h.topColor,v=h.bottomColor,g=h.sideTopColor,y=h.sideBottomColor,b=h.textureSize,x=p[c],_=d[c]+x,w=4*c,C=m.slice(w,w+4),S=v.slice(w,w+4),A=y.slice(w,w+4),M=g.slice(w,w+4),z=b&&b.slice(2*c,2*c+2),O=[],E=[],P=[],L=[],T=[],D=[],R=[],I=[],F=[],B=[],j=[],V=[],N=[],U=[],G=[],W=[],q=[],H=[],Z=[],Q=0,X=s.length;Q<X;Q+=2){var Y=s[Q],J=s[Q+1],K=i.lngLatToCoord([Y,J]);this.addVertex(O,R,L,B,[K[0],K[1],_],C,[0,0,1],[-1,-1],N,[-1,-1],W,f),H.push(1),o&&(this.addVertex(E,I,T,j,[K[0],K[1],x],S,[0,0,-1],[-1,-1],U,[-1,-1],W,f),q.push(0))}if(o)for(var $=this.isClock(r[0]),tt=!1,et=(Q=0,r.length);Q<et;Q++){var rt=r[Q];Q>0&&(tt=!0);for(var nt=!1,it=0,ot=0,at=rt.length;ot<at-1;ot++){var st=rt[ot],lt=rt[ot+1],ut=(K=nt||i.lngLatToCoord(st),i.lngLatToCoord(lt)),ct=P.length/3,ft=u.length,ht=this.getNormal(K,ut,!!(+$^+tt)),dt=e.vec2.distance(K,ut);Z.push(0,1,0,1),this.addVertex(P,F,D,V,[K[0],K[1],x],A,ht,[it,0],G,z,W,f),this.addVertex(P,F,D,V,[K[0],K[1],_],M,ht,[it,_],G,z,W,f),this.addVertex(P,F,D,V,[ut[0],ut[1],x],A,ht,[it+dt,0],G,z,W,f),this.addVertex(P,F,D,V,[ut[0],ut[1],_],M,ht,[it+dt,_],G,z,W,f),$?(u[ft]=ct,u[ft+1]=ct+3,u[ft+2]=ct+1,u[ft+3]=ct,u[ft+4]=ct+2,u[ft+5]=ct+3):(u[ft]=ct,u[ft+1]=ct+1,u[ft+2]=ct+3,u[ft+3]=ct,u[ft+4]=ct+3,u[ft+5]=ct+2),nt=ut,it+=dt}}var pt=E.length,mt=t.Geometry.mergeTriangles({vertex:E,index:l.slice(0)},{vertex:P,index:u},3);return t.Geometry.mergeTriangles(mt,{vertex:O,index:l.reverse()},3),k(I,F),k(I,R),k(T,D),k(T,L),k(j,V),k(j,B),k(U,G),k(U,N),k(q,Z),k(q,H),{vertex:mt.vertex,index:mt.index,color:I,normal:T,uv:j,textureSize:U,pickColor:W,topOrBottom:q,S:{C:pt,top:pt+P.length}}},n.prototype.addVertex=function(t,e,r,n,i,o,a,s,l,u,c,f){void 0===s&&(s=[-1,-1]);var h=t.length,d=e.length,p=n.length;if(t[h]=i[0],t[h+1]=i[1],t[h+2]=i[2],e[d]=o[0],e[d+1]=o[1],e[d+2]=o[2],e[d+3]=o[3],c&&f){var m=c.length;c[m]=f[0],c[m+1]=f[1],c[m+2]=f[2],c[m+3]=f[3]}r[h]=a[0],r[h+1]=a[1],r[h+2]=a[2],n[p]=s[0],n[p+1]=s[1],l&&u&&(l[p]=u[0],l[p+1]=u[1])},n.prototype.getNormal=function(t,r,n){void 0===n&&(n=!1);var i=e.vec3.create();e.vec3.set(i,r[0]-t[0],r[1]-t[1],0),n&&e.vec3.set(i,t[0]-r[0],t[1]-r[1],0);var o=e.vec3.create();e.vec3.set(o,0,0,1);var a=e.vec3.create();return e.vec3.normalize(a,e.vec3.cross(a,i,o))},n.prototype.isClock=function(t){for(var e=t.length,r=0,n=0;n<e;n++){var i=t[n],o=t[(n+1)%e];r+=(o[0]-i[0])*(o[1]+i[1])}return r>0},n.prototype.updateStyle=function(t,e){for(var r=0,n=t.length;r<n;r++){for(var i=t[r],o=e[r].attributes,a=o.altitude,s=o.height,l=o.topColor,u=o.bottomColor,c=o.sideTopColor,f=o.sideBottomColor,h=o.textureSize,d=i.k.origin,p=d.position,m=d.color,v=i.k.S,g=v.top,y=v.bottom,b=v.C,x=v.W,_=new Float32Array(m.length/2),w=0,C=0,S=0,k=p.length;S<k;S+=3){var A=S/3*4,M=void 0,z=[-1,-1];S>=x[w]&&w++;var O=4*w;S>=y[C+1]&&C++,S<b[C]?(M=u,p[S+2]=a[w]):S>=b[C]&&S<g[C]?((S-b[C])/3%2==0?(M=f,p[S+2]=a[w]):(M=c,p[S+2]=s[w]+a[w]),z=h.slice(2*w,2*w+2)):(M=l,p[S+2]=s[w]+a[w]),m[A]=M[O],m[A+1]=M[O+1],m[A+2]=M[O+2],m[A+3]=M[O+3],_[A/2]=z[0],_[A/2+1]=z[1]}i.attributes.position.buffer({data:p}),i.attributes.color.buffer({data:m}),i.attributes.textureSize.buffer({data:_}),i.uniforms=e[r].uniforms}},n.prototype.updateFrame=function(t){},n.prototype.destroy=function(){this.regl=null},n.m=new n,n}(t.GeometryFusion),M=A.getInstance(),z={vertex:"\n        precision highp float;\n\n        attribute vec3 position;\n        attribute vec3 normal;\n        attribute vec4 color;\n        attribute vec2 uv;\n        attribute vec2 textureSize;\n        attribute float topOrBottom;\n\n        varying vec3 vNormal;\n        varying vec4 vColor;\n        varying vec3 vPosition;\n        varying vec2 vUv;\n        varying vec2 vTexSize;\n        "+t.ColorGLSL.getColorShader().vertex+"\n\n        uniform mat4 mvp;\n        uniform float heightScale;\n        uniform float altitudeScale;\n\n        void main() {\n            vec3 realPos = position;\n            if(topOrBottom == 0.0) {\n                realPos = vec3(position.xy, position.z * altitudeScale);\n            }\n            if(topOrBottom == 1.0) {\n                realPos = vec3(position.xy, position.z * heightScale);\n            }\n            vColor = color;\n            vNormal = normal;\n            vPosition = realPos;\n            vUv = vec2(uv.x / textureSize.x, uv.y / textureSize.y);\n            vTexSize = textureSize;\n            gl_Position = mvp * vec4(realPos, 1.0);\n            "+t.ColorGLSL.getColorShader().mainVert+"\n        }\n    ",fragment:"\n        precision highp float;\n        varying vec4 vColor;\n\n        // 如果需要光照，这两个变量是必须的\n        varying vec3 vNormal;\n        varying vec3 vPosition;\n        varying vec2 vUv;\n        varying vec2 vTexSize;\n\n        uniform float opacity;\n        uniform sampler2D texture;\n        uniform bool useTexture;\n\n        "+t.Light.getLightShader()+"\n        "+t.ColorGLSL.getColorShader().fragment+"\n\n        void main() {\n            if(useTexture && vTexSize.x >= 0.0) {\n                gl_FragColor = texture2D(texture, vUv);\n            } else {\n                gl_FragColor = vColor;\n            }\n            if(acceptLight) {\n                gl_FragColor.rgb = lightColor(gl_FragColor.rgb);\n            }\n\n            gl_FragColor.a *= opacity;\n\n            "+t.ColorGLSL.getColorShader().mainFrag+"\n        }\n    "},O=function(t,e){var r=Math.log2(t),n=Math.log2(e);return r===~~r&&n===~~n?{mipmap:"nice",min:"nearest mipmap linear",mag:"linear",wrapS:"repeat",wrapT:"repeat"}:{min:"linear",mag:"linear"}},E=function(t){return void 0===t&&(t="normal"),{normal:{srcRGB:"src alpha",srcAlpha:1,dstRGB:"one minus src alpha",dstAlpha:"one minus src alpha"},lighter:{srcRGB:1,srcAlpha:1,dstRGB:1,dstAlpha:1},darker:{srcRGB:"dst color",srcAlpha:1,dstRGB:"dst color",dstAlpha:1},zero:{srcRGB:0,srcAlpha:0,dstRGB:0,dstAlpha:0}}[t]},P=function(){function e(t){this.regl=t,this.createCmd()}return e.getInstance=function(){return this.m},e.prototype.createCmd=function(){if(this.regl){var e=this.regl;this.D=e({frag:z.fragment,vert:z.vertex,attributes:c({position:e.prop("position"),color:e.prop("color"),normal:e.prop("normal"),uv:e.prop("uv"),textureSize:e.prop("textureSize"),topOrBottom:e.prop("topOrBottom")},t.ColorGLSL.getColor(e).attribute),uniforms:c(c({mvp:e.prop("mvp"),opacity:e.prop("opacity"),texture:e.prop("texture"),useTexture:e.prop("useTexture"),heightScale:e.prop("heightScale"),altitudeScale:e.prop("altitudeScale")},t.Light.getLights(e)),t.ColorGLSL.getColor(e).uniform),blend:{enable:!0,func:E("normal")},cull:{enable:e.prop("cullEnable"),face:e.prop("cullface")},frontFace:"cw",depth:{enable:e.prop("depth"),func:"lequal"},colorMask:e.prop("colorMask"),elements:e.prop("index")})}},e.prototype.render=function(t){if(this.regl){this.D||this.createCmd();for(var e=t.meshes,r=t.mvp,n=t.V,i=t.opacity,o=t.cullface,a=t.cameraPosition,s=t.shininess,l=t.acceptLight,u=t.texture,f=t.useTexture,h=t.depth,d=t.M,p="none"!==o,m="front"===o?"front":"back",v=d.height,g=d.altitude,y=0;y<e.length;y++){var b=e[y].attributes;this.D(c(c(c(c({},b),{mvp:r,colorMask:[!1,!1,!1,!1],opacity:i}),n),{cullEnable:p,cullface:m,depth:h,cameraPosition:a,shininess:s,acceptLight:l,texture:u,useTexture:f,isPick:!1,heightScale:v,altitudeScale:g}))}for(y=0;y<e.length;y++)b=e[y].attributes,this.D(c(c(c(c({},b),{mvp:r,colorMask:[!0,!0,!0,!0],opacity:i}),n),{cullEnable:p,cullface:m,cameraPosition:a,depth:h,shininess:s,acceptLight:l,texture:u,useTexture:f,isPick:!1,heightScale:v,altitudeScale:g}))}},e.prototype.pickRender=function(t){var e=this;if(this.regl){this.D||this.createCmd();var r=t.meshes,n=t.mvp,i=t.V,o=t.opacity,a=t.cullface,s=t.cameraPosition,l=t.depth,u=t.texture,f=t.pickFbo,h=t.pickPos,d=t.M,p="none"!==a,m="front"===a?"front":"back",v=d.height,g=d.altitude;f&&h&&f.use((function(){e.regl.clear({color:[0,0,0,0],depth:1});for(var t=0;t<r.length;t++){var a=r[t].attributes;e.D(c(c(c(c({},a),{mvp:n,colorMask:[!0,!0,!0,!0],opacity:o}),i),{cullEnable:p,cullface:m,cameraPosition:s,depth:l,shininess:1,acceptLight:!1,texture:u,useTexture:!1,isPick:!0,heightScale:v,altitudeScale:g}))}}))}},e.prototype.destroy=function(){this.regl=null,this.D=null},e.m=new e,e}();P.getInstance();var L=O,T=t.Util.CommonUtil.pushArray,D=function(t){function e(e){var r=t.call(this,e)||this;r.CLASS_NAME="Polygon",r.styleOptions={},r.fusion=new A,r.B=new P,r.R=!0,r._animateLayerState={altitude:1,height:1};var n=h.v;return r.zooms=void 0===e.zooms?n.zooms:e.zooms,r.visible=void 0===e.visible?n.visible:e.visible,r.zIndex=void 0===e.zIndex?n.zIndex:e.zIndex,r.opacity=void 0===e.opacity?n.opacity:e.opacity,r.depth=void 0===e.depth?n.depth:e.depth,r.shininess=void 0===e.shininess?n.shininess:e.shininess,r.acceptLight=void 0===e.acceptLight?n.acceptLight:e.acceptLight,r.cullface=e.cullface||n.cullface,r.hasSide=void 0===e.hasSide?n.hasSide:e.hasSide,r.createGLLayer(e),r.buryPoint.record(r.CLASS_NAME),r}return u(e,t),e.prototype.receiveDataset=function(t){this.dataset=t,this.setStyle(this.styleOptions),this.onAdd()},e.prototype.setStyle=function(e){if(t.prototype.setStyle.call(this,e),this.F=null,this.dataset=this.source.getDataset(),this.dataset&&this.dataset.length>0&&this.meshes){var r=this.filterDataset().didFusion,n=this.fusion.buildStyle(this.dataset,this.styleOptions);this.fusion.updateStyle(r,n),this.loca&&this.loca.requestRender()}},e.prototype.createRenderer=function(){t.prototype.createRenderer.call(this),this.loca&&this.loca.regl&&!this.B.regl&&(this.B.regl=this.loca.regl,this.loca.rendererManager.addRenderer(this.B))},e.prototype.beforeRender=function(){if(t.prototype.beforeRender.call(this),!this.fusion.regl&&this.loca&&(this.fusion.regl=this.loca.regl,this.loca.fusionManager.addFusion(this.fusion)),this.createRenderer(),this.source&&(this.dataset=this.source.getDataset()),this.fusion&&this.dataset&&this.dataset.length>0){var e=this.filterDataset(),r=e.willFusion,n=e.didFusion;this.fusion.updateFrame(n),r.length>0&&(this.meshes=T(n,this.fusion.fusion(r,this.styleOptions,this)))}var i=this.meshes[0]&&this.meshes[0].uniforms.texture;this.L(i)},e.prototype.render=function(){var t;if(this.loca&&this.loca.regl){this.loca.regl._refresh();var e=this.loca.customCoords.getCameraParams().position,r=null===(t=this.loca)||void 0===t?void 0:t.customCoords.getMVPMatrix(),n=this.loca.getLights();this.B&&this.meshes.length>0&&this.B.render({meshes:this.meshes,mvp:r,V:n,shininess:this.shininess,acceptLight:this.acceptLight,opacity:this._getOpacity(),depth:this.depth,cullface:this.cullface,cameraPosition:e,texture:this.F,useTexture:this.R,M:this._animateLayerState})}},e.prototype.pickRender=function(){var t;if(this.loca&&this.loca.regl){this.loca.regl._refresh();var e=null===(t=this.loca)||void 0===t?void 0:t.customCoords.getMVPMatrix(),r=this.loca.customCoords.getCameraParams().position;this.B&&this.F&&this.B.pickRender({meshes:this.meshes,mvp:e,V:this.loca.getLights(),shininess:this.shininess,acceptLight:this.acceptLight,opacity:this._getOpacity(),depth:this.depth,cullface:this.cullface,texture:this.F,pickFbo:this._needPickFrame&&this._pickFbo,pickPos:this._pickPos,cameraPosition:r,M:this._animateLayerState})}},e.prototype.afterRender=function(){},e.prototype.L=function(t){var e=this;if(this.R=!!t,!this.F&&this.loca&&this.loca.regl&&(this.F=this.loca.regl.texture({data:[[[0,255,0,0],[255,0,0,0]],[[0,0,255,0],[255,255,0,0]]],flipY:!0}),t))if("[object String]"===Object.prototype.toString.call(t)){var r=new Image;r.src=t,r.crossOrigin="anonymous",r.onload=function(){e.F=e.loca.regl.texture(c({data:r,flipY:!0},L(r.naturalWidth,r.naturalHeight)))}}else this.F=this.loca.regl.texture(c({data:t,flipY:!0},L(t.width,t.height)))},e}(t.Layer);a.default.PolygonLayer=D;var R=t.Util.CommonUtil.pushArray,I=function(r){function n(){return null!==r&&r.apply(this,arguments)||this}return u(n,r),n.getInstance=function(){return this.m},n.prototype.buildGeometry=function(){},n.prototype.buildStyle=function(e,r){for(var n=d.style,i=[],o=0;o<e.length;o++)if(e[o].features&&e[o].features.lines){for(var a=e[o].features.lines,s=t.StyleInstance.parse(a,r,n),l={},u=0;u<a.length;u++)if(s)for(var c in s.attributes){var f=s.attributes[c];l[c]||(l[c]=[]),f[u].length>0?R(l[c],f[u]):l[c][l[c].length]=f[u]}i.push({attributes:l,uniforms:s.uniforms,g:s.g})}return i},n.prototype.fusion=function(e,r,n,i){if(!this.regl)return[];if(!n.loca)return[];var o=[];i=i||this.buildStyle(e,r);for(var a=n.loca.customCoords,s=0;s<e.length;s++){var l=e[s];if(l.features&&l.features.lines&&i[s]){for(var u=l.features.lines,c=i[s],f={index:[],vertex:[],color:[],normal:[],lineWidth:[],distance:[],dash:[],borderColor:[],borderWidth:[],pickColor:[]},h=[],d=0;d<u.length;d++){var p=u[d],m=p.coordinates,v=n.colorPick.add(p);if("MultiLineString"===p.type)for(var g=0,y=m.length;g<y;g++){var b=m[g],x=this.triangles(b,{style:c,index:d,pickColor:v},a);t.Geometry.mergeTriangles(f,x),R(f.color,x.color),R(f.normal,x.normal),R(f.lineWidth,x.lineWidth),R(f.distance,x.distance),R(f.dash,x.dash),R(f.borderColor,x.borderColor),R(f.pickColor,x.pickColor),R(f.borderWidth,x.borderWidth)}else x=this.triangles(m,{style:c,index:d,pickColor:v},a),t.Geometry.mergeTriangles(f,x),R(f.color,x.color),R(f.normal,x.normal),R(f.lineWidth,x.lineWidth),R(f.distance,x.distance),R(f.dash,x.dash),R(f.pickColor,x.pickColor),R(f.borderColor,x.borderColor),R(f.borderWidth,x.borderWidth);h[d]=f.lineWidth.length}o[s]={id:l.id,attributes:{color:{buffer:this.regl.buffer(f.color),offset:0,P:16,_:!1,divisor:0},dash:{buffer:this.regl.buffer(f.dash),offset:0,P:16,_:!1,divisor:0},position:{buffer:this.regl.buffer(f.vertex),offset:0,P:12,_:!1,divisor:0},normal:{buffer:this.regl.buffer(f.normal),offset:0,P:12,_:!1,divisor:0},lineWidth:{buffer:this.regl.buffer(f.lineWidth),offset:0,P:4,_:!1,divisor:0},borderWidth:{buffer:this.regl.buffer(f.borderWidth),offset:0,P:4,_:!1,divisor:0},borderColor:{buffer:this.regl.buffer(f.borderColor),offset:0,P:16,_:!1,divisor:0},distance:{buffer:this.regl.buffer(f.distance),offset:0,P:8,_:!1,divisor:0},pickColor:{buffer:this.regl.buffer(f.pickColor),offset:0,P:16,_:!1,divisor:0},index:this.regl.elements({primitive:"triangles",type:"uint32",data:f.index})},uniforms:c.uniforms,g:c.g,k:{S:{W:h},origin:{color:f.color,lineWidth:f.lineWidth,borderColor:f.borderColor,borderWidth:f.borderWidth,dash:f.dash}}}}}return o},n.prototype.triangles=function(r,n,i){var o,a,s,l=n.index,u=n.pickColor,c=n.style.attributes,f=c.lineWidth,h=c.color,d=c.dashArray,p=c.borderColor,m=c.borderWidth,v=c.altitude,g=h.slice(4*l,4*l+4),y=d.slice(4*l,4*l+4),b=p.slice(4*l,4*l+4),x=m[l],_=f[l],w=v[l],C={vertex:[],index:[]},S=[],k=[],A=[],M=[],z=[],O=[],E=[],P=[],L=e.vec3.create();e.vec3.set(L,0,0,1);for(var T=0,D=0,I=r.length;D<I-1;D++){var F,B=[],j=[0,1,3,0,3,2],V=o||i.lngLatToCoord(r[D]),N=r[D][2]||w||0,U=a||i.lngLatToCoord(r[D+1]),G=r[D+1][2]||w||0,W=!1,q=!1,H=0;D>0&&(H=k[k.length-1]);var Z=e.vec2.distance(V,U),Q=Math.max(Z,T),X=Q;F=H+Z,D+2<I&&(W=i.lngLatToCoord(r[D+2]),X=Math.max(Z,e.vec2.distance(W,U))),R(k,[Q,H,Q,H,X,F,X,F]);var Y=this.calcNormal(V,U,L),J=[Y[0],Y[1],0],K=[0,0,0],$=[0,0,0],tt=s||{T:Y,angle:Math.PI},et=W?this.calcAngleNormal(V,U,W):{T:Y,angle:Math.PI};0===et.T[0]&&0===et.T[1]&&(et.T[0]=-Y[0],et.T[1]=-Y[1]),K[0]=tt.T[0],K[1]=tt.T[1],$[0]=et.T[0],$[1]=et.T[1];var rt=this.calcAngle(Y,K),nt=this.calcAngle(Y,$);q=rt<Math.PI/2&&nt<Math.PI/2||rt>Math.PI/2&&nt>Math.PI/2,rt<Math.PI/2&&(Y=[-Y[0],-Y[1],0]),nt<Math.PI/2&&(J=[-J[0],-J[1],0]);var it=this.calcWise(K,[-Y[0],-Y[1]])||1,ot=this.calcWise($,[-J[0],-J[1]])||1;if(K[2]=-it*tt.angle,$[2]=-ot*et.angle,this.addVertex({I:B,O:A,N:S,A:E,j:M,U:z,q:O,G:P,vertex:[V[0],V[1],N],color:g,normal:Y,lineWidth:_,dash:y,H:b,Y:x,pickColor:u}),this.addVertex({I:B,O:A,N:S,A:E,j:M,U:z,q:O,G:P,vertex:[V[0],V[1],N],color:g,normal:K,lineWidth:_,dash:y,H:b,Y:x,pickColor:u}),this.addVertex({I:B,O:A,N:S,A:E,j:M,U:z,q:O,G:P,vertex:[U[0],U[1],G],color:g,normal:q?J:$,lineWidth:_,dash:y,H:b,Y:x,pickColor:u}),this.addVertex({I:B,O:A,N:S,A:E,j:M,U:z,q:O,G:P,vertex:[U[0],U[1],G],color:g,normal:q?$:J,lineWidth:_,dash:y,H:b,Y:x,pickColor:u}),W){R(k,[X,F]);var at=this.calcNormal(U,W,L);this.calcAngle(at,$)<Math.PI/2&&(at[0]=-at[0],at[1]=-at[1]),this.addVertex({I:B,O:A,N:S,A:E,j:M,U:z,q:O,G:P,vertex:[U[0],U[1],G],color:g,normal:at,lineWidth:_,dash:y,H:b,Y:x,pickColor:u}),j[6]=2,j[7]=3,j[8]=4}t.Geometry.mergeTriangles(C,{index:j,vertex:B}),o=U,a=W,s=et,T=X}return{index:C.index,vertex:C.vertex,distance:k,normal:S,color:A,lineWidth:E,dash:M,borderColor:z,borderWidth:O,pickColor:P}},n.prototype.addVertex=function(t){var e=t.I,r=t.O,n=t.N,i=t.A,o=t.j,a=t.U,s=t.q,l=t.G,u=t.vertex,c=t.color,f=t.normal,h=t.lineWidth,d=t.dash,p=t.H,m=t.Y,v=t.pickColor,g=e.length,y=r.length,b=n.length;e[g]=u[0],e[g+1]=u[1],e[g+2]=u[2],r[y]=c[0],r[y+1]=c[1],r[y+2]=c[2],r[y+3]=c[3],n[b]=f[0],n[b+1]=f[1],n[b+2]=f[2],i[i.length]=h,o[y]=d[0],o[y+1]=d[1],o[y+2]=d[2],o[y+3]=d[3],a[y]=p[0],a[y+1]=p[1],a[y+2]=p[2],a[y+3]=p[3],l[y]=v[0],l[y+1]=v[1],l[y+2]=v[2],l[y+3]=v[3],s[s.length]=m},n.prototype.calcAngleNormal=function(t,r,n){var i=e.vec2.create();e.vec2.set(i,t[0],t[1]);var o=e.vec2.create();e.vec2.set(o,r[0],r[1]);var a=e.vec2.create();e.vec2.set(a,n[0],n[1]);var s=e.vec2.create();e.vec2.sub(s,i,o),e.vec2.normalize(s,s);var l=e.vec2.create();e.vec2.sub(l,a,o),e.vec2.normalize(l,l);var u=e.vec2.create();return e.vec2.add(u,s,l),e.vec2.normalize(u,u),{T:[u[0],u[1],0],angle:this.calcAngle([s[0],s[1],0],[l[0],l[1],0])}},n.prototype.calcAngle=function(t,r){var n=e.vec3.dot(t,r)/e.vec3.length(t)/e.vec3.length(r);return Math.acos(Math.min(1,n))},n.prototype.calcNormal=function(t,r,n){var i=e.vec3.create(),o=e.vec3.create();e.vec3.set(o,t[0],t[1],0);var a=e.vec3.create();e.vec3.set(a,r[0],r[1],0);var s=e.vec3.create();return e.vec3.sub(s,a,o),e.vec3.cross(i,n,s),e.vec3.normalize(i,i),[i[0],i[1],0]},n.prototype.calcWise=function(t,r){var n=e.vec3.create(),i=e.vec2.fromValues(t[0],t[1]),o=e.vec2.fromValues(r[0],r[1]);return e.vec2.cross(n,i,o),0===n[2]?n[2]:n[2]/Math.abs(n[2])},n.prototype.updateStyle=function(t,e){for(var r=0,n=t.length;r<n;r++){for(var i=t[r],o=e[r].attributes,a=o.color,s=o.lineWidth,l=o.borderColor,u=o.borderWidth,c=o.dashArray,f=i.k.origin,h=f.borderColor,d=f.color,p=f.lineWidth,m=f.borderWidth,v=f.dash,g=i.k.S.W,y=0,b=0,x=p.length;b<x;b++){var _=4*b;b>=g[y]&&y++;var w=4*y;d[_]=a[w],d[_+1]=a[w+1],d[_+2]=a[w+2],d[_+3]=a[w+3],h[_]=l[w],h[_+1]=l[w+1],h[_+2]=l[w+2],h[_+3]=l[w+3],v[_]=c[w],v[_+1]=c[w+1],v[_+2]=c[w+2],v[_+3]=c[w+3],m[b]=u[y],p[b]=s[y]}i.attributes.color.buffer({data:d}),i.attributes.lineWidth.buffer({data:p}),i.attributes.borderColor.buffer({data:h}),i.attributes.borderWidth.buffer({data:m}),i.attributes.dash.buffer({data:v})}},n.prototype.updateFrame=function(t){},n.prototype.destroy=function(){this.regl=null},n.m=new n,n}(t.GeometryFusion);I.getInstance();var F={vertex:"\n        precision highp float;\n        #define PI 3.14159265359\n        attribute vec3 position;\n        attribute vec4 color;\n        attribute vec4 borderColor;\n        attribute vec4 dash;\n        attribute vec3 normal;\n        attribute float lineWidth;\n        attribute float borderWidth;\n        attribute vec2 distance;\n        varying vec4 vColor;\n        varying vec4 vBorderColor;\n        varying vec4 vDash;\n        varying vec2 vNormal;\n        varying float vDist;\n        varying float vWidth;\n        varying float vBorderWidth;\n        uniform mat4 mvp;\n        uniform float resolution;\n        "+t.ColorGLSL.getColorShader().vertex+"\n\n        void main() {\n            vColor = color;\n            vBorderColor = borderColor;\n            vDash = dash;\n            vDist = distance.y; // 距离线起始点的距离\n            float angleLineWidth = (borderWidth + lineWidth / 2.) * resolution;\n            vWidth = lineWidth;\n            vBorderWidth = borderWidth;\n            // 线段的法向量还原\n            vec2 tmpNormal = normal.xy;\n\n            // z 方向不等于 0，说明是拐角向量，z 代表角度，需要对线宽进行计算\n            if(normal.z != 0.0) {\n                angleLineWidth /= sin(abs(normal.z / 2.));\n                angleLineWidth = min(distance.x, angleLineWidth);\n\n                // 拐角处的法向量，需要还原成垂直线段方向的向量\n                // 这样才能将描边计算出来\n                // 旋转角度计算\n                float theta = normal.z / abs(normal.z) * ((PI - abs(normal.z)) / 2.);\n                // 旋转\n                tmpNormal =\n                    mat2(cos(theta), -sin(theta),\n                         sin(theta), cos(theta)) * tmpNormal;\n            }\n            vNormal = normalize(tmpNormal.xy);\n\n            vec3 pos = position + vec3(normal.xy, 0) * angleLineWidth;\n            gl_Position = mvp * vec4(pos, 1.0);\n            "+t.ColorGLSL.getColorShader().mainVert+"\n        }\n    ",fragment:"\n        precision highp float;\n        uniform float resolution;\n        uniform float opacity;\n        varying vec4 vDash;\n        varying vec2 vNormal;\n        varying vec4 vColor;\n        varying float vDist;\n        varying float vWidth;\n        varying float vBorderWidth;\n        varying vec4 vBorderColor;\n        "+t.ColorGLSL.getColorShader().fragment+"\n\n        void main() {\n            float distPixel = vDist / resolution;\n            float offset = mod(distPixel, vDash.r + vDash.g + vDash.b + vDash.a);\n            if(offset > vDash.r && offset < vDash.r + vDash.g) {\n                discard;\n            } else if(offset > vDash.r + vDash.g + vDash.b) {\n                discard;\n            }\n\n            gl_FragColor = vColor;\n\n            if(vBorderWidth > 0. && length(vNormal) > 1. - vBorderWidth / (vWidth / 2. + vBorderWidth)) {\n                gl_FragColor = vBorderColor;\n            }\n            gl_FragColor.a *= opacity;\n            "+t.ColorGLSL.getColorShader().mainFrag+"\n        }\n    "},B=function(){function e(t){this.regl=t,this.createCmd()}return e.getInstance=function(){return this.m},e.prototype.createCmd=function(){if(this.regl){var e=this.regl;this.D=e({frag:F.fragment,vert:F.vertex,attributes:c({position:e.prop("position"),color:e.prop("color"),lineWidth:e.prop("lineWidth"),normal:e.prop("normal"),distance:e.prop("distance"),dash:e.prop("dash"),borderColor:e.prop("borderColor"),borderWidth:e.prop("borderWidth")},t.ColorGLSL.getColor(e).attribute),uniforms:c({mvp:e.prop("mvp"),resolution:e.prop("resolution"),opacity:e.prop("opacity")},t.ColorGLSL.getColor(e).uniform),blend:{enable:!0,func:E()},elements:e.prop("index")})}},e.prototype.render=function(t){var e=t.meshes,r=t.mvp,n=t.resolution,i=t.opacity;if(this.regl){this.D||this.createCmd();for(var o=0;o<e.length;o++){var a=e[o].attributes;this.D(c(c({},a),{mvp:r,resolution:n,opacity:i,isPick:!1}))}}},e.prototype.pickRender=function(t){var e=this,r=t.meshes,n=t.mvp,i=t.resolution,o=t.opacity,a=t.pickFbo,s=t.pickPos;this.regl&&(this.D||this.createCmd(),a&&s&&a.use((function(){e.regl.clear({color:[0,0,0,0],depth:1});for(var t=0;t<r.length;t++){var a=r[t].attributes;e.D(c(c({},a),{mvp:n,resolution:i,opacity:o,isPick:!0}))}})))},e.prototype.destroy=function(){this.regl=null,this.D=null},e.m=new e,e}();B.getInstance();var j=t.Util.CommonUtil.pushArray,V=function(t){function e(e){var r=t.call(this,e)||this;r.CLASS_NAME="Line",r.fusion=new I,r.B=new B,r.depth=!1;var n=d.v;return r.zooms=void 0===e.zooms?n.zooms:e.zooms,r.zIndex=void 0===e.zIndex?n.zIndex:e.zIndex,r.opacity=void 0===e.opacity?n.opacity:e.opacity,r.visible=void 0===e.visible?n.visible:e.visible,r.depth=void 0===e.depth?n.depth:e.depth,r.opacity=void 0===e.opacity?n.opacity:e.opacity,r.visible=void 0===e.visible?n.visible:e.visible,r.zooms=e.visible||n.visible,r.zIndex=void 0===e.zIndex?n.zIndex:e.zIndex,r.createGLLayer(e),r.buryPoint.record(r.CLASS_NAME),r}return u(e,t),e.prototype.receiveDataset=function(t){this.dataset=t,this.setStyle(this.styleOptions),this.onAdd()},e.prototype.setStyle=function(e){if(t.prototype.setStyle.call(this,e),this.dataset=this.source.getDataset(),this.dataset&&this.dataset.length>0&&this.meshes){var r=this.filterDataset().didFusion,n=this.fusion.buildStyle(this.dataset,this.styleOptions);this.fusion.updateStyle(r,n),this.loca&&this.loca.requestRender()}},e.prototype.createRenderer=function(){t.prototype.createRenderer.call(this),this.loca&&this.loca.regl&&!this.B.regl&&(this.B.regl=this.loca.regl,this.loca.rendererManager.addRenderer(this.B))},e.prototype.beforeRender=function(){if(t.prototype.beforeRender.call(this),!this.fusion.regl&&this.loca&&(this.fusion.regl=this.loca.regl,this.loca.fusionManager.addFusion(this.fusion)),this.createRenderer(),this.source&&(this.dataset=this.source.getDataset()),this.fusion){var e=this.filterDataset(),r=e.willFusion,n=e.didFusion;this.fusion.updateFrame(n),r.length>0&&(this.meshes=j(n,this.fusion.fusion(r,this.styleOptions,this)))}},e.prototype.render=function(){var t,e;if(this.loca&&this.loca.regl){this.loca.regl._refresh();var r=null===(t=this.loca)||void 0===t?void 0:t.customCoords.getMVPMatrix(),n=this.projection.getResolution(null===(e=this.loca)||void 0===e?void 0:e.map.getZoom());this.B&&this.meshes.length>0&&this.B.render({meshes:this.meshes,mvp:r,resolution:n,opacity:this._getOpacity()})}},e.prototype.pickRender=function(){var t,e;if(this.loca&&this.loca.regl){this.loca.regl._refresh();var r=null===(t=this.loca)||void 0===t?void 0:t.customCoords.getMVPMatrix(),n=this.projection.getResolution(null===(e=this.loca)||void 0===e?void 0:e.map.getZoom());this.B&&this.B.pickRender({meshes:this.meshes,mvp:r,resolution:n,opacity:this._getOpacity(),pickFbo:this._needPickFrame&&this._pickFbo,pickPos:this._pickPos})}},e.prototype.afterRender=function(){},e}(t.Layer);a.default.LineLayer=V;var N=t.Util.CommonUtil.pushArray,U=t.Util.ColorUtil.colorToArray.bind(t.Util.ColorUtil),G=function(e){function r(){return null!==e&&e.apply(this,arguments)||this}return u(r,e),r.getInstance=function(){return this.m},r.prototype.buildGeometry=function(t,e){void 0===t&&(t=1e3),void 0===e&&(e=1e3);for(var r=[],n=[],i=0;i<t;i++)for(var o=0;o<e;o++){if(o<e-1&&i>=1){var a=6*((i-1)*t+o);r[a]=t*(i-1)+o+1,r[a+1]=t*(i-1)+o,r[a+2]=i*t+o,r[a+3]=t*(i-1)+o+1,r[a+4]=i*t+o,r[a+5]=i*t+1+o}n.push(i*t+o)}return{size:[t,e],index:this.regl.elements({primitive:"triangles",type:"uint32",data:r}),position:{buffer:this.regl.buffer(n),offset:0,P:4,_:!1,divisor:0},texture:this.regl.texture({data:[[[0,255,0,200],[255,0,0,200]],[[0,0,255,200],[255,0,255,200]]],flipY:!0})}},r.prototype.buildStyle=function(e,r){for(var n=v.style,i={attributes:[],uniforms:!1,g:!1},o=0;o<e.length;o++)if(e[o].features&&e[o].features.points){var a=e[o].features.points,s=t.StyleInstance.parse(a,r,n),l={};i.uniforms||(i.uniforms=s.uniforms),i.g||(i.g=s.g);for(var u=0,c=a.length;u<c;u++)if(s)for(var f in s.attributes){var h=s.attributes[f];l[f]||(l[f]=[]),h[u].length>0?N(l[f],h[u]):l[f][l[f].length]=h[u]}i.attributes.push(l)}return i},r.prototype.fusion=function(e,r,n,i){if(!this.regl||!n.loca)return[];for(var o=[],a=(i=i||this.buildStyle(e,r)).attributes,s=n.loca.customCoords,l=[1/0,1/0,-1/0,-1/0],u=0,f=[1/0,-1/0],h=0;h<e.length;h++){var d=e[h];if(d.features&&d.features.points&&a[h]){for(var p=d.features.points,m=a[h],v=[],g={vertex:[],index:[],radius:[],value:[]},y=0;y<p.length;y++){var b,x=p[y],_=x.coordinates,w=+m.radius[y],C=+m.value[y];if("MultiPoint"===x.type)for(var S=0,k=_.length;S<k;S++){var A=[(b=s.lngLatToCoord(_[S]))[0],b[1],0,b[0],b[1],1,b[0],b[1],2,b[0],b[1],3];t.Geometry.mergeTriangles(g,{vertex:A,index:[0,1,2,1,3,2]}),N(g.radius,[w,w,w,w]),N(g.value,[C,C,C,C]),this.calcBbox(l,b),u=Math.max(u,w),f[0]=Math.min(C,f[0]),f[1]=Math.max(C,f[1])}else A=[(b=s.lngLatToCoord(_))[0],b[1],0,b[0],b[1],1,b[0],b[1],2,b[0],b[1],3],t.Geometry.mergeTriangles(g,{vertex:A,index:[0,1,2,1,3,2]}),N(g.radius,[w,w,w,w]),N(g.value,[C,C,C,C]),this.calcBbox(l,b),u=Math.max(u,w),f[0]=Math.min(C,f[0]),f[1]=Math.max(C,f[1]);v[y]=g.radius.length}var M=this.gradient2webgl(i.uniforms.gradient);o[h]={id:d.id,attributes:{position:{buffer:this.regl.buffer(g.vertex),offset:0,P:12,_:!1,divisor:0},radius:{buffer:this.regl.buffer(g.radius),offset:0,P:4,_:!1,divisor:0},value:{buffer:this.regl.buffer(g.value),offset:0,P:4,_:!1,divisor:0},index:this.regl.elements({primitive:"triangles",type:"uint32",data:g.index})},uniforms:c(c({},i.uniforms),{gradient:M.O,alpha:M.alpha,maxRadius:u,dataBBox:l,min:null===i.uniforms.min?f[0]:i.uniforms.min,max:null===i.uniforms.max?f[1]:i.uniforms.max}),g:c(c({},i.g),{count:m.radius.length}),k:{origin:{radius:g.radius,value:g.value},S:{W:v}}}}}return o},r.prototype.updateStyle=function(t,e){for(var r=0,n=t.length;r<n;r++){for(var i=t[r],o=e.attributes[r],a=o.radius,s=o.value,l=i.k.origin,u=l.radius,f=l.value,h=i.k.S.W,d=0,p=0,m=[1/0,-1/0],v=0,g=u.length;v<g;v++)v>=h[d]&&d++,u[v]=a[d],f[v]=s[d],p=Math.max(p,a[d]),m[0]=Math.min(s[d],m[0]),m[1]=Math.max(s[d],m[1]);i.attributes.radius.buffer({data:u}),i.attributes.value.buffer({data:f});var y=this.gradient2webgl(e.uniforms.gradient);i.uniforms=c(c(c({},i.uniforms),e.uniforms),{gradient:y.O,alpha:y.alpha,maxRadius:p,min:null===e.uniforms.min?m[0]:e.uniforms.min,max:null===e.uniforms.max?m[1]:e.uniforms.max})}},r.prototype.updateFrame=function(t){},r.prototype.calcBbox=function(t,e){var r=e[0],n=e[1];t[0]=Math.min(r,t[0]),t[1]=Math.min(n,t[1]),t[2]=Math.max(r,t[2]),t[3]=Math.max(n,t[3])},r.prototype.gradient2webgl=function(t){var e=[],r=[];for(var n in t)t.hasOwnProperty(n)&&e.push({stop:parseFloat(n),color:t[n]});e.sort((function(t,e){return t.stop-e.stop}));var i=[];for(n=0;n<e.length;n+=1){var o=U(e[n].color);r.push(e[n].stop,o[0],o[1],o[2]),i.push(o[3])}return{O:r,alpha:i}},r.prototype.destroy=function(){this.regl=null},r.m=new r,r}(t.GeometryFusion);G.getInstance();var W={vertex:"\n            precision highp float;\n            attribute vec3 position;\n            attribute float value;\n            attribute float radius;\n\n            varying float vValue;\n            varying vec2 vDir;\n            varying float vRadius;\n\n            uniform vec4 bbox;\n            uniform float resolution;\n            uniform float unit; // 0: px; 1: meter;\n            uniform float maxRadius;\n            uniform float radiusScale;\n\n            // 计算方位, xy 是位置, zw 是 方向 坐标\n            vec4 getPosByDirection(vec2 pos, float direction, float r) {\n                vec2 targetPos;\n                vec2 dir;\n\n                targetPos = vec2(pos - r);\n                dir = vec2(-1, -1);\n                if (direction == 1.0) {\n                    targetPos = vec2(pos.x - r, pos.y + r);\n                    dir = vec2(-1, 1);\n                } else if (direction == 2.0) {\n                    targetPos = vec2(pos.x + r, pos.y - r);\n                    dir = vec2(1, -1);\n                } else if (direction == 3.0) {\n                    targetPos = vec2(pos + r);\n                    dir = vec2(1, 1);\n                }\n                return vec4(targetPos, normalize(dir));\n            }\n\n            void main() {\n                float r = radius * radiusScale;\n                float maxR = maxRadius;\n                if(unit == 0.0) {\n                    r *= resolution;\n                    maxR *= resolution;\n                }\n                vec4 b = vec4(bbox.xy - maxR, bbox.zw + maxR);\n                vec2 center = vec2((b.z + b.x) / 2.0, (b.w + b.y) / 2.0);\n                vec2 bboxSize = vec2((b.z - b.x), (b.w - b.y)) / 2.0;\n                vec4 posDir = getPosByDirection(position.xy - center, position.z, r);\n                gl_Position = vec4(posDir.xy / bboxSize, 0, 1);\n                vValue = value;\n                vDir = posDir.zw * sqrt(r * r * 2.0);\n                vRadius = r;\n            }\n        ",fragment:"\n            precision highp float;\n            varying float vValue;\n            varying vec2 vDir;\n            varying float vRadius;\n\n            uniform float max;\n            uniform float min;\n\n            void main() {\n                float len = length(vDir);\n                // gl_FragColor = vec4(1, 0, 0, (vRadius - len) / vRadius);\n                gl_FragColor = vec4(1, 0, 0, (vRadius - len) / vRadius * (vValue - min) / (max - min));\n            }\n        "},q={vertex:"\n            precision highp float;\n            attribute float position;\n\n            varying float vValue;\n            varying vec2 vUv;\n\n            uniform mat4 mvp;\n            uniform float resolution;\n            uniform float height;\n            uniform float unit; // 0: px; 1: meter;\n            uniform vec2 size;\n            uniform vec4 bbox;\n            uniform float maxRadius;\n            uniform vec4 heightBezier;\n            uniform sampler2D texture;\n            uniform float heightScale;\n\n            vec2 bezier(float t, vec2 P0, vec2 P1, vec2 P2, vec2 P3) {\n                float t2 = t * t;\n                float one_minus_t = 1.0 - t;\n                float one_minus_t2 = one_minus_t * one_minus_t;\n                return (P0 * one_minus_t2 * one_minus_t + P1 * 3.0 * t * one_minus_t2 + P2 * 3.0 * t2 * one_minus_t + P3 * t2 * t);\n            }\n\n            vec2 toBezier(float t, vec4 p) {\n                return bezier(t, vec2(0.0, 0.0), vec2(p.x, p.y), vec2(p.z, p.w), vec2(1.0, 1.0));\n            }\n\n            // 计算纹理坐标\n            vec2 calcUV(float index, vec2 size) {\n                float y = floor(index / size.x);\n                float x = mod(index, size.x);\n                return vec2(x / (size.x - 1.0), y / (size.y - 1.0));\n            }\n\n            // 计算顶点坐标\n            vec2 calcVertex(float index, vec2 size, vec4 bbox) {\n                // 根据索引获取经纬度\n                float col = mod(index, size.x);\n                float row = floor(index / size.x);\n                float widthStep = (bbox.b - bbox.r) / (size.x - 1.0);\n                float heightStep = (bbox.a - bbox.g) / (size.y - 1.0);\n                float x = bbox.x + col * widthStep;\n                float y = bbox.y + row * heightStep;\n                return vec2(x, y);\n            }\n\n            void main() {\n                vUv = calcUV(position, size);\n                vec4 color = texture2D(texture, vUv);\n                float h = height * toBezier(color.a, heightBezier).y;\n                float maxR = maxRadius;\n                if(unit == 0.0) {\n                    h *= resolution;\n                    maxR *= resolution;\n                }\n                vec4 b = vec4(bbox.xy - maxR, bbox.zw + maxR);\n                gl_Position = mvp * vec4(calcVertex(position, size, b), h * heightScale, 1);\n            }\n        ",fragment:"\n            precision highp float;\n            varying vec2 vUv;\n            uniform sampler2D texture;\n            uniform float opacity;\n            uniform vec4 gradient[8];\n            uniform vec2 alpha;\n\n            float fade(float low, float high, float value) {\n                if (value < low || value > high) { return 0.0; }\n                return (value-low) / (high-low);\n            }\n\n            // 数值映射函数，为了将 x:0-1 映射到任意一个 [min, max] 区间的值\n            float scaleMap(float min, float max, float x) {\n                if(x == 0.0) {\n                    return x;\n                }\n                if(x < 0.0) {\n                    return min;\n                }\n                if(x > 1.0) {\n                    return max;\n                }\n                float delta = max - min;\n                return min + delta * x;\n            }\n\n            vec4 getColor(float intensity) {\n                vec3 color = vec3(0);\n                float a = 1.0;\n                color = mix(vec3(0, 0, 1), gradient[0].yzw, fade(0.0, gradient[0].x, intensity));\n                for (int gn = 0; gn < 8; gn += 1) {\n                    if (gradient[gn].x >= intensity) {\n                        color = mix(gradient[gn-1].yzw, gradient[gn].yzw, fade(gradient[gn-1].x, gradient[gn].x, intensity));\n                        // 彩虹效果\n                        // color = gradient[gn].yzw;\n                        break;\n                    }\n                }\n                return vec4(color, scaleMap(alpha.x, alpha.y, intensity));\n            }\n\n            void main() {\n                float gray = texture2D(texture, vUv).a;\n                gl_FragColor = getColor(gray);\n                gl_FragColor.a *= opacity;\n            }\n        "},H=function(){function t(t){this.Z=[0,0],this.regl=t,this.createCmd()}return t.getInstance=function(){return this.m},t.prototype.createCmd=function(){if(this.regl){var t=this.regl;this.X=t.framebuffer({width:t._gl.drawingBufferWidth,height:t._gl.drawingBufferHeight,stencil:!1}),this.Z=[this.regl._gl.drawingBufferWidth,this.regl._gl.drawingBufferHeight],this.J=t({framebuffer:t.prop("framebuffer"),frag:W.fragment,vert:W.vertex,attributes:{position:t.prop("position"),value:t.prop("value"),radius:t.prop("radius")},uniforms:{bbox:t.prop("bbox"),unit:t.prop("unit"),resolution:t.prop("resolution"),min:t.prop("min"),max:t.prop("max"),maxRadius:t.prop("maxRadius"),radiusScale:t.prop("radiusScale")},depth:{enable:!1},blend:{enable:!0,func:E()},elements:t.prop("index")}),this.K=t({frag:q.fragment,vert:q.vertex,attributes:{position:t.prop("position")},uniforms:{mvp:t.prop("mvp"),opacity:t.prop("opacity"),texture:t.prop("texture"),bbox:t.prop("bbox"),size:t.prop("size"),height:t.prop("height"),unit:t.prop("unit"),heightBezier:t.prop("heightBezier"),resolution:t.prop("resolution"),maxRadius:t.prop("maxRadius"),gradient:t.prop("gradient"),heightScale:t.prop("heightScale"),alpha:t.prop("alpha")},depth:{enable:t.prop("depth")},blend:{enable:!0,func:E()},cull:{enable:!0,face:"back"},frontFace:"cw",elements:t.prop("index")})}},t.prototype.render=function(t){var e=this,r=t.meshes,n=t.mvp,i=t.resolution,o=t.opacity,a=t.index,s=t.position,l=t.size,u=t.bbox,f=t.depth,h=t.M;if(this.regl){this.J&&this.K||this.createCmd(),this.Z[0]===this.regl._gl.drawingBufferWidth&&this.Z[1]===this.regl._gl.drawingBufferHeight||(this.Z=[this.regl._gl.drawingBufferWidth,this.regl._gl.drawingBufferHeight],this.X({width:this.Z[0],height:this.Z[1]}));for(var d=function(t){var d=r[t],m=d.attributes,v=d.uniforms,g=v.unit,y=v.max,b=v.min,x=v.gradient,_=v.opacity,w=v.heightBezier,C=v.height,S=v.dataBBox,k=v.maxRadius,A=d.g.count,M=p.bboxAnd(u,S);p.X.use((function(){e.regl.clear({color:[0,0,0,0],depth:1}),e.J(c(c({framebuffer:e.X},m),{unit:"px"===g?0:1,resolution:i,max:y,min:b,bbox:M,maxRadius:k,count:A,radiusScale:h.radius}))})),p.K({texture:p.X,heightBezier:w,unit:"px"===g?0:1,height:C,gradient:p.genGradient(x),alpha:_,position:s,index:a,resolution:i,mvp:n,bbox:M,maxRadius:k,size:l,opacity:o,depth:f,heightScale:h.height})},p=this,m=0;m<r.length;m++)d(m)}},t.prototype.bboxAnd=function(t,e){var r=[];return r[0]=Math.max(t[0],e[0]),r[1]=Math.max(t[1],e[1]),r[2]=Math.min(t[2],e[2]),r[3]=Math.min(t[3],e[3]),r},t.prototype.genGradient=function(t){for(var e=t.length,r=0;r<8;r++)e<=4*r&&(t=t.concat([-1,0,0,0]));return t},t.prototype.destroy=function(){this.regl=null,this.J=null,this.K=null},t.m=new t,t}();H.getInstance();var Z=t.Util.CommonUtil.pushArray,Q=function(t){function e(e){var r=t.call(this,e)||this;r.CLASS_NAME="HeatMap",r.fusion=new G,r.B=new H,r.$=!1,r._animateLayerState={height:1,radius:1};var n=v.v;return r.zooms=void 0===e.zooms?n.zooms:e.zooms,r.zIndex=void 0===e.zIndex?n.zIndex:e.zIndex,r.opacity=void 0===e.opacity?n.opacity:e.opacity,r.visible=void 0===e.visible?n.visible:e.visible,r.depth=void 0===e.depth?n.depth:e.depth,r.createGLLayer(e),r.buryPoint.record(r.CLASS_NAME),r}return u(e,t),e.prototype.receiveDataset=function(t){this.dataset=t,this.setStyle(this.styleOptions),this.onAdd()},e.prototype.setStyle=function(e){if(t.prototype.setStyle.call(this,e),this.dataset=this.source.getDataset(),this.dataset&&this.dataset.length>0&&this.meshes){var r=this.filterDataset().didFusion,n=this.fusion.buildStyle(this.dataset,this.styleOptions);this.fusion.updateStyle(r,n),this.loca&&this.loca.requestRender()}},e.prototype.createRenderer=function(){this.loca&&this.loca.regl&&!this.B.regl&&(this.B.regl=this.loca.regl,this.loca.rendererManager.addRenderer(this.B))},e.prototype.beforeRender=function(){if(t.prototype.beforeRender.call(this),!this.fusion.regl&&this.loca&&(this.fusion.regl=this.loca.regl,this.loca.fusionManager.addFusion(this.fusion)),this.createRenderer(),this.source&&(this.dataset=this.source.getDataset()),this.fusion){var e=this.filterDataset(),r=e.willFusion,n=e.didFusion;this.fusion.updateFrame(n),r.length>0&&(this.meshes=Z(n,this.fusion.fusion(r,this.styleOptions,this)),this.$=this.$||this.fusion.buildGeometry())}},e.prototype.render=function(){var t,e,r;this.loca&&this.loca.regl&&this.loca.regl._refresh();var n=null===(t=this.loca)||void 0===t?void 0:t.customCoords,i=n.getMVPMatrix(),o=this.projection.getResolution(null===(e=this.loca)||void 0===e?void 0:e.map.getZoom()),a=null===(r=this.loca)||void 0===r?void 0:r.map.getBounds().toJSON(),s=f(n.lngLatToCoord(a.slice(0,2)),n.lngLatToCoord(a.slice(2)));this.B&&this.meshes.length>0&&this.B.render(c(c({meshes:this.meshes,mvp:i,resolution:o,opacity:this._getOpacity()},this.$),{bbox:s,depth:this.depth,M:this._animateLayerState}))},e.prototype.pickRender=function(){},e.prototype.afterRender=function(){},e}(t.Layer);a.default.HeatMapLayer=Q;var X=function(){function t(){this.style={},this.V=[],this.tt=new s.GUI}return t.prototype.addLayer=function(t,e){var r=this;void 0===e&&(e="图层");var n=this.tt.addFolder(e),i=this.getSchema(t),o=t.styleOptions,a={},s=function(e){a[e]=o[e];var s=i[e].type;if(a[e]instanceof Function)return"continue";void 0===a[e]&&(a[e]=i[e].defaultValue),"color"===s?n.addColor(a,e).onChange((function(n){a[e]=n,t.setStyle(r.it(t,a))})):"array"===s?(a[e]=a[e]+"",n.add(a,e).onChange((function(n){a[e]=n,t.setStyle(r.it(t,a))}))):"image"===s?("[object String]"!==Object.prototype.toString.call(a[e])&&(a[e]=""),n.add(a,e).onChange((function(n){a[e]=n,t.setStyle(r.it(t,a))}))):n.add(a,e).onChange((function(n){a[e]=n,t.setStyle(r.it(t,a))}))};for(var l in i)s(l)},t.prototype.addLight=function(t,e,r){void 0===r&&(r="光源");var n=this.tt.addFolder(r),i={};this.V.push(i);var o=function(r){var o=t[r];"color"===r?(i[r]=t[r],n.addColor(i,r).onChange((function(n){i[r]=n,t[r]=i[r],e.requestRender()}))):"[object Array]"===Object.prototype.toString.call(o)?(i[r]=t[r]+"",n.add(i,r).onChange((function(n){i[r]=n.split(","),t[r]=i[r],e.requestRender()}))):(i[r]=t[r],n.add(i,r).onChange((function(n){i[r]=n,t[r]=i[r],e.requestRender()})))};for(var a in t)o(a)},t.prototype.getSchema=function(t){var e=t.CLASS_NAME;if(e)return S[e.toLowerCase()].style},t.prototype.it=function(t,e){var r=this.getSchema(t),n={},i=function(t){var i=r[t].type;if(n[t]=e[t],"array"===i){var o=(e[t]+"").split(",");isNaN(+o[0])||o.forEach((function(t,e){o[e]=+t})),n[t]=o}};for(var o in r)i(o);return n},t.prototype.destroy=function(){this.tt.destroy(),this.style={},this.V=[]},t}();a.default.Dat=X;var Y=t.Util.CommonUtil.pushArray,J=function(e){function r(){return null!==e&&e.apply(this,arguments)||this}return u(r,e),r.getInstance=function(){return this.m},r.prototype.buildGeometry=function(){},r.prototype.buildStyle=function(e,r){for(var n=m.style,i={attributes:[],uniforms:!1,g:!1},o=0;o<e.length;o++)if(e[o].features&&e[o].features.points){var a=e[o].features.points,s=t.StyleInstance.parse(a,r,n),l={};i.uniforms||(i.uniforms=s.uniforms),i.g||(i.g=s.g);for(var u=0,c=a.length;u<c;u++)if(s)for(var f in s.attributes){var h=s.attributes[f];l[f]||(l[f]=[]),h[u].length>0?Y(l[f],h[u]):l[f][l[f].length]=h[u]}i.attributes.push(l)}return i},r.prototype.fusion=function(e,r,n,i){if(!this.regl||!n.loca)return[];for(var o=[],a=(i=i||this.buildStyle(e,r)).attributes,s=n.loca.customCoords,l=0;l<e.length;l++){var u=e[l];if(u.features&&u.features.points){for(var c=u.features.points,f=a[l],h={index:[],vertex:[],color:[],number:[],uv:[],size:[],rotation:[],borderColor:[],borderWidth:[],pickColor:[]},d=[],p=0;p<c.length;p++){var m=c[p],v=m.coordinates,g=n.colorPick.add(m);if("MultiPoint"===m.type)for(var y=0,b=v.length;y<b;y++){var x=v[y],_=this.triangles(x,{attribute:f,index:p,pickColor:g},s);t.Geometry.mergeTriangles(h,_),Y(h.color,_.color),Y(h.rotation,_.rotation),Y(h.number,_.number),Y(h.size,_.size),Y(h.uv,_.uv),Y(h.borderColor,_.borderColor),Y(h.borderWidth,_.borderWidth),Y(h.pickColor,_.pickColor)}else _=this.triangles(v,{attribute:f,index:p,pickColor:g},s),t.Geometry.mergeTriangles(h,_),Y(h.color,_.color),Y(h.rotation,_.rotation),Y(h.number,_.number),Y(h.size,_.size),Y(h.uv,_.uv),Y(h.borderColor,_.borderColor),Y(h.borderWidth,_.borderWidth),Y(h.pickColor,_.pickColor);d[p]=h.rotation.length}o[l]={id:u.id,attributes:{color:{buffer:this.regl.buffer(h.color),offset:0,P:16,_:!1,divisor:0},pickColor:{buffer:this.regl.buffer(h.pickColor),offset:0,P:16,_:!1,divisor:0},borderColor:{buffer:this.regl.buffer(h.borderColor),offset:0,P:16,_:!1,divisor:0},position:{buffer:this.regl.buffer(h.vertex),offset:0,P:12,_:!1,divisor:0},number:{buffer:this.regl.buffer(h.number),offset:0,P:4,_:!1,divisor:0},borderWidth:{buffer:this.regl.buffer(h.borderWidth),offset:0,P:4,_:!1,divisor:0},rotation:{buffer:this.regl.buffer(h.rotation),offset:0,P:4,_:!1,divisor:0},size:{buffer:this.regl.buffer(h.size),offset:0,P:8,_:!1,divisor:0},uv:{buffer:this.regl.buffer(h.uv),offset:0,P:8,_:!1,divisor:0},index:this.regl.elements({primitive:"triangles",type:"uint32",data:h.index})},uniforms:i.uniforms,g:i.g,k:{S:{W:d},origin:{color:h.color,size:h.size,rotation:h.rotation,borderColor:h.borderColor,borderWidth:h.borderWidth}}}}}return o},r.prototype.triangles=function(t,e,r){var n=e.index,i=e.pickColor,o=e.attribute,a=o.size,s=o.color,l=o.rotation,u=o.altitude,c=o.borderColor,f=o.borderWidth,h=s.slice(4*n,4*n+4),d=c.slice(4*n,4*n+4),p=a.slice(2*n,2*n+2),m=l[n],v=f[n],g=u[n],y=r.lngLatToCoord(t),b=t[2]||g||0,x=[p[0],p[1],p[0],p[1],p[0],p[1],p[0],p[1]],_=[h[0],h[1],h[2],h[3],h[0],h[1],h[2],h[3],h[0],h[1],h[2],h[3],h[0],h[1],h[2],h[3]],w=[m,m,m,m];return{vertex:[y[0],y[1],b,y[0],y[1],b,y[0],y[1],b,y[0],y[1],b],index:[0,1,2,1,3,2],number:[0,1,3,2],uv:[0,0,0,1,1,0,1,1],size:x,rotation:w,color:_,borderColor:[d[0],d[1],d[2],d[3],d[0],d[1],d[2],d[3],d[0],d[1],d[2],d[3],d[0],d[1],d[2],d[3]],borderWidth:[v,v,v,v],pickColor:[i[0],i[1],i[2],i[3],i[0],i[1],i[2],i[3],i[0],i[1],i[2],i[3],i[0],i[1],i[2],i[3]]}},r.prototype.updateStyle=function(t,e){for(var r=0,n=t.length;r<n;r++){for(var i=t[r],o=e.attributes[r],a=o.color,s=o.borderColor,l=o.borderWidth,u=o.rotation,c=o.size,f=i.k.origin,h=f.borderColor,d=f.color,p=f.borderWidth,m=f.size,v=f.rotation,g=i.k.S.W,y=0,b=0,x=v.length;b<x;b++){var _=4*b;b>=g[y]&&y++;var w=4*y;d[_]=a[w],d[_+1]=a[w+1],d[_+2]=a[w+2],d[_+3]=a[w+3],h[_]=s[w],h[_+1]=s[w+1],h[_+2]=s[w+2],h[_+3]=s[w+3],m[_]=+c[w],m[_+1]=+c[w+1],m[_+2]=+c[w+2],m[_+3]=+c[w+3],p[b]=l[y],v[b]=u[y]}i.attributes.color.buffer({data:d}),i.attributes.rotation.buffer({data:v}),i.attributes.borderColor.buffer({data:h}),i.attributes.borderWidth.buffer({data:p}),i.attributes.size.buffer({data:m}),i.uniforms=e.uniforms}},r.prototype.updateFrame=function(t){},r.prototype.destroy=function(){this.regl=null},r.m=new r,r}(t.GeometryFusion);J.getInstance();var K={vertex:"\n        precision highp float;\n        #define PI 3.14159265359\n        attribute vec3 position;\n        attribute vec4 color;\n        attribute vec4 borderColor;\n        attribute vec2 size;\n        attribute vec2 uv;\n        attribute float rotation;\n        attribute float borderWidth;\n        attribute float number;\n\n        varying vec4 vColor;\n        varying vec4 vBColor;\n        varying float vBWidth;\n        varying vec2 vUv;\n        varying vec2 vSize;\n        varying vec2 vPos;\n\n        uniform mat4 mvp;\n        uniform float resolution;\n        // 0: px, 1: meter\n        uniform float unit;\n        "+t.ColorGLSL.getColorShader().vertex+"\n\n        void main() {\n            // 对角线长度一半\n            float diagonal = length(size + vec2(borderWidth * 2.0)) / 2.0;\n            float x = size.x / 2.0 + borderWidth;\n            float y = size.y / 2.0 + borderWidth;\n\n            // 计算顶点向量\n            // 1 3 -- 0 1\n            // 0 2 -- 2 3\n            float rotNumber = mod(number + 2.0, 4.0);\n            float oneAngle = asin(x / diagonal);\n            float twoAngle = asin(y / diagonal) * 2.0;\n            float theta = rotation / 180. * PI + oneAngle;\n            if(rotNumber == 1.0) {\n                theta += twoAngle;\n            } else if(rotNumber == 2.0) {\n                theta += twoAngle + oneAngle * 2.0;\n            } else if(rotNumber == 3.0) {\n                theta += (twoAngle + oneAngle) * 2.0;\n            }\n\n            vec2 pos =\n                mat2(cos(theta), -sin(theta),\n                     sin(theta), cos(theta)) * vec2(0, 1);\n\n            float res = unit == 0.0 ? resolution : 1.0;\n\n            gl_Position = mvp * vec4(position + vec3(pos, 0) * diagonal * res, 1.0);\n        \n            vColor = color;\n            vSize = size;\n            vBWidth = borderWidth;\n            vBColor = borderColor;\n            vUv = uv;\n            vPos = pos * diagonal;\n            "+t.ColorGLSL.getColorShader().mainVert+"\n        }\n    ",fragment:"\n        precision highp float;\n        uniform float resolution;\n        uniform float opacity;\n        uniform float textureSequence;\n        uniform sampler2D texture;\n        uniform float useTexture;\n        uniform float animateCounter;\n\n        varying vec2 vSize;\n        varying vec4 vColor;\n        varying vec4 vBColor;\n        varying float vBWidth;\n        varying vec2 vUv;\n        varying vec2 vPos;\n        "+t.ColorGLSL.getColorShader().fragment+"\n\n        void main() {\n            if(useTexture == 1.0) {\n                // 0.0001 解决 mod 运算的精度误差问题。\n                float offset = mod(animateCounter + 0.001, textureSequence) / textureSequence;\n                gl_FragColor = texture2D(texture, vec2(vUv.x / textureSequence + offset, vUv.y));\n                // gl_FragColor = vec4(mod(textureSequence + 0.1, textureSequence) / textureSequence, 0, 0, 1);\n            } else {\n                gl_FragColor = vColor;\n\n                // 抗锯齿像素位\n                float len = length(vPos);\n                float taaRadius = 2.0;\n                if(len > vSize.x / 2.0 + vBWidth) {\n                    discard;\n                } else if(len > vSize.x / 2.0 + vBWidth - taaRadius) {\n                    gl_FragColor = vBWidth > 0.0 ? vBColor : vColor;\n                    float opa = smoothstep(1.0, 0.0, (len - (vSize.x / 2.0 + vBWidth - taaRadius)) / taaRadius);\n                    gl_FragColor.a *= opa;\n                } else if(vBWidth > 0.0 && len > vSize.x / 2.0 + taaRadius) {\n                    gl_FragColor = vBColor;\n                } else if(vBWidth > 0.0 && len > vSize.x / 2.0) {\n                    float blend = smoothstep(0.0, 1.0, (len - vSize.x / taaRadius) / taaRadius);\n                    gl_FragColor = mix(vColor, vBColor, blend);\n                }\n            }\n            gl_FragColor.a *= opacity;\n            "+t.ColorGLSL.getColorShader().mainFrag+"\n        }\n    "},$=function(){function e(t){this.regl=t,this.createCmd()}return e.getInstance=function(){return this.m},e.prototype.createCmd=function(){if(this.regl){var e=this.regl;this.D=e({frag:K.fragment,vert:K.vertex,attributes:c({position:e.prop("position"),color:e.prop("color"),size:e.prop("size"),uv:e.prop("uv"),rotation:e.prop("rotation"),number:e.prop("number"),borderColor:e.prop("borderColor"),borderWidth:e.prop("borderWidth")},t.ColorGLSL.getColor(e).attribute),uniforms:c({mvp:e.prop("mvp"),resolution:e.prop("resolution"),opacity:e.prop("opacity"),unit:e.prop("unit"),texture:e.prop("texture"),textureSequence:e.prop("textureSequence"),useTexture:e.prop("useTexture"),animateCounter:e.prop("animateCounter")},t.ColorGLSL.getColor(e).uniform),blend:{enable:!0,func:E("normal"),equation:{rgb:"add",alpha:"add"}},cull:{enable:!0,face:"back"},frontFace:"cw",depth:{enable:e.prop("depth")},elements:e.prop("index")})}},e.prototype.render=function(t){var e=t.meshes,r=t.mvp,n=t.resolution,i=t.opacity,o=t.texture,a=t.useTexture,s=t.animateCounter,l=t.textureSequence,u=t.depth;if(this.regl){this.D||this.createCmd();for(var f=0;f<e.length;f++){var h=e[f],d=h.attributes,p=h.uniforms,m=p.unit,v=p.duration,g=p.animate,y=g?parseInt(s/60*l/(v/1e3)):0;this.D(c(c({},d),{mvp:r,resolution:n,opacity:i,unit:"px"===m?0:1,texture:o,textureSequence:l,useTexture:a,animateCounter:y,animate:g,depth:u,isPick:!1}))}}},e.prototype.pickRender=function(t){var e=this,r=t.meshes,n=t.mvp,i=t.resolution,o=t.opacity,a=t.texture,s=t.useTexture,l=t.animateCounter,u=t.textureSequence,f=t.depth,h=t.pickFbo,d=t.pickPos;this.regl&&(this.D||this.createCmd(),h&&d&&a&&h.use((function(){e.regl.clear({color:[0,0,0,0],depth:1});for(var t=0;t<r.length;t++){var h=r[t],d=h.attributes,p=h.uniforms,m=p.unit,v=p.duration,g=p.animate,y=g?parseInt(l/60*u/(v/1e3)):0;e.D(c(c({},d),{mvp:n,resolution:i,opacity:o,unit:"px"===m?0:1,texture:a,textureSequence:u,useTexture:s,animateCounter:y,animate:g,depth:f,isPick:!0}))}})))},e.prototype.destroy=function(){this.regl=null,this.D=null},e.m=new e,e}();$.getInstance();var tt=O,et=t.Util.CommonUtil.pushArray,rt=function(t){function e(e){var r=t.call(this,e)||this;r.CLASS_NAME="Scatter",r.fusion=new J,r.B=new $,r.R=!1,r.nt=0,r.et=0;var n=m.v;return r.zooms=void 0===e.zooms?n.zooms:e.zooms,r.visible=void 0===e.visible?n.visible:e.visible,r.zIndex=void 0===e.zIndex?n.zIndex:e.zIndex,r.opacity=void 0===e.opacity?n.opacity:e.opacity,r.depth=void 0===e.depth?n.depth:e.depth,r.createGLLayer(e),r.buryPoint.record(r.CLASS_NAME),r}return u(e,t),e.prototype.receiveDataset=function(t){this.dataset=t,this.setStyle(this.styleOptions),this.onAdd()},e.prototype.setStyle=function(e){if(e&&(t.prototype.setStyle.call(this,e),this.dataset=this.source.getDataset(),this.dataset&&this.dataset.length>0)){var r=this.filterDataset().didFusion;this.F=null;var n=this.fusion.buildStyle(this.dataset,this.styleOptions);this.fusion.updateStyle(r,n),this.loca&&this.loca.requestRender()}},e.prototype.createRenderer=function(){t.prototype.createRenderer.call(this),this.loca&&this.loca.regl&&!this.B.regl&&(this.B.regl=this.loca.regl,this.loca.rendererManager.addRenderer(this.B))},e.prototype.beforeRender=function(){if(t.prototype.beforeRender.call(this),!this.fusion.regl&&this.loca&&(this.fusion.regl=this.loca.regl,this.loca.fusionManager.addFusion(this.fusion)),this.createRenderer(),this.source&&(this.dataset=this.source.getDataset()),this.fusion&&this.styleOptions){var e=this.filterDataset(),r=e.willFusion,n=e.didFusion;this.fusion.updateFrame(n),r.length>0&&(this.meshes=et(n,this.fusion.fusion(r,this.styleOptions,this)))}if(this.meshes.length>0){var i=this.meshes[0].uniforms.texture;this.createTexture(i),this.et++}},e.prototype.render=function(){var t,e;if(this.loca&&this.loca.regl){this.loca.regl._refresh();var r=null===(t=this.loca)||void 0===t?void 0:t.customCoords.getMVPMatrix(),n=this.projection.getResolution(null===(e=this.loca)||void 0===e?void 0:e.map.getZoom());this.B&&this.meshes.length>0&&this.B.render({meshes:this.meshes,mvp:r,resolution:n,opacity:this._getOpacity(),texture:this.F,useTexture:+this.R,animateCounter:this.et,textureSequence:this.nt,depth:this.depth})}},e.prototype.pickRender=function(){var t,e;if(this.loca&&this.loca.regl){this.loca.regl._refresh();var r=null===(t=this.loca)||void 0===t?void 0:t.customCoords.getMVPMatrix(),n=this.projection.getResolution(null===(e=this.loca)||void 0===e?void 0:e.map.getZoom());this.B&&this.B.pickRender({meshes:this.meshes,mvp:r,resolution:n,opacity:this._getOpacity(),texture:this.F,useTexture:+this.R,animateCounter:this.et,textureSequence:this.nt,depth:this.depth,pickFbo:this._needPickFrame&&this._pickFbo,pickPos:this._pickPos})}},e.prototype.afterRender=function(){},e.prototype.createTexture=function(t){var e=this;if(this.R=!!t,!this.F&&this.loca&&this.loca.regl&&(this.F=this.loca.regl.texture({data:[[[0,255,0,0],[255,0,0,0]],[[0,0,255,0],[255,255,255,0]]]}),t))if("[object String]"===Object.prototype.toString.call(t)){var r=new Image;r.src=t,r.crossOrigin="anonymous",r.onload=function(){e.F=e.loca.regl.texture(c({data:r,flipY:!0},tt(r.naturalWidth,r.naturalHeight))),e.nt=r.naturalWidth/r.naturalHeight}}else this.F=this.loca.regl.texture(c({data:t,flipY:!0},tt(t.width,t.height))),this.nt=t.width/t.height},e}(t.Layer);function nt(t,e,r,i,o){var a;void 0===i&&(i=.5),0===i&&(a=new n.Bezier(e,e,r)),1===i&&(a=new n.Bezier(t,e,e));var s=function(t,e,r,i,o){void 0===t&&(t=2),void 0===o&&(o=.5);var a=n.Bezier.getUtils(),s=a.projectionratio(o,t),l=1-s,u={x:s*e.x+l*i.x,y:s*e.y+l*i.y,z:s*e.z+l*i.z},c=a.abcratio(o,t);return{rt:{x:r.x+(r.x-u.x)/c,y:r.y+(r.y-u.y)/c,z:r.y+(r.z-u.z)/c},ot:r,at:u,st:e,E:i}}(2,t,e,r,i);a=new n.Bezier(t,s.rt,r);var l=100;return o&&(l=o<=3?4:Math.floor(o)+1),a.getLUT(l)}function it(t,e,r){return(e-t)*r+t}function ot(t,e,r){void 0===r&&(r=1);for(var n=[],i=0;i<=r-1;i++){var o=t.x,a=t.y,s=t.z,l=e.x,u=e.y,c=e.z,f=i/(r-1),h={x:+it(o,l,f),y:+it(a,u,f),z:+it(s,c,f)};n.push(h)}return n}function at(t,e,r){return(e-t)*r+t}function st(t,e,r){void 0===e&&(e=0),void 0===r&&(r=at);var n=t.length-1,i=n*e,o=i>>0,a=r;return function(t,e,r){var n=t[0],i=t[1],o=t[2],s=t[3],l=e[0],u=e[1],c=e[2],f=e[3];return[a(n,l,r),a(i,u,r),a(o,c,r),a(s,f,r)]}(t[o],t[o+1>n?n:o+1],i-o)}a.default.ScatterLayer=rt;var lt=t.Util.CommonUtil.pushArray;t.Util.ColorUtil.colorToArray.bind(t.Util.ColorUtil);var ut=function(r){function n(){return null!==r&&r.apply(this,arguments)||this}return u(n,r),n.getInstance=function(){return this.m},n.prototype.buildGeometry=function(){},n.prototype.buildStyle=function(r,n,i){var o=_.style,a=[];if(!i.loca)return{};for(var s=i.loca.customCoords,l=0;l<r.length;l++)if(r[l].features&&r[l].features.lines){for(var u=[],c=0,f=r[l].features.lines;c<f.length;c++){var h=f[c],d=h.coordinates,p=h.type;if("LineString"===p){var m=d[0],v=d[1],g=s.lngLatToCoord(m),y=s.lngLatToCoord(v),b=e.vec2.distance(g,y);u.push({distance:b,link:h})}if("MultiLineString"===p)for(var x=0;x<d.length;x++){var w=d[x];m=w[0],v=w[1],g=s.lngLatToCoord(m),y=s.lngLatToCoord(v),b=e.vec2.distance(g,y),u.push({distance:b,link:{coordinates:h.coordinates[x],properties:h.properties}})}}var C=t.StyleInstance.parse(u,n,o);a.push(C)}return a},n.prototype.fusion=function(t,e,r,n){if(!this.regl||!r.loca)return[];var i=[];n=n||this.buildStyle(t,e,r);for(var o=r.loca.customCoords,a=function(e){var a=t[e];if(!a.features||!a.features.lines)return"continue";for(var l=a.features.lines,u=n[e],c=u.attributes,f=u.uniforms,h={vertex:[],color:[],pickColor:[],index:[]},d=0,p=function(t){var e=l[t],n=e.coordinates,i=c.lineColors,a=c.height,s=f.smoothSteps,u=r.colorPick.add(e);if("MultiLineString"===e.type){d=0;for(var p=function(t,e){var r=n[t],l=r[0],c=r[1],f=l[0],p=l[1],m=c[0],v=c[1],g={x:f,y:p,z:0},y={x:m,y:v,z:0},b=a[t],x=[],_=i[t];0===b?(x=ot(g,y,_.length)).forEach((function(t,e){e!==x.length-1&&h.index.push(d,++d);var r=o.lngLatToCoord([t.x,t.y]);h.vertex.push(r[0],r[1],t.z),lt(h.color,_[e]),lt(h.pickColor,u)})):(x=nt(g,{x:f-(f-m)/2,y:p-(p-v)/2,z:b},y,.5,s)).forEach((function(t,e){e!==x.length-1&&h.index.push(d,++d);var r=o.lngLatToCoord([t.x,t.y]);h.vertex.push(r[0],r[1],t.z);var n=st(_,t.t);lt(h.color,n),lt(h.pickColor,u)})),d++},m=0,v=n.length;m<v;m++)p(m)}else{var g=n,y=g[0],b=g[1],x=y[0],_=y[1],w=b[0],C=b[1],S={x:x,y:_,z:0},k={x:w,y:C,z:0},A=a[t],M=[],z=i[t];0===A?(M=ot(S,k,z.length)).forEach((function(t,e){e!==M.length-1&&h.index.push(d,++d);var r=o.lngLatToCoord([t.x,t.y]);h.vertex.push(r[0],r[1],t.z),lt(h.color,z[e]),lt(h.pickColor,u)})):(M=nt(S,{x:x-(x-w)/2,y:_-(_-C)/2,z:A},k,.5,s)).forEach((function(t,e){e!==M.length-1&&h.index.push(d,++d);var r=o.lngLatToCoord([t.x,t.y]);h.vertex.push(r[0],r[1],t.z);var n=st(z,t.t);lt(h.color,n),lt(h.pickColor,u)})),d++}},m=0;m<l.length;m++)p(m);i[e]={id:a.id,attributes:{color:{buffer:s.regl.buffer(h.color),offset:0,P:16,_:!1,divisor:0},pickColor:{buffer:s.regl.buffer(h.pickColor),offset:0,P:16,_:!1,divisor:0},position:{buffer:s.regl.buffer(h.vertex),offset:0,P:12,_:!1,divisor:0},index:s.regl.elements({primitive:"lines",type:"uint32",data:h.index})},uniforms:u.uniforms,g:u.g}},s=this,l=0;l<t.length;l++)a(l);return i},n.prototype.updateStyle=function(t,e,r,n){if(!r.loca)return[];var i=r.dataset;return this.fusion(i,e,r,n)},n.prototype.updateFrame=function(t){},n.prototype.destroy=function(){this.regl=null},n.m=new n,n}(t.GeometryFusion);ut.getInstance();var ct={vertex:"\n        precision highp float;\n        attribute vec3 position;\n        attribute vec4 color;\n        varying vec4 v_color;\n        uniform mat4 mvp;\n        "+t.ColorGLSL.getColorShader().vertex+"\n\n        void main() {\n            v_color = color;\n            gl_Position = mvp * vec4(position, 1.0);\n            "+t.ColorGLSL.getColorShader().mainVert+"\n        }\n    ",fragment:"\n        precision highp float;\n        varying vec4 v_color;\n        uniform float opacity;\n        "+t.ColorGLSL.getColorShader().fragment+"\n\n        void main() {\n            gl_FragColor = v_color;\n            gl_FragColor *= opacity;\n            "+t.ColorGLSL.getColorShader().mainFrag+"\n        }\n    "},ft=function(){function e(t){this.regl=t,this.createCmd()}return e.getInstance=function(){return this.m},e.prototype.createCmd=function(){if(this.regl){var e=this.regl;this.D=e({frag:ct.fragment,vert:ct.vertex,attributes:c({position:e.prop("position"),color:e.prop("color")},t.ColorGLSL.getColor(e).attribute),uniforms:c({mvp:e.prop("mvp"),opacity:e.prop("opacity")},t.ColorGLSL.getColor(e).uniform),depth:{enable:!1},blend:{enable:!0,func:e.prop("blendFun"),equation:{rgb:"add",alpha:"add"}},elements:e.prop("index")})}},e.prototype.render=function(t){var e=t.meshes,r=t.mvp,n=t.opacity;if(this.regl){this.D||this.createCmd();for(var i=0;i<e.length;i++){var o=e[i].attributes;this.D(c(c({blendFun:E("zero")},o),{mvp:r,opacity:n,isPick:!1})),this.D(c(c({blendFun:E("lighter")},o),{mvp:r,opacity:n,isPick:!1}))}}},e.prototype.pickRender=function(t){var e=this,r=t.meshes,n=t.mvp,i=t.opacity,o=t.pickFbo,a=t.pickPos;this.regl&&(this.D||this.createCmd(),o&&a&&o.use((function(){e.regl.clear({color:[0,0,0,0],depth:1});for(var t=0;t<r.length;t++){var o=r[t].attributes;e.D(c(c({blendFun:E("normal")},o),{mvp:n,opacity:i,isPick:!0}))}})))},e.prototype.destroy=function(){this.regl=null,this.D=null},e.m=new e,e}();ft.getInstance();var ht=t.Util.CommonUtil.pushArray,dt=function(t){function e(e){var r=t.call(this,e)||this;r.CLASS_NAME="Link",r.fusion=new ut,r.B=new ft;var n=_.v;return r.zooms=void 0===e.zooms?n.zooms:e.zooms,r.zIndex=void 0===e.zIndex?n.zIndex:e.zIndex,r.opacity=void 0===e.opacity?n.opacity:e.opacity,r.visible=void 0===e.visible?n.visible:e.visible,r.createGLLayer(e),r.buryPoint.record(r.CLASS_NAME),r}return u(e,t),e.prototype.receiveDataset=function(t){this.dataset=t,this.setStyle(this.styleOptions),this.onAdd()},e.prototype.setStyle=function(e){if(t.prototype.setStyle.call(this,e),this.dataset=this.source.getDataset(),this.meshes=[],this.dataset&&this.dataset.length>0&&this.meshes){var r=this.filterDataset().didFusion,n=this.fusion.buildStyle(this.dataset,this.styleOptions,this);this.meshes=this.fusion.updateStyle(r,this.styleOptions,this,n),this.loca&&this.loca.requestRender()}},e.prototype.createRenderer=function(){t.prototype.createRenderer.call(this),this.loca&&this.loca.regl&&!this.B.regl&&(this.B.regl=this.loca.regl,this.loca.rendererManager.addRenderer(this.B))},e.prototype.beforeRender=function(){if(t.prototype.beforeRender.call(this),!this.fusion.regl&&this.loca&&(this.fusion.regl=this.loca.regl,this.loca.fusionManager.addFusion(this.fusion)),this.createRenderer(),this.source&&(this.dataset=this.source.getDataset()),this.fusion){var e=this.filterDataset(),r=e.willFusion,n=e.didFusion;this.fusion.updateFrame(n),r.length>0&&(this.meshes=ht(n,this.fusion.fusion(r,this.styleOptions,this)))}},e.prototype.render=function(){var t;if(this.loca&&this.loca.regl){this.loca.regl._refresh();var e=null===(t=this.loca)||void 0===t?void 0:t.customCoords.getMVPMatrix();this.B&&this.meshes.length>0&&this.B.render({meshes:this.meshes,mvp:e,opacity:this._getOpacity()})}},e.prototype.pickRender=function(){var t;if(this.loca&&this.loca.regl){this.loca.regl._refresh();var e=null===(t=this.loca)||void 0===t?void 0:t.customCoords.getMVPMatrix();this.B&&this.B.pickRender({meshes:this.meshes,mvp:e,opacity:this._getOpacity(),pickFbo:this._needPickFrame&&this._pickFbo,pickPos:this._pickPos})}},e.prototype.afterRender=function(){},e}(t.Layer);a.default.LinkLayer=dt;var pt=function(t){return e.vec3.fromValues(-t[0],-t[1],-t[2])},mt=function(t,r){return e.vec3.fromValues(t[0]*r,t[1]*r,t[2]*r)},vt=function(t,r,n){var i=e.vec3.sub(e.vec3.create(),r,t),o=e.vec3.create();return e.vec3.cross(o,n,i),e.vec3.normalize(o,o)},gt=function(t,r){var n=e.vec3.dot(t,r)/e.vec3.length(t)/e.vec3.length(r);return Math.acos(Math.min(1,n))},yt=t.Util.CommonUtil.pushArray,bt=function(r){function n(){return null!==r&&r.apply(this,arguments)||this}return u(n,r),n.getInstance=function(){return this.m},n.prototype.buildGeometry=function(){},n.prototype.buildStyle=function(e,r){for(var n=p.style,i=[],o=function(o){var a=e[o];if(!e[o].features||!e[o].features.lines)return"continue";var s=a.features.lines,l=t.StyleInstance.parse(s,r,n),u={};s.forEach((function(t,e){if(l)for(var r in l.attributes){var n=l.attributes[r];u[r]||(u[r]=[]),u[r][u[r].length]=n[e]}})),i.push({attributes:u,uniforms:l.uniforms,g:l.g}),i.push(l)},a=0;a<e.length;a++)o(a);return i},n.prototype.updateStyle=function(t,e,r,n){if(!r.loca)return[];var i=r.dataset;return this.fusion(i,e,r,n)},n.prototype.fusion=function(t,e,r,n){var i=this;if(!this.regl||!r.loca)return[];var o=[];n=n||this.buildStyle(t,e);for(var a=r.loca.customCoords,s=function(e){var s=t[e];if(!t[e].features||!t[e].features.lines)return"continue";var u=s.features.lines,c=n[e],f={position:[],normal:[],angle:[],pointType:[],distance:[],startDistance:[],totalDistance:[],lineWidth:[],headColor:[],trailColor:[],pickColor:[],index:[]},h=0,d=[];u.forEach((function(t,e){var n=t.type,o=t.coordinates,s=r.colorPick.add(t);if("MultiLineString"===n)o.forEach((function(t){var r=t.map((function(t){return a.lngLatToCoord(t)})),n=i.triangles(r,{style:c,index:e,pickColor:s},a),o=n.index.map((function(t){return t+h}));yt(f.position,n.position),yt(f.normal,n.normal),yt(f.angle,n.angle),yt(f.pointType,n.pointType),yt(f.distance,n.distance),yt(f.startDistance,n.startDistance),yt(f.totalDistance,n.totalDistance),yt(f.lineWidth,n.lineWidth),yt(f.headColor,n.headColor),yt(f.trailColor,n.trailColor),yt(f.pickColor,n.pickColor),yt(f.index,o),h+=n.distance.length}));else{var l=o.map((function(t){return a.lngLatToCoord(t)})),u=i.triangles(l,{style:c,index:e,pickColor:s},a),p=u.index.map((function(t){return t+h}));yt(f.position,u.position),yt(f.normal,u.normal),yt(f.angle,u.angle),yt(f.pointType,u.pointType),yt(f.distance,u.distance),yt(f.startDistance,u.startDistance),yt(f.totalDistance,u.totalDistance),yt(f.lineWidth,u.lineWidth),yt(f.headColor,u.headColor),yt(f.trailColor,u.trailColor),yt(f.pickColor,u.pickColor),yt(f.index,p),h+=u.distance.length}d[e]=f.distance.length})),o[e]={id:s.id,attributes:{position:{buffer:l.regl.buffer(f.position),size:3,offset:0,P:0,_:!1,divisor:0},normal:{buffer:l.regl.buffer(f.normal),size:3,offset:0,P:0,_:!1,divisor:0},angle:{buffer:l.regl.buffer(f.angle),size:1,offset:0,P:0,_:!1,divisor:0},pointType:{buffer:l.regl.buffer(f.pointType),size:1,offset:0,P:0,_:!1,divisor:0},distance:{buffer:l.regl.buffer(f.distance),size:1,offset:0,P:0,_:!1,divisor:0},startDistance:{buffer:l.regl.buffer(f.startDistance),size:1,offset:0,P:0,_:!1,divisor:0},totalDistance:{buffer:l.regl.buffer(f.totalDistance),size:1,offset:0,P:0,_:!1,divisor:0},lineWidth:{buffer:l.regl.buffer(f.lineWidth),size:1,offset:0,P:0,_:!1,divisor:0},headColor:{buffer:l.regl.buffer(f.headColor),size:4,offset:0,P:0,_:!1,divisor:0},trailColor:{buffer:l.regl.buffer(f.trailColor),size:4,offset:0,P:0,_:!1,divisor:0},pickColor:{buffer:l.regl.buffer(f.pickColor),size:4,offset:0,P:0,_:!1,divisor:0},index:l.regl.elements({primitive:"triangles",type:"uint32",data:f.index})},uniforms:c.uniforms,g:c.g,k:{S:{W:d},origin:{position:f.position,normal:f.normal,angle:f.angle,pointType:f.pointType,distance:f.distance,startDistance:f.startDistance,totalDistance:f.totalDistance,lineWidth:f.lineWidth,index:f.index}}}},l=this,u=0;u<t.length;u++)s(u);return o},n.prototype.updateFrame=function(t){},n.prototype.triangles=function(t,r,n){for(var i=r.style,o=i.attributes,a=i.uniforms,s=r.index,l=r.pickColor,u=o.lineWidth,c=o.headColor,f=o.trailColor,h=a.altitude,d=function(t){for(var r=0,n=0;n<t.length-1;n++)r+=e.vec2.distance(t[n],t[n+1]);return r}(t),p={position:[],normal:[],angle:[],pointType:[],distance:[],startDistance:[],totalDistance:[],lineWidth:[],headColor:[],trailColor:[],pickColor:[],index:[]},m=[],v=0;v<t.length;v++)0!==v&&t[v][0]===t[v-1][0]&&t[v][1]===t[v-1][1]||m.push(t[v]);if(m.length<=1)return p;for(var g,y,b,x,_,w,C,S,k,A,M=e.vec3.fromValues(0,0,1),z=[],O=[],E=[],P=[],L=[],T=[],D=[],R=e.vec3.create(),I=e.vec3.create(),F=e.vec3.create(),B=0,j=0;j<m.length;j++){var V=m[j],N=e.vec3.fromValues(V[0],V[1],h),U=e.vec3.fromValues(V[0],V[1],0);if(e.vec3.normalize(U,U),0===j){var G=m[j+1],W=e.vec3.fromValues(G[0],G[1],h),q=e.vec3.sub(e.vec3.create(),W,N),H=vt(N,W,M);O.push(N,N),E.push(H,mt(H,-1)),P.push(0,0),L.push(0,0),T.push(0,0),D.push(B,B),R=pt(q),I=H,F=N}else if(j===m.length-1){var Z=e.vec3.dist(F,N);O.push(N,N),E.push(I,mt(I,-1)),P.push(0,0),L.push(0,0),B+=Z,T.push(Z,Z),D.push(B,B);var Q=O.length;z.push(Q-4,Q-2,Q-1),z.push(Q-4,Q-1,Q-3)}else{G=m[j+1],W=e.vec3.fromValues(G[0],G[1],h);var X=(w=R,C=q=e.vec3.sub(e.vec3.create(),W,N),S=void 0,k=void 0,A=void 0,S=e.vec3.normalize(e.vec3.create(),w),k=e.vec3.normalize(e.vec3.create(),C),A=e.vec3.add(e.vec3.create(),S,k),e.vec3.normalize(A,A));if(0===e.vec3.length(X))continue;H=vt(N,W,M);var Y=gt(X,q);Z=e.vec3.dist(F,N),g=R,y=q,b=void 0,x=void 0,_=void 0,b=e.vec3.create(),x=e.vec2.fromValues(g[0],g[1]),_=e.vec2.fromValues(y[0],y[1]),e.vec2.cross(b,_,x),(0===b[2]?b[2]:b[2]/Math.abs(b[2]))>=0?(O.push(N,N,N,N,N),E.push(X,mt(I,-1),X,X,mt(H,-1)),P.push(Y,0,Y,Y,0),L.push(-1,0,0,1,0),B+=Z,T.push(Z,Z,Z,Z,Z),D.push(B,B,B,B,B),Q=O.length,z.push(Q-3,Q-4,Q-1),z.push(Q-7,Q-5,Q-4),z.push(Q-7,Q-4,Q-6)):(O.push(N,N,N,N,N),E.push(I,X,X,H,X),P.push(0,Y,Y,0,Y),L.push(0,-1,0,0,1),B+=Z,T.push(Z,Z,Z,Z,Z),D.push(B,B,B,B,B),Q=O.length,z.push(Q-3,Q-5,Q-2),z.push(Q-7,Q-5,Q-4),z.push(Q-7,Q-4,Q-6)),R=pt(q),I=H,F=N}}var J=[],K=O.length;O.forEach((function(t){var e=t[0],r=t[1],n=t[2];J.push(e,r,n)}));var $=[];E.forEach((function(t){var e=t[0],r=t[1],n=t[2];$.push(e,r,n)}));var tt=u[s],et=c[s],rt=[],nt=f[s],it=[],ot=[];for(v=0;v<K;v++)rt.push.apply(rt,et),it.push.apply(it,nt),ot.push.apply(ot,l);return p.index=z,p.position=J,p.normal=$,p.angle=P,p.pointType=L,p.distance=T,p.startDistance=D,p.totalDistance=new Array(K).fill(d),p.lineWidth=new Array(K).fill(tt),p.headColor=rt,p.trailColor=it,p.pickColor=ot,p},n.prototype.destroy=function(){this.regl=null},n.m=new n,n}(t.GeometryFusion);bt.getInstance();var xt={vertex:"\n        precision highp float;\n        attribute vec3 position;\n        attribute vec3 normal;\n        attribute float angle;\n        attribute float pointType;\n        attribute float distance;\n        attribute float startDistance;\n        attribute float totalDistance;\n        attribute float lineWidth;\n        attribute vec4 headColor;\n        attribute vec4 trailColor;\n        uniform mat4 mvp;\n        uniform float resolution;\n        varying float vDistance;\n        varying float vTotalDistance;\n        varying vec4 vHeadColor;\n        varying vec4 vTrailColor;\n        "+t.ColorGLSL.getColorShader().vertex+"\n\n        vec3 normalizeAndMulti(vec3 vec, float multi) {\n            vec3 nNormal = normalize(vec);\n            return vec3(\n                multi * nNormal.x,\n                multi * nNormal.y,\n                multi * nNormal.z\n            );\n        }\n        \n        void main() {\n          float halfLineWidth = lineWidth / 2.0 * resolution;\n          vec3 pointPosition;\n            // 判断是否为内角点\n            if (angle != 0.0) {\n                // 判断是否为角度过小的特殊情形\n                bool angleIsTooSmall = halfLineWidth / tan(angle) >= distance;\n                if (angleIsTooSmall) {\n                    if (pointType == 0.0) {\n                        pointPosition = position;\n                    } else {\n                        pointPosition = position + normalizeAndMulti(normal, halfLineWidth);\n                    }\n                    vDistance = startDistance;\n                } else {\n                    pointPosition = position + normalizeAndMulti(normal, halfLineWidth / sin(angle));\n                    vDistance = startDistance + pointType * halfLineWidth / tan(angle);\n                }\n            } else {\n                // 外角点\n                pointPosition = position + normalizeAndMulti(normal, halfLineWidth);\n                vDistance = startDistance;\n            }\n            vTotalDistance = totalDistance;\n            vHeadColor = headColor;\n            vTrailColor = trailColor;\n            gl_Position = mvp * vec4(pointPosition, 1.0);\n            "+t.ColorGLSL.getColorShader().mainVert+"\n        }\n    ",fragment:"\n        precision highp float;\n        varying float vDistance;\n        varying float vTotalDistance;\n        varying vec4 vHeadColor;\n        varying vec4 vTrailColor;\n        uniform float interval;\n        uniform float duration;\n        uniform float time;\n        uniform float opacity;\n\n        float trailLength;\n        float offset;\n        float distanceMod;\n        float ratio;\n        "+t.ColorGLSL.getColorShader().fragment+"\n\n        void main() {\n            trailLength = vTotalDistance * interval;\n            offset = vTotalDistance * mod(time / duration * 1000.0, 1.0);\n            distanceMod = mod(vDistance + trailLength - offset, trailLength);\n            ratio = distanceMod / trailLength;\n            gl_FragColor = mix(vTrailColor, vHeadColor, ratio);\n            gl_FragColor.a *= opacity;\n\n            "+t.ColorGLSL.getColorShader().mainFrag+"\n            // if (vDistance > offset) {\n            //   gl_FragColor = vec4(0.0, 0.0, 0.0, 0.0);\n            // } else {\n            // }\n        }\n    "},_t=function(){function e(t){t&&(this.regl=t,this.lt=this.createCmd(t))}return e.getInstance=function(){return this.m},e.prototype.createCmd=function(e){return e({vert:xt.vertex,frag:xt.fragment,attributes:c({position:e.prop("position"),normal:e.prop("normal"),angle:e.prop("angle"),pointType:e.prop("pointType"),startDistance:e.prop("startDistance"),totalDistance:e.prop("totalDistance"),distance:e.prop("distance"),lineWidth:e.prop("lineWidth"),headColor:e.prop("headColor"),trailColor:e.prop("trailColor")},t.ColorGLSL.getColor(e).attribute),uniforms:c({mvp:e.prop("mvp"),resolution:e.prop("resolution"),opacity:e.prop("opacity"),duration:e.prop("duration"),interval:e.prop("interval"),time:e.prop("time")},t.ColorGLSL.getColor(e).uniform),blend:{enable:!0,func:{srcRGB:"src alpha",dstRGB:"one minus src alpha",srcAlpha:1,dstAlpha:"one minus src alpha"},equation:{rgb:"add",alpha:"add"}},depth:{enable:!1},primitive:"triangles",offset:0,elements:e.prop("index")})},e.prototype.render=function(t){var e=t.meshes,r=t.mvp,n=t.resolution,i=t.opacity,o=t.ut;if(this.regl){this.lt||(this.lt=this.createCmd(this.regl));var a=this.lt;e.forEach((function(t){var e=t.attributes,s=t.uniforms,l=s.interval,u=s.duration,f=o/60;a(c(c({},e),{mvp:r,resolution:n,opacity:i,interval:l,duration:u,time:f,isPick:!1}))}))}},e.prototype.pickRender=function(t){var e=this,r=t.meshes,n=t.mvp,i=t.resolution,o=t.opacity,a=t.ut,s=t.pickFbo,l=t.pickPos;if(this.regl){this.lt||(this.lt=this.createCmd(this.regl));var u=this.lt;s&&l&&s.use((function(){e.regl.clear({color:[0,0,0,0],depth:1}),r.forEach((function(t){var e=t.attributes,r=t.uniforms,s=r.interval,l=r.duration,f=a/60;u(c(c({},e),{mvp:n,resolution:i,opacity:o,interval:s,duration:l,time:f,isPick:!0}))}))}))}},e.prototype.destroy=function(){this.regl=null,this.lt=null},e.m=new e,e}();_t.getInstance();var wt=t.Util.CommonUtil.pushArray,Ct=function(t){function e(e){var r=t.call(this,e)||this;r.CLASS_NAME="PulseLine",r.fusion=new bt,r.B=new _t,r.et=0;var n=p.v;return r.zooms=void 0===e.zooms?n.zooms:e.zooms,r.visible=void 0===e.visible?n.visible:e.visible,r.zIndex=void 0===e.zIndex?n.zIndex:e.zIndex,r.opacity=void 0===e.opacity?n.opacity:e.opacity,r.createGLLayer(e),r.buryPoint.record(r.CLASS_NAME),r}return u(e,t),e.prototype.receiveDataset=function(t){this.dataset=t,this.setStyle(this.styleOptions),this.onAdd()},e.prototype.ht=function(){return{ut:this.et,timestamp:0}},e.prototype.setStyle=function(e){if(t.prototype.setStyle.call(this,e),this.dataset&&this.dataset.length>0&&this.meshes){var r=this.filterDataset().didFusion;if(r.length){var n=this.fusion.buildStyle(this.dataset,this.styleOptions);this.meshes=this.fusion.updateStyle(r,this.styleOptions,this,n),this.loca&&this.loca.requestRender()}}},e.prototype.createRenderer=function(){t.prototype.createRenderer.call(this),this.loca&&this.loca.regl&&!this.B.regl&&(this.B.regl=this.loca.regl,this.loca.rendererManager.addRenderer(this.B))},e.prototype.beforeRender=function(){if(t.prototype.beforeRender.call(this),!this.fusion.regl&&this.loca&&(this.fusion.regl=this.loca.regl,this.loca.fusionManager.addFusion(this.fusion)),this.createRenderer(),this.source&&(this.dataset=this.source.getDataset()),this.fusion){var e=this.filterDataset(),r=e.willFusion,n=e.didFusion;if(this.fusion.updateFrame(n),r.length>0){var i=this.fusion.fusion(r,this.styleOptions,this);this.meshes=wt(n,i)}}this.et++},e.prototype.render=function(){var t,e;if(this.loca&&this.loca.regl){this.loca.regl._refresh();var r=null===(t=this.loca)||void 0===t?void 0:t.customCoords.getMVPMatrix(),n=this.projection.getResolution(null===(e=this.loca)||void 0===e?void 0:e.map.getZoom());this.B&&this.meshes.length>0&&this.B.render({meshes:this.meshes,mvp:r,resolution:n,opacity:this._getOpacity(),ut:this.et})}},e.prototype.pickRender=function(){var t,e;if(this.loca&&this.loca.regl){this.loca.regl._refresh();var r=null===(t=this.loca)||void 0===t?void 0:t.customCoords.getMVPMatrix(),n=this.projection.getResolution(null===(e=this.loca)||void 0===e?void 0:e.map.getZoom());this.B&&this.B.pickRender({meshes:this.meshes,mvp:r,resolution:n,opacity:this._getOpacity(),ut:this.et,pickFbo:this._needPickFrame&&this._pickFbo,pickPos:this._pickPos})}},e.prototype.afterRender=function(){},e}(t.Layer);a.default.PulseLineLayer=Ct;var St,kt,At,Mt=(St=Math.PI/180,kt=180/Math.PI,At=6378137,{project:function(t,e){var r=85.0511287798;e=Math.max(Math.min(r,e),-r);var n=t*St,i=e*St;return i=Math.log(Math.tan(Math.PI/4+i/2)),[n*At,i*At]},unproject:function(t,e){return[t/At*kt,(2*Math.atan(Math.exp(e/At))-Math.PI/2)*kt]},getResolution:function(t){return 156543.03392804097/Math.pow(2,t)}}),zt={ft:function(t,e,r){void 0===e&&(e=100);for(var n={},i=[],o=2*e,a=-1,s=t.length;++a<s;){var l=t[a].vt,u=l[0],c=l[1],f=Mt.project(u,c),h=Math.floor(f[0]/o),d=Math.floor(f[1]/o),p=h+"-"+d,m=n[p];if(m)m.coordinates.push(t[a]);else{var v=Mt.unproject(h*o+e,d*o+e);n[p]=m={rowCol:[h,d],center:v,coordinates:[t[a]],ct:r(v)},i.push(m)}}return i},dt:function(t,e){void 0===e&&(e=100);for(var r={},n=[],i=2*e,o=-1,a=t.length;++o<a;){var s=t[o].coordinaties,l=Math.floor(s[0]/i),u=Math.floor(s[1]/i),c=l+"-"+u,f=r[c];f?f.coordinates.push(t[o]):(r[c]=f={rowCol:[l,u],center:[l*i+e,u*i+e],coordinates:[t[o]]},n.push(f))}return n},buildGeometry:function(t,e){var r=[],n=e.radius,i=t.ct,o=i[0],a=i[1],s=[o-n+0,a+n-0],l=[o-n+0,a-n+0],u=[o+n-0,a-n+0],c=[o+n-0,a+n-0];return r.push.apply(r,[s,l,u,c,s]),r}},Ot={bt:Math.PI/3,gt:[0,Math.PI/3,2*Math.PI/3,Math.PI/3,Math.PI/3,5*Math.PI/3],ft:function(t,e,r){void 0===e&&(e=100);for(var n={},i=[],o=2*e*Math.sin(this.bt),a=1.5*e,s=0,l=t.length;s<l;++s){var u=t[s].vt,c=u[0],f=u[1],h=Mt.project(c,f),d=h[0],p=h[1];p/=a;var m=Math.round(p);d=d/o-(1&m)/2;var v=Math.round(d),g=p-m;if(3*Math.abs(g)>1){var y=d-v,b=v+(d<v?-1:1)/2,x=m+(p<m?-1:1),_=d-b,w=p-x;y*y+g*g>_*_+w*w&&(v=b+(1&m?1:-1)/2,m=x)}var C=v+"-"+m,S=n[C];if(S)S.coordinates.push(t[s]);else{var k=Mt.unproject((v+(1&m)/2)*o,m*a);n[C]=S={rowCol:[v,m],center:k,coordinates:[t[s]],ct:r(k)},i.push(S)}}return i},buildGeometry:function(t,e){var r=[];e.gap;var n=e.radius,i=n/2,o=Math.sqrt(3)*n,a=Math.sqrt(Math.pow(o,2)+Math.pow(n,2)),s=t.ct,l=s[0],u=s[1],c=[l,u+a/2-0],f=[l-o/2+0,u+i-0],h=[l-o/2+0,u-i+0],d=[l,u-a/2+0],p=[l+o/2-0,u-i+0],m=[l+o/2-0,u+i-0];return r.push.apply(r,[c,f,h,d,p,m,c]),r}},Et=Object.freeze({__proto__:null,grid:zt,hexagon:Ot}),Pt=function(t){var e=[];if("MultiPoint"===t.type)for(var r=t.properties,n=(a=t.coordinates).length,i=0;i<n;++i){var o=a[i];e.push({properties:r,type:"Point",coordinates:o})}else if("MultiLineString"===t.type)for(r=t.properties,n=(a=t.coordinates).length,i=0;i<n;++i)o=a[i],e.push({properties:r,type:"Point",coordinates:o});else if("MultiPolygon"===t.type){var a;for(r=t.properties,n=(a=t.coordinates).length,i=0;i<n;++i)o=a[i],e.push({properties:r,type:"Point",coordinates:o})}return e},Lt=t.Util.CommonUtil.pushArray,Tt={grid:b,hexagon:x},Dt=function(e){function r(){return null!==e&&e.apply(this,arguments)||this}return u(r,e),r.getInstance=function(){return this.m},r.prototype.buildGeometry=function(t,e,r,n){var i,o,a,s;void 0===n&&(n="grid");for(var l=[],u=0,c=t.length;u<c;u++)if(t[u].features&&t[u].features.points){var f=e.unit,h=e.radius,d=e.gap,p=t[u].features.points,m=h,v=d;"px"===f&&(m*=r.projection.getResolution(null===(i=r.loca)||void 0===i?void 0:i.map.getZoom()),v*=r.projection.getResolution(null===(o=r.loca)||void 0===o?void 0:o.map.getZoom()));for(var g=[],y=[],b=0,x=p.length;b<x;b++){var _=p[b];if("MultiPoint"===_.type){for(var w=Pt(_),C=0,S=w.length;C<S;C++){var k=w[C];y.push({vt:k.coordinates,properties:k.properties})}Lt(g,w)}else y.push({vt:_.coordinates,properties:_.properties}),g.push(_)}var A=Et[n].ft(y,m+v,null===(a=r.loca)||void 0===a?void 0:a.customCoords.lngLatToCoord.bind(null===(s=r.loca)||void 0===s?void 0:s.customCoords));l.push(A)}return l},r.prototype.buildStyle=function(e,r,n){void 0===n&&(n="grid");for(var i=Tt[n].style,o=[],a=0,s=e.length;a<s;a++){for(var l=e[a],u=t.StyleInstance.parse(l,r,i),c={},f=0,h=l.length;f<h;f++)if(u)for(var d in u.attributes){var p=u.attributes[d];c[d]||(c[d]=[]),p[f].length>0?Lt(c[d],p[f]):c[d][c[d].length]=p[f]}o.push({attributes:c,uniforms:u.uniforms,g:u.g})}return o},r.prototype.fusion=function(e,r,n,i){var o;if(void 0===i&&(i="grid"),!this.regl||!n.loca)return[];var a=n.projection.getResolution(null===(o=n.loca)||void 0===o?void 0:o.map.getZoom()),s=[],l=this.buildGeometry(e,r,n,i),u=r.unit,c=r.radius,f=r.gap;"px"===u&&(c*=a,f*=a);for(var h=this.buildStyle(l,r,i),d=0,p=l.length;d<p;d++){for(var m=l[d],v=h[d],g={index:[],vertex:[],color:[],pickColor:[],normal:[],topOrBottom:[]},y=[],b=[],x=[],_=0,w=m.length;_<w;_++){var C=m[_],S=Et[i].buildGeometry(C,{radius:c,gap:f}),k=n.colorPick.add(C),A=M.triangles([S],{style:v,index:_,pickColor:k},{lngLatToCoord:function(t){return t}},n.hasSide),z=g.vertex.length;y.push(z),b.push(z+A.S.C),x.push(z+A.S.top),t.Geometry.mergeTriangles(g,A),Lt(g.color,A.color),Lt(g.pickColor,A.pickColor),Lt(g.normal,A.normal),Lt(g.topOrBottom,A.topOrBottom)}g.vertex.length,s[d]={id:e[d].id,attributes:{color:{buffer:this.regl.buffer(g.color),offset:0,P:16,_:!1,divisor:0},pickColor:{buffer:this.regl.buffer(g.pickColor),offset:0,P:16,_:!1,divisor:0},position:{buffer:this.regl.buffer(g.vertex),offset:0,P:12,_:!1,divisor:0},topOrBottom:{buffer:this.regl.buffer(g.topOrBottom),offset:0,P:4,_:!1,divisor:0},normal:{buffer:this.regl.buffer(g.normal),offset:0,P:12,_:!1,divisor:0},index:this.regl.elements({primitive:"triangles",type:"uint32",data:g.index})},uniforms:{},g:v.g}}return s},r.prototype.updateStyle=function(t,e){for(var r=0,n=t.length;r<n;r++){for(var i=t[r],o=e[r].attributes,a=o.altitude,s=o.height,l=o.topColor,u=o.bottomColor,c=o.sideColor,f=i.k.origin,h=f.position,d=f.color,p=i.k.S,m=p.top,v=p.bottom,g=p.C,y=p.W,b=0,x=0,_=0,w=h.length;_<w;_+=3){var C=_/3*4,S=void 0;_>=y[b]&&b++;var k=4*b;_>=v[x+1]&&x++,_<g[x]?(S=u,h[_+2]=a[b]):_>=g[x]&&_<m[x]?((_-g[x])/3%2==0?h[_+2]=a[b]:h[_+2]=s[b],S=c):(S=l,h[_+2]=s[b]),d[C]=S[k],d[C+1]=S[k+1],d[C+2]=S[k+2],d[C+3]=S[k+3]}i.attributes.position.buffer({data:h}),i.attributes.color.buffer({data:d})}},r.prototype.updateFrame=function(t,e,r,n){return void 0===n&&(n="grid"),"meter"===e.unit?[]:t&&t.length>0?this.fusion(t,e,r,n):void 0},r.prototype.destroy=function(){this.regl=null},r.m=new r,r}(t.GeometryFusion);Dt.getInstance();var Rt={vertex:"\n        precision highp float;\n\n        attribute vec3 position;\n        attribute vec3 normal;\n        attribute vec4 color;\n        attribute float topOrBottom;\n\n        varying vec3 vNormal;\n        varying vec4 vColor;\n        varying vec3 vPosition;\n\n        uniform mat4 mvp;\n        uniform float heightScale;\n        uniform float altitudeScale;\n        "+t.ColorGLSL.getColorShader().vertex+"\n\n        void main() {\n            // 动画\n            vec3 realPos = position;\n            if(topOrBottom == 0.0) {\n                realPos = vec3(position.xy, position.z * altitudeScale);\n            }\n            if(topOrBottom == 1.0) {\n                realPos = vec3(position.xy, position.z * heightScale);\n            }\n            vColor = color;\n            vNormal = normal;\n            vPosition = realPos;\n            gl_Position = mvp * vec4(realPos, 1.0);\n            "+t.ColorGLSL.getColorShader().mainVert+"\n        }\n    ",fragment:"\n        precision highp float;\n        varying vec4 vColor;\n\n        // 如果需要光照，这两个变量是必须的\n        varying vec3 vNormal;\n        varying vec3 vPosition;\n\n        uniform float opacity;\n\n        "+t.Light.getLightShader()+"\n        "+t.ColorGLSL.getColorShader().fragment+"\n\n        void main() {\n            gl_FragColor = vColor;\n            if(acceptLight) {\n                gl_FragColor.rgb = lightColor(gl_FragColor.rgb);\n            }\n\n            gl_FragColor.a *= opacity;\n            "+t.ColorGLSL.getColorShader().mainFrag+"\n        }\n    "},It=function(){function e(t){this.regl=t,this.createCmd()}return e.getInstance=function(){return this.m},e.prototype.createCmd=function(){if(this.regl){var e=this.regl;this.lt=e({frag:Rt.fragment,vert:Rt.vertex,attributes:c({position:e.prop("position"),color:e.prop("color"),normal:e.prop("normal"),topOrBottom:e.prop("topOrBottom")},t.ColorGLSL.getColor(e).attribute),uniforms:c(c({mvp:e.prop("mvp"),opacity:e.prop("opacity"),heightScale:e.prop("heightScale"),altitudeScale:e.prop("altitudeScale")},t.Light.getLights(e)),t.ColorGLSL.getColor(e).uniform),blend:{enable:!0,func:E()},cull:{enable:e.prop("cullEnable"),face:e.prop("cullface")},depth:{enable:e.prop("depth"),func:"lequal"},frontFace:"cw",colorMask:e.prop("colorMask"),elements:e.prop("index")})}},e.prototype.render=function(t,e){if(this.regl){this.lt||this.createCmd();for(var r=e.mvp,n=e.depth,i=e.shininess,o=e.acceptLight,a=e.cullface,s=e.opacity,l=e.cameraPosition,u=e.V,f=e.M,h="none"!==a,d="front"===a?"front":"back",p=f.height,m=f.altitude,v=0;v<t.length;v++){var g=t[v].attributes;this.lt(c(c(c({},g),u),{depth:n,shininess:i,acceptLight:o,cullEnable:h,cullface:d,opacity:s,cameraPosition:l,count:g.index.length,mvp:r,colorMask:[!1,!1,!1,!1],isPick:!1,heightScale:p,altitudeScale:m}))}for(v=0;v<t.length;v++)g=t[v].attributes,this.lt(c(c(c({},g),u),{depth:n,shininess:i,acceptLight:o,cullEnable:h,cullface:d,opacity:s,cameraPosition:l,count:g.index.length,mvp:r,colorMask:[!0,!0,!0,!0],isPick:!1,heightScale:p,altitudeScale:m}))}},e.prototype.pickRender=function(t,e){var r=this;if(this.regl){this.lt||this.createCmd();var n=e.mvp,i=e.depth,o=e.shininess,a=e.acceptLight,s=e.cullface,l=e.opacity,u=e.cameraPosition,f=e.V,h=e.pickFbo,d=e.M,p="none"!==s,m="front"===s?"front":"back",v=d.height,g=d.altitude;h&&h.use((function(){r.regl.clear({color:[0,0,0,0],depth:1});for(var e=0;e<t.length;e++){var s=t[e].attributes;r.lt(c(c(c({},s),f),{depth:i,shininess:o,acceptLight:a,cullEnable:p,cullface:m,opacity:l,cameraPosition:u,count:s.index.length,mvp:n,colorMask:[!0,!0,!0,!0],isPick:!0,heightScale:v,altitudeScale:g}))}}))}},e.prototype.destroy=function(){this.regl=null,this.lt=null},e.m=new e,e}();It.getInstance();var Ft=t.Util.CommonUtil.pushArray,Bt=function(t){function e(e){var r=t.call(this,e)||this;r.CLASS_NAME="Grid",r.fusion=new Dt,r.B=new It,r._animateLayerState={altitude:1,height:1};var n=b.v;return r.zooms=void 0===e.zooms?n.zooms:e.zooms,r.visible=void 0===e.visible?n.visible:e.visible,r.zIndex=void 0===e.zIndex?n.zIndex:e.zIndex,r.opacity=void 0===e.opacity?n.opacity:e.opacity,r.shininess=void 0===e.shininess?n.shininess:e.shininess,r.acceptLight=void 0===e.acceptLight?n.acceptLight:e.acceptLight,r.cullface=e.cullface||n.cullface,r.hasSide=void 0===e.hasSide?n.hasSide:e.hasSide,r.depth=void 0===e.depth?n.depth:e.depth,r.createGLLayer(e),r.buryPoint.record(r.CLASS_NAME),r}return u(e,t),e.prototype.receiveDataset=function(t){this.dataset=t,this.setStyle(this.styleOptions),this.onAdd()},e.prototype.setStyle=function(e){if(e.unit=e.unit||"meter",t.prototype.setStyle.call(this,e),this.dataset=this.source.getDataset(),this.colorPick.clear(),this.dataset&&this.dataset.length>0&&this.meshes){var r=this.filterDataset().willFusion;this.meshes=this.fusion.fusion(r,this.styleOptions,this),this.loca&&this.loca.requestRender()}},e.prototype.createRenderer=function(){t.prototype.createRenderer.call(this),this.loca&&this.loca.regl&&!this.B.regl&&(this.B.regl=this.loca.regl,this.loca.rendererManager.addRenderer(this.B))},e.prototype.beforeRender=function(){if(t.prototype.beforeRender.call(this),!this.fusion.regl&&this.loca&&(this.fusion.regl=this.loca.regl,this.loca.fusionManager.addFusion(this.fusion)),this.createRenderer(),this.source&&(this.dataset=this.source.getDataset()),this.fusion){var e=this.filterDataset(),r=e.willFusion,n=e.didFusion,i=e.didFusionDataset,o=this.fusion.updateFrame(i,this.styleOptions,this);"px"===this.styleOptions.unit?this.meshes=o||[]:this.meshes=n||[],r.length>0&&(this.meshes=Ft(this.meshes,this.fusion.fusion(r,this.styleOptions,this)))}},e.prototype.render=function(){var t;if(this.loca&&this.loca.regl){this.loca.regl._refresh();var e=null===(t=this.loca)||void 0===t?void 0:t.customCoords.getMVPMatrix(),r=this.loca.getLights();this.B&&this.meshes.length>0&&this.B.render(this.meshes,{mvp:e,V:r,cameraPosition:this.loca.customCoords.getCameraParams().position,shininess:this.shininess,acceptLight:this.acceptLight,opacity:this._getOpacity(),depth:this.depth,cullface:this.cullface,M:this._animateLayerState})}},e.prototype.pickRender=function(){var t;if(this.loca&&this.loca.regl){this.loca.regl._refresh();var e=null===(t=this.loca)||void 0===t?void 0:t.customCoords.getMVPMatrix(),r=this.loca.getLights();this.B&&this.B.pickRender(this.meshes,{mvp:e,V:r,cameraPosition:this.loca.customCoords.getCameraParams().position,shininess:this.shininess,acceptLight:this.acceptLight,opacity:this._getOpacity(),depth:this.depth,cullface:this.cullface,pickFbo:this._needPickFrame&&this._pickFbo,pickPos:this._pickPos,M:this._animateLayerState})}},e.prototype.afterRender=function(){},e}(t.Layer);a.default.GridLayer=Bt;var jt=t.Util.CommonUtil.pushArray,Vt=function(t){function e(e){var r=t.call(this,e)||this;r.CLASS_NAME="Hexagon",r.fusion=new Dt,r.B=new It,r._animateLayerState={altitude:1,height:1};var n=x.v;return r.zooms=void 0===e.zooms?n.zooms:e.zooms,r.zIndex=void 0===e.zIndex?n.zIndex:e.zIndex,r.opacity=void 0===e.opacity?n.opacity:e.opacity,r.visible=void 0===e.visible?n.visible:e.visible,r.shininess=void 0===e.shininess?n.shininess:e.shininess,r.acceptLight=void 0===e.acceptLight?n.acceptLight:e.acceptLight,r.cullface=e.cullface||n.cullface,r.hasSide=void 0===e.hasSide?n.hasSide:e.hasSide,r.depth=void 0===e.depth?n.depth:e.depth,r.createGLLayer(e),r.buryPoint.record(r.CLASS_NAME),r}return u(e,t),e.prototype.receiveDataset=function(t){this.dataset=t,this.setStyle(this.styleOptions),this.onAdd()},e.prototype.setStyle=function(e){if(e.unit=e.unit||"meter",t.prototype.setStyle.call(this,e),this.dataset=this.source.getDataset(),this.colorPick.clear(),this.dataset&&this.dataset.length>0&&this.meshes){var r=this.filterDataset().willFusion;this.meshes=this.fusion.fusion(r,this.styleOptions,this,"hexagon"),this.loca&&this.loca.requestRender()}},e.prototype.createRenderer=function(){t.prototype.createRenderer.call(this),this.loca&&this.loca.regl&&!this.B.regl&&(this.B.regl=this.loca.regl,this.loca.rendererManager.addRenderer(this.B))},e.prototype.beforeRender=function(){if(t.prototype.beforeRender.call(this),!this.fusion.regl&&this.loca&&(this.fusion.regl=this.loca.regl,this.loca.fusionManager.addFusion(this.fusion)),this.createRenderer(),this.source&&(this.dataset=this.source.getDataset()),this.fusion){var e=this.filterDataset(),r=e.willFusion,n=e.didFusion,i=e.didFusionDataset,o=this.fusion.updateFrame(i,this.styleOptions,this,"hexagon");"px"===this.styleOptions.unit?this.meshes=o||[]:this.meshes=n||[],r.length>0&&(this.meshes=jt(this.meshes,this.fusion.fusion(r,this.styleOptions,this,"hexagon")))}},e.prototype.render=function(){var t;if(this.loca&&this.loca.regl){this.loca.regl._refresh();var e=null===(t=this.loca)||void 0===t?void 0:t.customCoords.getMVPMatrix(),r=this.loca.getLights();this.B&&this.meshes.length>0&&this.B.render(this.meshes,{mvp:e,V:r,cameraPosition:this.loca.customCoords.getCameraParams().position,shininess:this.shininess,acceptLight:this.acceptLight,opacity:this._getOpacity(),depth:this.depth,cullface:this.cullface,M:this._animateLayerState})}},e.prototype.pickRender=function(){var t;if(this.loca&&this.loca.regl){this.loca.regl._refresh();var e=null===(t=this.loca)||void 0===t?void 0:t.customCoords.getMVPMatrix(),r=this.loca.getLights();this.B&&this.B.pickRender(this.meshes,{mvp:e,V:r,cameraPosition:this.loca.customCoords.getCameraParams().position,shininess:this.shininess,acceptLight:this.acceptLight,opacity:this._getOpacity(),depth:this.depth,cullface:this.cullface,pickFbo:this._needPickFrame&&this._pickFbo,pickPos:this._pickPos,M:this._animateLayerState})}},e.prototype.afterRender=function(){},e}(t.Layer);a.default.HexagonLayer=Vt;var Nt=t.Util.CommonUtil.pushArray,Ut=function(e){function r(){return null!==e&&e.apply(this,arguments)||this}return u(r,e),r.getInstance=function(){return this.m},r.prototype.buildStyle=function(e,r){for(var n=g.style,i=[],o=0;o<e.length;o++)if(e[o].features&&e[o].features.points){var a=e[o].features.points,s=t.StyleInstance.parse(a,r,n);i.push(s)}return i},r.prototype.buildGeometry=function(){},r.prototype.fusion=function(t,e,r,n){if(!this.regl)return[];if(!r.loca)return[];n=n||this.buildStyle(t,e);for(var i=r.loca.customCoords.lngLatToCoord.bind(r.loca.customCoords),o=[],a=0,s=t.length;a<s;a++){var l=t[a];if(l.features&&l.features.points&&n[a]){for(var u=n[a].attributes,c=l.features.points,f={vertex:[],color:[],radius:[],blurWidth:[],borderColor:[],borderWidth:[],pickColor:[]},h=0;h<c.length;h++){var d=c[h],p=d.coordinates,m=r.colorPick.add(d);if("MultiPoint"===d.type)for(var v=0,g=p.length;v<g;v++){var y=i(p[v]);Nt(f.vertex,y),Nt(f.color,u.color[h]),Nt(f.borderColor,u.borderColor[h]),Nt(f.pickColor,m),f.radius.push(u.radius[h]),f.blurWidth.push(u.blurWidth[h]),f.borderWidth.push(u.borderWidth[h])}else y=i(p),Nt(f.vertex,y),Nt(f.color,u.color[h]),Nt(f.borderColor,u.borderColor[h]),Nt(f.pickColor,m),f.radius.push(u.radius[h]),f.blurWidth.push(u.blurWidth[h]),f.borderWidth.push(u.borderWidth[h])}o[a]={status:"buffered",id:l.id,attributes:{position:{buffer:this.regl.buffer(f.vertex),offset:0,P:8,_:!1,divisor:0},radius:{buffer:this.regl.buffer(f.radius),offset:0,P:4,_:!1,divisor:0},color:{buffer:this.regl.buffer(f.color),offset:0,P:16,_:!1,divisor:0},borderWidth:{buffer:this.regl.buffer(f.borderWidth),offset:0,P:4,_:!1,divisor:0},borderColor:{buffer:this.regl.buffer(f.borderColor),offset:0,P:16,_:!1,divisor:0},blurWidth:{buffer:this.regl.buffer(f.blurWidth),offset:0,P:4,_:!1,divisor:0},pickColor:{buffer:this.regl.buffer(f.pickColor),offset:0,P:16,_:!1,divisor:0}},uniforms:n[a].uniforms,g:n[a].g,k:{count:f.radius.length}}}}return o},r.prototype.updateFrame=function(t){},r.prototype.destroy=function(){this.regl=null},r.m=new r,r}(t.GeometryFusion);Ut.getInstance();var Gt={point:{vertex:"\n            precision highp float;\n\n            uniform mat4 mvp;\n            uniform float resolution;\n            // unit: px=0, meter=1\n            uniform float unit;\n            uniform float ratio;\n            // 动画\n            uniform float radiusScale;\n\n            attribute vec2 position;\n            attribute float radius;\n            attribute vec4 color;\n            attribute float borderWidth;\n            attribute vec4 borderColor;\n            attribute float blurWidth;\n\n            varying float vRadius;\n            varying vec4 vColor;\n            varying float vBorderWidth;\n            varying vec4 vBorderColor;\n            varying float vBlurRadius;\n            "+t.ColorGLSL.getColorShader().vertex+"\n\n            void main() {\n                float res = (unit == 1.0 ? resolution : 1.0) / ratio;\n                gl_Position = mvp * vec4(position.xy, 0, 1);\n                vRadius = radius / res * radiusScale;\n                vColor = color;\n                vBorderWidth = borderWidth / res * radiusScale;\n                vBorderColor = borderColor;\n                vBlurRadius = blurWidth / res * radiusScale;\n                gl_PointSize = (vRadius + vBorderWidth) * 2.0 * radiusScale;\n                "+t.ColorGLSL.getColorShader().mainVert+"\n            }\n        ",fragment:"\n            precision highp float;\n            uniform float layerOpacity;\n            \n            varying float vRadius;\n            varying vec4 vColor;\n            varying float vBorderWidth;\n            varying vec4 vBorderColor;\n            varying float vBlurRadius;\n            "+t.ColorGLSL.getColorShader().fragment+"\n\n            void main() {\n                gl_FragColor = vColor;\n                // 抗锯齿像素位\n                float realRadius = vRadius + vBorderWidth;\n                float len = distance(gl_PointCoord, vec2(0.5, 0.5)) * 2.0 * realRadius;\n                float taaRadius = 2.0;\n                if(len > realRadius) {\n                    discard;\n                } else if(len > realRadius - taaRadius) {\n                    gl_FragColor = vBorderWidth > 0.0 ? vBorderColor : vColor;\n                    float opa = smoothstep(1.0, 0.0, (len - (realRadius - taaRadius)) / taaRadius);\n                    gl_FragColor.a *= opa;\n                } else if(vBorderWidth > 0.0 && len > vRadius + taaRadius) {\n                    gl_FragColor = vBorderColor;\n                } else if(vBorderWidth > 0.0 && len > vRadius) {\n                    float blend = smoothstep(0.0, 1.0, (len - vRadius / taaRadius) / taaRadius);\n                    gl_FragColor = mix(vColor, vBorderColor, blend);\n                }\n                // float opacity_t = 1. - smoothstep(u_range[1] - 1. / u_radius, u_range[1], offset);\n\n                if(vBlurRadius >= 0.0 && len > (realRadius - vBlurRadius)) {\n                    gl_FragColor.a = smoothstep(1.0, 0.0, (len - (realRadius - vBlurRadius)) / vBlurRadius);\n                }\n                // gl_FragColor.a *= layerOpacity;\n\n                "+t.ColorGLSL.getColorShader().mainFrag+"\n            }\n        "},yt:{vertex:"\n            precision highp float;\n\n            attribute float position;\n            varying vec2 vUv;\n\n            struct UvPos {\n                vec2 uv;\n                vec2 pos;\n            };\n\n            // 获取坐标\n            UvPos getPos(float type) {\n                UvPos result;\n                vec2 uv = vec2(1);\n                vec2 pos = vec2(1);\n                if(type == 0.0) {\n                    uv = vec2(0, 0);\n                    pos = vec2(-1, -1);\n                } else if(type == 1.0) {\n                    uv = vec2(0, 1);\n                    pos = vec2(-1, 1);\n                } else if(type == 2.0) {\n                    uv = vec2(1, 0);\n                    pos = vec2(1, -1);\n                }\n                result.uv = uv;\n                result.pos = pos;\n                return result;\n            }\n\n            void main() {\n                UvPos res = getPos(position);\n                gl_Position = vec4(res.pos, 0, 1);\n                vUv = res.uv;\n            }\n        ",fragment:"\n            precision highp float;\n\n            varying vec2 vUv;\n\n            uniform float layerOpacity;\n            uniform sampler2D texture;\n\n            void main() {\n                gl_FragColor = texture2D(texture, vUv);\n                gl_FragColor.a *= layerOpacity;\n            }\n        "}},Wt=function(){function e(t){this.regl=t,this.createCmd()}return e.getInstance=function(){return this.m},e.prototype.createCmd=function(){if(this.regl){var e=this.regl;this.xt=e.framebuffer({width:e._gl.drawingBufferWidth,height:e._gl.drawingBufferHeight,stencil:!1}),this.lt=e({frag:Gt.point.fragment,vert:Gt.point.vertex,attributes:c({position:e.prop("position"),radius:e.prop("radius"),color:e.prop("color"),borderWidth:e.prop("borderWidth"),borderColor:e.prop("borderColor"),blurWidth:e.prop("blurWidth")},t.ColorGLSL.getColor(e).attribute),primitive:"points",uniforms:c({mvp:e.prop("mvp"),resolution:e.prop("resolution"),unit:e.prop("unit"),ratio:window.AMap.Browser.retina?2:1,radiusScale:e.prop("radiusScale")},t.ColorGLSL.getColor(e).uniform),depth:{enable:!1},blend:{enable:!0,func:e.prop("blend")},count:e.prop("count")}),this.Ct=e({frag:Gt.yt.fragment,vert:Gt.yt.vertex,attributes:{position:[0,1,2,3]},uniforms:{texture:e.prop("texture"),layerOpacity:e.prop("layerOpacity")},depth:{enable:!1},blend:{enable:!0,func:e.prop("blend")},elements:[0,1,2,1,3,2],count:6})}},e.prototype.render=function(t){var e=this,r=t.meshes,n=t.mvp,i=t.layerOpacity,o=t.resolution,a=t.blend,s=t.M;if(this.regl&&!(r.length<1)){this.lt||this.createCmd(),this.xt.width===this.regl._gl.drawingBufferWidth&&this.xt.height===this.regl._gl.drawingBufferHeight||this.xt({width:this.regl._gl.drawingBufferWidth,height:this.regl._gl.drawingBufferHeight});for(var l=function(t){var l=r[t],f=l.attributes,h=l.uniforms,d=l.k.count;u.xt.use((function(){e.regl.clear({color:[0,0,0,0],depth:1}),e.lt(c(c({},f),{unit:"px"===h.unit?0:1,count:d,resolution:o,layerOpacity:i,mvp:n,blend:E(a),isPick:!1,radiusScale:s.radius}))})),u.Ct(c(c({},f),{texture:u.xt,layerOpacity:i,blend:E("normal")}))},u=this,f=0;f<r.length;f++)l(f)}},e.prototype.pickRender=function(t){var e=this,r=t.meshes,n=t.mvp,i=t.layerOpacity,o=t.resolution,a=t.pickFbo,s=t.pickPos,l=t.M;!this.regl||r.length<1||(this.regl._refresh(),this.lt||this.createCmd(),a&&s&&a.use((function(){e.regl.clear({color:[0,0,0,0]});for(var t=0;t<r.length;t++){var a=r[t],s=a.attributes,u=a.uniforms,f=a.k.count;e.lt(c(c({},s),{unit:"px"===u.unit?0:1,count:f,resolution:o,layerOpacity:i,mvp:n,blend:E("normal"),isPick:!0,radiusScale:l.radius}))}})))},e.prototype.destroy=function(){this.regl=null,this.lt=null,this.Ct=null,this.xt.destroy()},e.m=new e,e}();Wt.getInstance();var qt=t.Util.CommonUtil.pushArray,Ht=function(t){function e(e){var r=t.call(this,e)||this;r.CLASS_NAME="Point",r.fusion=new Ut,r.B=new Wt,r._animateLayerState={radius:1},r.zt=!1;var n=g.v;return r.zooms=void 0===e.zooms?n.zooms:e.zooms,r.visible=void 0===e.visible?n.visible:e.visible,r.zIndex=void 0===e.zIndex?n.zIndex:e.zIndex,r.opacity=void 0===e.opacity?n.opacity:e.opacity,r.blend=void 0===e.blend?n.blend:e.blend,r.createGLLayer(e),r.buryPoint.record(r.CLASS_NAME),r}return u(e,t),e.prototype.setStyle=function(e){t.prototype.setStyle.call(this,e),this.dataset=this.source.getDataset(),this.zt=!0,this.colorPick.clear(),this.dataset&&this.dataset.length>0&&this.loca&&this.loca.requestRender()},e.prototype.receiveDataset=function(t){this.dataset=t,this.setStyle(this.styleOptions),this.onAdd()},e.prototype.createRenderer=function(){t.prototype.createRenderer.call(this),this.loca&&this.loca.regl&&!this.B.regl&&(this.B.regl=this.loca.regl,this.loca.rendererManager.addRenderer(this.B))},e.prototype.beforeRender=function(){if(t.prototype.beforeRender.call(this),!this.fusion.regl&&this.loca&&(this.fusion.regl=this.loca.regl,this.loca.fusionManager.addFusion(this.fusion)),this.createRenderer(),this.source&&(this.dataset=this.source.getDataset()),this.fusion){var e=this.filterDataset(),r=e.willFusion,n=e.didFusion,i=e.didFusionDataset;if(this.zt?(this.meshes=this.fusion.fusion(i,this.styleOptions,this),this.zt=!1):this.zt||(this.meshes=n),r.length>0){var o=this.fusion.fusion(r,this.styleOptions,this);this.meshes=qt(this.meshes,o)}}},e.prototype.render=function(){var t,e;if(this.loca&&this.loca.regl){this.loca.regl._refresh();var r=null===(t=this.loca)||void 0===t?void 0:t.customCoords.getMVPMatrix(),n=this.projection.getResolution(null===(e=this.loca)||void 0===e?void 0:e.map.getZoom());this.B&&this.meshes.length>0&&this.B.render({meshes:this.meshes,mvp:r,resolution:n,layerOpacity:this._getOpacity(),blend:this.blend,M:this._animateLayerState})}},e.prototype.pickRender=function(){var t,e;if(this.loca&&this.loca.regl){this.loca.regl._refresh();var r=this.projection.getResolution(null===(t=this.loca)||void 0===t?void 0:t.map.getZoom()),n=null===(e=this.loca)||void 0===e?void 0:e.customCoords.getMVPMatrix();this.B&&this.meshes.length>0&&this.B.pickRender({meshes:this.meshes,resolution:r,layerOpacity:this._getOpacity(),pickFbo:this._needPickFrame&&this._pickFbo,pickPos:this._pickPos,mvp:n,M:this._animateLayerState})}},e.prototype.afterRender=function(){},e.prototype.destroy=function(){t.prototype.destroy.call(this),this.B.regl=null},e}(t.Layer);function Zt(t,e,r){var n=t.images,i=t.St,o=void 0===i?[64,64]:i;if(!Array.isArray(n))throw new Error("must be called with an array of iconSrcs to concatenate");var a=n.map((function(t){try{if(t instanceof SVGSVGElement){var e=(n=t.outerHTML,i=new Blob([n],{type:"image/svg+xml;charset=utf-8"}),(window.URL||window.webkitURL||window).createObjectURL(i));return(r=new Image).src=e,r}return t instanceof Image?t:((r=new Image).src=t,r);var r}catch(t){throw t}var n,i})).filter((function(t){return t&&t instanceof Image})).map((function(t){return new Promise((function(e,n){try{t.onerror=function(t){r&&r(t)},t.crossOrigin="anonymous",t.onload=function(){e(t)},t.complete&&e(t)}catch(t){n(t)}}))}));return Promise.all(a).then((function(t){!function(t,e){var r=t.images,n=t.St,i=void 0===n?[64,64]:n,o=i[0],a=i[1],s=r.reduce((function(t,e){return t+o}),0),l=document.createElement("canvas");l.width=s,l.height=a;for(var u=l.getContext("2d"),c=0,f=[],h=0;h<r.length;h++){var d=r[h];u.drawImage(d,c,0,o,a);var p={width:o,height:a,Pt:d,x:c,y:0};c+=o,f.push(p)}l.toBlob((function(t){var r=document.createElement("img"),n=URL.createObjectURL(t);r.onload=function(){URL.revokeObjectURL(n),e({blob:t,Pt:r,canvas:l,_t:f})},r.src=n}))}({images:t,St:o},(function(t){e(t)}))})).catch((function(t){r&&r(t)}))}function Qt(t,e,r){var n=t.images,i=t.St,o=void 0===i?[64,64]:i,a=new Map,s=[],l=n.map((function(t){return function(t,e,r){var n=-1,i=t;return e.has(i)?n=e.get(i):(i=t,t instanceof SVGSVGElement?i=(new XMLSerializer).serializeToString(t):t instanceof Image&&(i=t.src),e.has(i)?n=e.get(i):(r.push(t),n=r.length-1,e.set(i,n))),n}(t,a,s)}));Zt({images:s,St:o},(function(t){var r=t._t,n=l.map((function(t){return r[t]}));t._t=n,e&&e(t)}),(function(t){r&&r(t)}))}a.default.PointLayer=Ht;var Xt=t.Util.CommonUtil.pushArray,Yt=function(e){function r(){var t=null!==e&&e.apply(this,arguments)||this;return t.wt={},t}return u(r,e),r.getInstance=function(){return this.m},r.prototype.buildStyle=function(e,r){for(var n=y.style,i=[],o=0;o<e.length;o++)if(e[o].features&&e[o].features.points){for(var a=e[o].features.points,s=t.StyleInstance.parse(a,r,n),l={},u=0;u<a.length;u++)if(s)for(var c in s.attributes){var f=s.attributes[c];l[c]||(l[c]=[]),"string"==typeof f[u]?Xt(l[c],[f[u]]):f[u].length>0?Xt(l[c],f[u]):l[c][l[c].length]=f[u]}i.push({attributes:l,uniforms:s.uniforms,g:s.g})}return i},r.prototype.buildGeometry=function(){},r.prototype.fusion=function(t,e,r,n){if(!this.regl)return[];if(!r.loca)return[];n=n||this.buildStyle(t,e);var i=[];return e&&t&&t.length&&(i=this.kt({dataset:t,styleOptions:e,v:r,Wt:n})),i},r.prototype.Dt=function(t,e){var r=e.Vt(),n=r.Mt,i=r.Bt,o=null,a=t;return i.has(a)?o=i.get(a):(t instanceof SVGSVGElement?a=(new XMLSerializer).serializeToString(t):t instanceof Image?a=t.src:"string"==typeof t&&(a=t),i.has(a)?o=i.get(a):(n.push(t),o=n.length-1,i.set(a,o))),o},r.prototype.kt=function(t){for(var e,r=this,n=t.dataset,i=t.Wt,o=t.v,a=[],s=null===(e=null==o?void 0:o.loca)||void 0===e?void 0:e.customCoords,l=function(t){var e=t.Rt,n=t.style,i=t.vt,a=t.pickColor,l=s.lngLatToCoord(i);Xt(e.position,l),Xt(e.iconSize,n.iconSize);var u=n.rotation/180*Math.PI;Xt(e.rotation,[u]),Xt(e.opacity,[n.opacity]);var c=r.Dt(n.icon,o);Xt(e.iconIndex,[c]),Xt(e.pickColor,a)},u=0;u<n.length;u++){var c=n[u];if(c.features&&c.features.points){for(var f=c.features.points,h=i[u],d={position:[],iconIndex:[],iconSize:[],rotation:[],opacity:[],pickColor:[]},p=0;p<f.length;p++){var m=f[p],v=null==m?void 0:m.coordinates,g=o.colorPick.add(m),y={icon:h.attributes.icon[p],iconSize:h.attributes.iconSize.slice(2*p,2*p+2),rotation:h.attributes.rotation[p],opacity:h.attributes.opacity[p]};if(v&&v.length)if("MultiPoint"==m.type)for(var b=0;b<v.length;b++)l({Rt:d,style:y,vt:v[b],pickColor:g});else l({Rt:d,style:y,vt:v,pickColor:g})}a[u]={id:c.id,attributes:{position:{buffer:this.regl.buffer(d.position),offset:0,P:8,_:!1,divisor:0},iconIndex:{buffer:this.regl.buffer(d.iconIndex),offset:0,P:4,_:!1,divisor:0},iconSize:{buffer:this.regl.buffer(d.iconSize),offset:0,P:8,_:!1,divisor:0},rotation:{buffer:this.regl.buffer(d.rotation),offset:0,P:4,_:!1,divisor:0},opacity:{buffer:this.regl.buffer(d.opacity),offset:0,P:4,_:!1,divisor:0},pickColor:{buffer:this.regl.buffer(d.pickColor),offset:0,P:16,_:!1,divisor:0}},uniforms:h.uniforms,g:h.g,k:{count:d.position.length/2}}}}return a},r.prototype.updateFrame=function(){},r.prototype.destroy=function(){this.regl=null},r.m=new r,r}(t.GeometryFusion);Yt.getInstance();var Jt={Ft:"\n        precision highp float;\n\n        uniform mat4 mvp;\n        uniform float iconCount;\n        uniform float resolution;\n        // unit: px=0, meter=1\n        uniform float unit;\n        uniform float ratio;\n        uniform float radiusScale;\n\n        attribute vec2 position;\n        attribute vec2 iconSize;\n        attribute float rotation;\n        attribute float opacity;\n        attribute float iconIndex;\n\n        varying vec2 v_size;\n        varying float v_rotation;\n        varying float v_opacity;\n        varying vec2 v_texture_coord;\n        "+t.ColorGLSL.getColorShader().vertex+"\n\n        void main() {\n            float res = 1.0;\n            if(unit == 1.0) {\n                res = resolution;\n            }\n\n            gl_Position = mvp * vec4(position.xy, 0, 1);\n            v_texture_coord = vec2(1.0 / iconCount * iconIndex, 0.0);\n\n            // 计算 xy 的相对值\n            v_size = iconSize.xy / res * ratio * radiusScale;\n            float dist = sqrt(v_size.x * v_size.x + v_size.y * v_size.y);\n            v_size.x = v_size.x / dist * v_size.x;\n            v_size.y = v_size.y / dist * v_size.y;\n\n            v_rotation = rotation;\n            v_opacity = opacity;\n            gl_PointSize = dist;\n            "+t.ColorGLSL.getColorShader().mainVert+"\n        }\n    ",fragment:"\n        precision highp float;\n        uniform sampler2D texture;\n        // uniform float resolution;\n        uniform float layerOpacity;\n        uniform float iconCount;\n\n        varying vec2 v_size;\n        varying float v_rotation;\n        varying float v_opacity;\n        varying vec2 v_texture_coord;\n        "+t.ColorGLSL.getColorShader().fragment+"\n\n        vec2 rotateUV(vec2 uv, float arc, vec2 mid){\n            return vec2(\n                cos(arc) * (uv.x - mid.x) + sin(arc) * (uv.y - mid.y) + mid.x,\n                cos(arc) * (uv.y - mid.y) - sin(arc) * (uv.x - mid.x) + mid.y\n            );\n        }\n\n        vec2 reductTextureCoord(vec2 texture_coord, float arc){\n            vec2 inner_xy = rotateUV(texture_coord, arc, vec2(0.5, 0.5));\n            vec2 t_xy = sqrt(2.0) * (inner_xy - vec2(0.5, 0.5)) + vec2(0.5,0.5);\n            return t_xy;\n        }\n\n        void main() {\n            vec2 txture_partial_size = vec2(1.0 / iconCount, 1);\n            gl_FragColor = vec4(0,0,0,1.0);\n\n            float maxSize = max(v_size.x, v_size.y);\n            vec2 uv = vec2(\n                gl_PointCoord.x / v_size.x * maxSize,\n                gl_PointCoord.y / v_size.y * maxSize\n            );\n            vec2 ruv = reductTextureCoord(uv, v_rotation);\n            float flag1 = step(float(ruv.x), 0.0);\n            float flag2 = step(1.0, float(ruv.x));\n            float flag3 = step(1.0, float(ruv.y));\n            float flag4 = step(float(ruv.y), 0.0);\n            float invalid = flag1 + flag2 + flag3 + flag4;\n            vec2 _uv = txture_partial_size * ruv;\n            vec2 coord = v_texture_coord + _uv;\n            vec4 t_clr = texture2D(texture, coord);\n            gl_FragColor = (1.0 - invalid) * t_clr;\n            gl_FragColor.a *= (v_opacity * layerOpacity);\n            "+t.ColorGLSL.getColorShader().mainFrag+"\n        }\n    "},Kt=function(){function e(t){this.regl=t,this.createCmd()}return e.getInstance=function(){return this.m},e.prototype.createCmd=function(){if(this.regl){var e=this.regl;this.D=e({frag:Jt.fragment,vert:Jt.Ft,attributes:c({position:e.prop("position"),iconIndex:e.prop("iconIndex"),iconSize:e.prop("iconSize"),rotation:e.prop("rotation"),opacity:e.prop("opacity")},t.ColorGLSL.getColor(e).attribute),uniforms:c({mvp:e.prop("mvp"),resolution:e.prop("resolution"),texture:e.prop("texture"),iconCount:e.prop("iconCount"),layerOpacity:e.prop("layerOpacity"),unit:e.prop("unit"),radiusScale:e.prop("radiusScale"),ratio:window.AMap.Browser.retina?2:1},t.ColorGLSL.getColor(e).uniform),depth:{enable:!1},blend:{enable:!0,func:E("normal")},count:e.prop("count"),primitive:"points"})}},e.prototype.render=function(t){var e=t.meshes,r=t.mvp,n=t.layerOpacity,i=t.resolution,o=t.texture,a=t.iconCount,s=t.M;if(this.regl&&!(e.length<1)){this.D||this.createCmd();for(var l=0;l<e.length;l++){var u=e[l],f=u.attributes,h=u.uniforms,d=u.k.count;this.D(c(c(c({},f),h),{unit:"px"===h.unit?0:1,count:d,resolution:i,layerOpacity:n,iconCount:a,texture:o,mvp:r,isPick:!1,radiusScale:s.radius}))}}},e.prototype.pickRender=function(t){var e=this,r=t.meshes,n=t.mvp,i=t.layerOpacity,o=t.resolution,a=t.texture,s=t.iconCount,l=t.pickFbo,u=t.pickPos,f=t.M;!this.regl||r.length<1||(this.D||this.createCmd(),l&&u&&l.use((function(){e.regl.clear({color:[0,0,0,0],depth:1});for(var t=0;t<r.length;t++){var l=r[t],u=l.attributes,h=l.uniforms,d=l.k.count,p="px"===h.unit?0:1;e.D(c(c(c({},u),h),{unit:p,count:d,resolution:o,layerOpacity:i,iconCount:s,texture:a,mvp:n,isPick:!0,radiusScale:f.radius}))}})))},e.prototype.destroy=function(){this.regl=null,this.D=null},e.m=new e,e}();Kt.getInstance();var $t=t.Util.CommonUtil.pushArray,te=function(t){function e(e){var r=t.call(this,e)||this;r.CLASS_NAME="Icon",r.fusion=new Yt,r.B=new Kt,r.Lt=!1,r.zt=!1,r.Tt=[],r.It=0,r.Ot=new Map,r._animateLayerState={radius:1};var n=y.v;return r.zooms=void 0===e.zooms?n.zooms:e.zooms,r.visible=void 0===e.visible?n.visible:e.visible,r.zIndex=void 0===e.zIndex?n.zIndex:e.zIndex,r.opacity=void 0===e.opacity?n.opacity:e.opacity,r.createGLLayer(e),r.buryPoint.record(r.CLASS_NAME),r}return u(e,t),e.prototype.setStyle=function(e){t.prototype.setStyle.call(this,e),this.dataset=this.source.getDataset(),this.zt=!0,this.colorPick.clear(),this.Nt=null,this.Tt=[],this.Ot.clear(),this.dataset&&this.dataset.length>0&&this.loca&&this.loca.requestRender()},e.prototype.receiveDataset=function(t){this.dataset=t,this.setStyle(this.styleOptions),this.onAdd()},e.prototype.createRenderer=function(){t.prototype.createRenderer.call(this),this.loca&&this.loca.regl&&!this.B.regl&&(this.B.regl=this.loca.regl,this.loca.rendererManager.addRenderer(this.B))},e.prototype.beforeRender=function(){if(t.prototype.beforeRender.call(this),!this.fusion.regl&&this.loca&&(this.fusion.regl=this.loca.regl,this.loca.fusionManager.addFusion(this.fusion)),this.createRenderer(),this.source&&(this.dataset=this.source.getDataset()),this.fusion){var e=this.filterDataset(),r=e.willFusion,n=e.didFusion,i=e.didFusionDataset;if(this.zt?(this.At=this.meshes,this.meshes=this.fusion.fusion(i,this.styleOptions,this),this.zt=!1):this.zt||(this.meshes=n),r.length>0){var o=this.fusion.fusion(r,this.styleOptions,this);this.zt?this.Nt&&(this.meshes=o):this.meshes=$t(this.meshes,o)}}},e.prototype.render=function(){var t,e,r=this;if(this.loca&&this.loca.regl){if(this.loca.regl._refresh(),this.F){var n=null===(t=this.loca)||void 0===t?void 0:t.customCoords.getMVPMatrix(),i=this.projection.getResolution(null===(e=this.loca)||void 0===e?void 0:e.map.getZoom()),o=this.Nt?this.meshes:this.At;this.B&&o.length>0&&this.B.render({texture:this.F,iconCount:this.It,meshes:o,mvp:n,resolution:i,layerOpacity:this._getOpacity(),M:this._animateLayerState})}if(!this.Nt){var a=this.Tt;a&&a.length&&!this.Lt&&(this.Lt=!0,Qt({images:f(a,a,a),St:[64,64]},(function(t){var e,n;r.Lt=!1,r.Nt=t.Pt,t.Pt&&(r.F=null===(e=null==r?void 0:r.loca)||void 0===e?void 0:e.regl.texture({format:"rgba",width:r.Nt.width,jt:r.Nt.height,data:r.Nt}),r.It=a.length,null===(n=r.loca)||void 0===n||n.requestRender())}),(function(t){console.log("mergeImage error",t)})))}}},e.prototype.pickRender=function(){var t,e;if(this.loca&&this.loca.regl&&this.B){this.loca.regl._refresh();var r=null===(t=this.loca)||void 0===t?void 0:t.customCoords.getMVPMatrix(),n=this.projection.getResolution(null===(e=this.loca)||void 0===e?void 0:e.map.getZoom());this.B&&this.F&&this.B.pickRender({texture:this.F,iconCount:this.Tt.length,meshes:this.meshes,mvp:r,resolution:n,layerOpacity:this._getOpacity(),pickFbo:this._needPickFrame&&this._pickFbo,pickPos:this._pickPos,M:this._animateLayerState})}},e.prototype.destroy=function(){t.prototype.destroy.call(this),this.Nt=null,this.F=null},e.prototype.afterRender=function(){},e.prototype.Vt=function(){return{Bt:this.Ot,Mt:this.Tt}},e}(t.Layer);a.default.IconLayer=te;var ee=t.Util.CommonUtil.pushArray,re=function(e){function r(){return null!==e&&e.apply(this,arguments)||this}return u(r,e),r.getInstance=function(){return this.m},r.prototype.buildGeometry=function(){},r.prototype.buildStyle=function(e,r){for(var n=C.style,i=[],o=0;o<e.length;o++)if(e[o].features&&e[o].features.points){for(var a=e[o].features.points,s=t.StyleInstance.parse(a,r,n),l={},u=0;u<a.length;u++)if(s)for(var c in s.attributes){var f=s.attributes[c];l[c]||(l[c]=[]),f[u].length>0?ee(l[c],f[u]):l[c][l[c].length]=f[u]}i.push({attributes:l,uniforms:s.uniforms,g:s.g})}return i},r.prototype.fusion=function(e,r,n,i){if(!n.loca||!n.loca.regl)return[];var o=n.loca.regl,a=n.loca.customCoords,s=[];i=i||this.buildStyle(e,r);for(var l=0;l<e.length;l++){var u=e[l];if(u.features&&u.features.points&&i[l]){for(var c=u.features.points,f=i[l],h={index:[],vertex:[],radius:[],sideNo:[],color:[],rotation:[],pickColor:[]},d=f.attributes,p=d.altitude,m=d.height,v=d.radius,g=d.rotation,y=d.topColor,b=d.sideTopColor,x=d.sideBottomColor,_=f.uniforms.sideNumber,w=0;w<c.length;w++){var C=c[w],S=4*w,k=n.colorPick.add(C),A=C.coordinates;if("MultiPoint"===C.type)for(var M=0,z=A.length;M<z;M++){var O=A[M],E=this.Ut({vertex:[O[0],O[1],O[2]||p[w]],qt:a,height:m[w],pickColor:k,Gt:_,topColor:y.slice(S,S+4),sideTopColor:b.slice(S,S+4),sideBottomColor:x.slice(S,S+4),radius:v[w],rotation:g[w],hasSide:n.hasSide});t.Geometry.mergeTriangles(h,E,4),ee(h.color,E.O),ee(h.sideNo,E.Et),ee(h.radius,E.radius),ee(h.rotation,E.Ht),ee(h.pickColor,E.G)}else E=this.Ut({vertex:[A[0],A[1],A[2]||p[w]],qt:a,height:m[w],pickColor:k,Gt:_,topColor:y.slice(S,S+4),sideTopColor:b.slice(S,S+4),sideBottomColor:x.slice(S,S+4),radius:v[w],rotation:g[w],hasSide:n.hasSide}),t.Geometry.mergeTriangles(h,E,4),ee(h.color,E.O),ee(h.sideNo,E.Et),ee(h.radius,E.radius),ee(h.rotation,E.Ht),ee(h.pickColor,E.G)}s[l]={id:u.id,attributes:{position:{buffer:o.buffer(h.vertex),offset:0,P:16,_:!1,divisor:0},color:{buffer:o.buffer(h.color),offset:0,P:16,_:!1,divisor:0},sideNo:{buffer:o.buffer(h.sideNo),offset:0,P:4,_:!1,divisor:0},radius:{buffer:o.buffer(h.radius),offset:0,P:4,_:!1,divisor:0},rotation:{buffer:o.buffer(h.rotation),offset:0,P:4,_:!1,divisor:0},pickColor:{buffer:o.buffer(h.pickColor),offset:0,P:16,_:!1,divisor:0},index:o.elements({primitive:"triangles",type:"uint32",data:h.index})},uniforms:f.uniforms,g:f.g,k:{}}}}return s},r.prototype.updateStyle=function(t,e){for(var r=0,n=t.length;r<n;r++){for(var i=t[r],o=e[r].attributes,a=o.altitude,s=o.height,l=o.topColor,u=o.bottomColor,c=o.sideColor,f=o.textureSize,h=i.k.origin,d=h.position,p=h.color,m=i.k.S,v=m.top,g=m.bottom,y=m.C,b=m.W,x=new Float32Array(p.length/2),_=0,w=0,C=0,S=d.length;C<S;C+=3){var k=C/3*4,A=void 0,M=[-1,-1];C>=b[_]&&_++;var z=4*_;C>=g[w+1]&&w++,C<y[w]?(A=u,d[C+2]=a[_]):C>=y[w]&&C<v[w]?((C-y[w])/3%2==0?d[C+2]=a[_]:d[C+2]=s[_]+a[_],A=c,M=f.slice(2*_,2*_+2)):(A=l,d[C+2]=s[_]+a[_]),p[k]=A[z],p[k+1]=A[z+1],p[k+2]=A[z+2],p[k+3]=A[z+3],x[k/2]=M[0],x[k/2+1]=M[1]}i.attributes.position.buffer({data:d}),i.attributes.color.buffer({data:p}),i.attributes.textureSize.buffer({data:x}),i.uniforms=e[r].uniforms}},r.prototype.updateFrame=function(t){},r.prototype.destroy=function(){},r.prototype.Ut=function(t){var e=t.Gt,r=t.height,n=t.qt,i=t.vertex,o=t.topColor,a=t.sideTopColor,s=t.sideBottomColor,l=t.pickColor,u=t.radius,c=t.rotation,f=t.hasSide,h=[],d=[],p=[],m=[],v=[],g=[],y=[];this.Yt(y,e,v.length);for(var b=0;b<e;b++){var x=n.lngLatToCoord(i);this.Zt(d,p,[x[0],x[1],i[2]+r,1],o,h,l),m.push(b),g.push(u),v.push(c)}if(f)for(b=0;b<e;b++){x=n.lngLatToCoord(i);var _=v.length;y.push(_+1,_,_+3,_+3,_,_+2);for(var w=0;w<4;w++){var C=!!(w%2),S=C?a:s;this.Zt(d,p,[x[0],x[1],i[2]+(C?r:0),C?.5:0],S,h,l),m.push(w<2?b:b+.5),g.push(u),v.push(c)}}return{G:h,O:p,vertex:d,Et:m,Ht:v,radius:g,index:y}},r.prototype.Zt=function(t,e,r,n,i,o){var a=t.length,s=e.length;if(t[a]=r[0],t[a+1]=r[1],t[a+2]=r[2],t[a+3]=r[3],e[s]=n[0],e[s+1]=n[1],e[s+2]=n[2],e[s+3]=n[3],i&&o){var l=i.length;i[l]=o[0],i[l+1]=o[1],i[l+2]=o[2],i[l+3]=o[3]}},r.prototype.Yt=function(t,e,r){for(var n=0;n<e-2;n++)t.push(0,r+n+1,r+n+2);return t},r.m=new r,r}(t.GeometryFusion),ne=re.getInstance(),ie={vertex:"\n        precision highp float;\n\n        attribute vec4 position;\n        attribute vec4 color;\n        attribute float radius;\n        attribute float rotation;\n        // 边的序号, 代表当前的顶点序号\n        // 序号从正北方向开始，顺时针数\n        attribute float sideNo;\n\n        varying vec3 vNormal;\n        varying vec4 vColor;\n        varying vec3 vPosition;\n        "+t.ColorGLSL.getColorShader().vertex+"\n\n        uniform mat4 mvp;\n        // unit: px=0, meter=1\n        uniform float unit;\n        uniform float resolution;\n        uniform float heightScale;\n        uniform float altitudeScale;\n        uniform float rotationScale;\n        uniform float radiusScale;\n        uniform float sideNumber;\n\n        // z 轴旋转\n        vec2 rotateZ(vec2 a, float rad) {\n            float s = sin(rad);\n            float c = cos(rad);\n            float x = a.x;\n            float y = a.y;\n\n            // x = x * c - y * s;\n            // y = y * c + x * s;\n            // return vec2(x, y);\n            mat2 rotate = mat2(\n                c, -s,\n                s, c\n            );\n            return a * rotate;\n        }\n        // 根据序号，计算 normal 和顶点位置\n        struct vecInfo {\n            vec3 position;\n            vec3 normal;\n        };\n        vecInfo getVec() {\n            vec2 ori = vec2(0, 1);\n            float PI = 3.14159265;\n            float rot = rotation / 180.0 * PI * rotationScale;\n            float angle = PI * 2.0 / sideNumber;\n            // 如果是像素，需要计算为米\n            float r = unit == 1.0 ? 1.0 : resolution;\n            vec2 pos = rotateZ(ori, -angle * ceil(sideNo) - rot) * radius * radiusScale * r;\n            vec3 normal = vec3(0,0,1);\n\n            // 顶面 normal 就是 (0,0,1)\n            // 否则就是侧面，我们需要根据面定义侧面向量\n            // w 分量 =1.0，说明是顶面\n            // w = 0.5 说明是侧面的顶点\n            // w = 0.0 说明是侧面的底面\n            if(position.w != 1.0) {\n                normal = vec3(rotateZ(ori, -angle * (floor(sideNo) + 0.5) - rot), 0);\n            }\n            vecInfo result;\n            result.position =vec3(pos + position.xy, position.z);\n            result.normal = normal;\n            return result;\n        }\n\n        void main() {\n            vecInfo info = getVec();\n            float r = unit == 1.0 ? 1.0 : resolution;\n            vec3 realPos = info.position.xyz;\n            // 底部\n            if(position.w == 0.0) {\n                realPos = vec3(realPos.xy, realPos.z * r * altitudeScale);\n            }\n            // 顶部\n            if(position.w > 0.0) {\n                realPos = vec3(realPos.xy, realPos.z * r * heightScale);\n            }\n            vColor = color;\n            vNormal = info.normal;\n            vPosition = realPos;\n            gl_Position = mvp * vec4(realPos, 1.0);\n            "+t.ColorGLSL.getColorShader().mainVert+"\n        }\n    ",fragment:"\n        precision highp float;\n        varying vec4 vColor;\n\n        // 如果需要光照，这两个变量是必须的\n        varying vec3 vNormal;\n        varying vec3 vPosition;\n\n        uniform float opacity;\n\n        "+t.Light.getLightShader()+"\n        "+t.ColorGLSL.getColorShader().fragment+"\n\n        void main() {\n            gl_FragColor = vColor;\n            if(acceptLight) {\n                gl_FragColor.rgb = lightColor(gl_FragColor.rgb);\n            }\n\n            gl_FragColor.a *= opacity;\n            "+t.ColorGLSL.getColorShader().mainFrag+"\n        }\n    "},oe=function(){function e(t){this.regl=t,this.createCmd()}return e.prototype.createCmd=function(){if(this.regl){var e=this.regl;this.lt=e({frag:ie.fragment,vert:ie.vertex,attributes:c({position:e.prop("position"),color:e.prop("color"),sideNo:e.prop("sideNo"),radius:e.prop("radius"),rotation:e.prop("rotation")},t.ColorGLSL.getColor(e).attribute),uniforms:c(c({mvp:e.prop("mvp"),resolution:e.prop("resolution"),unit:e.prop("unit"),opacity:e.prop("layerOpacity"),sideNumber:e.prop("sideNumber"),altitudeScale:e.prop("altitudeScale"),heightScale:e.prop("heightScale"),radiusScale:e.prop("radiusScale"),rotationScale:e.prop("rotationScale")},t.ColorGLSL.getColor(e).uniform),t.Light.getLights(e)),blend:{enable:!0,func:E("normal")},cull:{enable:e.prop("cullEnable"),face:e.prop("cullface")},frontFace:"cw",depth:{enable:!0,func:"lequal"},elements:e.prop("index")})}},e.prototype.render=function(t){var e=t.meshes,r=t.mvp,n=t.V,i=t.layerOpacity,o=t.cullface,a=t.cameraPosition,s=t.shininess,l=t.acceptLight,u=t.M,f=t.resolution,h=t.isPick,d=void 0!==h&&h;if(this.regl&&!(e.length<1)){this.lt||this.createCmd();for(var p=u.height,m=u.altitude,v=u.radius,g=u.rotation,y=0;y<e.length;y++){var b=e[y],x=b.attributes,_=b.uniforms,w="none"!==o,C="front"===o?"front":"back";this.lt(c(c(c(c({},x),{unit:"px"===_.unit?0:1,layerOpacity:i,mvp:r}),n),{cullEnable:w,cullface:C,cameraPosition:a,shininess:s,acceptLight:l,isPick:d,resolution:f,sideNumber:_.sideNumber,heightScale:p,altitudeScale:m,rotationScale:g,radiusScale:v}))}}},e.prototype.pickRender=function(t){var e=this;this.regl&&(this.lt||this.createCmd(),t.isPick=!0,t.pickFbo&&t.pickPos&&t.pickFbo.use((function(){e.regl.clear({color:[0,0,0,0],depth:1}),e.render(t)})))},e.prototype.destroy=function(){this.regl=null,this.lt=null},e}(),ae=t.Util.CommonUtil.pushArray,se=function(t){function e(e){var r=t.call(this,e)||this;r.CLASS_NAME="Prism",r.fusion=new re,r.B=new oe,r._animateLayerState={radius:1,height:1,altitude:1,rotation:1},r.zt=!1;var n=C.v;return r.zooms=void 0===e.zooms?n.zooms:e.zooms,r.visible=void 0===e.visible?n.visible:e.visible,r.zIndex=void 0===e.zIndex?n.zIndex:e.zIndex,r.opacity=void 0===e.opacity?n.opacity:e.opacity,r.shininess=void 0===e.shininess?n.shininess:e.shininess,r.acceptLight=void 0===e.acceptLight?n.acceptLight:e.acceptLight,r.hasSide=void 0===e.hasSide?n.hasSide:e.hasSide,r.cullface=e.cullface||n.cullface,r.fusion=ne,r.createGLLayer(e),r.buryPoint.record(r.CLASS_NAME),r}return u(e,t),e.prototype.setStyle=function(e){t.prototype.setStyle.call(this,e),this.dataset=this.source.getDataset(),this.zt=!0,this.colorPick.clear(),this.loca&&this.dataset&&this.dataset.length>0&&this.loca.requestRender()},e.prototype.receiveDataset=function(t){this.dataset=t,this.setStyle(this.styleOptions),this.onAdd()},e.prototype.createRenderer=function(){t.prototype.createRenderer.call(this),this.loca&&this.loca.regl&&!this.B.regl&&(this.B.regl=this.loca.regl,this.loca.rendererManager.addRenderer(this.B))},e.prototype.beforeRender=function(){if(t.prototype.beforeRender.call(this),this.loca&&this.loca.fusionManager.addFusion(this.fusion),this.createRenderer(),this.source&&(this.dataset=this.source.getDataset()),this.fusion){var e=this.filterDataset(),r=e.willFusion,n=e.didFusion,i=e.didFusionDataset;if(this.zt?(this.meshes=this.fusion.fusion(i,this.styleOptions,this),this.zt=!1):this.zt||(this.meshes=n),r.length>0){var o=this.fusion.fusion(r,this.styleOptions,this);this.meshes=ae(this.meshes,o)}}},e.prototype.render=function(){var t,e;if(this.loca&&this.loca.regl){this.loca.regl._refresh();var r=null===(t=this.loca)||void 0===t?void 0:t.customCoords.getMVPMatrix(),n=this.projection.getResolution(null===(e=this.loca)||void 0===e?void 0:e.map.getZoom()),i=this.loca.customCoords.getCameraParams().position,o=this.loca.getLights();this.B&&this.meshes.length>0&&this.B.render({meshes:this.meshes,mvp:r,resolution:n,layerOpacity:this._getOpacity(),M:this._animateLayerState,V:o,cullface:this.cullface,cameraPosition:i,shininess:this.shininess,acceptLight:this.acceptLight,isPick:!1})}},e.prototype.pickRender=function(){var t,e;if(this.loca&&this.loca.regl){this.loca.regl._refresh();var r=null===(t=this.loca)||void 0===t?void 0:t.customCoords.getMVPMatrix(),n=this.projection.getResolution(null===(e=this.loca)||void 0===e?void 0:e.map.getZoom()),i=this.loca.customCoords.getCameraParams().position,o=this.loca.getLights();this.B&&this.meshes.length>0&&this.B.pickRender({meshes:this.meshes,mvp:r,resolution:n,layerOpacity:this._getOpacity(),M:this._animateLayerState,V:o,cullface:this.cullface,cameraPosition:i,shininess:this.shininess,acceptLight:this.acceptLight,isPick:!0,pickFbo:this._needPickFrame&&this._pickFbo,pickPos:this._pickPos})}},e.prototype.afterRender=function(){},e.prototype.destroy=function(){t.prototype.destroy.call(this),this.B.regl=null,this.B=null},e}(t.Layer);a.default.PrismLayer=se;var le=t.Util.CommonUtil.pushArray,ue=function(r){function n(){return null!==r&&r.apply(this,arguments)||this}return u(n,r),n.prototype.buildGeometry=function(){},n.prototype.buildStyle=function(r,n,i){var o=w.style,a=[];if(!i.loca)return{};for(var s=i.loca.customCoords,l=0;l<r.length;l++)if(r[l].features&&r[l].features.lines){for(var u=[],c=0,f=r[l].features.lines;c<f.length;c++){var h=f[c],d=h.coordinates,p=h.type;if("LineString"===p){var m=d[0],v=d[d.length-1],g=s.lngLatToCoord(m),y=s.lngLatToCoord(v),b=e.vec2.distance(g,y);u.push({distance:b,link:h})}if("MultiLineString"===p)for(var x=0;x<d.length;x++){var _=d[x],C=[_[0],_[_.length-1]];m=C[0],v=C[1],g=s.lngLatToCoord(m),y=s.lngLatToCoord(v),b=e.vec2.distance(g,y),u.push({distance:b,link:{coordinates:h.coordinates[x],properties:h.properties}})}}var S=t.StyleInstance.parse(u,n,o);a.push(S)}return a},n.prototype.fusion=function(t,r,n,i){if(!this.regl||!n.loca)return[];var o=[];i=i||this.buildStyle(t,r,n);for(var a=n.loca.customCoords,s=0;s<t.length;s++){var l=t[s];if(l.features&&l.features.lines){for(var u=l.features.lines,c=i[s],f=c.attributes,h=c.uniforms,d={vertex:[],color:[],pickColor:[],lineWidth:[],distance:[],speed:[],lineDir:[],dash:[],index:[]},p=0;p<u.length;p++){var m=u[p],v=m.coordinates,g=f.lineColors,y=f.height,b=f.lineWidth,x=f.dash,_=f.speed,w=h.smoothSteps,C=h.maxHeightScale,S=x[p],k=_[p],A=b[p],M=(A[1]-A[0])/(w-1),z=n.colorPick.add(m);if("MultiLineString"===m.type)for(var O=0,E=v.length;O<E;O++){var P=v[O],L=y[O],T=[],D=g[O],R=[P[0],P[P.length-1]],I=R[0],F=I[0],B=I[1],j=R[1],V={x:F,y:B,z:0},N={x:H=j[0],y:Z=j[1],z:0},U=[H-F,Z-B,0],G=[F-H,B-Z,0],W=e.vec3.cross(new Float32Array(3),U,[0,0,-1]),q=e.vec3.cross(new Float32Array(3),U,[0,0,1]);0===L?(T=ot(V,N,D.length),this.Xt(T,d,a,{Jt:D,Kt:A,Qt:W,pickColor:z,lineDir:U,$t:G,ti:M,ii:q,dash:S},!1)):(T=nt(V,{x:F-(F-H)/2,y:B-(B-Z)/2,z:L},N,.5,w),this.Xt(T,d,a,{Jt:D,Kt:A,Qt:W,pickColor:z,lineDir:U,$t:G,ti:M,ii:q,dash:S},!0))}else{var H,Z,Q=[v[0],v[v.length-1]],X=Q[0],Y=(F=X[0],B=X[1],Q[1]);U=[(H=Y[0])-F,(Z=Y[1])-B,0],G=[F-H,B-Z,0],W=e.vec3.cross(new Float32Array(3),U,[0,0,-1]),q=e.vec3.cross(new Float32Array(3),U,[0,0,1]),V={x:F,y:B,z:0},N={x:H,y:Z,z:0},L=y[p],T=[],D=g[p],0===L?(T=ot(V,N,Math.max(D.length,2)),this.Xt(T,d,a,{Jt:D,Kt:A,Qt:W,pickColor:z,lineDir:U,$t:G,ti:M,ii:q,dash:S,speed:k},!1)):(T=nt(V,{x:F-(F-H)*C,y:B-(B-Z)*C,z:L},N,.5,w),this.Xt(T,d,a,{Jt:D,Kt:A,Qt:W,pickColor:z,lineDir:U,$t:G,ti:M,ii:q,dash:S,speed:k},!0))}}o[s]={id:l.id,attributes:{color:{buffer:this.regl.buffer(d.color),offset:0,P:16,_:!1,divisor:0},dash:{buffer:this.regl.buffer(d.dash),offset:0,P:16,_:!1,divisor:0},speed:{buffer:this.regl.buffer(d.speed),offset:0,P:4,_:!1,divisor:0},lineDir:{buffer:this.regl.buffer(d.lineDir),offset:0,P:12,_:!1,divisor:0},lineWidth:{buffer:this.regl.buffer(d.lineWidth),offset:0,P:4,_:!1,divisor:0},distance:{buffer:this.regl.buffer(d.distance),offset:0,P:8,_:!1,divisor:0},pickColor:{buffer:this.regl.buffer(d.pickColor),offset:0,P:16,_:!1,divisor:0},position:{buffer:this.regl.buffer(d.vertex),offset:0,P:12,_:!1,divisor:0},index:this.regl.elements({primitive:"triangles",type:"uint32",data:d.index})},uniforms:c.uniforms,g:c.g}}}return o},n.prototype.updateStyle=function(t,e,r,n){if(!r.loca)return[];var i=r.dataset;return this.fusion(i,e,r,n)},n.prototype.updateFrame=function(t){},n.prototype.destroy=function(){this.regl=null},n.prototype.Xt=function(r,n,i,o,a){for(var s=o.Jt,l=o.speed,u=o.Kt,c=o.dash,f=o.Qt,h=o.pickColor,d=o.ti,p=o.ii,m=0,v=!1,g=0,y={ni:[],ei:[],coords:[]},b=0,x=r.length;b<x-1;b++){var _=r[b],w=r[b+1],C=v||i.lngLatToCoord([_.x,_.y]),S=[(O=i.lngLatToCoord([w.x,w.y]))[0]-C[0],O[1]-C[1],w.z-_.z],k=e.vec2.len(S);v||y.coords.push(C),y.coords.push(O),y.ei.push(S),y.ni.push(m),g+=k,m=k+m,v=O}var A=y.ni,M=y.ei,z=y.coords;for(b=0,x=r.length;b<x-1;b++){_=r[b],w=r[b+1],C=z[b];var O=z[b+1],E=(S=M[b],st(s,_.t)),P=st(s,w.t);a||(E=s[b],P=s[b+1]),k=A[b];var L=A[b-1]||0,T=M[b-1]||S,D=this.ri({oi:[C[0],C[1],_.z],color:E,Qt:f,lineDir:T,width:u[0]+d*b,distance:[L,g],pickColor:h,dash:c,speed:l},{oi:[O[0],O[1],w.z],color:P,Qt:p,lineDir:S,width:u[0]+d*(b+1),distance:[k,g],pickColor:h,dash:c,speed:l});t.Geometry.mergeTriangles(n,D,3),le(n.color,D.color),le(n.lineWidth,D.width),le(n.distance,D.distance),le(n.lineDir,D.lineDir),le(n.pickColor,D.pickColor),le(n.dash,D.dash),le(n.speed,D.speed)}},n.prototype.ri=function(t,e){var r=t.oi,n=t.color,i=t.width,o=t.pickColor,a=t.lineDir,s=t.distance,l=t.dash,u=t.speed,c=e.oi,h=e.color,d=e.width,p=e.pickColor,m=e.lineDir,v=e.distance,g=e.dash,y=e.speed,b=f(r,r,c,c),x=f(n,n,h,h),_=[i,i,d,d];return{vertex:b,distance:f(s,s,v,v),speed:[u,u,y,y],color:x,width:_,pickColor:f(o,o,p,p),lineDir:f(a,[-a[0],-a[1],-a[2]],m,[-m[0],-m[1],-m[2]]),dash:f(l,l,g,g),index:[1,0,2,2,3,1]}},n}(t.GeometryFusion),ce={vertex:"\n        precision highp float;\n        attribute vec3 position;\n        attribute vec4 color;\n        // attribute vec3 normal;\n        attribute vec3 lineDir;\n        attribute vec3 vertexNext;\n        attribute float lineWidth;\n        attribute vec2 distance;\n        attribute vec4 dash;\n        attribute float speed;\n        varying vec4 vColor;\n        varying vec4 vDash;\n        varying vec2 vDistance;\n        varying float vSpeed;\n        uniform mat4 mvp;\n        uniform vec3 cameraPosition;\n        uniform float unit; // 0: px; 1: meter;\n        uniform float resolution;\n        "+t.ColorGLSL.getColorShader().vertex+"\n\n        void main() {\n            float res = unit == 0.0 ? resolution : 1.0;\n            // 计算当前顶点到相机的向量\n            vec3 cameraDir = vec3(cameraPosition - position);\n            vec3 cameraNor = cross(cameraDir, lineDir);\n\n            vColor = color;\n            vDash = dash;\n            vSpeed = speed;\n            vDistance = distance;\n            vec3 pos = position + normalize(cameraNor) * (lineWidth / 2.0) * res;\n            gl_Position = mvp * vec4(pos, 1.0);\n            "+t.ColorGLSL.getColorShader().mainVert+"\n        }\n    ",fragment:"\n        precision highp float;\n        varying vec4 vColor;\n        varying vec4 vDash;\n        varying vec2 vDistance;\n        varying float vSpeed;\n        uniform float opacity;\n        uniform float animateCounter;\n        uniform float resolution;\n        uniform float flowLength;\n        uniform vec4 headColor;\n        uniform vec4 trailColor;\n        uniform float unit;\n        "+t.ColorGLSL.getColorShader().fragment+"\n\n        void main() {\n            float res = unit == 0.0 ? resolution : 1.0;\n            float curDist = vDistance.x - animateCounter;\n            float distPixel = vDistance.x / res;\n            float offset = mod(distPixel, vDash.r + vDash.g + vDash.b + vDash.a);\n            if(offset > vDash.r && offset < vDash.r + vDash.g) {\n                discard;\n            } else if(offset > vDash.r + vDash.g + vDash.b) {\n                discard;\n            }\n            float op = offset / (vDash.r + vDash.g + vDash.b + vDash.a);\n            gl_FragColor = vColor;\n\n            // 脉冲粒子\n            float ligLen = flowLength * res;\n            float curTop = animateCounter * vSpeed * res / 1000.0 * 60.0;\n            float realCurTop = mod(curTop, vDistance.y);\n            float realCurBottom = mod(curTop - ligLen, vDistance.y);\n            float delta = 1.0 - (curDist - realCurBottom) / ligLen;\n\n            vec4 resultColor = vColor;\n\n            // 说明是在末端，头部已经出了端点\n            if(realCurTop < realCurBottom) {\n                // 末端\n                if(curDist > realCurBottom) {\n                    resultColor = mix(headColor, trailColor, delta);\n                }\n                // 始端\n                if(curDist < realCurTop) {\n                    float delta = 1.0 - (vDistance.y - realCurBottom + curDist) / ligLen;\n                    resultColor = mix(headColor, trailColor, delta);\n                }\n                gl_FragColor = mix(vColor, resultColor, resultColor.a);\n            } else {\n                if(curDist < realCurTop && curDist > realCurBottom) {\n                    resultColor = mix(headColor, trailColor, delta);\n                }\n                gl_FragColor = mix(vColor, resultColor, resultColor.a);\n            }\n            gl_FragColor.a *= opacity;\n            "+t.ColorGLSL.getColorShader().mainFrag+"\n        }\n    "},fe=function(){function e(t){this.regl=t,this.createCmd()}return e.prototype.createCmd=function(){if(this.regl){var e=this.regl;this.D=e({frag:ce.fragment,vert:ce.vertex,attributes:c({position:e.prop("position"),color:e.prop("color"),lineDir:e.prop("lineDir"),lineWidth:e.prop("lineWidth"),distance:e.prop("distance"),dash:e.prop("dash"),speed:e.prop("speed")},t.ColorGLSL.getColor(e).attribute),uniforms:c({mvp:e.prop("mvp"),opacity:e.prop("opacity"),resolution:e.prop("resolution"),flowLength:e.prop("flowLength"),unit:e.prop("unit"),cameraPosition:e.prop("cameraPosition"),animateCounter:e.prop("animateCounter"),trailColor:e.prop("trailColor"),headColor:e.prop("headColor")},t.ColorGLSL.getColor(e).uniform),cull:{enable:!1},depth:{enable:e.prop("depth")},blend:{enable:!0,func:e.prop("blendFun")},elements:e.prop("index")})}},e.prototype.render=function(t){var e=t.meshes,r=t.mvp,n=t.animateCounter,i=t.opacity,o=t.resolution,a=t.depth,s=t.cameraPosition;if(this.regl){this.D||this.createCmd();for(var l=0;l<e.length;l++){var u=e[l],f=u.attributes,h=u.uniforms,d=h.unit,p=h.flowLength,m=h.trailColor,v=h.headColor;this.D(c(c({blendFun:E()},f),{cameraPosition:s,mvp:r,animateCounter:n,unit:"px"===d?0:1,resolution:o,opacity:i,depth:a,trailColor:m,headColor:v,flowLength:p,isPick:!1}))}}},e.prototype.pickRender=function(t){var e=this,r=t.meshes,n=t.animateCounter,i=t.mvp,o=t.opacity,a=t.pickFbo,s=t.pickPos,l=t.resolution,u=t.cameraPosition,f=t.depth;this.regl&&(this.D||this.createCmd(),a&&s&&a.use((function(){e.regl.clear({color:[0,0,0,0],depth:1});for(var t=0;t<r.length;t++){var a=r[t],s=a.attributes,h=a.uniforms,d=h.unit,p=h.flowLength,m=h.trailColor,v=h.headColor;e.D(c(c({blendFun:E()},s),{cameraPosition:u,mvp:i,animateCounter:n,unit:"px"===d?0:1,resolution:l,opacity:o,depth:f,trailColor:m,headColor:v,flowLength:p,isPick:!0}))}})))},e.prototype.destroy=function(){this.regl=null,this.D=null},e}(),he=t.Util.CommonUtil.pushArray,de=function(t){function e(e){var r=t.call(this,e)||this;r.CLASS_NAME="PulseLink",r.fusion=new ue,r.B=new fe,r.depth=!0,r.et=0;var n=w.v;return r.zooms=void 0===e.zooms?n.zooms:e.zooms,r.zIndex=void 0===e.zIndex?n.zIndex:e.zIndex,r.opacity=void 0===e.opacity?n.opacity:e.opacity,r.visible=void 0===e.visible?n.visible:e.visible,r.depth=void 0===e.depth?n.depth:e.depth,r.createGLLayer(e),r.buryPoint.record(r.CLASS_NAME),r}return u(e,t),e.prototype.receiveDataset=function(t){this.dataset=t,this.setStyle(this.styleOptions),this.onAdd()},e.prototype.setStyle=function(e){if(t.prototype.setStyle.call(this,e),this.dataset=this.source.getDataset(),this.meshes=[],this.dataset&&this.dataset.length>0&&this.meshes){var r=this.filterDataset().didFusion,n=this.fusion.buildStyle(this.dataset,this.styleOptions,this);this.meshes=this.fusion.updateStyle(r,this.styleOptions,this,n),this.loca&&this.loca.requestRender()}},e.prototype.createRenderer=function(){t.prototype.createRenderer.call(this),this.loca&&this.loca.regl&&!this.B.regl&&(this.B.regl=this.loca.regl,this.loca.rendererManager.addRenderer(this.B))},e.prototype.beforeRender=function(){if(t.prototype.beforeRender.call(this),!this.fusion.regl&&this.loca&&(this.fusion.regl=this.loca.regl,this.loca.fusionManager.addFusion(this.fusion)),this.createRenderer(),this.source&&(this.dataset=this.source.getDataset()),this.fusion){var e=this.filterDataset(),r=e.willFusion,n=e.didFusion;this.fusion.updateFrame(n),r.length>0&&(this.meshes=he(n,this.fusion.fusion(r,this.styleOptions,this))),this.et++}},e.prototype.render=function(){var t,e;if(this.loca&&this.loca.regl){this.loca.regl._refresh();var r=null===(t=this.loca)||void 0===t?void 0:t.customCoords.getMVPMatrix(),n=this.projection.getResolution(null===(e=this.loca)||void 0===e?void 0:e.map.getZoom()),i=this.loca.customCoords.getCameraParams().position;this.B&&this.meshes.length>0&&this.B.render({depth:this.depth,resolution:n,meshes:this.meshes,mvp:r,animateCounter:this.et,cameraPosition:i,opacity:this._getOpacity()})}},e.prototype.pickRender=function(){var t,e;if(this.loca&&this.loca.regl){this.loca.regl._refresh();var r=null===(t=this.loca)||void 0===t?void 0:t.customCoords.getMVPMatrix(),n=this.loca.customCoords.getCameraParams().position,i=this.projection.getResolution(null===(e=this.loca)||void 0===e?void 0:e.map.getZoom());this.B&&this.B.pickRender({depth:this.depth,meshes:this.meshes,mvp:r,resolution:i,cameraPosition:n,animateCounter:this.et,opacity:this._getOpacity(),pickFbo:this._needPickFrame&&this._pickFbo,pickPos:this._pickPos})}},e.prototype.afterRender=function(){},e}(t.Layer);return a.default.PulseLinkLayer=de,a.default.PulseLineLayer=Ct,a.default.PulseLinkLayer=de,a.default.PolygonLayer=D,a.default.LineLayer=V,a.default.HeatMapLayer=Q,a.default.ScatterLayer=rt,a.default.LinkLayer=dt,a.default.GridLayer=Bt,a.default.HexagonLayer=Vt,a.default.PointLayer=Ht,a.default.IconLayer=te,a.default.PrismLayer=se,a.default.Dat=X,a.default.version="2.0.0",a.default}(i,Ge,Kr,kn)}))}));
